@jokeran/frontend-code-skimmer 0.2.2 → 0.2.4

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 +95 -87
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,26 +1,29 @@
1
1
  #!/usr/bin/env node
2
- import D from'path';import'url';import Ot from'crypto';import {createRequire}from'module';import K from'fs';import cr from'fast-glob';import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import Mt from'os';import Ft from'better-sqlite3';import {z as z$1}from'zod';var Pt=Object.defineProperty;var V=(l,e)=>()=>(l&&(e=l(l=0)),e);var It=(l,e)=>{for(var t in e)Pt(l,t,{get:e[t],enumerable:true});};var $=V(()=>{});function A(l){return l.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 he(l,e){let t=l.length,r=e.length,n=Array.from({length:t+1},(s,o)=>Array.from({length:r+1},(i,a)=>o===0?a:a===0?o:0));for(let s=1;s<=t;s++)for(let o=1;o<=r;o++)l[s-1]===e[o-1]?n[s][o]=n[s-1][o-1]:n[s][o]=1+Math.min(n[s-1][o],n[s][o-1],n[s-1][o-1]);return n[t][r]}function Ze(l){return Ot.createHash("md5").update(l).digest("hex")}function Qe(l){if(!l)return 0;let e=1;for(let t=0;t<l.length;t++)l[t]===`
3
- `&&e++;return e}function te(l,e){return l===e?`L${l}`:`L${l}-L${e}`}function ye(l,e){return D.relative(e,l).replace(/\\/g,"/")}function ie(l,e){if(!l)return e;try{return JSON.parse(l)}catch{return e}}function U(l,e){let t=l.split(`
4
- `),n=e-1-1;for(;n>=0&&t[n].trim()==="";)n--;if(n<0||!t[n].trim().endsWith("*/"))return;let s=n;for(;s>0&&!t[s].trim().startsWith("/**");)s--;if(t[s].trim().startsWith("/**"))return t.slice(s,n+1).map(o=>o.replace(/^\s*\*\s?/,"").replace(/\/\*\*/,"").replace(/\*\//,"").trim()).filter(o=>o.length>0).join(" ")}function et(l,e){let t=l.toLowerCase(),r=e.toLowerCase();if(t===r)return 100;if(r.includes(t)||t.includes(r))return 85;let n=he(t,r),s=Math.max(t.length,r.length);if(s===0)return 100;let o=Math.max(0,100-n/s*100);return Math.round(o)}function Z(l){return l.startsWith("use")&&l.length>3&&/[A-Z]/.test(l[3])}function tt(l,e,t){if(t===0||t>3)return;let r=A(l).split(" "),n=A(e).split(" ");for(let s of r)for(let o of n){let i=he(s,o);if(i>0&&i<=3&&s!==o)return `"${s}" \u53EF\u80FD\u662F "${o}" \u7684\u62FC\u5199\u9519\u8BEF (\u7F16\u8F91\u8DDD\u79BB=${i})`}}var X=V(()=>{$();});var we,Ce,rt,Pe,Ie,nt,st,ot,Oe,je,Fe,it,be,at,ct,lt,z=V(()=>{$();we=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**","**/.nuxt/**","**/.next/**","**/__tests__/**","**/*.test.*","**/*.spec.*","**/*.min.js"],Ce=["**/*.vue","**/*.js","**/*.jsx","**/*.ts","**/*.tsx"],rt={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"]}},Pe=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","activated","deactivated","errorCaptured"],Ie=["onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","onActivated","onDeactivated","onErrorCaptured","onRenderTracked","onRenderTriggered","onServerPrefetch"],nt=["ref","reactive","shallowRef","shallowReactive","readonly"],st=["computed"],ot=["watch","watchEffect","watchPostEffect","watchSyncEffect"],Oe=["useState","useReducer","useRef","useImperativeHandle"],je=["useMemo","useCallback"],Fe=["useEffect","useLayoutEffect","useInsertionEffect"],it=["useContext","useDebugValue","useDeferredValue","useId","useSyncExternalStore","useTransition"],be=".skimmer-index.db",at=30,ct=4,lt=300;});function M(l,e,t,r=false){let n=[];return j(l,o=>{if(r&&o!==l&&(o.type==="FunctionDeclaration"||o.type==="ArrowFunctionExpression"||o.type==="FunctionExpression"||o.type==="ClassDeclaration"))return false;if(o.type==="CallExpression"){let a=Kt(o,e);a&&n.push(a);}if(o.type==="MemberExpression"){let i=Vt(o);i&&n.push(i);}}),qt(n)}function Kt(l,e,t){let r=l.callee;if(!r)return null;let n=Me(l);if(r.type==="MemberExpression"){let s=Xt(r);if(!s)return null;let{apiName:o,operation:i}=s,a=l.arguments,c=B(a?.[0]),f=Jt(o);return f?{symbolName:e,category:f,apiName:o,operation:i,detail:c,line:n}:o==="this"&&Se(i)?{symbolName:e,category:"network",apiName:`this.${i}`,operation:"wrapped_call",detail:c||B(a?.[1]),line:n}:pt(i)&&Yt(a)?{symbolName:e,category:"network",apiName:o,operation:i,detail:c||B(a?.[1]),line:n}:Se(o)||Se(`${o}.${i}`)?{symbolName:e,category:"network",apiName:o,operation:pt(i)?i:"wrapped_call",detail:c||B(a?.[1]),line:n}:null}if(r.type==="Identifier"){let s=r.name,o=zt(s),i=l.arguments,a=B(i?.[0]);return o?{symbolName:e,category:o.category,apiName:s,operation:o.operation,detail:a,line:n}:Se(s)?{symbolName:e,category:"network",apiName:s,operation:"wrapped_call",detail:a||B(i?.[1]),line:n}:null}return null}function Vt(l,e,t){let r=l.object,n=l.property;if(!r||!n||r.type!=="MemberExpression"&&r.type!=="ThisExpression"&&r.type!=="Identifier")return null;let s=Gt(r);if(!s)return null;n.type==="Identifier"?n.name:"";if(s==="this"||s===""){r.type==="MemberExpression"?r.property?.name:"";return null}return null}function Xt(l){let e=l.object,t=l.property;if(!e||!t||t.type!=="Identifier")return null;let r=t.name;if(e.type==="MemberExpression"){let n=e.property?.name;if(n)return {apiName:n,operation:r}}return e.type==="Identifier"?{apiName:e.name,operation:r}:e.type==="ThisExpression"?{apiName:"this",operation:r}:null}function zt(l){let e={fetch:"network",setTimeout:"timer",setInterval:"timer",clearTimeout:"timer",clearInterval:"timer",requestAnimationFrame:"timer",navigate:"router"};return e[l]?{category:e[l],operation:l}:null}function Me(l){return l.loc?.start?.line??0}function Gt(l){return l.type==="Identifier"?l.name:l.type==="ThisExpression"?"this":null}function Jt(l){if(l==="this")return null;for(let[e,t]of Object.entries(rt))if(l in t)return e;return null}function B(l,e){if(l){if(l.type==="Literal"||l.type==="StringLiteral"||l.type==="NumericLiteral"||l.type==="BooleanLiteral")return String(l.value);if(l.type==="NullLiteral")return "null";if(l.type==="TemplateLiteral"){let t=l.quasis,r=l.expressions||[],n=[];for(let o=0;o<t.length;o++){let i=t[o].value?.cooked||"";if(i&&n.push(i),o<r.length){let a=Ae(r[o])||"expr";n.push(`\${${a}}`);}}return n.join("")||"${expr}"}if(l.type==="Identifier")return `[\u53D8\u91CF: ${l.name}]`;if(l.type==="ObjectExpression"){let t=l.properties||[],r=["url","uri","path","api","endpoint"];for(let n of t){let s=n.key,o=n.value;if(!s||!o)continue;let i=s.type==="Identifier"?String(s.name):s.type==="Literal"?String(s.value):"";if(!r.includes(i))continue;let a=B(o);if(a)return `${i}:${a}`}return "{...}"}}}function Ae(l,e){if(!l)return;if(l.type==="Identifier")return l.name;if(l.type==="ThisExpression")return "this";if(l.type==="Literal"||l.type==="StringLiteral"||l.type==="NumericLiteral"||l.type==="BooleanLiteral")return String(l.value);if(l.type==="NullLiteral")return "null";if(l.type==="MemberExpression"){let r=Ae(l.object)||"obj",n=l.property,s=n?.type==="Identifier"?String(n.name):Ae(n)||"prop";return l.computed?`${r}[${s}]`:`${r}.${s}`}if(l.type==="CallExpression")return `${Ae(l.callee)||"fn"}(...)`;if(l.type==="TemplateLiteral")return B(l);let t=B(l);return t?.startsWith("[\u53D8\u91CF: ")?t.replace(/^\[变量: /,"").replace(/\]$/,""):t}function Se(l){return /request|api|http|fetch|ajax|akscommonhandle|commonhandle/i.test(l)}function pt(l){return ["get","post","put","delete","patch","request"].includes(l.toLowerCase())}function Yt(l,e){if(!l||l.length===0)return false;for(let t of l.slice(0,2)){let r=B(t);if(r&&(/https?:\/\//i.test(r)||r.includes("/")||/gw\d?\/|\/m\/|\/api\//i.test(r)))return true}return false}function qt(l){let e=new Set;return l.filter(t=>{let r=`${t.apiName}:${t.operation}:${t.line}`;return e.has(r)?false:(e.add(r),true)})}function _e(l,e,t){let r=[];return j(l,n=>{if(n.type==="CallExpression"&&n.callee?.type==="MemberExpression"){let s=n.callee,o=s.object,i=s.property;if(o.type==="ThisExpression"&&i.type==="Identifier"){let a=i.name;if(!a.startsWith("$")&&a!==e){let c=n.arguments,f=dt(c);r.push({calleeName:a,line:Me(n),args:f});}}}}),r}function J(l,e,t,r=false){let n=[];return j(l,o=>{if(r&&o!==l&&(o.type==="FunctionDeclaration"||o.type==="ArrowFunctionExpression"||o.type==="FunctionExpression"||o.type==="ClassDeclaration"))return false;if(o.type==="CallExpression"&&o.callee?.type==="Identifier"){let i=o.callee.name;if(i!==e&&!Zt(i)){let a=o.arguments,c=dt(a);n.push({calleeName:i,line:Me(o),args:c});}}}),n}function Zt(l){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(l)}function dt(l,e){if(!l||l.length===0)return;let t=l.slice(0,3).map(r=>B(r)).filter(r=>!!r);return t.length>0?t.join(", "):void 0}function j(l,e){if(!(!l||typeof l!="object")&&e(l)!==false)for(let t of Object.keys(l)){if(t==="type"||t==="loc"||t==="start"||t==="end")continue;let r=l[t];if(Array.isArray(r))for(let n of r)n&&typeof n=="object"&&n.type&&j(n,e);else r&&typeof r=="object"&&r.type&&j(r,e);}}var xe=V(()=>{$();z();});var ut,re,We=V(()=>{$();z();xe();X();ut=createRequire(import.meta.url),re=class{name="Vue2Parser";canParse(e,t){return e.endsWith(".vue")}parse(e,t){let r={framework:"vue2",filePath:e,symbols:[],relations:[],behaviors:[],errors:[]};try{let s=ut("vue-template-compiler").parseComponent(t);if(!s.script?.content)return r;let o=s.script.content,i=this.getScriptStartLine(t,s.script.start),a=t.split(`
5
- `),c;try{c=ut("@babel/parser").parse(o,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy"],errorRecovery:!0});}catch(f){return r.errors?.push(`AST \u89E3\u6790\u5931\u8D25: ${String(f)}`),r}this.extractFromAST(c.program,o,a,i,r);}catch(n){r.errors?.push(`\u89E3\u6790\u5931\u8D25: ${String(n)}`);}return r}getScriptStartLine(e,t){let r=1;for(let n=0;n<t&&n<e.length;n++)e[n]===`
6
- `&&r++;return r}extractFromAST(e,t,r,n,s){let o=t.split(`
7
- `),i=null;j(e,d=>{if(d.type==="ExportDefaultDeclaration"){let p=d.declaration;if(p?.type==="ObjectExpression")i=p;else if(p?.type==="CallExpression"){let u=p.arguments;u&&u.length>0&&u[0].type==="ObjectExpression"&&(i=u[0]);}else if(p?.type==="Identifier"){let u=p.name;j(e,g=>{if(g.type==="VariableDeclarator"&&g.id?.name===u){if(g.init?.type==="ObjectExpression")i=g.init;else if(g.init?.type==="CallExpression"){let m=g.init.arguments;m&&m.length>0&&m[0].type==="ObjectExpression"&&(i=m[0]);}}});}}});let c=false;if(!i&&(j(e,d=>{d.type==="ExportDefaultDeclaration"&&d.declaration?.type==="ClassDeclaration"&&(c=true,this.extractFromClassComponent(d.declaration,t,r,n,s));}),!c)){let d=null,p=0,u=["data","methods","computed","props","watch","components","created","mounted","mixins"];j(e,g=>{if(g.type==="ObjectExpression"){let m=g.properties||[],E=0;for(let N of m){let y=this.getPropKey(N);y&&u.includes(y)&&E++;}E>p&&(p=E,d=g);}}),p>=2&&d&&(i=d);}if(!i)return;let f=i.properties;for(let d of f||[]){let p=this.getPropKey(d);if(!p)continue;let u=d.type==="ObjectMethod"?d:d.value;if(!u)continue;let g=m=>m+n-1;switch(p){case "name":u?.type==="Literal"&&(String(u.value));break;case "data":this.extractData(u,o,g,s);break;case "props":this.extractProps(u,o,g,s);break;case "computed":this.extractComputedOrMethods(u,"computed",o,g,r,s);break;case "methods":this.extractComputedOrMethods(u,"method",o,g,r,s);break;case "watch":this.extractWatch(u,o,g,s);break;case "filters":this.extractComputedOrMethods(u,"filter",o,g,r,s);break;case "components":this.extractComponents(u,s);break;case "mixins":this.extractMixins(u,s);break;default:if(Pe.includes(p)){let m=g(this.getStartLine(d)),E=g(this.getEndLine(d)),N=U(r.join(`
8
- `),m),y=s.symbols.length;s.symbols.push({name:p,category:"lifecycle",framework:"vue2",startLine:m,endLine:E,jsdoc:N,camelWords:A(p)});let h=M(u,p);s.behaviors.push(...h);let b=_e(u,p);for(let T of b){if(T.args){let v=String(T.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[y].camelWords+=` ${A(v)} ${v}`;}s.relations.push({callerName:p,callerLine:m,calleeName:T.calleeName,callType:"this_method",line:g(T.line),args:T.args});}}break}}}extractData(e,t,r,n){let s=null;if(e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"||e.type==="ObjectMethod"?j(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 i=this.getPropKey(o);if(!i)continue;let a=r(this.getStartLine(o)),c=r(this.getEndLine(o)),f=this.getLiteralValue(o.value);n.symbols.push({name:i,category:"state",framework:"vue2",startLine:a,endLine:c,defaultValue:f,camelWords:A(i)});}}extractProps(e,t,r,n){if(e.type==="ArrayExpression"){for(let s of e.elements||[])if(s?.type==="Literal"){let o=String(s.value);n.symbols.push({name:o,category:"prop",framework:"vue2",startLine:r(this.getStartLine(s)),endLine:r(this.getEndLine(s)),camelWords:A(o)});}}else if(e.type==="ObjectExpression")for(let s of e.properties||[]){let o=this.getPropKey(s);if(!o)continue;let i=r(this.getStartLine(s)),a=r(this.getEndLine(s)),c;if(s.value?.type==="ObjectExpression"){let f=s.value.properties?.find(d=>this.getPropKey(d)==="default");f&&(c=this.getLiteralValue(f.value));}n.symbols.push({name:o,category:"prop",framework:"vue2",startLine:i,endLine:a,defaultValue:c,camelWords:A(o)});}}extractComputedOrMethods(e,t,r,n,s,o){if(e.type==="ObjectExpression")for(let i of e.properties||[]){let a=this.getPropKey(i);if(!a)continue;let c=i.type==="ObjectMethod"?i:i.value;if(!c)continue;let f=n(this.getStartLine(i)),d=n(this.getEndLine(i)),p=U(s.join(`
9
- `),f),u=this.extractParams(c),g=c.async===true,m=u?`${a}(${u.join(", ")})`:a;if(o.symbols.push({name:a,category:t,framework:"vue2",startLine:f,endLine:d,signature:m,params:u,isAsync:g,jsdoc:p,camelWords:A(a)}),t==="method"&&c){let E=M(c,a);o.behaviors.push(...E);let N=_e(c,a);for(let y of N){if(y.args){let h=String(y.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");o.symbols[o.symbols.length-1].camelWords+=` ${A(h)} ${h}`;}o.relations.push({callerName:a,callerLine:f,calleeName:y.calleeName,callType:"this_method",line:n(y.line),args:y.args});}}}}extractWatch(e,t,r,n){if(e.type==="ObjectExpression")for(let s of e.properties||[]){let o=this.getPropKey(s);if(!o)continue;let i=r(this.getStartLine(s)),a=r(this.getEndLine(s));n.symbols.push({name:o,category:"effect",framework:"vue2",startLine:i,endLine:a,camelWords:A(o)});}}extractComponents(e,t){if(e.type==="ObjectExpression")for(let r of e.properties||[]){let n=this.getPropKey(r);n&&t.symbols.push({name:n,category:"component",framework:"vue2",startLine:this.getStartLine(r),endLine:this.getEndLine(r),camelWords:A(n)});}}extractMixins(e,t){if(e.type==="ArrayExpression")for(let r of e.elements||[]){let n=r?.type==="Identifier"?r.name:null;n&&t.symbols.push({name:n,category:"mixin",framework:"vue2",startLine:this.getStartLine(r),endLine:this.getEndLine(r),camelWords:A(n)});}}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(r=>r.type==="Identifier"?r.name:r.type==="AssignmentPattern"?r.left?.name||"?":r.type==="RestElement"?`...${r.argument?.name||""}`:r.type==="TSParameterProperty"&&r.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,r,n,s){let o=a=>a+n-1,i=e.body;if(!(!i||i.type!=="ClassBody"))for(let a of i.body||[]){let c=this.getPropKey(a);if(!c)continue;let f=o(this.getStartLine(a)),d=o(this.getEndLine(a)),p=U(r.join(`
10
- `),f);if(a.type==="ClassMethod"){let g=Pe.includes(c)?"lifecycle":"method",m=this.extractParams(a),E=a.async===true,N=m?`${c}(${m.join(", ")})`:c;s.symbols.push({name:c,category:g,framework:"vue2",startLine:f,endLine:d,signature:N,params:m,isAsync:E,jsdoc:p,camelWords:A(c)});let y=M(a,c);s.behaviors.push(...y);let h=_e(a,c);for(let b of h){if(b.args){let T=String(b.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[s.symbols.length-1].camelWords+=` ${A(T)} ${T}`;}s.relations.push({callerName:c,callerLine:f,calleeName:b.calleeName,callType:"this_method",line:o(b.line),args:b.args});}}else if(a.type==="ClassProperty"){let u=(a.decorators||[]).some(m=>m.expression?.callee?.name==="Prop"),g=this.getLiteralValue(a.value);s.symbols.push({name:c,category:u?"prop":"state",framework:"vue2",startLine:f,endLine:d,defaultValue:g,camelWords:A(c)});}}}};});var Ue,Te,ft=V(()=>{$();z();xe();X();We();Ue=createRequire(import.meta.url),Te=class{name="Vue3Parser";canParse(e,t){return e.endsWith(".vue")?this.looksLikeVue3File(t):false}parse(e,t){let r={framework:"vue3",filePath:e,symbols:[],relations:[],behaviors:[],errors:[]};try{let{parse:n}=Ue("@vue/compiler-sfc"),{descriptor:s}=n(t),o=t.split(`
11
- `),i=!!s.scriptSetup,a=!!s.script;if(i){let c=s.scriptSetup,f=c.loc.start.line;this.parseSetupContent(c.content,f,o,r);}else if(a){let c=s.script,f=c.loc.start.line;this.parseScriptContent(c.content,f,o,r)||this.populateFromOptionsApiFallback(e,t,r);}}catch(n){r.errors?.push(`Vue3 \u89E3\u6790\u5931\u8D25: ${String(n)}`);}return r}parseSetupContent(e,t,r,n){let s;try{s=Ue("@babel/parser").parse(e,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"],errorRecovery:!0});}catch(c){n.errors?.push(`AST \u89E3\u6790\u5931\u8D25: ${String(c)}`);return}let o=c=>c+t-1,i=e.split(`
12
- `),a=s.program.body;for(let c of a||[])this.processTopLevelStatement(c,o,r,i,n);}parseScriptContent(e,t,r,n){let s;try{s=Ue("@babel/parser").parse(e,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"],errorRecovery:!0});}catch(c){return n.errors?.push(`AST \u89E3\u6790\u5931\u8D25: ${String(c)}`),false}let o=c=>c+t-1,i=e.split(`
13
- `),a=false;return j(s.program,c=>{if(c.type==="ExportDefaultDeclaration"&&c.declaration?.type==="ObjectExpression"){let f=c.declaration.properties?.find(d=>this.getPropKey(d)==="setup");if(f){a=true;let d=f.type==="ObjectMethod"?f:f.value;if(!d)return;let p=d.body;if(p?.type==="BlockStatement"){let u=p.body;for(let g of u||[])this.processTopLevelStatement(g,o,r,i,n);}}}}),a||j(s.program,c=>{if(!a&&c.type==="ObjectExpression"){let d=(c.properties||[]).find(p=>this.getPropKey(p)==="setup");if(d){a=true;let p=d.type==="ObjectMethod"?d:d.value;if(!p)return;let u=p.body;if(u?.type==="BlockStatement"){let g=u.body;for(let m of g||[])this.processTopLevelStatement(m,o,r,i,n);}}}}),a}processTopLevelStatement(e,t,r,n,s){let o=i=>{let a=i?.loc;return {start:a?.start?.line??1,end:a?.end?.line??1}};if(e.type==="VariableDeclaration")for(let i of e.declarations||[]){if(i.id?.type!=="Identifier"&&i.id?.type!=="ArrayPattern")continue;let a=i.init;if(a&&i.id.type==="Identifier"){let c=i.id.name;if(a.type==="ArrowFunctionExpression"||a.type==="FunctionExpression"){let{start:f,end:d}=o(e),p=U(r.join(`
14
- `),t(f)),u=this.extractParams(a),g=s.symbols.length;if(s.symbols.push({name:c,category:"method",framework:"vue3",startLine:t(f),endLine:t(d),signature:`${c}(${(u||[]).join(", ")})`,params:u,isAsync:a.async===true,jsdoc:p,camelWords:A(c)}),a.body){let m=M(a.body,c);s.behaviors.push(...m);let E=J(a.body,c);for(let N of E){if(N.args){let y=String(N.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[g].camelWords+=` ${A(y)} ${y}`;}s.relations.push({callerName:c,callerLine:t(f),calleeName:N.calleeName,callType:"direct_call",line:t(N.line),args:N.args});}}}else {let f=this.classifyVue3Declaration(c,a,t,o(e),r);f&&s.symbols.push(f);}}}if(e.type==="FunctionDeclaration"&&e.id?.type==="Identifier"){let i=e.id.name,{start:a,end:c}=o(e),f=U(r.join(`
15
- `),t(a)),d=this.extractParams(e),p=Ie.includes(i);if(s.symbols.push({name:i,category:p?"lifecycle":Z(i)?"hook":"method",framework:"vue3",startLine:t(a),endLine:t(c),signature:`${i}(${(d||[]).join(", ")})`,params:d,isAsync:e.async===true,jsdoc:f,camelWords:A(i)}),e.body){let u=M(e.body,i);s.behaviors.push(...u);let g=J(e.body,i);for(let m of g){if(m.args){let E=String(m.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[s.symbols.length-1].camelWords+=` ${A(E)} ${E}`;}s.relations.push({callerName:i,callerLine:t(a),calleeName:m.calleeName,callType:"direct_call",line:t(m.line),args:m.args});}}}if(e.type==="ExpressionStatement"&&e.expression?.type==="CallExpression"){let a=e.expression.callee;if(a?.type==="Identifier"){let c=a.name;if(["defineProps","defineEmits","defineExpose"].includes(c)){let{start:f,end:d}=o(e);s.symbols.push({name:c,category:c==="defineProps"?"prop":c==="defineEmits"?"emit":"export",framework:"vue3",startLine:t(f),endLine:t(d),camelWords:A(c)});}}}if(e.type==="ExpressionStatement"&&e.expression?.type==="CallExpression"){let i=e.expression,a=i.callee;if(a?.type==="Identifier"){let c=a.name;if(Ie.includes(c)){let{start:f,end:d}=o(e);s.symbols.push({name:c,category:"lifecycle",framework:"vue3",startLine:t(f),endLine:t(d),camelWords:A(c)});let p=i.arguments;if(p?.[0]){let u=M(p[0],c);s.behaviors.push(...u);let g=J(p[0],c);for(let m of g){if(m.args){let E=String(m.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[s.symbols.length-1].camelWords+=` ${A(E)} ${E}`;}s.relations.push({callerName:c,callerLine:t(f),calleeName:m.calleeName,callType:"direct_call",line:t(m.line),args:m.args});}}}}}}classifyVue3Declaration(e,t,r,n,s){if(t.type!=="CallExpression")return null;let o=t.callee;if(o?.type!=="Identifier")return null;let i=o.name,a=r(n.start),c=r(n.end),f=U(s.join(`
16
- `),a);if(nt.includes(i)){let d=t.arguments,p=d?.[0]?this.getLiteralValue(d[0]):void 0;return {name:e,category:"state",framework:"vue3",startLine:a,endLine:c,defaultValue:p,jsdoc:f,camelWords:A(e)}}return st.includes(i)?{name:e,category:"computed",framework:"vue3",startLine:a,endLine:c,jsdoc:f,camelWords:A(e)}:ot.includes(i)?{name:e,category:"effect",framework:"vue3",startLine:a,endLine:c,camelWords:A(e)}:i==="provide"||i==="inject"?{name:e,category:"provide",framework:"vue3",startLine:a,endLine:c,camelWords:A(e)}:Z(i)?{name:e,category:"hook",framework:"vue3",startLine:a,endLine:c,jsdoc:f,camelWords:A(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(r=>r.type==="Identifier"?r.name:r.type==="AssignmentPattern"?r.left?.name||"?":r.type==="RestElement"?`...${r.argument?.name||""}`:r.type==="ObjectPattern"?"{...}":r.type==="TSParameterProperty"&&r.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,r){let n=new re().parse(e,t);r.symbols=n.symbols.map(s=>({...s,framework:"vue3"})),r.relations=n.relations,r.behaviors=n.behaviors,r.errors=[...r.errors||[],...n.errors||[]];}};});var rr,nr,ae,mt=V(()=>{$();z();xe();X();rr=createRequire(import.meta.url),nr=[...Oe,...je,...Fe,...it],ae=class{name="ReactParser";canParse(e,t){let r=e.split(".").pop()?.toLowerCase();return ["jsx","tsx","js","ts"].includes(r||"")?t.includes("useState")||t.includes("useEffect")||t.includes("from 'react'")||t.includes('from "react"')||t.includes("React.")||t.includes("jsx")||t.includes("JSX"):false}parse(e,t){let r={framework:"react",filePath:e,symbols:[],relations:[],behaviors:[],errors:[]};try{let s=rr("@babel/parser").parse(t,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy"],errorRecovery:!0}),o=t.split(`
17
- `);this.extractFromAST(s.program?s.program:s,o,r);}catch(n){r.errors?.push(`React \u89E3\u6790\u5931\u8D25: ${String(n)}`);}return r}extractFromAST(e,t,r){let n=e.body;for(let s of n||[]){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;o&&o.id?.type==="Identifier"&&this.processFunction(o,t,r);}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;if(o)for(let i of o.declarations||[]){let a=i.init;if(a&&(a.type==="ArrowFunctionExpression"||a.type==="FunctionExpression")&&i.id?.type==="Identifier"){let c={...a,id:i.id,loc:{start:o.loc?.start??a.loc?.start,end:a.loc?.end}};this.processFunction(c,t,r);}}}}}processFunction(e,t,r){let n=e.id?.name;if(!n)return;let s=e.loc,o=s?.start?.line??1,i=s?.end?.line??1,a=Z(n),c=!a&&/^[A-Z]/.test(n),f=U(t.join(`
18
- `),o),d=this.extractParams(e),p=this.buildSymbolKey(n,o,i);r.symbols.push({name:n,category:a?"hook":c?"component":"function",framework:"react",startLine:o,endLine:i,internalKey:p,signature:`${n}(${(d||[]).join(", ")})`,params:d,isAsync:e.async===true,jsdoc:f,parentComponent:c?n:void 0,camelWords:A(n)});let u=e.body;if(u?.type!=="BlockStatement")return;let g=u.body;for(let N of g||[])this.processComponentStatement(N,n,t,r);let m=M(u,n,t,true);r.behaviors.push(...m);let E=J(u,n,t,true);for(let N of E){let y=r.symbols.findIndex(h=>h.name===n&&h.startLine===o);if(N.args&&y!==-1){let h=String(N.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");r.symbols[y].camelWords+=` ${A(h)} ${h}`;}r.relations.push({callerName:n,callerLine:o,callerKey:p,calleeName:N.calleeName,callType:"direct_call",line:N.line,args:N.args});}}processComponentStatement(e,t,r,n){let s=o=>{let i=o?.loc;return {start:i?.start?.line??1,end:i?.end?.line??1}};if(e.type==="VariableDeclaration")for(let o of e.declarations||[]){let i=o.init;if(!i||i.type!=="CallExpression")continue;let a=i.callee;if(a?.type!=="Identifier")continue;let c=a.name,{start:f,end:d}=s(e),p=f,u=d;if(Oe.includes(c)&&c!=="useRef"){if(o.id?.type==="ArrayPattern"){let g=o.id.elements,m=g[0]?.name,E=g[1]?.name;if(m){let N=i.arguments;n.symbols.push({name:m,category:"state",framework:"react",startLine:p,endLine:u,internalKey:this.buildSymbolKey(m,p,u,t),stateSetterName:E,defaultValue:this.getLiteralValue(N?.[0]),parentComponent:t,camelWords:A(m)});}}else if(o.id?.type==="Identifier"){let g=o.id.name;n.symbols.push({name:g,category:"state",framework:"react",startLine:p,endLine:u,internalKey:this.buildSymbolKey(g,p,u,t),parentComponent:t,camelWords:A(g)});}}if(c==="useRef"&&o.id?.type==="Identifier"){let g=o.id.name,m=i.arguments;n.symbols.push({name:g,category:"state",framework:"react",startLine:p,endLine:u,internalKey:this.buildSymbolKey(g,p,u,t),defaultValue:this.getLiteralValue(m?.[0]),parentComponent:t,camelWords:A(g)});}if(je.includes(c)&&o.id?.type==="Identifier"){let g=o.id.name,E=i.arguments?.[1],N=this.extractDepsArray(E);n.symbols.push({name:g,category:"computed",framework:"react",startLine:p,endLine:u,internalKey:this.buildSymbolKey(g,p,u,t),hookDeps:N,parentComponent:t,camelWords:A(g)});}if(Z(c)&&!nr.includes(c)){let g=o.id?.type==="Identifier"?o.id.name:o.id?.type==="ObjectPattern"?"{...}":"?";n.symbols.push({name:g,category:"hook",framework:"react",startLine:p,endLine:u,internalKey:this.buildSymbolKey(g,p,u,t),parentComponent:t,camelWords:A(g)});}}if(e.type==="ExpressionStatement"&&e.expression?.type==="CallExpression"){let o=e.expression,i=o.callee;if(i?.type==="Identifier"){let a=i.name;if(Fe.includes(a)){let{start:c,end:f}=s(e),d=o.arguments,p=d?.[1],u=this.extractDepsArray(p),g=this.buildSymbolKey(a,c,f,t),m=`${t}.${a}`;if(n.symbols.push({name:a,category:"effect",framework:"react",startLine:c,endLine:f,internalKey:g,hookDeps:u,parentComponent:t,camelWords:A(a)}),d?.[0]){let E=M(d[0],m,r,true).map(y=>({...y,symbolKey:g}));n.behaviors.push(...E);let N=J(d[0],m,r,true);for(let y of N){let h=n.symbols.findIndex(b=>b.name===a&&b.startLine===c);if(y.args&&h!==-1){let b=String(y.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");n.symbols[h].camelWords+=` ${A(b)} ${b}`;}n.relations.push({callerName:m,callerLine:c,callerKey:g,calleeName:y.calleeName,callType:"direct_call",line:y.line,args:y.args});}}}}}if(e.type==="FunctionDeclaration"&&e.id?.type==="Identifier"){let o=e.id.name;if(!Z(o)){let{start:i,end:a}=s(e),c=U(r.join(`
19
- `),i),f=this.extractParams(e);if(n.symbols.push({name:o,category:"method",framework:"react",startLine:i,endLine:a,internalKey:this.buildSymbolKey(o,i,a,t),signature:`${o}(${(f||[]).join(", ")})`,params:f,isAsync:e.async===true,jsdoc:c,parentComponent:t,camelWords:A(o)}),e.body){let d=M(e.body,o,r,true);n.behaviors.push(...d);let p=J(e.body,o,r,true);for(let u of p){let g=n.symbols.findIndex(m=>m.name===o&&m.startLine===i);if(u.args&&g!==-1){let m=String(u.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");n.symbols[g].camelWords+=` ${A(m)} ${m}`;}n.relations.push({callerName:o,callerLine:i,callerKey:this.buildSymbolKey(o,i,a,t),calleeName:u.calleeName,callType:"direct_call",line:u.line,args:u.args});}}}}if(e.type==="VariableDeclaration")for(let o of e.declarations||[]){let i=o.init;if(!i)continue;let a=i.type==="ArrowFunctionExpression"||i.type==="FunctionExpression";if(!a||o.id?.type!=="Identifier")continue;let c=o.id.name,f=i.type==="CallExpression"?i.callee:null;if(f?.type==="Identifier"&&Z(f.name))continue;if(i.type==="CallExpression"&&i.callee?.name==="useCallback"){let N=i.arguments?.[1],y=this.extractDepsArray(N),{start:h,end:b}=s(e);n.symbols.push({name:c,category:"computed",framework:"react",startLine:h,endLine:b,internalKey:this.buildSymbolKey(c,h,b,t),hookDeps:y,parentComponent:t,camelWords:A(c)});continue}if(!a)continue;let{start:p,end:u}=s(e),g=U(r.join(`
20
- `),p),m=this.extractParams(i);if(n.symbols.push({name:c,category:"method",framework:"react",startLine:p,endLine:u,internalKey:this.buildSymbolKey(c,p,u,t),signature:`${c}(${(m||[]).join(", ")})`,params:m,isAsync:i.async===true,jsdoc:g,parentComponent:t,camelWords:A(c)}),i.body){let E=M(i.body,c,r,true);n.behaviors.push(...E);let N=J(i.body,c,r,true);for(let y of N){let h=n.symbols.findIndex(b=>b.name===c&&b.startLine===p);if(y.args&&h!==-1){let b=String(y.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");n.symbols[h].camelWords+=` ${A(b)} ${b}`;}n.relations.push({callerName:c,callerLine:p,callerKey:this.buildSymbolKey(c,p,u,t),calleeName:y.calleeName,callType:"direct_call",line:y.line,args:y.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(r=>r.type==="Identifier"?r.name:r.type==="ObjectPattern"?"{...}":r.type==="ArrayPattern"?"[...]":r.type==="AssignmentPattern"?r.left?.name||"?":r.type==="RestElement"?`...${r.argument?.name||""}`:r.type==="TSParameterProperty"&&r.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,r,n){return `${n||"root"}:${e}:${t}:${r}`}};});function gt(l,e){for(let t of sr)if(t.canParse(l,e)){let r=t.parse(l,e);return or(r),r}return {framework:"js",filePath:l,symbols:[],relations:[],behaviors:[],errors:[`\u6CA1\u6709\u627E\u5230\u9002\u5408\u7684\u89E3\u6790\u5668: ${l}`]}}function or(l){if(!l.relations.length||!l.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(l.behaviors.filter(n=>n.category==="network").map(n=>n.symbolName));if(t.size===0)return;let r=new Set(l.behaviors.map(n=>`${n.symbolName}:${n.category}:${n.apiName}:${n.operation}:${n.line}`));for(let n of l.relations){if(!t.has(n.calleeName)||t.has(n.callerName)||e.has(n.callerName))continue;let s={symbolName:n.callerName,symbolKey:n.callerKey,category:"network",apiName:"wrapped_network",operation:n.calleeName,detail:n.args,line:n.line},o=`${s.symbolName}:${s.category}:${s.apiName}:${s.operation}:${s.line}`;r.has(o)||(r.add(o),l.behaviors.push(s));}}var He,sr,ht=V(()=>{$();We();ft();mt();He=class extends ae{name="JsTsFallbackParser";canParse(e){let t=e.split(".").pop()?.toLowerCase();return ["js","ts","jsx","tsx"].includes(t||"")}parse(e,t){let r=super.parse(e,t);return r.framework=e.endsWith(".ts")||e.endsWith(".tsx")?"ts":"js",r}},sr=[new Te,new re,new ae,new He];});var yt={};It(yt,{Indexer:()=>ce});var ce,Be=V(()=>{$();ht();X();z();ce=class{projectRoot;db;constructor(e,t){this.projectRoot=e,this.db=t;}async indexProject(e){let t=Date.now(),r=e?.include||[...Ce],n=e?.exclude||[...we],s=e?.force||false,o=await cr(r,{cwd:this.projectRoot,ignore:n,absolute:true,onlyFiles:true}),i={totalFiles:o.length,indexedFiles:0,skippedFiles:0,totalSymbols:0,durationMs:0,errors:[]};for(let a=0;a<o.length;a++){let c=o[a],f=ye(c,this.projectRoot);e?.onProgress?.(a+1,o.length,f);try{let d=await this.indexFile(c,f,s);d.skipped?i.skippedFiles++:(i.indexedFiles++,i.totalSymbols+=d.symbolCount,d.errors?.length&&i.errors.push(...d.errors.map(p=>({file:f,error:p}))));}catch(d){i.errors.push({file:f,error:String(d)});}}return i.durationMs=Date.now()-t,i}async indexFile(e,t,r=false){let n=K.readFileSync(e,"utf-8"),s=Ze(n);if(!r&&this.db.getFileHash(t)===s)return {skipped:true,symbolCount:0};let o=Qe(n),i=Buffer.byteLength(n,"utf-8"),a=gt(e,n);return this.db.saveParseResult(a,e,t,s,i,o),{skipped:false,symbolCount:a.symbols.length,errors:a.errors}}removeFile(e){this.db.deleteFile(e);}async startWatcher(){let{default:e}=await import('chokidar'),t=e.watch([...Ce].map(n=>D.posix.join(this.projectRoot,n)),{cwd:this.projectRoot,ignored:[...we],persistent:true,ignoreInitial:true,awaitWriteFinish:{stabilityThreshold:lt}}),r=async n=>{let s=ye(n,this.projectRoot);try{await this.indexFile(n,s),process.stderr.write(`[Frontend-Code-Skimmer] \u5DF2\u66F4\u65B0\u7D22\u5F15: ${s}
2
+ import H from'path';import'url';import Qt from'crypto';import {createRequire}from'module';import W from'fs';import Rn from'fast-glob';import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import rn from'os';import tn from'better-sqlite3';import {z as z$1}from'zod';var qt=Object.defineProperty;var z=(l,e)=>()=>(l&&(e=l(l=0)),e);var Zt=(l,e)=>{for(var t in e)qt(l,t,{get:e[t],enumerable:true});};var w=z(()=>{});function A(l){return l.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 _e(l,e){let t=l.length,n=e.length,r=Array.from({length:t+1},(s,o)=>Array.from({length:n+1},(i,c)=>o===0?c:c===0?o:0));for(let s=1;s<=t;s++)for(let o=1;o<=n;o++)l[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 lt(l){return Qt.createHash("md5").update(l).digest("hex")}function pt(l){if(!l)return 0;let e=1;for(let t=0;t<l.length;t++)l[t]===`
3
+ `&&e++;return e}function ce(l,e){return l===e?`L${l}`:`L${l}-L${e}`}function Ae(l,e){return H.relative(e,l).replace(/\\/g,"/")}function ue(l,e){if(!l)return e;try{return JSON.parse(l)}catch{return e}}function K(l,e){let t=l.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 dt(l,e){let t=l.toLowerCase(),n=e.toLowerCase();if(t===n)return 100;if(n.includes(t)||t.includes(n))return 85;let r=_e(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 Q(l){return l.startsWith("use")&&l.length>3&&/[A-Z]/.test(l[3])}function ut(l,e,t){if(t===0||t>3)return;let n=A(l).split(" "),r=A(e).split(" ");for(let s of n)for(let o of r){let i=_e(s,o);if(i>0&&i<=3&&s!==o)return `"${s}" \u53EF\u80FD\u662F "${o}" \u7684\u62FC\u5199\u9519\u8BEF (\u7F16\u8F91\u8DDD\u79BB=${i})`}}var J=z(()=>{w();});var Be,Ke,ft,Ve,Xe,mt,gt,ht,ze,Je,Ge,yt,xe,bt,Et,Nt,G=z(()=>{w();Be=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**","**/.nuxt/**","**/.next/**","**/__tests__/**","**/*.test.*","**/*.spec.*","**/*.min.js"],Ke=["**/*.vue","**/*.js","**/*.jsx","**/*.ts","**/*.tsx"],ft={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"]}},Ve=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","activated","deactivated","errorCaptured"],Xe=["onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","onActivated","onDeactivated","onErrorCaptured","onRenderTracked","onRenderTriggered","onServerPrefetch"],mt=["ref","reactive","shallowRef","shallowReactive","readonly"],gt=["computed"],ht=["watch","watchEffect","watchPostEffect","watchSyncEffect"],ze=["useState","useReducer","useRef","useImperativeHandle"],Je=["useMemo","useCallback"],Ge=["useEffect","useLayoutEffect","useInsertionEffect"],yt=["useContext","useDebugValue","useDeferredValue","useId","useSyncExternalStore","useTransition"],xe=".skimmer-index.db",bt=30,Et=4,Nt=300;});function U(l,e,t,n=false){let r=[];return j(l,o=>{if(n&&o!==l&&(o.type==="FunctionDeclaration"||o.type==="ArrowFunctionExpression"||o.type==="FunctionExpression"||o.type==="ClassDeclaration"))return false;if(o.type==="CallExpression"){let c=ln(o,e);c&&r.push(c);}if(o.type==="MemberExpression"){let i=pn(o);i&&r.push(i);}}),hn(r)}function ln(l,e,t){let n=l.callee;if(!n)return null;let r=ve(l);if(n.type==="MemberExpression"){let s=dn(n);if(!s)return null;let{apiName:o,operation:i}=s,c=l.arguments,a=V(c?.[0]),u=mn(o);return u?{symbolName:e,category:u,apiName:o,operation:i,detail:a,line:r}:o==="this"&&Re(i)?{symbolName:e,category:"network",apiName:`this.${i}`,operation:"wrapped_call",detail:a||V(c?.[1]),line:r}:St(i)&&gn(c)?{symbolName:e,category:"network",apiName:o,operation:i,detail:a||V(c?.[1]),line:r}:Re(o)||Re(`${o}.${i}`)?{symbolName:e,category:"network",apiName:o,operation:St(i)?i:"wrapped_call",detail:a||V(c?.[1]),line:r}:null}if(n.type==="Identifier"){let s=n.name,o=un(s),i=l.arguments,c=V(i?.[0]);return o?{symbolName:e,category:o.category,apiName:s,operation:o.operation,detail:c,line:r}:Re(s)?{symbolName:e,category:"network",apiName:s,operation:"wrapped_call",detail:c||V(i?.[1]),line:r}:null}return null}function pn(l,e,t){let n=l.object,r=l.property;if(!n||!r||n.type!=="MemberExpression"&&n.type!=="ThisExpression"&&n.type!=="Identifier")return null;let s=fn(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 dn(l){let e=l.object,t=l.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 un(l){let e={fetch:"network",setTimeout:"timer",setInterval:"timer",clearTimeout:"timer",clearInterval:"timer",requestAnimationFrame:"timer",navigate:"router"};return e[l]?{category:e[l],operation:l}:null}function ve(l){return l.loc?.start?.line??0}function fn(l){return l.type==="Identifier"?l.name:l.type==="ThisExpression"?"this":null}function mn(l){if(l==="this")return null;for(let[e,t]of Object.entries(ft))if(l in t)return e;return null}function V(l,e){if(l){if(l.type==="Literal"||l.type==="StringLiteral"||l.type==="NumericLiteral"||l.type==="BooleanLiteral")return String(l.value);if(l.type==="NullLiteral")return "null";if(l.type==="TemplateLiteral"){let t=l.quasis,n=l.expressions||[],r=[];for(let o=0;o<t.length;o++){let i=t[o].value?.cooked||"";if(i&&r.push(i),o<n.length){let c=ke(n[o])||"expr";r.push(`\${${c}}`);}}return r.join("")||"${expr}"}if(l.type==="Identifier")return `[\u53D8\u91CF: ${l.name}]`;if(l.type==="ObjectExpression"){let t=l.properties||[],n=["url","uri","path","api","endpoint"];for(let r of t){let s=r.key,o=r.value;if(!s||!o)continue;let i=s.type==="Identifier"?String(s.name):s.type==="Literal"?String(s.value):"";if(!n.includes(i))continue;let c=V(o);if(c)return `${i}:${c}`}return "{...}"}}}function ke(l,e){if(!l)return;if(l.type==="Identifier")return l.name;if(l.type==="ThisExpression")return "this";if(l.type==="Literal"||l.type==="StringLiteral"||l.type==="NumericLiteral"||l.type==="BooleanLiteral")return String(l.value);if(l.type==="NullLiteral")return "null";if(l.type==="MemberExpression"){let n=ke(l.object)||"obj",r=l.property,s=r?.type==="Identifier"?String(r.name):ke(r)||"prop";return l.computed?`${n}[${s}]`:`${n}.${s}`}if(l.type==="CallExpression")return `${ke(l.callee)||"fn"}(...)`;if(l.type==="TemplateLiteral")return V(l);let t=V(l);return t?.startsWith("[\u53D8\u91CF: ")?t.replace(/^\[变量: /,"").replace(/\]$/,""):t}function Re(l){return /request|api|http|fetch|ajax|akscommonhandle|commonhandle/i.test(l)}function St(l){return ["get","post","put","delete","patch","request"].includes(l.toLowerCase())}function gn(l,e){if(!l||l.length===0)return false;for(let t of l.slice(0,2)){let n=V(t);if(n&&(/https?:\/\//i.test(n)||n.includes("/")||/gw\d?\/|\/m\/|\/api\//i.test(n)))return true}return false}function hn(l){let e=new Set;return l.filter(t=>{let n=`${t.apiName}:${t.operation}:${t.line}`;return e.has(n)?false:(e.add(n),true)})}function Le(l,e,t){let n=[];return j(l,r=>{if(r.type==="CallExpression"&&r.callee?.type==="MemberExpression"){let s=r.callee,o=s.object,i=s.property;if(o.type==="ThisExpression"&&i.type==="Identifier"){let c=i.name;if(!c.startsWith("$")&&c!==e){let a=r.arguments,u=_t(a);n.push({calleeName:c,line:ve(r),args:u});}}}}),n}function q(l,e,t,n=false){let r=[];return j(l,o=>{if(n&&o!==l&&(o.type==="FunctionDeclaration"||o.type==="ArrowFunctionExpression"||o.type==="FunctionExpression"||o.type==="ClassDeclaration"))return false;if(o.type==="CallExpression"&&o.callee?.type==="Identifier"){let i=o.callee.name;if(i!==e&&!yn(i)){let c=o.arguments,a=_t(c);r.push({calleeName:i,line:ve(o),args:a});}}}),r}function yn(l){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(l)}function _t(l,e){if(!l||l.length===0)return;let t=l.slice(0,3).map(n=>V(n)).filter(n=>!!n);return t.length>0?t.join(", "):void 0}function j(l,e){if(!(!l||typeof l!="object")&&e(l)!==false)for(let t of Object.keys(l)){if(t==="type"||t==="loc"||t==="start"||t==="end")continue;let n=l[t];if(Array.isArray(n))for(let r of n)r&&typeof r=="object"&&r.type&&j(r,e);else n&&typeof n=="object"&&n.type&&j(n,e);}}function we(l,e){let t=[],n=new Set,r=l.split(`
5
+ `);for(let s=0;s<r.length;s++){let o=/(?:@|v-on:)[a-z][a-z0-9-]*(?:\.[a-z-]+)*="([^"]+)"/g,i;for(;(i=o.exec(r[s]))!==null;){let a=i[1].trim().match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)(?:\([^)]*\))?$/);if(!a)continue;let u=a[1];u.startsWith("$")||n.has(u)||(n.add(u),t.push({calleeName:u,line:e+s}));}}return t}function At(l,e){let t=[],n=new Set;return j(l,r=>{if(r.type!=="JSXAttribute")return;let s=r.name,o=r.value;if(!s||!o)return;let i=s.type==="JSXIdentifier"?String(s.name):"";if(!/^on[A-Z]/.test(i)||o.type!=="JSXExpressionContainer")return;let c=o.expression;if(!c)return;let a;if(c.type==="Identifier")a=c.name;else if(c.type==="MemberExpression"){let u=c.property?.name;u&&!/^\$/.test(u)&&(a=u);}!a||n.has(a)||(n.add(a),t.push({calleeName:a,line:ve(r)}));}),t}var Ce=z(()=>{w();G();});var xt,le,qe=z(()=>{w();G();Ce();J();xt=createRequire(import.meta.url),le=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=xt("vue-template-compiler").parseComponent(t);if(!s.script?.content)return n;let o=s.script.content,i=this.getScriptStartLine(t,s.script.start),c=t.split(`
6
+ `),a;try{a=xt("@babel/parser").parse(o,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy"],errorRecovery:!0});}catch(u){return n.errors?.push(`AST \u89E3\u6790\u5931\u8D25: ${String(u)}`),n}if(this.extractFromAST(a.program,o,c,i,n),s.template?.content){let u=this.getScriptStartLine(t,s.template.start),d=we(s.template.content,u);if(d.length>0){let p=s.template.content.split(`
7
+ `).length;n.symbols.push({name:"<template>",category:"lifecycle",framework:"vue2",startLine:u,endLine:u+p-1,camelWords:"template"});for(let f of d)n.relations.push({callerName:"<template>",callerLine:u,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]===`
8
+ `&&n++;return n}extractFromAST(e,t,n,r,s){let o=t.split(`
9
+ `),i=null;j(e,d=>{if(d.type==="ExportDefaultDeclaration"){let p=d.declaration;if(p?.type==="ObjectExpression")i=p;else if(p?.type==="CallExpression"){let f=p.arguments;f&&f.length>0&&f[0].type==="ObjectExpression"&&(i=f[0]);}else if(p?.type==="Identifier"){let f=p.name;j(e,m=>{if(m.type==="VariableDeclarator"&&m.id?.name===f){if(m.init?.type==="ObjectExpression")i=m.init;else if(m.init?.type==="CallExpression"){let g=m.init.arguments;g&&g.length>0&&g[0].type==="ObjectExpression"&&(i=g[0]);}}});}}});let a=false;if(!i&&(j(e,d=>{d.type==="ExportDefaultDeclaration"&&d.declaration?.type==="ClassDeclaration"&&(a=true,this.extractFromClassComponent(d.declaration,t,n,r,s));}),!a)){let d=null,p=0,f=["data","methods","computed","props","watch","components","created","mounted","mixins"];j(e,m=>{if(m.type==="ObjectExpression"){let g=m.properties||[],h=0;for(let N of g){let y=this.getPropKey(N);y&&f.includes(y)&&h++;}h>p&&(p=h,d=m);}}),p>=2&&d&&(i=d);}if(!i)return;let u=i.properties;for(let d of u||[]){let p=this.getPropKey(d);if(!p)continue;let f=d.type==="ObjectMethod"?d:d.value;if(!f)continue;let m=g=>g+r-1;switch(p){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(Ve.includes(p)){let g=m(this.getStartLine(d)),h=m(this.getEndLine(d)),N=K(n.join(`
10
+ `),g),y=s.symbols.length;s.symbols.push({name:p,category:"lifecycle",framework:"vue2",startLine:g,endLine:h,jsdoc:N,camelWords:A(p)});let b=U(f,p);s.behaviors.push(...b);let S=Le(f,p);for(let v of S){if(v.args){let T=String(v.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[y].camelWords+=` ${A(T)} ${T}`;}s.relations.push({callerName:p,callerLine:g,calleeName:v.calleeName,callType:"this_method",line:m(v.line),args:v.args});}}break}}}extractData(e,t,n,r){let s=null;if(e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"||e.type==="ObjectMethod"?j(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 i=this.getPropKey(o);if(!i)continue;let c=n(this.getStartLine(o)),a=n(this.getEndLine(o)),u=this.getLiteralValue(o.value);r.symbols.push({name:i,category:"state",framework:"vue2",startLine:c,endLine:a,defaultValue:u,camelWords:A(i)});}}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:A(o)});}}else if(e.type==="ObjectExpression")for(let s of e.properties||[]){let o=this.getPropKey(s);if(!o)continue;let i=n(this.getStartLine(s)),c=n(this.getEndLine(s)),a;if(s.value?.type==="ObjectExpression"){let u=s.value.properties?.find(d=>this.getPropKey(d)==="default");u&&(a=this.getLiteralValue(u.value));}r.symbols.push({name:o,category:"prop",framework:"vue2",startLine:i,endLine:c,defaultValue:a,camelWords:A(o)});}}extractComputedOrMethods(e,t,n,r,s,o){if(e.type==="ObjectExpression")for(let i of e.properties||[]){let c=this.getPropKey(i);if(!c)continue;let a=i.type==="ObjectMethod"?i:i.value;if(!a)continue;let u=r(this.getStartLine(i)),d=r(this.getEndLine(i)),p=K(s.join(`
11
+ `),u),f=this.extractParams(a),m=a.async===true,g=f?`${c}(${f.join(", ")})`:c;if(o.symbols.push({name:c,category:t,framework:"vue2",startLine:u,endLine:d,signature:g,params:f,isAsync:m,jsdoc:p,camelWords:A(c)}),t==="method"&&a){let h=U(a,c);o.behaviors.push(...h);let N=Le(a,c);for(let y of N){if(y.args){let b=String(y.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");o.symbols[o.symbols.length-1].camelWords+=` ${A(b)} ${b}`;}o.relations.push({callerName:c,callerLine:u,calleeName:y.calleeName,callType:"this_method",line:r(y.line),args:y.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 i=n(this.getStartLine(s)),c=n(this.getEndLine(s));r.symbols.push({name:o,category:"effect",framework:"vue2",startLine:i,endLine:c,camelWords:A(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:A(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:A(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,i=e.body;if(!(!i||i.type!=="ClassBody"))for(let c of i.body||[]){let a=this.getPropKey(c);if(!a)continue;let u=o(this.getStartLine(c)),d=o(this.getEndLine(c)),p=K(n.join(`
12
+ `),u);if(c.type==="ClassMethod"){let m=Ve.includes(a)?"lifecycle":"method",g=this.extractParams(c),h=c.async===true,N=g?`${a}(${g.join(", ")})`:a;s.symbols.push({name:a,category:m,framework:"vue2",startLine:u,endLine:d,signature:N,params:g,isAsync:h,jsdoc:p,camelWords:A(a)});let y=U(c,a);s.behaviors.push(...y);let b=Le(c,a);for(let S of b){if(S.args){let v=String(S.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[s.symbols.length-1].camelWords+=` ${A(v)} ${v}`;}s.relations.push({callerName:a,callerLine:u,calleeName:S.calleeName,callType:"this_method",line:o(S.line),args:S.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:a,category:f?"prop":"state",framework:"vue2",startLine:u,endLine:d,defaultValue:m,camelWords:A(a)});}}}};});var Ze,Pe,$t=z(()=>{w();G();Ce();J();qe();Ze=createRequire(import.meta.url),Pe=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}=Ze("@vue/compiler-sfc"),{descriptor:s}=r(t),o=t.split(`
13
+ `),i=!!s.scriptSetup,c=!!s.script;if(i){let a=s.scriptSetup,u=a.loc.start.line;this.parseSetupContent(a.content,u,o,n);}else if(c){let a=s.script,u=a.loc.start.line;this.parseScriptContent(a.content,u,o,n)||this.populateFromOptionsApiFallback(e,t,n);}if(s.template?.content){let a=s.template.loc.start.line,u=we(s.template.content,a);if(u.length>0){let d=s.template.content.split(`
14
+ `).length;n.symbols.push({name:"<template>",category:"lifecycle",framework:"vue3",startLine:a,endLine:a+d-1,camelWords:"template"});for(let p of u)n.relations.push({callerName:"<template>",callerLine:a,calleeName:p.calleeName,callType:"template_event",line:p.line});}}}catch(r){n.errors?.push(`Vue3 \u89E3\u6790\u5931\u8D25: ${String(r)}`);}return n}parseSetupContent(e,t,n,r){let s;try{s=Ze("@babel/parser").parse(e,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"],errorRecovery:!0});}catch(a){r.errors?.push(`AST \u89E3\u6790\u5931\u8D25: ${String(a)}`);return}let o=a=>a+t-1,i=e.split(`
15
+ `),c=s.program.body;for(let a of c||[])this.processTopLevelStatement(a,o,n,i,r);}parseScriptContent(e,t,n,r){let s;try{s=Ze("@babel/parser").parse(e,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"],errorRecovery:!0});}catch(a){return r.errors?.push(`AST \u89E3\u6790\u5931\u8D25: ${String(a)}`),false}let o=a=>a+t-1,i=e.split(`
16
+ `),c=false;return j(s.program,a=>{if(a.type==="ExportDefaultDeclaration"&&a.declaration?.type==="ObjectExpression"){let u=a.declaration.properties?.find(d=>this.getPropKey(d)==="setup");if(u){c=true;let d=u.type==="ObjectMethod"?u:u.value;if(!d)return;let p=d.body;if(p?.type==="BlockStatement"){let f=p.body;for(let m of f||[])this.processTopLevelStatement(m,o,n,i,r);}}}}),c||j(s.program,a=>{if(!c&&a.type==="ObjectExpression"){let d=(a.properties||[]).find(p=>this.getPropKey(p)==="setup");if(d){c=true;let p=d.type==="ObjectMethod"?d:d.value;if(!p)return;let f=p.body;if(f?.type==="BlockStatement"){let m=f.body;for(let g of m||[])this.processTopLevelStatement(g,o,n,i,r);}}}}),c}processTopLevelStatement(e,t,n,r,s){let o=i=>{let c=i?.loc;return {start:c?.start?.line??1,end:c?.end?.line??1}};if(e.type==="VariableDeclaration")for(let i of e.declarations||[]){if(i.id?.type!=="Identifier"&&i.id?.type!=="ArrayPattern")continue;let c=i.init;if(c&&i.id.type==="Identifier"){let a=i.id.name;if(c.type==="ArrowFunctionExpression"||c.type==="FunctionExpression"){let{start:u,end:d}=o(e),p=K(n.join(`
17
+ `),t(u)),f=this.extractParams(c),m=s.symbols.length;if(s.symbols.push({name:a,category:"method",framework:"vue3",startLine:t(u),endLine:t(d),signature:`${a}(${(f||[]).join(", ")})`,params:f,isAsync:c.async===true,jsdoc:p,camelWords:A(a)}),c.body){let g=U(c.body,a);s.behaviors.push(...g);let h=q(c.body,a);for(let N of h){if(N.args){let y=String(N.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[m].camelWords+=` ${A(y)} ${y}`;}s.relations.push({callerName:a,callerLine:t(u),calleeName:N.calleeName,callType:"direct_call",line:t(N.line),args:N.args});}}}else {let u=this.classifyVue3Declaration(a,c,t,o(e),n);u&&s.symbols.push(u);}}}if(e.type==="FunctionDeclaration"&&e.id?.type==="Identifier"){let i=e.id.name,{start:c,end:a}=o(e),u=K(n.join(`
18
+ `),t(c)),d=this.extractParams(e),p=Xe.includes(i);if(s.symbols.push({name:i,category:p?"lifecycle":Q(i)?"hook":"method",framework:"vue3",startLine:t(c),endLine:t(a),signature:`${i}(${(d||[]).join(", ")})`,params:d,isAsync:e.async===true,jsdoc:u,camelWords:A(i)}),e.body){let f=U(e.body,i);s.behaviors.push(...f);let m=q(e.body,i);for(let g of m){if(g.args){let h=String(g.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[s.symbols.length-1].camelWords+=` ${A(h)} ${h}`;}s.relations.push({callerName:i,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 a=c.name;if(["defineProps","defineEmits","defineExpose"].includes(a)){let{start:u,end:d}=o(e);s.symbols.push({name:a,category:a==="defineProps"?"prop":a==="defineEmits"?"emit":"export",framework:"vue3",startLine:t(u),endLine:t(d),camelWords:A(a)});}}}if(e.type==="ExpressionStatement"&&e.expression?.type==="CallExpression"){let i=e.expression,c=i.callee;if(c?.type==="Identifier"){let a=c.name;if(Xe.includes(a)){let{start:u,end:d}=o(e);s.symbols.push({name:a,category:"lifecycle",framework:"vue3",startLine:t(u),endLine:t(d),camelWords:A(a)});let p=i.arguments;if(p?.[0]){let f=U(p[0],a);s.behaviors.push(...f);let m=q(p[0],a);for(let g of m){if(g.args){let h=String(g.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");s.symbols[s.symbols.length-1].camelWords+=` ${A(h)} ${h}`;}s.relations.push({callerName:a,callerLine:t(u),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 i=o.name,c=n(r.start),a=n(r.end),u=K(s.join(`
19
+ `),c);if(mt.includes(i)){let d=t.arguments,p=d?.[0]?this.getLiteralValue(d[0]):void 0;return {name:e,category:"state",framework:"vue3",startLine:c,endLine:a,defaultValue:p,jsdoc:u,camelWords:A(e)}}return gt.includes(i)?{name:e,category:"computed",framework:"vue3",startLine:c,endLine:a,jsdoc:u,camelWords:A(e)}:ht.includes(i)?{name:e,category:"effect",framework:"vue3",startLine:c,endLine:a,camelWords:A(e)}:i==="provide"||i==="inject"?{name:e,category:"provide",framework:"vue3",startLine:c,endLine:a,camelWords:A(e)}:Q(i)?{name:e,category:"hook",framework:"vue3",startLine:c,endLine:a,jsdoc:u,camelWords:A(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 le().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 Sn,_n,fe,Tt=z(()=>{w();G();Ce();J();Sn=createRequire(import.meta.url),_n=[...ze,...Je,...Ge,...yt],fe=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"):false}parse(e,t){let n={framework:"react",filePath:e,symbols:[],relations:[],behaviors:[],errors:[]};try{let s=Sn("@babel/parser").parse(t,{sourceType:"module",plugins:["jsx","typescript","decorators-legacy"],errorRecovery:!0}),o=t.split(`
20
+ `);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;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;o&&o.id?.type==="Identifier"&&this.processFunction(o,t,n);}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;if(o)for(let i of o.declarations||[]){let c=i.init;if(c&&(c.type==="ArrowFunctionExpression"||c.type==="FunctionExpression")&&i.id?.type==="Identifier"){let a={...c,id:i.id,loc:{start:o.loc?.start??c.loc?.start,end:c.loc?.end}};this.processFunction(a,t,n);}}}}}processFunction(e,t,n){let r=e.id?.name;if(!r)return;let s=e.loc,o=s?.start?.line??1,i=s?.end?.line??1,c=Q(r),a=!c&&/^[A-Z]/.test(r),u=K(t.join(`
21
+ `),o),d=this.extractParams(e),p=this.buildSymbolKey(r,o,i);n.symbols.push({name:r,category:c?"hook":a?"component":"function",framework:"react",startLine:o,endLine:i,internalKey:p,signature:`${r}(${(d||[]).join(", ")})`,params:d,isAsync:e.async===true,jsdoc:u,parentComponent:a?r:void 0,camelWords:A(r)});let f=e.body;if(f?.type!=="BlockStatement")return;let m=f.body;for(let y of m||[])this.processComponentStatement(y,r,t,n);let g=U(f,r,t,true);n.behaviors.push(...g);let h=q(f,r,t,true);for(let y of h){let b=n.symbols.findIndex(S=>S.name===r&&S.startLine===o);if(y.args&&b!==-1){let S=String(y.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");n.symbols[b].camelWords+=` ${A(S)} ${S}`;}n.relations.push({callerName:r,callerLine:o,callerKey:p,calleeName:y.calleeName,callType:"direct_call",line:y.line,args:y.args});}let N=At(f);for(let y of N)n.relations.push({callerName:r,callerLine:o,callerKey:p,calleeName:y.calleeName,callType:"jsx_event",line:y.line});}processComponentStatement(e,t,n,r){let s=o=>{let i=o?.loc;return {start:i?.start?.line??1,end:i?.end?.line??1}};if(e.type==="VariableDeclaration")for(let o of e.declarations||[]){let i=o.init;if(!i||i.type!=="CallExpression")continue;let c=i.callee;if(c?.type!=="Identifier")continue;let a=c.name,{start:u,end:d}=s(e),p=u,f=d;if(ze.includes(a)&&a!=="useRef"){if(o.id?.type==="ArrayPattern"){let m=o.id.elements,g=m[0]?.name,h=m[1]?.name;if(g){let N=i.arguments;r.symbols.push({name:g,category:"state",framework:"react",startLine:p,endLine:f,internalKey:this.buildSymbolKey(g,p,f,t),stateSetterName:h,defaultValue:this.getLiteralValue(N?.[0]),parentComponent:t,camelWords:A(g)});}}else if(o.id?.type==="Identifier"){let m=o.id.name;r.symbols.push({name:m,category:"state",framework:"react",startLine:p,endLine:f,internalKey:this.buildSymbolKey(m,p,f,t),parentComponent:t,camelWords:A(m)});}}if(a==="useRef"&&o.id?.type==="Identifier"){let m=o.id.name,g=i.arguments;r.symbols.push({name:m,category:"state",framework:"react",startLine:p,endLine:f,internalKey:this.buildSymbolKey(m,p,f,t),defaultValue:this.getLiteralValue(g?.[0]),parentComponent:t,camelWords:A(m)});}if(Je.includes(a)&&o.id?.type==="Identifier"){let m=o.id.name,h=i.arguments?.[1],N=this.extractDepsArray(h);r.symbols.push({name:m,category:"computed",framework:"react",startLine:p,endLine:f,internalKey:this.buildSymbolKey(m,p,f,t),hookDeps:N,parentComponent:t,camelWords:A(m)});}if(Q(a)&&!_n.includes(a)){let m=o.id?.type==="Identifier"?o.id.name:o.id?.type==="ObjectPattern"?"{...}":"?";r.symbols.push({name:m,category:"hook",framework:"react",startLine:p,endLine:f,internalKey:this.buildSymbolKey(m,p,f,t),parentComponent:t,camelWords:A(m)});}}if(e.type==="ExpressionStatement"&&e.expression?.type==="CallExpression"){let o=e.expression,i=o.callee;if(i?.type==="Identifier"){let c=i.name;if(Ge.includes(c)){let{start:a,end:u}=s(e),d=o.arguments,p=d?.[1],f=this.extractDepsArray(p),m=this.buildSymbolKey(c,a,u,t),g=`${t}.${c}`;if(r.symbols.push({name:c,category:"effect",framework:"react",startLine:a,endLine:u,internalKey:m,hookDeps:f,parentComponent:t,camelWords:A(c)}),d?.[0]){let h=U(d[0],g,n,true).map(y=>({...y,symbolKey:m}));r.behaviors.push(...h);let N=q(d[0],g,n,true);for(let y of N){let b=r.symbols.findIndex(S=>S.name===c&&S.startLine===a);if(y.args&&b!==-1){let S=String(y.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");r.symbols[b].camelWords+=` ${A(S)} ${S}`;}r.relations.push({callerName:g,callerLine:a,callerKey:m,calleeName:y.calleeName,callType:"direct_call",line:y.line,args:y.args});}}}}}if(e.type==="FunctionDeclaration"&&e.id?.type==="Identifier"){let o=e.id.name;if(!Q(o)){let{start:i,end:c}=s(e),a=K(n.join(`
22
+ `),i),u=this.extractParams(e);if(r.symbols.push({name:o,category:"method",framework:"react",startLine:i,endLine:c,internalKey:this.buildSymbolKey(o,i,c,t),signature:`${o}(${(u||[]).join(", ")})`,params:u,isAsync:e.async===true,jsdoc:a,parentComponent:t,camelWords:A(o)}),e.body){let d=U(e.body,o,n,true);r.behaviors.push(...d);let p=q(e.body,o,n,true);for(let f of p){let m=r.symbols.findIndex(g=>g.name===o&&g.startLine===i);if(f.args&&m!==-1){let g=String(f.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");r.symbols[m].camelWords+=` ${A(g)} ${g}`;}r.relations.push({callerName:o,callerLine:i,callerKey:this.buildSymbolKey(o,i,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 i=o.init;if(!i)continue;let c=i.type==="ArrowFunctionExpression"||i.type==="FunctionExpression";if(!c||o.id?.type!=="Identifier")continue;let a=o.id.name,u=i.type==="CallExpression"?i.callee:null;if(u?.type==="Identifier"&&Q(u.name))continue;if(i.type==="CallExpression"&&i.callee?.name==="useCallback"){let N=i.arguments?.[1],y=this.extractDepsArray(N),{start:b,end:S}=s(e);r.symbols.push({name:a,category:"computed",framework:"react",startLine:b,endLine:S,internalKey:this.buildSymbolKey(a,b,S,t),hookDeps:y,parentComponent:t,camelWords:A(a)});continue}if(!c)continue;let{start:p,end:f}=s(e),m=K(n.join(`
23
+ `),p),g=this.extractParams(i);if(r.symbols.push({name:a,category:"method",framework:"react",startLine:p,endLine:f,internalKey:this.buildSymbolKey(a,p,f,t),signature:`${a}(${(g||[]).join(", ")})`,params:g,isAsync:i.async===true,jsdoc:m,parentComponent:t,camelWords:A(a)}),i.body){let h=U(i.body,a,n,true);r.behaviors.push(...h);let N=q(i.body,a,n,true);for(let y of N){let b=r.symbols.findIndex(S=>S.name===a&&S.startLine===p);if(y.args&&b!==-1){let S=String(y.args).replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]/g," ");r.symbols[b].camelWords+=` ${A(S)} ${S}`;}r.relations.push({callerName:a,callerLine:p,callerKey:this.buildSymbolKey(a,p,f,t),calleeName:y.calleeName,callType:"direct_call",line:y.line,args:y.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}`}};});function Rt(l,e){for(let t of An)if(t.canParse(l,e)){let n=t.parse(l,e);return xn(n),n}return {framework:"js",filePath:l,symbols:[],relations:[],behaviors:[],errors:[`\u6CA1\u6709\u627E\u5230\u9002\u5408\u7684\u89E3\u6790\u5668: ${l}`]}}function xn(l){if(!l.relations.length||!l.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(l.behaviors.filter(r=>r.category==="network").map(r=>r.symbolName));if(t.size===0)return;let n=new Set(l.behaviors.map(r=>`${r.symbolName}:${r.category}:${r.apiName}:${r.operation}:${r.line}`));for(let r of l.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),l.behaviors.push(s));}}var Qe,An,kt=z(()=>{w();qe();$t();Tt();Qe=class extends fe{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}},An=[new Pe,new le,new fe,new Qe];});var vt={};Zt(vt,{Indexer:()=>me});var me,et=z(()=>{w();kt();J();G();me=class{projectRoot;db;constructor(e,t){this.projectRoot=e,this.db=t;}async indexProject(e){let t=Date.now(),n=e?.include||[...Ke],r=e?.exclude||[...Be],s=e?.force||false,o=await Rn(n,{cwd:this.projectRoot,ignore:r,absolute:true,onlyFiles:true}),i={totalFiles:o.length,indexedFiles:0,skippedFiles:0,totalSymbols:0,durationMs:0,errors:[]};for(let c=0;c<o.length;c++){let a=o[c],u=Ae(a,this.projectRoot);e?.onProgress?.(c+1,o.length,u);try{let d=await this.indexFile(a,u,s);d.skipped?i.skippedFiles++:(i.indexedFiles++,i.totalSymbols+=d.symbolCount,d.errors?.length&&i.errors.push(...d.errors.map(p=>({file:u,error:p}))));}catch(d){i.errors.push({file:u,error:String(d)});}}return i.durationMs=Date.now()-t,i}async indexFile(e,t,n=false){let r=W.readFileSync(e,"utf-8"),s=lt(r);if(!n&&this.db.getFileHash(t)===s)return {skipped:true,symbolCount:0};let o=pt(r),i=Buffer.byteLength(r,"utf-8"),c=Rt(e,r);return this.db.saveParseResult(c,e,t,s,i,o),{skipped:false,symbolCount:c.symbols.length,errors:c.errors}}removeFile(e){this.db.deleteFile(e);}async startWatcher(){let{default:e}=await import('chokidar'),t=e.watch([...Ke].map(r=>H.posix.join(this.projectRoot,r)),{cwd:this.projectRoot,ignored:[...Be],persistent:true,ignoreInitial:true,awaitWriteFinish:{stabilityThreshold:Nt}}),n=async r=>{let s=Ae(r,this.projectRoot);try{await this.indexFile(r,s),process.stderr.write(`[Frontend-Code-Skimmer] \u5DF2\u66F4\u65B0\u7D22\u5F15: ${s}
21
24
  `);}catch(o){process.stderr.write(`[Frontend-Code-Skimmer] \u66F4\u65B0\u5931\u8D25: ${s} - ${String(o)}
22
- `);}};return t.on("add",r).on("change",r).on("unlink",n=>{let s=ye(n,this.projectRoot);this.removeFile(s),process.stderr.write(`[Frontend-Code-Skimmer] \u5DF2\u5220\u9664\u7D22\u5F15: ${s}
23
- `);}),()=>t.close()}};});$();$();$();X();z();var Ee=class{db;constructor(e,t){let r=t||D.join(e,be);K.mkdirSync(D.dirname(r),{recursive:true}),this.db=new Ft(r),this.initialize();}initialize(){this.db.pragma("journal_mode = WAL"),this.db.pragma("foreign_keys = ON"),this.db.pragma("synchronous = NORMAL"),this.db.exec(`
25
+ `);}};return t.on("add",n).on("change",n).on("unlink",r=>{let s=Ae(r,this.projectRoot);this.removeFile(s),process.stderr.write(`[Frontend-Code-Skimmer] \u5DF2\u5220\u9664\u7D22\u5F15: ${s}
26
+ `);}),()=>t.close()}};});w();w();w();J();G();var $e=class{db;constructor(e,t){let n=t||H.join(e,xe);W.mkdirSync(H.dirname(n),{recursive:true}),this.db=new tn(n),this.initialize();}initialize(){this.db.pragma("journal_mode = WAL"),this.db.pragma("foreign_keys = ON"),this.db.pragma("synchronous = NORMAL"),this.db.exec(`
24
27
  -- \u6587\u4EF6\u5143\u4FE1\u606F
25
28
  CREATE TABLE IF NOT EXISTS files (
26
29
  id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -146,58 +149,58 @@ import D from'path';import'url';import Ot from'crypto';import {createRequire}fro
146
149
  INSERT INTO relations_fts(rowid, args)
147
150
  VALUES (new.id, new.args);
148
151
  END;
149
- `);try{this.db.exec("ALTER TABLE relations ADD COLUMN args TEXT;");}catch{}try{this.db.prepare("SELECT 1 FROM relations_fts LIMIT 1").get()||this.db.exec("INSERT OR IGNORE INTO relations_fts(rowid, args) SELECT id, args FROM relations WHERE args IS NOT NULL;");}catch{}}saveParseResult(e,t,r,n,s,o){let i=D.extname(t).slice(1);this.db.transaction(()=>{let c=this.db.prepare("SELECT id FROM files WHERE path = ?").get(r),f;c?(f=c.id,this.db.prepare("DELETE FROM symbols WHERE file_id = ?").run(f),this.db.prepare(`
152
+ `);try{this.db.exec("ALTER TABLE relations ADD COLUMN args TEXT;");}catch{}try{this.db.prepare("SELECT 1 FROM relations_fts LIMIT 1").get()||this.db.exec("INSERT OR IGNORE INTO relations_fts(rowid, args) SELECT id, args FROM relations WHERE args IS NOT NULL;");}catch{}}saveParseResult(e,t,n,r,s,o){let i=H.extname(t).slice(1);this.db.transaction(()=>{let a=this.db.prepare("SELECT id FROM files WHERE path = ?").get(n),u;a?(u=a.id,this.db.prepare("DELETE FROM symbols WHERE file_id = ?").run(u),this.db.prepare(`
150
153
  UPDATE files SET
151
154
  abs_path = ?, framework = ?, content_hash = ?,
152
155
  last_indexed_at = ?, file_size = ?, line_count = ?
153
156
  WHERE id = ?
154
- `).run(t,e.framework,n,Date.now(),s,o,f)):f=this.db.prepare(`
157
+ `).run(t,e.framework,r,Date.now(),s,o,u)):u=this.db.prepare(`
155
158
  INSERT INTO files (path, abs_path, file_type, framework, content_hash, last_indexed_at, file_size, line_count)
156
159
  VALUES (?, ?, ?, ?, ?, ?, ?, ?)
157
- `).run(r,t,i,e.framework,n,Date.now(),s,o).lastInsertRowid;let d=this.db.prepare(`
160
+ `).run(n,t,i,e.framework,r,Date.now(),s,o).lastInsertRowid;let d=this.db.prepare(`
158
161
  INSERT INTO symbols (file_id, name, category, framework, start_line, end_line,
159
162
  signature, params_json, default_value, camel_words, jsdoc,
160
163
  is_async, hook_deps_json, state_setter_name, parent_component)
161
164
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
162
- `),p=new Map,u=new Map,g=h=>h.internalKey||`${h.name}:${h.startLine}:${h.endLine}`,m=(h,b)=>{p.set(g(h),b);let T=u.get(h.name)||[];T.push({id:b,name:h.name,startLine:h.startLine,endLine:h.endLine}),u.set(h.name,T);},E=(h,b,T)=>{if(T&&p.has(T))return p.get(T);let v=u.get(h)||[];if(v.length===0)return;if(v.length===1||b==null)return v[0]?.id;let W=v.filter(P=>P.startLine<=b&&b<=P.endLine);return W.length===1?W[0].id:W.length>1?W.sort((P,H)=>P.endLine-P.startLine-(H.endLine-H.startLine)||Math.abs(P.startLine-b)-Math.abs(H.startLine-b))[0]?.id:v.slice().sort((P,H)=>Math.abs(P.startLine-b)-Math.abs(H.startLine-b)||P.endLine-P.startLine-(H.endLine-H.startLine))[0]?.id};for(let h of e.symbols){let T=h.camelWords||A(h.name),v=d.run(f,h.name,h.category,h.framework,h.startLine,h.endLine,h.signature||null,h.params?JSON.stringify(h.params):null,h.defaultValue||null,T,h.jsdoc||null,h.isAsync?1:0,h.hookDeps?JSON.stringify(h.hookDeps):null,h.stateSetterName||null,h.parentComponent||null);m(h,v.lastInsertRowid);}let N=this.db.prepare(`
165
+ `),p=new Map,f=new Map,m=b=>b.internalKey||`${b.name}:${b.startLine}:${b.endLine}`,g=(b,S)=>{p.set(m(b),S);let v=f.get(b.name)||[];v.push({id:S,name:b.name,startLine:b.startLine,endLine:b.endLine}),f.set(b.name,v);},h=(b,S,v)=>{if(v&&p.has(v))return p.get(v);let T=f.get(b)||[];if(T.length===0)return;if(T.length===1||S==null)return T[0]?.id;let P=T.filter(I=>I.startLine<=S&&S<=I.endLine);return P.length===1?P[0].id:P.length>1?P.sort((I,O)=>I.endLine-I.startLine-(O.endLine-O.startLine)||Math.abs(I.startLine-S)-Math.abs(O.startLine-S))[0]?.id:T.slice().sort((I,O)=>Math.abs(I.startLine-S)-Math.abs(O.startLine-S)||I.endLine-I.startLine-(O.endLine-O.startLine))[0]?.id};for(let b of e.symbols){let v=b.camelWords||A(b.name),T=d.run(u,b.name,b.category,b.framework,b.startLine,b.endLine,b.signature||null,b.params?JSON.stringify(b.params):null,b.defaultValue||null,v,b.jsdoc||null,b.isAsync?1:0,b.hookDeps?JSON.stringify(b.hookDeps):null,b.stateSetterName||null,b.parentComponent||null);g(b,T.lastInsertRowid);}let N=this.db.prepare(`
163
166
  INSERT INTO relations (caller_id, callee_name, call_type, line_number, args)
164
167
  VALUES (?, ?, ?, ?, ?)
165
- `);for(let h of e.relations){let b=E(h.callerName,h.callerLine,h.callerKey);b&&N.run(b,h.calleeName,h.callType,h.line,h.args||null);}let y=this.db.prepare(`
168
+ `);for(let b of e.relations){let S=h(b.callerName,b.callerLine,b.callerKey);S&&N.run(S,b.calleeName,b.callType,b.line,b.args||null);}let y=this.db.prepare(`
166
169
  INSERT INTO behaviors (symbol_id, file_id, category, api_name, operation, detail, line_number)
167
170
  VALUES (?, ?, ?, ?, ?, ?, ?)
168
- `);for(let h of e.behaviors){let b=E(h.symbolName,h.line,h.symbolKey);b&&y.run(b,f,h.category,h.apiName,h.operation,h.detail||null,h.line);}})();}getFileHash(e){return this.db.prepare("SELECT content_hash FROM files WHERE path = ?").get(e)?.content_hash??null}deleteFile(e){this.db.prepare("DELETE FROM files WHERE path = ?").run(e);}getFileOutline(e){let t=this.db.prepare("SELECT * FROM files WHERE path = ?").get(e);if(!t)return {file:void 0,symbols:[],behaviors:[]};let r=t.id,n=this.db.prepare(`
171
+ `);for(let b of e.behaviors){let S=h(b.symbolName,b.line,b.symbolKey);S&&y.run(S,u,b.category,b.apiName,b.operation,b.detail||null,b.line);}})();}getFileHash(e){return this.db.prepare("SELECT content_hash FROM files WHERE path = ?").get(e)?.content_hash??null}deleteFile(e){this.db.prepare("DELETE FROM files WHERE path = ?").run(e);}getFileOutline(e){let t=this.db.prepare("SELECT * FROM files WHERE path = ?").get(e);if(!t)return {file:void 0,symbols:[],behaviors:[]};let n=t.id,r=this.db.prepare(`
169
172
  SELECT s.*, f.path as file_path
170
173
  FROM symbols s JOIN files f ON s.file_id = f.id
171
174
  WHERE s.file_id = ?
172
175
  ORDER BY s.start_line ASC
173
- `).all(r),s=this.db.prepare(`
176
+ `).all(n),s=this.db.prepare(`
174
177
  SELECT b.*, s.name as symbol_name
175
178
  FROM behaviors b JOIN symbols s ON b.symbol_id = s.id
176
179
  WHERE b.file_id = ?
177
- `).all(r);return {file:t,symbols:n,behaviors:s}}listFiles(e){let t="SELECT path, abs_path, framework, line_count FROM files",r=[];return e&&(t+=" WHERE path LIKE ?",r.push(`%${e}%`)),t+=" ORDER BY path",this.db.prepare(t).all(...r)}exactSearch(e,t,r,n){let s=`
180
+ `).all(n);return {file:t,symbols:r,behaviors:s}}listFiles(e){let t="SELECT path, abs_path, framework, line_count FROM files",n=[];return e&&(t+=" WHERE path LIKE ?",n.push(`%${e}%`)),t+=" ORDER BY path",this.db.prepare(t).all(...n)}exactSearch(e,t,n,r){let s=`
178
181
  SELECT s.*, f.path as file_path, f.abs_path
179
182
  FROM symbols s JOIN files f ON s.file_id = f.id
180
183
  WHERE LOWER(s.name) = LOWER(?)
181
- `,o=[e];return t&&(s+=" AND s.category = ?",o.push(t)),r&&(s+=" AND s.framework = ?",o.push(r)),n&&(s+=" AND f.path LIKE ?",o.push(`%${n}%`)),s+=" LIMIT 30",this.db.prepare(s).all(...o)}ftsSearch(e,t,r,n){let s=e.trim().split(/\s+/).map(o=>`${o}*`).join(" ");try{let o=`
184
+ `,o=[e];return t&&(s+=" AND s.category = ?",o.push(t)),n&&(s+=" AND s.framework = ?",o.push(n)),r&&(s+=" AND f.path LIKE ?",o.push(`%${r}%`)),s+=" LIMIT 30",this.db.prepare(s).all(...o)}ftsSearch(e,t,n,r){let s=e.trim().split(/\s+/).map(o=>`${o}*`).join(" ");try{let o=`
182
185
  SELECT s.*, f.path as file_path, f.abs_path,
183
186
  symbols_fts.rank as fts_rank
184
187
  FROM symbols_fts
185
188
  JOIN symbols s ON symbols_fts.rowid = s.id
186
189
  JOIN files f ON s.file_id = f.id
187
190
  WHERE symbols_fts MATCH ?
188
- `,i=[s];return t&&(o+=" AND s.category = ?",i.push(t)),r&&(o+=" AND s.framework = ?",i.push(r)),n&&(o+=" AND f.path LIKE ?",i.push(`%${n}%`)),o+=" ORDER BY symbols_fts.rank LIMIT 20",this.db.prepare(o).all(...i)}catch{return []}}getAllSymbolNames(e){let t=`
191
+ `,i=[s];return t&&(o+=" AND s.category = ?",i.push(t)),n&&(o+=" AND s.framework = ?",i.push(n)),r&&(o+=" AND f.path LIKE ?",i.push(`%${r}%`)),o+=" ORDER BY symbols_fts.rank LIMIT 20",this.db.prepare(o).all(...i)}catch{return []}}getAllSymbolNames(e){let t=`
189
192
  SELECT DISTINCT s.name, f.path as file_path, s.id
190
193
  FROM symbols s JOIN files f ON s.file_id = f.id
191
- `,r=[];return e&&(t+=" WHERE f.path LIKE ?",r.push(`%${e}%`)),this.db.prepare(t).all(...r)}getSymbolById(e){return this.db.prepare(`
194
+ `,n=[];return e&&(t+=" WHERE f.path LIKE ?",n.push(`%${e}%`)),this.db.prepare(t).all(...n)}getSymbolById(e){return this.db.prepare(`
192
195
  SELECT s.*, f.path as file_path, f.abs_path
193
196
  FROM symbols s JOIN files f ON s.file_id = f.id
194
197
  WHERE s.id = ?
195
- `).get(e)}getSymbolByName(e,t){if(t){let n=this.db.prepare(`
198
+ `).get(e)}getSymbolByName(e,t){if(t){let r=this.db.prepare(`
196
199
  SELECT s.*, f.path as file_path, f.abs_path
197
200
  FROM symbols s JOIN files f ON s.file_id = f.id
198
201
  WHERE s.name = ? AND f.path = ?
199
202
  LIMIT 1
200
- `).get(e,t);return n||(n=this.db.prepare(`
203
+ `).get(e,t);return r||(r=this.db.prepare(`
201
204
  SELECT s.*, f.path as file_path, f.abs_path
202
205
  FROM symbols s JOIN files f ON s.file_id = f.id
203
206
  WHERE s.name = ? AND f.path LIKE ?
@@ -213,7 +216,7 @@ import D from'path';import'url';import Ot from'crypto';import {createRequire}fro
213
216
  s.parent_component IS NULL DESC,
214
217
  f.line_count DESC
215
218
  LIMIT 1
216
- `).get(e,`%${t}%`)),n}if(!((this.db.prepare(`
219
+ `).get(e,`%${t}%`)),r}if(!((this.db.prepare(`
217
220
  SELECT COUNT(DISTINCT f.path) as c
218
221
  FROM symbols s JOIN files f ON s.file_id = f.id
219
222
  WHERE s.name = ?
@@ -232,25 +235,25 @@ import D from'path';import'url';import Ot from'crypto';import {createRequire}fro
232
235
  s.parent_component IS NULL DESC,
233
236
  f.line_count DESC
234
237
  LIMIT 1
235
- `).get(e)}behaviorSearch(e,t,r,n,s){let o=`
238
+ `).get(e)}behaviorSearch(e,t,n,r,s){let o=`
236
239
  SELECT b.*, s.name as symbol_name, s.start_line, s.end_line, s.category as symbol_category,
237
240
  f.path as file_path
238
241
  FROM behaviors b
239
242
  JOIN symbols s ON b.symbol_id = s.id
240
243
  JOIN files f ON b.file_id = f.id
241
244
  WHERE 1=1
242
- `,i=[];return e&&(o+=" AND b.category = ?",i.push(e)),t&&(o+=" AND LOWER(b.api_name) = LOWER(?)",i.push(t)),r&&(o+=" AND LOWER(b.operation) = LOWER(?)",i.push(r)),n&&(o+=" AND (LOWER(b.detail) LIKE LOWER(?) OR LOWER(b.api_name) LIKE LOWER(?))",i.push(`%${n}%`,`%${n}%`)),s&&(o+=" AND f.path LIKE ?",i.push(`%${s}%`)),o+=" ORDER BY f.path, b.line_number LIMIT 50",this.db.prepare(o).all(...i)}getCallers(e,t,r){let n=`
245
+ `,i=[];return e&&(o+=" AND b.category = ?",i.push(e)),t&&(o+=" AND LOWER(b.api_name) = LOWER(?)",i.push(t)),n&&(o+=" AND LOWER(b.operation) = LOWER(?)",i.push(n)),r&&(o+=" AND (LOWER(b.detail) LIKE LOWER(?) OR LOWER(b.api_name) LIKE LOWER(?))",i.push(`%${r}%`,`%${r}%`)),s&&(o+=" AND f.path LIKE ?",i.push(`%${s}%`)),o+=" ORDER BY f.path, b.line_number LIMIT 50",this.db.prepare(o).all(...i)}getCallers(e,t,n){let r=`
243
246
  SELECT r.*, s.name as caller_name, s.start_line, s.end_line, s.category,
244
247
  f.path as file_path
245
248
  FROM relations r
246
249
  JOIN symbols s ON r.caller_id = s.id
247
250
  JOIN files f ON s.file_id = f.id
248
251
  WHERE r.callee_name = ?
249
- `,s=[e];return t&&(n+=" AND f.path LIKE ?",s.push(`%${t}%`)),r&&(n+=" AND LOWER(COALESCE(r.args, '')) LIKE LOWER(?)",s.push(`%${r}%`)),n+=" ORDER BY f.path, r.line_number",this.db.prepare(n).all(...s)}getCallees(e){return this.db.prepare(`
252
+ `,s=[e];return t&&(r+=" AND f.path LIKE ?",s.push(`%${t}%`)),n&&(r+=" AND LOWER(COALESCE(r.args, '')) LIKE LOWER(?)",s.push(`%${n}%`)),r+=" ORDER BY f.path, r.line_number",this.db.prepare(r).all(...s)}getCallees(e){return this.db.prepare(`
250
253
  SELECT r.*, r.callee_name
251
254
  FROM relations r
252
255
  WHERE r.caller_id = ?
253
- `).all(e)}findRelationsByArgKeyword(e,t,r=50){let n=e.trim();if(!n)return [];let s=`
256
+ `).all(e)}findRelationsByArgKeyword(e,t,n=50){let r=e.trim();if(!r)return [];let s=`
254
257
  SELECT r.*, s.name as caller_name, s.start_line, s.end_line, s.category,
255
258
  f.path as file_path
256
259
  FROM relations_fts fts
@@ -258,14 +261,14 @@ import D from'path';import'url';import Ot from'crypto';import {createRequire}fro
258
261
  JOIN symbols s ON r.caller_id = s.id
259
262
  JOIN files f ON s.file_id = f.id
260
263
  WHERE fts.args MATCH ?
261
- `,i=[`"${n.replace(/"/g,'""')}"`];t&&(s+=" AND f.path LIKE ?",i.push(`%${t}%`)),s+=" ORDER BY f.path, r.line_number LIMIT ?",i.push(r);let a=[],c=false,f=false;try{a=this.db.prepare(s).all(...i),a.length>0&&(c=!0);}catch{f=true;}let d=/[^a-zA-Z0-9_\u4e00-\u9fa5]/.test(n);if(!c&&(f||d)){let u=n.replace(/[\\%_]/g,"\\$&"),g=`
264
+ `,i=[`"${r.replace(/"/g,'""')}"`];t&&(s+=" AND f.path LIKE ?",i.push(`%${t}%`)),s+=" ORDER BY f.path, r.line_number LIMIT ?",i.push(n);let c=[],a=false,u=false;try{c=this.db.prepare(s).all(...i),c.length>0&&(a=!0);}catch{u=true;}let d=/[^a-zA-Z0-9_\u4e00-\u9fa5]/.test(r);if(!a&&(u||d)){let f=r.replace(/[\\%_]/g,"\\$&"),m=`
262
265
  SELECT r.*, s.name as caller_name, s.start_line, s.end_line, s.category,
263
266
  f.path as file_path
264
267
  FROM relations r
265
268
  JOIN symbols s ON r.caller_id = s.id
266
269
  JOIN files f ON s.file_id = f.id
267
270
  WHERE LOWER(COALESCE(r.args, '')) LIKE LOWER(?) ESCAPE '\\'
268
- `,m=[`%${u}%`];t&&(g+=" AND f.path LIKE ?",m.push(`%${t}%`)),g+=" ORDER BY f.path, r.line_number LIMIT ?",m.push(r),a=this.db.prepare(g).all(...m);}return a}getProjectStats(){let e=this.db.prepare("SELECT COUNT(*) as c FROM files").get().c,t=this.db.prepare("SELECT COUNT(*) as c FROM symbols").get().c,r=this.db.prepare("SELECT COUNT(*) as c FROM behaviors").get().c,n=this.db.prepare("SELECT COUNT(*) as c FROM relations").get().c,s=this.db.prepare(`
271
+ `,g=[`%${f}%`];t&&(m+=" AND f.path LIKE ?",g.push(`%${t}%`)),m+=" ORDER BY f.path, r.line_number LIMIT ?",g.push(n),c=this.db.prepare(m).all(...g);}return c}getProjectStats(){let e=this.db.prepare("SELECT COUNT(*) as c FROM files").get().c,t=this.db.prepare("SELECT COUNT(*) as c FROM symbols").get().c,n=this.db.prepare("SELECT COUNT(*) as c FROM behaviors").get().c,r=this.db.prepare("SELECT COUNT(*) as c FROM relations").get().c,s=this.db.prepare(`
269
272
  SELECT framework, COUNT(*) as count FROM files GROUP BY framework
270
273
  `).all(),o=this.db.prepare(`
271
274
  SELECT f.path, f.line_count, COUNT(s.id) as symbol_count
@@ -274,9 +277,9 @@ import D from'path';import'url';import Ot from'crypto';import {createRequire}fro
274
277
  ORDER BY f.line_count DESC LIMIT 10
275
278
  `).all(),i=this.db.prepare(`
276
279
  SELECT category, COUNT(*) as count FROM behaviors GROUP BY category ORDER BY count DESC
277
- `).all(),a=this.db.prepare("SELECT page_count * page_size as size FROM pragma_page_count(), pragma_page_size()").get()?.size??0;return {fileCount:e,symbolCount:t,behaviorCount:r,relationCount:n,frameworkBreakdown:s,topFiles:o,behaviorStats:i,dbSize:a}}close(){this.db.close();}};z();var Wt=8,Ut=30,Ht=14,Bt=360*60*1e3,Ne=class{dbCache=new Map;accessTimes=new Map;dbPaths=new Map;lastProject=null;globalCacheDir;defaultProject;maxOpenProjects;maxIdleMs;dbTtlMs;lastDiskCleanupAt=0;constructor(){this.globalCacheDir=D.join(Mt.homedir(),".frontend-code-skimmer","databases"),K.mkdirSync(this.globalCacheDir,{recursive:true}),this.defaultProject=process.env.SKIMMER_PROJECT||null,this.defaultProject&&(this.defaultProject=D.resolve(this.defaultProject)),this.maxOpenProjects=this.parsePositiveInt(process.env.SKIMMER_MAX_OPEN_PROJECTS,Wt);let e=this.parsePositiveInt(process.env.SKIMMER_DB_IDLE_MINUTES,Ut),t=this.parsePositiveInt(process.env.SKIMMER_DB_TTL_DAYS,Ht);this.maxIdleMs=e*60*1e3,this.dbTtlMs=t*24*60*60*1e3,this.maybeCleanupDiskCache(Date.now());}resolveProjectRoot(e){if(e){let t=D.resolve(e);if(!K.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=D.resolve(e),r=Date.now();if(this.evictIdleDatabases(r),this.maybeCleanupDiskCache(r),this.dbCache.has(t))return this.touchProject(t,r),this.dbCache.get(t);this.evictLruIfNeeded(r);let n=this.resolveDbPath(t),s=new Ee(t,n);return this.dbCache.set(t,s),this.dbPaths.set(t,n),this.touchProject(t,r),this.lastProject=t,process.stderr.write(`[Frontend-Code-Skimmer] \u5DF2\u8FDE\u63A5\u9879\u76EE: ${t}
278
- `),process.stderr.write(`[Frontend-Code-Skimmer] \u6570\u636E\u5E93: ${n}
279
- `),s}getContext(e){let t=this.resolveProjectRoot(e),r=this.getDatabase(t);return this.lastProject=t,{db:r,projectRoot:t}}setLastProject(e){this.lastProject=D.resolve(e);}listProjects(){return Array.from(this.dbCache.entries()).map(([e])=>({root:e,dbPath:this.dbPaths.get(e)||this.resolveDbPath(e)}))}closeProject(e){let t=D.resolve(e),r=this.dbCache.get(t);r&&(r.close(),this.dbCache.delete(t),this.accessTimes.delete(t),this.dbPaths.delete(t),this.lastProject===t&&(this.lastProject=null));}closeAll(){for(let e of this.dbCache.values())e.close();this.dbCache.clear(),this.accessTimes.clear(),this.dbPaths.clear(),this.lastProject=null;}resolveDbPath(e){if(process.env.SKIMMER_DB&&this.dbCache.size===0)return D.resolve(process.env.SKIMMER_DB);let t=D.join(e,".agent","skimmer_find_symbol"),r=D.join(t,be);try{return K.mkdirSync(t,{recursive:!0}),K.accessSync(e,K.constants.W_OK),r}catch{let n=e.replace(/[/\\:]/g,"_").replace(/^_+/,"").slice(-60);return D.join(this.globalCacheDir,`${n}.db`)}}parsePositiveInt(e,t){let r=Number.parseInt(String(e||""),10);return Number.isFinite(r)&&r>0?r:t}touchProject(e,t){this.accessTimes.set(e,t);}evictLruIfNeeded(e){for(;this.dbCache.size>=this.maxOpenProjects;){let t=null,r=Number.POSITIVE_INFINITY;for(let n of this.dbCache.keys()){let s=this.accessTimes.get(n)??e;s<r&&(r=s,t=n);}if(!t)break;this.closeProject(t);}}evictIdleDatabases(e){for(let t of this.dbCache.keys()){if(t===this.lastProject)continue;let r=this.accessTimes.get(t)??e;e-r>this.maxIdleMs&&this.closeProject(t);}}maybeCleanupDiskCache(e){if(e-this.lastDiskCleanupAt<Bt)return;this.lastDiskCleanupAt=e;let t=[];try{t=K.readdirSync(this.globalCacheDir,{withFileTypes:!0});}catch{return}let r=new Set;for(let s of this.dbPaths.values())s.startsWith(this.globalCacheDir)&&r.add(D.resolve(s));let n=e-this.dbTtlMs;for(let s of t){if(!s.isFile()||!s.name.endsWith(".db"))continue;let o=D.join(this.globalCacheDir,s.name);if(r.has(D.resolve(o)))continue;let i;try{i=K.statSync(o);}catch{continue}i.mtimeMs>=n||(this.safeUnlink(o),this.safeUnlink(`${o}-wal`),this.safeUnlink(`${o}-shm`));}}safeUnlink(e){try{K.existsSync(e)&&K.unlinkSync(e);}catch{}}};$();Be();function bt(l,e){l.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
280
+ `).all(),c=this.db.prepare("SELECT page_count * page_size as size FROM pragma_page_count(), pragma_page_size()").get()?.size??0;return {fileCount:e,symbolCount:t,behaviorCount:n,relationCount:r,frameworkBreakdown:s,topFiles:o,behaviorStats:i,dbSize:c}}close(){this.db.close();}};G();var sn=8,on=30,an=14,cn=360*60*1e3,Te=class{dbCache=new Map;accessTimes=new Map;dbPaths=new Map;lastProject=null;globalCacheDir;defaultProject;maxOpenProjects;maxIdleMs;dbTtlMs;lastDiskCleanupAt=0;constructor(){this.globalCacheDir=H.join(rn.homedir(),".frontend-code-skimmer","databases"),W.mkdirSync(this.globalCacheDir,{recursive:true}),this.defaultProject=process.env.SKIMMER_PROJECT||null,this.defaultProject&&(this.defaultProject=H.resolve(this.defaultProject)),this.maxOpenProjects=this.parsePositiveInt(process.env.SKIMMER_MAX_OPEN_PROJECTS,sn);let e=this.parsePositiveInt(process.env.SKIMMER_DB_IDLE_MINUTES,on),t=this.parsePositiveInt(process.env.SKIMMER_DB_TTL_DAYS,an);this.maxIdleMs=e*60*1e3,this.dbTtlMs=t*24*60*60*1e3,this.maybeCleanupDiskCache(Date.now());}resolveProjectRoot(e){if(e){let t=H.resolve(e);if(!W.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=H.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 $e(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}
281
+ `),process.stderr.write(`[Frontend-Code-Skimmer] \u6570\u636E\u5E93: ${r}
282
+ `),s}getContext(e){let t=this.resolveProjectRoot(e),n=this.getDatabase(t);return this.lastProject=t,{db:n,projectRoot:t}}setLastProject(e){this.lastProject=H.resolve(e);}listProjects(){return Array.from(this.dbCache.entries()).map(([e])=>({root:e,dbPath:this.dbPaths.get(e)||this.resolveDbPath(e)}))}closeProject(e){let t=H.resolve(e),n=this.dbCache.get(t);n&&(n.close(),this.dbCache.delete(t),this.accessTimes.delete(t),this.dbPaths.delete(t),this.lastProject===t&&(this.lastProject=null));}closeAll(){for(let e of this.dbCache.values())e.close();this.dbCache.clear(),this.accessTimes.clear(),this.dbPaths.clear(),this.lastProject=null;}resolveDbPath(e){if(process.env.SKIMMER_DB&&this.dbCache.size===0)return H.resolve(process.env.SKIMMER_DB);let t=H.join(e,".agent","skimmer_find_symbol"),n=H.join(t,xe);try{return W.mkdirSync(t,{recursive:!0}),W.accessSync(e,W.constants.W_OK),n}catch{let r=e.replace(/[/\\:]/g,"_").replace(/^_+/,"").slice(-60);return H.join(this.globalCacheDir,`${r}.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){for(let t of this.dbCache.keys()){if(t===this.lastProject)continue;let n=this.accessTimes.get(t)??e;e-n>this.maxIdleMs&&this.closeProject(t);}}maybeCleanupDiskCache(e){if(e-this.lastDiskCleanupAt<cn)return;this.lastDiskCleanupAt=e;let t=[];try{t=W.readdirSync(this.globalCacheDir,{withFileTypes:!0});}catch{return}let n=new Set;for(let s of this.dbPaths.values())s.startsWith(this.globalCacheDir)&&n.add(H.resolve(s));let r=e-this.dbTtlMs;for(let s of t){if(!s.isFile()||!s.name.endsWith(".db"))continue;let o=H.join(this.globalCacheDir,s.name);if(n.has(H.resolve(o)))continue;let i;try{i=W.statSync(o);}catch{continue}i.mtimeMs>=r||(this.safeUnlink(o),this.safeUnlink(`${o}-wal`),this.safeUnlink(`${o}-shm`));}}safeUnlink(e){try{W.existsSync(e)&&W.unlinkSync(e);}catch{}}};w();et();function Lt(l,e){l.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
280
283
  \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
281
284
  \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
282
285
  \u591A\u4E2A\u9879\u76EE\u4F1A\u5E76\u884C\u7F13\u5B58\uFF0C\u5207\u6362\u65E0\u9700\u91CD\u542F\u3002
@@ -286,56 +289,60 @@ import D from'path';import'url';import Ot from'crypto';import {createRequire}fro
286
289
  - \u4EE3\u7801\u53D8\u66F4\u540E\u5237\u65B0: \u76F8\u540C\u8DEF\u5F84\u518D\u6B21\u8C03\u7528\uFF08\u81EA\u52A8\u68C0\u6D4B\u53D8\u66F4\uFF0C\u589E\u91CF\u66F4\u65B0\uFF09
287
290
  - \u5F3A\u5236\u5168\u91CF\u91CD\u5EFA: force=true
288
291
 
289
- \u8FD4\u56DE: \u7D22\u5F15\u7EDF\u8BA1\uFF08\u6587\u4EF6\u6570\u3001\u7B26\u53F7\u6570\u3001\u8017\u65F6\uFF09`,inputSchema:z$1.object({project_path:z$1.string().describe('\u9879\u76EE\u6839\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u5982 "/Users/xxx/projects/my-app"'),force:z$1.boolean().optional().default(false).describe("\u662F\u5426\u5F3A\u5236\u5168\u91CF\u91CD\u5EFA\uFF08\u9ED8\u8BA4\u589E\u91CF\uFF0C\u53EA\u66F4\u65B0\u53D8\u66F4\u6587\u4EF6\uFF09"),include:z$1.array(z$1.string()).optional().describe('\u8981\u5305\u542B\u7684\u6587\u4EF6 glob \u6A21\u5F0F\uFF0C\u5982 ["**/*.vue","**/*.tsx"]'),exclude:z$1.array(z$1.string()).optional().describe("\u8981\u989D\u5916\u6392\u9664\u7684 glob \u6A21\u5F0F")}),annotations:{readOnlyHint:false,destructiveHint:false,idempotentHint:true}},async({project_path:t,force:r,include:n,exclude:s})=>{let{db:o,projectRoot:i}=e.getContext(t),c=await new ce(i,o).indexProject({include:n,exclude:s,force:r,onProgress:(d,p)=>{(d%20===0||d===p)&&process.stderr.write(`[Frontend-Code-Skimmer] \u8FDB\u5EA6: ${d}/${p}
290
- `);}});e.setLastProject(i);let f=[`\u2705 \u7D22\u5F15\u5B8C\u6210 \u2014 ${i}`,"\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",`\u{1F4C1} \u603B\u6587\u4EF6\u6570: ${c.totalFiles}`,`\u{1F504} \u5DF2\u7D22\u5F15: ${c.indexedFiles}`,`\u23E9 \u5DF2\u8DF3\u8FC7: ${c.skippedFiles} (\u5185\u5BB9\u672A\u53D8)`,`\u{1F523} \u603B\u7B26\u53F7\u6570: ${c.totalSymbols}`,`\u23F1\uFE0F \u8017\u65F6: ${c.durationMs}ms`,"","\u{1F4A1} \u540E\u7EED\u5DE5\u5177\u8C03\u7528\u53EF\u7701\u7565 project_path\uFF08\u81EA\u52A8\u4F7F\u7528\u6B64\u9879\u76EE\uFF09"];if(c.errors.length>0){f.push(`
291
- \u26A0\uFE0F \u89E3\u6790\u5931\u8D25 (${c.errors.length} \u4E2A):`);for(let d of c.errors.slice(0,5))f.push(` - ${d.file}: ${d.error}`);c.errors.length>5&&f.push(` ... \u8FD8\u6709 ${c.errors.length-5} \u4E2A`);}return {content:[{type:"text",text:f.join(`
292
- `)}]}});}$();X();function Et(l,e){l.registerTool("skimmer_get_component_outline",{title:"\u83B7\u53D6\u7EC4\u4EF6/\u6587\u4EF6\u7ED3\u6784\u9AA8\u67B6",description:`\u5C06\u6570\u5343\u884C\u4EE3\u7801\u538B\u7F29\u4E3A\u6E05\u6670\u7684\u7ED3\u6784\u9AA8\u67B6\uFF08\u7EA6 30-80 \u884C\uFF09\uFF0C\u8282\u7701 90%+ Token\u3002
292
+ \u8FD4\u56DE: \u7D22\u5F15\u7EDF\u8BA1\uFF08\u6587\u4EF6\u6570\u3001\u7B26\u53F7\u6570\u3001\u8017\u65F6\uFF09`,inputSchema:z$1.object({project_path:z$1.string().describe('\u9879\u76EE\u6839\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u5982 "/Users/xxx/projects/my-app"'),force:z$1.boolean().optional().default(false).describe("\u662F\u5426\u5F3A\u5236\u5168\u91CF\u91CD\u5EFA\uFF08\u9ED8\u8BA4\u589E\u91CF\uFF0C\u53EA\u66F4\u65B0\u53D8\u66F4\u6587\u4EF6\uFF09"),include:z$1.array(z$1.string()).optional().describe('\u8981\u5305\u542B\u7684\u6587\u4EF6 glob \u6A21\u5F0F\uFF0C\u5982 ["**/*.vue","**/*.tsx"]'),exclude:z$1.array(z$1.string()).optional().describe("\u8981\u989D\u5916\u6392\u9664\u7684 glob \u6A21\u5F0F")}),annotations:{readOnlyHint:false,destructiveHint:false,idempotentHint:true}},async({project_path:t,force:n,include:r,exclude:s})=>{let{db:o,projectRoot:i}=e.getContext(t),a=await new me(i,o).indexProject({include:r,exclude:s,force:n,onProgress:(N,y)=>{(N%20===0||N===y)&&process.stderr.write(`[Frontend-Code-Skimmer] \u8FDB\u5EA6: ${N}/${y}
293
+ `);}});e.setLastProject(i);let u=a.indexedFiles>0||a.totalFiles>0,d=a.totalSymbols>0,p=u?"\u2705 \u53EF\u7528":"\u274C \u65E0\u53EF\u67E5\u8BE2\u6587\u4EF6",f=d?"\u2705 \u53EF\u7528":"\u26A0\uFE0F \u7B26\u53F7\u6570\u4E3A0\uFF08\u89E3\u6790\u53EF\u80FD\u672A\u63D0\u53D6\u5230\u7B26\u53F7\uFF0C\u4F46\u6587\u4EF6\u641C\u7D22\u4ECD\u53EF\u7528\uFF09",m=u?"\u2705 \u53EF\u7528":"\u274C \u65E0\u53EF\u67E5\u8BE2\u6587\u4EF6",g=u?"\u2705 \u53EF\u7528\uFF08\u57FA\u4E8E\u6B63\u5219\u626B\u63CF\u6587\u4EF6\uFF09":"\u274C \u65E0\u53EF\u67E5\u8BE2\u6587\u4EF6",h=[`\u2705 \u7D22\u5F15\u5B8C\u6210 \u2014 ${i}`,"\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501","","\u{1F4CA} \u3010\u7EDF\u8BA1\u6570\u91CF\u3011\uFF08\u6CE8\u610F\uFF1A\u7B26\u53F7\u65700\u53EF\u80FD\u662F\u89E3\u6790\u89C4\u5219\u672A\u547D\u4E2D\uFF0C\u4E0D\u4EE3\u8868\u7D22\u5F15\u5931\u8D25\uFF09",` \u{1F4C1} \u603B\u6587\u4EF6\u6570: ${a.totalFiles}`,` \u{1F504} \u5DF2\u7D22\u5F15: ${a.indexedFiles}`,` \u23E9 \u5DF2\u8DF3\u8FC7: ${a.skippedFiles} (\u5185\u5BB9\u672A\u53D8)`,` \u{1F523} \u603B\u7B26\u53F7\u6570: ${a.totalSymbols}`,` \u23F1\uFE0F \u8017\u65F6: ${a.durationMs}ms`,"","\u{1F50C} \u3010\u53EF\u67E5\u8BE2\u80FD\u529B\u72B6\u6001\u3011\uFF08\u4E0E\u7B26\u53F7\u6570\u65E0\u5173\uFF0C\u53EA\u8981\u6587\u4EF6\u626B\u63CF\u5B8C\u6210\u5373\u53EF\u7528\uFF09",` skimmer_find_symbol ${f}`,` skimmer_get_component_outline ${f}`,` skimmer_find_by_behavior ${m}`,` skimmer_trace_data_lifecycle ${g}`,` skimmer_trace_assignments ${g}`,` skimmer_get_code_slice ${p}`,"","\u{1F4A1} \u540E\u7EED\u5DE5\u5177\u8C03\u7528\u53EF\u7701\u7565 project_path\uFF08\u81EA\u52A8\u4F7F\u7528\u6B64\u9879\u76EE\uFF09"," \u5982\u7B26\u53F7\u6570\u4E3A0\u4F46\u5DE5\u5177\u4ECD\u8FD4\u56DE\u7ED3\u679C\uFF0C\u5C5E\u6B63\u5E38\u73B0\u8C61\uFF08\u6B63\u5219\u626B\u63CF\u8DEF\u5F84\u4E0D\u4F9D\u8D56\u7B26\u53F7\u7D22\u5F15\uFF09"];if(a.errors.length>0){h.push(`
294
+ \u26A0\uFE0F \u89E3\u6790\u5931\u8D25 (${a.errors.length} \u4E2A):`);for(let N of a.errors.slice(0,5))h.push(` - ${N.file}: ${N.error}`);a.errors.length>5&&h.push(` ... \u8FD8\u6709 ${a.errors.length-5} \u4E2A`);}return {content:[{type:"text",text:h.join(`
295
+ `)}]}});}w();J();function wt(l,e){l.registerTool("skimmer_get_component_outline",{title:"\u83B7\u53D6\u7EC4\u4EF6/\u6587\u4EF6\u7ED3\u6784\u9AA8\u67B6",description:`\u5C06\u6570\u5343\u884C\u4EE3\u7801\u538B\u7F29\u4E3A\u6E05\u6670\u7684\u7ED3\u6784\u9AA8\u67B6\uFF08\u7EA6 30-80 \u884C\uFF09\uFF0C\u8282\u7701 90%+ Token\u3002
293
296
  \u5305\u542B: props\u3001data/state\u3001computed\u3001methods/functions\u3001watch/effect\u3001lifecycle\u3001\u884C\u4E3A\u6807\u7B7E\u3002
294
297
  \u884C\u4E3A\u6807\u7B7E\u81EA\u52A8\u6807\u51FA: [storage:localStorage.setItem] [network:axios.get] \u7B49\u3002
295
298
 
296
299
  project_path \u53EF\u7701\u7565\uFF08\u4F7F\u7528\u4E0A\u6B21 skimmer_index_project \u6307\u5B9A\u7684\u9879\u76EE\uFF09\u3002
297
- file_path \u4F7F\u7528\u76F8\u5BF9\u4E8E\u9879\u76EE\u6839\u76EE\u5F55\u7684\u8DEF\u5F84\uFF0C\u5982 "src/views/apply/index.vue"\u3002`,inputSchema:z$1.object({file_path:z$1.string().describe('\u6587\u4EF6\u76F8\u5BF9\u8DEF\u5F84\uFF0C\u5982 "src/views/apply/index.vue"'),project_path:z$1.string().optional().describe("\u9879\u76EE\u6839\u76EE\u5F55\uFF08\u53EF\u7701\u7565\uFF0C\u4F7F\u7528\u4E0A\u6B21\u7D22\u5F15\u7684\u9879\u76EE\uFF09")}),annotations:{readOnlyHint:true,destructiveHint:false}},async({file_path:t,project_path:r})=>{let{db:n}=e.getContext(r),{file:s,symbols:o,behaviors:i}=n.getFileOutline(t);if(!s)return {content:[{type:"text",text:`\u274C \u6587\u4EF6\u672A\u7D22\u5F15: ${t}
300
+ file_path \u4F7F\u7528\u76F8\u5BF9\u4E8E\u9879\u76EE\u6839\u76EE\u5F55\u7684\u8DEF\u5F84\uFF0C\u5982 "src/views/apply/index.vue"\u3002`,inputSchema:z$1.object({file_path:z$1.string().describe('\u6587\u4EF6\u76F8\u5BF9\u8DEF\u5F84\uFF0C\u5982 "src/views/apply/index.vue"'),project_path:z$1.string().optional().describe("\u9879\u76EE\u6839\u76EE\u5F55\uFF08\u53EF\u7701\u7565\uFF0C\u4F7F\u7528\u4E0A\u6B21\u7D22\u5F15\u7684\u9879\u76EE\uFF09")}),annotations:{readOnlyHint:true,destructiveHint:false}},async({file_path:t,project_path:n})=>{let{db:r}=e.getContext(n),{file:s,symbols:o,behaviors:i}=r.getFileOutline(t);if(!s)return {content:[{type:"text",text:`\u274C \u6587\u4EF6\u672A\u7D22\u5F15: ${t}
298
301
 
299
302
  \u8BF7\u5148\u8FD0\u884C:
300
- skimmer_index_project({ project_path: "${r||"<\u9879\u76EE\u8DEF\u5F84>"}" })`}]};let a=new Map;for(let p of i){let u=p.symbol_id;a.has(u)||a.set(u,[]);let g=`[${p.category}:${p.api_name}.${p.operation}${p.detail?`("${p.detail}")`:""}]`,m=a.get(u);m.includes(g)||m.push(g);}let c=[];c.push(`\u{1F4C4} ${t} (${s.line_count} \u884C, ${s.framework})`),c.push(`${"\u2501".repeat(50)}`);let f={};for(let p of o){let u=p.category;f[u]||(f[u]=[]),f[u].push(p);}let d=[{key:"prop",icon:"\u{1F4E6}",label:"Props"},{key:"state",icon:"\u{1F4CA}",label:"Data / State"},{key:"computed",icon:"\u{1F504}",label:"Computed"},{key:"method",icon:"\u26A1",label:"Methods / Functions"},{key:"effect",icon:"\u{1F440}",label:"Watch / Effect"},{key:"lifecycle",icon:"\u{1F517}",label:"Lifecycle"},{key:"hook",icon:"\u{1FA9D}",label:"Hooks"},{key:"component",icon:"\u{1F9E9}",label:"Components"},{key:"mixin",icon:"\u{1F500}",label:"Mixins"},{key:"provide",icon:"\u{1F489}",label:"Provide / Inject"},{key:"emit",icon:"\u{1F4E1}",label:"Emits"},{key:"filter",icon:"\u{1F50D}",label:"Filters"},{key:"function",icon:"\u{1F527}",label:"Functions"},{key:"constant",icon:"\u{1F4CC}",label:"Constants"}];for(let{key:p,icon:u,label:g}of d){let m=f[p];if(m?.length){c.push(`
301
- ${u} ${g} (${m.length}):`);for(let E of m){let N=E.name,y=te(E.start_line,E.end_line),h=ie(E.params_json,[]),b=h.length>0?`(${h.join(", ")})`:"",T=E.default_value?` = ${E.default_value}`:"",v=E.is_async?"async ":"",W=a.get(E.id),P=W?.length?` ${W.slice(0,3).join(" ")}`:"",H=E.state_setter_name?` \u2192 ${E.state_setter_name}`:"",$e=E.hook_deps_json?` [deps:${ie(E.hook_deps_json,[]).join(",")}]`:"";c.push(` \u2022 ${v}${N}${b}${T}${H}${$e} ${y}${P}`);}}}return c.push(`
302
- ${"\u2500".repeat(50)}`),c.push(`\u{1F4A1} \u67E5\u770B\u5177\u4F53\u4EE3\u7801: skimmer_get_code_slice({ file_path: "${t}", symbol_name: "\u65B9\u6CD5\u540D" })`),{content:[{type:"text",text:c.join(`
303
- `)}]}});}$();$();X();z();var le=class{constructor(e){this.db=e;}search(e,t){let{category:r,framework:n,filePath:s,limit:o=at,fuzzy:i=true}=t||{},a=new Map,c=this.db.exactSearch(e,r,n,s);for(let m of c){let E=m.id;a.set(E,{symbol:m,filePath:m.file_path,score:100,matchReason:"\u7CBE\u786E\u5339\u914D"});}if(a.size>=o)return this.rankResults(a,o);let f=A(e),d=[e,f,...f.split(" ")].filter(Boolean);for(let m of d){if(m.length<2)continue;let E=this.db.ftsSearch(m,r,n,s);for(let N of E){let y=N.id;if(a.has(y))continue;let h=this.calcFtsScore(e,N.name);a.set(y,{symbol:N,filePath:N.file_path,score:h,matchReason:`FTS5 \u5168\u6587\u5339\u914D (${m})`});}}if(!i||a.size>=o)return this.rankResults(a,o);let p=this.db.getAllSymbolNames(s),u=e.toLowerCase(),g=A(e).split(" ");for(let{name:m,file_path:E,id:N}of p){if(a.has(N))continue;let y=he(u,m.toLowerCase());if(y<=ct){let T=Math.max(0,80-y*15),v=this.db.getSymbolById(N);if(!v||r&&v.category!==r||n&&v.framework!==n)continue;let W=tt(e,m,y);a.set(N,{symbol:v,filePath:E,score:T,matchReason:`\u6A21\u7CCA\u5339\u914D (\u7F16\u8F91\u8DDD\u79BB=${y})`,spellingSuggestion:W});continue}let h=A(m).split(" "),b=g.filter(T=>h.some(v=>et(T,v)>=75));if(b.length>0&&b.length>=Math.ceil(g.length*.6)){let T=50+b.length*10,v=this.db.getSymbolById(N);if(!v||r&&v.category!==r||n&&v.framework!==n)continue;a.set(N,{symbol:v,filePath:E,score:T,matchReason:`\u5355\u8BCD\u5339\u914D (${b.join(", ")})`});}}return this.rankResults(a,o)}searchByBehavior(e){return this.db.behaviorSearch(e.category,e.apiName,e.operation,e.keyword,e.filePath).map(r=>({symbolName:r.symbol_name,category:r.category,apiName:r.api_name,operation:r.operation,detail:r.detail,line:r.line_number,filePath:r.file_path,startLine:r.start_line,endLine:r.end_line}))}calcFtsScore(e,t){let r=e.toLowerCase(),n=t.toLowerCase();if(n===r)return 98;if(n.startsWith(r))return 88;if(n.includes(r))return 78;let s=A(e).split(" "),o=A(t).split(" ");return 60+s.filter(a=>o.some(c=>c.startsWith(a))).length*8}rankResults(e,t){return Array.from(e.values()).sort((r,n)=>n.score-r.score).slice(0,t)}};X();var At=createRequire(import.meta.url),Y="\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 pe(l){return l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ne(l,e,t){let r=[];for(let n of l){if(!n?.abs_path||!K.existsSync(n.abs_path))continue;let s=K.readFileSync(n.abs_path,"utf-8").split(`
304
- `);for(let o=0;o<s.length;o++){let i=s[o];for(let a of e)if(a.regex.test(i)){r.push({filePath:n.path,line:o+1,kind:a.kind,text:i.trim()});break}if(r.length>=t)return r}}return r}function Nt(l,e){let t=pe(l),r="(?:=|\\+=|-=|\\*=|/=|%=|\\|=|&=|\\^=|&&=|\\|\\|=|\\?\\?=)",n=[{kind:"declaration",regex:new RegExp(`\\b(?:const|let|var)\\s+${t}\\b`)},{kind:"assignment",regex:new RegExp(`\\b${t}\\b\\s*${r}`)},{kind:"update",regex:new RegExp(`(?:\\+\\+|--)\\s*\\b${t}\\b|\\b${t}\\b\\s*(?:\\+\\+|--)`)}];return e&&n.push({kind:"property_assignment",regex:new RegExp(`\\b${t}\\.[A-Za-z_$][\\w$]*\\s*${r}`)},{kind:"indexed_assignment",regex:new RegExp(`\\b${t}\\s*\\[[^\\]]+\\]\\s*${r}`)}),n}function ue(l,e){if(!(!l||typeof l!="object")){e(l);for(let t of Object.keys(l)){if(t==="type"||t==="loc"||t==="start"||t==="end")continue;let r=l[t];if(Array.isArray(r))for(let n of r)n&&typeof n=="object"&&n.type&&ue(n,e);else r&&typeof r=="object"&&r.type&&ue(r,e);}}}function Je(l){try{return At("@babel/parser").parse(l,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"],errorRecovery:!0})}catch{return null}}function Ye(l,e){if(!l.endsWith(".vue"))return [{content:e,lineOffset:1}];try{let{parse:s}=At("@vue/compiler-sfc"),{descriptor:o}=s(e),i=[];if(o.script?.content&&i.push({content:o.script.content,lineOffset:o.script.loc.start.line}),o.scriptSetup?.content&&i.push({content:o.scriptSetup.content,lineOffset:o.scriptSetup.loc.start.line}),i.length>0)return i}catch{}let t=e.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!t||!t[1])return [];let n=e.slice(0,t.index||0).split(`
305
- `).length;return [{content:t[1],lineOffset:n}]}function ee(l,e){return (l.loc?.start?.line??1)+e-1}function de(l){let e=l.property;return e?e.type==="Identifier"?String(e.name||""):e.type==="Literal"?String(e.value||""):null:null}function St(l,e){if(l.type!=="MemberExpression")return false;let t=l.object;return !t||t.type!=="ThisExpression"?false:de(l)===e}function Ve(l,e){return !!l&&l.type==="Identifier"&&String(l.name||"")===e}function Re(l){let e=l.object;return e?e.type==="Identifier"?String(e.name||""):e.type==="MemberExpression"&&e.object?.type==="ThisExpression"&&de(e)||null:null}function _t(l){let e=new Set;return l.filter(t=>{let r=`${t.filePath}:${t.line}:${t.kind}:${t.text}`;return e.has(r)?false:(e.add(r),true)})}function pr(l,e,t){let r=[];for(let n of l){if(!n.abs_path||!K.existsSync(n.abs_path))continue;let s=K.readFileSync(n.abs_path,"utf-8"),o=s.split(`
306
- `),i=Ye(n.path||D.basename(n.abs_path),s);for(let a of i){let c=Je(a.content);c&&ue(c,f=>{if(r.length>=t||f.type!=="VariableDeclarator")return;let d=f.id;if(!d||d.type!=="ObjectPattern")return;let p=d.properties||[];for(let u of p){if(u.type!=="ObjectProperty"&&u.type!=="Property")continue;let g=u.key,m=u.value,E=g?.type==="Identifier"?String(g.name||""):null;if(E!==e)continue;let N=m?.type==="Identifier"?String(m.name||""):E;if(!N)continue;let y=ee(f,a.lineOffset),h=o[y-1]?.trim()||"";r.push({alias:N,filePath:n.path,line:y,text:h});}});}}return r}function Xe(l,e,t,r){let n=[];for(let s of l){if(!s.abs_path||!K.existsSync(s.abs_path))continue;let o=K.readFileSync(s.abs_path,"utf-8"),i=o.split(`
307
- `),a=Ye(s.path||D.basename(s.abs_path),o);for(let c of a){let f=Je(c.content);if(f&&(ue(f,d=>{if(!(n.length>=r)){if(d.type==="VariableDeclarator"){let p=d.id;if(Ve(p,e)){let u=ee(d,c.lineOffset);n.push({filePath:s.path,line:u,kind:"declaration",text:i[u-1]?.trim()||""});}}if(d.type==="AssignmentExpression"){let p=d.left;if(!p)return;let u=ee(d,c.lineOffset);if(Ve(p,e)||St(p,e)){n.push({filePath:s.path,line:u,kind:"assignment",text:i[u-1]?.trim()||""});return}t&&p.type==="MemberExpression"&&Re(p)===e&&n.push({filePath:s.path,line:u,kind:p.computed?"indexed_assignment":"property_assignment",text:i[u-1]?.trim()||""});}if(d.type==="UpdateExpression"){let p=d.argument;if(!p)return;if(Ve(p,e)||St(p,e)){let u=ee(d,c.lineOffset);n.push({filePath:s.path,line:u,kind:"update",text:i[u-1]?.trim()||""});}}}}),n.length>=r))break}if(n.length>=r)break}return _t(n).slice(0,r)}function ze(l,e,t,r){let n=[];for(let s of l){if(!s.abs_path||!K.existsSync(s.abs_path))continue;let o=K.readFileSync(s.abs_path,"utf-8"),i=o.split(`
308
- `),a=Ye(s.path||D.basename(s.abs_path),o);for(let c of a){let f=Je(c.content);if(f&&(ue(f,d=>{if(!(n.length>=r)){if(d.type==="AssignmentExpression"){let p=d.left;if(!p||p.type!=="MemberExpression"||Re(p)!==e)return;let g=de(p);if(t&&g!==t)return;let m=ee(d,c.lineOffset);n.push({filePath:s.path,line:m,kind:p.computed?"bracket":"dot",text:i[m-1]?.trim()||""});}if(d.type==="UpdateExpression"){let p=d.argument;if(!p||p.type!=="MemberExpression"||Re(p)!==e)return;let g=de(p);if(t&&g!==t)return;let m=ee(d,c.lineOffset);n.push({filePath:s.path,line:m,kind:p.computed?"bracket":"dot",text:i[m-1]?.trim()||""});}if(d.type==="UnaryExpression"&&d.operator==="delete"){let p=d.argument;if(!p||p.type!=="MemberExpression"||Re(p)!==e)return;let g=de(p);if(t&&g!==t)return;let m=ee(d,c.lineOffset);n.push({filePath:s.path,line:m,kind:"delete",text:i[m-1]?.trim()||""});}}}),n.length>=r))break}if(n.length>=r)break}return _t(n).slice(0,r)}function xt(l,e){l.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
303
+ skimmer_index_project({ project_path: "${n||"<\u9879\u76EE\u8DEF\u5F84>"}" })`}]};let c=new Map;for(let p of i){let f=p.symbol_id;c.has(f)||c.set(f,[]);let m=`[${p.category}:${p.api_name}.${p.operation}${p.detail?`("${p.detail}")`:""}]`,g=c.get(f);g.includes(m)||g.push(m);}let a=[];a.push(`\u{1F4C4} ${t} (${s.line_count} \u884C, ${s.framework})`),a.push(`${"\u2501".repeat(50)}`);let u={};for(let p of o){if(p.name==="<template>")continue;let f=p.category;u[f]||(u[f]=[]),u[f].push(p);}let d=[{key:"prop",icon:"\u{1F4E6}",label:"Props"},{key:"state",icon:"\u{1F4CA}",label:"Data / State"},{key:"computed",icon:"\u{1F504}",label:"Computed"},{key:"method",icon:"\u26A1",label:"Methods / Functions"},{key:"effect",icon:"\u{1F440}",label:"Watch / Effect"},{key:"lifecycle",icon:"\u{1F517}",label:"Lifecycle"},{key:"hook",icon:"\u{1FA9D}",label:"Hooks"},{key:"component",icon:"\u{1F9E9}",label:"Components"},{key:"mixin",icon:"\u{1F500}",label:"Mixins"},{key:"provide",icon:"\u{1F489}",label:"Provide / Inject"},{key:"emit",icon:"\u{1F4E1}",label:"Emits"},{key:"filter",icon:"\u{1F50D}",label:"Filters"},{key:"function",icon:"\u{1F527}",label:"Functions"},{key:"constant",icon:"\u{1F4CC}",label:"Constants"}];for(let{key:p,icon:f,label:m}of d){let g=u[p];if(g?.length){a.push(`
304
+ ${f} ${m} (${g.length}):`);for(let h of g){let N=h.name,y=ce(h.start_line,h.end_line),b=ue(h.params_json,[]),S=b.length>0?`(${b.join(", ")})`:"",v=h.default_value?` = ${h.default_value}`:"",T=h.is_async?"async ":"",P=c.get(h.id),I=P?.length?` ${P.slice(0,3).join(" ")}`:"",O=h.state_setter_name?` \u2192 ${h.state_setter_name}`:"",ie=h.hook_deps_json?` [deps:${ue(h.hook_deps_json,[]).join(",")}]`:"";a.push(` \u2022 ${T}${N}${S}${v}${O}${ie} ${y}${I}`);}}}return a.push(`
305
+ ${"\u2500".repeat(50)}`),a.push(`\u{1F4A1} \u67E5\u770B\u5177\u4F53\u4EE3\u7801: skimmer_get_code_slice({ file_path: "${t}", symbol_name: "\u65B9\u6CD5\u540D" })`),{content:[{type:"text",text:a.join(`
306
+ `)}]}});}w();w();J();G();var ge=class{constructor(e){this.db=e;}search(e,t){let{category:n,framework:r,filePath:s,limit:o=bt,fuzzy:i=true}=t||{},c=new Map,a=this.db.exactSearch(e,n,r,s);for(let g of a){let h=g.id;c.set(h,{symbol:g,filePath:g.file_path,score:100,matchReason:"\u7CBE\u786E\u5339\u914D"});}if(c.size>=o)return this.rankResults(c,o);let u=A(e),d=[e,u,...u.split(" ")].filter(Boolean);for(let g of d){if(g.length<2)continue;let h=this.db.ftsSearch(g,n,r,s);for(let N of h){let y=N.id;if(c.has(y))continue;let b=this.calcFtsScore(e,N.name);c.set(y,{symbol:N,filePath:N.file_path,score:b,matchReason:`FTS5 \u5168\u6587\u5339\u914D (${g})`});}}if(!i||c.size>=o)return this.rankResults(c,o);let p=this.db.getAllSymbolNames(s),f=e.toLowerCase(),m=A(e).split(" ");for(let{name:g,file_path:h,id:N}of p){if(c.has(N))continue;let y=_e(f,g.toLowerCase());if(y<=Et){let v=Math.max(0,80-y*15),T=this.db.getSymbolById(N);if(!T||n&&T.category!==n||r&&T.framework!==r)continue;let P=ut(e,g,y);c.set(N,{symbol:T,filePath:h,score:v,matchReason:`\u6A21\u7CCA\u5339\u914D (\u7F16\u8F91\u8DDD\u79BB=${y})`,spellingSuggestion:P});continue}let b=A(g).split(" "),S=m.filter(v=>b.some(T=>dt(v,T)>=75));if(S.length>0&&S.length>=Math.ceil(m.length*.6)){let v=50+S.length*10,T=this.db.getSymbolById(N);if(!T||n&&T.category!==n||r&&T.framework!==r)continue;c.set(N,{symbol:T,filePath:h,score:v,matchReason:`\u5355\u8BCD\u5339\u914D (${S.join(", ")})`});}}return this.rankResults(c,o)}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}))}calcFtsScore(e,t){let n=e.toLowerCase(),r=t.toLowerCase();if(r===n)return 98;if(r.startsWith(n))return 88;if(r.includes(n))return 78;let s=A(e).split(" "),o=A(t).split(" ");return 60+s.filter(c=>o.some(a=>a.startsWith(c))).length*8}rankResults(e,t){return Array.from(e.values()).sort((n,r)=>r.score-n.score).slice(0,t)}};J();var Mt=createRequire(import.meta.url),Z="\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 he(l){return l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pe(l,e,t){let n=[];for(let r of l){if(!r?.abs_path||!W.existsSync(r.abs_path))continue;let s=W.readFileSync(r.abs_path,"utf-8").split(`
307
+ `);for(let o=0;o<s.length;o++){let i=s[o];for(let c of e)if(c.regex.test(i)){n.push({filePath:r.path,line:o+1,kind:c.kind,text:i.trim()});break}if(n.length>=t)return n}}return n}function Ct(l,e){let t=he(l),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 oe(l,e){if(!(!l||typeof l!="object")){e(l);for(let t of Object.keys(l)){if(t==="type"||t==="loc"||t==="start"||t==="end")continue;let n=l[t];if(Array.isArray(n))for(let r of n)r&&typeof r=="object"&&r.type&&oe(r,e);else n&&typeof n=="object"&&n.type&&oe(n,e);}}}function Me(l){try{return Mt("@babel/parser").parse(l,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy"],errorRecovery:!0})}catch{return null}}function De(l,e){if(!l.endsWith(".vue"))return [{content:e,lineOffset:1}];try{let{parse:s}=Mt("@vue/compiler-sfc"),{descriptor:o}=s(e),i=[];if(o.script?.content&&i.push({content:o.script.content,lineOffset:o.script.loc.start.line}),o.scriptSetup?.content&&i.push({content:o.scriptSetup.content,lineOffset:o.scriptSetup.loc.start.line}),i.length>0)return i}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(`
308
+ `).length;return [{content:t[1],lineOffset:r}]}function ee(l,e){return (l.loc?.start?.line??1)+e-1}function se(l){let e=l.property;return e?e.type==="Identifier"?String(e.name||""):e.type==="Literal"?String(e.value||""):null:null}function Pt(l,e){if(l.type!=="MemberExpression")return false;let t=l.object;return !t||t.type!=="ThisExpression"?false:se(l)===e}function nt(l,e){return !!l&&l.type==="Identifier"&&String(l.name||"")===e}function je(l){let e=l.object;return e?e.type==="Identifier"?String(e.name||""):e.type==="MemberExpression"&&e.object?.type==="ThisExpression"&&se(e)||null:null}function Dt(l){let e=new Set;return l.filter(t=>{let n=`${t.filePath}:${t.line}:${t.kind}:${t.text}`;return e.has(n)?false:(e.add(n),true)})}function rt(l,e,t=2){if(!W.existsSync(l))return {snippet:"",startLine:e};let n=W.readFileSync(l,"utf-8").split(`
309
+ `),r=Math.max(0,e-1-t),s=Math.min(n.length-1,e-1+t);return {snippet:n.slice(r,s+1).map((i,c)=>{let a=r+c+1;return ` ${a===e?"\u25B6":" "} ${String(a).padStart(4)} \u2502 ${i}`}).join(`
310
+ `),startLine:r+1}}function Ie(l,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}[l]??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}]`}function It(l,e){let t=l;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 Ot={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 jt(l,e,t){let n=[];for(let r of l){if(!r.abs_path||!W.existsSync(r.abs_path))continue;let s=W.readFileSync(r.abs_path,"utf-8"),o=s.split(`
311
+ `),i=De(r.path||H.basename(r.abs_path),s);for(let c of i){let a=Me(c.content);a&&oe(a,u=>{if(n.length>=t||u.type!=="VariableDeclarator")return;let d=u.id;if(!d||d.type!=="Identifier")return;let p=String(d.name||"");if(!p||p===e)return;let f=u.init;if(!f)return;let m=false;if(f.type==="Identifier"&&String(f.name||"")===e&&(m=true),!m&&f.type==="MemberExpression"&&se(f)===e&&(m=true),m||oe(f,N=>{m||(N.type==="Identifier"&&String(N.name||"")===e&&(m=true),N.type==="MemberExpression"&&se(N)===e&&(m=true));}),!m)return;let g=ee(u,c.lineOffset),h=o[g-1]?.trim()||"";n.push({alias:p,filePath:r.path,abs_path:r.abs_path,line:g,text:h});});}}return n}function Ft(l,e,t){let n=[];for(let r of l){if(!r.abs_path||!W.existsSync(r.abs_path))continue;let s=W.readFileSync(r.abs_path,"utf-8"),o=s.split(`
312
+ `),i=De(r.path||H.basename(r.abs_path),s);for(let c of i){let a=Me(c.content);a&&oe(a,u=>{if(n.length>=t||u.type!=="VariableDeclarator")return;let d=u.id;if(!d||d.type!=="ObjectPattern")return;let p=d.properties||[];for(let f of p){if(f.type!=="ObjectProperty"&&f.type!=="Property")continue;let m=f.key,g=f.value,h=m?.type==="Identifier"?String(m.name||""):null;if(h!==e)continue;let N=g?.type==="Identifier"?String(g.name||""):h;if(!N)continue;let y=ee(u,c.lineOffset),b=o[y-1]?.trim()||"";n.push({alias:N,filePath:r.path,line:y,text:b});}});}}return n}function st(l,e,t,n){let r=[];for(let s of l){if(!s.abs_path||!W.existsSync(s.abs_path))continue;let o=W.readFileSync(s.abs_path,"utf-8"),i=o.split(`
313
+ `),c=De(s.path||H.basename(s.abs_path),o);for(let a of c){let u=Me(a.content);if(u&&(oe(u,d=>{if(!(r.length>=n)){if(d.type==="VariableDeclarator"){let p=d.id;if(nt(p,e)){let f=ee(d,a.lineOffset);r.push({filePath:s.path,line:f,kind:"declaration",text:i[f-1]?.trim()||""});}}if(d.type==="AssignmentExpression"){let p=d.left;if(!p)return;let f=ee(d,a.lineOffset);if(nt(p,e)||Pt(p,e)){r.push({filePath:s.path,line:f,kind:"assignment",text:i[f-1]?.trim()||""});return}t&&p.type==="MemberExpression"&&je(p)===e&&r.push({filePath:s.path,line:f,kind:p.computed?"indexed_assignment":"property_assignment",text:i[f-1]?.trim()||""});}if(d.type==="UpdateExpression"){let p=d.argument;if(!p)return;if(nt(p,e)||Pt(p,e)){let f=ee(d,a.lineOffset);r.push({filePath:s.path,line:f,kind:"update",text:i[f-1]?.trim()||""});}}}}),r.length>=n))break}if(r.length>=n)break}return Dt(r).slice(0,n)}function Oe(l,e,t,n){let r=[];for(let s of l){if(!s.abs_path||!W.existsSync(s.abs_path))continue;let o=W.readFileSync(s.abs_path,"utf-8"),i=o.split(`
314
+ `),c=De(s.path||H.basename(s.abs_path),o);for(let a of c){let u=Me(a.content);if(u&&(oe(u,d=>{if(!(r.length>=n)){if(d.type==="AssignmentExpression"){let p=d.left;if(!p||p.type!=="MemberExpression"||je(p)!==e)return;let m=se(p);if(t&&m!==t)return;let g=ee(d,a.lineOffset);r.push({filePath:s.path,line:g,kind:p.computed?"bracket":"dot",text:i[g-1]?.trim()||""});}if(d.type==="UpdateExpression"){let p=d.argument;if(!p||p.type!=="MemberExpression"||je(p)!==e)return;let m=se(p);if(t&&m!==t)return;let g=ee(d,a.lineOffset);r.push({filePath:s.path,line:g,kind:p.computed?"bracket":"dot",text:i[g-1]?.trim()||""});}if(d.type==="UnaryExpression"&&d.operator==="delete"){let p=d.argument;if(!p||p.type!=="MemberExpression"||je(p)!==e)return;let m=se(p);if(t&&m!==t)return;let g=ee(d,a.lineOffset);r.push({filePath:s.path,line:g,kind:"delete",text:i[g-1]?.trim()||""});}}}),r.length>=n))break}if(r.length>=n)break}return Dt(r).slice(0,n)}function Wt(l,e){l.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
309
315
  \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
310
316
  \u9A7C\u5CF0\u62C6\u8BCD\uFF1A\u641C "change cache" \u4E5F\u80FD\u627E\u5230 "changeCacheValue"\u3002
311
317
  \u6846\u67B6\u611F\u77E5\uFF1A\u53EF\u6309 vue2/vue3/react \u8FC7\u6EE4\u3002
312
- project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({query:z$1.string().describe('\u641C\u7D22\u8BCD\uFF0C\u5982 "changeCash" \u6216 "handle submit"'),project_path:z$1.string().optional().describe(Y),category:z$1.enum(["state","computed","method","effect","prop","lifecycle","hook","component","mixin","function","all"]).optional().default("all").describe("\u7B26\u53F7\u7C7B\u578B\u8FC7\u6EE4"),framework:z$1.enum(["vue2","vue3","react","all"]).optional().default("all"),file_path:z$1.string().optional().describe('\u9650\u5B9A\u6587\u4EF6\u8DEF\u5F84\u641C\u7D22\uFF08\u5305\u542B\u5373\u53EF\uFF0C\u5982 "index.vue"\uFF09'),fuzzy:z$1.boolean().optional().default(true).describe("\u662F\u5426\u542F\u7528\u6A21\u7CCA\u5339\u914D\uFF08\u9ED8\u8BA4 true\uFF09"),limit:z$1.number().optional().default(15)}),annotations:{readOnlyHint:true,destructiveHint:false}},async({query:t,project_path:r,category:n,framework:s,file_path:o,fuzzy:i,limit:a})=>{let{db:c}=e.getContext(r),d=new le(c).search(t,{category:n==="all"?void 0:n,framework:s==="all"?void 0:s,filePath:o,fuzzy:i,limit:a});if(d.length===0)return {content:[{type:"text",text:`\u{1F50D} \u641C\u7D22 "${t}" \u65E0\u7ED3\u679C
318
+ project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({query:z$1.string().describe('\u641C\u7D22\u8BCD\uFF0C\u5982 "changeCash" \u6216 "handle submit"'),project_path:z$1.string().optional().describe(Z),category:z$1.enum(["state","computed","method","effect","prop","lifecycle","hook","component","mixin","function","all"]).optional().default("all").describe("\u7B26\u53F7\u7C7B\u578B\u8FC7\u6EE4"),framework:z$1.enum(["vue2","vue3","react","all"]).optional().default("all"),file_path:z$1.string().optional().describe('\u9650\u5B9A\u6587\u4EF6\u8DEF\u5F84\u641C\u7D22\uFF08\u5305\u542B\u5373\u53EF\uFF0C\u5982 "index.vue"\uFF09'),fuzzy:z$1.boolean().optional().default(true).describe("\u662F\u5426\u542F\u7528\u6A21\u7CCA\u5339\u914D\uFF08\u9ED8\u8BA4 true\uFF09"),limit:z$1.number().optional().default(15)}),annotations:{readOnlyHint:true,destructiveHint:false}},async({query:t,project_path:n,category:r,framework:s,file_path:o,fuzzy:i,limit:c})=>{let{db:a}=e.getContext(n),d=new ge(a).search(t,{category:r==="all"?void 0:r,framework:s==="all"?void 0:s,filePath:o,fuzzy:i,limit:c});if(d.length===0)return {content:[{type:"text",text:`\u{1F50D} \u641C\u7D22 "${t}" \u65E0\u7ED3\u679C
313
319
 
314
320
  \u{1F4A1} \u5C1D\u8BD5:
315
321
  skimmer_find_by_behavior \u6309\u884C\u4E3A\u641C\u7D22
316
322
  \u4F8B\u5982: skimmer_find_by_behavior({ category: "storage" })`}]};let p=[`\u{1F50D} \u641C\u7D22 "${t}" \u2014 \u627E\u5230 ${d.length} \u4E2A\u7ED3\u679C
317
- `];return d.forEach((u,g)=>{let m=u.symbol,E=ie(m.params_json,[]),N=E.length>0?`(${E.join(", ")})`:"",y=te(m.start_line,m.end_line);p.push(`${g+1}. ${m.name}${N} [${m.category}/${m.framework}] \u5339\u914D\u5EA6: ${u.score}%`),p.push(` \u{1F4C4} ${u.filePath}:${y}`),p.push(` \u{1F3AF} ${u.matchReason}`),u.spellingSuggestion&&p.push(` \u{1F4A1} ${u.spellingSuggestion}`),m.default_value&&p.push(` \u{1F4CC} \u9ED8\u8BA4\u503C: ${m.default_value}`),p.push("");}),{content:[{type:"text",text:p.join(`
323
+ `];return d.forEach((f,m)=>{let g=f.symbol,h=ue(g.params_json,[]),N=h.length>0?`(${h.join(", ")})`:"",y=ce(g.start_line,g.end_line);p.push(`${m+1}. ${g.name}${N} [${g.category}/${g.framework}] \u5339\u914D\u5EA6: ${f.score}%`),p.push(` \u{1F4C4} ${f.filePath}:${y}`),p.push(` \u{1F3AF} ${f.matchReason}`),f.spellingSuggestion&&p.push(` \u{1F4A1} ${f.spellingSuggestion}`),g.default_value&&p.push(` \u{1F4CC} \u9ED8\u8BA4\u503C: ${g.default_value}`),p.push("");}),{content:[{type:"text",text:p.join(`
318
324
  `)}]}}),l.registerTool("skimmer_get_code_slice",{title:"\u83B7\u53D6\u7CBE\u51C6\u4EE3\u7801\u7247\u6BB5",description:`\u8FD4\u56DE\u6307\u5B9A\u51FD\u6570/\u53D8\u91CF\u7684\u5B8C\u6574\u4EE3\u7801\uFF0C\u907F\u514D\u8BFB\u53D6\u5927\u6587\u4EF6\u6D6A\u8D39 Token\u3002
319
325
  \u540C\u65F6\u8FD4\u56DE\u8BE5\u7B26\u53F7\u7684\u884C\u4E3A\u6807\u7B7E\uFF08\u64CD\u4F5C\u4E86\u54EA\u4E9B\u5916\u90E8 API\uFF09\u3002
320
- project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({file_path:z$1.string().describe("\u6587\u4EF6\u76F8\u5BF9\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u9879\u76EE\u6839\u76EE\u5F55\uFF09"),symbol_name:z$1.string().describe("\u51FD\u6570\u6216\u53D8\u91CF\u540D"),project_path:z$1.string().optional().describe(Y),context_lines:z$1.number().optional().default(0).describe("\u4E0A\u4E0B\u65B9\u989D\u5916\u5C55\u793A\u7684\u884C\u6570")}),annotations:{readOnlyHint:true,destructiveHint:false}},async({file_path:t,symbol_name:r,project_path:n,context_lines:s})=>{let{db:o}=e.getContext(n),i=o.getSymbolByName(r,t);if(!i)return {content:[{type:"text",text:`\u274C \u672A\u627E\u5230: ${r}
326
+ project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({file_path:z$1.string().describe("\u6587\u4EF6\u76F8\u5BF9\u8DEF\u5F84\uFF08\u76F8\u5BF9\u4E8E\u9879\u76EE\u6839\u76EE\u5F55\uFF09"),symbol_name:z$1.string().describe("\u51FD\u6570\u6216\u53D8\u91CF\u540D"),project_path:z$1.string().optional().describe(Z),context_lines:z$1.number().optional().default(0).describe("\u4E0A\u4E0B\u65B9\u989D\u5916\u5C55\u793A\u7684\u884C\u6570")}),annotations:{readOnlyHint:true,destructiveHint:false}},async({file_path:t,symbol_name:n,project_path:r,context_lines:s})=>{let{db:o}=e.getContext(r),i=o.getSymbolByName(n,t);if(!i)return {content:[{type:"text",text:`\u274C \u672A\u627E\u5230: ${n}
321
327
  \u{1F4C4} \u6587\u4EF6: ${t}
322
328
 
323
- \u{1F4A1} \u8BD5\u8BD5: skimmer_find_symbol({ query: "${r}" })`}]};let a=i.abs_path;if(!K.existsSync(a))return {content:[{type:"text",text:`\u274C \u6587\u4EF6\u4E0D\u5B58\u5728: ${a}`}]};let f=K.readFileSync(a,"utf-8").split(`
324
- `),d=Math.max(1,i.start_line-s)-1,p=Math.min(f.length,i.end_line+s),u=f.slice(d,p).join(`
325
- `),{behaviors:g}=o.getFileOutline(t),m=g.filter(h=>h.symbol_id===i.id),E=a.split(".").pop()||"js",N=["tsx","jsx"].includes(E)?"jsx":["ts"].includes(E)?"typescript":"javascript",y=[`\u{1F4CD} ${i.name} [${i.category}/${i.framework}]`,`\u{1F4C4} ${t}:${te(i.start_line,i.end_line)}`];if(i.jsdoc&&y.push(`\u{1F4DD} ${i.jsdoc}`),m.length>0){let h=[...new Set(m.map(b=>`[${b.category}:${b.api_name}.${b.operation}${b.detail?`("${b.detail}")`:""}]`))];y.push(`\u{1F3F7}\uFE0F \u884C\u4E3A: ${h.join(" ")}`);}return y.push(`
326
- \`\`\`${N}`),y.push(u),y.push("```"),{content:[{type:"text",text:y.join(`
329
+ \u{1F4A1} \u8BD5\u8BD5: skimmer_find_symbol({ query: "${n}" })`}]};let c=i.abs_path;if(!W.existsSync(c))return {content:[{type:"text",text:`\u274C \u6587\u4EF6\u4E0D\u5B58\u5728: ${c}`}]};let u=W.readFileSync(c,"utf-8").split(`
330
+ `),d=Math.max(1,i.start_line-s)-1,p=Math.min(u.length,i.end_line+s),f=u.slice(d,p).join(`
331
+ `),{behaviors:m}=o.getFileOutline(t),g=m.filter(b=>b.symbol_id===i.id),h=c.split(".").pop()||"js",N=["tsx","jsx"].includes(h)?"jsx":["ts"].includes(h)?"typescript":"javascript",y=[`\u{1F4CD} ${i.name} [${i.category}/${i.framework}]`,`\u{1F4C4} ${t}:${ce(i.start_line,i.end_line)}`];if(i.jsdoc&&y.push(`\u{1F4DD} ${i.jsdoc}`),g.length>0){let b=[...new Set(g.map(S=>`[${S.category}:${S.api_name}.${S.operation}${S.detail?`("${S.detail}")`:""}]`))];y.push(`\u{1F3F7}\uFE0F \u884C\u4E3A: ${b.join(" ")}`);}return y.push(`
332
+ \`\`\`${N}`),y.push(f),y.push("```"),{content:[{type:"text",text:y.join(`
327
333
  `)}]}}),l.registerTool("skimmer_trace_assignments",{title:"\u8FFD\u8E2A\u53D8\u91CF\u8D4B\u503C\u94FE\u8DEF\uFF08\u8F7B\u91CF\uFF09",description:`\u3010\u964D\u7EA7\u5DE5\u5177\u3011\u4EC5\u5728\u4EE5\u4E0B\u573A\u666F\u5355\u72EC\u4F7F\u7528\uFF1A\u53EA\u9700\u67E5\u770B\u67D0\u4E2A\u7B80\u5355\u53D8\u91CF\uFF08\u975E\u5BF9\u8C61\uFF09\u7684\u8D4B\u503C\u4F4D\u7F6E\uFF0C\u4E14\u4E0D\u5173\u5FC3\u5C5E\u6027\u4FEE\u6539/\u53C2\u6570\u4F20\u9012/storage\u94FE\u8DEF\u3002
328
334
  \u26A0\uFE0F \u7EDD\u5927\u591A\u6570\u53D8\u91CF\u6EAF\u6E90\u573A\u666F\u8BF7\u4F18\u5148\u4F7F\u7528 skimmer_trace_data_lifecycle\uFF0C\u5B83\u80FD\u4E00\u6B21\u62FF\u5230\u6240\u6709\u4FE1\u606F\u3002
329
335
  \u2705 \u672C\u5DE5\u5177\u9002\u5408\uFF1Aloading / errorMsg / count \u8FD9\u7C7B\u7B80\u5355 flag \u7684\u8D4B\u503C\u8FFD\u8E2A\u3002
330
- \u274C \u4E0D\u9002\u5408\uFF1AstorageParams / savedData \u8FD9\u7C7B\u5BF9\u8C61\u3001\u9700\u8981\u8FFD\u8E2A\u5B8C\u6574\u6570\u636E\u6D41\u7684\u573A\u666F\u3002`,inputSchema:z$1.object({variable:z$1.string().describe('\u53D8\u91CF\u540D\uFF0C\u5982 "changeResult"'),project_path:z$1.string().optional().describe(Y),file_path:z$1.string().optional().describe("\u9650\u5B9A\u6587\u4EF6\u8DEF\u5F84\uFF08\u5305\u542B\u5373\u53EF\uFF09"),include_properties:z$1.boolean().optional().default(true).describe("\u662F\u5426\u5305\u542B variable.xxx / variable[...] \u8D4B\u503C"),limit:z$1.number().optional().default(80)}),annotations:{readOnlyHint:true,destructiveHint:false}},async({variable:t,project_path:r,file_path:n,include_properties:s,limit:o})=>{let{db:i}=e.getContext(r),a=i.listFiles(n),c=Math.min(300,Math.max(1,o||80)),f=s??true,d=Xe(a,t,f,c);if(d.length===0){let u=Nt(t,f);d=ne(a,u,c);}if(d.length===0)return {content:[{type:"text",text:`\u{1F9E9} \u53D8\u91CF\u8D4B\u503C\u8FFD\u8E2A: "${t}"
331
- \u672A\u627E\u5230\u5339\u914D\u8D4B\u503C\u8BED\u53E5
332
- \u8FC7\u6EE4: file_path=${n||"*"} include_properties=${f}`}]};let p=[`\u{1F9E9} \u53D8\u91CF\u8D4B\u503C\u8FFD\u8E2A: "${t}"`,`\u8FC7\u6EE4: file_path=${n||"*"} include_properties=${f}`,`\u547D\u4E2D: ${d.length} \u5904`,""];return d.forEach((u,g)=>{p.push(`${g+1}. [${u.kind}] \u{1F4C4} ${u.filePath}:L${u.line}`),p.push(` ${u.text}`);}),{content:[{type:"text",text:p.join(`
336
+ \u274C \u4E0D\u9002\u5408\uFF1AstorageParams / savedData \u8FD9\u7C7B\u5BF9\u8C61\u3001\u9700\u8981\u8FFD\u8E2A\u5B8C\u6574\u6570\u636E\u6D41\u7684\u573A\u666F\u3002`,inputSchema:z$1.object({variable:z$1.string().describe('\u53D8\u91CF\u540D\uFF0C\u5982 "changeResult"'),project_path:z$1.string().optional().describe(Z),file_path:z$1.string().optional().describe("\u9650\u5B9A\u6587\u4EF6\u8DEF\u5F84\uFF08\u5305\u542B\u5373\u53EF\uFF09"),include_properties:z$1.boolean().optional().default(true).describe("\u662F\u5426\u5305\u542B variable.xxx / variable[...] \u8D4B\u503C"),limit:z$1.number().optional().default(80)}),annotations:{readOnlyHint:true,destructiveHint:false}},async({variable:t,project_path:n,file_path:r,include_properties:s,limit:o})=>{let{db:i}=e.getContext(n),c=i.listFiles(r),a=Math.min(300,Math.max(1,o||80)),u=s??true,d=i.exactSearch(t,"state",void 0,r||void 0),p={vue2:"Vue2 data()",vue3:"Vue3 ref/reactive",react:"React useState/useRef"},f=d.filter(y=>y.default_value!=null).map(y=>({filePath:y.file_path,line:y.start_line,kind:`data_init(${p[y.framework]||y.framework})`,text:`${y.name}: ${y.default_value} \u2190 \u58F0\u660E\u521D\u59CB\u5316`})),m=st(c,t,u,a);if(m.length===0){let y=Ct(t,u);m=pe(c,y,a);}let g=new Map;for(let y of [...f,...m]){let b=`${y.filePath}:${y.line}`;g.has(b)||g.set(b,y);}let h=[...g.values()];if(h.length===0)return {content:[{type:"text",text:`\u{1F9E9} \u53D8\u91CF\u8D4B\u503C\u8FFD\u8E2A: "${t}"
337
+ \u672A\u627E\u5230\u5339\u914D\u8D4B\u503C\u8BED\u53E5\uFF08\u5305\u62EC\u58F0\u660E\u521D\u59CB\u5316\uFF09
338
+ \u8FC7\u6EE4: file_path=${r||"*"} include_properties=${u}`}]};let N=[`\u{1F9E9} \u53D8\u91CF\u8D4B\u503C\u8FFD\u8E2A: "${t}"`,`\u8FC7\u6EE4: file_path=${r||"*"} include_properties=${u}`,`\u547D\u4E2D: ${h.length} \u5904${f.length>0?`\uFF08\u542B ${f.length} \u5904\u58F0\u660E\u521D\u59CB\u5316\uFF09`:""}`,""];return h.forEach((y,b)=>{N.push(`${b+1}. [${y.kind}] \u{1F4C4} ${y.filePath}:L${y.line}`),N.push(` ${y.text}`);}),{content:[{type:"text",text:N.join(`
333
339
  `)}]}}),l.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
334
340
  \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
335
341
  \u2705 \u672C\u5DE5\u5177\u9002\u5408\uFF1Aobject.specificProp \u7684\u5355\u5B57\u6BB5\u7EA7\u522B\u7CBE\u786E\u8FFD\u8E2A\u3002
336
- \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(Y),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:r,project_path:n,file_path:s,limit:o})=>{let{db:i}=e.getContext(n),a=i.listFiles(s),c=Math.min(300,Math.max(1,o||80)),f=ze(a,t,r,c);if(f.length===0){let p=pe(t),u="(?:=|\\+=|-=|\\*=|/=|%=|\\|=|&=|\\^=|&&=|\\|\\|=|\\?\\?=)",g=[];if(r){let m=pe(r);g.push({kind:"dot",regex:new RegExp(`\\b${p}\\.${m}\\s*${u}`)},{kind:"bracket",regex:new RegExp(`\\b${p}\\s*\\[(?:'${m}'|"${m}")\\]\\s*${u}`)},{kind:"delete",regex:new RegExp(`\\bdelete\\s+${p}\\.(?:${m})\\b`)});}else g.push({kind:"dot",regex:new RegExp(`\\b${p}\\.[A-Za-z_$][\\w$]*\\s*${u}`)},{kind:"bracket",regex:new RegExp(`\\b${p}\\s*\\[(?:'[^']+'|"[^"]+")\\]\\s*${u}`)},{kind:"delete",regex:new RegExp(`\\bdelete\\s+${p}\\.[A-Za-z_$][\\w$]*\\b`)});f=ne(a,g,c);}if(f.length===0)return {content:[{type:"text",text:`\u{1F9ED} \u5C5E\u6027\u4FEE\u6539\u8FFD\u8E2A: ${t}${r?`.${r}`:".*"}
337
- \u672A\u627E\u5230\u5339\u914D\u8BED\u53E5
338
- \u8FC7\u6EE4: file_path=${s||"*"}`}]};let d=[`\u{1F9ED} \u5C5E\u6027\u4FEE\u6539\u8FFD\u8E2A: ${t}${r?`.${r}`:".*"}`,`\u8FC7\u6EE4: file_path=${s||"*"}`,`\u547D\u4E2D: ${f.length} \u5904`,""];return f.forEach((p,u)=>{d.push(`${u+1}. [${p.kind}] \u{1F4C4} ${p.filePath}:L${p.line}`),d.push(` ${p.text}`);}),{content:[{type:"text",text:d.join(`
342
+ \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(Z),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{db:i}=e.getContext(r),c=i.listFiles(s),a=Math.min(300,Math.max(1,o||80)),u=jt(c,t,20),d=Ft(c,t,20),p=[...new Set([...u.map(h=>h.alias),...d.map(h=>h.alias)].filter(h=>h!==t))],f=[t,...p],m=Oe(c,t,n,a);for(let h of p)m.push(...Oe(c,h,n,Math.floor(a/2)));if(m.length===0){let h="(?:=|\\+=|-=|\\*=|/=|%=|\\|=|&=|\\^=|&&=|\\|\\|=|\\?\\?=)",N=[];for(let y of f){let b=he(y);if(n){let S=he(n);N.push({kind:"dot",regex:new RegExp(`\\b${b}\\.${S}\\s*${h}`)},{kind:"bracket",regex:new RegExp(`\\b${b}\\s*\\[(?:'${S}'|"${S}")\\]\\s*${h}`)},{kind:"delete",regex:new RegExp(`\\bdelete\\s+${b}\\.(?:${S})\\b`)});}else N.push({kind:"dot",regex:new RegExp(`\\b${b}\\.[A-Za-z_$][\\w$]*\\s*${h}`)},{kind:"bracket",regex:new RegExp(`\\b${b}\\s*\\[(?:'[^']+'|"[^"]+")\\]\\s*${h}`)},{kind:"delete",regex:new RegExp(`\\bdelete\\s+${b}\\.[A-Za-z_$][\\w$]*\\b`)});}m=pe(c,N,a);}if(m.length===0){let h=p.length>0?`
343
+ \u522B\u540D\u5C55\u5F00: ${p.join(", ")}\uFF08\u5747\u672A\u547D\u4E2D\uFF09`:"";return {content:[{type:"text",text:`\u{1F9ED} \u5C5E\u6027\u4FEE\u6539\u8FFD\u8E2A: ${t}${n?`.${n}`:".*"}
344
+ \u672A\u627E\u5230\u5339\u914D\u8BED\u53E5${h}
345
+ \u8FC7\u6EE4: file_path=${s||"*"}`}]}}let g=[`\u{1F9ED} \u5C5E\u6027\u4FEE\u6539\u8FFD\u8E2A: ${t}${n?`.${n}`:".*"}`,`\u8FC7\u6EE4: file_path=${s||"*"}`];if(p.length>0){let h=u.map(y=>y.alias).filter(y=>y!==t).join(", "),N=d.map(y=>y.alias).filter(y=>y!==t).join(", ");h&&g.push(`\u26A1 \u5F15\u7528\u522B\u540D: ${h}\uFF08\u901A\u8FC7 let alias = this.${t} \u5C55\u5F00\uFF09`),N&&g.push(`\u26A1 \u89E3\u6784\u522B\u540D: ${N}\uFF08\u901A\u8FC7 const { ${t}: alias } \u5C55\u5F00\uFF09`);}return g.push(`\u547D\u4E2D: ${m.length} \u5904`,""),m.forEach((h,N)=>{g.push(`${N+1}. [${h.kind}] \u{1F4C4} ${h.filePath}:L${h.line}`),g.push(` ${h.text}`);}),{content:[{type:"text",text:g.join(`
339
346
  `)}]}}),l.registerTool("skimmer_find_by_behavior",{title:"\u6309\u884C\u4E3A\u6807\u7B7E\u641C\u7D22\u51FD\u6570",description:`\u6309 API \u8C03\u7528\u884C\u4E3A\u641C\u7D22\uFF0C\u5B8C\u5168\u7ED5\u8FC7\u547D\u540D\u95EE\u9898\u3002
340
347
  \u793A\u4F8B:
341
348
  - \u627E\u6240\u6709\u64CD\u4F5C localStorage \u7684\u51FD\u6570: { category: "storage" }
@@ -343,20 +350,20 @@ project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({file_path:z$1.str
343
350
  - \u627E\u53D1\u8BF7\u6C42\u7684: { category: "network" }
344
351
  - \u627E\u8DEF\u7531\u8DF3\u8F6C\u7684: { category: "router" }
345
352
  - \u6309 key \u540D\u641C\u7D22: { keyword: "cacheData" }
346
- project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({project_path:z$1.string().optional().describe(Y),category:z$1.enum(["storage","network","router","vuex","dom","event","timer","i18n"]).optional().describe("\u884C\u4E3A\u7C7B\u522B"),api_name:z$1.string().optional().describe('"localStorage" / "axios" / "$router"'),operation:z$1.string().optional().describe('"setItem" / "get" / "push" / "commit"'),keyword:z$1.string().optional().describe('\u5728\u53C2\u6570\u503C\u4E2D\u641C\u7D22\uFF08\u5982 key \u540D "cacheData"\uFF09'),file_path:z$1.string().optional().describe('\u9650\u5B9A\u6587\u4EF6\u8DEF\u5F84\u641C\u7D22\uFF08\u5305\u542B\u5373\u53EF\uFF0C\u5982 "src/views/apply/index.vue"\uFF09')}),annotations:{readOnlyHint:true,destructiveHint:false}},async({project_path:t,category:r,api_name:n,operation:s,keyword:o,file_path:i})=>{let{db:a}=e.getContext(t),f=new le(a).searchByBehavior({category:r,apiName:n,operation:s,keyword:o,filePath:i});if(f.length===0)return {content:[{type:"text",text:`\u{1F3F7}\uFE0F \u672A\u627E\u5230\u5339\u914D\u7684\u884C\u4E3A
347
- \u8FC7\u6EE4\u6761\u4EF6: ${JSON.stringify({category:r,api_name:n,operation:s,keyword:o,file_path:i})}`}]};let d=new Map;for(let u of f){let g=`${u.category}:${u.apiName}`;d.has(g)||d.set(g,[]),d.get(g).push(u);}let p=[`\u{1F3F7}\uFE0F \u884C\u4E3A\u641C\u7D22\u7ED3\u679C \u2014 ${f.length} \u6761
348
- `];for(let[u,g]of d){let[m,E]=u.split(":"),N=new Map;for(let y of g)N.has(y.operation)||N.set(y.operation,[]),N.get(y.operation).push(y);p.push(`\u{1F4C2} ${m} \u2192 ${E}:`);for(let[y,h]of N){p.push(` ${y}:`);for(let b of h){let T=b.detail?` key="${b.detail}"`:"";p.push(` \u2022 ${b.symbolName}${T} \u{1F4C4} ${b.filePath}:${te(b.startLine,b.endLine)}`);}}p.push("");}return {content:[{type:"text",text:p.join(`
349
- `)}]}}),l.registerTool("skimmer_get_call_graph",{title:"\u83B7\u53D6\u51FD\u6570\u8C03\u7528\u5173\u7CFB\u56FE\u8C31",description:"\u67E5\u770B\u51FD\u6570\u88AB\u8C01\u8C03\u7528\uFF08callers\uFF09\u4EE5\u53CA\u5B83\u8C03\u7528\u4E86\u4EC0\u4E48\uFF08callees\uFF09\u3002project_path \u53EF\u7701\u7565\u3002",inputSchema:z$1.object({symbol_name:z$1.string().describe("\u51FD\u6570\u540D"),project_path:z$1.string().optional().describe(Y),file_path:z$1.string().optional().describe("\u6587\u4EF6\u8DEF\u5F84\uFF08\u540C\u540D\u51FD\u6570\u65F6\u7528\u4E8E\u7CBE\u786E\u5B9A\u4F4D\uFF09"),direction:z$1.enum(["callers","callees","both"]).optional().default("both"),arg_keyword:z$1.string().optional().describe('\u8C03\u7528\u53C2\u6570\u5173\u952E\u5B57\u8FC7\u6EE4\uFF08\u5982 "storageParams"\uFF09')}),annotations:{readOnlyHint:true,destructiveHint:false}},async({symbol_name:t,project_path:r,file_path:n,direction:s,arg_keyword:o})=>{let{db:i}=e.getContext(r),a=i.getSymbolByName(t,n),c=[`\u{1F4CA} ${t} \u7684\u8C03\u7528\u56FE\u8C31
350
- `];if(s==="callers"||s==="both"){let f=i.getCallers(t,n,o);if(c.push(`\u2B06\uFE0F \u88AB\u8C03\u7528 (${f.length} \u5904):`),f.length===0)c.push(" \uFF08\u672A\u627E\u5230\u8C03\u7528\u8005\uFF09");else for(let d of f){let p=d.args?` \u53C2\u6570: "${d.args}"`:"";c.push(` \u2022 ${d.caller_name} [${d.category}] \u{1F4C4} ${d.file_path}:L${d.start_line}${p}`);}c.push("");}if((s==="callees"||s==="both")&&a){let f=i.getCallees(a.id);if(c.push(`\u2B07\uFE0F \u8C03\u7528\u4E86 (${f.length} \u4E2A):`),f.length===0)c.push(" \uFF08\u672A\u5206\u6790\u5230\u8C03\u7528\u5173\u7CFB\uFF09");else for(let d of f){let p=d.args?`("${d.args}")`:"";c.push(` \u2022 ${d.callee_name}${p} [${d.call_type}] L${d.line_number}`);}c.push("");}if(a){let{behaviors:f}=i.getFileOutline(a.file_path),d=f.filter(p=>p.symbol_id===a.id);if(d.length>0){c.push("\u{1F4E6} \u5916\u90E8\u72B6\u6001\u64CD\u4F5C:");for(let p of d){let u=p.detail?` ("${p.detail}")`:"";c.push(` \u2022 ${p.api_name}.${p.operation}${u} [${p.category}] L${p.line_number}`);}}}return {content:[{type:"text",text:c.join(`
351
- `)}]}}),l.registerTool("skimmer_get_blast_radius",{title:"\u8BC4\u4F30\u4FEE\u6539\u5F71\u54CD\u8303\u56F4",description:"\u5206\u6790\u4FEE\u6539\u67D0\u51FD\u6570\u4F1A\u5F71\u54CD\u54EA\u4E9B\u8C03\u7528\u70B9\uFF0C\u7ED9\u51FA\u98CE\u9669\u7B49\u7EA7\u3002\u4FEE\u6539\u524D\u8C03\u7528\u8BC4\u4F30\u98CE\u9669\u3002project_path \u53EF\u7701\u7565\u3002",inputSchema:z$1.object({symbol_name:z$1.string().describe("\u8981\u4FEE\u6539\u7684\u51FD\u6570\u540D"),project_path:z$1.string().optional().describe(Y),file_path:z$1.string().optional().describe("\u6587\u4EF6\u8DEF\u5F84\uFF08\u540C\u540D\u65F6\u7CBE\u786E\u5B9A\u4F4D\uFF09")}),annotations:{readOnlyHint:true,destructiveHint:false}},async({symbol_name:t,project_path:r,file_path:n})=>{let{db:s}=e.getContext(r),o=s.getCallers(t,n),i=s.getSymbolByName(t,n),{behaviors:a}=i?s.getFileOutline(i.file_path):{behaviors:[]},c=i?a.filter(u=>u.symbol_id===i.id):[],f=o.length===0?"\u{1F7E2}":o.length<=3?"\u{1F7E1}":"\u{1F534}",d=o.length===0?"\u4F4E":o.length<=3?"\u4E2D":"\u9AD8",p=[`\u{1F4A5} \u4FEE\u6539 ${t} \u7684\u5F71\u54CD\u8BC4\u4F30`,"\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",`${f} \u98CE\u9669\u7B49\u7EA7: ${d} (${o.length} \u5904\u76F4\u63A5\u8C03\u7528)`,""];if(o.length>0?(p.push("\u{1F534} \u76F4\u63A5\u5F71\u54CD:"),o.forEach((u,g)=>{p.push(` ${g+1}. ${u.caller_name} [${u.category}] \u{1F4C4} ${u.file_path}:L${u.start_line}`);}),p.push("")):p.push(`\u2705 \u65E0\u8C03\u7528\u8005\uFF0C\u5F71\u54CD\u8303\u56F4\u53EF\u63A7
352
- `),c.length>0){p.push("\u{1F4E6} \u5916\u90E8\u72B6\u6001\u5F71\u54CD:");for(let u of c)p.push(` \u2022 ${u.api_name}.${u.operation}${u.detail?` key="${u.detail}"`:""} [${u.category}]`);p.push(`
353
+ project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({project_path:z$1.string().optional().describe(Z),category:z$1.enum(["storage","network","router","vuex","dom","event","timer","i18n"]).optional().describe("\u884C\u4E3A\u7C7B\u522B"),api_name:z$1.string().optional().describe('"localStorage" / "axios" / "$router"'),operation:z$1.string().optional().describe('"setItem" / "get" / "push" / "commit"'),keyword:z$1.string().optional().describe('\u5728\u53C2\u6570\u503C\u4E2D\u641C\u7D22\uFF08\u5982 key \u540D "cacheData"\uFF09'),file_path:z$1.string().optional().describe('\u9650\u5B9A\u6587\u4EF6\u8DEF\u5F84\u641C\u7D22\uFF08\u5305\u542B\u5373\u53EF\uFF0C\u5982 "src/views/apply/index.vue"\uFF09')}),annotations:{readOnlyHint:true,destructiveHint:false}},async({project_path:t,category:n,api_name:r,operation:s,keyword:o,file_path:i})=>{let{db:c}=e.getContext(t),u=new ge(c).searchByBehavior({category:n,apiName:r,operation:s,keyword:o,filePath:i}),d=new Set(["localStorage","sessionStorage","cookie"]);if(r||(u=u.filter(m=>m.category!=="storage"||d.has(m.apiName.toLowerCase()))),u.length===0)return {content:[{type:"text",text:`\u{1F3F7}\uFE0F \u672A\u627E\u5230\u5339\u914D\u7684\u884C\u4E3A
354
+ \u8FC7\u6EE4\u6761\u4EF6: ${JSON.stringify({category:n,api_name:r,operation:s,keyword:o,file_path:i})}`}]};let p=new Map;for(let m of u){let g=`${m.category}:${m.apiName}`;p.has(g)||p.set(g,[]),p.get(g).push(m);}let f=[`\u{1F3F7}\uFE0F \u884C\u4E3A\u641C\u7D22\u7ED3\u679C \u2014 ${u.length} \u6761
355
+ `];for(let[m,g]of p){let[h,N]=m.split(":"),y=new Map;for(let b of g)y.has(b.operation)||y.set(b.operation,[]),y.get(b.operation).push(b);f.push(`\u{1F4C2} ${h} \u2192 ${N}:`);for(let[b,S]of y){f.push(` ${b}:`);let v=new Map;for(let T of S){let P=`${T.symbolName}|${T.filePath}`;v.has(P)||v.set(P,{item:T,callLines:[]}),v.get(P).callLines.push(T.line);}for(let{item:T,callLines:P}of v.values()){let I=T.detail?` key="${T.detail}"`:"",O=P.length>1?` \xD7${P.length} (L${P.join(", L")})`:` L${P[0]||T.startLine}`;f.push(` \u2022 ${T.symbolName}${I}${O} \u{1F4C4} ${T.filePath}:${ce(T.startLine,T.endLine)}`);}}f.push("");}return {content:[{type:"text",text:f.join(`
356
+ `)}]}}),l.registerTool("skimmer_get_call_graph",{title:"\u83B7\u53D6\u51FD\u6570\u8C03\u7528\u5173\u7CFB\u56FE\u8C31",description:"\u67E5\u770B\u51FD\u6570\u88AB\u8C01\u8C03\u7528\uFF08callers\uFF09\u4EE5\u53CA\u5B83\u8C03\u7528\u4E86\u4EC0\u4E48\uFF08callees\uFF09\u3002project_path \u53EF\u7701\u7565\u3002",inputSchema:z$1.object({symbol_name:z$1.string().describe("\u51FD\u6570\u540D"),project_path:z$1.string().optional().describe(Z),file_path:z$1.string().optional().describe("\u6587\u4EF6\u8DEF\u5F84\uFF08\u540C\u540D\u51FD\u6570\u65F6\u7528\u4E8E\u7CBE\u786E\u5B9A\u4F4D\uFF09"),direction:z$1.enum(["callers","callees","both"]).optional().default("both"),arg_keyword:z$1.string().optional().describe('\u8C03\u7528\u53C2\u6570\u5173\u952E\u5B57\u8FC7\u6EE4\uFF08\u5982 "storageParams"\uFF09')}),annotations:{readOnlyHint:true,destructiveHint:false}},async({symbol_name:t,project_path:n,file_path:r,direction:s,arg_keyword:o})=>{let{db:i}=e.getContext(n),c=i.getSymbolByName(t,r),a=[`\u{1F4CA} ${t} \u7684\u8C03\u7528\u56FE\u8C31
357
+ `];if(s==="callers"||s==="both"){let u=i.getCallers(t,r,o);if(a.push(`\u2B06\uFE0F \u88AB\u8C03\u7528 (${u.length} \u5904):`),u.length===0)a.push(" \uFF08\u672A\u627E\u5230\u8C03\u7528\u8005\uFF09");else for(let d of u){let p=d.args?` \u53C2\u6570: "${d.args}"`:"",f=d.call_type==="template_event"?" \u{1F5BC}\uFE0F [\u6A21\u677F\u4E8B\u4EF6\u5165\u53E3]":d.call_type==="jsx_event"?" \u269B\uFE0F [JSX\u4E8B\u4EF6\u5165\u53E3]":"";a.push(` \u2022 ${d.caller_name} [${d.category}]${f} \u{1F4C4} ${d.file_path}:L${d.start_line}${p}`);}a.push("");}if((s==="callees"||s==="both")&&c){let u=i.getCallees(c.id);if(a.push(`\u2B07\uFE0F \u8C03\u7528\u4E86 (${u.length} \u4E2A):`),u.length===0)a.push(" \uFF08\u672A\u5206\u6790\u5230\u8C03\u7528\u5173\u7CFB\uFF09");else for(let d of u){let p=d.args?`("${d.args}")`:"";a.push(` \u2022 ${d.callee_name}${p} [${d.call_type}] L${d.line_number}`);}a.push("");}if(c){let{behaviors:u}=i.getFileOutline(c.file_path),d=u.filter(p=>p.symbol_id===c.id);if(d.length>0){a.push("\u{1F4E6} \u5916\u90E8\u72B6\u6001\u64CD\u4F5C:");for(let p of d){let f=p.detail?` ("${p.detail}")`:"";a.push(` \u2022 ${p.api_name}.${p.operation}${f} [${p.category}] L${p.line_number}`);}}}return {content:[{type:"text",text:a.join(`
358
+ `)}]}}),l.registerTool("skimmer_get_blast_radius",{title:"\u8BC4\u4F30\u4FEE\u6539\u5F71\u54CD\u8303\u56F4",description:"\u5206\u6790\u4FEE\u6539\u67D0\u51FD\u6570\u4F1A\u5F71\u54CD\u54EA\u4E9B\u8C03\u7528\u70B9\uFF0C\u7ED9\u51FA\u98CE\u9669\u7B49\u7EA7\u3002\u4FEE\u6539\u524D\u8C03\u7528\u8BC4\u4F30\u98CE\u9669\u3002project_path \u53EF\u7701\u7565\u3002",inputSchema:z$1.object({symbol_name:z$1.string().describe("\u8981\u4FEE\u6539\u7684\u51FD\u6570\u540D"),project_path:z$1.string().optional().describe(Z),file_path:z$1.string().optional().describe("\u6587\u4EF6\u8DEF\u5F84\uFF08\u540C\u540D\u65F6\u7CBE\u786E\u5B9A\u4F4D\uFF09")}),annotations:{readOnlyHint:true,destructiveHint:false}},async({symbol_name:t,project_path:n,file_path:r})=>{let{db:s}=e.getContext(n),o=s.getCallers(t,r),i=s.getSymbolByName(t,r),{behaviors:c}=i?s.getFileOutline(i.file_path):{behaviors:[]},a=i?c.filter(f=>f.symbol_id===i.id):[],u=o.length===0?"\u{1F7E2}":o.length<=3?"\u{1F7E1}":"\u{1F534}",d=o.length===0?"\u4F4E":o.length<=3?"\u4E2D":"\u9AD8",p=[`\u{1F4A5} \u4FEE\u6539 ${t} \u7684\u5F71\u54CD\u8BC4\u4F30`,"\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",`${u} \u98CE\u9669\u7B49\u7EA7: ${d} (${o.length} \u5904\u76F4\u63A5\u8C03\u7528)`,""];if(o.length>0?(p.push("\u{1F534} \u76F4\u63A5\u5F71\u54CD:"),o.forEach((f,m)=>{let g=f.call_type==="template_event"?" \u{1F5BC}\uFE0F [\u6A21\u677F\u4E8B\u4EF6\u5165\u53E3]":f.call_type==="jsx_event"?" \u269B\uFE0F [JSX\u4E8B\u4EF6\u5165\u53E3]":"";p.push(` ${m+1}. ${f.caller_name} [${f.category}]${g} \u{1F4C4} ${f.file_path}:L${f.start_line}`);}),p.push("")):p.push(`\u2705 \u65E0\u8C03\u7528\u8005\uFF0C\u5F71\u54CD\u8303\u56F4\u53EF\u63A7
359
+ `),a.length>0){p.push("\u{1F4E6} \u5916\u90E8\u72B6\u6001\u5F71\u54CD:");for(let f of a)p.push(` \u2022 ${f.api_name}.${f.operation}${f.detail?` key="${f.detail}"`:""} [${f.category}]`);p.push(`
353
360
  \u26A0\uFE0F \u4FEE\u6539\u65F6\u6CE8\u610F\u5916\u90E8\u72B6\u6001\u7684\u8BFB\u5199\u683C\u5F0F\u4FDD\u6301\u4E00\u81F4`);}return {content:[{type:"text",text:p.join(`
354
361
  `)}]}}),l.registerTool("skimmer_get_project_overview",{title:"\u83B7\u53D6\u9879\u76EE\u6574\u4F53\u6982\u89C8",description:`\u8FD4\u56DE\u9879\u76EE\u7684\u5168\u666F\u7EDF\u8BA1\uFF1A\u6587\u4EF6\u6570\u3001\u6846\u67B6\u5206\u5E03\u3001\u6700\u5927\u6587\u4EF6\u3001\u884C\u4E3A\u7EDF\u8BA1\u3002
355
- \u652F\u6301\u5217\u51FA\u5F53\u524D\u6240\u6709\u5DF2\u7F13\u5B58\u7684\u9879\u76EE\u3002project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({project_path:z$1.string().optional().describe(Y),list_all_projects:z$1.boolean().optional().default(false).describe("\u662F\u5426\u5217\u51FA\u6240\u6709\u5DF2\u7D22\u5F15\u7684\u9879\u76EE")}),annotations:{readOnlyHint:true,destructiveHint:false}},async({project_path:t,list_all_projects:r})=>{if(r){let d=e.listProjects();if(d.length===0)return {content:[{type:"text",text:`\u{1F4CB} \u5F53\u524D\u6CA1\u6709\u5DF2\u7D22\u5F15\u7684\u9879\u76EE
362
+ \u652F\u6301\u5217\u51FA\u5F53\u524D\u6240\u6709\u5DF2\u7F13\u5B58\u7684\u9879\u76EE\u3002project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({project_path:z$1.string().optional().describe(Z),list_all_projects:z$1.boolean().optional().default(false).describe("\u662F\u5426\u5217\u51FA\u6240\u6709\u5DF2\u7D22\u5F15\u7684\u9879\u76EE")}),annotations:{readOnlyHint:true,destructiveHint:false}},async({project_path:t,list_all_projects:n})=>{if(n){let d=e.listProjects();if(d.length===0)return {content:[{type:"text",text:`\u{1F4CB} \u5F53\u524D\u6CA1\u6709\u5DF2\u7D22\u5F15\u7684\u9879\u76EE
356
363
 
357
364
  \u4F7F\u7528 skimmer_index_project({ project_path: "/your/project" }) \u5F00\u59CB\u7D22\u5F15`}]};let p=[`\u{1F4CB} \u5DF2\u7D22\u5F15\u7684\u9879\u76EE (${d.length} \u4E2A):
358
- `];return d.forEach((u,g)=>{p.push(`${g+1}. ${u.root}`),p.push(` \u6570\u636E\u5E93: ${u.dbPath}`);}),{content:[{type:"text",text:p.join(`
359
- `)}]}}let{db:n,projectRoot:s}=e.getContext(t),o=n.getProjectStats(),i=["\u{1F4CA} \u9879\u76EE\u6982\u89C8","\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",`\u{1F4C1} ${s}`,"",`\u{1F4C8} \u6574\u4F53: \u6587\u4EF6 ${o.fileCount} | \u7B26\u53F7 ${o.symbolCount} | \u884C\u4E3A\u6807\u7B7E ${o.behaviorCount} | \u8C03\u7528\u5173\u7CFB ${o.relationCount}`,""],a=o.frameworkBreakdown;if(a?.length){let d={vue2:"\u{1F7E2} Vue2",vue3:"\u{1F535} Vue3",react:"\u269B\uFE0F React",js:"\u{1F4DC} JS",ts:"\u{1F4D8} TS"};i.push("\u{1F527} \u6846\u67B6\u5206\u5E03:");for(let p of a)i.push(` ${d[p.framework]||p.framework}: ${p.count} \u4E2A`);i.push("");}let c=o.topFiles;c?.length&&(i.push("\u{1F5C2}\uFE0F Top 10 \u6700\u5927\u6587\u4EF6:"),c.forEach((d,p)=>i.push(` ${p+1}. ${d.path} (${d.line_count} \u884C, ${d.symbol_count} \u7B26\u53F7)`)),i.push(""));let f=o.behaviorStats;if(f?.length){let d={storage:"\u{1F4BE} \u5B58\u50A8",network:"\u{1F310} \u7F51\u7EDC",router:"\u{1F6E3}\uFE0F \u8DEF\u7531",vuex:"\u{1F4E6} Vuex",dom:"\u{1F5A5}\uFE0F DOM",event:"\u{1F4E1} \u4E8B\u4EF6",timer:"\u23F1\uFE0F \u5B9A\u65F6\u5668",i18n:"\u{1F30D} \u56FD\u9645\u5316"};i.push("\u{1F3F7}\uFE0F \u884C\u4E3A\u7EDF\u8BA1:");for(let p of f)i.push(` ${d[p.category]||p.category}: ${p.count} \u5904`);i.push("");}return i.push(`\u{1F4BD} \u6570\u636E\u5E93: ${Math.round(o.dbSize/1024)} KB`),{content:[{type:"text",text:i.join(`
365
+ `];return d.forEach((f,m)=>{p.push(`${m+1}. ${f.root}`),p.push(` \u6570\u636E\u5E93: ${f.dbPath}`);}),{content:[{type:"text",text:p.join(`
366
+ `)}]}}let{db:r,projectRoot:s}=e.getContext(t),o=r.getProjectStats(),i=["\u{1F4CA} \u9879\u76EE\u6982\u89C8","\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",`\u{1F4C1} ${s}`,"",`\u{1F4C8} \u6574\u4F53: \u6587\u4EF6 ${o.fileCount} | \u7B26\u53F7 ${o.symbolCount} | \u884C\u4E3A\u6807\u7B7E ${o.behaviorCount} | \u8C03\u7528\u5173\u7CFB ${o.relationCount}`,""],c=o.frameworkBreakdown;if(c?.length){let d={vue2:"\u{1F7E2} Vue2",vue3:"\u{1F535} Vue3",react:"\u269B\uFE0F React",js:"\u{1F4DC} JS",ts:"\u{1F4D8} TS"};i.push("\u{1F527} \u6846\u67B6\u5206\u5E03:");for(let p of c)i.push(` ${d[p.framework]||p.framework}: ${p.count} \u4E2A`);i.push("");}let a=o.topFiles;a?.length&&(i.push("\u{1F5C2}\uFE0F Top 10 \u6700\u5927\u6587\u4EF6:"),a.forEach((d,p)=>i.push(` ${p+1}. ${d.path} (${d.line_count} \u884C, ${d.symbol_count} \u7B26\u53F7)`)),i.push(""));let u=o.behaviorStats;if(u?.length){let d={storage:"\u{1F4BE} \u5B58\u50A8",network:"\u{1F310} \u7F51\u7EDC",router:"\u{1F6E3}\uFE0F \u8DEF\u7531",vuex:"\u{1F4E6} Vuex",dom:"\u{1F5A5}\uFE0F DOM",event:"\u{1F4E1} \u4E8B\u4EF6",timer:"\u23F1\uFE0F \u5B9A\u65F6\u5668",i18n:"\u{1F30D} \u56FD\u9645\u5316"};i.push("\u{1F3F7}\uFE0F \u884C\u4E3A\u7EDF\u8BA1:");for(let p of u)i.push(` ${d[p.category]||p.category}: ${p.count} \u5904`);i.push("");}return i.push(`\u{1F4BD} \u6570\u636E\u5E93: ${Math.round(o.dbSize/1024)} KB`),{content:[{type:"text",text:i.join(`
360
367
  `)}]}}),l.registerTool("skimmer_trace_data_lifecycle",{title:"\u53D8\u91CF\u5B8C\u6574\u751F\u547D\u5468\u671F\u8FFD\u8E2A\uFF08\u4E00\u952E\u7248\uFF09",description:`\u2B50 \u3010\u9996\u9009\u5DE5\u5177\u3011\u8FFD\u8E2A\u53D8\u91CF/\u72B6\u6001\u7684\u5B8C\u6574\u6570\u636E\u751F\u547D\u5468\u671F\uFF0C\u4E00\u6B21\u8C03\u7528\u805A\u5408 4 \u4E2A\u7EF4\u5EA6\uFF0C\u66FF\u4EE3\u8FC7\u53BB\u591A\u6B65\u624B\u52A8\u8FFD\u8E2A\u3002
361
368
 
362
369
  \u{1F3AF} \u89E6\u53D1\u89C4\u5219\uFF08\u9047\u5230\u4EE5\u4E0B\u4EFB\u610F\u4E00\u79CD\u95EE\u9898\uFF0C\u76F4\u63A5\u4F7F\u7528\u672C\u5DE5\u5177\uFF09\uFF1A
@@ -375,14 +382,15 @@ project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({project_path:z$1.
375
382
  \u65E7\u65B9\u5F0F: trace_assignments \u2192 find_symbol \u2192 get_code_slice \u2192 find_by_behavior \u2192 trace_key_flow
376
383
  \u65B0\u65B9\u5F0F: skimmer_trace_data_lifecycle({ variable: "xxx" }) \u2190 \u76F4\u63A5\u5F97\u5230\u5168\u90E8
377
384
 
378
- project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({variable:z$1.string().describe('\u8981\u8FFD\u8E2A\u7684\u53D8\u91CF\u540D\u6216 key\uFF0C\u5982 "storageParams" / "savedData"'),project_path:z$1.string().optional().describe(Y),file_path:z$1.string().optional().describe('\u9650\u5B9A\u6587\u4EF6\u8DEF\u5F84\uFF08\u5305\u542B\u5373\u53EF\uFF0C\u5982 "src/views/apply/index.vue"\uFF09'),storage_api:z$1.enum(["localStorage","sessionStorage","all"]).optional().default("all").describe("storage \u843D\u70B9\u8FC7\u6EE4"),max_depth:z$1.number().optional().default(2).describe("storage \u94FE\u8DEF\u5411\u4E0B\u8FFD\u8E2A\u6DF1\u5EA6\uFF081-5\uFF09"),limit:z$1.number().optional().default(40).describe("\u6BCF\u7EF4\u5EA6\u6700\u5927\u7ED3\u679C\u6570")}),annotations:{readOnlyHint:true,destructiveHint:false}},async({variable:t,project_path:r,file_path:n,storage_api:s,max_depth:o,limit:i})=>{let{db:a}=e.getContext(r),c=Math.min(5,Math.max(1,o||2)),f=Math.min(120,Math.max(1,i||40)),d=a.listFiles(n),p=pr(d,t,20),u=[...new Set(p.map(S=>S.alias).filter(S=>S!==t))],g=[t,...u],m=Xe(d,t,false,f);for(let S of u)m.push(...Xe(d,S,false,Math.floor(f/2)));let E=m.length===0?ne(d,Nt(t,false),f):[],N=m.length>0?m:E,y=ze(d,t,void 0,f);for(let S of u)y.push(...ze(d,S,void 0,Math.floor(f/2)));let h=y.length===0?ne(d,[{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`)}],f):[],b=y.length>0?y:h,T=a.findRelationsByArgKeyword(t,n,f);for(let S of u)T.push(...a.findRelationsByArgKeyword(S,n,Math.floor(f/2)));let v=[],W=[],P=[];for(let S of g){let k=pe(S),x=/^[a-zA-Z_$][\w$]*$/.test(S)?"\\b":"";v.push({kind:"template",regex:new RegExp(`(?::\\w+|v-model|v-if|v-show|@\\w+)="[^"]*${x}${k}${x}|\\{\\{[^}]*${x}${k}${x}[^}]*\\}\\}`)},{kind:"return",regex:new RegExp(`\\breturn\\b[^=]*${x}${k}${x}`)},{kind:"watch",regex:new RegExp(`watch[^(]*['"]\\.?${k}['"]`)},{kind:"computed_read",regex:new RegExp(`=>[^=]*${x}${k}${x}|return[^=]*${x}${k}${x}`)},{kind:"arg_usage",regex:new RegExp(`\\(\\s*[^)]*${x}${k}${x}[^)]*\\)`)}),W.push(`${x}${k}${x}\\s*(?:=|\\+=|-=|\\*=|\\/=)(?!=)|\\b(?:const|let|var)\\s+${k}\\b`),P.push(`${x}${k}${x}\\.\\w+\\s*(?:=|\\+=|-=)(?!=)|${x}${k}${x}\\s*\\[`);}let H=ne(d,v,f),$e=new RegExp(W.join("|")),Tt=new RegExp(P.join("|")),me=H.filter(S=>!$e.test(S.text)&&!Tt.test(S.text)),ve=new Map,Rt=(S,k)=>{if(!ve.has(S)){let{behaviors:L}=a.getFileOutline(S),C=new Map;for(let w of L){let q=String(w.symbol_name||"");C.has(q)||C.set(q,[]),C.get(q).push(w);}ve.set(S,C);}return (ve.get(S)?.get(k)||[]).filter(L=>String(L.category||"")!=="storage"?false:s==="all"?true:String(L.api_name||"").toLowerCase()===s.toLowerCase())},kt=(S,k)=>{let x=[],L=[{name:S,filePath:k,path:[S],level:0}],C=new Set([`${k}::${S}`]);for(;L.length>0;){let w=L.shift(),q=Rt(w.filePath,w.name);if(q.length>0){x.push({path:w.path,file:w.filePath,behaviors:q});continue}if(w.level>=c)continue;let F=a.getSymbolByName(w.name,w.filePath);if(F||(F=a.getSymbolByName(w.name)),!F)continue;let ge=String(F.file_path||F.abs_path||w.filePath),wt=a.getCallees(F.id);for(let Ct of wt){let oe=String(Ct.callee_name||"");if(!oe||oe.startsWith("$"))continue;let qe=`${ge}::${oe}`;C.has(qe)||(C.add(qe),L.push({name:oe,filePath:ge,path:[...w.path,oe],level:w.level+1}));}}return x},$t=u.length>0?` \u{1F517} \u53D1\u73B0\u89E3\u6784\u522B\u540D: ${u.map(S=>`"${S}"`).join(", ")}\uFF08\u5DF2\u4E00\u5E76\u8FFD\u8E2A\uFF09`:"",R=[`\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=${n||"*"} storage_api=${s} depth=${c}${$t}`,""];if(R.push(`\u2460 \u58F0\u660E & \u6574\u4F53\u8D4B\u503C (${N.length} \u5904)`),N.length===0)R.push(" \uFF08\u672A\u627E\u5230\uFF09");else {let S=["declaration","assignment","update"],k=new Map;for(let x of N)k.has(x.kind)||k.set(x.kind,[]),k.get(x.kind).push(x);for(let x of [...S,...Array.from(k.keys()).filter(L=>!S.includes(L))]){let L=k.get(x);!L||L.length===0||(R.push(` \u25B8 [${x}]`),L.slice(0,15).forEach(C=>R.push(` \u{1F4C4} ${C.filePath}:L${C.line} ${C.text}`)));}}if(R.push(""),R.push(`\u2461 \u5C5E\u6027\u4FEE\u6539 (${b.length} \u5904)`),b.length===0?R.push(' \uFF08\u672A\u627E\u5230 object.prop \u6216 object["prop"] \u5199\u5165\uFF09'):b.slice(0,20).forEach(S=>R.push(` \u{1F4C4} ${S.filePath}:L${S.line} [${S.kind}] ${S.text}`)),R.push(""),R.push(`\u2462 \u4F5C\u4E3A\u53C2\u6570\u88AB\u4F20\u5165\u8C03\u7528 (${T.length} \u5904)`),T.length===0?R.push(" \uFF08\u672A\u53D1\u73B0\u4EE5\u8BE5\u53D8\u91CF\u4F5C\u4E3A\u53C2\u6570\u7684\u51FD\u6570\u8C03\u7528\uFF09"):T.slice(0,20).forEach(S=>{let k=String(S.args||"");R.push(` \u{1F4C4} ${S.file_path}:L${S.line_number} ${S.caller_name} \u2192 ${S.callee_name} \u53C2\u6570: "${k}"`);}),R.push(""),R.push(`\u2463 \u8BFB\u53D6/\u4F7F\u7528 (${me.length} \u5904)`),me.length===0)R.push(" \uFF08\u672A\u53D1\u73B0 template \u7ED1\u5B9A / watch / computed / return \u4E2D\u7684\u5F15\u7528\uFF09");else {let S=new Map;for(let x of me)S.has(x.kind)||S.set(x.kind,[]),S.get(x.kind).push(x);let k={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[x,L]of S)R.push(` \u25B8 ${k[x]||x}`),L.slice(0,8).forEach(C=>R.push(` \u{1F4C4} ${C.filePath}:L${C.line} ${C.text}`));}R.push("");let se=0;R.push(`\u2464 Storage \u843D\u70B9\u8FFD\u8E2A (storage_api=${s}, depth=${c})`);let vt=s==="localStorage"?"localStorage":s==="sessionStorage"?"sessionStorage":"(?:localStorage|sessionStorage)",Lt=g.map(S=>({kind:"direct_storage",regex:new RegExp(`${vt}\\.(?:setItem|getItem|removeItem|clear)\\(.*?\\b${pe(S)}\\b`)})),Le=ne(d,Lt,f);if(Le.length>0&&(se+=1,R.push(" \u843D\u70B9 [\u76F4\u63A5\u547D\u4E2D\u5B58\u50A8]:"),Le.slice(0,15).forEach(S=>{R.push(` \u{1F4C4} ${S.filePath}:L${S.line} ${S.text.trim()}`);})),T.length===0&&Le.length===0)R.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 k of T){let x=`${k.file_path}::${k.callee_name}`;S.has(x)||S.set(x,k);}for(let[,k]of S){let x=String(k.callee_name||""),L=String(k.file_path||""),C=kt(x,L);C.length!==0&&(se+=1,C.slice(0,3).forEach(w=>{let q=w.file!==L?` \u2197 \u8DE8\u6587\u4EF6: ${w.file}`:"";R.push(` \u94FE\u8DEF: ${w.path.join(" \u2192 ")}${q}`),w.behaviors.forEach(F=>{let ge=F.detail?`("${String(F.detail)}")`:"";R.push(` \u843D\u70B9: ${F.api_name}.${F.operation}${ge} [${F.category}] L${F.line_number}`);});}));}se===0&&R.push(` \uFF08\u5728 depth=${c} \u5C42\u5185\u672A\u627E\u5230 storage \u5199\u5165\u94FE\u8DEF\uFF09`);}return R.push(""),R.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"),R.push("\u2705 \u6C47\u603B:"),R.push(` \u2460 \u58F0\u660E/\u8D4B\u503C: ${N.length} \u5904`),R.push(` \u2461 \u5C5E\u6027\u4FEE\u6539: ${b.length} \u5904`),R.push(` \u2462 \u53C2\u6570\u4F20\u9012: ${T.length} \u5904`),R.push(` \u2463 \u8BFB\u53D6\u5F15\u7528: ${me.length} \u5904`),R.push(` \u2464 storage: ${se>0?`\u2713 \u53D1\u73B0\u5199\u5165\u94FE\u8DEF (${se} \u6761)`:"\u2717 \u672A\u53D1\u73B0"}`),{content:[{type:"text",text:R.join(`
379
- `)}]}});}var fe=new Ne,ke=new McpServer({name:"frontend-code-skimmer",version:"0.1.0"});bt(ke,fe);Et(ke,fe);xt(ke,fe);async function fr(){if(process.env.SKIMMER_AUTO_INDEX==="true"&&process.env.SKIMMER_PROJECT){process.stderr.write(`[Frontend-Code-Skimmer] \u81EA\u52A8\u7D22\u5F15: ${process.env.SKIMMER_PROJECT}
380
- `);try{let{Indexer:r}=await Promise.resolve().then(()=>(Be(),yt)),{db:n,projectRoot:s}=fe.getContext(process.env.SKIMMER_PROJECT),i=await new r(s,n).indexProject();process.stderr.write(`[Frontend-Code-Skimmer] \u5B8C\u6210: ${i.indexedFiles} \u6587\u4EF6, ${i.totalSymbols} \u7B26\u53F7
381
- `);}catch(r){process.stderr.write(`[Frontend-Code-Skimmer] \u7D22\u5F15\u5931\u8D25: ${String(r)}
382
- `);}}let e=new StdioServerTransport;await ke.connect(e),process.stderr.write(`[Frontend-Code-Skimmer MCP] \u5DF2\u542F\u52A8
385
+ project_path \u53EF\u7701\u7565\u3002`,inputSchema:z$1.object({variable:z$1.string().describe('\u8981\u8FFD\u8E2A\u7684\u53D8\u91CF\u540D\u6216 key\uFF0C\u5982 "storageParams" / "savedData"'),project_path:z$1.string().optional().describe(Z),file_path:z$1.string().optional().describe('\u9650\u5B9A\u6587\u4EF6\u8DEF\u5F84\uFF08\u5305\u542B\u5373\u53EF\uFF0C\u5982 "src/views/apply/index.vue"\uFF09'),storage_api:z$1.enum(["localStorage","sessionStorage","all"]).optional().default("all").describe("storage \u843D\u70B9\u8FC7\u6EE4"),max_depth:z$1.number().optional().default(2).describe("storage \u94FE\u8DEF\u5411\u4E0B\u8FFD\u8E2A\u6DF1\u5EA6\uFF081-5\uFF09"),limit:z$1.number().optional().default(40).describe("\u6BCF\u7EF4\u5EA6\u6700\u5927\u7ED3\u679C\u6570")}),annotations:{readOnlyHint:true,destructiveHint:false}},async({variable:t,project_path:n,file_path:r,storage_api:s,max_depth:o,limit:i})=>{let {db:c}=e.getContext(n),a=Math.min(5,Math.max(1,o||2)),u=Math.min(120,Math.max(1,i||40)),d=c.listFiles(r),p=Ft(d,t,20),f=[...new Set(p.map(E=>E.alias).filter(E=>E!==t))],m=jt(d,t,20),g=[...new Set(m.map(E=>E.alias).filter(E=>E!==t))],h=[...new Set([...f,...g])],y=[t,...h],b=c.exactSearch(t,"state",void 0,r||void 0),S={vue2:"Vue2 data()",vue3:"Vue3 ref/reactive",react:"React useState/useRef"},v=b.filter(E=>E.default_value!=null).map(E=>({filePath:E.file_path,line:E.start_line,kind:`data_init(${S[E.framework]||E.framework})`,text:`${E.name}: ${E.default_value} \u2190 \u58F0\u660E\u521D\u59CB\u5316`})),T=st(d,t,false,u);for(let E of h)T.push(...st(d,E,false,Math.floor(u/2)));let P=T.length===0?pe(d,Ct(t,false),u):[],I=new Map;for(let E of [...v,...T.length>0?T:P]){let R=`${E.filePath}:${E.line}`;I.has(R)||I.set(R,E);}let O=[...I.values()],ie=Oe(d,t,void 0,u);for(let E of h)ie.push(...Oe(d,E,void 0,Math.floor(u/2)));let Ht=ie.length===0?pe(d,[{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`)}],u):[],be=ie.length>0?ie:Ht,te=c.findRelationsByArgKeyword(t,r,u);for(let E of h)te.push(...c.findRelationsByArgKeyword(E,r,Math.floor(u/2)));let ot=[],it=[],at=[];for(let E of y){let R=he(E),_=/^[a-zA-Z_$][\w$]*$/.test(E)?"\\b":"";ot.push({kind:"template",regex:new RegExp(`(?::\\w+|v-model|v-if|v-show|@\\w+)="[^"]*${_}${R}${_}|\\{\\{[^}]*${_}${R}${_}[^}]*\\}\\}`)},{kind:"return",regex:new RegExp(`\\breturn\\b[^=]*${_}${R}${_}`)},{kind:"watch",regex:new RegExp(`watch[^(]*['"]\\.?${R}['"]`)},{kind:"computed_read",regex:new RegExp(`=>[^=]*${_}${R}${_}|return[^=]*${_}${R}${_}`)},{kind:"arg_usage",regex:new RegExp(`\\(\\s*[^)]*${_}${R}${_}[^)]*\\)`)}),it.push(`${_}${R}${_}\\s*(?:=|\\+=|-=|\\*=|\\/=)(?!=)|\\b(?:const|let|var)\\s+${R}\\b`),at.push(`${_}${R}${_}\\.\\w+\\s*(?:=|\\+=|-=)(?!=)|${_}${R}${_}\\s*\\[`);}let Ut=pe(d,ot,u),Bt=new RegExp(it.join("|")),Kt=new RegExp(at.join("|")),Ee=Ut.filter(E=>!Bt.test(E.text)&&!Kt.test(E.text)),He=new Map,Vt=(E,R)=>{if(!He.has(E)){let{behaviors:L}=c.getFileOutline(E),k=new Map;for(let C of L){let B=String(C.symbol_name||"");k.has(B)||k.set(B,[]),k.get(B).push(C);}He.set(E,k);}return (He.get(E)?.get(R)||[]).filter(L=>String(L.category||"")!=="storage"?false:s==="all"?true:String(L.api_name||"").toLowerCase()===s.toLowerCase())},Xt=(E,R)=>{let _=[],L=[{name:E,filePath:R,path:[E],level:0}],k=new Set([`${R}::${E}`]);for(;L.length>0;){let C=L.shift(),B=Vt(C.filePath,C.name);if(B.length>0){_.push({path:C.path,file:C.filePath,behaviors:B});continue}if(C.level>=a)continue;let F=c.getSymbolByName(C.name,C.filePath);if(F||(F=c.getSymbolByName(C.name)),!F)continue;let ne=String(F.file_path||F.abs_path||C.filePath),Se=c.getCallees(F.id);for(let Ue of Se){let X=String(Ue.callee_name||"");if(!X||X.startsWith("$"))continue;let ct=`${ne}::${X}`;k.has(ct)||(k.add(ct),L.push({name:X,filePath:ne,path:[...C.path,X],level:C.level+1}));}}return _},zt=h.length>0?`
386
+ \u{1F517} \u53D1\u73B0\u522B\u540D: ${h.map(E=>`"${E}"`).join(", ")}\uFF08\u5DF2\u4E00\u5E76\u8FFD\u8E2A\u5C5E\u6027\u4FEE\u6539\uFF09`:"",ae=[];m.length>0&&(ae.push(` \u{1F517} \u5F15\u7528\u522B\u540D\u4F20\u64AD (${m.length} \u5904) \u2014 \u8FD9\u4E9B\u5C40\u90E8\u53D8\u91CF\u662F "${t}" \u7684\u5F15\u7528\uFF0C\u5176\u5C5E\u6027\u4FEE\u6539\u4E5F\u88AB\u8FFD\u8E2A:`),m.slice(0,10).forEach(E=>{let _=d.find(C=>C.path===E.filePath)?.abs_path||E.abs_path,L=Ie("alias_ref"),k=_?rt(_,E.line,2):{snippet:""};ae.push(` \u{1F4C4} ${E.filePath}:L${E.line} "${E.alias}" = ... ${L}`),ae.push(` ${E.text}`),k.snippet&&ae.push(k.snippet);}));let $=[`\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=${a}${zt}`,""];if($.push(`\u2460 \u58F0\u660E & \u6574\u4F53\u8D4B\u503C (${O.length} \u5904)`),O.length===0)$.push(" \uFF08\u672A\u627E\u5230\uFF09");else {let E={init:[],cache:[],user:[],unknown:[]};for(let _ of O){let L=It(_.text,_.line);E[L].push(_);}let R=["init","cache","user","unknown"];for(let _ of R){let L=E[_];!L||L.length===0||($.push(` \u25B8 ${Ot[_]} (${L.length} \u5904)`),L.slice(0,8).forEach(k=>{let C=h.includes(k.text.split("=")[0]?.trim().replace(/^(?:const|let|var)\s+/,"")||""),B=Ie(k.kind,C);$.push(` \u{1F4C4} ${k.filePath}:L${k.line} [${k.kind}] ${B}`),$.push(` ${k.text}`);}));}ae.length>0&&($.push(""),$.push(...ae));}if($.push(""),$.push(`\u2461 \u5C5E\u6027\u4FEE\u6539 (${be.length} \u5904)`),be.length===0)$.push(' \uFF08\u672A\u627E\u5230 object.prop \u6216 object["prop"] \u5199\u5165\uFF09'),h.length>0&&$.push(` \u2139\uFE0F \u5DF2\u8FFD\u8E2A\u522B\u540D: ${h.map(E=>`"${E}"`).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 E={init:[],cache:[],user:[],unknown:[]};for(let _ of be){let L=It(_.text,_.line);E[L].push(_);}let R=["init","cache","user","unknown"];for(let _ of R){let L=E[_];!L||L.length===0||($.push(` \u25B8 ${Ot[_]} (${L.length} \u5904)`),L.slice(0,8).forEach(k=>{let C=h.some(X=>k.text.startsWith(X)),B=Ie(k.kind,C),ne=d.find(X=>X.path===k.filePath)?.abs_path||"",Se=ne?rt(ne,k.line,2):{snippet:""},Ue=C?" \u{1F517}(via alias)":"";$.push(` \u{1F4C4} ${k.filePath}:L${k.line} [${k.kind}] ${B}${Ue}`),Se.snippet&&$.push(Se.snippet);}));}}if($.push(""),$.push(`\u2462 \u4F5C\u4E3A\u53C2\u6570\u88AB\u4F20\u5165\u8C03\u7528 (${te.length} \u5904)`),te.length===0?$.push(" \uFF08\u672A\u53D1\u73B0\u4EE5\u8BE5\u53D8\u91CF\u4F5C\u4E3A\u53C2\u6570\u7684\u51FD\u6570\u8C03\u7528\uFF09"):te.slice(0,20).forEach(E=>{let R=String(E.args||"");$.push(` \u{1F4C4} ${E.file_path}:L${E.line_number} ${E.caller_name} \u2192 ${E.callee_name} \u53C2\u6570: "${R}"`);}),$.push(""),$.push(`\u2463 \u8BFB\u53D6/\u4F7F\u7528 (${Ee.length} \u5904)`),Ee.length===0)$.push(" \uFF08\u672A\u53D1\u73B0 template \u7ED1\u5B9A / watch / computed / return \u4E2D\u7684\u5F15\u7528\uFF09");else {let E=new Map;for(let _ of Ee)E.has(_.kind)||E.set(_.kind,[]),E.get(_.kind).push(_);let R={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]of E)$.push(` \u25B8 ${R[_]||_}`),L.slice(0,8).forEach(k=>$.push(` \u{1F4C4} ${k.filePath}:L${k.line} ${k.text}`));}$.push("");let de=0;$.push(`\u2464 Storage \u843D\u70B9\u8FFD\u8E2A (storage_api=${s}, depth=${a})`);let Jt=s==="localStorage"?"localStorage":s==="sessionStorage"?"sessionStorage":"(?:localStorage|sessionStorage)",Gt=y.map(E=>({kind:"direct_storage",regex:new RegExp(`${Jt}\\.(?:setItem|getItem|removeItem|clear)\\(.*?\\b${he(E)}\\b`)})),Ne=pe(d,Gt,u);if(Ne.length>0&&(de+=1,$.push(` \u843D\u70B9 [\u76F4\u63A5\u547D\u4E2D\u5B58\u50A8] ${Ie("direct_storage")}:`),Ne.slice(0,15).forEach(E=>{let _=d.find(k=>k.path===E.filePath)?.abs_path||"",L=_?rt(_,E.line,2):{snippet:""};$.push(` \u{1F4C4} ${E.filePath}:L${E.line} ${E.text.trim()}`),L.snippet&&$.push(L.snippet);})),te.length===0&&Ne.length===0)$.push(" \uFF08\u672A\u53D1\u73B0\u76F4\u63A5 Storage \u64CD\u4F5C\uFF0C\u4E14\u65E0\u8C03\u7528\u5165\u53E3\u5C55\u5F00\u8FFD\u8E2A\uFF09");else {let E=new Map;for(let R of te){let _=`${R.file_path}::${R.callee_name}`;E.has(_)||E.set(_,R);}for(let[,R]of E){let _=String(R.callee_name||""),L=String(R.file_path||""),k=Xt(_,L);k.length!==0&&(de+=1,k.slice(0,3).forEach(C=>{let B=C.file!==L?` \u2197 \u8DE8\u6587\u4EF6: ${C.file}`:"";$.push(` \u94FE\u8DEF: ${C.path.join(" \u2192 ")}${B}`),C.behaviors.forEach(F=>{let ne=F.detail?`("${String(F.detail)}")`:"";$.push(` \u843D\u70B9: ${F.api_name}.${F.operation}${ne} [${F.category}] L${F.line_number}`);});}));}de===0&&Ne.length===0&&$.push(` \uFF08\u5728 depth=${a} \u5C42\u5185\u672A\u627E\u5230 storage \u5199\u5165\u94FE\u8DEF\uFF09`);}$.push(""),$.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 Yt=h.length>0?` (\u542B ${h.length} \u4E2A\u522B\u540D: ${h.slice(0,3).map(E=>`"${E}"`).join(", ")})`:"";return $.push(`\u2705 \u6C47\u603B${Yt}:`),$.push(` \u2460 \u58F0\u660E/\u8D4B\u503C: ${O.length} \u5904`),$.push(` \u2461 \u5C5E\u6027\u4FEE\u6539: ${be.length} \u5904 (\u5DF2\u8FFD\u8E2A\u522B\u540D: ${h.map(E=>`"${E}"`).join(", ")||"\u65E0"})`),$.push(` \u2462 \u53C2\u6570\u4F20\u9012: ${te.length} \u5904`),$.push(` \u2463 \u8BFB\u53D6\u5F15\u7528: ${Ee.length} \u5904`),$.push(` \u2464 storage: ${de>0?`\u2713 \u53D1\u73B0\u5199\u5165\u94FE\u8DEF (${de} \u6761)`:"\u2717 \u672A\u53D1\u73B0"}`),$.push(""),$.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"),$.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"),{content:[{type:"text",text:$.join(`
387
+ `)}]}});}var ye=new Te,We=new McpServer({name:"frontend-code-skimmer",version:"0.1.0"});Lt(We,ye);wt(We,ye);Wt(We,ye);async function wn(){if(process.env.SKIMMER_AUTO_INDEX==="true"&&process.env.SKIMMER_PROJECT){process.stderr.write(`[Frontend-Code-Skimmer] \u81EA\u52A8\u7D22\u5F15: ${process.env.SKIMMER_PROJECT}
388
+ `);try{let{Indexer:n}=await Promise.resolve().then(()=>(et(),vt)),{db:r,projectRoot:s}=ye.getContext(process.env.SKIMMER_PROJECT),i=await new n(s,r).indexProject();process.stderr.write(`[Frontend-Code-Skimmer] \u5B8C\u6210: ${i.indexedFiles} \u6587\u4EF6, ${i.totalSymbols} \u7B26\u53F7
389
+ `);}catch(n){process.stderr.write(`[Frontend-Code-Skimmer] \u7D22\u5F15\u5931\u8D25: ${String(n)}
390
+ `);}}let e=new StdioServerTransport;await We.connect(e),process.stderr.write(`[Frontend-Code-Skimmer MCP] \u5DF2\u542F\u52A8
383
391
  `),process.stderr.write(`[Frontend-Code-Skimmer MCP] \u652F\u6301\u6846\u67B6: Vue 2 / Vue 3 / React Hooks
384
392
  `),process.stderr.write(`[Frontend-Code-Skimmer MCP] \u652F\u6301\u6A21\u5F0F: \u52A8\u6001\u4EFB\u610F\u9879\u76EE\uFF08\u65E0\u9700\u542F\u52A8\u65F6\u6307\u5B9A\uFF09
385
393
  `),process.env.SKIMMER_PROJECT?process.stderr.write(`[Frontend-Code-Skimmer MCP] \u9ED8\u8BA4\u9879\u76EE: ${process.env.SKIMMER_PROJECT}
386
394
  `):process.stderr.write(`[Frontend-Code-Skimmer MCP] \u63D0\u793A: \u672A\u8BBE\u7F6E SKIMMER_PROJECT\uFF0C\u6BCF\u6B21\u8C03\u7528\u5DE5\u5177\u65F6\u8BF7\u4F20\u5165 project_path
387
- `);let t=()=>{fe.closeAll(),process.exit(0);};process.on("SIGINT",t),process.on("SIGTERM",t);}fr().catch(l=>{process.stderr.write(`[Frontend-Code-Skimmer MCP] \u542F\u52A8\u5931\u8D25: ${String(l)}
395
+ `);let t=()=>{ye.closeAll(),process.exit(0);};process.on("SIGINT",t),process.on("SIGTERM",t);}wn().catch(l=>{process.stderr.write(`[Frontend-Code-Skimmer MCP] \u542F\u52A8\u5931\u8D25: ${String(l)}
388
396
  `),process.exit(1);});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jokeran/frontend-code-skimmer",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Frontend-Code-Skimmer: 不读全文,只看骨架;不搜字符,搜语义关联。支持 Vue2/Vue3/React Hooks",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",