opencode-agent-orchestration-kit 1.0.39 → 1.0.41

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.
Files changed (51) hide show
  1. package/README.md +12 -3
  2. package/docker/open-design/data/app.sqlite +0 -0
  3. package/docker/open-design/data/app.sqlite-shm +0 -0
  4. package/docker/open-design/data/app.sqlite-wal +0 -0
  5. package/docker/open-design/opencode-auth/log/2026-05-02T105802.log +17 -0
  6. package/docker/open-design/opencode-auth/log/2026-05-04T102127.log +16 -0
  7. package/docker/open-design/opencode-auth/opencode.db +0 -0
  8. package/docker/open-design/opencode-auth/opencode.db-shm +0 -0
  9. package/docker/open-design/opencode-auth/opencode.db-wal +0 -0
  10. package/docs/models.md +1 -1
  11. package/docs/performance/native-tools-benchmark.md +33 -0
  12. package/docs/releases/v1.0.40.md +55 -0
  13. package/docs/releases/v1.0.41.md +42 -0
  14. package/docs/sync-boundary.md +27 -0
  15. package/opencode/commands/loop-status.md +24 -0
  16. package/opencode/commands/loop.md +8 -0
  17. package/opencode/docs/ai/harness/agents.md +8 -0
  18. package/opencode/docs/ai/harness/checks.md +6 -0
  19. package/opencode/docs/ai/harness/commands.md +10 -0
  20. package/opencode/docs/ai/harness/orchestration-contracts.json +9 -1
  21. package/opencode/docs/ai/specs/mission-runtime.md +44 -0
  22. package/opencode/plugins/mission-runtime.test.mjs +46 -0
  23. package/opencode/plugins/mission-runtime.ts +41 -0
  24. package/opencode/scripts/check-harness.mjs +111 -0
  25. package/opencode/scripts/check-harness.test.mjs +37 -1
  26. package/opencode/scripts/loop-state.mjs +5 -0
  27. package/opencode/scripts/loop-state.test.mjs +13 -0
  28. package/opencode/scripts/mission-runtime-observer.d.mts +25 -0
  29. package/opencode/scripts/mission-runtime-observer.mjs +124 -0
  30. package/opencode/scripts/mission-runtime.test.mjs +97 -0
  31. package/opencode/scripts/mission-status.mjs +136 -0
  32. package/opencode/scripts/mission-status.test.mjs +196 -0
  33. package/opencode/scripts/project-capability-snapshot.mjs +2 -1
  34. package/opencode/scripts/project-capability-snapshot.test.mjs +17 -0
  35. package/opencode/scripts/runtime-permission-policy.mjs +72 -0
  36. package/opencode/scripts/runtime-permission-policy.test.mjs +89 -0
  37. package/opencode/tools/open_design.ts +1 -1
  38. package/package.json +3 -3
  39. package/scripts/benchmark-tool-paths.mjs +226 -0
  40. package/scripts/benchmark-tool-paths.test.mjs +29 -0
  41. package/scripts/check-public-boundary.mjs +89 -0
  42. package/scripts/check-public-boundary.test.mjs +32 -0
  43. package/scripts/check.sh +15 -10
  44. package/scripts/install-smoke.sh +17 -0
  45. package/scripts/manage-installation.mjs +90 -7
  46. package/scripts/manage-installation.test.mjs +36 -0
  47. package/scripts/oc-switch.mjs +2 -1
  48. package/scripts/oc-switch.test.mjs +38 -0
  49. package/scripts/package-smoke.mjs +52 -3
  50. package/scripts/package-smoke.test.mjs +6 -6
  51. package/scripts/version.test.mjs +2 -2
@@ -224,6 +224,23 @@ test("repo with go.mod detects go stack", () => {
224
224
  }
225
225
  });
226
226
 
227
+ test("repo with Node scripts detects node stack without a package manifest", () => {
228
+ const tmp = makeRepoWith({
229
+ "scripts/tool.mjs": "#!/usr/bin/env node\nconsole.log('ok');\n",
230
+ });
231
+ try {
232
+ const result = runSnapshot(tmp);
233
+ const snapshot = parseOutput(result);
234
+
235
+ const node = snapshot.stacks_detected.find((stack) => stack.id === "node");
236
+ assert.ok(node, "should detect node stack");
237
+ assert.equal(node.confidence, "medium");
238
+ assert.ok(node.evidence.includes("scripts/tool.mjs"));
239
+ } finally {
240
+ fs.rmSync(tmp, { recursive: true, force: true });
241
+ }
242
+ });
243
+
227
244
  // ── Test 11: Custom repo with test files detects testing domain ─────────
