@punks/cli 3.2.2 → 3.3.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.
Files changed (98) hide show
  1. package/AGENTS.md +1 -1
  2. package/dist/BASELINE_CHANGELOG.md +43 -0
  3. package/dist/CHANGELOG.md +24 -0
  4. package/dist/baseline/scaffold-baseline/baseline.json +5 -5
  5. package/dist/baseline/scaffold-baseline/data/catalog/lint-assets.json +4 -1
  6. package/dist/baseline/scaffold-baseline/data/catalog/packs.json +5 -2
  7. package/dist/baseline/scaffold-baseline/data/catalog/skills.json +24 -0
  8. package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/post-command-flow.md +6 -1
  9. package/dist/baseline/scaffold-baseline/skills/agnostic/frontend/animate/LICENSE +21 -0
  10. package/dist/baseline/scaffold-baseline/skills/agnostic/frontend/animate/RECIPES.md +333 -0
  11. package/dist/baseline/scaffold-baseline/skills/agnostic/frontend/animate/SKILL.md +203 -0
  12. package/dist/baseline/scaffold-baseline/skills/agnostic/frontend/animate/UPSTREAM.md +9 -0
  13. package/dist/baseline/scaffold-baseline/skills/agnostic/frontend/review-animations/LICENSE +21 -0
  14. package/dist/baseline/scaffold-baseline/skills/agnostic/frontend/review-animations/SKILL.md +112 -0
  15. package/dist/baseline/scaffold-baseline/skills/agnostic/frontend/review-animations/STANDARDS.md +229 -0
  16. package/dist/baseline/scaffold-baseline/skills/agnostic/frontend/review-animations/UPSTREAM.md +9 -0
  17. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-plan/REFERENCE.md +5 -1
  18. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-plan/SKILL.md +8 -6
  19. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-plan/references/planner-task-graph.md +12 -7
  20. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/requirements-grill/SKILL.md +6 -4
  21. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/requirements-grill/references/artifact-output.md +36 -3
  22. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/requirements-grill/references/grilling-flow.md +18 -1
  23. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/EXAMPLES.md +1 -1
  24. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/REFERENCE.md +4 -3
  25. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/SKILL.md +2 -2
  26. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/assets/concepts/backlog-model.md +6 -6
  27. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/assets/providers/azure-devops-create-payload.md +7 -7
  28. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/assets/providers/github-projects-create-payload.md +12 -12
  29. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/assets/providers/linear-create-payload.md +9 -9
  30. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/write-backlog/assets/providers/monday-create-payload.md +10 -10
  31. package/dist/baseline/scaffold-baseline/skills/frameworks/expo/animate-expo/LICENSE +21 -0
  32. package/dist/baseline/scaffold-baseline/skills/frameworks/expo/animate-expo/RECIPES.md +435 -0
  33. package/dist/baseline/scaffold-baseline/skills/frameworks/expo/animate-expo/SKILL.md +255 -0
  34. package/dist/baseline/scaffold-baseline/skills/frameworks/expo/animate-expo/UPSTREAM.md +9 -0
  35. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/review.md +34 -9
  36. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/router.md +18 -11
  37. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/phase-handoff.md +19 -1
  38. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/AUTHORING-HANDOFF.md +14 -11
  39. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/retain-report.md +9 -2
  40. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/return-route.md +6 -8
  41. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/run-review.md +8 -5
  42. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/durable-report.md +29 -14
  43. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/state-graph.md +45 -32
  44. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/targets.md +2 -1
  45. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/scripts/review-contract.mjs +86 -12
  46. package/dist/baseline/scaffold-baseline.json +5 -5
  47. package/dist/baseline/scaffold-baseline.tgz +0 -0
  48. package/dist/data/AGENTS.md +1 -1
  49. package/dist/index.js +10 -10
  50. package/dist/skills/agnostic/cli/hi-cli/references/post-command-flow.md +6 -1
  51. package/dist/skills/agnostic/frontend/animate/LICENSE +21 -0
  52. package/dist/skills/agnostic/frontend/animate/RECIPES.md +324 -0
  53. package/dist/skills/agnostic/frontend/animate/SKILL.md +199 -0
  54. package/dist/skills/agnostic/frontend/animate/UPSTREAM.md +9 -0
  55. package/dist/skills/agnostic/frontend/review-animations/LICENSE +21 -0
  56. package/dist/skills/agnostic/frontend/review-animations/SKILL.md +112 -0
  57. package/dist/skills/agnostic/frontend/review-animations/STANDARDS.md +187 -0
  58. package/dist/skills/agnostic/frontend/review-animations/UPSTREAM.md +9 -0
  59. package/dist/skills/agnostic/planning/create-plan/REFERENCE.md +5 -1
  60. package/dist/skills/agnostic/planning/create-plan/SKILL.md +8 -6
  61. package/dist/skills/agnostic/planning/create-plan/references/planner-task-graph.md +12 -7
  62. package/dist/skills/agnostic/requirements/requirements-grill/SKILL.md +6 -4
  63. package/dist/skills/agnostic/requirements/requirements-grill/references/artifact-output.md +33 -3
  64. package/dist/skills/agnostic/requirements/requirements-grill/references/grilling-flow.md +18 -1
  65. package/dist/skills/agnostic/requirements/write-backlog/EXAMPLES.md +1 -1
  66. package/dist/skills/agnostic/requirements/write-backlog/REFERENCE.md +4 -3
  67. package/dist/skills/agnostic/requirements/write-backlog/SKILL.md +2 -2
  68. package/dist/skills/agnostic/requirements/write-backlog/assets/concepts/backlog-model.md +6 -6
  69. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/azure-devops-create-payload.md +7 -7
  70. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/github-projects-create-payload.md +12 -12
  71. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/linear-create-payload.md +9 -9
  72. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/monday-create-payload.md +10 -10
  73. package/dist/skills/frameworks/expo/animate-expo/LICENSE +21 -0
  74. package/dist/skills/frameworks/expo/animate-expo/RECIPES.md +385 -0
  75. package/dist/skills/frameworks/expo/animate-expo/SKILL.md +255 -0
  76. package/dist/skills/frameworks/expo/animate-expo/UPSTREAM.md +9 -0
  77. package/dist/skills/phases/delivery-phase/phases/review.md +34 -9
  78. package/dist/skills/phases/delivery-phase/phases/router.md +16 -9
  79. package/dist/skills/phases/delivery-phase/references/phase-handoff.md +19 -1
  80. package/dist/skills/phases/review-phase/AUTHORING-HANDOFF.md +14 -11
  81. package/dist/skills/phases/review-phase/phases/retain-report.md +9 -2
  82. package/dist/skills/phases/review-phase/phases/return-route.md +6 -8
  83. package/dist/skills/phases/review-phase/phases/run-review.md +8 -5
  84. package/dist/skills/phases/review-phase/references/durable-report.md +29 -14
  85. package/dist/skills/phases/review-phase/references/state-graph.md +18 -5
  86. package/dist/skills/phases/review-phase/references/targets.md +2 -1
  87. package/dist/skills/phases/review-phase/scripts/review-contract.mjs +91 -11
  88. package/package.json +52 -9
  89. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/adapters/claude.test.ts +0 -130
  90. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/adapters/codex.test.ts +0 -135
  91. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/adapters/cursor.test.ts +0 -138
  92. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/adapters/opencode.test.ts +0 -135
  93. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/contract.test.ts +0 -875
  94. package/dist/baseline/scaffold-baseline/data/scripts/sync-subagents.lifecycle.test.ts +0 -205
  95. package/dist/baseline/scaffold-baseline/data/scripts/sync-subagents.native.test.ts +0 -2765
  96. package/dist/baseline/scaffold-baseline/data/scripts/sync-subagents.test.ts +0 -2108
  97. package/dist/baseline/scaffold-baseline/data/subagents/manifest.test.ts +0 -116
  98. package/dist/skills/frameworks/nestjs/nestjs-best-practices/.gitignore +0 -29
