@1agh/maude 2.0.8 → 2.1.1

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 (401) hide show
  1. package/README.md +2 -1
  2. package/apps/hub/src/project-transactions/kernel.mjs +13 -7
  3. package/apps/studio/access/closure.ts +86 -10
  4. package/apps/studio/access/filters.ts +18 -1
  5. package/apps/studio/access/request.ts +8 -0
  6. package/apps/studio/acp/design-write-verb.ts +12 -2
  7. package/apps/studio/acp/env.ts +7 -2
  8. package/apps/studio/acp/index.ts +15 -4
  9. package/apps/studio/acp/login-state.ts +22 -5
  10. package/apps/studio/acp/may-scope.ts +38 -1
  11. package/apps/studio/acp/plugin-bootstrap.ts +13 -1
  12. package/apps/studio/acp/probe.ts +11 -4
  13. package/apps/studio/actions/agents.ts +110 -28
  14. package/apps/studio/actions/canvas-keys.ts +4 -2
  15. package/apps/studio/actions/ctx.ts +3 -0
  16. package/apps/studio/actions/defs/annotation.ts +84 -2
  17. package/apps/studio/actions/defs/app.ts +28 -1
  18. package/apps/studio/actions/defs/edit.ts +13 -0
  19. package/apps/studio/actions/defs/export.ts +12 -0
  20. package/apps/studio/actions/defs/sync.ts +18 -0
  21. package/apps/studio/actions/defs/video.ts +9 -0
  22. package/apps/studio/actions/documents.ts +6 -1
  23. package/apps/studio/actions/keymap.gen.ts +147 -9
  24. package/apps/studio/actions/menu.ts +5 -1
  25. package/apps/studio/actions/types.ts +4 -2
  26. package/apps/studio/actions/verbs.ts +9 -0
  27. package/apps/studio/actions.manifest.json +300 -45
  28. package/apps/studio/actions.parity.json +19 -1
  29. package/apps/studio/ai/save-hold.ts +2 -1
  30. package/apps/studio/ai/write-claim-scope.ts +7 -1
  31. package/apps/studio/ai/write-claim.ts +154 -3
  32. package/apps/studio/annotations/ai-read.ts +42 -6
  33. package/apps/studio/annotations/ai-write.ts +145 -2
  34. package/apps/studio/annotations/board-ops.ts +34 -3
  35. package/apps/studio/annotations/checklist-ops.ts +374 -0
  36. package/apps/studio/annotations/elements/checkitem.model.ts +129 -0
  37. package/apps/studio/annotations/elements/sticky.model.ts +54 -2
  38. package/apps/studio/annotations/ops.ts +30 -0
  39. package/apps/studio/annotations/registry.ts +9 -1
  40. package/apps/studio/annotations/templates.ts +4 -2
  41. package/apps/studio/annotations/text-steps.ts +114 -10
  42. package/apps/studio/annotations/ui/checklist-wire.ts +129 -0
  43. package/apps/studio/annotations/ui/checklist.tsx +429 -0
  44. package/apps/studio/annotations/ui/element-node.tsx +48 -2
  45. package/apps/studio/annotations/ui/template-place.ts +11 -1
  46. package/apps/studio/annotations/v1-adapter.ts +22 -3
  47. package/apps/studio/annotations-context-toolbar.tsx +12 -0
  48. package/apps/studio/annotations-layer.tsx +442 -49
  49. package/apps/studio/annotations-model.ts +4 -2
  50. package/apps/studio/api.ts +148 -21
  51. package/apps/studio/artboard-live-gate.tsx +54 -17
  52. package/apps/studio/artboard-still-persist.ts +166 -0
  53. package/apps/studio/artboard-still-raster.ts +6 -2
  54. package/apps/studio/artboard-still.ts +390 -20
  55. package/apps/studio/asset-added.ts +154 -0
  56. package/apps/studio/asset-details.ts +46 -3
  57. package/apps/studio/asset-origins.ts +5 -3
  58. package/apps/studio/asset-trash.ts +6 -1
  59. package/apps/studio/bin/_agent-browser-safe.mjs +3 -4
  60. package/apps/studio/bin/_annotate-post.mjs +14 -5
  61. package/apps/studio/bin/_audio-search.mjs +8 -2
  62. package/apps/studio/bin/_curl-local.mjs +7 -4
  63. package/apps/studio/bin/_desktop-locate.sh +145 -0
  64. package/apps/studio/bin/_ds-check-live.mjs +2 -1
  65. package/apps/studio/bin/_exports.mjs +38 -2
  66. package/apps/studio/bin/_history.mjs +79 -8
  67. package/apps/studio/bin/_import-asset.mjs +14 -9
  68. package/apps/studio/bin/_import-figma.mjs +510 -98
  69. package/apps/studio/bin/_index-cli.mjs +10 -21
  70. package/apps/studio/bin/_ingest-footage.mjs +24 -6
  71. package/apps/studio/bin/_media-probe.mjs +232 -0
  72. package/apps/studio/bin/_perf-probe-open.mjs +6 -0
  73. package/apps/studio/bin/_perf-probe-safari.mjs +6 -0
  74. package/apps/studio/bin/_perf-probe-studio.mjs +6 -1
  75. package/apps/studio/bin/_perf-probe.mjs +8 -3
  76. package/apps/studio/bin/_perf-sweep-shared.mjs +789 -0
  77. package/apps/studio/bin/_perf-sweep.mjs +240 -0
  78. package/apps/studio/bin/_record-shot.sh +33 -8
  79. package/apps/studio/bin/_screenshot-playwright.mjs +45 -2
  80. package/apps/studio/bin/_studio-verb.mjs +8 -3
  81. package/apps/studio/bin/_thumb-route.mjs +21 -0
  82. package/apps/studio/bin/_thumbs-playwright.mjs +83 -1
  83. package/apps/studio/bin/_transcribe.mjs +22 -6
  84. package/apps/studio/bin/_unsynced-refs.mjs +22 -0
  85. package/apps/studio/bin/_url-guard.mjs +120 -5
  86. package/apps/studio/bin/_url-guard.sh +29 -7
  87. package/apps/studio/bin/_video-limits.mjs +104 -0
  88. package/apps/studio/bin/_video-playwright.mjs +119 -19
  89. package/apps/studio/bin/_video-proxy.mjs +130 -0
  90. package/apps/studio/bin/_write-claim.mjs +38 -16
  91. package/apps/studio/bin/annotate.mjs +12 -2
  92. package/apps/studio/bin/canvas-rects.sh +19 -4
  93. package/apps/studio/bin/chat-open.sh +7 -1
  94. package/apps/studio/bin/draw-proof.sh +6 -2
  95. package/apps/studio/bin/generate.sh +32 -10
  96. package/apps/studio/bin/handoff.sh +2 -2
  97. package/apps/studio/bin/perf.sh +96 -15
  98. package/apps/studio/bin/photo-adjust.sh +6 -3
  99. package/apps/studio/bin/photo-bg-remove.sh +2 -2
  100. package/apps/studio/bin/prep.sh +21 -4
  101. package/apps/studio/bin/read-annotations.mjs +3 -0
  102. package/apps/studio/bin/runtime-health.sh +27 -1
  103. package/apps/studio/bin/screenshot.sh +152 -12
  104. package/apps/studio/bin/server-up.sh +64 -6
  105. package/apps/studio/bin/smoke.sh +43 -8
  106. package/apps/studio/bin/to-lottie.sh +3 -2
  107. package/apps/studio/bin/video-proxy.sh +27 -0
  108. package/apps/studio/bin/visual-sanity.sh +3 -1
  109. package/apps/studio/bridge/dgn-protocol.ts +157 -1
  110. package/apps/studio/bridge/mode-shows.ts +8 -6
  111. package/apps/studio/bridge/still-webp.ts +233 -0
  112. package/apps/studio/build.ts +18 -0
  113. package/apps/studio/canvas-build.ts +93 -11
  114. package/apps/studio/canvas-comment-mount.tsx +53 -8
  115. package/apps/studio/canvas-edit.ts +34 -1
  116. package/apps/studio/canvas-lib-module.ts +210 -0
  117. package/apps/studio/canvas-lib.tsx +3 -12
  118. package/apps/studio/canvas-pipeline.ts +111 -5
  119. package/apps/studio/canvas-shell.tsx +8 -11
  120. package/apps/studio/canvas-theme-pill.tsx +5 -3
  121. package/apps/studio/check/index.ts +12 -5
  122. package/apps/studio/check/video.ts +18 -2
  123. package/apps/studio/client/app.jsx +65 -7
  124. package/apps/studio/client/clipboard-relay.ts +193 -16
  125. package/apps/studio/client/comments-overlay.css +18 -0
  126. package/apps/studio/client/export-center.jsx +30 -0
  127. package/apps/studio/client/generate-dialog.jsx +49 -4
  128. package/apps/studio/client/github.js +7 -0
  129. package/apps/studio/client/home/HomeAccountsRow.jsx +221 -0
  130. package/apps/studio/client/home/HomeConnection.jsx +111 -0
  131. package/apps/studio/client/home/home-accounts-model.js +110 -1
  132. package/apps/studio/client/home/home-api.js +9 -2
  133. package/apps/studio/client/home/home-app.jsx +126 -13
  134. package/apps/studio/client/home/home-model.js +69 -1
  135. package/apps/studio/client/home/home-where-model.js +105 -0
  136. package/apps/studio/client/home/home.css +239 -1
  137. package/apps/studio/client/hooks/use-canvas-bridge.jsx +173 -98
  138. package/apps/studio/client/hooks/use-palette-and-panels.jsx +5 -1
  139. package/apps/studio/client/hooks/use-tabs.jsx +11 -4
  140. package/apps/studio/client/panels/DiffView.jsx +7 -1
  141. package/apps/studio/client/panels/TeamProjects.jsx +137 -134
  142. package/apps/studio/client/panels/chat-context.js +2 -0
  143. package/apps/studio/client/panels/slash-commands.gen.js +13 -13
  144. package/apps/studio/client/selection-scope.js +16 -9
  145. package/apps/studio/client/share-link.js +12 -0
  146. package/apps/studio/client/shell/viewport.jsx +11 -1
  147. package/apps/studio/client/shell-events.js +8 -0
  148. package/apps/studio/client/styles/3-kit-maude-v2.css +16 -0
  149. package/apps/studio/client/styles/_index.css +4 -0
  150. package/apps/studio/client/v2/ai/Feed.jsx +1 -1
  151. package/apps/studio/client/v2/ai/OfferCard.jsx +34 -0
  152. package/apps/studio/client/v2/ai/activity-line.js +54 -1
  153. package/apps/studio/client/v2/ai/ai-offer.js +21 -1
  154. package/apps/studio/client/v2/ai/run-model.js +3 -1
  155. package/apps/studio/client/v2/annotations/vote-store.js +28 -4
  156. package/apps/studio/client/v2/assets/asset-drop-session.js +37 -2
  157. package/apps/studio/client/v2/assets/canvas-drop-catcher.jsx +7 -5
  158. package/apps/studio/client/v2/assets/details-model.js +1 -1
  159. package/apps/studio/client/v2/assets/details.jsx +5 -0
  160. package/apps/studio/client/v2/assets/tile-drag.js +11 -7
  161. package/apps/studio/client/v2/comments/comments-panel.jsx +22 -3
  162. package/apps/studio/client/v2/create/duplicate-done.js +6 -2
  163. package/apps/studio/client/v2/diagnostics/diagnostics-host.jsx +1 -0
  164. package/apps/studio/client/v2/diagnostics/diagnostics-model.js +32 -2
  165. package/apps/studio/client/v2/diagnostics/diagnostics-sheet.jsx +35 -8
  166. package/apps/studio/client/v2/diagnostics/diagnostics.css +34 -0
  167. package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +113 -3
  168. package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +343 -6
  169. package/apps/studio/client/v2/diagnostics/sync-details/unsynced-refs.js +55 -0
  170. package/apps/studio/client/v2/ds/review.css +1 -1
  171. package/apps/studio/client/v2/export/exports-model.js +7 -0
  172. package/apps/studio/client/v2/export/exports-panel.jsx +1 -0
  173. package/apps/studio/client/v2/export/job-row.jsx +32 -2
  174. package/apps/studio/client/v2/handoff/ready-card.jsx +1 -1
  175. package/apps/studio/client/v2/history/compare-view.jsx +1 -0
  176. package/apps/studio/client/v2/inspector/css-write.js +6 -1
  177. package/apps/studio/client/v2/inspector/frame.jsx +28 -4
  178. package/apps/studio/client/v2/inspector/kinds/clip-model.js +51 -0
  179. package/apps/studio/client/v2/inspector/kinds/clip.jsx +75 -2
  180. package/apps/studio/client/v2/inspector/model.js +21 -0
  181. package/apps/studio/client/v2/inspector/sections/fill.jsx +12 -3
  182. package/apps/studio/client/v2/inspector/sections/recent-colours.js +8 -5
  183. package/apps/studio/client/v2/inspector/view-mode.jsx +11 -1
  184. package/apps/studio/client/v2/link-server/LinkServerDialog.jsx +492 -0
  185. package/apps/studio/client/v2/link-server/LinkServerHost.jsx +42 -0
  186. package/apps/studio/client/v2/link-server/link-server-api.js +142 -0
  187. package/apps/studio/client/v2/link-server/link-server-model.js +438 -0
  188. package/apps/studio/client/v2/link-server/link-server.css +109 -0
  189. package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +31 -86
  190. package/apps/studio/client/v2/onboarding/onboarding-model.js +1 -18
  191. package/apps/studio/client/v2/preview/link-follow.js +4 -2
  192. package/apps/studio/client/v2/preview/preview-chrome-host.jsx +16 -6
  193. package/apps/studio/client/v2/search/help-model.js +2 -0
  194. package/apps/studio/client/v2/search/search-keywords.js +3 -2
  195. package/apps/studio/client/v2/settings/account.jsx +4 -2
  196. package/apps/studio/client/v2/settings/advanced-section.jsx +344 -137
  197. package/apps/studio/client/v2/settings/connection-row.jsx +3 -59
  198. package/apps/studio/client/v2/settings/connections-section.jsx +118 -425
  199. package/apps/studio/client/v2/settings/general-section.jsx +155 -24
  200. package/apps/studio/client/v2/settings/project-sync-settings.jsx +4 -3
  201. package/apps/studio/client/v2/settings/reset-section.jsx +14 -3
  202. package/apps/studio/client/v2/settings/settings-card.jsx +142 -0
  203. package/apps/studio/client/v2/settings/settings-cards.js +220 -0
  204. package/apps/studio/client/v2/settings/settings-handlers.js +7 -6
  205. package/apps/studio/client/v2/settings/settings-model.js +100 -31
  206. package/apps/studio/client/v2/settings/settings-sheet.jsx +25 -6
  207. package/apps/studio/client/v2/settings/settings.css +374 -64
  208. package/apps/studio/client/v2/settings/this-project-card.jsx +730 -0
  209. package/apps/studio/client/v2/settings/this-project-model.js +172 -0
  210. package/apps/studio/client/v2/settings/use-connections.js +3 -2
  211. package/apps/studio/client/v2/settings/use-open-card.js +37 -0
  212. package/apps/studio/client/v2/share/share-sheet.jsx +28 -11
  213. package/apps/studio/client/v2/shell/api-session-boot.js +6 -0
  214. package/apps/studio/client/v2/shell/api-session.js +126 -0
  215. package/apps/studio/client/v2/shell/connection-state.js +197 -0
  216. package/apps/studio/client/v2/shell/floating-panels.css +31 -1
  217. package/apps/studio/client/v2/shell/image-pick.js +61 -8
  218. package/apps/studio/client/v2/shell/menu-aim.js +43 -0
  219. package/apps/studio/client/v2/shell/menu-runner.js +25 -7
  220. package/apps/studio/client/v2/shell/occlusion-insets.js +18 -1
  221. package/apps/studio/client/v2/shell/project-account-bus.js +36 -0
  222. package/apps/studio/client/v2/shell/project-account-card.jsx +357 -148
  223. package/apps/studio/client/v2/shell/project-account-model.js +272 -149
  224. package/apps/studio/client/v2/shell/project-account-toast.js +66 -0
  225. package/apps/studio/client/v2/shell/project-account.css +237 -0
  226. package/apps/studio/client/v2/shell/project-pill.jsx +52 -6
  227. package/apps/studio/client/v2/shell/share-cluster-host.jsx +166 -83
  228. package/apps/studio/client/v2/shell/shell-parity.js +3 -2
  229. package/apps/studio/client/v2/shell/shell-parity.json +71 -36
  230. package/apps/studio/client/v2/shell/still-bridge.js +194 -0
  231. package/apps/studio/client/v2/shell/still-store.js +319 -0
  232. package/apps/studio/client/v2/shell/use-account.js +2 -0
  233. package/apps/studio/client/v2/shell/use-tool-panels.js +2 -1
  234. package/apps/studio/client/v2/signin/use-signin.js +1 -1
  235. package/apps/studio/client/v2/timeline/Timeline.jsx +15 -0
  236. package/apps/studio/client/v2/timeline/frame-handle-model.js +142 -0
  237. package/apps/studio/client/v2/timeline/frame-handle.jsx +151 -0
  238. package/apps/studio/clip-ops.ts +126 -8
  239. package/apps/studio/cloud/endpoints.ts +29 -4
  240. package/apps/studio/collab/ai-activity.ts +10 -8
  241. package/apps/studio/collab/awareness-bridge.ts +34 -9
  242. package/apps/studio/collab/index.ts +3 -0
  243. package/apps/studio/collab/registry.ts +41 -10
  244. package/apps/studio/comment-reattach.ts +149 -0
  245. package/apps/studio/comments/mine-stamp.ts +15 -7
  246. package/apps/studio/comments/ops.ts +52 -8
  247. package/apps/studio/comments-overlay.tsx +146 -9
  248. package/apps/studio/dist/client.bundle.js +892 -885
  249. package/apps/studio/dist/comment-mount.js +2 -2
  250. package/apps/studio/dist/styles.css +1 -1
  251. package/apps/studio/dom-selection.ts +87 -18
  252. package/apps/studio/ds/board/directions.css +8 -0
  253. package/apps/studio/ds/board/outline.tsx +16 -0
  254. package/apps/studio/ds/canvas-check.ts +6 -0
  255. package/apps/studio/edit-ops/clip/reframe.ts +19 -3
  256. package/apps/studio/edit-ops/clip-carry.ts +602 -0
  257. package/apps/studio/edit-ops/clipboard.ts +318 -23
  258. package/apps/studio/edit-ops/dispatch.ts +20 -2
  259. package/apps/studio/edit-ops/scope-names.ts +249 -40
  260. package/apps/studio/edit-ops/slot-defaults.ts +3 -0
  261. package/apps/studio/edit-ops/types.ts +6 -0
  262. package/apps/studio/editing/align-bar.tsx +33 -9
  263. package/apps/studio/editing/artboard-actions.ts +5 -0
  264. package/apps/studio/editing/artboard-menu.tsx +6 -2
  265. package/apps/studio/editing/click-to-type.ts +1 -1
  266. package/apps/studio/editing/clip-words.ts +48 -0
  267. package/apps/studio/editing/clipboard.ts +21 -6
  268. package/apps/studio/editing/declared-background.ts +25 -0
  269. package/apps/studio/editing/index.tsx +3 -0
  270. package/apps/studio/editing/object-keys.ts +4 -4
  271. package/apps/studio/editing/object-menu.tsx +13 -3
  272. package/apps/studio/editing/pen/points.tsx +61 -0
  273. package/apps/studio/editing/text-in-place.tsx +11 -0
  274. package/apps/studio/editing/video-frame-handle.tsx +425 -0
  275. package/apps/studio/exporters/capture-prepass.ts +374 -0
  276. package/apps/studio/exporters/degraded.ts +148 -0
  277. package/apps/studio/exporters/hub-render-door.ts +28 -2
  278. package/apps/studio/exporters/index.ts +3 -1
  279. package/apps/studio/exporters/job-budget.ts +93 -0
  280. package/apps/studio/exporters/jobs.ts +215 -28
  281. package/apps/studio/exporters/parity-check.ts +254 -0
  282. package/apps/studio/exporters/remote.ts +209 -15
  283. package/apps/studio/exporters/svg-inline.ts +87 -0
  284. package/apps/studio/exporters/video-render-lib.ts +88 -26
  285. package/apps/studio/exporters/video.ts +29 -6
  286. package/apps/studio/figma/assets.ts +58 -43
  287. package/apps/studio/figma/codegen-fonts.ts +100 -0
  288. package/apps/studio/figma/fig-decode.ts +390 -25
  289. package/apps/studio/figma/fig-kiwi.ts +18 -4
  290. package/apps/studio/figma/fig-vector.ts +59 -3
  291. package/apps/studio/figma/sanitize.ts +2 -0
  292. package/apps/studio/figma/style-map.ts +293 -48
  293. package/apps/studio/figma/to-artboard.ts +455 -69
  294. package/apps/studio/figma/to-strokes.ts +44 -11
  295. package/apps/studio/figma/types.ts +13 -0
  296. package/apps/studio/footage/schema.ts +3 -3
  297. package/apps/studio/generation/adapters/elevenlabs.ts +7 -1
  298. package/apps/studio/generation/adapters/groq.ts +8 -1
  299. package/apps/studio/generation/spend.ts +312 -0
  300. package/apps/studio/generation/types.ts +12 -0
  301. package/apps/studio/handoff/run.ts +1 -1
  302. package/apps/studio/handoff/targets.ts +2 -2
  303. package/apps/studio/handoff/write-scopes.ts +1 -1
  304. package/apps/studio/history/describe-annotations.ts +4 -0
  305. package/apps/studio/home/accounts.ts +30 -11
  306. package/apps/studio/home/cloud.ts +6 -1
  307. package/apps/studio/home/create-local.ts +32 -3
  308. package/apps/studio/home/hub-health.ts +76 -0
  309. package/apps/studio/home/routes.ts +15 -4
  310. package/apps/studio/http.ts +438 -86
  311. package/apps/studio/imported-module-ids.ts +91 -0
  312. package/apps/studio/inspect.ts +2 -0
  313. package/apps/studio/migrate/hub.ts +8 -1
  314. package/apps/studio/notifications.tsx +47 -5
  315. package/apps/studio/paths.ts +10 -1
  316. package/apps/studio/port.ts +3 -2
  317. package/apps/studio/preview/preview-camera.tsx +15 -382
  318. package/apps/studio/readiness.ts +10 -1
  319. package/apps/studio/release-build.ts +51 -0
  320. package/apps/studio/routes/agent.ts +188 -9
  321. package/apps/studio/routes/ai.ts +43 -11
  322. package/apps/studio/routes/annotations.ts +27 -1
  323. package/apps/studio/routes/assets.ts +18 -1
  324. package/apps/studio/routes/canvas-origin.ts +12 -9
  325. package/apps/studio/routes/cloud-move.ts +15 -0
  326. package/apps/studio/routes/edit.ts +3 -0
  327. package/apps/studio/routes/export.ts +51 -0
  328. package/apps/studio/routes/generate.ts +42 -12
  329. package/apps/studio/routes/hub-link-folder.ts +334 -0
  330. package/apps/studio/routes/hub-signin.ts +78 -1
  331. package/apps/studio/routes/index.ts +9 -1
  332. package/apps/studio/routes/shell.ts +217 -5
  333. package/apps/studio/routes/sync.ts +136 -8
  334. package/apps/studio/routes/votes.ts +2 -1
  335. package/apps/studio/schema/annotations.v2.schema.json +143 -1
  336. package/apps/studio/schema/beats.v1.schema.json +1 -1
  337. package/apps/studio/schema/edl.v1.schema.json +1 -1
  338. package/apps/studio/schema/formats.ts +3 -3
  339. package/apps/studio/schema/transcript.v1.schema.json +1 -1
  340. package/apps/studio/server.ts +142 -43
  341. package/apps/studio/shell/api-key.ts +503 -0
  342. package/apps/studio/shell/attest.ts +59 -0
  343. package/apps/studio/shell/capture-url.ts +20 -0
  344. package/apps/studio/shell/cli-yield.ts +276 -0
  345. package/apps/studio/shell/clip-transfer.ts +302 -0
  346. package/apps/studio/shell/key-file.ts +108 -0
  347. package/apps/studio/shell/server-json.ts +75 -0
  348. package/apps/studio/shell/worktree.ts +19 -0
  349. package/apps/studio/spoof-chars.ts +9 -0
  350. package/apps/studio/studio-page-host.ts +1 -1
  351. package/apps/studio/sync/accepted-cold-start.ts +144 -8
  352. package/apps/studio/sync/accepted-link.ts +76 -29
  353. package/apps/studio/sync/action-stage.ts +575 -44
  354. package/apps/studio/sync/adopt-held.ts +85 -0
  355. package/apps/studio/sync/ctl-heal.ts +58 -0
  356. package/apps/studio/sync/file-ledger.ts +38 -4
  357. package/apps/studio/sync/file-membership.ts +16 -1
  358. package/apps/studio/sync/file-plane.ts +289 -22
  359. package/apps/studio/sync/held-deletes.ts +86 -5
  360. package/apps/studio/sync/hub-link.ts +8 -0
  361. package/apps/studio/sync/index.ts +196 -12
  362. package/apps/studio/sync/journal-client.ts +50 -4
  363. package/apps/studio/sync/link-consent.ts +22 -75
  364. package/apps/studio/sync/link-survey.ts +252 -0
  365. package/apps/studio/sync/local-kernel.ts +296 -8
  366. package/apps/studio/sync/projection.ts +22 -3
  367. package/apps/studio/sync/seed-progress.ts +12 -0
  368. package/apps/studio/sync/source-recovery.ts +59 -3
  369. package/apps/studio/sync/status.ts +19 -2
  370. package/apps/studio/sync/unsynced-refs.ts +397 -0
  371. package/apps/studio/sync/writer-registry.ts +20 -0
  372. package/apps/studio/thumbs/service.ts +4 -1
  373. package/apps/studio/tool-palette.tsx +23 -0
  374. package/apps/studio/ui-prefs.ts +40 -0
  375. package/apps/studio/use-agent-presence.tsx +2 -2
  376. package/apps/studio/use-canvas-keys.ts +6 -1
  377. package/apps/studio/video/format-ids.ts +2 -2
  378. package/apps/studio/video/inject.ts +31 -0
  379. package/apps/studio/video/media-risk.ts +58 -0
  380. package/apps/studio/video/object-fit.ts +137 -0
  381. package/apps/studio/video/provider-transcript.ts +141 -0
  382. package/apps/studio/whats-new.json +137 -0
  383. package/apps/studio/workspace-mode.ts +1 -0
  384. package/apps/studio/ws.ts +5 -0
  385. package/cli/commands/design.mjs +119 -8
  386. package/cli/lib/bash-guard.mjs +366 -6
  387. package/cli/lib/confine-read.mjs +1 -0
  388. package/cli/lib/design-help.gen.mjs +3 -2
  389. package/cli/lib/design-hook.mjs +387 -81
  390. package/cli/lib/design-link.mjs +16 -1
  391. package/cli/lib/design-open.mjs +49 -3
  392. package/cli/lib/desktop-locate.mjs +770 -0
  393. package/cli/lib/handoff.mjs +1 -1
  394. package/cli/lib/hook-state.mjs +291 -0
  395. package/cli/lib/pkg-root.mjs +65 -13
  396. package/cli/lib/studio-locate.mjs +59 -16
  397. package/package.json +15 -8
  398. package/plugins/design/templates/_shell.html +13 -0
  399. package/apps/studio/client/v2/onboarding/HubSheet.jsx +0 -212
  400. package/apps/studio/client/v2/shell/account-card-model.js +0 -114
  401. package/apps/studio/client/v2/shell/account-card.jsx +0 -189