228
245
 
229
246
  test("repo with test files detects testing domain", () => {
@@ -0,0 +1,72 @@
1
+ const DECISIONS = Object.freeze(["allow", "ask", "deny"]);
2
+
3
+ export const AGENT_IDS = Object.freeze([
4
+ "debugger",
5
+ "designer",
6
+ "developer",
7
+ "evaluator",
8
+ "evolver",
9
+ "lead",
10
+ "researcher",
11
+ "review_api",
12
+ "review_coordinator",
13
+ "review_quality",
14
+ "review_security",
15
+ "review_tests",
16
+ "reviewer",
17
+ "scoper",
18
+ "specifier",
19
+ ]);
20
+
21
+ export const POLICY_OPERATIONS = Object.freeze([
22
+ "read",
23
+ "write",
24
+ "shell",
25
+ "network",
26
+ "commit",
27
+ "push",
28
+ "deploy",
29
+ "delegate",
30
+ ]);
31
+
32
+ const common = {
33
+ read: "allow",
34
+ shell: "ask",
35
+ commit: "deny",
36
+ push: "deny",
37
+ deploy: "deny",
38
+ };
39
+
40
+ export const AGENT_POLICIES = Object.freeze({
41
+ debugger: Object.freeze({ ...common, repository_write: "unspecified", task_default: "unspecified", write: "ask", network: "allow", delegate_to: [] }),
42
+ designer: Object.freeze({ ...common, repository_write: "ask", task_default: "unspecified", write: "ask", network: "allow", delegate_to: [] }),
43
+ developer: Object.freeze({ ...common, repository_write: "allow", task_default: "unspecified", write: "allow", network: "ask", commit: "ask", delegate_to: [] }),
44
+ evaluator: Object.freeze({ ...common, repository_write: "unspecified", task_default: "unspecified", write: "ask", network: "ask", delegate_to: [] }),
45
+ evolver: Object.freeze({ ...common, repository_write: "unspecified", task_default: "unspecified", write: "ask", network: "ask", delegate_to: [] }),
46
+ lead: Object.freeze({ ...common, repository_write: "deny", task_default: "deny", write: "deny", network: "allow", delegate_to: ["debugger", "designer", "developer", "evaluator", "evolver", "researcher", "reviewer", "specifier"] }),
47
+ researcher: Object.freeze({ ...common, repository_write: "ask", task_default: "unspecified", write: "ask", network: "allow", delegate_to: [] }),
48
+ review_api: Object.freeze({ ...common, repository_write: "deny", task_default: "unspecified", write: "deny", network: "deny", delegate_to: [] }),
49
+ review_coordinator: Object.freeze({ ...common, repository_write: "deny", task_default: "deny", write: "deny", network: "deny", delegate_to: ["review_api", "review_quality", "review_security", "review_tests"] }),
50
+ review_quality: Object.freeze({ ...common, repository_write: "deny", task_default: "unspecified", write: "deny", network: "deny", delegate_to: [] }),
51
+ review_security: Object.freeze({ ...common, repository_write: "deny", task_default: "unspecified", write: "deny", network: "deny", delegate_to: [] }),
52
+ review_tests: Object.freeze({ ...common, repository_write: "deny", task_default: "unspecified", write: "deny", network: "deny", delegate_to: [] }),
53
+ reviewer: Object.freeze({ ...common, repository_write: "deny", task_default: "unspecified", write: "deny", network: "ask", delegate_to: [] }),
54
+ scoper: Object.freeze({ ...common, repository_write: "unspecified", task_default: "deny", write: "ask", network: "allow", delegate_to: ["debugger", "researcher", "specifier"] }),
55
+ specifier: Object.freeze({ ...common, repository_write: "ask", task_default: "unspecified", write: "ask", network: "allow", delegate_to: [] }),
56
+ });
57
+
58
+ function isDecision(value) {
59
+ return DECISIONS.includes(value);
60
+ }
61
+
62
+ export function decideToolAccess({ agentId, operation, target } = {}) {
63
+ const policy = AGENT_POLICIES[agentId];
64
+ if (!policy || !POLICY_OPERATIONS.includes(operation)) return "deny";
65
+
66
+ if (operation === "delegate") {
67
+ return policy.delegate_to.includes(target) ? "allow" : "deny";
68
+ }
69
+
70
+ const decision = policy[operation];
71
+ return isDecision(decision) ? decision : "deny";
72
+ }
@@ -0,0 +1,89 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+
4
+ import {
5
+ AGENT_IDS,
6
+ POLICY_OPERATIONS,
7
+ decideToolAccess,
8
+ } from "./runtime-permission-policy.mjs";
9
+
10
+ test("policy covers every configured agent and operation", () => {
11
+ assert.deepEqual(AGENT_IDS, [
12
+ "debugger",
13
+ "designer",
14
+ "developer",
15
+ "evaluator",
16
+ "evolver",
17
+ "lead",
18
+ "researcher",
19
+ "review_api",
20
+ "review_coordinator",
21
+ "review_quality",
22
+ "review_security",
23
+ "review_tests",
24
+ "reviewer",
25
+ "scoper",
26
+ "specifier",
27
+ ]);
28
+ assert.deepEqual(POLICY_OPERATIONS, [
29
+ "read",
30
+ "write",
31
+ "shell",
32
+ "network",
33
+ "commit",
34
+ "push",
35
+ "deploy",
36
+ "delegate",
37
+ ]);
38
+ });
39
+
40
+ test("role policy denies lead and reviewer implementation writes", () => {
41
+ assert.equal(decideToolAccess({ agentId: "lead", operation: "write" }), "deny");
42
+ assert.equal(decideToolAccess({ agentId: "reviewer", operation: "write" }), "deny");
43
+ assert.equal(decideToolAccess({ agentId: "developer", operation: "write" }), "allow");
44
+ assert.equal(decideToolAccess({ agentId: "designer", operation: "write" }), "ask");
45
+ });
46
+
47
+ test("delegation is restricted to the declared task allowlist", () => {
48
+ assert.equal(
49
+ decideToolAccess({ agentId: "lead", operation: "delegate", target: "developer" }),
50
+ "allow",
51
+ );
52
+ assert.equal(
53
+ decideToolAccess({ agentId: "lead", operation: "delegate", target: "unknown" }),
54
+ "deny",
55
+ );
56
+ assert.equal(
57
+ decideToolAccess({ agentId: "scoper", operation: "delegate", target: "researcher" }),
58
+ "allow",
59
+ );
60
+ assert.equal(
61
+ decideToolAccess({ agentId: "reviewer", operation: "delegate", target: "developer" }),
62
+ "deny",
63
+ );
64
+ assert.equal(
65
+ decideToolAccess({ agentId: "review_coordinator", operation: "delegate", target: "review_security" }),
66
+ "allow",
67
+ );
68
+ });
69
+
70
+ test("publication and deployment operations are denied for every role", () => {
71
+ for (const agentId of AGENT_IDS) {
72
+ assert.equal(decideToolAccess({ agentId, operation: "push" }), "deny", agentId);
73
+ assert.equal(decideToolAccess({ agentId, operation: "deploy" }), "deny", agentId);
74
+ }
75
+ });
76
+
77
+ test("unknown identities and operations never receive implicit allow", () => {
78
+ assert.equal(decideToolAccess({ agentId: "not-an-agent", operation: "write" }), "deny");
79
+ assert.equal(decideToolAccess({ agentId: "developer", operation: "not-an-operation" }), "deny");
80
+ assert.equal(decideToolAccess({ agentId: "developer", operation: "delegate", target: "reviewer" }), "deny");
81
+ });
82
+
83
+ test("specialist reviewers cannot write, delegate, or use network tools", () => {
84
+ for (const agentId of ["review_api", "review_quality", "review_security", "review_tests"]) {
85
+ assert.equal(decideToolAccess({ agentId, operation: "write" }), "deny", agentId);
86
+ assert.equal(decideToolAccess({ agentId, operation: "delegate", target: "developer" }), "deny", agentId);
87
+ assert.equal(decideToolAccess({ agentId, operation: "network" }), "deny", agentId);
88
+ }
89
+ });
@@ -40,7 +40,7 @@ function baseUrl(input?: string) {
40
40
  }
41
41
 
42
42
  const url = raw.replace(/\/+$/, "")
43
- if (/\/projects\//.test(url)) {
43
+ if (/\/projects(?:\/|$)/.test(url)) {
44
44
  throw new Error("OPEN_DESIGN_URL must be the Open Design base URL, not a project or file URL.")
45
45
  }
46
46
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-agent-orchestration-kit",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -35,8 +35,8 @@
35
35
  "check:compatibility": "node scripts/check-compatibility.mjs",
36
36
  "check:supply-chain": "node scripts/check-supply-chain.mjs",
37
37
  "contract-check": "bash scripts/check.sh",
38
- "unit-and-script-tests": "node --test scripts/*.test.mjs opencode/scripts/*.test.mjs",
39
- "typecheck": "npm --prefix opencode exec -- tsc --noEmit --jsx preserve --jsxImportSource @opentui/solid --module NodeNext --moduleResolution NodeNext --target ES2022 --strict --skipLibCheck opencode/plugins/token-tree-usage.tsx opencode/plugins/shell-export-guard.ts opencode/tools/open_design.ts",
38
+ "unit-and-script-tests": "node --test scripts/*.test.mjs opencode/scripts/*.test.mjs opencode/plugins/mission-runtime.test.mjs",
39
+ "typecheck": "npm --prefix opencode exec -- tsc --noEmit --jsx preserve --jsxImportSource @opentui/solid --module NodeNext --moduleResolution NodeNext --target ES2022 --strict --skipLibCheck opencode/plugins/token-tree-usage.tsx opencode/plugins/shell-export-guard.ts opencode/plugins/mission-runtime.ts opencode/tools/open_design.ts",
40
40
  "dependency-audit": "npm --prefix opencode audit --omit=dev --audit-level=low",
41
41
  "dependency-signature-audit": "npm --prefix opencode audit signatures",
42
42
  "installation-smoke": "bash scripts/install-smoke.sh",
@@ -0,0 +1,226 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "node:fs";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+ import { performance } from "node:perf_hooks";
7
+ import { spawnSync } from "node:child_process";
8
+ import { fileURLToPath } from "node:url";
9
+
10
+ import { createInstallationManager } from "./manage-installation.mjs";
11
+ import { generateSnapshot } from "../opencode/scripts/project-capability-snapshot.mjs";
12
+
13
+ const SCRIPT_PATH = fileURLToPath(import.meta.url);
14
+ const REPOSITORY_ROOT = path.dirname(path.dirname(SCRIPT_PATH));
15
+ const DEFAULT_ITERATIONS = 5;
16
+ const SKIP_DIRS = new Set([".git", "node_modules", ".cache", "dist", "build"]);
17
+ const SEARCH_PATTERN = /agent|orchestrat|mission|runtime/giu;
18
+
19
+ function invalid(message) {
20
+ const error = new Error(message);
21
+ error.code = "INVALID_BENCHMARK";
22
+ return error;
23
+ }
24
+
25
+ function walkFiles(root) {
26
+ const files = [];
27
+ function walk(directory, relative = "") {
28
+ for (const entry of fs.readdirSync(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
29
+ if (entry.isDirectory() && SKIP_DIRS.has(entry.name)) continue;
30
+ const child = relative ? `${relative}/${entry.name}` : entry.name;
31
+ const full = path.join(directory, entry.name);
32
+ if (entry.isDirectory()) walk(full, child);
33
+ else if (entry.isFile()) files.push({ relative: child, full });
34
+ }
35
+ }
36
+ walk(root);
37
+ return files;
38
+ }
39
+
40
+ function searchFiles(files) {
41
+ let matches = 0;
42
+ for (const file of files) {
43
+ const stat = fs.statSync(file.full);
44
+ if (stat.size > 512 * 1024) continue;
45
+ const text = fs.readFileSync(file.full, "utf8");
46
+ matches += text.match(SEARCH_PATTERN)?.length ?? 0;
47
+ }
48
+ return matches;
49
+ }
50
+
51
+ function parseFixture(root) {
52
+ const result = spawnSync(process.execPath, ["--check", root], { encoding: "utf8" });
53
+ if (result.status !== 0) throw invalid("Node parser benchmark command failed");
54
+ return result.status;
55
+ }
56
+
57
+ function createFixture(parent, name, fileCount) {
58
+ const root = path.join(parent, name);
59
+ const sourceRoot = path.join(root, "opencode");
60
+ fs.mkdirSync(path.join(root, "scripts"), { recursive: true });
61
+ fs.mkdirSync(path.join(sourceRoot, "agents"), { recursive: true });
62
+ fs.mkdirSync(path.join(sourceRoot, "docs", "ai", "harness"), { recursive: true });
63
+ fs.writeFileSync(path.join(root, "package.json"), '{"name":"benchmark-fixture","version":"1.0.0"}\n');
64
+ fs.writeFileSync(path.join(root, "scripts", "fixture.mjs"), "export const fixture = 'orchestration runtime agent mission';\n");
65
+ for (let index = 0; index < fileCount; index += 1) {
66
+ const directory = index % 2 === 0 ? path.join(sourceRoot, "agents") : path.join(sourceRoot, "docs", "ai", "harness");
67
+ fs.writeFileSync(path.join(directory, `fixture-${String(index).padStart(4, "0")}.md`), `agent ${index} orchestration runtime\n`);
68
+ }
69
+ return {
70
+ id: name,
71
+ root,
72
+ sourceRoot,
73
+ astFile: path.join(root, "scripts", "fixture.mjs"),
74
+ type: "synthetic",
75
+ files: fileCount + 3,
76
+ };
77
+ }
78
+
79
+ function safeRemove(parent, root) {
80
+ const relative = path.relative(parent, root);
81
+ if (!relative.startsWith("oak-benchmark-") || relative.includes(path.sep) || path.isAbsolute(relative)) {
82
+ throw invalid("refusing unsafe benchmark cleanup");
83
+ }
84
+ fs.rmSync(root, { recursive: true, force: true });
85
+ }
86
+
87
+ function readResourceUsage() {
88
+ const usage = process.resourceUsage();
89
+ return {
90
+ user_cpu_ms: usage.userCPUTime / 1000,
91
+ system_cpu_ms: usage.systemCPUTime / 1000,
92
+ max_rss_kb: usage.maxRSS,
93
+ };
94
+ }
95
+
96
+ export function percentile(values, fraction) {
97
+ if (!Array.isArray(values) || values.length === 0 || fraction < 0 || fraction > 1) {
98
+ throw invalid("percentile requires non-empty values and a fraction from 0 through 1");
99
+ }
100
+ const sorted = [...values].sort((left, right) => left - right);
101
+ const position = (sorted.length - 1) * fraction;
102
+ const lower = Math.floor(position);
103
+ const upper = Math.ceil(position);
104
+ if (lower === upper) return sorted[lower];
105
+ return sorted[lower] + (sorted[upper] - sorted[lower]) * (position - lower);
106
+ }
107
+
108
+ export function summarizeMeasurements(measurements) {
109
+ if (!Array.isArray(measurements) || measurements.length === 0) throw invalid("measurements must be non-empty");
110
+ return {
111
+ samples: measurements.length,
112
+ elapsed_ms_p50: percentile(measurements.map((sample) => sample.elapsed_ms), 0.5),
113
+ elapsed_ms_p95: percentile(measurements.map((sample) => sample.elapsed_ms), 0.95),
114
+ user_cpu_ms_p50: percentile(measurements.map((sample) => sample.user_cpu_ms), 0.5),
115
+ system_cpu_ms_p50: percentile(measurements.map((sample) => sample.system_cpu_ms), 0.5),
116
+ max_rss_kb_p95: percentile(measurements.map((sample) => sample.max_rss_kb), 0.95),
117
+ };
118
+ }
119
+
120
+ async function measure(operation) {
121
+ const before = readResourceUsage();
122
+ const started = performance.now();
123
+ await operation();
124
+ const after = readResourceUsage();
125
+ return {
126
+ elapsed_ms: performance.now() - started,
127
+ user_cpu_ms: Math.max(0, after.user_cpu_ms - before.user_cpu_ms),
128
+ system_cpu_ms: Math.max(0, after.system_cpu_ms - before.system_cpu_ms),
129
+ max_rss_kb: after.max_rss_kb,
130
+ };
131
+ }
132
+
133
+ async function benchmarkFixture(fixture, iterations, temporaryRoot) {
134
+ const files = walkFiles(fixture.root);
135
+ const operations = [
136
+ ["list", () => walkFiles(fixture.root)],
137
+ ["search", () => searchFiles(files)],
138
+ ["ast", () => parseFixture(fixture.astFile)],
139
+ ["background-snapshot", () => generateSnapshot(fixture.root)],
140
+ ["install", async () => {
141
+ const targetRoot = fs.mkdtempSync(path.join(temporaryRoot, "oak-benchmark-target-"));
142
+ try {
143
+ const result = await createInstallationManager({
144
+ sourceRoot: fixture.sourceRoot,
145
+ repositoryRoot: fixture.root,
146
+ versionProvider: () => "1.0.41",
147
+ }).run("install", { targetRoot });
148
+ if (result.exitCode !== 0) throw invalid(`installation benchmark failed for ${fixture.id}`);
149
+ } finally {
150
+ safeRemove(temporaryRoot, targetRoot);
151
+ }
152
+ }],
153
+ ];
154
+ const benchmarks = [];
155
+ for (const [id, operation] of operations) {
156
+ await operation();
157
+ const samples = [];
158
+ for (let index = 0; index < iterations; index += 1) samples.push(await measure(operation));
159
+ benchmarks.push({ id, summary: summarizeMeasurements(samples) });
160
+ }
161
+ return { id: fixture.id, type: fixture.type, files: files.length, benchmarks };
162
+ }
163
+
164
+ export async function runBenchmark(options = {}) {
165
+ const iterations = options.iterations ?? DEFAULT_ITERATIONS;
166
+ if (!Number.isInteger(iterations) || iterations < 2 || iterations > 20) throw invalid("iterations must be an integer from 2 through 20");
167
+ const repositoryRoot = options.repositoryRoot ?? REPOSITORY_ROOT;
168
+ const temporaryRoot = fs.mkdtempSync(path.join(os.tmpdir(), "oak-benchmark-"));
169
+ try {
170
+ const fixtures = [
171
+ createFixture(temporaryRoot, "small", 24),
172
+ createFixture(temporaryRoot, "medium", 160),
173
+ ];
174
+ if (options.includeRepository !== false) {
175
+ fixtures.push({
176
+ id: "repository",
177
+ root: repositoryRoot,
178
+ sourceRoot: path.join(repositoryRoot, "opencode"),
179
+ astFile: path.join(repositoryRoot, "scripts", "manage-installation.mjs"),
180
+ type: "repository",
181
+ });
182
+ }
183
+ const results = [];
184
+ for (const fixture of fixtures) results.push(await benchmarkFixture(fixture, iterations, temporaryRoot));
185
+ return {
186
+ schema_version: 1,
187
+ generated_at: new Date().toISOString(),
188
+ node: process.version,
189
+ platform: `${process.platform}/${process.arch}`,
190
+ iterations,
191
+ measurement_scope: "Node runner process; child command RSS is not isolated",
192
+ fixtures: results,
193
+ };
194
+ } finally {
195
+ safeRemove(os.tmpdir(), temporaryRoot);
196
+ }
197
+ }
198
+
199
+ function parseArgs(argv) {
200
+ const options = { iterations: DEFAULT_ITERATIONS, includeRepository: true };
201
+ for (let index = 0; index < argv.length; index += 1) {
202
+ if (argv[index] === "--iterations") {
203
+ const value = Number(argv[++index]);
204
+ if (!Number.isInteger(value)) throw invalid("--iterations requires an integer");
205
+ options.iterations = value;
206
+ } else if (argv[index] === "--no-repository") {
207
+ options.includeRepository = false;
208
+ } else if (argv[index] === "--help") {
209
+ process.stdout.write("Usage: node scripts/benchmark-tool-paths.mjs [--iterations N] [--no-repository]\n");
210
+ return null;
211
+ } else {
212
+ throw invalid(`unknown argument: ${argv[index]}`);
213
+ }
214
+ }
215
+ return options;
216
+ }
217
+
218
+ if (path.resolve(process.argv[1] ?? "") === SCRIPT_PATH) {
219
+ try {
220
+ const options = parseArgs(process.argv.slice(2));
221
+ if (options) process.stdout.write(`${JSON.stringify(await runBenchmark(options), null, 2)}\n`);
222
+ } catch (error) {
223
+ process.stderr.write(`${error.message}\n`);
224
+ process.exitCode = 2;
225
+ }
226
+ }
@@ -0,0 +1,29 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+
4
+ import { percentile, summarizeMeasurements } from "./benchmark-tool-paths.mjs";
5
+
6
+ test("benchmark percentile uses linear interpolation", () => {
7
+ assert.equal(percentile([1, 2, 3, 4], 0.5), 2.5);
8
+ assert.ok(Math.abs(percentile([1, 2, 3, 4], 0.95) - 3.85) < 1e-12);
9
+ });
10
+
11
+ test("benchmark summary exposes latency, CPU, and RSS percentiles", () => {
12
+ const summary = summarizeMeasurements([
13
+ { elapsed_ms: 1, user_cpu_ms: 2, system_cpu_ms: 3, max_rss_kb: 4 },
14
+ { elapsed_ms: 2, user_cpu_ms: 3, system_cpu_ms: 4, max_rss_kb: 5 },
15
+ { elapsed_ms: 3, user_cpu_ms: 4, system_cpu_ms: 5, max_rss_kb: 6 },
16
+ ]);
17
+ assert.equal(summary.samples, 3);
18
+ assert.equal(summary.elapsed_ms_p50, 2);
19
+ assert.equal(summary.elapsed_ms_p95, 2.9);
20
+ assert.equal(summary.user_cpu_ms_p50, 3);
21
+ assert.equal(summary.system_cpu_ms_p50, 4);
22
+ assert.equal(summary.max_rss_kb_p95, 5.9);
23
+ });
24
+
25
+ test("benchmark rejects invalid sample and percentile inputs", () => {
26
+ assert.throws(() => percentile([], 0.5), /non-empty/i);
27
+ assert.throws(() => percentile([1], 2), /fraction/i);
28
+ assert.throws(() => summarizeMeasurements([]), /non-empty/i);
29
+ });
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+
7
+ const ROOT = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
8
+ const BOUNDARY_DOC = "docs/sync-boundary.md";
9
+ const REQUIRED_FILES = [
10
+ BOUNDARY_DOC,
11
+ "opencode/commands/loop-status.md",
12
+ "opencode/docs/ai/specs/mission-runtime.md",
13
+ "opencode/plugins/mission-runtime.ts",
14
+ "opencode/scripts/mission-runtime-observer.mjs",
15
+ "opencode/scripts/mission-runtime-observer.d.mts",
16
+ "opencode/scripts/mission-status.mjs",
17
+ "opencode/scripts/runtime-permission-policy.mjs",
18
+ ];
19
+
20
+ // Keep these markers identical to the existing check.sh scan. They are built
21
+ // from fragments so this scanner does not trip over its own rules.
22
+ const PRIVATE_MARKERS = [
23
+ ["/", "Users", "/"].join(""),
24
+ ["synology", ".", "me"].join(""),
25
+ ["auth", ".", "json"].join(""),
26
+ ["OPENAI", "_", "API", "_", "KEY"].join(""),
27
+ ];
28
+
29
+ function walk(directory, root = directory, files = []) {
30
+ for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
31
+ if ([".git", "node_modules"].includes(entry.name)) continue;
32
+ if ([".gitignore", "check.sh"].includes(entry.name)) continue;
33
+ const full = path.join(directory, entry.name);
34
+ if (entry.isDirectory()) walk(full, root, files);
35
+ else if (entry.isFile()) files.push(path.relative(root, full));
36
+ }
37
+ return files.sort();
38
+ }
39
+
40
+ function fail(message) {
41
+ throw new Error(message);
42
+ }
43
+
44
+ export function scanPublicLeaks(root = ROOT) {
45
+ const findings = [];
46
+ for (const relative of walk(root)) {
47
+ const full = path.join(root, relative);
48
+ const text = fs.readFileSync(full, "utf8");
49
+ for (const marker of PRIVATE_MARKERS) {
50
+ if (text.includes(marker)) findings.push({ path: relative, marker: "private-marker" });
51
+ }
52
+ }
53
+ return findings;
54
+ }
55
+
56
+ export function validatePublicBoundary(root = ROOT) {
57
+ const resolvedRoot = path.resolve(root);
58
+ for (const relative of REQUIRED_FILES) {
59
+ const full = path.join(resolvedRoot, relative);
60
+ if (!fs.existsSync(full) || !fs.lstatSync(full).isFile()) {
61
+ fail(`${relative}: missing public boundary surface`);
62
+ }
63
+ }
64
+
65
+ const boundary = fs.readFileSync(path.join(resolvedRoot, BOUNDARY_DOC), "utf8");
66
+ for (const token of ["private", "public", "translate", "transform", "exclude", "credentials"]) {
67
+ if (!boundary.includes(token)) fail(`${BOUNDARY_DOC}: missing boundary token ${token}`);
68
+ }
69
+
70
+ const findings = scanPublicLeaks(resolvedRoot);
71
+ if (findings.length > 0) {
72
+ fail(`${findings[0].path}: public boundary leak scan failed`);
73
+ }
74
+
75
+ if (fs.existsSync(path.join(resolvedRoot, "opencode/scripts/model-switcher.mjs"))) {
76
+ fail("opencode/scripts/model-switcher.mjs: private provider surface is not public");
77
+ }
78
+ return { required_files: REQUIRED_FILES.length, scanned_files: walk(resolvedRoot).length };
79
+ }
80
+
81
+ if (process.argv[1] && fileURLToPath(import.meta.url) === path.resolve(process.argv[1])) {
82
+ try {
83
+ validatePublicBoundary();
84
+ process.stdout.write("Public boundary check passed.\n");
85
+ } catch (error) {
86
+ process.stderr.write(`${error instanceof Error ? error.message : "public boundary check failed"}\n`);
87
+ process.exitCode = 1;
88
+ }
89
+ }
@@ -0,0 +1,32 @@
1
+ import assert from "node:assert/strict";
2
+ import fs from "node:fs";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import test from "node:test";
6
+
7
+ import { scanPublicLeaks, validatePublicBoundary } from "./check-public-boundary.mjs";
8
+
9
+ test("the checked-out public boundary is complete and leak-free", () => {
10
+ assert.doesNotThrow(() => validatePublicBoundary());
11
+ });
12
+
13
+ test("the boundary scan reports a private marker without echoing its value", () => {
14
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "public-boundary-"));
15
+ try {
16
+ const leaked = ["/", "Users", "example", "secret"].join("/");
17
+ fs.writeFileSync(path.join(root, "leak.txt"), leaked);
18
+ const findings = scanPublicLeaks(root);
19
+ assert.deepEqual(findings, [{ path: "leak.txt", marker: "private-marker" }]);
20
+ } finally {
21
+ fs.rmSync(root, { recursive: true, force: true });
22
+ }
23
+ });
24
+
25
+ test("missing boundary documentation fails closed", () => {
26
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "public-boundary-missing-"));
27
+ try {
28
+ assert.throws(() => validatePublicBoundary(root), /docs\/sync-boundary\.md/);
29
+ } finally {
30
+ fs.rmSync(root, { recursive: true, force: true });
31
+ }
32
+ });
package/scripts/check.sh CHANGED
@@ -34,6 +34,8 @@ scripts/check-use-cases.test.mjs
34
34
  scripts/package-smoke.sh
