@pecot/visual-mcp 1.1.0 → 1.3.0
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/assets/slidev/deck-lint.config.js +2 -2
- package/assets/slidev/deck-lint.env.config.js +2 -2
- package/assets/slidev/package.json +7 -7
- package/assets/slidev/runtime/package.json +11 -11
- package/assets/slidev/scripts/eslint/_shared/dist/lib/drawio-geometry.js +10 -10
- package/assets/slidev/scripts/eslint/_shared/dist/lib/text-measurer.d.ts +2 -2
- package/assets/slidev/scripts/eslint/_shared/dist/lib/text-measurer.js +4 -4
- package/assets/slidev/scripts/eslint/_shared/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/_shared/lib/drawio-geometry.ts +10 -10
- package/assets/slidev/scripts/eslint/_shared/lib/text-measurer.ts +4 -4
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-content-before-frontmatter.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-missing-marker-cell.js +4 -4
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-missing-page.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-numeric-asset-prefix.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-numeric-filename-prefix.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-scaled-drawio.js +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-triple-hyphen-in-frontmatter.js +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-unknown-props.js +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/one-slide-per-file.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/require-matching-length.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/require-slides-entry.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/validate-clicks.js +7 -7
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-content-before-frontmatter.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-missing-marker-cell.ts +4 -4
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-missing-page.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-numeric-asset-prefix.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-numeric-filename-prefix.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-scaled-drawio.ts +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-triple-hyphen-in-frontmatter.ts +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-unknown-props.ts +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/one-slide-per-file.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/require-matching-length.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/require-slides-entry.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/validate-clicks.ts +7 -7
- package/assets/slidev/scripts/eslint/slidev-pages-lint/package.json +1 -1
- package/assets/slidev/scripts/eslint/text-constraints/dist/lib/rules/max-chars.js +6 -6
- package/assets/slidev/scripts/eslint/text-constraints/dist/lib/rules/textlint-body.js +3 -3
- package/assets/slidev/scripts/eslint/text-constraints/dist/lib/rules/textlint.js +2 -2
- package/assets/slidev/scripts/eslint/text-constraints/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/text-constraints/lib/rules/max-chars.ts +6 -6
- package/assets/slidev/scripts/eslint/text-constraints/lib/rules/textlint-body.ts +3 -3
- package/assets/slidev/scripts/eslint/text-constraints/lib/rules/textlint.ts +2 -2
- package/assets/slidev/scripts/eslint/text-constraints/package.json +1 -1
- package/assets/slidev/scripts/eslint/validate-references/dist/index.js +1 -1
- package/assets/slidev/scripts/eslint/validate-references/dist/lib/schema-validator.js +1 -1
- package/assets/slidev/scripts/eslint/validate-references/dist/lib/semantic-validator.js +12 -12
- package/assets/slidev/scripts/eslint/validate-references/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/validate-references/index.ts +1 -1
- package/assets/slidev/scripts/eslint/validate-references/lib/schema-validator.ts +2 -2
- package/assets/slidev/scripts/eslint/validate-references/lib/semantic-validator.ts +12 -12
- package/assets/slidev/scripts/eslint/validate-references/package.json +1 -1
- package/cli/dist/cli.js +11 -10
- package/cli/dist/commands/chromium/host-dependencies.js +14 -7
- package/cli/dist/commands/drawio/export.js +27 -24
- package/cli/dist/commands/drawio/theme.js +8 -8
- package/cli/dist/commands/drawio/url.js +40 -32
- package/cli/dist/commands/evidence-xlsx/create.js +19 -18
- package/cli/dist/commands/pptx-ooxml/preview.js +26 -30
- package/cli/dist/commands/slidev-project/create.js +27 -26
- package/cli/dist/commands/slidev-project/linked-theme.js +5 -5
- package/cli/dist/commands/slidev-project/lint.js +29 -27
- package/cli/dist/commands/slidev-project/sync.js +35 -34
- package/cli/dist/commands/slidev-project/theme.js +19 -18
- package/cli/dist/commands/slidev-to-pptx/convert.d.ts +4 -0
- package/cli/dist/commands/slidev-to-pptx/convert.js +88 -75
- package/cli/dist/diagnostics.d.ts +38 -0
- package/cli/dist/diagnostics.js +46 -0
- package/cli/dist/domain/_shared/ports.d.ts +0 -1
- package/cli/dist/domain/_shared/text-check.js +2 -2
- package/cli/dist/domain/drawio/export.js +4 -4
- package/cli/dist/domain/drawio/label-text.js +1 -1
- package/cli/dist/domain/drawio/url.d.ts +11 -7
- package/cli/dist/domain/drawio/url.js +67 -45
- package/cli/dist/domain/evidence-xlsx/image-dimensions.js +14 -14
- package/cli/dist/domain/evidence-xlsx/spec-schema.js +26 -26
- package/cli/dist/domain/pptx-ooxml/merge.js +3 -3
- package/cli/dist/domain/pptx-ooxml/prerender-replace.d.ts +1 -0
- package/cli/dist/domain/pptx-ooxml/prerender-replace.js +3 -3
- package/cli/dist/domain/slidev-project/generated-files.d.ts +1 -1
- package/cli/dist/domain/slidev-project/generated-files.js +36 -36
- package/cli/dist/domain/slidev-project/initial-pages.js +4 -4
- package/cli/dist/domain/slidev-project/lint.js +11 -11
- package/cli/dist/domain/slidev-project/sync.js +13 -13
- package/cli/dist/domain/slidev-project/warnings.js +4 -4
- package/cli/dist/domain/slidev-theme/declaration.js +9 -9
- package/cli/dist/domain/slidev-theme/references.js +10 -10
- package/cli/dist/domain/slidev-theme/store-layout.js +6 -6
- package/cli/dist/domain/slidev-theme/talk-theme.js +13 -13
- package/cli/dist/domain/slidev-theme/theme-spec.js +5 -5
- package/cli/dist/domain/slidev-to-pptx/errors.js +3 -3
- package/cli/dist/infra/_shared/dependency-root.js +4 -4
- package/cli/dist/infra/_shared/patch-apply.js +6 -5
- package/cli/dist/infra/_shared/runtime-install.d.ts +12 -84
- package/cli/dist/infra/_shared/runtime-install.js +74 -108
- package/cli/dist/infra/_shared/slidev-bin.js +1 -1
- package/cli/dist/infra/drawio/icons.js +3 -3
- package/cli/dist/infra/drawio/pdf.js +1 -1
- package/cli/dist/infra/drawio/screenshot.js +10 -9
- package/cli/dist/infra/evidence-xlsx/workbook-writer.js +2 -2
- package/cli/dist/infra/playwright/chromium.js +4 -3
- package/cli/dist/infra/playwright/host-dependencies.js +8 -8
- package/cli/dist/infra/playwright/launch.js +5 -5
- package/cli/dist/infra/pptx-ooxml/soffice.js +2 -2
- package/cli/dist/infra/slidev-project/eslint-runner.js +10 -9
- package/cli/dist/infra/slidev-project/fs.js +6 -6
- package/cli/dist/infra/slidev-theme/store.js +18 -15
- package/cli/dist/infra/slidev-to-pptx/cache-store.js +6 -6
- package/cli/dist/infra/slidev-to-pptx/console-logger.d.ts +5 -5
- package/cli/dist/infra/slidev-to-pptx/console-logger.js +19 -20
- package/cli/dist/infra/slidev-to-pptx/dom-converter.d.ts +1 -1
- package/cli/dist/infra/slidev-to-pptx/dom-converter.js +12 -12
- package/cli/dist/infra/slidev-to-pptx/index.js +1 -9
- package/cli/dist/infra/slidev-to-pptx/pipeline.d.ts +2 -2
- package/cli/dist/infra/slidev-to-pptx/pipeline.js +56 -56
- package/cli/dist/infra/slidev-to-pptx/prerender-capture.js +14 -14
- package/cli/dist/infra/slidev-to-pptx/prerender.js +10 -10
- package/cli/dist/infra/slidev-to-pptx/runner.js +1 -0
- package/cli/dist/infra/slidev-to-pptx/scanner.js +10 -10
- package/cli/dist/infra/slidev-to-pptx/server.d.ts +2 -1
- package/cli/dist/infra/slidev-to-pptx/server.js +3 -3
- package/cli/dist/infra/slidev-to-pptx/single-pass-worker.js +39 -39
- package/cli/dist/infra/slidev-to-pptx/slide-worker.js +3 -3
- package/cli/dist/infra/slidev-to-pptx/visibility-helpers.js +8 -8
- package/cli/dist/mcp/dev-server-registry.js +10 -9
- package/cli/dist/mcp/queue.js +1 -1
- package/cli/dist/mcp/result.js +4 -4
- package/cli/dist/mcp/serve.js +5 -3
- package/cli/dist/mcp/server.js +2 -2
- package/cli/dist/mcp/tools/_shared.d.ts +1 -1
- package/cli/dist/mcp/tools/_shared.js +47 -38
- package/cli/dist/mcp/tools/drawio.js +23 -22
- package/cli/dist/mcp/tools/evidence.js +8 -8
- package/cli/dist/mcp/tools/setup.js +26 -26
- package/cli/dist/mcp/tools/slide-dev.js +20 -20
- package/cli/dist/mcp/tools/slide-page.js +39 -37
- package/cli/dist/mcp/tools/slide-theme.js +6 -6
- package/cli/dist/mcp/tools/slide.js +52 -50
- package/cli/dist/mcp/windows-path.js +8 -7
- package/cli/dist/node-runtime.d.ts +6 -1
- package/cli/dist/node-runtime.js +16 -8
- package/npm-shrinkwrap.json +46 -52
- package/package.json +6 -6
- package/vendor/text-rules/dist/source-hash +1 -1
|
@@ -28,8 +28,8 @@ import { toPosixPath } from '../windows-path.js';
|
|
|
28
28
|
エージェントは「絶対パス」の指示から POSIX パスだけを組み立てようとして詰まる。
|
|
29
29
|
変換の実装は src/mcp/windows-path.ts。
|
|
30
30
|
*/
|
|
31
|
-
export const WINDOWS_PATH_NOTE = String.raw `Windows
|
|
32
|
-
+ '/mnt/<drive>/
|
|
31
|
+
export const WINDOWS_PATH_NOTE = String.raw `Windows-style paths (C:\... / \\wsl.localhost\<distro>\...) are accepted and `
|
|
32
|
+
+ 'converted to an absolute path under /mnt/<drive>/ or inside WSL.';
|
|
33
33
|
/**
|
|
34
34
|
ToolResult 同形の outputSchema。
|
|
35
35
|
|
|
@@ -37,13 +37,13 @@ data はツールごとに形が異なる (対応 CLI の --json 出力と同形
|
|
|
37
37
|
record として受け、同形性の検証は contract / parity テスト側で行う。
|
|
38
38
|
*/
|
|
39
39
|
export const TOOL_OUTPUT_SCHEMA = z.object({
|
|
40
|
-
ok: z.boolean().describe('
|
|
41
|
-
exitCode: z.number().describe('
|
|
42
|
-
artifacts: z.array(z.string()).describe('
|
|
43
|
-
data: z.record(z.string(), z.unknown()).describe('
|
|
44
|
-
message: z.string().describe('
|
|
45
|
-
stdout: z.string().optional().describe('
|
|
46
|
-
stderr: z.string().optional().describe('
|
|
40
|
+
ok: z.boolean().describe('Whether the tool completed its intended run'),
|
|
41
|
+
exitCode: z.number().describe('Exit code (0 = success)'),
|
|
42
|
+
artifacts: z.array(z.string()).describe('Absolute paths of files and directories created or updated'),
|
|
43
|
+
data: z.record(z.string(), z.unknown()).describe('Object with the details of the run'),
|
|
44
|
+
message: z.string().describe('One-line summary for the calling agent'),
|
|
45
|
+
stdout: z.string().optional().describe('Captured stdout (omitted when nothing was captured)'),
|
|
46
|
+
stderr: z.string().optional().describe('Captured stderr (omitted when nothing was captured)'),
|
|
47
47
|
});
|
|
48
48
|
/**
|
|
49
49
|
MCP サーバの process.stdout は JSON-RPC 専有なので、コマンドの出力は必ずここへ逃がす。
|
|
@@ -80,7 +80,7 @@ export function formatError(error) {
|
|
|
80
80
|
文面の違反で生成を止めたときの message。drawio_create と evidence_create で同じ文言にする。
|
|
81
81
|
*/
|
|
82
82
|
export function textViolationMessage(count) {
|
|
83
|
-
return
|
|
83
|
+
return `${count.toString()} text violations; fix the text without loosening the rules, then run again`;
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
errorData の data から、文面の違反の件数を取る。違反を持たない失敗は undefined。
|
|
@@ -100,7 +100,7 @@ export const RUNTIME_UNAVAILABLE_EXIT_CODE = 1;
|
|
|
100
100
|
/**
|
|
101
101
|
永続層の場所を特定できないときに利用者向けの応答へ載せる既定の表記。
|
|
102
102
|
*/
|
|
103
|
-
export const RUNTIME_ROOT_PLACEHOLDER = '
|
|
103
|
+
export const RUNTIME_ROOT_PLACEHOLDER = '<data-dir>/mcp-dist';
|
|
104
104
|
export function chromiumDefaultDependencies() {
|
|
105
105
|
return {
|
|
106
106
|
isInstalled: isChromiumInstalled,
|
|
@@ -113,12 +113,12 @@ export function chromiumDefaultDependencies() {
|
|
|
113
113
|
取得先として期待している場所。特定できないときも、文言が崩れないようにする。
|
|
114
114
|
*/
|
|
115
115
|
function expectedLocation(dependencies) {
|
|
116
|
-
return dependencies.browsersRoot() ?? 'Playwright
|
|
116
|
+
return dependencies.browsersRoot() ?? 'the default Playwright browsers directory';
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
119
|
取得先とネットワークの設定を確認させる誘導。bin/pecotv の fatal メッセージと同じ内容に揃える。
|
|
120
120
|
*/
|
|
121
|
-
const NETWORK_HINT = '
|
|
121
|
+
const NETWORK_HINT = '; check network reachability, the proxy settings (HTTPS_PROXY / HTTP_PROXY) and PLAYWRIGHT_DOWNLOAD_HOST, then run again';
|
|
122
122
|
/**
|
|
123
123
|
TLS の鎖の検証で失敗したと判断する stderr の目印。
|
|
124
124
|
|
|
@@ -144,9 +144,9 @@ TLS 証明書の検証失敗に添える、利用者向けの誘導。
|
|
|
144
144
|
SSL を中継するプロキシの配下では、そのプロキシの CA が必要になる。
|
|
145
145
|
pecot は証明書を同梱しないので、利用者が NODE_EXTRA_CA_CERTS で渡す。
|
|
146
146
|
*/
|
|
147
|
-
const TLS_CERT_HINT = 'TLS
|
|
148
|
-
+ '
|
|
149
|
-
+ '
|
|
147
|
+
const TLS_CERT_HINT = '; TLS certificate verification failed. Behind a proxy that intercepts SSL, '
|
|
148
|
+
+ 'set NODE_EXTRA_CA_CERTS to the path of a PEM file that contains the proxy\'s CA. '
|
|
149
|
+
+ 'If it is already set, check that the PEM contains the proxy\'s CA';
|
|
150
150
|
/**
|
|
151
151
|
取得プロセスの stderr が TLS の証明書検証の失敗を示すなら足す 1 文。示さなければ空文字。
|
|
152
152
|
|
|
@@ -171,17 +171,17 @@ SpawnResult.exitCode は、起動失敗 (ENOENT・playwright 未解決) とシ
|
|
|
171
171
|
*/
|
|
172
172
|
function chromiumFailureReason(result) {
|
|
173
173
|
if (result.exitCode === LOCK_CONFLICT_EXIT_CODE) {
|
|
174
|
-
return
|
|
175
|
-
+ '
|
|
174
|
+
return `another process is downloading chromium (lock wait exceeded ${String(LOCK_WAIT_SECONDS)} seconds)`
|
|
175
|
+
+ '; wait for it to finish, then run again';
|
|
176
176
|
}
|
|
177
177
|
if (result.timedOut)
|
|
178
|
-
return
|
|
178
|
+
return `download timed out${NETWORK_HINT}`;
|
|
179
179
|
if (result.exitCode === null) {
|
|
180
180
|
return result.signal === null
|
|
181
|
-
? '
|
|
182
|
-
:
|
|
181
|
+
? 'could not start the download command (see stderr for the reason); rebuild node_modules (pnpm install), then run again'
|
|
182
|
+
: `download command was interrupted by ${result.signal}; the download was cut off externally`;
|
|
183
183
|
}
|
|
184
|
-
return
|
|
184
|
+
return `download command exited with ${String(result.exitCode)}${NETWORK_HINT}`;
|
|
185
185
|
}
|
|
186
186
|
/**
|
|
187
187
|
chromium を要するツールのハンドラ冒頭で使う実行時ガード (続行可否を ToolResult の有無で返す形)。
|
|
@@ -209,13 +209,12 @@ signal) {
|
|
|
209
209
|
data: {
|
|
210
210
|
event: 'chromium.unavailable',
|
|
211
211
|
reason: 'chromium-not-installed',
|
|
212
|
-
detail: `${label}
|
|
213
|
-
+
|
|
214
|
-
+
|
|
215
|
-
+ `取得を自動化する場合は ${AUTO_INSTALL_ENV}=1 を設定してください。`,
|
|
212
|
+
detail: `${label} needs Playwright Chromium, but it is not found in ${expectedLocation(dependencies)}`
|
|
213
|
+
+ '; call the `setup` tool to download it (about 120MB)'
|
|
214
|
+
+ `; to automate the download, set ${AUTO_INSTALL_ENV}=1`,
|
|
216
215
|
expectedAt: expectedLocation(dependencies),
|
|
217
216
|
},
|
|
218
|
-
message: `
|
|
217
|
+
message: `cannot run ${label}: Playwright Chromium is not installed; call the \`setup\` tool`,
|
|
219
218
|
};
|
|
220
219
|
}
|
|
221
220
|
const result = await dependencies.install(signal);
|
|
@@ -224,7 +223,7 @@ signal) {
|
|
|
224
223
|
if (result.exitCode === 0 && await dependencies.isInstalled())
|
|
225
224
|
return undefined;
|
|
226
225
|
const detail = result.exitCode === 0
|
|
227
|
-
?
|
|
226
|
+
? `download command succeeded, but chromium is not in ${expectedLocation(dependencies)}`
|
|
228
227
|
: chromiumInstallFailureDetail(result);
|
|
229
228
|
return {
|
|
230
229
|
ok: false,
|
|
@@ -233,10 +232,10 @@ signal) {
|
|
|
233
232
|
data: {
|
|
234
233
|
event: 'chromium.unavailable',
|
|
235
234
|
reason: 'chromium-install-failed',
|
|
236
|
-
detail:
|
|
235
|
+
detail: `downloading chromium with ${AUTO_INSTALL_ENV}=1 for ${label} failed: ${detail}`,
|
|
237
236
|
expectedAt: expectedLocation(dependencies),
|
|
238
237
|
},
|
|
239
|
-
message: `
|
|
238
|
+
message: `cannot run ${label}: Playwright Chromium download failed`,
|
|
240
239
|
// 失敗原因が stdout 側にあることもある (playwright install は進捗・取得先を stdout へ書く)。
|
|
241
240
|
...spawnOutputPart(result),
|
|
242
241
|
};
|
|
@@ -246,7 +245,17 @@ export function runtimeDefaultDependencies() {
|
|
|
246
245
|
return {
|
|
247
246
|
// 永続層は版を持たない固定パスなので、解決の可否だけでなく、install 対象の内容から導く
|
|
248
247
|
// stamp も照らし合わせる (前の版で取得したツリーを、取得済みと誤判定させない)。
|
|
249
|
-
|
|
248
|
+
// manifest が読めないか @slidev/cli の宣言を欠くと、stamp が throw する。未取得として install へ進め、失敗を応答に載せる。
|
|
249
|
+
isInstalled: () => {
|
|
250
|
+
let stamp;
|
|
251
|
+
try {
|
|
252
|
+
stamp = runtimeInstallStamp(manifestPath);
|
|
253
|
+
}
|
|
254
|
+
catch {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
return areRuntimeDependenciesInstalled(stamp);
|
|
258
|
+
},
|
|
250
259
|
root: runtimeDependencyRoot,
|
|
251
260
|
install: signal => installRuntimeDependencies({ manifestPath, signal }),
|
|
252
261
|
};
|
|
@@ -275,11 +284,11 @@ export function ensureRuntimeDependencies(label, dependencies = runtimeDefaultDe
|
|
|
275
284
|
data: {
|
|
276
285
|
event: 'runtime-dependencies.unavailable',
|
|
277
286
|
reason: 'runtime-dependencies-not-installed',
|
|
278
|
-
detail: `${label}
|
|
287
|
+
detail: `${label} needs @slidev/cli / dom-to-pptx / @slidev/parser, which cannot be resolved; `
|
|
279
288
|
+ DEPENDENCY_RECOVERY_HINT,
|
|
280
289
|
expectedAt,
|
|
281
290
|
},
|
|
282
|
-
message:
|
|
291
|
+
message: `cannot run ${label}: runtime dependencies are not installed; call the \`setup\` tool`,
|
|
283
292
|
};
|
|
284
293
|
}
|
|
285
294
|
/**
|
|
@@ -297,14 +306,14 @@ subject は拒む文言の主語(どの形の指定かを示す)。
|
|
|
297
306
|
function absoluteThemePath(filePath, subject, original) {
|
|
298
307
|
const conversion = toPosixPath(filePath);
|
|
299
308
|
if (conversion.kind === 'unsupported') {
|
|
300
|
-
return { ok: false, detail:
|
|
309
|
+
return { ok: false, detail: `cannot resolve ${subject} path: ${conversion.reason}` };
|
|
301
310
|
}
|
|
302
311
|
const resolved = conversion.kind === 'converted' ? conversion.path : filePath;
|
|
303
312
|
if (!path.isAbsolute(resolved)) {
|
|
304
313
|
return {
|
|
305
314
|
ok: false,
|
|
306
|
-
detail: `${subject}
|
|
307
|
-
+ 'MCP
|
|
315
|
+
detail: `${subject} must be an absolute path: ${original}`
|
|
316
|
+
+ ' (the MCP server working directory differs from the caller, so relative paths cannot be resolved)',
|
|
308
317
|
};
|
|
309
318
|
}
|
|
310
319
|
return { ok: true, path: resolved };
|
|
@@ -317,12 +326,12 @@ slide_create はパスを受けないため、その値はそのまま返し、
|
|
|
317
326
|
*/
|
|
318
327
|
export function normalizeThemeArgument(theme, options = {}) {
|
|
319
328
|
if (theme.startsWith(FILE_THEME_PREFIX)) {
|
|
320
|
-
const absolute = absoluteThemePath(theme.slice(FILE_THEME_PREFIX.length), 'theme
|
|
329
|
+
const absolute = absoluteThemePath(theme.slice(FILE_THEME_PREFIX.length), 'theme file:', theme);
|
|
321
330
|
return absolute.ok ? { ok: true, theme: `${FILE_THEME_PREFIX}${absolute.path}` } : absolute;
|
|
322
331
|
}
|
|
323
332
|
if (options.allowPath !== true || theme.startsWith(GIT_THEME_PREFIX))
|
|
324
333
|
return { ok: true, theme };
|
|
325
|
-
const absolute = absoluteThemePath(theme, 'theme
|
|
334
|
+
const absolute = absoluteThemePath(theme, 'theme', theme);
|
|
326
335
|
return absolute.ok ? { ok: true, theme: absolute.path } : absolute;
|
|
327
336
|
}
|
|
328
337
|
//# sourceMappingURL=_shared.js.map
|
|
@@ -9,28 +9,29 @@
|
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
import { assertOutputExtension as assertDrawioExportOutputExtension, drawioExportDefaultDependencies, errorToReason as drawioExportErrorToReason, executeDrawioExport, toExitCode as drawioExportToExitCode, } from '../../commands/drawio/export.js';
|
|
11
11
|
import { drawioUrlDefaultDependencies, errorData as drawioUrlErrorData, executeDrawioUrl, toExitCode as drawioUrlToExitCode, } from '../../commands/drawio/url.js';
|
|
12
|
+
import { createDiagnostics } from '../../diagnostics.js';
|
|
12
13
|
import { resolvePluginRoot } from '../../infra/_shared/plugin-root.js';
|
|
13
14
|
import { defaultIconRoot } from '../../infra/drawio/icons.js';
|
|
14
15
|
import { parsePathArguments, toCallToolResult } from '../result.js';
|
|
15
16
|
import { captureCommandOutput, chromiumDefaultDependencies, ensureChromium, formatError, textViolationMessage, violationCountOf, normalizeThemeArgument, TOOL_OUTPUT_SCHEMA, WINDOWS_PATH_NOTE, } from './_shared.js';
|
|
16
17
|
const drawioCreateInput = z.object({
|
|
17
|
-
input_path: z.string().describe('
|
|
18
|
-
mode: z.enum(['view', 'edit']).describe('
|
|
19
|
-
out_path: z.string().describe('
|
|
18
|
+
input_path: z.string().describe('Absolute path of the input .drawio file. ' + WINDOWS_PATH_NOTE),
|
|
19
|
+
mode: z.enum(['view', 'edit']).describe('Purpose of the generated URL (view / edit). The generated URL is the same for both').default('view'),
|
|
20
|
+
out_path: z.string().describe('Absolute path of the .html file to write the viewer HTML to (opening it redirects to draw.io). If omitted, only the URL is returned in data.url. ' + WINDOWS_PATH_NOTE).optional(),
|
|
20
21
|
theme: z.string()
|
|
21
|
-
.describe('
|
|
22
|
-
+ 'talk-dir
|
|
23
|
-
+ '
|
|
22
|
+
.describe('Theme used to check the font and font size: `git+https://<host>/<owner>/<repo>.git#<tag>`, `file:<absolute path>`, '
|
|
23
|
+
+ 'or the absolute path of a talk-dir or a theme root. If omitted, the theme of the talk-dir is used when the diagram is under its `public/`; '
|
|
24
|
+
+ 'otherwise the built-in default (sans-serif) is used. When the diagram for a slide is placed outside the talk-dir, pass the absolute path of the talk-dir. '
|
|
24
25
|
+ WINDOWS_PATH_NOTE)
|
|
25
26
|
.optional(),
|
|
26
|
-
png: z.boolean().describe('
|
|
27
|
+
png: z.boolean().describe('Whether to also write a PNG as a sibling file (<out_path with the extension replaced by .png>) when out_path is given').default(true),
|
|
27
28
|
});
|
|
28
29
|
const drawioExportInput = z.object({
|
|
29
|
-
input_path: z.string().describe('
|
|
30
|
-
icons_dir: z.string().describe('icon://
|
|
31
|
-
out_path: z.string().describe('
|
|
32
|
-
print_hash: z.boolean().describe('
|
|
33
|
-
pdf: z.boolean().describe('
|
|
30
|
+
input_path: z.string().describe('Absolute path of the input .drawio file. ' + WINDOWS_PATH_NOTE),
|
|
31
|
+
icons_dir: z.string().describe('Absolute path of the root directory that resolves icon:// references. If omitted, <plugin-root>/assets/drawio-icons (the catalog bundled with the plugin) is used. Always specify it for diagrams that use a project-specific icon catalog (omitting it does not raise an error). ' + WINDOWS_PATH_NOTE).optional(),
|
|
32
|
+
out_path: z.string().describe('Absolute path of the output SVG. If omitted, it is written to <input_path>.svg. The PDF is written to a sibling file (<out_path with the extension replaced by .pdf>). ' + WINDOWS_PATH_NOTE).optional(),
|
|
33
|
+
print_hash: z.boolean().describe('Compute only the composite hash used for staleness checks, without exporting').default(false),
|
|
34
|
+
pdf: z.boolean().describe('Whether to also write a PDF as a sibling file (<out_path with the extension replaced by .pdf>) alongside the SVG').default(true),
|
|
34
35
|
});
|
|
35
36
|
/**
|
|
36
37
|
PNG を出せなかったときの exit code。CLI の「警告あり」と同じ 3 に揃える。
|
|
@@ -40,13 +41,13 @@ const PNG_SKIPPED_EXIT_CODE = 3;
|
|
|
40
41
|
message 末尾の警告件数サフィックス。drawio_create / drawio_export で表記を揃える。
|
|
41
42
|
*/
|
|
42
43
|
function warningSuffix(warningCount) {
|
|
43
|
-
return warningCount > 0 ? ` (
|
|
44
|
+
return warningCount > 0 ? ` (${String(warningCount)} warnings; details in stderr)` : '';
|
|
44
45
|
}
|
|
45
46
|
function drawioCreateMessage(outputFile, warningCount) {
|
|
46
47
|
const warnings = warningSuffix(warningCount);
|
|
47
48
|
return outputFile === undefined
|
|
48
|
-
? `drawio URL
|
|
49
|
-
: `drawio
|
|
49
|
+
? `generated drawio URL${warnings}`
|
|
50
|
+
: `wrote drawio viewer HTML to ${outputFile}${warnings}`;
|
|
50
51
|
}
|
|
51
52
|
/**
|
|
52
53
|
chromium 不在で PNG を諦めたときの結果を、CLI の degrade と同形に寄せる (SC-002)。
|
|
@@ -91,13 +92,13 @@ call) => {
|
|
|
91
92
|
}
|
|
92
93
|
// PNG を書くときだけ chromium が要る。out_path 省略時と png: false は URL 生成だけで完結する。
|
|
93
94
|
const unavailable = input.out_path !== undefined && input.png
|
|
94
|
-
? await ensureChromium('drawio_create
|
|
95
|
+
? await ensureChromium('drawio_create PNG output', chromiumDefaultDependencies(), call.signal)
|
|
95
96
|
: undefined;
|
|
96
97
|
const output = captureCommandOutput();
|
|
97
98
|
// CLI は capturePng の失敗を stderr へ書いてから warning に数える。
|
|
98
99
|
// 同じ行を残して、「警告 N 件、詳細は stderr」という message を CLI と MCP で同じ意味にする。
|
|
99
100
|
if (unavailable !== undefined)
|
|
100
|
-
output.stderr.
|
|
101
|
+
createDiagnostics(output.stderr).warning(`PNG export failed: ${unavailable.message}`);
|
|
101
102
|
try {
|
|
102
103
|
const execution = await executeDrawioUrl(input.input_path,
|
|
103
104
|
// chromium が無いときは PNG を要求せずに実行する (表示用 HTML の生成は成立する)。
|
|
@@ -185,17 +186,17 @@ function drawioExportFailure(error) {
|
|
|
185
186
|
}
|
|
186
187
|
function drawioExportMessage(execution) {
|
|
187
188
|
if (execution.outputFile === undefined)
|
|
188
|
-
return
|
|
189
|
+
return `computed composite hash: ${execution.sourceSha256}`;
|
|
189
190
|
const pdf = execution.pdfFile === undefined ? '' : ` (PDF: ${execution.pdfFile})`;
|
|
190
|
-
return `SVG
|
|
191
|
+
return `wrote SVG to ${execution.outputFile}${pdf}${warningSuffix(execution.warningCount)}`;
|
|
191
192
|
}
|
|
192
193
|
// annotations は SDK 既定 (readOnlyHint: false / openWorldHint: true) と一致するため付けない。
|
|
193
194
|
// どちらのツールもファイルを書き、PNG 生成では viewer.diagrams.net、SVG 生成では embed.diagrams.net へ到達する。
|
|
194
195
|
export const drawioCreateTool = {
|
|
195
196
|
name: 'drawio_create',
|
|
196
197
|
config: {
|
|
197
|
-
title: 'drawio
|
|
198
|
-
description: 'drawio XML
|
|
198
|
+
title: 'Output a drawio diagram as a deliverable',
|
|
199
|
+
description: 'Turns drawio XML into a deliverable that opens directly in a browser. Writes viewer HTML (.html; opening it redirects to draw.io) to out_path and, by default, also writes a rendered PNG (useful for checking the rendering). icon:// references are resolved to data URIs and embedded. Before generating, it checks the diagram labels against the text rules and generates nothing if there is a violation. The font and font size are checked against the theme declaration (theme, or the theme of the talk-dir that is an ancestor of the diagram), and the result is returned in data.theme.',
|
|
199
200
|
inputSchema: drawioCreateInput,
|
|
200
201
|
outputSchema: TOOL_OUTPUT_SCHEMA,
|
|
201
202
|
},
|
|
@@ -205,7 +206,7 @@ export const drawioExportTool = {
|
|
|
205
206
|
name: 'drawio_export',
|
|
206
207
|
config: {
|
|
207
208
|
title: 'drawio SVG / PDF export',
|
|
208
|
-
description: 'drawio XML
|
|
209
|
+
description: 'Exports drawio XML to a static SVG and a sibling PDF. Set pdf: false to suppress the PDF. With print_hash, it exports nothing and returns only the composite hash used for staleness checks. It does not check the diagram text, so pass a .drawio that has gone through drawio_create.',
|
|
209
210
|
inputSchema: drawioExportInput,
|
|
210
211
|
outputSchema: TOOL_OUTPUT_SCHEMA,
|
|
211
212
|
},
|
|
@@ -8,8 +8,8 @@ import { errorData, EVIDENCE_CREATE_FAILURE_EXIT_CODE, evidenceCreateDefaultDepe
|
|
|
8
8
|
import { parsePathArguments, toCallToolResult } from '../result.js';
|
|
9
9
|
import { captureCommandOutput, formatError, textViolationMessage, TOOL_OUTPUT_SCHEMA, violationCountOf, WINDOWS_PATH_NOTE } from './_shared.js';
|
|
10
10
|
const evidenceCreateInput = z.object({
|
|
11
|
-
input_path: z.string().describe('EvidenceSpec JSON
|
|
12
|
-
out_path: z.string().optional().describe('
|
|
11
|
+
input_path: z.string().describe('Absolute path of the EvidenceSpec JSON. ' + WINDOWS_PATH_NOTE),
|
|
12
|
+
out_path: z.string().optional().describe('Absolute path of the xlsx to write. If omitted, evidence.xlsx in the same directory as input_path. ' + WINDOWS_PATH_NOTE),
|
|
13
13
|
});
|
|
14
14
|
/**
|
|
15
15
|
out_path 省略時の既定。
|
|
@@ -35,13 +35,13 @@ async function handleEvidenceCreate(arguments_) {
|
|
|
35
35
|
stderr: output.stderr,
|
|
36
36
|
};
|
|
37
37
|
const data = await executeEvidenceCreate({ input: input.input_path, out: input.out_path ?? defaultOutPath(input.input_path) }, dependencies);
|
|
38
|
-
const counts =
|
|
38
|
+
const counts = `${String(data.items)} items; ${String(data.annotations)} annotations; ${String(data.skipped.length)} skipped`;
|
|
39
39
|
return toCallToolResult({
|
|
40
40
|
ok: true,
|
|
41
41
|
exitCode: 0,
|
|
42
42
|
artifacts: [data.outPath],
|
|
43
43
|
data: { ...data },
|
|
44
|
-
message:
|
|
44
|
+
message: `generated evidence xlsx: ${data.outPath} (${counts})`,
|
|
45
45
|
...output.part(),
|
|
46
46
|
});
|
|
47
47
|
}
|
|
@@ -63,10 +63,10 @@ async function handleEvidenceCreate(arguments_) {
|
|
|
63
63
|
export const evidenceCreateTool = {
|
|
64
64
|
name: 'evidence_create',
|
|
65
65
|
config: {
|
|
66
|
-
title: '
|
|
67
|
-
description: '
|
|
68
|
-
+ ' spec
|
|
69
|
-
+ '
|
|
66
|
+
title: 'Generate evidence xlsx',
|
|
67
|
+
description: 'Generates a work-evidence xlsx with screenshots pasted in, from an EvidenceSpec JSON.'
|
|
68
|
+
+ ' Places the images listed in the spec in order and adds annotations.'
|
|
69
|
+
+ ' Before generating, it checks the title, captions and annotations against the text rules and generates nothing if there is a violation.',
|
|
70
70
|
inputSchema: evidenceCreateInput,
|
|
71
71
|
outputSchema: TOOL_OUTPUT_SCHEMA,
|
|
72
72
|
// ローカルの spec / 画像を読んで xlsx を書くだけでネットワークには到達しない。
|
|
@@ -55,7 +55,7 @@ signal) {
|
|
|
55
55
|
const detail = isInstalled
|
|
56
56
|
? undefined
|
|
57
57
|
: (spawned.exitCode === 0
|
|
58
|
-
?
|
|
58
|
+
? `download command succeeded, but runtime dependencies cannot be resolved from ${location ?? 'the persistent location'}`
|
|
59
59
|
: runtimeInstallFailureDetail(spawned));
|
|
60
60
|
return { installed: isInstalled, downloaded: isInstalled, durationMs, location, detail, spawned };
|
|
61
61
|
}
|
|
@@ -71,18 +71,18 @@ function runtimeInstallFailureDetail(result) {
|
|
|
71
71
|
*/
|
|
72
72
|
function runtimeFailureReason(result) {
|
|
73
73
|
if (result.exitCode === LOCK_CONFLICT_EXIT_CODE) {
|
|
74
|
-
return
|
|
75
|
-
+ '
|
|
74
|
+
return `another process is downloading runtime dependencies (lock wait exceeded ${String(LOCK_WAIT_SECONDS)} seconds)`
|
|
75
|
+
+ '; wait for it to finish, then run again';
|
|
76
76
|
}
|
|
77
77
|
if (result.timedOut) {
|
|
78
|
-
return '
|
|
78
|
+
return 'download timed out; check network reachability and the proxy settings, then run again';
|
|
79
79
|
}
|
|
80
80
|
if (result.exitCode === null) {
|
|
81
81
|
return result.signal === null
|
|
82
|
-
? 'npm
|
|
83
|
-
:
|
|
82
|
+
? 'could not start npm (see stderr for the reason)'
|
|
83
|
+
: `download command was interrupted by ${result.signal}; the download was cut off externally`;
|
|
84
84
|
}
|
|
85
|
-
return `npm install
|
|
85
|
+
return `npm install exited with ${String(result.exitCode)} (see stderr for the reason)`;
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
Chromium を取得する。取得済みでも Playwright 側が冪等に skip するため常に実行する。
|
|
@@ -103,7 +103,7 @@ signal) {
|
|
|
103
103
|
const detail = isInstalled
|
|
104
104
|
? undefined
|
|
105
105
|
: (spawned.exitCode === 0
|
|
106
|
-
?
|
|
106
|
+
? `download command succeeded, but chromium is not in ${location ?? 'the browsers directory'}`
|
|
107
107
|
: chromiumInstallFailureDetail(spawned));
|
|
108
108
|
return { installed: isInstalled, downloaded: isInstalled && !isInstalledBefore, durationMs, location, detail, spawned };
|
|
109
109
|
}
|
|
@@ -130,7 +130,7 @@ signal) {
|
|
|
130
130
|
}
|
|
131
131
|
case 'installed': {
|
|
132
132
|
dependencies.record('ok');
|
|
133
|
-
return { ...base, installed: true, downloaded: true, detail:
|
|
133
|
+
return { ...base, installed: true, downloaded: true, detail: `installed packages: ${outcome.packages.join(' ')}` };
|
|
134
134
|
}
|
|
135
135
|
case 'missing': {
|
|
136
136
|
dependencies.record('missing');
|
|
@@ -141,7 +141,7 @@ signal) {
|
|
|
141
141
|
// 実行ファイルは runChromiumStage が揃えており、起動の失敗は各ツールが案内付きで返す。
|
|
142
142
|
// そのためここでは理由を残して通す (bin/pecotv の `pecotv chromium host-deps` と同じ扱い)。
|
|
143
143
|
dependencies.record('launch-failed');
|
|
144
|
-
return { ...base, installed: true, downloaded: false, detail: `Chromium
|
|
144
|
+
return { ...base, installed: true, downloaded: false, detail: `could not launch Chromium (cause other than OS libraries): ${outcome.detail}` };
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
}
|
|
@@ -169,12 +169,12 @@ function artifactsOf(stages) {
|
|
|
169
169
|
function successMessage(runtime, chromium, hostDependencies) {
|
|
170
170
|
const parts = [
|
|
171
171
|
runtime.downloaded
|
|
172
|
-
?
|
|
173
|
-
: '
|
|
172
|
+
? `runtime dependencies downloaded (${String(Math.round(runtime.durationMs / 1000))}s)`
|
|
173
|
+
: 'runtime dependencies already installed',
|
|
174
174
|
chromium.downloaded
|
|
175
|
-
? `Playwright Chromium
|
|
176
|
-
: 'Playwright Chromium
|
|
177
|
-
...(hostDependencies.downloaded ? [`
|
|
175
|
+
? `Playwright Chromium downloaded (${String(Math.round(chromium.durationMs / 1000))}s)`
|
|
176
|
+
: 'Playwright Chromium already installed',
|
|
177
|
+
...(hostDependencies.downloaded ? [`OS libraries required to launch Chromium installed (${hostDependencies.detail ?? ''})`] : []),
|
|
178
178
|
// 起動できなかったが OS のライブラリ以外が原因 (launch-failed)。成功のまま理由を伝える。
|
|
179
179
|
...(hostDependencies.downloaded || hostDependencies.detail === undefined ? [] : [hostDependencies.detail]),
|
|
180
180
|
];
|
|
@@ -229,11 +229,11 @@ export function setupTool(buildDependencies = chromiumDefaultDependencies, build
|
|
|
229
229
|
// 片方だけを見ると、もう片方の理由が data.<系統>.detail にしか残らず message から
|
|
230
230
|
// 消えるため、失敗した系統を全て畳んで載せる。
|
|
231
231
|
const failures = [
|
|
232
|
-
...(runtime.installed ? [] : [{ label: '
|
|
232
|
+
...(runtime.installed ? [] : [{ label: 'runtime dependencies', reason: 'runtime-install-failed', stage: runtime }]),
|
|
233
233
|
...(chromium.installed ? [] : [{ label: 'Playwright Chromium', reason: 'chromium-install-failed', stage: chromium }]),
|
|
234
234
|
...(hostDependencies === undefined || hostDependencies.installed
|
|
235
235
|
? []
|
|
236
|
-
: [{ label: 'Chromium
|
|
236
|
+
: [{ label: 'Chromium OS libraries', reason: 'chromium-host-deps-missing', stage: hostDependencies }]),
|
|
237
237
|
];
|
|
238
238
|
const detail = failures.map(failure => `${failure.label}: ${failure.stage.detail ?? ''}`).join(' / ');
|
|
239
239
|
// OS ライブラリの失敗は「取得」ではなく「足りない」ことを案内するため、取得の失敗と分ける。
|
|
@@ -243,7 +243,7 @@ export function setupTool(buildDependencies = chromiumDefaultDependencies, build
|
|
|
243
243
|
const message = [
|
|
244
244
|
...(acquisitionFailures.length === 0
|
|
245
245
|
? []
|
|
246
|
-
: [
|
|
246
|
+
: [`download failed for ${acquisitionFailures.map(failure => failure.label).join(' / ')}: `
|
|
247
247
|
+ acquisitionFailures.map(failure => `${failure.label}: ${failure.stage.detail ?? ''}`).join(' / ')]),
|
|
248
248
|
...(hostDependenciesDetail === undefined ? [] : [hostDependenciesDetail]),
|
|
249
249
|
].join(' / ');
|
|
@@ -265,14 +265,14 @@ export function setupTool(buildDependencies = chromiumDefaultDependencies, build
|
|
|
265
265
|
return {
|
|
266
266
|
name: 'setup',
|
|
267
267
|
config: {
|
|
268
|
-
title: '
|
|
269
|
-
description: 'pecotv
|
|
270
|
-
+ 'slide_create / slide_convert / slide_sync
|
|
271
|
-
+ '
|
|
272
|
-
+ '
|
|
273
|
-
+ 'Chromium
|
|
274
|
-
+ '
|
|
275
|
-
+ '
|
|
268
|
+
title: 'Prepare the runtime (runtime dependencies / Chromium download and OS libraries)',
|
|
269
|
+
description: 'Downloads the runtime dependencies pecotv uses (@slidev/cli / dom-to-pptx / @slidev/parser, etc.) and Playwright Chromium. '
|
|
270
|
+
+ 'Call it when slide_create / slide_convert / slide_sync fail with "runtime dependencies are not installed", '
|
|
271
|
+
+ 'or when drawio_export / slide_convert / drawio_create PNG output fails with "Playwright Chromium is not installed". '
|
|
272
|
+
+ 'The first run downloads about 600MB of runtime dependencies and about 120MB of Chromium, so it takes tens of seconds. '
|
|
273
|
+
+ 'If OS libraries needed to launch Chromium are missing, it installs them with apt-get where sudo is available, '
|
|
274
|
+
+ 'and otherwise returns the command to install them. '
|
|
275
|
+
+ 'It skips what is already installed, so it finishes quickly and is safe to call repeatedly.',
|
|
276
276
|
// 引数を取らないツールは空の z.object を渡す (src/mcp/server.ts の ToolConfig)。
|
|
277
277
|
inputSchema: z.object({}),
|
|
278
278
|
outputSchema: TOOL_OUTPUT_SCHEMA,
|
|
@@ -40,14 +40,14 @@ function defaultEnsureThemeLinked() {
|
|
|
40
40
|
}
|
|
41
41
|
const slideDevInput = z.object({
|
|
42
42
|
dir: z.string()
|
|
43
|
-
.describe('
|
|
43
|
+
.describe('Absolute path of the talk-dir to start the Slidev dev server for. Relative paths are not accepted. '
|
|
44
44
|
+ WINDOWS_PATH_NOTE),
|
|
45
45
|
port: z.number().int().min(1).max(65_535).optional()
|
|
46
|
-
.describe('
|
|
47
|
-
+ '
|
|
48
|
-
+ '
|
|
46
|
+
.describe('Port to start on. If it is in use, the call fails instead of moving to another port. '
|
|
47
|
+
+ 'If omitted, ports 3030 to 3034 are tried in ascending order and the first free one is used. '
|
|
48
|
+
+ 'Specifying a different port for a talk-dir that is already running reopens it on that port'),
|
|
49
49
|
stop: z.boolean().default(false)
|
|
50
|
-
.describe('
|
|
50
|
+
.describe('Stop the dev server of the talk-dir when true (arguments other than dir have no effect when stopping)'),
|
|
51
51
|
});
|
|
52
52
|
/**
|
|
53
53
|
spawn する前に talk-dir の体裁を確認する。続行してよければ undefined。
|
|
@@ -66,14 +66,14 @@ function inspectTalkDirectory(directory) {
|
|
|
66
66
|
if (!isDirectory) {
|
|
67
67
|
return {
|
|
68
68
|
reason: 'talk-dir-not-found',
|
|
69
|
-
detail: `
|
|
70
|
-
+ '`slide_create`
|
|
69
|
+
detail: `directory not found: ${directory}`
|
|
70
|
+
+ '; specify the absolute path of a directory generated by `slide_create`',
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
if (!existsSync(path.join(directory, 'slides.md'))) {
|
|
74
74
|
return {
|
|
75
75
|
reason: 'slides-md-not-found',
|
|
76
|
-
detail:
|
|
76
|
+
detail: `not a talk-dir (no slides.md): ${directory}; specify the root of a Slidev project`,
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
return undefined;
|
|
@@ -87,8 +87,8 @@ function inspectNodeModules(directory) {
|
|
|
87
87
|
if (!existsSync(path.join(directory, 'node_modules'))) {
|
|
88
88
|
return {
|
|
89
89
|
reason: 'node-modules-unresolved',
|
|
90
|
-
detail:
|
|
91
|
-
+
|
|
90
|
+
detail: `cannot resolve ${directory}/node_modules (the symlink may be broken)`
|
|
91
|
+
+ `; run \`slide_sync\` (dir: ${directory}), then try again`,
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
return undefined;
|
|
@@ -144,8 +144,8 @@ export function slideDevTool(buildRegistry = devServerRegistry, buildRuntimeDepe
|
|
|
144
144
|
},
|
|
145
145
|
// 動いていないサーバへの停止要求は失敗にしない (呼び出しの目的は達成されている)。
|
|
146
146
|
message: stopped.stopped
|
|
147
|
-
? `slide dev:
|
|
148
|
-
: `slide dev:
|
|
147
|
+
? `slide dev: stopped (${input.dir})`
|
|
148
|
+
: `slide dev: no running server (${input.dir})`,
|
|
149
149
|
...NO_OUTPUT,
|
|
150
150
|
});
|
|
151
151
|
}
|
|
@@ -210,20 +210,20 @@ export function slideDevTool(buildRegistry = devServerRegistry, buildRuntimeDepe
|
|
|
210
210
|
...(warnings.length > 0 && { warnings }),
|
|
211
211
|
},
|
|
212
212
|
message: started.reused
|
|
213
|
-
? `slide dev:
|
|
214
|
-
: `slide dev:
|
|
213
|
+
? `slide dev: reusing the running server ${started.url}`
|
|
214
|
+
: `slide dev: started ${started.url}`,
|
|
215
215
|
...NO_OUTPUT,
|
|
216
216
|
});
|
|
217
217
|
};
|
|
218
218
|
return {
|
|
219
219
|
name: 'slide_dev',
|
|
220
220
|
config: {
|
|
221
|
-
title: 'Slidev
|
|
222
|
-
description: 'talk-dir
|
|
223
|
-
+ '
|
|
224
|
-
+ '
|
|
225
|
-
+ 'stop: true
|
|
226
|
-
+ '
|
|
221
|
+
title: 'Start a Slidev preview',
|
|
222
|
+
description: 'Starts the Slidev dev server of a talk-dir and returns a URL that opens in a browser (data.url). '
|
|
223
|
+
+ 'The port can be set with port; if omitted, a free port from 3030 to 3034 is used. '
|
|
224
|
+
+ 'Calling again for the same talk-dir returns the running server as it is (data.reused: true). '
|
|
225
|
+
+ 'Set stop: true to stop it. '
|
|
226
|
+
+ 'The server runs only while the MCP server process is alive; the preview ends with the session.',
|
|
227
227
|
inputSchema: slideDevInput,
|
|
228
228
|
outputSchema: TOOL_OUTPUT_SCHEMA,
|
|
229
229
|
// annotations は明示しない。
|