specdacular 0.8.0 → 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.
Files changed (30) hide show
  1. package/README.md +166 -54
  2. package/commands/specd/continue.md +22 -14
  3. package/commands/specd/toolbox.md +58 -14
  4. package/package.json +1 -1
  5. package/specdacular/HELP.md +70 -9
  6. package/specdacular/STATE-MACHINE.md +376 -0
  7. package/specdacular/pipeline.json +76 -0
  8. package/specdacular/references/brain-routing.md +168 -0
  9. package/specdacular/references/commit-code.md +9 -6
  10. package/specdacular/references/commit-docs.md +9 -6
  11. package/specdacular/references/execute-hooks.md +127 -0
  12. package/specdacular/references/load-context.md +10 -9
  13. package/specdacular/references/resolve-pipeline.md +74 -0
  14. package/specdacular/references/select-feature.md +12 -5
  15. package/specdacular/references/validate-task.md +19 -11
  16. package/specdacular/templates/context/review-diff.md +60 -0
  17. package/specdacular/templates/context/section-display.md +51 -0
  18. package/specdacular/workflows/brain.md +378 -0
  19. package/specdacular/workflows/context-add.md +242 -0
  20. package/specdacular/workflows/context-manual-review.md +410 -0
  21. package/specdacular/workflows/continue.md +17 -259
  22. package/specdacular/workflows/execute.md +15 -42
  23. package/specdacular/workflows/map-codebase.md +14 -0
  24. package/specdacular/workflows/new.md +2 -2
  25. package/specdacular/workflows/phase-plan.md +142 -0
  26. package/specdacular/workflows/plan.md +10 -37
  27. package/specdacular/workflows/research.md +25 -7
  28. package/specdacular/workflows/review.md +11 -136
  29. package/specdacular/workflows/revise.md +126 -0
  30. package/specdacular/workflows/status.md +1 -1
@@ -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>
@@ -6,6 +6,7 @@ Load all context files for a task. Use after validation.
6
6
 
7
7
  **Before using this reference, you must have ready:**
8
8
  - `$TASK_NAME` — the task name
9
+ - `$TASK_DIR` — resolved task directory (from validate-task, either `.specd/tasks/$TASK_NAME` or `.specd/features/$TASK_NAME`)
9
10
  - `$PHASE` (optional) — phase number, if loading phase-specific context
10
11
 
11
12
  ### Always Load
@@ -20,11 +21,11 @@ Load all context files for a task. Use after validation.
20
21
 
21
22
  ```bash
22
23
  # Read all required files
23
- cat .specd/tasks/$TASK_NAME/FEATURE.md
24
- cat .specd/tasks/$TASK_NAME/CONTEXT.md
25
- cat .specd/tasks/$TASK_NAME/DECISIONS.md
26
- cat .specd/tasks/$TASK_NAME/STATE.md
27
- cat .specd/tasks/$TASK_NAME/config.json
24
+ cat $TASK_DIR/FEATURE.md
25
+ cat $TASK_DIR/CONTEXT.md
26
+ cat $TASK_DIR/DECISIONS.md
27
+ cat $TASK_DIR/STATE.md
28
+ cat $TASK_DIR/config.json
28
29
  ```
29
30
 
30
31
  ### Load If Exists
@@ -37,15 +38,15 @@ cat .specd/tasks/$TASK_NAME/config.json
37
38
 
38
39
  ```bash
39
40
  # Check and read optional files
40
- [ -f ".specd/tasks/$TASK_NAME/RESEARCH.md" ] && cat .specd/tasks/$TASK_NAME/RESEARCH.md
41
- [ -f ".specd/tasks/$TASK_NAME/ROADMAP.md" ] && cat .specd/tasks/$TASK_NAME/ROADMAP.md
42
- [ -f ".specd/tasks/$TASK_NAME/CHANGELOG.md" ] && cat .specd/tasks/$TASK_NAME/CHANGELOG.md
41
+ [ -f "$TASK_DIR/RESEARCH.md" ] && cat $TASK_DIR/RESEARCH.md
42
+ [ -f "$TASK_DIR/ROADMAP.md" ] && cat $TASK_DIR/ROADMAP.md
43
+ [ -f "$TASK_DIR/CHANGELOG.md" ] && cat $TASK_DIR/CHANGELOG.md
43
44
  ```
44
45
 
45
46
  ### Phase-Specific Context (when $PHASE is set)
46
47
 
47
48
  ```bash
48
- PHASE_DIR=".specd/tasks/$TASK_NAME/phases/phase-$(printf '%02d' $PHASE)"
49
+ PHASE_DIR="$TASK_DIR/phases/phase-$(printf '%02d' $PHASE)"
49
50
 
50
51
  # Read phase plan
51
52
  [ -f "$PHASE_DIR/PLAN.md" ] && cat "$PHASE_DIR/PLAN.md"
@@ -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>
@@ -8,7 +8,14 @@ Determine which task to work on.
8
8
  Use as task name. Normalize to kebab-case (lowercase, hyphens).
9
9
 
10
10
  ```bash
