@polymorphism-tech/morph-spec 8.37.1 → 8.38.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 (128) hide show
  1. package/CLAUDE.md +19 -6
  2. package/README.md +2 -2
  3. package/bin/morph-spec.js +16 -7
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/CLAUDE.md +3 -3
  8. package/framework/MORPH.md +25 -22
  9. package/framework/agents.json +76 -27
  10. package/framework/docs/CLI.md +54 -17
  11. package/framework/evals/rubrics/code-quality.md +5 -0
  12. package/framework/evals/rubrics/condensed.md +6 -2
  13. package/framework/evals/rubrics/contracts.md +20 -0
  14. package/framework/evals/rubrics/test-coverage.md +17 -6
  15. package/framework/hooks/README.md +9 -3
  16. package/framework/hooks/claude-code/core/graph-refresh-kick.js +52 -0
  17. package/framework/hooks/claude-code/core/telemetry-log.js +172 -87
  18. package/framework/hooks/claude-code/core/validate-completion.js +16 -90
  19. package/framework/hooks/claude-code/core/worktree-context.js +10 -0
  20. package/framework/hooks/shared/command-tokens.js +96 -0
  21. package/framework/hooks/shared/git-exclude.js +44 -0
  22. package/framework/hooks/shared/git-paths.js +52 -0
  23. package/framework/hooks/shared/graph-freshness.js +380 -0
  24. package/framework/hooks/shared/graph-refresh.js +416 -0
  25. package/framework/hooks/shared/morph-cli.js +17 -5
  26. package/framework/hooks/shared/redact-secrets.js +55 -0
  27. package/framework/hooks/shared/telemetry-logger.js +25 -2
  28. package/framework/hooks/shared/transcript-usage.js +80 -0
  29. package/framework/rubrics/backend.json +2 -2
  30. package/framework/rubrics/default.json +2 -2
  31. package/framework/rubrics/frontend.json +2 -2
  32. package/framework/rules/csharp-standards.md +1 -0
  33. package/framework/rules/morph-workflow.md +1 -0
  34. package/framework/rules/nextjs-standards.md +1 -0
  35. package/framework/schemas/config.schema.json +41 -1
  36. package/framework/schemas/feature.schema.json +5 -1
  37. package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
  38. package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
  39. package/framework/skills/core/morph-apply/SKILL.md +36 -11
  40. package/framework/skills/core/morph-brainstorming/SKILL.md +16 -7
  41. package/framework/skills/core/morph-eval/SKILL.md +1 -1
  42. package/framework/skills/core/morph-hotfix/SKILL.md +1 -1
  43. package/framework/skills/core/morph-implement/SKILL.md +39 -10
  44. package/framework/skills/core/morph-media/SKILL.md +1 -1
  45. package/framework/skills/core/morph-plan/SKILL.md +72 -15
  46. package/framework/skills/core/morph-proposal/SKILL.md +1 -1
  47. package/framework/skills/core/morph-review/SKILL.md +51 -13
  48. package/framework/skills/core/morph-stack-scan/SKILL.md +1 -1
  49. package/framework/skills/core/morph-standards/SKILL.md +1 -1
  50. package/framework/skills/core/morph-uiux/SKILL.md +34 -9
  51. package/framework/standards/STANDARDS.json +187 -12
  52. package/framework/standards/ai-agents/testing-ai.md +2 -1
  53. package/framework/standards/architecture/code-comments.md +64 -0
  54. package/framework/standards/backend/dotnet/testing.md +22 -0
  55. package/framework/standards/frontend/admin-app/data-table.md +562 -0
  56. package/framework/standards/frontend/admin-app/feedback.md +236 -0
  57. package/framework/standards/frontend/admin-app/forms.md +232 -0
  58. package/framework/standards/frontend/admin-app/page-structure.md +203 -0
  59. package/framework/standards/frontend/nextjs/components.md +37 -58
  60. package/framework/standards/frontend/nextjs/data-fetching.md +1 -0
  61. package/framework/standards/frontend/nextjs/forms.md +31 -30
  62. package/framework/standards/frontend/nextjs/state-management.md +2 -1
  63. package/framework/standards/frontend/nextjs/testing.md +18 -0
  64. package/framework/templates/context/design-system.md +3 -3
  65. package/framework/templates/docs/proposal.md +11 -0
  66. package/framework/templates/docs/spec.md +15 -0
  67. package/framework/templates/docs/ui-mockups.md +115 -98
  68. package/framework/templates/feature/decisions.md +124 -122
  69. package/package.json +1 -1
  70. package/src/commands/graph/affected.js +4 -3
  71. package/src/commands/graph/build.js +109 -18
  72. package/src/commands/graph/explain.js +8 -5
  73. package/src/commands/graph/status.js +14 -8
  74. package/src/commands/observability/cost.js +148 -18
  75. package/src/commands/project/doctor.js +82 -10
  76. package/src/commands/project/update.js +25 -0
  77. package/src/commands/project/worktree.js +73 -90
  78. package/src/commands/state/advance.js +18 -0
  79. package/src/commands/state/approve.js +15 -0
  80. package/src/commands/state/archive.js +62 -9
  81. package/src/commands/state/finish.js +62 -14
  82. package/src/commands/state/gate-check.js +8 -1
  83. package/src/commands/state/gate-decision.js +8 -4
  84. package/src/commands/state/report-check.js +90 -9
  85. package/src/commands/state/usecase.js +66 -0
  86. package/src/commands/tasks/dag.js +17 -2
  87. package/src/commands/validation/validate-feature.js +6 -1
  88. package/src/commands/validation/verify.js +20 -1
  89. package/src/dashboard/scanner/agents-scanner.js +5 -1
  90. package/src/dashboard/scanner/hooks-scanner.js +8 -1
  91. package/src/dashboard/scanner/standards-scanner.js +2 -1
  92. package/src/lib/ai/comment-stripper.js +101 -4
  93. package/src/lib/evaluator-report.js +25 -0
  94. package/src/lib/generators/handoff-generator.js +4 -18
  95. package/src/lib/git/default-branch.js +52 -0
  96. package/src/lib/git/tree-fingerprint.js +58 -0
  97. package/src/lib/git/tree-state.js +167 -0
  98. package/src/lib/graph/god-nodes.js +12 -3
  99. package/src/lib/graph/graph-health.js +48 -2
  100. package/src/lib/graph/graph-loader.js +99 -25
  101. package/src/lib/graph/graphifyignore.js +145 -28
  102. package/src/lib/graph/sanitize.js +117 -11
  103. package/src/lib/risk-detector.js +90 -0
  104. package/src/lib/specs/acervo-format.js +70 -0
  105. package/src/lib/specs/acervo-lifecycle.js +264 -0
  106. package/src/lib/specs/adr-index.js +169 -0
  107. package/src/lib/specs/revocations.js +156 -0
  108. package/src/lib/specs/screen-checklist.js +357 -0
  109. package/src/lib/specs/usecase-check.js +20 -16
  110. package/src/lib/specs/usecase-promoter.js +103 -38
  111. package/src/lib/specs/usecase-registry.js +7 -7
  112. package/src/lib/tasks/tasks-json-parser.js +2 -3
  113. package/src/lib/telemetry/metrics.js +386 -0
  114. package/src/lib/telemetry/telemetry-reader.js +161 -51
  115. package/src/lib/telemetry/verify-event.js +79 -0
  116. package/src/lib/validators/code-budget/code-budget-validator.js +172 -0
  117. package/src/lib/validators/code-budget/comment-scanner.js +75 -0
  118. package/src/lib/validators/code-budget/index.js +9 -0
  119. package/src/lib/validators/reuse/reuse-validator.js +4 -2
  120. package/src/lib/validators/reuse/symbol-scanner.js +27 -22
  121. package/src/lib/validators/validation-runner.js +21 -5
  122. package/src/lib/validators/verify-runner.js +11 -0
  123. package/src/lib/worktree/finish-backup.js +739 -0
  124. package/src/lib/worktree/ignored-triage.js +15 -8
  125. package/src/lib/worktree/worktree-audit.js +5 -0
  126. package/src/scripts/setup-infra.js +29 -18
  127. package/src/utils/agents-installer.js +281 -12
  128. package/src/utils/hooks-installer.js +75 -15
