@chiway/contextweaver 1.1.0 → 1.5.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.
- package/README.md +138 -28
- package/dist/{SearchService-MYPOCM3B.js → SearchService-WVD6THR3.js} +170 -82
- package/dist/chunk-3BNHQV5W.js +373 -0
- package/dist/chunk-BFCIZ52F.js +102 -0
- package/dist/{chunk-NQR4CGQ6.js → chunk-GDVB6PJ4.js} +58 -10
- package/dist/{lock-DVY3KJSK.js → chunk-HHYPQA3X.js} +2 -3
- package/dist/chunk-ISVCQFB4.js +223 -0
- package/dist/chunk-IZ6IUHNN.js +77 -0
- package/dist/{chunk-AMQQK4P7.js → chunk-JVKVSTQ3.js} +1 -2
- package/dist/chunk-LB42CZEB.js +18 -0
- package/dist/{chunk-6Z4JEEVJ.js → chunk-PPLFJGO3.js} +303 -58
- package/dist/chunk-R6CNZXZ7.js +143 -0
- package/dist/{chunk-RJURH22T.js → chunk-SKBAE26T.js} +0 -1
- package/dist/chunk-TPM6YP43.js +38 -0
- package/dist/{chunk-7G5V7YT5.js → chunk-V3K4YVAR.js} +12 -120
- package/dist/chunk-VWBKZ6QL.js +115 -0
- package/dist/chunk-XFIM2T6S.js +57 -0
- package/dist/{chunk-6QMYML5V.js → chunk-XMZZZKG7.js} +361 -295
- package/dist/chunk-XTWNT7KP.js +156 -0
- package/dist/chunk-Y6H7C3NA.js +85 -0
- package/dist/codebaseRetrieval-DIS5RH2C.js +14 -0
- package/dist/{config-BWZ6CU3W.js → config-LCOJHTCF.js} +1 -2
- package/dist/db-GBCLP4GG.js +68 -0
- package/dist/findReferences-N7ML7TUP.js +16 -0
- package/dist/getSymbolDefinition-6KMY4H33.js +17 -0
- package/dist/index.js +271 -40
- package/dist/listFiles-4VT2TPJD.js +14 -0
- package/dist/loadConfig-XTVT2OWW.js +9 -0
- package/dist/lock-HNKQ6X5B.js +8 -0
- package/dist/scanner-QDFZJLP7.js +13 -0
- package/dist/server-UAI3U7AB.js +347 -0
- package/dist/stats-AGKUCJQI.js +12 -0
- package/dist/vectorStore-4ODCERRO.js +12 -0
- package/package.json +9 -23
- package/dist/codebaseRetrieval-NLAMGOA2.js +0 -12
- package/dist/scanner-RFG4YWYI.js +0 -11
- package/dist/server-27HI7WZO.js +0 -147
package/dist/index.js
CHANGED
|
@@ -1,36 +1,228 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
withLock
|
|
4
|
+
} from "./chunk-HHYPQA3X.js";
|
|
5
|
+
import {
|
|
6
|
+
initFilter,
|
|
7
|
+
isFiltered,
|
|
3
8
|
scan
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-GDVB6PJ4.js";
|
|
10
|
+
import "./chunk-XMZZZKG7.js";
|
|
11
|
+
import "./chunk-LB42CZEB.js";
|
|
12
|
+
import "./chunk-XFIM2T6S.js";
|
|
13
|
+
import "./chunk-3BNHQV5W.js";
|
|
14
|
+
import {
|
|
15
|
+
getDefaultEnvFileContent
|
|
16
|
+
} from "./chunk-TPM6YP43.js";
|
|
17
|
+
import "./chunk-BFCIZ52F.js";
|
|
6
18
|
import {
|
|
7
19
|
generateProjectId
|
|
8
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-PPLFJGO3.js";
|
|
9
21
|
import {
|
|
10
22
|
logger
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
23
|
+
} from "./chunk-JVKVSTQ3.js";
|
|
24
|
+
import "./chunk-SKBAE26T.js";
|
|
13
25
|
|
|
14
26
|
// src/index.ts
|
|
15
|
-
import { promises as
|
|
27
|
+
import { promises as fs2 } from "fs";
|
|
16
28
|
import os from "os";
|
|
17
|
-
import
|
|
29
|
+
import path3 from "path";
|
|
18
30
|
import { fileURLToPath } from "url";
|
|
19
31
|
import cac from "cac";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
32
|
+
|
|
33
|
+
// src/cli/mirrorCommands.ts
|
|
34
|
+
import path from "path";
|
|
35
|
+
function parseOptionalPositiveInt(value) {
|
|
36
|
+
if (!value) {
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
const parsed = Number.parseInt(value, 10);
|
|
40
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
|
|
41
|
+
}
|
|
42
|
+
async function writeResponse(response) {
|
|
43
|
+
const text = response.content.map((item) => item.text).join("\n");
|
|
44
|
+
process.stdout.write(`${text}
|
|
45
|
+
`);
|
|
46
|
+
}
|
|
47
|
+
function registerMirrorCommands(cli2) {
|
|
48
|
+
cli2.command("list-files [path]", "\u5217\u51FA\u5DF2\u7D22\u5F15\u6587\u4EF6\u7ED3\u6784\uFF08\u955C\u50CF MCP list-files\uFF09").option("--glob <pattern>", "\u8DEF\u5F84 glob \u8FC7\u6EE4").option("--language <language>", "\u8BED\u8A00\u8FC7\u6EE4").option("--max-results <n>", "\u6700\u591A\u8FD4\u56DE\u6570\u91CF").action(
|
|
49
|
+
async (targetPath, options) => {
|
|
50
|
+
const repoPath = targetPath ? path.resolve(targetPath) : process.cwd();
|
|
51
|
+
const { handleListFiles } = await import("./listFiles-4VT2TPJD.js");
|
|
52
|
+
const response = await handleListFiles({
|
|
53
|
+
repo_path: repoPath,
|
|
54
|
+
glob: options.glob,
|
|
55
|
+
language: options.language,
|
|
56
|
+
max_results: parseOptionalPositiveInt(options.maxResults)
|
|
57
|
+
});
|
|
58
|
+
await writeResponse(response);
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
cli2.command("definition <symbol>", "\u67E5\u770B\u7B26\u53F7\u5B9A\u4E49\uFF08\u955C\u50CF MCP get-symbol-definition\uFF09").option("-p, --path <path>", "\u9879\u76EE\u8DEF\u5F84\uFF08\u9ED8\u8BA4\u5F53\u524D\u76EE\u5F55\uFF09").option("--hint-path <path>", "\u7528\u4E8E\u540C\u540D\u5B9A\u4E49\u6D88\u6B67\u7684\u504F\u597D\u8DEF\u5F84").option("--max-results <n>", "\u6700\u591A\u8FD4\u56DE\u6570\u91CF").action(
|
|
62
|
+
async (symbol, options) => {
|
|
63
|
+
const repoPath = options.path ? path.resolve(options.path) : process.cwd();
|
|
64
|
+
const { handleGetSymbolDefinition } = await import("./getSymbolDefinition-6KMY4H33.js");
|
|
65
|
+
const response = await handleGetSymbolDefinition({
|
|
66
|
+
repo_path: repoPath,
|
|
67
|
+
symbol,
|
|
68
|
+
hint_path: options.hintPath,
|
|
69
|
+
max_results: parseOptionalPositiveInt(options.maxResults)
|
|
70
|
+
});
|
|
71
|
+
await writeResponse(response);
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
cli2.command("references <symbol>", "\u67E5\u770B\u7B26\u53F7\u5F15\u7528\uFF08\u955C\u50CF MCP find-references\uFF09").option("-p, --path <path>", "\u9879\u76EE\u8DEF\u5F84\uFF08\u9ED8\u8BA4\u5F53\u524D\u76EE\u5F55\uFF09").option("--exclude-definition", "\u6392\u9664\u5B9A\u4E49\u672C\u8EAB").option("--max-results <n>", "\u6700\u591A\u8FD4\u56DE\u6570\u91CF").action(
|
|
75
|
+
async (symbol, options) => {
|
|
76
|
+
const repoPath = options.path ? path.resolve(options.path) : process.cwd();
|
|
77
|
+
const { handleFindReferences } = await import("./findReferences-N7ML7TUP.js");
|
|
78
|
+
const response = await handleFindReferences({
|
|
79
|
+
repo_path: repoPath,
|
|
80
|
+
symbol,
|
|
81
|
+
exclude_definition: options.excludeDefinition,
|
|
82
|
+
max_results: parseOptionalPositiveInt(options.maxResults)
|
|
83
|
+
});
|
|
84
|
+
await writeResponse(response);
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/scanner/watcher.ts
|
|
90
|
+
import fs from "fs";
|
|
91
|
+
import path2 from "path";
|
|
92
|
+
function defaultWatchFactory(rootPath, options, callback) {
|
|
93
|
+
const watcher = fs.watch(rootPath, options, (eventType, fileName) => {
|
|
94
|
+
callback(eventType, fileName);
|
|
95
|
+
});
|
|
96
|
+
return {
|
|
97
|
+
close() {
|
|
98
|
+
watcher.close();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function normalizeRelativePath(fileName) {
|
|
103
|
+
if (!fileName) return null;
|
|
104
|
+
return fileName.replace(/\\/g, "/");
|
|
105
|
+
}
|
|
106
|
+
function createWatchCoordinator(rootPath, options) {
|
|
107
|
+
const { debounceMs, scanFn, shouldIgnore, watchFactory = defaultWatchFactory } = options;
|
|
108
|
+
let timer = null;
|
|
109
|
+
let watcher = null;
|
|
110
|
+
let started = false;
|
|
111
|
+
let closed = false;
|
|
112
|
+
let isScanning = false;
|
|
113
|
+
let rerunRequested = false;
|
|
114
|
+
const runScan = async () => {
|
|
115
|
+
if (closed) return;
|
|
116
|
+
if (isScanning) {
|
|
117
|
+
rerunRequested = true;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
isScanning = true;
|
|
121
|
+
try {
|
|
122
|
+
await scanFn();
|
|
123
|
+
} finally {
|
|
124
|
+
isScanning = false;
|
|
125
|
+
if (!closed && rerunRequested) {
|
|
126
|
+
rerunRequested = false;
|
|
127
|
+
void runScan();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const scheduleScan = () => {
|
|
132
|
+
if (closed) return;
|
|
133
|
+
if (timer) {
|
|
134
|
+
clearTimeout(timer);
|
|
135
|
+
}
|
|
136
|
+
timer = setTimeout(() => {
|
|
137
|
+
timer = null;
|
|
138
|
+
void runScan();
|
|
139
|
+
}, debounceMs);
|
|
140
|
+
};
|
|
141
|
+
const onWatchEvent = (_eventType, fileName) => {
|
|
142
|
+
const relativePath = normalizeRelativePath(fileName);
|
|
143
|
+
if (relativePath && shouldIgnore(relativePath)) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
scheduleScan();
|
|
147
|
+
};
|
|
148
|
+
return {
|
|
149
|
+
async start() {
|
|
150
|
+
if (started) return;
|
|
151
|
+
started = true;
|
|
152
|
+
watcher = watchFactory(rootPath, { recursive: true }, onWatchEvent);
|
|
153
|
+
await runScan();
|
|
154
|
+
},
|
|
155
|
+
close() {
|
|
156
|
+
closed = true;
|
|
157
|
+
if (timer) {
|
|
158
|
+
clearTimeout(timer);
|
|
159
|
+
timer = null;
|
|
160
|
+
}
|
|
161
|
+
watcher?.close();
|
|
162
|
+
watcher = null;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
async function startWatchMode(rootPath, options = {}) {
|
|
167
|
+
const absoluteRoot = path2.resolve(rootPath);
|
|
168
|
+
const projectId = generateProjectId(absoluteRoot);
|
|
169
|
+
const debounceMs = options.debounceMs ?? 500;
|
|
170
|
+
await initFilter(absoluteRoot);
|
|
171
|
+
const runLockedScan = async () => {
|
|
172
|
+
logger.info({ rootPath: absoluteRoot }, "watch: \u89E6\u53D1\u589E\u91CF\u626B\u63CF");
|
|
173
|
+
await withLock(
|
|
174
|
+
projectId,
|
|
175
|
+
"index",
|
|
176
|
+
async () => {
|
|
177
|
+
const stats = await scan(absoluteRoot, { vectorIndex: true });
|
|
178
|
+
logger.info(
|
|
179
|
+
{
|
|
180
|
+
added: stats.added,
|
|
181
|
+
modified: stats.modified,
|
|
182
|
+
deleted: stats.deleted,
|
|
183
|
+
unchanged: stats.unchanged,
|
|
184
|
+
skipped: stats.skipped,
|
|
185
|
+
errors: stats.errors
|
|
186
|
+
},
|
|
187
|
+
"watch: \u626B\u63CF\u5B8C\u6210"
|
|
188
|
+
);
|
|
189
|
+
},
|
|
190
|
+
10 * 60 * 1e3
|
|
191
|
+
);
|
|
192
|
+
};
|
|
193
|
+
const coordinator = createWatchCoordinator(absoluteRoot, {
|
|
194
|
+
debounceMs,
|
|
195
|
+
scanFn: runLockedScan,
|
|
196
|
+
shouldIgnore: (relativePath) => isFiltered(relativePath)
|
|
197
|
+
});
|
|
198
|
+
await coordinator.start();
|
|
199
|
+
logger.info({ rootPath: absoluteRoot, debounceMs }, "watch: \u6587\u4EF6\u76D1\u542C\u5DF2\u542F\u52A8\uFF0C\u6309 Ctrl+C \u505C\u6B62");
|
|
200
|
+
const shutdown = () => {
|
|
201
|
+
coordinator.close();
|
|
202
|
+
logger.info("watch: \u6587\u4EF6\u76D1\u542C\u5DF2\u505C\u6B62");
|
|
203
|
+
process.exit(0);
|
|
204
|
+
};
|
|
205
|
+
process.once("SIGINT", shutdown);
|
|
206
|
+
process.once("SIGTERM", shutdown);
|
|
207
|
+
await new Promise(() => {
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// src/index.ts
|
|
212
|
+
var __dirname = path3.dirname(fileURLToPath(import.meta.url));
|
|
213
|
+
var pkgPath = path3.resolve(__dirname, "../package.json");
|
|
214
|
+
var pkg = JSON.parse(await fs2.readFile(pkgPath, "utf-8"));
|
|
23
215
|
var cli = cac("contextweaver");
|
|
24
216
|
if (process.argv.includes("-v") || process.argv.includes("--version")) {
|
|
25
217
|
console.log(pkg.version);
|
|
26
218
|
process.exit(0);
|
|
27
219
|
}
|
|
28
220
|
cli.command("init", "\u521D\u59CB\u5316 ContextWeaver \u914D\u7F6E").action(async () => {
|
|
29
|
-
const configDir =
|
|
30
|
-
const envFile =
|
|
221
|
+
const configDir = path3.join(os.homedir(), ".contextweaver");
|
|
222
|
+
const envFile = path3.join(configDir, ".env");
|
|
31
223
|
logger.info("\u5F00\u59CB\u521D\u59CB\u5316 ContextWeaver...");
|
|
32
224
|
try {
|
|
33
|
-
await
|
|
225
|
+
await fs2.mkdir(configDir, { recursive: true });
|
|
34
226
|
logger.info(`\u521B\u5EFA\u914D\u7F6E\u76EE\u5F55: ${configDir}`);
|
|
35
227
|
} catch (err) {
|
|
36
228
|
const error = err;
|
|
@@ -41,32 +233,15 @@ cli.command("init", "\u521D\u59CB\u5316 ContextWeaver \u914D\u7F6E").action(asyn
|
|
|
41
233
|
logger.info(`\u914D\u7F6E\u76EE\u5F55\u5DF2\u5B58\u5728: ${configDir}`);
|
|
42
234
|
}
|
|
43
235
|
try {
|
|
44
|
-
await
|
|
236
|
+
await fs2.access(envFile);
|
|
45
237
|
logger.warn(`.env \u6587\u4EF6\u5DF2\u5B58\u5728: ${envFile}`);
|
|
46
238
|
logger.info("\u521D\u59CB\u5316\u5B8C\u6210\uFF01");
|
|
47
239
|
return;
|
|
48
240
|
} catch {
|
|
49
241
|
}
|
|
50
|
-
const defaultEnvContent =
|
|
51
|
-
|
|
52
|
-
# Embedding API \u914D\u7F6E\uFF08\u5FC5\u9700\uFF09
|
|
53
|
-
EMBEDDINGS_API_KEY=your-api-key-here
|
|
54
|
-
EMBEDDINGS_BASE_URL=https://api.siliconflow.cn/v1/embeddings
|
|
55
|
-
EMBEDDINGS_MODEL=BAAI/bge-m3
|
|
56
|
-
EMBEDDINGS_MAX_CONCURRENCY=10
|
|
57
|
-
EMBEDDINGS_DIMENSIONS=1024
|
|
58
|
-
|
|
59
|
-
# Reranker \u914D\u7F6E\uFF08\u5FC5\u9700\uFF09
|
|
60
|
-
RERANK_API_KEY=your-api-key-here
|
|
61
|
-
RERANK_BASE_URL=https://api.siliconflow.cn/v1/rerank
|
|
62
|
-
RERANK_MODEL=BAAI/bge-reranker-v2-m3
|
|
63
|
-
RERANK_TOP_N=20
|
|
64
|
-
|
|
65
|
-
# \u7D22\u5F15\u5FFD\u7565\u6A21\u5F0F\uFF08\u53EF\u9009\uFF0C\u9017\u53F7\u5206\u9694\uFF0C\u9ED8\u8BA4\u5DF2\u5305\u542B\u5E38\u89C1\u5FFD\u7565\u9879\uFF09
|
|
66
|
-
# IGNORE_PATTERNS=.venv,node_modules
|
|
67
|
-
`;
|
|
242
|
+
const defaultEnvContent = getDefaultEnvFileContent();
|
|
68
243
|
try {
|
|
69
|
-
await
|
|
244
|
+
await fs2.writeFile(envFile, defaultEnvContent);
|
|
70
245
|
logger.info(`\u521B\u5EFA .env \u6587\u4EF6: ${envFile}`);
|
|
71
246
|
} catch (err) {
|
|
72
247
|
const error = err;
|
|
@@ -79,7 +254,7 @@ RERANK_TOP_N=20
|
|
|
79
254
|
logger.info("\u521D\u59CB\u5316\u5B8C\u6210\uFF01");
|
|
80
255
|
});
|
|
81
256
|
cli.command("index [path]", "\u626B\u63CF\u4EE3\u7801\u5E93\u5E76\u5EFA\u7ACB\u7D22\u5F15").option("-f, --force", "\u5F3A\u5236\u91CD\u65B0\u7D22\u5F15").action(async (targetPath, options) => {
|
|
82
|
-
const rootPath = targetPath ?
|
|
257
|
+
const rootPath = targetPath ? path3.resolve(targetPath) : process.cwd();
|
|
83
258
|
const projectId = generateProjectId(rootPath);
|
|
84
259
|
logger.info(`\u5F00\u59CB\u626B\u63CF: ${rootPath}`);
|
|
85
260
|
logger.info(`\u9879\u76EE ID: ${projectId}`);
|
|
@@ -88,9 +263,9 @@ cli.command("index [path]", "\u626B\u63CF\u4EE3\u7801\u5E93\u5E76\u5EFA\u7ACB\u7
|
|
|
88
263
|
}
|
|
89
264
|
const startTime = Date.now();
|
|
90
265
|
try {
|
|
91
|
-
const { withLock } = await import("./lock-
|
|
266
|
+
const { withLock: withLock2 } = await import("./lock-HNKQ6X5B.js");
|
|
92
267
|
let lastLoggedPercent = 0;
|
|
93
|
-
const stats = await
|
|
268
|
+
const stats = await withLock2(
|
|
94
269
|
projectId,
|
|
95
270
|
"index",
|
|
96
271
|
async () => scan(rootPath, {
|
|
@@ -119,8 +294,23 @@ cli.command("index [path]", "\u626B\u63CF\u4EE3\u7801\u5E93\u5E76\u5EFA\u7ACB\u7
|
|
|
119
294
|
process.exit(1);
|
|
120
295
|
}
|
|
121
296
|
});
|
|
297
|
+
cli.command("watch [path]", "\u76D1\u542C\u6587\u4EF6\u53D8\u5316\u5E76\u81EA\u52A8\u6267\u884C\u589E\u91CF\u7D22\u5F15").option("--debounce <ms>", "\u9632\u6296\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF0C\u9ED8\u8BA4 500\uFF09").action(async (targetPath, options) => {
|
|
298
|
+
const rootPath = targetPath ? path3.resolve(targetPath) : process.cwd();
|
|
299
|
+
const debounceMs = options.debounce ? Number.parseInt(options.debounce, 10) : 500;
|
|
300
|
+
if (!Number.isFinite(debounceMs) || debounceMs < 0) {
|
|
301
|
+
logger.error("\u65E0\u6548\u7684 --debounce \u53C2\u6570\uFF0C\u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 0 \u7684\u6574\u6570");
|
|
302
|
+
process.exit(1);
|
|
303
|
+
}
|
|
304
|
+
try {
|
|
305
|
+
await startWatchMode(rootPath, { debounceMs });
|
|
306
|
+
} catch (err) {
|
|
307
|
+
const error = err;
|
|
308
|
+
logger.error({ err, stack: error.stack }, `watch \u6A21\u5F0F\u542F\u52A8\u5931\u8D25: ${error.message}`);
|
|
309
|
+
process.exit(1);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
122
312
|
cli.command("mcp", "\u542F\u52A8 MCP \u670D\u52A1\u5668").action(async () => {
|
|
123
|
-
const { startMcpServer } = await import("./server-
|
|
313
|
+
const { startMcpServer } = await import("./server-UAI3U7AB.js");
|
|
124
314
|
try {
|
|
125
315
|
await startMcpServer();
|
|
126
316
|
} catch (err) {
|
|
@@ -134,14 +324,14 @@ cli.command("mcp", "\u542F\u52A8 MCP \u670D\u52A1\u5668").action(async () => {
|
|
|
134
324
|
});
|
|
135
325
|
cli.command("search", "\u672C\u5730\u68C0\u7D22\uFF08\u53C2\u6570\u5BF9\u9F50 MCP\uFF09").option("--repo-path <path>", "\u4EE3\u7801\u5E93\u6839\u76EE\u5F55\uFF08\u9ED8\u8BA4\u5F53\u524D\u76EE\u5F55\uFF09").option("--information-request <text>", "\u81EA\u7136\u8BED\u8A00\u95EE\u9898\u63CF\u8FF0\uFF08\u5FC5\u586B\uFF09").option("--technical-terms <terms>", "\u7CBE\u786E\u672F\u8BED\uFF08\u9017\u53F7\u5206\u9694\uFF09").action(
|
|
136
326
|
async (options) => {
|
|
137
|
-
const repoPath = options.repoPath ?
|
|
327
|
+
const repoPath = options.repoPath ? path3.resolve(options.repoPath) : process.cwd();
|
|
138
328
|
const informationRequest = options.informationRequest;
|
|
139
329
|
if (!informationRequest) {
|
|
140
330
|
logger.error("\u7F3A\u5C11 --information-request");
|
|
141
331
|
process.exit(1);
|
|
142
332
|
}
|
|
143
333
|
const technicalTerms = (options.technicalTerms || "").split(",").map((t) => t.trim()).filter(Boolean);
|
|
144
|
-
const { handleCodebaseRetrieval } = await import("./codebaseRetrieval-
|
|
334
|
+
const { handleCodebaseRetrieval } = await import("./codebaseRetrieval-DIS5RH2C.js");
|
|
145
335
|
const response = await handleCodebaseRetrieval({
|
|
146
336
|
repo_path: repoPath,
|
|
147
337
|
information_request: informationRequest,
|
|
@@ -152,6 +342,47 @@ cli.command("search", "\u672C\u5730\u68C0\u7D22\uFF08\u53C2\u6570\u5BF9\u9F50 MC
|
|
|
152
342
|
`);
|
|
153
343
|
}
|
|
154
344
|
);
|
|
345
|
+
cli.command("migrate", "LanceDB \u8FC1\u79FB\u7BA1\u7406\uFF08CRIT-B/CRIT-C\uFF09").option("--reset", "\u6E05\u7A7A LanceDB chunks \u8868\u5E76\u91CD\u7F6E\u8FC1\u79FB\u72B6\u6001\uFF08\u7528\u4E8E\u89E3\u9664 aborted\uFF09").option("-p, --path <path>", "\u9879\u76EE\u8DEF\u5F84\uFF08\u9ED8\u8BA4\u5F53\u524D\u76EE\u5F55\uFF09").action(async (options) => {
|
|
346
|
+
const rootPath = options.path ? path3.resolve(options.path) : process.cwd();
|
|
347
|
+
const projectId = generateProjectId(rootPath);
|
|
348
|
+
const { initDb, getLanceDbMigrationState, setLanceDbMigrationState, clearAllVectorIndexHash } = await import("./db-GBCLP4GG.js");
|
|
349
|
+
const db = initDb(projectId);
|
|
350
|
+
const state = getLanceDbMigrationState(db);
|
|
351
|
+
logger.info({ projectId, state }, "\u5F53\u524D LanceDB \u8FC1\u79FB\u72B6\u6001");
|
|
352
|
+
if (!options.reset) {
|
|
353
|
+
logger.info("\u5982\u9700\u89E3\u9664 aborted \u72B6\u6001\uFF0C\u4F7F\u7528 --reset \u9009\u9879");
|
|
354
|
+
db.close();
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
if (state !== "aborted" && state !== "pending") {
|
|
358
|
+
logger.info(`\u72B6\u6001\u4E3A ${state ?? "\u672A\u8BBE\u7F6E"}\uFF0C\u65E0\u9700 reset`);
|
|
359
|
+
db.close();
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const { getVectorStore } = await import("./vectorStore-4ODCERRO.js");
|
|
363
|
+
const { getEmbeddingConfig } = await import("./config-LCOJHTCF.js");
|
|
364
|
+
const store = await getVectorStore(projectId, getEmbeddingConfig().dimensions);
|
|
365
|
+
await store.clear();
|
|
366
|
+
logger.info("LanceDB chunks \u8868\u5DF2\u6E05\u7A7A");
|
|
367
|
+
const cleared = clearAllVectorIndexHash(db);
|
|
368
|
+
logger.info({ cleared }, "vector_index_hash \u5DF2\u6E05\u7A7A");
|
|
369
|
+
setLanceDbMigrationState(db, "done");
|
|
370
|
+
logger.info("\u8FC1\u79FB\u72B6\u6001\u5DF2\u91CD\u7F6E\u4E3A done\u3002\u8BF7\u91CD\u65B0\u8FD0\u884C `contextweaver index` \u91CD\u5EFA\u7D22\u5F15\u3002");
|
|
371
|
+
db.close();
|
|
372
|
+
});
|
|
373
|
+
cli.command("stats", "\u67E5\u770B\u7D22\u5F15/\u641C\u7D22/\u5065\u5EB7\u7EDF\u8BA1").option("--json", "\u4EE5 JSON \u683C\u5F0F\u8F93\u51FA").option("-p, --path <path>", "\u9879\u76EE\u8DEF\u5F84\uFF08\u9ED8\u8BA4\u5F53\u524D\u76EE\u5F55\uFF09").action(async (options) => {
|
|
374
|
+
const rootPath = options.path ? path3.resolve(options.path) : process.cwd();
|
|
375
|
+
const projectId = generateProjectId(rootPath);
|
|
376
|
+
const { collectStats, renderStatsText } = await import("./stats-AGKUCJQI.js");
|
|
377
|
+
const report = await collectStats(projectId);
|
|
378
|
+
if (options.json) {
|
|
379
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}
|
|
380
|
+
`);
|
|
381
|
+
} else {
|
|
382
|
+
process.stdout.write(`${renderStatsText(report)}
|
|
383
|
+
`);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
registerMirrorCommands(cli);
|
|
155
387
|
cli.help();
|
|
156
388
|
cli.parse();
|
|
157
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
handleListFiles,
|
|
3
|
+
listFilesSchema
|
|
4
|
+
} from "./chunk-Y6H7C3NA.js";
|
|
5
|
+
import "./chunk-VWBKZ6QL.js";
|
|
6
|
+
import "./chunk-TPM6YP43.js";
|
|
7
|
+
import "./chunk-BFCIZ52F.js";
|
|
8
|
+
import "./chunk-PPLFJGO3.js";
|
|
9
|
+
import "./chunk-JVKVSTQ3.js";
|
|
10
|
+
import "./chunk-SKBAE26T.js";
|
|
11
|
+
export {
|
|
12
|
+
handleListFiles,
|
|
13
|
+
listFilesSchema
|
|
14
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
scan
|
|
3
|
+
} from "./chunk-GDVB6PJ4.js";
|
|
4
|
+
import "./chunk-XMZZZKG7.js";
|
|
5
|
+
import "./chunk-LB42CZEB.js";
|
|
6
|
+
import "./chunk-XFIM2T6S.js";
|
|
7
|
+
import "./chunk-3BNHQV5W.js";
|
|
8
|
+
import "./chunk-PPLFJGO3.js";
|
|
9
|
+
import "./chunk-JVKVSTQ3.js";
|
|
10
|
+
import "./chunk-SKBAE26T.js";
|
|
11
|
+
export {
|
|
12
|
+
scan
|
|
13
|
+
};
|