mewkit 1.15.0 → 1.16.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 (490) hide show
  1. package/NOTICE +24 -0
  2. package/README.md +29 -70
  3. package/dist/commands/visual-plan.d.ts +23 -0
  4. package/dist/commands/visual-plan.d.ts.map +1 -0
  5. package/dist/commands/visual-plan.js +26 -0
  6. package/dist/commands/visual-plan.js.map +1 -0
  7. package/dist/core/capability.d.ts +81 -81
  8. package/dist/core/consolidation-ledger.d.ts.map +1 -1
  9. package/dist/core/consolidation-ledger.js +13 -11
  10. package/dist/core/consolidation-ledger.js.map +1 -1
  11. package/dist/core/install-metadata.d.ts +27 -27
  12. package/dist/core/plugin-manifest.d.ts +16 -16
  13. package/dist/core/release-metadata.d.ts +2 -2
  14. package/dist/core/task-record.d.ts +8 -8
  15. package/dist/index.js +33 -21
  16. package/dist/index.js.map +1 -1
  17. package/dist/local-web/atomic-write.d.ts +15 -0
  18. package/dist/local-web/atomic-write.d.ts.map +1 -0
  19. package/dist/local-web/atomic-write.js +69 -0
  20. package/dist/local-web/atomic-write.js.map +1 -0
  21. package/dist/local-web/constants.d.ts +13 -0
  22. package/dist/local-web/constants.d.ts.map +1 -0
  23. package/dist/local-web/constants.js +13 -0
  24. package/dist/local-web/constants.js.map +1 -0
  25. package/dist/local-web/etag.d.ts +19 -0
  26. package/dist/local-web/etag.d.ts.map +1 -0
  27. package/dist/local-web/etag.js +32 -0
  28. package/dist/local-web/etag.js.map +1 -0
  29. package/dist/local-web/host-guard.d.ts +12 -0
  30. package/dist/local-web/host-guard.d.ts.map +1 -0
  31. package/dist/local-web/host-guard.js +18 -0
  32. package/dist/local-web/host-guard.js.map +1 -0
  33. package/dist/local-web/index.d.ts +23 -0
  34. package/dist/local-web/index.d.ts.map +1 -0
  35. package/dist/local-web/index.js +23 -0
  36. package/dist/local-web/index.js.map +1 -0
  37. package/dist/local-web/local-server.d.ts +37 -0
  38. package/dist/local-web/local-server.d.ts.map +1 -0
  39. package/dist/local-web/local-server.js +85 -0
  40. package/dist/local-web/local-server.js.map +1 -0
  41. package/dist/local-web/open-browser.d.ts +12 -0
  42. package/dist/local-web/open-browser.d.ts.map +1 -0
  43. package/dist/{orchviz/open-url.js → local-web/open-browser.js} +9 -8
  44. package/dist/local-web/open-browser.js.map +1 -0
  45. package/dist/local-web/origin-guard.d.ts +11 -0
  46. package/dist/local-web/origin-guard.d.ts.map +1 -0
  47. package/dist/local-web/origin-guard.js +15 -0
  48. package/dist/local-web/origin-guard.js.map +1 -0
  49. package/dist/local-web/path-boundary.d.ts +20 -0
  50. package/dist/local-web/path-boundary.d.ts.map +1 -0
  51. package/dist/local-web/path-boundary.js +39 -0
  52. package/dist/local-web/path-boundary.js.map +1 -0
  53. package/dist/local-web/request-body.d.ts +24 -0
  54. package/dist/local-web/request-body.d.ts.map +1 -0
  55. package/dist/local-web/request-body.js +68 -0
  56. package/dist/local-web/request-body.js.map +1 -0
  57. package/dist/local-web/static-handler.d.ts +14 -0
  58. package/dist/local-web/static-handler.d.ts.map +1 -0
  59. package/dist/{orchviz/server → local-web}/static-handler.js +11 -6
  60. package/dist/local-web/static-handler.js.map +1 -0
  61. package/dist/migrate/reconcile/portable-manifest.d.ts +12 -12
  62. package/dist/migrate/reconcile/portable-registry.d.ts +24 -24
  63. package/dist/migrate/types.d.ts +10 -10
  64. package/dist/{orchviz/token-estimator.d.ts → token-estimator/index.d.ts} +6 -1
  65. package/dist/token-estimator/index.d.ts.map +1 -0
  66. package/dist/{orchviz/token-estimator.js → token-estimator/index.js} +11 -2
  67. package/dist/token-estimator/index.js.map +1 -0
  68. package/dist/visual-plan/__fixtures__/valid-plan.d.ts +15 -0
  69. package/dist/visual-plan/__fixtures__/valid-plan.d.ts.map +1 -0
  70. package/dist/visual-plan/__fixtures__/valid-plan.js +79 -0
  71. package/dist/visual-plan/__fixtures__/valid-plan.js.map +1 -0
  72. package/dist/visual-plan/application/apply-feedback.d.ts +31 -0
  73. package/dist/visual-plan/application/apply-feedback.d.ts.map +1 -0
  74. package/dist/visual-plan/application/apply-feedback.js +85 -0
  75. package/dist/visual-plan/application/apply-feedback.js.map +1 -0
  76. package/dist/visual-plan/application/apply-patch-op.d.ts +13 -0
  77. package/dist/visual-plan/application/apply-patch-op.d.ts.map +1 -0
  78. package/dist/visual-plan/application/apply-patch-op.js +72 -0
  79. package/dist/visual-plan/application/apply-patch-op.js.map +1 -0
  80. package/dist/visual-plan/application/approve.d.ts +24 -0
  81. package/dist/visual-plan/application/approve.d.ts.map +1 -0
  82. package/dist/visual-plan/application/approve.js +53 -0
  83. package/dist/visual-plan/application/approve.js.map +1 -0
  84. package/dist/visual-plan/application/clock.d.ts +8 -0
  85. package/dist/visual-plan/application/clock.d.ts.map +1 -0
  86. package/dist/visual-plan/application/clock.js +10 -0
  87. package/dist/visual-plan/application/clock.js.map +1 -0
  88. package/dist/visual-plan/application/export-plan.d.ts +19 -0
  89. package/dist/visual-plan/application/export-plan.d.ts.map +1 -0
  90. package/dist/visual-plan/application/export-plan.js +59 -0
  91. package/dist/visual-plan/application/export-plan.js.map +1 -0
  92. package/dist/visual-plan/application/patch-plan.d.ts +26 -0
  93. package/dist/visual-plan/application/patch-plan.d.ts.map +1 -0
  94. package/dist/visual-plan/application/patch-plan.js +48 -0
  95. package/dist/visual-plan/application/patch-plan.js.map +1 -0
  96. package/dist/visual-plan/application/prepare-feedback.d.ts +24 -0
  97. package/dist/visual-plan/application/prepare-feedback.d.ts.map +1 -0
  98. package/dist/visual-plan/application/prepare-feedback.js +70 -0
  99. package/dist/visual-plan/application/prepare-feedback.js.map +1 -0
  100. package/dist/visual-plan/application/rehash.d.ts +19 -0
  101. package/dist/visual-plan/application/rehash.d.ts.map +1 -0
  102. package/dist/visual-plan/application/rehash.js +43 -0
  103. package/dist/visual-plan/application/rehash.js.map +1 -0
  104. package/dist/visual-plan/application/status.d.ts +20 -0
  105. package/dist/visual-plan/application/status.d.ts.map +1 -0
  106. package/dist/visual-plan/application/status.js +27 -0
  107. package/dist/visual-plan/application/status.js.map +1 -0
  108. package/dist/visual-plan/application/validate-plan.d.ts +30 -0
  109. package/dist/visual-plan/application/validate-plan.d.ts.map +1 -0
  110. package/dist/visual-plan/application/validate-plan.js +59 -0
  111. package/dist/visual-plan/application/validate-plan.js.map +1 -0
  112. package/dist/visual-plan/domain/coverage.d.ts +35 -0
  113. package/dist/visual-plan/domain/coverage.d.ts.map +1 -0
  114. package/dist/visual-plan/domain/coverage.js +99 -0
  115. package/dist/visual-plan/domain/coverage.js.map +1 -0
  116. package/dist/visual-plan/domain/cross-refs.d.ts +20 -0
  117. package/dist/visual-plan/domain/cross-refs.d.ts.map +1 -0
  118. package/dist/visual-plan/domain/cross-refs.js +92 -0
  119. package/dist/visual-plan/domain/cross-refs.js.map +1 -0
  120. package/dist/visual-plan/domain/errors.d.ts +43 -0
  121. package/dist/visual-plan/domain/errors.d.ts.map +1 -0
  122. package/dist/visual-plan/domain/errors.js +33 -0
  123. package/dist/visual-plan/domain/errors.js.map +1 -0
  124. package/dist/visual-plan/domain/feedback-schemas.d.ts +160 -0
  125. package/dist/visual-plan/domain/feedback-schemas.d.ts.map +1 -0
  126. package/dist/visual-plan/domain/feedback-schemas.js +71 -0
  127. package/dist/visual-plan/domain/feedback-schemas.js.map +1 -0
  128. package/dist/visual-plan/domain/ids.d.ts +21 -0
  129. package/dist/visual-plan/domain/ids.d.ts.map +1 -0
  130. package/dist/visual-plan/domain/ids.js +25 -0
  131. package/dist/visual-plan/domain/ids.js.map +1 -0
  132. package/dist/visual-plan/domain/patches.d.ts +176 -0
  133. package/dist/visual-plan/domain/patches.d.ts.map +1 -0
  134. package/dist/visual-plan/domain/patches.js +41 -0
  135. package/dist/visual-plan/domain/patches.js.map +1 -0
  136. package/dist/visual-plan/domain/sanitizer-config.d.ts +61 -0
  137. package/dist/visual-plan/domain/sanitizer-config.d.ts.map +1 -0
  138. package/dist/visual-plan/domain/sanitizer-config.js +70 -0
  139. package/dist/visual-plan/domain/sanitizer-config.js.map +1 -0
  140. package/dist/visual-plan/domain/schemas.d.ts +1492 -0
  141. package/dist/visual-plan/domain/schemas.d.ts.map +1 -0
  142. package/dist/visual-plan/domain/schemas.js +166 -0
  143. package/dist/visual-plan/domain/schemas.js.map +1 -0
  144. package/dist/visual-plan/infrastructure/atomic-write.d.ts +11 -0
  145. package/dist/visual-plan/infrastructure/atomic-write.d.ts.map +1 -0
  146. package/dist/visual-plan/infrastructure/atomic-write.js +44 -0
  147. package/dist/visual-plan/infrastructure/atomic-write.js.map +1 -0
  148. package/dist/visual-plan/infrastructure/feedback-repository.d.ts +18 -0
  149. package/dist/visual-plan/infrastructure/feedback-repository.d.ts.map +1 -0
  150. package/dist/visual-plan/infrastructure/feedback-repository.js +59 -0
  151. package/dist/visual-plan/infrastructure/feedback-repository.js.map +1 -0
  152. package/dist/visual-plan/infrastructure/hashing.d.ts +37 -0
  153. package/dist/visual-plan/infrastructure/hashing.d.ts.map +1 -0
  154. package/dist/visual-plan/infrastructure/hashing.js +81 -0
  155. package/dist/visual-plan/infrastructure/hashing.js.map +1 -0
  156. package/dist/visual-plan/infrastructure/plan-state.d.ts +32 -0
  157. package/dist/visual-plan/infrastructure/plan-state.d.ts.map +1 -0
  158. package/dist/visual-plan/infrastructure/plan-state.js +58 -0
  159. package/dist/visual-plan/infrastructure/plan-state.js.map +1 -0
  160. package/dist/visual-plan/infrastructure/receipt-repository.d.ts +17 -0
  161. package/dist/visual-plan/infrastructure/receipt-repository.d.ts.map +1 -0
  162. package/dist/visual-plan/infrastructure/receipt-repository.js +59 -0
  163. package/dist/visual-plan/infrastructure/receipt-repository.js.map +1 -0
  164. package/dist/visual-plan/infrastructure/visual-plan-repository.d.ts +38 -0
  165. package/dist/visual-plan/infrastructure/visual-plan-repository.d.ts.map +1 -0
  166. package/dist/visual-plan/infrastructure/visual-plan-repository.js +97 -0
  167. package/dist/visual-plan/infrastructure/visual-plan-repository.js.map +1 -0
  168. package/dist/visual-plan/infrastructure/wireframe-sanitizer.d.ts +41 -0
  169. package/dist/visual-plan/infrastructure/wireframe-sanitizer.d.ts.map +1 -0
  170. package/dist/visual-plan/infrastructure/wireframe-sanitizer.js +72 -0
  171. package/dist/visual-plan/infrastructure/wireframe-sanitizer.js.map +1 -0
  172. package/dist/visual-plan/interface/cli.d.ts +29 -0
  173. package/dist/visual-plan/interface/cli.d.ts.map +1 -0
  174. package/dist/visual-plan/interface/cli.js +280 -0
  175. package/dist/visual-plan/interface/cli.js.map +1 -0
  176. package/dist/visual-plan/interface/studio.d.ts +20 -0
  177. package/dist/visual-plan/interface/studio.d.ts.map +1 -0
  178. package/dist/visual-plan/interface/studio.js +74 -0
  179. package/dist/visual-plan/interface/studio.js.map +1 -0
  180. package/dist/visual-plan/server/csp.d.ts +13 -0
  181. package/dist/visual-plan/server/csp.d.ts.map +1 -0
  182. package/dist/visual-plan/server/csp.js +17 -0
  183. package/dist/visual-plan/server/csp.js.map +1 -0
  184. package/dist/visual-plan/server/edit-lock.d.ts +28 -0
  185. package/dist/visual-plan/server/edit-lock.d.ts.map +1 -0
  186. package/dist/visual-plan/server/edit-lock.js +71 -0
  187. package/dist/visual-plan/server/edit-lock.js.map +1 -0
  188. package/dist/visual-plan/server/routes/feedback.d.ts +12 -0
  189. package/dist/visual-plan/server/routes/feedback.d.ts.map +1 -0
  190. package/dist/visual-plan/server/routes/feedback.js +63 -0
  191. package/dist/visual-plan/server/routes/feedback.js.map +1 -0
  192. package/dist/visual-plan/server/routes/get-plan.d.ts +14 -0
  193. package/dist/visual-plan/server/routes/get-plan.d.ts.map +1 -0
  194. package/dist/visual-plan/server/routes/get-plan.js +38 -0
  195. package/dist/visual-plan/server/routes/get-plan.js.map +1 -0
  196. package/dist/visual-plan/server/routes/patch.d.ts +10 -0
  197. package/dist/visual-plan/server/routes/patch.d.ts.map +1 -0
  198. package/dist/visual-plan/server/routes/patch.js +66 -0
  199. package/dist/visual-plan/server/routes/patch.js.map +1 -0
  200. package/dist/visual-plan/server/visual-plan-server.d.ts +30 -0
  201. package/dist/visual-plan/server/visual-plan-server.d.ts.map +1 -0
  202. package/dist/visual-plan/server/visual-plan-server.js +79 -0
  203. package/dist/visual-plan/server/visual-plan-server.js.map +1 -0
  204. package/dist/visual-plan-web/architects-daughter-latin-400-normal.woff +0 -0
  205. package/dist/visual-plan-web/architects-daughter-latin-400-normal.woff2 +0 -0
  206. package/dist/visual-plan-web/architects-daughter-latin-ext-400-normal.woff +0 -0
  207. package/dist/visual-plan-web/architects-daughter-latin-ext-400-normal.woff2 +0 -0
  208. package/dist/visual-plan-web/index.css +1 -0
  209. package/dist/visual-plan-web/index.html +17 -0
  210. package/dist/visual-plan-web/index.js +51 -0
  211. package/package.json +14 -17
  212. package/dist/commands/orchviz.d.ts +0 -12
  213. package/dist/commands/orchviz.d.ts.map +0 -1
  214. package/dist/commands/orchviz.js +0 -157
  215. package/dist/commands/orchviz.js.map +0 -1
  216. package/dist/migrate/converters/md-to-codex-rules.d.ts +0 -10
  217. package/dist/migrate/converters/md-to-codex-rules.d.ts.map +0 -1
  218. package/dist/migrate/converters/md-to-codex-rules.js +0 -133
  219. package/dist/migrate/converters/md-to-codex-rules.js.map +0 -1
  220. package/dist/orchviz/constants.d.ts +0 -72
  221. package/dist/orchviz/constants.d.ts.map +0 -1
  222. package/dist/orchviz/constants.js +0 -105
  223. package/dist/orchviz/constants.js.map +0 -1
  224. package/dist/orchviz/fs-utils.d.ts +0 -24
  225. package/dist/orchviz/fs-utils.d.ts.map +0 -1
  226. package/dist/orchviz/fs-utils.js +0 -49
  227. package/dist/orchviz/fs-utils.js.map +0 -1
  228. package/dist/orchviz/index.d.ts +0 -29
  229. package/dist/orchviz/index.d.ts.map +0 -1
  230. package/dist/orchviz/index.js +0 -28
  231. package/dist/orchviz/index.js.map +0 -1
  232. package/dist/orchviz/log-persister.d.ts +0 -22
  233. package/dist/orchviz/log-persister.d.ts.map +0 -1
  234. package/dist/orchviz/log-persister.js +0 -96
  235. package/dist/orchviz/log-persister.js.map +0 -1
  236. package/dist/orchviz/logger.d.ts +0 -13
  237. package/dist/orchviz/logger.d.ts.map +0 -1
  238. package/dist/orchviz/logger.js +0 -47
  239. package/dist/orchviz/logger.js.map +0 -1
  240. package/dist/orchviz/open-url.d.ts +0 -11
  241. package/dist/orchviz/open-url.d.ts.map +0 -1
  242. package/dist/orchviz/open-url.js.map +0 -1
  243. package/dist/orchviz/overlay/collector.d.ts +0 -29
  244. package/dist/orchviz/overlay/collector.d.ts.map +0 -1
  245. package/dist/orchviz/overlay/collector.js +0 -38
  246. package/dist/orchviz/overlay/collector.js.map +0 -1
  247. package/dist/orchviz/overlay/gate-readers.d.ts +0 -18
  248. package/dist/orchviz/overlay/gate-readers.d.ts.map +0 -1
  249. package/dist/orchviz/overlay/gate-readers.js +0 -111
  250. package/dist/orchviz/overlay/gate-readers.js.map +0 -1
  251. package/dist/orchviz/overlay/session-state-readers.d.ts +0 -18
  252. package/dist/orchviz/overlay/session-state-readers.d.ts.map +0 -1
  253. package/dist/orchviz/overlay/session-state-readers.js +0 -78
  254. package/dist/orchviz/overlay/session-state-readers.js.map +0 -1
  255. package/dist/orchviz/parser/handle-progress.d.ts +0 -9
  256. package/dist/orchviz/parser/handle-progress.d.ts.map +0 -1
  257. package/dist/orchviz/parser/handle-progress.js +0 -38
  258. package/dist/orchviz/parser/handle-progress.js.map +0 -1
  259. package/dist/orchviz/parser/handle-system.d.ts +0 -22
  260. package/dist/orchviz/parser/handle-system.d.ts.map +0 -1
  261. package/dist/orchviz/parser/handle-system.js +0 -99
  262. package/dist/orchviz/parser/handle-system.js.map +0 -1
  263. package/dist/orchviz/parser/handle-text.d.ts +0 -10
  264. package/dist/orchviz/parser/handle-text.d.ts.map +0 -1
  265. package/dist/orchviz/parser/handle-text.js +0 -83
  266. package/dist/orchviz/parser/handle-text.js.map +0 -1
  267. package/dist/orchviz/parser/handle-thinking.d.ts +0 -10
  268. package/dist/orchviz/parser/handle-thinking.d.ts.map +0 -1
  269. package/dist/orchviz/parser/handle-thinking.js +0 -35
  270. package/dist/orchviz/parser/handle-thinking.js.map +0 -1
  271. package/dist/orchviz/parser/handle-tool-result.d.ts +0 -10
  272. package/dist/orchviz/parser/handle-tool-result.d.ts.map +0 -1
  273. package/dist/orchviz/parser/handle-tool-result.js +0 -130
  274. package/dist/orchviz/parser/handle-tool-result.js.map +0 -1
  275. package/dist/orchviz/parser/handle-tool-use.d.ts +0 -11
  276. package/dist/orchviz/parser/handle-tool-use.d.ts.map +0 -1
  277. package/dist/orchviz/parser/handle-tool-use.js +0 -120
  278. package/dist/orchviz/parser/handle-tool-use.js.map +0 -1
  279. package/dist/orchviz/parser/index.d.ts +0 -38
  280. package/dist/orchviz/parser/index.d.ts.map +0 -1
  281. package/dist/orchviz/parser/index.js +0 -144
  282. package/dist/orchviz/parser/index.js.map +0 -1
  283. package/dist/orchviz/parser/label-helpers.d.ts +0 -9
  284. package/dist/orchviz/parser/label-helpers.d.ts.map +0 -1
  285. package/dist/orchviz/parser/label-helpers.js +0 -44
  286. package/dist/orchviz/parser/label-helpers.js.map +0 -1
  287. package/dist/orchviz/parser/strip-ansi.d.ts +0 -6
  288. package/dist/orchviz/parser/strip-ansi.d.ts.map +0 -1
  289. package/dist/orchviz/parser/strip-ansi.js +0 -14
  290. package/dist/orchviz/parser/strip-ansi.js.map +0 -1
  291. package/dist/orchviz/parser/utils.d.ts +0 -20
  292. package/dist/orchviz/parser/utils.d.ts.map +0 -1
  293. package/dist/orchviz/parser/utils.js +0 -54
  294. package/dist/orchviz/parser/utils.js.map +0 -1
  295. package/dist/orchviz/permission-detection.d.ts +0 -32
  296. package/dist/orchviz/permission-detection.d.ts.map +0 -1
  297. package/dist/orchviz/permission-detection.js +0 -104
  298. package/dist/orchviz/permission-detection.js.map +0 -1
  299. package/dist/orchviz/plan/apply-todo-toggle.d.ts +0 -29
  300. package/dist/orchviz/plan/apply-todo-toggle.d.ts.map +0 -1
  301. package/dist/orchviz/plan/apply-todo-toggle.js +0 -129
  302. package/dist/orchviz/plan/apply-todo-toggle.js.map +0 -1
  303. package/dist/orchviz/plan/atomic-write.d.ts +0 -25
  304. package/dist/orchviz/plan/atomic-write.d.ts.map +0 -1
  305. package/dist/orchviz/plan/atomic-write.js +0 -85
  306. package/dist/orchviz/plan/atomic-write.js.map +0 -1
  307. package/dist/orchviz/plan/collector.d.ts +0 -49
  308. package/dist/orchviz/plan/collector.d.ts.map +0 -1
  309. package/dist/orchviz/plan/collector.js +0 -169
  310. package/dist/orchviz/plan/collector.js.map +0 -1
  311. package/dist/orchviz/plan/etag.d.ts +0 -24
  312. package/dist/orchviz/plan/etag.d.ts.map +0 -1
  313. package/dist/orchviz/plan/etag.js +0 -58
  314. package/dist/orchviz/plan/etag.js.map +0 -1
  315. package/dist/orchviz/plan/find-active-plan.d.ts +0 -9
  316. package/dist/orchviz/plan/find-active-plan.d.ts.map +0 -1
  317. package/dist/orchviz/plan/find-active-plan.js +0 -90
  318. package/dist/orchviz/plan/find-active-plan.js.map +0 -1
  319. package/dist/orchviz/plan/index.d.ts +0 -23
  320. package/dist/orchviz/plan/index.d.ts.map +0 -1
  321. package/dist/orchviz/plan/index.js +0 -91
  322. package/dist/orchviz/plan/index.js.map +0 -1
  323. package/dist/orchviz/plan/list-plans.d.ts +0 -19
  324. package/dist/orchviz/plan/list-plans.d.ts.map +0 -1
  325. package/dist/orchviz/plan/list-plans.js +0 -143
  326. package/dist/orchviz/plan/list-plans.js.map +0 -1
  327. package/dist/orchviz/plan/parse-phase-file.d.ts +0 -13
  328. package/dist/orchviz/plan/parse-phase-file.d.ts.map +0 -1
  329. package/dist/orchviz/plan/parse-phase-file.js +0 -134
  330. package/dist/orchviz/plan/parse-phase-file.js.map +0 -1
  331. package/dist/orchviz/plan/parse-plan-file.d.ts +0 -19
  332. package/dist/orchviz/plan/parse-plan-file.d.ts.map +0 -1
  333. package/dist/orchviz/plan/parse-plan-file.js +0 -62
  334. package/dist/orchviz/plan/parse-plan-file.js.map +0 -1
  335. package/dist/orchviz/plan/plan-constants.d.ts +0 -17
  336. package/dist/orchviz/plan/plan-constants.d.ts.map +0 -1
  337. package/dist/orchviz/plan/plan-constants.js +0 -19
  338. package/dist/orchviz/plan/plan-constants.js.map +0 -1
  339. package/dist/orchviz/plan/plan-lifecycle.d.ts +0 -17
  340. package/dist/orchviz/plan/plan-lifecycle.d.ts.map +0 -1
  341. package/dist/orchviz/plan/plan-lifecycle.js +0 -97
  342. package/dist/orchviz/plan/plan-lifecycle.js.map +0 -1
  343. package/dist/orchviz/plan/types.d.ts +0 -46
  344. package/dist/orchviz/plan/types.d.ts.map +0 -1
  345. package/dist/orchviz/plan/types.js +0 -6
  346. package/dist/orchviz/plan/types.js.map +0 -1
  347. package/dist/orchviz/protocol.d.ts +0 -171
  348. package/dist/orchviz/protocol.d.ts.map +0 -1
  349. package/dist/orchviz/protocol.js +0 -23
  350. package/dist/orchviz/protocol.js.map +0 -1
  351. package/dist/orchviz/redact.d.ts +0 -10
  352. package/dist/orchviz/redact.d.ts.map +0 -1
  353. package/dist/orchviz/redact.js +0 -38
  354. package/dist/orchviz/redact.js.map +0 -1
  355. package/dist/orchviz/sanitize.d.ts +0 -11
  356. package/dist/orchviz/sanitize.d.ts.map +0 -1
  357. package/dist/orchviz/sanitize.js +0 -38
  358. package/dist/orchviz/sanitize.js.map +0 -1
  359. package/dist/orchviz/server/api-handlers.d.ts +0 -55
  360. package/dist/orchviz/server/api-handlers.d.ts.map +0 -1
  361. package/dist/orchviz/server/api-handlers.js +0 -112
  362. package/dist/orchviz/server/api-handlers.js.map +0 -1
  363. package/dist/orchviz/server/index.d.ts +0 -36
  364. package/dist/orchviz/server/index.d.ts.map +0 -1
  365. package/dist/orchviz/server/index.js +0 -144
  366. package/dist/orchviz/server/index.js.map +0 -1
  367. package/dist/orchviz/server/sse-handler.d.ts +0 -28
  368. package/dist/orchviz/server/sse-handler.d.ts.map +0 -1
  369. package/dist/orchviz/server/sse-handler.js +0 -217
  370. package/dist/orchviz/server/sse-handler.js.map +0 -1
  371. package/dist/orchviz/server/static-handler.d.ts +0 -9
  372. package/dist/orchviz/server/static-handler.d.ts.map +0 -1
  373. package/dist/orchviz/server/static-handler.js.map +0 -1
  374. package/dist/orchviz/server/write-handlers.d.ts +0 -20
  375. package/dist/orchviz/server/write-handlers.d.ts.map +0 -1
  376. package/dist/orchviz/server/write-handlers.js +0 -184
  377. package/dist/orchviz/server/write-handlers.js.map +0 -1
  378. package/dist/orchviz/server/write-utils.d.ts +0 -59
  379. package/dist/orchviz/server/write-utils.d.ts.map +0 -1
  380. package/dist/orchviz/server/write-utils.js +0 -161
  381. package/dist/orchviz/server/write-utils.js.map +0 -1
  382. package/dist/orchviz/session-discovery.d.ts +0 -19
  383. package/dist/orchviz/session-discovery.d.ts.map +0 -1
  384. package/dist/orchviz/session-discovery.js +0 -104
  385. package/dist/orchviz/session-discovery.js.map +0 -1
  386. package/dist/orchviz/session-manager.d.ts +0 -17
  387. package/dist/orchviz/session-manager.d.ts.map +0 -1
  388. package/dist/orchviz/session-manager.js +0 -63
  389. package/dist/orchviz/session-manager.js.map +0 -1
  390. package/dist/orchviz/session-runtime.d.ts +0 -21
  391. package/dist/orchviz/session-runtime.d.ts.map +0 -1
  392. package/dist/orchviz/session-runtime.js +0 -135
  393. package/dist/orchviz/session-runtime.js.map +0 -1
  394. package/dist/orchviz/session-watcher.d.ts +0 -33
  395. package/dist/orchviz/session-watcher.d.ts.map +0 -1
  396. package/dist/orchviz/session-watcher.js +0 -135
  397. package/dist/orchviz/session-watcher.js.map +0 -1
  398. package/dist/orchviz/subagent-meta.d.ts +0 -12
  399. package/dist/orchviz/subagent-meta.d.ts.map +0 -1
  400. package/dist/orchviz/subagent-meta.js +0 -34
  401. package/dist/orchviz/subagent-meta.js.map +0 -1
  402. package/dist/orchviz/subagent-scanner.d.ts +0 -15
  403. package/dist/orchviz/subagent-scanner.d.ts.map +0 -1
  404. package/dist/orchviz/subagent-scanner.js +0 -27
  405. package/dist/orchviz/subagent-scanner.js.map +0 -1
  406. package/dist/orchviz/subagent-watcher.d.ts +0 -20
  407. package/dist/orchviz/subagent-watcher.d.ts.map +0 -1
  408. package/dist/orchviz/subagent-watcher.js +0 -160
  409. package/dist/orchviz/subagent-watcher.js.map +0 -1
  410. package/dist/orchviz/token-estimator.d.ts.map +0 -1
  411. package/dist/orchviz/token-estimator.js.map +0 -1
  412. package/dist/orchviz/tool-input-data.d.ts +0 -11
  413. package/dist/orchviz/tool-input-data.d.ts.map +0 -1
  414. package/dist/orchviz/tool-input-data.js +0 -74
  415. package/dist/orchviz/tool-input-data.js.map +0 -1
  416. package/dist/orchviz/tool-summarizer.d.ts +0 -16
  417. package/dist/orchviz/tool-summarizer.d.ts.map +0 -1
  418. package/dist/orchviz/tool-summarizer.js +0 -129
  419. package/dist/orchviz/tool-summarizer.js.map +0 -1
  420. package/dist/orchviz-web/fira-code-cyrillic-400-normal.woff +0 -0
  421. package/dist/orchviz-web/fira-code-cyrillic-400-normal.woff2 +0 -0
  422. package/dist/orchviz-web/fira-code-cyrillic-500-normal.woff +0 -0
  423. package/dist/orchviz-web/fira-code-cyrillic-500-normal.woff2 +0 -0
  424. package/dist/orchviz-web/fira-code-cyrillic-ext-400-normal.woff +0 -0
  425. package/dist/orchviz-web/fira-code-cyrillic-ext-400-normal.woff2 +0 -0
  426. package/dist/orchviz-web/fira-code-cyrillic-ext-500-normal.woff +0 -0
  427. package/dist/orchviz-web/fira-code-cyrillic-ext-500-normal.woff2 +0 -0
  428. package/dist/orchviz-web/fira-code-greek-400-normal.woff +0 -0
  429. package/dist/orchviz-web/fira-code-greek-400-normal.woff2 +0 -0
  430. package/dist/orchviz-web/fira-code-greek-500-normal.woff +0 -0
  431. package/dist/orchviz-web/fira-code-greek-500-normal.woff2 +0 -0
  432. package/dist/orchviz-web/fira-code-greek-ext-400-normal.woff +0 -0
  433. package/dist/orchviz-web/fira-code-greek-ext-400-normal.woff2 +0 -0
  434. package/dist/orchviz-web/fira-code-greek-ext-500-normal.woff +0 -0
  435. package/dist/orchviz-web/fira-code-greek-ext-500-normal.woff2 +0 -0
  436. package/dist/orchviz-web/fira-code-latin-400-normal.woff +0 -0
  437. package/dist/orchviz-web/fira-code-latin-400-normal.woff2 +0 -0
  438. package/dist/orchviz-web/fira-code-latin-500-normal.woff +0 -0
  439. package/dist/orchviz-web/fira-code-latin-500-normal.woff2 +0 -0
  440. package/dist/orchviz-web/fira-code-latin-ext-400-normal.woff +0 -0
  441. package/dist/orchviz-web/fira-code-latin-ext-400-normal.woff2 +0 -0
  442. package/dist/orchviz-web/fira-code-latin-ext-500-normal.woff +0 -0
  443. package/dist/orchviz-web/fira-code-latin-ext-500-normal.woff2 +0 -0
  444. package/dist/orchviz-web/fira-code-symbols2-400-normal.woff +0 -0
  445. package/dist/orchviz-web/fira-code-symbols2-500-normal.woff +0 -0
  446. package/dist/orchviz-web/index.css +0 -1
  447. package/dist/orchviz-web/index.html +0 -18
  448. package/dist/orchviz-web/index.js +0 -53
  449. package/dist/orchviz-web/inter-cyrillic-400-normal.woff +0 -0
  450. package/dist/orchviz-web/inter-cyrillic-400-normal.woff2 +0 -0
  451. package/dist/orchviz-web/inter-cyrillic-500-normal.woff +0 -0
  452. package/dist/orchviz-web/inter-cyrillic-500-normal.woff2 +0 -0
  453. package/dist/orchviz-web/inter-cyrillic-600-normal.woff +0 -0
  454. package/dist/orchviz-web/inter-cyrillic-600-normal.woff2 +0 -0
  455. package/dist/orchviz-web/inter-cyrillic-ext-400-normal.woff +0 -0
  456. package/dist/orchviz-web/inter-cyrillic-ext-400-normal.woff2 +0 -0
  457. package/dist/orchviz-web/inter-cyrillic-ext-500-normal.woff +0 -0
  458. package/dist/orchviz-web/inter-cyrillic-ext-500-normal.woff2 +0 -0
  459. package/dist/orchviz-web/inter-cyrillic-ext-600-normal.woff +0 -0
  460. package/dist/orchviz-web/inter-cyrillic-ext-600-normal.woff2 +0 -0
  461. package/dist/orchviz-web/inter-greek-400-normal.woff +0 -0
  462. package/dist/orchviz-web/inter-greek-400-normal.woff2 +0 -0
  463. package/dist/orchviz-web/inter-greek-500-normal.woff +0 -0
  464. package/dist/orchviz-web/inter-greek-500-normal.woff2 +0 -0
  465. package/dist/orchviz-web/inter-greek-600-normal.woff +0 -0
  466. package/dist/orchviz-web/inter-greek-600-normal.woff2 +0 -0
  467. package/dist/orchviz-web/inter-greek-ext-400-normal.woff +0 -0
  468. package/dist/orchviz-web/inter-greek-ext-400-normal.woff2 +0 -0
  469. package/dist/orchviz-web/inter-greek-ext-500-normal.woff +0 -0
  470. package/dist/orchviz-web/inter-greek-ext-500-normal.woff2 +0 -0
  471. package/dist/orchviz-web/inter-greek-ext-600-normal.woff +0 -0
  472. package/dist/orchviz-web/inter-greek-ext-600-normal.woff2 +0 -0
  473. package/dist/orchviz-web/inter-latin-400-normal.woff +0 -0
  474. package/dist/orchviz-web/inter-latin-400-normal.woff2 +0 -0
  475. package/dist/orchviz-web/inter-latin-500-normal.woff +0 -0
  476. package/dist/orchviz-web/inter-latin-500-normal.woff2 +0 -0
  477. package/dist/orchviz-web/inter-latin-600-normal.woff +0 -0
  478. package/dist/orchviz-web/inter-latin-600-normal.woff2 +0 -0
  479. package/dist/orchviz-web/inter-latin-ext-400-normal.woff +0 -0
  480. package/dist/orchviz-web/inter-latin-ext-400-normal.woff2 +0 -0
  481. package/dist/orchviz-web/inter-latin-ext-500-normal.woff +0 -0
  482. package/dist/orchviz-web/inter-latin-ext-500-normal.woff2 +0 -0
  483. package/dist/orchviz-web/inter-latin-ext-600-normal.woff +0 -0
  484. package/dist/orchviz-web/inter-latin-ext-600-normal.woff2 +0 -0
  485. package/dist/orchviz-web/inter-vietnamese-400-normal.woff +0 -0
  486. package/dist/orchviz-web/inter-vietnamese-400-normal.woff2 +0 -0
  487. package/dist/orchviz-web/inter-vietnamese-500-normal.woff +0 -0
  488. package/dist/orchviz-web/inter-vietnamese-500-normal.woff2 +0 -0
  489. package/dist/orchviz-web/inter-vietnamese-600-normal.woff +0 -0
  490. package/dist/orchviz-web/inter-vietnamese-600-normal.woff2 +0 -0
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Apply-feedback CLI mechanics (deterministic half of the Phase-6 loop).
3
+ *
4
+ * The AGENT (the mk:visual-plan skill) classifies + applies each operation
5
+ * (visual-only → CLI patch; plan-semantic → Markdown edit; implementation →
6
+ * deferred; ambiguous → ask). This module owns only the deterministic guards:
7
+ * - `checkBatchFresh` — STOP before ANY mutation if the batch's baseRevision/
8
+ * baseHash no longer match the artifact (no auto-merge onto drifted state).
9
+ * - `recordResolution` — write the per-op receipt write-once (refuse a second
10
+ * apply of the same batch). Receipt existence is the "resolved" marker.
11
+ */
12
+ import { readArtifactRaw, artifactPath, writeArtifact } from "../infrastructure/visual-plan-repository.js";
13
+ import { etagFromFile } from "../../local-web/etag.js";
14
+ import { VisualPlanSchema } from "../domain/schemas.js";
15
+ import { ResolutionReceiptSchema } from "../domain/feedback-schemas.js";
16
+ import { readBatch } from "../infrastructure/feedback-repository.js";
17
+ import { receiptExists, writeReceipt } from "../infrastructure/receipt-repository.js";
18
+ import { buildVisualBlock, writeVisualBlock } from "../infrastructure/plan-state.js";
19
+ import { isValidFeedbackBatchId } from "../domain/ids.js";
20
+ import { nowIso } from "./clock.js";
21
+ /** Verify the batch still applies to the CURRENT artifact (pre-apply gate). */
22
+ export function checkBatchFresh(planDir, batchId) {
23
+ if (!isValidFeedbackBatchId(batchId))
24
+ return { ok: false, reason: `invalid batch id: ${JSON.stringify(batchId)}` };
25
+ const batch = readBatch(planDir, batchId);
26
+ if (!batch)
27
+ return { ok: false, reason: `batch ${batchId} not found or invalid` };
28
+ if (receiptExists(planDir, batchId))
29
+ return { ok: false, reason: `batch ${batchId} already resolved` };
30
+ const read = readArtifactRaw(planDir);
31
+ if (read.error)
32
+ return { ok: false, reason: "no visual artifact" };
33
+ const parsed = VisualPlanSchema.safeParse(read.raw);
34
+ if (!parsed.success)
35
+ return { ok: false, reason: "artifact not schema-valid" };
36
+ const currentHash = etagFromFile(artifactPath(planDir));
37
+ if (batch.baseRevision !== parsed.data.revision || batch.baseHash !== currentHash) {
38
+ return { ok: false, stale: true, reason: `batch base (rev ${batch.baseRevision}) no longer matches artifact (rev ${parsed.data.revision}) — regenerate feedback` };
39
+ }
40
+ return { ok: true };
41
+ }
42
+ /**
43
+ * Write the resolution receipt (agent supplies per-op outcomes). Refuses a
44
+ * double-apply. `resolvedAtRevision` is the artifact's CURRENT revision (after
45
+ * the agent applied ops). Returns the reopen command for re-review.
46
+ */
47
+ export function recordResolution(planDir, batchId, entries) {
48
+ if (!isValidFeedbackBatchId(batchId))
49
+ return { ok: false, error: `invalid batch id: ${JSON.stringify(batchId)}` };
50
+ const batch = readBatch(planDir, batchId);
51
+ if (!batch)
52
+ return { ok: false, error: `batch ${batchId} not found or invalid` };
53
+ if (receiptExists(planDir, batchId))
54
+ return { ok: false, error: `batch ${batchId} already resolved (receipt exists)` };
55
+ const read = readArtifactRaw(planDir);
56
+ if (read.error)
57
+ return { ok: false, error: "no visual artifact" };
58
+ const parsed = VisualPlanSchema.safeParse(read.raw);
59
+ if (!parsed.success)
60
+ return { ok: false, error: "artifact not schema-valid" };
61
+ const receipt = ResolutionReceiptSchema.safeParse({
62
+ schemaVersion: "visual-feedback-receipt/v1",
63
+ batchId,
64
+ planId: parsed.data.id,
65
+ baseRevision: batch.baseRevision,
66
+ resolvedAtRevision: parsed.data.revision,
67
+ resolvedAt: nowIso(),
68
+ entries,
69
+ });
70
+ if (!receipt.success)
71
+ return { ok: false, error: `invalid receipt entries: ${receipt.error.issues[0]?.message ?? "schema"}` };
72
+ if (!writeReceipt(planDir, receipt.data))
73
+ return { ok: false, error: `receipt for ${batchId} already exists` };
74
+ // Clear the batch from the pending list (it is now resolved). When none remain,
75
+ // drop review back to `draft` so the plan is eligible for re-review + approve.
76
+ const plan = parsed.data;
77
+ plan.review.pendingFeedbackBatchIds = plan.review.pendingFeedbackBatchIds.filter((x) => x !== batchId);
78
+ if (plan.review.pendingFeedbackBatchIds.length === 0 && plan.review.status === "feedback-pending") {
79
+ plan.review.status = "draft";
80
+ }
81
+ writeArtifact(planDir, plan);
82
+ writeVisualBlock(planDir, buildVisualBlock(plan, planDir));
83
+ return { ok: true, receiptPath: `visual-plan/resolutions/${batchId}.json`, reopenCommand: `mewkit visual-plan edit ${planDir}` };
84
+ }
85
+ //# sourceMappingURL=apply-feedback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-feedback.js","sourceRoot":"","sources":["../../../src/visual-plan/application/apply-feedback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAC3G,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAQpC,+EAA+E;AAC/E,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,OAAe;IAC/D,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,qBAAqB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;IACnH,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1C,IAAI,CAAC,KAAK;QAAE,OAAO,EAA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E,KAAK,EAAE,eAAe,OAAO,iBAAiB,EAAE,CAAC;IAE/G,gFAAgF;IAChF,+EAA+E;IAC/E,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,IAAI,CAAC,MAAM,CAAC,uBAAuB,GAAG,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC;IACvG,IAAI,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,kBAAkB,EAAE,CAAC;QACnG,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC;IAC9B,CAAC;IACD,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC7B,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAE3D,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,2BAA2B,OAAO,OAAO,EAAE,aAAa,EAAE,2BAA2B,OAAO,EAAE,EAAE,CAAC;AAClI,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Apply a single typed visual patch op to a parsed plan (mutates in place).
3
+ *
4
+ * Returns an error message when the op cannot apply (unknown target, duplicate
5
+ * append, unknown wireframe field); the orchestrator rejects the patch and never
6
+ * writes. Structural/coverage/safety re-validation is the orchestrator's job —
7
+ * this function only performs the mutation and the immediate target checks.
8
+ */
9
+ import type { PatchOp } from "../domain/patches.js";
10
+ import type { VisualPlan } from "../domain/schemas.js";
11
+ /** Mutate `plan` by `op`. Returns null on success, or an error message. */
12
+ export declare function applyPatchOp(plan: VisualPlan, op: PatchOp): string | null;
13
+ //# sourceMappingURL=apply-patch-op.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-patch-op.d.ts","sourceRoot":"","sources":["../../../src/visual-plan/application/apply-patch-op.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,sBAAsB,CAAC;AAGnE,2EAA2E;AAC3E,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAiDzE"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Apply a single typed visual patch op to a parsed plan (mutates in place).
3
+ *
4
+ * Returns an error message when the op cannot apply (unknown target, duplicate
5
+ * append, unknown wireframe field); the orchestrator rejects the patch and never
6
+ * writes. Structural/coverage/safety re-validation is the orchestrator's job —
7
+ * this function only performs the mutation and the immediate target checks.
8
+ */
9
+ import { editWireframeField } from "../infrastructure/wireframe-sanitizer.js";
10
+ /** Mutate `plan` by `op`. Returns null on success, or an error message. */
11
+ export function applyPatchOp(plan, op) {
12
+ switch (op.type) {
13
+ case "move-frame-lane": {
14
+ const frame = plan.canvas.frames.find((f) => f.id === op.frameId);
15
+ if (!frame)
16
+ return `unknown frame "${op.frameId}"`;
17
+ if (!plan.canvas.lanes.some((l) => l.id === op.laneId))
18
+ return `unknown lane "${op.laneId}"`;
19
+ frame.laneId = op.laneId;
20
+ return null;
21
+ }
22
+ case "reorder-frame": {
23
+ const frame = plan.canvas.frames.find((f) => f.id === op.frameId);
24
+ if (!frame)
25
+ return `unknown frame "${op.frameId}"`;
26
+ frame.order = op.order;
27
+ return null;
28
+ }
29
+ case "update-annotation": {
30
+ const a = plan.canvas.annotations.find((x) => x.id === op.annotationId);
31
+ if (!a)
32
+ return `unknown annotation "${op.annotationId}"`;
33
+ if (op.text !== undefined)
34
+ a.text = op.text;
35
+ if (op.placement !== undefined)
36
+ a.placement = op.placement;
37
+ if (op.points !== undefined)
38
+ a.points = op.points;
39
+ return null;
40
+ }
41
+ case "append-annotation": {
42
+ const anno = op.annotation;
43
+ if (plan.canvas.annotations.some((x) => x.id === anno.id))
44
+ return `annotation id "${anno.id}" already exists`;
45
+ plan.canvas.annotations.push(anno);
46
+ return null;
47
+ }
48
+ case "remove-annotation": {
49
+ const before = plan.canvas.annotations.length;
50
+ plan.canvas.annotations = plan.canvas.annotations.filter((x) => x.id !== op.annotationId);
51
+ return plan.canvas.annotations.length === before ? `unknown annotation "${op.annotationId}"` : null;
52
+ }
53
+ case "update-connector-label": {
54
+ const c = plan.canvas.connectors.find((x) => x.id === op.connectorId);
55
+ if (!c)
56
+ return `unknown connector "${op.connectorId}"`;
57
+ c.label = op.label;
58
+ return null;
59
+ }
60
+ case "update-wireframe-field": {
61
+ const frame = plan.canvas.frames.find((f) => f.id === op.frameId);
62
+ if (!frame)
63
+ return `unknown frame "${op.frameId}"`;
64
+ const edited = editWireframeField(frame.wireframe.html, op.fieldId, op.text);
65
+ if (edited === null)
66
+ return `no editable field "wf-field-${op.fieldId}" in frame "${op.frameId}"`;
67
+ frame.wireframe.html = edited;
68
+ return null;
69
+ }
70
+ }
71
+ }
72
+ //# sourceMappingURL=apply-patch-op.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-patch-op.js","sourceRoot":"","sources":["../../../src/visual-plan/application/apply-patch-op.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAE9E,2EAA2E;AAC3E,MAAM,UAAU,YAAY,CAAC,IAAgB,EAAE,EAAW;IACzD,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;QACjB,KAAK,iBAAiB,CAAC,CAAC,CAAC;YACxB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,CAAC;YAClE,IAAI,CAAC,KAAK;gBAAE,OAAO,kBAAkB,EAAE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ACD,KAAK,wBAAwB,CAAC,CAAC,CAAC;YAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,CAAC;YAClE,IAAI,CAAC,KAAK;gBAAE,OAAO,kBAAkB,EAAE,CAAC,OAAO,GAAG,CAAC;YACnD,MAAM,MAAM,GAAG,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;YAC7E,IAAI,MAAM,KAAK,IAAI;gBAAE,OAAO,+BAA+B,EAAE,CAAC,OAAO,eAAe,EAAE,CAAC,OAAO,GAAG,CAAC;YAClG,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,MAAM,CAAC;YAC9B,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC;AACF,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * `approve` — the deterministic post-Gate-1 transition (moved here from Phase 6
3
+ * per red-team C1 so Gate 1 is satisfiable from the first Phase-3 release).
4
+ *
5
+ * The CLI is the SINGLE writer of `review.status`. Approval is refused unless
6
+ * EVERY precondition holds: the artifact fully validates (schema, cross-refs,
7
+ * coverage with `unresolved === 0`, safe HTML, fresh source hashes), there is
8
+ * no pending feedback batch, and the requested `--revision` matches the
9
+ * artifact's current revision (so approval is pinned to the exact reviewed
10
+ * state). On success it stamps `review` and refreshes the `.plan-state` pointer.
11
+ * No skill ever writes an interim approval.
12
+ */
13
+ export interface ApproveResult {
14
+ ok: boolean;
15
+ revision: number;
16
+ /** Human-readable reasons approval was refused; empty on success. */
17
+ failedPreconditions: string[];
18
+ }
19
+ /**
20
+ * Approve the artifact at `planDir` for exactly `revision`. Returns the refused
21
+ * preconditions instead of throwing, so the CLI can list them and exit non-zero.
22
+ */
23
+ export declare function approvePlan(planDir: string, revision: number): ApproveResult;
24
+ //# sourceMappingURL=approve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approve.d.ts","sourceRoot":"","sources":["../../../src/visual-plan/application/approve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH,MAAM,WAAW,aAAa;IAC7B,EAAE,EAAE,OAAO,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa,CA+B5E"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * `approve` — the deterministic post-Gate-1 transition (moved here from Phase 6
3
+ * per red-team C1 so Gate 1 is satisfiable from the first Phase-3 release).
4
+ *
5
+ * The CLI is the SINGLE writer of `review.status`. Approval is refused unless
6
+ * EVERY precondition holds: the artifact fully validates (schema, cross-refs,
7
+ * coverage with `unresolved === 0`, safe HTML, fresh source hashes), there is
8
+ * no pending feedback batch, and the requested `--revision` matches the
9
+ * artifact's current revision (so approval is pinned to the exact reviewed
10
+ * state). On success it stamps `review` and refreshes the `.plan-state` pointer.
11
+ * No skill ever writes an interim approval.
12
+ */
13
+ import { validatePlan } from "./validate-plan.js";
14
+ import { writeArtifact } from "../infrastructure/visual-plan-repository.js";
15
+ import { buildVisualBlock, writeVisualBlock } from "../infrastructure/plan-state.js";
16
+ import { listReceipts } from "../infrastructure/receipt-repository.js";
17
+ import { nowIso } from "./clock.js";
18
+ /**
19
+ * Approve the artifact at `planDir` for exactly `revision`. Returns the refused
20
+ * preconditions instead of throwing, so the CLI can list them and exit non-zero.
21
+ */
22
+ export function approvePlan(planDir, revision) {
23
+ const failed = [];
24
+ const result = validatePlan(planDir);
25
+ if (!result.ok || !result.plan) {
26
+ for (const e of result.errors)
27
+ failed.push(`${e.path}: ${e.message} [${e.code}]`);
28
+ return { ok: false, revision, failedPreconditions: failed };
29
+ }
30
+ const plan = result.plan;
31
+ if (plan.revision !== revision) {
32
+ failed.push(`--revision ${revision} does not match artifact revision ${plan.revision}`);
33
+ }
34
+ if (plan.review.pendingFeedbackBatchIds.length > 0) {
35
+ failed.push(`cannot approve with ${plan.review.pendingFeedbackBatchIds.length} pending feedback batch(es)`);
36
+ }
37
+ // Receipt-aware refusal (Phase 6): a resolution receipt at the CURRENT revision
38
+ // with any unresolved semantic op means the feedback was not fully applied.
39
+ for (const receipt of listReceipts(planDir)) {
40
+ if (receipt.resolvedAtRevision === revision && receipt.entries.some((e) => e.outcome === "unresolved")) {
41
+ failed.push(`resolution receipt ${receipt.batchId} has unresolved operations at revision ${revision}`);
42
+ }
43
+ }
44
+ if (failed.length > 0)
45
+ return { ok: false, revision, failedPreconditions: failed };
46
+ plan.review.status = "approved";
47
+ plan.review.approvedRevision = revision;
48
+ plan.review.approvedAt = nowIso();
49
+ writeArtifact(planDir, plan);
50
+ writeVisualBlock(planDir, buildVisualBlock(plan, planDir));
51
+ return { ok: true, revision, failedPreconditions: [] };
52
+ }
53
+ //# sourceMappingURL=approve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approve.js","sourceRoot":"","sources":["../../../src/visual-plan/application/approve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AASpC;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,QAAgB;IAC5D,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,YAAY,CAAC,OA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AAE,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAEnF,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,UAAU,CAAC;IAChC,IAAI,CAAC,MAAM,CAAC,gBAAgB,GAAG,QAAQ,CAAC;IACxC,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,MAAM,EAAE,CAAC;IAClC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC7B,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3D,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,mBAAmB,EAAE,EAAE,EAAE,CAAC;AACxD,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Timestamp source, isolated so tests can assert format without freezing time.
3
+ * Kept trivial on purpose — the only reason it is a module is to give approval
4
+ * and rehash a single, mockable clock seam.
5
+ */
6
+ /** Current time as an ISO-8601 string. */
7
+ export declare function nowIso(): string;
8
+ //# sourceMappingURL=clock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../../../src/visual-plan/application/clock.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,0CAA0C;AAC1C,wBAAgB,MAAM,IAAI,MAAM,CAE/B"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Timestamp source, isolated so tests can assert format without freezing time.
3
+ * Kept trivial on purpose — the only reason it is a module is to give approval
4
+ * and rehash a single, mockable clock seam.
5
+ */
6
+ /** Current time as an ISO-8601 string. */
7
+ export function nowIso() {
8
+ return new Date().toISOString();
9
+ }
10
+ //# sourceMappingURL=clock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clock.js","sourceRoot":"","sources":["../../../src/visual-plan/application/clock.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,0CAA0C;AAC1C,MAAM,UAAU,MAAM;IACrB,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AACjC,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `export --format html` — render the CURRENT artifact into ONE self-contained,
3
+ * offline `plan.html`. The output carries the artifact's `review.status` in its
4
+ * header, so a draft export is never mistaken for final; the plan-creator flow
5
+ * (Step 8b) calls this only AFTER approval, making that export the canonical one.
6
+ *
7
+ * Safety: every plan-sourced string is HTML-escaped; wireframes are re-sanitized
8
+ * before inlining; there are no `<script>` tags and no auto-fetching elements
9
+ * (no `img`/`src`/`link`), so the page opens with zero network requests. A
10
+ * wireframe `<a href>` to a remote host is permitted but inert until clicked.
11
+ */
12
+ export interface ExportResult {
13
+ ok: boolean;
14
+ html?: string;
15
+ error?: string;
16
+ }
17
+ /** Build the self-contained plan.html string from the artifact at `planDir`. */
18
+ export declare function exportPlanHtml(planDir: string): ExportResult;
19
+ //# sourceMappingURL=export-plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-plan.d.ts","sourceRoot":"","sources":["../../../src/visual-plan/application/export-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,MAAM,WAAW,YAAY;IAC5B,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAqCD,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAS5D"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * `export --format html` — render the CURRENT artifact into ONE self-contained,
3
+ * offline `plan.html`. The output carries the artifact's `review.status` in its
4
+ * header, so a draft export is never mistaken for final; the plan-creator flow
5
+ * (Step 8b) calls this only AFTER approval, making that export the canonical one.
6
+ *
7
+ * Safety: every plan-sourced string is HTML-escaped; wireframes are re-sanitized
8
+ * before inlining; there are no `<script>` tags and no auto-fetching elements
9
+ * (no `img`/`src`/`link`), so the page opens with zero network requests. A
10
+ * wireframe `<a href>` to a remote host is permitted but inert until clicked.
11
+ */
12
+ import { readArtifactRaw } from "../infrastructure/visual-plan-repository.js";
13
+ import { sanitizeWireframeHtml } from "../infrastructure/wireframe-sanitizer.js";
14
+ import { computeCoverage } from "../domain/coverage.js";
15
+ import { VisualPlanSchema } from "../domain/schemas.js";
16
+ /** HTML-entity-encode a plan-sourced string for safe text/attribute placement. */
17
+ function esc(s) {
18
+ return s.replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
19
+ }
20
+ function coverageSection(plan) {
21
+ const { summary } = computeCoverage(plan);
22
+ const rows = plan.uiCoverage.surfaces
23
+ .flatMap((s) => s.states.map((st) => `<tr><td>${esc(s.label ?? s.id)}</td><td>${esc(st.label ?? st.id)}</td><td>${st.frameIds.length > 0 ? "framed" : st.omitted ? esc(st.omitted.reason) : "unresolved"}</td></tr>`))
24
+ .join("");
25
+ return `<h2>Coverage</h2><p class="vp-sum">${summary.resolved} resolved · ${summary.planned} planned · ${summary.omitted} omitted · ${summary.unresolved} unresolved</p><table><thead><tr><th>Surface</th><th>State</th><th>Closure</th></tr></thead><tbody>${rows}</tbody></table>`;
26
+ }
27
+ function framesSection(plan) {
28
+ const cards = plan.canvas.frames
29
+ .map((f) => `<article class="vp-frame"><header><strong>${esc(f.label)}</strong> <span class="vp-badge">${esc(f.surface)} · ${esc(f.changeMode)}</span></header><div class="wf-root">${sanitizeWireframeHtml(f.wireframe.html)}</div></article>`)
30
+ .join("");
31
+ return `<h2>Frames</h2><div class="vp-frames">${cards}</div>`;
32
+ }
33
+ function docsSection(plan) {
34
+ if (plan.documentBlocks.length === 0)
35
+ return "";
36
+ const items = plan.documentBlocks.map((b) => `<li>${b.title ? `<strong>${esc(b.title)}:</strong> ` : ""}${esc(b.body)}</li>`).join("");
37
+ return `<h2>Mechanics</h2><ul>${items}</ul>`;
38
+ }
39
+ const STYLE = `body{font:14px/1.5 system-ui,sans-serif;margin:0;padding:24px;background:#fff;color:#1c2430}
40
+ h1{margin:0 0 4px}h2{margin:24px 0 8px;border-bottom:1px solid #d7dbe0;padding-bottom:4px}
41
+ table{border-collapse:collapse;width:100%}th,td{border:1px solid #d7dbe0;padding:4px 8px;text-align:left;font-size:13px}
42
+ .vp-sum{color:#64707d}.vp-frames{display:flex;flex-wrap:wrap;gap:16px}
43
+ .vp-frame{border:1px solid #d7dbe0;border-radius:8px;overflow:hidden;width:340px}
44
+ .vp-frame header{padding:6px 10px;border-bottom:1px solid #d7dbe0;background:#f4f5f7}
45
+ .vp-badge{color:#64707d;font-size:12px}.wf-root{padding:10px}.wf-root .wf-button{display:inline-block;padding:6px 12px;background:#3563e9;color:#fff;border-radius:6px;text-decoration:none}
46
+ .wf-root .wf-input{height:30px;border:1px solid #d7dbe0;border-radius:6px;background:#eef1f4}.wf-root .wf-error{color:#c0392b}`;
47
+ /** Build the self-contained plan.html string from the artifact at `planDir`. */
48
+ export function exportPlanHtml(planDir) {
49
+ const read = readArtifactRaw(planDir);
50
+ if (read.error)
51
+ return { ok: false, error: read.error.message };
52
+ const parsed = VisualPlanSchema.safeParse(read.raw);
53
+ if (!parsed.success)
54
+ return { ok: false, error: "artifact must be schema-valid to export" };
55
+ const plan = parsed.data;
56
+ const html = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${esc(plan.id)} — visual plan</title><style>${STYLE}</style></head><body><h1>${esc(plan.id)}</h1><p class="vp-sum">revision ${plan.revision} · review ${esc(plan.review.status)}</p>${coverageSection(plan)}${framesSection(plan)}${docsSection(plan)}</body></html>\n`;
57
+ return { ok: true, html };
58
+ }
59
+ //# sourceMappingURL=export-plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-plan.js","sourceRoot":"","sources":["../../../src/visual-plan/application/export-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OA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S,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,yCAAyC,EAAE,CAAC;IAC5F,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IAEzB,MAAM,IAAI,GAAG,wIAAwI,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,gCAAgC,KAAK,4BAA4B,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,mCAAmC,IAAI,CAAC,QAAQ,aAAa,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC;IAC3Z,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Patch orchestrator — the single serialized writer behind PATCH /api/visual-plan.
3
+ *
4
+ * Flow: read → optimistic-concurrency check (If-Match ETag) → apply the typed op
5
+ * → bump revision + CLEAR approval → re-validate the mutated plan IN MEMORY →
6
+ * atomic write → return the new ETag. A stale ETag stops before any mutation
7
+ * (409). A patch that would make the artifact invalid/unsafe is rejected and
8
+ * NOT written, so the on-disk artifact is always valid. Approval is cleared on
9
+ * every accepted visual mutation (lane/order/annotation/connector/field) —
10
+ * re-review + re-approve must follow.
11
+ */
12
+ import type { PatchOp } from "../domain/patches.js";
13
+ import type { ValidationError } from "../domain/errors.js";
14
+ export type PatchStatus = "ok" | "stale" | "missing" | "invalid-artifact" | "op-rejected" | "invalid-result";
15
+ export interface PatchResult {
16
+ ok: boolean;
17
+ status: PatchStatus;
18
+ revision?: number;
19
+ etag?: string;
20
+ currentEtag?: string;
21
+ message?: string;
22
+ errors?: ValidationError[];
23
+ }
24
+ /** Apply `op` to the artifact at `planDir` under optimistic concurrency (`ifMatch`). */
25
+ export declare function patchPlan(planDir: string, op: PatchOp, ifMatch?: string): PatchResult;
26
+ //# sourceMappingURL=patch-plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patch-plan.d.ts","sourceRoot":"","sources":["../../../src/visual-plan/application/patch-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAIpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,GAAG,kBAAkB,GAAG,aAAa,GAAG,gBAAgB,CAAC;AAE7G,MAAM,WAAW,WAAW;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,wFAAwF;AACxF,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CA0BrF"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Patch orchestrator — the single serialized writer behind PATCH /api/visual-plan.
3
+ *
4
+ * Flow: read → optimistic-concurrency check (If-Match ETag) → apply the typed op
5
+ * → bump revision + CLEAR approval → re-validate the mutated plan IN MEMORY →
6
+ * atomic write → return the new ETag. A stale ETag stops before any mutation
7
+ * (409). A patch that would make the artifact invalid/unsafe is rejected and
8
+ * NOT written, so the on-disk artifact is always valid. Approval is cleared on
9
+ * every accepted visual mutation (lane/order/annotation/connector/field) —
10
+ * re-review + re-approve must follow.
11
+ */
12
+ import { readArtifactRaw, writeArtifact, artifactPath } from "../infrastructure/visual-plan-repository.js";
13
+ import { etagFromFile } from "../../local-web/etag.js";
14
+ import { VisualPlanSchema } from "../domain/schemas.js";
15
+ import { applyPatchOp } from "./apply-patch-op.js";
16
+ import { validateParsed } from "./validate-plan.js";
17
+ import { buildVisualBlock, writeVisualBlock } from "../infrastructure/plan-state.js";
18
+ /** Apply `op` to the artifact at `planDir` under optimistic concurrency (`ifMatch`). */
19
+ export function patchPlan(planDir, op, ifMatch) {
20
+ const currentEtag = etagFromFile(artifactPath(planDir));
21
+ if (currentEtag === null)
22
+ return { ok: false, status: "missing" };
23
+ if (ifMatch !== undefined && ifMatch !== currentEtag)
24
+ return { ok: false, status: "stale", currentEtag };
25
+ const read = readArtifactRaw(planDir);
26
+ if (read.error)
27
+ return { ok: false, status: "missing" };
28
+ const parsed = VisualPlanSchema.safeParse(read.raw);
29
+ if (!parsed.success)
30
+ return { ok: false, status: "invalid-artifact" };
31
+ const plan = parsed.data;
32
+ const opError = applyPatchOp(plan, op);
33
+ if (opError)
34
+ return { ok: false, status: "op-rejected", message: opError };
35
+ // Every accepted visual mutation invalidates approval and advances the revision.
36
+ plan.revision += 1;
37
+ if (plan.review.status === "approved")
38
+ plan.review.status = "draft";
39
+ plan.review.approvedRevision = null;
40
+ plan.review.approvedAt = null;
41
+ const { errors } = validateParsed(plan, planDir);
42
+ if (errors.length > 0)
43
+ return { ok: false, status: "invalid-result", errors };
44
+ writeArtifact(planDir, plan);
45
+ writeVisualBlock(planDir, buildVisualBlock(plan, planDir));
46
+ return { ok: true, status: "ok", revision: plan.revision, etag: etagFromFile(artifactPath(planDir)) ?? undefined };
47
+ }
48
+ //# sourceMappingURL=patch-plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patch-plan.js","sourceRoot":"","sources":["../../../src/visual-plan/application/patch-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,YA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a,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IAE3E,iFAAiF;IACjF,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC;IACnB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,UAAU;QAAE,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC;IACpE,IAAI,CAAC,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAC;IACpC,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;IAE9B,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAE9E,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC7B,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3D,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,YAAY,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC;AACpH,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * `prepare-feedback` — freeze the accumulated semantic operations into an
3
+ * immutable `visual-feedback/v1` batch and return the Copy Command.
4
+ *
5
+ * The SERVER is authoritative for the base: `baseRevision` + `baseHash` are
6
+ * stamped from the CURRENT artifact at persist time (not trusted from the
7
+ * client), so a batch always pins the exact reviewed state. The batch is
8
+ * write-once; the Copy Command is a repo-relative `/mk:visual-plan apply-feedback`
9
+ * a fresh agent session can run. Timestamps use the wall clock (this is a normal
10
+ * CLI/server runtime, not a workflow script).
11
+ */
12
+ export interface PrepareResult {
13
+ ok: boolean;
14
+ batchId?: string;
15
+ copyCommand?: string;
16
+ error?: string;
17
+ }
18
+ /**
19
+ * Build + persist an immutable feedback batch from `operations`. Returns the
20
+ * batch id + Copy Command, or an error (empty/invalid operations, missing
21
+ * artifact, id collision).
22
+ */
23
+ export declare function prepareFeedback(planDir: string, operations: unknown[]): PrepareResult;
24
+ //# sourceMappingURL=prepare-feedback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare-feedback.d.ts","sourceRoot":"","sources":["../../../src/visual-plan/application/prepare-feedback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH,MAAM,WAAW,aAAa;IAC7B,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AASD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,aAAa,CAsCrF"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * `prepare-feedback` — freeze the accumulated semantic operations into an
3
+ * immutable `visual-feedback/v1` batch and return the Copy Command.
4
+ *
5
+ * The SERVER is authoritative for the base: `baseRevision` + `baseHash` are
6
+ * stamped from the CURRENT artifact at persist time (not trusted from the
7
+ * client), so a batch always pins the exact reviewed state. The batch is
8
+ * write-once; the Copy Command is a repo-relative `/mk:visual-plan apply-feedback`
9
+ * a fresh agent session can run. Timestamps use the wall clock (this is a normal
10
+ * CLI/server runtime, not a workflow script).
11
+ */
12
+ import * as crypto from "node:crypto";
13
+ import * as path from "node:path";
14
+ import { readArtifactRaw, writeArtifact, serializeArtifact } from "../infrastructure/visual-plan-repository.js";
15
+ import { computeEtag } from "../../local-web/etag.js";
16
+ import { VisualPlanSchema } from "../domain/schemas.js";
17
+ import { FeedbackBatchSchema } from "../domain/feedback-schemas.js";
18
+ import { writeBatch } from "../infrastructure/feedback-repository.js";
19
+ import { buildVisualBlock, writeVisualBlock } from "../infrastructure/plan-state.js";
20
+ /** Compact `YYYYMMDDHHMMSS` timestamp (≥8 digits, satisfies the batch-id pattern). */
21
+ function stamp() {
22
+ const d = new Date();
23
+ const p = (n, w = 2) => String(n).padStart(w, "0");
24
+ return `${d.getFullYear()}${p(d.getMonth() + 1)}${p(d.getDate())}${p(d.getHours())}${p(d.getMinutes())}${p(d.getSeconds())}`;
25
+ }
26
+ /**
27
+ * Build + persist an immutable feedback batch from `operations`. Returns the
28
+ * batch id + Copy Command, or an error (empty/invalid operations, missing
29
+ * artifact, id collision).
30
+ */
31
+ export function prepareFeedback(planDir, operations) {
32
+ const read = readArtifactRaw(planDir);
33
+ if (read.error)
34
+ return { ok: false, error: "no visual artifact to attach feedback to" };
35
+ const parsed = VisualPlanSchema.safeParse(read.raw);
36
+ if (!parsed.success)
37
+ return { ok: false, error: "artifact must be schema-valid before preparing feedback" };
38
+ const plan = parsed.data;
39
+ // Validate the operations BEFORE mutating the artifact (build a throwaway batch
40
+ // with a placeholder hash just to run the op schema).
41
+ const id = `feedback-${stamp()}-${crypto.randomBytes(4).toString("hex")}`;
42
+ const opCheck = FeedbackBatchSchema.safeParse({
43
+ schemaVersion: "visual-feedback/v1", id, planId: plan.id, baseRevision: plan.revision,
44
+ baseHash: "0".repeat(64), createdAt: new Date().toISOString(), operations, status: "open",
45
+ });
46
+ if (!opCheck.success)
47
+ return { ok: false, error: `invalid feedback operations: ${opCheck.error.issues[0]?.message ?? "schema"}` };
48
+ // Transition review → feedback-pending: outstanding feedback makes the current
49
+ // approval stale and BLOCKS approve (the "no pending feedback batch" gate).
50
+ // NOTE: this is effectively single-active-batch — baseHash covers the whole
51
+ // artifact incl. the pending list, so preparing/resolving another batch marks
52
+ // earlier open batches stale (fails safe: checkBatchFresh → STOP, never corrupt).
53
+ plan.review.pendingFeedbackBatchIds = [...new Set([...plan.review.pendingFeedbackBatchIds, id])];
54
+ plan.review.status = "feedback-pending";
55
+ plan.review.approvedRevision = null;
56
+ plan.review.approvedAt = null;
57
+ // Write the batch BEFORE mutating the artifact, using the EXACT bytes the
58
+ // artifact write will persist (byte-identical serialization). A crash between
59
+ // the two writes then leaves at worst an inert STALE batch (recoverable), never
60
+ // a stranded pending id with no batch (which would permanently block approve).
61
+ const bytes = serializeArtifact(plan);
62
+ const batch = FeedbackBatchSchema.safeParse({ ...opCheck.data, baseHash: computeEtag(bytes) });
63
+ if (!batch.success || !writeBatch(planDir, batch.data))
64
+ return { ok: false, error: `could not persist batch ${id}` };
65
+ writeArtifact(planDir, plan);
66
+ writeVisualBlock(planDir, buildVisualBlock(plan, planDir));
67
+ const rel = path.relative(process.cwd(), planDir) || ".";
68
+ return { ok: true, batchId: id, copyCommand: `/mk:visual-plan apply-feedback ${rel} --batch ${id}` };
69
+ }
70
+ //# sourceMappingURL=prepare-feedback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare-feedback.js","sourceRoot":"","sources":["../../../src/visual-plan/application/prepare-feedback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAChH,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AASrF,sFAAsF;AACtF,SAAS,KAAK;IACb,MAAM,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;IACrB,MAAM,CAAC,GAAG,CAAC,CAAS,EAAE,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C7B,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAE3D,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,IAAI,GAAG,CAAC;IACzD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,kCAAkC,GAAG,YAAY,EAAE,EAAE,EAAE,CAAC;AACtG,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `rehash` — the ONLY sanctioned way to refresh pinned source hashes after an
3
+ * intentional Markdown edit (red-team M1).
4
+ *
5
+ * When a human deliberately edits `plan.md`/`phase-*.md`, the artifact's pinned
6
+ * hashes go stale and validation blocks. `rehash` recomputes them from disk and
7
+ * — critically — CLEARS any prior approval (an approval was tied to the old
8
+ * source bytes; refreshing the hash silently would let stale-reviewed content
9
+ * pass Gate 1). It changes nothing else. Re-review + re-`approve` must follow.
10
+ */
11
+ import { type ValidationError } from "../domain/errors.js";
12
+ export interface RehashResult {
13
+ ok: boolean;
14
+ errors: ValidationError[];
15
+ clearedApproval: boolean;
16
+ }
17
+ /** Recompute `source.planHash`/`phaseHashes` from disk and clear any approval. */
18
+ export declare function rehashPlan(planDir: string): RehashResult;
19
+ //# sourceMappingURL=rehash.d.ts.map