@@ -64,6 +64,8 @@ import {
64
64
  import { open as openAsync } from 'node:fs/promises';
65
65
  import path from 'node:path';
66
66
 
67
+ import { isCanvasSource } from '../skip-dirs.ts';
68
+ import { declaredCanvasGroups } from './canvas-path.ts';
67
69
  import { conflictCopyName, decideFile, type FileState } from './decide-file.ts';
68
70
  import type { DeliveryState, FileLedger, LedgerRow } from './file-ledger.ts';
69
71
  import {
@@ -74,11 +76,12 @@ import {
74
76
  MAX_SEGMENTS,
75
77
  OLDER_HUB_DEPTH_REASON,
76
78
  olderDoorRefuses,
79
+ olderDoorRefusesAdded,
77
80
  olderDoorRefusesDepth,
78
81
  } from './file-membership.ts';
79
82
  import {
80
83
  fetchJournal,
81
- type HeldReason,
84
+ type HeldEntry,
82
85
  type JournalEntry,
83
86
  type JournalPage,
84
87
  } from './journal-client.ts';
@@ -305,6 +308,13 @@ export const FIRST_ANCHOR_STORM_LIMIT = 10;
305
308
  * into everyone's; inbound turns a hostile or broken hub into a local wipe.
306
309
  */
307
310
  export const DELETE_BREAKER_MAX = 10;
311
+
312
+ /** A door's 409 that names a tombstone (`deleted` + `seq`, 2.1.1 T9). Hub-supplied: shape-checked. */
313
+ function tombstoneOf(body: Record<string, unknown> | null | undefined): { tombstoneSeq?: number } {
314
+ return body?.deleted === true && Number.isInteger(body.seq) && (body.seq as number) > 0
315
+ ? { tombstoneSeq: body.seq as number }
316
+ : {};
317
+ }
308
318
  export const DELETE_BREAKER_MAX_FRACTION = 0.25;
309
319
 
310
320
  /**
@@ -358,6 +368,9 @@ export const UNREACHABLE_HOLD_MS = 30_000;
358
368
  */
359
369
  export const MAX_DORUCEKA_ROWS = 300;
360
370
 
371
+ /** How many conflict copies one payload names (the rest are in the folder, and in the counts). */
372
+ export const MAX_CONFLICT_COPIES = 50;
373
+
361
374
  /** The last delete-hold we logged, so the same hold is not re-announced every
362
375
  * pass. Observed 47 times in a 72-line log, burying everything else. */
363
376
  let lastDeleteHoldKey = '';
@@ -371,6 +384,7 @@ function deliveryRank(state: DeliveryState): number {
371
384
  return 1;
372
385
  case 'stuck':
373
386
  case 'delete-held':
387
+ case 'delete-in-held':
374
388
  return 2;
375
389
  case 'referenced-but-unoffered':
376
390
  return 3;
@@ -475,6 +489,8 @@ export interface FilePlaneResult {
475
489
  count: number;
476
490
  paths: string[];
477
491
  folders?: HeldDeleteFolder[];
492
+ /** 2.1.1 T8 / N4 — `heldSetDigest` of EVERY path an answer would cover (the list above is capped) */
493
+ digest?: string;
478
494
  };
479
495
  /** Consecutive `reanchor` answers tripped the storm limit; the pass held. */
480
496
  reanchorHeld?: true;
@@ -488,7 +504,7 @@ export interface FilePlaneResult {
488
504
  * canvases before the owner set the canvas folders). Only an owner's journal
489
505
  * read carries it; absent otherwise. A count of 0 means nothing is held.
490
506
  */
491
- codeHeld?: { count: number; paths: { path: string; reason: HeldReason }[] };
507
+ codeHeld?: { count: number; paths: HeldEntry[]; overflow?: true };
492
508
  /**
493
509
  * Issue #175 — files the hub's door will not take, from the LEDGER (so a pass
494
510
  * that skipped them still reports them). `older` = held before asking, because
@@ -496,11 +512,37 @@ export interface FilePlaneResult {
496
512
  * and `reason` carries its words. Bounded; absent when there are none.
497
513
  */
498
514
  hubRefused?: { rel: string; reason: string; older?: true }[];
515
+ /**
516
+ * #167 T5.3 item 6 — `.tsx` canvases (they render `DesignCanvas`) outside this Mac's canvas
517
+ * folders, NOT offered to the hub while the project declares no canvas folders: the hub is the
518
+ * folder boundary then, takes them as canvases and refuses them as code. Held here. Bounded.
519
+ */
520
+ canvasOutsideFolders?: string[];
499
521
  }
500
522
 
501
523
  /** Statuses that are a door's FINAL word on a file push (issue #175). 408/429 are not: they retry. */
502
524
  const PERMANENT_PUSH_REFUSALS = new Set([400, 404, 413, 422]);
503
525
 
526
+ /** #167 T5.3 — whether `<designRoot>/config.json` names canvas folders (the hub's own predicate). */
527
+ function projectDeclaresCanvasFolders(designRoot: string): boolean {
528
+ try {
529
+ const parsed = JSON.parse(readFileSync(path.join(designRoot, 'config.json'), 'utf8'));
530
+ return declaredCanvasGroups(parsed?.canvasGroups) !== null;
531
+ } catch {
532
+ return false;
533
+ }
534
+ }
535
+
536
+ /** A small text file's contents, or null (missing, unreadable, or past 2 MB). */
537
+ function readTextOrNull(abs: string): string | null {
538
+ try {
539
+ if (statSync(abs).size > 2 * 1024 * 1024) return null;
540
+ return readFileSync(abs, 'utf8');
541
+ } catch {
542
+ return null;
543
+ }
544
+ }
545
+
504
546
  /** How many `hubRefused` rows one result carries. */
505
547
  export const MAX_HUB_REFUSED_ROWS = 200;
506
548
 
@@ -624,6 +666,12 @@ export interface FilePlaneOptions {
624
666
  * true, like `hubTakesV2Files`.
625
667
  */
626
668
  hubTakesDeepPaths?: boolean;
669
+ /**
670
+ * #172 — the hub advertises `asset-added-v1` (`hasAssetAddedV1`). False ⇒ the who-added sidecar
671
+ * `assets/<stem>.added.json` (`olderDoorRefusesAdded`) is held here with the older-hub reason;
672
+ * its asset still goes up. Absent ⇒ true, like `hubTakesV2Files`.
673
+ */
674
+ hubTakesAddedFiles?: boolean;
627
675
  /**
628
676
  * Issue #204 — how fast this plane talks to the hub (concurrency + requests per minute). One per
629
677
  * plane so the adaptive width survives from pass to pass. Default: `createPullPacer()`.
@@ -729,6 +777,13 @@ export const DELETE_HELD_REASON =
729
777
  export const HUB_ONLY_REASON =
730
778
  'deleted on this Mac and kept on the hub — it is not downloaded again';
731
779
 
780
+ /** 2.1.1 T13 — the ledger reason for a `delete-in-held` row. */
781
+ export const DELETE_IN_HELD_REASON =
782
+ 'the project deleted this, as part of a batch too large to remove here without asking';
783
+ /** 2.1.1 T13 — the ledger reason for a `kept-here` row. */
784
+ export const KEPT_HERE_REASON =
785
+ 'the project deleted this and you kept this Mac’s copy — it is not removed here or sent back';
786
+
732
787
  /** One folder of held deletes, for the Sync details row. */
733
788
  export interface HeldDeleteFolder {
734
789
  /** Design-root-relative folder (`''` = the design root itself). */
@@ -763,6 +818,28 @@ export function summarizeHeldDeletes(rows: Readonly<Record<string, LedgerRow>>):
763
818
  return { count: paths.length, paths, folders };
764
819
  }
765
820
 
821
+ /** 2.1.1 T13 — every `delete-in-held` row, grouped like the outbound ones (pure over the rows). */
822
+ export function summarizeHeldIncoming(
823
+ rows: Readonly<Record<string, LedgerRow>>,
824
+ skip?: ReadonlySet<string>
825
+ ): ReturnType<typeof summarizeHeldDeletes> {
826
+ const waiting: Record<string, LedgerRow> = {};
827
+ for (const [rel, row] of Object.entries(rows))
828
+ if (row.state === 'delete-in-held' && !skip?.has(rel))
829
+ waiting[rel] = { ...row, state: 'delete-held' };
830
+ return summarizeHeldDeletes(waiting);
831
+ }
832
+
833
+ /**
834
+ * 2.1.1 T8 — a fingerprint of a held set (sorted paths). Sync details shows a held batch with it and
835
+ * the person's answer carries it back, so an answer applies only to the set that was on screen.
836
+ */
837
+ export function heldSetDigest(paths: readonly string[]): string {
838
+ const h = createHash('sha256');
839
+ for (const p of [...paths].sort()) h.update(p).update('\n');
840
+ return h.digest('hex').slice(0, 32);
841
+ }
842
+
766
843
  /** Does `rel` sit in `folder` (or below it)? `null` folder = every held row. */
767
844
  export function inHeldFolder(rel: string, folder: string | null): boolean {
768
845
  if (folder === null) return true;
@@ -897,7 +974,8 @@ export async function scanLocalFilesAsync(
897
974
  /** Walk the design root (stat only, no reads) and keep what the classifier admits. */
898
975
  function walkAndClassify(
899
976
  designRoot: string,
900
- canvasGroups?: readonly CanvasGroupLike[]
977
+ canvasGroups?: readonly CanvasGroupLike[],
978
+ all = false
901
979
  ): { f: WalkedFile; cls: FileClass }[] {
902
980
  const found: WalkedFile[] = [];
903
981
 
@@ -940,11 +1018,28 @@ function walkAndClassify(
940
1018
  const out: { f: WalkedFile; cls: FileClass }[] = [];
941
1019
  for (const f of found) {
942
1020
  const cls = classifyProjectFile(f.rel, opts);
943
- if (isFilePlaneClass(cls)) out.push({ f, cls });
1021
+ if (all || isFilePlaneClass(cls)) out.push({ f, cls });
944
1022
  }
945
1023
  return out;
946
1024
  }
947
1025
 
1026
+ /**
1027
+ * 2.1.1 — every file the walk sees, with its class (`canvas-owned` included): the link survey
1028
+ * (sync/link-survey.ts) counts canvases and files with the SAME walk and classifier the plane uses,
1029
+ * so "only on this Mac" can never name a file the plane would not send.
1030
+ */
1031
+ export function walkClassifiedAll(
1032
+ designRoot: string,
1033
+ canvasGroups?: readonly CanvasGroupLike[]
1034
+ ): { rel: string; abs: string; size: number; cls: FileClass }[] {
1035
+ return walkAndClassify(designRoot, canvasGroups, true).map(({ f, cls }) => ({
1036
+ rel: f.rel,
1037
+ abs: f.abs,
1038
+ size: f.size,
1039
+ cls,
1040
+ }));
1041
+ }
1042
+
948
1043
  /**
949
1044
  * Fold journal entries into "what the hub currently holds", newest row wins.
950
1045
  */
@@ -965,6 +1060,11 @@ export interface FilePlane {
965
1060
  doruceka(): Record<string, DeliveryState>;
966
1061
  /** How many rows the ledger holds, before the doručenka's cap. */
967
1062
  dorucekaTotal(): number;
1063
+ /**
1064
+ * 2.1.1 T14 — files in conflict whose copy of this Mac's version still sits beside them: file →
1065
+ * copy (both designRoot-relative). What Sync details names; a row clears when the copy is gone.
1066
+ */
1067
+ conflictCopies(): Record<string, string>;
968
1068
  /**
969
1069
  * The media this machine cannot place, in BYTES as well as files — T29.
970
1070
  * `null` when nothing is blocked, so a healthy project carries no field.
@@ -986,6 +1086,20 @@ export interface FilePlane {
986
1086
  answerHeldDeletes(how: 'send' | 'purging' | 'keep', folder: string | null): string[];
987
1087
  /** The purge for these paths ended (done or not): held again unless the hub deleted them. */
988
1088
  endPurge(rels: readonly string[]): void;
1089
+ /** 2.1.1 T13 — the held INCOMING deletes (the project removed these; this Mac still has them). */
1090
+ heldIncomingDeletes(): ReturnType<typeof summarizeHeldDeletes>;
1091
+ /**
1092
+ * 2.1.1 T13 — the person's answer to held incoming deletes (`folder` null = all). `remove`: the
1093
+ * next pass quarantines them into `_trash/` in one go, past the breaker. `keep`: they stay on this
1094
+ * Mac and are neither removed nor sent back. Returns the paths the answer covered.
1095
+ * 2.1.1 T8 — `digest` is `heldSetDigest` of the set the person was shown: when the held set has
1096
+ * changed since (it grew, a row settled), nothing is applied and the answer is `null`.
1097
+ */
1098
+ answerIncomingDeletes(
1099
+ how: 'remove' | 'keep',
1100
+ folder: string | null,
1101
+ digest: string
1102
+ ): string[] | null;
989
1103
  }
990
1104
 
991
1105
  export function createFilePlane(opts: FilePlaneOptions): FilePlane {
@@ -1004,6 +1118,8 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
1004
1118
  const confirmedDeletes = new Set<string>();
1005
1119
  /** Issue #207 (7b) — held deletes an owner purge is deleting on the hub right now. */
1006
1120
  const purgingDeletes = new Set<string>();
1121
+ /** 2.1.1 T13 — held incoming deletes the person said to remove here (in memory, like the above). */
1122
+ const acceptedIncoming = new Set<string>();
1007
1123
  const readPropagateDeletes = (): boolean =>
1008
1124
  (typeof opts.propagateDeletes === 'function'
1009
1125
  ? opts.propagateDeletes()
@@ -1079,7 +1195,10 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
1079
1195
  * Capped at one per `REANCHOR_HOLD_RECOVERY_MS`, like the re-anchor storm,
1080
1196
  * so a hub answering `conflict` to every push cannot farm full reads.
1081
1197
  */
1082
- let fullReadOwed = Object.values(ledger.rows()).some((r) => r.state === 'conflict');
1198
+ // 2.1.1 T14 — a conflict that already parked its copy owes nothing: it stays in `conflict` on purpose
1199
+ let fullReadOwed = Object.values(ledger.rows()).some(
1200
+ (r) => r.state === 'conflict' && !r.conflictCopy
1201
+ );
1083
1202
  let lastOwedFullReadAt = Number.NEGATIVE_INFINITY;
1084
1203
 
1085
1204
  /**
@@ -1774,10 +1893,12 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
1774
1893
  */
1775
1894
  async function push(
1776
1895
  local: SyncableLocalFile,
1777
- expect: string | null
1896
+ expect: string | null,
1897
+ /** The tombstone seq this push decides over (2.1.1 T9) — the door asks it of an owner purge. */
1898
+ expectSeq?: number
1778
1899
  ): Promise<
1779
1900
  | { ok: true; seq: number | null }
1780
- | { ok: false; conflict: true; current: string | null }
1901
+ | { ok: false; conflict: true; current: string | null; tombstoneSeq?: number }
1781
1902
  | {
1782
1903
  ok: false;
1783
1904
  conflict?: false;
@@ -1825,7 +1946,7 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
1825
1946
  };
1826
1947
  }
1827
1948
  // T18 — past one request: a resumable session, in verified parts.
1828
- if (local.size > singlePutCeiling()) return pushSession(local, expect);
1949
+ if (local.size > singlePutCeiling()) return pushSession(local, expect, expectSeq);
1829
1950
  // ISSUE #207 — A LARGE BODY STREAMS FROM DISK. Handing fetch the whole file
1830
1951
  // as one buffer cost TWICE the file in memory over TLS (measured: 532 MB of
1831
1952
  // RSS for a 256 MB body; a `Bun.file` body is no better there), copied on
@@ -1871,6 +1992,7 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
1871
1992
  'content-type': 'application/octet-stream',
1872
1993
  'x-maude-content-sha256': local.hash,
1873
1994
  'x-maude-expect-hash': expect ?? 'none',
1995
+ ...(expectSeq !== undefined ? { 'x-maude-expect-seq': String(expectSeq) } : {}),
1874
1996
  // A stream has no length of its own; the door and every proxy in
1875
1997
  // front of it see the same one a buffer would have carried.
1876
1998
  'content-length': String(local.size),
@@ -1880,11 +2002,12 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
1880
2002
  }
1881
2003
  );
1882
2004
  if (res.status === 409) {
1883
- const body = (await res.json().catch(() => ({}))) as { current?: unknown };
2005
+ const body = (await res.json().catch(() => ({}))) as Record<string, unknown>;
1884
2006
  return {
1885
2007
  ok: false,
1886
2008
  conflict: true,
1887
2009
  current: typeof body?.current === 'string' ? body.current : null,
2010
+ ...tombstoneOf(body),
1888
2011
  };
1889
2012
  }
1890
2013
  if (!res.ok) return await refusal(res, { final: true });
@@ -1906,7 +2029,8 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
1906
2029
  */
1907
2030
  async function pushSession(
1908
2031
  local: SyncableLocalFile,
1909
- expect: string | null
2032
+ expect: string | null,
2033
+ expectSeq?: number
1910
2034
  ): Promise<Awaited<ReturnType<typeof push>>> {
1911
2035
  const json = async (res: Response) =>
1912
2036
  (await res.json().catch(() => ({}))) as Record<string, unknown>;
@@ -1922,6 +2046,7 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
1922
2046
  size: local.size,
1923
2047
  sha256: local.hash,
1924
2048
  expectHash: expect ?? 'none',
2049
+ ...(expectSeq !== undefined ? { expectSeq } : {}),
1925
2050
  }),
1926
2051
  signal: AbortSignal.timeout(GET_TIMEOUT_MS),
1927
2052
  });
@@ -1985,6 +2110,7 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
1985
2110
  ok: false,
1986
2111
  conflict: true,
1987
2112
  current: typeof body.current === 'string' ? body.current : null,
2113
+ ...tombstoneOf(body),
1988
2114
  };
1989
2115
  }
