refactor(workspace): P5 break hub cycles (tools↔engine, engine↔commands) - #83
Merged
Crsei merged 1 commit intoApr 21, 2026
Merged
Conversation
…mmands) - Move tools::agent -> engine::agent (5a) - Extract HookRunner trait into cc-types; engine no longer imports tools::hooks (5b) - Extract CommandDispatcher trait into cc-types; engine no longer imports commands (5c) Closes Crsei#74
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
Breaks the three narrow import cycles that would block extracting
tools,engine, andcommandsinto separate crates in Phase 6. Everything still compiles as one crate today; Phase 5 is purely a preparatory refactor.Closes #74. Part of #68.
What changed
5a — Move Agent tool into
engine/crates/claude-code-rs/src/tools/agent/→crates/claude-code-rs/src/engine/agent/(5 files)crate::engine::agent::AgentTool5b — Extract
HookRunnertrait intocc-typescrates/cc-types/src/hooks.rsdefinesHookRunnertrait + plain data types (HookEventConfig,HookEntry,HookOutput,PermissionOverride,PreToolHookResult,PostToolHookResult) +NoopHookRunnertools/hooks/mod.rsre-exports types and adds concreteShellHookRunnerQueryEngine,QueryEngineDeps, andToolUseContextnow holdArc<dyn HookRunner>instead of importingtools::hooksdirectlyctx.hook_runner5c — Invert
engine → commandscrates/cc-types/src/commands.rswithCommandDispatchertrait,ParsedCommandtype,NoopCommandDispatchercommands/mod.rsadds concreteDefaultCommandDispatcherprocess_user_inputnow takes&dyn CommandDispatcher; engine threads the dispatcher throughExternal call sites (
main.rs,teams/runner.rs,web/handlers.rs) install the shell/default impls; tests use the no-op defaults.Verification
Cycle-check greps (all return zero):
grep -rn "use crate::engine" crates/claude-code-rs/src/tools/grep -rn "use crate::tools::hooks" crates/claude-code-rs/src/engine/grep -rn "use crate::commands" crates/claude-code-rs/src/engine/Build & test:
cargo build --release -p claude-code-rs— clean (two pre-existing warnings on unusedsession_idfields inweb/handlers.rs)engine::agent59/59,engine::input_processing6/6,tools::hooks20/20,test_submit_local_commandpass%TEMP%-tied tests, plugin paths, model_add pricing) — none touch hooks/agent/commands/input_processingTest plan
rust-litebaseline)Arc<dyn HookRunner>/Arc<dyn CommandDispatcher>wiring at external call sites is correct