@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,439 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AdlStage,
|
|
3
|
+
SubjectKind,
|
|
4
|
+
makeHandoverBundle,
|
|
5
|
+
} from "./handover-contract.ts";
|
|
6
|
+
import type {
|
|
7
|
+
AdlStageValue,
|
|
8
|
+
Acceptance,
|
|
9
|
+
ArtifactRef,
|
|
10
|
+
ContextPack,
|
|
11
|
+
HandoverBundle,
|
|
12
|
+
Provenance,
|
|
13
|
+
Subject,
|
|
14
|
+
SubjectKindValue,
|
|
15
|
+
EscalationPolicyValue,
|
|
16
|
+
} from "./handover-contract.ts";
|
|
17
|
+
import type { TopologyIndex } from "./sync-index.ts";
|
|
18
|
+
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
// O6 — dispatch wiring.
|
|
21
|
+
//
|
|
22
|
+
// resolveDispatch maps a resolved *command + an INJECTED context to a
|
|
23
|
+
// DispatchDescriptor: WHAT subject is being acted on, WHICH routing ADL stage
|
|
24
|
+
// it is, interactive|batch, gated, and (for a real route) the HandoverBundle
|
|
25
|
+
// that the orchestrator EMITS to the owning skill.
|
|
26
|
+
//
|
|
27
|
+
// THE TWO-ENUM MAPPING (the iter-3 cert flagged this as O6's core job — do NOT
|
|
28
|
+
// conflate the two enums):
|
|
29
|
+
// - The *sync TOPOLOGY classifies a directory with one enum
|
|
30
|
+
// (build|evaluate|diagnose|orchestrator|shared|unknown — a DIR classification).
|
|
31
|
+
// - The routing/handover AdlStage is a different enum
|
|
32
|
+
// (build|evaluate|diagnose|improve|audit — a routed ACTION).
|
|
33
|
+
// This module produces the ROUTING enum from the *command, and resolves the
|
|
34
|
+
// target subject's PATH from the topology. The *audit case is the proof they
|
|
35
|
+
// are not the same: *audit routes to the evaluator (topology stage "evaluate")
|
|
36
|
+
// but its routing stage is Audit. The command — not the subject's topology
|
|
37
|
+
// classification — decides the routing stage.
|
|
38
|
+
//
|
|
39
|
+
// Producer-side, orchestrator-owned. The actual cross-skill RUNTIME invocation
|
|
40
|
+
// (handing the bundle to a real sibling skill) is DECLARED in orchestrator.md,
|
|
41
|
+
// NOT wired here. This file is the deterministic engine: resolve → (gate) → emit
|
|
42
|
+
// a descriptor. The descriptor's `bundle` is what a future runtime step ships.
|
|
43
|
+
//
|
|
44
|
+
// Design invariants (mirror scripts/handover-contract.ts + scripts/sync-index.ts):
|
|
45
|
+
// - Pure functions + (no CLI needed — this is a library used by the gate +
|
|
46
|
+
// the orchestrator's documented execution flow). No clock, no random, no
|
|
47
|
+
// network. Any timestamp / id / path is an INJECTED ctx field, so the same
|
|
48
|
+
// command + ctx always yields a deep-equal descriptor.
|
|
49
|
+
// - The topology index is INJECTED (from *sync) rather than re-scanned, so the
|
|
50
|
+
// engine stays pure + deterministic against committed fixtures.
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
/** Where a command runs: on the parent session (interactive) or a sub-agent (batch). */
|
|
54
|
+
export type DispatchMode = "interactive" | "batch";
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* One row of the command → route table. Mirrors routing.yaml. A `dispatch` row
|
|
58
|
+
* carries the route_target skill name + the ROUTING adl_stage; a `local` row is
|
|
59
|
+
* orchestrator-internal (no subject, no bundle). `gated` is the approval flag
|
|
60
|
+
* the execution gate (scripts/gate.ts) reads.
|
|
61
|
+
*/
|
|
62
|
+
export interface RouteEntry {
|
|
63
|
+
type: "dispatch" | "local";
|
|
64
|
+
/** The skill the *command routes to (dispatch rows only). Resolved in the topology. */
|
|
65
|
+
route_target?: string;
|
|
66
|
+
/** The ROUTING ADL stage (dispatch rows only) — NOT the subject's topology stage. */
|
|
67
|
+
adl_stage?: AdlStageValue;
|
|
68
|
+
mode: DispatchMode;
|
|
69
|
+
gated: boolean;
|
|
70
|
+
/** Why a local command is orchestrator-internal (local rows only). */
|
|
71
|
+
reason?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Optional re-entrant SKILL→SKILL delegation (route FROM the skill level — never
|
|
74
|
+
* agent-direct). The PRIMARY subject stays the command owner; this names a SECOND
|
|
75
|
+
* SKILL + a `mode` that skill should run. Used by *sync-spec: agentspec owns the
|
|
76
|
+
* command + the spec artifact, but Helix hands a `mode:sync-spec` sub-bundle to the
|
|
77
|
+
* BUILDER skill, which runs its OWN ai-architect #sync-spec (read-only). Helix never
|
|
78
|
+
* reaches into a skill's private agent — encapsulation preserved.
|
|
79
|
+
*/
|
|
80
|
+
delegates_to?: { route_target: string; mode: string };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// The canonical command → route table. Data-driven mirror of routing.yaml's
|
|
84
|
+
// `commands` block (route_target · stage · mode · gated). The routing AdlStage
|
|
85
|
+
// is assigned PER COMMAND here — this is the two-enum mapping's source of truth.
|
|
86
|
+
const ROUTES: Readonly<Record<string, RouteEntry>> = {
|
|
87
|
+
// ── dispatch commands (route to a subject, emit a bundle) ──────────────────
|
|
88
|
+
"*spec": {
|
|
89
|
+
type: "dispatch",
|
|
90
|
+
route_target: "mutagent-agentspec",
|
|
91
|
+
adl_stage: AdlStage.Spec,
|
|
92
|
+
mode: "interactive", // the *spec interview runs on the parent session (AskUserQuestion is parent-only)
|
|
93
|
+
gated: false, // spec gathering is read/author-only — no apply, so ungated
|
|
94
|
+
},
|
|
95
|
+
"*build": {
|
|
96
|
+
type: "dispatch",
|
|
97
|
+
route_target: "mutagent-builder",
|
|
98
|
+
adl_stage: AdlStage.Build,
|
|
99
|
+
mode: "batch",
|
|
100
|
+
gated: true,
|
|
101
|
+
},
|
|
102
|
+
"*sync-spec": {
|
|
103
|
+
// Canonical spec-reconcile (fuses former *spec-sync + *spec-from-impl). AGENTSPEC owns the
|
|
104
|
+
// entry (it owns the spec artifact); it DELEGATES the target-read to the BUILDER skill (which
|
|
105
|
+
// runs its own ai-architect #sync-spec) — skill-mediated, never agent-direct. Stage is SPEC.
|
|
106
|
+
type: "dispatch",
|
|
107
|
+
route_target: "mutagent-agentspec",
|
|
108
|
+
adl_stage: AdlStage.Spec,
|
|
109
|
+
mode: "batch",
|
|
110
|
+
gated: true,
|
|
111
|
+
delegates_to: { route_target: "mutagent-builder", mode: "sync-spec" },
|
|
112
|
+
},
|
|
113
|
+
"*evaluate": {
|
|
114
|
+
type: "dispatch",
|
|
115
|
+
route_target: "mutagent-evaluator",
|
|
116
|
+
adl_stage: AdlStage.Evaluate,
|
|
117
|
+
mode: "batch",
|
|
118
|
+
gated: false,
|
|
119
|
+
},
|
|
120
|
+
"*audit": {
|
|
121
|
+
type: "dispatch",
|
|
122
|
+
route_target: "mutagent-evaluator", // SAME target as *evaluate …
|
|
123
|
+
adl_stage: AdlStage.Audit, // … but a DIFFERENT routing stage (no conflation)
|
|
124
|
+
mode: "batch",
|
|
125
|
+
gated: false,
|
|
126
|
+
},
|
|
127
|
+
"*diagnose": {
|
|
128
|
+
type: "dispatch",
|
|
129
|
+
route_target: "mutagent-diagnostics",
|
|
130
|
+
adl_stage: AdlStage.Diagnose,
|
|
131
|
+
mode: "batch",
|
|
132
|
+
gated: true, // the IMPROVE (apply) step downstream is approval-gated
|
|
133
|
+
},
|
|
134
|
+
// *improve — the ⑤ IMPROVE stage's single owner is mutagent-optimize (DC-6, resolves
|
|
135
|
+
// the KP-O1 split-brain). optimize CONDUCTS the closed Build→Eval→Diagnose→Improve loop
|
|
136
|
+
// and owns the apply-gate; it DELEGATES the write to ② builder, the judge to ③ evaluator,
|
|
137
|
+
// the RCA to ④ diagnostics, and the transport to `mutagent-cli apply`. Routing stage stays
|
|
138
|
+
// Improve — the two-enum split: a DIFFERENT routing stage with its OWN owner (not builder).
|
|
139
|
+
// Gated: a DRAFT needs no target, but APPLY needs a resolvable global target + a known
|
|
140
|
+
// apply.kind — the target floor (checkOnboardingComplete, at apply) + the approval floor
|
|
141
|
+
// both bite before a fix is written.
|
|
142
|
+
"*improve": {
|
|
143
|
+
type: "dispatch",
|
|
144
|
+
route_target: "mutagent-optimize",
|
|
145
|
+
adl_stage: AdlStage.Improve,
|
|
146
|
+
mode: "batch",
|
|
147
|
+
gated: true, // apply is approval-gated (draft remedies gate at apply-time via the target floor)
|
|
148
|
+
},
|
|
149
|
+
// ── trace collection — `*discover` → the `discovery` SYSTEM AGENT ─────────────
|
|
150
|
+
// `*discover` dispatches the INTENT-AWARE `discovery` agent
|
|
151
|
+
// (mutagent-orchestrator/assets/agents/discovery.md), a kind:agent subject
|
|
152
|
+
// resolved from the *sync topology (sync-index indexes assets/agents/). The agent
|
|
153
|
+
// reads TraceQuery.operationIntent — `fetch` (DEFAULT: generic collect/list/monitor,
|
|
154
|
+
// count+fetch only) | `evals`|`dataset` (fetch → select → classify → curated) — and
|
|
155
|
+
// emits a HandoverBundle of UniTF JSONL + (Selection)Manifest for the consumer stage.
|
|
156
|
+
// `*collect-traces` is retained as an internal ALIAS of the same route.
|
|
157
|
+
//
|
|
158
|
+
// TWO-ENUM NOTE — respects the frozen split. The routing AdlStage enum
|
|
159
|
+
// (spec|build|evaluate|diagnose|improve|audit) has NO dedicated "collect" member;
|
|
160
|
+
// adding one would break the FROZEN HandoverBundle contract. Collection is a
|
|
161
|
+
// sequential-pre-worker that feeds diagnose|evaluate, so it routes under its DEFAULT
|
|
162
|
+
// downstream consumer stage — Diagnose. The routing stage classifies the ACTION's
|
|
163
|
+
// consumer, not a new lifecycle phase — same spirit as *audit reusing the evaluator target.
|
|
164
|
+
"*discover": {
|
|
165
|
+
type: "dispatch",
|
|
166
|
+
route_target: "discovery", // the discovery AGENT (kind:agent), resolved from the *sync topology
|
|
167
|
+
adl_stage: AdlStage.Diagnose, // default downstream consumer (see TWO-ENUM NOTE) — NOT a new enum member
|
|
168
|
+
mode: "batch",
|
|
169
|
+
gated: false, // collection is read-only fetch/normalize — no apply; downstream diagnose/evaluate gates separately
|
|
170
|
+
},
|
|
171
|
+
"*collect-traces": {
|
|
172
|
+
type: "dispatch",
|
|
173
|
+
route_target: "discovery", // internal ALIAS of *discover — same target
|
|
174
|
+
adl_stage: AdlStage.Diagnose,
|
|
175
|
+
mode: "batch",
|
|
176
|
+
gated: false,
|
|
177
|
+
},
|
|
178
|
+
// ── local-only commands (orchestrator-internal — no subject, no bundle) ────
|
|
179
|
+
"*sync": {
|
|
180
|
+
type: "local",
|
|
181
|
+
mode: "interactive",
|
|
182
|
+
gated: false,
|
|
183
|
+
reason: "orchestrator-internal topology index — runs scripts/sync-index.ts; routes to no subject",
|
|
184
|
+
},
|
|
185
|
+
// *dogfood — HIDDEN observe surface. Local: it spawns the `dogfood-monitor` BG agent to
|
|
186
|
+
// live-tail a DOGFOOD-TARGET session (config.dogfood.source_dir) + render the status report.
|
|
187
|
+
// No skill subject/bundle; read-only observation → ungated. *dogfood-stop ends the loop.
|
|
188
|
+
"*dogfood": {
|
|
189
|
+
type: "local",
|
|
190
|
+
mode: "batch",
|
|
191
|
+
gated: false,
|
|
192
|
+
reason: "orchestrator-internal observe surface — spawns dogfood-monitor to tail config.dogfood.source_dir; routes to no skill subject",
|
|
193
|
+
},
|
|
194
|
+
"*dogfood-stop": {
|
|
195
|
+
type: "local",
|
|
196
|
+
mode: "interactive",
|
|
197
|
+
gated: false,
|
|
198
|
+
reason: "orchestrator-internal — terminates a running *dogfood monitor loop",
|
|
199
|
+
},
|
|
200
|
+
// *monitor — the EXTERNAL Monitor (EXT-1). Local: it spawns the `monitor` BG agent to
|
|
201
|
+
// arm a watch on the dormant config.triggers; on a match the agent emits a HandoverBundle
|
|
202
|
+
// to the target stage (via the same dispatch model as *discover) + posts a Slack notification.
|
|
203
|
+
// Ships DISABLED (no auto-fire until triggers.<stage>.enabled:true). No skill subject/bundle
|
|
204
|
+
// fabricated HERE — arming the watch is read-only → ungated. *monitor-stop disarms the watch.
|
|
205
|
+
"*monitor": {
|
|
206
|
+
type: "local",
|
|
207
|
+
mode: "batch",
|
|
208
|
+
gated: false,
|
|
209
|
+
reason: "orchestrator-internal observe surface — spawns the monitor agent to watch config.triggers; routes to no skill subject (ships DISABLED)",
|
|
210
|
+
},
|
|
211
|
+
"*monitor-stop": {
|
|
212
|
+
type: "local",
|
|
213
|
+
mode: "interactive",
|
|
214
|
+
gated: false,
|
|
215
|
+
reason: "orchestrator-internal — disarms a running *monitor watch",
|
|
216
|
+
},
|
|
217
|
+
"*status": {
|
|
218
|
+
type: "local",
|
|
219
|
+
mode: "interactive",
|
|
220
|
+
gated: false,
|
|
221
|
+
reason: "orchestrator-internal state read — routes to no subject",
|
|
222
|
+
},
|
|
223
|
+
"*onboard": {
|
|
224
|
+
type: "local",
|
|
225
|
+
mode: "interactive",
|
|
226
|
+
gated: true, // CLI install is ALWAYS approval-gated (§4)
|
|
227
|
+
reason: "orchestrator-led onboarding/config — local; CLI install is approval-gated",
|
|
228
|
+
},
|
|
229
|
+
"*help": {
|
|
230
|
+
type: "local",
|
|
231
|
+
mode: "interactive",
|
|
232
|
+
gated: false,
|
|
233
|
+
reason: "orchestrator-internal dashboard render — routes to no subject",
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
// Command aliases (mirrors routing.yaml `aliases`). *config ⇒ *onboard.
|
|
238
|
+
const ALIASES: Readonly<Record<string, string>> = {
|
|
239
|
+
"*config": "*onboard",
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
/** Normalize a command to its canonical `*name` form (adds a leading `*`, resolves aliases). */
|
|
243
|
+
function normalizeCommand(command: string): string {
|
|
244
|
+
const trimmed = command.trim();
|
|
245
|
+
const starred = trimmed.startsWith("*") ? trimmed : `*${trimmed}`;
|
|
246
|
+
const lowered = starred.toLowerCase();
|
|
247
|
+
return ALIASES[lowered] ?? lowered;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Look up a command's route entry (after normalization + alias resolution).
|
|
252
|
+
* Returns undefined for an unrecognized command. Exported so the execution gate
|
|
253
|
+
* (scripts/gate.ts) reuses the SAME route table — one source of truth for the
|
|
254
|
+
* routing stage + gated flag.
|
|
255
|
+
*/
|
|
256
|
+
export function lookupRoute(command: string): RouteEntry | undefined {
|
|
257
|
+
return ROUTES[normalizeCommand(command)];
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// ── Descriptor types (discriminated union on `kind`) ─────────────────────────
|
|
261
|
+
|
|
262
|
+
/** A real stage route: a resolved subject + the HandoverBundle to emit. */
|
|
263
|
+
export interface DispatchDescriptor {
|
|
264
|
+
kind: "dispatch";
|
|
265
|
+
/** The normalized *command that produced this descriptor. */
|
|
266
|
+
command: string;
|
|
267
|
+
/** What is being acted on — resolved from the injected *sync topology. */
|
|
268
|
+
target_subject: Subject;
|
|
269
|
+
/** The ROUTING ADL stage (build|evaluate|diagnose|improve|audit). */
|
|
270
|
+
adl_stage: AdlStageValue;
|
|
271
|
+
mode: DispatchMode;
|
|
272
|
+
gated: boolean;
|
|
273
|
+
/** The bundle the orchestrator EMITS to the target skill (declare-only runtime). */
|
|
274
|
+
bundle: HandoverBundle;
|
|
275
|
+
/**
|
|
276
|
+
* Resolved skill-mediated delegation (from route.delegates_to), if any. The PRIMARY
|
|
277
|
+
* subject owns the command; after it runs, the owner asks Helix to hand a `mode`
|
|
278
|
+
* sub-bundle to this SECOND skill (route from the skill level — never a private agent).
|
|
279
|
+
* *sync-spec: primary = agentspec, delegates_to = { builder, "sync-spec" }.
|
|
280
|
+
*/
|
|
281
|
+
delegates_to?: { subject: Subject; mode: string };
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** A local-only command (orchestrator-internal): no subject, no bundle fabricated. */
|
|
285
|
+
export interface LocalDescriptor {
|
|
286
|
+
kind: "local";
|
|
287
|
+
command: string;
|
|
288
|
+
mode: DispatchMode;
|
|
289
|
+
gated: boolean;
|
|
290
|
+
reason: string;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** An unrecognized command — explicitly typed, never coerced into a fake route. */
|
|
294
|
+
export interface UnknownDescriptor {
|
|
295
|
+
kind: "unknown";
|
|
296
|
+
command: string;
|
|
297
|
+
reason: string;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export type Descriptor =
|
|
301
|
+
| DispatchDescriptor
|
|
302
|
+
| LocalDescriptor
|
|
303
|
+
| UnknownDescriptor;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* The injected context resolveDispatch needs. The topology comes from *sync; the
|
|
307
|
+
* bundle inputs (acceptance · provenance · escalation_policy · inputs ·
|
|
308
|
+
* context_pack) are all INJECTED — provenance.produced_at especially is a passed
|
|
309
|
+
* stamp, never a self-read clock, so the engine is deterministic.
|
|
310
|
+
*/
|
|
311
|
+
export interface DispatchContext {
|
|
312
|
+
/** The *sync topology index — injected, never re-scanned here. */
|
|
313
|
+
topology: TopologyIndex;
|
|
314
|
+
/** The raw NL ask that triggered the route, when one did (optional). */
|
|
315
|
+
intent?: { utterance?: string };
|
|
316
|
+
/** The downstream stage's goal + criteria. */
|
|
317
|
+
acceptance: Acceptance;
|
|
318
|
+
/** Who/when produced the bundle — both INJECTED (no clock). */
|
|
319
|
+
provenance: Provenance;
|
|
320
|
+
escalation_policy: EscalationPolicyValue;
|
|
321
|
+
/** Artifacts crossing the boundary (optional; defaults to empty). */
|
|
322
|
+
inputs?: ArtifactRef[];
|
|
323
|
+
/** The curated context handed down (optional; defaults to empty). */
|
|
324
|
+
context_pack?: Partial<ContextPack>;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Map a topology entry kind to a HandoverBundle SubjectKind. The topology has three
|
|
329
|
+
* kinds ("skill" | "agent" | "system_agent"); the FROZEN SubjectKind has two
|
|
330
|
+
* (skill | agent). Only "skill" → Skill; both "agent" and "system_agent" → Agent
|
|
331
|
+
* (a system_agent, e.g. `discovery`, is still an agent subject on the bundle).
|
|
332
|
+
*/
|
|
333
|
+
function toSubjectKind(kind: string): SubjectKindValue {
|
|
334
|
+
return kind === SubjectKind.Skill ? SubjectKind.Skill : SubjectKind.Agent;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Resolve a *command + injected ctx to a DispatchDescriptor.
|
|
339
|
+
*
|
|
340
|
+
* - dispatch command → resolve the route_target in the injected topology, build
|
|
341
|
+
* the target Subject {kind,name,path}, and BUILD the HandoverBundle (routing
|
|
342
|
+
* adl_stage from the command, subject from the topology, everything else
|
|
343
|
+
* injected via ctx). Reuses makeHandoverBundle.
|
|
344
|
+
* - local command (*sync/*status/*onboard/*help) → a non-dispatch descriptor,
|
|
345
|
+
* no subject/bundle fabricated.
|
|
346
|
+
* - unknown command → an explicit unknown descriptor.
|
|
347
|
+
*
|
|
348
|
+
* Pure + deterministic: same command + ctx ⇒ deep-equal descriptor. THROWS only
|
|
349
|
+
* on a precondition violation — a dispatch command whose route_target is not in
|
|
350
|
+
* the topology (you must *sync before you can route; an un-indexed target is
|
|
351
|
+
* surfaced loudly, not fabricated).
|
|
352
|
+
*/
|
|
353
|
+
export function resolveDispatch(
|
|
354
|
+
command: string,
|
|
355
|
+
ctx: DispatchContext,
|
|
356
|
+
): Descriptor {
|
|
357
|
+
const normalized = normalizeCommand(command);
|
|
358
|
+
const route = ROUTES[normalized];
|
|
359
|
+
|
|
360
|
+
if (route === undefined) {
|
|
361
|
+
return {
|
|
362
|
+
kind: "unknown",
|
|
363
|
+
command: normalized,
|
|
364
|
+
reason: `unrecognized command '${normalized}' — not in the routing table`,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (route.type === "local") {
|
|
369
|
+
return {
|
|
370
|
+
kind: "local",
|
|
371
|
+
command: normalized,
|
|
372
|
+
mode: route.mode,
|
|
373
|
+
gated: route.gated,
|
|
374
|
+
reason: route.reason ?? "orchestrator-internal command (routes to no subject)",
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// dispatch — resolve the target subject from the injected topology.
|
|
379
|
+
const targetName = route.route_target;
|
|
380
|
+
const entry = ctx.topology.entries.find((e) => e.name === targetName);
|
|
381
|
+
if (entry === undefined) {
|
|
382
|
+
throw new Error(
|
|
383
|
+
`resolveDispatch: route_target '${targetName}' for '${normalized}' is not ` +
|
|
384
|
+
`in the topology index (run *sync first — an un-indexed target cannot be routed)`,
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const target_subject: Subject = {
|
|
389
|
+
kind: toSubjectKind(entry.kind),
|
|
390
|
+
name: entry.name,
|
|
391
|
+
path: entry.path,
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
const adl_stage = route.adl_stage as AdlStageValue;
|
|
395
|
+
|
|
396
|
+
const bundle = makeHandoverBundle({
|
|
397
|
+
adl_stage,
|
|
398
|
+
subject: target_subject,
|
|
399
|
+
intent:
|
|
400
|
+
ctx.intent?.utterance !== undefined
|
|
401
|
+
? { command: normalized, utterance: ctx.intent.utterance }
|
|
402
|
+
: { command: normalized },
|
|
403
|
+
acceptance: ctx.acceptance,
|
|
404
|
+
provenance: ctx.provenance,
|
|
405
|
+
escalation_policy: ctx.escalation_policy,
|
|
406
|
+
inputs: ctx.inputs,
|
|
407
|
+
context_pack: ctx.context_pack,
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
// Skill-mediated delegation (route FROM the skill level): resolve the SECOND skill's
|
|
411
|
+
// subject from the SAME topology so an un-indexed delegate is surfaced loudly, not
|
|
412
|
+
// fabricated. No sub-bundle here — the owning skill asks Helix to hand off at runtime.
|
|
413
|
+
let delegates_to: DispatchDescriptor["delegates_to"];
|
|
414
|
+
if (route.delegates_to !== undefined) {
|
|
415
|
+
const dName = route.delegates_to.route_target;
|
|
416
|
+
const dEntry = ctx.topology.entries.find((e) => e.name === dName);
|
|
417
|
+
if (dEntry === undefined) {
|
|
418
|
+
throw new Error(
|
|
419
|
+
`resolveDispatch: delegates_to '${dName}' for '${normalized}' is not in the ` +
|
|
420
|
+
`topology index (run *sync first — an un-indexed delegate cannot be routed)`,
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
delegates_to = {
|
|
424
|
+
subject: { kind: toSubjectKind(dEntry.kind), name: dEntry.name, path: dEntry.path },
|
|
425
|
+
mode: route.delegates_to.mode,
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
return {
|
|
430
|
+
kind: "dispatch",
|
|
431
|
+
command: normalized,
|
|
432
|
+
target_subject,
|
|
433
|
+
adl_stage,
|
|
434
|
+
mode: route.mode,
|
|
435
|
+
gated: route.gated,
|
|
436
|
+
bundle,
|
|
437
|
+
...(delegates_to !== undefined ? { delegates_to } : {}),
|
|
438
|
+
};
|
|
439
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// extract-feedback — turn a Helix session transcript into ACTIONABLE, rationale-
|
|
3
|
+
// backed feedback items. Two channels:
|
|
4
|
+
//
|
|
5
|
+
// EXPLICIT — verbatim `[feedback] … [feedback]` (or `[feedback] … [/feedback]`)
|
|
6
|
+
// blocks the user typed. Captured VERBATIM with provenance.
|
|
7
|
+
// IMPLICIT — the P-0 deterministic signals reused from `mutagent-tools`:
|
|
8
|
+
// negative-reaction (frustration/profanity wordlist) + chat-feedback
|
|
9
|
+
// (a short evaluative reaction after an assistant turn).
|
|
10
|
+
//
|
|
11
|
+
// GROUNDING (anti-fabrication): every item carries an `evidencePointer` whose
|
|
12
|
+
// `quote` is verbatim from the transcript, and every `actionable` cites the turn it
|
|
13
|
+
// came from. We NEVER invent an observation the transcript doesn't support.
|
|
14
|
+
//
|
|
15
|
+
// PURITY: pure — no clock, no random, no I/O. Input is an already-parsed UniTF
|
|
16
|
+
// trace (the main session, via the shared claude-code adapter).
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
import { scanNegativeReaction } from "../../../mutagent-tools/src/signals/negative-reaction.ts";
|
|
20
|
+
import { detectChatFeedback } from "../../../mutagent-tools/src/signals/chat-feedback.ts";
|
|
21
|
+
import type { Span, UnifiedTrace } from "../../../mutagent-tools/src/format/unitf.ts";
|
|
22
|
+
|
|
23
|
+
import type { EvidencePointer, FeedbackItem } from "./types.ts";
|
|
24
|
+
|
|
25
|
+
/** A transcript is a parsed UniTF trace (the main Helix session). */
|
|
26
|
+
export type Transcript = UnifiedTrace;
|
|
27
|
+
|
|
28
|
+
/** Cap for a verbatim snippet quoted inside an `actionable`/`quote` (still verbatim-prefix). */
|
|
29
|
+
const SNIPPET_MAX = 280;
|
|
30
|
+
|
|
31
|
+
/** Best-effort deterministic stringify of a span input/output payload. */
|
|
32
|
+
function spanText(v: unknown): string {
|
|
33
|
+
if (v === undefined || v === null) return "";
|
|
34
|
+
if (typeof v === "string") return v;
|
|
35
|
+
if (typeof v === "number" || typeof v === "boolean") return String(v);
|
|
36
|
+
if (typeof v === "object") {
|
|
37
|
+
const o = v as Record<string, unknown>;
|
|
38
|
+
for (const k of ["text", "content", "response", "prompt", "message"]) {
|
|
39
|
+
if (typeof o[k] === "string") return o[k] as string;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
return JSON.stringify(v);
|
|
43
|
+
} catch {
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return "";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Verbatim-prefix snippet (never paraphrased) for inline citation. */
|
|
51
|
+
function snippet(text: string): string {
|
|
52
|
+
const t = text.trim();
|
|
53
|
+
return t.length <= SNIPPET_MAX ? t : `${t.slice(0, SNIPPET_MAX)}…`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface UserTurn {
|
|
57
|
+
/** Ordinal position among user turns (the transcript-line pointer). */
|
|
58
|
+
ordinal: number;
|
|
59
|
+
spanId: string;
|
|
60
|
+
text: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The ordered user turns of a transcript (role === "user" spans). */
|
|
64
|
+
function userTurns(t: Transcript): UserTurn[] {
|
|
65
|
+
const turns: UserTurn[] = [];
|
|
66
|
+
let ordinal = 0;
|
|
67
|
+
for (const span of t.spans) {
|
|
68
|
+
if (span.role !== "user") continue;
|
|
69
|
+
turns.push({ ordinal, spanId: span.spanId, text: spanText(span.output ?? span.input) });
|
|
70
|
+
ordinal++;
|
|
71
|
+
}
|
|
72
|
+
return turns;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The `[feedback] … [feedback]` / `[feedback] … [/feedback]` block matcher. */
|
|
76
|
+
const FEEDBACK_BLOCK_RE = /\[feedback\]([\s\S]*?)\[\/?feedback\]/gi;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* DOG-1 — the explicit-`[feedback]` self-reference boundary (the reflexivity
|
|
80
|
+
* ship-gate). A capability that READS text will read its OWN design docs: this
|
|
81
|
+
* session literally contains `[feedback]` as documentation (a plan quoting its
|
|
82
|
+
* trigger word). We must capture a REAL operator `[feedback]` directive — a turn
|
|
83
|
+
* that IS the input — and DROP a turn that merely QUOTES a document mentioning
|
|
84
|
+
* the token.
|
|
85
|
+
*
|
|
86
|
+
* `maskQuotedContext` returns a per-character boolean mask marking QUOTED regions
|
|
87
|
+
* — fenced code blocks (``` / ~~~), blockquote lines (`> …`), and inline-code
|
|
88
|
+
* spans (`` `…` ``). A `[feedback]` block whose OPENING delimiter falls inside a
|
|
89
|
+
* masked region is documentation, not a directive, and is skipped. Genuine
|
|
90
|
+
* top-level directives are never masked, so their verbatim body is preserved.
|
|
91
|
+
*/
|
|
92
|
+
export function maskQuotedContext(text: string): boolean[] {
|
|
93
|
+
const mask = new Array<boolean>(text.length).fill(false);
|
|
94
|
+
const setRange = (start: number, end: number): void => {
|
|
95
|
+
for (let i = start; i < end && i < text.length; i++) mask[i] = true;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
let offset = 0;
|
|
99
|
+
let inFence = false;
|
|
100
|
+
for (const line of text.split("\n")) {
|
|
101
|
+
const lineStart = offset;
|
|
102
|
+
const lineEnd = offset + line.length;
|
|
103
|
+
const trimmed = line.trimStart();
|
|
104
|
+
const isFenceDelim = trimmed.startsWith("```") || trimmed.startsWith("~~~");
|
|
105
|
+
|
|
106
|
+
if (isFenceDelim) {
|
|
107
|
+
// The fence delimiter line itself is quoted context either way.
|
|
108
|
+
setRange(lineStart, lineEnd);
|
|
109
|
+
inFence = !inFence;
|
|
110
|
+
} else if (inFence) {
|
|
111
|
+
setRange(lineStart, lineEnd); // inside a fenced code block
|
|
112
|
+
} else if (trimmed.startsWith(">")) {
|
|
113
|
+
setRange(lineStart, lineEnd); // a blockquote line
|
|
114
|
+
} else {
|
|
115
|
+
// inline-code spans on this line (`…`, ``…``): mask the whole span
|
|
116
|
+
const inlineCode = /(`+)[^\n]*?\1/g;
|
|
117
|
+
let m: RegExpExecArray | null;
|
|
118
|
+
while ((m = inlineCode.exec(line)) !== null) {
|
|
119
|
+
setRange(lineStart + m.index, lineStart + m.index + m[0].length);
|
|
120
|
+
if (m.index === inlineCode.lastIndex) inlineCode.lastIndex++; // guard zero-width
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
offset = lineEnd + 1; // +1 for the consumed "\n"
|
|
124
|
+
}
|
|
125
|
+
return mask;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function evidence(sessionId: string, turn: UserTurn, quote: string): EvidencePointer {
|
|
129
|
+
return { sessionId, spanId: turn.spanId, turnIndex: turn.ordinal, quote: snippet(quote) };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Extract explicit + implicit feedback from a transcript → actionable items.
|
|
134
|
+
* Deterministic order: explicit blocks (turn order) → negative-reaction turns
|
|
135
|
+
* (turn order) → chat-feedback reaction (if any).
|
|
136
|
+
*/
|
|
137
|
+
export function extractFeedback(transcript: Transcript): FeedbackItem[] {
|
|
138
|
+
const sessionId = transcript.sessionId ?? transcript.traceId;
|
|
139
|
+
const turns = userTurns(transcript);
|
|
140
|
+
const items: FeedbackItem[] = [];
|
|
141
|
+
|
|
142
|
+
// ── EXPLICIT: verbatim [feedback] blocks (DOG-1 boundary) ───────────────────
|
|
143
|
+
for (const turn of turns) {
|
|
144
|
+
// Quoted-context mask: a [feedback] opening inside a fence/blockquote/inline-
|
|
145
|
+
// code region is DOCUMENTATION (a doc-mention), not an operator directive.
|
|
146
|
+
const mask = maskQuotedContext(turn.text);
|
|
147
|
+
FEEDBACK_BLOCK_RE.lastIndex = 0;
|
|
148
|
+
let m: RegExpExecArray | null;
|
|
149
|
+
while ((m = FEEDBACK_BLOCK_RE.exec(turn.text)) !== null) {
|
|
150
|
+
if (mask[m.index] === true) continue; // opening delimiter is quoted → not a directive
|
|
151
|
+
const body = m[1].trim();
|
|
152
|
+
if (body.length === 0) continue;
|
|
153
|
+
const neg = scanNegativeReaction(body);
|
|
154
|
+
items.push({
|
|
155
|
+
source: "explicit",
|
|
156
|
+
kind: "feedback-block",
|
|
157
|
+
observation: body,
|
|
158
|
+
actionable: `Act on the user's explicit feedback (turn ${turn.ordinal}): "${snippet(body)}"`,
|
|
159
|
+
rationale: `Verbatim [feedback] block — a deliberate user signal (session ${sessionId}, turn ${turn.ordinal}).`,
|
|
160
|
+
severity: neg.hit ? "high" : "med",
|
|
161
|
+
evidencePointer: evidence(sessionId, turn, body),
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// ── IMPLICIT: P-0 negative-reaction (per user turn) ─────────────────────────
|
|
167
|
+
for (const turn of turns) {
|
|
168
|
+
const neg = scanNegativeReaction(turn.text);
|
|
169
|
+
if (!neg.hit) continue;
|
|
170
|
+
items.push({
|
|
171
|
+
source: "implicit",
|
|
172
|
+
kind: "negative-reaction",
|
|
173
|
+
observation: `Negative-reaction terms in a user turn: ${neg.terms.join(", ")}.`,
|
|
174
|
+
actionable: `Review the assistant turn preceding turn ${turn.ordinal} — the user reacted negatively ("${snippet(turn.text)}").`,
|
|
175
|
+
rationale: `P-0 negative-reaction signal (wordlist hit ×${neg.count}) over user-role text.`,
|
|
176
|
+
severity: neg.count >= 2 ? "high" : "med",
|
|
177
|
+
evidencePointer: evidence(sessionId, turn, turn.text),
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// ── IMPLICIT: P-0 chat-feedback (a short evaluative reaction after assistant) ─
|
|
182
|
+
const chat = detectChatFeedback(transcript.spans as Span[]);
|
|
183
|
+
if (chat.hasChatFeedback && chat.turnIndex !== undefined) {
|
|
184
|
+
const span = transcript.spans[chat.turnIndex];
|
|
185
|
+
if (span && span.role === "user") {
|
|
186
|
+
// map the span back to its user-turn ordinal
|
|
187
|
+
const turn = turns.find((t) => t.spanId === span.spanId);
|
|
188
|
+
if (turn) {
|
|
189
|
+
items.push({
|
|
190
|
+
source: "implicit",
|
|
191
|
+
kind: "chat-feedback",
|
|
192
|
+
observation: `In-conversation evaluative reaction detected at turn ${turn.ordinal}.`,
|
|
193
|
+
actionable: `Check whether the preceding assistant turn satisfied the user — an evaluative marker appears at turn ${turn.ordinal} ("${snippet(turn.text)}").`,
|
|
194
|
+
rationale: `P-0 chat-feedback heuristic (short user reaction with an evaluative marker after an assistant turn).`,
|
|
195
|
+
severity: "low",
|
|
196
|
+
evidencePointer: evidence(sessionId, turn, turn.text),
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return items;
|
|
203
|
+
}
|