squadrant 0.16.5 → 0.17.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "squadrant",
3
3
  "packageManager": "pnpm@10.30.3",
4
- "version": "0.16.5",
4
+ "version": "0.17.0",
5
5
  "description": "Multi-project orchestration for your coding agents (Claude, Codex, opencode, Gemini)",
6
6
  "type": "module",
7
7
  "bin": {
@@ -8,17 +8,40 @@ description: Complete captain playbook — session startup, crew spawning, statu
8
8
  ## Session Startup
9
9
 
10
10
  1. Read `~/.config/squadrant/config.json` — match your current working directory. Note your `spokeVault`, `group`, `groupRole`, and `maxCrew` (default: 5).
11
- 2. **Check for handoff from previous session:**
11
+ 2. **Check for a handoff, and verify live repo state — every boot, not just when the handoff is missing:**
12
12
  ```bash
13
13
  ~/.config/squadrant/scripts/read-handoff.sh "{spokeVaultPath}"
14
+ squadrant handoff facts {project} --fetch
14
15
  ```
15
- If a handoff exists (`"exists"` is not false), read the context carefully:
16
+ `read-handoff.sh` — if a handoff exists (`"exists"` is not false), read the context carefully:
16
17
  - `currentState` — what was happening when the last session ended
17
18
  - `openBranches` — branches with uncommitted/unmerged work
18
19
  - `nextSteps` — what the previous session planned to do next
19
20
  - `blockedItems` — unresolved blockers
20
21
  - `decisions` — important decisions already made (don't re-decide)
21
- The handoff file is auto-deleted after reading. Use this as your primary context source.
22
+ The handoff file is archived to `{spokeVault}/handoffs/<date>.json` after reading (not deleted) — use it as your primary context source.
23
+
24
+ `squadrant handoff facts {project} --fetch` — run this **every session start, unconditionally**, not only when the handoff is missing. `--fetch` is the one deliberate network call in your startup: it updates remote-tracking refs before reporting, so what follows is verified, not stale-and-silent. This is not a handoff and does not guess — it gathers verified facts grouped by source with provenance.
25
+
26
+ **Check `liveRepo.branchState` explicitly — these are flags, act on them directly, don't just skim past them:**
27
+ - `upstreamStatus: "behind"` — your local branch is stale relative to origin; don't trust local-only diffs until you've reconciled.
28
+ - `upstreamStatus: "diverged"` — both sides moved; this needs a decision (rebase/merge), not silence.
29
+ - `upstreamStatus: "upstream-gone"` — the remote branch was deleted; this local branch is likely done.
30
+ - `upstreamStatus: "no-upstream"` — never pushed.
31
+ - `dirtyWorkingTree: true` — uncommitted changes are sitting from a prior session; find out why before proceeding.
32
+ - `onUnexpectedBranch: true` — you're sitting on a `crew/*` worktree branch; a captain's own checkout normally shouldn't be.
33
+ - `mergedIntoBase: true` — this branch is fully merged into base already; safe to switch back to base / clean up.
34
+ - (This is the direct fix for a real incident: local `main` was 164 commits behind origin with no signal anything was wrong, and got reported as "188 commits ahead" when the true count was 24. Don't let that happen silently again — these flags exist so you don't have to eyeball `git log`.)
35
+
36
+ **Check tasks from the same call — `liveRepo.liveCrews`** lists every non-terminal crew task (name/state/task/question) for this project. A `state: "blocked"` entry with a `question` is waiting on you right now; don't miss it under everything else in the payload.
37
+
38
+ If `read-handoff.sh` reported `"exists": false`, reconstruct from this SAME `handoff facts` call's output instead of cold-starting blind — no need to run it twice:
39
+ - `checkpoint` — the newest archived handoff, if any, read in full (already covers history up to when it was written).
40
+ - `gapSessions` — captain sessions after the checkpoint, each with its own transcript (the work no handoff covers — read `meta.gapSessionIds` to see the boundary at a glance).
41
+ - `claudeMem` — your project's raw recent session summary and decisions.
42
+ - `meta` — which sources were actually available (`sourcesAvailable`/`sourcesMissing`), and `registryNote`/`checkpointFilename`/`usedFallbackWindow` explaining how the gap was determined.
43
+
44
+ **You do the synthesizing, not the command.** Compose your own understanding of `currentState`/`openBranches`/`nextSteps`/`blockedItems`/`decisions` from this evidence — cross-referencing `liveRepo` (exact, current) against `claudeMem` (distilled, can be stale) and each gap session's `transcript` (inference) yourself. State plainly in-session that this context is reconstructed and therefore inferred, not what the previous session actually wrote.
22
45
  3. Search **claude-mem** (`mem-search` skill) for your project name to get additional continuity.
23
46
  4. Check `{spokeVault}/daily-logs/` — read the most recent log if one exists.
24
47
  5. Check `{spokeVault}/learnings/` — **selectively** load relevant learnings (see "Selective Loading" section below). Do NOT read all files — grep by task keywords and tags.
@@ -30,8 +53,6 @@ The handoff file is auto-deleted after reading. Use this as your primary context
30
53
  If relevant pages exist, read them for context before starting work.
31
54
  8. Crew lifecycle events (done / blocked / idle) are delivered to your captain pane automatically by the squadrant daemon via daemon-direct cmux delivery (#332). No relay setup required.
32
55
 
33
- 9. (Opt-in) Status writes are not required on every event. Only run `~/.config/squadrant/scripts/write-status.sh` when you have a meaningful note worth recording (a blocker, a deliberate "starting work on X", etc.) — not on a schedule.
34
-
35
56
  ## Crew Setup
36
57
 
37
58
  You do NOT create an Agent Team. You spawn each crew session on demand as a **new tab** in your workspace via `squadrant crew spawn` (use `--direction right|down|...` to split into a pane instead). The surface is a fresh CLI session with the crew template loaded as system prompt — disposable, restartable, runtime-agnostic.
@@ -232,15 +253,21 @@ When a crew sends you a status message via `squadrant runtime send <project> "<m
232
253
 
233
254
  CREW REVIEW is **unambiguous** — a crew ran `squadrant crew signal review` after committing its work to `crew/<name>`. Unlike CREW IDLE, this is never a stray heartbeat miss: the crew has explicitly paused and is waiting for your verdict. The task is **NOT terminal** — don't treat it like CREW DONE.
234
255
 
256
+ **Review Modes:**
257
+ - **DEFAULT mode (Wait for human):** When a crew signals review, the captain does its own review of the diff, then **STOPS** and surfaces a diff summary (files changed, scope, notable points) to the USER in chat, and **WAITS** for the user to review and approve. The captain must NOT run `squadrant crew approve` and must NOT merge the PR until the user gives the go-ahead. Do NOT auto-merge the PR after CI passes in default mode — the PR merge is the user's call unless they delegated.
258
+ - **DELEGATED mode (Captain auto):** ONLY when the user explicitly delegates for that review (e.g. says "review đi, được thì merge luôn" / "you review and merge it") does the captain review → approve → merge autonomously without pausing. Delegation is per-request; it does not become the standing default.
259
+
260
+ *Note: Either way the captain-side review still happens — the human gate is ADDED ON TOP of the captain review, not a replacement for it.*
261
+
235
262
  On CREW REVIEW:
236
263
 
237
264
  1. **Open the diff** — `squadrant diff <project> <crew>` (branch-vs-base; the default is exactly the review surface). Use `--staged`/`--unstaged`/`--working` if you also want to peek at anything left uncommitted.
238
- 2. **Classify:**
265
+ 2. **Classify (Captain-side review):**
239
266
 
240
267
  | Diff looks | Captain action |
241
268
  |-----------|-----------------|
242
- | Good — matches the task, tests pass, no scope creep | `squadrant crew approve <project> <crew>` pushes `crew/<name>` to origin, opens the PR, terminalizes DONE. |
243
- | Needs changes | `squadrant crew send <project> <crew> "<feedback>"` — the crew iterates, re-commits, and re-signals `review`. Loop until approved. |
269
+ | Good — matches the task, tests pass, no scope creep | **DEFAULT mode:** Surface diff summary to user and WAIT for go-ahead. Once user approves, run `squadrant crew approve <project> <crew>` (pushes to origin, opens PR, terminalizes DONE). Wait for user to decide on merging.<br><br>**DELEGATED mode:** Run `squadrant crew approve <project> <crew>`, then merge autonomously. |
270
+ | Needs changes | `squadrant crew send <project> <crew> "<feedback>"` — the crew iterates, re-commits, and re-signals `review`. Loop until approved. (No user gate needed for rejecting back to crew). |
244
271
 
245
272
  3. **Never auto-terminalize a CREW REVIEW yourself** by emitting `task.done` directly — always go through `squadrant crew approve` so the push+PR actually happens before the task closes.
246
273
  4. Do **not** re-send the original task or close the crew while it's awaiting review — `crew close` on a `review`-state task discards work that hasn't been pushed anywhere yet.
@@ -256,8 +283,6 @@ After a crew task completes:
256
283
  5. Record learnings if any (see "Recording Learnings" below).
257
284
  6. Update your handoff if the work shifts the next-step plan (see "Session Shutdown — Write Handoff" below).
258
285
 
259
- Status writes (`write-status.sh`) are opt-in; you don't need to write status after every event.
260
-
261
286
  ## Status Board (show after substantive turns)
262
287
 
263
288
  After a **substantive turn** — shipped a release, opened or merged a PR, filed an issue, spawned or closed crews, or moved multiple threads at once — end your reply with a tight scannable board. Skip it after trivial answers; the board is signal, not noise.
@@ -1,7 +1,8 @@
1
1
  #!/bin/bash
2
2
  # Usage: read-handoff.sh <spoke-vault-path> [--keep]
3
- # Reads and prints handoff.json, then deletes it (unless --keep).
4
- # Captain calls this on session startup to load previous context.
3
+ # Reads and prints handoff.json, then archives it to handoffs/<date>.json
4
+ # (unless --keep). Captain calls this on session startup to load previous
5
+ # context.
5
6
  set -euo pipefail
6
7
 
7
8
  VAULT="${1:?Usage: read-handoff.sh <vault-path> [--keep]}"
@@ -16,7 +17,18 @@ fi
16
17
  # Print the handoff content
17
18
  cat "$HANDOFF_FILE"
18
19
 
19
- # Delete unless --keep flag
20
+ # Archive (don't delete) unless --keep flag. Multi-session days are the norm
21
+ # (compacts, relaunches), so a same-day archive must never be clobbered by a
22
+ # later read on the same day — uniquify with -2, -3, ... instead of overwriting.
20
23
  if [ "$KEEP" != "--keep" ]; then
21
- rm "$HANDOFF_FILE"
24
+ ARCHIVE_DIR="$VAULT/handoffs"
25
+ mkdir -p "$ARCHIVE_DIR"
26
+ DATE=$(date -u +%Y-%m-%d)
27
+ DEST="$ARCHIVE_DIR/$DATE.json"
28
+ N=2
29
+ while [ -e "$DEST" ]; do
30
+ DEST="$ARCHIVE_DIR/$DATE-$N.json"
31
+ N=$((N + 1))
32
+ done
33
+ mv "$HANDOFF_FILE" "$DEST"
22
34
  fi