sidecar-cli 0.1.4 → 0.1.5-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +257 -17
- package/dist/cli.js +673 -68
- package/dist/lib/banner.js +17 -1
- package/dist/lib/color.js +30 -0
- package/dist/lib/format.js +7 -1
- package/dist/lib/table.js +97 -0
- package/dist/prompts/packet-sections.js +203 -0
- package/dist/prompts/prompt-compiler.js +102 -72
- package/dist/prompts/prompt-service.js +16 -4
- package/dist/prompts/prompt-spec.js +128 -0
- package/dist/prompts/sections.js +194 -0
- package/dist/runners/claude-runner.js +7 -28
- package/dist/runners/codex-runner.js +7 -28
- package/dist/runners/config.js +75 -0
- package/dist/runners/runner-exec.js +152 -0
- package/dist/runs/capture.js +429 -0
- package/dist/runs/run-record.js +58 -0
- package/dist/runs/run-repository.js +2 -0
- package/dist/services/hook-service.js +130 -0
- package/dist/services/run-orchestrator-service.js +210 -11
- package/dist/services/run-review-service.js +1 -1
- package/dist/tasks/task-packet.js +18 -1
- package/dist/tasks/task-service.js +4 -1
- package/dist/templates/hooks.js +34 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -23,12 +23,6 @@ Install globally (stable):
|
|
|
23
23
|
npm install -g sidecar-cli
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
Note on npm deprecation warnings:
|
|
27
|
-
|
|
28
|
-
- You may see a transitive warning for `prebuild-install@7.1.3` during install.
|
|
29
|
-
- This currently comes from `better-sqlite3` (Sidecar's SQLite dependency), not from Sidecar code directly.
|
|
30
|
-
- Sidecar still installs/works normally; we will update when upstream dependency chain moves off it.
|
|
31
|
-
|
|
32
26
|
Install beta:
|
|
33
27
|
|
|
34
28
|
```bash
|
|
@@ -64,7 +58,7 @@ brew upgrade sidecar
|
|
|
64
58
|
|
|
65
59
|
Requirements:
|
|
66
60
|
|
|
67
|
-
- Node.js
|
|
61
|
+
- Node.js 22+ (Sidecar uses the built-in `node:sqlite` module)
|
|
68
62
|
- npm
|
|
69
63
|
|
|
70
64
|
Install dependencies:
|
|
@@ -135,11 +129,34 @@ This creates:
|
|
|
135
129
|
|
|
136
130
|
Use `--force` to overwrite Sidecar-managed files.
|
|
137
131
|
|
|
132
|
+
## Two namespaces: `log` and `work`
|
|
133
|
+
|
|
134
|
+
Sidecar is one CLI that does two jobs: capture local project memory, and run AI coding agents against that memory. Each job has a namespace:
|
|
135
|
+
|
|
136
|
+
- **`sidecar log <cmd>`** — memory: `worklog`, `decision`, `note`, `recent`, `context`, `summary`, `session`, `event`, `artifact`
|
|
137
|
+
- **`sidecar work <cmd>`** — runner: `task`, `run`, `prompt`, `hooks`
|
|
138
|
+
|
|
139
|
+
The underlying verbs still work directly, so `sidecar worklog record ...` and `sidecar log worklog record ...` are equivalent. Pick the form that reads best in your workflow.
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
sidecar log worklog record --done "..." --files src/a.ts
|
|
143
|
+
sidecar log decision record --title "..." --summary "..."
|
|
144
|
+
sidecar log context --format markdown
|
|
145
|
+
sidecar log summary refresh
|
|
146
|
+
|
|
147
|
+
sidecar work task create --title "..."
|
|
148
|
+
sidecar work run T-001
|
|
149
|
+
sidecar work prompt compile ./prompt.yaml
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Run `sidecar log --help` or `sidecar work --help` for the full listing.
|
|
153
|
+
|
|
138
154
|
## Core commands
|
|
139
155
|
|
|
140
156
|
Global:
|
|
141
157
|
|
|
142
158
|
- `sidecar init [--force] [--name <project-name>] [--instructions-template <name>] [--instructions-file <path>] [--json]`
|
|
159
|
+
- `sidecar demo [--cleanup] [--json]`
|
|
143
160
|
- `sidecar status [--json]`
|
|
144
161
|
- `sidecar preferences show [--json]`
|
|
145
162
|
- `sidecar ui [--no-open] [--port <port>] [--install-only] [--project <path>] [--reinstall]`
|
|
@@ -148,6 +165,15 @@ Global:
|
|
|
148
165
|
- `sidecar export [--format json|jsonl] [--output <path>]`
|
|
149
166
|
- `sidecar help`
|
|
150
167
|
|
|
168
|
+
Runner and prompts:
|
|
169
|
+
|
|
170
|
+
- `sidecar run <task-id> [--runner codex|claude|codex,claude] [--agent-role <role>] [--dry-run] [--json]`
|
|
171
|
+
- `sidecar run replay <run-id> [--runner <r>] [--agent-role <role>] [--reason <text>] [--edit-prompt] [--dry-run] [--json]`
|
|
172
|
+
- `sidecar run list [--task <task-id>] [--json]` · `sidecar run show <run-id> [--json]`
|
|
173
|
+
- `sidecar run queue [--json]` · `sidecar run start-ready [--dry-run] [--json]`
|
|
174
|
+
- `sidecar prompt compile <task-or-file> [--runner <r>] [--agent-role <role>] [--budget <n>] [--section-policy ...] [--explain] [--format json] [-o <path>]`
|
|
175
|
+
- `sidecar hooks print` · `sidecar hook <session-start|session-end|file-edit|user-prompt> [--actor-name <name>] [--json]`
|
|
176
|
+
|
|
151
177
|
Context and summary:
|
|
152
178
|
|
|
153
179
|
- `sidecar context [--limit <n>] [--format text|markdown|json] [--json]`
|
|
@@ -179,6 +205,216 @@ Artifacts:
|
|
|
179
205
|
- `sidecar artifact add <path> [--kind file|doc|screenshot|other] [--note <text>] [--json]`
|
|
180
206
|
- `sidecar artifact list [--json]`
|
|
181
207
|
|
|
208
|
+
## Validation kinds and auto-approve
|
|
209
|
+
|
|
210
|
+
Task packets describe post-run validation commands under `execution.commands.validation`. Each entry is tagged with a **kind** so Sidecar can route the result intelligently, apply a sensible default timeout, and surface the outcome in the UI and CLI.
|
|
211
|
+
|
|
212
|
+
### Kinds
|
|
213
|
+
|
|
214
|
+
| Kind | Default timeout | Intended for |
|
|
215
|
+
| --- | --- | --- |
|
|
216
|
+
| `typecheck` | 3 min | `tsc --noEmit`, `mypy`, `pyright` |
|
|
217
|
+
| `lint` | 3 min | `eslint`, `ruff`, `golangci-lint` |
|
|
218
|
+
| `test` | 10 min | unit/integration suites |
|
|
219
|
+
| `build` | 10 min | bundlers, compilers, image builds |
|
|
220
|
+
| `custom` | 5 min | anything else (the legacy default) |
|
|
221
|
+
|
|
222
|
+
### Authoring
|
|
223
|
+
|
|
224
|
+
On the CLI, prefix a command with `kind:`. Entries without a prefix default to `custom`.
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
sidecar task create \
|
|
228
|
+
--title "Add import flow" \
|
|
229
|
+
--summary "..." --goal "..." \
|
|
230
|
+
--validate-cmds "typecheck:tsc --noEmit,lint:eslint .,test:npm test"
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
In a task packet JSON file, use the object form:
|
|
234
|
+
|
|
235
|
+
```json
|
|
236
|
+
"execution": {
|
|
237
|
+
"commands": {
|
|
238
|
+
"validation": [
|
|
239
|
+
{ "kind": "typecheck", "command": "tsc --noEmit" },
|
|
240
|
+
{ "kind": "test", "command": "npm test", "timeout_ms": 900000 },
|
|
241
|
+
"bash scripts/smoke.sh"
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
String entries are accepted for back-compat (promoted to `{ kind: "custom", command }` on load).
|
|
248
|
+
|
|
249
|
+
### Auto-approve on all-green
|
|
250
|
+
|
|
251
|
+
When every validation step passes for a run, Sidecar can auto-approve the run so you don't have to click through the review queue for a strictly-green outcome. It's opt-in:
|
|
252
|
+
|
|
253
|
+
```json
|
|
254
|
+
// .sidecar/preferences.json
|
|
255
|
+
{ "review": { "autoApproveOnAllGreen": true } }
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Behavior when enabled:
|
|
259
|
+
|
|
260
|
+
- The run's `review_state` flips to `approved`, `reviewed_by` is set to `sidecar:auto`, and the review note records how many steps passed.
|
|
261
|
+
- Runs with zero configured validation steps are **not** auto-approved — a runner-only success still requires a human click.
|
|
262
|
+
- Any failing step blocks the run as today (task moves to `blocked`, blocker message includes the kind).
|
|
263
|
+
|
|
264
|
+
## Dual-runner pipelines
|
|
265
|
+
|
|
266
|
+
Pass a comma-separated list to `--runner` and Sidecar runs each runner sequentially on the same task, feeding the previous run's summary into the next runner's compiled prompt as linked context.
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
sidecar run T-001 --runner codex,claude
|
|
270
|
+
sidecar run T-001 --runner codex,claude --agent-role builder-app --dry-run
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Each step produces its own run record linked back to the first run in the pipeline via `parent_run_id`. The CLI prints a one-line summary per step (runner, agent role, run id, status, duration, changed file count), and the full pipeline envelope is available with `--json`. Use this to pair a planner/builder runner with a reviewer runner, or to compare runners head-to-head on the same task.
|
|
274
|
+
|
|
275
|
+
## Replay a run
|
|
276
|
+
|
|
277
|
+
When a run finishes (whether ok, blocked, or failed) you can kick off a fresh run with the **same task** and a link back to the original via `sidecar run replay`. It's the fastest way to try a different runner, re-run after fixing a blocker, or fork a green run into an experiment without losing the audit trail.
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
sidecar run replay R-001 --reason "retry with claude after codex blocker"
|
|
281
|
+
sidecar run replay R-001 --runner claude --agent-role builder-app --edit-prompt
|
|
282
|
+
sidecar run replay R-001 --reason "dry-run with new validation" --dry-run
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Flags:
|
|
286
|
+
|
|
287
|
+
- `--runner codex|claude` — override the parent's runner (defaults to parent's runner).
|
|
288
|
+
- `--agent-role <role>` — override the parent's agent role.
|
|
289
|
+
- `--reason "<text>"` — stored on the new run as `replay_reason`; surfaced in CLI and UI.
|
|
290
|
+
- `--edit-prompt` — opens the compiled prompt in `$VISUAL`/`$EDITOR` before the runner starts so you can tweak it.
|
|
291
|
+
- `--dry-run` — compile the prompt and create the run record without executing the runner.
|
|
292
|
+
- `--json` — machine-readable envelope output.
|
|
293
|
+
|
|
294
|
+
The new run record carries `parent_run_id: "R-001"` plus your `replay_reason`. `sidecar run show <id>` renders the lineage both ways:
|
|
295
|
+
|
|
296
|
+
- The parent shows **Replayed as:** with each child run id.
|
|
297
|
+
- Each child shows **Replay of:** with the parent id and reason.
|
|
298
|
+
|
|
299
|
+
The UI's Run Detail panel mirrors this: `Replay of:` links back to the parent; `Replays:` lists every child with its status. Both are clickable for one-hop navigation through a lineage.
|
|
300
|
+
|
|
301
|
+
## Ambient capture via Claude Code hooks
|
|
302
|
+
|
|
303
|
+
Sidecar can capture an ongoing Claude Code session into worklog/session records **without any explicit `sidecar worklog record` calls**. Once you wire Claude Code's hook system to `sidecar hook <event>`, every session start, file edit, and session end flows into your project memory automatically.
|
|
304
|
+
|
|
305
|
+
Print the ready-to-paste settings block:
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
sidecar hooks print
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Paste the `hooks` object into `.claude/settings.json` (project) or `~/.claude/settings.json` (user). Claude Code merges hook arrays across scopes, so user-level and project-level hooks compose.
|
|
312
|
+
|
|
313
|
+
The template wires four events:
|
|
314
|
+
|
|
315
|
+
| Claude Code event | Sidecar hook | Effect |
|
|
316
|
+
| ------------------ | ---------------------- | ------------------------------------------------------------------ |
|
|
317
|
+
| `SessionStart` | `sidecar hook session-start` | Opens a Sidecar session (`actor=agent`, name `claude-code:<sid>`). Idempotent. |
|
|
318
|
+
| `SessionEnd` | `sidecar hook session-end` | Closes the active session. Safe to call when none is open. |
|
|
319
|
+
| `PostToolUse` (Edit\|Write\|MultiEdit\|NotebookEdit) | `sidecar hook file-edit` | Records a worklog `"Edited <path> via <tool>"` and links the file as an artifact. Lazy-opens a session if none is active. |
|
|
320
|
+
| `UserPromptSubmit` | `sidecar hook user-prompt` | Records the first 200 chars of the prompt as a note. |
|
|
321
|
+
|
|
322
|
+
Each hook:
|
|
323
|
+
|
|
324
|
+
- Reads its payload JSON from stdin (Claude Code supplies it automatically).
|
|
325
|
+
- **Always exits 0** — hooks never block the caller, even on internal errors.
|
|
326
|
+
- Accepts `--actor-name <name>` to override the default actor name.
|
|
327
|
+
- Accepts `--json` to emit a structured envelope (useful when testing).
|
|
328
|
+
|
|
329
|
+
Quick manual smoke test:
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
echo '{"session_id":"abc"}' | sidecar hook session-start
|
|
333
|
+
echo '{"tool_name":"Edit","tool_input":{"file_path":"'"$PWD"'/README.md"}}' | sidecar hook file-edit
|
|
334
|
+
sidecar hook session-end
|
|
335
|
+
sidecar recent --type worklog --limit 3
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
Codex users can invoke the same CLI from any shell hook or wrapper script — the payload schema is permissive, so a minimal `{"tool_input":{"file_path":"..."}}` works.
|
|
339
|
+
|
|
340
|
+
## Automatic prompt token budgeting
|
|
341
|
+
|
|
342
|
+
When Sidecar compiles task prompts (`sidecar prompt compile` and run execution flows), it automatically applies a token budget to reduce context size without degrading execution quality.
|
|
343
|
+
|
|
344
|
+
Current behavior:
|
|
345
|
+
|
|
346
|
+
- Keeps required sections intact (task, objective, constraints, validation, definition of done).
|
|
347
|
+
- Deduplicates repeated list items.
|
|
348
|
+
- Trims only optional high-volume sections when needed (for example: in-scope lists, linked notes/decisions, long file lists).
|
|
349
|
+
- Adds compact overflow lines such as `+ N more ... (see task packet for full list)`.
|
|
350
|
+
|
|
351
|
+
Current defaults:
|
|
352
|
+
|
|
353
|
+
- Target budget: ~1200 estimated tokens
|
|
354
|
+
- Safety ceiling: ~1500 estimated tokens
|
|
355
|
+
|
|
356
|
+
Prompt optimization data is included in compile output and stored on run records:
|
|
357
|
+
|
|
358
|
+
- `prompt_tokens_estimated_before`
|
|
359
|
+
- `prompt_tokens_estimated_after`
|
|
360
|
+
- `prompt_budget_target`
|
|
361
|
+
- `prompt_trimmed_sections`
|
|
362
|
+
|
|
363
|
+
## Freestanding prompt specs
|
|
364
|
+
|
|
365
|
+
`sidecar prompt compile` also accepts a `.yaml`/`.yml`/`.json` spec file — no TaskPacket required. This lets you iterate on prompts directly, or compose them programmatically from another tool.
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
sidecar prompt compile ./my-prompt.yaml
|
|
369
|
+
sidecar prompt compile ./my-prompt.yaml --explain
|
|
370
|
+
sidecar prompt compile ./my-prompt.yaml --budget 1500 --budget-max 2000
|
|
371
|
+
sidecar prompt compile ./my-prompt.yaml --section-policy notes=drop,examples=trim-last
|
|
372
|
+
sidecar prompt compile ./my-prompt.yaml -o out.md
|
|
373
|
+
sidecar prompt compile ./my-prompt.yaml --format json
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Spec schema:
|
|
377
|
+
|
|
378
|
+
```yaml
|
|
379
|
+
header:
|
|
380
|
+
- "# My Prompt"
|
|
381
|
+
- "Optional preamble rendered verbatim."
|
|
382
|
+
|
|
383
|
+
sections:
|
|
384
|
+
- id: objective # optional — auto-slugified from title if omitted
|
|
385
|
+
title: Objective
|
|
386
|
+
required: true # forces policy=keep (never trimmed or dropped)
|
|
387
|
+
content: | # text section: string or string[]
|
|
388
|
+
Describe the goal in one or two sentences.
|
|
389
|
+
|
|
390
|
+
- title: Notes
|
|
391
|
+
list: # list section
|
|
392
|
+
- First note
|
|
393
|
+
- Second note
|
|
394
|
+
- Third note
|
|
395
|
+
empty_placeholder: "- no notes yet"
|
|
396
|
+
trim:
|
|
397
|
+
policy: trim-last # keep | trim-last | drop
|
|
398
|
+
limit: 2 # target-pass cap
|
|
399
|
+
limit_strict: 1 # safety-valve cap
|
|
400
|
+
overflow_label: notes # renders "+ N more notes (see task packet for full list)"
|
|
401
|
+
|
|
402
|
+
budget:
|
|
403
|
+
target: 1200 # soft target
|
|
404
|
+
max: 1500 # hard ceiling before strict pass
|
|
405
|
+
|
|
406
|
+
policy_overrides:
|
|
407
|
+
notes: keep # override per-section trim policies by id
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
Trim policies:
|
|
411
|
+
|
|
412
|
+
- `keep` — never trim or drop (default for text sections and `required: true`)
|
|
413
|
+
- `trim-last` — apply `limit` on the target pass, `limit_strict` on the strict pass (lists only)
|
|
414
|
+
- `drop` — remove the whole section on the strict pass when still over budget
|
|
415
|
+
|
|
416
|
+
`--explain` prints a per-section trace (policy applied, tokens, items kept/total) to stderr. `--format json` emits the standard envelope with `markdown` + full `metadata.sections` trace for programmatic use.
|
|
417
|
+
|
|
182
418
|
## Example workflow
|
|
183
419
|
|
|
184
420
|
```bash
|
|
@@ -289,22 +525,26 @@ sidecar ui --project ../other-repo
|
|
|
289
525
|
sidecar ui --reinstall
|
|
290
526
|
```
|
|
291
527
|
|
|
292
|
-
|
|
528
|
+
UI screens:
|
|
293
529
|
|
|
294
|
-
-
|
|
295
|
-
-
|
|
296
|
-
-
|
|
297
|
-
-
|
|
298
|
-
-
|
|
530
|
+
- **Mission Control**: open tasks, ready queue, runs in flight, pipelines, and run review queue — the main operational surface.
|
|
531
|
+
- **Run Detail**: compiled prompt and runner log viewers, typed validation results (kind badges, exit code, duration, snippet), replay lineage (`Replay of:` / `Replays:`), and auto-approval markers.
|
|
532
|
+
- **Overview**: project info, active session, recent decisions/worklogs, open tasks, recent notes, and counts.
|
|
533
|
+
- **Timeline**: paginated event stream (load-more).
|
|
534
|
+
- **Tasks** and **Decisions**: list views with summary and timestamps.
|
|
535
|
+
- **Preferences**: edit `.sidecar/preferences.json` and view `.sidecar/summary.md`.
|
|
299
536
|
|
|
300
|
-
UI write support
|
|
537
|
+
UI write support:
|
|
301
538
|
|
|
302
|
-
- Add notes from Overview
|
|
303
|
-
-
|
|
304
|
-
- Edit `.sidecar/preferences.json` from Preferences
|
|
539
|
+
- Add notes and open tasks from Overview.
|
|
540
|
+
- Trigger `run replay` with optional reason, runner override, and agent-role override from Run Detail.
|
|
541
|
+
- Edit `.sidecar/preferences.json` from Preferences.
|
|
305
542
|
- `output.humanTime` controls timestamp style in human-readable CLI output:
|
|
306
543
|
- `true`: friendly local times (for example `3/18/2026, 11:51 AM`)
|
|
307
544
|
- `false`: raw ISO-style timestamps
|
|
545
|
+
- `review.autoApproveOnAllGreen` — auto-approve runs when every validation step passes (see "Validation kinds and auto-approve").
|
|
546
|
+
|
|
547
|
+
See [packages/ui/UI.md](packages/ui/UI.md) for the full UI reference (state model, views, modals, HTTP API, accessibility).
|
|
308
548
|
|
|
309
549
|
## JSON output
|
|
310
550
|
|