@pecot/visual-mcp 1.1.0 → 1.2.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.
Files changed (52) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/assets/slidev/package.json +6 -6
  3. package/assets/slidev/runtime/package.json +11 -11
  4. package/assets/slidev/scripts/eslint/_shared/dist/tsconfig.tsbuildinfo +1 -1
  5. package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/tsconfig.tsbuildinfo +1 -1
  6. package/assets/slidev/scripts/eslint/slidev-pages-lint/package.json +1 -1
  7. package/assets/slidev/scripts/eslint/text-constraints/dist/tsconfig.tsbuildinfo +1 -1
  8. package/assets/slidev/scripts/eslint/text-constraints/package.json +1 -1
  9. package/assets/slidev/scripts/eslint/validate-references/dist/lib/schema-validator.js +1 -1
  10. package/assets/slidev/scripts/eslint/validate-references/dist/tsconfig.tsbuildinfo +1 -1
  11. package/assets/slidev/scripts/eslint/validate-references/lib/schema-validator.ts +2 -2
  12. package/assets/slidev/scripts/eslint/validate-references/package.json +1 -1
  13. package/cli/dist/cli.js +3 -2
  14. package/cli/dist/commands/chromium/host-dependencies.js +12 -5
  15. package/cli/dist/commands/drawio/export.js +14 -11
  16. package/cli/dist/commands/drawio/theme.js +1 -1
  17. package/cli/dist/commands/drawio/url.js +27 -19
  18. package/cli/dist/commands/evidence-xlsx/create.js +11 -10
  19. package/cli/dist/commands/pptx-ooxml/preview.js +13 -17
  20. package/cli/dist/commands/slidev-project/create.js +19 -18
  21. package/cli/dist/commands/slidev-project/lint.js +24 -22
  22. package/cli/dist/commands/slidev-project/sync.js +25 -24
  23. package/cli/dist/commands/slidev-project/theme.js +14 -13
  24. package/cli/dist/commands/slidev-to-pptx/convert.d.ts +4 -0
  25. package/cli/dist/commands/slidev-to-pptx/convert.js +45 -32
  26. package/cli/dist/diagnostics.d.ts +38 -0
  27. package/cli/dist/diagnostics.js +46 -0
  28. package/cli/dist/domain/_shared/ports.d.ts +0 -1
  29. package/cli/dist/domain/drawio/url.d.ts +11 -7
  30. package/cli/dist/domain/drawio/url.js +47 -25
  31. package/cli/dist/domain/pptx-ooxml/prerender-replace.d.ts +1 -0
  32. package/cli/dist/domain/pptx-ooxml/prerender-replace.js +3 -3
  33. package/cli/dist/domain/slidev-project/generated-files.js +3 -3
  34. package/cli/dist/infra/_shared/runtime-install.d.ts +12 -84
  35. package/cli/dist/infra/_shared/runtime-install.js +72 -107
  36. package/cli/dist/infra/slidev-to-pptx/console-logger.d.ts +5 -5
  37. package/cli/dist/infra/slidev-to-pptx/console-logger.js +19 -20
  38. package/cli/dist/infra/slidev-to-pptx/dom-converter.d.ts +1 -1
  39. package/cli/dist/infra/slidev-to-pptx/dom-converter.js +1 -1
  40. package/cli/dist/infra/slidev-to-pptx/index.js +1 -9
  41. package/cli/dist/infra/slidev-to-pptx/pipeline.d.ts +1 -1
  42. package/cli/dist/infra/slidev-to-pptx/pipeline.js +2 -2
  43. package/cli/dist/infra/slidev-to-pptx/server.d.ts +2 -1
  44. package/cli/dist/infra/slidev-to-pptx/server.js +2 -2
  45. package/cli/dist/mcp/serve.js +5 -3
  46. package/cli/dist/mcp/tools/_shared.js +11 -1
  47. package/cli/dist/mcp/tools/drawio.js +2 -1
  48. package/cli/dist/mcp/tools/slide-page.js +3 -1
  49. package/cli/dist/mcp/tools/slide.js +3 -1
  50. package/npm-shrinkwrap.json +45 -51
  51. package/package.json +5 -5
  52. package/vendor/text-rules/dist/source-hash +1 -1
@@ -9,6 +9,7 @@
9
9
  import { readFile, writeFile } from 'node:fs/promises';
10
10
  import path from 'node:path';
11
11
  import { Command } from 'commander';
12
+ import { createDiagnostics, passthrough, writeData } from '../../diagnostics.js';
12
13
  import { classifyTalkTheme } from '../../domain/slidev-theme/talk-theme.js';
13
14
  import { readThemeDeclaration } from '../../domain/slidev-theme/declaration.js';
14
15
  import { ThemeSpecError, parseThemeSpec } from '../../domain/slidev-theme/theme-spec.js';
@@ -66,14 +67,14 @@ export function createSlideSyncCommand(buildDependencies) {
66
67
  writeErr: (string_) => {
67
68
  const dependencies = buildDependencies();
68
69
  if (doesArgvWantJson(process.argv)) {
69
- dependencies.stdout.write(`${JSON.stringify({
70
+ writeData(dependencies.stdout, JSON.stringify({
70
71
  event: 'slide.sync.error',
71
72
  reason: 'invalid-option',
72
73
  detail: string_.replace(/^error:[ \t]*/i, '').trim(),
73
- })}\n`);
74
+ }));
74
75
  }
75
76
  else {
76
- dependencies.stderr.write(string_);
77
+ passthrough(dependencies.stderr, string_);
77
78
  }
78
79
  },
79
80
  })
@@ -94,7 +95,7 @@ export function createSlideSyncCommand(buildDependencies) {
94
95
  writeSyncSummary(summary, dependencies.stdout);
95
96
  });
96
97
  if (isWantsJson) {
97
- dependencies.stdout.write(`${JSON.stringify(execution.data)}\n`);
98
+ writeData(dependencies.stdout, JSON.stringify(execution.data));
98
99
  }
99
100
  else {
100
101
  writeAutoDeckLintReport(execution.lint, execution.summary.directory, dependencies);
@@ -104,14 +105,14 @@ export function createSlideSyncCommand(buildDependencies) {
104
105
  const reason = errorToReason(error);
105
106
  const detail = formatError(error);
106
107
  if (isWantsJson) {
107
- dependencies.stdout.write(`${JSON.stringify({
108
+ writeData(dependencies.stdout, JSON.stringify({
108
109
  event: 'slide.sync.error',
109
110
  reason,
110
111
  detail,
111
- })}\n`);
112
+ }));
112
113
  }
113
114
  else {
114
- dependencies.stderr.write(`pecotv slide sync 失敗: ${detail}\n`);
115
+ createDiagnostics(dependencies.stderr).error(`slide sync 失敗: ${detail}`);
115
116
  }
116
117
  process.exitCode = toExitCode(error);
117
118
  }
@@ -129,27 +130,27 @@ function writeSyncSummary(summary,
129
130
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
130
131
  stdout) {
131
132
  const { theme } = summary;
132
- const themeLine = theme === undefined ? undefined : ` テーマ: ${theme.name} (${theme.spec})\n`;
133
+ const themeLine = theme === undefined ? undefined : ` テーマ: ${theme.name} (${theme.spec})`;
133
134
  if (summary.nodeModulesOnly) {
134
- stdout.write(`slide sync (node_modules のみ): 成功 (${summary.directory})\n`);
135
+ writeData(stdout, `slide sync (node_modules のみ): 成功 (${summary.directory})`);
135
136
  if (themeLine !== undefined)
136
- stdout.write(themeLine);
137
- stdout.write(` node_modules → ${summary.nodeModulesTarget}\n`);
137
+ writeData(stdout, themeLine);
138
+ writeData(stdout, ` node_modules → ${summary.nodeModulesTarget}`);
138
139
  return;
139
140
  }
140
- stdout.write(`slide sync: 成功 (${summary.directory})\n`);
141
+ writeData(stdout, `slide sync: 成功 (${summary.directory})`);
141
142
  if (themeLine !== undefined)
142
- stdout.write(themeLine);
143
+ writeData(stdout, themeLine);
143
144
  if (summary.mode === 'relink') {
144
145
  if (theme !== undefined)
145
- stdout.write(` 置き場: ${theme.directory}\n`);
146
- stdout.write(` node_modules → ${summary.nodeModulesTarget}\n`);
147
- stdout.write(' node_modules のほかは変えていません。\n');
146
+ writeData(stdout, ` 置き場: ${theme.directory}`);
147
+ writeData(stdout, ` node_modules → ${summary.nodeModulesTarget}`);
148
+ writeData(stdout, ' node_modules のほかは変えていません。');
148
149
  return;
149
150
  }
150
- stdout.write(` node_modules → ${summary.nodeModulesTarget}\n`);
151
- stdout.write(` 消した名前 (${String(summary.removed.length)} 件): ${summary.removed.join(', ')}\n`);
152
- stdout.write(' 作品領域(slides.md / pages/*.md / public/slides/)は残しました。slides.md の theme: と package.json の依存を書き換えています。\n');
151
+ writeData(stdout, ` node_modules → ${summary.nodeModulesTarget}`);
152
+ writeData(stdout, ` 消した名前 (${String(summary.removed.length)} 件): ${summary.removed.join(', ')}`);
153
+ writeData(stdout, ' 作品領域(slides.md / pages/*.md / public/slides/)は残しました。slides.md の theme: と package.json の依存を書き換えています。');
153
154
  }
