opencode-agent-orchestration-kit 1.0.32 → 1.0.37
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 +73 -4
- package/SECURITY.md +7 -0
- package/docs/cli.md +100 -0
- package/docs/installation.md +25 -5
- package/docs/quickstart.md +1 -1
- package/docs/releases/v1.0.33.md +72 -0
- package/docs/releases/v1.0.34.md +59 -0
- package/docs/releases/v1.0.35.md +62 -0
- package/docs/releases/v1.0.36.md +58 -0
- package/docs/releases/v1.0.37.md +53 -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/agents/lead.md +11 -2
- package/opencode/agents/review_api.md +26 -9
- package/opencode/agents/review_coordinator.md +60 -68
- package/opencode/agents/review_quality.md +27 -11
- package/opencode/agents/review_security.md +26 -10
- package/opencode/agents/review_tests.md +26 -9
- package/opencode/agents/reviewer.md +95 -80
- package/opencode/commands/autonomous.md +75 -0
- package/opencode/commands/evolve.md +3 -1
- package/opencode/commands/feature.md +6 -2
- package/opencode/commands/loop.md +12 -8
- package/opencode/commands/review-orchestrated.md +26 -24
- package/opencode/commands/review-preflight.md +8 -7
- package/opencode/commands/review.md +27 -10
- package/opencode/docs/ai/harness/README.md +5 -0
- package/opencode/docs/ai/harness/agents.md +27 -3
- package/opencode/docs/ai/harness/checks.md +18 -0
- package/opencode/docs/ai/harness/commands.md +44 -0
- package/opencode/docs/ai/harness/orchestrated-review.md +8 -1
- package/opencode/docs/ai/harness/orchestration-contracts.json +924 -0
- package/opencode/package-lock.json +14 -8
- package/opencode/package.json +1 -0
- package/opencode/plugins/shell-export-guard.ts +23 -0
- package/opencode/scripts/adversarial-harness.test.mjs +5 -2
- package/opencode/scripts/check-harness.mjs +873 -18
- package/opencode/scripts/check-harness.test.mjs +562 -0
- package/opencode/scripts/loop-state.mjs +88 -14
- package/opencode/scripts/loop-state.test.mjs +82 -5
- package/opencode/scripts/review-orchestrated-prepare.mjs +18 -1
- package/opencode/scripts/review-orchestrated-prepare.test.mjs +49 -0
- package/opencode/scripts/shell-export-policy.d.mts +4 -0
- package/opencode/scripts/shell-export-policy.mjs +272 -0
- package/opencode/scripts/shell-export-policy.test.mjs +96 -0
- package/opencode/skills/code-review-and-quality/SKILL.md +63 -321
- package/opencode/skills/code-review-and-quality/references/profiles/backend-clean-ddd-cqrs.md +60 -0
- package/opencode/skills/code-review-and-quality/references/profiles/backend.md +54 -0
- package/opencode/skills/code-review-and-quality/references/profiles/frontend-clean-layered.md +60 -0
- package/opencode/skills/code-review-and-quality/references/profiles/frontend.md +62 -0
- package/opencode/skills/code-review-and-quality/references/review-policy.md +258 -0
- package/package.json +5 -2
- package/scripts/check-supply-chain.mjs +16 -2
- package/scripts/check-supply-chain.test.mjs +52 -1
- 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 +55 -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 +246 -0
- package/scripts/oak.test.mjs +329 -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
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import test from "node:test";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
parseMarkdownTable,
|
|
9
|
+
validateThreatModel,
|
|
10
|
+
} from "./check-threat-model.mjs";
|
|
11
|
+
|
|
12
|
+
const ROOT = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
|
13
|
+
const AGENTS = [
|
|
14
|
+
"debugger",
|
|
15
|
+
"designer",
|
|
16
|
+
"developer",
|
|
17
|
+
"evaluator",
|
|
18
|
+
"evolver",
|
|
19
|
+
"lead",
|
|
20
|
+
"researcher",
|
|
21
|
+
"review_api",
|
|
22
|
+
"review_coordinator",
|
|
23
|
+
"review_quality",
|
|
24
|
+
"review_security",
|
|
25
|
+
"review_tests",
|
|
26
|
+
"reviewer",
|
|
27
|
+
"scoper",
|
|
28
|
+
"specifier",
|
|
29
|
+
];
|
|
30
|
+
const SCENARIOS = [
|
|
31
|
+
"diff-injection-is-data",
|
|
32
|
+
"repo-doc-is-data",
|
|
33
|
+
"external-symlink-rejected",
|
|
34
|
+
"path-traversal-rejected",
|
|
35
|
+
"control-filename-rejected",
|
|
36
|
+
"rtk-wrapper-needs-approval",
|
|
37
|
+
"review-network-not-allowed",
|
|
38
|
+
"approval-hash-is-immutable",
|
|
39
|
+
"credential-canary-stays-local",
|
|
40
|
+
"unpinned-ref-needs-approval",
|
|
41
|
+
"repeated-event-rejected",
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
function table(heading, headers, rows) {
|
|
45
|
+
return [
|
|
46
|
+
`## ${heading}`,
|
|
47
|
+
"",
|
|
48
|
+
`| ${headers.join(" | ")} |`,
|
|
49
|
+
`| ${headers.map(() => "---").join(" | ")} |`,
|
|
50
|
+
...rows.map((row) => `| ${row.join(" | ")} |`),
|
|
51
|
+
"",
|
|
52
|
+
].join("\n");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function validModel() {
|
|
56
|
+
const actors = Array.from({ length: 6 }, (_, index) => [
|
|
57
|
+
`AC-${String(index + 1).padStart(3, "0")}`,
|
|
58
|
+
"Actor",
|
|
59
|
+
"untrusted",
|
|
60
|
+
"Capability",
|
|
61
|
+
]);
|
|
62
|
+
const assets = Array.from({ length: 10 }, (_, index) => [
|
|
63
|
+
`A-${String(index + 1).padStart(3, "0")}`,
|
|
64
|
+
"Asset",
|
|
65
|
+
"integrity",
|
|
66
|
+
]);
|
|
67
|
+
const boundaries = Array.from({ length: 9 }, (_, index) => [
|
|
68
|
+
`TB-${String(index + 1).padStart(3, "0")}`,
|
|
69
|
+
"Boundary",
|
|
70
|
+
"Flow",
|
|
71
|
+
]);
|
|
72
|
+
const risks = Array.from({ length: 20 }, (_, index) => [
|
|
73
|
+
`TM-${String(index + 1).padStart(3, "0")}`,
|
|
74
|
+
"Risk",
|
|
75
|
+
"AC-002",
|
|
76
|
+
"A-001",
|
|
77
|
+
"TB-001",
|
|
78
|
+
"Concrete abuse",
|
|
79
|
+
"medium",
|
|
80
|
+
"Existing control",
|
|
81
|
+
"limitation:fixture evidence",
|
|
82
|
+
"partially-mitigated",
|
|
83
|
+
"Residual remains",
|
|
84
|
+
"maintainer",
|
|
85
|
+
"permission or runtime change",
|
|
86
|
+
]);
|
|
87
|
+
const agentRows = AGENTS.map((agent) => [
|
|
88
|
+
agent,
|
|
89
|
+
"deny",
|
|
90
|
+
"ask",
|
|
91
|
+
"deny",
|
|
92
|
+
"deny",
|
|
93
|
+
"none",
|
|
94
|
+
"role",
|
|
95
|
+
`opencode/agents/${agent}.md`,
|
|
96
|
+
]);
|
|
97
|
+
const scenarioRows = SCENARIOS.map((scenario) => [
|
|
98
|
+
scenario,
|
|
99
|
+
"TM-001",
|
|
100
|
+
"test:opencode/scripts/adversarial-harness.test.mjs",
|
|
101
|
+
]);
|
|
102
|
+
return [
|
|
103
|
+
"# Threat Model",
|
|
104
|
+
"## Scope and security objectives",
|
|
105
|
+
"Portable fixture.",
|
|
106
|
+
table("Actors", ["ID", "Actor", "Trust", "Capabilities"], actors),
|
|
107
|
+
table("Assets", ["ID", "Asset", "Protection"], assets),
|
|
108
|
+
table("Trust boundaries", ["ID", "Boundary", "Flow"], boundaries),
|
|
109
|
+
table(
|
|
110
|
+
"Agent capabilities",
|
|
111
|
+
[
|
|
112
|
+
"Agent",
|
|
113
|
+
"Edit",
|
|
114
|
+
"Shell",
|
|
115
|
+
"Network",
|
|
116
|
+
"External directory",
|
|
117
|
+
"Delegation",
|
|
118
|
+
"Role",
|
|
119
|
+
"Source",
|
|
120
|
+
],
|
|
121
|
+
agentRows,
|
|
122
|
+
),
|
|
123
|
+
table(
|
|
124
|
+
"External surfaces",
|
|
125
|
+
["Surface", "Boundary", "Controls or limitations"],
|
|
126
|
+
[["Registry", "TB-006", "Pinned references"]],
|
|
127
|
+
),
|
|
128
|
+
table(
|
|
129
|
+
"Persistence surfaces",
|
|
130
|
+
[
|
|
131
|
+
"Surface",
|
|
132
|
+
"Owner",
|
|
133
|
+
"Sensitivity",
|
|
134
|
+
"Lifecycle",
|
|
135
|
+
"Controls or limitations",
|
|
136
|
+
],
|
|
137
|
+
[["State", "operator", "private", "create/read/delete", "limited access"]],
|
|
138
|
+
),
|
|
139
|
+
"## Data flows",
|
|
140
|
+
"1. Request -> agent -> tool.",
|
|
141
|
+
table(
|
|
142
|
+
"Risk register",
|
|
143
|
+
[
|
|
144
|
+
"ID",
|
|
145
|
+
"Title",
|
|
146
|
+
"Actor or input",
|
|
147
|
+
"Assets",
|
|
148
|
+
"Boundaries",
|
|
149
|
+
"Abuse",
|
|
150
|
+
"Severity",
|
|
151
|
+
"Controls",
|
|
152
|
+
"Evidence",
|
|
153
|
+
"Status",
|
|
154
|
+
"Residual",
|
|
155
|
+
"Authority",
|
|
156
|
+
"Review trigger",
|
|
157
|
+
],
|
|
158
|
+
risks,
|
|
159
|
+
),
|
|
160
|
+
table(
|
|
161
|
+
"Adversarial traceability",
|
|
162
|
+
["Scenario ID", "Risk ID", "Evidence"],
|
|
163
|
+
scenarioRows,
|
|
164
|
+
),
|
|
165
|
+
"## Residual risks and assumptions",
|
|
166
|
+
"The policy layer is not an operating-system sandbox.",
|
|
167
|
+
"## Private and public boundary",
|
|
168
|
+
"Only portable mechanisms are public.",
|
|
169
|
+
].join("\n\n");
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
test("parseMarkdownTable returns strict named columns", () => {
|
|
173
|
+
assert.deepEqual(
|
|
174
|
+
parseMarkdownTable(
|
|
175
|
+
table(
|
|
176
|
+
"Assets",
|
|
177
|
+
["ID", "Asset", "Protection"],
|
|
178
|
+
[["A-001", "Intent", "integrity"]],
|
|
179
|
+
),
|
|
180
|
+
"Assets",
|
|
181
|
+
["ID", "Asset", "Protection"],
|
|
182
|
+
),
|
|
183
|
+
[{ ID: "A-001", Asset: "Intent", Protection: "integrity" }],
|
|
184
|
+
);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test("the minimal complete model validates", () => {
|
|
188
|
+
assert.doesNotThrow(() =>
|
|
189
|
+
validateThreatModel(validModel(), {
|
|
190
|
+
agentIds: AGENTS,
|
|
191
|
+
scenarioIds: SCENARIOS,
|
|
192
|
+
}),
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
for (const [label, mutate, pattern] of [
|
|
197
|
+
[
|
|
198
|
+
"missing section",
|
|
199
|
+
(text) => text.replace("## Data flows", "## Missing"),
|
|
200
|
+
/Data flows/,
|
|
201
|
+
],
|
|
202
|
+
[
|
|
203
|
+
"duplicate asset",
|
|
204
|
+
(text) => text.replace("A-002 | Asset", "A-001 | Asset"),
|
|
205
|
+
/duplicate.*A-001/i,
|
|
206
|
+
],
|
|
207
|
+
[
|
|
208
|
+
"bad severity",
|
|
209
|
+
(text) => text.replace("| medium |", "| critical |"),
|
|
210
|
+
/severity/i,
|
|
211
|
+
],
|
|
212
|
+
[
|
|
213
|
+
"bad status",
|
|
214
|
+
(text) =>
|
|
215
|
+
text.replace("| partially-mitigated |", "| unknown |"),
|
|
216
|
+
/status/i,
|
|
217
|
+
],
|
|
218
|
+
[
|
|
219
|
+
"unknown asset",
|
|
220
|
+
(text) => text.replace("| A-001 | TB-001 |", "| A-999 | TB-001 |"),
|
|
221
|
+
/A-999/,
|
|
222
|
+
],
|
|
223
|
+
[
|
|
224
|
+
"unknown boundary",
|
|
225
|
+
(text) =>
|
|
226
|
+
text.replace("| TB-001 | Concrete", "| TB-999 | Concrete"),
|
|
227
|
+
/TB-999/,
|
|
228
|
+
],
|
|
229
|
+
[
|
|
230
|
+
"bad evidence",
|
|
231
|
+
(text) =>
|
|
232
|
+
text.replace("limitation:fixture evidence", "fixture evidence"),
|
|
233
|
+
/evidence/i,
|
|
234
|
+
],
|
|
235
|
+
[
|
|
236
|
+
"missing agent",
|
|
237
|
+
(text) => text.replace(/\| debugger \|[^\n]+\n/, ""),
|
|
238
|
+
/debugger/,
|
|
239
|
+
],
|
|
240
|
+
[
|
|
241
|
+
"duplicate scenario",
|
|
242
|
+
(text) =>
|
|
243
|
+
text.replace("repo-doc-is-data", "diff-injection-is-data"),
|
|
244
|
+
/scenario/i,
|
|
245
|
+
],
|
|
246
|
+
[
|
|
247
|
+
"private path",
|
|
248
|
+
(text) =>
|
|
249
|
+
`${text}\n${["", "Users", "example", "private"].join("/")}\n`,
|
|
250
|
+
/private marker/i,
|
|
251
|
+
],
|
|
252
|
+
]) {
|
|
253
|
+
test(`validateThreatModel rejects ${label}`, () => {
|
|
254
|
+
assert.throws(
|
|
255
|
+
() =>
|
|
256
|
+
validateThreatModel(mutate(validModel()), {
|
|
257
|
+
agentIds: AGENTS,
|
|
258
|
+
scenarioIds: SCENARIOS,
|
|
259
|
+
}),
|
|
260
|
+
pattern,
|
|
261
|
+
);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
test("accepted risks require maintainer authority and a review trigger", () => {
|
|
266
|
+
const accepted = validModel()
|
|
267
|
+
.replace("partially-mitigated", "accepted")
|
|
268
|
+
.replace(
|
|
269
|
+
"| maintainer | permission or runtime change |",
|
|
270
|
+
"| team | none |",
|
|
271
|
+
);
|
|
272
|
+
assert.throws(
|
|
273
|
+
() =>
|
|
274
|
+
validateThreatModel(accepted, {
|
|
275
|
+
agentIds: AGENTS,
|
|
276
|
+
scenarioIds: SCENARIOS,
|
|
277
|
+
}),
|
|
278
|
+
/accepted.*maintainer.*review trigger/i,
|
|
279
|
+
);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
test("the canonical repository model validates", () => {
|
|
283
|
+
const text = fs.readFileSync(path.join(ROOT, "docs/threat-model.md"), "utf8");
|
|
284
|
+
const agentIds = fs
|
|
285
|
+
.readdirSync(path.join(ROOT, "opencode/agents"))
|
|
286
|
+
.filter((name) => name.endsWith(".md"))
|
|
287
|
+
.map((name) => path.basename(name, ".md"))
|
|
288
|
+
.sort();
|
|
289
|
+
const scenarioIds = fs
|
|
290
|
+
.readFileSync(
|
|
291
|
+
path.join(
|
|
292
|
+
ROOT,
|
|
293
|
+
"opencode/docs/ai/evolution/benchmarks/adversarial-scenarios.jsonl",
|
|
294
|
+
),
|
|
295
|
+
"utf8",
|
|
296
|
+
)
|
|
297
|
+
.trim()
|
|
298
|
+
.split("\n")
|
|
299
|
+
.map((line) => JSON.parse(line).id)
|
|
300
|
+
.sort();
|
|
301
|
+
assert.doesNotThrow(() =>
|
|
302
|
+
validateThreatModel(text, { agentIds, scenarioIds }),
|
|
303
|
+
);
|
|
304
|
+
});
|