feat(scripts): add --staged-against flag to library-decisions check
Adds `--staged-against <base>` CLI flag to `check.mjs` so the reviewer agent can compare `git diff <base>...HEAD` instead of the git index. This gives the sandcastle reviewer a CI-compatible code path that works in its clean sandbox where `git diff --cached` may be empty. Appends a "Library-trace check" section to `.sandcastle/reviewer.prompt.md` instructing the reviewer to run the command before issuing a verdict. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -163,4 +163,21 @@ describe("checkLibraryDecisions", () => {
|
||||
|
||||
assert.deepEqual(checkLibraryDecisions(dir), []);
|
||||
});
|
||||
|
||||
test("--staged-against mode: new feature-tier dep without trace → exit 1", () => {
|
||||
const { dir, g } = makeRepo();
|
||||
// Baseline commit: feature package with no deps
|
||||
commitPkg(dir, g, "packages/feat-a", { dependencies: {} });
|
||||
// Second commit: adds new-lib — no trace file committed alongside it
|
||||
commitPkg(dir, g, "packages/feat-a", {
|
||||
dependencies: { "new-lib": "^1.0.0" },
|
||||
});
|
||||
|
||||
// HEAD has new-lib; HEAD~1 doesn't — no trace in the diff → exit 1
|
||||
const errs = checkLibraryDecisions(dir, { stagedAgainst: "HEAD~1" });
|
||||
|
||||
assert.equal(errs.length, 1);
|
||||
assert.equal(errs[0].dep, "new-lib");
|
||||
assert.equal(errs[0].reason, "no-trace");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user