1990
2116
  if (!done.ok) return await refusal(done);
@@ -2193,6 +2319,8 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2193
2319
  synced: 0,
2194
2320
  reanchored: false,
2195
2321
  };
2322
+ // #167 T5.3 item 6 — read once per pass: does the project declare its canvas folders?
2323
+ const foldersDeclared = projectDeclaresCanvasFolders(designRoot);
2196
2324
 
2197
2325
  // ── 0. Is the door shut? ─────────────────────────────────────────────
2198
2326
  //
@@ -2363,7 +2491,7 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2363
2491
  delta.delete(rel);
2364
2492
  continue;
2365
2493
  }
2366
- ledger.noteRemote(rel, row.deleted ? null : row.sha256, row.seq);
2494
+ ledger.noteRemote(rel, row.deleted ? null : row.sha256, row.seq, row.deleted === true);
2367
2495
  }
2368
2496
  // Only a COMPLETE full read may say "the hub does not have this". A
2369
2497
  // truncated one is silent about every path past its last page, and
@@ -2465,12 +2593,16 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2465
2593
  continue;
2466
2594
  }
2467
2595
  }
2596
+ // THE HUB'S LATEST WORD IS A TOMBSTONE — said on this page, or on an earlier one this
2597
+ // machine did not act on (2.1.1 T9: the inbound breaker held it). Remembered by the ledger,
2598
+ // so a held delete stays a delete instead of reading as "the hub lost it" next pass.
2599
+ const tombstoned = row ? row.deleted === true : ledger.remoteTombstoned(rel);
2468
2600
  // A DELETE IS A TRANSFER TOO. The code-module gate below only sees a
