opencode-agent-orchestration-kit 1.0.38 → 1.0.40
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/README.md +12 -3
- package/docker/open-design/Dockerfile +3 -1
- package/docker/open-design/entrypoint.mjs +61 -0
- package/docs/docker-open-design.md +5 -0
- package/docs/models.md +1 -1
- package/docs/open-design.md +8 -0
- package/docs/performance/native-tools-benchmark.md +33 -0
- package/docs/releases/v1.0.39.md +44 -0
- package/docs/releases/v1.0.40.md +55 -0
- package/docs/sync-boundary.md +27 -0
- package/opencode/commands/loop-status.md +24 -0
- package/opencode/commands/loop.md +8 -0
- package/opencode/docs/ai/harness/agents.md +8 -0
- package/opencode/docs/ai/harness/checks.md +6 -0
- package/opencode/docs/ai/harness/commands.md +10 -0
- package/opencode/docs/ai/harness/orchestration-contracts.json +9 -1
- package/opencode/docs/ai/specs/mission-runtime.md +44 -0
- package/opencode/plugins/mission-runtime.test.mjs +46 -0
- package/opencode/plugins/mission-runtime.ts +41 -0
- package/opencode/scripts/check-harness.mjs +111 -0
- package/opencode/scripts/check-harness.test.mjs +37 -1
- package/opencode/scripts/loop-state.mjs +5 -0
- package/opencode/scripts/loop-state.test.mjs +13 -0
- package/opencode/scripts/mission-runtime-observer.d.mts +25 -0
- package/opencode/scripts/mission-runtime-observer.mjs +124 -0
- package/opencode/scripts/mission-runtime.test.mjs +97 -0
- package/opencode/scripts/mission-status.mjs +136 -0
- package/opencode/scripts/mission-status.test.mjs +196 -0
- package/opencode/scripts/project-capability-snapshot.mjs +2 -1
- package/opencode/scripts/project-capability-snapshot.test.mjs +17 -0
- package/opencode/scripts/runtime-permission-policy.mjs +72 -0
- package/opencode/scripts/runtime-permission-policy.test.mjs +89 -0
- package/opencode/tools/open-design-http.d.mts +45 -0
- package/opencode/tools/open-design-http.mjs +387 -0
- package/opencode/tools/open_design.ts +2 -103
- package/package.json +3 -3
- package/scripts/benchmark-tool-paths.mjs +226 -0
- package/scripts/benchmark-tool-paths.test.mjs +29 -0
- package/scripts/check-public-boundary.mjs +89 -0
- package/scripts/check-public-boundary.test.mjs +32 -0
- package/scripts/check.sh +17 -10
- package/scripts/install-smoke.sh +17 -0
- package/scripts/manage-installation.mjs +90 -7
- package/scripts/manage-installation.test.mjs +36 -0
- package/scripts/open-design-entrypoint.test.mjs +54 -0
- package/scripts/open-design-http.test.mjs +211 -0
- package/scripts/package-smoke.mjs +52 -3
- package/scripts/package-smoke.test.mjs +6 -6
- package/scripts/version.test.mjs +2 -2
|
@@ -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.40",
|
|
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,12 +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
|
|
56
|
+
opencode/tools/open-design-http.mjs
|
|
57
|
+
opencode/tools/open-design-http.d.mts
|
|
52
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
|
|
53
66
|
opencode/scripts/shell-export-policy.mjs
|
|
54
67
|
opencode/scripts/shell-export-policy.d.mts
|
|
55
68
|
opencode/scripts/shell-export-policy.test.mjs
|
|
56
69
|
opencode/commands/loop.md
|
|
70
|
+
opencode/commands/loop-status.md
|
|
57
71
|
opencode/commands/plan.md
|
|
58
72
|
opencode/commands/test.md
|
|
59
73
|
opencode/commands/code-simplify.md
|
|
@@ -63,6 +77,7 @@ opencode/docs/ai/harness/commands.md
|
|
|
63
77
|
opencode/docs/ai/harness/evidence.md
|
|
64
78
|
opencode/docs/ai/harness/checks.md
|
|
65
79
|
opencode/docs/ai/harness/orchestration-contracts.json
|
|
80
|
+
opencode/docs/ai/specs/mission-runtime.md
|
|
66
81
|
opencode/docs/ai/evolution/README.md
|
|
67
82
|
opencode/docs/ai/evolution/evolution_history.md
|
|
68
83
|
opencode/docs/ai/evolution/mechanisms.jsonl
|
|
@@ -74,6 +89,7 @@ docker/open-design/docker-compose.yml
|
|
|
74
89
|
docker/open-design/.env.example
|
|
75
90
|
docker/open-design/opencode-od/opencode.json
|
|
76
91
|
docs/supply-chain.md
|
|
92
|
+
docs/performance/native-tools-benchmark.md
|
|
77
93
|
docs/threat-model.md
|
|
78
94
|
docs/use-cases/README.md
|
|
79
95
|
docs/use-cases/direct-label-change/README.md
|
|
@@ -228,16 +244,7 @@ grep -q 'Lead' opencode/plugins/token-tree-usage.tsx
|
|
|
228
244
|
grep -q 'Subagents' opencode/plugins/token-tree-usage.tsx
|
|
229
245
|
grep -q 'Partial total' opencode/plugins/token-tree-usage.tsx
|
|
230
246
|
|
|
231
|
-
|
|
232
|
-
if grep -R -nE "$private_re" . \
|
|
233
|
-
--exclude-dir=.git \
|
|
234
|
-
--exclude-dir=node_modules \
|
|
235
|
-
--exclude='.git' \
|
|
236
|
-
--exclude='check.sh' \
|
|
237
|
-
--exclude='.gitignore'; then
|
|
238
|
-
echo 'Potential private data found' >&2
|
|
239
|
-
exit 1
|
|
240
|
-
fi
|
|
247
|
+
node scripts/check-public-boundary.mjs
|
|
241
248
|
|
|
242
249
|
grep -q 'Apache License' LICENSE
|
|
243
250
|
grep -q 'OpenCode' NOTICE.md
|
package/scripts/install-smoke.sh
CHANGED
|
@@ -19,6 +19,9 @@ cd "$root"
|
|
|
19
19
|
expected_version="$(node -p "require('./package.json').version")"
|
|
20
20
|
expected_line="opencode-agent-orchestration-kit $expected_version"
|
|
21
21
|
|
|
22
|
+
mkdir -p "$target"
|
|
23
|
+
printf '%s\n' '{"default_agent":"lead"}' > "$target/opencode.json"
|
|
24
|
+
|
|
22
25
|
for wrapper in install.sh upgrade.sh doctor.sh uninstall.sh rollback.sh; do
|
|
23
26
|
test "$("./$wrapper" --version)" = "$expected_line"
|
|
24
27
|
done
|
|
@@ -29,6 +32,7 @@ const [, , sourceRoot, targetRoot] = process.argv
|
|
|
29
32
|
const result = await createInstallationManager({
|
|
30
33
|
sourceRoot,
|
|
31
34
|
versionProvider: () => "1.0.26",
|
|
35
|
+
releaseProvenance: null,
|
|
32
36
|
}).run("install", { targetRoot })
|
|
33
37
|
if (result.exitCode !== 0) throw result.error ?? new Error("smoke install failed")
|
|
34
38
|
NODE
|
|
@@ -38,6 +42,7 @@ test -f "$target/opencode.json"
|
|
|
38
42
|
test -f "$target/scripts/check-harness.mjs"
|
|
39
43
|
test -f "$target/.oak/manifest.json"
|
|
40
44
|
test -f "$target/.oak/rollback/transaction.json"
|
|
45
|
+
test "$(cat "$target/opencode.json")" = '{"default_agent":"lead"}'
|
|
41
46
|
|
|
42
47
|
node --input-type=module - "$target" <<'NODE'
|
|
43
48
|
import fs from "node:fs"
|
|
@@ -67,6 +72,18 @@ if (manifest.kit_version !== expected) throw new Error("upgraded manifest versio
|
|
|
67
72
|
if (rollback.previous_manifest?.kit_version !== "1.0.26" || rollback.next_manifest?.kit_version !== expected) {
|
|
68
73
|
throw new Error("upgrade snapshot version mismatch")
|
|
69
74
|
}
|
|
75
|
+
if (process.env.OAK_RELEASE_SOURCE_COMMIT) {
|
|
76
|
+
const provenance = manifest.release_provenance
|
|
77
|
+
if (!provenance
|
|
78
|
+
|| provenance.source_commit !== process.env.OAK_RELEASE_SOURCE_COMMIT
|
|
79
|
+
|| provenance.public_commit !== process.env.OAK_RELEASE_PUBLIC_COMMIT
|
|
80
|
+
|| provenance.kit_version !== expected
|
|
81
|
+
|| provenance.payload_sha256 !== manifest.payload_sha256
|
|
82
|
+
|| provenance.payload_sha256 !== process.env.OAK_RELEASE_PAYLOAD_SHA256
|
|
83
|
+
|| provenance.checks_result !== process.env.OAK_RELEASE_CHECKS_RESULT) {
|
|
84
|
+
throw new Error("release provenance mismatch")
|
|
85
|
+
}
|
|
86
|
+
}
|
|
70
87
|
NODE
|
|
71
88
|
|
|
72
89
|
./uninstall.sh --yes --target "$target" >/dev/null
|
|
@@ -310,16 +310,23 @@ export function assertSafeTarget({ targetRoot, repositoryRoot, sourceRoot, fsOps
|
|
|
310
310
|
return target;
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
function assertExactKeys(value, expected, label) {
|
|
313
|
+
function assertExactKeys(value, expected, label, options = {}) {
|
|
314
314
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw invalid(`${label} must be an object`);
|
|
315
315
|
const actual = Object.keys(value).sort();
|
|
316
316
|
const wanted = [...expected].sort();
|
|
317
|
+
const optional = new Set(options.optional ?? []);
|
|
317
318
|
const unknown = actual.filter((key) => !wanted.includes(key));
|
|
318
|
-
const missing = wanted.filter((key) => !actual.includes(key));
|
|
319
|
+
const missing = wanted.filter((key) => !actual.includes(key) && !optional.has(key));
|
|
319
320
|
if (unknown.length > 0) throw invalid(`${label} has unknown field: ${unknown[0]}`);
|
|
320
321
|
if (missing.length > 0) throw invalid(`${label} is missing field: ${missing[0]}`);
|
|
321
322
|
}
|
|
322
323
|
|
|
324
|
+
function assertCommit(value, label) {
|
|
325
|
+
if (typeof value !== "string" || !/^[0-9a-f]{40}$/.test(value)) {
|
|
326
|
+
throw invalid(`${label} must be a lowercase Git commit`);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
323
330
|
function assertHash(value, label) {
|
|
324
331
|
if (typeof value !== "string" || !/^[0-9a-f]{64}$/.test(value)) throw invalid(`${label} must be a lowercase SHA-256 digest`);
|
|
325
332
|
}
|
|
@@ -336,6 +343,11 @@ const MANIFEST_KEYS = [
|
|
|
336
343
|
"schema_version", "manager", "kit_version", "payload_sha256", "created_at", "updated_at",
|
|
337
344
|
"last_transaction_id", "owned_files", "preserved_files",
|
|
338
345
|
];
|
|
346
|
+
const OPTIONAL_MANIFEST_KEYS = ["release_provenance"];
|
|
347
|
+
const RELEASE_CONTEXT_KEYS = ["source_commit", "public_commit", "checks_result"];
|
|
348
|
+
const RELEASE_PROVENANCE_KEYS = [
|
|
349
|
+
"source_commit", "public_commit", "kit_version", "payload_sha256", "checks_result",
|
|
350
|
+
];
|
|
339
351
|
const OWNED_KEYS = ["path", "sha256", "mode"];
|
|
340
352
|
const PRESERVED_KEYS = [
|
|
341
353
|
"path", "observed_sha256", "observed_mode", "source_sha256", "source_mode",
|
|
@@ -346,7 +358,7 @@ const ACK_KEYS = [
|
|
|
346
358
|
];
|
|
347
359
|
|
|
348
360
|
export function validateManifest(manifest) {
|
|
349
|
-
assertExactKeys(manifest, MANIFEST_KEYS, "manifest");
|
|
361
|
+
assertExactKeys(manifest, [...MANIFEST_KEYS, ...OPTIONAL_MANIFEST_KEYS], "manifest", { optional: OPTIONAL_MANIFEST_KEYS });
|
|
350
362
|
if (manifest.schema_version !== SCHEMA_VERSION) throw invalid("manifest schema_version must be 1");
|
|
351
363
|
if (manifest.manager !== "opencode-agent-orchestration-kit") throw invalid("manifest manager is invalid");
|
|
352
364
|
try {
|
|
@@ -363,6 +375,12 @@ export function validateManifest(manifest) {
|
|
|
363
375
|
if (!Array.isArray(manifest.owned_files) || !Array.isArray(manifest.preserved_files)) {
|
|
364
376
|
throw invalid("manifest ownership lists must be arrays");
|
|
365
377
|
}
|
|
378
|
+
if (manifest.release_provenance !== undefined) {
|
|
379
|
+
validateReleaseProvenance(manifest.release_provenance, {
|
|
380
|
+
kitVersion: manifest.kit_version,
|
|
381
|
+
payloadSha256: manifest.payload_sha256,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
366
384
|
|
|
367
385
|
const allPaths = new Set();
|
|
368
386
|
let previousPath = null;
|
|
@@ -407,6 +425,46 @@ export function validateManifest(manifest) {
|
|
|
407
425
|
return manifest;
|
|
408
426
|
}
|
|
409
427
|
|
|
428
|
+
export function validateReleaseProvenance(provenance, expected = {}) {
|
|
429
|
+
assertExactKeys(provenance, RELEASE_PROVENANCE_KEYS, "release_provenance");
|
|
430
|
+
assertCommit(provenance.source_commit, "release_provenance source_commit");
|
|
431
|
+
assertCommit(provenance.public_commit, "release_provenance public_commit");
|
|
432
|
+
try {
|
|
433
|
+
parseStableVersion(provenance.kit_version);
|
|
434
|
+
} catch (error) {
|
|
435
|
+
throw invalid(`release_provenance kit_version is invalid: ${error.message}`);
|
|
436
|
+
}
|
|
437
|
+
assertHash(provenance.payload_sha256, "release_provenance payload_sha256");
|
|
438
|
+
if (provenance.checks_result !== "passed") {
|
|
439
|
+
throw invalid("release_provenance checks_result must be passed");
|
|
440
|
+
}
|
|
441
|
+
if (expected.kitVersion !== undefined && provenance.kit_version !== expected.kitVersion) {
|
|
442
|
+
throw invalid("release_provenance kit_version does not match manifest");
|
|
443
|
+
}
|
|
444
|
+
if (expected.payloadSha256 !== undefined && provenance.payload_sha256 !== expected.payloadSha256) {
|
|
445
|
+
throw invalid("release_provenance payload_sha256 does not match manifest");
|
|
446
|
+
}
|
|
447
|
+
return provenance;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function readReleaseContext(environment) {
|
|
451
|
+
const values = {
|
|
452
|
+
source_commit: environment.OAK_RELEASE_SOURCE_COMMIT,
|
|
453
|
+
public_commit: environment.OAK_RELEASE_PUBLIC_COMMIT,
|
|
454
|
+
checks_result: environment.OAK_RELEASE_CHECKS_RESULT,
|
|
455
|
+
};
|
|
456
|
+
const present = Object.values(values).some((value) => value !== undefined && value !== "");
|
|
457
|
+
if (!present) return null;
|
|
458
|
+
assertExactKeys(values, RELEASE_CONTEXT_KEYS, "release context");
|
|
459
|
+
if (RELEASE_CONTEXT_KEYS.some((key) => typeof values[key] !== "string" || values[key].length === 0)) {
|
|
460
|
+
throw invalid("release context must provide source, public, and checks identities");
|
|
461
|
+
}
|
|
462
|
+
assertCommit(values.source_commit, "release context source_commit");
|
|
463
|
+
assertCommit(values.public_commit, "release context public_commit");
|
|
464
|
+
if (values.checks_result !== "passed") throw invalid("release context checks_result must be passed");
|
|
465
|
+
return values;
|
|
466
|
+
}
|
|
467
|
+
|
|
410
468
|
export function canonicalManifestBytes(manifest) {
|
|
411
469
|
validateManifest(manifest);
|
|
412
470
|
return Buffer.from(`${canonicalJson(manifest)}\n`, "utf8");
|
|
@@ -653,10 +711,11 @@ function preservedEntry(source, target, reason) {
|
|
|
653
711
|
|
|
654
712
|
function makeNextManifest({ inspection, ownedFiles, preservedFiles, options }) {
|
|
655
713
|
const now = (options.clock?.() ?? new Date()).toISOString();
|
|
656
|
-
|
|
714
|
+
const kitVersion = parseStableVersion(options.kitVersion).canonical;
|
|
715
|
+
const manifest = {
|
|
657
716
|
schema_version: SCHEMA_VERSION,
|
|
658
717
|
manager: "opencode-agent-orchestration-kit",
|
|
659
|
-
kit_version:
|
|
718
|
+
kit_version: kitVersion,
|
|
660
719
|
payload_sha256: inspection.source.payloadSha256,
|
|
661
720
|
created_at: inspection.manifest?.created_at ?? now,
|
|
662
721
|
updated_at: now,
|
|
@@ -664,6 +723,19 @@ function makeNextManifest({ inspection, ownedFiles, preservedFiles, options }) {
|
|
|
664
723
|
owned_files: ownedFiles.sort((left, right) => left.path.localeCompare(right.path)),
|
|
665
724
|
preserved_files: preservedFiles.sort((left, right) => left.path.localeCompare(right.path)),
|
|
666
725
|
};
|
|
726
|
+
if (options.releaseProvenance) {
|
|
727
|
+
const releaseProvenance = {
|
|
728
|
+
...options.releaseProvenance,
|
|
729
|
+
kit_version: kitVersion,
|
|
730
|
+
payload_sha256: inspection.source.payloadSha256,
|
|
731
|
+
};
|
|
732
|
+
validateReleaseProvenance(releaseProvenance, {
|
|
733
|
+
kitVersion,
|
|
734
|
+
payloadSha256: inspection.source.payloadSha256,
|
|
735
|
+
});
|
|
736
|
+
manifest.release_provenance = releaseProvenance;
|
|
737
|
+
}
|
|
738
|
+
return manifest;
|
|
667
739
|
}
|
|
668
740
|
|
|
669
741
|
function classifyVersionState(sourceVersion, manifest, sourcePayloadSha256) {
|
|
@@ -1025,6 +1097,17 @@ export function createInstallationManager(options) {
|
|
|
1025
1097
|
const versionProvider = options.versionProvider ?? (() => {
|
|
1026
1098
|
throw invalid("canonical kit version provider is required");
|
|
1027
1099
|
});
|
|
1100
|
+
const releaseProvenance = Object.hasOwn(options, "releaseProvenance")
|
|
1101
|
+
? options.releaseProvenance
|
|
1102
|
+
: readReleaseContext(options.environment ?? process.env);
|
|
1103
|
+
if (releaseProvenance !== null && releaseProvenance !== undefined) {
|
|
1104
|
+
assertExactKeys(releaseProvenance, RELEASE_CONTEXT_KEYS, "release context");
|
|
1105
|
+
assertCommit(releaseProvenance.source_commit, "release context source_commit");
|
|
1106
|
+
assertCommit(releaseProvenance.public_commit, "release context public_commit");
|
|
1107
|
+
if (releaseProvenance.checks_result !== "passed") {
|
|
1108
|
+
throw invalid("release context checks_result must be passed");
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1028
1111
|
|
|
1029
1112
|
function currentKitVersion() {
|
|
1030
1113
|
return parseStableVersion(versionProvider()).canonical;
|
|
@@ -1915,7 +1998,7 @@ export function createInstallationManager(options) {
|
|
|
1915
1998
|
const transactionId = newTransactionId();
|
|
1916
1999
|
const inspection = inspectInstallation({ sourceRoot, targetRoot, deps: { fsOps } });
|
|
1917
2000
|
const kitVersion = currentKitVersion();
|
|
1918
|
-
const plan = buildPlan({ command, inspection, options: { ...runOptions, clock, transactionId, kitVersion } });
|
|
2001
|
+
const plan = buildPlan({ command, inspection, options: { ...runOptions, clock, transactionId, kitVersion, releaseProvenance } });
|
|
1919
2002
|
if (!plan.canApply) return { exitCode: 1, plan };
|
|
1920
2003
|
if (runOptions.dryRun) return { exitCode: 0, plan };
|
|
1921
2004
|
if (command === "upgrade" && !plan.hasWork) return { exitCode: 0, plan };
|
|
@@ -1923,7 +2006,7 @@ export function createInstallationManager(options) {
|
|
|
1923
2006
|
acquireLock(targetRoot, transactionId, command);
|
|
1924
2007
|
invocationLockOwned = true;
|
|
1925
2008
|
const lockedInspection = inspectInstallation({ sourceRoot, targetRoot, deps: { fsOps } });
|
|
1926
|
-
const lockedPlan = buildPlan({ command, inspection: lockedInspection, options: { ...runOptions, clock, transactionId, kitVersion } });
|
|
2009
|
+
const lockedPlan = buildPlan({ command, inspection: lockedInspection, options: { ...runOptions, clock, transactionId, kitVersion, releaseProvenance } });
|
|
1927
2010
|
if (lockedPlan.fingerprint !== plan.fingerprint || !lockedPlan.canApply) {
|
|
1928
2011
|
releaseLock(targetRoot);
|
|
1929
2012
|
return { exitCode: 1, plan: lockedPlan };
|