bigpowers 2.73.8 → 2.74.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.
Files changed (138) hide show
  1. package/.continue/rules/context7-mcp.md +0 -0
  2. package/.continue/rules/diagnose-stall.md +0 -0
  3. package/.kilocode/rules/context7-mcp.md +0 -0
  4. package/.kilocode/rules/diagnose-stall.md +0 -0
  5. package/.pi/package.json +2 -2
  6. package/.pi/prompts/audit-code.md +17 -13
  7. package/.pi/prompts/change-request.md +3 -1
  8. package/.pi/prompts/compose-workflow.md +15 -0
  9. package/.pi/prompts/context7-mcp.md +54 -0
  10. package/.pi/prompts/craft-skill.md +28 -0
  11. package/.pi/prompts/deepen-architecture.md +20 -0
  12. package/.pi/prompts/delegate-task.md +14 -0
  13. package/.pi/prompts/deploy.md +8 -0
  14. package/.pi/prompts/develop-tdd.md +15 -4
  15. package/.pi/prompts/diagnose-stall.md +53 -0
  16. package/.pi/prompts/dispatch-agents.md +49 -19
  17. package/.pi/prompts/gate-trace.md +9 -1
  18. package/.pi/prompts/guard-git.md +14 -0
  19. package/.pi/prompts/migrate-spec.md +12 -0
  20. package/.pi/prompts/plan-work.md +62 -2
  21. package/.pi/prompts/publish-package.md +11 -0
  22. package/.pi/prompts/release-branch.md +39 -43
  23. package/.pi/prompts/request-review.md +57 -17
  24. package/.pi/prompts/run-benchmark.md +3 -3
  25. package/.pi/prompts/run-evals.md +26 -6
  26. package/.pi/prompts/security-review.md +56 -8
  27. package/.pi/prompts/seed-conventions.md +61 -0
  28. package/.pi/prompts/session-state.md +5 -10
  29. package/.pi/prompts/slice-tasks.md +3 -0
  30. package/.pi/prompts/smoke-test.md +11 -0
  31. package/.pi/prompts/stocktake-skills.md +2 -1
  32. package/.pi/prompts/validate-contracts.md +12 -0
  33. package/.pi/prompts/validate-fix.md +2 -0
  34. package/.pi/prompts/verify-work.md +31 -20
  35. package/.pi/prompts/wire-ci.md +11 -0
  36. package/.pi/prompts/write-document.md +10 -0
  37. package/.pi/skills/audit-code/SKILL.md +17 -13
  38. package/.pi/skills/change-request/SKILL.md +3 -1
  39. package/.pi/skills/compose-workflow/SKILL.md +15 -0
  40. package/.pi/skills/context7-mcp/SKILL.md +56 -0
  41. package/.pi/skills/craft-skill/SKILL.md +28 -0
  42. package/.pi/skills/deepen-architecture/SKILL.md +20 -0
  43. package/.pi/skills/delegate-task/SKILL.md +14 -0
  44. package/.pi/skills/deploy/SKILL.md +8 -0
  45. package/.pi/skills/develop-tdd/SKILL.md +15 -4
  46. package/.pi/skills/diagnose-stall/SKILL.md +55 -0
  47. package/.pi/skills/dispatch-agents/SKILL.md +49 -19
  48. package/.pi/skills/gate-trace/SKILL.md +9 -1
  49. package/.pi/skills/guard-git/SKILL.md +14 -0
  50. package/.pi/skills/migrate-spec/SKILL.md +12 -0
  51. package/.pi/skills/plan-work/SKILL.md +62 -2
  52. package/.pi/skills/publish-package/SKILL.md +11 -0
  53. package/.pi/skills/release-branch/SKILL.md +39 -43
  54. package/.pi/skills/request-review/SKILL.md +57 -17
  55. package/.pi/skills/run-benchmark/SKILL.md +3 -3
  56. package/.pi/skills/run-evals/SKILL.md +26 -6
  57. package/.pi/skills/security-review/SKILL.md +56 -8
  58. package/.pi/skills/seed-conventions/SKILL.md +61 -0
  59. package/.pi/skills/session-state/SKILL.md +5 -10
  60. package/.pi/skills/slice-tasks/SKILL.md +3 -0
  61. package/.pi/skills/smoke-test/SKILL.md +11 -0
  62. package/.pi/skills/stocktake-skills/SKILL.md +2 -1
  63. package/.pi/skills/validate-contracts/SKILL.md +12 -0
  64. package/.pi/skills/validate-fix/SKILL.md +2 -0
  65. package/.pi/skills/verify-work/SKILL.md +31 -20
  66. package/.pi/skills/wire-ci/SKILL.md +11 -0
  67. package/.pi/skills/write-document/SKILL.md +10 -0
  68. package/CHANGELOG.md +14 -0
  69. package/CLAUDE.md +59 -1
  70. package/CONVENTIONS.md +80 -5
  71. package/README.md +1 -1
  72. package/SKILL-INDEX.md +1 -1
  73. package/package.json +1 -1
  74. package/scripts/bp-churn-rank.sh +49 -0
  75. package/scripts/check-import-boundaries.sh +64 -0
  76. package/scripts/compile-rule-matrix.sh +114 -0
  77. package/scripts/hooks/rtk-rewrite.sh +11 -0
  78. package/scripts/hooks/token-mgmt-pre-tool-use.sh +53 -0
  79. package/scripts/install.sh +6 -0
  80. package/scripts/lib/completeness-critic.sh +62 -0
  81. package/scripts/lib/doc-fetch-cache.sh +71 -0
  82. package/scripts/lib/golden-suite-gates.sh +3 -1
  83. package/scripts/lib/parallel-review-worktrees.sh +34 -0
  84. package/scripts/lib/plan-consistency-check.sh +88 -0
  85. package/scripts/lib/run-benchmark.py +210 -0
  86. package/scripts/lib/simple_yaml.py +130 -0
  87. package/scripts/lib/sync-context-engineering-ref.sh +19 -0
  88. package/scripts/lib/trace-matrix.py +10 -281
  89. package/scripts/lib/trace_renderer.py +147 -0
  90. package/scripts/references-manifest.yaml +19 -0
  91. package/scripts/run-benchmark.sh +6 -0
  92. package/scripts/sync-references.sh +25 -0
  93. package/scripts/test-trace-matrix-size.sh +46 -0
  94. package/scripts/validate-skill-catalog.sh +147 -0
  95. package/scripts/validate-skill-description.sh +70 -0
  96. package/skills/audit-code/SKILL.md +19 -13
  97. package/skills/change-request/SKILL.md +3 -1
  98. package/skills/compose-workflow/SKILL.md +15 -0
  99. package/skills/context7-mcp/SKILL.md +57 -0
  100. package/skills/craft-skill/SKILL.md +29 -0
  101. package/skills/deepen-architecture/SKILL.md +22 -0
  102. package/skills/delegate-task/SKILL.md +14 -0
  103. package/skills/deploy/SKILL.md +9 -0
  104. package/skills/develop-tdd/SKILL.md +18 -4
  105. package/skills/diagnose-stall/SKILL.md +56 -0
  106. package/skills/dispatch-agents/SKILL.md +51 -19
  107. package/skills/gate-trace/SKILL.md +11 -1
  108. package/skills/guard-git/REFERENCE.md +14 -0
  109. package/skills/migrate-spec/REFERENCE.md +12 -0
  110. package/skills/plan-work/REFERENCE.md +29 -2
  111. package/skills/plan-work/SKILL.md +38 -0
  112. package/skills/publish-package/REFERENCE.md +11 -0
  113. package/skills/release-branch/REFERENCE.md +14 -0
  114. package/skills/release-branch/SKILL.md +28 -43
  115. package/skills/request-review/SKILL.md +59 -17
  116. package/skills/run-benchmark/SKILL.md +4 -4
  117. package/skills/run-evals/REFERENCE.md +14 -4
  118. package/skills/run-evals/SKILL.md +13 -2
  119. package/skills/security-review/REFERENCE-false-positives.md +9 -8
  120. package/skills/security-review/REFERENCE-vuln-categories.md +4 -0
  121. package/skills/security-review/SKILL.md +45 -0
  122. package/skills/security-review/fixtures/CWE-79-xss-negative.js +6 -0
  123. package/skills/security-review/fixtures/CWE-79-xss-positive.js +6 -0
  124. package/skills/security-review/fixtures/CWE-89-sqli-negative.py +8 -0
  125. package/skills/security-review/fixtures/CWE-89-sqli-positive.py +9 -0
  126. package/skills/seed-conventions/REFERENCE.md +40 -0
  127. package/skills/seed-conventions/SKILL.md +22 -0
  128. package/skills/session-state/SKILL.md +5 -10
  129. package/skills/slice-tasks/SKILL.md +3 -0
  130. package/skills/smoke-test/REFERENCE.md +11 -0
  131. package/skills/stocktake-skills/SKILL.md +3 -1
  132. package/skills/validate-contracts/REFERENCE.md +12 -0
  133. package/skills/validate-fix/SKILL.md +3 -0
  134. package/skills/verify-work/REFERENCE.md +17 -0
  135. package/skills/verify-work/SKILL.md +18 -20
  136. package/skills/wire-ci/REFERENCE.md +11 -0
  137. package/skills/write-document/REFERENCE.md +10 -0
  138. package/skills-lock.json +32 -22