2469
2601
  // non-null remote, so a tombstone walked past it: an ancestor this peer
2470
2602
  // recorded (by push, or by agreement) was all `tombstone-agreed` needed
2471
2603
  // to quarantine a code module on the word of a hub that may not move
2472
2604
  // one. Refuse it here, reported, with the file and its row untouched.
2473
- if (row?.deleted && here && !mayReceiveCode()) {
2605
+ if (tombstoned && here && !mayReceiveCode()) {
2474
2606
  const cls = classifyProjectFile(rel, {
2475
2607
  canvasGroups: opts.canvasGroups,
2476
2608
  hasFile: (r) => local.has(r) || existsSync(path.join(designRoot, r)),
@@ -2566,6 +2698,28 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2566
2698
  }
2567
2699
  }
2568
2700
 
2701
+ // A CANVAS OUTSIDE YOUR CANVAS FOLDERS IS NOT OFFERED AS CODE (#167 T5.3 item 6, lead option A).
2702
+ // While the project declares no canvas folders the hub is the folder boundary: a `.tsx` that
2703
+ // renders DesignCanvas is a canvas there wherever it sits, and its file door refuses it as code.
2704
+ // This Mac's default folders make it code here, so it was offered and refused. Held instead,
2705
+ // with the way out (Open canvas folders); the file stays as it is.
2706
+ if (
2707
+ here &&
2708
+ remoteHash === null &&
2709
+ !foldersDeclared &&
2710
+ rel.endsWith('.tsx') &&
2711
+ classifyProjectFile(rel, {
2712
+ canvasGroups: opts.canvasGroups,
2713
+ hasFile: (r) => local.has(r) || existsSync(path.join(designRoot, r)),
2714
+ }) === 'code-module' &&
2715
+ isCanvasSource(readTextOrNull(path.join(designRoot, rel)))
2716
+ ) {
2717
+ const list = out.canvasOutsideFolders ?? [];
2718
+ if (list.length < MAX_HUB_REFUSED_ROWS) list.push(rel);
2719
+ out.canvasOutsideFolders = list;
2720
+ continue;
2721
+ }
2722
+
2569
2723
  // A HUB THAT CANNOT TAKE IT IS NOT OFFERED IT (issue #175). A 1.x door
2570
2724
  // answers `400 invalid path` to every 2.0-only file; asking costs a
2571
2725
  // request and tells nobody anything. Held with a reason instead — and
@@ -2573,7 +2727,8 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2573
2727
  // fix/205 — the same for a path deeper than an older door takes (8 segments).
2574
2728
  const olderHubReason =
2575
2729
  here && remoteHash === null
2576
- ? opts.hubTakesV2Files === false && olderDoorRefuses(rel)
2730
+ ? (opts.hubTakesV2Files === false && olderDoorRefuses(rel)) ||
2731
+ (opts.hubTakesAddedFiles === false && olderDoorRefusesAdded(rel))
2577
2732
  ? OLDER_HUB_REASON
2578
2733
  : opts.hubTakesDeepPaths === false && olderDoorRefusesDepth(rel)
2579
2734
  ? OLDER_HUB_DEPTH_REASON
@@ -2619,6 +2774,18 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2619
2774
  ) {
2620
2775
  continue;
2621
2776
  }
2777
+ // 2.1.1 T13 — KEPT HERE: the project deleted it and the person kept this Mac's copy. While the
2778
+ // file is still the bytes they kept and the project's word is still the delete, nothing is
2779
+ // decided: not removed here, not pushed back over the tombstone. An edit here, or a teammate
2780
+ // recreating the file, is a new decision.
2781
+ if (
2782
+ here &&
2783
+ remoteHash === null &&
2784
+ kept?.state === 'kept-here' &&
2785
+ here.hash === (kept.syncedHash ?? kept.lastSeenHash ?? null)
2786
+ ) {
2787
+ continue;
2788
+ }
2622
2789
 
2623
2790
  // GONE FROM HERE, AND THE HUB HOLDS EXACTLY WHAT THIS MAC LAST SAW (issue #207). No recorded
2624
2791
  // ancestor — the upload landed while its answer was lost (a timeout on a slow link), or the
@@ -2628,7 +2795,7 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2628
2795
  // this decision — the ledger's ancestor moves only after bytes land (`adoptAfter`).
2629
2796
  const ancestor =
2630
2797
  ledger.ancestorOf(rel) ??
2631
- (!here && remoteHash !== null && !row?.deleted && kept?.lastSeenHash === remoteHash
2798
+ (!here && remoteHash !== null && !tombstoned && kept?.lastSeenHash === remoteHash
2632
2799
  ? remoteHash
2633
2800
  : null);
2634
2801
  const state: FileState = {
@@ -2636,7 +2803,7 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2636
2803
  local: here?.hash ?? null,
2637
2804
  remote: remoteHash,
2638
2805
  ancestor,
2639
- ...(row?.deleted ? { remoteTombstone: true } : {}),
2806
+ ...(tombstoned ? { remoteTombstone: true } : {}),
2640
2807
  ...(degraded ? { epochChanged: true } : {}),
2641
2808
  ...(remoteHash && ledger.outboxHas(remoteHash) ? { selfInFlight: true } : {}),
2642
2809
  ...(propagateDeletes ? { propagateDeletes: true } : {}),
@@ -2654,6 +2821,16 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2654
2821
  continue;
2655
2822
  }
2656
2823
  if (decision.action === 'noop' && !decision.parkRemote) {
2824
+ // 2.1.1 T14 — A FILE IN CONFLICT STAYS IN CONFLICT WHILE ITS COPY IS BESIDE IT. The pass that
2825
+ // parked this Mac's version also moved the ancestor to the server's bytes, so the next pass
2826
+ // reads the pair as agreement and `adoptAfter` below used to turn the row `on-hub` — the
2827
+ // conflict vanished from Sync details with the copy still on disk and nothing said where.
2828
+ // The row clears when the copy is gone (the person kept one and removed the other) or this
2829
+ // path changes again; the bytes themselves have nothing left to move.
2830
+ if (here && keepsConflictCopy(kept, here.hash)) {
2831
+ out.synced += 1;
2832
+ continue;
2833
+ }
2657
2834
  if (decision.adoptAncestor && here) {
2658
2835
  // Record agreement so the next pass is a stat and nothing more.
2659
2836
  //
@@ -2686,6 +2863,7 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2686
2863
  ledger.forget(rel);
2687
2864
  purgingDeletes.delete(rel);
2688
2865
  confirmedDeletes.delete(rel);
2866
+ acceptedIncoming.delete(rel);
2689
2867
  } else if (
2690
2868
  !here &&
2691
2869
  remoteHash !== null &&
@@ -2742,7 +2920,11 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2742
2920
  // gates it). One still waiting for an answer keeps waiting, and a new local delete joins its
2743
2921
  // question rather than slipping out under the limit beside it.
2744
2922
  const hits = work.filter(
2745
- (w) => w.decision.action === action && !(direction === 'out' && confirmedDeletes.has(w.rel))
2923
+ (w) =>
2924
+ w.decision.action === action &&
2925
+ !(direction === 'out' && confirmedDeletes.has(w.rel)) &&
2926
+ // 2.1.1 T13 — an incoming delete the person said to remove here goes through.
2927
+ !(direction === 'in' && acceptedIncoming.has(w.rel))
2746
2928
  );
2747
2929
  const asking =
2748
2930
  direction === 'out' &&
@@ -2770,10 +2952,9 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2770
2952
  if (ledger.row(w.rel)?.state !== 'delete-held') {
2771
2953
  ledger.setState(w.rel, 'delete-held', { reason: DELETE_HELD_REASON });
2772
2954
  }
2773
- } else {
2774
- ledger.setState(w.rel, 'conflict', {
2775
- reason: 'the project wants this removed, as part of a batch too large to apply unasked',
2776
- });
2955
+ } else if (ledger.row(w.rel)?.state !== 'delete-in-held') {
2956
+ // Its own state (T13): `conflict` read as a both-sides edit and offered no answer.
2957
+ ledger.setState(w.rel, 'delete-in-held', { reason: DELETE_IN_HELD_REASON });
2777
2958
  }
2778
2959
  }
2779
2960
  if (direction === 'out') {
@@ -2783,9 +2964,21 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2783
2964
  count: all.count,
2784
2965
  paths: all.paths.slice(0, 200),
2785
2966
  folders: all.folders.slice(0, 20),
2967
+ // 2.1.1 N4 — the set an answer would cover (`heldDeletes()`: not one already answered)
2968
+ digest: heldSetDigest(
2969
+ all.paths.filter((r) => !purgingDeletes.has(r) && !confirmedDeletes.has(r))
2970
+ ),
2786
2971
  };
2787
2972
  } else {
2788
- out.deleteHeld = { direction, count: paths.length, paths: paths.slice(0, 200) };
2973
+ // Every row still waiting for the person's answer, not just this pass's hits (T13).
2974
+ const all = summarizeHeldIncoming(ledger.rows(), acceptedIncoming);
2975
+ out.deleteHeld = {
2976
+ direction,
2977
+ count: all.count,
2978
+ paths: all.paths.slice(0, 200),
2979
+ folders: all.folders.slice(0, 20),
2980
+ digest: heldSetDigest(all.paths),
2981
+ };
2789
2982
  }
2790
2983
  work = work.filter((w) => !hits.includes(w));
2791
2984
  }
