opencode-agent-orchestration-kit 1.0.45 → 1.1.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/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.1.0.md +91 -0
- package/docs/releases/v1.1.1.md +54 -0
- package/docs/supply-chain.md +10 -8
- 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 +19 -9
- 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 +8 -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 +142 -33
- package/opencode/scripts/check-harness.test.mjs +81 -8
- package/opencode/scripts/collect-session-evidence.mjs +59 -43
- 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/session-sources.test.mjs +41 -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 +4 -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 +24 -57
- package/scripts/check-supply-chain.test.mjs +37 -35
- 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.test.mjs +3 -3
- package/scripts/version.test.mjs +2 -2
- package/supply-chain.json +0 -4
- package/docs/superpowers.md +0 -41
|
@@ -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",
|
|
@@ -2115,6 +2123,9 @@ function checkAdversarialHarnessSurface() {
|
|
|
2115
2123
|
const testRel = "scripts/adversarial-harness.test.mjs";
|
|
2116
2124
|
const requiredThreats = [
|
|
2117
2125
|
"approval-state-manipulation",
|
|
2126
|
+
"delivery-default-branch-push",
|
|
2127
|
+
"delivery-private-path-leak",
|
|
2128
|
+
"delivery-without-review",
|
|
2118
2129
|
"diff-prompt-injection",
|
|
2119
2130
|
"event-corruption-replay",
|
|
2120
2131
|
"external-symlink",
|
|
@@ -2229,7 +2240,7 @@ function checkAdversarialHarnessSurface() {
|
|
|
2229
2240
|
],
|
|
2230
2241
|
[
|
|
2231
2242
|
"docs/ai/evolution/README.md",
|
|
2232
|
-
["Slice 2.5", "
|
|
2243
|
+
["Slice 2.5", "14 threats"],
|
|
2233
2244
|
],
|
|
2234
2245
|
]) {
|
|
2235
2246
|
const text = contractText(read(rel));
|
|
@@ -2882,13 +2893,16 @@ function checkRetryPoliciesContract() {
|
|
|
2882
2893
|
function checkShellExportGuardContract() {
|
|
2883
2894
|
const policyRel = "scripts/shell-export-policy.mjs";
|
|
2884
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";
|
|
2885
2899
|
const pluginRel = "plugins/shell-export-guard.ts";
|
|
2900
|
+
const surfaces = [policyRel, policyTestRel, coreRel, v1Rel, v2Rel, pluginRel];
|
|
2886
2901
|
|
|
2887
|
-
for (const rel of
|
|
2902
|
+
for (const rel of surfaces) {
|
|
2888
2903
|
if (!exists(rel)) fail(`${rel}: missing shell export guard surface`);
|
|
2889
2904
|
}
|
|
2890
|
-
|
|
2891
|
-
if (!exists(policyRel) || !exists(policyTestRel) || !exists(pluginRel)) return;
|
|
2905
|
+
if (!surfaces.every(exists)) return;
|
|
2892
2906
|
|
|
2893
2907
|
const policy = read(policyRel);
|
|
2894
2908
|
for (const token of [
|
|
@@ -2903,20 +2917,19 @@ function checkShellExportGuardContract() {
|
|
|
2903
2917
|
}
|
|
2904
2918
|
}
|
|
2905
2919
|
|
|
2906
|
-
const
|
|
2907
|
-
|
|
2908
|
-
"tool.execute.before",
|
|
2909
|
-
"
|
|
2910
|
-
"shell-export-guard",
|
|
2911
|
-
"bash",
|
|
2912
|
-
"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:"]],
|
|
2913
2925
|
]) {
|
|
2914
|
-
|
|
2915
|
-
|
|
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`);
|
|
2916
2932
|
}
|
|
2917
|
-
}
|
|
2918
|
-
if (/\$\{?command\}?/.test(plugin)) {
|
|
2919
|
-
fail(`${pluginRel}: shell export guard must not include the raw command in diagnostics`);
|
|
2920
2933
|
}
|
|
2921
2934
|
|
|
2922
2935
|
const policyTests = read(policyTestRel);
|
|
@@ -2992,30 +3005,108 @@ function checkRuntimePermissionPolicy() {
|
|
|
2992
3005
|
|
|
2993
3006
|
function checkOpenDesignToolContract() {
|
|
2994
3007
|
const rel = "tools/open_design.ts";
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
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`);
|
|
2998
3012
|
}
|
|
3013
|
+
if (!surfaces.every(exists)) return;
|
|
2999
3014
|
|
|
3000
|
-
const
|
|
3015
|
+
const shared = read(sharedRel);
|
|
3001
3016
|
for (const [label, present] of [
|
|
3002
|
-
["base URL environment",
|
|
3003
|
-
["base URL argument",
|
|
3004
|
-
["trailing slash normalization",
|
|
3005
|
-
["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(?:\\/|$)")],
|
|
3006
3021
|
]) {
|
|
3007
|
-
if (!present) fail(`${
|
|
3022
|
+
if (!present) fail(`${sharedRel}: missing Open Design ${label}`);
|
|
3008
3023
|
}
|
|
3009
3024
|
|
|
3025
|
+
const source = `${read(rel)}\n${shared}`;
|
|
3010
3026
|
if (/randomUUID|node:crypto/.test(source)) {
|
|
3011
|
-
fail(`${
|
|
3027
|
+
fail(`${sharedRel}: Open Design tool must not depend on randomUUID or node:crypto`);
|
|
3012
3028
|
}
|
|
3013
3029
|
const privateHostMarker = ["juancan", "as"].join("");
|
|
3014
3030
|
const nasVendorMarker = ["syn", "ology"].join("");
|
|
3015
3031
|
const usersPath = ["/", "Users", "/"].join("");
|
|
3016
3032
|
const homePath = ["/", "home", "/"].join("");
|
|
3017
3033
|
if (new RegExp(`${privateHostMarker}|${nasVendorMarker}|${usersPath}|${homePath}`, "i").test(source)) {
|
|
3018
|
-
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
|
+
}
|
|
3019
3110
|
}
|
|
3020
3111
|
}
|
|
3021
3112
|
|
|
@@ -3024,10 +3115,13 @@ function checkMissionRuntimeContract() {
|
|
|
3024
3115
|
"scripts/mission-status.mjs",
|
|
3025
3116
|
"scripts/mission-runtime-observer.mjs",
|
|
3026
3117
|
"scripts/mission-runtime.test.mjs",
|
|
3027
|
-
"
|
|
3118
|
+
"runtime/v1/mission-runtime.ts",
|
|
3028
3119
|
"plugins/mission-runtime.test.mjs",
|
|
3029
3120
|
"commands/loop-status.md",
|
|
3030
3121
|
"docs/ai/specs/mission-runtime.md",
|
|
3122
|
+
"plugins/mission-runtime.ts",
|
|
3123
|
+
"runtime/v2/mission-runtime.ts",
|
|
3124
|
+
"runtime/v2/mission-events.mjs",
|
|
3031
3125
|
];
|
|
3032
3126
|
for (const rel of required) {
|
|
3033
3127
|
if (!exists(rel)) fail(`${rel}: missing mission runtime surface`);
|
|
@@ -3044,13 +3138,27 @@ function checkMissionRuntimeContract() {
|
|
|
3044
3138
|
if (!observer.includes(token)) fail(`${required[1]}: missing observer token ${token}`);
|
|
3045
3139
|
}
|
|
3046
3140
|
|
|
3047
|
-
const plugin = read("
|
|
3141
|
+
const plugin = read("runtime/v1/mission-runtime.ts");
|
|
3048
3142
|
for (const token of ["event:", "chat.message", "showToast", "mission-runtime-observer.mjs"]) {
|
|
3049
3143
|
if (!plugin.includes(token)) fail(`${required[3]}: missing plugin token ${token}`);
|
|
3050
3144
|
}
|
|
3051
|
-
|
|
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}`)) {
|
|
3052
3155
|
fail("mission runtime observer: must not write durable loop state");
|
|
3053
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
|
+
}
|
|
3054
3162
|
}
|
|
3055
3163
|
|
|
3056
3164
|
checkConfig();
|
|
@@ -3096,6 +3204,7 @@ checkShellExportGuardContract();
|
|
|
3096
3204
|
checkRuntimePermissionPolicy();
|
|
3097
3205
|
checkOpenDesignToolContract();
|
|
3098
3206
|
checkMissionRuntimeContract();
|
|
3207
|
+
checkDeveloperGitPermissions();
|
|
3099
3208
|
|
|
3100
3209
|
if (errors.length > 0) {
|
|
3101
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, { 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: text parts only, with the time cutoff when not in full-rescan mode
|
|
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) {
|
|
@@ -387,10 +401,8 @@ async function summarizeSqlite(dbPath, previousCursor, fullRescan) {
|
|
|
387
401
|
const userMessages = [];
|
|
388
402
|
const assistantMessages = [];
|
|
389
403
|
for (const message of sessionMessages) {
|
|
390
|
-
//
|
|
391
|
-
|
|
392
|
-
const parsedData = parseJson(message.data);
|
|
393
|
-
const role = message.role || (parsedData.ok ? parsedData.value?.role : null);
|
|
404
|
+
// The message query extracts the role in SQL.
|
|
405
|
+
const role = message.role;
|
|
394
406
|
if (role === "user") userMessages.push(message);
|
|
395
407
|
if (role === "assistant") assistantMessages.push(message);
|
|
396
408
|
}
|
|
@@ -780,8 +792,12 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
780
792
|
}
|
|
781
793
|
|
|
782
794
|
const built = buildExecutionTrees(sqliteRows, rawRows, previousCursor, args.fullRescan, userTurnTimesBySession);
|
|
795
|
+
const runSessions = args.run ? loadRunSessions(path.resolve(args.run)) : null;
|
|
783
796
|
for (const tree of built.trees) {
|
|
784
797
|
tree.telemetry.diff_size = measureDiffSize(tree.root_directory);
|
|
798
|
+
if (runSessions) {
|
|
799
|
+
tree.run_id = tree.session_ids.some((id) => runSessions.sessionIds.has(id)) ? runSessions.runId : null;
|
|
800
|
+
}
|
|
785
801
|
}
|
|
786
802
|
const acceptedSessionIds = new Set(built.trees.flatMap((tree) => tree.session_ids));
|
|
787
803
|
const filteredSessionRows = sortSessions(sqliteRows.filter((row) => acceptedSessionIds.has(row.session_id)));
|