feat(commands): fork-agent infra + /btw /simplify /advisor (#33 #37 #62) - #85
Merged
Crsei merged 1 commit intoApr 21, 2026
Merged
Conversation
…rsei#37 Crsei#62) Builds a real forked-agent execution path and layers three user-facing commands on top of it. ## Fork infrastructure (issue Crsei#37) - `engine::agent::fork::run_fork` — ephemeral child QueryEngine with no persistence, configurable tool set, and single/multi-turn caps. - `SkillContext::Fork` now dispatches through this primitive instead of the prior "inline fallback", honoring each skill's `allowed_tools`. ## /btw (issue Crsei#37) - Tool-free, single-turn side-question fork that reuses the parent conversation as cache-safe context. Answer returned via `CommandResult::Output`, so the main transcript is not polluted. ## /simplify (issue Crsei#62) - Slash entrypoint for the bundled `simplify` skill. - Multi-agent mode: fans out three parallel reviewer forks (reuse / quality / efficiency) via `futures::future::join_all` and joins the outputs into a single action-oriented summary. - `--single` / `-1` fallback for a single-agent pass; optional scope argument narrows the review. ## /advisor + advisor_model plumbing (issue Crsei#33) - `advisor_model: Option<String>` added to `AppState`, `SettingsJson` (runtime), `RawSettings`/`EffectiveSettings` (on-disk, camelCase key `advisorModel`) and the JSON schema. - `ModelCallParams` carries it through the query loop into `MessagesRequest::advisor_model` (serialized with `skip_serializing_if`). `provider_supports_advisor` gates Anthropic, Azure, Bedrock, Vertex; other providers are stripped with a debug log. - `/advisor` supports show / set / unset (aliases: none/off/clear), persists atomically via `write_user_settings`, and flags inactive providers in its output. Tests: 27 new unit tests covering fork params, /btw usage path, /simplify arg parsing + multi-agent aggregation, advisor state transitions + on-disk round-trip, and provider-support matrix. All pass alongside the existing suite (299/299 serial). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
yaohaowei0914
pushed a commit
to yaohaowei0914/claude-code-rust
that referenced
this pull request
Apr 21, 2026
Integrates the fork-agent infrastructure and ancillary command/IPC updates that landed on rust-lite after this branch opened: - PR Crsei#85: fork-agent infra + /btw /simplify /advisor (Crsei#33 Crsei#37 Crsei#62) - PR Crsei#87: MCP/plugin/reload-plugins/ide/reload-plugins commands (Crsei#41 Crsei#44 Crsei#47 Crsei#49) - PR Crsei#88: /loop /schedule /team-onboarding (Crsei#43 Crsei#58 Crsei#60 Crsei#63) ## Conflict resolution Git's recursive merge handled every hunk on its own — each of the five files flagged as overlapping had non-overlapping line ranges between my workspace-split edits and rust-lite's feature edits: - `crates/cc-engine/src/types/app_state.rs` — my move to cc-engine vs. advisor/fork-related AppState fields. Clean auto-merge. - `crates/claude-code-rs/src/engine/agent/mod.rs` — my `cc_types::agent_*` import rewrites vs. rust-lite's `pub mod fork;` addition. Clean. - `crates/claude-code-rs/src/engine/lifecycle/deps.rs` — my `cc_types::background_agents` retyping and `hook_runner()` impl vs. rust-lite's `advisor_model` stripping logic. Clean. - `crates/claude-code-rs/src/query/deps.rs` — my `hook_runner()` / `drain_background_results` signature changes vs. rust-lite's new `ModelCallParams::advisor_model` field. Clean. - `crates/claude-code-rs/src/query/loop_impl.rs` — my hook-runner-trait rewiring vs. rust-lite's advisor model plumbing. Clean. All 40+ other touched files (api/*, commands/*, ide/*, ipc/*, services/*, etc.) merged without conflict — they're in regions my branch didn't touch. ## Verification - `cargo check --workspace`: clean (2 pre-existing warnings). - `cargo test -p cc-types`: 4/4 passing (teams + background_agents). - `cargo test -p cc-engine`: status_line + types suite unchanged. - `cargo test --bin claude-code-rs engine::agent query::loop_impl`: 69/69 passing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Delivers the fork-agent infrastructure and the three commands that depend on it:
advisor_modelplumbing into the Messages requestFork infrastructure (issue #37)
engine::agent::fork::run_forkprimitive — spawns an ephemeral childQueryEnginewith no persistence, configurable tool set, and single/multi-turn caps. Optionally seeds with parent messages for cache-safe reuse.SkillContext::Forkintools/skill.rsnow dispatches throughrun_forkinstead of the prior "inline fallback", honoring each skill'sallowed_tools./btw (issue #37)
/btw <question>runs a tool-free, single-turn fork.CommandResult::Output, so the main transcript is not polluted./simplify (issue #62)
simplifyskill to a user-facing slash command.futures::future::join_all, then joins the outputs into a single action-oriented summary.--single/-1runs a single-agent pass; optional scope argument (/simplify src/foo.rs) narrows the review./advisor + advisor_model plumbing (issue #33)
advisor_model: Option<String>added to:AppState(types/app_state.rs)SettingsJsonruntime projection (cc-config/runtime_settings.rs)RawSettings/EffectiveSettings+ JSON schema (camelCase keyadvisorModel)ModelCallParams→MessagesRequest(serialized withskip_serializing_if)provider_supports_advisor()gates Anthropic / Azure / Bedrock / Vertex; other providers are stripped with adebug!log (engine/lifecycle/deps.rs)./advisorsupports show / set / unset (aliases:none,off,clear), persists atomically viawrite_user_settings, and surfaces a clear inactive-provider note in its output.Test plan
cargo test -p claude-code-rs --bin claude-code-rs -- commands::btw commands::simplify commands::advisor engine::agent::fork api::client::tests::test_messages_request api::client::tests::test_provider_supports_advisor— 27/27 passcargo test -p claude-code-rs --bin claude-code-rs -- commands:: --test-threads=1— 299/299 pass (4 pre-existing env-var races surface only under parallelism; none of them are new tests in this PR — verified by running tests against base before stashing)cargo build -p claude-code-rs— clean, only the 2 pre-existingsession_idwarnings inweb/handlers.rsReview notes
run_forkprimitive is small on purpose: it reuses the existingcollect_stream_resultfrom the AgentTool path and skips the global agent-tree + IPC event registration, so/btwstays lightweight.noop_persistclosure so the command tests are hermetic (no env-var mutation, no touching of the user's realsettings.json). Disk round-trip is covered separately bypersist_to_path_round_trips_via_disk./advisorstill persists the value but the status line flags it as inactive.🤖 Generated with Claude Code