/** * CmdHarness — CodingHarness implementation for Command Code (cmd). * * Command Code is a pi fork with its own CLI, hook system, and session * file format. This harness encapsulates cmd-specific spawning logic: * - Shared hook script injection for SessionStart / readiness signaling * - Launch command construction with --trust --skip-onboarding --model * - Readiness detection via hook-provided COMMANDCODE_SESSION_ID * - JSONL session file monitoring (cmd-specific format with "tool" role) * - settings.json restoration on teardown */ import type { CodingHarness, HarnessConfigProfile, HarnessEnvironment, HarnessSpawnParams, SessionAnalysis } from "#src/harness/interface"; import type { TmuxManager } from "#src/tmux-manager"; import type { SubagentRecord } from "#src/types"; export declare class CmdHarness implements CodingHarness { readonly id = "cmd"; readonly roleDefinitionDelivery: "prompt-context"; /** Self-described widget identity (fallback row retained in harness-colors). */ readonly widgetIdentity: { colorHex: string; sigil: string; }; readonly completionSentinelKind = "Stop-hook sentinel"; /** Default tmux stop combo (fallback row retained in guard-config). */ readonly defaultStopKeyCombo = "C-c"; /** * cmd has NO live tool-status stream — its hooks-audit file carries only * SessionStart/Stop events (no PreToolUse/PostToolUse, no tool names). The * `LifecycleController` derives `currentTool` from the parsed session file * instead (`SessionAnalysis.toolCalls`). */ readonly providesToolStatusStream = false; /** * cmd collapses a bracketed paste into an unexpanded attachment chip whose * content never reaches the model, so the prompt must always go in literally. */ readonly promptDeliveryStyle: "literal"; /** cmd drops an Enter that arrives as a separate tmux command. */ readonly combinesTextAndEnter = true; /** * Config-dir profile (layer B). cmd exposes no config-dir env var, so the * only lever is a HOME redirect: `redirectEnv` returns `{ HOME: dir }`, * applied as a subshell-scoped env prefix on the launch command (the user's * real HOME is never mutated). The synth dir is shaped as a HOME containing * `.commandcode/` (`configSubdir ".commandcode"`). */ readonly configProfile: HarnessConfigProfile; /** cmd's sessions live at a fixed, non-per-agent path. */ resolveSessionDir(_record: SubagentRecord): string; resolveOwnedTempPaths(agentId: string, runtimeDir?: string): string[]; /** * Prepare the cmd environment before launching. * * 1. Creates a single shared hook script at a deterministic GLOBAL path * (~/.commandcode/.pi-tmux-hook.sh; idempotent — always re-written). * 2. Registers the shared hook in ~/.commandcode/settings.json using * atomic, idempotent, PERMANENT semantics (detects existing registration; * never restored on cleanup — the hook is env-gated and benign). * 3. Computes all status/ready/config/session paths. */ setupEnvironment(params: HarnessSpawnParams): Promise; /** * Build the cmd launch command. * * Constructs: cmd --trust --skip-onboarding [--model /] * with PI_TMUX_READY_FILE env var prepended. * Does NOT set PI_TMUX_SUBAGENT_STATUS_FILE — cmd doesn't use it * (only pi's child-status-writer uses that). */ buildLaunchCommand(params: HarnessSpawnParams, env: HarnessEnvironment): string; /** * Wait for the cmd TUI to signal readiness. * * Polls the ready file (written by the hook script when cmd fires * SessionStart) for up to 30 seconds, every 200ms. On success, * reads the COMMANDCODE_SESSION_ID from the file and computes * the session file path for monitoring. */ waitForReady(_params: HarnessSpawnParams, env: HarnessEnvironment, _agentId: string, _tmux: TmuxManager, _signal?: AbortSignal): Promise; readTurnCount(env: HarnessEnvironment): Promise; /** * Analyze a cmd-format session file using the cmd parser. * * Critical fix: previously `LifecycleController` used the pi parser * (`analyzeSessionFile`) for all harnesses, which misread cmd's * top-level-`role` JSONL format. This produced false-positive * "completed" detections within 10–12s of spawn and false-positive * "stalled" errors when the agent was actually done. */ analyzeSession(filePath: string): SessionAnalysis; /** * Report whether the cmd lifecycle-end sentinel has been written. * * Authoritative completion signal for `LifecycleController` — written by the * Stop hook on end of turn. See the `completion-sentinel` capability. */ isComplete(env: HarnessEnvironment): boolean; /** * Clean up cmd-specific resources. * * Removes the per-agent ready file and end sentinel. Does NOT touch the * shared global hook script or its ~/.commandcode/settings.json registration: * the hook is env-gated (inert without PI_TMUX_*_FILE) and registered * permanently, so there is nothing to restore. */ cleanup(env: HarnessEnvironment): Promise; } //# sourceMappingURL=cmd-harness.d.ts.map