@jokeran/frontend-code-skimmer 0.4.4 → 0.4.5

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.
Files changed (2) hide show
  1. package/dist/index.js +44 -44
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import*as Q from'fs';import Q__default from'fs';import*as z from'path';import z__default from'path';import {fileURLToPath}from'url';import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import Gr from'os';import Zn,{createHash}from'crypto';import sr from'better-sqlite3';import zr from'fast-glob';import {createRequire}from'module';import {z as z$1}from'zod';function ze(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 Ge(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 Me(i){return Zn.createHash("md5").update(i).digest("hex")}function qe(i){if(!i)return 0;let e=1;for(let t=0;t<i.length;t++)i[t]===`
2
+ import*as z from'path';import z__default from'path';import {fileURLToPath}from'url';import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import qr from'os';import*as Q from'fs';import Q__default from'fs';import Qn,{createHash}from'crypto';import ir from'better-sqlite3';import Gr from'fast-glob';import {createRequire}from'module';import {z as z$1}from'zod';function ze(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 Ge(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 Me(i){return Qn.createHash("md5").update(i).digest("hex")}function qe(i){if(!i)return 0;let e=1;for(let t=0;t<i.length;t++)i[t]===`
3
3
  `&&e++;return e}function Re(i,e){return i===e?`L${i}`:`L${i}-L${e}`}function de(i,e){return z__default.relative(e,i).replace(/\\/g,"/")}function je(i,e){if(!i)return e;try{return JSON.parse(i)}catch{return e}}function K(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 Jt(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=Ge(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 Yt(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=Ge(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 er=[".ts",".tsx",".js",".jsx",".vue"],tr=["index.ts","index.tsx","index.js","index.jsx","index.vue"];function nr(i){return [...er.map(e=>`${i}${e}`),...tr.map(e=>z.join(i,e))]}function Ne(i){if(Q.existsSync(i))try{if(Q.statSync(i).isFile())return i}catch{}for(let e of nr(i))if(Q.existsSync(e))return e;return i}var _t=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**","**/.nuxt/**","**/.next/**","**/__tests__/**","**/docs/js/**","**/public/**/*.js","**/*.test.*","**/*.spec.*","**/*.min.js"],Nt=["**/*.vue","**/*.js","**/*.jsx","**/*.ts","**/*.tsx"],Qt={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"]}},Tt=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","activated","deactivated","errorCaptured"],St=["onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","onActivated","onDeactivated","onErrorCaptured","onRenderTracked","onRenderTriggered","onServerPrefetch"],en=["ref","reactive","shallowRef","shallowReactive","readonly"],tn=["computed"],nn=["watch","watchEffect","watchPostEffect","watchSyncEffect"],xt=["useState","useReducer","useRef","useImperativeHandle"],At=["useMemo","useCallback"],Lt=["useEffect","useLayoutEffect","useInsertionEffect"],rn=["useContext","useDebugValue","useDeferredValue","useId","useSyncExternalStore","useTransition"],Je=".skimmer-index.db",sn=30,on=4,an=300;var rr=[{version:1,description:"\u5EFA\u7ACB schema_version \u8868",statements:[`CREATE TABLE IF NOT EXISTS schema_version (
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 qt(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=Ge(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 Jt(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=Ge(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 tr=[".ts",".tsx",".js",".jsx",".vue"],nr=["index.ts","index.tsx","index.js","index.jsx","index.vue"];function rr(i){return [...tr.map(e=>`${i}${e}`),...nr.map(e=>z.join(i,e))]}function Ne(i){if(Q.existsSync(i))try{if(Q.statSync(i).isFile())return i}catch{}for(let e of rr(i))if(Q.existsSync(e))return e;return i}var _t=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**","**/.nuxt/**","**/.next/**","**/__tests__/**","**/docs/js/**","**/public/**/*.js","**/*.test.*","**/*.spec.*","**/*.min.js"],Nt=["**/*.vue","**/*.js","**/*.jsx","**/*.ts","**/*.tsx"],Zt={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"]}},Tt=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","activated","deactivated","errorCaptured"],St=["onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","onActivated","onDeactivated","onErrorCaptured","onRenderTracked","onRenderTriggered","onServerPrefetch"],Qt=["ref","reactive","shallowRef","shallowReactive","readonly"],en=["computed"],tn=["watch","watchEffect","watchPostEffect","watchSyncEffect"],xt=["useState","useReducer","useRef","useImperativeHandle"],At=["useMemo","useCallback"],Lt=["useEffect","useLayoutEffect","useInsertionEffect"],nn=["useContext","useDebugValue","useDeferredValue","useId","useSyncExternalStore","useTransition"],Je=".skimmer-index.db",rn=30,sn=4,on=300;var sr=[{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
@@ -34,11 +34,11 @@ import*as Q from'fs';import Q__default from'fs';import*as z from'path';import z_
34
34
  file_path TEXT NOT NULL,
35
35
  error TEXT NOT NULL,
36
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 cn(i){let e=[],t=[];i.exec(`CREATE TABLE IF NOT EXISTS schema_version (
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 an(i){let e=[],t=[];i.exec(`CREATE TABLE IF NOT EXISTS schema_version (
38
38
  version INTEGER PRIMARY KEY,
39
39
  applied_at INTEGER NOT NULL,
40
40
  description TEXT
41
- )`);let n=i.prepare("SELECT MAX(version) as v FROM schema_version").get()?.v??0;for(let r of rr){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 or(i,e){let t=z__default.posix.dirname(e),n=t==="."?[]:t.split("/").map(()=>"..");return z__default.resolve(z__default.dirname(i),...n)}function ar(i,e,t){if(!i)return i;if(z__default.isAbsolute(i)){let n=de(Ne(i),t);return n.startsWith("..")?i.replace(/\\/g,"/"):n}if(i.startsWith(".")){let n=Ne(z__default.resolve(z__default.dirname(e),i)),r=de(n,t);return r.startsWith("..")?i.replace(/\\/g,"/"):r}if(i.startsWith("@/")){let n=Ne(z__default.resolve(t,"src",i.slice(2))),r=de(n,t);return r.startsWith("..")?i.replace(/\\/g,"/"):r}return i.replace(/\\/g,"/")}var Ye=class{db;constructor(e,t){let n=t||z__default.join(e,Je);Q__default.mkdirSync(z__default.dirname(n),{recursive:true}),this.db=new sr(n),this.initialize();}initialize(){this.db.pragma("journal_mode = WAL"),this.db.pragma("foreign_keys = ON"),this.db.pragma("synchronous = NORMAL"),this.db.exec(`
41
+ )`);let n=i.prepare("SELECT MAX(version) as v FROM schema_version").get()?.v??0;for(let r of sr){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 ar(i,e){let t=z__default.posix.dirname(e),n=t==="."?[]:t.split("/").map(()=>"..");return z__default.resolve(z__default.dirname(i),...n)}function cr(i,e,t){if(!i)return i;if(z__default.isAbsolute(i)){let n=de(Ne(i),t);return n.startsWith("..")?i.replace(/\\/g,"/"):n}if(i.startsWith(".")){let n=Ne(z__default.resolve(z__default.dirname(e),i)),r=de(n,t);return r.startsWith("..")?i.replace(/\\/g,"/"):r}if(i.startsWith("@/")){let n=Ne(z__default.resolve(t,"src",i.slice(2))),r=de(n,t);return r.startsWith("..")?i.replace(/\\/g,"/"):r}return i.replace(/\\/g,"/")}var Ye=class{db;constructor(e,t){let n=t||z__default.join(e,Je);Q__default.mkdirSync(z__default.dirname(n),{recursive:true}),this.db=new ir(n),this.initialize();}initialize(){this.db.pragma("journal_mode = WAL"),this.db.pragma("foreign_keys = ON"),this.db.pragma("synchronous = NORMAL"),this.db.exec(`
42
42
  -- \u6587\u4EF6\u5143\u4FE1\u606F
43
43
  CREATE TABLE IF NOT EXISTS files (
44
44
  id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -183,7 +183,7 @@ import*as Q from'fs';import Q__default from'fs';import*as z from'path';import z_
183
183
  CREATE INDEX IF NOT EXISTS idx_symbols_name ON symbols(name);
184
184
  CREATE INDEX IF NOT EXISTS idx_symbols_framework ON symbols(framework);
185
185
  CREATE INDEX IF NOT EXISTS idx_behaviors_file ON behaviors(file_id);
186
- `);let{applied:e,errors:t}=cn(this.db);e.length>0&&process.stderr.write(`[Frontend-Code-Skimmer] \u6570\u636E\u5E93\u8FC1\u79FB\u5B8C\u6210: v${e.join(", v")}
186
+ `);let{applied:e,errors:t}=an(this.db);e.length>0&&process.stderr.write(`[Frontend-Code-Skimmer] \u6570\u636E\u5E93\u8FC1\u79FB\u5B8C\u6210: v${e.join(", v")}
187
187
  `),t.length>0&&process.stderr.write(`[Frontend-Code-Skimmer] \u8FC1\u79FB\u8B66\u544A: ${t.join("; ")}
188
188
  `),this.db.exec(`
189
189
  CREATE INDEX IF NOT EXISTS idx_behaviors_api_lc ON behaviors(api_name_lc, operation_lc);
@@ -225,7 +225,7 @@ import*as Q from'fs';import Q__default from'fs';import*as z from'path';import z_
225
225
  INSERT INTO relations_fts(rowid, args)
226
226
  VALUES (new.id, new.args);
227
227
  END;
228
- `);}saveParseResult(e,t,n,r,s,o,a=0,c="",l=""){let p=z__default.extname(t).slice(1),d=or(t,n);this.db.transaction(()=>{this.clearIndexFailures(n);let m=this.db.prepare("SELECT id FROM files WHERE path = ?").get(n),f;m?(f=m.id,this.db.prepare("DELETE FROM symbols WHERE file_id = ?").run(f),this.db.prepare(`
228
+ `);}saveParseResult(e,t,n,r,s,o,a=0,c="",l=""){let p=z__default.extname(t).slice(1),d=ar(t,n);this.db.transaction(()=>{this.clearIndexFailures(n);let m=this.db.prepare("SELECT id FROM files WHERE path = ?").get(n),f;m?(f=m.id,this.db.prepare("DELETE FROM symbols WHERE file_id = ?").run(f),this.db.prepare(`
229
229
  UPDATE files SET
230
230
  abs_path = ?, framework = ?, content_hash = ?,
231
231
  last_indexed_at = ?, file_size = ?, line_count = ?, file_mtime = ?,
@@ -253,7 +253,7 @@ import*as Q from'fs';import Q__default from'fs';import*as z from'path';import z_
253
253
  `);for(let x of e.propertyWrites)N.run(x.objectName,x.objectName.toLowerCase(),x.propertyName||null,x.propertyName?.toLowerCase()||"",f,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 N=this.db.prepare(`
254
254
  INSERT INTO file_dependencies (from_file, to_file, dependency_kind, line_number)
255
255
  VALUES (?, ?, ?, ?)
256
- `);for(let x of e.fileDependencies)N.run(n,ar(x.toFile,t,d),x.dependencyKind,x.line);}let A=this.db.prepare(`
256
+ `);for(let x of e.fileDependencies)N.run(n,cr(x.toFile,t,d),x.dependencyKind,x.line);}let A=this.db.prepare(`
257
257
  INSERT INTO behaviors (symbol_id, file_id, category, api_name, api_name_lc, operation, operation_lc, detail, detail_lc, line_number)
258
258
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
259
259
  `);for(let N of e.behaviors){let x=_(N.symbolName,N.line,N.symbolKey);if(x){let L=N.detail||null;A.run(x,f,N.category,N.apiName,N.apiName.toLowerCase(),N.operation,N.operation.toLowerCase(),L,L?.toLowerCase()??"",N.line);}}if(e.errors?.length){let N=this.db.prepare(`
@@ -406,10 +406,10 @@ import*as Q from'fs';import Q__default from'fs';import*as z from'path';import z_
406
406
  JOIN symbols s ON r.caller_id = s.id
407
407
  JOIN files f ON s.file_id = f.id
408
408
  WHERE r.callee_name_lc = ?
409
- `,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 V(i,e,t,n=false){let r=[];return G(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.type==="OptionalCallExpression"){let c=cr(o,e);c&&r.push(c);}if(o.type==="MemberExpression"){let a=lr(o);a&&r.push(a);}}),hr(r)}function cr(i,e,t){let n=i.callee;if(!n)return null;let r=Rt(i);if(n.type==="MemberExpression"||n.type==="OptionalMemberExpression"){let s=pr(n);if(!s)return null;let{apiName:o,operation:a}=s,c=i.arguments,l=ne(c?.[0]),p=mr(o);return p?{symbolName:e,category:p,apiName:o,operation:a,detail:l,line:r}:o==="this"&&Ze(a)?{symbolName:e,category:"network",apiName:`this.${a}`,operation:"wrapped_call",detail:l||ne(c?.[1]),line:r}:ln(a)&&gr(c)?{symbolName:e,category:"network",apiName:o,operation:a,detail:l||ne(c?.[1]),line:r}:Ze(o)||Ze(`${o}.${a}`)?{symbolName:e,category:"network",apiName:o,operation:ln(a)?a:"wrapped_call",detail:l||ne(c?.[1]),line:r}:null}if(n.type==="Identifier"){let s=n.name,o=dr(s),a=i.arguments,c=ne(a?.[0]);return o?{symbolName:e,category:o.category,apiName:s,operation:o.operation,detail:c,line:r}:Ze(s)?{symbolName:e,category:"network",apiName:s,operation:"wrapped_call",detail:c||ne(a?.[1]),line:r}:null}return null}function lr(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=fr(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 pr(i){let e=i.object,t=i.property;if(!e||!t||t.type!=="Identifier")return null;let n=t.name;if(e.type==="MemberExpression"||e.type==="OptionalMemberExpression"){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 dr(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 Rt(i){return i.loc?.start?.line??0}function ur(i){let e=i.loc;return {line:e?.start?.line??0,column:e?.start?.column??0}}function fr(i){return i.type==="Identifier"?i.name:i.type==="ThisExpression"?"this":null}function mr(i){if(i==="this")return null;for(let[e,t]of Object.entries(Qt))if(i in t)return e;return null}function ne(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=Qe(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=ne(o);if(c)return `${a}:${c}`}return "{...}"}}}function Qe(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=Qe(i.object)||"obj",r=i.property,s=r?.type==="Identifier"?String(r.name):Qe(r)||"prop";return i.computed?`${n}[${s}]`:`${n}.${s}`}if(i.type==="CallExpression")return `${Qe(i.callee)||"fn"}(...)`;if(i.type==="TemplateLiteral")return ne(i);let t=ne(i);return t?.startsWith("[\u53D8\u91CF: ")?t.replace(/^\[变量: /,"").replace(/\]$/,""):t}function Ze(i){return /request|api|http|fetch|ajax|akscommonhandle|commonhandle/i.test(i)}function ln(i){return ["get","post","put","delete","patch","request"].includes(i.toLowerCase())}function gr(i,e){if(!i||i.length===0)return false;for(let t of i.slice(0,2)){let n=ne(t);if(n&&(/https?:\/\//i.test(n)||n.includes("/")||/gw\d?\/|\/m\/|\/api\//i.test(n)))return true}return false}function hr(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 ke(i,e,t){let n=[];return G(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=pn(l);n.push({calleeName:c,line:Rt(r),args:p});}}}}),n}function q(i,e,t,n=false){let r=[];return G(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&&!yr(a)){let c=o.arguments,l=pn(c);r.push({calleeName:a,line:Rt(o),args:l});}}}),r}function yr(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 pn(i,e){if(!i||i.length===0)return;let t=i.slice(0,3).map(n=>ne(n)).filter(n=>!!n);return t.length>0?t.join(", "):void 0}function G(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&&G(r,e);else n&&typeof n=="object"&&n.type&&G(n,e);}}function et(i,e){let t=[],n=new Set,r=i.split(`
410
- `);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 dn(i,e){let t=[],n=new Set;return G(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 m=c.property?.name;m&&!/^\$/.test(m)&&(l=m);}let{line:p,column:d}=ur(r),u=`${l}:${p}:${d}`;!l||n.has(u)||(n.add(u),t.push({calleeName:l,line:p}));}),t}var Er=createRequire(import.meta.url),un=false;function _r(i){un||(un=true,process.stderr.write(`[Frontend-Code-Skimmer] precise import graph \u5DF2\u964D\u7EA7: ${String(i)}
411
- `));}function fn(i,e,t){let n={filePath:i,imports:[],exports:[]};try{let r=Er("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=nt(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 m=u.propertyName?u.propertyName.text:u.name.text;n.imports.push({localName:u.name.text,originalName:m,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){_r(r);}return n}function nt(i,e){let t=z.dirname(i);if(e.startsWith(".")){let n=z.resolve(t,e);return Ne(n)}return e.startsWith("@/")?Nr(i,e):e}function Nr(i,e){let t=z.dirname(i);for(let n=0;n<10;n++){let r=z.join(t,"src");if(Q.existsSync(r)&&Q.statSync(r).isDirectory()){let o=z.join(r,e.replace(/^@\//,""));return Ne(o)}let s=z.dirname(t);if(s===t)break;t=s;}return e}function W(i){return {callerName:i.callerName,callerLine:i.callerLine,callerKey:i.callerKey,calleeName:i.calleeName,callType:i.callType,line:i.line,args:i.args,sourceKind:ze(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:nt(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:nt(e,s.value),dependencyKind:"re_export",line:o?.start?.line??1});}}return t}function st(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(rt(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(rt(l.name,t.get(l.name)));}continue}for(let c of r.specifiers||[]){let l=kt(c.local),p=kt(c.exported)||l;p&&(a?.value?n.push(`re_export:${p}:${a.value}`):n.push(rt(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=kt(o);n.push(rt("default",a?t.get(a):void 0));continue}if(o.type==="FunctionDeclaration"||o.type==="FunctionExpression"||o.type==="ArrowFunctionExpression"){let a=(o.params||[]).map(c=>wt(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 rt(i,e){return `${i}:${Tr(e)}`}function Tr(i){return i?i.category==="class"?"class":i.signature?`fn${i.signature.replace(/^[^(]*/,"")}`:i.category==="constant"?`const:${i.defaultValue||""}`:i.category:"unknown"}function kt(i){if(i){if(i.type==="Identifier")return String(i.name||"");if(i.type==="StringLiteral")return String(i.value||"")}}function wt(i){return i?i.type==="Identifier"?String(i.name||"param"):i.type==="AssignmentPattern"?wt(i.left):i.type==="RestElement"?wt(i.argument):"param":"param"}var mn=createRequire(import.meta.url);var we=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=mn("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(`
412
- `),l;try{l=mn("@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=et(s.template.content,p);if(d.length>0){let u=s.template.content.split(`
409
+ `,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 V(i,e,t,n=false){let r=[];return G(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.type==="OptionalCallExpression"){let c=lr(o,e);c&&r.push(c);}if(o.type==="MemberExpression"){let a=pr(o);a&&r.push(a);}}),yr(r)}function lr(i,e,t){let n=i.callee;if(!n)return null;let r=Rt(i);if(n.type==="MemberExpression"||n.type==="OptionalMemberExpression"){let s=dr(n);if(!s)return null;let{apiName:o,operation:a}=s,c=i.arguments,l=ne(c?.[0]),p=gr(o);return p?{symbolName:e,category:p,apiName:o,operation:a,detail:l,line:r}:o==="this"&&Ze(a)?{symbolName:e,category:"network",apiName:`this.${a}`,operation:"wrapped_call",detail:l||ne(c?.[1]),line:r}:cn(a)&&hr(c)?{symbolName:e,category:"network",apiName:o,operation:a,detail:l||ne(c?.[1]),line:r}:Ze(o)||Ze(`${o}.${a}`)?{symbolName:e,category:"network",apiName:o,operation:cn(a)?a:"wrapped_call",detail:l||ne(c?.[1]),line:r}:null}if(n.type==="Identifier"){let s=n.name,o=ur(s),a=i.arguments,c=ne(a?.[0]);return o?{symbolName:e,category:o.category,apiName:s,operation:o.operation,detail:c,line:r}:Ze(s)?{symbolName:e,category:"network",apiName:s,operation:"wrapped_call",detail:c||ne(a?.[1]),line:r}:null}return null}function pr(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=mr(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 dr(i){let e=i.object,t=i.property;if(!e||!t||t.type!=="Identifier")return null;let n=t.name;if(e.type==="MemberExpression"||e.type==="OptionalMemberExpression"){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 ur(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 Rt(i){return i.loc?.start?.line??0}function fr(i){let e=i.loc;return {line:e?.start?.line??0,column:e?.start?.column??0}}function mr(i){return i.type==="Identifier"?i.name:i.type==="ThisExpression"?"this":null}function gr(i){if(i==="this")return null;for(let[e,t]of Object.entries(Zt))if(i in t)return e;return null}function ne(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=Qe(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=ne(o);if(c)return `${a}:${c}`}return "{...}"}}}function Qe(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=Qe(i.object)||"obj",r=i.property,s=r?.type==="Identifier"?String(r.name):Qe(r)||"prop";return i.computed?`${n}[${s}]`:`${n}.${s}`}if(i.type==="CallExpression")return `${Qe(i.callee)||"fn"}(...)`;if(i.type==="TemplateLiteral")return ne(i);let t=ne(i);return t?.startsWith("[\u53D8\u91CF: ")?t.replace(/^\[变量: /,"").replace(/\]$/,""):t}function Ze(i){return /request|api|http|fetch|ajax|akscommonhandle|commonhandle/i.test(i)}function cn(i){return ["get","post","put","delete","patch","request"].includes(i.toLowerCase())}function hr(i,e){if(!i||i.length===0)return false;for(let t of i.slice(0,2)){let n=ne(t);if(n&&(/https?:\/\//i.test(n)||n.includes("/")||/gw\d?\/|\/m\/|\/api\//i.test(n)))return true}return false}function yr(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 ke(i,e,t){let n=[];return G(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=ln(l);n.push({calleeName:c,line:Rt(r),args:p});}}}}),n}function q(i,e,t,n=false){let r=[];return G(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&&!br(a)){let c=o.arguments,l=ln(c);r.push({calleeName:a,line:Rt(o),args:l});}}}),r}function br(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 ln(i,e){if(!i||i.length===0)return;let t=i.slice(0,3).map(n=>ne(n)).filter(n=>!!n);return t.length>0?t.join(", "):void 0}function G(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&&G(r,e);else n&&typeof n=="object"&&n.type&&G(n,e);}}function et(i,e){let t=[],n=new Set,r=i.split(`
410
+ `);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 pn(i,e){let t=[],n=new Set;return G(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 m=c.property?.name;m&&!/^\$/.test(m)&&(l=m);}let{line:p,column:d}=fr(r),u=`${l}:${p}:${d}`;!l||n.has(u)||(n.add(u),t.push({calleeName:l,line:p}));}),t}var _r=createRequire(import.meta.url),dn=false;function Nr(i){dn||(dn=true,process.stderr.write(`[Frontend-Code-Skimmer] precise import graph \u5DF2\u964D\u7EA7: ${String(i)}
411
+ `));}function un(i,e,t){let n={filePath:i,imports:[],exports:[]};try{let r=_r("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=nt(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 m=u.propertyName?u.propertyName.text:u.name.text;n.imports.push({localName:u.name.text,originalName:m,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){Nr(r);}return n}function nt(i,e){let t=z.dirname(i);if(e.startsWith(".")){let n=z.resolve(t,e);return Ne(n)}return e.startsWith("@/")?Tr(i,e):e}function Tr(i,e){let t=z.dirname(i);for(let n=0;n<10;n++){let r=z.join(t,"src");if(Q.existsSync(r)&&Q.statSync(r).isDirectory()){let o=z.join(r,e.replace(/^@\//,""));return Ne(o)}let s=z.dirname(t);if(s===t)break;t=s;}return e}function W(i){return {callerName:i.callerName,callerLine:i.callerLine,callerKey:i.callerKey,calleeName:i.calleeName,callType:i.callType,line:i.line,args:i.args,sourceKind:ze(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:nt(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:nt(e,s.value),dependencyKind:"re_export",line:o?.start?.line??1});}}return t}function st(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(rt(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(rt(l.name,t.get(l.name)));}continue}for(let c of r.specifiers||[]){let l=kt(c.local),p=kt(c.exported)||l;p&&(a?.value?n.push(`re_export:${p}:${a.value}`):n.push(rt(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=kt(o);n.push(rt("default",a?t.get(a):void 0));continue}if(o.type==="FunctionDeclaration"||o.type==="FunctionExpression"||o.type==="ArrowFunctionExpression"){let a=(o.params||[]).map(c=>wt(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 rt(i,e){return `${i}:${Sr(e)}`}function Sr(i){return i?i.category==="class"?"class":i.signature?`fn${i.signature.replace(/^[^(]*/,"")}`:i.category==="constant"?`const:${i.defaultValue||""}`:i.category:"unknown"}function kt(i){if(i){if(i.type==="Identifier")return String(i.name||"");if(i.type==="StringLiteral")return String(i.value||"")}}function wt(i){return i?i.type==="Identifier"?String(i.name||"param"):i.type==="AssignmentPattern"?wt(i.left):i.type==="RestElement"?wt(i.argument):"param":"param"}var fn=createRequire(import.meta.url);var we=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=fn("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(`
412
+ `),l;try{l=fn("@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=et(s.template.content,p);if(d.length>0){let u=s.template.content.split(`
413
413
  `).length;n.symbols.push({name:"<template>",category:"lifecycle",framework:"vue2",startLine:p,endLine:p+u-1,camelWords:"template"});for(let m of d)n.relations.push(W({callerName:"<template>",callerLine:p,calleeName:m.calleeName,callType:"template_event",line:m.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]===`
414
414
  `&&n++;return n}extractFromAST(e,t,n,r,s){let o=t.split(`
415
415
  `);s.fileDependencies=fe(e.body||[],s.filePath);let a=null;G(e,d=>{if(d.type==="ExportDefaultDeclaration"){let u=d.declaration;if(u?.type==="ObjectExpression")a=u;else if(u?.type==="CallExpression"){let m=u.arguments;m&&m.length>0&&m[0].type==="ObjectExpression"&&(a=m[0]);}else if(u?.type==="Identifier"){let m=u.name;G(e,f=>{if(f.type==="VariableDeclarator"&&f.id?.name===m){if(f.init?.type==="ObjectExpression")a=f.init;else if(f.init?.type==="CallExpression"){let g=f.init.arguments;g&&g.length>0&&g[0].type==="ObjectExpression"&&(a=g[0]);}}});}}});let l=false;if(!a&&(G(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,m=["data","methods","computed","props","watch","components","created","mounted","mixins"];G(e,f=>{if(f.type==="ObjectExpression"){let g=f.properties||[],h=0;for(let b of g){let S=this.getPropKey(b);S&&m.includes(S)&&h++;}h>u&&(u=h,d=f);}}),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 m=d.type==="ObjectMethod"?d:d.value;if(!m)continue;let f=g=>g+r-1;switch(u){case "name":m?.type==="Literal"&&(String(m.value));break;case "data":this.extractData(m,o,f,s);break;case "props":this.extractProps(m,o,f,s);break;case "computed":this.extractComputedOrMethods(m,"computed",o,f,n,s);break;case "methods":this.extractComputedOrMethods(m,"method",o,f,n,s);break;case "watch":this.extractWatch(m,o,f,s);break;case "filters":this.extractComputedOrMethods(m,"filter",o,f,n,s);break;case "components":this.extractComponents(m,s);break;case "mixins":this.extractMixins(m,s);break;default:if(Tt.includes(u)){let g=f(this.getStartLine(d)),h=f(this.getEndLine(d)),b=K(n.join(`
@@ -422,28 +422,28 @@ import*as Q from'fs';import Q__default from'fs';import*as z from'path';import z_
422
422
  `);r.fileDependencies=fe(s.program.body||[],r.filePath);let c=false;return G(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 m=u.body;for(let f of m||[])this.processTopLevelStatement(f,o,n,a,r);}}}}),c||G(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 m=u.body;if(m?.type==="BlockStatement"){let f=m.body;for(let g of f||[])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=K(n.join(`
423
423
  `),t(p)),m=this.extractParams(c),f=s.symbols.length;if(s.symbols.push({name:l,category:"method",framework:"vue3",startLine:t(p),endLine:t(d),signature:`${l}(${(m||[]).join(", ")})`,params:m,isAsync:c.async===true,jsdoc:u,camelWords:k(l)}),c.body){let g=V(c.body,l);s.behaviors.push(...g);let h=q(c.body,l);for(let b of h){if(b.args){let S=String(b.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[f].camelWords+=` ${k(S)} ${S}`;}s.relations.push(W({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=K(n.join(`
424
424
  `),t(c)),d=this.extractParams(e),u=St.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 m=V(e.body,a);s.behaviors.push(...m);let f=q(e.body,a);for(let g of f){if(g.args){let h=String(g.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[s.symbols.length-1].camelWords+=` ${k(h)} ${h}`;}s.relations.push(W({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(St.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 m=V(u[0],l);s.behaviors.push(...m);let f=q(u[0],l);for(let g of f){if(g.args){let h=String(g.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[s.symbols.length-1].camelWords+=` ${k(h)} ${h}`;}s.relations.push(W({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=K(s.join(`
425
- `),c);if(en.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 tn.includes(a)?{name:e,category:"computed",framework:"vue3",startLine:c,endLine:l,jsdoc:p,camelWords:k(e)}:nn.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 we().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 Lr=createRequire(import.meta.url),Rr=[...xt,...At,...Lt,...rn],We=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=Lr("@babel/parser").parse(t,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy"],errorRecovery:!0}),o=t.split(`
425
+ `),c);if(Qt.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 en.includes(a)?{name:e,category:"computed",framework:"vue3",startLine:c,endLine:l,jsdoc:p,camelWords:k(e)}:tn.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 we().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 Rr=createRequire(import.meta.url),kr=[...xt,...At,...Lt,...nn],We=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=Rr("@babel/parser").parse(t,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy"],errorRecovery:!0}),o=t.split(`
426
426
  `);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);continue}this.processTopLevelVariableDeclaration(c,t,n,a);}}}n.exportSignatureEntries=st(r,n.symbols);}processTopLevelVariableDeclaration(e,t,n,r){let s=e.id;if(!s||s.type!=="Identifier")return;let o=s.name;if(!o)return;let a=e.init,c=e.loc,l=c?.start?.line??1,p=c?.end?.line??1,d=this.buildSymbolKey(o,l,p);if(n.symbols.push({name:o,category:"constant",framework:"react",startLine:l,endLine:p,internalKey:d,isExported:r,defaultValue:this.getLiteralValue(a),jsdoc:K(t.join(`
427
427
  `),l),camelWords:k(o)}),!a)return;let u=V(a,o,t,true);n.behaviors.push(...u);let m=q(a,o,t,true);for(let f of m){let g=n.symbols.findIndex(h=>h.name===o&&h.startLine===l);if(f.args&&g!==-1){let h=String(f.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");n.symbols[g].camelWords+=` ${k(h)} ${h}`;}n.relations.push(W({callerName:o,callerLine:l,callerKey:d,calleeName:f.calleeName,callType:"direct_call",line:f.line,args:f.args}));}}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=K(t.join(`
428
- `),a),u=this.extractParams(e),m=this.buildSymbolKey(s,a,c);n.symbols.push({name:s,category:l?"hook":p?"component":"function",framework:"react",startLine:a,endLine:c,internalKey:m,signature:`${s}(${(u||[]).join(", ")})`,params:u,isAsync:e.async===true,isExported:r,jsdoc:d,parentComponent:p?s:void 0,camelWords:k(s)});let f=e.body;if(f?.type!=="BlockStatement")return;let g=f.body;for(let y of g||[])this.processComponentStatement(y,s,t,n);let h=V(f,s,t,true);n.behaviors.push(...h);let b=q(f,s,t,true);for(let y of b){let _=n.symbols.findIndex(E=>E.name===s&&E.startLine===a);if(y.args&&_!==-1){let E=String(y.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");n.symbols[_].camelWords+=` ${k(E)} ${E}`;}n.relations.push(W({callerName:s,callerLine:a,callerKey:m,calleeName:y.calleeName,callType:"direct_call",line:y.line,args:y.args}));}let S=dn(f);for(let y of S)n.relations.push(W({callerName:s,callerLine:a,callerKey:m,calleeName:y.calleeName,callType:"jsx_event",line:y.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,m=d;if(xt.includes(l)&&l!=="useRef"){if(o.id?.type==="ArrayPattern"){let f=o.id.elements,g=f[0]?.name,h=f[1]?.name;if(g){let b=a.arguments;r.symbols.push({name:g,category:"state",framework:"react",startLine:u,endLine:m,internalKey:this.buildSymbolKey(g,u,m,t),stateSetterName:h,defaultValue:this.getLiteralValue(b?.[0]),parentComponent:t,camelWords:k(g)});}}else if(o.id?.type==="Identifier"){let f=o.id.name;r.symbols.push({name:f,category:"state",framework:"react",startLine:u,endLine:m,internalKey:this.buildSymbolKey(f,u,m,t),parentComponent:t,camelWords:k(f)});}}if(l==="useRef"&&o.id?.type==="Identifier"){let f=o.id.name,g=a.arguments;r.symbols.push({name:f,category:"state",framework:"react",startLine:u,endLine:m,internalKey:this.buildSymbolKey(f,u,m,t),defaultValue:this.getLiteralValue(g?.[0]),parentComponent:t,camelWords:k(f)});}if(At.includes(l)&&o.id?.type==="Identifier"){let f=o.id.name,h=a.arguments?.[1],b=this.extractDepsArray(h);r.symbols.push({name:f,category:"computed",framework:"react",startLine:u,endLine:m,internalKey:this.buildSymbolKey(f,u,m,t),hookDeps:b,parentComponent:t,camelWords:k(f)});}if(be(l)&&!Rr.includes(l)){let f=o.id?.type==="Identifier"?o.id.name:o.id?.type==="ObjectPattern"?"{...}":"?";r.symbols.push({name:f,category:"hook",framework:"react",startLine:u,endLine:m,internalKey:this.buildSymbolKey(f,u,m,t),parentComponent:t,camelWords:k(f)});}}if(e.type==="ExpressionStatement"&&e.expression?.type==="CallExpression"){let o=e.expression,a=o.callee;if(a?.type==="Identifier"){let c=a.name;if(Lt.includes(c)){let{start:l,end:p}=s(e),d=o.arguments,u=d?.[1],m=this.extractDepsArray(u),f=this.buildSymbolKey(c,l,p,t),g=`${t}.${c}`;if(r.symbols.push({name:c,category:"effect",framework:"react",startLine:l,endLine:p,internalKey:f,hookDeps:m,parentComponent:t,camelWords:k(c)}),d?.[0]){let h=V(d[0],g,n,true).map(S=>({...S,symbolKey:f}));r.behaviors.push(...h);let b=q(d[0],g,n,true);for(let S of b){let y=r.symbols.findIndex(_=>_.name===c&&_.startLine===l);if(S.args&&y!==-1){let _=String(S.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");r.symbols[y].camelWords+=` ${k(_)} ${_}`;}r.relations.push(W({callerName:g,callerLine:l,callerKey:f,calleeName:S.calleeName,callType:"direct_call",line:S.line,args:S.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=K(n.join(`
428
+ `),a),u=this.extractParams(e),m=this.buildSymbolKey(s,a,c);n.symbols.push({name:s,category:l?"hook":p?"component":"function",framework:"react",startLine:a,endLine:c,internalKey:m,signature:`${s}(${(u||[]).join(", ")})`,params:u,isAsync:e.async===true,isExported:r,jsdoc:d,parentComponent:p?s:void 0,camelWords:k(s)});let f=e.body;if(f?.type!=="BlockStatement")return;let g=f.body;for(let y of g||[])this.processComponentStatement(y,s,t,n);let h=V(f,s,t,true);n.behaviors.push(...h);let b=q(f,s,t,true);for(let y of b){let _=n.symbols.findIndex(E=>E.name===s&&E.startLine===a);if(y.args&&_!==-1){let E=String(y.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");n.symbols[_].camelWords+=` ${k(E)} ${E}`;}n.relations.push(W({callerName:s,callerLine:a,callerKey:m,calleeName:y.calleeName,callType:"direct_call",line:y.line,args:y.args}));}let S=pn(f);for(let y of S)n.relations.push(W({callerName:s,callerLine:a,callerKey:m,calleeName:y.calleeName,callType:"jsx_event",line:y.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,m=d;if(xt.includes(l)&&l!=="useRef"){if(o.id?.type==="ArrayPattern"){let f=o.id.elements,g=f[0]?.name,h=f[1]?.name;if(g){let b=a.arguments;r.symbols.push({name:g,category:"state",framework:"react",startLine:u,endLine:m,internalKey:this.buildSymbolKey(g,u,m,t),stateSetterName:h,defaultValue:this.getLiteralValue(b?.[0]),parentComponent:t,camelWords:k(g)});}}else if(o.id?.type==="Identifier"){let f=o.id.name;r.symbols.push({name:f,category:"state",framework:"react",startLine:u,endLine:m,internalKey:this.buildSymbolKey(f,u,m,t),parentComponent:t,camelWords:k(f)});}}if(l==="useRef"&&o.id?.type==="Identifier"){let f=o.id.name,g=a.arguments;r.symbols.push({name:f,category:"state",framework:"react",startLine:u,endLine:m,internalKey:this.buildSymbolKey(f,u,m,t),defaultValue:this.getLiteralValue(g?.[0]),parentComponent:t,camelWords:k(f)});}if(At.includes(l)&&o.id?.type==="Identifier"){let f=o.id.name,h=a.arguments?.[1],b=this.extractDepsArray(h);r.symbols.push({name:f,category:"computed",framework:"react",startLine:u,endLine:m,internalKey:this.buildSymbolKey(f,u,m,t),hookDeps:b,parentComponent:t,camelWords:k(f)});}if(be(l)&&!kr.includes(l)){let f=o.id?.type==="Identifier"?o.id.name:o.id?.type==="ObjectPattern"?"{...}":"?";r.symbols.push({name:f,category:"hook",framework:"react",startLine:u,endLine:m,internalKey:this.buildSymbolKey(f,u,m,t),parentComponent:t,camelWords:k(f)});}}if(e.type==="ExpressionStatement"&&e.expression?.type==="CallExpression"){let o=e.expression,a=o.callee;if(a?.type==="Identifier"){let c=a.name;if(Lt.includes(c)){let{start:l,end:p}=s(e),d=o.arguments,u=d?.[1],m=this.extractDepsArray(u),f=this.buildSymbolKey(c,l,p,t),g=`${t}.${c}`;if(r.symbols.push({name:c,category:"effect",framework:"react",startLine:l,endLine:p,internalKey:f,hookDeps:m,parentComponent:t,camelWords:k(c)}),d?.[0]){let h=V(d[0],g,n,true).map(S=>({...S,symbolKey:f}));r.behaviors.push(...h);let b=q(d[0],g,n,true);for(let S of b){let y=r.symbols.findIndex(_=>_.name===c&&_.startLine===l);if(S.args&&y!==-1){let _=String(S.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");r.symbols[y].camelWords+=` ${k(_)} ${_}`;}r.relations.push(W({callerName:g,callerLine:l,callerKey:f,calleeName:S.calleeName,callType:"direct_call",line:S.line,args:S.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=K(n.join(`
429
429
  `),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=V(e.body,o,n,true);r.behaviors.push(...d);let u=q(e.body,o,n,true);for(let m of u){let f=r.symbols.findIndex(g=>g.name===o&&g.startLine===a);if(m.args&&f!==-1){let g=String(m.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");r.symbols[f].camelWords+=` ${k(g)} ${g}`;}r.relations.push(W({callerName:o,callerLine:a,callerKey:this.buildSymbolKey(o,a,c,t),calleeName:m.calleeName,callType:"direct_call",line:m.line,args:m.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],S=this.extractDepsArray(b),{start:y,end:_}=s(e);r.symbols.push({name:l,category:"computed",framework:"react",startLine:y,endLine:_,internalKey:this.buildSymbolKey(l,y,_,t),hookDeps:S,parentComponent:t,camelWords:k(l)});continue}if(!c)continue;let{start:u,end:m}=s(e),f=K(n.join(`
430
- `),u),g=this.extractParams(a);if(r.symbols.push({name:l,category:"method",framework:"react",startLine:u,endLine:m,internalKey:this.buildSymbolKey(l,u,m,t),signature:`${l}(${(g||[]).join(", ")})`,params:g,isAsync:a.async===true,jsdoc:f,parentComponent:t,camelWords:k(l)}),a.body){let h=V(a.body,l,n,true);r.behaviors.push(...h);let b=q(a.body,l,n,true);for(let S of b){let y=r.symbols.findIndex(_=>_.name===l&&_.startLine===u);if(S.args&&y!==-1){let _=String(S.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");r.symbols[y].camelWords+=` ${k(_)} ${_}`;}r.relations.push(W({callerName:l,callerLine:u,callerKey:this.buildSymbolKey(l,u,m,t),calleeName:S.calleeName,callType:"direct_call",line:S.line,args:S.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 wr=createRequire(import.meta.url),ot=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=wr("@babel/parser").parse(t,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy","classProperties"],errorRecovery:!0}),a=t.split(`
430
+ `),u),g=this.extractParams(a);if(r.symbols.push({name:l,category:"method",framework:"react",startLine:u,endLine:m,internalKey:this.buildSymbolKey(l,u,m,t),signature:`${l}(${(g||[]).join(", ")})`,params:g,isAsync:a.async===true,jsdoc:f,parentComponent:t,camelWords:k(l)}),a.body){let h=V(a.body,l,n,true);r.behaviors.push(...h);let b=q(a.body,l,n,true);for(let S of b){let y=r.symbols.findIndex(_=>_.name===l&&_.startLine===u);if(S.args&&y!==-1){let _=String(S.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");r.symbols[y].camelWords+=` ${k(_)} ${_}`;}r.relations.push(W({callerName:l,callerLine:u,callerKey:this.buildSymbolKey(l,u,m,t),calleeName:S.calleeName,callType:"direct_call",line:S.line,args:S.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 vr=createRequire(import.meta.url),ot=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=vr("@babel/parser").parse(t,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy","classProperties"],errorRecovery:!0}),a=t.split(`
431
431
  `),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=st(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:K(n.join(`
432
432
  `),o.startLine),parentComponent:o.ownerClass,camelWords:k(e)});let l=t.body;if(!l)return;let p=V(l,e,n,true);s.behaviors.push(...p);let d=q(l,e,n,true);for(let m of d)s.relations.push(W({callerName:e,callerLine:o.startLine,callerKey:a,calleeName:m.calleeName,callType:"direct_call",line:m.line,args:m.args}));let u=ke(l,e);for(let m of u)s.relations.push(W({callerName:e,callerLine:o.startLine,callerKey:a,calleeName:m.calleeName,callType:"this_method",line:m.line,args:m.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:K(t.join(`
433
- `),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 m=p.value;m&&(m.type==="ArrowFunctionExpression"||m.type==="FunctionExpression")&&(p.type==="ClassProperty"||p.type==="PropertyDefinition")&&this.addFunctionSymbol(u,m,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 Z(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"?Z(i):e.type==="MemberExpression"?e.object?.type==="ThisExpression"?Z(e):ie(e):null:null}function te(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 vr=new Set(["FunctionDeclaration","ArrowFunctionExpression","FunctionExpression","ObjectMethod","ClassMethod","ClassProperty"]);function gn(i,e){return !!e?.skipNestedFunctions&&vr.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;gn(o,t)||me(o,e,t);}continue}if(r&&typeof r=="object"&&r.type){let s=r;if(gn(s,t))continue;me(s,e,t);}}}}function hn(i,e,t=true,n){let r=[],s=[],o=(a,c=120)=>Cr(a,n,c);return me(i,a=>{if(a.type==="VariableDeclarator"){let c=a.id;if(!c)return;let l=at(c),p=o(a);for(let d of l)r.push({symbolName:d,kind:"declaration",line:ve(a),text:p,sourceLayer:te(p,ve(a))});}if(a.type==="AssignmentExpression"){let c=a.left;if(!c)return;let l=o(a),p=ve(a);if(c.type==="Identifier"&&r.push({symbolName:c.name,kind:"assignment",line:p,text:l,sourceLayer:te(l,p)}),c.type==="MemberExpression"&&c.object?.type==="ThisExpression"){let u=Z(c);if(u){r.push({symbolName:u,kind:"assignment",line:p,text:l,sourceLayer:te(l,p)});return}}if(c.type==="MemberExpression"){let d=ie(c);if(d&&Ct(d)){let u=Z(c);s.push({objectName:d,propertyName:u||void 0,line:p,text:l,kind:c.computed?"bracket":"dot",sourceLayer:te(l,p)});}}}if(a.type==="UpdateExpression"){let c=a.argument;if(!c)return;let l=o(a),p=ve(a);if(c.type==="Identifier"&&r.push({symbolName:c.name,kind:"update",line:p,text:l,sourceLayer:te(l,p)}),c.type==="MemberExpression"&&c.object?.type==="ThisExpression"){let u=Z(c);if(u){r.push({symbolName:u,kind:"update",line:p,text:l,sourceLayer:te(l,p)});return}}if(c.type==="MemberExpression"){let d=ie(c);if(d&&Ct(d)){let u=Z(c);s.push({objectName:d,propertyName:u||void 0,line:p,text:l,kind:c.computed?"bracket":"dot",sourceLayer:te(l,p)});}}}if(a.type==="UnaryExpression"&&a.operator==="delete"){let c=a.argument;if(c?.type==="MemberExpression"){let l=ie(c);if(l&&Ct(l)){let p=Z(c);s.push({objectName:l,propertyName:p||void 0,line:ve(a),text:o(a),kind:"delete",sourceLayer:te(o(a),ve(a))});}}}},{skipNestedFunctions:t}),{assignments:r,propertyWrites:s}}function at(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?at(n):[]}):i.type==="ArrayPattern"?(i.elements||[]).flatMap(t=>t?at(t):[]):i.type==="AssignmentPattern"?at(i.left):[]}function Ct(i){return !(/^[A-Z][A-Z]/.test(i)||/^(document|window|console|localStorage|sessionStorage|navigator|process|global|globalThis)$/.test(i))}function ve(i){return i.loc?.start?.line??1}function Cr(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 $r=createRequire(import.meta.url);function $t(i,e){let t={files:new Map,resolutionCache:new Map,localShadowCache:new Map};for(let{path:n,content:r}of i){let s=fn(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,Pr(r));}return t}function Pt(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 Pr(i){let e=new Map;try{let n=$r("@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)bn(s,e);}catch{return e}return e}function bn(i,e){if(i.type==="FunctionDeclaration"){let t=Se(i.id);if(!t)return;Ce(t,i,e),Or(Mr(i),t,e);return}if(i.type==="VariableDeclaration"){En(i,void 0,e);return}if(i.type==="ClassDeclaration"){Fr(i,e);return}if(i.type==="ExportNamedDeclaration"||i.type==="ExportDefaultDeclaration"){let t=i.declaration;if(!t)return;bn(t,e);}}function Or(i,e,t){for(let n of i){if(n.type==="FunctionDeclaration"){let r=Se(n.id);if(!r)continue;Ce(r,n,t,e);continue}if(n.type==="VariableDeclaration"){En(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;Ce(o,a,t,e,n);}}}function En(i,e,t){for(let n of i.declarations||[]){let r=Se(n.id),s=n.init;!r||!s||s.type!=="ArrowFunctionExpression"&&s.type!=="FunctionExpression"||Ce(r,s,t,e,n);}}function Fr(i,e){let t=Se(i.id);if(!t)return;let n=i.body?.body||[];for(let r of n){let s=Se(r.key);if(!s||s==="constructor")continue;if(r.type==="ClassMethod"||r.type==="ClassPrivateMethod"){Ce(s,r,e,t);continue}let o=r.value;o&&(o.type==="ArrowFunctionExpression"||o.type==="FunctionExpression")&&(r.type==="ClassProperty"||r.type==="PropertyDefinition")&&Ce(s,o,e,t,r);}}function Ce(i,e,t,n,r){let s=jr(r||e),o=Ur(i,s.start,s.end,n),a=Dr(e);t.set(o,a);}function Dr(i){let e=new Set;for(let n of i.params||[])for(let r of Te(n))e.add(r);let t=i.body;return t&&It(t,n=>{if(n.type==="VariableDeclarator"){for(let r of Te(n.id))e.add(r);return}if(n.type==="FunctionDeclaration"){let r=Se(n.id);return r&&e.add(r),false}if(n.type==="ClassDeclaration"){let r=Se(n.id);return r&&e.add(r),false}}),e}function It(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;yn(s)||It(s,e);}continue}if(n&&typeof n=="object"&&n.type){let r=n;if(yn(r))continue;It(r,e);}}}function yn(i){return ["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression","ClassMethod","ClassPrivateMethod","ObjectMethod"].includes(String(i.type||""))}function Te(i){return i?i.type==="Identifier"?[String(i.name||"")]:i.type==="AssignmentPattern"?Te(i.left):i.type==="RestElement"?Te(i.argument):i.type==="ArrayPattern"?(i.elements||[]).flatMap(e=>Te(e)):i.type==="ObjectPattern"?(i.properties||[]).flatMap(e=>{if(e.type==="RestElement")return Te(e.argument);let t=e.value||e.argument;return Te(t)}):[]:[]}function Se(i){if(i&&i.type==="Identifier")return String(i.name||"")}function Mr(i){let e=i.body;return !e||e.type!=="BlockStatement"?[]:e.body||[]}function jr(i){let e=i.loc;return {start:e?.start?.line??1,end:e?.end?.line??1}}function Ur(i,e,t,n){return n?`${n}:${i}:${e}:${t}`:`root:${i}:${e}:${t}`}var _n=createRequire(import.meta.url);function Nn(i,e){let t=i.errors||[];t.includes(e)||(i.errors=[...t,e]);}var Ot=class extends We{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}},Hr=[new it,new we,new We,new ot,new Ot];function He(i,e){for(let t of Hr)if(t.canParse(i,e)){let n=t.parse(i,e);return Xr(n),Br(n,e),n}return {framework:"js",filePath:i,symbols:[],relations:[],behaviors:[],errors:[`\u6CA1\u6709\u627E\u5230\u9002\u5408\u7684\u89E3\u6790\u5668: ${i}`]}}function Br(i,e){if(i.symbols.length!==0)try{let t=e,n=i.filePath.endsWith(".vue"),r=0;if(n)try{let{parse:u}=_n("@vue/compiler-sfc"),{descriptor:m}=u(e);if(m.scriptSetup?.content)t=m.scriptSetup.content,r=m.scriptSetup.loc.start.line-1;else if(m.script?.content)t=m.script.content,r=m.script.loc.start.line-1;else return}catch(u){Nn(i,`\u751F\u547D\u5468\u671F\u63D0\u53D6\u8DF3\u8FC7: Vue SFC \u89E3\u6790\u5931\u8D25 - ${String(u)}`);return}let a=_n("@babel/parser").parse(t,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy"],errorRecovery:!0}).program.body;if(!a?.length)return;let c=t.split(`
434
- `),{assignments:l,propertyWrites:p}=hn({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){Nn(i,`\u751F\u547D\u5468\u671F\u63D0\u53D6\u8DF3\u8FC7: AST \u89E3\u6790\u5931\u8D25 - ${String(t)}`);}}function Xr(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 Be(i,e){let t=Kr(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?Tn(n.join(`
435
- `)):"",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?Tn(s.join(`
436
- `)):"";return {contentHash:t,exportSignatureHash:r,importSignatureHash:o}}function xn(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 An(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 Kr(i){return createHash("sha256").update(i,"utf-8").digest("hex").slice(0,16)}function Tn(i){return createHash("sha256").update(i,"utf-8").digest("hex").slice(0,12)}var Vr={maxFiles:20,maxTimeMs:1500},ct=class{pending=[];options;constructor(e){this.options={...Vr,...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 lt=class{projectRoot;db;scheduler;constructor(e,t){this.projectRoot=e,this.db=t,this.scheduler=new ct;}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=$t(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=Pt(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}
437
- `);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||[...Nt],r=e?.exclude||[..._t],s=e?.force||false,o=Date.now(),a=await zr(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:[]};s&&(this.scheduler.clear(),this.db.clearProjectIndex());let p=0,d=0,u=0;if((e?.precisionMode||"heuristic")==="precise"){let f=[];for(let g=0;g<a.length;g++){let h=a[g],b=de(h,this.projectRoot);e?.onProgress?.(g+1,a.length,b);try{let S=Q__default.statSync(h).mtimeMs,y=Date.now(),_=Q__default.readFileSync(h,"utf-8"),E=Date.now()-y,A=Date.now(),N=He(h,_),x=Date.now()-A;p+=E,d+=x,f.push({absPath:h,relPath:b,result:N,parseMs:x,readMs:E,content:_,mtime:S});}catch(S){this.db.recordIndexFailure(b,String(S)),l.errors.push({file:b,error:String(S)});}}this.enhancePreciseRelations(f);for(let g of f){let h=Date.now();try{let b=Me(g.content),S=qe(g.content),y=Buffer.byteLength(g.content,"utf-8"),_=Be(g.result,g.content);this.db.saveParseResult(g.result,g.absPath,g.relPath,b,y,S,g.mtime,_.exportSignatureHash,_.importSignatureHash),l.indexedFiles++,l.totalSymbols+=g.result.symbols.length,g.result.errors?.length&&l.errors.push(...g.result.errors.map(E=>({file:g.relPath,error:E}))),u+=Date.now()-h;}catch(b){this.db.recordIndexFailure(g.relPath,String(b)),l.errors.push({file:g.relPath,error:String(b)});}}}else for(let f=0;f<a.length;f++){let g=a[f],h=de(g,this.projectRoot);e?.onProgress?.(f+1,a.length,h);try{let b=await this.indexFile(g,h,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(S=>({file:h,error:S}))));}catch(b){this.db.recordIndexFailure(h,String(b)),l.errors.push({file:h,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 h of s){let b=this.fileAbsPath(h);if(!Q__default.existsSync(b))continue;let S=this.db.getFileSignatures(h);if(!S){this.scheduler.enqueue(h,"low");continue}let y;try{y=Q__default.statSync(b);let P=this.db.getFileHashAndMtime(h);if(P&&P.mtime===y.mtimeMs&&P.contentHash)continue}catch{continue}let _=Q__default.readFileSync(b,"utf-8"),E=Me(_);if(S.contentHash===E){this.db.updateFileMtime(h,y.mtimeMs);continue}let A=He(b,_),N=Be(A,_),x=xn(S,N);if(x==="unchanged")continue;let{files:L,truncated:w}=An(h,x,o);w&&process.stderr.write(`[Frontend-Code-Skimmer] \u26A0\uFE0F ${h} \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
+ `),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 m=p.value;m&&(m.type==="ArrowFunctionExpression"||m.type==="FunctionExpression")&&(p.type==="ClassProperty"||p.type==="PropertyDefinition")&&this.addFunctionSymbol(u,m,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 Z(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"?Z(i):e.type==="MemberExpression"?e.object?.type==="ThisExpression"?Z(e):ie(e):null:null}function te(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 Cr=new Set(["FunctionDeclaration","ArrowFunctionExpression","FunctionExpression","ObjectMethod","ClassMethod","ClassProperty"]);function mn(i,e){return !!e?.skipNestedFunctions&&Cr.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;mn(o,t)||me(o,e,t);}continue}if(r&&typeof r=="object"&&r.type){let s=r;if(mn(s,t))continue;me(s,e,t);}}}}function gn(i,e,t=true,n){let r=[],s=[],o=(a,c=120)=>Ir(a,n,c);return me(i,a=>{if(a.type==="VariableDeclarator"){let c=a.id;if(!c)return;let l=at(c),p=o(a);for(let d of l)r.push({symbolName:d,kind:"declaration",line:ve(a),text:p,sourceLayer:te(p,ve(a))});}if(a.type==="AssignmentExpression"){let c=a.left;if(!c)return;let l=o(a),p=ve(a);if(c.type==="Identifier"&&r.push({symbolName:c.name,kind:"assignment",line:p,text:l,sourceLayer:te(l,p)}),c.type==="MemberExpression"&&c.object?.type==="ThisExpression"){let u=Z(c);if(u){r.push({symbolName:u,kind:"assignment",line:p,text:l,sourceLayer:te(l,p)});return}}if(c.type==="MemberExpression"){let d=ie(c);if(d&&Ct(d)){let u=Z(c);s.push({objectName:d,propertyName:u||void 0,line:p,text:l,kind:c.computed?"bracket":"dot",sourceLayer:te(l,p)});}}}if(a.type==="UpdateExpression"){let c=a.argument;if(!c)return;let l=o(a),p=ve(a);if(c.type==="Identifier"&&r.push({symbolName:c.name,kind:"update",line:p,text:l,sourceLayer:te(l,p)}),c.type==="MemberExpression"&&c.object?.type==="ThisExpression"){let u=Z(c);if(u){r.push({symbolName:u,kind:"update",line:p,text:l,sourceLayer:te(l,p)});return}}if(c.type==="MemberExpression"){let d=ie(c);if(d&&Ct(d)){let u=Z(c);s.push({objectName:d,propertyName:u||void 0,line:p,text:l,kind:c.computed?"bracket":"dot",sourceLayer:te(l,p)});}}}if(a.type==="UnaryExpression"&&a.operator==="delete"){let c=a.argument;if(c?.type==="MemberExpression"){let l=ie(c);if(l&&Ct(l)){let p=Z(c);s.push({objectName:l,propertyName:p||void 0,line:ve(a),text:o(a),kind:"delete",sourceLayer:te(o(a),ve(a))});}}}},{skipNestedFunctions:t}),{assignments:r,propertyWrites:s}}function at(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?at(n):[]}):i.type==="ArrayPattern"?(i.elements||[]).flatMap(t=>t?at(t):[]):i.type==="AssignmentPattern"?at(i.left):[]}function Ct(i){return !(/^[A-Z][A-Z]/.test(i)||/^(document|window|console|localStorage|sessionStorage|navigator|process|global|globalThis)$/.test(i))}function ve(i){return i.loc?.start?.line??1}function Ir(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 Pr=createRequire(import.meta.url);function $t(i,e){let t={files:new Map,resolutionCache:new Map,localShadowCache:new Map};for(let{path:n,content:r}of i){let s=un(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,Or(r));}return t}function Pt(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 Or(i){let e=new Map;try{let n=Pr("@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)yn(s,e);}catch{return e}return e}function yn(i,e){if(i.type==="FunctionDeclaration"){let t=Se(i.id);if(!t)return;Ce(t,i,e),Fr(jr(i),t,e);return}if(i.type==="VariableDeclaration"){bn(i,void 0,e);return}if(i.type==="ClassDeclaration"){Dr(i,e);return}if(i.type==="ExportNamedDeclaration"||i.type==="ExportDefaultDeclaration"){let t=i.declaration;if(!t)return;yn(t,e);}}function Fr(i,e,t){for(let n of i){if(n.type==="FunctionDeclaration"){let r=Se(n.id);if(!r)continue;Ce(r,n,t,e);continue}if(n.type==="VariableDeclaration"){bn(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;Ce(o,a,t,e,n);}}}function bn(i,e,t){for(let n of i.declarations||[]){let r=Se(n.id),s=n.init;!r||!s||s.type!=="ArrowFunctionExpression"&&s.type!=="FunctionExpression"||Ce(r,s,t,e,n);}}function Dr(i,e){let t=Se(i.id);if(!t)return;let n=i.body?.body||[];for(let r of n){let s=Se(r.key);if(!s||s==="constructor")continue;if(r.type==="ClassMethod"||r.type==="ClassPrivateMethod"){Ce(s,r,e,t);continue}let o=r.value;o&&(o.type==="ArrowFunctionExpression"||o.type==="FunctionExpression")&&(r.type==="ClassProperty"||r.type==="PropertyDefinition")&&Ce(s,o,e,t,r);}}function Ce(i,e,t,n,r){let s=Ur(r||e),o=Wr(i,s.start,s.end,n),a=Mr(e);t.set(o,a);}function Mr(i){let e=new Set;for(let n of i.params||[])for(let r of Te(n))e.add(r);let t=i.body;return t&&It(t,n=>{if(n.type==="VariableDeclarator"){for(let r of Te(n.id))e.add(r);return}if(n.type==="FunctionDeclaration"){let r=Se(n.id);return r&&e.add(r),false}if(n.type==="ClassDeclaration"){let r=Se(n.id);return r&&e.add(r),false}}),e}function It(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;hn(s)||It(s,e);}continue}if(n&&typeof n=="object"&&n.type){let r=n;if(hn(r))continue;It(r,e);}}}function hn(i){return ["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression","ClassMethod","ClassPrivateMethod","ObjectMethod"].includes(String(i.type||""))}function Te(i){return i?i.type==="Identifier"?[String(i.name||"")]:i.type==="AssignmentPattern"?Te(i.left):i.type==="RestElement"?Te(i.argument):i.type==="ArrayPattern"?(i.elements||[]).flatMap(e=>Te(e)):i.type==="ObjectPattern"?(i.properties||[]).flatMap(e=>{if(e.type==="RestElement")return Te(e.argument);let t=e.value||e.argument;return Te(t)}):[]:[]}function Se(i){if(i&&i.type==="Identifier")return String(i.name||"")}function jr(i){let e=i.body;return !e||e.type!=="BlockStatement"?[]:e.body||[]}function Ur(i){let e=i.loc;return {start:e?.start?.line??1,end:e?.end?.line??1}}function Wr(i,e,t,n){return n?`${n}:${i}:${e}:${t}`:`root:${i}:${e}:${t}`}var En=createRequire(import.meta.url);function _n(i,e){let t=i.errors||[];t.includes(e)||(i.errors=[...t,e]);}var Ot=class extends We{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}},Br=[new it,new we,new We,new ot,new Ot];function He(i,e){for(let t of Br)if(t.canParse(i,e)){let n=t.parse(i,e);return Kr(n),Xr(n,e),n}return {framework:"js",filePath:i,symbols:[],relations:[],behaviors:[],errors:[`\u6CA1\u6709\u627E\u5230\u9002\u5408\u7684\u89E3\u6790\u5668: ${i}`]}}function Xr(i,e){if(i.symbols.length!==0)try{let t=e,n=i.filePath.endsWith(".vue"),r=0;if(n)try{let{parse:u}=En("@vue/compiler-sfc"),{descriptor:m}=u(e);if(m.scriptSetup?.content)t=m.scriptSetup.content,r=m.scriptSetup.loc.start.line-1;else if(m.script?.content)t=m.script.content,r=m.script.loc.start.line-1;else return}catch(u){_n(i,`\u751F\u547D\u5468\u671F\u63D0\u53D6\u8DF3\u8FC7: Vue SFC \u89E3\u6790\u5931\u8D25 - ${String(u)}`);return}let a=En("@babel/parser").parse(t,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy"],errorRecovery:!0}).program.body;if(!a?.length)return;let c=t.split(`
434
+ `),{assignments:l,propertyWrites:p}=gn({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){_n(i,`\u751F\u547D\u5468\u671F\u63D0\u53D6\u8DF3\u8FC7: AST \u89E3\u6790\u5931\u8D25 - ${String(t)}`);}}function Kr(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 Be(i,e){let t=Vr(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?Nn(n.join(`
435
+ `)):"",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?Nn(s.join(`
436
+ `)):"";return {contentHash:t,exportSignatureHash:r,importSignatureHash:o}}function Sn(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 xn(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 Vr(i){return createHash("sha256").update(i,"utf-8").digest("hex").slice(0,16)}function Nn(i){return createHash("sha256").update(i,"utf-8").digest("hex").slice(0,12)}var zr={maxFiles:20,maxTimeMs:1500},ct=class{pending=[];options;constructor(e){this.options={...zr,...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 lt=class{projectRoot;db;scheduler;constructor(e,t){this.projectRoot=e,this.db=t,this.scheduler=new ct;}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=$t(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=Pt(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}
437
+ `);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||[...Nt],r=e?.exclude||[..._t],s=e?.force||false,o=Date.now(),a=await Gr(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:[]};s&&(this.scheduler.clear(),this.db.clearProjectIndex());let p=0,d=0,u=0;if((e?.precisionMode||"heuristic")==="precise"){let f=[];for(let g=0;g<a.length;g++){let h=a[g],b=de(h,this.projectRoot);e?.onProgress?.(g+1,a.length,b);try{let S=Q__default.statSync(h).mtimeMs,y=Date.now(),_=Q__default.readFileSync(h,"utf-8"),E=Date.now()-y,A=Date.now(),N=He(h,_),x=Date.now()-A;p+=E,d+=x,f.push({absPath:h,relPath:b,result:N,parseMs:x,readMs:E,content:_,mtime:S});}catch(S){this.db.recordIndexFailure(b,String(S)),l.errors.push({file:b,error:String(S)});}}this.enhancePreciseRelations(f);for(let g of f){let h=Date.now();try{let b=Me(g.content),S=qe(g.content),y=Buffer.byteLength(g.content,"utf-8"),_=Be(g.result,g.content);this.db.saveParseResult(g.result,g.absPath,g.relPath,b,y,S,g.mtime,_.exportSignatureHash,_.importSignatureHash),l.indexedFiles++,l.totalSymbols+=g.result.symbols.length,g.result.errors?.length&&l.errors.push(...g.result.errors.map(E=>({file:g.relPath,error:E}))),u+=Date.now()-h;}catch(b){this.db.recordIndexFailure(g.relPath,String(b)),l.errors.push({file:g.relPath,error:String(b)});}}}else for(let f=0;f<a.length;f++){let g=a[f],h=de(g,this.projectRoot);e?.onProgress?.(f+1,a.length,h);try{let b=await this.indexFile(g,h,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(S=>({file:h,error:S}))));}catch(b){this.db.recordIndexFailure(h,String(b)),l.errors.push({file:h,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 h of s){let b=this.fileAbsPath(h);if(!Q__default.existsSync(b))continue;let S=this.db.getFileSignatures(h);if(!S){this.scheduler.enqueue(h,"low");continue}let y;try{y=Q__default.statSync(b);let P=this.db.getFileHashAndMtime(h);if(P&&P.mtime===y.mtimeMs&&P.contentHash)continue}catch{continue}let _=Q__default.readFileSync(b,"utf-8"),E=Me(_);if(S.contentHash===E){this.db.updateFileMtime(h,y.mtimeMs);continue}let A=He(b,_),N=Be(A,_),x=Sn(S,N);if(x==="unchanged")continue;let{files:L,truncated:w}=xn(h,x,o);w&&process.stderr.write(`[Frontend-Code-Skimmer] \u26A0\uFE0F ${h} \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
438
438
  `);for(let P of L)a.add(P);let M=x==="export_changed"||x==="full_changed"?"high":x==="import_changed"?"normal":"low";for(let P of L)this.scheduler.enqueue(P,M);}let{tasks:c,exceededBudget:l,remainingPending:p}=this.scheduler.dequeueBatch(),d=[],u=[],m=0;for(let h=0;h<c.length;h++){let S=c[h].relPath;if(a.add(S),Date.now()-t>=r){u.push(...c.slice(h));break}let y=this.fileAbsPath(S);if(!Q__default.existsSync(y)){this.removeFile(S);continue}try{let _=Q__default.readFileSync(y,"utf-8"),E=He(y,_),A=Me(_),N=qe(_),x=Buffer.byteLength(_,"utf-8");d.push({absPath:y,relPath:S,result:E,content:_,hash:A,lineCount:N,fileSize:x,mtime:Q__default.statSync(y).mtimeMs});}catch(_){this.db.recordIndexFailure(S,String(_)),process.stderr.write(`[Frontend-Code-Skimmer] Selective precise \u5931\u8D25: ${S} - ${String(_)}
439
439
  `);}}u.length>0&&this.scheduler.requeue(u),this.enhancePreciseRelations(d);for(let h of d)try{let b=Be(h.result,h.content);this.db.saveParseResult(h.result,h.absPath,h.relPath,h.hash,h.fileSize,h.lineCount,h.mtime,b.exportSignatureHash,b.importSignatureHash),m++;}catch(b){this.db.recordIndexFailure(h.relPath,String(b)),process.stderr.write(`[Frontend-Code-Skimmer] Selective precise \u843D\u5E93\u5931\u8D25: ${h.relPath} - ${String(b)}
440
440
  `);}let f=Date.now()-t,g=p+u.length;return process.stderr.write(`[Frontend-Code-Skimmer] Selective precise: ${m}/${a.size} affected, ${f}ms, pending: ${g}${l||u.length>0?" (budget limited)":""}
441
- `),{reindexedFiles:m,affectedFiles:Array.from(a),skippedByBudget:g}}async indexFile(e,t,n=false){let r=0,s=0,o=null;if(!n){try{let y=Q__default.statSync(e);r=y.mtimeMs,s=y.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=Q__default.readFileSync(e,"utf-8"),l=Date.now()-a,p=Me(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=qe(c),u=Buffer.byteLength(c,"utf-8"),m=Date.now(),f=He(e,c),g=Date.now()-m,h=Be(f,c),b=Date.now();this.db.clearIndexFailures(t),this.db.saveParseResult(f,e,t,p,u,d,r,h.exportSignatureHash,h.importSignatureHash);let S=Date.now()-b;return {skipped:false,symbolCount:f.symbols.length,readMs:l,parseMs:g,saveMs:S,errors:f.errors}}removeFile(e){this.db.deleteFile(e);}fileAbsPath(e){return z__default.join(this.projectRoot,e)}async startWatcher(){let{default:e}=await import('chokidar'),t=e.watch([...Nt].map(r=>z__default.posix.join(this.projectRoot,r)),{cwd:this.projectRoot,ignored:[..._t],persistent:true,ignoreInitial:true,awaitWriteFinish:{stabilityThreshold:an}}),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}
441
+ `),{reindexedFiles:m,affectedFiles:Array.from(a),skippedByBudget:g}}async indexFile(e,t,n=false){let r=0,s=0,o=null;if(!n){try{let y=Q__default.statSync(e);r=y.mtimeMs,s=y.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=Q__default.readFileSync(e,"utf-8"),l=Date.now()-a,p=Me(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=qe(c),u=Buffer.byteLength(c,"utf-8"),m=Date.now(),f=He(e,c),g=Date.now()-m,h=Be(f,c),b=Date.now();this.db.clearIndexFailures(t),this.db.saveParseResult(f,e,t,p,u,d,r,h.exportSignatureHash,h.importSignatureHash);let S=Date.now()-b;return {skipped:false,symbolCount:f.symbols.length,readMs:l,parseMs:g,saveMs:S,errors:f.errors}}removeFile(e){this.db.deleteFile(e);}fileAbsPath(e){return z__default.join(this.projectRoot,e)}async startWatcher(){let{default:e}=await import('chokidar'),t=e.watch([...Nt].map(r=>z__default.posix.join(this.projectRoot,r)),{cwd:this.projectRoot,ignored:[..._t],persistent:true,ignoreInitial:true,awaitWriteFinish:{stabilityThreshold:on}}),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}
442
442
  `);}catch(o){process.stderr.write(`[Frontend-Code-Skimmer] \u66F4\u65B0\u5931\u8D25: ${s} - ${String(o)}
443
443
  `);}};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}
444
- `);}),()=>t.close()}};var Jr=8,Yr=30,Zr=14,Qr=360*60*1e3,pt=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=z__default.join(Gr.homedir(),".frontend-code-skimmer","databases"),Q__default.mkdirSync(this.globalCacheDir,{recursive:true}),this.defaultProject=process.env.SKIMMER_PROJECT||null,this.defaultProject&&(this.defaultProject=z__default.resolve(this.defaultProject)),this.maxOpenProjects=this.parsePositiveInt(process.env.SKIMMER_MAX_OPEN_PROJECTS,Jr);let e=this.parsePositiveInt(process.env.SKIMMER_DB_IDLE_MINUTES,Yr),t=this.parsePositiveInt(process.env.SKIMMER_DB_TTL_DAYS,Zr);this.maxIdleMs=e*60*1e3,this.dbTtlMs=t*24*60*60*1e3,this.maybeCleanupDiskCache(Date.now());}resolveProjectRoot(e){if(e){let t=z__default.resolve(e);if(!Q__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=z__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 Ye(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}
444
+ `);}),()=>t.close()}};var Yr=8,Zr=30,Qr=14,es=360*60*1e3,pt=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=z__default.join(qr.homedir(),".frontend-code-skimmer","databases"),Q__default.mkdirSync(this.globalCacheDir,{recursive:true}),this.defaultProject=process.env.SKIMMER_PROJECT||null,this.defaultProject&&(this.defaultProject=z__default.resolve(this.defaultProject)),this.maxOpenProjects=this.parsePositiveInt(process.env.SKIMMER_MAX_OPEN_PROJECTS,Yr);let e=this.parsePositiveInt(process.env.SKIMMER_DB_IDLE_MINUTES,Zr),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=z__default.resolve(e);if(!Q__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=z__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 Ye(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}
445
445
  `),process.stderr.write(`[Frontend-Code-Skimmer] \u6570\u636E\u5E93: ${r}
446
- `),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=z__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 lt(n,s);return this.indexerCache.set(n,o),this.touchProject(n,r),this.lastProject=n,o}setLastProject(e){this.lastProject=z__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=z__default.resolve(e),r=this.watcherCleanups.get(n);if(r)try{r();}catch{}this.watcherCleanups.set(n,t);}hasWatcher(e){let t=z__default.resolve(e);return this.watcherCleanups.has(t)}closeProject(e){let t=z__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 z__default.resolve(process.env.SKIMMER_DB);let t=z__default.join(e,".agent","skimmer_find_symbol"),n=z__default.join(t,Je);try{return Q__default.mkdirSync(t,{recursive:!0}),Q__default.accessSync(e,Q__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 z__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<Qr)return;this.lastDiskCleanupAt=e;let t=[];try{t=Q__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(z__default.resolve(s));let r=e-this.dbTtlMs;for(let s of t){if(!s.isFile()||!s.name.endsWith(".db"))continue;let o=z__default.join(this.globalCacheDir,s.name);if(n.has(z__default.resolve(o)))continue;let a;try{a=Q__default.statSync(o);}catch{continue}a.mtimeMs>=r||(this.safeUnlink(o),this.safeUnlink(`${o}-wal`),this.safeUnlink(`${o}-shm`));}}safeUnlink(e){try{Q__default.existsSync(e)&&Q__default.unlinkSync(e);}catch{}}};var dt=createRequire(import.meta.url);function Rn(i,e){let t=[];if(i==="heuristic")return {effective:"heuristic",warnings:t};let n=dt("fs"),r=dt("path");if(!ts(e,n,r))return t.push("precise \u6A21\u5F0F\u964D\u7EA7\u4E3A heuristic: \u9879\u76EE\u5185\u672A\u627E\u5230 tsconfig\uFF08\u5DF2\u68C0\u67E5\u6839\u76EE\u5F55\u53CA\u6700\u591A 3 \u5C42\u5B50\u76EE\u5F55\uFF09"),{effective:"heuristic",warnings:t};try{dt.resolve("typescript",{paths:[e]});}catch{try{dt.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 ts(i,e,t){let n=["tsconfig.json","tsconfig.base.json","tsconfig.app.json","tsconfig.lib.json","tsconfig.node.json"],r=new Set([".git","node_modules","dist","build","coverage",".next",".nuxt"]),s=[{dir:i,depth:0}];for(;s.length>0;){let o=s.shift();if(!o)break;for(let c of n){let l=t.join(o.dir,c);if(e.existsSync(l))return l}if(o.depth>=3)continue;let a;try{a=e.readdirSync(o.dir,{withFileTypes:!0});}catch{continue}for(let c of a)c.isDirectory()&&(r.has(c.name)||s.push({dir:t.join(o.dir,c.name),depth:o.depth+1}));}return null}function kn(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
446
+ `),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=z__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 lt(n,s);return this.indexerCache.set(n,o),this.touchProject(n,r),this.lastProject=n,o}setLastProject(e){this.lastProject=z__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=z__default.resolve(e),r=this.watcherCleanups.get(n);if(r)try{r();}catch{}this.watcherCleanups.set(n,t);}hasWatcher(e){let t=z__default.resolve(e);return this.watcherCleanups.has(t)}closeProject(e){let t=z__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 z__default.resolve(process.env.SKIMMER_DB);let t=z__default.join(e,".agent","skimmer_find_symbol"),n=z__default.join(t,Je);try{return Q__default.mkdirSync(t,{recursive:!0}),Q__default.accessSync(e,Q__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 z__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<es)return;this.lastDiskCleanupAt=e;let t=[];try{t=Q__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(z__default.resolve(s));let r=e-this.dbTtlMs;for(let s of t){if(!s.isFile()||!s.name.endsWith(".db"))continue;let o=z__default.join(this.globalCacheDir,s.name);if(n.has(z__default.resolve(o)))continue;let a;try{a=Q__default.statSync(o);}catch{continue}a.mtimeMs>=r||(this.safeUnlink(o),this.safeUnlink(`${o}-wal`),this.safeUnlink(`${o}-shm`));}}safeUnlink(e){try{Q__default.existsSync(e)&&Q__default.unlinkSync(e);}catch{}}};var dt=createRequire(import.meta.url);function Ln(i,e){let t=[];if(i==="heuristic")return {effective:"heuristic",warnings:t};let n=dt("fs"),r=dt("path");if(!ns(e,n,r))return t.push("precise \u6A21\u5F0F\u964D\u7EA7\u4E3A heuristic: \u9879\u76EE\u5185\u672A\u627E\u5230 tsconfig\uFF08\u5DF2\u68C0\u67E5\u6839\u76EE\u5F55\u53CA\u6700\u591A 3 \u5C42\u5B50\u76EE\u5F55\uFF09"),{effective:"heuristic",warnings:t};try{dt.resolve("typescript",{paths:[e]});}catch{try{dt.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 ns(i,e,t){let n=["tsconfig.json","tsconfig.base.json","tsconfig.app.json","tsconfig.lib.json","tsconfig.node.json"],r=new Set([".git","node_modules","dist","build","coverage",".next",".nuxt"]),s=[{dir:i,depth:0}];for(;s.length>0;){let o=s.shift();if(!o)break;for(let c of n){let l=t.join(o.dir,c);if(e.existsSync(l))return l}if(o.depth>=3)continue;let a;try{a=e.readdirSync(o.dir,{withFileTypes:!0});}catch{continue}for(let c of a)c.isDirectory()&&(r.has(c.name)||s.push({dir:t.join(o.dir,c.name),depth:o.depth+1}));}return null}function Rn(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
447
447
  \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
448
448
  \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
449
449
  \u591A\u4E2A\u9879\u76EE\u4F1A\u5E76\u884C\u7F13\u5B58\uFF0C\u5207\u6362\u65E0\u9700\u91CD\u542F\u3002
@@ -454,14 +454,14 @@ import*as Q from'fs';import Q__default from'fs';import*as z from'path';import z_
454
454
  - \u5F3A\u5236\u5168\u91CF\u91CD\u5EFA: force=true
455
455
  - \u7CBE\u786E\u7CBE\u5EA6\u6A21\u5F0F: precision_mode="precise"\uFF08\u57FA\u4E8E TypeScript Compiler API \u505A\u8DE8\u6587\u4EF6 import/export \u7ED1\u5B9A\uFF09
456
456
 
457
- \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\u9879\u76EE\u5185\u5B58\u5728 tsconfig)"),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}=Rn(p,l),m=e.getIndexer(l),f=await m.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}
457
+ \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\u9879\u76EE\u5185\u5B58\u5728 tsconfig)"),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}=Ln(p,l),m=e.getIndexer(l),f=await m.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}
458
458
  `);}});e.setLastProject(l);let g=0;try{let w=Date.now(),M=await m.startWatcher();g=Date.now()-w,e.registerWatcher(l,M),process.stderr.write(`[Frontend-Code-Skimmer] \u6587\u4EF6\u76D1\u542C\u5DF2\u542F\u52A8: ${l}
459
459
  `);}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)}
460
460
  `);}let h=null;if(a)try{let w=await m.selectivePrecise({maxFiles:c||20});h={reindexedFiles:w.reindexedFiles,affectedFiles:w.affectedFiles.length,skippedByBudget:w.skippedByBudget};}catch(w){process.stderr.write(`[Frontend-Code-Skimmer] Selective precise \u5931\u8D25: ${String(w)}
461
461
  `);}let b=f.indexedFiles>0||f.totalFiles>0,S=f.totalSymbols>0,y=b?"\u2705 \u53EF\u7528":"\u274C \u65E0\u53EF\u67E5\u8BE2\u6587\u4EF6",_=S?"\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",E=b?"\u2705 \u53EF\u7528":"\u274C \u65E0\u53EF\u67E5\u8BE2\u6587\u4EF6",A=b?"\u2705 \u53EF\u7528\uFF08\u57FA\u4E8E\u6B63\u5219\u626B\u63CF\u6587\u4EF6\uFF09":"\u274C \u65E0\u53EF\u67E5\u8BE2\u6587\u4EF6",N=f.phaseTimings,x=N?["","\u23F1\uFE0F \u3010\u9636\u6BB5\u8017\u65F6\u3011",` \u{1F50D} \u6587\u4EF6\u53D1\u73B0: ${N.discoverFilesMs}ms`,` \u{1F4D6} \u6587\u4EF6\u8BFB\u53D6: ${N.readFilesMs}ms`,` \u{1F52C} \u89E3\u6790: ${N.parseMs}ms`,` \u{1F4BE} \u6570\u636E\u5E93\u5199\u5165: ${N.saveToDbMs}ms`,` \u{1F4CA} \u603B\u8BA1: ${N.totalMs}ms`,` \u{1F4E1} \u6587\u4EF6\u76D1\u542C: ${g}ms`]:[],L=[`\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: ${f.totalFiles}`,` \u{1F504} \u5DF2\u7D22\u5F15: ${f.indexedFiles}`,` \u23E9 \u5DF2\u8DF3\u8FC7: ${f.skippedFiles} (\u5185\u5BB9\u672A\u53D8)`,` \u{1F523} \u603B\u7B26\u53F7\u6570: ${f.totalSymbols}`,` \u{1F3AF} \u7CBE\u5EA6\u6A21\u5F0F: ${d}`,` \u23F1\uFE0F \u8017\u65F6: ${f.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 ${_}`,` skimmer_get_component_outline ${_}`,` skimmer_find_by_behavior ${E}`,` skimmer_trace_data_lifecycle ${A}`,` skimmer_trace_assignments ${A}`,` skimmer_get_code_slice ${y}`," 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(f.errors.length>0){L.push(`
462
462
  \u26A0\uFE0F \u89E3\u6790\u5931\u8D25 (${f.errors.length} \u4E2A):`);for(let w of f.errors.slice(0,5))L.push(` - ${w.file}: ${w.error}`);f.errors.length>5&&L.push(` ... \u8FD8\u6709 ${f.errors.length-5} \u4E2A`);}if(u.length>0){L.push(""),L.push("\u26A0\uFE0F \u7CBE\u5EA6\u964D\u7EA7:");for(let w of u)L.push(` - ${w}`);}if(h){L.push(""),L.push("\u{1F3AF} \u9009\u62E9\u6027 Precise \u91CD\u7B97:"),L.push(` \u{1F4CA} \u91CD\u7B97\u6587\u4EF6: ${h.reindexedFiles}`),L.push(` \u{1F517} \u5F71\u54CD\u6587\u4EF6: ${h.affectedFiles} (\u5019\u9009\u6570)`),h.skippedByBudget>0&&(L.push(` \u23F8\uFE0F \u8D85\u9884\u7B97\u8DF3\u8FC7\u7684\u6587\u4EF6: ${h.skippedByBudget}`),L.push(" \u{1F4A1} \u540E\u7EED watcher \u89E6\u53D1\u6216\u518D\u6B21\u8C03\u7528 selective_precise=true \u7EE7\u7EED"));let w=m.getScheduler().pendingCount;w>0&&L.push(` \u{1F4CB} Pending queue: ${w} \u6587\u4EF6\u5F85\u91CD\u7B97`);}return {content:[{type:"text",text:L.join(`
463
- `)}]}});}function Dt(i,e,t){try{if(!e||!Q__default.existsSync(e))return {stale:!1};let n=Q__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 wn(i,e,t=5){let n=e.slice(0,t),r=[],s=0;for(let o of n){if(!o.abs_path||!Q__default.existsSync(o.abs_path))continue;s++;let{stale:a}=Dt(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 H(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(`
464
- `)}function vn(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
463
+ `)}]}});}function Dt(i,e,t){try{if(!e||!Q__default.existsSync(e))return {stale:!1};let n=Q__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 kn(i,e,t=5){let n=e.slice(0,t),r=[],s=0;for(let o of n){if(!o.abs_path||!Q__default.existsSync(o.abs_path))continue;s++;let{stale:a}=Dt(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 H(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(`
464
+ `)}function wn(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
465
465
  \u5305\u542B: props\u3001data/state\u3001computed\u3001methods/functions\u3001watch/effect\u3001lifecycle\u3001\u884C\u4E3A\u6807\u7B7E\u3002
466
466
  \u884C\u4E3A\u6807\u7B7E\u81EA\u52A8\u6807\u51FA: [storage:localStorage.setItem] [network:axios.get] \u7B49\u3002
467
467
 
@@ -480,15 +480,15 @@ ${E} ${A} (${N.length}):`);for(let x of N){let L=x.name,w=Re(x.start_line,x.end_
480
480
  ${"\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 S=Math.round((performance.now()-s)*100)/100,y=H({durationMs:S,resultCount:c.length,backend:"indexed"});return r&&(y.debug={scanned_files:1}),g.push(`
481
481
  \u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
482
482
  ${U(y)}`),{content:[{type:"text",text:g.join(`
483
- `)}]}});}var Xe=class{constructor(e){this.db=e;}db;search(e,t){let{category:n,framework:r,filePath:s,limit:o=sn,fuzzy:a=true,allowFallbackScan:c=false,debug:l=false}=t||{},p=e.trim(),d=new Map,u={},m=performance.now(),f=this.db.exactSearch(p,n,r,s);for(let A of f)d.set(A.id,{symbol:A,filePath:A.file_path,score:100,matchReason:"\u7CBE\u786E\u5339\u914D"});if(u["1_exact"]=Math.round((performance.now()-m)*100)/100,d.size>=o)return {results:this.rankResults(d,o)};let g=performance.now(),h=0,b=k(p),S=[p,b,...b.split(" ")].filter(Boolean).filter((A,N,x)=>x.indexOf(A)===N);for(let A of S){if(A.length<2)continue;let N=this.db.ftsSearch(A,n,r,s,o);h+=N.length;for(let x of N){let L=x.id;if(d.has(L))continue;let w=this.calcFtsScore(p,x.name);d.set(L,{symbol:x,filePath:x.file_path,score:w,matchReason:`FTS5 \u524D\u7F00\u5339\u914D ("${A}")`});}}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:h}:void 0};let y=a&&p.length>=3,_=0;if(y){let A=performance.now(),N=this.db.getAllSymbolNames(s),x=p.toLowerCase(),L=k(p).split(" ");for(let{name:w,file_path:M,id:P}of N){if(d.has(P))continue;_++;let B=Ge(x,w.toLowerCase()),ce=Math.max(x.length,w.length),ye=Math.min(on,Math.max(1,Math.floor(ce*.28)));if(B<=ye){let le=Math.max(0,80-B*15),X=this.db.getSymbolById(P);if(!X||n&&X.category!==n||r&&X.framework!==r)continue;let re=Yt(p,w,B);d.set(P,{symbol:X,filePath:M,score:le,matchReason:`\u6A21\u7CCA\u5339\u914D (\u7F16\u8F91\u8DDD\u79BB=${B})`,spellingSuggestion:re});continue}let xe=k(w).split(" "),J=L.filter(le=>xe.some(X=>Jt(le,X)>=75));if(J.length>0&&J.length>=Math.ceil(L.length*.5)){let le=50+J.length*10,X=this.db.getSymbolById(P);if(!X||n&&X.category!==n||r&&X.framework!==r)continue;d.set(P,{symbol:X,filePath:M,score:le,matchReason:`\u5355\u8BCD\u5339\u914D (${J.join(", ")})`});}}u["3_fuzzy"]=Math.round((performance.now()-A)*100)/100;}if(d.size===0&&c){let A=performance.now(),N=this.db.ftsSearchWithFallback(p,n,r,s,o);for(let x of N){let L=x.id;d.has(L)||d.set(L,{symbol:x,filePath:x.file_path,score:50,matchReason:"LIKE \u5168\u8868\u626B\u63CF fallback"});}u["4_fallback"]=Math.round((performance.now()-A)*100)/100;}let E=l?{phase_timings:u,candidate_count:h+_,fallback_reason:!y&&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:E}}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 On=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 Ke(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ie(i,e,t){let n=[];for(let r of i){if(!r?.abs_path||!Q__default.existsSync(r.abs_path))continue;let s=Q__default.readFileSync(r.abs_path,"utf-8").split(`
484
- `);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 Cn(i,e){let t=Ke(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 ht(i){try{return On("@babel/parser").parse(i,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"],errorRecovery:!0})}catch{return null}}function yt(i,e){if(!i.endsWith(".vue"))return [{content:e,lineOffset:1}];try{let{parse:s}=On("@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(`
485
- `).length;return [{content:t[1],lineOffset:r}]}function _e(i,e){return (i.loc?.start?.line??1)+e-1}function Wt(i,e){if(i.type!=="MemberExpression")return false;let t=i.object;return !t||t.type!=="ThisExpression"?false:Z(i)===e}function Mt(i,e){return !!i&&i.type==="Identifier"&&String(i.name||"")===e}function Fn(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 jt(i,e,t=2){if(!Q__default.existsSync(i))return {snippet:"",startLine:e};let n=Q__default.readFileSync(i,"utf-8").split(`
483
+ `)}]}});}var Xe=class{constructor(e){this.db=e;}db;search(e,t){let{category:n,framework:r,filePath:s,limit:o=rn,fuzzy:a=true,allowFallbackScan:c=false,debug:l=false}=t||{},p=e.trim(),d=new Map,u={},m=performance.now(),f=this.db.exactSearch(p,n,r,s);for(let A of f)d.set(A.id,{symbol:A,filePath:A.file_path,score:100,matchReason:"\u7CBE\u786E\u5339\u914D"});if(u["1_exact"]=Math.round((performance.now()-m)*100)/100,d.size>=o)return {results:this.rankResults(d,o)};let g=performance.now(),h=0,b=k(p),S=[p,b,...b.split(" ")].filter(Boolean).filter((A,N,x)=>x.indexOf(A)===N);for(let A of S){if(A.length<2)continue;let N=this.db.ftsSearch(A,n,r,s,o);h+=N.length;for(let x of N){let L=x.id;if(d.has(L))continue;let w=this.calcFtsScore(p,x.name);d.set(L,{symbol:x,filePath:x.file_path,score:w,matchReason:`FTS5 \u524D\u7F00\u5339\u914D ("${A}")`});}}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:h}:void 0};let y=a&&p.length>=3,_=0;if(y){let A=performance.now(),N=this.db.getAllSymbolNames(s),x=p.toLowerCase(),L=k(p).split(" ");for(let{name:w,file_path:M,id:P}of N){if(d.has(P))continue;_++;let B=Ge(x,w.toLowerCase()),ce=Math.max(x.length,w.length),ye=Math.min(sn,Math.max(1,Math.floor(ce*.28)));if(B<=ye){let le=Math.max(0,80-B*15),X=this.db.getSymbolById(P);if(!X||n&&X.category!==n||r&&X.framework!==r)continue;let re=Jt(p,w,B);d.set(P,{symbol:X,filePath:M,score:le,matchReason:`\u6A21\u7CCA\u5339\u914D (\u7F16\u8F91\u8DDD\u79BB=${B})`,spellingSuggestion:re});continue}let xe=k(w).split(" "),J=L.filter(le=>xe.some(X=>qt(le,X)>=75));if(J.length>0&&J.length>=Math.ceil(L.length*.5)){let le=50+J.length*10,X=this.db.getSymbolById(P);if(!X||n&&X.category!==n||r&&X.framework!==r)continue;d.set(P,{symbol:X,filePath:M,score:le,matchReason:`\u5355\u8BCD\u5339\u914D (${J.join(", ")})`});}}u["3_fuzzy"]=Math.round((performance.now()-A)*100)/100;}if(d.size===0&&c){let A=performance.now(),N=this.db.ftsSearchWithFallback(p,n,r,s,o);for(let x of N){let L=x.id;d.has(L)||d.set(L,{symbol:x,filePath:x.file_path,score:50,matchReason:"LIKE \u5168\u8868\u626B\u63CF fallback"});}u["4_fallback"]=Math.round((performance.now()-A)*100)/100;}let E=l?{phase_timings:u,candidate_count:h+_,fallback_reason:!y&&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:E}}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 Pn=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 Ke(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ie(i,e,t){let n=[];for(let r of i){if(!r?.abs_path||!Q__default.existsSync(r.abs_path))continue;let s=Q__default.readFileSync(r.abs_path,"utf-8").split(`
484
+ `);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 vn(i,e){let t=Ke(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 ht(i){try{return Pn("@babel/parser").parse(i,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"],errorRecovery:!0})}catch{return null}}function yt(i,e){if(!i.endsWith(".vue"))return [{content:e,lineOffset:1}];try{let{parse:s}=Pn("@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(`
485
+ `).length;return [{content:t[1],lineOffset:r}]}function _e(i,e){return (i.loc?.start?.line??1)+e-1}function Wt(i,e){if(i.type!=="MemberExpression")return false;let t=i.object;return !t||t.type!=="ThisExpression"?false:Z(i)===e}function Mt(i,e){return !!i&&i.type==="Identifier"&&String(i.name||"")===e}function On(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 jt(i,e,t=2){if(!Q__default.existsSync(i))return {snippet:"",startLine:e};let n=Q__default.readFileSync(i,"utf-8").split(`
486
486
  `),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(`
487
- `),startLine:r+1}}function ft(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 In={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 $n(i,e,t){let n=[];for(let r of i){if(!r.abs_path||!Q__default.existsSync(r.abs_path))continue;let s=Q__default.readFileSync(r.abs_path,"utf-8"),o=s.split(`
488
- `),a=yt(r.path||z__default.basename(r.abs_path),s);for(let c of a){let l=ht(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 m=p.init;if(!m)return;let f=false;if(m.type==="Identifier"&&String(m.name||"")===e?f=true:m.type==="MemberExpression"&&(f=Wt(m,e)||Z(m)===e),!f)return;let g=_e(p,c.lineOffset),h=o[g-1]?.trim()||"";n.push({alias:u,filePath:r.path,abs_path:r.abs_path,line:g,text:h});});}}return n}function Pn(i,e,t){let n=[];for(let r of i){if(!r.abs_path||!Q__default.existsSync(r.abs_path))continue;let s=Q__default.readFileSync(r.abs_path,"utf-8"),o=s.split(`
487
+ `),startLine:r+1}}function ft(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 Cn={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 In(i,e,t){let n=[];for(let r of i){if(!r.abs_path||!Q__default.existsSync(r.abs_path))continue;let s=Q__default.readFileSync(r.abs_path,"utf-8"),o=s.split(`
488
+ `),a=yt(r.path||z__default.basename(r.abs_path),s);for(let c of a){let l=ht(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 m=p.init;if(!m)return;let f=false;if(m.type==="Identifier"&&String(m.name||"")===e?f=true:m.type==="MemberExpression"&&(f=Wt(m,e)||Z(m)===e),!f)return;let g=_e(p,c.lineOffset),h=o[g-1]?.trim()||"";n.push({alias:u,filePath:r.path,abs_path:r.abs_path,line:g,text:h});});}}return n}function $n(i,e,t){let n=[];for(let r of i){if(!r.abs_path||!Q__default.existsSync(r.abs_path))continue;let s=Q__default.readFileSync(r.abs_path,"utf-8"),o=s.split(`
489
489
  `),a=yt(r.path||z__default.basename(r.abs_path),s);for(let c of a){let l=ht(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 m of u){if(m.type!=="ObjectProperty"&&m.type!=="Property")continue;let f=m.key,g=m.value,h=f?.type==="Identifier"?String(f.name||""):null;if(h!==e)continue;let b=g?.type==="Identifier"?String(g.name||""):h;if(!b)continue;let S=_e(p,c.lineOffset),y=o[S-1]?.trim()||"";n.push({alias:b,filePath:r.path,line:S,text:y});}});}}return n}function Ut(i,e,t,n){let r=[];for(let s of i){if(!s.abs_path||!Q__default.existsSync(s.abs_path))continue;let o=Q__default.readFileSync(s.abs_path,"utf-8"),a=o.split(`
490
- `),c=yt(s.path||z__default.basename(s.abs_path),o);for(let l of c){let p=ht(l.content);if(p&&(me(p,d=>{if(!(r.length>=n)){if(d.type==="VariableDeclarator"){let u=d.id;if(Mt(u,e)){let m=_e(d,l.lineOffset);r.push({filePath:s.path,line:m,kind:"declaration",text:a[m-1]?.trim()||""});}}if(d.type==="AssignmentExpression"){let u=d.left;if(!u)return;let m=_e(d,l.lineOffset);if(Mt(u,e)||Wt(u,e)){r.push({filePath:s.path,line:m,kind:"assignment",text:a[m-1]?.trim()||""});return}t&&u.type==="MemberExpression"&&ie(u)===e&&r.push({filePath:s.path,line:m,kind:u.computed?"indexed_assignment":"property_assignment",text:a[m-1]?.trim()||""});}if(d.type==="UpdateExpression"){let u=d.argument;if(!u)return;if(Mt(u,e)||Wt(u,e)){let m=_e(d,l.lineOffset);r.push({filePath:s.path,line:m,kind:"update",text:a[m-1]?.trim()||""});}}}}),r.length>=n))break}if(r.length>=n)break}return Fn(r).slice(0,n)}function mt(i,e,t,n){let r=[];for(let s of i){if(!s.abs_path||!Q__default.existsSync(s.abs_path))continue;let o=Q__default.readFileSync(s.abs_path,"utf-8"),a=o.split(`
491
- `),c=yt(s.path||z__default.basename(s.abs_path),o);for(let l of c){let p=ht(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 f=Z(u);if(t&&f!==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 f=Z(u);if(t&&f!==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 f=Z(u);if(t&&f!==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 Fn(r).slice(0,n)}function Dn(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
490
+ `),c=yt(s.path||z__default.basename(s.abs_path),o);for(let l of c){let p=ht(l.content);if(p&&(me(p,d=>{if(!(r.length>=n)){if(d.type==="VariableDeclarator"){let u=d.id;if(Mt(u,e)){let m=_e(d,l.lineOffset);r.push({filePath:s.path,line:m,kind:"declaration",text:a[m-1]?.trim()||""});}}if(d.type==="AssignmentExpression"){let u=d.left;if(!u)return;let m=_e(d,l.lineOffset);if(Mt(u,e)||Wt(u,e)){r.push({filePath:s.path,line:m,kind:"assignment",text:a[m-1]?.trim()||""});return}t&&u.type==="MemberExpression"&&ie(u)===e&&r.push({filePath:s.path,line:m,kind:u.computed?"indexed_assignment":"property_assignment",text:a[m-1]?.trim()||""});}if(d.type==="UpdateExpression"){let u=d.argument;if(!u)return;if(Mt(u,e)||Wt(u,e)){let m=_e(d,l.lineOffset);r.push({filePath:s.path,line:m,kind:"update",text:a[m-1]?.trim()||""});}}}}),r.length>=n))break}if(r.length>=n)break}return On(r).slice(0,n)}function mt(i,e,t,n){let r=[];for(let s of i){if(!s.abs_path||!Q__default.existsSync(s.abs_path))continue;let o=Q__default.readFileSync(s.abs_path,"utf-8"),a=o.split(`
491
+ `),c=yt(s.path||z__default.basename(s.abs_path),o);for(let l of c){let p=ht(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 f=Z(u);if(t&&f!==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 f=Z(u);if(t&&f!==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 f=Z(u);if(t&&f!==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 On(r).slice(0,n)}function Fn(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
492
492
  \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
493
493
  \u9A7C\u5CF0\u62C6\u8BCD\uFF1A\u641C "change cache" \u4E5F\u80FD\u627E\u5230 "changeCacheValue"\u3002
494
494
  \u6846\u67B6\u611F\u77E5\uFF1A\u53EF\u6309 vue2/vue3/react \u8FC7\u6EE4\u3002
@@ -524,7 +524,7 @@ ${U(N)}`),{content:[{type:"text",text:E.join(`
524
524
  `)}]}}),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
525
525
  \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
526
526
  \u2705 \u672C\u5DE5\u5177\u9002\u5408\uFF1Aloading / errorMsg / count \u8FD9\u7C7B\u7B80\u5355 flag \u7684\u8D4B\u503C\u8FFD\u8E2A\u3002
527
- \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),m={vue2:"Vue2 data()",vue3:"Vue3 ref/reactive",react:"React useState/useRef"},f=u.filter(E=>E.default_value!=null).map(E=>({filePath:E.file_path,line:E.start_line,kind:`data_init(${m[E.framework]||E.framework})`,text:`${E.name}: ${E.default_value} \u2190 \u58F0\u660E\u521D\u59CB\u5316`})),g=Ut(l,t,d,p);if(g.length===0){let E=Cn(t,d);g=Ie(l,E,p);}let h=new Map;for(let E of [...f,...g]){let A=`${E.filePath}:${E.line}`;h.has(A)||h.set(A,E);}let b=[...h.values()],S=Math.round((performance.now()-a)*100)/100;if(b.length===0){let E=H({durationMs:S,resultCount:0,backend:"ast_scan"});return {content:[{type:"text",text:`\u{1F9E9} \u53D8\u91CF\u8D4B\u503C\u8FFD\u8E2A: "${t}"
527
+ \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),m={vue2:"Vue2 data()",vue3:"Vue3 ref/reactive",react:"React useState/useRef"},f=u.filter(E=>E.default_value!=null).map(E=>({filePath:E.file_path,line:E.start_line,kind:`data_init(${m[E.framework]||E.framework})`,text:`${E.name}: ${E.default_value} \u2190 \u58F0\u660E\u521D\u59CB\u5316`})),g=Ut(l,t,d,p);if(g.length===0){let E=vn(t,d);g=Ie(l,E,p);}let h=new Map;for(let E of [...f,...g]){let A=`${E.filePath}:${E.line}`;h.has(A)||h.set(A,E);}let b=[...h.values()],S=Math.round((performance.now()-a)*100)/100;if(b.length===0){let E=H({durationMs:S,resultCount:0,backend:"ast_scan"});return {content:[{type:"text",text:`\u{1F9E9} \u53D8\u91CF\u8D4B\u503C\u8FFD\u8E2A: "${t}"
528
528
  \u672A\u627E\u5230\u5339\u914D\u8D4B\u503C\u8BED\u53E5\uFF08\u5305\u62EC\u58F0\u660E\u521D\u59CB\u5316\uFF09
529
529
  \u8FC7\u6EE4: file_path=${r||"*"} include_properties=${d}
530
530
 
@@ -535,7 +535,7 @@ ${U(_)}`),{content:[{type:"text",text:y.join(`
535
535
  `)}]}}),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
536
536
  \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
537
537
  \u2705 \u672C\u5DE5\u5177\u9002\u5408\uFF1Aobject.specificProp \u7684\u5355\u5B57\u6BB5\u7EA7\u522B\u7CBE\u786E\u8FFD\u8E2A\u3002
538
- \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=$n(l,t,20),u=Pn(l,t,20),m=[...new Set([...d.map(y=>y.alias),...u.map(y=>y.alias)].filter(y=>y!==t))],f=[t,...m],g=mt(l,t,n,p);for(let y of m)g.push(...mt(l,y,n,Math.floor(p/2)));if(g.length===0){let y="(?:=|\\+=|-=|\\*=|/=|%=|\\|=|&=|\\^=|&&=|\\|\\|=|\\?\\?=)",_=[];for(let E of f){let A=Ke(E);if(n){let N=Ke(n);_.push({kind:"dot",regex:new RegExp(`\\b${A}\\.${N}\\s*${y}`)},{kind:"bracket",regex:new RegExp(`\\b${A}\\s*\\[(?:'${N}'|"${N}")\\]\\s*${y}`)},{kind:"delete",regex:new RegExp(`\\bdelete\\s+${A}\\.(?:${N})\\b`)});}else _.push({kind:"dot",regex:new RegExp(`\\b${A}\\.[A-Za-z_$][\\w$]*\\s*${y}`)},{kind:"bracket",regex:new RegExp(`\\b${A}\\s*\\[(?:'[^']+'|"[^"]+")\\]\\s*${y}`)},{kind:"delete",regex:new RegExp(`\\bdelete\\s+${A}\\.[A-Za-z_$][\\w$]*\\b`)});}g=Ie(l,_,p);}let h=Math.round((performance.now()-a)*100)/100;if(g.length===0){let y=m.length>0?`
538
+ \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=In(l,t,20),u=$n(l,t,20),m=[...new Set([...d.map(y=>y.alias),...u.map(y=>y.alias)].filter(y=>y!==t))],f=[t,...m],g=mt(l,t,n,p);for(let y of m)g.push(...mt(l,y,n,Math.floor(p/2)));if(g.length===0){let y="(?:=|\\+=|-=|\\*=|/=|%=|\\|=|&=|\\^=|&&=|\\|\\|=|\\?\\?=)",_=[];for(let E of f){let A=Ke(E);if(n){let N=Ke(n);_.push({kind:"dot",regex:new RegExp(`\\b${A}\\.${N}\\s*${y}`)},{kind:"bracket",regex:new RegExp(`\\b${A}\\s*\\[(?:'${N}'|"${N}")\\]\\s*${y}`)},{kind:"delete",regex:new RegExp(`\\bdelete\\s+${A}\\.(?:${N})\\b`)});}else _.push({kind:"dot",regex:new RegExp(`\\b${A}\\.[A-Za-z_$][\\w$]*\\s*${y}`)},{kind:"bracket",regex:new RegExp(`\\b${A}\\s*\\[(?:'[^']+'|"[^"]+")\\]\\s*${y}`)},{kind:"delete",regex:new RegExp(`\\bdelete\\s+${A}\\.[A-Za-z_$][\\w$]*\\b`)});}g=Ie(l,_,p);}let h=Math.round((performance.now()-a)*100)/100;if(g.length===0){let y=m.length>0?`
539
539
  \u522B\u540D\u5C55\u5F00: ${m.join(", ")}\uFF08\u5747\u672A\u547D\u4E2D\uFF09`:"",_=H({durationMs:h,resultCount:0,backend:"ast_scan"});return {content:[{type:"text",text:`\u{1F9ED} \u5C5E\u6027\u4FEE\u6539\u8FFD\u8E2A: ${t}${n?`.${n}`:".*"}
540
540
  \u672A\u627E\u5230\u5339\u914D\u8BED\u53E5${y}
541
541
  \u8FC7\u6EE4: file_path=${s||"*"}
@@ -585,19 +585,19 @@ ${U(h)}`),{content:[{type:"text",text:m.join(`
585
585
  \u65E7\u65B9\u5F0F: trace_assignments \u2192 find_symbol \u2192 get_code_slice \u2192 find_by_behavior \u2192 trace_key_flow
586
586
  \u65B0\u65B9\u5F0F: skimmer_trace_data_lifecycle({ variable: "xxx" }) \u2190 \u76F4\u63A5\u5F97\u5230\u5168\u90E8
587
587
 
588
- 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),m="",f=wn(l,u,r?u.length:5);f.stale&&(m=`\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:
588
+ 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),m="",f=kn(l,u,r?u.length:5);f.stale&&(m=`\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:
589
589
  `+f.staleFilePaths.slice(0,3).map(T=>` \u2022 ${T}`).join(`
590
590
  `)+`
591
591
  \u5EFA\u8BAE: skimmer_index_project({ force: true })
592
- `);let g=Pn(u,t,20),h=[...new Set(g.map(T=>T.alias).filter(T=>T!==t))],b=$n(u,t,20),S=[...new Set(b.map(T=>T.alias).filter(T=>T!==t))],y=[...new Set([...h,...S])],E=[t,...y],A=l.exactSearch(t,"state",void 0,r||void 0),N={vue2:"Vue2 data()",vue3:"Vue3 ref/reactive",react:"React useState/useRef"},x=A.filter(T=>T.default_value!=null).map(T=>({filePath:T.file_path,line:T.start_line,kind:`data_init(${N[T.framework]||T.framework})`,text:`${T.name}: ${T.default_value} \u2190 \u58F0\u660E\u521D\u59CB\u5316`})),L=false,w=l.getAssignments(t,r,d),M=[];w.length>0?(M=w.map(T=>({filePath:T.file_path,line:T.line_number,kind:T.kind,text:T.text_snippet||"",sourceLayer:T.source_layer||void 0})),L=true):M=Ut(u,t,false,d);for(let T of y){let I=l.getAssignments(T,r,Math.floor(d/2));I.length>0?M.push(...I.map(R=>({filePath:R.file_path,line:R.line_number,kind:R.kind,text:R.text_snippet||"",sourceLayer:R.source_layer||void 0}))):M.push(...Ut(u,T,false,Math.floor(d/2)));}let P=M.length===0?Ie(u,Cn(t,false),d):[],B=new Map;for(let T of [...x,...M.length>0?M:P]){let I=`${T.filePath}:${T.line}`;B.has(I)||B.set(I,T);}let ce=[...B.values()],ye=false,xe=l.getPropertyWrites(t,void 0,r,d),J=[];xe.length>0?(J=xe.map(T=>({filePath:T.file_path,line:T.line_number,kind:T.kind,text:T.text_snippet||"",sourceLayer:T.source_layer||void 0})),ye=true):J=mt(u,t,void 0,d);for(let T of y){let I=l.getPropertyWrites(T,void 0,r,Math.floor(d/2));I.length>0?J.push(...I.map(R=>({filePath:R.file_path,line:R.line_number,kind:R.kind,text:R.text_snippet||"",sourceLayer:R.source_layer||void 0}))):J.push(...mt(u,T,void 0,Math.floor(d/2)));}let le=J.length===0?Ie(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=J.length>0?J:le,re=l.findRelationsByArgKeyword(t,r,d);for(let T of y)re.push(...l.findRelationsByArgKeyword(T,r,Math.floor(d/2)));let Xt=[],Kt=[],Vt=[];for(let T of E){let I=Ke(T),R=/^[a-zA-Z_$][\w$]*$/.test(T)?"\\b":"";Xt.push({kind:"template",regex:new RegExp(`(?::\\w+|v-model|v-if|v-show|@\\w+)="[^"]*${R}${I}${R}|\\{\\{[^}]*${R}${I}${R}[^}]*\\}\\}`)},{kind:"return",regex:new RegExp(`\\breturn\\b[^=]*${R}${I}${R}`)},{kind:"watch",regex:new RegExp(`watch[^(]*['"]\\.?${I}['"]`)},{kind:"computed_read",regex:new RegExp(`=>[^=]*${R}${I}${R}|return[^=]*${R}${I}${R}`)},{kind:"arg_usage",regex:new RegExp(`\\(\\s*[^)]*${R}${I}${R}[^)]*\\)`)}),Kt.push(`${R}${I}${R}\\s*(?:=|\\+=|-=|\\*=|\\/=)(?!=)|\\b(?:const|let|var)\\s+${I}\\b`),Vt.push(`${R}${I}${R}\\.\\w+\\s*(?:=|\\+=|-=)(?!=)|${R}${I}${R}\\s*\\[`);}let Hn=Ie(u,Xt,d),Bn=new RegExp(Kt.join("|")),Xn=new RegExp(Vt.join("|")),Pe=Hn.filter(T=>!Bn.test(T.text)&&!Xn.test(T.text)),bt=new Map,zt=(T,I)=>{if(!bt.has(T)){let{behaviors:O}=l.getFileOutline(T),$=new Map;for(let j of O){let ee=String(j.symbol_name||"");$.has(ee)||$.set(ee,[]),$.get(ee).push(j);}bt.set(T,$);}return (bt.get(T)?.get(I)||[]).filter(O=>String(O.category||"")!=="storage"?false:s==="all"?true:String(O.api_name||"").toLowerCase()===s.toLowerCase())},Kn=(T,I)=>{let R=[],O=[{name:T,filePath:I,path:[T],level:0}],$=new Set([`${I}::${T}`]);for(;O.length>0;){let j=O.shift(),ee=zt(j.filePath,j.name);if(ee.length>0){R.push({path:j.path,file:j.filePath,behaviors:ee});continue}if(j.level>=p)continue;let Y=l.getSymbolByName(j.name,j.filePath);if(Y||(Y=l.getSymbolByName(j.name)),!Y)continue;let pe=String(Y.file_path||Y.abs_path||j.filePath),Oe=zt(pe,j.name);if(Oe.length>0){R.push({path:j.path,file:pe,behaviors:Oe});continue}let Et=l.getCallees(Y.id);for(let Fe of Et){let De=String(Fe.callee_name||"");if(!De||De.startsWith("$"))continue;let qt=`${pe}::${De}`;$.has(qt)||($.add(qt),O.push({name:De,filePath:pe,path:[...j.path,De],level:j.level+1}));}}return R},Vn=y.length>0?`
593
- \u{1F517} \u53D1\u73B0\u522B\u540D: ${y.map(T=>`"${T}"`).join(", ")}\uFF08\u5DF2\u4E00\u5E76\u8FFD\u8E2A\u5C5E\u6027\u4FEE\u6539\uFF09`:"",Ae=[];b.length>0&&(Ae.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(T=>{let R=u.find(j=>j.path===T.filePath)?.abs_path||T.abs_path,O=ft("alias_ref"),$=R?jt(R,T.line,2):{snippet:""};Ae.push(` \u{1F4C4} ${T.filePath}:L${T.line} "${T.alias}" = ... ${O}`),Ae.push(` ${T.text}`),$.snippet&&Ae.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}${Vn}`,""];if(m&&C.push(m),C.push(`\u2460 \u58F0\u660E & \u6574\u4F53\u8D4B\u503C (${ce.length} \u5904)`),ce.length===0)C.push(" \uFF08\u672A\u627E\u5230\uFF09");else {let T={init:[],cache:[],user:[],unknown:[]};for(let R of ce){let O=R.sourceLayer||te(R.text,R.line);T[O].push(R);}let I=["init","cache","user","unknown"];for(let R of I){let O=T[R];!O||O.length===0||(C.push(` \u25B8 ${In[R]} (${O.length} \u5904)`),O.slice(0,8).forEach($=>{let j=y.includes($.text.split("=")[0]?.trim().replace(/^(?:const|let|var)\s+/,"")||""),ee=ft($.kind,j);C.push(` \u{1F4C4} ${$.filePath}:L${$.line} [${$.kind}] ${ee}`),C.push(` ${$.text}`);}));}Ae.length>0&&(C.push(""),C.push(...Ae));}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'),y.length>0&&C.push(` \u2139\uFE0F \u5DF2\u8FFD\u8E2A\u522B\u540D: ${y.map(T=>`"${T}"`).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 T={init:[],cache:[],user:[],unknown:[]};for(let R of X){let O=R.sourceLayer||te(R.text,R.line);T[O].push(R);}let I=["init","cache","user","unknown"];for(let R of I){let O=T[R];!O||O.length===0||(C.push(` \u25B8 ${In[R]} (${O.length} \u5904)`),O.slice(0,8).forEach($=>{let j=y.some(Fe=>$.text.startsWith(Fe)),ee=ft($.kind,j),pe=u.find(Fe=>Fe.path===$.filePath)?.abs_path||"",Oe=pe?jt(pe,$.line,2):{snippet:""},Et=j?" \u{1F517}(via alias)":"";C.push(` \u{1F4C4} ${$.filePath}:L${$.line} [${$.kind}] ${ee}${Et}`),Oe.snippet&&C.push(Oe.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(T=>{let I=String(T.args||"");C.push(` \u{1F4C4} ${T.file_path}:L${T.line_number} ${T.caller_name} \u2192 ${T.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 T=new Map;for(let R of Pe)T.has(R.kind)||T.set(R.kind,[]),T.get(R.kind).push(R);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[R,O]of T)C.push(` \u25B8 ${I[R]||R}`),O.slice(0,8).forEach($=>C.push(` \u{1F4C4} ${$.filePath}:L${$.line} ${$.text}`));}C.push("");let Le=0;C.push(`\u2464 Storage \u843D\u70B9\u8FFD\u8E2A (storage_api=${s}, depth=${p})`);let zn=s==="localStorage"?"localStorage":s==="sessionStorage"?"sessionStorage":"(?:localStorage|sessionStorage)",Gn=E.map(T=>({kind:"direct_storage",regex:new RegExp(`${zn}\\.(?:setItem|getItem|removeItem|clear)\\(.*?\\b${Ke(T)}\\b`)})),Ve=Ie(u,Gn,d);if(Ve.length>0&&(Le+=1,C.push(` \u843D\u70B9 [\u76F4\u63A5\u547D\u4E2D\u5B58\u50A8] ${ft("direct_storage")}:`),Ve.slice(0,15).forEach(T=>{let R=u.find($=>$.path===T.filePath)?.abs_path||"",O=R?jt(R,T.line,2):{snippet:""};C.push(` \u{1F4C4} ${T.filePath}:L${T.line} ${T.text.trim()}`),O.snippet&&C.push(O.snippet);})),re.length===0&&Ve.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 T=new Map;for(let I of re){let R=`${I.file_path}::${I.callee_name}`;T.has(R)||T.set(R,I);}for(let[,I]of T){let R=String(I.callee_name||""),O=String(I.file_path||""),$=Kn(R,O);$.length!==0&&(Le+=1,$.slice(0,3).forEach(j=>{let ee=j.file!==O?` \u2197 \u8DE8\u6587\u4EF6: ${j.file}`:"";C.push(` \u94FE\u8DEF: ${j.path.join(" \u2192 ")}${ee}`),j.behaviors.forEach(Y=>{let pe=Y.detail?`("${String(Y.detail)}")`:"";C.push(` \u843D\u70B9: ${Y.api_name}.${Y.operation}${pe} [${Y.category}] L${Y.line_number}`);});}));}Le===0&&Ve.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 qn=y.length>0?` (\u542B ${y.length} \u4E2A\u522B\u540D: ${y.slice(0,3).map(T=>`"${T}"`).join(", ")})`:"";C.push(`\u2705 \u6C47\u603B${qn}:`),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: ${y.map(T=>`"${T}"`).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: ${Le>0?`\u2713 \u53D1\u73B0\u5199\u5165\u94FE\u8DEF (${Le} \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 Jn=Math.round((performance.now()-c)*100)/100,Yn=ce.length+X.length+re.length+Pe.length+Le,Gt=H({durationMs:Jn,resultCount:Yn,backend:L&&ye?"indexed":L||ye?"hybrid":"fallback_scan"});return f.stale&&(Gt.index_freshness=f),C.push(`
592
+ `);let g=$n(u,t,20),h=[...new Set(g.map(T=>T.alias).filter(T=>T!==t))],b=In(u,t,20),S=[...new Set(b.map(T=>T.alias).filter(T=>T!==t))],y=[...new Set([...h,...S])],E=[t,...y],A=l.exactSearch(t,"state",void 0,r||void 0),N={vue2:"Vue2 data()",vue3:"Vue3 ref/reactive",react:"React useState/useRef"},x=A.filter(T=>T.default_value!=null).map(T=>({filePath:T.file_path,line:T.start_line,kind:`data_init(${N[T.framework]||T.framework})`,text:`${T.name}: ${T.default_value} \u2190 \u58F0\u660E\u521D\u59CB\u5316`})),L=false,w=l.getAssignments(t,r,d),M=[];w.length>0?(M=w.map(T=>({filePath:T.file_path,line:T.line_number,kind:T.kind,text:T.text_snippet||"",sourceLayer:T.source_layer||void 0})),L=true):M=Ut(u,t,false,d);for(let T of y){let I=l.getAssignments(T,r,Math.floor(d/2));I.length>0?M.push(...I.map(R=>({filePath:R.file_path,line:R.line_number,kind:R.kind,text:R.text_snippet||"",sourceLayer:R.source_layer||void 0}))):M.push(...Ut(u,T,false,Math.floor(d/2)));}let P=M.length===0?Ie(u,vn(t,false),d):[],B=new Map;for(let T of [...x,...M.length>0?M:P]){let I=`${T.filePath}:${T.line}`;B.has(I)||B.set(I,T);}let ce=[...B.values()],ye=false,xe=l.getPropertyWrites(t,void 0,r,d),J=[];xe.length>0?(J=xe.map(T=>({filePath:T.file_path,line:T.line_number,kind:T.kind,text:T.text_snippet||"",sourceLayer:T.source_layer||void 0})),ye=true):J=mt(u,t,void 0,d);for(let T of y){let I=l.getPropertyWrites(T,void 0,r,Math.floor(d/2));I.length>0?J.push(...I.map(R=>({filePath:R.file_path,line:R.line_number,kind:R.kind,text:R.text_snippet||"",sourceLayer:R.source_layer||void 0}))):J.push(...mt(u,T,void 0,Math.floor(d/2)));}let le=J.length===0?Ie(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=J.length>0?J:le,re=l.findRelationsByArgKeyword(t,r,d);for(let T of y)re.push(...l.findRelationsByArgKeyword(T,r,Math.floor(d/2)));let Bt=[],Xt=[],Kt=[];for(let T of E){let I=Ke(T),R=/^[a-zA-Z_$][\w$]*$/.test(T)?"\\b":"";Bt.push({kind:"template",regex:new RegExp(`(?::\\w+|v-model|v-if|v-show|@\\w+)="[^"]*${R}${I}${R}|\\{\\{[^}]*${R}${I}${R}[^}]*\\}\\}`)},{kind:"return",regex:new RegExp(`\\breturn\\b[^=]*${R}${I}${R}`)},{kind:"watch",regex:new RegExp(`watch[^(]*['"]\\.?${I}['"]`)},{kind:"computed_read",regex:new RegExp(`=>[^=]*${R}${I}${R}|return[^=]*${R}${I}${R}`)},{kind:"arg_usage",regex:new RegExp(`\\(\\s*[^)]*${R}${I}${R}[^)]*\\)`)}),Xt.push(`${R}${I}${R}\\s*(?:=|\\+=|-=|\\*=|\\/=)(?!=)|\\b(?:const|let|var)\\s+${I}\\b`),Kt.push(`${R}${I}${R}\\.\\w+\\s*(?:=|\\+=|-=)(?!=)|${R}${I}${R}\\s*\\[`);}let Bn=Ie(u,Bt,d),Xn=new RegExp(Xt.join("|")),Kn=new RegExp(Kt.join("|")),Pe=Bn.filter(T=>!Xn.test(T.text)&&!Kn.test(T.text)),bt=new Map,Vt=(T,I)=>{if(!bt.has(T)){let{behaviors:O}=l.getFileOutline(T),$=new Map;for(let j of O){let ee=String(j.symbol_name||"");$.has(ee)||$.set(ee,[]),$.get(ee).push(j);}bt.set(T,$);}return (bt.get(T)?.get(I)||[]).filter(O=>String(O.category||"")!=="storage"?false:s==="all"?true:String(O.api_name||"").toLowerCase()===s.toLowerCase())},Vn=(T,I)=>{let R=[],O=[{name:T,filePath:I,path:[T],level:0}],$=new Set([`${I}::${T}`]);for(;O.length>0;){let j=O.shift(),ee=Vt(j.filePath,j.name);if(ee.length>0){R.push({path:j.path,file:j.filePath,behaviors:ee});continue}if(j.level>=p)continue;let Y=l.getSymbolByName(j.name,j.filePath);if(Y||(Y=l.getSymbolByName(j.name)),!Y)continue;let pe=String(Y.file_path||Y.abs_path||j.filePath),Oe=Vt(pe,j.name);if(Oe.length>0){R.push({path:j.path,file:pe,behaviors:Oe});continue}let Et=l.getCallees(Y.id);for(let Fe of Et){let De=String(Fe.callee_name||"");if(!De||De.startsWith("$"))continue;let Gt=`${pe}::${De}`;$.has(Gt)||($.add(Gt),O.push({name:De,filePath:pe,path:[...j.path,De],level:j.level+1}));}}return R},zn=y.length>0?`
593
+ \u{1F517} \u53D1\u73B0\u522B\u540D: ${y.map(T=>`"${T}"`).join(", ")}\uFF08\u5DF2\u4E00\u5E76\u8FFD\u8E2A\u5C5E\u6027\u4FEE\u6539\uFF09`:"",Ae=[];b.length>0&&(Ae.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(T=>{let R=u.find(j=>j.path===T.filePath)?.abs_path||T.abs_path,O=ft("alias_ref"),$=R?jt(R,T.line,2):{snippet:""};Ae.push(` \u{1F4C4} ${T.filePath}:L${T.line} "${T.alias}" = ... ${O}`),Ae.push(` ${T.text}`),$.snippet&&Ae.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}${zn}`,""];if(m&&C.push(m),C.push(`\u2460 \u58F0\u660E & \u6574\u4F53\u8D4B\u503C (${ce.length} \u5904)`),ce.length===0)C.push(" \uFF08\u672A\u627E\u5230\uFF09");else {let T={init:[],cache:[],user:[],unknown:[]};for(let R of ce){let O=R.sourceLayer||te(R.text,R.line);T[O].push(R);}let I=["init","cache","user","unknown"];for(let R of I){let O=T[R];!O||O.length===0||(C.push(` \u25B8 ${Cn[R]} (${O.length} \u5904)`),O.slice(0,8).forEach($=>{let j=y.includes($.text.split("=")[0]?.trim().replace(/^(?:const|let|var)\s+/,"")||""),ee=ft($.kind,j);C.push(` \u{1F4C4} ${$.filePath}:L${$.line} [${$.kind}] ${ee}`),C.push(` ${$.text}`);}));}Ae.length>0&&(C.push(""),C.push(...Ae));}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'),y.length>0&&C.push(` \u2139\uFE0F \u5DF2\u8FFD\u8E2A\u522B\u540D: ${y.map(T=>`"${T}"`).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 T={init:[],cache:[],user:[],unknown:[]};for(let R of X){let O=R.sourceLayer||te(R.text,R.line);T[O].push(R);}let I=["init","cache","user","unknown"];for(let R of I){let O=T[R];!O||O.length===0||(C.push(` \u25B8 ${Cn[R]} (${O.length} \u5904)`),O.slice(0,8).forEach($=>{let j=y.some(Fe=>$.text.startsWith(Fe)),ee=ft($.kind,j),pe=u.find(Fe=>Fe.path===$.filePath)?.abs_path||"",Oe=pe?jt(pe,$.line,2):{snippet:""},Et=j?" \u{1F517}(via alias)":"";C.push(` \u{1F4C4} ${$.filePath}:L${$.line} [${$.kind}] ${ee}${Et}`),Oe.snippet&&C.push(Oe.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(T=>{let I=String(T.args||"");C.push(` \u{1F4C4} ${T.file_path}:L${T.line_number} ${T.caller_name} \u2192 ${T.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 T=new Map;for(let R of Pe)T.has(R.kind)||T.set(R.kind,[]),T.get(R.kind).push(R);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[R,O]of T)C.push(` \u25B8 ${I[R]||R}`),O.slice(0,8).forEach($=>C.push(` \u{1F4C4} ${$.filePath}:L${$.line} ${$.text}`));}C.push("");let Le=0;C.push(`\u2464 Storage \u843D\u70B9\u8FFD\u8E2A (storage_api=${s}, depth=${p})`);let Gn=s==="localStorage"?"localStorage":s==="sessionStorage"?"sessionStorage":"(?:localStorage|sessionStorage)",qn=E.map(T=>({kind:"direct_storage",regex:new RegExp(`${Gn}\\.(?:setItem|getItem|removeItem|clear)\\(.*?\\b${Ke(T)}\\b`)})),Ve=Ie(u,qn,d);if(Ve.length>0&&(Le+=1,C.push(` \u843D\u70B9 [\u76F4\u63A5\u547D\u4E2D\u5B58\u50A8] ${ft("direct_storage")}:`),Ve.slice(0,15).forEach(T=>{let R=u.find($=>$.path===T.filePath)?.abs_path||"",O=R?jt(R,T.line,2):{snippet:""};C.push(` \u{1F4C4} ${T.filePath}:L${T.line} ${T.text.trim()}`),O.snippet&&C.push(O.snippet);})),re.length===0&&Ve.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 T=new Map;for(let I of re){let R=`${I.file_path}::${I.callee_name}`;T.has(R)||T.set(R,I);}for(let[,I]of T){let R=String(I.callee_name||""),O=String(I.file_path||""),$=Vn(R,O);$.length!==0&&(Le+=1,$.slice(0,3).forEach(j=>{let ee=j.file!==O?` \u2197 \u8DE8\u6587\u4EF6: ${j.file}`:"";C.push(` \u94FE\u8DEF: ${j.path.join(" \u2192 ")}${ee}`),j.behaviors.forEach(Y=>{let pe=Y.detail?`("${String(Y.detail)}")`:"";C.push(` \u843D\u70B9: ${Y.api_name}.${Y.operation}${pe} [${Y.category}] L${Y.line_number}`);});}));}Le===0&&Ve.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 Jn=y.length>0?` (\u542B ${y.length} \u4E2A\u522B\u540D: ${y.slice(0,3).map(T=>`"${T}"`).join(", ")})`:"";C.push(`\u2705 \u6C47\u603B${Jn}:`),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: ${y.map(T=>`"${T}"`).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: ${Le>0?`\u2713 \u53D1\u73B0\u5199\u5165\u94FE\u8DEF (${Le} \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 Yn=Math.round((performance.now()-c)*100)/100,Zn=ce.length+X.length+re.length+Pe.length+Le,zt=H({durationMs:Yn,resultCount:Zn,backend:L&&ye?"indexed":L||ye?"hybrid":"fallback_scan"});return f.stale&&(zt.index_freshness=f),C.push(`
594
594
  \u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
595
- ${U(Gt)}`),{content:[{type:"text",text:C.join(`
596
- `)}]}});}function jn(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
595
+ ${U(zt)}`),{content:[{type:"text",text:C.join(`
596
+ `)}]}});}function Mn(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
597
597
  \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
598
598
  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 _=r.getLastIndexedTime();return _?new Date(_).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),f=e.listProjects().find(_=>_.root===s)?.dbPath||"",g=o.dbSize||0,h={dbPath:f,indexedFiles:c,totalSymbols:l,totalRelations:o.relationCount||0,totalBehaviors:o.behaviorCount||0,lastIndexedAt:a,failureCount:o.failureCount||0,failedFiles:p.map(_=>({file:_.file_path,error:_.error})),watcherActive:d,dbSizeBytes:g},b=Math.round((performance.now()-n)*100)/100,S=H({durationMs:b,resultCount:1,backend:"indexed"}),y=[`\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: ${h.indexedFiles}`,` \u{1F523} \u7B26\u53F7\u6570: ${h.totalSymbols}`,` \u{1F517} \u8C03\u7528\u5173\u7CFB: ${h.totalRelations}`,` \u{1F3F7}\uFE0F \u884C\u4E3A\u6807\u7B7E: ${h.totalBehaviors}`,` \u{1F4C5} \u6700\u540E\u7D22\u5F15\u65F6\u95F4: ${h.lastIndexedAt}`,` \u2757 \u5931\u8D25\u6587\u4EF6\u603B\u6570: ${h.failureCount}`,"","\u{1F50C} \u8FD0\u884C\u65F6\u72B6\u6001:",` \u{1F4C2} \u6587\u4EF6\u76D1\u542C: ${h.watcherActive?"\u2705 \u6D3B\u8DC3":"\u274C \u672A\u542F\u52A8"}`,` \u{1F4BE} \u6570\u636E\u5E93\u5927\u5C0F: ${Math.round(h.dbSizeBytes/1024)} KB`,` \u{1F4CD} \u6570\u636E\u5E93\u8DEF\u5F84: ${h.dbPath||"\uFF08\u5185\u5B58\uFF09"}`,"","\u{1F4A1} \u5EFA\u8BAE:"];if(h.totalSymbols===0&&h.indexedFiles>0?y.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"):h.indexedFiles===0?y.push(" \u274C \u5C1A\u672A\u7D22\u5F15 \u2014 \u8FD0\u884C skimmer_index_project \u5F00\u59CB\u7D22\u5F15"):y.push(" \u2705 \u7D22\u5F15\u72B6\u6001\u6B63\u5E38"),!h.watcherActive&&h.indexedFiles>0&&y.push(" \u{1F4A1} \u6587\u4EF6\u76D1\u542C\u672A\u542F\u52A8 \u2014 \u8FD0\u884C skimmer_index_project \u53EF\u81EA\u52A8\u5F00\u542F"),h.failedFiles.length>0){y.push(""),y.push("\u26A0\uFE0F \u6700\u8FD1\u5931\u8D25\u6587\u4EF6\u6837\u672C:");for(let _ of h.failedFiles.slice(0,5))y.push(` - ${_.file}: ${_.error}`);}return y.push(""),y.push("\u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500"),y.push(U(S)),{content:[{type:"text",text:y.join(`
599
- `)}]}});}var rs="\u9879\u76EE\u6839\u76EE\u5F55\uFF08\u53EF\u7701\u7565\uFF0C\u4F7F\u7528\u4E0A\u6B21\u7D22\u5F15\u7684\u9879\u76EE\uFF09";function Un(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
600
- \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(rs),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 f=e.listProjects(),g=Math.round((performance.now()-r)*100)/100,h=H({durationMs:g,resultCount:f.length,backend:"indexed"});if(f.length===0)return {content:[{type:"text",text:`\u{1F4CB} \u5F53\u524D\u6CA1\u6709\u5DF2\u7D22\u5F15\u7684\u9879\u76EE
599
+ `)}]}});}var ss="\u9879\u76EE\u6839\u76EE\u5F55\uFF08\u53EF\u7701\u7565\uFF0C\u4F7F\u7528\u4E0A\u6B21\u7D22\u5F15\u7684\u9879\u76EE\uFF09";function jn(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
600
+ \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(ss),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 f=e.listProjects(),g=Math.round((performance.now()-r)*100)/100,h=H({durationMs:g,resultCount:f.length,backend:"indexed"});if(f.length===0)return {content:[{type:"text",text:`\u{1F4CB} \u5F53\u524D\u6CA1\u6709\u5DF2\u7D22\u5F15\u7684\u9879\u76EE
601
601
 
602
602
  \u4F7F\u7528 skimmer_index_project({ project_path: "/your/project" }) \u5F00\u59CB\u7D22\u5F15
603
603
 
@@ -609,15 +609,15 @@ ${U(h)}`),{content:[{type:"text",text:b.join(`
609
609
  `)}]}}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 f={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(` ${f[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((f,g)=>{c.push(` ${g+1}. ${f.path} (${f.line_count} \u884C, ${f.symbol_count} \u7B26\u53F7)`);}),c.push(""));let d=a.behaviorStats;if(d?.length){let f={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(` ${f[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,m=H({durationMs:u,resultCount:1,backend:"indexed"});return c.push(`
610
610
  \u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
611
611
  ${U(m)}`),{content:[{type:"text",text:c.join(`
612
- `)}]}});}var he=new pt;function cs(){let i=z__default.dirname(fileURLToPath(import.meta.url)),e=[z__default.resolve(i,"../package.json"),z__default.resolve(i,"../../package.json")];for(let t of e)try{let n=JSON.parse(Q__default.readFileSync(t,"utf-8"));if(typeof n.version=="string"&&n.version.trim())return n.version.trim()}catch{}return "0.4.4"}var Wn=cs(),$e=new McpServer({name:"frontend-code-skimmer",version:Wn});kn($e,he);vn($e,he);Dn($e,he);jn($e,he);Un($e,he);async function ls(){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}
612
+ `)}]}});}function Wn(i){let e=[z__default.resolve(i,"../package.json"),z__default.resolve(i,"../../package.json")];for(let t of e)try{let n=JSON.parse(Q__default.readFileSync(t,"utf-8"));if(typeof n.version=="string"&&n.version.trim())return n.version.trim()}catch{}return "0.0.0-dev"}var he=new pt,Hn=Wn(z__default.dirname(fileURLToPath(import.meta.url))),$e=new McpServer({name:"frontend-code-skimmer",version:Hn});Rn($e,he);wn($e,he);Fn($e,he);Mn($e,he);jn($e,he);async function ps(){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}
613
613
  `);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
614
614
  `);let o=await r.startWatcher();he.registerWatcher(n,o),process.stderr.write(`[Frontend-Code-Skimmer] \u6587\u4EF6\u76D1\u542C\u5DF2\u542F\u52A8: ${n}
615
615
  `);}catch(n){process.stderr.write(`[Frontend-Code-Skimmer] \u7D22\u5F15\u5931\u8D25: ${String(n)}
616
- `);}}let e=new StdioServerTransport;await $e.connect(e),process.stderr.write(`[Frontend-Code-Skimmer MCP] \u5DF2\u542F\u52A8 (v${Wn})
616
+ `);}}let e=new StdioServerTransport;await $e.connect(e),process.stderr.write(`[Frontend-Code-Skimmer MCP] \u5DF2\u542F\u52A8 (v${Hn})
617
617
  `),process.stderr.write(`[Frontend-Code-Skimmer MCP] \u652F\u6301\u6846\u67B6: Vue 2 / Vue 3 / React Hooks
618
618
  `),process.stderr.write(`[Frontend-Code-Skimmer MCP] \u652F\u6301\u7CBE\u5EA6: heuristic / precise (\u8DE8\u6587\u4EF6 import \u7ED1\u5B9A)
619
619
  `),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
620
620
  `),process.env.SKIMMER_PROJECT?process.stderr.write(`[Frontend-Code-Skimmer MCP] \u9ED8\u8BA4\u9879\u76EE: ${process.env.SKIMMER_PROJECT}
621
621
  `):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
622
- `);let t=()=>{he.closeAll(),process.exit(0);};process.on("SIGINT",t),process.on("SIGTERM",t);}ls().catch(i=>{process.stderr.write(`[Frontend-Code-Skimmer MCP] \u542F\u52A8\u5931\u8D25: ${String(i)}
622
+ `);let t=()=>{he.closeAll(),process.exit(0);};process.on("SIGINT",t),process.on("SIGTERM",t);}ps().catch(i=>{process.stderr.write(`[Frontend-Code-Skimmer MCP] \u542F\u52A8\u5931\u8D25: ${String(i)}
623
623
  `),process.exit(1);});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jokeran/frontend-code-skimmer",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "Frontend-Code-Skimmer: 不读全文,只看骨架;不搜字符,搜语义关联。支持 Vue2/Vue3/React Hooks",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",