@@ -0,0 +1,147 @@
1
+ # story: e38s01
2
+ # trace_renderer.py — Output renderer for traceability matrix data.
3
+ import json
4
+ from pathlib import Path
5
+ from datetime import datetime, timezone
6
+
7
+ def emit_matrix_json(matrix_json_path: Path, stories: dict, tagged_sids: set, dark_stories: list, orphan_tags: list, stale_tags: list, matrix_stories: list) -> dict:
8
+ matrix = {
9
+ "generated_at": datetime.now(timezone.utc).isoformat(),
10
+ "matrix_version": "1.0",
11
+ "stories": matrix_stories,
12
+ "summary": {
13
+ "total_stories": len(stories),
14
+ "tagged_stories": len(tagged_sids & set(stories.keys())),
15
+ "dark_stories": dark_stories,
16
+ "dark_count": len(dark_stories),
17
+ "orphan_tags": orphan_tags,
18
+ "orphan_count": len(orphan_tags),
19
+ "stale_tags": stale_tags,
20
+ "stale_count": len(stale_tags),
21
+ "oracle_stats": {
22
+ "high": sum(1 for s in matrix_stories for l in s["links"] if l["confidence"] == "high"),
23
+ "medium": sum(1 for s in matrix_stories for l in s["links"] if l["confidence"] == "medium"),
24
+ "low": sum(1 for s in matrix_stories for l in s["links"] if l["confidence"] == "low")
25
+ }
26
+ }
27
+ }
28
+ matrix_json_path.parent.mkdir(parents=True, exist_ok=True)
29
+ matrix_json_path.write_text(json.dumps(matrix, indent=2), encoding="utf-8")
30
+ return matrix
31
+
32
+ def emit_trace_md(trace_md_path: Path, stories: dict, tagged_sids: set, dark_stories: list, orphan_tags: list, stale_tags: list, matrix_stories: list, matrix: dict, dev_status: dict) -> None:
33
+ lines = []
34
+ lines.append("# Traceability Matrix")
35
+ lines.append("")
36
+ lines.append(f"**Generated:** {datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%M:%S UTC')}")
37
+ lines.append(f"**Total stories:** {len(stories)}")
38
+ lines.append(f"**Tagged stories:** {len(tagged_sids & set(stories.keys()))}")
39
+ lines.append(f"**Dark stories:** {len(dark_stories)}")
40
+ lines.append(f"**Orphan tags:** {len(orphan_tags)}")
41
+ lines.append(f"**Stale tags:** {len(stale_tags)}")
42
+ lines.append("")
43
+ lines.append("## Oracle Stats")
44
+ lines.append("")
45
+ lines.append(f"- **High** (explicit tag): {matrix['summary']['oracle_stats']['high']}")
46
+ lines.append(f"- **Medium** (file heuristic): {matrix['summary']['oracle_stats']['medium']}")
47
+ lines.append(f"- **Low** (task reference): {matrix['summary']['oracle_stats']['low']}")
48
+ lines.append("")
49
+
50
+ # Story coverage table
51
+ lines.append("## Story Coverage")
52
+ lines.append("")
53
+ lines.append("| Story | Title | Epic | BCP | WSJF | Status | Links |")
54
+ lines.append("|-------|-------|------|-----|------|--------|-------|")
55
+ for s in matrix_stories:
56
+ lines.append(f"| {s['id']} | {s['title'][:60]} | {s['epic_id']} | {s['bcp']} | {s['wsjf']} | {s['status']} | {s['link_count']} |")
57
+ lines.append("")
58
+
59
+ # Findings
60
+ if dark_stories:
61
+ lines.append("## Dark Stories (no code links)")
62
+ lines.append("")
63
+ for ds in dark_stories:
64
+ sinfo = stories.get(ds, {})
65
+ lines.append(f"- **{ds}**: {sinfo.get('title', 'Unknown')} (status: {dev_status.get(ds, '?')})")
66
+ lines.append("")
67
+
68
+ if orphan_tags:
69
+ lines.append("## Orphan Tags (tag in code, no matching story)")
70
+ lines.append("")
71
+ for ot in orphan_tags:
72
+ lines.append(f"- `{ot}`")
73
+ lines.append("")
74
+
75
+ if stale_tags:
76
+ lines.append("## Stale Tags (story done, tag still in code)")
77
+ lines.append("")
78
+ for st in stale_tags:
79
+ lines.append(f"- `{st}`")
80
+ lines.append("")
81
+
82
+ trace_md_path.parent.mkdir(parents=True, exist_ok=True)
83
+ trace_md_path.write_text("\n".join(lines), encoding="utf-8")
84
+
85
+ def emit_okf_bundle(okf_dir: Path, stories: dict, matrix_stories: list) -> None:
86
+ okf_dir.mkdir(parents=True, exist_ok=True)
87
+
88
+ # Generate index.md
89
+ idx_lines = []
90
+ idx_lines.append("---")
91
+ idx_lines.append("type: Index")
92
+ idx_lines.append(f"generated_at: {datetime.now(timezone.utc).isoformat()}")
93
+ idx_lines.append(f"total_concepts: {len(stories)}")
94
+ idx_lines.append("---")
95
+ idx_lines.append("")
96
+ idx_lines.append("# Codebase Wiki — Story Traceability")
97
+ idx_lines.append("")
98
+ idx_lines.append("Auto-generated OKF bundle from trace-stories.sh.")
99
+ idx_lines.append("")
100
+ idx_lines.append("| Story | Title | Confidence | Links |")
101
+ idx_lines.append("|-------|-------|------------|-------|")
102
+ for s in matrix_stories:
103
+ confs = {l["confidence"] for l in s["links"]}
104
+ max_conf = "high" if "high" in confs else ("medium" if "medium" in confs else ("low" if confs else "none"))
105
+ idx_lines.append(f"| [{s['id']}](./{s['id']}.md) | {s['title'][:60]} | {max_conf} | {s['link_count']} |")
106
+ idx_lines.append("")
107
+ (okf_dir / "index.md").write_text("\n".join(idx_lines), encoding="utf-8")
108
+
109
+ # Generate one concept per story
110
+ for s in matrix_stories:
111
+ concept = []
112
+ concept.append("---")
113
+ concept.append(f"type: Story")
114
+ concept.append(f"id: {s['id']}")
115
+ concept.append(f"epic: {s['epic_id']}")
116
+ concept.append(f"bcps: {s['bcp']}")
117
+ concept.append(f"wsjf: {s['wsjf']}")
118
+ concept.append(f"implementation_status: {s['status']}")
119
+ max_confs = set()
120
+ for l in s["links"]:
121
+ max_confs.add(l["confidence"])
122
+ conf = "high" if "high" in max_confs else ("medium" if "medium" in max_confs else ("low" if max_confs else "none"))
123
+ concept.append(f"coverage_status: {'covered' if s['link_count'] > 0 else 'dark'}")
124
+ concept.append(f"confidence: {conf}")
125
+ concept.append("links:")
126
+ for l in s["links"]:
127
+ concept.append(f" - file: {l['file']}")
128
+ concept.append(f" line: {l['line']}")
129
+ concept.append(f" confidence: {l['confidence']}")
130
+ concept.append(f" method: {l['method']}")
131
+ concept.append("---")
132
+ concept.append("")
133
+ concept.append(f"# {s['id']}: {s['title']}")
134
+ concept.append("")
135
+ concept.append(f"**Epic:** {s['epic_id']} — {s.get('epic_title', 'Unknown')}")
136
+ concept.append(f"**Status:** {s['status']}")
137
+ concept.append(f"**BCP:** {s['bcp']} | **WSJF:** {s['wsjf']}")
138
+ concept.append("")
139
+ if s["links"]:
140
+ concept.append("## Implemented In")
141
+ concept.append("")
142
+ for l in s["links"]:
143
+ concept.append(f"- `{l['file']}` (line {l['line']}, confidence: {l['confidence']}, method: {l['method']})")
144
+ else:
145
+ concept.append("*No code links found — this is a dark story.*")
146
+ concept.append("")
147
+ (okf_dir / f"{s['id']}.md").write_text("\n".join(concept), encoding="utf-8")
@@ -0,0 +1,19 @@
1
+ # story: e45s10
2
+ # SSOT → docs/references distillation manifest.
3
+ # Each entry: source globs/files regenerate target via generator script.
4
+ version: 1
5
+ generated_at_field: docs/references/.sync-stamp
6
+
7
+ entries:
8
+ - id: model-profiles-catalog
9
+ sources:
10
+ - skills/*/SKILL.md
11
+ target: docs/references/model-profiles.md
12
+ generator: scripts/generate-reference-tables.sh
13
+
14
+ - id: context-engineering
15
+ sources:
16
+ - CLAUDE.md
17
+ - docs/PRINCIPLES.md
18
+ target: docs/references/context-engineering.md
19
+ generator: scripts/lib/sync-context-engineering-ref.sh
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ # story: e45s01
3
+ # run-benchmark.sh — N-run with/without-skill delta grading + train/validation split.
4
+ set -euo pipefail
5
+ source "$(dirname "${BASH_SOURCE[0]}")/lib/python-env.sh"
6
+ exec "$PYTHON" "$(dirname "${BASH_SOURCE[0]}")/lib/run-benchmark.py" "$@"
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env bash
2
+ # story: e45s10
3
+ # Regenerate docs/references from SSOT sources (see scripts/references-manifest.yaml).
4
+ # Schedule: weekly via .github/workflows/sync-references.yml; also safe to run locally.
5
+ set -euo pipefail
6
+
7
+ REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
8
+ MANIFEST="$REPO_ROOT/scripts/references-manifest.yaml"
9
+ STAMP_FILE="$REPO_ROOT/docs/references/.sync-stamp"
10
+
11
+ cd "$REPO_ROOT"
12
+ [[ -f "$MANIFEST" ]] || { echo "sync-references: missing manifest" >&2; exit 1; }
13
+
14
+ run_generator() {
15
+ local gen="$1"
16
+ [[ -x "$REPO_ROOT/$gen" || -f "$REPO_ROOT/$gen" ]] || { echo "sync-references: generator not found: $gen" >&2; exit 1; }
17
+ bash "$REPO_ROOT/$gen"
18
+ }
19
+
20
+ # model-profiles catalog
21
+ run_generator scripts/generate-reference-tables.sh
22
+ run_generator scripts/lib/sync-context-engineering-ref.sh
23
+
24
+ date -u +%Y-%m-%dT%H:%M:%SZ > "$STAMP_FILE"
25
+ echo "sync-references: OK (stamp $(cat "$STAMP_FILE"))"
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env bash
2
+ # test-trace-matrix-size.sh — recurrence guard for BUG-2026-07-06-gate-trace-matrix-oversized
3
+ #
4
+ # Asserts trace-matrix.py and its extracted modules stay under the 300-line cap.
5
+ #
6
+ # Usage: bash scripts/test-trace-matrix-size.sh
7
+
8
+ set -euo pipefail
9
+ source "$(dirname "${BASH_SOURCE[0]}")/lib/skill-common.sh"
10
+ resolve_repo_root
11
+
12
+ RED='\033[0;31m'
13
+ GREEN='\033[0;32m'
14
+ NC='\033[0m'
15
+
16
+ CAP=300
17
+ FAILURES=0
18
+
19
+ pass() { echo -e "${GREEN}PASS${NC} $1"; }
20
+ fail() { echo -e "${RED}FAIL${NC} $1"; FAILURES=$((FAILURES + 1)); }
21
+
22
+ check_lines() {
23
+ local file="$1"
24
+ local lines
25
+ lines=$(wc -l < "$REPO_ROOT/$file" | tr -d ' ')
26
+ if [[ "$lines" -le "$CAP" ]]; then
27
+ pass "$file: $lines lines (≤ $CAP)"
28
+ else
29
+ fail "$file: $lines lines (exceeds $CAP)"
30
+ fi
31
+ }
32
+
33
+ for f in \
34
+ scripts/lib/trace-matrix.py \
35
+ scripts/lib/simple_yaml.py \
36
+ scripts/lib/trace_renderer.py
37
+ do
38
+ check_lines "$f"
39
+ done
40
+
41
+ if [[ "$FAILURES" -gt 0 ]]; then
42
+ echo "test-trace-matrix-size.sh: $FAILURES failure(s)" >&2
43
+ exit 1
44
+ fi
45
+
46
+ exit 0
@@ -0,0 +1,147 @@
1
+ #!/usr/bin/env bash
2
+ # story: e45s12
3
+ # validate-skill-catalog.sh — code-enforced skill catalog hygiene (Hermes Curator pattern)
4
+ # Exit 0 when catalog passes; 1 on violations. --archive lists zero-usage skills for archiving.
5
+ set -euo pipefail
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
9
+ cd "$REPO_ROOT"
10
+
11
+ SKILLS_ROOT="$REPO_ROOT/skills"
12
+ [[ -d "$SKILLS_ROOT" ]] || SKILLS_ROOT="$REPO_ROOT"
13
+
14
+ ARCHIVE_MODE=false
15
+ STRICT=false
16
+ TARGET_SKILL=""
17
+ VIOLATIONS=0
18
+ WARNINGS=0
19
+
20
+ # Documented naming exceptions (craft-skill REFERENCE.md)
21
+ VERB_NOUN_EXCEPTIONS="grill-me grill-with-docs context7-mcp using-bigpowers deploy"
22
+
23
+ usage() {
24
+ echo "Usage: bash scripts/validate-skill-catalog.sh [--archive] [--strict] [--skill <name>]"
25
+ exit 2
26
+ }
27
+
28
+ while [[ $# -gt 0 ]]; do
29
+ case "$1" in
30
+ --archive) ARCHIVE_MODE=true; shift ;;
31
+ --strict) STRICT=true; shift ;;
32
+ --skill) TARGET_SKILL="${2:-}"; shift 2 ;;
33
+ --skill=*) TARGET_SKILL="${1#*=}"; shift ;;
34
+ -h|--help) usage ;;
35
+ *) echo "Unknown flag: $1" >&2; usage ;;
36
+ esac
37
+ done
38
+
39
+ report_catalog_violation() { echo "FAIL: $1" >&2; VIOLATIONS=$((VIOLATIONS + 1)); }
40
+ report_catalog_warning() { echo "WARN: $1" >&2; WARNINGS=$((WARNINGS + 1)); }
41
+
42
+ check_verb_noun() {
43
+ local name="$1"
44
+ if echo " $VERB_NOUN_EXCEPTIONS " | grep -q " $name "; then
45
+ return 0
46
+ fi
47
+ if [[ ! "$name" =~ ^[a-z][a-z0-9]*(-[a-z][a-z0-9]*)+$ ]]; then
48
+ report_catalog_violation "$name: not verb-noun kebab-case"
49
+ return 1
50
+ fi
51
+ local segments
52
+ segments=$(echo "$name" | tr '-' '\n' | wc -l | tr -d ' ')
53
+ if [[ "$segments" -gt 2 ]]; then
54
+ report_catalog_violation "$name: more than two hyphen segments (verb-noun only)"
55
+ fi
56
+ }
57
+
58
+ check_skill() {
59
+ local skill_md="$1"
60
+ local name
61
+ name=$(basename "$(dirname "$skill_md")")
62
+
63
+ check_verb_noun "$name" || true
64
+
65
+ if ! grep -q 'HARD GATE' "$skill_md" 2>/dev/null; then
66
+ if $STRICT; then report_catalog_violation "$name: missing HARD GATE block"; else report_catalog_warning "$name: missing HARD GATE block"; fi
67
+ fi
68
+
69
+ local desc
70
+ desc=$(awk 'BEGIN{f=0} /^---$/{f++; next} f==1{print} f==2{exit}' "$skill_md" \
71
+ | grep -E '^description:' | head -1 | sed 's/^description: *//; s/^> //' | tr -d '"' || true)
72
+ if [[ -n "$desc" && ${#desc} -gt 1024 ]]; then
73
+ report_catalog_violation "$name: description ${#desc} chars (max 1024)"
74
+ fi
75
+
76
+ local lines
77
+ lines=$(wc -l < "$skill_md" | tr -d ' ')
78
+ if [[ "$lines" -gt 300 ]]; then
79
+ report_catalog_warning "$name: SKILL.md $lines lines (target ≤300; split to REFERENCE.md)"
80
+ fi
81
+
82
+ local cmd
83
+ cmd=$(grep -E '^(> )?→ verify:' "$skill_md" 2>/dev/null | tail -1 | sed 's/^> // ; s/^→ verify: *//' || true)
84
+ if [[ -z "$cmd" ]]; then
85
+ if $STRICT; then report_catalog_violation "$name: missing → verify: command"; else report_catalog_warning "$name: missing → verify: command"; fi
86
+ fi
87
+ }
88
+
89
+ echo "Validating skill catalog under $SKILLS_ROOT ..."
90
+ if [[ -n "$TARGET_SKILL" ]]; then
91
+ skill_md="$SKILLS_ROOT/$TARGET_SKILL/SKILL.md"
92
+ [[ -f "$skill_md" ]] || { echo "FAIL: $skill_md not found" >&2; exit 1; }
93
+ check_skill "$skill_md"
94
+ else
95
+ for skill_md in "$SKILLS_ROOT"/*/SKILL.md; do
96
+ [[ -f "$skill_md" ]] || continue
97
+ check_skill "$skill_md"
98
+ done
99
+ fi
100
+
101
+ if $ARCHIVE_MODE; then
102
+ STATE="$REPO_ROOT/specs/state.yaml"
103
+ echo ""
104
+ echo "=== Archive candidates (zero calls in metrics.skill_timings) ==="
105
+ if [[ ! -f "$STATE" ]]; then
106
+ echo " (no specs/state.yaml — skip usage scan)"
107
+ else
108
+ python3 - "$STATE" "$SKILLS_ROOT" <<'PY'
109
+ import sys, glob, os
110
+ from pathlib import Path
111
+
112
+ state_path, skills_root = sys.argv[1], sys.argv[2]
113
+ text = Path(state_path).read_text(encoding="utf-8")
114
+ timings = set()
115
+ in_timings = False
116
+ for line in text.splitlines():
117
+ if line.strip() == "skill_timings:":
118
+ in_timings = True
119
+ continue
120
+ if in_timings:
121
+ if line.startswith(" ") and not line.startswith(" ") and line.rstrip().endswith(":"):
122
+ timings.add(line.strip().rstrip(":"))
123
+ elif line.strip() and not line.startswith(" "):
124
+ in_timings = False
125
+
126
+ skills = [os.path.basename(os.path.dirname(p)) for p in glob.glob(f"{skills_root}/*/SKILL.md")]
127
+ zero = sorted(s for s in skills if s not in timings)
128
+ if zero:
129
+ for s in zero:
130
+ print(f" ARCHIVE_CANDIDATE: {s} (0 calls — move to specs/epics/archive/ or delete)")
131
+ else:
132
+ print(" (no zero-usage skills)")
133
+ PY
134
+ fi
135
+ fi
136
+
137
+ echo ""
138
+ if [[ "$VIOLATIONS" -gt 0 ]]; then
139
+ echo "CATALOG INVALID: $VIOLATIONS violation(s), $WARNINGS warning(s)"
140
+ exit 1
141
+ fi
142
+ if $STRICT && [[ "$WARNINGS" -gt 0 ]]; then
143
+ echo "CATALOG INVALID (strict): $WARNINGS warning(s)"
144
+ exit 1
145
+ fi
146
+ echo "CATALOG OK: $WARNINGS warning(s)"
147
+ exit 0
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env bash
2
+ # story: e45s02
3
+ # CSO description discipline — max 1024 chars, no workflow-summary leakage.
4
+ set -euo pipefail
5
+
6
+ REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
7
+ SKILLS_ROOT="$REPO_ROOT/skills"
8
+ [[ -d "$SKILLS_ROOT" ]] || SKILLS_ROOT="$REPO_ROOT"
9
+
10
+ MAX_LEN=1024
11
+ ERRORS=0
12
+
13
+ audit_skill_description_cso() {
14
+ local path="$1"
15
+ local skill desc len
16
+
17
+ skill="$(basename "$(dirname "$path")")"
18
+ desc="$(
19
+ awk 'BEGIN{n=0} /^---$/{n++; next} n==1{print; next} n>=2{exit}' "$path" \
20
+ | grep -E '^description:' | head -1 | sed 's/^description:[[:space:]]*//' | sed 's/^"//;s/"$//'
21
+ )"
22
+
23
+ if [[ -z "$desc" ]]; then
24
+ echo "FAIL: $skill — missing description frontmatter"
25
+ ERRORS=$((ERRORS + 1))
26
+ return
27
+ fi
28
+
29
+ len=${#desc}
30
+ if (( len > MAX_LEN )); then
31
+ echo "FAIL: $skill — description ${len} chars (max ${MAX_LEN})"
32
+ ERRORS=$((ERRORS + 1))
33
+ fi
34
+
35
+ # Workflow-summary leakage: numbered steps, phase chains, verify prose in description
36
+ local leak=0
37
+ if echo "$desc" | grep -qE '(^|[[:space:]])([0-9]+\.|Step [0-9]+|First,|Then,|Finally,|→ verify:|HARD GATE|Process:|Workflow:)'; then
38
+ leak=1
39
+ fi
40
+ if echo "$desc" | grep -qE '(discover →|scope-work →|plan-work →|develop-tdd →|verify-work →|→ .* → )'; then
41
+ leak=1
42
+ fi
43
+ if (( leak )); then
44
+ echo "FAIL: $skill — workflow-summary leakage in description (keep triggers only; move steps to body)"
45
+ ERRORS=$((ERRORS + 1))
46
+ fi
47
+
48
+ if echo "$desc" | grep -qE 'model:[[:space:]]*(haiku|sonnet|opus)'; then
49
+ echo "FAIL: $skill — model hint belongs in frontmatter, not description"
50
+ ERRORS=$((ERRORS + 1))
51
+ fi
52
+ }
53
+
54
+ if [[ $# -gt 0 ]]; then
55
+ for f in "$@"; do
56
+ [[ -f "$f" ]] || { echo "FAIL: not found: $f" >&2; exit 1; }
57
+ audit_skill_description_cso "$f"
58
+ done
59
+ else
60
+ while IFS= read -r f; do
61
+ audit_skill_description_cso "$f"
62
+ done < <(find "$SKILLS_ROOT" -maxdepth 2 -name SKILL.md | sort)
63
+ fi
64
+
65
+ if (( ERRORS > 0 )); then
66
+ echo "validate-skill-description: $ERRORS issue(s)" >&2
67
+ exit 1
68
+ fi
69
+
70
+ echo "validate-skill-description: PASS"
@@ -1,4 +1,6 @@
1
1
  # story: e51s04
2
+ # story: e45s18
3
+ # story: e45s31
2
4
  ---
3
5
  name: audit-code
4
6
  model: haiku
@@ -14,11 +16,27 @@ Run this self-review before asking anyone else to look at the code. The goal is
14
16
 
15
17
  **Distinct from `request-review`:** This is the coding agent checking its own work. No second agent is involved. Run this first; run `request-review` after this passes.
16
18
 
19
+ ## Look-here-first (churn heuristic)
20
+
21
+ Before the checklist, rank changed files by git churn and review **high-churn hotspots first** — they carry the most latent risk regardless of diff size.
22
+
23
+ ```bash
24
+ bash scripts/bp-churn-rank.sh --since 90.days --limit 15
25
+ ```
26
+
27
+ Apply the full checklist to churn-ranked files in descending order. Files with zero recent commits but large diffs still get reviewed; churn only sets priority, not scope.
28
+
17
29
  ## Modes
18
30
 
19
31
  - Default: full checklist
20
32
  - --quick: Run only Supply Chain and Test Coverage. Use for changes under 50 LOC.
21
33
  - --gate: Non-interactive mode for automated CI gating (used by build-epic step 6). Exit with non-zero status code (`exit 1`) on ANY checklist failure; `exit 0` only if ALL items pass. Produces a compact pass/fail summary to stderr. On failure, list every ✗ item with reason.
34
+ - --parallel: Run checklist sections in **isolated git worktrees** (e45s18) so concurrent checks cannot corrupt each other's working tree. See [REFERENCE.md](REFERENCE.md) or:
35
+
36
+ ```bash
37
+ bash scripts/lib/parallel-review-worktrees.sh audit-code
38
+ ```
39
+
22
40
 
23
41
  ## Checklist
24
42
 
@@ -110,24 +128,12 @@ Report the checklist with ✓ / ✗ per item. For each ✗, describe what needs
110
128
  If all items pass: suggest running `request-review` for an independent second opinion.
111
129
  If any items fail: fix them before proceeding.
112
130
 
113
- ### Gate mode output (`--gate`)
114
-
115
- In `--gate` mode, print one summary line per checklist section:
116
-
117
- ```
118
- PASS Supply Chain & Security
119
- FAIL Provenance & Metadata (2 items)
120
- PASS Law of Demeter
121
- ...
122
- ```
123
-
124
- Aggregate exit code: `0` if all sections PASS, `1` (non-zero) if any section FAILs. Write the full audit report to `specs/verifications/AUDIT-<epic>-<story>.md` as a permanent record.
131
+ In `--gate` mode, print one summary line per checklist section (`PASS Supply Chain` / `FAIL Provenance (2 items)`). Exit `0` only if all PASS. Write full report to `specs/verifications/AUDIT-<epic>-<story>.md`.
125
132
 
126
133
  ## Verify
127
134
 
128
135
  → verify: `test -f CONVENTIONS.md && test -d skills/enforce-first && test -d skills/request-review && echo "OK: audit-code dependencies present" || echo "FAIL"`
129
136
 
130
-
131
137
  ## Handoff
132
138
 
133
139
  Gate: READY -> next: commit-message
@@ -5,6 +5,8 @@ effort: standard
5
5
  description: Add a new requirement or reorder epics by WSJF against specs/release-plan.yaml and epic capsule directories. Modes Add and Reorder. Use when a new requirement arrives mid-release or the plan needs prioritization.
6
6
  ---
7
7
 
8
+ # story: e45s29
9
+
8
10
  # Change Request
9
11
 
10
12
  > **HARD GATE** — `specs/release-plan.yaml` must exist before running either mode. If it doesn't, run `plan-release` first.
@@ -19,7 +21,7 @@ Intake a new requirement mid-flight without disrupting work in progress.
19
21
 
20
22
  1. **Capture**: What is the change? What problem does it solve?
21
23
  2. **Locate**: Which existing stories in `specs/epics/` does it affect or replace?
22
- 3. **Draft**: Add story + `tasks[]` with Gherkin-style AC in epic YAML (each task has `verify`).
24
+ 3. **Draft**: Add story + `tasks[]` with Gherkin-style AC in epic YAML (each task has `verify`). Tag requirement deltas: `ADDED` / `MODIFIED` / `REMOVED` / `RENAMED` with before/after for non-`ADDED` changes (e45s29).
23
25
  4. **Place**: Append story under existing epic capsule, or create `specs/epics/eNN-slug.yaml` and register in `release-plan.yaml` `epics[]`.
24
26
  5. **Score**: Compute WSJF; note if it outranks in-progress work.
25
27
 
@@ -5,6 +5,8 @@ model: sonnet
5
5
  effort: standard
6
6
  ---
7
7
 
8
+ # story: e45s27
9
+
8
10
  # Compose Workflow
9
11
  > **HARD GATE** — **HARD GATE** — Workflows are orchestration, not automation. Do NOT create workflows for tasks that should be single skills. Workflow complexity must be justified.
10
12
 
@@ -21,6 +23,19 @@ effort: standard
21
23
  > **Prefer the YAML recipe format** over the legacy `specs/WORKFLOW-<name>.md` markdown format.
22
24
  > YAML recipes are command-mappable, machine-readable, and listed in the Standard Recipe Library.
23
25
 
26
+ ## Terminal-state taxonomy (e45s27)
27
+
28
+ Every workflow step and `/loop` tick MUST exit with exactly one terminal state:
29
+
30
+ | State | Meaning | Next action |
31
+ |-------|---------|-------------|
32
+ | `success` | Step verify passed; artifacts written | Advance to next skill in recipe |
33
+ | `no-op` | Nothing to do (already green / already applied) | Skip step; advance |
34
+ | `blocked` | External gate (approval, red CI, missing dep) | `diagnose-stall` or escalate to user |
35
+ | `exhausted` | Max iterations/cycles reached (review cap, dispatch cycles) | Stop; human decision required |
36
+
37
+ Record terminal state in `specs/state.yaml` `handoff.last_terminal_state` when a recipe step completes. `/loop` ticks that produce no progress for two consecutive wakes → invoke `diagnose-stall`.
38
+
24
39
  ## Standard Recipe Library
25
40
 
26
41
  Pre-built recipes in `specs/workflows/` map agentic stack commands to skill chains.
@@ -0,0 +1,57 @@
1
+ ---
2
+ name: context7-mcp
3
+ # story: e45s19 e45s20
4
+ model: haiku
5
+ effort: light
6
+ description: Fetch current library docs via Context7 MCP instead of training data. Use when user asks about frameworks, APIs, setup, or code examples for React, Next.js, Prisma, etc.
7
+ ---
8
+
9
+ # Context7 MCP
10
+
11
+ > **HARD GATE** — Max **3** Context7 tool calls per user question (`resolve-library-id` + `query-docs` count toward the cap). On quota/rate-limit errors, emit an explicit **CONTEXT7_UNAVAILABLE** block — do NOT silently answer from training data.
12
+ >
13
+ > **HARD GATE** — Before HTTP fetch, check `bash scripts/lib/doc-fetch-cache.sh get "<libraryId>:<query>"`. Cache hit within TTL → use cached body (no round-trip). On ETag mismatch after conditional refresh, replace cache entry.
14
+
15
+ ## When to Use
16
+
17
+ - Setup/configuration questions ("How do I configure Next.js middleware?")
18
+ - Code involving libraries ("Write a Prisma query for…")
19
+ - API references ("What are the Supabase auth methods?")
20
+ - User mentions specific frameworks (React, Vue, Svelte, Express, Tailwind, etc.)
21
+
22
+ ## Bounded Retry (max 3x)
23
+
24
+ | Attempt | Action |
25
+ |---------|--------|
26
+ | 1 | `resolve-library-id` → pick best match |
27
+ | 2 | `query-docs` with selected `libraryId` |
28
+ | 3 | Retry `query-docs` once with refined query (narrower scope) |
29
+
30
+ After 3 failures, stop and print:
31
+
32
+ ```
33
+ CONTEXT7_UNAVAILABLE
34
+ Reason: <quota|rate-limit|no-match|timeout>
35
+ Action: Ask user to retry later, paste official docs URL, or run `bts docs <lib>`.
36
+ Do NOT substitute training-data answers without labeling them UNVERIFIED.
37
+ ```
38
+
39
+ ## Fetch Cache (ETag-revalidated)
40
+
41
+ 1. **Cache key:** `"<libraryId>:<normalized-query>"` (lowercase, trimmed).
42
+ 2. **Read:** `bash scripts/lib/doc-fetch-cache.sh get "<key>"` — exit 0 → use cached body.
43
+ 3. **Miss / stale:** call `query-docs`; store via `doc-fetch-cache.sh put`.
44
+ 4. **TTL:** 300s default (`DOC_CACHE_TTL`). Stale entries refresh on next fetch; honor `ETag` when MCP returns it.
45
+
46
+ `bts docs <lib>` shares the same cache helper when invoked from this skill.
47
+
48
+ ## Process
49
+
50
+ 1. `resolve-library-id` with `libraryName` + full user `query`.
51
+ 2. Select match: name similarity, reputation, benchmark score; prefer version-specific IDs when user names a version.
52
+ 3. `query-docs` with `libraryId` + specific question (one concept per call).
53
+ 4. Answer using fetched docs; cite library/version when relevant.
54
+
55
+ ## Verify
56
+
57
+ → verify: `test -f scripts/lib/doc-fetch-cache.sh && grep -q CONTEXT7_UNAVAILABLE skills/context7-mcp/SKILL.md && echo OK || echo FAIL`