@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.
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,4 +1,4 @@
1
- // `pecotv slide create --theme <theme-spec>` の実装。テンプレートはコピーしない。
1
+ // slide_create ツールの実装。テンプレートはコピーしない。
2
2
  // 次の順に実行する。
3
3
  // テーマの指定の解釈 → テーマの取得 → 宣言の読み取り → レイアウトの参照と分類の読み取り。
4
4
  // 続けて、生成先の確認 → slides.md と package.json の生成 → 初期ページ → public/slides。
@@ -8,8 +8,7 @@ import { randomBytes } from 'node:crypto';
8
8
  import { performance } from 'node:perf_hooks';
9
9
  import { mkdir, rename, rm, writeFile } from 'node:fs/promises';
10
10
  import path from 'node:path';
11
- import { Command } from 'commander';
12
- import { createDiagnostics, passthrough, writeData } from '../../diagnostics.js';
11
+ import { createDiagnostics } from '../../diagnostics.js';
13
12
  import { SlideCreateRuntimeError, SlideCreateUsageError } from '../../domain/slidev-project/errors.js';
14
13
  import { buildInitialPages, nameToTitle } from '../../domain/slidev-project/initial-pages.js';
15
14
  import { talkPackageJsonSource } from '../../domain/slidev-project/package-json.js';
@@ -18,19 +17,20 @@ import { LINK_COLOR_OMITTED_WARNING } from '../../domain/slidev-project/warnings
18
17
  import { readThemeDeclaration } from '../../domain/slidev-theme/declaration.js';
19
18
  import { themeErrorReason } from '../../domain/slidev-theme/error-reason.js';
20
19
  import { buildLayoutCatalog, readLayoutCategories, resolveLayoutReferences, } from '../../domain/slidev-theme/references.js';
21
- import { ThemeSpecError, parseThemeSpec } from '../../domain/slidev-theme/theme-spec.js';
20
+ import { parseThemeSpec } from '../../domain/slidev-theme/theme-spec.js';
22
21
  import { pluginDependencyRoot, themeStoreRoot } from '../../infra/_shared/dependency-root.js';
22
+ import { resolvePluginRoot } from '../../infra/_shared/plugin-root.js';
23
23
  import { assertDependencyRootAvailable, linkNodeModules, setupPublicSlides, talkDirectoryExists, writeGeneratedFiles, } from '../../infra/slidev-project/fs.js';
24
24
  import { NodeThemeFiles } from '../../infra/slidev-theme/fs.js';
25
25
  import { fetchTheme } from '../../infra/slidev-theme/store.js';
26
- import { autoDeckLintJsonField, runAutoDeckLint, writeAutoDeckLintReport, } from './lint.js';
26
+ import { autoDeckLintJsonField, runAutoDeckLint, } from './lint.js';
27
27
  import { absoluteSpec, packageSpec } from './theme-source.js';
28
28
  export { SlideCreateUsageError } from '../../domain/slidev-project/errors.js';
29
29
  /**
30
30
  テーマを取得し、talk-dir を生成する。
31
31
 
32
32
  生成は生成先と同じ親の下の一時 dir で組み立て、最後に入れ替える。
33
- `--force` で既存の生成先があっても、取得・生成のどこで失敗しても、既存は消えない。
33
+ `force` で既存の生成先があっても、取得・生成のどこで失敗しても、既存は消えない。
34
34
  失敗したら一時 dir を消す。取得中の警告は、失敗の前に出たものも stderr へ流す。
35
35
  */
36
36
  export async function runSlideCreate(projectDirectory, options,
@@ -63,7 +63,7 @@ warnings) {
63
63
  // 生成先には、取得の後まで触れない。生成先の存在と依存ルートの実体は、取得の前に確かめる。
64
64
  const destination = await talkDirectoryExists(projectAbsolute);
65
65
  if (!options.force && destination.exists) {
66
- throw new SlideCreateUsageError(`destination already exists (use --force to overwrite): ${projectAbsolute}`, 'dest-exists');
66
+ throw new SlideCreateUsageError(`destination already exists (pass force: true to overwrite): ${projectAbsolute}`, 'dest-exists');
67
67
  }
68
68
  const dependencyRoot = dependencies.dependencyRoot ?? dependencies.pluginRoot;
69
69
  assertDependencyRootAvailable(dependencyRoot);
@@ -107,7 +107,7 @@ warnings) {
107
107
  await writeGeneratedFiles(staging, { themeName: fetched.name });
108
108
  // node_modules の相対 symlink は親ごと同じ位置に入れ替わるため、入れ替え後も同じ先を指す。
109
109
  await linkNodeModules(staging, dependencyRoot, [{ name: fetched.name, directory: fetched.directory }]);
110
- // 組み立てが済んでから、既存の生成先 (--force) を外して入れ替える。
110
+ // 組み立てが済んでから、既存の生成先 (force) を外して入れ替える。
111
111
  if (destination.exists)
112
112
  await rm(projectAbsolute, { recursive: true, force: true });
113
113
  await rename(staging, projectAbsolute);
@@ -125,21 +125,15 @@ warnings) {
125
125
  };
