@pecot/visual-mcp 3.1.1-dev.142 → 3.1.1-dev.143
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/cli/dist/commands/drawio/export.d.ts +9 -24
- package/cli/dist/commands/drawio/export.js +15 -135
- package/cli/dist/commands/drawio/theme.d.ts +3 -3
- package/cli/dist/commands/drawio/theme.js +10 -10
- package/cli/dist/commands/drawio/url.d.ts +9 -26
- package/cli/dist/commands/drawio/url.js +18 -131
- package/cli/dist/commands/evidence-xlsx/create.d.ts +4 -12
- package/cli/dist/commands/evidence-xlsx/create.js +9 -92
- package/cli/dist/commands/slidev-project/create.d.ts +5 -30
- package/cli/dist/commands/slidev-project/create.js +12 -136
- package/cli/dist/commands/slidev-project/linked-theme.d.ts +1 -1
- package/cli/dist/commands/slidev-project/linked-theme.js +2 -2
- package/cli/dist/commands/slidev-project/lint.d.ts +8 -37
- package/cli/dist/commands/slidev-project/lint.js +16 -161
- package/cli/dist/commands/slidev-project/sync.d.ts +7 -26
- package/cli/dist/commands/slidev-project/sync.js +15 -156
- package/cli/dist/commands/slidev-project/theme.d.ts +2 -13
- package/cli/dist/commands/slidev-project/theme.js +3 -93
- package/cli/dist/commands/slidev-to-pptx/convert.d.ts +10 -17
- package/cli/dist/commands/slidev-to-pptx/convert.js +25 -266
- package/cli/dist/diagnostics.d.ts +0 -4
- package/cli/dist/diagnostics.js +0 -6
- package/cli/dist/domain/_shared/failure-kind.d.ts +2 -2
- package/cli/dist/domain/_shared/failure-kind.js +2 -2
- package/cli/dist/domain/_shared/ports.d.ts +3 -4
- package/cli/dist/domain/evidence-xlsx/image-dimensions.d.ts +1 -1
- package/cli/dist/domain/pptx-ooxml/preview-normalize.d.ts +0 -12
- package/cli/dist/domain/pptx-ooxml/preview-normalize.js +1 -25
- package/cli/dist/domain/slidev-project/errors.js +2 -2
- package/cli/dist/domain/slidev-project/generated-files.js +3 -3
- package/cli/dist/domain/slidev-project/lint.d.ts +7 -7
- package/cli/dist/domain/slidev-project/lint.js +8 -8
- package/cli/dist/domain/slidev-project/package-json.d.ts +1 -1
- package/cli/dist/domain/slidev-project/package-json.js +2 -2
- package/cli/dist/domain/slidev-project/sync.d.ts +11 -11
- package/cli/dist/domain/slidev-project/sync.js +18 -19
- package/cli/dist/domain/slidev-theme/deck-lint-input.js +1 -1
- package/cli/dist/domain/slidev-theme/declaration.js +1 -1
- package/cli/dist/domain/slidev-theme/skeleton.js +1 -1
- package/cli/dist/domain/slidev-theme/talk-theme.d.ts +3 -3
- package/cli/dist/domain/slidev-theme/talk-theme.js +5 -7
- package/cli/dist/domain/slidev-to-pptx/config.d.ts +1 -1
- package/cli/dist/domain/slidev-to-pptx/config.js +1 -1
- package/cli/dist/domain/slidev-to-pptx/errors.d.ts +4 -4
- package/cli/dist/domain/slidev-to-pptx/errors.js +4 -4
- package/cli/dist/domain/slidev-to-pptx/types.d.ts +1 -1
- package/cli/dist/infra/_shared/dependency-root.d.ts +9 -67
- package/cli/dist/infra/_shared/dependency-root.js +15 -126
- package/cli/dist/infra/_shared/flock.js +1 -2
- package/cli/dist/infra/_shared/plugin-root.d.ts +3 -5
- package/cli/dist/infra/_shared/plugin-root.js +5 -12
- package/cli/dist/infra/evidence-xlsx/workbook-writer.d.ts +1 -1
- package/cli/dist/infra/playwright/chromium.d.ts +4 -15
- package/cli/dist/infra/playwright/chromium.js +6 -18
- package/cli/dist/infra/playwright/host-dependencies.d.ts +2 -2
- package/cli/dist/infra/playwright/host-dependencies.js +6 -6
- package/cli/dist/infra/pptx-ooxml/soffice.js +1 -1
- package/cli/dist/infra/slidev-project/eslint-runner.d.ts +1 -1
- package/cli/dist/infra/slidev-project/eslint-runner.js +2 -2
- package/cli/dist/infra/slidev-to-pptx/index.js +1 -1
- package/cli/dist/infra/slidev-to-pptx/pipeline.js +1 -1
- package/cli/dist/infra/slidev-to-pptx/prerender-capture.js +1 -1
- package/cli/dist/infra/slidev-to-pptx/server.js +2 -2
- package/cli/dist/main.d.ts +3 -0
- package/cli/dist/main.js +28 -0
- package/cli/dist/mcp/result.d.ts +5 -1
- package/cli/dist/mcp/result.js +9 -1
- package/cli/dist/mcp/serve.d.ts +2 -3
- package/cli/dist/mcp/serve.js +4 -5
- package/cli/dist/mcp/server.d.ts +5 -1
- package/cli/dist/mcp/server.js +10 -7
- package/cli/dist/mcp/tool-names.js +4 -1
- package/cli/dist/mcp/tools/_shared.d.ts +1 -1
- package/cli/dist/mcp/tools/_shared.js +2 -2
- package/cli/dist/mcp/tools/drawio.js +12 -15
- package/cli/dist/mcp/tools/evidence.js +2 -2
- package/cli/dist/mcp/tools/file.d.ts +31 -0
- package/cli/dist/mcp/tools/file.js +482 -0
- package/cli/dist/mcp/tools/index.d.ts +1 -1
- package/cli/dist/mcp/tools/index.js +6 -3
- package/cli/dist/mcp/tools/setup.js +3 -3
- package/cli/dist/mcp/tools/slide-dev.js +6 -7
- package/cli/dist/mcp/tools/slide-page.js +3 -3
- package/cli/dist/mcp/tools/slide-theme.d.ts +0 -1
- package/cli/dist/mcp/tools/slide-theme.js +2 -3
- package/cli/dist/mcp/tools/slide.d.ts +4 -4
- package/cli/dist/mcp/tools/slide.js +13 -14
- package/cli/dist/node-runtime.d.ts +2 -2
- package/cli/dist/node-runtime.js +4 -13
- package/cli/dist/version.d.ts +1 -8
- package/cli/dist/version.js +2 -11
- package/npm-shrinkwrap.json +7 -17
- package/package.json +2 -3
- package/bin/pecot-visual-mcp.mjs +0 -10
- package/cli/dist/cli.d.ts +0 -5
- package/cli/dist/cli.js +0 -109
- package/cli/dist/commands/chromium/host-dependencies.d.ts +0 -18
- package/cli/dist/commands/chromium/host-dependencies.js +0 -75
- package/cli/dist/commands/pptx-ooxml/preview.d.ts +0 -74
- package/cli/dist/commands/pptx-ooxml/preview.js +0 -399
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { FailureReason } from '../../domain/_shared/failure-kind.js';
|
|
2
|
-
import { Command } from 'commander';
|
|
3
2
|
export declare class DrawioExportUsageError extends Error {
|
|
4
3
|
readonly reason: FailureReason;
|
|
5
4
|
constructor(message: string, reason: FailureReason);
|
|
@@ -35,7 +34,7 @@ export interface DrawioExportResultSummary {
|
|
|
35
34
|
readonly sourceSha256: string;
|
|
36
35
|
readonly iconCount: number;
|
|
37
36
|
/**
|
|
38
|
-
|
|
37
|
+
`printHash` はハッシュ算出だけを行い、export と書き出しは行わないため false。
|
|
39
38
|
*/
|
|
40
39
|
readonly written: boolean;
|
|
41
40
|
/**
|
|
@@ -49,9 +48,9 @@ export interface DrawioExportResultSummary {
|
|
|
49
48
|
readonly warningCount: number;
|
|
50
49
|
}
|
|
51
50
|
/**
|
|
52
|
-
|
|
53
|
-
PDF 同時出力時は兄弟 PDF が SVG
|
|
54
|
-
|
|
51
|
+
出力パスの拡張子を確認する。`.pdf` は `pdf` の有無に関係なく拒否する。
|
|
52
|
+
PDF 同時出力時は兄弟 PDF が SVG 自身を上書きし、`pdf: false` 時は中身が SVG の `.pdf` が書かれるため。
|
|
53
|
+
`printHash` は何も書かないため確認しない。
|
|
55
54
|
|
|
56
55
|
入力の読み込みや Chromium の確認より先に呼べるよう、IO を伴わない純粋関数にしてある
|
|
57
56
|
(MCP の drawio_export も Chromium 確認の前にこれを呼ぶ)。
|
|
@@ -59,16 +58,15 @@ PDF 同時出力時は兄弟 PDF が SVG 自身を上書きし、`--no-pdf` 時
|
|
|
59
58
|
export declare function assertOutputExtension(output: string | undefined, options: Readonly<Pick<DrawioExportOptions, 'printHash'>>): void;
|
|
60
59
|
export declare function runDrawioExport(inputFile: string, options: Readonly<DrawioExportOptions>, dependencies: DrawioExportDependencies): Promise<DrawioExportResultSummary>;
|
|
61
60
|
/**
|
|
62
|
-
executeDrawioExport の結果。
|
|
63
|
-
どちらもこれだけを見る(`data` の組み立てを両側に複製しないための共有点)。
|
|
61
|
+
executeDrawioExport の結果。MCP ツールの ToolResult 組み立てはこれだけを見る。
|
|
64
62
|
*/
|
|
65
63
|
export interface DrawioExportExecution {
|
|
66
64
|
/**
|
|
67
|
-
|
|
65
|
+
ツールの structuredContent に載せる値。
|
|
68
66
|
*/
|
|
69
67
|
readonly data: Readonly<Record<string, unknown>>;
|
|
70
68
|
/**
|
|
71
|
-
|
|
69
|
+
書き出したファイルの絶対パス。`printHash` では空。
|
|
72
70
|
*/
|
|
73
71
|
readonly artifacts: readonly string[];
|
|
74
72
|
/**
|
|
@@ -76,7 +74,7 @@ export interface DrawioExportExecution {
|
|
|
76
74
|
*/
|
|
77
75
|
readonly sourceSha256: string;
|
|
78
76
|
/**
|
|
79
|
-
書き出した SVG
|
|
77
|
+
書き出した SVG の絶対パス。`printHash` では undefined。
|
|
80
78
|
*/
|
|
81
79
|
readonly outputFile: string | undefined;
|
|
82
80
|
/**
|
|
@@ -84,24 +82,11 @@ export interface DrawioExportExecution {
|
|
|
84
82
|
*/
|
|
85
83
|
readonly pdfFile: string | undefined;
|
|
86
84
|
readonly warningCount: number;
|
|
87
|
-
/**
|
|
88
|
-
0 = 成功、3 = 警告あり(PDF 生成失敗)。`--print-hash` は常に 0。
|
|
89
|
-
*/
|
|
90
|
-
readonly exitCode: number;
|
|
91
85
|
}
|
|
92
86
|
/**
|
|
93
|
-
export(または
|
|
94
|
-
|
|
95
|
-
呼び出し元(commander action / MCP ツール)に残るのは「どう見せるか」だけにする。
|
|
87
|
+
export(または `printHash` のハッシュ算出)を実行し、ツールの結果に載せる data を組み立てる。
|
|
96
88
|
*/
|
|
97
89
|
export declare function executeDrawioExport(inputFile: string, options: Readonly<DrawioExportOptions>, dependencies: DrawioExportDependencies): Promise<DrawioExportExecution>;
|
|
98
90
|
export declare function errorToReason(error: unknown): FailureReason;
|
|
99
|
-
/**
|
|
100
|
-
例外を exit code 規約へ写す(2 = UsageError、1 = それ以外)。
|
|
101
|
-
|
|
102
|
-
CLI の action と MCP ツールが同じ対応表を使うための共有点。
|
|
103
|
-
*/
|
|
104
|
-
export declare function toExitCode(error: unknown): number;
|
|
105
|
-
export declare function createDrawioExportCommand(buildDependencies: () => DrawioExportDependencies): Command;
|
|
106
91
|
export declare function drawioExportDefaultDependencies(): DrawioExportDependencies;
|
|
107
92
|
//# sourceMappingURL=export.d.ts.map
|
|
@@ -1,43 +1,31 @@
|
|
|
1
|
-
//
|
|
2
|
-
// の実装。commands/drawio/url.ts と同形の DI / 二段例外 / writeErr フックを採用する。
|
|
1
|
+
// drawio_export ツールの実装。commands/drawio/url.ts と同形の DI / 二段例外を採用する。
|
|
3
2
|
//
|
|
4
3
|
// 公開ビルドの draw.io 図を CDN 非依存にするため、パイプライン(公開フック)が
|
|
5
4
|
// 呼ぶ自動化の一部。生 XML をそのまま export すると `icon://` 参照が全滅する。
|
|
6
5
|
// そのため icon 解決 → export → color-scheme 固定 → 合成ハッシュ埋め込み の順で処理する。
|
|
7
6
|
//
|
|
8
7
|
// 標準で SVG の兄弟ファイル(拡張子を .pdf に置換)として PDF も書き出す。PDF の失敗は
|
|
9
|
-
// SVG を書いたうえで warning
|
|
10
|
-
//
|
|
8
|
+
// SVG を書いたうえで warning に落とす。`pdf: false` で抑止する。出力パスに `.pdf` は
|
|
9
|
+
// `pdf` の有無に関係なく指定できない(中身が SVG の `.pdf` を書かないため)。
|
|
11
10
|
//
|
|
12
|
-
//
|
|
11
|
+
// `printHash` は export を伴わず合成ハッシュだけを出す。公開フックが「既存 SVG が
|
|
13
12
|
// 現在の入力と対応しているか」を判定するためのルート。
|
|
14
|
-
// ハッシュの組み立て規則をフック側の bash
|
|
15
|
-
//
|
|
16
|
-
// exit code 規約を次に示す。
|
|
17
|
-
// 0 = success。
|
|
18
|
-
// 1 = RuntimeError (input/output IO failure・icon 未解決・export 失敗)。
|
|
19
|
-
// 2 = UsageError (invalid option)。
|
|
20
|
-
// 3 = warnings present (PDF 生成失敗)。
|
|
13
|
+
// ハッシュの組み立て規則をフック側の bash に複製しないよう、ツール側へ寄せている。
|
|
21
14
|
import { mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
22
15
|
import path from 'node:path';
|
|
23
|
-
import { Command } from 'commander';
|
|
24
16
|
import { collectIconReferences, computeSourceHash, embedSourceHash, forceLightColorScheme, resolveIconsForExport, siblingPath } from '../../domain/drawio/export.js';
|
|
25
|
-
import { createDiagnostics
|
|
17
|
+
import { createDiagnostics } from '../../diagnostics.js';
|
|
26
18
|
import { createIconResolver } from '../../infra/drawio/icons.js';
|
|
27
19
|
import { exportPdf } from '../../infra/drawio/pdf.js';
|
|
28
20
|
import { exportViaEmbed } from '../../infra/drawio/screenshot.js';
|
|
29
21
|
/**
|
|
30
|
-
|
|
22
|
+
`output` 省略時に付与する拡張子。`<xmlSrc>.svg` という公開物の命名規約と揃える。
|
|
31
23
|
*/
|
|
32
24
|
const OUTPUT_SUFFIX = '.svg';
|
|
33
25
|
/**
|
|
34
26
|
兄弟 PDF の拡張子。
|
|
35
27
|
*/
|
|
36
28
|
const PDF_EXTENSION = '.pdf';
|
|
37
|
-
/**
|
|
38
|
-
警告が 1 件以上あるときの exit code。drawio url の「警告あり」と揃える。
|
|
39
|
-
*/
|
|
40
|
-
const WARNING_EXIT_CODE = 3;
|
|
41
29
|
export class DrawioExportUsageError extends Error {
|
|
42
30
|
reason;
|
|
43
31
|
constructor(message, reason) {
|
|
@@ -55,9 +43,9 @@ export class DrawioExportRuntimeError extends Error {
|
|
|
55
43
|
}
|
|
56
44
|
}
|
|
57
45
|
/**
|
|
58
|
-
|
|
59
|
-
PDF 同時出力時は兄弟 PDF が SVG
|
|
60
|
-
|
|
46
|
+
出力パスの拡張子を確認する。`.pdf` は `pdf` の有無に関係なく拒否する。
|
|
47
|
+
PDF 同時出力時は兄弟 PDF が SVG 自身を上書きし、`pdf: false` 時は中身が SVG の `.pdf` が書かれるため。
|
|
48
|
+
`printHash` は何も書かないため確認しない。
|
|
61
49
|
|
|
62
50
|
入力の読み込みや Chromium の確認より先に呼べるよう、IO を伴わない純粋関数にしてある
|
|
63
51
|
(MCP の drawio_export も Chromium 確認の前にこれを呼ぶ)。
|
|
@@ -65,7 +53,7 @@ PDF 同時出力時は兄弟 PDF が SVG 自身を上書きし、`--no-pdf` 時
|
|
|
65
53
|
export function assertOutputExtension(output, options) {
|
|
66
54
|
if (output === undefined || output === '' || options.printHash || (path.extname(output).toLowerCase() !== PDF_EXTENSION))
|
|
67
55
|
return;
|
|
68
|
-
throw new DrawioExportUsageError(
|
|
56
|
+
throw new DrawioExportUsageError(`output cannot use the ${PDF_EXTENSION} extension: ${path.resolve(output)} (fix: the output is SVG, so use an extension such as ${OUTPUT_SUFFIX})`, 'invalid-output-extension');
|
|
69
57
|
}
|
|
70
58
|
export async function runDrawioExport(inputFile, options,
|
|
71
59
|
// DI 経由の write は mutate メソッド。
|
|
@@ -77,7 +65,7 @@ dependencies) {
|
|
|
77
65
|
: path.resolve(options.output);
|
|
78
66
|
// 入力の読み込みより先に確認して、UsageError のルートでは成果物を残さない。
|
|
79
67
|
assertOutputExtension(options.output, options);
|
|
80
|
-
// 兄弟 PDF は SVG の拡張子を `.pdf`
|
|
68
|
+
// 兄弟 PDF は SVG の拡張子を `.pdf` に置換して置く。出力パスが `.svg` のように拡張子だけの
|
|
81
69
|
// ファイル名では置換でなく付加となり、`.svg.pdf` ができる(規則は siblingPath に集約)。
|
|
82
70
|
const pdfPath = siblingPath(absoluteOutput, PDF_EXTENSION);
|
|
83
71
|
let xml;
|
|
@@ -152,7 +140,7 @@ dependencies) {
|
|
|
152
140
|
catch (error) {
|
|
153
141
|
createDiagnostics(dependencies.stderr).warning(`PDF export failed: ${formatError(error)}`);
|
|
154
142
|
// 古い PDF の削除失敗は独立した警告として数えない。今回の PDF 失敗 1 件(pdfFailed /
|
|
155
|
-
// warnings: 1
|
|
143
|
+
// warnings: 1)に集約し、結果の data には出さず stderr の行だけで知らせる。
|
|
156
144
|
// 呼び出し側は `pdf: null` を見て隣の PDF を今回の出力として扱わない前提にする。
|
|
157
145
|
try {
|
|
158
146
|
await dependencies.removeFile(pdfPath);
|
|
@@ -164,9 +152,7 @@ dependencies) {
|
|
|
164
152
|
}
|
|
165
153
|
}
|
|
166
154
|
/**
|
|
167
|
-
export(または
|
|
168
|
-
|
|
169
|
-
呼び出し元(commander action / MCP ツール)に残るのは「どう見せるか」だけにする。
|
|
155
|
+
export(または `printHash` のハッシュ算出)を実行し、ツールの結果に載せる data を組み立てる。
|
|
170
156
|
*/
|
|
171
157
|
export async function executeDrawioExport(inputFile, options,
|
|
172
158
|
// DI 経由の write は mutate メソッド。
|
|
@@ -186,7 +172,6 @@ dependencies) {
|
|
|
186
172
|
outputFile: undefined,
|
|
187
173
|
pdfFile: undefined,
|
|
188
174
|
warningCount: 0,
|
|
189
|
-
exitCode: 0,
|
|
190
175
|
};
|
|
191
176
|
}
|
|
192
177
|
return {
|
|
@@ -195,7 +180,7 @@ dependencies) {
|
|
|
195
180
|
file: summary.outputFile,
|
|
196
181
|
sourceSha256: summary.sourceSha256,
|
|
197
182
|
icons: summary.iconCount,
|
|
198
|
-
// eslint-disable-next-line unicorn/no-null -- PDF を出していないときに `pdf: null`
|
|
183
|
+
// eslint-disable-next-line unicorn/no-null -- PDF を出していないときに `pdf: null` を返すことが結果の契約
|
|
199
184
|
pdf: summary.pdfFile ?? null,
|
|
200
185
|
pdfFailed: summary.pdfFailed,
|
|
201
186
|
warnings: summary.warningCount,
|
|
@@ -205,7 +190,6 @@ dependencies) {
|
|
|
205
190
|
outputFile: summary.outputFile,
|
|
206
191
|
pdfFile: summary.pdfFile,
|
|
207
192
|
warningCount: summary.warningCount,
|
|
208
|
-
exitCode: summary.warningCount > 0 ? WARNING_EXIT_CODE : 0,
|
|
209
193
|
};
|
|
210
194
|
}
|
|
211
195
|
/* c8 ignore start -- 非 Error 例外 (string throw 等) は本実装範囲では未発生、防御網のみ */
|
|
@@ -222,110 +206,6 @@ export function errorToReason(error) {
|
|
|
222
206
|
return 'unknown';
|
|
223
207
|
}
|
|
224
208
|
/* c8 ignore stop */
|
|
225
|
-
/**
|
|
226
|
-
例外を exit code 規約へ写す(2 = UsageError、1 = それ以外)。
|
|
227
|
-
|
|
228
|
-
CLI の action と MCP ツールが同じ対応表を使うための共有点。
|
|
229
|
-
*/
|
|
230
|
-
export function toExitCode(error) {
|
|
231
|
-
return error instanceof DrawioExportUsageError ? 2 : 1;
|
|
232
|
-
}
|
|
233
|
-
function doesArgvWantJson(argv) {
|
|
234
|
-
return argv.includes('--json');
|
|
235
|
-
}
|
|
236
|
-
// --icons は requiredOption のため未指定は commander が弾く。空文字だけがここに到達する。
|
|
237
|
-
function parseIcons(raw) {
|
|
238
|
-
const value = String(raw);
|
|
239
|
-
if (value === '') {
|
|
240
|
-
throw new DrawioExportUsageError('option --icons requires the root directory that resolves icon:// (fix: pass --icons <dir>)', 'missing-icons-root');
|
|
241
|
-
}
|
|
242
|
-
return value;
|
|
243
|
-
}
|
|
244
|
-
export function createDrawioExportCommand(buildDependencies) {
|
|
245
|
-
const command = new Command('export')
|
|
246
|
-
.description('export drawio XML to a static SVG and a sibling PDF')
|
|
247
|
-
.argument('<input>', 'input .drawio file path')
|
|
248
|
-
// CLI 側は required に据え置く(既定を持つのは MCP の drawio_export だけ)。
|
|
249
|
-
// 呼び出し側が talk-dir 相対の public/assets/icons など、解決の root を明示して渡す。
|
|
250
|
-
// プラグイン同梱カタログを既定にすると、誤った root で通知なしに解決されうる。
|
|
251
|
-
.requiredOption('--icons <dir>', 'root directory that resolves icon://')
|
|
252
|
-
.option('-o, --output <path>', `output SVG path (default: <input>${OUTPUT_SUFFIX})`)
|
|
253
|
-
.option('--no-pdf', 'do not write the sibling PDF (extension replaced with .pdf)')
|
|
254
|
-
.option('--print-hash', 'print only the composite hash for staleness checks to stdout, without exporting', false)
|
|
255
|
-
.option('--json', 'print machine-readable JSON to stdout', false)
|
|
256
|
-
.exitOverride()
|
|
257
|
-
.configureOutput({
|
|
258
|
-
writeErr: (string_) => {
|
|
259
|
-
const dependencies = buildDependencies();
|
|
260
|
-
if (doesArgvWantJson(process.argv)) {
|
|
261
|
-
writeData(dependencies.stdout, JSON.stringify({
|
|
262
|
-
event: 'drawio.export.error',
|
|
263
|
-
reason: 'invalid-option',
|
|
264
|
-
detail: string_.replace(/^error:[ \t]*/i, '').trim(),
|
|
265
|
-
}));
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
passthrough(dependencies.stderr, string_);
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
|
-
writeOut: (string_) => { writeData(buildDependencies().stdout, string_); },
|
|
272
|
-
})
|
|
273
|
-
.action(async (input, raw) => {
|
|
274
|
-
const dependencies = buildDependencies();
|
|
275
|
-
const isJson = raw['json'] === true;
|
|
276
|
-
let options;
|
|
277
|
-
try {
|
|
278
|
-
options = {
|
|
279
|
-
icons: parseIcons(raw['icons']),
|
|
280
|
-
output: typeof raw['output'] === 'string' ? raw['output'] : undefined,
|
|
281
|
-
printHash: raw['printHash'] === true,
|
|
282
|
-
pdf: raw['pdf'] !== false,
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
catch (error) {
|
|
286
|
-
writeFailure(dependencies, isJson, errorToReason(error), formatError(error));
|
|
287
|
-
process.exitCode = 2;
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
try {
|
|
291
|
-
const execution = await executeDrawioExport(input, options, dependencies);
|
|
292
|
-
if (isJson) {
|
|
293
|
-
writeData(dependencies.stdout, JSON.stringify(execution.data));
|
|
294
|
-
}
|
|
295
|
-
else if (execution.outputFile === undefined) {
|
|
296
|
-
// 呼び出し側(公開フック)が値をそのまま変数に取れるよう、素の出力は
|
|
297
|
-
// ハッシュ 1 行だけにする。
|
|
298
|
-
writeData(dependencies.stdout, execution.sourceSha256);
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
const diagnostics = createDiagnostics(dependencies.stderr);
|
|
302
|
-
diagnostics.done({ verb: 'create', target: execution.outputFile });
|
|
303
|
-
if (execution.pdfFile !== undefined) {
|
|
304
|
-
diagnostics.done({ verb: 'create', target: execution.pdfFile });
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
if (execution.exitCode !== 0) {
|
|
308
|
-
process.exitCode = execution.exitCode;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
catch (error) {
|
|
312
|
-
writeFailure(dependencies, isJson, errorToReason(error), formatError(error));
|
|
313
|
-
process.exitCode = toExitCode(error);
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
return command;
|
|
317
|
-
}
|
|
318
|
-
function writeFailure(
|
|
319
|
-
// DI 経由の write は mutate メソッド。
|
|
320
|
-
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
321
|
-
dependencies, isJson, reason, detail) {
|
|
322
|
-
if (isJson) {
|
|
323
|
-
writeData(dependencies.stdout, JSON.stringify({ event: 'drawio.export.error', reason, detail }));
|
|
324
|
-
}
|
|
325
|
-
else {
|
|
326
|
-
createDiagnostics(dependencies.stderr).error(detail);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
209
|
export function drawioExportDefaultDependencies() {
|
|
330
210
|
return {
|
|
331
211
|
stdout: process.stdout,
|
|
@@ -24,13 +24,13 @@ export interface DrawioThemeDependencies {
|
|
|
24
24
|
readonly fetchTheme?: typeof fetchTheme;
|
|
25
25
|
readonly themeStoreRoot?: () => string | undefined;
|
|
26
26
|
/**
|
|
27
|
-
|
|
27
|
+
`theme` の相対パスを絶対化する基準。省略時はカレント。
|
|
28
28
|
*/
|
|
29
29
|
readonly currentDirectory?: string;
|
|
30
30
|
readonly signal?: AbortSignal;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
|
|
33
|
+
MCP の data に載せる `theme`。
|
|
34
34
|
*/
|
|
35
35
|
export declare function themeData(theme: Readonly<DrawioTheme>): Readonly<Record<string, unknown>>;
|
|
36
36
|
/**
|
|
@@ -39,7 +39,7 @@ PNG 撮影のページが読み込む書体名。本文の書体に和文の書
|
|
|
39
39
|
export declare function themeFontNames(theme: Readonly<DrawioTheme>): readonly string[];
|
|
40
40
|
/**
|
|
41
41
|
図の確認に使うテーマを決める。
|
|
42
|
-
|
|
42
|
+
`theme` の指定・図の祖先の talk-dir・既定値の順。解けないテーマは例外で止める(古い値で確かめ続けない)。
|
|
43
43
|
info は取得や宣言の警告と、移行前の案内の出力先。
|
|
44
44
|
*/
|
|
45
45
|
export declare function resolveDrawioTheme(diagramPath: string, themeOption: string | undefined, dependencies: Readonly<DrawioThemeDependencies>, info: (message: string) => void): Promise<DrawioTheme>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
//
|
|
1
|
+
// drawio_create が書体と文字サイズを確かめるときの、テーマの宣言の決め方。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
// -
|
|
5
|
-
// -
|
|
6
|
-
// -
|
|
3
|
+
// 優先順は、`theme` の指定、図の祖先の talk-dir、本体の既定値。
|
|
4
|
+
// - `theme: git+...#tag`: 置き場から取得する(fetchTheme)。
|
|
5
|
+
// - `theme: file:<path>`: pecot-theme.json を直接読む。install は要らない。
|
|
6
|
+
// - `theme: <path>`: talk-dir かテーマ root。slides.md か pecot-theme.json が無ければ invalid-theme。
|
|
7
7
|
// - talk-dir: 祖先 D が slides.md を持ち、図が D/public/ の下にあるときだけ。
|
|
8
|
-
// 書体は常に確かめる。5 段のサイズは、talk-dir の中か
|
|
8
|
+
// 書体は常に確かめる。5 段のサイズは、talk-dir の中か `theme` 指定のときだけ確かめる。
|
|
9
9
|
// 移行前の talk-dir(theme-none)は既定値で続ける。解けないテーマ(theme-unlinked・取得や宣言の失敗)は止める。
|
|
10
|
-
// 宣言の欠落や schema の違いの警告は、図の作者には直せない。note
|
|
10
|
+
// 宣言の欠落や schema の違いの警告は、図の作者には直せない。note で出し、警告の件数に数えない。
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import { isRecord } from '../../domain/_shared/json.js';
|
|
13
13
|
import { THEME_DECLARATION_FILE_NAME, readThemeDeclaration } from '../../domain/slidev-theme/declaration.js';
|
|
@@ -29,7 +29,7 @@ const FALLBACK_THEME = {
|
|
|
29
29
|
fontSizes: undefined,
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
|
-
|
|
32
|
+
MCP の data に載せる `theme`。
|
|
33
33
|
*/
|
|
34
34
|
export function themeData(theme) {
|
|
35
35
|
return {
|
|
@@ -88,7 +88,7 @@ async function hasTheme(files, directory, names) {
|
|
|
88
88
|
return false;
|
|
89
89
|
}
|
|
90
90
|
function invalidTheme(option, detail) {
|
|
91
|
-
return new DrawioUrlUsageError(`invalid
|
|
91
|
+
return new DrawioUrlUsageError(`invalid theme (${detail}): ${option}`, 'invalid-theme');
|
|
92
92
|
}
|
|
93
93
|
async function themeFromOption(option,
|
|
94
94
|
// DI の port(関数と AbortSignal)を持つため readonly 化できない。
|
|
@@ -134,7 +134,7 @@ dependencies, files, currentDirectory, info) {
|
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
136
|
図の確認に使うテーマを決める。
|
|
137
|
-
|
|
137
|
+
`theme` の指定・図の祖先の talk-dir・既定値の順。解けないテーマは例外で止める(古い値で確かめ続けない)。
|
|
138
138
|
info は取得や宣言の警告と、移行前の案内の出力先。
|
|
139
139
|
*/
|
|
140
140
|
export async function resolveDrawioTheme(diagramPath, themeOption,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { FailureReason } from '../../domain/_shared/failure-kind.js';
|
|
2
|
-
import { Command } from 'commander';
|
|
3
2
|
import type { LintText } from '../../domain/_shared/text-check.js';
|
|
4
3
|
import type { ThemeFiles } from '../../domain/slidev-theme/ports.js';
|
|
5
4
|
import type { fetchTheme } from '../../infra/slidev-theme/store.js';
|
|
@@ -14,13 +13,9 @@ export interface DrawioUrlOptions {
|
|
|
14
13
|
*/
|
|
15
14
|
readonly theme?: string | undefined;
|
|
16
15
|
/**
|
|
17
|
-
|
|
16
|
+
`output` の指定値。省略時は URL をファイルに書き出さない。
|
|
18
17
|
*/
|
|
19
18
|
readonly output?: string | undefined;
|
|
20
|
-
/**
|
|
21
|
-
`--json` を選んだか。出力表現の分岐にしか使わず、実行内容には影響しない。
|
|
22
|
-
*/
|
|
23
|
-
readonly json?: boolean;
|
|
24
19
|
}
|
|
25
20
|
export interface DrawioUrlDependencies {
|
|
26
21
|
readonly pluginRoot: string;
|
|
@@ -51,7 +46,7 @@ export interface DrawioUrlDependencies {
|
|
|
51
46
|
*/
|
|
52
47
|
readonly themeStoreRoot?: () => string | undefined;
|
|
53
48
|
/**
|
|
54
|
-
|
|
49
|
+
テーマの相対パスを絶対化する基準。省略時はカレント。
|
|
55
50
|
*/
|
|
56
51
|
readonly currentDirectory?: string;
|
|
57
52
|
/**
|
|
@@ -71,12 +66,12 @@ interface DrawioUrlResultSummary {
|
|
|
71
66
|
}
|
|
72
67
|
export declare function runDrawioUrl(inputFile: string, options: Readonly<DrawioUrlOptions>, dependencies: DrawioUrlDependencies): Promise<DrawioUrlResultSummary>;
|
|
73
68
|
/**
|
|
74
|
-
executeDrawioUrl
|
|
75
|
-
|
|
69
|
+
executeDrawioUrl の結果。ツールの ToolResult 組み立ては
|
|
70
|
+
これだけを見る。
|
|
76
71
|
*/
|
|
77
72
|
export interface DrawioUrlExecution {
|
|
78
73
|
/**
|
|
79
|
-
|
|
74
|
+
ツールの structuredContent に載せる値。
|
|
80
75
|
*/
|
|
81
76
|
readonly data: Readonly<Record<string, unknown>>;
|
|
82
77
|
/**
|
|
@@ -88,22 +83,17 @@ export interface DrawioUrlExecution {
|
|
|
88
83
|
*/
|
|
89
84
|
readonly warningCount: number;
|
|
90
85
|
/**
|
|
91
|
-
|
|
92
|
-
*/
|
|
93
|
-
readonly exitCode: number;
|
|
94
|
-
/**
|
|
95
|
-
生成した URL。`--json` 無しで `-o` 無しのときに、stdout へ出す。
|
|
86
|
+
生成した URL。
|
|
96
87
|
*/
|
|
97
88
|
readonly url: string;
|
|
98
89
|
/**
|
|
99
|
-
|
|
90
|
+
`output` を解決した絶対パス。未指定なら undefined。
|
|
100
91
|
*/
|
|
101
92
|
readonly outputFile: string | undefined;
|
|
102
93
|
}
|
|
103
94
|
/**
|
|
104
|
-
URL 生成から出力ファイル・PNG
|
|
95
|
+
URL 生成から出力ファイル・PNG の書き出しまでを実行し、ツールの結果に載せる data を組み立てる。
|
|
105
96
|
|
|
106
|
-
呼び出し元(commander action / MCP ツール)に残るのは「どう見せるか」だけで、
|
|
107
97
|
出力先の解決・PNG の兄弟ファイル命名・警告件数の集計はすべてここに閉じる。
|
|
108
98
|
*/
|
|
109
99
|
export declare function executeDrawioUrl(inputFile: string, options: Readonly<DrawioUrlOptions>, dependencies: DrawioUrlDependencies): Promise<DrawioUrlExecution>;
|
|
@@ -112,15 +102,8 @@ export declare function executeDrawioUrl(inputFile: string, options: Readonly<Dr
|
|
|
112
102
|
*/
|
|
113
103
|
export declare function errorToReason(error: unknown): FailureReason;
|
|
114
104
|
/**
|
|
115
|
-
|
|
105
|
+
失敗時にツールの data に載せる内容。
|
|
116
106
|
*/
|
|
117
107
|
export declare function errorData(error: unknown): Readonly<Record<string, unknown>>;
|
|
118
|
-
/**
|
|
119
|
-
例外を exit code 規約へ写す(2 = UsageError とテーマの指定の誤り、1 = それ以外)。
|
|
120
|
-
|
|
121
|
-
CLI の action と MCP ツールが同じ対応表を使うための共有点。
|
|
122
|
-
*/
|
|
123
|
-
export declare function toExitCode(error: unknown): number;
|
|
124
|
-
export declare function createDrawioUrlCommand(buildDependencies: () => DrawioUrlDependencies): Command;
|
|
125
108
|
export declare function drawioUrlDefaultDependencies(): DrawioUrlDependencies;
|
|
126
109
|
//# sourceMappingURL=url.d.ts.map
|