Repository navigation
refactor(cli): split agent commands into modules, consolidate shared helpers - #350
Merged
Merged
Conversation
…resolver service - Single agent-type label source in util/agent.ts (display + compact variants covering all 11 types); delete partial TUI label maps. - Merge three relative-time formatters into util/time-format.ts (formatRelativeCompact + formatRelativeTime + local timestamp helpers). - Move sanitizeProviderOutput/ANSI_ESCAPE_PATTERN to util/text.ts and share AGENT_NAME_REGEX between agent commands and agent-group service. - Extract services/agent/resolve-agent.service.ts classifying empty/not-found/ambiguous/resolved; adopt in sendToAgent and channel-runner, unifying resolution messages. - Fix memoryMcp status tests spreading the whole fixture into getStatusReport, which bypassed the fs/command stubs and hit the real npm registry; delegate access/readFile to real fs under the temp home.
Break the 1253-line commands/agent.ts into commands/agent/* following the commands/skill/ convention: one module per subcommand, a shared render.ts for terminal presentation helpers, and a factory.ts for manager/service construction and stdin plumbing. - cli.ts and tests import registerAgentCommand via commands/agent/index. - open/kill/detail resolve agents through resolveAgentByName + reportAgentResolution; send/detail reuse assertDurableNameUnambiguous. - Commands keep Commander registration and terminal output; domain logic stays in services.
Mark planning milestones complete, tick verified test scenarios, and capture the split-module structure, integration points, and the worktree index-corruption + status-test network-flake notes.
- Move send-only helpers (readStdin, resolveSendMessage, writeWaitStatus, createCommandSendReporter) from factory.ts into send.command.ts; factory keeps only the shared manager/service constructors. - Extract resolveDurableAgentEntry into resolve-agent.service.ts, deduplicating the repository.resolve + multi-match + cross-mode ambiguity preamble shared by send and detail, and unifying on a single DurableAgentRepository construction path. - Reuse util/pluralize in the list waiting-agents message; keep the noun-only variant in render.ts renamed to pluralizeNoun. - Inline single-caller resolveTailCount into selectConversationMessages. - Extract renderDurableAgentDetail (render.ts) and reportStartError (start.command.ts) for readability.
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
Refactors the 1,253-line
commands/agent.tsinto acommands/agent/module tree following the existingcommands/skill/convention. Commands own Commander registration, option parsing, and terminal output; reusable logic lives in services.*.command.tsper subcommand (start, list, sessions, session, open, send, kill, detail, rename, console) +agent.command.tswiring +index.tsre-export;cli.tsis the only external import changeformatCwd, separators, conversation/detail rendering)createAgentManager+createDurableAgentServiceonlyservices/agent/resolve-agent.service.ts:resolveAgentByName(empty/not-found/ambiguous/resolved),reportAgentResolution,assertDurableNameUnambiguous,resolveDurableAgentEntry— adopted bysend,detail,open,kill,agent.service.ts, andchannel-runner.tsutil/agent.ts, all 11 types, display + compact variants), unified relative-time formatters (util/time-format.ts),sanitizeProviderOutput+ANSI_ESCAPE_PATTERNinutil/text.ts, sharedAGENT_NAME_REGEX(replacesGROUP_NAME_REGEX)tui/console/render/agentTypeLabel.tsandrender/formatRelative.ts; unified "Please use a more specific name." messagestatus.service.test.tsmemoryMcp tests were spreading the whole fixture intogetStatusReport, bypassing stubs and hitting the real npm registry (cause of the intermittent 5s timeouts); now deterministicagent --helpand all 11 subcommand helps are byte-identical tomainTest plan
npm run build— 6 projects, 266 filesvitest— 109 files / 1,318 tests passtsc -b+oxlintcleanai-devkit lint --feature refactor-agent-commands— 12 checksagent --helpparity vsmain(all subcommands)agent list,agent sessionson built distagent consolelabel rendering)