@pecot/visual-mcp 1.0.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 (60) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/assets/slidev/package.json +19 -12
  3. package/assets/slidev/runtime/package.json +24 -15
  4. package/assets/slidev/scripts/eslint/_shared/dist/lib/drawio-geometry.js +19 -1
  5. package/assets/slidev/scripts/eslint/_shared/dist/tsconfig.tsbuildinfo +1 -1
  6. package/assets/slidev/scripts/eslint/_shared/lib/drawio-geometry.ts +18 -1
  7. package/assets/slidev/scripts/eslint/_shared/package.json +12 -3
  8. package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/tsconfig.tsbuildinfo +1 -1
  9. package/assets/slidev/scripts/eslint/slidev-pages-lint/package.json +13 -4
  10. package/assets/slidev/scripts/eslint/text-constraints/dist/tsconfig.tsbuildinfo +1 -1
  11. package/assets/slidev/scripts/eslint/text-constraints/package.json +13 -4
  12. package/assets/slidev/scripts/eslint/validate-references/dist/lib/schema-validator.js +1 -1
  13. package/assets/slidev/scripts/eslint/validate-references/dist/tsconfig.tsbuildinfo +1 -1
  14. package/assets/slidev/scripts/eslint/validate-references/lib/schema-validator.ts +2 -2
  15. package/assets/slidev/scripts/eslint/validate-references/package.json +13 -4
  16. package/cli/dist/cli.js +3 -2
  17. package/cli/dist/commands/chromium/host-dependencies.js +12 -5
  18. package/cli/dist/commands/drawio/export.js +14 -11
  19. package/cli/dist/commands/drawio/theme.js +1 -1
  20. package/cli/dist/commands/drawio/url.js +27 -19
  21. package/cli/dist/commands/evidence-xlsx/create.js +11 -10
  22. package/cli/dist/commands/pptx-ooxml/preview.js +13 -17
  23. package/cli/dist/commands/slidev-project/create.js +19 -18
  24. package/cli/dist/commands/slidev-project/lint.js +24 -22
  25. package/cli/dist/commands/slidev-project/sync.js +25 -24
  26. package/cli/dist/commands/slidev-project/theme.js +14 -13
  27. package/cli/dist/commands/slidev-to-pptx/convert.d.ts +4 -0
  28. package/cli/dist/commands/slidev-to-pptx/convert.js +45 -32
  29. package/cli/dist/diagnostics.d.ts +38 -0
  30. package/cli/dist/diagnostics.js +46 -0
  31. package/cli/dist/domain/_shared/ports.d.ts +0 -1
  32. package/cli/dist/domain/drawio/url.d.ts +11 -7
  33. package/cli/dist/domain/drawio/url.js +47 -25
  34. package/cli/dist/domain/pptx-ooxml/prerender-replace.d.ts +1 -0
  35. package/cli/dist/domain/pptx-ooxml/prerender-replace.js +3 -3
  36. package/cli/dist/domain/slidev-project/generated-files.js +3 -3
  37. package/cli/dist/infra/_shared/dependency-root.js +63 -3
  38. package/cli/dist/infra/_shared/pnpm.d.ts +6 -1
  39. package/cli/dist/infra/_shared/pnpm.js +10 -3
  40. package/cli/dist/infra/_shared/runtime-install.d.ts +12 -84
  41. package/cli/dist/infra/_shared/runtime-install.js +72 -107
  42. package/cli/dist/infra/slidev-theme/store.js +5 -4
  43. package/cli/dist/infra/slidev-to-pptx/console-logger.d.ts +5 -5
  44. package/cli/dist/infra/slidev-to-pptx/console-logger.js +19 -20
  45. package/cli/dist/infra/slidev-to-pptx/dom-converter.d.ts +1 -1
  46. package/cli/dist/infra/slidev-to-pptx/dom-converter.js +1 -1
  47. package/cli/dist/infra/slidev-to-pptx/index.js +1 -9
  48. package/cli/dist/infra/slidev-to-pptx/pipeline.d.ts +1 -1
  49. package/cli/dist/infra/slidev-to-pptx/pipeline.js +4 -4
  50. package/cli/dist/infra/slidev-to-pptx/server.d.ts +4 -2
  51. package/cli/dist/infra/slidev-to-pptx/server.js +15 -6
  52. package/cli/dist/infra/slidev-to-pptx/single-pass-worker.d.ts +1 -1
  53. package/cli/dist/mcp/serve.js +5 -3
  54. package/cli/dist/mcp/tools/_shared.js +11 -1
  55. package/cli/dist/mcp/tools/drawio.js +2 -1
  56. package/cli/dist/mcp/tools/slide-page.js +3 -1
  57. package/cli/dist/mcp/tools/slide.js +3 -1
  58. package/npm-shrinkwrap.json +86 -83
  59. package/package.json +5 -5
  60. package/vendor/text-rules/dist/source-hash +1 -1
