MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / composeCommand

Function composeCommand

src/workspaces/adapters/pi.ts:75–93  ·  view source on GitHub ↗
(_base: readonly string[], ctx: SpawnContext)

Source from the content-addressed store, hash-verified

73 },
74
75 composeCommand(_base: readonly string[], ctx: SpawnContext): readonly string[] {
76 // Tools come from the CLI-injection path (alice on PATH + .pi/skills), not
77 // flags — so the command head is just the binary + a resume flag (if any).
78 const head = ['pi'];
79 // Quick-chat seed: `pi [--session-id <id>] <messages…>` opens the
80 // interactive TUI seeded with that first message. UNLIKE the other adapters,
81 // pi appends the seed REGARDLESS of the resume branch: pi assigns its own id
82 // at spawn (`assignsSessionId`), so a FRESH seeded spawn arrives here with
83 // BOTH a launcher-minted `{ sessionId }` AND `initialPrompt`. The launcher
84 // only ever sets `initialPrompt` on a fresh spawn, so its presence is itself
85 // the "this is fresh" signal — a real resume never carries one. NOTE pi
86 // REJECTS a `--` terminator ("Unknown option: --", verified 0.78.1), so the
87 // prompt is a bare trailing positional (a prompt starting with `-`/`--` is
88 // unprotected on pi; rare for chat messages — the other adapters guard with `--`).
89 const seed = ctx.initialPrompt ? [ctx.initialPrompt] : [];
90 if (ctx.resume === undefined) return [...head, ...seed];
91 if (ctx.resume === 'last') return [...head, '--continue', ...seed];
92 return [...head, '--session-id', ctx.resume.sessionId, ...seed];
93 },
94
95 // Headless: `pi -p <prompt>` is non-interactive and exits at the turn
96 // boundary. The MCP bridge + skills auto-load from `<cwd>/.pi` (process cwd =

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected