squadrant 0.9.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.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +268 -0
  3. package/dist/index.js +9154 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/squadrantd.js +3928 -0
  6. package/dist/squadrantd.js.map +1 -0
  7. package/package.json +68 -0
  8. package/plugin/.claude-plugin/plugin.json +5 -0
  9. package/plugin/skills/add-pick-crew-rule/SKILL.md +88 -0
  10. package/plugin/skills/captain-ops/SKILL.md +390 -0
  11. package/plugin/skills/command-ops/SKILL.md +157 -0
  12. package/plugin/skills/config-doctor/SKILL.md +46 -0
  13. package/plugin/skills/daily-log/SKILL.md +44 -0
  14. package/plugin/skills/karpathy-principles/SKILL.md +82 -0
  15. package/plugin/skills/set-effort/SKILL.md +59 -0
  16. package/plugin/skills/side-session/SKILL.md +113 -0
  17. package/plugin/skills/squadrant-effort/SKILL.md +8 -0
  18. package/plugin/skills/squadrant-new-project/SKILL.md +67 -0
  19. package/plugin/skills/squadrant-register-project/SKILL.md +60 -0
  20. package/plugin/skills/where-i-am/SKILL.md +102 -0
  21. package/plugin/skills/wiki-ops/SKILL.md +96 -0
  22. package/plugin/skills/wim/SKILL.md +8 -0
  23. package/scripts/acceptance-interactive-codex.sh +56 -0
  24. package/scripts/capture-skill.sh +32 -0
  25. package/scripts/claude-iv-smoke.mjs +133 -0
  26. package/scripts/fix-skill.sh +39 -0
  27. package/scripts/gen-codex-types.sh +18 -0
  28. package/scripts/mailbox-injector-smoke.mjs +124 -0
  29. package/scripts/mark-learning-useful.sh +22 -0
  30. package/scripts/migrate-to-squadrant.sh +158 -0
  31. package/scripts/notify-relay-placement-smoke.mjs +59 -0
  32. package/scripts/read-handoff.sh +22 -0
  33. package/scripts/record-learning.sh +31 -0
  34. package/scripts/record-side-handoff.sh +32 -0
  35. package/scripts/smoke-push-notify.mjs +147 -0
  36. package/scripts/spawn-crew-pane.sh +17 -0
  37. package/scripts/spawn-workspace.sh +206 -0
  38. package/scripts/wiki-ingest.sh +121 -0
  39. package/scripts/wiki-log.sh +20 -0
  40. package/scripts/wiki-query.sh +36 -0
  41. package/scripts/write-handoff.sh +31 -0
  42. package/templates/captain.claude.md +44 -0
  43. package/templates/captain.generic.md +45 -0
  44. package/templates/command.claude.md +32 -0
  45. package/templates/crew.claude.md +64 -0
  46. package/templates/crew.generic.md +51 -0
  47. package/templates/crew.opencode.md +51 -0
  48. package/templates/learnings.claude.md +40 -0
  49. package/templates/side.debug.claude.md +78 -0
  50. package/templates/side.research.claude.md +63 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,268 @@
