@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.
- package/.claude/skills/mutagent-helix/SKILL.md +113 -0
- package/.claude/skills/mutagent-helix/scripts/cli/codex-transcode.ts +143 -0
- package/.claude/skills/mutagent-helix/scripts/cli/doctor.ts +111 -0
- package/.claude/skills/mutagent-helix/scripts/cli/init.ts +382 -0
- package/.claude/skills/mutagent-helix/scripts/cli/run.sh +61 -0
- package/CLAUDE.md +193 -0
- package/LICENSE +201 -0
- package/NOTICE +22 -0
- package/README.md +209 -0
- package/assets/adl-loop.svg +162 -0
- package/assets/system-status.svg +422 -0
- package/bin/mutagent-cli.mjs +9950 -0
- package/bin/mutagent-helix.mjs +78 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/CLAUDE.md +28 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/SKILL.md +138 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/assets/templates/agentspec.yaml.tpl +247 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/references/frameworks/doc-pins.md +53 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/references/principles.md +91 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/references/requirements.yaml +295 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/references/workflows/orchestrator-protocol.md +302 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/cli/doctor.ts +116 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/cli/init.ts +230 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/cli/run.sh +60 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/config/resolve-spec-dir.ts +199 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/contract/agentspec.schema.ts +455 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/setup/detect.ts +67 -0
- package/mutagent-agentspec/.claude/skills/mutagent-agentspec/scripts/validate/validate-spec.ts +93 -0
- package/mutagent-agentspec/LICENSE +201 -0
- package/mutagent-agentspec/NOTICE +19 -0
- package/mutagent-agentspec/README.md +44 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/SKILL.md +100 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/assets/agents/ai-architect.md +312 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/assets/agents/ai-engineer.md +357 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/assets/templates/build-report.md.tpl +39 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/references/principles.md +31 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/references/workflows/build-protocol.md +61 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/references/workflows/improve-handoff.md +23 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/scripts/cli/run.sh +60 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/scripts/handoff/validate-build-input.ts +72 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/scripts/sync-spec/check-sync-spec.ts +499 -0
- package/mutagent-builder/.claude/skills/mutagent-builder/scripts/verify/spec-impl-coverage.ts +182 -0
- package/mutagent-builder/CLAUDE.md +25 -0
- package/mutagent-builder/README.md +26 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/README.md +192 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/SKILL.md +352 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/agents/ai-architect.md +256 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/agents/ai-engineer.md +344 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/agents/diagnostics-analyzer.md +576 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/agents/discovery.md +425 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/audit.json.tpl +24 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/audit.md.tpl +49 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/config.yaml.tpl +100 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/pr-body.md.tpl +56 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/report.html.tpl +327 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/README.md +27 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/iter-N-handover.md.tpl +125 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/self-diagnosis-contract.v0.1.0.yaml.tpl +234 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/spec.yaml.tpl +152 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/team.yaml.tpl +127 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/templates/shared/wave-N-dashboard.html.tpl +1712 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.1-nl-query.md +59 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.2-tier0-progress.md +58 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.3-analysis-progress.md +44 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.4-html-report.md +61 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.5-rca-detail.md +69 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/diagnostics/WF-2.6-stale-warning.md +53 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.1-welcome.md +60 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.2-source-platform-picker.md +41 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.3-source-auth.md +75 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.4-target-picker.md +48 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.5-ask-tool.md +43 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.6-config-review.md +57 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.7-filter-defaults.md +52 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/assets/wireframes/onboarding/WF-1.8-first-run.md +59 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/examples/sample-findings.json +92 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/examples/sample-meta.json +47 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/adapter-strategy.md +75 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/config-migration.md +84 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/config.md +159 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/filter-search-matrix.md +66 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/harness-knowledge.md +22 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/memory-format.md +78 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/onboarding-decisions.yaml +187 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/operation-inventory.md +59 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/overview.md +167 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/reference.md +119 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/script-index.md +101 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-adapter-contract.md +93 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/claude-code-transcripts.md +66 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/codex-transcripts.md +78 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/codex.md +145 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/install-paths.md +57 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/langfuse.md +178 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/local-jsonl.md +55 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/openobserve.md +102 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/source-platforms/otel.md +63 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/cloud-rest.md +84 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-claude.md +65 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-cloud-agent-sdk.md +92 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-codex.md +72 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-cursor.md +108 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-mastra.md +77 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/target-platforms/local-opencode.md +70 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/apply-pr-comment-format.md +82 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/diagnostics.md +35 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/handover-contract.md +247 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/onboarding.md +300 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/orchestrator-protocol.md +1861 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/rca.md +331 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/rendering-anatomy.md +314 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/schedule-prep.md +100 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/scope-model.md +128 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/references/workflows/verification-methodology.md +174 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/aggregate/sort-findings.ts +0 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/awareness/blind-spots.ts +167 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/awareness/llm-sample.ts +681 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/doctor.ts +215 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/init.ts +1013 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/install-agents.ts +350 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/run.sh +61 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/cli/shared-templates.ts +79 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/config/load.ts +392 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/config/resolve-credential.ts +120 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/config/schema.ts +641 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/config/validate.ts +134 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/context/build-diagnosis-context.ts +417 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/context/load-context.ts +105 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/contract/types.ts +166 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/enrich/build-render-input.ts +1964 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/enrich/corpus-severity.ts +172 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/enrich/dismissal-match.ts +270 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/enrich/rank-remedies.ts +75 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/hooks/install-hooks.sh +46 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/hooks/pre-push.sh +78 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/invocation/parse-brief.ts +188 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/library/match.ts +114 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/library/paths.ts +95 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/library/store.ts +535 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/library/types.ts +181 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/lint/template-inline-js.ts +267 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/memory/append.ts +188 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/memory/read.ts +218 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/platforms/entity-context.ts +686 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/read-unitf.ts +267 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/trace.ts +1078 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/unitf-adapter.ts +0 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/normalize/unitf-types.ts +213 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/report/persist-selections.ts +174 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/report/render.ts +3254 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/run/diagnose.ts +64 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/run/session.ts +167 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/sample/caps.ts +345 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/sample/deep-read-gate.ts +424 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/sample/representative.ts +584 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/scan/objection.ts +224 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/scan/trajectory.ts +489 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/self-diagnostics/dispatch.ts +135 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/self-diagnostics/probe.ts +170 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/setup/detect.ts +307 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/setup/ensure-cli.ts +315 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/setup/reconfigure.ts +77 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/setup/verify-agents.ts +207 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/slicer.ts +166 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/claude-code.ts +17 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/codex.ts +11 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/langfuse.ts +17 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/local-jsonl.ts +12 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/adapters/otel.ts +12 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/index.ts +54 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/registry.ts +45 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/source/types.ts +86 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/stale-detector.ts +74 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/test/render-playwright.cli.ts +477 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/tier0/claude-code.ts +133 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/tier0/langfuse.ts +143 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/tier0-scan.ts +423 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/completeness-check.ts +436 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/doc-refs.ts +190 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/finalize-gate.ts +417 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/findings-contract.ts +628 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/render-js-syntax.ts +188 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/report-checklist.yaml +217 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/trace-shape.ts +262 -0
- package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/validate/wave6-checklist.ts +326 -0
- package/mutagent-diagnostics/CLAUDE.md +41 -0
- package/mutagent-diagnostics/LICENSE +201 -0
- package/mutagent-diagnostics/NOTICE +18 -0
- package/mutagent-diagnostics/README.md +343 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/SKILL.md +548 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/agents/audit-executor.md +169 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/agents/dataset-builder.md +160 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/agents/discovery.md +425 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/agents/evaluator.md +1108 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/brand/theme.css +213 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/assets/brand/wordmark.html +9 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/context-flow-lens.md +85 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/data-lens.md +47 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/decision-lens.md +48 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/methodology-critic-lens.md +53 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/lenses/trajectory-lens.md +44 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/build-review-interface.md +83 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/edd-loop.md +134 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/error-analysis.md +113 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/eval-audit.md +154 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/eval-stage.md +168 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/generate-synthetic-data.md +81 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/grounded-adjudication.md +221 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/memory-format.md +65 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/methodology.md +201 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/operation-inventory.md +197 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/validate-evaluator.md +125 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/workflows/orchestrator-protocol.md +300 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/references/write-judge-prompt.md +123 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/behavior-tree.schema.yaml +73 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/dataset.schema.yaml +66 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/edd-change-request.schema.yaml +114 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/eval-matrix.schema.yaml +74 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/flow-graph.schema.yaml +69 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/flow-profile.schema.yaml +49 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/methodology-review.schema.yaml +40 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/schemas/scorecard.schema.yaml +85 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/agent-dispatch.ts +0 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/aggregate-discover.ts +543 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/artifact-paths.ts +115 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/assemble-scorecard.ts +172 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/build-dataset.ts +186 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/build-evals.ts +93 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/build-review-ui.ts +393 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/check-method-router.ts +170 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/aggregate.ts +112 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/audit-run.ts +182 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/doctor.ts +211 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/dogfood.ts +133 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/init.ts +601 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/methodology-review.ts +122 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/prep.ts +295 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/profile-subject.ts +165 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/run.sh +56 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cli/variance-check.ts +105 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/code-eval.ts +248 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/code-quality-verdict.ts +285 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/codegen-evals.ts +173 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cold-start-project.ts +151 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/cold-start-sampler.ts +267 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/config/load.ts +343 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/config/schema.ts +380 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/agentspec-evals.ts +85 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/dataset.ts +149 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/eval-engine.ts +118 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/eval-matrix.ts +577 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/eval-types.ts +1074 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/flow-graph.ts +194 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/types.ts +303 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/contracts/validation.ts +193 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/derive-dataset.ts +152 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/determine-outcome.ts +219 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/diff-discriminate.ts +160 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/discover-criteria.ts +348 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/edd/change-request.ts +232 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/edd/edd-types.ts +210 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/edd/variance-gate.ts +186 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/emit-completeness.ts +111 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/eval-engine.ts +160 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/evaluate.ts +333 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/flow-graph.ts +230 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/judge-prompt-template.ts +253 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/judge-provider.ts +135 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/lint-grounding.ts +229 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/lint-uniformity.ts +168 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/living-suite.ts +109 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/load-bundle.ts +203 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/load-profile-vocab.ts +64 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/load-profile.ts +106 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/mask.ts +138 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/materialize-dataset.ts +113 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/matrix-judge.ts +750 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/memory/append.ts +215 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/memory/read.ts +168 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/persist-eval-criteria.ts +232 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/prep-tasks.ts +125 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/profile-subject.ts +310 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/publish-report.ts +131 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/read-unitf-traces.ts +81 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/render-build-cards.ts +195 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/render-discover-report.ts +1640 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/render-eval-report.ts +3838 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/render-report.ts +212 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/resolve-credential.ts +110 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/resolve-ref.ts +98 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/result-verify.ts +129 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/route-failures.ts +330 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/run-deterministic.ts +367 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/run-evaluate.ts +719 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/run-judge.ts +155 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/run-pipeline.ts +175 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/sample-traces.ts +210 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/self-audit.ts +387 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/source-map.ts +106 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/subject-profile.ts +134 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/substrate.ts +162 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/sync-eval-criteria.ts +244 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/ui-slots.ts +119 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/unitf-to-evaltrace.ts +284 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/validate-judge.ts +358 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/scripts/variance-compare.ts +177 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/subjects/mutagent-diagnostics/behavior-tree.yaml +140 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/subjects/mutagent-diagnostics/eval-matrix.yaml +1270 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/subjects/mutagent-diagnostics/methodology-review.yaml +105 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/workflows/audit.workflow.js +82 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/workflows/data-leak.workflow.js +236 -0
- package/mutagent-evaluator/.claude/skills/mutagent-evaluator/workflows/variance.workflow.js +163 -0
- package/mutagent-evaluator/CLAUDE.md +45 -0
- package/mutagent-evaluator/LICENSE +201 -0
- package/mutagent-evaluator/NOTICE +23 -0
- package/mutagent-evaluator/README.md +88 -0
- package/mutagent-optimize/.claude/skills/mutagent-optimize/SKILL.md +287 -0
- package/mutagent-optimize/.claude/skills/mutagent-optimize/scripts/contracts/amend-request.ts +503 -0
- package/mutagent-optimize/.claude/skills/mutagent-optimize/scripts/improve-loop-run.ts +304 -0
- package/mutagent-optimize/.claude/skills/mutagent-optimize/scripts/loop-state-cli.ts +300 -0
- package/mutagent-optimize/.claude/skills/mutagent-optimize/scripts/loop-state.ts +440 -0
- package/mutagent-optimize/CLAUDE.md +49 -0
- package/mutagent-optimize/README.md +26 -0
- package/mutagent-orchestrator/CLAUDE.md +102 -0
- package/mutagent-orchestrator/README.md +20 -0
- package/mutagent-orchestrator/assets/agents/discovery.md +425 -0
- package/mutagent-orchestrator/assets/agents/dogfood-monitor.md +266 -0
- package/mutagent-orchestrator/assets/agents/monitor.md +258 -0
- package/mutagent-orchestrator/orchestrator.md +782 -0
- package/mutagent-orchestrator/references/MONITORING.md +209 -0
- package/mutagent-orchestrator/references/config-fields.md +132 -0
- package/mutagent-orchestrator/references/config-migration.md +132 -0
- package/mutagent-orchestrator/references/index-registry.md +92 -0
- package/mutagent-orchestrator/routing.yaml +391 -0
- package/mutagent-orchestrator/scripts/config-schema.ts +1010 -0
- package/mutagent-orchestrator/scripts/dispatch.ts +439 -0
- package/mutagent-orchestrator/scripts/dogfood/extract-feedback.ts +203 -0
- package/mutagent-orchestrator/scripts/dogfood/reconstruct-trajectory.ts +327 -0
- package/mutagent-orchestrator/scripts/dogfood/render-dogfood-report.ts +347 -0
- package/mutagent-orchestrator/scripts/dogfood/resolve-subagents.ts +160 -0
- package/mutagent-orchestrator/scripts/dogfood/run-report.ts +264 -0
- package/mutagent-orchestrator/scripts/dogfood/slack-thread.ts +106 -0
- package/mutagent-orchestrator/scripts/dogfood/types.ts +257 -0
- package/mutagent-orchestrator/scripts/eval-routing.ts +753 -0
- package/mutagent-orchestrator/scripts/gate.ts +219 -0
- package/mutagent-orchestrator/scripts/handover-contract.ts +362 -0
- package/mutagent-orchestrator/scripts/index/build-index.ts +351 -0
- package/mutagent-orchestrator/scripts/index/render-index.ts +110 -0
- package/mutagent-orchestrator/scripts/monitor/slack-notify.ts +111 -0
- package/mutagent-orchestrator/scripts/monitor/triggers.ts +162 -0
- package/mutagent-orchestrator/scripts/onboarding-check.ts +369 -0
- package/mutagent-orchestrator/scripts/render-roster.ts +308 -0
- package/mutagent-orchestrator/scripts/resolve-credential.ts +185 -0
- package/mutagent-orchestrator/scripts/resolve-paths.ts +114 -0
- package/mutagent-orchestrator/scripts/slack/format.ts +63 -0
- package/mutagent-orchestrator/scripts/slack/post.ts +115 -0
- package/mutagent-orchestrator/scripts/sync-index.ts +311 -0
- package/package.json +64 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* scripts/library/types.ts
|
|
3
|
+
* R2.3 (+D2) — class-memory library record types.
|
|
4
|
+
* Type A — Pure Script (type + schema definitions only).
|
|
5
|
+
*
|
|
6
|
+
* entity.json is the machine record per diagnosed entity. journal.md is the
|
|
7
|
+
* append-only human log. patterns/<id>.json are regex detectors promoted from
|
|
8
|
+
* operator-APPROVED findings (the only write trigger).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { Type } from "@sinclair/typebox";
|
|
12
|
+
import type { Static } from "@sinclair/typebox";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* D2: a single run record stored in the library. operatorInvocation is the
|
|
16
|
+
* VERBATIM brief preserved even when parsing succeeded (re-parse later + library
|
|
17
|
+
* authenticity, plan §5 D2).
|
|
18
|
+
*/
|
|
19
|
+
export const LibraryRunRecordSchema = Type.Object({
|
|
20
|
+
runId: Type.String(),
|
|
21
|
+
diagnosedAt: Type.String(),
|
|
22
|
+
/** D2 — verbatim operator brief that initiated this run (may be empty). */
|
|
23
|
+
operatorInvocation: Type.Optional(Type.String()),
|
|
24
|
+
/** How many approved findings this run contributed to the library. */
|
|
25
|
+
approvedFindingCount: Type.Number(),
|
|
26
|
+
});
|
|
27
|
+
export type LibraryRunRecord = Static<typeof LibraryRunRecordSchema>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A regex pattern detector promoted from an approved finding. Plain regex (no LLM)
|
|
31
|
+
* so Tier-0 can match it deterministically + cheaply.
|
|
32
|
+
*/
|
|
33
|
+
export const LibraryPatternSchema = Type.Object({
|
|
34
|
+
patternId: Type.String(),
|
|
35
|
+
/** Signal/failure-mode this pattern detects (e.g. "loop", "hallucination"). */
|
|
36
|
+
signal: Type.String(),
|
|
37
|
+
/** Plain regex source string (matched against trace text/tags in Tier-0). */
|
|
38
|
+
regex: Type.String(),
|
|
39
|
+
/** Regex flags (e.g. "i"). */
|
|
40
|
+
flags: Type.Optional(Type.String()),
|
|
41
|
+
/** The finding id this pattern was promoted from (provenance). */
|
|
42
|
+
sourceFindingId: Type.String(),
|
|
43
|
+
/** ISO8601 when it was approved into the library. */
|
|
44
|
+
approvedAt: Type.String(),
|
|
45
|
+
});
|
|
46
|
+
export type LibraryPattern = Static<typeof LibraryPatternSchema>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* BLOCK G (deep-read LEDGER) — one cross-run record per (entity, trace) the deep-read
|
|
50
|
+
* analyzer has already digested. The ledger lets the next run SKIP re-reading a trace
|
|
51
|
+
* whose digest is still VALID, while remaining honest about staleness: an entry is
|
|
52
|
+
* INVALIDATED (and excluded from a fold) when the analyzer version changed, the entity
|
|
53
|
+
* fingerprint changed, or the entry aged past its TTL. Blocks B (deep-read planning)
|
|
54
|
+
* and C (promotion) consume this — but the ledger itself NEVER decides promotion: it
|
|
55
|
+
* carries version-stamped digests + validity only (R2 boundary; Block C re-applies the
|
|
56
|
+
* evidence floor to folded digests).
|
|
57
|
+
*/
|
|
58
|
+
export const DeepReadLedgerEntrySchema = Type.Object({
|
|
59
|
+
/** Trace this digest was produced from (the dedupe key within an entity ledger). */
|
|
60
|
+
traceId: Type.String(),
|
|
61
|
+
/** Failure-mode / signal the deep-read attributed to this trace (e.g. "loop"). */
|
|
62
|
+
signal: Type.String(),
|
|
63
|
+
/** Short deterministic digest of what happened — NO client identity, synthetic-safe. */
|
|
64
|
+
whatHappenedDigest: Type.String(),
|
|
65
|
+
/** Pointer back to the evidence the digest was derived from (e.g. journal/report ref). */
|
|
66
|
+
evidenceRef: Type.String(),
|
|
67
|
+
/** Analyzer version that produced the digest — bump invalidates prior entries. */
|
|
68
|
+
analyzerVersion: Type.String(),
|
|
69
|
+
/** Entity fingerprint at digest time — a change (e.g. prompt edit) invalidates priors. */
|
|
70
|
+
entityFingerprint: Type.String(),
|
|
71
|
+
/** INJECTED ISO8601 timestamp the entry was recorded (drives TTL invalidation). */
|
|
72
|
+
ts: Type.String(),
|
|
73
|
+
});
|
|
74
|
+
export type DeepReadLedgerEntry = Static<typeof DeepReadLedgerEntrySchema>;
|
|
75
|
+
|
|
76
|
+
export const LibraryEntitySchema = Type.Object({
|
|
77
|
+
name: Type.String(),
|
|
78
|
+
entityType: Type.Union([
|
|
79
|
+
Type.Literal("agent"),
|
|
80
|
+
Type.Literal("tool"),
|
|
81
|
+
Type.Literal("skill"),
|
|
82
|
+
Type.Literal("model"),
|
|
83
|
+
]),
|
|
84
|
+
slug: Type.String(),
|
|
85
|
+
/** D2 — append-only run history (latest last). */
|
|
86
|
+
runs: Type.Array(LibraryRunRecordSchema),
|
|
87
|
+
/** Promoted regex detectors (matched FIRST in Tier-0). */
|
|
88
|
+
patterns: Type.Array(LibraryPatternSchema),
|
|
89
|
+
/**
|
|
90
|
+
* BLOCK G — cross-run deep-read ledger (append-only, deduped by traceId). Persisted
|
|
91
|
+
* in its OWN file (deep-read-ledger.json) so the approved-only entity.json write gate
|
|
92
|
+
* stays clean; carried on the record type for typed composition by Blocks B/C.
|
|
93
|
+
*/
|
|
94
|
+
deepReadLedger: Type.Array(DeepReadLedgerEntrySchema),
|
|
95
|
+
createdAt: Type.String(),
|
|
96
|
+
updatedAt: Type.String(),
|
|
97
|
+
});
|
|
98
|
+
export type LibraryEntity = Static<typeof LibraryEntitySchema>;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* R2.3 — prior-signal weight multiplier. A signal backed by a library prior counts
|
|
102
|
+
* 3× in the R2.2 awareness/selection step (plan §4 R2.3).
|
|
103
|
+
*/
|
|
104
|
+
export const PRIOR_SIGNAL_WEIGHT = 3;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* BLOCK G — default ledger TTL: 30 days in milliseconds. A deep-read digest older than
|
|
108
|
+
* this is treated as stale and excluded from foldValidDigests(). Callers may override
|
|
109
|
+
* per-fold; this is the sane default so a year-old digest never silently re-admits.
|
|
110
|
+
*/
|
|
111
|
+
export const DEEP_READ_LEDGER_TTL_MS = 30 * 24 * 60 * 60 * 1000;
|
|
112
|
+
|
|
113
|
+
// ── UNIFIED VERDICT LEDGER (finding-verdict MEMORY — both polarities) ─────────
|
|
114
|
+
//
|
|
115
|
+
// The verdict ledger is the diagnostics finding-verdict MEMORY: "what I found (and
|
|
116
|
+
// the operator APPROVED) vs what the operator DISMISSED". It is the SYMMETRIC twin of
|
|
117
|
+
// the approve→pattern loop — ONE per-entity store recording BOTH polarities:
|
|
118
|
+
// - "approved" — the operator accepted the finding / its remedy (valid).
|
|
119
|
+
// - "dismissed" — the operator ruled the finding not-an-issue (invalid → suppress).
|
|
120
|
+
//
|
|
121
|
+
// It lives in its OWN file (verdict-ledger.json) alongside entity.json — the approve→
|
|
122
|
+
// pattern PROMOTE behaviour (entity.json + patterns/ + journal + INDEX) is byte-unchanged;
|
|
123
|
+
// the approve path ADDITIVELY mirrors an "approved" verdict here (see store.ts).
|
|
124
|
+
//
|
|
125
|
+
// NEVER-EXPIRE (operator decision): a dismissal has NO TTL. It stays suppressed
|
|
126
|
+
// indefinitely and un-hides ONLY on (a) severity-escalation (handled at the enrich
|
|
127
|
+
// partition — the finding's current severity materially exceeds severityAtDismissal)
|
|
128
|
+
// or (b) entity-fingerprint invalidation (the agent's prompt/config changed — reuse
|
|
129
|
+
// the foldValidDigests entityFingerprint mechanism, WITHOUT the TTL branch).
|
|
130
|
+
|
|
131
|
+
/** The two polarities a finding verdict can carry. */
|
|
132
|
+
export const VERDICT_POLARITIES = ["approved", "dismissed"] as const;
|
|
133
|
+
export type VerdictPolarity = (typeof VERDICT_POLARITIES)[number];
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Severity grade a finding carries (mirrors Finding.severity in normalize/trace.ts).
|
|
137
|
+
* Duplicated here so the library layer stays free of a render/normalize import.
|
|
138
|
+
*/
|
|
139
|
+
export const VerdictSeveritySchema = Type.Union([
|
|
140
|
+
Type.Literal("crit"),
|
|
141
|
+
Type.Literal("high"),
|
|
142
|
+
Type.Literal("med"),
|
|
143
|
+
Type.Literal("info"),
|
|
144
|
+
]);
|
|
145
|
+
export type VerdictSeverity = Static<typeof VerdictSeveritySchema>;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* One entry in the unified verdict ledger. The (what, why, where) failure-mode triple
|
|
149
|
+
* is stored for provenance AND as the basis of the SEMANTIC final-check (the triple is
|
|
150
|
+
* NOT string-matched run-to-run — a pinned host-runtime reasoning check compares it;
|
|
151
|
+
* see enrich/dismissal-match.ts). Chesterton's-Fence provenance travels on every entry
|
|
152
|
+
* (reason · ts · operatorInvocation · runId · severityAtDismissal · entityFingerprint)
|
|
153
|
+
* so no verdict is a blind suppression.
|
|
154
|
+
*/
|
|
155
|
+
export const VerdictLedgerEntrySchema = Type.Object({
|
|
156
|
+
/** POLARITY — "approved" (valid) or "dismissed" (not-an-issue → suppress). */
|
|
157
|
+
verdict: Type.Union([Type.Literal("approved"), Type.Literal("dismissed")]),
|
|
158
|
+
/** The finding this verdict was cast on (provenance; NOT a run-to-run match key). */
|
|
159
|
+
findingId: Type.String(),
|
|
160
|
+
/** Entity slug — the EXACT-match half of the final-check (entity must match). */
|
|
161
|
+
entitySlug: Type.String(),
|
|
162
|
+
/** Failure-mode triple (from failureOrigin) — provenance + semantic-match basis. */
|
|
163
|
+
what: Type.String(),
|
|
164
|
+
why: Type.String(),
|
|
165
|
+
where: Type.String(),
|
|
166
|
+
/** OPTIONAL richer narration (failureOrigin.whatHappened) for the semantic check. */
|
|
167
|
+
whatHappened: Type.Optional(Type.String()),
|
|
168
|
+
/** Severity when the verdict was cast — the §escalation guard baseline. */
|
|
169
|
+
severityAtDismissal: VerdictSeveritySchema,
|
|
170
|
+
/** Entity fingerprint at verdict time — a change invalidates the verdict (config-change). */
|
|
171
|
+
entityFingerprint: Type.String(),
|
|
172
|
+
/** Operator's "why not an issue" / approval note (Chesterton's-Fence provenance). */
|
|
173
|
+
reason: Type.Optional(Type.String()),
|
|
174
|
+
/** D2 — verbatim operator invocation that cast this verdict. */
|
|
175
|
+
operatorInvocation: Type.Optional(Type.String()),
|
|
176
|
+
/** The run that produced the finding this verdict was cast on. */
|
|
177
|
+
runId: Type.String(),
|
|
178
|
+
/** INJECTED ISO8601 timestamp the verdict was recorded (provenance; NOT a TTL basis). */
|
|
179
|
+
ts: Type.String(),
|
|
180
|
+
});
|
|
181
|
+
export type VerdictLedgerEntry = Static<typeof VerdictLedgerEntrySchema>;
|
package/mutagent-diagnostics/.claude/skills/mutagent-diagnostics/scripts/lint/template-inline-js.ts
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* scripts/lint/template-inline-js.ts
|
|
3
|
+
* R-007-B: Template inline-JS TypeScript lint.
|
|
4
|
+
*
|
|
5
|
+
* Walks assets/templates/*.html and *.html.tpl and extracts every <script> block whose
|
|
6
|
+
* type attribute is empty or "text/javascript" (i.e. executable scripts,
|
|
7
|
+
* NOT type="application/ld+json" or similar data blocks).
|
|
8
|
+
*
|
|
9
|
+
* Rejects TypeScript-specific patterns:
|
|
10
|
+
* - Type annotations: `: string`, `: number`, `: boolean`, `: HTMLElement`,
|
|
11
|
+
* `: HTMLInputElement`, `: any`, `: void`
|
|
12
|
+
* - Type assertions: `as SomeType` (capital-letter identifiers)
|
|
13
|
+
* - Interfaces: `interface Foo {`
|
|
14
|
+
* - Type aliases: `type Foo =`
|
|
15
|
+
* - Generic functions: `function f<T>(`
|
|
16
|
+
*
|
|
17
|
+
* Exit 0 = all templates pass.
|
|
18
|
+
* Exit 1 = at least one pattern found — prints actionable error with file + line.
|
|
19
|
+
*
|
|
20
|
+
* Usage: bun scripts/lint/template-inline-js.ts [--templates-dir <path>]
|
|
21
|
+
* Defaults to assets/templates/ relative to this script's location.
|
|
22
|
+
* Scans *.html and *.html.tpl files (R-015-A: added .html.tpl support).
|
|
23
|
+
*
|
|
24
|
+
* Type A — Pure Script (no LLM, no agent ops, deterministic lint only).
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { readFileSync, readdirSync } from "fs";
|
|
28
|
+
import { resolve, dirname as pathDirname, join, basename } from "path";
|
|
29
|
+
|
|
30
|
+
// ── Forbidden TypeScript patterns in inline executable <script> blocks ─────────
|
|
31
|
+
|
|
32
|
+
const FORBIDDEN_PATTERNS: Array<{ pattern: RegExp; label: string }> = [
|
|
33
|
+
// Type annotations: `: string`, `: number`, `: boolean`, `: any`, `: void`
|
|
34
|
+
{
|
|
35
|
+
pattern: /:\s*(string|number|boolean|any|void)\b/,
|
|
36
|
+
label: "TypeScript type annotation (: string|number|boolean|any|void)",
|
|
37
|
+
},
|
|
38
|
+
// HTML element type annotations: `: HTMLElement`, `: HTMLInputElement`
|
|
39
|
+
{
|
|
40
|
+
pattern: /:\s*(HTMLElement|HTMLInputElement)\b/,
|
|
41
|
+
label: "TypeScript DOM type annotation (: HTMLElement | HTMLInputElement)",
|
|
42
|
+
},
|
|
43
|
+
// Type assertions: `as HTMLElement`, `as SomeUpperCaseIdentifier`
|
|
44
|
+
{
|
|
45
|
+
pattern: /\bas\s+[A-Z][a-zA-Z]+\b/,
|
|
46
|
+
label: "TypeScript type assertion (as SomeType)",
|
|
47
|
+
},
|
|
48
|
+
// Interface declarations: `interface Foo {`
|
|
49
|
+
{
|
|
50
|
+
pattern: /\binterface\s+\w+\s*\{/,
|
|
51
|
+
label: "TypeScript interface declaration",
|
|
52
|
+
},
|
|
53
|
+
// Type alias declarations: `type Foo =`
|
|
54
|
+
{
|
|
55
|
+
pattern: /\btype\s+\w+\s*=/,
|
|
56
|
+
label: "TypeScript type alias",
|
|
57
|
+
},
|
|
58
|
+
// Generic function syntax: `function f<T>(`
|
|
59
|
+
{
|
|
60
|
+
pattern: /\bfunction\s+\w+\s*<[A-Za-z][\w,\s]*>\s*\(/,
|
|
61
|
+
label: "TypeScript generic function",
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
// ── Script block extraction ────────────────────────────────────────────────────
|
|
66
|
+
|
|
67
|
+
interface ScriptBlock {
|
|
68
|
+
content: string;
|
|
69
|
+
startLine: number; // 1-indexed, line of the opening <script> tag
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Extract all executable <script> blocks from an HTML string.
|
|
74
|
+
* Executable = type attribute is absent, empty, or "text/javascript".
|
|
75
|
+
* Explicitly EXCLUDES type="application/ld+json" and other non-executable types.
|
|
76
|
+
*/
|
|
77
|
+
function extractExecutableScriptBlocks(html: string): ScriptBlock[] {
|
|
78
|
+
const blocks: ScriptBlock[] = [];
|
|
79
|
+
// Match <script ...> ... </script> (non-greedy, handles multiline)
|
|
80
|
+
const scriptTagRe = /<script([^>]*)>([\s\S]*?)<\/script>/gi;
|
|
81
|
+
|
|
82
|
+
let match: RegExpExecArray | null;
|
|
83
|
+
while ((match = scriptTagRe.exec(html)) !== null) {
|
|
84
|
+
const attrs = match[1] ?? "";
|
|
85
|
+
const content = match[2] ?? "";
|
|
86
|
+
|
|
87
|
+
// Extract type attribute value
|
|
88
|
+
const typeMatch = attrs.match(/\btype\s*=\s*["']?([^"'\s>]*)["']?/i);
|
|
89
|
+
const typeValue = typeMatch ? typeMatch[1].toLowerCase() : "";
|
|
90
|
+
|
|
91
|
+
// Skip non-executable script blocks
|
|
92
|
+
if (typeValue && typeValue !== "text/javascript") {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Calculate starting line number
|
|
97
|
+
const before = html.slice(0, match.index);
|
|
98
|
+
const startLine = (before.match(/\n/g)?.length ?? 0) + 1;
|
|
99
|
+
|
|
100
|
+
blocks.push({ content, startLine });
|
|
101
|
+
}
|
|
102
|
+
return blocks;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ── R-015-A: Literal newline inside JS string literal ─────────────────────────
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Detect lines where a JS string literal (single- or double-quoted) contains a
|
|
109
|
+
* raw LF — i.e., the quote is opened but not closed before end-of-line.
|
|
110
|
+
* Such strings cause `SyntaxError: Unexpected token ILLEGAL` in all browsers.
|
|
111
|
+
*
|
|
112
|
+
* Algorithm per line:
|
|
113
|
+
* 1. Strip properly-closed string literals (handles \' and \\ escapes inside)
|
|
114
|
+
* so their closing quotes don't produce false positives.
|
|
115
|
+
* 2. After stripping, any remaining quote at end-of-line = unclosed string
|
|
116
|
+
* spanning a literal newline.
|
|
117
|
+
*
|
|
118
|
+
* Limitation: does not handle template literals (`\`...\``) or regex literals —
|
|
119
|
+
* acceptable for a regression guard on simple browser-executable template JS.
|
|
120
|
+
*/
|
|
121
|
+
function detectLiteralNewlinesInBlock(
|
|
122
|
+
block: ScriptBlock,
|
|
123
|
+
filePath: string
|
|
124
|
+
): LintError[] {
|
|
125
|
+
const errors: LintError[] = [];
|
|
126
|
+
const lines = block.content.split("\n");
|
|
127
|
+
|
|
128
|
+
for (let i = 0; i < lines.length; i++) {
|
|
129
|
+
const line = lines[i];
|
|
130
|
+
|
|
131
|
+
// Strip complete single-quoted strings (including internal \' and \\ escapes)
|
|
132
|
+
let stripped = line.replace(/'(?:[^'\\]|\\.)*'/g, "__STR__");
|
|
133
|
+
// Strip complete double-quoted strings
|
|
134
|
+
stripped = stripped.replace(/"(?:[^"\\]|\\.)*"/g, "__STR__");
|
|
135
|
+
|
|
136
|
+
// After stripping matched pairs, an unclosed quote at EOL = literal newline in string
|
|
137
|
+
const singleUnclosed = /'[^']*$/.test(stripped);
|
|
138
|
+
const doubleUnclosed = /"[^"]*$/.test(stripped);
|
|
139
|
+
|
|
140
|
+
if (singleUnclosed || doubleUnclosed) {
|
|
141
|
+
errors.push({
|
|
142
|
+
file: filePath,
|
|
143
|
+
scriptStartLine: block.startLine,
|
|
144
|
+
contentLine: i + 1,
|
|
145
|
+
absoluteLine: block.startLine + i,
|
|
146
|
+
pattern:
|
|
147
|
+
"Literal newline inside JS string literal (use '\\n' escape instead — R-015-A)",
|
|
148
|
+
match: line.trim().slice(0, 120),
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return errors;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// ── Main lint runner ───────────────────────────────────────────────────────────
|
|
157
|
+
|
|
158
|
+
interface LintError {
|
|
159
|
+
file: string;
|
|
160
|
+
scriptStartLine: number;
|
|
161
|
+
contentLine: number; // line within the script block content (1-indexed)
|
|
162
|
+
absoluteLine: number; // approximate line in the HTML file
|
|
163
|
+
pattern: string;
|
|
164
|
+
match: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function lintTemplateFile(filePath: string): LintError[] {
|
|
168
|
+
const html = readFileSync(filePath, "utf8");
|
|
169
|
+
const blocks = extractExecutableScriptBlocks(html);
|
|
170
|
+
const errors: LintError[] = [];
|
|
171
|
+
|
|
172
|
+
for (const block of blocks) {
|
|
173
|
+
// Check TypeScript-specific forbidden patterns (line by line)
|
|
174
|
+
const lines = block.content.split("\n");
|
|
175
|
+
for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {
|
|
176
|
+
const line = lines[lineIdx];
|
|
177
|
+
for (const { pattern, label } of FORBIDDEN_PATTERNS) {
|
|
178
|
+
if (pattern.test(line)) {
|
|
179
|
+
errors.push({
|
|
180
|
+
file: filePath,
|
|
181
|
+
scriptStartLine: block.startLine,
|
|
182
|
+
contentLine: lineIdx + 1,
|
|
183
|
+
absoluteLine: block.startLine + lineIdx,
|
|
184
|
+
pattern: label,
|
|
185
|
+
match: line.trim().slice(0, 120),
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
// R-015-A: check for literal newlines inside single/double-quoted string literals
|
|
191
|
+
errors.push(...detectLiteralNewlinesInBlock(block, filePath));
|
|
192
|
+
}
|
|
193
|
+
return errors;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function resolveTemplatesDir(args: string[]): string {
|
|
197
|
+
const flagIdx = args.indexOf("--templates-dir");
|
|
198
|
+
if (flagIdx !== -1 && args[flagIdx + 1]) {
|
|
199
|
+
return resolve(args[flagIdx + 1]);
|
|
200
|
+
}
|
|
201
|
+
// Default: assets/templates/ relative to this script (scripts/lint/ → ../.. → skill root)
|
|
202
|
+
const scriptDir = import.meta.dirname ?? pathDirname(import.meta.url.replace("file://", ""));
|
|
203
|
+
return join(scriptDir, "..", "..", "assets", "templates");
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// ── Entrypoint ─────────────────────────────────────────────────────────────────
|
|
207
|
+
|
|
208
|
+
if (import.meta.main) {
|
|
209
|
+
const args = process.argv.slice(2);
|
|
210
|
+
const templatesDir = resolveTemplatesDir(args);
|
|
211
|
+
|
|
212
|
+
let htmlFiles: string[];
|
|
213
|
+
try {
|
|
214
|
+
htmlFiles = readdirSync(templatesDir)
|
|
215
|
+
.filter((f) => f.endsWith(".html") || f.endsWith(".html.tpl"))
|
|
216
|
+
.map((f) => join(templatesDir, f));
|
|
217
|
+
} catch (err) {
|
|
218
|
+
process.stderr.write(`[template-inline-js] ERROR: Could not read templates directory: ${templatesDir}\n ${err}\n`);
|
|
219
|
+
process.exit(1);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (htmlFiles.length === 0) {
|
|
223
|
+
process.stdout.write(`[template-inline-js] No .html files found in ${templatesDir} — nothing to lint.\n`);
|
|
224
|
+
process.exit(0);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const allErrors: LintError[] = [];
|
|
228
|
+
|
|
229
|
+
for (const file of htmlFiles) {
|
|
230
|
+
const errors = lintTemplateFile(file);
|
|
231
|
+
allErrors.push(...errors);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (allErrors.length === 0) {
|
|
235
|
+
process.stdout.write(
|
|
236
|
+
`[template-inline-js] PASS — ${htmlFiles.length} template(s) checked, 0 TypeScript patterns found.\n`
|
|
237
|
+
);
|
|
238
|
+
process.exit(0);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Report errors
|
|
242
|
+
process.stderr.write(
|
|
243
|
+
`[template-inline-js] FAIL — TypeScript patterns found in inline <script> blocks.\n` +
|
|
244
|
+
`Templates must use plain JavaScript only (no TypeScript syntax in browser-executed script tags).\n\n`
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
for (const err of allErrors) {
|
|
248
|
+
process.stderr.write(
|
|
249
|
+
` ${basename(err.file)}:${err.absoluteLine} — ${err.pattern}\n` +
|
|
250
|
+
` Line: ${err.match}\n`
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
process.stderr.write(
|
|
255
|
+
"\n" + allErrors.length + " error(s) found in " + new Set(allErrors.map((e) => e.file)).size + " file(s).\n" +
|
|
256
|
+
"FIX: Remove TypeScript syntax and literal newlines from inline <script type=\"text/javascript\"> blocks.\n" +
|
|
257
|
+
" Type annotations: remove ': Type' suffixes\n" +
|
|
258
|
+
" Type assertions: replace 'x as HTMLElement' with plain 'x'\n" +
|
|
259
|
+
" Interfaces/types: move to a separate .ts compilation step\n" +
|
|
260
|
+
" Literal newlines: replace join('\\n') spanning two lines with join('\\\\n') on one line (R-015-A)\n"
|
|
261
|
+
);
|
|
262
|
+
process.exit(1);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Export for testing
|
|
266
|
+
export { extractExecutableScriptBlocks, lintTemplateFile, detectLiteralNewlinesInBlock, FORBIDDEN_PATTERNS };
|
|
267
|
+
export type { ScriptBlock, LintError };
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* scripts/memory/append.ts
|
|
3
|
+
* PHASE 3 (PR-D) — project-level AutoMemory APPENDER.
|
|
4
|
+
*
|
|
5
|
+
* Appends a NEW (or UPDATES an existing) memory entry to `.mutagent/memory/` on
|
|
6
|
+
* operator feedback, and refreshes the `MEMORY.md` index. Called at run FINALIZE
|
|
7
|
+
* (finalize-gate / Step 9.9) when the operator gives feedback about the TOOL or a
|
|
8
|
+
* standing preference — see the classification rubric in references/memory-format.md.
|
|
9
|
+
*
|
|
10
|
+
* Reuses the store.ts APPEND DISCIPLINE (deterministic writes; INJECTED clock; a
|
|
11
|
+
* regenerated, sorted index) but NOT its per-entity keying — AutoMemory is keyed by
|
|
12
|
+
* a content SLUG, one FACT per file, not per diagnosed-entity.
|
|
13
|
+
*
|
|
14
|
+
* DETERMINISM: `created` is INJECTED (`now`, a YYYY-MM-DD string) so tests are
|
|
15
|
+
* byte-stable. Dedupe on append: an existing slug is UPDATED in place and its
|
|
16
|
+
* `created` date REFRESHED (the plan's "dedupe on append: update + refresh date").
|
|
17
|
+
*
|
|
18
|
+
* Type A — Pure Script (file I/O; clock INJECTED; base dir INJECTABLE for tests).
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync, readdirSync } from "fs";
|
|
22
|
+
import { join } from "path";
|
|
23
|
+
import {
|
|
24
|
+
memoryRoot,
|
|
25
|
+
memoryIndexPath,
|
|
26
|
+
memoryEntryPath,
|
|
27
|
+
parseMemoryEntry,
|
|
28
|
+
type MemoryEntry,
|
|
29
|
+
type MemoryType,
|
|
30
|
+
type MemoryLifecycle,
|
|
31
|
+
} from "./read.ts";
|
|
32
|
+
|
|
33
|
+
export interface AppendMemoryInput {
|
|
34
|
+
/** Kebab-case slug (also the entry filename). */
|
|
35
|
+
slug: string;
|
|
36
|
+
/** Frontmatter `name`. */
|
|
37
|
+
name: string;
|
|
38
|
+
/** Frontmatter `description` — the one-line relevance hint used at recall. */
|
|
39
|
+
description: string;
|
|
40
|
+
/** Classified type (rubric in references/memory-format.md; first-match wins). */
|
|
41
|
+
type: MemoryType;
|
|
42
|
+
/** ADL lifecycle tag. Defaults to "diagnose" for a diagnostics-run feedback. */
|
|
43
|
+
lifecycle: MemoryLifecycle;
|
|
44
|
+
/** The fact body (for feedback/project include **Why:** + **How to apply:** lines). */
|
|
45
|
+
body: string;
|
|
46
|
+
/** INJECTED absolute date (YYYY-MM-DD) — keeps writes deterministic in tests. */
|
|
47
|
+
now: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface AppendResult {
|
|
51
|
+
written: boolean;
|
|
52
|
+
/** "created" a new entry or "updated" an existing slug (dedupe). */
|
|
53
|
+
action: "created" | "updated";
|
|
54
|
+
slug: string;
|
|
55
|
+
entryPath: string;
|
|
56
|
+
indexPath: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Deterministic kebab-case slug: lowercase, non-alphanumerics → "-", collapse, trim. */
|
|
60
|
+
export function memorySlug(name: string): string {
|
|
61
|
+
return (
|
|
62
|
+
name
|
|
63
|
+
.toLowerCase()
|
|
64
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
65
|
+
.replace(/-+/g, "-")
|
|
66
|
+
.replace(/^-|-$/g, "") || "untitled"
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function ensureDir(dir: string): void {
|
|
71
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Render an entry to its committed markdown file shape (frontmatter + body). */
|
|
75
|
+
function renderEntry(input: AppendMemoryInput): string {
|
|
76
|
+
return (
|
|
77
|
+
`---\n` +
|
|
78
|
+
`name: ${input.name}\n` +
|
|
79
|
+
`description: ${input.description}\n` +
|
|
80
|
+
`metadata:\n` +
|
|
81
|
+
` type: ${input.type}\n` +
|
|
82
|
+
` lifecycle: ${input.lifecycle}\n` +
|
|
83
|
+
` created: ${input.now}\n` +
|
|
84
|
+
`---\n\n` +
|
|
85
|
+
`${input.body.trim()}\n`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Append (or dedupe-update) an AutoMemory entry + refresh the index. Returns the
|
|
91
|
+
* write outcome. Idempotent on the slug: a second append with the same slug UPDATES
|
|
92
|
+
* the file and refreshes its `created` date rather than creating a duplicate.
|
|
93
|
+
*/
|
|
94
|
+
export function appendMemory(input: AppendMemoryInput, base?: string): AppendResult {
|
|
95
|
+
const root = memoryRoot(base);
|
|
96
|
+
ensureDir(root);
|
|
97
|
+
|
|
98
|
+
const entryPath = memoryEntryPath(input.slug, base);
|
|
99
|
+
const action: "created" | "updated" = existsSync(entryPath)
|
|
100
|
+
? "updated"
|
|
101
|
+
: "created";
|
|
102
|
+
|
|
103
|
+
writeFileSync(entryPath, renderEntry(input), "utf8");
|
|
104
|
+
regenerateMemoryIndex(base);
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
written: true,
|
|
108
|
+
action,
|
|
109
|
+
slug: input.slug,
|
|
110
|
+
entryPath,
|
|
111
|
+
indexPath: memoryIndexPath(base),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Regenerate `MEMORY.md` DETERMINISTICALLY from the on-disk entries: one
|
|
117
|
+
* `- [Title](<slug>.md) — <hook>` line per entry, sorted by slug. Pure given disk
|
|
118
|
+
* state (mirrors store.ts regenerateIndex). The hook is the entry's description.
|
|
119
|
+
*/
|
|
120
|
+
export function regenerateMemoryIndex(base?: string): void {
|
|
121
|
+
const root = memoryRoot(base);
|
|
122
|
+
ensureDir(root);
|
|
123
|
+
|
|
124
|
+
const slugs = existsSync(root)
|
|
125
|
+
? readdirSync(root)
|
|
126
|
+
.filter((f) => f.endsWith(".md") && f !== "MEMORY.md")
|
|
127
|
+
.map((f) => f.slice(0, -3))
|
|
128
|
+
.sort()
|
|
129
|
+
: [];
|
|
130
|
+
|
|
131
|
+
const lines: string[] = [
|
|
132
|
+
"# mutagent — project AutoMemory",
|
|
133
|
+
"",
|
|
134
|
+
"> Project-level, COMMITTED. Subject = the TOOL + operator preferences (NOT the",
|
|
135
|
+
"> diagnosed agent). Claude-Code AutoMemory format; every entry DATED + classified",
|
|
136
|
+
"> + lifecycle-tagged. See references/memory-format.md.",
|
|
137
|
+
"",
|
|
138
|
+
];
|
|
139
|
+
for (const slug of slugs) {
|
|
140
|
+
const entry = loadEntry(slug, base);
|
|
141
|
+
if (!entry) continue;
|
|
142
|
+
lines.push(`- [${entry.name}](${slug}.md) — ${entry.description}`);
|
|
143
|
+
}
|
|
144
|
+
lines.push("");
|
|
145
|
+
writeFileSync(memoryIndexPath(base), lines.join("\n"), "utf8");
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Load + parse a single entry from disk, or null when absent/corrupt. */
|
|
149
|
+
function loadEntry(slug: string, base?: string): MemoryEntry | null {
|
|
150
|
+
const p = join(memoryRoot(base), `${slug}.md`);
|
|
151
|
+
if (!existsSync(p)) return null;
|
|
152
|
+
try {
|
|
153
|
+
return parseMemoryEntry(slug, readFileSync(p, "utf8"));
|
|
154
|
+
} catch {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// CLI usage: bun scripts/memory/append.ts <slug> <name> <description> <type> <lifecycle> <now> <body...> [--root <dir>]
|
|
160
|
+
if (import.meta.main) {
|
|
161
|
+
const argv = process.argv.slice(2);
|
|
162
|
+
const rootIdx = argv.indexOf("--root");
|
|
163
|
+
const base = rootIdx !== -1 ? argv[rootIdx + 1] : process.cwd();
|
|
164
|
+
const positional = rootIdx !== -1 ? argv.slice(0, rootIdx) : argv;
|
|
165
|
+
const [slug, name, description, type, lifecycle, now, ...bodyParts] = positional;
|
|
166
|
+
|
|
167
|
+
if (!slug || !name || !description || !type || !lifecycle || !now) {
|
|
168
|
+
process.stderr.write(
|
|
169
|
+
"Usage: bun scripts/memory/append.ts <slug> <name> <description> <type> <lifecycle> <YYYY-MM-DD> <body...> [--root <dir>]\n",
|
|
170
|
+
);
|
|
171
|
+
process.exit(1);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const result = appendMemory(
|
|
175
|
+
{
|
|
176
|
+
slug,
|
|
177
|
+
name,
|
|
178
|
+
description,
|
|
179
|
+
type: type as MemoryType,
|
|
180
|
+
lifecycle: lifecycle as MemoryLifecycle,
|
|
181
|
+
body: bodyParts.join(" "),
|
|
182
|
+
now,
|
|
183
|
+
},
|
|
184
|
+
base,
|
|
185
|
+
);
|
|
186
|
+
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
187
|
+
process.exit(0);
|
|
188
|
+
}
|