Skip to content

refactor(commands,core): migrate command handlers to zeph-commands (phase 3)#2925

Merged
bug-ops merged 3 commits intomainfrom
commands-handler-migration
Apr 12, 2026
Merged

refactor(commands,core): migrate command handlers to zeph-commands (phase 3)#2925
bug-ops merged 3 commits intomainfrom
commands-handler-migration

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Apr 12, 2026

Summary

Closes #2923. Completes phase 3 of the zeph-core decomposition epic (#2909): migrates all viable slash command handlers from zeph-core to the zeph-commands crate 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)
  • Sub-traits in src/traits/: ChannelSink, DebugAccess, MessageAccess, SessionAccess, AgentAccess
  • AgentAccess fat trait — object-safe bridge exposing Agent<C> subsystems without generic leakage
  • NullSink, NullAgent and null impls for borrow-splitting in dispatch blocks
  • Handlers in src/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> implements AgentAccess in agent_access_impl.rs
  • Null sentinels (NullDebugAccess, NullMessageAccess, NullSessionAccess) in command_context_impls.rs
  • Dispatch in Agent::run split into two inline registry blocks (session/debug and agent-command) to resolve borrow-checker conflicts
  • SlashCategory unified: local duplicate removed from slash_commands.rs, now uses canonical zeph_commands::SlashCategory

Deferred to #2924

/skill, /skills, /feedback are registered as silent stubs. Their implementations hold &SemanticMemory and &AnyProvider across .await points which prevents the future from being Send. Migration requires those types to implement Sync first.

Test results

7912 tests run: 7912 passed, 20 skipped
cargo +nightly fmt --check — clean
cargo clippy --workspace --lib --bins -- -D warnings — 0 warnings

bug-ops added 2 commits April 12, 2026 21:07
…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.
@bug-ops bug-ops added core zeph-core crate refactor Code refactoring without functional changes P2 High value, medium complexity architecture Architecture improvements labels Apr 12, 2026
@bug-ops bug-ops self-assigned this Apr 12, 2026
@bug-ops bug-ops added core zeph-core crate refactor Code refactoring without functional changes P2 High value, medium complexity architecture Architecture improvements labels Apr 12, 2026
@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes size/XL Extra large PR (500+ lines) labels Apr 12, 2026
@bug-ops bug-ops enabled auto-merge (squash) April 12, 2026 19:14
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().
@bug-ops bug-ops merged commit 97cefcd into main Apr 12, 2026
30 checks passed
@bug-ops bug-ops deleted the commands-handler-migration branch April 12, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

architecture Architecture improvements core zeph-core crate documentation Improvements or additions to documentation P2 High value, medium complexity refactor Code refactoring without functional changes rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(commands): complete handler migration from zeph-core to zeph-commands (phase 3)

1 participant