1
+ # Squadrant
2
+
3
+ Multi-project orchestration layer for coding agents. One command session controls everything.
4
+
5
+ > **Direction:** Squadrant is moving to support all major coding agents — Claude Code, Codex, Cursor, Gemini CLI — not just Claude Code. Claude Code is the reference implementation today; other agents land through the plugin system's driver abstractions and the upcoming cross-agent projection layer ([#31](https://github.com/tu11aa/squadrant/issues/31)). See [`docs/specs/2026-04-24-multi-agent-direction.md`](docs/specs/2026-04-24-multi-agent-direction.md).
6
+
7
+ ## How It Works
8
+
9
+ ```
10
+ squadrant launch <project> → Captain (per project, in cmux)
11
+ squadrant launch --all → Every Captain
12
+ squadrant command --task briefing → One-shot Command session in a split pane
13
+ (also: --task learnings-review | wiki-aggregate)
14
+ Captain → squadrant crew spawn … → Crew (new tab in the captain workspace, fresh agent CLI)
15
+ ```
16
+
17
+ 1. **`squadrant init`** — first-time setup
18
+ 2. **`squadrant launch <project>`** — start the project's captain in cmux
19
+ 3. **`squadrant launch --all`** — start every captain at once
20
+ 4. **`squadrant command --task briefing`** — on-demand Command session for cross-project work (optional; spawns in a split pane and exits when done)
21
+ 5. **`squadrant status`** — quick status check without spawning anything
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ npm i -g squadrant # global `squadrant` CLI (alias: `squad`)
27
+ squadrant init
28
+ squadrant doctor
29
+ ```
30
+
31
+ Or from source:
32
+
33
+ ```bash
34
+ git clone https://github.com/tu11aa/squadrant.git
35
+ cd squadrant
36
+ pnpm install
37
+ pnpm build # produces dist/index.js (the squadrant bin)
38
+ npm link # symlinks the global `squadrant`/`squad` to dist/index.js
39
+ squadrant init
40
+ squadrant doctor
41
+ ```
42
+
43
+ > Squadrant was formerly published/developed as `claude-cockpit`; it was rebranded in 0.9.0 as it grew into a multi-agent orchestration layer.
44
+
45
+ ## Prerequisites
46
+
47
+ - [Claude Code](https://claude.ai/code) >= 2.1.32
48
+ - [cmux](https://cmux.dev) (macOS terminal for coding agents)
49
+ - [Obsidian](https://obsidian.md) (status tracking)
50
+ - Node.js >= 18
51
+
52
+ ### Required Integrations
53
+
54
+ ```bash
55
+ # Claude Memory — cross-session continuity
56
+ /plugin marketplace add thedotmack/claude-mem
57
+ /plugin install claude-mem
58
+
59
+ # Task Master — PRD decomposition (works via Max subscription)
60
+ npm install -g task-master-ai
61
+
62
+ # GSD — wave-based execution for crew (fresh context per step)
63
+ npx get-shit-done-cc@latest --claude --global
64
+ ```
65
+
66
+ See `core/plugins.md` for full plugin setup.
67
+
68
+ ### Obsidian Plugins
69
+
70
+ See `obsidian/plugins.md` for Dataview, Templater setup.
71
+
72
+ ## Commands
73
+
74
+ | Command | Description |
75
+ |---------|-------------|
76
+ | `squadrant init` | First-time setup — config, hub vault, scripts |
77
+ | `squadrant launch <project>` | Start a specific project captain |
78
+ | `squadrant launch --all` | Launch all captain workspaces |
79
+ | `squadrant command [--task <briefing\|learnings-review\|wiki-aggregate>] [--agent <a>]` | Spawn a one-shot Command session in a split pane (no persistent Command). |
80
+ | `squadrant status` | Show all project status (no Claude needed) |
81
+ | `squadrant standup` | Daily standup summary (zero LLM tokens) |
82
+ | `squadrant doctor` | Health check — verify dependencies |
83
+ | `squadrant projects list` | List registered projects |
84
+ | `squadrant projects add <name> <path>` | Register a project |
85
+ | `squadrant projects remove <name>` | Unregister a project |
86
+ | `squadrant dashboard [--once]` | Print a one-shot status grid for all projects to the terminal. |
87
+ | `squadrant dashboard --pane [--direction <dir>] [--interval <s>]` | Open a refreshing sidebar pane in the current cmux workspace. |
88
+ | `squadrant dashboard sync-hub [--json]` | Mirror spoke `status.md` files into `{hubVault}/projects/` for Obsidian Dataview. |
89
+ | `squadrant runtime status <project>` | Check if a project's captain workspace is running |
90
+ | `squadrant runtime send <project> <msg>` | Send a message to a captain workspace (auto-Enter) |
91
+ | `squadrant runtime list` | List all workspaces from the active runtime |
92
+ | `squadrant workspace read <project> <path>` | Read a scope-relative file from the project's spoke vault |
93
+ | `squadrant workspace list <project> <dir>` | List entries in a spoke vault directory |
94
+ | `squadrant workspace read --hub <path>` | Read from the hub vault |
95
+ | `squadrant notify <message>` | Send a message to the user via the configured notifier |
96
+ | `squadrant projection emit [--scope user\|project] [--project <name>] [--target <name>] [--all]` | Emit squadrant rules + skills to Cursor/Codex/Gemini config files |
97
+ | `squadrant projection diff [same flags]` | Preview projection changes without writing |
98
+ | `squadrant projection list` | Show registered projection targets and their destinations |
99
+ | `squadrant crew spawn <project> <task> [--name <n>] [--direction tab\|right\|left\|up\|down] [--agent <a>]` | Spawn an interactive crew sub-session (tab in the captain workspace by default; `--direction` for a pane) |
100
+ | `squadrant crew send <project> <name> <message>` | Send a follow-up turn to an existing crew |
101
+ | `squadrant crew read <project> <name>` | Read a crew session's current screen |
102
+ | `squadrant crew close <project> <name>` | Shutdown a crew session (closes its tab) |
103
+ | `squadrant crew list <project>` | List live crews for a project |
104
+ | `squadrant shutdown [project]` | Graceful shutdown |
105
+ | `squadrant effort [max\|balance\|low]` | Get or set the global crew tokenomics dial (no arg prints current) |
106
+ | `squadrant retro` | Generate a retro (weekly/sprint summary) from daily logs and git (zero tokens) |
107
+ | `squadrant config check` | Detect config drift vs the current default schema |
108
+ | `squadrant heal [--dry-run\|daemon]` | Targeted, idempotent remediation for squadrant components (daemon, health) |
109
+ | `squadrant group dispatch …` | Cross-project intra-group operations (dispatch a task to a sibling project) |
110
+ | `squadrant cmux …` | cmux integration helpers |
111
+ | `squadrant feedback` | Open opt-in feedback issue |
112
+
113
+ ## Monorepo structure
114
+
115
+ Six internal packages in a one-way dependency DAG. All are private (not published to npm).
116
+
117
+ | Package | Owns | Notes |
118
+ |---|---|---|
119
+ | `@squadrant/shared` | Config schema, TypeScript types, constants | Leaf lib — zero internal deps |
120
+ | `@squadrant/core` | Daemon logic, state-machine, protocol, `AgentDriver` interface, task/crew bus | No concrete drivers — pure interfaces + orchestration |
121
+ | `@squadrant/agents` | AI driver seam — `claude`, `codex`, `opencode`, `gemini` drivers + registry | Implements `AgentDriver`. Add a new AI agent here. |
122
+ | `@squadrant/workspaces` | Runtime (cmux), workspace (obsidian), notifier (cmux) drivers + registries | Implements surface/workspace/notifier seams |
123
+ | `@squadrant/web` | Observability dashboard — bundled HTML/JS served by CLI | Read-only UI; inlined by CLI's tsup build |
124
+ | `@squadrant/cli` | Commands, bin entry, daemon host, templates, plugin dir | Root — depends on all other packages |
125
+
126
+ **Dependency DAG:** `shared ◄ core ◄ {agents, workspaces, web} ◄ cli`
127
+
128
+ **Build outputs** (`pnpm build` via tsup, all internal packages inlined):
129
+ - `dist/index.js` — CLI bin (`squadrant` command), entry: `packages/cli/src/index.ts`
130
+ - `dist/squadrantd.js` — daemon process, entry: `packages/cli/src/daemon-host.ts`
131
+
132
+ See the [architecture diagram](docs/diagrams/2026-06-18-cockpit-monorepo-architecture.html) for a visual overview.
133
+
134
+ ## Architecture
135
+
136
+ ### Roles
137
+
138
+ - **Command** (Opus) — *on-demand* cross-project session. Spawned by `squadrant command --task <briefing|learnings-review|wiki-aggregate>` in a split pane; exits when the task completes. No persistent Command process.
139
+ - **Captain** (Opus) — project leader, uses Agent Teams + git worktrees
140
+ - **Crew** (Sonnet by default) — interactive sub-session running as a new tab in the captain's workspace (or a split pane via `--direction`). Each crew is named (`crew-1`, `crew-2`, …) and stays idle between turns waiting for the captain's next message — same model as a Claude Agent Team subagent. Spawn with `squadrant crew spawn`, send follow-ups with `squadrant crew send`, close when done. Works with any agent CLI (claude and opencode are fully interactive; codex/gemini currently print-mode). Uses GSD for complex tasks.
141
+
142
+ ### Model Routing
143
+
144
+ Each role runs on the optimal model for cost/quality tradeoff. Configured in `config.json`:
145
+ - Command/Captain/Review: Opus (coordination + quality)
146
+ - Crew: Sonnet (execution)
147
+ - Exploration: Haiku (cheap lookups)
148
+
149
+ ### Runtime Abstraction
150
+
151
+ Workspaces run on a pluggable **runtime driver** (currently only `cmux`). Each project may override the global default via its `runtime` field. Bash scripts call `squadrant runtime <op>` to talk to the configured runtime instead of any specific binary. New runtimes (tmux, Docker, SSH) are added as driver files in `@squadrant/workspaces` (`packages/workspaces/runtimes/`) — see `docs/specs/archive/2026-04-20-plugin-system-runtime-design.md`.
152
+
153
+ ### Workspace Abstraction
154
+
155
+ Vault storage (hub + per-project spokes) runs behind a pluggable **workspace driver** (currently only `obsidian`). Filesystem operations — `read`, `write`, `list`, `exists`, `mkdir` — go through the driver instead of `fs` directly. Each project may override the global default via its `workspace` field. Bash scripts call `squadrant workspace <op>` to read/write vault data without hardcoding paths. New backends (Notion, plain-md, S3) are added as driver files in `@squadrant/workspaces` (`packages/workspaces/workspaces/`) — see `docs/specs/archive/2026-04-21-plugin-system-workspace-design.md`.
156
+
157
+ ### Notifier Abstraction
158
+
159
+ User-facing notifications run behind a pluggable **notifier driver** (currently only `cmux`). Escalations and other "tell the user" events go through `squadrant notify <message>`. The default `CmuxNotifier` delegates to `squadrant runtime send --command` — the abstraction exists as a swap-point for future Slack/Discord/email/pager drivers. Notifier is global (no per-project override). See `docs/specs/archive/2026-04-21-plugin-system-notifier-design.md`.
160
+
161
+ ### Crew Spawn (Interactive Sub-Sessions)
162
+
163
+ Crew is the captain's equivalent of an Agent Team subagent — but runtime-agnostic. The captain spawns a crew via `squadrant crew spawn <project> "<task>" [--name <n>]`, which opens a new tab in the captain's cmux workspace, boots an interactive Claude session (no `-p`), and sends the task as the first turn. The crew works on it and **stays idle** waiting for follow-ups. The captain drives the session with `squadrant crew send/read/close/list`, addressing each crew by its tab title (`🔧 <project>:<name>`).
164
+
165
+ Pass `--direction right|left|up|down` to use a split pane instead of a tab. State lives in the surface buffer + git; tabs die with the captain workspace on `squadrant shutdown`. Non-Claude agents (codex/gemini) currently still launch in print-mode; full interactive support is a follow-up. See [`docs/specs/archive/2026-05-05-squadrant-thin-redirect-design.md`](docs/specs/archive/2026-05-05-squadrant-thin-redirect-design.md).
166
+
167
+ ### Effort Dial (Tokenomics)
168
+
169
+ `squadrant effort max|balance|low` is a single global dial that biases how aggressively crews consume tokens — a captain-discretion signal, not mechanical routing. `max` favors quality/tokens, `low` biases toward economy (e.g. preferring opencode for cheap work); `balance` sits between. Run `squadrant effort` with no argument to print the current setting. The value lives in config and is honored by captains via the captain-ops playbook ([#317](https://github.com/tu11aa/squadrant/issues/317) / [#381](https://github.com/tu11aa/squadrant/pull/381)).
170
+
171
+ ### Crew Lifecycle & Delivery
172
+
173
+ - **Daemon-direct delivery** — crew turns and handoffs are delivered straight to the cmux surface by the daemon. The old `notify-relay` supervisor was deleted; there is no relay process to keep alive ([#332](https://github.com/tu11aa/squadrant/issues/332)).
174
+ - **Semantic heartbeat** — crews emit a lifecycle signal the captain reads as **CREW IDLE / QUIET / STALLED**, distinguishing "waiting for you" from "wedged" without scraping the pane ([#354](https://github.com/tu11aa/squadrant/issues/354)).
175
+ - **`stopped` project status + orphan reap** — when a captain goes away, the daemon reaps its orphaned crews and marks the project `stopped` (intentional shutdown) rather than leaving stale tabs or faulting ([#324](https://github.com/tu11aa/squadrant/issues/324) / [#323](https://github.com/tu11aa/squadrant/issues/323) / [#388](https://github.com/tu11aa/squadrant/pull/388)).
176
+
177
+ ### Projection (Cross-Agent Config Sync)
178
+
179
+ Squadrant rules (Karpathy principles, captain-ops) and per-project AGENTS.md emit to each supported agent's canonical path via `squadrant projection emit`. User-level projection pushes squadrant's skills to `~/.cursor/rules/squadrant-global.mdc`, `~/.codex/AGENTS.md`, `~/.gemini/GEMINI.md`. Project-level projection pushes a managed project's own `AGENTS.md` into `{project}/CLAUDE.md`, `{project}/.cursor/rules/squadrant.mdc`, `{project}/GEMINI.md` — zero squadrant-global content leaks into the project repo. Shared files use `<!-- squadrant:start --> ... <!-- squadrant:end -->` markers; dedicated files overwrite. See `docs/specs/archive/2026-04-24-plugin-system-projection-design.md`.
180
+
181
+ The user-level projection now also inlines `templates/captain.generic.md` and `templates/crew.generic.md` as `## Captain Role` / `## Crew Role` sections inside the squadrant marker block, so non-Claude agents (Codex, Gemini, Cursor) load the same role descriptions Claude Code loads via `--append-system-prompt-file`. See `docs/specs/archive/2026-05-05-multi-agent-template-parity-plan.md` (#45).
182
+
183
+ ### Obsidian Vaults (Hub-and-Spoke)
184
+
185
+ - **Hub vault** (`~/squadrant-hub`) — cross-project dashboard + hub wiki
186
+ - **Spoke vaults** — per-project status, learnings, and wiki
187
+
188
+ ### Knowledge System (opt-in writes)
189
+
190
+ - **Status (opt-in)** — captains record `{spokeVault}/status.md` via `write-status.sh` (also written by the captain session-end hook) when there's something worth noting (a blocker, "starting work on X"). Not on a schedule.
191
+ - **Dashboard** — `squadrant dashboard --pane` opens a refreshing sidebar pane in cmux that lists every project's live state, queried from the squadrant daemon's task records. `squadrant dashboard sync-hub` mirrors each spoke `status.md` into `{hubVault}/projects/` so the hub vault's `dashboard.md` Dataview query renders the same data inside Obsidian.
192
+ - **Handoff files** — captain writes when in-flight work needs to survive into tomorrow; skipped on uneventful sessions.
193
+ - **Daily logs** — captain writes when the day produced something worth a log; not on a schedule.
194
+ - **Learnings** — recorded when a captain encounters a genuinely surprising or reusable pattern.
195
+ - **Wiki** — compiled, indexed knowledge pages in spoke vaults (`wiki/pages/`); promoted from learnings when worth maintaining.
196
+ - **Hub Wiki** — cross-project knowledge aggregated by an on-demand `squadrant command --task wiki-aggregate` run.
197
+ - Scripts: `wiki-ingest.sh`, `wiki-query.sh`, `wiki-log.sh`.
198
+
199
+ ### Session Continuity
200
+
201
+ - **Handoff files** — captain writes context on shutdown, reads on startup
202
+ - **Session freshness** — auto-detects new day or template changes, forces fresh context
203
+ - **claude-mem** — cross-session memory via MCP plugin
204
+
205
+ ## Config
206
+
207
+ `~/.config/squadrant/config.json`
208
+
209
+ ```json
210
+ {
211
+ "commandName": "command",
212
+ "hubVault": "~/squadrant-hub",
213
+ "runtime": "cmux",
214
+ "workspace": "obsidian",
215
+ "notifier": "cmux",
216
+ "projects": {
217
+ "brove": {
218
+ "path": "~/projects/brove",
219
+ "captainName": "brove-captain",
220
+ "spokeVault": "~/squadrant-hub/spokes/brove",
221
+ "host": "local",
222
+ "runtime": "cmux",
223
+ "workspace": "obsidian",
224
+ }
225
+ },
226
+ "defaults": {
227
+ "maxCrew": 5,
228
+ "worktreeDir": ".worktrees",
229
+ "teammateMode": "in-process",
230
+ "permissions": {
231
+ "command": "default",
232
+ "captain": "acceptEdits"
233
+ },
234
+ "models": {
235
+ "command": "opus",
236
+ "captain": "opus",
237
+ "crew": "sonnet",
238
+ "exploration": "haiku",
239
+ "review": "opus"
240
+ }
241
+ }
242
+ }
243
+ ```
244
+
245
+ ## Supported Agents
246
+
247
+ | Agent | Status | Notes |
248
+ |---|---|---|
249
+ | Claude Code | ✅ Shipping | Reference implementation; reads `CLAUDE.md`, Skill tool, MCP via settings.json |
250
+ | Codex CLI | ✅ projection (skills + roles) | Captain/crew roles inlined into `~/.codex/AGENTS.md` (#45). First-class role identity is #35. |
251
+ | Cursor | ✅ projection (skills + roles) | Captain/crew roles inlined into `~/.cursor/rules/squadrant-global.mdc` (#45). |
252
+ | Gemini CLI | ✅ projection (skills + roles) | Captain/crew roles inlined into `~/.gemini/GEMINI.md` (#45). |
253
+ | opencode | ✅ driver + projection (interactive crew) | `opencode run "<prompt>"` with `--format json` / `-m <model>`; AGENTS.md projects to `~/.config/opencode/AGENTS.md`. |
254
+
255
+ Cross-agent config sync (one canonical source → agent-specific formats) is tracked in [#31](https://github.com/tu11aa/squadrant/issues/31).
256
+
257
+ ## Inspirations
258
+
259
+ - **[Andrej Karpathy](https://x.com/karpathy/status/2015883857489522876)** — coding principles baked into every captain/crew role ([`plugin/skills/karpathy-principles/SKILL.md`](plugin/skills/karpathy-principles/SKILL.md))
260
+ - **[forrestchang/andrej-karpathy-skills](https://github.com/forrestchang/andrej-karpathy-skills)** — reference packaging for the four principles (MIT)
261
+ - **[Multica](https://github.com/multica-ai/multica)** — validated the multi-agent runtime + skill-compounding direction
262
+ - **[AGENTS.md](https://agents.md/)** — convergence point for cross-agent instructions
263
+ - **[OpenSpace](https://github.com/openspacelabs/openspace)** — self-improving learnings loop (record → capture → fix → mark-useful)
264
+ - **[ComposioHQ](https://github.com/ComposioHQ/composio)** — tool/skill portability across agents
265
+
266
+ ## License
267
+
268
+ MIT