@jokeran/frontend-code-skimmer 0.4.1 → 0.4.3
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 +97 -19
- package/dist/index.js +179 -150
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import*as K from'path';import K__default from'path';import
|
|
3
|
-
`&&e++;return e}function
|
|
4
|
-
`),
|
|
2
|
+
import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import*as K from'path';import K__default from'path';import Kr from'os';import*as Z from'fs';import Z__default from'fs';import qn,{createHash}from'crypto';import tr from'better-sqlite3';import Xr from'fast-glob';import {createRequire}from'module';import {z as z$1}from'zod';function Ve(i){switch(i){case "template_event":return "template_event";case "jsx_event":return "jsx_event";case "hook_call":return "hook_call";case "import_func":return "import_call";default:return "method_call"}}function k(i){return i.replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/_/g," ").replace(/-/g," ").toLowerCase().trim().replace(/\s+/g," ")}function ze(i,e){let t=i.length,n=e.length,r=Array.from({length:t+1},(s,o)=>Array.from({length:n+1},(a,c)=>o===0?c:c===0?o:0));for(let s=1;s<=t;s++)for(let o=1;o<=n;o++)i[s-1]===e[o-1]?r[s][o]=r[s-1][o-1]:r[s][o]=1+Math.min(r[s-1][o],r[s][o-1],r[s-1][o-1]);return r[t][n]}function Fe(i){return qn.createHash("md5").update(i).digest("hex")}function Ge(i){if(!i)return 0;let e=1;for(let t=0;t<i.length;t++)i[t]===`
|
|
3
|
+
`&&e++;return e}function ke(i,e){return i===e?`L${i}`:`L${i}-L${e}`}function de(i,e){return K__default.relative(e,i).replace(/\\/g,"/")}function De(i,e){if(!i)return e;try{return JSON.parse(i)}catch{return e}}function V(i,e){let t=i.split(`
|
|
4
|
+
`),r=e-1-1;for(;r>=0&&t[r].trim()==="";)r--;if(r<0||!t[r].trim().endsWith("*/"))return;let s=r;for(;s>0&&!t[s].trim().startsWith("/**");)s--;if(t[s].trim().startsWith("/**"))return t.slice(s,r+1).map(o=>o.replace(/^\s*\*\s?/,"").replace(/\/\*\*/,"").replace(/\*\//,"").trim()).filter(o=>o.length>0).join(" ")}function zt(i,e){let t=i.toLowerCase(),n=e.toLowerCase();if(t===n)return 100;if(n.includes(t)||t.includes(n))return 85;let r=ze(t,n),s=Math.max(t.length,n.length);if(s===0)return 100;let o=Math.max(0,100-r/s*100);return Math.round(o)}function be(i){return i.startsWith("use")&&i.length>3&&/[A-Z]/.test(i[3])}function Gt(i,e,t){if(t===0||t>3)return;let n=k(i).split(" "),r=k(e).split(" ");for(let s of n)for(let o of r){let a=ze(s,o);if(a>0&&a<=3&&s!==o)return `"${s}" \u53EF\u80FD\u662F "${o}" \u7684\u62FC\u5199\u9519\u8BEF (\u7F16\u8F91\u8DDD\u79BB=${a})`}}var Yn=[".ts",".tsx",".js",".jsx",".vue"],Zn=["index.ts","index.tsx","index.js","index.jsx","index.vue"];function Qn(i){return [...Yn.map(e=>`${i}${e}`),...Zn.map(e=>K.join(i,e))]}function Te(i){if(Z.existsSync(i))try{if(Z.statSync(i).isFile())return i}catch{}for(let e of Qn(i))if(Z.existsSync(e))return e;return i}var Et=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**","**/.nuxt/**","**/.next/**","**/__tests__/**","**/*.test.*","**/*.spec.*","**/*.min.js"],_t=["**/*.vue","**/*.js","**/*.jsx","**/*.ts","**/*.tsx"],Jt={storage:{localStorage:["setItem","getItem","removeItem","clear","key"],sessionStorage:["setItem","getItem","removeItem","clear","key"],cookie:["cookie"]},network:{axios:["get","post","put","delete","patch","request","create"],fetch:["fetch"],XMLHttpRequest:["open","send"],$http:["get","post","put","delete"]},router:{$router:["push","replace","go","back","forward"],$route:[],useRouter:[],useRoute:[],navigate:[],history:["push","replace","go"]},vuex:{$store:["commit","dispatch","getters","state"],useStore:[],store:["commit","dispatch"]},dom:{document:["querySelector","getElementById","createElement","addEventListener"],window:["addEventListener","removeEventListener","open","close"],$refs:[],$nextTick:[],nextTick:[]},event:{$emit:[],EventBus:["emit","on","off"],dispatchEvent:[],emit:[]},timer:{setTimeout:[],setInterval:[],clearTimeout:[],clearInterval:[],requestAnimationFrame:[]},i18n:{$t:[],useI18n:[],t:[],i18n:["t","tc","te"]}},Nt=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","activated","deactivated","errorCaptured"],Tt=["onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","onActivated","onDeactivated","onErrorCaptured","onRenderTracked","onRenderTriggered","onServerPrefetch"],Yt=["ref","reactive","shallowRef","shallowReactive","readonly"],Zt=["computed"],Qt=["watch","watchEffect","watchPostEffect","watchSyncEffect"],St=["useState","useReducer","useRef","useImperativeHandle"],xt=["useMemo","useCallback"],At=["useEffect","useLayoutEffect","useInsertionEffect"],en=["useContext","useDebugValue","useDeferredValue","useId","useSyncExternalStore","useTransition"],qe=".skimmer-index.db",tn=30,nn=4,rn=300;var er=[{version:1,description:"\u5EFA\u7ACB schema_version \u8868",statements:[`CREATE TABLE IF NOT EXISTS schema_version (
|
|
5
5
|
version INTEGER PRIMARY KEY,
|
|
6
6
|
applied_at INTEGER NOT NULL,
|
|
7
7
|
description TEXT
|
|
@@ -29,11 +29,16 @@ import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {StdioSer
|
|
|
29
29
|
kind TEXT NOT NULL,
|
|
30
30
|
line_number INTEGER NOT NULL,
|
|
31
31
|
text_snippet TEXT
|
|
32
|
-
)`,"CREATE INDEX IF NOT EXISTS idx_data_assign_name_lc ON data_assignments(symbol_name_lc)","CREATE INDEX IF NOT EXISTS idx_data_assign_file ON data_assignments(file_id)","CREATE INDEX IF NOT EXISTS idx_prop_writes_obj_lc ON property_writes(object_name_lc)","CREATE INDEX IF NOT EXISTS idx_prop_writes_file ON property_writes(file_id)"]},{version:8,description:"Phase 5: files \u8868\u589E\u52A0 export_signature_hash \u548C import_signature_hash\uFF0C\u652F\u6491\u9009\u62E9\u6027 precise \u91CD\u7B97",statements:["ALTER TABLE files ADD COLUMN export_signature_hash TEXT DEFAULT ''","ALTER TABLE files ADD COLUMN import_signature_hash TEXT DEFAULT ''"]},{version:9,description:"Phase 3 \u4FEE\u6B63\uFF1Adata_assignments / property_writes \u6301\u4E45\u5316 source_layer",statements:["ALTER TABLE data_assignments ADD COLUMN source_layer TEXT NOT NULL DEFAULT 'unknown'","ALTER TABLE property_writes ADD COLUMN source_layer TEXT NOT NULL DEFAULT 'unknown'"]}
|
|
32
|
+
)`,"CREATE INDEX IF NOT EXISTS idx_data_assign_name_lc ON data_assignments(symbol_name_lc)","CREATE INDEX IF NOT EXISTS idx_data_assign_file ON data_assignments(file_id)","CREATE INDEX IF NOT EXISTS idx_prop_writes_obj_lc ON property_writes(object_name_lc)","CREATE INDEX IF NOT EXISTS idx_prop_writes_file ON property_writes(file_id)"]},{version:8,description:"Phase 5: files \u8868\u589E\u52A0 export_signature_hash \u548C import_signature_hash\uFF0C\u652F\u6491\u9009\u62E9\u6027 precise \u91CD\u7B97",statements:["ALTER TABLE files ADD COLUMN export_signature_hash TEXT DEFAULT ''","ALTER TABLE files ADD COLUMN import_signature_hash TEXT DEFAULT ''"]},{version:9,description:"Phase 3 \u4FEE\u6B63\uFF1Adata_assignments / property_writes \u6301\u4E45\u5316 source_layer",statements:["ALTER TABLE data_assignments ADD COLUMN source_layer TEXT NOT NULL DEFAULT 'unknown'","ALTER TABLE property_writes ADD COLUMN source_layer TEXT NOT NULL DEFAULT 'unknown'"]},{version:10,description:"\u6301\u4E45\u5316\u7D22\u5F15\u5931\u8D25\u6587\u4EF6\u4E0E\u9519\u8BEF\u4FE1\u606F\uFF0C\u4F9B index_health \u4E0E\u6392\u969C\u4F7F\u7528",statements:[`CREATE TABLE IF NOT EXISTS index_failures (
|
|
33
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
34
|
+
file_path TEXT NOT NULL,
|
|
35
|
+
error TEXT NOT NULL,
|
|
36
|
+
last_seen_at INTEGER NOT NULL
|
|
37
|
+
)`,"CREATE INDEX IF NOT EXISTS idx_index_failures_file ON index_failures(file_path)","CREATE INDEX IF NOT EXISTS idx_index_failures_seen ON index_failures(last_seen_at DESC)"]}];function sn(i){let e=[],t=[];i.exec(`CREATE TABLE IF NOT EXISTS schema_version (
|
|
33
38
|
version INTEGER PRIMARY KEY,
|
|
34
39
|
applied_at INTEGER NOT NULL,
|
|
35
40
|
description TEXT
|
|
36
|
-
)`);let n=
|
|
41
|
+
)`);let n=i.prepare("SELECT MAX(version) as v FROM schema_version").get()?.v??0;for(let r of er){if(r.version<=n)continue;let s=Date.now(),o=true;for(let a of r.statements)try{i.exec(a);}catch(c){let l=String(c);if(l.includes("duplicate column name"))continue;t.push(`v${r.version}: ${l.slice(0,120)}`),o=false;}i.prepare("INSERT OR REPLACE INTO schema_version (version, applied_at, description) VALUES (?, ?, ?)").run(r.version,s,o?r.description:`${r.description} (\u90E8\u5206\u8BED\u53E5\u8DF3\u8FC7)`),e.push(r.version);}return {applied:e,errors:t}}function rr(i,e){let t=K__default.posix.dirname(e),n=t==="."?[]:t.split("/").map(()=>"..");return K__default.resolve(K__default.dirname(i),...n)}function sr(i,e,t){if(!i)return i;if(K__default.isAbsolute(i)){let n=de(Te(i),t);return n.startsWith("..")?i.replace(/\\/g,"/"):n}if(i.startsWith(".")){let n=Te(K__default.resolve(K__default.dirname(e),i)),r=de(n,t);return r.startsWith("..")?i.replace(/\\/g,"/"):r}if(i.startsWith("@/")){let n=Te(K__default.resolve(t,"src",i.slice(2))),r=de(n,t);return r.startsWith("..")?i.replace(/\\/g,"/"):r}return i.replace(/\\/g,"/")}var Je=class{db;constructor(e,t){let n=t||K__default.join(e,qe);Z__default.mkdirSync(K__default.dirname(n),{recursive:true}),this.db=new tr(n),this.initialize();}initialize(){this.db.pragma("journal_mode = WAL"),this.db.pragma("foreign_keys = ON"),this.db.pragma("synchronous = NORMAL"),this.db.exec(`
|
|
37
42
|
-- \u6587\u4EF6\u5143\u4FE1\u606F
|
|
38
43
|
CREATE TABLE IF NOT EXISTS files (
|
|
39
44
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
@@ -167,11 +172,18 @@ import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {StdioSer
|
|
|
167
172
|
line_number INTEGER NOT NULL DEFAULT 0
|
|
168
173
|
);
|
|
169
174
|
|
|
175
|
+
CREATE TABLE IF NOT EXISTS index_failures (
|
|
176
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
177
|
+
file_path TEXT NOT NULL,
|
|
178
|
+
error TEXT NOT NULL,
|
|
179
|
+
last_seen_at INTEGER NOT NULL
|
|
180
|
+
);
|
|
181
|
+
|
|
170
182
|
-- \u7D22\u5F15\uFF08\u4EC5\u4FDD\u7559\u65E7\u5217\u7D22\u5F15\u2014\u2014\u65B0\u5217\u7D22\u5F15\u5728 migration \u4E4B\u540E\u521B\u5EFA\uFF09
|
|
171
183
|
CREATE INDEX IF NOT EXISTS idx_symbols_name ON symbols(name);
|
|
172
184
|
CREATE INDEX IF NOT EXISTS idx_symbols_framework ON symbols(framework);
|
|
173
185
|
CREATE INDEX IF NOT EXISTS idx_behaviors_file ON behaviors(file_id);
|
|
174
|
-
`);let{applied:e,errors:t}=
|
|
186
|
+
`);let{applied:e,errors:t}=sn(this.db);e.length>0&&process.stderr.write(`[Frontend-Code-Skimmer] \u6570\u636E\u5E93\u8FC1\u79FB\u5B8C\u6210: v${e.join(", v")}
|
|
175
187
|
`),t.length>0&&process.stderr.write(`[Frontend-Code-Skimmer] \u8FC1\u79FB\u8B66\u544A: ${t.join("; ")}
|
|
176
188
|
`),this.db.exec(`
|
|
177
189
|
CREATE INDEX IF NOT EXISTS idx_behaviors_api_lc ON behaviors(api_name_lc, operation_lc);
|
|
@@ -184,6 +196,8 @@ import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {StdioSer
|
|
|
184
196
|
CREATE INDEX IF NOT EXISTS idx_data_assign_file ON data_assignments(file_id);
|
|
185
197
|
CREATE INDEX IF NOT EXISTS idx_prop_writes_obj_lc ON property_writes(object_name_lc);
|
|
186
198
|
CREATE INDEX IF NOT EXISTS idx_prop_writes_file ON property_writes(file_id);
|
|
199
|
+
CREATE INDEX IF NOT EXISTS idx_index_failures_file ON index_failures(file_path);
|
|
200
|
+
CREATE INDEX IF NOT EXISTS idx_index_failures_seen ON index_failures(last_seen_at DESC);
|
|
187
201
|
|
|
188
202
|
CREATE VIRTUAL TABLE IF NOT EXISTS relations_fts USING fts5(
|
|
189
203
|
args,
|
|
@@ -211,74 +225,80 @@ import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {StdioSer
|
|
|
211
225
|
INSERT INTO relations_fts(rowid, args)
|
|
212
226
|
VALUES (new.id, new.args);
|
|
213
227
|
END;
|
|
214
|
-
`);}saveParseResult(e,t,n,s,
|
|
228
|
+
`);}saveParseResult(e,t,n,r,s,o,a=0,c="",l=""){let p=K__default.extname(t).slice(1),d=rr(t,n);this.db.transaction(()=>{this.clearIndexFailures(n);let f=this.db.prepare("SELECT id FROM files WHERE path = ?").get(n),m;f?(m=f.id,this.db.prepare("DELETE FROM symbols WHERE file_id = ?").run(m),this.db.prepare(`
|
|
215
229
|
UPDATE files SET
|
|
216
230
|
abs_path = ?, framework = ?, content_hash = ?,
|
|
217
231
|
last_indexed_at = ?, file_size = ?, line_count = ?, file_mtime = ?,
|
|
218
232
|
path_lc = LOWER(?),
|
|
219
233
|
export_signature_hash = ?, import_signature_hash = ?
|
|
220
234
|
WHERE id = ?
|
|
221
|
-
`).run(t,e.framework,
|
|
235
|
+
`).run(t,e.framework,r,Date.now(),s,o,a,n,c,l,m)):m=this.db.prepare(`
|
|
222
236
|
INSERT INTO files (path, path_lc, abs_path, file_type, framework, content_hash, last_indexed_at, file_size, line_count, file_mtime, export_signature_hash, import_signature_hash)
|
|
223
237
|
VALUES (?, LOWER(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
224
|
-
`).run(n,n,t,
|
|
238
|
+
`).run(n,n,t,p,e.framework,r,Date.now(),s,o,a,c,l).lastInsertRowid;let g=this.db.prepare(`
|
|
225
239
|
INSERT INTO symbols (file_id, name, name_lc, category, category_lc, framework, start_line, end_line,
|
|
226
240
|
signature, params_json, default_value, camel_words, jsdoc,
|
|
227
241
|
is_async, hook_deps_json, state_setter_name, parent_component)
|
|
228
242
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
229
|
-
`),
|
|
243
|
+
`),y=new Map,b=new Map,T=_=>_.internalKey||`${_.name}:${_.startLine}:${_.endLine}`,h=(_,x)=>{y.set(T(_),x);let A=b.get(_.name)||[];A.push({id:x,name:_.name,startLine:_.startLine,endLine:_.endLine}),b.set(_.name,A);},E=(_,x,A)=>{if(A&&y.has(A))return y.get(A);let w=b.get(_)||[];if(w.length===0)return;if(w.length===1||x==null)return w[0]?.id;let M=w.filter(O=>O.startLine<=x&&x<=O.endLine);return M.length===1?M[0].id:M.length>1?M.sort((O,B)=>O.endLine-O.startLine-(B.endLine-B.startLine)||Math.abs(O.startLine-x)-Math.abs(B.startLine-x))[0]?.id:w.slice().sort((O,B)=>Math.abs(O.startLine-x)-Math.abs(B.startLine-x)||O.endLine-O.startLine-(B.endLine-B.startLine))[0]?.id};for(let _ of e.symbols){let A=_.camelWords||k(_.name),w=_.name.toLowerCase(),M=_.category.toLowerCase(),O=g.run(m,_.name,w,_.category,M,_.framework,_.startLine,_.endLine,_.signature||null,_.params?JSON.stringify(_.params):null,_.defaultValue||null,A,_.jsdoc||null,_.isAsync?1:0,_.hookDeps?JSON.stringify(_.hookDeps):null,_.stateSetterName||null,_.parentComponent||null);h(_,O.lastInsertRowid);}let N=this.db.prepare(`
|
|
230
244
|
INSERT INTO relations (caller_id, callee_name, callee_name_lc, call_type, line_number, args,
|
|
231
245
|
source_kind, import_source, receiver_token, edge_kind)
|
|
232
246
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
233
|
-
`);for(let _ of e.relations){let x=
|
|
247
|
+
`);for(let _ of e.relations){let x=E(_.callerName,_.callerLine,_.callerKey);if(x){let A=_.sourceKind||Ve(_.callType);N.run(x,_.calleeName,_.calleeName.toLowerCase(),_.callType,_.line,_.args||null,A,_.importSource||null,_.receiverToken||null,_.edgeKind||"heuristic");}}if(this.db.prepare("DELETE FROM data_assignments WHERE file_id = ?").run(m),e.assignments?.length){let _=this.db.prepare(`
|
|
234
248
|
INSERT INTO data_assignments (symbol_name, symbol_name_lc, file_id, kind, source_layer, line_number, text_snippet)
|
|
235
249
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
236
|
-
`);for(let x of e.assignments)_.run(x.symbolName,x.symbolName.toLowerCase(),
|
|
250
|
+
`);for(let x of e.assignments)_.run(x.symbolName,x.symbolName.toLowerCase(),m,x.kind,x.sourceLayer||"unknown",x.line,x.text);}if(this.db.prepare("DELETE FROM property_writes WHERE file_id = ?").run(m),e.propertyWrites?.length){let _=this.db.prepare(`
|
|
237
251
|
INSERT INTO property_writes (object_name, object_name_lc, property_name, property_name_lc, file_id, kind, source_layer, line_number, text_snippet)
|
|
238
252
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
239
|
-
`);for(let x of e.propertyWrites)_.run(x.objectName,x.objectName.toLowerCase(),x.propertyName||null,x.propertyName?.toLowerCase()||"",
|
|
253
|
+
`);for(let x of e.propertyWrites)_.run(x.objectName,x.objectName.toLowerCase(),x.propertyName||null,x.propertyName?.toLowerCase()||"",m,x.kind,x.sourceLayer||"unknown",x.line,x.text);}if(this.db.prepare("DELETE FROM file_dependencies WHERE from_file = ?").run(n),e.fileDependencies?.length){let _=this.db.prepare(`
|
|
240
254
|
INSERT INTO file_dependencies (from_file, to_file, dependency_kind, line_number)
|
|
241
255
|
VALUES (?, ?, ?, ?)
|
|
242
|
-
`);for(let x of e.fileDependencies)_.run(n,
|
|
256
|
+
`);for(let x of e.fileDependencies)_.run(n,sr(x.toFile,t,d),x.dependencyKind,x.line);}let R=this.db.prepare(`
|
|
243
257
|
INSERT INTO behaviors (symbol_id, file_id, category, api_name, api_name_lc, operation, operation_lc, detail, detail_lc, line_number)
|
|
244
258
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
245
|
-
`);for(let _ of e.behaviors){let x=
|
|
259
|
+
`);for(let _ of e.behaviors){let x=E(_.symbolName,_.line,_.symbolKey);if(x){let A=_.detail||null;R.run(x,m,_.category,_.apiName,_.apiName.toLowerCase(),_.operation,_.operation.toLowerCase(),A,A?.toLowerCase()??"",_.line);}}if(e.errors?.length){let _=this.db.prepare(`
|
|
260
|
+
INSERT INTO index_failures (file_path, error, last_seen_at)
|
|
261
|
+
VALUES (?, ?, ?)
|
|
262
|
+
`),x=Date.now();for(let A of e.errors)_.run(n,A,x);}})();}recordIndexFailure(e,t){this.clearIndexFailures(e),this.db.prepare(`
|
|
263
|
+
INSERT INTO index_failures (file_path, error, last_seen_at)
|
|
264
|
+
VALUES (?, ?, ?)
|
|
265
|
+
`).run(e,t,Date.now());}clearIndexFailures(e){this.db.prepare("DELETE FROM index_failures WHERE file_path = ?").run(e);}getFileHash(e){return this.db.prepare("SELECT content_hash FROM files WHERE path = ?").get(e)?.content_hash??null}getFileMeta(e){let t=this.db.prepare("SELECT content_hash, file_mtime, file_size FROM files WHERE path = ?").get(e);return t?{hash:t.content_hash,mtime:t.file_mtime??0,fileSize:t.file_size??0}:null}updateFileMtime(e,t){this.db.prepare("UPDATE files SET file_mtime = ? WHERE path = ?").run(t,e);}getFileSignatures(e){let t=this.db.prepare("SELECT content_hash, export_signature_hash, import_signature_hash FROM files WHERE path = ?").get(e);return t?{contentHash:t.content_hash,exportSignatureHash:t.export_signature_hash||"",importSignatureHash:t.import_signature_hash||""}:null}getReverseDependencies(e){return this.db.prepare("SELECT from_file FROM file_dependencies WHERE to_file = ? AND dependency_kind IN ('import', 're_export')").all(e).map(n=>n.from_file)}getReverseDependencyMap(){let e=this.db.prepare("SELECT from_file, to_file FROM file_dependencies WHERE dependency_kind IN ('import', 're_export')").all(),t=new Map;for(let{from_file:n,to_file:r}of e){let s=t.get(r)||[];s.push(n),t.set(r,s);}return t}getAllFilePaths(){return this.db.prepare("SELECT path FROM files ORDER BY path").all().map(t=>t.path)}getFileHashAndMtime(e){let t=this.db.prepare("SELECT content_hash, file_mtime FROM files WHERE path = ?").get(e);return t?{contentHash:t.content_hash,mtime:t.file_mtime??0}:null}deleteFile(e){this.db.prepare("DELETE FROM file_dependencies WHERE from_file = ? OR to_file = ?").run(e,e),this.clearIndexFailures(e),this.db.prepare("DELETE FROM files WHERE path = ?").run(e);}getFileOutline(e){let t=this.db.prepare("SELECT * FROM files WHERE path = ?").get(e);if(!t)return {file:void 0,symbols:[],behaviors:[]};let n=t.id,r=this.db.prepare(`
|
|
246
266
|
SELECT s.*, f.path as file_path
|
|
247
267
|
FROM symbols s JOIN files f ON s.file_id = f.id
|
|
248
268
|
WHERE s.file_id = ?
|
|
249
269
|
ORDER BY s.start_line ASC
|
|
250
|
-
`).all(n),
|
|
270
|
+
`).all(n),s=this.db.prepare(`
|
|
251
271
|
SELECT b.*, s.name as symbol_name
|
|
252
272
|
FROM behaviors b JOIN symbols s ON b.symbol_id = s.id
|
|
253
273
|
WHERE b.file_id = ?
|
|
254
|
-
`).all(n);return {file:t,symbols:
|
|
274
|
+
`).all(n);return {file:t,symbols:r,behaviors:s}}listFiles(e){let t="SELECT path, abs_path, framework, line_count FROM files",n=[];return e&&(t+=" WHERE path_lc LIKE ?",n.push(`%${e.toLowerCase()}%`)),t+=" ORDER BY path",this.db.prepare(t).all(...n)}exactSearch(e,t,n,r){let s=`
|
|
255
275
|
SELECT s.*, f.path as file_path, f.abs_path
|
|
256
276
|
FROM symbols s JOIN files f ON s.file_id = f.id
|
|
257
277
|
WHERE s.name_lc = ?
|
|
258
|
-
`,
|
|
278
|
+
`,o=[e.toLowerCase()];return t&&(s+=" AND s.category_lc = ?",o.push(t.toLowerCase())),n&&(s+=" AND s.framework = ?",o.push(n)),r&&(s+=" AND f.path_lc LIKE ?",o.push(`%${r.toLowerCase()}%`)),s+=" LIMIT 30",this.db.prepare(s).all(...o)}ftsSearch(e,t,n,r,s=20,o=true){let a=Math.max(1,Math.min(200,s)),l=e.replace(/[^\w\u4e00-\u9fa5\s]/g," ").trim().split(/\s+/).filter(p=>p.length>=2);if(l.length>0){let p=l.map(d=>`${d}*`).join(" ");try{let d=`
|
|
259
279
|
SELECT s.*, f.path as file_path, f.abs_path,
|
|
260
280
|
bm25(symbols_fts, 10.0, 1.0, 0.5, 0.5) as fts_rank
|
|
261
281
|
FROM symbols_fts
|
|
262
282
|
JOIN symbols s ON symbols_fts.rowid = s.id
|
|
263
283
|
JOIN files f ON s.file_id = f.id
|
|
264
284
|
WHERE symbols_fts MATCH ?
|
|
265
|
-
`,
|
|
285
|
+
`,u=[p];return t&&(d+=" AND s.category_lc = ?",u.push(t.toLowerCase())),n&&(d+=" AND s.framework = ?",u.push(n)),r&&(d+=" AND f.path_lc LIKE ?",u.push(`%${r.toLowerCase()}%`)),d+=` ORDER BY fts_rank LIMIT ${a}`,this.db.prepare(d).all(...u)}catch{if(o)return []}}return o?[]:this.ftsLikeFallback(e,t,n,r,a)}ftsSearchWithFallback(e,t,n,r,s=20){return this.ftsSearch(e,t,n,r,s,false)}ftsLikeFallback(e,t,n,r,s=20){let o=e.toLowerCase().replace(/[\\%_]/g,"\\$&"),a=`
|
|
266
286
|
SELECT s.*, f.path as file_path, f.abs_path, 0 as fts_rank
|
|
267
287
|
FROM symbols s JOIN files f ON s.file_id = f.id
|
|
268
288
|
WHERE (s.name_lc LIKE ? OR LOWER(s.camel_words) LIKE ?) ESCAPE '\\'
|
|
269
|
-
`,c=[`%${
|
|
289
|
+
`,c=[`%${o}%`,`%${o}%`];return t&&(a+=" AND s.category_lc = ?",c.push(t.toLowerCase())),n&&(a+=" AND s.framework = ?",c.push(n)),r&&(a+=" AND f.path_lc LIKE ?",c.push(`%${r.toLowerCase()}%`)),a+=` LIMIT ${Math.max(1,Math.min(200,s))}`,this.db.prepare(a).all(...c)}getAllSymbolNames(e){let t=`
|
|
270
290
|
SELECT DISTINCT s.name, f.path as file_path, s.id
|
|
271
291
|
FROM symbols s JOIN files f ON s.file_id = f.id
|
|
272
292
|
`,n=[];return e&&(t+=" WHERE f.path_lc LIKE ?",n.push(`%${e.toLowerCase()}%`)),this.db.prepare(t).all(...n)}getSymbolById(e){return this.db.prepare(`
|
|
273
293
|
SELECT s.*, f.path as file_path, f.abs_path
|
|
274
294
|
FROM symbols s JOIN files f ON s.file_id = f.id
|
|
275
295
|
WHERE s.id = ?
|
|
276
|
-
`).get(e)}getSymbolByName(e,t){if(t){let
|
|
296
|
+
`).get(e)}getSymbolByName(e,t){if(t){let r=this.db.prepare(`
|
|
277
297
|
SELECT s.*, f.path as file_path, f.abs_path
|
|
278
298
|
FROM symbols s JOIN files f ON s.file_id = f.id
|
|
279
299
|
WHERE s.name = ? AND f.path = ?
|
|
280
300
|
LIMIT 1
|
|
281
|
-
`).get(e,t);return
|
|
301
|
+
`).get(e,t);return r||(r=this.db.prepare(`
|
|
282
302
|
SELECT s.*, f.path as file_path, f.abs_path
|
|
283
303
|
FROM symbols s JOIN files f ON s.file_id = f.id
|
|
284
304
|
WHERE s.name = ? AND f.path_lc LIKE ?
|
|
@@ -294,7 +314,7 @@ import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {StdioSer
|
|
|
294
314
|
s.parent_component IS NULL DESC,
|
|
295
315
|
f.line_count DESC
|
|
296
316
|
LIMIT 1
|
|
297
|
-
`).get(e,`%${t.toLowerCase()}%`)),
|
|
317
|
+
`).get(e,`%${t.toLowerCase()}%`)),r}if(!((this.db.prepare(`
|
|
298
318
|
SELECT COUNT(DISTINCT f.path) as c
|
|
299
319
|
FROM symbols s JOIN files f ON s.file_id = f.id
|
|
300
320
|
WHERE s.name_lc = ?
|
|
@@ -313,25 +333,25 @@ import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {StdioSer
|
|
|
313
333
|
s.parent_component IS NULL DESC,
|
|
314
334
|
f.line_count DESC
|
|
315
335
|
LIMIT 1
|
|
316
|
-
`).get(e.toLowerCase())}behaviorSearch(e,t,n,s
|
|
336
|
+
`).get(e.toLowerCase())}behaviorSearch(e,t,n,r,s){let o=`
|
|
317
337
|
SELECT b.*, s.name as symbol_name, s.start_line, s.end_line, s.category as symbol_category,
|
|
318
338
|
f.path as file_path
|
|
319
339
|
FROM behaviors b
|
|
320
340
|
JOIN symbols s ON b.symbol_id = s.id
|
|
321
341
|
JOIN files f ON b.file_id = f.id
|
|
322
342
|
WHERE 1=1
|
|
323
|
-
`,a=[];return e&&(
|
|
343
|
+
`,a=[];return e&&(o+=" AND b.category = ?",a.push(e)),t&&(o+=" AND b.api_name_lc = ?",a.push(t.toLowerCase())),n&&(o+=" AND b.operation_lc = ?",a.push(n.toLowerCase())),r&&(o+=" AND (b.detail_lc LIKE ? OR b.api_name_lc LIKE ?)",a.push(`%${r.toLowerCase()}%`,`%${r.toLowerCase()}%`)),s&&(o+=" AND f.path_lc LIKE ?",a.push(`%${s.toLowerCase()}%`)),o+=" ORDER BY f.path, b.line_number LIMIT 50",this.db.prepare(o).all(...a)}getCallers(e,t,n){let r=`
|
|
324
344
|
SELECT r.*, s.name as caller_name, s.start_line, s.end_line, s.category,
|
|
325
345
|
f.path as file_path
|
|
326
346
|
FROM relations r
|
|
327
347
|
JOIN symbols s ON r.caller_id = s.id
|
|
328
348
|
JOIN files f ON s.file_id = f.id
|
|
329
349
|
WHERE r.callee_name_lc = ?
|
|
330
|
-
`,
|
|
350
|
+
`,s=[e.toLowerCase()];return t&&(r+=" AND f.path_lc LIKE ?",s.push(`%${t.toLowerCase()}%`)),n&&(r+=" AND LOWER(COALESCE(r.args, '')) LIKE LOWER(?)",s.push(`%${n}%`)),r+=" ORDER BY f.path, r.line_number",this.db.prepare(r).all(...s)}getCallees(e){return this.db.prepare(`
|
|
331
351
|
SELECT r.*, r.callee_name
|
|
332
352
|
FROM relations r
|
|
333
353
|
WHERE r.caller_id = ?
|
|
334
|
-
`).all(e)}findRelationsByArgKeyword(e,t,n=50){let
|
|
354
|
+
`).all(e)}findRelationsByArgKeyword(e,t,n=50){let r=e.trim();if(!r)return [];let s=`
|
|
335
355
|
SELECT r.*, s.name as caller_name, s.start_line, s.end_line, s.category,
|
|
336
356
|
f.path as file_path
|
|
337
357
|
FROM relations_fts fts
|
|
@@ -339,77 +359,86 @@ import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {StdioSer
|
|
|
339
359
|
JOIN symbols s ON r.caller_id = s.id
|
|
340
360
|
JOIN files f ON s.file_id = f.id
|
|
341
361
|
WHERE fts.args MATCH ?
|
|
342
|
-
`,a=[`"${
|
|
362
|
+
`,a=[`"${r.replace(/"/g,'""')}"`];t&&(s+=" AND f.path_lc LIKE ?",a.push(`%${t.toLowerCase()}%`)),s+=" ORDER BY f.path, r.line_number LIMIT ?",a.push(n);let c=[],l=false,p=false;try{c=this.db.prepare(s).all(...a),c.length>0&&(l=!0);}catch{p=true;}let d=/[^a-zA-Z0-9_\u4e00-\u9fa5]/.test(r);if(!l&&(p||d)){let f=r.replace(/[\\%_]/g,"\\$&"),m=`
|
|
343
363
|
SELECT r.*, s.name as caller_name, s.start_line, s.end_line, s.category,
|
|
344
364
|
f.path as file_path
|
|
345
365
|
FROM relations r
|
|
346
366
|
JOIN symbols s ON r.caller_id = s.id
|
|
347
367
|
JOIN files f ON s.file_id = f.id
|
|
348
368
|
WHERE LOWER(COALESCE(r.args, '')) LIKE LOWER(?) ESCAPE '\\'
|
|
349
|
-
`,
|
|
369
|
+
`,g=[`%${f}%`];t&&(m+=" AND f.path_lc LIKE ?",g.push(`%${t.toLowerCase()}%`)),m+=" ORDER BY f.path, r.line_number LIMIT ?",g.push(n),c=this.db.prepare(m).all(...g);}return c}getLastIndexedTime(){return this.db.prepare("SELECT MAX(last_indexed_at) as ts FROM files").get()?.ts??null}getProjectStats(){let e=this.db.prepare("SELECT COUNT(*) as c FROM files").get().c,t=this.db.prepare("SELECT COUNT(*) as c FROM symbols").get().c,n=this.db.prepare("SELECT COUNT(*) as c FROM behaviors").get().c,r=this.db.prepare("SELECT COUNT(*) as c FROM relations").get().c,s=this.db.prepare("SELECT COUNT(*) as c FROM index_failures").get().c,o=this.db.prepare(`
|
|
350
370
|
SELECT framework, COUNT(*) as count FROM files GROUP BY framework
|
|
351
|
-
`).all(),
|
|
371
|
+
`).all(),a=this.db.prepare(`
|
|
352
372
|
SELECT f.path, f.line_count, COUNT(s.id) as symbol_count
|
|
353
373
|
FROM files f LEFT JOIN symbols s ON f.id = s.file_id
|
|
354
374
|
GROUP BY f.id
|
|
355
375
|
ORDER BY f.line_count DESC LIMIT 10
|
|
356
|
-
`).all(),
|
|
376
|
+
`).all(),c=this.db.prepare(`
|
|
357
377
|
SELECT category, COUNT(*) as count FROM behaviors GROUP BY category ORDER BY count DESC
|
|
358
|
-
`).all(),
|
|
378
|
+
`).all(),l=this.db.prepare("SELECT page_count * page_size as size FROM pragma_page_count(), pragma_page_size()").get()?.size??0;return {fileCount:e,symbolCount:t,behaviorCount:n,relationCount:r,failureCount:s,frameworkBreakdown:o,topFiles:a,behaviorStats:c,dbSize:l}}getIndexFailures(e=20){return this.db.prepare(`
|
|
379
|
+
SELECT file_path, error, last_seen_at
|
|
380
|
+
FROM index_failures
|
|
381
|
+
ORDER BY last_seen_at DESC, id DESC
|
|
382
|
+
LIMIT ?
|
|
383
|
+
`).all(e)}getFileDependencies(e,t="both"){return t==="from"?this.db.prepare(`
|
|
359
384
|
SELECT * FROM file_dependencies WHERE from_file = ? ORDER BY dependency_kind, to_file
|
|
360
385
|
`).all(e):t==="to"?this.db.prepare(`
|
|
361
386
|
SELECT * FROM file_dependencies WHERE to_file = ? ORDER BY dependency_kind, from_file
|
|
362
387
|
`).all(e):this.db.prepare(`
|
|
363
388
|
SELECT * FROM file_dependencies WHERE from_file = ? OR to_file = ?
|
|
364
389
|
ORDER BY dependency_kind, from_file, to_file
|
|
365
|
-
`).all(e,e)}getAssignments(e,t,n=40){let
|
|
390
|
+
`).all(e,e)}getAssignments(e,t,n=40){let r=`
|
|
366
391
|
SELECT a.*, f.path as file_path
|
|
367
392
|
FROM data_assignments a JOIN files f ON a.file_id = f.id
|
|
368
393
|
WHERE a.symbol_name_lc = ?
|
|
369
|
-
`,
|
|
394
|
+
`,s=[e.toLowerCase()];return t&&(r+=" AND f.path_lc LIKE ?",s.push(`%${t.toLowerCase()}%`)),r+=" ORDER BY f.path, a.line_number LIMIT ?",s.push(n),this.db.prepare(r).all(...s)}getPropertyWrites(e,t,n,r=40){let s=`
|
|
370
395
|
SELECT pw.*, f.path as file_path
|
|
371
396
|
FROM property_writes pw JOIN files f ON pw.file_id = f.id
|
|
372
397
|
WHERE pw.object_name_lc = ?
|
|
373
|
-
`,
|
|
398
|
+
`,o=[e.toLowerCase()];return t&&(s+=" AND pw.property_name_lc = ?",o.push(t.toLowerCase())),n&&(s+=" AND f.path_lc LIKE ?",o.push(`%${n.toLowerCase()}%`)),s+=" ORDER BY f.path, pw.line_number LIMIT ?",o.push(r),this.db.prepare(s).all(...o)}getCallersWithSourceKind(e,t,n){let r=`
|
|
374
399
|
SELECT r.*, s.name as caller_name, s.start_line, s.end_line, s.category,
|
|
375
400
|
f.path as file_path
|
|
376
401
|
FROM relations r
|
|
377
402
|
JOIN symbols s ON r.caller_id = s.id
|
|
378
403
|
JOIN files f ON s.file_id = f.id
|
|
379
404
|
WHERE r.callee_name_lc = ?
|
|
380
|
-
`,
|
|
381
|
-
`);for(let
|
|
382
|
-
`));}function
|
|
383
|
-
`),l;try{l=
|
|
384
|
-
`).length;n.symbols.push({name:"<template>",category:"lifecycle",framework:"vue2",startLine:
|
|
385
|
-
`&&n++;return n}extractFromAST(e,t,n,s
|
|
386
|
-
`);
|
|
387
|
-
`),
|
|
388
|
-
`),
|
|
389
|
-
`),
|
|
390
|
-
`),a=!!
|
|
391
|
-
`).length;n.symbols.push({name:"<template>",category:"lifecycle",framework:"vue3",startLine:l,endLine:l+
|
|
392
|
-
`),c=
|
|
393
|
-
`);
|
|
394
|
-
`),t(
|
|
395
|
-
`),t(c)),
|
|
396
|
-
`),c);if(
|
|
397
|
-
`);this.extractFromAST(
|
|
398
|
-
`),
|
|
399
|
-
`),a),
|
|
400
|
-
`),
|
|
401
|
-
`),
|
|
402
|
-
`)):
|
|
403
|
-
`)):"";return {contentHash:t,exportSignatureHash:s,importSignatureHash:i}}function ln(o,e){if(!o)return "full_changed";if(o.contentHash===e.contentHash)return "unchanged";let t=o.exportSignatureHash!==e.exportSignatureHash,n=o.importSignatureHash!==e.importSignatureHash;return t&&n?"full_changed":t?"export_changed":n?"import_changed":"body_only"}function pn(o,e,t){if(e==="unchanged")return [];if(e==="body_only")return [o];if(e==="import_changed")return [o];let n=new Set([o]),s=[o];for(;s.length>0;){let r=s.shift(),i=t.get(r)||[];for(let a of i)n.has(a)||n.add(a);}return Array.from(n)}function ys(o){return createHash("sha256").update(o,"utf-8").digest("hex").slice(0,16)}function an(o){return createHash("sha256").update(o,"utf-8").digest("hex").slice(0,12)}var bs={maxFiles:20,maxTimeMs:1500},nt=class{pending=[];options;constructor(e){this.options={...bs,...e};}configure(e){this.options={...this.options,...e};}enqueue(e,t){let n=this.pending.find(s=>s.relPath===e);if(n){let s={high:3,normal:2,low:1};s[t]>s[n.priority]&&(n.priority=t);return}this.pending.push({relPath:e,priority:t,addedAt:Date.now()});}dequeueBatch(){if(this.pending.length===0)return {tasks:[],exceededBudget:false,remainingPending:0};let e={high:0,normal:1,low:2};this.pending.sort((r,i)=>{let a=e[r.priority],c=e[i.priority];return a!==c?a-c:r.addedAt-i.addedAt});let t=[],n=this.pending.length>this.options.maxFiles;for(let r=0;r<Math.min(this.options.maxFiles,this.pending.length);r++)t.push(this.pending[r]);let s=new Set(t.map(r=>r.relPath));return this.pending=this.pending.filter(r=>!s.has(r.relPath)),{tasks:t,exceededBudget:n,remainingPending:this.pending.length}}requeue(e){if(e.length===0)return;let t=new Set(this.pending.map(s=>s.relPath)),n=e.filter(s=>!t.has(s.relPath));this.pending=[...n,...this.pending];}clear(){this.pending=[];}get pendingCount(){return this.pending.length}get budget(){return this.options}summary(){return this.pending.map(e=>({relPath:e.relPath,priority:e.priority}))}};var st=class{projectRoot;db;scheduler;constructor(e,t){this.projectRoot=e,this.db=t,this.scheduler=new nt;}getScheduler(){return this.scheduler}enhancePreciseRelations(e){try{let t=e.filter(({absPath:s})=>/\.(ts|tsx)$/i.test(s)).map(({absPath:s,content:r})=>({path:s,content:r})),n=Tt(t,"precise");if(n.files.size===0)return;for(let s of e){if(s.result.relations.length===0)continue;let r=new Set(s.result.symbols.map(i=>i.name));s.result.relations=St(s.result.relations,s.result.filePath,n,r);}}catch(t){let n=`precise enhancement \u5931\u8D25\uFF0C\u5DF2\u56DE\u9000\u5230\u672C\u5730 relations: ${String(t)}`;process.stderr.write(`[Frontend-Code-Skimmer] ${n}
|
|
404
|
-
`)
|
|
405
|
-
`);
|
|
406
|
-
`);}let
|
|
407
|
-
`)
|
|
408
|
-
`);}catch(
|
|
409
|
-
`);}}
|
|
410
|
-
`);}
|
|
411
|
-
`),process.stderr.write(`[Frontend-Code-Skimmer] \
|
|
412
|
-
`)
|
|
405
|
+
`,s=[e.toLowerCase()];return t&&(r+=" AND f.path_lc LIKE ?",s.push(`%${t.toLowerCase()}%`)),n&&(r+=" AND LOWER(COALESCE(r.args, '')) LIKE LOWER(?)",s.push(`%${n}%`)),r+=" ORDER BY f.path, r.line_number",this.db.prepare(r).all(...s)}close(){this.db.close();}};function G(i,e,t,n=false){let r=[];return z(i,o=>{if(n&&o!==i&&(o.type==="FunctionDeclaration"||o.type==="ArrowFunctionExpression"||o.type==="FunctionExpression"||o.type==="ClassDeclaration"))return false;if(o.type==="CallExpression"){let c=ir(o,e);c&&r.push(c);}if(o.type==="MemberExpression"){let a=or(o);a&&r.push(a);}}),fr(r)}function ir(i,e,t){let n=i.callee;if(!n)return null;let r=Lt(i);if(n.type==="MemberExpression"){let s=ar(n);if(!s)return null;let{apiName:o,operation:a}=s,c=i.arguments,l=te(c?.[0]),p=dr(o);return p?{symbolName:e,category:p,apiName:o,operation:a,detail:l,line:r}:o==="this"&&Ye(a)?{symbolName:e,category:"network",apiName:`this.${a}`,operation:"wrapped_call",detail:l||te(c?.[1]),line:r}:on(a)&&ur(c)?{symbolName:e,category:"network",apiName:o,operation:a,detail:l||te(c?.[1]),line:r}:Ye(o)||Ye(`${o}.${a}`)?{symbolName:e,category:"network",apiName:o,operation:on(a)?a:"wrapped_call",detail:l||te(c?.[1]),line:r}:null}if(n.type==="Identifier"){let s=n.name,o=cr(s),a=i.arguments,c=te(a?.[0]);return o?{symbolName:e,category:o.category,apiName:s,operation:o.operation,detail:c,line:r}:Ye(s)?{symbolName:e,category:"network",apiName:s,operation:"wrapped_call",detail:c||te(a?.[1]),line:r}:null}return null}function or(i,e,t){let n=i.object,r=i.property;if(!n||!r||n.type!=="MemberExpression"&&n.type!=="ThisExpression"&&n.type!=="Identifier")return null;let s=pr(n);if(!s)return null;r.type==="Identifier"?r.name:"";if(s==="this"||s===""){n.type==="MemberExpression"?n.property?.name:"";return null}return null}function ar(i){let e=i.object,t=i.property;if(!e||!t||t.type!=="Identifier")return null;let n=t.name;if(e.type==="MemberExpression"){let r=e.property?.name;if(r)return {apiName:r,operation:n}}return e.type==="Identifier"?{apiName:e.name,operation:n}:e.type==="ThisExpression"?{apiName:"this",operation:n}:null}function cr(i){let e={fetch:"network",setTimeout:"timer",setInterval:"timer",clearTimeout:"timer",clearInterval:"timer",requestAnimationFrame:"timer",navigate:"router"};return e[i]?{category:e[i],operation:i}:null}function Lt(i){return i.loc?.start?.line??0}function lr(i){let e=i.loc;return {line:e?.start?.line??0,column:e?.start?.column??0}}function pr(i){return i.type==="Identifier"?i.name:i.type==="ThisExpression"?"this":null}function dr(i){if(i==="this")return null;for(let[e,t]of Object.entries(Jt))if(i in t)return e;return null}function te(i,e){if(i){if(i.type==="Literal"||i.type==="StringLiteral"||i.type==="NumericLiteral"||i.type==="BooleanLiteral")return String(i.value);if(i.type==="NullLiteral")return "null";if(i.type==="TemplateLiteral"){let t=i.quasis,n=i.expressions||[],r=[];for(let o=0;o<t.length;o++){let a=t[o].value?.cooked||"";if(a&&r.push(a),o<n.length){let c=Ze(n[o])||"expr";r.push(`\${${c}}`);}}return r.join("")||"${expr}"}if(i.type==="Identifier")return `[\u53D8\u91CF: ${i.name}]`;if(i.type==="ObjectExpression"){let t=i.properties||[],n=["url","uri","path","api","endpoint"];for(let r of t){let s=r.key,o=r.value;if(!s||!o)continue;let a=s.type==="Identifier"?String(s.name):s.type==="Literal"?String(s.value):"";if(!n.includes(a))continue;let c=te(o);if(c)return `${a}:${c}`}return "{...}"}}}function Ze(i,e){if(!i)return;if(i.type==="Identifier")return i.name;if(i.type==="ThisExpression")return "this";if(i.type==="Literal"||i.type==="StringLiteral"||i.type==="NumericLiteral"||i.type==="BooleanLiteral")return String(i.value);if(i.type==="NullLiteral")return "null";if(i.type==="MemberExpression"){let n=Ze(i.object)||"obj",r=i.property,s=r?.type==="Identifier"?String(r.name):Ze(r)||"prop";return i.computed?`${n}[${s}]`:`${n}.${s}`}if(i.type==="CallExpression")return `${Ze(i.callee)||"fn"}(...)`;if(i.type==="TemplateLiteral")return te(i);let t=te(i);return t?.startsWith("[\u53D8\u91CF: ")?t.replace(/^\[变量: /,"").replace(/\]$/,""):t}function Ye(i){return /request|api|http|fetch|ajax|akscommonhandle|commonhandle/i.test(i)}function on(i){return ["get","post","put","delete","patch","request"].includes(i.toLowerCase())}function ur(i,e){if(!i||i.length===0)return false;for(let t of i.slice(0,2)){let n=te(t);if(n&&(/https?:\/\//i.test(n)||n.includes("/")||/gw\d?\/|\/m\/|\/api\//i.test(n)))return true}return false}function fr(i){let e=new Set;return i.filter(t=>{let n=`${t.apiName}:${t.operation}:${t.line}`;return e.has(n)?false:(e.add(n),true)})}function we(i,e,t){let n=[];return z(i,r=>{if(r.type==="CallExpression"&&r.callee?.type==="MemberExpression"){let s=r.callee,o=s.object,a=s.property;if(o.type==="ThisExpression"&&a.type==="Identifier"){let c=a.name;if(!c.startsWith("$")&&c!==e){let l=r.arguments,p=an(l);n.push({calleeName:c,line:Lt(r),args:p});}}}}),n}function ne(i,e,t,n=false){let r=[];return z(i,o=>{if(n&&o!==i&&(o.type==="FunctionDeclaration"||o.type==="ArrowFunctionExpression"||o.type==="FunctionExpression"||o.type==="ClassDeclaration"))return false;if(o.type==="CallExpression"&&o.callee?.type==="Identifier"){let a=o.callee.name;if(a!==e&&!mr(a)){let c=o.arguments,l=an(c);r.push({calleeName:a,line:Lt(o),args:l});}}}),r}function mr(i){return /^(useState|useEffect|useMemo|useCallback|useRef|useContext|useReducer|ref|reactive|computed|watch|watchEffect|console|setTimeout|setInterval|Math|Object|Array|JSON|String|Number|Boolean|Promise|require|import)$/.test(i)}function an(i,e){if(!i||i.length===0)return;let t=i.slice(0,3).map(n=>te(n)).filter(n=>!!n);return t.length>0?t.join(", "):void 0}function z(i,e){if(!(!i||typeof i!="object")&&e(i)!==false)for(let t of Object.keys(i)){if(t==="type"||t==="loc"||t==="start"||t==="end")continue;let n=i[t];if(Array.isArray(n))for(let r of n)r&&typeof r=="object"&&r.type&&z(r,e);else n&&typeof n=="object"&&n.type&&z(n,e);}}function Qe(i,e){let t=[],n=new Set,r=i.split(`
|
|
406
|
+
`);for(let s=0;s<r.length;s++){let o=/(?:@|v-on:)[a-z][a-z0-9-]*(?:\.[a-z-]+)*="([^"]+)"/g,a;for(;(a=o.exec(r[s]))!==null;){let l=a[1].trim().match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)(?:\([^)]*\))?$/);if(!l)continue;let p=l[1];if(p.startsWith("$"))continue;let d=e+s,u=`${p}:${d}:${a.index}`;n.has(u)||(n.add(u),t.push({calleeName:p,line:d}));}}return t}function cn(i,e){let t=[],n=new Set;return z(i,r=>{if(r.type!=="JSXAttribute")return;let s=r.name,o=r.value;if(!s||!o)return;let a=s.type==="JSXIdentifier"?String(s.name):"";if(!/^on[A-Z]/.test(a)||o.type!=="JSXExpressionContainer")return;let c=o.expression;if(!c)return;let l;if(c.type==="Identifier")l=c.name;else if(c.type==="MemberExpression"){let f=c.property?.name;f&&!/^\$/.test(f)&&(l=f);}let{line:p,column:d}=lr(r),u=`${l}:${p}:${d}`;!l||n.has(u)||(n.add(u),t.push({calleeName:l,line:p}));}),t}var hr=createRequire(import.meta.url),ln=false;function yr(i){ln||(ln=true,process.stderr.write(`[Frontend-Code-Skimmer] precise import graph \u5DF2\u964D\u7EA7: ${String(i)}
|
|
407
|
+
`));}function pn(i,e,t){let n={filePath:i,imports:[],exports:[]};try{let r=hr("typescript"),s=r.createSourceFile(i,e,r.ScriptTarget.Latest,!0);r.forEachChild(s,o=>{if(r.isImportDeclaration(o)){let a=o.moduleSpecifier;if(!a||!r.isStringLiteral(a))return;let c=a.text,l=tt(i,c),p=o.importClause;if(!p){n.imports.push({localName:"",originalName:"",modulePath:c,resolvedFile:l,isDefault:!1,isReExport:!1});return}let d=p.namedBindings;if(d&&r.isNamedImports(d))for(let u of d.elements){let f=u.propertyName?u.propertyName.text:u.name.text;n.imports.push({localName:u.name.text,originalName:f,modulePath:c,resolvedFile:l,isDefault:!1,isReExport:!1});}d&&r.isNamespaceImport(d)&&n.imports.push({localName:d.name.text,originalName:"*",modulePath:c,resolvedFile:l,isDefault:!1,isReExport:!1}),p.name&&n.imports.push({localName:p.name.text,originalName:"default",modulePath:c,resolvedFile:l,isDefault:!0,isReExport:!1});}if(r.isExportDeclaration(o)){let a=o.moduleSpecifier;if(a&&r.isStringLiteral(a)){let c=a.text,l=o.exportClause;if(l&&r.isNamedExports(l))for(let p of l.elements)n.exports.push({name:p.name.text,isDefault:!1,source:"re_export",reExportFrom:c});}else if(o.exportClause){let c=o.exportClause;if(r.isNamedExports(c))for(let l of c.elements)n.exports.push({name:l.name.text,isDefault:!1,source:"local"});}}if(r.isExportAssignment(o)&&(o.isExportEquals||n.exports.push({name:"default",isDefault:!0,source:"local"})),(r.isFunctionDeclaration(o)||r.isVariableStatement(o)||r.isClassDeclaration(o))&&o.modifiers?.some(a=>a.kind===r.SyntaxKind.ExportKeyword)){if(r.isFunctionDeclaration(o)&&o.name)n.exports.push({name:o.name.text,isDefault:o.name.text==="default",source:"local"});else if(r.isClassDeclaration(o)&&o.name)n.exports.push({name:o.name.text,isDefault:o.name.text==="default",source:"local"});else if(r.isVariableStatement(o))for(let a of o.declarationList.declarations)r.isIdentifier(a.name)&&n.exports.push({name:a.name.text,isDefault:!1,source:"local"});}});}catch(r){yr(r);}return n}function tt(i,e){let t=K.dirname(i);if(e.startsWith(".")){let n=K.resolve(t,e);return Te(n)}return e.startsWith("@/")?br(i,e):e}function br(i,e){let t=K.dirname(i);for(let n=0;n<10;n++){let r=K.join(t,"src");if(Z.existsSync(r)&&Z.statSync(r).isDirectory()){let o=K.join(r,e.replace(/^@\//,""));return Te(o)}let s=K.dirname(t);if(s===t)break;t=s;}return e}function H(i){return {callerName:i.callerName,callerLine:i.callerLine,callerKey:i.callerKey,calleeName:i.calleeName,callType:i.callType,line:i.line,args:i.args,sourceKind:Ve(i.callType),importSource:i.importSource,receiverToken:i.receiverToken,edgeKind:i.edgeKind||"heuristic"}}function fe(i,e){let t=[];for(let n of i){let r=n.type;if(r==="ImportDeclaration"){let s=n.source,o=n.loc;s?.value&&t.push({fromFile:e,toFile:tt(e,s.value),dependencyKind:"import",line:o?.start?.line??1});}if(r==="ExportNamedDeclaration"||r==="ExportAllDeclaration"){let s=n.source,o=n.loc;s?.value&&t.push({fromFile:e,toFile:tt(e,s.value),dependencyKind:"re_export",line:o?.start?.line??1});}}return t}function rt(i,e){let t=new Map(e.map(r=>[r.name,r])),n=[];for(let r of i){let s=r.type;if(s==="ExportNamedDeclaration"){let o=r.declaration,a=r.source;if(o){if(o.type==="FunctionDeclaration"||o.type==="ClassDeclaration"){let c=o.id;c?.name&&n.push(nt(c.name,t.get(c.name)));}else if(o.type==="VariableDeclaration")for(let c of o.declarations||[]){let l=c.id;l?.type==="Identifier"&&l.name&&n.push(nt(l.name,t.get(l.name)));}continue}for(let c of r.specifiers||[]){let l=Rt(c.local),p=Rt(c.exported)||l;p&&(a?.value?n.push(`re_export:${p}:${a.value}`):n.push(nt(p,l?t.get(l):void 0)));}continue}if(s==="ExportAllDeclaration"){let o=r.source;o?.value&&n.push(`re_export_all:${o.value}`);continue}if(s==="ExportDefaultDeclaration"){let o=r.declaration;if(!o){n.push("default:unknown");continue}if(o.type==="Identifier"){let a=Rt(o);n.push(nt("default",a?t.get(a):void 0));continue}if(o.type==="FunctionDeclaration"||o.type==="FunctionExpression"||o.type==="ArrowFunctionExpression"){let a=(o.params||[]).map(c=>kt(c)).join(", ");n.push(`default:fn(${a})`);continue}if(o.type==="ClassDeclaration"||o.type==="ClassExpression"){n.push("default:class");continue}n.push(`default:${String(o.type||"unknown")}`);}}return n.sort()}function nt(i,e){return `${i}:${Er(e)}`}function Er(i){return i?i.category==="class"?"class":i.signature?`fn${i.signature.replace(/^[^(]*/,"")}`:i.category==="constant"?`const:${i.defaultValue||""}`:i.category:"unknown"}function Rt(i){if(i){if(i.type==="Identifier")return String(i.name||"");if(i.type==="StringLiteral")return String(i.value||"")}}function kt(i){return i?i.type==="Identifier"?String(i.name||"param"):i.type==="AssignmentPattern"?kt(i.left):i.type==="RestElement"?kt(i.argument):"param":"param"}var dn=createRequire(import.meta.url);var ve=class{name="Vue2Parser";canParse(e,t){return e.endsWith(".vue")}parse(e,t){let n={framework:"vue2",filePath:e,symbols:[],relations:[],behaviors:[],errors:[]};try{let s=dn("vue-template-compiler").parseComponent(t);if(!s.script?.content)return n;let o=s.script.content,a=this.getScriptStartLine(t,s.script.start),c=t.split(`
|
|
408
|
+
`),l;try{l=dn("@babel/parser").parse(o,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy"],errorRecovery:!0});}catch(p){return n.errors?.push(`AST \u89E3\u6790\u5931\u8D25: ${String(p)}`),n}if(this.extractFromAST(l.program,o,c,a,n),s.template?.content){let p=this.getScriptStartLine(t,s.template.start),d=Qe(s.template.content,p);if(d.length>0){let u=s.template.content.split(`
|
|
409
|
+
`).length;n.symbols.push({name:"<template>",category:"lifecycle",framework:"vue2",startLine:p,endLine:p+u-1,camelWords:"template"});for(let f of d)n.relations.push(H({callerName:"<template>",callerLine:p,calleeName:f.calleeName,callType:"template_event",line:f.line}));}}}catch(r){n.errors?.push(`\u89E3\u6790\u5931\u8D25: ${String(r)}`);}return n}getScriptStartLine(e,t){let n=1;for(let r=0;r<t&&r<e.length;r++)e[r]===`
|
|
410
|
+
`&&n++;return n}extractFromAST(e,t,n,r,s){let o=t.split(`
|
|
411
|
+
`);s.fileDependencies=fe(e.body||[],s.filePath);let a=null;z(e,d=>{if(d.type==="ExportDefaultDeclaration"){let u=d.declaration;if(u?.type==="ObjectExpression")a=u;else if(u?.type==="CallExpression"){let f=u.arguments;f&&f.length>0&&f[0].type==="ObjectExpression"&&(a=f[0]);}else if(u?.type==="Identifier"){let f=u.name;z(e,m=>{if(m.type==="VariableDeclarator"&&m.id?.name===f){if(m.init?.type==="ObjectExpression")a=m.init;else if(m.init?.type==="CallExpression"){let g=m.init.arguments;g&&g.length>0&&g[0].type==="ObjectExpression"&&(a=g[0]);}}});}}});let l=false;if(!a&&(z(e,d=>{d.type==="ExportDefaultDeclaration"&&d.declaration?.type==="ClassDeclaration"&&(l=true,this.extractFromClassComponent(d.declaration,t,n,r,s));}),!l)){let d=null,u=0,f=["data","methods","computed","props","watch","components","created","mounted","mixins"];z(e,m=>{if(m.type==="ObjectExpression"){let g=m.properties||[],y=0;for(let b of g){let T=this.getPropKey(b);T&&f.includes(T)&&y++;}y>u&&(u=y,d=m);}}),u>=2&&d&&(a=d);}if(!a)return;let p=a.properties;for(let d of p||[]){let u=this.getPropKey(d);if(!u)continue;let f=d.type==="ObjectMethod"?d:d.value;if(!f)continue;let m=g=>g+r-1;switch(u){case "name":f?.type==="Literal"&&(String(f.value));break;case "data":this.extractData(f,o,m,s);break;case "props":this.extractProps(f,o,m,s);break;case "computed":this.extractComputedOrMethods(f,"computed",o,m,n,s);break;case "methods":this.extractComputedOrMethods(f,"method",o,m,n,s);break;case "watch":this.extractWatch(f,o,m,s);break;case "filters":this.extractComputedOrMethods(f,"filter",o,m,n,s);break;case "components":this.extractComponents(f,s);break;case "mixins":this.extractMixins(f,s);break;default:if(Nt.includes(u)){let g=m(this.getStartLine(d)),y=m(this.getEndLine(d)),b=V(n.join(`
|
|
412
|
+
`),g),T=s.symbols.length;s.symbols.push({name:u,category:"lifecycle",framework:"vue2",startLine:g,endLine:y,jsdoc:b,camelWords:k(u)});let h=G(f,u);s.behaviors.push(...h);let E=we(f,u);for(let N of E){if(N.args){let R=String(N.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[T].camelWords+=` ${k(R)} ${R}`;}s.relations.push(H({callerName:u,callerLine:g,calleeName:N.calleeName,callType:"this_method",line:m(N.line),args:N.args}));}}break}}}extractData(e,t,n,r){let s=null;if(e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"||e.type==="ObjectMethod"?z(e.body,o=>{o.type==="ReturnStatement"&&o.argument?.type==="ObjectExpression"&&(s=o.argument);}):e.type==="ObjectExpression"&&(s=e),!!s)for(let o of s.properties){let a=this.getPropKey(o);if(!a)continue;let c=n(this.getStartLine(o)),l=n(this.getEndLine(o)),p=this.getLiteralValue(o.value);r.symbols.push({name:a,category:"state",framework:"vue2",startLine:c,endLine:l,defaultValue:p,camelWords:k(a)});}}extractProps(e,t,n,r){if(e.type==="ArrayExpression"){for(let s of e.elements||[])if(s?.type==="Literal"){let o=String(s.value);r.symbols.push({name:o,category:"prop",framework:"vue2",startLine:n(this.getStartLine(s)),endLine:n(this.getEndLine(s)),camelWords:k(o)});}}else if(e.type==="ObjectExpression")for(let s of e.properties||[]){let o=this.getPropKey(s);if(!o)continue;let a=n(this.getStartLine(s)),c=n(this.getEndLine(s)),l;if(s.value?.type==="ObjectExpression"){let p=s.value.properties?.find(d=>this.getPropKey(d)==="default");p&&(l=this.getLiteralValue(p.value));}r.symbols.push({name:o,category:"prop",framework:"vue2",startLine:a,endLine:c,defaultValue:l,camelWords:k(o)});}}extractComputedOrMethods(e,t,n,r,s,o){if(e.type==="ObjectExpression")for(let a of e.properties||[]){let c=this.getPropKey(a);if(!c)continue;let l=a.type==="ObjectMethod"?a:a.value;if(!l)continue;let p=r(this.getStartLine(a)),d=r(this.getEndLine(a)),u=V(s.join(`
|
|
413
|
+
`),p),f=this.extractParams(l),m=l.async===true,g=f?`${c}(${f.join(", ")})`:c;if(o.symbols.push({name:c,category:t,framework:"vue2",startLine:p,endLine:d,signature:g,params:f,isAsync:m,jsdoc:u,camelWords:k(c)}),t==="method"&&l){let y=G(l,c);o.behaviors.push(...y);let b=we(l,c);for(let T of b){if(T.args){let h=String(T.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");o.symbols[o.symbols.length-1].camelWords+=` ${k(h)} ${h}`;}o.relations.push(H({callerName:c,callerLine:p,calleeName:T.calleeName,callType:"this_method",line:r(T.line),args:T.args}));}}}}extractWatch(e,t,n,r){if(e.type==="ObjectExpression")for(let s of e.properties||[]){let o=this.getPropKey(s);if(!o)continue;let a=n(this.getStartLine(s)),c=n(this.getEndLine(s));r.symbols.push({name:o,category:"effect",framework:"vue2",startLine:a,endLine:c,camelWords:k(o)});}}extractComponents(e,t){if(e.type==="ObjectExpression")for(let n of e.properties||[]){let r=this.getPropKey(n);r&&t.symbols.push({name:r,category:"component",framework:"vue2",startLine:this.getStartLine(n),endLine:this.getEndLine(n),camelWords:k(r)});}}extractMixins(e,t){if(e.type==="ArrayExpression")for(let n of e.elements||[]){let r=n?.type==="Identifier"?n.name:null;r&&t.symbols.push({name:r,category:"mixin",framework:"vue2",startLine:this.getStartLine(n),endLine:this.getEndLine(n),camelWords:k(r)});}}getPropKey(e){if(!e)return null;let t=e.key;return t?t.type==="Identifier"?t.name:t.type==="Literal"?String(t.value):null:null}getStartLine(e){return e?.loc?.start?.line??1}getEndLine(e){return e?.loc?.end?.line??1}extractParams(e){if(!e)return;let t=e.params;if(t)return t.map(n=>n.type==="Identifier"?n.name:n.type==="AssignmentPattern"?n.left?.name||"?":n.type==="RestElement"?`...${n.argument?.name||""}`:n.type==="TSParameterProperty"&&n.parameter?.name||"?")}getLiteralValue(e){if(e){if(e.type==="Literal"||e.type==="StringLiteral"||e.type==="NumericLiteral"||e.type==="BooleanLiteral")return String(e.value);if(e.type==="NullLiteral"||e.value===null)return "null";if(e.type==="ObjectExpression")return "{}";if(e.type==="ArrayExpression")return "[]";if(e.type==="Identifier"&&e.name==="undefined")return "undefined";if(e.type==="ArrowFunctionExpression"||e.type==="FunctionExpression"||e.type==="ObjectMethod")return "function"}}extractFromClassComponent(e,t,n,r,s){let o=c=>c+r-1,a=e.body;if(!(!a||a.type!=="ClassBody"))for(let c of a.body||[]){let l=this.getPropKey(c);if(!l)continue;let p=o(this.getStartLine(c)),d=o(this.getEndLine(c)),u=V(n.join(`
|
|
414
|
+
`),p);if(c.type==="ClassMethod"){let m=Nt.includes(l)?"lifecycle":"method",g=this.extractParams(c),y=c.async===true,b=g?`${l}(${g.join(", ")})`:l;s.symbols.push({name:l,category:m,framework:"vue2",startLine:p,endLine:d,signature:b,params:g,isAsync:y,jsdoc:u,camelWords:k(l)});let T=G(c,l);s.behaviors.push(...T);let h=we(c,l);for(let E of h){if(E.args){let N=String(E.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[s.symbols.length-1].camelWords+=` ${k(N)} ${N}`;}s.relations.push(H({callerName:l,callerLine:p,calleeName:E.calleeName,callType:"this_method",line:o(E.line),args:E.args}));}}else if(c.type==="ClassProperty"){let f=(c.decorators||[]).some(g=>g.expression?.callee?.name==="Prop"),m=this.getLiteralValue(c.value);s.symbols.push({name:l,category:f?"prop":"state",framework:"vue2",startLine:p,endLine:d,defaultValue:m,camelWords:k(l)});}}}};var wt=createRequire(import.meta.url),st=class{name="Vue3Parser";canParse(e,t){return e.endsWith(".vue")?this.looksLikeVue3File(t):false}parse(e,t){let n={framework:"vue3",filePath:e,symbols:[],relations:[],behaviors:[],errors:[]};try{let{parse:r}=wt("@vue/compiler-sfc"),{descriptor:s}=r(t),o=t.split(`
|
|
415
|
+
`),a=!!s.scriptSetup,c=!!s.script;if(a){let l=s.scriptSetup,p=l.loc.start.line;this.parseSetupContent(l.content,p,o,n);}else if(c){let l=s.script,p=l.loc.start.line;this.parseScriptContent(l.content,p,o,n)||this.populateFromOptionsApiFallback(e,t,n);}if(s.template?.content){let l=s.template.loc.start.line,p=Qe(s.template.content,l);if(p.length>0){let d=s.template.content.split(`
|
|
416
|
+
`).length;n.symbols.push({name:"<template>",category:"lifecycle",framework:"vue3",startLine:l,endLine:l+d-1,camelWords:"template"});for(let u of p)n.relations.push(H({callerName:"<template>",callerLine:l,calleeName:u.calleeName,callType:"template_event",line:u.line}));}}}catch(r){n.errors?.push(`Vue3 \u89E3\u6790\u5931\u8D25: ${String(r)}`);}return n}parseSetupContent(e,t,n,r){let s;try{s=wt("@babel/parser").parse(e,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"],errorRecovery:!0});}catch(l){r.errors?.push(`AST \u89E3\u6790\u5931\u8D25: ${String(l)}`);return}let o=l=>l+t-1,a=e.split(`
|
|
417
|
+
`),c=s.program.body;r.fileDependencies=fe(c,r.filePath);for(let l of c||[])this.processTopLevelStatement(l,o,n,a,r);}parseScriptContent(e,t,n,r){let s;try{s=wt("@babel/parser").parse(e,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"],errorRecovery:!0});}catch(l){return r.errors?.push(`AST \u89E3\u6790\u5931\u8D25: ${String(l)}`),false}let o=l=>l+t-1,a=e.split(`
|
|
418
|
+
`);r.fileDependencies=fe(s.program.body||[],r.filePath);let c=false;return z(s.program,l=>{if(l.type==="ExportDefaultDeclaration"&&l.declaration?.type==="ObjectExpression"){let p=l.declaration.properties?.find(d=>this.getPropKey(d)==="setup");if(p){c=true;let d=p.type==="ObjectMethod"?p:p.value;if(!d)return;let u=d.body;if(u?.type==="BlockStatement"){let f=u.body;for(let m of f||[])this.processTopLevelStatement(m,o,n,a,r);}}}}),c||z(s.program,l=>{if(!c&&l.type==="ObjectExpression"){let d=(l.properties||[]).find(u=>this.getPropKey(u)==="setup");if(d){c=true;let u=d.type==="ObjectMethod"?d:d.value;if(!u)return;let f=u.body;if(f?.type==="BlockStatement"){let m=f.body;for(let g of m||[])this.processTopLevelStatement(g,o,n,a,r);}}}}),c}processTopLevelStatement(e,t,n,r,s){let o=a=>{let c=a?.loc;return {start:c?.start?.line??1,end:c?.end?.line??1}};if(e.type==="VariableDeclaration")for(let a of e.declarations||[]){if(a.id?.type!=="Identifier"&&a.id?.type!=="ArrayPattern")continue;let c=a.init;if(c&&a.id.type==="Identifier"){let l=a.id.name;if(c.type==="ArrowFunctionExpression"||c.type==="FunctionExpression"){let{start:p,end:d}=o(e),u=V(n.join(`
|
|
419
|
+
`),t(p)),f=this.extractParams(c),m=s.symbols.length;if(s.symbols.push({name:l,category:"method",framework:"vue3",startLine:t(p),endLine:t(d),signature:`${l}(${(f||[]).join(", ")})`,params:f,isAsync:c.async===true,jsdoc:u,camelWords:k(l)}),c.body){let g=G(c.body,l);s.behaviors.push(...g);let y=ne(c.body,l);for(let b of y){if(b.args){let T=String(b.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[m].camelWords+=` ${k(T)} ${T}`;}s.relations.push(H({callerName:l,callerLine:t(p),calleeName:b.calleeName,callType:"direct_call",line:t(b.line),args:b.args}));}}}else {let p=this.classifyVue3Declaration(l,c,t,o(e),n);p&&s.symbols.push(p);}}}if(e.type==="FunctionDeclaration"&&e.id?.type==="Identifier"){let a=e.id.name,{start:c,end:l}=o(e),p=V(n.join(`
|
|
420
|
+
`),t(c)),d=this.extractParams(e),u=Tt.includes(a);if(s.symbols.push({name:a,category:u?"lifecycle":be(a)?"hook":"method",framework:"vue3",startLine:t(c),endLine:t(l),signature:`${a}(${(d||[]).join(", ")})`,params:d,isAsync:e.async===true,jsdoc:p,camelWords:k(a)}),e.body){let f=G(e.body,a);s.behaviors.push(...f);let m=ne(e.body,a);for(let g of m){if(g.args){let y=String(g.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[s.symbols.length-1].camelWords+=` ${k(y)} ${y}`;}s.relations.push(H({callerName:a,callerLine:t(c),calleeName:g.calleeName,callType:"direct_call",line:t(g.line),args:g.args}));}}}if(e.type==="ExpressionStatement"&&e.expression?.type==="CallExpression"){let c=e.expression.callee;if(c?.type==="Identifier"){let l=c.name;if(["defineProps","defineEmits","defineExpose"].includes(l)){let{start:p,end:d}=o(e);s.symbols.push({name:l,category:l==="defineProps"?"prop":l==="defineEmits"?"emit":"export",framework:"vue3",startLine:t(p),endLine:t(d),camelWords:k(l)});}}}if(e.type==="ExpressionStatement"&&e.expression?.type==="CallExpression"){let a=e.expression,c=a.callee;if(c?.type==="Identifier"){let l=c.name;if(Tt.includes(l)){let{start:p,end:d}=o(e);s.symbols.push({name:l,category:"lifecycle",framework:"vue3",startLine:t(p),endLine:t(d),camelWords:k(l)});let u=a.arguments;if(u?.[0]){let f=G(u[0],l);s.behaviors.push(...f);let m=ne(u[0],l);for(let g of m){if(g.args){let y=String(g.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[s.symbols.length-1].camelWords+=` ${k(y)} ${y}`;}s.relations.push(H({callerName:l,callerLine:t(p),calleeName:g.calleeName,callType:"direct_call",line:t(g.line),args:g.args}));}}}}}}classifyVue3Declaration(e,t,n,r,s){if(t.type!=="CallExpression")return null;let o=t.callee;if(o?.type!=="Identifier")return null;let a=o.name,c=n(r.start),l=n(r.end),p=V(s.join(`
|
|
421
|
+
`),c);if(Yt.includes(a)){let d=t.arguments,u=d?.[0]?this.getLiteralValue(d[0]):void 0;return {name:e,category:"state",framework:"vue3",startLine:c,endLine:l,defaultValue:u,jsdoc:p,camelWords:k(e)}}return Zt.includes(a)?{name:e,category:"computed",framework:"vue3",startLine:c,endLine:l,jsdoc:p,camelWords:k(e)}:Qt.includes(a)?{name:e,category:"effect",framework:"vue3",startLine:c,endLine:l,camelWords:k(e)}:a==="provide"||a==="inject"?{name:e,category:"provide",framework:"vue3",startLine:c,endLine:l,camelWords:k(e)}:be(a)?{name:e,category:"hook",framework:"vue3",startLine:c,endLine:l,jsdoc:p,camelWords:k(e)}:null}getPropKey(e){let t=e?.key;return t?t.type==="Identifier"?t.name:t.type==="Literal"?String(t.value):null:null}extractParams(e){let t=e.params;if(t)return t.map(n=>n.type==="Identifier"?n.name:n.type==="AssignmentPattern"?n.left?.name||"?":n.type==="RestElement"?`...${n.argument?.name||""}`:n.type==="ObjectPattern"?"{...}":n.type==="TSParameterProperty"&&n.parameter?.name||"?")}getLiteralValue(e){if(e){if(e.type==="Literal"||e.type==="StringLiteral"||e.type==="NumericLiteral"||e.type==="BooleanLiteral")return String(e.value);if(e.type==="NullLiteral")return "null";if(e.type==="ObjectExpression")return "{}";if(e.type==="ArrayExpression")return "[]"}}looksLikeVue3File(e){return e.includes("<script setup")?true:/\bdefine(?:Props|Emits|Expose|Slots|Model)\s*\(/.test(e)||/\bwithDefaults\s*\(/.test(e)||/\bdefineComponent\s*\(/.test(e)||/\bsetup\s*\(/.test(e)||/\b(?:ref|reactive|shallowRef|shallowReactive|readonly|computed|watch|watchEffect|watchPostEffect|watchSyncEffect|provide|inject|nextTick|onBeforeMount|onMounted|onBeforeUpdate|onUpdated|onBeforeUnmount|onUnmounted|onActivated|onDeactivated|onErrorCaptured|onRenderTracked|onRenderTriggered|onServerPrefetch)\s*\(/.test(e)}populateFromOptionsApiFallback(e,t,n){let r=new ve().parse(e,t);n.symbols=r.symbols.map(s=>({...s,framework:"vue3"})),n.relations=r.relations,n.behaviors=r.behaviors,n.errors=[...n.errors||[],...r.errors||[]];}};var Sr=createRequire(import.meta.url),xr=[...St,...xt,...At,...en],je=class{name="ReactParser";canParse(e,t){let n=e.split(".").pop()?.toLowerCase();return ["jsx","tsx","js","ts"].includes(n||"")?t.includes("useState")||t.includes("useEffect")||t.includes("from 'react'")||t.includes('from "react"')||t.includes("React.")||t.includes("jsx")||t.includes("JSX")?true:n==="jsx"||n==="tsx"||n==="js"?this.containsLikelyJsx(t):false:false}containsLikelyJsx(e){return /(?:^|\breturn\b|[=(,:{?&|;>])[\s([]*<[A-Za-z][\w.:-]*(?:\s|\/?>)/m.test(e)||/<>|<\/>/.test(e)}parse(e,t){let n={framework:"react",filePath:e,symbols:[],relations:[],behaviors:[],errors:[]};try{let s=Sr("@babel/parser").parse(t,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy"],errorRecovery:!0}),o=t.split(`
|
|
422
|
+
`);this.extractFromAST(s.program?s.program:s,o,n);}catch(r){n.errors?.push(`React \u89E3\u6790\u5931\u8D25: ${String(r)}`);}return n}extractFromAST(e,t,n){let r=e.body;n.fileDependencies=fe(r,n.filePath);for(let s of r||[]){if(s.type==="FunctionDeclaration"||s.type==="ExportDefaultDeclaration"&&s.declaration?.type==="FunctionDeclaration"||s.type==="ExportNamedDeclaration"&&s.declaration?.type==="FunctionDeclaration"){let o=s.type==="FunctionDeclaration"?s:s.declaration,a=s.type!=="FunctionDeclaration";o&&o.id?.type==="Identifier"&&this.processFunction(o,t,n,a);}if(s.type==="VariableDeclaration"||s.type==="ExportNamedDeclaration"&&s.declaration?.type==="VariableDeclaration"||s.type==="ExportDefaultDeclaration"&&s.declaration?.type==="VariableDeclaration"){let o=s.type==="VariableDeclaration"?s:s.declaration,a=s.type!=="VariableDeclaration";if(o)for(let c of o.declarations||[]){let l=c.init;if(l&&(l.type==="ArrowFunctionExpression"||l.type==="FunctionExpression")&&c.id?.type==="Identifier"){let p={...l,id:c.id,loc:{start:o.loc?.start??l.loc?.start,end:l.loc?.end}};this.processFunction(p,t,n,a);}}}}n.exportSignatureEntries=rt(r,n.symbols);}processFunction(e,t,n,r=false){let s=e.id?.name;if(!s)return;let o=e.loc,a=o?.start?.line??1,c=o?.end?.line??1,l=be(s),p=!l&&/^[A-Z]/.test(s),d=V(t.join(`
|
|
423
|
+
`),a),u=this.extractParams(e),f=this.buildSymbolKey(s,a,c);n.symbols.push({name:s,category:l?"hook":p?"component":"function",framework:"react",startLine:a,endLine:c,internalKey:f,signature:`${s}(${(u||[]).join(", ")})`,params:u,isAsync:e.async===true,isExported:r,jsdoc:d,parentComponent:p?s:void 0,camelWords:k(s)});let m=e.body;if(m?.type!=="BlockStatement")return;let g=m.body;for(let h of g||[])this.processComponentStatement(h,s,t,n);let y=G(m,s,t,true);n.behaviors.push(...y);let b=ne(m,s,t,true);for(let h of b){let E=n.symbols.findIndex(N=>N.name===s&&N.startLine===a);if(h.args&&E!==-1){let N=String(h.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");n.symbols[E].camelWords+=` ${k(N)} ${N}`;}n.relations.push(H({callerName:s,callerLine:a,callerKey:f,calleeName:h.calleeName,callType:"direct_call",line:h.line,args:h.args}));}let T=cn(m);for(let h of T)n.relations.push(H({callerName:s,callerLine:a,callerKey:f,calleeName:h.calleeName,callType:"jsx_event",line:h.line}));}processComponentStatement(e,t,n,r){let s=o=>{let a=o?.loc;return {start:a?.start?.line??1,end:a?.end?.line??1}};if(e.type==="VariableDeclaration")for(let o of e.declarations||[]){let a=o.init;if(!a||a.type!=="CallExpression")continue;let c=a.callee;if(c?.type!=="Identifier")continue;let l=c.name,{start:p,end:d}=s(e),u=p,f=d;if(St.includes(l)&&l!=="useRef"){if(o.id?.type==="ArrayPattern"){let m=o.id.elements,g=m[0]?.name,y=m[1]?.name;if(g){let b=a.arguments;r.symbols.push({name:g,category:"state",framework:"react",startLine:u,endLine:f,internalKey:this.buildSymbolKey(g,u,f,t),stateSetterName:y,defaultValue:this.getLiteralValue(b?.[0]),parentComponent:t,camelWords:k(g)});}}else if(o.id?.type==="Identifier"){let m=o.id.name;r.symbols.push({name:m,category:"state",framework:"react",startLine:u,endLine:f,internalKey:this.buildSymbolKey(m,u,f,t),parentComponent:t,camelWords:k(m)});}}if(l==="useRef"&&o.id?.type==="Identifier"){let m=o.id.name,g=a.arguments;r.symbols.push({name:m,category:"state",framework:"react",startLine:u,endLine:f,internalKey:this.buildSymbolKey(m,u,f,t),defaultValue:this.getLiteralValue(g?.[0]),parentComponent:t,camelWords:k(m)});}if(xt.includes(l)&&o.id?.type==="Identifier"){let m=o.id.name,y=a.arguments?.[1],b=this.extractDepsArray(y);r.symbols.push({name:m,category:"computed",framework:"react",startLine:u,endLine:f,internalKey:this.buildSymbolKey(m,u,f,t),hookDeps:b,parentComponent:t,camelWords:k(m)});}if(be(l)&&!xr.includes(l)){let m=o.id?.type==="Identifier"?o.id.name:o.id?.type==="ObjectPattern"?"{...}":"?";r.symbols.push({name:m,category:"hook",framework:"react",startLine:u,endLine:f,internalKey:this.buildSymbolKey(m,u,f,t),parentComponent:t,camelWords:k(m)});}}if(e.type==="ExpressionStatement"&&e.expression?.type==="CallExpression"){let o=e.expression,a=o.callee;if(a?.type==="Identifier"){let c=a.name;if(At.includes(c)){let{start:l,end:p}=s(e),d=o.arguments,u=d?.[1],f=this.extractDepsArray(u),m=this.buildSymbolKey(c,l,p,t),g=`${t}.${c}`;if(r.symbols.push({name:c,category:"effect",framework:"react",startLine:l,endLine:p,internalKey:m,hookDeps:f,parentComponent:t,camelWords:k(c)}),d?.[0]){let y=G(d[0],g,n,true).map(T=>({...T,symbolKey:m}));r.behaviors.push(...y);let b=ne(d[0],g,n,true);for(let T of b){let h=r.symbols.findIndex(E=>E.name===c&&E.startLine===l);if(T.args&&h!==-1){let E=String(T.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");r.symbols[h].camelWords+=` ${k(E)} ${E}`;}r.relations.push(H({callerName:g,callerLine:l,callerKey:m,calleeName:T.calleeName,callType:"direct_call",line:T.line,args:T.args}));}}}}}if(e.type==="FunctionDeclaration"&&e.id?.type==="Identifier"){let o=e.id.name;if(!be(o)){let{start:a,end:c}=s(e),l=V(n.join(`
|
|
424
|
+
`),a),p=this.extractParams(e);if(r.symbols.push({name:o,category:"method",framework:"react",startLine:a,endLine:c,internalKey:this.buildSymbolKey(o,a,c,t),signature:`${o}(${(p||[]).join(", ")})`,params:p,isAsync:e.async===true,jsdoc:l,parentComponent:t,camelWords:k(o)}),e.body){let d=G(e.body,o,n,true);r.behaviors.push(...d);let u=ne(e.body,o,n,true);for(let f of u){let m=r.symbols.findIndex(g=>g.name===o&&g.startLine===a);if(f.args&&m!==-1){let g=String(f.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");r.symbols[m].camelWords+=` ${k(g)} ${g}`;}r.relations.push(H({callerName:o,callerLine:a,callerKey:this.buildSymbolKey(o,a,c,t),calleeName:f.calleeName,callType:"direct_call",line:f.line,args:f.args}));}}}}if(e.type==="VariableDeclaration")for(let o of e.declarations||[]){let a=o.init;if(!a)continue;let c=a.type==="ArrowFunctionExpression"||a.type==="FunctionExpression";if(!c||o.id?.type!=="Identifier")continue;let l=o.id.name,p=a.type==="CallExpression"?a.callee:null;if(p?.type==="Identifier"&&be(p.name))continue;if(a.type==="CallExpression"&&a.callee?.name==="useCallback"){let b=a.arguments?.[1],T=this.extractDepsArray(b),{start:h,end:E}=s(e);r.symbols.push({name:l,category:"computed",framework:"react",startLine:h,endLine:E,internalKey:this.buildSymbolKey(l,h,E,t),hookDeps:T,parentComponent:t,camelWords:k(l)});continue}if(!c)continue;let{start:u,end:f}=s(e),m=V(n.join(`
|
|
425
|
+
`),u),g=this.extractParams(a);if(r.symbols.push({name:l,category:"method",framework:"react",startLine:u,endLine:f,internalKey:this.buildSymbolKey(l,u,f,t),signature:`${l}(${(g||[]).join(", ")})`,params:g,isAsync:a.async===true,jsdoc:m,parentComponent:t,camelWords:k(l)}),a.body){let y=G(a.body,l,n,true);r.behaviors.push(...y);let b=ne(a.body,l,n,true);for(let T of b){let h=r.symbols.findIndex(E=>E.name===l&&E.startLine===u);if(T.args&&h!==-1){let E=String(T.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");r.symbols[h].camelWords+=` ${k(E)} ${E}`;}r.relations.push(H({callerName:l,callerLine:u,callerKey:this.buildSymbolKey(l,u,f,t),calleeName:T.calleeName,callType:"direct_call",line:T.line,args:T.args}));}}}}extractDepsArray(e){if(!(!e||e.type!=="ArrayExpression"))return (e.elements||[]).filter(t=>!!t&&t.type==="Identifier").map(t=>t.name)}extractParams(e){let t=e.params;if(t)return t.map(n=>n.type==="Identifier"?n.name:n.type==="ObjectPattern"?"{...}":n.type==="ArrayPattern"?"[...]":n.type==="AssignmentPattern"?n.left?.name||"?":n.type==="RestElement"?`...${n.argument?.name||""}`:n.type==="TSParameterProperty"&&n.parameter?.name||"?")}getLiteralValue(e){if(e){if(e.type==="Literal"||e.type==="StringLiteral"||e.type==="NumericLiteral"||e.type==="BooleanLiteral")return String(e.value);if(e.type==="NullLiteral")return "null";if(e.type==="ObjectExpression")return "{}";if(e.type==="ArrayExpression")return "[]";if(e.type==="Identifier"&&e.name==="null")return "null"}}buildSymbolKey(e,t,n,r){return `${r||"root"}:${e}:${t}:${n}`}};var Lr=createRequire(import.meta.url),it=class{name="ToolingTsParser";canParse(e){let t=e.split(".").pop()?.toLowerCase();return ["js","jsx","ts","tsx"].includes(t||"")}parse(e,t){let n=e.endsWith(".ts")||e.endsWith(".tsx")?"ts":"js",r={framework:n,filePath:e,symbols:[],relations:[],behaviors:[],errors:[]};try{let o=Lr("@babel/parser").parse(t,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy","classProperties"],errorRecovery:!0}),a=t.split(`
|
|
426
|
+
`),c=(o.program||o).body,l=new Set;r.fileDependencies=fe(c||[],e);for(let p of c||[])this.processTopLevelStatement(p,a,n,r,l);if(l.size>0)for(let p of r.symbols)l.has(p.name)&&(p.isExported=!0);r.exportSignatureEntries=rt(c||[],r.symbols);}catch(s){r.errors?.push(`Tooling \u89E3\u6790\u5931\u8D25: ${String(s)}`);}return r}processTopLevelStatement(e,t,n,r,s){if(e.type==="FunctionDeclaration"){this.addTopLevelFunction(e,t,n,r,false);return}if(e.type==="ExportNamedDeclaration"||e.type==="ExportDefaultDeclaration"){let o=e.declaration;if(!o){this.collectDeferredExportNames(e,s);return}if(o.type==="FunctionDeclaration"){this.addTopLevelFunction(o,t,n,r,true);return}if(o.type==="ClassDeclaration"){this.addClass(o,t,n,r,true);return}if(o.type==="VariableDeclaration"){this.processVariableDeclaration(o,t,n,r,true);return}this.collectDeferredExportNames(e,s);return}if(e.type==="ClassDeclaration"){this.addClass(e,t,n,r,false);return}e.type==="VariableDeclaration"&&this.processVariableDeclaration(e,t,n,r,false);}collectDeferredExportNames(e,t){if(e.type==="ExportNamedDeclaration"){if(e.source?.type==="StringLiteral")return;for(let r of e.specifiers||[]){let s=r.local;s?.type==="Identifier"&&t.add(String(s.name||""));}return}if(e.type==="ExportDefaultDeclaration"){let n=e.declaration;n?.type==="Identifier"&&t.add(String(n.name||""));}}processVariableDeclaration(e,t,n,r,s){for(let o of e.declarations||[]){let a=o.id;if(!a||a.type!=="Identifier")continue;let c=String(a.name||"");if(!c)continue;let l=o.init,{start:p,end:d}=this.getLineRange(o);if(l&&(l.type==="ArrowFunctionExpression"||l.type==="FunctionExpression")){this.addFunctionSymbol(c,l,t,n,r,{startLine:p,endLine:d,isExported:s});continue}r.symbols.push({name:c,category:"constant",framework:n,startLine:p,endLine:d,isExported:s,defaultValue:this.getLiteralValue(l),camelWords:k(c)});}}addTopLevelFunction(e,t,n,r,s){let o=e.id?.name;if(!o)return;let{start:a,end:c}=this.getLineRange(e);this.addFunctionSymbol(o,e,t,n,r,{startLine:a,endLine:c,isExported:s});}addFunctionSymbol(e,t,n,r,s,o){let a=this.buildSymbolKey(e,o.startLine,o.endLine,o.ownerClass),c=this.extractParams(t);s.symbols.push({name:e,category:o.ownerClass?"method":"function",framework:r,startLine:o.startLine,endLine:o.endLine,internalKey:a,signature:`${e}(${(c||[]).join(", ")})`,params:c,isAsync:t.async===true,isExported:o.isExported,jsdoc:V(n.join(`
|
|
427
|
+
`),o.startLine),parentComponent:o.ownerClass,camelWords:k(e)});let l=t.body;if(!l)return;let p=G(l,e,n,true);s.behaviors.push(...p);let d=ne(l,e,n,true);for(let f of d)s.relations.push(H({callerName:e,callerLine:o.startLine,callerKey:a,calleeName:f.calleeName,callType:"direct_call",line:f.line,args:f.args}));let u=we(l,e);for(let f of u)s.relations.push(H({callerName:e,callerLine:o.startLine,callerKey:a,calleeName:f.calleeName,callType:"this_method",line:f.line,args:f.args}));}addClass(e,t,n,r,s){let o=e.id?.name;if(!o)return;let{start:a,end:c}=this.getLineRange(e);r.symbols.push({name:o,category:"class",framework:n,startLine:a,endLine:c,isExported:s,jsdoc:V(t.join(`
|
|
428
|
+
`),a),camelWords:k(o)});let l=e.body?.body;for(let p of l||[]){let d=p.key,u=d?.type==="Identifier"?String(d.name||""):"";if(!u||u==="constructor")continue;if(p.type==="ClassMethod"||p.type==="ClassPrivateMethod"){this.addFunctionSymbol(u,p,t,n,r,{startLine:this.getLineRange(p).start,endLine:this.getLineRange(p).end,isExported:false,ownerClass:o});continue}let f=p.value;f&&(f.type==="ArrowFunctionExpression"||f.type==="FunctionExpression")&&(p.type==="ClassProperty"||p.type==="PropertyDefinition")&&this.addFunctionSymbol(u,f,t,n,r,{startLine:this.getLineRange(p).start,endLine:this.getLineRange(p).end,isExported:false,ownerClass:o});}}extractParams(e){let t=e.params;return t?.length?t.map(n=>{if(n.type==="Identifier")return String(n.name||"");if(n.type==="AssignmentPattern"){let r=n.left;return r?.type==="Identifier"?String(r.name||""):"param"}return "param"}):[]}getLiteralValue(e){if(e){if(e.type==="StringLiteral"||e.type==="NumericLiteral"||e.type==="BooleanLiteral")return String(e.value);if(e.type==="NullLiteral")return "null";if(e.type==="ObjectExpression")return "{...}";if(e.type==="ArrayExpression")return "[...]"}}buildSymbolKey(e,t,n,r){return `${r||"root"}:${e}:${t}:${n}`}getLineRange(e){let t=e.loc;return {start:t?.start?.line??1,end:t?.end?.line??1}}};function Y(i){let e=i.property;return e?e.type==="Identifier"?String(e.name||""):e.type==="Literal"||e.type==="StringLiteral"?String(e.value||""):null:null}function ie(i){let e=i.object;return e?e.type==="Identifier"?String(e.name||""):e.type==="ThisExpression"?Y(i):e.type==="MemberExpression"?e.object?.type==="ThisExpression"?Y(e):ie(e):null:null}function ee(i,e){let t=i||"";return /created|mounted|beforeMount|setup\s*\(|\bdata\s*\(/.test(t)?"init":/getItem|localStorage|sessionStorage|\bfetch\b|\bload[A-Z]|\bget[A-Z]/.test(t)?"cache":/@click|@change|@input|onClick|onChange|handle[A-Z]|\bwatch\b/.test(t)?"user":e<=30?"init":"unknown"}var Rr=new Set(["FunctionDeclaration","ArrowFunctionExpression","FunctionExpression","ObjectMethod","ClassMethod","ClassProperty"]);function un(i,e){return !!e?.skipNestedFunctions&&Rr.has(String(i.type||""))}function me(i,e,t){if(!(!i||typeof i!="object")){e(i);for(let n of Object.keys(i)){if(n==="type"||n==="loc"||n==="start"||n==="end")continue;let r=i[n];if(Array.isArray(r)){for(let s of r){if(!s||typeof s!="object"||!s.type)continue;let o=s;un(o,t)||me(o,e,t);}continue}if(r&&typeof r=="object"&&r.type){let s=r;if(un(s,t))continue;me(s,e,t);}}}}function fn(i,e,t=true,n){let r=[],s=[],o=(a,c=120)=>kr(a,n,c);return me(i,a=>{if(a.type==="VariableDeclarator"){let c=a.id;if(!c)return;let l=ot(c),p=o(a);for(let d of l)r.push({symbolName:d,kind:"declaration",line:Ce(a),text:p,sourceLayer:ee(p,Ce(a))});}if(a.type==="AssignmentExpression"){let c=a.left;if(!c)return;let l=o(a),p=Ce(a);if(c.type==="Identifier"&&r.push({symbolName:c.name,kind:"assignment",line:p,text:l,sourceLayer:ee(l,p)}),c.type==="MemberExpression"&&c.object?.type==="ThisExpression"){let u=Y(c);if(u){r.push({symbolName:u,kind:"assignment",line:p,text:l,sourceLayer:ee(l,p)});return}}if(c.type==="MemberExpression"){let d=ie(c);if(d&&vt(d)){let u=Y(c);s.push({objectName:d,propertyName:u||void 0,line:p,text:l,kind:c.computed?"bracket":"dot",sourceLayer:ee(l,p)});}}}if(a.type==="UpdateExpression"){let c=a.argument;if(!c)return;let l=o(a),p=Ce(a);if(c.type==="Identifier"&&r.push({symbolName:c.name,kind:"update",line:p,text:l,sourceLayer:ee(l,p)}),c.type==="MemberExpression"&&c.object?.type==="ThisExpression"){let u=Y(c);if(u){r.push({symbolName:u,kind:"update",line:p,text:l,sourceLayer:ee(l,p)});return}}if(c.type==="MemberExpression"){let d=ie(c);if(d&&vt(d)){let u=Y(c);s.push({objectName:d,propertyName:u||void 0,line:p,text:l,kind:c.computed?"bracket":"dot",sourceLayer:ee(l,p)});}}}if(a.type==="UnaryExpression"&&a.operator==="delete"){let c=a.argument;if(c?.type==="MemberExpression"){let l=ie(c);if(l&&vt(l)){let p=Y(c);s.push({objectName:l,propertyName:p||void 0,line:Ce(a),text:o(a),kind:"delete",sourceLayer:ee(o(a),Ce(a))});}}}},{skipNestedFunctions:t}),{assignments:r,propertyWrites:s}}function ot(i){return i.type==="Identifier"?[i.name]:i.type==="ObjectPattern"?(i.properties||[]).flatMap(t=>{let n=t.type==="ObjectProperty"||t.type==="Property"?t.value:t;return n?ot(n):[]}):i.type==="ArrayPattern"?(i.elements||[]).flatMap(t=>t?ot(t):[]):i.type==="AssignmentPattern"?ot(i.left):[]}function vt(i){return !(/^[A-Z][A-Z]/.test(i)||/^(document|window|console|localStorage|sessionStorage|navigator|process|global|globalThis)$/.test(i))}function Ce(i){return i.loc?.start?.line??1}function kr(i,e,t=120){if(e){let r=i.loc;if(r?.start?.line&&r?.end?.line){let s=r.start.line-1,o=Math.min(r.end.line-1,s+5);return e.slice(s,o+1).map(c=>c.trim()).filter(c=>c).join(" ").slice(0,t)}}let n=i.loc;return n?.start?.line?`L${n.start.line}`:String(i.type||"?")}var vr=createRequire(import.meta.url);function It(i,e){let t={files:new Map,resolutionCache:new Map,localShadowCache:new Map};for(let{path:n,content:r}of i){let s=pn(n,r);t.files.set(n,s);let o=new Map;for(let a of s.imports)a.localName&&o.set(a.localName,`${a.resolvedFile}::${a.originalName}`);t.resolutionCache.set(n,o),t.localShadowCache.set(n,Cr(r));}return t}function $t(i,e,t,n){if(t.files.size===0)return i;let r=t.resolutionCache.get(e);if(!r||r.size===0)return i;let s=t.localShadowCache.get(e);return t.files.get(e)?i.map(c=>{let l=r.get(c.calleeName);return !l||c.callerKey&&s?.get(c.callerKey)?.has(c.calleeName)||n.has(c.calleeName)?c:{...c,edgeKind:"precise",importSource:c.importSource||l}}):i}function Cr(i){let e=new Map;try{let n=vr("@babel/parser").parse(i,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy","classProperties"],errorRecovery:!0}),r=(n.program||n).body;if(!r?.length)return e;for(let s of r)gn(s,e);}catch{return e}return e}function gn(i,e){if(i.type==="FunctionDeclaration"){let t=xe(i.id);if(!t)return;Ie(t,i,e),Ir(Pr(i),t,e);return}if(i.type==="VariableDeclaration"){hn(i,void 0,e);return}if(i.type==="ClassDeclaration"){$r(i,e);return}if(i.type==="ExportNamedDeclaration"||i.type==="ExportDefaultDeclaration"){let t=i.declaration;if(!t)return;gn(t,e);}}function Ir(i,e,t){for(let n of i){if(n.type==="FunctionDeclaration"){let r=xe(n.id);if(!r)continue;Ie(r,n,t,e);continue}if(n.type==="VariableDeclaration"){hn(n,e,t);continue}if(n.type==="ExpressionStatement"){let r=n.expression;if(r?.type!=="CallExpression")continue;let s=r.callee,o=s?.type==="Identifier"?String(s.name||""):"";if(!/^use[A-Z]/.test(o))continue;let a=r.arguments?.[0];if(!a||a.type!=="ArrowFunctionExpression"&&a.type!=="FunctionExpression")continue;Ie(o,a,t,e,n);}}}function hn(i,e,t){for(let n of i.declarations||[]){let r=xe(n.id),s=n.init;!r||!s||s.type!=="ArrowFunctionExpression"&&s.type!=="FunctionExpression"||Ie(r,s,t,e,n);}}function $r(i,e){let t=xe(i.id);if(!t)return;let n=i.body?.body||[];for(let r of n){let s=xe(r.key);if(!s||s==="constructor")continue;if(r.type==="ClassMethod"||r.type==="ClassPrivateMethod"){Ie(s,r,e,t);continue}let o=r.value;o&&(o.type==="ArrowFunctionExpression"||o.type==="FunctionExpression")&&(r.type==="ClassProperty"||r.type==="PropertyDefinition")&&Ie(s,o,e,t,r);}}function Ie(i,e,t,n,r){let s=Fr(r||e),o=Dr(i,s.start,s.end,n),a=Or(e);t.set(o,a);}function Or(i){let e=new Set;for(let n of i.params||[])for(let r of Se(n))e.add(r);let t=i.body;return t&&Ct(t,n=>{if(n.type==="VariableDeclarator"){for(let r of Se(n.id))e.add(r);return}if(n.type==="FunctionDeclaration"){let r=xe(n.id);return r&&e.add(r),false}if(n.type==="ClassDeclaration"){let r=xe(n.id);return r&&e.add(r),false}}),e}function Ct(i,e){if(!(!i||typeof i!="object")&&e(i)!==false)for(let t of Object.keys(i)){if(t==="type"||t==="loc"||t==="start"||t==="end")continue;let n=i[t];if(Array.isArray(n)){for(let r of n){if(!r||typeof r!="object"||!r.type)continue;let s=r;mn(s)||Ct(s,e);}continue}if(n&&typeof n=="object"&&n.type){let r=n;if(mn(r))continue;Ct(r,e);}}}function mn(i){return ["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression","ClassMethod","ClassPrivateMethod","ObjectMethod"].includes(String(i.type||""))}function Se(i){return i?i.type==="Identifier"?[String(i.name||"")]:i.type==="AssignmentPattern"?Se(i.left):i.type==="RestElement"?Se(i.argument):i.type==="ArrayPattern"?(i.elements||[]).flatMap(e=>Se(e)):i.type==="ObjectPattern"?(i.properties||[]).flatMap(e=>{if(e.type==="RestElement")return Se(e.argument);let t=e.value||e.argument;return Se(t)}):[]:[]}function xe(i){if(i&&i.type==="Identifier")return String(i.name||"")}function Pr(i){let e=i.body;return !e||e.type!=="BlockStatement"?[]:e.body||[]}function Fr(i){let e=i.loc;return {start:e?.start?.line??1,end:e?.end?.line??1}}function Dr(i,e,t,n){return n?`${n}:${i}:${e}:${t}`:`root:${i}:${e}:${t}`}var yn=createRequire(import.meta.url);function bn(i,e){let t=i.errors||[];t.includes(e)||(i.errors=[...t,e]);}var Ot=class extends je{name="JsTsFallbackParser";canParse(e){let t=e.split(".").pop()?.toLowerCase();return ["js","ts","jsx","tsx"].includes(t||"")}parse(e,t){let n=super.parse(e,t);return n.framework=e.endsWith(".ts")||e.endsWith(".tsx")?"ts":"js",n}},jr=[new st,new ve,new je,new it,new Ot];function Ue(i,e){for(let t of jr)if(t.canParse(i,e)){let n=t.parse(i,e);return Wr(n),Ur(n,e),n}return {framework:"js",filePath:i,symbols:[],relations:[],behaviors:[],errors:[`\u6CA1\u6709\u627E\u5230\u9002\u5408\u7684\u89E3\u6790\u5668: ${i}`]}}function Ur(i,e){if(i.symbols.length!==0)try{let t=e,n=i.filePath.endsWith(".vue"),r=0;if(n)try{let{parse:u}=yn("@vue/compiler-sfc"),{descriptor:f}=u(e);if(f.scriptSetup?.content)t=f.scriptSetup.content,r=f.scriptSetup.loc.start.line-1;else if(f.script?.content)t=f.script.content,r=f.script.loc.start.line-1;else return}catch(u){bn(i,`\u751F\u547D\u5468\u671F\u63D0\u53D6\u8DF3\u8FC7: Vue SFC \u89E3\u6790\u5931\u8D25 - ${String(u)}`);return}let a=yn("@babel/parser").parse(t,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy"],errorRecovery:!0}).program.body;if(!a?.length)return;let c=t.split(`
|
|
429
|
+
`),{assignments:l,propertyWrites:p}=fn({type:"Program",body:a},i.filePath,!1,c);if(r>0){for(let u of l)u.line+=r;for(let u of p)u.line+=r;}let d=new Set(i.symbols.map(u=>u.name));i.assignments=l.filter(u=>d.has(u.symbolName)),i.propertyWrites=p.filter(u=>d.has(u.objectName));}catch(t){bn(i,`\u751F\u547D\u5468\u671F\u63D0\u53D6\u8DF3\u8FC7: AST \u89E3\u6790\u5931\u8D25 - ${String(t)}`);}}function Wr(i){if(!i.relations.length||!i.behaviors.length)return;let e=new Set(["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","activated","deactivated","errorCaptured","setup","onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","onActivated","onDeactivated","onErrorCaptured","componentDidMount","componentDidUpdate","componentWillUnmount","componentDidCatch","getDerivedStateFromProps","getSnapshotBeforeUpdate","render","init","initialize"]),t=new Set(i.behaviors.filter(r=>r.category==="network").map(r=>r.symbolName));if(t.size===0)return;let n=new Set(i.behaviors.map(r=>`${r.symbolName}:${r.category}:${r.apiName}:${r.operation}:${r.line}`));for(let r of i.relations){if(!t.has(r.calleeName)||t.has(r.callerName)||e.has(r.callerName))continue;let s={symbolName:r.callerName,symbolKey:r.callerKey,category:"network",apiName:"wrapped_network",operation:r.calleeName,detail:r.args,line:r.line},o=`${s.symbolName}:${s.category}:${s.apiName}:${s.operation}:${s.line}`;n.has(o)||(n.add(o),i.behaviors.push(s));}}function We(i,e){let t=Hr(e),n=i.exportSignatureEntries?.length?[...i.exportSignatureEntries]:(()=>{let a=[];for(let c of i.symbols)if(c.isExported){let l=c.signature||"";a.push(`${c.name}:${l}`);}return a.sort(),a})(),r=n.length>0?En(n.join(`
|
|
430
|
+
`)):"",s=[];if(i.fileDependencies&&i.fileDependencies.length>0)for(let a of i.fileDependencies)(a.dependencyKind==="import"||a.dependencyKind==="re_export")&&s.push(a.toFile);s.sort();let o=s.length>0?En(s.join(`
|
|
431
|
+
`)):"";return {contentHash:t,exportSignatureHash:r,importSignatureHash:o}}function Nn(i,e){if(!i)return "full_changed";if(i.contentHash===e.contentHash)return "unchanged";let t=i.exportSignatureHash!==e.exportSignatureHash,n=i.importSignatureHash!==e.importSignatureHash;return t&&n?"full_changed":t?"export_changed":n?"import_changed":"body_only"}function Tn(i,e,t,n=200){if(e==="unchanged")return {files:[],truncated:false};if(e==="body_only")return {files:[i],truncated:false};if(e==="import_changed")return {files:[i],truncated:false};let r=new Set([i]),s=[i];for(;s.length>0;){let o=s.shift(),a=t.get(o)||[];for(let c of a)if(!r.has(c)){if(r.add(c),r.size>=n)return {files:Array.from(r),truncated:true};s.push(c);}}return {files:Array.from(r),truncated:false}}function Hr(i){return createHash("sha256").update(i,"utf-8").digest("hex").slice(0,16)}function En(i){return createHash("sha256").update(i,"utf-8").digest("hex").slice(0,12)}var Br={maxFiles:20,maxTimeMs:1500},at=class{pending=[];options;constructor(e){this.options={...Br,...e};}configure(e){this.options={...this.options,...e};}enqueue(e,t){let n=this.pending.find(r=>r.relPath===e);if(n){let r={high:3,normal:2,low:1};r[t]>r[n.priority]&&(n.priority=t);return}this.pending.push({relPath:e,priority:t,addedAt:Date.now()});}dequeueBatch(){if(this.pending.length===0)return {tasks:[],exceededBudget:false,remainingPending:0};let e={high:0,normal:1,low:2};this.pending.sort((s,o)=>{let a=e[s.priority],c=e[o.priority];return a!==c?a-c:s.addedAt-o.addedAt});let t=[],n=this.pending.length>this.options.maxFiles;for(let s=0;s<Math.min(this.options.maxFiles,this.pending.length);s++)t.push(this.pending[s]);let r=new Set(t.map(s=>s.relPath));return this.pending=this.pending.filter(s=>!r.has(s.relPath)),{tasks:t,exceededBudget:n,remainingPending:this.pending.length}}requeue(e){if(e.length===0)return;let t=new Set(this.pending.map(r=>r.relPath)),n=e.filter(r=>!t.has(r.relPath));this.pending=[...n,...this.pending];}clear(){this.pending=[];}get pendingCount(){return this.pending.length}get budget(){return this.options}summary(){return this.pending.map(e=>({relPath:e.relPath,priority:e.priority}))}};var ct=class{projectRoot;db;scheduler;constructor(e,t){this.projectRoot=e,this.db=t,this.scheduler=new at;}getScheduler(){return this.scheduler}enhancePreciseRelations(e){try{let t=e.filter(({absPath:r})=>/\.(ts|tsx|js|jsx)$/i.test(r)).map(({absPath:r,content:s})=>({path:r,content:s})),n=It(t,"precise");if(n.files.size===0)return;for(let r of e){if(r.result.relations.length===0)continue;let s=new Set(r.result.symbols.map(o=>o.name));r.result.relations=$t(r.result.relations,r.result.filePath,n,s);}}catch(t){let n=`precise enhancement \u5931\u8D25\uFF0C\u5DF2\u56DE\u9000\u5230\u672C\u5730 relations: ${String(t)}`;process.stderr.write(`[Frontend-Code-Skimmer] ${n}
|
|
432
|
+
`);for(let r of e){let s=r.result.errors||[];s.includes(n)||(r.result.errors=[...s,n]);}}}async indexProject(e){let t=Date.now(),n=e?.include||[..._t],r=e?.exclude||[...Et],s=e?.force||false,o=Date.now(),a=await Xr(n,{cwd:this.projectRoot,ignore:r,absolute:true,onlyFiles:true}),c=Date.now()-o,l={totalFiles:a.length,indexedFiles:0,skippedFiles:0,totalSymbols:0,durationMs:0,phaseTimings:{discoverFilesMs:c,readFilesMs:0,parseMs:0,saveToDbMs:0,totalMs:0},errors:[]},p=0,d=0,u=0;if((e?.precisionMode||"heuristic")==="precise"){let m=[];for(let g=0;g<a.length;g++){let y=a[g],b=de(y,this.projectRoot);e?.onProgress?.(g+1,a.length,b);try{let T=Z__default.statSync(y).mtimeMs,h=Date.now(),E=Z__default.readFileSync(y,"utf-8"),N=Date.now()-h,R=Date.now(),_=Ue(y,E),x=Date.now()-R;p+=N,d+=x,m.push({absPath:y,relPath:b,result:_,parseMs:x,readMs:N,content:E,mtime:T});}catch(T){this.db.recordIndexFailure(b,String(T)),l.errors.push({file:b,error:String(T)});}}this.enhancePreciseRelations(m);for(let g of m){let y=Date.now();try{let b=Fe(g.content),T=Ge(g.content),h=Buffer.byteLength(g.content,"utf-8"),E=We(g.result,g.content);this.db.saveParseResult(g.result,g.absPath,g.relPath,b,h,T,g.mtime,E.exportSignatureHash,E.importSignatureHash),l.indexedFiles++,l.totalSymbols+=g.result.symbols.length,g.result.errors?.length&&l.errors.push(...g.result.errors.map(N=>({file:g.relPath,error:N}))),u+=Date.now()-y;}catch(b){this.db.recordIndexFailure(g.relPath,String(b)),l.errors.push({file:g.relPath,error:String(b)});}}}else for(let m=0;m<a.length;m++){let g=a[m],y=de(g,this.projectRoot);e?.onProgress?.(m+1,a.length,y);try{let b=await this.indexFile(g,y,s);b.skipped?l.skippedFiles++:(l.indexedFiles++,l.totalSymbols+=b.symbolCount,p+=b.readMs||0,d+=b.parseMs||0,u+=b.saveMs||0,b.errors?.length&&l.errors.push(...b.errors.map(T=>({file:y,error:T}))));}catch(b){this.db.recordIndexFailure(y,String(b)),l.errors.push({file:y,error:String(b)});}}return l.phaseTimings.readFilesMs=p,l.phaseTimings.parseMs=d,l.phaseTimings.saveToDbMs=u,l.phaseTimings.totalMs=Date.now()-t,l.durationMs=l.phaseTimings.totalMs,l}async selectivePrecise(e){let t=Date.now(),n=e?.maxFiles??20,r=e?.maxTimeMs??1500;this.scheduler.configure({maxFiles:n,maxTimeMs:r});let s=this.db.getAllFilePaths(),o=this.db.getReverseDependencyMap(),a=new Set;for(let y of s){let b=this.fileAbsPath(y);if(!Z__default.existsSync(b))continue;let T=this.db.getFileSignatures(y);if(!T){this.scheduler.enqueue(y,"low");continue}let h;try{h=Z__default.statSync(b);let O=this.db.getFileHashAndMtime(y);if(O&&O.mtime===h.mtimeMs&&O.contentHash)continue}catch{continue}let E=Z__default.readFileSync(b,"utf-8"),N=Fe(E);if(T.contentHash===N){this.db.updateFileMtime(y,h.mtimeMs);continue}let R=Ue(b,E),_=We(R,E),x=Nn(T,_);if(x==="unchanged")continue;let{files:A,truncated:w}=Tn(y,x,o);w&&process.stderr.write(`[Frontend-Code-Skimmer] \u26A0\uFE0F ${y} \u7684\u53CD\u5411\u4F9D\u8D56\u6269\u6563\u5DF2\u8FBE\u4E0A\u9650\uFF08200\uFF09\uFF0C\u90E8\u5206\u4E0B\u6E38\u6587\u4EF6\u5C06\u8DF3\u8FC7\u672C\u6B21 precise \u91CD\u7B97
|
|
433
|
+
`);for(let O of A)a.add(O);let M=x==="export_changed"||x==="full_changed"?"high":x==="import_changed"?"normal":"low";for(let O of A)this.scheduler.enqueue(O,M);}let{tasks:c,exceededBudget:l,remainingPending:p}=this.scheduler.dequeueBatch(),d=[],u=[],f=0;for(let y=0;y<c.length;y++){let T=c[y].relPath;if(a.add(T),Date.now()-t>=r){u.push(...c.slice(y));break}let h=this.fileAbsPath(T);if(!Z__default.existsSync(h)){this.removeFile(T);continue}try{let E=Z__default.readFileSync(h,"utf-8"),N=Ue(h,E),R=Fe(E),_=Ge(E),x=Buffer.byteLength(E,"utf-8");d.push({absPath:h,relPath:T,result:N,content:E,hash:R,lineCount:_,fileSize:x,mtime:Z__default.statSync(h).mtimeMs});}catch(E){this.db.recordIndexFailure(T,String(E)),process.stderr.write(`[Frontend-Code-Skimmer] Selective precise \u5931\u8D25: ${T} - ${String(E)}
|
|
434
|
+
`);}}u.length>0&&this.scheduler.requeue(u),this.enhancePreciseRelations(d);for(let y of d)try{let b=We(y.result,y.content);this.db.saveParseResult(y.result,y.absPath,y.relPath,y.hash,y.fileSize,y.lineCount,y.mtime,b.exportSignatureHash,b.importSignatureHash),f++;}catch(b){this.db.recordIndexFailure(y.relPath,String(b)),process.stderr.write(`[Frontend-Code-Skimmer] Selective precise \u843D\u5E93\u5931\u8D25: ${y.relPath} - ${String(b)}
|
|
435
|
+
`);}let m=Date.now()-t,g=p+u.length;return process.stderr.write(`[Frontend-Code-Skimmer] Selective precise: ${f}/${a.size} affected, ${m}ms, pending: ${g}${l||u.length>0?" (budget limited)":""}
|
|
436
|
+
`),{reindexedFiles:f,affectedFiles:Array.from(a),skippedByBudget:g}}async indexFile(e,t,n=false){let r=0,s=0,o=null;if(!n){try{let h=Z__default.statSync(e);r=h.mtimeMs,s=h.size;}catch{}if(o=this.db.getFileMeta(t),o&&o.mtime>0&&o.mtime===r&&!(o.fileSize>0&&o.fileSize!==s))return {skipped:true,symbolCount:0,readMs:0,parseMs:0,saveMs:0}}let a=Date.now(),c=Z__default.readFileSync(e,"utf-8"),l=Date.now()-a,p=Fe(c);if(!n&&o&&o.hash===p)return r>0&&o.mtime!==r&&this.db.updateFileMtime(t,r),{skipped:true,symbolCount:0,readMs:l,parseMs:0,saveMs:0};let d=Ge(c),u=Buffer.byteLength(c,"utf-8"),f=Date.now(),m=Ue(e,c),g=Date.now()-f,y=We(m,c),b=Date.now();this.db.clearIndexFailures(t),this.db.saveParseResult(m,e,t,p,u,d,r,y.exportSignatureHash,y.importSignatureHash);let T=Date.now()-b;return {skipped:false,symbolCount:m.symbols.length,readMs:l,parseMs:g,saveMs:T,errors:m.errors}}removeFile(e){this.db.deleteFile(e);}fileAbsPath(e){return K__default.join(this.projectRoot,e)}async startWatcher(){let{default:e}=await import('chokidar'),t=e.watch([..._t].map(r=>K__default.posix.join(this.projectRoot,r)),{cwd:this.projectRoot,ignored:[...Et],persistent:true,ignoreInitial:true,awaitWriteFinish:{stabilityThreshold:rn}}),n=async r=>{let s=de(r,this.projectRoot);try{await this.indexFile(r,s),this.scheduler.enqueue(s,"normal"),process.stderr.write(`[Frontend-Code-Skimmer] \u5DF2\u66F4\u65B0\u7D22\u5F15: ${s}
|
|
437
|
+
`);}catch(o){process.stderr.write(`[Frontend-Code-Skimmer] \u66F4\u65B0\u5931\u8D25: ${s} - ${String(o)}
|
|
438
|
+
`);}};return t.on("add",n).on("change",n).on("unlink",r=>{let s=de(r,this.projectRoot);this.removeFile(s),process.stderr.write(`[Frontend-Code-Skimmer] \u5DF2\u5220\u9664\u7D22\u5F15: ${s}
|
|
439
|
+
`);}),()=>t.close()}};var zr=8,Gr=30,qr=14,Jr=360*60*1e3,lt=class{dbCache=new Map;accessTimes=new Map;indexerCache=new Map;dbPaths=new Map;watcherCleanups=new Map;lastProject=null;globalCacheDir;defaultProject;maxOpenProjects;maxIdleMs;dbTtlMs;lastDiskCleanupAt=0;constructor(){this.globalCacheDir=K__default.join(Kr.homedir(),".frontend-code-skimmer","databases"),Z__default.mkdirSync(this.globalCacheDir,{recursive:true}),this.defaultProject=process.env.SKIMMER_PROJECT||null,this.defaultProject&&(this.defaultProject=K__default.resolve(this.defaultProject)),this.maxOpenProjects=this.parsePositiveInt(process.env.SKIMMER_MAX_OPEN_PROJECTS,zr);let e=this.parsePositiveInt(process.env.SKIMMER_DB_IDLE_MINUTES,Gr),t=this.parsePositiveInt(process.env.SKIMMER_DB_TTL_DAYS,qr);this.maxIdleMs=e*60*1e3,this.dbTtlMs=t*24*60*60*1e3,this.maybeCleanupDiskCache(Date.now());}resolveProjectRoot(e){if(e){let t=K__default.resolve(e);if(!Z__default.existsSync(t))throw new Error(`\u9879\u76EE\u8DEF\u5F84\u4E0D\u5B58\u5728: ${t}`);return t}return this.lastProject?this.lastProject:this.defaultProject?this.defaultProject:process.cwd()}getDatabase(e){let t=K__default.resolve(e),n=Date.now();if(this.evictIdleDatabases(n),this.maybeCleanupDiskCache(n),this.dbCache.has(t))return this.touchProject(t,n),this.dbCache.get(t);this.evictLruIfNeeded(n);let r=this.resolveDbPath(t),s=new Je(t,r);return this.dbCache.set(t,s),this.dbPaths.set(t,r),this.touchProject(t,n),this.lastProject=t,process.stderr.write(`[Frontend-Code-Skimmer] \u5DF2\u8FDE\u63A5\u9879\u76EE: ${t}
|
|
440
|
+
`),process.stderr.write(`[Frontend-Code-Skimmer] \u6570\u636E\u5E93: ${r}
|
|
441
|
+
`),s}getContext(e){let t=this.resolveProjectRoot(e),n=this.getDatabase(t);return this.lastProject=t,{db:n,projectRoot:t}}getIndexer(e){let t=this.resolveProjectRoot(e),n=K__default.resolve(t),r=Date.now();if(this.evictIdleDatabases(r),this.maybeCleanupDiskCache(r),this.indexerCache.has(n))return this.touchProject(n,r),this.lastProject=n,this.indexerCache.get(n);let s=this.getDatabase(n),o=new ct(n,s);return this.indexerCache.set(n,o),this.touchProject(n,r),this.lastProject=n,o}setLastProject(e){this.lastProject=K__default.resolve(e);}listProjects(){return Array.from(this.dbCache.entries()).map(([e])=>({root:e,dbPath:this.dbPaths.get(e)||this.resolveDbPath(e)}))}registerWatcher(e,t){let n=K__default.resolve(e),r=this.watcherCleanups.get(n);if(r)try{r();}catch{}this.watcherCleanups.set(n,t);}hasWatcher(e){let t=K__default.resolve(e);return this.watcherCleanups.has(t)}closeProject(e){let t=K__default.resolve(e),n=this.watcherCleanups.get(t);if(n){try{n();}catch{}this.watcherCleanups.delete(t);}let r=this.dbCache.get(t);r&&(r.close(),this.dbCache.delete(t),this.accessTimes.delete(t),this.indexerCache.delete(t),this.dbPaths.delete(t),this.lastProject===t&&(this.lastProject=null));}closeAll(){for(let e of this.watcherCleanups.values())try{e();}catch{}this.watcherCleanups.clear();for(let e of this.dbCache.values())e.close();this.dbCache.clear(),this.indexerCache.clear(),this.accessTimes.clear(),this.dbPaths.clear(),this.lastProject=null;}resolveDbPath(e){if(process.env.SKIMMER_DB&&this.dbCache.size===0)return K__default.resolve(process.env.SKIMMER_DB);let t=K__default.join(e,".agent","skimmer_find_symbol"),n=K__default.join(t,qe);try{return Z__default.mkdirSync(t,{recursive:!0}),Z__default.accessSync(e,Z__default.constants.W_OK),n}catch{let r=createHash("md5").update(e).digest("hex").slice(0,8),s=e.replace(/[/\\:]/g,"_").replace(/^_+/,"").slice(-40);return K__default.join(this.globalCacheDir,`${r}_${s}.db`)}}parsePositiveInt(e,t){let n=Number.parseInt(String(e||""),10);return Number.isFinite(n)&&n>0?n:t}touchProject(e,t){this.accessTimes.set(e,t);}evictLruIfNeeded(e){for(;this.dbCache.size>=this.maxOpenProjects;){let t=null,n=Number.POSITIVE_INFINITY;for(let r of this.dbCache.keys()){let s=this.accessTimes.get(r)??e;s<n&&(n=s,t=r);}if(!t)break;this.closeProject(t);}}evictIdleDatabases(e){let t=[];for(let n of this.dbCache.keys()){if(n===this.lastProject)continue;let r=this.accessTimes.get(n)??e;e-r>this.maxIdleMs&&t.push(n);}for(let n of t)this.closeProject(n);}maybeCleanupDiskCache(e){if(e-this.lastDiskCleanupAt<Jr)return;this.lastDiskCleanupAt=e;let t=[];try{t=Z__default.readdirSync(this.globalCacheDir,{withFileTypes:!0});}catch{return}let n=new Set;for(let s of this.dbPaths.values())s.startsWith(this.globalCacheDir)&&n.add(K__default.resolve(s));let r=e-this.dbTtlMs;for(let s of t){if(!s.isFile()||!s.name.endsWith(".db"))continue;let o=K__default.join(this.globalCacheDir,s.name);if(n.has(K__default.resolve(o)))continue;let a;try{a=Z__default.statSync(o);}catch{continue}a.mtimeMs>=r||(this.safeUnlink(o),this.safeUnlink(`${o}-wal`),this.safeUnlink(`${o}-shm`));}}safeUnlink(e){try{Z__default.existsSync(e)&&Z__default.unlinkSync(e);}catch{}}};var pt=createRequire(import.meta.url);function xn(i,e){let t=[];if(i==="heuristic")return {effective:"heuristic",warnings:t};let n=pt("fs"),s=pt("path").join(e,"tsconfig.json");if(!n.existsSync(s))return t.push(`precise \u6A21\u5F0F\u964D\u7EA7\u4E3A heuristic: \u9879\u76EE\u6839\u76EE\u5F55\u672A\u627E\u5230 tsconfig.json (${s})`),{effective:"heuristic",warnings:t};try{pt.resolve("typescript",{paths:[e]});}catch{try{pt.resolve("typescript");}catch{return t.push("precise \u6A21\u5F0F\u964D\u7EA7\u4E3A heuristic: typescript \u5305\u4E0D\u53EF\u7528\uFF08\u53EF\u80FD\u9700\u8981 npm install\uFF09"),{effective:"heuristic",warnings:t}}}return {effective:"precise",warnings:t}}function An(i,e){i.registerTool("skimmer_index_project",{title:"\u7D22\u5F15\u9879\u76EE\u4EE3\u7801\uFF08\u652F\u6301\u4EFB\u610F\u9879\u76EE\uFF09",description:`\u521D\u59CB\u5316\u6216\u589E\u91CF\u66F4\u65B0\u524D\u7AEF\u9879\u76EE\u4EE3\u7801\u7D22\u5F15\u3002\u652F\u6301 Vue2/Vue3/React Hooks\u3002
|
|
413
442
|
\u6BCF\u6B21\u8C03\u7528\u5FC5\u987B\u4F20\u5165 project_path\uFF08\u9879\u76EE\u6839\u76EE\u5F55\u7EDD\u5BF9\u8DEF\u5F84\uFF09\uFF0C\u65E0\u9700\u5728\u542F\u52A8\u65F6\u56FA\u5B9A\u9879\u76EE\u3002
|
|
414
443
|
\u4F18\u5148\u4ECE\u7F16\u8F91\u5668\u5DE5\u4F5C\u533A\u3001\u5DF2\u6253\u5F00\u6587\u4EF6\u548C\u5F53\u524D\u4E0A\u4E0B\u6587\u4E2D\u81EA\u52A8\u63A8\u65AD project_path\uFF0C\u907F\u514D\u5411\u7528\u6237\u8FFD\u95EE\u8DEF\u5F84\u3002
|
|
415
444
|
\u591A\u4E2A\u9879\u76EE\u4F1A\u5E76\u884C\u7F13\u5B58\uFF0C\u5207\u6362\u65E0\u9700\u91CD\u542F\u3002
|
|
@@ -420,45 +449,45 @@ import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {StdioSer
|
|
|
420
449
|
- \u5F3A\u5236\u5168\u91CF\u91CD\u5EFA: force=true
|
|
421
450
|
- \u7CBE\u786E\u7CBE\u5EA6\u6A21\u5F0F: precision_mode="precise"\uFF08\u57FA\u4E8E TypeScript Compiler API \u505A\u8DE8\u6587\u4EF6 import/export \u7ED1\u5B9A\uFF09
|
|
422
451
|
|
|
423
|
-
\u8FD4\u56DE: \u7D22\u5F15\u7EDF\u8BA1\uFF08\u6587\u4EF6\u6570\u3001\u7B26\u53F7\u6570\u3001\u8017\u65F6\u3001\u7CBE\u5EA6\u6A21\u5F0F\uFF09`,inputSchema:z$1.object({project_path:z$1.string().describe('\u9879\u76EE\u6839\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u5982 "/Users/xxx/projects/my-app"'),force:z$1.boolean().optional().default(false).describe("\u662F\u5426\u5F3A\u5236\u5168\u91CF\u91CD\u5EFA\uFF08\u9ED8\u8BA4\u589E\u91CF\uFF0C\u53EA\u66F4\u65B0\u53D8\u66F4\u6587\u4EF6\uFF09"),include:z$1.array(z$1.string()).optional().describe('\u8981\u5305\u542B\u7684\u6587\u4EF6 glob \u6A21\u5F0F\uFF0C\u5982 ["**/*.vue","**/*.tsx"]'),exclude:z$1.array(z$1.string()).optional().describe("\u8981\u989D\u5916\u6392\u9664\u7684 glob \u6A21\u5F0F"),precision_mode:z$1.enum(["heuristic","precise"]).optional().default("heuristic").describe("\u5206\u6790\u7CBE\u5EA6\u6A21\u5F0F: heuristic(\u5FEB\u901F\uFF0C\u9ED8\u8BA4) | precise(\u8DE8\u6587\u4EF6 import/export \u7ED1\u5B9A\uFF0C\u9700\u8981 tsconfig.json)"),selective_precise:z$1.boolean().optional().default(false).describe("Phase 5: \u662F\u5426\u5728\u7D22\u5F15\u540E\u6267\u884C\u9009\u62E9\u6027 precise \u91CD\u7B97\uFF08\u4EC5\u91CD\u7B97\u53D8\u66F4\u6587\u4EF6+\u53D7\u5F71\u54CD\u6587\u4EF6\uFF09"),max_precise_files:z$1.number().optional().default(20).describe("\u9009\u62E9\u6027 precise \u5355\u6B21\u6700\u5927\u6587\u4EF6\u6570\uFF08\u9ED8\u8BA4 20\uFF09")}),annotations:{readOnlyHint:false,destructiveHint:false,idempotentHint:true}},async({project_path:t,force:n,include:
|
|
424
|
-
`);}});e.setLastProject(l);let
|
|
425
|
-
`);}catch(
|
|
426
|
-
`);}let
|
|
427
|
-
`);}let
|
|
428
|
-
\u26A0\uFE0F \u89E3\u6790\u5931\u8D25 (${
|
|
429
|
-
`)}]}});}function
|
|
430
|
-
`)}function
|
|
452
|
+
\u8FD4\u56DE: \u7D22\u5F15\u7EDF\u8BA1\uFF08\u6587\u4EF6\u6570\u3001\u7B26\u53F7\u6570\u3001\u8017\u65F6\u3001\u7CBE\u5EA6\u6A21\u5F0F\uFF09`,inputSchema:z$1.object({project_path:z$1.string().describe('\u9879\u76EE\u6839\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u5982 "/Users/xxx/projects/my-app"'),force:z$1.boolean().optional().default(false).describe("\u662F\u5426\u5F3A\u5236\u5168\u91CF\u91CD\u5EFA\uFF08\u9ED8\u8BA4\u589E\u91CF\uFF0C\u53EA\u66F4\u65B0\u53D8\u66F4\u6587\u4EF6\uFF09"),include:z$1.array(z$1.string()).optional().describe('\u8981\u5305\u542B\u7684\u6587\u4EF6 glob \u6A21\u5F0F\uFF0C\u5982 ["**/*.vue","**/*.tsx"]'),exclude:z$1.array(z$1.string()).optional().describe("\u8981\u989D\u5916\u6392\u9664\u7684 glob \u6A21\u5F0F"),precision_mode:z$1.enum(["heuristic","precise"]).optional().default("heuristic").describe("\u5206\u6790\u7CBE\u5EA6\u6A21\u5F0F: heuristic(\u5FEB\u901F\uFF0C\u9ED8\u8BA4) | precise(\u8DE8\u6587\u4EF6 import/export \u7ED1\u5B9A\uFF0C\u9700\u8981 tsconfig.json)"),selective_precise:z$1.boolean().optional().default(false).describe("Phase 5: \u662F\u5426\u5728\u7D22\u5F15\u540E\u6267\u884C\u9009\u62E9\u6027 precise \u91CD\u7B97\uFF08\u4EC5\u91CD\u7B97\u53D8\u66F4\u6587\u4EF6+\u53D7\u5F71\u54CD\u6587\u4EF6\uFF09"),max_precise_files:z$1.number().optional().default(20).describe("\u9009\u62E9\u6027 precise \u5355\u6B21\u6700\u5927\u6587\u4EF6\u6570\uFF08\u9ED8\u8BA4 20\uFF09")}),annotations:{readOnlyHint:false,destructiveHint:false,idempotentHint:true}},async({project_path:t,force:n,include:r,exclude:s,precision_mode:o,selective_precise:a,max_precise_files:c})=>{let{projectRoot:l}=e.getContext(t),p=o||"heuristic",{effective:d,warnings:u}=xn(p,l),f=e.getIndexer(l),m=await f.indexProject({include:r,exclude:s,force:n,precisionMode:d,onProgress:(w,M)=>{(w%20===0||w===M)&&process.stderr.write(`[Frontend-Code-Skimmer] \u8FDB\u5EA6: ${w}/${M}
|
|
453
|
+
`);}});e.setLastProject(l);let g=0;try{let w=Date.now(),M=await f.startWatcher();g=Date.now()-w,e.registerWatcher(l,M),process.stderr.write(`[Frontend-Code-Skimmer] \u6587\u4EF6\u76D1\u542C\u5DF2\u542F\u52A8: ${l}
|
|
454
|
+
`);}catch(w){process.stderr.write(`[Frontend-Code-Skimmer] \u6587\u4EF6\u76D1\u542C\u542F\u52A8\u5931\u8D25\uFF08\u7D22\u5F15\u4ECD\u53EF\u7528\uFF09: ${String(w)}
|
|
455
|
+
`);}let y=null;if(a)try{let w=await f.selectivePrecise({maxFiles:c||20});y={reindexedFiles:w.reindexedFiles,affectedFiles:w.affectedFiles.length,skippedByBudget:w.skippedByBudget};}catch(w){process.stderr.write(`[Frontend-Code-Skimmer] Selective precise \u5931\u8D25: ${String(w)}
|
|
456
|
+
`);}let b=m.indexedFiles>0||m.totalFiles>0,T=m.totalSymbols>0,h=b?"\u2705 \u53EF\u7528":"\u274C \u65E0\u53EF\u67E5\u8BE2\u6587\u4EF6",E=T?"\u2705 \u53EF\u7528":"\u26A0\uFE0F \u7B26\u53F7\u6570\u4E3A0\uFF08\u89E3\u6790\u53EF\u80FD\u672A\u63D0\u53D6\u5230\u7B26\u53F7\uFF0C\u4F46\u6587\u4EF6\u641C\u7D22\u4ECD\u53EF\u7528\uFF09",N=b?"\u2705 \u53EF\u7528":"\u274C \u65E0\u53EF\u67E5\u8BE2\u6587\u4EF6",R=b?"\u2705 \u53EF\u7528\uFF08\u57FA\u4E8E\u6B63\u5219\u626B\u63CF\u6587\u4EF6\uFF09":"\u274C \u65E0\u53EF\u67E5\u8BE2\u6587\u4EF6",_=m.phaseTimings,x=_?["","\u23F1\uFE0F \u3010\u9636\u6BB5\u8017\u65F6\u3011",` \u{1F50D} \u6587\u4EF6\u53D1\u73B0: ${_.discoverFilesMs}ms`,` \u{1F4D6} \u6587\u4EF6\u8BFB\u53D6: ${_.readFilesMs}ms`,` \u{1F52C} \u89E3\u6790: ${_.parseMs}ms`,` \u{1F4BE} \u6570\u636E\u5E93\u5199\u5165: ${_.saveToDbMs}ms`,` \u{1F4CA} \u603B\u8BA1: ${_.totalMs}ms`,` \u{1F4E1} \u6587\u4EF6\u76D1\u542C: ${g}ms`]:[],A=[`\u2705 \u7D22\u5F15\u5B8C\u6210 \u2014 ${l}`,"\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501","","\u{1F4CA} \u3010\u7EDF\u8BA1\u6570\u91CF\u3011\uFF08\u6CE8\u610F\uFF1A\u7B26\u53F7\u65700\u53EF\u80FD\u662F\u89E3\u6790\u89C4\u5219\u672A\u547D\u4E2D\uFF0C\u4E0D\u4EE3\u8868\u7D22\u5F15\u5931\u8D25\uFF09",` \u{1F4C1} \u603B\u6587\u4EF6\u6570: ${m.totalFiles}`,` \u{1F504} \u5DF2\u7D22\u5F15: ${m.indexedFiles}`,` \u23E9 \u5DF2\u8DF3\u8FC7: ${m.skippedFiles} (\u5185\u5BB9\u672A\u53D8)`,` \u{1F523} \u603B\u7B26\u53F7\u6570: ${m.totalSymbols}`,` \u{1F3AF} \u7CBE\u5EA6\u6A21\u5F0F: ${d}`,` \u23F1\uFE0F \u8017\u65F6: ${m.durationMs}ms`,...x,"","\u{1F50C} \u3010\u53EF\u67E5\u8BE2\u80FD\u529B\u72B6\u6001\u3011\uFF08\u4E0E\u7B26\u53F7\u6570\u65E0\u5173\uFF0C\u53EA\u8981\u6587\u4EF6\u626B\u63CF\u5B8C\u6210\u5373\u53EF\u7528\uFF09",` skimmer_find_symbol ${E}`,` skimmer_get_component_outline ${E}`,` skimmer_find_by_behavior ${N}`,` skimmer_trace_data_lifecycle ${R}`,` skimmer_trace_assignments ${R}`,` skimmer_get_code_slice ${h}`," skimmer_index_health \u2705 \u53EF\u7528","","\u{1F4A1} \u540E\u7EED\u5DE5\u5177\u8C03\u7528\u53EF\u7701\u7565 project_path\uFF08\u81EA\u52A8\u4F7F\u7528\u6B64\u9879\u76EE\uFF09"," \u5982\u7B26\u53F7\u6570\u4E3A0\u4F46\u5DE5\u5177\u4ECD\u8FD4\u56DE\u7ED3\u679C\uFF0C\u5C5E\u6B63\u5E38\u73B0\u8C61\uFF08\u6B63\u5219\u626B\u63CF\u8DEF\u5F84\u4E0D\u4F9D\u8D56\u7B26\u53F7\u7D22\u5F15\uFF09","\u{1F441}\uFE0F \u6587\u4EF6\u76D1\u542C\u5DF2\u542F\u52A8 \u2014 \u4EE3\u7801\u53D8\u66F4\u5C06\u81EA\u52A8\u589E\u91CF\u66F4\u65B0\u7D22\u5F15\uFF08\u65E0\u9700\u624B\u52A8\u91CD\u65B0\u7D22\u5F15\uFF09"];if(m.errors.length>0){A.push(`
|
|
457
|
+
\u26A0\uFE0F \u89E3\u6790\u5931\u8D25 (${m.errors.length} \u4E2A):`);for(let w of m.errors.slice(0,5))A.push(` - ${w.file}: ${w.error}`);m.errors.length>5&&A.push(` ... \u8FD8\u6709 ${m.errors.length-5} \u4E2A`);}if(u.length>0){A.push(""),A.push("\u26A0\uFE0F \u7CBE\u5EA6\u964D\u7EA7:");for(let w of u)A.push(` - ${w}`);}if(y){A.push(""),A.push("\u{1F3AF} \u9009\u62E9\u6027 Precise \u91CD\u7B97:"),A.push(` \u{1F4CA} \u91CD\u7B97\u6587\u4EF6: ${y.reindexedFiles}`),A.push(` \u{1F517} \u5F71\u54CD\u6587\u4EF6: ${y.affectedFiles} (\u5019\u9009\u6570)`),y.skippedByBudget>0&&(A.push(` \u23F8\uFE0F \u8D85\u9884\u7B97\u8DF3\u8FC7\u7684\u6587\u4EF6: ${y.skippedByBudget}`),A.push(" \u{1F4A1} \u540E\u7EED watcher \u89E6\u53D1\u6216\u518D\u6B21\u8C03\u7528 selective_precise=true \u7EE7\u7EED"));let w=f.getScheduler().pendingCount;w>0&&A.push(` \u{1F4CB} Pending queue: ${w} \u6587\u4EF6\u5F85\u91CD\u7B97`);}return {content:[{type:"text",text:A.join(`
|
|
458
|
+
`)}]}});}function Ft(i,e,t){try{if(!e||!Z__default.existsSync(e))return {stale:!1};let n=Z__default.statSync(e),r=i.getFileMeta(t);if(!r)return {stale:!1};let s=r.mtime>0&&n.mtimeMs>r.mtime,o=r.fileSize>0&&n.size!==r.fileSize;return s||o?{stale:!0,reason:o?`\u6587\u4EF6\u5927\u5C0F\u5DEE\u5F02 ${n.size-r.fileSize>0?"+":""}${n.size-r.fileSize} \u5B57\u8282`:"\u6587\u4EF6\u4FEE\u6539\u65F6\u95F4\u66F4\u65B0"}:{stale:!1}}catch{return {stale:false}}}function Ln(i,e,t=5){let n=e.slice(0,t),r=[],s=0;for(let o of n){if(!o.abs_path||!Z__default.existsSync(o.abs_path))continue;s++;let{stale:a}=Ft(i,o.abs_path,o.path);a&&r.push(o.path);}return {stale:r.length>0,reason:r.length>0?`${r.length}/${s} \u6587\u4EF6\u5DF2\u4FEE\u6539\u4F46\u7D22\u5F15\u672A\u66F4\u65B0`:void 0,checkedFiles:s,staleFiles:r.length,staleFilePaths:r.slice(0,5)}}function W(i){return {duration_ms:i.durationMs,result_count:i.resultCount,backend:i.backend,index_freshness:i.indexFreshness,project_count:i.projectCount??1,debug:i.debug,precision_mode_requested:i.precisionRequested,precision_mode_effective:i.precisionEffective,precision_warnings:i.precisionWarnings}}function U(i){let e=[`\u23F1\uFE0F \u8017\u65F6: ${i.duration_ms}ms | \u{1F4CA} \u7ED3\u679C\u6570: ${i.result_count} | \u{1F527} \u540E\u7AEF: ${i.backend}`];if(i.precision_mode_effective){let t=i.precision_mode_effective==="precise"?"\u{1F3AF} \u7CBE\u786E":"\u26A1 \u542F\u53D1\u5F0F",n=i.precision_mode_requested!==i.precision_mode_effective?` (\u8BF7\u6C42: ${i.precision_mode_requested})`:"";e.push(`\u{1F4D0} \u7CBE\u5EA6\u6A21\u5F0F: ${t}${n}`);}if(i.precision_warnings&&i.precision_warnings.length>0)for(let t of i.precision_warnings)e.push(`\u26A0\uFE0F \u7CBE\u5EA6\u8B66\u544A: ${t}`);if(i.index_freshness){let t=i.index_freshness;t.stale?(e.push(`\u26A0\uFE0F \u7D22\u5F15\u65B0\u9C9C\u5EA6: \u5DF2\u8FC7\u671F (${t.staleFiles}/${t.checkedFiles} \u6587\u4EF6) \u2014 ${t.reason||""}`),t.staleFilePaths.length>0&&e.push(` \u8FC7\u671F\u6587\u4EF6: ${t.staleFilePaths.join(", ")}`)):e.push(`\u2705 \u7D22\u5F15\u65B0\u9C9C\u5EA6: \u6700\u65B0 (\u5DF2\u68C0\u67E5 ${t.checkedFiles} \u6587\u4EF6)`);}if(i.debug){if(e.push("\u2500\u2500 \u8C03\u8BD5\u4FE1\u606F \u2500\u2500"),i.debug.phase_timings){e.push("\u9636\u6BB5\u8017\u65F6:");for(let[t,n]of Object.entries(i.debug.phase_timings))e.push(` ${t}: ${n}ms`);}i.debug.query_plan&&e.push(`\u67E5\u8BE2\u8BA1\u5212: ${i.debug.query_plan}`),i.debug.candidate_count!==void 0&&e.push(`\u5019\u9009\u6570: ${i.debug.candidate_count}`),i.debug.scanned_files!==void 0&&e.push(`\u626B\u63CF\u6587\u4EF6\u6570: ${i.debug.scanned_files}`),i.debug.fallback_reason&&e.push(`\u964D\u7EA7\u539F\u56E0: ${i.debug.fallback_reason}`);}return e.join(`
|
|
459
|
+
`)}function Rn(i,e){i.registerTool("skimmer_get_component_outline",{title:"\u83B7\u53D6\u7EC4\u4EF6/\u6587\u4EF6\u7ED3\u6784\u9AA8\u67B6",description:`\u5C06\u6570\u5343\u884C\u4EE3\u7801\u538B\u7F29\u4E3A\u6E05\u6670\u7684\u7ED3\u6784\u9AA8\u67B6\uFF08\u7EA6 30-80 \u884C\uFF09\uFF0C\u8282\u7701 90%+ Token\u3002
|
|
431
460
|
\u5305\u542B: props\u3001data/state\u3001computed\u3001methods/functions\u3001watch/effect\u3001lifecycle\u3001\u884C\u4E3A\u6807\u7B7E\u3002
|
|
432
461
|
\u884C\u4E3A\u6807\u7B7E\u81EA\u52A8\u6807\u51FA: [storage:localStorage.setItem] [network:axios.get] \u7B49\u3002
|
|
433
462
|
|
|
434
463
|
project_path \u53EF\u7701\u7565\uFF08\u4F7F\u7528\u4E0A\u6B21 skimmer_index_project \u6307\u5B9A\u7684\u9879\u76EE\uFF09\u3002
|
|
435
|
-
file_path \u4F7F\u7528\u76F8\u5BF9\u4E8E\u9879\u76EE\u6839\u76EE\u5F55\u7684\u8DEF\u5F84\uFF0C\u5982 "src/views/apply/index.vue"\u3002`,inputSchema:z$1.object({file_path:z$1.string().describe('\u6587\u4EF6\u76F8\u5BF9\u8DEF\u5F84\uFF0C\u5982 "src/views/apply/index.vue"'),project_path:z$1.string().optional().describe("\u9879\u76EE\u6839\u76EE\u5F55\uFF08\u53EF\u7701\u7565\uFF0C\u4F7F\u7528\u4E0A\u6B21\u7D22\u5F15\u7684\u9879\u76EE\uFF09"),debug:z$1.boolean().optional().default(false).describe("\u662F\u5426\u8F93\u51FA\u8C03\u8BD5\u5143\u4FE1\u606F")}),annotations:{readOnlyHint:true,destructiveHint:false}},async({file_path:t,project_path:n,debug:
|
|
464
|
+
file_path \u4F7F\u7528\u76F8\u5BF9\u4E8E\u9879\u76EE\u6839\u76EE\u5F55\u7684\u8DEF\u5F84\uFF0C\u5982 "src/views/apply/index.vue"\u3002`,inputSchema:z$1.object({file_path:z$1.string().describe('\u6587\u4EF6\u76F8\u5BF9\u8DEF\u5F84\uFF0C\u5982 "src/views/apply/index.vue"'),project_path:z$1.string().optional().describe("\u9879\u76EE\u6839\u76EE\u5F55\uFF08\u53EF\u7701\u7565\uFF0C\u4F7F\u7528\u4E0A\u6B21\u7D22\u5F15\u7684\u9879\u76EE\uFF09"),debug:z$1.boolean().optional().default(false).describe("\u662F\u5426\u8F93\u51FA\u8C03\u8BD5\u5143\u4FE1\u606F")}),annotations:{readOnlyHint:true,destructiveHint:false}},async({file_path:t,project_path:n,debug:r})=>{let s=performance.now(),{db:o}=e.getContext(n),{file:a,symbols:c,behaviors:l}=o.getFileOutline(t);if(!a){let E=Math.round((performance.now()-s)*100)/100,N=W({durationMs:E,resultCount:0,backend:"indexed"});return {content:[{type:"text",text:`\u274C \u6587\u4EF6\u672A\u7D22\u5F15: ${t}
|
|
436
465
|
|
|
437
466
|
\u8BF7\u5148\u8FD0\u884C:
|
|
438
467
|
skimmer_index_project({ project_path: "${n||"<\u9879\u76EE\u8DEF\u5F84>"}" })
|
|
439
468
|
|
|
440
469
|
\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
|
|
441
|
-
${U(
|
|
442
|
-
\u26A0\uFE0F [\u7D22\u5F15\u5DF2\u8FC7\u671F] ${
|
|
470
|
+
${U(N)}`}]}}let p="",d=a.abs_path,{stale:u,reason:f}=Ft(o,d,t);u&&(p=`
|
|
471
|
+
\u26A0\uFE0F [\u7D22\u5F15\u5DF2\u8FC7\u671F] ${f||""}\uFF0C\u884C\u53F7\u53EF\u80FD\u504F\u79FB\uFF08\u7D22\u5F15\u8BB0\u5F55 ${a.line_count} \u884C\uFF0C\u5B9E\u9645\u53EF\u80FD\u5DF2\u53D8\u5316\uFF09
|
|
443
472
|
\u7ACB\u5373\u91CD\u5EFA: skimmer_index_project({ force: true })
|
|
444
|
-
`);let
|
|
445
|
-
${
|
|
446
|
-
${"\u2500".repeat(50)}`),
|
|
473
|
+
`);let m=new Map;for(let E of l){let N=E.symbol_id;m.has(N)||m.set(N,[]);let R=`[${E.category}:${E.api_name}.${E.operation}${E.detail?`("${E.detail}")`:""}]`,_=m.get(N);_.includes(R)||_.push(R);}let g=[];g.push(`\u{1F4C4} ${t} (${a.line_count} \u884C, ${a.framework})`),g.push(`${"\u2501".repeat(50)}`),p&&g.push(p);let y={};for(let E of c){if(E.name==="<template>")continue;let N=E.category;y[N]||(y[N]=[]),y[N].push(E);}let b=[{key:"prop",icon:"\u{1F4E6}",label:"Props"},{key:"state",icon:"\u{1F4CA}",label:"Data / State"},{key:"computed",icon:"\u{1F504}",label:"Computed"},{key:"method",icon:"\u26A1",label:"Methods / Functions"},{key:"effect",icon:"\u{1F440}",label:"Watch / Effect"},{key:"lifecycle",icon:"\u{1F517}",label:"Lifecycle"},{key:"hook",icon:"\u{1FA9D}",label:"Hooks"},{key:"component",icon:"\u{1F9E9}",label:"Components"},{key:"mixin",icon:"\u{1F500}",label:"Mixins"},{key:"provide",icon:"\u{1F489}",label:"Provide / Inject"},{key:"emit",icon:"\u{1F4E1}",label:"Emits"},{key:"filter",icon:"\u{1F50D}",label:"Filters"},{key:"function",icon:"\u{1F527}",label:"Functions"},{key:"constant",icon:"\u{1F4CC}",label:"Constants"}];for(let{key:E,icon:N,label:R}of b){let _=y[E];if(_?.length){g.push(`
|
|
474
|
+
${N} ${R} (${_.length}):`);for(let x of _){let A=x.name,w=ke(x.start_line,x.end_line),M=De(x.params_json,[]),O=M.length>0?`(${M.join(", ")})`:"",B=x.default_value?` = ${x.default_value}`:"",ce=x.is_async?"async ":"",ye=m.get(x.id),Ae=ye?.length?` ${ye.slice(0,3).join(" ")}`:"",q=x.state_setter_name?` \u2192 ${x.state_setter_name}`:"",le=x.hook_deps_json?` [deps:${De(x.hook_deps_json,[]).join(",")}]`:"";g.push(` \u2022 ${ce}${A}${O}${B}${q}${le} ${w}${Ae}`);}}}g.push(`
|
|
475
|
+
${"\u2500".repeat(50)}`),g.push(`\u{1F4A1} \u67E5\u770B\u5177\u4F53\u4EE3\u7801: skimmer_get_code_slice({ file_path: "${t}", symbol_name: "\u65B9\u6CD5\u540D" })`);let T=Math.round((performance.now()-s)*100)/100,h=W({durationMs:T,resultCount:c.length,backend:"indexed"});return r&&(h.debug={scanned_files:1}),g.push(`
|
|
447
476
|
\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
|
|
448
|
-
${U(
|
|
449
|
-
`)}]}});}var
|
|
450
|
-
`);for(let
|
|
451
|
-
`).length;return [{content:t[1],lineOffset:
|
|
452
|
-
`),
|
|
453
|
-
`),startLine:
|
|
454
|
-
`),a=
|
|
455
|
-
`),a=
|
|
456
|
-
`),c=
|
|
457
|
-
`),c=
|
|
477
|
+
${U(h)}`),{content:[{type:"text",text:g.join(`
|
|
478
|
+
`)}]}});}var He=class{constructor(e){this.db=e;}db;search(e,t){let{category:n,framework:r,filePath:s,limit:o=tn,fuzzy:a=true,allowFallbackScan:c=false,debug:l=false}=t||{},p=e.trim(),d=new Map,u={},f=performance.now(),m=this.db.exactSearch(p,n,r,s);for(let R of m)d.set(R.id,{symbol:R,filePath:R.file_path,score:100,matchReason:"\u7CBE\u786E\u5339\u914D"});if(u["1_exact"]=Math.round((performance.now()-f)*100)/100,d.size>=o)return {results:this.rankResults(d,o)};let g=performance.now(),y=0,b=k(p),T=[p,b,...b.split(" ")].filter(Boolean).filter((R,_,x)=>x.indexOf(R)===_);for(let R of T){if(R.length<2)continue;let _=this.db.ftsSearch(R,n,r,s,o);y+=_.length;for(let x of _){let A=x.id;if(d.has(A))continue;let w=this.calcFtsScore(p,x.name);d.set(A,{symbol:x,filePath:x.file_path,score:w,matchReason:`FTS5 \u524D\u7F00\u5339\u914D ("${R}")`});}}if(u["2_fts"]=Math.round((performance.now()-g)*100)/100,d.size>=o)return {results:this.rankResults(d,o),debug:l?{phase_timings:u,candidate_count:y}:void 0};let h=a&&p.length>=3,E=0;if(h){let R=performance.now(),_=this.db.getAllSymbolNames(s),x=p.toLowerCase(),A=k(p).split(" ");for(let{name:w,file_path:M,id:O}of _){if(d.has(O))continue;E++;let B=ze(x,w.toLowerCase()),ce=Math.max(x.length,w.length),ye=Math.min(nn,Math.max(1,Math.floor(ce*.28)));if(B<=ye){let le=Math.max(0,80-B*15),X=this.db.getSymbolById(O);if(!X||n&&X.category!==n||r&&X.framework!==r)continue;let re=Gt(p,w,B);d.set(O,{symbol:X,filePath:M,score:le,matchReason:`\u6A21\u7CCA\u5339\u914D (\u7F16\u8F91\u8DDD\u79BB=${B})`,spellingSuggestion:re});continue}let Ae=k(w).split(" "),q=A.filter(le=>Ae.some(X=>zt(le,X)>=75));if(q.length>0&&q.length>=Math.ceil(A.length*.5)){let le=50+q.length*10,X=this.db.getSymbolById(O);if(!X||n&&X.category!==n||r&&X.framework!==r)continue;d.set(O,{symbol:X,filePath:M,score:le,matchReason:`\u5355\u8BCD\u5339\u914D (${q.join(", ")})`});}}u["3_fuzzy"]=Math.round((performance.now()-R)*100)/100;}if(d.size===0&&c){let R=performance.now(),_=this.db.ftsSearchWithFallback(p,n,r,s,o);for(let x of _){let A=x.id;d.has(A)||d.set(A,{symbol:x,filePath:x.file_path,score:50,matchReason:"LIKE \u5168\u8868\u626B\u63CF fallback"});}u["4_fallback"]=Math.round((performance.now()-R)*100)/100;}let N=l?{phase_timings:u,candidate_count:y+E,fallback_reason:!h&&p.length<3?"\u67E5\u8BE2\u8FC7\u77ED (<3\u5B57\u7B26)\uFF0C\u8DF3\u8FC7\u6A21\u7CCA\u5339\u914D":void 0}:void 0;return {results:this.rankResults(d,o),debug:N}}calcFtsScore(e,t){let n=e.toLowerCase(),r=t.toLowerCase();if(r===n)return 98;if(r.startsWith(n))return 91;if(r.includes(n))return 80;let s=k(e).split(" "),o=k(t).split(" "),a=s.some(l=>o[0]?.startsWith(l))?8:0,c=s.filter(l=>o.some(p=>p.startsWith(l))).length;return Math.min(88,58+c*8+a)}rankResults(e,t){return Array.from(e.values()).sort((n,r)=>r.score-n.score).slice(0,t)}searchByBehavior(e){return this.db.behaviorSearch(e.category,e.apiName,e.operation,e.keyword,e.filePath).map(n=>({symbolName:n.symbol_name,category:n.category,apiName:n.api_name,operation:n.operation,detail:n.detail,line:n.line_number,filePath:n.file_path,startLine:n.start_line,endLine:n.end_line}))}};var In=createRequire(import.meta.url),Ee="\u9879\u76EE\u6839\u76EE\u5F55\uFF08\u53EF\u7701\u7565\uFF0C\u81EA\u52A8\u4F7F\u7528\u4E0A\u6B21 skimmer_index_project \u6307\u5B9A\u7684\u9879\u76EE\uFF09";function Be(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $e(i,e,t){let n=[];for(let r of i){if(!r?.abs_path||!Z__default.existsSync(r.abs_path))continue;let s=Z__default.readFileSync(r.abs_path,"utf-8").split(`
|
|
479
|
+
`);for(let o=0;o<s.length;o++){let a=s[o];for(let c of e)if(c.regex.test(a)){n.push({filePath:r.path,line:o+1,kind:c.kind,text:a.trim()});break}if(n.length>=t)return n}}return n}function kn(i,e){let t=Be(i),n="(?:=|\\+=|-=|\\*=|/=|%=|\\|=|&=|\\^=|&&=|\\|\\|=|\\?\\?=)",r=[{kind:"declaration",regex:new RegExp(`\\b(?:const|let|var)\\s+${t}\\b`)},{kind:"assignment",regex:new RegExp(`\\b${t}\\b\\s*${n}`)},{kind:"update",regex:new RegExp(`(?:\\+\\+|--)\\s*\\b${t}\\b|\\b${t}\\b\\s*(?:\\+\\+|--)`)}];return e&&r.push({kind:"property_assignment",regex:new RegExp(`\\b${t}\\.[A-Za-z_$][\\w$]*\\s*${n}`)},{kind:"indexed_assignment",regex:new RegExp(`\\b${t}\\s*\\[[^\\]]+\\]\\s*${n}`)}),r}function gt(i){try{return In("@babel/parser").parse(i,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"],errorRecovery:!0})}catch{return null}}function ht(i,e){if(!i.endsWith(".vue"))return [{content:e,lineOffset:1}];try{let{parse:s}=In("@vue/compiler-sfc"),{descriptor:o}=s(e),a=[];if(o.script?.content&&a.push({content:o.script.content,lineOffset:o.script.loc.start.line}),o.scriptSetup?.content&&a.push({content:o.scriptSetup.content,lineOffset:o.scriptSetup.loc.start.line}),a.length>0)return a}catch{}let t=e.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!t||!t[1])return [];let r=e.slice(0,t.index||0).split(`
|
|
480
|
+
`).length;return [{content:t[1],lineOffset:r}]}function _e(i,e){return (i.loc?.start?.line??1)+e-1}function Ut(i,e){if(i.type!=="MemberExpression")return false;let t=i.object;return !t||t.type!=="ThisExpression"?false:Y(i)===e}function Dt(i,e){return !!i&&i.type==="Identifier"&&String(i.name||"")===e}function $n(i){let e=new Set;return i.filter(t=>{let n=`${t.filePath}:${t.line}:${t.kind}:${t.text}`;return e.has(n)?false:(e.add(n),true)})}function Mt(i,e,t=2){if(!Z__default.existsSync(i))return {snippet:"",startLine:e};let n=Z__default.readFileSync(i,"utf-8").split(`
|
|
481
|
+
`),r=Math.max(0,e-1-t),s=Math.min(n.length-1,e-1+t);return {snippet:n.slice(r,s+1).map((a,c)=>{let l=r+c+1;return ` ${l===e?"\u25B6":" "} ${String(l).padStart(4)} \u2502 ${a}`}).join(`
|
|
482
|
+
`),startLine:r+1}}function ut(i,e=false){let n=Math.max(50,({declaration:95,assignment:85,update:80,property_assignment:75,indexed_assignment:75,dot:75,bracket:75,delete:70,direct_storage:90,alias_ref:70,regex_fallback:60}[i]??65)-(e?5:0)),r=n>=90?"\u25CF\u25CF\u25CF\u25CF\u25CF":n>=80?"\u25CF\u25CF\u25CF\u25CF\u25CB":n>=70?"\u25CF\u25CF\u25CF\u25CB\u25CB":n>=60?"\u25CF\u25CF\u25CB\u25CB\u25CB":"\u25CF\u25CB\u25CB\u25CB\u25CB";return `[\u7F6E\u4FE1\u5EA6 ${n}% ${r}]`}var wn={init:"\u{1F331} \u521D\u59CB\u5316\u6765\u6E90",cache:"\u{1F4BE} \u7F13\u5B58\u56DE\u663E",user:"\u{1F5B1}\uFE0F \u7528\u6237\u4EA4\u4E92",unknown:"\u2753 \u672A\u77E5\u6765\u6E90"};function vn(i,e,t){let n=[];for(let r of i){if(!r.abs_path||!Z__default.existsSync(r.abs_path))continue;let s=Z__default.readFileSync(r.abs_path,"utf-8"),o=s.split(`
|
|
483
|
+
`),a=ht(r.path||K__default.basename(r.abs_path),s);for(let c of a){let l=gt(c.content);l&&me(l,p=>{if(n.length>=t||p.type!=="VariableDeclarator")return;let d=p.id;if(!d||d.type!=="Identifier")return;let u=String(d.name||"");if(!u||u===e)return;let f=p.init;if(!f)return;let m=false;if(f.type==="Identifier"&&String(f.name||"")===e?m=true:f.type==="MemberExpression"&&(m=Ut(f,e)||Y(f)===e),!m)return;let g=_e(p,c.lineOffset),y=o[g-1]?.trim()||"";n.push({alias:u,filePath:r.path,abs_path:r.abs_path,line:g,text:y});});}}return n}function Cn(i,e,t){let n=[];for(let r of i){if(!r.abs_path||!Z__default.existsSync(r.abs_path))continue;let s=Z__default.readFileSync(r.abs_path,"utf-8"),o=s.split(`
|
|
484
|
+
`),a=ht(r.path||K__default.basename(r.abs_path),s);for(let c of a){let l=gt(c.content);l&&me(l,p=>{if(n.length>=t||p.type!=="VariableDeclarator")return;let d=p.id;if(!d||d.type!=="ObjectPattern")return;let u=d.properties||[];for(let f of u){if(f.type!=="ObjectProperty"&&f.type!=="Property")continue;let m=f.key,g=f.value,y=m?.type==="Identifier"?String(m.name||""):null;if(y!==e)continue;let b=g?.type==="Identifier"?String(g.name||""):y;if(!b)continue;let T=_e(p,c.lineOffset),h=o[T-1]?.trim()||"";n.push({alias:b,filePath:r.path,line:T,text:h});}});}}return n}function jt(i,e,t,n){let r=[];for(let s of i){if(!s.abs_path||!Z__default.existsSync(s.abs_path))continue;let o=Z__default.readFileSync(s.abs_path,"utf-8"),a=o.split(`
|
|
485
|
+
`),c=ht(s.path||K__default.basename(s.abs_path),o);for(let l of c){let p=gt(l.content);if(p&&(me(p,d=>{if(!(r.length>=n)){if(d.type==="VariableDeclarator"){let u=d.id;if(Dt(u,e)){let f=_e(d,l.lineOffset);r.push({filePath:s.path,line:f,kind:"declaration",text:a[f-1]?.trim()||""});}}if(d.type==="AssignmentExpression"){let u=d.left;if(!u)return;let f=_e(d,l.lineOffset);if(Dt(u,e)||Ut(u,e)){r.push({filePath:s.path,line:f,kind:"assignment",text:a[f-1]?.trim()||""});return}t&&u.type==="MemberExpression"&&ie(u)===e&&r.push({filePath:s.path,line:f,kind:u.computed?"indexed_assignment":"property_assignment",text:a[f-1]?.trim()||""});}if(d.type==="UpdateExpression"){let u=d.argument;if(!u)return;if(Dt(u,e)||Ut(u,e)){let f=_e(d,l.lineOffset);r.push({filePath:s.path,line:f,kind:"update",text:a[f-1]?.trim()||""});}}}}),r.length>=n))break}if(r.length>=n)break}return $n(r).slice(0,n)}function ft(i,e,t,n){let r=[];for(let s of i){if(!s.abs_path||!Z__default.existsSync(s.abs_path))continue;let o=Z__default.readFileSync(s.abs_path,"utf-8"),a=o.split(`
|
|
486
|
+
`),c=ht(s.path||K__default.basename(s.abs_path),o);for(let l of c){let p=gt(l.content);if(p&&(me(p,d=>{if(!(r.length>=n)){if(d.type==="AssignmentExpression"){let u=d.left;if(!u||u.type!=="MemberExpression"||ie(u)!==e)return;let m=Y(u);if(t&&m!==t)return;let g=_e(d,l.lineOffset);r.push({filePath:s.path,line:g,kind:u.computed?"bracket":"dot",text:a[g-1]?.trim()||""});}if(d.type==="UpdateExpression"){let u=d.argument;if(!u||u.type!=="MemberExpression"||ie(u)!==e)return;let m=Y(u);if(t&&m!==t)return;let g=_e(d,l.lineOffset);r.push({filePath:s.path,line:g,kind:u.computed?"bracket":"dot",text:a[g-1]?.trim()||""});}if(d.type==="UnaryExpression"&&d.operator==="delete"){let u=d.argument;if(!u||u.type!=="MemberExpression"||ie(u)!==e)return;let m=Y(u);if(t&&m!==t)return;let g=_e(d,l.lineOffset);r.push({filePath:s.path,line:g,kind:"delete",text:a[g-1]?.trim()||""});}}}),r.length>=n))break}if(r.length>=n)break}return $n(r).slice(0,n)}function On(i,e){i.registerTool("skimmer_find_symbol",{title:"\u667A\u80FD\u7B26\u53F7\u641C\u7D22\uFF08\u652F\u6301\u62FC\u5199\u9519\u8BEF\uFF09",description:`\u4E09\u5C42\u641C\u7D22\uFF1A\u7CBE\u786E\u5339\u914D \u2192 FTS5\u5168\u6587 \u2192 Levenshtein\u6A21\u7CCA\u3002
|
|
458
487
|
\u89E3\u51B3\u62FC\u5199\u9519\u8BEF\uFF1A\u641C "changeCash" \u80FD\u627E\u5230 "changeCashValue"\uFF0C\u5E76\u63D0\u793A "cash \u53EF\u80FD\u662F cache \u7684\u62FC\u5199\u9519\u8BEF"\u3002
|
|
459
488
|
\u9A7C\u5CF0\u62C6\u8BCD\uFF1A\u641C "change cache" \u4E5F\u80FD\u627E\u5230 "changeCacheValue"\u3002
|
|
460
489
|
\u6846\u67B6\u611F\u77E5\uFF1A\u53EF\u6309 vue2/vue3/react \u8FC7\u6EE4\u3002
|
|
461
|
-
project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({query:z$1.string().describe('\u641C\u7D22\u8BCD\uFF0C\u5982 "changeCash" \u6216 "handle submit"'),project_path:z$1.string().optional().describe(
|
|
490
|
+
project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({query:z$1.string().describe('\u641C\u7D22\u8BCD\uFF0C\u5982 "changeCash" \u6216 "handle submit"'),project_path:z$1.string().optional().describe(Ee),category:z$1.enum(["state","computed","method","effect","prop","lifecycle","hook","component","mixin","function","all"]).optional().default("all").describe("\u7B26\u53F7\u7C7B\u578B\u8FC7\u6EE4"),framework:z$1.enum(["vue2","vue3","react","all"]).optional().default("all"),file_path:z$1.string().optional().describe('\u9650\u5B9A\u6587\u4EF6\u8DEF\u5F84\u641C\u7D22\uFF08\u5305\u542B\u5373\u53EF\uFF0C\u5982 "index.vue"\uFF09'),fuzzy:z$1.boolean().optional().default(true).describe("\u662F\u5426\u542F\u7528\u6A21\u7CCA\u5339\u914D\uFF08\u9ED8\u8BA4 true\uFF0C\u77ED\u67E5\u8BE2\u81EA\u52A8\u7981\u7528\uFF09"),allow_fallback_scan:z$1.boolean().optional().default(false).describe("0\u547D\u4E2D\u65F6\u662F\u5426\u5141\u8BB8 LIKE \u5168\u8868\u626B\u63CF\uFF08\u9ED8\u8BA4\u4E0D\u542F\u7528\uFF0C\u6602\u8D35\u64CD\u4F5C\uFF09"),debug:z$1.boolean().optional().default(false).describe("\u662F\u5426\u8F93\u51FA\u5404\u9636\u6BB5\u8017\u65F6\u548C\u5019\u9009\u6570"),limit:z$1.number().optional().default(15)}),annotations:{readOnlyHint:true,destructiveHint:false}},async({query:t,project_path:n,category:r,framework:s,file_path:o,fuzzy:a,allow_fallback_scan:c,debug:l,limit:p})=>{let d=performance.now(),{db:u}=e.getContext(n),f=new He(u),{results:m,debug:g}=f.search(t,{category:r==="all"?void 0:r,framework:s==="all"?void 0:s,filePath:o,fuzzy:a,limit:p,allowFallbackScan:c,debug:l}),y=Math.round((performance.now()-d)*100)/100,b=W({durationMs:y,resultCount:m.length,backend:"indexed",debug:l?g:void 0});if(m.length===0)return {content:[{type:"text",text:`\u{1F50D} \u641C\u7D22 "${t}" \u65E0\u7ED3\u679C
|
|
462
491
|
|
|
463
492
|
\u{1F4A1} \u5C1D\u8BD5:
|
|
464
493
|
skimmer_find_by_behavior \u6309\u884C\u4E3A\u641C\u7D22
|
|
@@ -466,74 +495,74 @@ project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({query:z$1.string(
|
|
|
466
495
|
\u{1F4A1} \u5C1D\u8BD5: skimmer_find_symbol({ allow_fallback_scan: true }) \u542F\u7528\u5168\u8868\u626B\u63CF`}
|
|
467
496
|
|
|
468
497
|
\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
|
|
469
|
-
${U(
|
|
470
|
-
`];return
|
|
471
|
-
${U(
|
|
472
|
-
`)}]}}),
|
|
498
|
+
${U(b)}`}]};let T=[`\u{1F50D} \u641C\u7D22 "${t}" \u2014 \u627E\u5230 ${m.length} \u4E2A\u7ED3\u679C
|
|
499
|
+
`];return m.forEach((h,E)=>{let N=h.symbol,R=De(N.params_json,[]),_=R.length>0?`(${R.join(", ")})`:"",x=ke(N.start_line,N.end_line);T.push(`${E+1}. ${N.name}${_} [${N.category}/${N.framework}] \u5339\u914D\u5EA6: ${h.score}%`),T.push(` \u{1F4C4} ${h.filePath}:${x}`),T.push(` \u{1F3AF} ${h.matchReason}`),h.spellingSuggestion&&T.push(` \u{1F4A1} ${h.spellingSuggestion}`),N.default_value&&T.push(` \u{1F4CC} \u9ED8\u8BA4\u503C: ${N.default_value}`),T.push("");}),T.push(`\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
|
|
500
|
+
${U(b)}`),{content:[{type:"text",text:T.join(`
|
|
501
|
+
`)}]}}),i.registerTool("skimmer_get_code_slice",{title:"\u83B7\u53D6\u7CBE\u51C6\u4EE3\u7801\u7247\u6BB5",description:`\u8FD4\u56DE\u6307\u5B9A\u51FD\u6570/\u53D8\u91CF\u7684\u5B8C\u6574\u4EE3\u7801\uFF0C\u907F\u514D\u8BFB\u53D6\u5927\u6587\u4EF6\u6D6A\u8D39 Token\u3002
|
|
473
502
|
\u540C\u65F6\u8FD4\u56DE\u8BE5\u7B26\u53F7\u7684\u884C\u4E3A\u6807\u7B7E\uFF08\u64CD\u4F5C\u4E86\u54EA\u4E9B\u5916\u90E8 API\uFF09\u3002
|
|
474
|
-
project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({file_path:z$1.string().describe("\u6587\u4EF6\u76F8\u5BF9\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u9879\u76EE\u6839\u76EE\u5F55\uFF09"),symbol_name:z$1.string().describe("\u51FD\u6570\u6216\u53D8\u91CF\u540D"),project_path:z$1.string().optional().describe(
|
|
503
|
+
project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({file_path:z$1.string().describe("\u6587\u4EF6\u76F8\u5BF9\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u9879\u76EE\u6839\u76EE\u5F55\uFF09"),symbol_name:z$1.string().describe("\u51FD\u6570\u6216\u53D8\u91CF\u540D"),project_path:z$1.string().optional().describe(Ee),context_lines:z$1.number().optional().default(0).describe("\u4E0A\u4E0B\u65B9\u989D\u5916\u5C55\u793A\u7684\u884C\u6570")}),annotations:{readOnlyHint:true,destructiveHint:false}},async({file_path:t,symbol_name:n,project_path:r,context_lines:s})=>{let o=performance.now(),{db:a}=e.getContext(r),c=a.getSymbolByName(n,t);if(!c){let x=Math.round((performance.now()-o)*100)/100,A=W({durationMs:x,resultCount:0,backend:"indexed"});return {content:[{type:"text",text:`\u274C \u672A\u627E\u5230: ${n}
|
|
475
504
|
\u{1F4C4} \u6587\u4EF6: ${t}
|
|
476
505
|
|
|
477
506
|
\u{1F4A1} \u8BD5\u8BD5: skimmer_find_symbol({ query: "${n}" })
|
|
478
507
|
|
|
479
508
|
\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
|
|
480
|
-
${U(A)}`}]}}let l=c.abs_path;if(!
|
|
481
|
-
`),
|
|
482
|
-
`),
|
|
509
|
+
${U(A)}`}]}}let l=c.abs_path;if(!Z__default.existsSync(l))return {content:[{type:"text",text:`\u274C \u6587\u4EF6\u4E0D\u5B58\u5728: ${l}`}]};let d=Z__default.readFileSync(l,"utf-8").split(`
|
|
510
|
+
`),u=Math.max(1,c.start_line-s)-1,f=Math.min(d.length,c.end_line+s),m=d.slice(u,f).join(`
|
|
511
|
+
`),y=m.includes(n)?"":`
|
|
483
512
|
\u26A0\uFE0F [\u884C\u53F7\u504F\u79FB] \u7D22\u5F15\u8BB0\u5F55 ${n} \u5728 L${c.start_line}\uFF0C\u4F46\u8BE5\u4F4D\u7F6E\u672A\u627E\u5230\u6B64\u7B26\u53F7\u3002
|
|
484
|
-
\u6587\u4EF6\u5DF2\u88AB\u4FEE\u6539\u4F46\u7D22\u5F15\u672A\u66F4\u65B0\uFF0C\u884C\u53F7\u53EF\u80FD\u504F\u79FB ${
|
|
513
|
+
\u6587\u4EF6\u5DF2\u88AB\u4FEE\u6539\u4F46\u7D22\u5F15\u672A\u66F4\u65B0\uFF0C\u884C\u53F7\u53EF\u80FD\u504F\u79FB ${d.length-c.end_line} \u884C\u5DE6\u53F3\u3002
|
|
485
514
|
\u5EFA\u8BAE: skimmer_index_project({ force: true })
|
|
486
|
-
`,{behaviors:
|
|
487
|
-
\`\`\`${
|
|
515
|
+
`,{behaviors:b}=a.getFileOutline(t),T=b.filter(x=>x.symbol_id===c.id),h=l.split(".").pop()||"js",E=["tsx","jsx"].includes(h)?"jsx":["ts"].includes(h)?"typescript":"javascript",N=[`\u{1F4CD} ${c.name} [${c.category}/${c.framework}]`,`\u{1F4C4} ${t}:${ke(c.start_line,c.end_line)}`];if(y&&N.push(y),c.jsdoc&&N.push(`\u{1F4DD} ${c.jsdoc}`),T.length>0){let x=[...new Set(T.map(A=>`[${A.category}:${A.api_name}.${A.operation}${A.detail?`("${A.detail}")`:""}]`))];N.push(`\u{1F3F7}\uFE0F \u884C\u4E3A: ${x.join(" ")}`);}N.push(`
|
|
516
|
+
\`\`\`${E}`),N.push(m),N.push("```");let R=Math.round((performance.now()-o)*100)/100,_=W({durationMs:R,resultCount:1,backend:"indexed"});return N.push(`
|
|
488
517
|
\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
|
|
489
|
-
${U(_)}`),{content:[{type:"text",text:
|
|
490
|
-
`)}]}}),
|
|
518
|
+
${U(_)}`),{content:[{type:"text",text:N.join(`
|
|
519
|
+
`)}]}}),i.registerTool("skimmer_trace_assignments",{title:"\u8FFD\u8E2A\u53D8\u91CF\u8D4B\u503C\u94FE\u8DEF\uFF08\u8F7B\u91CF\uFF09",description:`\u3010\u964D\u7EA7\u5DE5\u5177\u3011\u4EC5\u5728\u4EE5\u4E0B\u573A\u666F\u5355\u72EC\u4F7F\u7528\uFF1A\u53EA\u9700\u67E5\u770B\u67D0\u4E2A\u7B80\u5355\u53D8\u91CF\uFF08\u975E\u5BF9\u8C61\uFF09\u7684\u8D4B\u503C\u4F4D\u7F6E\uFF0C\u4E14\u4E0D\u5173\u5FC3\u5C5E\u6027\u4FEE\u6539/\u53C2\u6570\u4F20\u9012/storage\u94FE\u8DEF\u3002
|
|
491
520
|
\u26A0\uFE0F \u7EDD\u5927\u591A\u6570\u53D8\u91CF\u6EAF\u6E90\u573A\u666F\u8BF7\u4F18\u5148\u4F7F\u7528 skimmer_trace_data_lifecycle\uFF0C\u5B83\u80FD\u4E00\u6B21\u62FF\u5230\u6240\u6709\u4FE1\u606F\u3002
|
|
492
521
|
\u2705 \u672C\u5DE5\u5177\u9002\u5408\uFF1Aloading / errorMsg / count \u8FD9\u7C7B\u7B80\u5355 flag \u7684\u8D4B\u503C\u8FFD\u8E2A\u3002
|
|
493
|
-
\u274C \u4E0D\u9002\u5408\uFF1AstorageParams / savedData \u8FD9\u7C7B\u5BF9\u8C61\u3001\u9700\u8981\u8FFD\u8E2A\u5B8C\u6574\u6570\u636E\u6D41\u7684\u573A\u666F\u3002`,inputSchema:z$1.object({variable:z$1.string().describe('\u53D8\u91CF\u540D\uFF0C\u5982 "changeResult"'),project_path:z$1.string().optional().describe(
|
|
522
|
+
\u274C \u4E0D\u9002\u5408\uFF1AstorageParams / savedData \u8FD9\u7C7B\u5BF9\u8C61\u3001\u9700\u8981\u8FFD\u8E2A\u5B8C\u6574\u6570\u636E\u6D41\u7684\u573A\u666F\u3002`,inputSchema:z$1.object({variable:z$1.string().describe('\u53D8\u91CF\u540D\uFF0C\u5982 "changeResult"'),project_path:z$1.string().optional().describe(Ee),file_path:z$1.string().optional().describe("\u9650\u5B9A\u6587\u4EF6\u8DEF\u5F84\uFF08\u5305\u542B\u5373\u53EF\uFF09"),include_properties:z$1.boolean().optional().default(true).describe("\u662F\u5426\u5305\u542B variable.xxx / variable[...] \u8D4B\u503C"),limit:z$1.number().optional().default(80)}),annotations:{readOnlyHint:true,destructiveHint:false}},async({variable:t,project_path:n,file_path:r,include_properties:s,limit:o})=>{let a=performance.now(),{db:c}=e.getContext(n),l=c.listFiles(r),p=Math.min(300,Math.max(1,o||80)),d=s??true,u=c.exactSearch(t,"state",void 0,r||void 0),f={vue2:"Vue2 data()",vue3:"Vue3 ref/reactive",react:"React useState/useRef"},m=u.filter(N=>N.default_value!=null).map(N=>({filePath:N.file_path,line:N.start_line,kind:`data_init(${f[N.framework]||N.framework})`,text:`${N.name}: ${N.default_value} \u2190 \u58F0\u660E\u521D\u59CB\u5316`})),g=jt(l,t,d,p);if(g.length===0){let N=kn(t,d);g=$e(l,N,p);}let y=new Map;for(let N of [...m,...g]){let R=`${N.filePath}:${N.line}`;y.has(R)||y.set(R,N);}let b=[...y.values()],T=Math.round((performance.now()-a)*100)/100;if(b.length===0){let N=W({durationMs:T,resultCount:0,backend:"ast_scan"});return {content:[{type:"text",text:`\u{1F9E9} \u53D8\u91CF\u8D4B\u503C\u8FFD\u8E2A: "${t}"
|
|
494
523
|
\u672A\u627E\u5230\u5339\u914D\u8D4B\u503C\u8BED\u53E5\uFF08\u5305\u62EC\u58F0\u660E\u521D\u59CB\u5316\uFF09
|
|
495
|
-
\u8FC7\u6EE4: file_path=${
|
|
524
|
+
\u8FC7\u6EE4: file_path=${r||"*"} include_properties=${d}
|
|
496
525
|
|
|
497
526
|
\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
|
|
498
|
-
${U(
|
|
527
|
+
${U(N)}`}]}}let h=[`\u{1F9E9} \u53D8\u91CF\u8D4B\u503C\u8FFD\u8E2A: "${t}"`,`\u8FC7\u6EE4: file_path=${r||"*"} include_properties=${d}`,`\u547D\u4E2D: ${b.length} \u5904${m.length>0?`\uFF08\u542B ${m.length} \u5904\u58F0\u660E\u521D\u59CB\u5316\uFF09`:""}`,""];b.forEach((N,R)=>{h.push(`${R+1}. [${N.kind}] \u{1F4C4} ${N.filePath}:L${N.line}`),h.push(` ${N.text}`);});let E=W({durationMs:T,resultCount:b.length,backend:"ast_scan"});return h.push(`
|
|
499
528
|
\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
|
|
500
|
-
${U(
|
|
501
|
-
`)}]}}),
|
|
529
|
+
${U(E)}`),{content:[{type:"text",text:h.join(`
|
|
530
|
+
`)}]}}),i.registerTool("skimmer_trace_property_changes",{title:"\u8FFD\u8E2A\u5BF9\u8C61\u5C5E\u6027\u4FEE\u6539",description:`\u3010\u964D\u7EA7\u5DE5\u5177\u3011\u4EC5\u5728\u4EE5\u4E0B\u573A\u666F\u5355\u72EC\u4F7F\u7528\uFF1A\u9700\u8981\u7CBE\u786E\u8FC7\u6EE4\u67D0\u4E00\u4E2A\u5177\u4F53\u5C5E\u6027\u5B57\u6BB5\uFF08\u5982 storageParams.receiveAdr\uFF09\uFF0C\u800C\u4E0D\u9700\u8981\u6574\u4F53\u8D4B\u503C/\u53C2\u6570\u4F20\u9012/storage\u94FE\u8DEF\u4FE1\u606F\u3002
|
|
502
531
|
\u26A0\uFE0F \u7EDD\u5927\u591A\u6570\u5BF9\u8C61\u6EAF\u6E90\u573A\u666F\u8BF7\u4F18\u5148\u4F7F\u7528 skimmer_trace_data_lifecycle\uFF0C\u5B83\u80FD\u4E00\u6B21\u62FF\u5230\u6240\u6709\u4FE1\u606F\u3002
|
|
503
532
|
\u2705 \u672C\u5DE5\u5177\u9002\u5408\uFF1Aobject.specificProp \u7684\u5355\u5B57\u6BB5\u7EA7\u522B\u7CBE\u786E\u8FFD\u8E2A\u3002
|
|
504
|
-
\u274C \u4E0D\u9002\u5408\uFF1A\u9700\u8981\u4E86\u89E3\u5BF9\u8C61\u6574\u4F53\u6765\u6E90\u6216\u6570\u636E\u6D41\u5411\u7684\u573A\u666F\u3002`,inputSchema:z$1.object({object:z$1.string().describe('\u5BF9\u8C61\u540D\uFF0C\u5982 "storageParams" / "params"'),property:z$1.string().optional().describe('\u5C5E\u6027\u540D\uFF0C\u5982 "receiveAdr"'),project_path:z$1.string().optional().describe(
|
|
505
|
-
\u522B\u540D\u5C55\u5F00: ${
|
|
506
|
-
\u672A\u627E\u5230\u5339\u914D\u8BED\u53E5${
|
|
507
|
-
\u8FC7\u6EE4: file_path=${
|
|
533
|
+
\u274C \u4E0D\u9002\u5408\uFF1A\u9700\u8981\u4E86\u89E3\u5BF9\u8C61\u6574\u4F53\u6765\u6E90\u6216\u6570\u636E\u6D41\u5411\u7684\u573A\u666F\u3002`,inputSchema:z$1.object({object:z$1.string().describe('\u5BF9\u8C61\u540D\uFF0C\u5982 "storageParams" / "params"'),property:z$1.string().optional().describe('\u5C5E\u6027\u540D\uFF0C\u5982 "receiveAdr"'),project_path:z$1.string().optional().describe(Ee),file_path:z$1.string().optional().describe("\u9650\u5B9A\u6587\u4EF6\u8DEF\u5F84\uFF08\u5305\u542B\u5373\u53EF\uFF09"),limit:z$1.number().optional().default(80)}),annotations:{readOnlyHint:true,destructiveHint:false}},async({object:t,property:n,project_path:r,file_path:s,limit:o})=>{let a=performance.now(),{db:c}=e.getContext(r),l=c.listFiles(s),p=Math.min(300,Math.max(1,o||80)),d=vn(l,t,20),u=Cn(l,t,20),f=[...new Set([...d.map(h=>h.alias),...u.map(h=>h.alias)].filter(h=>h!==t))],m=[t,...f],g=ft(l,t,n,p);for(let h of f)g.push(...ft(l,h,n,Math.floor(p/2)));if(g.length===0){let h="(?:=|\\+=|-=|\\*=|/=|%=|\\|=|&=|\\^=|&&=|\\|\\|=|\\?\\?=)",E=[];for(let N of m){let R=Be(N);if(n){let _=Be(n);E.push({kind:"dot",regex:new RegExp(`\\b${R}\\.${_}\\s*${h}`)},{kind:"bracket",regex:new RegExp(`\\b${R}\\s*\\[(?:'${_}'|"${_}")\\]\\s*${h}`)},{kind:"delete",regex:new RegExp(`\\bdelete\\s+${R}\\.(?:${_})\\b`)});}else E.push({kind:"dot",regex:new RegExp(`\\b${R}\\.[A-Za-z_$][\\w$]*\\s*${h}`)},{kind:"bracket",regex:new RegExp(`\\b${R}\\s*\\[(?:'[^']+'|"[^"]+")\\]\\s*${h}`)},{kind:"delete",regex:new RegExp(`\\bdelete\\s+${R}\\.[A-Za-z_$][\\w$]*\\b`)});}g=$e(l,E,p);}let y=Math.round((performance.now()-a)*100)/100;if(g.length===0){let h=f.length>0?`
|
|
534
|
+
\u522B\u540D\u5C55\u5F00: ${f.join(", ")}\uFF08\u5747\u672A\u547D\u4E2D\uFF09`:"",E=W({durationMs:y,resultCount:0,backend:"ast_scan"});return {content:[{type:"text",text:`\u{1F9ED} \u5C5E\u6027\u4FEE\u6539\u8FFD\u8E2A: ${t}${n?`.${n}`:".*"}
|
|
535
|
+
\u672A\u627E\u5230\u5339\u914D\u8BED\u53E5${h}
|
|
536
|
+
\u8FC7\u6EE4: file_path=${s||"*"}
|
|
508
537
|
|
|
509
538
|
\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
|
|
510
|
-
${U(
|
|
539
|
+
${U(E)}`}]}}let b=[`\u{1F9ED} \u5C5E\u6027\u4FEE\u6539\u8FFD\u8E2A: ${t}${n?`.${n}`:".*"}`,`\u8FC7\u6EE4: file_path=${s||"*"}`];if(f.length>0){let h=d.map(N=>N.alias).filter(N=>N!==t).join(", "),E=u.map(N=>N.alias).filter(N=>N!==t).join(", ");h&&b.push(`\u26A1 \u5F15\u7528\u522B\u540D: ${h}\uFF08\u901A\u8FC7 let alias = this.${t} \u5C55\u5F00\uFF09`),E&&b.push(`\u26A1 \u89E3\u6784\u522B\u540D: ${E}\uFF08\u901A\u8FC7 const { ${t}: alias } \u5C55\u5F00\uFF09`);}b.push(`\u547D\u4E2D: ${g.length} \u5904`,""),g.forEach((h,E)=>{b.push(`${E+1}. [${h.kind}] \u{1F4C4} ${h.filePath}:L${h.line}`),b.push(` ${h.text}`);});let T=W({durationMs:y,resultCount:g.length,backend:"ast_scan"});return b.push(`
|
|
511
540
|
\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
|
|
512
|
-
${U(
|
|
513
|
-
`)}]}}),
|
|
541
|
+
${U(T)}`),{content:[{type:"text",text:b.join(`
|
|
542
|
+
`)}]}}),i.registerTool("skimmer_find_by_behavior",{title:"\u6309\u884C\u4E3A\u6807\u7B7E\u641C\u7D22\u51FD\u6570",description:`\u6309 API \u8C03\u7528\u884C\u4E3A\u641C\u7D22\uFF0C\u5B8C\u5168\u7ED5\u8FC7\u547D\u540D\u95EE\u9898\u3002
|
|
514
543
|
\u793A\u4F8B:
|
|
515
544
|
- \u627E\u6240\u6709\u64CD\u4F5C localStorage \u7684\u51FD\u6570: { category: "storage" }
|
|
516
545
|
- \u627E\u5199\u5165 localStorage \u7684: { api_name: "localStorage", operation: "setItem" }
|
|
517
546
|
- \u627E\u53D1\u8BF7\u6C42\u7684: { category: "network" }
|
|
518
547
|
- \u627E\u8DEF\u7531\u8DF3\u8F6C\u7684: { category: "router" }
|
|
519
548
|
- \u6309 key \u540D\u641C\u7D22: { keyword: "cacheData" }
|
|
520
|
-
project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({project_path:z$1.string().optional().describe(
|
|
521
|
-
\u8FC7\u6EE4\u6761\u4EF6: ${JSON.stringify({category:n,api_name:
|
|
549
|
+
project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({project_path:z$1.string().optional().describe(Ee),category:z$1.enum(["storage","network","router","vuex","dom","event","timer","i18n"]).optional().describe("\u884C\u4E3A\u7C7B\u522B"),api_name:z$1.string().optional().describe('"localStorage" / "axios" / "$router"'),operation:z$1.string().optional().describe('"setItem" / "get" / "push" / "commit"'),keyword:z$1.string().optional().describe('\u5728\u53C2\u6570\u503C\u4E2D\u641C\u7D22\uFF08\u5982 key \u540D "cacheData"\uFF09'),file_path:z$1.string().optional().describe('\u9650\u5B9A\u6587\u4EF6\u8DEF\u5F84\u641C\u7D22\uFF08\u5305\u542B\u5373\u53EF\uFF0C\u5982 "src/views/apply/index.vue"\uFF09')}),annotations:{readOnlyHint:true,destructiveHint:false}},async({project_path:t,category:n,api_name:r,operation:s,keyword:o,file_path:a})=>{let c=performance.now(),{db:l}=e.getContext(t),d=new He(l).searchByBehavior({category:n,apiName:r,operation:s,keyword:o,filePath:a}),u=new Set(["localStorage","sessionStorage","cookie"]);r||(d=d.filter(b=>b.category!=="storage"||u.has(b.apiName.toLowerCase())));let f=Math.round((performance.now()-c)*100)/100,m=W({durationMs:f,resultCount:d.length,backend:"indexed"});if(d.length===0)return {content:[{type:"text",text:`\u{1F3F7}\uFE0F \u672A\u627E\u5230\u5339\u914D\u7684\u884C\u4E3A
|
|
550
|
+
\u8FC7\u6EE4\u6761\u4EF6: ${JSON.stringify({category:n,api_name:r,operation:s,keyword:o,file_path:a})}
|
|
522
551
|
|
|
523
552
|
\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
|
|
524
|
-
${U(
|
|
525
|
-
`];for(let[
|
|
526
|
-
${U(
|
|
527
|
-
`)}]}}),
|
|
528
|
-
`],
|
|
553
|
+
${U(m)}`}]};let g=new Map;for(let b of d){let T=`${b.category}:${b.apiName}`;g.has(T)||g.set(T,[]),g.get(T).push(b);}let y=[`\u{1F3F7}\uFE0F \u884C\u4E3A\u641C\u7D22\u7ED3\u679C \u2014 ${d.length} \u6761
|
|
554
|
+
`];for(let[b,T]of g){let[h,E]=b.split(":"),N=new Map;for(let R of T)N.has(R.operation)||N.set(R.operation,[]),N.get(R.operation).push(R);y.push(`\u{1F4C2} ${h} \u2192 ${E}:`);for(let[R,_]of N){y.push(` ${R}:`);let x=new Map;for(let A of _){let w=`${A.symbolName}|${A.filePath}`;x.has(w)||x.set(w,{item:A,callLines:[]}),x.get(w).callLines.push(A.line);}for(let{item:A,callLines:w}of x.values()){let M=A.detail?` key="${A.detail}"`:"",O=w.length>1?` \xD7${w.length} (L${w.join(", L")})`:` L${w[0]||A.startLine}`;y.push(` \u2022 ${A.symbolName}${M}${O} \u{1F4C4} ${A.filePath}:${ke(A.startLine,A.endLine)}`);}}y.push("");}return y.push(`\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
|
|
555
|
+
${U(m)}`),{content:[{type:"text",text:y.join(`
|
|
556
|
+
`)}]}}),i.registerTool("skimmer_get_call_graph",{title:"\u83B7\u53D6\u51FD\u6570\u8C03\u7528\u5173\u7CFB\u56FE\u8C31",description:"\u67E5\u770B\u51FD\u6570\u88AB\u8C01\u8C03\u7528\uFF08callers\uFF09\u4EE5\u53CA\u5B83\u8C03\u7528\u4E86\u4EC0\u4E48\uFF08callees\uFF09\u3002project_path \u53EF\u7701\u7565\u3002",inputSchema:z$1.object({symbol_name:z$1.string().describe("\u51FD\u6570\u540D"),project_path:z$1.string().optional().describe(Ee),file_path:z$1.string().optional().describe("\u6587\u4EF6\u8DEF\u5F84\uFF08\u540C\u540D\u51FD\u6570\u65F6\u7528\u4E8E\u7CBE\u786E\u5B9A\u4F4D\uFF09"),direction:z$1.enum(["callers","callees","both"]).optional().default("both"),arg_keyword:z$1.string().optional().describe('\u8C03\u7528\u53C2\u6570\u5173\u952E\u5B57\u8FC7\u6EE4\uFF08\u5982 "storageParams"\uFF09')}),annotations:{readOnlyHint:true,destructiveHint:false}},async({symbol_name:t,project_path:n,file_path:r,direction:s,arg_keyword:o})=>{let a=performance.now(),{db:c}=e.getContext(n),l=c.getSymbolByName(t,r),p=[`\u{1F4CA} ${t} \u7684\u8C03\u7528\u56FE\u8C31
|
|
557
|
+
`],d=0,u=0,f=[],m=[];if(s==="callers"||s==="both"){if(f=c.getCallers(t,r,o),d+=f.length,u+=f.filter(h=>h.edge_kind==="precise").length,p.push(`\u2B06\uFE0F \u88AB\u8C03\u7528 (${f.length} \u5904):`),f.length===0)p.push(" \uFF08\u672A\u627E\u5230\u8C03\u7528\u8005\uFF09");else {let h={method_call:"",template_event:"\u{1F5BC}\uFE0F",jsx_event:"\u269B\uFE0F",hook_call:"\u{1FA9D}",import_call:"\u{1F4E5}",router_call:"\u{1F6E3}\uFE0F",store_dispatch:"\u{1F4E6}",store_commit:"\u{1F4E6}"};for(let E of f){let N=E.args?` \u53C2\u6570: "${E.args}"`:"",R=E.source_kind||"",_=E.edge_kind||"",x=h[R]?` ${h[R]}`:"",A=_==="precise"?" [\u{1F3AF}precise]":"";p.push(` \u2022 ${E.caller_name} [${E.category}]${x}${A} \u{1F4C4} ${E.file_path}:L${E.start_line}${N}`);}}p.push("");}if((s==="callees"||s==="both")&&l){if(m=c.getCallees(l.id),d+=m.length,u+=m.filter(h=>h.edge_kind==="precise").length,p.push(`\u2B07\uFE0F \u8C03\u7528\u4E86 (${m.length} \u4E2A):`),m.length===0)p.push(" \uFF08\u672A\u5206\u6790\u5230\u8C03\u7528\u5173\u7CFB\uFF09");else for(let h of m){let E=h.args?`("${h.args}")`:"",R=(h.edge_kind||"")==="precise"?" [\u{1F3AF}precise]":"";p.push(` \u2022 ${h.callee_name}${E} [${h.call_type}]${R} L${h.line_number}`);}p.push("");}if(l){let{behaviors:h}=c.getFileOutline(l.file_path),E=h.filter(N=>N.symbol_id===l.id);if(E.length>0){p.push("\u{1F4E6} \u5916\u90E8\u72B6\u6001\u64CD\u4F5C:");for(let N of E){let R=N.detail?` ("${N.detail}")`:"";p.push(` \u2022 ${N.api_name}.${N.operation}${R} [${N.category}] L${N.line_number}`);}}}let g=Math.round((performance.now()-a)*100)/100,y=u>0?"precise":"heuristic",b=[];y==="heuristic"&&d>0&&b.push('\u5F53\u524D\u7ED3\u679C\u5747\u4E3A\u542F\u53D1\u5F0F\u5206\u6790\uFF0C\u4F7F\u7528 skimmer_index_project({ precision_mode: "precise" }) \u53EF\u83B7\u5F97\u8DE8\u6587\u4EF6 import/export \u7CBE\u786E\u7ED1\u5B9A');let T=W({durationMs:g,resultCount:d,backend:"indexed",precisionEffective:y,precisionWarnings:b.length>0?b:void 0});return p.push(`
|
|
529
558
|
\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
|
|
530
|
-
${U(
|
|
531
|
-
`)}]}}),
|
|
532
|
-
`),c){let
|
|
533
|
-
\u26A0\uFE0F \u4FEE\u6539\u65F6\u6CE8\u610F\u5916\u90E8\u72B6\u6001\u7684\u8BFB\u5199\u683C\u5F0F\u4FDD\u6301\u4E00\u81F4`);}let
|
|
559
|
+
${U(T)}`),{content:[{type:"text",text:p.join(`
|
|
560
|
+
`)}]}}),i.registerTool("skimmer_get_blast_radius",{title:"\u8BC4\u4F30\u4FEE\u6539\u5F71\u54CD\u8303\u56F4",description:"\u5206\u6790\u4FEE\u6539\u67D0\u51FD\u6570\u4F1A\u5F71\u54CD\u54EA\u4E9B\u8C03\u7528\u70B9\uFF0C\u7ED9\u51FA\u98CE\u9669\u7B49\u7EA7\u3002\u4FEE\u6539\u524D\u8C03\u7528\u8BC4\u4F30\u98CE\u9669\u3002project_path \u53EF\u7701\u7565\u3002",inputSchema:z$1.object({symbol_name:z$1.string().describe("\u8981\u4FEE\u6539\u7684\u51FD\u6570\u540D"),project_path:z$1.string().optional().describe(Ee),file_path:z$1.string().optional().describe("\u6587\u4EF6\u8DEF\u5F84\uFF08\u540C\u540D\u65F6\u7CBE\u786E\u5B9A\u4F4D\uFF09")}),annotations:{readOnlyHint:true,destructiveHint:false}},async({symbol_name:t,project_path:n,file_path:r})=>{let s=performance.now(),{db:o}=e.getContext(n),a=o.getCallers(t,r),c=o.getSymbolByName(t,r),{behaviors:l}=c?o.getFileOutline(c.file_path):{behaviors:[]},p=c?l.filter(b=>b.symbol_id===c.id):[],d=a.length===0?"\u{1F7E2}":a.length<=3?"\u{1F7E1}":"\u{1F534}",u=a.length===0?"\u4F4E":a.length<=3?"\u4E2D":"\u9AD8",f=[`\u{1F4A5} \u4FEE\u6539 ${t} \u7684\u5F71\u54CD\u8BC4\u4F30`,"\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",`${d} \u98CE\u9669\u7B49\u7EA7: ${u} (${a.length} \u5904\u76F4\u63A5\u8C03\u7528)`,""],m={method_call:"\u{1F4DE} \u65B9\u6CD5\u8C03\u7528",template_event:"\u{1F5BC}\uFE0F \u6A21\u677F\u4E8B\u4EF6",jsx_event:"\u269B\uFE0F JSX\u4E8B\u4EF6",hook_call:"\u{1FA9D} Hook\u8C03\u7528",import_call:"\u{1F4E5} \u5BFC\u5165\u8C03\u7528",router_call:"\u{1F6E3}\uFE0F \u8DEF\u7531",store_dispatch:"\u{1F4E6} Store",store_commit:"\u{1F4E6} Commit"};if(a.length>0?(f.push("\u{1F534} \u76F4\u63A5\u5F71\u54CD:"),a.forEach((b,T)=>{let h=b.source_kind||"",E=m[h]?` ${m[h]}`:"";f.push(` ${T+1}. ${b.caller_name} [${b.category}]${E} \u{1F4C4} ${b.file_path}:L${b.start_line}`);}),f.push("")):f.push(`\u2705 \u65E0\u8C03\u7528\u8005\uFF0C\u5F71\u54CD\u8303\u56F4\u53EF\u63A7
|
|
561
|
+
`),c){let b=o.getFileDependencies(c.file_path,"to");if(b.length>0){f.push(`\u{1F4C2} \u6587\u4EF6\u4F9D\u8D56 (${b.length} \u4E2A\u6587\u4EF6 import \u4E86\u6B64\u6587\u4EF6):`);let T={import:"\u{1F4E5}",re_export:"\u{1F504}",component_ref:"\u{1F9E9}",store_ref:"\u{1F4E6}",api_ref:"\u{1F310}"};b.slice(0,10).forEach(h=>{f.push(` ${T[h.dependency_kind]||"\u2022"} ${h.from_file} (${h.dependency_kind})`);}),f.push("");}}if(p.length>0){f.push("\u{1F4E6} \u5916\u90E8\u72B6\u6001\u5F71\u54CD:");for(let b of p)f.push(` \u2022 ${b.api_name}.${b.operation}${b.detail?` key="${b.detail}"`:""} [${b.category}]`);f.push(`
|
|
562
|
+
\u26A0\uFE0F \u4FEE\u6539\u65F6\u6CE8\u610F\u5916\u90E8\u72B6\u6001\u7684\u8BFB\u5199\u683C\u5F0F\u4FDD\u6301\u4E00\u81F4`);}let g=Math.round((performance.now()-s)*100)/100,y=W({durationMs:g,resultCount:a.length,backend:"indexed"});return f.push(`
|
|
534
563
|
\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
|
|
535
|
-
${U(
|
|
536
|
-
`)}]}}),
|
|
564
|
+
${U(y)}`),{content:[{type:"text",text:f.join(`
|
|
565
|
+
`)}]}}),i.registerTool("skimmer_trace_data_lifecycle",{title:"\u53D8\u91CF\u5B8C\u6574\u751F\u547D\u5468\u671F\u8FFD\u8E2A\uFF08\u4E00\u952E\u7248\uFF09",description:`\u2B50 \u3010\u9996\u9009\u5DE5\u5177\u3011\u8FFD\u8E2A\u53D8\u91CF/\u72B6\u6001\u7684\u5B8C\u6574\u6570\u636E\u751F\u547D\u5468\u671F\uFF0C\u4E00\u6B21\u8C03\u7528\u805A\u5408 4 \u4E2A\u7EF4\u5EA6\uFF0C\u66FF\u4EE3\u8FC7\u53BB\u591A\u6B65\u624B\u52A8\u8FFD\u8E2A\u3002
|
|
537
566
|
|
|
538
567
|
\u{1F3AF} \u89E6\u53D1\u89C4\u5219\uFF08\u9047\u5230\u4EE5\u4E0B\u4EFB\u610F\u4E00\u79CD\u95EE\u9898\uFF0C\u76F4\u63A5\u4F7F\u7528\u672C\u5DE5\u5177\uFF09\uFF1A
|
|
539
568
|
- "xxx \u662F\u4ECE\u54EA\u91CC\u6765\u7684\uFF1F" / "xxx \u662F\u600E\u4E48\u8D4B\u503C\u7684\uFF1F"
|
|
@@ -551,39 +580,39 @@ ${U(b)}`),{content:[{type:"text",text:h.join(`
|
|
|
551
580
|
\u65E7\u65B9\u5F0F: trace_assignments \u2192 find_symbol \u2192 get_code_slice \u2192 find_by_behavior \u2192 trace_key_flow
|
|
552
581
|
\u65B0\u65B9\u5F0F: skimmer_trace_data_lifecycle({ variable: "xxx" }) \u2190 \u76F4\u63A5\u5F97\u5230\u5168\u90E8
|
|
553
582
|
|
|
554
|
-
project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({variable:z$1.string().describe('\u8981\u8FFD\u8E2A\u7684\u53D8\u91CF\u540D\u6216 key\uFF0C\u5982 "storageParams" / "savedData"'),project_path:z$1.string().optional().describe(
|
|
555
|
-
`+
|
|
583
|
+
project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({variable:z$1.string().describe('\u8981\u8FFD\u8E2A\u7684\u53D8\u91CF\u540D\u6216 key\uFF0C\u5982 "storageParams" / "savedData"'),project_path:z$1.string().optional().describe(Ee),file_path:z$1.string().optional().describe('\u9650\u5B9A\u6587\u4EF6\u8DEF\u5F84\uFF08\u5305\u542B\u5373\u53EF\uFF0C\u5982 "src/views/apply/index.vue"\uFF09'),storage_api:z$1.enum(["localStorage","sessionStorage","all"]).optional().default("all").describe("storage \u843D\u70B9\u8FC7\u6EE4"),max_depth:z$1.number().optional().default(2).describe("storage \u94FE\u8DEF\u5411\u4E0B\u8FFD\u8E2A\u6DF1\u5EA6\uFF081-5\uFF09"),limit:z$1.number().optional().default(40).describe("\u6BCF\u7EF4\u5EA6\u6700\u5927\u7ED3\u679C\u6570")}),annotations:{readOnlyHint:true,destructiveHint:false}},async({variable:t,project_path:n,file_path:r,storage_api:s,max_depth:o,limit:a})=>{let c=performance.now(),{db:l}=e.getContext(n),p=Math.min(5,Math.max(1,o||2)),d=Math.min(120,Math.max(1,a||40)),u=l.listFiles(r),f="",m=Ln(l,u,r?u.length:5);m.stale&&(f=`\u26A0\uFE0F [\u7D22\u5F15\u5DF2\u8FC7\u671F] \u4EE5\u4E0B\u6587\u4EF6\u5DF2\u4FEE\u6539\u4F46\u7D22\u5F15\u672A\u66F4\u65B0\uFF0C\u2462 \u53C2\u6570\u4F20\u9012 \u548C \u2464 storage \u94FE\u8DEF\u7684\u884C\u53F7\u53EF\u80FD\u504F\u79FB:
|
|
584
|
+
`+m.staleFilePaths.slice(0,3).map(S=>` \u2022 ${S}`).join(`
|
|
556
585
|
`)+`
|
|
557
586
|
\u5EFA\u8BAE: skimmer_index_project({ force: true })
|
|
558
|
-
`);let
|
|
559
|
-
\u{1F517} \u53D1\u73B0\u522B\u540D: ${
|
|
587
|
+
`);let g=Cn(u,t,20),y=[...new Set(g.map(S=>S.alias).filter(S=>S!==t))],b=vn(u,t,20),T=[...new Set(b.map(S=>S.alias).filter(S=>S!==t))],h=[...new Set([...y,...T])],N=[t,...h],R=l.exactSearch(t,"state",void 0,r||void 0),_={vue2:"Vue2 data()",vue3:"Vue3 ref/reactive",react:"React useState/useRef"},x=R.filter(S=>S.default_value!=null).map(S=>({filePath:S.file_path,line:S.start_line,kind:`data_init(${_[S.framework]||S.framework})`,text:`${S.name}: ${S.default_value} \u2190 \u58F0\u660E\u521D\u59CB\u5316`})),A=false,w=l.getAssignments(t,r,d),M=[];w.length>0?(M=w.map(S=>({filePath:S.file_path,line:S.line_number,kind:S.kind,text:S.text_snippet||"",sourceLayer:S.source_layer||void 0})),A=true):M=jt(u,t,false,d);for(let S of h){let I=l.getAssignments(S,r,Math.floor(d/2));I.length>0?M.push(...I.map(L=>({filePath:L.file_path,line:L.line_number,kind:L.kind,text:L.text_snippet||"",sourceLayer:L.source_layer||void 0}))):M.push(...jt(u,S,false,Math.floor(d/2)));}let O=M.length===0?$e(u,kn(t,false),d):[],B=new Map;for(let S of [...x,...M.length>0?M:O]){let I=`${S.filePath}:${S.line}`;B.has(I)||B.set(I,S);}let ce=[...B.values()],ye=false,Ae=l.getPropertyWrites(t,void 0,r,d),q=[];Ae.length>0?(q=Ae.map(S=>({filePath:S.file_path,line:S.line_number,kind:S.kind,text:S.text_snippet||"",sourceLayer:S.source_layer||void 0})),ye=true):q=ft(u,t,void 0,d);for(let S of h){let I=l.getPropertyWrites(S,void 0,r,Math.floor(d/2));I.length>0?q.push(...I.map(L=>({filePath:L.file_path,line:L.line_number,kind:L.kind,text:L.text_snippet||"",sourceLayer:L.source_layer||void 0}))):q.push(...ft(u,S,void 0,Math.floor(d/2)));}let le=q.length===0?$e(u,[{kind:"dot",regex:new RegExp(`\\b${t}\\.[A-Za-z_$][\\w$]*\\s*(?:=|\\+=|-=|\\*=|\\/=|%=|\\|=|&=|\\^=|&&=|\\|\\|=|\\?\\?=`)},{kind:"bracket",regex:new RegExp(`\\b${t}\\s*\\[(?:'[^']+'|"[^"]+")\\]\\s*(?:=|\\+=)`)},{kind:"delete",regex:new RegExp(`\\bdelete\\s+${t}\\.[A-Za-z_$][\\w$]*\\b`)}],d):[],X=q.length>0?q:le,re=l.findRelationsByArgKeyword(t,r,d);for(let S of h)re.push(...l.findRelationsByArgKeyword(S,r,Math.floor(d/2)));let Ht=[],Bt=[],Xt=[];for(let S of N){let I=Be(S),L=/^[a-zA-Z_$][\w$]*$/.test(S)?"\\b":"";Ht.push({kind:"template",regex:new RegExp(`(?::\\w+|v-model|v-if|v-show|@\\w+)="[^"]*${L}${I}${L}|\\{\\{[^}]*${L}${I}${L}[^}]*\\}\\}`)},{kind:"return",regex:new RegExp(`\\breturn\\b[^=]*${L}${I}${L}`)},{kind:"watch",regex:new RegExp(`watch[^(]*['"]\\.?${I}['"]`)},{kind:"computed_read",regex:new RegExp(`=>[^=]*${L}${I}${L}|return[^=]*${L}${I}${L}`)},{kind:"arg_usage",regex:new RegExp(`\\(\\s*[^)]*${L}${I}${L}[^)]*\\)`)}),Bt.push(`${L}${I}${L}\\s*(?:=|\\+=|-=|\\*=|\\/=)(?!=)|\\b(?:const|let|var)\\s+${I}\\b`),Xt.push(`${L}${I}${L}\\.\\w+\\s*(?:=|\\+=|-=)(?!=)|${L}${I}${L}\\s*\\[`);}let Mn=$e(u,Ht,d),jn=new RegExp(Bt.join("|")),Un=new RegExp(Xt.join("|")),Pe=Mn.filter(S=>!jn.test(S.text)&&!Un.test(S.text)),yt=new Map,Wn=(S,I)=>{if(!yt.has(S)){let{behaviors:P}=l.getFileOutline(S),$=new Map;for(let j of P){let Q=String(j.symbol_name||"");$.has(Q)||$.set(Q,[]),$.get(Q).push(j);}yt.set(S,$);}return (yt.get(S)?.get(I)||[]).filter(P=>String(P.category||"")!=="storage"?false:s==="all"?true:String(P.api_name||"").toLowerCase()===s.toLowerCase())},Hn=(S,I)=>{let L=[],P=[{name:S,filePath:I,path:[S],level:0}],$=new Set([`${I}::${S}`]);for(;P.length>0;){let j=P.shift(),Q=Wn(j.filePath,j.name);if(Q.length>0){L.push({path:j.path,file:j.filePath,behaviors:Q});continue}if(j.level>=p)continue;let J=l.getSymbolByName(j.name,j.filePath);if(J||(J=l.getSymbolByName(j.name)),!J)continue;let Ne=String(J.file_path||J.abs_path||j.filePath),Ke=l.getCallees(J.id);for(let bt of Ke){let pe=String(bt.callee_name||"");if(!pe||pe.startsWith("$"))continue;let Vt=`${Ne}::${pe}`;$.has(Vt)||($.add(Vt),P.push({name:pe,filePath:Ne,path:[...j.path,pe],level:j.level+1}));}}return L},Bn=h.length>0?`
|
|
588
|
+
\u{1F517} \u53D1\u73B0\u522B\u540D: ${h.map(S=>`"${S}"`).join(", ")}\uFF08\u5DF2\u4E00\u5E76\u8FFD\u8E2A\u5C5E\u6027\u4FEE\u6539\uFF09`:"",Le=[];b.length>0&&(Le.push(` \u{1F517} \u5F15\u7528\u522B\u540D\u4F20\u64AD (${b.length} \u5904) \u2014 \u8FD9\u4E9B\u5C40\u90E8\u53D8\u91CF\u662F "${t}" \u7684\u5F15\u7528\uFF0C\u5176\u5C5E\u6027\u4FEE\u6539\u4E5F\u88AB\u8FFD\u8E2A:`),b.slice(0,10).forEach(S=>{let L=u.find(j=>j.path===S.filePath)?.abs_path||S.abs_path,P=ut("alias_ref"),$=L?Mt(L,S.line,2):{snippet:""};Le.push(` \u{1F4C4} ${S.filePath}:L${S.line} "${S.alias}" = ... ${P}`),Le.push(` ${S.text}`),$.snippet&&Le.push($.snippet);}));let C=[`\u{1F52C} \u53D8\u91CF\u751F\u547D\u5468\u671F\u8FFD\u8E2A: "${t}"`,"\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",`\u8FC7\u6EE4: file_path=${r||"*"} storage_api=${s} depth=${p}${Bn}`,""];if(f&&C.push(f),C.push(`\u2460 \u58F0\u660E & \u6574\u4F53\u8D4B\u503C (${ce.length} \u5904)`),ce.length===0)C.push(" \uFF08\u672A\u627E\u5230\uFF09");else {let S={init:[],cache:[],user:[],unknown:[]};for(let L of ce){let P=L.sourceLayer||ee(L.text,L.line);S[P].push(L);}let I=["init","cache","user","unknown"];for(let L of I){let P=S[L];!P||P.length===0||(C.push(` \u25B8 ${wn[L]} (${P.length} \u5904)`),P.slice(0,8).forEach($=>{let j=h.includes($.text.split("=")[0]?.trim().replace(/^(?:const|let|var)\s+/,"")||""),Q=ut($.kind,j);C.push(` \u{1F4C4} ${$.filePath}:L${$.line} [${$.kind}] ${Q}`),C.push(` ${$.text}`);}));}Le.length>0&&(C.push(""),C.push(...Le));}if(C.push(""),C.push(`\u2461 \u5C5E\u6027\u4FEE\u6539 (${X.length} \u5904)`),X.length===0)C.push(' \uFF08\u672A\u627E\u5230 object.prop \u6216 object["prop"] \u5199\u5165\uFF09'),h.length>0&&C.push(` \u2139\uFE0F \u5DF2\u8FFD\u8E2A\u522B\u540D: ${h.map(S=>`"${S}"`).join(", ")} \u7684\u5C5E\u6027\u4FEE\u6539\uFF08\u5982\u4ECD\u672A\u627E\u5230\uFF0C\u8868\u793A\u771F\u6B63\u65E0\u95F4\u63A5\u5199\u5165\uFF09`);else {let S={init:[],cache:[],user:[],unknown:[]};for(let L of X){let P=L.sourceLayer||ee(L.text,L.line);S[P].push(L);}let I=["init","cache","user","unknown"];for(let L of I){let P=S[L];!P||P.length===0||(C.push(` \u25B8 ${wn[L]} (${P.length} \u5904)`),P.slice(0,8).forEach($=>{let j=h.some(pe=>$.text.startsWith(pe)),Q=ut($.kind,j),Ne=u.find(pe=>pe.path===$.filePath)?.abs_path||"",Ke=Ne?Mt(Ne,$.line,2):{snippet:""},bt=j?" \u{1F517}(via alias)":"";C.push(` \u{1F4C4} ${$.filePath}:L${$.line} [${$.kind}] ${Q}${bt}`),Ke.snippet&&C.push(Ke.snippet);}));}}if(C.push(""),C.push(`\u2462 \u4F5C\u4E3A\u53C2\u6570\u88AB\u4F20\u5165\u8C03\u7528 (${re.length} \u5904)`),re.length===0?C.push(" \uFF08\u672A\u53D1\u73B0\u4EE5\u8BE5\u53D8\u91CF\u4F5C\u4E3A\u53C2\u6570\u7684\u51FD\u6570\u8C03\u7528\uFF09"):re.slice(0,20).forEach(S=>{let I=String(S.args||"");C.push(` \u{1F4C4} ${S.file_path}:L${S.line_number} ${S.caller_name} \u2192 ${S.callee_name} \u53C2\u6570: "${I}"`);}),C.push(""),C.push(`\u2463 \u8BFB\u53D6/\u4F7F\u7528 (${Pe.length} \u5904)`),Pe.length===0)C.push(" \uFF08\u672A\u53D1\u73B0 template \u7ED1\u5B9A / watch / computed / return \u4E2D\u7684\u5F15\u7528\uFF09");else {let S=new Map;for(let L of Pe)S.has(L.kind)||S.set(L.kind,[]),S.get(L.kind).push(L);let I={template:"\u{1F5BC}\uFE0F template \u7ED1\u5B9A",return:"\u21A9\uFE0F return \u8FD4\u56DE",watch:"\u{1F441}\uFE0F watch \u76D1\u542C",computed_read:"\u{1F9EE} computed \u5F15\u7528",arg_usage:"\u{1F4E8} \u51FD\u6570\u53C2\u6570\u4F7F\u7528"};for(let[L,P]of S)C.push(` \u25B8 ${I[L]||L}`),P.slice(0,8).forEach($=>C.push(` \u{1F4C4} ${$.filePath}:L${$.line} ${$.text}`));}C.push("");let Re=0;C.push(`\u2464 Storage \u843D\u70B9\u8FFD\u8E2A (storage_api=${s}, depth=${p})`);let Xn=s==="localStorage"?"localStorage":s==="sessionStorage"?"sessionStorage":"(?:localStorage|sessionStorage)",Kn=N.map(S=>({kind:"direct_storage",regex:new RegExp(`${Xn}\\.(?:setItem|getItem|removeItem|clear)\\(.*?\\b${Be(S)}\\b`)})),Xe=$e(u,Kn,d);if(Xe.length>0&&(Re+=1,C.push(` \u843D\u70B9 [\u76F4\u63A5\u547D\u4E2D\u5B58\u50A8] ${ut("direct_storage")}:`),Xe.slice(0,15).forEach(S=>{let L=u.find($=>$.path===S.filePath)?.abs_path||"",P=L?Mt(L,S.line,2):{snippet:""};C.push(` \u{1F4C4} ${S.filePath}:L${S.line} ${S.text.trim()}`),P.snippet&&C.push(P.snippet);})),re.length===0&&Xe.length===0)C.push(" \uFF08\u672A\u53D1\u73B0\u76F4\u63A5 Storage \u64CD\u4F5C\uFF0C\u4E14\u65E0\u8C03\u7528\u5165\u53E3\u5C55\u5F00\u8FFD\u8E2A\uFF09");else {let S=new Map;for(let I of re){let L=`${I.file_path}::${I.callee_name}`;S.has(L)||S.set(L,I);}for(let[,I]of S){let L=String(I.callee_name||""),P=String(I.file_path||""),$=Hn(L,P);$.length!==0&&(Re+=1,$.slice(0,3).forEach(j=>{let Q=j.file!==P?` \u2197 \u8DE8\u6587\u4EF6: ${j.file}`:"";C.push(` \u94FE\u8DEF: ${j.path.join(" \u2192 ")}${Q}`),j.behaviors.forEach(J=>{let Ne=J.detail?`("${String(J.detail)}")`:"";C.push(` \u843D\u70B9: ${J.api_name}.${J.operation}${Ne} [${J.category}] L${J.line_number}`);});}));}Re===0&&Xe.length===0&&C.push(` \uFF08\u5728 depth=${p} \u5C42\u5185\u672A\u627E\u5230 storage \u5199\u5165\u94FE\u8DEF\uFF09`);}C.push(""),C.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501");let Vn=h.length>0?` (\u542B ${h.length} \u4E2A\u522B\u540D: ${h.slice(0,3).map(S=>`"${S}"`).join(", ")})`:"";C.push(`\u2705 \u6C47\u603B${Vn}:`),C.push(` \u2460 \u58F0\u660E/\u8D4B\u503C: ${ce.length} \u5904`),C.push(` \u2461 \u5C5E\u6027\u4FEE\u6539: ${X.length} \u5904 (\u5DF2\u8FFD\u8E2A\u522B\u540D: ${h.map(S=>`"${S}"`).join(", ")||"\u65E0"})`),C.push(` \u2462 \u53C2\u6570\u4F20\u9012: ${re.length} \u5904`),C.push(` \u2463 \u8BFB\u53D6\u5F15\u7528: ${Pe.length} \u5904`),C.push(` \u2464 storage: ${Re>0?`\u2713 \u53D1\u73B0\u5199\u5165\u94FE\u8DEF (${Re} \u6761)`:"\u2717 \u672A\u53D1\u73B0"}`),C.push(""),C.push("\u{1F4A1} \u6765\u6E90\u5206\u5C42\u8BF4\u660E: \u{1F331}\u521D\u59CB\u5316 = lifecycle/data | \u{1F4BE}\u7F13\u5B58\u56DE\u663E = storage\u8BFB/fetch | \u{1F5B1}\uFE0F\u7528\u6237\u4EA4\u4E92 = \u4E8B\u4EF6/watch"),C.push("\u{1F4CA} \u7F6E\u4FE1\u5EA6: \u25CF\u25CF\u25CF\u25CF\u25CF \u226590% \u25CF\u25CF\u25CF\u25CF\u25CB \u226580% \u25CF\u25CF\u25CF\u25CB\u25CB \u226570% \u25CF\u25CF\u25CB\u25CB\u25CB \u226560% \u9700\u4EBA\u5DE5\u9A8C\u8BC1\u884C\u53F7\u786E\u8BA4");let zn=Math.round((performance.now()-c)*100)/100,Gn=ce.length+X.length+re.length+Pe.length+Re,Kt=W({durationMs:zn,resultCount:Gn,backend:A&&ye?"indexed":A||ye?"hybrid":"fallback_scan"});return m.stale&&(Kt.index_freshness=m),C.push(`
|
|
560
589
|
\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
|
|
561
|
-
${U(
|
|
562
|
-
`)}]}});}function
|
|
590
|
+
${U(Kt)}`),{content:[{type:"text",text:C.join(`
|
|
591
|
+
`)}]}});}function Fn(i,e){i.registerTool("skimmer_index_health",{title:"\u7D22\u5F15\u5065\u5EB7\u68C0\u67E5",description:`\u68C0\u67E5\u5F53\u524D\u9879\u76EE\u7D22\u5F15\u7684\u5065\u5EB7\u72B6\u6001\u3002
|
|
563
592
|
\u8FD4\u56DE: \u7D22\u5F15\u6587\u4EF6\u6570\u3001\u7B26\u53F7\u6570\u3001\u5173\u7CFB\u6570\u3001\u884C\u4E3A\u6570\u3001\u6700\u540E\u66F4\u65B0\u65F6\u95F4\u3001\u5931\u8D25\u6587\u4EF6\u3001watcher \u72B6\u6001\u3001\u6570\u636E\u5E93\u5927\u5C0F\u3002
|
|
564
|
-
project_path \u53EF\u7701\u7565\uFF08\u81EA\u52A8\u4F7F\u7528\u4E0A\u6B21\u7D22\u5F15\u7684\u9879\u76EE\uFF09\u3002`,inputSchema:z$1.object({project_path:z$1.string().optional().describe("\u9879\u76EE\u6839\u76EE\u5F55\uFF08\u53EF\u7701\u7565\uFF0C\u4F7F\u7528\u4E0A\u6B21\u7D22\u5F15\u7684\u9879\u76EE\uFF09")}),annotations:{readOnlyHint:true,destructiveHint:false}},async({project_path:t})=>{let n=performance.now(),{db:
|
|
565
|
-
`)}]}});}var
|
|
566
|
-
\u652F\u6301\u5217\u51FA\u5F53\u524D\u6240\u6709\u5DF2\u7F13\u5B58\u7684\u9879\u76EE\u3002project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({project_path:z$1.string().optional().describe(
|
|
593
|
+
project_path \u53EF\u7701\u7565\uFF08\u81EA\u52A8\u4F7F\u7528\u4E0A\u6B21\u7D22\u5F15\u7684\u9879\u76EE\uFF09\u3002`,inputSchema:z$1.object({project_path:z$1.string().optional().describe("\u9879\u76EE\u6839\u76EE\u5F55\uFF08\u53EF\u7701\u7565\uFF0C\u4F7F\u7528\u4E0A\u6B21\u7D22\u5F15\u7684\u9879\u76EE\uFF09")}),annotations:{readOnlyHint:true,destructiveHint:false}},async({project_path:t})=>{let n=performance.now(),{db:r,projectRoot:s}=e.getContext(t),o=r.getProjectStats(),a=(()=>{try{let E=r.getLastIndexedTime();return E?new Date(E).toISOString():"\u6682\u65E0\u7D22\u5F15\u6570\u636E"}catch{return "\u6682\u65E0\u7D22\u5F15\u6570\u636E"}})(),c=o.fileCount||0,l=o.symbolCount||0,p=r.getIndexFailures(10),d=e.hasWatcher(s),m=e.listProjects().find(E=>E.root===s)?.dbPath||"",g=o.dbSize||0,y={dbPath:m,indexedFiles:c,totalSymbols:l,totalRelations:o.relationCount||0,totalBehaviors:o.behaviorCount||0,lastIndexedAt:a,failureCount:o.failureCount||0,failedFiles:p.map(E=>({file:E.file_path,error:E.error})),watcherActive:d,dbSizeBytes:g},b=Math.round((performance.now()-n)*100)/100,T=W({durationMs:b,resultCount:1,backend:"indexed"}),h=[`\u{1F3E5} \u7D22\u5F15\u5065\u5EB7\u68C0\u67E5 \u2014 ${s}`,"\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501","","\u{1F4CA} \u7D22\u5F15\u7EDF\u8BA1:",` \u{1F4C1} \u5DF2\u7D22\u5F15\u6587\u4EF6: ${y.indexedFiles}`,` \u{1F523} \u7B26\u53F7\u6570: ${y.totalSymbols}`,` \u{1F517} \u8C03\u7528\u5173\u7CFB: ${y.totalRelations}`,` \u{1F3F7}\uFE0F \u884C\u4E3A\u6807\u7B7E: ${y.totalBehaviors}`,` \u{1F4C5} \u6700\u540E\u7D22\u5F15\u65F6\u95F4: ${y.lastIndexedAt}`,` \u2757 \u5931\u8D25\u6587\u4EF6\u603B\u6570: ${y.failureCount}`,"","\u{1F50C} \u8FD0\u884C\u65F6\u72B6\u6001:",` \u{1F4C2} \u6587\u4EF6\u76D1\u542C: ${y.watcherActive?"\u2705 \u6D3B\u8DC3":"\u274C \u672A\u542F\u52A8"}`,` \u{1F4BE} \u6570\u636E\u5E93\u5927\u5C0F: ${Math.round(y.dbSizeBytes/1024)} KB`,` \u{1F4CD} \u6570\u636E\u5E93\u8DEF\u5F84: ${y.dbPath||"\uFF08\u5185\u5B58\uFF09"}`,"","\u{1F4A1} \u5EFA\u8BAE:"];if(y.totalSymbols===0&&y.indexedFiles>0?h.push(" \u26A0\uFE0F \u6709\u6587\u4EF6\u4F46\u7B26\u53F7\u6570\u4E3A0 \u2014 \u53EF\u80FD\u9700\u8981\u8C03\u6574\u89E3\u6790\u89C4\u5219\u6216\u5F3A\u5236\u91CD\u5EFA"):y.indexedFiles===0?h.push(" \u274C \u5C1A\u672A\u7D22\u5F15 \u2014 \u8FD0\u884C skimmer_index_project \u5F00\u59CB\u7D22\u5F15"):h.push(" \u2705 \u7D22\u5F15\u72B6\u6001\u6B63\u5E38"),!y.watcherActive&&y.indexedFiles>0&&h.push(" \u{1F4A1} \u6587\u4EF6\u76D1\u542C\u672A\u542F\u52A8 \u2014 \u8FD0\u884C skimmer_index_project \u53EF\u81EA\u52A8\u5F00\u542F"),y.failedFiles.length>0){h.push(""),h.push("\u26A0\uFE0F \u6700\u8FD1\u5931\u8D25\u6587\u4EF6\u6837\u672C:");for(let E of y.failedFiles.slice(0,5))h.push(` - ${E.file}: ${E.error}`);}return h.push(""),h.push("\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500"),h.push(U(T)),{content:[{type:"text",text:h.join(`
|
|
594
|
+
`)}]}});}var Qr="\u9879\u76EE\u6839\u76EE\u5F55\uFF08\u53EF\u7701\u7565\uFF0C\u4F7F\u7528\u4E0A\u6B21\u7D22\u5F15\u7684\u9879\u76EE\uFF09";function Dn(i,e){i.registerTool("skimmer_get_project_overview",{title:"\u83B7\u53D6\u9879\u76EE\u6574\u4F53\u6982\u89C8",description:`\u8FD4\u56DE\u9879\u76EE\u7684\u5168\u666F\u7EDF\u8BA1\uFF1A\u6587\u4EF6\u6570\u3001\u6846\u67B6\u5206\u5E03\u3001\u6700\u5927\u6587\u4EF6\u3001\u884C\u4E3A\u7EDF\u8BA1\u3002
|
|
595
|
+
\u652F\u6301\u5217\u51FA\u5F53\u524D\u6240\u6709\u5DF2\u7F13\u5B58\u7684\u9879\u76EE\u3002project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({project_path:z$1.string().optional().describe(Qr),list_all_projects:z$1.boolean().optional().default(false).describe("\u662F\u5426\u5217\u51FA\u6240\u6709\u5DF2\u7D22\u5F15\u7684\u9879\u76EE")}),annotations:{readOnlyHint:true,destructiveHint:false}},async({project_path:t,list_all_projects:n})=>{let r=performance.now();if(n){let m=e.listProjects(),g=Math.round((performance.now()-r)*100)/100,y=W({durationMs:g,resultCount:m.length,backend:"indexed"});if(m.length===0)return {content:[{type:"text",text:`\u{1F4CB} \u5F53\u524D\u6CA1\u6709\u5DF2\u7D22\u5F15\u7684\u9879\u76EE
|
|
567
596
|
|
|
568
597
|
\u4F7F\u7528 skimmer_index_project({ project_path: "/your/project" }) \u5F00\u59CB\u7D22\u5F15
|
|
569
598
|
|
|
570
599
|
\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
|
|
571
|
-
${U(
|
|
572
|
-
`];return
|
|
600
|
+
${U(y)}`}]};let b=[`\u{1F4CB} \u5DF2\u7D22\u5F15\u7684\u9879\u76EE (${m.length} \u4E2A):
|
|
601
|
+
`];return m.forEach((T,h)=>{b.push(`${h+1}. ${T.root}`),b.push(` \u6570\u636E\u5E93: ${T.dbPath}`);}),b.push(`
|
|
573
602
|
\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
|
|
574
|
-
${U(
|
|
575
|
-
`)}]}}let{db:
|
|
603
|
+
${U(y)}`),{content:[{type:"text",text:b.join(`
|
|
604
|
+
`)}]}}let{db:s,projectRoot:o}=e.getContext(t),a=s.getProjectStats(),c=["\u{1F4CA} \u9879\u76EE\u6982\u89C8","\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",`\u{1F4C1} ${o}`,"",`\u{1F4C8} \u6574\u4F53: \u6587\u4EF6 ${a.fileCount} | \u7B26\u53F7 ${a.symbolCount} | \u884C\u4E3A\u6807\u7B7E ${a.behaviorCount} | \u8C03\u7528\u5173\u7CFB ${a.relationCount}`,""],l=a.frameworkBreakdown;if(l?.length){let m={vue2:"\u{1F7E2} Vue2",vue3:"\u{1F535} Vue3",react:"\u269B\uFE0F React",js:"\u{1F4DC} JS",ts:"\u{1F4D8} TS"};c.push("\u{1F527} \u6846\u67B6\u5206\u5E03:");for(let g of l)c.push(` ${m[g.framework]||g.framework}: ${g.count} \u4E2A`);c.push("");}let p=a.topFiles;p?.length&&(c.push("\u{1F5C2}\uFE0F Top 10 \u6700\u5927\u6587\u4EF6:"),p.forEach((m,g)=>{c.push(` ${g+1}. ${m.path} (${m.line_count} \u884C, ${m.symbol_count} \u7B26\u53F7)`);}),c.push(""));let d=a.behaviorStats;if(d?.length){let m={storage:"\u{1F4BE} \u5B58\u50A8",network:"\u{1F310} \u7F51\u7EDC",router:"\u{1F6E3}\uFE0F \u8DEF\u7531",vuex:"\u{1F4E6} Vuex",dom:"\u{1F5A5}\uFE0F DOM",event:"\u{1F4E1} \u4E8B\u4EF6",timer:"\u23F1\uFE0F \u5B9A\u65F6\u5668",i18n:"\u{1F30D} \u56FD\u9645\u5316"};c.push("\u{1F3F7}\uFE0F \u884C\u4E3A\u7EDF\u8BA1:");for(let g of d)c.push(` ${m[g.category]||g.category}: ${g.count} \u5904`);c.push("");}c.push(`\u{1F4BD} \u6570\u636E\u5E93: ${Math.round(a.dbSize/1024)} KB`);let u=Math.round((performance.now()-r)*100)/100,f=W({durationMs:u,resultCount:1,backend:"indexed"});return c.push(`
|
|
576
605
|
\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
|
|
577
|
-
${U(
|
|
578
|
-
`)}]}});}var he=new
|
|
579
|
-
`);try{let{projectRoot:n}=he.getContext(process.env.SKIMMER_PROJECT),
|
|
580
|
-
`);let
|
|
606
|
+
${U(f)}`),{content:[{type:"text",text:c.join(`
|
|
607
|
+
`)}]}});}var he=new lt,Oe=new McpServer({name:"frontend-code-skimmer",version:"0.4.2"});An(Oe,he);Rn(Oe,he);On(Oe,he);Fn(Oe,he);Dn(Oe,he);async function ns(){if(process.env.SKIMMER_AUTO_INDEX==="true"&&process.env.SKIMMER_PROJECT){process.stderr.write(`[Frontend-Code-Skimmer] \u81EA\u52A8\u7D22\u5F15: ${process.env.SKIMMER_PROJECT}
|
|
608
|
+
`);try{let{projectRoot:n}=he.getContext(process.env.SKIMMER_PROJECT),r=he.getIndexer(n),s=await r.indexProject();process.stderr.write(`[Frontend-Code-Skimmer] \u5B8C\u6210: ${s.indexedFiles} \u6587\u4EF6, ${s.totalSymbols} \u7B26\u53F7
|
|
609
|
+
`);let o=await r.startWatcher();he.registerWatcher(n,o),process.stderr.write(`[Frontend-Code-Skimmer] \u6587\u4EF6\u76D1\u542C\u5DF2\u542F\u52A8: ${n}
|
|
581
610
|
`);}catch(n){process.stderr.write(`[Frontend-Code-Skimmer] \u7D22\u5F15\u5931\u8D25: ${String(n)}
|
|
582
|
-
`);}}let e=new StdioServerTransport;await
|
|
611
|
+
`);}}let e=new StdioServerTransport;await Oe.connect(e),process.stderr.write(`[Frontend-Code-Skimmer MCP] \u5DF2\u542F\u52A8 (v0.4.2)
|
|
583
612
|
`),process.stderr.write(`[Frontend-Code-Skimmer MCP] \u652F\u6301\u6846\u67B6: Vue 2 / Vue 3 / React Hooks
|
|
584
613
|
`),process.stderr.write(`[Frontend-Code-Skimmer MCP] \u652F\u6301\u7CBE\u5EA6: heuristic / precise (\u8DE8\u6587\u4EF6 import \u7ED1\u5B9A)
|
|
585
614
|
`),process.stderr.write(`[Frontend-Code-Skimmer MCP] \u652F\u6301\u6A21\u5F0F: \u52A8\u6001\u4EFB\u610F\u9879\u76EE\uFF08\u65E0\u9700\u542F\u52A8\u65F6\u6307\u5B9A\uFF09
|
|
586
615
|
`),process.env.SKIMMER_PROJECT?process.stderr.write(`[Frontend-Code-Skimmer MCP] \u9ED8\u8BA4\u9879\u76EE: ${process.env.SKIMMER_PROJECT}
|
|
587
616
|
`):process.stderr.write(`[Frontend-Code-Skimmer MCP] \u63D0\u793A: \u672A\u8BBE\u7F6E SKIMMER_PROJECT\uFF0C\u6BCF\u6B21\u8C03\u7528\u5DE5\u5177\u65F6\u8BF7\u4F20\u5165 project_path
|
|
588
|
-
`);let t=()=>{he.closeAll(),process.exit(0);};process.on("SIGINT",t),process.on("SIGTERM",t);}
|
|
617
|
+
`);let t=()=>{he.closeAll(),process.exit(0);};process.on("SIGINT",t),process.on("SIGTERM",t);}ns().catch(i=>{process.stderr.write(`[Frontend-Code-Skimmer MCP] \u542F\u52A8\u5931\u8D25: ${String(i)}
|
|
589
618
|
`),process.exit(1);});
|