@xiaobuyu/nodesign 0.0.1 → 0.0.2
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/README.md +156 -106
- package/bin/nodesign.js +0 -0
- package/package.json +1 -1
- package/server/api/README.md +45 -45
- package/server/api/_guard.js +75 -75
- package/server/api/admin.js +187 -187
- package/server/api/assets/docx-page.js +103 -103
- package/server/api/assets/helpers.js +22 -22
- package/server/api/assets/notes.js +144 -144
- package/server/api/assets.js +896 -896
- package/server/api/board.js +57 -57
- package/server/api/browse.js +138 -138
- package/server/api/canvas.js +444 -444
- package/server/api/chatai.js +324 -324
- package/server/api/exports/build-standalone.js +980 -980
- package/server/api/exports/cards.js +118 -118
- package/server/api/exports/docx-pdf.js +46 -46
- package/server/api/exports/export-page.js +142 -142
- package/server/api/exports/handoff.js +147 -147
- package/server/api/exports.js +690 -690
- package/server/api/instruction.js +75 -75
- package/server/api/me.js +116 -116
- package/server/api/memory.js +185 -185
- package/server/api/pending-changes.js +366 -366
- package/server/api/plugins.js +164 -164
- package/server/api/projects.js +220 -220
- package/server/api/publish.js +64 -64
- package/server/api/recent.js +73 -73
- package/server/api/sessions.js +589 -589
- package/server/api/skills.js +77 -77
- package/server/api/standalone-fit.js +168 -168
- package/server/api/turn-compose.js +180 -180
- package/server/api/turn-inflight.js +44 -44
- package/server/auth/README.md +17 -17
- package/server/auth/middleware.js +138 -138
- package/server/auth/origin-guard.js +71 -71
- package/server/auth/session.js +108 -108
- package/server/auth/tier.js +113 -113
- package/server/auth/users-store.js +348 -348
- package/server/edit/README.md +29 -29
- package/server/engine/README.md +113 -113
- package/server/engine/agent/agent-shared.js +550 -550
- package/server/engine/agent/auto-mode-default-hard-deny.txt +4 -4
- package/server/engine/agent/auto-mode-rules.js +78 -78
- package/server/engine/agent/context.js +418 -418
- package/server/engine/agent/events.js +464 -464
- package/server/engine/agent/hooks/canvas-validate.js +199 -199
- package/server/engine/agent/hooks/failure.js +120 -120
- package/server/engine/agent/hooks/file-events.js +75 -75
- package/server/engine/agent/hooks/lifecycle.js +233 -233
- package/server/engine/agent/hooks/post-canvas-focus.js +80 -80
- package/server/engine/agent/hooks/post-guidance.js +206 -206
- package/server/engine/agent/hooks/post-subagent-report.js +104 -104
- package/server/engine/agent/hooks/post-trim.js +58 -58
- package/server/engine/agent/hooks/pre-board-neighborhood.js +34 -34
- package/server/engine/agent/hooks/pre-defaults.js +84 -84
- package/server/engine/agent/hooks/pre-injectors.js +277 -277
- package/server/engine/agent/hooks/pre-performance-log-guard.js +78 -78
- package/server/engine/agent/hooks/pre-starter-files.js +61 -61
- package/server/engine/agent/hooks/pre-workspace-scope-guard.js +78 -78
- package/server/engine/agent/hooks/site-validate.js +94 -94
- package/server/engine/agent/hooks/tool-prompts.js +31 -31
- package/server/engine/agent/hooks/turn-state-memory.js +56 -56
- package/server/engine/agent/hooks/user-prompt-submit.js +215 -215
- package/server/engine/agent/hooks.js +354 -354
- package/server/engine/agent/init-contract.js +69 -69
- package/server/engine/agent/isolation.js +159 -159
- package/server/engine/agent/model-table.js +292 -292
- package/server/engine/agent/plugin-loader.js +266 -266
- package/server/engine/agent/prompts/nodesign-prelude.md +336 -336
- package/server/engine/agent/prompts/tools/ask-user-question-protocol.md +71 -71
- package/server/engine/agent/prompts/tools/direct-edit-protocol.md +98 -98
- package/server/engine/agent/prompts/tools/generate-image-cookbook.gemini-gateway.md +583 -583
- package/server/engine/agent/prompts/tools/generate-image-cookbook.md +483 -483
- package/server/engine/agent/prompts/tools/hybrid-reference.md +100 -100
- package/server/engine/agent/prompts/tools/paint-still-cookbook.md +270 -270
- package/server/engine/agent/prompts/tools/roll-film-cookbook.md +70 -70
- package/server/engine/agent/prompts/tools/site-reference.md +106 -106
- package/server/engine/agent/prompts/tools/tweaks-syntax.md +125 -125
- package/server/engine/agent/prompts/tools/vision-checker-dispatch.md +48 -48
- package/server/engine/agent/session-loop.js +1024 -1024
- package/server/engine/agent/session-model.js +164 -164
- package/server/engine/agent/skill.js +204 -204
- package/server/engine/agent/task-events.js +78 -78
- package/server/engine/agents/ds-extractor.md +132 -132
- package/server/engine/agents/explorer.md +190 -190
- package/server/engine/agents/index.js +230 -230
- package/server/engine/agents/schemas/design-system.json +156 -156
- package/server/engine/agents/schemas/tweak-schema.json +113 -113
- package/server/engine/agents/tweak-proposer.md +127 -127
- package/server/engine/agents/vision-checker.md +254 -254
- package/server/engine/browse/capture.js +422 -422
- package/server/engine/browse/card.js +137 -137
- package/server/engine/browse/handover.js +59 -59
- package/server/engine/browse/page-digest.js +119 -119
- package/server/engine/browse/refs.js +196 -196
- package/server/engine/browse/registry.js +307 -307
- package/server/engine/browse/screencast.js +170 -170
- package/server/engine/browse/state.js +121 -121
- package/server/engine/chatai/chat-log.js +79 -79
- package/server/engine/chatai/index.js +193 -193
- package/server/engine/chatai/openai-compat.js +152 -152
- package/server/engine/chatai/orchestrate.js +309 -309
- package/server/engine/chatai/perform.js +40 -40
- package/server/engine/chatai/summarize.js +79 -79
- package/server/engine/mcp/capability-gate.js +52 -52
- package/server/engine/mcp/index.js +339 -339
- package/server/engine/mcp/param-sanitizer.js +142 -142
- package/server/engine/mcp/tools/arrange-on-board.js +124 -124
- package/server/engine/mcp/tools/artifact-session.js +278 -278
- package/server/engine/mcp/tools/browse-computer.js +421 -421
- package/server/engine/mcp/tools/browse-find-batch.js +183 -183
- package/server/engine/mcp/tools/browse-screenshot.js +157 -157
- package/server/engine/mcp/tools/browse.js +480 -480
- package/server/engine/mcp/tools/build-docx.js +101 -101
- package/server/engine/mcp/tools/clear-pending-changes.js +99 -99
- package/server/engine/mcp/tools/create-on-board.js +155 -155
- package/server/engine/mcp/tools/crystallize-skill.js +168 -168
- package/server/engine/mcp/tools/explain-style.js +237 -237
- package/server/engine/mcp/tools/export-handoff.js +133 -133
- package/server/engine/mcp/tools/expose-tweaks.js +149 -149
- package/server/engine/mcp/tools/generate-image.js +842 -842
- package/server/engine/mcp/tools/get-computed-styles.js +164 -164
- package/server/engine/mcp/tools/get-pending-changes.js +205 -205
- package/server/engine/mcp/tools/h3box-ssh.js +84 -84
- package/server/engine/mcp/tools/helpers/acquire-page.js +82 -82
- package/server/engine/mcp/tools/helpers/motion-lab.js +554 -554
- package/server/engine/mcp/tools/helpers/motion-scroll.js +112 -112
- package/server/engine/mcp/tools/helpers/perception-page.js +215 -215
- package/server/engine/mcp/tools/helpers/reference-download.js +103 -103
- package/server/engine/mcp/tools/helpers/rembg-bridge.py +80 -80
- package/server/engine/mcp/tools/helpers/shot-pipeline.js +280 -280
- package/server/engine/mcp/tools/highlight.js +68 -68
- package/server/engine/mcp/tools/list-pages.js +222 -222
- package/server/engine/mcp/tools/lookup-tags.js +59 -59
- package/server/engine/mcp/tools/navigate-to-page.js +60 -60
- package/server/engine/mcp/tools/organize-board.js +64 -64
- package/server/engine/mcp/tools/paint-still.js +434 -434
- package/server/engine/mcp/tools/pin-to-board.js +130 -130
- package/server/engine/mcp/tools/preview-deck.js +130 -130
- package/server/engine/mcp/tools/profile-scroll.js +305 -305
- package/server/engine/mcp/tools/publish-site.js +102 -102
- package/server/engine/mcp/tools/query-elements.js +195 -195
- package/server/engine/mcp/tools/read-board.js +103 -103
- package/server/engine/mcp/tools/read-document.js +93 -93
- package/server/engine/mcp/tools/read-page.js +264 -264
- package/server/engine/mcp/tools/read-tavern-json.js +143 -143
- package/server/engine/mcp/tools/record-decision.js +140 -140
- package/server/engine/mcp/tools/relate-on-board.js +110 -110
- package/server/engine/mcp/tools/report-issue.js +115 -115
- package/server/engine/mcp/tools/roll-film.js +266 -266
- package/server/engine/mcp/tools/screenshot-docx.js +138 -138
- package/server/engine/mcp/tools/screenshot-url.js +195 -195
- package/server/engine/mcp/tools/screenshot.js +583 -583
- package/server/engine/mcp/tools/tier-gate.js +96 -96
- package/server/engine/mcp/tools/trace-motion.js +215 -215
- package/server/engine/mcp/tools/web-search.js +548 -548
- package/server/engine/motion/inventory.js +349 -349
- package/server/engine/perception/session.js +235 -235
- package/server/engine/plugins/nodesign/.claude-plugin/plugin.json +5 -5
- package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/SKILL.md +192 -192
- package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/canvas.template.html +667 -667
- package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/patterns/hybrid-grid.md +22 -22
- package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/patterns/image-led-cover.md +25 -25
- package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/patterns/portrait.md +23 -23
- package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/patterns/quote-backdrop.md +21 -21
- package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/patterns/section-divider.md +23 -23
- package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/patterns/text-led.md +21 -21
- package/server/engine/plugins/nodesign/skills/docx-craft/SKILL.md +162 -162
- package/server/engine/plugins/nodesign/skills/docx-craft/references/token-schema.md +407 -407
- package/server/engine/plugins/nodesign/skills/docx-craft//346/226/207/346/241/243.template.json +80 -80
- package/server/engine/plugins/nodesign/skills/rp-craft/SKILL.md +228 -228
- 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 -78
- package/server/engine/plugins/nodesign/skills/rp-craft//346/274/224/345/207/272.template.js +268 -268
- package/server/engine/plugins/nodesign/skills/site-craft/SKILL.md +323 -323
- package/server/engine/plugins/nodesign/skills/site-craft/patterns/build-lane.md +134 -134
- package/server/engine/plugins/nodesign/skills/site-craft/patterns/cutout-collage.md +61 -61
- package/server/engine/plugins/nodesign/skills/site-craft/patterns/mock-app.md +163 -163
- package/server/engine/plugins/nodesign/skills/site-craft/patterns/page-transitions.md +86 -86
- package/server/engine/runs/active-runs.js +698 -698
- package/server/engine/runs/live-turn.js +252 -252
- package/server/engine/runs/store.js +364 -364
- package/server/engine/runs/turn-relay.js +217 -217
- package/server/engine/runtime/workspace.js +164 -164
- package/server/lib/artifact-file-path.js +80 -80
- package/server/lib/artifact-target.js +284 -284
- package/server/lib/asset-refs.js +239 -239
- package/server/lib/async-queue.js +104 -104
- package/server/lib/auto-relations.js +130 -130
- package/server/lib/binding-types.js +60 -60
- package/server/lib/board-kind-sizes.js +62 -62
- package/server/lib/board-relations.js +133 -133
- package/server/lib/browse-proxy.js +180 -180
- package/server/lib/canvas-id.js +36 -36
- package/server/lib/cover.js +227 -227
- package/server/lib/danbooru-tags.js +291 -291
- package/server/lib/doc-extract.js +156 -156
- package/server/lib/docx/build-from-source.js +260 -260
- package/server/lib/docx/build.js +490 -490
- package/server/lib/docx/dump-styles.js +287 -287
- package/server/lib/docx/fonts/nodesign-cjk.conf +164 -164
- package/server/lib/docx/merge-runs.js +129 -129
- package/server/lib/docx/numbering.js +218 -218
- package/server/lib/docx/order.js +152 -152
- package/server/lib/docx/rawzip.js +172 -172
- package/server/lib/docx/render.js +92 -92
- package/server/lib/docx/text-lint.js +225 -225
- package/server/lib/docx/tokens.js +335 -335
- package/server/lib/docx/units.js +29 -29
- package/server/lib/docx/xml.js +291 -291
- package/server/lib/docx-pages.js +187 -187
- package/server/lib/export-collect.js +289 -289
- package/server/lib/export-package.js +210 -210
- package/server/lib/html-srcset.js +145 -145
- package/server/lib/image-variant.js +460 -460
- package/server/lib/ingress/forward-openai-chat.js +305 -305
- package/server/lib/ingress/openai-chat.js +491 -491
- package/server/lib/ingress/session-notice.js +66 -66
- package/server/lib/ingress/session-routes.js +68 -68
- package/server/lib/ingress/slot-probe.js +130 -130
- package/server/lib/ingress/upstream-billing.js +52 -52
- package/server/lib/ingress/upstream-fail-streak.js +72 -72
- package/server/lib/ingress/upstream-truncation.js +48 -48
- package/server/lib/issues-store.js +182 -182
- package/server/lib/kinds/deck.js +72 -72
- package/server/lib/kinds/docx.js +283 -283
- package/server/lib/kinds/file-kinds.js +113 -113
- package/server/lib/kinds/index.js +202 -202
- package/server/lib/kinds/site.js +161 -161
- package/server/lib/model-ingress.js +543 -543
- package/server/lib/moderation.js +255 -255
- package/server/lib/notice-store.js +103 -103
- package/server/lib/plugin-install.js +104 -104
- package/server/lib/plugin-validator.js +721 -721
- package/server/lib/publish-store.js +115 -115
- package/server/lib/quick-summary.js +52 -52
- package/server/lib/quota.js +270 -270
- package/server/lib/rate-window.js +29 -29
- package/server/lib/reference-assets.js +92 -92
- package/server/lib/region-shot.js +135 -135
- package/server/lib/safe-path.js +73 -73
- package/server/lib/sdk-session.js +33 -33
- package/server/lib/showcase-store.js +92 -92
- package/server/lib/site-publish.js +465 -465
- package/server/lib/ssrf-guard.js +432 -432
- package/server/lib/task-scan.js +158 -158
- package/server/lib/tavern-json.js +154 -154
- package/server/lib/video-variant.js +237 -237
- package/server/lib/workspace-path.js +33 -33
- package/server/ops/fix-sdk-musl.mjs +40 -40
- package/server/ops/install-macos-fonts.sh +114 -114
- package/server/ops/macos-fonts.conf +336 -336
- package/server/ops/sandbox-shim/bwrap +57 -57
- package/server/projects/assets-summary.js +119 -119
- package/server/projects/auto-name.js +53 -53
- package/server/projects/board-store.js +640 -640
- package/server/projects/move-entry.js +103 -103
- package/server/projects/store.js +270 -270
- package/server/projects/ui-config.js +54 -54
- package/server/projects/workspace-templates.js +53 -53
- package/server/projects/workspace.js +1025 -1025
- package/server/runtime/local-config.js +177 -177
- package/server/runtime/profile.js +72 -72
- package/server/services/rembg-service.py +334 -334
- package/server/shared/README.md +25 -25
- package/server/shared/deck.js +54 -54
- package/server/shared/time.js +49 -49
- package/server/style-pipeline/README.md +53 -53
- package/server/ws/broker.js +36 -36
- package/server/ws/browse-channel.js +177 -177
- package/server/ws/index.js +386 -386
- package/web/README.md +89 -89
- package/web/dist/assets/BrowserWindow-BYCgizHw.js +11 -0
- package/web/dist/assets/{DeckWindow-4G0xX7P3.js → DeckWindow-pNydEM4L.js} +1 -1
- package/web/dist/assets/{DocxWindow-BXQsoPkh.js → DocxWindow-PPgzh3Gq.js} +1 -1
- package/web/dist/assets/{SiteWindow-D6eS-2gM.js → SiteWindow-DM0LQPCO.js} +1 -1
- package/web/dist/assets/{index-Cbl3ATvp.js → index-BHTBJlpY.js} +32 -32
- package/web/dist/assets/{pending-edit-apply-DTjo2geW.js → pending-edit-apply-C0I13CbD.js} +1 -1
- package/web/dist/assets/{rotate-cw-LMT3x1Zj.js → rotate-cw-B1UQ8Hld.js} +1 -1
- package/web/dist/assets/{square-dashed-mouse-pointer-CBoAkfhi.js → square-dashed-mouse-pointer-8lrgqmfv.js} +1 -1
- package/web/dist/index.html +17 -17
- package/web/dist/assets/BrowserWindow-Dc7J7CYc.js +0 -11
|
@@ -1,230 +1,230 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* server/engine/agents/index.js — subagent 定义集合
|
|
3
|
-
*
|
|
4
|
-
* 通过 SDK 的 query options.agents 字段挂载 4 个子代理:
|
|
5
|
-
*
|
|
6
|
-
* explorer — ⏸ 停用中(2026-08-14)。研究员(搜索 + 读资料 + 验证事实)
|
|
7
|
-
* vision-checker — 截图 + a11y / 视觉合理性评审(C14 真实 prompt 在 vision-checker.md)
|
|
8
|
-
* ds-extractor — 抽 design system tokens(C15 真实 prompt + design-system.json schema)
|
|
9
|
-
* tweak-proposer — 推可调 slider schema(C16 真实 prompt + tweak-schema.json schema)
|
|
10
|
-
*
|
|
11
|
-
* 调用:main agent 用 Task 工具调(SDK 自动暴露)。
|
|
12
|
-
* **注意**:'Task' 必须在主 agent 的 toolAllowlist 里(session-loop.js DEFAULT_TOOL_ALLOWLIST)
|
|
13
|
-
* 否则 SDK 拒绝调用,所有子代理形同摆设。
|
|
14
|
-
*
|
|
15
|
-
* P0+ stage 1 范围:
|
|
16
|
-
* - 只挂定义骨架,main agent 通过 SKILL.md 引导**不主动调**这些子代理
|
|
17
|
-
* - 真调用流程留 stage 2(用户测试 + 真接通 H/F 流时再发力)
|
|
18
|
-
* - prompt 在 C14-C16 用 .md 文件填实,本 commit 用占位短句
|
|
19
|
-
*
|
|
20
|
-
* AgentDefinition 字段(sdk.d.ts:38):
|
|
21
|
-
* description: string 自然语言描述何时该用
|
|
22
|
-
* tools?: string[] 允许的工具,omit 继承父 agent
|
|
23
|
-
* disallowedTools?: string[]
|
|
24
|
-
* prompt: string system prompt
|
|
25
|
-
* model?: string alias 或 full id;'inherit' / omit 沿父
|
|
26
|
-
* mcpServers?: AgentMcpServerSpec[]
|
|
27
|
-
* skills?: string[]
|
|
28
|
-
* initialPrompt?: string 首条自动 user 消息
|
|
29
|
-
* maxTurns?: number
|
|
30
|
-
* background?: boolean true = fire-and-forget 不阻塞
|
|
31
|
-
* memory?: 'user' | 'project' | 'local'
|
|
32
|
-
* effort?: EffortLevel | number
|
|
33
|
-
* permissionMode?: PermissionMode
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
import fs from 'node:fs';
|
|
37
|
-
import path from 'node:path';
|
|
38
|
-
import { fileURLToPath } from 'node:url';
|
|
39
|
-
import { resolveModelRoute } from '../agent/model-context.js';
|
|
40
|
-
|
|
41
|
-
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* 同步读 agents/<name>.md 作为 agent prompt。模块加载时一次性读完,
|
|
45
|
-
* 后续每次 createAgents() 复用 cache,避免 spawn 时 IO。
|
|
46
|
-
*
|
|
47
|
-
* 缺失或读失败时降级到 STUB_PROMPT —— SDK 不至于 crash,main agent
|
|
48
|
-
* 调用时收到说明文字。
|
|
49
|
-
*/
|
|
50
|
-
const PROMPT_CACHE = {};
|
|
51
|
-
function loadPrompt(name) {
|
|
52
|
-
if (PROMPT_CACHE[name] !== undefined) return PROMPT_CACHE[name];
|
|
53
|
-
const file = path.join(HERE, `${name}.md`);
|
|
54
|
-
try {
|
|
55
|
-
PROMPT_CACHE[name] = fs.readFileSync(file, 'utf8');
|
|
56
|
-
} catch (err) {
|
|
57
|
-
console.warn(`[agents] failed to load ${name}.md (${err.message}); using stub`);
|
|
58
|
-
PROMPT_CACHE[name] = STUB_PROMPT(name);
|
|
59
|
-
}
|
|
60
|
-
return PROMPT_CACHE[name];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const STUB_PROMPT = (name) =>
|
|
64
|
-
`(P0+ stage 1 placeholder for ${name} agent. agents/${name}.md not found — `
|
|
65
|
-
+ `the file should ship with this commit. If you're an agent reading this, `
|
|
66
|
-
+ `report "agents/${name}.md missing" and stop.)`;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* 给定主 model,挑一个搭配的快速 model(subagent + SDK helper 共用)。
|
|
70
|
-
*
|
|
71
|
-
* 2026-08-19 起查表:API 通路模型的 fastModel 在 model-context.js 表里逐行配
|
|
72
|
-
* (必须同表可路由 —— 订阅 haiku 在 API 模式会 404,旧的 DMXAPI haiku-cc
|
|
73
|
-
* 硬编码就是"换了 api 之后 helper 起不来"的病根之一)。订阅模型沿用主 model
|
|
74
|
-
* 自己(不强制降级避免拼错模型名导致 404)。env NODESIGN_FAST_MODEL 显式覆盖
|
|
75
|
-
* 只对订阅路生效,见 session-loop 的通路注释。
|
|
76
|
-
*/
|
|
77
|
-
export function resolveDefaultFastModel(mainModel) {
|
|
78
|
-
if (!mainModel) return null;
|
|
79
|
-
const route = resolveModelRoute(mainModel);
|
|
80
|
-
return route.mode === 'api' ? route.fastModel : mainModel;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* 按 role 决定子代理 model。
|
|
85
|
-
*
|
|
86
|
-
* - **structural / search 类**(explorer / ds-extractor / tweak-proposer)→ subModel
|
|
87
|
-
* 功能是搜外链 / 抽 token / 推 slider,capability 不需跟主同级,走 fast model 省成本。
|
|
88
|
-
*
|
|
89
|
-
* - **judgment 类**(vision-checker)→ sdkSpoofMain
|
|
90
|
-
* 视觉评审要看出 plan compliance / palette match / 反 AI 套路这些细节,
|
|
91
|
-
* capability 必须跟主 agent 同级——直接喂主 agent **SDK 视角的 model**
|
|
92
|
-
* (Kimi 主时是 spoofing alias `claude-opus-4-7[1m]`,SDK 信 1M context;
|
|
93
|
-
* binary-fixup-proxy 出口反向还原成真 `kimi-k2.6` 给 gateway)。
|
|
94
|
-
*
|
|
95
|
-
* 绕开两个坑:
|
|
96
|
-
* 1. memory part4 — 喂 SDK 真 `kimi-k2.6` → SDK 不识别 → rawMaxTokens
|
|
97
|
-
* fallback 200k → 子代理 context window 被腰斩
|
|
98
|
-
* 2. memory feedback_kimi_split_messages — `'inherit'` 字面虽被 retract 为非
|
|
99
|
-
* root cause,但从未独立验证过;走"具体 sdkModel id 直传"绕开字面解析路径
|
|
100
|
-
*/
|
|
101
|
-
function pickAgentModel(role, { sdkSpoofMain, subModel }) {
|
|
102
|
-
if (role === 'vision-checker') return sdkSpoofMain || subModel;
|
|
103
|
-
return subModel;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* 创建 agents 配置 —— 喂给 query options.agents 字段。
|
|
108
|
-
*
|
|
109
|
-
* @param {object} [opts]
|
|
110
|
-
* @param {string} [opts.mainModel] 主 agent appModel(如 'kimi-k2.6')
|
|
111
|
-
* @param {string} [opts.sdkModel] 主 agent SDK 视角 model(spoofing 后的 alias,如 'claude-opus-4-7[1m]')。
|
|
112
|
-
* 缺省 = mainModel(非 Kimi 主时两者本就相等)。vision-checker 用这个。
|
|
113
|
-
* @param {string} [opts.fastModel] 显式覆盖 fast model;优先级:fastModel > NODESIGN_FAST_MODEL > resolveDefaultFastModel(mainModel)
|
|
114
|
-
* @returns {Record<string, AgentDefinition>}
|
|
115
|
-
*/
|
|
116
|
-
export function createAgents({ mainModel, sdkModel, fastModel } = {}) {
|
|
117
|
-
const subModel = fastModel
|
|
118
|
-
|| process.env.NODESIGN_FAST_MODEL
|
|
119
|
-
|| resolveDefaultFastModel(mainModel)
|
|
120
|
-
|| mainModel
|
|
121
|
-
|| 'claude-haiku-4-5';
|
|
122
|
-
// sdkSpoofMain:vision-checker 用的"主 agent SDK 视角 model"。
|
|
123
|
-
// 调用方未传 sdkModel 时 fallback 到 mainModel(非 Kimi 主时两者相等无害)。
|
|
124
|
-
const sdkSpoofMain = sdkModel || mainModel;
|
|
125
|
-
return {
|
|
126
|
-
// explorer —— 研究员子代理。主 agent 在做 deck/产物时遇到"需要外部素材
|
|
127
|
-
// / 参考 / 事实验证" 就 Task 派给它。它去搜 + 读 + 总结,给主 agent 一份
|
|
128
|
-
// 结构化研究报告(URLs / 字体 / 数据 / 趋势)。主 agent 拿报告直接 Edit
|
|
129
|
-
// canvas.html 用,不必自己分心去搜。
|
|
130
|
-
//
|
|
131
|
-
// tools 显式收窄到 read-only researcher:
|
|
132
|
-
// - mcp__nodesign__web_search(多 provider 联网搜)
|
|
133
|
-
// - mcp__nodesign__screenshot_url(外站截图 —— 找视觉参考要能看见视觉,
|
|
134
|
-
// 2026-07-29 前只能 WebFetch 文本转述"这个站是深色的",等于瞎子摸象)
|
|
135
|
-
// - WebFetch(SDK 内置,按 prompt 总结 URL 内容)
|
|
136
|
-
// - Read / Glob / Grep(看本地 ./assets 和 ./spec.json)
|
|
137
|
-
// - TodoWrite(多步研究列计划)
|
|
138
|
-
// 不给:Write/Edit(不写代码)/ Bash(不要 shell shenanigans)/
|
|
139
|
-
// AskUserQuestion(子代理不直接跟用户说话)/ screenshot/export/
|
|
140
|
-
// record_decision(不是它的角色)/ Task(不允许嵌套子代理)
|
|
141
|
-
// ⏸ explorer 研究员(2026-08-14 用户暂时停用:"有点没用")。定义与
|
|
142
|
-
// prompt(explorer.md)原样保留,恢复 = 取消注释 + prelude 补回子代理
|
|
143
|
-
// 清单那两行。停用期间搜索/读外链由主 agent 直接用 web_search / WebFetch。
|
|
144
|
-
// explorer: {
|
|
145
|
-
// description: 'Research/explorer subagent. …',
|
|
146
|
-
// prompt: loadPrompt('explorer'),
|
|
147
|
-
// model: pickAgentModel('explorer', { sdkSpoofMain, subModel }),
|
|
148
|
-
// tools: [
|
|
149
|
-
// 'mcp__nodesign__web_search', 'mcp__nodesign__screenshot_url',
|
|
150
|
-
// 'WebFetch', 'Read', 'Glob', 'Grep', 'TodoWrite',
|
|
151
|
-
// ],
|
|
152
|
-
// // maxTurns 12 的来历:8 轮在真实多维 brief 上会被 SDK 硬掐断流
|
|
153
|
-
// // (2026-08-05 两次报告全损),提级 + explorer.md「随手记」纪律。
|
|
154
|
-
// maxTurns: 12,
|
|
155
|
-
// },
|
|
156
|
-
|
|
157
|
-
'vision-checker': {
|
|
158
|
-
description:
|
|
159
|
-
'Visually inspect the current canvas.html design via screenshot. '
|
|
160
|
-
+ 'Use this when you need an independent second-pair-of-eyes review on '
|
|
161
|
-
+ 'whether the design looks right — alignment, contrast, hierarchy, spacing, '
|
|
162
|
-
+ 'a11y readability, and (when design-plan.md exists) per-page plan compliance. '
|
|
163
|
-
+ 'Returns a structured per-page critique with concrete fix suggestions.',
|
|
164
|
-
prompt: loadPrompt('vision-checker'),
|
|
165
|
-
// judgment 类——视觉评审 capability 必须跟主 agent 同级,走 sdkSpoofMain
|
|
166
|
-
// (Kimi 主时是 'claude-opus-4-7[1m]' alias,SDK 信 1M context;proxy 出口
|
|
167
|
-
// 反向还原成真 'kimi-k2.6' 给 gateway)。详见 pickAgentModel 注释。
|
|
168
|
-
model: pickAgentModel('vision-checker', { sdkSpoofMain, subModel }),
|
|
169
|
-
// 显式列 tools:read-only 视觉评审需要的最小集合。
|
|
170
|
-
// SDK doc 说"omit tools 继承父" 但跨 mcp 工具的继承行为不确定(explorer 也
|
|
171
|
-
// 显式列 mcp__nodesign__web_search 是同样的稳妥做法)。Phase 1.1 audit 后
|
|
172
|
-
// 改成显式声明,保证 vision-checker.md 里写的 mcp__nodesign__screenshot_canvas
|
|
173
|
-
// 真实可调。
|
|
174
|
-
//
|
|
175
|
-
// 2026-05-10:新增 list_pages(枚举页数 → 决定循环 pageIndex 上界)+
|
|
176
|
-
// TodoWrite(多步逐页评审编排,让前端可见 vision-checker 在做啥)。
|
|
177
|
-
tools: [
|
|
178
|
-
'mcp__nodesign__screenshot_canvas',
|
|
179
|
-
'mcp__nodesign__list_pages',
|
|
180
|
-
'Read', 'Glob',
|
|
181
|
-
'TodoWrite',
|
|
182
|
-
],
|
|
183
|
-
// maxTurns:逐页评审下界估算 = 1 (Read plan) + 1 (list_pages) + 1
|
|
184
|
-
// (fullPage 总览) + N (per-page 截图) + 1-2 (think + report)。N 页 deck
|
|
185
|
-
// 至少 N+5 turn。16 容纳到 ~10 页 deck;超长 deck 主 agent 应 prompt
|
|
186
|
-
// 里点名分批评审。
|
|
187
|
-
maxTurns: 16,
|
|
188
|
-
},
|
|
189
|
-
|
|
190
|
-
'ds-extractor': {
|
|
191
|
-
description:
|
|
192
|
-
'Extract a design system spec (color tokens, type scale, spacing scale, '
|
|
193
|
-
+ 'shadow tokens, border radius) from the current canvas.html. Returns a '
|
|
194
|
-
+ 'JSON document conformant to schemas/design-system.json. '
|
|
195
|
-
+ 'Use this when the user asks "抽 design system" / "extract design tokens" / '
|
|
196
|
-
+ '"capture the visual rules" — typically right before reusing the style.',
|
|
197
|
-
prompt: loadPrompt('ds-extractor'),
|
|
198
|
-
// SDK AgentDefinition 没有 outputFormat 字段(query options 级别才有)。
|
|
199
|
-
// 子代理走 prompt 内嵌 JSON Schema 引导输出,main agent 收到后 JSON.parse。
|
|
200
|
-
// schema 文件在 agents/schemas/design-system.json,prompt 里有完整摘录。
|
|
201
|
-
// structural 类(结构化抽 token),走 fast model
|
|
202
|
-
model: pickAgentModel('ds-extractor', { sdkSpoofMain, subModel }),
|
|
203
|
-
tools: [
|
|
204
|
-
'Read', 'Glob', 'Grep',
|
|
205
|
-
'mcp__nodesign__list_pages',
|
|
206
|
-
'mcp__nodesign__read_page',
|
|
207
|
-
'mcp__nodesign__get_computed_styles',
|
|
208
|
-
],
|
|
209
|
-
},
|
|
210
|
-
|
|
211
|
-
'tweak-proposer': {
|
|
212
|
-
description:
|
|
213
|
-
'Propose 4–10 tweakable dimensions of the current canvas (e.g., heading '
|
|
214
|
-
+ 'scale, spacing density, accent color, corner style). Returns JSON '
|
|
215
|
-
+ 'conformant to schemas/tweak-schema.json — the frontend renders each '
|
|
216
|
-
+ 'tweak as slider / select / color picker / toggle. Use this when the '
|
|
217
|
-
+ 'user wants to fine-tune without rewriting.',
|
|
218
|
-
prompt: loadPrompt('tweak-proposer'),
|
|
219
|
-
// 同 ds-extractor:SDK 不支持 per-agent outputFormat,schema 内嵌 prompt
|
|
220
|
-
// structural 类(schema 推导),走 fast model
|
|
221
|
-
model: pickAgentModel('tweak-proposer', { sdkSpoofMain, subModel }),
|
|
222
|
-
tools: [
|
|
223
|
-
'Read', 'Glob',
|
|
224
|
-
'mcp__nodesign__list_pages',
|
|
225
|
-
'mcp__nodesign__read_page',
|
|
226
|
-
'mcp__nodesign__expose_tweaks',
|
|
227
|
-
],
|
|
228
|
-
},
|
|
229
|
-
};
|
|
230
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* server/engine/agents/index.js — subagent 定义集合
|
|
3
|
+
*
|
|
4
|
+
* 通过 SDK 的 query options.agents 字段挂载 4 个子代理:
|
|
5
|
+
*
|
|
6
|
+
* explorer — ⏸ 停用中(2026-08-14)。研究员(搜索 + 读资料 + 验证事实)
|
|
7
|
+
* vision-checker — 截图 + a11y / 视觉合理性评审(C14 真实 prompt 在 vision-checker.md)
|
|
8
|
+
* ds-extractor — 抽 design system tokens(C15 真实 prompt + design-system.json schema)
|
|
9
|
+
* tweak-proposer — 推可调 slider schema(C16 真实 prompt + tweak-schema.json schema)
|
|
10
|
+
*
|
|
11
|
+
* 调用:main agent 用 Task 工具调(SDK 自动暴露)。
|
|
12
|
+
* **注意**:'Task' 必须在主 agent 的 toolAllowlist 里(session-loop.js DEFAULT_TOOL_ALLOWLIST)
|
|
13
|
+
* 否则 SDK 拒绝调用,所有子代理形同摆设。
|
|
14
|
+
*
|
|
15
|
+
* P0+ stage 1 范围:
|
|
16
|
+
* - 只挂定义骨架,main agent 通过 SKILL.md 引导**不主动调**这些子代理
|
|
17
|
+
* - 真调用流程留 stage 2(用户测试 + 真接通 H/F 流时再发力)
|
|
18
|
+
* - prompt 在 C14-C16 用 .md 文件填实,本 commit 用占位短句
|
|
19
|
+
*
|
|
20
|
+
* AgentDefinition 字段(sdk.d.ts:38):
|
|
21
|
+
* description: string 自然语言描述何时该用
|
|
22
|
+
* tools?: string[] 允许的工具,omit 继承父 agent
|
|
23
|
+
* disallowedTools?: string[]
|
|
24
|
+
* prompt: string system prompt
|
|
25
|
+
* model?: string alias 或 full id;'inherit' / omit 沿父
|
|
26
|
+
* mcpServers?: AgentMcpServerSpec[]
|
|
27
|
+
* skills?: string[]
|
|
28
|
+
* initialPrompt?: string 首条自动 user 消息
|
|
29
|
+
* maxTurns?: number
|
|
30
|
+
* background?: boolean true = fire-and-forget 不阻塞
|
|
31
|
+
* memory?: 'user' | 'project' | 'local'
|
|
32
|
+
* effort?: EffortLevel | number
|
|
33
|
+
* permissionMode?: PermissionMode
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
import fs from 'node:fs';
|
|
37
|
+
import path from 'node:path';
|
|
38
|
+
import { fileURLToPath } from 'node:url';
|
|
39
|
+
import { resolveModelRoute } from '../agent/model-context.js';
|
|
40
|
+
|
|
41
|
+
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 同步读 agents/<name>.md 作为 agent prompt。模块加载时一次性读完,
|
|
45
|
+
* 后续每次 createAgents() 复用 cache,避免 spawn 时 IO。
|
|
46
|
+
*
|
|
47
|
+
* 缺失或读失败时降级到 STUB_PROMPT —— SDK 不至于 crash,main agent
|
|
48
|
+
* 调用时收到说明文字。
|
|
49
|
+
*/
|
|
50
|
+
const PROMPT_CACHE = {};
|
|
51
|
+
function loadPrompt(name) {
|
|
52
|
+
if (PROMPT_CACHE[name] !== undefined) return PROMPT_CACHE[name];
|
|
53
|
+
const file = path.join(HERE, `${name}.md`);
|
|
54
|
+
try {
|
|
55
|
+
PROMPT_CACHE[name] = fs.readFileSync(file, 'utf8');
|
|
56
|
+
} catch (err) {
|
|
57
|
+
console.warn(`[agents] failed to load ${name}.md (${err.message}); using stub`);
|
|
58
|
+
PROMPT_CACHE[name] = STUB_PROMPT(name);
|
|
59
|
+
}
|
|
60
|
+
return PROMPT_CACHE[name];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const STUB_PROMPT = (name) =>
|
|
64
|
+
`(P0+ stage 1 placeholder for ${name} agent. agents/${name}.md not found — `
|
|
65
|
+
+ `the file should ship with this commit. If you're an agent reading this, `
|
|
66
|
+
+ `report "agents/${name}.md missing" and stop.)`;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 给定主 model,挑一个搭配的快速 model(subagent + SDK helper 共用)。
|
|
70
|
+
*
|
|
71
|
+
* 2026-08-19 起查表:API 通路模型的 fastModel 在 model-context.js 表里逐行配
|
|
72
|
+
* (必须同表可路由 —— 订阅 haiku 在 API 模式会 404,旧的 DMXAPI haiku-cc
|
|
73
|
+
* 硬编码就是"换了 api 之后 helper 起不来"的病根之一)。订阅模型沿用主 model
|
|
74
|
+
* 自己(不强制降级避免拼错模型名导致 404)。env NODESIGN_FAST_MODEL 显式覆盖
|
|
75
|
+
* 只对订阅路生效,见 session-loop 的通路注释。
|
|
76
|
+
*/
|
|
77
|
+
export function resolveDefaultFastModel(mainModel) {
|
|
78
|
+
if (!mainModel) return null;
|
|
79
|
+
const route = resolveModelRoute(mainModel);
|
|
80
|
+
return route.mode === 'api' ? route.fastModel : mainModel;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 按 role 决定子代理 model。
|
|
85
|
+
*
|
|
86
|
+
* - **structural / search 类**(explorer / ds-extractor / tweak-proposer)→ subModel
|
|
87
|
+
* 功能是搜外链 / 抽 token / 推 slider,capability 不需跟主同级,走 fast model 省成本。
|
|
88
|
+
*
|
|
89
|
+
* - **judgment 类**(vision-checker)→ sdkSpoofMain
|
|
90
|
+
* 视觉评审要看出 plan compliance / palette match / 反 AI 套路这些细节,
|
|
91
|
+
* capability 必须跟主 agent 同级——直接喂主 agent **SDK 视角的 model**
|
|
92
|
+
* (Kimi 主时是 spoofing alias `claude-opus-4-7[1m]`,SDK 信 1M context;
|
|
93
|
+
* binary-fixup-proxy 出口反向还原成真 `kimi-k2.6` 给 gateway)。
|
|
94
|
+
*
|
|
95
|
+
* 绕开两个坑:
|
|
96
|
+
* 1. memory part4 — 喂 SDK 真 `kimi-k2.6` → SDK 不识别 → rawMaxTokens
|
|
97
|
+
* fallback 200k → 子代理 context window 被腰斩
|
|
98
|
+
* 2. memory feedback_kimi_split_messages — `'inherit'` 字面虽被 retract 为非
|
|
99
|
+
* root cause,但从未独立验证过;走"具体 sdkModel id 直传"绕开字面解析路径
|
|
100
|
+
*/
|
|
101
|
+
function pickAgentModel(role, { sdkSpoofMain, subModel }) {
|
|
102
|
+
if (role === 'vision-checker') return sdkSpoofMain || subModel;
|
|
103
|
+
return subModel;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 创建 agents 配置 —— 喂给 query options.agents 字段。
|
|
108
|
+
*
|
|
109
|
+
* @param {object} [opts]
|
|
110
|
+
* @param {string} [opts.mainModel] 主 agent appModel(如 'kimi-k2.6')
|
|
111
|
+
* @param {string} [opts.sdkModel] 主 agent SDK 视角 model(spoofing 后的 alias,如 'claude-opus-4-7[1m]')。
|
|
112
|
+
* 缺省 = mainModel(非 Kimi 主时两者本就相等)。vision-checker 用这个。
|
|
113
|
+
* @param {string} [opts.fastModel] 显式覆盖 fast model;优先级:fastModel > NODESIGN_FAST_MODEL > resolveDefaultFastModel(mainModel)
|
|
114
|
+
* @returns {Record<string, AgentDefinition>}
|
|
115
|
+
*/
|
|
116
|
+
export function createAgents({ mainModel, sdkModel, fastModel } = {}) {
|
|
117
|
+
const subModel = fastModel
|
|
118
|
+
|| process.env.NODESIGN_FAST_MODEL
|
|
119
|
+
|| resolveDefaultFastModel(mainModel)
|
|
120
|
+
|| mainModel
|
|
121
|
+
|| 'claude-haiku-4-5';
|
|
122
|
+
// sdkSpoofMain:vision-checker 用的"主 agent SDK 视角 model"。
|
|
123
|
+
// 调用方未传 sdkModel 时 fallback 到 mainModel(非 Kimi 主时两者相等无害)。
|
|
124
|
+
const sdkSpoofMain = sdkModel || mainModel;
|
|
125
|
+
return {
|
|
126
|
+
// explorer —— 研究员子代理。主 agent 在做 deck/产物时遇到"需要外部素材
|
|
127
|
+
// / 参考 / 事实验证" 就 Task 派给它。它去搜 + 读 + 总结,给主 agent 一份
|
|
128
|
+
// 结构化研究报告(URLs / 字体 / 数据 / 趋势)。主 agent 拿报告直接 Edit
|
|
129
|
+
// canvas.html 用,不必自己分心去搜。
|
|
130
|
+
//
|
|
131
|
+
// tools 显式收窄到 read-only researcher:
|
|
132
|
+
// - mcp__nodesign__web_search(多 provider 联网搜)
|
|
133
|
+
// - mcp__nodesign__screenshot_url(外站截图 —— 找视觉参考要能看见视觉,
|
|
134
|
+
// 2026-07-29 前只能 WebFetch 文本转述"这个站是深色的",等于瞎子摸象)
|
|
135
|
+
// - WebFetch(SDK 内置,按 prompt 总结 URL 内容)
|
|
136
|
+
// - Read / Glob / Grep(看本地 ./assets 和 ./spec.json)
|
|
137
|
+
// - TodoWrite(多步研究列计划)
|
|
138
|
+
// 不给:Write/Edit(不写代码)/ Bash(不要 shell shenanigans)/
|
|
139
|
+
// AskUserQuestion(子代理不直接跟用户说话)/ screenshot/export/
|
|
140
|
+
// record_decision(不是它的角色)/ Task(不允许嵌套子代理)
|
|
141
|
+
// ⏸ explorer 研究员(2026-08-14 用户暂时停用:"有点没用")。定义与
|
|
142
|
+
// prompt(explorer.md)原样保留,恢复 = 取消注释 + prelude 补回子代理
|
|
143
|
+
// 清单那两行。停用期间搜索/读外链由主 agent 直接用 web_search / WebFetch。
|
|
144
|
+
// explorer: {
|
|
145
|
+
// description: 'Research/explorer subagent. …',
|
|
146
|
+
// prompt: loadPrompt('explorer'),
|
|
147
|
+
// model: pickAgentModel('explorer', { sdkSpoofMain, subModel }),
|
|
148
|
+
// tools: [
|
|
149
|
+
// 'mcp__nodesign__web_search', 'mcp__nodesign__screenshot_url',
|
|
150
|
+
// 'WebFetch', 'Read', 'Glob', 'Grep', 'TodoWrite',
|
|
151
|
+
// ],
|
|
152
|
+
// // maxTurns 12 的来历:8 轮在真实多维 brief 上会被 SDK 硬掐断流
|
|
153
|
+
// // (2026-08-05 两次报告全损),提级 + explorer.md「随手记」纪律。
|
|
154
|
+
// maxTurns: 12,
|
|
155
|
+
// },
|
|
156
|
+
|
|
157
|
+
'vision-checker': {
|
|
158
|
+
description:
|
|
159
|
+
'Visually inspect the current canvas.html design via screenshot. '
|
|
160
|
+
+ 'Use this when you need an independent second-pair-of-eyes review on '
|
|
161
|
+
+ 'whether the design looks right — alignment, contrast, hierarchy, spacing, '
|
|
162
|
+
+ 'a11y readability, and (when design-plan.md exists) per-page plan compliance. '
|
|
163
|
+
+ 'Returns a structured per-page critique with concrete fix suggestions.',
|
|
164
|
+
prompt: loadPrompt('vision-checker'),
|
|
165
|
+
// judgment 类——视觉评审 capability 必须跟主 agent 同级,走 sdkSpoofMain
|
|
166
|
+
// (Kimi 主时是 'claude-opus-4-7[1m]' alias,SDK 信 1M context;proxy 出口
|
|
167
|
+
// 反向还原成真 'kimi-k2.6' 给 gateway)。详见 pickAgentModel 注释。
|
|
168
|
+
model: pickAgentModel('vision-checker', { sdkSpoofMain, subModel }),
|
|
169
|
+
// 显式列 tools:read-only 视觉评审需要的最小集合。
|
|
170
|
+
// SDK doc 说"omit tools 继承父" 但跨 mcp 工具的继承行为不确定(explorer 也
|
|
171
|
+
// 显式列 mcp__nodesign__web_search 是同样的稳妥做法)。Phase 1.1 audit 后
|
|
172
|
+
// 改成显式声明,保证 vision-checker.md 里写的 mcp__nodesign__screenshot_canvas
|
|
173
|
+
// 真实可调。
|
|
174
|
+
//
|
|
175
|
+
// 2026-05-10:新增 list_pages(枚举页数 → 决定循环 pageIndex 上界)+
|
|
176
|
+
// TodoWrite(多步逐页评审编排,让前端可见 vision-checker 在做啥)。
|
|
177
|
+
tools: [
|
|
178
|
+
'mcp__nodesign__screenshot_canvas',
|
|
179
|
+
'mcp__nodesign__list_pages',
|
|
180
|
+
'Read', 'Glob',
|
|
181
|
+
'TodoWrite',
|
|
182
|
+
],
|
|
183
|
+
// maxTurns:逐页评审下界估算 = 1 (Read plan) + 1 (list_pages) + 1
|
|
184
|
+
// (fullPage 总览) + N (per-page 截图) + 1-2 (think + report)。N 页 deck
|
|
185
|
+
// 至少 N+5 turn。16 容纳到 ~10 页 deck;超长 deck 主 agent 应 prompt
|
|
186
|
+
// 里点名分批评审。
|
|
187
|
+
maxTurns: 16,
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
'ds-extractor': {
|
|
191
|
+
description:
|
|
192
|
+
'Extract a design system spec (color tokens, type scale, spacing scale, '
|
|
193
|
+
+ 'shadow tokens, border radius) from the current canvas.html. Returns a '
|
|
194
|
+
+ 'JSON document conformant to schemas/design-system.json. '
|
|
195
|
+
+ 'Use this when the user asks "抽 design system" / "extract design tokens" / '
|
|
196
|
+
+ '"capture the visual rules" — typically right before reusing the style.',
|
|
197
|
+
prompt: loadPrompt('ds-extractor'),
|
|
198
|
+
// SDK AgentDefinition 没有 outputFormat 字段(query options 级别才有)。
|
|
199
|
+
// 子代理走 prompt 内嵌 JSON Schema 引导输出,main agent 收到后 JSON.parse。
|
|
200
|
+
// schema 文件在 agents/schemas/design-system.json,prompt 里有完整摘录。
|
|
201
|
+
// structural 类(结构化抽 token),走 fast model
|
|
202
|
+
model: pickAgentModel('ds-extractor', { sdkSpoofMain, subModel }),
|
|
203
|
+
tools: [
|
|
204
|
+
'Read', 'Glob', 'Grep',
|
|
205
|
+
'mcp__nodesign__list_pages',
|
|
206
|
+
'mcp__nodesign__read_page',
|
|
207
|
+
'mcp__nodesign__get_computed_styles',
|
|
208
|
+
],
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
'tweak-proposer': {
|
|
212
|
+
description:
|
|
213
|
+
'Propose 4–10 tweakable dimensions of the current canvas (e.g., heading '
|
|
214
|
+
+ 'scale, spacing density, accent color, corner style). Returns JSON '
|
|
215
|
+
+ 'conformant to schemas/tweak-schema.json — the frontend renders each '
|
|
216
|
+
+ 'tweak as slider / select / color picker / toggle. Use this when the '
|
|
217
|
+
+ 'user wants to fine-tune without rewriting.',
|
|
218
|
+
prompt: loadPrompt('tweak-proposer'),
|
|
219
|
+
// 同 ds-extractor:SDK 不支持 per-agent outputFormat,schema 内嵌 prompt
|
|
220
|
+
// structural 类(schema 推导),走 fast model
|
|
221
|
+
model: pickAgentModel('tweak-proposer', { sdkSpoofMain, subModel }),
|
|
222
|
+
tools: [
|
|
223
|
+
'Read', 'Glob',
|
|
224
|
+
'mcp__nodesign__list_pages',
|
|
225
|
+
'mcp__nodesign__read_page',
|
|
226
|
+
'mcp__nodesign__expose_tweaks',
|
|
227
|
+
],
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
}
|