@xiaobuyu/nodesign 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (383) hide show
  1. package/README.md +266 -79
  2. package/README.zh-CN.md +254 -67
  3. package/package.json +2 -2
  4. package/server/api/admin.js +7 -0
  5. package/server/api/assets/docx-page.js +5 -4
  6. package/server/api/assets/helpers.js +26 -0
  7. package/server/api/assets/notes.js +50 -0
  8. package/server/api/assets.js +31 -38
  9. package/server/api/board.js +29 -1
  10. package/server/api/browse.js +3 -2
  11. package/server/api/chatai.js +9 -8
  12. package/server/api/exports/cards.js +7 -6
  13. package/server/api/exports/docx-pdf.js +4 -1
  14. package/server/api/instruction.js +3 -3
  15. package/server/api/local.js +10 -8
  16. package/server/api/projects.js +19 -3
  17. package/server/api/publish.js +3 -2
  18. package/server/api/sessions-rewind.js +220 -0
  19. package/server/api/sessions.js +58 -194
  20. package/server/api/stage.js +35 -0
  21. package/server/api/turn-model-switch.js +109 -0
  22. package/server/api/turn.js +52 -88
  23. package/server/auth/middleware.js +29 -6
  24. package/server/auth/tier.js +27 -7
  25. package/server/auth/users-store.js +14 -1
  26. package/server/engine/agent/actor-trail.js +110 -0
  27. package/server/engine/agent/agent-shared.js +22 -52
  28. package/server/engine/agent/beat-state.js +61 -0
  29. package/server/engine/agent/cast.js +322 -0
  30. package/server/engine/agent/events.js +18 -1
  31. package/server/engine/agent/hooks/beat-gate.js +73 -0
  32. package/server/engine/agent/hooks/failure.js +11 -1
  33. package/server/engine/agent/hooks/lifecycle.js +16 -41
  34. package/server/engine/agent/hooks/post-guidance.js +4 -38
  35. package/server/engine/agent/hooks/post-trim.js +1 -0
  36. package/server/engine/agent/hooks/pre-board-dirty.js +29 -0
  37. package/server/engine/agent/hooks/pre-defaults.js +206 -2
  38. package/server/engine/agent/hooks/pre-injectors.js +19 -2
  39. package/server/engine/agent/hooks/pre-peer-guard.js +88 -0
  40. package/server/engine/agent/hooks/pre-unknown-params.js +82 -0
  41. package/server/engine/agent/hooks/pre-workspace-scope-guard.js +33 -0
  42. package/server/engine/agent/hooks/resident-role-lifecycle.js +100 -0
  43. package/server/engine/agent/hooks/slot-alias.js +30 -0
  44. package/server/engine/agent/hooks/user-prompt-submit.js +208 -47
  45. package/server/engine/agent/hooks.js +80 -14
  46. package/server/engine/agent/isolation.js +25 -2
  47. package/server/engine/agent/memory-config.js +87 -0
  48. package/server/engine/agent/model-context.js +102 -18
  49. package/server/engine/agent/model-table.js +361 -58
  50. package/server/engine/agent/prompts/nodesign-prelude.md +579 -70
  51. package/server/engine/agent/prompts/tools/direct-edit-protocol.md +1 -1
  52. package/server/engine/agent/prompts/tools/generate-image-cookbook.md +26 -9
  53. package/server/engine/agent/prompts/tools/paint-still-cookbook.md +1 -1
  54. package/server/engine/agent/prompts/tools/site-reference.md +15 -4
  55. package/server/engine/agent/role-card.js +175 -0
  56. package/server/engine/agent/rp-mode.js +17 -0
  57. package/server/engine/agent/session-loop.js +55 -32
  58. package/server/engine/agent/stage-status.js +73 -0
  59. package/server/engine/agent/subagent-flight.js +73 -0
  60. package/server/engine/agent/system-prompts.js +41 -0
  61. package/server/engine/agent/tool-input-stream.js +165 -0
  62. package/server/engine/agents/explorer.md +1 -1
  63. package/server/engine/agents/index.js +1 -1
  64. package/server/engine/mcp/actor.js +59 -0
  65. package/server/engine/mcp/capability-gate.js +21 -2
  66. package/server/engine/mcp/index.js +118 -33
  67. package/server/engine/mcp/mode-profile.js +139 -0
  68. package/server/engine/mcp/server-name.js +19 -0
  69. package/server/engine/mcp/tools/artifact-session.js +2 -1
  70. package/server/engine/mcp/tools/browse-computer.js +2 -1
  71. package/server/engine/mcp/tools/browse-find-batch.js +95 -16
  72. package/server/engine/mcp/tools/browse.js +25 -3
  73. package/server/engine/mcp/tools/cast-role.js +167 -0
  74. package/server/engine/mcp/tools/crystallize-skill.js +1 -1
  75. package/server/engine/mcp/tools/draw-trend.js +104 -0
  76. package/server/engine/mcp/tools/edit-board-schema.js +56 -0
  77. package/server/engine/mcp/tools/edit-board.js +569 -0
  78. package/server/engine/mcp/tools/generate-image.js +50 -70
  79. package/server/engine/mcp/tools/helpers/codex-imagegen.js +139 -0
  80. package/server/engine/mcp/tools/helpers/rembg.js +7 -2
  81. package/server/engine/mcp/tools/helpers/shot-pipeline.js +109 -0
  82. package/server/engine/mcp/tools/list-pages.js +11 -5
  83. package/server/engine/mcp/tools/look-at-board.js +4 -3
  84. package/server/engine/mcp/tools/open-sheet.js +242 -0
  85. package/server/engine/mcp/tools/organize-board.js +45 -6
  86. package/server/engine/mcp/tools/paint-still.js +1 -1
  87. package/server/engine/mcp/tools/pin-to-board.js +103 -19
  88. package/server/engine/mcp/tools/read-board.js +123 -16
  89. package/server/engine/mcp/tools/read-tavern-json.js +87 -19
  90. package/server/engine/mcp/tools/report-issue.js +15 -7
  91. package/server/engine/mcp/tools/role-memory.js +83 -0
  92. package/server/engine/mcp/tools/roll-dice.js +82 -0
  93. package/server/engine/mcp/tools/roll-film.js +1 -1
  94. package/server/engine/mcp/tools/screenshot.js +19 -9
  95. package/server/engine/mcp/tools/set-vars.js +150 -0
  96. package/server/engine/mcp/tools/sheet-replan.js +46 -0
  97. package/server/engine/mcp/tools/web-search.js +12 -16
  98. package/server/engine/mcp/tools/write-on-board-flow.js +108 -0
  99. package/server/engine/mcp/tools/write-on-board-place.js +211 -0
  100. package/server/engine/mcp/tools/write-on-board-role-anchor.js +48 -0
  101. package/server/engine/mcp/tools/write-on-board-schema.js +125 -0
  102. package/server/engine/mcp/tools/write-on-board.js +568 -99
  103. package/server/engine/plugins/nodesign/skills/blackboard-rp/SKILL.md +215 -0
  104. package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/SKILL.md +14 -7
  105. package/server/engine/plugins/nodesign/skills/docx-craft/SKILL.md +44 -5
  106. package/server/engine/plugins/nodesign/skills/docx-craft/references/token-schema.md +16 -0
  107. package/server/engine/plugins/nodesign/skills/site-craft/SKILL.md +24 -8
  108. package/server/engine/plugins/nodesign/skills/story-craft/SKILL.md +94 -0
  109. package/server/engine/plugins/nodesign/skills/story-import/SKILL.md +112 -0
  110. package/server/engine/plugins/nodesign/skills/story-intimacy/SKILL.md +72 -0
  111. package/server/engine/plugins/nodesign/skills/story-voice/SKILL.md +66 -0
  112. package/server/engine/plugins/nodesign/skills/story-voice/voices//345/206/267/347/241/254.md +33 -0
  113. package/server/engine/plugins/nodesign/skills/story-voice/voices//346/203/205/346/204/237/347/233/264/347/273/231.md +42 -0
  114. package/server/engine/plugins/nodesign/skills/story-voice/voices//346/204/217/350/257/206/346/265/201.md +42 -0
  115. package/server/engine/plugins/nodesign/skills/story-voice/voices//346/255/246/344/276/240/347/231/275/350/257/235.md +34 -0
  116. package/server/engine/plugins/nodesign/skills/story-voice/voices//347/224/237/346/264/273/346/265/201.md +35 -0
  117. package/server/engine/plugins/nodesign/skills/story-voice/voices//347/231/275/346/217/217.md +37 -0
  118. package/server/engine/plugins/nodesign/skills/story-voice/voices//350/210/236/345/217/260/345/211/247.md +32 -0
  119. package/server/engine/plugins/nodesign/skills/story-voice/voices//351/230/266/346/256/265/345/210/207/346/215/242.md +42 -0
  120. package/server/engine/runs/board-seater.js +272 -0
  121. package/server/engine/runs/board-tasklist.js +90 -48
  122. package/server/engine/runs/turn-relay.js +24 -2
  123. package/server/engine/runs/user-chalk-echo.js +44 -0
  124. package/server/index.js +2 -2
  125. package/server/lib/artifact-target.js +31 -14
  126. package/server/lib/board-anchor.js +49 -0
  127. package/server/lib/board-dirty.js +93 -0
  128. package/server/lib/board-excerpt.js +80 -0
  129. package/server/lib/board-follow.js +111 -0
  130. package/server/lib/board-groups.js +1 -5
  131. package/server/lib/board-hero.js +3 -1
  132. package/server/lib/board-kind-sizes.js +38 -3
  133. package/server/lib/board-lanes.js +58 -0
  134. package/server/lib/board-obstacles.js +80 -0
  135. package/server/lib/board-relations.js +5 -1
  136. package/server/lib/board-sheets.js +467 -0
  137. package/server/lib/board-shelf.js +86 -0
  138. package/server/lib/board-transform.js +62 -0
  139. package/server/lib/canvas-id.js +46 -4
  140. package/server/lib/chalk-flow.js +88 -0
  141. package/server/lib/chalk-rewrite.js +63 -0
  142. package/server/lib/chalk-size-pref.js +48 -0
  143. package/server/lib/chalk.js +42 -3
  144. package/server/lib/export-collect.js +3 -1
  145. package/server/lib/ingress/forward-openai-chat.js +16 -4
  146. package/server/lib/ingress/openai-chat.js +23 -12
  147. package/server/lib/ingress/session-routes.js +3 -3
  148. package/server/lib/ingress/stream-watchdog.js +53 -0
  149. package/server/lib/ingress/upstream-billing.js +15 -0
  150. package/server/lib/ingress/upstream-error-hints.js +36 -0
  151. package/server/lib/issues-store.js +3 -1
  152. package/server/lib/json-preview.js +58 -0
  153. package/server/lib/kinds/docx.js +11 -4
  154. package/server/lib/kinds/index.js +6 -16
  155. package/server/lib/kinds/site.js +40 -7
  156. package/server/lib/model-ingress.js +26 -1
  157. package/server/lib/moderation.js +10 -5
  158. package/server/lib/quota.js +26 -6
  159. package/server/lib/rect.js +50 -0
  160. package/server/lib/rewrite-refs.js +110 -0
  161. package/server/lib/screen.js +36 -0
  162. package/server/lib/sheet-state.js +19 -0
  163. package/server/lib/sketch-array.js +118 -0
  164. package/server/lib/sketch-hatch.js +99 -0
  165. package/server/lib/sketch-layout.js +269 -69
  166. package/server/lib/sketch-shapes.js +152 -0
  167. package/server/lib/sketch-stencils.js +170 -0
  168. package/server/lib/ssrf-guard.js +9 -0
  169. package/server/lib/state-table.js +237 -0
  170. package/server/lib/state-trend.js +94 -0
  171. package/server/lib/state-triggers.js +199 -0
  172. package/server/lib/task-scan.js +18 -0
  173. package/server/lib/tavern-json.js +48 -0
  174. package/server/lib/user-uploads.js +88 -0
  175. package/server/projects/board-limits.js +5 -3
  176. package/server/projects/board-sanitize.js +220 -10
  177. package/server/projects/board-store.js +137 -7
  178. package/server/projects/memory-migration.js +85 -0
  179. package/server/projects/move-entry.js +11 -1
  180. package/server/projects/session-jsonl.js +110 -0
  181. package/server/projects/store.js +56 -3
  182. package/server/projects/ui-config.js +2 -1
  183. package/server/projects/viewpoint-store.js +35 -3
  184. package/server/projects/workspace-slots.js +30 -0
  185. package/server/projects/workspace-templates.js +42 -10
  186. package/server/projects/workspace.js +25 -26
  187. package/server/runtime/capabilities.js +6 -2
  188. package/server/services/rembg-launcher.js +5 -2
  189. package/server/shared/locales.js +70 -0
  190. package/server/shared/messages-en.js +69 -0
  191. package/server/shared/messages.js +65 -0
  192. package/server/ws/broker.js +3 -0
  193. package/server/ws/index.js +43 -3
  194. package/web/README.md +1 -1
  195. package/web/dist/assets/{BrowserWindow-P_vIdh-G.js → BrowserWindow-CcaGRWz5.js} +1 -1
  196. package/web/dist/assets/DeckWindow-BIr2KGFT.js +6 -0
  197. package/web/dist/assets/{DocxWindow-DSAU1-tD.js → DocxWindow-B9KZmU5z.js} +2 -2
  198. package/web/dist/assets/{MermaidBlock-DR1GikCv.js → MermaidBlock-DrfRnz8E.js} +43 -43
  199. package/web/dist/assets/{SiteWindow-92uBuRRR.js → SiteWindow-CJOjCF7d.js} +6 -6
  200. package/web/dist/assets/{abnfDiagram-VCTEODGH-uA8Esix4.js → abnfDiagram-VCTEODGH-CUZbQGIg.js} +1 -1
  201. package/web/dist/assets/{arc-D_khH_xN.js → arc-C1-HSUny.js} +1 -1
  202. package/web/dist/assets/{architectureDiagram-5GKGNRK7-DydJHqOt.js → architectureDiagram-5GKGNRK7-B5nwvu60.js} +2 -2
  203. package/web/dist/assets/{blockDiagram-NRAW4CY4-B7wBbKiW.js → blockDiagram-NRAW4CY4-uPPuFLwR.js} +1 -1
  204. package/web/dist/assets/{c4Diagram-UCG6FXSJ-6mrH0x7Y.js → c4Diagram-UCG6FXSJ-C0mKBFlz.js} +1 -1
  205. package/web/dist/assets/channel-BxpWNOGU.js +1 -0
  206. package/web/dist/assets/{chunk-2Q5K7J3B-Cuikho5Q.js → chunk-2Q5K7J3B-Cs0rlZ4q.js} +1 -1
  207. package/web/dist/assets/{chunk-5VM5RSS4-3-KZ5AUz.js → chunk-5VM5RSS4-DtR63oYb.js} +1 -1
  208. package/web/dist/assets/{chunk-F27PBJKO-Bkwq2gGU.js → chunk-F27PBJKO-B3MRdezJ.js} +1 -1
  209. package/web/dist/assets/{chunk-G27WJ6UU-BLyQzdGE.js → chunk-G27WJ6UU-BtwntwpS.js} +1 -1
  210. package/web/dist/assets/{chunk-JWPE2WC7-B7HxxQds.js → chunk-JWPE2WC7-BHsTe5PD.js} +1 -1
  211. package/web/dist/assets/{chunk-LCL6LL3I-CtXrnUwF.js → chunk-LCL6LL3I-knY15Qdm.js} +1 -1
  212. package/web/dist/assets/{chunk-POPQ4Y6H-dxddZlXt.js → chunk-POPQ4Y6H-C51tgK_I.js} +1 -1
  213. package/web/dist/assets/{chunk-SVP7TREG-DpkmrgHn.js → chunk-SVP7TREG-CnwRZmF_.js} +1 -1
  214. package/web/dist/assets/{chunk-XXDRQBXY-BwZ7RbpQ.js → chunk-XXDRQBXY-BtXzVF-_.js} +1 -1
  215. package/web/dist/assets/classDiagram-DTDB5LWJ-DUEKmDfo.js +1 -0
  216. package/web/dist/assets/classDiagram-v2-JRS7N3AN-DUEKmDfo.js +1 -0
  217. package/web/dist/assets/{cose-bilkent-JH36ORCC-DGFOsMUt.js → cose-bilkent-JH36ORCC-CzWlGP6i.js} +1 -1
  218. package/web/dist/assets/{cynefin-OW5HDTMX-DUwn3ehS.js → cynefin-OW5HDTMX-vK64EGSv.js} +1 -1
  219. package/web/dist/assets/{cynefinDiagram-5FMLGOSQ-DlLAOZ9x.js → cynefinDiagram-5FMLGOSQ-Bs3g1Gvh.js} +1 -1
  220. package/web/dist/assets/{dagre-3AP2YEHR-CyourLfz.js → dagre-3AP2YEHR-BhgkYe8V.js} +1 -1
  221. package/web/dist/assets/{diagram-S7CK7UJ4-BTMbx2np.js → diagram-S7CK7UJ4-C_6mvD2V.js} +1 -1
  222. package/web/dist/assets/{diagram-UQ7AKVKN-UK94_1-P.js → diagram-UQ7AKVKN-qW7tssUW.js} +1 -1
  223. package/web/dist/assets/{diagram-VSXAHHWV-C7zS-v9v.js → diagram-VSXAHHWV-txJPHpvG.js} +1 -1
  224. package/web/dist/assets/{diagram-VX7I27RA-DKJRa6CK.js → diagram-VX7I27RA-CQTMsCnL.js} +1 -1
  225. package/web/dist/assets/{diagram-Z3DM3KII-kUbAfGAp.js → diagram-Z3DM3KII--cb1hoE6.js} +1 -1
  226. package/web/dist/assets/{ebnfDiagram-PWID7BFC-CVW16_vb.js → ebnfDiagram-PWID7BFC-Da6lDU77.js} +1 -1
  227. package/web/dist/assets/{erDiagram-SSCWMZ5O-BRQMFQ5y.js → erDiagram-SSCWMZ5O-DGCMrsQn.js} +1 -1
  228. package/web/dist/assets/{flowDiagram-A5DVABFB-S34LpLtK.js → flowDiagram-A5DVABFB-GdOL_qno.js} +1 -1
  229. package/web/dist/assets/{ganttDiagram-EL5Y4UJY-BFiqk1-G.js → ganttDiagram-EL5Y4UJY-Cx1F_jBK.js} +4 -4
  230. package/web/dist/assets/{gitGraphDiagram-WWUBYQGX-LZsrdyyv.js → gitGraphDiagram-WWUBYQGX-B5_6JhR3.js} +1 -1
  231. package/web/dist/assets/hand-CuvZZQGW.webp +0 -0
  232. package/web/dist/assets/index-BYKfMnmv.js +2759 -0
  233. package/web/dist/assets/index-CW7VsrVg.css +1 -0
  234. package/web/dist/assets/{infoDiagram-RXCK75RN-0DvN6KIp.js → infoDiagram-RXCK75RN-CjvKpSPA.js} +1 -1
  235. package/web/dist/assets/{ishikawaDiagram-5VMMS53U-CaY3A-Bx.js → ishikawaDiagram-5VMMS53U-CxLoAPhx.js} +1 -1
  236. package/web/dist/assets/{journeyDiagram-EYS64GPL-BBeiaCrj.js → journeyDiagram-EYS64GPL-BfvS1upJ.js} +1 -1
  237. package/web/dist/assets/{kanban-definition-3QL26DDD-ux42DRXQ.js → kanban-definition-3QL26DDD-DKPPu0w4.js} +1 -1
  238. package/web/dist/assets/{layout-CnXiF_NB.js → layout-Dhgck-Zo.js} +1 -1
  239. package/web/dist/assets/{linear-BMW0u6G6.js → linear-DMSQ-aUw.js} +1 -1
  240. package/web/dist/assets/lxgw-nd-app-bold-D1pKA1bR.woff2 +0 -0
  241. package/web/dist/assets/lxgw-nd-app-regular-BDe3d26v.woff2 +0 -0
  242. package/web/dist/assets/lxgw-nd-bold-Bufvlg03.woff2 +0 -0
  243. package/web/dist/assets/lxgw-nd-regular-DQwoI4OP.woff2 +0 -0
  244. package/web/dist/assets/lxgwwenkaiscreen-subset-100-DLPe7tEt.woff2 +0 -0
  245. package/web/dist/assets/lxgwwenkaiscreen-subset-101-d3VsZKWT.woff2 +0 -0
  246. package/web/dist/assets/lxgwwenkaiscreen-subset-102-ClzJuLq6.woff2 +0 -0
  247. package/web/dist/assets/lxgwwenkaiscreen-subset-103-DuDnQ6K-.woff2 +0 -0
  248. package/web/dist/assets/lxgwwenkaiscreen-subset-104-kPGW3Eem.woff2 +0 -0
  249. package/web/dist/assets/lxgwwenkaiscreen-subset-105-BzD54h-0.woff2 +0 -0
  250. package/web/dist/assets/lxgwwenkaiscreen-subset-106-BQ7fIzlx.woff2 +0 -0
  251. package/web/dist/assets/lxgwwenkaiscreen-subset-107-D8tDfFHI.woff2 +0 -0
  252. package/web/dist/assets/lxgwwenkaiscreen-subset-108-tGhkpwep.woff2 +0 -0
  253. package/web/dist/assets/lxgwwenkaiscreen-subset-109-7SMVSrly.woff2 +0 -0
  254. package/web/dist/assets/lxgwwenkaiscreen-subset-110-_uDKrFed.woff2 +0 -0
  255. package/web/dist/assets/lxgwwenkaiscreen-subset-111-Bio825RE.woff2 +0 -0
  256. package/web/dist/assets/lxgwwenkaiscreen-subset-112-D2ee0i-C.woff2 +0 -0
  257. package/web/dist/assets/lxgwwenkaiscreen-subset-113-JPFVDrga.woff2 +0 -0
  258. package/web/dist/assets/lxgwwenkaiscreen-subset-114-BcfxYA4w.woff2 +0 -0
  259. package/web/dist/assets/lxgwwenkaiscreen-subset-115-B1HeeOsd.woff2 +0 -0
  260. package/web/dist/assets/lxgwwenkaiscreen-subset-116-hY12tXpq.woff2 +0 -0
  261. package/web/dist/assets/lxgwwenkaiscreen-subset-117-BvuZwmre.woff2 +0 -0
  262. package/web/dist/assets/lxgwwenkaiscreen-subset-118-tzvs_H7j.woff2 +0 -0
  263. package/web/dist/assets/lxgwwenkaiscreen-subset-119-J2DWuYDN.woff2 +0 -0
  264. package/web/dist/assets/lxgwwenkaiscreen-subset-21-pDubCJV5.woff2 +0 -0
  265. package/web/dist/assets/lxgwwenkaiscreen-subset-22-ChAPMpqp.woff2 +0 -0
  266. package/web/dist/assets/lxgwwenkaiscreen-subset-23-BBx3oNpT.woff2 +0 -0
  267. package/web/dist/assets/lxgwwenkaiscreen-subset-24-CYt-Oagk.woff2 +0 -0
  268. package/web/dist/assets/lxgwwenkaiscreen-subset-25-Cx3j-ZUv.woff2 +0 -0
  269. package/web/dist/assets/lxgwwenkaiscreen-subset-26-B9AfZ3LL.woff2 +0 -0
  270. package/web/dist/assets/lxgwwenkaiscreen-subset-27-Bh2s9MNE.woff2 +0 -0
  271. package/web/dist/assets/lxgwwenkaiscreen-subset-28-C02JPoKP.woff2 +0 -0
  272. package/web/dist/assets/lxgwwenkaiscreen-subset-29-T_tbUGhk.woff2 +0 -0
  273. package/web/dist/assets/lxgwwenkaiscreen-subset-30-DMfyNzhz.woff2 +0 -0
  274. package/web/dist/assets/lxgwwenkaiscreen-subset-31-DFfdzbkg.woff2 +0 -0
  275. package/web/dist/assets/lxgwwenkaiscreen-subset-32-Bs1fz2iW.woff2 +0 -0
  276. package/web/dist/assets/lxgwwenkaiscreen-subset-33-cpB96OkZ.woff2 +0 -0
  277. package/web/dist/assets/lxgwwenkaiscreen-subset-34-BhinPYWX.woff2 +0 -0
  278. package/web/dist/assets/lxgwwenkaiscreen-subset-35-D_njRQqA.woff2 +0 -0
  279. package/web/dist/assets/lxgwwenkaiscreen-subset-36-DqXlLE3t.woff2 +0 -0
  280. package/web/dist/assets/lxgwwenkaiscreen-subset-37-j5LbvMph.woff2 +0 -0
  281. package/web/dist/assets/lxgwwenkaiscreen-subset-38-oO4jWdKm.woff2 +0 -0
  282. package/web/dist/assets/lxgwwenkaiscreen-subset-39-CabsX4rw.woff2 +0 -0
  283. package/web/dist/assets/lxgwwenkaiscreen-subset-4-PatS3YHh.woff2 +0 -0
  284. package/web/dist/assets/lxgwwenkaiscreen-subset-40-yrLg3C3e.woff2 +0 -0
  285. package/web/dist/assets/lxgwwenkaiscreen-subset-41-DBXmCQhc.woff2 +0 -0
  286. package/web/dist/assets/lxgwwenkaiscreen-subset-42-Bqij_UiQ.woff2 +0 -0
  287. package/web/dist/assets/lxgwwenkaiscreen-subset-43-D3kp0Ntc.woff2 +0 -0
  288. package/web/dist/assets/lxgwwenkaiscreen-subset-44-B_BNGvK4.woff2 +0 -0
  289. package/web/dist/assets/lxgwwenkaiscreen-subset-45-CZc0cQWs.woff2 +0 -0
  290. package/web/dist/assets/lxgwwenkaiscreen-subset-46-CHQX5Kd9.woff2 +0 -0
  291. package/web/dist/assets/lxgwwenkaiscreen-subset-47-Ci8gLrHA.woff2 +0 -0
  292. package/web/dist/assets/lxgwwenkaiscreen-subset-48-run3ugD3.woff2 +0 -0
  293. package/web/dist/assets/lxgwwenkaiscreen-subset-49-DgfiUb6u.woff2 +0 -0
  294. package/web/dist/assets/lxgwwenkaiscreen-subset-5-B0CtGbX_.woff2 +0 -0
  295. package/web/dist/assets/lxgwwenkaiscreen-subset-50-CdCG-POr.woff2 +0 -0
  296. package/web/dist/assets/lxgwwenkaiscreen-subset-51-L2okeQZ2.woff2 +0 -0
  297. package/web/dist/assets/lxgwwenkaiscreen-subset-52-BZAqyGJW.woff2 +0 -0
  298. package/web/dist/assets/lxgwwenkaiscreen-subset-53-B0xWqLeU.woff2 +0 -0
  299. package/web/dist/assets/lxgwwenkaiscreen-subset-54-BZVQX-EA.woff2 +0 -0
  300. package/web/dist/assets/lxgwwenkaiscreen-subset-55-093mkIUJ.woff2 +0 -0
  301. package/web/dist/assets/lxgwwenkaiscreen-subset-56-CbhWG8G-.woff2 +0 -0
  302. package/web/dist/assets/lxgwwenkaiscreen-subset-57-pLQuvo6c.woff2 +0 -0
  303. package/web/dist/assets/lxgwwenkaiscreen-subset-58-BHhoY50x.woff2 +0 -0
  304. package/web/dist/assets/lxgwwenkaiscreen-subset-59-D1_6DuIQ.woff2 +0 -0
  305. package/web/dist/assets/lxgwwenkaiscreen-subset-6-BnAelmYU.woff2 +0 -0
  306. package/web/dist/assets/lxgwwenkaiscreen-subset-60-HDBIuLTZ.woff2 +0 -0
  307. package/web/dist/assets/lxgwwenkaiscreen-subset-61-C-c13SeU.woff2 +0 -0
  308. package/web/dist/assets/lxgwwenkaiscreen-subset-62-kHRVOhZ2.woff2 +0 -0
  309. package/web/dist/assets/lxgwwenkaiscreen-subset-63-C0MCsvFv.woff2 +0 -0
  310. package/web/dist/assets/lxgwwenkaiscreen-subset-64-DZekguCj.woff2 +0 -0
  311. package/web/dist/assets/lxgwwenkaiscreen-subset-65-CtP6c3IU.woff2 +0 -0
  312. package/web/dist/assets/lxgwwenkaiscreen-subset-66-DLVWoMSf.woff2 +0 -0
  313. package/web/dist/assets/lxgwwenkaiscreen-subset-67-BVuOnayH.woff2 +0 -0
  314. package/web/dist/assets/lxgwwenkaiscreen-subset-68-DpxQ6Mnx.woff2 +0 -0
  315. package/web/dist/assets/lxgwwenkaiscreen-subset-69-qesBxLmC.woff2 +0 -0
  316. package/web/dist/assets/lxgwwenkaiscreen-subset-70-BBt1xN7h.woff2 +0 -0
  317. package/web/dist/assets/lxgwwenkaiscreen-subset-71-BWqZacwB.woff2 +0 -0
  318. package/web/dist/assets/lxgwwenkaiscreen-subset-72-B1wP_Yst.woff2 +0 -0
  319. package/web/dist/assets/lxgwwenkaiscreen-subset-73-C99T7jNZ.woff2 +0 -0
  320. package/web/dist/assets/lxgwwenkaiscreen-subset-74-DrUTsWBe.woff2 +0 -0
  321. package/web/dist/assets/lxgwwenkaiscreen-subset-75-C4M5XXQe.woff2 +0 -0
  322. package/web/dist/assets/lxgwwenkaiscreen-subset-76-Bq8spVWF.woff2 +0 -0
  323. package/web/dist/assets/lxgwwenkaiscreen-subset-77-D9vNupE2.woff2 +0 -0
  324. package/web/dist/assets/lxgwwenkaiscreen-subset-78-D6th7Gnu.woff2 +0 -0
  325. package/web/dist/assets/lxgwwenkaiscreen-subset-79-bezM85cS.woff2 +0 -0
  326. package/web/dist/assets/lxgwwenkaiscreen-subset-80-DD8pnhG2.woff2 +0 -0
  327. package/web/dist/assets/lxgwwenkaiscreen-subset-81-N6jtSyBs.woff2 +0 -0
  328. package/web/dist/assets/lxgwwenkaiscreen-subset-82-D6c180bZ.woff2 +0 -0
  329. package/web/dist/assets/lxgwwenkaiscreen-subset-83-em17AadM.woff2 +0 -0
  330. package/web/dist/assets/lxgwwenkaiscreen-subset-84-CJ8gdrMK.woff2 +0 -0
  331. package/web/dist/assets/lxgwwenkaiscreen-subset-85-9PPGO1eB.woff2 +0 -0
  332. package/web/dist/assets/lxgwwenkaiscreen-subset-86-CjWPf-u5.woff2 +0 -0
  333. package/web/dist/assets/lxgwwenkaiscreen-subset-87-8D_X_yOC.woff2 +0 -0
  334. package/web/dist/assets/lxgwwenkaiscreen-subset-88-9vtKFPBx.woff2 +0 -0
  335. package/web/dist/assets/lxgwwenkaiscreen-subset-89-BhE5jAKX.woff2 +0 -0
  336. package/web/dist/assets/lxgwwenkaiscreen-subset-90-D2Npfm5E.woff2 +0 -0
  337. package/web/dist/assets/lxgwwenkaiscreen-subset-91-C6Ft1-Eu.woff2 +0 -0
  338. package/web/dist/assets/lxgwwenkaiscreen-subset-97-CaExyQP9.woff2 +0 -0
  339. package/web/dist/assets/lxgwwenkaiscreen-subset-98-CPoVbsUd.woff2 +0 -0
  340. package/web/dist/assets/lxgwwenkaiscreen-subset-99-ZUQZGVgH.woff2 +0 -0
  341. package/web/dist/assets/{mindmap-definition-FBJOCRG2-hUxSpdKn.js → mindmap-definition-FBJOCRG2-CalfL_Kn.js} +1 -1
  342. package/web/dist/assets/{pegDiagram-XKGWAZYB-aCaQPH0w.js → pegDiagram-XKGWAZYB-D9mVWz7l.js} +1 -1
  343. package/web/dist/assets/pending-edit-apply-kwMFWsUe.js +31 -0
  344. package/web/dist/assets/{pieDiagram-E7YTZNPT-CmOEZ8zg.js → pieDiagram-E7YTZNPT-DELzbZNS.js} +1 -1
  345. package/web/dist/assets/{quadrantDiagram-AXDQQJYC-VW6fAhsV.js → quadrantDiagram-AXDQQJYC-TZqp4mfA.js} +1 -1
  346. package/web/dist/assets/{railroadDiagram-O6MQD6OU-CKJ7Ba5K.js → railroadDiagram-O6MQD6OU-DxX59f0i.js} +1 -1
  347. package/web/dist/assets/{requirementDiagram-EFPCY7ZU-pNGkq9Vw.js → requirementDiagram-EFPCY7ZU-DFdsJLIe.js} +1 -1
  348. package/web/dist/assets/{rotate-cw-KAfChbGV.js → rotate-cw-62liz7LX.js} +1 -1
  349. package/web/dist/assets/{sankeyDiagram-P5KCCOFB-BIMmDTfZ.js → sankeyDiagram-P5KCCOFB-ByYcd3fG.js} +1 -1
  350. package/web/dist/assets/{sequenceDiagram-WJ2MYXX4-BBW7wzKY.js → sequenceDiagram-WJ2MYXX4-Bj-ml1jS.js} +1 -1
  351. package/web/dist/assets/{sizeCapture-X5ZJPWSS-DdkXmLYR.js → sizeCapture-X5ZJPWSS-KhsXThyD.js} +1 -1
  352. package/web/dist/assets/{square-dashed-mouse-pointer-CDUlhUP7.js → square-dashed-mouse-pointer-D_VrqVpy.js} +1 -1
  353. package/web/dist/assets/{stateDiagram-HBIQ2CUA-W313Uz16.js → stateDiagram-HBIQ2CUA-BJlpHfWU.js} +1 -1
  354. package/web/dist/assets/stateDiagram-v2-4QOOHH4V-CR2kYAH2.js +1 -0
  355. package/web/dist/assets/{swimlanes-XN3QIQJK-C29TL26K.js → swimlanes-XN3QIQJK-DUB9OJVs.js} +1 -1
  356. package/web/dist/assets/swimlanesDiagram-VK2B7HYN-BitOxnG2.js +8 -0
  357. package/web/dist/assets/{timeline-definition-24CTP7MA-CF0JMObX.js → timeline-definition-24CTP7MA-C03NX82A.js} +1 -1
  358. package/web/dist/assets/{vennDiagram-4TSXK5OY-DrDFsaH3.js → vennDiagram-4TSXK5OY-B9pjzngp.js} +1 -1
  359. package/web/dist/assets/{wardleyDiagram-VM6X3IG4-CVrnRIS_.js → wardleyDiagram-VM6X3IG4-UqWq_mcT.js} +1 -1
  360. package/web/dist/assets/{xychartDiagram-S5SC5T6Z-BvkN1zsT.js → xychartDiagram-S5SC5T6Z-D2pDKtOv.js} +1 -1
  361. package/web/dist/index.html +2 -2
  362. package/server/api/memory.js +0 -185
  363. package/server/engine/agent/prompts/tools/generate-image-cookbook.gemini-gateway.md +0 -583
  364. package/server/engine/mcp/tools/arrange-on-board.js +0 -124
  365. package/server/engine/mcp/tools/create-on-board.js +0 -152
  366. package/server/engine/mcp/tools/edit-sketch.js +0 -167
  367. package/server/engine/mcp/tools/record-decision.js +0 -140
  368. package/server/engine/mcp/tools/relate-on-board.js +0 -112
  369. package/server/engine/mcp/tools/sketch-on-board.js +0 -337
  370. package/server/engine/plugins/nodesign/skills/rp-craft/SKILL.md +0 -235
  371. package/server/engine/plugins/nodesign/skills/rp-craft/patterns//346/274/224/345/207/272/351/241/265-/346/234/200/345/260/217/345/256/236/347/216/260.html +0 -78
  372. package/server/engine/plugins/nodesign/skills/rp-craft//346/274/224/345/207/272.template.js +0 -268
  373. package/web/dist/assets/DeckWindow-BpLv5082.js +0 -16
  374. package/web/dist/assets/channel-DGkccMO1.js +0 -1
  375. package/web/dist/assets/classDiagram-DTDB5LWJ-BGscw3OD.js +0 -1
  376. package/web/dist/assets/classDiagram-v2-JRS7N3AN-BGscw3OD.js +0 -1
  377. package/web/dist/assets/index-C0KUf6Wd.css +0 -1
  378. package/web/dist/assets/index-GAamh1p4.js +0 -2152
  379. package/web/dist/assets/lxgw-nd-bold-DbRfiTgo.woff2 +0 -0
  380. package/web/dist/assets/lxgw-nd-regular-CpMw9Ehg.woff2 +0 -0
  381. package/web/dist/assets/pending-edit-apply-AcdOQ9Ij.js +0 -31
  382. package/web/dist/assets/stateDiagram-v2-4QOOHH4V-DDhJBZzf.js +0 -1
  383. package/web/dist/assets/swimlanesDiagram-VK2B7HYN-BfN-Xdmu.js +0 -8
