@coralai/sps-cli 0.51.3 → 0.51.5

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 CHANGED
@@ -1,1482 +1,539 @@
1
1
  # SPS CLI — AI Agent Harness & Development Pipeline
2
2
 
3
- [![npm](https://img.shields.io/npm/v/@coralai/sps-cli)](https://www.npmjs.com/package/@coralai/sps-cli)
3
+ [![npm](https://img.shields.io/npm/v/@coralai/sps-cli)](https://www.npmjs.com/package/@coralai/sps-cli) [![license](https://img.shields.io/npm/l/@coralai/sps-cli)](../../LICENSE)
4
4
 
5
- > **中文文档**: See `README-CN.md` in the source repository for Chinese documentation.
5
+ > **中文文档**:[README-CN.md](./README-CN.md)
6
6
 
7
- **v0.51.0**
7
+ **v0.51.3**
8
8
 
9
- SPS (Smart Pipeline System) is an AI Agent harness and automated development pipeline. Three modes:
9
+ SPS (Smart Pipeline System) drives a Claude Code worker through task cards — code, commit, push, QA, merge, all automated. Three modes:
10
10
 
11
- - **Harness mode** (`sps agent`): Zero-config agent interaction — one-shot, multi-turn chat, persistent sessions
12
- - **Pipeline mode** (`sps pipeline`): Fully automated card-driven development workflow with YAML-configurable stages
13
- - **Console mode** (`sps console`, **v0.44+**): Local web dashboard project list, kanban, workers, logs, skills management in one UI
11
+ | Mode | Command | When |
12
+ |---|---|---|
13
+ | **Harness** | `sps agent` | Zero-config one-shot or multi-turn chat with Claude. No project, no PM. |
14
+ | **Pipeline** | `sps tick <project>` | Automated card-driven workflow with YAML-configurable stages. |
15
+ | **Console** | `sps console` | Web UI — kanban, logs, workers, projects, chat (since v0.44). |
14
16
 
15
- **v0.51.0 Wiki Knowledge Base** ([doc-28](../../docs/design/28-wiki-system.md), opt-in per project):
17
+ The headline feature in v0.51 is the **Wiki Knowledge Base** — opt-in per project, structured cross-linked pages (modules / concepts / decisions / lessons / sources), 5-layer retrieval auto-injected into worker prompts. See [doc-28](../../docs/design/28-wiki-system.md) and [`ATTRIBUTION.md`](./ATTRIBUTION.md).
16
18
 
17
- ```bash
18
- sps wiki init <project> # scaffold wiki/ + WIKI.md + .gitignore
19
- sps wiki update <project> # source diff (--finalize writes manifest)
20
- sps wiki read <project> "<query>" # 5-layer retrieval → prompt-injection markdown
21
- sps wiki check <project> # lint: orphan / dead-link / fm-gap / stale
22
- sps wiki list/get/add/status # helpers
23
- ```
24
-
25
- When `WIKI_ENABLED=true` is set, StageEngine auto-injects the 5-layer wiki context
26
- into Worker prompts (hot.md + index summary + relevant pages, ranked
27
- lesson/decision > concept > module/source) and appends a wiki-update reminder.
28
- The Worker then follows `skills/wiki-update/SKILL.md` to write/update pages.
29
- Inspired by [claude-obsidian](https://github.com/kepano/claude-obsidian) (MIT) +
30
- Karpathy's "LLM Wiki" pattern; see [`ATTRIBUTION.md`](./ATTRIBUTION.md).
31
-
32
- ```bash
33
- # Harness mode — talk to Claude Code instantly
34
- sps agent "Explain this repo"
35
- sps agent --chat # multi-turn REPL (daemon-backed)
36
- sps agent --profile reviewer --context src/auth.ts "Review this module"
37
- sps agent --verbose --output report.md "Security audit"
38
-
39
- # Pipeline mode — automated development workflow
40
- sps pipeline start my-project # or: sps tick my-project
41
- sps pipeline workers my-project # worker dashboard
42
- sps pipeline board my-project # card board
43
- ```
44
-
45
- ## Harness Mode (`sps agent`)
46
-
47
- Zero-config direct agent interaction. No project setup, PM tools, or Git required.
48
-
49
- ### One-shot
50
-
51
- ```bash
52
- sps agent "What does this codebase do?"
53
- sps agent --output summary.md "Summarize this repo"
54
- ```
55
-
56
- ### Multi-turn Chat (Persistent)
57
-
58
- Sessions survive terminal closures via background daemon:
59
-
60
- ```bash
61
- sps agent --chat # start chat (daemon auto-starts)
62
- > Analyze the auth module
63
- > Now refactor it to use bcrypt
64
- > /exit # detach (session stays alive)
65
-
66
- sps agent --chat # reconnect — agent remembers context
67
- > What did we do last time?
68
- ```
69
-
70
- ### Advanced Flags
71
-
72
- Claude is the only supported CLI as of v0.38.0; there is no `--tool` flag.
73
-
74
- | Flag | Description | Example |
75
- |------|-------------|---------|
76
- | `--chat` | Multi-turn REPL mode | `sps agent --chat` |
77
- | `--name <name>` | Named session (persistent) | `--name backend` |
78
- | `--verbose` / `-v` | Show tool calls | Shows Read, Edit, Bash in yellow |
79
- | `--context <file>` | Attach file content | `--context src/main.ts` (multiple OK) |
80
- | `--system "<text>"` | System instruction | `--system "Reply in Chinese"` |
81
- | `--profile <name>` | Load role profile | `--profile reviewer`, `--profile security` |
82
- | `--output <file>` | Save output to file | `--output report.md` |
83
- | `--json` | JSON output for scripting | `sps agent --json "2+2"` |
84
- | `--hook <cmd>` | Post-prompt feedback loop | `--hook "npm test"` (multiple OK) |
85
- | `--mcp <server>` | Attach MCP server | `--mcp postgres`, `--mcp github` |
86
- | `--attach` | Read-only session viewer | `--attach --name backend` |
87
-
88
- ### Hook Feedback Loop
89
-
90
- Agent completes → hooks run → if any fail → failure fed back to agent → agent fixes → retry (max 5):
91
-
92
- ```bash
93
- # Auto-fix until tests pass
94
- sps agent --hook "npm test" "Fix the failing auth test"
95
-
96
- # Multi-hook: lint + typecheck
97
- sps agent --hook "npm run lint" --hook "npm run typecheck" "Refactor utils"
98
-
99
- # Multi-agent: writer + reviewer loop
100
- sps agent --hook "sps agent --json --profile reviewer 'Review. Reply PASS or FAIL.'" "Write auth module"
101
- ```
102
-
103
- ### MCP Server Integration
104
-
105
- Attach MCP servers to give the agent additional tools:
106
-
107
- ```bash
108
- sps agent --mcp postgres "Show all tables and row counts"
109
- sps agent --mcp github "List open issues in this repo"
110
- sps agent --mcp filesystem --mcp fetch "Download the API spec and save it locally"
111
- ```
112
-
113
- Built-in: `filesystem`, `postgres`, `sqlite`, `github`, `memory`, `fetch`. Custom: any command path.
114
-
115
- ### Session Management
116
-
117
- ```bash
118
- sps agent status # list active sessions
119
- sps agent close --name backend # close a session
120
- sps agent --attach --name backend # read-only view of session output
121
- sps agent daemon start # start background daemon manually
122
- sps agent daemon stop # stop daemon (kills all sessions)
123
- sps agent daemon status # check daemon status
124
- ```
125
-
126
- ### Cross-Server Remote Sessions
127
-
128
- Access a remote server's daemon via SSH tunnel:
129
-
130
- ```bash
131
- # Remote server: start daemon
132
- sps agent daemon start
133
-
134
- # Remote server: bridge socket to TCP (run once)
135
- node -e "
136
- const net = require('net');
137
- const server = net.createServer(c => {
138
- const d = net.createConnection('/home/user/.coral/sessions/daemon.sock');
139
- c.pipe(d); d.pipe(c);
140
- c.on('error', () => d.destroy()); d.on('error', () => c.destroy());
141
- });
142
- server.listen(19876, '127.0.0.1', () => console.log('Bridge ready'));
143
- " &
144
-
145
- # Local machine: SSH tunnel
146
- ssh -L 19876:127.0.0.1:19876 user@server -N &
147
-
148
- # Local machine: bridge TCP back to socket
149
- node -e "
150
- const net = require('net');
151
- try { require('fs').unlinkSync('/tmp/sps-remote.sock'); } catch {}
152
- const server = net.createServer(c => {
153
- const r = net.createConnection(19876, '127.0.0.1');
154
- c.pipe(r); r.pipe(c);
155
- c.on('error', () => r.destroy()); r.on('error', () => c.destroy());
156
- });
157
- server.listen('/tmp/sps-remote.sock', () => console.log('Local bridge ready'));
158
- " &
159
-
160
- # Local machine: use remote daemon
161
- SPS_DAEMON_SOCKET=/tmp/sps-remote.sock sps agent --name work "Analyze the codebase"
162
- ```
163
-
164
- ### Agents
165
-
166
- Built-in agent: `claude` only (as of v0.38.0). Codex and Gemini support have been removed.
167
-
168
- ## Pipeline Mode (`sps pipeline`)
169
-
170
- Fully automated card-driven development workflow. Requires project configuration.
171
-
172
- ```bash
173
- sps pipeline start my-project # start continuous pipeline (= sps tick)
174
- sps pipeline stop my-project # stop pipeline
175
- sps pipeline status # show all projects
176
- sps pipeline reset my-project # reset cards for re-execution
177
- sps pipeline workers my-project # worker dashboard
178
- sps pipeline board my-project # card board
179
- sps pipeline logs my-project # log viewer
180
- ```
181
-
182
- All old commands still work as aliases: `sps tick`, `sps stop`, `sps status`, `sps reset`, `sps logs`, `sps worker dashboard`, `sps card dashboard`.
183
-
184
- ### Pipeline YAML Configuration
185
-
186
- Create `.sps/pipelines/<name>.yaml` in your project to customize the pipeline:
187
-
188
- ```yaml
189
- mode: project
190
-
191
- pm:
192
- card_states:
193
- planning: Planning
194
- backlog: Backlog
195
- ready: Todo
196
- active: Inprogress
197
- review: QA
198
- done: Done
199
-
200
- stages:
201
- - name: develop
202
- trigger: "card_enters 'Todo'"
203
- card_state: Inprogress
204
- profile: phaser,typescript # skill profiles to load
205
- completion: git-evidence # git-evidence | fast-forward-merge | exit-code
206
- on_complete: "move_card QA"
207
- on_fail:
208
- action: "label NEEDS-FIX"
209
- comment: "Development failed."
210
-
211
- - name: integrate
212
- trigger: "card_enters 'QA'"
213
- card_state: QA
214
- completion: fast-forward-merge
215
- on_complete: "move_card Done"
216
- queue: fifo
217
- ```
218
-
219
- Switch between multiple pipelines:
220
-
221
- ```bash
222
- sps pipeline use my-project develop # activate develop.yaml
223
- sps pipeline use my-project docs # switch to docs.yaml
224
- ```
225
-
226
- ### Worker Management
227
-
228
- ```bash
229
- sps worker ps my-project # show worker status, pid, runtime
230
- sps worker kill my-project 42 # kill specific worker by seq
231
- ```
232
-
233
- ### Console Mode (`sps console`, v0.44+)
234
-
235
- Local web dashboard — a Pastel Neubrutalism UI over all SPS data. One command:
236
-
237
- ```bash
238
- sps console # starts server, opens browser at http://localhost:4311
239
- sps console --port 5000 # custom port
240
- sps console --no-open # don't auto-open browser
241
- sps console --dev # dev mode (proxy to Vite HMR server)
242
- sps console --kill # stop running console
243
- ```
244
-
245
- What you get:
246
- - **Project list** — all `~/.coral/projects/*` at a glance, with card/worker stats
247
- - **Kanban board** — cards by state, per-project, SSE live updates (M2)
248
- - **Workers** — 4-slot table with running/stuck/crashed/idle, log tail per slot (M3)
249
- - **Logs** — live tail with level filter, search (M3)
250
- - **Skills** — link/freeze/unfreeze, category-colored grid (M4)
251
- - **System** — version, env config, doctor (M4)
252
- - **Chat** — `sps agent` daemon sessions, streamed (M5)
253
-
254
- Under the hood: Node + Hono on `127.0.0.1:4311`, chokidar watchers pushing SSE to a React 19 + Vite + Tailwind v4 + shadcn/ui frontend. Design system locked in `console/DESIGN.md`.
255
-
256
- ### Skill Management
257
-
258
- SPS ships 27 bundled skills (23 developer skills + 4 worker profiles). Three-tier
259
- distribution:
260
-
261
- ```
262
- npm package user level project level
263
- workflow-cli/skills/ ──cpSync──▶ ~/.coral/skills/ ──symlink──▶ <project>/.claude/skills/
264
- (bundled) (stable path) (gitignored)
265
- ```
266
-
267
- Bundled skills cover languages (`python`, `typescript`, `golang`, `rust`, `kotlin`,
268
- `swift`, `java`), ends (`frontend`, `backend`, `mobile`, `database`, `devops`),
269
- personas (`backend-architect`, `code-reviewer`, `qa-tester`, ...), and workflows
270
- (`coding-standards`, `git-workflow`, `architecture-decision-records`,
271
- `debugging-workflow`). Card frontmatter references them by name:
272
-
273
- ```yaml
274
- ---
275
- title: "Implement login API"
276
- skills: [backend, python, security-engineer]
277
19
  ---
278
- ```
279
-
280
- Command family:
281
-
282
- ```bash
283
- sps skill list # list user-level skills + project link state
284
- sps skill add python # symlink into current project's .claude/skills/
285
- sps skill remove python # remove the link (user-level source untouched)
286
- sps skill freeze backend # symlink → real copy (allow project-level customization)
287
- sps skill unfreeze backend # real copy → symlink (drop local edits, re-follow global)
288
- sps skill sync # (1) bundled → user, (2) user → ~/.claude/skills/
289
- ```
290
-
291
- `add` uses `symlinkSync` (with `cpSync` fallback). First run auto-appends
292
- `.claude/skills/` to the project's `.gitignore` — per-user symlinks shouldn't
293
- go into the repo.
294
-
295
- ### Memory System
296
-
297
- Three-layer persistent memory at `~/.coral/memory/`:
298
-
299
- ```
300
- ~/.coral/memory/
301
- ├── user/ # Cross-project user preferences
302
- ├── agents/<id>/ # Per-daemon instance experience
303
- └── projects/<name>/ # Project-specific knowledge
304
- ```
305
-
306
- ```bash
307
- sps memory context my-project # generate prompt injection (user + project)
308
- sps memory context my-project --agent daemon-1 # include agent memory
309
- sps memory list my-project # show all memory indexes
310
- sps memory list my-project --agent daemon-1 # include agent layer
311
- sps memory add my-project --type convention --name "API naming" --body "Use camelCase"
312
- ```
313
-
314
- Memory types: `convention` (no decay), `decision` (slow decay), `lesson` (30-day decay), `reference` (no decay).
315
-
316
- Workers receive memory in their prompt and can write new memories directly to the filesystem. Frontmatter format: `name`, `description`, `type`. Each directory has a `MEMORY.md` index file.
317
-
318
- ### Global Configuration
319
-
320
- `~/.coral/env` holds shared credentials (GitLab, PM backends, Matrix). No agent selector — claude is the only supported CLI.
321
-
322
- ## Architecture
323
-
324
- ```
325
- SPS CLI
326
- ├── Harness Mode (sps agent)
327
- │ ├── SessionDaemon (Unix socket, background persistent)
328
- │ ├── DaemonClient (NDJSON RPC)
329
- │ └── AcpSdkAdapter
330
- │ └── claude-agent-acp (ACP community shim for Claude Code)
331
-
332
- ├── Pipeline Mode (sps pipeline)
333
- │ ├── WorkerManager + CompletionJudge
334
- │ ├── 3-Layer Engine: Scheduler → StageEngine × N → Monitor
335
- │ └── AcpSdkAdapter (shared with harness)
336
-
337
- └── Memory System (~/.coral/memory/)
338
- ├── user/ (cross-project preferences)
339
- ├── agents/<id>/ (per-daemon experience)
340
- └── projects/<name>/ (conventions, decisions, lessons, references)
341
- ```
342
20
 
343
- ACP SDK transport: structured JSON-RPC over stdio. No terminal scraping. Deterministic state detection via protocol events.
344
-
345
- ## Table of Contents
346
-
347
- - [Installation](#installation)
348
- - [Prerequisites](#prerequisites)
349
- - [Quick Start](#quick-start)
350
- - [Harness Mode](#harness-mode-sps-agent)
351
- - [Pipeline Mode](#pipeline-mode-sps-pipeline)
21
+ ## Table of contents
22
+
23
+ - [Install & setup](#install--setup)
24
+ - [Harness mode (`sps agent`)](#harness-mode-sps-agent)
25
+ - [Console mode (`sps console`)](#console-mode-sps-console)
26
+ - [Pipeline mode (`sps tick`)](#pipeline-mode-sps-tick)
27
+ - [Card lifecycle](#card-lifecycle)
28
+ - [Memory + Wiki](#memory--wiki)
29
+ - [Skills](#skills)
30
+ - [Command reference](#command-reference)
31
+ - [Project config (conf)](#project-config-conf)
32
+ - [Project layout](#project-layout)
352
33
  - [Architecture](#architecture)
353
- - [State Machine](#state-machine)
354
- - [Command Reference](#command-reference)
355
- - [Worker Rule Files](#worker-rule-files)
356
- - [Project Configuration](#project-configuration)
357
- - [Multi-Project Parallel Execution](#multi-project-parallel-execution)
358
- - [Architecture Overview](#architecture-overview)
359
- - [Directory Structure](#directory-structure)
360
-
361
- ---
362
-
363
- ## Installation
364
-
365
- ```bash
366
- npm install -g @coralai/sps-cli
367
- ```
368
-
369
- Local development:
370
-
371
- ```bash
372
- cd coding-work-flow/workflow-cli
373
- npm run build
374
- # Or run directly with tsx
375
- npx tsx src/main.ts --help
376
- ```
377
-
378
- ## Prerequisites
379
-
380
- | Dependency | Minimum Version | Description |
381
- |------------|----------------|-------------|
382
- | Node.js | 18+ | CLI runtime |
383
- | git | 2.x | Branch and worktree management |
384
- | Claude Code CLI or Codex CLI | Latest | AI Worker |
385
- | tmux | 3.x | No longer required (legacy dependency removed in v0.26.1) |
386
-
387
- ## Quick Start
388
-
389
- ```bash
390
- # 1. Global environment initialization (first-time setup, configure GitLab/PM/notification credentials)
391
- sps setup
392
-
393
- # 2. Clone your project repository (prerequisite)
394
- git clone git@gitlab.example.com:team/my-project.git ~/projects/my-project
395
-
396
- # 3. Initialize SPS project management directory
397
- sps project init my-project
398
-
399
- # 4. Edit project configuration
400
- vim ~/.coral/projects/my-project/conf
401
-
402
- # 5. Health check + auto-fix (generates CLAUDE.md, AGENTS.md, initializes state.json, etc.)
403
- sps doctor my-project --fix
404
-
405
- # 6. (Optional) Edit Worker rules to add project-specific coding standards
406
- vim ~/projects/my-project/CLAUDE.md
407
-
408
- # 7. Create task cards
409
- sps card add my-project "Implement user login" "JWT authentication endpoint"
410
- sps card add my-project "Implement order system" "CRUD API + pagination"
411
-
412
- # 8. Start pipeline (fully automated, exits when all cards are complete)
413
- sps tick my-project
414
-
415
- # 9. (Optional) Monitor Worker status in real time
416
- sps worker dashboard
417
-
418
- # 10. (Optional) Monitor task cards in board view
419
- sps card dashboard my-project
420
- ```
421
-
422
- ---
423
-
424
- ## State Machine
425
-
426
- Each task card progresses through the following state machine, fully driven by SPS:
427
-
428
- ### MR_MODE=none (Default, Recommended)
429
-
430
- The main path is now a worker-owned two-phase flow:
431
-
432
- ```
433
- Planning -> Backlog -> Todo -> Inprogress -> QA -> Done
434
- ```
435
-
436
- | Phase | Trigger Engine | Action |
437
- |-------|---------------|--------|
438
- | Planning -> Backlog | SchedulerEngine | Select card for queue, check admission criteria |
439
- | Backlog -> Todo | ExecutionEngine | Create branch, create worktree, generate phase prompts |
440
- | Todo -> Inprogress | ExecutionEngine | Assign Worker slot, launch development worker |
441
- | Inprogress -> QA | PostActions | Detect development completion, release slot, move card to QA |
442
- | QA -> Done | CloseoutEngine | Launch/resume integration worker, verify merge evidence, release resources, clean up worktree |
443
-
444
- In this model, the development worker stops at “implementation complete and committed on the task branch”. The QA worker owns integration: it must inspect the current worktree, rebase/merge the task branch back into the target branch, resolve conflicts, and finish the integration. If a development worker merges early anyway, SPS absorbs that as an exception from git evidence and closes the task directly instead of forcing an extra QA run. See `docs/design/10-acp-worker-runtime-design.md` for the persistent Agent transport model, the full worker state breakdown, and the local same-user OAuth reuse boundary. See `docs/design/11-runtime-state-authority-and-recovery-redesign.md` for the redesign that demotes `state.json` / `acp-state.json` to projections and re-centers recovery around PM state plus worktree/git evidence. See `docs/design/12-unified-runtime-state-machine.md` for the current unified state-machine model. See `docs/design/13-development-guardrails.md` for the non-negotiable development rules that prevent future features from reintroducing old state, merge, or prompt-model drift.
445
-
446
- The autonomous main path uses ACP SDK transport (`WORKER_TRANSPORT=acp-sdk`). Workers communicate with Claude Code via structured ACP JSON-RPC over stdio. `sps acp` commands provide diagnostic and manual-control capabilities.
447
-
448
- ### MR_MODE=create (Optional)
449
-
450
- After completing coding, the Worker creates an MR. The task is then considered complete. MR review is handled by subsequent processes (under development):
451
-
452
- ```
453
- Planning -> Backlog -> Todo -> Inprogress -> Done (MR created)
454
- ```
455
-
456
- | Phase | Trigger Engine | Action |
457
- |-------|---------------|--------|
458
- | Inprogress -> Done | ExecutionEngine | Detect Worker completion (MR created), release resources, clean up worktree |
459
-
460
- ### Auxiliary Status Labels
461
-
462
- Cards may be tagged with the following labels, indicating special handling is needed:
463
-
464
- | Label | Meaning | Handling |
465
- |-------|---------|----------|
466
- | `BLOCKED` | Blocked by external dependency | Skipped, awaiting manual intervention |
467
- | `NEEDS-FIX` | Worker failure or CI failure | Auto-fix or manual intervention |
468
- | `WAITING-CONFIRMATION` | Worker awaiting destructive operation confirmation | Notify for manual confirmation |
469
- | `CONFLICT` | Merge conflict | Worker auto-resolves or manual handling |
470
- | `STALE-RUNTIME` | Worker runtime anomaly | MonitorEngine cleanup |
471
-
472
- ---
473
-
474
- ## Command Reference
475
-
476
- ### Global Options
477
-
478
- All commands support:
479
-
480
- | Option | Description |
481
- |--------|-------------|
482
- | `--json` | Output structured JSON (for script/cron consumption) |
483
- | `--dry-run` | Preview actions without executing |
484
- | `--help` | Show help |
485
- | `--version` | Show version number |
486
-
487
- ### Exit Codes
488
-
489
- | Exit Code | Meaning |
490
- |-----------|---------|
491
- | `0` | Success |
492
- | `1` | Business failure / validation failure |
493
- | `2` | Argument error |
494
- | `3` | External dependency unavailable (GitLab / PM / Worker) |
34
+ - [Troubleshooting](#troubleshooting)
495
35
 
496
36
  ---
497
37
 
498
- ### sps setup
499
-
500
- Global environment initialization wizard for configuring external system credentials. Preserves existing values by showing current configuration as defaults -- press Enter to keep the current value.
38
+ ## Install & setup
501
39
 
502
40
  ```bash
503
- sps setup [--force]
41
+ npm install -g @coralai/sps-cli # latest 0.51.x
42
+ sps setup # interactive wizard (must run once)
504
43
  ```
505
44
 
506
- **Interactive configuration items:**
45
+ `sps setup`:
46
+ 1. Creates `~/.coral/` directory tree (`projects/`, `memory/{user,agents}/`).
47
+ 2. Copies bundled skills → `~/.coral/skills/`.
48
+ 3. Asks for `GITLAB_URL` / `GITLAB_TOKEN` / `MATRIX_*` (optional) → writes `~/.coral/env`.
49
+ 4. Symlinks user skills → `~/.claude/skills/`.
50
+ 5. Installs `@agentclientprotocol/claude-agent-acp` globally.
507
51
 
508
- - GitLab: `GITLAB_URL`, `GITLAB_TOKEN`, `GITLAB_SSH_HOST`, `GITLAB_SSH_PORT`
509
- - Plane: `PLANE_URL`, `PLANE_API_KEY`, `PLANE_WORKSPACE_SLUG`
510
- - Trello: `TRELLO_API_KEY`, `TRELLO_TOKEN`
511
- - Matrix: `MATRIX_HOMESERVER`, `MATRIX_TOKEN`, `MATRIX_ROOM_ID`
52
+ Re-run safe with `sps setup --force` (keeps existing values as defaults). After upgrading sps-cli later, run **`sps skill sync --force`** to pull updated skill SOPs (default sync is non-destructive — won't overwrite existing skills).
512
53
 
513
- Credentials are stored in `~/.coral/env` (permissions 0600), shared across all projects.
514
-
515
- | Option | Description |
516
- |--------|-------------|
517
- | `--force` | Overwrite existing `~/.coral/env` |
54
+ **Prerequisites**: Node 18; an Anthropic API key (or Claude Pro / Max subscription); `claude` CLI in PATH.
518
55
 
519
56
  ---
520
57
 
521
- ### sps project init
58
+ ## Harness mode (`sps agent`)
522
59
 
523
- Initialize an SPS project management directory.
60
+ Direct one-shot or multi-turn chat with Claude. No project, no PM, no Git.
524
61
 
525
62
  ```bash
526
- sps project init <project> [--force]
527
- ```
528
-
529
- **Created directory structure:**
530
-
531
- SPS management directory (`~/.coral/projects/<project>/`):
532
- ```
533
- ~/.coral/projects/<project>/
534
- ├── conf # Project configuration file (generated from template)
535
- ├── logs/ # Log directory
536
- ├── pm_meta/ # PM metadata cache
537
- ├── runtime/ # Runtime state
538
- ├── pipeline_order.json # Card execution order
539
- ├── batch_scheduler.sh # cron-compatible entry script
540
- └── deploy.sh # Deployment script template
541
- ```
542
-
543
- Target project repo (`<PROJECT_DIR>/.claude/`, installed when the repo path exists):
544
- ```
545
- <PROJECT_DIR>/.claude/
546
- ├── settings.json # Stop + UserPromptSubmit hooks (committed)
547
- ├── settings.local.json # autoMemoryDirectory (gitignored)
548
- ├── CLAUDE.md # Project rules skeleton
549
- ├── hooks/
550
- │ └── stop.sh # Default Stop hook script (marks COMPLETED-<stage>)
551
- ├── skills/ # Empty; add project-specific skills here
552
- └── rules/ # Empty; add path-scoped rules here
553
- ```
63
+ # One-shot
64
+ sps agent "Explain this repo"
65
+ sps agent --output summary.md "Summarize the architecture"
554
66
 
555
- | Option | Description |
556
- |--------|-------------|
557
- | `--force` | Overwrite template files (conf will not be overwritten; `.claude/` files are preserved) |
67
+ # Multi-turn (daemon-backed, persistent sessions)
68
+ sps agent --chat # interactive REPL
69
+ sps agent --chat --name reviewer # named session, resume later
70
+ sps agent status # list active sessions
71
+ sps agent close --name reviewer
558
72
 
559
- **Example:**
73
+ # Profile + context files
74
+ sps agent --profile reviewer "Review this module" --context src/auth.ts --context src/auth.test.ts
75
+ sps agent --system "You are a release engineer" "Plan the v0.52 cut"
560
76
 
561
- ```bash
562
- sps project init accounting-agent
563
- # -> Creates ~/.coral/projects/accounting-agent/
564
- # -> Next step: edit conf to fill in configuration values
77
+ # Verbose
78
+ sps agent --verbose "Why did this build fail?"
565
79
  ```
566
80
 
567
- ---
81
+ **`--profile <name>`**: looks up `~/.coral/skills/dev-worker/references/<name>.md`, injects as system prompt. (Different from `sps skill add` — that's for project-level skill linking.)
568
82
 
569
- ### sps doctor
83
+ **Built-in agent**: `claude` only (Codex / Gemini support removed in v0.38). Workers communicate via ACP JSON-RPC over stdio with `claude-agent-acp`.
570
84
 
571
- Project health check and auto-repair.
85
+ **Agent skills auto-loaded by Claude Code**: `~/.claude/skills/` is scanned by `claude` itself — including `sps-pipeline`, `sps-memory`, `wiki-update`, and the 24 dev/persona skills. Skill descriptions trigger lazy load; no SPS prompt injection needed for harness mode.
572
86
 
573
- ```bash
574
- sps doctor <project> [--fix] [--json] [--skip-remote]
575
- ```
576
-
577
- Equivalent to `sps project doctor <project>`.
578
-
579
- **Checks:**
580
-
581
- | Check | Description | --fix |
582
- |-------|-------------|-------|
583
- | global-env | Whether `~/.coral/env` exists | -- |
584
- | global-env-vars | Whether GITLAB_URL / GITLAB_TOKEN are loaded | -- |
585
- | conf-load | Whether configuration file can be loaded | -- |
586
- | conf-fields | Whether all required fields are present | -- |
587
- | instance-dir / logs-dir / runtime-dir / pm-meta-dir | Directory structure | Create missing directories |
588
- | repo-dir | Whether project repo exists and is a git repository | -- |
589
- | gitignore-sps | Whether `.sps/` is in .gitignore | Append |
590
- | worker-rules | Whether CLAUDE.md / AGENTS.md exist in repo root | Generate and commit (including .gitignore) |
591
- | skill-profiles | Whether profile files specified by DEFAULT_WORKER_SKILLS exist | -- |
592
- | state-json | Whether runtime state file is valid | Initialize |
593
- | pipeline-order | Whether execution order file exists | Create empty |
594
- | conf-cli-fields | Whether CLI-required Provider field mappings are complete (Plane only) | Append mappings |
595
- | gitlab | GitLab API connectivity | -- |
596
- | plane | Plane API connectivity (PM_TOOL=plane only) | -- |
597
- | pm-states / pm-lists | Whether PM state/list UUIDs are valid | Auto-create + write to conf |
598
- | worker-tool | Whether Claude Code / Codex CLI is in PATH | -- |
599
- | acp-runtime | Whether ACP agent binaries are available | -- |
600
-
601
- | Option | Description |
602
- |--------|-------------|
603
- | `--fix` | Auto-fix repairable issues (create directories, generate files, initialize state) |
604
- | `--json` | Output check results in JSON format |
605
- | `--skip-remote` | Skip remote connectivity checks (GitLab/Plane) |
606
-
607
- **Example:**
608
-
609
- ```bash
610
- # Check + auto-fix
611
- sps doctor my-project --fix
612
- # ok global-env /home/user/.coral/env
613
- # ok global-env-vars GITLAB_URL and GITLAB_TOKEN set
614
- # ok conf-load Loaded ~/.coral/projects/my-project/conf
615
- # ok conf-fields All required fields present
616
- # ok repo-dir /home/user/projects/my-project
617
- # ok gitignore-sps .sps/ in .gitignore
618
- # ok worker-rules Generated and committed: CLAUDE.md, AGENTS.md
619
- # ok skill-profiles DEFAULT_WORKER_SKILLS="senior" -- all profiles found
620
- # ok state-json Initialized with 3 worker slots
621
- # ok acp-runtime claude-agent-acp available
622
-
623
- # JSON output
624
- sps doctor my-project --json
625
- ```
87
+ **Daemon cwd caveat**: `sps console` and `sps agent --chat` start a session daemon (`~/.coral/sessions/daemon.sock`) that captures `process.cwd()` at startup and uses it as the default working directory for all chat workers. To switch the chat's working directory, restart the daemon: `sps agent daemon stop && sps agent daemon start` from the desired cwd.
626
88
 
627
89
  ---
628
90
 
629
- ### sps card add
91
+ ## Console mode (`sps console`)
630
92
 
631
- Create a task card.
93
+ Local web UI bundled into the binary. Single-instance guard via `~/.coral/console.lock`.
632
94
 
633
95
  ```bash
634
- sps card add <project> "<title>" ["description"]
96
+ sps console # opens http://127.0.0.1:4311
97
+ sps console --port 5000
98
+ sps console --no-open # don't auto-open browser
99
+ sps console --kill # stop running console
100
+ sps console --dev # vite dev server (development)
635
101
  ```
636
102
 
637
- Cards are created in the Planning state, automatically tagged with `AI-PIPELINE`, and appended to `pipeline_order.json`.
103
+ Pages:
638
104
 
639
- After creation, add a `skill:` label to specify the Worker's expertise (see label descriptions below).
105
+ | Path | Purpose |
106
+ |---|---|
107
+ | `/projects` | List all projects with status |
108
+ | `/projects/new` | Create project (form has Wiki toggle, v0.51+) |
109
+ | `/projects/<n>` | Pipeline editor + conf editor + delete |
110
+ | `/board` | Kanban (per-column scrolling, v0.51.1+) |
111
+ | `/workers` | Aggregate worker dashboard across projects |
112
+ | `/logs` | Live SSE log viewer |
113
+ | `/skills` | User-level skill management |
114
+ | `/system` | Global settings + daemon status |
115
+ | `/chat` | Agent chat (multi-session, persistent) |
640
116
 
641
- | Option | Description |
642
- |--------|-------------|
643
- | `--json` | Output creation result in JSON format |
644
-
645
- **Example:**
646
-
647
- ```bash
648
- # Create cards + add skill labels
649
- sps card add my-project "Implement user login" "JWT authentication endpoint"
650
- sps pm addLabel my-project 1 "skill:backend"
651
-
652
- sps card add my-project "Implement order list" "CRUD API + pagination"
653
- sps pm addLabel my-project 2 "skill:backend"
654
-
655
- sps card add my-project "Write API documentation" "User and order endpoint docs"
656
- sps pm addLabel my-project 3 "skill:writer"
657
- ```
658
-
659
- ### sps card dashboard
660
-
661
- Kanban-style dashboard for task cards. Single-project mode renders a full board, while multi-project mode renders compact mini boards side by side.
662
-
663
- ```bash
664
- sps card dashboard [project1] [project2] ... [--once] [--json]
665
- ```
666
-
667
- | Option | Description |
668
- |--------|-------------|
669
- | (no arguments) | Auto-discovers all projects under `~/.coral/projects/` and renders compact multi-project panels |
670
- | `<project>` | Render a full single-project board with `Planning / Backlog / Todo / In Progress / QA / Done` columns |
671
- | `--once` | Output one snapshot and exit |
672
- | `--json` | Output structured card/board snapshots for scripting |
673
-
674
- Single-project mode shows:
675
- - Project title and live counts
676
- - Six workflow columns
677
- - Compact task cards with title, label summary, worker/runtime state, and conflict/waiting badges
678
-
679
- Multi-project mode shows:
680
- - One panel per project
681
- - Compact per-state counts
682
- - Hot cards summary for running / waiting / conflict items
683
-
684
- **Example:**
685
-
686
- ```bash
687
- # Full board for one project
688
- sps card dashboard my-project
689
-
690
- # Compact board snapshots for all projects
691
- sps card dashboard
692
-
693
- # Single JSON snapshot
694
- sps card dashboard my-project --json
695
- ```
696
-
697
- #### Skill Labels
698
-
699
- Each card should have **one** `skill:` label. The Pipeline automatically loads the corresponding Worker skill profile and injects it into the prompt:
700
-
701
- | Label | Worker Role | Deliverables |
702
- |-------|------------|--------------|
703
- | `skill:architect` | Architecture design | ADR, design docs, directory structure |
704
- | `skill:frontend` | Frontend development | Components, pages, frontend tests |
705
- | `skill:backend` | Backend development | API, DB migration, backend tests |
706
- | `skill:fullstack` | Full-stack development | Frontend + backend + DB integrated |
707
- | `skill:prototyper` | Rapid prototyping | Runnable MVP |
708
- | `skill:reviewer` | Code review | Review report + fix commits |
709
- | `skill:security` | Security audit | Audit report + vulnerability fixes |
710
- | `skill:writer` | Technical writing | README, API docs, PRD |
711
- | `skill:optimizer` | Performance optimization | Benchmark report + optimization commits |
712
- | `skill:senior` | General purpose (fallback) | High-quality general implementation |
713
-
714
- Profile files are located at `~/.coral/profiles/<name>.md`. When no label is present, it falls back to the project conf's `DEFAULT_WORKER_SKILLS`.
117
+ Tech: Hono server on `127.0.0.1:4311`, chokidar watchers pushing SSE to React 19 + Vite + Tailwind v4 + shadcn/ui frontend. Design system: Pastel Neubrutalism, locked in [`console/DESIGN.md`](./console/DESIGN.md).
715
118
 
716
119
  ---
717
120
 
718
- ### sps tick
719
-
720
- Unified main loop -- orchestrates all engines, executing scheduler -> qa -> pipeline -> monitor in sequence.
721
-
722
- ```bash
723
- sps tick <project> [project2] [project3] ... [--json] [--dry-run]
724
- ```
725
-
726
- **Execution order (per tick cycle):**
727
-
728
- 1. **scheduler tick** -- Planning -> Backlog (select cards for queue)
729
- 2. **qa tick** -- QA -> integration worker -> Done (prioritize finishing branch integration and freeing Worker slots)
730
- 3. **pipeline tick** -- Backlog -> Todo -> Inprogress (prepare environment + launch Worker)
731
- 4. **monitor tick** -- Anomaly inspection and alignment
732
-
733
- **Run modes:**
734
-
735
- | Mode | Behavior |
736
- |------|----------|
737
- | Continuous (default) | Cycles every 30 seconds, auto-exits when all cards are complete |
738
-
739
- **Concurrency mutex:**
121
+ ## Pipeline mode (`sps tick`)
740
122
 
741
- Only one `tick` instance is allowed per project at any time. Mutex is implemented via `runtime/tick.lock` (PID + timestamp). Locks exceeding `TICK_LOCK_TIMEOUT_MINUTES` (default 30 minutes) are considered deadlocked and can be forcibly taken over.
123
+ Fully automated card-driven workflow. **One worker, one card at a time, serial.** Each card walks one or more YAML-defined stages (e.g. `develop review → Done`); failure halts pipeline until you remove the `NEEDS-FIX` label.
742
124
 
743
- **Failure classification:**
744
-
745
- | Type | Behavior | Example |
746
- |------|----------|---------|
747
- | Fatal failure | Short-circuits the entire tick | Corrupted conf, PM unavailable |
748
- | Degraded continuation | Subsequent steps run with limitations | Scheduler failure -> pipeline won't launch new cards |
749
- | Non-critical failure | Logged and continued | Notification send failure |
750
-
751
- | Option | Description |
752
- |--------|-------------|
753
- | `--once` | Exit after single execution |
754
- | `--json` | Output aggregated results in JSON format |
755
- | `--dry-run` | Preview actions without executing |
756
-
757
- **Example:**
125
+ ### Create a project
758
126
 
759
127
  ```bash
760
- # Single project continuous run
761
- sps tick my-project
762
-
763
- # Multi-project simultaneous management
764
- sps tick project-a project-b project-c
765
-
766
- # JSON output (suitable for cron)
767
- sps tick my-project --json
768
-
769
- # Preview mode
770
- sps tick my-project --dry-run
128
+ sps project init my-app
129
+ # or use Console /projects/new — has a Wiki toggle (v0.51+)
771
130
  ```
772
131
 
773
- **JSON output format:**
774
-
775
- ```json
776
- {
777
- "project": "my-project",
778
- "component": "tick",
779
- "status": "ok",
780
- "exitCode": 0,
781
- "steps": [
782
- { "step": "scheduler", "status": "ok", "actions": ["..."] },
783
- { "step": "qa", "status": "ok", "actions": ["..."] },
784
- { "step": "pipeline", "status": "ok", "actions": ["..."] },
785
- { "step": "monitor", "status": "ok", "checks": ["..."] }
786
- ]
787
- }
788
- ```
132
+ Asks for: project dir, merge branch, max workers, ACK timeout, optional GitLab remote, optional Matrix room.
789
133
 
790
- ---
791
-
792
- ### sps status
134
+ Generates:
793
135
 
794
- Show running status of all projects.
795
-
796
- ```bash
797
- sps status [--json]
798
136
  ```
799
-
800
- | Option | Description |
801
- |--------|-------------|
802
- | `--json` | Output structured JSON |
803
-
804
- ---
805
-
806
- ### sps acp
807
-
808
- Manage persistent session-backed worker sessions directly for diagnostics, manual intervention, and experiments. This is no longer the default transport used by `sps tick`.
809
-
810
- ```bash
811
- sps acp ensure <project> <slot> [claude] [--json]
812
- sps acp run <project> <slot> [claude] "<prompt>" [--json]
813
- sps acp prompt <project> <slot> [claude] "<prompt>" [--json]
814
- sps acp status <project> [slot] [--json]
815
- sps acp stop <project> <slot> [--json]
137
+ ~/.coral/projects/my-app/
138
+ ├── conf # mode 600 — your active config
139
+ ├── conf.example # full reference (read-only docs)
140
+ ├── pipelines/
141
+ │ ├── project.yaml # default 1-stage pipeline (develop → Done)
142
+ │ └── sample.yaml.example # heavily-commented YAML reference
143
+ └── pipeline_order.json # active pipeline pointer
816
144
  ```
817
145
 
818
- Current behavior:
819
-
820
- - `ensure` starts or reuses an ACP SDK session for the specified worker slot
821
- - `run` submits a prompt onto the session and records a new run snapshot
822
- - `status` refreshes session and run state from the local gateway
823
- - `stop` terminates the persistent session and marks the slot `offline`
824
- - `sps tick` does not use this transport as its default autonomous execution chain
825
- - retry / conflict follow-up runs reuse the same slot session when possible, and now recreate a fresh persistent session automatically if the old one has already disappeared
146
+ In the target repo (PROJECT_DIR):
826
147
 
827
- Observed session states:
828
-
829
- | State | Meaning |
830
- |-------|---------|
831
- | `ready` | Session is authenticated and idle, ready to accept a prompt |
832
- | `busy` | Session is alive and currently working |
833
- | `booting` | Session started but is still blocked on onboarding or authentication |
834
- | `offline` | Session is not reachable |
835
-
836
- Current verification scope:
837
-
838
- - Codex is verified in this release for `ensure -> run -> status -> stop`
839
- - Claude session bootstrap and status detection are implemented, but prompt execution still depends on host-side `claude auth login`
840
-
841
- ---
842
-
843
- ### sps scheduler tick
844
-
845
- Manually execute the scheduling step: Planning -> Backlog.
846
-
847
- ```bash
848
- sps scheduler tick <project> [--json] [--dry-run]
849
- ```
850
-
851
- - Reads `pipeline_order.json` to determine card priority
852
- - Checks admission criteria (Worker availability, conflict domains, etc.)
853
- - Moves eligible cards from Planning to Backlog
854
-
855
- **Example:**
856
-
857
- ```bash
858
- sps scheduler tick my-project
859
- sps scheduler tick my-project --dry-run
860
148
  ```
861
-
862
- ---
863
-
864
- ### sps pipeline tick
865
-
866
- Manually execute the execution chain: Backlog -> Todo -> Inprogress.
867
-
868
- ```bash
869
- sps pipeline tick <project> [--json] [--dry-run]
149
+ .claude/CLAUDE.md # worker rules (auto-installed)
150
+ .claude/skills/ # symlinked from ~/.coral/skills/
151
+ .claude/settings.local.json # Claude Code local config
152
+ wiki/ # if WIKI_ENABLED — see doc-28
153
+ ATTRIBUTION.md # if WIKI_ENABLED
870
154
  ```
871
155
 
872
- **Internal steps:**
873
-
874
- 1. **Check Inprogress cards** -- Detect Worker completion status. MR_MODE=none pushes directly to Done; MR_MODE=create confirms MR then pushes to Done
875
- 2. **Process Backlog cards** -- Create branch + create worktree + generate phase prompts -> push to Todo
876
- 3. **Process Todo cards** -- Assign Worker slot + build task context + launch Worker -> push to Inprogress
877
-
878
- Limited by `MAX_ACTIONS_PER_TICK` (default 1) to prevent launching too many Workers in a single tick cycle. There is a delay between multiple Worker launches (2 seconds in print mode, 10 seconds in interactive mode).
879
-
880
- When ResourceLimiter blocks a launch, SPS now logs the exact reason (`worker cap reached` vs `memory threshold reached`) together with `active/max` and `memory/current-threshold` diagnostics.
881
-
882
- If `MAX_CONCURRENT_WORKERS` is increased after a project was already running, SPS now auto-reconciles legacy `state.json` worker slots to the new configured count on the next read.
883
-
884
- Cards with `BLOCKED`, `NEEDS-FIX`, `CONFLICT`, `WAITING-CONFIRMATION`, or `STALE-RUNTIME` labels are skipped.
885
-
886
- **Example:**
156
+ ### Run
887
157
 
888
158
  ```bash
889
- sps pipeline tick my-project
890
- sps pipeline tick my-project --json
159
+ sps tick my-app # foreground tick loop
160
+ sps pipeline start my-app # alias
161
+ sps pipeline stop my-app # graceful stop (alias: sps stop my-app)
162
+ sps stop --all # stop all running ticks
163
+ sps status # all projects
891
164
  ```
892
165
 
893
- ---
894
-
895
- ### sps worker
896
-
897
- Worker lifecycle management.
898
-
899
- #### sps worker launch
166
+ ### Pipeline YAML
900
167
 
901
- Manually launch a single Worker.
168
+ `~/.coral/projects/<n>/pipelines/project.yaml` single source of truth for stages.
902
169
 
903
- ```bash
904
- sps worker launch <project> <seq> [--json] [--dry-run]
170
+ ```yaml
171
+ mode: project
172
+ git: true # false = non-code project, no git ops
173
+ stages:
174
+ - name: develop
175
+ profile: fullstack
176
+ on_complete: "move_card Review"
177
+ on_fail: { action: "label NEEDS-FIX", halt: true }
178
+ - name: review
179
+ profile: reviewer
180
+ on_complete: "move_card Done"
181
+ on_fail: { action: "label REVIEW-FAILED", halt: true }
905
182
  ```
906
183
 
907
- If the card is in Backlog state, it will automatically execute prepare first (create branch + worktree), then launch the Worker.
908
-
909
- **Launch process:**
910
-
911
- 1. Assign an available Worker slot
912
- 2. Write `.sps/task_prompt.txt` to the worktree
913
- 3. Launch Worker process
914
- 4. Push card to Inprogress
915
-
916
- **Worker transport (`WORKER_TRANSPORT=acp-sdk`, the only supported mode):**
917
-
918
- Workers communicate with Claude Code via structured ACP JSON-RPC protocol over stdio, using the `claude-agent-acp` shim. As of v0.38.0, Claude is the only supported CLI.
184
+ Critical rules:
185
+ 1. `mode: project` for state-machine pipelines; `mode: steps` for one-shot custom (use `sps pipeline run <name>`).
186
+ 2. Each stage's `on_complete` must point to the **next** stage's target state.
187
+ 3. Last stage's `on_complete: "move_card Done"`.
188
+ 4. Don't write `agent:` field — it's silently ignored (v0.38+ Claude is the only worker).
189
+ 5. `trigger` and `card_state` are auto-derived per stage.
919
190
 
920
- Key advantages:
921
- - **Structured communication** -- JSON-RPC protocol, no terminal screen-scraping
922
- - **Deterministic state detection** -- No regex parsing, no guessing
923
- - **Permission handling** -- Programmatic per-tool-call approval via `requestPermission` callback
924
- - **Real-time logs** -- ACP events stream to `*-acp-*.log` files
925
- - **No external dependencies** -- Pure process management, suitable for CI/CD environments
191
+ Field reference: see `~/.coral/projects/<n>/pipelines/sample.yaml.example` (auto-generated, comment-rich) or [doc-17](../../docs/design/17-pipeline-configuration-design.md).
926
192
 
927
- **Session Resume chain:**
193
+ ---
928
194
 
929
- Multiple tasks on the same worktree (initial implementation -> CI fix -> conflict resolution) share the same session:
195
+ ## Card lifecycle
930
196
 
931
197
  ```
932
- Task 1: claude -p "Implement feature" -> session_id_1 (stored in state.json)
933
- CI fix: claude -p "Fix CI" --resume sid -> Inherits full context from task 1
934
- Conflict: claude -p "Resolve conflict" --resume sid -> Inherits all historical context
198
+ Planning Backlog Todo Inprogress [QA / Review] → Done
199
+ fail
200
+ NEEDS-FIX (halt)
935
201
  ```
936
202
 
937
- **Example:**
203
+ Default states (configurable via YAML `pm.card_states`).
938
204
 
939
205
  ```bash
940
- sps worker launch my-project 24
941
- sps worker launch my-project 24 --dry-run
942
- ```
206
+ sps card add <p> "Title" "Description"
207
+ sps card add <p> "T" "D" --skills python,backend --labels feature
943
208
 
944
- #### sps worker dashboard
209
+ sps card dashboard <p> # CLI table
210
+ # console: /board?project=<n>
945
211
 
946
- Real-time dashboard for monitoring all Worker running states.
212
+ sps card mark-started <p> <seq> # called by Claude Code UserPromptSubmit hook
213
+ sps card mark-complete <p> <seq> # called by Claude Code Stop hook
947
214
 
948
- ```bash
949
- sps worker dashboard [project1] [project2] ... [--once] [--json]
215
+ sps reset <p> # reset all non-Done cards
216
+ sps reset <p> --card 5,6,7
217
+ sps reset <p> --all # full reset incl. Done + worktrees + branches
950
218
  ```
951
219
 
952
- | Option | Description |
953
- |--------|-------------|
954
- | (no arguments) | Auto-discovers all projects under `~/.coral/projects/` |
955
- | `--once` | Output a single snapshot then exit (no real-time mode) |
956
- | `--json` | Output in JSON format (all projects, all Worker slot states + output preview) |
957
-
958
- **Real-time mode:**
220
+ ### Card label vocabulary
959
221
 
960
- - Refreshes every 3 seconds by default (adjustable via `SPS_DASHBOARD_INTERVAL` environment variable)
961
- - Press `q` to quit, press `r` to force refresh
962
- - Uses alternate screen buffer (does not pollute terminal scrollback)
963
- - Adaptive grid layout, one panel per Worker
964
- - Proc mode panels show: PID, exit code, JSONL-rendered human-readable output
965
- - ACP SDK panels show: transport, session/run status, model, cwd, pending confirmation, and the latest structured summary line
966
-
967
- **Example:**
968
-
969
- ```bash
970
- # Monitor all projects
971
- sps worker dashboard
222
+ | Label | Meaning | Set by |
223
+ |---|---|---|
224
+ | `AI-PIPELINE` | Required to enter pipeline | User on creation |
225
+ | `STARTED-<stage>` | ACK signal Claude received the prompt | UserPromptSubmit hook |
226
+ | `COMPLETED-<stage>` | Worker finished a stage | Stop hook |
227
+ | `CLAIMED` | StageEngine reserved a worker slot | Engine |
228
+ | `NEEDS-FIX` | Worker failed; pipeline halted | Engine |
229
+ | `BLOCKED` | External dep; pipeline skips | User |
230
+ | `WAITING-CONFIRMATION` | Worker waiting on user input | Engine |
231
+ | `STALE-RUNTIME` | Inprogress > timeout | MonitorEngine |
232
+ | `ACK-TIMEOUT` | Claude never ACK'd within `WORKER_ACK_TIMEOUT_S` | MonitorEngine |
233
+ | `skill:<name>` | Force-load specific skill | User |
234
+ | `conflict:<domain>` | Serial-with-others-in-same-domain | User |
972
235
 
973
- # Monitor specific projects
974
- sps worker dashboard my-project
975
-
976
- # Single snapshot
977
- sps worker dashboard --once
978
-
979
- # JSON output (for script consumption)
980
- sps worker dashboard --json
981
-
982
- # Custom refresh interval
983
- SPS_DASHBOARD_INTERVAL=5000 sps worker dashboard
984
- ```
236
+ The active stage writes a per-slot marker file at `~/.coral/projects/<p>/runtime/worker-<slot>-current.json` (v0.50.21+). Stop hook reads it to detect which card the worker just finished.
985
237
 
986
238
  ---
987
239
 
988
- ### sps pm
240
+ ## Memory + Wiki
989
241
 
990
- PM backend operations.
242
+ Two complementary persistence systems, both auto-injected into worker prompts.
991
243
 
992
- #### sps pm scan
244
+ | | **Memory** | **Wiki** (v0.51+) |
245
+ |---|---|---|
246
+ | Path | `~/.coral/memory/{user,agents,projects/<p>}/` | `<repo>/wiki/` (per-project, in repo) |
247
+ | Format | Flat markdown + YAML frontmatter | 5 page types with zod-validated frontmatter |
248
+ | Cross-link | None (flat index) | `[[type/Title]]` wikilinks |
249
+ | Auto-inject | `knowledge` section of prompt | `wikiContext` section (5-layer retrieval) |
250
+ | Opt-in | Always on (toggle via `ENABLE_MEMORY=false`) | Per-project (`WIKI_ENABLED=true`) |
251
+ | Best for | Personal prefs, ad-hoc decisions, gotchas | Structured project knowledge: modules, concepts, decisions, lessons |
993
252
 
994
- View card list.
253
+ ### Memory CLI
995
254
 
996
255
  ```bash
997
- sps pm scan <project> [state]
998
- ```
999
-
1000
- Lists all cards when `state` is not specified.
256
+ sps memory list <p> # show project memory index
257
+ sps memory list # global view (user + agents)
258
+ sps memory context <p> --card <seq> # preview prompt injection
1001
259
 
1002
- **Example:**
1003
-
1004
- ```bash
1005
- # View all cards
1006
- sps pm scan my-project
1007
-
1008
- # Filter by state
1009
- sps pm scan my-project Inprogress
1010
- sps pm scan my-project Planning
1011
- ```
1012
-
1013
- #### sps pm move
1014
-
1015
- Manually move a card's state.
1016
-
1017
- ```bash
1018
- sps pm move <project> <seq> <state>
1019
- ```
1020
-
1021
- **Example:**
1022
-
1023
- ```bash
1024
- sps pm move my-project 24 QA
1025
- sps pm move my-project 25 Done
1026
- ```
1027
-
1028
- #### sps pm comment
1029
-
1030
- Add a comment to a card.
1031
-
1032
- ```bash
1033
- sps pm comment <project> <seq> "<text>"
260
+ sps memory add <p> --type convention --name "API uses camelCase" \
261
+ --description "REST endpoints use camelCase" --body "..."
1034
262
  ```
1035
263
 
1036
- **Example:**
1037
-
1038
- ```bash
1039
- sps pm comment my-project 24 "CI passed, awaiting review"
1040
- ```
264
+ Types: `convention` (no decay), `decision` (slow), `lesson` (30 days), `reference` (no decay).
1041
265
 
1042
- #### sps pm checklist
1043
-
1044
- Manage card checklists.
266
+ ### Wiki CLI (when `WIKI_ENABLED=true`)
1045
267
 
1046
268
  ```bash
1047
- # Create checklist
1048
- sps pm checklist create <project> <seq> "item1" "item2" "item3"
1049
-
1050
- # View checklist
1051
- sps pm checklist list <project> <seq>
1052
-
1053
- # Check/uncheck items
1054
- sps pm checklist check <project> <seq> <item-id>
1055
- sps pm checklist uncheck <project> <seq> <item-id>
269
+ sps wiki init <p> # scaffold wiki/ (auto on project init if toggled on)
270
+ sps wiki update <p> # show source diff
271
+ sps wiki update <p> --finalize # flush manifest after worker writes pages
272
+ sps wiki check <p> # lint: orphan / dead-link / fm-gap / stale
273
+ sps wiki list <p> --type lesson --tag pipeline
274
+ sps wiki get <p> lessons/Stop-Hook-Race
275
+ sps wiki status <p> # source ↔ manifest ↔ pages diff
276
+ sps wiki add <p> ~/notes.md --category transcripts
277
+ sps wiki read <p> "<query>" # preview the 5-layer retrieval
1056
278
  ```
1057
279
 
1058
- **Example:**
280
+ The 5-layer retrieval: hot.md / index summary / pinned / skill-tag / BM25F keyword. Type priority: lesson = 3, decision = 3, concept = 2, module = 1, source = 1. Token budget capped at ~2000.
1059
281
 
1060
- ```bash
1061
- sps pm checklist create my-project 24 "Unit tests" "Integration tests" "Code review"
1062
- sps pm checklist list my-project 24
1063
- sps pm checklist check my-project 24 item-001
1064
- ```
282
+ Worker SOP: [`skills/wiki-update/SKILL.md`](./skills/wiki-update/SKILL.md) (300 lines, single source of truth).
1065
283
 
1066
284
  ---
1067
285
 
1068
- ### sps qa tick
286
+ ## Skills
1069
287
 
1070
- QA close-out and worktree cleanup.
288
+ User-level skills live in `~/.coral/skills/` (28 bundled, copied from npm package on `sps setup`). Symlinked into `~/.claude/skills/` so Claude Code auto-loads them.
1071
289
 
1072
290
  ```bash
1073
- sps qa tick <project> [--json]
291
+ sps skill list # what's available + project status
292
+ sps skill add <name> --project <p> # symlink into <repo>/.claude/skills/
293
+ sps skill remove <name> --project <p>
294
+ sps skill freeze <name> --project <p> # symlink → real copy (allow project edits)
295
+ sps skill unfreeze <name> --project <p> # back to symlink
296
+ sps skill sync # ① bundled (npm pkg) → ~/.coral/skills/
297
+ # ② ~/.coral/skills/ → ~/.claude/skills/
298
+ sps skill sync --force # ⭐ overwrite existing user skills (after sps-cli upgrade)
1074
299
  ```
1075
300
 
1076
- **When MR_MODE=none:** QA is the integration phase. The QA worker must inspect the task worktree, continue merge/rebase work, resolve conflicts, and drive the branch back into the target branch. `qa tick` launches or resumes that integration worker and only moves the card to `Done` after merge evidence is observed.
1077
-
1078
- **When MR_MODE=create:** QA remains a compatibility path while MR flow is still being converged on the same worker-owned model.
301
+ Bundled skills (v0.51.3):
1079
302
 
1080
- **Automatic worktree cleanup:**
1081
-
1082
- After each qa tick cycle, items in the `state.worktreeCleanup` queue are automatically processed:
1083
-
1084
- 1. `git worktree remove --force <path>` -- Remove worktree directory
1085
- 2. `git branch -d <branch>` -- Delete merged local branch
1086
- 3. `git worktree prune` -- Clean up residual references
1087
-
1088
- Failed cleanup entries remain in the queue and are automatically retried in the next tick cycle.
1089
-
1090
- **Example:**
1091
-
1092
- ```bash
1093
- sps qa tick my-project
1094
- sps qa tick my-project --json
1095
- ```
303
+ - **Dev (23)**: `frontend`, `frontend-developer`, `backend`, `backend-architect`, `typescript`, `golang`, `rust`, `python`, `java`, `kotlin`, `swift`, `mobile`, `database`, `database-optimizer`, `qa-tester`, `security-engineer`, `architecture-decision-records`, `coding-standards`, `debugging-workflow`, `devops`, `devops-automator`, `git-workflow`, `code-reviewer`
304
+ - **Worker profiles (3)**: `dev-worker`, `tax-worker`, `reviewer` (referenced via `--profile`)
305
+ - **SPS-specific (5)**: `sps-pipeline`, `sps-memory`, `wiki-update`
1096
306
 
1097
307
  ---
1098
308
 
1099
- ### sps monitor tick
1100
-
1101
- Manually execute anomaly detection and health inspection.
1102
-
1103
- ```bash
1104
- sps monitor tick <project> [--json]
1105
- ```
1106
-
1107
- **Inspection items:**
1108
-
1109
- | Check | Description |
1110
- |-------|-------------|
1111
- | Orphan slot cleanup | Worker process is dead but slot is still marked active |
1112
- | Timeout detection | Inprogress exceeds `INPROGRESS_TIMEOUT_HOURS` |
1113
- | State alignment | Whether PM state and runtime state are consistent |
1114
-
1115
- **Example:**
309
+ ## Command reference
1116
310
 
1117
311
  ```bash
1118
- sps monitor tick my-project
1119
- sps monitor tick my-project --json
1120
- ```
312
+ # Setup & projects
313
+ sps setup [--force]
314
+ sps project init <name>
315
+ sps project doctor <name> [--fix] [--json] [--reset-state] [--skip-remote]
316
+ sps doctor <name> --fix # alias
317
+
318
+ # Pipeline
319
+ sps tick <project> [--json]
320
+ sps pipeline start|stop|status|reset|workers|board|card|logs|list|run|use [project] [args]
321
+ sps pipeline run <name> "<prompt>" # for mode: steps pipelines
322
+ sps pipeline tick <project> # one-off StageEngine pass
323
+ sps scheduler tick <project> # Planning → Backlog promotion
324
+ sps qa tick <project> # QA → Done finalization
325
+ sps monitor tick <project> # health probe (ACK timeout, stale)
326
+ sps pm scan <project> # rebuild card index from disk
327
+
328
+ # Cards
329
+ sps card add <p> "title" ["description"] [--skills a,b] [--labels x,y]
330
+ sps card dashboard <p>
331
+ sps card mark-started <p> [seq] [--stage <name>]
332
+ sps card mark-complete <p> <seq> [--stage <name>]
333
+
334
+ # Worker
335
+ sps worker ps <project>
336
+ sps worker dashboard <project>
337
+ sps worker kill <project> <seq>
338
+ sps worker launch <project> <seq>
339
+
340
+ # Status / logs
341
+ sps status [--json]
342
+ sps stop <project> [--all]
343
+ sps reset <project> [--all] [--card N,N,N]
344
+ sps logs [project] [--err] [--lines N] [--no-follow]
345
+
346
+ # Memory
347
+ sps memory list [project] [--agent <id>]
348
+ sps memory context <project> [--card <seq>] [--agent <id>]
349
+ sps memory add <project> --type <T> --name "title" [--body "content"]
350
+
351
+ # Wiki (v0.51+)
352
+ sps wiki init <p>
353
+ sps wiki update <p> [--finalize] [--json]
354
+ sps wiki read <p> "<query>" [--skills a,b] [--pinned id1,id2] [--budget N]
355
+ sps wiki check <p> [--json] [--fix]
356
+ sps wiki add <p> <file> [--category <name>] [--no-ingest]
357
+ sps wiki list <p> [--type T] [--tag T] [--json]
358
+ sps wiki get <p> <pageId> [--json]
359
+ sps wiki status <p> [--json]
360
+
361
+ # Skill
362
+ sps skill list [--project <p>]
363
+ sps skill add <name> [--project <p>]
364
+ sps skill remove <name> [--project <p>]
365
+ sps skill freeze <name> [--project <p>]
366
+ sps skill unfreeze <name> [--project <p>]
367
+ sps skill sync [--force]
368
+
369
+ # Console
370
+ sps console [--port N] [--host H] [--no-open] [--dev] [--kill]
371
+
372
+ # Agent
373
+ sps agent "<prompt>" [--profile <p>] [--system "..."] [--context file] [--output file] [--verbose]
374
+ sps agent --chat [--name <session>]
375
+ sps agent status|close|list|add [args]
376
+ sps agent daemon start|stop|status
377
+
378
+ # Hooks (called by Claude Code, not by users)
379
+ sps hook stop
380
+ sps hook user-prompt-submit
381
+
382
+ # ACP control (for advanced debugging)
383
+ sps acp <ensure|run|prompt|status|stop|pending|respond> <project> [args]
384
+ ```
385
+
386
+ Add `--help` after any command to see its specific usage. Add `--json` for structured output where supported.
1121
387
 
1122
388
  ---
1123
389
 
1124
- ### sps stop
1125
-
1126
- Stop running tick process(es).
1127
-
1128
- ```bash
1129
- sps stop <project> # stop specific project
1130
- sps stop --all # stop all running ticks
1131
- ```
390
+ ## Project config (conf)
391
+
392
+ Live at `~/.coral/projects/<name>/conf` (shell `export VAR="value"` syntax, mode 600). Full field reference (with comments) auto-generated at `~/.coral/projects/<name>/conf.example`.
393
+
394
+ | Field | Default | Notes |
395
+ |---|---|---|
396
+ | `PROJECT_NAME` | (required) | Internal id |
397
+ | `PROJECT_DIR` | (required) | Absolute path to repo |
398
+ | `GITLAB_PROJECT` | — | `user/repo` (optional, for GitLab API) |
399
+ | `GITLAB_PROJECT_ID` | — | Numeric ID (GitLab only; auto-resolved from path on first MR) |
400
+ | `GITLAB_MERGE_BRANCH` | `main` | Worker pushes here |
401
+ | `PM_TOOL` | `markdown` | **Only `markdown` supported as of v0.42**. Cards live in `~/.coral/projects/<n>/cards/<state>/<seq>.md` |
402
+ | `PIPELINE_LABEL` | `AI-PIPELINE` | Required label on cards to enter pipeline |
403
+ | `MR_MODE` | `none` | `none` (push direct) / `create` (open MR; needs `GITLAB_PROJECT_ID`) |
404
+ | `WORKER_TRANSPORT` | `acp-sdk` | Fixed; do not change |
405
+ | `MAX_CONCURRENT_WORKERS` | `1` | Slot count; cards still serial within a project |
406
+ | `MAX_ACTIONS_PER_TICK` | `3` | New tasks claimable per tick |
407
+ | `INPROGRESS_TIMEOUT_HOURS` | `2` | After this, MonitorEngine flags STALE-RUNTIME |
408
+ | `WORKER_ACK_TIMEOUT_S` | `300` | Wait for STARTED-<stage> label after dispatch (5min, raised in v0.50.24) |
409
+ | `WORKER_ACK_MAX_RETRIES` | `1` | ACK timeout retry count |
410
+ | `MONITOR_AUTO_QA` | `true` | Auto-advance to QA on stale runtime |
411
+ | `CONFLICT_DEFAULT` | `serial` | Fallback for cards without `conflict:` label |
412
+ | `MATRIX_ROOM_ID` | — | Project-level Matrix override |
413
+ | `WORKTREE_DIR` | `~/.coral/worktrees/<p>` | Worker scratch space |
414
+ | `DEFAULT_WORKER_SKILLS` | — | Comma-separated; fallback when no `profile:` and no `card.skills` |
415
+ | `ENABLE_MEMORY` | `true` | `false` skips memory write instructions in prompt |
416
+ | **`WIKI_ENABLED`** | unset (off) | **v0.51+**: `true` enables wiki context injection + reminder |
417
+ | `COMPLETION_SIGNAL` | `done` | Word the Stop hook listens for |
418
+
419
+ Global credentials at `~/.coral/env`: `GITLAB_URL`, `GITLAB_TOKEN`, `GITLAB_SSH_HOST`, `GITLAB_SSH_PORT`, `MATRIX_HOMESERVER`, `MATRIX_ACCESS_TOKEN`, `MATRIX_ROOM_ID`. Set via `sps setup` or `vim`.
1132
420
 
1133
421
  ---
1134
422
 
1135
- ### sps reset
1136
-
1137
- Reset cards for re-execution. Performs 5 atomic steps: stop tick, clean state, remove worktrees + branches, move cards to Planning, report.
1138
-
1139
- ```bash
1140
- sps reset <project> # reset all non-Done cards
1141
- sps reset <project> --all # reset ALL cards including Done
1142
- sps reset <project> --card 5 # reset specific card
1143
- sps reset <project> --card 5,6,7 # reset multiple cards
1144
- ```
1145
-
1146
- Typical workflow after version upgrade:
1147
-
1148
- ```bash
1149
- npm i -g @coralai/sps-cli # upgrade
1150
- sps reset my-project # clean reset
1151
- sps tick my-project # re-run
423
+ ## Project layout
424
+
425
+ ```
426
+ ~/.coral/ # User-global state
427
+ ├── env # Global credentials (mode 600)
428
+ ├── skills/ # User-level skills (synced from npm)
429
+ ├── memory/{user,agents,projects}/ # 3-layer memory store
430
+ ├── projects/<name>/ # Per-project state
431
+ │ ├── conf # Project config (mode 600)
432
+ │ ├── conf.example # Field reference (auto-generated)
433
+ │ ├── pipelines/{project,*}.yaml # Pipeline definitions
434
+ │ ├── pipeline_order.json # Active pipeline pointer
435
+ │ ├── runtime/state.json # Worker slot + active card state
436
+ │ ├── runtime/worker-<slot>-current.json # Per-slot card marker (v0.50.21+)
437
+ │ ├── runtime/tick.lock # Tick lock
438
+ │ ├── runtime/acp-state.json # ACP session state
439
+ │ ├── cards/<state>/<seq>.md # Card files (markdown PM backend)
440
+ │ ├── cards/seq.txt # Sequence counter
441
+ │ ├── logs/ # Per-tick logs
442
+ │ └── pm_meta/ # Card index
443
+ ├── sessions/ # Agent daemon (chat sessions)
444
+ │ ├── daemon.sock daemon.pid
445
+ │ └── chat-sessions/<id>.json # Persisted chat sessions
446
+ ├── console.lock # Single-instance guard for console
447
+ └── worktrees/<project>/<seq>/ # Worker worktree per active card
448
+ ```
449
+
450
+ In the target repo (PROJECT_DIR):
451
+
452
+ ```
453
+ .claude/
454
+ ├── CLAUDE.md # Worker rules (project-specific + SPS-injected)
455
+ ├── settings.local.json # Claude Code local config
456
+ ├── skills/ # Symlinked from ~/.coral/skills/
457
+ └── hooks/{start,stop}.sh # Lifecycle hooks (call into sps)
458
+ wiki/ # If WIKI_ENABLED — see docs/design/28-wiki-system.md
459
+ ATTRIBUTION.md # If WIKI_ENABLED
1152
460
  ```
1153
461
 
1154
462
  ---
1155
463
 
1156
- ### sps logs
464
+ ## Architecture
1157
465
 
1158
- Real-time log viewer.
466
+ 4-layer service architecture (v0.50+):
1159
467
 
1160
- ```bash
1161
- sps logs [project] # follow pipeline log
1162
- sps logs <project> --err # follow error log
1163
- sps logs <project> --lines 50 # show last 50 lines
1164
- sps logs <project> --no-follow # print and exit
1165
468
  ```
1166
-
1167
- ---
1168
-
1169
- ## Worker Rule Files
1170
-
1171
- `sps doctor --fix` generates rule files for the Claude Code worker:
1172
-
1173
- | File | Purpose | Committed to git |
1174
- |------|---------|-----------------|
1175
- | `CLAUDE.md` | Project rules for Claude Code Worker | Yes |
1176
- | `.sps/development_prompt.txt` | Development-phase prompt (debug archive) | No (.gitignore) |
1177
- | `.sps/integration_prompt.txt` | Integration-phase prompt (debug archive) | No (.gitignore) |
1178
- | `docs/DECISIONS.md` | Architecture decisions (worker auto-maintained) | Yes |
1179
- | `docs/CHANGELOG.md` | Change log (worker auto-maintained) | Yes |
1180
-
1181
- **Note**: Prompts are generated in-memory and passed via stdin (v0.25.0+). The `.sps/` files are debug archives only — their absence does not block the pipeline.
1182
-
1183
- **Skill Profile injection (v0.16+):**
1184
-
1185
- | File | Purpose |
1186
- |------|---------|
1187
- | `~/.coral/profiles/<name>.md` | Loaded into Worker prompt via `skill:<name>` label |
1188
-
1189
- Prompt assembly order: Skill Profile -> CLAUDE.md/AGENTS.md -> DECISIONS.md/CHANGELOG.md -> Task description
1190
-
1191
- ### How It Works
1192
-
1193
- 1. `CLAUDE.md` and `AGENTS.md` are committed to the repository's main branch
1194
- 2. When creating a git worktree, these files are automatically inherited
1195
- 3. On startup, the Worker reads CLAUDE.md to understand project rules (auto-discovered in interactive mode; auto-loaded from cwd in print mode)
1196
- 4. Task-specific information is written into `.sps/development_prompt.txt` and `.sps/integration_prompt.txt` inside each worktree; `.sps/task_prompt.txt` remains as a development-phase compatibility alias
1197
- 5. Development workers use the development prompt and stop at a committed task branch; QA workers use the integration prompt and complete merge/conflict work
1198
-
1199
- ### Project Knowledge Base
1200
-
1201
- Each Worker is instructed in the task prompt to:
1202
-
1203
- - **Before starting**: Read `docs/DECISIONS.md` and `docs/CHANGELOG.md` to understand decisions and changes from preceding tasks
1204
- - **After completion**: Append their architecture decisions to `docs/DECISIONS.md` and change summaries to `docs/CHANGELOG.md`
1205
-
1206
- These files are merged with the code into the target branch. The next Worker inherits them when creating a worktree, enabling cross-task knowledge transfer.
1207
-
1208
- ### Customizing Project Rules
1209
-
1210
- The generated CLAUDE.md includes a "Project-Specific Rules" placeholder section where you can add:
1211
-
1212
- ```markdown
1213
- ## Project-Specific Rules
1214
- - Language: TypeScript strict mode
1215
- - Test framework: vitest, coverage 80%+
1216
- - Architecture: src/modules/<domain>/ directory structure
1217
- - Linting: eslint + prettier, must pass before commit
469
+ Delivery (commands/, console/routes/) Thin parameter parsing + I/O orchestration
470
+
471
+ Service (services/) ProjectService / ChatService / PipelineService /
472
+ SkillService / WikiService — Result<T> + DomainEvent
473
+
474
+ Domain (engines/) SchedulerEngine / StageEngine / MonitorEngine /
475
+ CloseoutEngine / EventHandler — pipeline logic
476
+
477
+ Infrastructure WorkerManager (single worker), ACPWorkerRuntime,
478
+ (manager/, providers/, daemon/) sessionDaemon, TaskBackend, RepoBackend
1218
479
  ```
1219
480
 
1220
- SPS will not overwrite existing CLAUDE.md / AGENTS.md files.
1221
-
1222
- ---
1223
-
1224
- ## Project Configuration
1225
-
1226
- Configuration is split into two layers:
1227
-
1228
- | File | Scope | Description |
1229
- |------|-------|-------------|
1230
- | `~/.coral/env` | Global | Credentials shared across all projects (GitLab token, PM API key, etc.) |
1231
- | `~/.coral/projects/<project>/conf` | Project | Project-specific configuration (repository, branch, Worker parameters, etc.) |
481
+ Engines:
1232
482
 
1233
- Project conf can reference global variables (e.g., `${PLANE_URL}`).
483
+ - **SchedulerEngine** promotes Planning Backlog when `AI-PIPELINE` label present.
484
+ - **StageEngine** — drives card through stages; builds prompt (skill + projectRules + memory + **wikiContext** + task description + **wikiUpdateReminder**); kicks worker via ACP.
485
+ - **MonitorEngine** — ACK timeout detection, stale runtime, auto-QA promotion.
486
+ - **CloseoutEngine** + **EventHandler** — finalize completed cards.
1234
487
 
1235
- ### Configuration Field Reference
488
+ **Single-worker is intentional**: v0.37.2 deleted multi-worker concurrency code. Don't propose "add a parallel mode" — the architecture relies on serial execution for state coherence. For higher throughput, run multiple projects in parallel.
1236
489
 
1237
- #### Project Basics
1238
-
1239
- | Field | Required | Default | Description |
1240
- |-------|----------|---------|-------------|
1241
- | `PROJECT_NAME` | Yes | -- | Project name |
1242
- | `PROJECT_DIR` | No | `~/projects/<project>` | Project repository path |
1243
-
1244
- #### GitLab
1245
-
1246
- | Field | Required | Default | Description |
1247
- |-------|----------|---------|-------------|
1248
- | `GITLAB_PROJECT` | Yes | -- | GitLab project path (e.g., `group/repo`) |
1249
- | `GITLAB_PROJECT_ID` | Yes | -- | GitLab project numeric ID |
1250
- | `GITLAB_MERGE_BRANCH` | Yes | `develop` | MR target branch |
1251
-
1252
- #### PM Backend
1253
-
1254
- | Field | Required | Default | Description |
1255
- |-------|----------|---------|-------------|
1256
- | `PM_TOOL` | No | `trello` | PM backend type: `plane` / `trello` / `markdown` |
1257
- | `PIPELINE_LABEL` | No | `AI-PIPELINE` | Pipeline card label |
1258
- | `MR_MODE` | No | `none` | Merge mode: `none` (worker-owned QA integration back to target branch) / `create` (create MR, review flow under development) |
1259
-
1260
- #### Worker
1261
-
1262
- Claude is the only supported CLI as of v0.38.0; there is no per-project agent selector.
1263
-
1264
- | Field | Required | Default | Description |
1265
- |-------|----------|---------|-------------|
1266
- | `WORKER_TRANSPORT` | No | `acp-sdk` | Worker transport (only `acp-sdk` is supported) |
1267
- | `MAX_CONCURRENT_WORKERS` | No | `3` | Maximum parallel Workers (worker slot ceiling) |
1268
- | `WORKER_RESTART_LIMIT` | No | `2` | Maximum restart count after Worker death |
1269
- | `MAX_ACTIONS_PER_TICK` | No | `1` | Maximum launches per tick cycle; raise with `MAX_CONCURRENT_WORKERS` if one tick should fill all slots |
1270
-
1271
- #### Timeouts and Policies
1272
-
1273
- | Field | Required | Default | Description |
1274
- |-------|----------|---------|-------------|
1275
- | `INPROGRESS_TIMEOUT_HOURS` | No | `8` | Inprogress timeout in hours |
1276
- | `MONITOR_AUTO_QA` | No | `false` | Whether Monitor auto-pushes completed cards to QA |
1277
- | `CONFLICT_DEFAULT` | No | `serial` | Default conflict domain strategy: `serial` / `parallel` |
1278
- | `TICK_LOCK_TIMEOUT_MINUTES` | No | `30` | Tick lock timeout in minutes |
1279
-
1280
- #### Paths
1281
-
1282
- | Field | Required | Default | Description |
1283
- |-------|----------|---------|-------------|
1284
- | `WORKTREE_DIR` | No | `~/.coral/worktrees/` | Worktree root directory |
1285
-
1286
- ### Configuration Example
1287
-
1288
- ```bash
1289
- # ~/.coral/projects/my-project/conf
1290
-
1291
- PROJECT_NAME="my-project"
1292
- PROJECT_DIR="/home/user/projects/my-project"
1293
-
1294
- # GitLab
1295
- GITLAB_PROJECT="team/my-project"
1296
- GITLAB_PROJECT_ID="42"
1297
- GITLAB_MERGE_BRANCH="develop"
1298
-
1299
- # PM (uses variables from global ~/.coral/env)
1300
- PM_TOOL="plane"
1301
- PLANE_API_URL="${PLANE_URL}"
1302
- PLANE_PROJECT_ID="project-uuid-here"
1303
-
1304
- # Worker (claude is the only supported CLI — no selector)
1305
- MAX_CONCURRENT_WORKERS=3
1306
- MAX_ACTIONS_PER_TICK=1
1307
-
1308
- # Merge mode
1309
- MR_MODE="none" # none (worker-owned QA integration) or create (create MR)
1310
- ```
490
+ For deep dives:
491
+ - [doc-27: Service Layer Architecture](../../docs/design/27-service-layer-architecture.md) — current architecture
492
+ - [doc-26: Console Architecture](../../docs/design/26-console-architecture.md) console internals
493
+ - [doc-28: Wiki System](../../docs/design/28-wiki-system.md) — wiki design
494
+ - [doc-13: Development Guardrails](../../docs/design/13-development-guardrails.md) hard rules for contributors
495
+ - [doc-17: Pipeline Configuration](../../docs/design/17-pipeline-configuration-design.md) YAML field semantics
496
+ - [docs/design/](../../docs/design/) — full design tree (most v0.15-v0.32 docs are marked HISTORICAL)
1311
497
 
1312
498
  ---
1313
499
 
1314
- ## Multi-Project Parallel Execution
1315
-
1316
- SPS supports managing multiple projects simultaneously in a single process:
500
+ ## Troubleshooting
1317
501
 
1318
502
  ```bash
1319
- sps tick project-a project-b project-c
1320
- ```
1321
-
1322
- Each project is fully isolated:
1323
- - Independent ProjectContext, Provider instances, Engine instances
1324
- - Independent tick.lock (non-blocking between projects)
1325
- - Independent state.json (Worker slots are not mixed)
1326
- - Errors in one project do not affect others
503
+ sps doctor <project> --fix # ★ first thing to try
504
+ sps logs <project> --err # stderr / errors only
505
+ sps reset <project> --card <seq> # nuke a stuck card
506
+ sps reset <project> --all # full project reset
1327
507
 
1328
- Multi-Worker parallel configuration:
508
+ # Worker / daemon issues
509
+ sps worker ps <project>
510
+ sps agent daemon status # is the chat daemon up?
511
+ sps agent daemon stop && sps agent daemon start # restart (clears stale cwd)
1329
512
 
1330
- ```bash
1331
- # Set in project conf
1332
- MAX_CONCURRENT_WORKERS=3
1333
- CONFLICT_DEFAULT=parallel
513
+ # Wiki issues
514
+ sps wiki check <project>
515
+ sps wiki status <project>
1334
516
  ```
1335
517
 
1336
- ---
1337
-
1338
- ## Architecture Overview
518
+ Common issues:
1339
519
 
1340
- ### Four-Layer Architecture
1341
-
1342
- ```
1343
- Layer 3 Commands + Engines CLI commands + state machine engines
1344
- Layer 2 Providers Concrete backend implementations
1345
- Layer 1 Interfaces Abstract interfaces
1346
- Layer 0 Core Runtime Configuration, paths, state, locks, logging
1347
- ```
1348
-
1349
- ### Supported Backends
1350
-
1351
- | Type | Provider | Interface |
1352
- |------|----------|-----------|
1353
- | PM Backend | Plane CE / Trello / Markdown | TaskBackend |
1354
- | Code Hosting | GitLab | RepoBackend |
1355
- | AI Worker (print) | ClaudePrintProvider / CodexExecProvider | WorkerProvider |
1356
- | AI Worker (interactive) | ClaudeTmuxProvider / CodexTmuxProvider | WorkerProvider |
1357
- | Notifications | Matrix | Notifier |
1358
-
1359
- ### Engines
1360
-
1361
- | Engine | Responsibility |
1362
- |--------|---------------|
1363
- | SchedulerEngine | Planning -> Backlog (card selection, sorting, admission checks) |
1364
- | ExecutionEngine | Backlog -> Todo -> Inprogress (prepare environment, launch development Worker, detect completion handoff to QA) |
1365
- | CloseoutEngine | Worktree cleanup (legacy QA card handling when MR_MODE=create) |
1366
- | MonitorEngine | Anomaly detection (orphan cleanup, timeouts, blocks, state alignment, dead Worker completion detection) |
1367
-
1368
- ---
1369
-
1370
- ## Directory Structure
1371
-
1372
- ```
1373
- workflow-cli/
1374
- ├── src/
1375
- │ ├── main.ts # CLI entry point, command routing
1376
- │ ├── commands/ # Command implementations
1377
- │ │ ├── setup.ts # sps setup
1378
- │ │ ├── projectInit.ts # sps project init
1379
- │ │ ├── doctor.ts # sps doctor
1380
- │ │ ├── cardAdd.ts # sps card add
1381
- │ │ ├── tick.ts # sps tick
1382
- │ │ ├── schedulerTick.ts # sps scheduler tick
1383
- │ │ ├── pipelineTick.ts # sps pipeline tick
1384
- │ │ ├── workerLaunch.ts # sps worker launch
1385
- │ │ ├── workerDashboard.ts # sps worker dashboard
1386
- │ │ ├── pmCommand.ts # sps pm *
1387
- │ │ ├── qaTick.ts # sps qa tick
1388
- │ │ └── monitorTick.ts # sps monitor tick
1389
- │ ├── core/ # Core runtime
1390
- │ │ ├── config.ts # Configuration loading (shell conf parsing)
1391
- │ │ ├── context.ts # ProjectContext
1392
- │ │ ├── paths.ts # Path resolution
1393
- │ │ ├── state.ts # Runtime state (state.json)
1394
- │ │ ├── lock.ts # Tick lock
1395
- │ │ ├── logger.ts # Logging + structured events
1396
- │ │ └── queue.ts # Pipeline queue
1397
- │ ├── engines/ # State machine engines
1398
- │ │ ├── SchedulerEngine.ts # Card selection and queuing
1399
- │ │ ├── ExecutionEngine.ts # Execution chain
1400
- │ │ ├── CloseoutEngine.ts # QA close-out
1401
- │ │ └── MonitorEngine.ts # Anomaly detection
1402
- │ ├── manager/ # Worker process management module (v0.16.0)
1403
- │ │ ├── supervisor.ts # fd-redirected spawn, child handle, exit callbacks
1404
- │ │ ├── completion-judge.ts # git output checks, marker/keyword detection
1405
- │ │ ├── post-actions.ts # merge + PM update + slot release + notify
1406
- │ │ ├── pm-client.ts # Lightweight PM operations (Plane/Trello/Markdown)
1407
- │ │ ├── resource-limiter.ts # Global worker count cap + memory checks
1408
- │ │ └── recovery.ts # Post-restart PID scan recovery
1409
- │ ├── interfaces/ # Abstract interfaces
1410
- │ │ ├── TaskBackend.ts # PM backend interface
1411
- │ │ ├── RepoBackend.ts # Code repository interface
1412
- │ │ ├── Notifier.ts # Notification interface
1413
- │ │ └── HookProvider.ts # Hook interface
1414
- │ ├── models/ # Type definitions
1415
- │ │ └── types.ts # Card, CommandResult, WorkerStatus, etc.
1416
- │ └── providers/ # Concrete implementations
1417
- │ ├── registry.ts # Provider factory
1418
- │ ├── PlaneTaskBackend.ts
1419
- │ ├── TrelloTaskBackend.ts
1420
- │ ├── MarkdownTaskBackend.ts
1421
- │ ├── adapters/ # ACP SDK adapters
1422
- │ │ └── AcpSdkAdapter.ts # Unified ACP adapter (JSON-RPC over stdio)
1423
- │ ├── outputParser.ts # JSONL output parsing, process management utilities
1424
- │ ├── streamRenderer.ts # JSONL -> human-readable text (for Dashboard)
1425
- │ ├── GitLabRepoBackend.ts
1426
- │ └── MatrixNotifier.ts
1427
- ├── package.json
1428
- └── tsconfig.json
1429
- ```
520
+ | Symptom | Cause / fix |
521
+ |---|---|
522
+ | Pipeline halted with `NEEDS-FIX` | Open the failed card, fix the issue, remove the label. Console makes this 2 clicks. |
523
+ | Worker not starting | `sps worker ps`, then `sps logs --err`. Often Claude API key missing or `claude-agent-acp` adapter not installed (`sps setup` reinstalls). |
524
+ | Cards stuck in Planning | Need `AI-PIPELINE` label. `sps card add` applies it automatically; if added externally, add manually. |
525
+ | ACK timeout on every card | Claude cold-start is slow with many skill / memory files. Raise `WORKER_ACK_TIMEOUT_S` (default 300s as of v0.50.24). |
526
+ | Console shows stale data | SSE may have dropped; reload page; if persistent, `sps console --kill && sps console`. |
527
+ | Wiki context not injecting | Verify `WIKI_ENABLED=true` in conf and `wiki/WIKI.md` exists. StageEngine logs a warning if conf says yes but scaffold is missing. |
528
+ | New skill SOP not pulling after upgrade | `sps skill sync --force` (default sync skips existing skills). |
529
+ | Daemon chat using wrong cwd | Daemon captures cwd at startup. `sps agent daemon stop && cd <repo> && sps agent daemon start`. |
1430
530
 
1431
531
  ---
1432
532
 
1433
- ## Manager Module (v0.16.0)
533
+ ## License & attribution
1434
534
 
1435
- v0.16.0 introduced the `src/manager/` directory, decoupling Worker process management from Engines into independent modules that run as internal tick modules (not standalone daemons).
1436
-
1437
- | Module | Lines | Responsibility |
1438
- |--------|-------|---------------|
1439
- | `supervisor.ts` | 288 | fd-redirected spawn (OS-level guaranteed output writing), holds child handle, exit callback triggers post-processing, three-layer env var merging (system -> global credentials -> project config) |
1440
- | `completion-judge.ts` | 110 | phase-aware git evidence checks (branch commits vs merged target), marker file detection, completion keyword fallback |
1441
- | `post-actions.ts` | 412 | Complete post-Worker-exit chain: merge -> PM state update -> slot release -> notify |
1442
- | `pm-client.ts` | 294 | Lightweight PM operation wrapper, supports Plane/Trello/Markdown backends |
1443
- | `resource-limiter.ts` | 103 | Global worker count cap check + memory check + launch interval control |
1444
- | `recovery.ts` | 205 | Post-tick-restart PID scan to recover orphan worker processes |
1445
-
1446
- **Refactoring results:**
1447
- - ExecutionEngine reduced from 1219 to 916 lines (removed attemptResume, completeAndRelease)
1448
- - MonitorEngine reduced from 974 to 750 lines (removed direct PID detection)
1449
- - tick.ts added ~80 lines (initialize shared Manager modules, run Recovery on startup)
1450
-
1451
- ---
1452
-
1453
- ## Label-Driven Skill Injection (v0.16.0)
1454
-
1455
- Worker expertise is injected via PM card labels, allowing customization of Worker behavior for different tasks without code changes.
1456
-
1457
- **Mechanism:**
1458
- - Adding a `skill:xxx` label to a PM card -> automatically loads `~/.coral/profiles/xxx.md` into the Worker prompt
1459
- - Multiple `skill:` labels can be stacked for combined injection
1460
- - Projects can configure default skills via `DEFAULT_WORKER_SKILLS`; card labels override project defaults
1461
-
1462
- **Prompt assembly order:**
1463
- 1. Skill Profiles (skill templates)
1464
- 2. Project Rules (CLAUDE.md / AGENTS.md)
1465
- 3. Project Knowledge (docs/DECISIONS.md, docs/CHANGELOG.md)
1466
- 4. Task (.sps/task_prompt.txt)
1467
-
1468
- **Built-in skill templates:**
1469
-
1470
- | File | Purpose |
1471
- |------|---------|
1472
- | `~/.coral/profiles/_template.md` | Template for creating new skills |
1473
- | `~/.coral/profiles/typescript.md` | TypeScript project coding standards |
1474
- | `~/.coral/profiles/phaser.md` | Phaser game framework development guide |
1475
-
1476
- **Adding new skills requires zero code:** Simply create an md file in `~/.coral/profiles/` directory, then add the corresponding `skill:xxx` label to the PM card.
1477
-
1478
- ---
535
+ MIT, see [`LICENSE`](../../LICENSE).
1479
536
 
1480
- ## License
537
+ The Wiki system (v0.51+) borrows ~70% from [claude-obsidian](https://github.com/kepano/claude-obsidian) (MIT) — three-layer architecture, manifest delta tracking, hot cache, ingest workflow, contradiction callouts, wikilinks. SPS-specific 30%: 5 page types, `sources={card,commit,path}`, 5-layer reader, `sps wiki check` exit gate. Mental model from Karpathy's "LLM Wiki" gist.
1481
538
 
1482
- MIT
539
+ Full attribution: [`ATTRIBUTION.md`](./ATTRIBUTION.md).