specrails 0.2.0 → 0.2.1
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/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.1
|
package/package.json
CHANGED
|
@@ -65,6 +65,28 @@ Print a setup report:
|
|
|
65
65
|
|
|
66
66
|
**Pass `TEST_CMD` (or equivalent) and `BACKLOG_AVAILABLE` forward** — all later phases must use these.
|
|
67
67
|
|
|
68
|
+
#### 5. Web Manager (Pipeline Monitor)
|
|
69
|
+
|
|
70
|
+
Check if the web manager is running:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
curl -sf http://127.0.0.1:4200/api/state >/dev/null 2>&1
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
- If reachable: set `WEB_MANAGER=true`. Print: `| Pipeline Monitor | ok | http://127.0.0.1:4200 |`
|
|
77
|
+
- If not reachable: set `WEB_MANAGER=false`. Print: `| Pipeline Monitor | off | start with: cd .claude/web-manager && npm run dev |`
|
|
78
|
+
|
|
79
|
+
**Web Manager notification helper:** Throughout this pipeline, use the following pattern to notify the web manager of phase transitions. Always fire-and-forget — never let a notification failure block the pipeline.
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Only execute if WEB_MANAGER=true
|
|
83
|
+
curl -sf -X POST http://127.0.0.1:4200/hooks/events \
|
|
84
|
+
-H 'Content-Type: application/json' \
|
|
85
|
+
-d '{"event":"<EVENT>","agent":"<PHASE>"}' >/dev/null 2>&1 || true
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Where `<EVENT>` is one of `agent_start`, `agent_stop`, `agent_error` and `<PHASE>` is one of `architect`, `developer`, `reviewer`, `ship`.
|
|
89
|
+
|
|
68
90
|
---
|
|
69
91
|
|
|
70
92
|
## Phase 0: Parse input and determine mode
|
|
@@ -265,6 +287,8 @@ For `body_sha` rows in the table, display only the first 8 characters of each SH
|
|
|
265
287
|
|
|
266
288
|
## Phase 3a: Architect (parallel, in main repo)
|
|
267
289
|
|
|
290
|
+
**Web Manager:** If `WEB_MANAGER=true`, notify: `{"event":"agent_start","agent":"architect"}`
|
|
291
|
+
|
|
268
292
|
For each chosen idea, launch an **sr-architect** agent (`subagent_type: sr-architect`, `run_in_background: true`).
|
|
269
293
|
|
|
270
294
|
Each architect creates OpenSpec artifacts in `openspec/changes/<name>/`.
|
|
@@ -331,8 +355,12 @@ Quick-check each architect's artifacts:
|
|
|
331
355
|
3. File references are real (>70% must exist)
|
|
332
356
|
4. Layer tags present on tasks
|
|
333
357
|
|
|
358
|
+
**Web Manager:** If `WEB_MANAGER=true`, notify: `{"event":"agent_stop","agent":"architect"}`
|
|
359
|
+
|
|
334
360
|
## Phase 3b: Implement
|
|
335
361
|
|
|
362
|
+
**Web Manager:** If `WEB_MANAGER=true`, notify: `{"event":"agent_start","agent":"developer"}`
|
|
363
|
+
|
|
336
364
|
### Pre-flight: Verify Bash permission
|
|
337
365
|
|
|
338
366
|
Before launching any developer agent, run a trivial Bash command to confirm Bash is allowed.
|
|
@@ -371,6 +399,8 @@ For each feature, analyze the tasks' layer tags:
|
|
|
371
399
|
|
|
372
400
|
Wait for all developers to complete.
|
|
373
401
|
|
|
402
|
+
**Web Manager:** If `WEB_MANAGER=true`, notify: `{"event":"agent_stop","agent":"developer"}`
|
|
403
|
+
|
|
374
404
|
## Phase 3c: Write Tests
|
|
375
405
|
|
|
376
406
|
Launch a **sr-test-writer** agent for each feature immediately after its developer completes.
|
|
@@ -540,6 +570,8 @@ Pass `MERGE_REPORT` to the Phase 4b reviewer agent prompt, listing any files in
|
|
|
540
570
|
|
|
541
571
|
### 4b. Layer Dispatch and Review
|
|
542
572
|
|
|
573
|
+
**Web Manager:** If `WEB_MANAGER=true`, notify: `{"event":"agent_start","agent":"reviewer"}`
|
|
574
|
+
|
|
543
575
|
#### Step 1: Layer Classification
|
|
544
576
|
|
|
545
577
|
Before launching any reviewer, classify `MODIFIED_FILES_LIST` into layer-specific file sets.
|
|
@@ -610,6 +642,8 @@ Note: if total layer report length is very large, truncate each layer report to
|
|
|
610
642
|
|
|
611
643
|
Launch the **sr-reviewer** agent (foreground, `run_in_background: false`). Wait for it to complete.
|
|
612
644
|
|
|
645
|
+
**Web Manager:** If `WEB_MANAGER=true`, notify: `{"event":"agent_stop","agent":"reviewer"}`
|
|
646
|
+
|
|
613
647
|
**If `DRY_RUN=true`**, add the following to the reviewer agent prompt:
|
|
614
648
|
|
|
615
649
|
> Note: This is a dry-run review. Developer files are under .claude/.dry-run/\<feature-name\>/.
|
|
@@ -745,6 +779,8 @@ If conflicts exist: print the same conflict report format as Phase 3a.0 (with `P
|
|
|
745
779
|
|
|
746
780
|
### 4c. Ship — Git & backlog updates
|
|
747
781
|
|
|
782
|
+
**Web Manager:** If `WEB_MANAGER=true`, notify: `{"event":"agent_start","agent":"ship"}`
|
|
783
|
+
|
|
748
784
|
**Security gate:** If `SECURITY_BLOCKED=true`:
|
|
749
785
|
1. Print all Critical findings from the security-reviewer output
|
|
750
786
|
2. Do NOT create a branch, commit, push, or PR
|
|
@@ -961,12 +997,15 @@ Include the shipping mode in the report:
|
|
|
961
997
|
- If automatic: show PR URL, CI status, backlog updates made
|
|
962
998
|
- If manual: show summary of changes, suggested git commands, backlog updates pending
|
|
963
999
|
|
|
1000
|
+
**Web Manager:** If `WEB_MANAGER=true`, notify: `{"event":"agent_stop","agent":"ship"}`
|
|
1001
|
+
|
|
964
1002
|
---
|
|
965
1003
|
|
|
966
1004
|
## Error Handling
|
|
967
1005
|
|
|
968
1006
|
- If a sr-product-manager fails: skip that area, continue with others
|
|
969
|
-
- If a sr-architect fails: skip that area, report the failure
|
|
970
|
-
- If a sr-developer fails: report which phase it failed at
|
|
971
|
-
- If the sr-reviewer finds unfixable issues: report them, push what works
|
|
1007
|
+
- If a sr-architect fails: skip that area, report the failure. **Web Manager:** notify `{"event":"agent_error","agent":"architect"}`
|
|
1008
|
+
- If a sr-developer fails: report which phase it failed at. **Web Manager:** notify `{"event":"agent_error","agent":"developer"}`
|
|
1009
|
+
- If the sr-reviewer finds unfixable issues: report them, push what works. **Web Manager:** notify `{"event":"agent_error","agent":"reviewer"}`
|
|
1010
|
+
- If Phase 4c (ship) fails: **Web Manager:** notify `{"event":"agent_error","agent":"ship"}`
|
|
972
1011
|
- Never block the entire pipeline on a single agent failure. Always produce a final report.
|
|
@@ -12,7 +12,7 @@ The specrails web manager is a locally-run dashboard that monitors and controls
|
|
|
12
12
|
## Setup
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
cd web
|
|
15
|
+
cd .claude/web-manager
|
|
16
16
|
npm install
|
|
17
17
|
```
|
|
18
18
|
|
|
@@ -20,8 +20,16 @@ This installs both the server dependencies (Express, WebSocket) and the client d
|
|
|
20
20
|
|
|
21
21
|
## Start
|
|
22
22
|
|
|
23
|
+
**Always start from your project root**, not from inside the web-manager directory. This ensures the project name is detected correctly:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
cd .claude/web-manager && npm run dev
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or specify the project name explicitly:
|
|
30
|
+
|
|
23
31
|
```bash
|
|
24
|
-
npm run dev
|
|
32
|
+
cd .claude/web-manager && SPECRAILS_PROJECT_NAME=my-project npm run dev
|
|
25
33
|
```
|
|
26
34
|
|
|
27
35
|
This starts two processes concurrently:
|
|
@@ -36,7 +44,7 @@ The server accepts these CLI flags (used with `npm run dev:server` or `tsx serve
|
|
|
36
44
|
|
|
37
45
|
| Flag | Default | Description |
|
|
38
46
|
|------|---------|-------------|
|
|
39
|
-
| `--project <name>` | `
|
|
47
|
+
| `--project <name>` | basename of `cwd` | Project name displayed in the dashboard header |
|
|
40
48
|
| `--port <n>` | `4200` | Port the backend server listens on |
|
|
41
49
|
|
|
42
50
|
Example:
|
|
@@ -45,36 +53,40 @@ Example:
|
|
|
45
53
|
tsx server/index.ts --project my-app --port 4000
|
|
46
54
|
```
|
|
47
55
|
|
|
48
|
-
|
|
56
|
+
You can also set the project name via environment variable: `SPECRAILS_PROJECT_NAME=my-app npm run dev`
|
|
49
57
|
|
|
50
|
-
|
|
58
|
+
## How It Connects to the Pipeline
|
|
51
59
|
|
|
52
|
-
|
|
60
|
+
The `/sr:implement` pipeline automatically detects whether the web manager is running and sends phase transition notifications. **No manual hook configuration is required.**
|
|
53
61
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
When you run `/sr:implement`, the orchestrator:
|
|
63
|
+
1. Checks if `http://127.0.0.1:4200` is reachable (Phase -1 pre-flight)
|
|
64
|
+
2. If yes, sends `POST /hooks/events` notifications at each phase transition:
|
|
65
|
+
- Architect starts/completes
|
|
66
|
+
- Developer starts/completes
|
|
67
|
+
- Reviewer starts/completes
|
|
68
|
+
- Ship starts/completes
|
|
69
|
+
3. If not reachable, the pipeline runs normally without notifications
|
|
70
|
+
|
|
71
|
+
All notifications are fire-and-forget — a failed notification never blocks the pipeline.
|
|
72
|
+
|
|
73
|
+
## Manual Hook Testing
|
|
62
74
|
|
|
63
|
-
To manually fire a hook event (useful for testing):
|
|
75
|
+
To manually fire a hook event (useful for testing the dashboard):
|
|
64
76
|
|
|
65
77
|
```bash
|
|
66
78
|
# Mark the architect phase as running
|
|
67
|
-
curl -X POST http://
|
|
79
|
+
curl -sf -X POST http://127.0.0.1:4200/hooks/events \
|
|
68
80
|
-H 'Content-Type: application/json' \
|
|
69
81
|
-d '{"event":"agent_start","agent":"architect"}'
|
|
70
82
|
|
|
71
83
|
# Mark the architect phase as done
|
|
72
|
-
curl -X POST http://
|
|
84
|
+
curl -sf -X POST http://127.0.0.1:4200/hooks/events \
|
|
73
85
|
-H 'Content-Type: application/json' \
|
|
74
86
|
-d '{"event":"agent_stop","agent":"architect"}'
|
|
75
87
|
|
|
76
88
|
# Mark the developer phase as errored
|
|
77
|
-
curl -X POST http://
|
|
89
|
+
curl -sf -X POST http://127.0.0.1:4200/hooks/events \
|
|
78
90
|
-H 'Content-Type: application/json' \
|
|
79
91
|
-d '{"event":"agent_error","agent":"developer"}'
|
|
80
92
|
```
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import http from 'http'
|
|
2
|
+
import path from 'path'
|
|
2
3
|
import express from 'express'
|
|
3
4
|
import { WebSocketServer, WebSocket } from 'ws'
|
|
4
5
|
import type { WsMessage } from './types'
|
|
@@ -6,8 +7,25 @@ import { ClaudeNotFoundError, SpawnBusyError } from './types'
|
|
|
6
7
|
import { createHooksRouter, getPhaseStates, resetPhases } from './hooks'
|
|
7
8
|
import { spawnClaude, isSpawnActive, getLogBuffer } from './spawner'
|
|
8
9
|
|
|
10
|
+
// Resolve project name: env var > CLI flag > git root basename > cwd parent
|
|
11
|
+
function resolveProjectName(): string {
|
|
12
|
+
if (process.env.SPECRAILS_PROJECT_NAME) {
|
|
13
|
+
return process.env.SPECRAILS_PROJECT_NAME
|
|
14
|
+
}
|
|
15
|
+
// The web-manager lives at <project>/.claude/web-manager/
|
|
16
|
+
// Walk up two levels to find the project root
|
|
17
|
+
const cwd = process.cwd()
|
|
18
|
+
const parentDir = path.basename(path.resolve(cwd, '../..'))
|
|
19
|
+
const immediateParent = path.basename(path.resolve(cwd, '..'))
|
|
20
|
+
// If we're inside .claude/web-manager, use the grandparent directory name
|
|
21
|
+
if (immediateParent === '.claude') {
|
|
22
|
+
return parentDir
|
|
23
|
+
}
|
|
24
|
+
return path.basename(cwd)
|
|
25
|
+
}
|
|
26
|
+
|
|
9
27
|
// Parse CLI args
|
|
10
|
-
let projectName =
|
|
28
|
+
let projectName = resolveProjectName()
|
|
11
29
|
let port = 4200
|
|
12
30
|
|
|
13
31
|
for (let i = 2; i < process.argv.length; i++) {
|