The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
Buddy launch flags Implementation Plan
For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Let the owner restart their Buddy from Desktop with free-form extra launch flags (for example --chrome). The flags are
saved on the daemon's agent record and applied on every later launch.
Architecture:
- The CLI gains a pure parser and validator (
lib/launchArgs.ts), an optionallaunchArgson the registry row, and an append inbuildLaunchOverrides. agent_restarttakes an optionallaunchArgsstring, saves it, and echoes the saved words.- Desktop gains a "Restart Buddy…" dialog in the Buddy chat's menu, sending through
AppNotifier.restartAgent.
Tech Stack: TypeScript (cli, vitest), Dart/Flutter (desktop, flutter_test).
Spec: docs/specs/2026-11-06-buddy-launch-flags.md
Global Constraints
- Limits: at most 1024 characters and 20 words; no NUL or newline; an unclosed quote is refused.
- The error code is
INVALID_LAUNCH_ARGS, with adetailnaming the problem. - Refused flags (the part before
=):- Claude:
--resume,-r,--continue,-c,--model,--permission-mode,--dangerously-skip-permissions,--session-id,--settings,--append-system-prompt,--system-prompt,--mcp-config,--fork-session. - Codex:
--model,-m,--dangerously-bypass-approvals-and-sandbox,--ask-for-approval,-a,--sandbox,-s,--profile,-p, plusresumeorforkas the first word. - Other engines: only the length, word-count and character rules.
- Claude:
- Never run a shell. The words go into argv as they are.
- The record field is
launchArgs?: string[], never written when empty. - Argv order: after the Swarm's args, before Harness's instructions.
- Desktop copy, exactly:
- menu item "Restart Buddy…";
- title "Restart Buddy";
- field label "Extra launch flags", hint
--chrome; - detail "Added to 's command line each time this Buddy starts on . Your Buddy runs with full permissions. Clear the field to remove them.";
- buttons "Restart" and "Cancel";
- engine did not start: "The Buddy didn't start with these flags. Fix or clear them and restart.";
- old daemon: "Update Harness on to use launch flags."
- Code, comments and UI text are in English.
Review Focus
- A status re-check after a lost reply. Desktop re-asks
agent_create_status, which never echoeslaunchArgs. It must not show "Update Harness". Pinned in Task 5. - A repeated Restart with the same receipt but different flags. The receipt fingerprint must include
launchArgs, so the second request is not treated as the first one. Pinned in Task 3. - A stopped Buddy brought back after a reboot. The stopped row must keep
launchArgs, and the restored argv must carry them. Pinned in Task 2. - A word that is only
=or-, or a quoted flag such as"--model". The flag is checked after unquoting, so"--model"is refused. Pinned in Task 1. - Clearing the field on an agent with no saved flags. It is a no-op restart, writes no empty array, and echoes
[]. Pinned in Task 3.
Task 1: Parse and validate launch flags (CLI)
Files:
- Create:
cli/src/lib/launchArgs.ts - Test:
cli/src/lib/launchArgs.spec.ts
Interfaces:
Produces:
parseLaunchArgs(engine: AgentEngine, text: string): { ok: true; args: string[] } | { ok: false; detail: string };LAUNCH_ARGS_MAX_CHARS = 1024;LAUNCH_ARGS_MAX_WORDS = 20.
Step 1: Write the failing tests in
launchArgs.spec.ts:parseLaunchArgs('claude', '--chrome')→{ ok: true, args: ['--chrome'] }.parseLaunchArgs('claude', ' ')→{ ok: true, args: [] }.parseLaunchArgs('claude',--add-dir "/a b" --x='y z' c\ d)→ args['--add-dir', '/a b', "--x=y z", 'c d'].- Unclosed quote
'--x "a'→ok: false, detail containsquote. - 21 words →
ok: false, detail contains20. - 1025 characters →
ok: false, detail contains1024. - Text containing
\nor\0→ok: false. - Claude: each refused flag, bare and as
--model=opus, plus the quoted'"--model"', givesok: falsewith detail--model is set by Harness and can't be added here.. - Claude
-c→ refused. Codex-c model_reasoning_effort=high→ok: true. - Codex
resumeas the first word → refused. Codex--search resume→ok: true. parseLaunchArgs('opencode', '--model x')→ok: true.
Step 2: Run
cd cli && npx vitest run src/lib/launchArgs.spec.ts. Expected: FAIL (module not found).Step 3: Implement
parseLaunchArgs.- A small POSIX word splitter: whitespace separates words; single quotes are literal; double quotes allow
\"and\\; a backslash outside quotes escapes the next character. - Then the limits, then the per-engine refused sets from Global Constraints. Compare
word.split('=')[0]. - Detail for a refused flag is
`${flag} is set by Harness and can't be added here.`.
- A small POSIX word splitter: whitespace separates words; single quotes are literal; double quotes allow
Step 4: Run the same command. Expected: PASS.
Step 5: Commit
git add cli/src/lib/launchArgs.ts cli/src/lib/launchArgs.spec.ts git commit -m "cli: parse and validate a Buddy's extra launch flags"
Task 2: Save launch flags on the agent record and apply them on every launch (CLI)
Files:
- Modify:
cli/src/lib/registry.ts:RegisteredSessionnearswarmSkill;- the row normaliser near line 689 (
const { … swarmSkill: rawSwarmSkill, ...rest } = row); - the load near line 1387;
- add
setLaunchArgsbesidesetLaunchModel(~2590).
- Modify:
cli/src/lib/launchOverrides.ts:LaunchSourcegetslaunchArgs?: string[]; append it afterswarm!.args(engine)(~line 323) and beforeswarmInstructions. - Modify:
cli/src/core/agents/launch.ts:61: passlaunchArgs: session.launchArgsintobuildLaunchOverrides. - Test:
cli/src/lib/registry.spec.ts,cli/src/lib/launchOverrides.spec.ts
Interfaces:
Consumes: none.
Produces:
RegisteredSession.launchArgs?: string[];registry.setLaunchArgs(agentId: string, args: string[]): boolean. An empty array deletes the field; it returns false for an unknown agent.
Step 1: Write the failing tests.
- registry.spec:
setLaunchArgs('a1', ['--chrome'])then reload from disk →byAgent('a1').launchArgsequals['--chrome'].setLaunchArgs('a1', [])→ the field is absent ('launchArgs' in rowis false).- A row with
launchArgs: [1, '--x']orlaunchArgs: 'x'on disk loads with nolaunchArgs. Only an array of strings is kept. - A stopped-row round trip through the normaliser keeps
['--chrome'].
- launchOverrides.spec: a Buddy source (
swarmSkillrolebuddy) withlaunchArgs: ['--chrome']givesextraArgswhere--chromecomes after the Swarm args and before the instruction args (--append-system-promptfor Claude). With nolaunchArgs,extraArgsis unchanged from today.
- registry.spec:
Step 2: Run
cd cli && npx vitest run src/lib/registry.spec.ts src/lib/launchOverrides.spec.ts. Expected: the new cases FAIL.Step 3: Implement.
- Parse with a guard
Array.isArray(v) && v.every(w => typeof w === 'string') && v.length > 0, in both the normaliser and the load. setLaunchArgsmirrorssetLaunchModel, persisting the same way.- Pass the field through
launch.ts.
- Parse with a guard
Step 4: Run the same command. Expected: PASS. Also run
cd cli && npx tsc --noEmit -p .. Expected: clean.Step 5: Commit
git add cli/src/lib/registry.ts cli/src/lib/registry.spec.ts cli/src/lib/launchOverrides.ts cli/src/lib/launchOverrides.spec.ts cli/src/core/agents/launch.ts git commit -m "cli: an agent's saved launch flags ride every relaunch"
Task 3: agent_restart takes launchArgs (CLI)
Files:
- Modify:
cli/src/core/agents/launches.ts:relaunch(~line 600). The deps type gainssetLaunchArgs. - Modify:
cli/src/core/main.ts: wiresetLaunchArgs: (id, a) => registry.setLaunchArgs(id, a)wherelaunchesis built (the block withbyAgent: (id) => registry.byAgent(id), toProject: …near line 3059). - Test:
cli/src/core/agents/launches.spec.ts
Interfaces:
Consumes:
parseLaunchArgs(Task 1) andregistry.setLaunchArgs(Task 2).Produces:
- Request
agent_restart { agentId, creationId?, launchArgs?: string }. - Reply: today's shape plus
launchArgs: string[]whenever the request carriedlaunchArgs. That holds for the direct reply and for the receipt reply. - Error
{ error: 'INVALID_LAUNCH_ARGS', detail }.
- Request
Step 1: Write the failing tests in launches.spec, using its existing
setup():- Restart with
launchArgs: '--chrome'callssetLaunchArgs('agent-1', ['--chrome'])before the restart runs. The reply containslaunchArgs: ['--chrome'], both with and withoutcreationId. launchArgs: ''callssetLaunchArgs(id, [])and echoes[].launchArgs: '--model x'repliesINVALID_LAUNCH_ARGSwith detail--model is set by Harness and can't be added here., and neither restarts nor saves.- A non-string
launchArgs(for example5) →INVALID_LAUNCH_ARGS. agent_resumewithlaunchArgs→INVALID_LAUNCH_ARGS. Only restart takes them.- A team-written agent (
permissionMode: 'teamWritten') withlaunchArgs→INVALID_LAUNCH_ARGS. - Two requests with the same
creationIdand differentlaunchArgs→ the second is refused as a mismatched receipt. Use the error the receipt store already gives a different fingerprint.
- Restart with
Step 2: Run
cd cli && npx vitest run src/core/agents/launches.spec.ts. Expected: the new cases FAIL.Step 3: Implement in
relaunch.- Before
invoke: whenpayload.launchArgs !== undefined:- refuse unless
operation === 'restart'and it is a string; - refuse a team-written target;
- parse it with the target's engine (
byAgent(target)!.engine); - then
setLaunchArgs(target, parsed.args).
- refuse unless
- Add
launchArgs(the parsed words) tocreationFingerprint(...)when present. - Add
launchArgs: parsed.argsto both reply paths when present.
- Before
Step 4: Run the same command plus
cd cli && npx tsc --noEmit -p .. Expected: PASS, clean.Step 5: Commit
git add cli/src/core/agents/launches.ts cli/src/core/agents/launches.spec.ts cli/src/core/main.ts git commit -m "cli: agent_restart saves and echoes extra launch flags"
Task 4: The agent frame carries launchArgs (CLI)
Files:
- Modify:
cli/src/lib/agentFrame.ts: theAgentFrameinterface andagentFrame(s, …)addlaunchArgs?: string[]when the session has any. - Test:
cli/src/lib/agentFrame.spec.ts
Interfaces:
Produces:
AgentFrame.launchArgs?: string[]. It is absent when the session has none.Step 1: Write the failing tests.
agentFrame({ ...session, launchArgs: ['--chrome'] }, ctx)haslaunchArgs: ['--chrome'].- A session without the field gives a frame with no
launchArgskey.
Step 2: Run
cd cli && npx vitest run src/lib/agentFrame.spec.ts. Expected: FAIL.Step 3: Implement the conditional spread in
agentFrame.Step 4: Run the same command, then
cd cli && npx vitest run src/core src/lib && npx tsc --noEmit -p . && npm run test:core. Expected: PASS, clean, 100% coverage forsrc/core.Step 5: Commit
git add cli/src/lib/agentFrame.ts cli/src/lib/agentFrame.spec.ts git commit -m "cli: an agent's frame names its extra launch flags"
Task 5: Desktop sends launchArgs and reads them back
Files:
- Modify:
desktop/lib/core/models.dart:Agentgainsfinal List<String> launchArgs(defaultconst []);Agent.fromJsonreadsj['launchArgs'], keeping only strings.
- Modify:
desktop/lib/state/app_state.dart:RestartAgentResultgainsfinal bool launchArgsIgnored(default false);restartAgent(machineId, agentId, {AgentRestartAttempt? attempt, String? launchArgs})and_runAgentRestartadd'launchArgs': launchArgsto theagent_restartpayload when it is non-null and the request is not a status check.
- Test:
desktop/test/agent_restart_launch_args_test.dart
Interfaces:
Produces:
AppNotifier.restartAgent(String machineId, String agentId, {AgentRestartAttempt? attempt, String? launchArgs});RestartAgentResult.launchArgsIgnored;Agent.launchArgs.
Step 1: Write the failing tests. Use the recording fake connection the existing restart tests use.
restartAgent('m1', 'a1', launchArgs: '--chrome')sends anagent_restartpayload withlaunchArgs: '--chrome'.- A reply that echoes
launchArgsgiveslaunchArgsIgnored == false. - A created reply with no
launchArgsgiveslaunchArgsIgnored == true. - A status check (
agent_create_status) path never sendslaunchArgsand never setslaunchArgsIgnored. Agent.fromJson({... 'launchArgs': ['--chrome', 3]})giveslaunchArgs == ['--chrome'].
Step 2: Run
cd desktop && flutter test test/agent_restart_launch_args_test.dart. Expected: FAIL.Step 3: Implement.
launchArgsIgnored=launchArgs != null && !checking && result['launchArgs'] == null && no error.- The status-check request keeps its payload unchanged.
Step 4: Run the same command plus
flutter analyze. Expected: PASS, no issues.Step 5: Commit
git add desktop/lib/core/models.dart desktop/lib/state/app_state.dart desktop/test/agent_restart_launch_args_test.dart git commit -m "desktop: restart an agent with extra launch flags"
Task 6: "Restart Buddy…" in the Buddy chat's menu (Desktop)
Files:
- Create:
desktop/lib/super_tabs/buddy_restart.dart:Future<void> showRestartBuddy(BuildContext context, SuperTabController c, String projectId, {AppNotifier? app});- its dialog widget, following
showRenameBuddy's dialog style.
- Modify:
desktop/lib/super_tabs/view.dart(~line 3960): after "Rename Buddy…", additem('Restart Buddy…', …)wheneditable && c.buddy(group.projectId) != null. - Test:
desktop/test/super_tab_buddy_restart_test.dart
Interfaces:
Consumes:
AppNotifier.restartAgent(..., launchArgs:),RestartAgentResult.launchArgsIgnoredandAgent.launchArgs(Task 5);c.buddy(projectId)(SuperTabAgentwithmachineId,harnessId);buddyMachineName(c, machineId, app: app)(buddies.dart).
Step 1: Write the failing widget tests.
- The menu shows "Restart Buddy…" on the reader's own Buddy chat, and not on a project chat or a read-only Buddy history chat.
- The dialog prefills
--chromefrom the machine agent'slaunchArgsand shows the exact detail line with the engine and machine name. - Pressing Restart calls
restartAgent(machineId, harnessId, launchArgs: '--chrome --x'); on success the dialog closes. - An
INVALID_LAUNCH_ARGSresult shows the daemon's detail under the field, and the dialog stays open. - A failed restart shows "The Buddy didn't start with these flags. Fix or clear them and restart."
launchArgsIgnoredshows "Update Harness on to use launch flags."- Enter in the field restarts. While the request runs, the field is read-only and Restart shows progress.
Step 2: Run
cd desktop && flutter test test/super_tab_buddy_restart_test.dart. Expected: FAIL.Step 3: Implement the dialog and the menu item, using the copy from Global Constraints. The restart error text for
INVALID_LAUNCH_ARGSis the daemon'sdetail.Step 4: Run the same command plus
flutter analyze. Expected: PASS, no issues.Step 5: Commit
git add desktop/lib/super_tabs/buddy_restart.dart desktop/lib/super_tabs/view.dart desktop/test/super_tab_buddy_restart_test.dart git commit -m "desktop: Restart Buddy with extra launch flags"
Final checks
cd cli && npx tsc --noEmit -p . && npx vitest run src/lib src/core && npm run test:corecd desktop && flutter analyze && flutter test test/agent_restart_launch_args_test.dart test/super_tab_buddy_restart_test.dart- Manual: on Diego's Mac, restart his Claude Buddy with
--chromeand confirm the pane's process argv contains--chrome(ps). Then restart with an empty field and confirm it is gone.