@punks/cli 5.1.1 → 5.2.0
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/AGENTS.md +28 -10
- package/dist/BASELINE_CHANGELOG.md +11 -1
- package/dist/CHANGELOG.md +32 -0
- package/dist/baseline/scaffold-baseline/baseline.json +5 -10
- package/dist/baseline/scaffold-baseline/data/catalog/packs.json +1 -1
- package/dist/baseline/scaffold-baseline/data/catalog/skills.json +0 -8
- package/dist/baseline/scaffold-baseline/data/scripts/commit-gate-runner.mjs +118 -41
- package/dist/baseline/scaffold-baseline/data/scripts/commit-gate-runner.test.ts +345 -26
- package/dist/baseline/scaffold-baseline/data/scripts/sync-subagents-validator.test.ts +39 -0
- package/dist/baseline/scaffold-baseline/data/scripts/sync-subagents.mjs +8 -2
- package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/define-handoffs.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/model-state.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/test-routes.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/write-phases.md +2 -2
- package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/write-router.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/references/authoring-contract.md +8 -8
- package/dist/baseline/scaffold-baseline/skills/agnostic/quality/autoreview/SKILL.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/agnostic/quality/make-tsuite/SKILL.md +2 -2
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/brainstorm/SKILL.md +21 -11
- package/dist/baseline/scaffold-baseline/skills/phases/debugging-phase/SKILL.md +3 -4
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/SKILL.md +2 -2
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/debug.md +2 -2
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/human-steering.md +25 -0
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/implement.md +2 -2
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/review.md +2 -2
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/router.md +3 -2
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/context-continuity.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/failure-continuity.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/phase-handoff.md +4 -3
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/AUTHORING-HANDOFF.md +9 -9
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/SKILL.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/ensure-fog.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/grilling.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/human-steering.md +25 -0
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/prototype.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/reconcile.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/research.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/router.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/references/state-graph.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/return-route.md +6 -5
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/router.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/run-review.md +2 -1
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/state-graph.md +3 -3
- package/dist/baseline/scaffold-baseline.json +5 -5
- package/dist/baseline/scaffold-baseline.tgz +0 -0
- package/dist/data/AGENTS.md +22 -5
- package/dist/data/scripts/commit-gate-runner.mjs +118 -41
- package/dist/data/scripts/sync-subagents.mjs +8 -2
- package/dist/index.js +93 -90
- package/dist/skills/agnostic/docs/write-graph-based-skills/phases/define-handoffs.md +1 -1
- package/dist/skills/agnostic/docs/write-graph-based-skills/phases/model-state.md +1 -1
- package/dist/skills/agnostic/docs/write-graph-based-skills/phases/test-routes.md +1 -1
- package/dist/skills/agnostic/docs/write-graph-based-skills/phases/write-phases.md +2 -2
- package/dist/skills/agnostic/docs/write-graph-based-skills/phases/write-router.md +1 -1
- package/dist/skills/agnostic/docs/write-graph-based-skills/references/authoring-contract.md +8 -8
- package/dist/skills/agnostic/quality/autoreview/SKILL.md +1 -1
- package/dist/skills/agnostic/quality/make-tsuite/SKILL.md +2 -2
- package/dist/skills/agnostic/requirements/brainstorm/SKILL.md +21 -11
- package/dist/skills/phases/debugging-phase/SKILL.md +3 -4
- package/dist/skills/phases/delivery-phase/SKILL.md +2 -2
- package/dist/skills/phases/delivery-phase/phases/debug.md +2 -2
- package/dist/skills/phases/delivery-phase/phases/human-steering.md +25 -0
- package/dist/skills/phases/delivery-phase/phases/implement.md +2 -2
- package/dist/skills/phases/delivery-phase/phases/review.md +2 -2
- package/dist/skills/phases/delivery-phase/phases/router.md +3 -2
- package/dist/skills/phases/delivery-phase/references/context-continuity.md +1 -1
- package/dist/skills/phases/delivery-phase/references/failure-continuity.md +1 -1
- package/dist/skills/phases/delivery-phase/references/phase-handoff.md +4 -3
- package/dist/skills/phases/finder-phase/AUTHORING-HANDOFF.md +6 -6
- package/dist/skills/phases/finder-phase/SKILL.md +1 -1
- package/dist/skills/phases/finder-phase/phases/ensure-fog.md +1 -1
- package/dist/skills/phases/finder-phase/phases/grilling.md +1 -1
- package/dist/skills/phases/finder-phase/phases/human-steering.md +25 -0
- package/dist/skills/phases/finder-phase/phases/prototype.md +1 -1
- package/dist/skills/phases/finder-phase/phases/reconcile.md +1 -1
- package/dist/skills/phases/finder-phase/phases/research.md +1 -1
- package/dist/skills/phases/finder-phase/phases/router.md +1 -1
- package/dist/skills/phases/finder-phase/references/state-graph.md +1 -1
- package/dist/skills/phases/review-phase/phases/return-route.md +6 -5
- package/dist/skills/phases/review-phase/phases/router.md +1 -1
- package/dist/skills/phases/review-phase/phases/run-review.md +2 -1
- package/dist/skills/phases/review-phase/references/state-graph.md +3 -3
- package/package.json +12 -6
- package/dist/baseline/scaffold-baseline/skills/agnostic/generic/handback/SKILL.md +0 -27
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/handback.md +0 -27
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/handback.md +0 -29
- package/dist/skills/agnostic/generic/handback/SKILL.md +0 -27
- package/dist/skills/phases/delivery-phase/phases/handback.md +0 -27
- package/dist/skills/phases/finder-phase/phases/handback.md +0 -29
package/AGENTS.md
CHANGED
|
@@ -1,20 +1,38 @@
|
|
|
1
1
|
## CLI App Guidance
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This app owns the `hi`/`hint` executable, repository detection, local scaffold and update writes, bundled baseline fallback, diff ergonomics, and release/baseline publishing scripts. Keep remote registry, provenance, auth, telemetry, and artifact access behind the control-plane boundary.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Work within the accepted goal. Obtain explicit user authorization before changing requirements, weakening a gate, or substantially redesigning implementation.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
Autonomy ends at accepted goal bounds. If progress requires changed requirements, a weaker gate, or substantial implementation redesign, invoke `$handback` before expanding work.
|
|
7
|
+
Use [Rule Registry](../../.agents/rules/index.md) as the exhaustive codebase-rule index. Activate every rule whose path or task trigger matches the work, read its linked file, and record `pass`, `fail`, or `not-applicable` with evidence in the current handoff work log.
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
### Skills
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
Read the installed skill on its exact invocation below; phase routing remains inherited from the root guidance.
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
| Skill | Exact trigger |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| `autoreview` | When the task explicitly invokes `autoreview`, read `../../.agents/skills/autoreview/SKILL.md`. |
|
|
16
|
+
| `codebase-design` | When the task explicitly invokes `codebase-design`, read `../../.agents/skills/codebase-design/SKILL.md`. |
|
|
17
|
+
| `effect` | When the task explicitly invokes `effect`, read `../../.agents/skills/effect/SKILL.md`. |
|
|
18
|
+
| `effect-backend-structure` | When the task explicitly invokes `effect-backend-structure`, read `../../.agents/skills/effect-backend-structure/SKILL.md`. |
|
|
19
|
+
| `effect-recoverable-actions` | When the task explicitly invokes `effect-recoverable-actions`, read `../../.agents/skills/effect-recoverable-actions/SKILL.md`. |
|
|
20
|
+
| `effect-service-design` | When the task explicitly invokes `effect-service-design`, read `../../.agents/skills/effect-service-design/SKILL.md`. |
|
|
21
|
+
| `improve-codebase-architecture` | When the task explicitly invokes `improve-codebase-architecture`, read `../../.agents/skills/improve-codebase-architecture/SKILL.md`. |
|
|
22
|
+
| `make-tsuite` | When the task explicitly invokes `make-tsuite`, read `../../.agents/skills/make-tsuite/SKILL.md`. |
|
|
23
|
+
| `parallel-research` | When the task explicitly invokes `parallel-research`, read `../../.agents/skills/parallel-research/SKILL.md`. |
|
|
24
|
+
| `prototype` | When the task explicitly invokes `prototype`, read `../../.agents/skills/prototype/SKILL.md`. |
|
|
25
|
+
| `quality-types` | When the task explicitly invokes `quality-types`, read `../../.agents/skills/quality-types/SKILL.md`. |
|
|
26
|
+
| `review` | When the task explicitly invokes `review`, read `../../.agents/skills/review/SKILL.md`. |
|
|
27
|
+
| `simplify` | When the task explicitly invokes `simplify`, read `../../.agents/skills/simplify/SKILL.md`. |
|
|
28
|
+
| `swarm-planner` | When the task explicitly invokes `swarm-planner`, read `../../.agents/skills/swarm-planner/SKILL.md`. |
|
|
29
|
+
| `tdd` | When the task explicitly invokes `tdd`, read `../../.agents/skills/tdd/SKILL.md`. |
|
|
30
|
+
| `turborepo` | When the task explicitly invokes `turborepo`, read `../../.agents/skills/turborepo/SKILL.md`. |
|
|
15
31
|
|
|
16
|
-
|
|
32
|
+
### Source and validation seams
|
|
17
33
|
|
|
18
|
-
- `opensrc path cevr/sentry-cli` (`https://github.com/cevr/sentry-cli`)
|
|
34
|
+
Read the [Source Guide](../../opensrc/README.md) when work depends on third-party library behavior. For CLI UX, packaging, or release behavior patterns, inspect `opensrc path cevr/sentry-cli` (`https://github.com/cevr/sentry-cli`).
|
|
19
35
|
|
|
20
|
-
|
|
36
|
+
Validate the changed CLI behavior with the narrowest applicable tests and checks in `package.json`; use the nested source guidance for source and packaged-data changes. For release-bearing work, run `bun run release:classify -- --base <base-ref> --head <head-ref>` from the repository root and require it to pass.
|
|
37
|
+
|
|
38
|
+
When work changes operator workflow, setup, or AI scaffolding behavior, update [docs index](../../docs/README.md) and [CLI scaffolding runbook](../../docs/runbooks/hi-cli-scaffolding.md) in the same task.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
-
Compatibility: `>=5.
|
|
5
|
+
Compatibility: `>=5.2.0 <5.3.0`
|
|
6
6
|
|
|
7
7
|
### Added
|
|
8
8
|
|
|
@@ -12,6 +12,16 @@ Compatibility: `>=5.1.0 <5.2.0`
|
|
|
12
12
|
|
|
13
13
|
### Fixed
|
|
14
14
|
|
|
15
|
+
- Cover staged deletions, root changes, and cross-owner renames in the bundled
|
|
16
|
+
Commit Gate runner. Honor explicit file, owner, and repository execution modes,
|
|
17
|
+
deduplicate identical checks, and preserve successful command diagnostics;
|
|
18
|
+
accept the matching execution metadata in generated subagent contracts (#222).
|
|
19
|
+
- Retire the standalone `handback` skill from the shipped catalog and interaction
|
|
20
|
+
pack; keep human steering and scope decisions within their owning workflow
|
|
21
|
+
phases (#222).
|
|
22
|
+
- Update bundled brainstorm guidance to trace the system from the operating
|
|
23
|
+
agent's perspective and reconcile affected design documents and plans when
|
|
24
|
+
their edits are authorized (#222).
|
|
15
25
|
- Restore Effect internal-module topology and repository-boundary guidance; keep
|
|
16
26
|
service qualification and application policy in `effect-service-design` (#205).
|
|
17
27
|
- Sync canonical `wearedevpunks/skills@0519d685213a8085928bde8a5d744fcd6737c931`
|
package/dist/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 5.2.0 - 2026-09-22
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Add explicit file, owner, and repository execution scopes for Commit Gate checks,
|
|
10
|
+
including repository lint and format authority in project settings (#222).
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Validate the complete update candidate, including live guidance targets, staged
|
|
15
|
+
replacements, and removals, before publishing managed changes (#222).
|
|
16
|
+
- Limit update installation and lint work to affected consumers, including optional
|
|
17
|
+
dependency consumers; support generated backoffice Vitest overrides and preserve
|
|
18
|
+
actionable installation and configuration errors (#222).
|
|
19
|
+
- Keep unrelated archives and migration payloads out of generation freshness while
|
|
20
|
+
retaining validation of explicitly referenced inputs (#222).
|
|
21
|
+
- Cover root changes, deletions, and cross-owner renames in Commit Gate checks;
|
|
22
|
+
preserve command output, deduplicate identical checks, and enforce zero warnings
|
|
23
|
+
for generated Oxlint commands (#222).
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- Retire the standalone handback skill and its generated prompt pointers in favor
|
|
28
|
+
of handback guidance owned by lifecycle phases (#222).
|
|
29
|
+
- Use Bun 1.4.0 for repository tooling and two-vCPU Linux CI workers, removing
|
|
30
|
+
automated macOS jobs and provisioning browsers only for selected consumers (#223).
|
|
31
|
+
- Reuse verification results across unrelated documentation changes while tracking
|
|
32
|
+
consumed inputs and runtime capabilities; remove duplicate task execution (#223).
|
|
33
|
+
- Reduce routine test setup and repeated assertions, use minimal real release
|
|
34
|
+
recovery histories, and retain full historical recovery replay and updater
|
|
35
|
+
benchmarking as on-demand diagnostics (#223).
|
|
36
|
+
|
|
5
37
|
## 5.1.1 - 2026-09-17
|
|
6
38
|
|
|
7
39
|
### Added
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"channel": "stable",
|
|
4
|
-
"version": "2026.09.
|
|
5
|
-
"tag": "baseline/stable/2026.09.
|
|
6
|
-
"commit": "
|
|
4
|
+
"version": "2026.09.22-71e84184",
|
|
5
|
+
"tag": "baseline/stable/2026.09.22-71e84184",
|
|
6
|
+
"commit": "71e84184be2e0eff48cffae43face01df5d300ab",
|
|
7
7
|
"sha256": null,
|
|
8
8
|
"compatibility": {
|
|
9
|
-
"cliVersionRange": ">=5.
|
|
9
|
+
"cliVersionRange": ">=5.2.0 <5.3.0"
|
|
10
10
|
},
|
|
11
|
-
"generatedAt": "2026-09-
|
|
11
|
+
"generatedAt": "2026-09-22T14:24:57.000Z",
|
|
12
12
|
"capabilities": {
|
|
13
13
|
"scopedAuthoring": {
|
|
14
14
|
"revision": "1",
|
|
@@ -358,11 +358,6 @@
|
|
|
358
358
|
"authoringRevision": "1",
|
|
359
359
|
"id": "handoff"
|
|
360
360
|
},
|
|
361
|
-
{
|
|
362
|
-
"activationRevision": "1",
|
|
363
|
-
"authoringRevision": "1",
|
|
364
|
-
"id": "handback"
|
|
365
|
-
},
|
|
366
361
|
{
|
|
367
362
|
"activationRevision": "1",
|
|
368
363
|
"authoringRevision": "1",
|
|
@@ -551,14 +551,6 @@
|
|
|
551
551
|
"sourceDirectory": "skills/agnostic/generic/handoff",
|
|
552
552
|
"tier": "agnostic"
|
|
553
553
|
},
|
|
554
|
-
{
|
|
555
|
-
"framework": null,
|
|
556
|
-
"id": "handback",
|
|
557
|
-
"language": null,
|
|
558
|
-
"requiresTools": [],
|
|
559
|
-
"sourceDirectory": "skills/agnostic/generic/handback",
|
|
560
|
-
"tier": "agnostic"
|
|
561
|
-
},
|
|
562
554
|
{
|
|
563
555
|
"framework": null,
|
|
564
556
|
"id": "improve-codebase-architecture",
|
|
@@ -39,11 +39,29 @@ const stagedPaths = async () => {
|
|
|
39
39
|
const { stdout } = await execFile("git", [
|
|
40
40
|
"diff",
|
|
41
41
|
"--cached",
|
|
42
|
-
"--name-
|
|
43
|
-
"--
|
|
42
|
+
"--name-status",
|
|
43
|
+
"--find-renames",
|
|
44
44
|
"-z",
|
|
45
45
|
]);
|
|
46
|
-
|
|
46
|
+
const entries = stdout.split("\0").filter(Boolean);
|
|
47
|
+
const triggers = new Set();
|
|
48
|
+
const files = new Set();
|
|
49
|
+
for (let index = 0; index < entries.length; index += 2) {
|
|
50
|
+
const status = entries[index];
|
|
51
|
+
let file = entries[index + 1];
|
|
52
|
+
if (status.startsWith("R") || status.startsWith("C")) {
|
|
53
|
+
if (status.startsWith("R")) {
|
|
54
|
+
triggers.add(file);
|
|
55
|
+
}
|
|
56
|
+
index += 1;
|
|
57
|
+
file = entries[index + 1];
|
|
58
|
+
}
|
|
59
|
+
triggers.add(file);
|
|
60
|
+
if (status !== "D") {
|
|
61
|
+
files.add(file);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return { files: [...files], triggers: [...triggers] };
|
|
47
65
|
};
|
|
48
66
|
|
|
49
67
|
const activeWorktreeRoot = async () => {
|
|
@@ -68,50 +86,109 @@ if (contractsPath === null) {
|
|
|
68
86
|
const contracts = JSON.parse(contractsContent);
|
|
69
87
|
const worktreeRoot = await activeWorktreeRoot();
|
|
70
88
|
const staged = await stagedPaths();
|
|
71
|
-
if (staged.length === 0) {
|
|
89
|
+
if (staged.triggers.length === 0) {
|
|
72
90
|
process.exit(0);
|
|
73
91
|
}
|
|
74
92
|
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const files = staged
|
|
82
|
-
.filter((file) => prefix === "" || file.startsWith(prefix))
|
|
83
|
-
.map((file) => (prefix === "" ? file : file.slice(prefix.length)));
|
|
84
|
-
if (files.length === 0) {
|
|
85
|
-
return [];
|
|
86
|
-
}
|
|
87
|
-
const fileArguments = files.map(shellQuote).join(" ");
|
|
88
|
-
const commands = [
|
|
89
|
-
["lint", contract.lint],
|
|
90
|
-
["formatCheck", contract.formatCheck],
|
|
91
|
-
];
|
|
92
|
-
const results = await Promise.all(
|
|
93
|
-
commands.map(async ([kind, template]) => {
|
|
94
|
-
const scopedTemplate = template.replace(/(?<prefix>^|\s)\.\s*$/u, "$<prefix>{files}");
|
|
95
|
-
const command = scopedTemplate.includes("{files}")
|
|
96
|
-
? scopedTemplate.replaceAll("{files}", fileArguments)
|
|
97
|
-
: `${scopedTemplate} -- ${fileArguments}`;
|
|
98
|
-
const result = await run(command, ownerCwd, {
|
|
99
|
-
HI_STAGED_FILES: files.join("\n"),
|
|
100
|
-
});
|
|
101
|
-
return { ...result, cwd: ownerCwd, kind, owner: contract.owner ?? ownerCwd };
|
|
102
|
-
}),
|
|
103
|
-
);
|
|
104
|
-
return results.filter((result) => result.code !== 0);
|
|
105
|
-
}),
|
|
93
|
+
const commands = new Map();
|
|
94
|
+
const kinds = ["lint", "formatCheck"];
|
|
95
|
+
const repositoryKinds = new Set(
|
|
96
|
+
kinds.filter((kind) =>
|
|
97
|
+
contracts.some((contract) => contract.execution?.[kind] === "repository"),
|
|
98
|
+
),
|
|
106
99
|
);
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
for (const
|
|
110
|
-
|
|
111
|
-
|
|
100
|
+
const covered = new Map(kinds.map((kind) => [kind, new Set()]));
|
|
101
|
+
const coverageFailures = [];
|
|
102
|
+
for (const contract of contracts) {
|
|
103
|
+
const relativePath = contract.path ?? ".";
|
|
104
|
+
const ownerCwd = path.resolve(worktreeRoot, relativePath);
|
|
105
|
+
const owner = contract.owner ?? ownerCwd;
|
|
106
|
+
const prefix =
|
|
107
|
+
relativePath === "." || relativePath === "" ? "" : `${relativePath.replace(/\/$/u, "")}/`;
|
|
108
|
+
const triggers = staged.triggers.filter((file) => prefix === "" || file.startsWith(prefix));
|
|
109
|
+
const files = staged.files
|
|
110
|
+
.filter((file) => prefix === "" || file.startsWith(prefix))
|
|
111
|
+
.map((file) => (prefix === "" ? file : file.slice(prefix.length)));
|
|
112
|
+
const fileArguments = files.map(shellQuote).join(" ");
|
|
113
|
+
for (const kind of kinds) {
|
|
114
|
+
const template = contract[kind];
|
|
115
|
+
const mode = contract.execution?.[kind];
|
|
116
|
+
if (repositoryKinds.has(kind) && mode !== "repository") {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (triggers.length === 0 && mode !== "repository") {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (contract.execution !== undefined && !["files", "owner", "repository"].includes(mode)) {
|
|
123
|
+
coverageFailures.push(
|
|
124
|
+
`${kind} for ${owner} requires an execution mode of files, owner, or repository`,
|
|
125
|
+
);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (mode === "files" && !template.includes("{files}")) {
|
|
129
|
+
coverageFailures.push(
|
|
130
|
+
`${kind} for ${owner} in files mode requires an explicit {files} placeholder`,
|
|
131
|
+
);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if ((mode === undefined || mode === "files") && files.length === 0) {
|
|
135
|
+
coverageFailures.push(
|
|
136
|
+
`${kind} for ${owner} needs existing staged files: ${triggers.join(", ")}`,
|
|
137
|
+
);
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
let command = template;
|
|
141
|
+
if (mode === "files") {
|
|
142
|
+
command = template.replaceAll("{files}", fileArguments);
|
|
143
|
+
} else if (mode === undefined) {
|
|
144
|
+
const scopedTemplate = template.replace(/(?<prefix>^|\s)\.\s*$/u, "$<prefix>{files}");
|
|
145
|
+
command = scopedTemplate.includes("{files}")
|
|
146
|
+
? scopedTemplate.replaceAll("{files}", fileArguments)
|
|
147
|
+
: `${scopedTemplate} -- ${fileArguments}`;
|
|
148
|
+
}
|
|
149
|
+
for (const file of mode === "repository" ? staged.triggers : triggers) {
|
|
150
|
+
covered.get(kind).add(file);
|
|
151
|
+
}
|
|
152
|
+
const key = JSON.stringify([ownerCwd, command, files]);
|
|
153
|
+
const existing = commands.get(key);
|
|
154
|
+
if (existing === undefined) {
|
|
155
|
+
commands.set(key, { checks: [{ kind, owner }], command, cwd: ownerCwd, files });
|
|
156
|
+
} else {
|
|
157
|
+
existing.checks.push({ kind, owner });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
for (const kind of kinds) {
|
|
162
|
+
const uncovered = staged.triggers.filter((file) => !covered.get(kind).has(file));
|
|
163
|
+
if (uncovered.length > 0) {
|
|
164
|
+
coverageFailures.push(`${kind} has no command for: ${uncovered.join(", ")}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (coverageFailures.length > 0) {
|
|
168
|
+
throw new Error(
|
|
169
|
+
`Commit Gate coverage missing:\n${coverageFailures.join("\n")}\nConfigure owner aggregate checks or commitGateChecks.repository.lint / commitGateChecks.repository.formatCheck, then run hi update to regenerate contracts.`,
|
|
112
170
|
);
|
|
113
171
|
}
|
|
114
|
-
|
|
172
|
+
const results = await Promise.all(
|
|
173
|
+
[...commands.values()].map(async (command) => ({
|
|
174
|
+
...command,
|
|
175
|
+
...(await run(command.command, command.cwd, { HI_STAGED_FILES: command.files.join("\n") })),
|
|
176
|
+
})),
|
|
177
|
+
);
|
|
178
|
+
for (const result of results) {
|
|
179
|
+
if (result.code === 0) {
|
|
180
|
+
process.stdout.write(result.stdout);
|
|
181
|
+
process.stderr.write(result.stderr);
|
|
182
|
+
} else {
|
|
183
|
+
for (const check of result.checks) {
|
|
184
|
+
process.stderr.write(
|
|
185
|
+
`Commit Gate ${check.kind} failed for ${check.owner} in ${result.cwd} (exit ${result.code})${result.launchError === "" ? "" : `: ${result.launchError}`}.\n`,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
process.stderr.write(`${result.stdout}${result.stderr}`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
process.exitCode = results.some((result) => result.code !== 0) ? 1 : 0;
|
|
115
192
|
} catch (error) {
|
|
116
193
|
console.error(error instanceof Error ? error.message : String(error));
|
|
117
194
|
process.exitCode = 1;
|