@pecot/visual-mcp 3.1.1-dev.141 → 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.
Files changed (101) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/cli/dist/commands/drawio/export.d.ts +9 -24
  3. package/cli/dist/commands/drawio/export.js +15 -135
  4. package/cli/dist/commands/drawio/theme.d.ts +3 -3
  5. package/cli/dist/commands/drawio/theme.js +10 -10
  6. package/cli/dist/commands/drawio/url.d.ts +9 -26
  7. package/cli/dist/commands/drawio/url.js +18 -131
  8. package/cli/dist/commands/evidence-xlsx/create.d.ts +4 -12
  9. package/cli/dist/commands/evidence-xlsx/create.js +9 -92
  10. package/cli/dist/commands/slidev-project/create.d.ts +5 -30
  11. package/cli/dist/commands/slidev-project/create.js +12 -136
  12. package/cli/dist/commands/slidev-project/linked-theme.d.ts +1 -1
  13. package/cli/dist/commands/slidev-project/linked-theme.js +2 -2
  14. package/cli/dist/commands/slidev-project/lint.d.ts +8 -37
  15. package/cli/dist/commands/slidev-project/lint.js +16 -161
  16. package/cli/dist/commands/slidev-project/sync.d.ts +7 -26
  17. package/cli/dist/commands/slidev-project/sync.js +15 -156
  18. package/cli/dist/commands/slidev-project/theme.d.ts +2 -13
  19. package/cli/dist/commands/slidev-project/theme.js +3 -93
  20. package/cli/dist/commands/slidev-to-pptx/convert.d.ts +10 -17
  21. package/cli/dist/commands/slidev-to-pptx/convert.js +25 -266
  22. package/cli/dist/diagnostics.d.ts +0 -4
  23. package/cli/dist/diagnostics.js +0 -6
  24. package/cli/dist/domain/_shared/failure-kind.d.ts +2 -2
  25. package/cli/dist/domain/_shared/failure-kind.js +2 -2
  26. package/cli/dist/domain/_shared/ports.d.ts +3 -4
  27. package/cli/dist/domain/evidence-xlsx/image-dimensions.d.ts +1 -1
  28. package/cli/dist/domain/pptx-ooxml/preview-normalize.d.ts +0 -12
  29. package/cli/dist/domain/pptx-ooxml/preview-normalize.js +1 -25
  30. package/cli/dist/domain/slidev-project/errors.js +2 -2
  31. package/cli/dist/domain/slidev-project/generated-files.js +3 -3
  32. package/cli/dist/domain/slidev-project/lint.d.ts +7 -7
  33. package/cli/dist/domain/slidev-project/lint.js +8 -8
  34. package/cli/dist/domain/slidev-project/package-json.d.ts +1 -1
  35. package/cli/dist/domain/slidev-project/package-json.js +2 -2
  36. package/cli/dist/domain/slidev-project/sync.d.ts +11 -11
  37. package/cli/dist/domain/slidev-project/sync.js +18 -19
  38. package/cli/dist/domain/slidev-theme/deck-lint-input.js +1 -1
  39. package/cli/dist/domain/slidev-theme/declaration.js +1 -1
  40. package/cli/dist/domain/slidev-theme/skeleton.js +1 -1
  41. package/cli/dist/domain/slidev-theme/talk-theme.d.ts +3 -3
  42. package/cli/dist/domain/slidev-theme/talk-theme.js +5 -7
  43. package/cli/dist/domain/slidev-to-pptx/config.d.ts +1 -1
  44. package/cli/dist/domain/slidev-to-pptx/config.js +1 -1
  45. package/cli/dist/domain/slidev-to-pptx/errors.d.ts +4 -4
  46. package/cli/dist/domain/slidev-to-pptx/errors.js +4 -4
  47. package/cli/dist/domain/slidev-to-pptx/types.d.ts +1 -1
  48. package/cli/dist/infra/_shared/dependency-root.d.ts +9 -67
  49. package/cli/dist/infra/_shared/dependency-root.js +15 -126
  50. package/cli/dist/infra/_shared/flock.js +1 -2
  51. package/cli/dist/infra/_shared/plugin-root.d.ts +3 -5
  52. package/cli/dist/infra/_shared/plugin-root.js +5 -12
  53. package/cli/dist/infra/evidence-xlsx/workbook-writer.d.ts +1 -1
  54. package/cli/dist/infra/playwright/chromium.d.ts +4 -15
  55. package/cli/dist/infra/playwright/chromium.js +6 -18
  56. package/cli/dist/infra/playwright/host-dependencies.d.ts +2 -2
  57. package/cli/dist/infra/playwright/host-dependencies.js +6 -6
  58. package/cli/dist/infra/pptx-ooxml/soffice.js +1 -1
  59. package/cli/dist/infra/slidev-project/eslint-runner.d.ts +1 -1
  60. package/cli/dist/infra/slidev-project/eslint-runner.js +2 -2
  61. package/cli/dist/infra/slidev-to-pptx/index.js +1 -1
  62. package/cli/dist/infra/slidev-to-pptx/pipeline.js +1 -1
  63. package/cli/dist/infra/slidev-to-pptx/prerender-capture.js +1 -1
  64. package/cli/dist/infra/slidev-to-pptx/server.js +2 -2
  65. package/cli/dist/main.d.ts +3 -0
  66. package/cli/dist/main.js +28 -0
  67. package/cli/dist/mcp/result.d.ts +5 -1
  68. package/cli/dist/mcp/result.js +9 -1
  69. package/cli/dist/mcp/serve.d.ts +2 -3
  70. package/cli/dist/mcp/serve.js +4 -5
  71. package/cli/dist/mcp/server.d.ts +5 -1
  72. package/cli/dist/mcp/server.js +10 -7
  73. package/cli/dist/mcp/tool-names.js +4 -1
  74. package/cli/dist/mcp/tools/_shared.d.ts +1 -1
  75. package/cli/dist/mcp/tools/_shared.js +2 -2
  76. package/cli/dist/mcp/tools/drawio.js +12 -15
  77. package/cli/dist/mcp/tools/evidence.js +2 -2
  78. package/cli/dist/mcp/tools/file.d.ts +31 -0
  79. package/cli/dist/mcp/tools/file.js +482 -0
  80. package/cli/dist/mcp/tools/index.d.ts +1 -1
  81. package/cli/dist/mcp/tools/index.js +6 -3
  82. package/cli/dist/mcp/tools/setup.js +3 -3
  83. package/cli/dist/mcp/tools/slide-dev.js +6 -7
  84. package/cli/dist/mcp/tools/slide-page.js +3 -3
  85. package/cli/dist/mcp/tools/slide-theme.d.ts +0 -1
  86. package/cli/dist/mcp/tools/slide-theme.js +2 -3
  87. package/cli/dist/mcp/tools/slide.d.ts +4 -4
  88. package/cli/dist/mcp/tools/slide.js +13 -14
  89. package/cli/dist/node-runtime.d.ts +2 -2
  90. package/cli/dist/node-runtime.js +4 -13
  91. package/cli/dist/version.d.ts +1 -8
  92. package/cli/dist/version.js +2 -11
  93. package/npm-shrinkwrap.json +7 -17
  94. package/package.json +2 -3
  95. package/bin/pecot-visual-mcp.mjs +0 -10
  96. package/cli/dist/cli.d.ts +0 -5
  97. package/cli/dist/cli.js +0 -109
  98. package/cli/dist/commands/chromium/host-dependencies.d.ts +0 -18
  99. package/cli/dist/commands/chromium/host-dependencies.js +0 -75
  100. package/cli/dist/commands/pptx-ooxml/preview.d.ts +0 -74
  101. package/cli/dist/commands/pptx-ooxml/preview.js +0 -399
