Skip to content

gut(commands): remove 11 gutted/vestigial command definitions #2134

@alexey-pelykh

Description

@alexey-pelykh

Summary

Remove dead model/thinking/reasoning/elevated/exec infrastructure — inline directive type fields, model directive parser, thinking-level types and normalization, help text references, and the stop command registry entry with its stub handlers.

Infrastructure to remove: model directive parser (model.ts), thinking types and normalization (thinking.ts), dead InlineDirectives type fields (hasThinkDirective, hasReasoningDirective, hasElevatedDirective, hasExecDirective + associated data fields), stop command registry entry, help text for /compact, /stop, /think, /model, /context, /skill.

Why

This infrastructure is non-functional in RemoteClaw:

  • Model directive (/model <id>, /models): extractModelDirective() parser still runs during parseInlineDirectives(), but the result is never acted on — persistInlineDirectives() has the model handling gutted (line 24: "Model directive handling gutted in RemoteClaw — CLI runtimes own model selection").
  • Thinking/reasoning/elevated (/think, /reasoning, /elevated): Type fields (hasThinkDirective, hasReasoningDirective, hasElevatedDirective) defined on InlineDirectives but never populated to true — the upstream parsing code that would set them was gutted. get-reply-directives.ts checks these fields but they are always undefined. The thinking.ts types (ThinkLevel, ElevatedLevel, ReasoningLevel) and normalization functions (normalizeThinkLevel, normalizeElevatedLevel, normalizeReasoningLevel) are imported across ~10 files but serve no middleware purpose — CLI agents manage their own thinking/reasoning levels.
  • Exec (hasExecDirective, execAsk, execHost, execNode, execSecurity): Dead type fields on InlineDirectives, never populated. No execution handler exists.
  • Stop (/stop): Registry entry at commands-registry.data.ts:458-464, but its handler in commands-session.ts:23-24 is a no-op stub returning null. The real abort mechanism lives in abort.ts (a separate code path triggered by the abort infrastructure, not the command registry).
  • Help text: buildHelpMessage() in status.ts:649-678 references /compact, /stop, /think <level>, /model <id>, /context, /skill <name> [input] — all non-functional.

Context

Part of the /remoteclaw command subtree refactor. All surviving RemoteClaw commands will move under /remoteclaw <subcommand> so the agent CLI owns the bare / namespace. Removing dead infrastructure first clears noise before the restructure.

Scope

Section 1: Remove stop command registry entry + stub handlers

File Change
src/auto-reply/commands-registry.data.ts:458-464 Delete the stop defineChatCommand() block
src/auto-reply/reply/commands-session.ts:21-24 Delete handleAbortTrigger and handleStopCommand stub stubs + line 474 export
src/auto-reply/reply/commands-core.ts:19,24,149-150 Remove imports and array entries for handleStopCommand, handleAbortTrigger

Note: abort.ts, abort-cutoff.ts, and their test remain untouched — the real abort mechanism is separate from the command registry stub.

Section 2: Remove model directive parser

File Change
src/auto-reply/model.ts (56 lines) Delete entire file — extractModelDirective() parser
src/auto-reply/model.test.ts (181 lines) Delete entire file — tests for model directive
src/auto-reply/reply/directive-handling.parse.ts:2 Remove import { extractModelDirective }
src/auto-reply/reply/directive-handling.parse.ts:67-74 Remove extractModelDirective() call, simplify parseInlineDirectives()

After removal, hasModelDirective / rawModelDirective / rawModelProfile still exist on InlineDirectives but will always be false/undefined. Full InlineDirectives type cleanup is Section 3.

Section 3: Remove dead InlineDirectives type fields

Remove fields from the InlineDirectives type in directive-handling.parse.ts:11-48 that are never meaningfully populated:

Model fields (populated by parser being deleted in Section 2):

  • hasModelDirective (line 17)
  • rawModelDirective (line 18)
  • rawModelProfile (line 19)

Think/reasoning/elevated/exec fields (never populated to true — upstream parsing was gutted):

  • thinkLevel (line 32), hasThinkDirective (line 33)
  • reasoningLevel (line 35), hasReasoningDirective (line 36)
  • elevatedLevel (line 38), rawElevatedLevel (line 39), hasElevatedDirective (line 40)
  • execAsk (line 42), execHost (line 43), execNode (line 44), execSecurity (line 45), hasExecDirective (line 47)

Cascade: remove all reads of these fields from consuming files:

  • get-reply-directives.ts — checks on hasModelDirective, hasThinkDirective, hasReasoningDirective, hasElevatedDirective, hasExecDirective
  • get-reply-directives-apply.ts:182directives.hasModelDirective check
  • get-reply-directives-utils.ts:11hasModelDirective: false in clearInlineDirectives()
  • get-reply-run.ts:391directives.hasThinkDirective check
  • directive-handling.parse.ts:124directives.hasModelDirective in isDirectiveOnly()

Section 4: Remove thinking types and normalization