11
- [ -d ".specd/tasks/$ARGUMENTS" ] || { echo "not found"; exit 1; }
11
+ # Check tasks/ first, fall back to features/ for backwards compat
12
+ if [ -d ".specd/tasks/$ARGUMENTS" ]; then
13
+ TASK_DIR=".specd/tasks/$ARGUMENTS"
14
+ elif [ -d ".specd/features/$ARGUMENTS" ]; then
15
+ TASK_DIR=".specd/features/$ARGUMENTS"
16
+ else
17
+ echo "not found"; exit 1
18
+ fi
12
19
  ```
13
20
 
14
21
  **If task not found:**
@@ -19,9 +26,9 @@ Available tasks:
19
26
  ```
20
27
 
21
28
  ```bash
22
- ls -d .specd/tasks/*/ 2>/dev/null | while read dir; do
29
+ { ls -d .specd/tasks/*/ 2>/dev/null; ls -d .specd/features/*/ 2>/dev/null; } | while read dir; do
23
30
  basename "$dir"
24
- done
31
+ done | sort -u
25
32
  ```
26
33
 
27
34
  End workflow.
@@ -30,8 +37,8 @@ End workflow.
30
37
  Scan for in-progress tasks:
31
38
 
32
39
  ```bash
33
- # List task directories with config.json
34
- for dir in .specd/tasks/*/config.json; do
40
+ # List task directories with config.json (check both locations)
41
+ for dir in .specd/tasks/*/config.json .specd/features/*/config.json; do
35
42
  [ -f "$dir" ] && echo "$dir"
36
43
  done
37
44
  ```
@@ -10,17 +10,25 @@ Check that a task directory exists with required files.
10
10
  **Basic validation (all workflows):**
11
11
 
12
12
  ```bash
13
- # Check task directory exists
14
- [ -d ".specd/tasks/$TASK_NAME" ] || { echo "not found"; exit 1; }
13
+ # Check task directory exists (tasks/ preferred, features/ for backwards compat)
14
+ if [ -d ".specd/tasks/$TASK_NAME" ]; then
15
+ TASK_DIR=".specd/tasks/$TASK_NAME"
16
+ elif [ -d ".specd/features/$TASK_NAME" ]; then
17
+ TASK_DIR=".specd/features/$TASK_NAME"
18
+ else
19
+ echo "not found"; exit 1
20
+ fi
15
21
 
16
22
  # Check required files
17
- [ -f ".specd/tasks/$TASK_NAME/FEATURE.md" ] || { echo "missing FEATURE.md"; exit 1; }
18
- [ -f ".specd/tasks/$TASK_NAME/CONTEXT.md" ] || { echo "missing CONTEXT.md"; exit 1; }
19
- [ -f ".specd/tasks/$TASK_NAME/DECISIONS.md" ] || { echo "missing DECISIONS.md"; exit 1; }
20
- [ -f ".specd/tasks/$TASK_NAME/STATE.md" ] || { echo "missing STATE.md"; exit 1; }
21
- [ -f ".specd/tasks/$TASK_NAME/config.json" ] || { echo "missing config.json"; exit 1; }
23
+ [ -f "$TASK_DIR/FEATURE.md" ] || { echo "missing FEATURE.md"; exit 1; }
24
+ [ -f "$TASK_DIR/CONTEXT.md" ] || { echo "missing CONTEXT.md"; exit 1; }
25
+ [ -f "$TASK_DIR/DECISIONS.md" ] || { echo "missing DECISIONS.md"; exit 1; }
26
+ [ -f "$TASK_DIR/STATE.md" ] || { echo "missing STATE.md"; exit 1; }
27
+ [ -f "$TASK_DIR/config.json" ] || { echo "missing config.json"; exit 1; }
22
28
  ```
23
29
 
30
+ **`$TASK_DIR` is now set** — use it in all subsequent file references instead of hardcoding `.specd/tasks/$TASK_NAME`.
31
+
24
32
  **If task not found:**
25
33
  ```
26
34
  Task '{name}' not found.
@@ -40,10 +48,10 @@ Run /specd:discuss {name} to rebuild context.
40
48
 
41
49
  ```bash
42
50
  # Check phases exist (for execute/review)
43
- [ -d ".specd/tasks/$TASK_NAME/phases" ] || { echo "no phases"; exit 1; }
51
+ [ -d "$TASK_DIR/phases" ] || { echo "no phases"; exit 1; }
44
52
 
45
53
  # Check ROADMAP exists (for execute/review)
46
- [ -f ".specd/tasks/$TASK_NAME/ROADMAP.md" ] || { echo "no roadmap"; exit 1; }
54
+ [ -f "$TASK_DIR/ROADMAP.md" ] || { echo "no roadmap"; exit 1; }
47
55
  ```
48
56
 
49
57
  **If no phases:**
@@ -57,8 +65,8 @@ Run /specd:plan {name} to create phases.
57
65
 
58
66
  ```bash
59
67
  # Check optional files
60
- [ -f ".specd/tasks/$TASK_NAME/RESEARCH.md" ] && echo "has_research"
61
- [ -f ".specd/tasks/$TASK_NAME/ROADMAP.md" ] && echo "has_roadmap"
68
+ [ -f "$TASK_DIR/RESEARCH.md" ] && echo "has_research"
69
+ [ -f "$TASK_DIR/ROADMAP.md" ] && echo "has_roadmap"
62
70
  ```
63
71
 
64
72
  </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 |