@punks/cli 4.0.2 → 4.0.4
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/dist/BASELINE_CHANGELOG.md +29 -0
- package/dist/CHANGELOG.md +25 -0
- package/dist/baseline/scaffold-baseline/baseline.json +5 -5
- package/dist/baseline/scaffold-baseline/data/catalog/lint-assets.json +10 -4
- package/dist/baseline/scaffold-baseline/data/catalog/packs.json +0 -1
- package/dist/baseline/scaffold-baseline/data/catalog/skills.json +0 -8
- package/dist/baseline/scaffold-baseline/data/hooks/format-edited-file.mjs +602 -101
- package/dist/baseline/scaffold-baseline/data/scripts/commit-gate-runner.d.ts +11 -0
- package/dist/baseline/scaffold-baseline/data/scripts/commit-gate-runner.mjs +103 -0
- package/dist/baseline/scaffold-baseline/data/scripts/commit-gate-runner.test.ts +144 -0
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/adapters/claude.mjs +1 -0
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/adapters/codex.mjs +1 -0
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/adapters/cursor.mjs +1 -0
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/adapters/opencode.mjs +1 -0
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/contract.ts +24 -33
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/core.mjs +4 -0
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/core.test.ts +61 -0
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/lint-feedback.test.ts +123 -0
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/test-fixtures/claude/actions.json +1 -0
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/test-fixtures/codex/actions.json +2 -1
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/test-fixtures/cursor/projection.json +1 -0
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/test-fixtures/opencode/projection.json +1 -0
- package/dist/baseline/scaffold-baseline/data/scripts/sync-subagents-validator.test.ts +59 -0
- package/dist/baseline/scaffold-baseline/data/scripts/sync-subagents.d.mts +1 -0
- package/dist/baseline/scaffold-baseline/data/scripts/sync-subagents.mjs +27 -14
- package/dist/baseline/scaffold-baseline/skills/agnostic/docs/docs-onboarding/SKILL.md +2 -2
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-spec/SKILL.md +32 -32
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-spec/assets/SPEC-TEMPLATE.md +7 -7
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-spec/references/readiness.md +14 -13
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-spec/references/spec-quality-bar.md +26 -19
- package/dist/baseline/scaffold-baseline/skills/agnostic/quality/autoreview/SKILL.md +2 -2
- package/dist/baseline/scaffold-baseline/skills/agnostic/quality/autoreview/scripts/autoreview +3 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/brainstorm/SKILL.md +18 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/requirements-grill/SKILL.md +2 -1
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/EXAMPLES.md +9 -9
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/REFERENCE.md +43 -55
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/SKILL.md +68 -63
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/assets/concepts/backlog-model.md +26 -29
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/assets/concepts/story-shape.md +5 -5
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/assets/providers/azure-devops-create-payload.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/assets/providers/github-projects-create-payload.md +2 -2
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/assets/providers/linear-create-payload.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/assets/providers/monday-create-payload.md +2 -2
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/references/business-projection.md +19 -24
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/references/delivery-status.md +17 -13
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/references/fog-intake.md +45 -48
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/references/functional-projection.md +16 -21
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/references/normalization.md +14 -14
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/references/project-context.md +32 -27
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/references/providers/github.md +105 -150
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/references/providers/linear.md +111 -181
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/references/technical-projection.md +51 -47
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/scripts/validate-task-blocker-graph.mjs +49 -35
- package/dist/baseline/scaffold-baseline/skills/agnostic/security/security-best-practices/references/javascript-typescript-vue-web-frontend-security.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/frameworks/expo/eas-update-insights/references/update-insights-schema.md +2 -6
- package/dist/baseline/scaffold-baseline/skills/frameworks/expo/expo-skill-eval/SKILL.md +6 -7
- package/dist/baseline/scaffold-baseline/skills/frameworks/pulumi/pulumi-best-practices/SKILL.md +1 -3
- package/dist/baseline/scaffold-baseline/skills/frameworks/pulumi/pulumi-component/SKILL.md +2 -14
- package/dist/baseline/scaffold-baseline/skills/frameworks/tanstack-query/tanstack-query/references/best-practices.md +7 -1
- package/dist/baseline/scaffold-baseline/skills/frameworks/tanstack-query/tanstack-query/templates/devtools-setup.tsx +4 -0
- package/dist/baseline/scaffold-baseline/skills/frameworks/trpc/tanstack-query/references/best-practices.md +7 -1
- package/dist/baseline/scaffold-baseline/skills/frameworks/trpc/tanstack-query/templates/devtools-setup.tsx +4 -0
- package/dist/baseline/scaffold-baseline/skills/languages/typescript/quality-types/SKILL.md +1 -3
- package/dist/baseline/scaffold-baseline/skills/phases/business-finder/SKILL.md +29 -16
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/SKILL.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/router.md +10 -8
- package/dist/baseline/scaffold-baseline/skills/phases/design-phase/phases/backlog.md +26 -17
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/AUTHORING-HANDOFF.md +51 -261
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/SKILL.md +22 -25
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/ensure-fog.md +13 -23
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/grilling.md +40 -0
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/handback.md +11 -18
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/prototype.md +13 -21
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/reconcile.md +21 -35
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/research.md +13 -18
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/return-target.md +14 -25
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/router.md +22 -56
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/references/entrypoint-contract.md +25 -26
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/references/root-routing.md +12 -20
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/references/runtime-handoff.md +17 -39
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/references/state-graph.md +27 -49
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/scripts/finder-contract.mjs +40 -359
- package/dist/baseline/scaffold-baseline/skills/phases/functional-finder/SKILL.md +29 -62
- package/dist/baseline/scaffold-baseline/skills/phases/requirements-phase/SKILL.md +49 -13
- package/dist/baseline/scaffold-baseline.json +5 -5
- package/dist/baseline/scaffold-baseline.tgz +0 -0
- package/dist/data/hooks/format-edited-file.d.mts +21 -0
- package/dist/data/hooks/format-edited-file.mjs +588 -98
- package/dist/data/scripts/commit-gate-runner.mjs +103 -0
- package/dist/data/scripts/harness-projection/adapters/claude.mjs +1 -0
- package/dist/data/scripts/harness-projection/adapters/codex.mjs +1 -0
- package/dist/data/scripts/harness-projection/adapters/cursor.mjs +1 -0
- package/dist/data/scripts/harness-projection/adapters/opencode.mjs +1 -0
- package/dist/data/scripts/harness-projection/core.mjs +4 -0
- package/dist/data/scripts/harness-projection/test-fixtures/claude/actions.json +1 -0
- package/dist/data/scripts/harness-projection/test-fixtures/codex/actions.json +2 -1
- package/dist/data/scripts/harness-projection/test-fixtures/cursor/projection.json +1 -0
- package/dist/data/scripts/harness-projection/test-fixtures/opencode/projection.json +1 -0
- package/dist/data/scripts/sync-subagents.d.mts +1 -0
- package/dist/data/scripts/sync-subagents.mjs +30 -13
- package/dist/data/shared-agents.md +2 -60
- package/dist/index.js +73 -64
- package/dist/skills/agnostic/docs/docs-onboarding/SKILL.md +2 -2
- package/dist/skills/agnostic/planning/create-spec/SKILL.md +32 -32
- package/dist/skills/agnostic/planning/create-spec/assets/SPEC-TEMPLATE.md +7 -7
- package/dist/skills/agnostic/planning/create-spec/references/readiness.md +14 -13
- package/dist/skills/agnostic/planning/create-spec/references/spec-quality-bar.md +26 -19
- package/dist/skills/agnostic/quality/autoreview/SKILL.md +2 -2
- package/dist/skills/agnostic/quality/autoreview/scripts/autoreview +3 -0
- package/dist/skills/agnostic/requirements/brainstorm/SKILL.md +18 -0
- package/dist/skills/agnostic/requirements/requirements-grill/SKILL.md +2 -1
- package/dist/skills/agnostic/requirements/write-backlog/EXAMPLES.md +9 -9
- package/dist/skills/agnostic/requirements/write-backlog/REFERENCE.md +43 -55
- package/dist/skills/agnostic/requirements/write-backlog/SKILL.md +68 -63
- package/dist/skills/agnostic/requirements/write-backlog/assets/concepts/backlog-model.md +26 -29
- package/dist/skills/agnostic/requirements/write-backlog/assets/concepts/story-shape.md +5 -5
- package/dist/skills/agnostic/requirements/write-backlog/assets/providers/azure-devops-create-payload.md +1 -1
- package/dist/skills/agnostic/requirements/write-backlog/assets/providers/github-projects-create-payload.md +2 -2
- package/dist/skills/agnostic/requirements/write-backlog/assets/providers/linear-create-payload.md +1 -1
- package/dist/skills/agnostic/requirements/write-backlog/assets/providers/monday-create-payload.md +2 -2
- package/dist/skills/agnostic/requirements/write-backlog/references/business-projection.md +19 -24
- package/dist/skills/agnostic/requirements/write-backlog/references/delivery-status.md +17 -13
- package/dist/skills/agnostic/requirements/write-backlog/references/fog-intake.md +45 -48
- package/dist/skills/agnostic/requirements/write-backlog/references/functional-projection.md +16 -21
- package/dist/skills/agnostic/requirements/write-backlog/references/normalization.md +14 -14
- package/dist/skills/agnostic/requirements/write-backlog/references/project-context.md +32 -27
- package/dist/skills/agnostic/requirements/write-backlog/references/providers/github.md +97 -142
- package/dist/skills/agnostic/requirements/write-backlog/references/providers/linear.md +106 -176
- package/dist/skills/agnostic/requirements/write-backlog/references/technical-projection.md +51 -47
- package/dist/skills/agnostic/requirements/write-backlog/scripts/validate-task-blocker-graph.mjs +55 -31
- package/dist/skills/phases/business-finder/SKILL.md +29 -16
- package/dist/skills/phases/delivery-phase/SKILL.md +1 -1
- package/dist/skills/phases/delivery-phase/phases/router.md +10 -8
- package/dist/skills/phases/design-phase/phases/backlog.md +26 -17
- package/dist/skills/phases/finder-phase/AUTHORING-HANDOFF.md +51 -261
- package/dist/skills/phases/finder-phase/SKILL.md +22 -25
- package/dist/skills/phases/finder-phase/phases/ensure-fog.md +13 -23
- package/dist/skills/phases/finder-phase/phases/grilling.md +40 -0
- package/dist/skills/phases/finder-phase/phases/handback.md +11 -18
- package/dist/skills/phases/finder-phase/phases/prototype.md +13 -21
- package/dist/skills/phases/finder-phase/phases/reconcile.md +21 -35
- package/dist/skills/phases/finder-phase/phases/research.md +13 -18
- package/dist/skills/phases/finder-phase/phases/return-target.md +14 -25
- package/dist/skills/phases/finder-phase/phases/router.md +22 -56
- package/dist/skills/phases/finder-phase/references/entrypoint-contract.md +25 -26
- package/dist/skills/phases/finder-phase/references/root-routing.md +12 -20
- package/dist/skills/phases/finder-phase/references/runtime-handoff.md +17 -39
- package/dist/skills/phases/finder-phase/references/state-graph.md +27 -49
- package/dist/skills/phases/finder-phase/scripts/finder-contract.mjs +44 -357
- package/dist/skills/phases/functional-finder/SKILL.md +29 -62
- package/dist/skills/phases/requirements-phase/SKILL.md +49 -13
- package/package.json +7 -5
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/adopt-business-path.md +0 -52
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/business-grilling.md +0 -68
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/functional-grilling.md +0 -53
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/technical-grilling.md +0 -67
- package/dist/baseline/scaffold-baseline/skills/phases/technical-finder/SKILL.md +0 -74
- package/dist/baseline/scaffold-baseline/skills/phases/technical-finder/agents/openai.yaml +0 -2
- package/dist/skills/phases/finder-phase/phases/adopt-business-path.md +0 -52
- package/dist/skills/phases/finder-phase/phases/business-grilling.md +0 -68
- package/dist/skills/phases/finder-phase/phases/functional-grilling.md +0 -53
- package/dist/skills/phases/finder-phase/phases/technical-grilling.md +0 -67
- package/dist/skills/phases/technical-finder/SKILL.md +0 -74
- package/dist/skills/phases/technical-finder/agents/openai.yaml +0 -2
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface CommitGateRunnerContract {
|
|
2
|
+
readonly formatCheck: string;
|
|
3
|
+
readonly lint: string;
|
|
4
|
+
readonly owner?: string;
|
|
5
|
+
readonly path?: string;
|
|
6
|
+
readonly root: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type CommitGateRunnerResult =
|
|
10
|
+
| { readonly code: 0; readonly failures: readonly [] }
|
|
11
|
+
| { readonly code: 1; readonly failures: readonly string[] };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execFile as execFileCallback } from "node:child_process";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
import process from "node:process";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { promisify } from "node:util";
|
|
8
|
+
|
|
9
|
+
const execFile = promisify(execFileCallback);
|
|
10
|
+
|
|
11
|
+
const run = async (command, cwd, environment) => {
|
|
12
|
+
try {
|
|
13
|
+
const result = await execFile("sh", ["-c", command], {
|
|
14
|
+
cwd,
|
|
15
|
+
env: { ...process.env, ...environment },
|
|
16
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
17
|
+
});
|
|
18
|
+
return { code: 0, stderr: result.stderr, stdout: result.stdout };
|
|
19
|
+
} catch (error) {
|
|
20
|
+
return {
|
|
21
|
+
code: typeof error.code === "number" ? error.code : 1,
|
|
22
|
+
stderr: error.stderr ?? "",
|
|
23
|
+
stdout: error.stdout ?? "",
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const stagedPaths = async () => {
|
|
29
|
+
const { stdout } = await execFile("git", [
|
|
30
|
+
"diff",
|
|
31
|
+
"--cached",
|
|
32
|
+
"--name-only",
|
|
33
|
+
"--diff-filter=ACMR",
|
|
34
|
+
"-z",
|
|
35
|
+
]);
|
|
36
|
+
return stdout.split("\0").filter(Boolean);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const shellQuote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
40
|
+
|
|
41
|
+
const argument = (name) => {
|
|
42
|
+
const index = process.argv.indexOf(name);
|
|
43
|
+
return index === -1 ? null : (process.argv[index + 1] ?? null);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const contractsPath = argument("--contracts");
|
|
47
|
+
if (contractsPath === null) {
|
|
48
|
+
console.error("Commit Gate runner requires --contracts <path>.");
|
|
49
|
+
process.exitCode = 2;
|
|
50
|
+
} else {
|
|
51
|
+
try {
|
|
52
|
+
const contractsContent = await readFile(contractsPath, "utf-8");
|
|
53
|
+
const contracts = JSON.parse(contractsContent);
|
|
54
|
+
const staged = await stagedPaths();
|
|
55
|
+
if (staged.length === 0) {
|
|
56
|
+
process.exit(0);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const failuresByContract = await Promise.all(
|
|
60
|
+
contracts.map(async (contract) => {
|
|
61
|
+
const relativePath = contract.path ?? ".";
|
|
62
|
+
const root = path.resolve(contract.root ?? process.cwd(), relativePath);
|
|
63
|
+
const prefix =
|
|
64
|
+
relativePath === "." || relativePath === "" ? "" : `${relativePath.replace(/\/$/u, "")}/`;
|
|
65
|
+
const files = staged
|
|
66
|
+
.filter((file) => prefix === "" || file.startsWith(prefix))
|
|
67
|
+
.map((file) => (prefix === "" ? file : file.slice(prefix.length)));
|
|
68
|
+
if (files.length === 0) {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
const fileArguments = files.map(shellQuote).join(" ");
|
|
72
|
+
const commands = [
|
|
73
|
+
["lint", contract.lint],
|
|
74
|
+
["formatCheck", contract.formatCheck],
|
|
75
|
+
];
|
|
76
|
+
const results = await Promise.all(
|
|
77
|
+
commands.map(async ([kind, template]) => {
|
|
78
|
+
const scopedTemplate = template.replace(/(?<prefix>^|\s)\.\s*$/u, "$<prefix>{files}");
|
|
79
|
+
const command = scopedTemplate.includes("{files}")
|
|
80
|
+
? scopedTemplate.replaceAll("{files}", fileArguments)
|
|
81
|
+
: `${scopedTemplate} -- ${fileArguments}`;
|
|
82
|
+
const result = await run(command, root, {
|
|
83
|
+
HI_STAGED_FILES: files.join("\n"),
|
|
84
|
+
});
|
|
85
|
+
return { ...result, kind, owner: contract.owner ?? root };
|
|
86
|
+
}),
|
|
87
|
+
);
|
|
88
|
+
return results.filter((result) => result.code !== 0);
|
|
89
|
+
}),
|
|
90
|
+
);
|
|
91
|
+
const failures = failuresByContract.flat();
|
|
92
|
+
|
|
93
|
+
for (const failure of failures) {
|
|
94
|
+
process.stderr.write(
|
|
95
|
+
`Commit Gate ${failure.kind} failed for ${failure.owner} (exit ${failure.code}).\n${failure.stdout}${failure.stderr}`,
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
process.exitCode = failures.length === 0 ? 0 : 1;
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
101
|
+
process.exitCode = 1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { mkdir, mkdtemp, readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { describe, expect, it } from "vitest";
|
|
6
|
+
|
|
7
|
+
interface ExecResult {
|
|
8
|
+
readonly code: number;
|
|
9
|
+
readonly stderr: string;
|
|
10
|
+
readonly stdout: string;
|
|
11
|
+
}
|
|
12
|
+
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
13
|
+
typeof value === "object" && value !== null;
|
|
14
|
+
const run = async (
|
|
15
|
+
command: string,
|
|
16
|
+
args: readonly string[],
|
|
17
|
+
options: { readonly cwd: string },
|
|
18
|
+
): Promise<ExecResult> => {
|
|
19
|
+
await Promise.resolve();
|
|
20
|
+
try {
|
|
21
|
+
return {
|
|
22
|
+
code: 0,
|
|
23
|
+
stderr: "",
|
|
24
|
+
stdout: execFileSync(command, args, {
|
|
25
|
+
cwd: options.cwd,
|
|
26
|
+
encoding: "utf-8",
|
|
27
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
} catch (error) {
|
|
31
|
+
const record = isRecord(error) ? error : {};
|
|
32
|
+
return {
|
|
33
|
+
code: typeof record.status === "number" ? record.status : 1,
|
|
34
|
+
stderr: typeof record.stderr === "string" ? record.stderr : "",
|
|
35
|
+
stdout: typeof record.stdout === "string" ? record.stdout : "",
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const runner = path.resolve(import.meta.dirname, "commit-gate-runner.mjs");
|
|
40
|
+
|
|
41
|
+
const fixture = async () => {
|
|
42
|
+
const root = await mkdtemp(path.join(tmpdir(), "commit-gate-runner-"));
|
|
43
|
+
await run("git", ["init", "-q"], { cwd: root });
|
|
44
|
+
await mkdir(path.join(root, ".devpunks"), { recursive: true });
|
|
45
|
+
await writeFile(
|
|
46
|
+
path.join(root, "marker.mjs"),
|
|
47
|
+
"import fs from 'node:fs'; fs.writeFileSync('marker.out', process.cwd() + '\\n' + process.argv.slice(2).join('\\n'));",
|
|
48
|
+
);
|
|
49
|
+
return root;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
describe("Commit Gate runner", () => {
|
|
53
|
+
it("does not spawn quality commands when no files are staged", async () => {
|
|
54
|
+
const root = await fixture();
|
|
55
|
+
await writeFile(
|
|
56
|
+
path.join(root, ".devpunks/contracts.json"),
|
|
57
|
+
JSON.stringify([
|
|
58
|
+
{
|
|
59
|
+
formatCheck: "node marker.mjs .",
|
|
60
|
+
lint: "node marker.mjs .",
|
|
61
|
+
owner: "root",
|
|
62
|
+
path: ".",
|
|
63
|
+
root,
|
|
64
|
+
},
|
|
65
|
+
]),
|
|
66
|
+
);
|
|
67
|
+
const result = await run("node", [runner, "--contracts", ".devpunks/contracts.json"], {
|
|
68
|
+
cwd: root,
|
|
69
|
+
});
|
|
70
|
+
expect(result.stdout).toBe("");
|
|
71
|
+
await expect(readFile(path.join(root, "marker.out"), "utf-8")).rejects.toThrow("ENOENT");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("aggregates lint and format failures", async () => {
|
|
75
|
+
const root = await fixture();
|
|
76
|
+
await writeFile(path.join(root, "a.ts"), "a");
|
|
77
|
+
await run("git", ["add", "."], { cwd: root });
|
|
78
|
+
await writeFile(path.join(root, "fail.mjs"), "process.exit(1);");
|
|
79
|
+
await writeFile(
|
|
80
|
+
path.join(root, ".devpunks/contracts.json"),
|
|
81
|
+
JSON.stringify([
|
|
82
|
+
{ formatCheck: "node fail.mjs", lint: "node fail.mjs", owner: "root", path: ".", root },
|
|
83
|
+
]),
|
|
84
|
+
);
|
|
85
|
+
const result = await run("node", [runner, "--contracts", ".devpunks/contracts.json"], {
|
|
86
|
+
cwd: root,
|
|
87
|
+
});
|
|
88
|
+
expect(result.code).toBe(1);
|
|
89
|
+
expect(result.stderr).toContain("lint");
|
|
90
|
+
expect(result.stderr).toContain("format");
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("passes root-relative staged files and excludes deletions", async () => {
|
|
94
|
+
const root = await fixture();
|
|
95
|
+
await writeFile(path.join(root, "a.ts"), "a");
|
|
96
|
+
await writeFile(path.join(root, "gone.ts"), "gone");
|
|
97
|
+
await run("git", ["add", "."], { cwd: root });
|
|
98
|
+
await run("git", ["commit", "-qm", "seed"], { cwd: root });
|
|
99
|
+
await writeFile(path.join(root, "a.ts"), "changed");
|
|
100
|
+
await run("git", ["add", "a.ts"], { cwd: root });
|
|
101
|
+
await run("git", ["rm", "-q", "gone.ts"], { cwd: root });
|
|
102
|
+
await writeFile(
|
|
103
|
+
path.join(root, ".devpunks/contracts.json"),
|
|
104
|
+
JSON.stringify([
|
|
105
|
+
{
|
|
106
|
+
formatCheck: "node marker.mjs .",
|
|
107
|
+
lint: "node marker.mjs .",
|
|
108
|
+
owner: "root",
|
|
109
|
+
path: ".",
|
|
110
|
+
root,
|
|
111
|
+
},
|
|
112
|
+
]),
|
|
113
|
+
);
|
|
114
|
+
const result = await run("node", [runner, "--contracts", ".devpunks/contracts.json"], {
|
|
115
|
+
cwd: root,
|
|
116
|
+
});
|
|
117
|
+
expect(result.stderr).not.toContain("gone.ts");
|
|
118
|
+
await expect(readFile(path.join(root, "marker.out"), "utf-8")).resolves.toContain("a.ts");
|
|
119
|
+
await expect(readFile(path.join(root, "marker.out"), "utf-8")).resolves.not.toContain("\n.");
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("uses nested owner cwd and owner-relative staged paths", async () => {
|
|
123
|
+
const root = await fixture();
|
|
124
|
+
await mkdir(path.join(root, "apps/web/src"), { recursive: true });
|
|
125
|
+
await writeFile(path.join(root, "apps/web/src/a.ts"), "a");
|
|
126
|
+
await run("git", ["add", "."], { cwd: root });
|
|
127
|
+
await writeFile(
|
|
128
|
+
path.join(root, ".devpunks/contracts.json"),
|
|
129
|
+
JSON.stringify([
|
|
130
|
+
{
|
|
131
|
+
formatCheck: "node ../../marker.mjs",
|
|
132
|
+
lint: "node ../../marker.mjs",
|
|
133
|
+
owner: "web",
|
|
134
|
+
path: "apps/web",
|
|
135
|
+
root,
|
|
136
|
+
},
|
|
137
|
+
]),
|
|
138
|
+
);
|
|
139
|
+
await run("node", [runner, "--contracts", ".devpunks/contracts.json"], { cwd: root });
|
|
140
|
+
const marker = await readFile(path.join(root, "apps/web/marker.out"), "utf-8");
|
|
141
|
+
expect(marker).toContain("apps/web");
|
|
142
|
+
expect(marker).toContain("src/a.ts");
|
|
143
|
+
});
|
|
144
|
+
});
|
|
@@ -73,6 +73,7 @@ const projectContribution = ({ scopeId, contribution }) => {
|
|
|
73
73
|
operation: "merge-json",
|
|
74
74
|
target: `.claude/settings.json#${configuration.path.join(".")}:${contribution.identity.id}`,
|
|
75
75
|
file: ".claude/settings.json",
|
|
76
|
+
responseMode: "claude-post-tool-use-context",
|
|
76
77
|
...configuration,
|
|
77
78
|
},
|
|
78
79
|
];
|
|
@@ -81,6 +81,7 @@ const cursorProject = ({ scopeId, contribution }) => {
|
|
|
81
81
|
source: `.agents/hooks/${contributionId}.mjs`,
|
|
82
82
|
target: `.cursor/hooks/${contributionId}.mjs`,
|
|
83
83
|
config: { path: ".cursor/hooks.json", ...config },
|
|
84
|
+
responseMode: "cursor-user-message",
|
|
84
85
|
contributionId,
|
|
85
86
|
},
|
|
86
87
|
];
|
|
@@ -67,9 +67,9 @@ const planForSupport = ({
|
|
|
67
67
|
...contextPlan,
|
|
68
68
|
scopes: contextPlan.scopes.map((scope) => ({
|
|
69
69
|
...scope,
|
|
70
|
-
contributions: scope.contributions
|
|
71
|
-
(contribution) =>
|
|
72
|
-
|
|
70
|
+
contributions: scope.contributions
|
|
71
|
+
.filter((contribution) => contribution.kind !== "commit-gate")
|
|
72
|
+
.filter((contribution) => byFamily.get(contribution.kind)?.support === support),
|
|
73
73
|
})),
|
|
74
74
|
};
|
|
75
75
|
};
|
|
@@ -94,23 +94,22 @@ export const testHarnessProjectionContract = ({
|
|
|
94
94
|
|
|
95
95
|
describe(`${name} harness projection adapter`, () => {
|
|
96
96
|
it("projects supported contributions", () => {
|
|
97
|
-
const result = project({ adapter, contextPlan: supported })
|
|
97
|
+
const result = project({ adapter, contextPlan: supported });
|
|
98
98
|
const expectedIds = contributionIds(supported);
|
|
99
99
|
|
|
100
100
|
expect(expectedIds.length).toBeGreaterThan(0);
|
|
101
101
|
expect(result.actions.map(({ trace }) => trace.contribution.id)).toEqual(
|
|
102
102
|
expect.arrayContaining([...expectedIds]),
|
|
103
103
|
);
|
|
104
|
-
expect(result.summary).
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
});
|
|
104
|
+
expect(result.summary._tag).toBe("HarnessProjectionSuccess");
|
|
105
|
+
if (result.summary._tag === "HarnessProjectionSuccess") {
|
|
106
|
+
expect(result.summary.applied.length).toBeGreaterThan(0);
|
|
107
|
+
expect(result.summary.applied.every(({ support }) => support === "supported")).toBe(true);
|
|
108
|
+
}
|
|
110
109
|
});
|
|
111
110
|
|
|
112
111
|
it("records per-contribution outcomes for degraded capabilities", () => {
|
|
113
|
-
const result = project({ adapter, contextPlan: degraded })
|
|
112
|
+
const result = project({ adapter, contextPlan: degraded });
|
|
114
113
|
const expectedKeys = degraded.scopes.flatMap((scope) =>
|
|
115
114
|
scope.contributions.map(
|
|
116
115
|
(contribution) => `${scope.id}:${contribution.kind}:${contribution.identity.id}`,
|
|
@@ -144,20 +143,18 @@ export const testHarnessProjectionContract = ({
|
|
|
144
143
|
});
|
|
145
144
|
|
|
146
145
|
it("records unsupported contributions without projecting actions", () => {
|
|
147
|
-
const result = project({ adapter, contextPlan: unsupported })
|
|
146
|
+
const result = project({ adapter, contextPlan: unsupported });
|
|
148
147
|
|
|
149
148
|
expect(contributionIds(unsupported).length).toBeGreaterThan(0);
|
|
150
149
|
expect(result.actions).toEqual([]);
|
|
151
|
-
expect(result.summary).
|
|
152
|
-
|
|
153
|
-
applied
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
]),
|
|
160
|
-
});
|
|
150
|
+
expect(result.summary._tag).toBe("HarnessProjectionPartial");
|
|
151
|
+
if (result.summary._tag === "HarnessProjectionPartial") {
|
|
152
|
+
expect(result.summary.applied).toEqual([]);
|
|
153
|
+
expect(result.summary.omissions.length).toBeGreaterThan(0);
|
|
154
|
+
expect(result.summary.omissions.every(({ support }) => support === "unsupported")).toBe(
|
|
155
|
+
true,
|
|
156
|
+
);
|
|
157
|
+
}
|
|
161
158
|
});
|
|
162
159
|
|
|
163
160
|
it("continues valid contributions after an adapter defect", () => {
|
|
@@ -173,19 +170,13 @@ export const testHarnessProjectionContract = ({
|
|
|
173
170
|
},
|
|
174
171
|
};
|
|
175
172
|
|
|
176
|
-
const result = project({ adapter: defectAdapter, contextPlan })
|
|
173
|
+
const result = project({ adapter: defectAdapter, contextPlan });
|
|
177
174
|
|
|
178
175
|
expect(result.actions.length).toBeGreaterThan(0);
|
|
179
|
-
expect(result.summary).
|
|
180
|
-
|
|
181
|
-
errors
|
|
182
|
-
|
|
183
|
-
_tag: "HarnessAdapterDefectError",
|
|
184
|
-
message: "stub defect",
|
|
185
|
-
}),
|
|
186
|
-
],
|
|
187
|
-
omissions: expect.any(Array),
|
|
188
|
-
});
|
|
176
|
+
expect(result.summary._tag).toBe("HarnessProjectionFailure");
|
|
177
|
+
if (result.summary._tag === "HarnessProjectionFailure") {
|
|
178
|
+
expect(result.summary.errors.some(({ message }) => message === "stub defect")).toBe(true);
|
|
179
|
+
}
|
|
189
180
|
});
|
|
190
181
|
|
|
191
182
|
it("is deterministic for identical semantic input", () => {
|
|
@@ -124,6 +124,10 @@ export function project({ adapter, contextPlan }) {
|
|
|
124
124
|
|
|
125
125
|
for (const scope of contextPlan.scopes) {
|
|
126
126
|
for (const contribution of scope.contributions) {
|
|
127
|
+
if (contribution.kind === "commit-gate") {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
|
|
127
131
|
contributionCount += 1;
|
|
128
132
|
const capability = capabilities.get(contribution.kind);
|
|
129
133
|
const trace = traceFor({ adapter, contextPlan, scope, contribution });
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "@effect/vitest";
|
|
2
|
+
import type { ContextPlan } from "@punks/scaffold/context-plan";
|
|
3
|
+
import type { HarnessCapabilityMatrix } from "@punks/scaffold/harness-capability";
|
|
4
|
+
|
|
5
|
+
import { project } from "./core.mjs";
|
|
6
|
+
import type { HarnessProjectionAdapter } from "./contract";
|
|
7
|
+
|
|
8
|
+
const matrix = {
|
|
9
|
+
adapter: {
|
|
10
|
+
id: "test",
|
|
11
|
+
version: "2026.09.02-v1",
|
|
12
|
+
},
|
|
13
|
+
capabilities: [
|
|
14
|
+
{ family: "skill", support: "supported" },
|
|
15
|
+
{ family: "scoped-prompt", support: "supported" },
|
|
16
|
+
{ family: "lifecycle-hook", support: "supported" },
|
|
17
|
+
{ family: "tool-configuration", support: "supported" },
|
|
18
|
+
{ family: "subagent-template", support: "supported" },
|
|
19
|
+
],
|
|
20
|
+
matrixVersion: "2026.09.02-v1",
|
|
21
|
+
} as const satisfies HarnessCapabilityMatrix;
|
|
22
|
+
|
|
23
|
+
describe("harness projection", () => {
|
|
24
|
+
it("ignores commit gates because adapters project only harness capabilities", () => {
|
|
25
|
+
const adapterProject = vi.fn<HarnessProjectionAdapter["project"]>();
|
|
26
|
+
const contextPlan = {
|
|
27
|
+
scopes: [
|
|
28
|
+
{
|
|
29
|
+
contributions: [
|
|
30
|
+
{
|
|
31
|
+
compatibility: [],
|
|
32
|
+
contract: {
|
|
33
|
+
formatCheck: "bun run check:format",
|
|
34
|
+
lint: "bun run lint",
|
|
35
|
+
},
|
|
36
|
+
identity: { id: "verification", version: "1" },
|
|
37
|
+
kind: "commit-gate",
|
|
38
|
+
order: 0,
|
|
39
|
+
provenance: { revision: "1", source: "project" },
|
|
40
|
+
references: [],
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
id: "root",
|
|
44
|
+
packs: [],
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
version: "1",
|
|
48
|
+
} satisfies ContextPlan;
|
|
49
|
+
|
|
50
|
+
const result = project({
|
|
51
|
+
adapter: { matrix, project: adapterProject },
|
|
52
|
+
contextPlan,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
expect(adapterProject).not.toHaveBeenCalled();
|
|
56
|
+
expect(result).toStrictEqual({
|
|
57
|
+
actions: [],
|
|
58
|
+
summary: { _tag: "HarnessProjectionSuccess", applied: [] },
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { testHooks } from "../../hooks/format-edited-file.mjs";
|
|
4
|
+
import { claudeAdapter } from "./adapters/claude.mjs";
|
|
5
|
+
import { codexAdapter } from "./adapters/codex.mjs";
|
|
6
|
+
import { cursorAdapter } from "./adapters/cursor.mjs";
|
|
7
|
+
import { openCodeAdapter } from "./adapters/opencode.mjs";
|
|
8
|
+
|
|
9
|
+
const finding = {
|
|
10
|
+
column: 1,
|
|
11
|
+
documentation: "https://oxc.rs/docs/guide/usage/linter/rules/no-console",
|
|
12
|
+
file: "apps/demo/src/bad.ts",
|
|
13
|
+
help: "Remove the console statement",
|
|
14
|
+
line: 2,
|
|
15
|
+
message: "Unexpected console statement",
|
|
16
|
+
rule: "no-console",
|
|
17
|
+
severity: "error",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const summary = {
|
|
21
|
+
diagnostics: [finding],
|
|
22
|
+
exhausted: false,
|
|
23
|
+
failures: [],
|
|
24
|
+
format_failed: [],
|
|
25
|
+
lint_failed: [finding.file],
|
|
26
|
+
result: "findings",
|
|
27
|
+
status: "findings",
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const cleanSummary = {
|
|
31
|
+
diagnostics: [],
|
|
32
|
+
exhausted: false,
|
|
33
|
+
failures: [],
|
|
34
|
+
format_failed: [],
|
|
35
|
+
lint_failed: [],
|
|
36
|
+
result: "clean",
|
|
37
|
+
status: "clean",
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const contribution = {
|
|
41
|
+
compatibility: [],
|
|
42
|
+
identity: { id: "format-edited-file", version: "2026.09.02" },
|
|
43
|
+
kind: "lifecycle-hook" as const,
|
|
44
|
+
order: 0,
|
|
45
|
+
provenance: { revision: "2026.09.02", source: "baseline" },
|
|
46
|
+
references: [],
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const hookAction = (adapter: typeof codexAdapter) => {
|
|
50
|
+
const capability = adapter.matrix.capabilities.find(({ family }) => family === "lifecycle-hook");
|
|
51
|
+
if (capability === undefined) {
|
|
52
|
+
throw new Error("lifecycle-hook capability is missing");
|
|
53
|
+
}
|
|
54
|
+
const projected = adapter.project({ capability, contribution, scopeId: "root" });
|
|
55
|
+
if (!Array.isArray(projected)) {
|
|
56
|
+
throw new TypeError("formatter hook was not projected");
|
|
57
|
+
}
|
|
58
|
+
return projected;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
describe("provider-native lint feedback", () => {
|
|
62
|
+
it("projects actionable findings through each provider's response contract", () => {
|
|
63
|
+
const codex = testHooks.renderProviderFeedback("codex", summary);
|
|
64
|
+
expect(codex).toMatchObject({
|
|
65
|
+
decision: "block",
|
|
66
|
+
hookSpecificOutput: {
|
|
67
|
+
additionalContext: expect.stringContaining("apps/demo/src/bad.ts:2:1"),
|
|
68
|
+
hookEventName: "PostToolUse",
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const claude = testHooks.renderProviderFeedback("claude", summary);
|
|
73
|
+
expect(claude).toMatchObject({
|
|
74
|
+
hookSpecificOutput: {
|
|
75
|
+
additionalContext: expect.stringContaining("(error) [no-console]"),
|
|
76
|
+
hookEventName: "PostToolUse",
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const cursor = testHooks.renderProviderFeedback("cursor", summary);
|
|
81
|
+
expect(cursor).toMatchObject({ user_message: expect.stringContaining("Unexpected console") });
|
|
82
|
+
|
|
83
|
+
const opencode = testHooks.renderProviderFeedback("opencode", summary);
|
|
84
|
+
expect(opencode).toMatchObject({
|
|
85
|
+
diagnostics: [expect.objectContaining({ file: finding.file, rule: finding.rule })],
|
|
86
|
+
event: "lint-feedback",
|
|
87
|
+
repairRequested: true,
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("stays silent for clean verification and reports exhaustion without a repair request", () => {
|
|
92
|
+
expect(testHooks.renderProviderFeedback("codex", cleanSummary)).toBeNull();
|
|
93
|
+
|
|
94
|
+
const exhausted = testHooks.renderProviderFeedback("codex", {
|
|
95
|
+
...summary,
|
|
96
|
+
exhausted: true,
|
|
97
|
+
});
|
|
98
|
+
expect(exhausted).toMatchObject({
|
|
99
|
+
hookSpecificOutput: { additionalContext: expect.stringContaining("exhausted") },
|
|
100
|
+
});
|
|
101
|
+
expect("decision" in exhausted).toBeFalsy();
|
|
102
|
+
expect(String(exhausted.hookSpecificOutput.additionalContext).toLowerCase()).not.toContain(
|
|
103
|
+
"fix these",
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("marks the provider hook mode in every projection", () => {
|
|
108
|
+
const codexActions = hookAction(codexAdapter);
|
|
109
|
+
const claudeActions = hookAction(claudeAdapter);
|
|
110
|
+
const cursorActions = hookAction(cursorAdapter);
|
|
111
|
+
const opencodeActions = hookAction(openCodeAdapter);
|
|
112
|
+
|
|
113
|
+
expect(JSON.stringify(codexActions)).toContain("codex-post-tool-use-block");
|
|
114
|
+
expect(JSON.stringify(claudeActions)).toContain("claude-post-tool-use-context");
|
|
115
|
+
expect(JSON.stringify(cursorActions)).toContain("cursor-user-message");
|
|
116
|
+
expect(JSON.stringify(opencodeActions)).toContain("opencode-structured-log");
|
|
117
|
+
expect([
|
|
118
|
+
JSON.stringify(codexActions.map(({ entries }) => entries)).includes("responseMode"),
|
|
119
|
+
JSON.stringify(claudeActions.map(({ value }) => value)).includes("responseMode"),
|
|
120
|
+
JSON.stringify(cursorActions.map(({ config }) => config)).includes("responseMode"),
|
|
121
|
+
]).toStrictEqual([false, false, false]);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"operation": "merge-json",
|
|
53
53
|
"target": ".claude/settings.json#hooks.PostToolUse:format-edited-file",
|
|
54
54
|
"file": ".claude/settings.json",
|
|
55
|
+
"responseMode": "claude-post-tool-use-context",
|
|
55
56
|
"path": ["hooks", "PostToolUse"],
|
|
56
57
|
"value": {
|
|
57
58
|
"matcher": "Edit|Write|MultiEdit",
|