File Change
src/auto-reply/thinking.ts (231 lines) Remove ThinkLevel, ElevatedLevel, ReasoningLevel types and their normalization functions (normalizeThinkLevel, normalizeElevatedLevel, normalizeReasoningLevel, listThinkingLevels, formatThinkingLevels, supportsXHighThinking, resolveElevatedMode, etc.). Keep VerboseLevel, normalizeVerboseLevel, NoticeLevel, normalizeNoticeLevel, UsageDisplayLevel, normalizeUsageDisplay, resolveResponseUsageMode — these are alive.
src/auto-reply/reply/directive-handling.levels.ts (41 lines) Delete entire file — resolves current think/reasoning/elevated levels from session, dead without the types
src/auto-reply/reply/get-reply-directives.ts Remove ThinkLevel/ElevatedLevel/ReasoningLevel imports and all resolved*Level logic
src/auto-reply/reply/get-reply-run.ts Remove think/reasoning/elevated level resolution and propagation
src/auto-reply/reply/get-reply.ts Remove resolved*Level destructuring and passing
src/auto-reply/status.ts:67,95-98 Remove ThinkLevel/ElevatedLevel/ReasoningLevel imports and type usage
src/auto-reply/reply/get-reply-inline-actions.ts:50-53 Remove resolved*Level optional fields
src/auto-reply/reply/get-reply-run.media-only.test.ts:112-114 Remove resolved*Level from test fixtures
src/auto-reply/reply/get-reply.reset-hooks-fallback.test.ts:133-136 Remove resolved*Level from test fixtures
src/agents/model-selection.ts:15,58 Remove duplicate ThinkLevel type and resolveThinkingDefault()
src/agents/subagent-spawn.ts:4,407 Remove formatThinkingLevels, normalizeThinkLevel imports and usage
src/cron/isolated-agent/run.test-harness.ts:115 Remove normalizeThinkLevel mock

Section 5: Remove help text references

File Change
src/auto-reply/status.ts:652-673 In buildHelpMessage(): remove /compact, /stop from Session line; remove /think <level>, /model <id> from Options line; remove /context from Status line; remove /skill <name> [input] Skills section

Section 6: Remove directive-handling.persist.ts model handling comment

File Change
src/auto-reply/reply/directive-handling.persist.ts:24 Remove gutted model directive comment — no model directive fields exist after Section 3

Files affected

Delete entirely

  • src/auto-reply/model.ts (56 lines)
  • src/auto-reply/model.test.ts (181 lines)
  • src/auto-reply/reply/directive-handling.levels.ts (41 lines)

Modify

  • src/auto-reply/thinking.ts — remove think/elevated/reasoning types and functions (~165 lines removed, ~66 lines kept)
  • src/auto-reply/commands-registry.data.ts — delete stop definition
  • src/auto-reply/reply/commands-session.ts — delete handleAbortTrigger/handleStopCommand stubs + export
  • src/auto-reply/reply/commands-core.ts — remove stop/abort imports and array entries
  • src/auto-reply/reply/directive-handling.parse.ts — remove model parser import, call, and dead type fields
  • src/auto-reply/reply/directive-handling.persist.ts — remove gutted comment
  • src/auto-reply/reply/directive-handling.ts — barrel re-exports may need update
  • src/auto-reply/reply/get-reply-directives.ts — remove dead directive field checks and think/reasoning/elevated level resolution
  • src/auto-reply/reply/get-reply-directives-apply.ts — remove hasModelDirective check
  • src/auto-reply/reply/get-reply-directives-utils.ts — remove hasModelDirective from clearInlineDirectives()
  • src/auto-reply/reply/get-reply-run.ts — remove think/reasoning/elevated level resolution
  • src/auto-reply/reply/get-reply.ts — remove resolved*Level destructuring
  • src/auto-reply/reply/get-reply-inline-actions.ts — remove resolved*Level optional fields
  • src/auto-reply/status.ts — remove ThinkLevel/ElevatedLevel/ReasoningLevel imports + help text
  • src/auto-reply/reply/get-reply-run.media-only.test.ts — update test fixtures
  • src/auto-reply/reply/get-reply.reset-hooks-fallback.test.ts — update test fixtures
  • src/agents/model-selection.ts — remove duplicate ThinkLevel + resolveThinkingDefault
  • src/agents/subagent-spawn.ts — remove thinking imports and usage
  • src/cron/isolated-agent/run.test-harness.ts — remove normalizeThinkLevel mock
  • src/auto-reply/commands-registry.test.ts — update/remove tests referencing model/stop/think

Acceptance criteria

  • grep -r "extractModelDirective" src/ returns zero matches
  • grep -r "hasThinkDirective\|hasReasoningDirective\|hasElevatedDirective\|hasExecDirective" src/ returns zero matches
  • grep -r "ThinkLevel\|ElevatedLevel\|ReasoningLevel" src/ returns zero matches (excluding Telegram's local TelegramReasoningLevel type in bot-message-dispatch.ts — that is a separate local type, not the dead upstream one)
  • grep -r "normalizeThinkLevel\|normalizeElevatedLevel\|normalizeReasoningLevel" src/ returns zero matches
  • No stop entry in commands-registry.data.ts
  • No handleStopCommand/handleAbortTrigger in commands-session.ts
  • buildHelpMessage() does not reference /compact, /stop, /think, /model, /context, /skill
  • abort.ts and abort-cutoff.ts remain untouched (real abort mechanism)
  • VerboseLevel, normalizeVerboseLevel, UsageDisplayLevel, resolveResponseUsageMode remain in thinking.ts (alive infrastructure)
  • Verbose and queue directive fields remain on InlineDirectives (alive infrastructure)
  • npm run build succeeds
  • npm test passes

Metadata

Metadata

Assignees

No one assigned

    Labels

    gutRemoving dead upstream subsystems

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions