@pecot/visual-mcp 3.1.1-dev.142 → 3.1.1-dev.144
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/cli/dist/commands/drawio/export.d.ts +9 -24
- package/cli/dist/commands/drawio/export.js +15 -135
- package/cli/dist/commands/drawio/theme.d.ts +3 -3
- package/cli/dist/commands/drawio/theme.js +10 -10
- package/cli/dist/commands/drawio/url.d.ts +9 -26
- package/cli/dist/commands/drawio/url.js +18 -131
- package/cli/dist/commands/evidence-xlsx/create.d.ts +4 -12
- package/cli/dist/commands/evidence-xlsx/create.js +9 -92
- package/cli/dist/commands/slidev-project/create.d.ts +5 -30
- package/cli/dist/commands/slidev-project/create.js +12 -136
- package/cli/dist/commands/slidev-project/linked-theme.d.ts +1 -1
- package/cli/dist/commands/slidev-project/linked-theme.js +2 -2
- package/cli/dist/commands/slidev-project/lint.d.ts +8 -37
- package/cli/dist/commands/slidev-project/lint.js +16 -161
- package/cli/dist/commands/slidev-project/sync.d.ts +7 -26
- package/cli/dist/commands/slidev-project/sync.js +15 -156
- package/cli/dist/commands/slidev-project/theme.d.ts +2 -13
- package/cli/dist/commands/slidev-project/theme.js +3 -93
- package/cli/dist/commands/slidev-to-pptx/convert.d.ts +10 -17
- package/cli/dist/commands/slidev-to-pptx/convert.js +25 -266
- package/cli/dist/diagnostics.d.ts +0 -4
- package/cli/dist/diagnostics.js +0 -6
- package/cli/dist/domain/_shared/failure-kind.d.ts +2 -2
- package/cli/dist/domain/_shared/failure-kind.js +2 -2
- package/cli/dist/domain/_shared/ports.d.ts +3 -4
- package/cli/dist/domain/evidence-xlsx/image-dimensions.d.ts +1 -1
- package/cli/dist/domain/pptx-ooxml/preview-normalize.d.ts +0 -12
- package/cli/dist/domain/pptx-ooxml/preview-normalize.js +1 -25
- package/cli/dist/domain/slidev-project/errors.js +2 -2
- package/cli/dist/domain/slidev-project/generated-files.js +3 -3
- package/cli/dist/domain/slidev-project/lint.d.ts +7 -7
- package/cli/dist/domain/slidev-project/lint.js +8 -8
- package/cli/dist/domain/slidev-project/package-json.d.ts +1 -1
- package/cli/dist/domain/slidev-project/package-json.js +2 -2
- package/cli/dist/domain/slidev-project/sync.d.ts +11 -11
- package/cli/dist/domain/slidev-project/sync.js +18 -19
- package/cli/dist/domain/slidev-theme/deck-lint-input.js +1 -1
- package/cli/dist/domain/slidev-theme/declaration.js +1 -1
- package/cli/dist/domain/slidev-theme/skeleton.js +1 -1
- package/cli/dist/domain/slidev-theme/talk-theme.d.ts +3 -3
- package/cli/dist/domain/slidev-theme/talk-theme.js +5 -7
- package/cli/dist/domain/slidev-to-pptx/config.d.ts +1 -1
- package/cli/dist/domain/slidev-to-pptx/config.js +1 -1
- package/cli/dist/domain/slidev-to-pptx/errors.d.ts +4 -4
- package/cli/dist/domain/slidev-to-pptx/errors.js +4 -4
- package/cli/dist/domain/slidev-to-pptx/types.d.ts +1 -1
- package/cli/dist/infra/_shared/dependency-root.d.ts +9 -67
- package/cli/dist/infra/_shared/dependency-root.js +15 -126
- package/cli/dist/infra/_shared/flock.js +1 -2
- package/cli/dist/infra/_shared/plugin-root.d.ts +3 -5
- package/cli/dist/infra/_shared/plugin-root.js +5 -12
- package/cli/dist/infra/evidence-xlsx/workbook-writer.d.ts +1 -1
- package/cli/dist/infra/playwright/chromium.d.ts +4 -15
- package/cli/dist/infra/playwright/chromium.js +6 -18
- package/cli/dist/infra/playwright/host-dependencies.d.ts +2 -2
- package/cli/dist/infra/playwright/host-dependencies.js +6 -6
- package/cli/dist/infra/pptx-ooxml/soffice.js +1 -1
- package/cli/dist/infra/slidev-project/eslint-runner.d.ts +1 -1
- package/cli/dist/infra/slidev-project/eslint-runner.js +2 -2
- package/cli/dist/infra/slidev-to-pptx/index.js +1 -1
- package/cli/dist/infra/slidev-to-pptx/pipeline.js +1 -1
- package/cli/dist/infra/slidev-to-pptx/prerender-capture.js +1 -1
- package/cli/dist/infra/slidev-to-pptx/server.js +2 -2
- package/cli/dist/main.d.ts +3 -0
- package/cli/dist/main.js +28 -0
- package/cli/dist/mcp/result.d.ts +5 -1
- package/cli/dist/mcp/result.js +9 -1
- package/cli/dist/mcp/serve.d.ts +2 -3
- package/cli/dist/mcp/serve.js +4 -5
- package/cli/dist/mcp/server.d.ts +5 -1
- package/cli/dist/mcp/server.js +10 -7
- package/cli/dist/mcp/tool-names.js +4 -1
- package/cli/dist/mcp/tools/_shared.d.ts +1 -1
- package/cli/dist/mcp/tools/_shared.js +2 -2
- package/cli/dist/mcp/tools/drawio.js +12 -15
- package/cli/dist/mcp/tools/evidence.js +2 -2
- package/cli/dist/mcp/tools/file.d.ts +31 -0
- package/cli/dist/mcp/tools/file.js +482 -0
- package/cli/dist/mcp/tools/index.d.ts +1 -1
- package/cli/dist/mcp/tools/index.js +6 -3
- package/cli/dist/mcp/tools/setup.js +3 -3
- package/cli/dist/mcp/tools/slide-dev.js +6 -7
- package/cli/dist/mcp/tools/slide-page.js +3 -3
- package/cli/dist/mcp/tools/slide-theme.d.ts +0 -1
- package/cli/dist/mcp/tools/slide-theme.js +2 -3
- package/cli/dist/mcp/tools/slide.d.ts +4 -4
- package/cli/dist/mcp/tools/slide.js +13 -14
- package/cli/dist/node-runtime.d.ts +2 -2
- package/cli/dist/node-runtime.js +4 -13
- package/cli/dist/version.d.ts +1 -8
- package/cli/dist/version.js +2 -11
- package/npm-shrinkwrap.json +7 -17
- package/package.json +2 -3
- package/bin/pecot-visual-mcp.mjs +0 -10
- package/cli/dist/cli.d.ts +0 -5
- package/cli/dist/cli.js +0 -109
- package/cli/dist/commands/chromium/host-dependencies.d.ts +0 -18
- package/cli/dist/commands/chromium/host-dependencies.js +0 -75
- package/cli/dist/commands/pptx-ooxml/preview.d.ts +0 -74
- package/cli/dist/commands/pptx-ooxml/preview.js +0 -399
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
// PostToolUse の mcp_tool フックが呼ぶ 3 ツール(file_lint・file_validate・file_brief)。
|
|
2
|
+
// 結果は command フックの stdout と同じに読まれるので、text は JSON のオブジェクト 1 つにし、isError を付けない。
|
|
3
|
+
/* eslint-disable security/detect-non-literal-fs-filename -- 編集されたファイルと、プラグインの同梱物のパスだけを扱う */
|
|
4
|
+
// ToolCallContext.signal(AbortSignal)は readonly にできない。
|
|
5
|
+
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
6
|
+
import { existsSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { pathToFileURL } from 'node:url';
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { executeSlideTheme } from '../../commands/slidev-project/theme.js';
|
|
11
|
+
import { isRecord } from '../../domain/_shared/json.js';
|
|
12
|
+
import { themeErrorReason } from '../../domain/slidev-theme/error-reason.js';
|
|
13
|
+
import { DEPENDENCY_RECOVERY_HINT } from '../../infra/_shared/dependency-root.js';
|
|
14
|
+
import { resolvePluginRoot } from '../../infra/_shared/plugin-root.js';
|
|
15
|
+
import { spawnPromise } from '../../infra/_shared/process.js';
|
|
16
|
+
import { resolveEslintBin } from '../../infra/slidev-project/eslint-runner.js';
|
|
17
|
+
import { NodeThemeFiles } from '../../infra/slidev-theme/fs.js';
|
|
18
|
+
import { formatError } from './_shared.js';
|
|
19
|
+
// 文脈の上限は UTF-8 のバイト数(Copilot CLI の上限がバイトのため)。
|
|
20
|
+
const CONTEXT_MAX_LAYOUT = 3500;
|
|
21
|
+
const CONTEXT_MAX_ESLINT = 3500;
|
|
22
|
+
const CONTEXT_MAX_TEXT_LINT = 3000;
|
|
23
|
+
const CONTEXT_MAX_REFERENCES = 3000;
|
|
24
|
+
const ESLINT_TIMEOUT_MS = 30_000;
|
|
25
|
+
const TEXT_LINT_TIMEOUT_MS = 20_000;
|
|
26
|
+
const VALIDATOR_TIMEOUT_MS = 30_000;
|
|
27
|
+
const GIT_TIMEOUT_MS = 10_000;
|
|
28
|
+
const TIMEOUT_EXIT_CODE = 124;
|
|
29
|
+
const CRASH_BANNER = 'Oops! Something went wrong';
|
|
30
|
+
const RECOVERY_LINE = `To restore it, ${DEPENDENCY_RECOVERY_HINT}.`;
|
|
31
|
+
const UNLINKED_RECOVERY_LINE = 'Relinking node_modules with slide_sync (node_modules_only: true) restores it.';
|
|
32
|
+
const LAYOUT_SECTION_KEYS = ['status', 'best_practices', 'anti_patterns'];
|
|
33
|
+
const fileInput = z.object({
|
|
34
|
+
file_path: z.string().describe('Absolute path of the file that was written or edited (the hook passes tool_input.file_path)'),
|
|
35
|
+
cwd: z.string().optional().describe('Working directory of the session. Text rules for a file outside a git repository read .textlintignore from here'),
|
|
36
|
+
});
|
|
37
|
+
const fileOutput = z.object({
|
|
38
|
+
hookSpecificOutput: z.strictObject({
|
|
39
|
+
hookEventName: z.literal('PostToolUse'),
|
|
40
|
+
additionalContext: z.string().describe('Notice passed to the agent'),
|
|
41
|
+
}).optional().describe('Present only when there is something to tell the agent'),
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
返すオブジェクトを text 1 ブロックと structuredContent の両方に載せる。
|
|
45
|
+
*/
|
|
46
|
+
function hookResult(additionalContext) {
|
|
47
|
+
const output = additionalContext === undefined
|
|
48
|
+
? {}
|
|
49
|
+
: { hookSpecificOutput: { hookEventName: 'PostToolUse', additionalContext } };
|
|
50
|
+
return { content: [{ type: 'text', text: JSON.stringify(output) }], structuredContent: { ...output } };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
1 行目に `<kind>: `、2 行目以降に空白 2 つを付ける。空行は空のまま残す。
|
|
54
|
+
*/
|
|
55
|
+
export function hookMessage(kind, text) {
|
|
56
|
+
return text.replace(/\n+$/, '').split('\n')
|
|
57
|
+
.map((line, index) => (index === 0 ? `${kind}: ${line}` : (line === '' ? '' : ` ${line}`)))
|
|
58
|
+
.join('\n');
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
本文を UTF-8 のバイト数で行単位に切る。切ったら、残りの行のうち `item` に合う数を note に書く。
|
|
62
|
+
*/
|
|
63
|
+
export function capContext(max, item, unit, text) {
|
|
64
|
+
const lines = text.replace(/\n+$/, '').split('\n');
|
|
65
|
+
let size = 0;
|
|
66
|
+
let cut;
|
|
67
|
+
for (const [index, line] of lines.entries()) {
|
|
68
|
+
const cost = Buffer.byteLength(line) + (index === 0 ? 0 : 1);
|
|
69
|
+
if (size + cost > max) {
|
|
70
|
+
cut = index;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
size += cost;
|
|
74
|
+
}
|
|
75
|
+
if (cut === undefined)
|
|
76
|
+
return { body: lines.join('\n'), note: '' };
|
|
77
|
+
const rest = lines.slice(Math.max(cut, 1)).filter(line => item.test(line)).length;
|
|
78
|
+
const body = cut === 0 ? headWithinBytes(lines[0] ?? '', max) : lines.slice(0, cut).join('\n');
|
|
79
|
+
return { body, note: `Truncated at ${String(max)} bytes: ${String(rest)} more ${unit} not shown.` };
|
|
80
|
+
}
|
|
81
|
+
function headWithinBytes(line, max) {
|
|
82
|
+
let head = '';
|
|
83
|
+
for (const character of line) {
|
|
84
|
+
if (Buffer.byteLength(head + character) > max)
|
|
85
|
+
break;
|
|
86
|
+
head += character;
|
|
87
|
+
}
|
|
88
|
+
return head;
|
|
89
|
+
}
|
|
90
|
+
function withNote(capped) {
|
|
91
|
+
return capped.note === '' ? '' : `\n${capped.note}`;
|
|
92
|
+
}
|
|
93
|
+
function isDirectory(target) {
|
|
94
|
+
try {
|
|
95
|
+
return statSync(target).isDirectory();
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function isFile(target) {
|
|
102
|
+
try {
|
|
103
|
+
return statSync(target).isFile();
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
`slides.md` と `pages/` を持つ最も近い上の dir。論理パスで遡る(pages/ が talk-dir の外への symlink でも見失わない)。
|
|
111
|
+
*/
|
|
112
|
+
export function findTalkRoot(directory) {
|
|
113
|
+
let current = directory;
|
|
114
|
+
while (current !== '' && current !== path.dirname(current)) {
|
|
115
|
+
if (isFile(path.join(current, 'slides.md')) && isDirectory(path.join(current, 'pages')))
|
|
116
|
+
return current;
|
|
117
|
+
current = path.dirname(current);
|
|
118
|
+
}
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
function locateFile(input) {
|
|
122
|
+
if (input.file_path === '')
|
|
123
|
+
return undefined;
|
|
124
|
+
const filePath = path.resolve(input.cwd ?? process.cwd(), input.file_path);
|
|
125
|
+
const directory = path.dirname(filePath);
|
|
126
|
+
const talkRoot = isDirectory(directory) ? findTalkRoot(directory) : undefined;
|
|
127
|
+
const relative = talkRoot === undefined
|
|
128
|
+
? undefined
|
|
129
|
+
: [path.relative(talkRoot, directory), path.basename(filePath)].filter(part => part !== '').join('/');
|
|
130
|
+
return { filePath, directory, talkRoot, relative };
|
|
131
|
+
}
|
|
132
|
+
function isPagesMarkdown(relative) {
|
|
133
|
+
return relative?.startsWith('pages/') === true && relative.endsWith('.md');
|
|
134
|
+
}
|
|
135
|
+
// deck lint の対象。text lint は二重に報告しないよう、ここを飛ばす。
|
|
136
|
+
function isDeckLintTarget(relative) {
|
|
137
|
+
return isPagesMarkdown(relative) || relative === 'slides.md';
|
|
138
|
+
}
|
|
139
|
+
function physicalPath(target) {
|
|
140
|
+
try {
|
|
141
|
+
return realpathSync(target);
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
return target;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function assetsDirectory() {
|
|
148
|
+
return physicalPath(path.join(resolvePluginRoot(), 'assets', 'slidev'));
|
|
149
|
+
}
|
|
150
|
+
async function readThemeLint(talkRoot) {
|
|
151
|
+
try {
|
|
152
|
+
const { data } = await executeSlideTheme({ dir: talkRoot }, { files: new NodeThemeFiles() });
|
|
153
|
+
return { ok: true, lint: data.lint, directory: data.theme.directory };
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
return { ok: false, reason: themeErrorReason(error), detail: formatError(error) };
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
テーマを読めなかった理由の文。eslint は theme-unlinked・theme-none 以外の theme-* を「宣言を読めない」と書く。
|
|
161
|
+
*/
|
|
162
|
+
function themeFailureLine(theme, isDeclarationWording = false) {
|
|
163
|
+
if (theme.reason === 'theme-unlinked') {
|
|
164
|
+
return `The theme could not be resolved (reason: theme-unlinked). ${theme.detail}\n${UNLINKED_RECOVERY_LINE}`;
|
|
165
|
+
}
|
|
166
|
+
if (theme.reason === undefined)
|
|
167
|
+
return `The theme declaration could not be fetched (${theme.detail}).`;
|
|
168
|
+
if (isDeclarationWording && theme.reason !== 'theme-none') {
|
|
169
|
+
return `The theme declaration could not be read (reason: ${theme.reason}). ${theme.detail}`;
|
|
170
|
+
}
|
|
171
|
+
return `The theme could not be resolved (reason: ${theme.reason}). ${theme.detail}`;
|
|
172
|
+
}
|
|
173
|
+
function exitLabel(result) {
|
|
174
|
+
if (result.timedOut)
|
|
175
|
+
return String(TIMEOUT_EXIT_CODE);
|
|
176
|
+
return result.exitCode === null ? `signal ${result.signal ?? 'unknown'}` : String(result.exitCode);
|
|
177
|
+
}
|
|
178
|
+
function combinedOutput(result) {
|
|
179
|
+
return [result.stdout, result.stderr].filter(text => text !== '').join('\n').replace(/\n+$/, '');
|
|
180
|
+
}
|
|
181
|
+
function headLines(text) {
|
|
182
|
+
return text.split('\n').slice(0, 10).join('\n');
|
|
183
|
+
}
|
|
184
|
+
async function guarded(notify, run) {
|
|
185
|
+
try {
|
|
186
|
+
return await run();
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
return notify(`An unexpected error stopped the check: ${formatError(error)}`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// --- file_lint ---
|
|
193
|
+
async function lintWithEslint(file, talkRoot, relative, call) {
|
|
194
|
+
const notify = (reason) => hookResult(hookMessage('warning', `eslint not run: ${file.filePath}\n${reason}\nNo eslint result exists for this file, so violations have not been detected.`));
|
|
195
|
+
return guarded(notify, async () => {
|
|
196
|
+
const assets = assetsDirectory();
|
|
197
|
+
const theme = await readThemeLint(talkRoot);
|
|
198
|
+
let eslintBin;
|
|
199
|
+
try {
|
|
200
|
+
eslintBin = resolveEslintBin(assets);
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
eslintBin = undefined;
|
|
204
|
+
}
|
|
205
|
+
const deckLintConfig = path.join(assets, 'deck-lint.env.config.js');
|
|
206
|
+
const missing = [
|
|
207
|
+
...(eslintBin === undefined || !isFile(eslintBin) ? ['node_modules/eslint'] : []),
|
|
208
|
+
...(isFile(deckLintConfig) ? [] : ['deck-lint.env.config.js']),
|
|
209
|
+
];
|
|
210
|
+
if (eslintBin === undefined || missing.length > 0) {
|
|
211
|
+
const themeDirectory = theme.ok ? theme.directory : 'unresolved';
|
|
212
|
+
return notify(`The lint environment is incomplete (missing: ${missing.join(', ')} / theme: ${themeDirectory}).\n${RECOVERY_LINE}`);
|
|
213
|
+
}
|
|
214
|
+
if (!theme.ok)
|
|
215
|
+
return notify(themeFailureLine(theme, true));
|
|
216
|
+
// 相対パスを物理の cwd で渡す。絶対パスだと symlink をまたいだときに base path の外と判定される。
|
|
217
|
+
const result = await spawnPromise(process.execPath, [eslintBin, '--no-fix', '--config', deckLintConfig, relative], {
|
|
218
|
+
cwd: physicalPath(talkRoot),
|
|
219
|
+
// interface-env: none
|
|
220
|
+
env: { ...process.env, PECOTV_DECK_LINT: JSON.stringify(theme.lint) },
|
|
221
|
+
timeoutMs: ESLINT_TIMEOUT_MS,
|
|
222
|
+
signal: call.signal,
|
|
223
|
+
});
|
|
224
|
+
const output = combinedOutput(result);
|
|
225
|
+
if (!result.timedOut && result.exitCode === 0) {
|
|
226
|
+
if (output.includes('outside of base path')) {
|
|
227
|
+
return hookResult(hookMessage('warning', `eslint skipped: ${file.filePath}\n\n`
|
|
228
|
+
+ `eslint did not lint the file because it judged the file to be outside its base path (talk root: ${talkRoot} / eslint argument: ${relative}). `
|
|
229
|
+
+ 'No lint ran, so violations in this file have not been detected.'));
|
|
230
|
+
}
|
|
231
|
+
if (output.includes('no matching configuration')) {
|
|
232
|
+
return notify(`eslint judged the file to be outside its configuration (eslint argument: ${relative} / talk root: ${talkRoot}). `
|
|
233
|
+
+ 'The path is a lint target, so the eslint config may be inconsistent.');
|
|
234
|
+
}
|
|
235
|
+
// node の警告などの未知の出力は、違反として報告しない。
|
|
236
|
+
return hookResult();
|
|
237
|
+
}
|
|
238
|
+
const isCrashed = output.includes(CRASH_BANNER);
|
|
239
|
+
if (!isCrashed && output !== '' && result.exitCode === 1 && !result.timedOut) {
|
|
240
|
+
const capped = capContext(CONTEXT_MAX_ESLINT, /^\s+\d+:\d+\s/, 'violations', output.replace(/^\s*\n/, ''));
|
|
241
|
+
return hookResult(hookMessage('warning', `eslint violations: ${file.filePath}\n\n${capped.body}\n\n`
|
|
242
|
+
+ `The output above lists the eslint violations in this file.${withNote(capped)}`));
|
|
243
|
+
}
|
|
244
|
+
const head = headLines(output);
|
|
245
|
+
return notify(`${eslintFailureReason(result, isCrashed)}.${head === '' ? '' : `\neslint output: ${head}`}`);
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
function eslintFailureReason(result, isCrashed) {
|
|
249
|
+
if (isCrashed)
|
|
250
|
+
return `eslint crashed (exit ${exitLabel(result)} / config resolution failure, plugin load failure, etc.)`;
|
|
251
|
+
if (result.timedOut)
|
|
252
|
+
return 'eslint timed out (over 30 seconds)';
|
|
253
|
+
if (result.exitCode === 2)
|
|
254
|
+
return 'eslint exited with a fatal error (exit 2 / config resolution failure, etc.)';
|
|
255
|
+
return `eslint exited abnormally (exit ${exitLabel(result)})`;
|
|
256
|
+
}
|
|
257
|
+
async function repositoryRoot(directory) {
|
|
258
|
+
if (!isDirectory(directory))
|
|
259
|
+
return undefined;
|
|
260
|
+
const result = await spawnPromise('git', ['-C', directory, 'rev-parse', '--show-toplevel'], { timeoutMs: GIT_TIMEOUT_MS });
|
|
261
|
+
const top = result.stdout.trim();
|
|
262
|
+
return top !== '' && result.exitCode === 0 ? top : undefined;
|
|
263
|
+
}
|
|
264
|
+
function textLintBin() {
|
|
265
|
+
return path.join(resolvePluginRoot(), 'vendor', 'text-rules', 'dist', 'bin', 'pecot-text-lint.js');
|
|
266
|
+
}
|
|
267
|
+
async function lintWithTextRules(file, cwd, call) {
|
|
268
|
+
const notify = (reason) => hookResult(hookMessage('warning', `text lint not run: ${file.filePath}\n${reason}\nThe writing rules were not applied to this file, so no violations were detected.`));
|
|
269
|
+
return guarded(notify, async () => {
|
|
270
|
+
const bin = textLintBin();
|
|
271
|
+
if (!isFile(bin))
|
|
272
|
+
return notify(`pecot-text-lint is missing (${bin}).\n${RECOVERY_LINE}`);
|
|
273
|
+
// bin は作業ディレクトリの .textlintignore を読むので、ファイルの属するリポのルートで動かす。
|
|
274
|
+
const runDirectory = await repositoryRoot(file.directory) ?? cwd;
|
|
275
|
+
const result = await spawnPromise(process.execPath, [bin, file.filePath], {
|
|
276
|
+
...(runDirectory !== undefined && isDirectory(runDirectory) && { cwd: runDirectory }),
|
|
277
|
+
timeoutMs: TEXT_LINT_TIMEOUT_MS,
|
|
278
|
+
signal: call.signal,
|
|
279
|
+
});
|
|
280
|
+
if (!result.timedOut && result.exitCode === 0)
|
|
281
|
+
return hookResult();
|
|
282
|
+
const output = result.stdout.replace(/\n+$/, '');
|
|
283
|
+
if (output !== '' && result.exitCode === 1 && !result.timedOut) {
|
|
284
|
+
const capped = capContext(CONTEXT_MAX_TEXT_LINT, /./, 'violations', output);
|
|
285
|
+
return hookResult(hookMessage('warning', `text lint violations: ${file.filePath}\n\n${capped.body}\n\n`
|
|
286
|
+
+ `The text above does not satisfy the writing rules. The rules stay enabled.${withNote(capped)}`));
|
|
287
|
+
}
|
|
288
|
+
if (result.timedOut)
|
|
289
|
+
return notify('pecot-text-lint timed out (over 20 seconds).');
|
|
290
|
+
const stderrHead = headLines(result.stderr.replace(/\n+$/, ''));
|
|
291
|
+
return notify(`pecot-text-lint failed (exit ${exitLabel(result)}):${stderrHead === '' ? '' : `\n${stderrHead}`}`);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
async function lintFile(input, call) {
|
|
295
|
+
const file = locateFile(input);
|
|
296
|
+
if (file === undefined)
|
|
297
|
+
return hookResult();
|
|
298
|
+
if (file.talkRoot !== undefined && file.relative !== undefined && isDeckLintTarget(file.relative)) {
|
|
299
|
+
return lintWithEslint(file, file.talkRoot, file.relative, call);
|
|
300
|
+
}
|
|
301
|
+
return lintWithTextRules(file, input.cwd, call);
|
|
302
|
+
}
|
|
303
|
+
// --- file_validate ---
|
|
304
|
+
const VALIDATOR_FOOTER = /^\d+ files checked, \d+ error\(s\) found\.$/;
|
|
305
|
+
async function validateFile(input, call) {
|
|
306
|
+
const file = locateFile(input);
|
|
307
|
+
if (file === undefined || !/\.ya?ml$/.test(file.filePath))
|
|
308
|
+
return hookResult();
|
|
309
|
+
const baseName = path.basename(file.filePath);
|
|
310
|
+
// validator が飛ばすファイル。検証されないのが正しい。
|
|
311
|
+
if (baseName === '_template.yaml')
|
|
312
|
+
return hookResult();
|
|
313
|
+
const { talkRoot } = file;
|
|
314
|
+
// 参照の dir の名前に "ref" を含む前提で、テーマを読む前に絞る(public/ などの yaml でテーマの知らせを出さない)。
|
|
315
|
+
if (talkRoot === undefined || !/[Rr]ef/.test(path.relative(talkRoot, file.directory)))
|
|
316
|
+
return hookResult();
|
|
317
|
+
const notify = (reason) => hookResult(hookMessage('warning', `references validation not run: ${file.filePath}\n${reason}\nNo validation ran for this file, so violations have not been detected.`));
|
|
318
|
+
return guarded(notify, async () => {
|
|
319
|
+
const assets = assetsDirectory();
|
|
320
|
+
const validator = path.join(assets, 'scripts', 'eslint', 'validate-references', 'dist', 'index.js');
|
|
321
|
+
if (!isFile(validator)) {
|
|
322
|
+
return notify('The validation environment is incomplete (missing: assets/slidev/scripts/eslint/validate-references/dist/index.js '
|
|
323
|
+
+ `/ assets: ${assets}).\n${RECOVERY_LINE}`);
|
|
324
|
+
}
|
|
325
|
+
const theme = await readThemeLint(talkRoot);
|
|
326
|
+
if (!theme.ok)
|
|
327
|
+
return notify(themeFailureLine(theme));
|
|
328
|
+
const physicalDirectory = physicalPath(file.directory);
|
|
329
|
+
const referencesDirectory = theme.lint.referencesDirectories.find(directory => physicalPath(directory) === physicalDirectory);
|
|
330
|
+
if (referencesDirectory === undefined)
|
|
331
|
+
return hookResult();
|
|
332
|
+
// validator は argv[1] と import.meta.url を比べて自己実行を判定するので、物理パスで渡す。
|
|
333
|
+
const result = await spawnPromise(process.execPath, [physicalPath(validator), '--dir', physicalDirectory], {
|
|
334
|
+
cwd: physicalPath(talkRoot),
|
|
335
|
+
timeoutMs: VALIDATOR_TIMEOUT_MS,
|
|
336
|
+
signal: call.signal,
|
|
337
|
+
});
|
|
338
|
+
const output = combinedOutput(result);
|
|
339
|
+
const lines = output.split('\n');
|
|
340
|
+
const footer = lines.findLast(line => VALIDATOR_FOOTER.test(line));
|
|
341
|
+
// validator は参照の dir の直下の *.yaml だけを読む。完走しても、編集したファイルを含まないことがある。
|
|
342
|
+
const isFileChecked = lines.includes(` ✓ ${baseName}`) || lines.includes(` ✗ ${baseName}`);
|
|
343
|
+
if (!result.timedOut && result.exitCode === 0) {
|
|
344
|
+
if (footer === undefined) {
|
|
345
|
+
return notify(`The validator exited with 0 but printed no completion footer (validator: ${validator}). The validation may not have run.`);
|
|
346
|
+
}
|
|
347
|
+
if (!isFileChecked) {
|
|
348
|
+
return notify(`The validator completed (${footer}), but ${baseName} is not among the validated files. `
|
|
349
|
+
+ 'The validator reads only *.yaml directly under the references dir (*.yml and subdirectories are excluded).');
|
|
350
|
+
}
|
|
351
|
+
return hookResult();
|
|
352
|
+
}
|
|
353
|
+
if (footer !== undefined && result.exitCode === 1 && !result.timedOut) {
|
|
354
|
+
const attribution = isFileChecked
|
|
355
|
+
? ''
|
|
356
|
+
: `\n${baseName} itself is not among the validated files (the validator reads only *.yaml directly under the references dir).`;
|
|
357
|
+
const categoryHint = output.includes('required property \'category\'')
|
|
358
|
+
? '\nA layout yaml without `category` takes an id from `layout_categories` in `_common.yaml`. '
|
|
359
|
+
+ 'Right after a theme update, relinking node_modules with slide_sync (node_modules_only: true) refreshes that vocabulary.'
|
|
360
|
+
: '';
|
|
361
|
+
const capped = capContext(CONTEXT_MAX_REFERENCES, /^ {4}\[/, 'violations', output);
|
|
362
|
+
return hookResult(hookMessage('warning', `references schema violations: ${footer}\n`
|
|
363
|
+
+ `This is the validation result for the whole references directory (edited file: ${file.filePath}).${attribution}\n\n`
|
|
364
|
+
+ `${capped.body}\n\nThe output above lists the schema violations.${categoryHint}${withNote(capped)}`));
|
|
365
|
+
}
|
|
366
|
+
const head = headLines(output);
|
|
367
|
+
return notify(`${validatorFailureReason(result, output)}.${head === '' ? '' : `\nvalidator output: ${head}`}`);
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
function validatorFailureReason(result, output) {
|
|
371
|
+
if (result.timedOut)
|
|
372
|
+
return 'The validator timed out (over 30 seconds)';
|
|
373
|
+
if (result.exitCode !== 1)
|
|
374
|
+
return `The validator exited abnormally (exit ${exitLabel(result)})`;
|
|
375
|
+
return output === ''
|
|
376
|
+
? 'The validator exited abnormally without output (exit 1 / failed cd to the talk root, etc.)'
|
|
377
|
+
: 'The validator crashed (exit 1 / no completion footer: broken dist, module resolution failure, missing target dir, etc.)';
|
|
378
|
+
}
|
|
379
|
+
function isSharedReferenceModule(value) {
|
|
380
|
+
return isRecord(value)
|
|
381
|
+
&& typeof value['extractFrontmatterText'] === 'function'
|
|
382
|
+
&& typeof value['parseFrontmatter'] === 'function'
|
|
383
|
+
&& typeof value['loadLayoutReference'] === 'function';
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
参照の YAML から、規約の項目の原文の行を抜き出す。トップレベルのキーの行から、次のトップレベルの要素の手前までを 1 ブロックにする。
|
|
387
|
+
*/
|
|
388
|
+
function sectionBlocks(source, reference) {
|
|
389
|
+
const lines = source.split('\n');
|
|
390
|
+
const blockAt = (start) => {
|
|
391
|
+
const next = lines.slice(start + 1).findIndex(line => /^\S/.test(line));
|
|
392
|
+
const picked = lines.slice(start, next === -1 ? lines.length : start + 1 + next);
|
|
393
|
+
while (picked.at(-1)?.trim() === '')
|
|
394
|
+
picked.pop();
|
|
395
|
+
return picked.join('\n');
|
|
396
|
+
};
|
|
397
|
+
const keys = new Set(Object.entries(reference).filter(([, value]) => value !== undefined).map(([key]) => key));
|
|
398
|
+
return LAYOUT_SECTION_KEYS.filter(key => keys.has(key))
|
|
399
|
+
.map(key => lines.findIndex(line => line.startsWith(`${key}:`)))
|
|
400
|
+
.filter(start => start !== -1)
|
|
401
|
+
.toSorted((a, b) => a - b)
|
|
402
|
+
.map(start => blockAt(start));
|
|
403
|
+
}
|
|
404
|
+
async function briefFile(input) {
|
|
405
|
+
const file = locateFile(input);
|
|
406
|
+
// slides.md は束ねる側なので対象外。判定装置ではないので、出せないときは何も知らせない。
|
|
407
|
+
if (file?.talkRoot === undefined || !isPagesMarkdown(file.relative))
|
|
408
|
+
return hookResult();
|
|
409
|
+
try {
|
|
410
|
+
const shared = path.join(assetsDirectory(), 'scripts', 'eslint', '_shared', 'dist', 'index.js');
|
|
411
|
+
if (!isFile(shared))
|
|
412
|
+
return hookResult();
|
|
413
|
+
const theme = await readThemeLint(file.talkRoot);
|
|
414
|
+
if (!theme.ok || theme.lint.referencesDirectories.length === 0)
|
|
415
|
+
return hookResult();
|
|
416
|
+
const directories = theme.lint.referencesDirectories;
|
|
417
|
+
const physicalDirectory = physicalPath(file.directory);
|
|
418
|
+
if (directories.some(directory => physicalPath(directory) === physicalDirectory))
|
|
419
|
+
return hookResult();
|
|
420
|
+
const module_ = await import(pathToFileURL(physicalPath(shared)).href);
|
|
421
|
+
if (!isSharedReferenceModule(module_))
|
|
422
|
+
return hookResult();
|
|
423
|
+
const source = readFileSync(file.filePath, 'utf8');
|
|
424
|
+
if (module_.extractFrontmatterText(source) === null)
|
|
425
|
+
return hookResult();
|
|
426
|
+
const frontmatter = module_.parseFrontmatter(source);
|
|
427
|
+
const layout = isRecord(frontmatter) ? frontmatter['layout'] : undefined;
|
|
428
|
+
// `../` と、`_template` などの内部ファイルを弾く。
|
|
429
|
+
if (typeof layout !== 'string' || !/^[a-z0-9][\w.-]*$/i.test(layout))
|
|
430
|
+
return hookResult();
|
|
431
|
+
const yamlPath = directories.map(directory => path.join(directory, `${layout}.yaml`)).find(candidate => existsSync(candidate));
|
|
432
|
+
if (yamlPath === undefined)
|
|
433
|
+
return hookResult();
|
|
434
|
+
const reference = module_.loadLayoutReference(directories, layout);
|
|
435
|
+
if (reference === null)
|
|
436
|
+
return hookResult();
|
|
437
|
+
const sections = sectionBlocks(readFileSync(yamlPath, 'utf8'), reference);
|
|
438
|
+
if (sections.length === 0)
|
|
439
|
+
return hookResult();
|
|
440
|
+
const capped = capContext(CONTEXT_MAX_LAYOUT, /./, 'lines', `${yamlPath}:\n\n${sections.join('\n\n')}`);
|
|
441
|
+
return hookResult(`${capped.body}${withNote(capped)}`);
|
|
442
|
+
}
|
|
443
|
+
catch {
|
|
444
|
+
return hookResult();
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
// --- 定義 ---
|
|
448
|
+
function fileTool(name, title, description, handle) {
|
|
449
|
+
return {
|
|
450
|
+
name,
|
|
451
|
+
isForHook: true,
|
|
452
|
+
config: {
|
|
453
|
+
title,
|
|
454
|
+
description,
|
|
455
|
+
inputSchema: fileInput,
|
|
456
|
+
outputSchema: fileOutput,
|
|
457
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
458
|
+
},
|
|
459
|
+
handler: async (arguments_, call) => {
|
|
460
|
+
const parsed = fileInput.safeParse(arguments_);
|
|
461
|
+
return parsed.success ? await handle(parsed.data, call) : hookResult();
|
|
462
|
+
},
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
const HOOK_NOTE = 'Called by the PostToolUse hook after Write and Edit. '
|
|
466
|
+
+ 'Returns {} when there is nothing to report, otherwise hookSpecificOutput.additionalContext. Never fails.';
|
|
467
|
+
/**
|
|
468
|
+
編集したファイルの lint。talk-dir の pages/**\/*.md と slides.md はテーマの規則の eslint、それ以外は文章規則。
|
|
469
|
+
*/
|
|
470
|
+
export const fileLintTool = fileTool('file_lint', 'Lint edited file', 'Lints a file that was just written or edited. Slide pages and slides.md in a talk-dir are linted with the theme rules (eslint); '
|
|
471
|
+
+ 'other files are checked with the writing rules (pecot-text-lint) from the root of their git repository. ' + HOOK_NOTE, lintFile);
|
|
472
|
+
/**
|
|
473
|
+
編集した参照の YAML を、テーマの参照の dir ごと validate-references で検証する。
|
|
474
|
+
*/
|
|
475
|
+
export const fileValidateTool = fileTool('file_validate', 'Validate reference yaml', 'Validates the reference yaml directory of a talk-dir when a yaml in it was edited, against the reference schema. '
|
|
476
|
+
+ 'Only directories listed in the theme lint.referencesDirectories are validated; _template.yaml is skipped. ' + HOOK_NOTE, validateFile);
|
|
477
|
+
/**
|
|
478
|
+
編集したページの layout に当たる参照の YAML から、status・best_practices・anti_patterns の原文を返す。
|
|
479
|
+
*/
|
|
480
|
+
export const fileBriefTool = fileTool('file_brief', 'Brief layout conventions', 'Returns the status, best_practices and anti_patterns sections, verbatim, of the reference yaml for the layout '
|
|
481
|
+
+ 'of an edited page under pages/ in a talk-dir, with the yaml path. It does not judge the page. ' + HOOK_NOTE, async (input) => briefFile(input));
|
|
482
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ToolDefinition } from '../server.js';
|
|
2
2
|
/**
|
|
3
|
-
tools/list に公開する
|
|
3
|
+
tools/list に公開する 14 ツール。並びはそのまま tools/list の並びになる。
|
|
4
4
|
*/
|
|
5
5
|
export declare function allTools(): readonly ToolDefinition[];
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
// 公開する
|
|
1
|
+
// 公開する 14 ツールの集約。系統別 8 ファイルの定義をここで 1 本の配列にまとめ、
|
|
2
2
|
// serve.ts が createMcpServer() へ渡す。
|
|
3
3
|
//
|
|
4
4
|
// 呼び出しごとに配列を組み直すのは、slide 系がツール定義をファクトリ関数で公開しているため。
|
|
5
5
|
// 既定 deps ファクトリの評価は各ハンドラ内に閉じている (module top-level では何も評価しない)。
|
|
6
|
-
// CLAUDE_PLUGIN_ROOT 未設定でも allTools() と tools/list が成功する、という受け入れ条件はこの構造で満たす。
|
|
7
6
|
import { drawioCreateTool, drawioExportTool } from './drawio.js';
|
|
8
7
|
import { evidenceCreateTool } from './evidence.js';
|
|
8
|
+
import { fileBriefTool, fileLintTool, fileValidateTool } from './file.js';
|
|
9
9
|
import { setupTool } from './setup.js';
|
|
10
10
|
import { slideTools } from './slide.js';
|
|
11
11
|
import { slideDevTool } from './slide-dev.js';
|
|
12
12
|
import { slidePageTool } from './slide-page.js';
|
|
13
13
|
import { slideThemeTool } from './slide-theme.js';
|
|
14
14
|
/**
|
|
15
|
-
tools/list に公開する
|
|
15
|
+
tools/list に公開する 14 ツール。並びはそのまま tools/list の並びになる。
|
|
16
16
|
*/
|
|
17
17
|
export function allTools() {
|
|
18
18
|
return [
|
|
@@ -24,6 +24,9 @@ export function allTools() {
|
|
|
24
24
|
drawioExportTool,
|
|
25
25
|
evidenceCreateTool,
|
|
26
26
|
setupTool(),
|
|
27
|
+
fileLintTool,
|
|
28
|
+
fileValidateTool,
|
|
29
|
+
fileBriefTool,
|
|
27
30
|
];
|
|
28
31
|
}
|
|
29
32
|
//# sourceMappingURL=index.js.map
|
|
@@ -101,8 +101,8 @@ signal) {
|
|
|
101
101
|
Chromium が起動するのに要る OS のライブラリを確認し、足りなければ入れる (#1217)。
|
|
102
102
|
|
|
103
103
|
実行ファイルの取得 (runChromiumStage) では OS のライブラリは入らない。本体は
|
|
104
|
-
infra/playwright/host-dependencies.ts
|
|
105
|
-
|
|
104
|
+
infra/playwright/host-dependencies.ts。
|
|
105
|
+
結果は印に記録する (失敗も期限付きで記録し、毎回の確認を避ける)。
|
|
106
106
|
MCP は stdout を JSON-RPC に使うため、apt-get 開始前の通知 (deps.notify) は既定のまま何も出さない。
|
|
107
107
|
*/
|
|
108
108
|
async function runHostDependenciesStage(dependencies,
|
|
@@ -129,7 +129,7 @@ signal) {
|
|
|
129
129
|
case 'launch-failed': {
|
|
130
130
|
// OS のライブラリ以外の原因 (実行ファイルの欠け等) は本段の担当外。
|
|
131
131
|
// 実行ファイルは runChromiumStage が揃えており、起動の失敗は各ツールが案内付きで返す。
|
|
132
|
-
//
|
|
132
|
+
// そのためここでは理由を残して通す。
|
|
133
133
|
dependencies.record('launch-failed');
|
|
134
134
|
return { ...base, installed: true, downloaded: false, detail: `could not launch Chromium (cause other than OS libraries): ${outcome.detail}` };
|
|
135
135
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// slide_dev ツール。talk-dir の Slidev dev サーバを起動し、ブラウザで開ける URL を返す。
|
|
2
|
-
// dev サーバの寿命が MCP
|
|
2
|
+
// dev サーバの寿命が MCP サーバに紐づく。実処理は src/mcp/dev-server-registry.ts。
|
|
3
3
|
// 参照するのは引数で受けた talk-dir と、その直下の固定名 (slides.md / node_modules) のみ。
|
|
4
4
|
/* eslint-disable security/detect-non-literal-fs-filename */
|
|
5
5
|
import { existsSync, statSync } from 'node:fs';
|
|
@@ -9,14 +9,13 @@ import { errorToReason as slideCreateErrorToReason } from '../../commands/slidev
|
|
|
9
9
|
import { ensureTalkThemeLinked, linkedThemeDefaultDependencies, } from '../../commands/slidev-project/linked-theme.js';
|
|
10
10
|
import { failureKindOf } from '../../domain/_shared/failure-kind.js';
|
|
11
11
|
import { pluginDependencyRoot } from '../../infra/_shared/dependency-root.js';
|
|
12
|
-
import { resolvePluginRoot } from '../../infra/_shared/plugin-root.js';
|
|
13
12
|
import { devServerRegistry } from '../dev-server-registry.js';
|
|
14
13
|
import { parsePathArguments, toCallToolResult } from '../result.js';
|
|
15
14
|
import { ensureRuntimeDependencies, MISSING_RUNTIME_OUTPUT_SHAPE, PATH_REJECTION_OUTPUT_SHAPE, runtimeDefaultDependencies, toolOutputFields, WINDOWS_PATH_NOTE, withCapturedOutput, } from './_shared.js';
|
|
16
15
|
// context に AbortSignal を持つため readonly にできない。
|
|
17
16
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
18
17
|
function ensureThemeLinkedWithDefaults(directory, context) {
|
|
19
|
-
return ensureTalkThemeLinked(directory, linkedThemeDefaultDependencies(pluginDependencyRoot()
|
|
18
|
+
return ensureTalkThemeLinked(directory, linkedThemeDefaultDependencies(pluginDependencyRoot(), context), { requireTheme: true });
|
|
20
19
|
}
|
|
21
20
|
function defaultEnsureThemeLinked() {
|
|
22
21
|
return ensureThemeLinkedWithDefaults;
|
|
@@ -132,8 +131,8 @@ export function slideDevTool(buildRegistry = devServerRegistry, buildRuntimeDepe
|
|
|
132
131
|
},
|
|
133
132
|
// 動いていないサーバへの停止要求は失敗にしない (呼び出しの目的は達成されている)。
|
|
134
133
|
message: stopped.stopped
|
|
135
|
-
? `
|
|
136
|
-
: `
|
|
134
|
+
? `slide_dev: stopped (${input.dir})`
|
|
135
|
+
: `slide_dev: no running server (${input.dir})`,
|
|
137
136
|
});
|
|
138
137
|
}
|
|
139
138
|
// 起動には @slidev/cli の bin が要る。未取得のときの失敗の型は
|
|
@@ -196,8 +195,8 @@ export function slideDevTool(buildRegistry = devServerRegistry, buildRuntimeDepe
|
|
|
196
195
|
...(warnings.length > 0 && { warnings }),
|
|
197
196
|
},
|
|
198
197
|
message: started.reused
|
|
199
|
-
? `
|
|
200
|
-
: `
|
|
198
|
+
? `slide_dev: reusing the running server ${started.url}`
|
|
199
|
+
: `slide_dev: started ${started.url}`,
|
|
201
200
|
});
|
|
202
201
|
};
|
|
203
202
|
return {
|
|
@@ -172,8 +172,8 @@ function isAlreadyExistsError(error) {
|
|
|
172
172
|
return typeof code === 'string' && code === 'EEXIST';
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
175
|
-
テーマの解決・宣言の失敗を、slide_page の失敗応答にする。reason は
|
|
176
|
-
|
|
175
|
+
テーマの解決・宣言の失敗を、slide_page の失敗応答にする。reason は slide_theme と同じ。
|
|
176
|
+
復旧の案内は、例外の文言が持つ。
|
|
177
177
|
*/
|
|
178
178
|
function themeFailure(error) {
|
|
179
179
|
return failure(slideThemeErrorToReason(error), formatError(error));
|
|
@@ -262,7 +262,7 @@ output) {
|
|
|
262
262
|
reference: referenceText,
|
|
263
263
|
includes: included.includes,
|
|
264
264
|
},
|
|
265
|
-
message: `
|
|
265
|
+
message: `slide_page: generated (${target})`
|
|
266
266
|
+ '; fill in the content following props / text_constraints in reference, '
|
|
267
267
|
+ `then register "src: ./pages/${file.filename}" in slides.md separately`,
|
|
268
268
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { SlideThemeDependencies } from '../../commands/slidev-project/theme.js';
|
|
2
2
|
import type { ToolDefinition } from '../server.js';
|
|
3
3
|
/**
|
|
4
|
-
`pecotv slide theme` 相当。
|
|
5
4
|
`theme`(名前・指定・宣言の有無・root)、`declaration`、`layouts`、`categories`、`lint`、`warnings` を返す。
|
|
6
5
|
*/
|
|
7
6
|
export declare function slideThemeTool(buildDependencies?: () => SlideThemeDependencies): ToolDefinition;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// slide_theme ツール。talk-dir
|
|
1
|
+
// slide_theme ツール。talk-dir が参照するテーマの宣言とレイアウトの一覧を返す。
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { errorToReason, executeSlideTheme, slideThemeDefaultDependencies, } from '../../commands/slidev-project/theme.js';
|
|
4
4
|
import { failureKindOf } from '../../domain/_shared/failure-kind.js';
|
|
@@ -54,7 +54,6 @@ const slideThemeShape = {
|
|
|
54
54
|
};
|
|
55
55
|
const slideThemeOutput = toolOutputFields(slideThemeShape, PATH_REJECTION_OUTPUT_SHAPE);
|
|
56
56
|
/**
|
|
57
|
-
`pecotv slide theme` 相当。
|
|
58
57
|
`theme`(名前・指定・宣言の有無・root)、`declaration`、`layouts`、`categories`、`lint`、`warnings` を返す。
|
|
59
58
|
*/
|
|
60
59
|
export function slideThemeTool(buildDependencies = slideThemeDefaultDependencies) {
|
|
@@ -80,7 +79,7 @@ export function slideThemeTool(buildDependencies = slideThemeDefaultDependencies
|
|
|
80
79
|
return toCallToolResult({
|
|
81
80
|
ok: true,
|
|
82
81
|
data: { ...data },
|
|
83
|
-
message: `
|
|
82
|
+
message: `slide_theme: ${data.theme.name} (${String(data.layouts.length)} layouts)`,
|
|
84
83
|
});
|
|
85
84
|
}
|
|
86
85
|
catch (error) {
|