@@ -35,8 +35,25 @@ import { realEffects } from '../lib/installers/effects.js';
35
35
  * (junctions, port block, primary-root landing) and its removal routed
36
36
  * through the safe `worktree remove --if-clean` — and appends
37
37
  * block-raw-worktree-add to the PreToolUse:Bash chain.
38
+ *
39
+ * 3.9.0 binds telemetry-log to PostToolUseFailure (a Bash command that exits
40
+ * non-zero fires only that event, so red runs used to vanish from the log),
41
+ * PostToolBatch (once per model turn that used tools) and SubagentStop (the
42
+ * sub-agent's own token usage). The three only record, so they run with
43
+ * `async: true`: a node process per model turn never holds the turn up.
44
+ *
45
+ * 3.10.0 appends graph-refresh-kick to the all-tools PostToolUse chain: after a
46
+ * Bash or PowerShell command that runs git/gh/morph-spec it launches the
47
+ * detached refresh of the ROOT's codebase graph
48
+ * (framework/hooks/shared/graph-refresh.js). `update` re-runs
49
+ * this installer, so installed projects get the refresh without re-running
50
+ * `setup-infra` — the step that never reached them.
51
+ *
52
+ * 3.11.0 writes every `timeout` in seconds, the unit Claude Code reads: the
53
+ * values were milliseconds, so a hung hook held the session for hours (120000
54
+ * on WorktreeCreate is 33 h) instead of the seconds they meant.
38
55
  */
39
- const HOOKS_VERSION = '3.8.0';
56
+ const HOOKS_VERSION = '3.11.0';
40
57
 
41
58
  /** Marker for old dispatch.js (v1) */
42
59
  const OLD_DISPATCH_COMMAND = 'node framework/hooks/agent-teams/dispatch.js';
@@ -119,7 +136,7 @@ const MORPH_HOOKS = [
119
136
  hooks: [{
120
137
  type: 'command',
121
138
  command: 'node framework/hooks/claude-code/core/worktree-context.js',
122
- timeout: 5000
139
+ timeout: 5
123
140
  }]
124
141
  },
125
142
 
@@ -173,7 +190,7 @@ const MORPH_HOOKS = [
173
190
  hooks: [{
174
191
  type: 'command',
175
192
  command: 'node framework/hooks/claude-code/core/worktree-create.js',
176
- timeout: 120000
193
+ timeout: 120
177
194
  }]
178
195
  },
179
196
 
@@ -188,7 +205,7 @@ const MORPH_HOOKS = [
188
205
  hooks: [{
189
206
  type: 'command',
190
207
  command: 'node framework/hooks/claude-code/core/worktree-remove.js',
191
- timeout: 60000
208
+ timeout: 60
192
209
  }]
193
210
  },
194
211
 
@@ -227,24 +244,66 @@ const MORPH_HOOKS = [
227
244
  type: 'command',
228
245
  command: 'node framework/hooks/claude-code/core/chain.js',
229
246
  args: ['state-sync', 'gate-guard'],
230
- timeout: 6000
247
+ timeout: 6
231
248
  }]
