opencode-agent-orchestration-kit 1.0.44 → 1.1.0
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/CONTRIBUTING.md +0 -1
- package/NOTICE.md +1 -5
- package/README.md +37 -49
- package/compatibility.json +7 -0
- package/docs/cli.md +69 -1
- package/docs/commands.md +1 -1
- package/docs/comparison.md +3 -3
- package/docs/compatibility.md +33 -14
- package/docs/installation.md +2 -0
- package/docs/models.md +1 -1
- package/docs/open-design.md +2 -0
- package/docs/opencode-v2.md +190 -0
- package/docs/releases/v1.0.45.md +77 -0
- package/docs/releases/v1.1.0.md +91 -0
- package/docs/supply-chain.md +4 -7
- package/docs/threat-model.md +16 -6
- package/docs/troubleshooting.md +7 -4
- package/docs/workflows.md +27 -4
- package/opencode/AGENTS.md +18 -10
- package/opencode/agents/designer.md +1 -1
- package/opencode/agents/developer.md +60 -6
- package/opencode/agents/lead.md +59 -10
- package/opencode/agents/reviewer.md +7 -0
- package/opencode/agents/scoper.md +1 -0
- package/opencode/agents/specifier.md +1 -0
- package/opencode/commands/autonomous.md +175 -24
- package/opencode/docs/ai/evolution/README.md +5 -4
- package/opencode/docs/ai/evolution/benchmarks/adversarial-scenarios.jsonl +3 -0
- package/opencode/docs/ai/evolution/session-sources.md +12 -0
- package/opencode/docs/ai/harness/agents.md +23 -6
- package/opencode/docs/ai/harness/checks.md +3 -2
- package/opencode/docs/ai/harness/commands.md +7 -4
- package/opencode/docs/ai/harness/skill_registry.json +107 -1
- package/opencode/docs/ai/harness/skill_registry.md +5 -0
- package/opencode/docs/ai/specs/mission-runtime.md +9 -0
- package/opencode/opencode.json +0 -1
- package/opencode/plugins/mission-runtime.test.mjs +15 -3
- package/opencode/plugins/mission-runtime.ts +11 -39
- package/opencode/plugins/oak-tui/server.ts +8 -0
- package/opencode/plugins/oak-tui/tui.tsx +81 -0
- package/opencode/plugins/open-design.ts +12 -0
- package/opencode/plugins/shell-export-guard.ts +13 -23
- package/opencode/plugins/token-tree-usage.tsx +4 -1
- package/opencode/runtime/v1/mission-runtime.ts +73 -0
- package/opencode/runtime/v1/shell-export-guard.ts +9 -0
- package/opencode/runtime/v2/mission-events.d.mts +13 -0
- package/opencode/runtime/v2/mission-events.mjs +64 -0
- package/opencode/runtime/v2/mission-events.test.mjs +120 -0
- package/opencode/runtime/v2/mission-runtime.ts +26 -0
- package/opencode/runtime/v2/open-design.ts +17 -0
- package/opencode/runtime/v2/shell-export-guard.ts +8 -0
- package/opencode/runtime/v2/token-usage.d.mts +15 -0
- package/opencode/runtime/v2/token-usage.mjs +35 -0
- package/opencode/runtime/v2/token-usage.test.mjs +30 -0
- package/opencode/scripts/adversarial-harness.test.mjs +50 -1
- package/opencode/scripts/check-harness.mjs +150 -33
- package/opencode/scripts/check-harness.test.mjs +81 -8
- package/opencode/scripts/collect-session-evidence.mjs +57 -39
- package/opencode/scripts/collect-session-evidence.test.mjs +164 -0
- package/opencode/scripts/deliver.d.mts +37 -0
- package/opencode/scripts/deliver.mjs +204 -0
- package/opencode/scripts/deliver.test.mjs +245 -0
- package/opencode/scripts/loop-state.mjs +50 -1
- package/opencode/scripts/loop-state.test.mjs +33 -0
- package/opencode/scripts/mission-runtime.test.mjs +1 -1
- package/opencode/scripts/mission-status.test.mjs +2 -0
- package/opencode/scripts/runtime-permission-policy.mjs +1 -1
- package/opencode/scripts/runtime-permission-policy.test.mjs +3 -2
- package/opencode/scripts/session-sources.d.mts +6 -0
- package/opencode/scripts/session-sources.mjs +49 -0
- package/opencode/scripts/shell-export-guard-core.d.mts +2 -0
- package/opencode/scripts/shell-export-guard-core.mjs +21 -0
- package/opencode/scripts/shell-export-guard-core.test.mjs +43 -0
- package/opencode/scripts/task-run.d.mts +63 -0
- package/opencode/scripts/task-run.mjs +224 -0
- package/opencode/scripts/task-run.test.mjs +178 -0
- package/opencode/skills/debugging-and-error-recovery/SKILL.md +20 -0
- package/opencode/skills/oak-adversarial-review/SKILL.md +138 -0
- package/opencode/skills/oak-commit/SKILL.md +69 -0
- package/opencode/skills/oak-enrich-task/SKILL.md +109 -0
- package/opencode/skills/oak-runtime-verification/SKILL.md +103 -0
- package/opencode/skills/oak-update-docs/SKILL.md +54 -0
- package/opencode/tools/open-design-tools.d.mts +17 -0
- package/opencode/tools/open-design-tools.mjs +254 -0
- package/opencode/tools/open_design.ts +26 -259
- package/package.json +6 -3
- package/scripts/benchmark-tool-paths.mjs +1 -1
- package/scripts/check-compatibility.mjs +58 -4
- package/scripts/check-compatibility.test.mjs +159 -11
- package/scripts/check-public-boundary.mjs +3 -0
- package/scripts/check-supply-chain.mjs +26 -58
- package/scripts/check-supply-chain.test.mjs +39 -36
- package/scripts/check.sh +42 -7
- package/scripts/manage-installation.mjs +34 -20
- package/scripts/manage-installation.test.mjs +29 -0
- package/scripts/oak.mjs +72 -2
- package/scripts/oak.test.mjs +69 -1
- package/scripts/open-design-http.test.mjs +1 -1
- package/scripts/open-design-tools.test.mjs +49 -0
- package/scripts/opencode-compat-smoke.sh +45 -4
- package/scripts/opencode-v2-smoke.mjs +197 -0
- package/scripts/opencode-v2-smoke.test.mjs +59 -0
- package/scripts/package-smoke.mjs +14 -0
- package/scripts/package-smoke.test.mjs +45 -2
- package/scripts/version.test.mjs +2 -2
- package/supply-chain.json +0 -4
- package/docker/open-design/data/app.sqlite +0 -0
- package/docker/open-design/data/app.sqlite-shm +0 -0
- package/docker/open-design/data/app.sqlite-wal +0 -0
- package/docker/open-design/opencode-auth/log/2026-05-02T105802.log +0 -17
- package/docker/open-design/opencode-auth/log/2026-05-04T102127.log +0 -16
- package/docker/open-design/opencode-auth/opencode.db +0 -0
- package/docker/open-design/opencode-auth/opencode.db-shm +0 -0
- package/docker/open-design/opencode-auth/opencode.db-wal +0 -0
- package/docs/superpowers.md +0 -41
|
@@ -14,9 +14,12 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
LoopStateError,
|
|
16
16
|
acquireLoop,
|
|
17
|
+
attestReview,
|
|
17
18
|
initLoopState,
|
|
18
19
|
inspectLoopState,
|
|
20
|
+
recordLoopAction,
|
|
19
21
|
} from "./loop-state.mjs";
|
|
22
|
+
import { DeliverError, deliver } from "./deliver.mjs";
|
|
20
23
|
|
|
21
24
|
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
|
|
22
25
|
const root = path.dirname(scriptDir);
|
|
@@ -84,6 +87,29 @@ function initializeLoop(rootDir) {
|
|
|
84
87
|
return contractPath;
|
|
85
88
|
}
|
|
86
89
|
|
|
90
|
+
function completedDeliveryLoop(rootDir) {
|
|
91
|
+
const contractPath = initializeLoop(rootDir);
|
|
92
|
+
acquireLoop({ root: rootDir, slug: "example", contractPath, sessionId: "session-1", actionId: "resume-1" });
|
|
93
|
+
attestReview({ root: rootDir, slug: "example", reviewerSessionId: "child-1", reviewerAgent: "reviewer", reviewerVerdict: "APPROVE" });
|
|
94
|
+
recordLoopAction({ root: rootDir, slug: "example", sessionId: "session-1", actionId: "done-1", iteration: 1, completedStep: "reviewer_approved", blockingCause: null, status: "completed" });
|
|
95
|
+
fs.writeFileSync(path.join(rootDir, "pr-body.md"), "## What\nA change.\n");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function assertDeliveryRefused(rootDir, code, replies = {}) {
|
|
99
|
+
const calls = [];
|
|
100
|
+
const scripted = { "git rev-parse": "feat/x", "git symbolic-ref": "origin/main", "git status": "", "git rev-list": "1", ...replies };
|
|
101
|
+
const runner = (command, args) => {
|
|
102
|
+
calls.push([command, ...args]);
|
|
103
|
+
const reply = scripted[`${command} ${args[0]}`];
|
|
104
|
+
return reply === undefined ? { status: 1, stdout: "" } : { status: 0, stdout: `${reply}\n` };
|
|
105
|
+
};
|
|
106
|
+
assert.throws(
|
|
107
|
+
() => deliver({ root: rootDir, slug: "example", title: "Add x", bodyFile: "pr-body.md", runner }),
|
|
108
|
+
(error) => error instanceof DeliverError && error.code === code,
|
|
109
|
+
);
|
|
110
|
+
assert.equal(calls.some((call) => call[0] === "gh" || (call[0] === "git" && call[1] === "push")), false);
|
|
111
|
+
}
|
|
112
|
+
|
|
87
113
|
function readAgent(rel) {
|
|
88
114
|
return fs.readFileSync(path.join(root, rel), "utf8");
|
|
89
115
|
}
|
|
@@ -270,6 +296,29 @@ const handlers = {
|
|
|
270
296
|
assert.match(contract, /explicit human approval before installation/);
|
|
271
297
|
},
|
|
272
298
|
|
|
299
|
+
"deliver-default-branch-refused"() {
|
|
300
|
+
withTempDir("opencode-adversarial-deliver-", (rootDir) => {
|
|
301
|
+
completedDeliveryLoop(rootDir);
|
|
302
|
+
assertDeliveryRefused(rootDir, "default_branch", { "git rev-parse": "main" });
|
|
303
|
+
});
|
|
304
|
+
},
|
|
305
|
+
|
|
306
|
+
"deliver-without-attestation-refused"() {
|
|
307
|
+
withTempDir("opencode-adversarial-deliver-", (rootDir) => {
|
|
308
|
+
completedDeliveryLoop(rootDir);
|
|
309
|
+
fs.rmSync(path.join(rootDir, ".opencode/loops/example.review.json"));
|
|
310
|
+
assertDeliveryRefused(rootDir, "attestation_missing");
|
|
311
|
+
});
|
|
312
|
+
},
|
|
313
|
+
|
|
314
|
+
"deliver-private-path-body-refused"() {
|
|
315
|
+
withTempDir("opencode-adversarial-deliver-", (rootDir) => {
|
|
316
|
+
completedDeliveryLoop(rootDir);
|
|
317
|
+
fs.writeFileSync(path.join(rootDir, "pr-body.md"), "Screenshot at /home/someone/shot.png\n");
|
|
318
|
+
assertDeliveryRefused(rootDir, "unsafe_body");
|
|
319
|
+
});
|
|
320
|
+
},
|
|
321
|
+
|
|
273
322
|
"repeated-event-rejected"() {
|
|
274
323
|
withTempDir("opencode-adversarial-event-", (rootDir) => {
|
|
275
324
|
initializeLoop(rootDir);
|
|
@@ -285,7 +334,7 @@ const handlers = {
|
|
|
285
334
|
};
|
|
286
335
|
|
|
287
336
|
test("adversarial corpus maps each threat to one real harness defense", () => {
|
|
288
|
-
assert.equal(scenarios.length,
|
|
337
|
+
assert.equal(scenarios.length, 14);
|
|
289
338
|
assert.deepEqual(
|
|
290
339
|
scenarios.map((scenario) => scenario.id).sort(),
|
|
291
340
|
Object.keys(handlers).sort(),
|
|
@@ -799,7 +799,7 @@ function checkAutonomousContract() {
|
|
|
799
799
|
const text = contractText(read(rel));
|
|
800
800
|
for (const token of [
|
|
801
801
|
"authorization: explicit_command_invocation",
|
|
802
|
-
"execution_scope:
|
|
802
|
+
"execution_scope: feature_branch_to_pull_request",
|
|
803
803
|
"max_iterations_per_invocation: 6",
|
|
804
804
|
"planned_iteration_budget: task_specific_1_to_6",
|
|
805
805
|
"hard_safety_ceiling: 6",
|
|
@@ -812,13 +812,21 @@ function checkAutonomousContract() {
|
|
|
812
812
|
"worktree_mode: prohibited",
|
|
813
813
|
"scheduling: prohibited",
|
|
814
814
|
"parallelism: prohibited",
|
|
815
|
-
"
|
|
816
|
-
"
|
|
815
|
+
"delivery_path: oak_deliver_only",
|
|
816
|
+
"merge_deploy_release_publish: prohibited",
|
|
817
|
+
"default_branch_push: prohibited",
|
|
818
|
+
"force_push: prohibited",
|
|
819
|
+
"ci_fix_attempts_per_job: 2",
|
|
820
|
+
"stop_reasons: closed_list_of_seven",
|
|
821
|
+
"autonomy_log: docs/ai/runs/<date>-<slug>/autonomy.md",
|
|
822
|
+
"run_context: oak_run_required",
|
|
817
823
|
"reviewer_execution: task_subagent_only",
|
|
818
824
|
"reviewer_evidence: required_subagent_attestation",
|
|
819
825
|
"oak state init --root .",
|
|
820
826
|
"task reviewer",
|
|
821
827
|
"oak state attest-review --root .",
|
|
828
|
+
"oak deliver pr --root .",
|
|
829
|
+
"Never merge",
|
|
822
830
|
"developer -> reviewer -> developer (state sync)",
|
|
823
831
|
"Do not create worktrees, schedule runs, execute parallel branches, use network",
|
|
824
832
|
"two iterations without observable progress",
|
|
@@ -1167,6 +1175,7 @@ function checkOrchestratedReviewContract() {
|
|
|
1167
1175
|
["agents/researcher.md", "BEGIN_SPEC_INPUT", "researcher must delimit a forwardable spec_input block"],
|
|
1168
1176
|
["agents/lead.md", "BEGIN_SPEC_INPUT", "lead must forward researcher's spec_input block"],
|
|
1169
1177
|
["agents/lead.md", "Do not re-synthesize the research", "lead must not rewrite research findings before specifier"],
|
|
1178
|
+
["agents/lead.md", "You always delegate. You do none of those things yourself", "lead must never implement"],
|
|
1170
1179
|
["agents/specifier.md", "BEGIN_SPEC_INPUT", "specifier must know the block arrives verbatim"],
|
|
1171
1180
|
]) {
|
|
1172
1181
|
if (exists(specRel) && !read(specRel).includes(specToken)) fail(`${specRel}: missing ${specToken} (${specWhy})`);
|
|
@@ -1317,6 +1326,13 @@ function checkLeadRouterContract() {
|
|
|
1317
1326
|
fail("agents/lead.md: lead edit permission must remain deny");
|
|
1318
1327
|
}
|
|
1319
1328
|
|
|
1329
|
+
// Only the `bash:` block: `task` also defaults to `"*": deny`, and matching
|
|
1330
|
+
// the whole frontmatter would let an `ask` pass.
|
|
1331
|
+
const leadBash = (frontmatter.match(/^ bash:\n((?: .*\n)+)/m) || [])[1] || "";
|
|
1332
|
+
if (!/^\s*"\*":\s*deny\s*$/m.test(leadBash)) {
|
|
1333
|
+
fail('agents/lead.md: bash must default to deny - with --auto an "ask" is auto-approved, which let lead implement instead of delegating');
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1320
1336
|
for (const command of [
|
|
1321
1337
|
'"cd": allow',
|
|
1322
1338
|
'"cd *": allow',
|
|
@@ -2107,6 +2123,9 @@ function checkAdversarialHarnessSurface() {
|
|
|
2107
2123
|
const testRel = "scripts/adversarial-harness.test.mjs";
|
|
2108
2124
|
const requiredThreats = [
|
|
2109
2125
|
"approval-state-manipulation",
|
|
2126
|
+
"delivery-default-branch-push",
|
|
2127
|
+
"delivery-private-path-leak",
|
|
2128
|
+
"delivery-without-review",
|
|
2110
2129
|
"diff-prompt-injection",
|
|
2111
2130
|
"event-corruption-replay",
|
|
2112
2131
|
"external-symlink",
|
|
@@ -2221,7 +2240,7 @@ function checkAdversarialHarnessSurface() {
|
|
|
2221
2240
|
],
|
|
2222
2241
|
[
|
|
2223
2242
|
"docs/ai/evolution/README.md",
|
|
2224
|
-
["Slice 2.5", "
|
|
2243
|
+
["Slice 2.5", "14 threats"],
|
|
2225
2244
|
],
|
|
2226
2245
|
]) {
|
|
2227
2246
|
const text = contractText(read(rel));
|
|
@@ -2874,13 +2893,16 @@ function checkRetryPoliciesContract() {
|
|
|
2874
2893
|
function checkShellExportGuardContract() {
|
|
2875
2894
|
const policyRel = "scripts/shell-export-policy.mjs";
|
|
2876
2895
|
const policyTestRel = "scripts/shell-export-policy.test.mjs";
|
|
2896
|
+
const coreRel = "scripts/shell-export-guard-core.mjs";
|
|
2897
|
+
const v1Rel = "runtime/v1/shell-export-guard.ts";
|
|
2898
|
+
const v2Rel = "runtime/v2/shell-export-guard.ts";
|
|
2877
2899
|
const pluginRel = "plugins/shell-export-guard.ts";
|
|
2900
|
+
const surfaces = [policyRel, policyTestRel, coreRel, v1Rel, v2Rel, pluginRel];
|
|
2878
2901
|
|
|
2879
|
-
for (const rel of
|
|
2902
|
+
for (const rel of surfaces) {
|
|
2880
2903
|
if (!exists(rel)) fail(`${rel}: missing shell export guard surface`);
|
|
2881
2904
|
}
|
|
2882
|
-
|
|
2883
|
-
if (!exists(policyRel) || !exists(policyTestRel) || !exists(pluginRel)) return;
|
|
2905
|
+
if (!surfaces.every(exists)) return;
|
|
2884
2906
|
|
|
2885
2907
|
const policy = read(policyRel);
|
|
2886
2908
|
for (const token of [
|
|
@@ -2895,20 +2917,19 @@ function checkShellExportGuardContract() {
|
|
|
2895
2917
|
}
|
|
2896
2918
|
}
|
|
2897
2919
|
|
|
2898
|
-
const
|
|
2899
|
-
|
|
2900
|
-
"tool.execute.before",
|
|
2901
|
-
"
|
|
2902
|
-
"shell-export-guard",
|
|
2903
|
-
"bash",
|
|
2904
|
-
"shell",
|
|
2920
|
+
for (const [rel, tokens] of [
|
|
2921
|
+
[coreRel, ["classifyShellExport", "shell-export-guard", "bash", "shell"]],
|
|
2922
|
+
[v1Rel, ["tool.execute.before", "assertShellCallAllowed", "oak:v1-only"]],
|
|
2923
|
+
[v2Rel, ['"execute.before"', "assertShellCallAllowed"]],
|
|
2924
|
+
[pluginRel, ["oak.shell-export-guard", "server:", "setup:"]],
|
|
2905
2925
|
]) {
|
|
2906
|
-
|
|
2907
|
-
|
|
2926
|
+
const source = read(rel);
|
|
2927
|
+
for (const token of tokens) {
|
|
2928
|
+
if (!source.includes(token)) fail(`${rel}: missing shell export guard token ${token}`);
|
|
2929
|
+
}
|
|
2930
|
+
if (/\$\{?command\}?/.test(source)) {
|
|
2931
|
+
fail(`${rel}: shell export guard must not include the raw command in diagnostics`);
|
|
2908
2932
|
}
|
|
2909
|
-
}
|
|
2910
|
-
if (/\$\{?command\}?/.test(plugin)) {
|
|
2911
|
-
fail(`${pluginRel}: shell export guard must not include the raw command in diagnostics`);
|
|
2912
2933
|
}
|
|
2913
2934
|
|
|
2914
2935
|
const policyTests = read(policyTestRel);
|
|
@@ -2984,30 +3005,108 @@ function checkRuntimePermissionPolicy() {
|
|
|
2984
3005
|
|
|
2985
3006
|
function checkOpenDesignToolContract() {
|
|
2986
3007
|
const rel = "tools/open_design.ts";
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
3008
|
+
const sharedRel = "tools/open-design-tools.mjs";
|
|
3009
|
+
const surfaces = [rel, sharedRel, "runtime/v2/open-design.ts", "plugins/open-design.ts"];
|
|
3010
|
+
for (const surface of surfaces) {
|
|
3011
|
+
if (!exists(surface)) fail(`${surface}: missing Open Design tool`);
|
|
2990
3012
|
}
|
|
3013
|
+
if (!surfaces.every(exists)) return;
|
|
2991
3014
|
|
|
2992
|
-
const
|
|
3015
|
+
const shared = read(sharedRel);
|
|
2993
3016
|
for (const [label, present] of [
|
|
2994
|
-
["base URL environment",
|
|
2995
|
-
["base URL argument",
|
|
2996
|
-
["trailing slash normalization",
|
|
2997
|
-
["project-path guard",
|
|
3017
|
+
["base URL environment", shared.includes("OPEN_DESIGN_URL")],
|
|
3018
|
+
["base URL argument", shared.includes('baseUrl: "optional"')],
|
|
3019
|
+
["trailing slash normalization", shared.includes('raw.replace(/\\/+$/, "")')],
|
|
3020
|
+
["project-path guard", shared.includes("projects(?:\\/|$)")],
|
|
2998
3021
|
]) {
|
|
2999
|
-
if (!present) fail(`${
|
|
3022
|
+
if (!present) fail(`${sharedRel}: missing Open Design ${label}`);
|
|
3000
3023
|
}
|
|
3001
3024
|
|
|
3025
|
+
const source = `${read(rel)}\n${shared}`;
|
|
3002
3026
|
if (/randomUUID|node:crypto/.test(source)) {
|
|
3003
|
-
fail(`${
|
|
3027
|
+
fail(`${sharedRel}: Open Design tool must not depend on randomUUID or node:crypto`);
|
|
3004
3028
|
}
|
|
3005
3029
|
const privateHostMarker = ["juancan", "as"].join("");
|
|
3006
3030
|
const nasVendorMarker = ["syn", "ology"].join("");
|
|
3007
3031
|
const usersPath = ["/", "Users", "/"].join("");
|
|
3008
3032
|
const homePath = ["/", "home", "/"].join("");
|
|
3009
3033
|
if (new RegExp(`${privateHostMarker}|${nasVendorMarker}|${usersPath}|${homePath}`, "i").test(source)) {
|
|
3010
|
-
fail(`${
|
|
3034
|
+
fail(`${sharedRel}: Open Design tool contains a private endpoint or local path`);
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
|
|
3038
|
+
// OpenCode applies the last matching bash rule, so every git deny must follow
|
|
3039
|
+
// the allow it narrows.
|
|
3040
|
+
const DEVELOPER_GIT_DENIES = [
|
|
3041
|
+
"git add -A*",
|
|
3042
|
+
"git add --all*",
|
|
3043
|
+
"git add -u*",
|
|
3044
|
+
"git add --update*",
|
|
3045
|
+
"git add .",
|
|
3046
|
+
"git add . *",
|
|
3047
|
+
"git add -?A*",
|
|
3048
|
+
"git add -?u*",
|
|
3049
|
+
"git add -?f*",
|
|
3050
|
+
"git add --a*",
|
|
3051
|
+
"git add --u*",
|
|
3052
|
+
"git add --f*",
|
|
3053
|
+
"git add * -A*",
|
|
3054
|
+
"git add * .",
|
|
3055
|
+
"git add ./",
|
|
3056
|
+
"git add ./ *",
|
|
3057
|
+
"git add :/*",
|
|
3058
|
+
"git add -f*",
|
|
3059
|
+
"git add * -f*",
|
|
3060
|
+
"git add *--force*",
|
|
3061
|
+
"git commit * -a*",
|
|
3062
|
+
"git commit *--all*",
|
|
3063
|
+
"git commit * -n*",
|
|
3064
|
+
"git commit *--no-v*",
|
|
3065
|
+
"git commit -a*",
|
|
3066
|
+
"git commit -n*",
|
|
3067
|
+
"git commit *--am*",
|
|
3068
|
+
"git commit * -?a*",
|
|
3069
|
+
"git commit * -?n*",
|
|
3070
|
+
"git commit * .",
|
|
3071
|
+
"git commit * -- *",
|
|
3072
|
+
"git push*",
|
|
3073
|
+
"gh *",
|
|
3074
|
+
"git merge*",
|
|
3075
|
+
"git reset --hard*",
|
|
3076
|
+
"git -C *",
|
|
3077
|
+
"git -c *",
|
|
3078
|
+
"rm *.opencode*",
|
|
3079
|
+
"git branch -d*",
|
|
3080
|
+
"git branch -D*",
|
|
3081
|
+
"git branch --delete*",
|
|
3082
|
+
];
|
|
3083
|
+
const DEVELOPER_GIT_ALLOWS = [
|
|
3084
|
+
["git add ", "git add *"],
|
|
3085
|
+
["git commit ", "git commit -m *"],
|
|
3086
|
+
];
|
|
3087
|
+
|
|
3088
|
+
function checkDeveloperGitPermissions() {
|
|
3089
|
+
const rel = "agents/developer.md";
|
|
3090
|
+
const rules = [];
|
|
3091
|
+
let inBash = false;
|
|
3092
|
+
for (const line of frontmatterBlock(rel).split("\n")) {
|
|
3093
|
+
if (/^ [A-Za-z_]/.test(line)) inBash = /^ bash:\s*$/.test(line);
|
|
3094
|
+
if (!inBash) continue;
|
|
3095
|
+
const match = line.match(/^ "([^"]+)":\s*(allow|ask|deny)$/);
|
|
3096
|
+
if (match) rules.push({ key: match[1], action: match[2] });
|
|
3097
|
+
}
|
|
3098
|
+
const indexOf = (key) => rules.findIndex((rule) => rule.key === key);
|
|
3099
|
+
for (const key of DEVELOPER_GIT_DENIES) {
|
|
3100
|
+
const index = indexOf(key);
|
|
3101
|
+
if (index === -1 || rules[index].action !== "deny") {
|
|
3102
|
+
fail(`${rel}: developer bash must deny ${key}`);
|
|
3103
|
+
continue;
|
|
3104
|
+
}
|
|
3105
|
+
for (const [prefix, allowKey] of DEVELOPER_GIT_ALLOWS) {
|
|
3106
|
+
if (key.startsWith(prefix) && index < indexOf(allowKey)) {
|
|
3107
|
+
fail(`${rel}: developer bash deny ${key} must come after ${allowKey}`);
|
|
3108
|
+
}
|
|
3109
|
+
}
|
|
3011
3110
|
}
|
|
3012
3111
|
}
|
|
3013
3112
|
|
|
@@ -3016,10 +3115,13 @@ function checkMissionRuntimeContract() {
|
|
|
3016
3115
|
"scripts/mission-status.mjs",
|
|
3017
3116
|
"scripts/mission-runtime-observer.mjs",
|
|
3018
3117
|
"scripts/mission-runtime.test.mjs",
|
|
3019
|
-
"
|
|
3118
|
+
"runtime/v1/mission-runtime.ts",
|
|
3020
3119
|
"plugins/mission-runtime.test.mjs",
|
|
3021
3120
|
"commands/loop-status.md",
|
|
3022
3121
|
"docs/ai/specs/mission-runtime.md",
|
|
3122
|
+
"plugins/mission-runtime.ts",
|
|
3123
|
+
"runtime/v2/mission-runtime.ts",
|
|
3124
|
+
"runtime/v2/mission-events.mjs",
|
|
3023
3125
|
];
|
|
3024
3126
|
for (const rel of required) {
|
|
3025
3127
|
if (!exists(rel)) fail(`${rel}: missing mission runtime surface`);
|
|
@@ -3036,13 +3138,27 @@ function checkMissionRuntimeContract() {
|
|
|
3036
3138
|
if (!observer.includes(token)) fail(`${required[1]}: missing observer token ${token}`);
|
|
3037
3139
|
}
|
|
3038
3140
|
|
|
3039
|
-
const plugin = read("
|
|
3141
|
+
const plugin = read("runtime/v1/mission-runtime.ts");
|
|
3040
3142
|
for (const token of ["event:", "chat.message", "showToast", "mission-runtime-observer.mjs"]) {
|
|
3041
3143
|
if (!plugin.includes(token)) fail(`${required[3]}: missing plugin token ${token}`);
|
|
3042
3144
|
}
|
|
3043
|
-
|
|
3145
|
+
const entry = read("plugins/mission-runtime.ts");
|
|
3146
|
+
for (const token of ["oak.mission-runtime", "server:", "setup:"]) {
|
|
3147
|
+
if (!entry.includes(token)) fail(`plugins/mission-runtime.ts: missing plugin token ${token}`);
|
|
3148
|
+
}
|
|
3149
|
+
const v2Plugin = read("runtime/v2/mission-runtime.ts");
|
|
3150
|
+
const v2Events = read("runtime/v2/mission-events.mjs");
|
|
3151
|
+
if (!v2Plugin.includes("event.subscribe")) {
|
|
3152
|
+
fail("runtime/v2/mission-runtime.ts: missing plugin token event.subscribe");
|
|
3153
|
+
}
|
|
3154
|
+
if (/writeFile|appendFile|rename|\.opencode\/loops/.test(`${observer}\n${plugin}\n${entry}\n${v2Plugin}\n${v2Events}`)) {
|
|
3044
3155
|
fail("mission runtime observer: must not write durable loop state");
|
|
3045
3156
|
}
|
|
3157
|
+
for (const rel of ["runtime/v1/mission-runtime.ts", "runtime/v2/mission-runtime.ts"]) {
|
|
3158
|
+
if (!read(rel).includes("appendRunEvent")) {
|
|
3159
|
+
fail(`${rel}: run events must go through appendRunEvent only`);
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3046
3162
|
}
|
|
3047
3163
|
|
|
3048
3164
|
checkConfig();
|
|
@@ -3088,6 +3204,7 @@ checkShellExportGuardContract();
|
|
|
3088
3204
|
checkRuntimePermissionPolicy();
|
|
3089
3205
|
checkOpenDesignToolContract();
|
|
3090
3206
|
checkMissionRuntimeContract();
|
|
3207
|
+
checkDeveloperGitPermissions();
|
|
3091
3208
|
|
|
3092
3209
|
if (errors.length > 0) {
|
|
3093
3210
|
console.error("Harness check failed:");
|
|
@@ -156,6 +156,19 @@ test("shell export guard surfaces are required", () => {
|
|
|
156
156
|
}
|
|
157
157
|
});
|
|
158
158
|
|
|
159
|
+
test("shell export guard OpenCode 2 adapter is required", () => {
|
|
160
|
+
const cwd = makeFixture();
|
|
161
|
+
try {
|
|
162
|
+
fs.rmSync(path.join(cwd, "runtime/v2/shell-export-guard.ts"));
|
|
163
|
+
|
|
164
|
+
const result = runHarness(cwd);
|
|
165
|
+
assert.notEqual(result.status, 0, "checker accepted a missing OpenCode 2 guard adapter");
|
|
166
|
+
assert.match(result.stderr, /runtime\/v2\/shell-export-guard\.ts: missing shell export guard surface/);
|
|
167
|
+
} finally {
|
|
168
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
|
|
159
172
|
for (const [label, mutate, diagnostic] of [
|
|
160
173
|
[
|
|
161
174
|
"missing the Open Design project URL guard",
|
|
@@ -163,23 +176,23 @@ for (const [label, mutate, diagnostic] of [
|
|
|
163
176
|
'if (/\\/projects(?:\\/|$)/.test(url)) {',
|
|
164
177
|
"if (false) {",
|
|
165
178
|
),
|
|
166
|
-
/tools\/
|
|
179
|
+
/tools\/open-design-tools\.mjs: missing Open Design project-path guard/,
|
|
167
180
|
],
|
|
168
181
|
[
|
|
169
182
|
"using randomUUID",
|
|
170
183
|
(source) => `${source}\nconst randomUUID = true\n`,
|
|
171
|
-
/tools\/
|
|
184
|
+
/tools\/open-design-tools\.mjs: Open Design tool must not depend on randomUUID/,
|
|
172
185
|
],
|
|
173
186
|
[
|
|
174
187
|
"containing a private endpoint",
|
|
175
188
|
(source) => `${source}\nconst endpoint = "https://private.synology.example"\n`,
|
|
176
|
-
/tools\/
|
|
189
|
+
/tools\/open-design-tools\.mjs: Open Design tool contains a private endpoint or local path/,
|
|
177
190
|
],
|
|
178
191
|
]) {
|
|
179
192
|
test(`Open Design contract rejects ${label}`, () => {
|
|
180
193
|
const cwd = makeFixture();
|
|
181
194
|
try {
|
|
182
|
-
const rel = "tools/
|
|
195
|
+
const rel = "tools/open-design-tools.mjs";
|
|
183
196
|
const source = fs.readFileSync(path.join(cwd, rel), "utf8");
|
|
184
197
|
write(rel, mutate(source), cwd);
|
|
185
198
|
|
|
@@ -571,12 +584,12 @@ function writeLoopFixture(cwd, command) {
|
|
|
571
584
|
}
|
|
572
585
|
|
|
573
586
|
const validAutonomousCommand = `---
|
|
574
|
-
description: Runs a bounded
|
|
587
|
+
description: Runs a bounded autonomous workflow that ends at an open pull request.
|
|
575
588
|
agent: lead
|
|
576
589
|
---
|
|
577
590
|
|
|
578
591
|
authorization: explicit_command_invocation
|
|
579
|
-
execution_scope:
|
|
592
|
+
execution_scope: feature_branch_to_pull_request
|
|
580
593
|
max_iterations_per_invocation: 6
|
|
581
594
|
planned_iteration_budget: task_specific_1_to_6
|
|
582
595
|
hard_safety_ceiling: 6
|
|
@@ -589,8 +602,14 @@ human_view_path: .opencode/loops/<slug>.md
|
|
|
589
602
|
worktree_mode: prohibited
|
|
590
603
|
scheduling: prohibited
|
|
591
604
|
parallelism: prohibited
|
|
592
|
-
|
|
593
|
-
|
|
605
|
+
delivery_path: oak_deliver_only
|
|
606
|
+
merge_deploy_release_publish: prohibited
|
|
607
|
+
default_branch_push: prohibited
|
|
608
|
+
force_push: prohibited
|
|
609
|
+
ci_fix_attempts_per_job: 2
|
|
610
|
+
stop_reasons: closed_list_of_seven
|
|
611
|
+
autonomy_log: docs/ai/runs/<date>-<slug>/autonomy.md
|
|
612
|
+
run_context: oak_run_required
|
|
594
613
|
reviewer_execution: task_subagent_only
|
|
595
614
|
reviewer_evidence: required_subagent_attestation
|
|
596
615
|
|
|
@@ -599,6 +618,8 @@ developer -> reviewer -> developer (state sync)
|
|
|
599
618
|
oak state init --root .
|
|
600
619
|
task reviewer
|
|
601
620
|
oak state attest-review --root .
|
|
621
|
+
oak deliver pr --root .
|
|
622
|
+
Never merge
|
|
602
623
|
|
|
603
624
|
Do not create worktrees, schedule runs, execute parallel branches, use network or write-capable MCP connectors, or publish changes.
|
|
604
625
|
two iterations without observable progress
|
|
@@ -613,6 +634,27 @@ function writeAutonomousFixture(cwd, command) {
|
|
|
613
634
|
fs.appendFileSync(docsPath, "\n## `/autonomous`\n");
|
|
614
635
|
}
|
|
615
636
|
|
|
637
|
+
test("harness rejects autonomous delivery that may merge, force-push or bypass oak deliver", () => {
|
|
638
|
+
const cwd = makeFixture();
|
|
639
|
+
try {
|
|
640
|
+
writeAutonomousFixture(
|
|
641
|
+
cwd,
|
|
642
|
+
validAutonomousCommand
|
|
643
|
+
.replace("merge_deploy_release_publish: prohibited\n", "")
|
|
644
|
+
.replace("force_push: prohibited\n", "")
|
|
645
|
+
.replace("delivery_path: oak_deliver_only\n", ""),
|
|
646
|
+
);
|
|
647
|
+
|
|
648
|
+
const result = runHarness(cwd);
|
|
649
|
+
assert.notEqual(result.status, 0, "checker accepted an autonomous delivery without its limits");
|
|
650
|
+
assert.match(result.stderr, /commands\/autonomous\.md: missing merge_deploy_release_publish: prohibited/);
|
|
651
|
+
assert.match(result.stderr, /commands\/autonomous\.md: missing force_push: prohibited/);
|
|
652
|
+
assert.match(result.stderr, /commands\/autonomous\.md: missing delivery_path: oak_deliver_only/);
|
|
653
|
+
} finally {
|
|
654
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
|
|
616
658
|
test("harness rejects autonomous work without reviewer-subagent attestation", () => {
|
|
617
659
|
const cwd = makeFixture();
|
|
618
660
|
try {
|
|
@@ -2059,3 +2101,34 @@ test("harness rejects a specialist that claims a final verdict", () => {
|
|
|
2059
2101
|
fs.rmSync(cwd, { recursive: true, force: true });
|
|
2060
2102
|
}
|
|
2061
2103
|
});
|
|
2104
|
+
|
|
2105
|
+
test("developer git permissions deny bulk staging, hook bypass, push and gh after the allows", () => {
|
|
2106
|
+
const cwd = makeFixture();
|
|
2107
|
+
try {
|
|
2108
|
+
const rel = "agents/developer.md";
|
|
2109
|
+
const source = fs.readFileSync(path.join(cwd, rel), "utf8");
|
|
2110
|
+
write(rel, source.replace(' "git push*": deny\n', ""), cwd);
|
|
2111
|
+
const result = runHarness(cwd);
|
|
2112
|
+
assert.notEqual(result.status, 0);
|
|
2113
|
+
assert.match(result.stderr, /agents\/developer\.md: developer bash must deny git push\*/);
|
|
2114
|
+
} finally {
|
|
2115
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
2116
|
+
}
|
|
2117
|
+
});
|
|
2118
|
+
|
|
2119
|
+
test("developer git permissions reject a deny placed before its allow", () => {
|
|
2120
|
+
const cwd = makeFixture();
|
|
2121
|
+
try {
|
|
2122
|
+
const rel = "agents/developer.md";
|
|
2123
|
+
const source = fs.readFileSync(path.join(cwd, rel), "utf8");
|
|
2124
|
+
const moved = source
|
|
2125
|
+
.replace(' "git add -A*": deny\n', "")
|
|
2126
|
+
.replace(' "git add *": allow\n', ' "git add -A*": deny\n "git add *": allow\n');
|
|
2127
|
+
write(rel, moved, cwd);
|
|
2128
|
+
const result = runHarness(cwd);
|
|
2129
|
+
assert.notEqual(result.status, 0);
|
|
2130
|
+
assert.match(result.stderr, /agents\/developer\.md: developer bash deny git add -A\* must come after git add \*/);
|
|
2131
|
+
} finally {
|
|
2132
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
2133
|
+
}
|
|
2134
|
+
});
|
|
@@ -5,6 +5,7 @@ import os from "node:os";
|
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { spawn, spawnSync } from "node:child_process";
|
|
7
7
|
import { pathToFileURL } from "node:url";
|
|
8
|
+
import { SESSION_TABLES_SQL, pickSessionSchemas, sessionQueries } from "./session-sources.mjs";
|
|
8
9
|
|
|
9
10
|
function fail(message) {
|
|
10
11
|
console.error(message);
|
|
@@ -70,6 +71,9 @@ function parseArgs(argv) {
|
|
|
70
71
|
args.sources.push(argv[++i]);
|
|
71
72
|
} else if (token === "--full-rescan") {
|
|
72
73
|
args.fullRescan = true;
|
|
74
|
+
} else if (token === "--run") {
|
|
75
|
+
args.run = argv[++i];
|
|
76
|
+
if (!args.run) fail("--run requires a run-summary.json path");
|
|
73
77
|
} else {
|
|
74
78
|
fail(`Unknown argument: ${token}`);
|
|
75
79
|
}
|
|
@@ -77,6 +81,21 @@ function parseArgs(argv) {
|
|
|
77
81
|
return args;
|
|
78
82
|
}
|
|
79
83
|
|
|
84
|
+
// A run summary lists the sessions the mission-runtime plugin recorded while
|
|
85
|
+
// the run was open; trees containing any of them belong to that run.
|
|
86
|
+
function loadRunSessions(summaryPath) {
|
|
87
|
+
const summary = JSON.parse(fs.readFileSync(summaryPath, "utf8"));
|
|
88
|
+
if (summary?.schema !== "oak.run.summary/1" || typeof summary.run?.run_id !== "string") {
|
|
89
|
+
fail(`--run must reference an oak.run.summary/1 file: ${summaryPath}`);
|
|
90
|
+
}
|
|
91
|
+
const sessionIds = new Set(
|
|
92
|
+
(Array.isArray(summary.events) ? summary.events : [])
|
|
93
|
+
.filter((event) => event?.type === "agent_session" && typeof event.session_id === "string")
|
|
94
|
+
.map((event) => event.session_id),
|
|
95
|
+
);
|
|
96
|
+
return { runId: summary.run.run_id, sessionIds };
|
|
97
|
+
}
|
|
98
|
+
|
|
80
99
|
function defaultSources() {
|
|
81
100
|
const home = os.homedir();
|
|
82
101
|
const sources = [path.join(home, ".local", "share", "opencode", "opencode.db")];
|
|
@@ -310,46 +329,41 @@ async function summarizeSqlite(dbPath, previousCursor, fullRescan) {
|
|
|
310
329
|
const cutoff = !fullRescan && previousCursor ? previousCursor.cursor_end_time_updated_max : null;
|
|
311
330
|
const cutoffFilter = cutoff ? `AND time_created > ${Number(cutoff)}` : "";
|
|
312
331
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
select
|
|
318
|
-
id,
|
|
319
|
-
project_id,
|
|
320
|
-
parent_id,
|
|
321
|
-
slug,
|
|
322
|
-
directory,
|
|
323
|
-
title,
|
|
324
|
-
version,
|
|
325
|
-
time_created,
|
|
326
|
-
time_updated,
|
|
327
|
-
workspace_id,
|
|
328
|
-
path,
|
|
329
|
-
agent,
|
|
330
|
-
model,
|
|
331
|
-
cost,
|
|
332
|
-
tokens_input,
|
|
333
|
-
tokens_output,
|
|
334
|
-
tokens_reasoning,
|
|
335
|
-
tokens_cache_read,
|
|
336
|
-
tokens_cache_write
|
|
337
|
-
from session
|
|
338
|
-
order by time_updated desc, id desc;
|
|
339
|
-
`,
|
|
340
|
-
300_000,
|
|
341
|
-
);
|
|
332
|
+
const schemas = pickSessionSchemas(await streamSqliteJson(dbPath, SESSION_TABLES_SQL, 300_000)).map((schema) => ({
|
|
333
|
+
schema,
|
|
334
|
+
queries: sessionQueries(schema, { fullRescan, cutoffFilter }),
|
|
335
|
+
}));
|
|
342
336
|
|
|
343
|
-
//
|
|
344
|
-
//
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
337
|
+
// Session query: always full (lightweight, needed for parent resolution)
|
|
338
|
+
// A session can be in both schemas: OpenCode 2 imports OpenCode 1 sessions,
|
|
339
|
+
// and OpenCode 1 can keep using one after switching back. The most recently
|
|
340
|
+
// updated copy owns the session; on a tie the earlier schema (OpenCode 2) wins.
|
|
341
|
+
const owners = new Map();
|
|
342
|
+
for (const { schema, queries } of schemas) {
|
|
343
|
+
for (const row of await streamSqliteJson(dbPath, queries.sessions, 300_000)) {
|
|
344
|
+
const owner = owners.get(row.id);
|
|
345
|
+
if (!owner || (row.time_updated ?? 0) > (owner.row.time_updated ?? 0)) owners.set(row.id, { schema, row });
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
// Same order as the session SQL: time_updated desc, id desc (binary).
|
|
349
|
+
const sessions = [...owners.values()]
|
|
350
|
+
.map((owner) => owner.row)
|
|
351
|
+
.sort((a, b) => (b.time_updated ?? 0) - (a.time_updated ?? 0) || (a.id < b.id ? 1 : a.id > b.id ? -1 : 0));
|
|
352
|
+
|
|
353
|
+
// Rows are appended one by one: spreading hundreds of thousands of rows into
|
|
354
|
+
// push() exceeds the engine's argument limit.
|
|
355
|
+
const messages = [];
|
|
356
|
+
const parts = [];
|
|
357
|
+
for (const { schema, queries } of schemas) {
|
|
358
|
+
const owned = (row) => owners.get(row.session_id)?.schema === schema;
|
|
359
|
+
|
|
360
|
+
// Message query: extract only role from JSON data (reduces output from ~31MB to ~200KB)
|
|
361
|
+
// Apply time cutoff when not in full-rescan mode
|
|
362
|
+
for (const row of await streamSqliteJson(dbPath, queries.messages, 300_000)) if (owned(row)) messages.push(row);
|
|
363
|
+
|
|
364
|
+
// Part query: need full data for text extraction, but apply time cutoff to reduce rows scanned
|
|
365
|
+
for (const row of await streamSqliteJson(dbPath, queries.parts, 300_000)) if (owned(row)) parts.push(row);
|
|
366
|
+
}
|
|
353
367
|
|
|
354
368
|
const messagesBySession = new Map();
|
|
355
369
|
for (const message of messages) {
|
|
@@ -780,8 +794,12 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
780
794
|
}
|
|
781
795
|
|
|
782
796
|
const built = buildExecutionTrees(sqliteRows, rawRows, previousCursor, args.fullRescan, userTurnTimesBySession);
|
|
797
|
+
const runSessions = args.run ? loadRunSessions(path.resolve(args.run)) : null;
|
|
783
798
|
for (const tree of built.trees) {
|
|
784
799
|
tree.telemetry.diff_size = measureDiffSize(tree.root_directory);
|
|
800
|
+
if (runSessions) {
|
|
801
|
+
tree.run_id = tree.session_ids.some((id) => runSessions.sessionIds.has(id)) ? runSessions.runId : null;
|
|
802
|
+
}
|
|
785
803
|
}
|
|
786
804
|
const acceptedSessionIds = new Set(built.trees.flatMap((tree) => tree.session_ids));
|
|
787
805
|
const filteredSessionRows = sortSessions(sqliteRows.filter((row) => acceptedSessionIds.has(row.session_id)));
|