@@ -1,13 +1,12 @@
1
- // Phase 2 の `pecotv slide convert` 実装。
1
+ // slide_convert ツールの実装。
2
2
  // Slidev プロジェクトディレクトリを `npx slidev build` でビルドする。
3
3
  // in-process pipeline で、単スライド PPTX 群 (slides/<prefix><N>.pptx) を取得する。
4
4
  // pipeline の実装は `infra/slidev-to-pptx/InProcessSlidevPptxPipeline`。
5
- // cli 側の純粋ロジック `domain/pptx-ooxml/merge.ts` で結合して --out に書き出す。
5
+ // cli 側の純粋ロジック `domain/pptx-ooxml/merge.ts` で結合して出力パスに書き出す。
6
6
  // SlidevRunner / SlidevPptxPipeline は port 経由で DI される (tech-advisor B1)。
7
7
  import { performance } from 'node:perf_hooks';
8
8
  import { access, readFile, mkdir, readdir, rm, stat } from 'node:fs/promises';
9
9
  import path from 'node:path';
10
- import { Command, Option } from 'commander';
11
10
  import { PipelineRuntimeError, PipelineTimeoutError, } from '../../domain/slidev-to-pptx/errors.js';
12
11
  import { ANIMATION_POLICY_SCHEMA_VERSION, DEFAULT_SLIDE_PREFIX, parseSlideFilename, } from '../../domain/slidev-to-pptx/config.js';
13
12
  import { mergePptxFiles } from '../../domain/pptx-ooxml/merge.js';
