specdacular 0.8.1 → 0.9.2
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 +166 -54
- package/commands/specd/continue.md +22 -14
- package/commands/specd/toolbox.md +58 -14
- package/package.json +1 -1
- package/specdacular/HELP.md +70 -9
- package/specdacular/STATE-MACHINE.md +376 -0
- package/specdacular/pipeline.json +76 -0
- package/specdacular/references/brain-routing.md +168 -0
- package/specdacular/references/commit-code.md +9 -6
- package/specdacular/references/commit-docs.md +9 -6
- package/specdacular/references/execute-hooks.md +127 -0
- package/specdacular/references/resolve-pipeline.md +74 -0
- package/specdacular/templates/context/review-diff.md +60 -0
- package/specdacular/templates/context/section-display.md +51 -0
- package/specdacular/workflows/brain.md +378 -0
- package/specdacular/workflows/context-add.md +242 -0
- package/specdacular/workflows/context-manual-review.md +410 -0
- package/specdacular/workflows/continue.md +17 -259
- package/specdacular/workflows/execute.md +15 -42
- package/specdacular/workflows/map-codebase.md +14 -0
- package/specdacular/workflows/phase-plan.md +142 -0
- package/specdacular/workflows/plan.md +10 -37
- package/specdacular/workflows/research.md +25 -7
- package/specdacular/workflows/review.md +11 -136
- package/specdacular/workflows/revise.md +126 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<shared name="execute_hooks">
|
|
2
|
+
|
|
3
|
+
## Execute Hooks
|
|
4
|
+
|
|
5
|
+
Resolve and execute a hook. Called by brain.md for pre/post hooks around each step.
|
|
6
|
+
|
|
7
|
+
**Before using this reference, you must have ready:**
|
|
8
|
+
- `$HOOK_CONFIG` — the hook configuration (from pipeline.json step or global hooks)
|
|
9
|
+
- `$STEP_NAME` — the current step name (for convention discovery and logging)
|
|
10
|
+
- `$TASK_NAME` — the task name
|
|
11
|
+
- `$TASK_DIR` — path to task directory
|
|
12
|
+
|
|
13
|
+
### Resolve Hook
|
|
14
|
+
|
|
15
|
+
**If hook config is explicitly set (not null):**
|
|
16
|
+
|
|
17
|
+
Hook config shape:
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"workflow": "path/to/hook.md",
|
|
21
|
+
"mode": "inline",
|
|
22
|
+
"optional": false
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Defaults if fields are missing:
|
|
27
|
+
- `mode`: `"inline"`
|
|
28
|
+
- `optional`: `false`
|
|
29
|
+
|
|
30
|
+
**If hook config is null — convention fallback:**
|
|
31
|
+
|
|
32
|
+
Check for convention-named hook file:
|
|
33
|
+
```bash
|
|
34
|
+
[ -f ".specd/hooks/{pre|post}-{step-name}.md" ] && echo "found"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
If found, use it with defaults: `mode: "inline"`, `optional: false`.
|
|
38
|
+
|
|
39
|
+
If not found, skip — no hook to execute.
|
|
40
|
+
|
|
41
|
+
### Execute Hook — Inline Mode
|
|
42
|
+
|
|
43
|
+
When `mode` is `"inline"` (default):
|
|
44
|
+
|
|
45
|
+
1. Read the hook markdown file
|
|
46
|
+
2. Execute the hook's instructions in the brain's current context
|
|
47
|
+
3. The hook has full access to task files (FEATURE.md, CONTEXT.md, DECISIONS.md, etc.)
|
|
48
|
+
4. The hook can read and modify any task file — this is how it communicates with subsequent steps
|
|
49
|
+
5. After hook completes, continue to next item in execution sequence
|
|
50
|
+
|
|
51
|
+
**Convention for hooks modifying shared files:**
|
|
52
|
+
Hooks should append to designated sections rather than overwriting. If adding context, append under a `## Hook Context` section or similar.
|
|
53
|
+
|
|
54
|
+
### Execute Hook — Subagent Mode
|
|
55
|
+
|
|
56
|
+
When `mode` is `"subagent"`:
|
|
57
|
+
|
|
58
|
+
1. **Flush state to disk first:** Ensure all pending config.json and STATE.md writes are committed. The subagent reads from disk and must see current state.
|
|
59
|
+
|
|
60
|
+
2. **Spawn hook as Task agent:**
|
|
61
|
+
```
|
|
62
|
+
Task(
|
|
63
|
+
subagent_type: "general-purpose"
|
|
64
|
+
model: "sonnet"
|
|
65
|
+
run_in_background: false
|
|
66
|
+
description: "Hook: {hook-file-name}"
|
|
67
|
+
prompt: "You are executing a hook for the specdacular workflow system.
|
|
68
|
+
|
|
69
|
+
Read and follow the instructions in: {path/to/hook.md}
|
|
70
|
+
|
|
71
|
+
Task context:
|
|
72
|
+
- Task name: {task-name}
|
|
73
|
+
- Task directory: {task-dir}
|
|
74
|
+
- Current step: {step-name}
|
|
75
|
+
|
|
76
|
+
You have full access to read and modify task files in the task directory.
|
|
77
|
+
After completing the hook instructions, return a brief summary of what you did."
|
|
78
|
+
)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
3. After subagent returns, brain continues. Subagent's file modifications are already on disk.
|
|
82
|
+
|
|
83
|
+
### Error Handling
|
|
84
|
+
|
|
85
|
+
**If hook succeeds:** Continue to next item in execution sequence.
|
|
86
|
+
|
|
87
|
+
**If hook fails and `optional: false` (default):**
|
|
88
|
+
- Stop the pipeline immediately
|
|
89
|
+
- Save current state (config.json, STATE.md)
|
|
90
|
+
- Surface the error to the user:
|
|
91
|
+
```
|
|
92
|
+
Hook failed: {hook-file-name}
|
|
93
|
+
Error: {description of what went wrong}
|
|
94
|
+
|
|
95
|
+
Pipeline stopped. Resume with /specd:continue {task-name}
|
|
96
|
+
```
|
|
97
|
+
- End workflow
|
|
98
|
+
|
|
99
|
+
**If hook fails and `optional: true`:**
|
|
100
|
+
- Print visible warning:
|
|
101
|
+
```
|
|
102
|
+
[HOOK SKIPPED] {hook-file-name} failed: {reason}
|
|
103
|
+
```
|
|
104
|
+
- Append to CHANGELOG.md:
|
|
105
|
+
```markdown
|
|
106
|
+
### {date} - Hook Failure
|
|
107
|
+
|
|
108
|
+
**{hook-file-name} (optional, skipped)**
|
|
109
|
+
- **Step:** {step-name}
|
|
110
|
+
- **Error:** {reason}
|
|
111
|
+
- **Impact:** Hook skipped, pipeline continued
|
|
112
|
+
```
|
|
113
|
+
- Continue to next item in execution sequence
|
|
114
|
+
|
|
115
|
+
### Execution Order
|
|
116
|
+
|
|
117
|
+
The full hook execution sequence around a step:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
1. Global hooks.pre-step (if configured)
|
|
121
|
+
2. Step hooks.pre (if configured, else convention fallback)
|
|
122
|
+
3. ── STEP WORKFLOW ──
|
|
123
|
+
4. Step hooks.post (if configured, else convention fallback)
|
|
124
|
+
5. Global hooks.post-step (if configured)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
</shared>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<shared name="resolve_pipeline">
|
|
2
|
+
|
|
3
|
+
## Resolve Pipeline
|
|
4
|
+
|
|
5
|
+
Load and validate the pipeline configuration.
|
|
6
|
+
|
|
7
|
+
**Before using this reference, you must have ready:**
|
|
8
|
+
- Working directory is the project root
|
|
9
|
+
|
|
10
|
+
### Load Pipeline
|
|
11
|
+
|
|
12
|
+
**Resolution order:**
|
|
13
|
+
1. Check for user override: `.specd/pipeline.json`
|
|
14
|
+
2. Fall back to installed default: `~/.claude/specdacular/pipeline.json`
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
if [ -f ".specd/pipeline.json" ]; then
|
|
18
|
+
echo "user-override"
|
|
19
|
+
elif [ -f "~/.claude/specdacular/pipeline.json" ]; then
|
|
20
|
+
echo "default"
|
|
21
|
+
else
|
|
22
|
+
echo "not-found"
|
|
23
|
+
fi
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**If user override found:**
|
|
27
|
+
```
|
|
28
|
+
Using custom pipeline from .specd/pipeline.json
|
|
29
|
+
```
|
|
30
|
+
Read `.specd/pipeline.json`.
|
|
31
|
+
|
|
32
|
+
**If default found:**
|
|
33
|
+
Read the installed `specdacular/pipeline.json` (use the path prefix from install — `~/.claude/specdacular/pipeline.json` for global, `.claude/specdacular/pipeline.json` for local).
|
|
34
|
+
|
|
35
|
+
**If not found:**
|
|
36
|
+
```
|
|
37
|
+
No pipeline.json found. This shouldn't happen — try reinstalling with npx specdacular.
|
|
38
|
+
```
|
|
39
|
+
End workflow.
|
|
40
|
+
|
|
41
|
+
### Validate Pipeline
|
|
42
|
+
|
|
43
|
+
After loading, validate the pipeline config:
|
|
44
|
+
|
|
45
|
+
**1. Check schema_version:**
|
|
46
|
+
```
|
|
47
|
+
Read "schema_version" field. If missing, warn:
|
|
48
|
+
"Warning: pipeline.json has no schema_version. Expected 1.0."
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**2. Check pipeline references:**
|
|
52
|
+
For each step in all pipelines, if a step has `"pipeline": "{name}"`:
|
|
53
|
+
- Check that `pipelines.{name}` exists
|
|
54
|
+
- If not: error with `"Pipeline step '{step.name}' references pipeline '{name}' which doesn't exist in pipelines object."`
|
|
55
|
+
|
|
56
|
+
**3. Check workflow references:**
|
|
57
|
+
For each step with a `"workflow"` field:
|
|
58
|
+
- Check the value is a non-empty string
|
|
59
|
+
- If empty: error with `"Step '{step.name}' has no workflow specified."`
|
|
60
|
+
|
|
61
|
+
**4. Warn on missing standard steps (non-blocking):**
|
|
62
|
+
Check if these step names exist in any pipeline: discuss, plan, execute, review.
|
|
63
|
+
For each missing, warn:
|
|
64
|
+
```
|
|
65
|
+
Note: Standard step '{name}' not found in pipeline. This is OK if intentional.
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Set Pipeline Variable
|
|
69
|
+
|
|
70
|
+
After validation, the pipeline config is available as `$PIPELINE` for the brain to use.
|
|
71
|
+
|
|
72
|
+
`$PIPELINE_SOURCE` is set to `"user-override"` or `"default"`.
|
|
73
|
+
|
|
74
|
+
</shared>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Context Review Diff Template
|
|
2
|
+
|
|
3
|
+
Template for displaying re-mapping results when comparing current vs re-mapped section content. Referenced by `specdacular/workflows/context-review.md`.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Re-map Diff Display
|
|
8
|
+
|
|
9
|
+
Shown after a `specd-codebase-mapper` agent returns re-mapped content for a section.
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
13
|
+
RE-MAP RESULTS: {section title}
|
|
14
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
15
|
+
|
|
16
|
+
Note: AI regeneration may rephrase content even when
|
|
17
|
+
facts are unchanged. Focus on factual differences.
|
|
18
|
+
|
|
19
|
+
───── CURRENT ─────────────────────────────────────────
|
|
20
|
+
|
|
21
|
+
{current section content}
|
|
22
|
+
|
|
23
|
+
───── RE-MAPPED ───────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
{agent's returned content}
|
|
26
|
+
|
|
27
|
+
───── KEY DIFFERENCES ─────────────────────────────────
|
|
28
|
+
|
|
29
|
+
- {factual difference 1: added/removed/changed item}
|
|
30
|
+
- {factual difference 2}
|
|
31
|
+
...
|
|
32
|
+
|
|
33
|
+
{If no factual differences: "No factual changes detected — only phrasing differences."}
|
|
34
|
+
|
|
35
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Key Differences Guidelines
|
|
39
|
+
|
|
40
|
+
When summarizing differences, focus on **factual changes only**:
|
|
41
|
+
- New file paths, functions, or integrations added
|
|
42
|
+
- Removed items that no longer exist in the codebase
|
|
43
|
+
- Changed descriptions that reflect actual behavior differences
|
|
44
|
+
- Updated version numbers or configuration values
|
|
45
|
+
|
|
46
|
+
**Ignore:**
|
|
47
|
+
- Rephrased descriptions with the same meaning
|
|
48
|
+
- Reordered items within a list
|
|
49
|
+
- Formatting differences (bullet style, heading level)
|
|
50
|
+
- Synonymous wording ("utilizes" vs "uses")
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Variables
|
|
55
|
+
|
|
56
|
+
| Variable | Description |
|
|
57
|
+
|----------|-------------|
|
|
58
|
+
| `{section title}` | The heading text of the section being re-mapped |
|
|
59
|
+
| `{current section content}` | Existing section body for comparison |
|
|
60
|
+
| `{agent's returned content}` | New content from the `specd-codebase-mapper` agent |
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Context Section Display Template
|
|
2
|
+
|
|
3
|
+
Template for displaying a single section of a codebase context file to the user during review. Referenced by `specdacular/workflows/context-review.md`.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Section Display
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
================================================================
|
|
11
|
+
{If ### subsection: "## {Parent Title} > "}{## or ###} {Section Title} [{current}/{total}]{If tagged: " · {USER_MODIFIED|AUTO_GENERATED}: YYYY-MM-DD"}
|
|
12
|
+
================================================================
|
|
13
|
+
|
|
14
|
+
{exact section content from the file — verbatim, no modifications, no strikethrough, no interpretation}
|
|
15
|
+
|
|
16
|
+
────────────────────────────────────────
|
|
17
|
+
{assessment icon} {assessment label} — {brief explanation}
|
|
18
|
+
================================================================
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Header:** `=` separator, section heading with position counter, `=` separator. For `###` subsections, prefix with the parent `##` heading and ` > ` to show context.
|
|
22
|
+
|
|
23
|
+
**Middle — Raw content:** The exact text from the file in a code fence. Do NOT interpret the content — no strikethrough on missing paths, no added formatting. Show it verbatim.
|
|
24
|
+
|
|
25
|
+
**Bottom — Assessment:** The agent's analysis with icon, label, and brief explanation. Closed with `=` separator.
|
|
26
|
+
|
|
27
|
+
**Empty parent sections** (## with no content, only ### children) are NOT displayed as reviewable sections. Their heading is shown as a prefix on child sections instead.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Assessment Logic
|
|
32
|
+
|
|
33
|
+
Based on the section's tag and its date:
|
|
34
|
+
|
|
35
|
+
- **No tag** → ⚠️ Untagged — never reviewed or generated
|
|
36
|
+
- **Tag date older than 14 days** → ⚠️ Potentially stale
|
|
37
|
+
- **Tag date within 14 days** → ✅ Recently reviewed
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## User Actions
|
|
42
|
+
|
|
43
|
+
After displaying the section, prompt the user with:
|
|
44
|
+
|
|
45
|
+
| Action | Description |
|
|
46
|
+
|--------|-------------|
|
|
47
|
+
| Confirm | Section is correct, move to next |
|
|
48
|
+
| Edit | User describes what to change |
|
|
49
|
+
| Remove | Delete this section (warns about children) |
|
|
50
|
+
| Re-map | Spawn mapper agent, show diff |
|
|
51
|
+
| Done for now | Skip remaining sections |
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
<purpose>
|
|
2
|
+
Config-driven orchestrator that replaces continue.md's hardcoded flow control. Reads pipeline.json, determines the next step based on task state, handles modes (default/interactive/auto), dispatches step workflows, executes hooks, and manages state transitions.
|
|
3
|
+
|
|
4
|
+
The brain is the single source of truth for workflow orchestration. Step workflows just do their job and return — the brain decides what comes next.
|
|
5
|
+
|
|
6
|
+
**Modes:**
|
|
7
|
+
- **Default:** Auto-runs steps, pauses where `pause: true`. Smart about skipping unnecessary steps.
|
|
8
|
+
- **Interactive (`--interactive`):** Prompts at each stage transition with skip/jump options
|
|
9
|
+
- **Auto (`--auto`):** Runs everything, only stops on errors or task completion
|
|
10
|
+
</purpose>
|
|
11
|
+
|
|
12
|
+
<philosophy>
|
|
13
|
+
|
|
14
|
+
## One Orchestrator
|
|
15
|
+
|
|
16
|
+
All flow control lives here. Step workflows are pure execution — they do their work and return. They never dispatch the next step.
|
|
17
|
+
|
|
18
|
+
## Config-Driven
|
|
19
|
+
|
|
20
|
+
The pipeline comes from pipeline.json, not hardcoded logic. Users can swap steps, add hooks, or replace the entire pipeline.
|
|
21
|
+
|
|
22
|
+
## State Machine
|
|
23
|
+
|
|
24
|
+
The brain reads state → determines position → dispatches → updates state → loops. Every state transition is explicit and persisted before dispatch.
|
|
25
|
+
|
|
26
|
+
## Hooks Are Workflow Steps
|
|
27
|
+
|
|
28
|
+
Hooks are markdown files executed like any other workflow step. They can read and modify task files. No special output contract.
|
|
29
|
+
|
|
30
|
+
</philosophy>
|
|
31
|
+
|
|
32
|
+
<process>
|
|
33
|
+
|
|
34
|
+
<step name="parse_args">
|
|
35
|
+
Parse arguments to extract task name and mode.
|
|
36
|
+
|
|
37
|
+
**Parse $ARGUMENTS:**
|
|
38
|
+
- Extract task name (first argument, or only argument without --)
|
|
39
|
+
- Check for `--interactive` flag
|
|
40
|
+
- Check for `--auto` flag
|
|
41
|
+
- If `--interactive` → interactive mode
|
|
42
|
+
- If `--auto` → auto mode
|
|
43
|
+
- Otherwise → default mode
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
Mode: {default | interactive | auto}
|
|
47
|
+
Task: {task-name}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Continue to validate.
|
|
51
|
+
</step>
|
|
52
|
+
|
|
53
|
+
<step name="validate">
|
|
54
|
+
@~/.claude/specdacular/references/validate-task.md
|
|
55
|
+
|
|
56
|
+
Use basic validation with $TASK_NAME.
|
|
57
|
+
|
|
58
|
+
Continue to resolve_pipeline.
|
|
59
|
+
</step>
|
|
60
|
+
|
|
61
|
+
<step name="resolve_pipeline">
|
|
62
|
+
@~/.claude/specdacular/references/resolve-pipeline.md
|
|
63
|
+
|
|
64
|
+
Load and validate the pipeline configuration.
|
|
65
|
+
|
|
66
|
+
After loading, apply mode:
|
|
67
|
+
- If `--interactive` flag was set, use interactive mode
|
|
68
|
+
- If `--auto` flag was set, use auto mode
|
|
69
|
+
- Otherwise use default mode (auto-run, pause at `pause: true` steps)
|
|
70
|
+
|
|
71
|
+
**Check for orchestrator mode:**
|
|
72
|
+
Read `.specd/config.json` (project-level, not task-level). If it has `"type": "orchestrator"`:
|
|
73
|
+
- Set `$ORCHESTRATOR_MODE = true`
|
|
74
|
+
- Log: `Orchestrator mode: multi-project task management active.`
|
|
75
|
+
|
|
76
|
+
**How orchestrator mode works with the brain:**
|
|
77
|
+
|
|
78
|
+
The brain runs the same pipeline for orchestrator tasks. The difference is that step workflows detect orchestrator mode internally and hand off to specialized orchestrator workflows:
|
|
79
|
+
- `new.md` → detects orchestrator → delegates to `orchestrator/new.md` (multi-project task creation)
|
|
80
|
+
- `plan.md` → detects orchestrator → delegates to `orchestrator/plan.md` (cross-project phasing)
|
|
81
|
+
- `discuss.md`, `research.md` → work at orchestrator level (system-wide discussion/research)
|
|
82
|
+
- `execute.md` → for orchestrator tasks, reads DEPENDENCIES.md to determine cross-project phase order. Executes phases per-project respecting dependency graph.
|
|
83
|
+
- `review.md`, `revise.md` → work per-project within the orchestrator's coordination
|
|
84
|
+
|
|
85
|
+
The brain does NOT need different routing for orchestrator mode. The pipeline is the same — orchestrator awareness lives in the step workflows that need it. The brain's job is to drive the pipeline; the steps handle multi-project specifics.
|
|
86
|
+
|
|
87
|
+
**Important:** When in orchestrator mode, the phase-execution loop may need to coordinate across projects. The brain reads the orchestrator task's DEPENDENCIES.md to understand cross-project phase ordering, and dispatches execute/review/revise per project in dependency order.
|
|
88
|
+
|
|
89
|
+
Continue to main_loop.
|
|
90
|
+
</step>
|
|
91
|
+
|
|
92
|
+
<step name="main_loop">
|
|
93
|
+
The core orchestration loop. Repeats until task is complete or user stops.
|
|
94
|
+
|
|
95
|
+
**On each iteration:**
|
|
96
|
+
|
|
97
|
+
1. **Load current state:**
|
|
98
|
+
Read config.json, STATE.md, CONTEXT.md from task directory.
|
|
99
|
+
|
|
100
|
+
2. **Determine next step:**
|
|
101
|
+
@~/.claude/specdacular/references/brain-routing.md
|
|
102
|
+
|
|
103
|
+
This sets: `$NEXT_STEP`, `$NEXT_PIPELINE`, and optionally `$TASK_COMPLETE` or `$RESUME`.
|
|
104
|
+
|
|
105
|
+
3. **If task complete:**
|
|
106
|
+
Continue to complete.
|
|
107
|
+
|
|
108
|
+
4. **Find step config in pipeline:**
|
|
109
|
+
Look up `$NEXT_STEP` in `$PIPELINE.pipelines.$NEXT_PIPELINE`.
|
|
110
|
+
|
|
111
|
+
5. **Prompt or proceed:**
|
|
112
|
+
Continue to prompt_or_proceed.
|
|
113
|
+
|
|
114
|
+
6. **After step dispatch returns:**
|
|
115
|
+
Continue to update_state.
|
|
116
|
+
|
|
117
|
+
7. **After state update:**
|
|
118
|
+
Loop back to step 1 (re-read state, determine next step).
|
|
119
|
+
|
|
120
|
+
Continue to prompt_or_proceed.
|
|
121
|
+
</step>
|
|
122
|
+
|
|
123
|
+
<step name="prompt_or_proceed">
|
|
124
|
+
Mode-based dispatch decision.
|
|
125
|
+
|
|
126
|
+
**Default mode:**
|
|
127
|
+
Check the step's `pause` field:
|
|
128
|
+
- If `false` or absent: auto-proceed (no prompt). But first, evaluate if the step adds value — if not, skip it (see smart skipping below).
|
|
129
|
+
- If `true`: prompt user before proceeding
|
|
130
|
+
|
|
131
|
+
When pausing, present current state and ask what to do:
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
**Current state:** {stage description}
|
|
135
|
+
{Additional context based on step — e.g., phase number}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Use AskUserQuestion with step-appropriate options:
|
|
139
|
+
|
|
140
|
+
For plan step (phase-execution pipeline — phase-plan.md):
|
|
141
|
+
- Auto-proceed (no pause). Plan has no pause field.
|
|
142
|
+
|
|
143
|
+
For execute step:
|
|
144
|
+
- "Execute" (Recommended) — Start/resume phase execution
|
|
145
|
+
- "Review plan" — Read the PLAN.md first
|
|
146
|
+
- "Stop for now" — Come back later
|
|
147
|
+
|
|
148
|
+
For review step:
|
|
149
|
+
- Dispatch directly (review has its own user interaction)
|
|
150
|
+
|
|
151
|
+
For revise step:
|
|
152
|
+
- Dispatch directly (revise has its own user interaction)
|
|
153
|
+
|
|
154
|
+
**Interactive mode (`--interactive`):**
|
|
155
|
+
Prompt at every stage transition, regardless of `pause` field.
|
|
156
|
+
|
|
157
|
+
Use AskUserQuestion with step-appropriate options:
|
|
158
|
+
|
|
159
|
+
For discuss step:
|
|
160
|
+
- "Discuss" (Recommended) — Dive into gray areas
|
|
161
|
+
- "Skip to research" — Move on without resolving
|
|
162
|
+
- "Skip to planning" — Jump straight to planning
|
|
163
|
+
|
|
164
|
+
For research step:
|
|
165
|
+
- "Research" (Recommended) — Investigate implementation patterns
|
|
166
|
+
- "Skip to planning" — Plan without research
|
|
167
|
+
- "Discuss more" — Continue discussion
|
|
168
|
+
|
|
169
|
+
For plan step (main pipeline — task-level):
|
|
170
|
+
- "Plan" (Recommended) — Create roadmap with phase goals
|
|
171
|
+
- "Research first" — Run research before planning
|
|
172
|
+
- "Discuss more" — Continue discussion
|
|
173
|
+
|
|
174
|
+
For plan step (phase-execution pipeline — phase-plan.md):
|
|
175
|
+
- "Plan this phase" (Recommended) — Create detailed PLAN.md
|
|
176
|
+
- "Skip to execute" — Execute without explicit planning
|
|
177
|
+
- "Stop for now" — Come back later
|
|
178
|
+
|
|
179
|
+
For execute step:
|
|
180
|
+
- "Execute" (Recommended) — Start/resume phase execution
|
|
181
|
+
- "Review plan" — Read the PLAN.md first
|
|
182
|
+
- "Stop for now" — Come back later
|
|
183
|
+
|
|
184
|
+
For review step:
|
|
185
|
+
- Dispatch directly (review has its own user interaction)
|
|
186
|
+
|
|
187
|
+
For revise step:
|
|
188
|
+
- Dispatch directly (revise has its own user interaction)
|
|
189
|
+
|
|
190
|
+
**Auto mode (`--auto`):**
|
|
191
|
+
Proceed without prompting. Apply smart skipping (see below). Only stop on errors or task completion.
|
|
192
|
+
|
|
193
|
+
**If user chooses "Stop for now":**
|
|
194
|
+
Save state and exit:
|
|
195
|
+
```
|
|
196
|
+
───────────────────────────────────────────────────────
|
|
197
|
+
|
|
198
|
+
Progress saved. Pick up where you left off anytime:
|
|
199
|
+
|
|
200
|
+
/specd:continue {task-name}
|
|
201
|
+
```
|
|
202
|
+
End workflow.
|
|
203
|
+
|
|
204
|
+
**If user chooses an alternative (e.g., "Skip to research"):**
|
|
205
|
+
Update `$NEXT_STEP` accordingly and continue to dispatch.
|
|
206
|
+
|
|
207
|
+
**Smart step skipping (default and auto modes):**
|
|
208
|
+
Before dispatching a step, evaluate whether it adds value. Skip if:
|
|
209
|
+
- **discuss:** No gray areas remaining in CONTEXT.md → skip, advance to research
|
|
210
|
+
- **research (task-level):** Task is straightforward (few files, clear requirements, no external dependencies) → skip, advance to plan
|
|
211
|
+
|
|
212
|
+
When skipping, log:
|
|
213
|
+
```
|
|
214
|
+
Skipping {step}: {reason}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
In interactive mode, don't auto-skip — instead recommend skipping: mark the skip option as "(Recommended)" and the step as the alternative.
|
|
218
|
+
|
|
219
|
+
Continue to execute_hooks_and_step.
|
|
220
|
+
</step>
|
|
221
|
+
|
|
222
|
+
<step name="execute_hooks_and_step">
|
|
223
|
+
Execute pre-hooks, the step workflow, and post-hooks.
|
|
224
|
+
|
|
225
|
+
**Save state before dispatch:**
|
|
226
|
+
Update config.json to reflect the step is starting. For execute step, set `phases.current_status: "executing"` and record `phase_start_commit`.
|
|
227
|
+
|
|
228
|
+
Commit state:
|
|
229
|
+
@~/.claude/specdacular/references/commit-docs.md
|
|
230
|
+
- **$FILES:** config.json, STATE.md
|
|
231
|
+
- **$MESSAGE:** `docs({task-name}): starting {step-name}`
|
|
232
|
+
- **$LABEL:** `state transition`
|
|
233
|
+
|
|
234
|
+
**Execute pre-hooks:**
|
|
235
|
+
@~/.claude/specdacular/references/execute-hooks.md
|
|
236
|
+
|
|
237
|
+
Run pre-hooks in order:
|
|
238
|
+
1. Global `hooks.pre-step` from pipeline.json (if configured)
|
|
239
|
+
2. Step's `hooks.pre` from the step config (if configured)
|
|
240
|
+
3. Convention fallback: check `.specd/hooks/pre-{step-name}.md` (if file exists and no explicit config)
|
|
241
|
+
|
|
242
|
+
For each hook, use the execution logic from the reference.
|
|
243
|
+
|
|
244
|
+
If a required pre-hook fails, stop pipeline and save state. Do NOT dispatch the step.
|
|
245
|
+
|
|
246
|
+
**Dispatch step workflow:**
|
|
247
|
+
Resolve the workflow path from the step's `workflow` field.
|
|
248
|
+
Execute the workflow:
|
|
249
|
+
@~/.claude/specdacular/workflows/{workflow}
|
|
250
|
+
|
|
251
|
+
Pass $TASK_NAME as context.
|
|
252
|
+
|
|
253
|
+
**After step returns:**
|
|
254
|
+
|
|
255
|
+
**Execute post-hooks:**
|
|
256
|
+
@~/.claude/specdacular/references/execute-hooks.md
|
|
257
|
+
|
|
258
|
+
Run post-hooks in order:
|
|
259
|
+
1. Step's `hooks.post` from the step config (if configured)
|
|
260
|
+
2. Convention fallback: check `.specd/hooks/post-{step-name}.md` (if file exists and no explicit config)
|
|
261
|
+
3. Global `hooks.post-step` from pipeline.json (if configured)
|
|
262
|
+
|
|
263
|
+
For each hook, use the execution logic from the reference.
|
|
264
|
+
|
|
265
|
+
If a required post-hook fails, stop pipeline and save state.
|
|
266
|
+
|
|
267
|
+
Continue to update_state.
|
|
268
|
+
</step>
|
|
269
|
+
|
|
270
|
+
<step name="update_state">
|
|
271
|
+
Update state based on which step just completed.
|
|
272
|
+
|
|
273
|
+
**After discuss completes:**
|
|
274
|
+
- Stage stays at "discussion"
|
|
275
|
+
- Re-read CONTEXT.md to check if gray areas are resolved
|
|
276
|
+
- If all resolved, advance stage to "research"
|
|
277
|
+
|
|
278
|
+
**After research completes:**
|
|
279
|
+
- Set stage to "planning" in config.json
|
|
280
|
+
|
|
281
|
+
**After plan completes (task-level — main pipeline):**
|
|
282
|
+
- plan.md sets stage to "execution" and phases info in config.json
|
|
283
|
+
- Brain loops back, routing picks up phase-execution pipeline
|
|
284
|
+
|
|
285
|
+
**After plan completes (phase-level — phase-execution pipeline, phase-plan.md):**
|
|
286
|
+
- phase-plan.md creates PLAN.md but does NOT change config.json
|
|
287
|
+
- Status stays "pending" but PLAN.md now exists
|
|
288
|
+
- Brain loops back, routing sees pending + PLAN.md exists → routes to execute
|
|
289
|
+
|
|
290
|
+
**After execute completes:**
|
|
291
|
+
- Set `phases.current_status: "executed"` in config.json
|
|
292
|
+
|
|
293
|
+
**After review completes:**
|
|
294
|
+
- Read review outcome from config.json or STATE.md
|
|
295
|
+
- If user approved ("Looks good"): set `phases.current_status: "completed"`, increment `phases.completed`, advance to next phase or mark task complete
|
|
296
|
+
- If user wants revisions: set up for revise step
|
|
297
|
+
- If user stopped: save state, exit
|
|
298
|
+
|
|
299
|
+
**After revise completes:**
|
|
300
|
+
- Read config.json — revise should have set `phases.current_status: "pending"` (fix plan created, needs execution)
|
|
301
|
+
- Brain loops back to execute for the current phase (including decimal fix phases)
|
|
302
|
+
|
|
303
|
+
**Commit state updates:**
|
|
304
|
+
@~/.claude/specdacular/references/commit-docs.md
|
|
305
|
+
- **$FILES:** config.json, STATE.md
|
|
306
|
+
- **$MESSAGE:** `docs({task-name}): {step-name} complete`
|
|
307
|
+
- **$LABEL:** `state transition`
|
|
308
|
+
|
|
309
|
+
Return to main_loop.
|
|
310
|
+
</step>
|
|
311
|
+
|
|
312
|
+
<step name="phase_loop">
|
|
313
|
+
Handle the phase-execution sub-pipeline loop.
|
|
314
|
+
|
|
315
|
+
When the brain reaches the `phase-execution` pipeline reference in the main pipeline:
|
|
316
|
+
|
|
317
|
+
1. Read ROADMAP.md and config.json to determine current phase
|
|
318
|
+
2. Enter the phase-execution sub-pipeline (plan → execute → review → revise)
|
|
319
|
+
3. After each iteration through the sub-pipeline:
|
|
320
|
+
- If review approved and more phases remain: advance `phases.current`, set status "pending", loop
|
|
321
|
+
- If review approved and no more phases: exit sub-pipeline, task complete
|
|
322
|
+
- If revise created fix plans: stay on current phase, loop back to execute
|
|
323
|
+
- If user stopped: save state, exit
|
|
324
|
+
|
|
325
|
+
**Decimal phase handling:**
|
|
326
|
+
After revise creates a fix plan (e.g., phase-01.1/):
|
|
327
|
+
```bash
|
|
328
|
+
ls -d $TASK_DIR/phases/phase-$(printf '%02d' $CURRENT).* 2>/dev/null | sort -V
|
|
329
|
+
```
|
|
330
|
+
If decimal phases exist and are incomplete, execute them before advancing to next integer phase.
|
|
331
|
+
|
|
332
|
+
**Phase advancement:**
|
|
333
|
+
```
|
|
334
|
+
phases.current += 1
|
|
335
|
+
phases.current_status = "pending"
|
|
336
|
+
phases.phase_start_commit = null
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
Continue to main_loop (which will route to the next phase's execute step).
|
|
340
|
+
</step>
|
|
341
|
+
|
|
342
|
+
<step name="complete">
|
|
343
|
+
All phases complete. Task is done.
|
|
344
|
+
|
|
345
|
+
**Update state:**
|
|
346
|
+
- Set stage to "complete" in config.json
|
|
347
|
+
|
|
348
|
+
**Present:**
|
|
349
|
+
```
|
|
350
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
351
|
+
TASK COMPLETE
|
|
352
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
353
|
+
|
|
354
|
+
**Task:** {task-name}
|
|
355
|
+
**Phases completed:** {N}
|
|
356
|
+
**Decisions made:** {N}
|
|
357
|
+
|
|
358
|
+
All phases executed and reviewed. Task is done!
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
End workflow.
|
|
362
|
+
</step>
|
|
363
|
+
|
|
364
|
+
</process>
|
|
365
|
+
|
|
366
|
+
<success_criteria>
|
|
367
|
+
- Pipeline loaded from .specd/pipeline.json or installed default
|
|
368
|
+
- Pipeline validated (schema version, references, workflow paths)
|
|
369
|
+
- State-based routing matches all 8 state combinations
|
|
370
|
+
- Default mode auto-runs, pauses at `pause: true` steps, smart-skips unnecessary steps
|
|
371
|
+
- Interactive mode prompts at each transition with skip/jump options
|
|
372
|
+
- Auto mode proceeds without prompting, smart-skips, stops on errors
|
|
373
|
+
- Phase-execution sub-pipeline loops correctly per phase
|
|
374
|
+
- Decimal fix phases handled
|
|
375
|
+
- State saved before dispatch for reliable resume
|
|
376
|
+
- Stop/resume works at any point via /specd:continue
|
|
377
|
+
- Hook execution points marked for Phase 2
|
|
378
|
+
</success_criteria>
|