@logictan/dsh-stitch-designer 2.0.4 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -5
- package/lib/canvas.js +30 -8
- package/lib/guidance.js +5 -1
- package/lib/index.js +41 -21
- package/lib/tools.js +111 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @logictan/dsh-stitch-designer
|
|
2
2
|
|
|
3
3
|
Google Stitch (AI UI generation) inside DSH: Stitch's own `mcp__stitch__*` tools,
|
|
4
|
-
one local addition (`
|
|
4
|
+
one local addition (`remove_screens_from_canvas`), plus the design conventions
|
|
5
5
|
that keep one code project bound to one Stitch project.
|
|
6
6
|
|
|
7
7
|
Ported from [liuxinlongwa-hue/dsh-stitch-designer](https://github.com/liuxinlongwa-hue/dsh-stitch-designer)
|
|
@@ -30,7 +30,7 @@ The tool list is read from Stitch at activation, not copied into this package,
|
|
|
30
30
|
so a tool Stitch adds or renames shows up without a code change. A call budget
|
|
31
31
|
of 180s covers `generate_screen_from_text`, which is long-running.
|
|
32
32
|
|
|
33
|
-
### `
|
|
33
|
+
### `remove_screens_from_canvas` — the one tool Stitch does not offer
|
|
34
34
|
|
|
35
35
|
Stitch has no screen-delete API. `stitch delete screen` answers
|
|
36
36
|
`UNSUPPORTED_RESOURCE / "Stitch screens do not support delete."`, and
|
|
@@ -40,8 +40,17 @@ either, so this is not a capability the bridge failed to expose.
|
|
|
40
40
|
|
|
41
41
|
What the service does accept is a project-level rewrite of the canvas:
|
|
42
42
|
`PATCH /v1/projects/<id>?updateMask=screenInstances` with the instance list
|
|
43
|
-
minus
|
|
44
|
-
small REST transport (`src/canvas.js`) alongside the MCP one.
|
|
43
|
+
minus the unwanted entries. That is what this tool does, and it is why the
|
|
44
|
+
plugin carries a small REST transport (`src/canvas.js`) alongside the MCP one.
|
|
45
|
+
|
|
46
|
+
Removal is **batch by construction, not by looping**: the canvas is a single
|
|
47
|
+
field, so N ids cost one GET and one PATCH. Looping would mean N
|
|
48
|
+
read-modify-write cycles and a lost removal whenever two of them raced. Passing
|
|
49
|
+
a single id in the list is simply the one-element case.
|
|
50
|
+
|
|
51
|
+
Ids that are not on the canvas do not fail the call: the ones that are get
|
|
52
|
+
removed, and the leftovers come back in the result so the caller can see them.
|
|
53
|
+
When *none* of the ids is on the canvas the tool raises instead of writing.
|
|
45
54
|
|
|
46
55
|
The screen object is not destroyed — it stays addressable at
|
|
47
56
|
`GET /v1/projects/<p>/screens/<s>` — but it leaves the project, which is what
|
|
@@ -50,7 +59,7 @@ route at all (the canvas `label` is a separate field and does not change the
|
|
|
50
59
|
screen `title`), so this plugin offers no rename tool.
|
|
51
60
|
|
|
52
61
|
```
|
|
53
|
-
|
|
62
|
+
mcp__stitch__remove_screens_from_canvas { projectId, screenIds: [screenId, ...] }
|
|
54
63
|
```
|
|
55
64
|
|
|
56
65
|
## Settings
|
package/lib/canvas.js
CHANGED
|
@@ -86,28 +86,48 @@ export function createCanvasClient(options = {}) {
|
|
|
86
86
|
|
|
87
87
|
return {
|
|
88
88
|
/**
|
|
89
|
-
* Take one
|
|
89
|
+
* Take one or more screens off a project's canvas.
|
|
90
|
+
*
|
|
91
|
+
* Batch is the primitive: the canvas is a single field, so every removal is
|
|
92
|
+
* absorbed into ONE read-modify-write cycle and therefore one PATCH, however
|
|
93
|
+
* many ids are given. Removing one screen is simply the one-element case.
|
|
90
94
|
*
|
|
91
95
|
* @param projectId - the project id (bare, without the `projects/` prefix).
|
|
92
|
-
* @param
|
|
96
|
+
* @param screenIds - screen ids to remove; the bare ids from `list_screens`.
|
|
93
97
|
* @param exec - the tool execution context, whose signal is honoured.
|
|
94
|
-
* @returns the project after the write
|
|
98
|
+
* @returns the project after the write, plus which ids were removed and
|
|
99
|
+
* which were not on the canvas.
|
|
100
|
+
* @throws when no id is given, or when none of them is on the canvas.
|
|
95
101
|
*/
|
|
96
|
-
async
|
|
102
|
+
async removeScreens(projectId, screenIds, exec) {
|
|
103
|
+
const requested = Array.isArray(screenIds) ? screenIds.filter((id) => typeof id === 'string' && id !== '') : [];
|
|
104
|
+
if (requested.length === 0) {
|
|
105
|
+
throw new Error(
|
|
106
|
+
'No screen id was given: pass at least one screen id in screenIds. ' +
|
|
107
|
+
'Run list_screens to see the screens this project currently holds.',
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
97
111
|
const apiKey = await requireKey();
|
|
98
112
|
const projectUrl = `${url}/projects/${projectId}`;
|
|
99
113
|
|
|
100
114
|
const project = await request({ method: 'GET', url: projectUrl, apiKey, timeoutMs, signal: exec?.signal });
|
|
101
115
|
const instances = Array.isArray(project?.screenInstances) ? project.screenInstances : [];
|
|
102
|
-
const
|
|
103
|
-
|
|
116
|
+
const screenIdOf = (instance) => String(instance?.sourceScreen ?? '').split('/screens/').pop() ?? '';
|
|
117
|
+
|
|
118
|
+
const kept = instances.filter((instance) => !requested.includes(screenIdOf(instance)));
|
|
119
|
+
const present = instances.map(screenIdOf);
|
|
120
|
+
const removed = requested.filter((id) => present.includes(id));
|
|
121
|
+
const missing = requested.filter((id) => !present.includes(id));
|
|
122
|
+
|
|
123
|
+
if (removed.length === 0) {
|
|
104
124
|
throw new Error(
|
|
105
|
-
`
|
|
125
|
+
`None of the given screen ids is on the canvas of project ${projectId}, so there is nothing to remove. ` +
|
|
106
126
|
'Run list_screens to see the screens this project currently holds.',
|
|
107
127
|
);
|
|
108
128
|
}
|
|
109
129
|
|
|
110
|
-
|
|
130
|
+
const updated = await request({
|
|
111
131
|
method: 'PATCH',
|
|
112
132
|
url: `${projectUrl}?updateMask=screenInstances`,
|
|
113
133
|
apiKey,
|
|
@@ -115,6 +135,8 @@ export function createCanvasClient(options = {}) {
|
|
|
115
135
|
timeoutMs,
|
|
116
136
|
signal: exec?.signal,
|
|
117
137
|
});
|
|
138
|
+
|
|
139
|
+
return { ...updated, removed, missing };
|
|
118
140
|
},
|
|
119
141
|
};
|
|
120
142
|
}
|
package/lib/guidance.js
CHANGED
|
@@ -38,7 +38,11 @@ export const SECTION_ORDER = 150;
|
|
|
38
38
|
* acted on.
|
|
39
39
|
*/
|
|
40
40
|
export const STITCH_GUIDANCE = [
|
|
41
|
-
'本机已安装 dsh-stitch-designer 插件(Google Stitch AI 界面设计):提供 Stitch 原生工具(数量随上游变化,含建/删/列项目、列/取界面、生成界面、改界面、生成变体、设计系统、设计稿上传与文件下载),以及 1 个本插件自建的 `
|
|
41
|
+
'本机已安装 dsh-stitch-designer 插件(Google Stitch AI 界面设计):提供 Stitch 原生工具(数量随上游变化,含建/删/列项目、列/取界面、生成界面、改界面、生成变体、设计系统、设计稿上传与文件下载),以及 1 个本插件自建的 `mcp__stitch__remove_screens_from_canvas`(把一张或多张 screen 从项目画布上移除;传一个 id 就是删一张——Stitch 没有删除单张 screen 的接口)。',
|
|
42
|
+
'',
|
|
43
|
+
'下面这些工具的参数只有一两个字符串(项目 id、screen id、标题、文件名),所以它们的参数表不进提示词,但工具本身照常可调用——直接按名调用即可:`mcp__stitch__list_projects`、`mcp__stitch__get_project`(`name` 传 `projects/<id>`)、`mcp__stitch__create_project`(`title`)、`mcp__stitch__delete_project`(`name`)、`mcp__stitch__list_screens`(`projectId`)、`mcp__stitch__get_screen`(`name` 传 `projects/<id>/screens/<id>`)、`mcp__stitch__list_design_systems`(`projectId`)、`mcp__stitch__download_file`(`name` 取 screen 的 `html_code.name` 或 `screenshot.name`)、`mcp__stitch__remove_screens_from_canvas`(`projectId` + `screenIds` 数组)。',
|
|
44
|
+
'',
|
|
45
|
+
'参数结构复杂的那几只(`create_design_system`、`update_design_system`、`apply_design_system`、`generate_screen_from_text`、`edit_screens`、`generate_variants`、`upload_design_md`、`create_design_system_from_design_md`)参数表保持完整,按提示词里的说明填即可。',
|
|
42
46
|
'',
|
|
43
47
|
'用 Stitch 设计稿实现界面时,遵守以下规范:',
|
|
44
48
|
'1. 一个代码项目只对应一个 Stitch 项目,对应关系记录在该代码项目根目录的 `.stitch.json`。继续沿用已记录的那个项目,不要为同一个代码项目再调 `create_project`——插件会直接报错拒绝,并告知已绑定的项目 id。记录指向的 Stitch 项目已被删除时,插件会自动清掉记录,可重新创建。',
|
package/lib/index.js
CHANGED
|
@@ -41,7 +41,7 @@ import { createCanvasClient } from './canvas.js';
|
|
|
41
41
|
import { createStitchClient } from './stitch.js';
|
|
42
42
|
import { createInvoker } from './conventions.js';
|
|
43
43
|
import { SECTION_NAME, SECTION_ORDER, STITCH_GUIDANCE } from './guidance.js';
|
|
44
|
-
import { createOutput, createToolDefinition, publicToolName } from './tools.js';
|
|
44
|
+
import { createOutput, createToolDefinition, publicToolName, withoutWithdrawn } from './tools.js';
|
|
45
45
|
|
|
46
46
|
/** Plugin row id; must equal the row id in `cordis.patch.yml`. */
|
|
47
47
|
export const name = 'stitch-designer';
|
|
@@ -58,6 +58,9 @@ export const API_KEY_REF = 'STITCH_API_KEY';
|
|
|
58
58
|
/** Server namespace embedded in every public tool name (`mcp__stitch__*`). */
|
|
59
59
|
export const SERVER_NAME = 'stitch';
|
|
60
60
|
|
|
61
|
+
/** The prefix every tool this plugin registers carries, announcement filter included. */
|
|
62
|
+
const PUBLIC_PREFIX = `mcp__${SERVER_NAME}__`;
|
|
63
|
+
|
|
61
64
|
/**
|
|
62
65
|
* Register the Stitch tools and announce the design conventions.
|
|
63
66
|
*
|
|
@@ -137,19 +140,23 @@ export function apply(ctx) {
|
|
|
137
140
|
sync().catch(report);
|
|
138
141
|
});
|
|
139
142
|
|
|
140
|
-
// `
|
|
143
|
+
// `remove_screens_from_canvas` is local, not upstream: Stitch has no
|
|
141
144
|
// screen-delete route (`stitch delete screen` answers
|
|
142
145
|
// `UNSUPPORTED_RESOURCE`, `DELETE .../screens/<id>` answers 404), so the
|
|
143
|
-
// bridge performs the removal itself through
|
|
146
|
+
// bridge performs the removal itself through one project-level PATCH. The
|
|
147
|
+
// tool takes a list because the canvas is one field: N removals are one
|
|
148
|
+
// write, and a single removal is just the one-element list. It is
|
|
144
149
|
// registered here unconditionally because it needs no `tools/list` to
|
|
145
150
|
// describe it — its contract is this file's.
|
|
146
151
|
const removeScreenDispose = tools.register({
|
|
147
|
-
name: publicToolName(SERVER_NAME, '
|
|
152
|
+
name: publicToolName(SERVER_NAME, 'remove_screens_from_canvas'),
|
|
148
153
|
description:
|
|
149
|
-
'Remove one
|
|
150
|
-
+ 'rewrites the project\'s canvas without
|
|
151
|
-
+ '
|
|
152
|
-
+ '
|
|
154
|
+
'Remove one or more screens from a Stitch project canvas. Stitch has no screen-delete API, so '
|
|
155
|
+
+ 'this rewrites the project\'s canvas without those screens — always in a single write, '
|
|
156
|
+
+ 'however many ids you pass. The screen objects themselves are not destroyed; they disappear '
|
|
157
|
+
+ 'from the project, which is what clears abandoned screens out. Use '
|
|
158
|
+
+ 'mcp__stitch__list_screens to find screen ids first. Ids that are not on the canvas are '
|
|
159
|
+
+ 'reported back rather than failing the whole call.',
|
|
153
160
|
parameters: {
|
|
154
161
|
type: 'object',
|
|
155
162
|
properties: {
|
|
@@ -157,25 +164,26 @@ export function apply(ctx) {
|
|
|
157
164
|
type: 'string',
|
|
158
165
|
description: 'Stitch project id (bare id, not "projects/<id>").',
|
|
159
166
|
},
|
|
160
|
-
|
|
161
|
-
type: '
|
|
162
|
-
|
|
167
|
+
screenIds: {
|
|
168
|
+
type: 'array',
|
|
169
|
+
items: { type: 'string' },
|
|
170
|
+
description: 'Ids of the screens to remove from the canvas. One id is the normal single-removal case.',
|
|
163
171
|
},
|
|
164
172
|
},
|
|
165
|
-
required: ['projectId', '
|
|
173
|
+
required: ['projectId', 'screenIds'],
|
|
166
174
|
},
|
|
167
175
|
output: createOutput(undefined),
|
|
168
176
|
async execute(args, exec) {
|
|
169
|
-
const result = await canvas.
|
|
177
|
+
const result = await canvas.removeScreens(args.projectId, args.screenIds, exec);
|
|
170
178
|
const remaining = Array.isArray(result?.screenInstances) ? result.screenInstances.length : 0;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
};
|
|
179
|
+
const lines = [
|
|
180
|
+
`Removed ${result.removed.length} screen(s) from project ${args.projectId}: ${result.removed.join(', ')}.`,
|
|
181
|
+
`The canvas now holds ${remaining} screen(s).`,
|
|
182
|
+
];
|
|
183
|
+
if (result.missing.length > 0) {
|
|
184
|
+
lines.push(`Not on the canvas (left alone): ${result.missing.join(', ')}.`);
|
|
185
|
+
}
|
|
186
|
+
return { content: [{ type: 'text', text: lines.join(' ') }] };
|
|
179
187
|
},
|
|
180
188
|
});
|
|
181
189
|
|
|
@@ -189,6 +197,18 @@ export function apply(ctx) {
|
|
|
189
197
|
}, 'stitch-designer: Stitch tools');
|
|
190
198
|
});
|
|
191
199
|
|
|
200
|
+
// ------------------------------------------------------------ annotation
|
|
201
|
+
// The withdrawn half of the toolset (see `ANNOUNCED_TOOLS`): registered and
|
|
202
|
+
// executable, absent from every request's tool list. Filtering by the public
|
|
203
|
+
// name prefix rather than by a captured registration set keeps this correct
|
|
204
|
+
// when `tools/list` fails at boot and the tools appear later on a credential
|
|
205
|
+
// update — the names are the contract, the set of them is not.
|
|
206
|
+
ctx.on('system-prompt/assemble', async (_assembly, _context, next) => {
|
|
207
|
+
const assembly = await next();
|
|
208
|
+
const tools = withoutWithdrawn(assembly.tools, PUBLIC_PREFIX);
|
|
209
|
+
return tools === assembly.tools ? assembly : { ...assembly, tools };
|
|
210
|
+
});
|
|
211
|
+
|
|
192
212
|
// ------------------------------------------------------------- guidance
|
|
193
213
|
// The design conventions that cannot be enforced are announced instead, the
|
|
194
214
|
// way this repository delivers every other non-computable rule. Read through
|
package/lib/tools.js
CHANGED
|
@@ -10,13 +10,15 @@
|
|
|
10
10
|
* Two measured facts drive every choice here (probed against the live
|
|
11
11
|
* `tools/list` of 2026-10-08, all 15 tools):
|
|
12
12
|
*
|
|
13
|
-
* - `parameters` is passed through VERBATIM
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* - `parameters` is passed through VERBATIM, minus the two `x-google-*` fields
|
|
14
|
+
* {@link PROMPT_ONLY_EXTENSIONS} names. `ToolRuntime.register` validates only
|
|
15
|
+
* `output.schema`; it never inspects `definition.parameters`. Stitch's input
|
|
16
|
+
* schemas carry `$defs` / `$ref` / `x-google-*` (11 of 15 fail
|
|
16
17
|
* `assertSupportedJsonSchema`), so routing them through `defineTool` — which
|
|
17
18
|
* validates its `parameters` at construction — would throw for 11 tools.
|
|
18
|
-
* Registering the
|
|
19
|
-
* shape that keeps the upstream contract intact for the model
|
|
19
|
+
* Registering the upstream schema is therefore not a shortcut, it is the only
|
|
20
|
+
* shape that keeps the upstream contract intact for the model; the two fields
|
|
21
|
+
* removed on top of it are prompt weight the model cannot act on.
|
|
20
22
|
* - `output.schema` IS validated, both at registration and again on every
|
|
21
23
|
* result (`createSuccessResult`). 13 of Stitch's 15 advertised
|
|
22
24
|
* `outputSchema`s are outside the accepted subset, so they must be dropped
|
|
@@ -59,6 +61,107 @@ export function publicToolName(serverName, rawName) {
|
|
|
59
61
|
return `${normalized.slice(0, MAX_PUBLIC_NAME_LENGTH - HASH_LENGTH - 1)}_${hash}`;
|
|
60
62
|
}
|
|
61
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Stitch tools whose definitions stay in the prompt; every other one is withdrawn.
|
|
66
|
+
*
|
|
67
|
+
* Measured on the live `tools/list` (2026-11-11): the 17 definitions cost 45,680
|
|
68
|
+
* characters of a 180,629-character first request, and across 651 local sessions
|
|
69
|
+
* the two heaviest were called twice. Withdrawing a definition from the prompt
|
|
70
|
+
* does not unregister the tool — execution resolves through the registry's layer
|
|
71
|
+
* visibility, not through the assembly — so a model that names one still gets it
|
|
72
|
+
* run; what it loses is the schema, which for simple string-id tools is not the
|
|
73
|
+
* thing that decides whether the call is right.
|
|
74
|
+
*
|
|
75
|
+
* The split follows that test, not usage: a tool stays announced when its
|
|
76
|
+
* arguments are structures the model cannot guess (a `DesignSystem`,
|
|
77
|
+
* a `VariantOptions`, a `screenInstances` entry), and is withdrawn when they are
|
|
78
|
+
* a project id, a screen id, a title or a prompt — all of which the guidance
|
|
79
|
+
* section spells out. The two design-system writers alone are 15,815 characters,
|
|
80
|
+
* so keeping them announced is what makes the split worth anything.
|
|
81
|
+
*/
|
|
82
|
+
export const ANNOUNCED_TOOLS = new Set([
|
|
83
|
+
'create_design_system',
|
|
84
|
+
'create_design_system_from_design_md',
|
|
85
|
+
'apply_design_system',
|
|
86
|
+
'upload_design_md',
|
|
87
|
+
'generate_screen_from_text',
|
|
88
|
+
'edit_screens',
|
|
89
|
+
'generate_variants',
|
|
90
|
+
]);
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Whether one upstream Stitch tool keeps its definition in the prompt.
|
|
94
|
+
*
|
|
95
|
+
* @param rawName - Stitch's own tool name.
|
|
96
|
+
* @returns `true` when the definition is announced.
|
|
97
|
+
*/
|
|
98
|
+
export function isAnnounced(rawName) {
|
|
99
|
+
return ANNOUNCED_TOOLS.has(rawName);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Drop the withdrawn Stitch definitions from an assembled tool list.
|
|
104
|
+
*
|
|
105
|
+
* Names outside the `mcp__<server>__` namespace pass through untouched: the
|
|
106
|
+
* assembly holds every provider's tools, and only this plugin's are its to
|
|
107
|
+
* remove. The prefix test is against the public name, not a captured
|
|
108
|
+
* registration set, so a `tools/list` that failed at boot and succeeded later on
|
|
109
|
+
* a credential update still gets filtered.
|
|
110
|
+
*
|
|
111
|
+
* @param tools - the assembly's tool definitions.
|
|
112
|
+
* @param prefix - the public-name prefix this plugin registers under.
|
|
113
|
+
* @returns the same array when nothing was withdrawn, otherwise a filtered copy.
|
|
114
|
+
*/
|
|
115
|
+
export function withoutWithdrawn(tools, prefix) {
|
|
116
|
+
if (!Array.isArray(tools)) return tools;
|
|
117
|
+
const kept = tools.filter(
|
|
118
|
+
(tool) => typeof tool?.name !== 'string' || !tool.name.startsWith(prefix) || isAnnounced(tool.name.slice(prefix.length)),
|
|
119
|
+
);
|
|
120
|
+
return kept.length === tools.length ? tools : kept;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* `x-google-*` fields the prompt pays for and the model cannot use.
|
|
125
|
+
*
|
|
126
|
+
* Measured on the live `tools/list` (2026-11-11): `create_design_system` and
|
|
127
|
+
* `update_design_system` carry 4,744 characters of `x-google-enum-descriptions`
|
|
128
|
+
* each — one English gloss per font enum value, restating the value it sits on —
|
|
129
|
+
* plus 1,460 characters of `x-google-enum-deprecated`, every entry `false`.
|
|
130
|
+
* Together 44% of each 14,000-character schema, and across 651 local sessions
|
|
131
|
+
* the pair was called twice. The enum values themselves are untouched, so the
|
|
132
|
+
* model still sees every legal font; only the glosses and the all-false flags go.
|
|
133
|
+
*/
|
|
134
|
+
const PROMPT_ONLY_EXTENSIONS = new Set(['x-google-enum-descriptions', 'x-google-enum-deprecated']);
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Copy an upstream input schema with its prompt-only extension fields removed.
|
|
138
|
+
*
|
|
139
|
+
* `parameters` is otherwise passed through verbatim (see the module note), so
|
|
140
|
+
* this is a subtraction, never a rewrite: object keys, ordering, `$defs`,
|
|
141
|
+
* `$ref`, `oneOf` and every standard keyword survive as they arrive. The schema
|
|
142
|
+
* is not validated here — the runtime does not inspect `parameters`, and
|
|
143
|
+
* Stitch's own schemas would fail `assertSupportedJsonSchema`.
|
|
144
|
+
*
|
|
145
|
+
* @param schema - the upstream `inputSchema`.
|
|
146
|
+
* @returns the same schema, or a copy without {@link PROMPT_ONLY_EXTENSIONS}.
|
|
147
|
+
*/
|
|
148
|
+
export function promptSafeInputSchema(schema) {
|
|
149
|
+
if (schema === null || typeof schema !== 'object') return schema;
|
|
150
|
+
if (Array.isArray(schema)) return schema.map(promptSafeInputSchema);
|
|
151
|
+
let changed = false;
|
|
152
|
+
const copy = {};
|
|
153
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
154
|
+
if (PROMPT_ONLY_EXTENSIONS.has(key)) {
|
|
155
|
+
changed = true;
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
const next = promptSafeInputSchema(value);
|
|
159
|
+
if (next !== value) changed = true;
|
|
160
|
+
copy[key] = next;
|
|
161
|
+
}
|
|
162
|
+
return changed ? copy : schema;
|
|
163
|
+
}
|
|
164
|
+
|
|
62
165
|
/**
|
|
63
166
|
* Keep an advertised output schema only if the runtime accepts it.
|
|
64
167
|
*
|
|
@@ -137,7 +240,8 @@ export function createOutput(structuredSchema) {
|
|
|
137
240
|
/**
|
|
138
241
|
* Adapt one upstream Stitch tool descriptor to a ToolRuntime definition.
|
|
139
242
|
*
|
|
140
|
-
* `parameters` is the raw upstream `inputSchema`
|
|
243
|
+
* `parameters` is the raw upstream `inputSchema` minus {@link PROMPT_ONLY_EXTENSIONS}
|
|
244
|
+
* (see the module note); every other field arrives as Stitch sent it. The
|
|
141
245
|
* result is unregistered; the caller owns registration lifetime.
|
|
142
246
|
*
|
|
143
247
|
* @param options - upstream descriptor fields plus the raw-result callback.
|
|
@@ -148,7 +252,7 @@ export function createToolDefinition(options) {
|
|
|
148
252
|
return {
|
|
149
253
|
name,
|
|
150
254
|
description,
|
|
151
|
-
parameters: inputSchema,
|
|
255
|
+
parameters: promptSafeInputSchema(inputSchema),
|
|
152
256
|
output: createOutput(supportedOutputSchema(outputSchema)),
|
|
153
257
|
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
|
154
258
|
async execute(args, exec) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logictan/dsh-stitch-designer",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "DSH Stitch designer: Google Stitch AI UI generation as native mcp__stitch__* tools, plus the design conventions that keep one code project bound to one Stitch project. DSH Stitch 界面设计子插件。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|