opencode-agent-orchestration-kit 1.0.32 → 1.0.33
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 +33 -2
- package/SECURITY.md +7 -0
- package/docker/open-design/data/app.sqlite +0 -0
- package/docker/open-design/data/app.sqlite-shm +0 -0
- package/docker/open-design/data/app.sqlite-wal +0 -0
- package/docker/open-design/opencode-auth/log/2026-05-02T105802.log +17 -0
- package/docker/open-design/opencode-auth/log/2026-05-04T102127.log +16 -0
- package/docker/open-design/opencode-auth/opencode.db +0 -0
- package/docker/open-design/opencode-auth/opencode.db-shm +0 -0
- package/docker/open-design/opencode-auth/opencode.db-wal +0 -0
- package/docs/cli.md +72 -0
- package/docs/installation.md +25 -5
- package/docs/quickstart.md +1 -1
- package/docs/releases/v1.0.33.md +72 -0
- package/docs/security.md +4 -0
- package/docs/supply-chain.md +9 -5
- package/docs/threat-model.md +244 -0
- package/docs/use-cases/README.md +31 -0
- package/docs/use-cases/direct-label-change/README.md +76 -0
- package/docs/use-cases/direct-label-change/before/package.json +8 -0
- package/docs/use-cases/direct-label-change/before/src/settings-label.mjs +1 -0
- package/docs/use-cases/direct-label-change/before/test/settings-label.test.mjs +8 -0
- package/docs/use-cases/direct-label-change/case.json +118 -0
- package/docs/use-cases/direct-label-change/expected/package.json +8 -0
- package/docs/use-cases/direct-label-change/expected/src/settings-label.mjs +1 -0
- package/docs/use-cases/direct-label-change/expected/test/settings-label.test.mjs +8 -0
- package/docs/use-cases/feature-tag-normalizer/README.md +78 -0
- package/docs/use-cases/feature-tag-normalizer/before/package.json +8 -0
- package/docs/use-cases/feature-tag-normalizer/before/src/normalize-tags.mjs +3 -0
- package/docs/use-cases/feature-tag-normalizer/before/test/normalize-tags.test.mjs +13 -0
- package/docs/use-cases/feature-tag-normalizer/case.json +119 -0
- package/docs/use-cases/feature-tag-normalizer/expected/package.json +8 -0
- package/docs/use-cases/feature-tag-normalizer/expected/src/normalize-tags.mjs +14 -0
- package/docs/use-cases/feature-tag-normalizer/expected/test/normalize-tags.test.mjs +18 -0
- package/docs/workflows.md +6 -0
- package/opencode/docs/ai/harness/README.md +2 -0
- package/opencode/docs/ai/harness/agents.md +7 -0
- package/opencode/docs/ai/harness/checks.md +9 -0
- package/opencode/docs/ai/harness/commands.md +8 -0
- package/opencode/docs/ai/harness/orchestration-contracts.json +891 -0
- package/opencode/package-lock.json +14 -8
- package/opencode/package.json +1 -0
- package/opencode/scripts/check-harness.mjs +634 -10
- package/opencode/scripts/check-harness.test.mjs +380 -0
- package/package.json +4 -1
- package/scripts/check-supply-chain.mjs +11 -1
- package/scripts/check-supply-chain.test.mjs +47 -0
- package/scripts/check-threat-model.mjs +421 -0
- package/scripts/check-threat-model.test.mjs +304 -0
- package/scripts/check-use-cases.mjs +501 -0
- package/scripts/check-use-cases.test.mjs +225 -0
- package/scripts/check.sh +51 -1
- package/scripts/install-smoke.sh +24 -1
- package/scripts/manage-installation.mjs +567 -25
- package/scripts/manage-installation.test.mjs +418 -0
- package/scripts/oak.mjs +200 -0
- package/scripts/oak.test.mjs +277 -0
- package/scripts/package-smoke.mjs +57 -0
- package/scripts/package-smoke.test.mjs +75 -2
- package/scripts/version.mjs +1 -0
- package/scripts/version.test.mjs +3 -2
- package/supply-chain.json +1 -0
|
@@ -64,6 +64,386 @@ function writeRouterScenarios(cwd, scenarios) {
|
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
const orchestrationContractRel =
|
|
68
|
+
"docs/ai/harness/orchestration-contracts.json";
|
|
69
|
+
|
|
70
|
+
function readOrchestrationContract(cwd) {
|
|
71
|
+
return JSON.parse(
|
|
72
|
+
fs.readFileSync(path.join(cwd, orchestrationContractRel), "utf8"),
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function writeOrchestrationContract(cwd, contract) {
|
|
77
|
+
write(
|
|
78
|
+
orchestrationContractRel,
|
|
79
|
+
`${JSON.stringify(contract, null, 2)}\n`,
|
|
80
|
+
cwd,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
test("orchestration contract file is required", () => {
|
|
85
|
+
const cwd = makeFixture();
|
|
86
|
+
try {
|
|
87
|
+
fs.rmSync(path.join(cwd, orchestrationContractRel), { force: true });
|
|
88
|
+
|
|
89
|
+
const result = runHarness(cwd);
|
|
90
|
+
assert.notEqual(result.status, 0, "checker accepted a missing orchestration contract");
|
|
91
|
+
assert.match(result.stderr, /missing orchestration contract/);
|
|
92
|
+
} finally {
|
|
93
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("orchestration contract file must be regular and non-symlink", () => {
|
|
98
|
+
const cwd = makeFixture();
|
|
99
|
+
const external = path.join(cwd, "external-contract.json");
|
|
100
|
+
try {
|
|
101
|
+
fs.writeFileSync(external, "{}\n");
|
|
102
|
+
fs.rmSync(path.join(cwd, orchestrationContractRel));
|
|
103
|
+
fs.symlinkSync(external, path.join(cwd, orchestrationContractRel));
|
|
104
|
+
|
|
105
|
+
const result = runHarness(cwd);
|
|
106
|
+
assert.notEqual(result.status, 0, "checker followed a symlinked orchestration contract");
|
|
107
|
+
assert.match(result.stderr, /regular non-symlink/);
|
|
108
|
+
} finally {
|
|
109
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test("orchestration contract rejects an unknown top-level key", () => {
|
|
114
|
+
const cwd = makeFixture();
|
|
115
|
+
try {
|
|
116
|
+
const contract = readOrchestrationContract(cwd);
|
|
117
|
+
writeOrchestrationContract(cwd, { ...contract, scheduler: {} });
|
|
118
|
+
|
|
119
|
+
const result = runHarness(cwd);
|
|
120
|
+
assert.notEqual(result.status, 0, "checker accepted an unknown orchestration key");
|
|
121
|
+
assert.match(result.stderr, /must contain exactly/);
|
|
122
|
+
} finally {
|
|
123
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test("orchestration contract header is closed", async (t) => {
|
|
128
|
+
for (const [label, mutate, pattern] of [
|
|
129
|
+
[
|
|
130
|
+
"schema version",
|
|
131
|
+
(contract) => ({ ...contract, schema_version: 2 }),
|
|
132
|
+
/schema_version must be 1/,
|
|
133
|
+
],
|
|
134
|
+
[
|
|
135
|
+
"contract identity",
|
|
136
|
+
(contract) => ({ ...contract, contract_id: "other-contract" }),
|
|
137
|
+
/contract_id must be oak-orchestration/,
|
|
138
|
+
],
|
|
139
|
+
]) {
|
|
140
|
+
await t.test(label, () => {
|
|
141
|
+
const cwd = makeFixture();
|
|
142
|
+
try {
|
|
143
|
+
writeOrchestrationContract(cwd, mutate(readOrchestrationContract(cwd)));
|
|
144
|
+
const result = runHarness(cwd);
|
|
145
|
+
assert.notEqual(result.status, 0, `checker accepted invalid ${label}`);
|
|
146
|
+
assert.match(result.stderr, pattern);
|
|
147
|
+
} finally {
|
|
148
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test("orchestration contract requires the canonical evidence catalog", () => {
|
|
155
|
+
const cwd = makeFixture();
|
|
156
|
+
try {
|
|
157
|
+
const contract = readOrchestrationContract(cwd);
|
|
158
|
+
writeOrchestrationContract(cwd, {
|
|
159
|
+
...contract,
|
|
160
|
+
evidence_types: ["static_contract"],
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const result = runHarness(cwd);
|
|
164
|
+
assert.notEqual(result.status, 0, "checker accepted an incomplete evidence catalog");
|
|
165
|
+
assert.match(result.stderr, /evidence_types must match the canonical catalog/);
|
|
166
|
+
} finally {
|
|
167
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test("orchestration contract requires every harness agent", () => {
|
|
172
|
+
const cwd = makeFixture();
|
|
173
|
+
try {
|
|
174
|
+
const contract = readOrchestrationContract(cwd);
|
|
175
|
+
writeOrchestrationContract(cwd, { ...contract, agents: [] });
|
|
176
|
+
|
|
177
|
+
const result = runHarness(cwd);
|
|
178
|
+
assert.notEqual(result.status, 0, "checker accepted an empty agent catalog");
|
|
179
|
+
assert.match(result.stderr, /agent catalog must match harness agents/);
|
|
180
|
+
} finally {
|
|
181
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test("orchestration agent contracts match frontmatter authority", async (t) => {
|
|
186
|
+
for (const [label, mutate, pattern] of [
|
|
187
|
+
[
|
|
188
|
+
"mode",
|
|
189
|
+
(agent) => ({ ...agent, mode: "subagent" }),
|
|
190
|
+
/agent lead mode must match frontmatter/,
|
|
191
|
+
],
|
|
192
|
+
[
|
|
193
|
+
"write permission",
|
|
194
|
+
(agent) => ({
|
|
195
|
+
...agent,
|
|
196
|
+
permission_invariants: {
|
|
197
|
+
...agent.permission_invariants,
|
|
198
|
+
repository_write: "allow",
|
|
199
|
+
},
|
|
200
|
+
}),
|
|
201
|
+
/agent lead repository_write must match frontmatter/,
|
|
202
|
+
],
|
|
203
|
+
[
|
|
204
|
+
"delegation allowlist",
|
|
205
|
+
(agent) => ({
|
|
206
|
+
...agent,
|
|
207
|
+
delegates_to: agent.delegates_to.filter((id) => id !== "developer"),
|
|
208
|
+
}),
|
|
209
|
+
/agent lead delegates_to must match selected profile/,
|
|
210
|
+
],
|
|
211
|
+
[
|
|
212
|
+
"closed shape",
|
|
213
|
+
(agent) => ({ ...agent, prompt: "forbidden" }),
|
|
214
|
+
/agent lead must contain exactly/,
|
|
215
|
+
],
|
|
216
|
+
]) {
|
|
217
|
+
await t.test(label, () => {
|
|
218
|
+
const cwd = makeFixture();
|
|
219
|
+
try {
|
|
220
|
+
const contract = readOrchestrationContract(cwd);
|
|
221
|
+
contract.agents = contract.agents.map((agent) =>
|
|
222
|
+
agent.id === "lead" ? mutate(agent) : agent
|
|
223
|
+
);
|
|
224
|
+
writeOrchestrationContract(cwd, contract);
|
|
225
|
+
|
|
226
|
+
const result = runHarness(cwd);
|
|
227
|
+
assert.notEqual(result.status, 0, `checker accepted invalid agent ${label}`);
|
|
228
|
+
assert.match(result.stderr, pattern);
|
|
229
|
+
} finally {
|
|
230
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
test("orchestration contract requires one exact inventory profile", () => {
|
|
237
|
+
const cwd = makeFixture();
|
|
238
|
+
try {
|
|
239
|
+
const contract = readOrchestrationContract(cwd);
|
|
240
|
+
writeOrchestrationContract(cwd, { ...contract, profiles: {} });
|
|
241
|
+
|
|
242
|
+
const result = runHarness(cwd);
|
|
243
|
+
assert.notEqual(result.status, 0, "checker accepted no inventory profile");
|
|
244
|
+
assert.match(result.stderr, /must select exactly one inventory profile/);
|
|
245
|
+
} finally {
|
|
246
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
test("orchestration profile preserves surface-specific delegations", () => {
|
|
251
|
+
const cwd = makeFixture();
|
|
252
|
+
try {
|
|
253
|
+
const contract = readOrchestrationContract(cwd);
|
|
254
|
+
contract.profiles.public.delegation_extensions = {
|
|
255
|
+
scoper: ["debugger"],
|
|
256
|
+
};
|
|
257
|
+
writeOrchestrationContract(cwd, contract);
|
|
258
|
+
|
|
259
|
+
const result = runHarness(cwd);
|
|
260
|
+
assert.notEqual(result.status, 0, "checker accepted a foreign delegation extension");
|
|
261
|
+
assert.match(result.stderr, /agent scoper delegates_to must match selected profile/);
|
|
262
|
+
} finally {
|
|
263
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
test("orchestration command contracts match command frontmatter", async (t) => {
|
|
268
|
+
for (const [label, mutate, pattern] of [
|
|
269
|
+
[
|
|
270
|
+
"root agent",
|
|
271
|
+
(command) => ({ ...command, root_agent: "developer" }),
|
|
272
|
+
/command feature root_agent must match frontmatter/,
|
|
273
|
+
],
|
|
274
|
+
[
|
|
275
|
+
"subtask",
|
|
276
|
+
(command) => ({ ...command, subtask: true }),
|
|
277
|
+
/command feature subtask must match frontmatter/,
|
|
278
|
+
],
|
|
279
|
+
[
|
|
280
|
+
"closed shape",
|
|
281
|
+
(command) => ({ ...command, prompt: "forbidden" }),
|
|
282
|
+
/command feature must contain exactly/,
|
|
283
|
+
],
|
|
284
|
+
]) {
|
|
285
|
+
await t.test(label, () => {
|
|
286
|
+
const cwd = makeFixture();
|
|
287
|
+
try {
|
|
288
|
+
const contract = readOrchestrationContract(cwd);
|
|
289
|
+
contract.commands = contract.commands.map((command) =>
|
|
290
|
+
command.id === "feature" ? mutate(command) : command
|
|
291
|
+
);
|
|
292
|
+
writeOrchestrationContract(cwd, contract);
|
|
293
|
+
|
|
294
|
+
const result = runHarness(cwd);
|
|
295
|
+
assert.notEqual(result.status, 0, `checker accepted invalid command ${label}`);
|
|
296
|
+
assert.match(result.stderr, pattern);
|
|
297
|
+
} finally {
|
|
298
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
test("orchestration workflow references declared agents", () => {
|
|
305
|
+
const cwd = makeFixture();
|
|
306
|
+
try {
|
|
307
|
+
const contract = readOrchestrationContract(cwd);
|
|
308
|
+
contract.workflows = [{
|
|
309
|
+
id: "invalid-flow",
|
|
310
|
+
entrypoints: ["freeform"],
|
|
311
|
+
stages: [{ agent: "ghost", requirement: "required" }],
|
|
312
|
+
barriers: [],
|
|
313
|
+
retry_policy: null,
|
|
314
|
+
completion_authority: { kind: "result-contract", agent: null },
|
|
315
|
+
required_evidence: ["static_contract"],
|
|
316
|
+
adaptive: true,
|
|
317
|
+
}];
|
|
318
|
+
writeOrchestrationContract(cwd, contract);
|
|
319
|
+
|
|
320
|
+
const result = runHarness(cwd);
|
|
321
|
+
assert.notEqual(result.status, 0, "checker accepted an unknown stage agent");
|
|
322
|
+
assert.match(result.stderr, /workflow invalid-flow stage agent must reference an agent/);
|
|
323
|
+
} finally {
|
|
324
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
test("orchestration retry limits are bounded", () => {
|
|
329
|
+
const cwd = makeFixture();
|
|
330
|
+
try {
|
|
331
|
+
const contract = readOrchestrationContract(cwd);
|
|
332
|
+
contract.retry_policies = [{
|
|
333
|
+
id: "developer-default",
|
|
334
|
+
scope: "developer",
|
|
335
|
+
max_attempts: 4,
|
|
336
|
+
requires_new_evidence: true,
|
|
337
|
+
on_exhaustion: "escalate-review",
|
|
338
|
+
}];
|
|
339
|
+
writeOrchestrationContract(cwd, contract);
|
|
340
|
+
|
|
341
|
+
const result = runHarness(cwd);
|
|
342
|
+
assert.notEqual(result.status, 0, "checker accepted an unbounded retry policy");
|
|
343
|
+
assert.match(result.stderr, /retry developer-default max_attempts must be between 1 and 3/);
|
|
344
|
+
} finally {
|
|
345
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
test("orchestration routing requires known targets", () => {
|
|
350
|
+
const cwd = makeFixture();
|
|
351
|
+
try {
|
|
352
|
+
const contract = readOrchestrationContract(cwd);
|
|
353
|
+
contract.routing_rules = [{
|
|
354
|
+
id: "invalid-route",
|
|
355
|
+
target: "ghost",
|
|
356
|
+
precedence: 1,
|
|
357
|
+
}];
|
|
358
|
+
writeOrchestrationContract(cwd, contract);
|
|
359
|
+
|
|
360
|
+
const result = runHarness(cwd);
|
|
361
|
+
assert.notEqual(result.status, 0, "checker accepted an unknown routing target");
|
|
362
|
+
assert.match(result.stderr, /routing rule invalid-route target must reference an agent or ask-user/);
|
|
363
|
+
} finally {
|
|
364
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
test("orchestration catalog preserves approved behavior", async (t) => {
|
|
369
|
+
for (const [label, mutate, pattern] of [
|
|
370
|
+
[
|
|
371
|
+
"command workflow",
|
|
372
|
+
(contract) => ({
|
|
373
|
+
...contract,
|
|
374
|
+
commands: contract.commands.map((command) =>
|
|
375
|
+
command.id === "feature" ? { ...command, workflow: "plan" } : command
|
|
376
|
+
),
|
|
377
|
+
}),
|
|
378
|
+
/command feature workflow must match its entrypoint/,
|
|
379
|
+
],
|
|
380
|
+
[
|
|
381
|
+
"required workflow stage",
|
|
382
|
+
(contract) => ({
|
|
383
|
+
...contract,
|
|
384
|
+
workflows: contract.workflows.map((workflow) =>
|
|
385
|
+
workflow.id === "plan"
|
|
386
|
+
? { ...workflow, stages: workflow.stages.filter((stage) => stage.agent !== "specifier") }
|
|
387
|
+
: workflow
|
|
388
|
+
),
|
|
389
|
+
}),
|
|
390
|
+
/workflow plan stages must match the approved sequence/,
|
|
391
|
+
],
|
|
392
|
+
[
|
|
393
|
+
"retry invariant",
|
|
394
|
+
(contract) => ({
|
|
395
|
+
...contract,
|
|
396
|
+
retry_policies: contract.retry_policies.map((policy) =>
|
|
397
|
+
policy.id === "developer-default" ? { ...policy, max_attempts: 3 } : policy
|
|
398
|
+
),
|
|
399
|
+
}),
|
|
400
|
+
/retry developer-default must match the approved policy/,
|
|
401
|
+
],
|
|
402
|
+
[
|
|
403
|
+
"routing invariant",
|
|
404
|
+
(contract) => ({
|
|
405
|
+
...contract,
|
|
406
|
+
routing_rules: contract.routing_rules.map((rule) =>
|
|
407
|
+
rule.id === "reviewable-change" ? { ...rule, target: "developer" } : rule
|
|
408
|
+
),
|
|
409
|
+
}),
|
|
410
|
+
/routing rule reviewable-change must match the approved rule/,
|
|
411
|
+
],
|
|
412
|
+
[
|
|
413
|
+
"routing catalog",
|
|
414
|
+
(contract) => ({
|
|
415
|
+
...contract,
|
|
416
|
+
routing_rules: contract.routing_rules.filter((rule) => rule.id !== "visual-impact"),
|
|
417
|
+
}),
|
|
418
|
+
/routing rule catalog must match the approved catalog/,
|
|
419
|
+
],
|
|
420
|
+
[
|
|
421
|
+
"completion authority",
|
|
422
|
+
(contract) => ({
|
|
423
|
+
...contract,
|
|
424
|
+
workflows: contract.workflows.map((workflow) =>
|
|
425
|
+
workflow.id === "loop"
|
|
426
|
+
? { ...workflow, completion_authority: { kind: "agent", agent: "lead" } }
|
|
427
|
+
: workflow
|
|
428
|
+
),
|
|
429
|
+
}),
|
|
430
|
+
/workflow loop completion authority must match the approved authority/,
|
|
431
|
+
],
|
|
432
|
+
]) {
|
|
433
|
+
await t.test(label, () => {
|
|
434
|
+
const cwd = makeFixture();
|
|
435
|
+
try {
|
|
436
|
+
writeOrchestrationContract(cwd, mutate(readOrchestrationContract(cwd)));
|
|
437
|
+
const result = runHarness(cwd);
|
|
438
|
+
assert.notEqual(result.status, 0, `checker accepted changed ${label}`);
|
|
439
|
+
assert.match(result.stderr, pattern);
|
|
440
|
+
} finally {
|
|
441
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
|
|
67
447
|
const validLoopCommand = `---
|
|
68
448
|
description: Run a bounded and verifiable engineering loop.
|
|
69
449
|
agent: lead
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-agent-orchestration-kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.33",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"oak": "scripts/oak.mjs"
|
|
9
|
+
},
|
|
7
10
|
"files": [
|
|
8
11
|
"CODE_OF_CONDUCT.md",
|
|
9
12
|
"CONTRIBUTING.md",
|
|
@@ -24,7 +24,7 @@ const EXACT_KEYS = {
|
|
|
24
24
|
commit: ["commit"],
|
|
25
25
|
image: ["tag", "digest"],
|
|
26
26
|
version: ["version"],
|
|
27
|
-
overrides: ["@babel/core", "uuid"],
|
|
27
|
+
overrides: ["@babel/core", "brace-expansion", "uuid"],
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
const COMMIT = /^[0-9a-f]{40}$/;
|
|
@@ -115,6 +115,10 @@ export function validateSupplyChainData(data) {
|
|
|
115
115
|
assertStableVersion(data.external_refs.pnpm.version, "external_refs.pnpm.version");
|
|
116
116
|
assertStableVersion(data.external_refs.opencode_ai.version, "external_refs.opencode_ai.version");
|
|
117
117
|
assertStableVersion(data.npm_overrides["@babel/core"], "npm_overrides.@babel/core");
|
|
118
|
+
assertStableVersion(
|
|
119
|
+
data.npm_overrides["brace-expansion"],
|
|
120
|
+
"npm_overrides.brace-expansion",
|
|
121
|
+
);
|
|
118
122
|
assertStableVersion(data.npm_overrides.uuid, "npm_overrides.uuid");
|
|
119
123
|
return data;
|
|
120
124
|
}
|
|
@@ -187,6 +191,10 @@ function validatePackages(root, data, fsOps) {
|
|
|
187
191
|
if (JSON.stringify(rootPackage.files) !== JSON.stringify(PACKAGE_FILES)) {
|
|
188
192
|
throw invalid(`package.json files must be exactly: ${PACKAGE_FILES.join(", ")}`);
|
|
189
193
|
}
|
|
194
|
+
assertExactKeys(rootPackage.bin, ["oak"], "package.json bin");
|
|
195
|
+
if (rootPackage.bin.oak !== "scripts/oak.mjs") {
|
|
196
|
+
throw invalid("package.json bin.oak must be scripts/oak.mjs");
|
|
197
|
+
}
|
|
190
198
|
for (const [script, command] of [
|
|
191
199
|
["dependency-audit", "npm --prefix opencode audit --omit=dev --audit-level=low"],
|
|
192
200
|
["dependency-signature-audit", "npm --prefix opencode audit signatures"],
|
|
@@ -507,6 +515,7 @@ function canonicalDocumentationPinBlock(data) {
|
|
|
507
515
|
| pnpm | ${data.external_refs.pnpm.version} | exact version |
|
|
508
516
|
| opencode-ai | ${data.external_refs.opencode_ai.version} | exact version |
|
|
509
517
|
| @babel/core override | ${data.npm_overrides["@babel/core"]} | exact version |
|
|
518
|
+
| brace-expansion override | ${data.npm_overrides["brace-expansion"]} | exact version |
|
|
510
519
|
| uuid override | ${data.npm_overrides.uuid} | exact version |
|
|
511
520
|
<!-- supply-chain-pins:end -->`;
|
|
512
521
|
}
|
|
@@ -534,6 +543,7 @@ function validateDocumentation(root, data, fsOps) {
|
|
|
534
543
|
"| pnpm |",
|
|
535
544
|
"| opencode-ai |",
|
|
536
545
|
"| @babel/core override |",
|
|
546
|
+
"| brace-expansion override |",
|
|
537
547
|
"| uuid override |",
|
|
538
548
|
].map((row) => actualBlock.indexOf(row));
|
|
539
549
|
const rowsAreOrdered = rowPositions.every(
|
|
@@ -46,6 +46,7 @@ const VALID = {
|
|
|
46
46
|
},
|
|
47
47
|
npm_overrides: {
|
|
48
48
|
"@babel/core": "7.29.7",
|
|
49
|
+
"brace-expansion": "5.0.8",
|
|
49
50
|
uuid: "14.0.0",
|
|
50
51
|
},
|
|
51
52
|
};
|
|
@@ -91,6 +92,7 @@ function canonicalPolicy() {
|
|
|
91
92
|
| pnpm | ${VALID.external_refs.pnpm.version} | exact version |
|
|
92
93
|
| opencode-ai | ${VALID.external_refs.opencode_ai.version} | exact version |
|
|
93
94
|
| @babel/core override | ${VALID.npm_overrides["@babel/core"]} | exact version |
|
|
95
|
+
| brace-expansion override | ${VALID.npm_overrides["brace-expansion"]} | exact version |
|
|
94
96
|
| uuid override | ${VALID.npm_overrides.uuid} | exact version |
|
|
95
97
|
<!-- supply-chain-pins:end -->
|
|
96
98
|
|
|
@@ -156,6 +158,7 @@ function withSurfaceFixture(callback) {
|
|
|
156
158
|
fs.writeFileSync(path.join(root, "supply-chain.json"), `${JSON.stringify(VALID)}\n`);
|
|
157
159
|
fs.writeFileSync(path.join(root, "package.json"), `${JSON.stringify({
|
|
158
160
|
files: PACKAGE_FILES,
|
|
161
|
+
bin: { oak: "scripts/oak.mjs" },
|
|
159
162
|
scripts: {
|
|
160
163
|
"dependency-audit": "npm --prefix opencode audit --omit=dev --audit-level=low",
|
|
161
164
|
"dependency-signature-audit": "npm --prefix opencode audit signatures",
|
|
@@ -177,6 +180,11 @@ function withSurfaceFixture(callback) {
|
|
|
177
180
|
resolved: "https://registry.npmjs.org/@babel/core/-/core-7.29.7.tgz",
|
|
178
181
|
integrity: "sha512-babel",
|
|
179
182
|
},
|
|
183
|
+
"node_modules/brace-expansion": {
|
|
184
|
+
version: VALID.npm_overrides["brace-expansion"],
|
|
185
|
+
resolved: "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.8.tgz",
|
|
186
|
+
integrity: "sha512-braceexpansion",
|
|
187
|
+
},
|
|
180
188
|
"node_modules/uuid": {
|
|
181
189
|
version: VALID.npm_overrides.uuid,
|
|
182
190
|
resolved: "https://registry.npmjs.org/uuid/-/uuid-14.0.0.tgz",
|
|
@@ -211,6 +219,7 @@ function withCliFixture(inventory, callback) {
|
|
|
211
219
|
writeValidDocumentation(root);
|
|
212
220
|
fs.writeFileSync(path.join(root, "package.json"), `${JSON.stringify({
|
|
213
221
|
files: PACKAGE_FILES,
|
|
222
|
+
bin: { oak: "scripts/oak.mjs" },
|
|
214
223
|
scripts: {
|
|
215
224
|
"dependency-audit": "npm --prefix opencode audit --omit=dev --audit-level=low",
|
|
216
225
|
"dependency-signature-audit": "npm --prefix opencode audit signatures",
|
|
@@ -307,6 +316,10 @@ test("requires exact canonical versions without ranges", () => {
|
|
|
307
316
|
(data) => { data.npm_overrides["@babel/core"] = ">=7.29.7"; },
|
|
308
317
|
"npm_overrides.@babel/core",
|
|
309
318
|
);
|
|
319
|
+
expectInvalid(
|
|
320
|
+
(data) => { data.npm_overrides["brace-expansion"] = "^5.0.8"; },
|
|
321
|
+
"npm_overrides.brace-expansion",
|
|
322
|
+
);
|
|
310
323
|
expectInvalid(
|
|
311
324
|
(data) => { data.npm_overrides.uuid = "14.0"; },
|
|
312
325
|
"npm_overrides.uuid",
|
|
@@ -325,6 +338,23 @@ test("surface validation accepts exact overrides, regenerated lock entries, and
|
|
|
325
338
|
});
|
|
326
339
|
});
|
|
327
340
|
|
|
341
|
+
test("surface validation requires exactly the canonical oak bin", () => {
|
|
342
|
+
for (const [bin, expected] of [
|
|
343
|
+
[undefined, /package\.json bin/i],
|
|
344
|
+
[{ oak: "scripts/other.mjs" }, /bin\.oak/i],
|
|
345
|
+
[{ oak: "scripts/oak.mjs", other: "scripts/other.mjs" }, /keys must be exactly/i],
|
|
346
|
+
]) {
|
|
347
|
+
withSurfaceFixture((root) => {
|
|
348
|
+
const packagePath = path.join(root, "package.json");
|
|
349
|
+
const packageJson = JSON.parse(fs.readFileSync(packagePath, "utf8"));
|
|
350
|
+
if (bin === undefined) delete packageJson.bin;
|
|
351
|
+
else packageJson.bin = bin;
|
|
352
|
+
fs.writeFileSync(packagePath, `${JSON.stringify(packageJson)}\n`);
|
|
353
|
+
assert.throws(() => checkSupplyChain(root), expected);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
|
|
328
358
|
test("surface validation requires the exact Superpowers commit", () => {
|
|
329
359
|
withSurfaceFixture((root) => {
|
|
330
360
|
const relative = "opencode/opencode.json";
|
|
@@ -549,6 +579,7 @@ for (const [label, current, replacement] of [
|
|
|
549
579
|
["pnpm", `| pnpm | ${VALID.external_refs.pnpm.version} |`, "| pnpm | DRIFTED |"],
|
|
550
580
|
["opencode-ai", `| opencode-ai | ${VALID.external_refs.opencode_ai.version} |`, "| opencode-ai | DRIFTED |"],
|
|
551
581
|
["Babel override", `| @babel/core override | ${VALID.npm_overrides["@babel/core"]} |`, "| @babel/core override | DRIFTED |"],
|
|
582
|
+
["brace-expansion override", `| brace-expansion override | ${VALID.npm_overrides["brace-expansion"]} |`, "| brace-expansion override | DRIFTED |"],
|
|
552
583
|
["uuid override", `| uuid override | ${VALID.npm_overrides.uuid} |`, "| uuid override | DRIFTED |"],
|
|
553
584
|
]) {
|
|
554
585
|
test(`documentation validation rejects a drifted ${label} pin`, () => {
|
|
@@ -646,6 +677,9 @@ for (const [dependency, mutation] of [
|
|
|
646
677
|
["@babel/core", (packageData) => { delete packageData.overrides["@babel/core"]; }],
|
|
647
678
|
["@babel/core range", (packageData) => { packageData.overrides["@babel/core"] = "^7.29.7"; }],
|
|
648
679
|
["@babel/core wrong version", (packageData) => { packageData.overrides["@babel/core"] = "7.29.6"; }],
|
|
680
|
+
["brace-expansion", (packageData) => { delete packageData.overrides["brace-expansion"]; }],
|
|
681
|
+
["brace-expansion range", (packageData) => { packageData.overrides["brace-expansion"] = "^5.0.8"; }],
|
|
682
|
+
["brace-expansion wrong version", (packageData) => { packageData.overrides["brace-expansion"] = "5.0.7"; }],
|
|
649
683
|
["uuid", (packageData) => { delete packageData.overrides.uuid; }],
|
|
650
684
|
["uuid range", (packageData) => { packageData.overrides.uuid = "^14.0.0"; }],
|
|
651
685
|
["uuid wrong version", (packageData) => { packageData.overrides.uuid = "13.0.0"; }],
|
|
@@ -671,6 +705,19 @@ test("surface validation rejects a lockfile not regenerated to the Babel overrid
|
|
|
671
705
|
});
|
|
672
706
|
});
|
|
673
707
|
|
|
708
|
+
test("surface validation rejects a lockfile not regenerated to the brace-expansion override", () => {
|
|
709
|
+
withSurfaceFixture((root) => {
|
|
710
|
+
const relative = "opencode/package-lock.json";
|
|
711
|
+
const lock = JSON.parse(fs.readFileSync(path.join(root, relative), "utf8"));
|
|
712
|
+
lock.packages["node_modules/brace-expansion"].version = "5.0.7";
|
|
713
|
+
fs.writeFileSync(path.join(root, relative), `${JSON.stringify(lock)}\n`);
|
|
714
|
+
assert.throws(
|
|
715
|
+
() => checkSupplyChain(root),
|
|
716
|
+
/package-lock\.json brace-expansion must resolve to 5\.0\.8/,
|
|
717
|
+
);
|
|
718
|
+
});
|
|
719
|
+
});
|
|
720
|
+
|
|
674
721
|
for (const [label, mutate, message] of [
|
|
675
722
|
["missing resolved", (entry) => { delete entry.resolved; }, /node_modules\/example.*canonical npm registry resolved URL/i],
|
|
676
723
|
["non-registry resolved", (entry) => { entry.resolved = "https://example.invalid/example.tgz"; }, /node_modules\/example.*canonical npm registry resolved URL/i],
|