@@ -2960,6 +3153,21 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2960
3153
  while (inFlight.size > 0) await Promise.race(inFlight);
2961
3154
  };
2962
3155
 
3156
+ // 2.1.1 T13 — AN ACCEPTED INCOMING BATCH IS ONE PASS. Filing a file into `_trash/` is a local
3157
+ // rename: no request, no bytes, no hub to protect. The per-pass file ceiling exists for
3158
+ // downloads and uploads, and would stretch a person's "Remove here too" over a dozen passes.
3159
+ if (acceptedIncoming.size > 0) {
3160
+ const now1 = work.filter(
3161
+ (w) => w.decision.action === 'quarantine' && acceptedIncoming.has(w.rel)
3162
+ );
3163
+ if (now1.length > 0) {
3164
+ const gone = new Set(now1);
3165
+ work = work.filter((w) => !gone.has(w));
3166
+ for (const item of now1) await run(item);
3167
+ moved = 0;
3168
+ }
3169
+ }
3170
+
2963
3171
  for (const item of work) {
2964
3172
  // TWO CEILINGS, because they bound different things and only one of them
2965
3173
  // survives a bad day. `moved` bounds what LANDS — disk writes, parked
@@ -3264,8 +3472,16 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
3264
3472
  }
3265
3473
  ledger.setState(rel, 'pushing');
