@bradygaster/squad-cli 0.9.6-insider.2 → 0.10.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/dist/cli/commands/copilot-bridge.d.ts.map +1 -1
- package/dist/cli/commands/copilot-bridge.js +5 -1
- package/dist/cli/commands/copilot-bridge.js.map +1 -1
- package/dist/cli/commands/doctor.d.ts +6 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -1
- package/dist/cli/commands/doctor.js +120 -5
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/export.d.ts +7 -3
- package/dist/cli/commands/export.d.ts.map +1 -1
- package/dist/cli/commands/export.js +68 -16
- package/dist/cli/commands/export.js.map +1 -1
- package/dist/cli/commands/import.d.ts +7 -3
- package/dist/cli/commands/import.d.ts.map +1 -1
- package/dist/cli/commands/import.js +140 -42
- package/dist/cli/commands/import.js.map +1 -1
- package/dist/cli/commands/install-hooks.d.ts.map +1 -1
- package/dist/cli/commands/install-hooks.js +50 -5
- package/dist/cli/commands/install-hooks.js.map +1 -1
- package/dist/cli/commands/link.d.ts.map +1 -1
- package/dist/cli/commands/link.js +7 -1
- package/dist/cli/commands/link.js.map +1 -1
- package/dist/cli/commands/loop.d.ts.map +1 -1
- package/dist/cli/commands/loop.js +7 -5
- package/dist/cli/commands/loop.js.map +1 -1
- package/dist/cli/commands/memory.d.ts +2 -0
- package/dist/cli/commands/memory.d.ts.map +1 -0
- package/dist/cli/commands/memory.js +304 -0
- package/dist/cli/commands/memory.js.map +1 -0
- package/dist/cli/commands/migrate-backend.d.ts +36 -5
- package/dist/cli/commands/migrate-backend.d.ts.map +1 -1
- package/dist/cli/commands/migrate-backend.js +250 -40
- package/dist/cli/commands/migrate-backend.js.map +1 -1
- package/dist/cli/commands/notes.d.ts +27 -0
- package/dist/cli/commands/notes.d.ts.map +1 -0
- package/dist/cli/commands/notes.js +222 -0
- package/dist/cli/commands/notes.js.map +1 -0
- package/dist/cli/commands/plugin.d.ts.map +1 -1
- package/dist/cli/commands/plugin.js +423 -8
- package/dist/cli/commands/plugin.js.map +1 -1
- package/dist/cli/commands/skill.d.ts +31 -0
- package/dist/cli/commands/skill.d.ts.map +1 -0
- package/dist/cli/commands/skill.js +497 -0
- package/dist/cli/commands/skill.js.map +1 -0
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +9 -1
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/state-mcp.d.ts +25 -0
- package/dist/cli/commands/state-mcp.d.ts.map +1 -0
- package/dist/cli/commands/state-mcp.js +168 -0
- package/dist/cli/commands/state-mcp.js.map +1 -0
- package/dist/cli/commands/watch/agent-spawn.d.ts +62 -0
- package/dist/cli/commands/watch/agent-spawn.d.ts.map +1 -0
- package/dist/cli/commands/watch/agent-spawn.js +127 -0
- package/dist/cli/commands/watch/agent-spawn.js.map +1 -0
- package/dist/cli/commands/watch/capabilities/board.d.ts.map +1 -1
- package/dist/cli/commands/watch/capabilities/board.js +2 -1
- package/dist/cli/commands/watch/capabilities/board.js.map +1 -1
- package/dist/cli/commands/watch/capabilities/decision-hygiene.d.ts.map +1 -1
- package/dist/cli/commands/watch/capabilities/decision-hygiene.js +3 -2
- package/dist/cli/commands/watch/capabilities/decision-hygiene.js.map +1 -1
- package/dist/cli/commands/watch/capabilities/execute.d.ts.map +1 -1
- package/dist/cli/commands/watch/capabilities/execute.js +14 -2
- package/dist/cli/commands/watch/capabilities/execute.js.map +1 -1
- package/dist/cli/commands/watch/capabilities/index.d.ts.map +1 -1
- package/dist/cli/commands/watch/capabilities/index.js +2 -0
- package/dist/cli/commands/watch/capabilities/index.js.map +1 -1
- package/dist/cli/commands/watch/capabilities/monitor-email.d.ts +1 -1
- package/dist/cli/commands/watch/capabilities/monitor-email.d.ts.map +1 -1
- package/dist/cli/commands/watch/capabilities/monitor-email.js +21 -4
- package/dist/cli/commands/watch/capabilities/monitor-email.js.map +1 -1
- package/dist/cli/commands/watch/capabilities/monitor-teams.d.ts +1 -1
- package/dist/cli/commands/watch/capabilities/monitor-teams.d.ts.map +1 -1
- package/dist/cli/commands/watch/capabilities/monitor-teams.js +21 -5
- package/dist/cli/commands/watch/capabilities/monitor-teams.js.map +1 -1
- package/dist/cli/commands/watch/capabilities/notes-promote.d.ts +11 -0
- package/dist/cli/commands/watch/capabilities/notes-promote.d.ts.map +1 -0
- package/dist/cli/commands/watch/capabilities/notes-promote.js +124 -0
- package/dist/cli/commands/watch/capabilities/notes-promote.js.map +1 -0
- package/dist/cli/commands/watch/capabilities/retro.d.ts.map +1 -1
- package/dist/cli/commands/watch/capabilities/retro.js +3 -2
- package/dist/cli/commands/watch/capabilities/retro.js.map +1 -1
- package/dist/cli/commands/watch/capabilities/wave-dispatch.d.ts.map +1 -1
- package/dist/cli/commands/watch/capabilities/wave-dispatch.js +2 -1
- package/dist/cli/commands/watch/capabilities/wave-dispatch.js.map +1 -1
- package/dist/cli/commands/watch/index.d.ts.map +1 -1
- package/dist/cli/commands/watch/index.js +16 -12
- package/dist/cli/commands/watch/index.js.map +1 -1
- package/dist/cli/core/cast.d.ts.map +1 -1
- package/dist/cli/core/cast.js +132 -1
- package/dist/cli/core/cast.js.map +1 -1
- package/dist/cli/core/command-help.d.ts +44 -0
- package/dist/cli/core/command-help.d.ts.map +1 -0
- package/dist/cli/core/command-help.js +401 -0
- package/dist/cli/core/command-help.js.map +1 -0
- package/dist/cli/core/copilot-invocation.d.ts +57 -0
- package/dist/cli/core/copilot-invocation.d.ts.map +1 -0
- package/dist/cli/core/copilot-invocation.js +84 -0
- package/dist/cli/core/copilot-invocation.js.map +1 -0
- package/dist/cli/core/effective-squad-dir.d.ts +33 -0
- package/dist/cli/core/effective-squad-dir.d.ts.map +1 -0
- package/dist/cli/core/effective-squad-dir.js +37 -0
- package/dist/cli/core/effective-squad-dir.js.map +1 -0
- package/dist/cli/core/init.d.ts +2 -0
- package/dist/cli/core/init.d.ts.map +1 -1
- package/dist/cli/core/init.js +74 -1
- package/dist/cli/core/init.js.map +1 -1
- package/dist/cli/core/mcp-root.d.ts +60 -0
- package/dist/cli/core/mcp-root.d.ts.map +1 -0
- package/dist/cli/core/mcp-root.js +124 -0
- package/dist/cli/core/mcp-root.js.map +1 -0
- package/dist/cli/core/mcp-spec.d.ts +48 -0
- package/dist/cli/core/mcp-spec.d.ts.map +1 -0
- package/dist/cli/core/mcp-spec.js +61 -0
- package/dist/cli/core/mcp-spec.js.map +1 -0
- package/dist/cli/core/npm-registry.d.ts +25 -0
- package/dist/cli/core/npm-registry.d.ts.map +1 -0
- package/dist/cli/core/npm-registry.js +65 -0
- package/dist/cli/core/npm-registry.js.map +1 -0
- package/dist/cli/core/templates.d.ts.map +1 -1
- package/dist/cli/core/templates.js +52 -16
- package/dist/cli/core/templates.js.map +1 -1
- package/dist/cli/core/upgrade.d.ts +5 -0
- package/dist/cli/core/upgrade.d.ts.map +1 -1
- package/dist/cli/core/upgrade.js +231 -12
- package/dist/cli/core/upgrade.js.map +1 -1
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +1 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/shell/components/App.js +1 -1
- package/dist/cli/shell/components/App.js.map +1 -1
- package/dist/cli/shell/components/MessageStream.js +2 -2
- package/dist/cli/shell/components/MessageStream.js.map +1 -1
- package/dist/cli/shell/coordinator.d.ts.map +1 -1
- package/dist/cli/shell/coordinator.js +11 -5
- package/dist/cli/shell/coordinator.js.map +1 -1
- package/dist/cli/shell/index.d.ts.map +1 -1
- package/dist/cli/shell/index.js +14 -7
- package/dist/cli/shell/index.js.map +1 -1
- package/dist/cli/shell/lifecycle.d.ts.map +1 -1
- package/dist/cli/shell/lifecycle.js +12 -7
- package/dist/cli/shell/lifecycle.js.map +1 -1
- package/dist/cli/shell/session-store.d.ts +4 -4
- package/dist/cli/shell/session-store.d.ts.map +1 -1
- package/dist/cli/shell/session-store.js +11 -11
- package/dist/cli/shell/session-store.js.map +1 -1
- package/dist/cli-entry.js +162 -50
- package/dist/cli-entry.js.map +1 -1
- package/package.json +7 -3
- package/scripts/patch-esm-imports.mjs +3 -1
- package/templates/after-agent-reference.md +64 -0
- package/templates/ceremony-reference.md +82 -0
- package/templates/client-compatibility-reference.md +46 -0
- package/templates/copilot-agent.md +96 -0
- package/templates/copilot-instructions.md +14 -0
- package/templates/model-selection-reference.md +101 -0
- package/templates/prd-intake.md +105 -0
- package/templates/rai-charter.md +110 -0
- package/templates/rai-policy.md +103 -0
- package/templates/ralph-reference.md +141 -0
- package/templates/routing.md +1 -0
- package/templates/scribe-charter.md +18 -151
- package/templates/session-init-reference.md +199 -0
- package/templates/skills/e2e-template-testing/SKILL.md +557 -0
- package/templates/skills/fact-checking/SKILL.md +61 -0
- package/templates/skills/squad-commands/SKILL.md +303 -0
- package/templates/skills/squad-version-check/SKILL.md +160 -0
- package/templates/spawn-reference.md +131 -0
- package/templates/squad.agent.md.template +200 -625
- package/templates/workflow-wiring-appendix-a-code-reviewer.md +131 -0
- package/templates/workflow-wiring-appendix-b-documenter.md +140 -0
- package/templates/workflow-wiring-guide.md +276 -0
- package/templates/workflows/squad-heartbeat.yml +167 -167
- package/templates/worktree-reference.md +126 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Ralph Reference
|
|
2
|
+
|
|
3
|
+
## Ralph — Work Monitor
|
|
4
|
+
|
|
5
|
+
Ralph is a built-in squad member whose job is keeping tabs on work. **Ralph tracks and drives the work queue.** Always on the roster, one job: make sure the team never sits idle.
|
|
6
|
+
|
|
7
|
+
**⚡ CRITICAL BEHAVIOR: When Ralph is active, the coordinator MUST NOT stop and wait for user input between work items. Ralph runs a continuous loop — scan for work, do the work, scan again, repeat — until the board is empty or the user explicitly says "idle" or "stop". This is not optional. If work exists, keep going. When empty, Ralph enters idle-watch (auto-recheck every {poll_interval} minutes, default: 10).**
|
|
8
|
+
|
|
9
|
+
**Between checks:** Ralph's in-session loop runs while work exists. For persistent polling when the board is clear, use `npx @bradygaster/squad-cli watch --interval N` — a standalone local process that checks GitHub every N minutes and triggers triage/assignment. See [Watch Mode](#watch-mode-squad-watch).
|
|
10
|
+
|
|
11
|
+
**On-demand reference:** Read `.squad/templates/ralph-reference.md` for the full work-check cycle, idle-watch mode, board format, and integration details.
|
|
12
|
+
|
|
13
|
+
### Roster Entry
|
|
14
|
+
|
|
15
|
+
Ralph always appears in `team.md`: `| Ralph | Work Monitor | — | 🔄 Monitor |`
|
|
16
|
+
|
|
17
|
+
### Triggers
|
|
18
|
+
|
|
19
|
+
| User says | Action |
|
|
20
|
+
|-----------|--------|
|
|
21
|
+
| "Ralph, go" / "Ralph, start monitoring" / "keep working" | Activate work-check loop |
|
|
22
|
+
| "Ralph, status" / "What's on the board?" / "How's the backlog?" | Run one work-check cycle, report results, don't loop |
|
|
23
|
+
| "Ralph, check every N minutes" | Set idle-watch polling interval |
|
|
24
|
+
| "Ralph, idle" / "Take a break" / "Stop monitoring" | Fully deactivate (stop loop + idle-watch) |
|
|
25
|
+
| "Ralph, scope: just issues" / "Ralph, skip CI" | Adjust what Ralph monitors this session |
|
|
26
|
+
| References PR feedback or changes requested | Spawn agent to address PR review feedback |
|
|
27
|
+
| "merge PR #N" / "merge it" (recent context) | Merge via `gh pr merge` |
|
|
28
|
+
|
|
29
|
+
These are intent signals, not exact strings — match meaning, not words.
|
|
30
|
+
|
|
31
|
+
When Ralph is active, run this check cycle after every batch of agent work completes (or immediately on activation):
|
|
32
|
+
|
|
33
|
+
**Step 1 — Scan for work** (run these in parallel):
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Untriaged issues (labeled squad but no squad:{member} sub-label)
|
|
37
|
+
gh issue list --label "squad" --state open --json number,title,labels,assignees --limit 20
|
|
38
|
+
|
|
39
|
+
# Member-assigned issues (labeled squad:{member}, still open)
|
|
40
|
+
gh issue list --state open --json number,title,labels,assignees --limit 20 | # filter for squad:* labels
|
|
41
|
+
|
|
42
|
+
# Open PRs from squad members
|
|
43
|
+
gh pr list --state open --json number,title,author,labels,isDraft,reviewDecision --limit 20
|
|
44
|
+
|
|
45
|
+
# Draft PRs (agent work in progress)
|
|
46
|
+
gh pr list --state open --draft --json number,title,author,labels,checks --limit 20
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Step 2 — Categorize findings:**
|
|
50
|
+
|
|
51
|
+
| Category | Signal | Action |
|
|
52
|
+
|----------|--------|--------|
|
|
53
|
+
| **Untriaged issues** | `squad` label, no `squad:{member}` label | Lead triages: reads issue, assigns `squad:{member}` label |
|
|
54
|
+
| **Assigned but unstarted** | `squad:{member}` label, no assignee or no PR | Spawn the assigned agent to pick it up |
|
|
55
|
+
| **Draft PRs** | PR in draft from squad member | Check if agent needs to continue; if stalled, nudge |
|
|
56
|
+
| **Review feedback** | PR has `CHANGES_REQUESTED` review | Route feedback to PR author agent to address |
|
|
57
|
+
| **CI failures** | PR checks failing | Notify assigned agent to fix, or create a fix issue |
|
|
58
|
+
| **Approved PRs** | PR approved, CI green, ready to merge | Merge and close related issue |
|
|
59
|
+
| **No work found** | All clear | Report: "📋 Board is clear. Ralph is idling." Suggest `npx @bradygaster/squad-cli watch` for persistent polling. |
|
|
60
|
+
|
|
61
|
+
**Step 3 — Act on highest-priority item:**
|
|
62
|
+
- Process one category at a time, highest priority first (untriaged > assigned > CI failures > review feedback > approved PRs)
|
|
63
|
+
- Spawn agents as needed, collect results
|
|
64
|
+
- **⚡ CRITICAL: After results are collected, DO NOT stop. DO NOT wait for user input. IMMEDIATELY go back to Step 1 and scan again.** This is a loop — Ralph keeps cycling until the board is clear or the user says "idle". Each cycle is one "round".
|
|
65
|
+
- If multiple items exist in the same category, process them in parallel (spawn multiple agents)
|
|
66
|
+
|
|
67
|
+
**Step 4 — Periodic check-in** (every 3-5 rounds):
|
|
68
|
+
|
|
69
|
+
After every 3-5 rounds, pause and report before continuing:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
🔄 Ralph: Round {N} complete.
|
|
73
|
+
✅ {X} issues closed, {Y} PRs merged
|
|
74
|
+
📋 {Z} items remaining: {brief list}
|
|
75
|
+
Continuing... (say "Ralph, idle" to stop)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Do NOT ask for permission to continue.** Just report and keep going. The user must explicitly say "idle" or "stop" to break the loop. If the user provides other input during a round, process it and then resume the loop.
|
|
79
|
+
|
|
80
|
+
### Watch Mode (`squad watch`)
|
|
81
|
+
|
|
82
|
+
Ralph's in-session loop processes work while it exists, then idles. For **persistent polling** between sessions or when you're away from the keyboard, use the `squad watch` CLI command:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npx @bradygaster/squad-cli watch # polls every 10 minutes (default)
|
|
86
|
+
npx @bradygaster/squad-cli watch --interval 5 # polls every 5 minutes
|
|
87
|
+
npx @bradygaster/squad-cli watch --interval 30 # polls every 30 minutes
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
This runs as a standalone local process (not inside Copilot) that:
|
|
91
|
+
- Checks GitHub every N minutes for untriaged squad work
|
|
92
|
+
- Auto-triages issues based on team roles and keywords
|
|
93
|
+
- Assigns @copilot to `squad:copilot` issues (if auto-assign is enabled)
|
|
94
|
+
- Runs until Ctrl+C
|
|
95
|
+
|
|
96
|
+
**Three layers of Ralph:**
|
|
97
|
+
|
|
98
|
+
| Layer | When | How |
|
|
99
|
+
|-------|------|-----|
|
|
100
|
+
| **In-session** | You're at the keyboard | "Ralph, go" — active loop while work exists |
|
|
101
|
+
| **Local watchdog** | You're away but machine is on | `npx @bradygaster/squad-cli watch --interval 10` |
|
|
102
|
+
| **Cloud heartbeat** | Fully unattended | `squad-heartbeat.yml` — event-based only (cron disabled) |
|
|
103
|
+
|
|
104
|
+
### Ralph State
|
|
105
|
+
|
|
106
|
+
Ralph's state is session-scoped (not persisted to disk):
|
|
107
|
+
- **Active/idle** — whether the loop is running
|
|
108
|
+
- **Round count** — how many check cycles completed
|
|
109
|
+
- **Scope** — what categories to monitor (default: all)
|
|
110
|
+
- **Stats** — issues closed, PRs merged, items processed this session
|
|
111
|
+
|
|
112
|
+
### Ralph on the Board
|
|
113
|
+
|
|
114
|
+
When Ralph reports status, use this format:
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
🔄 Ralph — Work Monitor
|
|
118
|
+
━━━━━━━━━━━━━━━━━━━━━━
|
|
119
|
+
📊 Board Status:
|
|
120
|
+
🔴 Untriaged: 2 issues need triage
|
|
121
|
+
🟡 In Progress: 3 issues assigned, 1 draft PR
|
|
122
|
+
🟢 Ready: 1 PR approved, awaiting merge
|
|
123
|
+
✅ Done: 5 issues closed this session
|
|
124
|
+
|
|
125
|
+
Next action: Triaging #42 — "Fix auth endpoint timeout"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Integration with Follow-Up Work
|
|
129
|
+
|
|
130
|
+
After the coordinator's step 6 ("Immediately assess: Does anything trigger follow-up work?"), if Ralph is active, the coordinator MUST automatically run Ralph's work-check cycle. **Do NOT return control to the user.** This creates a continuous pipeline:
|
|
131
|
+
|
|
132
|
+
1. User activates Ralph → work-check cycle runs
|
|
133
|
+
2. Work found → agents spawned → results collected
|
|
134
|
+
3. Follow-up work assessed → more agents if needed
|
|
135
|
+
4. Ralph scans GitHub again (Step 1) → IMMEDIATELY, no pause
|
|
136
|
+
5. More work found → repeat from step 2
|
|
137
|
+
6. No more work → "📋 Board is clear. Ralph is idling." (suggest `npx @bradygaster/squad-cli watch` for persistent polling)
|
|
138
|
+
|
|
139
|
+
**Ralph does NOT ask "should I continue?" — Ralph KEEPS GOING.** Only stops on explicit "idle"/"stop" or session end. A clear board → idle-watch, not full stop. For persistent monitoring after the board clears, use `npx @bradygaster/squad-cli watch`.
|
|
140
|
+
|
|
141
|
+
These are intent signals, not exact strings — match the user's meaning, not their exact words.
|
package/templates/routing.md
CHANGED
|
@@ -13,6 +13,7 @@ How to decide who handles what.
|
|
|
13
13
|
| Testing | {Name} | Write tests, find edge cases, verify fixes |
|
|
14
14
|
| Scope & priorities | {Name} | What to build next, trade-offs, decisions |
|
|
15
15
|
| Session logging | Scribe | Automatic — never needs routing |
|
|
16
|
+
| RAI review | Rai | Content safety, bias checks, credential detection, ethical review |
|
|
16
17
|
|
|
17
18
|
## Issue Routing
|
|
18
19
|
|
|
@@ -24,62 +24,11 @@
|
|
|
24
24
|
|
|
25
25
|
**Worktree awareness:** Use the `TEAM ROOT` provided in the spawn prompt to resolve all `.squad/` paths. If no TEAM ROOT is given, run `git rev-parse --show-toplevel` as fallback. Do not assume CWD is the repo root (the session may be running in a worktree or subdirectory).
|
|
26
26
|
|
|
27
|
-
**State backend awareness:** Check `STATE_BACKEND` from the spawn prompt.
|
|
28
|
-
|
|
29
|
-
### State Leak Guard (orphan/git-notes backends only)
|
|
30
|
-
|
|
31
|
-
Before logging or merging, check if any agent accidentally committed state files to the working branch:
|
|
32
|
-
|
|
33
|
-
```powershell
|
|
34
|
-
# Check if state files are staged or committed but shouldn't be
|
|
35
|
-
$stateFiles = @(
|
|
36
|
-
'.squad/decisions.md',
|
|
37
|
-
'.squad/decisions-archive.md'
|
|
38
|
-
)
|
|
39
|
-
$statePatterns = @(
|
|
40
|
-
'.squad/agents/*/history.md',
|
|
41
|
-
'.squad/agents/*/history-archive.md',
|
|
42
|
-
'.squad/log/*',
|
|
43
|
-
'.squad/orchestration-log/*',
|
|
44
|
-
'.squad/decisions/inbox/*'
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
# 1. Check git status for accidentally staged state files
|
|
48
|
-
$dirty = git status --porcelain | Where-Object { $_.Length -gt 3 } | ForEach-Object {
|
|
49
|
-
$_.Substring(3) -replace '^.* -> ',''
|
|
50
|
-
} | Where-Object {
|
|
51
|
-
$f = $_
|
|
52
|
-
($f -in $stateFiles) -or ($statePatterns | Where-Object { $f -like $_ })
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if ($dirty) {
|
|
56
|
-
# Unstage any accidentally added state files
|
|
57
|
-
$dirty | ForEach-Object { git reset HEAD -- $_ 2>$null }
|
|
58
|
-
# Restore from HEAD (discard working tree changes for state files)
|
|
59
|
-
$dirty | ForEach-Object { git checkout HEAD -- $_ 2>$null }
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
# 2. Check if the most recent commit on this branch has state files
|
|
63
|
-
$lastCommitFiles = git diff-tree --no-commit-id --name-only -r HEAD 2>$null
|
|
64
|
-
$leakedInCommit = $lastCommitFiles | Where-Object {
|
|
65
|
-
$f = $_
|
|
66
|
-
($f -in $stateFiles) -or ($statePatterns | Where-Object { $f -like $_ })
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if ($leakedInCommit) {
|
|
70
|
-
# State files leaked into the last commit — amend to remove them
|
|
71
|
-
$leakedInCommit | ForEach-Object { git rm --cached -- $_ 2>$null }
|
|
72
|
-
git commit --amend --no-edit 2>$null
|
|
73
|
-
}
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
If any files were cleaned, log: `⚠️ State leak guard: removed {N} state file(s) from working branch.`
|
|
77
|
-
|
|
78
|
-
After the guard, proceed with normal Scribe work (but persist state via the configured backend, not the working branch).
|
|
27
|
+
**State backend awareness:** Check `STATE_BACKEND` from the spawn prompt. Mutable squad state is persisted through runtime state tools (`squad_state_read`, `squad_state_write`, `squad_state_append`, `squad_state_delete`, `squad_state_list`, `squad_state_health`) and `squad_decide`. Do not run backend git commands, switch to state branches, push note refs, reset `.squad/`, or commit mutable state by hand. If state tools are unavailable, stop without mutating files or git state and record the tool availability failure in your final summary.
|
|
79
28
|
|
|
80
29
|
After every substantial work session:
|
|
81
30
|
|
|
82
|
-
1. **Log the session** to
|
|
31
|
+
1. **Log the session** to `log/{timestamp}-{topic}.md` with `squad_state_write` (replace `:` with `-` in `{timestamp}` so the filename is valid on all platforms, e.g. `2026-06-02T21-15-30Z`):
|
|
83
32
|
- Who worked
|
|
84
33
|
- What was done
|
|
85
34
|
- Decisions made
|
|
@@ -87,119 +36,37 @@ After every substantial work session:
|
|
|
87
36
|
- Brief. Facts only.
|
|
88
37
|
|
|
89
38
|
2. **Merge the decision inbox:**
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
39
|
+
- List all files in `decisions/inbox/` with `squad_state_list`
|
|
40
|
+
- Read each entry with `squad_state_read`
|
|
41
|
+
- Append each decision's contents to `decisions.md` with `squad_state_write` after dedupe
|
|
42
|
+
- Delete each inbox file after merging with `squad_state_delete`
|
|
93
43
|
|
|
94
44
|
3. **Deduplicate and consolidate decisions.md:**
|
|
95
45
|
- Parse the file into decision blocks (each block starts with `### `).
|
|
96
46
|
- **Exact duplicates:** If two blocks share the same heading, keep the first and remove the rest.
|
|
97
47
|
- **Overlapping decisions:** Compare block content across all remaining blocks. If two or more blocks cover the same area (same topic, same architectural concern, same component) but were written independently (different dates, different authors), consolidate them:
|
|
98
48
|
a. Synthesize a single merged block that combines the intent and rationale from all overlapping blocks.
|
|
99
|
-
b. Use the CURRENT_DATETIME value from your spawn prompt and a new heading: `###
|
|
49
|
+
b. Use the literal CURRENT_DATETIME value from your spawn prompt and a new heading: `### <CURRENT_DATETIME value>: {consolidated topic} (consolidated)`. Substitute the actual timestamp; do not write placeholder text.
|
|
100
50
|
c. Credit all original authors: `**By:** {Name1}, {Name2}`
|
|
101
51
|
d. Under **What:**, combine the decisions. Note any differences or evolution.
|
|
102
52
|
e. Under **Why:**, merge the rationale, preserving unique reasoning from each.
|
|
103
53
|
f. Remove the original overlapping blocks.
|
|
104
|
-
- Write the updated file back
|
|
54
|
+
- Write the updated file back with `squad_state_write`. This handles duplicates and convergent decisions introduced by concurrent agent writes.
|
|
105
55
|
|
|
106
56
|
4. **Propagate cross-agent updates:**
|
|
107
|
-
For any newly merged decision that affects other agents, append to their `history.md
|
|
57
|
+
For any newly merged decision that affects other agents, append to their `agents/{agent}/history.md` with `squad_state_append`. Replace the parenthetical timestamp with the literal CURRENT_DATETIME value from your spawn prompt; do not write placeholder text.
|
|
108
58
|
```
|
|
109
|
-
📌 Team update (
|
|
59
|
+
📌 Team update (<CURRENT_DATETIME value>): {summary} — decided by {Name}
|
|
110
60
|
```
|
|
111
61
|
|
|
112
|
-
5. **Commit
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
- Identify changed `.squad/` state files via `git status --porcelain` filtered to allowed paths.
|
|
121
|
-
- For each file, use git plumbing to write to the orphan branch:
|
|
122
|
-
```powershell
|
|
123
|
-
# Create a temporary worktree for the orphan branch
|
|
124
|
-
$orphanWt = Join-Path ([System.IO.Path]::GetTempPath()) "squad-state-$(Get-Random)"
|
|
125
|
-
git worktree add $orphanWt squad-state 2>$null
|
|
126
|
-
if ($LASTEXITCODE -ne 0) { git worktree add --orphan $orphanWt squad-state }
|
|
127
|
-
# Copy state files to orphan worktree
|
|
128
|
-
$filesToSync | ForEach-Object {
|
|
129
|
-
$dest = Join-Path $orphanWt $_
|
|
130
|
-
New-Item -ItemType Directory -Path (Split-Path $dest) -Force | Out-Null
|
|
131
|
-
Copy-Item $_ $dest -Force
|
|
132
|
-
}
|
|
133
|
-
# Commit in orphan worktree
|
|
134
|
-
Push-Location $orphanWt
|
|
135
|
-
git add .squad/
|
|
136
|
-
git diff --cached --quiet
|
|
137
|
-
if ($LASTEXITCODE -ne 0) {
|
|
138
|
-
$msgFile = [System.IO.Path]::GetTempFileName()
|
|
139
|
-
Set-Content -Path $msgFile -Value "docs(ai-team): $summary" -Encoding utf8
|
|
140
|
-
git commit -F $msgFile
|
|
141
|
-
Remove-Item $msgFile
|
|
142
|
-
git push origin squad-state
|
|
143
|
-
}
|
|
144
|
-
Pop-Location
|
|
145
|
-
git worktree remove $orphanWt --force
|
|
146
|
-
```
|
|
147
|
-
- After committing to orphan, reset working tree state files: `git checkout HEAD -- .squad/`
|
|
148
|
-
- ⚠️ NEVER commit `.squad/` state files to the working branch when using orphan backend.
|
|
149
|
-
|
|
150
|
-
**If STATE_BACKEND is "git-notes":**
|
|
151
|
-
State is already persisted in git notes refs by agents. Scribe only needs to:
|
|
152
|
-
- Push any locally created note refs: `git push origin 'refs/notes/squad/*'`
|
|
153
|
-
- Commit decisions.md (the merged canonical file) to the working branch as normal.
|
|
154
|
-
|
|
155
|
-
**If STATE_BACKEND is "worktree" (default):**
|
|
156
|
-
Commit to the working branch as normal:
|
|
157
|
-
- `cd` into the team root first.
|
|
158
|
-
- Stage only files Scribe actually modified in this session.
|
|
159
|
-
Use `git status --porcelain` to build an explicit file list filtered to allowed `.squad/` paths:
|
|
160
|
-
```powershell
|
|
161
|
-
$allowed = @(
|
|
162
|
-
'.squad/decisions.md',
|
|
163
|
-
'.squad/decisions-archive.md'
|
|
164
|
-
)
|
|
165
|
-
$allowedPatterns = @(
|
|
166
|
-
'.squad/agents/*/history.md',
|
|
167
|
-
'.squad/agents/*/history-archive.md',
|
|
168
|
-
'.squad/log/*',
|
|
169
|
-
'.squad/orchestration-log/*'
|
|
170
|
-
)
|
|
171
|
-
$filesToStage = git status --porcelain | Where-Object { $_.Length -gt 3 } | ForEach-Object { $_.Substring(3) -replace '^.* -> ','' } | Where-Object {
|
|
172
|
-
$f = $_
|
|
173
|
-
($f -in $allowed) -or ($allowedPatterns | Where-Object { $f -like $_ })
|
|
174
|
-
}
|
|
175
|
-
if ($filesToStage) { $filesToStage | Where-Object { $_ } | ForEach-Object { git add -- $_ } }
|
|
176
|
-
```
|
|
177
|
-
⚠️ NEVER use `git add .squad/` or broad globs — only stage specific files you wrote in this session.
|
|
178
|
-
- Check for staged changes: `git diff --cached --quiet`
|
|
179
|
-
If exit code is 0, no changes — skip silently.
|
|
180
|
-
- Write the commit message to a temp file, then commit with `-F`:
|
|
181
|
-
```
|
|
182
|
-
$msg = @"
|
|
183
|
-
docs(ai-team): {brief summary}
|
|
184
|
-
|
|
185
|
-
Session: {timestamp}-{topic}
|
|
186
|
-
Requested by: {user name}
|
|
187
|
-
|
|
188
|
-
Changes:
|
|
189
|
-
- {what was logged}
|
|
190
|
-
- {what decisions were merged}
|
|
191
|
-
- {what decisions were deduplicated}
|
|
192
|
-
- {what cross-agent updates were propagated}
|
|
193
|
-
"@
|
|
194
|
-
$msgFile = [System.IO.Path]::GetTempFileName()
|
|
195
|
-
Set-Content -Path $msgFile -Value $msg -Encoding utf8
|
|
196
|
-
git commit -F $msgFile
|
|
197
|
-
Remove-Item $msgFile
|
|
198
|
-
```
|
|
199
|
-
- **Verify the commit landed:** Run `git log --oneline -1` and confirm the
|
|
200
|
-
output matches the expected message. If it doesn't, report the error.
|
|
201
|
-
|
|
202
|
-
6. **Never speak to the user.** Never appear in responses. Work silently.
|
|
62
|
+
5. **Commit and verify persistence through the runtime backend:**
|
|
63
|
+
- Run `squad_state_health` when available.
|
|
64
|
+
- Re-read `decisions.md`, `log/{timestamp}-{topic}.md`, and any updated histories with `squad_state_read`.
|
|
65
|
+
- Never amend, reset, checkout, push notes, or switch branches to persist mutable squad state. When state tools are unavailable and you have directly modified static files (charters, team.md, skills), commit those changes with `git commit`.
|
|
66
|
+
|
|
67
|
+
6. **Commit handling:** Never commit mutable squad state. If non-state repo files changed, report them for coordinator handling.
|
|
68
|
+
|
|
69
|
+
7. **Never speak to the user.** Never appear in responses. Work silently.
|
|
203
70
|
|
|
204
71
|
## The Memory Architecture
|
|
205
72
|
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# Session Init Reference
|
|
2
|
+
|
|
3
|
+
Procedures the coordinator runs at session start, in order. Each step is
|
|
4
|
+
self-contained, fails silent, and degrades to "show normal greeting."
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Step 1: Update Check
|
|
9
|
+
|
|
10
|
+
Check whether a newer Squad version exists for the user's channel. Append to
|
|
11
|
+
the greeting if a newer version is found. Never block the session; every
|
|
12
|
+
failure path ends at "show normal greeting."
|
|
13
|
+
|
|
14
|
+
### 1.1 Kill Switch
|
|
15
|
+
|
|
16
|
+
If the environment variable `SQUAD_NO_UPDATE_CHECK` is set to `1`, **skip
|
|
17
|
+
Step 1 entirely** and show the normal greeting. This is the same kill switch
|
|
18
|
+
as the upstream CLI banner — one opt-out disables both.
|
|
19
|
+
|
|
20
|
+
### 1.2 Channel Detection
|
|
21
|
+
|
|
22
|
+
Read the stamped version from the `<!-- version: X -->` HTML comment at the
|
|
23
|
+
top of `squad.agent.md` (or from the `- **Version:** X` identity line as
|
|
24
|
+
fallback). Classify the channel:
|
|
25
|
+
|
|
26
|
+
| Stamped version contains | Channel |
|
|
27
|
+
|--------------------------|-----------|
|
|
28
|
+
| `-insider` | `insider` |
|
|
29
|
+
| `-preview` | `preview` |
|
|
30
|
+
| (neither) | `latest` |
|
|
31
|
+
|
|
32
|
+
Store the stamped version as `currentVersion` and the detected channel.
|
|
33
|
+
|
|
34
|
+
### 1.3 Hybrid Cache Strategy
|
|
35
|
+
|
|
36
|
+
The strategy differs by channel to avoid redundant network calls for the
|
|
37
|
+
common (`latest`) case.
|
|
38
|
+
|
|
39
|
+
#### For `latest` channel — read upstream OS-specific cache
|
|
40
|
+
|
|
41
|
+
The upstream Squad CLI (`self-update.ts`) already fetches the latest version
|
|
42
|
+
on startup and writes it to an OS-specific path with a 24h TTL. Read that
|
|
43
|
+
cache instead of making a new npm call.
|
|
44
|
+
|
|
45
|
+
**One-liner to read the upstream cache:**
|
|
46
|
+
```
|
|
47
|
+
node -e "const p=require('path'),o=require('os');const b=process.env.APPDATA||(process.platform==='darwin'?p.join(o.homedir(),'Library','Application Support'):p.join(o.homedir(),'.config'));const f=p.join(b,'squad-cli','update-check.json');try{const d=JSON.parse(require('fs').readFileSync(f,'utf8'));const age=Date.now()-d.checkedAt;if(age<86400000)console.log(JSON.stringify(d));else console.log('STALE')}catch{console.log('MISS')}"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Output semantics:
|
|
51
|
+
- Valid JSON `{"latestVersion":"X.Y.Z","checkedAt":N}` → cache hit; use `latestVersion`
|
|
52
|
+
- `STALE` → cache expired (older than 24h); treat as no data
|
|
53
|
+
- `MISS` → cache missing or corrupt; treat as no data
|
|
54
|
+
|
|
55
|
+
On `STALE` or `MISS`, show the normal greeting (no notice). Do **not** make an
|
|
56
|
+
independent npm call for `latest`-channel users — the upstream CLI will refresh
|
|
57
|
+
the cache on its next run.
|
|
58
|
+
|
|
59
|
+
**OS-specific cache path for reference:**
|
|
60
|
+
- Windows: `%APPDATA%\squad-cli\update-check.json`
|
|
61
|
+
- Linux: `~/.config/squad-cli/update-check.json`
|
|
62
|
+
- macOS: `~/Library/Application Support/squad-cli/update-check.json`
|
|
63
|
+
|
|
64
|
+
#### For `insider` / `preview` channels — own probe with repo-local cache
|
|
65
|
+
|
|
66
|
+
The upstream cache only stores the `latest` dist-tag and is not useful for
|
|
67
|
+
pre-release channels. Use a separate probe.
|
|
68
|
+
|
|
69
|
+
**Step A — Check repo-local cache:**
|
|
70
|
+
|
|
71
|
+
Read `.squad/.cache/version-check.json`. If the file exists, is not older than
|
|
72
|
+
24h, and `currentVersion` matches `stamped version`, use `channelVersion` from
|
|
73
|
+
it. Skip the npm probe.
|
|
74
|
+
|
|
75
|
+
**Repo-local cache schema:**
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"checkedAt": "2026-05-26T14:13:28.492Z",
|
|
79
|
+
"currentVersion": "0.9.6-insider.2",
|
|
80
|
+
"channel": "insider",
|
|
81
|
+
"channelVersion": "0.9.7-insider.1"
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Step B — npm probe (on cache miss / stale / version mismatch):**
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
npm view @bradygaster/squad-cli dist-tags --json
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
- Timeout: **5 seconds.** If the command does not respond within 5 seconds,
|
|
92
|
+
abandon and show normal greeting.
|
|
93
|
+
- On success: extract `dist-tags[channel]` (e.g., `dist-tags["insider"]`).
|
|
94
|
+
Write `.squad/.cache/version-check.json` with the schema above.
|
|
95
|
+
Create `.squad/.cache/` if it does not exist.
|
|
96
|
+
- On any error (network failure, registry unreachable, parse error): show
|
|
97
|
+
normal greeting.
|
|
98
|
+
|
|
99
|
+
### 1.4 Comparison
|
|
100
|
+
|
|
101
|
+
Compare `currentVersion` against the resolved `latestVersionForChannel` using
|
|
102
|
+
semver ordering (pre-release suffixes sort lower than their release counterpart,
|
|
103
|
+
e.g., `0.9.5-insider.1 < 0.9.5`).
|
|
104
|
+
|
|
105
|
+
- `latestVersionForChannel > currentVersion` → update available
|
|
106
|
+
- Equal or older → no notice
|
|
107
|
+
|
|
108
|
+
### 1.5 Greeting Append
|
|
109
|
+
|
|
110
|
+
When an update is available, append to the normal greeting (on the same line,
|
|
111
|
+
separated by ` · `):
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
· 🆕 v{latestVersionForChannel} available — say "upgrade squad"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Example complete greeting line:
|
|
118
|
+
```
|
|
119
|
+
Squad v0.9.4-insider.1 · 🆕 v0.9.7-insider.1 available — say "upgrade squad"
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Do not mention the update check, the cache, or the mechanism. Just the notice.
|
|
123
|
+
|
|
124
|
+
### 1.6 Upgrade Flow
|
|
125
|
+
|
|
126
|
+
**Trigger phrases** (case-insensitive, match anywhere in user message):
|
|
127
|
+
- "upgrade squad"
|
|
128
|
+
- "update squad"
|
|
129
|
+
- "what's new" *(when a version notice has been shown in this session)*
|
|
130
|
+
- "install the update"
|
|
131
|
+
- "yes upgrade"
|
|
132
|
+
|
|
133
|
+
**Flow:**
|
|
134
|
+
|
|
135
|
+
1. **Confirm** — ask the user to confirm before running the upgrade:
|
|
136
|
+
> "I'll run `squad upgrade` now. This overwrites `squad.agent.md` and
|
|
137
|
+
> casting files but preserves `config.json`, `team.md`, `decisions.md`,
|
|
138
|
+
> and all agent history. Ready?"
|
|
139
|
+
Wait for affirmative response before proceeding.
|
|
140
|
+
|
|
141
|
+
2. **Run upgrade:**
|
|
142
|
+
```
|
|
143
|
+
squad upgrade
|
|
144
|
+
```
|
|
145
|
+
Capture output. On failure (non-zero exit, error output), report the error
|
|
146
|
+
to the user and stop.
|
|
147
|
+
|
|
148
|
+
3. **What's-new digest** — after successful upgrade, fetch and summarize
|
|
149
|
+
release notes:
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
gh api repos/bradygaster/squad/releases --jq '[.[] | select(.tag_name | test("^v"))]'
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
- Extract 3–6 bullet points from releases between `oldVersion` and
|
|
156
|
+
`newVersion`, inclusive.
|
|
157
|
+
- Priority: `feat` entries first, then `fix`, then `docs`.
|
|
158
|
+
- Format:
|
|
159
|
+
```
|
|
160
|
+
📋 What's new in v{newVersion}:
|
|
161
|
+
• {feat summary 1}
|
|
162
|
+
• {feat summary 2}
|
|
163
|
+
• {fix summary}
|
|
164
|
+
```
|
|
165
|
+
- **Fallback chain:**
|
|
166
|
+
- `gh` not authenticated → "See full release notes at:
|
|
167
|
+
https://github.com/bradygaster/squad/releases"
|
|
168
|
+
- No releases found → "No release notes found for this version range."
|
|
169
|
+
- Network failure → link to releases page
|
|
170
|
+
|
|
171
|
+
4. **Restart prompt** — after showing the digest, prompt the user:
|
|
172
|
+
> "`squad.agent.md` has been updated. For the new coordinator instructions
|
|
173
|
+
> to take effect, please start a new session (close and re-open this chat).
|
|
174
|
+
> Your team state and decisions are unchanged."
|
|
175
|
+
|
|
176
|
+
### 1.7 Failure Modes
|
|
177
|
+
|
|
178
|
+
Every failure path ends at "show normal greeting." The update check never
|
|
179
|
+
interrupts or delays the session.
|
|
180
|
+
|
|
181
|
+
| Failure | Behavior |
|
|
182
|
+
|---------|----------|
|
|
183
|
+
| `node` not on PATH | `MISS` → normal greeting |
|
|
184
|
+
| Upstream cache missing / corrupt | `MISS` → normal greeting |
|
|
185
|
+
| Upstream cache stale (`latest` channel) | Normal greeting (no npm call) |
|
|
186
|
+
| npm probe timeout (5s) | Normal greeting |
|
|
187
|
+
| npm probe network error | Normal greeting |
|
|
188
|
+
| npm probe parse error | Normal greeting |
|
|
189
|
+
| `.squad/.cache/` write error | Normal greeting (skip cache write) |
|
|
190
|
+
| `gh` not available / unauthenticated | Upgrade flow: link to releases page |
|
|
191
|
+
| `squad upgrade` exits non-zero | Report error, stop flow |
|
|
192
|
+
| Any unexpected exception | Log to `.squad/orchestration-log/`, normal greeting |
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## (Future steps reserved)
|
|
197
|
+
|
|
198
|
+
- Step 2: \<reserved\> — e.g., dependency drift check
|
|
199
|
+
- Step 3: \<reserved\> — e.g., repo policy / state-backend audit
|