@mutagent/helix 0.1.0-alpha.14

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 (357) hide show
  1. package/.claude/skills/mutagent-helix/SKILL.md +113 -0
  2. package/.claude/skills/mutagent-helix/scripts/cli/codex-transcode.ts +143 -0
  3. package/.claude/skills/mutagent-helix/scripts/cli/doctor.ts +111 -0
  4. package/.claude/skills/mutagent-helix/scripts/cli/init.ts +382 -0
  5. package/.claude/skills/mutagent-helix/scripts/cli/run.sh +61 -0
  6. package/CLAUDE.md +193 -0
  7. package/LICENSE +201 -0
  8. package/NOTICE +22 -0
  9. package/README.md +209 -0
  10. package/assets/adl-loop.svg +162 -0
  11. package/assets/system-status.svg +422 -0
  12. package/bin/mutagent-cli.mjs +9950 -0
  13. package/bin/mutagent-helix.mjs +78 -0
  14. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/CLAUDE.md +28 -0
  15. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/SKILL.md +138 -0
  16. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/assets/templates/agentspec.yaml.tpl +247 -0
  17. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/references/frameworks/doc-pins.md +53 -0
  18. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/references/principles.md +91 -0
  19. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/references/requirements.yaml +295 -0
  20. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/references/workflows/orchestrator-protocol.md +302 -0
  21. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/cli/doctor.ts +116 -0
  22. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/cli/init.ts +230 -0
  23. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/cli/run.sh +60 -0
  24. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/config/resolve-spec-dir.ts +199 -0
  25. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/contract/agentspec.schema.ts +455 -0
  26. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/setup/detect.ts +67 -0
  27. package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/validate/validate-spec.ts +93 -0
  28. package/mutagent-agentspec/LICENSE +201 -0
  29. package/mutagent-agentspec/NOTICE +19 -0
  30. package/mutagent-agentspec/README.md +44 -0
  31. package/mutagent-builder/.claude/skills/mutagent-builder/SKILL.md +100 -0
  32. package/mutagent-builder/.claude/skills/mutagent-builder/assets/agents/ai-architect.md +312 -0
  33. package/mutagent-builder/.claude/skills/mutagent-builder/assets/agents/ai-engineer.md +357 -0
  34. package/mutagent-builder/.claude/skills/mutagent-builder/assets/templates/build-report.md.tpl +39 -0
  35. package/mutagent-builder/.claude/skills/mutagent-builder/references/principles.md +31 -0
  36. package/mutagent-builder/.claude/skills/mutagent-builder/references/workflows/build-protocol.md +61 -0
  37. package/mutagent-builder/.claude/skills/mutagent-builder/references/workflows/improve-handoff.md +23 -0
  38. package/mutagent-builder/.claude/skills/mutagent-builder/scripts/cli/run.sh +60 -0
  39. package/mutagent-builder/.claude/skills/mutagent-builder/scripts/handoff/validate-build-input.ts +72 -0
  40. package/mutagent-builder/.claude/skills/mutagent-builder/scripts/sync-spec/check-sync-spec.ts +499 -0
  41. package/mutagent-builder/.claude/skills/mutagent-builder/scripts/verify/spec-impl-coverage.ts +182 -0
  42. package/mutagent-builder/CLAUDE.md +25 -0
  43. package/mutagent-builder/README.md +26 -0
  44. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/README.md +192 -0
  45. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/SKILL.md +352 -0
  46. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/agents/ai-architect.md +256 -0
  47. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/agents/ai-engineer.md +344 -0
  48. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/agents/diagnostics-analyzer.md +576 -0
  49. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/agents/discovery.md +425 -0
  50. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/audit.json.tpl +24 -0
  51. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/audit.md.tpl +49 -0
  52. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/config.yaml.tpl +100 -0
  53. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/pr-body.md.tpl +56 -0
  54. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/report.html.tpl +327 -0
  55. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/README.md +27 -0
  56. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/iter-N-handover.md.tpl +125 -0
  57. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/self-diagnosis-contract.v0.1.0.yaml.tpl +234 -0
  58. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/spec.yaml.tpl +152 -0
  59. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/team.yaml.tpl +127 -0
  60. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/wave-N-dashboard.html.tpl +1712 -0
  61. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.1-nl-query.md +59 -0
  62. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.2-tier0-progress.md +58 -0
  63. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.3-analysis-progress.md +44 -0
  64. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.4-html-report.md +61 -0
  65. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.5-rca-detail.md +69 -0
  66. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.6-stale-warning.md +53 -0
  67. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.1-welcome.md +60 -0
  68. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.2-source-platform-picker.md +41 -0
  69. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.3-source-auth.md +75 -0
  70. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.4-target-picker.md +48 -0
  71. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.5-ask-tool.md +43 -0
  72. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.6-config-review.md +57 -0
  73. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.7-filter-defaults.md +52 -0
  74. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.8-first-run.md +59 -0
  75. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/examples/sample-findings.json +92 -0
  76. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/examples/sample-meta.json +47 -0
  77. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/adapter-strategy.md +75 -0
  78. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/config-migration.md +84 -0
  79. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/config.md +159 -0
  80. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/filter-search-matrix.md +66 -0
  81. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/harness-knowledge.md +22 -0
  82. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/memory-format.md +78 -0
  83. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/onboarding-decisions.yaml +187 -0
  84. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/operation-inventory.md +59 -0
  85. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/overview.md +167 -0
  86. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/reference.md +119 -0
  87. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/script-index.md +101 -0
  88. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-adapter-contract.md +93 -0
  89. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/claude-code-transcripts.md +66 -0
  90. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/codex-transcripts.md +78 -0
  91. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/codex.md +145 -0
  92. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/install-paths.md +57 -0
  93. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/langfuse.md +178 -0
  94. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/local-jsonl.md +55 -0
  95. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/openobserve.md +102 -0
  96. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/otel.md +63 -0
  97. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/cloud-rest.md +84 -0
  98. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-claude.md +65 -0
  99. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-cloud-agent-sdk.md +92 -0
  100. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-codex.md +72 -0
  101. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-cursor.md +108 -0
  102. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-mastra.md +77 -0
  103. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-opencode.md +70 -0
  104. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/apply-pr-comment-format.md +82 -0
  105. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/diagnostics.md +35 -0
  106. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/handover-contract.md +247 -0
  107. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/onboarding.md +300 -0
  108. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/orchestrator-protocol.md +1861 -0
  109. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/rca.md +331 -0
  110. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/rendering-anatomy.md +314 -0
  111. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/schedule-prep.md +100 -0
  112. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/scope-model.md +128 -0
  113. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/verification-methodology.md +174 -0
  114. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/aggregate/sort-findings.ts +0 -0
  115. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/awareness/blind-spots.ts +167 -0
  116. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/awareness/llm-sample.ts +681 -0
  117. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/doctor.ts +215 -0
  118. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/init.ts +1013 -0
  119. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/install-agents.ts +350 -0
  120. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/run.sh +61 -0
  121. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/shared-templates.ts +79 -0
  122. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/config/load.ts +392 -0
  123. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/config/resolve-credential.ts +120 -0
  124. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/config/schema.ts +641 -0
  125. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/config/validate.ts +134 -0
  126. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/context/build-diagnosis-context.ts +417 -0
  127. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/context/load-context.ts +105 -0
  128. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/contract/types.ts +166 -0
  129. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/enrich/build-render-input.ts +1964 -0
  130. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/enrich/corpus-severity.ts +172 -0
  131. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/enrich/dismissal-match.ts +270 -0
  132. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/enrich/rank-remedies.ts +75 -0
  133. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/hooks/install-hooks.sh +46 -0
  134. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/hooks/pre-push.sh +78 -0
  135. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/invocation/parse-brief.ts +188 -0
  136. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/library/match.ts +114 -0
  137. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/library/paths.ts +95 -0
  138. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/library/store.ts +535 -0
  139. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/library/types.ts +181 -0
  140. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/lint/template-inline-js.ts +267 -0
  141. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/memory/append.ts +188 -0
  142. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/memory/read.ts +218 -0
  143. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/platforms/entity-context.ts +686 -0
  144. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/read-unitf.ts +267 -0
  145. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/trace.ts +1078 -0
  146. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/unitf-adapter.ts +0 -0
  147. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/unitf-types.ts +213 -0
  148. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/report/persist-selections.ts +174 -0
  149. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/report/render.ts +3254 -0
  150. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/run/diagnose.ts +64 -0
  151. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/run/session.ts +167 -0
  152. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/sample/caps.ts +345 -0
  153. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/sample/deep-read-gate.ts +424 -0
  154. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/sample/representative.ts +584 -0
  155. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/scan/objection.ts +224 -0
  156. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/scan/trajectory.ts +489 -0
  157. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/self-diagnostics/dispatch.ts +135 -0
  158. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/self-diagnostics/probe.ts +170 -0
  159. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/setup/detect.ts +307 -0
  160. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/setup/ensure-cli.ts +315 -0
  161. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/setup/reconfigure.ts +77 -0
  162. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/setup/verify-agents.ts +207 -0
  163. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/slicer.ts +166 -0
  164. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/claude-code.ts +17 -0
  165. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/codex.ts +11 -0
  166. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/langfuse.ts +17 -0
  167. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/local-jsonl.ts +12 -0
  168. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/otel.ts +12 -0
  169. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/index.ts +54 -0
  170. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/registry.ts +45 -0
  171. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/types.ts +86 -0
  172. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/stale-detector.ts +74 -0
  173. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/test/render-playwright.cli.ts +477 -0
  174. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/tier0/claude-code.ts +133 -0
  175. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/tier0/langfuse.ts +143 -0
  176. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/tier0-scan.ts +423 -0
  177. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/completeness-check.ts +436 -0
  178. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/doc-refs.ts +190 -0
  179. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/finalize-gate.ts +417 -0
  180. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/findings-contract.ts +628 -0
  181. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/render-js-syntax.ts +188 -0
  182. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/report-checklist.yaml +217 -0
  183. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/trace-shape.ts +262 -0
  184. package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/wave6-checklist.ts +326 -0
  185. package/mutagent-diagnostics/CLAUDE.md +41 -0
  186. package/mutagent-diagnostics/LICENSE +201 -0
  187. package/mutagent-diagnostics/NOTICE +18 -0
  188. package/mutagent-diagnostics/README.md +343 -0
  189. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/SKILL.md +548 -0
  190. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/agents/audit-executor.md +169 -0
  191. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/agents/dataset-builder.md +160 -0
  192. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/agents/discovery.md +425 -0
  193. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/agents/evaluator.md +1108 -0
  194. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/brand/theme.css +213 -0
  195. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/brand/wordmark.html +9 -0
  196. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/context-flow-lens.md +85 -0
  197. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/data-lens.md +47 -0
  198. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/decision-lens.md +48 -0
  199. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/methodology-critic-lens.md +53 -0
  200. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/trajectory-lens.md +44 -0
  201. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/build-review-interface.md +83 -0
  202. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/edd-loop.md +134 -0
  203. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/error-analysis.md +113 -0
  204. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/eval-audit.md +154 -0
  205. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/eval-stage.md +168 -0
  206. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/generate-synthetic-data.md +81 -0
  207. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/grounded-adjudication.md +221 -0
  208. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/memory-format.md +65 -0
  209. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/methodology.md +201 -0
  210. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/operation-inventory.md +197 -0
  211. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/validate-evaluator.md +125 -0
  212. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/workflows/orchestrator-protocol.md +300 -0
  213. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/write-judge-prompt.md +123 -0
  214. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/behavior-tree.schema.yaml +73 -0
  215. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/dataset.schema.yaml +66 -0
  216. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/edd-change-request.schema.yaml +114 -0
  217. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/eval-matrix.schema.yaml +74 -0
  218. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/flow-graph.schema.yaml +69 -0
  219. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/flow-profile.schema.yaml +49 -0
  220. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/methodology-review.schema.yaml +40 -0
  221. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/scorecard.schema.yaml +85 -0
  222. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/agent-dispatch.ts +0 -0
  223. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/aggregate-discover.ts +543 -0
  224. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/artifact-paths.ts +115 -0
  225. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/assemble-scorecard.ts +172 -0
  226. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/build-dataset.ts +186 -0
  227. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/build-evals.ts +93 -0
  228. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/build-review-ui.ts +393 -0
  229. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/check-method-router.ts +170 -0
  230. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/aggregate.ts +112 -0
  231. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/audit-run.ts +182 -0
  232. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/doctor.ts +211 -0
  233. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/dogfood.ts +133 -0
  234. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/init.ts +601 -0
  235. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/methodology-review.ts +122 -0
  236. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/prep.ts +295 -0
  237. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/profile-subject.ts +165 -0
  238. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/run.sh +56 -0
  239. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/variance-check.ts +105 -0
  240. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/code-eval.ts +248 -0
  241. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/code-quality-verdict.ts +285 -0
  242. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/codegen-evals.ts +173 -0
  243. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cold-start-project.ts +151 -0
  244. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cold-start-sampler.ts +267 -0
  245. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/config/load.ts +343 -0
  246. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/config/schema.ts +380 -0
  247. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/agentspec-evals.ts +85 -0
  248. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/dataset.ts +149 -0
  249. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/eval-engine.ts +118 -0
  250. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/eval-matrix.ts +577 -0
  251. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/eval-types.ts +1074 -0
  252. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/flow-graph.ts +194 -0
  253. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/types.ts +303 -0
  254. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/validation.ts +193 -0
  255. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/derive-dataset.ts +152 -0
  256. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/determine-outcome.ts +219 -0
  257. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/diff-discriminate.ts +160 -0
  258. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/discover-criteria.ts +348 -0
  259. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/edd/change-request.ts +232 -0
  260. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/edd/edd-types.ts +210 -0
  261. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/edd/variance-gate.ts +186 -0
  262. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/emit-completeness.ts +111 -0
  263. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/eval-engine.ts +160 -0
  264. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/evaluate.ts +333 -0
  265. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/flow-graph.ts +230 -0
  266. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/judge-prompt-template.ts +253 -0
  267. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/judge-provider.ts +135 -0
  268. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/lint-grounding.ts +229 -0
  269. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/lint-uniformity.ts +168 -0
  270. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/living-suite.ts +109 -0
  271. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/load-bundle.ts +203 -0
  272. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/load-profile-vocab.ts +64 -0
  273. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/load-profile.ts +106 -0
  274. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/mask.ts +138 -0
  275. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/materialize-dataset.ts +113 -0
  276. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/matrix-judge.ts +750 -0
  277. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/memory/append.ts +215 -0
  278. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/memory/read.ts +168 -0
  279. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/persist-eval-criteria.ts +232 -0
  280. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/prep-tasks.ts +125 -0
  281. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/profile-subject.ts +310 -0
  282. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/publish-report.ts +131 -0
  283. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/read-unitf-traces.ts +81 -0
  284. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/render-build-cards.ts +195 -0
  285. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/render-discover-report.ts +1640 -0
  286. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/render-eval-report.ts +3838 -0
  287. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/render-report.ts +212 -0
  288. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/resolve-credential.ts +110 -0
  289. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/resolve-ref.ts +98 -0
  290. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/result-verify.ts +129 -0
  291. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/route-failures.ts +330 -0
  292. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/run-deterministic.ts +367 -0
  293. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/run-evaluate.ts +719 -0
  294. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/run-judge.ts +155 -0
  295. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/run-pipeline.ts +175 -0
  296. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/sample-traces.ts +210 -0
  297. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/self-audit.ts +387 -0
  298. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/source-map.ts +106 -0
  299. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/subject-profile.ts +134 -0
  300. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/substrate.ts +162 -0
  301. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/sync-eval-criteria.ts +244 -0
  302. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/ui-slots.ts +119 -0
  303. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/unitf-to-evaltrace.ts +284 -0
  304. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/validate-judge.ts +358 -0
  305. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/variance-compare.ts +177 -0
  306. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/subjects/mutagent-diagnostics/behavior-tree.yaml +140 -0
  307. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/subjects/mutagent-diagnostics/eval-matrix.yaml +1270 -0
  308. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/subjects/mutagent-diagnostics/methodology-review.yaml +105 -0
  309. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/workflows/audit.workflow.js +82 -0
  310. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/workflows/data-leak.workflow.js +236 -0
  311. package/mutagent-evaluator/.claude/skills/mutagent-evaluator/workflows/variance.workflow.js +163 -0
  312. package/mutagent-evaluator/CLAUDE.md +45 -0
  313. package/mutagent-evaluator/LICENSE +201 -0
  314. package/mutagent-evaluator/NOTICE +23 -0
  315. package/mutagent-evaluator/README.md +88 -0
  316. package/mutagent-optimize/.claude/skills/mutagent-optimize/SKILL.md +287 -0
  317. package/mutagent-optimize/.claude/skills/mutagent-optimize/scripts/contracts/amend-request.ts +503 -0
  318. package/mutagent-optimize/.claude/skills/mutagent-optimize/scripts/improve-loop-run.ts +304 -0
  319. package/mutagent-optimize/.claude/skills/mutagent-optimize/scripts/loop-state-cli.ts +300 -0
  320. package/mutagent-optimize/.claude/skills/mutagent-optimize/scripts/loop-state.ts +440 -0
  321. package/mutagent-optimize/CLAUDE.md +49 -0
  322. package/mutagent-optimize/README.md +26 -0
  323. package/mutagent-orchestrator/CLAUDE.md +102 -0
  324. package/mutagent-orchestrator/README.md +20 -0
  325. package/mutagent-orchestrator/assets/agents/discovery.md +425 -0
  326. package/mutagent-orchestrator/assets/agents/dogfood-monitor.md +266 -0
  327. package/mutagent-orchestrator/assets/agents/monitor.md +258 -0
  328. package/mutagent-orchestrator/orchestrator.md +782 -0
  329. package/mutagent-orchestrator/references/MONITORING.md +209 -0
  330. package/mutagent-orchestrator/references/config-fields.md +132 -0
  331. package/mutagent-orchestrator/references/config-migration.md +132 -0
  332. package/mutagent-orchestrator/references/index-registry.md +92 -0
  333. package/mutagent-orchestrator/routing.yaml +391 -0
  334. package/mutagent-orchestrator/scripts/config-schema.ts +1010 -0
  335. package/mutagent-orchestrator/scripts/dispatch.ts +439 -0
  336. package/mutagent-orchestrator/scripts/dogfood/extract-feedback.ts +203 -0
  337. package/mutagent-orchestrator/scripts/dogfood/reconstruct-trajectory.ts +327 -0
  338. package/mutagent-orchestrator/scripts/dogfood/render-dogfood-report.ts +347 -0
  339. package/mutagent-orchestrator/scripts/dogfood/resolve-subagents.ts +160 -0
  340. package/mutagent-orchestrator/scripts/dogfood/run-report.ts +264 -0
  341. package/mutagent-orchestrator/scripts/dogfood/slack-thread.ts +106 -0
  342. package/mutagent-orchestrator/scripts/dogfood/types.ts +257 -0
  343. package/mutagent-orchestrator/scripts/eval-routing.ts +753 -0
  344. package/mutagent-orchestrator/scripts/gate.ts +219 -0
  345. package/mutagent-orchestrator/scripts/handover-contract.ts +362 -0
  346. package/mutagent-orchestrator/scripts/index/build-index.ts +351 -0
  347. package/mutagent-orchestrator/scripts/index/render-index.ts +110 -0
  348. package/mutagent-orchestrator/scripts/monitor/slack-notify.ts +111 -0
  349. package/mutagent-orchestrator/scripts/monitor/triggers.ts +162 -0
  350. package/mutagent-orchestrator/scripts/onboarding-check.ts +369 -0
  351. package/mutagent-orchestrator/scripts/render-roster.ts +308 -0
  352. package/mutagent-orchestrator/scripts/resolve-credential.ts +185 -0
  353. package/mutagent-orchestrator/scripts/resolve-paths.ts +114 -0
  354. package/mutagent-orchestrator/scripts/slack/format.ts +63 -0
  355. package/mutagent-orchestrator/scripts/slack/post.ts +115 -0
  356. package/mutagent-orchestrator/scripts/sync-index.ts +311 -0
  357. package/package.json +64 -0
