@precisionutilityguild/liquid-shadow 1.0.9 → 1.0.10

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 (39) hide show
  1. package/README.md +3 -3
  2. package/dist/data/migrations/000_baseline.sql +17 -0
  3. package/dist/data/migrations/014_tribunal_state.sql +24 -0
  4. package/dist/data/migrations/015_repo_level_handoffs_nullable.sql +52 -0
  5. package/dist/data/migrations/016_repair_tribunal_artifact_fk.sql +58 -0
  6. package/dist/entry/cli/index.js +540 -493
  7. package/dist/entry/ember/index.js +44 -20
  8. package/dist/entry/mcp/server.js +388 -347
  9. package/dist/entry/tribunal/index.js +650 -0
  10. package/dist/index.js +387 -346
  11. package/dist/logic/parser/index.js +16 -16
  12. package/dist/skills/shadow_audit/SKILL.md +22 -30
  13. package/dist/skills/shadow_chronicle/SKILL.md +16 -29
  14. package/dist/skills/shadow_continue/SKILL.md +37 -53
  15. package/dist/skills/shadow_coordinate/SKILL.md +46 -0
  16. package/dist/skills/shadow_crystallize/SKILL.md +13 -27
  17. package/dist/skills/shadow_mission/SKILL.md +27 -41
  18. package/dist/skills/shadow_onboard/SKILL.md +26 -35
  19. package/dist/skills/shadow_research/SKILL.md +15 -23
  20. package/dist/skills/shadow_sync/SKILL.md +18 -9
  21. package/dist/skills/shadow_synthesize/SKILL.md +14 -36
  22. package/dist/skills/shadow_trace_impact/SKILL.md +30 -50
  23. package/dist/skills/shadow_understand/SKILL.md +37 -52
  24. package/dist/skills/shadow_workspace/SKILL.md +17 -17
  25. package/dist/web-manifest.json +13 -6
  26. package/package.json +1 -1
  27. package/skills/shadow_audit/SKILL.md +22 -30
  28. package/skills/shadow_chronicle/SKILL.md +16 -29
  29. package/skills/shadow_continue/SKILL.md +37 -53
  30. package/skills/shadow_coordinate/SKILL.md +46 -0
  31. package/skills/shadow_crystallize/SKILL.md +13 -27
  32. package/skills/shadow_mission/SKILL.md +27 -41
  33. package/skills/shadow_onboard/SKILL.md +26 -35
  34. package/skills/shadow_research/SKILL.md +15 -23
  35. package/skills/shadow_sync/SKILL.md +18 -9
  36. package/skills/shadow_synthesize/SKILL.md +14 -36
  37. package/skills/shadow_trace_impact/SKILL.md +30 -50
  38. package/skills/shadow_understand/SKILL.md +37 -52
  39. package/skills/shadow_workspace/SKILL.md +17 -17
