@xiaobuyu/nodesign 0.0.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.
- package/LICENSE +661 -0
- package/README.md +140 -0
- package/bin/nodesign.js +176 -0
- package/package.json +104 -0
- package/server/api/README.md +45 -0
- package/server/api/_guard.js +75 -0
- package/server/api/admin.js +187 -0
- package/server/api/assets/docx-page.js +103 -0
- package/server/api/assets/helpers.js +22 -0
- package/server/api/assets/notes.js +144 -0
- package/server/api/assets.js +896 -0
- package/server/api/board.js +57 -0
- package/server/api/browse.js +138 -0
- package/server/api/canvas.js +444 -0
- package/server/api/chatai.js +324 -0
- package/server/api/exports/build-standalone.js +980 -0
- package/server/api/exports/cards.js +118 -0
- package/server/api/exports/docx-pdf.js +46 -0
- package/server/api/exports/export-page.js +142 -0
- package/server/api/exports/handoff.js +147 -0
- package/server/api/exports.js +690 -0
- package/server/api/instruction.js +75 -0
- package/server/api/local.js +115 -0
- package/server/api/me.js +116 -0
- package/server/api/memory.js +185 -0
- package/server/api/pending-changes.js +366 -0
- package/server/api/plugins.js +164 -0
- package/server/api/projects.js +220 -0
- package/server/api/publish.js +64 -0
- package/server/api/recent.js +73 -0
- package/server/api/sessions.js +589 -0
- package/server/api/skills.js +77 -0
- package/server/api/standalone-fit.js +168 -0
- package/server/api/turn-compose.js +180 -0
- package/server/api/turn-inflight.js +44 -0
- package/server/api/turn.js +669 -0
- package/server/auth/README.md +17 -0
- package/server/auth/middleware.js +138 -0
- package/server/auth/origin-guard.js +71 -0
- package/server/auth/session.js +108 -0
- package/server/auth/tier.js +113 -0
- package/server/auth/users-store.js +348 -0
- package/server/edit/README.md +29 -0
- package/server/engine/README.md +113 -0
- package/server/engine/agent/agent-shared.js +550 -0
- package/server/engine/agent/auto-mode-default-hard-deny.txt +4 -0
- package/server/engine/agent/auto-mode-rules.js +78 -0
- package/server/engine/agent/context.js +418 -0
- package/server/engine/agent/events.js +464 -0
- package/server/engine/agent/hooks/canvas-validate.js +199 -0
- package/server/engine/agent/hooks/failure.js +120 -0
- package/server/engine/agent/hooks/file-events.js +75 -0
- package/server/engine/agent/hooks/lifecycle.js +233 -0
- package/server/engine/agent/hooks/post-canvas-focus.js +80 -0
- package/server/engine/agent/hooks/post-guidance.js +206 -0
- package/server/engine/agent/hooks/post-subagent-report.js +104 -0
- package/server/engine/agent/hooks/post-trim.js +58 -0
- package/server/engine/agent/hooks/pre-board-neighborhood.js +34 -0
- package/server/engine/agent/hooks/pre-defaults.js +84 -0
- package/server/engine/agent/hooks/pre-injectors.js +277 -0
- package/server/engine/agent/hooks/pre-performance-log-guard.js +78 -0
- package/server/engine/agent/hooks/pre-starter-files.js +61 -0
- package/server/engine/agent/hooks/pre-workspace-scope-guard.js +78 -0
- package/server/engine/agent/hooks/site-validate.js +94 -0
- package/server/engine/agent/hooks/tool-prompts.js +31 -0
- package/server/engine/agent/hooks/turn-state-memory.js +56 -0
- package/server/engine/agent/hooks/user-prompt-submit.js +215 -0
- package/server/engine/agent/hooks.js +354 -0
- package/server/engine/agent/init-contract.js +69 -0
- package/server/engine/agent/isolation.js +159 -0
- package/server/engine/agent/model-context.js +359 -0
- package/server/engine/agent/model-table.js +292 -0
- package/server/engine/agent/plugin-loader.js +266 -0
- package/server/engine/agent/prompts/nodesign-prelude.md +336 -0
- package/server/engine/agent/prompts/tools/ask-user-question-protocol.md +71 -0
- package/server/engine/agent/prompts/tools/direct-edit-protocol.md +98 -0
- package/server/engine/agent/prompts/tools/generate-image-cookbook.gemini-gateway.md +583 -0
- package/server/engine/agent/prompts/tools/generate-image-cookbook.md +483 -0
- package/server/engine/agent/prompts/tools/hybrid-reference.md +100 -0
- package/server/engine/agent/prompts/tools/paint-still-cookbook.md +270 -0
- package/server/engine/agent/prompts/tools/roll-film-cookbook.md +70 -0
- package/server/engine/agent/prompts/tools/site-reference.md +106 -0
- package/server/engine/agent/prompts/tools/tweaks-syntax.md +125 -0
- package/server/engine/agent/prompts/tools/vision-checker-dispatch.md +48 -0
- package/server/engine/agent/session-loop.js +1024 -0
- package/server/engine/agent/session-model.js +164 -0
- package/server/engine/agent/skill.js +204 -0
- package/server/engine/agent/system-prompts.js +86 -0
- package/server/engine/agent/task-events.js +78 -0
- package/server/engine/agents/ds-extractor.md +132 -0
- package/server/engine/agents/explorer.md +190 -0
- package/server/engine/agents/index.js +230 -0
- package/server/engine/agents/schemas/design-system.json +156 -0
- package/server/engine/agents/schemas/tweak-schema.json +113 -0
- package/server/engine/agents/tweak-proposer.md +127 -0
- package/server/engine/agents/vision-checker.md +254 -0
- package/server/engine/browse/capture.js +422 -0
- package/server/engine/browse/card.js +137 -0
- package/server/engine/browse/handover.js +59 -0
- package/server/engine/browse/page-digest.js +119 -0
- package/server/engine/browse/refs.js +196 -0
- package/server/engine/browse/registry.js +307 -0
- package/server/engine/browse/screencast.js +170 -0
- package/server/engine/browse/state.js +121 -0
- package/server/engine/chatai/chat-log.js +79 -0
- package/server/engine/chatai/index.js +193 -0
- package/server/engine/chatai/openai-compat.js +152 -0
- package/server/engine/chatai/orchestrate.js +309 -0
- package/server/engine/chatai/perform.js +40 -0
- package/server/engine/chatai/summarize.js +79 -0
- package/server/engine/mcp/capability-gate.js +52 -0
- package/server/engine/mcp/index.js +339 -0
- package/server/engine/mcp/param-sanitizer.js +142 -0
- package/server/engine/mcp/tools/arrange-on-board.js +124 -0
- package/server/engine/mcp/tools/artifact-session.js +278 -0
- package/server/engine/mcp/tools/browse-computer.js +421 -0
- package/server/engine/mcp/tools/browse-find-batch.js +183 -0
- package/server/engine/mcp/tools/browse-screenshot.js +157 -0
- package/server/engine/mcp/tools/browse.js +480 -0
- package/server/engine/mcp/tools/build-docx.js +101 -0
- package/server/engine/mcp/tools/clear-pending-changes.js +99 -0
- package/server/engine/mcp/tools/create-on-board.js +155 -0
- package/server/engine/mcp/tools/crystallize-skill.js +168 -0
- package/server/engine/mcp/tools/deliver-files.js +0 -0
- package/server/engine/mcp/tools/explain-style.js +237 -0
- package/server/engine/mcp/tools/export-handoff.js +133 -0
- package/server/engine/mcp/tools/expose-tweaks.js +149 -0
- package/server/engine/mcp/tools/generate-image.js +842 -0
- package/server/engine/mcp/tools/get-computed-styles.js +164 -0
- package/server/engine/mcp/tools/get-pending-changes.js +205 -0
- package/server/engine/mcp/tools/h3box-ssh.js +84 -0
- package/server/engine/mcp/tools/helpers/acquire-page.js +82 -0
- package/server/engine/mcp/tools/helpers/motion-lab.js +554 -0
- package/server/engine/mcp/tools/helpers/motion-scroll.js +112 -0
- package/server/engine/mcp/tools/helpers/perception-page.js +215 -0
- package/server/engine/mcp/tools/helpers/reference-download.js +103 -0
- package/server/engine/mcp/tools/helpers/rembg-bridge.py +80 -0
- package/server/engine/mcp/tools/helpers/rembg.js +273 -0
- package/server/engine/mcp/tools/helpers/shot-pipeline.js +280 -0
- package/server/engine/mcp/tools/highlight.js +68 -0
- package/server/engine/mcp/tools/list-pages.js +222 -0
- package/server/engine/mcp/tools/lookup-tags.js +59 -0
- package/server/engine/mcp/tools/navigate-to-page.js +60 -0
- package/server/engine/mcp/tools/organize-board.js +64 -0
- package/server/engine/mcp/tools/paint-still.js +434 -0
- package/server/engine/mcp/tools/pin-to-board.js +130 -0
- package/server/engine/mcp/tools/preview-deck.js +130 -0
- package/server/engine/mcp/tools/profile-scroll.js +305 -0
- package/server/engine/mcp/tools/publish-site.js +102 -0
- package/server/engine/mcp/tools/query-elements.js +195 -0
- package/server/engine/mcp/tools/read-board.js +103 -0
- package/server/engine/mcp/tools/read-document.js +93 -0
- package/server/engine/mcp/tools/read-page.js +264 -0
- package/server/engine/mcp/tools/read-tavern-json.js +143 -0
- package/server/engine/mcp/tools/record-decision.js +140 -0
- package/server/engine/mcp/tools/relate-on-board.js +110 -0
- package/server/engine/mcp/tools/remove-background.js +391 -0
- package/server/engine/mcp/tools/report-issue.js +115 -0
- package/server/engine/mcp/tools/roll-film.js +266 -0
- package/server/engine/mcp/tools/screenshot-docx.js +138 -0
- package/server/engine/mcp/tools/screenshot-url.js +195 -0
- package/server/engine/mcp/tools/screenshot.js +583 -0
- package/server/engine/mcp/tools/tier-gate.js +96 -0
- package/server/engine/mcp/tools/trace-motion.js +215 -0
- package/server/engine/mcp/tools/web-search.js +548 -0
- package/server/engine/motion/inventory.js +349 -0
- package/server/engine/perception/session.js +235 -0
- package/server/engine/plugins/nodesign/.claude-plugin/plugin.json +5 -0
- package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/SKILL.md +192 -0
- package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/canvas.template.html +667 -0
- package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/patterns/hybrid-grid.md +22 -0
- package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/patterns/image-led-cover.md +25 -0
- package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/patterns/portrait.md +23 -0
- package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/patterns/quote-backdrop.md +21 -0
- package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/patterns/section-divider.md +23 -0
- package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/patterns/text-led.md +21 -0
- package/server/engine/plugins/nodesign/skills/docx-craft/SKILL.md +162 -0
- package/server/engine/plugins/nodesign/skills/docx-craft/references/token-schema.md +407 -0
- package/server/engine/plugins/nodesign/skills/docx-craft//346/226/207/346/241/243.template.json +80 -0
- package/server/engine/plugins/nodesign/skills/rp-craft/SKILL.md +228 -0
- 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 +78 -0
- package/server/engine/plugins/nodesign/skills/rp-craft//346/274/224/345/207/272.template.js +268 -0
- package/server/engine/plugins/nodesign/skills/site-craft/SKILL.md +323 -0
- package/server/engine/plugins/nodesign/skills/site-craft/patterns/build-lane.md +134 -0
- package/server/engine/plugins/nodesign/skills/site-craft/patterns/cutout-collage.md +61 -0
- package/server/engine/plugins/nodesign/skills/site-craft/patterns/mock-app.md +163 -0
- package/server/engine/plugins/nodesign/skills/site-craft/patterns/page-transitions.md +86 -0
- package/server/engine/runs/active-runs.js +698 -0
- package/server/engine/runs/live-turn.js +252 -0
- package/server/engine/runs/store.js +364 -0
- package/server/engine/runs/turn-relay.js +217 -0
- package/server/engine/runtime/workspace.js +164 -0
- package/server/index.js +235 -0
- package/server/lib/artifact-file-path.js +80 -0
- package/server/lib/artifact-target.js +284 -0
- package/server/lib/asset-refs.js +239 -0
- package/server/lib/async-queue.js +104 -0
- package/server/lib/auto-relations.js +130 -0
- package/server/lib/binding-types.js +60 -0
- package/server/lib/board-kind-sizes.js +62 -0
- package/server/lib/board-relations.js +133 -0
- package/server/lib/browse-proxy.js +180 -0
- package/server/lib/canvas-id.js +36 -0
- package/server/lib/cover.js +227 -0
- package/server/lib/danbooru-tags.js +291 -0
- package/server/lib/doc-extract.js +156 -0
- package/server/lib/docx/build-from-source.js +260 -0
- package/server/lib/docx/build.js +490 -0
- package/server/lib/docx/dump-styles.js +287 -0
- package/server/lib/docx/fonts/nodesign-cjk.conf +164 -0
- package/server/lib/docx/merge-runs.js +129 -0
- package/server/lib/docx/numbering.js +218 -0
- package/server/lib/docx/order.js +152 -0
- package/server/lib/docx/rawzip.js +172 -0
- package/server/lib/docx/render.js +92 -0
- package/server/lib/docx/text-lint.js +225 -0
- package/server/lib/docx/tokens.js +335 -0
- package/server/lib/docx/units.js +29 -0
- package/server/lib/docx/xml.js +291 -0
- package/server/lib/docx-pages.js +187 -0
- package/server/lib/export-collect.js +289 -0
- package/server/lib/export-package.js +210 -0
- package/server/lib/html-srcset.js +145 -0
- package/server/lib/image-variant.js +460 -0
- package/server/lib/ingress/forward-openai-chat.js +305 -0
- package/server/lib/ingress/openai-chat.js +491 -0
- package/server/lib/ingress/session-notice.js +66 -0
- package/server/lib/ingress/session-routes.js +68 -0
- package/server/lib/ingress/slot-probe.js +130 -0
- package/server/lib/ingress/upstream-billing.js +52 -0
- package/server/lib/ingress/upstream-fail-streak.js +72 -0
- package/server/lib/ingress/upstream-truncation.js +48 -0
- package/server/lib/issues-store.js +182 -0
- package/server/lib/kinds/deck.js +72 -0
- package/server/lib/kinds/docx.js +283 -0
- package/server/lib/kinds/file-kinds.js +113 -0
- package/server/lib/kinds/index.js +202 -0
- package/server/lib/kinds/site.js +161 -0
- package/server/lib/model-ingress.js +543 -0
- package/server/lib/moderation.js +255 -0
- package/server/lib/notice-store.js +103 -0
- package/server/lib/plugin-install.js +104 -0
- package/server/lib/plugin-validator.js +721 -0
- package/server/lib/publish-store.js +115 -0
- package/server/lib/quick-summary.js +52 -0
- package/server/lib/quota.js +270 -0
- package/server/lib/rate-window.js +29 -0
- package/server/lib/reference-assets.js +92 -0
- package/server/lib/region-shot.js +135 -0
- package/server/lib/safe-path.js +73 -0
- package/server/lib/sdk-session.js +33 -0
- package/server/lib/showcase-store.js +92 -0
- package/server/lib/site-publish.js +465 -0
- package/server/lib/ssrf-guard.js +432 -0
- package/server/lib/task-scan.js +158 -0
- package/server/lib/tavern-json.js +154 -0
- package/server/lib/video-variant.js +237 -0
- package/server/lib/workspace-path.js +33 -0
- package/server/ops/fix-sdk-musl.mjs +40 -0
- package/server/ops/install-macos-fonts.sh +114 -0
- package/server/ops/macos-fonts.conf +336 -0
- package/server/ops/sandbox-shim/bwrap +57 -0
- package/server/projects/assets-summary.js +119 -0
- package/server/projects/auto-name.js +53 -0
- package/server/projects/board-store.js +640 -0
- package/server/projects/move-entry.js +103 -0
- package/server/projects/store.js +270 -0
- package/server/projects/ui-config.js +54 -0
- package/server/projects/workspace-templates.js +53 -0
- package/server/projects/workspace.js +1025 -0
- package/server/runtime/capabilities.js +153 -0
- package/server/runtime/local-config.js +177 -0
- package/server/runtime/local-env.js +88 -0
- package/server/runtime/platform.js +342 -0
- package/server/runtime/profile.js +72 -0
- package/server/services/rembg-launcher.js +313 -0
- package/server/services/rembg-service.py +334 -0
- package/server/shared/README.md +25 -0
- package/server/shared/deck.js +54 -0
- package/server/shared/time.js +49 -0
- package/server/style-pipeline/README.md +53 -0
- package/server/ws/broker.js +36 -0
- package/server/ws/browse-channel.js +177 -0
- package/server/ws/index.js +386 -0
- package/web/README.md +89 -0
- package/web/dist/assets/BrowserWindow-Dc7J7CYc.js +11 -0
- package/web/dist/assets/DeckWindow-4G0xX7P3.js +16 -0
- package/web/dist/assets/DocxWindow-BXQsoPkh.js +16 -0
- package/web/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/web/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/web/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/web/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/web/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/web/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/web/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/web/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/web/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/web/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/web/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/web/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/web/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/web/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/web/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/web/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/web/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/web/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/web/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/web/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/web/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/web/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/web/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/web/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/web/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/web/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/web/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/web/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/web/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/web/dist/assets/SiteWindow-D6eS-2gM.js +18 -0
- package/web/dist/assets/again-D8tfgKKO.webp +0 -0
- package/web/dist/assets/caveat-nd-CP6HlsNg.woff2 +0 -0
- package/web/dist/assets/clock-xJhvfYpS.webp +0 -0
- package/web/dist/assets/film-cut-BBKMwH7q.webp +0 -0
- package/web/dist/assets/film-still-BZ_DL9Tt.webp +0 -0
- package/web/dist/assets/index-C0KUf6Wd.css +1 -0
- package/web/dist/assets/index-Cbl3ATvp.js +2125 -0
- package/web/dist/assets/ink-desk-BRbxeDsR.webp +0 -0
- package/web/dist/assets/ink-night-Bz4BT3XH.webp +0 -0
- package/web/dist/assets/ink-portrait-C0DM4V8Q.webp +0 -0
- package/web/dist/assets/longcang-regular-C0uvTuKa.woff2 +0 -0
- package/web/dist/assets/lxgw-nd-bold-DbRfiTgo.woff2 +0 -0
- package/web/dist/assets/lxgw-nd-regular-CpMw9Ehg.woff2 +0 -0
- package/web/dist/assets/pending-edit-apply-DTjo2geW.js +31 -0
- package/web/dist/assets/question-8H4HSqxh.webp +0 -0
- package/web/dist/assets/reject-BaPJqElj.webp +0 -0
- package/web/dist/assets/rotate-cw-LMT3x1Zj.js +11 -0
- package/web/dist/assets/rp-portrait-CbrGpew2.webp +0 -0
- package/web/dist/assets/rp-street-C4jVKjxx.webp +0 -0
- package/web/dist/assets/square-dashed-mouse-pointer-CBoAkfhi.js +11 -0
- package/web/dist/assets/tangle-DIxHVNuT.webp +0 -0
- package/web/dist/assets/thisone-BylZKglV.webp +0 -0
- package/web/dist/assets/thumb-DO1wfK1I.webp +0 -0
- package/web/dist/index.html +18 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mcp/tools/read-tavern-json.js — read_tavern_json MCP tool(2026-08-15)
|
|
3
|
+
*
|
|
4
|
+
* 搬酒馆的东西进来时的读取口。**不要用 Read 去读这类文件**:真样本
|
|
5
|
+
* (Izumi 0814.json)464KB、210 条提示词,启用的只有 56 条 —— Read 一次就是
|
|
6
|
+
* 十几万 token 进上下文,换来的绝大部分是停用的备选条目。
|
|
7
|
+
*
|
|
8
|
+
* 两步走:先 `摘要` 看结构(每条只给名字/角色/字数/一句引子),挑好了再
|
|
9
|
+
* `取` 正文。转成 编排.yaml 和设定文件是 agent 自己的活,这个工具只读不写。
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import fs from 'node:fs/promises';
|
|
14
|
+
import { tool } from '@anthropic-ai/claude-agent-sdk';
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
import { detectKind, digest, fetchEntries } from '../../../lib/tavern-json.js';
|
|
17
|
+
|
|
18
|
+
const MAX_FETCH_CHARS = 24_000;
|
|
19
|
+
|
|
20
|
+
function 渲染摘要(d, 文件名) {
|
|
21
|
+
const L = [];
|
|
22
|
+
if (d.形态 === 'preset') {
|
|
23
|
+
L.push(`酒馆 Chat Completion 预设:${文件名}`);
|
|
24
|
+
L.push(`启用 ${d.启用.length} 条(其中有正文的 ${d.启用.filter(e => e.字数 > 0).length} 条,合计 ${d.合计字数} 字)· 停用 ${d.停用.length} 条`);
|
|
25
|
+
const p = d.参数;
|
|
26
|
+
L.push(`参数:temperature ${p.temperature} · top_p ${p.top_p} · 最大输出 ${p.最大输出} · reasoning_effort ${p.reasoning_effort ?? '未设'}`);
|
|
27
|
+
L.push('');
|
|
28
|
+
L.push('启用条目(顺序 = 进模型顺序):');
|
|
29
|
+
for (const [i, e] of d.启用.entries()) {
|
|
30
|
+
const 标 = e.占位 ? '〔占位·酒馆运行时填,搬过来丢掉〕'
|
|
31
|
+
: e.分隔 ? '〔分节标题·无正文〕' : `${e.字数}字`;
|
|
32
|
+
L.push(`${String(i + 1).padStart(2)}. ${e.名字} [${e.角色}] ${标}${e.深度 != null ? ` 深度${e.深度}` : ''}`);
|
|
33
|
+
if (e.引子) L.push(` ${e.引子}…`);
|
|
34
|
+
}
|
|
35
|
+
if (d.停用.length) {
|
|
36
|
+
L.push('');
|
|
37
|
+
L.push(`停用的 ${d.停用.length} 条(同一功能的备选,酒馆里只开一个;名字列表):`);
|
|
38
|
+
L.push(d.停用.map(e => e.名字).join(' / '));
|
|
39
|
+
}
|
|
40
|
+
L.push('');
|
|
41
|
+
L.push('占位条目(marker,酒馆运行时填角色卡/历史,搬过来一律丢):' + (d.占位条目.join(' / ') || '无'));
|
|
42
|
+
L.push('分节标题(0 字,只是把开关分组,也不用搬):' + (d.分隔条目.join(' / ') || '无'));
|
|
43
|
+
} else if (d.形态 === 'card') {
|
|
44
|
+
L.push(`酒馆角色卡:${d.名字}(${文件名})`);
|
|
45
|
+
for (const f of d.字段) L.push(`- ${f.字段} ${f.字数}字 ${f.引子}…`);
|
|
46
|
+
if (d.开场白备选) L.push(`- alternate_greetings ${d.开场白备选} 条备选开场白`);
|
|
47
|
+
if (d.世界书.length) {
|
|
48
|
+
L.push('');
|
|
49
|
+
L.push(`内嵌世界书 ${d.世界书.length} 条:`);
|
|
50
|
+
for (const e of d.世界书) {
|
|
51
|
+
L.push(`- ${e.名字} ${e.常驻 ? '常驻' : `触发[${e.触发.join(' ')}]`} ${e.字数}字${e.停用 ? ' (停用)' : ''}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
L.push(`酒馆世界书:${文件名},${d.条目.length} 条`);
|
|
56
|
+
for (const e of d.条目) {
|
|
57
|
+
L.push(`- ${e.名字} ${e.常驻 ? '常驻' : `触发[${e.触发.join(' ')}]`} ${e.字数}字${e.停用 ? ' (停用)' : ''}`);
|
|
58
|
+
if (e.引子) L.push(` ${e.引子}…`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
L.push('');
|
|
62
|
+
L.push('要正文就再调一次本工具:mode="fetch",entries=["名字或名字的一部分", …]。');
|
|
63
|
+
return L.join('\n');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function makeReadTavernJsonTool({ workspaceRoot, sharedRoot }) {
|
|
67
|
+
return tool(
|
|
68
|
+
'read_tavern_json',
|
|
69
|
+
`Read a SillyTavern (酒馆) export JSON — a chat-completion **preset**, a
|
|
70
|
+
**character card** (V2/V3), or a **lorebook** — without pouring the whole file
|
|
71
|
+
into your context.
|
|
72
|
+
|
|
73
|
+
Use this instead of Read for any 酒馆 JSON. A real preset in the wild is 460KB
|
|
74
|
+
with 210 prompt entries of which only 56 are enabled; Read would burn six digits
|
|
75
|
+
of tokens on disabled alternates.
|
|
76
|
+
|
|
77
|
+
Two steps:
|
|
78
|
+
1. mode "digest" (default) — structure only: every entry's name, role, size and a
|
|
79
|
+
60-char peek, plus which are enabled/disabled, plus sampler params.
|
|
80
|
+
2. mode "fetch" with entries[] — full text of just the ones you picked (name,
|
|
81
|
+
partial name, or id). Capped at ${MAX_FETCH_CHARS} chars per call.
|
|
82
|
+
|
|
83
|
+
This tool only reads. Turning a preset into 编排.yaml + 设定 files is your job —
|
|
84
|
+
you decide the grouping, and you drop what does not belong (markers are filled by
|
|
85
|
+
酒馆 at runtime and have no place here; platform-specific jailbreak sections are
|
|
86
|
+
pointless on this platform).`,
|
|
87
|
+
{
|
|
88
|
+
path: z.string().describe(
|
|
89
|
+
'Path to the .json. Relative paths resolve against the session workspace, '
|
|
90
|
+
+ 'then the shared project dir (e.g. "assets/Izumi 0814.json").',
|
|
91
|
+
),
|
|
92
|
+
// ⚠️ 参数名和枚举值一律 ASCII —— 工具 schema 是模型要照着填的东西,
|
|
93
|
+
// 中文键名在这条路上不可靠(全仓其他工具也都是 ASCII,别开这个头)
|
|
94
|
+
mode: z.enum(['digest', 'fetch']).optional()
|
|
95
|
+
.describe('digest = structure only (default); fetch = full text of the picked entries'),
|
|
96
|
+
entries: z.array(z.string()).optional()
|
|
97
|
+
.describe('For mode="fetch": entry names (partial match ok) or ids'),
|
|
98
|
+
},
|
|
99
|
+
async ({ path: rel, mode = 'digest', entries = [] }) => {
|
|
100
|
+
const fail = (text) => ({ content: [{ type: 'text', text }], isError: true });
|
|
101
|
+
try {
|
|
102
|
+
const raw = String(rel || '').trim();
|
|
103
|
+
if (!raw) return fail('read_tavern_json needs a path.');
|
|
104
|
+
const candidates = path.isAbsolute(raw)
|
|
105
|
+
? [raw]
|
|
106
|
+
: [workspaceRoot && path.resolve(workspaceRoot, raw),
|
|
107
|
+
sharedRoot && path.resolve(sharedRoot, raw)].filter(Boolean);
|
|
108
|
+
let abs = null;
|
|
109
|
+
for (const c of candidates) {
|
|
110
|
+
try { await fs.access(c); abs = c; break; } catch { /* 下一个 */ }
|
|
111
|
+
}
|
|
112
|
+
if (!abs) return fail(`File not found: ${raw}\nLooked in:\n${candidates.map(c => ` ${c}`).join('\n')}`);
|
|
113
|
+
|
|
114
|
+
let doc;
|
|
115
|
+
try { doc = JSON.parse(await fs.readFile(abs, 'utf8')); } catch (e) {
|
|
116
|
+
return fail(`这个文件不是合法 JSON:${e.message}`);
|
|
117
|
+
}
|
|
118
|
+
const kind = detectKind(doc);
|
|
119
|
+
if (!kind) {
|
|
120
|
+
return fail('认不出这是酒馆的哪种导出(预设要有 prompts + prompt_order;角色卡要有 first_mes;世界书要有 entries)。普通 JSON 用 Read 就行。');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (mode === 'fetch') {
|
|
124
|
+
const 出 = fetchEntries(doc, entries);
|
|
125
|
+
if (!出.length) return fail(`没找到这些条目:${entries.join(' / ')}。先用 mode="digest" 看名字。`);
|
|
126
|
+
let 总 = 0;
|
|
127
|
+
const 块 = [];
|
|
128
|
+
for (const e of 出) {
|
|
129
|
+
if (总 >= MAX_FETCH_CHARS) { 块.push(`〔余下 ${出.length - 块.length} 条超出单次上限,分批取〕`); break; }
|
|
130
|
+
const 文 = e.正文.slice(0, MAX_FETCH_CHARS - 总);
|
|
131
|
+
总 += 文.length;
|
|
132
|
+
块.push(`### ${e.名字}${e.角色 ? ` [${e.角色}]` : ''}\n${文}`);
|
|
133
|
+
}
|
|
134
|
+
return { content: [{ type: 'text', text: 块.join('\n\n') }] };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return { content: [{ type: 'text', text: 渲染摘要(digest(doc), path.basename(abs)) }] };
|
|
138
|
+
} catch (err) {
|
|
139
|
+
return fail(`read_tavern_json failed: ${err?.message || String(err)}`);
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
);
|
|
143
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mcp/tools/record-decision.js — record_decision MCP tool
|
|
3
|
+
*
|
|
4
|
+
* agent 在做关键设计决策时调,把"做了什么 + 为什么"写成共享便利贴
|
|
5
|
+
* `notes/决策.md` 的一面(`---` 分面)。2026-07-30 起决策
|
|
6
|
+
* 不再进 spec.json.decisions[]:便利贴是 agent 和用户的**共享层**——
|
|
7
|
+
* 用户在画布上直接看到、能翻、能改;spec.json 只是 agent 自己的暗档案,
|
|
8
|
+
* 用户看不见,头脑风暴根本进不来。旧会话已有的 spec.json decisions[]
|
|
9
|
+
* 仍被 hooks 注入(只读遗产),新决策一律走这里。
|
|
10
|
+
*
|
|
11
|
+
* 便利贴格式约定(前端 NoteSticker 按此渲染):
|
|
12
|
+
* - 一个 .md = 一张贴;`\n---\n` 分面,翻页看
|
|
13
|
+
* - 每面第一行 `# 标题`
|
|
14
|
+
*
|
|
15
|
+
* 落点:工作区 `notes/`(扁平模型,2026-08-08 起)—— 没有"任务归属"了,
|
|
16
|
+
* 便利贴直接住项目桌面。
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { tool } from '@anthropic-ai/claude-agent-sdk';
|
|
20
|
+
import { z } from 'zod';
|
|
21
|
+
import { promises as fs } from 'node:fs';
|
|
22
|
+
import path from 'node:path';
|
|
23
|
+
import { Events } from '../../agent/events.js';
|
|
24
|
+
|
|
25
|
+
const NOTE_FILE = '决策.md';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param {object} deps
|
|
29
|
+
* @param {string} deps.workspaceRoot
|
|
30
|
+
* @param {string} [deps.sessionId]
|
|
31
|
+
* @param {import('../../agent/context.js').AgentContext} [deps.ctx]
|
|
32
|
+
*/
|
|
33
|
+
export function makeRecordDecisionTool({ workspaceRoot, sessionId, ctx }) {
|
|
34
|
+
return tool(
|
|
35
|
+
'record_decision',
|
|
36
|
+
`Record a key design decision as a face of the project's decision sticky note
|
|
37
|
+
(notes/决策.md). The note is SHARED with the user — it renders as
|
|
38
|
+
a flippable sticky on their canvas, they can read and edit it. Use this to
|
|
39
|
+
capture WHY you made a particular choice — color, type scale, layout metaphor,
|
|
40
|
+
copy strategy — so the intent survives across sessions and the user can push
|
|
41
|
+
back on it.
|
|
42
|
+
|
|
43
|
+
Use this tool when:
|
|
44
|
+
- You make a non-trivial choice that has multiple defensible alternatives
|
|
45
|
+
(e.g., picking a primary color, deciding deck length, choosing a layout)
|
|
46
|
+
- The user gives feedback that changes a previous decision (record both)
|
|
47
|
+
- You want to document a constraint discovered mid-work
|
|
48
|
+
|
|
49
|
+
Do NOT use this tool for:
|
|
50
|
+
- Trivial implementation details (CSS class names, file structure)
|
|
51
|
+
- Things obvious from the canvas itself (the visible design speaks for itself)
|
|
52
|
+
- Every change — over-recording bloats the note and dilutes signal
|
|
53
|
+
|
|
54
|
+
For free-form shared notes (brainstorm material, reference digests, handoff
|
|
55
|
+
context), just Write notes/<slug>.md directly — same sticky-note
|
|
56
|
+
rendering, no tool needed.`,
|
|
57
|
+
{
|
|
58
|
+
title: z
|
|
59
|
+
.string()
|
|
60
|
+
.min(2)
|
|
61
|
+
.max(200)
|
|
62
|
+
.describe('Short decision title (e.g., "Primary color = #3366FF")'),
|
|
63
|
+
rationale: z
|
|
64
|
+
.string()
|
|
65
|
+
.min(2)
|
|
66
|
+
.max(2000)
|
|
67
|
+
.describe('Why this choice — connect to brief / user feedback / design principle'),
|
|
68
|
+
scope: z
|
|
69
|
+
.string()
|
|
70
|
+
.optional()
|
|
71
|
+
.describe('Where it applies (e.g., "Global", "Cover page", "All H1 headings")'),
|
|
72
|
+
alternatives: z
|
|
73
|
+
.array(z.string())
|
|
74
|
+
.optional()
|
|
75
|
+
.describe('Alternatives considered, briefly noting why rejected'),
|
|
76
|
+
},
|
|
77
|
+
async ({ title, rationale, scope, alternatives }) => {
|
|
78
|
+
try {
|
|
79
|
+
if (!workspaceRoot) {
|
|
80
|
+
return {
|
|
81
|
+
content: [{ type: 'text', text: 'No workspace bound; cannot record decision.' }],
|
|
82
|
+
isError: true,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const alts = Array.isArray(alternatives)
|
|
86
|
+
? alternatives.map(s => String(s).trim()).filter(Boolean) : [];
|
|
87
|
+
const face = [
|
|
88
|
+
`# ${title.trim()}`,
|
|
89
|
+
'',
|
|
90
|
+
rationale.trim(),
|
|
91
|
+
...(scope ? ['', `- 范围:${scope.trim()}`] : []),
|
|
92
|
+
...(alts.length ? [`- 备选:${alts.join(' / ')}`] : []),
|
|
93
|
+
`- ${new Date().toISOString().slice(0, 10)}`,
|
|
94
|
+
].join('\n');
|
|
95
|
+
|
|
96
|
+
const notesDir = path.join(workspaceRoot, 'notes');
|
|
97
|
+
await fs.mkdir(notesDir, { recursive: true });
|
|
98
|
+
const noteFile = path.join(notesDir, NOTE_FILE);
|
|
99
|
+
let prev = '';
|
|
100
|
+
try { prev = await fs.readFile(noteFile, 'utf8'); } catch { /* 首条 */ }
|
|
101
|
+
const next = prev.trim() ? `${prev.replace(/\s+$/, '')}\n\n---\n\n${face}\n` : `${face}\n`;
|
|
102
|
+
await fs.writeFile(noteFile, next, 'utf8');
|
|
103
|
+
|
|
104
|
+
const faceCount = next.split(/\n---\n/).length;
|
|
105
|
+
try {
|
|
106
|
+
// MCP 工具写盘不走 PostToolUse(Write/Edit) 那条 file_changed 直发,
|
|
107
|
+
// 自己补一发,前端便利贴才会当场刷新
|
|
108
|
+
// 工作区相对路径(fileChanged 正字法;曾发绝对路径=前端只吃到清单重拉,
|
|
109
|
+
// 寻址和版本 key 全失配。2026-08-14 普查改)
|
|
110
|
+
ctx?.emit?.(Events.fileChanged(`notes/${NOTE_FILE}`, 'change'));
|
|
111
|
+
ctx?.emit?.({
|
|
112
|
+
type: 'run.decision_recorded',
|
|
113
|
+
title: title.trim(),
|
|
114
|
+
scope: scope?.trim() || null,
|
|
115
|
+
decisionsCount: faceCount,
|
|
116
|
+
});
|
|
117
|
+
} catch { /* emit fail-safe */ }
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
content: [{
|
|
121
|
+
type: 'text',
|
|
122
|
+
// ⚠️ 这里曾写 `tasks/${task}/...` —— 扁平化删掉 task 变量时漏了这行,
|
|
123
|
+
// `task` 成悬空引用:决策照写、事件照发,**返回时 ReferenceError 被
|
|
124
|
+
// 外层 catch 接住**,agent 每次调用都收到报错以为失败(还可能重试出
|
|
125
|
+
// 重复面)。悬空引用潜伏族第二案(第一案 reloadToken,2026-08-08)。
|
|
126
|
+
text: `Decision recorded as face ${faceCount} of notes/${NOTE_FILE}: "${title.trim()}"`,
|
|
127
|
+
}],
|
|
128
|
+
};
|
|
129
|
+
} catch (err) {
|
|
130
|
+
return {
|
|
131
|
+
content: [{
|
|
132
|
+
type: 'text',
|
|
133
|
+
text: `Record decision failed: ${err?.message || String(err)}`,
|
|
134
|
+
}],
|
|
135
|
+
isError: true,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
);
|
|
140
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
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 } 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
|
+
},
|
|
67
|
+
async ({ type, from, to, label }) => {
|
|
68
|
+
if (!projectId) {
|
|
69
|
+
return { content: [{ type: 'text', text: 'No project bound; cannot draw relationships.' }], isError: true };
|
|
70
|
+
}
|
|
71
|
+
if (from === to) {
|
|
72
|
+
return {
|
|
73
|
+
content: [{ type: 'text', text: 'from and to are the same thing — a relationship needs two ends.' }],
|
|
74
|
+
isError: true,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const id = nextId();
|
|
78
|
+
// by:'agent' 不只是记录出处 —— 用户画的线 agent 不该擅自删,反过来也一样
|
|
79
|
+
const binding = { type, from, to, by: 'agent', ...(label ? { label } : {}) };
|
|
80
|
+
const board = await patchBoard(projectId, { bindings: { [id]: binding } });
|
|
81
|
+
|
|
82
|
+
// 服务端会丢掉非法的线(未知 type / 自环)。**丢了要说**,否则 agent 以为
|
|
83
|
+
// 画上了,用户看不到,两边都不知道发生了什么。
|
|
84
|
+
if (!board.bindings?.[id]) {
|
|
85
|
+
return {
|
|
86
|
+
content: [{ type: 'text', text: `Relationship rejected by the board (bad type or endpoints): ${type} ${from} -> ${to}` }],
|
|
87
|
+
isError: true,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// 广播:前端整份重拉。**sessionId 必须显式给 null** —— ctx 会把自己的
|
|
92
|
+
// sessionId 补进事件,那样只有当前会话的连接收得到,别的 tab 看不见。
|
|
93
|
+
try {
|
|
94
|
+
ctx?.emit?.({
|
|
95
|
+
type: 'board.updated',
|
|
96
|
+
sessionId: null,
|
|
97
|
+
summary: `已画一条「${BINDING_TYPES[type].label}」关系`,
|
|
98
|
+
});
|
|
99
|
+
} catch { /* emit fail-safe:广播失败不该让工具报错,线已经落盘了 */ }
|
|
100
|
+
|
|
101
|
+
const arrow = BINDING_TYPES[type].directed ? '->' : '<->';
|
|
102
|
+
return {
|
|
103
|
+
content: [{
|
|
104
|
+
type: 'text',
|
|
105
|
+
text: `Drew ${type} (${BINDING_TYPES[type].label}): ${from} ${arrow} ${to}`,
|
|
106
|
+
}],
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
);
|
|
110
|
+
}
|