openplanr 3.0.0 → 3.1.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 (233) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/cli/commands/init-deterministic.d.ts.map +1 -1
  3. package/dist/cli/commands/init-deterministic.js +49 -6
  4. package/dist/cli/commands/init-deterministic.js.map +1 -1
  5. package/dist/cli/commands/upgrade.d.ts.map +1 -1
  6. package/dist/cli/commands/upgrade.js +4 -2
  7. package/dist/cli/commands/upgrade.js.map +1 -1
  8. package/dist/dashboard/.vite/manifest.json +2 -2
  9. package/dist/dashboard/assets/{index-Bk8DyO_2.css → index-BU5fzjyz.css} +1 -1
  10. package/dist/dashboard/assets/index-G7ygVDGg.js +572 -0
  11. package/dist/dashboard/assets/index-G7ygVDGg.js.map +1 -0
  12. package/dist/dashboard/dashboard-manifest.json +14 -14
  13. package/dist/dashboard/index.html +2 -2
  14. package/dist/models/types.d.ts +0 -46
  15. package/dist/models/types.d.ts.map +1 -1
  16. package/dist/services/capability-map-service.d.ts +4 -0
  17. package/dist/services/capability-map-service.d.ts.map +1 -1
  18. package/dist/services/capability-map-service.js +7 -1
  19. package/dist/services/capability-map-service.js.map +1 -1
  20. package/dist/services/claude-plugin-service.d.ts +15 -1
  21. package/dist/services/claude-plugin-service.d.ts.map +1 -1
  22. package/dist/services/claude-plugin-service.js +66 -15
  23. package/dist/services/claude-plugin-service.js.map +1 -1
  24. package/dist/services/config-service.d.ts +24 -1
  25. package/dist/services/config-service.d.ts.map +1 -1
  26. package/dist/services/config-service.js +69 -2
  27. package/dist/services/config-service.js.map +1 -1
  28. package/dist/services/git-service.d.ts +5 -0
  29. package/dist/services/git-service.d.ts.map +1 -1
  30. package/dist/services/git-service.js +27 -0
  31. package/dist/services/git-service.js.map +1 -1
  32. package/dist/services/linear-pull-service.d.ts.map +1 -1
  33. package/dist/services/linear-pull-service.js +1 -2
  34. package/dist/services/linear-pull-service.js.map +1 -1
  35. package/dist/services/pipeline-package-service.d.ts +2 -0
  36. package/dist/services/pipeline-package-service.d.ts.map +1 -1
  37. package/dist/services/pipeline-package-service.js +2 -1
  38. package/dist/services/pipeline-package-service.js.map +1 -1
  39. package/dist/services/runtime-change-summary.d.ts.map +1 -1
  40. package/dist/services/runtime-change-summary.js +4 -0
  41. package/dist/services/runtime-change-summary.js.map +1 -1
  42. package/dist/services/runtime-manager-service.d.ts.map +1 -1
  43. package/dist/services/runtime-manager-service.js +14 -3
  44. package/dist/services/runtime-manager-service.js.map +1 -1
  45. package/dist/services/spec-service.d.ts.map +1 -1
  46. package/dist/services/spec-service.js +11 -22
  47. package/dist/services/spec-service.js.map +1 -1
  48. package/dist/services/upgrade-report.d.ts.map +1 -1
  49. package/dist/services/upgrade-report.js +5 -2
  50. package/dist/services/upgrade-report.js.map +1 -1
  51. package/dist/services/upgrade-service.d.ts +14 -0
  52. package/dist/services/upgrade-service.d.ts.map +1 -1
  53. package/dist/services/upgrade-service.js +69 -11
  54. package/dist/services/upgrade-service.js.map +1 -1
  55. package/dist/templates/rules/shared/capability-map.md.hbs +2 -2
  56. package/lib/host-packages/adapter-registry.json +5 -5
  57. package/lib/host-packages/capability-map.json +89 -29
  58. package/lib/host-packages/claude/.claude-plugin/marketplace.json +2 -2
  59. package/lib/host-packages/claude/openplanr/.claude-plugin/plugin.json +1 -1
  60. package/lib/host-packages/claude/openplanr/.openplanr-content.json +70 -38
  61. package/lib/host-packages/claude/openplanr/CONNECTORS.md +62 -0
  62. package/lib/host-packages/claude/openplanr/README.md +1 -1
  63. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-share.mjs +1 -1
  64. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-protocol-contracts-31a760fc.mjs +259 -36
  65. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +54 -54
  66. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/lib/artifact/ui/studio-shell.css +1 -1
  67. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +259 -36
  68. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +4 -4
  69. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/package.json +3 -3
  70. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +43 -24
  71. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/03-react-dom-client-fiber-foundations.js +279 -58
  72. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/04-react-dom-client-reconciliation-hooks.js +50 -42
  73. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/05-react-dom-client-render-phases.js +282 -146
  74. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/06-react-dom-client-commit-effects.js +949 -316
  75. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/07-react-dom-client-work-loop-scheduling.js +143 -87
  76. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/08-react-dom-client-dom-events-properties-hydration.js +930 -183
  77. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +17 -15
  78. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/14-interface-primitives.js +375 -191
  79. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-interface-primitives.js +140 -105
  80. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/16-studio-shell.js +146 -54
  81. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +25 -25
  82. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +8 -4
  83. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +259 -36
  84. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +8 -4
  85. package/lib/host-packages/claude/openplanr/skills/connect/SKILL.md +60 -0
  86. package/lib/host-packages/claude/openplanr/skills/connect/references/connectors.md +62 -0
  87. package/lib/host-packages/claude/openplanr/skills/openplanr/SKILL.md +4 -0
  88. package/lib/host-packages/claude/openplanr/skills/plan/SKILL.md +4 -1
  89. package/lib/host-packages/claude/openplanr/skills/plan/scripts/planning-ids.mjs +49 -3
  90. package/lib/host-packages/claude/openplanr/skills/share/SKILL.md +87 -0
  91. package/lib/host-packages/claude/openplanr/skills/share/references/connectors.md +62 -0
  92. package/lib/host-packages/claude/openplanr/skills/ship/SKILL.md +6 -3
  93. package/lib/host-packages/claude/openplanr/skills/ship/scripts/discover-verification.mjs +2 -1
  94. package/lib/host-packages/claude/openplanr/skills/sprint/SKILL.md +15 -6
  95. package/lib/host-packages/claude/openplanr/skills/sprint/references/connectors.md +62 -0
  96. package/lib/host-packages/claude/openplanr/skills/sprint/references/tracker-connections.md +9 -13
  97. package/lib/host-packages/claude/openplanr/skills/status/SKILL.md +14 -3
  98. package/lib/host-packages/claude/openplanr/skills/status/references/connectors.md +62 -0
  99. package/lib/host-packages/claude/openplanr/skills/status/references/tracker-connections.md +9 -13
  100. package/lib/host-packages/claude/openplanr/skills/sync/SKILL.md +25 -10
  101. package/lib/host-packages/claude/openplanr/skills/sync/references/connectors.md +62 -0
  102. package/lib/host-packages/claude/openplanr/skills/sync/references/tracker-connections.md +9 -13
  103. package/lib/host-packages/cursor/openplanr/.openplanr-content.json +69 -37
  104. package/lib/host-packages/cursor/openplanr/CONNECTORS.md +62 -0
  105. package/lib/host-packages/cursor/openplanr/manifest.json +4 -2
  106. package/lib/host-packages/cursor/openplanr/rules/planr-connect/references/connectors.md +62 -0
  107. package/lib/host-packages/cursor/openplanr/rules/planr-connect.mdc +58 -0
  108. package/lib/host-packages/cursor/openplanr/rules/planr-openplanr.mdc +4 -0
  109. package/lib/host-packages/cursor/openplanr/rules/planr-plan/scripts/planning-ids.mjs +49 -3
  110. package/lib/host-packages/cursor/openplanr/rules/planr-plan.mdc +4 -1
  111. package/lib/host-packages/cursor/openplanr/rules/planr-share/references/connectors.md +62 -0
  112. package/lib/host-packages/cursor/openplanr/rules/planr-share.mdc +85 -0
  113. package/lib/host-packages/cursor/openplanr/rules/planr-ship/scripts/discover-verification.mjs +2 -1
  114. package/lib/host-packages/cursor/openplanr/rules/planr-ship.mdc +6 -3
  115. package/lib/host-packages/cursor/openplanr/rules/planr-sprint/references/connectors.md +62 -0
  116. package/lib/host-packages/cursor/openplanr/rules/planr-sprint/references/tracker-connections.md +9 -13
  117. package/lib/host-packages/cursor/openplanr/rules/planr-sprint.mdc +15 -6
  118. package/lib/host-packages/cursor/openplanr/rules/planr-status/references/connectors.md +62 -0
  119. package/lib/host-packages/cursor/openplanr/rules/planr-status/references/tracker-connections.md +9 -13
  120. package/lib/host-packages/cursor/openplanr/rules/planr-status.mdc +14 -3
  121. package/lib/host-packages/cursor/openplanr/rules/planr-sync/references/connectors.md +62 -0
  122. package/lib/host-packages/cursor/openplanr/rules/planr-sync/references/tracker-connections.md +9 -13
  123. package/lib/host-packages/cursor/openplanr/rules/planr-sync.mdc +25 -10
  124. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-share.mjs +1 -1
  125. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-protocol-contracts-31a760fc.mjs +259 -36
  126. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +54 -54
  127. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/lib/artifact/ui/studio-shell.css +1 -1
  128. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +259 -36
  129. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +4 -4
  130. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/package.json +3 -3
  131. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +43 -24
  132. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/03-react-dom-client-fiber-foundations.js +279 -58
  133. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/04-react-dom-client-reconciliation-hooks.js +50 -42
  134. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/05-react-dom-client-render-phases.js +282 -146
  135. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/06-react-dom-client-commit-effects.js +949 -316
  136. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/07-react-dom-client-work-loop-scheduling.js +143 -87
  137. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/08-react-dom-client-dom-events-properties-hydration.js +930 -183
  138. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +17 -15
  139. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/14-interface-primitives.js +375 -191
  140. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-interface-primitives.js +140 -105
  141. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/16-studio-shell.js +146 -54
  142. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +25 -25
  143. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +8 -4
  144. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +259 -36
  145. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +8 -4
  146. package/lib/host-packages/openai/.claude-plugin/marketplace.json +2 -2
  147. package/lib/host-packages/openai/openplanr/.codex-plugin/plugin.json +1 -1
  148. package/lib/host-packages/openai/openplanr/.openplanr-content.json +88 -40
  149. package/lib/host-packages/openai/openplanr/CONNECTORS.md +62 -0
  150. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-share.mjs +1 -1
  151. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-protocol-contracts-31a760fc.mjs +259 -36
  152. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +54 -54
  153. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/lib/artifact/ui/studio-shell.css +1 -1
  154. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +259 -36
  155. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +4 -4
  156. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/package.json +3 -3
  157. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +43 -24
  158. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/03-react-dom-client-fiber-foundations.js +279 -58
  159. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/04-react-dom-client-reconciliation-hooks.js +50 -42
  160. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/05-react-dom-client-render-phases.js +282 -146
  161. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/06-react-dom-client-commit-effects.js +949 -316
  162. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/07-react-dom-client-work-loop-scheduling.js +143 -87
  163. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/08-react-dom-client-dom-events-properties-hydration.js +930 -183
  164. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +17 -15
  165. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/14-interface-primitives.js +375 -191
  166. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-interface-primitives.js +140 -105
  167. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/16-studio-shell.js +146 -54
  168. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +25 -25
  169. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +8 -4
  170. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +259 -36
  171. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +8 -4
  172. package/lib/host-packages/openai/openplanr/skills/connect/SKILL.md +59 -0
  173. package/lib/host-packages/openai/openplanr/skills/connect/agents/openai.yaml +6 -0
  174. package/lib/host-packages/openai/openplanr/skills/connect/openplanr.skill.json +37 -0
  175. package/lib/host-packages/openai/openplanr/skills/connect/references/connectors.md +62 -0
  176. package/lib/host-packages/openai/openplanr/skills/openplanr/SKILL.md +4 -0
  177. package/lib/host-packages/openai/openplanr/skills/plan/SKILL.md +4 -1
  178. package/lib/host-packages/openai/openplanr/skills/plan/scripts/planning-ids.mjs +49 -3
  179. package/lib/host-packages/openai/openplanr/skills/share/SKILL.md +86 -0
  180. package/lib/host-packages/openai/openplanr/skills/share/agents/openai.yaml +6 -0
  181. package/lib/host-packages/openai/openplanr/skills/share/openplanr.skill.json +37 -0
  182. package/lib/host-packages/openai/openplanr/skills/share/references/connectors.md +62 -0
  183. package/lib/host-packages/openai/openplanr/skills/ship/SKILL.md +6 -3
  184. package/lib/host-packages/openai/openplanr/skills/ship/scripts/discover-verification.mjs +2 -1
  185. package/lib/host-packages/openai/openplanr/skills/sprint/SKILL.md +15 -6
  186. package/lib/host-packages/openai/openplanr/skills/sprint/openplanr.skill.json +11 -0
  187. package/lib/host-packages/openai/openplanr/skills/sprint/references/connectors.md +62 -0
  188. package/lib/host-packages/openai/openplanr/skills/sprint/references/tracker-connections.md +9 -13
  189. package/lib/host-packages/openai/openplanr/skills/status/SKILL.md +14 -3
  190. package/lib/host-packages/openai/openplanr/skills/status/openplanr.skill.json +11 -0
  191. package/lib/host-packages/openai/openplanr/skills/status/references/connectors.md +62 -0
  192. package/lib/host-packages/openai/openplanr/skills/status/references/tracker-connections.md +9 -13
  193. package/lib/host-packages/openai/openplanr/skills/sync/SKILL.md +25 -10
  194. package/lib/host-packages/openai/openplanr/skills/sync/openplanr.skill.json +11 -0
  195. package/lib/host-packages/openai/openplanr/skills/sync/references/connectors.md +62 -0
  196. package/lib/host-packages/openai/openplanr/skills/sync/references/tracker-connections.md +9 -13
  197. package/lib/json-schema.mjs +313 -36
  198. package/lib/schemas/v1.0.0/spec.schema.json +120 -0
  199. package/lib/schemas/v1.0.0/story.schema.json +95 -0
  200. package/lib/schemas/v1.0.0/task.schema.json +171 -0
  201. package/lib/schemas/v1.7.0/spec.schema.json +117 -0
  202. package/lib/schemas/v1.7.0/story.schema.json +107 -0
  203. package/lib/schemas/v1.7.0/task.schema.json +217 -0
  204. package/package.json +32 -32
  205. package/dist/dashboard/assets/index-Csby7_ur.js +0 -557
  206. package/dist/dashboard/assets/index-Csby7_ur.js.map +0 -1
  207. package/dist/services/audit-log-service.d.ts +0 -47
  208. package/dist/services/audit-log-service.d.ts.map +0 -1
  209. package/dist/services/audit-log-service.js +0 -211
  210. package/dist/services/audit-log-service.js.map +0 -1
  211. package/dist/services/delta-apply-service.d.ts +0 -16
  212. package/dist/services/delta-apply-service.d.ts.map +0 -1
  213. package/dist/services/delta-apply-service.js +0 -74
  214. package/dist/services/delta-apply-service.js.map +0 -1
  215. package/dist/services/evidence-verifier.d.ts +0 -71
  216. package/dist/services/evidence-verifier.d.ts.map +0 -1
  217. package/dist/services/evidence-verifier.js +0 -174
  218. package/dist/services/evidence-verifier.js.map +0 -1
  219. package/dist/services/revise-apply-service.d.ts +0 -55
  220. package/dist/services/revise-apply-service.d.ts.map +0 -1
  221. package/dist/services/revise-apply-service.js +0 -265
  222. package/dist/services/revise-apply-service.js.map +0 -1
  223. package/dist/services/revise-cache-service.d.ts +0 -46
  224. package/dist/services/revise-cache-service.d.ts.map +0 -1
  225. package/dist/services/revise-cache-service.js +0 -89
  226. package/dist/services/revise-cache-service.js.map +0 -1
  227. package/dist/services/revise-plan-service.d.ts +0 -38
  228. package/dist/services/revise-plan-service.d.ts.map +0 -1
  229. package/dist/services/revise-plan-service.js +0 -153
  230. package/dist/services/revise-plan-service.js.map +0 -1
  231. /package/lib/host-packages/claude/openplanr/runtime/design/scripts/{design-runtime-support-336900df0d39.mjs → design-runtime-support-e34c388a8e59.mjs} +0 -0
  232. /package/lib/host-packages/cursor/openplanr/runtime/design/scripts/{design-runtime-support-336900df0d39.mjs → design-runtime-support-e34c388a8e59.mjs} +0 -0
  233. /package/lib/host-packages/openai/openplanr/runtime/design/scripts/{design-runtime-support-336900df0d39.mjs → design-runtime-support-e34c388a8e59.mjs} +0 -0
@@ -1,47 +0,0 @@
1
- /**
2
- * Audit log writer for `planr revise`.
3
- *
4
- * Every revise run — dry-run included — produces an audit log capturing
5
- * applied / skipped / flagged / failed artifacts with rationale, evidence,
6
- * ambiguities, and unified diffs. Entries are *flushed immediately* to
7
- * disk as they are produced (see `appendEntry`), not batched at cascade
8
- * end, so an interrupted run still leaves an accurate record of exactly
9
- * what was written.
10
- *
11
- * Two output formats: Markdown (human-readable, default) and JSON (for CI /
12
- * tooling / future telemetry workflows). Core structure lives here so
13
- * token-usage and cache-hit/miss stats can layer on additively.
14
- */
15
- import type { ReviseAudit, ReviseAuditEntry, ReviseAuditFormat } from '../models/types.js';
16
- export interface AuditLogWriterOptions {
17
- projectDir: string;
18
- scope: string;
19
- cascade: boolean;
20
- dryRun: boolean;
21
- format: ReviseAuditFormat;
22
- /** Override the default path (.planr/reports/revise-<scope>-<date>.<ext>). */
23
- overridePath?: string;
24
- /** ISO date used in the default filename. Defaults to today in local time. */
25
- dateStamp?: string;
26
- }
27
- export interface AuditLogWriter {
28
- /** Absolute path of the audit file being written. */
29
- path: string;
30
- /** Append one artifact entry and flush to disk immediately. */
31
- appendEntry(entry: ReviseAuditEntry): void;
32
- /**
33
- * Close the audit — records `completedAt`, final summary, and (for JSON
34
- * format) rewrites the file with the accumulated entries wrapped in a
35
- * ReviseAudit envelope. Markdown output is append-only and closes with a
36
- * trailing summary section.
37
- */
38
- close(summary?: Partial<Pick<ReviseAudit, 'interrupted' | 'tokenUsage'>>): void;
39
- }
40
- /**
41
- * Create a writer. For Markdown output, writes the header immediately so
42
- * users can `tail -f` the log during long cascades. For JSON output, the
43
- * accumulated entries are materialized on close (JSON is not line-oriented).
44
- */
45
- export declare function createAuditLogWriter(options: AuditLogWriterOptions): AuditLogWriter;
46
- export declare function readAuditJson(logPath: string): ReviseAudit;
47
- //# sourceMappingURL=audit-log-service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"audit-log-service.d.ts","sourceRoot":"","sources":["../../src/services/audit-log-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAG3F,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC3C;;;;;OAKG;IACH,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,aAAa,GAAG,YAAY,CAAC,CAAC,GAAG,IAAI,CAAC;CACjF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CA0CnF;AA4JD,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAM1D"}
@@ -1,211 +0,0 @@
1
- /**
2
- * Audit log writer for `planr revise`.
3
- *
4
- * Every revise run — dry-run included — produces an audit log capturing
5
- * applied / skipped / flagged / failed artifacts with rationale, evidence,
6
- * ambiguities, and unified diffs. Entries are *flushed immediately* to
7
- * disk as they are produced (see `appendEntry`), not batched at cascade
8
- * end, so an interrupted run still leaves an accurate record of exactly
9
- * what was written.
10
- *
11
- * Two output formats: Markdown (human-readable, default) and JSON (for CI /
12
- * tooling / future telemetry workflows). Core structure lives here so
13
- * token-usage and cache-hit/miss stats can layer on additively.
14
- */
15
- import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
16
- import path from 'node:path';
17
- import { PLANNING_FOLDER } from '../utils/constants.js';
18
- /**
19
- * Create a writer. For Markdown output, writes the header immediately so
20
- * users can `tail -f` the log during long cascades. For JSON output, the
21
- * accumulated entries are materialized on close (JSON is not line-oriented).
22
- */
23
- export function createAuditLogWriter(options) {
24
- const audit = {
25
- scope: options.scope,
26
- cascade: options.cascade,
27
- dryRun: options.dryRun,
28
- startedAt: new Date().toISOString(),
29
- entries: [],
30
- };
31
- const logPath = options.overridePath ?? defaultAuditPath(options);
32
- mkdirSync(path.dirname(logPath), { recursive: true });
33
- if (options.format === 'md') {
34
- writeFileSync(logPath, renderHeader(audit), 'utf-8');
35
- }
36
- else {
37
- writeFileSync(logPath, JSON.stringify(audit, null, 2), 'utf-8');
38
- }
39
- return {
40
- path: logPath,
41
- appendEntry(entry) {
42
- audit.entries.push(entry);
43
- if (options.format === 'md') {
44
- appendFileSync(logPath, renderEntry(entry), 'utf-8');
45
- }
46
- else {
47
- // JSON: rewrite the envelope each append. O(n²) over the run, but
48
- // for a typical cascade (<100 artifacts) this is well under 10ms.
49
- // The guarantee we need is durability, not write efficiency.
50
- writeFileSync(logPath, JSON.stringify(audit, null, 2), 'utf-8');
51
- }
52
- },
53
- close(summary) {
54
- audit.completedAt = new Date().toISOString();
55
- if (summary?.interrupted)
56
- audit.interrupted = summary.interrupted;
57
- if (summary?.tokenUsage)
58
- audit.tokenUsage = summary.tokenUsage;
59
- if (options.format === 'md') {
60
- appendFileSync(logPath, renderFooter(audit), 'utf-8');
61
- }
62
- else {
63
- writeFileSync(logPath, JSON.stringify(audit, null, 2), 'utf-8');
64
- }
65
- },
66
- };
67
- }
68
- function defaultAuditPath(options) {
69
- const date = options.dateStamp ?? toIsoDate(new Date());
70
- const ext = options.format === 'json' ? 'json' : 'md';
71
- const file = `revise-${options.scope}-${date}.${ext}`;
72
- return path.join(options.projectDir, PLANNING_FOLDER, 'reports', file);
73
- }
74
- function toIsoDate(d) {
75
- const y = d.getFullYear();
76
- const m = String(d.getMonth() + 1).padStart(2, '0');
77
- const day = String(d.getDate()).padStart(2, '0');
78
- return `${y}-${m}-${day}`;
79
- }
80
- // ---------------------------------------------------------------------------
81
- // Markdown rendering
82
- // ---------------------------------------------------------------------------
83
- function renderHeader(audit) {
84
- const mode = audit.dryRun ? 'dry-run' : 'apply';
85
- const cascade = audit.cascade ? 'on' : 'off';
86
- return [
87
- `# Revise audit — ${audit.scope} (${toIsoDate(new Date(audit.startedAt))})`,
88
- `> mode=${mode} · cascade=${cascade} · started=${audit.startedAt}`,
89
- '',
90
- '## Entries',
91
- '',
92
- '',
93
- ].join('\n');
94
- }
95
- function renderEntry(entry) {
96
- const out = [];
97
- out.push(`### [${entry.outcome}] ${entry.artifactId}`);
98
- if (entry.artifactPath)
99
- out.push(`> ${entry.artifactPath}`);
100
- out.push(`> timestamp=${entry.timestamp}`);
101
- out.push('');
102
- out.push(`**Rationale:** ${entry.rationale}`);
103
- if (entry.evidence.length > 0) {
104
- out.push('');
105
- out.push('**Evidence:**');
106
- for (const ev of entry.evidence) {
107
- const quote = ev.quote ? ` — "${truncate(ev.quote, 120)}"` : '';
108
- out.push(`- [${ev.type}] \`${ev.ref}\`${quote}`);
109
- }
110
- }
111
- if (entry.ambiguous.length > 0) {
112
- out.push('');
113
- out.push('**Ambiguous (human decision required):**');
114
- for (const a of entry.ambiguous) {
115
- out.push(`- §${a.section}: ${a.reason}`);
116
- }
117
- }
118
- if (entry.error) {
119
- out.push('');
120
- out.push(`**Error:** \`${entry.error}\``);
121
- }
122
- if (entry.diff && entry.diff.length > 0) {
123
- out.push('');
124
- out.push('**Diff:**');
125
- out.push('```diff');
126
- out.push(entry.diff);
127
- out.push('```');
128
- }
129
- out.push('');
130
- return `${out.join('\n')}\n`;
131
- }
132
- function renderFooter(audit) {
133
- const counts = audit.entries.reduce((acc, e) => {
134
- acc[e.outcome] = (acc[e.outcome] ?? 0) + 1;
135
- return acc;
136
- }, {});
137
- const summaryRows = Object.entries(counts)
138
- .sort(([a], [b]) => a.localeCompare(b))
139
- .map(([outcome, n]) => `- ${outcome}: ${n}`);
140
- const out = [];
141
- out.push('');
142
- out.push('## Summary');
143
- out.push(`> completed=${audit.completedAt ?? 'n/a'} · entries=${audit.entries.length}`);
144
- out.push('');
145
- if (summaryRows.length > 0) {
146
- out.push(...summaryRows);
147
- }
148
- else {
149
- out.push('- (no entries recorded)');
150
- }
151
- // Cascade-level grouping — only emitted when at least one entry carries
152
- // a level tag. Includes empty groups (with a count of 0) so readers can
153
- // see which levels had nothing to process.
154
- if (audit.cascade) {
155
- const levels = [
156
- 'epic',
157
- 'features',
158
- 'stories',
159
- 'tasks',
160
- ];
161
- const byLevel = audit.entries.reduce((acc, e) => {
162
- const key = e.cascadeLevel ?? 'unlabeled';
163
- if (!acc[key])
164
- acc[key] = [];
165
- acc[key].push({ outcome: e.outcome, artifactId: e.artifactId });
166
- return acc;
167
- }, {});
168
- out.push('');
169
- out.push('### By cascade level');
170
- for (const level of levels) {
171
- const rows = byLevel[level] ?? [];
172
- out.push('');
173
- out.push(`**${level}** (${rows.length}):`);
174
- if (rows.length === 0) {
175
- out.push('- (no artifacts at this level)');
176
- continue;
177
- }
178
- for (const row of rows) {
179
- out.push(`- [${row.outcome}] ${row.artifactId}`);
180
- }
181
- }
182
- }
183
- if (audit.interrupted) {
184
- out.push('');
185
- out.push(`**Interrupted:** reason=${audit.interrupted.reason}${audit.interrupted.atArtifactId ? ` (at ${audit.interrupted.atArtifactId})` : ''}`);
186
- }
187
- if (audit.tokenUsage) {
188
- out.push('');
189
- out.push(`**Tokens:** ${audit.tokenUsage.inputTokens.toLocaleString()} in → ${audit.tokenUsage.outputTokens.toLocaleString()} out`);
190
- }
191
- out.push('');
192
- return `${out.join('\n')}\n`;
193
- }
194
- function truncate(s, n) {
195
- if (s.length <= n)
196
- return s;
197
- return `${s.slice(0, n)}…`;
198
- }
199
- // ---------------------------------------------------------------------------
200
- // Convenience: load an audit log back into a ReviseAudit (for tooling).
201
- // Not used by the revise command itself but required by future `planr
202
- // revise feedback <finding-id>` in this release.
203
- // ---------------------------------------------------------------------------
204
- export function readAuditJson(logPath) {
205
- if (!existsSync(logPath)) {
206
- throw new Error(`Audit log not found at ${logPath}`);
207
- }
208
- const raw = readFileSync(logPath, 'utf-8');
209
- return JSON.parse(raw);
210
- }
211
- //# sourceMappingURL=audit-log-service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"audit-log-service.js","sourceRoot":"","sources":["../../src/services/audit-log-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7F,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AA4BxD;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA8B;IACjE,MAAM,KAAK,GAAgB;QACzB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,OAAO,EAAE,EAAE;KACZ,CAAC;IAEF,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClE,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEtD,IAAI,OAAO,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;QAC5B,aAAa,CAAC,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;SAAM,CAAC;QACN,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,C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,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACb,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AAC/B,CAAC;AAED,SAAS,QAAQ,CAAC,CAAS,EAAE,CAAS;IACpC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IAC5B,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC;AAC7B,CAAC;AAED,8EAA8E;AAC9E,wEAAwE;AACxE,sEAAsE;AACtE,iDAAiD;AACjD,8EAA8E;AAE9E,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,0BAA0B,OAAO,EAAE,CAAC,CAAC;IACvD,CAAC;IACD,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC3C,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAgB,CAAC;AACxC,CAAC"}
@@ -1,16 +0,0 @@
1
- /**
2
- * Apply structured deltas from AI refine to an artifact — replaces the
3
- * whole-file `improvedMarkdown` blob contract.
4
- *
5
- * Frontmatter changes are surgical (regex per field, same as updateArtifactFields).
6
- * Body changes target specific ## headings or exact text matches.
7
- */
8
- export interface BodyChange {
9
- type: 'replaceSection' | 'replaceText';
10
- heading?: string;
11
- findExact?: string;
12
- replaceWith?: string;
13
- newContent?: string;
14
- }
15
- export declare function applyRefineDeltas(raw: string, frontmatterChanges?: Record<string, unknown>, bodyChanges?: BodyChange[]): string;
16
- //# sourceMappingURL=delta-apply-service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"delta-apply-service.d.ts","sourceRoot":"","sources":["../../src/services/delta-apply-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,gBAAgB,GAAG,aAAa,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAQD,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5C,WAAW,CAAC,EAAE,UAAU,EAAE,GACzB,MAAM,CAmER"}
@@ -1,74 +0,0 @@
1
- /**
2
- * Apply structured deltas from AI refine to an artifact — replaces the
3
- * whole-file `improvedMarkdown` blob contract.
4
- *
5
- * Frontmatter changes are surgical (regex per field, same as updateArtifactFields).
6
- * Body changes target specific ## headings or exact text matches.
7
- */
8
- import { escapeRegExp } from '../utils/escape-regexp.js';
9
- function yamlEscapeValue(value) {
10
- const str = String(value);
11
- const escaped = str.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
12
- return `"${escaped}"`;
13
- }
14
- export function applyRefineDeltas(raw, frontmatterChanges, bodyChanges) {
15
- let result = raw;
16
- if (frontmatterChanges && Object.keys(frontmatterChanges).length > 0) {
17
- const openIdx = result.indexOf('---');
18
- const closeIdx = result.indexOf('\n---', openIdx + 3);
19
- if (openIdx !== -1 && closeIdx !== -1) {
20
- let frontmatter = result.slice(openIdx, closeIdx);
21
- const body = result.slice(closeIdx);
22
- for (const [key, value] of Object.entries(frontmatterChanges)) {
23
- const pattern = new RegExp(`^${escapeRegExp(key)}:\\s*.*$`, 'm');
24
- const replacement = `${key}: ${yamlEscapeValue(value)}`;
25
- if (pattern.test(frontmatter)) {
26
- frontmatter = frontmatter.replace(pattern, () => replacement);
27
- }
28
- else {
29
- frontmatter += `\n${replacement}`;
30
- }
31
- }
32
- result = frontmatter + body;
33
- }
34
- }
35
- if (bodyChanges && bodyChanges.length > 0) {
36
- const openIdx = result.indexOf('---');
37
- const closeIdx = result.indexOf('\n---', openIdx + 3);
38
- if (closeIdx === -1)
39
- return result;
40
- const header = result.slice(0, closeIdx + 4);
41
- let body = result.slice(closeIdx + 4);
42
- for (const change of bodyChanges) {
43
- if (change.type === 'replaceSection' && change.heading && change.newContent !== undefined) {
44
- const headingPattern = new RegExp(`(^|\\n)(##\\s+${escapeRegExp(change.heading)}\\s*\\n)`, 'i');
45
- const match = headingPattern.exec(body);
46
- if (match) {
47
- const sectionStart = (match.index ?? 0) + match[1].length;
48
- const afterHeading = sectionStart + match[2].length;
49
- const nextHeading = body.slice(afterHeading).search(/\n##\s+/);
50
- const sectionEnd = nextHeading === -1 ? body.length : afterHeading + nextHeading;
51
- body =
52
- body.slice(0, sectionStart) +
53
- match[2] +
54
- change.newContent.trimEnd() +
55
- '\n' +
56
- body.slice(sectionEnd);
57
- }
58
- else {
59
- body = `${body.trimEnd()}\n\n## ${change.heading}\n\n${change.newContent.trimEnd()}\n`;
60
- }
61
- }
62
- else if (change.type === 'replaceText' &&
63
- change.findExact &&
64
- change.replaceWith !== undefined) {
65
- if (body.includes(change.findExact)) {
66
- body = body.replace(change.findExact, change.replaceWith);
67
- }
68
- }
69
- }
70
- result = header + body;
71
- }
72
- return result;
73
- }
74
- //# sourceMappingURL=delta-apply-service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"delta-apply-service.js","sourceRoot":"","sources":["../../src/services/delta-apply-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAUzD,SAAS,eAAe,CAAC,KAAc;IACrC,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAChE,OAAO,IAAI,OAAO,GAAG,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC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AAC,CAAC,EAAE,YAAY,CAAC;4BAC3B,KAAK,CAAC,CAAC,CAAC;4BACR,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE;4BAC3B,IAAI;4BACJ,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBAC3B,CAAC;qBAAM,CAAC;oBACN,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,UAAU,MAAM,CAAC,OAAO,OAAO,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC;gBACzF,CAAC;YACH,CAAC;iBAAM,IACL,MAAM,CAAC,IAAI,KAAK,aAAa;gBAC7B,MAAM,CAAC,SAAS;gBAChB,MAAM,CAAC,WAAW,KAAK,SAAS,EAChC,CAAC;gBACD,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;oBACpC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;gBAC5D,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACzB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,71 +0,0 @@
1
- /**
2
- * Post-flight evidence verification for `planr revise`.
3
- *
4
- * The revise agent emits a ReviseDecision with typed evidence citations. Before
5
- * the user ever sees a diff, this verifier checks each citation against the
6
- * real repo:
7
- *
8
- * - `file_exists` / `file_absent` — fs.stat on the ref path
9
- * - `grep_match` — literal check inside the codebase context
10
- * the agent was given; rejects claims the
11
- * agent could not have seen
12
- * - `sibling_artifact` — artifact id must exist on disk
13
- * - `source_quote` — source path must exist on disk (quote
14
- * fuzzy-match is best-effort)
15
- * - `pattern_rule` — rule id must be in the detected pattern
16
- * rules for this run
17
- *
18
- * Unverifiable evidence is dropped with a reason. If a `revise` action has no
19
- * surviving evidence after the sweep, the decision is demoted to `flag` with
20
- * an explicit ambiguity entry — the agent's judgment wasn't necessarily wrong,
21
- * but its *proof* can't be trusted, so a human owns the call.
22
- */
23
- import type { OpenPlanrConfig, ReviseDecision, ReviseEvidence } from '../models/types.js';
24
- /**
25
- * Run-time context the verifier needs. Callers should populate this from the
26
- * same inputs used to build the revise prompt, so the verifier checks evidence
27
- * against exactly the material the agent had access to.
28
- */
29
- export interface EvidenceVerifierContext {
30
- projectDir: string;
31
- config: OpenPlanrConfig;
32
- /**
33
- * Directory of the artifact being verified. Used to resolve relative
34
- * evidence refs like `../features/FEAT-001-slug.md` that appear in
35
- * markdown cross-reference links (those paths are relative to the
36
- * artifact's file location, not to projectDir). Falls back to projectDir
37
- * when omitted.
38
- */
39
- artifactDir?: string;
40
- /** Concatenated string from `formatCodebaseContext`; undefined in fast mode. */
41
- codebaseContextFormatted?: string;
42
- /** Labels (paths or URLs) of declared sources supplied to the agent. */
43
- knownSourceRefs: string[];
44
- /** Pattern rule ids detected in the codebase context (from pattern-rules). */
45
- knownPatternRuleIds: string[];
46
- }
47
- export interface DroppedEvidence {
48
- evidence: ReviseEvidence;
49
- reason: string;
50
- }
51
- export interface DecisionVerificationResult {
52
- /** Possibly-rewritten decision (evidence filtered; action demoted if needed). */
53
- decision: ReviseDecision;
54
- /** Evidence items that failed verification and were removed from the decision. */
55
- dropped: DroppedEvidence[];
56
- /** True when the verifier changed the action (e.g., revise → flag). */
57
- demoted: boolean;
58
- }
59
- /**
60
- * Verify every evidence item in a decision; drop anything unverifiable.
61
- * Demote `revise` to `flag` when no verifiable evidence remains.
62
- */
63
- export declare function verifyDecision(decision: ReviseDecision, ctx: EvidenceVerifierContext): Promise<DecisionVerificationResult>;
64
- interface EvidenceCheck {
65
- ok: boolean;
66
- reason: string;
67
- }
68
- /** Verify a single evidence item. Exported primarily for testing. */
69
- export declare function verifyEvidence(ev: ReviseEvidence, ctx: EvidenceVerifierContext): Promise<EvidenceCheck>;
70
- export {};
71
- //# sourceMappingURL=evidence-verifier.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"evidence-verifier.d.ts","sourceRoot":"","sources":["../../src/services/evidence-verifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EAEV,eAAe,EAEf,cAAc,EACd,cAAc,EACf,MAAM,oBAAoB,CAAC;AAI5B;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,eAAe,CAAC;IACxB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,wEAAwE;IACxE,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,8EAA8E;IAC9E,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,cAAc,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,0BAA0B;IACzC,iFAAiF;IACjF,QAAQ,EAAE,cAAc,CAAC;IACzB,kFAAkF;IAClF,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,uEAAuE;IACvE,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,cAAc,EACxB,GAAG,EAAE,uBAAuB,GAC3B,OAAO,CAAC,0BAA0B,CAAC,CAmErC;AAED,UAAU,aAAa;IACrB,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qEAAqE;AACrE,wBAAsB,cAAc,CAClC,EAAE,EAAE,cAAc,EAClB,GAAG,EAAE,uBAAuB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAwDxB"}
@@ -1,174 +0,0 @@
1
- /**
2
- * Post-flight evidence verification for `planr revise`.
3
- *
4
- * The revise agent emits a ReviseDecision with typed evidence citations. Before
5
- * the user ever sees a diff, this verifier checks each citation against the
6
- * real repo:
7
- *
8
- * - `file_exists` / `file_absent` — fs.stat on the ref path
9
- * - `grep_match` — literal check inside the codebase context
10
- * the agent was given; rejects claims the
11
- * agent could not have seen
12
- * - `sibling_artifact` — artifact id must exist on disk
13
- * - `source_quote` — source path must exist on disk (quote
14
- * fuzzy-match is best-effort)
15
- * - `pattern_rule` — rule id must be in the detected pattern
16
- * rules for this run
17
- *
18
- * Unverifiable evidence is dropped with a reason. If a `revise` action has no
19
- * surviving evidence after the sweep, the decision is demoted to `flag` with
20
- * an explicit ambiguity entry — the agent's judgment wasn't necessarily wrong,
21
- * but its *proof* can't be trusted, so a human owns the call.
22
- */
23
- import { stat } from 'node:fs/promises';
24
- import path from 'node:path';
25
- import { logger } from '../utils/logger.js';
26
- import { findArtifactTypeById, listArtifacts, readArtifact } from './artifact-service.js';
27
- /**
28
- * Verify every evidence item in a decision; drop anything unverifiable.
29
- * Demote `revise` to `flag` when no verifiable evidence remains.
30
- */
31
- export async function verifyDecision(decision, ctx) {
32
- const dropped = [];
33
- const verified = [];
34
- for (const ev of decision.evidence) {
35
- const check = await verifyEvidence(ev, ctx);
36
- if (check.ok) {
37
- verified.push(ev);
38
- }
39
- else {
40
- dropped.push({ evidence: ev, reason: check.reason });
41
- }
42
- }
43
- if (dropped.length > 0) {
44
- logger.debug(`evidence-verifier: dropped ${dropped.length}/${decision.evidence.length} citations for ${decision.artifactId}`);
45
- }
46
- // Demotion rules for a `revise` action. We never silently apply a rewrite
47
- // whose evidence base is weak. Two triggers:
48
- //
49
- // (a) `verified.length === 0` — no evidence survived at all
50
- // (b) `dropped.length > verified.length` — a majority of the agent's
51
- // evidence was unverifiable. This catches the failure mode where
52
- // the agent cites one true thing and several hallucinated ones;
53
- // without this rule a 1-out-of-6 verification rate passes through
54
- // because at least one citation survives.
55
- //
56
- // Both rules target `revise` specifically — `flag` decisions are already
57
- // asking for human review, and `skip` decisions don't change anything.
58
- const shouldDemote = decision.action === 'revise' && (verified.length === 0 || dropped.length > verified.length);
59
- if (shouldDemote) {
60
- const reason = verified.length === 0
61
- ? 'Agent proposed a revision but none of its evidence citations could be verified against the repo. Human review required.'
62
- : `Agent proposed a revision but a majority of its evidence citations (${dropped.length}/${dropped.length + verified.length}) could not be verified. Most likely hallucinated — human review required.`;
63
- const tag = verified.length === 0 ? 'all evidence unverifiable' : 'majority evidence unverifiable';
64
- const ambiguity = {
65
- section: '(evidence verification)',
66
- reason,
67
- };
68
- return {
69
- decision: {
70
- ...decision,
71
- action: 'flag',
72
- evidence: verified, // keep any surviving citations in the flag record
73
- // Preserve the agent's proposed rewrite so the audit log can show it
74
- // as a "rejected proposal" diff. The apply path still refuses to
75
- // write it (action=flag), but users can read the audit entry to
76
- // see what the agent wanted and decide whether to hand-apply.
77
- ambiguous: [...decision.ambiguous, ambiguity],
78
- rationale: `${decision.rationale} [demoted: ${tag}]`,
79
- },
80
- dropped,
81
- demoted: true,
82
- };
83
- }
84
- return {
85
- decision: { ...decision, evidence: verified },
86
- dropped,
87
- demoted: false,
88
- };
89
- }
90
- /** Verify a single evidence item. Exported primarily for testing. */
91
- export async function verifyEvidence(ev, ctx) {
92
- switch (ev.type) {
93
- case 'file_exists':
94
- return (await pathExists(ctx.projectDir, ev.ref, ctx.artifactDir))
95
- ? ok()
96
- : fail(`cited file does not exist: ${ev.ref}`);
97
- case 'file_absent':
98
- return (await pathExists(ctx.projectDir, ev.ref, ctx.artifactDir))
99
- ? fail(`cited file IS present in the repo, contradicting 'file_absent': ${ev.ref}`)
100
- : ok();
101
- case 'grep_match':
102
- if (!ctx.codebaseContextFormatted) {
103
- return fail('grep_match citation requires codebase context, but context was not loaded (fast mode)');
104
- }
105
- // Require either ref OR quote to appear in the context the agent saw.
106
- if (ctx.codebaseContextFormatted.includes(ev.ref) ||
107
- (ev.quote && ctx.codebaseContextFormatted.includes(ev.quote))) {
108
- return ok();
109
- }
110
- return fail(`grep_match token not found in codebase context: ${ev.ref}`);
111
- case 'sibling_artifact': {
112
- const type = findArtifactTypeById(ev.ref);
113
- if (!type) {
114
- return fail(`sibling_artifact ref is not a recognizable artifact id: ${ev.ref}`);
115
- }
116
- return (await artifactExists(ctx.projectDir, ctx.config, type, ev.ref))
117
- ? ok()
118
- : fail(`sibling_artifact not found on disk: ${ev.ref}`);
119
- }
120
- case 'source_quote':
121
- // Source refs are labels/paths declared in .planr/revise.yaml; the
122
- // caller has already globbed them, so we validate against that list.
123
- return ctx.knownSourceRefs.includes(ev.ref)
124
- ? ok()
125
- : fail(`source_quote ref is not a declared source: ${ev.ref}`);
126
- case 'pattern_rule':
127
- return ctx.knownPatternRuleIds.includes(ev.ref)
128
- ? ok()
129
- : fail(`pattern_rule ref is not a detected pattern rule: ${ev.ref}`);
130
- default: {
131
- // Exhaustive check — if a new evidence type is added to the TS union
132
- // but not here, the compiler will complain.
133
- const _exhaustive = ev.type;
134
- return fail(`unhandled evidence type: ${String(_exhaustive)}`);
135
- }
136
- }
137
- }
138
- const ok = () => ({ ok: true, reason: '' });
139
- const fail = (reason) => ({ ok: false, reason });
140
- async function pathExists(projectDir, ref, artifactDir) {
141
- // Choose resolution base:
142
- // - Relative refs (`./` or `../`) resolve against the artifact's directory
143
- // when available, because OpenPlanr's cross-reference convention writes
144
- // paths like `../features/FEAT-001-slug.md` relative to the artifact file.
145
- // - Everything else (repo-root-style refs like `src/services/foo.ts`) resolves
146
- // against projectDir.
147
- const looksRelative = ref.startsWith('./') || ref.startsWith('../');
148
- const base = looksRelative && artifactDir ? artifactDir : projectDir;
149
- const resolved = path.resolve(base, ref);
150
- const normalized = path.normalize(resolved);
151
- // Traversal guard — the final path must still land inside projectDir
152
- // (after following any `../`). This blocks probes like `../../../etc/passwd`
153
- // while allowing legitimate artifact→sibling-dir references.
154
- if (!normalized.startsWith(path.normalize(projectDir)))
155
- return false;
156
- try {
157
- await stat(normalized);
158
- return true;
159
- }
160
- catch {
161
- return false;
162
- }
163
- }
164
- async function artifactExists(projectDir, config, type, id) {
165
- // readArtifact is the authoritative existence check — it looks for files
166
- // matching `${id}-*.md` in the correct artifact-type directory.
167
- const artifact = await readArtifact(projectDir, config, type, id);
168
- if (artifact !== null)
169
- return true;
170
- // Fallback: scan the listing in case id-case or prefix routing differs.
171
- const list = await listArtifacts(projectDir, config, type);
172
- return list.some((a) => a.id === id);
173
- }
174
- //# sourceMappingURL=evidence-verifier.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"evidence-verifier.js","sourceRoot":"","sources":["../../src/services/evidence-verifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAQ7B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAwC1F;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,QAAwB,EACxB,GAA4B;IAE5B,MAAM,OAAO,GAAsB,EAAE,CAAC;IACtC,MAAM,QAAQ,GAAqB,EAAE,CAAC;IAEtC,KAAK,MAAM,EAAE,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACnC,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;QAC5C,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC;YACb,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,CAAC,KAAK,CACV,8BAA8B,OAAO,CAAC,MAAM,IAAI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