mirror of
https://github.com/garrytan/gstack.git
synced 2026-06-18 07:40:09 +02:00
0ecb8c9cd7
The cso carve moved Secrets Archaeology (prefixes, lib/redact-patterns.ts pointer, git-history scan) into sections/audit-phases.md, and the document-release carve moved the Step 9 PR-body redaction scan into sections/release-body.md. Three content-presence tests asserted that content in the skeleton SKILL.md/.md.tmpl; they now read the skeleton+sections union (same fix as cso-preserved + parity). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
52 lines
2.0 KiB
TypeScript
52 lines
2.0 KiB
TypeScript
/**
|
|
* /document-release + /document-generate redaction wiring (T6/T7).
|
|
*/
|
|
import { describe, test, expect } from "bun:test";
|
|
import * as fs from "fs";
|
|
import * as path from "path";
|
|
|
|
const ROOT = path.resolve(import.meta.dir, "..");
|
|
// document-release is carved (skeleton + sections/release-body.md). Step 9
|
|
// (commit + PR-body redaction scan) moved into the section template; check the
|
|
// union of SKILL.md.tmpl + sections/*.md.tmpl so the scan-before-edit ordering
|
|
// still verifies. document-generate is NOT carved (plain .md.tmpl).
|
|
function unionTmpl(skill: string): string {
|
|
let t = fs.readFileSync(path.join(ROOT, skill, "SKILL.md.tmpl"), "utf-8");
|
|
const dir = path.join(ROOT, skill, "sections");
|
|
if (fs.existsSync(dir)) {
|
|
for (const f of fs.readdirSync(dir).sort()) {
|
|
if (f.endsWith(".md.tmpl")) t += "\n" + fs.readFileSync(path.join(dir, f), "utf-8");
|
|
}
|
|
}
|
|
return t;
|
|
}
|
|
const RELEASE = unionTmpl("document-release");
|
|
const GENERATE = fs.readFileSync(path.join(ROOT, "document-generate", "SKILL.md.tmpl"), "utf-8");
|
|
|
|
describe("/document-release redaction", () => {
|
|
test("scans the PR-body temp file before gh pr edit", () => {
|
|
const scanIdx = RELEASE.indexOf("gstack-redact --from-file /tmp/gstack-pr-body");
|
|
const editIdx = RELEASE.indexOf("gh pr edit --body-file /tmp/gstack-pr-body");
|
|
expect(scanIdx).toBeGreaterThan(-1);
|
|
expect(editIdx).toBeGreaterThan(scanIdx);
|
|
});
|
|
test("HIGH blocks the edit", () => {
|
|
expect(RELEASE).toMatch(/exit 3 \(HIGH\).*do NOT edit/i);
|
|
});
|
|
});
|
|
|
|
describe("/document-generate redaction", () => {
|
|
test("scans staged doc diff before commit", () => {
|
|
const scanIdx = GENERATE.indexOf("gstack-redact --repo-visibility");
|
|
const commitIdx = GENERATE.indexOf("git commit -m");
|
|
expect(scanIdx).toBeGreaterThan(-1);
|
|
expect(commitIdx).toBeGreaterThan(scanIdx);
|
|
});
|
|
test("scans added lines of the staged diff", () => {
|
|
expect(GENERATE).toMatch(/git diff --cached[\s\S]{0,80}gstack-redact/);
|
|
});
|
|
test("HIGH blocks the commit", () => {
|
|
expect(GENERATE).toMatch(/Do NOT commit/i);
|
|
});
|
|
});
|