codex-genesis-harness 0.1.1 → 0.1.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.
Files changed (180) hide show
  1. package/.codebase/ARCHITECTURE_REVIEW_COMPLETE.md +216 -0
  2. package/.codebase/CURRENT_STATE.md +2 -0
  3. package/.codebase/DOMAIN_MODELS.md +5 -3
  4. package/.codebase/FILE_NAMING_CLARIFICATION.md +161 -0
  5. package/.codebase/HARNESS_COMPLETENESS_AUDIT.md +613 -0
  6. package/.codebase/IMPLEMENTATION_COMPLETE.md +429 -0
  7. package/.codebase/IMPLEMENTATION_HANDOFF.md +351 -0
  8. package/.codebase/IMPROVEMENTS_SUMMARY.md +419 -0
  9. package/.codebase/PHASE3_SKILLS_NAMING_COMPLETE.md +292 -0
  10. package/.codebase/PHASE_DEPENDENCY_MAP.md +486 -0
  11. package/.codebase/QUICK_START_SPEC_IMPACT.md +456 -0
  12. package/.codebase/README.md +139 -0
  13. package/.codebase/RECOVERY_POINTS.md +438 -0
  14. package/.codex/skills/genesis-api-sync/SKILL.md +354 -0
  15. package/.codex/skills/genesis-api-sync/agents/openai.yaml +7 -0
  16. package/.codex/skills/genesis-api-sync/checklists/api-sync-checklist.md +101 -0
  17. package/.codex/skills/genesis-api-sync/examples/example.md +68 -0
  18. package/.codex/skills/genesis-api-sync/templates/api-change-template.md +257 -0
  19. package/.codex/skills/genesis-debug-guide/SKILL.md +479 -0
  20. package/.codex/skills/genesis-debug-guide/agents/openai.yaml +7 -0
  21. package/.codex/skills/genesis-debug-guide/checklists/flaky-test-investigation.md +339 -0
  22. package/.codex/skills/genesis-debug-guide/checklists/production-bug-debug.md +210 -0
  23. package/.codex/skills/genesis-debug-guide/checklists/test-failure-debug.md +158 -0
  24. package/.codex/skills/genesis-debug-guide/examples/example.md +48 -0
  25. package/.codex/skills/genesis-debug-guide/observability/debug-commands.md +365 -0
  26. package/.codex/skills/genesis-debug-guide/playbooks/unit-test-failures.md +289 -0
  27. package/.codex/skills/genesis-debug-guide/templates/debug-investigation-log.md +288 -0
  28. package/.codex/skills/genesis-docs-automation/SKILL.md +1003 -0
  29. package/.codex/skills/genesis-docs-automation/agents/openai.yaml +7 -0
  30. package/.codex/skills/genesis-docs-automation/checklists/docs-validation.md +359 -0
  31. package/.codex/skills/genesis-docs-automation/checklists/spec-alignment.md +312 -0
  32. package/.codex/skills/genesis-docs-automation/examples/example.md +59 -0
  33. package/.codex/skills/genesis-docs-automation/observability/docs-tracking.md +382 -0
  34. package/.codex/skills/genesis-docs-automation/playbooks/auto-update-flow.md +851 -0
  35. package/.codex/skills/genesis-docs-automation/playbooks/changelog-generation.md +491 -0
  36. package/.codex/skills/genesis-docs-automation/templates/changelog-entry-template.md +187 -0
  37. package/.codex/skills/genesis-docs-automation/templates/handoff-template.md +297 -0
  38. package/.codex/skills/genesis-harness/SKILL.md +734 -82
  39. package/.codex/skills/genesis-harness/checklists/bug-fix-qa.md +169 -0
  40. package/.codex/skills/genesis-harness/checklists/new-feature-qa.md +157 -0
  41. package/.codex/skills/genesis-harness/checklists/refactor-qa.md +216 -0
  42. package/.codex/skills/genesis-harness/checklists/requirements-validation.md +211 -0
  43. package/.codex/skills/genesis-harness/resources/change-impact-matrix-template.md +204 -0
  44. package/.codex/skills/genesis-harness/resources/foundation-phase-template.md +131 -0
  45. package/.codex/skills/genesis-harness/resources/phase-00-foundation-template.md +76 -0
  46. package/.codex/skills/genesis-harness/resources/post-implementation-guide.md +347 -0
  47. package/.codex/skills/genesis-harness/scripts/check-architecture-boundaries.sh +23 -23
  48. package/.codex/skills/genesis-harness/scripts/check-docs-sync.sh +24 -24
  49. package/.codex/skills/genesis-harness/scripts/check-no-debug-logs.sh +21 -21
  50. package/.codex/skills/genesis-harness/scripts/check-required-planning-files.sh +46 -46
  51. package/.codex/skills/genesis-harness/scripts/check-spec-changelog.sh +24 -24
  52. package/.codex/skills/genesis-harness/scripts/check-task-tracking.sh +25 -25
  53. package/.codex/skills/genesis-harness/scripts/compact-context.sh +54 -0
  54. package/.codex/skills/genesis-harness/scripts/create-adr.sh +74 -74
  55. package/.codex/skills/genesis-harness/scripts/create-bug.sh +160 -160
  56. package/.codex/skills/genesis-harness/scripts/create-feature.sh +217 -217
  57. package/.codex/skills/genesis-harness/scripts/detect-stack.sh +26 -26
  58. package/.codex/skills/genesis-harness/scripts/init-planning.sh +750 -719
  59. package/.codex/skills/genesis-harness/scripts/list-changed-files.sh +12 -12
  60. package/.codex/skills/genesis-harness/scripts/offload-log.sh +72 -0
  61. package/.codex/skills/genesis-harness/scripts/run-verification.sh +47 -47
  62. package/.codex/skills/genesis-harness/scripts/run-verify-loop.sh +75 -0
  63. package/.codex/skills/genesis-harness/scripts/update-state.sh +33 -33
  64. package/.codex/skills/genesis-harness-engineering/SKILL.md +159 -0
  65. package/.codex/skills/genesis-harness-engineering/checklists/checklist.md +48 -0
  66. package/.codex/skills/genesis-harness-engineering/examples/example.md +57 -0
  67. package/.codex/skills/genesis-harness-engineering/playbooks/harness-evolution.md +99 -0
  68. package/.codex/skills/genesis-harness-engineering/templates/harness-change-template.md +37 -0
  69. package/.codex/skills/genesis-observability-automation/SKILL.md +382 -0
  70. package/.codex/skills/genesis-observability-automation/agents/openai.yaml +7 -0
  71. package/.codex/skills/genesis-observability-automation/examples/example.md +86 -0
  72. package/.codex/skills/genesis-performance-profiling/SKILL.md +510 -0
  73. package/.codex/skills/genesis-performance-profiling/agents/openai.yaml +6 -0
  74. package/.codex/skills/genesis-performance-profiling/checklists/optimization-verification.md +199 -0
  75. package/.codex/skills/genesis-performance-profiling/checklists/performance-baseline.md +183 -0
  76. package/.codex/skills/genesis-performance-profiling/examples/example.md +234 -0
  77. package/.codex/skills/genesis-performance-profiling/observability/performance-tracking.md +202 -0
  78. package/.codex/skills/genesis-performance-profiling/playbooks/load-testing-orchestration.md +593 -0
  79. package/.codex/skills/genesis-performance-profiling/playbooks/profiling-playbook.md +601 -0
  80. package/.codex/skills/genesis-performance-profiling/templates/load-test-config-template.md +428 -0
  81. package/.codex/skills/genesis-performance-profiling/templates/performance-report-template.md +238 -0
  82. package/.codex/skills/genesis-release-orchestration/SKILL.md +653 -0
  83. package/.codex/skills/genesis-release-orchestration/agents/openai.yaml +7 -0
  84. package/.codex/skills/genesis-release-orchestration/checklists/post-deployment-verification.md +274 -0
  85. package/.codex/skills/genesis-release-orchestration/checklists/pre-release-validation.md +220 -0
  86. package/.codex/skills/genesis-release-orchestration/examples/example.md +78 -0
  87. package/.codex/skills/genesis-release-orchestration/observability/release-tracking.md +253 -0
  88. package/.codex/skills/genesis-release-orchestration/playbooks/canary-deployment-orchestration.md +472 -0
  89. package/.codex/skills/genesis-release-orchestration/playbooks/semantic-versioning-automation.md +494 -0
  90. package/.codex/skills/genesis-release-orchestration/templates/deployment-strategy-template.md +303 -0
  91. package/.codex/skills/genesis-release-orchestration/templates/release-runbook-template.md +420 -0
  92. package/.codex/skills/genesis-research-first/SKILL.md +237 -0
  93. package/.codex/skills/genesis-research-first/agents/openai.yaml +7 -0
  94. package/.codex/skills/genesis-research-first/examples/example.md +85 -0
  95. package/.codex/skills/genesis-spec-propagation/SKILL.md +534 -0
  96. package/.codex/skills/genesis-spec-propagation/agents/openai.yaml +7 -0
  97. package/.codex/skills/genesis-spec-propagation/checklists/phase-update-verification.md +384 -0
  98. package/.codex/skills/genesis-spec-propagation/checklists/spec-change-detection.md +257 -0
  99. package/.codex/skills/genesis-spec-propagation/examples/example.md +63 -0
  100. package/.codex/skills/genesis-spec-propagation/observability/propagation-tracking.md +373 -0
  101. package/.codex/skills/genesis-spec-propagation/playbooks/breaking-change-propagation.md +692 -0
  102. package/.codex/skills/genesis-spec-propagation/playbooks/feature-change-propagation.md +434 -0
  103. package/.codex/skills/genesis-spec-propagation/templates/migration-guide-template.md +407 -0
  104. package/.codex/skills/spec-impact-engine/SKILL.md +504 -0
  105. package/.codex/skills/spec-impact-engine/agents/openai.yaml +7 -0
  106. package/.codex/skills/spec-impact-engine/detect-spec-changes.sh +262 -0
  107. package/.codex/skills/spec-impact-engine/examples/example.md +98 -0
  108. package/.codex/skills/spec-impact-engine/templates/impact-report.md +248 -0
  109. package/.codex/skills/spec-impact-engine/templates/migration-guide.md +223 -0
  110. package/.codex-plugin/plugin.json +1 -1
  111. package/README.EN.md +719 -0
  112. package/README.VI.md +712 -0
  113. package/README.md +261 -107
  114. package/VERSION +1 -1
  115. package/bin/genesis-harness.js +20 -11
  116. package/package.json +1 -1
  117. package/scripts/README.md +342 -0
  118. package/scripts/compact-context.sh +54 -0
  119. package/scripts/detect-changes.sh +152 -0
  120. package/scripts/install.sh +50 -41
  121. package/scripts/offload-log.sh +72 -0
  122. package/scripts/run-evals.sh +70 -43
  123. package/scripts/run-verify-loop.sh +75 -0
  124. package/scripts/uninstall.sh +52 -43
  125. package/scripts/verify.sh +165 -73
  126. package/.codex/skills/harness-engineering-skill/SKILL.md +0 -45
  127. package/.codex/skills/harness-engineering-skill/checklists/checklist.md +0 -8
  128. package/.codex/skills/harness-engineering-skill/examples/example.md +0 -4
  129. package/.codex/skills/harness-engineering-skill/templates/harness-change-template.md +0 -8
  130. /package/.codex/skills/{ai-provider-skill → genesis-ai-provider}/SKILL.md +0 -0
  131. /package/.codex/skills/{ai-provider-skill → genesis-ai-provider}/agents/openai.yaml +0 -0
  132. /package/.codex/skills/{ai-provider-skill → genesis-ai-provider}/checklists/checklist.md +0 -0
  133. /package/.codex/skills/{ai-provider-skill → genesis-ai-provider}/examples/example.md +0 -0
  134. /package/.codex/skills/{ai-provider-skill → genesis-ai-provider}/templates/provider-contract-template.md +0 -0
  135. /package/.codex/skills/{api-contract-skill → genesis-api-contract}/SKILL.md +0 -0
  136. /package/.codex/skills/{api-contract-skill → genesis-api-contract}/agents/openai.yaml +0 -0
  137. /package/.codex/skills/{api-contract-skill → genesis-api-contract}/checklists/checklist.md +0 -0
  138. /package/.codex/skills/{api-contract-skill → genesis-api-contract}/examples/example.md +0 -0
  139. /package/.codex/skills/{api-contract-skill → genesis-api-contract}/templates/api-contract-template.md +0 -0
  140. /package/.codex/skills/{architecture-skill → genesis-architecture}/SKILL.md +0 -0
  141. /package/.codex/skills/{architecture-skill → genesis-architecture}/agents/openai.yaml +0 -0
  142. /package/.codex/skills/{architecture-skill → genesis-architecture}/checklists/checklist.md +0 -0
  143. /package/.codex/skills/{architecture-skill → genesis-architecture}/examples/example.md +0 -0
  144. /package/.codex/skills/{architecture-skill → genesis-architecture}/templates/architecture-decision-template.md +0 -0
  145. /package/.codex/skills/{codebase-map-skill → genesis-codebase-map}/SKILL.md +0 -0
  146. /package/.codex/skills/{codebase-map-skill → genesis-codebase-map}/agents/openai.yaml +0 -0
  147. /package/.codex/skills/{codebase-map-skill → genesis-codebase-map}/checklists/checklist.md +0 -0
  148. /package/.codex/skills/{codebase-map-skill → genesis-codebase-map}/examples/example.md +0 -0
  149. /package/.codex/skills/{codebase-map-skill → genesis-codebase-map}/templates/map-update-template.md +0 -0
  150. /package/.codex/skills/{design-spec-skill → genesis-design-spec}/SKILL.md +0 -0
  151. /package/.codex/skills/{design-spec-skill → genesis-design-spec}/agents/openai.yaml +0 -0
  152. /package/.codex/skills/{design-spec-skill → genesis-design-spec}/checklists/checklist.md +0 -0
  153. /package/.codex/skills/{design-spec-skill → genesis-design-spec}/examples/example.md +0 -0
  154. /package/.codex/skills/{design-spec-skill → genesis-design-spec}/templates/design-spec-template.md +0 -0
  155. /package/.codex/skills/{docs-skill → genesis-docs}/SKILL.md +0 -0
  156. /package/.codex/skills/{docs-skill → genesis-docs}/agents/openai.yaml +0 -0
  157. /package/.codex/skills/{docs-skill → genesis-docs}/checklists/checklist.md +0 -0
  158. /package/.codex/skills/{docs-skill → genesis-docs}/examples/example.md +0 -0
  159. /package/.codex/skills/{docs-skill → genesis-docs}/templates/docs-update-template.md +0 -0
  160. /package/.codex/skills/{harness-engineering-skill → genesis-harness-engineering}/agents/openai.yaml +0 -0
  161. /package/.codex/skills/{pipeline-orchestration-skill → genesis-pipeline-orchestration}/SKILL.md +0 -0
  162. /package/.codex/skills/{pipeline-orchestration-skill → genesis-pipeline-orchestration}/agents/openai.yaml +0 -0
  163. /package/.codex/skills/{pipeline-orchestration-skill → genesis-pipeline-orchestration}/checklists/checklist.md +0 -0
  164. /package/.codex/skills/{pipeline-orchestration-skill → genesis-pipeline-orchestration}/examples/example.md +0 -0
  165. /package/.codex/skills/{pipeline-orchestration-skill → genesis-pipeline-orchestration}/templates/orchestration-template.md +0 -0
  166. /package/.codex/skills/{planning-skill → genesis-planning}/SKILL.md +0 -0
  167. /package/.codex/skills/{planning-skill → genesis-planning}/agents/openai.yaml +0 -0
  168. /package/.codex/skills/{planning-skill → genesis-planning}/checklists/checklist.md +0 -0
  169. /package/.codex/skills/{planning-skill → genesis-planning}/examples/example.md +0 -0
  170. /package/.codex/skills/{planning-skill → genesis-planning}/templates/plan-template.md +0 -0
  171. /package/.codex/skills/{release-skill → genesis-release}/SKILL.md +0 -0
  172. /package/.codex/skills/{release-skill → genesis-release}/agents/openai.yaml +0 -0
  173. /package/.codex/skills/{release-skill → genesis-release}/checklists/checklist.md +0 -0
  174. /package/.codex/skills/{release-skill → genesis-release}/examples/example.md +0 -0
  175. /package/.codex/skills/{release-skill → genesis-release}/templates/release-checklist-template.md +0 -0
  176. /package/.codex/skills/{research-skill → genesis-research}/SKILL.md +0 -0
  177. /package/.codex/skills/{research-skill → genesis-research}/agents/openai.yaml +0 -0
  178. /package/.codex/skills/{research-skill → genesis-research}/checklists/checklist.md +0 -0
  179. /package/.codex/skills/{research-skill → genesis-research}/examples/example.md +0 -0
  180. /package/.codex/skills/{research-skill → genesis-research}/templates/research-note-template.md +0 -0
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env bash
2
+ # ==============================================================================
3
+ # Genesis Codex Harness — Context Compaction Engine
4
+ # ==============================================================================
5
+ # Summarizes active project planning files, active tasks, and logs into a single
6
+ # .planning/CONTEXT_SUMMARY.md file to safely offload context before compacting.
7
+ # Reduces context window usage and prevents Context Rot.
8
+ # ==============================================================================
9
+
10
+ set -euo pipefail
11
+
12
+ PLANNING_DIR="${1:-.planning}"
13
+ SUMMARY_FILE="$PLANNING_DIR/CONTEXT_SUMMARY.md"
14
+
15
+ if [ ! -d "$PLANNING_DIR" ]; then
16
+ echo "Error: Planning directory '$PLANNING_DIR' does not exist." >&2
17
+ exit 1
18
+ fi
19
+
20
+ echo "==> Compacting active context..."
21
+
22
+ {
23
+ echo "# Context Compaction Summary"
24
+ echo "Generated: $(date +'%Y-%m-%d %H:%M:%S')"
25
+ echo ""
26
+ echo "## 📊 Active State Summary"
27
+ if [ -f "$PLANNING_DIR/STATE.md" ]; then
28
+ grep -E "^- (Current Phase|Active Feature|Last Completed Task|Next Task|Blockers):" "$PLANNING_DIR/STATE.md" || true
29
+ else
30
+ echo "State file not found. Project initialized but state unpopulated."
31
+ fi
32
+ echo ""
33
+ echo "## 🎯 Key Architectural Invariants"
34
+ if [ -f "$PLANNING_DIR/ARCHITECTURE.md" ]; then
35
+ head -n 25 "$PLANNING_DIR/ARCHITECTURE.md"
36
+ else
37
+ echo "Architecture file not found."
38
+ fi
39
+ echo ""
40
+ echo "## 📝 Active Task Progress"
41
+ # Find all task lists in active features or bugs
42
+ find "$PLANNING_DIR/features" "$PLANNING_DIR/bugs" -name "TASKS.md" 2>/dev/null | while read -r task_file; do
43
+ echo "### Tasks for: $(basename "$(dirname "$task_file")")"
44
+ grep -E "^- \[[x~ ]\]" "$task_file" | tail -n 15 || true
45
+ echo ""
46
+ done
47
+ echo ""
48
+ echo "## ⚠️ Fragile Areas & Lessons Learned"
49
+ if [ -f "$PLANNING_DIR/PITFALLS.md" ]; then
50
+ head -n 15 "$PLANNING_DIR/PITFALLS.md"
51
+ fi
52
+ } > "$SUMMARY_FILE"
53
+
54
+ echo "==> Context compaction complete! Summary saved to: file://$(pwd)/$SUMMARY_FILE"
@@ -1,74 +1,74 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- usage() {
5
- echo "Usage: $0 <slug> [title] [root]" >&2
6
- exit 2
7
- }
8
-
9
- slug="${1:-}"
10
- title="${2:-$slug}"
11
- root="${3:-.}"
12
- [ -n "$slug" ] || usage
13
-
14
- case "$slug" in
15
- *[!a-z0-9-]*|'') echo "Slug must use lowercase letters, numbers, and hyphens." >&2; exit 2 ;;
16
- esac
17
-
18
- cd "$root"
19
- mkdir -p .planning/decisions
20
-
21
- next="$(
22
- find .planning/decisions -maxdepth 1 -type f -name 'ADR-[0-9][0-9][0-9]-*.md' 2>/dev/null \
23
- | sed -E 's#.*/ADR-([0-9]{3})-.*#\1#' \
24
- | sort -n \
25
- | tail -1
26
- )"
27
- if [ -z "$next" ]; then
28
- number="001"
29
- else
30
- number="$(printf '%03d' "$((10#$next + 1))")"
31
- fi
32
-
33
- file=".planning/decisions/ADR-${number}-${slug}.md"
34
- if [ -e "$file" ]; then
35
- echo "ADR already exists: $file" >&2
36
- exit 1
37
- fi
38
-
39
- cat > "$file" <<EOF
40
- # ADR-${number}: $title
41
-
42
- Status: Proposed
43
- Date: $(date +%Y-%m-%d)
44
-
45
- ## Context
46
-
47
- TBD
48
-
49
- ## Decision
50
-
51
- TBD
52
-
53
- ## Alternatives Considered
54
-
55
- - [ ] TBD
56
-
57
- ## Consequences
58
-
59
- - [ ] TBD
60
-
61
- ## Risks
62
-
63
- - [ ] TBD
64
-
65
- ## Mitigation
66
-
67
- - [ ] TBD
68
-
69
- ## Verification Evidence
70
-
71
- TBD
72
- EOF
73
-
74
- echo "$file"
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ usage() {
5
+ echo "Usage: $0 <slug> [title] [root]" >&2
6
+ exit 2
7
+ }
8
+
9
+ slug="${1:-}"
10
+ title="${2:-$slug}"
11
+ root="${3:-.}"
12
+ [ -n "$slug" ] || usage
13
+
14
+ case "$slug" in
15
+ *[!a-z0-9-]*|'') echo "Slug must use lowercase letters, numbers, and hyphens." >&2; exit 2 ;;
16
+ esac
17
+
18
+ cd "$root"
19
+ mkdir -p .planning/decisions
20
+
21
+ next="$(
22
+ find .planning/decisions -maxdepth 1 -type f -name 'ADR-[0-9][0-9][0-9]-*.md' 2>/dev/null \
23
+ | sed -E 's#.*/ADR-([0-9]{3})-.*#\1#' \
24
+ | sort -n \
25
+ | tail -1
26
+ )"
27
+ if [ -z "$next" ]; then
28
+ number="001"
29
+ else
30
+ number="$(printf '%03d' "$((10#$next + 1))")"
31
+ fi
32
+
33
+ file=".planning/decisions/ADR-${number}-${slug}.md"
34
+ if [ -e "$file" ]; then
35
+ echo "ADR already exists: $file" >&2
36
+ exit 1
37
+ fi
38
+
39
+ cat > "$file" <<EOF
40
+ # ADR-${number}: $title
41
+
42
+ Status: Proposed
43
+ Date: $(date +%Y-%m-%d)
44
+
45
+ ## Context
46
+
47
+ TBD
48
+
49
+ ## Decision
50
+
51
+ TBD
52
+
53
+ ## Alternatives Considered
54
+
55
+ - [ ] TBD
56
+
57
+ ## Consequences
58
+
59
+ - [ ] TBD
60
+
61
+ ## Risks
62
+
63
+ - [ ] TBD
64
+
65
+ ## Mitigation
66
+
67
+ - [ ] TBD
68
+
69
+ ## Verification Evidence
70
+
71
+ TBD
72
+ EOF
73
+
74
+ echo "$file"
@@ -1,160 +1,160 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- usage() {
5
- echo "Usage: $0 <slug> [summary] [root]" >&2
6
- exit 2
7
- }
8
-
9
- slug="${1:-}"
10
- summary="${2:-TBD}"
11
- root="${3:-.}"
12
- [ -n "$slug" ] || usage
13
-
14
- case "$slug" in
15
- *[!a-z0-9-]*|'') echo "Slug must use lowercase letters, numbers, and hyphens." >&2; exit 2 ;;
16
- esac
17
-
18
- cd "$root"
19
- mkdir -p .planning/bugs
20
-
21
- next="$(
22
- find .planning/bugs -maxdepth 1 -type d -name '[0-9][0-9][0-9]-*' 2>/dev/null \
23
- | sed -E 's#.*/([0-9]{3})-.*#\1#' \
24
- | sort -n \
25
- | tail -1
26
- )"
27
- if [ -z "$next" ]; then
28
- number="001"
29
- else
30
- number="$(printf '%03d' "$((10#$next + 1))")"
31
- fi
32
-
33
- dir=".planning/bugs/${number}-${slug}"
34
- if [ -e "$dir" ]; then
35
- echo "Bug directory already exists: $dir" >&2
36
- exit 1
37
- fi
38
-
39
- mkdir -p "$dir"
40
-
41
- cat > "$dir/REPORT.md" <<EOF
42
- # Bug Report: $summary
43
-
44
- ## Summary
45
-
46
- $summary
47
-
48
- ## Expected Behavior
49
-
50
- - [ ] TBD
51
-
52
- ## Actual Behavior
53
-
54
- - [ ] TBD
55
-
56
- ## Reproduction Steps
57
-
58
- - [ ] TBD
59
-
60
- ## Environment
61
-
62
- TBD
63
- EOF
64
-
65
- cat > "$dir/ROOT_CAUSE.md" <<'EOF'
66
- # Root Cause
67
-
68
- ## Evidence
69
-
70
- - [ ] TBD
71
-
72
- ## Root Cause
73
-
74
- TBD
75
-
76
- ## Failed Assumption
77
-
78
- TBD
79
-
80
- ## Correct Pattern
81
-
82
- TBD
83
- EOF
84
-
85
- cat > "$dir/PLAN.md" <<'EOF'
86
- # Plan
87
-
88
- ## Files To Change
89
-
90
- ### File: `path/to/file`
91
-
92
- Change:
93
- Why:
94
- Risk:
95
- Test:
96
- Docs impact:
97
-
98
- ## Fix Steps
99
-
100
- - [ ] TBD
101
-
102
- ## Rollback Plan
103
-
104
- - [ ] TBD
105
- EOF
106
-
107
- cat > "$dir/TEST_CONTRACT.md" <<'EOF'
108
- # Test Contract
109
-
110
- - [ ] Reproduction fails before fix
111
- - [ ] Regression test or verification fails before fix
112
- - [ ] Regression test or verification passes after fix
113
- - [ ] Related edge case is covered
114
- EOF
115
-
116
- cat > "$dir/TASKS.md" <<'EOF'
117
- # Tasks
118
-
119
- - [ ] Read PITFALLS.md
120
- - [ ] Read LESSONS_LEARNED.md
121
- - [ ] Reproduce bug
122
- - [ ] Identify root cause
123
- - [ ] Write regression test or verification
124
- - [ ] Fix bug
125
- - [ ] Run verification
126
- - [ ] Update LESSONS_LEARNED.md
127
- - [ ] Update docs if behavior changed
128
- - [ ] Review changed files
129
- - [ ] Update STATE.md
130
- - [ ] Update SPEC_CHANGELOG.md if needed
131
- EOF
132
-
133
- cat > "$dir/VERIFICATION.md" <<'EOF'
134
- # Verification
135
-
136
- - [ ] Define reproduction command
137
- - [ ] Run failing verification before fix
138
- - [ ] Run passing verification after fix
139
-
140
- | Command | Result | Evidence |
141
- |---|---|---|
142
- | TBD | TBD | TBD |
143
- EOF
144
-
145
- cat > "$dir/REVIEW.md" <<'EOF'
146
- # Review
147
-
148
- - [ ] Changed files reviewed
149
- - [ ] Regression coverage checked
150
- - [ ] Docs impact checked
151
- - [ ] Debug logs removed
152
-
153
- ## Findings
154
-
155
- | Severity | File | Issue | Follow-Up |
156
- |---|---|---|---|
157
- | TBD | TBD | TBD | TBD |
158
- EOF
159
-
160
- echo "$dir"
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ usage() {
5
+ echo "Usage: $0 <slug> [summary] [root]" >&2
6
+ exit 2
7
+ }
8
+
9
+ slug="${1:-}"
10
+ summary="${2:-TBD}"
11
+ root="${3:-.}"
12
+ [ -n "$slug" ] || usage
13
+
14
+ case "$slug" in
15
+ *[!a-z0-9-]*|'') echo "Slug must use lowercase letters, numbers, and hyphens." >&2; exit 2 ;;
16
+ esac
17
+
18
+ cd "$root"
19
+ mkdir -p .planning/bugs
20
+
21
+ next="$(
22
+ find .planning/bugs -maxdepth 1 -type d -name '[0-9][0-9][0-9]-*' 2>/dev/null \
23
+ | sed -E 's#.*/([0-9]{3})-.*#\1#' \
24
+ | sort -n \
25
+ | tail -1
26
+ )"
27
+ if [ -z "$next" ]; then
28
+ number="001"
29
+ else
30
+ number="$(printf '%03d' "$((10#$next + 1))")"
31
+ fi
32
+
33
+ dir=".planning/bugs/${number}-${slug}"
34
+ if [ -e "$dir" ]; then
35
+ echo "Bug directory already exists: $dir" >&2
36
+ exit 1
37
+ fi
38
+
39
+ mkdir -p "$dir"
40
+
41
+ cat > "$dir/REPORT.md" <<EOF
42
+ # Bug Report: $summary
43
+
44
+ ## Summary
45
+
46
+ $summary
47
+
48
+ ## Expected Behavior
49
+
50
+ - [ ] TBD
51
+
52
+ ## Actual Behavior
53
+
54
+ - [ ] TBD
55
+
56
+ ## Reproduction Steps
57
+
58
+ - [ ] TBD
59
+
60
+ ## Environment
61
+
62
+ TBD
63
+ EOF
64
+
65
+ cat > "$dir/ROOT_CAUSE.md" <<'EOF'
66
+ # Root Cause
67
+
68
+ ## Evidence
69
+
70
+ - [ ] TBD
71
+
72
+ ## Root Cause
73
+
74
+ TBD
75
+
76
+ ## Failed Assumption
77
+
78
+ TBD
79
+
80
+ ## Correct Pattern
81
+
82
+ TBD
83
+ EOF
84
+
85
+ cat > "$dir/PLAN.md" <<'EOF'
86
+ # Plan
87
+
88
+ ## Files To Change
89
+
90
+ ### File: `path/to/file`
91
+
92
+ Change:
93
+ Why:
94
+ Risk:
95
+ Test:
96
+ Docs impact:
97
+
98
+ ## Fix Steps
99
+
100
+ - [ ] TBD
101
+
102
+ ## Rollback Plan
103
+
104
+ - [ ] TBD
105
+ EOF
106
+
107
+ cat > "$dir/TEST_CONTRACT.md" <<'EOF'
108
+ # Test Contract
109
+
110
+ - [ ] Reproduction fails before fix
111
+ - [ ] Regression test or verification fails before fix
112
+ - [ ] Regression test or verification passes after fix
113
+ - [ ] Related edge case is covered
114
+ EOF
115
+
116
+ cat > "$dir/TASKS.md" <<'EOF'
117
+ # Tasks
118
+
119
+ - [ ] Read PITFALLS.md
120
+ - [ ] Read LESSONS_LEARNED.md
121
+ - [ ] Reproduce bug
122
+ - [ ] Identify root cause
123
+ - [ ] Write regression test or verification
124
+ - [ ] Fix bug
125
+ - [ ] Run verification
126
+ - [ ] Update LESSONS_LEARNED.md
127
+ - [ ] Update docs if behavior changed
128
+ - [ ] Review changed files
129
+ - [ ] Update STATE.md
130
+ - [ ] Update SPEC_CHANGELOG.md if needed
131
+ EOF
132
+
133
+ cat > "$dir/VERIFICATION.md" <<'EOF'
134
+ # Verification
135
+
136
+ - [ ] Define reproduction command
137
+ - [ ] Run failing verification before fix
138
+ - [ ] Run passing verification after fix
139
+
140
+ | Command | Result | Evidence |
141
+ |---|---|---|
142
+ | TBD | TBD | TBD |
143
+ EOF
144
+
145
+ cat > "$dir/REVIEW.md" <<'EOF'
146
+ # Review
147
+
148
+ - [ ] Changed files reviewed
149
+ - [ ] Regression coverage checked
150
+ - [ ] Docs impact checked
151
+ - [ ] Debug logs removed
152
+
153
+ ## Findings
154
+
155
+ | Severity | File | Issue | Follow-Up |
156
+ |---|---|---|---|
157
+ | TBD | TBD | TBD | TBD |
158
+ EOF
159
+
160
+ echo "$dir"