mindforge-cc 1.0.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 (324) hide show
  1. package/.agent/CLAUDE.md +462 -0
  2. package/.agent/forge/help.md +7 -0
  3. package/.agent/forge/init-project.md +32 -0
  4. package/.agent/forge/plan-phase.md +30 -0
  5. package/.agent/mindforge/approve.md +18 -0
  6. package/.agent/mindforge/audit.md +30 -0
  7. package/.agent/mindforge/benchmark.md +33 -0
  8. package/.agent/mindforge/complete-milestone.md +18 -0
  9. package/.agent/mindforge/debug.md +126 -0
  10. package/.agent/mindforge/discuss-phase.md +138 -0
  11. package/.agent/mindforge/execute-phase.md +165 -0
  12. package/.agent/mindforge/health.md +21 -0
  13. package/.agent/mindforge/help.md +23 -0
  14. package/.agent/mindforge/init-org.md +131 -0
  15. package/.agent/mindforge/init-project.md +155 -0
  16. package/.agent/mindforge/install-skill.md +15 -0
  17. package/.agent/mindforge/map-codebase.md +298 -0
  18. package/.agent/mindforge/metrics.md +22 -0
  19. package/.agent/mindforge/migrate.md +40 -0
  20. package/.agent/mindforge/milestone.md +12 -0
  21. package/.agent/mindforge/next.md +105 -0
  22. package/.agent/mindforge/plan-phase.md +125 -0
  23. package/.agent/mindforge/plugins.md +40 -0
  24. package/.agent/mindforge/pr-review.md +41 -0
  25. package/.agent/mindforge/profile-team.md +23 -0
  26. package/.agent/mindforge/publish-skill.md +19 -0
  27. package/.agent/mindforge/quick.md +135 -0
  28. package/.agent/mindforge/release.md +10 -0
  29. package/.agent/mindforge/retrospective.md +26 -0
  30. package/.agent/mindforge/review.md +157 -0
  31. package/.agent/mindforge/security-scan.md +233 -0
  32. package/.agent/mindforge/ship.md +100 -0
  33. package/.agent/mindforge/skills.md +141 -0
  34. package/.agent/mindforge/status.md +104 -0
  35. package/.agent/mindforge/sync-confluence.md +11 -0
  36. package/.agent/mindforge/sync-jira.md +12 -0
  37. package/.agent/mindforge/tokens.md +8 -0
  38. package/.agent/mindforge/update.md +42 -0
  39. package/.agent/mindforge/verify-phase.md +62 -0
  40. package/.agent/mindforge/workspace.md +29 -0
  41. package/.claude/CLAUDE.md +462 -0
  42. package/.claude/commands/forge/help.md +7 -0
  43. package/.claude/commands/forge/init-project.md +32 -0
  44. package/.claude/commands/forge/plan-phase.md +30 -0
  45. package/.claude/commands/mindforge/approve.md +18 -0
  46. package/.claude/commands/mindforge/audit.md +30 -0
  47. package/.claude/commands/mindforge/benchmark.md +33 -0
  48. package/.claude/commands/mindforge/complete-milestone.md +18 -0
  49. package/.claude/commands/mindforge/debug.md +126 -0
  50. package/.claude/commands/mindforge/discuss-phase.md +138 -0
  51. package/.claude/commands/mindforge/execute-phase.md +165 -0
  52. package/.claude/commands/mindforge/health.md +21 -0
  53. package/.claude/commands/mindforge/help.md +23 -0
  54. package/.claude/commands/mindforge/init-org.md +131 -0
  55. package/.claude/commands/mindforge/init-project.md +155 -0
  56. package/.claude/commands/mindforge/install-skill.md +15 -0
  57. package/.claude/commands/mindforge/map-codebase.md +298 -0
  58. package/.claude/commands/mindforge/metrics.md +22 -0
  59. package/.claude/commands/mindforge/migrate.md +40 -0
  60. package/.claude/commands/mindforge/milestone.md +12 -0
  61. package/.claude/commands/mindforge/next.md +105 -0
  62. package/.claude/commands/mindforge/plan-phase.md +125 -0
  63. package/.claude/commands/mindforge/plugins.md +40 -0
  64. package/.claude/commands/mindforge/pr-review.md +41 -0
  65. package/.claude/commands/mindforge/profile-team.md +23 -0
  66. package/.claude/commands/mindforge/publish-skill.md +19 -0
  67. package/.claude/commands/mindforge/quick.md +135 -0
  68. package/.claude/commands/mindforge/release.md +10 -0
  69. package/.claude/commands/mindforge/retrospective.md +26 -0
  70. package/.claude/commands/mindforge/review.md +157 -0
  71. package/.claude/commands/mindforge/security-scan.md +233 -0
  72. package/.claude/commands/mindforge/ship.md +100 -0
  73. package/.claude/commands/mindforge/skills.md +141 -0
  74. package/.claude/commands/mindforge/status.md +104 -0
  75. package/.claude/commands/mindforge/sync-confluence.md +11 -0
  76. package/.claude/commands/mindforge/sync-jira.md +12 -0
  77. package/.claude/commands/mindforge/tokens.md +8 -0
  78. package/.claude/commands/mindforge/update.md +42 -0
  79. package/.claude/commands/mindforge/verify-phase.md +62 -0
  80. package/.claude/commands/mindforge/workspace.md +29 -0
  81. package/.forge/org/CONVENTIONS.md +0 -0
  82. package/.forge/org/ORG.md +0 -0
  83. package/.forge/org/SECURITY.md +0 -0
  84. package/.forge/org/TOOLS.md +0 -0
  85. package/.forge/personas/analyst.md +0 -0
  86. package/.forge/personas/architect.md +0 -0
  87. package/.forge/personas/debug-specialist.md +0 -0
  88. package/.forge/personas/developer.md +26 -0
  89. package/.forge/personas/qa-engineer.md +0 -0
  90. package/.forge/personas/release-manager.md +0 -0
  91. package/.forge/personas/security-reviewer.md +33 -0
  92. package/.forge/personas/tech-writer.md +0 -0
  93. package/.forge/skills/api-design/SKILL.md +0 -0
  94. package/.forge/skills/code-quality/SKILL.md +0 -0
  95. package/.forge/skills/documentation/SKILL.md +0 -0
  96. package/.forge/skills/security-review/SKILL.md +23 -0
  97. package/.forge/skills/testing-standards/SKILL.md +27 -0
  98. package/.github/workflows/mindforge-ci.yml +224 -0
  99. package/.gitlab-ci-mindforge.yml +18 -0
  100. package/.mindforge/MINDFORGE-SCHEMA.json +165 -0
  101. package/.mindforge/audit/AUDIT-SCHEMA.md +451 -0
  102. package/.mindforge/ci/ci-config-schema.md +21 -0
  103. package/.mindforge/ci/ci-mode.md +179 -0
  104. package/.mindforge/ci/github-actions-adapter.md +224 -0
  105. package/.mindforge/ci/gitlab-ci-adapter.md +31 -0
  106. package/.mindforge/ci/jenkins-adapter.md +44 -0
  107. package/.mindforge/distribution/registry-client.md +166 -0
  108. package/.mindforge/distribution/registry-schema.md +96 -0
  109. package/.mindforge/distribution/skill-publisher.md +44 -0
  110. package/.mindforge/distribution/skill-validator.md +74 -0
  111. package/.mindforge/engine/compaction-protocol.md +182 -0
  112. package/.mindforge/engine/context-injector.md +128 -0
  113. package/.mindforge/engine/dependency-parser.md +113 -0
  114. package/.mindforge/engine/skills/conflict-resolver.md +69 -0
  115. package/.mindforge/engine/skills/loader.md +184 -0
  116. package/.mindforge/engine/skills/registry.md +98 -0
  117. package/.mindforge/engine/skills/versioning.md +75 -0
  118. package/.mindforge/engine/verification-pipeline.md +111 -0
  119. package/.mindforge/engine/wave-executor.md +235 -0
  120. package/.mindforge/governance/GOVERNANCE-CONFIG.md +17 -0
  121. package/.mindforge/governance/approval-workflow.md +37 -0
  122. package/.mindforge/governance/change-classifier.md +63 -0
  123. package/.mindforge/governance/compliance-gates.md +31 -0
  124. package/.mindforge/integrations/confluence.md +27 -0
  125. package/.mindforge/integrations/connection-manager.md +163 -0
  126. package/.mindforge/integrations/github.md +25 -0
  127. package/.mindforge/integrations/gitlab.md +13 -0
  128. package/.mindforge/integrations/jira.md +102 -0
  129. package/.mindforge/integrations/slack.md +41 -0
  130. package/.mindforge/intelligence/antipattern-detector.md +75 -0
  131. package/.mindforge/intelligence/difficulty-scorer.md +55 -0
  132. package/.mindforge/intelligence/health-engine.md +208 -0
  133. package/.mindforge/intelligence/skill-gap-analyser.md +40 -0
  134. package/.mindforge/intelligence/smart-compaction.md +71 -0
  135. package/.mindforge/metrics/METRICS-SCHEMA.md +42 -0
  136. package/.mindforge/metrics/quality-tracker.md +32 -0
  137. package/.mindforge/monorepo/cross-package-planner.md +114 -0
  138. package/.mindforge/monorepo/dependency-graph-builder.md +32 -0
  139. package/.mindforge/monorepo/workspace-detector.md +129 -0
  140. package/.mindforge/org/CONVENTIONS.md +62 -0
  141. package/.mindforge/org/ORG.md +51 -0
  142. package/.mindforge/org/SECURITY.md +50 -0
  143. package/.mindforge/org/TOOLS.md +53 -0
  144. package/.mindforge/org/integrations/INTEGRATIONS-CONFIG.md +58 -0
  145. package/.mindforge/org/skills/MANIFEST.md +38 -0
  146. package/.mindforge/personas/analyst.md +52 -0
  147. package/.mindforge/personas/architect.md +75 -0
  148. package/.mindforge/personas/debug-specialist.md +52 -0
  149. package/.mindforge/personas/developer.md +85 -0
  150. package/.mindforge/personas/overrides/README.md +85 -0
  151. package/.mindforge/personas/qa-engineer.md +61 -0
  152. package/.mindforge/personas/release-manager.md +76 -0
  153. package/.mindforge/personas/security-reviewer.md +91 -0
  154. package/.mindforge/personas/tech-writer.md +51 -0
  155. package/.mindforge/plugins/PLUGINS-MANIFEST.md +23 -0
  156. package/.mindforge/plugins/plugin-loader.md +93 -0
  157. package/.mindforge/plugins/plugin-registry.md +44 -0
  158. package/.mindforge/plugins/plugin-schema.md +68 -0
  159. package/.mindforge/pr-review/ai-reviewer.md +266 -0
  160. package/.mindforge/pr-review/finding-formatter.md +46 -0
  161. package/.mindforge/pr-review/review-prompt-templates.md +44 -0
  162. package/.mindforge/production/compatibility-layer.md +39 -0
  163. package/.mindforge/production/migration-engine.md +52 -0
  164. package/.mindforge/production/production-checklist.md +165 -0
  165. package/.mindforge/production/token-optimiser.md +68 -0
  166. package/.mindforge/skills/accessibility/SKILL.md +106 -0
  167. package/.mindforge/skills/api-design/SKILL.md +98 -0
  168. package/.mindforge/skills/code-quality/SKILL.md +88 -0
  169. package/.mindforge/skills/data-privacy/SKILL.md +126 -0
  170. package/.mindforge/skills/database-patterns/SKILL.md +192 -0
  171. package/.mindforge/skills/documentation/SKILL.md +91 -0
  172. package/.mindforge/skills/incident-response/SKILL.md +180 -0
  173. package/.mindforge/skills/performance/SKILL.md +120 -0
  174. package/.mindforge/skills/security-review/SKILL.md +83 -0
  175. package/.mindforge/skills/testing-standards/SKILL.md +97 -0
  176. package/.mindforge/team/TEAM-PROFILE.md +42 -0
  177. package/.mindforge/team/multi-handoff.md +23 -0
  178. package/.mindforge/team/profiles/README.md +13 -0
  179. package/.mindforge/team/session-merger.md +18 -0
  180. package/.planning/ARCHITECTURE.md +0 -0
  181. package/.planning/AUDIT.jsonl +0 -0
  182. package/.planning/HANDOFF.json +28 -0
  183. package/.planning/PROJECT.md +33 -0
  184. package/.planning/RELEASE-CHECKLIST.md +68 -0
  185. package/.planning/REQUIREMENTS.md +0 -0
  186. package/.planning/ROADMAP.md +0 -0
  187. package/.planning/STATE.md +31 -0
  188. package/.planning/approvals/.gitkeep +1 -0
  189. package/.planning/archive/.gitkeep +1 -0
  190. package/.planning/audit-archive/.gitkeep +1 -0
  191. package/.planning/decisions/.gitkeep +0 -0
  192. package/.planning/decisions/ADR-001-handoff-tracking.md +41 -0
  193. package/.planning/decisions/ADR-002-markdown-commands.md +46 -0
  194. package/.planning/decisions/ADR-003-skills-trigger-model.md +37 -0
  195. package/.planning/decisions/ADR-004-wave-parallelism-model.md +45 -0
  196. package/.planning/decisions/ADR-005-append-only-audit-log.md +51 -0
  197. package/.planning/decisions/ADR-006-tiered-skills-system.md +22 -0
  198. package/.planning/decisions/ADR-007-trigger-keyword-model.md +22 -0
  199. package/.planning/decisions/ADR-008-just-in-time-skill-loading.md +29 -0
  200. package/.planning/decisions/ADR-009-enterprise-integration-retry-policy.md +8 -0
  201. package/.planning/decisions/ADR-010-governance-tier-escalation.md +8 -0
  202. package/.planning/decisions/ADR-011-multi-developer-handoff-contract.md +8 -0
  203. package/.planning/decisions/ADR-012-intelligence-feedback-loops.md +19 -0
  204. package/.planning/decisions/ADR-013-mindforge-md-constitution.md +16 -0
  205. package/.planning/decisions/ADR-014-metrics-as-signals-not-evaluation.md +15 -0
  206. package/.planning/decisions/ADR-015-npm-based-skill-registry.md +26 -0
  207. package/.planning/decisions/ADR-016-ci-exit-code-0-on-timeout.md +27 -0
  208. package/.planning/decisions/ADR-017-sdk-localhost-only.md +28 -0
  209. package/.planning/decisions/ADR-018-installer-self-install-detection.md +15 -0
  210. package/.planning/decisions/ADR-019-self-update-scope-preservation.md +14 -0
  211. package/.planning/decisions/ADR-020-v1.0.0-stable-interface-contract.md +23 -0
  212. package/.planning/jira-sync.json +9 -0
  213. package/.planning/milestones/.gitkeep +1 -0
  214. package/.planning/phases/day1/REVIEW-DAY1.md +50 -0
  215. package/.planning/phases/day1/SECURITY-REVIEW-DAY1.md +15 -0
  216. package/.planning/phases/day2/REVIEW-DAY2.md +521 -0
  217. package/.planning/phases/day3/REVIEW-DAY3.md +234 -0
  218. package/.planning/slack-threads.json +6 -0
  219. package/CHANGELOG.md +175 -0
  220. package/LICENSE +21 -0
  221. package/MINDFORGE.md +76 -0
  222. package/README.md +182 -0
  223. package/RELEASENOTES.md +41 -0
  224. package/SECURITY.md +4 -0
  225. package/bin/install.js +120 -0
  226. package/bin/installer-core.js +292 -0
  227. package/bin/migrations/0.1.0-to-0.5.0.js +37 -0
  228. package/bin/migrations/0.5.0-to-0.6.0.js +17 -0
  229. package/bin/migrations/0.6.0-to-1.0.0.js +100 -0
  230. package/bin/migrations/migrate.js +151 -0
  231. package/bin/migrations/schema-versions.js +64 -0
  232. package/bin/updater/changelog-fetcher.js +62 -0
  233. package/bin/updater/self-update.js +169 -0
  234. package/bin/updater/version-comparator.js +68 -0
  235. package/bin/validate-config.js +92 -0
  236. package/bin/wizard/config-generator.js +112 -0
  237. package/bin/wizard/environment-detector.js +76 -0
  238. package/bin/wizard/setup-wizard.js +237 -0
  239. package/docs/Context/Master-Context.md +701 -0
  240. package/docs/architecture/README.md +35 -0
  241. package/docs/architecture/decision-records-index.md +26 -0
  242. package/docs/ci-cd-integration.md +30 -0
  243. package/docs/ci-quickstart.md +78 -0
  244. package/docs/commands-reference.md +11 -0
  245. package/docs/contributing/CONTRIBUTING.md +38 -0
  246. package/docs/contributing/plugin-authoring.md +50 -0
  247. package/docs/contributing/skill-authoring.md +41 -0
  248. package/docs/enterprise-setup.md +25 -0
  249. package/docs/faq.md +38 -0
  250. package/docs/getting-started.md +36 -0
  251. package/docs/governance-guide.md +23 -0
  252. package/docs/mindforge-md-reference.md +53 -0
  253. package/docs/monorepo-guide.md +26 -0
  254. package/docs/persona-customisation.md +56 -0
  255. package/docs/quick-verify.md +33 -0
  256. package/docs/reference/audit-events.md +53 -0
  257. package/docs/reference/commands.md +82 -0
  258. package/docs/reference/config-reference.md +64 -0
  259. package/docs/reference/sdk-api.md +48 -0
  260. package/docs/reference/skills-api.md +57 -0
  261. package/docs/release-checklist-guide.md +37 -0
  262. package/docs/requirements.md +29 -0
  263. package/docs/sdk-reference.md +27 -0
  264. package/docs/security/SECURITY.md +42 -0
  265. package/docs/security/penetration-test-results.md +31 -0
  266. package/docs/security/threat-model.md +142 -0
  267. package/docs/skills-authoring-guide.md +119 -0
  268. package/docs/skills-publishing-guide.md +21 -0
  269. package/docs/team-setup-guide.md +21 -0
  270. package/docs/troubleshooting.md +119 -0
  271. package/docs/tutorial.md +195 -0
  272. package/docs/upgrade.md +44 -0
  273. package/docs/user-guide.md +131 -0
  274. package/docs/usp-features.md +214 -0
  275. package/eslint.config.mjs +31 -0
  276. package/examples/starter-project/.planning/AUDIT.jsonl +1 -0
  277. package/examples/starter-project/.planning/HANDOFF.json +23 -0
  278. package/examples/starter-project/.planning/PROJECT.md +27 -0
  279. package/examples/starter-project/.planning/STATE.md +10 -0
  280. package/examples/starter-project/MINDFORGE.md +40 -0
  281. package/examples/starter-project/README.md +14 -0
  282. package/implementation-roadmap/day-1-imp/DAY1-HARDEN.md +823 -0
  283. package/implementation-roadmap/day-1-imp/DAY1-IMPLEMENT.md +2459 -0
  284. package/implementation-roadmap/day-1-imp/DAY1-REVIEW.md +288 -0
  285. package/implementation-roadmap/day-2-imp/DAY2-HARDEN.md +954 -0
  286. package/implementation-roadmap/day-2-imp/DAY2-IMPLEMENT.md +2347 -0
  287. package/implementation-roadmap/day-2-imp/DAY2-REVIEW.md +422 -0
  288. package/implementation-roadmap/day-3-imp/DAY3-HARDEN.md +870 -0
  289. package/implementation-roadmap/day-3-imp/DAY3-IMPLEMENT.md +2798 -0
  290. package/implementation-roadmap/day-3-imp/DAY3-REVIEW.md +484 -0
  291. package/implementation-roadmap/day-4-imp/DAY4-HARDEN.md +1087 -0
  292. package/implementation-roadmap/day-4-imp/DAY4-IMPLEMENT.md +2874 -0
  293. package/implementation-roadmap/day-4-imp/DAY4-REVIEW.md +386 -0
  294. package/implementation-roadmap/day-5-imp/DAY5-HARDEN.md +1078 -0
  295. package/implementation-roadmap/day-5-imp/DAY5-IMPLEMENT.md +3151 -0
  296. package/implementation-roadmap/day-5-imp/DAY5-REVIEW.md +345 -0
  297. package/implementation-roadmap/day-6-imp/DAY6-COMPLETE.md +3919 -0
  298. package/implementation-roadmap/day-7-imp-prod/DAY7-PRODUCTION-FINAL.md +4513 -0
  299. package/package.json +31 -0
  300. package/sdk/README.md +69 -0
  301. package/sdk/eslint.config.mjs +34 -0
  302. package/sdk/package-lock.json +1507 -0
  303. package/sdk/package.json +30 -0
  304. package/sdk/src/client.ts +133 -0
  305. package/sdk/src/commands.ts +63 -0
  306. package/sdk/src/events.ts +166 -0
  307. package/sdk/src/index.ts +22 -0
  308. package/sdk/src/types.ts +87 -0
  309. package/sdk/tsconfig.json +13 -0
  310. package/tests/audit.test.js +206 -0
  311. package/tests/ci-mode.test.js +162 -0
  312. package/tests/compaction.test.js +161 -0
  313. package/tests/distribution.test.js +205 -0
  314. package/tests/e2e.test.js +618 -0
  315. package/tests/governance.test.js +130 -0
  316. package/tests/install.test.js +209 -0
  317. package/tests/integrations.test.js +128 -0
  318. package/tests/intelligence.test.js +117 -0
  319. package/tests/metrics.test.js +96 -0
  320. package/tests/migration.test.js +309 -0
  321. package/tests/production.test.js +416 -0
  322. package/tests/sdk.test.js +200 -0
  323. package/tests/skills-platform.test.js +403 -0
  324. package/tests/wave-engine.test.js +338 -0