126
126
  }
127
127
  /**
128
- `slide create` の実処理と機械可読な結果組み立て。CLI action と MCP ツールの双方がここを通る。
129
-
130
- @param onCreated 生成完了時点(deck lint より前)に呼ばれる。CLI は人間向けの成否行を
131
- ここで書き、違反一覧より先に出す。MCP ツールは渡さない。
128
+ slide_create の実処理と機械可読な結果組み立て。MCP ツールがここを通る。
132
129
  */
133
130
  export async function executeSlideCreate(projectDirectory, options,
134
131
  // DI 経由の write は mutate メソッド。
135
132
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
136
- dependencies, onCreated) {
133
+ dependencies) {
137
134
  const { catalog, warnings, ...summary } = await runSlideCreate(projectDirectory, options, dependencies);
138
135
  for (const warning of warnings)
139
136
  createDiagnostics(dependencies.stderr).warning(warning);
140
- if (options.emitCatalog)
141
- emitLayoutCatalog(catalog, dependencies.stdout);
142
- onCreated?.(summary);
143
137
  // 生成直後のデッキ全体 lint。違反があっても create の成否は変えない。
144
138
  const lint = await runAutoDeckLint(summary.projectDirectory, dependencies);
145
139
  return {
@@ -157,37 +151,6 @@ dependencies, onCreated) {
157
151
  };
158
152
  }
159
153
  /**
160
- 収集済みのレイアウトの一覧を人間向けに stdout へ書き出す。分類ごとに群化し、deprecated は群内で
161
- `[deprecated]` 接頭辞を付ける(選ばない対象だが、分類から外して別枠にすると、その分類に
162
- 何が属するかが読めなくなる)。レイアウトが 0 件の分類も見出しを出して不足を見せる。
163
- */
164
- export function emitLayoutCatalog(catalog,
165
- // WritableStream の write は mutate。
166
- // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
167
- stdout) {
168
- const { categories, layouts } = catalog;
169
- writeData(stdout, '='.repeat(60));
170
- writeData(stdout, 'Layout Catalog (read it fully before plan mode in Step 2)');
171
- writeData(stdout, `${'='.repeat(60)}\n\n`);
172
- for (const category of categories) {
173
- writeData(stdout, `--- ${category.label}: ${category.question} ---\n\n`);
174
- const members = layouts.filter(entry => entry.category === category.id);
175
- if (members.length === 0) {
176
- writeData(stdout, '(no matching layouts)\n\n');
177
- continue;
178
- }
179
- for (const { layout, description, deprecated } of members) {
180
- writeData(stdout, `- ${deprecated ? '[deprecated] ' : ''}${layout}: ${description}`);
181
- }
182
- writeData(stdout, '');
183
- }
184
- }
185
- /* c8 ignore start -- 非 Error 例外 (string throw 等) は本実装範囲では未発生、防御網のみ */
186
- function formatError(error) {
187
- return error instanceof Error ? error.message : String(error);
188
- }
189
- /* c8 ignore stop */
190
- /**
191
154
  失敗の reason。テーマの取得・宣言・指定の失敗は `theme-<reason>`(`themeErrorReason`)にする。
192
155
  */