232
249
  },
233
250
 
234
- // === PostToolUse: All — telemetry capture (silent) + loop detection.
235
- // telemetry-log is the single generic vantage point of an NLH: it appends
236
- // every tool call (skill, sub-agent dispatch, knowledge-base read, …) to
237
- // .morph/logs/events.jsonl. Silent and fail-open — never blocks, never
238
- // injects. `morph-spec telemetry` reads the stream back. Both links
239
- // declared 5000ms; chain declares the sum (sequential worst case). ===
251
+ // === PostToolUse: All — telemetry capture (silent) + loop detection +
252
+ // graph refresh kick. telemetry-log is the single generic vantage point of an
253
+ // NLH: it appends every tool call (skill, sub-agent dispatch, knowledge-base
254
+ // read, …) to .morph/logs/events.jsonl. Silent and fail-open — never blocks,
255
+ // never injects. `morph-spec telemetry` reads the stream back.
256
+ // graph-refresh-kick only spawns a DETACHED worker (never waits on graphify),
257
+ // so it rides this chain instead of costing a process of its own per Bash
258
+ // call. Timeout stays the sum of the first two links (sequential worst case);
259
+ // the kick returns in milliseconds. ===
240
260
  {
241
261
  event: 'PostToolUse',
242
262
  matcher: null,
243
263
  hooks: [{
244
264
  type: 'command',
245
265
  command: 'node framework/hooks/claude-code/core/chain.js',
246
- args: ['telemetry-log', 'loop-detect'],
247
- timeout: 10000
266
+ args: ['telemetry-log', 'loop-detect', 'graph-refresh-kick'],
267
+ timeout: 10
268
+ }]
269
+ },
270
+
271
+ // === PostToolUseFailure: All — telemetry of the failed call (exit code,
272
+ // duration). loop-detect stays out: its warning is shaped for PostToolUse.
273
+ {
274
+ event: 'PostToolUseFailure',
275
+ matcher: null,
276
+ hooks: [{
277
+ type: 'command',
278
+ command: 'node framework/hooks/claude-code/core/telemetry-log.js',
279
+ timeout: 5,
280
+ async: true
281
+ }]
282
+ },
283
+
284
+ // === PostToolBatch — one event per model turn that used tools. The event
285
+ // takes no matcher. ===
286
+ {
287
+ event: 'PostToolBatch',
288
+ matcher: null,
289
+ hooks: [{
290
+ type: 'command',
291
+ command: 'node framework/hooks/claude-code/core/telemetry-log.js',
292
+ timeout: 5,
293
+ async: true
294
+ }]
295
+ },
296
+
297
+ // === SubagentStop — the sub-agent's token usage, read from its own
298
+ // transcript (the session transcript does not include it). ===
299
+ {
300
+ event: 'SubagentStop',
301
+ matcher: null,
302
+ hooks: [{
303
+ type: 'command',
304
+ command: 'node framework/hooks/claude-code/core/telemetry-log.js',
305
+ timeout: 10,
306
+ async: true
248
307
  }]
249
308
  },
250
309
 
@@ -258,7 +317,7 @@ const MORPH_HOOKS = [
258
317
  hooks: [{
259
318
  type: 'command',
260
319
  command: 'node framework/hooks/claude-code/core/telemetry-log.js',
261
- timeout: 5000
320
+ timeout: 5
262
321
  }]
263
322
  },
264
323
 
@@ -338,7 +397,8 @@ export async function installClaudeHooks(targetPath, { fx = realEffects() } = {}
338
397
  return {
339
398
  type: h.type,
340
399
  command,
341
- ...(h.timeout !== undefined ? { timeout: h.timeout } : {})
400
+ ...(h.timeout !== undefined ? { timeout: h.timeout } : {}),
401
+ ...(h.async ? { async: true } : {})
342
402
  };
343
403
  });
344
404