35
35
  scripts/package-smoke.mjs
36
36
  scripts/package-smoke.test.mjs
37
+ scripts/benchmark-tool-paths.mjs
38
+ scripts/benchmark-tool-paths.test.mjs
37
39
  scripts/opencode-compat-smoke.sh
38
40
  scripts/manage-installation.mjs
39
41
  scripts/manage-installation.test.mjs
@@ -48,14 +50,24 @@ opencode/package.json
48
50
  opencode/package-lock.json
49
51
  opencode/plugins/token-tree-usage.tsx
50
52
  opencode/plugins/shell-export-guard.ts
53
+ opencode/plugins/mission-runtime.ts
54
+ opencode/plugins/mission-runtime.test.mjs
51
55
  opencode/tools/open_design.ts
52
56
  opencode/tools/open-design-http.mjs
53
57
  opencode/tools/open-design-http.d.mts
54
58
  opencode/scripts/check-harness.mjs
59
+ opencode/scripts/mission-runtime-observer.mjs
60
+ opencode/scripts/mission-runtime-observer.d.mts
61
+ opencode/scripts/mission-runtime.test.mjs
62
+ opencode/scripts/mission-status.mjs
63
+ opencode/scripts/mission-status.test.mjs
64
+ opencode/scripts/runtime-permission-policy.mjs
65
+ opencode/scripts/runtime-permission-policy.test.mjs
55
66
  opencode/scripts/shell-export-policy.mjs
