opencode-agent-orchestration-kit 1.0.27
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/.github/CODEOWNERS +1 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +65 -0
- package/.github/ISSUE_TEMPLATE/config.yml +11 -0
- package/.github/ISSUE_TEMPLATE/documentation.yml +22 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +43 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +25 -0
- package/.github/workflows/check.yml +47 -0
- package/CODE_OF_CONDUCT.md +24 -0
- package/CONTRIBUTING.md +52 -0
- package/LICENSE +201 -0
- package/NOTICE.md +23 -0
- package/README.md +806 -0
- package/SECURITY.md +17 -0
- package/docker/open-design/.env.example +6 -0
- package/docker/open-design/Dockerfile +50 -0
- package/docker/open-design/docker-compose.yml +18 -0
- package/docker/open-design/opencode-od/agents/od-worker.md +22 -0
- package/docker/open-design/opencode-od/opencode.json +24 -0
- package/docs/agents.md +21 -0
- package/docs/commands.md +16 -0
- package/docs/configuration.md +30 -0
- package/docs/docker-open-design.md +42 -0
- package/docs/impeccable.md +18 -0
- package/docs/installation.md +176 -0
- package/docs/models.md +17 -0
- package/docs/open-design.md +25 -0
- package/docs/quickstart.md +74 -0
- package/docs/releases/v1.0.10.md +46 -0
- package/docs/releases/v1.0.14.md +39 -0
- package/docs/releases/v1.0.27.md +66 -0
- package/docs/security.md +8 -0
- package/docs/superpowers/plans/2026-07-20-safe-installation-lifecycle.md +779 -0
- package/docs/superpowers/plans/2026-07-20-version-identity-and-releases.md +590 -0
- package/docs/superpowers/specs/2026-07-20-safe-installation-lifecycle-design.md +1350 -0
- package/docs/superpowers/specs/2026-07-20-version-identity-and-releases-design.md +557 -0
- package/docs/superpowers.md +34 -0
- package/docs/synology.md +30 -0
- package/docs/troubleshooting.md +54 -0
- package/docs/workflows.md +44 -0
- package/doctor.sh +5 -0
- package/env.example +15 -0
- package/install.sh +5 -0
- package/opencode/AGENTS.md +104 -0
- package/opencode/agents/debugger.md +41 -0
- package/opencode/agents/designer.md +93 -0
- package/opencode/agents/developer.md +180 -0
- package/opencode/agents/evaluator.md +35 -0
- package/opencode/agents/evolver.md +31 -0
- package/opencode/agents/lead.md +251 -0
- package/opencode/agents/researcher.md +76 -0
- package/opencode/agents/review_api.md +34 -0
- package/opencode/agents/review_coordinator.md +111 -0
- package/opencode/agents/review_quality.md +35 -0
- package/opencode/agents/review_security.md +35 -0
- package/opencode/agents/review_tests.md +37 -0
- package/opencode/agents/reviewer.md +116 -0
- package/opencode/agents/scoper.md +75 -0
- package/opencode/agents/specifier.md +116 -0
- package/opencode/commands/code-simplify.md +36 -0
- package/opencode/commands/design.md +27 -0
- package/opencode/commands/evolve.md +165 -0
- package/opencode/commands/feature.md +67 -0
- package/opencode/commands/implement.md +11 -0
- package/opencode/commands/init.md +34 -0
- package/opencode/commands/loop.md +145 -0
- package/opencode/commands/mvp-spec.md +20 -0
- package/opencode/commands/plan.md +74 -0
- package/opencode/commands/research.md +12 -0
- package/opencode/commands/review-orchestrated.md +47 -0
- package/opencode/commands/review-preflight.md +26 -0
- package/opencode/commands/review.md +18 -0
- package/opencode/commands/scope.md +36 -0
- package/opencode/commands/spec.md +12 -0
- package/opencode/commands/test.md +40 -0
- package/opencode/docs/ai/evolution/README.md +135 -0
- package/opencode/docs/ai/evolution/benchmarks/manual-scenarios.md +123 -0
- package/opencode/docs/ai/evolution/benchmarks/router-scenarios.jsonl +8 -0
- package/opencode/docs/ai/evolution/evolution_history.md +83 -0
- package/opencode/docs/ai/evolution/mechanisms.jsonl +7 -0
- package/opencode/docs/ai/evolution/rejected_mechanisms.jsonl +2 -0
- package/opencode/docs/ai/evolution/runs/README.md +15 -0
- package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/analysis/overview.md +12 -0
- package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/change_evaluation.json +108 -0
- package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/change_manifest.json +52 -0
- package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/evaluation.md +19 -0
- package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/post_evaluation.md +12 -0
- package/opencode/docs/ai/evolution/runs/iteration-002-feature-flow-fix/analysis/overview.md +7 -0
- package/opencode/docs/ai/evolution/runs/iteration-002-feature-flow-fix/change_evaluation.json +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-002-feature-flow-fix/evaluation.md +19 -0
- package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/analysis/overview.md +13 -0
- package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/change_evaluation.json +66 -0
- package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/change_manifest.json +82 -0
- package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/evaluation.md +20 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/ahe-run-lifecycle-validator.md +40 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/evolve-evaluation-only-contract.md +15 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/open-design-tool-contract.md +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/slash-command-contract-coverage.md +40 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/overview.md +17 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/pre_apply_approval.md +15 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/change_evaluation.json +252 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/change_manifest.json +210 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/evaluation.md +25 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/post_apply_evaluation.md +15 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/post_manifest_evaluation.md +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/pre_apply_evaluation.md +15 -0
- package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/analysis/overview.md +13 -0
- package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/change_evaluation.json +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/change_manifest.json +30 -0
- package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/evaluation.md +25 -0
- package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/analysis/overview.md +13 -0
- package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/change_evaluation.json +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/change_manifest.json +29 -0
- package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/evaluation.md +18 -0
- package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/analysis/overview.md +13 -0
- package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/change_evaluation.json +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/change_manifest.json +34 -0
- package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/evaluation.md +17 -0
- package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/analysis/overview.md +13 -0
- package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/change_evaluation.json +12 -0
- package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/change_manifest.json +28 -0
- package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/evaluation.md +17 -0
- package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/analysis/overview.md +9 -0
- package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/change_evaluation.json +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/change_manifest.json +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/evaluation.md +18 -0
- package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/analysis/overview.md +12 -0
- package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/change_evaluation.json +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/change_manifest.json +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/evaluation.md +17 -0
- package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/analysis/overview.md +10 -0
- package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/change_evaluation.json +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/change_manifest.json +30 -0
- package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/evaluation.md +17 -0
- package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/analysis/overview.md +25 -0
- package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/change_evaluation.json +28 -0
- package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/change_manifest.json +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/evaluation.md +22 -0
- package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/analysis/overview.md +27 -0
- package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/change_evaluation.json +32 -0
- package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/change_manifest.json +49 -0
- package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/evaluation.md +92 -0
- package/opencode/docs/ai/evolution/runs/iteration-014-harness-baseline/analysis/detail/token-vs-semantic.md +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-014-harness-baseline/analysis/overview.md +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-014-harness-baseline/evaluation.md +36 -0
- package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/analysis/overview.md +13 -0
- package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/change_evaluation.json +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/change_manifest.json +47 -0
- package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/evaluation.md +27 -0
- package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/analysis/overview.md +32 -0
- package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/change_evaluation.json +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/change_manifest.json +35 -0
- package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/evaluation.md +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/analysis/detail/pattern-1-feature-sidecar-false-positive.md +51 -0
- package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/analysis/detail/pattern-2-checker-time-budget.md +52 -0
- package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/analysis/overview.md +99 -0
- package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/change_evaluation.json +61 -0
- package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/change_manifest.json +61 -0
- package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/evaluation.md +448 -0
- package/opencode/docs/ai/evolution/runs/iteration-018-free-message-routing-audit/analysis/detail/intake-gray-zone.md +65 -0
- package/opencode/docs/ai/evolution/runs/iteration-018-free-message-routing-audit/analysis/overview.md +172 -0
- package/opencode/docs/ai/evolution/runs/iteration-018-free-message-routing-audit/evaluation.md +226 -0
- package/opencode/docs/ai/evolution/runs/iteration-019-handoff-routing-audit/analysis/detail/plan-only-gray-zone.md +62 -0
- package/opencode/docs/ai/evolution/runs/iteration-019-handoff-routing-audit/analysis/overview.md +167 -0
- package/opencode/docs/ai/evolution/runs/iteration-019-handoff-routing-audit/evaluation.md +163 -0
- package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/analysis/overview.md +42 -0
- package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/change_evaluation.json +46 -0
- package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/change_manifest.json +57 -0
- package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/evaluation.md +48 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/analysis/detail/contract-vs-runtime-gap.md +163 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/analysis/detail/evidence-collection-blocker.md +134 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/analysis/overview.md +111 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/change_evaluation.json +52 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/change_manifest.json +50 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/evaluation.md +46 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/manifest-justification.md +48 -0
- package/opencode/docs/ai/evolution/session-sources.md +91 -0
- package/opencode/docs/ai/harness/README.md +32 -0
- package/opencode/docs/ai/harness/agents.md +148 -0
- package/opencode/docs/ai/harness/checks.md +119 -0
- package/opencode/docs/ai/harness/commands.md +391 -0
- package/opencode/docs/ai/harness/evidence.md +85 -0
- package/opencode/docs/ai/harness/init-detection-rules.md +160 -0
- package/opencode/docs/ai/harness/orchestrated-review.md +131 -0
- package/opencode/docs/ai/harness/skill-metadata-schema.md +198 -0
- package/opencode/docs/ai/harness/skill-resolution.md +202 -0
- package/opencode/docs/ai/harness/skill_registry.json +443 -0
- package/opencode/docs/ai/harness/skill_registry.md +43 -0
- package/opencode/docs/ai/project-context-template.md +53 -0
- package/opencode/opencode.json +38 -0
- package/opencode/package-lock.json +1717 -0
- package/opencode/package.json +11 -0
- package/opencode/plugins/token-tree-usage.tsx +206 -0
- package/opencode/references/performance-checklist.md +153 -0
- package/opencode/references/security-checklist.md +134 -0
- package/opencode/references/testing-patterns.md +236 -0
- package/opencode/scripts/check-harness.mjs +1572 -0
- package/opencode/scripts/check-harness.test.mjs +820 -0
- package/opencode/scripts/collect-session-evidence.mjs +612 -0
- package/opencode/scripts/collect-session-evidence.test.mjs +443 -0
- package/opencode/scripts/preflight-audit.mjs +497 -0
- package/opencode/scripts/preflight-audit.test.mjs +363 -0
- package/opencode/scripts/project-capability-snapshot.mjs +407 -0
- package/opencode/scripts/project-capability-snapshot.test.mjs +382 -0
- package/opencode/scripts/review-orchestrated-prepare.mjs +547 -0
- package/opencode/scripts/review-orchestrated-prepare.test.mjs +516 -0
- package/opencode/scripts/skill-resolver.mjs +585 -0
- package/opencode/scripts/skill-resolver.test.mjs +781 -0
- package/opencode/scripts/update-skill-registry.mjs +380 -0
- package/opencode/skills/api-and-interface-design/SKILL.md +315 -0
- package/opencode/skills/autonomous-loops/SKILL.md +312 -0
- package/opencode/skills/code-review-and-quality/SKILL.md +365 -0
- package/opencode/skills/code-simplification/SKILL.md +345 -0
- package/opencode/skills/context-engineering/SKILL.md +252 -0
- package/opencode/skills/debugging-and-error-recovery/SKILL.md +316 -0
- package/opencode/skills/documentation-and-adrs/SKILL.md +298 -0
- package/opencode/skills/doubt-driven-development/SKILL.md +168 -0
- package/opencode/skills/iterative-retrieval/SKILL.md +232 -0
- package/opencode/skills/open-design/SKILL.md +123 -0
- package/opencode/skills/performance-optimization/SKILL.md +365 -0
- package/opencode/skills/security-and-hardening/SKILL.md +369 -0
- package/opencode/skills/source-driven-development/SKILL.md +210 -0
- package/opencode/skills/test-driven-development/SKILL.md +406 -0
- package/opencode/skills/using-agent-skills/SKILL.md +194 -0
- package/opencode/skills/verification-loop/SKILL.md +162 -0
- package/opencode/tools/open_design.ts +361 -0
- package/opencode/tui.json +5 -0
- package/package.json +20 -0
- package/rollback.sh +5 -0
- package/scripts/check.sh +184 -0
- package/scripts/install-smoke.sh +111 -0
- package/scripts/manage-installation.mjs +1498 -0
- package/scripts/manage-installation.test.mjs +1936 -0
- package/scripts/version.mjs +197 -0
- package/scripts/version.test.mjs +195 -0
- package/uninstall.sh +5 -0
- package/upgrade.sh +5 -0
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* preflight-audit.mjs
|
|
5
|
+
*
|
|
6
|
+
* Produces a harness preflight audit artifact for a given AHE iteration.
|
|
7
|
+
* This is a mechanical, heuristics-based audit that reads docs/contracts
|
|
8
|
+
* and staged artifacts to produce an objective baseline before proposing
|
|
9
|
+
* harness changes.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* node scripts/preflight-audit.mjs --iteration iteration-XXX
|
|
13
|
+
*
|
|
14
|
+
* Output:
|
|
15
|
+
* docs/ai/evolution/runs/iteration-XXX/preflight-audit.json
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import fs from "node:fs";
|
|
19
|
+
import path from "node:path";
|
|
20
|
+
|
|
21
|
+
const root = process.cwd();
|
|
22
|
+
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// Args
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
|
|
27
|
+
function parseArgs(argv) {
|
|
28
|
+
const args = {};
|
|
29
|
+
for (let i = 2; i < argv.length; i += 1) {
|
|
30
|
+
if (argv[i] === "--iteration") {
|
|
31
|
+
args.iteration = argv[++i];
|
|
32
|
+
} else if (argv[i] === "--output-dir") {
|
|
33
|
+
args.outputDir = argv[++i];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (!args.iteration) {
|
|
37
|
+
console.error("Usage: node scripts/preflight-audit.mjs --iteration iteration-XXX");
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
return args;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
// FS helpers
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
function read(rel) {
|
|
48
|
+
return fs.readFileSync(path.join(root, rel), "utf8");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function exists(rel) {
|
|
52
|
+
return fs.existsSync(path.join(root, rel));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function listMarkdown(dir) {
|
|
56
|
+
const dirPath = path.join(root, dir);
|
|
57
|
+
if (!fs.existsSync(dirPath)) return [];
|
|
58
|
+
return fs
|
|
59
|
+
.readdirSync(dirPath)
|
|
60
|
+
.filter((f) => f.endsWith(".md"))
|
|
61
|
+
.map((f) => f.replace(/\.md$/, ""));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
// JSONL helpers
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Parse a JSONL file and return parsed objects for each valid line.
|
|
70
|
+
* Used instead of raw substring matching to detect structured agent/command
|
|
71
|
+
* references in execution trees and normalized sessions.
|
|
72
|
+
*
|
|
73
|
+
* Heuristic: we check fields `agent`, `agentName`, `type`, `command`,
|
|
74
|
+
* `commandName` on each parsed line. If the JSONL has no stable schema,
|
|
75
|
+
* this heuristic is documented and tested to reduce false positives.
|
|
76
|
+
*/
|
|
77
|
+
function parseJsonlFile(filePath) {
|
|
78
|
+
try {
|
|
79
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
80
|
+
const records = [];
|
|
81
|
+
for (const line of content.split("\n")) {
|
|
82
|
+
const trimmed = line.trim();
|
|
83
|
+
if (!trimmed) continue;
|
|
84
|
+
try {
|
|
85
|
+
records.push(JSON.parse(trimmed));
|
|
86
|
+
} catch {
|
|
87
|
+
// skip malformed lines
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return records;
|
|
91
|
+
} catch {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const EVIDENCE_FIELDS = ["agent", "agentName", "root_agent", "type", "command", "commandName"];
|
|
97
|
+
|
|
98
|
+
function hasStructuredEvidence(records, name) {
|
|
99
|
+
for (const rec of records) {
|
|
100
|
+
if (!rec || typeof rec !== "object") continue;
|
|
101
|
+
// Check string fields (agent, agentName, root_agent, type, command, commandName)
|
|
102
|
+
for (const field of EVIDENCE_FIELDS) {
|
|
103
|
+
if (typeof rec[field] === "string" && rec[field] === name) return true;
|
|
104
|
+
}
|
|
105
|
+
// Check participating_agents array (collector-produced execution trees)
|
|
106
|
+
if (Array.isArray(rec.participating_agents) && rec.participating_agents.includes(name)) return true;
|
|
107
|
+
// Recurse into children arrays (e.g. execution tree nodes)
|
|
108
|
+
if (Array.isArray(rec.children)) {
|
|
109
|
+
if (hasStructuredEvidence(rec.children, name)) return true;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ---------------------------------------------------------------------------
|
|
116
|
+
// Harness surfaces
|
|
117
|
+
// ---------------------------------------------------------------------------
|
|
118
|
+
|
|
119
|
+
function discoverAgents() {
|
|
120
|
+
return listMarkdown("agents");
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function discoverCommands() {
|
|
124
|
+
return listMarkdown("commands");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// ---------------------------------------------------------------------------
|
|
128
|
+
// Staged artifacts
|
|
129
|
+
// ---------------------------------------------------------------------------
|
|
130
|
+
|
|
131
|
+
function findStagedArtifacts(iteration) {
|
|
132
|
+
const rawDir = path.join(root, "docs/ai/evolution/runs", iteration, "raw");
|
|
133
|
+
const artifacts = {};
|
|
134
|
+
|
|
135
|
+
if (!fs.existsSync(rawDir)) return artifacts;
|
|
136
|
+
|
|
137
|
+
const knownArtifacts = [
|
|
138
|
+
"execution-trees.jsonl",
|
|
139
|
+
"normalized-sessions.jsonl",
|
|
140
|
+
"session-sources.summary.json",
|
|
141
|
+
"cursor.json",
|
|
142
|
+
];
|
|
143
|
+
|
|
144
|
+
for (const name of knownArtifacts) {
|
|
145
|
+
const p = path.join(rawDir, name);
|
|
146
|
+
if (fs.existsSync(p)) {
|
|
147
|
+
artifacts[name] = p;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return artifacts;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// ---------------------------------------------------------------------------
|
|
155
|
+
// Matrix: doc-runtime alignment per surface
|
|
156
|
+
// ---------------------------------------------------------------------------
|
|
157
|
+
|
|
158
|
+
function buildDocRuntimeMatrix(agents, commands, stagedArtifacts) {
|
|
159
|
+
const matrix = [];
|
|
160
|
+
|
|
161
|
+
// Pre-parse JSONL artifacts once for structured evidence detection
|
|
162
|
+
const treesRecords = stagedArtifacts["execution-trees.jsonl"]
|
|
163
|
+
? parseJsonlFile(stagedArtifacts["execution-trees.jsonl"])
|
|
164
|
+
: [];
|
|
165
|
+
const sessionsRecords = stagedArtifacts["normalized-sessions.jsonl"]
|
|
166
|
+
? parseJsonlFile(stagedArtifacts["normalized-sessions.jsonl"])
|
|
167
|
+
: [];
|
|
168
|
+
|
|
169
|
+
// Agents
|
|
170
|
+
for (const agent of agents) {
|
|
171
|
+
const docPath = `agents/${agent}.md`;
|
|
172
|
+
const docExists = exists(docPath);
|
|
173
|
+
// Structured evidence: parse JSONL and check agent/agentName/type fields
|
|
174
|
+
// instead of raw substring match which can produce false positives
|
|
175
|
+
const hasRuntimeEvidence =
|
|
176
|
+
hasStructuredEvidence(treesRecords, agent) ||
|
|
177
|
+
hasStructuredEvidence(sessionsRecords, agent);
|
|
178
|
+
|
|
179
|
+
const aligned = docExists && hasRuntimeEvidence;
|
|
180
|
+
matrix.push({
|
|
181
|
+
type: "agent",
|
|
182
|
+
name: agent,
|
|
183
|
+
doc_exists: docExists,
|
|
184
|
+
runtime_evidence_exists: hasRuntimeEvidence,
|
|
185
|
+
aligned,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Commands
|
|
190
|
+
for (const command of commands) {
|
|
191
|
+
const docPath = `commands/${command}.md`;
|
|
192
|
+
const docExists = exists(docPath);
|
|
193
|
+
// Structured evidence: check command/commandName fields in JSONL records
|
|
194
|
+
const hasRuntimeEvidence =
|
|
195
|
+
hasStructuredEvidence(treesRecords, command) ||
|
|
196
|
+
hasStructuredEvidence(sessionsRecords, command);
|
|
197
|
+
|
|
198
|
+
const aligned = docExists && hasRuntimeEvidence;
|
|
199
|
+
matrix.push({
|
|
200
|
+
type: "command",
|
|
201
|
+
name: command,
|
|
202
|
+
doc_exists: docExists,
|
|
203
|
+
runtime_evidence_exists: hasRuntimeEvidence,
|
|
204
|
+
aligned,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Workflow surfaces (harness-level contracts)
|
|
209
|
+
const workflowDocs = [
|
|
210
|
+
{ name: "evolve", path: "commands/evolve.md" },
|
|
211
|
+
{ name: "feature", path: "commands/feature.md" },
|
|
212
|
+
{ name: "plan", path: "commands/plan.md" },
|
|
213
|
+
{ name: "scope", path: "commands/scope.md" },
|
|
214
|
+
];
|
|
215
|
+
for (const wf of workflowDocs) {
|
|
216
|
+
const docExists = exists(wf.path);
|
|
217
|
+
matrix.push({
|
|
218
|
+
type: "workflow",
|
|
219
|
+
name: wf.name,
|
|
220
|
+
doc_exists: docExists,
|
|
221
|
+
runtime_evidence_exists: false,
|
|
222
|
+
aligned: docExists,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Evidence surfaces
|
|
227
|
+
const evidenceDocs = [
|
|
228
|
+
{ name: "evidence", path: "docs/ai/harness/evidence.md" },
|
|
229
|
+
{ name: "session-sources", path: "docs/ai/evolution/session-sources.md" },
|
|
230
|
+
];
|
|
231
|
+
for (const ev of evidenceDocs) {
|
|
232
|
+
const docExists = exists(ev.path);
|
|
233
|
+
matrix.push({
|
|
234
|
+
type: "evidence",
|
|
235
|
+
name: ev.name,
|
|
236
|
+
doc_exists: docExists,
|
|
237
|
+
runtime_evidence_exists: false,
|
|
238
|
+
aligned: docExists,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return matrix;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// ---------------------------------------------------------------------------
|
|
246
|
+
// Drift detection
|
|
247
|
+
// ---------------------------------------------------------------------------
|
|
248
|
+
|
|
249
|
+
function detectDrifts(matrix, stagedArtifacts) {
|
|
250
|
+
const drifts = [];
|
|
251
|
+
|
|
252
|
+
// Drift type 1: Documented agent with no runtime evidence
|
|
253
|
+
for (const entry of matrix) {
|
|
254
|
+
if (entry.type === "agent" && entry.doc_exists && !entry.runtime_evidence_exists) {
|
|
255
|
+
drifts.push({
|
|
256
|
+
surface: entry.name,
|
|
257
|
+
type: "missing_evidence",
|
|
258
|
+
description: `Agent \`${entry.name}\` is documented but has no runtime evidence in staged artifacts`,
|
|
259
|
+
severity: "medium",
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Drift type 2: Documented command with no runtime evidence
|
|
265
|
+
for (const entry of matrix) {
|
|
266
|
+
if (entry.type === "command" && entry.doc_exists && !entry.runtime_evidence_exists) {
|
|
267
|
+
drifts.push({
|
|
268
|
+
surface: entry.name,
|
|
269
|
+
type: "missing_evidence",
|
|
270
|
+
description: `Command \`${entry.name}\` is documented but has no runtime evidence in staged artifacts`,
|
|
271
|
+
severity: "low",
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Drift type 3: Missing documentation for discovered surface
|
|
277
|
+
for (const entry of matrix) {
|
|
278
|
+
if (!entry.doc_exists) {
|
|
279
|
+
drifts.push({
|
|
280
|
+
surface: entry.name,
|
|
281
|
+
type: "missing_docs",
|
|
282
|
+
description: `${entry.type} \`${entry.name}\` exists but has no documentation`,
|
|
283
|
+
severity: entry.type === "agent" ? "high" : "medium",
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// Drift type 4: Missing staged artifacts entirely
|
|
289
|
+
const hasTrees = "execution-trees.jsonl" in stagedArtifacts;
|
|
290
|
+
const hasCursor = "cursor.json" in stagedArtifacts;
|
|
291
|
+
if (!hasTrees && !hasCursor) {
|
|
292
|
+
drifts.push({
|
|
293
|
+
surface: "session_sources",
|
|
294
|
+
type: "missing_staging",
|
|
295
|
+
description: "No staged session artifacts (execution-trees.jsonl, cursor.json) found for this iteration",
|
|
296
|
+
severity: "medium",
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Drift type 5: Runtime contradicts contract (heuristic: agent appears in trees
|
|
301
|
+
// but the flow order documented in evolve.md is violated)
|
|
302
|
+
if (hasTrees) {
|
|
303
|
+
try {
|
|
304
|
+
const trees = fs.readFileSync(stagedArtifacts["execution-trees.jsonl"], "utf8");
|
|
305
|
+
// Simple heuristic: check if sidecar agents appear where they shouldn't
|
|
306
|
+
const sidecars = ["evaluator", "debugger", "evolver"];
|
|
307
|
+
const featureFlow = exists("commands/feature.md") ? read("commands/feature.md") : "";
|
|
308
|
+
if (featureFlow.includes("Flujo obligatorio")) {
|
|
309
|
+
const flowSection = featureFlow.split("## Flujo obligatorio")[1]?.split("## Reglas")[0] || "";
|
|
310
|
+
for (const sidecar of sidecars) {
|
|
311
|
+
if (flowSection.includes(sidecar)) {
|
|
312
|
+
drifts.push({
|
|
313
|
+
surface: "feature_flow",
|
|
314
|
+
type: "runtime_contradiction",
|
|
315
|
+
description: `Sidecar \`${sidecar}\` appears in mandatory feature flow, contradicting AHE sidecar-only contract`,
|
|
316
|
+
severity: "high",
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
} catch {
|
|
322
|
+
// ignore read errors
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return drifts;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// ---------------------------------------------------------------------------
|
|
330
|
+
// Scoring
|
|
331
|
+
// ---------------------------------------------------------------------------
|
|
332
|
+
|
|
333
|
+
function computeScores(matrix, drifts) {
|
|
334
|
+
const total = matrix.length;
|
|
335
|
+
if (total === 0) {
|
|
336
|
+
return {
|
|
337
|
+
contract_coverage: 0,
|
|
338
|
+
runtime_evidence_coverage: 0,
|
|
339
|
+
doc_runtime_alignment: 0,
|
|
340
|
+
drift_severity: "none",
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const docsPresent = matrix.filter((m) => m.doc_exists).length;
|
|
345
|
+
const evidencePresent = matrix.filter((m) => m.runtime_evidence_exists).length;
|
|
346
|
+
const aligned = matrix.filter((m) => m.aligned).length;
|
|
347
|
+
|
|
348
|
+
const contract_coverage = docsPresent / total;
|
|
349
|
+
const runtime_evidence_coverage = evidencePresent / total;
|
|
350
|
+
const doc_runtime_alignment = aligned / total;
|
|
351
|
+
|
|
352
|
+
// Drift severity: worst among all drifts
|
|
353
|
+
let drift_severity = "none";
|
|
354
|
+
for (const d of drifts) {
|
|
355
|
+
if (d.severity === "high") { drift_severity = "high"; break; }
|
|
356
|
+
if (d.severity === "medium" && drift_severity !== "high") drift_severity = "medium";
|
|
357
|
+
if (d.severity === "low" && drift_severity === "none") drift_severity = "low";
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return { contract_coverage, runtime_evidence_coverage, doc_runtime_alignment, drift_severity };
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// ---------------------------------------------------------------------------
|
|
364
|
+
// Recommendations
|
|
365
|
+
// ---------------------------------------------------------------------------
|
|
366
|
+
|
|
367
|
+
function generateRecommendations(matrix, drifts, scores) {
|
|
368
|
+
const recs = [];
|
|
369
|
+
|
|
370
|
+
// From drifts
|
|
371
|
+
for (const drift of drifts) {
|
|
372
|
+
if (drift.type === "runtime_contradiction") {
|
|
373
|
+
recs.push({
|
|
374
|
+
priority: "high",
|
|
375
|
+
description: `Resolve runtime contradiction: ${drift.description}`,
|
|
376
|
+
surface: drift.surface,
|
|
377
|
+
});
|
|
378
|
+
} else if (drift.type === "missing_docs") {
|
|
379
|
+
recs.push({
|
|
380
|
+
priority: drift.severity === "high" ? "high" : "medium",
|
|
381
|
+
description: `Add documentation for ${drift.type.replace(/_/g, " ")}: \`${drift.surface}\``,
|
|
382
|
+
surface: drift.surface,
|
|
383
|
+
});
|
|
384
|
+
} else if (drift.type === "missing_staging") {
|
|
385
|
+
recs.push({
|
|
386
|
+
priority: "medium",
|
|
387
|
+
description: "Run `node scripts/collect-session-evidence.mjs --iteration <iteration>` to produce staged artifacts",
|
|
388
|
+
surface: "session_sources",
|
|
389
|
+
});
|
|
390
|
+
} else if (drift.type === "missing_evidence") {
|
|
391
|
+
recs.push({
|
|
392
|
+
priority: "low",
|
|
393
|
+
description: `Collect runtime evidence for documented surface: \`${drift.surface}\``,
|
|
394
|
+
surface: drift.surface,
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// From scores
|
|
400
|
+
if (scores.contract_coverage < 0.8) {
|
|
401
|
+
recs.push({
|
|
402
|
+
priority: "medium",
|
|
403
|
+
description: `Contract coverage is low (${(scores.contract_coverage * 100).toFixed(0)}%): ensure all agents and commands have documentation`,
|
|
404
|
+
surface: "harness",
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
if (scores.runtime_evidence_coverage < 0.3) {
|
|
409
|
+
recs.push({
|
|
410
|
+
priority: "low",
|
|
411
|
+
description: `Runtime evidence coverage is low (${(scores.runtime_evidence_coverage * 100).toFixed(0)}%): consider collecting more session evidence`,
|
|
412
|
+
surface: "session_sources",
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// Sort by priority
|
|
417
|
+
const order = { high: 0, medium: 1, low: 2 };
|
|
418
|
+
recs.sort((a, b) => order[a.priority] - order[b.priority]);
|
|
419
|
+
|
|
420
|
+
return recs;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// ---------------------------------------------------------------------------
|
|
424
|
+
// Confidence
|
|
425
|
+
// ---------------------------------------------------------------------------
|
|
426
|
+
|
|
427
|
+
function computeConfidence(scores, drifts, hasStagedArtifacts) {
|
|
428
|
+
if (scores.drift_severity === "high") return "low";
|
|
429
|
+
if (!hasStagedArtifacts) return "low";
|
|
430
|
+
if (drifts.length === 0 && scores.contract_coverage > 0.9) return "high";
|
|
431
|
+
if (scores.contract_coverage > 0.7 && scores.drift_severity !== "high") return "medium";
|
|
432
|
+
return "low";
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// ---------------------------------------------------------------------------
|
|
436
|
+
// Main
|
|
437
|
+
// ---------------------------------------------------------------------------
|
|
438
|
+
|
|
439
|
+
function main() {
|
|
440
|
+
const args = parseArgs(process.argv);
|
|
441
|
+
const iteration = args.iteration;
|
|
442
|
+
|
|
443
|
+
// Discover surfaces
|
|
444
|
+
const agents = discoverAgents();
|
|
445
|
+
const commands = discoverCommands();
|
|
446
|
+
|
|
447
|
+
// Find staged artifacts
|
|
448
|
+
const stagedArtifacts = findStagedArtifacts(iteration);
|
|
449
|
+
const hasStagedArtifacts = Object.keys(stagedArtifacts).length > 0;
|
|
450
|
+
|
|
451
|
+
// Build matrix
|
|
452
|
+
const docRuntimeMatrix = buildDocRuntimeMatrix(agents, commands, stagedArtifacts);
|
|
453
|
+
|
|
454
|
+
// Detect drifts
|
|
455
|
+
const drifts = detectDrifts(docRuntimeMatrix, stagedArtifacts);
|
|
456
|
+
|
|
457
|
+
// Compute scores
|
|
458
|
+
const scores = computeScores(docRuntimeMatrix, drifts);
|
|
459
|
+
|
|
460
|
+
// Generate recommendations
|
|
461
|
+
const recommendations = generateRecommendations(docRuntimeMatrix, drifts, scores);
|
|
462
|
+
|
|
463
|
+
// Compute confidence
|
|
464
|
+
const confidence = computeConfidence(scores, drifts, hasStagedArtifacts);
|
|
465
|
+
|
|
466
|
+
// Build artifact
|
|
467
|
+
const artifact = {
|
|
468
|
+
iteration,
|
|
469
|
+
timestamp: new Date().toISOString(),
|
|
470
|
+
scores,
|
|
471
|
+
doc_runtime_matrix: docRuntimeMatrix,
|
|
472
|
+
drifts,
|
|
473
|
+
recommendations,
|
|
474
|
+
coverage: {
|
|
475
|
+
agents_scanned: agents.length,
|
|
476
|
+
commands_scanned: commands.length,
|
|
477
|
+
surfaces_total: docRuntimeMatrix.length,
|
|
478
|
+
staged_artifacts_found: Object.keys(stagedArtifacts),
|
|
479
|
+
},
|
|
480
|
+
confidence,
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
// Write output
|
|
484
|
+
const outDir = args.outputDir
|
|
485
|
+
? path.resolve(root, args.outputDir)
|
|
486
|
+
: path.join(root, "docs/ai/evolution/runs", iteration);
|
|
487
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
488
|
+
const outPath = path.join(outDir, "preflight-audit.json");
|
|
489
|
+
fs.writeFileSync(outPath, JSON.stringify(artifact, null, 2) + "\n");
|
|
490
|
+
|
|
491
|
+
console.log(`Preflight audit written to ${outPath}`);
|
|
492
|
+
console.log(` confidence: ${confidence}`);
|
|
493
|
+
console.log(` drifts: ${drifts.length}`);
|
|
494
|
+
console.log(` recommendations: ${recommendations.length}`);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
main();
|