@@ -1,112 +0,0 @@
1
- /**
2
- * mcp/tools/relate-on-board.js — relate_on_board MCP tool(2026-08-07)
3
- *
4
- * 让 agent 在画布上**画出产物之间的关系**。
5
- *
6
- * ## 为什么这个工具重要
7
- *
8
- * 北极星是「任务文件夹能排出登录墙那种版面」。手摆之所以好看,是因为每张纸的
9
- * 位置在回答「它和旁边那张什么关系」—— 而系统此前只知道每个产物的尺寸和
10
- * mtime。**关系数据不到位,再好的布局算法也只能排出「错落有致的网格」。**
11
- *
12
- * 关键洞察是:**关系不需要推断,agent 手里本来就有**。它知道 proto-暖调 和
13
- * proto-冷调 是同一拍的两个试作、知道哪张图是哪次批注的结果、知道这版改自那版。
14
- * 这些信息现在全在会话里,一落到画布就只剩文件名。这个工具就是那条落差。
15
- *
16
- * 线不存坐标:端点是物件 id 或工作区 id,端点一移动线自己跟着走。
17
- */
18
-
19
- import { tool } from '@anthropic-ai/claude-agent-sdk';
20
- import { z } from 'zod';
21
- import { patchBoard } from '../../../projects/board-store.js';
22
- import { BINDING_TYPES, BINDING_TYPE_IDS, BINDING_MATERIALS } from '../../../lib/binding-types.js';
23
-
24
- /** 词汇表渲染成工具描述里的一段表,免得两处各写各的 */
25
- const VOCAB = BINDING_TYPE_IDS
26
- .map(id => `- ${id} (${BINDING_TYPES[id].label})${BINDING_TYPES[id].directed ? '' : ' — undirected'}`)
27
- .join('\n');
28
-
29
- let seq = 0;
30
- const nextId = () => `b:a${Date.now().toString(36)}${(seq++ % 1000).toString(36)}`;
31
-
32
- export function makeRelateOnBoardTool({ projectId, ctx }) {
33
- return tool(
34
- 'relate_on_board',
35
- `Draw a relationship line between two things on the workbench canvas.
36
-
37
- The canvas knows *what* each artifact is, but not *how they relate*. You are
38
- the only one who knows that — you made them. Recording it lets the user see
39
- lineage at a glance, and lets layout put related things near each other.
40
-
41
- Relationship types:
42
- ${VOCAB}
43
-
44
- Endpoints are canvas ids — a kind prefix plus the workspace-relative path,
45
- exactly as the file sits on disk:
46
- - a file: 'assets/generated/x.webp', 'notes/灵感.md'
47
- - a deck: 'deck:海报/proto-暖调.html'
48
- - a site: 'site:伊蕾娜手账研究站'
49
- - a folder: just its path, '海报' or '海报/初稿'
50
-
51
- Use it right after you produce something that relates to earlier work:
52
- - made v2 of a poster → derives-from, from the new one to the old one
53
- - produced two variants to compare → contrast between them
54
- - storyboard panels in order → flow, each to the next
55
- - used a reference image in a deck → ref, from the deck to the image
56
-
57
- Do NOT use it for "these are all in the same folder" — that is what the
58
- folder already says. Only record relationships that are not obvious from
59
- where the files live.`,
60
- {
61
- type: z.enum(BINDING_TYPE_IDS).describe('Relationship kind (see list above)'),
62
- from: z.string().min(1).max(300).describe('Source canvas id — see forms above'),
63
- to: z.string().min(1).max(300).describe('Target canvas id — see forms above'),
64
- label: z.string().max(60).optional()
65
- .describe('Optional short words on the line. Omit to use the default for the type.'),
66
- material: z.enum(BINDING_MATERIALS).optional()
67
- .describe('How the line is drawn (orthogonal to type): ink = quiet archive line (default); pencil = hand-drawn; yarn = detective red string with pins, for hypotheses/evidence while reasoning. The whole canvas is a detective board — use yarn when the relation is still being argued, ink when it is settled.'),
68
- },
69
- async ({ type, from, to, label, material }) => {
70
- if (!projectId) {
71
- return { content: [{ type: 'text', text: 'No project bound; cannot draw relationships.' }], isError: true };
72
- }
73
- if (from === to) {
74
- return {
75
- content: [{ type: 'text', text: 'from and to are the same thing — a relationship needs two ends.' }],
76
- isError: true,
77
- };
78
- }
79
- const id = nextId();
80
- // by:'agent' 不只是记录出处 —— 用户画的线 agent 不该擅自删,反过来也一样
81
- const binding = { type, from, to, by: 'agent', ...(label ? { label } : {}), ...(material && material !== 'ink' ? { material } : {}) };
82
- const board = await patchBoard(projectId, { bindings: { [id]: binding } });
83
-
84
- // 服务端会丢掉非法的线(未知 type / 自环)。**丢了要说**,否则 agent 以为
85
- // 画上了,用户看不到,两边都不知道发生了什么。
86
- if (!board.bindings?.[id]) {
87
- return {
88
- content: [{ type: 'text', text: `Relationship rejected by the board (bad type or endpoints): ${type} ${from} -> ${to}` }],
89
- isError: true,
90
- };
91
- }
92
-
93
- // 广播:前端整份重拉。**sessionId 必须显式给 null** —— ctx 会把自己的
94
- // sessionId 补进事件,那样只有当前会话的连接收得到,别的 tab 看不见。
95
- try {
96
- ctx?.emit?.({
97
- type: 'board.updated',
98
- sessionId: null,
99
- summary: `已画一条「${BINDING_TYPES[type].label}」关系`,
100
- });
101
- } catch { /* emit fail-safe:广播失败不该让工具报错,线已经落盘了 */ }
102
-
103
- const arrow = BINDING_TYPES[type].directed ? '->' : '<->';
104
- return {
105
- content: [{
106
- type: 'text',
107
- text: `Drew ${type} (${BINDING_TYPES[type].label}): ${from} ${arrow} ${to}`,
108
- }],
109
- };
110
- },
111
- );
112
- }
@@ -1,337 +0,0 @@
1
- /**
2
- * mcp/tools/sketch-on-board.js —— sketch_on_board / finish_sketch(2026-08-23 黑板)
3
- *
4
- * 让 agent 把画布当黑板:一次调用落一整张示意图(节点 + 形状 + 线),而不是
5
- * 像 create_on_board 那样一条条写。设计要点(跟用户商定的形状):
6
- * - **没有几何容器**:一张图 = 一批带同一 #tag 的普通物件和线。read_board 按
7
- * 连通分量 + tag 分段读,用户可以整组选/整组擦,入座算法照旧绕着走
8
- * - **两阶段**:落下来的默认是 staging(半透明,"正在画"),finish_sketch 或
9
- * 回合结束自动落定;落定只清 staging 位,tag 留着当逻辑分组
10
- * - **结构不是像素**:agent 给模板 + 网格坐标(1 格 = 24px),服务端算像素与落位
11
- * - **形状是涂鸦**:rect/ellipse/arrow… 在服务端生成带手绘抖动的路径,落成
12
- * 普通 scribble 对象,前端零改动;自由路径(path)也收,同一白名单
13
- * - 线的材质缺省 pencil(手绘)—— 草图上的线是人顺手拉的;要丝线/墨线自己说
14
- *
15
- * 护栏:每回合 3 张图;每张 ≤ 40 节点 / 30 形状 / 60 线。
16
- */
17
-
18
- import { tool } from '@anthropic-ai/claude-agent-sdk';
19
- import { z } from 'zod';
20
- import { readBoard, patchBoard, commitStaging, removeByTag, TEXT_FONTS } from '../../../projects/board-store.js';
21
- import { estimateSizeOn } from '../../../lib/board-kind-sizes.js';
22
- import { layerOf, normalizeCanvasId } from '../../../lib/canvas-id.js';
23
- import { BINDING_TYPE_IDS, BINDING_MATERIALS } from '../../../lib/binding-types.js';
24
- import { UNIT, SKETCH_FIT, SKETCH_MAX, textBox, shapePath, layoutNodes, bboxOf, findSpot, fitFor } from '../../../lib/sketch-layout.js';
25
- import { getViewpoint } from '../../../projects/viewpoint-store.js';
26
-
27
- const MAX_NODES = 40;
28
- const MAX_SHAPES = 30;
29
- const MAX_EDGES = 60;
30
-
31
- let seq = 0;
32
- const stamp = () => `${Date.now().toString(36)}${(seq++ % 1000).toString(36)}`;
33
- const COLORS = ['ink', 'red', 'pencil', 'brass'];
34
-
35
- const LOCAL_ID = z.string().regex(/^[A-Za-z0-9_-]{1,24}$/, 'local id: letters/digits/_/-');
36
- const GRID_PT = z.object({ x: z.number().min(-400).max(400), y: z.number().min(-400).max(400) });
37
-
38
- export function makeSketchOnBoardTool({ projectId, ctx }) {
39
- const turnStamp = { turn: -1, count: 0 }; // 只记数(返回里不再报余额)
40
- return tool(
41
- 'sketch_on_board',
42
- `Draw a whole sketch on the canvas in ONE call — notes, shapes and lines, laid out
43
- together: a comparison table, a flow, a mind map, a detective board linking real
44
- artifacts. The canvas is the blackboard; use it when thinking out loud with the user
45
- would be clearer as a picture than as prose.
46
-
47
- How it works
48
- - You describe STRUCTURE; the server does pixels. Pick a layout template (column /
49
- row / grid / mindmap) or place nodes yourself on a grid (1 cell = ${UNIT}px, layout
50
- 'free', at:{x,y}). Whole sketch lands beside \`near\` (a canvas id from read_board)
51
- or under the desktop's current content.
52
- - nodes: plain handwriting or format:'md' (Markdown + KaTeX $…$ + \`\`\`mermaid fences).
53
- Use md for lists/tables/formulas; mermaid only for dense formal diagrams
54
- (sequence/state) — anything that should connect to real artifacts must be nodes+edges.
55
- - shapes: rect / ellipse / circle / line / arrow / underline (hand-drawn look is
56
- applied for you) or path (raw SVG M/L/Q in local px) — all in grid units.
57
- - edges: between local node ids and/or real canvas ids. type = the relation
58
- vocabulary (link/annotates/flow/contrast/derives-from/ref); material = ink (quiet
59
- archive line) / pencil (hand-drawn, default here) / yarn (detective red string + pins
60
- for hypotheses and evidence).
61
- - Everything carries one #tag (a group): read_board {tag} reads just it, the user can
62
- select/erase it as a whole, finish_sketch commits or erases it.
63
- - Items land as STAGING (half-transparent = you are still drawing). Call finish_sketch
64
- when done, or they commit automatically when the turn ends. Look at the result with
65
- look_at_board before you call it done — agent scribbles only make sense with eyes.
66
- - Readability rule: the user reads the board at 80–100% zoom. Body text stays md/lg
67
- (sm only for captions ≤40 chars); one sketch ≤ ${SKETCH_FIT.w}x${SKETCH_FIT.h} world px (one screen at 80%),
68
- hard limit ${SKETCH_MAX.w}x${SKETCH_MAX.h} — split into two tagged sketches instead of one huge one.
69
- - To change an existing sketch use edit_sketch (move/retext/add/remove by id) — do NOT
70
- erase and redraw the whole thing for a small change.
71
- Per sketch: ≤${MAX_NODES} nodes, ${MAX_SHAPES} shapes, ${MAX_EDGES} edges (split big ones).`,
72
- {
73
- title: z.string().max(60).optional().describe('Optional heading written at the top of the sketch'),
74
- tag: z.string().regex(/^[\w一-鿿぀-ヿ-]{1,40}$/).optional()
75
- .describe('Group tag (letters/digits/_/-/CJK, ≤40). Default: auto "sk-<stamp>"'),
76
- near: z.string().max(300).optional().describe('Canvas id to place the sketch beside (right side; falls back to below)'),
77
- layout: z.enum(['auto', 'free', 'column', 'row', 'grid', 'mindmap']).optional()
78
- .describe('auto = free if any node has at, else column (≤4) / grid'),
79
- cols: z.number().int().min(1).max(8).optional().describe('grid columns'),
80
- staging: z.boolean().optional().describe('Default true. false = land committed (solid) immediately'),
81
- nodes: z.array(z.object({
82
- id: LOCAL_ID.describe('Local id to reference from edges/shapes'),
83
- text: z.string().min(1).max(4000),
84
- format: z.enum(['plain', 'md']).optional(),
85
- size: z.enum(['sm', 'md', 'lg', 'xl']).optional(),
86
- font: z.enum(['pen', 'kai', 'sans', 'serif', 'mono']).optional(),
87
- color: z.enum(['ink', 'red', 'pencil', 'brass']).optional(),
88
- at: GRID_PT.optional().describe('Grid position (layout free); top-left of the node'),
89
- w: z.number().min(3).max(22).optional().describe('Width in grid units (md nodes; default by content; ≤22 = 528px — paragraphs grow down, not wide)'),
90
- })).max(MAX_NODES).optional(),
91
- shapes: z.array(z.object({
92
- id: LOCAL_ID.optional(),
93
- kind: z.enum(['rect', 'ellipse', 'circle', 'line', 'arrow', 'underline', 'path']),
94
- at: GRID_PT.optional().describe('Grid position (top-left for rect/ellipse; start point for line/arrow). Or use around:'),
95
- around: LOCAL_ID.optional().describe('rect/ellipse/circle/underline: wrap this node (pad applied) instead of at/w/h'),
96
- w: z.number().min(0).max(200).optional().describe('grid units'),
97
- h: z.number().min(0).max(200).optional().describe('grid units'),
98
- to: GRID_PT.optional().describe('line/arrow end point (grid)'),
99
- toNode: LOCAL_ID.optional().describe('line/arrow: aim at this node\'s center instead of to'),
100
- d: z.string().max(8000).optional().describe('path kind: SVG path (M/L/Q/Z only) in local px'),
101
- color: z.enum(['ink', 'red', 'pencil', 'brass']).optional(),
102
- width: z.number().min(1).max(12).optional(),
103
- })).max(MAX_SHAPES).optional(),
104
- edges: z.array(z.object({
105
- from: z.string().min(1).max(300).describe('local node id or canvas id'),
106
- to: z.string().min(1).max(300).describe('local node id or canvas id'),
107
- type: z.enum(BINDING_TYPE_IDS).optional().describe('default link'),
108
- material: z.enum(BINDING_MATERIALS).optional().describe('default pencil'),
109
- label: z.string().max(60).optional(),
110
- })).max(MAX_EDGES).optional(),
111
- },
112
- async (args) => {
113
- if (!projectId) return { content: [{ type: 'text', text: 'No project bound.' }], isError: true };
114
- const err = (t) => ({ content: [{ type: 'text', text: t }], isError: true });
115
- // 回合闸 08-23 用户拍板先不设(「别设置限制吧先」):只记数不拦
116
- const turn = ctx?.runId ?? -1;
117
- if (turnStamp.turn !== turn) { turnStamp.turn = turn; turnStamp.count = 0; }
118
-
119
- const nodesIn = args.nodes || [];
120
- const shapesIn = args.shapes || [];
121
- const edgesIn = args.edges || [];
122
- if (!nodesIn.length && !shapesIn.length) return err('空图不落板:至少给一个节点或形状。');
123
- const tag = args.tag || `sk-${stamp()}`;
124
- const staging = args.staging !== false;
125
-
126
- // ── 节点身位 ──
127
- const localIds = new Set();
128
- const nodes = [];
129
- if (args.title) {
130
- nodes.push({ key: '__title', text: `## ${args.title}`, format: 'md', size: 'md', font: 'kai', color: 'ink', at: null, w: null });
131
- }
132
- for (const n of nodesIn) {
133
- if (localIds.has(n.id)) return err(`节点 id 重复:${n.id}`);
134
- localIds.add(n.id);
135
- // 可读性规范:正文不低于 md(0.8 倍下 12.8 屏幕像素是底线);sm 只给 ≤40 字的题注
136
- const size = (n.size === 'sm' && n.text.length > 40) ? 'md' : (n.size || 'md');
137
- nodes.push({ key: n.id, text: n.text, format: n.format || 'plain', size, font: n.font || 'pen', color: n.color || 'ink', at: n.at || null, w: n.w || null });
138
- }
139
- for (const n of nodes) {
140
- const box = textBox(n.text, n.size, { md: n.format === 'md', wUnits: n.w });
141
- n.w = box.w; n.h = box.h;
142
- }
143
- // 标题永远在最上面:free 模式给它 (0,-2),模板模式它就是第一个
144
- const titleNode = nodes.find(n => n.key === '__title');
145
- let tpl = args.layout || 'auto';
146
- if (tpl === 'auto') tpl = nodes.some(n => n.at) ? 'free' : (nodes.length - (titleNode ? 1 : 0) <= 4 ? 'column' : 'grid');
147
- const layoutInput = titleNode && tpl === 'mindmap' ? nodes.filter(n => n !== titleNode) : nodes;
148
- const pos = layoutNodes(layoutInput, { template: tpl, cols: args.cols });
149
- if (titleNode && !pos.has('__title')) {
150
- const bb = bboxOf([...pos.entries()].map(([k, p]) => ({ x: p.x, y: p.y, ...nodes.find(n => n.key === k) })));
151
- pos.set('__title', { x: bb.x, y: bb.y - titleNode.h - 12 });
152
- } else if (titleNode && tpl === 'free' && !titleNode.at) {
153
- const bb = bboxOf([...pos.entries()].filter(([k]) => k !== '__title').map(([k, p]) => ({ x: p.x, y: p.y, ...nodes.find(n => n.key === k) })));
154
- pos.set('__title', { x: bb.x, y: bb.y - titleNode.h - 12 });
155
- }
156
- const rectOfNode = (key) => { const n = nodes.find(x => x.key === key); const p = pos.get(key); return n && p ? { x: p.x, y: p.y, w: n.w, h: n.h } : null; };
157
-
158
- // ── 形状(局部像素)──
159
- const shapes = [];
160
- for (let i = 0; i < shapesIn.length; i += 1) {
161
- const s = shapesIn[i];
162
- const sid = s.id || `s${i + 1}`;
163
- if (localIds.has(sid) || shapes.some(x => x.key === sid)) return err(`形状 id「${sid}」跟节点/别的形状重名(形状缺省叫 s1,s2…,节点别用这类名)`);
164
- const seed = `${tag}:${sid}`;
165
- const color = COLORS.includes(s.color) ? s.color : (s.kind === 'arrow' || s.kind === 'line' ? 'ink2' : 'ink');
166
- const width = s.width || 2;
167
- let rect; let d;
168
- if (s.kind === 'path') {
169
- if (!s.d || !/^[\dMLQCZ ,.\-eE]+$/.test(s.d)) return err(`形状 ${sid}:path 只收 M/L/Q/Z 与数字`);
170
- // 自由路径:算它的包围盒,平移到 (at 或 0,0)
171
- const nums = s.d.match(/-?\d*\.?\d+(?:[eE][-+]?\d+)?/g)?.map(Number) || [];
172
- const xs = nums.filter((_, k) => k % 2 === 0); const ys = nums.filter((_, k) => k % 2 === 1);
173
- const w = Math.max(4, Math.max(...xs) - Math.min(0, Math.min(...xs))); const h = Math.max(4, Math.max(...ys) - Math.min(0, Math.min(...ys)));
174
- rect = { x: (s.at?.x || 0) * UNIT, y: (s.at?.y || 0) * UNIT, w: w + 6, h: h + 6 };
175
- d = s.d;
176
- } else if (s.kind === 'line' || s.kind === 'arrow' || s.kind === 'underline') {
177
- let a; let b;
178
- if (s.kind === 'underline' && s.around) {
179
- const r = rectOfNode(s.around); if (!r) return err(`形状 ${sid}:around 指向不存在的节点 ${s.around}`);
180
- a = { x: r.x + 2, y: r.y + r.h - 2 }; b = { x: r.x + r.w - 2, y: r.y + r.h - 2 };
181
- } else {
182
- if (!s.at) return err(`形状 ${sid}:${s.kind} 要 at 起点`);
183
- a = { x: s.at.x * UNIT, y: s.at.y * UNIT };
184
- if (s.toNode) {
185
- const r = rectOfNode(s.toNode); if (!r) return err(`形状 ${sid}:toNode 指向不存在的节点 ${s.toNode}`);
186
- b = { x: r.x + r.w / 2, y: r.y + r.h / 2 };
187
- } else if (s.to) b = { x: s.to.x * UNIT, y: s.to.y * UNIT };
188
- else if (s.kind === 'underline') b = { x: a.x + (s.w || 4) * UNIT, y: a.y };
189
- else return err(`形状 ${sid}:${s.kind} 要 to 或 toNode`);
190
- }
191
- const sp = shapePath(s.kind, { to: { x: b.x - a.x, y: b.y - a.y } }, seed);
192
- rect = { x: Math.min(a.x, b.x) - 6, y: Math.min(a.y, b.y) - 6, w: sp.w, h: sp.h };
193
- d = sp.d;
194
- } else {
195
- let box;
196
- if (s.around) {
197
- const r = rectOfNode(s.around); if (!r) return err(`形状 ${sid}:around 指向不存在的节点 ${s.around}`);
198
- const pad = s.kind === 'rect' ? 8 : 14;
199
- box = { x: r.x - pad, y: r.y - pad, w: r.w + pad * 2, h: r.h + pad * 2 };
200
- if (s.kind === 'circle') { const dmax = Math.max(box.w, box.h); box = { x: box.x + (box.w - dmax) / 2, y: box.y + (box.h - dmax) / 2, w: dmax, h: dmax }; }
201
- } else {
202
- if (!s.at || !s.w) return err(`形状 ${sid}:${s.kind} 要 at + w(+h)或 around`);
203
- box = { x: s.at.x * UNIT, y: s.at.y * UNIT, w: s.w * UNIT, h: (s.h || s.w) * UNIT };
204
- }
205
- const sp = shapePath(s.kind, { w: box.w, h: box.h }, seed);
206
- rect = { x: box.x - 6, y: box.y - 6, w: sp.w, h: sp.h };
207
- d = sp.d;
208
- }
209
- shapes.push({ key: sid, rect, d, color: COLORS.includes(color) ? color : 'ink', width });
210
- }
211
-
212
- // ── 先分配 id、解析线 ──
213
- // 线要先于落位算:一条连到真实产物卡的线会改变**主角判断**(手画线 +0.5 焦点分),
214
- // 那张卡可能因此放大 1.5 倍 —— 落位必须按"线画上去之后"的尺寸避让
215
- // (08-23 首跑真踩:草图连了一条丝线到纸本站,纸本当场成主角,身体盖住半张图)。
216
- const board = await readBoard(projectId);
217
- const known = new Set(Object.keys(board.zones || {}));
218
- const idOf = new Map(); // local → canvas id
219
- for (const n of nodes) idOf.set(n.key, `text:a${stamp()}`);
220
- for (const sh of shapes) idOf.set(sh.key, `scribble:a${stamp()}`);
221
- const resolveEnd = (raw) => {
222
- if (idOf.has(raw)) return idOf.get(raw);
223
- const cid = normalizeCanvasId(raw);
224
- if (cid && board.objects?.[cid]) return cid;
225
- if (cid && board.zones?.[cid] !== undefined) return cid;
226
- return null;
227
- };
228
- const bindings = {};
229
- const badEdges = [];
230
- for (const e of edgesIn) {
231
- const from = resolveEnd(e.from); const to = resolveEnd(e.to);
232
- if (!from || !to || from === to) { badEdges.push(`${e.from}→${e.to}`); continue; }
233
- bindings[`b:a${stamp()}`] = {
234
- type: e.type || 'link', from, to, by: 'agent', material: e.material || 'pencil', tag,
235
- ...(staging ? { staging: true } : {}), ...(e.label ? { label: e.label } : {}),
236
- };
237
- }
238
- // 落位用"线画上之后"的板来估尺寸(主角可能换人)
239
- const after = { ...board, bindings: { ...(board.bindings || {}), ...bindings } };
240
-
241
- // ── 宏观落位 ──
242
- const local = bboxOf([
243
- ...nodes.map(n => ({ ...pos.get(n.key), w: n.w, h: n.h })),
244
- ...shapes.map(sh => sh.rect),
245
- ]);
246
- let zone = '';
247
- let anchor = null;
248
- if (args.near) {
249
- const nid = normalizeCanvasId(args.near);
250
- const e = nid ? board.objects?.[nid] : null;
251
- if (!e || !Number.isFinite(e.x)) return err(`锚点 ${args.near} 还没有座位(read_board 里看不到就锚不上)。`);
252
- zone = layerOf(nid, e, known);
253
- anchor = { x: e.x, y: e.y, ...estimateSizeOn(after, nid, e) };
254
- }
255
- const obstacles = [];
256
- let contentBottom = 0;
257
- for (const [id, e] of Object.entries(board.objects || {})) {
258
- if (!Number.isFinite(e?.x) || layerOf(id, e, known) !== zone) continue;
259
- const r = { x: e.x, y: e.y, ...estimateSizeOn(after, id, e) };
260
- obstacles.push(r); contentBottom = Math.max(contentBottom, r.y + r.h);
261
- }
262
- if (!zone) for (const zz of Object.values(board.zones || {})) if (Number.isFinite(zz?.y)) contentBottom = Math.max(contentBottom, zz.y + 240);
263
- // 尺寸规范:硬上限直接拒(一张图说一件事),推荐上限以上给提醒
264
- if (local.w > SKETCH_MAX.w || local.h > SKETCH_MAX.h) {
265
- return err(`这张图太大了(${Math.round(local.w)}x${Math.round(local.h)} 世界像素,上限 ${SKETCH_MAX.w}x${SKETCH_MAX.h}):用户在 80%~100% 缩放下看不全。拆成两张(各自一个 tag,之间用线连),或减节点/缩 w。`);
266
- }
267
- // 用户视口(同一层才算;黑板是主窗口时画在他眼前)+ 按他的屏幕算"一屏"
268
- const vp = getViewpoint(projectId);
269
- const vpRect = (vp && (vp.layer || '') === zone && vp.camera) ? vp.camera : null;
270
- const fit = fitFor(vp);
271
- const spot = findSpot({ w: local.w + 24, h: local.h + 24, near: anchor, obstacles, contentBottom, viewport: vpRect });
272
- const ox = spot.x - local.x + 12; const oy = spot.y - local.y + 12;
273
-
274
- // ── 落盘 ──
275
- const objects = {};
276
- const common = { z: 1, zone, by: 'agent', tag, ...(staging ? { staging: true } : {}) };
277
- for (const n of nodes) {
278
- const p = pos.get(n.key);
279
- objects[idOf.get(n.key)] = {
280
- x: Math.round(p.x + ox), y: Math.round(p.y + oy), w: n.w, h: n.h, kind: 'text',
281
- data: { t: n.text, ...(n.format === 'md' ? { format: 'md' } : {}), font: TEXT_FONTS.includes(n.font) ? n.font : 'pen', size: n.size, color: n.color },
282
- ...common,
283
- };
284
- }
285
- for (const sh of shapes) {
286
- objects[idOf.get(sh.key)] = { x: Math.round(sh.rect.x + ox), y: Math.round(sh.rect.y + oy), w: Math.round(sh.rect.w), h: Math.round(sh.rect.h), kind: 'scribble', data: { d: sh.d, color: sh.color, width: sh.width }, ...common };
287
- }
288
- const saved = await patchBoard(projectId, { objects, bindings });
289
- const landed = Object.keys(objects).filter(id => saved.objects?.[id]).length;
290
- if (!landed) return err('草图被 board 拒了(内容或字段不合法)。');
291
- turnStamp.count += 1;
292
- const world = { x: Math.round(local.x + ox), y: Math.round(local.y + oy), w: Math.round(local.w), h: Math.round(local.h) };
293
- try {
294
- ctx?.emit?.({ type: 'board.updated', sessionId: null, summary: `画了一张草图 #${tag}` });
295
- // 镜头提示(前端只在黑板模式跟随;不是劫持,是"黑板是主窗口"的约定)
296
- ctx?.emit?.({ type: 'board.focus', sessionId: null, tag, rect: world, layer: zone });
297
- } catch { /* fail-soft */ }
298
- const lines = [
299
- `Sketch #${tag} landed${staging ? ' as STAGING (半透明)' : ''}: ${Object.keys(objects).length - shapes.length} nodes, ${shapes.length} shapes, ${Object.keys(bindings).length} lines; layout ${tpl}; at world (${world.x},${world.y}) ${world.w}x${world.h}${anchor ? ` (${spot.side} of ${args.near})` : ' (below current content)'}.`,
300
- `ids: ${[...idOf].map(([k, v]) => `${k}=${v}`).join(', ')}`,
301
- ];
302
- if (badEdges.length) lines.push(`Skipped ${badEdges.length} edge(s) with unknown endpoints: ${badEdges.slice(0, 6).join(', ')}`);
303
- if (world.w > fit.w || world.h > fit.h) lines.push(`⚠ Bigger than one screen at 80% zoom${fit.screen ? ` (user's screen ${fit.screen.w}x${fit.screen.h}px → ${fit.w}x${fit.h} world px fits)` : ` (${fit.w}x${fit.h} fits)`} — the user will have to pan. Split into two tagged sketches (side by side or stacked) next time.`);
304
- if (vp?.zoom && vp.zoom < 0.8) lines.push(`User's zoom is ${vp.zoom} (<0.8): text this size is small on their screen. Keep nodes md/lg and say in one line that there is a sketch on the board.`);
305
- lines.push(spot.side === 'viewport' ? 'Placed inside the user\'s current viewport.' : `Placed ${spot.side === 'bottom' ? 'below current content' : spot.side + ' of the anchor'}${vpRect ? ' (no room in the user\'s viewport)' : ''}.`);
306
- lines.push(staging
307
- ? 'Next: look_at_board {tag} to check it, then finish_sketch {tag} (or it commits at turn end). Mention the sketch to the user in one line.'
308
- : 'Next: look_at_board {tag} to check it.');
309
- return { content: [{ type: 'text', text: lines.join('\n') }] };
310
- },
311
- );
312
- }
313
-
314
- export function makeFinishSketchTool({ projectId, ctx }) {
315
- return tool(
316
- 'finish_sketch',
317
- `Commit a staging sketch (make it solid) — or erase it. Pass the #tag from
318
- sketch_on_board; omit tag to commit everything still staging. erase:true deletes the
319
- whole group (its notes/shapes/lines; real artifact cards only lose the tag).`,
320
- {
321
- tag: z.string().max(40).optional(),
322
- erase: z.boolean().optional(),
323
- },
324
- async ({ tag, erase }) => {
325
- if (!projectId) return { content: [{ type: 'text', text: 'No project bound.' }], isError: true };
326
- if (erase) {
327
- if (!tag) return { content: [{ type: 'text', text: 'erase needs a tag.' }], isError: true };
328
- const { removed } = await removeByTag(projectId, tag);
329
- try { ctx?.emit?.({ type: 'board.updated', sessionId: null, summary: `擦掉了草图 #${tag}` }); } catch { /* */ }
330
- return { content: [{ type: 'text', text: `Erased #${tag}: ${removed} item(s)/line(s) removed.` }] };
331
- }
332
- const { committed } = await commitStaging(projectId, { tag: tag || null });
333
- if (committed) { try { ctx?.emit?.({ type: 'board.updated', sessionId: null, summary: `草图落定${tag ? ` #${tag}` : ''}` }); } catch { /* */ } }
334
- return { content: [{ type: 'text', text: committed ? `Committed ${committed} item(s)${tag ? ` of #${tag}` : ''}.` : 'Nothing was staging.' }] };
335
- },
336
- );
337
- }