@@ -0,0 +1,1078 @@
1
+ # MindForge — Day 5 Hardening Prompt
2
+ # Branch: `feat/mindforge-intelligence-layer`
3
+ # Run this AFTER DAY5-REVIEW.md is APPROVED
4
+
5
+ ---
6
+
7
+ ## CONTEXT
8
+
9
+ You are performing **Day 5 Hardening** of the MindForge intelligence layer.
10
+
11
+ Activate the **`architect.md`** persona throughout.
12
+
13
+ Day 5 hardening focuses on three concerns distinct from previous days:
14
+
15
+ 1. **Signal quality** — are the intelligence signals (difficulty scores,
16
+ anti-pattern detections, quality metrics) accurate enough to be trusted?
17
+ A framework that gives noisy or misleading signals is worse than one that
18
+ gives no signals at all.
19
+
20
+ 2. **Feedback loop integrity** — does intelligence actually improve future
21
+ behaviour? Compaction → better HANDOFF → better next session. Retrospective
22
+ → action items → MINDFORGE.md changes → better future phases. These loops
23
+ must be explicit and verifiable.
24
+
25
+ 3. **Wizard reliability** — a failed first-run experience is a MindForge
26
+ abandonment event. Every failure path must produce a clear, actionable
27
+ error message.
28
+
29
+ Confirm all review findings resolved:
30
+
31
+ ```bash
32
+ git log --oneline | head -30
33
+ node tests/install.test.js && \
34
+ node tests/wave-engine.test.js && \
35
+ node tests/audit.test.js && \
36
+ node tests/compaction.test.js && \
37
+ node tests/skills-platform.test.js && \
38
+ node tests/integrations.test.js && \
39
+ node tests/governance.test.js && \
40
+ node tests/intelligence.test.js && \
41
+ node tests/metrics.test.js
42
+ # All 9 suites must pass
43
+ ```
44
+
45
+ ---
46
+
47
+ ## HARDEN 1 — Fix all review findings
48
+
49
+ For every BLOCKING and MAJOR finding from DAY5-REVIEW.md:
50
+ 1. Read the finding precisely
51
+ 2. Apply the exact recommended fix
52
+ 3. Commit: `fix(day5-review): [finding title]`
53
+
54
+ One commit per finding. Re-run full test battery after all fixes.
55
+
56
+ ---
57
+
58
+ ## HARDEN 2 — Fix anti-pattern false positives
59
+
60
+ The review identified two false-positive risks. Apply both fixes.
61
+
62
+ ### Fix C01 — Exclude test files
63
+
64
+ Update `antipattern-detector.md` — add to the C01 section:
65
+
66
+ ```markdown
67
+ ### C01 false positive prevention
68
+
69
+ Exclude from C01 scanning:
70
+ ```bash
71
+ # Build exclusion list for type-coercion check
72
+ EXCLUDED_DIRS=("tests/" "test/" "__tests__/" "*.test.ts" "*.spec.ts" "*.test.js" "*.spec.js")
73
+
74
+ # Apply when running C01 detection:
75
+ grep -rn "==\s*null\|==\s*undefined\|==\s*false\|==\s*0" \
76
+ src/ \
77
+ --include="*.ts" --include="*.js" \
78
+ --exclude="*.test.ts" --exclude="*.spec.ts" --exclude="*.test.js" --exclude="*.spec.js"
79
+ ```
80
+
81
+ Additionally: do not flag `==` comparisons inside:
82
+ - Test assertion functions: `expect(x).toBe(null)`, `assert.equal(x, null)`
83
+ - Type guard functions: `function isNull(x: unknown): x is null { return x == null }`
84
+ (Type guards intentionally use `==` for null/undefined coalescing)
85
+
86
+ For type guards: the pattern `x == null` (checking for both null AND undefined)
87
+ is acceptable and intentional. Only flag `== null` inside non-type-guard functions
88
+ in auth, middleware, and security-critical paths.
89
+ ```
90
+
91
+ ### Fix B03 — Cursor pagination exception
92
+
93
+ Add to the B03 section:
94
+
95
+ ```markdown
96
+ ### B03 cursor pagination exception
97
+
98
+ Cursor-based pagination is exempt from the unbounded query check.
99
+ A query using cursor-based pagination may omit `LIMIT`/`take:` on the final
100
+ "fetch until cursor" call. Detect cursor pagination by looking for:
101
+ - Prisma: `cursor:` parameter
102
+ - Raw SQL: `WHERE (created_at, id) < (:cursor_time, :cursor_id)`
103
+ - Any query with both `orderBy:` and `cursor:`
104
+
105
+ ```bash
106
+ # Exempt cursor-paginated queries:
107
+ grep -rn "findMany\b" src/ --include="*.ts" | \
108
+ python3 -c "
109
+ import sys
110
+ for line in sys.stdin:
111
+ if 'cursor:' in line or '< :cursor' in line.lower():
112
+ continue # cursor pagination — exempt
113
+ if 'take:' not in line and 'limit:' not in line.lower():
114
+ print('B03 candidate:', line.strip())
115
+ "
116
+ ```
117
+ ```
118
+
119
+ ### Fix D01 — Count executable lines only
120
+
121
+ Add to the D01 section:
122
+
123
+ ```markdown
124
+ ### D01 executable line counting
125
+
126
+ Count non-comment, non-blank, non-decorator lines only:
127
+
128
+ ```bash
129
+ # Count executable lines (exclude blanks, comments, decorators)
130
+ count_executable_lines() {
131
+ local FILE="$1"
132
+ grep -v '^\s*$' "${FILE}" | # remove blank lines
133
+ grep -v '^\s*//' | # remove single-line JS/TS comments
134
+ grep -v '^\s*\*' | # remove JSDoc lines
135
+ grep -v '^\s*@' | # remove decorators
136
+ wc -l
137
+ }
138
+
139
+ # Apply D01 threshold (500 lines) to executable count
140
+ for FILE in $(find src/ -name "*.ts" -o -name "*.py"); do
141
+ EXEC_LINES=$(count_executable_lines "${FILE}")
142
+ if [ "${EXEC_LINES}" -gt 500 ]; then
143
+ echo "D01 candidate: ${FILE} (${EXEC_LINES} executable lines)"
144
+ fi
145
+ done
146
+ ```
147
+ ```
148
+
149
+ **Commit:**
150
+ ```bash
151
+ git add .mindforge/intelligence/antipattern-detector.md
152
+ git commit -m "harden(antipattern): fix C01 test-file false positive, B03 cursor pagination, D01 line counting"
153
+ ```
154
+
155
+ ---
156
+
157
+ ## HARDEN 3 — Seal the intelligence feedback loops
158
+
159
+ The review identified that intelligence outputs don't explicitly feed back into
160
+ improved future behaviour. Add explicit feedback connectors.
161
+
162
+ ### Feedback loop 1: Retrospective → MINDFORGE.md
163
+
164
+ Add to `retrospective.md` — Step 5:
165
+
166
+ ```markdown
167
+ ## Step 5 — Apply learnings to MINDFORGE.md
168
+
169
+ After the retrospective discussion, explicitly ask:
170
+ "Based on this retrospective, should we update MINDFORGE.md to improve future phases?
171
+
172
+ Common MINDFORGE.md improvements from retrospectives:
173
+
174
+ | Retrospective finding | MINDFORGE.md change |
175
+ |---|---|
176
+ | Plans were too vague | `AUTO_DISCUSS_PHASE=true` or lower `DISCUSS_PHASE_REQUIRED_ABOVE_DIFFICULTY` |
177
+ | Verify pass rate was low | Reduce `MAX_TASKS_PER_PHASE` for more atomic decomposition |
178
+ | Too many security findings | `ALWAYS_LOAD_SKILLS=security-review,data-privacy` |
179
+ | Approvals slowed us down | Review `TIER2_SLA_HOURS` and consider Tier 1 threshold adjustment |
180
+ | Context compacted too often | `COMPACTION_THRESHOLD_PCT=65` (earlier, more graceful compaction) |
181
+ | Tests were thin | `MIN_TEST_COVERAGE_PCT=85` (raise bar) |
182
+
183
+ Suggested changes: [list from discussion analysis]
184
+
185
+ Apply? (yes/no — I'll show you the exact MINDFORGE.md changes)"
186
+
187
+ If yes: make the specific MINDFORGE.md changes in this session.
188
+ Commit: `chore(config): apply retrospective learnings to MINDFORGE.md (Phase [N])`
189
+
190
+ This commits the improvements immediately, making the retrospective tangibly actionable.
191
+ ```
192
+
193
+ ### Feedback loop 2: Difficulty score → Plan granularity
194
+
195
+ Add to `difficulty-scorer.md`:
196
+
197
+ ```markdown
198
+ ## Feedback loop: difficulty score influences task granularity
199
+
200
+ The difficulty score is not just a display — it drives task decomposition:
201
+
202
+ | Composite score | Task granularity instruction to planner |
203
+ |---|---|
204
+ | 1.0-2.0 (Easy) | Plans can be broader: 1 plan = 1 complete feature component |
205
+ | 2.1-3.0 (Moderate) | Standard granularity: 1 plan = 1 significant function/module |
206
+ | 3.1-4.0 (Challenging) | Fine granularity: 1 plan = 1 specific function or endpoint |
207
+ | 4.1-5.0 (Hard) | Maximum granularity: 1 plan = 1 specific change within 3-4 files max |
208
+
209
+ **The planner reads the difficulty score from DIFFICULTY-SCORE-[N].md before
210
+ creating any PLAN files.** It adjusts its decomposition strategy based on the
211
+ recommended task count range in that file.
212
+
213
+ This is the feedback mechanism: difficulty → task count → plan granularity →
214
+ execution quality. A hard phase with coarse plans is the #1 cause of high
215
+ task failure rates.
216
+ ```
217
+
218
+ ### Feedback loop 3: Session quality → next session behaviour
219
+
220
+ Add to `quality-tracker.md`:
221
+
222
+ ```markdown
223
+ ## Quality metrics → agent behaviour adjustment
224
+
225
+ When session quality score is below warning thresholds, agents adjust behaviour
226
+ for the next session automatically (not waiting for a retrospective):
227
+
228
+ ### Automatic adjustments (applied at session start if warning conditions met)
229
+
230
+ **If verify pass rate < 75% in last 3 sessions:**
231
+ Agent adds to its plan review checklist:
232
+ "For each <verify> step: can I run this command RIGHT NOW and get a deterministic result?
233
+ If not — rewrite the verify step before executing the plan."
234
+
235
+ **If task failure rate > 20% in last session:**
236
+ Agent halves its estimated task scope for the current phase.
237
+ If the current plan seems large: suggest splitting before executing.
238
+
239
+ **If compaction frequency > 2 per session:**
240
+ Agent proactively summarises after every 4 tasks (not waiting for 70%).
241
+ This prevents compaction from being forced under pressure.
242
+
243
+ **If security findings increased across last 3 phases:**
244
+ Agent automatically activates security-review skill for ALL tasks in the current phase,
245
+ not just trigger-matched tasks. Reports this to user at session start.
246
+
247
+ These automatic adjustments are reported to the user:
248
+ "Quality signal detected: [signal]. Adjusting behaviour for this session: [adjustment]."
249
+ ```
250
+
251
+ **Commit:**
252
+ ```bash
253
+ git add .mindforge/intelligence/ .claude/commands/mindforge/retrospective.md \
254
+ .agent/mindforge/retrospective.md
255
+ git commit -m "harden(intelligence): seal feedback loops — retro→MINDFORGE, difficulty→granularity, quality→behaviour"
256
+ ```
257
+
258
+ ---
259
+
260
+ ## HARDEN 4 — Harden the setup wizard
261
+
262
+ Apply the wizard reliability fixes from the review.
263
+
264
+ ### Fix 1 — stdin TTY detection
265
+
266
+ Update `setup-wizard.js` — find the `IS_INTERACTIVE` definition and update:
267
+
268
+ ```javascript
269
+ // Before:
270
+ const IS_INTERACTIVE = !ARGS.some(a => ['--claude','--antigravity','--all','--help'].includes(a));
271
+
272
+ // After:
273
+ const IS_INTERACTIVE =
274
+ !ARGS.some(a => ['--claude','--antigravity','--all','--help'].includes(a)) &&
275
+ process.stdin.isTTY !== false; // gracefully handle CI/piped environments
276
+ ```
277
+
278
+ ### Fix 2 — Collect credential guidance, print at end
279
+
280
+ Update the `configureFeatures` function to collect guidance:
281
+
282
+ ```javascript
283
+ async function configureFeatures(rl) {
284
+ // ... existing code ...
285
+
286
+ // Collect credential guidance instead of printing inline
287
+ const credGuidance = [];
288
+
289
+ if (features.includes('Jira integration')) {
290
+ // ... existing Jira config questions ...
291
+ credGuidance.push({
292
+ service: 'Jira / Confluence (Atlassian)',
293
+ envVar: 'JIRA_API_TOKEN',
294
+ url: 'https://id.atlassian.com/manage-profile/security/api-tokens',
295
+ instruction: 'Create an API token and set: export JIRA_API_TOKEN="your-token"'
296
+ });
297
+ }
298
+
299
+ if (features.includes('Slack notifications')) {
300
+ // ... existing Slack config questions ...
301
+ credGuidance.push({
302
+ service: 'Slack',
303
+ envVar: 'SLACK_BOT_TOKEN',
304
+ url: 'https://api.slack.com/apps',
305
+ instruction: 'Create a bot, add to workspace, copy Bot Token: export SLACK_BOT_TOKEN="xoxb-..."'
306
+ });
307
+ }
308
+
309
+ if (features.includes('GitHub integration')) {
310
+ // ... existing GitHub config questions ...
311
+ credGuidance.push({
312
+ service: 'GitHub',
313
+ envVar: 'GITHUB_TOKEN',
314
+ url: 'https://github.com/settings/tokens',
315
+ instruction: 'Create a personal access token with repo scope: export GITHUB_TOKEN="ghp_..."'
316
+ });
317
+ }
318
+
319
+ return { config, credGuidance };
320
+ }
321
+ ```
322
+
323
+ Update `printNextSteps` to accept and display all credential guidance together:
324
+
325
+ ```javascript
326
+ function printNextSteps(runtimes, scope, credGuidance = []) {
327
+ // ... existing next steps ...
328
+
329
+ if (credGuidance.length > 0) {
330
+ console.log(c.bold('\n Configure credentials:\n'));
331
+ credGuidance.forEach(g => {
332
+ console.log(` ${c.cyan(g.service)}`);
333
+ console.log(` ${g.instruction}`);
334
+ console.log(c.dim(` Docs: ${g.url}\n`));
335
+ });
336
+ }
337
+ }
338
+ ```
339
+
340
+ ### Fix 3 — Config generator idempotency
341
+
342
+ Update `config-generator.js` — add idempotency check:
343
+
344
+ ```javascript
345
+ async function writeIntegrationsConfig(config) {
346
+ // ... existing code ...
347
+
348
+ if (config.jira) {
349
+ const placeholder = 'JIRA_BASE_URL=https://your-org.atlassian.net';
350
+ if (content.includes(placeholder)) {
351
+ content = content.replace(placeholder, `JIRA_BASE_URL=${config.jira.baseUrl}`);
352
+ console.log(' ✅ JIRA_BASE_URL configured');
353
+ } else if (!content.includes(config.jira.baseUrl)) {
354
+ // Placeholder was already replaced with something else
355
+ console.log(` ⏭️ JIRA_BASE_URL already configured — not overwriting`);
356
+ }
357
+ // If content already has the correct value: silently skip
358
+ }
359
+ // Apply same pattern to all config replacements
360
+ }
361
+ ```
362
+
363
+ ### Fix 4 — Wizard error messages
364
+
365
+ Add a comprehensive error handler to `setup-wizard.js`:
366
+
367
+ ```javascript
368
+ // ── Error handler ─────────────────────────────────────────────────────────────
369
+ function handleWizardError(err) {
370
+ console.error(c.red('\n ❌ Setup encountered an issue:\n'));
371
+
372
+ const COMMON_ERRORS = {
373
+ 'ENOENT': {
374
+ message: 'A required file was not found.',
375
+ action: 'Ensure you are running from the project root directory.',
376
+ },
377
+ 'EACCES': {
378
+ message: 'Permission denied writing to target directory.',
379
+ action: 'Check directory permissions or run with appropriate access.',
380
+ },
381
+ 'MODULE_NOT_FOUND': {
382
+ message: 'MindForge installer files are missing.',
383
+ action: 'Re-run: npx mindforge-cc@latest to get a fresh copy.',
384
+ },
385
+ 'ERR_INVALID_ARG_TYPE': {
386
+ message: 'Unexpected argument type in setup wizard.',
387
+ action: 'Try non-interactive mode: npx mindforge-cc --claude --local',
388
+ },
389
+ };
390
+
391
+ const known = COMMON_ERRORS[err.code] || COMMON_ERRORS['ERR_INVALID_ARG_TYPE'];
392
+ console.error(` ${c.yellow('Problem:')} ${known?.message || err.message}`);
393
+ console.error(` ${c.yellow('Action:')} ${known?.action || 'Run in non-interactive mode:'}`);
394
+ console.error(c.dim(`\n Non-interactive fallback:`));
395
+ console.error(c.dim(' npx mindforge-cc --claude --local # Install for Claude Code'));
396
+ console.error(c.dim(' npx mindforge-cc --antigravity --local # Install for Antigravity'));
397
+ console.error(c.dim(' npx mindforge-cc --all --global # Install both globally'));
398
+ console.error('');
399
+ }
400
+ ```
401
+
402
+ Update the main catch block:
403
+ ```javascript
404
+ } catch (err) {
405
+ rl.close();
406
+ handleWizardError(err);
407
+ process.exit(1);
408
+ }
409
+ ```
410
+
411
+ **Commit:**
412
+ ```bash
413
+ git add bin/wizard/
414
+ git commit -m "harden(wizard): fix TTY detection, collect credentials at end, add idempotency, better errors"
415
+ ```
416
+
417
+ ---
418
+
419
+ ## HARDEN 5 — Fix the AUDIT.jsonl corrupt-line handling
420
+
421
+ Update `health-engine.md` — replace the auto-repair for invalid AUDIT.jsonl lines:
422
+
423
+ ```markdown
424
+ ### AUDIT.jsonl corruption handling (updated)
425
+
426
+ **Do NOT remove invalid lines from AUDIT.jsonl.**
427
+ AUDIT.jsonl is an append-only immutable record. Deleting lines — even invalid
428
+ ones — violates the immutability contract and destroys part of the audit trail.
429
+
430
+ **Instead: isolate corrupted lines without deletion.**
431
+
432
+ Auto-repair procedure for AUDIT.jsonl invalid lines:
433
+
434
+ ```bash
435
+ # Step 1: Identify invalid lines
436
+ python3 -c "
437
+ import sys
438
+ invalid = []
439
+ for i, line in enumerate(open('.planning/AUDIT.jsonl'), 1):
440
+ line = line.strip()
441
+ if not line: continue
442
+ try:
443
+ import json; json.loads(line)
444
+ except:
445
+ invalid.append((i, line[:80]))
446
+ for i, l in invalid:
447
+ print(f'Line {i}: {l}')
448
+ "
449
+
450
+ # Step 2: Copy invalid lines to a quarantine file (do NOT delete from original)
451
+ python3 -c "
452
+ import sys, json
453
+ quarantine = []
454
+ for i, line in enumerate(open('.planning/AUDIT.jsonl'), 1):
455
+ stripped = line.strip()
456
+ if not stripped: continue
457
+ try:
458
+ json.loads(stripped)
459
+ except:
460
+ quarantine.append({'line': i, 'raw': stripped})
461
+
462
+ if quarantine:
463
+ import uuid, datetime
464
+ qf = '.planning/AUDIT.jsonl.quarantine'
465
+ with open(qf, 'a') as f:
466
+ for q in quarantine:
467
+ f.write(json.dumps(q) + '\n')
468
+ print(f'Quarantined {len(quarantine)} lines to {qf}')
469
+ "
470
+
471
+ # Step 3: Write a correction entry documenting the quarantine
472
+ QUARANTINE_COUNT=$(wc -l < .planning/AUDIT.jsonl.quarantine 2>/dev/null || echo "0")
473
+ echo "{\"id\":\"$(uuidgen)\",\"timestamp\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"event\":\"audit_quarantine\",\"quarantined_lines\":${QUARANTINE_COUNT},\"quarantine_file\":\".planning/AUDIT.jsonl.quarantine\",\"agent\":\"mindforge-health-engine\"}" >> .planning/AUDIT.jsonl
474
+ ```
475
+
476
+ The original AUDIT.jsonl is untouched. The quarantine file documents what was
477
+ found without destroying the audit trail. The new correction entry ensures
478
+ the quarantine action is itself audited.
479
+ ```
480
+
481
+ **Commit:**
482
+ ```bash
483
+ git add .mindforge/intelligence/health-engine.md
484
+ git commit -m "harden(health): fix AUDIT.jsonl corruption handling — quarantine not delete"
485
+ ```
486
+
487
+ ---
488
+
489
+ ## HARDEN 6 — Add non-overridable rules to MINDFORGE.md
490
+
491
+ The review identified that MINDFORGE.md can override anything — including safety primitives. Fix.
492
+
493
+ Add to `MINDFORGE.md` at the very top (after the header comment):
494
+
495
+ ```markdown
496
+ ## NON-OVERRIDABLE RULES (read-only — these cannot be changed in MINDFORGE.md)
497
+
498
+ The following CLAUDE.md behaviours are governance primitives and cannot be
499
+ disabled or overridden by MINDFORGE.md, regardless of what is configured here:
500
+
501
+ - Security auto-trigger: always activates for auth/payment/PII changes
502
+ - Plan-first rule: implementation cannot begin without a PLAN file
503
+ - Secret detection gate: blocks commits with credential patterns — no exceptions
504
+ - AUDIT writing: every significant action writes to AUDIT.jsonl
505
+ - Quality gates 1 and 3: CRITICAL security findings and secrets block all merges
506
+
507
+ Any MINDFORGE.md value that attempts to disable these rules will be ignored.
508
+ The agent will log: "MINDFORGE.md attempted to override a non-overridable rule: [rule].
509
+ Override ignored — governance primitive cannot be disabled."
510
+ ```
511
+
512
+ Update CLAUDE.md to enforce this:
513
+
514
+ Add to the MINDFORGE.md section in CLAUDE.md:
515
+
516
+ ```markdown
517
+ ### Non-overridable rules enforcement
518
+ When reading MINDFORGE.md, validate each override value:
519
+ - If MINDFORGE.md contains: `SECURITY_AUTOTRIGGER=false`, `SECRET_DETECTION=false`,
520
+ `PLAN_FIRST=false`, or `AUDIT_WRITING=false`:
521
+ Log: "MINDFORGE.md override ignored: [rule] is a non-overridable governance primitive."
522
+ Apply the CLAUDE.md default regardless.
523
+ - Never expose error messages that reveal which overrides were attempted —
524
+ just silently enforce the defaults.
525
+ ```
526
+
527
+ **Commit:**
528
+ ```bash
529
+ git add MINDFORGE.md .claude/CLAUDE.md .agent/CLAUDE.md
530
+ git commit -m "harden(MINDFORGE): add non-overridable governance primitives, enforce in CLAUDE.md"
531
+ ```
532
+
533
+ ---
534
+
535
+ ## HARDEN 7 — Write 3 ADRs for Day 5 decisions
536
+
537
+ ### `.planning/decisions/ADR-012-intelligence-feedback-loops.md`
538
+
539
+ ```markdown
540
+ # ADR-012: Intelligence outputs must feed back into system behaviour
541
+
542
+ **Status:** Accepted
543
+ **Date:** [today]
544
+
545
+ ## Context
546
+ Day 5 adds intelligence components (difficulty scorer, quality metrics,
547
+ retrospective, smart compaction) that produce structured outputs.
548
+ The question is: are these outputs used purely for display, or do they
549
+ actually change how agents behave?
550
+
551
+ ## Decision
552
+ All intelligence outputs are connected to behaviour changes:
553
+ - Difficulty score → task granularity (planning)
554
+ - Retrospective → MINDFORGE.md updates (configuration)
555
+ - Quality metrics → automatic session behaviour adjustments
556
+ - Smart compaction → richer HANDOFF.json → better session continuity
557
+
558
+ ## Rationale
559
+ Intelligence that only displays information without changing behaviour is
560
+ a dashboard, not a system. MindForge is a framework that improves over time.
561
+ The feedback loops are what distinguishes MindForge from frameworks that stay
562
+ static regardless of what they learn about the team's patterns.
563
+
564
+ ## Consequences
565
+ Each intelligence component must have a documented feedback path.
566
+ The feedback is explicit (user-confirmed) for high-impact changes (MINDFORGE.md)
567
+ and automatic for low-impact adjustments (session behaviour thresholds).
568
+ ```
569
+
570
+ ### `.planning/decisions/ADR-013-mindforge-md-constitution.md`
571
+
572
+ ```markdown
573
+ # ADR-013: MINDFORGE.md as project constitution with non-overridable primitives
574
+
575
+ **Status:** Accepted
576
+ **Date:** [today]
577
+
578
+ ## Context
579
+ MINDFORGE.md provides project-level overrides for MindForge defaults.
580
+ The question is: can it override everything, or are some behaviours protected?
581
+
582
+ ## Decision
583
+ MINDFORGE.md can override configuration and preferences but not governance primitives.
584
+ Governance primitives (secret detection, security auto-trigger, plan-first rule,
585
+ AUDIT writing) cannot be disabled by any MINDFORGE.md configuration.
586
+
587
+ ## Rationale
588
+ If a developer (or a compromised build system) could use MINDFORGE.md to disable
589
+ the secret detection gate, the entire governance system would be circumventable.
590
+ The value of non-bypassable governance primitives depends on them being
591
+ genuinely non-bypassable — a "mostly non-bypassable" governance gate is
592
+ worse than a known-bypassable one, because it creates false confidence.
593
+
594
+ ## Consequences
595
+ - Security and governance features work consistently across all projects
596
+ - Teams cannot accidentally disable safety features
597
+ - Emergency situations require the `--emergency` flag, which is audited
598
+ ```
599
+
600
+ ### `.planning/decisions/ADR-014-metrics-as-signals-not-scores.md`
601
+
602
+ ```markdown
603
+ # ADR-014: Metrics are signals for improvement, not performance evaluation
604
+
605
+ **Status:** Accepted
606
+ **Date:** [today]
607
+
608
+ ## Context
609
+ MindForge collects session quality scores and phase metrics.
610
+ These could be used as developer performance metrics or as system improvement signals.
611
+
612
+ ## Decision
613
+ MindForge metrics are system improvement signals ONLY.
614
+ They are used to: improve planning, adjust skills loading, tune compaction behaviour,
615
+ and inform retrospectives. They are NOT used to evaluate individual developer performance.
616
+
617
+ ## Rationale
618
+ Using agent quality metrics as developer performance metrics would:
619
+ 1. Create incentives to game the metrics (skip complex phases, avoid
620
+ security-flagged tasks, etc.)
621
+ 2. Be invalid: session quality scores measure the agent's effectiveness given
622
+ the task context — not the developer's skill or effort.
623
+ 3. Create psychological safety issues that harm team adoption.
624
+
625
+ The team profile system (TEAM-PROFILE.md) captures strengths and growth areas
626
+ for personalisation purposes — not for evaluation.
627
+
628
+ ## Consequences
629
+ - Team profiles must never be used in performance reviews
630
+ - Session quality scores are per-session, not per-developer
631
+ - The /mindforge:metrics command does not expose per-developer scores
632
+ - Documentation explicitly states this policy
633
+ ```
634
+
635
+ **Commit:**
636
+ ```bash
637
+ git add .planning/decisions/
638
+ git commit -m "docs(adr): add ADR-012 feedback loops, ADR-013 MINDFORGE constitution, ADR-014 metrics policy"
639
+ ```
640
+
641
+ ---
642
+
643
+ ## HARDEN 8 — Add metrics policy to TEAM-PROFILE.md
644
+
645
+ Update `.mindforge/team/TEAM-PROFILE.md` — add a policy section at the top:
646
+
647
+ ```markdown
648
+ ## IMPORTANT: Metrics usage policy
649
+
650
+ **Per ADR-014:** The data in this file and in `.mindforge/metrics/` is for
651
+ system improvement only — NOT for developer performance evaluation.
652
+
653
+ These metrics measure the agent framework's effectiveness in supporting the team.
654
+ They should not be used in performance reviews, sprint retrospectives as developer
655
+ assessments, or any evaluation context.
656
+
657
+ What this data IS used for:
658
+ - Personalising agent responses (verbosity, explanation depth, code style)
659
+ - Improving skill loading for the team's tech stack
660
+ - Tuning compaction thresholds for the team's session patterns
661
+ - Informing retrospective discussions about process, not people
662
+
663
+ If you observe a low quality metric: investigate the process or the plan quality —
664
+ not the developer.
665
+ ```
666
+
667
+ Also add to `docs/team-setup-guide.md`:
668
+
669
+ ```markdown
670
+ # MindForge Team Setup Guide
671
+
672
+ ## Overview
673
+ MindForge supports multi-developer teams through the multi-HANDOFF system,
674
+ team profiles, and shared governance configuration.
675
+
676
+ ## Setting up for a team
677
+
678
+ ### Step 1 — Configure approvers in INTEGRATIONS-CONFIG.md
679
+ ```
680
+ TIER2_APPROVERS=john@company.com,jane@company.com
681
+ TIER3_APPROVERS=security-officer@company.com
682
+ EMERGENCY_APPROVERS=cto@company.com
683
+ ```
684
+
685
+ ### Step 2 — Run team profiling
686
+ ```
687
+ /mindforge:profile-team --questionnaire
688
+ ```
689
+ Each developer runs this once. Answers are stored in per-developer profile files.
690
+
691
+ ### Step 3 — Define branch strategy in MINDFORGE.md
692
+ ```
693
+ BRANCHING_STRATEGY=phase
694
+ PHASE_BRANCH_TEMPLATE=feat/phase-{N}-{slug}
695
+ ```
696
+
697
+ ### Step 4 — Coordinate phase ownership
698
+ Use the shared HANDOFF.json `active_developers` field to track who is working on which plan.
699
+ Avoid assigning two developers to plans that touch the same files.
700
+
701
+ ## Ethics policy
702
+ See ADR-014 and the TEAM-PROFILE.md metrics usage policy.
703
+ MindForge metrics are NOT performance metrics.
704
+ ```
705
+
706
+ **Commit:**
707
+ ```bash
708
+ git add .mindforge/team/TEAM-PROFILE.md docs/team-setup-guide.md
709
+ git commit -m "harden(team): add metrics ethics policy per ADR-014, write team setup guide"
710
+ ```
711
+
712
+ ---
713
+
714
+ ## HARDEN 9 — Update docs/mindforge-md-reference.md
715
+
716
+ Write comprehensive reference documentation for MINDFORGE.md:
717
+
718
+ ```markdown
719
+ # MINDFORGE.md Reference
720
+
721
+ MINDFORGE.md is the "project constitution" — a project-level configuration
722
+ file that customises MindForge defaults for your specific project.
723
+
724
+ ## Location
725
+ Place `MINDFORGE.md` in the project root (same level as `package.json`).
726
+ It is read by agents after `CLAUDE.md` and `ORG.md`.
727
+
728
+ ## Syntax
729
+ Key-value pairs in `KEY=value` format, with Markdown headers as sections.
730
+ Multi-line values use triple-quote delimiters: `KEY="""..."""`
731
+ Comments start with `#`.
732
+
733
+ ## All available settings
734
+
735
+ ### Model preferences
736
+ | Setting | Default | Description |
737
+ |---|---|---|
738
+ | `PLANNER_MODEL` | `inherit` | Model for planning agent |
739
+ | `EXECUTOR_MODEL` | `inherit` | Model for execution agents |
740
+ | `REVIEWER_MODEL` | `inherit` | Model for code review |
741
+ | `SECURITY_MODEL` | `inherit` | Model for security review |
742
+ | Valid values: `claude-opus-4-5`, `claude-sonnet-4-5`, `claude-haiku-4-5`, `inherit` | | |
743
+
744
+ ### Execution behaviour
745
+ | Setting | Default | Description |
746
+ |---|---|---|
747
+ | `TIER1_AUTO_APPROVE` | `true` | Auto-approve Tier 1 changes |
748
+ | `WAVE_CONFIRMATION_REQUIRED` | `false` | Require confirmation before each wave |
749
+ | `AUTO_DISCUSS_PHASE` | `false` | Run discuss-phase before every plan-phase |
750
+ | `VERIFY_PASS_RATE_WARNING_THRESHOLD` | `0.75` | Warn when below this rate |
751
+ | `COMPACTION_THRESHOLD_PCT` | `70` | Context % that triggers compaction |
752
+ | `MAX_TASKS_PER_PHASE` | `15` | Suggest splitting above this count |
753
+
754
+ ### Quality standards
755
+ | Setting | Default | Description |
756
+ |---|---|---|
757
+ | `MIN_TEST_COVERAGE_PCT` | `80` | Minimum test coverage |
758
+ | `MAX_FUNCTION_LINES` | `40` | Maximum function length |
759
+ | `MAX_CYCLOMATIC_COMPLEXITY` | `10` | Maximum cyclomatic complexity |
760
+ | `BLOCK_ON_MEDIUM_SECURITY_FINDINGS` | `false` | Also block on MEDIUM findings |
761
+
762
+ ### Skills
763
+ | Setting | Default | Description |
764
+ |---|---|---|
765
+ | `ALWAYS_LOAD_SKILLS` | (empty) | Skills always loaded regardless of triggers |
766
+ | `DISABLED_SKILLS` | (empty) | Skills to never load |
767
+ | `MAX_FULL_SKILL_INJECTIONS` | `3` | Above this count, summarise lower-priority skills |
768
+
769
+ ### Non-overridable settings
770
+ These CANNOT be changed via MINDFORGE.md:
771
+ - Security auto-trigger for auth/payment/PII changes
772
+ - Plan-first rule (no implementation without a PLAN)
773
+ - Secret detection gate (no commits with credentials)
774
+ - AUDIT.jsonl writing requirement
775
+ - CRITICAL security findings blocking merges
776
+
777
+ See ADR-013 for the rationale.
778
+
779
+ ## Example MINDFORGE.md files
780
+
781
+ ### Startup project (speed-focused)
782
+ ```
783
+ TIER1_AUTO_APPROVE=true
784
+ WAVE_CONFIRMATION_REQUIRED=false
785
+ MIN_TEST_COVERAGE_PCT=70
786
+ EXECUTOR_MODEL=claude-sonnet-4-5
787
+ ALWAYS_LOAD_SKILLS=security-review
788
+ ```
789
+
790
+ ### Enterprise compliance project (quality-focused)
791
+ ```
792
+ BLOCK_ON_MEDIUM_SECURITY_FINDINGS=true
793
+ MIN_TEST_COVERAGE_PCT=90
794
+ REQUIRE_ADR_FOR_ALL_DECISIONS=true
795
+ DISCUSS_PHASE_REQUIRED_ABOVE_DIFFICULTY=2.5
796
+ AUTO_DISCUSS_PHASE=false
797
+ SECURITY_MODEL=claude-opus-4-5
798
+ ALWAYS_LOAD_SKILLS=security-review,data-privacy,testing-standards
799
+ ```
800
+ ```
801
+
802
+ **Commit:**
803
+ ```bash
804
+ git add docs/mindforge-md-reference.md
805
+ git commit -m "docs: write comprehensive MINDFORGE.md reference documentation"
806
+ ```
807
+
808
+ ---
809
+
810
+ ## HARDEN 10 — Add missing test coverage
811
+
812
+ Add to `tests/intelligence.test.js`:
813
+
814
+ ```javascript
815
+ // Add after existing tests:
816
+
817
+ console.log('\nHardening-prompted intelligence tests:');
818
+
819
+ test('anti-pattern C01 does NOT flag test files', () => {
820
+ // Test assertion syntax that looks like type coercion but is fine in tests
821
+ const testCode = 'expect(result).toBe(null); assert.equal(count, 0);';
822
+ // The test file exclusion should prevent flagging — verify the detection logic respects this
823
+ // In the simulation: we check if the pattern regex fires (it will on raw code)
824
+ // The real protection is the file exclusion grep flag
825
+ const found = detectAntipattern(testCode);
826
+ // Pattern fires in code — the FILE exclusion is what protects. Note this in docs.
827
+ // Test that the anti-pattern spec mentions the file exclusion:
828
+ const content = read('.mindforge/intelligence/antipattern-detector.md');
829
+ assert.ok(
830
+ content.includes('*.test.ts') || content.includes('test files'),
831
+ 'antipattern-detector should exclude test files from C01'
832
+ );
833
+ });
834
+
835
+ test('health engine required files list includes Day 5 commands', () => {
836
+ const content = read('.mindforge/intelligence/health-engine.md');
837
+ assert.ok(content.includes('health.md'), 'Health engine should check for health.md');
838
+ assert.ok(content.includes('retrospective.md'), 'Health engine should check for retrospective.md');
839
+ assert.ok(content.includes('metrics.md'), 'Health engine should check for metrics.md');
840
+ });
841
+
842
+ test('MINDFORGE.md documents non-overridable rules', () => {
843
+ const content = read('MINDFORGE.md');
844
+ assert.ok(
845
+ content.includes('NON-OVERRIDABLE') || content.includes('non-overridable'),
846
+ 'MINDFORGE.md should document non-overridable governance primitives'
847
+ );
848
+ });
849
+
850
+ test('smart-compaction Level 2 HANDOFF has decisions_made field', () => {
851
+ const content = read('.mindforge/intelligence/smart-compaction.md');
852
+ assert.ok(content.includes('decisions_made'), 'Level 2 HANDOFF should include decisions_made');
853
+ });
854
+
855
+ test('retrospective command feeds back to MINDFORGE.md', () => {
856
+ const content = read('.claude/commands/mindforge/retrospective.md');
857
+ assert.ok(
858
+ content.includes('MINDFORGE.md') && (content.includes('apply') || content.includes('update')),
859
+ 'Retrospective should offer to update MINDFORGE.md with learnings'
860
+ );
861
+ });
862
+
863
+ test('quality tracker has automatic behaviour adjustments', () => {
864
+ const content = read('.mindforge/metrics/quality-tracker.md');
865
+ assert.ok(
866
+ content.includes('Automatic adjustment') || content.includes('automatic'),
867
+ 'Quality tracker should define automatic behaviour adjustments'
868
+ );
869
+ });
870
+
871
+ test('AUDIT.jsonl corruption fix uses quarantine (not deletion)', () => {
872
+ const content = read('.mindforge/intelligence/health-engine.md');
873
+ assert.ok(
874
+ content.includes('quarantine') || content.includes('AUDIT.jsonl.quarantine'),
875
+ 'Health engine should quarantine corrupt AUDIT lines, not delete them'
876
+ );
877
+ });
878
+ ```
879
+
880
+ Add to `tests/metrics.test.js`:
881
+
882
+ ```javascript
883
+ // Add after existing tests:
884
+
885
+ console.log('\nHardening-prompted metrics tests:');
886
+
887
+ test('TEAM-PROFILE.md has metrics ethics policy', () => {
888
+ const content = read('.mindforge/team/TEAM-PROFILE.md');
889
+ assert.ok(
890
+ content.includes('NOT') && (content.includes('performance') || content.includes('evaluation')),
891
+ 'TEAM-PROFILE.md should state metrics are not for performance evaluation'
892
+ );
893
+ });
894
+
895
+ test('metrics schema has compaction-quality.jsonl defined', () => {
896
+ const content = read('.mindforge/metrics/METRICS-SCHEMA.md');
897
+ assert.ok(content.includes('compaction-quality.jsonl'), 'Should define compaction-quality.jsonl');
898
+ });
899
+
900
+ test('metrics schema has session_quality_score field', () => {
901
+ const content = read('.mindforge/metrics/METRICS-SCHEMA.md');
902
+ assert.ok(content.includes('session_quality_score'), 'session-quality.jsonl should have score field');
903
+ });
904
+
905
+ test('session quality score clamps to 0-100', () => {
906
+ function calcScore(opts = {}) {
907
+ const { tasksFailed=0, qualityGatesFailed=0, critical=0, high=0 } = opts;
908
+ let s = 100 - tasksFailed*15 - qualityGatesFailed*10 - critical*30 - high*15;
909
+ if (!qualityGatesFailed) s += 5;
910
+ if (!critical && !high) s += 5;
911
+ return Math.max(0, Math.min(100, s));
912
+ }
913
+ assert.strictEqual(calcScore({}), 100, 'Perfect session should score 100 (after clamping)');
914
+ assert.strictEqual(calcScore({ tasksFailed: 10 }), 0, 'Many failures should clamp to 0');
915
+ assert.ok(calcScore({ tasksFailed: 1 }) < 100, 'One failure should reduce score');
916
+ });
917
+ ```
918
+
919
+ **Commit:**
920
+ ```bash
921
+ git add tests/intelligence.test.js tests/metrics.test.js
922
+ git commit -m "test(day5): add hardening-prompted test cases for intelligence and metrics"
923
+ ```
924
+
925
+ ---
926
+
927
+ ## HARDEN 11 — Update CHANGELOG.md and bump to v0.5.0
928
+
929
+ Update `CHANGELOG.md` — prepend:
930
+
931
+ ```markdown
932
+ ## [0.5.0] — Day 5 Intelligence Layer
933
+
934
+ ### Added
935
+ - Framework Health Engine: 7-category health check with auto-repair protocol
936
+ - Smart Context Compaction: 3-level structured insight extraction (Level 1/2/3)
937
+ - Captures: decisions, discoveries, implicit knowledge, quality signals
938
+ - Phase Difficulty Scorer: 4-dimension scoring (Technical, Risk, Ambiguity, Dependencies)
939
+ - Composite score drives task granularity and skill activation
940
+ - Anti-Pattern Detection Engine: 5 categories, 13 patterns with false-positive prevention
941
+ - C01: auth type coercion (test-file excluded), B03: unbounded queries (cursor exemption)
942
+ - Skill Gap Analyser: identifies missing skills for planned phase work
943
+ - Team Profile System: capability profiles with tech preferences and quality patterns
944
+ - Agent Performance Metrics: session/phase quality scores and trend analysis
945
+ - Per ADR-014: metrics are system signals, NOT developer performance metrics
946
+ - MINDFORGE.md project constitution: 25 configurable settings + non-overridable primitives
947
+ - Interactive Setup Wizard: guided first-run with environment detection
948
+ - Detects Node.js project type, package manager, existing installs
949
+ - Guides integration configuration with credential safety
950
+ - /mindforge:health — comprehensive health check with auto-repair
951
+ - /mindforge:retrospective — structured retrospectives with MINDFORGE.md feedback loop
952
+ - /mindforge:profile-team — team capability profiling
953
+ - /mindforge:metrics — quality metrics dashboard
954
+ - 3 new ADRs: ADR-012 feedback loops, ADR-013 MINDFORGE constitution, ADR-014 metrics policy
955
+ - Intelligence feedback loops: difficulty→granularity, retro→MINDFORGE, quality→behaviour
956
+
957
+ ### Hardened
958
+ - Anti-pattern false positive prevention (test-file exclusion, cursor pagination)
959
+ - AUDIT.jsonl corruption: quarantine not deletion (immutability preserved)
960
+ - Non-overridable governance primitives in MINDFORGE.md (per ADR-013)
961
+ - Setup wizard: stdin TTY detection, credential guidance collected at end
962
+ - Team profile ethics policy per ADR-014
963
+ ```
964
+
965
+ ```bash
966
+ git add CHANGELOG.md package.json
967
+ git commit -m "chore(release): v0.5.0 final, update CHANGELOG"
968
+ ```
969
+
970
+ ---
971
+
972
+ ## HARDEN 12 — Final pre-merge checklist
973
+
974
+ ```bash
975
+ # 1. All 9 test suites pass
976
+ for suite in install wave-engine audit compaction skills-platform \
977
+ integrations governance intelligence metrics; do
978
+ echo -n "Testing ${suite}... "
979
+ node tests/${suite}.test.js 2>&1 | tail -1
980
+ done
981
+
982
+ # 2. Intelligence files complete
983
+ ls .mindforge/intelligence/ | wc -l # Expected: 5
984
+ ls .mindforge/metrics/ | wc -l # Expected: 2
985
+ ls .mindforge/team/ | wc -l # Expected: 3+
986
+ ls bin/wizard/ | wc -l # Expected: 3
987
+
988
+ # 3. All 25 commands in both runtimes
989
+ ls .claude/commands/mindforge/ | wc -l # Expected: 25
990
+ ls .agent/mindforge/ | wc -l # Expected: 25
991
+ diff <(ls .claude/commands/mindforge/ | sort) <(ls .agent/mindforge/ | sort)
992
+ # Expected: no output
993
+
994
+ # 4. MINDFORGE.md at project root with non-overridable section
995
+ grep "NON-OVERRIDABLE" MINDFORGE.md # Expected: match
996
+
997
+ # 5. ADRs — now 14 total
998
+ ls .planning/decisions/*.md | wc -l # Expected: 14
999
+
1000
+ # 6. package.json at 0.5.0
1001
+ node -e "console.log(require('./package.json').version)" # Expected: 0.5.0
1002
+
1003
+ # 7. No secrets anywhere
1004
+ grep -rE "(password|token|api_key)\s*=\s*['\"][^'\"]{8,}" \
1005
+ --include="*.md" --include="*.js" --include="*.json" \
1006
+ --exclude-dir=node_modules --exclude-dir=.git . 2>/dev/null \
1007
+ | grep -v "placeholder\|example\|template\|your-\|TEST_ONLY"
1008
+ # Expected: no output
1009
+
1010
+ # 8. CHANGELOG.md has 0.5.0 entry
1011
+ grep "0.5.0" CHANGELOG.md # Expected: match
1012
+
1013
+ # 9. Git log clean
1014
+ git log --oneline | head -25
1015
+ # Expected: ~15 clean commits from Day 5
1016
+ ```
1017
+
1018
+ ---
1019
+
1020
+ ## FINAL COMMIT AND PUSH
1021
+
1022
+ ```bash
1023
+ git add .
1024
+ git commit -m "harden(day5): complete Day 5 hardening — feedback loops, anti-pattern fixes, wizard resilience"
1025
+ git push origin feat/mindforge-intelligence-layer
1026
+ ```
1027
+
1028
+ ---
1029
+
1030
+ ## DAY 5 COMPLETE — What you have built
1031
+
1032
+ | Component | Files | Status |
1033
+ |---|---|---|
1034
+ | Health engine (7 categories, auto-repair) | health-engine.md | ✅ |
1035
+ | Smart compaction (3 levels, structured extraction) | smart-compaction.md | ✅ |
1036
+ | Difficulty scorer (4 dimensions, composite) | difficulty-scorer.md | ✅ |
1037
+ | Anti-pattern detector (5 categories, 13 patterns) | antipattern-detector.md | ✅ |
1038
+ | Skill gap analyser | skill-gap-analyser.md | ✅ |
1039
+ | Team profile system + profiles | TEAM-PROFILE.md + README.md | ✅ |
1040
+ | Metrics schema (4 JSONL files) | METRICS-SCHEMA.md | ✅ |
1041
+ | Quality tracker + trend analysis | quality-tracker.md | ✅ |
1042
+ | MINDFORGE.md project constitution | MINDFORGE.md | ✅ |
1043
+ | Interactive setup wizard (3 files) | bin/wizard/*.js | ✅ |
1044
+ | /mindforge:health | 25th command | ✅ |
1045
+ | /mindforge:retrospective | 26th command | ✅ |
1046
+ | /mindforge:profile-team | 27th command | ✅ |
1047
+ | /mindforge:metrics | 28th command | ✅ |
1048
+ | Intelligence test suite | intelligence.test.js | ✅ |
1049
+ | Metrics test suite | metrics.test.js | ✅ |
1050
+ | 3 new ADRs | ADR-012, 013, 014 | ✅ |
1051
+ | Enterprise + governance docs | enterprise-setup.md + team-setup-guide.md | ✅ |
1052
+ | MINDFORGE.md reference | mindforge-md-reference.md | ✅ |
1053
+
1054
+ **MindForge is now at v0.5.0:**
1055
+ **25 commands · 10 skills · 8 personas · 14 ADRs · 9 test suites · 5 days of builds**
1056
+
1057
+ ---
1058
+
1059
+ ## DAY 6 PREVIEW
1060
+
1061
+ ```
1062
+ Branch: feat/mindforge-distribution-platform
1063
+
1064
+ Day 6 scope:
1065
+ - Public skills registry on npm: npx mindforge-skills install [skill-name]
1066
+ - Multi-repo and monorepo support (workspace-aware phase execution)
1067
+ - AI-generated PR code reviews using Claude API
1068
+ - MindForge CI mode: non-interactive execution in GitHub Actions / GitLab CI
1069
+ - /mindforge:init-org — organisation-wide MindForge setup wizard
1070
+ - Skill contribution guidelines and community skill validation
1071
+ - Performance benchmarking system for skill quality comparison
1072
+ - MindForge SDK: programmatic API for embedding in other tools
1073
+ - Real-time progress streaming via Server-Sent Events
1074
+ - MINDFORGE.md schema validation (JSON Schema for config file)
1075
+ ```
1076
+
1077
+ **Branch:** `feat/mindforge-intelligence-layer`
1078
+ **Day 5 hardening complete. Open PR → assign reviewer → merge to main.**