@blackbelt-technology/pi-dashboard-openspec-workflow 0.5.4
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/.pi/skills/fix-worktree-opsx-skills-not-created/SKILL.md +26 -0
- package/.pi/skills/pre-scaffold-openspec-coherence-check/SKILL.md +37 -0
- package/.pi/skills/reverse-spec-from-code/SKILL.md +184 -0
- package/.pi/skills/reverse-spec-from-code/prompts/auditor.md +31 -0
- package/.pi/skills/reverse-spec-from-code/prompts/discovery.md +44 -0
- package/.pi/skills/reverse-spec-from-code/prompts/generator.md +70 -0
- package/.pi/skills/spec-coherence-check/SKILL.md +496 -0
- package/.pi/skills/spec-coherence-check/references/proposal-queue-schema.md +121 -0
- package/README.md +34 -0
- package/package.json +37 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "fix-worktree-opsx-skills-not-created"
|
|
3
|
+
description: "Diagnose/fix worktrees missing the generated openspec-* (opsx) skills after worktreeInit. Root cause: bare `npx openspec` can resolve a squatted registry stub instead of the real CLI."
|
|
4
|
+
version: 1
|
|
5
|
+
created: "2026-07-13"
|
|
6
|
+
updated: "2026-07-13"
|
|
7
|
+
---
|
|
8
|
+
## When to Use
|
|
9
|
+
Use when a git worktree lacks the OpenSpec experimental-workflow skills (.pi/skills/openspec-explore, openspec-new-change, etc.), the /opsx: slash commands are missing, or openspec-apply-change stalls in a worktree. Also when auditing the .pi/settings.json worktreeInit hook.
|
|
10
|
+
|
|
11
|
+
## Procedure
|
|
12
|
+
1. Confirm the skills are GENERATED, not committed: `.pi/.gitignore` has `skills/openspec-*/**` (only `openspec-shared` is tracked). So every fresh worktree starts without them and must regenerate via `openspec init`.
|
|
13
|
+
2. Know the CLI package: the `openspec` binary is provided by the SCOPED package `@fission-ai/openspec` (declared in packages/server, hoisted to root node_modules/.bin/openspec). The BARE name `openspec` on npm is a squatted `0.0.0` stub that does nothing.
|
|
14
|
+
3. Root cause of silent failure: worktreeInit ran `npx openspec init ...`. When the local .bin/openspec isn't resolvable from the worktree root (hoisting/install timing/npx cache), bare `npx openspec` fetches `openspec@0.0.0` → init creates nothing → no opsx skills, while the `&&` chain still exits 0.
|
|
15
|
+
4. Fix: in .pi/settings.json worktreeInit.run.command, call the scoped package explicitly: `npx @fission-ai/openspec init --tools pi --force`. npx then resolves the local install (or fetches the CORRECT scoped package) and can never hit the 0.0.0 stub.
|
|
16
|
+
5. Verify: fresh worktree → `npx @fission-ai/openspec init --tools pi --force` → `ls .pi/skills/ | grep openspec-` shows 8 generated skills + openspec-shared (9 total). CLI prints `8 skills and 8 commands in .pi/` and `/opsx:new`.
|
|
17
|
+
6. To backfill an existing broken worktree: cd into it and run `npx @fission-ai/openspec init --tools pi --force` (safe — the openspec-* dirs are gitignored so this won't dirty git).
|
|
18
|
+
|
|
19
|
+
## Pitfalls
|
|
20
|
+
- Don't use `npx --no-install @fission-ai/openspec` in a worktree that hasn't run `npm ci` yet — nothing is installed, so it errors. The worktreeInit chain runs `(npm ci || npm install)` FIRST, so plain `npx @fission-ai/openspec` is correct.
|
|
21
|
+
- The worktreeInit gate `test ! -d .pi/skills/openspec-explore` correctly re-triggers init when only the skills are missing (OR-chained), so the gate is fine — the bug was the command, not the gate.
|
|
22
|
+
- `openspec init --force` may rewrite tracked AGENTS.md/CLAUDE.md; the gitignored `.pi/skills/openspec-*` dirs are safe to (re)generate.
|
|
23
|
+
|
|
24
|
+
## Verification
|
|
25
|
+
1. git worktree add --detach /tmp/wt develop; cd /tmp/wt; npx @fission-ai/openspec init --tools pi --force; test -d .pi/skills/openspec-explore && echo OK; git worktree remove --force /tmp/wt
|
|
26
|
+
2. npm view openspec version # → 0.0.0 (proves the bare-name stub); npx --no-install @fission-ai/openspec --version # → real 1.4.x from local install
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "pre-scaffold-openspec-coherence-check"
|
|
3
|
+
description: "Run before scaffolding any OpenSpec proposal in the project to catch duplicates of archived work and contradictions with already-shipped architecture. Always run when about to create openspec/changes/<name>/ (proposal.md/design.md/tasks.md), especially for proposals touching any subsystem with a recent archive entry. Skipping this check produces stale proposals that duplicate archived work and contradict shipped architecture. Triggers: 'scaffold OpenSpec', 'write a proposal', 'create change', 'openspec change new'."
|
|
4
|
+
version: 1
|
|
5
|
+
created: "2026-06-13"
|
|
6
|
+
updated: "2026-06-13"
|
|
7
|
+
---
|
|
8
|
+
## When to Use
|
|
9
|
+
Use before scaffolding any new OpenSpec change in this project, regardless of whether the topic feels novel. Two of the most damaging mistakes the assistant has made are (a) re-proposing work that already shipped and was archived, and (b) basing claims about current code on stale file-index harvests or grep results that miss the actual wiring idiom. This skill front-loads the cheap checks that would have caught both.
|
|
10
|
+
|
|
11
|
+
Trigger this skill when about to run any of: openspec change new, Write to openspec/changes/<name>/proposal.md, the openspec-new-change skill, the openspec-ff-change skill, or any drafted "## Why / ## What Changes" markdown that will become a proposal.
|
|
12
|
+
|
|
13
|
+
Do NOT skip even when the explore-mode conversation feels grounded. The Explore subagent harvests the file-index which can be days stale; the main agent's own grep can answer the wrong question (e.g. grepping for a consumer component when the wiring is inline).
|
|
14
|
+
|
|
15
|
+
## Procedure
|
|
16
|
+
1. Archive sweep: ls openspec/changes/archive/ | grep -iE ‘<topic-keywords>’. For tool-renderer / plugin-slot / MCP / ctx_* / context-mode topics specifically check for 2026-06-05-wire-tool-renderer-slot and 2026-06-05-add-ctx-tool-renderer. If any archive entry matches the topic, READ its proposal.md before writing a new one.
|
|
17
|
+
2. Active sweep: openspec list | grep -iE ‘<topic-keywords>’. Read any active change that overlaps so the new proposal does not collide on filename, capability, or scope.
|
|
18
|
+
3. Current-code verification (for behaviour claims): if the proposal says ‘X is not wired’, ‘Y never fires’, ‘Z falls through to Generic’, grep for the FUNCTIONAL pattern not just the named component. For tool-renderer claims specifically: grep -rn 'getClaims.*tool-renderer\\|forToolName' packages/client/src/components/ToolCallStep.tsx and read the current dispatch block (lines 90–120). The slot wiring inlines useSlotRegistryOrNull + forToolName + claimShouldRender; the ToolRendererSlot consumer component is unused, but that does NOT mean the slot is unwired.
|
|
19
|
+
4. Slot-prop contract check: cat packages/shared/src/dashboard-plugin/slot-props.ts and read SlotPropsMap[‘<slot>’]. Confirm the required fields (every slot requires pluginContext: AnyPluginContext) and the optional fields. Do not invent a contract.
|
|
20
|
+
5. Registry check (built-in renderers): cat packages/client/src/components/tool-renderers/registry.ts. The ctx_* family is mapped to a single CtxToolRenderer with a ctx_-prefix safety net for new tool names. Honour this architecture choice unless explicitly proposing to revisit it.
|
|
21
|
+
6. Architecture-choice review: when the topic intersects an existing implementation, search recent commits with git log --oneline --since=<30 days> -- <relevant paths> to understand which design the team picked and the rationale. The choice between core built-in vs plugin for ctx_* was DELIBERATE (high-frequency tool, hot path); do not propose to reverse it without an explicit justification section.
|
|
22
|
+
7. Optional but recommended: run the spec-coherence-check skill (project skill) which sweeps all active proposals for staleness, conflicts, and obsolescence against the current codebase and archived changes. Treat its output as authoritative.
|
|
23
|
+
|
|
24
|
+
## Pitfalls
|
|
25
|
+
- Trusting an Explore subagent that read only the file-index. The file-index can lag commits by days; for any claim about CURRENT code behaviour, verify against the source tree directly.
|
|
26
|
+
- Misreading grep results: 'rg ToolRendererSlot returns no hits' is technically correct but does NOT imply 'plugin tool-renderer claims do not fire'. The wiring may be inline. Always grep for the FUNCTIONAL identifier (getClaims, forToolName) not just the named component.
|
|
27
|
+
- Skipping the archive sweep because the topic feels new. Topics that already shipped get archived under YYYY-MM-DD-prefixed folder names; ls openspec/changes/archive/ once, costs nothing.
|
|
28
|
+
- Inventing a slot prop contract from memory. Every plugin slot in slot-props.ts requires pluginContext: AnyPluginContext on top of the slot-specific fields. Missing this in a spec is a silent gap.
|
|
29
|
+
- Re-proposing a plugin-based architecture without acknowledging the team chose core built-in (commit 858464d0 for ctx_*). The proposal must explicitly argue why the existing choice should be reversed; otherwise it contradicts shipped reality.
|
|
30
|
+
- Pushing a proposal commit straight to develop without running these checks. develop accumulates contributions quickly; a stale proposal there gets cleaned up by others (which is what happened to openspec/changes/wire-tool-renderer-slot/ in commit e4e63989 — someone deleted my folder upstream, and I had to revert the rest).
|
|
31
|
+
|
|
32
|
+
## Verification
|
|
33
|
+
1. The archive sweep ran and either returned no matches OR I read every matching proposal.md and either align with it (delta-style change) or explicitly argue why a fresh proposal is needed.
|
|
34
|
+
2. For every behaviour claim in the proposal's ## Why section, I have a direct grep / cat result from current code that supports it, not a recollection.
|
|
35
|
+
3. The proposal's ## What Changes section does not contradict any code in packages/client/src/components/tool-renderers/registry.ts, packages/client/src/components/ToolCallStep.tsx, or packages/shared/src/dashboard-plugin/slot-props.ts.
|
|
36
|
+
4. If proposing a new capability name, it does not collide with any folder under openspec/changes/ or openspec/changes/archive/. Specifically: openspec/changes/<name>/ does not exist AND openspec/changes/archive/*-<name>/ does not exist.
|
|
37
|
+
5. openspec validate <change-name> passes (catches structural issues but not contradictions — the above checks catch those).
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: reverse-spec-from-code
|
|
3
|
+
description: Reverse-generate OpenSpec capability specs (openspec/specs/<cap>/spec.md) from existing code that lacks them, using parallel subagents, to enrich the kb_search corpus. Discovers capability boundaries in a target directory/package, fans out one blind generator per capability that follows the behavioral contract ACROSS file boundaries, audits each generated spec against the actual code for hallucinations, writes to a scratch dir, and promotes to openspec/specs/ only on user confirm. Use on "reverse-engineer specs from this package", "generate specs from code", "backfill openspec specs", "spec this code for the KB", "document <package> as openspec specs".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# reverse-spec-from-code
|
|
7
|
+
|
|
8
|
+
Turn spec-less code into OpenSpec capability specs so `kb_search` has high-signal,
|
|
9
|
+
consistently-formatted behavioral documents to index. Tuned via a blind
|
|
10
|
+
generate→judge loop against 6 real specs: requirement coverage 97%, scenario
|
|
11
|
+
coverage 91% (see `docs/research/reverse-spec-from-code.md` for the tuning record
|
|
12
|
+
+ a model-loss test across opus / deepseek-flash / haiku).
|
|
13
|
+
|
|
14
|
+
> Scratch MUST live OUTSIDE `openspec/` (kb indexes `openspec/`). Use the
|
|
15
|
+
> gitignored repo-root dir `.reverse-spec-scratch/` — otherwise every draft
|
|
16
|
+
> pollutes `kb_search` with duplicate spec chunks. Promotion MOVES the file
|
|
17
|
+
> into `openspec/specs/` (the only kb-indexed copy).
|
|
18
|
+
|
|
19
|
+
## When to use
|
|
20
|
+
|
|
21
|
+
- A package/directory under `packages/` has behavior but no `openspec/specs/<cap>/spec.md`.
|
|
22
|
+
- You want to enrich `kb_search` (it indexes `openspec/` markdown) with behavioral specs.
|
|
23
|
+
- An existing spec is stale and you want a code-current reconciliation (`--refresh`).
|
|
24
|
+
|
|
25
|
+
Skip for a single trivial file, or when the capability already has an accurate spec.
|
|
26
|
+
|
|
27
|
+
## Core principle (the lever that matters)
|
|
28
|
+
|
|
29
|
+
**A capability's contract is not confined to one file.** The single biggest
|
|
30
|
+
quality driver is making each generator FOLLOW the behavioral contract across
|
|
31
|
+
file boundaries: every emitted message/event, registry write, spawned/killed
|
|
32
|
+
process, config read, or DOM attribute is a contract with another component and
|
|
33
|
+
must be spec'd too. In tuning this moved requirement coverage from 40% to 95% on
|
|
34
|
+
the cross-cutting capability. The generator prompt (`prompts/generator.md`)
|
|
35
|
+
enforces this in STEP 1 — do not weaken it.
|
|
36
|
+
|
|
37
|
+
## Fitness, honestly
|
|
38
|
+
|
|
39
|
+
"Match an existing spec" is a PROXY, not the goal. Real specs drift from code.
|
|
40
|
+
The goal is a spec that accurately describes **current** code and is searchable.
|
|
41
|
+
Target: high requirement coverage + **zero code-ungrounded hallucination**.
|
|
42
|
+
Code-current divergence from a stale spec is a win, not a miss.
|
|
43
|
+
|
|
44
|
+
## Procedure
|
|
45
|
+
|
|
46
|
+
1. **Resolve target + scope.** User names a directory/package (e.g. `packages/server`)
|
|
47
|
+
and optionally a single capability. Confirm the target path exists.
|
|
48
|
+
|
|
49
|
+
2. **Discover capability boundaries.** Spawn ONE discovery subagent
|
|
50
|
+
(`prompts/discovery.md`, model `@compact` is fine) that clusters the target's
|
|
51
|
+
files into capabilities using the directory `AGENTS.md` tree (`kb agents <dir>`,
|
|
52
|
+
`kb_search --doc-type agents`) + grep. It returns a manifest:
|
|
53
|
+
`[{ capability, purpose_hint, files[] }]`. For a single-capability target you
|
|
54
|
+
may skip this and build the manifest by hand.
|
|
55
|
+
|
|
56
|
+
3. **Skip already-specced capabilities.** For each manifest entry, if
|
|
57
|
+
`openspec/specs/<capability>/spec.md` exists and `--refresh` was NOT requested,
|
|
58
|
+
drop it (report as skipped). With `--refresh`, keep it and reconcile.
|
|
59
|
+
|
|
60
|
+
4. **Generate in parallel (blind).** Fan out ONE generator subagent per remaining
|
|
61
|
+
capability IN A SINGLE MESSAGE (`prompts/generator.md`). Each reads code only
|
|
62
|
+
— never an existing spec — and writes `.reverse-spec-scratch/<capability>/spec.md`.
|
|
63
|
+
Pass capability, purpose_hint, start files, and the output path. Model: a
|
|
64
|
+
fast/cheap model (`@fast`/`@compact`) is viable AS LONG AS the format gate
|
|
65
|
+
(step 6.5) and the `@research` auditor run — see "Model choice" below.
|
|
66
|
+
|
|
67
|
+
5. **Audit in parallel (code-grounding).** Fan out ONE auditor subagent per
|
|
68
|
+
generated spec IN A SINGLE MESSAGE (`prompts/auditor.md`, model `@research`).
|
|
69
|
+
Each verifies the generated spec against the ACTUAL code and returns strict
|
|
70
|
+
JSON: `hallucinated_requirements[]` (in spec, not in code),
|
|
71
|
+
`missing_behaviors[]` (in code, not in spec), `format_ok`, `verdict`
|
|
72
|
+
(pass|revise). No real spec is needed — the code is the oracle.
|
|
73
|
+
|
|
74
|
+
6. **Revise if needed.** For any spec with `verdict: revise`, re-spawn its
|
|
75
|
+
generator with the auditor's findings appended (remove the listed
|
|
76
|
+
hallucinations, add the listed missing behaviors). One revise pass is usually
|
|
77
|
+
enough; re-audit only if the first audit was severe.
|
|
78
|
+
|
|
79
|
+
6.5. **Format gate (`openspec validate`) — HARD, deterministic.** `openspec
|
|
80
|
+
validate` only reads specs under `openspec/specs/`, so validate each scratch
|
|
81
|
+
spec via a throwaway id, then delete it:
|
|
82
|
+
```bash
|
|
83
|
+
for c in <cap1> <cap2> ...; do
|
|
84
|
+
d="openspec/specs/_rsfc-val-$c"; mkdir -p "$d"
|
|
85
|
+
cp ".reverse-spec-scratch/$c/spec.md" "$d/spec.md"
|
|
86
|
+
openspec validate "_rsfc-val-$c" --type spec 2>&1 | grep -qi "is valid" \
|
|
87
|
+
&& echo "$c: VALID" || echo "$c: INVALID"
|
|
88
|
+
rm -rf "$d"
|
|
89
|
+
done
|
|
90
|
+
```
|
|
91
|
+
Any spec that is INVALID is treated exactly like `verdict: revise` with reason
|
|
92
|
+
"format: openspec validate failed" — re-spawn its generator emphasizing the
|
|
93
|
+
FORMAT rule (no tables, no bold `**Scenario:**`, no numbered requirements),
|
|
94
|
+
then re-run this gate. A spec that fails validate is NEVER promoted. Cheap
|
|
95
|
+
generator models fail here most often — this gate is what makes them safe.
|
|
96
|
+
|
|
97
|
+
7. **Present + promote on confirm.** Show the user: per-capability spec path,
|
|
98
|
+
requirement count, and audit + validate summary (skipped / passed / revised /
|
|
99
|
+
valid). Only specs that BOTH audit-pass AND validate-pass are promotable. Use
|
|
100
|
+
`ask_user` (confirm or multiselect) to choose which to promote. On confirm,
|
|
101
|
+
MOVE `.reverse-spec-scratch/<cap>/spec.md` → `openspec/specs/<cap>/spec.md`
|
|
102
|
+
(create the dir; move, don't copy, so no duplicate stays under an indexed
|
|
103
|
+
root). NEVER write `openspec/specs/` without explicit confirm.
|
|
104
|
+
|
|
105
|
+
8. **Verify KB indexing.** After promotion, run `kb_search "<a phrase from a new
|
|
106
|
+
spec>"` to confirm the spec is discoverable. Report the result.
|
|
107
|
+
|
|
108
|
+
## Subagent routing
|
|
109
|
+
|
|
110
|
+
| Role | Prompt | Model | Access | Parallel |
|
|
111
|
+
|------------|-----------------------|------------------|-------------|----------|
|
|
112
|
+
| discovery | prompts/discovery.md | `@compact` | read-only | 1 pass |
|
|
113
|
+
| generator | prompts/generator.md | `@research` (max quality) or `@fast`/`@compact` (cheap; needs gate) | read+write (scratch) | N in one message |
|
|
114
|
+
| auditor | prompts/auditor.md | `@research` (keep strong — the safety net) | read-only | N in one message |
|
|
115
|
+
|
|
116
|
+
Fan out generators (then auditors) as multiple `Agent` calls in a SINGLE message
|
|
117
|
+
so they run concurrently. One capability per subagent — isolated context.
|
|
118
|
+
|
|
119
|
+
### Model choice (from the model-loss test in docs/research/reverse-spec-from-code.md)
|
|
120
|
+
|
|
121
|
+
Judge/generator swap on the 6 ground-truth specs (judge held `@research`):
|
|
122
|
+
|
|
123
|
+
| generator | req cov | scen cov | `openspec validate` |
|
|
124
|
+
|---|---|---|---|
|
|
125
|
+
| opus (`@research`) | 97% | 91% | 6/6 |
|
|
126
|
+
| deepseek-flash (`@fast`) + format directive | 96% | 90% | 6/6 |
|
|
127
|
+
| haiku (`@compact`), no directive | 88% | 81% | 3/6 |
|
|
128
|
+
|
|
129
|
+
- "fast" ≠ "weak": `@fast` (deepseek-flash) nearly matched opus on coverage.
|
|
130
|
+
- Cheap models lose most on FORMAT and on the HARDEST cross-file capabilities —
|
|
131
|
+
the format gate (6.5) fixes the former; extra revise cycles fix the latter.
|
|
132
|
+
- Recommended cost config: `@fast` generator + format gate + `@research` auditor
|
|
133
|
+
+ revise loop ≈ opus quality at a fraction of the cost. Keep the auditor strong;
|
|
134
|
+
it is the hallucination safety net regardless of generator model.
|
|
135
|
+
|
|
136
|
+
## Output format (what generators produce)
|
|
137
|
+
|
|
138
|
+
Full-form OpenSpec spec (post-archive shape, NOT the `## ADDED Requirements` delta):
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
# <capability> Specification
|
|
142
|
+
|
|
143
|
+
## Purpose
|
|
144
|
+
<1-3 sentences>
|
|
145
|
+
|
|
146
|
+
## Requirements
|
|
147
|
+
### Requirement: <short imperative name>
|
|
148
|
+
The <subject> SHALL <behavioral obligation>.
|
|
149
|
+
|
|
150
|
+
#### Scenario: <name>
|
|
151
|
+
- **WHEN** <trigger>
|
|
152
|
+
- **THEN** <observable outcome>
|
|
153
|
+
- **AND** <optional>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Pitfalls
|
|
157
|
+
|
|
158
|
+
- **Under-scoped input** — feeding one file to a cross-cutting capability caps
|
|
159
|
+
coverage low no matter how good the prompt. Discovery must gather ALL files;
|
|
160
|
+
the generator must follow references. This is the #1 failure mode.
|
|
161
|
+
- **Over-splitting** — without a grouping rule the generator emits many tiny
|
|
162
|
+
requirements. Prompt targets 3-8 grouped requirements with rich scenarios.
|
|
163
|
+
- **Visual/detail invention** — UI capabilities tempt the model to describe
|
|
164
|
+
pixels/colors it did not confirm. The prompt forbids unconfirmed detail; the
|
|
165
|
+
auditor catches the rest.
|
|
166
|
+
- **Clobbering real specs / kb pollution** — scratch-first in the gitignored
|
|
167
|
+
repo-root `.reverse-spec-scratch/` (NEVER under `openspec/`, which kb indexes),
|
|
168
|
+
promote (move) only on confirm.
|
|
169
|
+
- **Chasing 100% match to an existing spec** — the spec may be stale. The code
|
|
170
|
+
is the oracle; the auditor checks the code, not the old spec.
|
|
171
|
+
- **Cheap-model format breaks** — smaller/faster generators (`@fast`/`@compact`)
|
|
172
|
+
tend to emit markdown tables, bold `**Scenario:**`, or numbered requirements
|
|
173
|
+
that FAIL `openspec validate`. The format directive in `prompts/generator.md`
|
|
174
|
+
plus the step-6.5 validate gate catch this; never promote a cheap-model spec
|
|
175
|
+
without running the gate.
|
|
176
|
+
|
|
177
|
+
## Verification
|
|
178
|
+
|
|
179
|
+
- Format gate (step 6.5) returned VALID for every promoted spec
|
|
180
|
+
(`openspec validate <capability> --type spec` → "is valid"). This is a HARD
|
|
181
|
+
gate, not an advisory check — an invalid spec is never promoted.
|
|
182
|
+
- Auditor returned `verdict: pass` (or `revise` was resolved) for every promoted spec.
|
|
183
|
+
- `kb_search "<phrase from a new spec>"` returns the new spec.
|
|
184
|
+
- No file under `openspec/specs/` was written without user confirm.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Auditor prompt (code-grounding check)
|
|
2
|
+
|
|
3
|
+
The oracle is the CODE, not any existing spec. Fill {PLACEHOLDERS}. Model: @research.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are auditing a GENERATED OpenSpec spec against the ACTUAL source code it
|
|
8
|
+
claims to describe. The code is the source of truth. Judge by MEANING.
|
|
9
|
+
|
|
10
|
+
CAPABILITY: {CAPABILITY}
|
|
11
|
+
GENERATED SPEC: {GEN_PATH}
|
|
12
|
+
SOURCE FILES: {SOURCE_FILES} (read these, and grep/Read any other file the spec references)
|
|
13
|
+
|
|
14
|
+
Read the generated spec, then read the code. For every Requirement and Scenario
|
|
15
|
+
in the spec, verify it is grounded in real code behavior. Then check the code for
|
|
16
|
+
significant behaviors the spec omitted (emitted messages, error paths, cleanup,
|
|
17
|
+
cross-component contracts).
|
|
18
|
+
|
|
19
|
+
Output STRICT JSON ONLY (no prose, no code fence), exactly these keys:
|
|
20
|
+
{
|
|
21
|
+
"capability": "{CAPABILITY}",
|
|
22
|
+
"hallucinated_requirements": ["<spec requirement/scenario with NO basis in the code>"],
|
|
23
|
+
"missing_behaviors": ["<significant code behavior absent from the spec>"],
|
|
24
|
+
"format_ok": <true|false, has # <cap> Specification + ## Purpose + ## Requirements + Requirement/Scenario WHEN/THEN>,
|
|
25
|
+
"verdict": "<pass|revise>",
|
|
26
|
+
"notes": "<2-3 sentence diagnosis>"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
verdict = "revise" if there is any hallucinated requirement OR a missing behavior
|
|
30
|
+
that is central to the capability; otherwise "pass". Minor omissions do not force
|
|
31
|
+
a revise.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Discovery prompt (capability clustering)
|
|
2
|
+
|
|
3
|
+
Fill {PLACEHOLDERS}. Model: @compact is fine. Read-only.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are mapping a code target into OpenSpec CAPABILITY boundaries so each can be
|
|
8
|
+
spec'd independently.
|
|
9
|
+
|
|
10
|
+
TARGET: {TARGET_DIR}
|
|
11
|
+
|
|
12
|
+
STEP 1 — Read the directory's per-file record: run `kb agents {TARGET_DIR}` (or
|
|
13
|
+
read {TARGET_DIR}/AGENTS.md) for the one-line purpose of each file. Use
|
|
14
|
+
`kb_search --doc-type agents "<topic>"` to find related rows. Fall back to `ls`
|
|
15
|
+
+ grep only if the tree misses.
|
|
16
|
+
|
|
17
|
+
STEP 2 — Cluster files into capabilities. A capability is a distinct
|
|
18
|
+
behavioral unit (usually 1-4 closely-related files that together implement one
|
|
19
|
+
externally-observable behavior). Prefer the granularity of existing
|
|
20
|
+
`openspec/specs/<cap>/` names (kebab-case, behavior-scoped, e.g. `ws-ping-pong`,
|
|
21
|
+
`server-cors`, `force-kill-handler`). One file may host more than one capability;
|
|
22
|
+
one capability may span files — cluster by BEHAVIOR, not by file.
|
|
23
|
+
|
|
24
|
+
AVOID over-fragmentation: do NOT emit several capabilities that all share the
|
|
25
|
+
SAME single source file (e.g. five capabilities all pointing at client.ts). If
|
|
26
|
+
one file hosts many behaviors, prefer ONE capability for that file (or split
|
|
27
|
+
only when a behavior clearly has its own file set). Redundant same-file
|
|
28
|
+
capabilities would spawn duplicate generators reading identical code.
|
|
29
|
+
|
|
30
|
+
STEP 3 — For each capability, note whether `openspec/specs/<capability>/spec.md`
|
|
31
|
+
already exists (check the filesystem).
|
|
32
|
+
|
|
33
|
+
Output STRICT JSON ONLY (no prose, no code fence):
|
|
34
|
+
{
|
|
35
|
+
"target": "{TARGET_DIR}",
|
|
36
|
+
"capabilities": [
|
|
37
|
+
{
|
|
38
|
+
"capability": "<kebab-case-name>",
|
|
39
|
+
"purpose_hint": "<one line: the externally-observable behavior>",
|
|
40
|
+
"files": ["<path>", "..."],
|
|
41
|
+
"existing_spec": <true|false>
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Generator prompt (v3 — shipped)
|
|
2
|
+
|
|
3
|
+
Fill the {PLACEHOLDERS} and pass as the subagent task. Model: @research, @coding,
|
|
4
|
+
or a fast/cheap model (@fast / @compact). The FORMAT rule below is a hard gate
|
|
5
|
+
that keeps cheaper models valid — a model-loss test showed a cheap generator
|
|
6
|
+
drops from 3/6 to 6/6 `openspec validate` passes once this directive is present.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
You are reverse-engineering an OpenSpec capability specification from existing
|
|
11
|
+
source code, for a knowledge base that must accurately describe CURRENT behavior.
|
|
12
|
+
|
|
13
|
+
CAPABILITY: {CAPABILITY}
|
|
14
|
+
SCOPE: {PURPOSE_HINT}
|
|
15
|
+
START FROM: {SOURCE_FILES}
|
|
16
|
+
You MAY and SHOULD read beyond these files. Use grep/Read to follow the
|
|
17
|
+
capability across boundaries.
|
|
18
|
+
|
|
19
|
+
STEP 1 — Map the capability's FULL surface (most important step):
|
|
20
|
+
- Read the start files.
|
|
21
|
+
- A capability's contract usually spans multiple files. Whenever the code
|
|
22
|
+
EMITS a message/event, WRITES to a registry/store, SETS a DOM attribute,
|
|
23
|
+
CALLS another module, READS config or package.json, or SPAWNS/KILLS a
|
|
24
|
+
process — that is an observable contract with ANOTHER component. grep the
|
|
25
|
+
repo for the other side and read it. Capture that behavior as a requirement
|
|
26
|
+
even though it lives in a different file.
|
|
27
|
+
- Include error paths, edge cases, cleanup/teardown, and default behavior.
|
|
28
|
+
|
|
29
|
+
STEP 2 — Write spec.md in EXACTLY this OpenSpec full-form format:
|
|
30
|
+
|
|
31
|
+
# {CAPABILITY} Specification
|
|
32
|
+
|
|
33
|
+
## Purpose
|
|
34
|
+
<1-3 sentences: what this capability does and why it exists>
|
|
35
|
+
|
|
36
|
+
## Requirements
|
|
37
|
+
### Requirement: <short imperative name>
|
|
38
|
+
The <subject> SHALL <behavioral obligation>. <optional clarifying sentences>
|
|
39
|
+
|
|
40
|
+
#### Scenario: <short name>
|
|
41
|
+
- **WHEN** <trigger / precondition>
|
|
42
|
+
- **THEN** <required observable outcome>
|
|
43
|
+
- **AND** <additional outcome, optional>
|
|
44
|
+
|
|
45
|
+
RULES:
|
|
46
|
+
- SHALL statements describe externally-observable behavior (inputs, outputs,
|
|
47
|
+
side effects, messages, errors), never implementation detail (no variable
|
|
48
|
+
names, no line numbers).
|
|
49
|
+
- GROUP related obligations under ONE Requirement with multiple Scenarios. Aim
|
|
50
|
+
for the FEWEST requirements that still separate genuinely distinct
|
|
51
|
+
obligations — typically 3-8. Do not split one behavior into many tiny reqs.
|
|
52
|
+
- Every Requirement has at least one concrete Scenario using real values
|
|
53
|
+
(intervals, ports, signals, message names, error codes, headers) from code.
|
|
54
|
+
- Derive requirements ONLY from behavior present in the code. Describe what the
|
|
55
|
+
code ACTUALLY does now — do not invent, and do not soften to match older
|
|
56
|
+
assumptions.
|
|
57
|
+
- Do NOT describe visual, layout, or detail specifics (colors, pixel sizes,
|
|
58
|
+
exact segment stacking) that you did not directly confirm in the code. When
|
|
59
|
+
unsure, describe behavior at the level the code supports.
|
|
60
|
+
- FORMAT IS A HARD GATE. Use EXACTLY these markers: `### Requirement: <name>`
|
|
61
|
+
(a heading, with NO leading number like "Requirement 1:") and `#### Scenario:
|
|
62
|
+
<name>` (a heading — NOT bold `**Scenario:**`, NOT a markdown table). Every
|
|
63
|
+
scenario body is `- **WHEN**` / `- **THEN**` / `- **AND**` bullet lines. A
|
|
64
|
+
spec that uses tables, bold scenario labels, or numbered requirements FAILS
|
|
65
|
+
`openspec validate` and is rejected. This is the #1 failure mode on
|
|
66
|
+
smaller/faster generator models — do not deviate.
|
|
67
|
+
- Cover the cross-component contracts you found in STEP 1.
|
|
68
|
+
- Output ONLY the spec.md content. Write it to {OUTPUT_PATH} with the Write
|
|
69
|
+
tool ({OUTPUT_PATH} is under the gitignored `.reverse-spec-scratch/`, NOT
|
|
70
|
+
under `openspec/`). Reply only "done".
|
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: spec-coherence-check
|
|
3
|
+
description: >-
|
|
4
|
+
Sweep all active OpenSpec proposals for staleness, conflicts, and obsolescence
|
|
5
|
+
against the current codebase and archived changes. Use when proposals may be
|
|
6
|
+
outdated, when checking cross-proposal conflicts, or before starting a batch
|
|
7
|
+
of implementations. Produces a gap-analysis report, updates a priority queue
|
|
8
|
+
file, and can auto-fix trivial issues or guide conversations for complex ones.
|
|
9
|
+
license: MIT
|
|
10
|
+
compatibility: Requires openspec CLI and git.
|
|
11
|
+
metadata:
|
|
12
|
+
author: robson
|
|
13
|
+
version: "1.0"
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
Analyze active OpenSpec proposals against the current codebase state,
|
|
17
|
+
detect staleness / conflicts / obsolescence, and orchestrate updates.
|
|
18
|
+
|
|
19
|
+
**Input**: Optional `--proposal <name>` for single-proposal mode.
|
|
20
|
+
No arguments = full sweep of all active proposals.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Phase 1: Sweep Report
|
|
25
|
+
|
|
26
|
+
### Step 1 — Gather context
|
|
27
|
+
|
|
28
|
+
**a) Get all active proposals:**
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
openspec list --json
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
If `--proposal <name>` was provided, filter to just that proposal.
|
|
35
|
+
|
|
36
|
+
**b) List all archived changes:**
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
ls openspec/changes/archive/
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Parse archive directory names to extract dates. Format is `YYYY-MM-DD-<name>`.
|
|
43
|
+
Extract the first 10 characters as the date string.
|
|
44
|
+
|
|
45
|
+
**c) Date each active proposal using this fallback chain:**
|
|
46
|
+
|
|
47
|
+
1. Git first-commit date:
|
|
48
|
+
```bash
|
|
49
|
+
git log --follow --diff-filter=A --format='%ai' -- "openspec/changes/<name>/proposal.md" | tail -1
|
|
50
|
+
```
|
|
51
|
+
Parse the date portion (first 10 chars: `YYYY-MM-DD`).
|
|
52
|
+
|
|
53
|
+
2. If empty (file is untracked), use filesystem birthtime:
|
|
54
|
+
- macOS: `stat -f "%SB" -t "%Y-%m-%d" "openspec/changes/<name>/proposal.md"`
|
|
55
|
+
- Linux: `stat -c "%W" "openspec/changes/<name>/proposal.md"` (convert epoch to date)
|
|
56
|
+
|
|
57
|
+
3. If still unknown, use the oldest archive date as a floor estimate.
|
|
58
|
+
|
|
59
|
+
**d) Read artifacts for each active proposal.**
|
|
60
|
+
|
|
61
|
+
Read only the files that exist — not all proposals have all artifacts:
|
|
62
|
+
- `openspec/changes/<name>/proposal.md` (always exists)
|
|
63
|
+
- `openspec/changes/<name>/design.md` (if exists)
|
|
64
|
+
- `openspec/changes/<name>/tasks.md` (if exists)
|
|
65
|
+
- `openspec/changes/<name>/specs/` directory (if exists)
|
|
66
|
+
|
|
67
|
+
From each proposal, extract and note:
|
|
68
|
+
- **Referenced files**: paths matching `src/...` in Impact and body text
|
|
69
|
+
- **Referenced capabilities**: from `### Modified Capabilities` and `### New Capabilities`
|
|
70
|
+
- **Assumptions**: statements in Context sections, Non-Goals, and design decisions
|
|
71
|
+
- **Files touched**: from `## Impact` section specifically
|
|
72
|
+
|
|
73
|
+
**e) Read relevant archived changes.**
|
|
74
|
+
|
|
75
|
+
For each active proposal, identify archives dated **after** its creation date.
|
|
76
|
+
For each such archive, read its `proposal.md` and extract:
|
|
77
|
+
- `## What Changes` — summary of modifications
|
|
78
|
+
- `## Capabilities` — look for `BREAKING` markers, `Modified`, `Removed` entries
|
|
79
|
+
- `## Impact` — files and components touched
|
|
80
|
+
|
|
81
|
+
Keep only archives whose Impact or Capabilities overlap with the proposal
|
|
82
|
+
being analyzed (same files or same capabilities).
|
|
83
|
+
|
|
84
|
+
### Step 2 — File existence detection
|
|
85
|
+
|
|
86
|
+
For each active proposal, extract all file paths from:
|
|
87
|
+
- The `## Impact` section (look for `src/...` patterns and filenames like `FooBar.tsx`)
|
|
88
|
+
- The body text of proposal.md and design.md
|
|
89
|
+
|
|
90
|
+
For each extracted path:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
find src/ -path "*<filename>" -o -name "<filename>" 2>/dev/null
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
If a referenced file does not exist anywhere in the codebase:
|
|
97
|
+
- Record issue: severity `stale`, autoFixable `true`
|
|
98
|
+
- Description: "Referenced file `<path>` no longer exists"
|
|
99
|
+
- Try to find where the functionality moved:
|
|
100
|
+
```bash
|
|
101
|
+
rg -l "<key-term-from-filename>" src/ --type ts
|
|
102
|
+
```
|
|
103
|
+
If a likely replacement is found, note it in the issue for auto-fix.
|
|
104
|
+
|
|
105
|
+
### Step 3 — Archive impact analysis
|
|
106
|
+
|
|
107
|
+
For each archived change that is dated after the proposal's creation:
|
|
108
|
+
|
|
109
|
+
Compare the archive's data against the proposal:
|
|
110
|
+
|
|
111
|
+
1. **File overlap**: Do the archive's Impact files intersect with the proposal's
|
|
112
|
+
Impact files? If yes, the proposal may reference outdated file state.
|
|
113
|
+
|
|
114
|
+
2. **Capability overlap**: Does the archive modify or remove capabilities that the
|
|
115
|
+
proposal lists under Modified Capabilities? If yes, the proposal's
|
|
116
|
+
assumptions about those capabilities may be invalid.
|
|
117
|
+
|
|
118
|
+
3. **BREAKING markers**: Does the archive contain `BREAKING` in its Capabilities
|
|
119
|
+
section for capabilities the proposal touches?
|
|
120
|
+
|
|
121
|
+
For each overlap found:
|
|
122
|
+
- If BREAKING marker present: severity `broken`, autoFixable `false`
|
|
123
|
+
- Description: "Archived change `<archive-name>` has BREAKING changes to
|
|
124
|
+
`<capability>` which this proposal modifies. Specifically: `<detail>`"
|
|
125
|
+
- If non-breaking file overlap: severity `stale`, autoFixable `true`
|
|
126
|
+
- Description: "File `<file>` was modified by `<archive-name>` after this
|
|
127
|
+
proposal was created. Impact section may be outdated."
|
|
128
|
+
|
|
129
|
+
### Step 4 — Concept validity check
|
|
130
|
+
|
|
131
|
+
For each proposal that has Context, Non-Goals, or Design assumptions sections,
|
|
132
|
+
extract key statements and verify them against the current codebase.
|
|
133
|
+
|
|
134
|
+
**What to check:**
|
|
135
|
+
|
|
136
|
+
- **"Currently X does Y"** statements — Read the relevant source file to confirm
|
|
137
|
+
X still does Y.
|
|
138
|
+
```bash
|
|
139
|
+
rg "<key pattern>" src/ --type ts -l
|
|
140
|
+
```
|
|
141
|
+
Then read the file to verify the claim.
|
|
142
|
+
|
|
143
|
+
- **Non-Goals that state "not doing Z"** — Check if Z has been implemented:
|
|
144
|
+
```bash
|
|
145
|
+
rg "<Z-related-pattern>" src/ --type ts -l
|
|
146
|
+
```
|
|
147
|
+
If Z now exists, the Non-Goal is invalidated.
|
|
148
|
+
|
|
149
|
+
- **Protocol message references** — Verify messages still exist:
|
|
150
|
+
```bash
|
|
151
|
+
rg "<message_type>" <protocol-source-files>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
- **Component references** — Verify components still exist:
|
|
155
|
+
```bash
|
|
156
|
+
find <components-dir>/ -name "<ComponentName>*"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
- **"Bridge does W"** statements — Check bridge still has that behavior:
|
|
160
|
+
```bash
|
|
161
|
+
rg "<W-pattern>" <source-dir>/ --type ts -l
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
For each invalidated statement:
|
|
165
|
+
- If it changes the design fundamentally (Non-Goal now implemented, core
|
|
166
|
+
assumption wrong): severity `broken`, autoFixable `false`
|
|
167
|
+
- Description: "Assumption '<quote>' is no longer true because `<evidence>`"
|
|
168
|
+
- If it's a minor reference (renamed variable, moved function):
|
|
169
|
+
severity `stale`, autoFixable `true`
|
|
170
|
+
|
|
171
|
+
### Step 5 — Obsolescence check
|
|
172
|
+
|
|
173
|
+
For each proposal, check whether the feature it introduces already exists:
|
|
174
|
+
|
|
175
|
+
1. Search for the New Capability name in existing specs:
|
|
176
|
+
```bash
|
|
177
|
+
ls openspec/specs/ | grep "<capability-keyword>"
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
2. Search for feature-specific keywords from the proposal title:
|
|
181
|
+
```bash
|
|
182
|
+
rg -l "<feature-keyword>" src/ --type ts
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
3. Check if implementation files the proposal plans to create already exist:
|
|
186
|
+
```bash
|
|
187
|
+
ls -la <planned-new-file-path> 2>/dev/null
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
If strong evidence the feature already exists:
|
|
191
|
+
- Record issue: severity `obsolete`
|
|
192
|
+
- Description: "This feature appears to already be implemented. Evidence:
|
|
193
|
+
`<file>` exists / spec `<name>` already covers this capability"
|
|
194
|
+
|
|
195
|
+
### Step 6 — Cross-proposal conflict detection
|
|
196
|
+
|
|
197
|
+
**Skip this step if running in single-proposal mode (`--proposal <name>`).**
|
|
198
|
+
|
|
199
|
+
Build a file-touch matrix. For each proposal, extract the files from its
|
|
200
|
+
Impact section. Then identify all files/capabilities touched by 2+ proposals.
|
|
201
|
+
|
|
202
|
+
For each overlap:
|
|
203
|
+
1. Read both proposals' descriptions of what they change in that file/capability
|
|
204
|
+
2. Assess if the changes are:
|
|
205
|
+
- **Additive** (both add new things, no conflict) — severity `low`
|
|
206
|
+
- **Potentially conflicting** (both modify the same area differently) — severity `medium`
|
|
207
|
+
- **Incompatible** (architectural assumptions clash) — severity `high`
|
|
208
|
+
|
|
209
|
+
3. For medium/high conflicts, suggest a resolution:
|
|
210
|
+
- Which proposal should go first?
|
|
211
|
+
- Does one establish infrastructure the other needs?
|
|
212
|
+
- Can scopes be adjusted to reduce overlap?
|
|
213
|
+
|
|
214
|
+
Record each conflict with:
|
|
215
|
+
- The proposal names involved
|
|
216
|
+
- The overlapping area (file or capability)
|
|
217
|
+
- Severity assessment
|
|
218
|
+
- Suggested resolution
|
|
219
|
+
|
|
220
|
+
### Step 7 — Priority scoring
|
|
221
|
+
|
|
222
|
+
For each proposal, calculate a priority score (lower = implement first):
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
Base = 50
|
|
226
|
+
|
|
227
|
+
SUBTRACT:
|
|
228
|
+
-20 status is "ok" (no issues, ready to implement)
|
|
229
|
+
-15 complexity is "trivial" (1-2 files, isolated)
|
|
230
|
+
-10 no cross-proposal conflicts
|
|
231
|
+
-10 no dependencies on other proposals
|
|
232
|
+
- 5 touches fewer than 5 files
|
|
233
|
+
|
|
234
|
+
ADD:
|
|
235
|
+
+20 status is "broken" (needs rework before implementable)
|
|
236
|
+
+15 other proposals depend on this one (infrastructure change)
|
|
237
|
+
+10 complexity is "fundamental" (architecture-level)
|
|
238
|
+
+ 5 has cross-proposal conflicts
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**Classify complexity:**
|
|
242
|
+
- `trivial`: 1-2 files, isolated fix, no protocol/architecture changes
|
|
243
|
+
- `minor`: small feature, well-scoped, < 5 files
|
|
244
|
+
- `major`: cross-cutting, multiple components, protocol changes
|
|
245
|
+
- `fundamental`: architecture-level, breaking changes
|
|
246
|
+
|
|
247
|
+
**Dependency override:** If proposal A should be done after proposal B
|
|
248
|
+
(because B establishes patterns/infrastructure A needs), then
|
|
249
|
+
A.priority MUST be higher (worse) than B.priority regardless of raw scores.
|
|
250
|
+
|
|
251
|
+
**Obsolete override:** If status is "obsolete", set priority = 999.
|
|
252
|
+
|
|
253
|
+
**Empty override:** If a change directory has no proposal.md or only an
|
|
254
|
+
empty directory, set status = "empty" and priority = 999.
|
|
255
|
+
|
|
256
|
+
Sort proposals by priority (ascending). This is the suggested
|
|
257
|
+
implementation order.
|
|
258
|
+
|
|
259
|
+
### Step 8 — Generate sweep report
|
|
260
|
+
|
|
261
|
+
Display the report to the user in this format:
|
|
262
|
+
|
|
263
|
+
```markdown
|
|
264
|
+
## Coherence Sweep Report — <YYYY-MM-DD>
|
|
265
|
+
|
|
266
|
+
### Summary
|
|
267
|
+
| Proposal | Status | Issues | Complexity | Priority | Created |
|
|
268
|
+
|----------|--------|--------|------------|----------|---------|
|
|
269
|
+
| name | ✅/⚠️/🔴/💀/📭 | N | trivial/minor/major/fundamental | N | YYYY-MM-DD |
|
|
270
|
+
|
|
271
|
+
Status legend: ✅ OK ⚠️ STALE 🔴 BROKEN 💀 OBSOLETE 📭 EMPTY
|
|
272
|
+
|
|
273
|
+
### Cross-Proposal Conflicts
|
|
274
|
+
| File/Area | Proposals | Severity | Suggested Resolution |
|
|
275
|
+
|-----------|-----------|----------|---------------------|
|
|
276
|
+
|
|
277
|
+
### Suggested Implementation Order
|
|
278
|
+
1. **name** (priority N) — reason
|
|
279
|
+
2. **name** (priority N) — reason
|
|
280
|
+
...
|
|
281
|
+
|
|
282
|
+
### Detailed Issues
|
|
283
|
+
|
|
284
|
+
(Show only for proposals with issues — skip ✅ OK proposals)
|
|
285
|
+
|
|
286
|
+
#### <proposal-name> (<status emoji>)
|
|
287
|
+
1. **[STALE]** Description
|
|
288
|
+
- Caused by: <archive-name or codebase change>
|
|
289
|
+
- Auto-fixable: yes
|
|
290
|
+
- Fix: update `<old>` → `<new>` in `<artifact>`
|
|
291
|
+
2. **[BROKEN]** Description
|
|
292
|
+
- Caused by: <archive-name>
|
|
293
|
+
- Auto-fixable: no
|
|
294
|
+
- Recommendation: <specific action>
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
For large sweeps (10+ proposals), show the summary table first, then
|
|
298
|
+
detailed issues only for flagged proposals. Do not expand ✅ OK proposals.
|
|
299
|
+
|
|
300
|
+
### Step 9 — Write proposal queue file
|
|
301
|
+
|
|
302
|
+
Write the analysis results to `.pi/proposal-queue.json`.
|
|
303
|
+
|
|
304
|
+
**If the file already exists**, read it first:
|
|
305
|
+
```bash
|
|
306
|
+
cat .pi/proposal-queue.json
|
|
307
|
+
```
|
|
308
|
+
Extract any `notes` fields from existing proposal entries. These are
|
|
309
|
+
user-added annotations that MUST be preserved in the updated file.
|
|
310
|
+
|
|
311
|
+
**Write the JSON file** following the schema in
|
|
312
|
+
[references/proposal-queue-schema.md](references/proposal-queue-schema.md).
|
|
313
|
+
|
|
314
|
+
Include:
|
|
315
|
+
- `lastChecked`: current ISO-8601 timestamp
|
|
316
|
+
- `lastSweepSummary`: e.g., "3 broken, 2 stale, 9 ok, 0 obsolete"
|
|
317
|
+
- `proposals`: array with full analysis per proposal
|
|
318
|
+
- `conflicts`: array of cross-proposal conflicts
|
|
319
|
+
|
|
320
|
+
After writing, announce:
|
|
321
|
+
> "Wrote `.pi/proposal-queue.json` with N proposals, M conflicts."
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## Phase 2: Individual Triage
|
|
326
|
+
|
|
327
|
+
After displaying the sweep report, use the **AskUserQuestion tool** to ask:
|
|
328
|
+
|
|
329
|
+
> "Which proposals do you want to address? Pick from the flagged ones
|
|
330
|
+
> (e.g., 'terminal-emulator, session-tree-navigation'), say 'all' to
|
|
331
|
+
> process all flagged proposals in priority order, or 'none' to stop here."
|
|
332
|
+
|
|
333
|
+
If the user says "none", stop. The sweep report and JSON file are the output.
|
|
334
|
+
|
|
335
|
+
For each selected proposal, proceed based on its status:
|
|
336
|
+
|
|
337
|
+
### STALE proposals — auto-fix
|
|
338
|
+
|
|
339
|
+
For each issue with `autoFixable: true`:
|
|
340
|
+
|
|
341
|
+
1. **Show the proposed fix** before applying:
|
|
342
|
+
```
|
|
343
|
+
In `<artifact>`:
|
|
344
|
+
- Old: `<old text>`
|
|
345
|
+
+ New: `<new text>`
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
2. **Apply the fix** — edit the artifact file with the text replacement.
|
|
349
|
+
|
|
350
|
+
3. **Validate** after all fixes for this proposal:
|
|
351
|
+
```bash
|
|
352
|
+
openspec validate <name>
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
4. If all issues were auto-fixable and now fixed, update the proposal's
|
|
356
|
+
status to "ok" in `.pi/proposal-queue.json`.
|
|
357
|
+
|
|
358
|
+
### BROKEN proposals — guided conversation
|
|
359
|
+
|
|
360
|
+
For each issue with `autoFixable: false`:
|
|
361
|
+
|
|
362
|
+
1. **Present the conflict clearly:**
|
|
363
|
+
|
|
364
|
+
```markdown
|
|
365
|
+
## Issue: <short title>
|
|
366
|
+
|
|
367
|
+
**In your proposal:** "<quote from the proposal artifact>"
|
|
368
|
+
**In reality:** "<what actually exists or changed in the codebase>"
|
|
369
|
+
**Caused by:** <archived change name or codebase evolution>
|
|
370
|
+
|
|
371
|
+
### Options
|
|
372
|
+
A) <option that simplifies the proposal to match current reality>
|
|
373
|
+
B) <option that preserves the original intent with adjustments>
|
|
374
|
+
C) Defer — needs deeper investigation before deciding
|
|
375
|
+
D) Mark as obsolete — this aspect is no longer needed
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
2. **Use AskUserQuestion tool** to get the user's decision (A/B/C/D or
|
|
379
|
+
custom response).
|
|
380
|
+
|
|
381
|
+
3. **Apply the decision:**
|
|
382
|
+
- **A or B**: Edit the relevant artifact (proposal.md, design.md, or
|
|
383
|
+
specs/) to reflect the decision. Show the changes before applying.
|
|
384
|
+
- **C**: Add a note to the proposal's `notes` field in the JSON:
|
|
385
|
+
"Deferred: <issue description> — needs investigation"
|
|
386
|
+
- **D**: Mark this specific issue as resolved, but if ALL issues for
|
|
387
|
+
the proposal are marked D, suggest archiving the whole proposal.
|
|
388
|
+
|
|
389
|
+
4. **If the decision changes scope significantly**, offer:
|
|
390
|
+
> "This changes the proposal fundamentally. Want me to regenerate
|
|
391
|
+
> design.md and tasks.md? (This would use openspec-ff-change to
|
|
392
|
+
> recreate downstream artifacts.)"
|
|
393
|
+
|
|
394
|
+
5. **Validate** after all changes:
|
|
395
|
+
```bash
|
|
396
|
+
openspec validate <name> --strict
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
6. **Update** `.pi/proposal-queue.json` with resolved issues and new status.
|
|
400
|
+
|
|
401
|
+
### OBSOLETE proposals — suggest archival
|
|
402
|
+
|
|
403
|
+
1. Present the evidence:
|
|
404
|
+
```markdown
|
|
405
|
+
## Proposal `<name>` appears obsolete
|
|
406
|
+
|
|
407
|
+
**Evidence:** <why it's obsolete — feature exists at `<file>`,
|
|
408
|
+
capability `<name>` already covers this, etc.>
|
|
409
|
+
|
|
410
|
+
Archive this proposal?
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
2. Use **AskUserQuestion tool** to confirm.
|
|
414
|
+
|
|
415
|
+
3. If confirmed:
|
|
416
|
+
```bash
|
|
417
|
+
openspec archive <name> --skip-specs --yes
|
|
418
|
+
```
|
|
419
|
+
Remove the entry from `.pi/proposal-queue.json`.
|
|
420
|
+
|
|
421
|
+
4. If rejected: change status from "obsolete" to "ok" or "stale" as
|
|
422
|
+
appropriate, add a note explaining why it's still relevant.
|
|
423
|
+
|
|
424
|
+
### CONFLICT resolution — cross-proposal
|
|
425
|
+
|
|
426
|
+
When processing a proposal that has entries in the `conflicts` array:
|
|
427
|
+
|
|
428
|
+
1. **Show both proposals** for the conflicting area:
|
|
429
|
+
```markdown
|
|
430
|
+
## Conflict: <file/area>
|
|
431
|
+
|
|
432
|
+
**Proposal A (`<name>`):** <what it plans to do>
|
|
433
|
+
**Proposal B (`<name>`):** <what it plans to do>
|
|
434
|
+
|
|
435
|
+
**Suggested resolution:** <from the conflicts array>
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
2. Use **AskUserQuestion tool**: "Accept this ordering? Or adjust scopes?"
|
|
439
|
+
|
|
440
|
+
3. **Update both entries** in `.pi/proposal-queue.json`:
|
|
441
|
+
- Set `dependsOn` if an ordering was agreed
|
|
442
|
+
- Adjust priorities to respect the ordering
|
|
443
|
+
- Add notes about the resolution
|
|
444
|
+
|
|
445
|
+
---
|
|
446
|
+
|
|
447
|
+
## Gotchas
|
|
448
|
+
|
|
449
|
+
- **Untracked proposals**: Some proposals may not be committed to git yet.
|
|
450
|
+
The dating fallback chain handles this — filesystem birthtime is the
|
|
451
|
+
second option. If stat also fails, use the oldest archive date.
|
|
452
|
+
|
|
453
|
+
- **Empty changes**: Some changes (like `electron-embedding`) may have an
|
|
454
|
+
empty directory or only a directory with no proposal.md. Mark these as
|
|
455
|
+
status "empty" with priority 999 and skip all detection steps.
|
|
456
|
+
|
|
457
|
+
- **Partial artifacts**: Some proposals have only `proposal.md` without
|
|
458
|
+
design.md or tasks.md. Run detection only against the artifacts that
|
|
459
|
+
exist. Don't flag missing optional artifacts as issues.
|
|
460
|
+
|
|
461
|
+
- **Archive date parsing**: Archive directories use `YYYY-MM-DD-<name>`
|
|
462
|
+
format. Always parse the first 10 characters as the date. Some names
|
|
463
|
+
may contain extra hyphens — only the first 10 chars matter.
|
|
464
|
+
|
|
465
|
+
- **False positives**: When uncertain whether an issue is real, prefer
|
|
466
|
+
the lower severity: STALE over BROKEN, BROKEN over OBSOLETE. Every
|
|
467
|
+
issue MUST cite specific evidence (file path, archive name, code
|
|
468
|
+
snippet). Never flag something without evidence.
|
|
469
|
+
|
|
470
|
+
- **Large sweeps**: With 10+ proposals, context pressure is real. Process
|
|
471
|
+
proposals sequentially — gather context for one, analyze it, move to
|
|
472
|
+
the next. Don't try to hold all proposals in memory at once. The
|
|
473
|
+
summary table and JSON file accumulate results incrementally.
|
|
474
|
+
|
|
475
|
+
- **Cross-platform stat**: macOS uses `stat -f "%SB"`, Linux uses
|
|
476
|
+
`stat -c "%W"`. Try macOS first, fall back to Linux syntax.
|
|
477
|
+
|
|
478
|
+
---
|
|
479
|
+
|
|
480
|
+
## Guardrails
|
|
481
|
+
|
|
482
|
+
- **Never modify artifacts without showing the change first** — even
|
|
483
|
+
auto-fixes MUST be displayed before applying.
|
|
484
|
+
- **Never auto-fix BROKEN issues** — these always require human judgment
|
|
485
|
+
via guided conversation. Only STALE issues with autoFixable: true
|
|
486
|
+
can be auto-fixed.
|
|
487
|
+
- **Never archive without confirmation** — always ask before archiving
|
|
488
|
+
proposals marked obsolete.
|
|
489
|
+
- **Always run `openspec validate` after any artifact modification.**
|
|
490
|
+
- **Preserve user notes** — when updating `.pi/proposal-queue.json`,
|
|
491
|
+
read the existing file first and carry over any `notes` fields.
|
|
492
|
+
- **Ground all claims in evidence** — every issue must reference a
|
|
493
|
+
specific file, archived change, or code snippet. Never speculate
|
|
494
|
+
about what might be wrong. If you can't find evidence, don't flag it.
|
|
495
|
+
- **Respect single-proposal mode** — if `--proposal <name>` was given,
|
|
496
|
+
do not analyze other proposals or run cross-proposal conflict detection.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Proposal Queue Schema
|
|
2
|
+
|
|
3
|
+
File location: `.pi/proposal-queue.json`
|
|
4
|
+
|
|
5
|
+
This file is written by the `spec-coherence-check` skill and designed
|
|
6
|
+
to be consumed by future automation skills (e.g., `openspec-auto-pipeline`).
|
|
7
|
+
|
|
8
|
+
## Schema
|
|
9
|
+
|
|
10
|
+
```json
|
|
11
|
+
{
|
|
12
|
+
"lastChecked": "ISO-8601 timestamp of last sweep",
|
|
13
|
+
"lastSweepSummary": "human-readable summary string",
|
|
14
|
+
"proposals": [
|
|
15
|
+
{
|
|
16
|
+
"name": "string — proposal directory name",
|
|
17
|
+
"status": "ok | stale | broken | obsolete | empty",
|
|
18
|
+
"priority": "number — lower = implement first",
|
|
19
|
+
"complexity": "trivial | minor | major | fundamental",
|
|
20
|
+
"createdAt": "YYYY-MM-DD",
|
|
21
|
+
"checkedAt": "ISO-8601 timestamp",
|
|
22
|
+
"issues": [
|
|
23
|
+
{
|
|
24
|
+
"severity": "stale | broken | obsolete",
|
|
25
|
+
"description": "string — what is wrong",
|
|
26
|
+
"artifact": "string — which artifact file is affected",
|
|
27
|
+
"causedBy": "string — archive name or codebase change",
|
|
28
|
+
"autoFixable": "boolean"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"dependsOn": ["string — proposal names this should follow"],
|
|
32
|
+
"blockedBy": ["string — hard dependencies (must be done before)"],
|
|
33
|
+
"conflictsWith": ["string — proposals touching same area"],
|
|
34
|
+
"touchesFiles": ["string — file paths from Impact section"],
|
|
35
|
+
"touchesCapabilities": ["string — capability names from Capabilities section"],
|
|
36
|
+
"notes": "string — optional manual notes (preserved across updates)"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"conflicts": [
|
|
40
|
+
{
|
|
41
|
+
"proposals": ["string — two or more proposal names"],
|
|
42
|
+
"area": "string — file or capability that overlaps",
|
|
43
|
+
"severity": "low | medium | high",
|
|
44
|
+
"resolution": "string — suggested ordering or scope adjustment"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Field Details
|
|
51
|
+
|
|
52
|
+
### proposals[].status
|
|
53
|
+
|
|
54
|
+
| Value | Meaning |
|
|
55
|
+
|-------|---------|
|
|
56
|
+
| `ok` | Ready to implement as-is. No issues detected. |
|
|
57
|
+
| `stale` | Minor references outdated. All issues are auto-fixable. |
|
|
58
|
+
| `broken` | Design assumptions invalidated. Needs human judgment. |
|
|
59
|
+
| `obsolete` | Feature already exists or problem solved differently. |
|
|
60
|
+
| `empty` | Change directory exists but has no meaningful artifacts. |
|
|
61
|
+
|
|
62
|
+
### proposals[].priority
|
|
63
|
+
|
|
64
|
+
Lower number = implement sooner. Typical range is 5–999.
|
|
65
|
+
|
|
66
|
+
- Score 999 = bottom of queue (obsolete or empty proposals)
|
|
67
|
+
- Dependency constraints always override raw scores: if A depends on B,
|
|
68
|
+
then A.priority > B.priority regardless of calculated score
|
|
69
|
+
- Users can influence ordering via the `notes` field (future automation
|
|
70
|
+
can read notes for manual overrides)
|
|
71
|
+
|
|
72
|
+
### proposals[].complexity
|
|
73
|
+
|
|
74
|
+
| Value | Criteria |
|
|
75
|
+
|-------|----------|
|
|
76
|
+
| `trivial` | 1–2 files, isolated fix, no protocol/architecture changes |
|
|
77
|
+
| `minor` | Small feature, well-scoped, fewer than 5 files |
|
|
78
|
+
| `major` | Cross-cutting, multiple components, protocol changes |
|
|
79
|
+
| `fundamental` | Architecture-level change, breaking changes |
|
|
80
|
+
|
|
81
|
+
### proposals[].issues[]
|
|
82
|
+
|
|
83
|
+
Each issue represents one detected problem. The `autoFixable` field
|
|
84
|
+
determines the triage path:
|
|
85
|
+
|
|
86
|
+
- `autoFixable: true` → STALE auto-fix flow (show change, apply, validate)
|
|
87
|
+
- `autoFixable: false` → BROKEN guided conversation (present options, ask user)
|
|
88
|
+
|
|
89
|
+
The `causedBy` field references either an archive directory name
|
|
90
|
+
(e.g., `2026-03-27-server-side-directory-services`) or a general
|
|
91
|
+
codebase change description.
|
|
92
|
+
|
|
93
|
+
### proposals[].dependsOn vs blockedBy
|
|
94
|
+
|
|
95
|
+
| Field | Meaning |
|
|
96
|
+
|-------|---------|
|
|
97
|
+
| `dependsOn` | Soft ordering preference. "Should be done after these." |
|
|
98
|
+
| `blockedBy` | Hard constraint. "Cannot be implemented until these are done." |
|
|
99
|
+
|
|
100
|
+
Both arrays contain proposal names (not archive names).
|
|
101
|
+
|
|
102
|
+
### proposals[].notes
|
|
103
|
+
|
|
104
|
+
Free-text field for manual annotations. The coherence-check skill
|
|
105
|
+
preserves this field across re-runs. Users can write anything here —
|
|
106
|
+
implementation notes, reasons to defer, manual priority overrides, etc.
|
|
107
|
+
|
|
108
|
+
### conflicts[].severity
|
|
109
|
+
|
|
110
|
+
| Value | Meaning |
|
|
111
|
+
|-------|---------|
|
|
112
|
+
| `low` | Both proposals add to the same file but in different areas |
|
|
113
|
+
| `medium` | Both proposals modify the same component/API differently |
|
|
114
|
+
| `high` | Both proposals make incompatible architectural assumptions |
|
|
115
|
+
|
|
116
|
+
### conflicts[].resolution
|
|
117
|
+
|
|
118
|
+
A human-readable suggestion for resolving the conflict, typically one of:
|
|
119
|
+
- Implementation ordering ("Implement X before Y because...")
|
|
120
|
+
- Scope adjustment ("Narrow X to exclude area Z, which Y covers")
|
|
121
|
+
- Merge suggestion ("These proposals could be combined into one")
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @blackbelt-technology/pi-dashboard-openspec-workflow
|
|
2
|
+
|
|
3
|
+
A pi package — **skills only, no tools** — with helpers for the
|
|
4
|
+
[OpenSpec](https://github.com/Fission-AI/OpenSpec) change lifecycle.
|
|
5
|
+
|
|
6
|
+
Reusable in any OpenSpec + pi project.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pi install npm:@blackbelt-technology/pi-dashboard-openspec-workflow
|
|
12
|
+
# or try without installing:
|
|
13
|
+
pi -e npm:@blackbelt-technology/pi-dashboard-openspec-workflow
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Skills
|
|
17
|
+
|
|
18
|
+
| Skill | What it does |
|
|
19
|
+
|-------|--------------|
|
|
20
|
+
| `spec-coherence-check` | Sweep all active proposals for staleness, conflicts, and obsolescence against the current codebase and archived changes. Produces a gap-analysis report + priority queue. |
|
|
21
|
+
| `pre-scaffold-openspec-coherence-check` | Run before scaffolding a new proposal to catch duplicates of archived work and contradictions with already-shipped architecture. |
|
|
22
|
+
| `fix-worktree-opsx-skills-not-created` | Repair a git worktree missing the generated `openspec-*` (opsx) skills. Root cause: bare `npx openspec` resolves a squatted registry stub instead of the real CLI. |
|
|
23
|
+
| `reverse-spec-from-code` | Reverse-generate `openspec/specs/<cap>/spec.md` from spec-less code, using parallel blind generators + auditors, to enrich the `kb_search` corpus. |
|
|
24
|
+
|
|
25
|
+
Skills load by natural-language trigger, or explicitly via `/skill:<name>`.
|
|
26
|
+
|
|
27
|
+
## How loading works
|
|
28
|
+
|
|
29
|
+
Pure-skill package: `package.json` `pi.skills` points pi at each skill
|
|
30
|
+
directory. No `extension.ts`, no build step.
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@blackbelt-technology/pi-dashboard-openspec-workflow",
|
|
3
|
+
"version": "0.5.4",
|
|
4
|
+
"description": "OpenSpec-lifecycle helper skills for pi sessions — spec-coherence-check (sweep active proposals for staleness/conflicts/obsolescence), pre-scaffold-openspec-coherence-check (guard before scaffolding a proposal against archived/shipped work), fix-worktree-opsx-skills-not-created (repair worktrees missing the generated opsx skills), reverse-spec-from-code (backfill capability specs from spec-less code). Pure-skill package, no extension.ts. Reusable in any OpenSpec + pi project.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/BlackBeltTechnology/pi-agent-dashboard",
|
|
13
|
+
"directory": "packages/openspec-workflow"
|
|
14
|
+
},
|
|
15
|
+
"pi": {
|
|
16
|
+
"skills": [
|
|
17
|
+
".pi/skills/spec-coherence-check",
|
|
18
|
+
".pi/skills/pre-scaffold-openspec-coherence-check",
|
|
19
|
+
".pi/skills/fix-worktree-opsx-skills-not-created",
|
|
20
|
+
".pi/skills/reverse-spec-from-code"
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
".pi/skills/",
|
|
25
|
+
"README.md"
|
|
26
|
+
],
|
|
27
|
+
"keywords": [
|
|
28
|
+
"pi-package",
|
|
29
|
+
"pi-skill",
|
|
30
|
+
"pi-dashboard",
|
|
31
|
+
"openspec",
|
|
32
|
+
"spec",
|
|
33
|
+
"proposal",
|
|
34
|
+
"coherence",
|
|
35
|
+
"worktree"
|
|
36
|
+
]
|
|
37
|
+
}
|