193
156
  export function errorToReason(error) {
@@ -197,97 +160,10 @@ export function errorToReason(error) {
197
160
  return error.reason;
198
161
  return themeErrorReason(error) ?? 'unknown';
199
162
  }
200
- /**
201
- 失敗時の exit code。usage error(引数の誤り、テーマの指定の誤り)= 2、それ以外の実行失敗 = 1。
202
- */
203
- export function toExitCode(error) {
204
- return error instanceof SlideCreateUsageError || error instanceof ThemeSpecError ? 2 : 1;
205
- }
206
- function doesArgvWantJson(argv) {
207
- return argv.includes('--json');
208
- }
209
- export function createSlideCreateCommand(buildDependencies) {
210
- const command = new Command('create')
211
- .description('create a Slidev presentation that references a theme')
212
- .argument('<project-dir>', 'destination directory')
213
- .requiredOption('--theme <spec>', 'theme spec (git+https://<host>/<owner>/<repo>.git#<tag> or file:<path>)')
214
- .option('--force', 'overwrite an existing directory', false)
215
- .option('--json', 'print machine-readable JSON to stdout', false)
216
- .exitOverride()
217
- .configureOutput({
218
- writeErr: (string_) => {
219
- const dependencies = buildDependencies();
220
- if (doesArgvWantJson(process.argv)) {
221
- writeData(dependencies.stdout, JSON.stringify({
222
- event: 'slide.create.error',
223
- reason: 'invalid-option',
224
- detail: string_.replace(/^error:[ \t]*/i, '').trim(),
225
- }));
226
- }
227
- else {
228
- passthrough(dependencies.stderr, string_);
229
- }
230
- },
231
- })
232
- .action(async (projectDirectory, raw) => {
233
- const dependencies = buildDependencies();
234
- const isWantsJson = raw['json'] === true;
235
- const options = {
236
- theme: requireString(raw, 'theme'),
237
- force: raw['force'] === true,
238
- emitCatalog: !isWantsJson,
239
- };
240
- try {
241
- const execution = await executeSlideCreate(projectDirectory, options, dependencies, (summary) => {
242
- if (isWantsJson)
243
- return;
244
- writeData(dependencies.stdout, `slide create: success (${summary.projectDirectory})`);
245
- writeData(dependencies.stdout, ` theme=${summary.theme.name}, ${String(Math.round(summary.durationMs))}ms`);
246
- });
247
- if (isWantsJson) {
248
- writeData(dependencies.stdout, JSON.stringify(execution.data));
249
- }
250
- else {
251
- writeAutoDeckLintReport(execution.lint, execution.summary.projectDirectory, dependencies);
252
- }
253
- }
254
- catch (error) {
255
- const reason = errorToReason(error);
256
- const detail = formatError(error);
257
- if (isWantsJson) {
258
- writeData(dependencies.stdout, JSON.stringify({
259
- event: 'slide.create.error',
260
- reason,
261
- detail,
262
- }));
263
- }
264
- else {
265
- createDiagnostics(dependencies.stderr).error(`slide create failed: ${detail}`);
266
- }
267
- process.exitCode = toExitCode(error);
268
- }
269
- });
270
- return command;
271
- }
272
- function requireString(raw, key) {
273
- // eslint-disable-next-line security/detect-object-injection -- key は本ファイル内固定文字列
274
- const value = raw[key];
275
- /* c8 ignore next 3 -- commander の requiredOption で必ず string が入るため到達不能 */
276
- if (typeof value !== 'string') {
277
- throw new SlideCreateUsageError(`option --${key} is required`, 'missing-option');
278
- }
279
- return value;
280
- }
281
163
  export function slideCreateDefaultDependencies() {
282
- const pluginRoot = process.env['CLAUDE_PLUGIN_ROOT'];
283
- /* c8 ignore next 3 -- bin/pecotv が CLAUDE_PLUGIN_ROOT を必ず export するため未設定ルートは実運用で発生しない */
284
- if (pluginRoot === undefined || pluginRoot === '') {
285
- throw new SlideCreateRuntimeError('CLAUDE_PLUGIN_ROOT is not set', 'unknown');
286
- }
287
- const dependencyRoot = pluginDependencyRoot();
288
164
  return {
289
- pluginRoot,
290
- ...(dependencyRoot !== undefined && { dependencyRoot }),
165
+ pluginRoot: resolvePluginRoot(),
166
+ dependencyRoot: pluginDependencyRoot(),
291
167
  stdout: process.stdout,
292
168
  stderr: process.stderr,
293
169
  now: () => performance.now(),
@@ -53,7 +53,7 @@ export interface EnsureThemeLinkedResult {
53
53
  export interface EnsureThemeLinkedOptions {
54
54
  /**
55
55
  テーマを参照しない talk-dir を、`theme-none` で止めるか。
56
- dev・convert は止める(移行前の形は描画しない)。`sync --node-modules-only` は止めず、テーマ無しで張り直す。
56
+ dev・convert は止める(移行前の形は描画しない)。`node_modules_only` の sync は止めず、テーマ無しで張り直す。
57
57
  */
58
58
  readonly requireTheme?: boolean;
59
59
  }
@@ -1,6 +1,6 @@
1
1
  // talk-dir の node_modules にテーマが今の値で張られているかを確かめ、違えば張り直す。
2
2
  // あわせて、本体の生成ファイル(`vite.config.ts`・`start.mjs`)を本体の今の内容にそろえる。
3
- // dev・convert・`sync --node-modules-only` と、移行済みの talk-dir の通常の `sync` が呼ぶ。
3
+ // dev・convert・`node_modules_only` の sync と、移行済みの talk-dir の通常の sync が呼ぶ。
4
4
  //
5
5
  // 順は次のとおり。
6
6
  // `package.json` の spec を読み、`fetchTheme` を通してから、生成ファイルをそろえる。
@@ -47,7 +47,7 @@ async function unmanagedTheme(talkDirectory, files, options) {
47
47
  catch (error) {
48
48
  // ここへ来た時点で theme: は依存を指しているので、起こりうるのは theme-unlinked だけ。
49
49
  // dev・convert はそのまま Slidev を起こすと一般の起動失敗になり、案内が出ない。案内つきで止める。
50
- // sync の --node-modules-only は止めず、テーマ無しで張り直す。
50
+ // sync の node_modules_only は止めず、テーマ無しで張り直す。
51
51
  if (error instanceof ThemeResolveError && options.requireTheme !== true) {
52
52
  return { relinked: false, regenerated: false, theme: undefined, nodeModulesTarget: undefined };
53
53
  }
@@ -1,20 +1,13 @@
1
1
  import type { FailureReason } from '../../domain/_shared/failure-kind.js';
2
- import { Command } from 'commander';
3
2
  import type { EslintRunner, SlideLintSummary } from '../../domain/slidev-project/lint.js';
4
3
  export interface SlideLintOptions {
5
4
  readonly dir: string;
6
5
  }
7
6
  export interface SlideLintDependencies {
8
7
  /**
9
- 同梱アセットの起点。CLAUDE_PLUGIN_ROOT。
8
+ 同梱アセットの起点(resolvePluginRoot)。
10
9
  */
11
10
  readonly pluginRoot: string;
12
- /**
13
- lint 用の設定(deck-lint.env.config.js)・eslint 本体・ルールの dist を取る実行用ミラー。
14
- PECOTV_RUNTIME_DIR(実行中の cli と同じ版のミラー)。省略時は pluginRoot(開発・テスト)。
15
- `runtime/current` は別セッションが切り替えた新版を指すので使わない。
16
- */
17
- readonly runtimeDirectory?: string;
18
11
  readonly stdout: NodeJS.WritableStream;
19
12
  readonly stderr: NodeJS.WritableStream;
20
13
  /**
@@ -24,28 +17,16 @@ export interface SlideLintDependencies {
24
17
  readonly eslint?: EslintRunner;
25
18
  }
26
19
  export type SlideLintResultSummary = SlideLintSummary;
27
- /**
28
- commander コマンドファクトリ。コマンド名は `lint`、`slide` グループ配下に登録する想定。
29
-
30
- 受け付ける options:
31
- - `--dir <path>` (必須): talk-dir 絶対パス
32
- - `--json`: machine-readable な JSON を stdout に出す
33
-
34
- exit code: 違反あり = 1 / 実行失敗 = 1 / usage error = 2(commander 専用)。
35
- eslint 自身の exit 2(設定エラー)は domain で `SlideLintRuntimeError` に変換済みで、
36
- ここで 2 に化けることはない。
37
- */
38
- export declare function createSlideLintCommand(buildDependencies: () => SlideLintDependencies): Command;
39
20
  export interface SlideLintExecution {
40
21
  readonly summary: SlideLintResultSummary;
41
22
  /**
42
- `--json` の payload。MCP ツールの構造化データもこれをそのまま返す。
23
+ ツールの構造化データに載せる payload。
43
24
  event 名は outcome で変わる(違反ありは `slide.lint.violations`)。
44
25
  */
45
26
  readonly data: Readonly<Record<string, unknown>>;
46
27
  }
47
28
  /**
48
- `slide lint` の実処理と機械可読な結果組み立て。CLI action と MCP ツールの双方がここを通る。
29
+ slide_lint の実処理と機械可読な結果組み立て。MCP ツールがここを通る。
49
30
  */
50
31
  export declare function executeSlideLint(options: Readonly<SlideLintOptions>, dependencies: SlideLintDependencies): Promise<SlideLintExecution>;
51
32
  export interface AutoDeckLintReport {
@@ -59,31 +40,21 @@ export interface AutoDeckLintReport {
59
40
  readonly failure: string | undefined;
60
41
  }
61
42
  /**
62
- `slide create` / `slide sync` 末尾で実行するデッキ全体 lint。
43
+ slide_create / slide_sync 末尾で実行するデッキ全体 lint。
63
44
 
64
- 違反と実行失敗は、呼び出し元の exit code に影響させない。
45
+ 違反と実行失敗は、呼び出し元の成否に影響させない。
65
46
  そのため例外は投げず、`AutoDeckLintReport` に畳んで返す。
66
47
  */
67
48
  export declare function runAutoDeckLint(talkDirectory: string, dependencies: SlideLintDependencies): Promise<AutoDeckLintReport>;
68
49
  /**
69
- `runAutoDeckLint` の結果を人間向けに書き出す。違反は一覧表示のみで、呼び出し元の
70
- 成否には影響しない旨と再確認コマンドを添える。
71
- */
72
- export declare function writeAutoDeckLintReport(report: Readonly<AutoDeckLintReport>, talkDirectory: string, dependencies: SlideLintDependencies): void;
73
- /**
74
- `--json` 出力の `slide.create.done` / `slide.sync.done` に載せる lint 要約フィールド。
50
+ `slide.create.done` / `slide.sync.done` の data に載せる lint 要約フィールド。
75
51
  */
76
52
  export declare function autoDeckLintJsonField(report: Readonly<AutoDeckLintReport>): Readonly<Record<string, unknown>>;
77
53
  export declare function errorToReason(error: unknown): FailureReason;
78
- export declare function isUsageError(error: unknown): boolean;
79
- /**
80
- 失敗時の exit code。usage error = 2、それ以外の実行失敗 = 1(違反ありの 1 は成功ルート)。
81
- */
82
- export declare function toExitCode(error: unknown): number;
83
54
  export declare function slideLintDefaultDependencies(): SlideLintDependencies;
84
55
  /**
85
- テスト用の薄いファサード。commander を介さず domain `runSlideLint` を
56
+ テスト用の薄いファサード。domain `runSlideLint` を
86
57
  production と同じ infra 組み立てで呼ぶための shortcut。
87
58
  */
88
- export declare function runSlideLintFromCli(directory: string, dependencies: SlideLintDependencies): Promise<SlideLintResultSummary>;
59
+ export declare function runSlideLintDirectly(directory: string, dependencies: SlideLintDependencies): Promise<SlideLintResultSummary>;
89
60
  //# sourceMappingURL=lint.d.ts.map
@@ -1,95 +1,23 @@
1
- // `pecotv slide lint` コマンドのファサード。既存 talk-dir 全体(`pages/**/*.md` +
1
+ // slide_lint ツールのファサード。既存 talk-dir 全体(`pages/**/*.md` +
2
2
  // `slides.md`)を、本体の assets/slidev の eslint で lint する。
3
- // 規則と寸法は、talk-dir が参照するテーマの宣言を `slide theme` と同じ手順で解釈した結果を使う。
3
+ // 規則と寸法は、talk-dir が参照するテーマの宣言を slide_theme と同じ手順で解釈した結果を使う。
4
4
  //
5
- // commander DI / exitOverride / configureOutput.writeErr / 二段例外型は
6
- // slidev-project/sync.ts のパターンを忠実に踏襲する。実体ロジックは
5
+ // DI と二段例外型は slidev-project/sync.ts のパターンを踏襲する。実体ロジックは
7
6
  // domain/slidev-project/lint.ts、eslint 起動は infra/slidev-project/eslint-runner.ts。
8
7
  //
9
- // 本ファイルは、`slide create` / `slide sync` 末尾の自動 lint の供給元も兼ねる。
10
- // 対象は `runAutoDeckLint` と `writeAutoDeckLintReport`。
8
+ // 本ファイルは、`slide_create` / `slide_sync` 末尾の自動 lint の供給元も兼ねる。
9
+ // 対象は `runAutoDeckLint` と `autoDeckLintJsonField`。
11
10
  import path from 'node:path';
12
- import { Command } from 'commander';
13
- import { createDiagnostics, passthrough, writeData } from '../../diagnostics.js';
14
11
  import { SlideLintRuntimeError, SlideLintUsageError, runSlideLint, } from '../../domain/slidev-project/lint.js';
15
12
  import { SlideCreateRuntimeError, SlideCreateUsageError, } from '../../domain/slidev-project/errors.js';
16
13
  import { themeErrorReason } from '../../domain/slidev-theme/error-reason.js';
17
- import { runningMirrorDirectory } from '../../infra/_shared/dependency-root.js';
14
+ import { resolvePluginRoot } from '../../infra/_shared/plugin-root.js';
18
15
  import { ChildProcessEslintRunner } from '../../infra/slidev-project/eslint-runner.js';
19
16
  import { listSkippedSymlinkPageDirectories, hasSlidesMd, talkDirectoryExists, } from '../../infra/slidev-project/fs.js';
20
17
  import { NodeThemeFiles } from '../../infra/slidev-theme/fs.js';
21
18
  import { executeSlideTheme } from './theme.js';
22
19
  /**
23
- commander コマンドファクトリ。コマンド名は `lint`、`slide` グループ配下に登録する想定。
24
-
25
- 受け付ける options:
26
- - `--dir <path>` (必須): talk-dir 絶対パス
27
- - `--json`: machine-readable な JSON を stdout に出す
28
-
29
- exit code: 違反あり = 1 / 実行失敗 = 1 / usage error = 2(commander 専用)。
30
- eslint 自身の exit 2(設定エラー)は domain で `SlideLintRuntimeError` に変換済みで、
31
- ここで 2 に化けることはない。
32
- */
33
- export function createSlideLintCommand(buildDependencies) {
34
- const command = new Command('lint')
35
- .description('lint the whole talk-dir (pages/**/*.md and slides.md)')
36
- .requiredOption('--dir <path>', 'absolute path of the talk-dir to lint')
37
- .option('--json', 'print machine-readable JSON to stdout', false)
38
- .exitOverride()
39
- .configureOutput({
40
- writeErr: (string_) => {
41
- const dependencies = buildDependencies();
42
- if (doesArgvWantJson(process.argv)) {
43
- writeData(dependencies.stdout, JSON.stringify({
44
- event: 'slide.lint.error',
45
- reason: 'invalid-option',
46
- detail: string_.replace(/^error:[ \t]*/i, '').trim(),
47
- }));
48
- }
49
- else {
50
- passthrough(dependencies.stderr, string_);
51
- }
52
- },
53
- })
54
- .action(async (raw) => {
55
- const dependencies = buildDependencies();
56
- const isWantsJson = raw['json'] === true;
57
- const options = { dir: requireString(raw, 'dir') };
58
- try {
59
- const { summary, data } = await executeSlideLint(options, dependencies);
60
- if (isWantsJson) {
61
- writeData(dependencies.stdout, JSON.stringify(data));
62
- }
63
- else {
64
- // 件数行を読まずに成否が分かるよう見出し行に結果を載せる(no-target は exit 0 側)。
65
- const outcomeLabel = summary.outcome === 'violations' ? 'violations' : 'success';
66
- writeData(dependencies.stdout, `slide lint: ${outcomeLabel} (${summary.directory})`);
67
- writeSummaryLines(summary, dependencies);
68
- }
69
- if (summary.outcome === 'violations') {
70
- process.exitCode = 1;
71
- }
72
- }
73
- catch (error) {
74
- const reason = errorToReason(error);
75
- const detail = formatError(error);
76
- if (isWantsJson) {
77
- writeData(dependencies.stdout, JSON.stringify({
78
- event: 'slide.lint.error',
79
- reason,
80
- detail,
81
- }));
82
- }
83
- else {
84
- createDiagnostics(dependencies.stderr).error(`slide lint failed: ${detail}`);
85
- }
86
- process.exitCode = toExitCode(error);
87
- }
88
- });
89
- return command;
90
- }
91
- /**
92
- `slide lint` の実処理と機械可読な結果組み立て。CLI action と MCP ツールの双方がここを通る。
20
+ slide_lint の実処理と機械可読な結果組み立て。MCP ツールがここを通る。
93
21
  */
94
22
  export async function executeSlideLint(options,
95
23
  // DI 経由の write は mutate メソッド。
@@ -114,8 +42,7 @@ async function runActionLint(directory,
114
42
  // DI 経由の write は mutate メソッド。
115
43
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
116
44
  dependencies) {
117
- const root = dependencies.runtimeDirectory ?? dependencies.pluginRoot;
118
- const assetsDirectory = path.join(root, 'assets', 'slidev');
45
+ const assetsDirectory = path.join(dependencies.pluginRoot, 'assets', 'slidev');
119
46
  return await runSlideLint({ directory }, {
120
47
  assetsDirectory,
121
48
  deckLintConfig: path.join(assetsDirectory, 'deck-lint.env.config.js'),
@@ -128,34 +55,9 @@ dependencies) {
128
55
  });
129
56
  }
130
57
  /**
131
- 人間向けの集計 + 違反一覧を書き出す。`slide lint` 単体と create / sync の自動 lint で
132
- 同じ体裁にするため共有する。
133
- */
134
- function writeSummaryLines(summary,
135
- // DI 経由の write は mutate メソッド。
136
- // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
137
- dependencies) {
138
- // 走査抜けの警告は lint 対象 0 件でも出す必要があるため no-target の早期 return より前に置く。
139
- const diagnostics = createDiagnostics(dependencies.stderr);
140
- for (const skipped of summary.skippedSymlinkDirectories) {
141
- diagnostics.warning(`${skipped} is a symlink and is not scanned by eslint`
142
- + ' (files under it may not be linted)');
143
- }
144
- if (summary.outcome === 'no-target') {
145
- writeData(dependencies.stdout, ` linted 0 files (no pages/**/*.md or slides.md found)`);
146
- return;
147
- }
148
- writeData(dependencies.stdout, ` linted ${String(summary.lintedFileCount)} files / ${String(summary.errorCount)} errors`
149
- + ` / ${String(summary.warningCount)} warnings`);
150
- for (const violation of summary.violations) {
151
- writeData(dependencies.stdout, ` ${violation.file}:${String(violation.line)}:${String(violation.column)}`
152
- + ` ${violation.rule} ${violation.message}`);
153
- }
154
- }
155
- /**
156
- `slide create` / `slide sync` 末尾で実行するデッキ全体 lint。
58
+ slide_create / slide_sync 末尾で実行するデッキ全体 lint。
157
59
 
158
- 違反と実行失敗は、呼び出し元の exit code に影響させない。
60
+ 違反と実行失敗は、呼び出し元の成否に影響させない。
159
61
  そのため例外は投げず、`AutoDeckLintReport` に畳んで返す。
160
62
  */
161
63
  export async function runAutoDeckLint(talkDirectory,
@@ -170,26 +72,7 @@ dependencies) {
170
72
  }
171
73
  }
172
74
  /**
173
- `runAutoDeckLint` の結果を人間向けに書き出す。違反は一覧表示のみで、呼び出し元の
174
- 成否には影響しない旨と再確認コマンドを添える。
175
- */
176
- export function writeAutoDeckLintReport(report, talkDirectory,
177
- // DI 経由の write は mutate メソッド。
178
- // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
179
- dependencies) {
180
- const { summary } = report;
181
- if (summary === undefined) {
182
- createDiagnostics(dependencies.stderr).warning(`deck lint skipped: ${report.failure ?? ''}`);
183
- return;
184
- }
185
- writeData(dependencies.stdout, 'deck lint:');
186
- writeSummaryLines(summary, dependencies);
187
- if (summary.outcome === 'violations') {
188
- writeData(dependencies.stdout, ` the violations above do not affect this command's result; after fixing, run pecotv slide lint --dir ${talkDirectory} to recheck`);
189
- }
190
- }
191
- /**
192
- `--json` 出力の `slide.create.done` / `slide.sync.done` に載せる lint 要約フィールド。
75
+ `slide.create.done` / `slide.sync.done` の data に載せる lint 要約フィールド。
193
76
  */
194
77
  export function autoDeckLintJsonField(report) {
195
78
  const { summary } = report;
@@ -209,7 +92,7 @@ export function autoDeckLintJsonField(report) {
209
92
  export function errorToReason(error) {
210
93
  if (error instanceof SlideLintUsageError)
211
94
  return error.reason;
212
- // テーマの解決・宣言・取得の失敗は `theme-<reason>` の形で載せる(slide theme と同じ)
95
+ // テーマの解決・宣言・取得の失敗は `theme-<reason>` の形で載せる(slide_theme と同じ)
213
96
  const themeReason = themeErrorReason(error);
214
97
  if (themeReason !== undefined)
215
98
  return themeReason;
@@ -217,7 +100,7 @@ export function errorToReason(error) {
217
100
  return error.reason;
218
101
  // infra/slidev-project/fs.ts は SlideCreate{Runtime,Usage}Error を投げる。
219
102
  // assertTalkDirectory のルートで、talkDirectoryExists / doesSlidesMdExist が EACCES 等を受けた場合。
220
- // SlideCreateRuntimeError を投げ、そのまま CLI に届く。
103
+ // SlideCreateRuntimeError を投げ、そのまま呼び出し元に届く。
221
104
  // ENOENT のルートは SlideLintRuntimeError に変換される。
222
105
  if (error instanceof SlideCreateRuntimeError)
223
106
  return error.reason;
@@ -228,51 +111,23 @@ export function errorToReason(error) {
228
111
  return 'unknown';
229
112
  /* c8 ignore stop */
230
113
  }
231
- export function isUsageError(error) {
232
- return error instanceof SlideLintUsageError || error instanceof SlideCreateUsageError;
233
- }
234
- /**
235
- 失敗時の exit code。usage error = 2、それ以外の実行失敗 = 1(違反ありの 1 は成功ルート)。
236
- */
237
- export function toExitCode(error) {
238
- return isUsageError(error) ? 2 : 1;
239
- }
240
114
  /* c8 ignore start -- 非 Error 例外 (string throw 等) は本実装範囲では未発生、防御網のみ */
241
115
  function formatError(error) {
242
116
  return error instanceof Error ? error.message : String(error);
243
117
  }
244
118
  /* c8 ignore stop */
245
- function doesArgvWantJson(argv) {
246
- return argv.includes('--json');
247
- }
248
- function requireString(raw, key) {
249
- // eslint-disable-next-line security/detect-object-injection -- key は本ファイル内固定文字列
250
- const value = raw[key];
251
- /* c8 ignore next 3 -- commander の requiredOption で必ず string が入るため到達不能 */
252
- if (typeof value !== 'string') {
253
- throw new SlideLintUsageError(`option --${key} is required`, 'missing-option');
254
- }
255
- return value;
256
- }
257
119
  export function slideLintDefaultDependencies() {
258
- const pluginRoot = process.env['CLAUDE_PLUGIN_ROOT'];
259
- /* c8 ignore next 3 -- bin/pecotv が CLAUDE_PLUGIN_ROOT を必ず export するため未設定ルートは実運用で発生しない */
260
- if (pluginRoot === undefined || pluginRoot === '') {
261
- throw new SlideLintRuntimeError('CLAUDE_PLUGIN_ROOT is not set', 'unknown');
262
- }
263
- const runtimeDirectory = runningMirrorDirectory();
264
120
  return {
265
- pluginRoot,
266
- ...(runtimeDirectory !== undefined && { runtimeDirectory }),
121
+ pluginRoot: resolvePluginRoot(),
267
122
  stdout: process.stdout,
268
123
  stderr: process.stderr,
269
124
  };
270
125
  }
271
126
  /**
272
- テスト用の薄いファサード。commander を介さず domain `runSlideLint` を
127
+ テスト用の薄いファサード。domain `runSlideLint` を
273
128
  production と同じ infra 組み立てで呼ぶための shortcut。
274
129
  */
275
- export async function runSlideLintFromCli(directory,
130
+ export async function runSlideLintDirectly(directory,
276
131
  // DI 経由の write は mutate メソッド。
277
132
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
278
133
  dependencies) {
@@ -1,5 +1,4 @@
1
1
  import type { FailureReason } from '../../domain/_shared/failure-kind.js';
2
- import { Command } from 'commander';
3
2
  import type { ThemeFiles } from '../../domain/slidev-theme/ports.js';
4
3
  import { fetchTheme } from '../../infra/slidev-theme/store.js';
5
4
  import type { AutoDeckLintReport } from './lint.js';
@@ -16,7 +15,7 @@ export interface SlideSyncOptions {
16
15
  }
17
16
  export interface SlideSyncDependencies {
18
17
  /**
19
- 同梱アセットの起点。CLAUDE_PLUGIN_ROOT。
18
+ 同梱アセットの起点(resolvePluginRoot)。
20
19
  */
21
20
  readonly pluginRoot: string;
22
21
  /**
@@ -26,7 +25,7 @@ export interface SlideSyncDependencies {
26
25
  readonly stdout: NodeJS.WritableStream;
27
26
  readonly stderr: NodeJS.WritableStream;
28
27
  /**
29
- `--node-modules-only` と、移行済みの talk-dir の通常の sync が、テーマの取得と張り直しを任せる port。
28
+ `nodeModulesOnly` と、移行済みの talk-dir の通常の sync が、テーマの取得と張り直しを任せる port。
30
29
  省略時は実装(git・pnpm・実ファイル)。
31
30
  */
32
31
  readonly ensureThemeLinked?: EnsureThemeLinkedPort;
@@ -48,43 +47,25 @@ export interface SlideSyncDependencies {
48
47
  readonly currentDirectory?: string;
49
48
  }
50
49
  export type SlideSyncResultSummary = SlideSyncSummary;
51
- /**
52
- commander コマンドファクトリ。コマンド名は `sync`、`slide` グループ配下に登録する想定。
53
-
54
- 受け付ける options を次に示す。
55
- - `--dir <path>` (必須): talk-dir 絶対パス。
56
- - `--theme <spec>`: 移行前の talk-dir を、このテーマを参照する形へ移す。
57
- - `--node-modules-only`: node_modules の張り直しのみ実行。
58
- - `--json`: machine-readable な JSON を stdout に出す。
59
- */
60
- export declare function createSlideSyncCommand(buildDependencies: () => SlideSyncDependencies): Command;
61
50
  export interface SlideSyncExecution {
62
51
  readonly summary: SlideSyncResultSummary;
63
52
  readonly lint: AutoDeckLintReport;
64
53
  /**
65
- `--json` の `slide.sync.done` payload。MCP ツールの構造化データもこれをそのまま返す。
54
+ `slide.sync.done` の payload。MCP ツールの構造化データもこれをそのまま返す。
66
55
  */
67
56
  readonly data: Readonly<Record<string, unknown>>;
68
57
  }
69
58
  /**
70
- `slide sync` の実処理と機械可読な結果組み立て。CLI action と MCP ツールの双方がここを通る。
71
-
72
- @param onSynced 同期完了時点(deck lint より前)に呼ばれる。CLI は人間向けの成否行を
73
- ここで書き、違反一覧より先に出す。MCP ツールは渡さない。
59
+ slide_sync の実処理と機械可読な結果組み立て。MCP ツールがここを通る。
74
60
  */
75
- export declare function executeSlideSync(options: Readonly<SlideSyncOptions>, dependencies: SlideSyncDependencies, onSynced?: (summary: Readonly<SlideSyncResultSummary>) => void): Promise<SlideSyncExecution>;
61
+ export declare function executeSlideSync(options: Readonly<SlideSyncOptions>, dependencies: SlideSyncDependencies): Promise<SlideSyncExecution>;
76
62
  export declare function errorToReason(error: unknown): FailureReason;
77
- export declare function isUsageError(error: unknown): boolean;
78
- /**
79
- 失敗時の exit code。usage error = 2、それ以外の実行失敗 = 1。
80
- */
81
- export declare function toExitCode(error: unknown): number;
82
63
  export declare function slideSyncDefaultDependencies(): SlideSyncDependencies;
83
64
  /**
84
- commander を介さず同期本体だけを呼ぶ shortcut。deck lint を伴わないため、
65
+ 同期本体だけを呼ぶ shortcut。deck lint を伴わないため、
85
66
  同期そのものの結果を観測したいテストが使う(本番ルートは `executeSlideSync`)。
86
67
  */
87
- export declare function runSlideSyncFromCli(directory: string, options: Readonly<{
68
+ export declare function runSlideSyncDirectly(directory: string, options: Readonly<{
88
69
  nodeModulesOnly: boolean;
89
70
  theme?: string | undefined;
90
71
  }>, dependencies: SlideSyncDependencies): Promise<SlideSyncResultSummary>;