@precisionutilityguild/liquid-shadow 1.0.10 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +279 -62
- package/dist/entry/cli/index.js +1069 -748
- package/dist/entry/ember/index.js +287 -252
- package/dist/entry/mcp/server.js +973 -791
- package/dist/entry/tribunal/index.js +296 -261
- package/dist/index.js +966 -784
- package/dist/logic/domain/embeddings/worker.js +1 -1
- package/dist/logic/parser/index.js +12 -12
- package/dist/logic/parser/worker.js +1 -1
- package/dist/skills/shadow_workspace/SKILL.md +24 -2
- package/dist/web-manifest.json +6 -2
- package/package.json +2 -1
- package/skills/shadow_workspace/SKILL.md +24 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parentPort as c,workerData as E}from"worker_threads";import
|
|
1
|
+
import g from"os";import{parentPort as c,workerData as E}from"worker_threads";import y from"pino";var M={10:"TRACE",20:"DEBUG",30:"INFO",40:"WARN",50:"ERROR",60:"FATAL"},h=y({level:process.env.LOG_LEVEL||"warn",base:{service:"liquid-shadow"},formatters:{level(e,r){return{level:e,severity:M[r]??"INFO"}}},transport:{target:"pino-pretty",options:{colorize:!0,translateTime:"HH:MM:ss",destination:2,levelKey:"severity",messageKey:"message"}}}),o=h;try{g.setPriority(g.constants.priority.PRIORITY_BELOW_NORMAL)}catch{}var u=process.env.EMBEDDING_MODEL??"Xenova/all-MiniLM-L6-v2",a=process.env.EMBEDDING_DTYPE??"fp32",s=null;async function w(){if(!s){s=await import("@xenova/transformers"),s.env.cacheDir=E?.cacheDir||"./.cache",s.env.allowLocalModels=!0;let{ONNX:e}=s;if(e?.InferenceSession?.create){let r=e.InferenceSession.create.bind(e.InferenceSession);e.InferenceSession.create=(t,n={})=>r(t,{...n,intraOpNumThreads:2,extra:{"session.intra_op.allow_spinning":"0","session.force_spinning_stop":"1","ep.dynamic.workload_type":"Efficient",...n.extra??{}}})}}return s}var l=null;function f(e=!1){let r=(a||"").toLowerCase(),t={};return a&&(t.dtype=a),e?(t.quantized=!1,t):(r==="fp32"||r==="fp16"||r==="float32"||r==="float16"?t.quantized=!1:r.startsWith("q")&&(t.quantized=!0),t)}async function b(){let{pipeline:e}=await w(),r=f(!1);try{l=await e("feature-extraction",u,r)}catch(t){let n=t?.message||"";if(!(n.includes("/onnx/model_quantized.onnx")||n.includes("model_quantized.onnx")))throw t;o.warn({model:u,dtype:a},"Quantized ONNX artifact missing, retrying with unquantized ONNX"),l=await e("feature-extraction",u,f(!0))}}async function v(e){if(e.length===0)return[];try{let r=await l(e,{pooling:"mean",normalize:!0}),[t,n]=r.dims,i=[];for(let d=0;d<t;d++){let p=d*n,m=p+n;i.push(Array.from(r.data.slice(p,m)))}return i}catch(r){o.error({err:r,batchSize:e.length},"Vectorized batch embedding failed, falling back to sequential");let t=[];for(let n of e){if(!n||n.trim().length===0){t.push(null);continue}try{let i=await l(n,{pooling:"mean",normalize:!0});t.push(Array.from(i.data))}catch{t.push(null)}}return t}}async function R(e){if(e.type==="shutdown"&&process.exit(0),e.type==="embed")try{let r=await v(e.texts),t={type:"result",id:e.id,embeddings:r};c?.postMessage(t)}catch(r){let t={type:"error",id:e.id,error:r instanceof Error?r.message:String(r)};c?.postMessage(t)}}async function z(){await b();let e={type:"ready"};c?.postMessage(e),c?.on("message",r=>{R(r).catch(t=>{o.error({error:t},"Worker error")})})}z().catch(e=>{o.error({error:e},"Failed to initialize embedding worker"),process.exit(1)});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import ot from"fs";function
|
|
2
|
-
`)
|
|
3
|
-
`)[0].trim();return i.length>200?i.substring(0,197)+"...":i}function ve(n,t,i){let e=n.toLowerCase(),s=t.toLowerCase(),l=e.split("/").pop()||e;return i==="TsInterfaceDeclaration"||i==="TsTypeAliasDeclaration"||i==="TsEnumDeclaration"?"Type Definition":l.startsWith("use")||s.startsWith("use")?"Hook":e.includes("components/")||e.endsWith(".tsx")?"Component":e.includes("models/")||s.endsWith("model")?"Model":e.includes("services/")||e.includes("controllers/")||e.includes("handlers/")||e.includes("mcp/")||e.endsWith("service.ts")||e.endsWith("controller.ts")||e.endsWith("handler.ts")||s.endsWith("service")||s.endsWith("controller")||s.endsWith("handler")?"Service":e.includes("repositories/")||e.includes("repos/")||e.endsWith("repository.ts")||e.endsWith("repo.ts")||s.endsWith("repository")||s.endsWith("repo")?"Repository":"Other"}function ce(n){let t=[];return/\b(fetch|axios|superagent|got)\s*\(|import\s+.*\b(http|https|node-fetch)\b/i.test(n)&&t.push("Network"),(/\b(knex|prisma|typeorm|mongoose|sequelize|pg|mysql|sqlite3)\b/i.test(n)||/\b(SELECT\s+.*FROM|INSERT\s+INTO|UPDATE\s+.*SET|DELETE\s+FROM)\b/i.test(n)||/\.query\s*\(|\.execute\s*\(/i.test(n)&&/db|database|client|pool/i.test(n))&&t.push("Database"),(/\bfs\./i.test(n)||/\b(readFileSync|writeFileSync|readFile|writeFile|readdir)\b/.test(n)||/import\s+.*\bfs\b/.test(n))&&t.push("File System"),(/\b(localStorage|sessionStorage|indexedDB)\./.test(n)||/\bdocument\.cookie\b/.test(n))&&t.push("Browser Storage"),t}function V(n,t){if(!n)return"";let i=n.trimStart();for(;/^\/\*[\s\S]*?\*\//.test(i);)i=i.replace(/^\/\*[\s\S]*?\*\/\s*/,"");for(;/^\/\/[^\n]*\n/.test(i);)i=i.replace(/^\/\/[^\n]*\n\s*/,"");if(i=i.replace(/^(?:import[^\n]*\n)+/,"").replace(/^(?:export\s+\{[^}]*\}\s+from\s+['"][^'"]+['"];?\s*\n?)+/,"").trim(),t==="TsInterfaceDeclaration"||t==="TsTypeAliasDeclaration")return i;let e=0,s=0,l=i.length;for(let y=0;y<i.length;y++){let E=i[y];if(E==="(")e++;else if(E===")")e--;else if(E==="<")s++;else if(E===">")s--;else if(E==="{"){if(e===0&&s===0){l=y;break}}else if(E===";"&&e===0&&s===0){l=y;break}else if(E==="="&&i[y+1]===">"&&e===0&&s===0){l=y+2;break}}let f=i.substring(0,l).trim();return f.length>500?f.slice(0,497)+"...":f}function Ge(n){let t=[];for(let i of n)i.type==="ImportDeclaration"&&t.push({module:i.source.value,name:i.specifiers.map(e=>e.type==="ImportDefaultSpecifier"?"default":e.type==="ImportNamespaceSpecifier"?"*":e.local?.value||e.imported?.value||"*").join(", ")}),i.type==="ExportAllDeclaration"&&t.push({module:i.source.value,name:"*"}),i.type==="ExportNamedDeclaration"&&i.source&&t.push({module:i.source.value,name:i.specifiers.map(e=>e.type==="ExportSpecifier"?e.orig.value:"*").join(", ")});return t}function mt(n,t){for(let i of n){if((i.type==="FunctionDeclaration"||i.type==="ClassDeclaration")&&(i.identifier?.value||i.id?.value)===t)return i.span;if(i.type==="VariableDeclaration"){for(let e of i.declarations)if(e.id?.type==="Identifier"&&e.id.value===t)return e.span||i.span}if((i.type==="TsTypeAliasDeclaration"||i.type==="TsInterfaceDeclaration"||i.type==="TsEnumDeclaration")&&(i.id?.value||i.identifier?.value)===t)return i.span;if(i.type==="ExportDeclaration"){let e=i.declaration;if(!e)continue;if((e.type==="FunctionDeclaration"||e.type==="ClassDeclaration")&&(e.identifier?.value||e.id?.value)===t)return e.span||i.span;if(e.type==="VariableDeclaration"){for(let s of e.declarations)if(s.id?.type==="Identifier"&&s.id.value===t)return s.span||e.span||i.span}}}return null}function Ke(n,t,i,e,s,l,f,y,E){let o=E??(a=>Se(a,i)),u=[];for(let a of n){if(a.type==="ExportDeclaration"){let c=a.declaration,m=c.type,r="";m==="VariableDeclaration"?r=c.declarations.map(T=>T.id.value).join("",""):r=c.id?.value||c.identifier?.value||"anonymous";let p=o(a.span.start-t),g=o(a.span.end-t),x=U(p,l,e),S=y(a.span),d=[];if(a.type==="ExportDeclaration"&&(m==="ClassDeclaration"||m==="ClassExpression")){let T=c.body||[];for(let C of T)if(C.type==="ClassMethod"||C.type==="ClassProperty"){let N=C.key.value;if(!N)continue;let J=o(C.span.start-t),q=o(C.span.end-t),A=y(C.span),z=U(J,l,e);d.push({name:N,kind:C.type,signature:V(A,C.type),line:w(J,s),endLine:w(q,s),doc:z,classification:C.type==="ClassMethod"?"Method":"Property",capabilities:"[]"})}}else if(m==="FunctionDeclaration"&&c.body?.type==="BlockStatement")d=Ae(c.body.stmts,t,i,e,s,l,y,o);else if(m==="VariableDeclaration"){for(let T of c.declarations)if(T.init&&(T.init.type==="ArrowFunctionExpression"||T.init.type==="FunctionExpression")&&T.init.body?.type==="BlockStatement"){d=Ae(T.init.body.stmts,t,i,e,s,l,y,o);break}}u.push({name:r,kind:m,signature:V(S,m),line:w(p,s),endLine:w(g,s),doc:x,classification:ve(f,r,m),capabilities:JSON.stringify(ce(S)),members:d})}if(a.type==="ExportNamedDeclaration"){for(let c of a.specifiers)if(c.type==="ExportSpecifier"){let m=c.orig.value,r=c.exported?.value||m,g=mt(n,m)||a.span,x=o(g.start-t),S=o(g.end-t),d=U(x,l,e);u.push({name:r,kind:"ExportSpecifier",signature:`export { ${m} }`,line:w(x,s),endLine:w(S,s),doc:d,classification:"Export mapping",capabilities:"[]"})}}if(a.type==="ExportDefaultDeclaration"){let c=o(a.span.start-t),m=o(a.span.end-t),r=U(c,l,e),p=y(a.span),g=[];if(a.decl.type==="ClassExpression"||a.decl.type==="ClassDeclaration"){let x=a.decl.body||[];for(let S of x)if(S.type==="ClassMethod"||S.type==="ClassProperty"){let d=S.key.value;if(!d)continue;let T=o(S.span.start-t),C=o(S.span.end-t),N=y(S.span),J=U(T,l,e);g.push({name:d,kind:S.type,signature:V(N,S.type),line:w(T,s),endLine:w(C,s),doc:J,classification:S.type==="ClassMethod"?"Method":"Property",capabilities:"[]"})}}else(a.decl.type==="FunctionExpression"||a.decl.type==="FunctionDeclaration"||a.decl.type==="ArrowFunctionExpression")&&a.decl.body?.type==="BlockStatement"&&(g=Ae(a.decl.body.stmts,t,i,e,s,l,y,o));u.push({name:"default",kind:"DefaultExport",signature:V(p,"DefaultExport"),line:w(c,s),endLine:w(m,s),doc:r,classification:"Default Export",capabilities:JSON.stringify(ce(p)),members:g})}if(a.type==="ExportDefaultExpression"){let c=o(a.span.start-t),m=o(a.span.end-t),r=U(c,l,e),p=y(a.span),g=a.expression,x=g?.type==="Identifier"?g.value:g?.identifier?.value||g?.id?.value||void 0;u.push({name:"default",kind:"DefaultExport",signature:V(p,"DefaultExport"),line:w(c,s),endLine:w(m,s),doc:r,classification:"Default Export",capabilities:JSON.stringify(ce(p)),members:[],defaultTarget:x})}if(a.type==="ExportAllDeclaration"){let c=o(a.span.start-t),m=o(a.span.end-t),r=a.source.value,p=U(c,l,e);u.push({name:"*",kind:"ExportAllDeclaration",signature:`export * from "${r}"`,line:w(c,s),endLine:w(m,s),doc:p,classification:"Re-export",capabilities:"[]"})}}return u}function Ae(n,t,i,e,s,l,f,y){let E=[];for(let o of n){if(o.type==="VariableDeclaration")for(let u of o.declarations){let a=[],c=r=>{if(r.type==="Identifier")a.push({name:r.value,span:r.span});else if(r.type==="ArrayPattern")for(let p of r.elements)p&&c(p);else if(r.type==="ObjectPattern")for(let p of r.properties)p.type==="AssignmentPatternProperty"?a.push({name:p.key.value,span:p.span}):p.type==="KeyValuePatternProperty"&&c(p.value)};c(u.id);let m=u.init&&(u.init.type==="ArrowFunctionExpression"||u.init.type==="FunctionExpression");for(let r of a){let p=m?u.init.span||u.span||r.span:u.span||r.span,g=m?u.init.type:"VariableDeclaration",x=m?"Internal Function":"Internal Variable",S=y(p.start-t),d=y(p.end-t),T=f(p),C=U(S,l,e);E.push({name:r.name,kind:g,signature:V(T,g),line:w(S,s),endLine:w(d,s),doc:C,classification:x,capabilities:"[]"})}}if(o.type==="FunctionDeclaration"){let u=o.identifier?.value||o.ident?.value||"anonymous",a=y(o.span.start-t),c=y(o.span.end-t),m=f(o.span),r=U(a,l,e);E.push({name:u,kind:"FunctionDeclaration",signature:V(m,"FunctionDeclaration"),line:w(a,s),endLine:w(c,s),doc:r,classification:"Internal Function",capabilities:"[]"})}if(o.type==="ReturnStatement"&&o.argument?.type==="ObjectExpression")for(let u of o.argument.properties){let a="",c=u.span||u.key?.span||u.ident?.span;if(u.type==="KeyValueProperty"){let m=u.key;a=m?.value||m?.raw||(m?.type==="Identifier"?m.value:"")}else u.type==="MethodProperty"?a=u.key?.value||u.key?.raw||"":u.type==="ShorthandProperty"?a=u.ident?.value||"":u.type==="Identifier"&&(a=u.value||"");if(a&&c){let m=y(c.start-t),r=y(c.end-t),p=f(c),g=U(m,l,e);E.push({name:a,kind:"ReturnProperty",signature:V(p,"ReturnProperty"),line:w(m,s),endLine:w(r,s),doc:g,classification:"Return Member",capabilities:"[]"})}}if(o.type==="ExpressionStatement"&&o.expression.type==="CallExpression"){let u=o.expression;if(u.callee.type==="MemberExpression"&&(u.callee.property?.value==="on"||u.callee.property?.value==="once")){let a=u.arguments[0]?.expression?.value,c=u.arguments[1]?.expression;if(a&&c&&(c.type==="ArrowFunctionExpression"||c.type==="FunctionExpression")){let m=y(c.span.start-t),r=y(c.span.end-t),p=f(c.span);E.push({name:`on:${a}`,kind:c.type,signature:V(p,c.type),line:w(m,s),endLine:w(r,s),doc:"",classification:"Event Handler",capabilities:"[]"})}}if(u.callee.type==="Identifier"&&u.callee.value==="addRoute"&&u.arguments.length>=3){let a=u.arguments[2].expression;if(a.type==="StringLiteral"){let c=a.value,m=y(u.span.start-t),r=y(u.span.end-t),p=f(u.span);E.push({name:c,kind:"HTTP Route",signature:V(p,"HTTP Route"),line:w(m,s),endLine:w(r,s),doc:"",classification:"Service Boundary",capabilities:JSON.stringify({path:c})})}}}}return E}function Qe(n,t,i,e,s,l){let f=l??(o=>Se(o,i)),y=[];function E(o){if(!(!o||typeof o!="object")){if(o.type==="CallExpression"){let u=ft(o);if(u){let a=f(o.span.start-t);y.push({...u,line:w(a,e),snippet:s(o.span)})}}for(let u of Object.keys(o)){if(u==="span")continue;let a=o[u];Array.isArray(a)?a.forEach(E):typeof a=="object"&&E(a)}}}return n.forEach(E),y}function ft(n){let{callee:t,arguments:i}=n;if(!i||i.length===0)return null;if(t.type==="Identifier"&&t.value,t.type==="Identifier"&&t.value==="addRoute"&&i.length>=3){let e=i[2].expression;if(e.type==="StringLiteral")return{type:"api_route",name:e.value,direction:"consume"}}if(t.type==="MemberExpression"&&t.property?.type==="Identifier"){let e=t.property.value;if(e==="emit"&&i[0].expression.type==="StringLiteral")return{type:"socket_event",name:i[0].expression.value,direction:"produce"};if(e==="on"&&i[0].expression.type==="StringLiteral")return{type:"socket_event",name:i[0].expression.value,direction:"consume"};if(["get","post","put","delete","patch"].includes(e)&&i[0].expression.type==="StringLiteral"){let l=i[0].expression.value,f=t.object.type==="Identifier"?t.object.value:"";if(["axios","http","request","appApi","restApi","adminApi","client"].includes(f))return{type:"api_route",name:l,direction:"produce"};if(l.startsWith("/"))return{type:"api_route",name:l,direction:"consume"}}}return t.type==="Identifier"&&t.value==="fetch"&&i[0].expression.type==="StringLiteral"?{type:"api_route",name:i[0].expression.value,direction:"produce"}:null}function ye(n){let{classification:t,capabilities:i,exports:e,fileName:s}=n,l={Network:"API integration",Database:"data persistence","File System":"file I/O operations","Browser Storage":"client-side storage"},f=i.map(r=>l[r]).filter(Boolean).join(" and "),E={Component:(r,p)=>{let g=p.find(S=>S.kind==="FunctionDeclaration"||S.kind==="ClassDeclaration")?.name,x=g?`React component: ${g}`:"React UI component";return r?`${x} with ${r}`:x},Hook:(r,p)=>{let g=p.find(S=>S.name.startsWith("use"))?.name,x=g?`Custom React hook: ${g}`:"Custom React hook";return r?`${x} for ${r}`:x},Service:(r,p)=>{let x=`Service layer: ${p[0]?.name||"Service"}`;return r?`${x} handling ${r}`:x},Repository:(r,p)=>`Data repository: ${p[0]?.name||"Repository"} for ${r||"data access"}`,"Type Definition":(r,p)=>`Type definitions: ${p.slice(0,3).map(x=>x.name).join("")}${p.length>3?"...":""}`,Model:(r,p)=>`Data model: ${p[0]?.name||"Model"}`,"HTTP Route":(r,p)=>{let g=p.filter(x=>x.classification==="Service Boundary");return g.length>0?`API endpoints: ${g.slice(0,3).map(x=>x.name).join("")}`:"API route handler"},"Micro IR (PHP)":(r,p)=>{let g=p.some(S=>S.classification==="Service Boundary"),x=p.find(S=>S.kind==="ClassDeclaration")?.name;return g?"PHP controller with API routes":x?`PHP class: ${x}`:"PHP module"},"Micro IR (Python)":(r,p)=>{let g=p.some(S=>S.classification==="Service Boundary"),x=p.find(S=>S.kind==="ClassDeclaration")?.name;return g?"Python API handler with routes":x?`Python class: ${x}`:"Python module"},"Micro IR (Go/TS) ":(r,p)=>{let g=p.some(S=>S.kind==="TypeDeclaration"),x=p.filter(S=>S.kind==="FunctionDeclaration");return g&&x.length>0?`Go package: types and ${x.length} function(s)`:g?"Go package: type definitions":x.length>0?`Go package: ${x[0].name} and ${x.length} function(s)`:"Go module"},"Micro IR (Rust/TS) ":(r,p)=>{let g=p.find(d=>d.kind==="TraitDeclaration")?.name,x=p.find(d=>d.kind==="StructDeclaration")?.name,S=p.filter(d=>d.kind==="FunctionDeclaration");return g?r.includes("Rust trait")?`Rust module: trait ${g}`:`Rust module: ${g}`:x?`Rust module: struct ${x}`:S.length>0?`Rust module: ${S.length} function(s)`:"Rust module"}}[t];if(E)return E(f,e);if(e.length===0)return s?`Module: ${s}`:"Module with no exports";let o=e.filter(r=>r.kind==="FunctionDeclaration"),u=e.filter(r=>r.kind==="ClassDeclaration"),a=e.filter(r=>r.kind==="TsInterfaceDeclaration"||r.kind==="TsTypeAliasDeclaration"),c=[];if(u.length>0&&c.push(`Class: ${u[0].name}`),o.length>0){let r=o.slice(0,2).map(p=>p.name).join("");c.push(`Functions: ${r}`)}a.length>0&&c.push(`Types: ${a.length}`);let m=c.length>0?c.join(" | "):`Module with ${e.length} export(s)`;return f?`${m} \u2014 ${f}`:m}function Xe(n){let t=new Set;function i(e){if(!(!e||typeof e!="object")){e.typeAnnotation&&I(e.typeAnnotation,t),(e.type==="TsTypeReference"||e.type==="TsTypeAnnotation")&&I(e,t);for(let s in e){if(s==="span"||s==="comments"||s==="interpreter")continue;let l=e[s];l&&typeof l=="object"&&(Array.isArray(l)?l.forEach(i):i(l))}}}return n.forEach(e=>i(e)),Array.from(t)}function I(n,t){if(n){if(n.type==="TsTypeAnnotation"){I(n.typeAnnotation,t);return}n.type==="TsTypeReference"&&(n.typeName?.type==="Identifier"&&t.add(n.typeName.value),n.typeName?.type==="TsQualifiedName"&&Ye(n.typeName,t),n.typeParams&&I(n.typeParams,t)),n.type==="TsArrayType"&&I(n.elementType,t),n.type==="TsUnionType"&&n.types?.forEach(i=>I(i,t)),n.type==="TsIntersectionType"&&n.types?.forEach(i=>I(i,t)),n.type==="TsTupleType"&&n.elemTypes?.forEach(i=>I(i.ty,t)),(n.type==="TsFunctionType"||n.type==="TsConstructorType")&&(n.params?.forEach(i=>I(i.typeAnnotation,t)),n.typeAnnotation&&I(n.typeAnnotation,t)),n.type==="TsTypeParameterDeclaration"&&n.params?.forEach(i=>{i.constraint&&I(i.constraint,t),i.default&&I(i.default,t)}),n.type==="TsTypeParameterInstantiation"&&n.params?.forEach(i=>I(i,t)),n.type==="TsMappedType"&&n.typeAnnotation&&I(n.typeAnnotation,t),n.type==="TsIndexedAccessType"&&(I(n.objectType,t),I(n.indexType,t)),n.type==="TsConditionalType"&&(I(n.checkType,t),I(n.extendsType,t),I(n.trueType,t),I(n.falseType,t)),n.type==="TsTypeLiteral"&&n.members?.forEach(i=>{i.typeAnnotation&&I(i.typeAnnotation,t)})}}function Ye(n,t){n.type==="TsQualifiedName"?(n.left&&Ye(n.left,t),n.right?.value&&t.add(n.right.value)):n.type==="Identifier"&&t.add(n.value)}import ct from"path";import $e from"path";import st from"path";import vt from"fs";import{fileURLToPath as Mt}from"url";import*as ie from"web-tree-sitter";import dt from"pino";var ht={10:"TRACE",20:"DEBUG",30:"INFO",40:"WARN",50:"ERROR",60:"FATAL"},yt=dt({level:process.env.LOG_LEVEL||"warn",base:{service:"liquid-shadow"},formatters:{level(n,t){return{level:n,severity:ht[t]??"INFO"}}},transport:{target:"pino-pretty",options:{colorize:!0,translateTime:"HH:MM:ss",destination:2,levelKey:"severity",messageKey:"message"}}}),ne=yt;import{fileURLToPath as gt}from"node:url";import{dirname as Ie,join as tt,resolve as bt}from"node:path";import{existsSync as xt}from"node:fs";var Dt=gt(import.meta.url),et=Ie(Dt);function St(){let n=et;for(;n!==Ie(n);){if(xt(tt(n,"package.json")))return n;n=Ie(n)}return bt(et,"..","..")}function nt(...n){return tt(St(),...n)}var Xt=st.dirname(Mt(import.meta.url)),it=ne.child({module:"parser:tree-sitter"}),Me=class{parser=null;languages=new Map;async ensureInitialized(){if(this.parser)return;let t=ie.Parser||ie;await t.init(),this.parser=new t}async getLanguage(t){if(this.languages.has(t))return this.languages.get(t);let i=nt("resources","grammars",`tree-sitter-${this.getLangName(t)}.wasm`);if(!vt.existsSync(i))return it.warn({grammarPath:i},"Grammar WASM not found"),null;try{let e=await ie.Language.load(i);return this.languages.set(t,e),e}catch(e){return it.error({err:e,ext:t},"Failed to load language grammar"),null}}getLangName(t){switch(t.toLowerCase()){case".php":return"php";case".py":return"python";case".go":return"go";case".rs":return"rust";default:return""}}getQueries(t){switch(t.toLowerCase()){case".php":return`
|
|
1
|
+
import ot from"fs";import ct from"path";import mt from"pino";var ft={10:"TRACE",20:"DEBUG",30:"INFO",40:"WARN",50:"ERROR",60:"FATAL"},dt=mt({level:process.env.LOG_LEVEL||"warn",base:{service:"liquid-shadow"},formatters:{level(n,t){return{level:n,severity:ft[t]??"INFO"}}},transport:{target:"pino-pretty",options:{colorize:!0,translateTime:"HH:MM:ss",destination:2,levelKey:"severity",messageKey:"message"}}}),ne=dt;import*as Ae from"@swc/core";function Je(n){if(!n||typeof n!="object")return!1;let t=n;return typeof t.parse=="function"&&typeof t.parseSync=="function"}function ht(){if(Je(Ae))return Ae;let n=Ae;if(Je(n.default))return n.default;throw new Error("SWC runtime unavailable: couldn't resolve parse/parseSync from @swc/core exports")}var yt=ht();function Se(n,t,i){return yt.parseSync(n,t,i)}function ve(n,t,i){let e=n.toLowerCase(),s=t.toLowerCase(),l=e.split("/").pop()||e;return i==="TsInterfaceDeclaration"||i==="TsTypeAliasDeclaration"||i==="TsEnumDeclaration"?"Type Definition":l.startsWith("use")||s.startsWith("use")?"Hook":e.includes("components/")||e.endsWith(".tsx")?"Component":e.includes("models/")||s.endsWith("model")?"Model":e.includes("services/")||e.includes("controllers/")||e.includes("handlers/")||e.includes("mcp/")||e.endsWith("service.ts")||e.endsWith("controller.ts")||e.endsWith("handler.ts")||s.endsWith("service")||s.endsWith("controller")||s.endsWith("handler")?"Service":e.includes("repositories/")||e.includes("repos/")||e.endsWith("repository.ts")||e.endsWith("repo.ts")||s.endsWith("repository")||s.endsWith("repo")?"Repository":"Other"}function ce(n){let t=[];return/\b(fetch|axios|superagent|got)\s*\(|import\s+.*\b(http|https|node-fetch)\b/i.test(n)&&t.push("Network"),(/\b(knex|prisma|typeorm|mongoose|sequelize|pg|mysql|sqlite3)\b/i.test(n)||/\b(SELECT\s+.*FROM|INSERT\s+INTO|UPDATE\s+.*SET|DELETE\s+FROM)\b/i.test(n)||/\.query\s*\(|\.execute\s*\(/i.test(n)&&/db|database|client|pool/i.test(n))&&t.push("Database"),(/\bfs\./i.test(n)||/\b(readFileSync|writeFileSync|readFile|writeFile|readdir)\b/.test(n)||/import\s+.*\bfs\b/.test(n))&&t.push("File System"),(/\b(localStorage|sessionStorage|indexedDB)\./.test(n)||/\bdocument\.cookie\b/.test(n))&&t.push("Browser Storage"),t}function qe(n){let t=[],i=/\/\*\*[\s\S]*?\*\//g,e;for(;(e=i.exec(n))!==null;)t.push({start:e.index,end:e.index+e[0].length,text:e[0]});return t}function U(n,t,i){for(let e of t){if(e.start===n)return e.text;if(e.start>n&&e.start<n+50){let s=i.substring(n,e.start);if(/^\s*$/.test(s))return e.text}if(e.end<=n&&e.end>n-50){let s=i.substring(e.end,n);if(/^\s*$/.test(s))return e.text}}return""}function He(n){if(!n)return"";let i=n.replace(/\/\*\*|\*\/|\*/g,"").trim().split(`
|
|
2
|
+
`)[0].trim();return i.length>200?i.substring(0,197)+"...":i}function Ue(n){let t=n.split(`
|
|
3
|
+
`),i=[],e=0;for(let s of t)i.push(e),e+=s.length+1;return i}function w(n,t){for(let i=0;i<t.length;i++)if(t[i+1]>n||i===t.length-1)return i+1;return 1}function Me(n,t){return t.slice(0,n).toString("utf8").length}function Ve(n){if(n.toString("utf8").length===n.length)return e=>e;let i=new Map;return e=>{let s=i.get(e);return s===void 0&&(s=n.slice(0,e).toString("utf8").length,i.set(e,s)),s}}function Ge(n,t,i){let e=n.start-t,s=n.end-t;return e<0||s>i.length?"":i.slice(e,s).toString("utf8")}function V(n,t){if(!n)return"";let i=n.trimStart();for(;/^\/\*[\s\S]*?\*\//.test(i);)i=i.replace(/^\/\*[\s\S]*?\*\/\s*/,"");for(;/^\/\/[^\n]*\n/.test(i);)i=i.replace(/^\/\/[^\n]*\n\s*/,"");if(i=i.replace(/^(?:import[^\n]*\n)+/,"").replace(/^(?:export\s+\{[^}]*\}\s+from\s+['"][^'"]+['"];?\s*\n?)+/,"").trim(),t==="TsInterfaceDeclaration"||t==="TsTypeAliasDeclaration")return i;let e=0,s=0,l=i.length;for(let y=0;y<i.length;y++){let E=i[y];if(E==="(")e++;else if(E===")")e--;else if(E==="<")s++;else if(E===">")s--;else if(E==="{"){if(e===0&&s===0){l=y;break}}else if(E===";"&&e===0&&s===0){l=y;break}else if(E==="="&&i[y+1]===">"&&e===0&&s===0){l=y+2;break}}let f=i.substring(0,l).trim();return f.length>500?f.slice(0,497)+"...":f}function Ke(n){let t=[];for(let i of n)i.type==="ImportDeclaration"&&t.push({module:i.source.value,name:i.specifiers.map(e=>e.type==="ImportDefaultSpecifier"?"default":e.type==="ImportNamespaceSpecifier"?"*":e.local?.value||e.imported?.value||"*").join(", ")}),i.type==="ExportAllDeclaration"&&t.push({module:i.source.value,name:"*"}),i.type==="ExportNamedDeclaration"&&i.source&&t.push({module:i.source.value,name:i.specifiers.map(e=>e.type==="ExportSpecifier"?e.orig.value:"*").join(", ")});return t}function gt(n,t){for(let i of n){if((i.type==="FunctionDeclaration"||i.type==="ClassDeclaration")&&(i.identifier?.value||i.id?.value)===t)return i.span;if(i.type==="VariableDeclaration"){for(let e of i.declarations)if(e.id?.type==="Identifier"&&e.id.value===t)return e.span||i.span}if((i.type==="TsTypeAliasDeclaration"||i.type==="TsInterfaceDeclaration"||i.type==="TsEnumDeclaration")&&(i.id?.value||i.identifier?.value)===t)return i.span;if(i.type==="ExportDeclaration"){let e=i.declaration;if(!e)continue;if((e.type==="FunctionDeclaration"||e.type==="ClassDeclaration")&&(e.identifier?.value||e.id?.value)===t)return e.span||i.span;if(e.type==="VariableDeclaration"){for(let s of e.declarations)if(s.id?.type==="Identifier"&&s.id.value===t)return s.span||e.span||i.span}}}return null}function Qe(n,t,i,e,s,l,f,y,E){let o=E??(a=>Me(a,i)),u=[];for(let a of n){if(a.type==="ExportDeclaration"){let c=a.declaration,m=c.type,r="";m==="VariableDeclaration"?r=c.declarations.map(T=>T.id.value).join("",""):r=c.id?.value||c.identifier?.value||"anonymous";let p=o(a.span.start-t),g=o(a.span.end-t),x=U(p,l,e),S=y(a.span),d=[];if(a.type==="ExportDeclaration"&&(m==="ClassDeclaration"||m==="ClassExpression")){let T=c.body||[];for(let C of T)if(C.type==="ClassMethod"||C.type==="ClassProperty"){let N=C.key.value;if(!N)continue;let O=o(C.span.start-t),q=o(C.span.end-t),A=y(C.span),z=U(O,l,e);d.push({name:N,kind:C.type,signature:V(A,C.type),line:w(O,s),endLine:w(q,s),doc:z,classification:C.type==="ClassMethod"?"Method":"Property",capabilities:"[]"})}}else if(m==="FunctionDeclaration"&&c.body?.type==="BlockStatement")d=Ie(c.body.stmts,t,i,e,s,l,y,o);else if(m==="VariableDeclaration"){for(let T of c.declarations)if(T.init&&(T.init.type==="ArrowFunctionExpression"||T.init.type==="FunctionExpression")&&T.init.body?.type==="BlockStatement"){d=Ie(T.init.body.stmts,t,i,e,s,l,y,o);break}}u.push({name:r,kind:m,signature:V(S,m),line:w(p,s),endLine:w(g,s),doc:x,classification:ve(f,r,m),capabilities:JSON.stringify(ce(S)),members:d})}if(a.type==="ExportNamedDeclaration"){for(let c of a.specifiers)if(c.type==="ExportSpecifier"){let m=c.orig.value,r=c.exported?.value||m,g=gt(n,m)||a.span,x=o(g.start-t),S=o(g.end-t),d=U(x,l,e);u.push({name:r,kind:"ExportSpecifier",signature:`export { ${m} }`,line:w(x,s),endLine:w(S,s),doc:d,classification:"Export mapping",capabilities:"[]"})}}if(a.type==="ExportDefaultDeclaration"){let c=o(a.span.start-t),m=o(a.span.end-t),r=U(c,l,e),p=y(a.span),g=[];if(a.decl.type==="ClassExpression"||a.decl.type==="ClassDeclaration"){let x=a.decl.body||[];for(let S of x)if(S.type==="ClassMethod"||S.type==="ClassProperty"){let d=S.key.value;if(!d)continue;let T=o(S.span.start-t),C=o(S.span.end-t),N=y(S.span),O=U(T,l,e);g.push({name:d,kind:S.type,signature:V(N,S.type),line:w(T,s),endLine:w(C,s),doc:O,classification:S.type==="ClassMethod"?"Method":"Property",capabilities:"[]"})}}else(a.decl.type==="FunctionExpression"||a.decl.type==="FunctionDeclaration"||a.decl.type==="ArrowFunctionExpression")&&a.decl.body?.type==="BlockStatement"&&(g=Ie(a.decl.body.stmts,t,i,e,s,l,y,o));u.push({name:"default",kind:"DefaultExport",signature:V(p,"DefaultExport"),line:w(c,s),endLine:w(m,s),doc:r,classification:"Default Export",capabilities:JSON.stringify(ce(p)),members:g})}if(a.type==="ExportDefaultExpression"){let c=o(a.span.start-t),m=o(a.span.end-t),r=U(c,l,e),p=y(a.span),g=a.expression,x=g?.type==="Identifier"?g.value:g?.identifier?.value||g?.id?.value||void 0;u.push({name:"default",kind:"DefaultExport",signature:V(p,"DefaultExport"),line:w(c,s),endLine:w(m,s),doc:r,classification:"Default Export",capabilities:JSON.stringify(ce(p)),members:[],defaultTarget:x})}if(a.type==="ExportAllDeclaration"){let c=o(a.span.start-t),m=o(a.span.end-t),r=a.source.value,p=U(c,l,e);u.push({name:"*",kind:"ExportAllDeclaration",signature:`export * from "${r}"`,line:w(c,s),endLine:w(m,s),doc:p,classification:"Re-export",capabilities:"[]"})}}return u}function Ie(n,t,i,e,s,l,f,y){let E=[];for(let o of n){if(o.type==="VariableDeclaration")for(let u of o.declarations){let a=[],c=r=>{if(r.type==="Identifier")a.push({name:r.value,span:r.span});else if(r.type==="ArrayPattern")for(let p of r.elements)p&&c(p);else if(r.type==="ObjectPattern")for(let p of r.properties)p.type==="AssignmentPatternProperty"?a.push({name:p.key.value,span:p.span}):p.type==="KeyValuePatternProperty"&&c(p.value)};c(u.id);let m=u.init&&(u.init.type==="ArrowFunctionExpression"||u.init.type==="FunctionExpression");for(let r of a){let p=m?u.init.span||u.span||r.span:u.span||r.span,g=m?u.init.type:"VariableDeclaration",x=m?"Internal Function":"Internal Variable",S=y(p.start-t),d=y(p.end-t),T=f(p),C=U(S,l,e);E.push({name:r.name,kind:g,signature:V(T,g),line:w(S,s),endLine:w(d,s),doc:C,classification:x,capabilities:"[]"})}}if(o.type==="FunctionDeclaration"){let u=o.identifier?.value||o.ident?.value||"anonymous",a=y(o.span.start-t),c=y(o.span.end-t),m=f(o.span),r=U(a,l,e);E.push({name:u,kind:"FunctionDeclaration",signature:V(m,"FunctionDeclaration"),line:w(a,s),endLine:w(c,s),doc:r,classification:"Internal Function",capabilities:"[]"})}if(o.type==="ReturnStatement"&&o.argument?.type==="ObjectExpression")for(let u of o.argument.properties){let a="",c=u.span||u.key?.span||u.ident?.span;if(u.type==="KeyValueProperty"){let m=u.key;a=m?.value||m?.raw||(m?.type==="Identifier"?m.value:"")}else u.type==="MethodProperty"?a=u.key?.value||u.key?.raw||"":u.type==="ShorthandProperty"?a=u.ident?.value||"":u.type==="Identifier"&&(a=u.value||"");if(a&&c){let m=y(c.start-t),r=y(c.end-t),p=f(c),g=U(m,l,e);E.push({name:a,kind:"ReturnProperty",signature:V(p,"ReturnProperty"),line:w(m,s),endLine:w(r,s),doc:g,classification:"Return Member",capabilities:"[]"})}}if(o.type==="ExpressionStatement"&&o.expression.type==="CallExpression"){let u=o.expression;if(u.callee.type==="MemberExpression"&&(u.callee.property?.value==="on"||u.callee.property?.value==="once")){let a=u.arguments[0]?.expression?.value,c=u.arguments[1]?.expression;if(a&&c&&(c.type==="ArrowFunctionExpression"||c.type==="FunctionExpression")){let m=y(c.span.start-t),r=y(c.span.end-t),p=f(c.span);E.push({name:`on:${a}`,kind:c.type,signature:V(p,c.type),line:w(m,s),endLine:w(r,s),doc:"",classification:"Event Handler",capabilities:"[]"})}}if(u.callee.type==="Identifier"&&u.callee.value==="addRoute"&&u.arguments.length>=3){let a=u.arguments[2].expression;if(a.type==="StringLiteral"){let c=a.value,m=y(u.span.start-t),r=y(u.span.end-t),p=f(u.span);E.push({name:c,kind:"HTTP Route",signature:V(p,"HTTP Route"),line:w(m,s),endLine:w(r,s),doc:"",classification:"Service Boundary",capabilities:JSON.stringify({path:c})})}}}}return E}function Xe(n,t,i,e,s,l){let f=l??(o=>Me(o,i)),y=[];function E(o){if(!(!o||typeof o!="object")){if(o.type==="CallExpression"){let u=bt(o);if(u){let a=f(o.span.start-t);y.push({...u,line:w(a,e),snippet:s(o.span)})}}for(let u of Object.keys(o)){if(u==="span")continue;let a=o[u];Array.isArray(a)?a.forEach(E):typeof a=="object"&&E(a)}}}return n.forEach(E),y}function bt(n){let{callee:t,arguments:i}=n;if(!i||i.length===0)return null;if(t.type==="Identifier"&&t.value,t.type==="Identifier"&&t.value==="addRoute"&&i.length>=3){let e=i[2].expression;if(e.type==="StringLiteral")return{type:"api_route",name:e.value,direction:"consume"}}if(t.type==="MemberExpression"&&t.property?.type==="Identifier"){let e=t.property.value;if(e==="emit"&&i[0].expression.type==="StringLiteral")return{type:"socket_event",name:i[0].expression.value,direction:"produce"};if(e==="on"&&i[0].expression.type==="StringLiteral")return{type:"socket_event",name:i[0].expression.value,direction:"consume"};if(["get","post","put","delete","patch"].includes(e)&&i[0].expression.type==="StringLiteral"){let l=i[0].expression.value,f=t.object.type==="Identifier"?t.object.value:"";if(["axios","http","request","appApi","restApi","adminApi","client"].includes(f))return{type:"api_route",name:l,direction:"produce"};if(l.startsWith("/"))return{type:"api_route",name:l,direction:"consume"}}}return t.type==="Identifier"&&t.value==="fetch"&&i[0].expression.type==="StringLiteral"?{type:"api_route",name:i[0].expression.value,direction:"produce"}:null}import Le from"path";import Rt from"fs";import it from"path";import{fileURLToPath as Ct}from"url";import*as ie from"web-tree-sitter";import{existsSync as xt}from"node:fs";import{dirname as $e,join as et,resolve as Dt}from"node:path";import{fileURLToPath as St}from"node:url";var vt=St(import.meta.url),Ye=$e(vt);function Mt(){let n=Ye;for(;n!==$e(n);){if(xt(et(n,"package.json")))return n;n=$e(n)}return Dt(Ye,"..","..")}function tt(...n){return et(Mt(),...n)}var Qt=it.dirname(Ct(import.meta.url)),nt=ne.child({module:"parser:tree-sitter"}),Re=class{parser=null;languages=new Map;async ensureInitialized(){if(this.parser)return;let t=ie.Parser||ie;await t.init(),this.parser=new t}async getLanguage(t){if(this.languages.has(t))return this.languages.get(t);let i=tt("resources","grammars",`tree-sitter-${this.getLangName(t)}.wasm`);if(!Rt.existsSync(i))return nt.warn({grammarPath:i},"Grammar WASM not found"),null;try{let e=await ie.Language.load(i);return this.languages.set(t,e),e}catch(e){return nt.error({err:e,ext:t},"Failed to load language grammar"),null}}getLangName(t){switch(t.toLowerCase()){case".php":return"php";case".py":return"python";case".go":return"go";case".rs":return"rust";default:return""}}getQueries(t){switch(t.toLowerCase()){case".php":return`
|
|
4
4
|
(function_definition name: (name) @name) @func
|
|
5
5
|
(class_declaration name: (name) @name) @class
|
|
6
6
|
(interface_declaration name: (name) @name) @interface
|
|
@@ -24,16 +24,16 @@ import ot from"fs";function je(n){let t=n.split(`
|
|
|
24
24
|
(trait_item name: (_type_identifier) @name) @trait
|
|
25
25
|
(type_item name: (_type_identifier) @name) @type
|
|
26
26
|
(use_declaration argument: (_) @name) @import
|
|
27
|
-
`;default:return""}}mapKind(t,i){if(t==="import")return"ImportDeclaration";if(i===".php"){if(t==="func")return"FunctionDeclaration";if(t==="class")return"ClassDeclaration";if(t==="interface")return"InterfaceDeclaration";if(t==="trait")return"TraitDeclaration";if(t==="method")return"MethodDeclaration"}if(i===".py"){if(t==="func")return"FunctionDeclaration";if(t==="class")return"ClassDeclaration"}if(i===".go"){if(t==="func")return"FunctionDeclaration";if(t==="type")return"TypeDeclaration"}if(i===".rs"){if(t==="func")return"FunctionDeclaration";if(t==="struct")return"StructDeclaration";if(t==="enum")return"EnumDeclaration";if(t==="trait")return"TraitDeclaration";if(t==="type")return"TypeDeclaration"}return"Unknown"}mapClassification(t){return t==="import"?"Dependency":t==="func"||t==="method"?"Function":t==="class"||t==="interface"||t==="trait"||t==="struct"||t==="enum"||t==="type"?"Class":"Other"}async parse(t,i){await this.ensureInitialized();let e=
|
|
28
|
-
`),y=this.getQueries(e);if(!y)return[];let o=new ie.Query(s,y).matches(l.rootNode),u=[];for(let a of o){let c=a.captures.find(p=>p.name==="name")?.node,m=a.captures[0].node,r=a.captures[0].name;if(c){let p=m.startPosition.row+1,g=m.endPosition.row+1,x=f[m.startPosition.row].trim();u.push({name:c.text,kind:this.mapKind(r,e),classification:this.mapClassification(r),signature:x,line:p,endLine:g,doc:"",capabilities:"{}"})}}return u}};var
|
|
29
|
-
`),f="",y="",E=0,o=0,u=-1,a=-1,c=[],m=[],r=!1,p=i?"api":"",g="",x=/^namespace\s+([a-zA-Z0-9_\\]+);/,S=/^(?:abstract\s+)?(?:readonly\s+)?class\s+([a-zA-Z0-9_]+)/,d=/^interface\s+([a-zA-Z0-9_]+)/,T=/^trait\s+([a-zA-Z0-9_]+)/,C=/^enum\s+([a-zA-Z0-9_]+)(?:\s*:\s*(string|int))?\s*/,N=/^((?:(?:public|protected|private|static)\s+)*)function\s+([a-zA-Z0-9_]+)\s*\(/,
|
|
27
|
+
`;default:return""}}mapKind(t,i){if(t==="import")return"ImportDeclaration";if(i===".php"){if(t==="func")return"FunctionDeclaration";if(t==="class")return"ClassDeclaration";if(t==="interface")return"InterfaceDeclaration";if(t==="trait")return"TraitDeclaration";if(t==="method")return"MethodDeclaration"}if(i===".py"){if(t==="func")return"FunctionDeclaration";if(t==="class")return"ClassDeclaration"}if(i===".go"){if(t==="func")return"FunctionDeclaration";if(t==="type")return"TypeDeclaration"}if(i===".rs"){if(t==="func")return"FunctionDeclaration";if(t==="struct")return"StructDeclaration";if(t==="enum")return"EnumDeclaration";if(t==="trait")return"TraitDeclaration";if(t==="type")return"TypeDeclaration"}return"Unknown"}mapClassification(t){return t==="import"?"Dependency":t==="func"||t==="method"?"Function":t==="class"||t==="interface"||t==="trait"||t==="struct"||t==="enum"||t==="type"?"Class":"Other"}async parse(t,i){await this.ensureInitialized();let e=it.extname(t).toLowerCase(),s=await this.getLanguage(e);if(!s||!this.parser)return[];this.parser.setLanguage(s);let l=this.parser.parse(i),f=i.split(`
|
|
28
|
+
`),y=this.getQueries(e);if(!y)return[];let o=new ie.Query(s,y).matches(l.rootNode),u=[];for(let a of o){let c=a.captures.find(p=>p.name==="name")?.node,m=a.captures[0].node,r=a.captures[0].name;if(c){let p=m.startPosition.row+1,g=m.endPosition.row+1,x=f[m.startPosition.row].trim();u.push({name:c.text,kind:this.mapKind(r,e),classification:this.mapClassification(r),signature:x,line:p,endLine:g,doc:"",capabilities:"{}"})}}return u}};function ye(n){let{classification:t,capabilities:i,exports:e,fileName:s}=n,l={Network:"API integration",Database:"data persistence","File System":"file I/O operations","Browser Storage":"client-side storage"},f=i.map(r=>l[r]).filter(Boolean).join(" and "),E={Component:(r,p)=>{let g=p.find(S=>S.kind==="FunctionDeclaration"||S.kind==="ClassDeclaration")?.name,x=g?`React component: ${g}`:"React UI component";return r?`${x} with ${r}`:x},Hook:(r,p)=>{let g=p.find(S=>S.name.startsWith("use"))?.name,x=g?`Custom React hook: ${g}`:"Custom React hook";return r?`${x} for ${r}`:x},Service:(r,p)=>{let x=`Service layer: ${p[0]?.name||"Service"}`;return r?`${x} handling ${r}`:x},Repository:(r,p)=>`Data repository: ${p[0]?.name||"Repository"} for ${r||"data access"}`,"Type Definition":(r,p)=>`Type definitions: ${p.slice(0,3).map(x=>x.name).join("")}${p.length>3?"...":""}`,Model:(r,p)=>`Data model: ${p[0]?.name||"Model"}`,"HTTP Route":(r,p)=>{let g=p.filter(x=>x.classification==="Service Boundary");return g.length>0?`API endpoints: ${g.slice(0,3).map(x=>x.name).join("")}`:"API route handler"},"Micro IR (PHP)":(r,p)=>{let g=p.some(S=>S.classification==="Service Boundary"),x=p.find(S=>S.kind==="ClassDeclaration")?.name;return g?"PHP controller with API routes":x?`PHP class: ${x}`:"PHP module"},"Micro IR (Python)":(r,p)=>{let g=p.some(S=>S.classification==="Service Boundary"),x=p.find(S=>S.kind==="ClassDeclaration")?.name;return g?"Python API handler with routes":x?`Python class: ${x}`:"Python module"},"Micro IR (Go/TS) ":(r,p)=>{let g=p.some(S=>S.kind==="TypeDeclaration"),x=p.filter(S=>S.kind==="FunctionDeclaration");return g&&x.length>0?`Go package: types and ${x.length} function(s)`:g?"Go package: type definitions":x.length>0?`Go package: ${x[0].name} and ${x.length} function(s)`:"Go module"},"Micro IR (Rust/TS) ":(r,p)=>{let g=p.find(d=>d.kind==="TraitDeclaration")?.name,x=p.find(d=>d.kind==="StructDeclaration")?.name,S=p.filter(d=>d.kind==="FunctionDeclaration");return g?r.includes("Rust trait")?`Rust module: trait ${g}`:`Rust module: ${g}`:x?`Rust module: struct ${x}`:S.length>0?`Rust module: ${S.length} function(s)`:"Rust module"}}[t];if(E)return E(f,e);if(e.length===0)return s?`Module: ${s}`:"Module with no exports";let o=e.filter(r=>r.kind==="FunctionDeclaration"),u=e.filter(r=>r.kind==="ClassDeclaration"),a=e.filter(r=>r.kind==="TsInterfaceDeclaration"||r.kind==="TsTypeAliasDeclaration"),c=[];if(u.length>0&&c.push(`Class: ${u[0].name}`),o.length>0){let r=o.slice(0,2).map(p=>p.name).join("");c.push(`Functions: ${r}`)}a.length>0&&c.push(`Types: ${a.length}`);let m=c.length>0?c.join(" | "):`Module with ${e.length} export(s)`;return f?`${m} \u2014 ${f}`:m}var Ce=class{parse(t,i=!1){let e=[],s=[],l=t.split(`
|
|
29
|
+
`),f="",y="",E=0,o=0,u=-1,a=-1,c=[],m=[],r=!1,p=i?"api":"",g="",x=/^namespace\s+([a-zA-Z0-9_\\]+);/,S=/^(?:abstract\s+)?(?:readonly\s+)?class\s+([a-zA-Z0-9_]+)/,d=/^interface\s+([a-zA-Z0-9_]+)/,T=/^trait\s+([a-zA-Z0-9_]+)/,C=/^enum\s+([a-zA-Z0-9_]+)(?:\s*:\s*(string|int))?\s*/,N=/^((?:(?:public|protected|private|static)\s+)*)function\s+([a-zA-Z0-9_]+)\s*\(/,O=/^(public|protected|private)\s+(static\s+)?(readonly\s+)?(?:(\?\s*)?([a-zA-Z0-9_\\|]+)\s+)?\$([a-zA-Z0-9_]+)/,q=/^use\s+([a-zA-Z0-9_\\]+)(?:\s+as\s+([a-zA-Z0-9_]+))?;/,A=/^#\[([a-zA-Z0-9_\\]+)(?:\((.*)\))?\]/,z=/(?:Route::|router->|\$router->|->)(get|post|put|delete|patch|match)\s*\(\s*(?:uri\s*:\s*)?['"]([^'"]+)['"]/,W=/->prefix\s*\(\s*(?:prefix\s*:\s*)?['"]([^'"]+)['"]/,le=/\$this->(hasMany|hasOne|belongsTo|belongsToMany|morphTo|morphMany|morphOne|morphToMany|morphedByMany)\s*\(\s*([a-zA-Z0-9_\\]+)(?:::class)?/,Fe=/^->(hasMany|hasOne|belongsTo|belongsToMany|morphTo|morphMany|morphOne|morphToMany|morphedByMany)\s*\(\s*([a-zA-Z0-9_\\]+)(?:::class)?/,ge=/(public|protected|private)\s+(readonly\s+)?(?:(\?\s*)?([a-zA-Z0-9_\\|]+)\s+)?\$([a-zA-Z0-9_]+)/g,be=/(?:protected|public)\s+\$(fillable|casts|guarded|hidden|appends|with)\s*=/;function xe(b){try{let h=JSON.parse(b||"{}");if(h&&typeof h=="object"&&!Array.isArray(h))return h}catch{}return{}}function pe(b,h){let _=[],D=b,v=0,k=0;for(;D<l.length;){let F=l[D].trim();_.push(F),v+=(F.match(/\[/g)||[]).length-(F.match(/]/g)||[]).length,k+=(F.match(/\(/g)||[]).length-(F.match(/\)/g)||[]).length;let j=F.includes(h),H=v<=0&&k<=0;if(j&&H)break;D+=1}return{text:_.join(" "),endIndex:D}}function se(b,h){let _=h.replace(/^[^=]+=\s*/,"").replace(/;$/,"").trim();if(b==="casts"){let F={},j=/['"]([^'"]+)['"]\s*=>\s*['"]([^'"]+)['"]/g,H=null;for(;H=j.exec(_);)F[H[1]]=H[2];return F}let D=[],v=/['"]([^'"]+)['"]/g,k=null;for(;k=v.exec(_);)D.push(k[1]);return D}function we(b,h){for(let _=h;_>=0;_-=1){let D=b[_]?.trim()||"";if(D)return D}return""}function re(b,h,_,D){if(!f)return;let v=h.split("\\").pop()||h;s.push({type:"eloquent_relation",name:v,direction:"produce",line:_,snippet:D,method:b,url:`${f}->${v}`})}for(let b=0;b<l.length;b++){let h=l[b].trim();if(!h)continue;let _=(h.match(/{/g)||[]).length,D=(h.match(/}/g)||[]).length,v=o;if(o+=_-D,y&&o<=a){let R=e.find(M=>M.name===y&&M.line===E);R&&(R.endLine=b+1),y="",a=-1}if(f&&o<=u){let R=e.find(M=>M.name===f&&(M.kind==="ClassDeclaration"||M.kind==="TraitDeclaration"||M.kind==="InterfaceDeclaration"||M.kind==="EnumDeclaration"));R&&(R.endLine=b+1),f="",u=-1}let k=h.match(W);if(k&&(p=k[1]),h.includes("});")&&(p=""),h.startsWith("/**")){r=!0,m=[];continue}if(r){h.endsWith("*/")?r=!1:m.push(h.replace(/^\*\s?/,""));continue}let F=h.match(A);if(F){c.push(F[1]);continue}let j=h.match(x);if(j){g=j[1]||"",c=[],m=[];continue}let H=h.match(S);if(H){f=H[1],u=o-_;let R={attributes:c};g&&(R.namespace=g),e.push({name:f,kind:"ClassDeclaration",classification:"Class",signature:`class ${f}`,line:b+1,endLine:b+1,doc:m.join(`
|
|
30
30
|
`).trim(),capabilities:JSON.stringify(R),members:[]}),c=[],m=[];continue}let X=h.match(d);if(X){let R=X[1];f=R,u=o-_,e.push({name:R,kind:"InterfaceDeclaration",classification:"Interface",signature:`interface ${R}`,line:b+1,endLine:b+1,doc:m.join(`
|
|
31
31
|
`).trim(),capabilities:JSON.stringify({attributes:c}),members:[]}),c=[],m=[];continue}let ue=h.match(T);if(ue){let R=ue[1];f=R,u=o-_,e.push({name:R,kind:"TraitDeclaration",classification:"Trait",signature:`trait ${R}`,line:b+1,endLine:b+1,doc:m.join(`
|
|
32
32
|
`).trim(),capabilities:JSON.stringify({attributes:c}),members:[]}),c=[],m=[];continue}let ae=h.match(C);if(ae){let R=ae[1],M=ae[2]||null;f=R,u=o-_;let Z={attributes:c,backedType:M};g&&(Z.namespace=g),e.push({name:R,kind:"EnumDeclaration",classification:"Enum",signature:M?`enum ${R}: ${M}`:`enum ${R}`,line:b+1,endLine:b+1,doc:m.join(`
|
|
33
|
-
`).trim(),capabilities:JSON.stringify(Z),members:[]}),c=[],m=[];continue}let me=h.match(N);if(me){let R=(me[1]||"").trim(),M=me[2],Z=!!f,
|
|
34
|
-
`).trim();if(We){let
|
|
35
|
-
`).trim(),capabilities:JSON.stringify({visibility:R,static:M,readonly:Z,type:
|
|
36
|
-
`),l=[{indent:-1,name:"root",type:"root"}],f=[],y=/^class\s+([a-zA-Z0-9_]+)/,E=/^async\s+def\s+([a-zA-Z0-9_]+)|^def\s+([a-zA-Z0-9_]+)/,o=/^(?:from\s+([a-zA-Z0-9_
|
|
37
|
-
`).trim()),x=[]}else x.push(C);continue}let q=T.search(/\S/),A=T.trim(),z=A.match(/^(['"]{3})/);if(z){let D=z[1],v=l[l.length-1];if(v.node&&!v.node.doc){if(A.substring(3).includes(D)){let k=A.replace(new RegExp(D,"g"),"").trim();v.node.doc=k}else{p=!0,g=D;let k=A.substring(3).trim();k&&x.push(k)}continue}}for(;l.length>1&&l[l.length-1].indent>=q;)l.pop();let W=l[l.length-1],le=W.type==="root"&&q===0;if(le&&/^__all__\s*=/.test(A)){let D=r(d),v=[],k=/['"]([^'"]+)['"]/g,F=null;for(;F=k.exec(D.text);)v.push(F[1]);let
|
|
33
|
+
`).trim(),capabilities:JSON.stringify(Z),members:[]}),c=[],m=[];continue}let me=h.match(N);if(me){let R=(me[1]||"").trim(),M=me[2],Z=!!f,B=/\bprivate\b/.test(R)?"private":/\bprotected\b/.test(R)?"protected":"public",L=/\bstatic\b/.test(R),G=pe(b,")"),te=G.text.match(/\)\s*:\s*([?a-zA-Z0-9_\\|]+)/),De=te?te[1]:null,pt=_>0&&D>=_;y=M,E=b+1,a=o-_;let We=!1,_e={};for(let J of c)J.toLowerCase().includes("route")&&(We=!0,_e={type:"route",method:"GET",path:"/"});let ze=m.join(`
|
|
34
|
+
`).trim();if(We){let J=_e.path||"/";e.push({name:J,kind:"HTTP Route",classification:"Service Boundary",signature:`Function: ${M}`,line:b+1,endLine:b+1,doc:ze,capabilities:JSON.stringify({type:"route",handler:f?`${f}@${M}`:M,..._e})}),s.push({type:"api_route",name:J,direction:"consume",line:b+1,snippet:h})}let Ze={name:M,kind:Z?"MethodDeclaration":"FunctionDeclaration",classification:Z?"Method":"Function",signature:`${Z?f+":: ":""}${M}`,line:b+1,endLine:b+1,doc:ze,capabilities:JSON.stringify(Z?{attributes:c,visibility:B,static:L,returnType:De}:{attributes:c,returnType:De})};e.push(Ze);let ke=Z?h.match(le):null;if(ke&&re(ke[1],ke[2],b+1,h),Z&&M==="__construct"){let J=null;for(;J=ge.exec(G.text);){let je=J[1],Be=!!J[2],Pe=J[4]?`${J[3]?"?":""}${J[4]}`:null,Oe=J[5],ut=`${je} ${Be?"readonly ":""}${Pe?`${Pe} `:""}$${Oe}`.trim();e.push({name:Oe,kind:"PropertyDeclaration",classification:"Property",signature:ut,line:b+1,endLine:b+1,doc:"",capabilities:JSON.stringify({visibility:je,static:!1,readonly:Be,type:Pe}),members:[]})}ge.lastIndex=0}pt&&(Ze.endLine=b+1,y="",a=-1),c=[],m=[];continue}let fe=!1,Q=!1,P=b,$=f&&!y?h.match(O):null;if($){fe=!0;let R=$[1],M=!!$[2],Z=!!$[3],B=$[5]?`${$[4]?"?":""}${$[5]}`:null,L=$[6],G=`${R} ${M?"static ":""}${Z?"readonly ":""}${B?`${B} `:""}$${L}`.trim();e.push({name:L,kind:"PropertyDeclaration",classification:"Property",signature:G,line:b+1,endLine:b+1,doc:m.join(`
|
|
35
|
+
`).trim(),capabilities:JSON.stringify({visibility:R,static:M,readonly:Z,type:B}),members:[]})}let Y=f&&!y?h.match(be):null;if(Y){Q=!0;let R=Y[1],M=pe(b,";");P=M.endIndex;let Z=se(R,M.text),B=[...e].reverse().find(L=>L.name===f&&L.kind==="ClassDeclaration");if(B){let L=xe(B.capabilities);(!L.modelConfig||typeof L.modelConfig!="object"||Array.isArray(L.modelConfig))&&(L.modelConfig={}),L.modelConfig[R]=Z,B.capabilities=JSON.stringify(L)}}if(fe||Q){Q&&P>b&&(b=P),c=[],m=[];continue}let oe=h.match(q);if(oe){let R=oe[1]||"",M=oe[2]||R.split("\\").pop()||"";e.push({name:M,kind:"ImportSpecifier",classification:"Dependency",signature:`use ${R}`,line:b+1,endLine:b+1,doc:"",capabilities:JSON.stringify({type:"use",namespace:R})}),c=[],m=[];continue}let K=h.match(z);if(K){let R=K[1].toUpperCase(),M=K[2];if(h.includes("Route::")||h.includes("router->")||h.includes("action")||h.includes(",")&&!h.includes("view(")){if(p){let te=p.startsWith("/")?p:`/${p}`,De=M.startsWith("/")?M:`/${M}`;M=(te+De).replace(/\/+/g,"/")}let B=null,L=h.match(/\[\s*([a-zA-Z0-9_]+)::class\s*,\s*['"]([^'"]+)['"]\s*\]/);if(L)B=`${L[1]}@${L[2]}`;else if(h.includes("::class")){let te=h.match(/([a-zA-Z0-9_]+)::class/);te&&(B=te[1])}let G=h;!h.endsWith(");")&&b+1<l.length&&(G+=" "+l[b+1].trim(),!G.endsWith(");")&&b+2<l.length&&(G+=" "+l[b+2].trim())),e.push({name:M,kind:"HTTP Route",classification:"Service Boundary",signature:G,line:b+1,endLine:b+1,doc:"",capabilities:JSON.stringify({type:"route",method:R,path:M,handler:B})}),s.push({type:"api_route",name:M,direction:"consume",line:b+1,snippet:G,method:R,url:M}),m=[];continue}}let ee=f&&y?h.match(le):null,de=f&&y?h.match(Fe):null;if(ee)re(ee[1],ee[2],b+1,h);else if(de){let R=we(l,b-1);/\$this\b/.test(R)&&re(de[1],de[2],b+1,h)}let lt=/(?:\$client|client|Http)::(get|post|put|delete|patch|request)\s*\(\s*(?:url\s*:\s*)?([^,)]+)|(?:\$client|client)->(request|get|post|put|delete|patch)\s*\(\s*([^,)]+)/,he=h.match(lt);if(he){let R=(he[1]||he[3]).toUpperCase(),M=(he[2]||he[4]).trim();(M.startsWith("'")&&M.endsWith("'")||M.startsWith('"')&&M.endsWith('"'))&&(M=M.substring(1,M.length-1)),s.push({type:"api_route",name:M,direction:"produce",line:b+1,snippet:h,method:R,url:M})}!h.startsWith("#[")&&!h.startsWith("//")&&!h.startsWith("*")&&!r&&(c=[],m=[])}return{nodes:e,events:s}}};var Ee=class{currentRoutePrefix="";parse(t){this.currentRoutePrefix="";let i=[],e=[],s=t.split(`
|
|
36
|
+
`),l=[{indent:-1,name:"root",type:"root"}],f=[],y=/^class\s+([a-zA-Z0-9_]+)/,E=/^async\s+def\s+([a-zA-Z0-9_]+)|^def\s+([a-zA-Z0-9_]+)/,o=/^(?:from\s+([a-zA-Z0-9_.]+)\s+import|import\s+([a-zA-Z0-9_.]+))/,u=/^@(.*)/;function a(d){return d.trim().split(/[.(]/)[0]?.trim()||d}function c(d){let T=d.decorators.map(N=>a(N.raw)),C={decorators:d.decorators,decoratorNames:T};return d.async===!0&&(C.async=!0),d.accessor&&(C.accessor=d.accessor),d.contextmanager===!0&&(C.contextmanager=!0),JSON.stringify(C)}function m(d,T){return(d.match(new RegExp(`\\${T}`,"g"))||[]).length}function r(d){let T=[],C=d,N=0,O=0,q=0,A=!1;do{let z=s[C].trim();if(T.push(z),N+=m(z,"(")-m(z,")"),O+=m(z,"[")-m(z,"]"),q+=m(z,"{")-m(z,"}"),A=z.endsWith("\\"),C+1>=s.length||N<=0&&O<=0&&q<=0&&!A)break;C+=1}while(!0);return{text:T.join(" "),endIndex:C}}let p=!1,g="",x=[],S=[];for(let d=0;d<s.length;d++){let T=s[d],C=T.trim();if(!C||C.startsWith("#"))continue;let N=/^([a-zA-Z0-9_]+)\s*=\s*(?:APIRouter|Blueprint)\s*\(\s*(?:prefix\s*=\s*)?['"]([^'"]+)['"]/,O=C.match(N);if(O&&(this.currentRoutePrefix=O[2]),p){if(C.endsWith(g)||C.includes(g)){p=!1;let D=C.replace(g,"").trim();D&&x.push(D);let v=l[l.length-1];v.node&&(v.node.doc=x.join(`
|
|
37
|
+
`).trim()),x=[]}else x.push(C);continue}let q=T.search(/\S/),A=T.trim(),z=A.match(/^(['"]{3})/);if(z){let D=z[1],v=l[l.length-1];if(v.node&&!v.node.doc){if(A.substring(3).includes(D)){let k=A.replace(new RegExp(D,"g"),"").trim();v.node.doc=k}else{p=!0,g=D;let k=A.substring(3).trim();k&&x.push(k)}continue}}for(;l.length>1&&l[l.length-1].indent>=q;)l.pop();let W=l[l.length-1],le=W.type==="root"&&q===0;if(le&&/^__all__\s*=/.test(A)){let D=r(d),v=[],k=/['"]([^'"]+)['"]/g,F=null;for(;F=k.exec(D.text);)v.push(F[1]);let j={name:"__all__",kind:"ModuleExports",classification:"ExportList",signature:"__all__ = [...]",line:d+1,endLine:D.endIndex+1,doc:"",capabilities:JSON.stringify({exports:v}),members:[]};S.push(j),i.push(j),d=D.endIndex,f=[];continue}let ge=/^([A-Z][A-Z0-9_]*)(?:\s*:\s*[^=]+)?\s*=/,be=le?A.match(ge):null;if(be){let D=r(d),v=D.text.length>120?`${D.text.slice(0,117)}...`:D.text,k={name:be[1],kind:"VariableDeclaration",classification:"Constant",signature:v,line:d+1,endLine:D.endIndex+1,doc:"",capabilities:"{}",members:[]};S.push(k),i.push(k),d=D.endIndex,f=[];continue}let xe=A.match(u);if(xe){f.push({raw:xe[1].trim(),line:d+1});continue}let pe=A.match(y);if(pe){let D=pe[1],v={name:D,kind:"ClassDeclaration",classification:"Class",signature:`class ${D}`,line:d+1,endLine:d+1,doc:"",capabilities:c({decorators:f}),members:[]};S.push(v),W.node?(W.node.members||(W.node.members=[]),W.node.members.push(v)):i.push(v),l.push({indent:q,name:D,type:"class",node:v}),f=[];continue}let se=A.match(E);if(se){let D=!!se[1],v=se[1]||se[2],k=W.type==="class",F=f.some(P=>/(?:^|\.)contextmanager$/.test(P.raw.trim())),j;f.some(P=>P.raw.trim()==="property")&&(j="getter");for(let P of f){let $=P.raw.trim().match(/^[a-zA-Z_][a-zA-Z0-9_]*\.(setter|deleter)$/);if($){j=$[1];break}}let H=!1,X={};for(let P of f)if(P.raw.match(/(?:app|router)\.(get|post|put|delete|patch|websocket)/)){H=!0;let Y=["get","post","put","delete","patch","websocket"].find(ee=>P.raw.toLowerCase().includes(`.${ee}`))?.toUpperCase()||"GET",oe=P.raw.match(/['"]([^'"]+)['"]/),K=oe?oe[1]:"/";if(this.currentRoutePrefix){let ee=this.currentRoutePrefix.endsWith("/")?this.currentRoutePrefix.slice(0,-1):this.currentRoutePrefix,de=K.startsWith("/")?K:`/${K}`;K=ee+de}X={type:"route",method:Y,path:K}}if(H){let P=X.path||"",$=X.method==="WEBSOCKET",Y={name:P||v,kind:$?"WebSocket Route":"HTTP Route",classification:"Service Boundary",signature:`Function: ${v}`,line:d+1,endLine:d+1,doc:"",capabilities:JSON.stringify({handler:k?`${W.name}.${v}`:v,async:D,...X})};S.push(Y),i.push(Y),e.push({type:$?"websocket_route":"api_route",name:P,direction:"consume",line:d+1,snippet:A})}for(let P of f){let $=P.raw.match(/(?:^|\.)receiver\s*\(\s*([a-zA-Z0-9_.]+)/);$&&e.push({type:"signal",name:$[1].split(".").pop()||$[1],direction:"consume",line:P.line,snippet:`@${P.raw}`})}let ue=f.some(P=>P.raw==="staticmethod"),ae=f.some(P=>P.raw==="classmethod"),me=`${D?"async ":""}${k?(ue?"@staticmethod ":ae?"@classmethod ":"")+W.name+".":""}${v}`,fe=!!j,Q={name:v,kind:fe?"PropertyDeclaration":D&&k?"AsyncMethodDeclaration":D?"AsyncFunctionDeclaration":k?"MethodDeclaration":"FunctionDeclaration",classification:fe?"Property":k?ue||ae?"Static Method":"Method":"Function",signature:me,line:d+1,endLine:d+1,doc:"",capabilities:c({decorators:f,async:D,accessor:j,contextmanager:F}),members:[]};S.push(Q),W.node?(W.node.members||(W.node.members=[]),W.node.members.push(Q)):i.push(Q),l.push({indent:q,name:v,type:"function",node:Q}),f=[];continue}let we=/^(?:path|re_path|url)\s*\(\s*['"]([^'"]+)['"]/,re=A.match(we);if(re){let D=re[1].replace(/^\^/,""),v={name:D,kind:"HTTP Route",classification:"Service Boundary",signature:A.trim(),line:d+1,endLine:d+1,doc:"",capabilities:JSON.stringify({type:"route",method:"GET",path:D})};S.push(v),i.push(v),e.push({type:"api_route",name:D,direction:"consume",line:d+1,snippet:A});continue}let b=/(?:requests|httpx|client|http)\.(get|post|put|delete|patch|request)\s*\(\s*(?:url\s*:\s*)?([^,)]+)/,h=A.match(b);if(h){let D=h[1].toUpperCase(),v=h[2].trim();(v.startsWith("'")&&v.endsWith("'")||v.startsWith('"')&&v.endsWith('"'))&&(v=v.substring(1,v.length-1)),e.push({type:"api_route",name:v,direction:"produce",line:d+1,snippet:A,method:D,url:v})}let _=A.match(o);if(_){let D=_[1]||_[2],v={name:D,kind:"ImportSpecifier",classification:"Dependency",signature:`import ${D}`,line:d+1,endLine:d+1,doc:"",capabilities:JSON.stringify({type:"import",module:D})};S.push(v),i.push(v),f=[];continue}f=[],W.node&&(W.node.endLine=d+1)}return{nodes:S,events:e}}};function Et(n,t){let i=0,e=!1;for(let s=t;s<n.length;s++){let l=n[s];for(let f of l)if(f==="{")i++,e=!0;else if(f==="}"&&(i--,e&&i<=0))return s+1;if(!e&&s>t&&/[;}]$/.test(l.trim()))return s+1}return Math.min(n.length,t+41)}var st=[{extension:[".php"],rules:[]},{extension:[".py"],rules:[]},{extension:[".go"],rules:[{regex:/func\s+([a-zA-Z0-9_]+)\(/g,onMatch:n=>({name:n[1],kind:"FunctionDeclaration",classification:"Function",signature:n[0]})},{regex:/func\s+\([^)]+\)\s+([a-zA-Z0-9_]+)\(/g,onMatch:n=>({name:n[1],kind:"MethodDeclaration",classification:"Method",signature:n[0]})},{regex:/import\s+['"]([^'"]+)['"]/g,onMatch:n=>({name:n[1],kind:"ImportSpecifier",classification:"Dependency",signature:n[0],meta:{type:"import",path:n[1]}})}]},{extension:[".rs"],rules:[{regex:/fn\s+([a-zA-Z0-9_]+)\s*\(/g,onMatch:n=>({name:n[1],kind:"FunctionDeclaration",classification:"Function",signature:n[0]})},{regex:/struct\s+([a-zA-Z0-9_]+)/g,onMatch:n=>({name:n[1],kind:"StructDeclaration",classification:"Class",signature:n[0]})},{regex:/enum\s+([a-zA-Z0-9_]+)/g,onMatch:n=>({name:n[1],kind:"EnumDeclaration",classification:"Class",signature:n[0]})},{regex:/trait\s+([a-zA-Z0-9_]+)/g,onMatch:n=>({name:n[1],kind:"TraitDeclaration",classification:"Class",signature:n[0]})},{regex:/use\s+([a-zA-Z0-9_:]+(?:\s+as\s+[a-zA-Z0-9_]+)?);/g,onMatch:n=>({name:n[1].trim(),kind:"ImportDeclaration",classification:"Dependency",signature:n[0],meta:{type:"import",path:n[1].trim()}})}]},{extension:[".ts",".tsx",".js",".jsx",".mjs",".cjs"],rules:[{regex:/(?:export\s+)?(?:async\s+)?function\s+([a-zA-Z0-9_]+)\s*\(/g,onMatch:n=>({name:n[1],kind:"FunctionDeclaration",classification:"Function"})},{regex:/(?:export\s+)?class\s+([a-zA-Z0-9_]+)/g,onMatch:n=>({name:n[1],kind:"ClassDeclaration",classification:"Class"})},{regex:/(?:export\s+)?interface\s+([a-zA-Z0-9_]+)/g,onMatch:n=>({name:n[1],kind:"InterfaceDeclaration",classification:"Interface"})},{regex:/(?:export\s+)?const\s+([a-zA-Z0-9_]+)\s*=/g,onMatch:n=>({name:n[1],kind:"VariableDeclaration",classification:"Constant"})},{regex:/import\s+.*\s+from\s+['"]([^'"]+)['"]/g,onMatch:n=>({name:n[1],kind:"ImportDeclaration",classification:"Dependency",meta:{path:n[1]}})}]}];function Tt(n,t){let i=[];if(n===".go"&&t.some(e=>e.kind==="TypeDeclaration")&&i.push("Go type"),n===".rs"&&(t.some(e=>e.kind==="TraitDeclaration")&&i.push("Rust trait"),t.some(e=>e.kind==="StructDeclaration")&&i.push("Rust struct"),t.some(e=>e.kind==="EnumDeclaration")&&i.push("Rust enum")),n===".py"){for(let e of t)if(e.capabilities)try{if(JSON.parse(e.capabilities).decoratorNames?.length){i.push("Python decorators");break}}catch{}t.some(e=>e.kind==="AsyncFunctionDeclaration"||e.kind==="AsyncMethodDeclaration")&&i.push("Async")}return i}var Te=class{phpParser=new Ce;pythonParser=new Ee;treeSitterParser=new Re;supports(t){return st.some(i=>i.extension.includes(t.toLowerCase()))}async parse(t,i){let e=Le.extname(t).toLowerCase(),s=[],l=[];if(e===".php"||e===".py"||e===".go"||e===".rs"){if(e===".py"){let o=this.pythonParser.parse(i);s=o.nodes,l=o.events}else if(e===".php"){let o=t.toLowerCase().endsWith("api.php"),u=this.phpParser.parse(i,o);s=u.nodes,l=u.events}else try{s=await this.treeSitterParser.parse(t,i)}catch{}if(s.length>0){let o=e===".php"?"Micro IR (PHP/TS) ":e===".py"?"Micro IR (Python/TS) ":e===".go"?"Micro IR (Go/TS) ":"Micro IR (Rust/TS) ",u=s.filter(r=>r.classification!=="Dependency"),a=s.filter(r=>r.classification==="Dependency"),c=Tt(e,s),m=ye({classification:o,capabilities:c,exports:u.map(r=>({name:r.name,kind:r.kind,classification:r.classification})),fileName:Le.basename(t)});return{exports:u,imports:a.map(r=>({module:r.name,name:r.name,kind:r.kind,classification:r.classification})),events:l,classification:o,summary:m||`${e.substring(1).toUpperCase()} module`,parseStatus:"success"}}}let f=st.find(o=>o.extension.includes(e));if(!f)return{exports:[],imports:[],classification:"Unknown",summary:"",parseStatus:"failed",parseError:`Unsupported file extension: ${e}`};let y=i.split(`
|
|
38
38
|
`);for(let o of f.rules){o.regex.lastIndex=0;let u;for(;(u=o.regex.exec(i))!==null;){let a=o.onMatch(u),c=i.substring(0,u.index).split(`
|
|
39
|
-
`).length,m=
|
|
39
|
+
`).length,m=Et(y,c-1);s.push({name:a.name||"anonymous",kind:a.kind||"Unknown",classification:a.classification||"Other",signature:a.signature||u[0],line:c,endLine:m,doc:"",capabilities:JSON.stringify(a.meta||{})})}}let E=ye({classification:`Micro IR (${e.substring(1).toUpperCase()})`,capabilities:[],exports:s.map(o=>({name:o.name,kind:o.kind,classification:o.classification})),fileName:Le.basename(t)});return{exports:s,imports:[],classification:`Micro IR (${e.substring(1).toUpperCase()})`,summary:E||"Module",parseStatus:s.length>0?"success":"partial"}}};function rt(n){let t=new Set;function i(e){if(!(!e||typeof e!="object")){e.typeAnnotation&&I(e.typeAnnotation,t),(e.type==="TsTypeReference"||e.type==="TsTypeAnnotation")&&I(e,t);for(let s in e){if(s==="span"||s==="comments"||s==="interpreter")continue;let l=e[s];l&&typeof l=="object"&&(Array.isArray(l)?l.forEach(i):i(l))}}}return n.forEach(e=>i(e)),Array.from(t)}function I(n,t){if(n){if(n.type==="TsTypeAnnotation"){I(n.typeAnnotation,t);return}n.type==="TsTypeReference"&&(n.typeName?.type==="Identifier"&&t.add(n.typeName.value),n.typeName?.type==="TsQualifiedName"&&at(n.typeName,t),n.typeParams&&I(n.typeParams,t)),n.type==="TsArrayType"&&I(n.elementType,t),n.type==="TsUnionType"&&n.types?.forEach(i=>I(i,t)),n.type==="TsIntersectionType"&&n.types?.forEach(i=>I(i,t)),n.type==="TsTupleType"&&n.elemTypes?.forEach(i=>I(i.ty,t)),(n.type==="TsFunctionType"||n.type==="TsConstructorType")&&(n.params?.forEach(i=>I(i.typeAnnotation,t)),n.typeAnnotation&&I(n.typeAnnotation,t)),n.type==="TsTypeParameterDeclaration"&&n.params?.forEach(i=>{i.constraint&&I(i.constraint,t),i.default&&I(i.default,t)}),n.type==="TsTypeParameterInstantiation"&&n.params?.forEach(i=>I(i,t)),n.type==="TsMappedType"&&n.typeAnnotation&&I(n.typeAnnotation,t),n.type==="TsIndexedAccessType"&&(I(n.objectType,t),I(n.indexType,t)),n.type==="TsConditionalType"&&(I(n.checkType,t),I(n.extendsType,t),I(n.trueType,t),I(n.falseType,t)),n.type==="TsTypeLiteral"&&n.members?.forEach(i=>{i.typeAnnotation&&I(i.typeAnnotation,t)})}}function at(n,t){n.type==="TsQualifiedName"?(n.left&&at(n.left,t),n.right?.value&&t.add(n.right.value)):n.type==="Identifier"&&t.add(n.value)}var Ne=new Te;async function vn(n){let t=ct.extname(n);if(Ne.supports(t)&&t!==".ts"&&t!==".tsx")try{let l=await ot.promises.readFile(n,"utf-8");return{...await Ne.parse(n,l),content:l}}catch(l){return ne.error({filePath:n,error:l.message},"HeuristicParser failed"),{exports:[],imports:[],classification:"Unknown",summary:"",content:"",parseStatus:"failed",parseError:l.message}}let i;try{i=await ot.promises.readFile(n)}catch(l){return{exports:[],imports:[],classification:"Error",summary:"",content:"",parseStatus:"failed",parseError:`File read error: ${l.message}`}}let e=i.toString("utf8"),s=Ue(e);try{let l=n.endsWith(".tsx"),f=n.endsWith(".d.ts")||n.endsWith(".d.tsx"),y,E={syntax:"typescript",tsx:l,decorators:!0,comments:!0};if(f)try{y=Se(e,E)}catch{y=Se(e,{...E,isModule:!1})}else y=Se(e,E);let o=y.span.start,u=Ve(i),a=qe(e),c=C=>Ge(C,o,i),m=Ke(y.body),r=rt(y.body);r.length>0&&ne.debug({filePath:n,count:r.length},"Extracted type references"),r.forEach(C=>{m.push({module:"__type_reference__",name:C})});let p=Qe(y.body,o,i,e,s,a,n,c,u),g=Xe(y.body,o,i,s,c,u),x=ve(n,"","Module"),d=a.length>0&&e.slice(0,a[0].start).trim().length===0?a[0].text:p.find(C=>C.doc)?.doc||"",T=He(d);if(!T&&p.length>0){let C=ce(e);T=ye({classification:x,capabilities:C,exports:p.map(N=>({name:N.name,kind:N.kind,classification:N.classification})),fileName:ct.basename(n)})}return{exports:p,imports:m,events:g,classification:x,summary:T,content:e,parseStatus:"success"}}catch(l){ne.warn({filePath:n,error:l.message},"SWC parsing failed, using heuristic fallback");try{let f=await Ne.parse(n,e);return{...f,content:e,classification:f.classification+" (Degraded)",parseStatus:"partial",parseError:`SWC failed, used heuristic fallback: ${l.message}`}}catch(f){return ne.error({filePath:n,error:f.message},"All parsing strategies failed"),{exports:[],imports:[],classification:"Error",summary:"",content:e,parseStatus:"failed",parseError:`All parsing strategies failed: ${f.message}`}}}}export{vn as parseFile};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{existsSync as n}from"node:fs";import{dirname as d,join as c}from"node:path";import{fileURLToPath as f}from"node:url";import{parentPort as i}from"node:worker_threads";var l=f(import.meta.url),a=d(l),t=null;async function p(){if(t)return t;let e,r=c(a,"index.ts"),s=c(a,"index.js");if(n(r)&&l.endsWith(".ts"))e=r;else if(n(s))e=s;else throw new Error(`Cannot find parser module in ${a}`);return t=(await import(e)).parseFile,t}async function g(e){if(e.type==="shutdown"&&process.exit(0),e.type==="parse")try{let s=await(await p())(e.filePath),o={type:"result",id:e.id,result:s};i?.postMessage(o)}catch(r){let s={type:"error",id:e.id,error:r instanceof Error?r.message:String(r)};i?.postMessage(s)}}async function y(){await p();let e={type:"ready"};i?.postMessage(e),i?.on("message",r=>{g(r).catch(s=>{console.error("Parser worker error:",s)})})}y().catch(e=>{console.error("Failed to initialize parser worker:",e),process.exit(1)});
|
|
@@ -10,7 +10,15 @@ Manage multi-repository workspaces and cross-repo mission links using the Shadow
|
|
|
10
10
|
## Core calls
|
|
11
11
|
|
|
12
12
|
- List active work across repos:
|
|
13
|
-
- `shadow_workspace_list({ repoPaths, status? })`
|
|
13
|
+
- `shadow_workspace_list({ repoPaths, status?, limit?, summarize? })`
|
|
14
|
+
- Inspect workspace identity, freshness, and next safe action:
|
|
15
|
+
- `shadow_workspace_status({ name?, repoPaths? })`
|
|
16
|
+
- Make a workspace usable without guessing whether to reuse, refresh, repair, or rebuild:
|
|
17
|
+
- `shadow_workspace_ensure({ repoPaths, name?, repairPolicy?, rebuildPolicy? })`
|
|
18
|
+
- Repair stale registry/db/lock state when a workspace exists but is degraded:
|
|
19
|
+
- `shadow_workspace_repair({ name?, repoPaths?, rebuildPolicy? })`
|
|
20
|
+
- Dry-run or apply cleanup for obsolete, duplicate, or orphaned workspaces:
|
|
21
|
+
- `shadow_workspace_gc({ name?, repoPaths?, apply?, olderThanDays?, includeCustom? })`
|
|
14
22
|
- Build a fused search index:
|
|
15
23
|
- `shadow_workspace_fuse({ repoPaths, name? })`
|
|
16
24
|
- Link missions across repos:
|
|
@@ -18,13 +26,27 @@ Manage multi-repository workspaces and cross-repo mission links using the Shadow
|
|
|
18
26
|
- Visualize a repo's mission graph:
|
|
19
27
|
- `shadow_ops_graph({ repoPath, missionId?, depth?, format? })`
|
|
20
28
|
|
|
29
|
+
## Recommended sequence
|
|
30
|
+
|
|
31
|
+
- Start with `shadow_workspace_status` when you need to know whether a named or inferred workspace is healthy.
|
|
32
|
+
- Use `shadow_workspace_ensure` for the normal "make this workspace work" path.
|
|
33
|
+
- Use `shadow_workspace_repair` when the workspace already exists and you specifically need cleanup/recovery behavior.
|
|
34
|
+
- Use `shadow_workspace_gc` for maintenance, duplicate cleanup, or stale/orphaned fused indexes.
|
|
35
|
+
- Use `shadow_workspace_fuse` only when you explicitly want to create a fused index, not as the default repair path.
|
|
36
|
+
- Use `shadow_workspace_list` when you need a federated mission/repo overview across multiple repos.
|
|
37
|
+
|
|
21
38
|
## After fusion
|
|
22
39
|
|
|
23
40
|
- Use the normal `shadow_search_*` and `shadow_analyze_*` tools inside the participating repos.
|
|
24
41
|
- For routes and events that cross repo boundaries, use:
|
|
25
42
|
- `shadow_analyze_mesh({ repoPath, topic, includeCrossRepo: true })`
|
|
43
|
+
- For cross-repo impact tracing, pair fused workspaces with:
|
|
44
|
+
- `shadow_analyze_impact({ repoPath, symbolName, filePath? })`
|
|
26
45
|
|
|
27
46
|
## Rules
|
|
28
47
|
|
|
29
|
-
- `shadow_workspace_list` and `
|
|
48
|
+
- `shadow_workspace_list`, `shadow_workspace_fuse`, and `shadow_workspace_ensure` take `repoPaths`, not `repoPath`.
|
|
49
|
+
- `shadow_workspace_status`, `shadow_workspace_repair`, and `shadow_workspace_gc` can resolve by `name`, `repoPaths`, or both depending on what context you have.
|
|
30
50
|
- `shadow_workspace_link` uses explicit parent and child repo paths; there is no shared `repoPath` parameter.
|
|
51
|
+
- Prefer `shadow_workspace_status` before mutating workspace state when you are unsure which workspace will be selected.
|
|
52
|
+
- Prefer `shadow_workspace_ensure` over calling `shadow_workspace_fuse` directly for routine operator/agent recovery.
|
package/dist/web-manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.11",
|
|
3
3
|
"toolsByPrefix": {
|
|
4
4
|
"RECON": {
|
|
5
5
|
"subcommands": [
|
|
@@ -80,9 +80,13 @@
|
|
|
80
80
|
},
|
|
81
81
|
"WORKSPACE": {
|
|
82
82
|
"subcommands": [
|
|
83
|
+
"ensure",
|
|
83
84
|
"fuse",
|
|
85
|
+
"gc",
|
|
84
86
|
"link",
|
|
85
|
-
"list"
|
|
87
|
+
"list",
|
|
88
|
+
"repair",
|
|
89
|
+
"status"
|
|
86
90
|
],
|
|
87
91
|
"description": "Federated view of active missions across multiple repositories."
|
|
88
92
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@precisionutilityguild/liquid-shadow",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "Tactical Repository Intelligence Operative - Liquid Shadow Ecosystem",
|
|
5
5
|
"homepage": "https://liquidshadow.pugcorp.online/",
|
|
6
6
|
"repository": {
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
"web-tree-sitter": "^0.26.3"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
|
+
"@biomejs/biome": "^2.4.9",
|
|
92
93
|
"@types/better-sqlite3": "^7.6.13",
|
|
93
94
|
"@types/js-yaml": "^4.0.9",
|
|
94
95
|
"@vitest/coverage-v8": "^4.0.18",
|
|
@@ -10,7 +10,15 @@ Manage multi-repository workspaces and cross-repo mission links using the Shadow
|
|
|
10
10
|
## Core calls
|
|
11
11
|
|
|
12
12
|
- List active work across repos:
|
|
13
|
-
- `shadow_workspace_list({ repoPaths, status? })`
|
|
13
|
+
- `shadow_workspace_list({ repoPaths, status?, limit?, summarize? })`
|
|
14
|
+
- Inspect workspace identity, freshness, and next safe action:
|
|
15
|
+
- `shadow_workspace_status({ name?, repoPaths? })`
|
|
16
|
+
- Make a workspace usable without guessing whether to reuse, refresh, repair, or rebuild:
|
|
17
|
+
- `shadow_workspace_ensure({ repoPaths, name?, repairPolicy?, rebuildPolicy? })`
|
|
18
|
+
- Repair stale registry/db/lock state when a workspace exists but is degraded:
|
|
19
|
+
- `shadow_workspace_repair({ name?, repoPaths?, rebuildPolicy? })`
|
|
20
|
+
- Dry-run or apply cleanup for obsolete, duplicate, or orphaned workspaces:
|
|
21
|
+
- `shadow_workspace_gc({ name?, repoPaths?, apply?, olderThanDays?, includeCustom? })`
|
|
14
22
|
- Build a fused search index:
|
|
15
23
|
- `shadow_workspace_fuse({ repoPaths, name? })`
|
|
16
24
|
- Link missions across repos:
|
|
@@ -18,13 +26,27 @@ Manage multi-repository workspaces and cross-repo mission links using the Shadow
|
|
|
18
26
|
- Visualize a repo's mission graph:
|
|
19
27
|
- `shadow_ops_graph({ repoPath, missionId?, depth?, format? })`
|
|
20
28
|
|
|
29
|
+
## Recommended sequence
|
|
30
|
+
|
|
31
|
+
- Start with `shadow_workspace_status` when you need to know whether a named or inferred workspace is healthy.
|
|
32
|
+
- Use `shadow_workspace_ensure` for the normal "make this workspace work" path.
|
|
33
|
+
- Use `shadow_workspace_repair` when the workspace already exists and you specifically need cleanup/recovery behavior.
|
|
34
|
+
- Use `shadow_workspace_gc` for maintenance, duplicate cleanup, or stale/orphaned fused indexes.
|
|
35
|
+
- Use `shadow_workspace_fuse` only when you explicitly want to create a fused index, not as the default repair path.
|
|
36
|
+
- Use `shadow_workspace_list` when you need a federated mission/repo overview across multiple repos.
|
|
37
|
+
|
|
21
38
|
## After fusion
|
|
22
39
|
|
|
23
40
|
- Use the normal `shadow_search_*` and `shadow_analyze_*` tools inside the participating repos.
|
|
24
41
|
- For routes and events that cross repo boundaries, use:
|
|
25
42
|
- `shadow_analyze_mesh({ repoPath, topic, includeCrossRepo: true })`
|
|
43
|
+
- For cross-repo impact tracing, pair fused workspaces with:
|
|
44
|
+
- `shadow_analyze_impact({ repoPath, symbolName, filePath? })`
|
|
26
45
|
|
|
27
46
|
## Rules
|
|
28
47
|
|
|
29
|
-
- `shadow_workspace_list` and `
|
|
48
|
+
- `shadow_workspace_list`, `shadow_workspace_fuse`, and `shadow_workspace_ensure` take `repoPaths`, not `repoPath`.
|
|
49
|
+
- `shadow_workspace_status`, `shadow_workspace_repair`, and `shadow_workspace_gc` can resolve by `name`, `repoPaths`, or both depending on what context you have.
|
|
30
50
|
- `shadow_workspace_link` uses explicit parent and child repo paths; there is no shared `repoPath` parameter.
|
|
51
|
+
- Prefer `shadow_workspace_status` before mutating workspace state when you are unsure which workspace will be selected.
|
|
52
|
+
- Prefer `shadow_workspace_ensure` over calling `shadow_workspace_fuse` directly for routine operator/agent recovery.
|