@@ -15,14 +14,13 @@ import { applyHyperlinkFix, applyJapaneseFontFix, applyTransition, removeAnimati
15
14
  import { applyPrerenderImageReplace, findPrerenderImages, } from '../../domain/pptx-ooxml/prerender-replace.js';
16
15
  import { readThemeDeclaration } from '../../domain/slidev-theme/declaration.js';
17
16
  import { sanitizeFilename } from '../../domain/slidev-to-pptx/slides-title.js';
18
- import { createDiagnostics, passthrough, writeData } from '../../diagnostics.js';
17
+ import { createDiagnostics } from '../../diagnostics.js';
19
18
  import { readSlidesTitleFromFile } from '../../infra/slidev-to-pptx/slides-title-reader.js';
20
19
  import { ChildProcessSlidevRunner } from '../../infra/slidev-to-pptx/runner.js';
21
20
  import { InProcessSlidevPptxPipeline } from '../../infra/slidev-to-pptx/index.js';
22
21
  import { XmldomXmlEngine } from '../../infra/pptx-ooxml/xml-engine.js';
23
22
  import { YauzlYazlPptxArchive } from '../../infra/pptx-ooxml/archive.js';
24
23
  import { pluginDependencyRoot } from '../../infra/_shared/dependency-root.js';
25
- import { resolvePluginRoot } from '../../infra/_shared/plugin-root.js';
26
24
  import { NodeThemeFiles } from '../../infra/slidev-theme/fs.js';
27
25
  import { readVersion } from '../../version.js';
28
26
  import { ensureTalkThemeLinked, linkedThemeDefaultDependencies } from '../slidev-project/linked-theme.js';
@@ -30,8 +28,6 @@ import { themeErrorReason } from '../../domain/slidev-theme/error-reason.js';
30
28
  import { SlideCreateRuntimeError } from '../../domain/slidev-project/errors.js';
31
29
  import { EAST_ASIAN_FONT_OMITTED_WARNING, LINK_COLOR_OMITTED_WARNING } from '../../domain/slidev-project/warnings.js';
32
30
  import { NS_PACKAGE_RELATIONSHIPS } from '../../domain/_shared/ooxml-uris.js';
33
- const TRANSITION_TYPES = ['fade', 'morph'];
34
- const MORPH_OPTIONS = ['byObject', 'byWord', 'byChar'];
35
31
  /**
36
32
  変換工程の進捗文言。割合は切り捨て (完了前に 100% と出さない)。
37
33
  */
@@ -77,7 +73,7 @@ const PPTX_CONVERT_IDLE_TIMEOUT_MS = 600_000;
77
73
  const THEME_PATTERN = /^[\w@/.-]+$/;
78
74
  export function validateTheme(theme) {
79
75
  if (!THEME_PATTERN.test(theme)) {
80
- throw new SlideConvertUsageError(`--theme accepts only [a-zA-Z0-9@/_.-]: ${theme}`, 'invalid-theme');
76
+ throw new SlideConvertUsageError(`theme accepts only [a-zA-Z0-9@/_.-]: ${theme}`, 'invalid-theme');
81
77
  }
82
78
  }
83
79
  /**
@@ -176,25 +172,21 @@ dependencies) {
176
172
  await ensureProjectDirectory(projectAbs);
177
173
  // テーマを今の値で張ってから、宣言の PPTX の値を取る。以降の build はこの node_modules で動く。
178
174
  const fontPolicy = await resolveFontPolicy(projectAbs, dependencies);
179
- // 出力 PPTX 配置先 (--out) のディレクトリは存在保証する。in-process pipeline は
175
+ // 出力 PPTX 配置先のディレクトリは存在保証する。in-process pipeline は
180
176
  // outputDir 配下の slides/<prefix><N>.pptx 群を生成するため、cli 側で merge して outputAbs に書き出す。
181
177
  await mkdir(path.dirname(outputAbs), { recursive: true });
182
178
  const start = dependencies.now();
183
179
  await cleanBuildArtifacts(projectAbs);
184
180
  const cleanBuildMs = dependencies.now() - start;
185
- // capture/relay 切替: slidev build 子プロセスの stdout/stderr は --json 時に破棄する
186
- // (tech-advisor B2)。--json でないときは、どちらも stderr へ中継する (stdout はデータだけ)。
181
+ // slidev build 子プロセスの stdout/stderr は、どちらも stderr へ中継する (stdout はデータだけ)。
187
182
  // in-process pipeline の人間可読ログは、常に stderr の診断行 (note / warning / error) で出る。
188
- const isRelayEnabled = options.json !== true;
189
183
  const buildOptions = { timeoutMs: SLIDEV_BUILD_TIMEOUT_MS };
190
184
  if (options.theme !== undefined)
191
185
  buildOptions.theme = options.theme;
192
186
  if (dependencies.signal !== undefined)
193
187
  buildOptions.signal = dependencies.signal;
194
- if (isRelayEnabled) {
195
- buildOptions.stdout = dependencies.stderr;
196
- buildOptions.stderr = dependencies.stderr;
197
- }
188
+ buildOptions.stdout = dependencies.stderr;
189
+ buildOptions.stderr = dependencies.stderr;
198
190
  const buildStart = dependencies.now();
199
191
  dependencies.onProgress?.('running slidev build');
200
192
  const buildResult = await dependencies.slidevRunner.build(projectAbs, buildOptions);
@@ -209,7 +201,7 @@ dependencies) {
209
201
  // in-process pipeline は skipPostprocess 指定時、staging/slides/<prefix><N>.pptx のみを出力する。
210
202
  // Phase 2+3 は skip する。
211
203
  // 本コマンドは TS 側で merge を行う。
212
- // そのため staging ディレクトリを作って単スライド PPTX を受け取り、--out に書き出す。
204
+ // そのため staging ディレクトリを作って単スライド PPTX を受け取り、出力パスに書き出す。
213
205
  const stagingDirectory = path.join(projectAbs, 'pptx');
214
206
  await mkdir(stagingDirectory, { recursive: true });
215
207
  const convertOptions = {
@@ -220,10 +212,10 @@ dependencies) {
220
212
  skipPostprocess: true,
221
213
  // 差分キャッシュは標準で有効。読み書き先は staging 配下の pptx/cache/。
222
214
  cachePluginVersion: dependencies.pluginVersion(),
223
- // --no-cache は読み取りだけを止める。保存は動くので次回以降は再びヒットする。
215
+ // cache: false は読み取りだけを止める。保存は動くので次回以降は再びヒットする。
224
216
  cacheSkipRead: options.cache === false,
225
217
  };
226
- // --theme は envHash の材料にもなる (F-01)。テーマ切替後に旧描画のキャッシュが
218
+ // theme は envHash の材料にもなる (F-01)。テーマ切替後に旧描画のキャッシュが
227
219
  // 通知なしにヒットしないよう、slidev build に渡した値をそのまま pptxConverter にも渡す。
228
220
  if (options.theme !== undefined)
229
221
  convertOptions.theme = options.theme;
@@ -231,7 +223,7 @@ dependencies) {
231
223
  convertOptions.logLevel = options.logLevel;
232
224
  if (dependencies.signal !== undefined)
233
225
  convertOptions.signal = dependencies.signal;
234
- // --no-single-pass は現行ルートを強制する。未指定はキーを置かず、pipeline 側が env に従う。
226
+ // singlePass: false は現行ルートを強制する。未指定はキーを置かず、pipeline 側が env に従う。
235
227
  if (options.singlePass === false)
236
228
  convertOptions.singlePass = false;
237
229
  convertOptions.stderr = dependencies.stderr;
@@ -275,7 +267,7 @@ dependencies) {
275
267
  throw new SlideConvertRuntimeError(`pptx convert failed: ${formatPipelineErrors(pipelineResult.errors)}`, 'pptx-convert-failed');
276
268
  }
277
269
  // staging/slides/<prefix><N>.pptx 群を読み込み、TS 側 merge ロジックで結合する。
278
- // staging から letter-spacing.json / href-map.json を auto-detect (priority: flag > staging > empty)。
270
+ // staging から letter-spacing.json / href-map.json を auto-detect (priority: 引数 > staging > empty)。
279
271
  const slidesDirectory = path.join(stagingDirectory, 'slides');
280
272
  const spacingMap = await resolveLetterSpacingMap(options.spacingJson, path.join(slidesDirectory, 'letter-spacing.json'));
281
273
  const hrefMap = await resolveHrefMap(options.hrefJson, path.join(slidesDirectory, 'href-map.json'));
@@ -313,7 +305,7 @@ dependencies) {
313
305
  return summary;
314
306
  }
315
307
  catch (error) {
316
- // merge / 出力書き出しは生の Error(例: --out がディレクトリのときの EISDIR)を投げる。
308
+ // merge / 出力書き出しは生の Error(例: 出力パスがディレクトリのときの EISDIR)を投げる。
317
309
  // wrap しないと reason が unknown になり、利用者が原因を特定できない。
318
310
  const converted = error instanceof SlideConvertRuntimeError
319
311
  ? error
@@ -337,13 +329,13 @@ error, diagnostics) {
337
329
  return error;
338
330
  }
339
331
  /**
340
- `--json` の error payload に載せる警告。pipeline 未到達の失敗では空配列。
332
+ 失敗時の data に載せる警告。pipeline 未到達の失敗では空配列。
341
333
  */
342
334
  function warningsOf(error) {
343
335
  return (error instanceof SlideConvertRuntimeError) ? error.warnings ?? [] : [];
344
336
  }
345
337
  /**
346
- `--json` の error payload に載せる変換エラー。pipeline 未到達の失敗では空配列。
338
+ 失敗時の data に載せる変換エラー。pipeline 未到達の失敗では空配列。
347
339
  */
348
340
  function pipelineErrorsOf(error) {
349
341
  return (error instanceof SlideConvertRuntimeError) ? error.pipelineErrors ?? [] : [];
@@ -379,7 +371,7 @@ async function readSidecarObject(sourcePath, label) {
379
371
  return raw;
380
372
  }
381
373
  /**
382
- staging または CLI flag から letter-spacing.json を読み込んで Map 化する。
374
+ staging または引数から letter-spacing.json を読み込んで Map 化する。
383
375
  priority: `flag > staging > empty`。
384
376
  */
385
377
  async function resolveLetterSpacingMap(flagPath, stagingPath) {
@@ -404,7 +396,7 @@ async function resolveLetterSpacingMap(flagPath, stagingPath) {
404
396
  return map;
405
397
  }
406
398
  /**
407
- staging または CLI flag から href-map.json を読み込んで Map 化する。
399
+ staging または引数から href-map.json を読み込んで Map 化する。
408
400
  priority: `flag > staging > empty`。
409
401
  */
410
402
  async function resolveHrefMap(flagPath, stagingPath) {
@@ -423,7 +415,7 @@ async function resolveHrefMap(flagPath, stagingPath) {
423
415
  }
424
416
  /**
425
417
  staging から animation-policy.json を読み込み、`p:timing` を残す stepIndex の集合を
426
- 返す(#1070)。CLI flag は持たない。
418
+ 返す(#1070)。引数では受けない。
427
419
 
428
420
  不在時は空集合で進む(= 全スライドの `p:timing` を除去する)。sidecar が「残す側」を
429
421
  列挙する形なのは、この既定を「全除去」に倒すため。「全保持」を既定にすると、読めなかった
@@ -481,7 +473,7 @@ chain は timing 除去 → sanitize → font fix → hyperlink fix → transiti
481
473
 
482
474
  `chainOptions.spacingMap` / `hrefMap` / `keepTimingSteps` は呼び出し側で解決済みの値を
483
475
  渡すこと。
484
- spacingMap / hrefMap は staging auto-detect と CLI flag から得る (priority: flag > staging > empty)。
476
+ spacingMap / hrefMap は staging auto-detect と引数から得る (priority: 引数 > staging > empty)。
485
477
  keepTimingSteps は staging の animation-policy.json から得る (不在なら空集合 = 全スライドの timing を除去)。
486
478
  */
487
479
  async function mergeSingleSlidePptxesTo(stagingDirectory, outputAbs, chainOptions,
@@ -665,19 +657,13 @@ export function errorToReason(error) {
665
657
  if (error instanceof SlideCreateRuntimeError)
666
658
  return error.reason;
667
659
  // pipeline 到達後の生 Error(merge / 出力書き出し)は merge-failed へ wrap 済み。
668
- // 到達前の生 Error(--out 親の mkdir、cleanBuildArtifacts の rm、slidevRunner.build の spawn 失敗)は wrap されない。
660
+ // 到達前の生 Error(出力パスの親の mkdir、cleanBuildArtifacts の rm、slidevRunner.build の spawn 失敗)は wrap されない。
669
661
  // それらはここへ届き、従来どおり unknown になる。
670
662
  // テーマの取得・宣言・指定・未参照の失敗は、theme-<reason> にする。
671
663
  return themeErrorReason(error) ?? 'unknown';
672
664
  }
673
665
  /**
674
- 失敗時の exit code。usage error = 2、それ以外の実行失敗 = 1。
675
- */
676
- export function toExitCode(error) {
677
- return error instanceof SlideConvertUsageError ? 2 : 1;
678
- }
679
- /**
680
- `--json` の error payload に載せる pipeline 診断。CLI と MCP ツールで同形にする。
666
+ 失敗時の data に載せる pipeline 診断。
681
667
  */
682
668
  export function convertErrorDiagnostics(error) {
683
669
  return { warnings: warningsOf(error), errors: pipelineErrorsOf(error) };
@@ -688,32 +674,7 @@ function formatError(error) {
688
674
  }
689
675
  /* c8 ignore stop */
690
676
  /**
691
- 人間向けのキャッシュ判定出力。どのステップを変換したかが SC-001 の確認手段になるため、
692
- サマリ 1 行に続けてステップ別の判定も出す。
693
-
694
- 全ステップを列挙すると多スライドデッキ(例: 51 ステップ)で 500 文字を超えて可読性を
695
- 損なうため、miss(= 今回実際に変換したステップ)のみを列挙し、hit は件数集約する。
696
- 全 hit なら miss 列挙自体を出さず件数のみ。
697
- */
698
- function formatCacheSummary(cache) {
699
- const summaryLine = `cache: ${String(cache.hits)} hits / ${String(cache.misses)} misses`
700
- + ` (enabled: ${String(cache.enabled)}, invalidated: ${cache.invalidated})\n`;
701
- if (cache.perStep.length === 0)
702
- return summaryLine;
703
- const missSteps = cache.perStep.filter(entry => entry.cache === 'miss');
704
- const hitCount = cache.perStep.length - missSteps.length;
705
- if (missSteps.length === 0) {
706
- return `${summaryLine}cache steps: ${String(hitCount)} hit\n`;
707
- }
708
- const missList = missSteps.map(entry => `#${entry.key}`).join(', ');
709
- const hitSuffix = hitCount === 0 ? '' : ` (${String(hitCount)} more hit)`;
710
- return `${summaryLine}cache steps: miss ${missList}${hitSuffix}\n`;
711
- }
712
- function doesArgvWantJson(argv) {
713
- return argv.includes('--json');
714
- }
715
- /**
716
- --out 省略時の既定出力パスを解決する。
677
+ 出力パス省略時の既定を解決する。
717
678
  `slides.md` の frontmatter title があれば、
718
679
  `<project-dir>/pptx/<sanitizeFilename(title)>.pptx` を返す。
719
680
  title 不在 (frontmatter 無し / キー無し / 空値 / 読取失敗) なら、
@@ -744,7 +705,7 @@ stderr) {
744
705
  });
745
706
  }
746
707
  /**
747
- `slide convert` の実処理と機械可読な結果組み立て。CLI action と MCP ツールの双方がここを通る。
708
+ slide_convert の実処理と機械可読な結果組み立て。MCP ツールがここを通る。
748
709
 
749
710
  `options.out` は解決済みの出力パスを渡す(省略時の既定は `resolveDefaultOut`)。
750
711
  `slide.convert.start` は進捗イベントで結果ではないため、ここでは扱わない。
@@ -808,208 +769,6 @@ function buildConvertDoneData(summary) {
808
769
  }
809
770
  return donePayload;
810
771
  }
811
- export function createSlideConvertCommand(buildDependencies) {
812
- const command = new Command('convert')
813
- .description('convert a Slidev project to PPTX')
814
- .argument('<project-dir>', 'Slidev project directory')
815
- .option('--out <path>', 'output .pptx path (default: <project-dir>/pptx/<slides.md title | basename>.pptx)')
816
- .option('--theme <name>', 'name passed to slidev --theme (allowed characters: [a-zA-Z0-9@/_.-])')
817
- .option('--spacing-json <path>', 'letter-spacing JSON path (default: auto-detect staging/slides/letter-spacing.json)')
818
- .option('--href-json <path>', 'hyperlink JSON path (default: auto-detect staging/slides/href-map.json)')
819
- .option('--transition-type <type>', 'transition type (fade|morph)')
820
- .option('--transition-duration-ms <ms>', 'transition duration (ms)')
821
- .option('--morph-option <option>', 'morph option (byObject|byWord|byChar)')
822
- .option('--no-cache', 'convert all slides without reading the cache (the cache is rebuilt on completion)')
823
- .option('--no-single-pass', 'convert with the per-step route that opens a page for each slide step, not the single-pass route')
824
- .addOption(new Option('--log-level <level>', 'progress detail (verbose and debug write progress to stderr)').choices(['normal', 'verbose', 'debug']))
825
- .option('--json', 'emit machine-readable progress on stdout', false)
826
- .exitOverride()
827
- .configureOutput({
828
- writeOut: (string_) => {
829
- writeData(buildDependencies().stdout, string_);
830
- },
831
- writeErr: (string_) => {
832
- const dependencies = buildDependencies();
833
- if (doesArgvWantJson(process.argv)) {
834
- writeData(dependencies.stdout, JSON.stringify({
835
- event: 'slide.convert.error',
836
- reason: 'invalid-option',
837
- detail: string_.replace(/^error:\s*/i, '').trim(),
838
- // done payload と同じく常時載せる。option 解析で落ちた run は pipeline 未到達のため空配列。
839
- warnings: [],
840
- errors: [],
841
- }));
842
- }
843
- else {
844
- passthrough(dependencies.stderr, string_);
845
- }
846
- },
847
- })
848
- .action(async (projectDirectory, raw) => {
849
- const dependencies = buildDependencies();
850
- const isWantsJson = raw['json'] === true;
851
- let options;
852
- try {
853
- const theme = optionalString(raw, 'theme');
854
- const spacingJson = optionalString(raw, 'spacingJson');
855
- const hrefJson = optionalString(raw, 'hrefJson');
856
- const transitionType = optionalTransitionType(raw, 'transitionType');
857
- const transitionDurationMs = optionalPositiveInt(raw, 'transitionDurationMs', 'invalid-transition-duration-ms');
858
- const morphOption = optionalMorphOption(raw, 'morphOption');
859
- const logLevel = optionalLogLevel(raw, 'logLevel');
860
- const optionalsPart = {};
861
- if (theme !== undefined)
862
- optionalsPart.theme = theme;
863
- if (spacingJson !== undefined)
864
- optionalsPart.spacingJson = spacingJson;
865
- if (hrefJson !== undefined)
866
- optionalsPart.hrefJson = hrefJson;
867
- if (transitionType !== undefined)
868
- optionalsPart.transitionType = transitionType;
869
- if (transitionDurationMs !== undefined)
870
- optionalsPart.transitionDurationMs = transitionDurationMs;
871
- if (morphOption !== undefined)
872
- optionalsPart.morphOption = morphOption;
873
- if (logLevel !== undefined)
874
- optionalsPart.logLevel = logLevel;
875
- const outOption = optionalString(raw, 'out');
876
- const resolvedProject = path.resolve(projectDirectory);
877
- const out = outOption ?? await resolveDefaultOut(resolvedProject, dependencies.stderr);
878
- options = {
879
- out,
880
- json: isWantsJson,
881
- // commander は `--no-cache` の受け皿として raw['cache'] に既定 true を入れる。
882
- cache: raw['cache'] !== false,
883
- // `--no-single-pass` も同じく raw['singlePass'] に既定 true が入る。
884
- singlePass: raw['singlePass'] !== false,
885
- ...optionalsPart,
886
- };
887
- }
888
- catch (error) {
889
- const reason = errorToReason(error);
890
- const detail = formatError(error);
891
- if (isWantsJson) {
892
- writeData(dependencies.stdout, JSON.stringify({
893
- event: 'slide.convert.error',
894
- reason,
895
- detail,
896
- warnings: [],
897
- errors: [],
898
- }));
899
- }
900
- else {
901
- createDiagnostics(dependencies.stderr).error(detail);
902
- }
903
- process.exitCode = toExitCode(error);
904
- return;
905
- }
906
- try {
907
- if (options.json === true) {
908
- // event 順序保証: start → done (失敗時は start → error)。tooling 側 stream parser
909
- // は start を進捗開始の signal として待つことができる。
910
- writeData(dependencies.stdout, JSON.stringify({
911
- event: 'slide.convert.start',
912
- input: path.resolve(projectDirectory),
913
- output: path.resolve(options.out),
914
- }));
915
- }
916
- const { summary, data } = await executeSlideConvert(projectDirectory, options, dependencies);
917
- if (options.json === true) {
918
- writeData(dependencies.stdout, JSON.stringify(data));
919
- }
920
- else {
921
- writeData(dependencies.stdout, `slide convert: ${summary.inputAbs} -> ${summary.outputAbs}`
922
- + ` (${String(Math.round(summary.durationMs))}ms)`);
923
- // 0 件のときは出さない(除去が起きなかった run で行数を増やさない)。
924
- if (summary.animationTimingRemovedSlides > 0) {
925
- writeData(dependencies.stdout, `animation: removed p:timing from ${String(summary.animationTimingRemovedSlides)} slides`
926
- + ` (slides with an explicit setting are kept)`);
927
- }
928
- if (summary.cache !== undefined) {
929
- writeData(dependencies.stdout, formatCacheSummary(summary.cache));
930
- }
931
- }
932
- }
933
- catch (error) {
934
- const reason = errorToReason(error);
935
- const detail = formatError(error);
936
- if (options.json === true) {
937
- writeData(dependencies.stdout, JSON.stringify({
938
- event: 'slide.convert.error',
939
- reason,
940
- detail,
941
- // 失敗した run でも pipeline が積んだ警告・変換エラーを観測できるようにする。
942
- // pipeline 未到達なら空配列(done payload と同じく「不在=旧版」と区別する)。
943
- // detail 側 (formatPipelineErrors) は先頭 3 件に丸めるが、機械可読側は全件載せる。
944
- ...convertErrorDiagnostics(error),
945
- }));
946
- }
947
- else {
948
- createDiagnostics(dependencies.stderr).error(detail);
949
- }
950
- process.exitCode = toExitCode(error);
951
- }
952
- });
953
- return command;
954
- }
955
- const LOG_LEVELS = ['normal', 'verbose', 'debug'];
956
- function optionalLogLevel(raw, key) {
957
- // eslint-disable-next-line security/detect-object-injection -- key は本ファイル内の固定文字列のみ
958
- const value = raw[key];
959
- return LOG_LEVELS.find(level => level === value);
960
- }
961
- function optionalString(raw, key) {
962
- // eslint-disable-next-line security/detect-object-injection -- key は本ファイル内の固定文字列のみ
963
- const value = raw[key];
964
- if (value === undefined)
965
- return undefined;
966
- /* c8 ignore next 3 -- commander が --opt <string> で先に validate するため到達不能 */
967
- if (typeof value !== 'string') {
968
- throw new SlideConvertUsageError(`option --${key} must be a string`, 'invalid-option');
969
- }
970
- return value;
971
- }
972
- function optionalTransitionType(raw, key) {
973
- const value = optionalString(raw, key);
974
- if (value === undefined)
975
- return undefined;
976
- if (!isTransitionType(value)) {
977
- throw new SlideConvertUsageError(`option --${kebab(key)} accepts only ${TRANSITION_TYPES.join('|')}: ${value}`, 'invalid-transition-type');
978
- }
979
- return value;
980
- }
981
- function optionalMorphOption(raw, key) {
982
- const value = optionalString(raw, key);
983
- if (value === undefined)
984
- return undefined;
985
- if (!isMorphOption(value)) {
986
- throw new SlideConvertUsageError(`option --${kebab(key)} accepts only ${MORPH_OPTIONS.join('|')}: ${value}`, 'invalid-morph-option');
987
- }
988
- return value;
989
- }
990
- function optionalPositiveInt(raw, key, reason) {
991
- const value = optionalString(raw, key);
992
- if (value === undefined)
993
- return undefined;
994
- const parsed = Math.trunc(Number(value));
995
- if (!Number.isFinite(parsed) || parsed <= 0 || String(parsed) !== value.trim()) {
996
- throw new SlideConvertUsageError(`option --${kebab(key)} must be a positive integer: ${value}`, reason);
997
- }
998
- return parsed;
999
- }
1000
- function isTransitionType(value) {
1001
- // readonly TransitionType[] は readonly string[] と互換だが、includes に渡すため string[] へ widening が必要。
1002
- // eslint-disable-next-line no-restricted-syntax
1003
- return TRANSITION_TYPES.includes(value);
1004
- }
1005
- function isMorphOption(value) {
1006
- // readonly MorphOption[] は readonly string[] と互換だが、includes に渡すため string[] へ widening が必要。
1007
- // eslint-disable-next-line no-restricted-syntax
1008
- return MORPH_OPTIONS.includes(value);
1009
- }
1010
- function kebab(camel) {
1011
- return camel.replaceAll(/[A-Z]/g, m => `-${m.toLowerCase()}`);
1012
- }
1013
772
  export function slideConvertDefaultDependencies() {
1014
773
  return {
1015
774
  slidevRunner: new ChildProcessSlidevRunner(),
@@ -1020,7 +779,7 @@ export function slideConvertDefaultDependencies() {
1020
779
  stderr: process.stderr,
1021
780
  now: () => performance.now(),
1022
781
  pluginVersion: readVersion,
1023
- ensureThemeLinked: (directory, context) => ensureTalkThemeLinked(directory, linkedThemeDefaultDependencies(pluginDependencyRoot() ?? resolvePluginRoot(), context), { requireTheme: true }),
782
+ ensureThemeLinked: (directory, context) => ensureTalkThemeLinked(directory, linkedThemeDefaultDependencies(pluginDependencyRoot(), context), { requireTheme: true }),
1024
783
  readThemeDeclaration: themeDirectory => readThemeDeclaration(new NodeThemeFiles(), themeDirectory),
1025
784
  };
1026
785
  }
@@ -31,8 +31,4 @@ export declare function createDiagnostics(stderr: DiagnosticStream): Diagnostics
31
31
  結果の本体を stdout にそのまま出す。末尾に改行が無ければ 1 つ足す
32
32
  */
33
33
  export declare function writeData(stdout: DiagnosticStream, text: string): void;
34
- /**
35
- commander が組み立てた使い方エラー・ヘルプの枠を、手を加えずに書く。commander が `error: ` を付ける
36
- */
37
- export declare function passthrough(stream: DiagnosticStream, text: string): void;
38
34
  //# sourceMappingURL=diagnostics.d.ts.map
@@ -37,10 +37,4 @@ export function createDiagnostics(stderr) {
37
37
  export function writeData(stdout, text) {
38
38
  stdout.write(text.endsWith('\n') ? text : `${text}\n`);
39
39
  }
40
- /**
41
- commander が組み立てた使い方エラー・ヘルプの枠を、手を加えずに書く。commander が `error: ` を付ける
42
- */
43
- export function passthrough(stream, text) {
44
- stream.write(text);
45
- }
46
40
  //# sourceMappingURL=diagnostics.js.map
@@ -2,12 +2,12 @@ export declare const FAILURE_KINDS: readonly ['broken-reference', 'cancelled', '
2
2
  export type FailureKind = typeof FAILURE_KINDS[number];
3
3
  export declare const CLI_ONLY_FAILURE_REASONS: readonly ['input-mutated', 'input-open-failed', 'invalid-mode', 'invalid-morph-option', 'invalid-transition-duration-ms', 'invalid-transition-type', 'missing-icons-root', 'missing-option', 'relative-dir', 'soffice-conversion-failed', 'soffice-not-found', 'soffice-timeout'];
4
4
  /**
5
- CLI の `--json` の `reason` に載る失敗の名前。MCP は failureKindOf で kind に写して返す。
5
+ 失敗の `reason` の名前。MCP は failureKindOf で kind に写して返す。
6
6
  */
7
7
  export type FailureReason = FailureKind | typeof CLI_ONLY_FAILURE_REASONS[number];
8
8
  export declare function isFailureKind(reason: string): reason is FailureKind;
9
9
  /**
10
- MCP の結果の `kind`。CLI だけの名前は MCP に届かないが、届いたときは `unknown` にする。
10
+ MCP の結果の `kind`。引数の解釈だけの名前は MCP に届かないが、届いたときは `unknown` にする。
11
11
  */
12
12
  export declare function failureKindOf(reason: FailureReason): FailureKind;
13
13
  //# sourceMappingURL=failure-kind.d.ts.map
@@ -74,7 +74,7 @@ export const FAILURE_KINDS = [
74
74
  'unknown-layout',
75
75
  'write-failed',
76
76
  ];
77
- // CLI の引数の解釈と、MCP ツールの無いコマンド(pptx preview)だけが `--json` の reason に出す名前。
77
+ // 引数の解釈だけが reason に出す名前。
78
78
  // MCP は引数を inputSchema と parsePathArguments で先に確かめるため、これらは返らない。
79
79
  // eslint-disable-next-line no-restricted-syntax -- 名前の一覧から型を作るため、要素をリテラルの型のまま残す
80
80
  export const CLI_ONLY_FAILURE_REASONS = [
@@ -95,7 +95,7 @@ export function isFailureKind(reason) {
95
95
  return FAILURE_KINDS.some(kind => kind === reason);
96
96
  }
97
97
  /**
98
- MCP の結果の `kind`。CLI だけの名前は MCP に届かないが、届いたときは `unknown` にする。
98
+ MCP の結果の `kind`。引数の解釈だけの名前は MCP に届かないが、届いたときは `unknown` にする。
99
99
  */
100
100
  export function failureKindOf(reason) {
101
101
  return isFailureKind(reason) ? reason : 'unknown';
@@ -75,9 +75,8 @@ export interface PptxWriter {
75
75
  finish(outputPath: string): Promise<void>;
76
76
  }
77
77
  /**
78
- PPTX を soffice (LibreOffice headless) 経由で PDF 化する port。
79
- `pecotv pptx preview` が、プレビュー正規化済みの一時 PPTX を PDF へレンダリングするときに
80
- 利用する。fake 差し替えで command テストを soffice 非依存にする(SlidevRunner と同流儀)。
78
+ OOXML ファイルを soffice (LibreOffice headless) 経由で PDF 化する port。
79
+ e2e が xlsx を PDF へレンダリングして見た目を確かめるときに使う。
81
80
 
82
81
  実装は soffice の出力 PDF を outputDirectory/<inputStem>.pdf に書き出す。soffice が変換失敗でも
83
82
  exit 0 を返す既知挙動があるため、成否判定(PDF 実在・非空)は呼び出し元の責務とする。
@@ -125,7 +124,7 @@ Slidev 出力ディレクトリ (`dist/`) から PPTX を生成する port。
125
124
 
126
125
  `skipPostprocess: true` を渡すと、Phase 2+3 (旧 Python pptx-postprocess 相当の merge) を skip する。
127
126
  その場合は単スライド PPTX (slides/<prefix><N>.pptx) のみが生成される。
128
- pecotv slide convert はこちらを利用し、merge は cli 側 `domain/pptx-ooxml/merge.ts` で実施する。
127
+ slide_convert はこちらを利用し、merge は cli 側 `domain/pptx-ooxml/merge.ts` で実施する。
129
128
  */
130
129
  export interface SlidevPptxPipeline {
131
130
  convert(arguments_: Readonly<SlidevPptxConvertArguments>): Promise<PipelineResult>;
@@ -8,7 +8,7 @@ export type ImageDimensionsFailure = 'unsupported-format' | 'unreadable';
8
8
  export type ImageFormat = 'png' | 'jpeg';
9
9
  /**
10
10
  寸法読み取りの結果。1 件の失敗で xlsx 生成全体を落とさない (FR-006) ため、
11
- 例外ではなく ok:false で返す。`message` は CLI がそのまま stderr に出せる文言。
11
+ 例外ではなく ok:false で返す。`message` はそのまま利用者に出せる文言。
12
12
 
13
13
  `not-found` は fs アクセスの結果であり infra 側の責務なので、ここには持たせない。
14
14
  */
@@ -15,16 +15,4 @@ export interface PreviewDivergenceFinding {
15
15
  0 件になる)。slide 番号の付与は command 層が part 名から導出する。
16
16
  */
17
17
  export declare function detectPreviewDivergence(slide: XmlDocument): readonly PreviewDivergenceFinding[];
18
- /**
19
- 検知対象の bodyPr を `wrap="square"` + `<a:noAutofit/>` に正規化する。
20
-
21
- - `wrap` 属性を `square` に setAttr する(他属性は保存される)。
22
- - 子 `a:spAutoFit` を `<a:noAutofit xmlns:a="…"/>` に replaceWithXml する。
23
- fragment parse 用に xmlns:a 宣言が必須。
24
-
25
- 冪等。正規化済み(noAutofit + wrap=square)の bodyPr は XPath にヒットしないため、再適用されない。
26
- */
27
- export declare function applyPreviewNormalization(slide: XmlDocument): {
28
- readonly normalized: number;
29
- };
30
18
  //# sourceMappingURL=preview-normalize.d.ts.map
@@ -4,10 +4,8 @@
4
4
  // コンテナ内 PDF プレビューで左揃えテキストが中央寄せ化する。
5
5
  // 内包 pptxgenjs が 3.12.0 → 4.0.1 に上がっても、この組み合わせは維持される。
6
6
  // #1062 の計測では、51 枚のデッキの検知件数は 1.1.10 / 2.1.1 とも 175 件で同数だった。
7
- // 元 PPTX は変更せず、プレビュー専用コピーに対して `noAutofit` + `wrap="square"` へ置換する。
8
- // 実装は XmlDocument / XmlNode ポート経由で行い、parse / serialize は commands 層の責務とする。
7
+ // 検知だけを行う。scripts/pptx-compare/ が差分の比較に使う。実装は XmlDocument / XmlNode ポート経由で行う。
9
8
  import { NAMESPACES } from './post-process.js';
10
- import { NS_DRAWINGML } from '../_shared/ooxml-uris.js';
11
9
  // `wrap="none"` かつ子に `a:spAutoFit` を持つ bodyPr のみを対象とする。
12
10
  // wrap=none と spAutoFit の片方だけを持つ要素は触らない。
13
11
  const DIVERGENT_BODYPR_XPATH = '//a:bodyPr[@wrap=\'none\'][a:spAutoFit]';
@@ -27,28 +25,6 @@ export function detectPreviewDivergence(slide) {
27
25
  }
28
26
  return findings;
29
27
  }
30
- /**
31
- 検知対象の bodyPr を `wrap="square"` + `<a:noAutofit/>` に正規化する。
32
-
33
- - `wrap` 属性を `square` に setAttr する(他属性は保存される)。
34
- - 子 `a:spAutoFit` を `<a:noAutofit xmlns:a="…"/>` に replaceWithXml する。
35
- fragment parse 用に xmlns:a 宣言が必須。
36
-
37
- 冪等。正規化済み(noAutofit + wrap=square)の bodyPr は XPath にヒットしないため、再適用されない。
38
- */
39
- export function applyPreviewNormalization(slide) {
40
- let normalized = 0;
41
- for (const bodyPr of slide.selectNodes(DIVERGENT_BODYPR_XPATH, NAMESPACES)) {
42
- bodyPr.setAttr('wrap', 'square');
43
- const [spAutoFit] = bodyPr.selectNodes('./a:spAutoFit', NAMESPACES);
44
- /* c8 ignore next 3 -- XPath が a:spAutoFit を子に持つ bodyPr のみを返すため undefined の分岐は到達不能 */
45
- if (spAutoFit === undefined)
46
- continue;
47
- spAutoFit.replaceWithXml(`<a:noAutofit xmlns:a="${NS_DRAWINGML}"/>`);
48
- normalized += 1;
49
- }
50
- return { normalized };
51
- }
52
28
  function resolveShapeName(bodyPr) {
53
29
  const [cNvPr] = bodyPr.selectNodes('ancestor::p:sp/p:nvSpPr/p:cNvPr', NAMESPACES);
54
30
  if (cNvPr === undefined)
@@ -1,5 +1,5 @@
1
- // slide create / sync / lint が共有する例外。
2
- // usage error(CLI 引数の誤り、exit 2)と runtime error(実行時の失敗、exit 1)を分ける。
1
+ // slide_create / slide_sync / slide_lint が共有する例外。
2
+ // usage error(引数の誤り)と runtime error(実行時の失敗)を分ける。
3
3
  export class SlideCreateUsageError extends Error {
4
4
  reason;
5
5
  constructor(message, reason) {
@@ -155,7 +155,7 @@ export function viteConfigSource(options) {
155
155
  ' headers: { \'Cache-Control\': \'no-cache\' },',
156
156
  ' },',
157
157
  ' define: {',
158
- ' // pecotv slide convert loads the print page once and converts all pages.',
158
+ ' // slide_convert loads the print page once and converts all pages.',
159
159
  ' // this setting puts the print route into the built SPA.',
160
160
  ' // it is a Slidev-internal define, not a public API.',
161
161
  ' // when this flag has no effect on a build, pecotv warns and converts the old way.',
@@ -178,7 +178,7 @@ export const START_SCRIPT_SOURCE = [
178
178
  ' * A way to preview manually in environments that do not use MCP.',
179
179
  ' * It targets editors and plain terminals that have not registered the pecot-visual server.',
180
180
  ' * The directory of this script is the working root.',
181
- ' * node_modules is prepared by pecotv slide create and pecotv slide sync.',
181
+ ' * node_modules is prepared by the slide_create and slide_sync tools.',
182
182
  ' * When it is missing, the script points to sync and exits.',
183
183
  ' * It starts the Slidev bin directly with node.',
184
184
  ' */',
@@ -195,7 +195,7 @@ export const START_SCRIPT_SOURCE = [
195
195
  '',
196
196
  'if (!existsSync(slidevBin)) {',
197
197
  ' console.error(\'error: @slidev/cli not found at \' + slidevBin + \'.\')',
198
- ' console.error(\' run pecotv slide sync --dir \' + __dirname + \' --node-modules-only\')',
198
+ ' console.error(\' call the slide_sync tool with dir: \' + __dirname + \' and node_modules_only: true\')',
199
199
  ' process.exit(1)',
200
200
  '}',
201
201
  '',