Commit 59670f0
Copilot SDK-powered spec compiler (#7)
* feat: add compile build command using Copilot SDK
Adds a new `build` subcommand to the spec compiler that uses
`@github/copilot-sdk` to launch a Copilot agent session, feed it the
generated compilation prompt, and stream the agent's work to the terminal.
The build command:
- Validates Copilot auth before starting (with clear error messages)
- Prompts for model selection via `gum choose` (falls back to defaults)
- Prompts for reasoning effort (skipped if model doesn't support it)
- Creates an autopilot session (approveAll — no permission prompts)
- Streams output in two modes:
- Normal: compact phase-level status with tool activity
- Verbose (--verbose): raw agent transcript with streaming deltas
- Tracks metrics: tokens, tool calls, files written
- Prints a compilation summary (time, files, LOC, tokens)
- Auto-locks specs on success (skip with --no-lock)
- Handles SIGINT for graceful cancellation
New flags: --model, --effort, --verbose, --no-lock
Existing commands (status, prompt, lock, clean) are unchanged.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat: always prompt for model, effort, and output dir with good defaults
Flags (--model, --effort, --out) now pre-select the default value in
the interactive prompt rather than skipping it entirely. Adds a new
output directory picker via `gum input`.
Flow order changed: auth runs first (fail fast), then interactive
config, then prompt generation uses the user-chosen distDir.
Non-TTY / no gum: falls back to sensible defaults silently.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat: add multi-pass compilation loop with improvement prompts
After each compilation pass, the user is prompted to run another pass.
Subsequent passes send the agent a focused improvement prompt that
re-reads specs and fixes missed implementations, failing tests, and
inconsistencies.
- printSummary now shows pass number and cumulative pass count
- Session stays alive between passes (only disconnects on exit)
- gum confirm with readline fallback for pass prompt
- Auto-lock deferred until all passes complete
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: count only agent-written files in build metrics
Replace scanOutput() filesystem walk with countAgentOutput() that
uses the tracked filesWritten set from tool execution events. This
excludes node_modules and other non-agent files from the count.
Also track file deletions separately so the summary shows
'N written, M deleted' when files are removed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: show lock file path when no dirty specs found
Helps users understand which lock file is keeping specs clean.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor: replace gum log with chalk for all status output
Use chalk-based console.log consistently for compilation status
messages instead of shelling out to gum log. Removes gumLog helper.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: broaden tool name matching for file metrics and phase detection
The Copilot SDK agent may use varying tool names (edit, create,
write_to_file, str_replace_editor, etc.) depending on the model.
Use substring matching on normalized tool names instead of exact
string comparisons so file writes are always tracked.
Also broadens the path argument lookup to check path, file_path,
filePath, and file argument names.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: use user-chosen dir directly as output, don't append target
The output dir picker default is now dist/<target>/ (e.g. dist/bun/).
If the user changes it to dist/bun-claude/, that's used as-is — no
extra /<target> suffix appended. The prompt command still correctly
joins distDir + target since it receives the base dist/ dir.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* style: remove gear icons from tool activity output
Use indentation and dim gray text only for cleaner output.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor: replace gum with @clack/prompts for interactive CLI
Remove gum (external Go binary) dependency entirely. All interactive
prompts (model picker, effort picker, output dir, multi-pass confirm)
now use @clack/prompts which runs in-process with zero external deps.
- Single code path instead of gum-vs-chalk branching
- No install prerequisites beyond Bun
- Add Copilot subscription to README prerequisites
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat: show agent's last message after each pass completes
Displays the agent's final message between the phase checkmarks and the
summary stats. Gives visibility into what the agent accomplished in each
pass without needing verbose mode.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat: reframe prompt for depth-first compilation
Restructure the compilation prompt to prioritize a working interactive
playground over surface coverage. Key changes:
- Add 'depth over breadth' philosophy section
- Require components to be fully complete (impl + tests + demo) before
moving to the next one
- Make --interactive the primary output, not a stub
- Verification happens per-component, not just at the end
- Multi-pass improvement prompt reinforces interactive demo priority
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat: render agent summary as markdown in a box
Use marked + marked-terminal to render the agent's final message with
proper markdown formatting (headings, bold, code, lists) and wrap it
in a boxen container with dim border and 'Agent summary' title.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat: add multi-pass summary instructions to system prompt
Tell the agent to end each pass with a structured summary of what was
accomplished and explicit next-pass priorities. This makes the boxed
agent summary actionable and helps the user decide whether to run
another pass.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat: instruct agent to verify dependencies via web browsing
Add rule to system prompt telling the agent to check npm/GitHub for
libraries before assuming they don't exist. Prevents knowledge cutoff
issues where the agent falls back to polyfills for packages that are
actually published.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat: lock after each pass to bank completed work
Previously the lock only ran once after all passes finished. Now each
successful pass (no errors) locks immediately, so completed components
are banked incrementally. A bad subsequent pass won't lose the progress
from earlier passes.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat: delegate lock to the agent per-component
Remove auto-lock after passes. Instead, instruct the agent in the system
prompt to run 'bun run compile lock --target <t> --component <Name>'
after fully completing each component (tests pass + demo wired). This
ensures only genuinely completed components get locked.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat: add --autopilot flag for unattended multi-pass builds
Auto-continues passes without prompting, up to a max of (dirty specs + 5)
passes. Shows pass count as 'Pass N/max' in the log. Useful for running
full compilations unattended.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* docs: update README with build command, flags, and autopilot
Rewrite the 'Compiling to a target' section to document:
- All CLI commands in a table
- Full build flags reference (including --autopilot)
- Interactive vs autopilot workflow examples
- Agent-driven per-component locking
- Multi-pass philosophy (depth over breadth)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* docs: add 'Generating prompts manually' section to README
Document the compile prompt command as an alternative to compile build,
for users who want to feed prompts to external agents manually.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* docs: note that build sessions must run from dist target folder
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: address PR review -- no-lock suppresses agent instructions, fix prompt path docs
- --no-lock now conditionally omits lock instructions from system prompt
- Updated help text to reflect actual behavior
- Fixed README prompt path: <out>/<target>/_compile-prompt.md
- Fixed working directory guidance: repo root, not dist folder
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* 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>
* feat: keep manual multi-pass loop in both modes, SDK mode sets agent behavior
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor: autopilot flag only sets SDK mode, no custom pass logic
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: move sessionMode declaration before first use
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* docs: update README with new autopilot approach (SDK-driven, no custom loop)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat: offer manual passes in all modes, not just interactive
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor: unified clack timeline for build output
Replace disconnected log blocks with @clack/prompts timeline:
- printBuildHeader uses clack.log.step/info
- Normal mode phases: step → tool messages → success
- Agent summary uses clack.note (replaces boxen)
- printSummary uses clack.log.success/message
- Errors/warnings use clack.log.error/warn
- Multi-pass labels use clack.log.step
- clack.outro on cleanup and errors
- Remove boxen dependency (replaced by clack.note)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: compact tool call lines in clack timeline
Use raw log with │ prefix for tool activity instead of
clack.log.message() which adds extra blank lines between entries.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: count files/LOC by scanning output directory
Replace unreliable event-based file tracking (tool name heuristics
didn't match actual SDK tool names → 0 files) with a post-compilation
directory scan. Skips node_modules, .git, vendor, target, and other
common dependency/build folders.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: capture agent summary from deltas as fallback
The assistant.message event can have empty content. Accumulate
message_delta content and use it as fallback so the Agent summary
note always shows the last assistant response.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 4b9fb7b commit 59670f0
4 files changed
Lines changed: 979 additions & 64 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
174 | 204 | | |
175 | 205 | | |
176 | 206 | | |
177 | 207 | | |
178 | 208 | | |
179 | 209 | | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
| 210 | + | |
| 211 | + | |
185 | 212 | | |
186 | | - | |
187 | | - | |
| 213 | + | |
| 214 | + | |
188 | 215 | | |
189 | | - | |
190 | | - | |
| 216 | + | |
| 217 | + | |
191 | 218 | | |
192 | 219 | | |
193 | 220 | | |
194 | 221 | | |
195 | | - | |
196 | | - | |
197 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
198 | 232 | | |
199 | 233 | | |
200 | 234 | | |
201 | | - | |
202 | | - | |
203 | | - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
204 | 238 | | |
205 | | - | |
206 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
207 | 242 | | |
208 | | - | |
209 | | - | |
210 | | - | |
| 243 | + | |
211 | 244 | | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
216 | 249 | | |
217 | 250 | | |
218 | | - | |
219 | | - | |
220 | | - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
221 | 264 | | |
222 | 265 | | |
223 | 266 | | |
224 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
225 | 280 | | |
226 | 281 | | |
227 | | - | |
228 | | - | |
| 282 | + | |
| 283 | + | |
229 | 284 | | |
230 | | - | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
231 | 308 | | |
232 | 309 | | |
233 | 310 | | |
| |||
237 | 314 | | |
238 | 315 | | |
239 | 316 | | |
240 | | - | |
| 317 | + | |
241 | 318 | | |
242 | 319 | | |
243 | 320 | | |
| |||
0 commit comments