@@ -77,21 +77,34 @@ function elementsByTagName(document, tagName) {
77
77
  function attributeValue(element, name) {
78
78
  return element.getAttribute(name) ?? undefined;
79
79
  }
80
+ // 消した跡の前後がつながって新しいコメントになる入力があるため、変化しなくなるまで繰り返す。
80
81
  export function stripComments(xml) {
81
- return xml.replaceAll(XML_COMMENT_REGEX, '');
82
+ let current = xml;
83
+ let previous;
84
+ do {
85
+ previous = current;
86
+ current = current.replaceAll(XML_COMMENT_REGEX, '');
87
+ } while (current !== previous);
88
+ return current;
82
89
  }
83
90
  /**
84
- mxCell の value 属性内 HTML を確認し、警告メッセージ配列を返す。
91
+ mxCell の value 属性内 HTML を確認し、診断の配列を返す。
85
92
  Python 版の `_validate_html` と同等の検出ルールは次の 3 つ。
86
93
  1. `<font>` の属性が face/size/color/style 以外 → warn。
87
94
  2. value 内 HTML でシングルクォート属性値を使用 → warn。
88
- 3. `<font color>` と mxCell style の fontColor が同一値で二重指定 → info。
95
+ 3. `<font color>` と mxCell style の fontColor が同一値で二重指定 → note。
89
96
  */
90
97
  export function validateHtml(xml) {
91
- const warnings = [];
98
+ const findings = [];
99
+ const warn = (message) => {
100
+ findings.push({ severity: 'warning', message });
101
+ };
102
+ const note = (message) => {
103
+ findings.push({ severity: 'note', message });
104
+ };
92
105
  const document = parseDrawioXml(xml);
93
106
  if (document === undefined)
94
- return warnings;
107
+ return findings;
95
108
  for (const cell of elementsByTagName(document, 'mxCell')) {
96
109
  const rawValue = attributeValue(cell, 'value');
97
110
  if (rawValue === undefined || rawValue === '' || !rawValue.includes('<'))
@@ -100,7 +113,7 @@ export function validateHtml(xml) {
100
113
  const styleAttribute = attributeValue(cell, 'style') ?? '';
101
114
  // ルール2: シングルクォート属性値検出(生 XML 値で確認)
102
115
  for (const sq of rawValue.matchAll(SINGLE_QUOTE_ATTR_REGEX)) {
103
- warnings.push(`[warn] mxCell id=${cellId}: シングルクォート属性値を検出 — ${sq[0]}。&quot; によるダブルクォートを使用してください`);
116
+ warn(`mxCell id=${cellId}: シングルクォート属性値を検出 — ${sq[0]}。&quot; によるダブルクォートを使用してください`);
104
117
  }
105
118
  // xmldom の getAttribute() は既に entity デコード済 string を返すため、
106
119
  // Python `html.unescape` 相当の二重デコードは不要。
@@ -115,7 +128,7 @@ export function validateHtml(xml) {
115
128
  if (FONT_ALLOWED_ATTRS.has(attributeName))
116
129
  continue;
117
130
  const sortedAllowed = [...FONT_ALLOWED_ATTRS].toSorted((a, b) => a.localeCompare(b)).join(', ');
118
- warnings.push(`[warn] mxCell id=${cellId}: <font> の非対応属性 '${attributeName}' を検出。対応属性: ${sortedAllowed}`);
131
+ warn(`mxCell id=${cellId}: <font> の非対応属性 '${attributeName}' を検出。対応属性: ${sortedAllowed}`);
119
132
  }
120
133
  }
121
134
  // ルール3: fontColor 二重指定検出
@@ -135,23 +148,26 @@ export function validateHtml(xml) {
135
148
  /* c8 ignore next -- FONT_COLOR_VALUE_REGEX は group(1) を必ずキャプチャする。空文字の右辺は到達不能 */
136
149
  const htmlColor = (colorMatch[1] ?? '').trim().toLowerCase();
137
150
  if (htmlColor === fontColorStyle) {
138
- warnings.push(`[info] mxCell id=${cellId}: <font color="${htmlColor}"> と style fontColor=${fontColorStyle} が同一値で二重指定されています`);
151
+ note(`mxCell id=${cellId}: <font color="${htmlColor}"> と style fontColor=${fontColorStyle} が同一値で二重指定されています`);
139
152
  }
140
153
  }
141
154
  }
142
155
  }
143
- return warnings;
156
+ return findings;
144
157
  }