154
155
  /**
155
156
  `slide sync` の実処理と機械可読な結果組み立て。CLI action と MCP ツールの双方がここを通る。
@@ -163,7 +164,7 @@ export async function executeSlideSync(options,
163
164
  dependencies, onSynced) {
164
165
  const summary = await runSyncCore(options, dependencies);
165
166
  for (const warning of summary.warnings)
166
- dependencies.stderr.write(`[warn] ${warning}\n`);
167
+ createDiagnostics(dependencies.stderr).warning(warning);
167
168
  onSynced?.(summary);
168
169
  // 同期後のデッキ全体 lint。違反があっても sync の成否は変えない。
169
170
  const lint = await runAutoDeckLint(summary.directory, dependencies);
@@ -203,12 +204,12 @@ stderr) {
203
204
  try {
204
205
  const { data } = await executeSlideTheme({ dir: directory }, { files: new NodeThemeFiles() });
205
206
  for (const warning of data.warnings)
206
- stderr.write(`[warn] ${warning}\n`);
207
+ createDiagnostics(stderr).warning(warning);
207
208
  return { categories: data.categories, layouts: data.layouts };
208
209
  }
209
210
  catch (error) {
210
211
  // 移行前の形 (theme: none) もここに来る。一覧を空にして、同期の成否は変えない。
211
- stderr.write(`[warn] layout catalog を読み取れませんでした: ${directory} (${formatError(error)})\n`);
212
+ createDiagnostics(stderr).warning(`layout catalog を読み取れませんでした: ${directory} (${formatError(error)})`);
212
213
  return { categories: [], layouts: [] };
213
214
  }
214
215
  }
@@ -231,11 +232,11 @@ dependencies) {
231
232
  storeRoot: dependencies.themeStoreRoot ?? themeStoreRoot,
232
233
  currentDirectory: dependencies.currentDirectory ?? process.cwd(),
233
234
  dependencyRoot,
234
- warn: (message) => { dependencies.stderr.write(`[warn] ${message}\n`); },
235
+ warn: (message) => { createDiagnostics(dependencies.stderr).warning(message); },
235
236
  }),
236
237
  ensureThemeLinked: dependencies.ensureThemeLinked ?? (directory => ensureTalkThemeLinked(directory, linkedThemeDefaultDependencies(dependencyRoot,
237
238
  /* c8 ignore next -- 実 git の取得中に出る警告の出力先。テストは実 git に出ない */
238
- { warn: (message) => { dependencies.stderr.write(`[warn] ${message}\n`); } }))),
239
+ { warn: (message) => { createDiagnostics(dependencies.stderr).warning(message); } }))),
239
240
  });
240
241
  }
241
242
  /**
@@ -13,6 +13,7 @@
13
13
  import path from 'node:path';
14
14
  import { Command } from 'commander';
15
15
  import { THEME_DECLARATION_FILE_NAME, readThemeDeclaration, } from '../../domain/slidev-theme/declaration.js';
16
+ import { createDiagnostics, passthrough, writeData } from '../../diagnostics.js';
16
17
  import { themeErrorReason } from '../../domain/slidev-theme/error-reason.js';
17
18
  import { buildLayoutCatalog, readLayoutCategories, resolveLayoutReferences, } from '../../domain/slidev-theme/references.js';
18
19
  import { resolveTalkTheme } from '../../domain/slidev-theme/talk-theme.js';
@@ -85,19 +86,19 @@ stdout,
85
86
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
86
87
  stderr) {
87
88
  const { theme } = data;
88
- stdout.write(`slide theme: ${theme.name} (${theme.spec})\n`);
89
- stdout.write(` テーマ root: ${theme.directory}\n`);
90
- stdout.write(` 宣言: ${theme.declared ? 'あり' : 'なし'}\n`);
91
- stdout.write(` レイアウト ${String(data.layouts.length)} 件\n`);
89
+ writeData(stdout, `slide theme: ${theme.name} (${theme.spec})`);
90
+ writeData(stdout, ` テーマ root: ${theme.directory}`);
91
+ writeData(stdout, ` 宣言: ${theme.declared ? 'あり' : 'なし'}`);
92
+ writeData(stdout, ` レイアウト ${String(data.layouts.length)} 件`);
92
93
  for (const category of data.categories) {
93
- stdout.write(` --- ${category.label}: ${category.question} ---\n`);
94
+ writeData(stdout, ` --- ${category.label}: ${category.question} ---`);
94
95
  const members = data.layouts.filter(entry => entry.category === category.id);
95
96
  for (const layout of members) {
96
- stdout.write(` - ${layout.deprecated ? '[deprecated] ' : ''}${layout.layout}: ${layout.description}\n`);
97
+ writeData(stdout, ` - ${layout.deprecated ? '[deprecated] ' : ''}${layout.layout}: ${layout.description}`);
97
98
  }
98
99
  }
99
100
  for (const warning of data.warnings) {
100
- stderr.write(`[warn] ${warning}\n`);
101
+ createDiagnostics(stderr).warning(warning);
101
102
  }
102
103
  }
103
104
  /**
@@ -119,14 +120,14 @@ export function createSlideThemeCommand(buildDependencies) {
119
120
  writeErr: (string_) => {
120
121
  const dependencies = buildDependencies();
121
122
  if (doesArgvWantJson(process.argv)) {
122
- dependencies.stdout.write(`${JSON.stringify({
123
+ writeData(dependencies.stdout, JSON.stringify({
123
124
  event: 'slide.theme.error',
124
125
  reason: 'invalid-option',
125
126
  detail: string_.replace(/^error:[ \t]*/i, '').trim(),
