@pecot/visual-mcp 3.0.2-dev.44 → 3.0.2-dev.48
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/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pecot/visual-mcp",
|
|
3
|
-
"version": "3.0.2-dev.
|
|
3
|
+
"version": "3.0.2-dev.48",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@pecot/visual-mcp",
|
|
9
|
-
"version": "3.0.2-dev.
|
|
9
|
+
"version": "3.0.2-dev.48",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@cffnpwr/textlint-plugin-comments": "1.0.0",
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { TextlintKernelDescriptor } from '@textlint/kernel';
|
|
2
|
+
export type IgnoreCheck = (file: string) => Promise<boolean>;
|
|
2
3
|
export interface MainDependencies {
|
|
3
4
|
readonly descriptor: () => TextlintKernelDescriptor;
|
|
4
5
|
readonly readFile: (file: string) => Promise<string>;
|
|
5
6
|
readonly stdout: (text: string) => void;
|
|
6
7
|
readonly stderr: (text: string) => void;
|
|
8
|
+
readonly ignoreCheck: (descriptor: TextlintKernelDescriptor) => Promise<IgnoreCheck>;
|
|
7
9
|
}
|
|
10
|
+
export declare const IGNORE_FILE = ".textlintignore";
|
|
11
|
+
export declare function relativeToCwd(file: string, cwd: string): Promise<string | undefined>;
|
|
8
12
|
export declare const REAL_DEPS: MainDependencies;
|
|
9
13
|
export interface Arguments {
|
|
10
14
|
readonly commitMsg: boolean;
|
|
@@ -1,11 +1,46 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
1
|
+
import { readFile, realpath } from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { TextlintKernel } from '@textlint/kernel';
|
|
4
4
|
import { BYTE_ORDER_MARK } from './byte-order-mark.js';
|
|
5
5
|
import { buildDescriptor } from './descriptor.js';
|
|
6
6
|
import { oneLine, withoutSummary } from './findings.js';
|
|
7
|
+
// textlint の CLI と同じく、作業ディレクトリの .textlintignore を読む。
|
|
8
|
+
export const IGNORE_FILE = '.textlintignore';
|
|
9
|
+
function isOutside(relative) {
|
|
10
|
+
return relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative);
|
|
11
|
+
}
|
|
12
|
+
// 作業ディレクトリからの相対パス。外にあるときは undefined。
|
|
13
|
+
// 見かけのパスで外に出るときだけ、リンクを通った作業ディレクトリとみて実体どうしでそろえ直す。
|
|
14
|
+
export async function relativeToCwd(file, cwd) {
|
|
15
|
+
let relative = path.relative(cwd, path.resolve(cwd, file));
|
|
16
|
+
if (isOutside(relative)) {
|
|
17
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- 作業ディレクトリと、引数で渡されたファイルの親を解決する
|
|
18
|
+
const base = await realpath(cwd);
|
|
19
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- 同上
|
|
20
|
+
const directory = await realpath(path.dirname(path.resolve(cwd, file)));
|
|
21
|
+
relative = path.relative(base, path.join(directory, path.basename(file)));
|
|
22
|
+
}
|
|
23
|
+
return isOutside(relative) ? undefined : relative.split(path.sep).join('/');
|
|
24
|
+
}
|
|
25
|
+
// scanFilePath は除外の型を作業ディレクトリからの相対で照らすので、相対パスに直して渡す。
|
|
26
|
+
// textlint は --commit-msg では要らないので、ここで初めて読む。
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- textlint の型に合わせる
|
|
28
|
+
async function textlintIgnoreCheck(descriptor) {
|
|
29
|
+
const { createLinter } = await import('textlint');
|
|
30
|
+
const cwd = process.cwd();
|
|
31
|
+
const linter = createLinter({ descriptor, cwd, ignoreFilePath: IGNORE_FILE });
|
|
32
|
+
return async (file) => {
|
|
33
|
+
const relative = await relativeToCwd(file, cwd);
|
|
34
|
+
if (relative === undefined) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const result = await linter.scanFilePath(relative);
|
|
38
|
+
return result.status === 'ignored';
|
|
39
|
+
};
|
|
40
|
+
}
|
|
7
41
|
export const REAL_DEPS = {
|
|
8
42
|
descriptor: buildDescriptor,
|
|
43
|
+
ignoreCheck: textlintIgnoreCheck,
|
|
9
44
|
// eslint-disable-next-line security/detect-non-literal-fs-filename -- 引数で渡されたパスを読むのがコマンドの役割
|
|
10
45
|
readFile: async (file) => readFile(file, 'utf8'),
|
|
11
46
|
stdout: (text) => {
|
|
@@ -59,12 +94,20 @@ export async function main(argv, dependencies) {
|
|
|
59
94
|
const { commitMsg, files } = parseArgv(argv);
|
|
60
95
|
const descriptor = dependencies.descriptor();
|
|
61
96
|
const kernel = new TextlintKernel();
|
|
97
|
+
let isIgnored;
|
|
62
98
|
for (const file of files) {
|
|
63
99
|
current = file;
|
|
64
100
|
const extension = commitMsg ? '.md' : path.extname(file);
|
|
65
101
|
if (descriptor.findPluginDescriptorWithExt(extension) === undefined) {
|
|
66
102
|
continue;
|
|
67
103
|
}
|
|
104
|
+
// コミットメッセージはリポのファイルでないので、除外の一覧と照らさない。
|
|
105
|
+
if (!commitMsg) {
|
|
106
|
+
isIgnored ??= await dependencies.ignoreCheck(descriptor);
|
|
107
|
+
if (await isIgnored(file)) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
68
111
|
// kernel は本文の BOM を落として数えるので、plugin にも同じ本文を渡して位置をそろえる。
|
|
69
112
|
const original = await dependencies.readFile(file);
|
|
70
113
|
const text = original.replace(BYTE_ORDER_MARK, '');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
a77852f2ff8d5e80668bfe8a3a43841c7db474504aef77313b991e9858ce440b
|