opencode-agent-orchestration-kit 1.0.27
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/.github/CODEOWNERS +1 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +65 -0
- package/.github/ISSUE_TEMPLATE/config.yml +11 -0
- package/.github/ISSUE_TEMPLATE/documentation.yml +22 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +43 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +25 -0
- package/.github/workflows/check.yml +47 -0
- package/CODE_OF_CONDUCT.md +24 -0
- package/CONTRIBUTING.md +52 -0
- package/LICENSE +201 -0
- package/NOTICE.md +23 -0
- package/README.md +806 -0
- package/SECURITY.md +17 -0
- package/docker/open-design/.env.example +6 -0
- package/docker/open-design/Dockerfile +50 -0
- package/docker/open-design/docker-compose.yml +18 -0
- package/docker/open-design/opencode-od/agents/od-worker.md +22 -0
- package/docker/open-design/opencode-od/opencode.json +24 -0
- package/docs/agents.md +21 -0
- package/docs/commands.md +16 -0
- package/docs/configuration.md +30 -0
- package/docs/docker-open-design.md +42 -0
- package/docs/impeccable.md +18 -0
- package/docs/installation.md +176 -0
- package/docs/models.md +17 -0
- package/docs/open-design.md +25 -0
- package/docs/quickstart.md +74 -0
- package/docs/releases/v1.0.10.md +46 -0
- package/docs/releases/v1.0.14.md +39 -0
- package/docs/releases/v1.0.27.md +66 -0
- package/docs/security.md +8 -0
- package/docs/superpowers/plans/2026-07-20-safe-installation-lifecycle.md +779 -0
- package/docs/superpowers/plans/2026-07-20-version-identity-and-releases.md +590 -0
- package/docs/superpowers/specs/2026-07-20-safe-installation-lifecycle-design.md +1350 -0
- package/docs/superpowers/specs/2026-07-20-version-identity-and-releases-design.md +557 -0
- package/docs/superpowers.md +34 -0
- package/docs/synology.md +30 -0
- package/docs/troubleshooting.md +54 -0
- package/docs/workflows.md +44 -0
- package/doctor.sh +5 -0
- package/env.example +15 -0
- package/install.sh +5 -0
- package/opencode/AGENTS.md +104 -0
- package/opencode/agents/debugger.md +41 -0
- package/opencode/agents/designer.md +93 -0
- package/opencode/agents/developer.md +180 -0
- package/opencode/agents/evaluator.md +35 -0
- package/opencode/agents/evolver.md +31 -0
- package/opencode/agents/lead.md +251 -0
- package/opencode/agents/researcher.md +76 -0
- package/opencode/agents/review_api.md +34 -0
- package/opencode/agents/review_coordinator.md +111 -0
- package/opencode/agents/review_quality.md +35 -0
- package/opencode/agents/review_security.md +35 -0
- package/opencode/agents/review_tests.md +37 -0
- package/opencode/agents/reviewer.md +116 -0
- package/opencode/agents/scoper.md +75 -0
- package/opencode/agents/specifier.md +116 -0
- package/opencode/commands/code-simplify.md +36 -0
- package/opencode/commands/design.md +27 -0
- package/opencode/commands/evolve.md +165 -0
- package/opencode/commands/feature.md +67 -0
- package/opencode/commands/implement.md +11 -0
- package/opencode/commands/init.md +34 -0
- package/opencode/commands/loop.md +145 -0
- package/opencode/commands/mvp-spec.md +20 -0
- package/opencode/commands/plan.md +74 -0
- package/opencode/commands/research.md +12 -0
- package/opencode/commands/review-orchestrated.md +47 -0
- package/opencode/commands/review-preflight.md +26 -0
- package/opencode/commands/review.md +18 -0
- package/opencode/commands/scope.md +36 -0
- package/opencode/commands/spec.md +12 -0
- package/opencode/commands/test.md +40 -0
- package/opencode/docs/ai/evolution/README.md +135 -0
- package/opencode/docs/ai/evolution/benchmarks/manual-scenarios.md +123 -0
- package/opencode/docs/ai/evolution/benchmarks/router-scenarios.jsonl +8 -0
- package/opencode/docs/ai/evolution/evolution_history.md +83 -0
- package/opencode/docs/ai/evolution/mechanisms.jsonl +7 -0
- package/opencode/docs/ai/evolution/rejected_mechanisms.jsonl +2 -0
- package/opencode/docs/ai/evolution/runs/README.md +15 -0
- package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/analysis/overview.md +12 -0
- package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/change_evaluation.json +108 -0
- package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/change_manifest.json +52 -0
- package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/evaluation.md +19 -0
- package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/post_evaluation.md +12 -0
- package/opencode/docs/ai/evolution/runs/iteration-002-feature-flow-fix/analysis/overview.md +7 -0
- package/opencode/docs/ai/evolution/runs/iteration-002-feature-flow-fix/change_evaluation.json +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-002-feature-flow-fix/evaluation.md +19 -0
- package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/analysis/overview.md +13 -0
- package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/change_evaluation.json +66 -0
- package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/change_manifest.json +82 -0
- package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/evaluation.md +20 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/ahe-run-lifecycle-validator.md +40 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/evolve-evaluation-only-contract.md +15 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/open-design-tool-contract.md +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/slash-command-contract-coverage.md +40 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/overview.md +17 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/pre_apply_approval.md +15 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/change_evaluation.json +252 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/change_manifest.json +210 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/evaluation.md +25 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/post_apply_evaluation.md +15 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/post_manifest_evaluation.md +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/pre_apply_evaluation.md +15 -0
- package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/analysis/overview.md +13 -0
- package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/change_evaluation.json +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/change_manifest.json +30 -0
- package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/evaluation.md +25 -0
- package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/analysis/overview.md +13 -0
- package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/change_evaluation.json +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/change_manifest.json +29 -0
- package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/evaluation.md +18 -0
- package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/analysis/overview.md +13 -0
- package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/change_evaluation.json +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/change_manifest.json +34 -0
- package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/evaluation.md +17 -0
- package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/analysis/overview.md +13 -0
- package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/change_evaluation.json +12 -0
- package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/change_manifest.json +28 -0
- package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/evaluation.md +17 -0
- package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/analysis/overview.md +9 -0
- package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/change_evaluation.json +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/change_manifest.json +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/evaluation.md +18 -0
- package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/analysis/overview.md +12 -0
- package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/change_evaluation.json +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/change_manifest.json +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/evaluation.md +17 -0
- package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/analysis/overview.md +10 -0
- package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/change_evaluation.json +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/change_manifest.json +30 -0
- package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/evaluation.md +17 -0
- package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/analysis/overview.md +25 -0
- package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/change_evaluation.json +28 -0
- package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/change_manifest.json +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/evaluation.md +22 -0
- package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/analysis/overview.md +27 -0
- package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/change_evaluation.json +32 -0
- package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/change_manifest.json +49 -0
- package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/evaluation.md +92 -0
- package/opencode/docs/ai/evolution/runs/iteration-014-harness-baseline/analysis/detail/token-vs-semantic.md +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-014-harness-baseline/analysis/overview.md +14 -0
- package/opencode/docs/ai/evolution/runs/iteration-014-harness-baseline/evaluation.md +36 -0
- package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/analysis/overview.md +13 -0
- package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/change_evaluation.json +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/change_manifest.json +47 -0
- package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/evaluation.md +27 -0
- package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/analysis/overview.md +32 -0
- package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/change_evaluation.json +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/change_manifest.json +35 -0
- package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/evaluation.md +31 -0
- package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/analysis/detail/pattern-1-feature-sidecar-false-positive.md +51 -0
- package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/analysis/detail/pattern-2-checker-time-budget.md +52 -0
- package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/analysis/overview.md +99 -0
- package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/change_evaluation.json +61 -0
- package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/change_manifest.json +61 -0
- package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/evaluation.md +448 -0
- package/opencode/docs/ai/evolution/runs/iteration-018-free-message-routing-audit/analysis/detail/intake-gray-zone.md +65 -0
- package/opencode/docs/ai/evolution/runs/iteration-018-free-message-routing-audit/analysis/overview.md +172 -0
- package/opencode/docs/ai/evolution/runs/iteration-018-free-message-routing-audit/evaluation.md +226 -0
- package/opencode/docs/ai/evolution/runs/iteration-019-handoff-routing-audit/analysis/detail/plan-only-gray-zone.md +62 -0
- package/opencode/docs/ai/evolution/runs/iteration-019-handoff-routing-audit/analysis/overview.md +167 -0
- package/opencode/docs/ai/evolution/runs/iteration-019-handoff-routing-audit/evaluation.md +163 -0
- package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/analysis/overview.md +42 -0
- package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/change_evaluation.json +46 -0
- package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/change_manifest.json +57 -0
- package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/evaluation.md +48 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/analysis/detail/contract-vs-runtime-gap.md +163 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/analysis/detail/evidence-collection-blocker.md +134 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/analysis/overview.md +111 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/change_evaluation.json +52 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/change_manifest.json +50 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/evaluation.md +46 -0
- package/opencode/docs/ai/evolution/runs/iteration-021/manifest-justification.md +48 -0
- package/opencode/docs/ai/evolution/session-sources.md +91 -0
- package/opencode/docs/ai/harness/README.md +32 -0
- package/opencode/docs/ai/harness/agents.md +148 -0
- package/opencode/docs/ai/harness/checks.md +119 -0
- package/opencode/docs/ai/harness/commands.md +391 -0
- package/opencode/docs/ai/harness/evidence.md +85 -0
- package/opencode/docs/ai/harness/init-detection-rules.md +160 -0
- package/opencode/docs/ai/harness/orchestrated-review.md +131 -0
- package/opencode/docs/ai/harness/skill-metadata-schema.md +198 -0
- package/opencode/docs/ai/harness/skill-resolution.md +202 -0
- package/opencode/docs/ai/harness/skill_registry.json +443 -0
- package/opencode/docs/ai/harness/skill_registry.md +43 -0
- package/opencode/docs/ai/project-context-template.md +53 -0
- package/opencode/opencode.json +38 -0
- package/opencode/package-lock.json +1717 -0
- package/opencode/package.json +11 -0
- package/opencode/plugins/token-tree-usage.tsx +206 -0
- package/opencode/references/performance-checklist.md +153 -0
- package/opencode/references/security-checklist.md +134 -0
- package/opencode/references/testing-patterns.md +236 -0
- package/opencode/scripts/check-harness.mjs +1572 -0
- package/opencode/scripts/check-harness.test.mjs +820 -0
- package/opencode/scripts/collect-session-evidence.mjs +612 -0
- package/opencode/scripts/collect-session-evidence.test.mjs +443 -0
- package/opencode/scripts/preflight-audit.mjs +497 -0
- package/opencode/scripts/preflight-audit.test.mjs +363 -0
- package/opencode/scripts/project-capability-snapshot.mjs +407 -0
- package/opencode/scripts/project-capability-snapshot.test.mjs +382 -0
- package/opencode/scripts/review-orchestrated-prepare.mjs +547 -0
- package/opencode/scripts/review-orchestrated-prepare.test.mjs +516 -0
- package/opencode/scripts/skill-resolver.mjs +585 -0
- package/opencode/scripts/skill-resolver.test.mjs +781 -0
- package/opencode/scripts/update-skill-registry.mjs +380 -0
- package/opencode/skills/api-and-interface-design/SKILL.md +315 -0
- package/opencode/skills/autonomous-loops/SKILL.md +312 -0
- package/opencode/skills/code-review-and-quality/SKILL.md +365 -0
- package/opencode/skills/code-simplification/SKILL.md +345 -0
- package/opencode/skills/context-engineering/SKILL.md +252 -0
- package/opencode/skills/debugging-and-error-recovery/SKILL.md +316 -0
- package/opencode/skills/documentation-and-adrs/SKILL.md +298 -0
- package/opencode/skills/doubt-driven-development/SKILL.md +168 -0
- package/opencode/skills/iterative-retrieval/SKILL.md +232 -0
- package/opencode/skills/open-design/SKILL.md +123 -0
- package/opencode/skills/performance-optimization/SKILL.md +365 -0
- package/opencode/skills/security-and-hardening/SKILL.md +369 -0
- package/opencode/skills/source-driven-development/SKILL.md +210 -0
- package/opencode/skills/test-driven-development/SKILL.md +406 -0
- package/opencode/skills/using-agent-skills/SKILL.md +194 -0
- package/opencode/skills/verification-loop/SKILL.md +162 -0
- package/opencode/tools/open_design.ts +361 -0
- package/opencode/tui.json +5 -0
- package/package.json +20 -0
- package/rollback.sh +5 -0
- package/scripts/check.sh +184 -0
- package/scripts/install-smoke.sh +111 -0
- package/scripts/manage-installation.mjs +1498 -0
- package/scripts/manage-installation.test.mjs +1936 -0
- package/scripts/version.mjs +197 -0
- package/scripts/version.test.mjs +195 -0
- package/uninstall.sh +5 -0
- package/upgrade.sh +5 -0
|
@@ -0,0 +1,516 @@
|
|
|
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 { execFileSync } from "node:child_process";
|
|
6
|
+
import test from "node:test";
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
DEFAULT_BUDGETS,
|
|
10
|
+
buildExecutionPlan,
|
|
11
|
+
cleanupWorkspace,
|
|
12
|
+
parseArgs,
|
|
13
|
+
prepareReviewWorkspace,
|
|
14
|
+
recordReviewerResult,
|
|
15
|
+
} from "./review-orchestrated-prepare.mjs";
|
|
16
|
+
|
|
17
|
+
function run(cwd, command, args) {
|
|
18
|
+
return execFileSync(command, args, { cwd, encoding: "utf8" });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function makeRepo() {
|
|
22
|
+
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), "review-orchestrated-fixture-"));
|
|
23
|
+
run(cwd, "git", ["init"]);
|
|
24
|
+
run(cwd, "git", ["config", "user.email", "review@example.test"]);
|
|
25
|
+
run(cwd, "git", ["config", "user.name", "Review Test"]);
|
|
26
|
+
fs.writeFileSync(path.join(cwd, "README.md"), "# Fixture\n");
|
|
27
|
+
run(cwd, "git", ["add", "README.md"]);
|
|
28
|
+
run(cwd, "git", ["commit", "-m", "initial"]);
|
|
29
|
+
return cwd;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function writeFile(cwd, rel, content) {
|
|
33
|
+
const full = path.join(cwd, rel);
|
|
34
|
+
fs.mkdirSync(path.dirname(full), { recursive: true });
|
|
35
|
+
fs.writeFileSync(full, content);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function prepare(cwd, extra = {}) {
|
|
39
|
+
return prepareReviewWorkspace({
|
|
40
|
+
base: "HEAD",
|
|
41
|
+
staged: false,
|
|
42
|
+
includeUntracked: false,
|
|
43
|
+
dryRun: false,
|
|
44
|
+
retain: true,
|
|
45
|
+
workspace: fs.mkdtempSync(path.join(os.tmpdir(), "review-workspace-")),
|
|
46
|
+
cwd,
|
|
47
|
+
budgets: { ...DEFAULT_BUDGETS },
|
|
48
|
+
...extra,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function prepareDefaultWorkspace(cwd, extra = {}) {
|
|
53
|
+
return prepareReviewWorkspace({
|
|
54
|
+
base: "HEAD",
|
|
55
|
+
staged: false,
|
|
56
|
+
includeUntracked: false,
|
|
57
|
+
dryRun: false,
|
|
58
|
+
retain: true,
|
|
59
|
+
cwd,
|
|
60
|
+
budgets: { ...DEFAULT_BUDGETS },
|
|
61
|
+
...extra,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
test("doc-only changes are skipped without launching reviewers", () => {
|
|
66
|
+
const cwd = makeRepo();
|
|
67
|
+
try {
|
|
68
|
+
fs.appendFileSync(path.join(cwd, "README.md"), "\nMore docs.\n");
|
|
69
|
+
const manifest = prepare(cwd);
|
|
70
|
+
|
|
71
|
+
assert.equal(manifest.classification, "skipped");
|
|
72
|
+
assert.deepEqual(manifest.selected_reviewers, []);
|
|
73
|
+
assert.match(manifest.skipped_reason, /No review agents launched/);
|
|
74
|
+
assert.ok(fs.existsSync(path.join(manifest.workspace, "manifest.json")));
|
|
75
|
+
} finally {
|
|
76
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test("normal implementation change selects quality reviewer", () => {
|
|
81
|
+
const cwd = makeRepo();
|
|
82
|
+
try {
|
|
83
|
+
writeFile(cwd, "src/app.js", "export function value() { return 1 }\n");
|
|
84
|
+
run(cwd, "git", ["add", "src/app.js"]);
|
|
85
|
+
run(cwd, "git", ["commit", "-m", "add app"]);
|
|
86
|
+
writeFile(cwd, "src/app.js", "export function value() { return 2 }\n");
|
|
87
|
+
|
|
88
|
+
const manifest = prepare(cwd);
|
|
89
|
+
|
|
90
|
+
assert.equal(manifest.classification, "trivial");
|
|
91
|
+
assert.deepEqual(manifest.selected_reviewers, ["review_quality"]);
|
|
92
|
+
assert.equal(manifest.patches.length, 1);
|
|
93
|
+
const patch = fs.readFileSync(path.join(manifest.workspace, manifest.patches[0].path), "utf8");
|
|
94
|
+
assert.match(patch, /BEGIN_UNTRUSTED_PATCH_DATA/);
|
|
95
|
+
assert.match(patch, /END_UNTRUSTED_PATCH_DATA/);
|
|
96
|
+
} finally {
|
|
97
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test("security and api paths select specialized reviewers", () => {
|
|
102
|
+
const cwd = makeRepo();
|
|
103
|
+
try {
|
|
104
|
+
writeFile(cwd, "src/auth/session.js", "export const token = 'old'\n");
|
|
105
|
+
writeFile(cwd, "src/api/schema.graphql", "type Query { old: String }\n");
|
|
106
|
+
run(cwd, "git", ["add", "."]);
|
|
107
|
+
run(cwd, "git", ["commit", "-m", "add sensitive files"]);
|
|
108
|
+
writeFile(cwd, "src/auth/session.js", "export const token = process.env.TOKEN\n");
|
|
109
|
+
writeFile(cwd, "src/api/schema.graphql", "type Query { old: String, next: String }\n");
|
|
110
|
+
|
|
111
|
+
const manifest = prepare(cwd, {
|
|
112
|
+
budgets: {
|
|
113
|
+
...DEFAULT_BUDGETS,
|
|
114
|
+
max_reviewers: 4,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
assert.equal(manifest.classification, "full");
|
|
119
|
+
assert.ok(manifest.risk_flags.includes("security"));
|
|
120
|
+
assert.ok(manifest.risk_flags.includes("api"));
|
|
121
|
+
assert.ok(manifest.selected_reviewers.includes("review_security"));
|
|
122
|
+
assert.ok(manifest.selected_reviewers.includes("review_api"));
|
|
123
|
+
} finally {
|
|
124
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test("tests-only risk stays lite and does not select api reviewer", () => {
|
|
129
|
+
const cwd = makeRepo();
|
|
130
|
+
try {
|
|
131
|
+
writeFile(cwd, "scripts/check-harness.test.mjs", "test('old', () => {})\n");
|
|
132
|
+
writeFile(cwd, "src/tool.mjs", "export const value = 1\n");
|
|
133
|
+
run(cwd, "git", ["add", "."]);
|
|
134
|
+
run(cwd, "git", ["commit", "-m", "add tests"]);
|
|
135
|
+
writeFile(cwd, "scripts/check-harness.test.mjs", "test('new', () => {})\n");
|
|
136
|
+
writeFile(cwd, "src/tool.mjs", "export const value = 2\n");
|
|
137
|
+
|
|
138
|
+
const manifest = prepare(cwd);
|
|
139
|
+
|
|
140
|
+
assert.equal(manifest.classification, "lite");
|
|
141
|
+
assert.deepEqual(manifest.selected_reviewers, ["review_quality", "review_tests"]);
|
|
142
|
+
assert.deepEqual(manifest.recommended_reviewers, ["review_quality", "review_tests"]);
|
|
143
|
+
assert.equal(manifest.execution_plan.mode, "preflight");
|
|
144
|
+
assert.equal(manifest.execution_plan.ai_review, "not_run");
|
|
145
|
+
assert.deepEqual(manifest.execution_plan.planned_reviewers, []);
|
|
146
|
+
assert.ok(manifest.omitted_reviewers.includes("review_api"));
|
|
147
|
+
assert.deepEqual(
|
|
148
|
+
manifest.reviewer_patch_sets.review_tests.patches.map((patch) => patch.file),
|
|
149
|
+
["scripts/check-harness.test.mjs"],
|
|
150
|
+
);
|
|
151
|
+
assert.deepEqual(
|
|
152
|
+
manifest.reviewer_patch_sets.review_quality.patches.map((patch) => patch.file),
|
|
153
|
+
["scripts/check-harness.test.mjs", "src/tool.mjs"],
|
|
154
|
+
);
|
|
155
|
+
} finally {
|
|
156
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test("dry-run is a preflight-compatible alias without reviewer execution", () => {
|
|
161
|
+
const options = parseArgs(["--dry-run", "--retain", "--reviewer-timeout-ms", "5000"]);
|
|
162
|
+
assert.equal(options.dryRun, true);
|
|
163
|
+
assert.equal(options.agents, false);
|
|
164
|
+
assert.equal(options.fullAgents, false);
|
|
165
|
+
assert.equal(options.budgets.reviewer_timeout_ms, 5000);
|
|
166
|
+
|
|
167
|
+
const plan = buildExecutionPlan("lite", ["review_quality", "review_tests"], options);
|
|
168
|
+
assert.equal(plan.mode, "preflight");
|
|
169
|
+
assert.equal(plan.dry_run_alias, true);
|
|
170
|
+
assert.equal(plan.ai_review, "not_run");
|
|
171
|
+
assert.deepEqual(plan.planned_reviewers, []);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test("combined command arguments are parsed without a retry", () => {
|
|
175
|
+
const options = parseArgs(["--agents --retain"]);
|
|
176
|
+
|
|
177
|
+
assert.equal(options.agents, true);
|
|
178
|
+
assert.equal(options.retain, true);
|
|
179
|
+
assert.equal(options.fullAgents, false);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
test("--agents mode plans at most one focused reviewer for lite changes", () => {
|
|
183
|
+
const cwd = makeRepo();
|
|
184
|
+
try {
|
|
185
|
+
writeFile(cwd, "scripts/check-harness.test.mjs", "test('old', () => {})\n");
|
|
186
|
+
writeFile(cwd, "src/tool.mjs", "export const value = 1\n");
|
|
187
|
+
run(cwd, "git", ["add", "."]);
|
|
188
|
+
run(cwd, "git", ["commit", "-m", "add tests"]);
|
|
189
|
+
writeFile(cwd, "scripts/check-harness.test.mjs", "test('new', () => {})\n");
|
|
190
|
+
writeFile(cwd, "src/tool.mjs", "export const value = 2\n");
|
|
191
|
+
|
|
192
|
+
const manifest = prepare(cwd, { agents: true });
|
|
193
|
+
|
|
194
|
+
assert.equal(manifest.classification, "lite");
|
|
195
|
+
assert.equal(manifest.execution_plan.mode, "agents");
|
|
196
|
+
assert.equal(manifest.execution_plan.ai_review, "coordinator_focused");
|
|
197
|
+
assert.deepEqual(manifest.execution_plan.planned_reviewers, ["review_tests"]);
|
|
198
|
+
assert.equal(manifest.execution_plan.max_reviewers_to_execute, 1);
|
|
199
|
+
} finally {
|
|
200
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test("small api-only changes stay lite and plan one api reviewer", () => {
|
|
205
|
+
const cwd = makeRepo();
|
|
206
|
+
try {
|
|
207
|
+
writeFile(cwd, "src/api/users.js", "export function parseLimit(value) { return Number(value); }\n");
|
|
208
|
+
run(cwd, "git", ["add", "."]);
|
|
209
|
+
run(cwd, "git", ["commit", "-m", "add public api"]);
|
|
210
|
+
writeFile(
|
|
211
|
+
cwd,
|
|
212
|
+
"src/api/users.js",
|
|
213
|
+
"export function parseLimit(value) {\n const parsed = Number(value);\n if (!Number.isInteger(parsed) || parsed < 1 || parsed > 100) throw new RangeError('limit');\n return parsed;\n}\n",
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
const manifest = prepare(cwd, { agents: true });
|
|
217
|
+
|
|
218
|
+
assert.equal(manifest.classification, "lite");
|
|
219
|
+
assert.deepEqual(manifest.risk_flags, ["api"]);
|
|
220
|
+
assert.deepEqual(manifest.execution_plan.planned_reviewers, ["review_api"]);
|
|
221
|
+
assert.equal(manifest.execution_plan.max_reviewers_to_execute, 1);
|
|
222
|
+
} finally {
|
|
223
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
test("auth permission changes plan the security reviewer", () => {
|
|
228
|
+
const cwd = makeRepo();
|
|
229
|
+
try {
|
|
230
|
+
writeFile(cwd, "src/auth/permissions.js", "export const canDelete = role => role === 'admin'\n");
|
|
231
|
+
run(cwd, "git", ["add", "."]);
|
|
232
|
+
run(cwd, "git", ["commit", "-m", "add permissions"]);
|
|
233
|
+
writeFile(cwd, "src/auth/permissions.js", "export const canDelete = role => role === 'admin' || role === 'member'\n");
|
|
234
|
+
|
|
235
|
+
const manifest = prepare(cwd, { agents: true });
|
|
236
|
+
|
|
237
|
+
assert.equal(manifest.classification, "full");
|
|
238
|
+
assert.ok(manifest.risk_flags.includes("permissions"));
|
|
239
|
+
assert.deepEqual(manifest.execution_plan.planned_reviewers, ["review_security"]);
|
|
240
|
+
} finally {
|
|
241
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
test("dependency manifests select security while lockfiles stay filtered", () => {
|
|
246
|
+
const cwd = makeRepo();
|
|
247
|
+
try {
|
|
248
|
+
writeFile(cwd, "package.json", '{"dependencies":{"example-lib":"1.0.0"}}\n');
|
|
249
|
+
writeFile(cwd, "package-lock.json", '{"lockfileVersion":3,"packages":{}}\n');
|
|
250
|
+
run(cwd, "git", ["add", "."]);
|
|
251
|
+
run(cwd, "git", ["commit", "-m", "add dependency"]);
|
|
252
|
+
writeFile(cwd, "package.json", '{"dependencies":{"example-lib":"2.0.0"}}\n');
|
|
253
|
+
writeFile(cwd, "package-lock.json", '{"lockfileVersion":3,"packages":{"node_modules/example-lib":{"version":"2.0.0"}}}\n');
|
|
254
|
+
|
|
255
|
+
const manifest = prepare(cwd, { agents: true });
|
|
256
|
+
|
|
257
|
+
assert.equal(manifest.classification, "full");
|
|
258
|
+
assert.ok(manifest.risk_flags.includes("deps"));
|
|
259
|
+
assert.ok(manifest.risk_flags.includes("lockfiles"));
|
|
260
|
+
assert.deepEqual(manifest.execution_plan.planned_reviewers, ["review_security"]);
|
|
261
|
+
assert.deepEqual(manifest.filtered_files, ["package-lock.json"]);
|
|
262
|
+
assert.deepEqual(manifest.patches.map((patch) => patch.file), ["package.json"]);
|
|
263
|
+
} finally {
|
|
264
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
test("deleted regression tests plan the tests reviewer", () => {
|
|
269
|
+
const cwd = makeRepo();
|
|
270
|
+
try {
|
|
271
|
+
writeFile(cwd, "src/discount.js", "export const discount = value => value\n");
|
|
272
|
+
writeFile(cwd, "test/discount.test.js", "test('discount', () => {})\n");
|
|
273
|
+
run(cwd, "git", ["add", "."]);
|
|
274
|
+
run(cwd, "git", ["commit", "-m", "add discount tests"]);
|
|
275
|
+
writeFile(cwd, "src/discount.js", "export const discount = value => Math.max(value, 0)\n");
|
|
276
|
+
fs.rmSync(path.join(cwd, "test/discount.test.js"));
|
|
277
|
+
|
|
278
|
+
const manifest = prepare(cwd, { agents: true });
|
|
279
|
+
|
|
280
|
+
assert.equal(manifest.classification, "lite");
|
|
281
|
+
assert.ok(manifest.risk_flags.includes("tests"));
|
|
282
|
+
assert.deepEqual(manifest.execution_plan.planned_reviewers, ["review_tests"]);
|
|
283
|
+
} finally {
|
|
284
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
test("--full-agents mode caps planned specialized reviewers at four", () => {
|
|
289
|
+
const options = parseArgs(["--full-agents", "--max-reviewers", "9"]);
|
|
290
|
+
const plan = buildExecutionPlan("full", ["review_quality", "review_security", "review_tests", "review_api", "extra"], options);
|
|
291
|
+
|
|
292
|
+
assert.equal(plan.mode, "full-agents");
|
|
293
|
+
assert.equal(plan.ai_review, "experimental_specialized_agents");
|
|
294
|
+
assert.deepEqual(plan.planned_reviewers, ["review_quality", "review_security", "review_tests", "review_api"]);
|
|
295
|
+
assert.equal(plan.max_reviewers_to_execute, 4);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
test("reviewer timeout and failure statuses are recorded as partial results", () => {
|
|
299
|
+
const manifest = {
|
|
300
|
+
failed_reviewers: [],
|
|
301
|
+
timed_out_reviewers: [],
|
|
302
|
+
execution_plan: {
|
|
303
|
+
reviewer_results: {},
|
|
304
|
+
},
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
const timedOut = recordReviewerResult(manifest, "review_tests", "timed_out", { elapsed_ms: 90001 });
|
|
308
|
+
assert.deepEqual(timedOut.timed_out_reviewers, ["review_tests"]);
|
|
309
|
+
assert.equal(timedOut.execution_plan.reviewer_results.review_tests.status, "timed_out");
|
|
310
|
+
|
|
311
|
+
const failed = recordReviewerResult(timedOut, "review_security", "failed", { error: "no findings written" });
|
|
312
|
+
assert.deepEqual(failed.failed_reviewers, ["review_security"]);
|
|
313
|
+
assert.equal(failed.execution_plan.reviewer_results.review_security.error, "no findings written");
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
test("moderate multi-file review stays lite without high risk flags", () => {
|
|
317
|
+
const cwd = makeRepo();
|
|
318
|
+
try {
|
|
319
|
+
for (let index = 0; index < 14; index++) {
|
|
320
|
+
writeFile(cwd, `src/file-${index}.mjs`, `export const value${index} = 1\n`);
|
|
321
|
+
}
|
|
322
|
+
writeFile(cwd, "scripts/check-harness.test.mjs", "test('old', () => {})\n");
|
|
323
|
+
run(cwd, "git", ["add", "."]);
|
|
324
|
+
run(cwd, "git", ["commit", "-m", "add files"]);
|
|
325
|
+
for (let index = 0; index < 14; index++) {
|
|
326
|
+
writeFile(cwd, `src/file-${index}.mjs`, `export const value${index} = 2\n`);
|
|
327
|
+
}
|
|
328
|
+
writeFile(cwd, "scripts/check-harness.test.mjs", "test('new', () => {})\n");
|
|
329
|
+
|
|
330
|
+
const manifest = prepare(cwd);
|
|
331
|
+
|
|
332
|
+
assert.equal(manifest.classification, "lite");
|
|
333
|
+
assert.deepEqual(manifest.selected_reviewers, ["review_quality", "review_tests"]);
|
|
334
|
+
} finally {
|
|
335
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
test("lockfiles and generated files are filtered but kept as risk signals", () => {
|
|
340
|
+
const cwd = makeRepo();
|
|
341
|
+
try {
|
|
342
|
+
writeFile(cwd, "package-lock.json", "{\"lockfileVersion\":1}\n");
|
|
343
|
+
writeFile(cwd, "src/generated/client.generated.ts", "export const x = 1\n");
|
|
344
|
+
run(cwd, "git", ["add", "."]);
|
|
345
|
+
run(cwd, "git", ["commit", "-m", "add generated"]);
|
|
346
|
+
writeFile(cwd, "package-lock.json", "{\"lockfileVersion\":2}\n");
|
|
347
|
+
writeFile(cwd, "src/generated/client.generated.ts", "export const x = 2\n");
|
|
348
|
+
|
|
349
|
+
const manifest = prepare(cwd);
|
|
350
|
+
|
|
351
|
+
assert.equal(manifest.classification, "full");
|
|
352
|
+
assert.deepEqual(manifest.patches, []);
|
|
353
|
+
assert.ok(manifest.filtered_files.includes("package-lock.json"));
|
|
354
|
+
assert.ok(manifest.filtered_files.includes("src/generated/client.generated.ts"));
|
|
355
|
+
assert.ok(manifest.risk_flags.includes("lockfiles"));
|
|
356
|
+
assert.ok(manifest.risk_flags.includes("generated"));
|
|
357
|
+
} finally {
|
|
358
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
test("database migrations are not automatically filtered", () => {
|
|
363
|
+
const cwd = makeRepo();
|
|
364
|
+
try {
|
|
365
|
+
writeFile(cwd, "db/migrations/001_init.sql", "select 1;\n");
|
|
366
|
+
run(cwd, "git", ["add", "."]);
|
|
367
|
+
run(cwd, "git", ["commit", "-m", "add migration"]);
|
|
368
|
+
writeFile(cwd, "db/migrations/001_init.sql", "select 2;\n");
|
|
369
|
+
|
|
370
|
+
const manifest = prepare(cwd);
|
|
371
|
+
|
|
372
|
+
assert.ok(manifest.risk_flags.includes("migrations"));
|
|
373
|
+
assert.equal(manifest.filtered_files.includes("db/migrations/001_init.sql"), false);
|
|
374
|
+
assert.equal(manifest.patches.length, 1);
|
|
375
|
+
} finally {
|
|
376
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
test("untracked files are listed but not reviewed by default", () => {
|
|
381
|
+
const cwd = makeRepo();
|
|
382
|
+
try {
|
|
383
|
+
writeFile(cwd, "src/new.js", "export const created = true\n");
|
|
384
|
+
const manifest = prepare(cwd);
|
|
385
|
+
|
|
386
|
+
assert.deepEqual(manifest.diff_scope.untracked_files, ["src/new.js"]);
|
|
387
|
+
assert.equal(manifest.diff_scope.untracked_reviewed, false);
|
|
388
|
+
assert.equal(manifest.changed_files.length, 0);
|
|
389
|
+
assert.equal(manifest.classification, "skipped");
|
|
390
|
+
} finally {
|
|
391
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
test("include-untracked adds untracked files to review patches", () => {
|
|
396
|
+
const cwd = makeRepo();
|
|
397
|
+
try {
|
|
398
|
+
writeFile(cwd, "src/new.js", "export const created = true\n");
|
|
399
|
+
const manifest = prepare(cwd, { includeUntracked: true });
|
|
400
|
+
|
|
401
|
+
assert.equal(manifest.diff_scope.untracked_reviewed, true);
|
|
402
|
+
assert.equal(manifest.changed_files[0].path, "src/new.js");
|
|
403
|
+
assert.equal(manifest.patches.length, 1);
|
|
404
|
+
} finally {
|
|
405
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
test("retained review workspaces are filtered when untracked are included", () => {
|
|
410
|
+
const cwd = makeRepo();
|
|
411
|
+
try {
|
|
412
|
+
for (let index = 0; index < 25; index++) {
|
|
413
|
+
writeFile(cwd, `.opencode-review-/run-old/artifact-${index}.json`, "{}\n");
|
|
414
|
+
}
|
|
415
|
+
writeFile(cwd, ".opencode-review-/run-old/manifest.json", "{}\n");
|
|
416
|
+
writeFile(cwd, "src/new.js", "export const created = true\n");
|
|
417
|
+
const manifest = prepare(cwd, { includeUntracked: true });
|
|
418
|
+
|
|
419
|
+
assert.ok(manifest.filtered_files.includes(".opencode-review-/run-old/manifest.json"));
|
|
420
|
+
assert.ok(manifest.generated_files.includes(".opencode-review-/run-old/manifest.json"));
|
|
421
|
+
assert.deepEqual(manifest.patches.map((patch) => patch.file), ["src/new.js"]);
|
|
422
|
+
assert.equal(manifest.classification, "lite");
|
|
423
|
+
} finally {
|
|
424
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
test("budget overflow is recorded in the manifest", () => {
|
|
429
|
+
const cwd = makeRepo();
|
|
430
|
+
try {
|
|
431
|
+
writeFile(cwd, "src/large.js", "export const value = 1\n");
|
|
432
|
+
run(cwd, "git", ["add", "."]);
|
|
433
|
+
run(cwd, "git", ["commit", "-m", "add large"]);
|
|
434
|
+
writeFile(cwd, "src/large.js", `export const value = \`${"x".repeat(2000)}\`\n`);
|
|
435
|
+
|
|
436
|
+
const manifest = prepare(cwd, {
|
|
437
|
+
budgets: {
|
|
438
|
+
max_reviewers: 3,
|
|
439
|
+
max_patch_bytes_per_reviewer: 500,
|
|
440
|
+
max_total_patch_bytes: 500,
|
|
441
|
+
},
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
assert.equal(manifest.budgets.budget_exceeded, true);
|
|
445
|
+
assert.equal(manifest.patches.length, 0);
|
|
446
|
+
assert.equal(manifest.dropped_patches.length, 1);
|
|
447
|
+
assert.ok(manifest.budgets.written_patch_bytes <= manifest.budgets.max_total_patch_bytes);
|
|
448
|
+
assert.match(manifest.budgets.exceeded_behavior, /manual review/);
|
|
449
|
+
} finally {
|
|
450
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
test("per-reviewer patch budget records omitted reviewer patches", () => {
|
|
455
|
+
const cwd = makeRepo();
|
|
456
|
+
try {
|
|
457
|
+
writeFile(cwd, "scripts/check-harness.test.mjs", "test('old', () => {})\n");
|
|
458
|
+
run(cwd, "git", ["add", "."]);
|
|
459
|
+
run(cwd, "git", ["commit", "-m", "add tests"]);
|
|
460
|
+
writeFile(cwd, "scripts/check-harness.test.mjs", "test('new', () => {})\n");
|
|
461
|
+
|
|
462
|
+
const manifest = prepare(cwd, {
|
|
463
|
+
budgets: {
|
|
464
|
+
max_reviewers: 3,
|
|
465
|
+
max_patch_bytes_per_reviewer: 1,
|
|
466
|
+
max_total_patch_bytes: 50_000,
|
|
467
|
+
},
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
assert.equal(manifest.patches.length, 1);
|
|
471
|
+
assert.equal(manifest.reviewer_patch_sets.review_tests.patches.length, 0);
|
|
472
|
+
assert.equal(manifest.reviewer_patch_sets.review_tests.omitted_patches.length, 1);
|
|
473
|
+
assert.equal(manifest.reviewer_patch_sets.review_tests.omitted_patches[0].reason, "max_patch_bytes_per_reviewer");
|
|
474
|
+
} finally {
|
|
475
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
test("parseArgs rejects invalid invocation shapes", () => {
|
|
480
|
+
assert.throws(() => parseArgs(["--unknown"]), /Unknown argument/);
|
|
481
|
+
assert.throws(() => parseArgs(["--base"]), /--base requires a value/);
|
|
482
|
+
assert.throws(() => parseArgs(["--max-reviewers", "0"]), /max_reviewers must be a positive number/);
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
test("cleanup removes workspace unless retained", () => {
|
|
486
|
+
const cwd = makeRepo();
|
|
487
|
+
try {
|
|
488
|
+
fs.appendFileSync(path.join(cwd, "README.md"), "\nMore docs.\n");
|
|
489
|
+
const cleanupManifest = prepare(cwd, { retain: false });
|
|
490
|
+
assert.equal(cleanupManifest.workspace_retention, "cleanup");
|
|
491
|
+
cleanupWorkspace(cleanupManifest);
|
|
492
|
+
assert.equal(fs.existsSync(cleanupManifest.workspace), false);
|
|
493
|
+
|
|
494
|
+
const retainedManifest = prepare(cwd, { retain: true });
|
|
495
|
+
assert.equal(retainedManifest.workspace_retention, "retain");
|
|
496
|
+
cleanupWorkspace(retainedManifest);
|
|
497
|
+
assert.equal(fs.existsSync(retainedManifest.workspace), true);
|
|
498
|
+
fs.rmSync(retainedManifest.workspace, { recursive: true, force: true });
|
|
499
|
+
} finally {
|
|
500
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
test("default workspace is created inside the repo", () => {
|
|
505
|
+
const cwd = makeRepo();
|
|
506
|
+
try {
|
|
507
|
+
fs.appendFileSync(path.join(cwd, "README.md"), "\nMore docs.\n");
|
|
508
|
+
const manifest = prepareDefaultWorkspace(cwd);
|
|
509
|
+
|
|
510
|
+
assert.ok(manifest.workspace.startsWith(path.join(cwd, ".opencode-review-")));
|
|
511
|
+
assert.ok(fs.existsSync(path.join(manifest.workspace, "manifest.json")));
|
|
512
|
+
fs.rmSync(manifest.workspace, { recursive: true, force: true });
|
|
513
|
+
} finally {
|
|
514
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
515
|
+
}
|
|
516
|
+
});
|