@lorrylurui/code-intelligence-mcp 1.0.4 → 1.0.6
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/dist/indexer/indexProject.js +15 -4
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import fg from 'fast-glob';
|
|
5
5
|
import { join, resolve } from 'node:path';
|
|
6
6
|
import { Node, Project } from 'ts-morph';
|
|
7
|
-
import { readFileSync } from 'node:fs';
|
|
7
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
8
8
|
import { extractInterfaceOrTypeMeta, extractMetaFromCallable, } from './extractMeta.js';
|
|
9
9
|
import { getLeadingDocDescription, getRelativePathForDisplay, hasJsxInNode, inferCategoryFromPath, isSelectorLike, isTsxFile, snippetForNode, } from './heuristics.js';
|
|
10
10
|
import { parseJsFile } from './babelParser.js';
|
|
@@ -147,6 +147,15 @@ const DEFAULT_IGNORE = [
|
|
|
147
147
|
'**/dist/**',
|
|
148
148
|
'**/.git/**',
|
|
149
149
|
'**/coverage/**',
|
|
150
|
+
'**/build/**',
|
|
151
|
+
'**/.next/**',
|
|
152
|
+
'**/.nuxt/**',
|
|
153
|
+
'**/.output/**',
|
|
154
|
+
'**/vendor/**',
|
|
155
|
+
'**/.cache/**',
|
|
156
|
+
'**/.venv/**',
|
|
157
|
+
'**/dist-srv/**',
|
|
158
|
+
'**/.turbo/**',
|
|
150
159
|
];
|
|
151
160
|
/**
|
|
152
161
|
* 按 glob 收集文件,用 ts-morph 加载并遍历每个文件的导出,生成全部代码块行。
|
|
@@ -171,10 +180,12 @@ export async function indexProject(opts) {
|
|
|
171
180
|
const tsFiles = files.filter(isTsFile);
|
|
172
181
|
const jsFiles = files.filter(isJsFile);
|
|
173
182
|
const out = [];
|
|
174
|
-
// 处理 TS/TSX
|
|
175
|
-
|
|
183
|
+
// 处理 TS/TSX 文件(只有 tsconfig.json 存在时才处理)
|
|
184
|
+
const tsConfigPath = join(projectRoot, 'tsconfig.json');
|
|
185
|
+
const hasTsConfig = existsSync(tsConfigPath);
|
|
186
|
+
if (tsFiles.length > 0 && hasTsConfig) {
|
|
176
187
|
const project = new Project({
|
|
177
|
-
tsConfigFilePath:
|
|
188
|
+
tsConfigFilePath: tsConfigPath,
|
|
178
189
|
skipAddingFilesFromTsConfig: true,
|
|
179
190
|
skipFileDependencyResolution: true,
|
|
180
191
|
});
|