3266
3474
  const expect = decision.action === 'revive' ? null : remoteHash;
3267
- const res = await push(here, expect);
3475
+ // Over a tombstone this machine knows of, say which one (2.1.1 T9).
3476
+ const overTombstone = ledger.remoteTombstoned(rel);
3477
+ const res = await push(
3478
+ here,
3479
+ expect,
3480
+ overTombstone ? ledger.row(rel)?.remoteSeq : undefined
3481
+ );
3268
3482
  if (res.ok) {
3483
+ // The hub holds these bytes now; the tombstone this push decided over is history.
3484
+ if (overTombstone) ledger.noteRemote(rel, here.hash, res.seq ?? undefined);
3269
3485
  await ledger.adoptAfter(rel, here.hash, () => {}, {
3270
3486
  ...(res.seq !== null ? { remoteSeq: res.seq } : {}),
3271
3487
  size: here.size,
@@ -3295,6 +3511,18 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
3295
3511
  out.synced += 1;
3296
3512
  return true;
3297
3513
  }
3514
+ if (res.conflict && res.current === null && res.tombstoneSeq !== undefined) {
3515
+ // THE PATH IS TOMBSTONED, and this push did not decide over that tombstone (an owner
3516
+ // purge asks it be named — 2.1.1 T9). Remember it, so the next pass decides against the
3517
+ // delete (agreed → quarantine, held by the breaker; changed here → revive naming it)
3518
+ // instead of offering the same stale write again.
3519
+ ledger.noteRemote(rel, null, res.tombstoneSeq, true);
3520
+ ledger.setState(rel, 'conflict', {
3521
+ reason: 'the project deleted this file since this Mac last looked — deciding again',
3522
+ });
3523
+ out.conflicts.push({ rel, copy: null });
3524
+ return true;
3525
+ }
3298
3526
  if (res.conflict) {
3299
3527
  // The hub moved under us. Do NOT retry blindly — re-decide next
3300
3528
  // pass against what it actually holds now, which is exactly what a
@@ -3423,6 +3651,7 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
3423
3651
  return false;
3424
3652
  }
3425
3653
  ledger.forget(rel);
3654
+ acceptedIncoming.delete(rel);
3426
3655
  out.deleted.push({ rel, parked });
3427
3656
  return true;
3428
3657
  }
@@ -3464,6 +3693,13 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
3464
3693
  }
