@precisionutilityguild/liquid-shadow 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +279 -62
- package/dist/data/migrations/000_baseline.sql +17 -0
- package/dist/data/migrations/014_tribunal_state.sql +24 -0
- package/dist/data/migrations/015_repo_level_handoffs_nullable.sql +52 -0
- package/dist/data/migrations/016_repair_tribunal_artifact_fk.sql +58 -0
- package/dist/entry/cli/index.js +1296 -928
- package/dist/entry/ember/index.js +313 -254
- package/dist/entry/mcp/server.js +1031 -808
- package/dist/entry/tribunal/index.js +685 -0
- package/dist/index.js +1008 -785
- package/dist/logic/domain/embeddings/worker.js +1 -1
- package/dist/logic/parser/index.js +16 -16
- package/dist/logic/parser/worker.js +1 -1
- package/dist/skills/shadow_audit/SKILL.md +22 -30
- package/dist/skills/shadow_chronicle/SKILL.md +16 -29
- package/dist/skills/shadow_continue/SKILL.md +37 -53
- package/dist/skills/shadow_coordinate/SKILL.md +46 -0
- package/dist/skills/shadow_crystallize/SKILL.md +13 -27
- package/dist/skills/shadow_mission/SKILL.md +27 -41
- package/dist/skills/shadow_onboard/SKILL.md +26 -35
- package/dist/skills/shadow_research/SKILL.md +15 -23
- package/dist/skills/shadow_sync/SKILL.md +18 -9
- package/dist/skills/shadow_synthesize/SKILL.md +14 -36
- package/dist/skills/shadow_trace_impact/SKILL.md +30 -50
- package/dist/skills/shadow_understand/SKILL.md +37 -52
- package/dist/skills/shadow_workspace/SKILL.md +44 -22
- package/dist/web-manifest.json +18 -7
- package/package.json +2 -1
- package/skills/shadow_audit/SKILL.md +22 -30
- package/skills/shadow_chronicle/SKILL.md +16 -29
- package/skills/shadow_continue/SKILL.md +37 -53
- package/skills/shadow_coordinate/SKILL.md +46 -0
- package/skills/shadow_crystallize/SKILL.md +13 -27
- package/skills/shadow_mission/SKILL.md +27 -41
- package/skills/shadow_onboard/SKILL.md +26 -35
- package/skills/shadow_research/SKILL.md +15 -23
- package/skills/shadow_sync/SKILL.md +18 -9
- package/skills/shadow_synthesize/SKILL.md +14 -36
- package/skills/shadow_trace_impact/SKILL.md +30 -50
- package/skills/shadow_understand/SKILL.md +37 -52
- package/skills/shadow_workspace/SKILL.md +44 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parentPort as c,workerData as E}from"worker_threads";import
|
|
1
|
+
import g from"os";import{parentPort as c,workerData as E}from"worker_threads";import y from"pino";var M={10:"TRACE",20:"DEBUG",30:"INFO",40:"WARN",50:"ERROR",60:"FATAL"},h=y({level:process.env.LOG_LEVEL||"warn",base:{service:"liquid-shadow"},formatters:{level(e,r){return{level:e,severity:M[r]??"INFO"}}},transport:{target:"pino-pretty",options:{colorize:!0,translateTime:"HH:MM:ss",destination:2,levelKey:"severity",messageKey:"message"}}}),o=h;try{g.setPriority(g.constants.priority.PRIORITY_BELOW_NORMAL)}catch{}var u=process.env.EMBEDDING_MODEL??"Xenova/all-MiniLM-L6-v2",a=process.env.EMBEDDING_DTYPE??"fp32",s=null;async function w(){if(!s){s=await import("@xenova/transformers"),s.env.cacheDir=E?.cacheDir||"./.cache",s.env.allowLocalModels=!0;let{ONNX:e}=s;if(e?.InferenceSession?.create){let r=e.InferenceSession.create.bind(e.InferenceSession);e.InferenceSession.create=(t,n={})=>r(t,{...n,intraOpNumThreads:2,extra:{"session.intra_op.allow_spinning":"0","session.force_spinning_stop":"1","ep.dynamic.workload_type":"Efficient",...n.extra??{}}})}}return s}var l=null;function f(e=!1){let r=(a||"").toLowerCase(),t={};return a&&(t.dtype=a),e?(t.quantized=!1,t):(r==="fp32"||r==="fp16"||r==="float32"||r==="float16"?t.quantized=!1:r.startsWith("q")&&(t.quantized=!0),t)}async function b(){let{pipeline:e}=await w(),r=f(!1);try{l=await e("feature-extraction",u,r)}catch(t){let n=t?.message||"";if(!(n.includes("/onnx/model_quantized.onnx")||n.includes("model_quantized.onnx")))throw t;o.warn({model:u,dtype:a},"Quantized ONNX artifact missing, retrying with unquantized ONNX"),l=await e("feature-extraction",u,f(!0))}}async function v(e){if(e.length===0)return[];try{let r=await l(e,{pooling:"mean",normalize:!0}),[t,n]=r.dims,i=[];for(let d=0;d<t;d++){let p=d*n,m=p+n;i.push(Array.from(r.data.slice(p,m)))}return i}catch(r){o.error({err:r,batchSize:e.length},"Vectorized batch embedding failed, falling back to sequential");let t=[];for(let n of e){if(!n||n.trim().length===0){t.push(null);continue}try{let i=await l(n,{pooling:"mean",normalize:!0});t.push(Array.from(i.data))}catch{t.push(null)}}return t}}async function R(e){if(e.type==="shutdown"&&process.exit(0),e.type==="embed")try{let r=await v(e.texts),t={type:"result",id:e.id,embeddings:r};c?.postMessage(t)}catch(r){let t={type:"error",id:e.id,error:r instanceof Error?r.message:String(r)};c?.postMessage(t)}}async function z(){await b();let e={type:"ready"};c?.postMessage(e),c?.on("message",r=>{R(r).catch(t=>{o.error({error:t},"Worker error")})})}z().catch(e=>{o.error({error:e},"Failed to initialize embedding worker"),process.exit(1)});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import ot from"fs";function Je(t){let n=t.split(`
|
|
2
|
-
`)
|
|
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";import ct from"path";import mt from"pino";var ft={10:"TRACE",20:"DEBUG",30:"INFO",40:"WARN",50:"ERROR",60:"FATAL"},dt=mt({level:process.env.LOG_LEVEL||"warn",base:{service:"liquid-shadow"},formatters:{level(n,t){return{level:n,severity:ft[t]??"INFO"}}},transport:{target:"pino-pretty",options:{colorize:!0,translateTime:"HH:MM:ss",destination:2,levelKey:"severity",messageKey:"message"}}}),ne=dt;import*as Ae from"@swc/core";function Je(n){if(!n||typeof n!="object")return!1;let t=n;return typeof t.parse=="function"&&typeof t.parseSync=="function"}function ht(){if(Je(Ae))return Ae;let n=Ae;if(Je(n.default))return n.default;throw new Error("SWC runtime unavailable: couldn't resolve parse/parseSync from @swc/core exports")}var yt=ht();function Se(n,t,i){return yt.parseSync(n,t,i)}function ve(n,t,i){let e=n.toLowerCase(),s=t.toLowerCase(),l=e.split("/").pop()||e;return i==="TsInterfaceDeclaration"||i==="TsTypeAliasDeclaration"||i==="TsEnumDeclaration"?"Type Definition":l.startsWith("use")||s.startsWith("use")?"Hook":e.includes("components/")||e.endsWith(".tsx")?"Component":e.includes("models/")||s.endsWith("model")?"Model":e.includes("services/")||e.includes("controllers/")||e.includes("handlers/")||e.includes("mcp/")||e.endsWith("service.ts")||e.endsWith("controller.ts")||e.endsWith("handler.ts")||s.endsWith("service")||s.endsWith("controller")||s.endsWith("handler")?"Service":e.includes("repositories/")||e.includes("repos/")||e.endsWith("repository.ts")||e.endsWith("repo.ts")||s.endsWith("repository")||s.endsWith("repo")?"Repository":"Other"}function ce(n){let t=[];return/\b(fetch|axios|superagent|got)\s*\(|import\s+.*\b(http|https|node-fetch)\b/i.test(n)&&t.push("Network"),(/\b(knex|prisma|typeorm|mongoose|sequelize|pg|mysql|sqlite3)\b/i.test(n)||/\b(SELECT\s+.*FROM|INSERT\s+INTO|UPDATE\s+.*SET|DELETE\s+FROM)\b/i.test(n)||/\.query\s*\(|\.execute\s*\(/i.test(n)&&/db|database|client|pool/i.test(n))&&t.push("Database"),(/\bfs\./i.test(n)||/\b(readFileSync|writeFileSync|readFile|writeFile|readdir)\b/.test(n)||/import\s+.*\bfs\b/.test(n))&&t.push("File System"),(/\b(localStorage|sessionStorage|indexedDB)\./.test(n)||/\bdocument\.cookie\b/.test(n))&&t.push("Browser Storage"),t}function qe(n){let t=[],i=/\/\*\*[\s\S]*?\*\//g,e;for(;(e=i.exec(n))!==null;)t.push({start:e.index,end:e.index+e[0].length,text:e[0]});return t}function U(n,t,i){for(let e of t){if(e.start===n)return e.text;if(e.start>n&&e.start<n+50){let s=i.substring(n,e.start);if(/^\s*$/.test(s))return e.text}if(e.end<=n&&e.end>n-50){let s=i.substring(e.end,n);if(/^\s*$/.test(s))return e.text}}return""}function He(n){if(!n)return"";let i=n.replace(/\/\*\*|\*\/|\*/g,"").trim().split(`
|
|
2
|
+
`)[0].trim();return i.length>200?i.substring(0,197)+"...":i}function Ue(n){let t=n.split(`
|
|
3
|
+
`),i=[],e=0;for(let s of t)i.push(e),e+=s.length+1;return i}function w(n,t){for(let i=0;i<t.length;i++)if(t[i+1]>n||i===t.length-1)return i+1;return 1}function Me(n,t){return t.slice(0,n).toString("utf8").length}function Ve(n){if(n.toString("utf8").length===n.length)return e=>e;let i=new Map;return e=>{let s=i.get(e);return s===void 0&&(s=n.slice(0,e).toString("utf8").length,i.set(e,s)),s}}function Ge(n,t,i){let e=n.start-t,s=n.end-t;return e<0||s>i.length?"":i.slice(e,s).toString("utf8")}function V(n,t){if(!n)return"";let i=n.trimStart();for(;/^\/\*[\s\S]*?\*\//.test(i);)i=i.replace(/^\/\*[\s\S]*?\*\/\s*/,"");for(;/^\/\/[^\n]*\n/.test(i);)i=i.replace(/^\/\/[^\n]*\n\s*/,"");if(i=i.replace(/^(?:import[^\n]*\n)+/,"").replace(/^(?:export\s+\{[^}]*\}\s+from\s+['"][^'"]+['"];?\s*\n?)+/,"").trim(),t==="TsInterfaceDeclaration"||t==="TsTypeAliasDeclaration")return i;let e=0,s=0,l=i.length;for(let y=0;y<i.length;y++){let E=i[y];if(E==="(")e++;else if(E===")")e--;else if(E==="<")s++;else if(E===">")s--;else if(E==="{"){if(e===0&&s===0){l=y;break}}else if(E===";"&&e===0&&s===0){l=y;break}else if(E==="="&&i[y+1]===">"&&e===0&&s===0){l=y+2;break}}let f=i.substring(0,l).trim();return f.length>500?f.slice(0,497)+"...":f}function Ke(n){let t=[];for(let i of n)i.type==="ImportDeclaration"&&t.push({module:i.source.value,name:i.specifiers.map(e=>e.type==="ImportDefaultSpecifier"?"default":e.type==="ImportNamespaceSpecifier"?"*":e.local?.value||e.imported?.value||"*").join(", ")}),i.type==="ExportAllDeclaration"&&t.push({module:i.source.value,name:"*"}),i.type==="ExportNamedDeclaration"&&i.source&&t.push({module:i.source.value,name:i.specifiers.map(e=>e.type==="ExportSpecifier"?e.orig.value:"*").join(", ")});return t}function gt(n,t){for(let i of n){if((i.type==="FunctionDeclaration"||i.type==="ClassDeclaration")&&(i.identifier?.value||i.id?.value)===t)return i.span;if(i.type==="VariableDeclaration"){for(let e of i.declarations)if(e.id?.type==="Identifier"&&e.id.value===t)return e.span||i.span}if((i.type==="TsTypeAliasDeclaration"||i.type==="TsInterfaceDeclaration"||i.type==="TsEnumDeclaration")&&(i.id?.value||i.identifier?.value)===t)return i.span;if(i.type==="ExportDeclaration"){let e=i.declaration;if(!e)continue;if((e.type==="FunctionDeclaration"||e.type==="ClassDeclaration")&&(e.identifier?.value||e.id?.value)===t)return e.span||i.span;if(e.type==="VariableDeclaration"){for(let s of e.declarations)if(s.id?.type==="Identifier"&&s.id.value===t)return s.span||e.span||i.span}}}return null}function Qe(n,t,i,e,s,l,f,y,E){let o=E??(a=>Me(a,i)),u=[];for(let a of n){if(a.type==="ExportDeclaration"){let c=a.declaration,m=c.type,r="";m==="VariableDeclaration"?r=c.declarations.map(T=>T.id.value).join("",""):r=c.id?.value||c.identifier?.value||"anonymous";let p=o(a.span.start-t),g=o(a.span.end-t),x=U(p,l,e),S=y(a.span),d=[];if(a.type==="ExportDeclaration"&&(m==="ClassDeclaration"||m==="ClassExpression")){let T=c.body||[];for(let C of T)if(C.type==="ClassMethod"||C.type==="ClassProperty"){let N=C.key.value;if(!N)continue;let O=o(C.span.start-t),q=o(C.span.end-t),A=y(C.span),z=U(O,l,e);d.push({name:N,kind:C.type,signature:V(A,C.type),line:w(O,s),endLine:w(q,s),doc:z,classification:C.type==="ClassMethod"?"Method":"Property",capabilities:"[]"})}}else if(m==="FunctionDeclaration"&&c.body?.type==="BlockStatement")d=Ie(c.body.stmts,t,i,e,s,l,y,o);else if(m==="VariableDeclaration"){for(let T of c.declarations)if(T.init&&(T.init.type==="ArrowFunctionExpression"||T.init.type==="FunctionExpression")&&T.init.body?.type==="BlockStatement"){d=Ie(T.init.body.stmts,t,i,e,s,l,y,o);break}}u.push({name:r,kind:m,signature:V(S,m),line:w(p,s),endLine:w(g,s),doc:x,classification:ve(f,r,m),capabilities:JSON.stringify(ce(S)),members:d})}if(a.type==="ExportNamedDeclaration"){for(let c of a.specifiers)if(c.type==="ExportSpecifier"){let m=c.orig.value,r=c.exported?.value||m,g=gt(n,m)||a.span,x=o(g.start-t),S=o(g.end-t),d=U(x,l,e);u.push({name:r,kind:"ExportSpecifier",signature:`export { ${m} }`,line:w(x,s),endLine:w(S,s),doc:d,classification:"Export mapping",capabilities:"[]"})}}if(a.type==="ExportDefaultDeclaration"){let c=o(a.span.start-t),m=o(a.span.end-t),r=U(c,l,e),p=y(a.span),g=[];if(a.decl.type==="ClassExpression"||a.decl.type==="ClassDeclaration"){let x=a.decl.body||[];for(let S of x)if(S.type==="ClassMethod"||S.type==="ClassProperty"){let d=S.key.value;if(!d)continue;let T=o(S.span.start-t),C=o(S.span.end-t),N=y(S.span),O=U(T,l,e);g.push({name:d,kind:S.type,signature:V(N,S.type),line:w(T,s),endLine:w(C,s),doc:O,classification:S.type==="ClassMethod"?"Method":"Property",capabilities:"[]"})}}else(a.decl.type==="FunctionExpression"||a.decl.type==="FunctionDeclaration"||a.decl.type==="ArrowFunctionExpression")&&a.decl.body?.type==="BlockStatement"&&(g=Ie(a.decl.body.stmts,t,i,e,s,l,y,o));u.push({name:"default",kind:"DefaultExport",signature:V(p,"DefaultExport"),line:w(c,s),endLine:w(m,s),doc:r,classification:"Default Export",capabilities:JSON.stringify(ce(p)),members:g})}if(a.type==="ExportDefaultExpression"){let c=o(a.span.start-t),m=o(a.span.end-t),r=U(c,l,e),p=y(a.span),g=a.expression,x=g?.type==="Identifier"?g.value:g?.identifier?.value||g?.id?.value||void 0;u.push({name:"default",kind:"DefaultExport",signature:V(p,"DefaultExport"),line:w(c,s),endLine:w(m,s),doc:r,classification:"Default Export",capabilities:JSON.stringify(ce(p)),members:[],defaultTarget:x})}if(a.type==="ExportAllDeclaration"){let c=o(a.span.start-t),m=o(a.span.end-t),r=a.source.value,p=U(c,l,e);u.push({name:"*",kind:"ExportAllDeclaration",signature:`export * from "${r}"`,line:w(c,s),endLine:w(m,s),doc:p,classification:"Re-export",capabilities:"[]"})}}return u}function Ie(n,t,i,e,s,l,f,y){let E=[];for(let o of n){if(o.type==="VariableDeclaration")for(let u of o.declarations){let a=[],c=r=>{if(r.type==="Identifier")a.push({name:r.value,span:r.span});else if(r.type==="ArrayPattern")for(let p of r.elements)p&&c(p);else if(r.type==="ObjectPattern")for(let p of r.properties)p.type==="AssignmentPatternProperty"?a.push({name:p.key.value,span:p.span}):p.type==="KeyValuePatternProperty"&&c(p.value)};c(u.id);let m=u.init&&(u.init.type==="ArrowFunctionExpression"||u.init.type==="FunctionExpression");for(let r of a){let p=m?u.init.span||u.span||r.span:u.span||r.span,g=m?u.init.type:"VariableDeclaration",x=m?"Internal Function":"Internal Variable",S=y(p.start-t),d=y(p.end-t),T=f(p),C=U(S,l,e);E.push({name:r.name,kind:g,signature:V(T,g),line:w(S,s),endLine:w(d,s),doc:C,classification:x,capabilities:"[]"})}}if(o.type==="FunctionDeclaration"){let u=o.identifier?.value||o.ident?.value||"anonymous",a=y(o.span.start-t),c=y(o.span.end-t),m=f(o.span),r=U(a,l,e);E.push({name:u,kind:"FunctionDeclaration",signature:V(m,"FunctionDeclaration"),line:w(a,s),endLine:w(c,s),doc:r,classification:"Internal Function",capabilities:"[]"})}if(o.type==="ReturnStatement"&&o.argument?.type==="ObjectExpression")for(let u of o.argument.properties){let a="",c=u.span||u.key?.span||u.ident?.span;if(u.type==="KeyValueProperty"){let m=u.key;a=m?.value||m?.raw||(m?.type==="Identifier"?m.value:"")}else u.type==="MethodProperty"?a=u.key?.value||u.key?.raw||"":u.type==="ShorthandProperty"?a=u.ident?.value||"":u.type==="Identifier"&&(a=u.value||"");if(a&&c){let m=y(c.start-t),r=y(c.end-t),p=f(c),g=U(m,l,e);E.push({name:a,kind:"ReturnProperty",signature:V(p,"ReturnProperty"),line:w(m,s),endLine:w(r,s),doc:g,classification:"Return Member",capabilities:"[]"})}}if(o.type==="ExpressionStatement"&&o.expression.type==="CallExpression"){let u=o.expression;if(u.callee.type==="MemberExpression"&&(u.callee.property?.value==="on"||u.callee.property?.value==="once")){let a=u.arguments[0]?.expression?.value,c=u.arguments[1]?.expression;if(a&&c&&(c.type==="ArrowFunctionExpression"||c.type==="FunctionExpression")){let m=y(c.span.start-t),r=y(c.span.end-t),p=f(c.span);E.push({name:`on:${a}`,kind:c.type,signature:V(p,c.type),line:w(m,s),endLine:w(r,s),doc:"",classification:"Event Handler",capabilities:"[]"})}}if(u.callee.type==="Identifier"&&u.callee.value==="addRoute"&&u.arguments.length>=3){let a=u.arguments[2].expression;if(a.type==="StringLiteral"){let c=a.value,m=y(u.span.start-t),r=y(u.span.end-t),p=f(u.span);E.push({name:c,kind:"HTTP Route",signature:V(p,"HTTP Route"),line:w(m,s),endLine:w(r,s),doc:"",classification:"Service Boundary",capabilities:JSON.stringify({path:c})})}}}}return E}function Xe(n,t,i,e,s,l){let f=l??(o=>Me(o,i)),y=[];function E(o){if(!(!o||typeof o!="object")){if(o.type==="CallExpression"){let u=bt(o);if(u){let a=f(o.span.start-t);y.push({...u,line:w(a,e),snippet:s(o.span)})}}for(let u of Object.keys(o)){if(u==="span")continue;let a=o[u];Array.isArray(a)?a.forEach(E):typeof a=="object"&&E(a)}}}return n.forEach(E),y}function bt(n){let{callee:t,arguments:i}=n;if(!i||i.length===0)return null;if(t.type==="Identifier"&&t.value,t.type==="Identifier"&&t.value==="addRoute"&&i.length>=3){let e=i[2].expression;if(e.type==="StringLiteral")return{type:"api_route",name:e.value,direction:"consume"}}if(t.type==="MemberExpression"&&t.property?.type==="Identifier"){let e=t.property.value;if(e==="emit"&&i[0].expression.type==="StringLiteral")return{type:"socket_event",name:i[0].expression.value,direction:"produce"};if(e==="on"&&i[0].expression.type==="StringLiteral")return{type:"socket_event",name:i[0].expression.value,direction:"consume"};if(["get","post","put","delete","patch"].includes(e)&&i[0].expression.type==="StringLiteral"){let l=i[0].expression.value,f=t.object.type==="Identifier"?t.object.value:"";if(["axios","http","request","appApi","restApi","adminApi","client"].includes(f))return{type:"api_route",name:l,direction:"produce"};if(l.startsWith("/"))return{type:"api_route",name:l,direction:"consume"}}}return t.type==="Identifier"&&t.value==="fetch"&&i[0].expression.type==="StringLiteral"?{type:"api_route",name:i[0].expression.value,direction:"produce"}:null}import Le from"path";import Rt from"fs";import it from"path";import{fileURLToPath as Ct}from"url";import*as ie from"web-tree-sitter";import{existsSync as xt}from"node:fs";import{dirname as $e,join as et,resolve as Dt}from"node:path";import{fileURLToPath as St}from"node:url";var vt=St(import.meta.url),Ye=$e(vt);function Mt(){let n=Ye;for(;n!==$e(n);){if(xt(et(n,"package.json")))return n;n=$e(n)}return Dt(Ye,"..","..")}function tt(...n){return et(Mt(),...n)}var Qt=it.dirname(Ct(import.meta.url)),nt=ne.child({module:"parser:tree-sitter"}),Re=class{parser=null;languages=new Map;async ensureInitialized(){if(this.parser)return;let t=ie.Parser||ie;await t.init(),this.parser=new t}async getLanguage(t){if(this.languages.has(t))return this.languages.get(t);let i=tt("resources","grammars",`tree-sitter-${this.getLangName(t)}.wasm`);if(!Rt.existsSync(i))return nt.warn({grammarPath:i},"Grammar WASM not found"),null;try{let e=await ie.Language.load(i);return this.languages.set(t,e),e}catch(e){return nt.error({err:e,ext:t},"Failed to load language grammar"),null}}getLangName(t){switch(t.toLowerCase()){case".php":return"php";case".py":return"python";case".go":return"go";case".rs":return"rust";default:return""}}getQueries(t){switch(t.toLowerCase()){case".php":return`
|
|
4
4
|
(function_definition name: (name) @name) @func
|
|
5
5
|
(class_declaration name: (name) @name) @class
|
|
6
6
|
(interface_declaration name: (name) @name) @interface
|
|
@@ -24,16 +24,16 @@ import ot from"fs";function Je(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(
|
|
28
|
-
`),y=this.getQueries(e);if(!y)return[];let o=new ie.Query(s,y).matches(l.rootNode),
|
|
29
|
-
`),
|
|
30
|
-
`).trim(),capabilities:JSON.stringify(R),members:[]}),c=[],
|
|
31
|
-
`).trim(),capabilities:JSON.stringify({attributes:c}),members:[]}),c=[],
|
|
32
|
-
`).trim(),capabilities:JSON.stringify({attributes:c}),members:[]}),c=[],
|
|
33
|
-
`).trim(),capabilities:JSON.stringify(Z),members:[]}),c=[],
|
|
34
|
-
`).trim();if(We){let J=_e.path||"/";e.push({name:J,kind:"HTTP Route",classification:"Service Boundary",signature:`Function: ${M}`,line:
|
|
35
|
-
`).trim(),capabilities:JSON.stringify({visibility:R,static:M,readonly:Z,type:
|
|
36
|
-
`),l=[{indent:-1,name:"root",type:"root"}],
|
|
37
|
-
`).trim()),
|
|
38
|
-
`);for(let o of
|
|
39
|
-
`).length,
|
|
27
|
+
`;default:return""}}mapKind(t,i){if(t==="import")return"ImportDeclaration";if(i===".php"){if(t==="func")return"FunctionDeclaration";if(t==="class")return"ClassDeclaration";if(t==="interface")return"InterfaceDeclaration";if(t==="trait")return"TraitDeclaration";if(t==="method")return"MethodDeclaration"}if(i===".py"){if(t==="func")return"FunctionDeclaration";if(t==="class")return"ClassDeclaration"}if(i===".go"){if(t==="func")return"FunctionDeclaration";if(t==="type")return"TypeDeclaration"}if(i===".rs"){if(t==="func")return"FunctionDeclaration";if(t==="struct")return"StructDeclaration";if(t==="enum")return"EnumDeclaration";if(t==="trait")return"TraitDeclaration";if(t==="type")return"TypeDeclaration"}return"Unknown"}mapClassification(t){return t==="import"?"Dependency":t==="func"||t==="method"?"Function":t==="class"||t==="interface"||t==="trait"||t==="struct"||t==="enum"||t==="type"?"Class":"Other"}async parse(t,i){await this.ensureInitialized();let e=it.extname(t).toLowerCase(),s=await this.getLanguage(e);if(!s||!this.parser)return[];this.parser.setLanguage(s);let l=this.parser.parse(i),f=i.split(`
|
|
28
|
+
`),y=this.getQueries(e);if(!y)return[];let o=new ie.Query(s,y).matches(l.rootNode),u=[];for(let a of o){let c=a.captures.find(p=>p.name==="name")?.node,m=a.captures[0].node,r=a.captures[0].name;if(c){let p=m.startPosition.row+1,g=m.endPosition.row+1,x=f[m.startPosition.row].trim();u.push({name:c.text,kind:this.mapKind(r,e),classification:this.mapClassification(r),signature:x,line:p,endLine:g,doc:"",capabilities:"{}"})}}return u}};function ye(n){let{classification:t,capabilities:i,exports:e,fileName:s}=n,l={Network:"API integration",Database:"data persistence","File System":"file I/O operations","Browser Storage":"client-side storage"},f=i.map(r=>l[r]).filter(Boolean).join(" and "),E={Component:(r,p)=>{let g=p.find(S=>S.kind==="FunctionDeclaration"||S.kind==="ClassDeclaration")?.name,x=g?`React component: ${g}`:"React UI component";return r?`${x} with ${r}`:x},Hook:(r,p)=>{let g=p.find(S=>S.name.startsWith("use"))?.name,x=g?`Custom React hook: ${g}`:"Custom React hook";return r?`${x} for ${r}`:x},Service:(r,p)=>{let x=`Service layer: ${p[0]?.name||"Service"}`;return r?`${x} handling ${r}`:x},Repository:(r,p)=>`Data repository: ${p[0]?.name||"Repository"} for ${r||"data access"}`,"Type Definition":(r,p)=>`Type definitions: ${p.slice(0,3).map(x=>x.name).join("")}${p.length>3?"...":""}`,Model:(r,p)=>`Data model: ${p[0]?.name||"Model"}`,"HTTP Route":(r,p)=>{let g=p.filter(x=>x.classification==="Service Boundary");return g.length>0?`API endpoints: ${g.slice(0,3).map(x=>x.name).join("")}`:"API route handler"},"Micro IR (PHP)":(r,p)=>{let g=p.some(S=>S.classification==="Service Boundary"),x=p.find(S=>S.kind==="ClassDeclaration")?.name;return g?"PHP controller with API routes":x?`PHP class: ${x}`:"PHP module"},"Micro IR (Python)":(r,p)=>{let g=p.some(S=>S.classification==="Service Boundary"),x=p.find(S=>S.kind==="ClassDeclaration")?.name;return g?"Python API handler with routes":x?`Python class: ${x}`:"Python module"},"Micro IR (Go/TS) ":(r,p)=>{let g=p.some(S=>S.kind==="TypeDeclaration"),x=p.filter(S=>S.kind==="FunctionDeclaration");return g&&x.length>0?`Go package: types and ${x.length} function(s)`:g?"Go package: type definitions":x.length>0?`Go package: ${x[0].name} and ${x.length} function(s)`:"Go module"},"Micro IR (Rust/TS) ":(r,p)=>{let g=p.find(d=>d.kind==="TraitDeclaration")?.name,x=p.find(d=>d.kind==="StructDeclaration")?.name,S=p.filter(d=>d.kind==="FunctionDeclaration");return g?r.includes("Rust trait")?`Rust module: trait ${g}`:`Rust module: ${g}`:x?`Rust module: struct ${x}`:S.length>0?`Rust module: ${S.length} function(s)`:"Rust module"}}[t];if(E)return E(f,e);if(e.length===0)return s?`Module: ${s}`:"Module with no exports";let o=e.filter(r=>r.kind==="FunctionDeclaration"),u=e.filter(r=>r.kind==="ClassDeclaration"),a=e.filter(r=>r.kind==="TsInterfaceDeclaration"||r.kind==="TsTypeAliasDeclaration"),c=[];if(u.length>0&&c.push(`Class: ${u[0].name}`),o.length>0){let r=o.slice(0,2).map(p=>p.name).join("");c.push(`Functions: ${r}`)}a.length>0&&c.push(`Types: ${a.length}`);let m=c.length>0?c.join(" | "):`Module with ${e.length} export(s)`;return f?`${m} \u2014 ${f}`:m}var Ce=class{parse(t,i=!1){let e=[],s=[],l=t.split(`
|
|
29
|
+
`),f="",y="",E=0,o=0,u=-1,a=-1,c=[],m=[],r=!1,p=i?"api":"",g="",x=/^namespace\s+([a-zA-Z0-9_\\]+);/,S=/^(?:abstract\s+)?(?:readonly\s+)?class\s+([a-zA-Z0-9_]+)/,d=/^interface\s+([a-zA-Z0-9_]+)/,T=/^trait\s+([a-zA-Z0-9_]+)/,C=/^enum\s+([a-zA-Z0-9_]+)(?:\s*:\s*(string|int))?\s*/,N=/^((?:(?:public|protected|private|static)\s+)*)function\s+([a-zA-Z0-9_]+)\s*\(/,O=/^(public|protected|private)\s+(static\s+)?(readonly\s+)?(?:(\?\s*)?([a-zA-Z0-9_\\|]+)\s+)?\$([a-zA-Z0-9_]+)/,q=/^use\s+([a-zA-Z0-9_\\]+)(?:\s+as\s+([a-zA-Z0-9_]+))?;/,A=/^#\[([a-zA-Z0-9_\\]+)(?:\((.*)\))?\]/,z=/(?:Route::|router->|\$router->|->)(get|post|put|delete|patch|match)\s*\(\s*(?:uri\s*:\s*)?['"]([^'"]+)['"]/,W=/->prefix\s*\(\s*(?:prefix\s*:\s*)?['"]([^'"]+)['"]/,le=/\$this->(hasMany|hasOne|belongsTo|belongsToMany|morphTo|morphMany|morphOne|morphToMany|morphedByMany)\s*\(\s*([a-zA-Z0-9_\\]+)(?:::class)?/,Fe=/^->(hasMany|hasOne|belongsTo|belongsToMany|morphTo|morphMany|morphOne|morphToMany|morphedByMany)\s*\(\s*([a-zA-Z0-9_\\]+)(?:::class)?/,ge=/(public|protected|private)\s+(readonly\s+)?(?:(\?\s*)?([a-zA-Z0-9_\\|]+)\s+)?\$([a-zA-Z0-9_]+)/g,be=/(?:protected|public)\s+\$(fillable|casts|guarded|hidden|appends|with)\s*=/;function xe(b){try{let h=JSON.parse(b||"{}");if(h&&typeof h=="object"&&!Array.isArray(h))return h}catch{}return{}}function pe(b,h){let _=[],D=b,v=0,k=0;for(;D<l.length;){let F=l[D].trim();_.push(F),v+=(F.match(/\[/g)||[]).length-(F.match(/]/g)||[]).length,k+=(F.match(/\(/g)||[]).length-(F.match(/\)/g)||[]).length;let j=F.includes(h),H=v<=0&&k<=0;if(j&&H)break;D+=1}return{text:_.join(" "),endIndex:D}}function se(b,h){let _=h.replace(/^[^=]+=\s*/,"").replace(/;$/,"").trim();if(b==="casts"){let F={},j=/['"]([^'"]+)['"]\s*=>\s*['"]([^'"]+)['"]/g,H=null;for(;H=j.exec(_);)F[H[1]]=H[2];return F}let D=[],v=/['"]([^'"]+)['"]/g,k=null;for(;k=v.exec(_);)D.push(k[1]);return D}function we(b,h){for(let _=h;_>=0;_-=1){let D=b[_]?.trim()||"";if(D)return D}return""}function re(b,h,_,D){if(!f)return;let v=h.split("\\").pop()||h;s.push({type:"eloquent_relation",name:v,direction:"produce",line:_,snippet:D,method:b,url:`${f}->${v}`})}for(let b=0;b<l.length;b++){let h=l[b].trim();if(!h)continue;let _=(h.match(/{/g)||[]).length,D=(h.match(/}/g)||[]).length,v=o;if(o+=_-D,y&&o<=a){let R=e.find(M=>M.name===y&&M.line===E);R&&(R.endLine=b+1),y="",a=-1}if(f&&o<=u){let R=e.find(M=>M.name===f&&(M.kind==="ClassDeclaration"||M.kind==="TraitDeclaration"||M.kind==="InterfaceDeclaration"||M.kind==="EnumDeclaration"));R&&(R.endLine=b+1),f="",u=-1}let k=h.match(W);if(k&&(p=k[1]),h.includes("});")&&(p=""),h.startsWith("/**")){r=!0,m=[];continue}if(r){h.endsWith("*/")?r=!1:m.push(h.replace(/^\*\s?/,""));continue}let F=h.match(A);if(F){c.push(F[1]);continue}let j=h.match(x);if(j){g=j[1]||"",c=[],m=[];continue}let H=h.match(S);if(H){f=H[1],u=o-_;let R={attributes:c};g&&(R.namespace=g),e.push({name:f,kind:"ClassDeclaration",classification:"Class",signature:`class ${f}`,line:b+1,endLine:b+1,doc:m.join(`
|
|
30
|
+
`).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,B=/\bprivate\b/.test(R)?"private":/\bprotected\b/.test(R)?"protected":"public",L=/\bstatic\b/.test(R),G=pe(b,")"),te=G.text.match(/\)\s*:\s*([?a-zA-Z0-9_\\|]+)/),De=te?te[1]:null,pt=_>0&&D>=_;y=M,E=b+1,a=o-_;let We=!1,_e={};for(let J of c)J.toLowerCase().includes("route")&&(We=!0,_e={type:"route",method:"GET",path:"/"});let ze=m.join(`
|
|
34
|
+
`).trim();if(We){let J=_e.path||"/";e.push({name:J,kind:"HTTP Route",classification:"Service Boundary",signature:`Function: ${M}`,line:b+1,endLine:b+1,doc:ze,capabilities:JSON.stringify({type:"route",handler:f?`${f}@${M}`:M,..._e})}),s.push({type:"api_route",name:J,direction:"consume",line:b+1,snippet:h})}let Ze={name:M,kind:Z?"MethodDeclaration":"FunctionDeclaration",classification:Z?"Method":"Function",signature:`${Z?f+":: ":""}${M}`,line:b+1,endLine:b+1,doc:ze,capabilities:JSON.stringify(Z?{attributes:c,visibility:B,static:L,returnType:De}:{attributes:c,returnType:De})};e.push(Ze);let ke=Z?h.match(le):null;if(ke&&re(ke[1],ke[2],b+1,h),Z&&M==="__construct"){let J=null;for(;J=ge.exec(G.text);){let je=J[1],Be=!!J[2],Pe=J[4]?`${J[3]?"?":""}${J[4]}`:null,Oe=J[5],ut=`${je} ${Be?"readonly ":""}${Pe?`${Pe} `:""}$${Oe}`.trim();e.push({name:Oe,kind:"PropertyDeclaration",classification:"Property",signature:ut,line:b+1,endLine:b+1,doc:"",capabilities:JSON.stringify({visibility:je,static:!1,readonly:Be,type:Pe}),members:[]})}ge.lastIndex=0}pt&&(Ze.endLine=b+1,y="",a=-1),c=[],m=[];continue}let fe=!1,Q=!1,P=b,$=f&&!y?h.match(O):null;if($){fe=!0;let R=$[1],M=!!$[2],Z=!!$[3],B=$[5]?`${$[4]?"?":""}${$[5]}`:null,L=$[6],G=`${R} ${M?"static ":""}${Z?"readonly ":""}${B?`${B} `:""}$${L}`.trim();e.push({name:L,kind:"PropertyDeclaration",classification:"Property",signature:G,line:b+1,endLine:b+1,doc:m.join(`
|
|
35
|
+
`).trim(),capabilities:JSON.stringify({visibility:R,static:M,readonly:Z,type:B}),members:[]})}let Y=f&&!y?h.match(be):null;if(Y){Q=!0;let R=Y[1],M=pe(b,";");P=M.endIndex;let Z=se(R,M.text),B=[...e].reverse().find(L=>L.name===f&&L.kind==="ClassDeclaration");if(B){let L=xe(B.capabilities);(!L.modelConfig||typeof L.modelConfig!="object"||Array.isArray(L.modelConfig))&&(L.modelConfig={}),L.modelConfig[R]=Z,B.capabilities=JSON.stringify(L)}}if(fe||Q){Q&&P>b&&(b=P),c=[],m=[];continue}let oe=h.match(q);if(oe){let R=oe[1]||"",M=oe[2]||R.split("\\").pop()||"";e.push({name:M,kind:"ImportSpecifier",classification:"Dependency",signature:`use ${R}`,line:b+1,endLine:b+1,doc:"",capabilities:JSON.stringify({type:"use",namespace:R})}),c=[],m=[];continue}let K=h.match(z);if(K){let R=K[1].toUpperCase(),M=K[2];if(h.includes("Route::")||h.includes("router->")||h.includes("action")||h.includes(",")&&!h.includes("view(")){if(p){let te=p.startsWith("/")?p:`/${p}`,De=M.startsWith("/")?M:`/${M}`;M=(te+De).replace(/\/+/g,"/")}let B=null,L=h.match(/\[\s*([a-zA-Z0-9_]+)::class\s*,\s*['"]([^'"]+)['"]\s*\]/);if(L)B=`${L[1]}@${L[2]}`;else if(h.includes("::class")){let te=h.match(/([a-zA-Z0-9_]+)::class/);te&&(B=te[1])}let G=h;!h.endsWith(");")&&b+1<l.length&&(G+=" "+l[b+1].trim(),!G.endsWith(");")&&b+2<l.length&&(G+=" "+l[b+2].trim())),e.push({name:M,kind:"HTTP Route",classification:"Service Boundary",signature:G,line:b+1,endLine:b+1,doc:"",capabilities:JSON.stringify({type:"route",method:R,path:M,handler:B})}),s.push({type:"api_route",name:M,direction:"consume",line:b+1,snippet:G,method:R,url:M}),m=[];continue}}let ee=f&&y?h.match(le):null,de=f&&y?h.match(Fe):null;if(ee)re(ee[1],ee[2],b+1,h);else if(de){let R=we(l,b-1);/\$this\b/.test(R)&&re(de[1],de[2],b+1,h)}let lt=/(?:\$client|client|Http)::(get|post|put|delete|patch|request)\s*\(\s*(?:url\s*:\s*)?([^,)]+)|(?:\$client|client)->(request|get|post|put|delete|patch)\s*\(\s*([^,)]+)/,he=h.match(lt);if(he){let R=(he[1]||he[3]).toUpperCase(),M=(he[2]||he[4]).trim();(M.startsWith("'")&&M.endsWith("'")||M.startsWith('"')&&M.endsWith('"'))&&(M=M.substring(1,M.length-1)),s.push({type:"api_route",name:M,direction:"produce",line:b+1,snippet:h,method:R,url:M})}!h.startsWith("#[")&&!h.startsWith("//")&&!h.startsWith("*")&&!r&&(c=[],m=[])}return{nodes:e,events:s}}};var Ee=class{currentRoutePrefix="";parse(t){this.currentRoutePrefix="";let i=[],e=[],s=t.split(`
|
|
36
|
+
`),l=[{indent:-1,name:"root",type:"root"}],f=[],y=/^class\s+([a-zA-Z0-9_]+)/,E=/^async\s+def\s+([a-zA-Z0-9_]+)|^def\s+([a-zA-Z0-9_]+)/,o=/^(?:from\s+([a-zA-Z0-9_.]+)\s+import|import\s+([a-zA-Z0-9_.]+))/,u=/^@(.*)/;function a(d){return d.trim().split(/[.(]/)[0]?.trim()||d}function c(d){let T=d.decorators.map(N=>a(N.raw)),C={decorators:d.decorators,decoratorNames:T};return d.async===!0&&(C.async=!0),d.accessor&&(C.accessor=d.accessor),d.contextmanager===!0&&(C.contextmanager=!0),JSON.stringify(C)}function m(d,T){return(d.match(new RegExp(`\\${T}`,"g"))||[]).length}function r(d){let T=[],C=d,N=0,O=0,q=0,A=!1;do{let z=s[C].trim();if(T.push(z),N+=m(z,"(")-m(z,")"),O+=m(z,"[")-m(z,"]"),q+=m(z,"{")-m(z,"}"),A=z.endsWith("\\"),C+1>=s.length||N<=0&&O<=0&&q<=0&&!A)break;C+=1}while(!0);return{text:T.join(" "),endIndex:C}}let p=!1,g="",x=[],S=[];for(let d=0;d<s.length;d++){let T=s[d],C=T.trim();if(!C||C.startsWith("#"))continue;let N=/^([a-zA-Z0-9_]+)\s*=\s*(?:APIRouter|Blueprint)\s*\(\s*(?:prefix\s*=\s*)?['"]([^'"]+)['"]/,O=C.match(N);if(O&&(this.currentRoutePrefix=O[2]),p){if(C.endsWith(g)||C.includes(g)){p=!1;let D=C.replace(g,"").trim();D&&x.push(D);let v=l[l.length-1];v.node&&(v.node.doc=x.join(`
|
|
37
|
+
`).trim()),x=[]}else x.push(C);continue}let q=T.search(/\S/),A=T.trim(),z=A.match(/^(['"]{3})/);if(z){let D=z[1],v=l[l.length-1];if(v.node&&!v.node.doc){if(A.substring(3).includes(D)){let k=A.replace(new RegExp(D,"g"),"").trim();v.node.doc=k}else{p=!0,g=D;let k=A.substring(3).trim();k&&x.push(k)}continue}}for(;l.length>1&&l[l.length-1].indent>=q;)l.pop();let W=l[l.length-1],le=W.type==="root"&&q===0;if(le&&/^__all__\s*=/.test(A)){let D=r(d),v=[],k=/['"]([^'"]+)['"]/g,F=null;for(;F=k.exec(D.text);)v.push(F[1]);let j={name:"__all__",kind:"ModuleExports",classification:"ExportList",signature:"__all__ = [...]",line:d+1,endLine:D.endIndex+1,doc:"",capabilities:JSON.stringify({exports:v}),members:[]};S.push(j),i.push(j),d=D.endIndex,f=[];continue}let ge=/^([A-Z][A-Z0-9_]*)(?:\s*:\s*[^=]+)?\s*=/,be=le?A.match(ge):null;if(be){let D=r(d),v=D.text.length>120?`${D.text.slice(0,117)}...`:D.text,k={name:be[1],kind:"VariableDeclaration",classification:"Constant",signature:v,line:d+1,endLine:D.endIndex+1,doc:"",capabilities:"{}",members:[]};S.push(k),i.push(k),d=D.endIndex,f=[];continue}let xe=A.match(u);if(xe){f.push({raw:xe[1].trim(),line:d+1});continue}let pe=A.match(y);if(pe){let D=pe[1],v={name:D,kind:"ClassDeclaration",classification:"Class",signature:`class ${D}`,line:d+1,endLine:d+1,doc:"",capabilities:c({decorators:f}),members:[]};S.push(v),W.node?(W.node.members||(W.node.members=[]),W.node.members.push(v)):i.push(v),l.push({indent:q,name:D,type:"class",node:v}),f=[];continue}let se=A.match(E);if(se){let D=!!se[1],v=se[1]||se[2],k=W.type==="class",F=f.some(P=>/(?:^|\.)contextmanager$/.test(P.raw.trim())),j;f.some(P=>P.raw.trim()==="property")&&(j="getter");for(let P of f){let $=P.raw.trim().match(/^[a-zA-Z_][a-zA-Z0-9_]*\.(setter|deleter)$/);if($){j=$[1];break}}let H=!1,X={};for(let P of f)if(P.raw.match(/(?:app|router)\.(get|post|put|delete|patch|websocket)/)){H=!0;let Y=["get","post","put","delete","patch","websocket"].find(ee=>P.raw.toLowerCase().includes(`.${ee}`))?.toUpperCase()||"GET",oe=P.raw.match(/['"]([^'"]+)['"]/),K=oe?oe[1]:"/";if(this.currentRoutePrefix){let ee=this.currentRoutePrefix.endsWith("/")?this.currentRoutePrefix.slice(0,-1):this.currentRoutePrefix,de=K.startsWith("/")?K:`/${K}`;K=ee+de}X={type:"route",method:Y,path:K}}if(H){let P=X.path||"",$=X.method==="WEBSOCKET",Y={name:P||v,kind:$?"WebSocket Route":"HTTP Route",classification:"Service Boundary",signature:`Function: ${v}`,line:d+1,endLine:d+1,doc:"",capabilities:JSON.stringify({handler:k?`${W.name}.${v}`:v,async:D,...X})};S.push(Y),i.push(Y),e.push({type:$?"websocket_route":"api_route",name:P,direction:"consume",line:d+1,snippet:A})}for(let P of f){let $=P.raw.match(/(?:^|\.)receiver\s*\(\s*([a-zA-Z0-9_.]+)/);$&&e.push({type:"signal",name:$[1].split(".").pop()||$[1],direction:"consume",line:P.line,snippet:`@${P.raw}`})}let ue=f.some(P=>P.raw==="staticmethod"),ae=f.some(P=>P.raw==="classmethod"),me=`${D?"async ":""}${k?(ue?"@staticmethod ":ae?"@classmethod ":"")+W.name+".":""}${v}`,fe=!!j,Q={name:v,kind:fe?"PropertyDeclaration":D&&k?"AsyncMethodDeclaration":D?"AsyncFunctionDeclaration":k?"MethodDeclaration":"FunctionDeclaration",classification:fe?"Property":k?ue||ae?"Static Method":"Method":"Function",signature:me,line:d+1,endLine:d+1,doc:"",capabilities:c({decorators:f,async:D,accessor:j,contextmanager:F}),members:[]};S.push(Q),W.node?(W.node.members||(W.node.members=[]),W.node.members.push(Q)):i.push(Q),l.push({indent:q,name:v,type:"function",node:Q}),f=[];continue}let we=/^(?:path|re_path|url)\s*\(\s*['"]([^'"]+)['"]/,re=A.match(we);if(re){let D=re[1].replace(/^\^/,""),v={name:D,kind:"HTTP Route",classification:"Service Boundary",signature:A.trim(),line:d+1,endLine:d+1,doc:"",capabilities:JSON.stringify({type:"route",method:"GET",path:D})};S.push(v),i.push(v),e.push({type:"api_route",name:D,direction:"consume",line:d+1,snippet:A});continue}let b=/(?:requests|httpx|client|http)\.(get|post|put|delete|patch|request)\s*\(\s*(?:url\s*:\s*)?([^,)]+)/,h=A.match(b);if(h){let D=h[1].toUpperCase(),v=h[2].trim();(v.startsWith("'")&&v.endsWith("'")||v.startsWith('"')&&v.endsWith('"'))&&(v=v.substring(1,v.length-1)),e.push({type:"api_route",name:v,direction:"produce",line:d+1,snippet:A,method:D,url:v})}let _=A.match(o);if(_){let D=_[1]||_[2],v={name:D,kind:"ImportSpecifier",classification:"Dependency",signature:`import ${D}`,line:d+1,endLine:d+1,doc:"",capabilities:JSON.stringify({type:"import",module:D})};S.push(v),i.push(v),f=[];continue}f=[],W.node&&(W.node.endLine=d+1)}return{nodes:S,events:e}}};function Et(n,t){let i=0,e=!1;for(let s=t;s<n.length;s++){let l=n[s];for(let f of l)if(f==="{")i++,e=!0;else if(f==="}"&&(i--,e&&i<=0))return s+1;if(!e&&s>t&&/[;}]$/.test(l.trim()))return s+1}return Math.min(n.length,t+41)}var st=[{extension:[".php"],rules:[]},{extension:[".py"],rules:[]},{extension:[".go"],rules:[{regex:/func\s+([a-zA-Z0-9_]+)\(/g,onMatch:n=>({name:n[1],kind:"FunctionDeclaration",classification:"Function",signature:n[0]})},{regex:/func\s+\([^)]+\)\s+([a-zA-Z0-9_]+)\(/g,onMatch:n=>({name:n[1],kind:"MethodDeclaration",classification:"Method",signature:n[0]})},{regex:/import\s+['"]([^'"]+)['"]/g,onMatch:n=>({name:n[1],kind:"ImportSpecifier",classification:"Dependency",signature:n[0],meta:{type:"import",path:n[1]}})}]},{extension:[".rs"],rules:[{regex:/fn\s+([a-zA-Z0-9_]+)\s*\(/g,onMatch:n=>({name:n[1],kind:"FunctionDeclaration",classification:"Function",signature:n[0]})},{regex:/struct\s+([a-zA-Z0-9_]+)/g,onMatch:n=>({name:n[1],kind:"StructDeclaration",classification:"Class",signature:n[0]})},{regex:/enum\s+([a-zA-Z0-9_]+)/g,onMatch:n=>({name:n[1],kind:"EnumDeclaration",classification:"Class",signature:n[0]})},{regex:/trait\s+([a-zA-Z0-9_]+)/g,onMatch:n=>({name:n[1],kind:"TraitDeclaration",classification:"Class",signature:n[0]})},{regex:/use\s+([a-zA-Z0-9_:]+(?:\s+as\s+[a-zA-Z0-9_]+)?);/g,onMatch:n=>({name:n[1].trim(),kind:"ImportDeclaration",classification:"Dependency",signature:n[0],meta:{type:"import",path:n[1].trim()}})}]},{extension:[".ts",".tsx",".js",".jsx",".mjs",".cjs"],rules:[{regex:/(?:export\s+)?(?:async\s+)?function\s+([a-zA-Z0-9_]+)\s*\(/g,onMatch:n=>({name:n[1],kind:"FunctionDeclaration",classification:"Function"})},{regex:/(?:export\s+)?class\s+([a-zA-Z0-9_]+)/g,onMatch:n=>({name:n[1],kind:"ClassDeclaration",classification:"Class"})},{regex:/(?:export\s+)?interface\s+([a-zA-Z0-9_]+)/g,onMatch:n=>({name:n[1],kind:"InterfaceDeclaration",classification:"Interface"})},{regex:/(?:export\s+)?const\s+([a-zA-Z0-9_]+)\s*=/g,onMatch:n=>({name:n[1],kind:"VariableDeclaration",classification:"Constant"})},{regex:/import\s+.*\s+from\s+['"]([^'"]+)['"]/g,onMatch:n=>({name:n[1],kind:"ImportDeclaration",classification:"Dependency",meta:{path:n[1]}})}]}];function Tt(n,t){let i=[];if(n===".go"&&t.some(e=>e.kind==="TypeDeclaration")&&i.push("Go type"),n===".rs"&&(t.some(e=>e.kind==="TraitDeclaration")&&i.push("Rust trait"),t.some(e=>e.kind==="StructDeclaration")&&i.push("Rust struct"),t.some(e=>e.kind==="EnumDeclaration")&&i.push("Rust enum")),n===".py"){for(let e of t)if(e.capabilities)try{if(JSON.parse(e.capabilities).decoratorNames?.length){i.push("Python decorators");break}}catch{}t.some(e=>e.kind==="AsyncFunctionDeclaration"||e.kind==="AsyncMethodDeclaration")&&i.push("Async")}return i}var Te=class{phpParser=new Ce;pythonParser=new Ee;treeSitterParser=new Re;supports(t){return st.some(i=>i.extension.includes(t.toLowerCase()))}async parse(t,i){let e=Le.extname(t).toLowerCase(),s=[],l=[];if(e===".php"||e===".py"||e===".go"||e===".rs"){if(e===".py"){let o=this.pythonParser.parse(i);s=o.nodes,l=o.events}else if(e===".php"){let o=t.toLowerCase().endsWith("api.php"),u=this.phpParser.parse(i,o);s=u.nodes,l=u.events}else try{s=await this.treeSitterParser.parse(t,i)}catch{}if(s.length>0){let o=e===".php"?"Micro IR (PHP/TS) ":e===".py"?"Micro IR (Python/TS) ":e===".go"?"Micro IR (Go/TS) ":"Micro IR (Rust/TS) ",u=s.filter(r=>r.classification!=="Dependency"),a=s.filter(r=>r.classification==="Dependency"),c=Tt(e,s),m=ye({classification:o,capabilities:c,exports:u.map(r=>({name:r.name,kind:r.kind,classification:r.classification})),fileName:Le.basename(t)});return{exports:u,imports:a.map(r=>({module:r.name,name:r.name,kind:r.kind,classification:r.classification})),events:l,classification:o,summary:m||`${e.substring(1).toUpperCase()} module`,parseStatus:"success"}}}let f=st.find(o=>o.extension.includes(e));if(!f)return{exports:[],imports:[],classification:"Unknown",summary:"",parseStatus:"failed",parseError:`Unsupported file extension: ${e}`};let y=i.split(`
|
|
38
|
+
`);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=Et(y,c-1);s.push({name:a.name||"anonymous",kind:a.kind||"Unknown",classification:a.classification||"Other",signature:a.signature||u[0],line:c,endLine:m,doc:"",capabilities:JSON.stringify(a.meta||{})})}}let E=ye({classification:`Micro IR (${e.substring(1).toUpperCase()})`,capabilities:[],exports:s.map(o=>({name:o.name,kind:o.kind,classification:o.classification})),fileName:Le.basename(t)});return{exports:s,imports:[],classification:`Micro IR (${e.substring(1).toUpperCase()})`,summary:E||"Module",parseStatus:s.length>0?"success":"partial"}}};function rt(n){let t=new Set;function i(e){if(!(!e||typeof e!="object")){e.typeAnnotation&&I(e.typeAnnotation,t),(e.type==="TsTypeReference"||e.type==="TsTypeAnnotation")&&I(e,t);for(let s in e){if(s==="span"||s==="comments"||s==="interpreter")continue;let l=e[s];l&&typeof l=="object"&&(Array.isArray(l)?l.forEach(i):i(l))}}}return n.forEach(e=>i(e)),Array.from(t)}function I(n,t){if(n){if(n.type==="TsTypeAnnotation"){I(n.typeAnnotation,t);return}n.type==="TsTypeReference"&&(n.typeName?.type==="Identifier"&&t.add(n.typeName.value),n.typeName?.type==="TsQualifiedName"&&at(n.typeName,t),n.typeParams&&I(n.typeParams,t)),n.type==="TsArrayType"&&I(n.elementType,t),n.type==="TsUnionType"&&n.types?.forEach(i=>I(i,t)),n.type==="TsIntersectionType"&&n.types?.forEach(i=>I(i,t)),n.type==="TsTupleType"&&n.elemTypes?.forEach(i=>I(i.ty,t)),(n.type==="TsFunctionType"||n.type==="TsConstructorType")&&(n.params?.forEach(i=>I(i.typeAnnotation,t)),n.typeAnnotation&&I(n.typeAnnotation,t)),n.type==="TsTypeParameterDeclaration"&&n.params?.forEach(i=>{i.constraint&&I(i.constraint,t),i.default&&I(i.default,t)}),n.type==="TsTypeParameterInstantiation"&&n.params?.forEach(i=>I(i,t)),n.type==="TsMappedType"&&n.typeAnnotation&&I(n.typeAnnotation,t),n.type==="TsIndexedAccessType"&&(I(n.objectType,t),I(n.indexType,t)),n.type==="TsConditionalType"&&(I(n.checkType,t),I(n.extendsType,t),I(n.trueType,t),I(n.falseType,t)),n.type==="TsTypeLiteral"&&n.members?.forEach(i=>{i.typeAnnotation&&I(i.typeAnnotation,t)})}}function at(n,t){n.type==="TsQualifiedName"?(n.left&&at(n.left,t),n.right?.value&&t.add(n.right.value)):n.type==="Identifier"&&t.add(n.value)}var Ne=new Te;async function vn(n){let t=ct.extname(n);if(Ne.supports(t)&&t!==".ts"&&t!==".tsx")try{let l=await ot.promises.readFile(n,"utf-8");return{...await Ne.parse(n,l),content:l}}catch(l){return ne.error({filePath:n,error:l.message},"HeuristicParser failed"),{exports:[],imports:[],classification:"Unknown",summary:"",content:"",parseStatus:"failed",parseError:l.message}}let i;try{i=await ot.promises.readFile(n)}catch(l){return{exports:[],imports:[],classification:"Error",summary:"",content:"",parseStatus:"failed",parseError:`File read error: ${l.message}`}}let e=i.toString("utf8"),s=Ue(e);try{let l=n.endsWith(".tsx"),f=n.endsWith(".d.ts")||n.endsWith(".d.tsx"),y,E={syntax:"typescript",tsx:l,decorators:!0,comments:!0};if(f)try{y=Se(e,E)}catch{y=Se(e,{...E,isModule:!1})}else y=Se(e,E);let o=y.span.start,u=Ve(i),a=qe(e),c=C=>Ge(C,o,i),m=Ke(y.body),r=rt(y.body);r.length>0&&ne.debug({filePath:n,count:r.length},"Extracted type references"),r.forEach(C=>{m.push({module:"__type_reference__",name:C})});let p=Qe(y.body,o,i,e,s,a,n,c,u),g=Xe(y.body,o,i,s,c,u),x=ve(n,"","Module"),d=a.length>0&&e.slice(0,a[0].start).trim().length===0?a[0].text:p.find(C=>C.doc)?.doc||"",T=He(d);if(!T&&p.length>0){let C=ce(e);T=ye({classification:x,capabilities:C,exports:p.map(N=>({name:N.name,kind:N.kind,classification:N.classification})),fileName:ct.basename(n)})}return{exports:p,imports:m,events:g,classification:x,summary:T,content:e,parseStatus:"success"}}catch(l){ne.warn({filePath:n,error:l.message},"SWC parsing failed, using heuristic fallback");try{let f=await Ne.parse(n,e);return{...f,content:e,classification:f.classification+" (Degraded)",parseStatus:"partial",parseError:`SWC failed, used heuristic fallback: ${l.message}`}}catch(f){return ne.error({filePath:n,error:f.message},"All parsing strategies failed"),{exports:[],imports:[],classification:"Error",summary:"",content:e,parseStatus:"failed",parseError:`All parsing strategies failed: ${f.message}`}}}}export{vn as parseFile};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{existsSync as n}from"node:fs";import{dirname as d,join as c}from"node:path";import{fileURLToPath as f}from"node:url";import{parentPort as i}from"node:worker_threads";var l=f(import.meta.url),a=d(l),t=null;async function p(){if(t)return t;let e,r=c(a,"index.ts"),s=c(a,"index.js");if(n(r)&&l.endsWith(".ts"))e=r;else if(n(s))e=s;else throw new Error(`Cannot find parser module in ${a}`);return t=(await import(e)).parseFile,t}async function g(e){if(e.type==="shutdown"&&process.exit(0),e.type==="parse")try{let s=await(await p())(e.filePath),o={type:"result",id:e.id,result:s};i?.postMessage(o)}catch(r){let s={type:"error",id:e.id,error:r instanceof Error?r.message:String(r)};i?.postMessage(s)}}async function y(){await p();let e={type:"ready"};i?.postMessage(e),i?.on("message",r=>{g(r).catch(s=>{console.error("Parser worker error:",s)})})}y().catch(e=>{console.error("Failed to initialize parser worker:",e),process.exit(1)});
|
|
@@ -1,43 +1,35 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: audit
|
|
3
|
-
description:
|
|
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
|
-
#
|
|
6
|
+
# Audit
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Use this skill when the goal is repository health, not feature delivery.
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Start
|
|
11
11
|
|
|
12
|
-
1.
|
|
13
|
-
2.
|
|
14
|
-
3.
|
|
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
|
-
##
|
|
16
|
+
## Add depth only when needed
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
##
|
|
25
|
+
## Close the loop
|
|
34
26
|
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
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
|
-
##
|
|
31
|
+
## Rules
|
|
40
32
|
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
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:
|
|
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
|
-
#
|
|
6
|
+
# Chronicle
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Use this skill when the answer lives in mission history rather than the current code graph.
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Core calls
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
##
|
|
18
|
+
## Good pairings
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
| **Recent (Markdown)** | `shadow_ops_chronicle` (limit: 10, format: "markdown") |
|
|
24
|
-
| **Time Range** | `shadow_ops_chronicle` (since: <unix>, until: <unix>) |
|
|
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
|
-
##
|
|
23
|
+
## Notes
|
|
29
24
|
|
|
30
|
-
-
|
|
31
|
-
-
|
|
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
|
-
|
|
6
|
+
# Continue
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Pick one mission from `next_work_candidates` and finish it end to end.
|
|
9
9
|
|
|
10
|
-
##
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
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`.
|