@blackbelt-technology/pi-dashboard-openspec-workflow 0.6.1 → 0.8.0

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.
@@ -3,24 +3,50 @@ name: "fix-worktree-opsx-skills-not-created"
3
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
4
  version: 1
5
5
  created: "2026-07-13"
6
- updated: "2026-07-13"
6
+ updated: "2026-08-20"
7
7
  ---
8
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.
9
+ Use when a git worktree lacks the OpenSpec lifecycle skills (`.pi/skills/openspec-explore`, `openspec-propose`, and related directories), `/opsx:` commands are missing, `openspec-apply-change` stalls, or `.pi/settings.json#worktreeInit` needs an audit.
10
10
 
11
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).
12
+ 1. Confirm the skills are generated, not committed. `.pi/.gitignore` contains `skills/openspec-*/**`; each fresh worktree must run `openspec init`.
13
+ 2. Confirm the repository declares `@fission-ai/openspec` and identify its package-manager install command. The unscoped npm package `openspec` is a `0.0.0` stub.
14
+ 3. Require a clean `git status --porcelain=v1`, then install repository dependencies. For this repository, run `pnpm install --frozen-lockfile`.
15
+ 4. Use the repository-pinned binary when it exists:
16
+ ```bash
17
+ pnpm exec openspec init --tools pi --force
18
+ ```
19
+ `pnpm exec` uses the declared local dependency and fails when the binary is absent. In a repository that does not declare the CLI, use the version-pinned scoped package explicitly: `npx @fission-ai/openspec@1.6.0 init --tools pi --force`.
20
+ 5. Verify the CLI reports setup success. Check the lifecycle skills this repository requires by name: `openspec-explore`, `openspec-propose`, `openspec-apply-change`, `openspec-update-change`, and `openspec-archive-change`.
21
+ 6. Check `git status --short`. Generated `openspec-*` skill directories should remain ignored. Review any tracked context-file rewrite before continuing.
22
+
23
+ ## Why the old path fails
24
+
25
+ Bare `npx openspec init ...` can fetch `openspec@0.0.0` when `node_modules/.bin/openspec` is absent. The stub exits without generating lifecycle skills. Installing dependencies first and using `pnpm exec openspec` preserves the lockfile-selected CLI and fails visibly when setup is incomplete.
18
26
 
19
27
  ## 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.
28
+ - Run the dependency install first. `pnpm exec openspec` cannot recover a missing local binary.
29
+ - Do not hard-code the number of generated skills or commands. OpenSpec releases generate different sets; validate the required lifecycle names.
30
+ - The worktree-init gate `test ! -d .pi/skills/openspec-explore` correctly re-triggers initialization when generated skills are absent.
31
+ - `openspec init --force` can rewrite tracked `AGENTS.md` or `CLAUDE.md`. Generated skill directories are safe; tracked context changes require review.
23
32
 
24
33
  ## 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
34
+
35
+ ```bash
36
+ set -euo pipefail
37
+ before_status="$(git status --porcelain=v1)"
38
+ if [ -n "$before_status" ]; then
39
+ printf '%s\n' "Refusing recovery in a dirty worktree" >&2
40
+ exit 1
41
+ fi
42
+ pnpm install --frozen-lockfile
43
+ pnpm exec openspec --version
44
+ pnpm exec openspec init --tools pi --force
45
+ for skill in openspec-explore openspec-propose openspec-apply-change openspec-update-change openspec-archive-change; do
46
+ test -d ".pi/skills/$skill" || exit 1
47
+ done
48
+ after_status="$(git status --porcelain=v1)"
49
+ test -z "$after_status"
50
+ ```
51
+
52
+ Completion requires setup success, every named directory, and empty Git status before and after recovery.
@@ -1,6 +1,6 @@
1
1
  ---
2
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'."
3
+ description: 'Run before scaffolding any OpenSpec proposal to catch duplicates of archived work and contradictions with shipped architecture. Always run when about to create openspec/changes/<name>/, especially for proposals touching a subsystem with a recent archive entry. Triggers: ''scaffold OpenSpec'', ''write a proposal'', ''create change'', ''openspec change new''.'
4
4
  version: 1
5
5
  created: "2026-06-13"
6
6
  updated: "2026-06-13"
@@ -1,6 +1,6 @@
1
1
  ---
2
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".
3
+ description: 'Reverse-generate OpenSpec capability specs (openspec/specs/<cap>/spec.md) from code that lacks them, or reconcile an existing stale spec with `--refresh`, using parallel subagents. Fans out one blind generator per capability, audits each spec against the code for hallucinations, and promotes only on user confirm. Use on "generate specs from code", "backfill openspec specs", "refresh a stale spec".'
4
4
  ---
5
5
 
6
6
  # reverse-spec-from-code