@@ -45,9 +45,14 @@ the fixed wiki values are `review-report`, `project`, and `internal`. Its title
45
45
  uses the derived filename slug; created and updated equal the date in
46
46
  `reviewed_at`. Its lineage, run, mode, timestamp, accepted-bounds identity/hash,
47
47
  and snapshot hash must agree with the JSON authority and recomputed evidence.
48
+ Prototype-sensitive frontmatter keys are malformed and are rejected before any
49
+ assignment. `reviewed_at` must name a real UTC calendar instant. Delivery
50
+ normalization requires a non-empty inclusive scope and delivery-goal identity;
51
+ governing-source normalization requires a non-empty source set.
48
52
 
49
53
  The parsed JSON object is report authority. Detached objects, sidecars, and
50
- caller-supplied derived identities are never trusted. It contains exactly these fields:
54
+ caller-supplied derived identities are never trusted. It contains exactly these
55
+ fields:
51
56
 
52
57
  - `review_lineage_id`
53
58
  - `review_run_id`
@@ -60,8 +65,8 @@ caller-supplied derived identities are never trusted. It contains exactly these
60
65
  - canonical `source_set_hash`
61
66
  - an explicit outcome for Standards, skill adherence and scoped skills,
62
67
  architecture, simplify, and Spec
63
- - stable finding identifiers with severity, location, impact, evidence, and
64
- action
68
+ - stable finding identifiers with severity, location, impact, evidence,
69
+ action, and one `return_route`
65
70
  - routing and validation
66
71
 
67
72
  Delivery mode also records delivery-goal identity, review ordinal, and preceding
@@ -70,16 +75,23 @@ as null or not applicable.
70
75
 
71
76
  `lens_outcomes` has exactly `standards`, `skill_adherence`, `architecture`,
72
77
  `simplify`, and `spec`; each value is `clean` or `findings`. Every finding has
73
- exactly stable `id`, `lens`, `severity`, `location`, `impact`, `evidence`, and
74
- `action`. Finding IDs are unique, severity is `critical`, `high`, `medium`, or
75
- `low`, and each lens outcome agrees with whether that lens has a finding.
78
+ exactly the fields `id`, `lens`, `severity`, `location`, `impact`, `evidence`,
79
+ `action`, and `return_route`. Finding IDs are unique, severity is `critical`,
80
+ `high`, `medium`, or `low`, and each lens outcome agrees with whether that lens
81
+ has a finding. Each finding's `return_route` is exactly `debugging`,
82
+ `implementation`, `debt_follow_up`, or `docs_ingest`.
76
83
 
77
84
  `routing` has exactly `primary` and `secondary_architecture_follow_up`.
78
85
  `primary` is `debugging`, `implementation`, `debt_follow_up`, `docs_ingest`, or
79
- `closeout`; the secondary flag is boolean. `validation` is an array of records
80
- with exactly command, isolation mode, before/after frozen hashes, outcome, and
81
- evidence. Isolation is proven no-write, disposable checkout, or disposable
82
- snapshot. Retained validation records require equal before/after hashes.
86
+ `closeout`; the secondary flag is boolean. Aggregate routing is derived by the
87
+ public `deriveReviewRouting` helper from the complete finding set. Precedence is
88
+ `debugging` > `implementation` > `debt_follow_up` > `docs_ingest`; an empty set
89
+ derives `closeout`, and debt is secondary only beside debugging or
90
+ implementation. A supplied aggregate mismatch is invalid. `validation` is an
91
+ array of records with exactly command, isolation mode, before/after frozen
92
+ hashes, outcome, and evidence. Isolation is proven no-write, disposable
93
+ checkout, or disposable snapshot. Retained validation records require equal
94
+ before/after hashes.
83
95
 
84
96
  Delivery ordinals are 1 through 3. Review 1 has null preceding-repair ordinal;
85
97
  review 2 or 3 records respectively 1 or 2. Standalone delivery-goal identity,
@@ -117,12 +129,15 @@ evidence. A candidate is a valid retained pass only when every predicate holds:
117
129
  snapshot hash, source-set hash, and deterministic report path equal values
118
130
  recomputed from the canonical identity algorithm;
119
131
  3. the outside-envelope report SHA-256 equals the exact retained report blob;
120
- 4. current accepted-bounds, normalized-target, and governing-source hashes still
132
+ 4. bytes resolved from `reportCommitSha:reportPath` are exactly equal to the
133
+ local report bytes; the caller supplies them as `resolvedReportBytes`;
134
+ 5. current accepted-bounds, normalized-target, and governing-source hashes still
121
135
  equal the report values;
122
- 5. the report commit changed the report path and only repository-approved
136
+ 6. the report commit changed the report path and only repository-approved
123
137
  report, navigation, and wiki-log envelope paths;
124
- 6. the approved retained ref contains that exact report commit;
125
- 7. delivery ordinal is an integer from 1 through 3; standalone delivery-only
138
+ 7. the approved retained ref contains that exact report commit with boolean
139
+ `true` containment evidence;
140
+ 8. delivery ordinal is an integer from 1 through 3; standalone delivery-only
126
141
  fields are null.
127
142
 
128
143
  A malformed report, wrong lineage or run id, wrong blob or freshness hash,
@@ -27,11 +27,17 @@ and clean handoff.
27
27
  | `review_routed` | Readonly return | Standalone | Standalone caller | `review_complete` | None | Retained report output and route |
28
28
  | `review_routed` | Resume debug route | Handoff already records run id, debug route, and `debug_active` | `delivery-phase` | `debug_active` | None | Existing atomic handoff; no guard fallthrough |
29
29
  | `review_routed` | Resume implementation route | Handoff already records run id, implementation route, and `repair_active` | `delivery-phase` | `repair_active` | None | Existing atomic handoff; no guard fallthrough |
30
- | `review_routed` | Mixed or single finding route | Runtime evidence exists; run id unrecorded | `delivery-phase` | `debug_active` | Atomic handoff opens corresponding repair | Primary debug route, stable findings, atomic handoff, optional architecture follow-up |
31
- | `review_routed` | Mixed or single finding route | No runtime evidence; in-scope non-runtime blocker exists; run id unrecorded | `delivery-phase` | `repair_active` | Atomic handoff opens corresponding repair | Primary implementation route, stable findings, atomic handoff, optional architecture follow-up |
32
- | `review_routed` | Finding route | No higher blocker; broad architecture debt exists | `delivery-phase` | `debt_follow_up` | None | Debt route and stable findings |
33
- | `review_routed` | No-blocker route | Required documentation remains | `delivery-phase` | `docs_ingest` | None | Report and docs route |
34
- | `review_routed` | No-blocker route | Documentation complete | `delivery-phase` | `closeout` | None | Report and closeout route |
30
+ | `review_routed` | Resume debt follow-up | Handoff already records run id, retained report, stable finding IDs, and `debt_follow_up` | Delivery review handoff | `debt_follow_up` | None | Existing debt keys and artifact; no duplicate capture |
31
+ | `review_routed` | Mixed finding route | Runtime evidence exists; derived primary route is `debugging`; secondary architecture follow-up is true; run id unrecorded | `delivery-phase` | `debt_follow_up` | None | Explicit finding routes, stable findings, post-debt route `debugging` |
32
+ | `review_routed` | Mixed finding route | No runtime evidence; derived primary route is `implementation`; secondary architecture follow-up is true; run id unrecorded | `delivery-phase` | `debt_follow_up` | None | Explicit finding routes, stable findings, post-debt route `implementation` |
33
+ | `review_routed` | Single repair route | Runtime evidence exists; derived primary route is `debugging`; no debt follow-up; run id unrecorded | `delivery-phase` | `debug_active` | Atomic handoff opens corresponding repair | Explicit finding routes, stable findings, atomic handoff |
34
+ | `review_routed` | Single repair route | No runtime evidence; in-scope non-runtime blocker exists; derived primary route is `implementation`; no debt follow-up; run id unrecorded | `delivery-phase` | `repair_active` | Atomic handoff opens corresponding repair | Explicit finding routes, stable findings, atomic handoff |
35
+ | `review_routed` | Finding route | Derived primary route is `debt_follow_up` | `delivery-phase` | `debt_follow_up` | None | Explicit debt routes, stable findings, post-debt route `docs_ingest` or `closeout` |
36
+ | `debt_follow_up` | Debt captured | Every debt key is present; `post_debt_route` is `debugging` | Delivery review handoff | `debug_active` | Open repair after capture exactly once | Retained report commit/path, stable finding IDs, artifact path, captured keys |
37
+ | `debt_follow_up` | Debt captured | Every debt key is present; `post_debt_route` is `implementation` | Delivery review handoff | `repair_active` | Open repair after capture exactly once | Retained report commit/path, stable finding IDs, artifact path, captured keys |
38
+ | `debt_follow_up` | Debt captured | Every debt key is present; `post_debt_route` is `docs_ingest` or `closeout` | Delivery review handoff | `docs_ingest` or `closeout` | None | Retained report commit/path, stable finding IDs, artifact path, captured keys |
39
+ | `review_routed` | Documentation-only findings | Derived primary route is `docs_ingest` | `delivery-phase` | `docs_ingest` | None | Explicit docs routes and stable findings |
40
+ | `review_routed` | Finding-free route | Finding set is empty | `delivery-phase` | `closeout` | None | Report and derived closeout route |
35
41
  | `repair_active` or `debug_active` | Ordinary repair completes | `review_count < 3` | `delivery-phase` | `review_due` | None | Stale prior report, changed target identity, preserved counters |
36
42
  | `repair_active` or `debug_active` | Fix 3 completes | `review_count = 3` and `repair_count = 3` | `delivery-phase` | `focused_validation` | None | Fix-3 changes and required focused validation |
37
43
  | `focused_validation` | Focused validation fails | Repair epoch 3 remains open | `delivery-phase` | `repair_active` or `debug_active` | None; unchanged counters | Failed validation and recorded owning route |
@@ -52,6 +58,13 @@ already-consumed ordinals. Complete the transition only after the write. An
52
58
  already recorded run ID resumes its active state without another increment and
53
59
  cannot fall through to an unrecorded guard.
54
60
 
61
+ Debt capture is also idempotent. The retained report commit, report path, and
62
+ stable finding ID form one key in the goal/spec-linked debt artifact. Resume
63
+ reuses recorded keys, adds only missing keys, and follows durable
64
+ `post_debt_route` without implementing unaccepted debt. Secondary debt records
65
+ `debugging` or `implementation`; primary debt records `docs_ingest` or
66
+ `closeout`. Capture completes before the recorded route opens.
67
+
55
68
  Review 1 may open fix 1, review 2 fix 2, and review 3 fix 3. Fix 3 never opens
56
69
  review 4. A failed focused validation stays in repair epoch 3 until that same
57
70
  validation passes.
@@ -6,7 +6,8 @@ composition, report, routing, and freshness contracts.
6
6
 
7
7
  ## Scope
8
8
 
9
- Record the smallest certain inclusive scope. Full-repository expansion requires
9
+ Record a non-empty, smallest certain inclusive scope in every review mode. A
10
+ zero-artifact bundle is not a review target. Full-repository expansion requires
10
11
  an explicit caller request. Unsupported targets or invalid accepted bounds enter
11
12
  `review_failed` with exact evidence, no report, and no counter change, including
12
13
  when a delivery counter is already 3.
@@ -39,8 +39,15 @@ export const inclusiveScopeHash = (entries) =>
39
39
  export const acceptedBoundsHash = (identity, scopeEntries) =>
40
40
  hashRecord("accepted-bounds", [identity, inclusiveScopeHash(scopeEntries)]);
41
41
 
42
- export const deliveryLineageId = (deliveryGoalIdentity) =>
43
- hashRecord("delivery-lineage", [deliveryGoalIdentity]);
42
+ export const deliveryLineageId = (deliveryGoalIdentity) => {
43
+ if (
44
+ typeof deliveryGoalIdentity !== "string" ||
45
+ deliveryGoalIdentity.length === 0
46
+ ) {
47
+ throw new TypeError("delivery goal identity must be a non-empty string");
48
+ }
49
+ return hashRecord("delivery-lineage", [deliveryGoalIdentity]);
50
+ };
44
51
 
45
52
  export const standaloneLineageId = (locator, boundsHash) =>
46
53
  hashRecord("standalone-lineage", [locator, boundsHash]);
@@ -130,10 +137,23 @@ export const sourceSetHash = (sources) =>
130
137
  .flatMap(({ path, hash }) => [path, hash]),
131
138
  );
132
139
 
