Skip to content

Commit 0d75e3d

Browse files
basiclinesCopilot
andcommitted
feat: use SDK session modes -- autopilot vs interactive
Set session.rpc.mode.set() based on --autopilot flag: - Default: 'interactive' mode, user confirms each pass - --autopilot: 'autopilot' mode, agent runs autonomously Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e5b979a commit 0d75e3d

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Optional:
197197
--effort <level> Reasoning effort: low | medium | high | xhigh
198198
--verbose Show full agent transcript (raw streaming)
199199
--no-lock Prevent the agent from locking components
200-
--autopilot Auto-run passes without confirmation (max: specs + 5)
200+
--autopilot Use SDK autopilot mode (agent runs autonomously, max: specs + 5 passes)
201201
--all-targets Compile all targets sequentially
202202
```
203203

@@ -228,12 +228,13 @@ on the previous output — the agent reviews, fixes, and extends its own work.
228228
| **2nd** | Extend & fix | More components added, test failures fixed, demo polished. |
229229
| **3rd** | Polish | Catches subtle spec violations, hardens edge cases. |
230230

231-
**Interactive mode** (default): After each pass, the compiler asks whether to
232-
continue. You see a boxed markdown summary of what the agent accomplished.
231+
**Interactive mode** (default): The agent runs in the SDK's `interactive` mode.
232+
After each pass, the compiler asks whether to continue. You see a boxed markdown
233+
summary of what the agent accomplished.
233234

234-
**Autopilot mode** (`--autopilot`): Passes auto-continue without prompting,
235-
up to a maximum of `(dirty specs + 5)` passes. The agent stops early if
236-
everything is complete.
235+
**Autopilot mode** (`--autopilot`): Sets the SDK agent mode to `autopilot`.
236+
Passes auto-continue without prompting, up to a maximum of `(dirty specs + 5)`
237+
passes. The agent stops early if everything is complete.
237238

238239
The agent is instructed to follow a **depth-over-breadth** philosophy: it fully
239240
completes each component (implementation + tests + interactive demo) before

scripts/compile.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -613,11 +613,11 @@ async function promptBuildConfig(
613613
return { model: model.id, effort, distDir, supportsEffort };
614614
}
615615

616-
function printBuildHeader(target: string, config: BuildConfig): void {
616+
function printBuildHeader(target: string, config: BuildConfig, mode: string): void {
617617
const effortStr = config.effort ? ` · Effort: ${config.effort}` : "";
618618
log(`\n${chalk.cyan("●")} ${chalk.bold("TUIkit compiler")}`);
619619
log(` Target: ${chalk.bold(target)} · Model: ${chalk.bold(config.model)}${effortStr}`);
620-
log(` Output: ${relative(SPECS_DIR, config.distDir)}/\n`);
620+
log(` Output: ${relative(SPECS_DIR, config.distDir)}/ · Mode: ${mode}\n`);
621621
}
622622

623623
function printSummary(
@@ -715,7 +715,7 @@ async function cmdBuild(
715715
writeFileSync(promptPath, prompt);
716716

717717
// 5. Print header
718-
printBuildHeader(target, config);
718+
printBuildHeader(target, config, sessionMode);
719719
log(` ${chalk.dim(`${dirty.length} dirty specs to compile`)}\n`);
720720

721721
// 6. Metrics
@@ -732,6 +732,7 @@ async function cmdBuild(
732732
};
733733

734734
// 7. Create session
735+
const sessionMode = autopilot ? "autopilot" : "interactive";
735736
const sessionConfig: Record<string, unknown> = {
736737
model: config.model,
737738
onPermissionRequest: approveAll,
@@ -815,7 +816,13 @@ your final message like this:
815816
process.exit(1);
816817
}
817818

818-
// 8. SIGINT handler
819+
// 8. Set SDK agent mode
820+
await session.rpc.mode.set({ mode: sessionMode });
821+
if (verbose) {
822+
log(chalk.dim(` Agent mode: ${sessionMode}`));
823+
}
824+
825+
// 9. SIGINT handler
819826
let aborted = false;
820827
const sigintHandler = async () => {
821828
if (aborted) return;
@@ -832,7 +839,7 @@ your final message like this:
832839
};
833840
process.on("SIGINT", sigintHandler);
834841

835-
// 9. Event handlers
842+
// 10. Event handlers
836843
let currentPhase = "Starting";
837844

838845
if (verbose) {
@@ -1198,7 +1205,7 @@ Build options:
11981205
--effort <level> Reasoning effort: low | medium | high | xhigh (default: high)
11991206
--verbose Show full agent transcript (raw streaming output)
12001207
--no-lock Suppress agent lock instructions (agent won't lock components)
1201-
--autopilot Auto-run passes without confirmation (max: components + 5)
1208+
--autopilot Use SDK autopilot mode — agent runs all passes autonomously
12021209
12031210
Common options:
12041211
--out <dir> Output directory for compiled code (default: dist/)

0 commit comments

Comments
 (0)