@pecot/visual-mcp 2.0.0 → 3.0.1-dev.25
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/.claude-plugin/plugin.json +1 -1
- package/README.md +3 -2
- package/assets/slidev/package.json +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/package.json +1 -1
- package/assets/slidev/scripts/eslint/text-constraints/package.json +1 -1
- package/cli/dist/domain/_shared/failure-kind.d.ts +1 -1
- package/cli/dist/domain/_shared/failure-kind.js +1 -1
- package/cli/dist/mcp/dev-server-registry.d.ts +4 -0
- package/cli/dist/mcp/dev-server-registry.js +4 -1
- package/cli/dist/mcp/result.d.ts +34 -73
- package/cli/dist/mcp/result.js +72 -76
- package/cli/dist/mcp/tools/_shared.d.ts +36 -35
- package/cli/dist/mcp/tools/_shared.js +57 -70
- package/cli/dist/mcp/tools/drawio.js +44 -63
- package/cli/dist/mcp/tools/evidence.js +9 -18
- package/cli/dist/mcp/tools/setup.js +14 -36
- package/cli/dist/mcp/tools/slide-dev.js +13 -35
- package/cli/dist/mcp/tools/slide-page.js +16 -24
- package/cli/dist/mcp/tools/slide-theme.js +3 -13
- package/cli/dist/mcp/tools/slide.d.ts +2 -2
- package/cli/dist/mcp/tools/slide.js +27 -71
- package/cli/dist/mcp/warnings.d.ts +24 -0
- package/cli/dist/mcp/warnings.js +101 -0
- package/cli/dist/mcp/windows-path.js +1 -1
- package/npm-shrinkwrap.json +27 -126
- package/package.json +2 -2
- package/vendor/text-rules/dist/source-hash +1 -1
|
@@ -19,18 +19,7 @@ import { pluginDependencyRoot } from '../../infra/_shared/dependency-root.js';
|
|
|
19
19
|
import { resolvePluginRoot } from '../../infra/_shared/plugin-root.js';
|
|
20
20
|
import { devServerRegistry } from '../dev-server-registry.js';
|
|
21
21
|
import { parsePathArguments, toCallToolResult } from '../result.js';
|
|
22
|
-
import { ensureRuntimeDependencies, runtimeDefaultDependencies, TOOL_OUTPUT_SCHEMA, WINDOWS_PATH_NOTE, } from './_shared.js';
|
|
23
|
-
/**
|
|
24
|
-
dev サーバを起動できなかったときの exit code (各コマンドの RuntimeError と同じ 1)。
|
|
25
|
-
*/
|
|
26
|
-
const DEV_SERVER_EXIT_CODE = 1;
|
|
27
|
-
/**
|
|
28
|
-
子プロセスを起こす前に諦めたルートの出力。
|
|
29
|
-
|
|
30
|
-
ToolResult の stdout / stderr が省略されるのは「捕捉していない」ときで、捕捉した結果が
|
|
31
|
-
空であることとは意味が違う (tools/_shared.ts)。実行前ガードでも捕捉相当のキーは残す。
|
|
32
|
-
*/
|
|
33
|
-
const NO_OUTPUT = { stdout: '', stderr: '' };
|
|
22
|
+
import { ensureRuntimeDependencies, runtimeDefaultDependencies, TOOL_OUTPUT_SCHEMA, WINDOWS_PATH_NOTE, withCapturedOutput, } from './_shared.js';
|
|
34
23
|
// context に AbortSignal を持つため readonly にできない。
|
|
35
24
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
36
25
|
function ensureThemeLinkedWithDefaults(directory, context) {
|
|
@@ -100,18 +89,13 @@ function inspectNodeModules(directory) {
|
|
|
100
89
|
function guardFailure(defect, directory, warnings = []) {
|
|
101
90
|
return {
|
|
102
91
|
ok: false,
|
|
103
|
-
exitCode: DEV_SERVER_EXIT_CODE,
|
|
104
92
|
kind: failureKindOf(defect.reason),
|
|
105
|
-
|
|
93
|
+
detail: defect.detail,
|
|
106
94
|
data: {
|
|
107
95
|
event: 'slide.dev.error',
|
|
108
|
-
reason: defect.reason,
|
|
109
|
-
detail: defect.detail,
|
|
110
96
|
dir: directory,
|
|
111
97
|
...(warnings.length > 0 && { warnings }),
|
|
112
98
|
},
|
|
113
|
-
message: defect.detail,
|
|
114
|
-
...NO_OUTPUT,
|
|
115
99
|
};
|
|
116
100
|
}
|
|
117
101
|
/**
|
|
@@ -136,8 +120,6 @@ export function slideDevTool(buildRegistry = devServerRegistry, buildRuntimeDepe
|
|
|
136
120
|
const stopped = buildRegistry().stop(input.dir);
|
|
137
121
|
return toCallToolResult({
|
|
138
122
|
ok: true,
|
|
139
|
-
exitCode: 0,
|
|
140
|
-
artifacts: [],
|
|
141
123
|
data: {
|
|
142
124
|
event: 'slide.dev.stopped',
|
|
143
125
|
dir: input.dir,
|
|
@@ -148,7 +130,6 @@ export function slideDevTool(buildRegistry = devServerRegistry, buildRuntimeDepe
|
|
|
148
130
|
message: stopped.stopped
|
|
149
131
|
? `slide dev: stopped (${input.dir})`
|
|
150
132
|
: `slide dev: no running server (${input.dir})`,
|
|
151
|
-
...NO_OUTPUT,
|
|
152
133
|
});
|
|
153
134
|
}
|
|
154
135
|
// 起動には @slidev/cli の bin が要る。未取得のときの失敗の型は
|
|
@@ -160,7 +141,7 @@ export function slideDevTool(buildRegistry = devServerRegistry, buildRuntimeDepe
|
|
|
160
141
|
if (defect !== undefined)
|
|
161
142
|
return toCallToolResult(guardFailure(defect, input.dir));
|
|
162
143
|
// テーマを今の値で張る。取得済みなら stamp を比べるだけで、ネットワークには出ない。
|
|
163
|
-
// 取得中の警告は応答の
|
|
144
|
+
// 取得中の警告は応答の warnings に載せ、MCP のキャンセルは取得 (git) まで届ける。
|
|
164
145
|
const warnings = [];
|
|
165
146
|
let ensured;
|
|
166
147
|
const context = {
|
|
@@ -187,21 +168,19 @@ export function slideDevTool(buildRegistry = devServerRegistry, buildRuntimeDepe
|
|
|
187
168
|
await buildRegistry().stopAndWait(input.dir);
|
|
188
169
|
const started = await buildRegistry().start(input.dir, { port: input.port, signal: call.signal });
|
|
189
170
|
if (!started.ok) {
|
|
190
|
-
return toCallToolResult({
|
|
171
|
+
return toCallToolResult(withCapturedOutput({
|
|
191
172
|
ok: false,
|
|
192
|
-
exitCode: DEV_SERVER_EXIT_CODE,
|
|
193
173
|
kind: started.reason,
|
|
194
|
-
|
|
195
|
-
data: {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
174
|
+
detail: started.detail,
|
|
175
|
+
data: {
|
|
176
|
+
event: 'slide.dev.error',
|
|
177
|
+
dir: input.dir,
|
|
178
|
+
...(warnings.length > 0 && { warnings }),
|
|
179
|
+
},
|
|
180
|
+
}, started));
|
|
200
181
|
}
|
|
201
182
|
return toCallToolResult({
|
|
202
183
|
ok: true,
|
|
203
|
-
exitCode: 0,
|
|
204
|
-
artifacts: [],
|
|
205
184
|
data: {
|
|
206
185
|
event: started.reused ? 'slide.dev.reused' : 'slide.dev.started',
|
|
207
186
|
dir: input.dir,
|
|
@@ -215,16 +194,15 @@ export function slideDevTool(buildRegistry = devServerRegistry, buildRuntimeDepe
|
|
|
215
194
|
message: started.reused
|
|
216
195
|
? `slide dev: reusing the running server ${started.url}`
|
|
217
196
|
: `slide dev: started ${started.url}`,
|
|
218
|
-
...NO_OUTPUT,
|
|
219
197
|
});
|
|
220
198
|
};
|
|
221
199
|
return {
|
|
222
200
|
name: 'slide_dev',
|
|
223
201
|
config: {
|
|
224
202
|
title: 'Start a Slidev preview',
|
|
225
|
-
description: 'Starts the Slidev dev server of a talk-dir and returns a URL that opens in a browser (
|
|
203
|
+
description: 'Starts the Slidev dev server of a talk-dir and returns a URL that opens in a browser (url). '
|
|
226
204
|
+ 'The port can be set with port; if omitted, a free port from 3030 to 3034 is used. '
|
|
227
|
-
+ 'Calling again for the same talk-dir returns the running server as it is (
|
|
205
|
+
+ 'Calling again for the same talk-dir returns the running server as it is (reused: true). '
|
|
228
206
|
+ 'Set stop: true to stop it. '
|
|
229
207
|
+ 'The server runs only while the MCP server process is alive; the preview ends with the session.',
|
|
230
208
|
inputSchema: slideDevInput,
|
|
@@ -23,10 +23,6 @@ import { extractSkeleton, isFrontmatterBlock } from '../../domain/slidev-theme/s
|
|
|
23
23
|
import { parsePathArguments, toCallToolResult } from '../result.js';
|
|
24
24
|
import { captureCommandOutput, formatError, TOOL_OUTPUT_SCHEMA, WINDOWS_PATH_NOTE, } from './_shared.js';
|
|
25
25
|
/**
|
|
26
|
-
ページを生成できなかったときの exit code (各コマンドの RuntimeError と同じ 1)。
|
|
27
|
-
*/
|
|
28
|
-
const SLIDE_PAGE_EXIT_CODE = 1;
|
|
29
|
-
/**
|
|
30
26
|
生成するページの拡張子。省略された `file` にはこれを補う。
|
|
31
27
|
*/
|
|
32
28
|
const PAGE_EXTENSION = '.md';
|
|
@@ -60,8 +56,8 @@ includes ブロック内の yaml コメント行。項目の間に挟まって
|
|
|
60
56
|
const YAML_COMMENT_REGEX = /^[ \t]*#/;
|
|
61
57
|
const slidePageInput = z.object({
|
|
62
58
|
layout: z.string()
|
|
63
|
-
.describe('Layout name. Decide the presentation style from the categories (
|
|
64
|
-
+ 'then choose from the names in
|
|
59
|
+
.describe('Layout name. Decide the presentation style from the categories (categories) in the slide_create / slide_sync response, '
|
|
60
|
+
+ 'then choose from the names in layouts that belong to that category'),
|
|
65
61
|
dir: z.string()
|
|
66
62
|
.describe('Absolute path of the talk-dir to generate the page in. Relative paths are not accepted. ' + WINDOWS_PATH_NOTE),
|
|
67
63
|
file: z.string()
|
|
@@ -70,16 +66,14 @@ const slidePageInput = z.object({
|
|
|
70
66
|
.describe('Overwrite when a page with the same name already exists'),
|
|
71
67
|
});
|
|
72
68
|
/**
|
|
73
|
-
失敗時の ToolResult (
|
|
69
|
+
失敗時の ToolResult (捕捉した出力は呼び出し側が output.finish で移す)。
|
|
74
70
|
*/
|
|
75
71
|
function failure(reason, detail, extra = {}) {
|
|
76
72
|
return {
|
|
77
73
|
ok: false,
|
|
78
|
-
exitCode: SLIDE_PAGE_EXIT_CODE,
|
|
79
74
|
kind: failureKindOf(reason),
|
|
80
|
-
|
|
81
|
-
data: { event: 'slide.page.error',
|
|
82
|
-
message: detail,
|
|
75
|
+
detail,
|
|
76
|
+
data: { event: 'slide.page.error', ...extra },
|
|
83
77
|
};
|
|
84
78
|
}
|
|
85
79
|
/**
|
|
@@ -181,7 +175,7 @@ function themeFailure(error) {
|
|
|
181
175
|
return failure(slideThemeErrorToReason(error), formatError(error));
|
|
182
176
|
}
|
|
183
177
|
/**
|
|
184
|
-
|
|
178
|
+
引数検証後の実処理。捕捉した出力は呼び出し側が output.finish で移す。
|
|
185
179
|
|
|
186
180
|
実行時依存 (永続層) と Chromium は要らない。参照 yaml の読み取りと 1 ファイルの書き込み
|
|
187
181
|
だけなので、`runtime_setup` 前の環境でも通る。
|
|
@@ -212,7 +206,7 @@ output) {
|
|
|
212
206
|
const reference = references.entries.find(candidate => candidate.name === input.layout);
|
|
213
207
|
if (entry === undefined || reference === undefined) {
|
|
214
208
|
return failure('unknown-layout', `layout not found in theme ${theme.theme.name} referenced by ${input.dir}: ${input.layout}`
|
|
215
|
-
+ '; decide the presentation style from
|
|
209
|
+
+ '; decide the presentation style from categories, then choose from layouts of that category', { categories: theme.categories, layouts: theme.layouts });
|
|
216
210
|
}
|
|
217
211
|
if (!reference.file.endsWith('.yaml')) {
|
|
218
212
|
return failure('skeleton-unavailable', `cannot write a skeleton: theme ${theme.theme.name} has no reference yaml for ${entry.layout} (references/${entry.layout}.yaml)`
|
|
@@ -251,10 +245,9 @@ output) {
|
|
|
251
245
|
throw error;
|
|
252
246
|
return failure('file-exists', `file already exists: ${target}; pass force: true to overwrite, or specify a different file`);
|
|
253
247
|
}
|
|
248
|
+
// 書いたページのパスは path の項目で返す。
|
|
254
249
|
return {
|
|
255
250
|
ok: true,
|
|
256
|
-
exitCode: 0,
|
|
257
|
-
artifacts: [target],
|
|
258
251
|
data: {
|
|
259
252
|
event: 'slide.page.done',
|
|
260
253
|
layout: entry.layout,
|
|
@@ -266,7 +259,7 @@ output) {
|
|
|
266
259
|
includes: included.includes,
|
|
267
260
|
},
|
|
268
261
|
message: `slide page: generated (${target})`
|
|
269
|
-
+ '; fill in the content following props / text_constraints in
|
|
262
|
+
+ '; fill in the content following props / text_constraints in reference, '
|
|
270
263
|
+ `then register "src: ./pages/${file.filename}" in slides.md separately`,
|
|
271
264
|
};
|
|
272
265
|
}
|
|
@@ -280,14 +273,13 @@ async function handleSlidePage(arguments_, readReferenceText) {
|
|
|
280
273
|
const validated = parsePathArguments(slidePageInput, arguments_, ['dir']);
|
|
281
274
|
if (validated.rejected !== undefined)
|
|
282
275
|
return toCallToolResult(validated.rejected);
|
|
283
|
-
//
|
|
284
|
-
// 「捕捉したなら空でもキーを残す」契約 (tools/_shared.ts) を全 return ルートで満たす。
|
|
276
|
+
// テーマの警告は捕捉先の stderr に書き、output.finish で warnings へ移す。
|
|
285
277
|
const output = captureCommandOutput();
|
|
286
278
|
try {
|
|
287
|
-
return
|
|
279
|
+
return output.finish(await generatePage(validated.input, readReferenceText, output));
|
|
288
280
|
}
|
|
289
281
|
catch (error) {
|
|
290
|
-
return
|
|
282
|
+
return output.finish(failure('write-failed', formatError(error)));
|
|
291
283
|
}
|
|
292
284
|
}
|
|
293
285
|
/**
|
|
@@ -302,10 +294,10 @@ readReferenceText = file => readFile(file, 'utf8')) {
|
|
|
302
294
|
title: 'Generate a Slidev page',
|
|
303
295
|
description: 'Generates a skeleton page for one layout under pages/ of the talk-dir, '
|
|
304
296
|
+ 'and returns the specification of that layout (props / text_constraints / clicks / best_practices / anti_patterns / examples). '
|
|
305
|
-
+ 'The specification is returned in
|
|
306
|
-
+ 'Decide the presentation style from the categories (
|
|
307
|
-
+ 'then choose the layout name from
|
|
308
|
-
+ '(passing an unknown name returns
|
|
297
|
+
+ 'The specification is returned in reference and includes. '
|
|
298
|
+
+ 'Decide the presentation style from the categories (categories) in the slide_create / slide_sync response, '
|
|
299
|
+
+ 'then choose the layout name from layouts of that category '
|
|
300
|
+
+ '(passing an unknown name returns categories and layouts in the response). '
|
|
309
301
|
+ 'The generated page must be registered separately as a src: entry in slides.md.',
|
|
310
302
|
inputSchema: slidePageInput,
|
|
311
303
|
outputSchema: TOOL_OUTPUT_SCHEMA,
|
|
@@ -9,10 +9,6 @@ import { errorToReason, executeSlideTheme, slideThemeDefaultDependencies, } from
|
|
|
9
9
|
import { failureKindOf } from '../../domain/_shared/failure-kind.js';
|
|
10
10
|
import { parsePathArguments, toCallToolResult } from '../result.js';
|
|
11
11
|
import { formatError, TOOL_OUTPUT_SCHEMA, WINDOWS_PATH_NOTE } from './_shared.js';
|
|
12
|
-
/**
|
|
13
|
-
解決・宣言の失敗の exit code(各コマンドの RuntimeError と同じ 1)。
|
|
14
|
-
*/
|
|
15
|
-
const SLIDE_THEME_EXIT_CODE = 1;
|
|
16
12
|
const slideThemeInput = z.object({
|
|
17
13
|
dir: z.string()
|
|
18
14
|
.describe('Absolute path of the talk-dir whose theme to inspect. Relative paths are not accepted. ' + WINDOWS_PATH_NOTE),
|
|
@@ -43,22 +39,16 @@ export function slideThemeTool(buildDependencies = slideThemeDefaultDependencies
|
|
|
43
39
|
const { data } = await executeSlideTheme({ dir }, buildDependencies());
|
|
44
40
|
return toCallToolResult({
|
|
45
41
|
ok: true,
|
|
46
|
-
exitCode: 0,
|
|
47
|
-
artifacts: [],
|
|
48
42
|
data: { ...data },
|
|
49
43
|
message: `slide theme: ${data.theme.name} (${String(data.layouts.length)} layouts)`,
|
|
50
44
|
});
|
|
51
45
|
}
|
|
52
46
|
catch (error) {
|
|
53
|
-
const detail = formatError(error);
|
|
54
|
-
const reason = errorToReason(error);
|
|
55
47
|
return toCallToolResult({
|
|
56
48
|
ok: false,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
data: { event: 'slide.theme.error', reason, detail },
|
|
61
|
-
message: detail,
|
|
49
|
+
kind: failureKindOf(errorToReason(error)),
|
|
50
|
+
detail: formatError(error),
|
|
51
|
+
data: { event: 'slide.theme.error' },
|
|
62
52
|
});
|
|
63
53
|
}
|
|
64
54
|
},
|
|
@@ -22,8 +22,8 @@ export declare function slideConvertTool(buildDependencies?: () => SlideConvertD
|
|
|
22
22
|
*/
|
|
23
23
|
export declare function slideSyncTool(buildDependencies?: () => SlideSyncDependencies, buildRuntimeDependencies?: () => RuntimeDependencies): ToolDefinition;
|
|
24
24
|
/**
|
|
25
|
-
`pecotv slide lint`
|
|
26
|
-
|
|
25
|
+
`pecotv slide lint` 相当。違反の検出は「報告が成果」なので、違反があっても成功で返す (CLI は exit 1)。
|
|
26
|
+
違反の有無は outcome の項目で読む。
|
|
27
27
|
*/
|
|
28
28
|
export declare function slideLintTool(buildDependencies?: () => SlideLintDependencies): ToolDefinition;
|
|
29
29
|
/**
|
|
@@ -1,34 +1,25 @@
|
|
|
1
1
|
// MCP ツール定義のうち slide 系 4 件 (slide_create / slide_convert / slide_sync / slide_lint)。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// ための構造で、ハンドラ側には「引数の写像」と「ToolResult への正規化」しか置かない。
|
|
6
|
-
//
|
|
7
|
-
// deps は必ずハンドラ内で組み立てる。
|
|
8
|
-
// 既定 deps ファクトリは CLAUDE_PLUGIN_ROOT 未設定で throw する。
|
|
9
|
-
// モジュール top-level や allTools() 評価時に組み立てると tools/list ごと落ちる。
|
|
10
|
-
// stdout / stderr は MCP のプロセス stdout が JSON-RPC 専有なので、必ず捕捉先へ差し替える。
|
|
3
|
+
// 各ハンドラは CLI コマンドの execute<Cmd>() を呼び、結果を ToolResult に写すだけにする。
|
|
4
|
+
// deps はハンドラ内で組み立てる (既定 deps は CLAUDE_PLUGIN_ROOT 未設定で throw し、top-level だと tools/list ごと落ちる)。
|
|
11
5
|
import path from 'node:path';
|
|
12
6
|
import { z } from 'zod';
|
|
13
|
-
import { errorToReason as slideCreateErrorToReason, executeSlideCreate, slideCreateDefaultDependencies,
|
|
14
|
-
import { errorToReason as slideLintErrorToReason, executeSlideLint, slideLintDefaultDependencies,
|
|
15
|
-
import { errorToReason as slideSyncErrorToReason, executeSlideSync, slideSyncDefaultDependencies,
|
|
16
|
-
import { convertErrorDiagnostics, errorToReason as slideConvertErrorToReason, executeSlideConvert, resolveDefaultOut, slideConvertDefaultDependencies,
|
|
7
|
+
import { errorToReason as slideCreateErrorToReason, executeSlideCreate, slideCreateDefaultDependencies, } from '../../commands/slidev-project/create.js';
|
|
8
|
+
import { errorToReason as slideLintErrorToReason, executeSlideLint, slideLintDefaultDependencies, } from '../../commands/slidev-project/lint.js';
|
|
9
|
+
import { errorToReason as slideSyncErrorToReason, executeSlideSync, slideSyncDefaultDependencies, } from '../../commands/slidev-project/sync.js';
|
|
10
|
+
import { convertErrorDiagnostics, errorToReason as slideConvertErrorToReason, executeSlideConvert, resolveDefaultOut, slideConvertDefaultDependencies, } from '../../commands/slidev-to-pptx/convert.js';
|
|
17
11
|
import { failureKindOf } from '../../domain/_shared/failure-kind.js';
|
|
18
12
|
import { parsePathArguments, toCallToolResult } from '../result.js';
|
|
19
13
|
import { captureCommandOutput, chromiumDefaultDependencies, ensureChromium, ensureRuntimeDependencies, formatError, normalizeThemeArgument, runtimeDefaultDependencies, TOOL_OUTPUT_SCHEMA, WINDOWS_PATH_NOTE, } from './_shared.js';
|
|
20
14
|
/**
|
|
21
15
|
失敗時の ToolResult。data は対応する CLI コマンドの `--json` error payload と同形にする。
|
|
22
16
|
*/
|
|
23
|
-
function failureResult(event, reason,
|
|
24
|
-
const detail = formatError(error);
|
|
17
|
+
function failureResult(event, reason, error, extra = {}) {
|
|
25
18
|
return {
|
|
26
19
|
ok: false,
|
|
27
|
-
exitCode,
|
|
28
20
|
kind: failureKindOf(reason),
|
|
29
|
-
|
|
30
|
-
data: { event,
|
|
31
|
-
message: detail,
|
|
21
|
+
detail: formatError(error),
|
|
22
|
+
data: { event, ...extra },
|
|
32
23
|
};
|
|
33
24
|
}
|
|
34
25
|
const slideCreateInput = z.object({
|
|
@@ -54,7 +45,7 @@ export function slideCreateTool(buildDependencies = slideCreateDefaultDependenci
|
|
|
54
45
|
description: 'Generates a new talk-dir that references the Slidev theme given by `theme`. '
|
|
55
46
|
+ 'The theme is specified by a git URL with a tag (`git+https://<host>/<owner>/<repo>.git#<tag>`) '
|
|
56
47
|
+ 'or a local path (`file:<path>`). '
|
|
57
|
-
+ 'Returns the presentation categories (
|
|
48
|
+
+ 'Returns the presentation categories (categories) and the list of selectable layouts (layouts). '
|
|
58
49
|
+ 'Also returns the lint result of the whole deck right after generation (generation counts as successful even with lint violations).',
|
|
59
50
|
inputSchema: slideCreateInput,
|
|
60
51
|
outputSchema: TOOL_OUTPUT_SCHEMA,
|
|
@@ -67,11 +58,7 @@ export function slideCreateTool(buildDependencies = slideCreateDefaultDependenci
|
|
|
67
58
|
const input = validated.input;
|
|
68
59
|
const normalized = normalizeThemeArgument(input.theme);
|
|
69
60
|
if (!normalized.ok) {
|
|
70
|
-
return toCallToolResult(
|
|
71
|
-
...failureResult('slide.create.error', 'invalid-option', 2, new Error(normalized.detail)),
|
|
72
|
-
stdout: '',
|
|
73
|
-
stderr: '',
|
|
74
|
-
});
|
|
61
|
+
return toCallToolResult(failureResult('slide.create.error', 'invalid-option', new Error(normalized.detail)));
|
|
75
62
|
}
|
|
76
63
|
// 生成の最後に行う node_modules の張り直しは依存ルートの実体を要る。実処理より前に見る。
|
|
77
64
|
// 見ずに進むと、テーマの取得 (git) を終えた後で symlink-failed になり、runtime_setup の案内も出ない。
|
|
@@ -88,22 +75,16 @@ export function slideCreateTool(buildDependencies = slideCreateDefaultDependenci
|
|
|
88
75
|
};
|
|
89
76
|
const execution = await executeSlideCreate(input.project_dir,
|
|
90
77
|
// 人間向けの catalog 整形出力は stdout を汚すので出さない。
|
|
91
|
-
// 同じ元データは
|
|
78
|
+
// 同じ元データは layouts に構造化して載る。
|
|
92
79
|
{ theme: normalized.theme, force: input.force, emitCatalog: false }, dependencies);
|
|
93
|
-
return
|
|
80
|
+
return output.finish({
|
|
94
81
|
ok: true,
|
|
95
|
-
exitCode: 0,
|
|
96
|
-
artifacts: [execution.summary.projectDirectory],
|
|
97
82
|
data: execution.data,
|
|
98
83
|
message: `slide create: succeeded (${execution.summary.projectDirectory})`,
|
|
99
|
-
...output.part(),
|
|
100
84
|
});
|
|
101
85
|
}
|
|
102
86
|
catch (error) {
|
|
103
|
-
return
|
|
104
|
-
...failureResult('slide.create.error', slideCreateErrorToReason(error), slideCreateExitCode(error), error),
|
|
105
|
-
...output.part(),
|
|
106
|
-
});
|
|
87
|
+
return output.finish(failureResult('slide.create.error', slideCreateErrorToReason(error), error));
|
|
107
88
|
}
|
|
108
89
|
},
|
|
109
90
|
};
|
|
@@ -164,10 +145,7 @@ export function slideConvertTool(buildDependencies = slideConvertDefaultDependen
|
|
|
164
145
|
return toCallToolResult(unavailable);
|
|
165
146
|
const output = captureCommandOutput();
|
|
166
147
|
try {
|
|
167
|
-
// json: false
|
|
168
|
-
// 進捗の人間可読ログは stderr の診断行 (note / warning / error) で出るので、ToolResult の stderr に入る。
|
|
169
|
-
// stdout には変換結果の要約だけが入る。
|
|
170
|
-
// MCP サーバの process.stdout は JSON-RPC 専有なので、実 stdout へは何も書かせない。
|
|
148
|
+
// json: false 相当で呼び、出力を捕捉する。warning の行は warnings、失敗のときの出力は log に入る。
|
|
171
149
|
const dependencies = {
|
|
172
150
|
...buildDependencies(),
|
|
173
151
|
stdout: output.stdout,
|
|
@@ -191,21 +169,15 @@ export function slideConvertTool(buildDependencies = slideConvertDefaultDependen
|
|
|
191
169
|
...(input.morph_option !== undefined && { morphOption: input.morph_option }),
|
|
192
170
|
};
|
|
193
171
|
const execution = await executeSlideConvert(input.project_dir, options, dependencies);
|
|
194
|
-
return
|
|
172
|
+
return output.finish({
|
|
195
173
|
ok: true,
|
|
196
|
-
exitCode: 0,
|
|
197
|
-
artifacts: [execution.summary.outputAbs],
|
|
198
174
|
data: execution.data,
|
|
199
175
|
message: `slide convert: ${execution.summary.inputAbs} -> ${execution.summary.outputAbs}`
|
|
200
176
|
+ ` (${String(Math.round(execution.summary.durationMs))}ms)`,
|
|
201
|
-
...output.part(),
|
|
202
177
|
});
|
|
203
178
|
}
|
|
204
179
|
catch (error) {
|
|
205
|
-
return
|
|
206
|
-
...failureResult('slide.convert.error', slideConvertErrorToReason(error), slideConvertExitCode(error), error, convertErrorDiagnostics(error)),
|
|
207
|
-
...output.part(),
|
|
208
|
-
});
|
|
180
|
+
return output.finish(failureResult('slide.convert.error', slideConvertErrorToReason(error), error, convertErrorDiagnostics(error)));
|
|
209
181
|
}
|
|
210
182
|
},
|
|
211
183
|
};
|
|
@@ -234,12 +206,12 @@ export function slideSyncTool(buildDependencies = slideSyncDefaultDependencies,
|
|
|
234
206
|
description: 'Syncs an existing talk-dir. '
|
|
235
207
|
+ 'A pre-migration talk-dir (one that holds a copy of the template; slide_dev and others stop with theme-none) '
|
|
236
208
|
+ 'is moved to a form that references the theme given by `theme`. Files that came from the template are deleted, '
|
|
237
|
-
+ 'and the work area (slides.md / pages/*.md / public/slides/) is kept. The deleted names are returned in
|
|
209
|
+
+ 'and the work area (slides.md / pages/*.md / public/slides/) is kept. The deleted names are returned in migration.removed. '
|
|
238
210
|
+ 'A migrated talk-dir that references a theme (theme: in slides.md points to the theme in dependencies of package.json) '
|
|
239
211
|
+ 'fetches the theme at the version in the dependency and relinks node_modules, '
|
|
240
212
|
+ 'and aligns the generated files (vite.config.ts, start.mjs) with the current content of the plugin. Other files are left unchanged. '
|
|
241
213
|
+ 'To raise the theme version, rewrite the #<tag> of the dependency in package.json before calling. '
|
|
242
|
-
+ 'Returns the presentation categories (
|
|
214
|
+
+ 'Returns the presentation categories (categories), the list of selectable layouts (layouts), '
|
|
243
215
|
+ 'and the lint result of the whole deck after the sync. A running slide_dev must be stopped with stop: true and started again.',
|
|
244
216
|
inputSchema: slideSyncInput,
|
|
245
217
|
outputSchema: TOOL_OUTPUT_SCHEMA,
|
|
@@ -256,11 +228,7 @@ export function slideSyncTool(buildDependencies = slideSyncDefaultDependencies,
|
|
|
256
228
|
if (input.theme !== undefined) {
|
|
257
229
|
const normalized = normalizeThemeArgument(input.theme);
|
|
258
230
|
if (!normalized.ok) {
|
|
259
|
-
return toCallToolResult(
|
|
260
|
-
...failureResult('slide.sync.error', 'invalid-option', 2, new Error(normalized.detail)),
|
|
261
|
-
stdout: '',
|
|
262
|
-
stderr: '',
|
|
263
|
-
});
|
|
231
|
+
return toCallToolResult(failureResult('slide.sync.error', 'invalid-option', new Error(normalized.detail)));
|
|
264
232
|
}
|
|
265
233
|
theme = normalized.theme;
|
|
266
234
|
}
|
|
@@ -277,20 +245,14 @@ export function slideSyncTool(buildDependencies = slideSyncDefaultDependencies,
|
|
|
277
245
|
stderr: output.stderr,
|
|
278
246
|
};
|
|
279
247
|
const execution = await executeSlideSync({ dir: input.dir, nodeModulesOnly: input.node_modules_only, theme }, dependencies);
|
|
280
|
-
return
|
|
248
|
+
return output.finish({
|
|
281
249
|
ok: true,
|
|
282
|
-
exitCode: 0,
|
|
283
|
-
artifacts: [execution.summary.directory],
|
|
284
250
|
data: execution.data,
|
|
285
251
|
message: syncSuccessMessage(execution.summary),
|
|
286
|
-
...output.part(),
|
|
287
252
|
});
|
|
288
253
|
}
|
|
289
254
|
catch (error) {
|
|
290
|
-
return
|
|
291
|
-
...failureResult('slide.sync.error', slideSyncErrorToReason(error), slideSyncExitCode(error), error),
|
|
292
|
-
...output.part(),
|
|
293
|
-
});
|
|
255
|
+
return output.finish(failureResult('slide.sync.error', slideSyncErrorToReason(error), error));
|
|
294
256
|
}
|
|
295
257
|
},
|
|
296
258
|
};
|
|
@@ -309,8 +271,8 @@ const slideLintInput = z.object({
|
|
|
309
271
|
.describe('Absolute path of the talk-dir to lint. Relative paths are not accepted. ' + WINDOWS_PATH_NOTE),
|
|
310
272
|
});
|
|
311
273
|
/**
|
|
312
|
-
`pecotv slide lint`
|
|
313
|
-
|
|
274
|
+
`pecotv slide lint` 相当。違反の検出は「報告が成果」なので、違反があっても成功で返す (CLI は exit 1)。
|
|
275
|
+
違反の有無は outcome の項目で読む。
|
|
314
276
|
*/
|
|
315
277
|
export function slideLintTool(buildDependencies = slideLintDefaultDependencies) {
|
|
316
278
|
return {
|
|
@@ -318,7 +280,7 @@ export function slideLintTool(buildDependencies = slideLintDefaultDependencies)
|
|
|
318
280
|
config: {
|
|
319
281
|
title: 'Lint a Slidev deck',
|
|
320
282
|
description: 'Lints the whole talk-dir (pages/**/*.md and slides.md) '
|
|
321
|
-
+ 'and returns the list of violations. The call itself succeeds
|
|
283
|
+
+ 'and returns the list of violations. The call itself succeeds even with violations; outcome is violations when any are found.',
|
|
322
284
|
inputSchema: slideLintInput,
|
|
323
285
|
outputSchema: TOOL_OUTPUT_SCHEMA,
|
|
324
286
|
// 読み取りのみで何も書き換えず、ネットワークにも到達しない。
|
|
@@ -338,23 +300,17 @@ export function slideLintTool(buildDependencies = slideLintDefaultDependencies)
|
|
|
338
300
|
};
|
|
339
301
|
const { summary, data } = await executeSlideLint({ dir: input.dir }, dependencies);
|
|
340
302
|
const hasViolations = summary.outcome === 'violations';
|
|
341
|
-
return
|
|
303
|
+
return output.finish({
|
|
342
304
|
ok: true,
|
|
343
|
-
exitCode: hasViolations ? 1 : 0,
|
|
344
|
-
artifacts: [],
|
|
345
305
|
data,
|
|
346
306
|
message: hasViolations
|
|
347
307
|
? `slide lint: violations found (${summary.directory}); ${String(summary.errorCount)} errors`
|
|
348
308
|
+ `; ${String(summary.warningCount)} warnings`
|
|
349
309
|
: `slide lint: succeeded (${summary.directory}); ${String(summary.lintedFileCount)} files linted`,
|
|
350
|
-
...output.part(),
|
|
351
310
|
});
|
|
352
311
|
}
|
|
353
312
|
catch (error) {
|
|
354
|
-
return
|
|
355
|
-
...failureResult('slide.lint.error', slideLintErrorToReason(error), slideLintExitCode(error), error),
|
|
356
|
-
...output.part(),
|
|
357
|
-
});
|
|
313
|
+
return output.finish(failureResult('slide.lint.error', slideLintErrorToReason(error), error));
|
|
358
314
|
}
|
|
359
315
|
},
|
|
360
316
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
保つ warning の件数の上限。超えた分は数えて、最後に知らせの 1 文を足す。
|
|
3
|
+
*/
|
|
4
|
+
export declare const WARNING_LIMIT_COUNT = 100;
|
|
5
|
+
/**
|
|
6
|
+
保つ warning の文の合計の上限 (バイト)。出力の捕捉と同じ 64KB にする。
|
|
7
|
+
*/
|
|
8
|
+
export declare const WARNING_LIMIT_BYTES: number;
|
|
9
|
+
export interface WarningCollector {
|
|
10
|
+
/**
|
|
11
|
+
改行を除いた 1 行を渡す。
|
|
12
|
+
*/
|
|
13
|
+
addLine(line: string): void;
|
|
14
|
+
/**
|
|
15
|
+
ここまでの warning の文。trailing は改行で終わっていない最後の行で、状態には残さない。
|
|
16
|
+
*/
|
|
17
|
+
list(trailing?: string): string[];
|
|
18
|
+
}
|
|
19
|
+
export declare function createWarningCollector(): WarningCollector;
|
|
20
|
+
/**
|
|
21
|
+
文字列の全体から warning の文を取る。続きの行 (先頭に空白 2 つ) は同じ文に含める。
|
|
22
|
+
*/
|
|
23
|
+
export declare function warningsOf(text: string): string[];
|
|
24
|
+
//# sourceMappingURL=warnings.d.ts.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// diagnostics の `warning: ` の行を文の配列にする。出力の捕捉の上限と別に保ち、早く出た warning を落とさない。
|
|
2
|
+
const WARNING_PREFIX = 'warning: ';
|
|
3
|
+
const CONTINUATION_PREFIX = ' ';
|
|
4
|
+
/**
|
|
5
|
+
保つ warning の件数の上限。超えた分は数えて、最後に知らせの 1 文を足す。
|
|
6
|
+
*/
|
|
7
|
+
export const WARNING_LIMIT_COUNT = 100;
|
|
8
|
+
/**
|
|
9
|
+
保つ warning の文の合計の上限 (バイト)。出力の捕捉と同じ 64KB にする。
|
|
10
|
+
*/
|
|
11
|
+
export const WARNING_LIMIT_BYTES = 64 * 1024;
|
|
12
|
+
class WarningState {
|
|
13
|
+
kept = [];
|
|
14
|
+
seen = new Set();
|
|
15
|
+
keptBytes = 0;
|
|
16
|
+
omitted = 0;
|
|
17
|
+
/**
|
|
18
|
+
組み立て中の warning の行。上限を超えた後の行は足さず、バイト数だけ数える。
|
|
19
|
+
*/
|
|
20
|
+
current;
|
|
21
|
+
currentBytes = 0;
|
|
22
|
+
append(text) {
|
|
23
|
+
const bytes = Buffer.byteLength(text, 'utf8');
|
|
24
|
+
// 1 つの warning が上限を超えたら、それ以上の行は持たない (閉じるときに省いた数へ入る)。
|
|
25
|
+
if (this.currentBytes + bytes <= WARNING_LIMIT_BYTES)
|
|
26
|
+
this.current?.push(text);
|
|
27
|
+
this.currentBytes += bytes;
|
|
28
|
+
}
|
|
29
|
+
close() {
|
|
30
|
+
const { current } = this;
|
|
31
|
+
if (current === undefined)
|
|
32
|
+
return;
|
|
33
|
+
this.current = undefined;
|
|
34
|
+
const text = current.join('\n');
|
|
35
|
+
if (text.trim() === '' || this.seen.has(text))
|
|
36
|
+
return;
|
|
37
|
+
if (this.kept.length >= WARNING_LIMIT_COUNT || this.keptBytes + this.currentBytes > WARNING_LIMIT_BYTES) {
|
|
38
|
+
this.omitted += 1;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
this.kept.push(text);
|
|
42
|
+
this.seen.add(text);
|
|
43
|
+
this.keptBytes += this.currentBytes;
|
|
44
|
+
}
|
|
45
|
+
clone() {
|
|
46
|
+
const copy = new WarningState();
|
|
47
|
+
copy.kept.push(...this.kept);
|
|
48
|
+
for (const text of this.seen)
|
|
49
|
+
copy.seen.add(text);
|
|
50
|
+
copy.keptBytes = this.keptBytes;
|
|
51
|
+
copy.omitted = this.omitted;
|
|
52
|
+
copy.current = this.current === undefined ? undefined : [...this.current];
|
|
53
|
+
copy.currentBytes = this.currentBytes;
|
|
54
|
+
return copy;
|
|
55
|
+
}
|
|
56
|
+
addLine(line) {
|
|
57
|
+
if (line.startsWith(WARNING_PREFIX)) {
|
|
58
|
+
this.close();
|
|
59
|
+
this.current = [];
|
|
60
|
+
this.currentBytes = 0;
|
|
61
|
+
this.append(line.slice(WARNING_PREFIX.length));
|
|
62
|
+
}
|
|
63
|
+
else if (this.current !== undefined && line.startsWith(CONTINUATION_PREFIX)) {
|
|
64
|
+
this.append(line.slice(CONTINUATION_PREFIX.length));
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.close();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
finish() {
|
|
71
|
+
this.close();
|
|
72
|
+
return this.omitted > 0 ? [...this.kept, omittedNotice(this.omitted)] : [...this.kept];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function omittedNotice(count) {
|
|
76
|
+
return `${String(count)} more warnings were omitted (limit: ${String(WARNING_LIMIT_COUNT)} warnings or ${String(WARNING_LIMIT_BYTES)} bytes)`;
|
|
77
|
+
}
|
|
78
|
+
export function createWarningCollector() {
|
|
79
|
+
const state = new WarningState();
|
|
80
|
+
return {
|
|
81
|
+
addLine: (line) => {
|
|
82
|
+
state.addLine(line);
|
|
83
|
+
},
|
|
84
|
+
list: (trailing) => {
|
|
85
|
+
const snapshot = state.clone();
|
|
86
|
+
if (trailing !== undefined)
|
|
87
|
+
snapshot.addLine(trailing);
|
|
88
|
+
return snapshot.finish();
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
文字列の全体から warning の文を取る。続きの行 (先頭に空白 2 つ) は同じ文に含める。
|
|
94
|
+
*/
|
|
95
|
+
export function warningsOf(text) {
|
|
96
|
+
const collector = createWarningCollector();
|
|
97
|
+
for (const line of text.split('\n'))
|
|
98
|
+
collector.addLine(line);
|
|
99
|
+
return collector.list();
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=warnings.js.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// だがクライアントが組み立てるパスは `C:\Users\...` 形式になる。
|
|
5
5
|
// POSIX では `C:\...` は絶対パスと判定されない。
|
|
6
6
|
// 変換を挟まないと FR-011 の絶対パス確認 (src/mcp/result.ts) が実処理の前に全て弾いてしまう。
|
|
7
|
-
//
|
|
7
|
+
// 変換するのは入力側だけ。応答の項目には変換後の POSIX パスをそのまま載せる。
|
|
8
8
|
// Windows 形式への逆変換はしない。
|
|
9
9
|
//
|
|
10
10
|
// 変換後のパスは `..` を含むと mount root の外へ出うる (`C:\..\..\etc` → `/etc`)。FR-011 と
|