3465
3694
  }
3466
3695
 
3696
+ /** A row whose conflict copy still sits beside it and whose bytes are the ones the conflict settled on. */
3697
+ function keepsConflictCopy(kept: LedgerRow | null | undefined, hereHash: string): boolean {
3698
+ if (!kept || kept.state !== 'conflict' || !kept.conflictCopy) return false;
3699
+ if (kept.syncedHash !== hereHash) return false;
3700
+ return existsSync(path.join(designRoot, kept.conflictCopy));
3701
+ }
3702
+
3467
3703
  function restat(rel: string): void {
3468
3704
  try {
3469
3705
  const st = statSync(path.join(designRoot, rel));
@@ -3505,6 +3741,23 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
3505
3741
  dorucekaTotal() {
3506
3742
  return Object.keys(ledger.rows()).length;
3507
3743
  },
3744
+ conflictCopies() {
3745
+ // 2.1.1 T14 — the file → the copy of this Mac's version parked beside it, for every row still
3746
+ // in conflict. Bounded like the doručenka, and only copies that are still on disk.
3747
+ const out: Record<string, string> = {};
3748
+ for (const [rel, row] of Object.entries(ledger.rows()).sort((a, b) =>
3749
+ a[0].localeCompare(b[0])
3750
+ )) {
3751
+ if (Object.keys(out).length >= MAX_CONFLICT_COPIES) break;
3752
+ if (
3753
+ row.state === 'conflict' &&
3754
+ row.conflictCopy &&
3755
+ existsSync(path.join(designRoot, row.conflictCopy))
3756
+ )
3757
+ out[rel] = row.conflictCopy;
3758
+ }
3759
+ return out;
3760
+ },
3508
3761
  heldDeletes() {
3509
3762
  // What still waits for an answer: an answered row (being sent, or purged) is not asked again.
3510
3763
  const waiting: Record<string, LedgerRow> = {};
@@ -3526,6 +3779,20 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
3526
3779
  endPurge(rels) {
3527
3780
  for (const rel of rels) purgingDeletes.delete(rel);
3528
3781
  },
3782
+ heldIncomingDeletes() {
3783
+ return summarizeHeldIncoming(ledger.rows(), acceptedIncoming);
3784
+ },
3785
+ answerIncomingDeletes(how, folder, digest) {
3786
+ const all = summarizeHeldIncoming(ledger.rows(), acceptedIncoming).paths;
3787
+ // 2.1.1 T8 — the answer covers exactly the set the person saw, or nothing
3788
+ if (digest !== heldSetDigest(all)) return null;
3789
+ const rels = all.filter((r) => inHeldFolder(r, folder));
3790
+ for (const rel of rels) {
3791
+ if (how === 'remove') acceptedIncoming.add(rel);
3792
+ else ledger.setState(rel, 'kept-here', { reason: KEPT_HERE_REASON });
3793
+ }
3794
+ return rels;
3795
+ },
3529
3796
  /**
3530
3797
  * HOW MUCH MEDIA IS NOT HERE — plan T29.
3531
3798
  *