Skip to content

D-20: ClaudeCommandBuilder — surface parameter + Dialogue flags #270

@kirich1409

Description

@kirich1409

Description

Extend ClaudeCommandBuilder.build(...) to accept a SessionSurface parameter and emit the correct CLI arguments for each surface. For .agentDialogue(.claudeCode) — append stream-json flags per spec.

Spec: Epic #250 §4.1 (ClaudeCommandBuilder); docs/architecture/dialogue-events.md §7 (CLI launch flags).

Scope

File

MacApp/Packages/AgentOrchestrator/Sources/AgentOrchestrator/ClaudeCommandBuilder.swift

New signature

```swift
public static func build(
claudePath: String,
workingDirectory: URL,
shellPATH: String? = nil,
surface: SessionSurface,
sessionIDForResume: SessionID? = nil // optional, for --resume when opening sibling
) -> TerminalCommand
```

Arguments by surface

  • .shell — should not reach this builder (shell launched through different path); assert / fatalError.
  • .agentTerminal(.claudeCode) — current behavior (no extra args; interactive mode).
  • .agentDialogue(.claudeCode) — append:
    • -p (headless)
    • --output-format stream-json
    • --verbose
    • --include-partial-messages
    • --bare
    • --permission-mode acceptEdits (MVP — auto-accept edits only)
    • --allowedTools <csv> (from SettingsStore; whitelist for Bash, WebFetch, etc. that aren't edits)
  • If sessionIDForResume is provided — append --resume <UUID> regardless of surface.

Environment (unchanged)

Keep existing env: PATH, TERM=xterm-256color, COLORTERM=truecolor, GIT_PAGER=cat, PAGER=cat, strip TERM_PROGRAM*.

Caller sites

Update all call sites:

  • AgentSessionFeature._claudeDetected — passes surface from state.
  • New "Open as X" action handler (D-25) — passes sessionIDForResume.

Acceptance Criteria

  • build(...) signature updated with surface + sessionIDForResume.
  • .agentDialogue(.claudeCode) produces all 6 expected flags exactly (-p --output-format stream-json --verbose --include-partial-messages --bare --permission-mode acceptEdits + --allowedTools whitelist). --input-format stream-json is Post-MVP (undocumented per Anthropic issue #24594).
  • .agentTerminal(.claudeCode) produces no extra flags (unchanged).
  • --resume appended correctly when sessionIDForResume present.
  • Unit tests cover every (surface, sessionIDForResume) combination.
  • All callers updated; compilation passes.

Relationships

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions