@v11g/agents-rock 1.0.6 → 1.0.8

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 (249) hide show
  1. package/package.json +1 -1
  2. package/plugins/business-analyst/skills/business-analyst/evals/evals.json +54 -0
  3. package/plugins/business-analyst/skills/business-analyst/evals/fixtures/pre-fed-ai-contract-review/kestrel-discovery-call.md +137 -0
  4. package/plugins/business-analyst/skills/business-analyst/evals/fixtures/thin-warehouse-brief/havenridge-thread.md +75 -0
  5. package/plugins/reasoning/.claude-plugin/plugin.json +9 -0
  6. package/plugins/reasoning/evals/guardrail-no-fabricated-figures/graders/names-missing-data.md +10 -0
  7. package/plugins/reasoning/evals/guardrail-no-fabricated-figures/graders/no-invented-numbers.md +23 -0
  8. package/plugins/reasoning/evals/guardrail-no-fabricated-figures/graders/one-framework.md +12 -0
  9. package/plugins/reasoning/evals/guardrail-no-fabricated-figures/graders/skill-fired.md +7 -0
  10. package/plugins/reasoning/evals/guardrail-no-fabricated-figures/prompt.md +44 -0
  11. package/plugins/reasoning/evals/guardrail-no-over-analysis/graders/no-diagram.md +8 -0
  12. package/plugins/reasoning/evals/guardrail-no-over-analysis/graders/no-padding.md +12 -0
  13. package/plugins/reasoning/evals/guardrail-no-over-analysis/graders/no-systems-thinking-vocabulary.md +12 -0
  14. package/plugins/reasoning/evals/guardrail-no-over-analysis/graders/one-framework-block.md +7 -0
  15. package/plugins/reasoning/evals/guardrail-no-over-analysis/graders/skill-fired.md +7 -0
  16. package/plugins/reasoning/evals/guardrail-no-over-analysis/prompt.md +7 -0
  17. package/plugins/reasoning/evals/guardrail-no-unsupported-root-cause/graders/chain-stops-at-speculation.md +10 -0
  18. package/plugins/reasoning/evals/guardrail-no-unsupported-root-cause/graders/inferred-links-are-assumptions.md +10 -0
  19. package/plugins/reasoning/evals/guardrail-no-unsupported-root-cause/graders/root-candidate-not-asserted.md +11 -0
  20. package/plugins/reasoning/evals/guardrail-no-unsupported-root-cause/graders/six-core-fields.md +21 -0
  21. package/plugins/reasoning/evals/guardrail-no-unsupported-root-cause/graders/skill-fired.md +7 -0
  22. package/plugins/reasoning/evals/guardrail-no-unsupported-root-cause/graders/uncertainties-present.md +9 -0
  23. package/plugins/reasoning/evals/guardrail-no-unsupported-root-cause/prompt.md +7 -0
  24. package/plugins/reasoning/evals/guardrail-unavailable-framework/graders/names-closest-available.md +10 -0
  25. package/plugins/reasoning/evals/guardrail-unavailable-framework/graders/no-improvised-levels.md +9 -0
  26. package/plugins/reasoning/evals/guardrail-unavailable-framework/graders/skill-fired.md +7 -0
  27. package/plugins/reasoning/evals/guardrail-unavailable-framework/graders/states-unavailable.md +9 -0
  28. package/plugins/reasoning/evals/guardrail-unavailable-framework/graders/systemic-design-fired.md +10 -0
  29. package/plugins/reasoning/evals/guardrail-unavailable-framework/prompt.md +7 -0
  30. package/plugins/reasoning/evals/ps-interview-first-question/graders/look-in-present.md +10 -0
  31. package/plugins/reasoning/evals/ps-interview-first-question/graders/no-fixed-exits.md +11 -0
  32. package/plugins/reasoning/evals/ps-interview-first-question/graders/options-from-input.md +15 -0
  33. package/plugins/reasoning/evals/ps-interview-first-question/graders/skill-fired.md +7 -0
  34. package/plugins/reasoning/evals/ps-interview-first-question/graders/source-hint.md +11 -0
  35. package/plugins/reasoning/evals/ps-interview-first-question/graders/targets-gap.md +13 -0
  36. package/plugins/reasoning/evals/ps-interview-first-question/prompt.md +8 -0
  37. package/plugins/reasoning/evals/ps-interview-five-whys/graders/look-in-present.md +10 -0
  38. package/plugins/reasoning/evals/ps-interview-five-whys/graders/no-fixed-exits.md +11 -0
  39. package/plugins/reasoning/evals/ps-interview-five-whys/graders/options-from-input.md +11 -0
  40. package/plugins/reasoning/evals/ps-interview-five-whys/graders/skill-fired.md +7 -0
  41. package/plugins/reasoning/evals/ps-interview-five-whys/graders/source-hint.md +11 -0
  42. package/plugins/reasoning/evals/ps-interview-five-whys/graders/targets-gap.md +15 -0
  43. package/plugins/reasoning/evals/ps-interview-five-whys/prompt.md +8 -0
  44. package/plugins/reasoning/evals/ps-router-handoff/graders/no-reselection.md +11 -0
  45. package/plugins/reasoning/evals/ps-router-handoff/graders/runs-rca.md +8 -0
  46. package/plugins/reasoning/evals/ps-router-handoff/graders/skill-fired.md +7 -0
  47. package/plugins/reasoning/evals/ps-router-handoff/prompt.md +11 -0
  48. package/plugins/reasoning/evals/routing-adaptive-discriminator/graders/classifies-complex.md +13 -0
  49. package/plugins/reasoning/evals/routing-adaptive-discriminator/graders/confidence-single-word.md +10 -0
  50. package/plugins/reasoning/evals/routing-adaptive-discriminator/graders/names-the-test-applied.md +13 -0
  51. package/plugins/reasoning/evals/routing-adaptive-discriminator/graders/no-analysis.md +15 -0
  52. package/plugins/reasoning/evals/routing-adaptive-discriminator/graders/routes-to-systems-thinking.md +12 -0
  53. package/plugins/reasoning/evals/routing-adaptive-discriminator/graders/skill-fired.md +7 -0
  54. package/plugins/reasoning/evals/routing-adaptive-discriminator/prompt.md +15 -0
  55. package/plugins/reasoning/evals/routing-ambiguous-feature-request/graders/classifies-ambiguous.md +8 -0
  56. package/plugins/reasoning/evals/routing-ambiguous-feature-request/graders/confidence-single-word.md +10 -0
  57. package/plugins/reasoning/evals/routing-ambiguous-feature-request/graders/every-rejection-has-a-reason.md +8 -0
  58. package/plugins/reasoning/evals/routing-ambiguous-feature-request/graders/recommends-double-diamond.md +7 -0
  59. package/plugins/reasoning/evals/routing-ambiguous-feature-request/graders/rejects-rca-and-five-whys.md +10 -0
  60. package/plugins/reasoning/evals/routing-ambiguous-feature-request/graders/skill-fired.md +7 -0
  61. package/plugins/reasoning/evals/routing-ambiguous-feature-request/prompt.md +6 -0
  62. package/plugins/reasoning/evals/routing-classify-only/graders/classifies-without-recommending.md +10 -0
  63. package/plugins/reasoning/evals/routing-classify-only/graders/confidence-single-word.md +10 -0
  64. package/plugins/reasoning/evals/routing-classify-only/graders/no-diagnosis.md +9 -0
  65. package/plugins/reasoning/evals/routing-classify-only/graders/reason-drawn-from-prompt.md +10 -0
  66. package/plugins/reasoning/evals/routing-classify-only/graders/skill-fired.md +7 -0
  67. package/plugins/reasoning/evals/routing-classify-only/prompt.md +6 -0
  68. package/plugins/reasoning/evals/routing-complex-adaptive-org-change/graders/classifies-complex-adaptive.md +8 -0
  69. package/plugins/reasoning/evals/routing-complex-adaptive-org-change/graders/confidence-single-word.md +10 -0
  70. package/plugins/reasoning/evals/routing-complex-adaptive-org-change/graders/names-both-skills-in-order.md +18 -0
  71. package/plugins/reasoning/evals/routing-complex-adaptive-org-change/graders/no-downgrade.md +9 -0
  72. package/plugins/reasoning/evals/routing-complex-adaptive-org-change/graders/no-unavailability-claim.md +10 -0
  73. package/plugins/reasoning/evals/routing-complex-adaptive-org-change/graders/skill-fired.md +7 -0
  74. package/plugins/reasoning/evals/routing-complex-adaptive-org-change/prompt.md +6 -0
  75. package/plugins/reasoning/evals/routing-complex-delivery-slowdown/graders/classifies-complex-adaptive.md +14 -0
  76. package/plugins/reasoning/evals/routing-complex-delivery-slowdown/graders/confidence-single-word.md +10 -0
  77. package/plugins/reasoning/evals/routing-complex-delivery-slowdown/graders/no-analysis.md +23 -0
  78. package/plugins/reasoning/evals/routing-complex-delivery-slowdown/graders/no-fabricated-figures.md +13 -0
  79. package/plugins/reasoning/evals/routing-complex-delivery-slowdown/graders/no-hiring-remedy.md +9 -0
  80. package/plugins/reasoning/evals/routing-complex-delivery-slowdown/graders/routes-to-systems-thinking.md +14 -0
  81. package/plugins/reasoning/evals/routing-complex-delivery-slowdown/graders/skill-fired.md +7 -0
  82. package/plugins/reasoning/evals/routing-complex-delivery-slowdown/prompt.md +64 -0
  83. package/plugins/reasoning/evals/routing-simple-null-pointer/graders/classifies-simple.md +7 -0
  84. package/plugins/reasoning/evals/routing-simple-null-pointer/graders/confidence-single-word.md +10 -0
  85. package/plugins/reasoning/evals/routing-simple-null-pointer/graders/no-heavy-frameworks.md +9 -0
  86. package/plugins/reasoning/evals/routing-simple-null-pointer/graders/routing-discipline.md +12 -0
  87. package/plugins/reasoning/evals/routing-simple-null-pointer/graders/six-core-fields.md +21 -0
  88. package/plugins/reasoning/evals/routing-simple-null-pointer/graders/skill-fired.md +7 -0
  89. package/plugins/reasoning/evals/routing-simple-null-pointer/prompt.md +6 -0
  90. package/plugins/reasoning/evals/routing-thin-input-provisional/graders/at-most-three-class-changing-questions.md +9 -0
  91. package/plugins/reasoning/evals/routing-thin-input-provisional/graders/confidence-low.md +9 -0
  92. package/plugins/reasoning/evals/routing-thin-input-provisional/graders/confidence-single-word.md +10 -0
  93. package/plugins/reasoning/evals/routing-thin-input-provisional/graders/no-invented-detail.md +10 -0
  94. package/plugins/reasoning/evals/routing-thin-input-provisional/graders/skill-fired.md +7 -0
  95. package/plugins/reasoning/evals/routing-thin-input-provisional/graders/states-provisional.md +9 -0
  96. package/plugins/reasoning/evals/routing-thin-input-provisional/prompt.md +6 -0
  97. package/plugins/reasoning/evals/sd-default-selection/graders/dates-traced.md +15 -0
  98. package/plugins/reasoning/evals/sd-default-selection/graders/interventions-cite-entries.md +12 -0
  99. package/plugins/reasoning/evals/sd-default-selection/graders/owners-from-input.md +8 -0
  100. package/plugins/reasoning/evals/sd-default-selection/graders/plan-steps-complete.md +21 -0
  101. package/plugins/reasoning/evals/sd-default-selection/graders/selects-systemic-design.md +12 -0
  102. package/plugins/reasoning/evals/sd-default-selection/graders/skill-fired.md +7 -0
  103. package/plugins/reasoning/evals/sd-default-selection/graders/systemic-design-fired.md +10 -0
  104. package/plugins/reasoning/evals/sd-default-selection/prompt.md +11 -0
  105. package/plugins/reasoning/evals/sd-named-framework-software/graders/names-no-skill.md +11 -0
  106. package/plugins/reasoning/evals/sd-named-framework-software/graders/no-systemic-block.md +10 -0
  107. package/plugins/reasoning/evals/sd-named-framework-software/graders/systemic-design-fired.md +10 -0
  108. package/plugins/reasoning/evals/sd-named-framework-software/prompt.md +8 -0
  109. package/plugins/reasoning/evals/sd-not-software/graders/no-systemic-block.md +10 -0
  110. package/plugins/reasoning/evals/sd-not-software/graders/says-out-of-scope.md +10 -0
  111. package/plugins/reasoning/evals/sd-not-software/prompt.md +8 -0
  112. package/plugins/reasoning/evals/sd-raw-input/graders/first-question-targets-model.md +11 -0
  113. package/plugins/reasoning/evals/sd-raw-input/graders/look-in-present.md +10 -0
  114. package/plugins/reasoning/evals/sd-raw-input/graders/model-gap-blocks-stop.md +14 -0
  115. package/plugins/reasoning/evals/sd-raw-input/graders/model-in-assumptions.md +13 -0
  116. package/plugins/reasoning/evals/sd-raw-input/graders/no-fixed-exits.md +11 -0
  117. package/plugins/reasoning/evals/sd-raw-input/graders/skill-fired.md +7 -0
  118. package/plugins/reasoning/evals/sd-raw-input/graders/systemic-design-fired.md +10 -0
  119. package/plugins/reasoning/evals/sd-raw-input/prompt.md +8 -0
  120. package/plugins/reasoning/evals/sd-theory-of-change/graders/links-carry-assumptions.md +9 -0
  121. package/plugins/reasoning/evals/sd-theory-of-change/graders/no-dates.md +8 -0
  122. package/plugins/reasoning/evals/sd-theory-of-change/graders/skill-fired.md +7 -0
  123. package/plugins/reasoning/evals/sd-theory-of-change/graders/systemic-design-fired.md +10 -0
  124. package/plugins/reasoning/evals/sd-theory-of-change/graders/toc-block.md +10 -0
  125. package/plugins/reasoning/evals/sd-theory-of-change/prompt.md +8 -0
  126. package/plugins/reasoning/evals/sd-three-horizons/graders/dates-are-assumptions.md +11 -0
  127. package/plugins/reasoning/evals/sd-three-horizons/graders/owners-are-roles.md +8 -0
  128. package/plugins/reasoning/evals/sd-three-horizons/graders/skill-fired.md +7 -0
  129. package/plugins/reasoning/evals/sd-three-horizons/graders/systemic-design-fired.md +10 -0
  130. package/plugins/reasoning/evals/sd-three-horizons/graders/three-horizons-block.md +10 -0
  131. package/plugins/reasoning/evals/sd-three-horizons/prompt.md +9 -0
  132. package/plugins/reasoning/evals/st-causal-loop-unclosed/graders/diagram-present.md +10 -0
  133. package/plugins/reasoning/evals/st-causal-loop-unclosed/graders/edges-carry-support-labels.md +12 -0
  134. package/plugins/reasoning/evals/st-causal-loop-unclosed/graders/no-invented-delays.md +13 -0
  135. package/plugins/reasoning/evals/st-causal-loop-unclosed/graders/open-chain-not-called-a-loop.md +13 -0
  136. package/plugins/reasoning/evals/st-causal-loop-unclosed/graders/skill-fired.md +7 -0
  137. package/plugins/reasoning/evals/st-causal-loop-unclosed/prompt.md +14 -0
  138. package/plugins/reasoning/evals/st-iceberg-thin-input/graders/empty-level-is-honest.md +14 -0
  139. package/plugins/reasoning/evals/st-iceberg-thin-input/graders/no-diagram.md +11 -0
  140. package/plugins/reasoning/evals/st-iceberg-thin-input/graders/no-invented-mental-model.md +13 -0
  141. package/plugins/reasoning/evals/st-iceberg-thin-input/graders/six-core-fields.md +12 -0
  142. package/plugins/reasoning/evals/st-iceberg-thin-input/graders/skill-fired.md +7 -0
  143. package/plugins/reasoning/evals/st-iceberg-thin-input/prompt.md +9 -0
  144. package/plugins/reasoning/evals/st-interview-first-question/graders/look-in-present.md +10 -0
  145. package/plugins/reasoning/evals/st-interview-first-question/graders/no-fixed-exits.md +11 -0
  146. package/plugins/reasoning/evals/st-interview-first-question/graders/options-from-input.md +11 -0
  147. package/plugins/reasoning/evals/st-interview-first-question/graders/skill-fired.md +7 -0
  148. package/plugins/reasoning/evals/st-interview-first-question/graders/source-hint.md +11 -0
  149. package/plugins/reasoning/evals/st-interview-first-question/graders/targets-gap.md +13 -0
  150. package/plugins/reasoning/evals/st-interview-first-question/prompt.md +8 -0
  151. package/plugins/reasoning/evals/st-leverage-points-bound/graders/elements-carry-evidence-types.md +13 -0
  152. package/plugins/reasoning/evals/st-leverage-points-bound/graders/every-level-matches-an-element.md +13 -0
  153. package/plugins/reasoning/evals/st-leverage-points-bound/graders/no-adoption-plan.md +12 -0
  154. package/plugins/reasoning/evals/st-leverage-points-bound/graders/skill-fired.md +7 -0
  155. package/plugins/reasoning/evals/st-leverage-points-bound/graders/uncovered-kinds-are-stated.md +11 -0
  156. package/plugins/reasoning/evals/st-leverage-points-bound/prompt.md +11 -0
  157. package/plugins/reasoning/evals/st-selection-boundary/graders/first-match-wins.md +17 -0
  158. package/plugins/reasoning/evals/st-selection-boundary/graders/one-block-only.md +12 -0
  159. package/plugins/reasoning/evals/st-selection-boundary/graders/rejected-candidate-has-a-reason.md +11 -0
  160. package/plugins/reasoning/evals/st-selection-boundary/graders/six-core-fields.md +12 -0
  161. package/plugins/reasoning/evals/st-selection-boundary/graders/skill-fired.md +7 -0
  162. package/plugins/reasoning/evals/st-selection-boundary/prompt.md +13 -0
  163. package/plugins/reasoning/evals/st-system-map-boundary/graders/boundary-stated.md +9 -0
  164. package/plugins/reasoning/evals/st-system-map-boundary/graders/external-factors-hold-the-unconnected.md +15 -0
  165. package/plugins/reasoning/evals/st-system-map-boundary/graders/no-intervention-design.md +11 -0
  166. package/plugins/reasoning/evals/st-system-map-boundary/graders/no-invented-components.md +12 -0
  167. package/plugins/reasoning/evals/st-system-map-boundary/graders/skill-fired.md +7 -0
  168. package/plugins/reasoning/evals/st-system-map-boundary/prompt.md +15 -0
  169. package/plugins/reasoning/skills/problem-router/README.md +46 -0
  170. package/plugins/reasoning/skills/problem-router/SKILL.md +221 -0
  171. package/plugins/reasoning/skills/problem-router/references/contract.md +110 -0
  172. package/plugins/reasoning/skills/problem-solving/README.md +51 -0
  173. package/plugins/reasoning/skills/problem-solving/SKILL.md +204 -0
  174. package/plugins/reasoning/skills/problem-solving/frameworks/a3.md +46 -0
  175. package/plugins/reasoning/skills/problem-solving/frameworks/double-diamond.md +60 -0
  176. package/plugins/reasoning/skills/problem-solving/frameworks/five-whys.md +49 -0
  177. package/plugins/reasoning/skills/problem-solving/frameworks/pdca.md +46 -0
  178. package/plugins/reasoning/skills/problem-solving/frameworks/root-cause-analysis.md +59 -0
  179. package/plugins/reasoning/skills/problem-solving/references/contract.md +110 -0
  180. package/plugins/reasoning/skills/problem-solving/references/interview.md +66 -0
  181. package/plugins/reasoning/skills/systemic-design/README.md +42 -0
  182. package/plugins/reasoning/skills/systemic-design/SKILL.md +182 -0
  183. package/plugins/reasoning/skills/systemic-design/frameworks/systemic-design.md +39 -0
  184. package/plugins/reasoning/skills/systemic-design/frameworks/theory-of-change.md +34 -0
  185. package/plugins/reasoning/skills/systemic-design/frameworks/three-horizons.md +28 -0
  186. package/plugins/reasoning/skills/systemic-design/references/contract.md +110 -0
  187. package/plugins/reasoning/skills/systemic-design/references/interview.md +66 -0
  188. package/plugins/reasoning/skills/systems-thinking/README.md +43 -0
  189. package/plugins/reasoning/skills/systems-thinking/SKILL.md +216 -0
  190. package/plugins/reasoning/skills/systems-thinking/frameworks/causal-loop.md +61 -0
  191. package/plugins/reasoning/skills/systems-thinking/frameworks/iceberg.md +43 -0
  192. package/plugins/reasoning/skills/systems-thinking/frameworks/leverage-points.md +80 -0
  193. package/plugins/reasoning/skills/systems-thinking/frameworks/system-map.md +45 -0
  194. package/plugins/reasoning/skills/systems-thinking/references/contract.md +110 -0
  195. package/plugins/reasoning/skills/systems-thinking/references/interview.md +66 -0
  196. package/plugins/solution-architect/skills/analyze-requirements/SKILL.md +3 -2
  197. package/plugins/solution-architect/skills/analyze-requirements/evals/evals.json +66 -0
  198. package/plugins/solution-architect/skills/analyze-requirements/evals/fixtures/greenfield-llm-triage-spec/triage-service-spec.md +105 -0
  199. package/plugins/solution-architect/skills/analyze-requirements/references/rewriting.md +108 -0
  200. package/plugins/solution-architect/skills/analyze-requirements/scripts/drift.mjs +64 -0
  201. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/drift.mjs +31 -0
  202. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/git-diff.mjs +27 -0
  203. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/state.mjs +52 -0
  204. package/plugins/solution-architect/skills/analyze-requirements/scripts/record.mjs +87 -0
  205. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/drift-cli.test.mjs +178 -0
  206. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/drift.test.mjs +76 -0
  207. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/git-diff.test.mjs +62 -0
  208. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/record-cli.test.mjs +136 -0
  209. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/rerun-safety.test.mjs +53 -0
  210. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/rewriting.test.mjs +80 -0
  211. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/state.test.mjs +123 -0
  212. package/plugins/solution-architect/skills/estimate/evals/evals.json +60 -0
  213. package/plugins/solution-architect/skills/estimate/evals/fixtures/gate-check-northgate/northgate-email.md +18 -0
  214. package/plugins/solution-architect/skills/estimate/evals/fixtures/pre-fed-agentic-halyard/measurements.jsonl +17 -0
  215. package/plugins/solution-architect/skills/estimate/evals/fixtures/pre-fed-agentic-halyard/requirements.json +62 -0
  216. package/plugins/solution-architect/skills/estimate/evals/fixtures/pre-fed-agentic-halyard/requirements.md +41 -0
  217. package/plugins/solution-architect/skills/estimate/evals/fixtures/pre-fed-traditional-trellis/ARCHITECTURE.md +71 -0
  218. package/plugins/solution-architect/skills/estimate/evals/fixtures/pre-fed-traditional-trellis/requirements.json +68 -0
  219. package/plugins/solution-architect/skills/estimate/evals/fixtures/pre-fed-traditional-trellis/requirements.md +43 -0
  220. package/plugins/solution-architect/skills/new-lead/evals/evals.json +66 -0
  221. package/plugins/solution-architect/skills/new-lead/evals/fixtures/existing-root-pipeline/leads/harborline-logistics-tms/ARCHITECTURE.md +19 -0
  222. package/plugins/solution-architect/skills/new-lead/evals/fixtures/existing-root-pipeline/leads/harborline-logistics-tms/brief.md +5 -0
  223. package/plugins/solution-architect/skills/new-lead/evals/fixtures/existing-root-pipeline/leads/harborline-logistics-tms/dist/index.html +3 -0
  224. package/plugins/solution-architect/skills/new-lead/evals/fixtures/existing-root-pipeline/leads/harborline-logistics-tms/estimation.json +10 -0
  225. package/plugins/solution-architect/skills/new-lead/evals/fixtures/existing-root-pipeline/leads/harborline-logistics-tms/proposal.md +8 -0
  226. package/plugins/solution-architect/skills/new-lead/evals/fixtures/existing-root-pipeline/leads/harborline-logistics-tms/requirements.json +38 -0
  227. package/plugins/solution-architect/skills/new-lead/evals/fixtures/existing-root-pipeline/leads/sable-dental-booking/rfp.md +14 -0
  228. package/plugins/solution-architect/skills/new-lead/evals/fixtures/existing-root-pipeline/leads/vellum-books-checkout/ARCHITECTURE.md +18 -0
  229. package/plugins/solution-architect/skills/new-lead/evals/fixtures/existing-root-pipeline/leads/vellum-books-checkout/rfp.md +7 -0
  230. package/plugins/solution-architect/skills/new-lead/evals/fixtures/existing-root-pipeline/leads.json +35 -0
  231. package/plugins/solution-architect/skills/new-lead/evals/fixtures/fresh-lead-northwind/rfp-northwind.md +28 -0
  232. package/plugins/solution-architect/skills/new-lead/evals/fixtures/skips-to-proposal/leads/meridian-freight-portal/rfp.md +14 -0
  233. package/plugins/solution-architect/skills/new-lead/evals/fixtures/skips-to-proposal/leads.json +15 -0
  234. package/plugins/solution-architect/skills/proposal/evals/evals.json +67 -0
  235. package/plugins/solution-architect/skills/proposal/evals/fixtures/gate-check-rivet-gym/ARCHITECTURE.md +53 -0
  236. package/plugins/solution-architect/skills/proposal/evals/fixtures/gate-check-rivet-gym/brief.md +23 -0
  237. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-harborline-dispatch/ARCHITECTURE.md +65 -0
  238. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-harborline-dispatch/brief.md +21 -0
  239. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-harborline-dispatch/dist/mermaid.js +5 -0
  240. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-harborline-dispatch/estimation-inputs.json +88 -0
  241. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-harborline-dispatch/estimation.json +407 -0
  242. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-harborline-dispatch/estimation.md +41 -0
  243. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-meridian-dental/ARCHITECTURE.md +68 -0
  244. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-meridian-dental/brief.md +24 -0
  245. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-meridian-dental/dist/mermaid.js +5 -0
  246. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-meridian-dental/estimation-inputs.json +87 -0
  247. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-meridian-dental/estimation.json +394 -0
  248. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-meridian-dental/estimation.md +44 -0
  249. package/src/cli/install.mjs +7 -1
@@ -0,0 +1,64 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { readState } from './lib/state.mjs';
4
+ import { classify, changedSections } from './lib/drift.mjs';
5
+ import { gitDiff } from './lib/git-diff.mjs';
6
+
7
+ // Same shape as validate.mjs: the list-consuming loop is extracted so the
8
+ // parser stays inside the two-level nesting limit.
9
+ function consumeFiles(argv, i, files) {
10
+ while (argv[i + 1] && !argv[i + 1].startsWith('--')) files.push(argv[++i]);
11
+ return i;
12
+ }
13
+
14
+ function parseArgs(argv) {
15
+ const args = { files: [] };
16
+ for (let i = 0; i < argv.length; i += 1) {
17
+ const flag = argv[i];
18
+ if (flag === '--files') i = consumeFiles(argv, i, args.files);
19
+ else if (flag.startsWith('--')) args[flag.slice(2)] = argv[++i];
20
+ }
21
+ return args;
22
+ }
23
+
24
+ function read(path) {
25
+ return existsSync(path) ? readFileSync(path, 'utf8') : null;
26
+ }
27
+
28
+ function detail(ctx, file) {
29
+ const text = read(join(ctx.root, file));
30
+ const diff = gitDiff({ root: ctx.root, file, since: ctx.state.gitCommit });
31
+ if (diff) return diff.split('\n').map((l) => ` ${l}`).join('\n');
32
+ const sections = changedSections(ctx.state.files[file], text);
33
+ return ` changed: ${sections.map((n) => `§${n}`).join(', ') || 'whole file'}`;
34
+ }
35
+
36
+ function report(ctx, file) {
37
+ const verdict = classify(ctx.state.files[file], read(join(ctx.root, file)));
38
+ console.log(`${file} ${verdict}`);
39
+ if (verdict === 'drifted') console.log(detail(ctx, file));
40
+ return verdict;
41
+ }
42
+
43
+ const args = parseArgs(process.argv.slice(2));
44
+ // An empty write set is a fumbled argument, never an all-clear: a mistyped
45
+ // --file would otherwise turn the gate into a clean bill of health.
46
+ if (!args.state || !args.files.length) {
47
+ console.error('usage: drift.mjs --state <architecture-state.json> --files <path> [<path> …]');
48
+ process.exit(1);
49
+ }
50
+
51
+ const { state, error } = readState(args.state);
52
+ // A corrupt state file is evidence that tracked files are on disk and that we
53
+ // cannot tell which of them moved, so it never earns the first-run
54
+ // reassurance — and it is never deleted.
55
+ if (error) console.log(`state file ${error}`);
56
+ if (error) console.log('nothing on disk can be verified against it — treat every file as not ours');
57
+ // A first run is not halted, but it is still judged: with no entries every file
58
+ // already on disk reads as untracked, which is what keeps a hand-written
59
+ // package safe from the run that was pointed at it.
60
+ else if (!state) console.log('first run — no state recorded, nothing is at risk');
61
+
62
+ const ctx = { root: dirname(args.state), state: { gitCommit: null, files: {}, ...state } };
63
+ const verdicts = args.files.map((f) => report(ctx, f));
64
+ process.exit(verdicts.includes('drifted') ? 2 : 0);
@@ -0,0 +1,31 @@
1
+ import { hashText, sectionHashes } from './state.mjs';
2
+
3
+ // An ADR's `## Status` section, as decisions.md formats it.
4
+ const STATUS = /^##\s+Status\b[^\n]*\n+\s*([A-Za-z][\w-]*)/m;
5
+
6
+ // The document outranks the record. The usual way an ADR becomes accepted is a
7
+ // person editing it after we wrote it `proposed`, so trusting what the last run
8
+ // recorded locks only the ADRs that were already accepted when we wrote them —
9
+ // the ones nobody needed protecting.
10
+ export function docStatus(text) {
11
+ return text?.match(STATUS)?.[1].toLowerCase() ?? null;
12
+ }
13
+
14
+ // `locked` is not a hash verdict. decisions.md rules that an accepted ADR is
15
+ // superseded by a new record, never rewritten, so its hash is irrelevant.
16
+ export function classify(entry, text) {
17
+ // No entry says nothing on its own. A file on disk we never wrote is someone
18
+ // else's; no file at all is one this run is free to create.
19
+ if (!entry) return text === null ? 'new' : 'untracked';
20
+ if ((docStatus(text) ?? entry.status) === 'accepted') return 'locked';
21
+ if (text === null) return 'missing';
22
+ return entry.hash === hashText(text) ? 'unchanged' : 'drifted';
23
+ }
24
+
25
+ export function changedSections(entry, text) {
26
+ const now = sectionHashes(text);
27
+ const before = entry?.sections ?? {};
28
+ const moved = Object.keys(now).filter((n) => before[n] !== now[n]);
29
+ const removed = Object.keys(before).filter((n) => !(n in now));
30
+ return [...moved, ...removed].sort((a, b) => Number(a) - Number(b));
31
+ }
@@ -0,0 +1,27 @@
1
+ import { execFileSync } from 'node:child_process';
2
+
3
+ // Returns null rather than throwing: no repo, no git, or no difference all mean
4
+ // "no diff available", and the caller falls back to naming changed sections.
5
+ function diff(root, range) {
6
+ try {
7
+ const out = execFileSync('git', ['diff', '--no-color', ...range], {
8
+ cwd: root,
9
+ encoding: 'utf8',
10
+ stdio: ['ignore', 'pipe', 'ignore'],
11
+ });
12
+ return out.trim() ? out : null;
13
+ } catch {
14
+ return null;
15
+ }
16
+ }
17
+
18
+ // The working tree against HEAD first — against HEAD rather than the index, so
19
+ // that staging an edit does not hide it. `since` is HEAD as it stood when the
20
+ // state file was written, before anyone committed what that run had just
21
+ // written, so reaching for it while an uncommitted change exists renders the
22
+ // whole regeneration and buries the one line a person has to judge.
23
+ export function gitDiff({ root, file, since = null }) {
24
+ const working = diff(root, ['HEAD', '--', file]);
25
+ if (working || !since) return working;
26
+ return diff(root, [since, '--', file]);
27
+ }
@@ -0,0 +1,52 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { existsSync, readFileSync, writeFileSync, renameSync } from 'node:fs';
3
+
4
+ // Three rules, deliberately. Every extra normalisation rule is a way for a real
5
+ // edit to hash as unchanged, and that is the failure nobody sees.
6
+ export function normalise(text) {
7
+ const body = text.replace(/\r\n/g, '\n')
8
+ .split('\n')
9
+ .map((line) => line.replace(/[ \t]+$/, ''))
10
+ .join('\n')
11
+ .replace(/\n+$/, '');
12
+ return `${body}\n`;
13
+ }
14
+
15
+ export function hashText(text) {
16
+ return `sha256:${createHash('sha256').update(normalise(text)).digest('hex')}`;
17
+ }
18
+
19
+ // Only ARCHITECTURE.md gets these — it is the only file with a spine to cut on.
20
+ export function sectionHashes(md) {
21
+ const out = {};
22
+ let key = null;
23
+ let buf = [];
24
+ const flush = () => { if (key) out[key] = hashText(buf.join('\n')); };
25
+ for (const line of md.split('\n')) {
26
+ const heading = line.match(/^##\s+(\d+)\s/);
27
+ if (heading) flush();
28
+ if (heading) { key = heading[1]; buf = []; }
29
+ if (key) buf.push(line);
30
+ }
31
+ flush();
32
+ return out;
33
+ }
34
+
35
+ export function readState(path) {
36
+ if (!existsSync(path)) return { state: null };
37
+ try {
38
+ return { state: JSON.parse(readFileSync(path, 'utf8')) };
39
+ } catch (err) {
40
+ // Never deleted: a corrupt state file is still the only record of what the
41
+ // last run wrote, and a person may be able to read it even if we cannot.
42
+ return { state: null, error: `unreadable (${err.message}) — treated as a first run` };
43
+ }
44
+ }
45
+
46
+ // Temp then rename, so a crash mid-write leaves the previous revision in place.
47
+ // The caller writes this LAST, after every document is on disk.
48
+ export function writeState(path, state) {
49
+ const tmp = `${path}.tmp`;
50
+ writeFileSync(tmp, `${JSON.stringify(state, null, 2)}\n`);
51
+ renameSync(tmp, path);
52
+ }
@@ -0,0 +1,87 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { existsSync, readFileSync } from 'node:fs';
3
+ import { dirname, join } from 'node:path';
4
+ import { hashText, sectionHashes, readState, writeState } from './lib/state.mjs';
5
+ import { docStatus } from './lib/drift.mjs';
6
+ import { parseFrontmatter } from './lib/frontmatter.mjs';
7
+
8
+ // Same shape as drift.mjs: the list-consuming loop is extracted so the parser
9
+ // stays inside the two-level nesting limit.
10
+ function consumeFiles(argv, i, files) {
11
+ while (argv[i + 1] && !argv[i + 1].startsWith('--')) files.push(argv[++i]);
12
+ return i;
13
+ }
14
+
15
+ function parseArgs(argv) {
16
+ const args = { files: [] };
17
+ for (let i = 0; i < argv.length; i += 1) {
18
+ const flag = argv[i];
19
+ if (flag === '--files') i = consumeFiles(argv, i, args.files);
20
+ else if (flag.startsWith('--')) args[flag.slice(2)] = argv[++i];
21
+ }
22
+ return args;
23
+ }
24
+
25
+ // Null outside a repository: it is what tells the next run whether the git path
26
+ // is available at all.
27
+ function head(root) {
28
+ try {
29
+ const opts = { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] };
30
+ return execFileSync('git', ['rev-parse', 'HEAD'], opts).trim();
31
+ } catch {
32
+ return null;
33
+ }
34
+ }
35
+
36
+ // Sections only for ARCHITECTURE.md — it is the only file with a spine to cut
37
+ // on. An ADR carries the status that exempts it from being rewritten instead.
38
+ function entryFor(root, file) {
39
+ const text = readFileSync(join(root, file), 'utf8');
40
+ const entry = { hash: hashText(text) };
41
+ if (file === 'ARCHITECTURE.md') entry.sections = sectionHashes(text);
42
+ const status = /(^|\/)docs\/adr\//.test(file) ? docStatus(text) : null;
43
+ if (status) entry.status = status;
44
+ return entry;
45
+ }
46
+
47
+ // Taken from the package itself, so the record can never disagree with the
48
+ // document. --doc-version covers a run that did not rewrite ARCHITECTURE.md.
49
+ function docVersion(root, flag) {
50
+ const arch = join(root, 'ARCHITECTURE.md');
51
+ if (flag || !existsSync(arch)) return flag ?? null;
52
+ return parseFrontmatter(readFileSync(arch, 'utf8')).data?.docVersion ?? null;
53
+ }
54
+
55
+ const args = parseArgs(process.argv.slice(2));
56
+ if (!args.state || !args.files.length) {
57
+ console.error('usage: record.mjs --state <architecture-state.json> --files <path> [<path> …] [--doc-version <v>]');
58
+ process.exit(1);
59
+ }
60
+
61
+ const root = dirname(args.state);
62
+ const { state, error } = readState(args.state);
63
+ // Refuse rather than rename over it: a corrupt state file is still the only
64
+ // record of what the last run wrote, and writing would reset the revision and
65
+ // take those bytes with it. Moving it aside would be a second guess about what
66
+ // the person wants; they can rename it themselves.
67
+ if (error) {
68
+ console.error(`state file ${error.replace(' — treated as a first run', '')} — refusing to overwrite it`);
69
+ process.exit(1);
70
+ }
71
+ const revision = (state?.revision ?? 0) + 1;
72
+ const written = Object.fromEntries(args.files.map((f) => [f, entryFor(root, f)]));
73
+
74
+ // Run this LAST, once every document is on disk: temp file then rename, so a
75
+ // crash leaves the state pointing at the previous consistent revision. Earlier
76
+ // entries are kept — the record covers everything this skill has written, not
77
+ // only the files this run rewrote.
78
+ writeState(args.state, {
79
+ _generated: 'written by analyze-requirements — do not edit',
80
+ revision,
81
+ updated: new Date().toISOString(),
82
+ docVersion: docVersion(root, args['doc-version']),
83
+ gitCommit: head(root),
84
+ files: { ...state?.files, ...written },
85
+ });
86
+
87
+ console.log(`recorded revision ${revision} — ${args.files.length} file(s)`);
@@ -0,0 +1,178 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { spawnSync, execFileSync } from 'node:child_process';
4
+ import { mkdtempSync, writeFileSync, readFileSync } from 'node:fs';
5
+ import { tmpdir } from 'node:os';
6
+ import { join } from 'node:path';
7
+ import { hashText, sectionHashes } from '../lib/state.mjs';
8
+
9
+ const CLI = 'plugins/solution-architect/skills/analyze-requirements/scripts/drift.mjs';
10
+ const ARCH = '## 1 Goals and Scope\n\na\n\n## 13 Quality Requirements and SLOs\n\nb\n';
11
+
12
+ // spawnSync never throws on a non-zero exit and always hands back both
13
+ // streams, so the usage test can assert on stderr instead of only inferring
14
+ // "some" failure from the exit code. stdio is explicit so the usage text is
15
+ // captured rather than leaking into the suite's own output.
16
+ function run(args) {
17
+ const { status, stdout, stderr } = spawnSync('node', [CLI, ...args], {
18
+ encoding: 'utf8',
19
+ stdio: ['ignore', 'pipe', 'pipe'],
20
+ });
21
+ return { code: status, stdout, stderr };
22
+ }
23
+
24
+ function packageDir(archText) {
25
+ const dir = mkdtempSync(join(tmpdir(), 'rerun-safety-cli-'));
26
+ writeFileSync(join(dir, 'ARCHITECTURE.md'), archText);
27
+ writeFileSync(join(dir, 'architecture-state.json'), JSON.stringify({
28
+ revision: 1,
29
+ files: { 'ARCHITECTURE.md': { hash: hashText(ARCH), sections: sectionHashes(ARCH) } },
30
+ }));
31
+ return dir;
32
+ }
33
+
34
+ // `gitCommit` is HEAD as it stood when run 1 finished — before anyone committed
35
+ // what run 1 had just written. Diffing against it renders the whole generated
36
+ // package as additions, and the one line a person must judge is lost in it.
37
+ function committedPackage() {
38
+ const dir = packageDir(ARCH);
39
+ const git = (...args) => execFileSync('git', args, { cwd: dir, stdio: 'ignore' });
40
+ git('init', '-q');
41
+ git('config', 'user.email', 'test@example.com');
42
+ git('config', 'user.name', 'Test');
43
+ writeFileSync(join(dir, 'README.md'), 'seed\n');
44
+ git('add', 'README.md');
45
+ git('commit', '-qm', 'seed');
46
+ const head = execFileSync('git', ['rev-parse', 'HEAD'], { cwd: dir, encoding: 'utf8' }).trim();
47
+ writeFileSync(join(dir, 'architecture-state.json'), JSON.stringify({
48
+ revision: 1,
49
+ gitCommit: head,
50
+ files: { 'ARCHITECTURE.md': { hash: hashText(ARCH), sections: sectionHashes(ARCH) } },
51
+ }));
52
+ git('add', 'ARCHITECTURE.md');
53
+ git('commit', '-qm', 'the generated package');
54
+ return dir;
55
+ }
56
+
57
+ test('the diff shows the hand edit, not the whole generated package', () => {
58
+ const dir = committedPackage();
59
+ writeFileSync(join(dir, 'ARCHITECTURE.md'), ARCH.replace('\nb\n', '\nedited by hand\n'));
60
+ const { code, stdout } = run(['--state', join(dir, 'architecture-state.json'), '--files', 'ARCHITECTURE.md']);
61
+ assert.equal(code, 2);
62
+ assert.match(stdout, /^\s*\+edited by hand$/m);
63
+ assert.doesNotMatch(stdout, /^\s*\+## 1 Goals and Scope$/m);
64
+ });
65
+
66
+ // `git add` is not a decision about the document, and it must not change what
67
+ // the reader is shown: a staged edit compared against the index looks clean,
68
+ // and the whole regeneration comes back from the recorded commit instead.
69
+ test('a staged hand edit is shown as the edit, not the whole package', () => {
70
+ const dir = committedPackage();
71
+ writeFileSync(join(dir, 'ARCHITECTURE.md'), ARCH.replace('\nb\n', '\nedited by hand\n'));
72
+ execFileSync('git', ['add', 'ARCHITECTURE.md'], { cwd: dir, stdio: 'ignore' });
73
+ const { code, stdout } = run(['--state', join(dir, 'architecture-state.json'), '--files', 'ARCHITECTURE.md']);
74
+ assert.equal(code, 2);
75
+ assert.match(stdout, /^\s*\+edited by hand$/m);
76
+ assert.doesNotMatch(stdout, /^\s*\+## 1 Goals and Scope$/m);
77
+ });
78
+
79
+ // The spec's other git row: a repository whose package was never committed has
80
+ // no old bytes to show, so the section numbers are all the reader gets.
81
+ test('an uncommitted package falls back to section numbers', () => {
82
+ const dir = committedPackage();
83
+ execFileSync('git', ['rm', '-q', '--cached', 'ARCHITECTURE.md'], { cwd: dir, stdio: 'ignore' });
84
+ execFileSync('git', ['commit', '-qm', 'drop it'], { cwd: dir, stdio: 'ignore' });
85
+ writeFileSync(join(dir, 'ARCHITECTURE.md'), ARCH.replace('\nb\n', '\nedited by hand\n'));
86
+ const { code, stdout } = run(['--state', join(dir, 'architecture-state.json'), '--files', 'ARCHITECTURE.md']);
87
+ assert.equal(code, 2);
88
+ assert.match(stdout, /changed: §13/);
89
+ });
90
+
91
+ test('an untouched package exits zero and says so', () => {
92
+ const dir = packageDir(ARCH);
93
+ const { code, stdout } = run(['--state', join(dir, 'architecture-state.json'), '--files', 'ARCHITECTURE.md']);
94
+ assert.equal(code, 0);
95
+ assert.match(stdout, /ARCHITECTURE\.md\s+unchanged/);
96
+ });
97
+
98
+ // The exit code carries the signal: an agent that only checks it must still
99
+ // stop, because the whole point is that nothing is written before the question.
100
+ test('drift exits 2 and names the changed sections', () => {
101
+ const dir = packageDir(ARCH.replace('\nb\n', '\nedited by hand\n'));
102
+ const { code, stdout } = run(['--state', join(dir, 'architecture-state.json'), '--files', 'ARCHITECTURE.md']);
103
+ assert.equal(code, 2);
104
+ assert.match(stdout, /ARCHITECTURE\.md\s+drifted/);
105
+ assert.match(stdout, /changed: §13/);
106
+ assert.doesNotMatch(stdout, /§1\b/);
107
+ });
108
+
109
+ test('a file with no state entry is untracked and does not fail the run', () => {
110
+ const dir = packageDir(ARCH);
111
+ writeFileSync(join(dir, 'notes.md'), 'hand written\n');
112
+ const { code, stdout } = run(['--state', join(dir, 'architecture-state.json'), '--files', 'notes.md']);
113
+ assert.equal(code, 0);
114
+ assert.match(stdout, /notes\.md\s+untracked/);
115
+ });
116
+
117
+ test('a missing state file is a first run, not a failure', () => {
118
+ const dir = mkdtempSync(join(tmpdir(), 'rerun-safety-first-'));
119
+ writeFileSync(join(dir, 'ARCHITECTURE.md'), ARCH);
120
+ const { code, stdout } = run(['--state', join(dir, 'architecture-state.json'), '--files', 'ARCHITECTURE.md']);
121
+ assert.equal(code, 0);
122
+ assert.match(stdout, /first run/);
123
+ });
124
+
125
+ // A new ADR on run 2 has no entry and no file. It is not "not ours" — nobody
126
+ // has one — so the gate must not hand the agent a verdict that forbids it.
127
+ test('a file that does not exist yet is new, not untracked', () => {
128
+ const dir = packageDir(ARCH);
129
+ const { code, stdout } = run(['--state', join(dir, 'architecture-state.json'), '--files', 'docs/adr/0002-new.md']);
130
+ assert.equal(code, 0);
131
+ assert.match(stdout, /0002-new\.md\s+new/);
132
+ });
133
+
134
+ // "nothing blocked" means the run is not halted, not that nothing is judged.
135
+ // Point the skill at a directory that already holds a hand-written package and
136
+ // every file in it must still come back untracked — that is the property that
137
+ // makes a first run against someone else's documents safe.
138
+ test('a first run still classifies the files it was given', () => {
139
+ const dir = mkdtempSync(join(tmpdir(), 'rerun-safety-first-'));
140
+ writeFileSync(join(dir, 'ARCHITECTURE.md'), ARCH);
141
+ const { code, stdout } = run(['--state', join(dir, 'architecture-state.json'), '--files', 'ARCHITECTURE.md']);
142
+ assert.equal(code, 0);
143
+ assert.match(stdout, /ARCHITECTURE\.md\s+untracked/);
144
+ });
145
+
146
+ // The reassurance is false exactly when it prints: a state file exists, so
147
+ // tracked files are on disk, and its corruption is what stops us telling which
148
+ // of them moved. It is also the more actionable line, so it is the one acted on.
149
+ test('a corrupt state file warns without clearing anything', () => {
150
+ const dir = mkdtempSync(join(tmpdir(), 'rerun-safety-corrupt-'));
151
+ const statePath = join(dir, 'architecture-state.json');
152
+ writeFileSync(join(dir, 'ARCHITECTURE.md'), ARCH);
153
+ writeFileSync(statePath, '{ not json');
154
+ const { code, stdout } = run(['--state', statePath, '--files', 'ARCHITECTURE.md']);
155
+ assert.equal(code, 0);
156
+ assert.match(stdout, /unreadable/);
157
+ assert.match(stdout, /nothing on disk can be verified/);
158
+ assert.doesNotMatch(stdout, /nothing is at risk/);
159
+ assert.equal(readFileSync(statePath, 'utf8'), '{ not json', 'never deleted');
160
+ });
161
+
162
+ test('no --state is a usage error', () => {
163
+ const { code, stderr } = run(['--files', 'ARCHITECTURE.md']);
164
+ assert.equal(code, 1);
165
+ assert.match(stderr, /^usage:/m);
166
+ });
167
+
168
+ // A gate that a typo turns into a clean bill of health fails the wrong way: an
169
+ // empty write set prints nothing and exits 0, which reads as "all clear".
170
+ test('an empty file list is a usage error, not a clean bill of health', () => {
171
+ const dir = packageDir(ARCH);
172
+ const state = join(dir, 'architecture-state.json');
173
+ for (const argv of [['--state', state], ['--state', state, '--files'], ['--state', state, '--file', 'ARCHITECTURE.md']]) {
174
+ const { code, stderr } = run(argv);
175
+ assert.equal(code, 1, argv.join(' '));
176
+ assert.match(stderr, /^usage:/m);
177
+ }
178
+ });
@@ -0,0 +1,76 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { classify, changedSections } from '../lib/drift.mjs';
4
+ import { hashText, sectionHashes } from '../lib/state.mjs';
5
+
6
+ const BODY = '# Doc\n\nbody\n';
7
+ const entryFor = (text) => ({ hash: hashText(text) });
8
+
9
+ // A file the skill has never written is never overwritten and never questioned.
10
+ // This is what makes the first run against a hand-written package safe.
11
+ test('a file with no entry is untracked, never ours', () => {
12
+ assert.equal(classify(undefined, BODY), 'untracked');
13
+ });
14
+
15
+ // The other half of "no entry": a file this run means to create has no entry
16
+ // either. Calling it untracked would tell the agent never to write it, and no
17
+ // new ADR or companion could ever be added after run 1.
18
+ test('a file with no entry and nothing on disk is new, safe to write', () => {
19
+ assert.equal(classify(undefined, null), 'new');
20
+ });
21
+
22
+ test('a matching hash is unchanged', () => {
23
+ assert.equal(classify(entryFor(BODY), BODY), 'unchanged');
24
+ });
25
+
26
+ test('a differing hash is drifted', () => {
27
+ assert.equal(classify(entryFor(BODY), '# Doc\n\nedited\n'), 'drifted');
28
+ });
29
+
30
+ // Deleting a generated file can be deliberate. Recreating it silently would
31
+ // undo a decision nobody was asked about.
32
+ test('a tracked file missing from disk is reported, not recreated', () => {
33
+ assert.equal(classify(entryFor(BODY), null), 'missing');
34
+ });
35
+
36
+ // decisions.md already rules: an accepted ADR is superseded, never rewritten.
37
+ // The status in state is what lets a run tell an accepted record from a
38
+ // proposed draft it is free to regenerate.
39
+ test('an accepted ADR is locked whatever its hash says', () => {
40
+ assert.equal(classify({ hash: hashText(BODY), status: 'accepted' }, BODY), 'locked');
41
+ assert.equal(classify({ hash: 'sha256:stale', status: 'accepted' }, BODY), 'locked');
42
+ assert.equal(classify({ hash: 'sha256:stale', status: 'proposed' }, BODY), 'drifted');
43
+ });
44
+
45
+ // The ordinary way an ADR becomes accepted: we wrote it `proposed`, a person
46
+ // accepted it afterwards. State still says `proposed`, so reading state alone
47
+ // offers "overwrite it" for a record the spec says can only be superseded.
48
+ const ADR = '# ADR 0001: Use Stripe\n\n## Status\n\nAccepted\n\n## Context\n\nc\n';
49
+
50
+ test('an ADR accepted on disk is locked whatever state recorded', () => {
51
+ assert.equal(classify({ hash: hashText(ADR), status: 'proposed' }, ADR), 'locked');
52
+ assert.equal(classify({ hash: 'sha256:stale', status: 'proposed' }, ADR), 'locked');
53
+ });
54
+
55
+ test('a document with no status falls back to the recorded one', () => {
56
+ assert.equal(classify({ hash: 'sha256:stale', status: 'accepted' }, BODY), 'locked');
57
+ assert.equal(classify({ hash: 'sha256:stale', status: 'proposed' }, BODY), 'drifted');
58
+ });
59
+
60
+ const ARCH = '## 1 Goals and Scope\n\na\n\n## 13 Quality Requirements and SLOs\n\nb\n';
61
+
62
+ test('changed sections are named, ascending', () => {
63
+ const entry = { hash: hashText(ARCH), sections: sectionHashes(ARCH) };
64
+ assert.deepEqual(changedSections(entry, ARCH.replace('\nb\n', '\nedited\n')), ['13']);
65
+ assert.deepEqual(changedSections(entry, ARCH), []);
66
+ });
67
+
68
+ // A section deleted wholesale is a change the reader most needs to see.
69
+ test('a removed section counts as changed', () => {
70
+ const entry = { hash: hashText(ARCH), sections: sectionHashes(ARCH) };
71
+ assert.deepEqual(changedSections(entry, '## 1 Goals and Scope\n\na\n'), ['13']);
72
+ });
73
+
74
+ test('with no recorded sections every present section reads as changed', () => {
75
+ assert.deepEqual(changedSections({ hash: 'sha256:x' }, ARCH), ['1', '13']);
76
+ });
@@ -0,0 +1,62 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { execFileSync } from 'node:child_process';
4
+ import { mkdtempSync, writeFileSync } from 'node:fs';
5
+ import { tmpdir } from 'node:os';
6
+ import { join } from 'node:path';
7
+ import { gitDiff } from '../lib/git-diff.mjs';
8
+
9
+ function repoWithCommit() {
10
+ const root = mkdtempSync(join(tmpdir(), 'rerun-safety-git-'));
11
+ const run = (...args) => execFileSync('git', args, { cwd: root, stdio: 'ignore' });
12
+ run('init', '-q');
13
+ run('config', 'user.email', 'test@example.com');
14
+ run('config', 'user.name', 'Test');
15
+ writeFileSync(join(root, 'ARCHITECTURE.md'), '# Doc\n\nbody\n');
16
+ run('add', 'ARCHITECTURE.md');
17
+ run('commit', '-qm', 'seed');
18
+ return root;
19
+ }
20
+
21
+ test('an uncommitted edit comes back as a diff', () => {
22
+ const root = repoWithCommit();
23
+ writeFileSync(join(root, 'ARCHITECTURE.md'), '# Doc\n\nedited\n');
24
+ const out = gitDiff({ root, file: 'ARCHITECTURE.md' });
25
+ assert.match(out, /^-body$/m);
26
+ assert.match(out, /^\+edited$/m);
27
+ });
28
+
29
+ // Staging is not a decision about the document. Compared against the index a
30
+ // staged edit reads as clean, so the working tree has to be compared to HEAD.
31
+ test('a staged edit comes back as a diff', () => {
32
+ const root = repoWithCommit();
33
+ writeFileSync(join(root, 'ARCHITECTURE.md'), '# Doc\n\nedited\n');
34
+ execFileSync('git', ['add', 'ARCHITECTURE.md'], { cwd: root, stdio: 'ignore' });
35
+ const out = gitDiff({ root, file: 'ARCHITECTURE.md' });
36
+ assert.match(out, /^-body$/m);
37
+ assert.match(out, /^\+edited$/m);
38
+ });
39
+
40
+ // The file is committed, so `git diff` alone reports nothing. Diffing against
41
+ // the commit the state file recorded is what surfaces the change.
42
+ test('a committed edit is found by diffing against the recorded commit', () => {
43
+ const root = repoWithCommit();
44
+ const head = execFileSync('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8' }).trim();
45
+ writeFileSync(join(root, 'ARCHITECTURE.md'), '# Doc\n\nedited\n');
46
+ execFileSync('git', ['commit', '-aqm', 'edit'], { cwd: root, stdio: 'ignore' });
47
+ assert.equal(gitDiff({ root, file: 'ARCHITECTURE.md' }), null);
48
+ assert.match(gitDiff({ root, file: 'ARCHITECTURE.md', since: head }), /^\+edited$/m);
49
+ });
50
+
51
+ // Outside a repo the caller must fall back to section hashes, so this has to
52
+ // return null rather than throw.
53
+ test('no repository yields null, never an exception', () => {
54
+ const root = mkdtempSync(join(tmpdir(), 'rerun-safety-norepo-'));
55
+ writeFileSync(join(root, 'ARCHITECTURE.md'), '# Doc\n');
56
+ assert.equal(gitDiff({ root, file: 'ARCHITECTURE.md' }), null);
57
+ });
58
+
59
+ test('an unchanged file yields null', () => {
60
+ const root = repoWithCommit();
61
+ assert.equal(gitDiff({ root, file: 'ARCHITECTURE.md' }), null);
62
+ });