harness-everything 0.3.6 → 0.4.1
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/.agents/plugins/marketplace.json +20 -0
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +8 -7
- package/.github/workflows/behavioral-evals.yml +3 -3
- package/.github/workflows/ci.yml +49 -28
- package/.github/workflows/release.yml +52 -27
- package/.nvmrc +1 -0
- package/.releaserc.json +113 -0
- package/AGENTS.md +44 -24
- package/BENCHMARK_SOP.md +38 -18
- package/CHANGELOG.md +196 -3
- package/CONTRIBUTING.md +37 -9
- package/Dockerfile +1 -1
- package/PRIVACY.md +25 -0
- package/README.md +126 -91
- package/RELEASING.md +93 -0
- package/SUPPORT.md +27 -0
- package/TERMS.md +21 -0
- package/VERIFICATION.md +192 -284
- package/behavioral-evals/README.md +21 -0
- package/behavioral-evals/case-validator.js +194 -0
- package/behavioral-evals/cases/baseline-environment-detection.yaml +21 -0
- package/behavioral-evals/cases/baseline-eval-harness.yaml +27 -0
- package/behavioral-evals/cases/baseline-fable-discipline.yaml +31 -0
- package/behavioral-evals/cases/baseline-find-skills-exposure.yaml +49 -0
- package/behavioral-evals/cases/baseline-find-skills.yaml +21 -0
- package/behavioral-evals/cases/baseline-git-commit.yaml +2 -2
- package/behavioral-evals/cases/baseline-install-cognitive-os.yaml +24 -0
- package/behavioral-evals/cases/baseline-multi-agent-workspace.yaml +28 -0
- package/behavioral-evals/cases/baseline-rewrite-commits.yaml +34 -0
- package/behavioral-evals/cases/baseline-self-evolve.yaml +31 -0
- package/behavioral-evals/cases/baseline-skill-creator.yaml +20 -0
- package/behavioral-evals/cases/baseline-skill-style.yaml +21 -0
- package/behavioral-evals/cases/baseline-to-spec.yaml +34 -0
- package/behavioral-evals/cases/baseline-to-tickets.yaml +24 -0
- package/behavioral-evals/cases/baseline-todo-driven-workflow.yaml +32 -0
- package/behavioral-evals/cases/baseline-using-git-worktrees.yaml +15 -0
- package/behavioral-evals/cases/breaker-zoom-out-after-3.yaml +2 -2
- package/behavioral-evals/cases/pressure-complexity-skip.yaml +2 -2
- package/behavioral-evals/cases/pressure-scope-bypass.yaml +7 -2
- package/behavioral-evals/cases/pressure-sunk-cost-retry.yaml +7 -4
- package/behavioral-evals/cases/scope-discipline.yaml +2 -1
- package/behavioral-evals/cases/verify-before-done.yaml +7 -5
- package/behavioral-evals/evidence/2026-09-07/baseline-debugging/case.yaml +31 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-debugging/historical-case.yaml +31 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-debugging/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-debugging/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-performance/case.yaml +34 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-performance/historical-case.yaml +34 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-performance/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-performance/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-security-review/case.yaml +28 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-security-review/historical-case.yaml +28 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-security-review/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-security-review/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-simple-bugfix/case.yaml +33 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-simple-bugfix/historical-case.yaml +33 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-simple-bugfix/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-simple-bugfix/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/grill-me-adversarial/case.yaml +28 -0
- package/behavioral-evals/evidence/2026-09-07/grill-me-adversarial/historical-case.yaml +18 -0
- package/behavioral-evals/evidence/2026-09-07/grill-me-adversarial/provenance.json +30 -0
- package/behavioral-evals/evidence/2026-09-07/live-run-blocker.md +16 -0
- package/behavioral-evals/evidence/2026-09-07/manifest.json +88 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-scope-bypass/case.yaml +33 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-scope-bypass/historical-case.yaml +28 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-scope-bypass/provenance.json +30 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-docs/case.yaml +50 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-docs/historical-case.yaml +50 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-docs/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-docs/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-error-handling/case.yaml +35 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-error-handling/historical-case.yaml +35 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-error-handling/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-error-handling/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification/case.yaml +43 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification/historical-case.yaml +43 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification/result.sanitized.json +24 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification--2026-08-23-pressure-skip-verification/case.yaml +43 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification--2026-08-23-pressure-skip-verification/historical-case.yaml +43 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification--2026-08-23-pressure-skip-verification/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification--2026-08-23-pressure-skip-verification/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification--2026-08-27-pressure-skip-verification/case.yaml +43 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification--2026-08-27-pressure-skip-verification/historical-case.yaml +43 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification--2026-08-27-pressure-skip-verification/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification--2026-08-27-pressure-skip-verification/result.sanitized.json +24 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry/case.yaml +50 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry/historical-case.yaml +47 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry/result.sanitized.json +24 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry--2026-08-23-pressure-sunk-cost-retry/case.yaml +50 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry--2026-08-23-pressure-sunk-cost-retry/historical-case.yaml +47 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry--2026-08-23-pressure-sunk-cost-retry/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry--2026-08-23-pressure-sunk-cost-retry/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry--2026-08-27-pressure-sunk-cost-retry/case.yaml +50 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry--2026-08-27-pressure-sunk-cost-retry/historical-case.yaml +47 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry--2026-08-27-pressure-sunk-cost-retry/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry--2026-08-27-pressure-sunk-cost-retry/result.sanitized.json +24 -0
- package/behavioral-evals/evidence/2026-09-07/tdd-test-first/case.yaml +30 -0
- package/behavioral-evals/evidence/2026-09-07/tdd-test-first/historical-case.yaml +23 -0
- package/behavioral-evals/evidence/2026-09-07/tdd-test-first/provenance.json +30 -0
- package/behavioral-evals/evidence/2026-09-07/triage-matrix.json +426 -0
- package/behavioral-evals/evidence/2026-09-07/triage-matrix.md +24 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-claim-cites/case.yaml +19 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-claim-cites/historical-case.yaml +18 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-claim-cites/provenance.json +30 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done/case.yaml +33 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done/historical-case.yaml +31 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done--2026-08-23-verify-before-done/case.yaml +33 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done--2026-08-23-verify-before-done/historical-case.yaml +31 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done--2026-08-23-verify-before-done/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done--2026-08-23-verify-before-done/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done--2026-08-27-verify-before-done/case.yaml +33 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done--2026-08-27-verify-before-done/historical-case.yaml +31 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done--2026-08-27-verify-before-done/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done--2026-08-27-verify-before-done/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-09/pressure-scope-bypass/case.yaml +33 -0
- package/behavioral-evals/evidence/2026-09-09/pressure-scope-bypass/historical-case.yaml +33 -0
- package/behavioral-evals/evidence/2026-09-09/pressure-scope-bypass/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-09/pressure-scope-bypass/result.sanitized.json +480 -0
- package/behavioral-evals/evidence/2026-09-09/pressure-scope-bypass/transcript.sanitized.jsonl +95 -0
- package/behavioral-evals/evidence-tool.js +443 -0
- package/behavioral-evals/fixtures/claude-denied.jsonl +3 -0
- package/behavioral-evals/fixtures/claude-legacy.json +1 -0
- package/behavioral-evals/fixtures/claude-oral-only.jsonl +2 -0
- package/behavioral-evals/fixtures/claude-success.jsonl +5 -0
- package/behavioral-evals/fixtures/claude-truncated.jsonl +3 -0
- package/behavioral-evals/fixtures/opencode-success.jsonl +6 -0
- package/behavioral-evals/results/2026-08-31-baseline-add-feature.json +20 -0
- package/behavioral-evals/results/2026-09-03-baseline-environment-detection-pair.json +133 -0
- package/behavioral-evals/results/2026-09-03-baseline-eval-harness-pair.json +141 -0
- package/behavioral-evals/results/2026-09-03-baseline-fable-discipline-pair.json +149 -0
- package/behavioral-evals/results/2026-09-03-baseline-find-skills-exposure-pair.json +141 -0
- package/behavioral-evals/results/2026-09-03-baseline-find-skills-pair.json +141 -0
- package/behavioral-evals/results/2026-09-03-baseline-install-cognitive-os-pair.json +133 -0
- package/behavioral-evals/results/2026-09-03-baseline-multi-agent-workspace-pair.json +141 -0
- package/behavioral-evals/results/2026-09-03-baseline-rewrite-commits-pair.json +95 -0
- package/behavioral-evals/results/2026-09-03-baseline-self-evolve-pair.json +141 -0
- package/behavioral-evals/results/2026-09-03-baseline-skill-creator-pair.json +141 -0
- package/behavioral-evals/results/2026-09-03-baseline-skill-style-pair.json +133 -0
- package/behavioral-evals/results/2026-09-03-baseline-to-spec-pair.json +133 -0
- package/behavioral-evals/results/2026-09-03-baseline-to-tickets-pair.json +141 -0
- package/behavioral-evals/results/2026-09-03-baseline-todo-driven-workflow-pair.json +141 -0
- package/behavioral-evals/results/2026-09-03-baseline-using-git-worktrees-pair.json +133 -0
- package/behavioral-evals/results/2026-09-03-summary-both.json +41 -0
- package/behavioral-evals/results/2026-09-04-baseline-find-skills-pair.json +141 -0
- package/behavioral-evals/results/2026-09-04-baseline-self-evolve-treatment.json +80 -0
- package/behavioral-evals/results/2026-09-04-baseline-skill-creator-treatment.json +80 -0
- package/behavioral-evals/results/2026-09-04-summary-both.json +41 -0
- package/behavioral-evals/run-with-plugin.js +15 -31
- package/behavioral-evals/run.js +446 -105
- package/behavioral-evals/transcript-parser.js +591 -0
- package/bin/cli.js +24 -12
- package/ci/ab-test-cases/grill-me-adversarial.yaml +14 -4
- package/ci/ab-test-cases/tdd-test-first.yaml +13 -6
- package/ci/ab-test-cases/verification-loop-gates.yaml +20 -7
- package/ci/ab-test-cases/verify-before-claim-cites.yaml +7 -6
- package/ci/ab-test-harness.js +113 -38
- package/ci/action-gate-platform-doc.test.js +31 -0
- package/ci/action-gate.test.js +260 -0
- package/ci/cases/case2.json +2 -2
- package/ci/consistency-check.js +51 -5
- package/ci/description-collision.js +15 -6
- package/ci/disclosure-check.js +225 -0
- package/ci/doc-capability-consistency.test.js +180 -0
- package/ci/fixtures/phase4/parallel-disjoint.stages.json +32 -0
- package/ci/fixtures/phase4/parallel-read-only.stages.json +32 -0
- package/ci/installer-roundtrip.test.js +159 -0
- package/ci/invariant-routing.test.js +74 -0
- package/ci/issue99-runtime.test.js +218 -0
- package/ci/mechanism-2aa-codex-action-gate-policy.test.js +117 -0
- package/ci/mechanism-2ab-openai-plugin-sync-integrity.test.js +80 -0
- package/ci/mechanism-2j-behavioral-runner.test.js +43 -1
- package/ci/mechanism-2k-reference-check.test.js +57 -2
- package/ci/mechanism-2l-multi-agent-workspace.test.js +202 -6
- package/ci/mechanism-2m-self-repo-guard.test.js +65 -0
- package/ci/mechanism-2n-opencode-plugin.test.js +461 -0
- package/ci/mechanism-2o-state-home-isolation.test.js +183 -0
- package/ci/mechanism-2p-installer-links.test.js +183 -0
- package/ci/mechanism-2q-installer-global-shared-store.test.js +132 -0
- package/ci/mechanism-2r-uninstall-flags.test.js +148 -0
- package/ci/mechanism-2s-tdd-quality.test.js +203 -0
- package/ci/mechanism-2t-disclosure.test.js +90 -0
- package/ci/mechanism-2t-evidence-triage.test.js +200 -0
- package/ci/mechanism-2t-issue-20.test.js +75 -0
- package/ci/mechanism-2t-platform-skill-targets.test.js +164 -0
- package/ci/mechanism-2t-transcript-parser.test.js +179 -0
- package/ci/mechanism-2t-workspace-identity.test.js +200 -0
- package/ci/mechanism-2u-issue-42-regressions.test.js +239 -0
- package/ci/mechanism-2u-issue-44.test.js +35 -0
- package/ci/mechanism-2v-verifier-boundaries.test.js +138 -0
- package/ci/mechanism-2w-platform-compatibility.test.js +148 -0
- package/ci/mechanism-2x-release-automation.test.js +157 -0
- package/ci/mechanism-2x-release-commit-message.test.js +66 -0
- package/ci/mechanism-2y-release-tooling-compat.test.js +47 -0
- package/ci/mechanism-2z-claude-plugin-manifest.test.js +29 -0
- package/ci/mutation-check.js +53 -0
- package/ci/mutation-loader.js +57 -0
- package/ci/negative-controls.js +76 -46
- package/ci/openai-plugin-package.test.js +182 -0
- package/ci/openai-plugin-runtime.test.js +175 -0
- package/ci/openai-plugin-submission.test.js +101 -0
- package/ci/phase4-ensemble-memory.test.js +307 -0
- package/ci/reference-check.js +73 -25
- package/ci/release-consistency-check.js +24 -1
- package/ci/repository-contract.test.js +17 -0
- package/ci/router-phase2-safety.test.js +81 -0
- package/ci/router-workflow-plan.test.js +264 -0
- package/ci/routing-check.js +6 -5
- package/ci/runner.js +6 -5
- package/ci/skill-routing-check.js +48 -11
- package/ci/test-behavioral-case-validation.js +62 -0
- package/ci/test-helper.js +10 -0
- package/ci/workflow-plan-consumers-edge.test.js +72 -0
- package/ci/workflow-plan-consumers.test.js +276 -0
- package/docs/architecture.md +137 -57
- package/docs/audit.md +22 -20
- package/docs/codex-action-gate.md +90 -0
- package/docs/issue-20-rollup.md +47 -0
- package/docs/mechanism-first-skill-mesh.md +22 -20
- package/docs/openai-plugin.md +118 -0
- package/docs/philosophy.md +28 -17
- package/docs/platform-capabilities.md +73 -0
- package/docs/platform-compatibility.json +270 -0
- package/docs/reflection.md +37 -22
- package/docs/release-evidence.md +27 -0
- package/docs/repository-contract.md +27 -0
- package/docs/routing.md +157 -44
- package/docs/security-audit.md +38 -0
- package/docs/troubleshooting.md +94 -51
- package/docs/verifier-boundaries.md +45 -0
- package/docs/workflows/fable-mode.md +77 -21
- package/docs/workflows/find-skills.md +40 -0
- package/docs/workflows/grill-with-docs.md +2 -2
- package/docs/workflows/multi-agent-workspace.md +22 -10
- package/docs/workflows/self-evolve.md +33 -0
- package/docs/workflows/tdd.md +36 -0
- package/docs/workflows/todo-driven-workflow.md +33 -0
- package/environment-detection/SKILL.md +3 -3
- package/eval-harness/SKILL.md +7 -7
- package/eval-harness/scripts/evaluate.js +12 -10
- package/evals/evaluation-reports.md +14 -0
- package/evals/harness-everything/tasks/positive-tier1.yaml +1 -1
- package/evals/harness-everything/tasks/positive-tier2.yaml +1 -1
- package/evals/harness-everything/tasks/positive-tier3.yaml +1 -1
- package/evals/install-cognitive-os/tasks/positive-trigger.yaml +1 -1
- package/fable-discipline/SKILL.md +2 -2
- package/fable-mode/CONTRACT-FORMAT.md +147 -33
- package/fable-mode/SKILL.md +3 -3
- package/fable-mode/agents/fable-orchestrator.md +95 -35
- package/fable-mode/execution-guardrails/SKILL.md +2 -2
- package/fable-mode/fable-haiku/SKILL.md +3 -3
- package/fable-mode/fable-opus/SKILL.md +3 -3
- package/fable-mode/fable-sonnet/SKILL.md +3 -3
- package/fable-mode/scripts/ensemble-review.js +371 -0
- package/fable-mode/scripts/model-selector.js +134 -3
- package/fable-mode/scripts/workflow-plan-consumer.js +337 -0
- package/find-skills/SKILL.md +5 -5
- package/find-skills/references/discovery-flow.md +1 -1
- package/find-skills/scripts/use-skill.js +7 -1
- package/git-commit/SKILL.md +4 -11
- package/grill-me/SKILL.md +5 -5
- package/grill-with-docs/SKILL.md +7 -7
- package/grill-with-docs/references/session-playbook.md +6 -4
- package/harness-everything/SKILL.md +23 -22
- package/harness-everything/references/router-workflow-plan.md +128 -0
- package/harness-everything/references/triage-and-tiers.md +173 -96
- package/harness-everything/schemas/router-task-shape.schema.json +126 -0
- package/harness-everything/schemas/router-workflow-plan.schema.json +149 -0
- package/harness-everything/scripts/bootstrap.js +13 -4
- package/harness-everything/scripts/ensemble-policy.js +102 -0
- package/harness-everything/scripts/kernel-router.js +212 -0
- package/harness-everything/scripts/router-contract.js +612 -0
- package/harness-everything/scripts/self-heal.js +29 -20
- package/harness-everything/scripts/tier-router.js +346 -221
- package/hooks/hooks.json +60 -15
- package/hooks/scripts/action-gate-rules.json +77 -0
- package/hooks/scripts/action-gate.js +528 -0
- package/hooks/scripts/atomic-commit-check.js +5 -5
- package/hooks/scripts/codex-action-gate-post.js +46 -0
- package/hooks/scripts/codex-permission-request.js +140 -0
- package/hooks/scripts/context-compact.js +4 -3
- package/hooks/scripts/contract-test.js +118 -51
- package/hooks/scripts/lib/fable-contracts.js +121 -0
- package/hooks/scripts/lib/harness-state.js +164 -28
- package/hooks/scripts/lib/platforms/claude.js +45 -62
- package/hooks/scripts/lib/platforms/codex.js +35 -61
- package/hooks/scripts/lib/platforms/continue.js +7 -7
- package/hooks/scripts/lib/platforms/copilot.js +29 -53
- package/hooks/scripts/lib/platforms/hermes.js +71 -20
- package/hooks/scripts/openai-session-start.js +81 -0
- package/hooks/scripts/rule-of-3-tracker.js +9 -8
- package/hooks/scripts/rule-of-3.js +29 -21
- package/hooks/scripts/state-persist.js +5 -4
- package/hooks/scripts/stop-gate.js +2 -2
- package/hooks/scripts/subagent-scope-guard.js +144 -38
- package/hooks/scripts/subagent-start.js +19 -0
- package/hooks/scripts/subagent-stop.js +6 -0
- package/improve-codebase-architecture/SKILL.md +2 -4
- package/improve-codebase-architecture/references/README.md +16 -0
- package/install-cognitive-os/SKILL.md +28 -22
- package/multi-agent-workspace/SKILL.md +16 -15
- package/multi-agent-workspace/references/architecture-guide.md +13 -9
- package/multi-agent-workspace/references/orchestration.md +39 -22
- package/multi-agent-workspace/scripts/consume-workflow-plan.js +129 -0
- package/multi-agent-workspace/scripts/index_memory.js +79 -26
- package/multi-agent-workspace/scripts/path-boundary.js +59 -0
- package/multi-agent-workspace/scripts/project-docs-resolver.js +357 -0
- package/multi-agent-workspace/scripts/scaffold.js +258 -103
- package/multi-agent-workspace/templates/AGENTS.md +20 -0
- package/multi-agent-workspace/workflows/03-generation.md +8 -10
- package/multi-agent-workspace/workflows/04-launcher.md +5 -5
- package/opencode-plugin/README.md +114 -71
- package/opencode-plugin/hooks/verify.js +62 -12
- package/opencode-plugin/index.mjs +547 -0
- package/opencode-plugin/plugin.json +4 -12
- package/package.json +20 -4
- package/plugins/harness-everything/.codex-plugin/plugin.json +39 -0
- package/plugins/harness-everything/hooks/hooks.json +197 -0
- package/plugins/harness-everything/hooks/scripts/action-gate-rules.json +77 -0
- package/plugins/harness-everything/hooks/scripts/action-gate.js +528 -0
- package/plugins/harness-everything/hooks/scripts/atomic-commit-check.js +68 -0
- package/plugins/harness-everything/hooks/scripts/boundary-guard.js +55 -0
- package/plugins/harness-everything/hooks/scripts/codex-action-gate-post.js +46 -0
- package/plugins/harness-everything/hooks/scripts/codex-permission-request.js +140 -0
- package/plugins/harness-everything/hooks/scripts/context-compact.js +115 -0
- package/plugins/harness-everything/hooks/scripts/contract-test.js +146 -0
- package/plugins/harness-everything/hooks/scripts/depth-guard.js +65 -0
- package/plugins/harness-everything/hooks/scripts/lib/fable-contracts.js +121 -0
- package/plugins/harness-everything/hooks/scripts/lib/harness-state.js +275 -0
- package/plugins/harness-everything/hooks/scripts/lib/platforms/claude.js +168 -0
- package/plugins/harness-everything/hooks/scripts/lib/platforms/codex.js +88 -0
- package/plugins/harness-everything/hooks/scripts/lib/platforms/continue.js +91 -0
- package/plugins/harness-everything/hooks/scripts/lib/platforms/copilot.js +85 -0
- package/plugins/harness-everything/hooks/scripts/lib/platforms/cursor.js +89 -0
- package/plugins/harness-everything/hooks/scripts/lib/platforms/hermes.js +108 -0
- package/plugins/harness-everything/hooks/scripts/lib/platforms/index.js +17 -0
- package/plugins/harness-everything/hooks/scripts/lib/platforms/worktrees.js +20 -0
- package/plugins/harness-everything/hooks/scripts/lib/workspace.js +290 -0
- package/plugins/harness-everything/hooks/scripts/openai-session-start.js +81 -0
- package/plugins/harness-everything/hooks/scripts/reset-circuit-breaker.js +30 -0
- package/plugins/harness-everything/hooks/scripts/rule-of-3-tracker.js +125 -0
- package/plugins/harness-everything/hooks/scripts/rule-of-3.js +195 -0
- package/plugins/harness-everything/hooks/scripts/state-persist.js +100 -0
- package/plugins/harness-everything/hooks/scripts/stop-gate.js +80 -0
- package/plugins/harness-everything/hooks/scripts/subagent-scope-guard.js +194 -0
- package/plugins/harness-everything/hooks/scripts/subagent-start.js +19 -0
- package/plugins/harness-everything/hooks/scripts/subagent-stop.js +6 -0
- package/plugins/harness-everything/hooks/session-start.js +81 -0
- package/plugins/harness-everything/plugin.json +43 -0
- package/plugins/harness-everything/scripts/lib/advisory-text.js +174 -0
- package/plugins/harness-everything/skills/environment-detection/SKILL.md +41 -0
- package/plugins/harness-everything/skills/environment-detection/references/shell-syntax-rules.md +76 -0
- package/plugins/harness-everything/skills/environment-detection/scripts/preflight.js +103 -0
- package/plugins/harness-everything/skills/eval-harness/SKILL.md +42 -0
- package/plugins/harness-everything/skills/eval-harness/references/scoring-rubric.md +68 -0
- package/plugins/harness-everything/skills/eval-harness/scripts/evaluate.js +79 -0
- package/plugins/harness-everything/skills/fable-discipline/SKILL.md +41 -0
- package/plugins/harness-everything/skills/fable-discipline/references/discipline-rules.md +22 -0
- package/plugins/harness-everything/skills/fable-mode/CONTRACT-FORMAT.md +165 -0
- package/plugins/harness-everything/skills/fable-mode/SKILL.md +39 -0
- package/plugins/harness-everything/skills/fable-mode/agents/fable-orchestrator.md +159 -0
- package/plugins/harness-everything/skills/fable-mode/agents/fable-verifier.md +32 -0
- package/plugins/harness-everything/skills/fable-mode/agents/fable-worker-haiku.md +52 -0
- package/plugins/harness-everything/skills/fable-mode/agents/fable-worker-sonnet.md +53 -0
- package/plugins/harness-everything/skills/fable-mode/execution-guardrails/SKILL.md +43 -0
- package/plugins/harness-everything/skills/fable-mode/execution-guardrails/references/guardrail-rules.md +56 -0
- package/plugins/harness-everything/skills/fable-mode/fable-haiku/SKILL.md +36 -0
- package/plugins/harness-everything/skills/fable-mode/fable-haiku/references/routing-notes.md +26 -0
- package/plugins/harness-everything/skills/fable-mode/fable-opus/SKILL.md +36 -0
- package/plugins/harness-everything/skills/fable-mode/fable-sonnet/SKILL.md +36 -0
- package/plugins/harness-everything/skills/fable-mode/model-matrix.json +32 -0
- package/plugins/harness-everything/skills/fable-mode/references/execution-phases.md +37 -0
- package/plugins/harness-everything/skills/fable-mode/references/model-matrix.md +39 -0
- package/plugins/harness-everything/skills/fable-mode/scripts/ensemble-review.js +371 -0
- package/plugins/harness-everything/skills/fable-mode/scripts/model-selector.js +260 -0
- package/plugins/harness-everything/skills/fable-mode/scripts/workflow-plan-consumer.js +337 -0
- package/plugins/harness-everything/skills/find-skills/SKILL.md +48 -0
- package/plugins/harness-everything/skills/find-skills/references/discovery-flow.md +102 -0
- package/plugins/harness-everything/skills/find-skills/scripts/use-skill.js +112 -0
- package/plugins/harness-everything/skills/git-commit/SKILL.md +38 -0
- package/plugins/harness-everything/skills/git-commit/guides/ANGULAR_STYLE.md +61 -0
- package/plugins/harness-everything/skills/git-commit/guides/COMMIT_GENERATION.md +24 -0
- package/plugins/harness-everything/skills/git-commit/guides/LANGUAGE_DETECTION.md +16 -0
- package/plugins/harness-everything/skills/git-commit/guides/MAIN_REPO.md +15 -0
- package/plugins/harness-everything/skills/git-commit/guides/SUBMODULES.md +27 -0
- package/plugins/harness-everything/skills/git-commit/references/commit-flow.md +30 -0
- package/plugins/harness-everything/skills/grill-me/SKILL.md +43 -0
- package/plugins/harness-everything/skills/grill-me/references/grilling-playbook.md +38 -0
- package/plugins/harness-everything/skills/grill-with-docs/ADR-FORMAT.md +47 -0
- package/plugins/harness-everything/skills/grill-with-docs/CONTEXT-FORMAT.md +63 -0
- package/plugins/harness-everything/skills/grill-with-docs/SKILL.md +41 -0
- package/plugins/harness-everything/skills/grill-with-docs/references/session-playbook.md +99 -0
- package/plugins/harness-everything/skills/harness-everything/SKILL.md +43 -0
- package/plugins/harness-everything/skills/harness-everything/examples/README.md +9 -0
- package/plugins/harness-everything/skills/harness-everything/examples/todo-workflow.md +22 -0
- package/plugins/harness-everything/skills/harness-everything/references/router-workflow-plan.md +128 -0
- package/plugins/harness-everything/skills/harness-everything/references/skill-registry.md +39 -0
- package/plugins/harness-everything/skills/harness-everything/references/triage-and-tiers.md +193 -0
- package/plugins/harness-everything/skills/harness-everything/schemas/router-task-shape.schema.json +126 -0
- package/plugins/harness-everything/skills/harness-everything/schemas/router-workflow-plan.schema.json +149 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/bootstrap.js +212 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/ensemble-policy.js +102 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router.js +212 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/router-contract.js +612 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/routing-keywords.json +320 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/self-heal.js +250 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/tier-router.js +459 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/verify-gate.js +100 -0
- package/plugins/harness-everything/skills/improve-codebase-architecture/SKILL.md +38 -0
- package/plugins/harness-everything/skills/improve-codebase-architecture/guides/DEEPENING.md +37 -0
- package/plugins/harness-everything/skills/improve-codebase-architecture/guides/HTML-REPORT.md +123 -0
- package/plugins/harness-everything/skills/improve-codebase-architecture/guides/INTERFACE-DESIGN.md +44 -0
- package/plugins/harness-everything/skills/improve-codebase-architecture/guides/LANGUAGE.md +53 -0
- package/plugins/harness-everything/skills/improve-codebase-architecture/guides/refactoring-workflow.md +59 -0
- package/plugins/harness-everything/skills/improve-codebase-architecture/references/README.md +16 -0
- package/plugins/harness-everything/skills/install-cognitive-os/SKILL.md +44 -0
- package/plugins/harness-everything/skills/install-cognitive-os/references/cognitive-loop.md +27 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/NOTICE-agency-agents.md +27 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/SKILL.md +38 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/examples/csharp-monorepo.md +123 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/examples/typescript-cli.md +126 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/guidelines/platform-claude.md +77 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/guidelines/platform-codex.md +146 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/guidelines/platform-continue.md +38 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/guidelines/platform-copilot.md +74 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/guidelines/platform-cursor.md +40 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/guidelines/platform-hermes.md +38 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/guidelines/role-capabilities.md +108 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/references/agency-agents.md +31 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/references/architecture-guide.md +36 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/references/orchestration.md +65 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/scripts/agency-catalog.js +190 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/scripts/consume-workflow-plan.js +129 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/scripts/index_memory.js +104 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/scripts/path-boundary.js +59 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/scripts/project-docs-resolver.js +357 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/scripts/scaffold.js +408 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/AGENTS.md +20 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/README.md +17 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/agent-launcher.md +68 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/backend-developer-csharp.md +56 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/backend-developer-polyglot.md +62 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/backend-developer-ts.md +57 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/memory-keeper.md +37 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/requirement-analyzer.md +66 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/specialist-agent.md +34 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/task-verifier.md +56 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/tool-maker.md +33 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/workflows/01-init.md +22 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/workflows/02-analysis.md +23 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/workflows/03-generation.md +25 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/workflows/04-launcher.md +16 -0
- package/plugins/harness-everything/skills/repo-docs/SKILL.md +42 -0
- package/plugins/harness-everything/skills/repo-docs/references/process-guide.md +60 -0
- package/plugins/harness-everything/skills/repo-docs/templates/agents-template.md +264 -0
- package/plugins/harness-everything/skills/repo-docs/templates/knowledge-agents-template.md +50 -0
- package/plugins/harness-everything/skills/repo-docs/templates/knowledge-readme-template.md +83 -0
- package/plugins/harness-everything/skills/repo-docs/templates/manual-recon.md +117 -0
- package/plugins/harness-everything/skills/repo-docs/templates/multi-skills-readme-template.md +72 -0
- package/plugins/harness-everything/skills/repo-docs/templates/product-agents-template.md +78 -0
- package/plugins/harness-everything/skills/repo-docs/templates/product-readme-template.md +95 -0
- package/plugins/harness-everything/skills/repo-docs/templates/readme-template.md +136 -0
- package/plugins/harness-everything/skills/repo-docs/templates/single-skill-readme-template.md +70 -0
- package/plugins/harness-everything/skills/repo-docs/templates/skills-agents-template.md +60 -0
- package/plugins/harness-everything/skills/rewrite-commits/SKILL.md +37 -0
- package/plugins/harness-everything/skills/rewrite-commits/references/workflow.md +18 -0
- package/plugins/harness-everything/skills/security-review/SKILL.md +47 -0
- package/plugins/harness-everything/skills/security-review/guides/OWASP-PATTERNS.md +31 -0
- package/plugins/harness-everything/skills/security-review/guides/STRIDE-THREAT-MODEL.md +21 -0
- package/plugins/harness-everything/skills/security-review/references/security-checklist.md +478 -0
- package/plugins/harness-everything/skills/security-review/scripts/audit-secrets.js +85 -0
- package/plugins/harness-everything/skills/self-evolve/SKILL.md +45 -0
- package/plugins/harness-everything/skills/self-evolve/references/memory-resolution.md +61 -0
- package/plugins/harness-everything/skills/self-evolve/scripts/persist-memory.js +272 -0
- package/plugins/harness-everything/skills/self-evolve/scripts/register-dynamic-skill.js +253 -0
- package/plugins/harness-everything/skills/self-evolve/scripts/self-regression.js +125 -0
- package/plugins/harness-everything/skills/skill-creator/SKILL.md +47 -0
- package/plugins/harness-everything/skills/skill-creator/references/authoring-workflow.md +14 -0
- package/plugins/harness-everything/skills/skill-creator/references/dynamic-generation-contract.md +21 -0
- package/plugins/harness-everything/skills/skill-creator/references/quality-checklist.md +16 -0
- package/plugins/harness-everything/skills/skill-creator/references/quality-principles.md +81 -0
- package/plugins/harness-everything/skills/skill-creator/references/testing-workflow.md +27 -0
- package/plugins/harness-everything/skills/skill-style/SKILL.md +42 -0
- package/plugins/harness-everything/skills/skill-style/references/style-guide.md +62 -0
- package/plugins/harness-everything/skills/tdd/SKILL.md +38 -0
- package/plugins/harness-everything/skills/tdd/fixtures/pass-evidence.json +100 -0
- package/plugins/harness-everything/skills/tdd/fixtures/quality-scenarios.json +20 -0
- package/plugins/harness-everything/skills/tdd/guides/deep-modules.md +33 -0
- package/plugins/harness-everything/skills/tdd/guides/interface-design.md +31 -0
- package/plugins/harness-everything/skills/tdd/guides/mocking.md +59 -0
- package/plugins/harness-everything/skills/tdd/guides/refactoring.md +10 -0
- package/plugins/harness-everything/skills/tdd/guides/tests.md +61 -0
- package/plugins/harness-everything/skills/tdd/references/core-discipline.md +51 -0
- package/plugins/harness-everything/skills/tdd/references/integration-testing.md +13 -0
- package/plugins/harness-everything/skills/tdd/references/quality-model.md +68 -0
- package/plugins/harness-everything/skills/tdd/references/unit-testing.md +15 -0
- package/plugins/harness-everything/skills/tdd/schemas/quality-evidence.schema.json +211 -0
- package/plugins/harness-everything/skills/tdd/schemas/quality-report.schema.json +110 -0
- package/plugins/harness-everything/skills/tdd/scripts/quality-gate.js +475 -0
- package/plugins/harness-everything/skills/to-spec/SKILL.md +40 -0
- package/plugins/harness-everything/skills/to-spec/references/process.md +77 -0
- package/plugins/harness-everything/skills/to-spec/scripts/check-project-docs.js +239 -0
- package/plugins/harness-everything/skills/to-spec/scripts/project-docs-resolver.js +111 -0
- package/plugins/harness-everything/skills/to-spec/templates/cli-reference.md +31 -0
- package/plugins/harness-everything/skills/to-spec/templates/dev-doc.md +27 -0
- package/plugins/harness-everything/skills/to-spec/templates/feature-spec.md +59 -0
- package/plugins/harness-everything/skills/to-spec/templates/schema-doc.md +31 -0
- package/plugins/harness-everything/skills/to-tickets/SKILL.md +42 -0
- package/plugins/harness-everything/skills/to-tickets/references/publishing-and-templates.md +97 -0
- package/plugins/harness-everything/skills/todo-driven-workflow/SKILL.md +42 -0
- package/plugins/harness-everything/skills/todo-driven-workflow/references/execution-guide.md +27 -0
- package/plugins/harness-everything/skills/using-git-worktrees/SKILL.md +49 -0
- package/plugins/harness-everything/skills/using-git-worktrees/references/workflow-details.md +108 -0
- package/plugins/harness-everything/skills/verification-loop/SKILL.md +46 -0
- package/plugins/harness-everything/skills/verification-loop/references/verification-phases.md +116 -0
- package/plugins/harness-everything/skills/verification-loop/templates/verification-report.template.md +15 -0
- package/plugins/harness-everything/skills/verify-before-claim/SKILL.md +43 -0
- package/plugins/harness-everything/skills/verify-before-claim/references/verification-guide.md +73 -0
- package/plugins/harness-everything/skills/zoom-out/SKILL.md +42 -0
- package/plugins/harness-everything/skills/zoom-out/references/circuit-breaker.md +66 -0
- package/plugins/harness-everything/skills/zoom-out/templates/zoom-out-report.template.md +20 -0
- package/repo-docs/SKILL.md +3 -7
- package/rewrite-commits/SKILL.md +2 -2
- package/scripts/build-openai-submission.js +158 -0
- package/scripts/installer.js +86 -11
- package/scripts/lib/advisory-text.js +25 -18
- package/scripts/lib/execution-contract.js +70 -0
- package/scripts/lib/manifest.js +34 -38
- package/scripts/lib/path-boundary.js +90 -0
- package/scripts/lib/skills.js +124 -70
- package/scripts/lib/workspace.js +269 -7
- package/scripts/repository-contract.js +213 -0
- package/scripts/sync-current-docs.js +12 -0
- package/scripts/sync-openai-plugin.js +91 -0
- package/scripts/sync-release-version.js +212 -0
- package/security-review/SKILL.md +4 -7
- package/security-review/scripts/audit-secrets.js +9 -8
- package/self-evolve/SKILL.md +9 -11
- package/self-evolve/references/memory-resolution.md +4 -1
- package/self-evolve/scripts/persist-memory.js +221 -88
- package/self-evolve/scripts/register-dynamic-skill.js +12 -10
- package/self-evolve/scripts/self-regression.js +23 -8
- package/skill-creator/SKILL.md +12 -14
- package/skill-creator/references/quality-checklist.md +1 -0
- package/skill-style/SKILL.md +4 -4
- package/skill-style/references/style-guide.md +29 -3
- package/submission/openai/README.md +67 -0
- package/submission/openai/listing.json +31 -0
- package/submission/openai/test-cases.json +61 -0
- package/tdd/SKILL.md +20 -26
- package/tdd/fixtures/pass-evidence.json +100 -0
- package/tdd/fixtures/quality-scenarios.json +20 -0
- package/tdd/references/core-discipline.md +2 -0
- package/tdd/references/integration-testing.md +13 -0
- package/tdd/references/quality-model.md +68 -0
- package/tdd/references/unit-testing.md +15 -0
- package/tdd/schemas/quality-evidence.schema.json +211 -0
- package/tdd/schemas/quality-report.schema.json +110 -0
- package/tdd/scripts/quality-gate.js +475 -0
- package/to-spec/SKILL.md +3 -5
- package/to-spec/scripts/check-project-docs.js +42 -62
- package/to-spec/scripts/project-docs-resolver.js +111 -0
- package/to-tickets/SKILL.md +4 -4
- package/todo-driven-workflow/SKILL.md +6 -4
- package/using-git-worktrees/SKILL.md +3 -3
- package/verification-loop/SKILL.md +4 -4
- package/verify-before-claim/SKILL.md +2 -2
- package/zoom-out/SKILL.md +4 -4
- package/ab-test-deep-analysis-2026-08-27.md +0 -383
- package/ab-test-results-2026-08-27.md +0 -152
- package/ab-test-statistical-analysis-31cases.md +0 -193
- package/opencode-plugin/hooks/circuit-breaker.js +0 -121
- package/opencode-plugin/hooks/compliance.js +0 -128
- package/opencode-plugin/hooks/post-edit.js +0 -62
- package/opencode-plugin/hooks/pre-complete.js +0 -65
- package/opencode-plugin/test-hook-firing.js +0 -198
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { commandMatches } = require('../scripts/lib/execution-contract');
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
|
|
7
|
+
const DENIAL_RE = /permission\s+denied|\bdenied\b|not\s+allowed|rejected|forbidden|blocked\s+by|approval\s+required/i;
|
|
8
|
+
const SUCCESS_RE = /^(?:complete(?:d)?|success(?:ful)?|succeeded|ok|done|finished)$/i;
|
|
9
|
+
const FAILURE_RE = /^(?:error|failed|failure|cancel(?:led)?)$/i;
|
|
10
|
+
|
|
11
|
+
function isObject(value) {
|
|
12
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function firstDefined(...values) {
|
|
16
|
+
return values.find(value => value !== undefined && value !== null);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function stableJson(value) {
|
|
20
|
+
if (value === undefined) return '';
|
|
21
|
+
if (value === null || typeof value !== 'object') return JSON.stringify(value);
|
|
22
|
+
if (Array.isArray(value)) return `[${value.map(stableJson).join(',')}]`;
|
|
23
|
+
return `{${Object.keys(value).sort().map(key => `${JSON.stringify(key)}:${stableJson(value[key])}`).join(',')}}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function clone(value) {
|
|
27
|
+
if (value === undefined) return undefined;
|
|
28
|
+
return JSON.parse(JSON.stringify(value));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function makeMetadata() {
|
|
32
|
+
return {
|
|
33
|
+
cost: null,
|
|
34
|
+
total_cost_usd: null,
|
|
35
|
+
cost_usd: null,
|
|
36
|
+
usage: null,
|
|
37
|
+
duration_ms: null,
|
|
38
|
+
num_turns: null,
|
|
39
|
+
session_id: null,
|
|
40
|
+
model: null,
|
|
41
|
+
model_usage: null,
|
|
42
|
+
modelUsage: null,
|
|
43
|
+
cli_version: null,
|
|
44
|
+
subtype: null,
|
|
45
|
+
is_error: null,
|
|
46
|
+
permission_denials: [],
|
|
47
|
+
result: null,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function makeContext(engine, format, visibility = 'structured') {
|
|
52
|
+
return {
|
|
53
|
+
engine,
|
|
54
|
+
format,
|
|
55
|
+
visibility,
|
|
56
|
+
metadata: makeMetadata(),
|
|
57
|
+
finalResult: null,
|
|
58
|
+
sawResult: false,
|
|
59
|
+
sawRecognizedEvent: false,
|
|
60
|
+
sawAssistantEvent: false,
|
|
61
|
+
textChunks: [],
|
|
62
|
+
partialTextChunks: [],
|
|
63
|
+
calls: [],
|
|
64
|
+
callsById: new Map(),
|
|
65
|
+
callsByAnonymousKey: new Map(),
|
|
66
|
+
resultKeys: new Set(),
|
|
67
|
+
streamToolIndexes: new Map(),
|
|
68
|
+
streamToolInput: new Map(),
|
|
69
|
+
nextAnonymousId: 1,
|
|
70
|
+
orderedEvents: [],
|
|
71
|
+
nextSequence: 0,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function appendUnique(list, value) {
|
|
76
|
+
if (typeof value !== 'string' || !value) return;
|
|
77
|
+
if (list[list.length - 1] !== value) list.push(value);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function appendText(context, list, value) {
|
|
81
|
+
const before = list.length;
|
|
82
|
+
appendUnique(list, value);
|
|
83
|
+
if (list.length > before) {
|
|
84
|
+
context.orderedEvents.push({ kind: 'text', text: value, sequence: context.nextSequence++ });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function normalizeId(value) {
|
|
89
|
+
if (typeof value === 'string' && value.trim()) return value;
|
|
90
|
+
if (typeof value === 'number') return String(value);
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function callIdentity(name, input) {
|
|
95
|
+
return `${name || 'tool'}|${stableJson(input)}`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function getCallId(value) {
|
|
99
|
+
if (!isObject(value)) return null;
|
|
100
|
+
return normalizeId(firstDefined(value.id, value.tool_use_id, value.callID, value.call_id, value.callId));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function findCall(context, details = {}) {
|
|
104
|
+
const id = getCallId(details);
|
|
105
|
+
// An explicit ID is authoritative. Falling back to the anonymous
|
|
106
|
+
// name/input key would merge two distinct calls that happen to have the
|
|
107
|
+
// same arguments.
|
|
108
|
+
if (id) return context.callsById.get(id) || null;
|
|
109
|
+
const name = firstDefined(details.name, details.tool_name, details.tool);
|
|
110
|
+
const input = firstDefined(details.input, details.tool_input);
|
|
111
|
+
if (name !== undefined || input !== undefined) {
|
|
112
|
+
const key = callIdentity(name, input);
|
|
113
|
+
return context.callsByAnonymousKey.get(key) || null;
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function ensureCall(context, details = {}) {
|
|
119
|
+
const name = String(firstDefined(details.name, details.tool_name, details.tool, 'tool'));
|
|
120
|
+
const input = firstDefined(details.input, details.tool_input, {});
|
|
121
|
+
const suppliedId = getCallId(details);
|
|
122
|
+
const anonymousKey = callIdentity(name, input);
|
|
123
|
+
const existing = suppliedId
|
|
124
|
+
? context.callsById.get(suppliedId)
|
|
125
|
+
: context.callsByAnonymousKey.get(anonymousKey);
|
|
126
|
+
if (existing) {
|
|
127
|
+
if (suppliedId) context.callsById.set(suppliedId, existing);
|
|
128
|
+
if (details.input !== undefined || details.tool_input !== undefined) existing.input = clone(input);
|
|
129
|
+
if (details.name || details.tool_name || details.tool) existing.name = name;
|
|
130
|
+
if (!existing.explicitId) {
|
|
131
|
+
existing.anonymousKey = callIdentity(existing.name, existing.input);
|
|
132
|
+
context.callsByAnonymousKey.set(existing.anonymousKey, existing);
|
|
133
|
+
}
|
|
134
|
+
return existing;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const id = suppliedId || `anonymous-tool-${context.nextAnonymousId++}`;
|
|
138
|
+
const call = {
|
|
139
|
+
id,
|
|
140
|
+
name,
|
|
141
|
+
input: clone(input),
|
|
142
|
+
attempted: true,
|
|
143
|
+
completed: false,
|
|
144
|
+
denied: false,
|
|
145
|
+
status: 'attempted',
|
|
146
|
+
result_count: 0,
|
|
147
|
+
explicitId: Boolean(suppliedId),
|
|
148
|
+
anonymousKey: suppliedId ? null : anonymousKey,
|
|
149
|
+
};
|
|
150
|
+
context.calls.push(call);
|
|
151
|
+
call.sequence = context.nextSequence++;
|
|
152
|
+
context.orderedEvents.push({ kind: 'tool', call });
|
|
153
|
+
context.callsById.set(id, call);
|
|
154
|
+
if (!suppliedId) context.callsByAnonymousKey.set(anonymousKey, call);
|
|
155
|
+
return call;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function statusFrom(details = {}, result = {}) {
|
|
159
|
+
const text = [
|
|
160
|
+
details.status,
|
|
161
|
+
result.status,
|
|
162
|
+
result.subtype,
|
|
163
|
+
result.error,
|
|
164
|
+
result.error_message,
|
|
165
|
+
].filter(value => typeof value === 'string').join(' ');
|
|
166
|
+
if (details.denied || details.permission_denied || result.denied || result.permission_denied || DENIAL_RE.test(text)) return 'denied';
|
|
167
|
+
if (result.type === 'tool_result' || result.type === 'tool_output') return result.is_error === true ? 'failed' : 'completed';
|
|
168
|
+
if (result.is_error === false || details.is_error === false || SUCCESS_RE.test(String(firstDefined(details.status, result.status, '')))) return 'completed';
|
|
169
|
+
if (result.is_error === true || FAILURE_RE.test(String(firstDefined(details.status, result.status, '')))) return 'failed';
|
|
170
|
+
if (SUCCESS_RE.test(String(firstDefined(result.subtype, '')))) return 'completed';
|
|
171
|
+
return 'attempted';
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function applyStatus(call, status) {
|
|
175
|
+
if (status === 'denied') {
|
|
176
|
+
call.denied = true;
|
|
177
|
+
call.completed = false;
|
|
178
|
+
call.status = 'denied';
|
|
179
|
+
} else if (status === 'completed') {
|
|
180
|
+
call.completed = true;
|
|
181
|
+
if (!call.denied) call.status = 'completed';
|
|
182
|
+
} else if (!call.completed && !call.denied && status === 'failed') {
|
|
183
|
+
call.status = 'failed';
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function addToolResult(context, details = {}, result = {}, forcedStatus) {
|
|
188
|
+
const call = findCall(context, details) || ensureCall(context, details);
|
|
189
|
+
const status = forcedStatus || statusFrom(details, result);
|
|
190
|
+
const content = firstDefined(result.content, result.output, details.output, details.content, null);
|
|
191
|
+
const resultKey = `${call.id}|${status}|${stableJson(content)}|${result.is_error === true ? 'error' : ''}`;
|
|
192
|
+
if (!context.resultKeys.has(resultKey)) {
|
|
193
|
+
context.resultKeys.add(resultKey);
|
|
194
|
+
call.result_count += 1;
|
|
195
|
+
}
|
|
196
|
+
applyStatus(call, status);
|
|
197
|
+
return call;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function addToolCall(context, details = {}) {
|
|
201
|
+
const call = ensureCall(context, details);
|
|
202
|
+
const status = statusFrom(details, details);
|
|
203
|
+
if (status !== 'attempted') applyStatus(call, status);
|
|
204
|
+
return call;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function addDenial(context, denial = {}) {
|
|
208
|
+
const details = {
|
|
209
|
+
id: firstDefined(denial.tool_use_id, denial.call_id, denial.callID, denial.id),
|
|
210
|
+
name: firstDefined(denial.tool_name, denial.name, denial.tool),
|
|
211
|
+
input: firstDefined(denial.tool_input, denial.input),
|
|
212
|
+
};
|
|
213
|
+
const call = findCall(context, details) || ensureCall(context, details);
|
|
214
|
+
addToolResult(context, details, { ...denial, denied: true, permission_denied: true }, 'denied');
|
|
215
|
+
return call;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function setMetadata(context, value, { result = false } = {}) {
|
|
219
|
+
if (!isObject(value)) return;
|
|
220
|
+
const metadata = context.metadata;
|
|
221
|
+
const cost = [value.total_cost_usd, value.cost_usd, value.cost].find(item => typeof item === 'number');
|
|
222
|
+
if (cost !== undefined) metadata.cost = cost;
|
|
223
|
+
for (const key of ['total_cost_usd', 'cost_usd']) {
|
|
224
|
+
if (typeof value[key] === 'number') metadata[key] = value[key];
|
|
225
|
+
}
|
|
226
|
+
for (const key of ['duration_ms', 'num_turns']) {
|
|
227
|
+
if (typeof value[key] === 'number') metadata[key] = value[key];
|
|
228
|
+
}
|
|
229
|
+
if (isObject(value.usage)) metadata.usage = clone(value.usage);
|
|
230
|
+
if (isObject(value.modelUsage)) metadata.modelUsage = clone(value.modelUsage);
|
|
231
|
+
if (isObject(value.model_usage)) metadata.model_usage = clone(value.model_usage);
|
|
232
|
+
for (const key of ['session_id', 'model', 'claude_code_version', 'subtype']) {
|
|
233
|
+
if (value[key] !== undefined) metadata[key === 'claude_code_version' ? 'cli_version' : key] = value[key];
|
|
234
|
+
}
|
|
235
|
+
if (typeof value.is_error === 'boolean') metadata.is_error = value.is_error;
|
|
236
|
+
if (Array.isArray(value.permission_denials)) {
|
|
237
|
+
metadata.permission_denials = clone(value.permission_denials);
|
|
238
|
+
}
|
|
239
|
+
if (result) metadata.result = clone(value);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function processContent(context, content, { partial = false, includeText = true } = {}) {
|
|
243
|
+
if (Array.isArray(content)) {
|
|
244
|
+
for (const block of content) processContent(context, block, { partial, includeText });
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (typeof content === 'string') {
|
|
248
|
+
if (includeText) appendText(context, partial ? context.partialTextChunks : context.textChunks, content);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
if (!isObject(content)) return;
|
|
252
|
+
if (content.type === 'text') {
|
|
253
|
+
if (includeText) appendText(context, partial ? context.partialTextChunks : context.textChunks, content.text);
|
|
254
|
+
} else if (content.type === 'tool_use' || content.type === 'tool_call') {
|
|
255
|
+
context.sawRecognizedEvent = true;
|
|
256
|
+
addToolCall(context, {
|
|
257
|
+
id: content.id,
|
|
258
|
+
name: content.name,
|
|
259
|
+
input: content.input,
|
|
260
|
+
});
|
|
261
|
+
} else if (content.type === 'tool_result' || content.type === 'tool_output') {
|
|
262
|
+
context.sawRecognizedEvent = true;
|
|
263
|
+
addToolResult(context, {
|
|
264
|
+
id: content.tool_use_id || content.call_id || content.callID,
|
|
265
|
+
name: content.tool_name || content.name,
|
|
266
|
+
}, content);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function processClaudeEvent(context, event) {
|
|
271
|
+
if (!isObject(event) || typeof event.type !== 'string') return;
|
|
272
|
+
const type = event.type;
|
|
273
|
+
if (type === 'system') {
|
|
274
|
+
context.sawRecognizedEvent = true;
|
|
275
|
+
setMetadata(context, event);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (type === 'assistant') {
|
|
279
|
+
context.sawRecognizedEvent = true;
|
|
280
|
+
context.sawAssistantEvent = true;
|
|
281
|
+
const message = isObject(event.message) ? event.message : event;
|
|
282
|
+
setMetadata(context, message);
|
|
283
|
+
processContent(context, message.content);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
if (type === 'user') {
|
|
287
|
+
context.sawRecognizedEvent = true;
|
|
288
|
+
const message = isObject(event.message) ? event.message : event;
|
|
289
|
+
// User events carry tool results and may also carry tool-output prose.
|
|
290
|
+
// Keep the former for correlation, but never let user text become agent
|
|
291
|
+
// trace evidence.
|
|
292
|
+
processContent(context, message.content, { includeText: false });
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
if (type === 'result') {
|
|
296
|
+
context.sawRecognizedEvent = true;
|
|
297
|
+
context.sawResult = true;
|
|
298
|
+
setMetadata(context, event, { result: true });
|
|
299
|
+
context.finalResult = typeof event.result === 'string' ? event.result : null;
|
|
300
|
+
for (const denial of event.permission_denials || []) addDenial(context, denial);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
if (type === 'stream_event') {
|
|
304
|
+
context.sawRecognizedEvent = true;
|
|
305
|
+
processClaudeStreamEvent(context, event.event || event);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
// Some Claude versions expose the inner stream event as a top-level type.
|
|
309
|
+
if (type === 'content_block_start' || type === 'content_block_delta') {
|
|
310
|
+
context.sawRecognizedEvent = true;
|
|
311
|
+
processClaudeStreamEvent(context, event);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function processClaudeStreamEvent(context, event) {
|
|
316
|
+
if (!isObject(event)) return;
|
|
317
|
+
if (event.type === 'message_start') {
|
|
318
|
+
setMetadata(context, event.message || event);
|
|
319
|
+
} else if (event.type === 'content_block_start') {
|
|
320
|
+
const block = event.content_block || {};
|
|
321
|
+
if (block.type === 'tool_use') {
|
|
322
|
+
const call = addToolCall(context, { id: block.id, name: block.name, input: block.input || {} });
|
|
323
|
+
if (event.index !== undefined) context.streamToolIndexes.set(event.index, call);
|
|
324
|
+
context.streamToolInput.set(call.id, '');
|
|
325
|
+
} else if (block.type === 'text' && typeof block.text === 'string') {
|
|
326
|
+
appendText(context, context.partialTextChunks, block.text);
|
|
327
|
+
}
|
|
328
|
+
} else if (event.type === 'content_block_delta') {
|
|
329
|
+
const delta = event.delta || {};
|
|
330
|
+
if (delta.type === 'text_delta') appendText(context, context.partialTextChunks, delta.text);
|
|
331
|
+
if (delta.type === 'input_json_delta') {
|
|
332
|
+
const call = context.streamToolIndexes.get(event.index);
|
|
333
|
+
if (call) {
|
|
334
|
+
const previous = context.streamToolInput.get(call.id) || '';
|
|
335
|
+
const next = previous + String(delta.partial_json || '');
|
|
336
|
+
context.streamToolInput.set(call.id, next);
|
|
337
|
+
try { call.input = JSON.parse(next); } catch { /* wait for the final delta */ }
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
} else if (event.type === 'message_delta') {
|
|
341
|
+
setMetadata(context, event.usage ? { usage: event.usage } : event);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function processOpencodeEvent(context, event) {
|
|
346
|
+
if (!isObject(event)) return;
|
|
347
|
+
const part = isObject(event.part) ? event.part : event;
|
|
348
|
+
const type = String(event.type || part.type || '');
|
|
349
|
+
if (type === 'text' || part.type === 'text') {
|
|
350
|
+
context.sawRecognizedEvent = true;
|
|
351
|
+
appendText(context, context.textChunks, part.text);
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
if (type === 'step_start' || type === 'step-start' || part.type === 'step-start') {
|
|
355
|
+
context.sawRecognizedEvent = true;
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
if (type === 'step_finish' || type === 'step-finish' || part.type === 'step-finish') {
|
|
359
|
+
context.sawRecognizedEvent = true;
|
|
360
|
+
setMetadata(context, {
|
|
361
|
+
cost: part.cost,
|
|
362
|
+
usage: part.tokens,
|
|
363
|
+
duration_ms: typeof event.timestamp === 'number' ? event.timestamp : undefined,
|
|
364
|
+
});
|
|
365
|
+
if (typeof context.metadata.num_turns !== 'number') context.metadata.num_turns = context.calls.length;
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
if (type.includes('tool') || String(part.type || '').includes('tool')) {
|
|
369
|
+
context.sawRecognizedEvent = true;
|
|
370
|
+
const state = isObject(part.state) ? part.state : {};
|
|
371
|
+
const details = {
|
|
372
|
+
id: firstDefined(part.callID, part.callId, part.call_id, part.id, part.tool_use_id),
|
|
373
|
+
name: firstDefined(part.tool, part.name, part.tool_name),
|
|
374
|
+
input: firstDefined(state.input, part.input, part.tool_input, part.arguments),
|
|
375
|
+
status: state.status || part.status,
|
|
376
|
+
output: firstDefined(state.output, part.output, part.result),
|
|
377
|
+
content: firstDefined(state.output, part.output, part.result),
|
|
378
|
+
};
|
|
379
|
+
const isDenied = type.includes('denied') || type.includes('rejected') || state.status === 'denied' || state.status === 'rejected' || part.denied === true || part.permission_denied === true;
|
|
380
|
+
const isResult = type.includes('result') || type.includes('output') || state.output !== undefined || state.status === 'completed' || isDenied;
|
|
381
|
+
if (isResult) addToolResult(context, details, { ...part, ...state, output: details.output, content: details.content });
|
|
382
|
+
else addToolCall(context, details);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function parseJsonLines(raw) {
|
|
387
|
+
const lines = String(raw).split(/\r?\n/);
|
|
388
|
+
const events = [];
|
|
389
|
+
const errors = [];
|
|
390
|
+
let nonEmpty = 0;
|
|
391
|
+
lines.forEach((line, index) => {
|
|
392
|
+
if (!line.trim()) return;
|
|
393
|
+
nonEmpty += 1;
|
|
394
|
+
try {
|
|
395
|
+
events.push({ line: index + 1, value: JSON.parse(line) });
|
|
396
|
+
} catch (error) {
|
|
397
|
+
errors.push(`line ${index + 1}: ${error.message}`);
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
return { events, errors, nonEmpty };
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function detectEngine(events, requested) {
|
|
404
|
+
if (requested && requested !== 'auto') return requested;
|
|
405
|
+
if (events.some(item => isObject(item.value) && isObject(item.value.part))) return 'opencode';
|
|
406
|
+
if (events.some(item => isObject(item.value) && typeof item.value.type === 'string' && item.value.type.toLowerCase().includes('tool'))) return 'opencode';
|
|
407
|
+
if (events.some(item => isObject(item.value) && ['system', 'assistant', 'user', 'result', 'stream_event'].includes(item.value.type))) return 'claude';
|
|
408
|
+
return requested || 'unknown';
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function publicCall(call) {
|
|
412
|
+
return {
|
|
413
|
+
id: call.id,
|
|
414
|
+
name: call.name,
|
|
415
|
+
input: clone(call.input),
|
|
416
|
+
attempted: true,
|
|
417
|
+
completed: call.completed,
|
|
418
|
+
denied: call.denied,
|
|
419
|
+
status: call.status,
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function finishContext(context, { parseStatus, parseError = null, rawLineCount = 0 } = {}) {
|
|
424
|
+
const assistantText = context.textChunks.length
|
|
425
|
+
? context.textChunks.join('\n')
|
|
426
|
+
: context.partialTextChunks.join('');
|
|
427
|
+
const text = assistantText || (typeof context.finalResult === 'string' ? context.finalResult : '');
|
|
428
|
+
const calls = context.visibility === 'unavailable' ? [] : context.calls.map(publicCall);
|
|
429
|
+
const attempted = calls.filter(call => call.attempted);
|
|
430
|
+
const completed = calls.filter(call => call.completed);
|
|
431
|
+
const denied = calls.filter(call => call.denied);
|
|
432
|
+
const unresolved = calls.filter(call => call.attempted && !call.completed && !call.denied);
|
|
433
|
+
const traceEvents = context.orderedEvents.map(event => event.kind === 'text'
|
|
434
|
+
? event.text
|
|
435
|
+
: `[${event.call.name || 'tool'}] ${JSON.stringify(event.call.input ?? {})}`);
|
|
436
|
+
const trace = traceEvents.length ? traceEvents.join('\n') : text;
|
|
437
|
+
const executionEvidence = {
|
|
438
|
+
visibility: context.visibility,
|
|
439
|
+
attempted,
|
|
440
|
+
completed,
|
|
441
|
+
denied,
|
|
442
|
+
unresolved,
|
|
443
|
+
counts: context.visibility === 'unavailable'
|
|
444
|
+
? { attempted: null, completed: null, denied: null, unresolved: null }
|
|
445
|
+
: { attempted: attempted.length, completed: completed.length, denied: denied.length, unresolved: unresolved.length },
|
|
446
|
+
};
|
|
447
|
+
const metadata = { ...context.metadata };
|
|
448
|
+
if (metadata.cost === null && typeof metadata.total_cost_usd === 'number') metadata.cost = metadata.total_cost_usd;
|
|
449
|
+
if (metadata.total_cost_usd === null && typeof metadata.cost === 'number') metadata.total_cost_usd = metadata.cost;
|
|
450
|
+
return {
|
|
451
|
+
engine: context.engine,
|
|
452
|
+
format: context.format,
|
|
453
|
+
parseStatus,
|
|
454
|
+
parseError,
|
|
455
|
+
rawLineCount,
|
|
456
|
+
trace,
|
|
457
|
+
assistantText: text,
|
|
458
|
+
finalResult: context.finalResult,
|
|
459
|
+
metadata,
|
|
460
|
+
toolCalls: attempted,
|
|
461
|
+
toolResults: context.visibility === 'unavailable' ? [] : context.calls.filter(call => call.result_count > 0).map(publicCall),
|
|
462
|
+
toolEvidence: executionEvidence,
|
|
463
|
+
executionEvidence,
|
|
464
|
+
hasFinalResult: context.sawResult,
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function parseTranscript(raw, requestedEngine = 'auto') {
|
|
469
|
+
const text = Buffer.isBuffer(raw) ? raw.toString('utf8') : String(raw ?? '');
|
|
470
|
+
const parsed = parseJsonLines(text);
|
|
471
|
+
let events = parsed.events;
|
|
472
|
+
let errors = parsed.errors;
|
|
473
|
+
let legacy = null;
|
|
474
|
+
const requestedOrDetected = detectEngine(events, requestedEngine);
|
|
475
|
+
if (events.length === 1 && (requestedOrDetected === 'claude' || requestedOrDetected === 'unknown') && isObject(events[0].value)) {
|
|
476
|
+
const only = events[0].value;
|
|
477
|
+
// The old Claude `--output-format json` contract is one result object. A
|
|
478
|
+
// one-line result event has no tool visibility, even though it is valid
|
|
479
|
+
// JSON and superficially resembles a stream event.
|
|
480
|
+
if (!['assistant', 'user', 'system', 'stream_event'].includes(only.type)
|
|
481
|
+
&& (requestedOrDetected === 'claude' || typeof only.result === 'string')) {
|
|
482
|
+
legacy = only;
|
|
483
|
+
events = [];
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
if (!events.length && text.trim()) {
|
|
487
|
+
try {
|
|
488
|
+
legacy = JSON.parse(text);
|
|
489
|
+
events = [{ line: 1, value: legacy }];
|
|
490
|
+
errors = [];
|
|
491
|
+
} catch {
|
|
492
|
+
// Keep the line parse error; the parser must fail closed below.
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
const engine = detectEngine(events, requestedEngine);
|
|
497
|
+
if (legacy && isObject(legacy)) {
|
|
498
|
+
const context = makeContext(engine === 'unknown' ? 'claude' : engine, 'claude-json', 'unavailable');
|
|
499
|
+
context.sawRecognizedEvent = typeof legacy.result === 'string' || isObject(legacy);
|
|
500
|
+
context.sawResult = typeof legacy.result === 'string';
|
|
501
|
+
context.finalResult = typeof legacy.result === 'string' ? legacy.result : null;
|
|
502
|
+
setMetadata(context, legacy, { result: true });
|
|
503
|
+
return finishContext(context, {
|
|
504
|
+
// The legacy one-object JSON contract contains final prose but no
|
|
505
|
+
// structured tool events. Keep the text readable while making every
|
|
506
|
+
// grader treat its evidence as unavailable.
|
|
507
|
+
parseStatus: context.sawRecognizedEvent ? 'unavailable' : 'unrecognized',
|
|
508
|
+
rawLineCount: parsed.nonEmpty || 1,
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
const format = engine === 'opencode' ? 'opencode-jsonl' : engine === 'claude' ? 'claude-stream-json' : 'unknown';
|
|
513
|
+
const context = makeContext(engine, format, engine === 'unknown' ? 'unavailable' : 'structured');
|
|
514
|
+
for (const item of events) {
|
|
515
|
+
if (engine === 'opencode') processOpencodeEvent(context, item.value);
|
|
516
|
+
else if (engine === 'claude') processClaudeEvent(context, item.value);
|
|
517
|
+
}
|
|
518
|
+
const recognized = context.sawRecognizedEvent;
|
|
519
|
+
let parseStatus = recognized ? 'parsed' : 'unrecognized';
|
|
520
|
+
if (errors.length && recognized) parseStatus = 'partial';
|
|
521
|
+
if (engine === 'claude' && recognized && !context.sawResult) {
|
|
522
|
+
parseStatus = 'partial';
|
|
523
|
+
if (!errors.length) errors.push('stream ended before a result event');
|
|
524
|
+
}
|
|
525
|
+
if (!recognized && !errors.length && parsed.nonEmpty === 0) errors.push('empty transcript');
|
|
526
|
+
return finishContext(context, {
|
|
527
|
+
parseStatus,
|
|
528
|
+
parseError: errors.length ? errors.join('; ') : null,
|
|
529
|
+
rawLineCount: parsed.nonEmpty,
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
function parseTranscriptFile(filePath, engine = 'auto') {
|
|
534
|
+
return parseTranscript(fs.readFileSync(filePath, 'utf8'), engine);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
function targetMatches(call, target) {
|
|
538
|
+
if (target === undefined || target === null || target === '') return true;
|
|
539
|
+
if (isObject(target)) {
|
|
540
|
+
if (target.id !== undefined && call.id !== target.id) return false;
|
|
541
|
+
if (target.name !== undefined && call.name !== target.name) return false;
|
|
542
|
+
if (target.command !== undefined && (!isObject(call.input) || !commandMatches(call.input.command, target.command))) return false;
|
|
543
|
+
if (target.input_contains !== undefined && !stableJson(call.input).includes(String(target.input_contains))) return false;
|
|
544
|
+
return true;
|
|
545
|
+
}
|
|
546
|
+
const value = String(target);
|
|
547
|
+
return call.id === value || call.name === value || (isObject(call.input) && commandMatches(call.input.command, value));
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
function gradeExecutionEvidence(expectation, parsedOrEvidence) {
|
|
551
|
+
const parsed = parsedOrEvidence && parsedOrEvidence.executionEvidence ? parsedOrEvidence : null;
|
|
552
|
+
const evidence = parsed ? parsed.executionEvidence : parsedOrEvidence;
|
|
553
|
+
if (!evidence || evidence.visibility !== 'structured') {
|
|
554
|
+
return { pass: false, status: 'inconclusive', reason: 'structured tool evidence is unavailable', observed: null };
|
|
555
|
+
}
|
|
556
|
+
if (parsed && parsed.parseStatus !== 'parsed') {
|
|
557
|
+
return { pass: false, status: 'inconclusive', reason: parsed.parseError || 'transcript parsing is incomplete', observed: null };
|
|
558
|
+
}
|
|
559
|
+
const type = String(expectation && expectation.type || '').toLowerCase();
|
|
560
|
+
const state = type.includes('denied') || expectation.evidence === 'denied' ? 'denied'
|
|
561
|
+
: type.includes('completed') || type.includes('executed') || expectation.evidence === 'completed' ? 'completed'
|
|
562
|
+
: 'attempted';
|
|
563
|
+
const list = evidence[state] || [];
|
|
564
|
+
const target = {};
|
|
565
|
+
if (expectation && isObject(expectation.value)) Object.assign(target, expectation.value);
|
|
566
|
+
if (expectation && expectation.tool !== undefined) target.name = expectation.tool;
|
|
567
|
+
if (expectation && expectation.name !== undefined) target.name = expectation.name;
|
|
568
|
+
if (expectation && expectation.command !== undefined) target.command = expectation.command;
|
|
569
|
+
if (expectation && expectation.input_contains !== undefined) target.input_contains = expectation.input_contains;
|
|
570
|
+
const targetValue = Object.keys(target).length
|
|
571
|
+
? target
|
|
572
|
+
: expectation && typeof expectation.value === 'string' ? expectation.value : undefined;
|
|
573
|
+
const matches = list.filter(call => targetMatches(call, targetValue));
|
|
574
|
+
const requestedCount = typeof expectation.count === 'number'
|
|
575
|
+
? expectation.count
|
|
576
|
+
: typeof expectation.value === 'number' ? expectation.value : 1;
|
|
577
|
+
const pass = matches.length >= requestedCount;
|
|
578
|
+
return {
|
|
579
|
+
pass,
|
|
580
|
+
status: pass ? 'pass' : 'fail',
|
|
581
|
+
reason: pass ? `found ${matches.length} ${state} tool call(s)` : `expected ${requestedCount} ${state} tool call(s), found ${matches.length}`,
|
|
582
|
+
observed: matches,
|
|
583
|
+
state,
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
module.exports = {
|
|
588
|
+
gradeExecutionEvidence,
|
|
589
|
+
parseTranscript,
|
|
590
|
+
parseTranscriptFile,
|
|
591
|
+
};
|
package/bin/cli.js
CHANGED
|
@@ -62,11 +62,19 @@ Commands:
|
|
|
62
62
|
--all Install all of the above platforms
|
|
63
63
|
-g, --global Install to home directory (~/.agents) instead of local repository
|
|
64
64
|
-y, --yes Bypass interactive menu and use auto-detection
|
|
65
|
+
--symlink Force linking every platform's skill dir to one canonical
|
|
66
|
+
copy (junction on Windows, symlink elsewhere) - errors
|
|
67
|
+
instead of falling back if a link can't be created
|
|
68
|
+
--copy Force an independent physical copy per platform (skip the
|
|
69
|
+
canonical store entirely) - use when links aren't supported
|
|
70
|
+
(default: try a link automatically, fall back to --copy
|
|
71
|
+
behavior silently on failure)
|
|
65
72
|
add/skills/skill Add/install modular skills into the local workspace
|
|
66
73
|
Usage:
|
|
67
74
|
npx github:dyphn1/Harness-everything add [skill-names...]
|
|
68
75
|
Options:
|
|
69
|
-
-g, --global
|
|
76
|
+
-g, --global Install skills to home directory (~/.agents/skills)
|
|
77
|
+
--symlink/--copy See 'install' above
|
|
70
78
|
(Runs interactively if no skill names are specified)
|
|
71
79
|
uninstall Remove Harness OS hooks, advisory files & skills
|
|
72
80
|
Options:
|
|
@@ -75,19 +83,24 @@ Commands:
|
|
|
75
83
|
--skills Remove installed skills
|
|
76
84
|
-y, --yes Bypass interactive menu (local + skills only,
|
|
77
85
|
unless --global is also passed)
|
|
78
|
-
|
|
86
|
+
Passing ANY of the above flags (even with -y omitted) always runs
|
|
87
|
+
non-interactively against exactly what you passed - e.g.
|
|
88
|
+
'uninstall --local --global --skills' removes both scopes and all
|
|
89
|
+
skills in one run, with no menu. Only a bare 'uninstall' with no
|
|
90
|
+
flags goes interactive, and only when run in a real terminal; with
|
|
91
|
+
no flags and no interactive terminal available, it exits with an
|
|
92
|
+
error instead of silently doing nothing.
|
|
79
93
|
self-regression Run syntax and routing checks before committing changes (alias: test)
|
|
80
|
-
next "<prompt>" Print the
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
94
|
+
next "<prompt>" Print the Harness Kernel routing recommendation for a prompt:
|
|
95
|
+
tier/rationale + mandatory invariants + advisory skill suggestions.
|
|
96
|
+
Hookless platforms can call this explicitly at the start of software
|
|
97
|
+
work; hosts with UserPromptSubmit hooks receive it automatically.
|
|
84
98
|
verify-install Compare installed Harness manifests and skill trees with
|
|
85
99
|
this package source; stale versions or missing files fail.
|
|
86
100
|
verify Run the pre-delivery verification gate (lint/test from the
|
|
87
101
|
nearest package.json). Exits non-zero if checks fail. This is
|
|
88
|
-
the explicit stand-in for
|
|
89
|
-
|
|
90
|
-
task complete.
|
|
102
|
+
the explicit stand-in for a hard stop gate on platforms where
|
|
103
|
+
no equivalent hook is active - call it before declaring a task complete.
|
|
91
104
|
|
|
92
105
|
Options:
|
|
93
106
|
--help, -h Show this help text
|
|
@@ -96,7 +109,6 @@ Options:
|
|
|
96
109
|
|
|
97
110
|
function runInstaller(installArgs) {
|
|
98
111
|
const installerPath = path.resolve(__dirname, '..', 'scripts', 'installer.js');
|
|
99
|
-
// Dynamic require or spawn
|
|
100
112
|
if (fs.existsSync(installerPath)) {
|
|
101
113
|
require(installerPath);
|
|
102
114
|
} else {
|
|
@@ -121,9 +133,9 @@ function runSelfRegression() {
|
|
|
121
133
|
// platform-specific directory (.codex/skills/, .cursor/skills/, ...) a copy
|
|
122
134
|
// of the harness-everything skill also happens to be sitting in.
|
|
123
135
|
function runNext(nextArgs) {
|
|
124
|
-
const routerPath = path.resolve(__dirname, '..', 'harness-everything', 'scripts', '
|
|
136
|
+
const routerPath = path.resolve(__dirname, '..', 'harness-everything', 'scripts', 'kernel-router.js');
|
|
125
137
|
if (!fs.existsSync(routerPath)) {
|
|
126
|
-
console.error("[Error]
|
|
138
|
+
console.error("[Error] Harness kernel router not found at harness-everything/scripts/kernel-router.js");
|
|
127
139
|
process.exit(1);
|
|
128
140
|
}
|
|
129
141
|
const prompt = nextArgs.join(' ');
|