@@ -0,0 +1,351 @@
1
+ /**
2
+ * scripts/index/build-index.ts
3
+ * F4 — the `.mutagent/index.md` spec ↔ implementation REGISTRY writer (build core).
4
+ * Type A — Pure core (data → model) + a thin INJECTED-I/O regenerate wrapper.
5
+ *
6
+ * WHAT this is: one deterministic writer that regenerates a single `.mutagent/index.md`
7
+ * linking each registered AgentSpec to everything that realizes it — HIGH-LEVEL ONLY:
8
+ * spec identity · stage · verdict · build target + LINKS to implementation code and
9
+ * context docs, stamped with `spec_version` + an injected `updated` date.
10
+ *
11
+ * ANTI-DRIFT (LOAD-BEARING): the index carries identity + stage/verdict + version/date +
12
+ * LINKS ONLY. It NEVER restates eval criteria / scenarios / dataset detail — that lives in
13
+ * the evaluator's living-suite; duplicating it here is a drift + maintenance burden. The
14
+ * index only points; it never copies.
15
+ *
16
+ * DETERMINISM (mirrors mutagent-diagnostics `store.ts` regenerateIndex):
17
+ * - entries sorted by spec_id · code/context links sorted by path · deduped
18
+ * - the ONLY non-determinism (the `updated` date) is INJECTED by the caller (nowIso)
19
+ * - pure `buildIndexModel` (no I/O, no clock) + pure `renderIndex` (render-index.ts)
20
+ * - `regenerateIndex` takes an INJECTED IndexIo seam → byte-stable tests with no disk
21
+ *
22
+ * The rendered markdown IS the machine surface — no sidecar JSON. See render-index.ts for
23
+ * the exact layout and references/index-registry.md for the update-point convention.
24
+ */
25
+
26
+ import * as fs from "node:fs";
27
+ import * as path from "node:path";
28
+ import { parse as parseYaml } from "yaml";
29
+
30
+ import {
31
+ MUTAGENT_DIR,
32
+ STAGE_DIRS,
33
+ mutagentDir,
34
+ stageDir,
35
+ resolveConfigRoot,
36
+ } from "../resolve-paths.ts";
37
+ import { renderIndex } from "./render-index.ts";
38
+
39
+ // ── Model ────────────────────────────────────────────────────────────────────
40
+
41
+ /** A link to an implementation file that realizes an agent (from a target `code_refs[]`). */
42
+ export interface IndexCodeLink {
43
+ /** Project-root-relative path (config determinism: never absolute). */
44
+ path: string;
45
+ /** WHY this file matters (verbatim from the config `code_refs[].why`). */
46
+ why: string;
47
+ }
48
+
49
+ /** A link to a context / product doc (from `global.context[]`). */
50
+ export interface IndexContextLink {
51
+ /** Project-root-relative path. */
52
+ path: string;
53
+ what: string;
54
+ why: string;
55
+ when: string;
56
+ }
57
+
58
+ /** One agent's HIGH-LEVEL registry entry. Links only — no eval detail. */
59
+ export interface IndexEntry {
60
+ /** Display name — `definition.identity.name`, falling back to the spec_id. */
61
+ name: string;
62
+ /** The stable identity anchor `meta.spec_id` (also the sort key). */
63
+ specId: string;
64
+ /** `meta.spec_version`. */
65
+ specVersion: string;
66
+ /** `meta.loop_state.stage` — where in the ADL loop the spec sits. */
67
+ stage: string;
68
+ /** `meta.loop_state.last_verdict`, or null when the agent has no verdict yet. */
69
+ lastVerdict: string | null;
70
+ /** `.mutagent/`-relative link to the spec file: `specs/<id>/agentspec.yaml`. */
71
+ specPath: string;
72
+ /** `build.{target_framework, runtime}`, or null when the spec has no build block. */
73
+ build: { targetFramework: string; runtime: string } | null;
74
+ /** Implementation links (config `global.targets[].code_refs`), sorted + deduped by path. */
75
+ codeRefs: IndexCodeLink[];
76
+ /** Context / product doc links (`global.context[]`), sorted by path. */
77
+ contextLinks: IndexContextLink[];
78
+ }
79
+
80
+ /** The whole index — an injected `updated` date + spec_id-sorted entries. */
81
+ export interface IndexModel {
82
+ /** Injected `updated` date, formatted YYYY-MM-DD. */
83
+ updated: string;
84
+ entries: IndexEntry[];
85
+ }
86
+
87
+ /** A parsed spec keyed by its on-disk directory id (the spec_id dir under `.mutagent/specs`). */
88
+ export interface LoadedSpec {
89
+ /** The on-disk directory name (canonically the spec_id). Drives the spec link path. */
90
+ id: string;
91
+ /** The parsed agentspec.yaml (unknown — defensively narrowed here). */
92
+ spec: unknown;
93
+ }
94
+
95
+ export interface BuildIndexInput {
96
+ specs: LoadedSpec[];
97
+ /** The parsed `.mutagent/config.yaml` (unknown — the code_refs + context source). */
98
+ config: unknown;
99
+ /** INJECTED ISO8601 timestamp — the `updated` stamp is `nowIso.slice(0,10)`. */
100
+ nowIso: string;
101
+ }
102
+
103
+ // ── Defensive narrowing helpers (no cross-package schema import — standalone rule) ──
104
+
105
+ function asRecord(v: unknown): Record<string, unknown> | null {
106
+ return typeof v === "object" && v !== null && !Array.isArray(v)
107
+ ? (v as Record<string, unknown>)
108
+ : null;
109
+ }
110
+
111
+ function asString(v: unknown): string | null {
112
+ return typeof v === "string" && v.length > 0 ? v : null;
113
+ }
114
+
115
+ function asArray(v: unknown): unknown[] {
116
+ return Array.isArray(v) ? v : [];
117
+ }
118
+
119
+ // ── Config extraction (code_refs + context — the realized-impl + doc links) ─────
120
+
121
+ /**
122
+ * Pull every target's `code_refs` from `global.targets[]`, flatten, dedupe by path
123
+ * (first `why` wins), and sort by path. These are the realized implementation links
124
+ * shared across the install (per PR-013 the spec never enumerates its own impls, so the
125
+ * config's targets are the impl-link source of truth).
126
+ */
127
+ export function extractCodeRefs(config: unknown): IndexCodeLink[] {
128
+ const global = asRecord(asRecord(config)?.global);
129
+ const targets = asArray(global?.targets);
130
+ const byPath = new Map<string, IndexCodeLink>();
131
+ for (const t of targets) {
132
+ const refs = asArray(asRecord(t)?.code_refs);
133
+ for (const r of refs) {
134
+ const rec = asRecord(r);
135
+ const p = asString(rec?.path);
136
+ if (!p) continue;
137
+ if (!byPath.has(p)) {
138
+ byPath.set(p, { path: p, why: asString(rec?.why) ?? "" });
139
+ }
140
+ }
141
+ }
142
+ return [...byPath.values()].sort((a, b) => a.path.localeCompare(b.path));
143
+ }
144
+
145
+ /** Pull `global.context[]` context links, sorted by path. */
146
+ export function extractContextLinks(config: unknown): IndexContextLink[] {
147
+ const global = asRecord(asRecord(config)?.global);
148
+ const context = asArray(global?.context);
149
+ const links: IndexContextLink[] = [];
150
+ for (const c of context) {
151
+ const rec = asRecord(c);
152
+ const p = asString(rec?.path);
153
+ if (!p) continue;
154
+ links.push({
155
+ path: p,
156
+ what: asString(rec?.what) ?? "",
157
+ why: asString(rec?.why) ?? "",
158
+ when: asString(rec?.when) ?? "",
159
+ });
160
+ }
161
+ return links.sort((a, b) => a.path.localeCompare(b.path));
162
+ }
163
+
164
+ // ── Spec extraction ────────────────────────────────────────────────────────────
165
+
166
+ /**
167
+ * Narrow one parsed agentspec into an IndexEntry. Reads HIGH-LEVEL fields only —
168
+ * meta identity + loop_state + build — plus the shared config-sourced code/context links.
169
+ * Tolerant of missing fields (fall back to the dir id / sensible placeholders) so a
170
+ * partially-written spec still lands a row rather than crashing the whole regen.
171
+ */
172
+ export function buildEntry(
173
+ loaded: LoadedSpec,
174
+ codeRefs: IndexCodeLink[],
175
+ contextLinks: IndexContextLink[],
176
+ ): IndexEntry {
177
+ const spec = asRecord(loaded.spec);
178
+ const meta = asRecord(spec?.meta);
179
+ const loopState = asRecord(meta?.loop_state);
180
+ const definition = asRecord(spec?.definition);
181
+ const identity = asRecord(definition?.identity);
182
+ const build = asRecord(spec?.build);
183
+
184
+ const specId = asString(meta?.spec_id) ?? loaded.id;
185
+ const targetFramework = asString(build?.target_framework);
186
+
187
+ return {
188
+ name: asString(identity?.name) ?? specId,
189
+ specId,
190
+ specVersion: asString(meta?.spec_version) ?? "unknown",
191
+ stage: asString(loopState?.stage) ?? "unknown",
192
+ lastVerdict: asString(loopState?.last_verdict),
193
+ // Link path uses the on-disk dir id (disk truth), not the parsed spec_id.
194
+ specPath: `${STAGE_DIRS.specs}/${loaded.id}/agentspec.yaml`,
195
+ build: targetFramework
196
+ ? { targetFramework, runtime: asString(build?.runtime) ?? "—" }
197
+ : null,
198
+ codeRefs,
199
+ contextLinks,
200
+ };
201
+ }
202
+
203
+ /**
204
+ * Build the whole index model from parsed specs + config + an injected clock. PURE:
205
+ * no I/O, no `Date.now()`. Entries are sorted by spec_id for deterministic output.
206
+ */
207
+ export function buildIndexModel(input: BuildIndexInput): IndexModel {
208
+ const codeRefs = extractCodeRefs(input.config);
209
+ const contextLinks = extractContextLinks(input.config);
210
+ const entries = input.specs
211
+ .map((s) => buildEntry(s, codeRefs, contextLinks))
212
+ .sort((a, b) => a.specId.localeCompare(b.specId));
213
+ return { updated: input.nowIso.slice(0, 10), entries };
214
+ }
215
+
216
+ // ── Injected I/O seam (byte-stable tests with no disk) ──────────────────────────
217
+
218
+ /**
219
+ * The file-system seam `regenerateIndex` depends on. The live binding uses `node:fs`;
220
+ * tests inject an in-memory fake so a full regenerate round-trips WITHOUT touching disk.
221
+ */
222
+ export interface IndexIo {
223
+ /** List the spec directories directly under `<root>/.mutagent/specs` (dir names only). */
224
+ listSpecDirs(specsRoot: string): string[];
225
+ /** Read `<specsRoot>/<specId>/agentspec.yaml`, or null when absent. */
226
+ readSpec(specsRoot: string, specId: string): string | null;
227
+ /** Read `<root>/.mutagent/config.yaml`, or null when absent. */
228
+ readConfig(configFile: string): string | null;
229
+ /** Write the regenerated `<root>/.mutagent/index.md`. */
230
+ writeIndex(indexFile: string, content: string): void;
231
+ }
232
+
233
+ /** Live IndexIo — binds real `node:fs`. */
234
+ export const liveIo: IndexIo = {
235
+ listSpecDirs(specsRoot: string): string[] {
236
+ let names: string[];
237
+ try {
238
+ names = fs.readdirSync(specsRoot);
239
+ } catch {
240
+ return [];
241
+ }
242
+ return names.filter((n) => {
243
+ try {
244
+ return fs.statSync(path.join(specsRoot, n)).isDirectory();
245
+ } catch {
246
+ return false;
247
+ }
248
+ });
249
+ },
250
+ readSpec(specsRoot: string, specId: string): string | null {
251
+ const p = path.join(specsRoot, specId, "agentspec.yaml");
252
+ try {
253
+ return fs.readFileSync(p, "utf8");
254
+ } catch {
255
+ return null;
256
+ }
257
+ },
258
+ readConfig(configFile: string): string | null {
259
+ try {
260
+ return fs.readFileSync(configFile, "utf8");
261
+ } catch {
262
+ return null;
263
+ }
264
+ },
265
+ writeIndex(indexFile: string, content: string): void {
266
+ fs.mkdirSync(path.dirname(indexFile), { recursive: true });
267
+ fs.writeFileSync(indexFile, content, "utf8");
268
+ },
269
+ };
270
+
271
+ export interface RegenerateResult {
272
+ /** Absolute path to the written `.mutagent/index.md`. */
273
+ indexFile: string;
274
+ /** The exact bytes written (returned for round-trip assertions). */
275
+ content: string;
276
+ }
277
+
278
+ /**
279
+ * Regenerate `<root>/.mutagent/index.md` from every `agentspec.yaml` under
280
+ * `<root>/.mutagent/specs/*` + the install config. DETERMINISTIC given (disk state, nowIso):
281
+ * re-running with the same inputs writes byte-identical output. The clock is INJECTED; the
282
+ * fs is INJECTED (defaults to `liveIo`). A spec whose YAML fails to parse is SKIPPED (its
283
+ * row is dropped rather than crashing the whole regen — fail-soft per-entry).
284
+ */
285
+ export function regenerateIndex(
286
+ root: string,
287
+ nowIso: string,
288
+ io: IndexIo = liveIo,
289
+ ): RegenerateResult {
290
+ const specsRoot = stageDir(root, STAGE_DIRS.specs);
291
+ const configFile = path.join(mutagentDir(root), "config.yaml");
292
+ const indexFile = path.join(mutagentDir(root), "index.md");
293
+
294
+ const specs: LoadedSpec[] = [];
295
+ for (const id of io.listSpecDirs(specsRoot)) {
296
+ const raw = io.readSpec(specsRoot, id);
297
+ if (raw === null) continue;
298
+ let parsed: unknown;
299
+ try {
300
+ parsed = parseYaml(raw);
301
+ } catch {
302
+ continue; // fail-soft: a malformed spec drops its row, never the whole index.
303
+ }
304
+ specs.push({ id, spec: parsed });
305
+ }
306
+
307
+ const configRaw = io.readConfig(configFile);
308
+ let config: unknown = null;
309
+ if (configRaw !== null) {
310
+ try {
311
+ config = parseYaml(configRaw);
312
+ } catch {
313
+ config = null; // no config links rather than a crash.
314
+ }
315
+ }
316
+
317
+ const model = buildIndexModel({ specs, config, nowIso });
318
+ const content = renderIndex(model);
319
+ io.writeIndex(indexFile, content);
320
+ return { indexFile, content };
321
+ }
322
+
323
+ // ── CLI — regenerate the index for the resolved (or supplied) install root ──────
324
+ //
325
+ // bun run scripts/index/build-index.ts [root] [--now <ISO8601>]
326
+ //
327
+ // `root` defaults to the resolved `.mutagent/` install root. `--now` overrides the
328
+ // clock (deterministic scripting / reproducing a stamp); default is the wall clock.
329
+
330
+ function runCli(argv: string[]): number {
331
+ const args = argv.slice(2);
332
+ const nowFlagIdx = args.indexOf("--now");
333
+ const nowIso =
334
+ nowFlagIdx >= 0 && args[nowFlagIdx + 1]
335
+ ? (args[nowFlagIdx + 1] as string)
336
+ : new Date().toISOString();
337
+ const positional = args.find((a, i) => !a.startsWith("--") && i !== nowFlagIdx + 1);
338
+ const root = positional ? path.resolve(positional) : resolveConfigRoot();
339
+
340
+ const { indexFile } = regenerateIndex(root, nowIso);
341
+ console.info(`[build-index] wrote ${indexFile} (root: ${path.join(root, MUTAGENT_DIR)})`);
342
+ return 0;
343
+ }
344
+
345
+ const isMain =
346
+ typeof import.meta !== "undefined" &&
347
+ (import.meta as unknown as { main?: boolean }).main === true;
348
+ if (isMain) {
349
+ const argv = typeof Bun !== "undefined" ? Bun.argv : process.argv;
350
+ process.exit(runCli(argv));
351
+ }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * scripts/index/render-index.ts
3
+ * F4 — the `.mutagent/index.md` REGISTRY renderer (pure model → markdown).
4
+ * Type A — Pure Script (no I/O, no clock — the model already carries the injected date).
5
+ *
6
+ * The rendered markdown IS the machine surface (no sidecar JSON): section headers +
7
+ * markdown links are what downstream reads. HIGH-LEVEL ONLY — identity · stage · verdict ·
8
+ * build target + LINKS. NEVER eval criteria / scenarios (anti-drift; see build-index.ts).
9
+ *
10
+ * DETERMINISM: a pure function of the model. Same model in → byte-identical string out.
11
+ * Output ends with exactly one trailing newline (POSIX-friendly, stable across regens).
12
+ */
13
+
14
+ import type {
15
+ IndexCodeLink,
16
+ IndexContextLink,
17
+ IndexEntry,
18
+ IndexModel,
19
+ } from "./build-index.ts";
20
+
21
+ const TITLE = "# MutagenT — Agent Index";
22
+ const BLURB_1 =
23
+ "> Spec ↔ implementation registry. Regenerated at each ADL stage — do not hand-edit.";
24
+ const BLURB_2 =
25
+ "> HIGH-LEVEL links only (anti-drift): identity · stage · verdict · version/date + links. No eval criteria/scenarios.";
26
+ const EMPTY_NOTE = "_No agent specs registered yet._";
27
+
28
+ /** The em-dash placeholder for an absent value (verdict / runtime). */
29
+ const NONE = "—";
30
+
31
+ /**
32
+ * Link out to a PROJECT-ROOT-relative path from the index, which lives at
33
+ * `<root>/.mutagent/index.md`. Config paths are project-root-relative (determinism rule),
34
+ * so hop out of `.mutagent/` with a `../` prefix. Absolute paths (unusual) pass through.
35
+ */
36
+ function projectRootHref(p: string): string {
37
+ if (p.startsWith("/")) return p;
38
+ return `../${p.replace(/^\.\//, "")}`;
39
+ }
40
+
41
+ /** `[label](href)` — label defaults to the raw path (its most recognizable form). */
42
+ function mdLink(hrefPath: string, label: string, projectRoot: boolean): string {
43
+ const href = projectRoot ? projectRootHref(hrefPath) : hrefPath;
44
+ return `[${label}](${href})`;
45
+ }
46
+
47
+ function renderCodeRefs(refs: IndexCodeLink[]): string[] {
48
+ if (refs.length === 0) return [];
49
+ const lines = ["- **Agent code / tooling / harness / runtime:**"];
50
+ for (const r of refs) {
51
+ const suffix = r.why ? ` — ${r.why}` : "";
52
+ lines.push(` - ${mdLink(r.path, r.path, true)}${suffix}`);
53
+ }
54
+ return lines;
55
+ }
56
+
57
+ function renderContextLinks(links: IndexContextLink[]): string[] {
58
+ if (links.length === 0) return [];
59
+ const lines = ["- **Context / product docs:**"];
60
+ for (const c of links) {
61
+ const what = c.what ? ` — ${c.what}` : "";
62
+ const when = c.when ? ` _(when: ${c.when})_` : "";
63
+ lines.push(` - ${mdLink(c.path, c.path, true)}${what}${when}`);
64
+ }
65
+ return lines;
66
+ }
67
+
68
+ /**
69
+ * Render one agent's section. `updated` is the model's injected date (a single regen stamp
70
+ * for the whole file) — NOT the spec's own `loop_state.updated_at`, so the file is byte-stable
71
+ * under an injected clock (the F4 determinism contract).
72
+ */
73
+ export function renderEntry(entry: IndexEntry, updated: string): string[] {
74
+ const verdict = entry.lastVerdict ?? NONE;
75
+ const lines: string[] = [
76
+ `## ${entry.name} — \`spec_id: ${entry.specId}\` · spec v${entry.specVersion} · updated ${updated}`,
77
+ `- **Spec:** ${mdLink(entry.specPath, "agentspec.yaml", false)} · stage: ${entry.stage} · verdict: ${verdict}`,
78
+ ];
79
+ if (entry.build) {
80
+ lines.push(
81
+ `- **Build:** target ${entry.build.targetFramework} · runtime ${entry.build.runtime}`,
82
+ );
83
+ }
84
+ lines.push(...renderCodeRefs(entry.codeRefs));
85
+ lines.push(...renderContextLinks(entry.contextLinks));
86
+ return lines;
87
+ }
88
+
89
+ /**
90
+ * Render the whole index model to markdown. PURE: same model → byte-identical string.
91
+ * Layout: title · two-line anti-drift blurb · `updated <date> · N agent(s)` summary ·
92
+ * one `##` section per agent (sorted by spec_id upstream). Empty index → a friendly note.
93
+ */
94
+ export function renderIndex(model: IndexModel): string {
95
+ const count = model.entries.length;
96
+ const summary = `_updated ${model.updated} · ${count} ${count === 1 ? "agent" : "agents"}_`;
97
+
98
+ const blocks: string[] = [TITLE, "", BLURB_1, BLURB_2, "", summary, ""];
99
+
100
+ if (count === 0) {
101
+ blocks.push(EMPTY_NOTE);
102
+ } else {
103
+ for (const entry of model.entries) {
104
+ blocks.push(...renderEntry(entry, model.updated), "");
105
+ }
106
+ blocks.pop(); // drop the trailing spacer; the final newline is added below.
107
+ }
108
+
109
+ return blocks.join("\n") + "\n";
110
+ }
@@ -0,0 +1,111 @@
1
+ // ---------------------------------------------------------------------------
2
+ // monitor/slack-notify — the External Monitor's OWN Slack emitter (EXT-1).
3
+ //
4
+ // The OUTWARD monitor's voice: a discrete NOTIFICATION (one standalone message)
5
+ // each time a trigger fires — human-readable + precise (trigger · what fired ·
6
+ // routed stage). This is NOT a live thread (that is the dogfood monitor's voice,
7
+ // dogfood/slack-thread.ts); it is a one-shot event notification.
8
+ //
9
+ // PURE message builder: `monitorNotifyMessage(match, meta) → SlackMsg` is
10
+ // `input → message`, no I/O/clock/random — identical input ⇒ byte-identical text
11
+ // (deterministic tests). Posting goes through `../slack/post` (the ONE shared
12
+ // impure seam), config-gated: an unconfigured sink ⇒ a no-op that touches ZERO
13
+ // network (the guard lives in slack/post — a broken/absent Slack never errors).
14
+ //
15
+ // SEPARATION (load-bearing — ADR-6/ADR-11): this emitter imports ONLY `../slack/*`
16
+ // (shared transport + primitives) + its sibling `./triggers.ts` (the TriggerMatch
17
+ // type). It NEVER imports the dogfood monitor's emitter (`../dogfood/*`). Shared
18
+ // transport, separate semantics — a test asserts the import boundary.
19
+ // ---------------------------------------------------------------------------
20
+
21
+ import { bold, code, italic } from "../slack/format.ts";
22
+ import { postMessage } from "../slack/post.ts";
23
+ import type { PostDeps, PostResult, SlackMsg } from "../slack/post.ts";
24
+ import type { TriggerMatch } from "./triggers.ts";
25
+
26
+ /** Routing ADL-stage → a compact display label with its circled numeral (self-contained). */
27
+ const STAGE_DISPLAY: Readonly<Record<string, string>> = {
28
+ spec: "① SPEC",
29
+ build: "② BUILD",
30
+ evaluate: "③ EVALUATE",
31
+ diagnose: "④ DIAGNOSE",
32
+ improve: "⑤ IMPROVE",
33
+ audit: "③ EVALUATE (audit)",
34
+ };
35
+
36
+ /** Display a stage token; unknown tokens fall back to their upper-case form. */
37
+ function stageLabel(stage: string): string {
38
+ return STAGE_DISPLAY[stage] ?? stage.toUpperCase();
39
+ }
40
+
41
+ /** Metadata for a monitor notification (optional context on the fired trigger). */
42
+ export interface MonitorNotifyMeta {
43
+ /** Human project label (the monitored system), optional. */
44
+ project?: string;
45
+ }
46
+
47
+ /**
48
+ * Build the discrete notification for one fired trigger. PURE + deterministic —
49
+ * identical (match, meta) ⇒ identical `SlackMsg`. `kind:"root"` because each
50
+ * notification is a standalone top-level message (not a thread reply).
51
+ */
52
+ export function monitorNotifyMessage(match: TriggerMatch, meta: MonitorNotifyMeta = {}): SlackMsg {
53
+ const project = meta.project ? ` · project ${bold(meta.project)}` : "";
54
+ const runs = match.run ? ` · runs ${code(match.run)}` : "";
55
+ const text =
56
+ `🛰️ ${bold("External Monitor")} — trigger ${code(match.rule.on)} fired → routed ` +
57
+ `${bold(stageLabel(match.stage))}${project} · ${italic(match.reason)}${runs}`;
58
+ return { kind: "root", text };
59
+ }
60
+
61
+ /**
62
+ * The External Monitor's Slack sink config (mirrors `config.monitor.slack`). Kept
63
+ * as a LOCAL structural type — this emitter deliberately does NOT import
64
+ * `../config-schema.ts` (the separation boundary is `../slack/*` only). The agent
65
+ * passes `config.monitor?.slack` in.
66
+ */
67
+ export interface MonitorSlackConfig {
68
+ enabled?: boolean;
69
+ channel: string;
70
+ /** The ENV-VAR NAME holding the bot token (xoxb-…) — a reference, never a secret. */
71
+ token_ref: string;
72
+ }
73
+
74
+ /** A resolved Slack sink — a concrete channel + bot token ready to post with. */
75
+ export interface MonitorSink {
76
+ channel: string;
77
+ token: string;
78
+ }
79
+
80
+ /**
81
+ * Resolve `config.monitor.slack` to a concrete sink, or null when Slack is not
82
+ * configured. Active ONLY when `enabled:true` AND the `token_ref` env var is set
83
+ * (same discipline as the dogfood sink / credentials_ref: `token_ref` is an
84
+ * env-var NAME, never a raw secret). `env` is INJECTED so tests stay deterministic
85
+ * (defaults to `process.env`).
86
+ */
87
+ export function resolveMonitorSink(
88
+ slack: MonitorSlackConfig | undefined,
89
+ env: Record<string, string | undefined> = process.env,
90
+ ): MonitorSink | null {
91
+ if (slack === undefined || slack.enabled !== true) return null;
92
+ const token = env[slack.token_ref];
93
+ if (token === undefined || token.length === 0) return null;
94
+ return { channel: slack.channel, token };
95
+ }
96
+
97
+ /**
98
+ * Post a monitor notification via the shared transport. CONFIG-GATED NO-OP: with a
99
+ * null sink (Slack unconfigured/disabled) the underlying `postMessage` receives an
100
+ * empty channel/undefined token and no-ops — returns null, ZERO network. `deps`
101
+ * injects `fetch` for tests (mirrors slack/post).
102
+ */
103
+ export async function postMonitorNotification(
104
+ match: TriggerMatch,
105
+ meta: MonitorNotifyMeta,
106
+ sink: MonitorSink | null,
107
+ deps: PostDeps = {},
108
+ ): Promise<PostResult | null> {
109
+ const msg = monitorNotifyMessage(match, meta);
110
+ return postMessage({ channel: sink?.channel ?? "", text: msg.text, token: sink?.token }, deps);
111
+ }