126
- })}\n`);
127
+ }));
127
128
  }
128
129
  else {
129
- dependencies.stderr.write(string_);
130
+ passthrough(dependencies.stderr, string_);
130
131
  }
131
132
  },
132
133
  })
@@ -137,7 +138,7 @@ export function createSlideThemeCommand(buildDependencies) {
137
138
  try {
138
139
  const { data } = await executeSlideTheme({ dir: directory }, dependencies);
139
140
  if (isWantsJson) {
140
- dependencies.stdout.write(`${JSON.stringify(data)}\n`);
141
+ writeData(dependencies.stdout, JSON.stringify(data));
141
142
  }
142
143
  else {
143
144
  writeHumanReport(data, dependencies.stdout, dependencies.stderr);
@@ -147,10 +148,10 @@ export function createSlideThemeCommand(buildDependencies) {
147
148
  const reason = errorToReason(error);
148
149
  const detail = formatError(error);
149
150
  if (isWantsJson) {
150
- dependencies.stdout.write(`${JSON.stringify({ event: 'slide.theme.error', reason, detail })}\n`);
151
+ writeData(dependencies.stdout, JSON.stringify({ event: 'slide.theme.error', reason, detail }));
151
152
  }
152
153
  else {
153
- dependencies.stderr.write(`pecotv slide theme 失敗: ${detail}\n`);
154
+ createDiagnostics(dependencies.stderr).error(`slide theme 失敗: ${detail}`);
154
155
  }
155
156
  process.exitCode = 1;
156
157
  }
@@ -24,6 +24,10 @@ export interface SlideConvertOptions {
24
24
  readonly transitionType?: TransitionType;
25
25
  readonly transitionDurationMs?: number;
26
26
  readonly morphOption?: MorphOption;
27
+ /**
28
+ 進捗の詳しさ。省略時は infra の既定 (normal)。verbose・debug は進捗を stderr に note: で出す
29
+ */
30
+ readonly logLevel?: 'normal' | 'verbose' | 'debug';
27
31
  }
28
32
  export interface SlideConvertDependencies {
29
33
  readonly slidevRunner: SlidevRunner;
@@ -11,7 +11,7 @@
11
11
  import { performance } from 'node:perf_hooks';
12
12
  import { access, readFile, mkdir, readdir, rm, stat } from 'node:fs/promises';
13
13
  import path from 'node:path';
14
- import { Command } from 'commander';
14
+ import { Command, Option } from 'commander';
15
15
  import { PipelineRuntimeError, PipelineTimeoutError, } from '../../domain/slidev-to-pptx/errors.js';
16
16
  import { ANIMATION_POLICY_SCHEMA_VERSION, DEFAULT_SLIDE_PREFIX, parseSlideFilename, } from '../../domain/slidev-to-pptx/config.js';
17
17
  import { mergePptxFiles } from '../../domain/pptx-ooxml/merge.js';
@@ -19,6 +19,7 @@ import { applyHyperlinkFix, applyJapaneseFontFix, applyTransition, removeAnimati
19
19
  import { applyPrerenderImageReplace, findPrerenderImages, } from '../../domain/pptx-ooxml/prerender-replace.js';
20
20
  import { readThemeDeclaration } from '../../domain/slidev-theme/declaration.js';
21
21
  import { sanitizeFilename } from '../../domain/slidev-to-pptx/slides-title.js';
22
+ import { createDiagnostics, passthrough, writeData } from '../../diagnostics.js';
22
23
  import { readSlidesTitleFromFile } from '../../infra/slidev-to-pptx/slides-title-reader.js';
23
24
  import { ChildProcessSlidevRunner } from '../../infra/slidev-to-pptx/runner.js';
24
25
  import { InProcessSlidevPptxPipeline } from '../../infra/slidev-to-pptx/index.js';
@@ -148,20 +149,21 @@ async function resolveFontPolicy(projectAbs,
148
149
  // port メソッドが mutable と判定されるため interface readonly fields で担保。
149
150
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
150
151
  dependencies) {
152
+ const diagnostics = createDiagnostics(dependencies.stderr);
151
153
  const { theme } = await dependencies.ensureThemeLinked(projectAbs, {
152
154
  signal: dependencies.signal,
153
- warn: (message) => { dependencies.stderr.write(`[warn] ${message}\n`); },
155
+ warn: (message) => { diagnostics.warning(message); },
154
156
  });
155
157
  if (theme === undefined)
156
158
  return {};
157
159
  const { declaration, warnings } = await dependencies.readThemeDeclaration(theme.directory);
158
160
  for (const warning of warnings)
159
- dependencies.stderr.write(`[warn] ${warning}\n`);
161
+ diagnostics.warning(warning);
160
162
  // 書体とリンク色を宣言から取るため、省いた deck は書き込みが無くなる。変化に気付けるよう知らせる。
161
163
  if (declaration.pptx.linkColor === undefined)
162
- dependencies.stderr.write(`[warn] ${LINK_COLOR_OMITTED_WARNING}\n`);
164
+ diagnostics.warning(LINK_COLOR_OMITTED_WARNING);
163
165
  if (declaration.pptx.eastAsianFont === undefined)
164
- dependencies.stderr.write(`[warn] ${EAST_ASIAN_FONT_OMITTED_WARNING}\n`);
166
+ diagnostics.warning(EAST_ASIAN_FONT_OMITTED_WARNING);
165
167
  return fontPolicyOf(declaration.pptx);
166
168
  }
167
169
  export async function runSlideConvert(projectDirectory, options,
@@ -185,10 +187,8 @@ dependencies) {
185
187
  await cleanBuildArtifacts(projectAbs);
186
188
  const cleanBuildMs = dependencies.now() - start;
187
189
  // capture/relay 切替: slidev build 子プロセスの stdout/stderr は --json 時に破棄する
188
- // (tech-advisor B2)。
189
- // in-process pipeline へは、--json 時に stdout を渡さず stderr だけを渡す。
190
- // 対象は InProcessSlidevPptxPipeline (infra/slidev-to-pptx/index.ts)。
191
- // 同 pipeline は stdout 未指定なら人間可読ログを stderr へ出すため、stdout は JSON 行だけになる。
190
+ // (tech-advisor B2)。--json でないときは、どちらも stderr へ中継する (stdout はデータだけ)。
191
+ // in-process pipeline の人間可読ログは、常に stderr の診断行 (note / warning / error) で出る。
192
192
  const isRelayEnabled = options.json !== true;
193
193
  const buildOptions = { timeoutMs: SLIDEV_BUILD_TIMEOUT_MS };
194
194
  if (options.theme !== undefined)
@@ -196,7 +196,7 @@ dependencies) {
196
196
  if (dependencies.signal !== undefined)
197
197
  buildOptions.signal = dependencies.signal;
198
198
  if (isRelayEnabled) {
199
- buildOptions.stdout = dependencies.stdout;
199
+ buildOptions.stdout = dependencies.stderr;
200
200
  buildOptions.stderr = dependencies.stderr;
201
201
  }
202
202
  const buildStart = dependencies.now();
@@ -231,13 +231,13 @@ dependencies) {
231
231
  // 通知なしにヒットしないよう、slidev build に渡した値をそのまま pptxConverter にも渡す。
232
232
  if (options.theme !== undefined)
233
233
  convertOptions.theme = options.theme;
234
+ if (options.logLevel !== undefined)
235
+ convertOptions.logLevel = options.logLevel;
234
236
  if (dependencies.signal !== undefined)
235
237
  convertOptions.signal = dependencies.signal;
236
238
  // --no-single-pass は現行ルートを強制する。未指定はキーを置かず、pipeline 側が env に従う。
237
239
  if (options.singlePass === false)
238
240
  convertOptions.singlePass = false;
239
- if (isRelayEnabled)
240
- convertOptions.stdout = dependencies.stdout;
241
241
  convertOptions.stderr = dependencies.stderr;
242
242
  const report = dependencies.onProgress;
243
243
  if (report !== undefined) {
@@ -578,7 +578,7 @@ dependencies) {
578
578
  // 外側ループは `^ppt/slides/slide\d+\.xml$` で gate されるため、media part の追加 set は
579
579
  // ループ進行を撹乱しない。
580
580
  const entries = await findPrerenderImages(slidesDirectory, originalSlideNumber, { exists: doesPathExist });
581
- await applyPrerenderImageReplace(slideDocument, relsDocument, partMap, entries, { readFile });
581
+ await applyPrerenderImageReplace(slideDocument, relsDocument, partMap, entries, { readFile, warn: createDiagnostics(dependencies.stderr).warning });
582
582
  partMap.set(slidePart, dependencies.engine.serialize(slideDocument));
583
583
  partMap.set(relsPart, dependencies.engine.serialize(relsDocument));
584
584
  }
@@ -742,8 +742,8 @@ stderr) {
742
742
  // slides.md 不在 (ENOENT) は basename fallback の正常系のため警告しない。
743
743
  // それ以外の読取失敗 (permission 等) は診断を stderr に残す (stdout の JSON イベント契約を汚さない)。
744
744
  if (error.code !== 'ENOENT') {
745
- stderr.write(`pecotv slide convert: slides.md を読み取れないため既定出力名を basename から決定します`
746
- + ` (${slidesPath}): ${error.message}\n`);
745
+ createDiagnostics(stderr).warning(`slides.md を読み取れないため既定出力名を basename から決定します`
746
+ + ` (${slidesPath}): ${error.message}`);
747
747
  }
748
748
  });
749
749
  }
@@ -825,23 +825,27 @@ export function createSlideConvertCommand(buildDependencies) {
825
825
  .option('--morph-option <option>', 'morph option (byObject|byWord|byChar)')
826
826
  .option('--no-cache', 'キャッシュを読まずに全スライドを変換する(完了時にキャッシュは再構築される)')
827
827
  .option('--no-single-pass', '1 パスのルートを使わず、スライドのステップごとにページを開く従来ルートで変換する')
828
+ .addOption(new Option('--log-level <level>', '進捗の詳しさ(verbose・debug は進捗を stderr に出す)').choices(['normal', 'verbose', 'debug']))
828
829
  .option('--json', 'emit machine-readable progress on stdout', false)
829
830
  .exitOverride()
830
831
  .configureOutput({
832
+ writeOut: (string_) => {
833
+ writeData(buildDependencies().stdout, string_);
834
+ },
831
835
  writeErr: (string_) => {
832
836
  const dependencies = buildDependencies();
833
837
  if (doesArgvWantJson(process.argv)) {
834
- dependencies.stdout.write(JSON.stringify({
838
+ writeData(dependencies.stdout, JSON.stringify({
835
839
  event: 'slide.convert.error',
836
840
  reason: 'invalid-option',
837
841
  detail: string_.replace(/^error:\s*/i, '').trim(),
838
842
  // done payload と同じく常時載せる。option 解析で落ちた run は pipeline 未到達のため空配列。
839
843
  warnings: [],
840
844
  errors: [],
841
- }) + '\n');
845
+ }));
842
846
  }
843
847
  else {
844
- dependencies.stderr.write(string_);
848
+ passthrough(dependencies.stderr, string_);
845
849
  }
846
850
  },
847
851
  })
@@ -856,6 +860,7 @@ export function createSlideConvertCommand(buildDependencies) {
856
860
  const transitionType = optionalTransitionType(raw, 'transitionType');
857
861
  const transitionDurationMs = optionalPositiveInt(raw, 'transitionDurationMs', 'invalid-transition-duration-ms');
858
862
  const morphOption = optionalMorphOption(raw, 'morphOption');
863
+ const logLevel = optionalLogLevel(raw, 'logLevel');
859
864
  const optionalsPart = {};
860
865
  if (theme !== undefined)
861
866
  optionalsPart.theme = theme;
@@ -869,6 +874,8 @@ export function createSlideConvertCommand(buildDependencies) {
869
874
  optionalsPart.transitionDurationMs = transitionDurationMs;
870
875
  if (morphOption !== undefined)
871
876
  optionalsPart.morphOption = morphOption;
877
+ if (logLevel !== undefined)
878
+ optionalsPart.logLevel = logLevel;
872
879
  const outOption = optionalString(raw, 'out');
873
880
  const resolvedProject = path.resolve(projectDirectory);
874
881
  const out = outOption ?? await resolveDefaultOut(resolvedProject, dependencies.stderr);
@@ -886,16 +893,16 @@ export function createSlideConvertCommand(buildDependencies) {
886
893
  const reason = errorToReason(error);
887
894
  const detail = formatError(error);
888
895
  if (isWantsJson) {
889
- dependencies.stdout.write(JSON.stringify({
896
+ writeData(dependencies.stdout, JSON.stringify({
890
897
  event: 'slide.convert.error',
891
898
  reason,
892
899
  detail,
893
900
  warnings: [],
894
901
  errors: [],
895
- }) + '\n');
902
+ }));
896
903
  }
897
904
  else {
898
- dependencies.stderr.write(`pecotv slide convert: ${detail}\n`);
905
+ createDiagnostics(dependencies.stderr).error(detail);
899
906
  }
900
907
  process.exitCode = toExitCode(error);
901
908
  return;
@@ -904,26 +911,26 @@ export function createSlideConvertCommand(buildDependencies) {
904
911
  if (options.json === true) {
905
912
  // event 順序保証: start → done (失敗時は start → error)。tooling 側 stream parser
906
913
  // は start を進捗開始の signal として待つことができる。
907
- dependencies.stdout.write(JSON.stringify({
914
+ writeData(dependencies.stdout, JSON.stringify({
908
915
  event: 'slide.convert.start',
909
916
  input: path.resolve(projectDirectory),
910
917
  output: path.resolve(options.out),
911
- }) + '\n');
918
+ }));
912
919
  }
913
920
  const { summary, data } = await executeSlideConvert(projectDirectory, options, dependencies);
914
921
  if (options.json === true) {
915
- dependencies.stdout.write(JSON.stringify(data) + '\n');
922
+ writeData(dependencies.stdout, JSON.stringify(data));
916
923
  }
917
924
  else {
918
- dependencies.stdout.write(`slide convert: ${summary.inputAbs} -> ${summary.outputAbs}`
919
- + ` (${String(Math.round(summary.durationMs))}ms)\n`);
925
+ writeData(dependencies.stdout, `slide convert: ${summary.inputAbs} -> ${summary.outputAbs}`
926
+ + ` (${String(Math.round(summary.durationMs))}ms)`);
920
927
  // 0 件のときは出さない(除去が起きなかった run で行数を増やさない)。
921
928
  if (summary.animationTimingRemovedSlides > 0) {
922
- dependencies.stdout.write(`animation: ${String(summary.animationTimingRemovedSlides)} 枚のスライドから`
923
- + ` p:timing を除去しました (明示指定のあるスライドは保持)\n`);
929
+ writeData(dependencies.stdout, `animation: ${String(summary.animationTimingRemovedSlides)} 枚のスライドから`
930
+ + ` p:timing を除去しました (明示指定のあるスライドは保持)`);
924
931
  }
925
932
  if (summary.cache !== undefined) {
926
- dependencies.stdout.write(formatCacheSummary(summary.cache));
933
+ writeData(dependencies.stdout, formatCacheSummary(summary.cache));
927
934
  }
928
935
  }
929
936
  }
@@ -931,7 +938,7 @@ export function createSlideConvertCommand(buildDependencies) {
931
938
  const reason = errorToReason(error);
932
939
  const detail = formatError(error);
933
940
  if (options.json === true) {
934
- dependencies.stdout.write(JSON.stringify({
941
+ writeData(dependencies.stdout, JSON.stringify({
935
942
  event: 'slide.convert.error',
936
943
  reason,
937
944
  detail,
@@ -939,16 +946,22 @@ export function createSlideConvertCommand(buildDependencies) {
939
946
  // pipeline 未到達なら空配列(done payload と同じく「不在=旧版」と区別する)。
940
947
  // detail 側 (formatPipelineErrors) は先頭 3 件に丸めるが、機械可読側は全件載せる。
941
948
  ...convertErrorDiagnostics(error),
942
- }) + '\n');
949
+ }));
943
950
  }
944
951
  else {
945
- dependencies.stderr.write(`pecotv slide convert: ${detail}\n`);
952
+ createDiagnostics(dependencies.stderr).error(detail);
946
953
  }
947
954
  process.exitCode = toExitCode(error);
948
955
  }
949
956
  });
950
957
  return command;
951
958
  }
959
+ const LOG_LEVELS = ['normal', 'verbose', 'debug'];
960
+ function optionalLogLevel(raw, key) {
961
+ // eslint-disable-next-line security/detect-object-injection -- key は本ファイル内の固定文字列のみ
962
+ const value = raw[key];
963
+ return LOG_LEVELS.find(level => level === value);
964
+ }
952
965
  function optionalString(raw, key) {
953
966
  // eslint-disable-next-line security/detect-object-injection -- key は本ファイル内の固定文字列のみ
954
967
  const value = raw[key];
@@ -0,0 +1,38 @@
1
+ import { z } from 'zod';
2
+ export interface DiagnosticStream {
3
+ write(text: string): unknown;
4
+ }
5
+ /**
6
+ done の動詞。自由な文字列を受け取らない
7
+ */
8
+ export declare const DiagnosticVerbSchema: z.ZodEnum<{
9
+ add: "add";
10
+ create: "create";
11
+ }>;
12
+ export type DiagnosticVerb = z.infer<typeof DiagnosticVerbSchema>;
13
+ export interface DiagnosticOperation {
14
+ readonly verb: DiagnosticVerb;
15
+ readonly target: string;
16
+ }
17
+ export interface Diagnostics {
18
+ readonly error: (message: string) => void;
19
+ readonly warning: (message: string) => void;
20
+ /**
21
+ 情報の診断だけに使う。進捗の行には使わない
22
+ */
23
+ readonly note: (message: string) => void;
24
+ /**
25
+ 実行した操作を `<過去分詞>: <target>` で出す
26
+ */
27
+ readonly done: (operation: DiagnosticOperation) => void;
28
+ }
29
+ export declare function createDiagnostics(stderr: DiagnosticStream): Diagnostics;
30
+ /**
31
+ 結果の本体を stdout にそのまま出す。末尾に改行が無ければ 1 つ足す
32
+ */
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
+ //# sourceMappingURL=diagnostics.d.ts.map
@@ -0,0 +1,46 @@
1
+ // stderr の診断行と stdout のデータを書く、唯一の場所。
2
+ // 行の形は specs/021-cli-output-functions/contracts/output-lines.md が決める。
3
+ // 期待の行は tests/diagnostics-cases.json に置く。
4
+ import { z } from 'zod';
5
+ /**
6
+ done の動詞。自由な文字列を受け取らない
7
+ */
8
+ export const DiagnosticVerbSchema = z.enum(['create', 'add']);
9
+ function pastOf(verb) {
10
+ switch (verb) {
11
+ case 'create': {
12
+ return 'created';
13
+ }
14
+ case 'add': {
15
+ return 'added';
16
+ }
17
+ }
18
+ }
19
+ /**
20
+ 末尾の改行を取り除き、2 行目以降の先頭に空白 2 つを付け、末尾に改行を 1 つ付ける
21
+ */
22
+ function formatMessage(prefix, message) {
23
+ const lines = message.replace(/\n+$/, '').split('\n');
24
+ return `${prefix}: ${lines.join('\n ')}\n`;
25
+ }
26
+ export function createDiagnostics(stderr) {
27
+ return {
28
+ error: (message) => { stderr.write(formatMessage('error', message)); },
29
+ warning: (message) => { stderr.write(formatMessage('warning', message)); },
30
+ note: (message) => { stderr.write(formatMessage('note', message)); },
31
+ done: ({ verb, target }) => { stderr.write(`${pastOf(verb)}: ${target}\n`); },
32
+ };
33
+ }
34
+ /**
35
+ 結果の本体を stdout にそのまま出す。末尾に改行が無ければ 1 つ足す
36
+ */
37
+ export function writeData(stdout, text) {
38
+ stdout.write(text.endsWith('\n') ? text : `${text}\n`);
39
+ }
40
+ /**
41
+ commander が組み立てた使い方エラー・ヘルプの枠を、手を加えずに書く。commander が `error: ` を付ける
42
+ */
43
+ export function passthrough(stream, text) {
44
+ stream.write(text);
45
+ }
46
+ //# sourceMappingURL=diagnostics.js.map
@@ -145,7 +145,6 @@ export interface SlidevPptxConvertArguments {
145
145
  */
146
146
  readonly signal?: AbortSignal;
147
147
  readonly skipPostprocess?: boolean;
148
- readonly stdout?: NodeJS.WritableStream;
149
148
  readonly stderr?: NodeJS.WritableStream;
150
149
  /**
151
150
  既定 0 (ephemeral)。dist/ を serve する HTTP server の port。0 のときは OS が空き
@@ -5,20 +5,24 @@ parse に失敗した XML は undefined を返し、呼び出し側は確認を
5
5
  */
6
6
  export declare function parseDrawioXml(xml: string): XmldomDocument | undefined;
7
7
  export declare function stripComments(xml: string): string;
8
+ export interface DrawioFinding {
9
+ readonly severity: 'warning' | 'note';
10
+ readonly message: string;
11
+ }
8
12
  /**
9
- mxCell の value 属性内 HTML を確認し、警告メッセージ配列を返す。
13
+ mxCell の value 属性内 HTML を確認し、診断の配列を返す。
10
14
  Python 版の `_validate_html` と同等の検出ルールは次の 3 つ。
11
15
  1. `<font>` の属性が face/size/color/style 以外 → warn。
12
16
  2. value 内 HTML でシングルクォート属性値を使用 → warn。
13
- 3. `<font color>` と mxCell style の fontColor が同一値で二重指定 → info。
17
+ 3. `<font color>` と mxCell style の fontColor が同一値で二重指定 → note。
14
18
  */
15
- export declare function validateHtml(xml: string): readonly string[];
19
+ export declare function validateHtml(xml: string): readonly DrawioFinding[];
16
20
  /**
17
21
  mxCell の style と value を確認し、警告メッセージ配列を返す。
18
22
  対象は、折り返し必須 (日本語/改行/<br>) なのに `whiteSpace=wrap` が style に無い、box 系 vertex。
19
- v-diagram-creator が stderr の [warn] を読んで該当 mxCell に追記できる粒度で、id を入れる。
23
+ v-diagram-creator が stderr の warning を読んで該当 mxCell に追記できる粒度で、id を入れる。
20
24
  */
21
- export declare function validateWhitespaceWrap(xml: string): readonly string[];
25
+ export declare function validateWhitespaceWrap(xml: string): readonly DrawioFinding[];
22
26
  /**
23
27
  確かめる書体。テーマの宣言の `fonts.body` と `fonts.eastAsian` に当たる。
24
28
  */
@@ -61,7 +65,7 @@ value の HTML(`<font face>`・`style="font-family:..."`・`style="font:..."`
61
65
  `<object label>` / `<UserObject label>` に包まれたセルは、label を文字列として確認する。
62
66
  themeName は文言に書くテーマの名前。省くと「既定の書体」と書く。
63
67
  */
64
- export declare function validateSlideFonts(xml: string, fonts: Readonly<ThemeFonts>, themeName?: string): readonly string[];
68
+ export declare function validateSlideFonts(xml: string, fonts: Readonly<ThemeFonts>, themeName?: string): readonly DrawioFinding[];
65
69
  /**
66
70
  図の文字の大きさがテーマの宣言の 5 段(`fontSizes`)から外れる mxCell への、警告メッセージ配列を返す。
67
71
  大きさはセル style の fontSize(未指定は draw.io 既定の 11px)を初期値にして、文字列ごとに求める。
@@ -69,7 +73,7 @@ value の HTML(`style="font-size:..."`・`style="font:..."`)の入れ子の
69
73
  `<font size>` は使わない前提で、出たら警告する。px 以外の単位は指定文字列を出して px での指定を案内する。
70
74
  文字を持たないセルは対象外。
71
75
  */
72
- export declare function validateSlideFontSizes(xml: string, sizes: Readonly<ThemeFontSizes>): readonly string[];
76
+ export declare function validateSlideFontSizes(xml: string, sizes: Readonly<ThemeFontSizes>): readonly DrawioFinding[];
73
77
  /**
74
78
  style="..." 属性内に現れる `icon://path#color` を resolveIcon 経由で
75
79
  data URI に置換する。value 等のテキスト内容は対象外(Python リファレンスと同じ)。