133
- export const reviewReportPath = ({ lineageId, reviewedAt, snapshotHash }) => {
134
- if (!/^\d{8}T\d{6}Z$/u.test(reviewedAt)) {
135
- throw new TypeError("reviewedAt must use YYYYMMDDTHHMMSSZ UTC format");
140
+ const assertReviewedAt = (reviewedAt, field) => {
141
+ const match = /^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/u.exec(
142
+ reviewedAt,
143
+ );
144
+ if (!match) {
145
+ throw new TypeError(`${field} must use YYYYMMDDTHHMMSSZ UTC format`);
146
+ }
147
+ const [, year, month, day, hour, minute, second] = match;
148
+ const iso = `${year}-${month}-${day}T${hour}:${minute}:${second}.000Z`;
149
+ const instant = new Date(iso);
150
+ if (Number.isNaN(instant.valueOf()) || instant.toISOString() !== iso) {
151
+ throw new TypeError(`${field} must name a real UTC instant`);
136
152
  }
153
+ };
154
+
155
+ export const reviewReportPath = ({ lineageId, reviewedAt, snapshotHash }) => {
156
+ assertReviewedAt(reviewedAt, "reviewedAt");
137
157
  return `apps/wiki/content/docs/project/reviews/${reviewScopeSlug(lineageId)}-${reviewedAt}-${snapshot12(snapshotHash)}-review-report.md`;
138
158
  };
139
159
 
@@ -165,6 +185,35 @@ const LENS_KEYS = [
165
185
  "simplify",
166
186
  "spec",
167
187
  ];
188
+ const PROTOTYPE_KEYS = new Set(["__proto__", "constructor", "prototype"]);
189
+ const FINDING_ROUTES = [
190
+ "debugging",
191
+ "implementation",
192
+ "debt_follow_up",
193
+ "docs_ingest",
194
+ ];
195
+
196
+ export const deriveReviewRouting = (findings) => {
197
+ if (
198
+ !Array.isArray(findings) ||
199
+ findings.some(
200
+ (finding) =>
201
+ finding === null ||
202
+ typeof finding !== "object" ||
203
+ !FINDING_ROUTES.includes(finding.return_route),
204
+ )
205
+ ) {
206
+ throw new TypeError("invalid finding return route");
207
+ }
208
+ const routes = new Set(findings.map(({ return_route: route }) => route));
209
+ const primary = FINDING_ROUTES.find((route) => routes.has(route)) ?? "closeout";
210
+ return {
211
+ primary,
212
+ secondary_architecture_follow_up:
213
+ routes.has("debt_follow_up") &&
214
+ (primary === "debugging" || primary === "implementation"),
215
+ };
216
+ };
168
217
 
169
218
  const exactKeys = (value, keys) =>
170
219
  value !== null &&
@@ -182,9 +231,7 @@ const sortedUniqueStrings = (values) =>
182
231
  isDeepStrictEqual(values, sortUtf8(values));
183
232
 
184
233
  const reportDate = (reviewedAt) => {
185
- if (!/^\d{8}T\d{6}Z$/u.test(reviewedAt)) {
186
- throw new TypeError("reviewed_at must use YYYYMMDDTHHMMSSZ");
187
- }
234
+ assertReviewedAt(reviewedAt, "reviewed_at");
188
235
  return `${reviewedAt.slice(0, 4)}-${reviewedAt.slice(4, 6)}-${reviewedAt.slice(6, 8)}`;
189
236
  };
190
237
 
@@ -240,11 +287,14 @@ const parseFrontmatter = (text) => {
240
287
  if (!text.startsWith("---\n")) throw new TypeError("missing frontmatter");
241
288
  const close = text.indexOf("\n---\n", 4);
242
289
  if (close < 0) throw new TypeError("unclosed frontmatter");
243
- const frontmatter = {};
290
+ const frontmatter = Object.create(null);
244
291
  for (const line of text.slice(4, close).split("\n")) {
245
292
  const separator = line.indexOf(": ");
246
293
  if (separator < 1) throw new TypeError("malformed frontmatter line");
247
294
  const key = line.slice(0, separator);
295
+ if (PROTOTYPE_KEYS.has(key)) {
296
+ throw new TypeError("prototype-sensitive frontmatter key");
297
+ }
248
298
  if (Object.hasOwn(frontmatter, key)) throw new TypeError("duplicate frontmatter key");
249
299
  const raw = line.slice(separator + 2);
250
300
  frontmatter[key] = raw === "[]" ? [] : JSON.parse(raw);
@@ -288,6 +338,8 @@ export const normalizeReviewTarget = (mode, evidence) => {
288
338
  !nonemptyString(evidence.actualBaseRef) ||
289
339
  !COMMIT_SHA.test(evidence.fixedPointSha) ||
290
340
  !nonemptyString(evidence.headIdentity) ||
341
+ !Array.isArray(evidence.scopeEntries) ||
342
+ evidence.scopeEntries.length === 0 ||
291
343
  !sortedUniqueStrings(sortUtf8(evidence.scopeEntries)) ||
292
344
  !Buffer.isBuffer(evidence.canonicalPatchBytes)
293
345
  ) {
@@ -304,11 +356,18 @@ export const normalizeReviewTarget = (mode, evidence) => {
304
356
  };
305
357
  }
306
358
  if (mode === "standalone") {
359
+ if (
360
+ !Array.isArray(evidence.scopeEntries) ||
361
+ evidence.scopeEntries.length === 0
362
+ ) {
363
+ throw new TypeError("invalid standalone target evidence");
364
+ }
307
365
  const files = orderedFiles(evidence.files);
308
366
  const identities = files.map(({ identity }) => identity);
309
367
  const scope = sortUtf8(evidence.scopeEntries);
310
368
  if (
311
369
  !nonemptyString(evidence.locator) ||
370
+ identities.length === 0 ||
312
371
  !sortedUniqueStrings(identities) ||
313
372
  !files.every(({ bytes }) => Buffer.isBuffer(bytes)) ||
314
373
  !isDeepStrictEqual(scope, identities)
@@ -330,6 +389,7 @@ export const normalizeReviewTarget = (mode, evidence) => {
330
389
  export const normalizeReviewSources = (sources) => {
331
390
  if (
332
391
  !Array.isArray(sources) ||
392
+ sources.length === 0 ||
333
393
  sources.some(
334
394
  ({ path, bytes }) => !nonemptyString(path) || !Buffer.isBuffer(bytes),
335
395
  ) ||
@@ -422,7 +482,12 @@ const validateTargetSchema = (target, mode, errors) => {
422
482
  errors.push("malformed:normalized_target_schema");
423
483
  return;
424
484
  }
425
- if (!nonemptyString(target.locator) || !sortedUniqueStrings(target.inclusive_scope)) {
485
+ if (
486
+ !nonemptyString(target.locator) ||
487
+ !Array.isArray(target.inclusive_scope) ||
488
+ target.inclusive_scope.length === 0 ||
489
+ !sortedUniqueStrings(target.inclusive_scope)
490
+ ) {
426
491
  errors.push("malformed:normalized_target_common_fields");
427
492
  }
428
493
  if (mode === "delivery") {
@@ -472,6 +537,7 @@ const validateReportSemantics = (report, errors) => {
472
537
  "impact",
473
538
  "evidence",
474
539
  "action",
540
+ "return_route",
475
541
  ];
476
542
  const ids = new Set();
477
543
  const findingLenses = new Set();
@@ -514,6 +580,14 @@ const validateReportSemantics = (report, errors) => {
514
580
  typeof report.routing?.secondary_architecture_follow_up !== "boolean"
515
581
  ) {
516
582
  errors.push("malformed:routing");
583
+ } else {
584
+ try {
585
+ if (!isDeepStrictEqual(report.routing, deriveReviewRouting(report.findings))) {
586
+ errors.push("mismatch:routing");
587
+ }
588
+ } catch {
589
+ errors.push("malformed:finding_return_route");
590
+ }
517
591
  }
518
592
 
519
593
  const validationKeys = [
@@ -708,7 +782,13 @@ const inspectRetainedPass = (candidate, expected) => {
708
782
  ) {
709
783
  errors.push("mismatch:report_sha256");
710
784
  }
711
- if (!candidate.refContainsCommit) errors.push("ref_missing_commit");
785
+ if (
786
+ !Buffer.isBuffer(candidate.resolvedReportBytes) ||
787
+ !candidate.reportBytes.equals(candidate.resolvedReportBytes)
788
+ ) {
789
+ errors.push("mismatch:resolved_report_bytes");
790
+ }
791
+ if (candidate.refContainsCommit !== true) errors.push("ref_missing_commit");
712
792
  if (!COMMIT_SHA.test(candidate.reportCommitSha)) {
713
793
  errors.push("invalid:report_commit_sha");
714
794
  }
package/package.json CHANGED
@@ -1,22 +1,65 @@
1
1
  {
2
2
  "name": "@punks/cli",
3
- "version": "3.2.2",
3
+ "version": "3.3.0",
4
4
  "description": "Harness Intelligence scaffolding CLI",
5
- "bin": {
6
- "hi": "dist/index.js",
7
- "hint": "dist/index.js"
8
- },
9
- "type": "module",
10
5
  "homepage": "https://github.com/wearedevpunks/harness-intelligence/tree/main/apps/cli#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/wearedevpunks/harness-intelligence/issues"
8
+ },
11
9
  "repository": {
12
10
  "type": "git",
13
11
  "url": "git+https://github.com/wearedevpunks/harness-intelligence.git",
14
12
  "directory": "apps/cli"
15
13
  },
16
- "bugs": {
17
- "url": "https://github.com/wearedevpunks/harness-intelligence/issues"
14
+ "bin": {
15
+ "hi": "dist/index.js",
16
+ "hint": "dist/index.js"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md",
21
+ "AGENTS.md"
22
+ ],
23
+ "type": "module",
24
+ "scripts": {
25
+ "build": "\"${HI_TEST_NODE_PATH:-node}\" ./scripts/build-dist.mjs",
26
+ "baseline:build": "bun ./scripts/build-baseline.mjs",
27
+ "baseline:publish": "node ./scripts/publish-baseline.mjs",
28
+ "baseline:rollback": "node ./scripts/rollback-baseline.mjs",
29
+ "check-types": "\"${HI_TEST_NODE_PATH:-node}\" --input-type=module -e \"await import(new URL('./bin/tsc', import.meta.resolve('@typescript/native/package.json')))\" -- tsc --noEmit",
30
+ "dev": "bun run ./src/index.ts scaffold",
31
+ "entrypoints": "bun ./scripts/print-entrypoints.mjs",
32
+ "local": "bun run build && bun run ./dist/index.js",
33
+ "release:authority": "cd ../.. && node ./apps/cli/scripts/run-release-authority.mjs",
34
+ "release:candidate": "cd ../.. && node ./apps/cli/scripts/run-release-candidate.mjs",
35
+ "release:classify": "cd ../.. && node ./apps/cli/scripts/classify-release-impact.mjs",
36
+ "release:publish": "node ./scripts/release-dispatcher.mjs",
37
+ "release:publish:beta": "NPM_TAG=beta node ./scripts/release-dispatcher.mjs",
38
+ "release:publication": "cd ../.. && node ./apps/cli/scripts/run-release-publication.mjs",
39
+ "sync:skills": "node ./scripts/sync-skills-repo.mjs",
40
+ "test": "vitest run --config vitest.config.ts",
41
+ "test:parallel": "vitest run --config vitest.config.ts --fileParallelism --maxWorkers=2",
42
+ "ui:catalog": "bun ./scripts/run-renderer-catalog.mjs",
43
+ "lint": "oxlint src scripts",
44
+ "check": "bun run lint && oxfmt --check src scripts package.json tsconfig.json vitest.config.ts"
18
45
  },
19
46
  "dependencies": {
20
47
  "react-devtools-core": "^6.1.5"
21
- }
48
+ },
49
+ "devDependencies": {
50
+ "@effect/eslint-plugin": "latest",
51
+ "@effect/platform-bun": "catalog:",
52
+ "@effect/vitest": "catalog:",
53
+ "@oxlint/plugins": "latest",
54
+ "@punks/contract": "workspace:*",
55
+ "@punks/env": "workspace:*",
56
+ "@punks/scaffold": "workspace:*",
57
+ "@types/node": "catalog:",
58
+ "effect": "catalog:",
59
+ "oxlint": "latest",
60
+ "typescript": "catalog:",
61
+ "ultracite": "latest",
62
+ "vitest": "catalog:"
63
+ },
64
+ "packageManager": "bun@1.3.5"
22
65
  }
@@ -1,130 +0,0 @@
1
- import { readFileSync } from "node:fs";
2
-
3
- import { ContextPlan } from "@punks/scaffold/context-plan";
4
- import * as EffectVitest from "@effect/vitest";
5
- import * as Schema from "effect/Schema";
6
-
7
- import { testHarnessProjectionContract } from "../contract";
8
- import type { HarnessProjectionAdapter } from "../contract";
9
- import { project } from "../core.mjs";
10
-
11
- const { describe, expect, it } = EffectVitest;
12
-
13
- const { claudeAdapter } = (await import(new URL("claude.mjs", import.meta.url).href)) as {
14
- readonly claudeAdapter: HarnessProjectionAdapter;
15
- };
16
-
17
- const fixture = <Value>(name: string): Value =>
18
- JSON.parse(
19
- readFileSync(new URL(`../test-fixtures/claude/${name}.json`, import.meta.url), "utf-8"),
20
- ) as Value;
21
-
22
- const contextPlan = Schema.decodeUnknownSync(ContextPlan)(fixture("context-plan"));
23
-
24
- testHarnessProjectionContract({ adapter: claudeAdapter, contextPlan, name: "claude" });
25
-
26
- describe("Claude harness projection adapter", () => {
27
- it("locks the exact five-row capability matrix as a compatibility fixture", () => {
28
- expect(claudeAdapter.matrix).toEqual(fixture("matrix"));
29
- expect(JSON.stringify(claudeAdapter.matrix)).toBe(JSON.stringify(fixture("matrix")));
30
- });
31
-
32
- it("projects compiler-shaped contributions into collision-free native intents", () => {
33
- const result = project({ adapter: claudeAdapter, contextPlan });
34
- const intents = result.actions.map(({ trace: _trace, ...intent }) => intent);
35
- const targets = intents.flatMap((intent) =>
36
- "target" in intent && typeof intent.target === "string" ? [intent.target] : [],
37
- );
38
-
39
- expect(intents).toEqual(fixture("actions"));
40
- expect(JSON.stringify(intents)).toBe(JSON.stringify(fixture("actions")));
41
- expect(new Set(targets).size).toBe(targets.length);
42
- expect(result.actions.map(({ trace }) => [trace.scopeId, trace.contribution.id])).toEqual(
43
- fixture("traces"),
44
- );
45
- });
46
-
47
- it("renders each canonical subagent contribution to its own Claude file", () => {
48
- const templates = project({ adapter: claudeAdapter, contextPlan }).actions.filter(
49
- (action) => action.operation === "render-template",
50
- );
51
-
52
- expect(templates).toMatchObject([
53
- {
54
- filename: "apps-cli.md",
55
- skills: ["effect-authoring", "tdd"],
56
- target: ".claude/agents/apps-cli.md",
57
- templateId: "apps-cli",
58
- },
59
- {
60
- filename: "code-review.md",
61
- skills: ["tdd"],
62
- target: ".claude/agents/code-review.md",
63
- templateId: "code-review",
64
- },
65
- ]);
66
- });
67
-
68
- it("records every real tool contribution as a typed canonical omission", () => {
69
- const { summary } = project({ adapter: claudeAdapter, contextPlan });
70
-
71
- expect(summary).toMatchObject({
72
- _tag: "HarnessProjectionPartial",
73
- omissions: ["agent-browser", "opensrc", "portless", "skills"].map((id) => ({
74
- _tag: "HarnessProjectionOmission",
75
- support: "unsupported",
76
- trace: {
77
- adapter: { id: "claude", version: "1.0.0" },
78
- contribution: { id, version: "2026.07.17" },
79
- matrixVersion: "2026.07.17-v1",
80
- scopeId: "root",
81
- },
82
- warning: {
83
- _tag: "UnsupportedHarnessCapabilityWarning",
84
- family: "tool-configuration",
85
- reason: "Harness tool configuration is not projected into Claude settings",
86
- },
87
- })),
88
- });
89
- });
90
-
91
- it("returns unsupported for unknown lifecycle hook IDs while preserving known hooks", () => {
92
- const capability = claudeAdapter.matrix.capabilities.find(
93
- ({ family }) => family === "lifecycle-hook",
94
- );
95
- const knownHooks = contextPlan.scopes
96
- .flatMap(({ contributions }) => contributions)
97
- .filter(({ kind }) => kind === "lifecycle-hook");
98
- if (capability === undefined) {
99
- throw new Error("Claude lifecycle-hook capability is missing");
100
- }
101
-
102
- expect(knownHooks.map(({ identity }) => identity.id)).toEqual([
103
- "format-edited-file",
104
- "scaffold-update-check",
105
- ]);
106
- for (const contribution of knownHooks) {
107
- expect(claudeAdapter.project({ capability, contribution, scopeId: "root" })).toBeInstanceOf(
108
- Array,
109
- );
110
- }
111
-
112
- expect(
113
- claudeAdapter.project({
114
- capability,
115
- contribution: {
116
- compatibility: [],
117
- identity: { id: "unknown-hook", version: "2026.07.28" },
118
- kind: "lifecycle-hook",
119
- order: 99,
120
- provenance: { revision: "2026.07.28", source: "bundled" },
121
- references: [],
122
- },
123
- scopeId: "root",
124
- }),
125
- ).toEqual({
126
- _tag: "HarnessProjectionUnsupported",
127
- reason: "Claude lifecycle hook unknown-hook has no native projection",
128
- });
129
- });
130
- });
@@ -1,135 +0,0 @@
1
- import { readFileSync } from "node:fs";
2
-
3
- import { ContextPlan } from "@punks/scaffold/context-plan";
4
- import * as EffectVitest from "@effect/vitest";
5
- import * as Schema from "effect/Schema";
6
-
7
- import { testHarnessProjectionContract } from "../contract";
8
- import type { HarnessProjectionAdapter } from "../contract";
9
- import { project } from "../core.mjs";
10
-
11
- const { describe, expect, it } = EffectVitest;
12
-
13
- const { codexAdapter } = (await import(new URL("codex.mjs", import.meta.url).href)) as {
14
- readonly codexAdapter: HarnessProjectionAdapter;
15
- };
16
-
17
- const fixture = <Value>(name: string): Value =>
18
- JSON.parse(
19
- readFileSync(new URL(`../test-fixtures/codex/${name}.json`, import.meta.url), "utf-8"),
20
- ) as Value;
21
-
22
- const contextPlan = Schema.decodeUnknownSync(ContextPlan)(fixture("context-plan"));
23
-
24
- testHarnessProjectionContract({ adapter: codexAdapter, contextPlan, name: "codex" });
25
-
26
- describe("Codex harness projection adapter", () => {
27
- it("locks the exact five-row capability matrix as a compatibility fixture", () => {
28
- expect(codexAdapter.matrix).toEqual(fixture("matrix"));
29
- expect(JSON.stringify(codexAdapter.matrix)).toBe(JSON.stringify(fixture("matrix")));
30
- });
31
-
32
- it("projects compiler-shaped contributions into collision-free native intents", () => {
33
- const result = project({ adapter: codexAdapter, contextPlan });
34
- const intents = result.actions.map(({ trace: _trace, ...intent }) => intent);
35
- const targets = intents.flatMap((intent) =>
36
- "target" in intent && typeof intent.target === "string" ? [intent.target] : [],
37
- );
38
-
39
- expect(intents).toEqual(fixture("actions"));
40
- expect(JSON.stringify(intents)).toBe(JSON.stringify(fixture("actions")));
41
- expect(new Set(targets).size).toBe(targets.length);
42
- expect(result.actions.map(({ trace }) => [trace.scopeId, trace.contribution.id])).toEqual(
43
- fixture("traces"),
44
- );
45
- });
46
-
47
- it("links skills only inside their specific Codex subagent TOML render", () => {
48
- const { actions } = project({ adapter: codexAdapter, contextPlan });
49
- const skillActions = actions.filter((action) => action.operation === "use-native-skill");
50
- const templates = actions.filter((action) => action.operation === "render-template");
51
-
52
- expect(skillActions).toHaveLength(4);
53
- expect(skillActions.every((action) => !("target" in action))).toBe(true);
54
- expect(templates).toMatchObject([
55
- {
56
- filename: "apps-cli.toml",
57
- skills: [
58
- { id: "effect-authoring", path: "../../.agents/skills/effect-authoring" },
59
- { id: "tdd", path: "../../.agents/skills/tdd" },
60
- ],
61
- target: ".codex/agents/apps-cli.toml",
62
- templateId: "apps-cli",
63
- },
64
- {
65
- filename: "code-review.toml",
66
- skills: [{ id: "tdd", path: "../../.agents/skills/tdd" }],
67
- target: ".codex/agents/code-review.toml",
68
- templateId: "code-review",
69
- },
70
- ]);
71
- });
72
-
73
- it("records every real tool contribution as a typed canonical omission", () => {
74
- const { summary } = project({ adapter: codexAdapter, contextPlan });
75
-
76
- expect(summary).toMatchObject({
77
- _tag: "HarnessProjectionPartial",
78
- omissions: ["agent-browser", "opensrc", "portless", "skills"].map((id) => ({
79
- _tag: "HarnessProjectionOmission",
80
- support: "unsupported",
81
- trace: {
82
- adapter: { id: "codex", version: "1.0.0" },
83
- contribution: { id, version: "2026.07.17" },
84
- matrixVersion: "2026.07.17-v1",
85
- scopeId: "root",
86
- },
87
- warning: {
88
- _tag: "UnsupportedHarnessCapabilityWarning",
89
- family: "tool-configuration",
90
- reason: "Harness tool configuration is not projected into Codex config",
91
- },
92
- })),
93
- });
94
- });
95
-
96
- it("returns unsupported for unknown lifecycle hook IDs while preserving known hooks", () => {
97
- const capability = codexAdapter.matrix.capabilities.find(
98
- ({ family }) => family === "lifecycle-hook",
99
- );
100
- const knownHooks = contextPlan.scopes
101
- .flatMap(({ contributions }) => contributions)
102
- .filter(({ kind }) => kind === "lifecycle-hook");
103
- if (capability === undefined) {
104
- throw new Error("Codex lifecycle-hook capability is missing");
105
- }
106
-
107
- expect(knownHooks.map(({ identity }) => identity.id)).toEqual([
108
- "format-edited-file",
109
- "scaffold-update-check",
110
- ]);
111
- for (const contribution of knownHooks) {
112
- expect(codexAdapter.project({ capability, contribution, scopeId: "root" })).toBeInstanceOf(
113
- Array,
114
- );
115
- }
116
-
117
- expect(
118
- codexAdapter.project({
119
- capability,
120
- contribution: {
121
- compatibility: [],
122
- identity: { id: "unknown-hook", version: "2026.07.28" },
123
- kind: "lifecycle-hook",
124
- order: 99,
125
- provenance: { revision: "2026.07.28", source: "bundled" },
126
- references: [],
127
- },
128
- scopeId: "root",
129
- }),
130
- ).toEqual({
131
- _tag: "HarnessProjectionUnsupported",
132
- reason: "Codex lifecycle hook unknown-hook has no native projection",
133
- });
134
- });
135
- });