@@ -0,0 +1,45 @@
1
+ # SKILL.md — index
2
+
3
+ Pull-only condensed map. Source: packages/openspec-workflow/.pi/skills/spec-coherence-check/SKILL.md. Trigger → sweep phase → severity/status → action.
4
+
5
+ ## Meta
6
+ - Skill name — `spec-coherence-check`. Sweeps active OpenSpec proposals for staleness/conflicts/obsolescence vs codebase + archive.
7
+ - Trigger — proposals may be outdated, cross-proposal conflicts, before batch of implementations. Requires openspec CLI + git.
8
+ - Input — `--proposal <name>` = single mode; no args = full sweep.
9
+ - Output — gap-analysis report + `.pi/proposal-queue.json`; auto-fix trivial, guided conversation for complex.
10
+
11
+ ## Phase 1: Sweep Report
12
+ - Step 1 gather — `openspec list --json`; `ls openspec/changes/archive/`. Date each proposal: git first-commit `git log --follow --diff-filter=A --format='%ai' -- "openspec/changes/<name>/proposal.md" | tail -1` → birthtime macOS `stat -f "%SB" -t "%Y-%m-%d"` / Linux `stat -c "%W"` → oldest archive date floor. Read artifacts that exist: proposal.md (always), design.md, tasks.md, specs/. Extract referenced files (`src/...`), capabilities, assumptions, Impact files.
13
+ - Step 2 file existence — `find src/ -path "*<filename>" -o -name "<filename>" 2>/dev/null`. Missing → severity `stale`, autoFixable true. Find move: `rg -l "<key-term>" src/ --type ts`.
14
+ - Step 3 archive impact — archives dated after proposal creation. File overlap → `stale` autoFixable; capability overlap; `BREAKING` marker → `broken` autoFixable false.
15
+ - Step 4 concept validity — verify "Currently X does Y" via `rg "<pattern>" src/ --type ts -l`; Non-Goal now implemented → invalidated. Fundamental break → `broken`; minor ref → `stale`.
16
+ - Step 5 obsolescence — `ls openspec/specs/ | grep "<kw>"`; `rg -l "<kw>" src/ --type ts`; `ls -la <planned-new-file>`. Feature exists → `obsolete`.
17
+ - Step 6 cross-proposal conflicts — skip in single mode. File-touch matrix; 2+ proposals same file. Additive → low; modify same area → medium; architectural clash → high. Suggest ordering/scope fix.
18
+ - Step 7 priority — Base 50. −20 ok, −15 trivial, −10 no conflicts, −10 no deps, −5 <5 files. +20 broken, +15 others depend, +10 fundamental, +5 conflicts. Complexity: trivial 1-2 files isolated / minor <5 files / major cross-cutting protocol / fundamental architecture. Dependency override A-after-B → A.priority > B. Obsolete → 999. Empty dir → status `empty`, priority 999. Sort ascending.
19
+ - Step 8 report — `## Coherence Sweep Report — <YYYY-MM-DD>`. Summary table Proposal|Status|Issues|Complexity|Priority|Created. Legend ✅ OK ⚠️ STALE 🔴 BROKEN 💀 OBSOLETE 📭 EMPTY. Conflicts table + suggested implementation order + detailed issues (flagged only; 10+ proposals → summary first).
20
+ - Step 9 queue file — write `.pi/proposal-queue.json`; read existing first, preserve user `notes` fields. Schema: references/proposal-queue-schema.md. Fields: lastChecked (ISO), lastSweepSummary, proposals, conflicts. Announce "Wrote `.pi/proposal-queue.json` with N proposals, M conflicts."
21
+
22
+ ## Phase 2: Individual Triage
23
+ - AskUserQuestion — "Which proposals...?" Pick flagged names, 'all' in priority order, or 'none' stop.
24
+ - STALE auto-fix — show fix (Old/New) BEFORE applying; apply edit; `openspec validate <name>`; status → ok.
25
+ - BROKEN guided convo — present In your proposal / In reality / Caused by; options A simplify, B preserve intent, C defer (note "Deferred: ... — needs investigation"), D obsolete (all D → suggest archive). Scope change → offer openspec-ff-change regenerate. `openspec validate <name> --strict`; update JSON.
26
+ - OBSOLETE — evidence → confirm → `openspec archive <name> --skip-specs --yes`; remove from queue. Rejected → status ok/stale + note.
27
+ - CONFLICT — show both proposals + suggested resolution; AskUserQuestion ordering; update both entries: dependsOn, priorities, notes.
28
+
29
+ ## Gotchas
30
+ - Untracked proposals — birthtime fallback; stat fails → oldest archive floor.
31
+ - Empty changes (e.g. electron-embedding) — status `empty`, priority 999, skip detection.
32
+ - Partial artifacts — detect only existing; missing optional design/tasks not issues.
33
+ - Archive dates — parse first 10 chars only (`YYYY-MM-DD-<name>`).
34
+ - False positives — prefer STALE < BROKEN < OBSOLETE; every issue cites evidence, never flag without.
35
+ - Large sweeps — process proposals sequentially.
36
+ - stat — macOS `-f "%SB"`, Linux `-c "%W"`.
37
+
38
+ ## Guardrails
39
+ - Never modify artifacts without showing change first — auto-fixes included.
40
+ - Never auto-fix BROKEN — human judgment required; only STALE autoFixable true.
41
+ - Never archive without confirmation.
42
+ - Always run `openspec validate` after any artifact modification.
43
+ - Preserve user notes when rewriting `.pi/proposal-queue.json`.
44
+ - Ground all claims in evidence; no evidence → don't flag.
45
+ - Respect single-proposal mode — no other proposals, no conflict detection.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blackbelt-technology/pi-dashboard-openspec-workflow",
3
- "version": "0.6.1",
3
+ "version": "0.8.0",
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
5
  "type": "module",
6
6
  "license": "MIT",
@@ -22,7 +22,9 @@
22
22
  },
23
23
  "files": [
24
24
  ".pi/skills/",
25
- "README.md"
25
+ "README.md",
26
+ "!**/AGENTS.md",
27
+ "!**/*.AGENTS.md"
26
28
  ],
27
29
  "keywords": [
28
30
  "pi-package",