@@ -1,6 +1,6 @@
1
- import ot from"fs";function Je(t){let n=t.split(`
2
- `),i=[],e=0;for(let s of n)i.push(e),e+=s.length+1;return i}function E(t,n){for(let i=0;i<n.length;i++)if(n[i+1]>t||i===n.length-1)return i+1;return 1}function De(t,n){return n.slice(0,t).toString("utf8").length}function qe(t){if(t.toString("utf8").length===t.length)return e=>e;let i=new Map;return e=>{let s=i.get(e);return s===void 0&&(s=t.slice(0,e).toString("utf8").length,i.set(e,s)),s}}function He(t,n,i){let e=t.start-n,s=t.end-n;return e<0||s>i.length?"":i.slice(e,s).toString("utf8")}function Ue(t){let n=[],i=/\/\*\*[\s\S]*?\*\//g,e;for(;(e=i.exec(t))!==null;)n.push({start:e.index,end:e.index+e[0].length,text:e[0]});return n}function V(t,n,i){for(let e of n){if(e.start===t)return e.text;if(e.start>t&&e.start<t+50){let s=i.substring(t,e.start);if(/^\s*$/.test(s))return e.text}if(e.end<=t&&e.end>t-50){let s=i.substring(e.end,t);if(/^\s*$/.test(s))return e.text}}return""}function Ve(t){if(!t)return"";let i=t.replace(/\/\*\*|\*\/|\*/g,"").trim().split(`
3
- `)[0].trim();return i.length>200?i.substring(0,197)+"...":i}function ve(t,n,i){let e=t.toLowerCase(),s=n.toLowerCase();return e.includes("components/")||e.endsWith(".tsx")?"Component":e.startsWith("use")||s.startsWith("use")?"Hook":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":i==="TsInterfaceDeclaration"||i==="TsTypeAliasDeclaration"?"Type Definition":"Other"}function he(t){let n=[];return/\b(fetch|axios|superagent|got)\s*\(|import\s+.*\b(http|https|node-fetch)\b/i.test(t)&&n.push("Network"),(/\b(knex|prisma|typeorm|mongoose|sequelize|pg|mysql|sqlite3)\b/i.test(t)||/\b(SELECT\s+.*FROM|INSERT\s+INTO|UPDATE\s+.*SET|DELETE\s+FROM)\b/i.test(t)||/\.query\s*\(|\.execute\s*\(/i.test(t)&&/db|database|client|pool/i.test(t))&&n.push("Database"),(/\bfs\./i.test(t)||/\b(readFileSync|writeFileSync|readFile|writeFile|readdir)\b/.test(t)||/import\s+.*\bfs\b/.test(t))&&n.push("File System"),(/\b(localStorage|sessionStorage|indexedDB)\./.test(t)||/\bdocument\.cookie\b/.test(t))&&n.push("Browser Storage"),n}function G(t,n){if(!t)return"";let i=t.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(),n==="TsInterfaceDeclaration"||n==="TsTypeAliasDeclaration")return i;let e=0,s=0,l=i.length;for(let y=0;y<i.length;y++){let T=i[y];if(T==="(")e++;else if(T===")")e--;else if(T==="<")s++;else if(T===">")s--;else if(T==="{"){if(e===0&&s===0){l=y;break}}else if(T===";"&&e===0&&s===0){l=y;break}else if(T==="="&&i[y+1]===">"&&e===0&&s===0){l=y+2;break}}let m=i.substring(0,l).trim();return m.length>500?m.slice(0,497)+"...":m}function Ge(t){let n=[];for(let i of t)i.type==="ImportDeclaration"&&n.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"&&n.push({module:i.source.value,name:"*"}),i.type==="ExportNamedDeclaration"&&i.source&&n.push({module:i.source.value,name:i.specifiers.map(e=>e.type==="ExportSpecifier"?e.orig.value:"*").join(", ")});return n}function mt(t,n){for(let i of t){if((i.type==="FunctionDeclaration"||i.type==="ClassDeclaration")&&(i.identifier?.value||i.id?.value)===n)return i.span;if(i.type==="VariableDeclaration"){for(let e of i.declarations)if(e.id?.type==="Identifier"&&e.id.value===n)return e.span||i.span}if((i.type==="TsTypeAliasDeclaration"||i.type==="TsInterfaceDeclaration"||i.type==="TsEnumDeclaration")&&(i.id?.value||i.identifier?.value)===n)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)===n)return e.span||i.span;if(e.type==="VariableDeclaration"){for(let s of e.declarations)if(s.id?.type==="Identifier"&&s.id.value===n)return s.span||e.span||i.span}}}return null}function Ke(t,n,i,e,s,l,m,y,T){let o=T??(a=>De(a,i)),p=[];for(let a of t){if(a.type==="ExportDeclaration"){let c=a.declaration,f=c.type,r="";f==="VariableDeclaration"?r=c.declarations.map(w=>w.id.value).join("",""):r=c.id?.value||c.identifier?.value||"anonymous";let u=o(a.span.start-n),b=o(a.span.end-n),S=V(u,l,e),D=y(a.span),d=[];if(a.type==="ExportDeclaration"&&(f==="ClassDeclaration"||f==="ClassExpression")){let w=c.body||[];for(let C of w)if(C.type==="ClassMethod"||C.type==="ClassProperty"){let N=C.key.value;if(!N)continue;let j=o(C.span.start-n),q=o(C.span.end-n),P=y(C.span),z=V(j,l,e);d.push({name:N,kind:C.type,signature:G(P,C.type),line:E(j,s),endLine:E(q,s),doc:z,classification:C.type==="ClassMethod"?"Method":"Property",capabilities:"[]"})}}else if(f==="FunctionDeclaration"&&c.body?.type==="BlockStatement")d=Pe(c.body.stmts,n,i,e,s,l,y,o);else if(f==="VariableDeclaration"){for(let w of c.declarations)if(w.init&&(w.init.type==="ArrowFunctionExpression"||w.init.type==="FunctionExpression")&&w.init.body?.type==="BlockStatement"){d=Pe(w.init.body.stmts,n,i,e,s,l,y,o);break}}p.push({name:r,kind:f,signature:G(D,f),line:E(u,s),endLine:E(b,s),doc:S,classification:ve(m,r,f),capabilities:JSON.stringify(he(D)),members:d})}if(a.type==="ExportNamedDeclaration"){for(let c of a.specifiers)if(c.type==="ExportSpecifier"){let f=c.orig.value,r=c.exported?.value||f,b=mt(t,f)||a.span,S=o(b.start-n),D=o(b.end-n),d=V(S,l,e);p.push({name:r,kind:"ExportSpecifier",signature:`export { ${f} }`,line:E(S,s),endLine:E(D,s),doc:d,classification:"Export mapping",capabilities:"[]"})}}if(a.type==="ExportDefaultDeclaration"){let c=o(a.span.start-n),f=o(a.span.end-n),r=V(c,l,e),u=y(a.span),b=[];if(a.decl.type==="ClassExpression"||a.decl.type==="ClassDeclaration"){let S=a.decl.body||[];for(let D of S)if(D.type==="ClassMethod"||D.type==="ClassProperty"){let d=D.key.value;if(!d)continue;let w=o(D.span.start-n),C=o(D.span.end-n),N=y(D.span),j=V(w,l,e);b.push({name:d,kind:D.type,signature:G(N,D.type),line:E(w,s),endLine:E(C,s),doc:j,classification:D.type==="ClassMethod"?"Method":"Property",capabilities:"[]"})}}else(a.decl.type==="FunctionExpression"||a.decl.type==="FunctionDeclaration"||a.decl.type==="ArrowFunctionExpression")&&a.decl.body?.type==="BlockStatement"&&(b=Pe(a.decl.body.stmts,n,i,e,s,l,y,o));p.push({name:"default",kind:"DefaultExport",signature:G(u,"DefaultExport"),line:E(c,s),endLine:E(f,s),doc:r,classification:"Default Export",capabilities:JSON.stringify(he(u)),members:b})}if(a.type==="ExportAllDeclaration"){let c=o(a.span.start-n),f=o(a.span.end-n),r=a.source.value,u=V(c,l,e);p.push({name:"*",kind:"ExportAllDeclaration",signature:`export * from "${r}"`,line:E(c,s),endLine:E(f,s),doc:u,classification:"Re-export",capabilities:"[]"})}}return p}function Pe(t,n,i,e,s,l,m,y){let T=[];for(let o of t){if(o.type==="VariableDeclaration")for(let p 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 u of r.elements)u&&c(u);else if(r.type==="ObjectPattern")for(let u of r.properties)u.type==="AssignmentPatternProperty"?a.push({name:u.key.value,span:u.span}):u.type==="KeyValuePatternProperty"&&c(u.value)};c(p.id);let f=p.init&&(p.init.type==="ArrowFunctionExpression"||p.init.type==="FunctionExpression");for(let r of a){let u=f?p.init.span||p.span||r.span:p.span||r.span,b=f?p.init.type:"VariableDeclaration",S=f?"Internal Function":"Internal Variable",D=y(u.start-n),d=y(u.end-n),w=m(u),C=V(D,l,e);T.push({name:r.name,kind:b,signature:G(w,b),line:E(D,s),endLine:E(d,s),doc:C,classification:S,capabilities:"[]"})}}if(o.type==="FunctionDeclaration"){let p=o.identifier?.value||o.ident?.value||"anonymous",a=y(o.span.start-n),c=y(o.span.end-n),f=m(o.span),r=V(a,l,e);T.push({name:p,kind:"FunctionDeclaration",signature:G(f,"FunctionDeclaration"),line:E(a,s),endLine:E(c,s),doc:r,classification:"Internal Function",capabilities:"[]"})}if(o.type==="ReturnStatement"&&o.argument?.type==="ObjectExpression")for(let p of o.argument.properties){let a="",c=p.span||p.key?.span||p.ident?.span;if(p.type==="KeyValueProperty"){let f=p.key;a=f?.value||f?.raw||(f?.type==="Identifier"?f.value:"")}else p.type==="MethodProperty"?a=p.key?.value||p.key?.raw||"":p.type==="ShorthandProperty"?a=p.ident?.value||"":p.type==="Identifier"&&(a=p.value||"");if(a&&c){let f=y(c.start-n),r=y(c.end-n),u=m(c),b=V(f,l,e);T.push({name:a,kind:"ReturnProperty",signature:G(u,"ReturnProperty"),line:E(f,s),endLine:E(r,s),doc:b,classification:"Return Member",capabilities:"[]"})}}if(o.type==="ExpressionStatement"&&o.expression.type==="CallExpression"){let p=o.expression;if(p.callee.type==="MemberExpression"&&(p.callee.property?.value==="on"||p.callee.property?.value==="once")){let a=p.arguments[0]?.expression?.value,c=p.arguments[1]?.expression;if(a&&c&&(c.type==="ArrowFunctionExpression"||c.type==="FunctionExpression")){let f=y(c.span.start-n),r=y(c.span.end-n),u=m(c.span);T.push({name:`on:${a}`,kind:c.type,signature:G(u,c.type),line:E(f,s),endLine:E(r,s),doc:"",classification:"Event Handler",capabilities:"[]"})}}if(p.callee.type==="Identifier"&&p.callee.value==="addRoute"&&p.arguments.length>=3){let a=p.arguments[2].expression;if(a.type==="StringLiteral"){let c=a.value,f=y(p.span.start-n),r=y(p.span.end-n),u=m(p.span);T.push({name:c,kind:"HTTP Route",signature:G(u,"HTTP Route"),line:E(f,s),endLine:E(r,s),doc:"",classification:"Service Boundary",capabilities:JSON.stringify({path:c})})}}}}return T}function Qe(t,n,i,e,s,l){let m=l??(o=>De(o,i)),y=[];function T(o){if(!(!o||typeof o!="object")){if(o.type==="CallExpression"){let p=ft(o);if(p){let a=m(o.span.start-n);y.push({...p,line:E(a,e),snippet:s(o.span)})}}for(let p of Object.keys(o)){if(p==="span")continue;let a=o[p];Array.isArray(a)?a.forEach(T):typeof a=="object"&&T(a)}}}return t.forEach(T),y}function ft(t){let{callee:n,arguments:i}=t;if(!i||i.length===0)return null;if(n.type==="Identifier"&&n.value,n.type==="Identifier"&&n.value==="addRoute"&&i.length>=3){let e=i[2].expression;if(e.type==="StringLiteral")return{type:"api_route",name:e.value,direction:"consume"}}if(n.type==="MemberExpression"&&n.property?.type==="Identifier"){let e=n.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,m=n.object.type==="Identifier"?n.object.value:"";if(["axios","http","request","appApi","restApi","adminApi","client"].includes(m))return{type:"api_route",name:l,direction:"produce"};if(l.startsWith("/"))return{type:"api_route",name:l,direction:"consume"}}}return n.type==="Identifier"&&n.value==="fetch"&&i[0].expression.type==="StringLiteral"?{type:"api_route",name:i[0].expression.value,direction:"produce"}:null}function ye(t){let{classification:n,capabilities:i,exports:e,fileName:s}=t,l={Network:"API integration",Database:"data persistence","File System":"file I/O operations","Browser Storage":"client-side storage"},m=i.map(r=>l[r]).filter(Boolean).join(" and "),T={Component:(r,u)=>{let b=u.find(D=>D.kind==="FunctionDeclaration"||D.kind==="ClassDeclaration")?.name,S=b?`React component: ${b}`:"React UI component";return r?`${S} with ${r}`:S},Hook:(r,u)=>{let b=u.find(D=>D.name.startsWith("use"))?.name,S=b?`Custom React hook: ${b}`:"Custom React hook";return r?`${S} for ${r}`:S},Service:(r,u)=>{let S=`Service layer: ${u[0]?.name||"Service"}`;return r?`${S} handling ${r}`:S},Repository:(r,u)=>`Data repository: ${u[0]?.name||"Repository"} for ${r||"data access"}`,"Type Definition":(r,u)=>`Type definitions: ${u.slice(0,3).map(S=>S.name).join("")}${u.length>3?"...":""}`,Model:(r,u)=>`Data model: ${u[0]?.name||"Model"}`,"HTTP Route":(r,u)=>{let b=u.filter(S=>S.classification==="Service Boundary");return b.length>0?`API endpoints: ${b.slice(0,3).map(S=>S.name).join("")}`:"API route handler"},"Micro IR (PHP)":(r,u)=>{let b=u.some(D=>D.classification==="Service Boundary"),S=u.find(D=>D.kind==="ClassDeclaration")?.name;return b?"PHP controller with API routes":S?`PHP class: ${S}`:"PHP module"},"Micro IR (Python)":(r,u)=>{let b=u.some(D=>D.classification==="Service Boundary"),S=u.find(D=>D.kind==="ClassDeclaration")?.name;return b?"Python API handler with routes":S?`Python class: ${S}`:"Python module"},"Micro IR (Go/TS) ":(r,u)=>{let b=u.some(D=>D.kind==="TypeDeclaration"),S=u.filter(D=>D.kind==="FunctionDeclaration");return b&&S.length>0?`Go package: types and ${S.length} function(s)`:b?"Go package: type definitions":S.length>0?`Go package: ${S[0].name} and ${S.length} function(s)`:"Go module"},"Micro IR (Rust/TS) ":(r,u)=>{let b=u.find(d=>d.kind==="TraitDeclaration")?.name,S=u.find(d=>d.kind==="StructDeclaration")?.name,D=u.filter(d=>d.kind==="FunctionDeclaration");return b?r.includes("Rust trait")?`Rust module: trait ${b}`:`Rust module: ${b}`:S?`Rust module: struct ${S}`:D.length>0?`Rust module: ${D.length} function(s)`:"Rust module"}}[n];if(T)return T(m,e);if(e.length===0)return s?`Module: ${s}`:"Module with no exports";let o=e.filter(r=>r.kind==="FunctionDeclaration"),p=e.filter(r=>r.kind==="ClassDeclaration"),a=e.filter(r=>r.kind==="TsInterfaceDeclaration"||r.kind==="TsTypeAliasDeclaration"),c=[];if(p.length>0&&c.push(`Class: ${p[0].name}`),o.length>0){let r=o.slice(0,2).map(u=>u.name).join("");c.push(`Functions: ${r}`)}a.length>0&&c.push(`Types: ${a.length}`);let f=c.length>0?c.join(" | "):`Module with ${e.length} export(s)`;return m?`${f} \u2014 ${m}`:f}function Xe(t){let n=new Set;function i(e){if(!(!e||typeof e!="object")){e.typeAnnotation&&I(e.typeAnnotation,n),(e.type==="TsTypeReference"||e.type==="TsTypeAnnotation")&&I(e,n);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 t.forEach(e=>i(e)),Array.from(n)}function I(t,n){if(t){if(t.type==="TsTypeAnnotation"){I(t.typeAnnotation,n);return}t.type==="TsTypeReference"&&(t.typeName?.type==="Identifier"&&n.add(t.typeName.value),t.typeName?.type==="TsQualifiedName"&&Ye(t.typeName,n),t.typeParams&&I(t.typeParams,n)),t.type==="TsArrayType"&&I(t.elementType,n),t.type==="TsUnionType"&&t.types?.forEach(i=>I(i,n)),t.type==="TsIntersectionType"&&t.types?.forEach(i=>I(i,n)),t.type==="TsTupleType"&&t.elemTypes?.forEach(i=>I(i.ty,n)),(t.type==="TsFunctionType"||t.type==="TsConstructorType")&&(t.params?.forEach(i=>I(i.typeAnnotation,n)),t.typeAnnotation&&I(t.typeAnnotation,n)),t.type==="TsTypeParameterDeclaration"&&t.params?.forEach(i=>{i.constraint&&I(i.constraint,n),i.default&&I(i.default,n)}),t.type==="TsTypeParameterInstantiation"&&t.params?.forEach(i=>I(i,n)),t.type==="TsMappedType"&&t.typeAnnotation&&I(t.typeAnnotation,n),t.type==="TsIndexedAccessType"&&(I(t.objectType,n),I(t.indexType,n)),t.type==="TsConditionalType"&&(I(t.checkType,n),I(t.extendsType,n),I(t.trueType,n),I(t.falseType,n)),t.type==="TsTypeLiteral"&&t.members?.forEach(i=>{i.typeAnnotation&&I(i.typeAnnotation,n)})}}function Ye(t,n){t.type==="TsQualifiedName"?(t.left&&Ye(t.left,n),t.right?.value&&n.add(t.right.value)):t.type==="Identifier"&&n.add(t.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(t,n){return{level:t,severity:ht[n]??"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 St=gt(import.meta.url),et=Ie(St);function Dt(){let t=et;for(;t!==Ie(t);){if(xt(tt(t,"package.json")))return t;t=Ie(t)}return bt(et,"..","..")}function nt(...t){return tt(Dt(),...t)}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 n=ie.Parser||ie;await n.init(),this.parser=new n}async getLanguage(n){if(this.languages.has(n))return this.languages.get(n);let i=nt("resources","grammars",`tree-sitter-${this.getLangName(n)}.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(n,e),e}catch(e){return it.error({err:e,ext:n},"Failed to load language grammar"),null}}getLangName(n){switch(n.toLowerCase()){case".php":return"php";case".py":return"python";case".go":return"go";case".rs":return"rust";default:return""}}getQueries(n){switch(n.toLowerCase()){case".php":return`
1
+ import ot from"fs";function je(n){let t=n.split(`
2
+ `),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 Se(n,t){return t.slice(0,n).toString("utf8").length}function qe(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 He(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 Ue(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 Ve(n){if(!n)return"";let i=n.replace(/\/\*\*|\*\/|\*/g,"").trim().split(`
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`
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(t){let n=t.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(n,i){if(n==="import")return"ImportDeclaration";if(i===".php"){if(n==="func")return"FunctionDeclaration";if(n==="class")return"ClassDeclaration";if(n==="interface")return"InterfaceDeclaration";if(n==="trait")return"TraitDeclaration";if(n==="method")return"MethodDeclaration"}if(i===".py"){if(n==="func")return"FunctionDeclaration";if(n==="class")return"ClassDeclaration"}if(i===".go"){if(n==="func")return"FunctionDeclaration";if(n==="type")return"TypeDeclaration"}if(i===".rs"){if(n==="func")return"FunctionDeclaration";if(n==="struct")return"StructDeclaration";if(n==="enum")return"EnumDeclaration";if(n==="trait")return"TraitDeclaration";if(n==="type")return"TypeDeclaration"}return"Unknown"}mapClassification(n){return n==="import"?"Dependency":n==="func"||n==="method"?"Function":n==="class"||n==="interface"||n==="trait"||n==="struct"||n==="enum"||n==="type"?"Class":"Other"}async parse(n,i){await this.ensureInitialized();let e=st.extname(n).toLowerCase(),s=await this.getLanguage(e);if(!s||!this.parser)return[];this.parser.setLanguage(s);let l=this.parser.parse(i),m=i.split(`
28
- `),y=this.getQueries(e);if(!y)return[];let o=new ie.Query(s,y).matches(l.rootNode),p=[];for(let a of o){let c=a.captures.find(u=>u.name==="name")?.node,f=a.captures[0].node,r=a.captures[0].name;if(c){let u=f.startPosition.row+1,b=f.endPosition.row+1,S=m[f.startPosition.row].trim();p.push({name:c.text,kind:this.mapKind(r,e),classification:this.mapClassification(r),signature:S,line:u,endLine:b,doc:"",capabilities:"{}"})}}return p}};var Re=class{parse(n,i=!1){let e=[],s=[],l=n.split(`
29
- `),m="",y="",T=0,o=0,p=-1,a=-1,c=[],f=[],r=!1,u=i?"api":"",b="",S=/^namespace\s+([a-zA-Z0-9_\\]+);/,D=/^(?:abstract\s+)?(?:readonly\s+)?class\s+([a-zA-Z0-9_]+)/,d=/^interface\s+([a-zA-Z0-9_]+)/,w=/^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*\(/,j=/^(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_]+))?;/,P=/^#\[([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*)?['"]([^'"]+)['"]/,ce=/\$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(g){try{let h=JSON.parse(g||"{}");if(h&&typeof h=="object"&&!Array.isArray(h))return h}catch{}return{}}function le(g,h){let _=[],x=g,v=0,k=0;for(;x<l.length;){let F=l[x].trim();_.push(F),v+=(F.match(/\[/g)||[]).length-(F.match(/]/g)||[]).length,k+=(F.match(/\(/g)||[]).length-(F.match(/\)/g)||[]).length;let B=F.includes(h),H=v<=0&&k<=0;if(B&&H)break;x+=1}return{text:_.join(" "),endIndex:x}}function se(g,h){let _=h.replace(/^[^=]+=\s*/,"").replace(/;$/,"").trim();if(g==="casts"){let F={},B=/['"]([^'"]+)['"]\s*=>\s*['"]([^'"]+)['"]/g,H=null;for(;H=B.exec(_);)F[H[1]]=H[2];return F}let x=[],v=/['"]([^'"]+)['"]/g,k=null;for(;k=v.exec(_);)x.push(k[1]);return x}function Ee(g,h){for(let _=h;_>=0;_-=1){let x=g[_]?.trim()||"";if(x)return x}return""}function re(g,h,_,x){if(!m)return;let v=h.split("\\").pop()||h;s.push({type:"eloquent_relation",name:v,direction:"produce",line:_,snippet:x,method:g,url:`${m}->${v}`})}for(let g=0;g<l.length;g++){let h=l[g].trim();if(!h)continue;let _=(h.match(/{/g)||[]).length,x=(h.match(/}/g)||[]).length,v=o;if(o+=_-x,y&&o<=a){let R=e.find(M=>M.name===y&&M.line===T);R&&(R.endLine=g+1),y="",a=-1}if(m&&o<=p){let R=e.find(M=>M.name===m&&(M.kind==="ClassDeclaration"||M.kind==="TraitDeclaration"||M.kind==="InterfaceDeclaration"||M.kind==="EnumDeclaration"));R&&(R.endLine=g+1),m="",p=-1}let k=h.match(W);if(k&&(u=k[1]),h.includes("});")&&(u=""),h.startsWith("/**")){r=!0,f=[];continue}if(r){h.endsWith("*/")?r=!1:f.push(h.replace(/^\*\s?/,""));continue}let F=h.match(P);if(F){c.push(F[1]);continue}let B=h.match(S);if(B){b=B[1]||"",c=[],f=[];continue}let H=h.match(D);if(H){m=H[1],p=o-_;let R={attributes:c};b&&(R.namespace=b),e.push({name:m,kind:"ClassDeclaration",classification:"Class",signature:`class ${m}`,line:g+1,endLine:g+1,doc:f.join(`
30
- `).trim(),capabilities:JSON.stringify(R),members:[]}),c=[],f=[];continue}let X=h.match(d);if(X){let R=X[1];m=R,p=o-_,e.push({name:R,kind:"InterfaceDeclaration",classification:"Interface",signature:`interface ${R}`,line:g+1,endLine:g+1,doc:f.join(`
31
- `).trim(),capabilities:JSON.stringify({attributes:c}),members:[]}),c=[],f=[];continue}let pe=h.match(w);if(pe){let R=pe[1];m=R,p=o-_,e.push({name:R,kind:"TraitDeclaration",classification:"Trait",signature:`trait ${R}`,line:g+1,endLine:g+1,doc:f.join(`
32
- `).trim(),capabilities:JSON.stringify({attributes:c}),members:[]}),c=[],f=[];continue}let ae=h.match(C);if(ae){let R=ae[1],M=ae[2]||null;m=R,p=o-_;let Z={attributes:c,backedType:M};b&&(Z.namespace=b),e.push({name:R,kind:"EnumDeclaration",classification:"Enum",signature:M?`enum ${R}: ${M}`:`enum ${R}`,line:g+1,endLine:g+1,doc:f.join(`
33
- `).trim(),capabilities:JSON.stringify(Z),members:[]}),c=[],f=[];continue}let ue=h.match(N);if(ue){let R=(ue[1]||"").trim(),M=ue[2],Z=!!m,O=/\bprivate\b/.test(R)?"private":/\bprotected\b/.test(R)?"protected":"public",L=/\bstatic\b/.test(R),U=le(g,")"),te=U.text.match(/\)\s*:\s*([?a-zA-Z0-9_\\|]+)/),Se=te?te[1]:null,pt=_>0&&x>=_;y=M,T=g+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=f.join(`
34
- `).trim();if(We){let J=_e.path||"/";e.push({name:J,kind:"HTTP Route",classification:"Service Boundary",signature:`Function: ${M}`,line:g+1,endLine:g+1,doc:ze,capabilities:JSON.stringify({type:"route",handler:m?`${m}@${M}`:M,..._e})}),s.push({type:"api_route",name:J,direction:"consume",line:g+1,snippet:h})}let Ze={name:M,kind:Z?"MethodDeclaration":"FunctionDeclaration",classification:Z?"Method":"Function",signature:`${Z?m+":: ":""}${M}`,line:g+1,endLine:g+1,doc:ze,capabilities:JSON.stringify(Z?{attributes:c,visibility:O,static:L,returnType:Se}:{attributes:c,returnType:Se})};e.push(Ze);let ke=Z?h.match(ce):null;if(ke&&re(ke[1],ke[2],g+1,h),Z&&M==="__construct"){let J=null;for(;J=ge.exec(U.text);){let Be=J[1],Oe=!!J[2],Ae=J[4]?`${J[3]?"?":""}${J[4]}`:null,je=J[5],ut=`${Be} ${Oe?"readonly ":""}${Ae?`${Ae} `:""}$${je}`.trim();e.push({name:je,kind:"PropertyDeclaration",classification:"Property",signature:ut,line:g+1,endLine:g+1,doc:"",capabilities:JSON.stringify({visibility:Be,static:!1,readonly:Oe,type:Ae}),members:[]})}ge.lastIndex=0}pt&&(Ze.endLine=g+1,y="",a=-1),c=[],f=[];continue}let me=!1,Q=!1,A=g,$=m&&!y?h.match(j):null;if($){me=!0;let R=$[1],M=!!$[2],Z=!!$[3],O=$[5]?`${$[4]?"?":""}${$[5]}`:null,L=$[6],U=`${R} ${M?"static ":""}${Z?"readonly ":""}${O?`${O} `:""}$${L}`.trim();e.push({name:L,kind:"PropertyDeclaration",classification:"Property",signature:U,line:g+1,endLine:g+1,doc:f.join(`
35
- `).trim(),capabilities:JSON.stringify({visibility:R,static:M,readonly:Z,type:O}),members:[]})}let Y=m&&!y?h.match(be):null;if(Y){Q=!0;let R=Y[1],M=le(g,";");A=M.endIndex;let Z=se(R,M.text),O=[...e].reverse().find(L=>L.name===m&&L.kind==="ClassDeclaration");if(O){let L=xe(O.capabilities);(!L.modelConfig||typeof L.modelConfig!="object"||Array.isArray(L.modelConfig))&&(L.modelConfig={}),L.modelConfig[R]=Z,O.capabilities=JSON.stringify(L)}}if(me||Q){Q&&A>g&&(g=A),c=[],f=[];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:g+1,endLine:g+1,doc:"",capabilities:JSON.stringify({type:"use",namespace:R})}),c=[],f=[];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(u){let te=u.startsWith("/")?u:`/${u}`,Se=M.startsWith("/")?M:`/${M}`;M=(te+Se).replace(/\/+/g,"/")}let O=null,L=h.match(/\[\s*([a-zA-Z0-9_]+)::class\s*,\s*['"]([^'"]+)['"]\s*\]/);if(L)O=`${L[1]}@${L[2]}`;else if(h.includes("::class")){let te=h.match(/([a-zA-Z0-9_]+)::class/);te&&(O=te[1])}let U=h;!h.endsWith(");")&&g+1<l.length&&(U+=" "+l[g+1].trim(),!U.endsWith(");")&&g+2<l.length&&(U+=" "+l[g+2].trim())),e.push({name:M,kind:"HTTP Route",classification:"Service Boundary",signature:U,line:g+1,endLine:g+1,doc:"",capabilities:JSON.stringify({type:"route",method:R,path:M,handler:O})}),s.push({type:"api_route",name:M,direction:"consume",line:g+1,snippet:U,method:R,url:M}),f=[];continue}}let ee=m&&y?h.match(ce):null,fe=m&&y?h.match(Fe):null;if(ee)re(ee[1],ee[2],g+1,h);else if(fe){let R=Ee(l,g-1);/\$this\b/.test(R)&&re(fe[1],fe[2],g+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*([^,)]+)/,de=h.match(lt);if(de){let R=(de[1]||de[3]).toUpperCase(),M=(de[2]||de[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:g+1,snippet:h,method:R,url:M})}!h.startsWith("#[")&&!h.startsWith("//")&&!h.startsWith("*")&&!r&&(c=[],f=[])}return{nodes:e,events:s}}};var Ce=class{currentRoutePrefix="";parse(n){this.currentRoutePrefix="";let i=[],e=[],s=n.split(`
36
- `),l=[{indent:-1,name:"root",type:"root"}],m=[],y=/^class\s+([a-zA-Z0-9_]+)/,T=/^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_\.]+))/,p=/^@(.*)/;function a(d){return d.trim().split(/[.(]/)[0]?.trim()||d}function c(d){let w=d.decorators.map(N=>a(N.raw)),C={decorators:d.decorators,decoratorNames:w};return d.async===!0&&(C.async=!0),d.accessor&&(C.accessor=d.accessor),d.contextmanager===!0&&(C.contextmanager=!0),JSON.stringify(C)}function f(d,w){return(d.match(new RegExp(`\\${w}`,"g"))||[]).length}function r(d){let w=[],C=d,N=0,j=0,q=0,P=!1;do{let z=s[C].trim();if(w.push(z),N+=f(z,"(")-f(z,")"),j+=f(z,"[")-f(z,"]"),q+=f(z,"{")-f(z,"}"),P=z.endsWith("\\"),C+1>=s.length||N<=0&&j<=0&&q<=0&&!P)break;C+=1}while(!0);return{text:w.join(" "),endIndex:C}}let u=!1,b="",S=[],D=[];for(let d=0;d<s.length;d++){let w=s[d],C=w.trim();if(!C||C.startsWith("#"))continue;let N=/^([a-zA-Z0-9_]+)\s*=\s*(?:APIRouter|Blueprint)\s*\(\s*(?:prefix\s*=\s*)?['"]([^'"]+)['"]/,j=C.match(N);if(j&&(this.currentRoutePrefix=j[2]),u){if(C.endsWith(b)||C.includes(b)){u=!1;let x=C.replace(b,"").trim();x&&S.push(x);let v=l[l.length-1];v.node&&(v.node.doc=S.join(`
37
- `).trim()),S=[]}else S.push(C);continue}let q=w.search(/\S/),P=w.trim(),z=P.match(/^(['"]{3})/);if(z){let x=z[1],v=l[l.length-1];if(v.node&&!v.node.doc){if(P.substring(3).includes(x)){let k=P.replace(new RegExp(x,"g"),"").trim();v.node.doc=k}else{u=!0,b=x;let k=P.substring(3).trim();k&&S.push(k)}continue}}for(;l.length>1&&l[l.length-1].indent>=q;)l.pop();let W=l[l.length-1],ce=W.type==="root"&&q===0;if(ce&&/^__all__\s*=/.test(P)){let x=r(d),v=[],k=/['"]([^'"]+)['"]/g,F=null;for(;F=k.exec(x.text);)v.push(F[1]);let B={name:"__all__",kind:"ModuleExports",classification:"ExportList",signature:"__all__ = [...]",line:d+1,endLine:x.endIndex+1,doc:"",capabilities:JSON.stringify({exports:v}),members:[]};D.push(B),i.push(B),d=x.endIndex,m=[];continue}let ge=/^([A-Z][A-Z0-9_]*)(?:\s*:\s*[^=]+)?\s*=/,be=ce?P.match(ge):null;if(be){let x=r(d),v=x.text.length>120?`${x.text.slice(0,117)}...`:x.text,k={name:be[1],kind:"VariableDeclaration",classification:"Constant",signature:v,line:d+1,endLine:x.endIndex+1,doc:"",capabilities:"{}",members:[]};D.push(k),i.push(k),d=x.endIndex,m=[];continue}let xe=P.match(p);if(xe){m.push({raw:xe[1].trim(),line:d+1});continue}let le=P.match(y);if(le){let x=le[1],v={name:x,kind:"ClassDeclaration",classification:"Class",signature:`class ${x}`,line:d+1,endLine:d+1,doc:"",capabilities:c({decorators:m}),members:[]};D.push(v),W.node?(W.node.members||(W.node.members=[]),W.node.members.push(v)):i.push(v),l.push({indent:q,name:x,type:"class",node:v}),m=[];continue}let se=P.match(T);if(se){let x=!!se[1],v=se[1]||se[2],k=W.type==="class",F=m.some(A=>/(?:^|\.)contextmanager$/.test(A.raw.trim())),B;m.some(A=>A.raw.trim()==="property")&&(B="getter");for(let A of m){let $=A.raw.trim().match(/^[a-zA-Z_][a-zA-Z0-9_]*\.(setter|deleter)$/);if($){B=$[1];break}}let H=!1,X={};for(let A of m)if(A.raw.match(/(?:app|router)\.(get|post|put|delete|patch|websocket)/)){H=!0;let Y=["get","post","put","delete","patch","websocket"].find(ee=>A.raw.toLowerCase().includes(`.${ee}`))?.toUpperCase()||"GET",oe=A.raw.match(/['"]([^'"]+)['"]/),K=oe?oe[1]:"/";if(this.currentRoutePrefix){let ee=this.currentRoutePrefix.endsWith("/")?this.currentRoutePrefix.slice(0,-1):this.currentRoutePrefix,fe=K.startsWith("/")?K:`/${K}`;K=ee+fe}X={type:"route",method:Y,path:K}}if(H){let A=X.path||"",$=X.method==="WEBSOCKET",Y={name:A||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:x,...X})};D.push(Y),i.push(Y),e.push({type:$?"websocket_route":"api_route",name:A,direction:"consume",line:d+1,snippet:P})}for(let A of m){let $=A.raw.match(/(?:^|\.)receiver\s*\(\s*([a-zA-Z0-9_\.]+)/);$&&e.push({type:"signal",name:$[1].split(".").pop()||$[1],direction:"consume",line:A.line,snippet:`@${A.raw}`})}let pe=m.some(A=>A.raw==="staticmethod"),ae=m.some(A=>A.raw==="classmethod"),ue=`${x?"async ":""}${k?(pe?"@staticmethod ":ae?"@classmethod ":"")+W.name+".":""}${v}`,me=!!B,Q={name:v,kind:me?"PropertyDeclaration":x&&k?"AsyncMethodDeclaration":x?"AsyncFunctionDeclaration":k?"MethodDeclaration":"FunctionDeclaration",classification:me?"Property":k?pe||ae?"Static Method":"Method":"Function",signature:ue,line:d+1,endLine:d+1,doc:"",capabilities:c({decorators:m,async:x,accessor:B,contextmanager:F}),members:[]};D.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}),m=[];continue}let Ee=/^(?:path|re_path|url)\s*\(\s*['"]([^'"]+)['"]/,re=P.match(Ee);if(re){let x=re[1].replace(/^\^/,""),v={name:x,kind:"HTTP Route",classification:"Service Boundary",signature:P.trim(),line:d+1,endLine:d+1,doc:"",capabilities:JSON.stringify({type:"route",method:"GET",path:x})};D.push(v),i.push(v),e.push({type:"api_route",name:x,direction:"consume",line:d+1,snippet:P});continue}let g=/(?:requests|httpx|client|http)\.(get|post|put|delete|patch|request)\s*\(\s*(?:url\s*:\s*)?([^,)]+)/,h=P.match(g);if(h){let x=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:P,method:x,url:v})}let _=P.match(o);if(_){let x=_[1]||_[2],v={name:x,kind:"ImportSpecifier",classification:"Dependency",signature:`import ${x}`,line:d+1,endLine:d+1,doc:"",capabilities:JSON.stringify({type:"import",module:x})};D.push(v),i.push(v),m=[];continue}m=[],W.node&&(W.node.endLine=d+1)}return{nodes:D,events:e}}};function Rt(t,n){let i=0,e=!1;for(let s=n;s<t.length;s++){let l=t[s];for(let m of l)if(m==="{")i++,e=!0;else if(m==="}"&&(i--,e&&i<=0))return s+1;if(!e&&s>n&&/[;}]$/.test(l.trim()))return s+1}return Math.min(t.length,n+41)}var rt=[{extension:[".php"],rules:[]},{extension:[".py"],rules:[]},{extension:[".go"],rules:[{regex:/func\s+([a-zA-Z0-9_]+)\(/g,onMatch:t=>({name:t[1],kind:"FunctionDeclaration",classification:"Function",signature:t[0]})},{regex:/func\s+\([^\)]+\)\s+([a-zA-Z0-9_]+)\(/g,onMatch:t=>({name:t[1],kind:"MethodDeclaration",classification:"Method",signature:t[0]})},{regex:/import\s+['"]([^'"]+)['"]/g,onMatch:t=>({name:t[1],kind:"ImportSpecifier",classification:"Dependency",signature:t[0],meta:{type:"import",path:t[1]}})}]},{extension:[".rs"],rules:[{regex:/fn\s+([a-zA-Z0-9_]+)\s*\(/g,onMatch:t=>({name:t[1],kind:"FunctionDeclaration",classification:"Function",signature:t[0]})},{regex:/struct\s+([a-zA-Z0-9_]+)/g,onMatch:t=>({name:t[1],kind:"StructDeclaration",classification:"Class",signature:t[0]})},{regex:/enum\s+([a-zA-Z0-9_]+)/g,onMatch:t=>({name:t[1],kind:"EnumDeclaration",classification:"Class",signature:t[0]})},{regex:/trait\s+([a-zA-Z0-9_]+)/g,onMatch:t=>({name:t[1],kind:"TraitDeclaration",classification:"Class",signature:t[0]})},{regex:/use\s+([a-zA-Z0-9_:]+(?:\s+as\s+[a-zA-Z0-9_]+)?);/g,onMatch:t=>({name:t[1].trim(),kind:"ImportDeclaration",classification:"Dependency",signature:t[0],meta:{type:"import",path:t[1].trim()}})}]},{extension:[".ts",".tsx",".js",".jsx",".mjs",".cjs"],rules:[{regex:/(?:export\s+)?(?:async\s+)?function\s+([a-zA-Z0-9_]+)\s*\(/g,onMatch:t=>({name:t[1],kind:"FunctionDeclaration",classification:"Function"})},{regex:/(?:export\s+)?class\s+([a-zA-Z0-9_]+)/g,onMatch:t=>({name:t[1],kind:"ClassDeclaration",classification:"Class"})},{regex:/(?:export\s+)?interface\s+([a-zA-Z0-9_]+)/g,onMatch:t=>({name:t[1],kind:"InterfaceDeclaration",classification:"Interface"})},{regex:/(?:export\s+)?const\s+([a-zA-Z0-9_]+)\s*=/g,onMatch:t=>({name:t[1],kind:"VariableDeclaration",classification:"Constant"})},{regex:/import\s+.*\s+from\s+['"]([^'"]+)['"]/g,onMatch:t=>({name:t[1],kind:"ImportDeclaration",classification:"Dependency",meta:{path:t[1]}})}]}];function Ct(t,n){let i=[];if(t===".go"&&n.some(e=>e.kind==="TypeDeclaration")&&i.push("Go type"),t===".rs"&&(n.some(e=>e.kind==="TraitDeclaration")&&i.push("Rust trait"),n.some(e=>e.kind==="StructDeclaration")&&i.push("Rust struct"),n.some(e=>e.kind==="EnumDeclaration")&&i.push("Rust enum")),t===".py"){for(let e of n)if(e.capabilities)try{if(JSON.parse(e.capabilities).decoratorNames?.length){i.push("Python decorators");break}}catch{}n.some(e=>e.kind==="AsyncFunctionDeclaration"||e.kind==="AsyncMethodDeclaration")&&i.push("Async")}return i}var Te=class{phpParser=new Re;pythonParser=new Ce;treeSitterParser=new Me;supports(n){return rt.some(i=>i.extension.includes(n.toLowerCase()))}async parse(n,i){let e=$e.extname(n).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=n.toLowerCase().endsWith("api.php"),p=this.phpParser.parse(i,o);s=p.nodes,l=p.events}else try{s=await this.treeSitterParser.parse(n,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) ",p=s.filter(r=>r.classification!=="Dependency"),a=s.filter(r=>r.classification==="Dependency"),c=Ct(e,s),f=ye({classification:o,capabilities:c,exports:p.map(r=>({name:r.name,kind:r.kind,classification:r.classification})),fileName:$e.basename(n)});return{exports:p,imports:a.map(r=>({module:r.name,name:r.name,kind:r.kind,classification:r.classification})),events:l,classification:o,summary:f||`${e.substring(1).toUpperCase()} module`,parseStatus:"success"}}}let m=rt.find(o=>o.extension.includes(e));if(!m)return{exports:[],imports:[],classification:"Unknown",summary:"",parseStatus:"failed",parseError:`Unsupported file extension: ${e}`};let y=i.split(`
38
- `);for(let o of m.rules){o.regex.lastIndex=0;let p;for(;(p=o.regex.exec(i))!==null;){let a=o.onMatch(p),c=i.substring(0,p.index).split(`
39
- `).length,f=Rt(y,c-1);s.push({name:a.name||"anonymous",kind:a.kind||"Unknown",classification:a.classification||"Other",signature:a.signature||p[0],line:c,endLine:f,doc:"",capabilities:JSON.stringify(a.meta||{})})}}let T=ye({classification:`Micro IR (${e.substring(1).toUpperCase()})`,capabilities:[],exports:s.map(o=>({name:o.name,kind:o.kind,classification:o.classification})),fileName:$e.basename(n)});return{exports:s,imports:[],classification:`Micro IR (${e.substring(1).toUpperCase()})`,summary:T||"Module",parseStatus:s.length>0?"success":"partial"}}};import*as Le from"@swc/core";function at(t){if(!t||typeof t!="object")return!1;let n=t;return typeof n.parse=="function"&&typeof n.parseSync=="function"}function Tt(){if(at(Le))return Le;let t=Le;if(at(t.default))return t.default;throw new Error("SWC runtime unavailable: couldn't resolve parse/parseSync from @swc/core exports")}var wt=Tt();function we(t,n,i){return wt.parseSync(t,n,i)}var Ne=new Te;async function vn(t){let n=ct.extname(t);if(Ne.supports(n)&&n!==".ts"&&n!==".tsx")try{let l=await ot.promises.readFile(t,"utf-8");return{...await Ne.parse(t,l),content:l}}catch(l){return ne.error({filePath:t,error:l.message},"HeuristicParser failed"),{exports:[],imports:[],classification:"Unknown",summary:"",content:"",parseStatus:"failed",parseError:l.message}}let i;try{i=await ot.promises.readFile(t)}catch(l){return{exports:[],imports:[],classification:"Error",summary:"",content:"",parseStatus:"failed",parseError:`File read error: ${l.message}`}}let e=i.toString("utf8"),s=Je(e);try{let l=t.endsWith(".tsx"),m=t.endsWith(".d.ts")||t.endsWith(".d.tsx"),y,T={syntax:"typescript",tsx:l,decorators:!0,comments:!0};if(m)try{y=we(e,T)}catch{y=we(e,{...T,isModule:!1})}else y=we(e,T);let o=y.span.start,p=qe(i),a=Ue(e),c=C=>He(C,o,i),f=Ge(y.body),r=Xe(y.body);r.length>0&&ne.debug({filePath:t,count:r.length},"Extracted type references"),r.forEach(C=>{f.push({module:"__type_reference__",name:C})});let u=Ke(y.body,o,i,e,s,a,t,c,p),b=Qe(y.body,o,i,s,c,p),S=ve(t,"","Module"),d=a.length>0&&e.slice(0,a[0].start).trim().length===0?a[0].text:u.find(C=>C.doc)?.doc||"",w=Ve(d);if(!w&&u.length>0){let C=he(e);w=ye({classification:S,capabilities:C,exports:u.map(N=>({name:N.name,kind:N.kind,classification:N.classification})),fileName:ct.basename(t)})}return{exports:u,imports:f,events:b,classification:S,summary:w,content:e,parseStatus:"success"}}catch(l){ne.warn({filePath:t,error:l.message},"SWC parsing failed, using heuristic fallback");try{let m=await Ne.parse(t,e);return{...m,content:e,classification:m.classification+" (Degraded)",parseStatus:"partial",parseError:`SWC failed, used heuristic fallback: ${l.message}`}}catch(m){return ne.error({filePath:t,error:m.message},"All parsing strategies failed"),{exports:[],imports:[],classification:"Error",summary:"",content:e,parseStatus:"failed",parseError:`All parsing strategies failed: ${m.message}`}}}}export{vn as parseFile};
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=st.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}};var Re=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*\(/,J=/^(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 B=F.includes(h),H=v<=0&&k<=0;if(B&&H)break;D+=1}return{text:_.join(" "),endIndex:D}}function se(b,h){let _=h.replace(/^[^=]+=\s*/,"").replace(/;$/,"").trim();if(b==="casts"){let F={},B=/['"]([^'"]+)['"]\s*=>\s*['"]([^'"]+)['"]/g,H=null;for(;H=B.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 B=h.match(x);if(B){g=B[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
+ `).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
+ `).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
+ `).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,O=/\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:O,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 Be=j[1],Oe=!!j[2],Pe=j[4]?`${j[3]?"?":""}${j[4]}`:null,Je=j[5],ut=`${Be} ${Oe?"readonly ":""}${Pe?`${Pe} `:""}$${Je}`.trim();e.push({name:Je,kind:"PropertyDeclaration",classification:"Property",signature:ut,line:b+1,endLine:b+1,doc:"",capabilities:JSON.stringify({visibility:Be,static:!1,readonly:Oe,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(J):null;if($){fe=!0;let R=$[1],M=!!$[2],Z=!!$[3],O=$[5]?`${$[4]?"?":""}${$[5]}`:null,L=$[6],G=`${R} ${M?"static ":""}${Z?"readonly ":""}${O?`${O} `:""}$${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:O}),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),O=[...e].reverse().find(L=>L.name===f&&L.kind==="ClassDeclaration");if(O){let L=xe(O.capabilities);(!L.modelConfig||typeof L.modelConfig!="object"||Array.isArray(L.modelConfig))&&(L.modelConfig={}),L.modelConfig[R]=Z,O.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 O=null,L=h.match(/\[\s*([a-zA-Z0-9_]+)::class\s*,\s*['"]([^'"]+)['"]\s*\]/);if(L)O=`${L[1]}@${L[2]}`;else if(h.includes("::class")){let te=h.match(/([a-zA-Z0-9_]+)::class/);te&&(O=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:O})}),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 Ce=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,J=0,q=0,A=!1;do{let z=s[C].trim();if(T.push(z),N+=m(z,"(")-m(z,")"),J+=m(z,"[")-m(z,"]"),q+=m(z,"{")-m(z,"}"),A=z.endsWith("\\"),C+1>=s.length||N<=0&&J<=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*)?['"]([^'"]+)['"]/,J=C.match(N);if(J&&(this.currentRoutePrefix=J[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 B={name:"__all__",kind:"ModuleExports",classification:"ExportList",signature:"__all__ = [...]",line:d+1,endLine:D.endIndex+1,doc:"",capabilities:JSON.stringify({exports:v}),members:[]};S.push(B),i.push(B),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())),B;f.some(P=>P.raw.trim()==="property")&&(B="getter");for(let P of f){let $=P.raw.trim().match(/^[a-zA-Z_][a-zA-Z0-9_]*\.(setter|deleter)$/);if($){B=$[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=!!B,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:B,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 Rt(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 rt=[{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 Ct(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 Ee=class{phpParser=new Re;pythonParser=new Ce;treeSitterParser=new Me;supports(t){return rt.some(i=>i.extension.includes(t.toLowerCase()))}async parse(t,i){let e=$e.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=Ct(e,s),m=ye({classification:o,capabilities:c,exports:u.map(r=>({name:r.name,kind:r.kind,classification:r.classification})),fileName:$e.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=rt.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
+ `);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=Rt(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:$e.basename(t)});return{exports:s,imports:[],classification:`Micro IR (${e.substring(1).toUpperCase()})`,summary:E||"Module",parseStatus:s.length>0?"success":"partial"}}};import*as Le from"@swc/core";function at(n){if(!n||typeof n!="object")return!1;let t=n;return typeof t.parse=="function"&&typeof t.parseSync=="function"}function Et(){if(at(Le))return Le;let n=Le;if(at(n.default))return n.default;throw new Error("SWC runtime unavailable: couldn't resolve parse/parseSync from @swc/core exports")}var Tt=Et();function Te(n,t,i){return Tt.parseSync(n,t,i)}var Ne=new Ee;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=je(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=Te(e,E)}catch{y=Te(e,{...E,isModule:!1})}else y=Te(e,E);let o=y.span.start,u=qe(i),a=Ue(e),c=C=>He(C,o,i),m=Ge(y.body),r=Xe(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=Ke(y.body,o,i,e,s,a,n,c,u),g=Qe(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=Ve(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,43 +1,35 @@
1
1
  ---
2
2
  name: audit
3
- description: Perform codebase health audits to identify dead code, circular dependencies, and technical debt. Use when auditing code quality, finding unused code, detecting circular dependencies, or when the user asks about codebase health, technical debt, or code cleanup.
3
+ description: Audit repository health with Shadow tools. Use when hunting dead code, import cycles, layer drift, orphaned config, structural risks, or when turning audit findings into cleanup work.
4
4
  ---
5
5
 
6
- # Codebase Audit
6
+ # Audit
7
7
 
8
- Comprehensive health audit using Shadow analyze toolkit.
8
+ Use this skill when the goal is repository health, not feature delivery.
9
9
 
10
- ## 🚀 Workflow
10
+ ## Start
11
11
 
12
- 1. **Session Context**: `shadow_ops_context` (repoPath) **ONE CALL** for hologram + chronicle + briefing. Get architecture baseline.
13
- 2. **Dead Code Detection**: `shadow_analyze_debt` (mode: "dead-code", limit: 100, includeTests: false, repoPath) — Unused exports.
14
- 3. **Circular Dependencies**: `shadow_analyze_debt` (mode: "circular-deps", limit: 20, repoPath) — Import cycles.
15
- 4. **Layer Integrity** (optional): `shadow_recon_topography` (repoPath) — Detailed layer analysis if hologram summary isn't enough.
16
- 5. **Log Findings**: `shadow_ops_log` (missionId, type: "discovery", content, repoPath).
17
- 6. **Create Cleanup Mission** (optional): `shadow_ops_plan` (name: "Codebase Cleanup", templateId: "refactoring", templateVars, repoPath).
12
+ 1. `shadow_ops_context({ repoPath, compact: true })`
13
+ 2. `shadow_analyze_debt({ repoPath, mode: "dead-code", confidenceThreshold: "high" })`
14
+ 3. `shadow_analyze_debt({ repoPath, mode: "circular-deps" })`
18
15
 
19
- ## 🛠 Precise Tooling
16
+ ## Add depth only when needed
20
17
 
21
- | Audit Target | Atomic Tool |
22
- | :------------------- | :------------------------------------------------------------------------------------- |
23
- | **Session Start** 🚀 | `shadow_ops_context` (repoPath) **START HERE** for baseline |
24
- | **Architecture** | `shadow_recon_hologram` (repoPath) if you need standalone |
25
- | **Dead Code** | `shadow_analyze_debt` (mode: "dead-code", limit: 100, **confidenceThreshold: "high"**) |
26
- | **Circular Deps** | `shadow_analyze_debt` (mode: "circular-deps") |
27
- | **Layers** | `shadow_recon_topography` — detailed breakdown if needed |
28
- | **Config Audit** | `shadow_search_config` (kind: "Env", **showUsage: true**) — find orphaned env vars |
29
- | **Event Mesh** | `shadow_analyze_mesh` (repoPath) — audit all HTTP routes, socket events, pubsub topics |
30
- | **Type Integrity** | `shadow_analyze_type_graph` (filePath, repoPath) — interface/type inheritance chains |
31
- | **Theme Patterns** | `shadow_ops_crystallize_theme` (query, repoPath) — recurring issues across missions |
18
+ - `shadow_recon_topography({ repoPath })` for layer drift and boundary violations.
19
+ - `shadow_recon_scout({ repoPath })` for architectural drift and anomalies.
20
+ - `shadow_search_config({ repoPath, kind: "Env", showUsage: true })` for orphaned config and env keys.
21
+ - `shadow_analyze_impact({ repoPath, symbolName, filePath? })` for risky hubs.
22
+ - `shadow_analyze_type_graph({ repoPath, symbolName, filePath? })` when a central interface or base class is involved.
23
+ - `shadow_analyze_mesh({ repoPath, topic, type? })` only when you already have a concrete route or event fragment such as `"/api/"` or `"order."`.
32
24
 
33
- ## 💡 Intelligence Options
25
+ ## Close the loop
34
26
 
35
- - **`shadow_analyze_debt` confidence levels**: Use `confidenceThreshold: "high"` for likely dead code, `"medium"` for possibly intentional (test fixtures, etc.), `"all"` for everything.
36
- - **`shadow_analyze_debt` exclusion filters**: Use `excludePatterns`, `includeMigrations: false`, `includeFixtures: false` to reduce noise.
37
- - **`shadow_search_config` with `showUsage: true`**: Cross-references config vars with code to show usage counts and identify orphaned vars (defined but never used).
27
+ - `shadow_ops_log({ repoPath, missionId?, type: "discovery", content, filePath?, symbolName? })`
28
+ - `shadow_ops_handoff({ repoPath, missionId?, kind: "debt_scan", findings, risks?, gaps? })`
29
+ - `shadow_ops_plan({ repoPath, name, goal, templateId: "refactoring", workingSet? })`
38
30
 
39
- ## 🔍 Health Criteria
31
+ ## Rules
40
32
 
41
- - **Critical Issues**: Circular deps in core logic, >50 dead exports, orphaned env vars with secrets
42
- - **Warning Signs**: Layer violations (Test → Logic), >20 dead exports, >10 orphaned configs
43
- - **Good Health**: Clean layers, <10 dead exports, no circular deps, all configs in use
33
+ - Start with `confidenceThreshold: "high"` and widen only if the user wants a broader sweep.
34
+ - `shadow_ops_crystallize_theme` takes `theme`, not `query`.
35
+ - `shadow_analyze_type_graph` requires `symbolName`.
@@ -1,40 +1,27 @@
1
1
  ---
2
2
  name: chronicle
3
- description: Retrieve and analyze the repository's narrative archive as recorded in Git-native memory. Use when you need to understand historical decisions, catch up on repository progress, review recently completed missions, or when the user asks for a project history, changelog, or chronological overview of architectural changes.
3
+ description: Read the repository narrative archive. Use when you need project history, ADR context, recent completed work, release-note material, or a chronological view of architectural changes.
4
4
  ---
5
5
 
6
- # Repository Chronicle
6
+ # Chronicle
7
7
 
8
- Retrieve narrative archive from Git-native memory.
8
+ Use this skill when the answer lives in mission history rather than the current code graph.
9
9
 
10
- ## 🚀 Workflow
10
+ ## Core calls
11
11
 
12
- 1. **Recent History**: `shadow_ops_chronicle` (limit: 10, format: "markdown", repoPath) — Last 10 entries.
13
- 2. **Time-Filtered**:
14
- - `shadow_ops_chronicle` (since: &lt;unix&gt;, limit: 20, repoPath)
15
- - `shadow_ops_chronicle` (until: &lt;unix&gt;, limit: 20, repoPath)
16
- 3. **Structured Data**: `shadow_ops_chronicle` (format: "json", limit: 50, repoPath) — For processing.
17
- 4. **Paginated**: `shadow_ops_chronicle` (limit: 10, offset: 10, repoPath) — Second page.
12
+ - Recent narrative: `shadow_ops_chronicle({ repoPath, limit: 10, format: "markdown" })`
13
+ - Structured output: `shadow_ops_chronicle({ repoPath, format: "json", limit: 50 })`
14
+ - Time window: `shadow_ops_chronicle({ repoPath, since, until })`
15
+ - Branch-scoped history: `shadow_ops_chronicle({ repoPath, branch, limit })`
16
+ - Pagination: `shadow_ops_chronicle({ repoPath, limit, offset })`
18
17
 
19
- ## 🛠 Precise Tooling
18
+ ## Good pairings
20
19
 
21
- | Chronicle Query | Atomic Tool |
22
- | :-------------------- | :---------------------------------------------------------------- |
23
- | **Recent (Markdown)** | `shadow_ops_chronicle` (limit: 10, format: "markdown") |
24
- | **Time Range** | `shadow_ops_chronicle` (since: &lt;unix&gt;, until: &lt;unix&gt;) |
25
- | **JSON Data** | `shadow_ops_chronicle` (format: "json", limit: 50) |
26
- | **Pagination** | `shadow_ops_chronicle` (limit: 10, offset: 10) |
20
+ - `shadow_ops_context({ repoPath, compact: true })` if you also need the current mission landscape.
21
+ - `shadow_ops_graph({ repoPath, missionId, format: "mermaid" })` when a historical mission hierarchy matters.
27
22
 
28
- ## Output Formats
23
+ ## Notes
29
24
 
30
- - **`format: "markdown"`** (default): Human-readable narrative feed with missions grouped as Strategic Initiatives and Standalone Episodes
31
- - **`format: "json"`**: Structured data for programmatic analysis (includes missionId, steps, timestamps, ADRs)
32
-
33
- ## Use Cases
34
-
35
- - **Onboarding**: Read last 10 entries to catch up
36
- - **Release Notes**: Get completed missions since last release
37
- - **ADR Review**: Extract all architectural decisions
38
- - **Progress Reports**: Show what's been done this week
39
-
40
- **Note:** Chronicle reads from Git Notes, so it's persistent across branches and clones.
25
+ - `format: "markdown"` is best for humans.
26
+ - `format: "json"` is best when another tool or agent will process the result.
27
+ - Chronicle is backed by Git Notes, so it survives across branches and clones.
@@ -3,61 +3,45 @@ name: continue
3
3
  description: Get briefing, pick one mission from next_work_candidates, then work that mission to completion with all remaining steps in one run. Use when continuing work on missions, executing mission steps, or when the user asks to continue work, finish a mission, or proceed with development tasks.
4
4
  ---
5
5
 
6
- **In one sentence:** Get briefing (+ optional trace), pick **one mission** from **next_work_candidates** (ranked by relevance), then work that mission to completion — all remaining steps in one run. Update and log as you go. No status reports; when you're done with that mission, it's done.
6
+ # Continue
7
7
 
8
- ---
8
+ Pick one mission from `next_work_candidates` and finish it end to end.
9
9
 
10
- ## 1. Context
11
-
12
- - **Option A (one shot):** `shadow_ops_context` (repoPath) → returns hologram + chronicle(5) + **briefing** (counts, **next_work_candidates** ranked by relevance). Use when you want architecture + history + backlog in one call at the start of /continue.
13
- - **Option B:** `shadow_ops_briefing` (scope: "project", repoPath) → **next_work_candidates** (relevance-ranked), hierarchy, analytics.
14
- - Use **altitude** to control output density: `orbit` (~200 tokens, counts + candidates only), `atmosphere` (default, strategy + crystals), `ground` (raw logs + working set + collisions).
15
- - `shadow_sync_trace` (repoPath) only if you care about external changes. Otherwise skip.
16
-
17
- ## 2. Pick one mission
18
-
19
- - **`next_work_candidates`** are ranked by the MissionRelevanceScorer (recency × 0.4 + activity × 0.3 + status × 0.2 + blockers × 0.1). Higher score = more relevant.
20
- - Choose the top-ranked candidate. Prefer in-progress over planned. Parent-only missions (umbrellas) are already filtered out.
21
-
22
- ## 3. Work the whole mission
23
-
24
- - For that mission, run through **all remaining steps** (not just one):
25
- - **Surgical Discovery:** `shadow_analyze_flow` (symbolName, filePath, repoPath).
26
- - **Execute Step**: Set in-progress → implement → `shadow_ops_track` (missionId, stepId, status: "completed", contextPivot, repoPath).
27
- - **Atomic Logging:** At least once per step. `shadow_ops_log` (missionId, type: "decision", content, symbolName, repoPath).
28
- - **Inter-agent handoff** (multi-agent pipelines only): When handing off findings to another agent, call `shadow_ops_handoff` (missionId, role, summary, findings, repoPath) to persist a typed artifact with embedding. The receiving agent calls `shadow_ops_handoff_read` (missionId, query, repoPath) to semantically retrieve relevant prior handoffs.
29
- - **Seal the mission**: `shadow_ops_track` (missionId, status: "completed", repoPath).
30
- - This **auto-triggers**: ADR synthesis, Git Notes persistence, and cascade parent completion (if all sibling missions are also done, the parent auto-completes too).
31
- - No need to call `shadow_ops_synthesize` separately — it's automatic on completion.
32
- - **Optional — Crystallize** (for long-running missions with many logs): `shadow_ops_crystallize` (missionId, repoPath) compresses raw intent logs into a single crystal summary. Useful mid-mission to keep briefings lean.
33
- - **Optional — Theme Crystallize** (cross-mission patterns): `shadow_ops_crystallize_theme` (query, repoPath) clusters semantically related intent logs across ALL missions to surface recurring architectural themes. Use when you sense a pattern repeating across missions.
34
-
35
- ## 🛠 Precise Tooling
36
-
37
- | Action | Atomic Tool | Example |
38
- | :--------------------- | :----------------------------- | :--------------------------------------------------------------- |
39
- | **Context (one shot)** | `shadow_ops_context` | repoPath — hologram + chronicle + briefing |
40
- | **Briefing** | `shadow_ops_briefing` | scope: "project", altitude: "orbit", repoPath |
41
- | **Flow Trace** | `shadow_analyze_flow` | symbolName: "handleRequest", filePath, repoPath |
42
- | **Step Update** | `shadow_ops_track` | missionId: 4, stepId: "s2", status: "completed" |
43
- | **Intent Log** | `shadow_ops_log` | missionId: 4, type: "fix", content: "..." |
44
- | **Complete Mission** | `shadow_ops_track` | missionId: 4, status: "completed" — auto-synthesizes ADR |
45
- | **Crystallize** | `shadow_ops_crystallize` | missionId: 4 — compress logs mid-mission |
46
- | **Theme Crystallize** | `shadow_ops_crystallize_theme` | query: "auth patterns" — cross-mission semantic clustering |
47
- | **Handoff (write)** | `shadow_ops_handoff` | missionId, role: "RECON", summary, findings — persist artifact |
48
- | **Handoff (read)** | `shadow_ops_handoff_read` | missionId, query: "auth findings" — semantic retrieval |
49
- | **Event Mesh** | `shadow_analyze_mesh` | repoPath — surface all HTTP routes, socket events, pubsub topics |
50
- | **Type Graph** | `shadow_analyze_type_graph` | filePath, repoPath — interface/type inheritance map |
51
- | **Explain Diff** | `shadow_analyze_explain_diff` | fromCommit, toCommit, repoPath — semantic diff narrative |
52
-
53
- _Note: Always use `symbolName` in `shadow_ops_log` to create Liquid Anchors._
54
-
55
- ## 4. Don't
10
+ ## Start
56
11
 
57
- - Don't do one step and stop /continue is "finish a mission," not "do one step."
58
- - Don't call `shadow_ops_synthesize` after completing it's automatic on `status: "completed"`.
59
- - Don't long status reports. Don't ask "what should I work on?" unless a real tie. Don't auto-commit.
12
+ 1. `shadow_ops_context({ repoPath, compact: true })` or `shadow_ops_briefing({ repoPath, scope: "project", altitude: "orbit" })`
13
+ 2. Pick one leaf mission from `next_work_candidates`. Prefer in-progress over planned.
14
+ 3. If there is no candidate, stop and plan new work instead of inventing a mission.
60
15
 
61
- ---
16
+ ## Work loop
17
+
18
+ - Mark the active step: `shadow_ops_track({ repoPath, missionId, stepId, status: "in-progress" })`
19
+ - If multiple agents may edit the same area, check and claim first:
20
+ - `shadow_working_set_check({ repoPath, filePaths })`
21
+ - `shadow_ops_claim({ repoPath, missionId, filePaths, agentTag? })`
22
+ - Do focused discovery with the relevant search, recon, analyze, and inspect tools.
23
+ - Record at least one meaningful log per step:
24
+ - `shadow_ops_log({ repoPath, missionId, type: "decision" | "discovery" | "fix", content, filePath?, symbolName? })`
25
+ - Mark each finished step:
26
+ - `shadow_ops_track({ repoPath, missionId, stepId, status: "completed", contextPivot? })`
62
27
 
63
- **Tools:** `shadow_ops_context` (optional start), `shadow_ops_briefing`, `shadow_ops_track`, `shadow_ops_log`, `shadow_ops_crystallize`, `shadow_ops_crystallize_theme`, `shadow_ops_handoff`, `shadow_ops_handoff_read`, `shadow_sync_trace`. For discovery: `shadow_search_*`, `shadow_recon_*`, `shadow_analyze_*` (including `shadow_analyze_mesh`, `shadow_analyze_type_graph`, `shadow_analyze_explain_diff`).
28
+ ## Finish
29
+
30
+ - Optional handoff for downstream agents:
31
+ - `shadow_ops_handoff({ repoPath, missionId, kind, findings, risks?, gaps?, confidence?, agentTag? })`
32
+ - `shadow_ops_handoff_read({ repoPath, missionId?, kind?, query?, limit? })`
33
+ - Optional review gate, but only after the user explicitly asks for Tribunal or clearly approves it:
34
+ - `shadow_ops_tribunal_submit({ repoPath, missionId })`
35
+ - `shadow_ops_tribunal_status({ repoPath, missionId })`
36
+ - Release any claims you took:
37
+ - `shadow_ops_release({ repoPath, missionId, filePaths? })`
38
+ - Complete the mission:
39
+ - `shadow_ops_track({ repoPath, missionId, status: "completed" })`
40
+
41
+ ## Rules
42
+
43
+ - Don't do one step and stop — /continue is "finish a mission," not "do one step."
44
+ - Don't call `shadow_ops_synthesize` after completion unless you are intentionally regenerating the record.
45
+ - Never run Tribunal without explicit user consent.
46
+ - `shadow_ops_handoff` does not take `role` or `summary`; use `kind` plus structured `findings`.
47
+ - `shadow_ops_crystallize_theme` takes `theme`, not `query`.
@@ -0,0 +1,46 @@
1
+ ---
2
+ name: coordinate
3
+ description: Coordinate multi-agent or parallel work with working-set checks, file claims, dispatch waves, handoffs, and user-approved Tribunal review. Use when several agents may edit at once or when work must be transferred cleanly.
4
+ ---
5
+
6
+ # Coordinate
7
+
8
+ Use this skill when execution risk comes from overlap, not code complexity.
9
+
10
+ ## Conflict control
11
+
12
+ - `shadow_working_set_check({ repoPath, filePaths })`
13
+ - `shadow_ops_claim({ repoPath, missionId, filePaths, agentTag? })`
14
+ - `shadow_ops_release({ repoPath, missionId, filePaths? })`
15
+
16
+ ## Parallel planning
17
+
18
+ - `shadow_ops_dispatch_plan({ repoPath, parentMissionId?, missionIds?, includeClaimCheck: true })`
19
+ - `shadow_ops_graph({ repoPath, missionId, depth?, format: "mermaid" | "json" })`
20
+
21
+ ## Handoffs
22
+
23
+ - Write: `shadow_ops_handoff({ repoPath, missionId?, kind, findings, risks?, gaps?, missionsCreated?, confidence?, agentTag? })`
24
+ - Read: `shadow_ops_handoff_read({ repoPath, missionId?, kind?, query?, limit? })`
25
+
26
+ Available `kind` values:
27
+
28
+ - `recon_report`
29
+ - `risk_assessment`
30
+ - `impact_map`
31
+ - `debt_scan`
32
+ - `custom`
33
+
34
+ ## Tribunal
35
+
36
+ Never run Tribunal unless the user explicitly asks for it or clearly approves it.
37
+
38
+ - `shadow_ops_tribunal_submit({ repoPath, missionId })`
39
+ - `shadow_ops_tribunal_status({ repoPath, missionId? or sessionId? })`
40
+
41
+ ## Rules
42
+
43
+ - Claim only the files you expect to edit.
44
+ - Release claims promptly when the work is done.
45
+ - Tribunal is opt-in only. Treat it as a user-consent gate, not an automatic review step.
46
+ - Handoffs must be structured. There is no `role` or `summary` field.