refactor(commands,core): migrate command handlers to zeph-commands (phase 3)#2925
Merged
refactor(commands,core): migrate command handlers to zeph-commands (phase 3)#2925
Conversation
…ommands (#2923) Introduce the `AgentAccess` fat trait in `zeph-commands` — a single object-safe trait whose methods delegate to `Agent<C>` subsystems that require simultaneous access to multiple fields (which cannot be decomposed into separate `CommandContext` field borrows without borrow-checker conflicts). `Agent<C>` implements `AgentAccess` in the new `agent_access_impl.rs`. `CommandContext` gains an `agent: &mut dyn AgentAccess` field backed by `NullAgent` (zero-size no-op) in the session/debug dispatch block and `self` (the agent) in the dedicated agent-command dispatch block. Handlers migrated to `zeph-commands`: `/memory`, `/graph`, `/guidelines`, `/model`, `/provider`, `/policy`, `/scheduler`, `/lsp`. `/skill`, `/skills`, `/feedback` are registered as stubs that return `CommandOutput::Silent`, letting `handle_builtin_command` in `zeph-core` handle them. Their `as_string` helpers were added but removed after the `Send` constraint analysis showed that `&SemanticMemory` and `&AnyProvider` held across `.await` prevent the future from being `Send`; migration is deferred until those types implement `Sync`. `NullSink` added to `zeph-commands::sink` for the agent-command dispatch block where the channel is not needed. `NullDebugAccess`, `NullMessageAccess`, and `NullSessionAccess` added in `command_context_impls.rs` for the same purpose. `zeph-core::agent::command_registry` and all `commands/` handler modules are deleted; their logic lives in `zeph-commands` or was already present in the pre-existing `handle_builtin_command` path.
…slash_commands.rs Remove the local `SlashCategory` and `SlashCommandInfo` types from slash_commands.rs and replace with the canonical `SlashCategory` and `CommandInfo` re-exported from zeph-commands. Variant mapping: Info → Debugging Model → Configuration Tools → Integration (mcp/image/agent) or Skills (skill/skills) Debug → Debugging Update COMMANDS constant and handle_help_command category list to use the unified variants. Fixes the DRY violation flagged in code review.
Agent::run now requires C: 'static due to the AgentAccess impl bound introduced in the handler migration. Propagate the bound to run_tui_agent which calls agent.run().
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
Closes #2923. Completes phase 3 of the zeph-core decomposition epic (#2909): migrates all viable slash command handlers from
zeph-coreto thezeph-commandscrate using trait-based decoupling (Option A).What changed
zeph-commands (new)
CommandContext<'a>— non-generic context struct with trait-object fields (sink,debug,messages,session,agent)src/traits/:ChannelSink,DebugAccess,MessageAccess,SessionAccess,AgentAccessAgentAccessfat trait — object-safe bridge exposingAgent<C>subsystems without generic leakageNullSink,NullAgentand null impls for borrow-splitting in dispatch blockssrc/handlers/:session(exit, quit, clear, reset, clear-queue),debug(log, debug-dump, dump-format),memory(/memory, /graph, /guidelines),model(/model, /provider),policy(/policy),scheduler(/scheduler),lsp(/lsp),skill(stubs for /skill, /skills, /feedback)zeph-core
Agent<C>implementsAgentAccessinagent_access_impl.rsNullDebugAccess,NullMessageAccess,NullSessionAccess) incommand_context_impls.rsAgent::runsplit into two inline registry blocks (session/debug and agent-command) to resolve borrow-checker conflictsSlashCategoryunified: local duplicate removed fromslash_commands.rs, now uses canonicalzeph_commands::SlashCategoryDeferred to #2924
/skill,/skills,/feedbackare registered as silent stubs. Their implementations hold&SemanticMemoryand&AnyProvideracross.awaitpoints which prevents the future from beingSend. Migration requires those types to implementSyncfirst.Test results