@jokeran/frontend-code-skimmer 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +24 -24
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import*as K from'path';import K__default from'path';import Kr from'os';import*as Z from'fs';import Z__default from'fs';import qn,{createHash}from'crypto';import tr from'better-sqlite3';import Xr from'fast-glob';import {createRequire}from'module';import {z as z$1}from'zod';function Ve(i){switch(i){case "template_event":return "template_event";case "jsx_event":return "jsx_event";case "hook_call":return "hook_call";case "import_func":return "import_call";default:return "method_call"}}function k(i){return i.replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/_/g," ").replace(/-/g," ").toLowerCase().trim().replace(/\s+/g," ")}function ze(i,e){let t=i.length,n=e.length,r=Array.from({length:t+1},(s,o)=>Array.from({length:n+1},(a,c)=>o===0?c:c===0?o:0));for(let s=1;s<=t;s++)for(let o=1;o<=n;o++)i[s-1]===e[o-1]?r[s][o]=r[s-1][o-1]:r[s][o]=1+Math.min(r[s-1][o],r[s][o-1],r[s-1][o-1]);return r[t][n]}function Fe(i){return qn.createHash("md5").update(i).digest("hex")}function Ge(i){if(!i)return 0;let e=1;for(let t=0;t<i.length;t++)i[t]===`
3
3
  `&&e++;return e}function ke(i,e){return i===e?`L${i}`:`L${i}-L${e}`}function de(i,e){return K__default.relative(e,i).replace(/\\/g,"/")}function De(i,e){if(!i)return e;try{return JSON.parse(i)}catch{return e}}function V(i,e){let t=i.split(`
4
- `),r=e-1-1;for(;r>=0&&t[r].trim()==="";)r--;if(r<0||!t[r].trim().endsWith("*/"))return;let s=r;for(;s>0&&!t[s].trim().startsWith("/**");)s--;if(t[s].trim().startsWith("/**"))return t.slice(s,r+1).map(o=>o.replace(/^\s*\*\s?/,"").replace(/\/\*\*/,"").replace(/\*\//,"").trim()).filter(o=>o.length>0).join(" ")}function zt(i,e){let t=i.toLowerCase(),n=e.toLowerCase();if(t===n)return 100;if(n.includes(t)||t.includes(n))return 85;let r=ze(t,n),s=Math.max(t.length,n.length);if(s===0)return 100;let o=Math.max(0,100-r/s*100);return Math.round(o)}function be(i){return i.startsWith("use")&&i.length>3&&/[A-Z]/.test(i[3])}function Gt(i,e,t){if(t===0||t>3)return;let n=k(i).split(" "),r=k(e).split(" ");for(let s of n)for(let o of r){let a=ze(s,o);if(a>0&&a<=3&&s!==o)return `"${s}" \u53EF\u80FD\u662F "${o}" \u7684\u62FC\u5199\u9519\u8BEF (\u7F16\u8F91\u8DDD\u79BB=${a})`}}var Yn=[".ts",".tsx",".js",".jsx",".vue"],Zn=["index.ts","index.tsx","index.js","index.jsx","index.vue"];function Qn(i){return [...Yn.map(e=>`${i}${e}`),...Zn.map(e=>K.join(i,e))]}function Te(i){if(Z.existsSync(i))try{if(Z.statSync(i).isFile())return i}catch{}for(let e of Qn(i))if(Z.existsSync(e))return e;return i}var bt=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**","**/.nuxt/**","**/.next/**","**/__tests__/**","**/*.test.*","**/*.spec.*","**/*.min.js"],Et=["**/*.vue","**/*.js","**/*.jsx","**/*.ts","**/*.tsx"],Jt={storage:{localStorage:["setItem","getItem","removeItem","clear","key"],sessionStorage:["setItem","getItem","removeItem","clear","key"],cookie:["cookie"]},network:{axios:["get","post","put","delete","patch","request","create"],fetch:["fetch"],XMLHttpRequest:["open","send"],$http:["get","post","put","delete"]},router:{$router:["push","replace","go","back","forward"],$route:[],useRouter:[],useRoute:[],navigate:[],history:["push","replace","go"]},vuex:{$store:["commit","dispatch","getters","state"],useStore:[],store:["commit","dispatch"]},dom:{document:["querySelector","getElementById","createElement","addEventListener"],window:["addEventListener","removeEventListener","open","close"],$refs:[],$nextTick:[],nextTick:[]},event:{$emit:[],EventBus:["emit","on","off"],dispatchEvent:[],emit:[]},timer:{setTimeout:[],setInterval:[],clearTimeout:[],clearInterval:[],requestAnimationFrame:[]},i18n:{$t:[],useI18n:[],t:[],i18n:["t","tc","te"]}},_t=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","activated","deactivated","errorCaptured"],Nt=["onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","onActivated","onDeactivated","onErrorCaptured","onRenderTracked","onRenderTriggered","onServerPrefetch"],Yt=["ref","reactive","shallowRef","shallowReactive","readonly"],Zt=["computed"],Qt=["watch","watchEffect","watchPostEffect","watchSyncEffect"],Tt=["useState","useReducer","useRef","useImperativeHandle"],St=["useMemo","useCallback"],xt=["useEffect","useLayoutEffect","useInsertionEffect"],en=["useContext","useDebugValue","useDeferredValue","useId","useSyncExternalStore","useTransition"],qe=".skimmer-index.db",tn=30,nn=4,rn=300;var er=[{version:1,description:"\u5EFA\u7ACB schema_version \u8868",statements:[`CREATE TABLE IF NOT EXISTS schema_version (
4
+ `),r=e-1-1;for(;r>=0&&t[r].trim()==="";)r--;if(r<0||!t[r].trim().endsWith("*/"))return;let s=r;for(;s>0&&!t[s].trim().startsWith("/**");)s--;if(t[s].trim().startsWith("/**"))return t.slice(s,r+1).map(o=>o.replace(/^\s*\*\s?/,"").replace(/\/\*\*/,"").replace(/\*\//,"").trim()).filter(o=>o.length>0).join(" ")}function zt(i,e){let t=i.toLowerCase(),n=e.toLowerCase();if(t===n)return 100;if(n.includes(t)||t.includes(n))return 85;let r=ze(t,n),s=Math.max(t.length,n.length);if(s===0)return 100;let o=Math.max(0,100-r/s*100);return Math.round(o)}function be(i){return i.startsWith("use")&&i.length>3&&/[A-Z]/.test(i[3])}function Gt(i,e,t){if(t===0||t>3)return;let n=k(i).split(" "),r=k(e).split(" ");for(let s of n)for(let o of r){let a=ze(s,o);if(a>0&&a<=3&&s!==o)return `"${s}" \u53EF\u80FD\u662F "${o}" \u7684\u62FC\u5199\u9519\u8BEF (\u7F16\u8F91\u8DDD\u79BB=${a})`}}var Yn=[".ts",".tsx",".js",".jsx",".vue"],Zn=["index.ts","index.tsx","index.js","index.jsx","index.vue"];function Qn(i){return [...Yn.map(e=>`${i}${e}`),...Zn.map(e=>K.join(i,e))]}function Te(i){if(Z.existsSync(i))try{if(Z.statSync(i).isFile())return i}catch{}for(let e of Qn(i))if(Z.existsSync(e))return e;return i}var Et=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**","**/.nuxt/**","**/.next/**","**/__tests__/**","**/*.test.*","**/*.spec.*","**/*.min.js"],_t=["**/*.vue","**/*.js","**/*.jsx","**/*.ts","**/*.tsx"],Jt={storage:{localStorage:["setItem","getItem","removeItem","clear","key"],sessionStorage:["setItem","getItem","removeItem","clear","key"],cookie:["cookie"]},network:{axios:["get","post","put","delete","patch","request","create"],fetch:["fetch"],XMLHttpRequest:["open","send"],$http:["get","post","put","delete"]},router:{$router:["push","replace","go","back","forward"],$route:[],useRouter:[],useRoute:[],navigate:[],history:["push","replace","go"]},vuex:{$store:["commit","dispatch","getters","state"],useStore:[],store:["commit","dispatch"]},dom:{document:["querySelector","getElementById","createElement","addEventListener"],window:["addEventListener","removeEventListener","open","close"],$refs:[],$nextTick:[],nextTick:[]},event:{$emit:[],EventBus:["emit","on","off"],dispatchEvent:[],emit:[]},timer:{setTimeout:[],setInterval:[],clearTimeout:[],clearInterval:[],requestAnimationFrame:[]},i18n:{$t:[],useI18n:[],t:[],i18n:["t","tc","te"]}},Nt=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","activated","deactivated","errorCaptured"],Tt=["onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","onActivated","onDeactivated","onErrorCaptured","onRenderTracked","onRenderTriggered","onServerPrefetch"],Yt=["ref","reactive","shallowRef","shallowReactive","readonly"],Zt=["computed"],Qt=["watch","watchEffect","watchPostEffect","watchSyncEffect"],St=["useState","useReducer","useRef","useImperativeHandle"],xt=["useMemo","useCallback"],At=["useEffect","useLayoutEffect","useInsertionEffect"],en=["useContext","useDebugValue","useDeferredValue","useId","useSyncExternalStore","useTransition"],qe=".skimmer-index.db",tn=30,nn=4,rn=300;var er=[{version:1,description:"\u5EFA\u7ACB schema_version \u8868",statements:[`CREATE TABLE IF NOT EXISTS schema_version (
5
5
  version INTEGER PRIMARY KEY,
6
6
  applied_at INTEGER NOT NULL,
7
7
  description TEXT
@@ -402,43 +402,43 @@ import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {StdioSer
402
402
  JOIN symbols s ON r.caller_id = s.id
403
403
  JOIN files f ON s.file_id = f.id
404
404
  WHERE r.callee_name_lc = ?
405
- `,s=[e.toLowerCase()];return t&&(r+=" AND f.path_lc LIKE ?",s.push(`%${t.toLowerCase()}%`)),n&&(r+=" AND LOWER(COALESCE(r.args, '')) LIKE LOWER(?)",s.push(`%${n}%`)),r+=" ORDER BY f.path, r.line_number",this.db.prepare(r).all(...s)}close(){this.db.close();}};function G(i,e,t,n=false){let r=[];return z(i,o=>{if(n&&o!==i&&(o.type==="FunctionDeclaration"||o.type==="ArrowFunctionExpression"||o.type==="FunctionExpression"||o.type==="ClassDeclaration"))return false;if(o.type==="CallExpression"){let c=ir(o,e);c&&r.push(c);}if(o.type==="MemberExpression"){let a=or(o);a&&r.push(a);}}),fr(r)}function ir(i,e,t){let n=i.callee;if(!n)return null;let r=At(i);if(n.type==="MemberExpression"){let s=ar(n);if(!s)return null;let{apiName:o,operation:a}=s,c=i.arguments,l=te(c?.[0]),p=dr(o);return p?{symbolName:e,category:p,apiName:o,operation:a,detail:l,line:r}:o==="this"&&Ye(a)?{symbolName:e,category:"network",apiName:`this.${a}`,operation:"wrapped_call",detail:l||te(c?.[1]),line:r}:on(a)&&ur(c)?{symbolName:e,category:"network",apiName:o,operation:a,detail:l||te(c?.[1]),line:r}:Ye(o)||Ye(`${o}.${a}`)?{symbolName:e,category:"network",apiName:o,operation:on(a)?a:"wrapped_call",detail:l||te(c?.[1]),line:r}:null}if(n.type==="Identifier"){let s=n.name,o=cr(s),a=i.arguments,c=te(a?.[0]);return o?{symbolName:e,category:o.category,apiName:s,operation:o.operation,detail:c,line:r}:Ye(s)?{symbolName:e,category:"network",apiName:s,operation:"wrapped_call",detail:c||te(a?.[1]),line:r}:null}return null}function or(i,e,t){let n=i.object,r=i.property;if(!n||!r||n.type!=="MemberExpression"&&n.type!=="ThisExpression"&&n.type!=="Identifier")return null;let s=pr(n);if(!s)return null;r.type==="Identifier"?r.name:"";if(s==="this"||s===""){n.type==="MemberExpression"?n.property?.name:"";return null}return null}function ar(i){let e=i.object,t=i.property;if(!e||!t||t.type!=="Identifier")return null;let n=t.name;if(e.type==="MemberExpression"){let r=e.property?.name;if(r)return {apiName:r,operation:n}}return e.type==="Identifier"?{apiName:e.name,operation:n}:e.type==="ThisExpression"?{apiName:"this",operation:n}:null}function cr(i){let e={fetch:"network",setTimeout:"timer",setInterval:"timer",clearTimeout:"timer",clearInterval:"timer",requestAnimationFrame:"timer",navigate:"router"};return e[i]?{category:e[i],operation:i}:null}function At(i){return i.loc?.start?.line??0}function lr(i){let e=i.loc;return {line:e?.start?.line??0,column:e?.start?.column??0}}function pr(i){return i.type==="Identifier"?i.name:i.type==="ThisExpression"?"this":null}function dr(i){if(i==="this")return null;for(let[e,t]of Object.entries(Jt))if(i in t)return e;return null}function te(i,e){if(i){if(i.type==="Literal"||i.type==="StringLiteral"||i.type==="NumericLiteral"||i.type==="BooleanLiteral")return String(i.value);if(i.type==="NullLiteral")return "null";if(i.type==="TemplateLiteral"){let t=i.quasis,n=i.expressions||[],r=[];for(let o=0;o<t.length;o++){let a=t[o].value?.cooked||"";if(a&&r.push(a),o<n.length){let c=Ze(n[o])||"expr";r.push(`\${${c}}`);}}return r.join("")||"${expr}"}if(i.type==="Identifier")return `[\u53D8\u91CF: ${i.name}]`;if(i.type==="ObjectExpression"){let t=i.properties||[],n=["url","uri","path","api","endpoint"];for(let r of t){let s=r.key,o=r.value;if(!s||!o)continue;let a=s.type==="Identifier"?String(s.name):s.type==="Literal"?String(s.value):"";if(!n.includes(a))continue;let c=te(o);if(c)return `${a}:${c}`}return "{...}"}}}function Ze(i,e){if(!i)return;if(i.type==="Identifier")return i.name;if(i.type==="ThisExpression")return "this";if(i.type==="Literal"||i.type==="StringLiteral"||i.type==="NumericLiteral"||i.type==="BooleanLiteral")return String(i.value);if(i.type==="NullLiteral")return "null";if(i.type==="MemberExpression"){let n=Ze(i.object)||"obj",r=i.property,s=r?.type==="Identifier"?String(r.name):Ze(r)||"prop";return i.computed?`${n}[${s}]`:`${n}.${s}`}if(i.type==="CallExpression")return `${Ze(i.callee)||"fn"}(...)`;if(i.type==="TemplateLiteral")return te(i);let t=te(i);return t?.startsWith("[\u53D8\u91CF: ")?t.replace(/^\[变量: /,"").replace(/\]$/,""):t}function Ye(i){return /request|api|http|fetch|ajax|akscommonhandle|commonhandle/i.test(i)}function on(i){return ["get","post","put","delete","patch","request"].includes(i.toLowerCase())}function ur(i,e){if(!i||i.length===0)return false;for(let t of i.slice(0,2)){let n=te(t);if(n&&(/https?:\/\//i.test(n)||n.includes("/")||/gw\d?\/|\/m\/|\/api\//i.test(n)))return true}return false}function fr(i){let e=new Set;return i.filter(t=>{let n=`${t.apiName}:${t.operation}:${t.line}`;return e.has(n)?false:(e.add(n),true)})}function we(i,e,t){let n=[];return z(i,r=>{if(r.type==="CallExpression"&&r.callee?.type==="MemberExpression"){let s=r.callee,o=s.object,a=s.property;if(o.type==="ThisExpression"&&a.type==="Identifier"){let c=a.name;if(!c.startsWith("$")&&c!==e){let l=r.arguments,p=an(l);n.push({calleeName:c,line:At(r),args:p});}}}}),n}function ne(i,e,t,n=false){let r=[];return z(i,o=>{if(n&&o!==i&&(o.type==="FunctionDeclaration"||o.type==="ArrowFunctionExpression"||o.type==="FunctionExpression"||o.type==="ClassDeclaration"))return false;if(o.type==="CallExpression"&&o.callee?.type==="Identifier"){let a=o.callee.name;if(a!==e&&!mr(a)){let c=o.arguments,l=an(c);r.push({calleeName:a,line:At(o),args:l});}}}),r}function mr(i){return /^(useState|useEffect|useMemo|useCallback|useRef|useContext|useReducer|ref|reactive|computed|watch|watchEffect|console|setTimeout|setInterval|Math|Object|Array|JSON|String|Number|Boolean|Promise|require|import)$/.test(i)}function an(i,e){if(!i||i.length===0)return;let t=i.slice(0,3).map(n=>te(n)).filter(n=>!!n);return t.length>0?t.join(", "):void 0}function z(i,e){if(!(!i||typeof i!="object")&&e(i)!==false)for(let t of Object.keys(i)){if(t==="type"||t==="loc"||t==="start"||t==="end")continue;let n=i[t];if(Array.isArray(n))for(let r of n)r&&typeof r=="object"&&r.type&&z(r,e);else n&&typeof n=="object"&&n.type&&z(n,e);}}function Qe(i,e){let t=[],n=new Set,r=i.split(`
405
+ `,s=[e.toLowerCase()];return t&&(r+=" AND f.path_lc LIKE ?",s.push(`%${t.toLowerCase()}%`)),n&&(r+=" AND LOWER(COALESCE(r.args, '')) LIKE LOWER(?)",s.push(`%${n}%`)),r+=" ORDER BY f.path, r.line_number",this.db.prepare(r).all(...s)}close(){this.db.close();}};function G(i,e,t,n=false){let r=[];return z(i,o=>{if(n&&o!==i&&(o.type==="FunctionDeclaration"||o.type==="ArrowFunctionExpression"||o.type==="FunctionExpression"||o.type==="ClassDeclaration"))return false;if(o.type==="CallExpression"){let c=ir(o,e);c&&r.push(c);}if(o.type==="MemberExpression"){let a=or(o);a&&r.push(a);}}),fr(r)}function ir(i,e,t){let n=i.callee;if(!n)return null;let r=Lt(i);if(n.type==="MemberExpression"){let s=ar(n);if(!s)return null;let{apiName:o,operation:a}=s,c=i.arguments,l=te(c?.[0]),p=dr(o);return p?{symbolName:e,category:p,apiName:o,operation:a,detail:l,line:r}:o==="this"&&Ye(a)?{symbolName:e,category:"network",apiName:`this.${a}`,operation:"wrapped_call",detail:l||te(c?.[1]),line:r}:on(a)&&ur(c)?{symbolName:e,category:"network",apiName:o,operation:a,detail:l||te(c?.[1]),line:r}:Ye(o)||Ye(`${o}.${a}`)?{symbolName:e,category:"network",apiName:o,operation:on(a)?a:"wrapped_call",detail:l||te(c?.[1]),line:r}:null}if(n.type==="Identifier"){let s=n.name,o=cr(s),a=i.arguments,c=te(a?.[0]);return o?{symbolName:e,category:o.category,apiName:s,operation:o.operation,detail:c,line:r}:Ye(s)?{symbolName:e,category:"network",apiName:s,operation:"wrapped_call",detail:c||te(a?.[1]),line:r}:null}return null}function or(i,e,t){let n=i.object,r=i.property;if(!n||!r||n.type!=="MemberExpression"&&n.type!=="ThisExpression"&&n.type!=="Identifier")return null;let s=pr(n);if(!s)return null;r.type==="Identifier"?r.name:"";if(s==="this"||s===""){n.type==="MemberExpression"?n.property?.name:"";return null}return null}function ar(i){let e=i.object,t=i.property;if(!e||!t||t.type!=="Identifier")return null;let n=t.name;if(e.type==="MemberExpression"){let r=e.property?.name;if(r)return {apiName:r,operation:n}}return e.type==="Identifier"?{apiName:e.name,operation:n}:e.type==="ThisExpression"?{apiName:"this",operation:n}:null}function cr(i){let e={fetch:"network",setTimeout:"timer",setInterval:"timer",clearTimeout:"timer",clearInterval:"timer",requestAnimationFrame:"timer",navigate:"router"};return e[i]?{category:e[i],operation:i}:null}function Lt(i){return i.loc?.start?.line??0}function lr(i){let e=i.loc;return {line:e?.start?.line??0,column:e?.start?.column??0}}function pr(i){return i.type==="Identifier"?i.name:i.type==="ThisExpression"?"this":null}function dr(i){if(i==="this")return null;for(let[e,t]of Object.entries(Jt))if(i in t)return e;return null}function te(i,e){if(i){if(i.type==="Literal"||i.type==="StringLiteral"||i.type==="NumericLiteral"||i.type==="BooleanLiteral")return String(i.value);if(i.type==="NullLiteral")return "null";if(i.type==="TemplateLiteral"){let t=i.quasis,n=i.expressions||[],r=[];for(let o=0;o<t.length;o++){let a=t[o].value?.cooked||"";if(a&&r.push(a),o<n.length){let c=Ze(n[o])||"expr";r.push(`\${${c}}`);}}return r.join("")||"${expr}"}if(i.type==="Identifier")return `[\u53D8\u91CF: ${i.name}]`;if(i.type==="ObjectExpression"){let t=i.properties||[],n=["url","uri","path","api","endpoint"];for(let r of t){let s=r.key,o=r.value;if(!s||!o)continue;let a=s.type==="Identifier"?String(s.name):s.type==="Literal"?String(s.value):"";if(!n.includes(a))continue;let c=te(o);if(c)return `${a}:${c}`}return "{...}"}}}function Ze(i,e){if(!i)return;if(i.type==="Identifier")return i.name;if(i.type==="ThisExpression")return "this";if(i.type==="Literal"||i.type==="StringLiteral"||i.type==="NumericLiteral"||i.type==="BooleanLiteral")return String(i.value);if(i.type==="NullLiteral")return "null";if(i.type==="MemberExpression"){let n=Ze(i.object)||"obj",r=i.property,s=r?.type==="Identifier"?String(r.name):Ze(r)||"prop";return i.computed?`${n}[${s}]`:`${n}.${s}`}if(i.type==="CallExpression")return `${Ze(i.callee)||"fn"}(...)`;if(i.type==="TemplateLiteral")return te(i);let t=te(i);return t?.startsWith("[\u53D8\u91CF: ")?t.replace(/^\[变量: /,"").replace(/\]$/,""):t}function Ye(i){return /request|api|http|fetch|ajax|akscommonhandle|commonhandle/i.test(i)}function on(i){return ["get","post","put","delete","patch","request"].includes(i.toLowerCase())}function ur(i,e){if(!i||i.length===0)return false;for(let t of i.slice(0,2)){let n=te(t);if(n&&(/https?:\/\//i.test(n)||n.includes("/")||/gw\d?\/|\/m\/|\/api\//i.test(n)))return true}return false}function fr(i){let e=new Set;return i.filter(t=>{let n=`${t.apiName}:${t.operation}:${t.line}`;return e.has(n)?false:(e.add(n),true)})}function we(i,e,t){let n=[];return z(i,r=>{if(r.type==="CallExpression"&&r.callee?.type==="MemberExpression"){let s=r.callee,o=s.object,a=s.property;if(o.type==="ThisExpression"&&a.type==="Identifier"){let c=a.name;if(!c.startsWith("$")&&c!==e){let l=r.arguments,p=an(l);n.push({calleeName:c,line:Lt(r),args:p});}}}}),n}function ne(i,e,t,n=false){let r=[];return z(i,o=>{if(n&&o!==i&&(o.type==="FunctionDeclaration"||o.type==="ArrowFunctionExpression"||o.type==="FunctionExpression"||o.type==="ClassDeclaration"))return false;if(o.type==="CallExpression"&&o.callee?.type==="Identifier"){let a=o.callee.name;if(a!==e&&!mr(a)){let c=o.arguments,l=an(c);r.push({calleeName:a,line:Lt(o),args:l});}}}),r}function mr(i){return /^(useState|useEffect|useMemo|useCallback|useRef|useContext|useReducer|ref|reactive|computed|watch|watchEffect|console|setTimeout|setInterval|Math|Object|Array|JSON|String|Number|Boolean|Promise|require|import)$/.test(i)}function an(i,e){if(!i||i.length===0)return;let t=i.slice(0,3).map(n=>te(n)).filter(n=>!!n);return t.length>0?t.join(", "):void 0}function z(i,e){if(!(!i||typeof i!="object")&&e(i)!==false)for(let t of Object.keys(i)){if(t==="type"||t==="loc"||t==="start"||t==="end")continue;let n=i[t];if(Array.isArray(n))for(let r of n)r&&typeof r=="object"&&r.type&&z(r,e);else n&&typeof n=="object"&&n.type&&z(n,e);}}function Qe(i,e){let t=[],n=new Set,r=i.split(`
406
406
  `);for(let s=0;s<r.length;s++){let o=/(?:@|v-on:)[a-z][a-z0-9-]*(?:\.[a-z-]+)*="([^"]+)"/g,a;for(;(a=o.exec(r[s]))!==null;){let l=a[1].trim().match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)(?:\([^)]*\))?$/);if(!l)continue;let p=l[1];if(p.startsWith("$"))continue;let d=e+s,u=`${p}:${d}:${a.index}`;n.has(u)||(n.add(u),t.push({calleeName:p,line:d}));}}return t}function cn(i,e){let t=[],n=new Set;return z(i,r=>{if(r.type!=="JSXAttribute")return;let s=r.name,o=r.value;if(!s||!o)return;let a=s.type==="JSXIdentifier"?String(s.name):"";if(!/^on[A-Z]/.test(a)||o.type!=="JSXExpressionContainer")return;let c=o.expression;if(!c)return;let l;if(c.type==="Identifier")l=c.name;else if(c.type==="MemberExpression"){let f=c.property?.name;f&&!/^\$/.test(f)&&(l=f);}let{line:p,column:d}=lr(r),u=`${l}:${p}:${d}`;!l||n.has(u)||(n.add(u),t.push({calleeName:l,line:p}));}),t}var hr=createRequire(import.meta.url),ln=false;function yr(i){ln||(ln=true,process.stderr.write(`[Frontend-Code-Skimmer] precise import graph \u5DF2\u964D\u7EA7: ${String(i)}
407
- `));}function pn(i,e,t){let n={filePath:i,imports:[],exports:[]};try{let r=hr("typescript"),s=r.createSourceFile(i,e,r.ScriptTarget.Latest,!0);r.forEachChild(s,o=>{if(r.isImportDeclaration(o)){let a=o.moduleSpecifier;if(!a||!r.isStringLiteral(a))return;let c=a.text,l=tt(i,c),p=o.importClause;if(!p){n.imports.push({localName:"",originalName:"",modulePath:c,resolvedFile:l,isDefault:!1,isReExport:!1});return}let d=p.namedBindings;if(d&&r.isNamedImports(d))for(let u of d.elements){let f=u.propertyName?u.propertyName.text:u.name.text;n.imports.push({localName:u.name.text,originalName:f,modulePath:c,resolvedFile:l,isDefault:!1,isReExport:!1});}d&&r.isNamespaceImport(d)&&n.imports.push({localName:d.name.text,originalName:"*",modulePath:c,resolvedFile:l,isDefault:!1,isReExport:!1}),p.name&&n.imports.push({localName:p.name.text,originalName:"default",modulePath:c,resolvedFile:l,isDefault:!0,isReExport:!1});}if(r.isExportDeclaration(o)){let a=o.moduleSpecifier;if(a&&r.isStringLiteral(a)){let c=a.text,l=o.exportClause;if(l&&r.isNamedExports(l))for(let p of l.elements)n.exports.push({name:p.name.text,isDefault:!1,source:"re_export",reExportFrom:c});}else if(o.exportClause){let c=o.exportClause;if(r.isNamedExports(c))for(let l of c.elements)n.exports.push({name:l.name.text,isDefault:!1,source:"local"});}}if(r.isExportAssignment(o)&&(o.isExportEquals||n.exports.push({name:"default",isDefault:!0,source:"local"})),(r.isFunctionDeclaration(o)||r.isVariableStatement(o)||r.isClassDeclaration(o))&&o.modifiers?.some(a=>a.kind===r.SyntaxKind.ExportKeyword)){if(r.isFunctionDeclaration(o)&&o.name)n.exports.push({name:o.name.text,isDefault:o.name.text==="default",source:"local"});else if(r.isClassDeclaration(o)&&o.name)n.exports.push({name:o.name.text,isDefault:o.name.text==="default",source:"local"});else if(r.isVariableStatement(o))for(let a of o.declarationList.declarations)r.isIdentifier(a.name)&&n.exports.push({name:a.name.text,isDefault:!1,source:"local"});}});}catch(r){yr(r);}return n}function tt(i,e){let t=K.dirname(i);if(e.startsWith(".")){let n=K.resolve(t,e);return Te(n)}return e.startsWith("@/")?br(i,e):e}function br(i,e){let t=K.dirname(i);for(let n=0;n<10;n++){let r=K.join(t,"src");if(Z.existsSync(r)&&Z.statSync(r).isDirectory()){let o=K.join(r,e.replace(/^@\//,""));return Te(o)}let s=K.dirname(t);if(s===t)break;t=s;}return e}function H(i){return {callerName:i.callerName,callerLine:i.callerLine,callerKey:i.callerKey,calleeName:i.calleeName,callType:i.callType,line:i.line,args:i.args,sourceKind:Ve(i.callType),importSource:i.importSource,receiverToken:i.receiverToken,edgeKind:i.edgeKind||"heuristic"}}function fe(i,e){let t=[];for(let n of i){let r=n.type;if(r==="ImportDeclaration"){let s=n.source,o=n.loc;s?.value&&t.push({fromFile:e,toFile:tt(e,s.value),dependencyKind:"import",line:o?.start?.line??1});}if(r==="ExportNamedDeclaration"||r==="ExportAllDeclaration"){let s=n.source,o=n.loc;s?.value&&t.push({fromFile:e,toFile:tt(e,s.value),dependencyKind:"re_export",line:o?.start?.line??1});}}return t}function rt(i,e){let t=new Map(e.map(r=>[r.name,r])),n=[];for(let r of i){let s=r.type;if(s==="ExportNamedDeclaration"){let o=r.declaration,a=r.source;if(o){if(o.type==="FunctionDeclaration"||o.type==="ClassDeclaration"){let c=o.id;c?.name&&n.push(nt(c.name,t.get(c.name)));}else if(o.type==="VariableDeclaration")for(let c of o.declarations||[]){let l=c.id;l?.type==="Identifier"&&l.name&&n.push(nt(l.name,t.get(l.name)));}continue}for(let c of r.specifiers||[]){let l=Lt(c.local),p=Lt(c.exported)||l;p&&(a?.value?n.push(`re_export:${p}:${a.value}`):n.push(nt(p,l?t.get(l):void 0)));}continue}if(s==="ExportAllDeclaration"){let o=r.source;o?.value&&n.push(`re_export_all:${o.value}`);continue}if(s==="ExportDefaultDeclaration"){let o=r.declaration;if(!o){n.push("default:unknown");continue}if(o.type==="Identifier"){let a=Lt(o);n.push(nt("default",a?t.get(a):void 0));continue}if(o.type==="FunctionDeclaration"||o.type==="FunctionExpression"||o.type==="ArrowFunctionExpression"){let a=(o.params||[]).map(c=>Rt(c)).join(", ");n.push(`default:fn(${a})`);continue}if(o.type==="ClassDeclaration"||o.type==="ClassExpression"){n.push("default:class");continue}n.push(`default:${String(o.type||"unknown")}`);}}return n.sort()}function nt(i,e){return `${i}:${Er(e)}`}function Er(i){return i?i.category==="class"?"class":i.signature?`fn${i.signature.replace(/^[^(]*/,"")}`:i.category==="constant"?`const:${i.defaultValue||""}`:i.category:"unknown"}function Lt(i){if(i){if(i.type==="Identifier")return String(i.name||"");if(i.type==="StringLiteral")return String(i.value||"")}}function Rt(i){return i?i.type==="Identifier"?String(i.name||"param"):i.type==="AssignmentPattern"?Rt(i.left):i.type==="RestElement"?Rt(i.argument):"param":"param"}var dn=createRequire(import.meta.url);var ve=class{name="Vue2Parser";canParse(e,t){return e.endsWith(".vue")}parse(e,t){let n={framework:"vue2",filePath:e,symbols:[],relations:[],behaviors:[],errors:[]};try{let s=dn("vue-template-compiler").parseComponent(t);if(!s.script?.content)return n;let o=s.script.content,a=this.getScriptStartLine(t,s.script.start),c=t.split(`
407
+ `));}function pn(i,e,t){let n={filePath:i,imports:[],exports:[]};try{let r=hr("typescript"),s=r.createSourceFile(i,e,r.ScriptTarget.Latest,!0);r.forEachChild(s,o=>{if(r.isImportDeclaration(o)){let a=o.moduleSpecifier;if(!a||!r.isStringLiteral(a))return;let c=a.text,l=tt(i,c),p=o.importClause;if(!p){n.imports.push({localName:"",originalName:"",modulePath:c,resolvedFile:l,isDefault:!1,isReExport:!1});return}let d=p.namedBindings;if(d&&r.isNamedImports(d))for(let u of d.elements){let f=u.propertyName?u.propertyName.text:u.name.text;n.imports.push({localName:u.name.text,originalName:f,modulePath:c,resolvedFile:l,isDefault:!1,isReExport:!1});}d&&r.isNamespaceImport(d)&&n.imports.push({localName:d.name.text,originalName:"*",modulePath:c,resolvedFile:l,isDefault:!1,isReExport:!1}),p.name&&n.imports.push({localName:p.name.text,originalName:"default",modulePath:c,resolvedFile:l,isDefault:!0,isReExport:!1});}if(r.isExportDeclaration(o)){let a=o.moduleSpecifier;if(a&&r.isStringLiteral(a)){let c=a.text,l=o.exportClause;if(l&&r.isNamedExports(l))for(let p of l.elements)n.exports.push({name:p.name.text,isDefault:!1,source:"re_export",reExportFrom:c});}else if(o.exportClause){let c=o.exportClause;if(r.isNamedExports(c))for(let l of c.elements)n.exports.push({name:l.name.text,isDefault:!1,source:"local"});}}if(r.isExportAssignment(o)&&(o.isExportEquals||n.exports.push({name:"default",isDefault:!0,source:"local"})),(r.isFunctionDeclaration(o)||r.isVariableStatement(o)||r.isClassDeclaration(o))&&o.modifiers?.some(a=>a.kind===r.SyntaxKind.ExportKeyword)){if(r.isFunctionDeclaration(o)&&o.name)n.exports.push({name:o.name.text,isDefault:o.name.text==="default",source:"local"});else if(r.isClassDeclaration(o)&&o.name)n.exports.push({name:o.name.text,isDefault:o.name.text==="default",source:"local"});else if(r.isVariableStatement(o))for(let a of o.declarationList.declarations)r.isIdentifier(a.name)&&n.exports.push({name:a.name.text,isDefault:!1,source:"local"});}});}catch(r){yr(r);}return n}function tt(i,e){let t=K.dirname(i);if(e.startsWith(".")){let n=K.resolve(t,e);return Te(n)}return e.startsWith("@/")?br(i,e):e}function br(i,e){let t=K.dirname(i);for(let n=0;n<10;n++){let r=K.join(t,"src");if(Z.existsSync(r)&&Z.statSync(r).isDirectory()){let o=K.join(r,e.replace(/^@\//,""));return Te(o)}let s=K.dirname(t);if(s===t)break;t=s;}return e}function H(i){return {callerName:i.callerName,callerLine:i.callerLine,callerKey:i.callerKey,calleeName:i.calleeName,callType:i.callType,line:i.line,args:i.args,sourceKind:Ve(i.callType),importSource:i.importSource,receiverToken:i.receiverToken,edgeKind:i.edgeKind||"heuristic"}}function fe(i,e){let t=[];for(let n of i){let r=n.type;if(r==="ImportDeclaration"){let s=n.source,o=n.loc;s?.value&&t.push({fromFile:e,toFile:tt(e,s.value),dependencyKind:"import",line:o?.start?.line??1});}if(r==="ExportNamedDeclaration"||r==="ExportAllDeclaration"){let s=n.source,o=n.loc;s?.value&&t.push({fromFile:e,toFile:tt(e,s.value),dependencyKind:"re_export",line:o?.start?.line??1});}}return t}function rt(i,e){let t=new Map(e.map(r=>[r.name,r])),n=[];for(let r of i){let s=r.type;if(s==="ExportNamedDeclaration"){let o=r.declaration,a=r.source;if(o){if(o.type==="FunctionDeclaration"||o.type==="ClassDeclaration"){let c=o.id;c?.name&&n.push(nt(c.name,t.get(c.name)));}else if(o.type==="VariableDeclaration")for(let c of o.declarations||[]){let l=c.id;l?.type==="Identifier"&&l.name&&n.push(nt(l.name,t.get(l.name)));}continue}for(let c of r.specifiers||[]){let l=Rt(c.local),p=Rt(c.exported)||l;p&&(a?.value?n.push(`re_export:${p}:${a.value}`):n.push(nt(p,l?t.get(l):void 0)));}continue}if(s==="ExportAllDeclaration"){let o=r.source;o?.value&&n.push(`re_export_all:${o.value}`);continue}if(s==="ExportDefaultDeclaration"){let o=r.declaration;if(!o){n.push("default:unknown");continue}if(o.type==="Identifier"){let a=Rt(o);n.push(nt("default",a?t.get(a):void 0));continue}if(o.type==="FunctionDeclaration"||o.type==="FunctionExpression"||o.type==="ArrowFunctionExpression"){let a=(o.params||[]).map(c=>kt(c)).join(", ");n.push(`default:fn(${a})`);continue}if(o.type==="ClassDeclaration"||o.type==="ClassExpression"){n.push("default:class");continue}n.push(`default:${String(o.type||"unknown")}`);}}return n.sort()}function nt(i,e){return `${i}:${Er(e)}`}function Er(i){return i?i.category==="class"?"class":i.signature?`fn${i.signature.replace(/^[^(]*/,"")}`:i.category==="constant"?`const:${i.defaultValue||""}`:i.category:"unknown"}function Rt(i){if(i){if(i.type==="Identifier")return String(i.name||"");if(i.type==="StringLiteral")return String(i.value||"")}}function kt(i){return i?i.type==="Identifier"?String(i.name||"param"):i.type==="AssignmentPattern"?kt(i.left):i.type==="RestElement"?kt(i.argument):"param":"param"}var dn=createRequire(import.meta.url);var ve=class{name="Vue2Parser";canParse(e,t){return e.endsWith(".vue")}parse(e,t){let n={framework:"vue2",filePath:e,symbols:[],relations:[],behaviors:[],errors:[]};try{let s=dn("vue-template-compiler").parseComponent(t);if(!s.script?.content)return n;let o=s.script.content,a=this.getScriptStartLine(t,s.script.start),c=t.split(`
408
408
  `),l;try{l=dn("@babel/parser").parse(o,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy"],errorRecovery:!0});}catch(p){return n.errors?.push(`AST \u89E3\u6790\u5931\u8D25: ${String(p)}`),n}if(this.extractFromAST(l.program,o,c,a,n),s.template?.content){let p=this.getScriptStartLine(t,s.template.start),d=Qe(s.template.content,p);if(d.length>0){let u=s.template.content.split(`
409
409
  `).length;n.symbols.push({name:"<template>",category:"lifecycle",framework:"vue2",startLine:p,endLine:p+u-1,camelWords:"template"});for(let f of d)n.relations.push(H({callerName:"<template>",callerLine:p,calleeName:f.calleeName,callType:"template_event",line:f.line}));}}}catch(r){n.errors?.push(`\u89E3\u6790\u5931\u8D25: ${String(r)}`);}return n}getScriptStartLine(e,t){let n=1;for(let r=0;r<t&&r<e.length;r++)e[r]===`
410
410
  `&&n++;return n}extractFromAST(e,t,n,r,s){let o=t.split(`
411
- `);s.fileDependencies=fe(e.body||[],s.filePath);let a=null;z(e,d=>{if(d.type==="ExportDefaultDeclaration"){let u=d.declaration;if(u?.type==="ObjectExpression")a=u;else if(u?.type==="CallExpression"){let f=u.arguments;f&&f.length>0&&f[0].type==="ObjectExpression"&&(a=f[0]);}else if(u?.type==="Identifier"){let f=u.name;z(e,m=>{if(m.type==="VariableDeclarator"&&m.id?.name===f){if(m.init?.type==="ObjectExpression")a=m.init;else if(m.init?.type==="CallExpression"){let g=m.init.arguments;g&&g.length>0&&g[0].type==="ObjectExpression"&&(a=g[0]);}}});}}});let l=false;if(!a&&(z(e,d=>{d.type==="ExportDefaultDeclaration"&&d.declaration?.type==="ClassDeclaration"&&(l=true,this.extractFromClassComponent(d.declaration,t,n,r,s));}),!l)){let d=null,u=0,f=["data","methods","computed","props","watch","components","created","mounted","mixins"];z(e,m=>{if(m.type==="ObjectExpression"){let g=m.properties||[],y=0;for(let b of g){let T=this.getPropKey(b);T&&f.includes(T)&&y++;}y>u&&(u=y,d=m);}}),u>=2&&d&&(a=d);}if(!a)return;let p=a.properties;for(let d of p||[]){let u=this.getPropKey(d);if(!u)continue;let f=d.type==="ObjectMethod"?d:d.value;if(!f)continue;let m=g=>g+r-1;switch(u){case "name":f?.type==="Literal"&&(String(f.value));break;case "data":this.extractData(f,o,m,s);break;case "props":this.extractProps(f,o,m,s);break;case "computed":this.extractComputedOrMethods(f,"computed",o,m,n,s);break;case "methods":this.extractComputedOrMethods(f,"method",o,m,n,s);break;case "watch":this.extractWatch(f,o,m,s);break;case "filters":this.extractComputedOrMethods(f,"filter",o,m,n,s);break;case "components":this.extractComponents(f,s);break;case "mixins":this.extractMixins(f,s);break;default:if(_t.includes(u)){let g=m(this.getStartLine(d)),y=m(this.getEndLine(d)),b=V(n.join(`
411
+ `);s.fileDependencies=fe(e.body||[],s.filePath);let a=null;z(e,d=>{if(d.type==="ExportDefaultDeclaration"){let u=d.declaration;if(u?.type==="ObjectExpression")a=u;else if(u?.type==="CallExpression"){let f=u.arguments;f&&f.length>0&&f[0].type==="ObjectExpression"&&(a=f[0]);}else if(u?.type==="Identifier"){let f=u.name;z(e,m=>{if(m.type==="VariableDeclarator"&&m.id?.name===f){if(m.init?.type==="ObjectExpression")a=m.init;else if(m.init?.type==="CallExpression"){let g=m.init.arguments;g&&g.length>0&&g[0].type==="ObjectExpression"&&(a=g[0]);}}});}}});let l=false;if(!a&&(z(e,d=>{d.type==="ExportDefaultDeclaration"&&d.declaration?.type==="ClassDeclaration"&&(l=true,this.extractFromClassComponent(d.declaration,t,n,r,s));}),!l)){let d=null,u=0,f=["data","methods","computed","props","watch","components","created","mounted","mixins"];z(e,m=>{if(m.type==="ObjectExpression"){let g=m.properties||[],y=0;for(let b of g){let T=this.getPropKey(b);T&&f.includes(T)&&y++;}y>u&&(u=y,d=m);}}),u>=2&&d&&(a=d);}if(!a)return;let p=a.properties;for(let d of p||[]){let u=this.getPropKey(d);if(!u)continue;let f=d.type==="ObjectMethod"?d:d.value;if(!f)continue;let m=g=>g+r-1;switch(u){case "name":f?.type==="Literal"&&(String(f.value));break;case "data":this.extractData(f,o,m,s);break;case "props":this.extractProps(f,o,m,s);break;case "computed":this.extractComputedOrMethods(f,"computed",o,m,n,s);break;case "methods":this.extractComputedOrMethods(f,"method",o,m,n,s);break;case "watch":this.extractWatch(f,o,m,s);break;case "filters":this.extractComputedOrMethods(f,"filter",o,m,n,s);break;case "components":this.extractComponents(f,s);break;case "mixins":this.extractMixins(f,s);break;default:if(Nt.includes(u)){let g=m(this.getStartLine(d)),y=m(this.getEndLine(d)),b=V(n.join(`
412
412
  `),g),T=s.symbols.length;s.symbols.push({name:u,category:"lifecycle",framework:"vue2",startLine:g,endLine:y,jsdoc:b,camelWords:k(u)});let h=G(f,u);s.behaviors.push(...h);let E=we(f,u);for(let N of E){if(N.args){let R=String(N.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[T].camelWords+=` ${k(R)} ${R}`;}s.relations.push(H({callerName:u,callerLine:g,calleeName:N.calleeName,callType:"this_method",line:m(N.line),args:N.args}));}}break}}}extractData(e,t,n,r){let s=null;if(e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"||e.type==="ObjectMethod"?z(e.body,o=>{o.type==="ReturnStatement"&&o.argument?.type==="ObjectExpression"&&(s=o.argument);}):e.type==="ObjectExpression"&&(s=e),!!s)for(let o of s.properties){let a=this.getPropKey(o);if(!a)continue;let c=n(this.getStartLine(o)),l=n(this.getEndLine(o)),p=this.getLiteralValue(o.value);r.symbols.push({name:a,category:"state",framework:"vue2",startLine:c,endLine:l,defaultValue:p,camelWords:k(a)});}}extractProps(e,t,n,r){if(e.type==="ArrayExpression"){for(let s of e.elements||[])if(s?.type==="Literal"){let o=String(s.value);r.symbols.push({name:o,category:"prop",framework:"vue2",startLine:n(this.getStartLine(s)),endLine:n(this.getEndLine(s)),camelWords:k(o)});}}else if(e.type==="ObjectExpression")for(let s of e.properties||[]){let o=this.getPropKey(s);if(!o)continue;let a=n(this.getStartLine(s)),c=n(this.getEndLine(s)),l;if(s.value?.type==="ObjectExpression"){let p=s.value.properties?.find(d=>this.getPropKey(d)==="default");p&&(l=this.getLiteralValue(p.value));}r.symbols.push({name:o,category:"prop",framework:"vue2",startLine:a,endLine:c,defaultValue:l,camelWords:k(o)});}}extractComputedOrMethods(e,t,n,r,s,o){if(e.type==="ObjectExpression")for(let a of e.properties||[]){let c=this.getPropKey(a);if(!c)continue;let l=a.type==="ObjectMethod"?a:a.value;if(!l)continue;let p=r(this.getStartLine(a)),d=r(this.getEndLine(a)),u=V(s.join(`
413
413
  `),p),f=this.extractParams(l),m=l.async===true,g=f?`${c}(${f.join(", ")})`:c;if(o.symbols.push({name:c,category:t,framework:"vue2",startLine:p,endLine:d,signature:g,params:f,isAsync:m,jsdoc:u,camelWords:k(c)}),t==="method"&&l){let y=G(l,c);o.behaviors.push(...y);let b=we(l,c);for(let T of b){if(T.args){let h=String(T.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");o.symbols[o.symbols.length-1].camelWords+=` ${k(h)} ${h}`;}o.relations.push(H({callerName:c,callerLine:p,calleeName:T.calleeName,callType:"this_method",line:r(T.line),args:T.args}));}}}}extractWatch(e,t,n,r){if(e.type==="ObjectExpression")for(let s of e.properties||[]){let o=this.getPropKey(s);if(!o)continue;let a=n(this.getStartLine(s)),c=n(this.getEndLine(s));r.symbols.push({name:o,category:"effect",framework:"vue2",startLine:a,endLine:c,camelWords:k(o)});}}extractComponents(e,t){if(e.type==="ObjectExpression")for(let n of e.properties||[]){let r=this.getPropKey(n);r&&t.symbols.push({name:r,category:"component",framework:"vue2",startLine:this.getStartLine(n),endLine:this.getEndLine(n),camelWords:k(r)});}}extractMixins(e,t){if(e.type==="ArrayExpression")for(let n of e.elements||[]){let r=n?.type==="Identifier"?n.name:null;r&&t.symbols.push({name:r,category:"mixin",framework:"vue2",startLine:this.getStartLine(n),endLine:this.getEndLine(n),camelWords:k(r)});}}getPropKey(e){if(!e)return null;let t=e.key;return t?t.type==="Identifier"?t.name:t.type==="Literal"?String(t.value):null:null}getStartLine(e){return e?.loc?.start?.line??1}getEndLine(e){return e?.loc?.end?.line??1}extractParams(e){if(!e)return;let t=e.params;if(t)return t.map(n=>n.type==="Identifier"?n.name:n.type==="AssignmentPattern"?n.left?.name||"?":n.type==="RestElement"?`...${n.argument?.name||""}`:n.type==="TSParameterProperty"&&n.parameter?.name||"?")}getLiteralValue(e){if(e){if(e.type==="Literal"||e.type==="StringLiteral"||e.type==="NumericLiteral"||e.type==="BooleanLiteral")return String(e.value);if(e.type==="NullLiteral"||e.value===null)return "null";if(e.type==="ObjectExpression")return "{}";if(e.type==="ArrayExpression")return "[]";if(e.type==="Identifier"&&e.name==="undefined")return "undefined";if(e.type==="ArrowFunctionExpression"||e.type==="FunctionExpression"||e.type==="ObjectMethod")return "function"}}extractFromClassComponent(e,t,n,r,s){let o=c=>c+r-1,a=e.body;if(!(!a||a.type!=="ClassBody"))for(let c of a.body||[]){let l=this.getPropKey(c);if(!l)continue;let p=o(this.getStartLine(c)),d=o(this.getEndLine(c)),u=V(n.join(`
414
- `),p);if(c.type==="ClassMethod"){let m=_t.includes(l)?"lifecycle":"method",g=this.extractParams(c),y=c.async===true,b=g?`${l}(${g.join(", ")})`:l;s.symbols.push({name:l,category:m,framework:"vue2",startLine:p,endLine:d,signature:b,params:g,isAsync:y,jsdoc:u,camelWords:k(l)});let T=G(c,l);s.behaviors.push(...T);let h=we(c,l);for(let E of h){if(E.args){let N=String(E.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[s.symbols.length-1].camelWords+=` ${k(N)} ${N}`;}s.relations.push(H({callerName:l,callerLine:p,calleeName:E.calleeName,callType:"this_method",line:o(E.line),args:E.args}));}}else if(c.type==="ClassProperty"){let f=(c.decorators||[]).some(g=>g.expression?.callee?.name==="Prop"),m=this.getLiteralValue(c.value);s.symbols.push({name:l,category:f?"prop":"state",framework:"vue2",startLine:p,endLine:d,defaultValue:m,camelWords:k(l)});}}}};var kt=createRequire(import.meta.url),st=class{name="Vue3Parser";canParse(e,t){return e.endsWith(".vue")?this.looksLikeVue3File(t):false}parse(e,t){let n={framework:"vue3",filePath:e,symbols:[],relations:[],behaviors:[],errors:[]};try{let{parse:r}=kt("@vue/compiler-sfc"),{descriptor:s}=r(t),o=t.split(`
414
+ `),p);if(c.type==="ClassMethod"){let m=Nt.includes(l)?"lifecycle":"method",g=this.extractParams(c),y=c.async===true,b=g?`${l}(${g.join(", ")})`:l;s.symbols.push({name:l,category:m,framework:"vue2",startLine:p,endLine:d,signature:b,params:g,isAsync:y,jsdoc:u,camelWords:k(l)});let T=G(c,l);s.behaviors.push(...T);let h=we(c,l);for(let E of h){if(E.args){let N=String(E.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[s.symbols.length-1].camelWords+=` ${k(N)} ${N}`;}s.relations.push(H({callerName:l,callerLine:p,calleeName:E.calleeName,callType:"this_method",line:o(E.line),args:E.args}));}}else if(c.type==="ClassProperty"){let f=(c.decorators||[]).some(g=>g.expression?.callee?.name==="Prop"),m=this.getLiteralValue(c.value);s.symbols.push({name:l,category:f?"prop":"state",framework:"vue2",startLine:p,endLine:d,defaultValue:m,camelWords:k(l)});}}}};var wt=createRequire(import.meta.url),st=class{name="Vue3Parser";canParse(e,t){return e.endsWith(".vue")?this.looksLikeVue3File(t):false}parse(e,t){let n={framework:"vue3",filePath:e,symbols:[],relations:[],behaviors:[],errors:[]};try{let{parse:r}=wt("@vue/compiler-sfc"),{descriptor:s}=r(t),o=t.split(`
415
415
  `),a=!!s.scriptSetup,c=!!s.script;if(a){let l=s.scriptSetup,p=l.loc.start.line;this.parseSetupContent(l.content,p,o,n);}else if(c){let l=s.script,p=l.loc.start.line;this.parseScriptContent(l.content,p,o,n)||this.populateFromOptionsApiFallback(e,t,n);}if(s.template?.content){let l=s.template.loc.start.line,p=Qe(s.template.content,l);if(p.length>0){let d=s.template.content.split(`
416
- `).length;n.symbols.push({name:"<template>",category:"lifecycle",framework:"vue3",startLine:l,endLine:l+d-1,camelWords:"template"});for(let u of p)n.relations.push(H({callerName:"<template>",callerLine:l,calleeName:u.calleeName,callType:"template_event",line:u.line}));}}}catch(r){n.errors?.push(`Vue3 \u89E3\u6790\u5931\u8D25: ${String(r)}`);}return n}parseSetupContent(e,t,n,r){let s;try{s=kt("@babel/parser").parse(e,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"],errorRecovery:!0});}catch(l){r.errors?.push(`AST \u89E3\u6790\u5931\u8D25: ${String(l)}`);return}let o=l=>l+t-1,a=e.split(`
417
- `),c=s.program.body;r.fileDependencies=fe(c,r.filePath);for(let l of c||[])this.processTopLevelStatement(l,o,n,a,r);}parseScriptContent(e,t,n,r){let s;try{s=kt("@babel/parser").parse(e,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"],errorRecovery:!0});}catch(l){return r.errors?.push(`AST \u89E3\u6790\u5931\u8D25: ${String(l)}`),false}let o=l=>l+t-1,a=e.split(`
416
+ `).length;n.symbols.push({name:"<template>",category:"lifecycle",framework:"vue3",startLine:l,endLine:l+d-1,camelWords:"template"});for(let u of p)n.relations.push(H({callerName:"<template>",callerLine:l,calleeName:u.calleeName,callType:"template_event",line:u.line}));}}}catch(r){n.errors?.push(`Vue3 \u89E3\u6790\u5931\u8D25: ${String(r)}`);}return n}parseSetupContent(e,t,n,r){let s;try{s=wt("@babel/parser").parse(e,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"],errorRecovery:!0});}catch(l){r.errors?.push(`AST \u89E3\u6790\u5931\u8D25: ${String(l)}`);return}let o=l=>l+t-1,a=e.split(`
417
+ `),c=s.program.body;r.fileDependencies=fe(c,r.filePath);for(let l of c||[])this.processTopLevelStatement(l,o,n,a,r);}parseScriptContent(e,t,n,r){let s;try{s=wt("@babel/parser").parse(e,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"],errorRecovery:!0});}catch(l){return r.errors?.push(`AST \u89E3\u6790\u5931\u8D25: ${String(l)}`),false}let o=l=>l+t-1,a=e.split(`
418
418
  `);r.fileDependencies=fe(s.program.body||[],r.filePath);let c=false;return z(s.program,l=>{if(l.type==="ExportDefaultDeclaration"&&l.declaration?.type==="ObjectExpression"){let p=l.declaration.properties?.find(d=>this.getPropKey(d)==="setup");if(p){c=true;let d=p.type==="ObjectMethod"?p:p.value;if(!d)return;let u=d.body;if(u?.type==="BlockStatement"){let f=u.body;for(let m of f||[])this.processTopLevelStatement(m,o,n,a,r);}}}}),c||z(s.program,l=>{if(!c&&l.type==="ObjectExpression"){let d=(l.properties||[]).find(u=>this.getPropKey(u)==="setup");if(d){c=true;let u=d.type==="ObjectMethod"?d:d.value;if(!u)return;let f=u.body;if(f?.type==="BlockStatement"){let m=f.body;for(let g of m||[])this.processTopLevelStatement(g,o,n,a,r);}}}}),c}processTopLevelStatement(e,t,n,r,s){let o=a=>{let c=a?.loc;return {start:c?.start?.line??1,end:c?.end?.line??1}};if(e.type==="VariableDeclaration")for(let a of e.declarations||[]){if(a.id?.type!=="Identifier"&&a.id?.type!=="ArrayPattern")continue;let c=a.init;if(c&&a.id.type==="Identifier"){let l=a.id.name;if(c.type==="ArrowFunctionExpression"||c.type==="FunctionExpression"){let{start:p,end:d}=o(e),u=V(n.join(`
419
419
  `),t(p)),f=this.extractParams(c),m=s.symbols.length;if(s.symbols.push({name:l,category:"method",framework:"vue3",startLine:t(p),endLine:t(d),signature:`${l}(${(f||[]).join(", ")})`,params:f,isAsync:c.async===true,jsdoc:u,camelWords:k(l)}),c.body){let g=G(c.body,l);s.behaviors.push(...g);let y=ne(c.body,l);for(let b of y){if(b.args){let T=String(b.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[m].camelWords+=` ${k(T)} ${T}`;}s.relations.push(H({callerName:l,callerLine:t(p),calleeName:b.calleeName,callType:"direct_call",line:t(b.line),args:b.args}));}}}else {let p=this.classifyVue3Declaration(l,c,t,o(e),n);p&&s.symbols.push(p);}}}if(e.type==="FunctionDeclaration"&&e.id?.type==="Identifier"){let a=e.id.name,{start:c,end:l}=o(e),p=V(n.join(`
420
- `),t(c)),d=this.extractParams(e),u=Nt.includes(a);if(s.symbols.push({name:a,category:u?"lifecycle":be(a)?"hook":"method",framework:"vue3",startLine:t(c),endLine:t(l),signature:`${a}(${(d||[]).join(", ")})`,params:d,isAsync:e.async===true,jsdoc:p,camelWords:k(a)}),e.body){let f=G(e.body,a);s.behaviors.push(...f);let m=ne(e.body,a);for(let g of m){if(g.args){let y=String(g.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[s.symbols.length-1].camelWords+=` ${k(y)} ${y}`;}s.relations.push(H({callerName:a,callerLine:t(c),calleeName:g.calleeName,callType:"direct_call",line:t(g.line),args:g.args}));}}}if(e.type==="ExpressionStatement"&&e.expression?.type==="CallExpression"){let c=e.expression.callee;if(c?.type==="Identifier"){let l=c.name;if(["defineProps","defineEmits","defineExpose"].includes(l)){let{start:p,end:d}=o(e);s.symbols.push({name:l,category:l==="defineProps"?"prop":l==="defineEmits"?"emit":"export",framework:"vue3",startLine:t(p),endLine:t(d),camelWords:k(l)});}}}if(e.type==="ExpressionStatement"&&e.expression?.type==="CallExpression"){let a=e.expression,c=a.callee;if(c?.type==="Identifier"){let l=c.name;if(Nt.includes(l)){let{start:p,end:d}=o(e);s.symbols.push({name:l,category:"lifecycle",framework:"vue3",startLine:t(p),endLine:t(d),camelWords:k(l)});let u=a.arguments;if(u?.[0]){let f=G(u[0],l);s.behaviors.push(...f);let m=ne(u[0],l);for(let g of m){if(g.args){let y=String(g.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[s.symbols.length-1].camelWords+=` ${k(y)} ${y}`;}s.relations.push(H({callerName:l,callerLine:t(p),calleeName:g.calleeName,callType:"direct_call",line:t(g.line),args:g.args}));}}}}}}classifyVue3Declaration(e,t,n,r,s){if(t.type!=="CallExpression")return null;let o=t.callee;if(o?.type!=="Identifier")return null;let a=o.name,c=n(r.start),l=n(r.end),p=V(s.join(`
421
- `),c);if(Yt.includes(a)){let d=t.arguments,u=d?.[0]?this.getLiteralValue(d[0]):void 0;return {name:e,category:"state",framework:"vue3",startLine:c,endLine:l,defaultValue:u,jsdoc:p,camelWords:k(e)}}return Zt.includes(a)?{name:e,category:"computed",framework:"vue3",startLine:c,endLine:l,jsdoc:p,camelWords:k(e)}:Qt.includes(a)?{name:e,category:"effect",framework:"vue3",startLine:c,endLine:l,camelWords:k(e)}:a==="provide"||a==="inject"?{name:e,category:"provide",framework:"vue3",startLine:c,endLine:l,camelWords:k(e)}:be(a)?{name:e,category:"hook",framework:"vue3",startLine:c,endLine:l,jsdoc:p,camelWords:k(e)}:null}getPropKey(e){let t=e?.key;return t?t.type==="Identifier"?t.name:t.type==="Literal"?String(t.value):null:null}extractParams(e){let t=e.params;if(t)return t.map(n=>n.type==="Identifier"?n.name:n.type==="AssignmentPattern"?n.left?.name||"?":n.type==="RestElement"?`...${n.argument?.name||""}`:n.type==="ObjectPattern"?"{...}":n.type==="TSParameterProperty"&&n.parameter?.name||"?")}getLiteralValue(e){if(e){if(e.type==="Literal"||e.type==="StringLiteral"||e.type==="NumericLiteral"||e.type==="BooleanLiteral")return String(e.value);if(e.type==="NullLiteral")return "null";if(e.type==="ObjectExpression")return "{}";if(e.type==="ArrayExpression")return "[]"}}looksLikeVue3File(e){return e.includes("<script setup")?true:/\bdefine(?:Props|Emits|Expose|Slots|Model)\s*\(/.test(e)||/\bwithDefaults\s*\(/.test(e)||/\bdefineComponent\s*\(/.test(e)||/\bsetup\s*\(/.test(e)||/\b(?:ref|reactive|shallowRef|shallowReactive|readonly|computed|watch|watchEffect|watchPostEffect|watchSyncEffect|provide|inject|nextTick|onBeforeMount|onMounted|onBeforeUpdate|onUpdated|onBeforeUnmount|onUnmounted|onActivated|onDeactivated|onErrorCaptured|onRenderTracked|onRenderTriggered|onServerPrefetch)\s*\(/.test(e)}populateFromOptionsApiFallback(e,t,n){let r=new ve().parse(e,t);n.symbols=r.symbols.map(s=>({...s,framework:"vue3"})),n.relations=r.relations,n.behaviors=r.behaviors,n.errors=[...n.errors||[],...r.errors||[]];}};var Sr=createRequire(import.meta.url),xr=[...Tt,...St,...xt,...en],je=class{name="ReactParser";canParse(e,t){let n=e.split(".").pop()?.toLowerCase();return ["jsx","tsx","js","ts"].includes(n||"")?t.includes("useState")||t.includes("useEffect")||t.includes("from 'react'")||t.includes('from "react"')||t.includes("React.")||t.includes("jsx")||t.includes("JSX")?true:n==="jsx"||n==="tsx"||n==="js"?this.containsLikelyJsx(t):false:false}containsLikelyJsx(e){return /(?:^|\breturn\b|[=(,:{?&|;>])[\s([]*<[A-Za-z][\w.:-]*(?:\s|\/?>)/m.test(e)||/<>|<\/>/.test(e)}parse(e,t){let n={framework:"react",filePath:e,symbols:[],relations:[],behaviors:[],errors:[]};try{let s=Sr("@babel/parser").parse(t,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy"],errorRecovery:!0}),o=t.split(`
420
+ `),t(c)),d=this.extractParams(e),u=Tt.includes(a);if(s.symbols.push({name:a,category:u?"lifecycle":be(a)?"hook":"method",framework:"vue3",startLine:t(c),endLine:t(l),signature:`${a}(${(d||[]).join(", ")})`,params:d,isAsync:e.async===true,jsdoc:p,camelWords:k(a)}),e.body){let f=G(e.body,a);s.behaviors.push(...f);let m=ne(e.body,a);for(let g of m){if(g.args){let y=String(g.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[s.symbols.length-1].camelWords+=` ${k(y)} ${y}`;}s.relations.push(H({callerName:a,callerLine:t(c),calleeName:g.calleeName,callType:"direct_call",line:t(g.line),args:g.args}));}}}if(e.type==="ExpressionStatement"&&e.expression?.type==="CallExpression"){let c=e.expression.callee;if(c?.type==="Identifier"){let l=c.name;if(["defineProps","defineEmits","defineExpose"].includes(l)){let{start:p,end:d}=o(e);s.symbols.push({name:l,category:l==="defineProps"?"prop":l==="defineEmits"?"emit":"export",framework:"vue3",startLine:t(p),endLine:t(d),camelWords:k(l)});}}}if(e.type==="ExpressionStatement"&&e.expression?.type==="CallExpression"){let a=e.expression,c=a.callee;if(c?.type==="Identifier"){let l=c.name;if(Tt.includes(l)){let{start:p,end:d}=o(e);s.symbols.push({name:l,category:"lifecycle",framework:"vue3",startLine:t(p),endLine:t(d),camelWords:k(l)});let u=a.arguments;if(u?.[0]){let f=G(u[0],l);s.behaviors.push(...f);let m=ne(u[0],l);for(let g of m){if(g.args){let y=String(g.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[s.symbols.length-1].camelWords+=` ${k(y)} ${y}`;}s.relations.push(H({callerName:l,callerLine:t(p),calleeName:g.calleeName,callType:"direct_call",line:t(g.line),args:g.args}));}}}}}}classifyVue3Declaration(e,t,n,r,s){if(t.type!=="CallExpression")return null;let o=t.callee;if(o?.type!=="Identifier")return null;let a=o.name,c=n(r.start),l=n(r.end),p=V(s.join(`
421
+ `),c);if(Yt.includes(a)){let d=t.arguments,u=d?.[0]?this.getLiteralValue(d[0]):void 0;return {name:e,category:"state",framework:"vue3",startLine:c,endLine:l,defaultValue:u,jsdoc:p,camelWords:k(e)}}return Zt.includes(a)?{name:e,category:"computed",framework:"vue3",startLine:c,endLine:l,jsdoc:p,camelWords:k(e)}:Qt.includes(a)?{name:e,category:"effect",framework:"vue3",startLine:c,endLine:l,camelWords:k(e)}:a==="provide"||a==="inject"?{name:e,category:"provide",framework:"vue3",startLine:c,endLine:l,camelWords:k(e)}:be(a)?{name:e,category:"hook",framework:"vue3",startLine:c,endLine:l,jsdoc:p,camelWords:k(e)}:null}getPropKey(e){let t=e?.key;return t?t.type==="Identifier"?t.name:t.type==="Literal"?String(t.value):null:null}extractParams(e){let t=e.params;if(t)return t.map(n=>n.type==="Identifier"?n.name:n.type==="AssignmentPattern"?n.left?.name||"?":n.type==="RestElement"?`...${n.argument?.name||""}`:n.type==="ObjectPattern"?"{...}":n.type==="TSParameterProperty"&&n.parameter?.name||"?")}getLiteralValue(e){if(e){if(e.type==="Literal"||e.type==="StringLiteral"||e.type==="NumericLiteral"||e.type==="BooleanLiteral")return String(e.value);if(e.type==="NullLiteral")return "null";if(e.type==="ObjectExpression")return "{}";if(e.type==="ArrayExpression")return "[]"}}looksLikeVue3File(e){return e.includes("<script setup")?true:/\bdefine(?:Props|Emits|Expose|Slots|Model)\s*\(/.test(e)||/\bwithDefaults\s*\(/.test(e)||/\bdefineComponent\s*\(/.test(e)||/\bsetup\s*\(/.test(e)||/\b(?:ref|reactive|shallowRef|shallowReactive|readonly|computed|watch|watchEffect|watchPostEffect|watchSyncEffect|provide|inject|nextTick|onBeforeMount|onMounted|onBeforeUpdate|onUpdated|onBeforeUnmount|onUnmounted|onActivated|onDeactivated|onErrorCaptured|onRenderTracked|onRenderTriggered|onServerPrefetch)\s*\(/.test(e)}populateFromOptionsApiFallback(e,t,n){let r=new ve().parse(e,t);n.symbols=r.symbols.map(s=>({...s,framework:"vue3"})),n.relations=r.relations,n.behaviors=r.behaviors,n.errors=[...n.errors||[],...r.errors||[]];}};var Sr=createRequire(import.meta.url),xr=[...St,...xt,...At,...en],je=class{name="ReactParser";canParse(e,t){let n=e.split(".").pop()?.toLowerCase();return ["jsx","tsx","js","ts"].includes(n||"")?t.includes("useState")||t.includes("useEffect")||t.includes("from 'react'")||t.includes('from "react"')||t.includes("React.")||t.includes("jsx")||t.includes("JSX")?true:n==="jsx"||n==="tsx"||n==="js"?this.containsLikelyJsx(t):false:false}containsLikelyJsx(e){return /(?:^|\breturn\b|[=(,:{?&|;>])[\s([]*<[A-Za-z][\w.:-]*(?:\s|\/?>)/m.test(e)||/<>|<\/>/.test(e)}parse(e,t){let n={framework:"react",filePath:e,symbols:[],relations:[],behaviors:[],errors:[]};try{let s=Sr("@babel/parser").parse(t,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy"],errorRecovery:!0}),o=t.split(`
422
422
  `);this.extractFromAST(s.program?s.program:s,o,n);}catch(r){n.errors?.push(`React \u89E3\u6790\u5931\u8D25: ${String(r)}`);}return n}extractFromAST(e,t,n){let r=e.body;n.fileDependencies=fe(r,n.filePath);for(let s of r||[]){if(s.type==="FunctionDeclaration"||s.type==="ExportDefaultDeclaration"&&s.declaration?.type==="FunctionDeclaration"||s.type==="ExportNamedDeclaration"&&s.declaration?.type==="FunctionDeclaration"){let o=s.type==="FunctionDeclaration"?s:s.declaration,a=s.type!=="FunctionDeclaration";o&&o.id?.type==="Identifier"&&this.processFunction(o,t,n,a);}if(s.type==="VariableDeclaration"||s.type==="ExportNamedDeclaration"&&s.declaration?.type==="VariableDeclaration"||s.type==="ExportDefaultDeclaration"&&s.declaration?.type==="VariableDeclaration"){let o=s.type==="VariableDeclaration"?s:s.declaration,a=s.type!=="VariableDeclaration";if(o)for(let c of o.declarations||[]){let l=c.init;if(l&&(l.type==="ArrowFunctionExpression"||l.type==="FunctionExpression")&&c.id?.type==="Identifier"){let p={...l,id:c.id,loc:{start:o.loc?.start??l.loc?.start,end:l.loc?.end}};this.processFunction(p,t,n,a);}}}}n.exportSignatureEntries=rt(r,n.symbols);}processFunction(e,t,n,r=false){let s=e.id?.name;if(!s)return;let o=e.loc,a=o?.start?.line??1,c=o?.end?.line??1,l=be(s),p=!l&&/^[A-Z]/.test(s),d=V(t.join(`
423
- `),a),u=this.extractParams(e),f=this.buildSymbolKey(s,a,c);n.symbols.push({name:s,category:l?"hook":p?"component":"function",framework:"react",startLine:a,endLine:c,internalKey:f,signature:`${s}(${(u||[]).join(", ")})`,params:u,isAsync:e.async===true,isExported:r,jsdoc:d,parentComponent:p?s:void 0,camelWords:k(s)});let m=e.body;if(m?.type!=="BlockStatement")return;let g=m.body;for(let h of g||[])this.processComponentStatement(h,s,t,n);let y=G(m,s,t,true);n.behaviors.push(...y);let b=ne(m,s,t,true);for(let h of b){let E=n.symbols.findIndex(N=>N.name===s&&N.startLine===a);if(h.args&&E!==-1){let N=String(h.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");n.symbols[E].camelWords+=` ${k(N)} ${N}`;}n.relations.push(H({callerName:s,callerLine:a,callerKey:f,calleeName:h.calleeName,callType:"direct_call",line:h.line,args:h.args}));}let T=cn(m);for(let h of T)n.relations.push(H({callerName:s,callerLine:a,callerKey:f,calleeName:h.calleeName,callType:"jsx_event",line:h.line}));}processComponentStatement(e,t,n,r){let s=o=>{let a=o?.loc;return {start:a?.start?.line??1,end:a?.end?.line??1}};if(e.type==="VariableDeclaration")for(let o of e.declarations||[]){let a=o.init;if(!a||a.type!=="CallExpression")continue;let c=a.callee;if(c?.type!=="Identifier")continue;let l=c.name,{start:p,end:d}=s(e),u=p,f=d;if(Tt.includes(l)&&l!=="useRef"){if(o.id?.type==="ArrayPattern"){let m=o.id.elements,g=m[0]?.name,y=m[1]?.name;if(g){let b=a.arguments;r.symbols.push({name:g,category:"state",framework:"react",startLine:u,endLine:f,internalKey:this.buildSymbolKey(g,u,f,t),stateSetterName:y,defaultValue:this.getLiteralValue(b?.[0]),parentComponent:t,camelWords:k(g)});}}else if(o.id?.type==="Identifier"){let m=o.id.name;r.symbols.push({name:m,category:"state",framework:"react",startLine:u,endLine:f,internalKey:this.buildSymbolKey(m,u,f,t),parentComponent:t,camelWords:k(m)});}}if(l==="useRef"&&o.id?.type==="Identifier"){let m=o.id.name,g=a.arguments;r.symbols.push({name:m,category:"state",framework:"react",startLine:u,endLine:f,internalKey:this.buildSymbolKey(m,u,f,t),defaultValue:this.getLiteralValue(g?.[0]),parentComponent:t,camelWords:k(m)});}if(St.includes(l)&&o.id?.type==="Identifier"){let m=o.id.name,y=a.arguments?.[1],b=this.extractDepsArray(y);r.symbols.push({name:m,category:"computed",framework:"react",startLine:u,endLine:f,internalKey:this.buildSymbolKey(m,u,f,t),hookDeps:b,parentComponent:t,camelWords:k(m)});}if(be(l)&&!xr.includes(l)){let m=o.id?.type==="Identifier"?o.id.name:o.id?.type==="ObjectPattern"?"{...}":"?";r.symbols.push({name:m,category:"hook",framework:"react",startLine:u,endLine:f,internalKey:this.buildSymbolKey(m,u,f,t),parentComponent:t,camelWords:k(m)});}}if(e.type==="ExpressionStatement"&&e.expression?.type==="CallExpression"){let o=e.expression,a=o.callee;if(a?.type==="Identifier"){let c=a.name;if(xt.includes(c)){let{start:l,end:p}=s(e),d=o.arguments,u=d?.[1],f=this.extractDepsArray(u),m=this.buildSymbolKey(c,l,p,t),g=`${t}.${c}`;if(r.symbols.push({name:c,category:"effect",framework:"react",startLine:l,endLine:p,internalKey:m,hookDeps:f,parentComponent:t,camelWords:k(c)}),d?.[0]){let y=G(d[0],g,n,true).map(T=>({...T,symbolKey:m}));r.behaviors.push(...y);let b=ne(d[0],g,n,true);for(let T of b){let h=r.symbols.findIndex(E=>E.name===c&&E.startLine===l);if(T.args&&h!==-1){let E=String(T.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");r.symbols[h].camelWords+=` ${k(E)} ${E}`;}r.relations.push(H({callerName:g,callerLine:l,callerKey:m,calleeName:T.calleeName,callType:"direct_call",line:T.line,args:T.args}));}}}}}if(e.type==="FunctionDeclaration"&&e.id?.type==="Identifier"){let o=e.id.name;if(!be(o)){let{start:a,end:c}=s(e),l=V(n.join(`
423
+ `),a),u=this.extractParams(e),f=this.buildSymbolKey(s,a,c);n.symbols.push({name:s,category:l?"hook":p?"component":"function",framework:"react",startLine:a,endLine:c,internalKey:f,signature:`${s}(${(u||[]).join(", ")})`,params:u,isAsync:e.async===true,isExported:r,jsdoc:d,parentComponent:p?s:void 0,camelWords:k(s)});let m=e.body;if(m?.type!=="BlockStatement")return;let g=m.body;for(let h of g||[])this.processComponentStatement(h,s,t,n);let y=G(m,s,t,true);n.behaviors.push(...y);let b=ne(m,s,t,true);for(let h of b){let E=n.symbols.findIndex(N=>N.name===s&&N.startLine===a);if(h.args&&E!==-1){let N=String(h.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");n.symbols[E].camelWords+=` ${k(N)} ${N}`;}n.relations.push(H({callerName:s,callerLine:a,callerKey:f,calleeName:h.calleeName,callType:"direct_call",line:h.line,args:h.args}));}let T=cn(m);for(let h of T)n.relations.push(H({callerName:s,callerLine:a,callerKey:f,calleeName:h.calleeName,callType:"jsx_event",line:h.line}));}processComponentStatement(e,t,n,r){let s=o=>{let a=o?.loc;return {start:a?.start?.line??1,end:a?.end?.line??1}};if(e.type==="VariableDeclaration")for(let o of e.declarations||[]){let a=o.init;if(!a||a.type!=="CallExpression")continue;let c=a.callee;if(c?.type!=="Identifier")continue;let l=c.name,{start:p,end:d}=s(e),u=p,f=d;if(St.includes(l)&&l!=="useRef"){if(o.id?.type==="ArrayPattern"){let m=o.id.elements,g=m[0]?.name,y=m[1]?.name;if(g){let b=a.arguments;r.symbols.push({name:g,category:"state",framework:"react",startLine:u,endLine:f,internalKey:this.buildSymbolKey(g,u,f,t),stateSetterName:y,defaultValue:this.getLiteralValue(b?.[0]),parentComponent:t,camelWords:k(g)});}}else if(o.id?.type==="Identifier"){let m=o.id.name;r.symbols.push({name:m,category:"state",framework:"react",startLine:u,endLine:f,internalKey:this.buildSymbolKey(m,u,f,t),parentComponent:t,camelWords:k(m)});}}if(l==="useRef"&&o.id?.type==="Identifier"){let m=o.id.name,g=a.arguments;r.symbols.push({name:m,category:"state",framework:"react",startLine:u,endLine:f,internalKey:this.buildSymbolKey(m,u,f,t),defaultValue:this.getLiteralValue(g?.[0]),parentComponent:t,camelWords:k(m)});}if(xt.includes(l)&&o.id?.type==="Identifier"){let m=o.id.name,y=a.arguments?.[1],b=this.extractDepsArray(y);r.symbols.push({name:m,category:"computed",framework:"react",startLine:u,endLine:f,internalKey:this.buildSymbolKey(m,u,f,t),hookDeps:b,parentComponent:t,camelWords:k(m)});}if(be(l)&&!xr.includes(l)){let m=o.id?.type==="Identifier"?o.id.name:o.id?.type==="ObjectPattern"?"{...}":"?";r.symbols.push({name:m,category:"hook",framework:"react",startLine:u,endLine:f,internalKey:this.buildSymbolKey(m,u,f,t),parentComponent:t,camelWords:k(m)});}}if(e.type==="ExpressionStatement"&&e.expression?.type==="CallExpression"){let o=e.expression,a=o.callee;if(a?.type==="Identifier"){let c=a.name;if(At.includes(c)){let{start:l,end:p}=s(e),d=o.arguments,u=d?.[1],f=this.extractDepsArray(u),m=this.buildSymbolKey(c,l,p,t),g=`${t}.${c}`;if(r.symbols.push({name:c,category:"effect",framework:"react",startLine:l,endLine:p,internalKey:m,hookDeps:f,parentComponent:t,camelWords:k(c)}),d?.[0]){let y=G(d[0],g,n,true).map(T=>({...T,symbolKey:m}));r.behaviors.push(...y);let b=ne(d[0],g,n,true);for(let T of b){let h=r.symbols.findIndex(E=>E.name===c&&E.startLine===l);if(T.args&&h!==-1){let E=String(T.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");r.symbols[h].camelWords+=` ${k(E)} ${E}`;}r.relations.push(H({callerName:g,callerLine:l,callerKey:m,calleeName:T.calleeName,callType:"direct_call",line:T.line,args:T.args}));}}}}}if(e.type==="FunctionDeclaration"&&e.id?.type==="Identifier"){let o=e.id.name;if(!be(o)){let{start:a,end:c}=s(e),l=V(n.join(`
424
424
  `),a),p=this.extractParams(e);if(r.symbols.push({name:o,category:"method",framework:"react",startLine:a,endLine:c,internalKey:this.buildSymbolKey(o,a,c,t),signature:`${o}(${(p||[]).join(", ")})`,params:p,isAsync:e.async===true,jsdoc:l,parentComponent:t,camelWords:k(o)}),e.body){let d=G(e.body,o,n,true);r.behaviors.push(...d);let u=ne(e.body,o,n,true);for(let f of u){let m=r.symbols.findIndex(g=>g.name===o&&g.startLine===a);if(f.args&&m!==-1){let g=String(f.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");r.symbols[m].camelWords+=` ${k(g)} ${g}`;}r.relations.push(H({callerName:o,callerLine:a,callerKey:this.buildSymbolKey(o,a,c,t),calleeName:f.calleeName,callType:"direct_call",line:f.line,args:f.args}));}}}}if(e.type==="VariableDeclaration")for(let o of e.declarations||[]){let a=o.init;if(!a)continue;let c=a.type==="ArrowFunctionExpression"||a.type==="FunctionExpression";if(!c||o.id?.type!=="Identifier")continue;let l=o.id.name,p=a.type==="CallExpression"?a.callee:null;if(p?.type==="Identifier"&&be(p.name))continue;if(a.type==="CallExpression"&&a.callee?.name==="useCallback"){let b=a.arguments?.[1],T=this.extractDepsArray(b),{start:h,end:E}=s(e);r.symbols.push({name:l,category:"computed",framework:"react",startLine:h,endLine:E,internalKey:this.buildSymbolKey(l,h,E,t),hookDeps:T,parentComponent:t,camelWords:k(l)});continue}if(!c)continue;let{start:u,end:f}=s(e),m=V(n.join(`
425
425
  `),u),g=this.extractParams(a);if(r.symbols.push({name:l,category:"method",framework:"react",startLine:u,endLine:f,internalKey:this.buildSymbolKey(l,u,f,t),signature:`${l}(${(g||[]).join(", ")})`,params:g,isAsync:a.async===true,jsdoc:m,parentComponent:t,camelWords:k(l)}),a.body){let y=G(a.body,l,n,true);r.behaviors.push(...y);let b=ne(a.body,l,n,true);for(let T of b){let h=r.symbols.findIndex(E=>E.name===l&&E.startLine===u);if(T.args&&h!==-1){let E=String(T.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");r.symbols[h].camelWords+=` ${k(E)} ${E}`;}r.relations.push(H({callerName:l,callerLine:u,callerKey:this.buildSymbolKey(l,u,f,t),calleeName:T.calleeName,callType:"direct_call",line:T.line,args:T.args}));}}}}extractDepsArray(e){if(!(!e||e.type!=="ArrayExpression"))return (e.elements||[]).filter(t=>!!t&&t.type==="Identifier").map(t=>t.name)}extractParams(e){let t=e.params;if(t)return t.map(n=>n.type==="Identifier"?n.name:n.type==="ObjectPattern"?"{...}":n.type==="ArrayPattern"?"[...]":n.type==="AssignmentPattern"?n.left?.name||"?":n.type==="RestElement"?`...${n.argument?.name||""}`:n.type==="TSParameterProperty"&&n.parameter?.name||"?")}getLiteralValue(e){if(e){if(e.type==="Literal"||e.type==="StringLiteral"||e.type==="NumericLiteral"||e.type==="BooleanLiteral")return String(e.value);if(e.type==="NullLiteral")return "null";if(e.type==="ObjectExpression")return "{}";if(e.type==="ArrayExpression")return "[]";if(e.type==="Identifier"&&e.name==="null")return "null"}}buildSymbolKey(e,t,n,r){return `${r||"root"}:${e}:${t}:${n}`}};var Lr=createRequire(import.meta.url),it=class{name="ToolingTsParser";canParse(e){let t=e.split(".").pop()?.toLowerCase();return ["js","jsx","ts","tsx"].includes(t||"")}parse(e,t){let n=e.endsWith(".ts")||e.endsWith(".tsx")?"ts":"js",r={framework:n,filePath:e,symbols:[],relations:[],behaviors:[],errors:[]};try{let o=Lr("@babel/parser").parse(t,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy","classProperties"],errorRecovery:!0}),a=t.split(`
426
426
  `),c=(o.program||o).body,l=new Set;r.fileDependencies=fe(c||[],e);for(let p of c||[])this.processTopLevelStatement(p,a,n,r,l);if(l.size>0)for(let p of r.symbols)l.has(p.name)&&(p.isExported=!0);r.exportSignatureEntries=rt(c||[],r.symbols);}catch(s){r.errors?.push(`Tooling \u89E3\u6790\u5931\u8D25: ${String(s)}`);}return r}processTopLevelStatement(e,t,n,r,s){if(e.type==="FunctionDeclaration"){this.addTopLevelFunction(e,t,n,r,false);return}if(e.type==="ExportNamedDeclaration"||e.type==="ExportDefaultDeclaration"){let o=e.declaration;if(!o){this.collectDeferredExportNames(e,s);return}if(o.type==="FunctionDeclaration"){this.addTopLevelFunction(o,t,n,r,true);return}if(o.type==="ClassDeclaration"){this.addClass(o,t,n,r,true);return}if(o.type==="VariableDeclaration"){this.processVariableDeclaration(o,t,n,r,true);return}this.collectDeferredExportNames(e,s);return}if(e.type==="ClassDeclaration"){this.addClass(e,t,n,r,false);return}e.type==="VariableDeclaration"&&this.processVariableDeclaration(e,t,n,r,false);}collectDeferredExportNames(e,t){if(e.type==="ExportNamedDeclaration"){if(e.source?.type==="StringLiteral")return;for(let r of e.specifiers||[]){let s=r.local;s?.type==="Identifier"&&t.add(String(s.name||""));}return}if(e.type==="ExportDefaultDeclaration"){let n=e.declaration;n?.type==="Identifier"&&t.add(String(n.name||""));}}processVariableDeclaration(e,t,n,r,s){for(let o of e.declarations||[]){let a=o.id;if(!a||a.type!=="Identifier")continue;let c=String(a.name||"");if(!c)continue;let l=o.init,{start:p,end:d}=this.getLineRange(o);if(l&&(l.type==="ArrowFunctionExpression"||l.type==="FunctionExpression")){this.addFunctionSymbol(c,l,t,n,r,{startLine:p,endLine:d,isExported:s});continue}r.symbols.push({name:c,category:"constant",framework:n,startLine:p,endLine:d,isExported:s,defaultValue:this.getLiteralValue(l),camelWords:k(c)});}}addTopLevelFunction(e,t,n,r,s){let o=e.id?.name;if(!o)return;let{start:a,end:c}=this.getLineRange(e);this.addFunctionSymbol(o,e,t,n,r,{startLine:a,endLine:c,isExported:s});}addFunctionSymbol(e,t,n,r,s,o){let a=this.buildSymbolKey(e,o.startLine,o.endLine,o.ownerClass),c=this.extractParams(t);s.symbols.push({name:e,category:o.ownerClass?"method":"function",framework:r,startLine:o.startLine,endLine:o.endLine,internalKey:a,signature:`${e}(${(c||[]).join(", ")})`,params:c,isAsync:t.async===true,isExported:o.isExported,jsdoc:V(n.join(`
427
427
  `),o.startLine),parentComponent:o.ownerClass,camelWords:k(e)});let l=t.body;if(!l)return;let p=G(l,e,n,true);s.behaviors.push(...p);let d=ne(l,e,n,true);for(let f of d)s.relations.push(H({callerName:e,callerLine:o.startLine,callerKey:a,calleeName:f.calleeName,callType:"direct_call",line:f.line,args:f.args}));let u=we(l,e);for(let f of u)s.relations.push(H({callerName:e,callerLine:o.startLine,callerKey:a,calleeName:f.calleeName,callType:"this_method",line:f.line,args:f.args}));}addClass(e,t,n,r,s){let o=e.id?.name;if(!o)return;let{start:a,end:c}=this.getLineRange(e);r.symbols.push({name:o,category:"class",framework:n,startLine:a,endLine:c,isExported:s,jsdoc:V(t.join(`
428
- `),a),camelWords:k(o)});let l=e.body?.body;for(let p of l||[]){let d=p.key,u=d?.type==="Identifier"?String(d.name||""):"";if(!u||u==="constructor")continue;if(p.type==="ClassMethod"||p.type==="ClassPrivateMethod"){this.addFunctionSymbol(u,p,t,n,r,{startLine:this.getLineRange(p).start,endLine:this.getLineRange(p).end,isExported:false,ownerClass:o});continue}let f=p.value;f&&(f.type==="ArrowFunctionExpression"||f.type==="FunctionExpression")&&(p.type==="ClassProperty"||p.type==="PropertyDefinition")&&this.addFunctionSymbol(u,f,t,n,r,{startLine:this.getLineRange(p).start,endLine:this.getLineRange(p).end,isExported:false,ownerClass:o});}}extractParams(e){let t=e.params;return t?.length?t.map(n=>{if(n.type==="Identifier")return String(n.name||"");if(n.type==="AssignmentPattern"){let r=n.left;return r?.type==="Identifier"?String(r.name||""):"param"}return "param"}):[]}getLiteralValue(e){if(e){if(e.type==="StringLiteral"||e.type==="NumericLiteral"||e.type==="BooleanLiteral")return String(e.value);if(e.type==="NullLiteral")return "null";if(e.type==="ObjectExpression")return "{...}";if(e.type==="ArrayExpression")return "[...]"}}buildSymbolKey(e,t,n,r){return `${r||"root"}:${e}:${t}:${n}`}getLineRange(e){let t=e.loc;return {start:t?.start?.line??1,end:t?.end?.line??1}}};function Y(i){let e=i.property;return e?e.type==="Identifier"?String(e.name||""):e.type==="Literal"||e.type==="StringLiteral"?String(e.value||""):null:null}function ie(i){let e=i.object;return e?e.type==="Identifier"?String(e.name||""):e.type==="ThisExpression"?Y(i):e.type==="MemberExpression"?e.object?.type==="ThisExpression"?Y(e):ie(e):null:null}function ee(i,e){let t=i||"";return /created|mounted|beforeMount|setup\s*\(|\bdata\s*\(/.test(t)?"init":/getItem|localStorage|sessionStorage|\bfetch\b|\bload[A-Z]|\bget[A-Z]/.test(t)?"cache":/@click|@change|@input|onClick|onChange|handle[A-Z]|\bwatch\b/.test(t)?"user":e<=30?"init":"unknown"}var Rr=new Set(["FunctionDeclaration","ArrowFunctionExpression","FunctionExpression","ObjectMethod","ClassMethod","ClassProperty"]);function un(i,e){return !!e?.skipNestedFunctions&&Rr.has(String(i.type||""))}function me(i,e,t){if(!(!i||typeof i!="object")){e(i);for(let n of Object.keys(i)){if(n==="type"||n==="loc"||n==="start"||n==="end")continue;let r=i[n];if(Array.isArray(r)){for(let s of r){if(!s||typeof s!="object"||!s.type)continue;let o=s;un(o,t)||me(o,e,t);}continue}if(r&&typeof r=="object"&&r.type){let s=r;if(un(s,t))continue;me(s,e,t);}}}}function fn(i,e,t=true,n){let r=[],s=[],o=(a,c=120)=>kr(a,n,c);return me(i,a=>{if(a.type==="VariableDeclarator"){let c=a.id;if(!c)return;let l=ot(c),p=o(a);for(let d of l)r.push({symbolName:d,kind:"declaration",line:Ce(a),text:p,sourceLayer:ee(p,Ce(a))});}if(a.type==="AssignmentExpression"){let c=a.left;if(!c)return;let l=o(a),p=Ce(a);if(c.type==="Identifier"&&r.push({symbolName:c.name,kind:"assignment",line:p,text:l,sourceLayer:ee(l,p)}),c.type==="MemberExpression"&&c.object?.type==="ThisExpression"){let u=Y(c);if(u){r.push({symbolName:u,kind:"assignment",line:p,text:l,sourceLayer:ee(l,p)});return}}if(c.type==="MemberExpression"){let d=ie(c);if(d&&wt(d)){let u=Y(c);s.push({objectName:d,propertyName:u||void 0,line:p,text:l,kind:c.computed?"bracket":"dot",sourceLayer:ee(l,p)});}}}if(a.type==="UpdateExpression"){let c=a.argument;if(!c)return;let l=o(a),p=Ce(a);if(c.type==="Identifier"&&r.push({symbolName:c.name,kind:"update",line:p,text:l,sourceLayer:ee(l,p)}),c.type==="MemberExpression"&&c.object?.type==="ThisExpression"){let u=Y(c);if(u){r.push({symbolName:u,kind:"update",line:p,text:l,sourceLayer:ee(l,p)});return}}if(c.type==="MemberExpression"){let d=ie(c);if(d&&wt(d)){let u=Y(c);s.push({objectName:d,propertyName:u||void 0,line:p,text:l,kind:c.computed?"bracket":"dot",sourceLayer:ee(l,p)});}}}if(a.type==="UnaryExpression"&&a.operator==="delete"){let c=a.argument;if(c?.type==="MemberExpression"){let l=ie(c);if(l&&wt(l)){let p=Y(c);s.push({objectName:l,propertyName:p||void 0,line:Ce(a),text:o(a),kind:"delete",sourceLayer:ee(o(a),Ce(a))});}}}},{skipNestedFunctions:t}),{assignments:r,propertyWrites:s}}function ot(i){return i.type==="Identifier"?[i.name]:i.type==="ObjectPattern"?(i.properties||[]).flatMap(t=>{let n=t.type==="ObjectProperty"||t.type==="Property"?t.value:t;return n?ot(n):[]}):i.type==="ArrayPattern"?(i.elements||[]).flatMap(t=>t?ot(t):[]):i.type==="AssignmentPattern"?ot(i.left):[]}function wt(i){return !(/^[A-Z][A-Z]/.test(i)||/^(document|window|console|localStorage|sessionStorage|navigator|process|global|globalThis)$/.test(i))}function Ce(i){return i.loc?.start?.line??1}function kr(i,e,t=120){if(e){let r=i.loc;if(r?.start?.line&&r?.end?.line){let s=r.start.line-1,o=Math.min(r.end.line-1,s+5);return e.slice(s,o+1).map(c=>c.trim()).filter(c=>c).join(" ").slice(0,t)}}let n=i.loc;return n?.start?.line?`L${n.start.line}`:String(i.type||"?")}var vr=createRequire(import.meta.url);function Ct(i,e){let t={files:new Map,resolutionCache:new Map,localShadowCache:new Map};for(let{path:n,content:r}of i){let s=pn(n,r);t.files.set(n,s);let o=new Map;for(let a of s.imports)a.localName&&o.set(a.localName,`${a.resolvedFile}::${a.originalName}`);t.resolutionCache.set(n,o),t.localShadowCache.set(n,Cr(r));}return t}function It(i,e,t,n){if(t.files.size===0)return i;let r=t.resolutionCache.get(e);if(!r||r.size===0)return i;let s=t.localShadowCache.get(e);return t.files.get(e)?i.map(c=>{let l=r.get(c.calleeName);return !l||c.callerKey&&s?.get(c.callerKey)?.has(c.calleeName)||n.has(c.calleeName)?c:{...c,edgeKind:"precise",importSource:c.importSource||l}}):i}function Cr(i){let e=new Map;try{let n=vr("@babel/parser").parse(i,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy","classProperties"],errorRecovery:!0}),r=(n.program||n).body;if(!r?.length)return e;for(let s of r)gn(s,e);}catch{return e}return e}function gn(i,e){if(i.type==="FunctionDeclaration"){let t=xe(i.id);if(!t)return;Ie(t,i,e),Ir(Pr(i),t,e);return}if(i.type==="VariableDeclaration"){hn(i,void 0,e);return}if(i.type==="ClassDeclaration"){$r(i,e);return}if(i.type==="ExportNamedDeclaration"||i.type==="ExportDefaultDeclaration"){let t=i.declaration;if(!t)return;gn(t,e);}}function Ir(i,e,t){for(let n of i){if(n.type==="FunctionDeclaration"){let r=xe(n.id);if(!r)continue;Ie(r,n,t,e);continue}if(n.type==="VariableDeclaration"){hn(n,e,t);continue}if(n.type==="ExpressionStatement"){let r=n.expression;if(r?.type!=="CallExpression")continue;let s=r.callee,o=s?.type==="Identifier"?String(s.name||""):"";if(!/^use[A-Z]/.test(o))continue;let a=r.arguments?.[0];if(!a||a.type!=="ArrowFunctionExpression"&&a.type!=="FunctionExpression")continue;Ie(o,a,t,e,n);}}}function hn(i,e,t){for(let n of i.declarations||[]){let r=xe(n.id),s=n.init;!r||!s||s.type!=="ArrowFunctionExpression"&&s.type!=="FunctionExpression"||Ie(r,s,t,e,n);}}function $r(i,e){let t=xe(i.id);if(!t)return;let n=i.body?.body||[];for(let r of n){let s=xe(r.key);if(!s||s==="constructor")continue;if(r.type==="ClassMethod"||r.type==="ClassPrivateMethod"){Ie(s,r,e,t);continue}let o=r.value;o&&(o.type==="ArrowFunctionExpression"||o.type==="FunctionExpression")&&(r.type==="ClassProperty"||r.type==="PropertyDefinition")&&Ie(s,o,e,t,r);}}function Ie(i,e,t,n,r){let s=Fr(r||e),o=Dr(i,s.start,s.end,n),a=Or(e);t.set(o,a);}function Or(i){let e=new Set;for(let n of i.params||[])for(let r of Se(n))e.add(r);let t=i.body;return t&&vt(t,n=>{if(n.type==="VariableDeclarator"){for(let r of Se(n.id))e.add(r);return}if(n.type==="FunctionDeclaration"){let r=xe(n.id);return r&&e.add(r),false}if(n.type==="ClassDeclaration"){let r=xe(n.id);return r&&e.add(r),false}}),e}function vt(i,e){if(!(!i||typeof i!="object")&&e(i)!==false)for(let t of Object.keys(i)){if(t==="type"||t==="loc"||t==="start"||t==="end")continue;let n=i[t];if(Array.isArray(n)){for(let r of n){if(!r||typeof r!="object"||!r.type)continue;let s=r;mn(s)||vt(s,e);}continue}if(n&&typeof n=="object"&&n.type){let r=n;if(mn(r))continue;vt(r,e);}}}function mn(i){return ["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression","ClassMethod","ClassPrivateMethod","ObjectMethod"].includes(String(i.type||""))}function Se(i){return i?i.type==="Identifier"?[String(i.name||"")]:i.type==="AssignmentPattern"?Se(i.left):i.type==="RestElement"?Se(i.argument):i.type==="ArrayPattern"?(i.elements||[]).flatMap(e=>Se(e)):i.type==="ObjectPattern"?(i.properties||[]).flatMap(e=>{if(e.type==="RestElement")return Se(e.argument);let t=e.value||e.argument;return Se(t)}):[]:[]}function xe(i){if(i&&i.type==="Identifier")return String(i.name||"")}function Pr(i){let e=i.body;return !e||e.type!=="BlockStatement"?[]:e.body||[]}function Fr(i){let e=i.loc;return {start:e?.start?.line??1,end:e?.end?.line??1}}function Dr(i,e,t,n){return n?`${n}:${i}:${e}:${t}`:`root:${i}:${e}:${t}`}var yn=createRequire(import.meta.url);function bn(i,e){let t=i.errors||[];t.includes(e)||(i.errors=[...t,e]);}var $t=class extends je{name="JsTsFallbackParser";canParse(e){let t=e.split(".").pop()?.toLowerCase();return ["js","ts","jsx","tsx"].includes(t||"")}parse(e,t){let n=super.parse(e,t);return n.framework=e.endsWith(".ts")||e.endsWith(".tsx")?"ts":"js",n}},jr=[new st,new ve,new je,new it,new $t];function Ue(i,e){for(let t of jr)if(t.canParse(i,e)){let n=t.parse(i,e);return Wr(n),Ur(n,e),n}return {framework:"js",filePath:i,symbols:[],relations:[],behaviors:[],errors:[`\u6CA1\u6709\u627E\u5230\u9002\u5408\u7684\u89E3\u6790\u5668: ${i}`]}}function Ur(i,e){if(i.symbols.length!==0)try{let t=e,n=i.filePath.endsWith(".vue"),r=0;if(n)try{let{parse:u}=yn("@vue/compiler-sfc"),{descriptor:f}=u(e);if(f.scriptSetup?.content)t=f.scriptSetup.content,r=f.scriptSetup.loc.start.line-1;else if(f.script?.content)t=f.script.content,r=f.script.loc.start.line-1;else return}catch(u){bn(i,`\u751F\u547D\u5468\u671F\u63D0\u53D6\u8DF3\u8FC7: Vue SFC \u89E3\u6790\u5931\u8D25 - ${String(u)}`);return}let a=yn("@babel/parser").parse(t,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy"],errorRecovery:!0}).program.body;if(!a?.length)return;let c=t.split(`
428
+ `),a),camelWords:k(o)});let l=e.body?.body;for(let p of l||[]){let d=p.key,u=d?.type==="Identifier"?String(d.name||""):"";if(!u||u==="constructor")continue;if(p.type==="ClassMethod"||p.type==="ClassPrivateMethod"){this.addFunctionSymbol(u,p,t,n,r,{startLine:this.getLineRange(p).start,endLine:this.getLineRange(p).end,isExported:false,ownerClass:o});continue}let f=p.value;f&&(f.type==="ArrowFunctionExpression"||f.type==="FunctionExpression")&&(p.type==="ClassProperty"||p.type==="PropertyDefinition")&&this.addFunctionSymbol(u,f,t,n,r,{startLine:this.getLineRange(p).start,endLine:this.getLineRange(p).end,isExported:false,ownerClass:o});}}extractParams(e){let t=e.params;return t?.length?t.map(n=>{if(n.type==="Identifier")return String(n.name||"");if(n.type==="AssignmentPattern"){let r=n.left;return r?.type==="Identifier"?String(r.name||""):"param"}return "param"}):[]}getLiteralValue(e){if(e){if(e.type==="StringLiteral"||e.type==="NumericLiteral"||e.type==="BooleanLiteral")return String(e.value);if(e.type==="NullLiteral")return "null";if(e.type==="ObjectExpression")return "{...}";if(e.type==="ArrayExpression")return "[...]"}}buildSymbolKey(e,t,n,r){return `${r||"root"}:${e}:${t}:${n}`}getLineRange(e){let t=e.loc;return {start:t?.start?.line??1,end:t?.end?.line??1}}};function Y(i){let e=i.property;return e?e.type==="Identifier"?String(e.name||""):e.type==="Literal"||e.type==="StringLiteral"?String(e.value||""):null:null}function ie(i){let e=i.object;return e?e.type==="Identifier"?String(e.name||""):e.type==="ThisExpression"?Y(i):e.type==="MemberExpression"?e.object?.type==="ThisExpression"?Y(e):ie(e):null:null}function ee(i,e){let t=i||"";return /created|mounted|beforeMount|setup\s*\(|\bdata\s*\(/.test(t)?"init":/getItem|localStorage|sessionStorage|\bfetch\b|\bload[A-Z]|\bget[A-Z]/.test(t)?"cache":/@click|@change|@input|onClick|onChange|handle[A-Z]|\bwatch\b/.test(t)?"user":e<=30?"init":"unknown"}var Rr=new Set(["FunctionDeclaration","ArrowFunctionExpression","FunctionExpression","ObjectMethod","ClassMethod","ClassProperty"]);function un(i,e){return !!e?.skipNestedFunctions&&Rr.has(String(i.type||""))}function me(i,e,t){if(!(!i||typeof i!="object")){e(i);for(let n of Object.keys(i)){if(n==="type"||n==="loc"||n==="start"||n==="end")continue;let r=i[n];if(Array.isArray(r)){for(let s of r){if(!s||typeof s!="object"||!s.type)continue;let o=s;un(o,t)||me(o,e,t);}continue}if(r&&typeof r=="object"&&r.type){let s=r;if(un(s,t))continue;me(s,e,t);}}}}function fn(i,e,t=true,n){let r=[],s=[],o=(a,c=120)=>kr(a,n,c);return me(i,a=>{if(a.type==="VariableDeclarator"){let c=a.id;if(!c)return;let l=ot(c),p=o(a);for(let d of l)r.push({symbolName:d,kind:"declaration",line:Ce(a),text:p,sourceLayer:ee(p,Ce(a))});}if(a.type==="AssignmentExpression"){let c=a.left;if(!c)return;let l=o(a),p=Ce(a);if(c.type==="Identifier"&&r.push({symbolName:c.name,kind:"assignment",line:p,text:l,sourceLayer:ee(l,p)}),c.type==="MemberExpression"&&c.object?.type==="ThisExpression"){let u=Y(c);if(u){r.push({symbolName:u,kind:"assignment",line:p,text:l,sourceLayer:ee(l,p)});return}}if(c.type==="MemberExpression"){let d=ie(c);if(d&&vt(d)){let u=Y(c);s.push({objectName:d,propertyName:u||void 0,line:p,text:l,kind:c.computed?"bracket":"dot",sourceLayer:ee(l,p)});}}}if(a.type==="UpdateExpression"){let c=a.argument;if(!c)return;let l=o(a),p=Ce(a);if(c.type==="Identifier"&&r.push({symbolName:c.name,kind:"update",line:p,text:l,sourceLayer:ee(l,p)}),c.type==="MemberExpression"&&c.object?.type==="ThisExpression"){let u=Y(c);if(u){r.push({symbolName:u,kind:"update",line:p,text:l,sourceLayer:ee(l,p)});return}}if(c.type==="MemberExpression"){let d=ie(c);if(d&&vt(d)){let u=Y(c);s.push({objectName:d,propertyName:u||void 0,line:p,text:l,kind:c.computed?"bracket":"dot",sourceLayer:ee(l,p)});}}}if(a.type==="UnaryExpression"&&a.operator==="delete"){let c=a.argument;if(c?.type==="MemberExpression"){let l=ie(c);if(l&&vt(l)){let p=Y(c);s.push({objectName:l,propertyName:p||void 0,line:Ce(a),text:o(a),kind:"delete",sourceLayer:ee(o(a),Ce(a))});}}}},{skipNestedFunctions:t}),{assignments:r,propertyWrites:s}}function ot(i){return i.type==="Identifier"?[i.name]:i.type==="ObjectPattern"?(i.properties||[]).flatMap(t=>{let n=t.type==="ObjectProperty"||t.type==="Property"?t.value:t;return n?ot(n):[]}):i.type==="ArrayPattern"?(i.elements||[]).flatMap(t=>t?ot(t):[]):i.type==="AssignmentPattern"?ot(i.left):[]}function vt(i){return !(/^[A-Z][A-Z]/.test(i)||/^(document|window|console|localStorage|sessionStorage|navigator|process|global|globalThis)$/.test(i))}function Ce(i){return i.loc?.start?.line??1}function kr(i,e,t=120){if(e){let r=i.loc;if(r?.start?.line&&r?.end?.line){let s=r.start.line-1,o=Math.min(r.end.line-1,s+5);return e.slice(s,o+1).map(c=>c.trim()).filter(c=>c).join(" ").slice(0,t)}}let n=i.loc;return n?.start?.line?`L${n.start.line}`:String(i.type||"?")}var vr=createRequire(import.meta.url);function It(i,e){let t={files:new Map,resolutionCache:new Map,localShadowCache:new Map};for(let{path:n,content:r}of i){let s=pn(n,r);t.files.set(n,s);let o=new Map;for(let a of s.imports)a.localName&&o.set(a.localName,`${a.resolvedFile}::${a.originalName}`);t.resolutionCache.set(n,o),t.localShadowCache.set(n,Cr(r));}return t}function $t(i,e,t,n){if(t.files.size===0)return i;let r=t.resolutionCache.get(e);if(!r||r.size===0)return i;let s=t.localShadowCache.get(e);return t.files.get(e)?i.map(c=>{let l=r.get(c.calleeName);return !l||c.callerKey&&s?.get(c.callerKey)?.has(c.calleeName)||n.has(c.calleeName)?c:{...c,edgeKind:"precise",importSource:c.importSource||l}}):i}function Cr(i){let e=new Map;try{let n=vr("@babel/parser").parse(i,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy","classProperties"],errorRecovery:!0}),r=(n.program||n).body;if(!r?.length)return e;for(let s of r)gn(s,e);}catch{return e}return e}function gn(i,e){if(i.type==="FunctionDeclaration"){let t=xe(i.id);if(!t)return;Ie(t,i,e),Ir(Pr(i),t,e);return}if(i.type==="VariableDeclaration"){hn(i,void 0,e);return}if(i.type==="ClassDeclaration"){$r(i,e);return}if(i.type==="ExportNamedDeclaration"||i.type==="ExportDefaultDeclaration"){let t=i.declaration;if(!t)return;gn(t,e);}}function Ir(i,e,t){for(let n of i){if(n.type==="FunctionDeclaration"){let r=xe(n.id);if(!r)continue;Ie(r,n,t,e);continue}if(n.type==="VariableDeclaration"){hn(n,e,t);continue}if(n.type==="ExpressionStatement"){let r=n.expression;if(r?.type!=="CallExpression")continue;let s=r.callee,o=s?.type==="Identifier"?String(s.name||""):"";if(!/^use[A-Z]/.test(o))continue;let a=r.arguments?.[0];if(!a||a.type!=="ArrowFunctionExpression"&&a.type!=="FunctionExpression")continue;Ie(o,a,t,e,n);}}}function hn(i,e,t){for(let n of i.declarations||[]){let r=xe(n.id),s=n.init;!r||!s||s.type!=="ArrowFunctionExpression"&&s.type!=="FunctionExpression"||Ie(r,s,t,e,n);}}function $r(i,e){let t=xe(i.id);if(!t)return;let n=i.body?.body||[];for(let r of n){let s=xe(r.key);if(!s||s==="constructor")continue;if(r.type==="ClassMethod"||r.type==="ClassPrivateMethod"){Ie(s,r,e,t);continue}let o=r.value;o&&(o.type==="ArrowFunctionExpression"||o.type==="FunctionExpression")&&(r.type==="ClassProperty"||r.type==="PropertyDefinition")&&Ie(s,o,e,t,r);}}function Ie(i,e,t,n,r){let s=Fr(r||e),o=Dr(i,s.start,s.end,n),a=Or(e);t.set(o,a);}function Or(i){let e=new Set;for(let n of i.params||[])for(let r of Se(n))e.add(r);let t=i.body;return t&&Ct(t,n=>{if(n.type==="VariableDeclarator"){for(let r of Se(n.id))e.add(r);return}if(n.type==="FunctionDeclaration"){let r=xe(n.id);return r&&e.add(r),false}if(n.type==="ClassDeclaration"){let r=xe(n.id);return r&&e.add(r),false}}),e}function Ct(i,e){if(!(!i||typeof i!="object")&&e(i)!==false)for(let t of Object.keys(i)){if(t==="type"||t==="loc"||t==="start"||t==="end")continue;let n=i[t];if(Array.isArray(n)){for(let r of n){if(!r||typeof r!="object"||!r.type)continue;let s=r;mn(s)||Ct(s,e);}continue}if(n&&typeof n=="object"&&n.type){let r=n;if(mn(r))continue;Ct(r,e);}}}function mn(i){return ["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression","ClassMethod","ClassPrivateMethod","ObjectMethod"].includes(String(i.type||""))}function Se(i){return i?i.type==="Identifier"?[String(i.name||"")]:i.type==="AssignmentPattern"?Se(i.left):i.type==="RestElement"?Se(i.argument):i.type==="ArrayPattern"?(i.elements||[]).flatMap(e=>Se(e)):i.type==="ObjectPattern"?(i.properties||[]).flatMap(e=>{if(e.type==="RestElement")return Se(e.argument);let t=e.value||e.argument;return Se(t)}):[]:[]}function xe(i){if(i&&i.type==="Identifier")return String(i.name||"")}function Pr(i){let e=i.body;return !e||e.type!=="BlockStatement"?[]:e.body||[]}function Fr(i){let e=i.loc;return {start:e?.start?.line??1,end:e?.end?.line??1}}function Dr(i,e,t,n){return n?`${n}:${i}:${e}:${t}`:`root:${i}:${e}:${t}`}var yn=createRequire(import.meta.url);function bn(i,e){let t=i.errors||[];t.includes(e)||(i.errors=[...t,e]);}var Ot=class extends je{name="JsTsFallbackParser";canParse(e){let t=e.split(".").pop()?.toLowerCase();return ["js","ts","jsx","tsx"].includes(t||"")}parse(e,t){let n=super.parse(e,t);return n.framework=e.endsWith(".ts")||e.endsWith(".tsx")?"ts":"js",n}},jr=[new st,new ve,new je,new it,new Ot];function Ue(i,e){for(let t of jr)if(t.canParse(i,e)){let n=t.parse(i,e);return Wr(n),Ur(n,e),n}return {framework:"js",filePath:i,symbols:[],relations:[],behaviors:[],errors:[`\u6CA1\u6709\u627E\u5230\u9002\u5408\u7684\u89E3\u6790\u5668: ${i}`]}}function Ur(i,e){if(i.symbols.length!==0)try{let t=e,n=i.filePath.endsWith(".vue"),r=0;if(n)try{let{parse:u}=yn("@vue/compiler-sfc"),{descriptor:f}=u(e);if(f.scriptSetup?.content)t=f.scriptSetup.content,r=f.scriptSetup.loc.start.line-1;else if(f.script?.content)t=f.script.content,r=f.script.loc.start.line-1;else return}catch(u){bn(i,`\u751F\u547D\u5468\u671F\u63D0\u53D6\u8DF3\u8FC7: Vue SFC \u89E3\u6790\u5931\u8D25 - ${String(u)}`);return}let a=yn("@babel/parser").parse(t,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy"],errorRecovery:!0}).program.body;if(!a?.length)return;let c=t.split(`
429
429
  `),{assignments:l,propertyWrites:p}=fn({type:"Program",body:a},i.filePath,!1,c);if(r>0){for(let u of l)u.line+=r;for(let u of p)u.line+=r;}let d=new Set(i.symbols.map(u=>u.name));i.assignments=l.filter(u=>d.has(u.symbolName)),i.propertyWrites=p.filter(u=>d.has(u.objectName));}catch(t){bn(i,`\u751F\u547D\u5468\u671F\u63D0\u53D6\u8DF3\u8FC7: AST \u89E3\u6790\u5931\u8D25 - ${String(t)}`);}}function Wr(i){if(!i.relations.length||!i.behaviors.length)return;let e=new Set(["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","activated","deactivated","errorCaptured","setup","onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","onActivated","onDeactivated","onErrorCaptured","componentDidMount","componentDidUpdate","componentWillUnmount","componentDidCatch","getDerivedStateFromProps","getSnapshotBeforeUpdate","render","init","initialize"]),t=new Set(i.behaviors.filter(r=>r.category==="network").map(r=>r.symbolName));if(t.size===0)return;let n=new Set(i.behaviors.map(r=>`${r.symbolName}:${r.category}:${r.apiName}:${r.operation}:${r.line}`));for(let r of i.relations){if(!t.has(r.calleeName)||t.has(r.callerName)||e.has(r.callerName))continue;let s={symbolName:r.callerName,symbolKey:r.callerKey,category:"network",apiName:"wrapped_network",operation:r.calleeName,detail:r.args,line:r.line},o=`${s.symbolName}:${s.category}:${s.apiName}:${s.operation}:${s.line}`;n.has(o)||(n.add(o),i.behaviors.push(s));}}function We(i,e){let t=Hr(e),n=i.exportSignatureEntries?.length?[...i.exportSignatureEntries]:(()=>{let a=[];for(let c of i.symbols)if(c.isExported){let l=c.signature||"";a.push(`${c.name}:${l}`);}return a.sort(),a})(),r=n.length>0?En(n.join(`
430
430
  `)):"",s=[];if(i.fileDependencies&&i.fileDependencies.length>0)for(let a of i.fileDependencies)(a.dependencyKind==="import"||a.dependencyKind==="re_export")&&s.push(a.toFile);s.sort();let o=s.length>0?En(s.join(`
431
- `)):"";return {contentHash:t,exportSignatureHash:r,importSignatureHash:o}}function Nn(i,e){if(!i)return "full_changed";if(i.contentHash===e.contentHash)return "unchanged";let t=i.exportSignatureHash!==e.exportSignatureHash,n=i.importSignatureHash!==e.importSignatureHash;return t&&n?"full_changed":t?"export_changed":n?"import_changed":"body_only"}function Tn(i,e,t,n=200){if(e==="unchanged")return {files:[],truncated:false};if(e==="body_only")return {files:[i],truncated:false};if(e==="import_changed")return {files:[i],truncated:false};let r=new Set([i]),s=[i];for(;s.length>0;){let o=s.shift(),a=t.get(o)||[];for(let c of a)if(!r.has(c)){if(r.add(c),r.size>=n)return {files:Array.from(r),truncated:true};s.push(c);}}return {files:Array.from(r),truncated:false}}function Hr(i){return createHash("sha256").update(i,"utf-8").digest("hex").slice(0,16)}function En(i){return createHash("sha256").update(i,"utf-8").digest("hex").slice(0,12)}var Br={maxFiles:20,maxTimeMs:1500},at=class{pending=[];options;constructor(e){this.options={...Br,...e};}configure(e){this.options={...this.options,...e};}enqueue(e,t){let n=this.pending.find(r=>r.relPath===e);if(n){let r={high:3,normal:2,low:1};r[t]>r[n.priority]&&(n.priority=t);return}this.pending.push({relPath:e,priority:t,addedAt:Date.now()});}dequeueBatch(){if(this.pending.length===0)return {tasks:[],exceededBudget:false,remainingPending:0};let e={high:0,normal:1,low:2};this.pending.sort((s,o)=>{let a=e[s.priority],c=e[o.priority];return a!==c?a-c:s.addedAt-o.addedAt});let t=[],n=this.pending.length>this.options.maxFiles;for(let s=0;s<Math.min(this.options.maxFiles,this.pending.length);s++)t.push(this.pending[s]);let r=new Set(t.map(s=>s.relPath));return this.pending=this.pending.filter(s=>!r.has(s.relPath)),{tasks:t,exceededBudget:n,remainingPending:this.pending.length}}requeue(e){if(e.length===0)return;let t=new Set(this.pending.map(r=>r.relPath)),n=e.filter(r=>!t.has(r.relPath));this.pending=[...n,...this.pending];}clear(){this.pending=[];}get pendingCount(){return this.pending.length}get budget(){return this.options}summary(){return this.pending.map(e=>({relPath:e.relPath,priority:e.priority}))}};var ct=class{projectRoot;db;scheduler;constructor(e,t){this.projectRoot=e,this.db=t,this.scheduler=new at;}getScheduler(){return this.scheduler}enhancePreciseRelations(e){try{let t=e.filter(({absPath:r})=>/\.(ts|tsx|js|jsx)$/i.test(r)).map(({absPath:r,content:s})=>({path:r,content:s})),n=Ct(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=It(r.result.relations,r.result.filePath,n,s);}}catch(t){let n=`precise enhancement \u5931\u8D25\uFF0C\u5DF2\u56DE\u9000\u5230\u672C\u5730 relations: ${String(t)}`;process.stderr.write(`[Frontend-Code-Skimmer] ${n}
432
- `);for(let r of e){let s=r.result.errors||[];s.includes(n)||(r.result.errors=[...s,n]);}}}async indexProject(e){let t=Date.now(),n=e?.include||[...Et],r=e?.exclude||[...bt],s=e?.force||false,o=Date.now(),a=await Xr(n,{cwd:this.projectRoot,ignore:r,absolute:true,onlyFiles:true}),c=Date.now()-o,l={totalFiles:a.length,indexedFiles:0,skippedFiles:0,totalSymbols:0,durationMs:0,phaseTimings:{discoverFilesMs:c,readFilesMs:0,parseMs:0,saveToDbMs:0,totalMs:0},errors:[]},p=0,d=0,u=0;if((e?.precisionMode||"heuristic")==="precise"){let m=[];for(let g=0;g<a.length;g++){let y=a[g],b=de(y,this.projectRoot);e?.onProgress?.(g+1,a.length,b);try{let T=Z__default.statSync(y).mtimeMs,h=Date.now(),E=Z__default.readFileSync(y,"utf-8"),N=Date.now()-h,R=Date.now(),_=Ue(y,E),x=Date.now()-R;p+=N,d+=x,m.push({absPath:y,relPath:b,result:_,parseMs:x,readMs:N,content:E,mtime:T});}catch(T){this.db.recordIndexFailure(b,String(T)),l.errors.push({file:b,error:String(T)});}}this.enhancePreciseRelations(m);for(let g of m){let y=Date.now();try{let b=Fe(g.content),T=Ge(g.content),h=Buffer.byteLength(g.content,"utf-8"),E=We(g.result,g.content);this.db.saveParseResult(g.result,g.absPath,g.relPath,b,h,T,g.mtime,E.exportSignatureHash,E.importSignatureHash),l.indexedFiles++,l.totalSymbols+=g.result.symbols.length,g.result.errors?.length&&l.errors.push(...g.result.errors.map(N=>({file:g.relPath,error:N}))),u+=Date.now()-y;}catch(b){this.db.recordIndexFailure(g.relPath,String(b)),l.errors.push({file:g.relPath,error:String(b)});}}}else for(let m=0;m<a.length;m++){let g=a[m],y=de(g,this.projectRoot);e?.onProgress?.(m+1,a.length,y);try{let b=await this.indexFile(g,y,s);b.skipped?l.skippedFiles++:(l.indexedFiles++,l.totalSymbols+=b.symbolCount,p+=b.readMs||0,d+=b.parseMs||0,u+=b.saveMs||0,b.errors?.length&&l.errors.push(...b.errors.map(T=>({file:y,error:T}))));}catch(b){this.db.recordIndexFailure(y,String(b)),l.errors.push({file:y,error:String(b)});}}return l.phaseTimings.readFilesMs=p,l.phaseTimings.parseMs=d,l.phaseTimings.saveToDbMs=u,l.phaseTimings.totalMs=Date.now()-t,l.durationMs=l.phaseTimings.totalMs,l}async selectivePrecise(e){let t=Date.now(),n=e?.maxFiles??20,r=e?.maxTimeMs??1500;this.scheduler.configure({maxFiles:n,maxTimeMs:r});let s=this.db.getAllFilePaths(),o=this.db.getReverseDependencyMap(),a=new Set;for(let y of s){let b=this.fileAbsPath(y);if(!Z__default.existsSync(b))continue;let T=this.db.getFileSignatures(y);if(!T){this.scheduler.enqueue(y,"low");continue}let h;try{h=Z__default.statSync(b);let O=this.db.getFileHashAndMtime(y);if(O&&O.mtime===h.mtimeMs&&O.contentHash)continue}catch{continue}let E=Z__default.readFileSync(b,"utf-8"),N=Fe(E);if(T.contentHash===N){this.db.updateFileMtime(y,h.mtimeMs);continue}let R=Ue(b,E),_=We(R,E),x=Nn(T,_);if(x==="unchanged")continue;let{files:A,truncated:w}=Tn(y,x,o);w&&process.stderr.write(`[Frontend-Code-Skimmer] \u26A0\uFE0F ${y} \u7684\u53CD\u5411\u4F9D\u8D56\u6269\u6563\u5DF2\u8FBE\u4E0A\u9650\uFF08200\uFF09\uFF0C\u90E8\u5206\u4E0B\u6E38\u6587\u4EF6\u5C06\u8DF3\u8FC7\u672C\u6B21 precise \u91CD\u7B97
431
+ `)):"";return {contentHash:t,exportSignatureHash:r,importSignatureHash:o}}function Nn(i,e){if(!i)return "full_changed";if(i.contentHash===e.contentHash)return "unchanged";let t=i.exportSignatureHash!==e.exportSignatureHash,n=i.importSignatureHash!==e.importSignatureHash;return t&&n?"full_changed":t?"export_changed":n?"import_changed":"body_only"}function Tn(i,e,t,n=200){if(e==="unchanged")return {files:[],truncated:false};if(e==="body_only")return {files:[i],truncated:false};if(e==="import_changed")return {files:[i],truncated:false};let r=new Set([i]),s=[i];for(;s.length>0;){let o=s.shift(),a=t.get(o)||[];for(let c of a)if(!r.has(c)){if(r.add(c),r.size>=n)return {files:Array.from(r),truncated:true};s.push(c);}}return {files:Array.from(r),truncated:false}}function Hr(i){return createHash("sha256").update(i,"utf-8").digest("hex").slice(0,16)}function En(i){return createHash("sha256").update(i,"utf-8").digest("hex").slice(0,12)}var Br={maxFiles:20,maxTimeMs:1500},at=class{pending=[];options;constructor(e){this.options={...Br,...e};}configure(e){this.options={...this.options,...e};}enqueue(e,t){let n=this.pending.find(r=>r.relPath===e);if(n){let r={high:3,normal:2,low:1};r[t]>r[n.priority]&&(n.priority=t);return}this.pending.push({relPath:e,priority:t,addedAt:Date.now()});}dequeueBatch(){if(this.pending.length===0)return {tasks:[],exceededBudget:false,remainingPending:0};let e={high:0,normal:1,low:2};this.pending.sort((s,o)=>{let a=e[s.priority],c=e[o.priority];return a!==c?a-c:s.addedAt-o.addedAt});let t=[],n=this.pending.length>this.options.maxFiles;for(let s=0;s<Math.min(this.options.maxFiles,this.pending.length);s++)t.push(this.pending[s]);let r=new Set(t.map(s=>s.relPath));return this.pending=this.pending.filter(s=>!r.has(s.relPath)),{tasks:t,exceededBudget:n,remainingPending:this.pending.length}}requeue(e){if(e.length===0)return;let t=new Set(this.pending.map(r=>r.relPath)),n=e.filter(r=>!t.has(r.relPath));this.pending=[...n,...this.pending];}clear(){this.pending=[];}get pendingCount(){return this.pending.length}get budget(){return this.options}summary(){return this.pending.map(e=>({relPath:e.relPath,priority:e.priority}))}};var ct=class{projectRoot;db;scheduler;constructor(e,t){this.projectRoot=e,this.db=t,this.scheduler=new at;}getScheduler(){return this.scheduler}enhancePreciseRelations(e){try{let t=e.filter(({absPath:r})=>/\.(ts|tsx|js|jsx)$/i.test(r)).map(({absPath:r,content:s})=>({path:r,content:s})),n=It(t,"precise");if(n.files.size===0)return;for(let r of e){if(r.result.relations.length===0)continue;let s=new Set(r.result.symbols.map(o=>o.name));r.result.relations=$t(r.result.relations,r.result.filePath,n,s);}}catch(t){let n=`precise enhancement \u5931\u8D25\uFF0C\u5DF2\u56DE\u9000\u5230\u672C\u5730 relations: ${String(t)}`;process.stderr.write(`[Frontend-Code-Skimmer] ${n}
432
+ `);for(let r of e){let s=r.result.errors||[];s.includes(n)||(r.result.errors=[...s,n]);}}}async indexProject(e){let t=Date.now(),n=e?.include||[..._t],r=e?.exclude||[...Et],s=e?.force||false,o=Date.now(),a=await Xr(n,{cwd:this.projectRoot,ignore:r,absolute:true,onlyFiles:true}),c=Date.now()-o,l={totalFiles:a.length,indexedFiles:0,skippedFiles:0,totalSymbols:0,durationMs:0,phaseTimings:{discoverFilesMs:c,readFilesMs:0,parseMs:0,saveToDbMs:0,totalMs:0},errors:[]},p=0,d=0,u=0;if((e?.precisionMode||"heuristic")==="precise"){let m=[];for(let g=0;g<a.length;g++){let y=a[g],b=de(y,this.projectRoot);e?.onProgress?.(g+1,a.length,b);try{let T=Z__default.statSync(y).mtimeMs,h=Date.now(),E=Z__default.readFileSync(y,"utf-8"),N=Date.now()-h,R=Date.now(),_=Ue(y,E),x=Date.now()-R;p+=N,d+=x,m.push({absPath:y,relPath:b,result:_,parseMs:x,readMs:N,content:E,mtime:T});}catch(T){this.db.recordIndexFailure(b,String(T)),l.errors.push({file:b,error:String(T)});}}this.enhancePreciseRelations(m);for(let g of m){let y=Date.now();try{let b=Fe(g.content),T=Ge(g.content),h=Buffer.byteLength(g.content,"utf-8"),E=We(g.result,g.content);this.db.saveParseResult(g.result,g.absPath,g.relPath,b,h,T,g.mtime,E.exportSignatureHash,E.importSignatureHash),l.indexedFiles++,l.totalSymbols+=g.result.symbols.length,g.result.errors?.length&&l.errors.push(...g.result.errors.map(N=>({file:g.relPath,error:N}))),u+=Date.now()-y;}catch(b){this.db.recordIndexFailure(g.relPath,String(b)),l.errors.push({file:g.relPath,error:String(b)});}}}else for(let m=0;m<a.length;m++){let g=a[m],y=de(g,this.projectRoot);e?.onProgress?.(m+1,a.length,y);try{let b=await this.indexFile(g,y,s);b.skipped?l.skippedFiles++:(l.indexedFiles++,l.totalSymbols+=b.symbolCount,p+=b.readMs||0,d+=b.parseMs||0,u+=b.saveMs||0,b.errors?.length&&l.errors.push(...b.errors.map(T=>({file:y,error:T}))));}catch(b){this.db.recordIndexFailure(y,String(b)),l.errors.push({file:y,error:String(b)});}}return l.phaseTimings.readFilesMs=p,l.phaseTimings.parseMs=d,l.phaseTimings.saveToDbMs=u,l.phaseTimings.totalMs=Date.now()-t,l.durationMs=l.phaseTimings.totalMs,l}async selectivePrecise(e){let t=Date.now(),n=e?.maxFiles??20,r=e?.maxTimeMs??1500;this.scheduler.configure({maxFiles:n,maxTimeMs:r});let s=this.db.getAllFilePaths(),o=this.db.getReverseDependencyMap(),a=new Set;for(let y of s){let b=this.fileAbsPath(y);if(!Z__default.existsSync(b))continue;let T=this.db.getFileSignatures(y);if(!T){this.scheduler.enqueue(y,"low");continue}let h;try{h=Z__default.statSync(b);let O=this.db.getFileHashAndMtime(y);if(O&&O.mtime===h.mtimeMs&&O.contentHash)continue}catch{continue}let E=Z__default.readFileSync(b,"utf-8"),N=Fe(E);if(T.contentHash===N){this.db.updateFileMtime(y,h.mtimeMs);continue}let R=Ue(b,E),_=We(R,E),x=Nn(T,_);if(x==="unchanged")continue;let{files:A,truncated:w}=Tn(y,x,o);w&&process.stderr.write(`[Frontend-Code-Skimmer] \u26A0\uFE0F ${y} \u7684\u53CD\u5411\u4F9D\u8D56\u6269\u6563\u5DF2\u8FBE\u4E0A\u9650\uFF08200\uFF09\uFF0C\u90E8\u5206\u4E0B\u6E38\u6587\u4EF6\u5C06\u8DF3\u8FC7\u672C\u6B21 precise \u91CD\u7B97
433
433
  `);for(let O of A)a.add(O);let M=x==="export_changed"||x==="full_changed"?"high":x==="import_changed"?"normal":"low";for(let O of A)this.scheduler.enqueue(O,M);}let{tasks:c,exceededBudget:l,remainingPending:p}=this.scheduler.dequeueBatch(),d=[],u=[],f=0;for(let y=0;y<c.length;y++){let T=c[y].relPath;if(a.add(T),Date.now()-t>=r){u.push(...c.slice(y));break}let h=this.fileAbsPath(T);if(!Z__default.existsSync(h)){this.removeFile(T);continue}try{let E=Z__default.readFileSync(h,"utf-8"),N=Ue(h,E),R=Fe(E),_=Ge(E),x=Buffer.byteLength(E,"utf-8");d.push({absPath:h,relPath:T,result:N,content:E,hash:R,lineCount:_,fileSize:x,mtime:Z__default.statSync(h).mtimeMs});}catch(E){this.db.recordIndexFailure(T,String(E)),process.stderr.write(`[Frontend-Code-Skimmer] Selective precise \u5931\u8D25: ${T} - ${String(E)}
434
434
  `);}}u.length>0&&this.scheduler.requeue(u),this.enhancePreciseRelations(d);for(let y of d)try{let b=We(y.result,y.content);this.db.saveParseResult(y.result,y.absPath,y.relPath,y.hash,y.fileSize,y.lineCount,y.mtime,b.exportSignatureHash,b.importSignatureHash),f++;}catch(b){this.db.recordIndexFailure(y.relPath,String(b)),process.stderr.write(`[Frontend-Code-Skimmer] Selective precise \u843D\u5E93\u5931\u8D25: ${y.relPath} - ${String(b)}
435
435
  `);}let m=Date.now()-t,g=p+u.length;return process.stderr.write(`[Frontend-Code-Skimmer] Selective precise: ${f}/${a.size} affected, ${m}ms, pending: ${g}${l||u.length>0?" (budget limited)":""}
436
- `),{reindexedFiles:f,affectedFiles:Array.from(a),skippedByBudget:g}}async indexFile(e,t,n=false){let r=0,s=0,o=null;if(!n){try{let h=Z__default.statSync(e);r=h.mtimeMs,s=h.size;}catch{}if(o=this.db.getFileMeta(t),o&&o.mtime>0&&o.mtime===r&&!(o.fileSize>0&&o.fileSize!==s))return {skipped:true,symbolCount:0,readMs:0,parseMs:0,saveMs:0}}let a=Date.now(),c=Z__default.readFileSync(e,"utf-8"),l=Date.now()-a,p=Fe(c);if(!n&&o&&o.hash===p)return r>0&&o.mtime!==r&&this.db.updateFileMtime(t,r),{skipped:true,symbolCount:0,readMs:l,parseMs:0,saveMs:0};let d=Ge(c),u=Buffer.byteLength(c,"utf-8"),f=Date.now(),m=Ue(e,c),g=Date.now()-f,y=We(m,c),b=Date.now();this.db.clearIndexFailures(t),this.db.saveParseResult(m,e,t,p,u,d,r,y.exportSignatureHash,y.importSignatureHash);let T=Date.now()-b;return {skipped:false,symbolCount:m.symbols.length,readMs:l,parseMs:g,saveMs:T,errors:m.errors}}removeFile(e){this.db.deleteFile(e);}fileAbsPath(e){return K__default.join(this.projectRoot,e)}async startWatcher(){let{default:e}=await import('chokidar'),t=e.watch([...Et].map(r=>K__default.posix.join(this.projectRoot,r)),{cwd:this.projectRoot,ignored:[...bt],persistent:true,ignoreInitial:true,awaitWriteFinish:{stabilityThreshold:rn}}),n=async r=>{let s=de(r,this.projectRoot);try{await this.indexFile(r,s),this.scheduler.enqueue(s,"normal"),process.stderr.write(`[Frontend-Code-Skimmer] \u5DF2\u66F4\u65B0\u7D22\u5F15: ${s}
436
+ `),{reindexedFiles:f,affectedFiles:Array.from(a),skippedByBudget:g}}async indexFile(e,t,n=false){let r=0,s=0,o=null;if(!n){try{let h=Z__default.statSync(e);r=h.mtimeMs,s=h.size;}catch{}if(o=this.db.getFileMeta(t),o&&o.mtime>0&&o.mtime===r&&!(o.fileSize>0&&o.fileSize!==s))return {skipped:true,symbolCount:0,readMs:0,parseMs:0,saveMs:0}}let a=Date.now(),c=Z__default.readFileSync(e,"utf-8"),l=Date.now()-a,p=Fe(c);if(!n&&o&&o.hash===p)return r>0&&o.mtime!==r&&this.db.updateFileMtime(t,r),{skipped:true,symbolCount:0,readMs:l,parseMs:0,saveMs:0};let d=Ge(c),u=Buffer.byteLength(c,"utf-8"),f=Date.now(),m=Ue(e,c),g=Date.now()-f,y=We(m,c),b=Date.now();this.db.clearIndexFailures(t),this.db.saveParseResult(m,e,t,p,u,d,r,y.exportSignatureHash,y.importSignatureHash);let T=Date.now()-b;return {skipped:false,symbolCount:m.symbols.length,readMs:l,parseMs:g,saveMs:T,errors:m.errors}}removeFile(e){this.db.deleteFile(e);}fileAbsPath(e){return K__default.join(this.projectRoot,e)}async startWatcher(){let{default:e}=await import('chokidar'),t=e.watch([..._t].map(r=>K__default.posix.join(this.projectRoot,r)),{cwd:this.projectRoot,ignored:[...Et],persistent:true,ignoreInitial:true,awaitWriteFinish:{stabilityThreshold:rn}}),n=async r=>{let s=de(r,this.projectRoot);try{await this.indexFile(r,s),this.scheduler.enqueue(s,"normal"),process.stderr.write(`[Frontend-Code-Skimmer] \u5DF2\u66F4\u65B0\u7D22\u5F15: ${s}
437
437
  `);}catch(o){process.stderr.write(`[Frontend-Code-Skimmer] \u66F4\u65B0\u5931\u8D25: ${s} - ${String(o)}
438
438
  `);}};return t.on("add",n).on("change",n).on("unlink",r=>{let s=de(r,this.projectRoot);this.removeFile(s),process.stderr.write(`[Frontend-Code-Skimmer] \u5DF2\u5220\u9664\u7D22\u5F15: ${s}
439
439
  `);}),()=>t.close()}};var zr=8,Gr=30,qr=14,Jr=360*60*1e3,lt=class{dbCache=new Map;accessTimes=new Map;indexerCache=new Map;dbPaths=new Map;watcherCleanups=new Map;lastProject=null;globalCacheDir;defaultProject;maxOpenProjects;maxIdleMs;dbTtlMs;lastDiskCleanupAt=0;constructor(){this.globalCacheDir=K__default.join(Kr.homedir(),".frontend-code-skimmer","databases"),Z__default.mkdirSync(this.globalCacheDir,{recursive:true}),this.defaultProject=process.env.SKIMMER_PROJECT||null,this.defaultProject&&(this.defaultProject=K__default.resolve(this.defaultProject)),this.maxOpenProjects=this.parsePositiveInt(process.env.SKIMMER_MAX_OPEN_PROJECTS,zr);let e=this.parsePositiveInt(process.env.SKIMMER_DB_IDLE_MINUTES,Gr),t=this.parsePositiveInt(process.env.SKIMMER_DB_TTL_DAYS,qr);this.maxIdleMs=e*60*1e3,this.dbTtlMs=t*24*60*60*1e3,this.maybeCleanupDiskCache(Date.now());}resolveProjectRoot(e){if(e){let t=K__default.resolve(e);if(!Z__default.existsSync(t))throw new Error(`\u9879\u76EE\u8DEF\u5F84\u4E0D\u5B58\u5728: ${t}`);return t}return this.lastProject?this.lastProject:this.defaultProject?this.defaultProject:process.cwd()}getDatabase(e){let t=K__default.resolve(e),n=Date.now();if(this.evictIdleDatabases(n),this.maybeCleanupDiskCache(n),this.dbCache.has(t))return this.touchProject(t,n),this.dbCache.get(t);this.evictLruIfNeeded(n);let r=this.resolveDbPath(t),s=new Je(t,r);return this.dbCache.set(t,s),this.dbPaths.set(t,r),this.touchProject(t,n),this.lastProject=t,process.stderr.write(`[Frontend-Code-Skimmer] \u5DF2\u8FDE\u63A5\u9879\u76EE: ${t}
440
440
  `),process.stderr.write(`[Frontend-Code-Skimmer] \u6570\u636E\u5E93: ${r}
441
- `),s}getContext(e){let t=this.resolveProjectRoot(e),n=this.getDatabase(t);return this.lastProject=t,{db:n,projectRoot:t}}getIndexer(e){let t=this.resolveProjectRoot(e),n=K__default.resolve(t),r=Date.now();if(this.evictIdleDatabases(r),this.maybeCleanupDiskCache(r),this.indexerCache.has(n))return this.touchProject(n,r),this.lastProject=n,this.indexerCache.get(n);let s=this.getDatabase(n),o=new ct(n,s);return this.indexerCache.set(n,o),this.touchProject(n,r),this.lastProject=n,o}setLastProject(e){this.lastProject=K__default.resolve(e);}listProjects(){return Array.from(this.dbCache.entries()).map(([e])=>({root:e,dbPath:this.dbPaths.get(e)||this.resolveDbPath(e)}))}registerWatcher(e,t){let n=K__default.resolve(e),r=this.watcherCleanups.get(n);if(r)try{r();}catch{}this.watcherCleanups.set(n,t);}hasWatcher(e){let t=K__default.resolve(e);return this.watcherCleanups.has(t)}closeProject(e){let t=K__default.resolve(e),n=this.watcherCleanups.get(t);if(n){try{n();}catch{}this.watcherCleanups.delete(t);}let r=this.dbCache.get(t);r&&(r.close(),this.dbCache.delete(t),this.accessTimes.delete(t),this.indexerCache.delete(t),this.dbPaths.delete(t),this.lastProject===t&&(this.lastProject=null));}closeAll(){for(let e of this.watcherCleanups.values())try{e();}catch{}this.watcherCleanups.clear();for(let e of this.dbCache.values())e.close();this.dbCache.clear(),this.indexerCache.clear(),this.accessTimes.clear(),this.dbPaths.clear(),this.lastProject=null;}resolveDbPath(e){if(process.env.SKIMMER_DB&&this.dbCache.size===0)return K__default.resolve(process.env.SKIMMER_DB);let t=K__default.join(e,".agent","skimmer_find_symbol"),n=K__default.join(t,qe);try{return Z__default.mkdirSync(t,{recursive:!0}),Z__default.accessSync(e,Z__default.constants.W_OK),n}catch{let r=createHash("md5").update(e).digest("hex").slice(0,8),s=e.replace(/[/\\:]/g,"_").replace(/^_+/,"").slice(-40);return K__default.join(this.globalCacheDir,`${r}_${s}.db`)}}parsePositiveInt(e,t){let n=Number.parseInt(String(e||""),10);return Number.isFinite(n)&&n>0?n:t}touchProject(e,t){this.accessTimes.set(e,t);}evictLruIfNeeded(e){for(;this.dbCache.size>=this.maxOpenProjects;){let t=null,n=Number.POSITIVE_INFINITY;for(let r of this.dbCache.keys()){let s=this.accessTimes.get(r)??e;s<n&&(n=s,t=r);}if(!t)break;this.closeProject(t);}}evictIdleDatabases(e){let t=[];for(let n of this.dbCache.keys()){if(n===this.lastProject)continue;let r=this.accessTimes.get(n)??e;e-r>this.maxIdleMs&&t.push(n);}for(let n of t)this.closeProject(n);}maybeCleanupDiskCache(e){if(e-this.lastDiskCleanupAt<Jr)return;this.lastDiskCleanupAt=e;let t=[];try{t=Z__default.readdirSync(this.globalCacheDir,{withFileTypes:!0});}catch{return}let n=new Set;for(let s of this.dbPaths.values())s.startsWith(this.globalCacheDir)&&n.add(K__default.resolve(s));let r=e-this.dbTtlMs;for(let s of t){if(!s.isFile()||!s.name.endsWith(".db"))continue;let o=K__default.join(this.globalCacheDir,s.name);if(n.has(K__default.resolve(o)))continue;let a;try{a=Z__default.statSync(o);}catch{continue}a.mtimeMs>=r||(this.safeUnlink(o),this.safeUnlink(`${o}-wal`),this.safeUnlink(`${o}-shm`));}}safeUnlink(e){try{Z__default.existsSync(e)&&Z__default.unlinkSync(e);}catch{}}};var Ot=createRequire(import.meta.url);function xn(i,e){let t=[];if(i==="heuristic")return {effective:"heuristic",warnings:t};let n=Ot("fs"),s=Ot("path").join(e,"tsconfig.json");if(!n.existsSync(s))return t.push(`precise \u6A21\u5F0F\u964D\u7EA7\u4E3A heuristic: \u9879\u76EE\u6839\u76EE\u5F55\u672A\u627E\u5230 tsconfig.json (${s})`),{effective:"heuristic",warnings:t};try{Ot.resolve("typescript");}catch{return t.push("precise \u6A21\u5F0F\u964D\u7EA7\u4E3A heuristic: typescript \u5305\u4E0D\u53EF\u7528\uFF08\u53EF\u80FD\u9700\u8981 npm install\uFF09"),{effective:"heuristic",warnings:t}}return {effective:"precise",warnings:t}}function An(i,e){i.registerTool("skimmer_index_project",{title:"\u7D22\u5F15\u9879\u76EE\u4EE3\u7801\uFF08\u652F\u6301\u4EFB\u610F\u9879\u76EE\uFF09",description:`\u521D\u59CB\u5316\u6216\u589E\u91CF\u66F4\u65B0\u524D\u7AEF\u9879\u76EE\u4EE3\u7801\u7D22\u5F15\u3002\u652F\u6301 Vue2/Vue3/React Hooks\u3002
441
+ `),s}getContext(e){let t=this.resolveProjectRoot(e),n=this.getDatabase(t);return this.lastProject=t,{db:n,projectRoot:t}}getIndexer(e){let t=this.resolveProjectRoot(e),n=K__default.resolve(t),r=Date.now();if(this.evictIdleDatabases(r),this.maybeCleanupDiskCache(r),this.indexerCache.has(n))return this.touchProject(n,r),this.lastProject=n,this.indexerCache.get(n);let s=this.getDatabase(n),o=new ct(n,s);return this.indexerCache.set(n,o),this.touchProject(n,r),this.lastProject=n,o}setLastProject(e){this.lastProject=K__default.resolve(e);}listProjects(){return Array.from(this.dbCache.entries()).map(([e])=>({root:e,dbPath:this.dbPaths.get(e)||this.resolveDbPath(e)}))}registerWatcher(e,t){let n=K__default.resolve(e),r=this.watcherCleanups.get(n);if(r)try{r();}catch{}this.watcherCleanups.set(n,t);}hasWatcher(e){let t=K__default.resolve(e);return this.watcherCleanups.has(t)}closeProject(e){let t=K__default.resolve(e),n=this.watcherCleanups.get(t);if(n){try{n();}catch{}this.watcherCleanups.delete(t);}let r=this.dbCache.get(t);r&&(r.close(),this.dbCache.delete(t),this.accessTimes.delete(t),this.indexerCache.delete(t),this.dbPaths.delete(t),this.lastProject===t&&(this.lastProject=null));}closeAll(){for(let e of this.watcherCleanups.values())try{e();}catch{}this.watcherCleanups.clear();for(let e of this.dbCache.values())e.close();this.dbCache.clear(),this.indexerCache.clear(),this.accessTimes.clear(),this.dbPaths.clear(),this.lastProject=null;}resolveDbPath(e){if(process.env.SKIMMER_DB&&this.dbCache.size===0)return K__default.resolve(process.env.SKIMMER_DB);let t=K__default.join(e,".agent","skimmer_find_symbol"),n=K__default.join(t,qe);try{return Z__default.mkdirSync(t,{recursive:!0}),Z__default.accessSync(e,Z__default.constants.W_OK),n}catch{let r=createHash("md5").update(e).digest("hex").slice(0,8),s=e.replace(/[/\\:]/g,"_").replace(/^_+/,"").slice(-40);return K__default.join(this.globalCacheDir,`${r}_${s}.db`)}}parsePositiveInt(e,t){let n=Number.parseInt(String(e||""),10);return Number.isFinite(n)&&n>0?n:t}touchProject(e,t){this.accessTimes.set(e,t);}evictLruIfNeeded(e){for(;this.dbCache.size>=this.maxOpenProjects;){let t=null,n=Number.POSITIVE_INFINITY;for(let r of this.dbCache.keys()){let s=this.accessTimes.get(r)??e;s<n&&(n=s,t=r);}if(!t)break;this.closeProject(t);}}evictIdleDatabases(e){let t=[];for(let n of this.dbCache.keys()){if(n===this.lastProject)continue;let r=this.accessTimes.get(n)??e;e-r>this.maxIdleMs&&t.push(n);}for(let n of t)this.closeProject(n);}maybeCleanupDiskCache(e){if(e-this.lastDiskCleanupAt<Jr)return;this.lastDiskCleanupAt=e;let t=[];try{t=Z__default.readdirSync(this.globalCacheDir,{withFileTypes:!0});}catch{return}let n=new Set;for(let s of this.dbPaths.values())s.startsWith(this.globalCacheDir)&&n.add(K__default.resolve(s));let r=e-this.dbTtlMs;for(let s of t){if(!s.isFile()||!s.name.endsWith(".db"))continue;let o=K__default.join(this.globalCacheDir,s.name);if(n.has(K__default.resolve(o)))continue;let a;try{a=Z__default.statSync(o);}catch{continue}a.mtimeMs>=r||(this.safeUnlink(o),this.safeUnlink(`${o}-wal`),this.safeUnlink(`${o}-shm`));}}safeUnlink(e){try{Z__default.existsSync(e)&&Z__default.unlinkSync(e);}catch{}}};var pt=createRequire(import.meta.url);function xn(i,e){let t=[];if(i==="heuristic")return {effective:"heuristic",warnings:t};let n=pt("fs"),s=pt("path").join(e,"tsconfig.json");if(!n.existsSync(s))return t.push(`precise \u6A21\u5F0F\u964D\u7EA7\u4E3A heuristic: \u9879\u76EE\u6839\u76EE\u5F55\u672A\u627E\u5230 tsconfig.json (${s})`),{effective:"heuristic",warnings:t};try{pt.resolve("typescript",{paths:[e]});}catch{try{pt.resolve("typescript");}catch{return t.push("precise \u6A21\u5F0F\u964D\u7EA7\u4E3A heuristic: typescript \u5305\u4E0D\u53EF\u7528\uFF08\u53EF\u80FD\u9700\u8981 npm install\uFF09"),{effective:"heuristic",warnings:t}}}return {effective:"precise",warnings:t}}function An(i,e){i.registerTool("skimmer_index_project",{title:"\u7D22\u5F15\u9879\u76EE\u4EE3\u7801\uFF08\u652F\u6301\u4EFB\u610F\u9879\u76EE\uFF09",description:`\u521D\u59CB\u5316\u6216\u589E\u91CF\u66F4\u65B0\u524D\u7AEF\u9879\u76EE\u4EE3\u7801\u7D22\u5F15\u3002\u652F\u6301 Vue2/Vue3/React Hooks\u3002
442
442
  \u6BCF\u6B21\u8C03\u7528\u5FC5\u987B\u4F20\u5165 project_path\uFF08\u9879\u76EE\u6839\u76EE\u5F55\u7EDD\u5BF9\u8DEF\u5F84\uFF09\uFF0C\u65E0\u9700\u5728\u542F\u52A8\u65F6\u56FA\u5B9A\u9879\u76EE\u3002
443
443
  \u4F18\u5148\u4ECE\u7F16\u8F91\u5668\u5DE5\u4F5C\u533A\u3001\u5DF2\u6253\u5F00\u6587\u4EF6\u548C\u5F53\u524D\u4E0A\u4E0B\u6587\u4E2D\u81EA\u52A8\u63A8\u65AD project_path\uFF0C\u907F\u514D\u5411\u7528\u6237\u8FFD\u95EE\u8DEF\u5F84\u3002
444
444
  \u591A\u4E2A\u9879\u76EE\u4F1A\u5E76\u884C\u7F13\u5B58\uFF0C\u5207\u6362\u65E0\u9700\u91CD\u542F\u3002
@@ -476,14 +476,14 @@ ${"\u2500".repeat(50)}`),g.push(`\u{1F4A1} \u67E5\u770B\u5177\u4F53\u4EE3\u7801:
476
476
  \u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
477
477
  ${U(h)}`),{content:[{type:"text",text:g.join(`
478
478
  `)}]}});}var He=class{constructor(e){this.db=e;}db;search(e,t){let{category:n,framework:r,filePath:s,limit:o=tn,fuzzy:a=true,allowFallbackScan:c=false,debug:l=false}=t||{},p=e.trim(),d=new Map,u={},f=performance.now(),m=this.db.exactSearch(p,n,r,s);for(let R of m)d.set(R.id,{symbol:R,filePath:R.file_path,score:100,matchReason:"\u7CBE\u786E\u5339\u914D"});if(u["1_exact"]=Math.round((performance.now()-f)*100)/100,d.size>=o)return {results:this.rankResults(d,o)};let g=performance.now(),y=0,b=k(p),T=[p,b,...b.split(" ")].filter(Boolean).filter((R,_,x)=>x.indexOf(R)===_);for(let R of T){if(R.length<2)continue;let _=this.db.ftsSearch(R,n,r,s,o);y+=_.length;for(let x of _){let A=x.id;if(d.has(A))continue;let w=this.calcFtsScore(p,x.name);d.set(A,{symbol:x,filePath:x.file_path,score:w,matchReason:`FTS5 \u524D\u7F00\u5339\u914D ("${R}")`});}}if(u["2_fts"]=Math.round((performance.now()-g)*100)/100,d.size>=o)return {results:this.rankResults(d,o),debug:l?{phase_timings:u,candidate_count:y}:void 0};let h=a&&p.length>=3,E=0;if(h){let R=performance.now(),_=this.db.getAllSymbolNames(s),x=p.toLowerCase(),A=k(p).split(" ");for(let{name:w,file_path:M,id:O}of _){if(d.has(O))continue;E++;let B=ze(x,w.toLowerCase()),ce=Math.max(x.length,w.length),ye=Math.min(nn,Math.max(1,Math.floor(ce*.28)));if(B<=ye){let le=Math.max(0,80-B*15),X=this.db.getSymbolById(O);if(!X||n&&X.category!==n||r&&X.framework!==r)continue;let re=Gt(p,w,B);d.set(O,{symbol:X,filePath:M,score:le,matchReason:`\u6A21\u7CCA\u5339\u914D (\u7F16\u8F91\u8DDD\u79BB=${B})`,spellingSuggestion:re});continue}let Ae=k(w).split(" "),q=A.filter(le=>Ae.some(X=>zt(le,X)>=75));if(q.length>0&&q.length>=Math.ceil(A.length*.5)){let le=50+q.length*10,X=this.db.getSymbolById(O);if(!X||n&&X.category!==n||r&&X.framework!==r)continue;d.set(O,{symbol:X,filePath:M,score:le,matchReason:`\u5355\u8BCD\u5339\u914D (${q.join(", ")})`});}}u["3_fuzzy"]=Math.round((performance.now()-R)*100)/100;}if(d.size===0&&c){let R=performance.now(),_=this.db.ftsSearchWithFallback(p,n,r,s,o);for(let x of _){let A=x.id;d.has(A)||d.set(A,{symbol:x,filePath:x.file_path,score:50,matchReason:"LIKE \u5168\u8868\u626B\u63CF fallback"});}u["4_fallback"]=Math.round((performance.now()-R)*100)/100;}let N=l?{phase_timings:u,candidate_count:y+E,fallback_reason:!h&&p.length<3?"\u67E5\u8BE2\u8FC7\u77ED (<3\u5B57\u7B26)\uFF0C\u8DF3\u8FC7\u6A21\u7CCA\u5339\u914D":void 0}:void 0;return {results:this.rankResults(d,o),debug:N}}calcFtsScore(e,t){let n=e.toLowerCase(),r=t.toLowerCase();if(r===n)return 98;if(r.startsWith(n))return 91;if(r.includes(n))return 80;let s=k(e).split(" "),o=k(t).split(" "),a=s.some(l=>o[0]?.startsWith(l))?8:0,c=s.filter(l=>o.some(p=>p.startsWith(l))).length;return Math.min(88,58+c*8+a)}rankResults(e,t){return Array.from(e.values()).sort((n,r)=>r.score-n.score).slice(0,t)}searchByBehavior(e){return this.db.behaviorSearch(e.category,e.apiName,e.operation,e.keyword,e.filePath).map(n=>({symbolName:n.symbol_name,category:n.category,apiName:n.api_name,operation:n.operation,detail:n.detail,line:n.line_number,filePath:n.file_path,startLine:n.start_line,endLine:n.end_line}))}};var In=createRequire(import.meta.url),Ee="\u9879\u76EE\u6839\u76EE\u5F55\uFF08\u53EF\u7701\u7565\uFF0C\u81EA\u52A8\u4F7F\u7528\u4E0A\u6B21 skimmer_index_project \u6307\u5B9A\u7684\u9879\u76EE\uFF09";function Be(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $e(i,e,t){let n=[];for(let r of i){if(!r?.abs_path||!Z__default.existsSync(r.abs_path))continue;let s=Z__default.readFileSync(r.abs_path,"utf-8").split(`
479
- `);for(let o=0;o<s.length;o++){let a=s[o];for(let c of e)if(c.regex.test(a)){n.push({filePath:r.path,line:o+1,kind:c.kind,text:a.trim()});break}if(n.length>=t)return n}}return n}function kn(i,e){let t=Be(i),n="(?:=|\\+=|-=|\\*=|/=|%=|\\|=|&=|\\^=|&&=|\\|\\|=|\\?\\?=)",r=[{kind:"declaration",regex:new RegExp(`\\b(?:const|let|var)\\s+${t}\\b`)},{kind:"assignment",regex:new RegExp(`\\b${t}\\b\\s*${n}`)},{kind:"update",regex:new RegExp(`(?:\\+\\+|--)\\s*\\b${t}\\b|\\b${t}\\b\\s*(?:\\+\\+|--)`)}];return e&&r.push({kind:"property_assignment",regex:new RegExp(`\\b${t}\\.[A-Za-z_$][\\w$]*\\s*${n}`)},{kind:"indexed_assignment",regex:new RegExp(`\\b${t}\\s*\\[[^\\]]+\\]\\s*${n}`)}),r}function mt(i){try{return In("@babel/parser").parse(i,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"],errorRecovery:!0})}catch{return null}}function gt(i,e){if(!i.endsWith(".vue"))return [{content:e,lineOffset:1}];try{let{parse:s}=In("@vue/compiler-sfc"),{descriptor:o}=s(e),a=[];if(o.script?.content&&a.push({content:o.script.content,lineOffset:o.script.loc.start.line}),o.scriptSetup?.content&&a.push({content:o.scriptSetup.content,lineOffset:o.scriptSetup.loc.start.line}),a.length>0)return a}catch{}let t=e.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!t||!t[1])return [];let r=e.slice(0,t.index||0).split(`
479
+ `);for(let o=0;o<s.length;o++){let a=s[o];for(let c of e)if(c.regex.test(a)){n.push({filePath:r.path,line:o+1,kind:c.kind,text:a.trim()});break}if(n.length>=t)return n}}return n}function kn(i,e){let t=Be(i),n="(?:=|\\+=|-=|\\*=|/=|%=|\\|=|&=|\\^=|&&=|\\|\\|=|\\?\\?=)",r=[{kind:"declaration",regex:new RegExp(`\\b(?:const|let|var)\\s+${t}\\b`)},{kind:"assignment",regex:new RegExp(`\\b${t}\\b\\s*${n}`)},{kind:"update",regex:new RegExp(`(?:\\+\\+|--)\\s*\\b${t}\\b|\\b${t}\\b\\s*(?:\\+\\+|--)`)}];return e&&r.push({kind:"property_assignment",regex:new RegExp(`\\b${t}\\.[A-Za-z_$][\\w$]*\\s*${n}`)},{kind:"indexed_assignment",regex:new RegExp(`\\b${t}\\s*\\[[^\\]]+\\]\\s*${n}`)}),r}function gt(i){try{return In("@babel/parser").parse(i,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"],errorRecovery:!0})}catch{return null}}function ht(i,e){if(!i.endsWith(".vue"))return [{content:e,lineOffset:1}];try{let{parse:s}=In("@vue/compiler-sfc"),{descriptor:o}=s(e),a=[];if(o.script?.content&&a.push({content:o.script.content,lineOffset:o.script.loc.start.line}),o.scriptSetup?.content&&a.push({content:o.scriptSetup.content,lineOffset:o.scriptSetup.loc.start.line}),a.length>0)return a}catch{}let t=e.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!t||!t[1])return [];let r=e.slice(0,t.index||0).split(`
480
480
  `).length;return [{content:t[1],lineOffset:r}]}function _e(i,e){return (i.loc?.start?.line??1)+e-1}function Ut(i,e){if(i.type!=="MemberExpression")return false;let t=i.object;return !t||t.type!=="ThisExpression"?false:Y(i)===e}function Dt(i,e){return !!i&&i.type==="Identifier"&&String(i.name||"")===e}function $n(i){let e=new Set;return i.filter(t=>{let n=`${t.filePath}:${t.line}:${t.kind}:${t.text}`;return e.has(n)?false:(e.add(n),true)})}function Mt(i,e,t=2){if(!Z__default.existsSync(i))return {snippet:"",startLine:e};let n=Z__default.readFileSync(i,"utf-8").split(`
481
481
  `),r=Math.max(0,e-1-t),s=Math.min(n.length-1,e-1+t);return {snippet:n.slice(r,s+1).map((a,c)=>{let l=r+c+1;return ` ${l===e?"\u25B6":" "} ${String(l).padStart(4)} \u2502 ${a}`}).join(`
482
- `),startLine:r+1}}function dt(i,e=false){let n=Math.max(50,({declaration:95,assignment:85,update:80,property_assignment:75,indexed_assignment:75,dot:75,bracket:75,delete:70,direct_storage:90,alias_ref:70,regex_fallback:60}[i]??65)-(e?5:0)),r=n>=90?"\u25CF\u25CF\u25CF\u25CF\u25CF":n>=80?"\u25CF\u25CF\u25CF\u25CF\u25CB":n>=70?"\u25CF\u25CF\u25CF\u25CB\u25CB":n>=60?"\u25CF\u25CF\u25CB\u25CB\u25CB":"\u25CF\u25CB\u25CB\u25CB\u25CB";return `[\u7F6E\u4FE1\u5EA6 ${n}% ${r}]`}var wn={init:"\u{1F331} \u521D\u59CB\u5316\u6765\u6E90",cache:"\u{1F4BE} \u7F13\u5B58\u56DE\u663E",user:"\u{1F5B1}\uFE0F \u7528\u6237\u4EA4\u4E92",unknown:"\u2753 \u672A\u77E5\u6765\u6E90"};function vn(i,e,t){let n=[];for(let r of i){if(!r.abs_path||!Z__default.existsSync(r.abs_path))continue;let s=Z__default.readFileSync(r.abs_path,"utf-8"),o=s.split(`
483
- `),a=gt(r.path||K__default.basename(r.abs_path),s);for(let c of a){let l=mt(c.content);l&&me(l,p=>{if(n.length>=t||p.type!=="VariableDeclarator")return;let d=p.id;if(!d||d.type!=="Identifier")return;let u=String(d.name||"");if(!u||u===e)return;let f=p.init;if(!f)return;let m=false;if(f.type==="Identifier"&&String(f.name||"")===e?m=true:f.type==="MemberExpression"&&(m=Ut(f,e)||Y(f)===e),!m)return;let g=_e(p,c.lineOffset),y=o[g-1]?.trim()||"";n.push({alias:u,filePath:r.path,abs_path:r.abs_path,line:g,text:y});});}}return n}function Cn(i,e,t){let n=[];for(let r of i){if(!r.abs_path||!Z__default.existsSync(r.abs_path))continue;let s=Z__default.readFileSync(r.abs_path,"utf-8"),o=s.split(`
484
- `),a=gt(r.path||K__default.basename(r.abs_path),s);for(let c of a){let l=mt(c.content);l&&me(l,p=>{if(n.length>=t||p.type!=="VariableDeclarator")return;let d=p.id;if(!d||d.type!=="ObjectPattern")return;let u=d.properties||[];for(let f of u){if(f.type!=="ObjectProperty"&&f.type!=="Property")continue;let m=f.key,g=f.value,y=m?.type==="Identifier"?String(m.name||""):null;if(y!==e)continue;let b=g?.type==="Identifier"?String(g.name||""):y;if(!b)continue;let T=_e(p,c.lineOffset),h=o[T-1]?.trim()||"";n.push({alias:b,filePath:r.path,line:T,text:h});}});}}return n}function jt(i,e,t,n){let r=[];for(let s of i){if(!s.abs_path||!Z__default.existsSync(s.abs_path))continue;let o=Z__default.readFileSync(s.abs_path,"utf-8"),a=o.split(`
485
- `),c=gt(s.path||K__default.basename(s.abs_path),o);for(let l of c){let p=mt(l.content);if(p&&(me(p,d=>{if(!(r.length>=n)){if(d.type==="VariableDeclarator"){let u=d.id;if(Dt(u,e)){let f=_e(d,l.lineOffset);r.push({filePath:s.path,line:f,kind:"declaration",text:a[f-1]?.trim()||""});}}if(d.type==="AssignmentExpression"){let u=d.left;if(!u)return;let f=_e(d,l.lineOffset);if(Dt(u,e)||Ut(u,e)){r.push({filePath:s.path,line:f,kind:"assignment",text:a[f-1]?.trim()||""});return}t&&u.type==="MemberExpression"&&ie(u)===e&&r.push({filePath:s.path,line:f,kind:u.computed?"indexed_assignment":"property_assignment",text:a[f-1]?.trim()||""});}if(d.type==="UpdateExpression"){let u=d.argument;if(!u)return;if(Dt(u,e)||Ut(u,e)){let f=_e(d,l.lineOffset);r.push({filePath:s.path,line:f,kind:"update",text:a[f-1]?.trim()||""});}}}}),r.length>=n))break}if(r.length>=n)break}return $n(r).slice(0,n)}function ut(i,e,t,n){let r=[];for(let s of i){if(!s.abs_path||!Z__default.existsSync(s.abs_path))continue;let o=Z__default.readFileSync(s.abs_path,"utf-8"),a=o.split(`
486
- `),c=gt(s.path||K__default.basename(s.abs_path),o);for(let l of c){let p=mt(l.content);if(p&&(me(p,d=>{if(!(r.length>=n)){if(d.type==="AssignmentExpression"){let u=d.left;if(!u||u.type!=="MemberExpression"||ie(u)!==e)return;let m=Y(u);if(t&&m!==t)return;let g=_e(d,l.lineOffset);r.push({filePath:s.path,line:g,kind:u.computed?"bracket":"dot",text:a[g-1]?.trim()||""});}if(d.type==="UpdateExpression"){let u=d.argument;if(!u||u.type!=="MemberExpression"||ie(u)!==e)return;let m=Y(u);if(t&&m!==t)return;let g=_e(d,l.lineOffset);r.push({filePath:s.path,line:g,kind:u.computed?"bracket":"dot",text:a[g-1]?.trim()||""});}if(d.type==="UnaryExpression"&&d.operator==="delete"){let u=d.argument;if(!u||u.type!=="MemberExpression"||ie(u)!==e)return;let m=Y(u);if(t&&m!==t)return;let g=_e(d,l.lineOffset);r.push({filePath:s.path,line:g,kind:"delete",text:a[g-1]?.trim()||""});}}}),r.length>=n))break}if(r.length>=n)break}return $n(r).slice(0,n)}function On(i,e){i.registerTool("skimmer_find_symbol",{title:"\u667A\u80FD\u7B26\u53F7\u641C\u7D22\uFF08\u652F\u6301\u62FC\u5199\u9519\u8BEF\uFF09",description:`\u4E09\u5C42\u641C\u7D22\uFF1A\u7CBE\u786E\u5339\u914D \u2192 FTS5\u5168\u6587 \u2192 Levenshtein\u6A21\u7CCA\u3002
482
+ `),startLine:r+1}}function ut(i,e=false){let n=Math.max(50,({declaration:95,assignment:85,update:80,property_assignment:75,indexed_assignment:75,dot:75,bracket:75,delete:70,direct_storage:90,alias_ref:70,regex_fallback:60}[i]??65)-(e?5:0)),r=n>=90?"\u25CF\u25CF\u25CF\u25CF\u25CF":n>=80?"\u25CF\u25CF\u25CF\u25CF\u25CB":n>=70?"\u25CF\u25CF\u25CF\u25CB\u25CB":n>=60?"\u25CF\u25CF\u25CB\u25CB\u25CB":"\u25CF\u25CB\u25CB\u25CB\u25CB";return `[\u7F6E\u4FE1\u5EA6 ${n}% ${r}]`}var wn={init:"\u{1F331} \u521D\u59CB\u5316\u6765\u6E90",cache:"\u{1F4BE} \u7F13\u5B58\u56DE\u663E",user:"\u{1F5B1}\uFE0F \u7528\u6237\u4EA4\u4E92",unknown:"\u2753 \u672A\u77E5\u6765\u6E90"};function vn(i,e,t){let n=[];for(let r of i){if(!r.abs_path||!Z__default.existsSync(r.abs_path))continue;let s=Z__default.readFileSync(r.abs_path,"utf-8"),o=s.split(`
483
+ `),a=ht(r.path||K__default.basename(r.abs_path),s);for(let c of a){let l=gt(c.content);l&&me(l,p=>{if(n.length>=t||p.type!=="VariableDeclarator")return;let d=p.id;if(!d||d.type!=="Identifier")return;let u=String(d.name||"");if(!u||u===e)return;let f=p.init;if(!f)return;let m=false;if(f.type==="Identifier"&&String(f.name||"")===e?m=true:f.type==="MemberExpression"&&(m=Ut(f,e)||Y(f)===e),!m)return;let g=_e(p,c.lineOffset),y=o[g-1]?.trim()||"";n.push({alias:u,filePath:r.path,abs_path:r.abs_path,line:g,text:y});});}}return n}function Cn(i,e,t){let n=[];for(let r of i){if(!r.abs_path||!Z__default.existsSync(r.abs_path))continue;let s=Z__default.readFileSync(r.abs_path,"utf-8"),o=s.split(`
484
+ `),a=ht(r.path||K__default.basename(r.abs_path),s);for(let c of a){let l=gt(c.content);l&&me(l,p=>{if(n.length>=t||p.type!=="VariableDeclarator")return;let d=p.id;if(!d||d.type!=="ObjectPattern")return;let u=d.properties||[];for(let f of u){if(f.type!=="ObjectProperty"&&f.type!=="Property")continue;let m=f.key,g=f.value,y=m?.type==="Identifier"?String(m.name||""):null;if(y!==e)continue;let b=g?.type==="Identifier"?String(g.name||""):y;if(!b)continue;let T=_e(p,c.lineOffset),h=o[T-1]?.trim()||"";n.push({alias:b,filePath:r.path,line:T,text:h});}});}}return n}function jt(i,e,t,n){let r=[];for(let s of i){if(!s.abs_path||!Z__default.existsSync(s.abs_path))continue;let o=Z__default.readFileSync(s.abs_path,"utf-8"),a=o.split(`
485
+ `),c=ht(s.path||K__default.basename(s.abs_path),o);for(let l of c){let p=gt(l.content);if(p&&(me(p,d=>{if(!(r.length>=n)){if(d.type==="VariableDeclarator"){let u=d.id;if(Dt(u,e)){let f=_e(d,l.lineOffset);r.push({filePath:s.path,line:f,kind:"declaration",text:a[f-1]?.trim()||""});}}if(d.type==="AssignmentExpression"){let u=d.left;if(!u)return;let f=_e(d,l.lineOffset);if(Dt(u,e)||Ut(u,e)){r.push({filePath:s.path,line:f,kind:"assignment",text:a[f-1]?.trim()||""});return}t&&u.type==="MemberExpression"&&ie(u)===e&&r.push({filePath:s.path,line:f,kind:u.computed?"indexed_assignment":"property_assignment",text:a[f-1]?.trim()||""});}if(d.type==="UpdateExpression"){let u=d.argument;if(!u)return;if(Dt(u,e)||Ut(u,e)){let f=_e(d,l.lineOffset);r.push({filePath:s.path,line:f,kind:"update",text:a[f-1]?.trim()||""});}}}}),r.length>=n))break}if(r.length>=n)break}return $n(r).slice(0,n)}function ft(i,e,t,n){let r=[];for(let s of i){if(!s.abs_path||!Z__default.existsSync(s.abs_path))continue;let o=Z__default.readFileSync(s.abs_path,"utf-8"),a=o.split(`
486
+ `),c=ht(s.path||K__default.basename(s.abs_path),o);for(let l of c){let p=gt(l.content);if(p&&(me(p,d=>{if(!(r.length>=n)){if(d.type==="AssignmentExpression"){let u=d.left;if(!u||u.type!=="MemberExpression"||ie(u)!==e)return;let m=Y(u);if(t&&m!==t)return;let g=_e(d,l.lineOffset);r.push({filePath:s.path,line:g,kind:u.computed?"bracket":"dot",text:a[g-1]?.trim()||""});}if(d.type==="UpdateExpression"){let u=d.argument;if(!u||u.type!=="MemberExpression"||ie(u)!==e)return;let m=Y(u);if(t&&m!==t)return;let g=_e(d,l.lineOffset);r.push({filePath:s.path,line:g,kind:u.computed?"bracket":"dot",text:a[g-1]?.trim()||""});}if(d.type==="UnaryExpression"&&d.operator==="delete"){let u=d.argument;if(!u||u.type!=="MemberExpression"||ie(u)!==e)return;let m=Y(u);if(t&&m!==t)return;let g=_e(d,l.lineOffset);r.push({filePath:s.path,line:g,kind:"delete",text:a[g-1]?.trim()||""});}}}),r.length>=n))break}if(r.length>=n)break}return $n(r).slice(0,n)}function On(i,e){i.registerTool("skimmer_find_symbol",{title:"\u667A\u80FD\u7B26\u53F7\u641C\u7D22\uFF08\u652F\u6301\u62FC\u5199\u9519\u8BEF\uFF09",description:`\u4E09\u5C42\u641C\u7D22\uFF1A\u7CBE\u786E\u5339\u914D \u2192 FTS5\u5168\u6587 \u2192 Levenshtein\u6A21\u7CCA\u3002
487
487
  \u89E3\u51B3\u62FC\u5199\u9519\u8BEF\uFF1A\u641C "changeCash" \u80FD\u627E\u5230 "changeCashValue"\uFF0C\u5E76\u63D0\u793A "cash \u53EF\u80FD\u662F cache \u7684\u62FC\u5199\u9519\u8BEF"\u3002
488
488
  \u9A7C\u5CF0\u62C6\u8BCD\uFF1A\u641C "change cache" \u4E5F\u80FD\u627E\u5230 "changeCacheValue"\u3002
489
489
  \u6846\u67B6\u611F\u77E5\uFF1A\u53EF\u6309 vue2/vue3/react \u8FC7\u6EE4\u3002
@@ -530,7 +530,7 @@ ${U(E)}`),{content:[{type:"text",text:h.join(`
530
530
  `)}]}}),i.registerTool("skimmer_trace_property_changes",{title:"\u8FFD\u8E2A\u5BF9\u8C61\u5C5E\u6027\u4FEE\u6539",description:`\u3010\u964D\u7EA7\u5DE5\u5177\u3011\u4EC5\u5728\u4EE5\u4E0B\u573A\u666F\u5355\u72EC\u4F7F\u7528\uFF1A\u9700\u8981\u7CBE\u786E\u8FC7\u6EE4\u67D0\u4E00\u4E2A\u5177\u4F53\u5C5E\u6027\u5B57\u6BB5\uFF08\u5982 storageParams.receiveAdr\uFF09\uFF0C\u800C\u4E0D\u9700\u8981\u6574\u4F53\u8D4B\u503C/\u53C2\u6570\u4F20\u9012/storage\u94FE\u8DEF\u4FE1\u606F\u3002
531
531
  \u26A0\uFE0F \u7EDD\u5927\u591A\u6570\u5BF9\u8C61\u6EAF\u6E90\u573A\u666F\u8BF7\u4F18\u5148\u4F7F\u7528 skimmer_trace_data_lifecycle\uFF0C\u5B83\u80FD\u4E00\u6B21\u62FF\u5230\u6240\u6709\u4FE1\u606F\u3002
532
532
  \u2705 \u672C\u5DE5\u5177\u9002\u5408\uFF1Aobject.specificProp \u7684\u5355\u5B57\u6BB5\u7EA7\u522B\u7CBE\u786E\u8FFD\u8E2A\u3002
533
- \u274C \u4E0D\u9002\u5408\uFF1A\u9700\u8981\u4E86\u89E3\u5BF9\u8C61\u6574\u4F53\u6765\u6E90\u6216\u6570\u636E\u6D41\u5411\u7684\u573A\u666F\u3002`,inputSchema:z$1.object({object:z$1.string().describe('\u5BF9\u8C61\u540D\uFF0C\u5982 "storageParams" / "params"'),property:z$1.string().optional().describe('\u5C5E\u6027\u540D\uFF0C\u5982 "receiveAdr"'),project_path:z$1.string().optional().describe(Ee),file_path:z$1.string().optional().describe("\u9650\u5B9A\u6587\u4EF6\u8DEF\u5F84\uFF08\u5305\u542B\u5373\u53EF\uFF09"),limit:z$1.number().optional().default(80)}),annotations:{readOnlyHint:true,destructiveHint:false}},async({object:t,property:n,project_path:r,file_path:s,limit:o})=>{let a=performance.now(),{db:c}=e.getContext(r),l=c.listFiles(s),p=Math.min(300,Math.max(1,o||80)),d=vn(l,t,20),u=Cn(l,t,20),f=[...new Set([...d.map(h=>h.alias),...u.map(h=>h.alias)].filter(h=>h!==t))],m=[t,...f],g=ut(l,t,n,p);for(let h of f)g.push(...ut(l,h,n,Math.floor(p/2)));if(g.length===0){let h="(?:=|\\+=|-=|\\*=|/=|%=|\\|=|&=|\\^=|&&=|\\|\\|=|\\?\\?=)",E=[];for(let N of m){let R=Be(N);if(n){let _=Be(n);E.push({kind:"dot",regex:new RegExp(`\\b${R}\\.${_}\\s*${h}`)},{kind:"bracket",regex:new RegExp(`\\b${R}\\s*\\[(?:'${_}'|"${_}")\\]\\s*${h}`)},{kind:"delete",regex:new RegExp(`\\bdelete\\s+${R}\\.(?:${_})\\b`)});}else E.push({kind:"dot",regex:new RegExp(`\\b${R}\\.[A-Za-z_$][\\w$]*\\s*${h}`)},{kind:"bracket",regex:new RegExp(`\\b${R}\\s*\\[(?:'[^']+'|"[^"]+")\\]\\s*${h}`)},{kind:"delete",regex:new RegExp(`\\bdelete\\s+${R}\\.[A-Za-z_$][\\w$]*\\b`)});}g=$e(l,E,p);}let y=Math.round((performance.now()-a)*100)/100;if(g.length===0){let h=f.length>0?`
533
+ \u274C \u4E0D\u9002\u5408\uFF1A\u9700\u8981\u4E86\u89E3\u5BF9\u8C61\u6574\u4F53\u6765\u6E90\u6216\u6570\u636E\u6D41\u5411\u7684\u573A\u666F\u3002`,inputSchema:z$1.object({object:z$1.string().describe('\u5BF9\u8C61\u540D\uFF0C\u5982 "storageParams" / "params"'),property:z$1.string().optional().describe('\u5C5E\u6027\u540D\uFF0C\u5982 "receiveAdr"'),project_path:z$1.string().optional().describe(Ee),file_path:z$1.string().optional().describe("\u9650\u5B9A\u6587\u4EF6\u8DEF\u5F84\uFF08\u5305\u542B\u5373\u53EF\uFF09"),limit:z$1.number().optional().default(80)}),annotations:{readOnlyHint:true,destructiveHint:false}},async({object:t,property:n,project_path:r,file_path:s,limit:o})=>{let a=performance.now(),{db:c}=e.getContext(r),l=c.listFiles(s),p=Math.min(300,Math.max(1,o||80)),d=vn(l,t,20),u=Cn(l,t,20),f=[...new Set([...d.map(h=>h.alias),...u.map(h=>h.alias)].filter(h=>h!==t))],m=[t,...f],g=ft(l,t,n,p);for(let h of f)g.push(...ft(l,h,n,Math.floor(p/2)));if(g.length===0){let h="(?:=|\\+=|-=|\\*=|/=|%=|\\|=|&=|\\^=|&&=|\\|\\|=|\\?\\?=)",E=[];for(let N of m){let R=Be(N);if(n){let _=Be(n);E.push({kind:"dot",regex:new RegExp(`\\b${R}\\.${_}\\s*${h}`)},{kind:"bracket",regex:new RegExp(`\\b${R}\\s*\\[(?:'${_}'|"${_}")\\]\\s*${h}`)},{kind:"delete",regex:new RegExp(`\\bdelete\\s+${R}\\.(?:${_})\\b`)});}else E.push({kind:"dot",regex:new RegExp(`\\b${R}\\.[A-Za-z_$][\\w$]*\\s*${h}`)},{kind:"bracket",regex:new RegExp(`\\b${R}\\s*\\[(?:'[^']+'|"[^"]+")\\]\\s*${h}`)},{kind:"delete",regex:new RegExp(`\\bdelete\\s+${R}\\.[A-Za-z_$][\\w$]*\\b`)});}g=$e(l,E,p);}let y=Math.round((performance.now()-a)*100)/100;if(g.length===0){let h=f.length>0?`
534
534
  \u522B\u540D\u5C55\u5F00: ${f.join(", ")}\uFF08\u5747\u672A\u547D\u4E2D\uFF09`:"",E=W({durationMs:y,resultCount:0,backend:"ast_scan"});return {content:[{type:"text",text:`\u{1F9ED} \u5C5E\u6027\u4FEE\u6539\u8FFD\u8E2A: ${t}${n?`.${n}`:".*"}
535
535
  \u672A\u627E\u5230\u5339\u914D\u8BED\u53E5${h}
536
536
  \u8FC7\u6EE4: file_path=${s||"*"}
@@ -584,8 +584,8 @@ project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({variable:z$1.stri
584
584
  `+m.staleFilePaths.slice(0,3).map(S=>` \u2022 ${S}`).join(`
585
585
  `)+`
586
586
  \u5EFA\u8BAE: skimmer_index_project({ force: true })
587
- `);let g=Cn(u,t,20),y=[...new Set(g.map(S=>S.alias).filter(S=>S!==t))],b=vn(u,t,20),T=[...new Set(b.map(S=>S.alias).filter(S=>S!==t))],h=[...new Set([...y,...T])],N=[t,...h],R=l.exactSearch(t,"state",void 0,r||void 0),_={vue2:"Vue2 data()",vue3:"Vue3 ref/reactive",react:"React useState/useRef"},x=R.filter(S=>S.default_value!=null).map(S=>({filePath:S.file_path,line:S.start_line,kind:`data_init(${_[S.framework]||S.framework})`,text:`${S.name}: ${S.default_value} \u2190 \u58F0\u660E\u521D\u59CB\u5316`})),A=false,w=l.getAssignments(t,r,d),M=[];w.length>0?(M=w.map(S=>({filePath:S.file_path,line:S.line_number,kind:S.kind,text:S.text_snippet||"",sourceLayer:S.source_layer||void 0})),A=true):M=jt(u,t,false,d);for(let S of h){let I=l.getAssignments(S,r,Math.floor(d/2));I.length>0?M.push(...I.map(L=>({filePath:L.file_path,line:L.line_number,kind:L.kind,text:L.text_snippet||"",sourceLayer:L.source_layer||void 0}))):M.push(...jt(u,S,false,Math.floor(d/2)));}let O=M.length===0?$e(u,kn(t,false),d):[],B=new Map;for(let S of [...x,...M.length>0?M:O]){let I=`${S.filePath}:${S.line}`;B.has(I)||B.set(I,S);}let ce=[...B.values()],ye=false,Ae=l.getPropertyWrites(t,void 0,r,d),q=[];Ae.length>0?(q=Ae.map(S=>({filePath:S.file_path,line:S.line_number,kind:S.kind,text:S.text_snippet||"",sourceLayer:S.source_layer||void 0})),ye=true):q=ut(u,t,void 0,d);for(let S of h){let I=l.getPropertyWrites(S,void 0,r,Math.floor(d/2));I.length>0?q.push(...I.map(L=>({filePath:L.file_path,line:L.line_number,kind:L.kind,text:L.text_snippet||"",sourceLayer:L.source_layer||void 0}))):q.push(...ut(u,S,void 0,Math.floor(d/2)));}let le=q.length===0?$e(u,[{kind:"dot",regex:new RegExp(`\\b${t}\\.[A-Za-z_$][\\w$]*\\s*(?:=|\\+=|-=|\\*=|\\/=|%=|\\|=|&=|\\^=|&&=|\\|\\|=|\\?\\?=`)},{kind:"bracket",regex:new RegExp(`\\b${t}\\s*\\[(?:'[^']+'|"[^"]+")\\]\\s*(?:=|\\+=)`)},{kind:"delete",regex:new RegExp(`\\bdelete\\s+${t}\\.[A-Za-z_$][\\w$]*\\b`)}],d):[],X=q.length>0?q:le,re=l.findRelationsByArgKeyword(t,r,d);for(let S of h)re.push(...l.findRelationsByArgKeyword(S,r,Math.floor(d/2)));let Ht=[],Bt=[],Xt=[];for(let S of N){let I=Be(S),L=/^[a-zA-Z_$][\w$]*$/.test(S)?"\\b":"";Ht.push({kind:"template",regex:new RegExp(`(?::\\w+|v-model|v-if|v-show|@\\w+)="[^"]*${L}${I}${L}|\\{\\{[^}]*${L}${I}${L}[^}]*\\}\\}`)},{kind:"return",regex:new RegExp(`\\breturn\\b[^=]*${L}${I}${L}`)},{kind:"watch",regex:new RegExp(`watch[^(]*['"]\\.?${I}['"]`)},{kind:"computed_read",regex:new RegExp(`=>[^=]*${L}${I}${L}|return[^=]*${L}${I}${L}`)},{kind:"arg_usage",regex:new RegExp(`\\(\\s*[^)]*${L}${I}${L}[^)]*\\)`)}),Bt.push(`${L}${I}${L}\\s*(?:=|\\+=|-=|\\*=|\\/=)(?!=)|\\b(?:const|let|var)\\s+${I}\\b`),Xt.push(`${L}${I}${L}\\.\\w+\\s*(?:=|\\+=|-=)(?!=)|${L}${I}${L}\\s*\\[`);}let Mn=$e(u,Ht,d),jn=new RegExp(Bt.join("|")),Un=new RegExp(Xt.join("|")),Pe=Mn.filter(S=>!jn.test(S.text)&&!Un.test(S.text)),ht=new Map,Wn=(S,I)=>{if(!ht.has(S)){let{behaviors:P}=l.getFileOutline(S),$=new Map;for(let j of P){let Q=String(j.symbol_name||"");$.has(Q)||$.set(Q,[]),$.get(Q).push(j);}ht.set(S,$);}return (ht.get(S)?.get(I)||[]).filter(P=>String(P.category||"")!=="storage"?false:s==="all"?true:String(P.api_name||"").toLowerCase()===s.toLowerCase())},Hn=(S,I)=>{let L=[],P=[{name:S,filePath:I,path:[S],level:0}],$=new Set([`${I}::${S}`]);for(;P.length>0;){let j=P.shift(),Q=Wn(j.filePath,j.name);if(Q.length>0){L.push({path:j.path,file:j.filePath,behaviors:Q});continue}if(j.level>=p)continue;let J=l.getSymbolByName(j.name,j.filePath);if(J||(J=l.getSymbolByName(j.name)),!J)continue;let Ne=String(J.file_path||J.abs_path||j.filePath),Ke=l.getCallees(J.id);for(let yt of Ke){let pe=String(yt.callee_name||"");if(!pe||pe.startsWith("$"))continue;let Vt=`${Ne}::${pe}`;$.has(Vt)||($.add(Vt),P.push({name:pe,filePath:Ne,path:[...j.path,pe],level:j.level+1}));}}return L},Bn=h.length>0?`
588
- \u{1F517} \u53D1\u73B0\u522B\u540D: ${h.map(S=>`"${S}"`).join(", ")}\uFF08\u5DF2\u4E00\u5E76\u8FFD\u8E2A\u5C5E\u6027\u4FEE\u6539\uFF09`:"",Le=[];b.length>0&&(Le.push(` \u{1F517} \u5F15\u7528\u522B\u540D\u4F20\u64AD (${b.length} \u5904) \u2014 \u8FD9\u4E9B\u5C40\u90E8\u53D8\u91CF\u662F "${t}" \u7684\u5F15\u7528\uFF0C\u5176\u5C5E\u6027\u4FEE\u6539\u4E5F\u88AB\u8FFD\u8E2A:`),b.slice(0,10).forEach(S=>{let L=u.find(j=>j.path===S.filePath)?.abs_path||S.abs_path,P=dt("alias_ref"),$=L?Mt(L,S.line,2):{snippet:""};Le.push(` \u{1F4C4} ${S.filePath}:L${S.line} "${S.alias}" = ... ${P}`),Le.push(` ${S.text}`),$.snippet&&Le.push($.snippet);}));let C=[`\u{1F52C} \u53D8\u91CF\u751F\u547D\u5468\u671F\u8FFD\u8E2A: "${t}"`,"\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",`\u8FC7\u6EE4: file_path=${r||"*"} storage_api=${s} depth=${p}${Bn}`,""];if(f&&C.push(f),C.push(`\u2460 \u58F0\u660E & \u6574\u4F53\u8D4B\u503C (${ce.length} \u5904)`),ce.length===0)C.push(" \uFF08\u672A\u627E\u5230\uFF09");else {let S={init:[],cache:[],user:[],unknown:[]};for(let L of ce){let P=L.sourceLayer||ee(L.text,L.line);S[P].push(L);}let I=["init","cache","user","unknown"];for(let L of I){let P=S[L];!P||P.length===0||(C.push(` \u25B8 ${wn[L]} (${P.length} \u5904)`),P.slice(0,8).forEach($=>{let j=h.includes($.text.split("=")[0]?.trim().replace(/^(?:const|let|var)\s+/,"")||""),Q=dt($.kind,j);C.push(` \u{1F4C4} ${$.filePath}:L${$.line} [${$.kind}] ${Q}`),C.push(` ${$.text}`);}));}Le.length>0&&(C.push(""),C.push(...Le));}if(C.push(""),C.push(`\u2461 \u5C5E\u6027\u4FEE\u6539 (${X.length} \u5904)`),X.length===0)C.push(' \uFF08\u672A\u627E\u5230 object.prop \u6216 object["prop"] \u5199\u5165\uFF09'),h.length>0&&C.push(` \u2139\uFE0F \u5DF2\u8FFD\u8E2A\u522B\u540D: ${h.map(S=>`"${S}"`).join(", ")} \u7684\u5C5E\u6027\u4FEE\u6539\uFF08\u5982\u4ECD\u672A\u627E\u5230\uFF0C\u8868\u793A\u771F\u6B63\u65E0\u95F4\u63A5\u5199\u5165\uFF09`);else {let S={init:[],cache:[],user:[],unknown:[]};for(let L of X){let P=L.sourceLayer||ee(L.text,L.line);S[P].push(L);}let I=["init","cache","user","unknown"];for(let L of I){let P=S[L];!P||P.length===0||(C.push(` \u25B8 ${wn[L]} (${P.length} \u5904)`),P.slice(0,8).forEach($=>{let j=h.some(pe=>$.text.startsWith(pe)),Q=dt($.kind,j),Ne=u.find(pe=>pe.path===$.filePath)?.abs_path||"",Ke=Ne?Mt(Ne,$.line,2):{snippet:""},yt=j?" \u{1F517}(via alias)":"";C.push(` \u{1F4C4} ${$.filePath}:L${$.line} [${$.kind}] ${Q}${yt}`),Ke.snippet&&C.push(Ke.snippet);}));}}if(C.push(""),C.push(`\u2462 \u4F5C\u4E3A\u53C2\u6570\u88AB\u4F20\u5165\u8C03\u7528 (${re.length} \u5904)`),re.length===0?C.push(" \uFF08\u672A\u53D1\u73B0\u4EE5\u8BE5\u53D8\u91CF\u4F5C\u4E3A\u53C2\u6570\u7684\u51FD\u6570\u8C03\u7528\uFF09"):re.slice(0,20).forEach(S=>{let I=String(S.args||"");C.push(` \u{1F4C4} ${S.file_path}:L${S.line_number} ${S.caller_name} \u2192 ${S.callee_name} \u53C2\u6570: "${I}"`);}),C.push(""),C.push(`\u2463 \u8BFB\u53D6/\u4F7F\u7528 (${Pe.length} \u5904)`),Pe.length===0)C.push(" \uFF08\u672A\u53D1\u73B0 template \u7ED1\u5B9A / watch / computed / return \u4E2D\u7684\u5F15\u7528\uFF09");else {let S=new Map;for(let L of Pe)S.has(L.kind)||S.set(L.kind,[]),S.get(L.kind).push(L);let I={template:"\u{1F5BC}\uFE0F template \u7ED1\u5B9A",return:"\u21A9\uFE0F return \u8FD4\u56DE",watch:"\u{1F441}\uFE0F watch \u76D1\u542C",computed_read:"\u{1F9EE} computed \u5F15\u7528",arg_usage:"\u{1F4E8} \u51FD\u6570\u53C2\u6570\u4F7F\u7528"};for(let[L,P]of S)C.push(` \u25B8 ${I[L]||L}`),P.slice(0,8).forEach($=>C.push(` \u{1F4C4} ${$.filePath}:L${$.line} ${$.text}`));}C.push("");let Re=0;C.push(`\u2464 Storage \u843D\u70B9\u8FFD\u8E2A (storage_api=${s}, depth=${p})`);let Xn=s==="localStorage"?"localStorage":s==="sessionStorage"?"sessionStorage":"(?:localStorage|sessionStorage)",Kn=N.map(S=>({kind:"direct_storage",regex:new RegExp(`${Xn}\\.(?:setItem|getItem|removeItem|clear)\\(.*?\\b${Be(S)}\\b`)})),Xe=$e(u,Kn,d);if(Xe.length>0&&(Re+=1,C.push(` \u843D\u70B9 [\u76F4\u63A5\u547D\u4E2D\u5B58\u50A8] ${dt("direct_storage")}:`),Xe.slice(0,15).forEach(S=>{let L=u.find($=>$.path===S.filePath)?.abs_path||"",P=L?Mt(L,S.line,2):{snippet:""};C.push(` \u{1F4C4} ${S.filePath}:L${S.line} ${S.text.trim()}`),P.snippet&&C.push(P.snippet);})),re.length===0&&Xe.length===0)C.push(" \uFF08\u672A\u53D1\u73B0\u76F4\u63A5 Storage \u64CD\u4F5C\uFF0C\u4E14\u65E0\u8C03\u7528\u5165\u53E3\u5C55\u5F00\u8FFD\u8E2A\uFF09");else {let S=new Map;for(let I of re){let L=`${I.file_path}::${I.callee_name}`;S.has(L)||S.set(L,I);}for(let[,I]of S){let L=String(I.callee_name||""),P=String(I.file_path||""),$=Hn(L,P);$.length!==0&&(Re+=1,$.slice(0,3).forEach(j=>{let Q=j.file!==P?` \u2197 \u8DE8\u6587\u4EF6: ${j.file}`:"";C.push(` \u94FE\u8DEF: ${j.path.join(" \u2192 ")}${Q}`),j.behaviors.forEach(J=>{let Ne=J.detail?`("${String(J.detail)}")`:"";C.push(` \u843D\u70B9: ${J.api_name}.${J.operation}${Ne} [${J.category}] L${J.line_number}`);});}));}Re===0&&Xe.length===0&&C.push(` \uFF08\u5728 depth=${p} \u5C42\u5185\u672A\u627E\u5230 storage \u5199\u5165\u94FE\u8DEF\uFF09`);}C.push(""),C.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501");let Vn=h.length>0?` (\u542B ${h.length} \u4E2A\u522B\u540D: ${h.slice(0,3).map(S=>`"${S}"`).join(", ")})`:"";C.push(`\u2705 \u6C47\u603B${Vn}:`),C.push(` \u2460 \u58F0\u660E/\u8D4B\u503C: ${ce.length} \u5904`),C.push(` \u2461 \u5C5E\u6027\u4FEE\u6539: ${X.length} \u5904 (\u5DF2\u8FFD\u8E2A\u522B\u540D: ${h.map(S=>`"${S}"`).join(", ")||"\u65E0"})`),C.push(` \u2462 \u53C2\u6570\u4F20\u9012: ${re.length} \u5904`),C.push(` \u2463 \u8BFB\u53D6\u5F15\u7528: ${Pe.length} \u5904`),C.push(` \u2464 storage: ${Re>0?`\u2713 \u53D1\u73B0\u5199\u5165\u94FE\u8DEF (${Re} \u6761)`:"\u2717 \u672A\u53D1\u73B0"}`),C.push(""),C.push("\u{1F4A1} \u6765\u6E90\u5206\u5C42\u8BF4\u660E: \u{1F331}\u521D\u59CB\u5316 = lifecycle/data | \u{1F4BE}\u7F13\u5B58\u56DE\u663E = storage\u8BFB/fetch | \u{1F5B1}\uFE0F\u7528\u6237\u4EA4\u4E92 = \u4E8B\u4EF6/watch"),C.push("\u{1F4CA} \u7F6E\u4FE1\u5EA6: \u25CF\u25CF\u25CF\u25CF\u25CF \u226590% \u25CF\u25CF\u25CF\u25CF\u25CB \u226580% \u25CF\u25CF\u25CF\u25CB\u25CB \u226570% \u25CF\u25CF\u25CB\u25CB\u25CB \u226560% \u9700\u4EBA\u5DE5\u9A8C\u8BC1\u884C\u53F7\u786E\u8BA4");let zn=Math.round((performance.now()-c)*100)/100,Gn=ce.length+X.length+re.length+Pe.length+Re,Kt=W({durationMs:zn,resultCount:Gn,backend:A&&ye?"indexed":A||ye?"hybrid":"fallback_scan"});return m.stale&&(Kt.index_freshness=m),C.push(`
587
+ `);let g=Cn(u,t,20),y=[...new Set(g.map(S=>S.alias).filter(S=>S!==t))],b=vn(u,t,20),T=[...new Set(b.map(S=>S.alias).filter(S=>S!==t))],h=[...new Set([...y,...T])],N=[t,...h],R=l.exactSearch(t,"state",void 0,r||void 0),_={vue2:"Vue2 data()",vue3:"Vue3 ref/reactive",react:"React useState/useRef"},x=R.filter(S=>S.default_value!=null).map(S=>({filePath:S.file_path,line:S.start_line,kind:`data_init(${_[S.framework]||S.framework})`,text:`${S.name}: ${S.default_value} \u2190 \u58F0\u660E\u521D\u59CB\u5316`})),A=false,w=l.getAssignments(t,r,d),M=[];w.length>0?(M=w.map(S=>({filePath:S.file_path,line:S.line_number,kind:S.kind,text:S.text_snippet||"",sourceLayer:S.source_layer||void 0})),A=true):M=jt(u,t,false,d);for(let S of h){let I=l.getAssignments(S,r,Math.floor(d/2));I.length>0?M.push(...I.map(L=>({filePath:L.file_path,line:L.line_number,kind:L.kind,text:L.text_snippet||"",sourceLayer:L.source_layer||void 0}))):M.push(...jt(u,S,false,Math.floor(d/2)));}let O=M.length===0?$e(u,kn(t,false),d):[],B=new Map;for(let S of [...x,...M.length>0?M:O]){let I=`${S.filePath}:${S.line}`;B.has(I)||B.set(I,S);}let ce=[...B.values()],ye=false,Ae=l.getPropertyWrites(t,void 0,r,d),q=[];Ae.length>0?(q=Ae.map(S=>({filePath:S.file_path,line:S.line_number,kind:S.kind,text:S.text_snippet||"",sourceLayer:S.source_layer||void 0})),ye=true):q=ft(u,t,void 0,d);for(let S of h){let I=l.getPropertyWrites(S,void 0,r,Math.floor(d/2));I.length>0?q.push(...I.map(L=>({filePath:L.file_path,line:L.line_number,kind:L.kind,text:L.text_snippet||"",sourceLayer:L.source_layer||void 0}))):q.push(...ft(u,S,void 0,Math.floor(d/2)));}let le=q.length===0?$e(u,[{kind:"dot",regex:new RegExp(`\\b${t}\\.[A-Za-z_$][\\w$]*\\s*(?:=|\\+=|-=|\\*=|\\/=|%=|\\|=|&=|\\^=|&&=|\\|\\|=|\\?\\?=`)},{kind:"bracket",regex:new RegExp(`\\b${t}\\s*\\[(?:'[^']+'|"[^"]+")\\]\\s*(?:=|\\+=)`)},{kind:"delete",regex:new RegExp(`\\bdelete\\s+${t}\\.[A-Za-z_$][\\w$]*\\b`)}],d):[],X=q.length>0?q:le,re=l.findRelationsByArgKeyword(t,r,d);for(let S of h)re.push(...l.findRelationsByArgKeyword(S,r,Math.floor(d/2)));let Ht=[],Bt=[],Xt=[];for(let S of N){let I=Be(S),L=/^[a-zA-Z_$][\w$]*$/.test(S)?"\\b":"";Ht.push({kind:"template",regex:new RegExp(`(?::\\w+|v-model|v-if|v-show|@\\w+)="[^"]*${L}${I}${L}|\\{\\{[^}]*${L}${I}${L}[^}]*\\}\\}`)},{kind:"return",regex:new RegExp(`\\breturn\\b[^=]*${L}${I}${L}`)},{kind:"watch",regex:new RegExp(`watch[^(]*['"]\\.?${I}['"]`)},{kind:"computed_read",regex:new RegExp(`=>[^=]*${L}${I}${L}|return[^=]*${L}${I}${L}`)},{kind:"arg_usage",regex:new RegExp(`\\(\\s*[^)]*${L}${I}${L}[^)]*\\)`)}),Bt.push(`${L}${I}${L}\\s*(?:=|\\+=|-=|\\*=|\\/=)(?!=)|\\b(?:const|let|var)\\s+${I}\\b`),Xt.push(`${L}${I}${L}\\.\\w+\\s*(?:=|\\+=|-=)(?!=)|${L}${I}${L}\\s*\\[`);}let Mn=$e(u,Ht,d),jn=new RegExp(Bt.join("|")),Un=new RegExp(Xt.join("|")),Pe=Mn.filter(S=>!jn.test(S.text)&&!Un.test(S.text)),yt=new Map,Wn=(S,I)=>{if(!yt.has(S)){let{behaviors:P}=l.getFileOutline(S),$=new Map;for(let j of P){let Q=String(j.symbol_name||"");$.has(Q)||$.set(Q,[]),$.get(Q).push(j);}yt.set(S,$);}return (yt.get(S)?.get(I)||[]).filter(P=>String(P.category||"")!=="storage"?false:s==="all"?true:String(P.api_name||"").toLowerCase()===s.toLowerCase())},Hn=(S,I)=>{let L=[],P=[{name:S,filePath:I,path:[S],level:0}],$=new Set([`${I}::${S}`]);for(;P.length>0;){let j=P.shift(),Q=Wn(j.filePath,j.name);if(Q.length>0){L.push({path:j.path,file:j.filePath,behaviors:Q});continue}if(j.level>=p)continue;let J=l.getSymbolByName(j.name,j.filePath);if(J||(J=l.getSymbolByName(j.name)),!J)continue;let Ne=String(J.file_path||J.abs_path||j.filePath),Ke=l.getCallees(J.id);for(let bt of Ke){let pe=String(bt.callee_name||"");if(!pe||pe.startsWith("$"))continue;let Vt=`${Ne}::${pe}`;$.has(Vt)||($.add(Vt),P.push({name:pe,filePath:Ne,path:[...j.path,pe],level:j.level+1}));}}return L},Bn=h.length>0?`
588
+ \u{1F517} \u53D1\u73B0\u522B\u540D: ${h.map(S=>`"${S}"`).join(", ")}\uFF08\u5DF2\u4E00\u5E76\u8FFD\u8E2A\u5C5E\u6027\u4FEE\u6539\uFF09`:"",Le=[];b.length>0&&(Le.push(` \u{1F517} \u5F15\u7528\u522B\u540D\u4F20\u64AD (${b.length} \u5904) \u2014 \u8FD9\u4E9B\u5C40\u90E8\u53D8\u91CF\u662F "${t}" \u7684\u5F15\u7528\uFF0C\u5176\u5C5E\u6027\u4FEE\u6539\u4E5F\u88AB\u8FFD\u8E2A:`),b.slice(0,10).forEach(S=>{let L=u.find(j=>j.path===S.filePath)?.abs_path||S.abs_path,P=ut("alias_ref"),$=L?Mt(L,S.line,2):{snippet:""};Le.push(` \u{1F4C4} ${S.filePath}:L${S.line} "${S.alias}" = ... ${P}`),Le.push(` ${S.text}`),$.snippet&&Le.push($.snippet);}));let C=[`\u{1F52C} \u53D8\u91CF\u751F\u547D\u5468\u671F\u8FFD\u8E2A: "${t}"`,"\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",`\u8FC7\u6EE4: file_path=${r||"*"} storage_api=${s} depth=${p}${Bn}`,""];if(f&&C.push(f),C.push(`\u2460 \u58F0\u660E & \u6574\u4F53\u8D4B\u503C (${ce.length} \u5904)`),ce.length===0)C.push(" \uFF08\u672A\u627E\u5230\uFF09");else {let S={init:[],cache:[],user:[],unknown:[]};for(let L of ce){let P=L.sourceLayer||ee(L.text,L.line);S[P].push(L);}let I=["init","cache","user","unknown"];for(let L of I){let P=S[L];!P||P.length===0||(C.push(` \u25B8 ${wn[L]} (${P.length} \u5904)`),P.slice(0,8).forEach($=>{let j=h.includes($.text.split("=")[0]?.trim().replace(/^(?:const|let|var)\s+/,"")||""),Q=ut($.kind,j);C.push(` \u{1F4C4} ${$.filePath}:L${$.line} [${$.kind}] ${Q}`),C.push(` ${$.text}`);}));}Le.length>0&&(C.push(""),C.push(...Le));}if(C.push(""),C.push(`\u2461 \u5C5E\u6027\u4FEE\u6539 (${X.length} \u5904)`),X.length===0)C.push(' \uFF08\u672A\u627E\u5230 object.prop \u6216 object["prop"] \u5199\u5165\uFF09'),h.length>0&&C.push(` \u2139\uFE0F \u5DF2\u8FFD\u8E2A\u522B\u540D: ${h.map(S=>`"${S}"`).join(", ")} \u7684\u5C5E\u6027\u4FEE\u6539\uFF08\u5982\u4ECD\u672A\u627E\u5230\uFF0C\u8868\u793A\u771F\u6B63\u65E0\u95F4\u63A5\u5199\u5165\uFF09`);else {let S={init:[],cache:[],user:[],unknown:[]};for(let L of X){let P=L.sourceLayer||ee(L.text,L.line);S[P].push(L);}let I=["init","cache","user","unknown"];for(let L of I){let P=S[L];!P||P.length===0||(C.push(` \u25B8 ${wn[L]} (${P.length} \u5904)`),P.slice(0,8).forEach($=>{let j=h.some(pe=>$.text.startsWith(pe)),Q=ut($.kind,j),Ne=u.find(pe=>pe.path===$.filePath)?.abs_path||"",Ke=Ne?Mt(Ne,$.line,2):{snippet:""},bt=j?" \u{1F517}(via alias)":"";C.push(` \u{1F4C4} ${$.filePath}:L${$.line} [${$.kind}] ${Q}${bt}`),Ke.snippet&&C.push(Ke.snippet);}));}}if(C.push(""),C.push(`\u2462 \u4F5C\u4E3A\u53C2\u6570\u88AB\u4F20\u5165\u8C03\u7528 (${re.length} \u5904)`),re.length===0?C.push(" \uFF08\u672A\u53D1\u73B0\u4EE5\u8BE5\u53D8\u91CF\u4F5C\u4E3A\u53C2\u6570\u7684\u51FD\u6570\u8C03\u7528\uFF09"):re.slice(0,20).forEach(S=>{let I=String(S.args||"");C.push(` \u{1F4C4} ${S.file_path}:L${S.line_number} ${S.caller_name} \u2192 ${S.callee_name} \u53C2\u6570: "${I}"`);}),C.push(""),C.push(`\u2463 \u8BFB\u53D6/\u4F7F\u7528 (${Pe.length} \u5904)`),Pe.length===0)C.push(" \uFF08\u672A\u53D1\u73B0 template \u7ED1\u5B9A / watch / computed / return \u4E2D\u7684\u5F15\u7528\uFF09");else {let S=new Map;for(let L of Pe)S.has(L.kind)||S.set(L.kind,[]),S.get(L.kind).push(L);let I={template:"\u{1F5BC}\uFE0F template \u7ED1\u5B9A",return:"\u21A9\uFE0F return \u8FD4\u56DE",watch:"\u{1F441}\uFE0F watch \u76D1\u542C",computed_read:"\u{1F9EE} computed \u5F15\u7528",arg_usage:"\u{1F4E8} \u51FD\u6570\u53C2\u6570\u4F7F\u7528"};for(let[L,P]of S)C.push(` \u25B8 ${I[L]||L}`),P.slice(0,8).forEach($=>C.push(` \u{1F4C4} ${$.filePath}:L${$.line} ${$.text}`));}C.push("");let Re=0;C.push(`\u2464 Storage \u843D\u70B9\u8FFD\u8E2A (storage_api=${s}, depth=${p})`);let Xn=s==="localStorage"?"localStorage":s==="sessionStorage"?"sessionStorage":"(?:localStorage|sessionStorage)",Kn=N.map(S=>({kind:"direct_storage",regex:new RegExp(`${Xn}\\.(?:setItem|getItem|removeItem|clear)\\(.*?\\b${Be(S)}\\b`)})),Xe=$e(u,Kn,d);if(Xe.length>0&&(Re+=1,C.push(` \u843D\u70B9 [\u76F4\u63A5\u547D\u4E2D\u5B58\u50A8] ${ut("direct_storage")}:`),Xe.slice(0,15).forEach(S=>{let L=u.find($=>$.path===S.filePath)?.abs_path||"",P=L?Mt(L,S.line,2):{snippet:""};C.push(` \u{1F4C4} ${S.filePath}:L${S.line} ${S.text.trim()}`),P.snippet&&C.push(P.snippet);})),re.length===0&&Xe.length===0)C.push(" \uFF08\u672A\u53D1\u73B0\u76F4\u63A5 Storage \u64CD\u4F5C\uFF0C\u4E14\u65E0\u8C03\u7528\u5165\u53E3\u5C55\u5F00\u8FFD\u8E2A\uFF09");else {let S=new Map;for(let I of re){let L=`${I.file_path}::${I.callee_name}`;S.has(L)||S.set(L,I);}for(let[,I]of S){let L=String(I.callee_name||""),P=String(I.file_path||""),$=Hn(L,P);$.length!==0&&(Re+=1,$.slice(0,3).forEach(j=>{let Q=j.file!==P?` \u2197 \u8DE8\u6587\u4EF6: ${j.file}`:"";C.push(` \u94FE\u8DEF: ${j.path.join(" \u2192 ")}${Q}`),j.behaviors.forEach(J=>{let Ne=J.detail?`("${String(J.detail)}")`:"";C.push(` \u843D\u70B9: ${J.api_name}.${J.operation}${Ne} [${J.category}] L${J.line_number}`);});}));}Re===0&&Xe.length===0&&C.push(` \uFF08\u5728 depth=${p} \u5C42\u5185\u672A\u627E\u5230 storage \u5199\u5165\u94FE\u8DEF\uFF09`);}C.push(""),C.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501");let Vn=h.length>0?` (\u542B ${h.length} \u4E2A\u522B\u540D: ${h.slice(0,3).map(S=>`"${S}"`).join(", ")})`:"";C.push(`\u2705 \u6C47\u603B${Vn}:`),C.push(` \u2460 \u58F0\u660E/\u8D4B\u503C: ${ce.length} \u5904`),C.push(` \u2461 \u5C5E\u6027\u4FEE\u6539: ${X.length} \u5904 (\u5DF2\u8FFD\u8E2A\u522B\u540D: ${h.map(S=>`"${S}"`).join(", ")||"\u65E0"})`),C.push(` \u2462 \u53C2\u6570\u4F20\u9012: ${re.length} \u5904`),C.push(` \u2463 \u8BFB\u53D6\u5F15\u7528: ${Pe.length} \u5904`),C.push(` \u2464 storage: ${Re>0?`\u2713 \u53D1\u73B0\u5199\u5165\u94FE\u8DEF (${Re} \u6761)`:"\u2717 \u672A\u53D1\u73B0"}`),C.push(""),C.push("\u{1F4A1} \u6765\u6E90\u5206\u5C42\u8BF4\u660E: \u{1F331}\u521D\u59CB\u5316 = lifecycle/data | \u{1F4BE}\u7F13\u5B58\u56DE\u663E = storage\u8BFB/fetch | \u{1F5B1}\uFE0F\u7528\u6237\u4EA4\u4E92 = \u4E8B\u4EF6/watch"),C.push("\u{1F4CA} \u7F6E\u4FE1\u5EA6: \u25CF\u25CF\u25CF\u25CF\u25CF \u226590% \u25CF\u25CF\u25CF\u25CF\u25CB \u226580% \u25CF\u25CF\u25CF\u25CB\u25CB \u226570% \u25CF\u25CF\u25CB\u25CB\u25CB \u226560% \u9700\u4EBA\u5DE5\u9A8C\u8BC1\u884C\u53F7\u786E\u8BA4");let zn=Math.round((performance.now()-c)*100)/100,Gn=ce.length+X.length+re.length+Pe.length+Re,Kt=W({durationMs:zn,resultCount:Gn,backend:A&&ye?"indexed":A||ye?"hybrid":"fallback_scan"});return m.stale&&(Kt.index_freshness=m),C.push(`
589
589
  \u2500\u2500 \u5143\u4FE1\u606F \u2500\u2500
590
590
  ${U(Kt)}`),{content:[{type:"text",text:C.join(`
591
591
  `)}]}});}function Fn(i,e){i.registerTool("skimmer_index_health",{title:"\u7D22\u5F15\u5065\u5EB7\u68C0\u67E5",description:`\u68C0\u67E5\u5F53\u524D\u9879\u76EE\u7D22\u5F15\u7684\u5065\u5EB7\u72B6\u6001\u3002
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jokeran/frontend-code-skimmer",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Frontend-Code-Skimmer: 不读全文,只看骨架;不搜字符,搜语义关联。支持 Vue2/Vue3/React Hooks",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",