145
158
  /**
146
159
  mxCell の style と value を確認し、警告メッセージ配列を返す。
147
160
  対象は、折り返し必須 (日本語/改行/<br>) なのに `whiteSpace=wrap` が style に無い、box 系 vertex。
148
- v-diagram-creator が stderr の [warn] を読んで該当 mxCell に追記できる粒度で、id を入れる。
161
+ v-diagram-creator が stderr の warning を読んで該当 mxCell に追記できる粒度で、id を入れる。
149
162
  */
150
163
  export function validateWhitespaceWrap(xml) {
151
- const warnings = [];
164
+ const findings = [];
165
+ const warn = (message) => {
166
+ findings.push({ severity: 'warning', message });
167
+ };
152
168
  const document = parseDrawioXml(xml);
153
169
  if (document === undefined)
154
- return warnings;
170
+ return findings;
155
171
  for (const cell of elementsByTagName(document, 'mxCell')) {
156
172
  if (attributeValue(cell, 'vertex') !== '1')
157
173
  continue;
@@ -174,9 +190,9 @@ export function validateWhitespaceWrap(xml) {
174
190
  .replaceAll('\r', String.raw `\r`)
175
191
  .replaceAll('\n', String.raw `\n`);
176
192
  const ellipsis = graphemes.length > 20 ? '…' : '';
177
- warnings.push(`[warn] mxCell id=${cellId}: 折り返しが必要な value (日本語/改行を含む) ですが style に whiteSpace=wrap がありません — value 先頭: "${preview}${ellipsis}"。style に whiteSpace=wrap を付けてください`);
193
+ warn(`mxCell id=${cellId}: 折り返しが必要な value (日本語/改行を含む) ですが style に whiteSpace=wrap がありません — value 先頭: "${preview}${ellipsis}"。style に whiteSpace=wrap を付けてください`);
178
194
  }
179
- return warnings;
195
+ return findings;
180
196
  }
181
197
  const JAPANESE_REGEX = /[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u;
182
198
  const BLANK_TEXT_REGEX = /^(?:\s|&nbsp;|&#160;)*$/i;
@@ -410,10 +426,13 @@ value の HTML(`<font face>`・`style="font-family:..."`・`style="font:..."`
410
426
  themeName は文言に書くテーマの名前。省くと「既定の書体」と書く。
411
427
  */
412
428
  export function validateSlideFonts(xml, fonts, themeName) {
413
- const warnings = [];
429
+ const findings = [];
430
+ const warn = (message) => {
431
+ findings.push({ severity: 'warning', message });
432
+ };
414
433
  const document = parseDrawioXml(xml);
415
434
  if (document === undefined)
416
- return warnings;
435
+ return findings;
417
436
  const eastAsian = fonts.eastAsian === undefined ? undefined : parseFontList(fonts.eastAsian)[0];
418
437
  const allowed = new Set([...fonts.body.flatMap(name => parseFontList(name)), ...(eastAsian === undefined ? [] : [eastAsian])]);
419
438
  const label = fontSourceLabel(themeName);
@@ -421,9 +440,9 @@ export function validateSlideFonts(xml, fonts, themeName) {
421
440
  for (const cell of textCells(document)) {
422
441
  const { runs: allRuns, unreadableShorthands } = walkText(cell.text, initialState(cell.style));
423
442
  const runs = allRuns.filter(run => !(run.font?.includes(MONOSPACE_FONT) ?? false));
424
- const prefix = `[warn] mxCell id=${cell.id}:`;
443
+ const prefix = `mxCell id=${cell.id}:`;
425
444
  for (const shorthand of unreadableShorthands) {
426
- warnings.push(`${prefix} font: ${shorthand} — ${SHORTHAND_WARNING}`);
445
+ warn(`${prefix} font: ${shorthand} — ${SHORTHAND_WARNING}`);
427
446
  }
428
447
  const offTheme = runs.find(run => run.font?.[0] === undefined || !allowed.has(run.font[0]));
429
448
  if (offTheme !== undefined) {
@@ -431,7 +450,7 @@ export function validateSlideFonts(xml, fonts, themeName) {
431
450
  const fix = offTheme.fontSource === 'html'
432
451
  ? `value 内の font-family 指定(<font face> や style の font-family)を消してください。書体はセルの style の fontFamily=${advice} に任せます`
433
452
  : `style に fontFamily=${advice} を付けてください`;
434
- warnings.push(`${prefix} ${actual}の文字列が${label}ではありません — "${offTheme.text}"。図の文字は${label}で組みます。${fix}`);
453
+ warn(`${prefix} ${actual}の文字列が${label}ではありません — "${offTheme.text}"。図の文字は${label}で組みます。${fix}`);
435
454
  }
436
455
  if (eastAsian === undefined || fonts.eastAsian === undefined)
437
456
  continue;
@@ -441,9 +460,9 @@ export function validateSlideFonts(xml, fonts, themeName) {
441
460
  const fix = missingJapanese.fontSource === 'html'
442
461
  ? `value 内の font-family 指定(<font face> や style の font-family)を消すか ${advice} にしてください`
443
462
  : `fontFamily を ${advice} にしてください`;
444
- warnings.push(`${prefix} 和文を含む文字列の書体の並びに ${fonts.eastAsian} がありません — "${missingJapanese.text}"。和文が代替書体で描かれます。${fix}`);
463
+ warn(`${prefix} 和文を含む文字列の書体の並びに ${fonts.eastAsian} がありません — "${missingJapanese.text}"。和文が代替書体で描かれます。${fix}`);
445
464
  }
446
- return warnings;
465
+ return findings;
447
466
  }
448
467
  /**
449
468
  規定外の文字サイズを、サイズの表示ラベルごとに最初の 1 件ずつ返す。
@@ -476,10 +495,13 @@ value の HTML(`style="font-size:..."`・`style="font:..."`)の入れ子の
476
495
  文字を持たないセルは対象外。
477
496
  */
478
497
  export function validateSlideFontSizes(xml, sizes) {
479
- const warnings = [];
498
+ const findings = [];
499
+ const warn = (message) => {
500
+ findings.push({ severity: 'warning', message });
501
+ };
480
502
  const document = parseDrawioXml(xml);
481
503
  if (document === undefined)
482
- return warnings;
504
+ return findings;
483
505
  const steps = new Set([sizes.heading, sizes.headingSm, sizes.body, sizes.bodySm, sizes.label]);
484
506
  const guide = fontSizeGuide(sizes);
485
507
  for (const cell of textCells(document)) {
@@ -488,10 +510,10 @@ export function validateSlideFontSizes(xml, sizes) {
488
510
  const fix = run.sizeSource === 'html' || run.fontSizeAttribute !== undefined
489
511
  ? 'value 内の font-size 指定(<font size> や style の font-size)を消し、セルの style に fontSize=<サイズ> を付けてください'
490
512
  : 'style に fontSize=<サイズ> を付けてください';
491
- warnings.push(`[warn] mxCell id=${cell.id}: ${sizeCause(label, run)} — "${run.text}"。${guide}。${fix}`);
513
+ warn(`mxCell id=${cell.id}: ${sizeCause(label, run)} — "${run.text}"。${guide}。${fix}`);
492
514
  }
493
515
  }
494
- return warnings;
516
+ return findings;
495
517
  }
496
518
  function isBoxShape(style) {
497
519
  const segments = style.split(';').map(s => s.trim()).filter(s => s.length > 0);
@@ -31,6 +31,7 @@ export declare function findPrerenderImages(slidesDirectory: string, slideNumber
31
31
  }): Promise<readonly PrerenderEntry[]>;
32
32
  export declare function applyPrerenderImageReplace(slide: XmlDocument, rels: XmlDocument, partMap: Map<string, Buffer>, entries: readonly PrerenderEntry[], io: {
33
33
  readonly readFile: (path: string) => Promise<Buffer>;
34
+ readonly warn: (message: string) => void;
34
35
  }): Promise<{
35
36
  readonly replaced: number;
36
37
  }>;
@@ -160,7 +160,7 @@ export async function applyPrerenderImageReplace(slide, rels, partMap, entries,
160
160
  highResolutionBuffer = await io.readFile(entry.imagePath);
161
161
  }
162
162
  catch (error) {
163
- console.warn(`prerender image read failed: ${entry.imagePath}: ${String(error)}`);
163
+ io.warn(`prerender image read failed: ${entry.imagePath}: ${String(error)}`);
164
164
  continue;
165
165
  }
166
166
  // 1 段目: 座標 + サイズ。matchPrerenderToMedia は matched 済 mediaPart を
@@ -222,13 +222,13 @@ async function loadMeta(metaPath, io) {
222
222
  return undefined;
223
223
  }
224
224
  if (!isRecord(parsed)) {
225
- console.warn(`prerender meta unrecognized: ${metaPath} (not a JSON object)`);
225
+ io.warn(`prerender meta unrecognized: ${metaPath} (not a JSON object)`);
226
226
  return undefined;
227
227
  }
228
228
  const width = parsed['width'];
229
229
  const height = parsed['height'];
230
230
  if (typeof width !== 'number' || typeof height !== 'number') {
231
- console.warn(`prerender meta unrecognized: ${metaPath} (width/height missing or non-numeric)`);
231
+ io.warn(`prerender meta unrecognized: ${metaPath} (width/height missing or non-numeric)`);
232
232
  return undefined;
233
233
  }
234
234
  const meta = { width, height };
@@ -194,8 +194,8 @@ export const START_SCRIPT_SOURCE = [
194
194
  'const slidevBin = join(__dirname, \'node_modules\', \'@slidev\', \'cli\', \'bin\', \'slidev.mjs\')',
195
195
  '',
196
196
  'if (!existsSync(slidevBin)) {',
197
- ' console.error(\'@slidev/cli not found at \' + slidevBin + \'.\')',
198
- ' console.error(\'pecotv slide sync --dir \' + __dirname + \' --node-modules-only を実行してください。\')',
197
+ ' console.error(\'error: @slidev/cli not found at \' + slidevBin + \'.\')',
198
+ ' console.error(\' pecotv slide sync --dir \' + __dirname + \' --node-modules-only を実行してください。\')',
199
199
  ' process.exit(1)',
200
200
  '}',
201
201
  '',
@@ -211,7 +211,7 @@ export const START_SCRIPT_SOURCE = [
211
211
  '})',
212
212
  '',
213
213
  'slidev.on(\'error\', (error) => {',
214
- ' console.error(\'Failed to start Slidev:\', error)',
214
+ ' console.error(\'error: Failed to start Slidev:\', error)',
215
215
  ' process.exit(1)',
216
216
  '})',
217
217
  '',
@@ -32,6 +32,7 @@
32
32
  import { existsSync, readFileSync, realpathSync } from 'node:fs';
33
33
  import { createRequire } from 'node:module';
34
34
  import path from 'node:path';
35
+ import { parse as parseYaml } from 'yaml';
35
36
  const DATA_DIRECTORY_PROJECT = 'pecot-visual';
36
37
  /**
37
38
  データ置き場として有効な値なら、末尾の改行と CR を落とした値。無効なら undefined。
@@ -88,6 +89,64 @@ export function themeStoreRoot() {
88
89
  return data === undefined ? undefined : path.join(data, 'themes');
89
90
  }
90
91
  /**
92
+ `node_modules` を持つ側のディレクトリ。`root` 自身か、`root` を `packages` に含む上位の workspace root。
93
+
94
+ `root` に `pnpm-workspace.yaml` が無いときだけ、上の dir を最大 3 つまで遡る。無関係な workspace は採らない。
95
+ */
96
+ function nodeModulesHolder(root) {
97
+ let current = root;
98
+ for (let level = 0; level <= 3; level += 1) {
99
+ const workspace = path.join(current, 'pnpm-workspace.yaml');
100
+ // eslint-disable-next-line security/detect-non-literal-fs-filename -- 参照先は pnpm-workspace.yaml のみ
101
+ if (existsSync(workspace))
102
+ return level === 0 || isIncludedByWorkspace(workspace, path.relative(current, root)) ? current : root;
103
+ const parent = path.dirname(current);
104
+ if (parent === current)
105
+ break;
106
+ current = parent;
107
+ }
108
+ return root;
109
+ }
110
+ /**
111
+ `pnpm-workspace.yaml` の `packages` が、workspace root からの相対パスを含むか。読めない・形が違うときは false。
112
+ */
113
+ function isIncludedByWorkspace(workspaceFile, relative) {
114
+ let packages;
115
+ try {
116
+ // eslint-disable-next-line security/detect-non-literal-fs-filename -- 参照先は pnpm-workspace.yaml のみ
117
+ const parsed = parseYaml(readFileSync(workspaceFile, 'utf8'));
118
+ packages = typeof parsed === 'object' && parsed !== null && 'packages' in parsed ? parsed.packages : undefined;
119
+ }
120
+ catch {
121
+ return false;
122
+ }
123
+ if (!Array.isArray(packages))
124
+ return false;
125
+ const target = relative.split(path.sep);
126
+ let isIncluded = false;
127
+ for (const entry of packages) {
128
+ if (typeof entry !== 'string')
129
+ continue;
130
+ const isNegated = entry.startsWith('!');
131
+ const pattern = (isNegated ? entry.slice(1) : entry).replace(/^\.\//, '').replace(/\/$/, '').split('/');
132
+ if (isMatchingSegments(pattern, target))
133
+ isIncluded = !isNegated;
134
+ }
135
+ return isIncluded;
136
+ }
137
+ /**
138
+ `*`(1 階層の任意の名前)と `**`(0 階層以上)だけを扱う glob の一致の判定。
139
+ */
140
+ function isMatchingSegments(pattern, target) {
141
+ const [head, ...rest] = pattern;
142
+ if (head === undefined)
143
+ return target.length === 0;
144
+ if (head === '**')
145
+ return isMatchingSegments(rest, target) || (target.length > 0 && isMatchingSegments(pattern, target.slice(1)));
146
+ const [first, ...others] = target;
147
+ return first !== undefined && (head === '*' || head === first) && isMatchingSegments(rest, others);
148
+ }
149
+ /**
91
150
  環境変数の値。未設定・空白のみは undefined。
92
151
  */
93
152
  export function trimmedEnvironment(name) {
@@ -168,7 +227,7 @@ flock(1) は、親ディレクトリが実在しないとロックファイル
168
227
  */
169
228
  function firstExistingNodeModules(roots) {
170
229
  for (const root of roots) {
171
- const candidate = path.join(root, 'node_modules');
230
+ const candidate = path.join(nodeModulesHolder(root), 'node_modules');
172
231
  // eslint-disable-next-line security/detect-non-literal-fs-filename -- 参照先は node_modules のみ
173
232
  if (existsSync(candidate))
174
233
  return candidate;
@@ -199,7 +258,7 @@ export function resolveTalkDirectoryNodeModules(dependencyRoot) {
199
258
  const roots = runtimeRoot === undefined ? [dependencyRoot] : [dependencyRoot, runtimeRoot];
200
259
  for (const root of roots) {
201
260
  if (areProbesResolvableWithin(root))
202
- return path.join(root, 'node_modules');
261
+ return path.join(nodeModulesHolder(root), 'node_modules');
203
262
  }
204
263
  return undefined;
205
264
  }
@@ -266,7 +325,8 @@ Node の解決は基準点の上位ディレクトリへ遡る。
266
325
  bind mount / worktree では、論理パスと物理パスが割れるため。
267
326
  */
268
327
  function areProbesResolvableWithin(root) {
269
- const nodeModules = path.join(root, 'node_modules');
328
+ const holder = nodeModulesHolder(root);
329
+ const nodeModules = path.join(holder, 'node_modules');
270
330
  let physical;
271
331
  try {
272
332
  // eslint-disable-next-line security/detect-non-literal-fs-filename -- 参照先は node_modules のみ
@@ -9,6 +9,10 @@ export declare const FALLBACK_PNPM_VERSION = "12.15.0";
9
9
  export interface PnpmCommand {
10
10
  readonly command: string;
11
11
  readonly commandArguments: readonly string[];
12
+ /**
13
+ 起動時の cwd。指定が無ければ、呼び出し側が対象の dir を cwd にする。
14
+ */
15
+ readonly cwd?: string;
12
16
  }
13
17
  /**
14
18
  コマンドが PATH 上にあるか。テストが差し替える。
@@ -16,6 +20,7 @@ export interface PnpmCommand {
16
20
  export type CommandProbe = (command: string) => boolean;
17
21
  /**
18
22
  pnpm の起動コマンドを返す。pnpm が無く corepack も無いときは npx で版を指す。
23
+ targetDirectory は pnpm を実行する対象の dir(絶対パス)。npx を使うときだけ --dir に渡す。
19
24
  */
20
- export declare function resolvePnpmCommand(pluginRoot: string, isAvailable?: CommandProbe): PnpmCommand;
25
+ export declare function resolvePnpmCommand(pluginRoot: string, targetDirectory: string, isAvailable?: CommandProbe): PnpmCommand;
21
26
  //# sourceMappingURL=pnpm.d.ts.map
@@ -1,6 +1,8 @@
1
1
  // pnpm の起動コマンドを解く。bin/_lib.sh の resolve_pnpm と同じ順を TypeScript に写したもの。
2
2
  //
3
- // 順は pnpm、corepack pnpm@<版>、`npx --yes pnpm@<版>`。
3
+ // 順は pnpm、corepack pnpm@<版>、`npx --yes pnpm@<版> --dir <対象>`(cwd は /)。
4
+ // npm 11 は、cwd の package.json が devEngines.packageManager に pnpm を宣言していると npx も止める。
5
+ // そのため npx を使うときは cwd を / にして起動し、pnpm には --dir で対象の dir を指す。
4
6
  // 版は package.json の packageManager から読み、読めなければ FALLBACK_PNPM_VERSION を使う。
5
7
  // 単体配布の package.json は packageManager を持たない(npx で起動する配布物に pnpm の宣言を載せると、
6
8
  // corepack を有効にした環境で止まる)。そのため定数が要る。
@@ -38,12 +40,17 @@ function pnpmVersion(pluginRoot) {
38
40
  }
39
41
  /**
40
42
  pnpm の起動コマンドを返す。pnpm が無く corepack も無いときは npx で版を指す。
43
+ targetDirectory は pnpm を実行する対象の dir(絶対パス)。npx を使うときだけ --dir に渡す。
41
44
  */
42
- export function resolvePnpmCommand(pluginRoot, isAvailable = isOnPath) {
45
+ export function resolvePnpmCommand(pluginRoot, targetDirectory, isAvailable = isOnPath) {
43
46
  if (isAvailable('pnpm'))
44
47
  return { command: 'pnpm', commandArguments: [] };
45
48
  if (isAvailable('corepack'))
46
49
  return { command: 'corepack', commandArguments: [`pnpm@${pnpmVersion(pluginRoot)}`] };
47
- return { command: 'npx', commandArguments: ['--yes', `pnpm@${pnpmVersion(pluginRoot)}`] };
50
+ return {
51
+ command: 'npx',
52
+ commandArguments: ['--yes', `pnpm@${pnpmVersion(pluginRoot)}`, '--dir', targetDirectory],
53
+ cwd: path.parse(targetDirectory).root,
54
+ };
48
55
  }
49
56
  //# sourceMappingURL=pnpm.js.map
@@ -1,52 +1,15 @@
1
1
  import type { SpawnResult } from '../../domain/_shared/spawn-result.js';
2
2
  /**
3
3
  本体の実行時依存の manifest を置く dir。プラグインのルートからの相対パス。
4
-
5
- 単体配布の install 対象はこの dir の package.json から得る。
6
4
  */
7
5
  export declare const RUNTIME_MANIFEST_DIRECTORY: string;
8
6
  /**
9
- 取得の上限時間 (ms)。
10
-
11
- 計測では 631MB / 455 エントリで 37 秒かかった(`.pecot/work/982/exp/persist-deps.sh`)。
12
- chromium 取得(計測 33 秒に対し上限 300 秒)と同じだけの余裕を取る。
7
+ 取得の上限時間 (ms)。計測 37 秒(631MB)に対し、chromium 取得と同じ約 10 倍の余裕を取る。
13
8
  */
14
9
  export declare const RUNTIME_INSTALL_TIMEOUT_MS = 600000;
15
10
  /**
16
- slidev 中核パッケージの固定版。
17
-
18
- manifest は `@slidev/cli` / `@slidev/client` を完全一致の版で宣言する。ただし、宣言が範囲に変わっても固定版で入れる。
19
- 永続層は `--no-package-lock` で install するため、そのまま渡すと時点ごとに別の 53.x へ解決される。
20
- slidev の中核パッケージは、互いを完全一致の版で要求する。
21
- npm レジストリの `@slidev/cli@53.0.0` の dependencies で確認した。
22
- `@slidev/parser` / `@slidev/client` / `@slidev/types` を、いずれも `53.0.0` 固定で引く。
23
- そのため cli だけが上位版へ動くと、nested に別版の parser / client が入る。
24
- すると、pptx 差分キャッシュの slideHash を求める parser と、slidev build の parser がずれる。
25
- cli/package.json の slidev-parser-pin-reason と同じ理由。
26
-
27
- 対処として lockfile を持たせる案もある。
28
- ただし lockfile は「解決結果を再現する」だけで、中核パッケージ同士の版一致は保証しない。
29
- 初回解決が cli 52.16 / parser 52.15 なら、その食い違いを固定してしまう。
30
- よって中核パッケージを同一版に固定する方を採る。
31
- この値はプラグイン配布の構成と同じで、中核 4 本(cli / client / parser / types)とも 53.0.0 になる。
32
- cli/package.json の `@slidev/parser` の pin と同値であることを、unit test で固定する。
33
- `@slidev/theme-default` は別の版系列(0.25.x)なので対象に含めない。
34
- */
35
- export declare const SLIDEV_CORE_VERSION = "53.0.0";
36
- /**
37
- 永続層へ入れる patch-package の版。完全一致で固定する。
38
-
39
- 本体の実行時依存は patch を持たない。
40
- patch-package を入れる理由は、テーマの置き場が使うことにある。
41
- 使う箇所は infra/slidev-theme/store.ts の applyThemePatches の中。
42
- `resolveDependency('patch-package/package.json')` で解決する。
43
-
44
- 永続層は `--no-package-lock` で install するため、caret のままだと時点ごとに別の 8.x へ解決される。
45
- slidev 中核パッケージと同じ理由で、検証した版だけを配る(Epic #152)。
46
-
47
- 監査 manifest(scripts/release/runtime-manifest.mjs)は同じ規則を写して、同値比較で固定している。
48
-
49
- 値は plugins/pecot-visual/package.json の devDependencies と同値にし、unit test で固定する。
11
+ 永続層へ入れる patch-package の版(完全一致)。テーマの patch 適用が使う。
12
+ plugins/pecot-visual/package.json の devDependencies と同値で、unit test が固定する。
50
13
  */
51
14
  export declare const PATCH_PACKAGE_RANGE = "8.0.1";
52
15
  /**
@@ -58,22 +21,8 @@ export interface RuntimeInstallPlan {
58
21
  }
59
22
  /**
60
23
  永続層へ install する内容を実行時依存の manifest から組み立てる。
61
-
62
- specs には次を入れる。
63
- - manifest の `dependencies`。`workspace:` 等のローカル参照は除く。
64
- - `devDependencies` の `dom-to-pptx`。pptx 変換の bundle 供給元になる。
65
- - `@slidev/parser`。
66
-
67
- slidev 中核パッケージは、range ではなく `SLIDEV_CORE_VERSION` で固定する。
68
-
69
- overrides には、manifest の `overrides` をそのまま写す。
70
- manifest は推移依存の版を overrides で pin している。
71
- install 対象を manifest から導く設計なので、解決の pin だけ落とすと、
72
- 永続層とプラグイン配布で別の推移依存を掴む。
73
-
74
- manifest が読めないときも、取得は諦めない。
75
- 最低限 `@slidev/parser` は返し、npm 側のエラーを呼び出し元へ見せる。
76
- ここで空を返すと、「install は成功したのに何も入らない」という判別しづらい状態になる。
24
+ slidev 中核パッケージは manifest の `@slidev/cli` の版で固定し、overrides は manifest から写す。
25
+ manifest が読めない、または `@slidev/cli` の版が無い・空のときは配布の破損として throw する(版なしの install を避ける)。
77
26
  */
78
27
  export declare function runtimeInstallPlan(manifestPath: string): RuntimeInstallPlan;
79
28
  /**
@@ -82,18 +31,12 @@ export declare function runtimeInstallPlan(manifestPath: string): RuntimeInstall
82
31
  export declare function runtimeInstallSpecs(manifestPath: string): readonly string[];
83
32
  /**
84
33
  永続層の取得済み判定に使う印。install 対象(specs と overrides)の内容から導く。
85
-
86
- 永続層は版を持たない固定パスなので、利用者が新版へ上げて manifest の依存が変わっても、
87
- 「解決できる」だけでは前の版の残骸と区別できない。
88
- 印には、pecotv の版そのものではなく install 対象の内容を使う。
89
- 依存が変わらない版上げで、600MB の再取得を強いないため。
34
+ pecotv の版ではなく内容を使うのは、依存が変わらない版上げで 600MB の再取得を避けるため。
90
35
  */
91
36
  export declare function runtimeInstallStamp(manifestPath: string): string;
92
37
  /**
93
38
  永続層への取得を排他するロックのパス。場所を決められなければ undefined。
94
-
95
- chromium 側(installLockPath)は依存ルートの `node_modules` に置く。
96
- こちらは `node_modules` を作る側なので、永続層の直下に置く(install 前に mkdir する)。
39
+ `node_modules` を作る側なので、chromium 側と違い永続層の直下に置く。
97
40
  */
98
41
  export declare function runtimeInstallLockPath(): string | undefined;
99
42
  /**
@@ -121,26 +64,11 @@ export interface InstallRuntimeDependenciesOptions {
121
64
  readonly npmCommand?: string | undefined;
122
65
  }
123
66
  /**
124
- 永続層へ実行時依存を install する。取得先は無ければここで作る(runtimeDependencyRoot は作らない)。
125
-
126
- `--prefix` を有効にするには、install 先に package.json が必要になる。
127
- 無いと npm は上位へ遡り、HOME 直下など意図しない場所へ書き込む。
128
- 毎回書き直すのは冪等だからで、途中終了した前回の残骸(package.json だけ欠けた状態)から復帰する意味もある。
129
-
130
- 単体配布は MCP クライアントごとに別プロセスが立つ。
131
- そのため複数セッションからの `setup` が、同じ `node_modules` へ同時に実行され得る。
132
- chromium 取得と同じ flock(1) で直列化する。
133
- flock(1) が無い環境では、ロックなしで実行する。
134
-
135
- stamp は install が成功したときにだけ置く。
136
- 先に消しておくのは、途中で失敗した install の残骸を「取得済み」と誤判定させないため。
137
-
138
- npm 自体は、npx 経由の起動なら必ず同居する。
139
- 解決できない環境では spawnPromise が `exitCode: null` を返し、呼び出し元が理由付きの失敗として扱う。
140
-
141
- env は利用者環境のものを引き継ぐ。
142
- 取得先と proxy の指定は利用者側の変数で行われるため、絞り込まない。
143
- プロキシの CA は利用者が `NODE_EXTRA_CA_CERTS` で渡す。
67
+ 永続層へ実行時依存を install する。取得先は無ければここで作る。
68
+ `--prefix` を使うには install 先に package.json が要る(無いと npm は上位へ遡る)ので、毎回書き直す。
69
+ 複数セッションの `setup` が並走し得るため、flock(1) で直列化する(無い環境ではロックなし)。
70
+ stamp は成功時だけ置き、先に消す。途中で失敗した残骸を取得済みと誤判定させないため。
71
+ manifest から plan を組めないときは、起動失敗(exitCode: null, failedStage: 'npm')として返す。
144
72
  */
145
73
  export declare function installRuntimeDependencies(options: Readonly<InstallRuntimeDependenciesOptions>): Promise<RuntimeInstallResult>;
146
74
  //# sourceMappingURL=runtime-install.d.ts.map