Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions crates/agents/src/auth_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -843,9 +843,7 @@ fn sanitize_and_read_dsh_credentials(dsh_dir: &Path) -> Option<String> {
.map(str::to_string)
})
});
if mutated
&& let Ok(serialized) = serde_yaml::to_string(&doc)
{
if mutated && let Ok(serialized) = serde_yaml::to_string(&doc) {
let _ = std::fs::write(&path, serialized);
}
api_key
Expand All @@ -858,9 +856,7 @@ fn apply_dsh_native_launch_env(env: &mut HashMap<String, String>) {
.get("DEEPSEEK_API_KEY")
.map(|value| value.trim())
.is_some_and(|value| !value.is_empty());
if !has_env_key
&& let Some(api_key) = credential_key
{
if !has_env_key && let Some(api_key) = credential_key {
env.insert("DEEPSEEK_API_KEY".to_string(), api_key);
}
if let Some(base_url) = env.get("DEEPSEEK_BASE_URL").cloned() {
Expand Down Expand Up @@ -2187,4 +2183,3 @@ mod tests {
);
}
}

6 changes: 2 additions & 4 deletions crates/agents/src/cli_exposure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,8 @@ pub fn export_managed_bun_to_user_environment(
let source_exe = bun_bin_dir.join("bun.exe");
let dest_exe = user_bin.join("bun.exe");
if source_exe.is_file() && !paths_refer_to_same_file(&source_exe, &dest_exe) {
let temporary = dest_exe.with_file_name(format!(
".bun.exe.vibex-toolchain-{}.tmp",
Uuid::new_v4()
));
let temporary =
dest_exe.with_file_name(format!(".bun.exe.vibex-toolchain-{}.tmp", Uuid::new_v4()));
if fs::copy(&source_exe, &temporary).is_ok()
&& replace_file_atomically(&temporary, &dest_exe).is_err()
{
Expand Down
1 change: 0 additions & 1 deletion crates/agents/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5219,4 +5219,3 @@ mod tests {
);
}
}

3 changes: 2 additions & 1 deletion crates/agents/src/manager/runner/controls_apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ impl AgentConnectionRunner {
let (was_plan, mode_uses_set_mode) = {
let mut controls = self.session_controls.write().await;
let stored = controls.entry(session_id).or_default();
let (_, current_mode) = session_modes_from_config_options(&stored.config_options);
let (_, current_mode) =
session_modes_from_config_options(&stored.config_options);
let was_plan = current_mode.as_deref() == Some("plan")
|| stored
.modes
Expand Down
3 changes: 2 additions & 1 deletion crates/agents/src/manager/runner/controls_emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ impl AgentConnectionRunner {
OMP_YOLO_MODE_ID,
);
if let Some(ref mut mode_state) = entry.modes {
mode_state.current_mode_id = acp::schema::v1::SessionModeId::new(OMP_YOLO_MODE_ID);
mode_state.current_mode_id =
acp::schema::v1::SessionModeId::new(OMP_YOLO_MODE_ID);
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion crates/agents/src/native_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1741,7 +1741,10 @@ mod tests {
let home = Path::new("/tmp/vibex-home");
let environment = BTreeMap::from([(
"PI_CODING_AGENT_DIR".to_string(),
home.join(".pi").join("agent").to_string_lossy().into_owned(),
home.join(".pi")
.join("agent")
.to_string_lossy()
.into_owned(),
)]);
assert_eq!(
omp_config_path(home, &environment),
Expand Down
15 changes: 7 additions & 8 deletions crates/agents/src/omp_providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,9 @@ fn provider_key(providers: &Mapping, provider_id: &str, name: &str, api_url: &st
.as_mapping()
.is_some_and(|node| text(node, "baseUrl") == api_url);
same_url.then(|| key.as_str().unwrap_or("").to_string())
}) {
if !existing.is_empty() {
return existing;
}
}) && !existing.is_empty()
{
return existing;
}
let slug = slug(name);
if slug.is_empty() {
Expand Down Expand Up @@ -241,10 +240,10 @@ fn model_ids(raw: &str) -> Vec<String> {
}
}
}
if ids.is_empty() {
if let Some(id) = value.as_str() {
ids.push(id.to_string());
}
if ids.is_empty()
&& let Some(id) = value.as_str()
{
ids.push(id.to_string());
}
ids
}
Expand Down
20 changes: 8 additions & 12 deletions crates/agents/src/skills.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2199,9 +2199,7 @@ fn synthetic_weekly_installs(installs: Option<u64>, seed: &str) -> Vec<u64> {
.map(|idx| {
let growth = 60 + idx * 10;
let wave = ((hash.wrapping_add(idx * 13)) % 23) + 90;
base.saturating_mul(growth)
.saturating_mul(wave)
/ 10_000
base.saturating_mul(growth).saturating_mul(wave) / 10_000
})
.collect()
}
Expand Down Expand Up @@ -2397,8 +2395,7 @@ pub async fn search_skill_market_with_view(
row.id
};
let known = snapshot.iter().find(|s| {
s.id.eq_ignore_ascii_case(&id)
|| s.skill_id.eq_ignore_ascii_case(&row.skill_id)
s.id.eq_ignore_ascii_case(&id) || s.skill_id.eq_ignore_ascii_case(&row.skill_id)
});
let weekly_installs = if !row.weekly_installs.is_empty() {
row.weekly_installs
Expand Down Expand Up @@ -2445,9 +2442,8 @@ fn parse_skill_description(html: &str) -> Option<String> {
}

fn html_fragment_to_markdown(fragment: &str) -> String {
static TAG_RE: std::sync::LazyLock<regex::Regex> = std::sync::LazyLock::new(|| {
regex::Regex::new(r"<[^>]+>").expect("valid html tag regex")
});
static TAG_RE: std::sync::LazyLock<regex::Regex> =
std::sync::LazyLock::new(|| regex::Regex::new(r"<[^>]+>").expect("valid html tag regex"));
let mut s = fragment
.replace("<h1>", "\n# ")
.replace("</h1>", "\n\n")
Expand Down Expand Up @@ -2517,9 +2513,7 @@ fn parse_skill_markdown_from_html(
}
}
description.map(|desc| {
format!(
"---\nname: {skill_id}\nsource: {source}\n---\n\n# {skill_id}\n\n{desc}\n"
)
format!("---\nname: {skill_id}\nsource: {source}\n---\n\n# {skill_id}\n\n{desc}\n")
})
}

Expand All @@ -2536,7 +2530,9 @@ async fn fetch_github_raw_skill_markdown(
let candidates = [
format!("https://raw.githubusercontent.com/{clean_source}/HEAD/skills/{clean_id}/SKILL.md"),
format!("https://raw.githubusercontent.com/{clean_source}/HEAD/{clean_id}/SKILL.md"),
format!("https://raw.githubusercontent.com/{clean_source}/HEAD/.claude/skills/{clean_id}/SKILL.md"),
format!(
"https://raw.githubusercontent.com/{clean_source}/HEAD/.claude/skills/{clean_id}/SKILL.md"
),
format!("https://raw.githubusercontent.com/{clean_source}/HEAD/SKILL.md"),
];
for url in candidates {
Expand Down
6 changes: 1 addition & 5 deletions crates/agents/tests/built_in_profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1460,9 +1460,5 @@ fn omp_native_config_exposes_approval_mode_select_field() {
assert_eq!(field.kind, NativeConfigFieldKind::Select);
assert_eq!(field.surface, NativeConfigSurface::Configuration);
let values: Vec<_> = field.options.iter().map(|(value, _)| *value).collect();
assert_eq!(
values,
["always-ask", "always-ask-cached", "write", "yolo"]
);
assert_eq!(values, ["always-ask", "always-ask-cached", "write", "yolo"]);
}

50 changes: 39 additions & 11 deletions crates/conversations/src/collaboration_sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ pub async fn list_dm_messages(

let (mut pre, post) = match since_seq {
Some(since) => {
let pre = list_pre_cutover_dm_messages(
let mut pre = list_pre_cutover_dm_messages(
pool,
conversation_id,
Some(since),
Expand All @@ -1255,6 +1255,10 @@ pub async fn list_dm_messages(
)
.await?;
let post = dm_space_messages_since(pool, &thread_id, since).await?;
if pre.is_empty() && post.is_empty() && cutover_seq == 0 {
pre = list_pre_cutover_dm_messages(pool, conversation_id, Some(since), limit, None)
.await?;
}
(pre, post)
}
None => {
Expand All @@ -1276,7 +1280,8 @@ pub async fn list_dm_messages(
.await?
};
if pre.is_empty() && post.is_empty() && cutover_seq == 0 {
pre = list_pre_cutover_dm_messages(pool, conversation_id, None, limit, None).await?;
pre =
list_pre_cutover_dm_messages(pool, conversation_id, None, limit, None).await?;
}
(pre, post)
}
Expand Down Expand Up @@ -2126,7 +2131,10 @@ pub async fn identity_members_for_conversations_batch(
let rows = query.fetch_all(pool).await.map_err(db_err)?;
let mut out = HashMap::with_capacity(rows.len());
for (conv_id, member_id, is_sup, avatar, color) in rows {
if let Some(cid) = conv_id.map(|s| s.trim().to_string()).filter(|s| !s.is_empty()) {
if let Some(cid) = conv_id
.map(|s| s.trim().to_string())
.filter(|s| !s.is_empty())
{
out.entry(cid)
.or_insert((member_id, is_sup != 0, avatar, color));
}
Expand All @@ -2137,7 +2145,10 @@ pub async fn identity_members_for_conversations_batch(
if !out.contains_key(*cid)
&& let Ok(uuid) = Uuid::parse_str(cid)
{
derived_to_conv.push((identity::member_id_for_conversation(uuid), (*cid).to_string()));
derived_to_conv.push((
identity::member_id_for_conversation(uuid),
(*cid).to_string(),
));
}
}
if !derived_to_conv.is_empty() {
Expand Down Expand Up @@ -2177,8 +2188,7 @@ pub async fn enrich_space_members_batch(
if members.is_empty() {
return Ok(Vec::new());
}
let is_group_space =
!space_id.starts_with("unassigned:") && !space_id.starts_with("direct:");
let is_group_space = !space_id.starts_with("unassigned:") && !space_id.starts_with("direct:");
let mut identity_by_conv: HashMap<String, (String, bool, Option<String>, Option<String>)> =
HashMap::new();

Expand All @@ -2197,7 +2207,10 @@ pub async fn enrich_space_members_batch(
.map_err(db_err)?;

for (conv_id, identity_id, is_sup, avatar, color) in bound_rows {
if let Some(cid) = conv_id.map(|s| s.trim().to_string()).filter(|s| !s.is_empty()) {
if let Some(cid) = conv_id
.map(|s| s.trim().to_string())
.filter(|s| !s.is_empty())
{
identity_by_conv
.entry(cid)
.or_insert((identity_id, is_sup != 0, avatar, color));
Expand Down Expand Up @@ -3212,10 +3225,25 @@ mod tests {
.iter()
.find(|v| v.get("nickname").and_then(|s| s.as_str()) == Some("Beta"))
.expect("Beta member");
assert!(alpha.get("identity_member_id").and_then(|v| v.as_str()).is_some());
assert_eq!(alpha.get("is_supervisor").and_then(|v| v.as_bool()), Some(true));
assert!(beta.get("identity_member_id").and_then(|v| v.as_str()).is_some());
assert_eq!(beta.get("is_supervisor").and_then(|v| v.as_bool()), Some(false));
assert!(
alpha
.get("identity_member_id")
.and_then(|v| v.as_str())
.is_some()
);
assert_eq!(
alpha.get("is_supervisor").and_then(|v| v.as_bool()),
Some(true)
);
assert!(
beta.get("identity_member_id")
.and_then(|v| v.as_str())
.is_some()
);
assert_eq!(
beta.get("is_supervisor").and_then(|v| v.as_bool()),
Some(false)
);
assert_ne!(
alpha.get("identity_member_id"),
beta.get("identity_member_id")
Expand Down
4 changes: 3 additions & 1 deletion crates/conversations/src/session_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,9 @@ mod tests {
assert_eq!(
derive_session_display_name(
None,
Some("现在会话的标题字数没有限制,默认按照第一条消息命名时,若第一条消息过长会导致会话名称超级长"),
Some(
"现在会话的标题字数没有限制,默认按照第一条消息命名时,若第一条消息过长会导致会话名称超级长"
),
1
),
"现在会话的标题字数没有限制,默认按照第一条消息命名时,若第一条消"
Expand Down
32 changes: 18 additions & 14 deletions crates/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,20 +496,24 @@ mod tests {
.await
.expect("migrations should deduplicate duplicate root_path rows");

let older_hidden: i64 =
sqlx::query_scalar("SELECT hidden FROM projects WHERE id = ?")
.bind(older_project_id)
.fetch_one(&pool)
.await
.expect("older hidden");
let newer_hidden: i64 =
sqlx::query_scalar("SELECT hidden FROM projects WHERE id = ?")
.bind(newer_project_id)
.fetch_one(&pool)
.await
.expect("newer hidden");
assert_eq!(older_hidden, 1, "older duplicate project must be soft-hidden");
assert_eq!(newer_hidden, 0, "newest duplicate project must remain visible");
let older_hidden: i64 = sqlx::query_scalar("SELECT hidden FROM projects WHERE id = ?")
.bind(older_project_id)
.fetch_one(&pool)
.await
.expect("older hidden");
let newer_hidden: i64 = sqlx::query_scalar("SELECT hidden FROM projects WHERE id = ?")
.bind(newer_project_id)
.fetch_one(&pool)
.await
.expect("newer hidden");
assert_eq!(
older_hidden, 1,
"older duplicate project must be soft-hidden"
);
assert_eq!(
newer_hidden, 0,
"newest duplicate project must remain visible"
);
}
}

Expand Down
15 changes: 9 additions & 6 deletions crates/plugins/src/worker_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3326,9 +3326,7 @@ fn validate_registrations(
.filter(|handler| !(is_v2_runtime && *handler == "app.activate"))
.collect::<BTreeSet<_>>();
let actual = handlers.iter().map(String::as_str).collect::<BTreeSet<_>>();
if !is_v2_runtime
&& let Some(undeclared) = actual.difference(&declared).next()
{
if !is_v2_runtime && let Some(undeclared) = actual.difference(&declared).next() {
return Err(WorkerHostError::new(
"handler_undeclared",
format!("Worker registered undeclared handler {undeclared}"),
Expand Down Expand Up @@ -3652,11 +3650,16 @@ mod worker_host_tests {
.and_then(Path::parent)
.expect("workspace root");
let code_completion_dir = repo_root.join("plugins").join("code-completion");
let package = PluginPackage::inspect(&code_completion_dir, crate::PluginSourceKind::Snapshot)
.expect("inspect code-completion");
let package =
PluginPackage::inspect(&code_completion_dir, crate::PluginSourceKind::Snapshot)
.expect("inspect code-completion");
assert_eq!(package.api_version, "2.0");
assert_eq!(
package.app.status_items.first().and_then(|s| s.text.as_deref()),
package
.app
.status_items
.first()
.and_then(|s| s.text.as_deref()),
Some("AI代码补全")
);

Expand Down
17 changes: 9 additions & 8 deletions crates/server/src/agent_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,7 @@ where
);
prepare_user_environment(&user_env).await?;
let _bun = if profile_requires_bun(&plan.agent_id) {
let resolved =
resolve_bun_runtime(&managed_artifacts, node.as_ref(), &user_env).await?;
let resolved = resolve_bun_runtime(&managed_artifacts, node.as_ref(), &user_env).await?;
on_progress(36, &format!("[env] bun={}", resolved.display()));
if let Some(executable) = resolved.parent() {
utils::shell::expose_user_bin_to_process_path(executable);
Expand Down Expand Up @@ -1019,10 +1018,10 @@ fn export_bootstrapped_node(runtime: &NodeRuntime) -> anyhow::Result<()> {
fn export_bootstrapped_bun(bin_dir: &Path) -> anyhow::Result<()> {
let home =
dirs::home_dir().ok_or_else(|| anyhow::anyhow!("could not resolve the home directory"))?;
let published =
export_managed_bun_to_user_environment(&home, bin_dir, host_shell_family()).map_err(
|error| anyhow::anyhow!("failed to export Bun to the user environment: {error}"),
)?;
let published = export_managed_bun_to_user_environment(&home, bin_dir, host_shell_family())
.map_err(|error| {
anyhow::anyhow!("failed to export Bun to the user environment: {error}")
})?;
if published.is_empty() {
anyhow::bail!("managed Bun did not contain a bun executable to export");
}
Expand Down Expand Up @@ -1116,8 +1115,10 @@ async fn install_bun_via_npm_fallback(
) -> anyhow::Result<PathBuf> {
let npm = node
.map(|runtime| runtime.npm.clone())
.or(utils::shell::resolve_executable_path(if cfg!(windows) { "npm.cmd" } else { "npm" })
.await)
.or(
utils::shell::resolve_executable_path(if cfg!(windows) { "npm.cmd" } else { "npm" })
.await,
)
.ok_or_else(|| anyhow::anyhow!("npm is unavailable for Bun fallback install"))?;
let spec = format!("bun@{MANAGED_BUN_VERSION}");
let mut command = utils::process::new_hidden_tokio_command(&npm, std::iter::empty::<&str>());
Expand Down
Loading
Loading