56
67
  opencode/scripts/shell-export-policy.d.mts
57
68
  opencode/scripts/shell-export-policy.test.mjs
58
69
  opencode/commands/loop.md
70
+ opencode/commands/loop-status.md
59
71
  opencode/commands/plan.md
60
72
  opencode/commands/test.md
61
73
  opencode/commands/code-simplify.md
@@ -65,6 +77,7 @@ opencode/docs/ai/harness/commands.md
65
77
  opencode/docs/ai/harness/evidence.md
66
78
  opencode/docs/ai/harness/checks.md
67
79
  opencode/docs/ai/harness/orchestration-contracts.json
80
+ opencode/docs/ai/specs/mission-runtime.md
68
81
  opencode/docs/ai/evolution/README.md
69
82
  opencode/docs/ai/evolution/evolution_history.md
70
83
  opencode/docs/ai/evolution/mechanisms.jsonl
@@ -76,6 +89,7 @@ docker/open-design/docker-compose.yml
76
89
  docker/open-design/.env.example
77
90
  docker/open-design/opencode-od/opencode.json
78
91
  docs/supply-chain.md
92
+ docs/performance/native-tools-benchmark.md
79
93
  docs/threat-model.md
80
94
  docs/use-cases/README.md
81
95
  docs/use-cases/direct-label-change/README.md
@@ -230,16 +244,7 @@ grep -q 'Lead' opencode/plugins/token-tree-usage.tsx
230
244
  grep -q 'Subagents' opencode/plugins/token-tree-usage.tsx
231
245
  grep -q 'Partial total' opencode/plugins/token-tree-usage.tsx
232
246
 
233
- private_re="$(printf '%s|%s|%s|%s' '/''Users/' 'synology''\\.me' 'auth''\\.json' 'OPENAI''_API_KEY')"
234
- if grep -R -nE "$private_re" . \
235
- --exclude-dir=.git \
236
- --exclude-dir=node_modules \
237
- --exclude='.git' \
238
- --exclude='check.sh' \
239
- --exclude='.gitignore'; then
240
- echo 'Potential private data found' >&2
241
- exit 1
242
- fi
247
+ node scripts/check-public-boundary.mjs
243
248
 
244
249
  grep -q 'Apache License' LICENSE
245
250
  grep -q 'OpenCode' NOTICE.md