codebaseiq 0.3.0 → 0.3.1
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/CHANGELOG.md +15 -0
- package/dist/{chunk-BFBIMTCJ.js → chunk-2XBJRZEM.js} +2 -2
- package/dist/{chunk-GDHWOA57.js → chunk-2Z7K66D7.js} +2 -2
- package/dist/{chunk-HVFB3PME.js → chunk-3H2H5ODK.js} +2 -2
- package/dist/{chunk-LZSQ6X7E.js → chunk-3LQJRS4I.js} +2 -2
- package/dist/{chunk-GIDCP7KV.js → chunk-3ON3A2QV.js} +2 -2
- package/dist/{chunk-TPO7XC5Z.js → chunk-4GWN76B2.js} +2 -2
- package/dist/{chunk-GL6UTNUB.js → chunk-53ELMZRF.js} +2 -2
- package/dist/{chunk-6VREELBC.js → chunk-57OPIQFM.js} +2 -2
- package/dist/{chunk-JSNTHRLQ.js → chunk-5CR4U5X2.js} +2 -2
- package/dist/{chunk-GUFPEFBG.js → chunk-5MPBSFZH.js} +2 -2
- package/dist/{chunk-K7JLSGCJ.js → chunk-5TZNHP4T.js} +3 -3
- package/dist/{chunk-DVWO7RBC.js → chunk-5YBDBY5L.js} +2 -2
- package/dist/{chunk-T5X7DK6C.js → chunk-6EYESTJM.js} +2 -2
- package/dist/{chunk-AQI4N64O.js → chunk-6FXXYYQM.js} +2 -2
- package/dist/{chunk-VWYGCMV5.js → chunk-AGGR2BKS.js} +2 -2
- package/dist/{chunk-FEIZXBLH.js → chunk-ALOEHWJS.js} +2 -2
- package/dist/{chunk-D53LWANR.js → chunk-AXQCHG77.js} +2 -2
- package/dist/{chunk-7JELP5YE.js → chunk-BFANZRQ5.js} +2 -2
- package/dist/{chunk-5IZRKWTZ.js → chunk-BGYRF5YX.js} +2 -2
- package/dist/{chunk-5IC2WZAL.js → chunk-BIADXGC3.js} +2 -2
- package/dist/{chunk-HENP2O4A.js → chunk-BPKNP3KZ.js} +2 -2
- package/dist/{chunk-GP7C5VAE.js → chunk-CB5AVJMM.js} +2 -2
- package/dist/{chunk-HQA7EBSK.js → chunk-CJTKGAGH.js} +2 -2
- package/dist/{chunk-JLZLLLW5.js → chunk-CLPCFGRT.js} +2 -2
- package/dist/{chunk-EXZ7VLRY.js → chunk-CSPDQLLU.js} +2 -2
- package/dist/{chunk-AEXQYQD7.js → chunk-CYJS33YX.js} +2 -2
- package/dist/{chunk-AURCQHSG.js → chunk-DDRA3QKN.js} +2 -2
- package/dist/{chunk-3RSBGWGL.js → chunk-DECN422G.js} +2 -2
- package/dist/{chunk-3RR2K7EZ.js → chunk-DJKOXMNG.js} +2 -2
- package/dist/{chunk-PFC44E6D.js → chunk-DWBAESVW.js} +2 -2
- package/dist/{chunk-FQTIFWLR.js → chunk-EHPOTEQX.js} +2 -2
- package/dist/{chunk-NBCQZSGR.js → chunk-ELYMY5S2.js} +2 -2
- package/dist/{chunk-FTTV7IRX.js → chunk-EOKVZXNF.js} +42 -42
- package/dist/{chunk-HINZQKSY.js → chunk-F5CJO5JN.js} +2 -2
- package/dist/{chunk-SMDIEDM4.js → chunk-G7GVV2TV.js} +2 -2
- package/dist/{chunk-67VJAYVR.js → chunk-HJTM3C4Y.js} +2 -2
- package/dist/{chunk-I22IZYDI.js → chunk-HNXRVGMY.js} +2 -2
- package/dist/{chunk-NCJILOAK.js → chunk-I3OK27P7.js} +2 -2
- package/dist/{chunk-FWQGH2N2.js → chunk-ILGTMRMZ.js} +2 -2
- package/dist/{chunk-DDN2F6GB.js → chunk-JAFDMV5I.js} +2 -2
- package/dist/{chunk-LONKINMJ.js → chunk-JNXI6NQ7.js} +2 -2
- package/dist/{chunk-6BF3VYEF.js → chunk-JSB43EX6.js} +2 -2
- package/dist/chunk-JYRJYXUV.js +2 -0
- package/dist/chunk-K4S2VH42.js +82 -0
- package/dist/{chunk-75KJGYX7.js → chunk-K6FNTQQW.js} +2 -2
- package/dist/{chunk-XQPPURLQ.js → chunk-KEJ2HLRW.js} +2 -2
- package/dist/{chunk-D7AZAOZX.js → chunk-KFTHI2R6.js} +2 -2
- package/dist/{chunk-J3GLP7Q5.js → chunk-KLX6NSWT.js} +2 -2
- package/dist/{chunk-TJBOJUVN.js → chunk-KUKKLWJD.js} +2 -2
- package/dist/{chunk-2EDX3JT5.js → chunk-KUKWHP4R.js} +2 -2
- package/dist/{chunk-JFIA2JI3.js → chunk-KWRQVLPX.js} +2 -2
- package/dist/{chunk-5DSL3NT2.js → chunk-L37EQYAX.js} +2 -2
- package/dist/{chunk-ITSJMNUD.js → chunk-LCW3PSGL.js} +2 -2
- package/dist/{chunk-2PRONPAS.js → chunk-LSZYMN2A.js} +2 -2
- package/dist/{chunk-Q23IMHXS.js → chunk-MC46AL7B.js} +2 -2
- package/dist/{chunk-JYI7CV25.js → chunk-MDFT325O.js} +2 -2
- package/dist/{chunk-CVHOQONG.js → chunk-N2XDMNVI.js} +2 -2
- package/dist/chunk-NNG6M6XD.js +3 -0
- package/dist/{chunk-MVRGB4KJ.js → chunk-O2KWU34K.js} +2 -2
- package/dist/{chunk-USOAJHY7.js → chunk-OBC7HSSO.js} +2 -2
- package/dist/{chunk-RIYJ4L33.js → chunk-OKAF4OQS.js} +2 -2
- package/dist/{chunk-GQXXOS55.js → chunk-OP6BUIV6.js} +2 -2
- package/dist/{chunk-23C5AD3B.js → chunk-OQ3DK7FW.js} +2 -2
- package/dist/chunk-OT5ISJSR.js +2 -0
- package/dist/{chunk-C7QWUBR2.js → chunk-OWJWOEDU.js} +2 -2
- package/dist/{chunk-RJVAPMHF.js → chunk-PIFYOWS4.js} +2 -2
- package/dist/{chunk-CR3OG6SQ.js → chunk-PTR3EOXC.js} +2 -2
- package/dist/{chunk-NBZKSTXP.js → chunk-QY7QB7I6.js} +2 -2
- package/dist/{chunk-Q3ZCQY2Y.js → chunk-R4OJGTMP.js} +2 -2
- package/dist/{chunk-UQE4XFSA.js → chunk-RIO3JXHM.js} +2 -2
- package/dist/{chunk-CW6AXOLR.js → chunk-SA7G6GJX.js} +2 -2
- package/dist/{chunk-Q4XEU3UH.js → chunk-SB53KPWA.js} +2 -2
- package/dist/{chunk-36JC5BG2.js → chunk-SUE7SHZL.js} +2 -2
- package/dist/{chunk-ZAFGY22Q.js → chunk-SZ4P7MF7.js} +2 -2
- package/dist/{chunk-BBP7HVBJ.js → chunk-T2M5HWBQ.js} +2 -2
- package/dist/{chunk-MHWMEZDA.js → chunk-TEMM2FEL.js} +2 -2
- package/dist/{chunk-JX6ZWDOS.js → chunk-TLTSESB4.js} +2 -2
- package/dist/{chunk-FOZ74V56.js → chunk-UIAUPFBJ.js} +2 -2
- package/dist/{chunk-PHNCEUXX.js → chunk-UJIXCI3L.js} +2 -2
- package/dist/{chunk-XMJ53WG4.js → chunk-UMEPSVKT.js} +2 -2
- package/dist/{chunk-GWYZVVKY.js → chunk-V4NGDIEA.js} +2 -2
- package/dist/{chunk-E52K4L2W.js → chunk-VSGOIZMQ.js} +2 -2
- package/dist/{chunk-Z6RL7XOE.js → chunk-W7QDASTN.js} +2 -2
- package/dist/{chunk-PTQPPPG2.js → chunk-WO6OFKUC.js} +2 -2
- package/dist/{chunk-C7OUW52M.js → chunk-XJBK3QDV.js} +2 -2
- package/dist/{chunk-FH5WG4LE.js → chunk-XUPFA6GH.js} +2 -2
- package/dist/{chunk-DAKIGMIK.js → chunk-YPBKBYPS.js} +2 -2
- package/dist/{chunk-ZQ62NNKN.js → chunk-Z66XYVLZ.js} +2 -2
- package/dist/{chunk-OFGOOL6U.js → chunk-ZMA5HWXY.js} +2 -2
- package/dist/{cli-program-UO7PZD6V.js → cli-program-SCHOHOQE.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{code-viewer-VHLBLIUM.js → code-viewer-AMRXV444.js} +2 -2
- package/dist/{code-viewer-KIXEYQNJ.js → code-viewer-EXI5SFFR.js} +2 -2
- package/dist/{command-descriptors-F5P2V3NW.js → command-descriptors-H6A4UY72.js} +3 -3
- package/dist/{command-descriptors-YCLATF5I.js → command-descriptors-ROIOTCCW.js} +3 -3
- package/dist/direct-navigation-3JOYP2MO.js +3 -0
- package/dist/direct-navigation-SJMJLBY7.js +2 -0
- package/dist/index.js +1 -1
- package/dist/invocation-command-descriptors-GMZX3UAD.js +2 -0
- package/dist/invocation-command-descriptors-HNMKDEF6.js +3 -0
- package/dist/{output-continuation-command-BTETTXEC.js → output-continuation-command-5NWVDQT7.js} +2 -2
- package/dist/output-continuation-command-RNEHNYPU.js +3 -0
- package/dist/project-reindex-MIW5CYEG.js +3 -0
- package/dist/{project-reindex-CRJU3IFG.js → project-reindex-VQ23LWDA.js} +2 -2
- package/dist/queries/affected.js +1 -1
- package/dist/queries/anchors.js +1 -1
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/context.js +1 -1
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/dependence-slice.js +1 -1
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/drift.js +1 -1
- package/dist/queries/entry-map.js +1 -1
- package/dist/queries/evidence.js +1 -1
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/health.js +1 -1
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/reference-neighborhood.js +1 -1
- package/dist/queries/reference-reachability.js +1 -1
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.js +1 -1
- package/dist/queries/source-inspection.js +1 -1
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/surface.js +1 -1
- package/dist/queries/system-map.js +1 -1
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/value-flow.js +1 -1
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +1 -1
- package/dist/reindex.js +1 -1
- package/dist/runtime.js +1 -1
- package/dist/rust-semantic-session-server.js +1 -1
- package/dist/rust-semantic-session-worker.js +1 -1
- package/dist/rust-semantic-worker.js +1 -1
- package/dist/{sentinel-ensure-command-SPW7XQLB.js → sentinel-ensure-command-H66AZ3VE.js} +2 -2
- package/dist/sentinel-ensure-command-R4YAUCJB.js +3 -0
- package/dist/watch-server.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-6JMAVFL4.js +0 -3
- package/dist/chunk-6WAPPQ5F.js +0 -82
- package/dist/chunk-P4NVCOM7.js +0 -2
- package/dist/chunk-Z35GOVEH.js +0 -2
- package/dist/direct-navigation-4XJTXIDT.js +0 -2
- package/dist/direct-navigation-J5MVYYAD.js +0 -3
- package/dist/invocation-command-descriptors-RWV4VAI4.js +0 -2
- package/dist/invocation-command-descriptors-U76PN7IY.js +0 -3
- package/dist/output-continuation-command-BL25S26S.js +0 -3
- package/dist/project-reindex-TQFCOA2O.js +0 -3
- package/dist/sentinel-ensure-command-OSWGCFFL.js +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as C,b as x,c as K,d as $}from"./chunk-
|
|
1
|
+
import{a as C,b as x,c as K,d as $}from"./chunk-QY7QB7I6.js";import{a as A}from"./chunk-DGXRDLV5.js";import{b as L,c as R}from"./chunk-BPKNP3KZ.js";import{a as y}from"./chunk-BGBBVSH4.js";import{h as M}from"./chunk-NDKOVQFG.js";import{a as k}from"./chunk-BRQL7AFJ.js";import{b as F,d as P,e as g}from"./chunk-GVAF222T.js";import{l as T}from"./chunk-F74LZWCE.js";import{w as I}from"./chunk-7GAK2F3H.js";function me(t,e){let{scope:n,minLoc:i=3,maxLoc:s=80,limit:a=30,includeLowConfidence:c=!1,scanLimit:o}=e??{},f=e?.semantic!==!1,r=new R(t),d=r.scopedDefinitions(n),b=Q(r,n),l={high:0,medium:1,low:2};return A({candidates:()=>U(t,r,d,{minLoc:i,maxLoc:s}),orderCandidates:(u,m)=>y(m)-y(u)||u.relativePath.localeCompare(m.relativePath),scanLimit:o,profile:{name:"stale-abstractions"},prepare:u=>{let m=W(u),p=O(t,r,u,m,{semantic:f}),S=u.filter(h=>{if(p.incompleteSymbolIds.has(h.symbolId)||p.unavailableSymbolIds.has(h.symbolId)||r.hasSuppressionComment(h))return!1;let D=v(t,h,p.consumerFileMap,m);return D.realConsumers.length<=1&&!D.transitivelyReachable&&j(h,D.realConsumers.length,b)});return{...p,singletonBackedClassIds:H(t,r,d,S,{semantic:f}),candidateIndex:m}},evaluate:(u,m)=>{if(m.incompleteSymbolIds.has(u.symbolId)||m.unavailableSymbolIds.has(u.symbolId)||r.hasSuppressionComment(u)||m.singletonBackedClassIds.has(u.symbolId))return null;let p=v(t,u,m.consumerFileMap,m.candidateIndex);if(p.transitivelyReachable||p.realConsumers.length>1||p.realConsumers.length===0&&p.barrelConsumers>0||!j(p.definition,p.realConsumers.length,b))return null;let S=V(t,p);return!c&&S.confidence==="low"?null:S},orderResults:(u,m)=>l[u.confidence]-l[m.confidence]||m.loc-u.loc||u.file.localeCompare(m.file)||u.startLine-m.startLine,limit:a})}function U(t,e,n,i){return n.filter(s=>s.isTypeLike&&y(s)>=i.minLoc).filter(s=>y(s)<=i.maxLoc).filter(s=>!t.isIgnored(s.relativePath)).filter(s=>!s.relativePath.endsWith(".d.ts")).filter(s=>k(s.relativePath)!=="test").filter(s=>!M(t,s.symbol,s.relativePath)).filter(s=>!X(s.symbol))}function B(t,e,n,i){return x(C(t,e).forDefinitions(n,{semantic:i.semantic,sourceFallback:i.sourceFallback}))}function O(t,e,n,i,s){let a=B(t,e,n,{semantic:!1,sourceFallback:!1}),c=n.filter(l=>{let u=v(t,l,a,i);return u.realConsumers.length<=1&&!(u.realConsumers.length>0&&w(l.relativePath))}),o=C(t,e).forDefinitions(c,{semantic:s.semantic,sourceFallback:!1}),f=new Set([...o.values()].filter(l=>l.semanticIncomplete).map(l=>l.definition.symbolId)),r=new Set([...o.values()].filter(l=>l.semanticUnavailable).map(l=>l.definition.symbolId)),d=s.semantic&&c.length>0?L(a,x(o)):a,b=c.filter(l=>v(t,l,d,i).realConsumers.length<=1);return{consumerFileMap:L(d,B(t,e,b,{semantic:!1,sourceFallback:!0})),incompleteSymbolIds:f,unavailableSymbolIds:r}}function W(t){let e=new Map;for(let n of t){let i=e.get(n.relativePath);i||(i=new Map,e.set(n.relativePath,i));let s=g(n.symbol);s&&i.set(s,n)}return e}function v(t,e,n,i){let a=[...n.get(e.symbolId)??new Set].filter(d=>d!==e.relativePath&&!t.isIgnored(d)),{realConsumers:c,barrelConsumers:o,importOnlyConsumers:f}=K(t,e,a),r=Y(t,e,n,i);return{definition:e,realConsumers:c,barrelConsumers:o+f,transitivelyReachable:r}}function V(t,e){let n=N(t,e.definition.relativePath,e.definition.startLine),i=w(e.definition.relativePath)?!0:ee(t,e.definition),{confidence:s,reason:a}=ne(e.realConsumers.length,n,i),c=z(e.realConsumers.length,n,i);return{symbol:e.definition.symbol,shortName:P(e.definition.symbol),file:e.definition.relativePath,startLine:e.definition.startLine,endLine:e.definition.endLine,loc:y(e.definition),consumers:e.realConsumers.length,barrelConsumers:e.barrelConsumers,kind:n,definerUsesType:i,confidence:s,reason:a,actionTier:c.actionTier,stalenessKind:c.stalenessKind,recommendation:c.recommendation}}function z(t,e,n){return t===0?{actionTier:"direct",stalenessKind:"unused-abstraction",recommendation:"Delete the abstraction or wire the missing consumer after checking public/package surfaces."}:e==="class"?{actionTier:"signal",stalenessKind:"one-to-one-class-encapsulation",recommendation:"Treat as weak signal: a one-consumer class may be intentional encapsulation, so inline only after reviewing ownership and state boundaries."}:n?{actionTier:"signal",stalenessKind:"single-consumer-abstraction",recommendation:"Review whether this single-consumer abstraction earns its name or should be folded into the owning feature."}:{actionTier:"signal",stalenessKind:"misplaced-single-consumer-type",recommendation:"Review moving or co-locating the type with its only real consumer; keep it here only if this file owns the public contract."}}function H(t,e,n,i,s){let a=_(t,Z(n),i),c=a.map(d=>d.singleton);if(a.length===0)return new Set;let o=C(t,e).forDefinitions(c,{semantic:s.semantic,sourceFallback:!0}),f=x(o),r=new Set;for(let{singleton:d,classId:b}of a){let l=o.get(d.symbolId);(l?.semanticIncomplete||l?.semanticUnavailable||G(t,d,f))&&r.add(b)}return r}function Z(t){let e=new Map;for(let n of t){let i=g(n.symbol);i&&e.set(E(n.relativePath,i),n)}return e}function _(t,e,n){let i=[];for(let s of n){let a=q(t,e,s);a&&i.push({singleton:a,classId:s.symbolId})}return i}function q(t,e,n){if(N(t,n.relativePath,n.startLine)!=="class")return null;let i=g(n.symbol);if(!i)return null;let s=J(t,n.relativePath,i);return s?e.get(E(n.relativePath,s))??null:null}function G(t,e,n){let i=g(e.symbol),s=n.get(e.symbolId);return!i||!s?!1:[...s].some(a=>a!==e.relativePath&&!t.isIgnored(a)&&!$(t,a,i))}function E(t,e){return`${t}\0${e}`}function J(t,e,n){let i=I(t,e);if(!i)return null;let s=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`\\bexport\\s+const\\s+([A-Za-z_$][\\w$]*)\\s*=\\s*new\\s+${s}\\s*\\(`);return i.match(a)?.[1]??null}function Q(t,e){return new Set(t.scopedDefinitions(e).filter(n=>n.isFunctionLike).map(n=>n.relativePath))}function X(t){let e=F(t);if("kind"in e)return!1;let n=e.descriptors;if(n.length<2)return!1;let i=n[n.length-1],s=n[n.length-2];return i?.suffix==="type"&&s?.suffix==="type"}function w(t){let n=(t.split("/").pop()??"").replace(/\.[^.]+$/,"");return!!(n==="types"||n.endsWith("-types")||n==="models"||n==="schema"||n==="common"||n==="protocol"||n==="proto"||n==="dto"||n==="mod"||n==="contracts"||/(^|\/)types(\/|\.)/.test(t)||/(^|\/)models?(\/|\.)/.test(t)||/(^|\/)proto(?:col)?(\/|\.)/.test(t)||/(^|\/)schema(\/|\.)/.test(t)||/(^|\/)contracts?(\/|\.)/.test(t))}function j(t,e,n){return!(w(t.relativePath)&&e>0||e===0&&n.has(t.relativePath))}function Y(t,e,n,i){let s=T(t,e.relativePath),a=g(e.symbol);if(!a)return!1;let c=i.get(e.relativePath);if(!c)return!1;let o=[...s.get(a)??[]],f=new Set;for(;o.length>0;){let r=o.pop();if(f.has(r))continue;f.add(r);let d=c.get(r);if(!d)continue;let b=n.get(d.symbolId);if(b){for(let l of b)if(l!==e.relativePath&&!t.isIgnored(l))return!0}for(let l of s.get(r)??[])o.push(l)}return!1}function N(t,e,n){let i=I(t,e);if(!i)return"other";let s=i.split(`
|
|
2
2
|
`),a=Math.max(0,n-2),c=Math.min(s.length-1,n+2);for(let o=a;o<=c;o++){let r=(s[o]??"").replace(/^\s*\/\/.*$/g,"");if(/\b(?:export\s+)?(?:abstract\s+)?class\s+\w/.test(r))return"class";if(/\b(?:export\s+)?interface\s+\w/.test(r))return"interface";if(/\b(?:export\s+)?type\s+\w/.test(r))return"type";if(/\b(?:export\s+)?(?:const\s+)?enum\s+\w/.test(r))return"enum"}return"other"}function ee(t,e){let n=I(t,e.relativePath);if(!n)return!1;let i=g(e.symbol);if(!i)return!1;let s=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`\\b${s}\\b`),c=n.split(`
|
|
3
3
|
`);for(let o=0;o<c.length;o++)if(!(o>=e.startLine&&o<=e.endLine)&&a.test(c[o]??""))return!0;return!1}function ne(t,e,n){return t===0?{confidence:"high",reason:"unused \u2014 no consumers and defining file has no real usage"}:t===1&&e==="class"?{confidence:"low",reason:"1 consumer + class kind \u2014 likely 1:1 encapsulation, not over-abstraction"}:t===1&&!n?{confidence:"high",reason:"1 consumer + defining file never uses it \u2014 type belongs with its consumer"}:{confidence:"medium",reason:"1 consumer \u2014 single-use abstraction"}}export{me as a};
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
//# sourceMappingURL=chunk-T2M5HWBQ.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as de}from"./chunk-YHPG3S2U.js";import{b as ue}from"./chunk-B75HZHUP.js";import{c as I}from"./chunk-HENP2O4A.js";import{a as le}from"./chunk-6VREELBC.js";import{k as ce}from"./chunk-J3GLP7Q5.js";import{c as ae}from"./chunk-MSI3K7PJ.js";import{i as oe}from"./chunk-J7AMBVWF.js";import{a as ie,b as re,c as se}from"./chunk-ELNRLMC5.js";import{e as ee,f as te,h as ne}from"./chunk-NDKOVQFG.js";import{a as Q}from"./chunk-BRQL7AFJ.js";import{C as S,d as Z,e as $,g as G,h as J,i as q,j as V,k as K,s as X,x as Y}from"./chunk-GVAF222T.js";import{p as H}from"./chunk-F74LZWCE.js";import{C as x,a as L,z}from"./chunk-ICUL7XRT.js";import{f as w,l as B,t as U,v as j,w as P,x as W}from"./chunk-7GAK2F3H.js";import{d as y}from"./chunk-3LCDIREB.js";import{d as D}from"./chunk-UC2FD2PS.js";var _=new WeakMap,me=U({kind:"definition-exclusions",invalidation:j("definition-exclusions"),serialize:e=>JSON.stringify(e),deserialize:Ne});function pe(e,t){let n=z(t);if(!(n==="rust"||n==="typescript"||n==="tsx"||n==="javascript"))return[];let i=P(e,t);if(!i)return[];let o=B(e,t,i),c=me.read(e,t,o);if(c)return c;let u=n==="rust"?Ue(e,t):Fe(e,t);return me.write(e,t,o,u),u}function Ne(e){try{let t=JSON.parse(e);if(!Array.isArray(t))return null;let n=t.map(Te);return n.some(s=>s===null)?null:n}catch{return null}}function Te(e){if(!e||typeof e!="object")return null;let t=e;if(typeof t.startLine!="number"||!Number.isFinite(t.startLine)||typeof t.endLine!="number"||!Number.isFinite(t.endLine)||typeof t.reason!="string"||t.containerName!==void 0&&typeof t.containerName!="string")return null;let n=t.disposition===void 0?Xe(t.reason):t.disposition;return n!=="exclude"&&n!=="implicit-usage"?null:{startLine:t.startLine,endLine:t.endLine,reason:t.reason,disposition:n,...t.containerName?{containerName:t.containerName}:{}}}var be=new Set(["describe","it","test","fdescribe","fit","xdescribe","xit","beforeEach","afterEach","beforeAll","afterAll","before","after","suite","bench","benchmark"]),ke=/\b(?:describe|it|test|fdescribe|fit|xdescribe|xit|beforeEach|afterEach|beforeAll|afterAll|before|after|suite|bench|benchmark)\s*\(/,Ae=/\b(?:export\s+)?(?:async\s+)?function\s+use[A-Z][A-Za-z0-9_$]*\b|\b(?:const|let|var)\s+use[A-Z][A-Za-z0-9_$]*\s*(?::[^=;]+)?=\s*(?:async\s*)?(?:function\b|(?:<[^=;{]+>\s*)?(?:\([^)]*\)|[A-Za-z_$][\w$]*)\s*=>)/;function Fe(e,t){let n=P(e,t);if(!n||!Me(n))return[];let s=x(e,t);if(!s)return[];let i=_.get(s);if(i)return i;let o=!1,c=s.rootNode;for(let l of c.namedChildren){if(l.type!=="expression_statement")continue;let d=l.namedChild(0);if(!d||d.type!=="call_expression")continue;let r=d.namedChild(0);if(!r)continue;let a=r.type==="member_expression"?r.namedChild(r.namedChildCount-1)?.text:r.text;if(a&&be.has(a)){o=!0;break}}let u=[];o&&u.push({startLine:0,endLine:c.endPosition.row,reason:"TS/JS test file (describe/it/test at top level)",disposition:"exclude"});for(let l of c.namedChildren){let d=null,r=null;if(l.type==="function_declaration")d=l.namedChild(0)?.text??null,r=l;else if(l.type==="export_statement"){let a=l.namedChild(0);a?.type==="function_declaration"&&(d=a.namedChild(0)?.text??null,r=a)}else if(l.type==="lexical_declaration"){let a=l.namedChild(0);if(a?.type==="variable_declarator"){let p=a.namedChild(0)?.text,f=a.namedChild(1);p&&(f?.type==="arrow_function"||f?.type==="function_expression")&&(d=p,r=a)}}d&&/^use[A-Z]/.test(d)&&r&&u.push({startLine:r.startPosition.row,endLine:r.endPosition.row,reason:"React custom hook (use*)",disposition:"exclude"})}return u.push(...ye(s,new Set(["function_declaration","method_definition","class_declaration","interface_declaration","type_alias_declaration","enum_declaration","variable_declarator","export_statement"]),new Set(["comment"]))),_.set(s,u),u}function Me(e){if(e.includes("codebaseiq"))return!0;let t=!1;for(let n of be)if(e.includes(n)){t=!0;break}return t&&ke.test(e)?!0:e.includes("use")&&Ae.test(e)}var Oe=/codebaseiq[\s:-]*ignore[\s:-]*(?:dead(?:-code)?|stale)?/i;function Be(e){return Oe.test(e)}function ye(e,t,n){let s=[],i=o=>{if(t.has(o.type)&&o.parent){let u=o.parent.children,l=-1;for(let d=0;d<u.length;d+=1)if(u[d].startIndex===o.startIndex&&u[d].type===o.type){l=d;break}if(l>0)for(let d=l-1;d>=0;d-=1){let r=u[d];if(n.has(r.type)){if(Be(r.text)){s.push({startLine:o.startPosition.row,endLine:o.endPosition.row,reason:"codebaseiq suppression comment",disposition:"exclude"});break}continue}if(!(r.type==="attribute_item"||r.type==="inner_attribute_item"))break}}for(let c of o.namedChildren)i(c)};return i(e.rootNode),s}function Ue(e,t){let n=x(e,t);if(!n)return[];let s=_.get(n);if(s)return s;let i=[],o=je(n);return o?(_.set(n,o),o):(ge(n.rootNode,i,!1,!1),i.push(...ye(n,new Set(["function_item","function_signature_item","struct_item","enum_item","union_item","impl_item","mod_item","static_item","const_item"]),new Set(["line_comment","block_comment"]))),i.push(...Ve(n.rootNode)),_.set(n,i),i)}function je(e){return Ye(e.rootNode)?[{startLine:0,endLine:e.rootNode.endPosition.row,reason:"generated file (@generated header)",disposition:"exclude"}]:null}function ge(e,t,n,s){let i=n,o=s;e.type==="trait_item"&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait declaration body (dynamic dispatch)",disposition:"implicit-usage"}),e.type==="impl_item"&&e.childForFieldName("trait")&&(o=!0,t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait impl block (dynamic dispatch)",disposition:"implicit-usage"})),e.type==="function_item"||e.type==="function_signature_item"?We(e,t,n,s):s&&qe(e)?t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait impl associated item (dynamic dispatch)",disposition:"implicit-usage"}):e.type==="struct_item"||e.type==="enum_item"||e.type==="union_item"?ze(e,t,n):e.type==="mod_item"&&N(e).some(c=>/#\[\s*cfg\s*\(\s*test\s*\)/.test(c))&&(i=!0);for(let c of e.namedChildren)ge(c,t,i,o)}function We(e,t,n,s){let i=N(e),o=null;s?o={reason:"trait impl method (dynamic dispatch)",disposition:"implicit-usage"}:n&&(o={reason:"inside #[cfg(test)] mod",disposition:"exclude"});for(let c of i){if(he(c)){o={reason:"#[allow(dead_code)]",disposition:"exclude"};break}let u=Ge(c);if(u){o=u;break}}o&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:o.reason,disposition:o.disposition})}function ze(e,t,n){let s=N(e),i=e.namedChildren.find(o=>o.type==="type_identifier")?.text;s.some(Je)&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[derive(...)] - generated impl may access fields",disposition:"implicit-usage",containerName:i}),s.some(he)&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[allow(dead_code)]",disposition:"exclude",containerName:i}),n&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"inside #[cfg(test)] mod",disposition:"exclude",containerName:i})}function N(e){let t=e.parent;if(!t)return[];let n=t.children,s=-1;for(let o=0;o<n.length;o+=1)if(n[o].startIndex===e.startIndex&&n[o].type===e.type){s=o;break}if(s<=0)return[];let i=[];for(let o=s-1;o>=0;o-=1){let c=n[o];if(c.type==="attribute_item"||c.type==="inner_attribute_item")i.push(c.text);else{if(c.type==="line_comment"||c.type==="block_comment")continue;break}}return i}var He=new Set(["test","bench","tokio::test","async_std::test"]),Ze=new Set(["no_mangle","export_name","link_name","used","macro_export","proc_macro","proc_macro_derive","proc_macro_attribute"]),$e=new Set(["allow","warn","deny","forbid","cfg","cfg_attr","doc","inline","cold","must_use","deprecated","repr","derive","automatically_derived","non_exhaustive","path","link","link_section","global_allocator","panic_handler"]);function Ge(e){if(/#\[\s*cfg\s*\(\s*test\s*\)/.test(e))return{reason:"#[cfg(test)]",disposition:"exclude"};let t=Ke(e);return t?He.has(t)?{reason:`#[${t}]`,disposition:"exclude"}:Ze.has(t)?{reason:`Rust ABI/export attribute #[${t}]`,disposition:"implicit-usage"}:$e.has(t)?null:{reason:`Rust attribute macro #[${t}]`,disposition:"implicit-usage"}:null}function Je(e){return/#\[\s*derive\s*\(/.test(e)}function he(e){return/#\[\s*allow\s*\(\s*dead_code\s*\)/.test(e)}function qe(e){return e.type==="const_item"||e.type==="type_item"||e.type==="static_item"||e.type==="associated_type"}function Ve(e){let t=Qe(e);if(t.size===0)return[];let n=[];for(let s of e.descendantsOfType("mod_item")){let i=s.childForFieldName("name")?.text;i&&t.has(i)&&n.push({startLine:s.startPosition.row,endLine:s.endPosition.row,reason:'attribute `with = "..."` module - body may be invoked via reflection',disposition:"implicit-usage",containerName:i})}return n}function Ke(e){let t=/^#!?\[\s*([A-Za-z_][A-Za-z0-9_]*(?:\s*::\s*[A-Za-z_][A-Za-z0-9_]*)*)/.exec(e);return t?t[1].replace(/\s+/g,""):null}function Xe(e){return e==="#[tauri::command]"||e==="#[command]"||e==="#[wasm_bindgen]"||e==="#[no_mangle]"||e==="#[napi]"||e==="#[pyfunction]"||e==="#[pymethod]"||e==="#[pyo3]"||e==="#[doc(hidden)]"||e.startsWith("trait ")||e.startsWith("#[derive(<reflective>)]")||e.startsWith("#[derive(...)]")||e.startsWith('serde `with = "')||e.startsWith('attribute `with = "')||e.startsWith("Rust attribute macro #[")||e.startsWith("Rust ABI/export attribute #[")?"implicit-usage":"exclude"}function Ye(e){for(let t=0;t<Math.min(e.namedChildCount,12);t+=1){let n=e.namedChild(t);if(!n||n.type!=="line_comment"&&n.type!=="block_comment")break;if(/@generated\b/.test(n.text)||/This file is .*generated\b/i.test(n.text)||/Code generated by/i.test(n.text)||/Generated by:\s*https?:\/\/openapi-generator/i.test(n.text)||/openapi-generator/i.test(n.text)&&/Generated by/i.test(n.text))return!0}return!1}var fe=/\bwith\s*=\s*"([^"]+)"/g;function Qe(e){let t=new Set;for(let n of e.descendantsOfType("attribute_item")){fe.lastIndex=0;let s;for(;(s=fe.exec(n.text))!==null;){let i=s[1],o=i.split("::").pop()??i;o&&t.add(o)}}return t}function xe(e){let t=T(e);return(n,s,i,o)=>t(n,s,i,o)?.disposition==="exclude"}function T(e){let t=new Map,n=s=>{let i=t.get(s);if(i)return i;let o=pe(e,s),c=new Map;for(let u of o){if(!u.containerName)continue;let l=c.get(u.containerName)??[];l.push(u),c.set(u.containerName,l)}return i={ranges:o,containers:c},t.set(s,i),i};return(s,i,o,c)=>{let u=n(s),l=[];for(let r of u.ranges)i>=r.startLine&&i<=r.endLine&&l.push(r);let d=new Set;c&&d.add(c);for(let r of S(o))d.add(r);for(let r of d){let a=u.containers.get(r);a&&l.push(...a)}return et(l)}}function et(e){if(e.length===0)return null;let n=e.find(s=>s.disposition==="exclude")??e[0];return{disposition:n.disposition,reason:n.reason}}function Ct(e,t={}){w(e,{groups:t.semanticProvider===!0?["whole-project","semantic-provider"]:["whole-project"]})}function _e(e,t,n={}){w(e,{groups:n.definitions===!0?["source-file","definition-catalog"]:["source-file"],file:t.replace(/\\/g,"/")})}function Se(e,t){if(t.isIgnoredPath(e.relativePath))return b("ignored-file");if(q(e.symbol))return b("module-like-symbol");if(!E(e.symbol))return b("non-value-symbol");if(!e.isFunctionLike&&e.enclosingSymbol&&E(e.enclosingSymbol))return b("nested-non-callable-value");if(!t.includeTests&&!tt(e.relativePath))return b("test-file");if(!t.includeTests&&t.isExcludedRegion(e.relativePath,e.startLine,e.symbol,e.parentTypeName))return b("excluded-file-region");let n=$(e.symbol);if(n==="<constructor>")return b("implicit-constructor");if(e.symbol.startsWith("scip-python ")){if(n==="__all__")return b("python-runtime-metadata");if(/^__[^_].*__$/.test(n))return b("python-protocol-member")}return t.isDeclarationOnlyCallable()?b("declaration-only-callable"):t.isFrameworkContractCallable()?b("framework-contract-member"):V(e.symbol)?b("rust-trait-impl-member"):K(e.symbol)?b("rust-test-module"):!t.includeMembers&&!nt(e)?b("member"):e.endLine-e.startLine+1<t.minLoc?b("below-min-loc"):{accepted:!0}}function tt(e){return Q(e)!=="test"}function b(e){return{accepted:!1,rejectionReason:e}}function E(e){return J(e)||e.endsWith("().")||e.endsWith(".")}function nt(e){return G(e.symbol)||S(e.symbol).length===0}function Ee(){return new Map}function Re(e,t,n){let s=new Map;for(let i of ie(e,n))e.isIgnored(i.relative_path)||t.has(i.relative_path)||C(s,i.symbol_id,i.relative_path,i.ref_count,"scip-mention");return s}function Ce(e,t,n,s={}){let i=new Set;if(s.conservative||n.size===0){for(let o of se(e,t))i.add(o.symbol_id);return i}for(let o of re(e,t))e.isIgnored(o.relative_path)||n.has(o.relative_path)||i.add(o.symbol_id);return i}function k(e,t){let n=e.get(t);if(!n)return!1;for(let s of n.values())if(s.occurrences>0)return!0;return!1}function R(e,t,n){let s=e.get(t);if(!s)return!1;for(let[i,o]of s)if(i!==n&&o.occurrences>0)return!0;return!1}function ve(e){return e?.occurrences??0}function C(e,t,n,s,i="source-fallback"){if(s<=0)return;let o=we(e,t,n);o.occurrences+=s,o.sources.add(i)}function De(e,t,n,s,i){if(s<=0)return;let o=we(e,t,n);o.occurrences=Math.max(s,o.occurrences),o.sources.add(i)}function we(e,t,n){let s=e.get(t);s||(s=new Map,e.set(t,s));let i=s.get(n);return i||(i={occurrences:0,sources:new Set},s.set(n,i)),i}function Yt(e,t={}){let{scope:n,minLoc:s=1,includeTests:i=!1,skipBarrels:o=!1,includeMembers:c=!1,deadCodeOnly:u=!1,scanLimit:l,semantic:d=!0}=t,r=0,a=y("dead.candidates",()=>{let m=ue(it(e,{scope:n,minLoc:s,includeTests:i,includeMembers:c}),l);return r=m.length,m},()=>({definitions:r})),p=0,f=o?y("dead.inactive-barrels",()=>{let m=new Set(ee(e));return p=m.size,m},()=>({paths:p})):new Set,A=0,g=u?Ee():y("dead.mention-reference-counts",()=>{let m=Re(e,f,a.map(v=>v.symbolId));return A=m.size,m},()=>({definitions:a.length,symbolsWithReferences:A})),F=0,Pe=u?y("dead.mentioned-symbol-ids",()=>{let m=Ce(e,a.map(v=>v.symbolId),f,{conservative:f.size===0});return F=m.size,m},()=>({definitions:a.length,referencedSymbols:F})):new Set,h=u?a.filter(m=>!Pe.has(m.symbolId)):a.filter(m=>!R(g,m.symbolId,m.relativePath));u?y("dead.source-fallback.dead-code-only",()=>ut(e,h,g,{inactiveBarrelPaths:f}),()=>({definitions:h.length,testReferencesIncluded:!0})):y("dead.source-fallback.ast",()=>lt(e,h,g,{inactiveBarrelPaths:f}),()=>({definitions:h.length,testReferencesIncluded:!0}));let M=u?h.filter(m=>!k(g,m.symbolId)):h.filter(m=>!R(g,m.symbolId,m.relativePath)),O=new Set;y("dead.caller-map-supplement",()=>{O=pt(e,M,g,{inactiveBarrelPaths:f,includeSemantic:!u&&d})},()=>({definitions:M.length,semantic:!u&&d}));let Ie=u?h.filter(m=>!k(g,m.symbolId)):a.filter(m=>!O.has(m.symbolId));return ct(e,ot(Ie,g))}function it(e,t){let n=xe(e),s=[];for(let i of Y(e,{scope:t.scope,symbolMatches:E,sqlPrefilter:"function-like"}))Se(i,{minLoc:t.minLoc,includeTests:t.includeTests,includeMembers:t.includeMembers,isIgnoredPath:c=>e.isIgnored(c),isExcludedRegion:n,isDeclarationOnlyCallable:()=>st(e,i),isFrameworkContractCallable:()=>de(e,i)}).accepted&&s.push(i);return s}var rt=["method_signature","abstract_method_signature","call_signature","construct_signature"];function st(e,t){if(!t.parentTypeName||!/\.[cm]?[jt]sx?$/.test(t.relativePath))return!1;let n=x(e,t.relativePath);if(n)return n.rootNode.descendantsOfType([...rt]).some(i=>i.startPosition.row<=t.startLine&&i.endPosition.row>=t.endLine);let s=W(e,t.relativePath).slice(t.startLine,t.endLine+1).join(`
|
|
1
|
+
import{a as de}from"./chunk-YHPG3S2U.js";import{b as ue}from"./chunk-B75HZHUP.js";import{c as I}from"./chunk-BPKNP3KZ.js";import{a as le}from"./chunk-57OPIQFM.js";import{k as ce}from"./chunk-KLX6NSWT.js";import{c as ae}from"./chunk-MSI3K7PJ.js";import{i as oe}from"./chunk-J7AMBVWF.js";import{a as ie,b as re,c as se}from"./chunk-ELNRLMC5.js";import{e as ee,f as te,h as ne}from"./chunk-NDKOVQFG.js";import{a as Q}from"./chunk-BRQL7AFJ.js";import{C as S,d as Z,e as $,g as G,h as J,i as q,j as V,k as K,s as X,x as Y}from"./chunk-GVAF222T.js";import{p as H}from"./chunk-F74LZWCE.js";import{C as x,a as L,z}from"./chunk-ICUL7XRT.js";import{f as w,l as B,t as U,v as j,w as P,x as W}from"./chunk-7GAK2F3H.js";import{d as y}from"./chunk-3LCDIREB.js";import{d as D}from"./chunk-UC2FD2PS.js";var _=new WeakMap,me=U({kind:"definition-exclusions",invalidation:j("definition-exclusions"),serialize:e=>JSON.stringify(e),deserialize:Ne});function pe(e,t){let n=z(t);if(!(n==="rust"||n==="typescript"||n==="tsx"||n==="javascript"))return[];let i=P(e,t);if(!i)return[];let o=B(e,t,i),c=me.read(e,t,o);if(c)return c;let u=n==="rust"?Ue(e,t):Fe(e,t);return me.write(e,t,o,u),u}function Ne(e){try{let t=JSON.parse(e);if(!Array.isArray(t))return null;let n=t.map(Te);return n.some(s=>s===null)?null:n}catch{return null}}function Te(e){if(!e||typeof e!="object")return null;let t=e;if(typeof t.startLine!="number"||!Number.isFinite(t.startLine)||typeof t.endLine!="number"||!Number.isFinite(t.endLine)||typeof t.reason!="string"||t.containerName!==void 0&&typeof t.containerName!="string")return null;let n=t.disposition===void 0?Xe(t.reason):t.disposition;return n!=="exclude"&&n!=="implicit-usage"?null:{startLine:t.startLine,endLine:t.endLine,reason:t.reason,disposition:n,...t.containerName?{containerName:t.containerName}:{}}}var be=new Set(["describe","it","test","fdescribe","fit","xdescribe","xit","beforeEach","afterEach","beforeAll","afterAll","before","after","suite","bench","benchmark"]),ke=/\b(?:describe|it|test|fdescribe|fit|xdescribe|xit|beforeEach|afterEach|beforeAll|afterAll|before|after|suite|bench|benchmark)\s*\(/,Ae=/\b(?:export\s+)?(?:async\s+)?function\s+use[A-Z][A-Za-z0-9_$]*\b|\b(?:const|let|var)\s+use[A-Z][A-Za-z0-9_$]*\s*(?::[^=;]+)?=\s*(?:async\s*)?(?:function\b|(?:<[^=;{]+>\s*)?(?:\([^)]*\)|[A-Za-z_$][\w$]*)\s*=>)/;function Fe(e,t){let n=P(e,t);if(!n||!Me(n))return[];let s=x(e,t);if(!s)return[];let i=_.get(s);if(i)return i;let o=!1,c=s.rootNode;for(let l of c.namedChildren){if(l.type!=="expression_statement")continue;let d=l.namedChild(0);if(!d||d.type!=="call_expression")continue;let r=d.namedChild(0);if(!r)continue;let a=r.type==="member_expression"?r.namedChild(r.namedChildCount-1)?.text:r.text;if(a&&be.has(a)){o=!0;break}}let u=[];o&&u.push({startLine:0,endLine:c.endPosition.row,reason:"TS/JS test file (describe/it/test at top level)",disposition:"exclude"});for(let l of c.namedChildren){let d=null,r=null;if(l.type==="function_declaration")d=l.namedChild(0)?.text??null,r=l;else if(l.type==="export_statement"){let a=l.namedChild(0);a?.type==="function_declaration"&&(d=a.namedChild(0)?.text??null,r=a)}else if(l.type==="lexical_declaration"){let a=l.namedChild(0);if(a?.type==="variable_declarator"){let p=a.namedChild(0)?.text,f=a.namedChild(1);p&&(f?.type==="arrow_function"||f?.type==="function_expression")&&(d=p,r=a)}}d&&/^use[A-Z]/.test(d)&&r&&u.push({startLine:r.startPosition.row,endLine:r.endPosition.row,reason:"React custom hook (use*)",disposition:"exclude"})}return u.push(...ye(s,new Set(["function_declaration","method_definition","class_declaration","interface_declaration","type_alias_declaration","enum_declaration","variable_declarator","export_statement"]),new Set(["comment"]))),_.set(s,u),u}function Me(e){if(e.includes("codebaseiq"))return!0;let t=!1;for(let n of be)if(e.includes(n)){t=!0;break}return t&&ke.test(e)?!0:e.includes("use")&&Ae.test(e)}var Oe=/codebaseiq[\s:-]*ignore[\s:-]*(?:dead(?:-code)?|stale)?/i;function Be(e){return Oe.test(e)}function ye(e,t,n){let s=[],i=o=>{if(t.has(o.type)&&o.parent){let u=o.parent.children,l=-1;for(let d=0;d<u.length;d+=1)if(u[d].startIndex===o.startIndex&&u[d].type===o.type){l=d;break}if(l>0)for(let d=l-1;d>=0;d-=1){let r=u[d];if(n.has(r.type)){if(Be(r.text)){s.push({startLine:o.startPosition.row,endLine:o.endPosition.row,reason:"codebaseiq suppression comment",disposition:"exclude"});break}continue}if(!(r.type==="attribute_item"||r.type==="inner_attribute_item"))break}}for(let c of o.namedChildren)i(c)};return i(e.rootNode),s}function Ue(e,t){let n=x(e,t);if(!n)return[];let s=_.get(n);if(s)return s;let i=[],o=je(n);return o?(_.set(n,o),o):(ge(n.rootNode,i,!1,!1),i.push(...ye(n,new Set(["function_item","function_signature_item","struct_item","enum_item","union_item","impl_item","mod_item","static_item","const_item"]),new Set(["line_comment","block_comment"]))),i.push(...Ve(n.rootNode)),_.set(n,i),i)}function je(e){return Ye(e.rootNode)?[{startLine:0,endLine:e.rootNode.endPosition.row,reason:"generated file (@generated header)",disposition:"exclude"}]:null}function ge(e,t,n,s){let i=n,o=s;e.type==="trait_item"&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait declaration body (dynamic dispatch)",disposition:"implicit-usage"}),e.type==="impl_item"&&e.childForFieldName("trait")&&(o=!0,t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait impl block (dynamic dispatch)",disposition:"implicit-usage"})),e.type==="function_item"||e.type==="function_signature_item"?We(e,t,n,s):s&&qe(e)?t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait impl associated item (dynamic dispatch)",disposition:"implicit-usage"}):e.type==="struct_item"||e.type==="enum_item"||e.type==="union_item"?ze(e,t,n):e.type==="mod_item"&&N(e).some(c=>/#\[\s*cfg\s*\(\s*test\s*\)/.test(c))&&(i=!0);for(let c of e.namedChildren)ge(c,t,i,o)}function We(e,t,n,s){let i=N(e),o=null;s?o={reason:"trait impl method (dynamic dispatch)",disposition:"implicit-usage"}:n&&(o={reason:"inside #[cfg(test)] mod",disposition:"exclude"});for(let c of i){if(he(c)){o={reason:"#[allow(dead_code)]",disposition:"exclude"};break}let u=Ge(c);if(u){o=u;break}}o&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:o.reason,disposition:o.disposition})}function ze(e,t,n){let s=N(e),i=e.namedChildren.find(o=>o.type==="type_identifier")?.text;s.some(Je)&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[derive(...)] - generated impl may access fields",disposition:"implicit-usage",containerName:i}),s.some(he)&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[allow(dead_code)]",disposition:"exclude",containerName:i}),n&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"inside #[cfg(test)] mod",disposition:"exclude",containerName:i})}function N(e){let t=e.parent;if(!t)return[];let n=t.children,s=-1;for(let o=0;o<n.length;o+=1)if(n[o].startIndex===e.startIndex&&n[o].type===e.type){s=o;break}if(s<=0)return[];let i=[];for(let o=s-1;o>=0;o-=1){let c=n[o];if(c.type==="attribute_item"||c.type==="inner_attribute_item")i.push(c.text);else{if(c.type==="line_comment"||c.type==="block_comment")continue;break}}return i}var He=new Set(["test","bench","tokio::test","async_std::test"]),Ze=new Set(["no_mangle","export_name","link_name","used","macro_export","proc_macro","proc_macro_derive","proc_macro_attribute"]),$e=new Set(["allow","warn","deny","forbid","cfg","cfg_attr","doc","inline","cold","must_use","deprecated","repr","derive","automatically_derived","non_exhaustive","path","link","link_section","global_allocator","panic_handler"]);function Ge(e){if(/#\[\s*cfg\s*\(\s*test\s*\)/.test(e))return{reason:"#[cfg(test)]",disposition:"exclude"};let t=Ke(e);return t?He.has(t)?{reason:`#[${t}]`,disposition:"exclude"}:Ze.has(t)?{reason:`Rust ABI/export attribute #[${t}]`,disposition:"implicit-usage"}:$e.has(t)?null:{reason:`Rust attribute macro #[${t}]`,disposition:"implicit-usage"}:null}function Je(e){return/#\[\s*derive\s*\(/.test(e)}function he(e){return/#\[\s*allow\s*\(\s*dead_code\s*\)/.test(e)}function qe(e){return e.type==="const_item"||e.type==="type_item"||e.type==="static_item"||e.type==="associated_type"}function Ve(e){let t=Qe(e);if(t.size===0)return[];let n=[];for(let s of e.descendantsOfType("mod_item")){let i=s.childForFieldName("name")?.text;i&&t.has(i)&&n.push({startLine:s.startPosition.row,endLine:s.endPosition.row,reason:'attribute `with = "..."` module - body may be invoked via reflection',disposition:"implicit-usage",containerName:i})}return n}function Ke(e){let t=/^#!?\[\s*([A-Za-z_][A-Za-z0-9_]*(?:\s*::\s*[A-Za-z_][A-Za-z0-9_]*)*)/.exec(e);return t?t[1].replace(/\s+/g,""):null}function Xe(e){return e==="#[tauri::command]"||e==="#[command]"||e==="#[wasm_bindgen]"||e==="#[no_mangle]"||e==="#[napi]"||e==="#[pyfunction]"||e==="#[pymethod]"||e==="#[pyo3]"||e==="#[doc(hidden)]"||e.startsWith("trait ")||e.startsWith("#[derive(<reflective>)]")||e.startsWith("#[derive(...)]")||e.startsWith('serde `with = "')||e.startsWith('attribute `with = "')||e.startsWith("Rust attribute macro #[")||e.startsWith("Rust ABI/export attribute #[")?"implicit-usage":"exclude"}function Ye(e){for(let t=0;t<Math.min(e.namedChildCount,12);t+=1){let n=e.namedChild(t);if(!n||n.type!=="line_comment"&&n.type!=="block_comment")break;if(/@generated\b/.test(n.text)||/This file is .*generated\b/i.test(n.text)||/Code generated by/i.test(n.text)||/Generated by:\s*https?:\/\/openapi-generator/i.test(n.text)||/openapi-generator/i.test(n.text)&&/Generated by/i.test(n.text))return!0}return!1}var fe=/\bwith\s*=\s*"([^"]+)"/g;function Qe(e){let t=new Set;for(let n of e.descendantsOfType("attribute_item")){fe.lastIndex=0;let s;for(;(s=fe.exec(n.text))!==null;){let i=s[1],o=i.split("::").pop()??i;o&&t.add(o)}}return t}function xe(e){let t=T(e);return(n,s,i,o)=>t(n,s,i,o)?.disposition==="exclude"}function T(e){let t=new Map,n=s=>{let i=t.get(s);if(i)return i;let o=pe(e,s),c=new Map;for(let u of o){if(!u.containerName)continue;let l=c.get(u.containerName)??[];l.push(u),c.set(u.containerName,l)}return i={ranges:o,containers:c},t.set(s,i),i};return(s,i,o,c)=>{let u=n(s),l=[];for(let r of u.ranges)i>=r.startLine&&i<=r.endLine&&l.push(r);let d=new Set;c&&d.add(c);for(let r of S(o))d.add(r);for(let r of d){let a=u.containers.get(r);a&&l.push(...a)}return et(l)}}function et(e){if(e.length===0)return null;let n=e.find(s=>s.disposition==="exclude")??e[0];return{disposition:n.disposition,reason:n.reason}}function Ct(e,t={}){w(e,{groups:t.semanticProvider===!0?["whole-project","semantic-provider"]:["whole-project"]})}function _e(e,t,n={}){w(e,{groups:n.definitions===!0?["source-file","definition-catalog"]:["source-file"],file:t.replace(/\\/g,"/")})}function Se(e,t){if(t.isIgnoredPath(e.relativePath))return b("ignored-file");if(q(e.symbol))return b("module-like-symbol");if(!E(e.symbol))return b("non-value-symbol");if(!e.isFunctionLike&&e.enclosingSymbol&&E(e.enclosingSymbol))return b("nested-non-callable-value");if(!t.includeTests&&!tt(e.relativePath))return b("test-file");if(!t.includeTests&&t.isExcludedRegion(e.relativePath,e.startLine,e.symbol,e.parentTypeName))return b("excluded-file-region");let n=$(e.symbol);if(n==="<constructor>")return b("implicit-constructor");if(e.symbol.startsWith("scip-python ")){if(n==="__all__")return b("python-runtime-metadata");if(/^__[^_].*__$/.test(n))return b("python-protocol-member")}return t.isDeclarationOnlyCallable()?b("declaration-only-callable"):t.isFrameworkContractCallable()?b("framework-contract-member"):V(e.symbol)?b("rust-trait-impl-member"):K(e.symbol)?b("rust-test-module"):!t.includeMembers&&!nt(e)?b("member"):e.endLine-e.startLine+1<t.minLoc?b("below-min-loc"):{accepted:!0}}function tt(e){return Q(e)!=="test"}function b(e){return{accepted:!1,rejectionReason:e}}function E(e){return J(e)||e.endsWith("().")||e.endsWith(".")}function nt(e){return G(e.symbol)||S(e.symbol).length===0}function Ee(){return new Map}function Re(e,t,n){let s=new Map;for(let i of ie(e,n))e.isIgnored(i.relative_path)||t.has(i.relative_path)||C(s,i.symbol_id,i.relative_path,i.ref_count,"scip-mention");return s}function Ce(e,t,n,s={}){let i=new Set;if(s.conservative||n.size===0){for(let o of se(e,t))i.add(o.symbol_id);return i}for(let o of re(e,t))e.isIgnored(o.relative_path)||n.has(o.relative_path)||i.add(o.symbol_id);return i}function k(e,t){let n=e.get(t);if(!n)return!1;for(let s of n.values())if(s.occurrences>0)return!0;return!1}function R(e,t,n){let s=e.get(t);if(!s)return!1;for(let[i,o]of s)if(i!==n&&o.occurrences>0)return!0;return!1}function ve(e){return e?.occurrences??0}function C(e,t,n,s,i="source-fallback"){if(s<=0)return;let o=we(e,t,n);o.occurrences+=s,o.sources.add(i)}function De(e,t,n,s,i){if(s<=0)return;let o=we(e,t,n);o.occurrences=Math.max(s,o.occurrences),o.sources.add(i)}function we(e,t,n){let s=e.get(t);s||(s=new Map,e.set(t,s));let i=s.get(n);return i||(i={occurrences:0,sources:new Set},s.set(n,i)),i}function Yt(e,t={}){let{scope:n,minLoc:s=1,includeTests:i=!1,skipBarrels:o=!1,includeMembers:c=!1,deadCodeOnly:u=!1,scanLimit:l,semantic:d=!0}=t,r=0,a=y("dead.candidates",()=>{let m=ue(it(e,{scope:n,minLoc:s,includeTests:i,includeMembers:c}),l);return r=m.length,m},()=>({definitions:r})),p=0,f=o?y("dead.inactive-barrels",()=>{let m=new Set(ee(e));return p=m.size,m},()=>({paths:p})):new Set,A=0,g=u?Ee():y("dead.mention-reference-counts",()=>{let m=Re(e,f,a.map(v=>v.symbolId));return A=m.size,m},()=>({definitions:a.length,symbolsWithReferences:A})),F=0,Pe=u?y("dead.mentioned-symbol-ids",()=>{let m=Ce(e,a.map(v=>v.symbolId),f,{conservative:f.size===0});return F=m.size,m},()=>({definitions:a.length,referencedSymbols:F})):new Set,h=u?a.filter(m=>!Pe.has(m.symbolId)):a.filter(m=>!R(g,m.symbolId,m.relativePath));u?y("dead.source-fallback.dead-code-only",()=>ut(e,h,g,{inactiveBarrelPaths:f}),()=>({definitions:h.length,testReferencesIncluded:!0})):y("dead.source-fallback.ast",()=>lt(e,h,g,{inactiveBarrelPaths:f}),()=>({definitions:h.length,testReferencesIncluded:!0}));let M=u?h.filter(m=>!k(g,m.symbolId)):h.filter(m=>!R(g,m.symbolId,m.relativePath)),O=new Set;y("dead.caller-map-supplement",()=>{O=pt(e,M,g,{inactiveBarrelPaths:f,includeSemantic:!u&&d})},()=>({definitions:M.length,semantic:!u&&d}));let Ie=u?h.filter(m=>!k(g,m.symbolId)):a.filter(m=>!O.has(m.symbolId));return ct(e,ot(Ie,g))}function it(e,t){let n=xe(e),s=[];for(let i of Y(e,{scope:t.scope,symbolMatches:E,sqlPrefilter:"function-like"}))Se(i,{minLoc:t.minLoc,includeTests:t.includeTests,includeMembers:t.includeMembers,isIgnoredPath:c=>e.isIgnored(c),isExcludedRegion:n,isDeclarationOnlyCallable:()=>st(e,i),isFrameworkContractCallable:()=>de(e,i)}).accepted&&s.push(i);return s}var rt=["method_signature","abstract_method_signature","call_signature","construct_signature"];function st(e,t){if(!t.parentTypeName||!/\.[cm]?[jt]sx?$/.test(t.relativePath))return!1;let n=x(e,t.relativePath);if(n)return n.rootNode.descendantsOfType([...rt]).some(i=>i.startPosition.row<=t.startLine&&i.endPosition.row>=t.endLine);let s=W(e,t.relativePath).slice(t.startLine,t.endLine+1).join(`
|
|
2
2
|
`).trim();return s.endsWith(";")&&!s.includes("=>")&&!s.includes("{")}function ot(e,t){return e.map(n=>at(n,t)).filter(n=>n.cross_file_refs===0).sort((n,s)=>s.loc-n.loc||n.relative_path.localeCompare(s.relative_path)||n.start_line-s.start_line)}function at(e,t){let n=t.get(e.symbolId)??new Map,s=ve(n.get(e.relativePath)),i=0;for(let[o,c]of n)o!==e.relativePath&&(i+=c.occurrences);return{relative_path:e.relativePath,start_line:e.startLine,end_line:e.endLine,loc:e.endLine-e.startLine+1,symbol:e.symbol,parent_type_name:e.parentTypeName,same_file_refs:s,cross_file_refs:i}}function ct(e,t){let n=T(e),s=[],i=0,o=0,c=0,u=0,l=0,d=0;for(let r of t){if(e.isIgnored(r.relative_path))continue;if(te(e,r.relative_path)){u++;continue}if(ne(e,r.symbol,r.relative_path)){l++;continue}let a=n(r.relative_path,r.start_line,r.symbol,r.parent_type_name),p=a?.disposition==="implicit-usage"?a.reason:void 0,f=p?"implicit-usage":r.same_file_refs===0?"dead-code":"file-internal";f==="dead-code"?i++:f==="file-internal"?o++:c++,d+=r.loc,s.push({relativePath:r.relative_path,startLine:r.start_line,endLine:r.end_line,loc:r.loc,symbol:r.symbol,shortName:Z(r.symbol),sameFileRefs:r.same_file_refs,kind:f,...p?{implicitUsageReason:p}:{}})}return{symbols:s,counts:{total:s.length,deadCode:i,fileInternal:o,implicitUsage:c,loc:d},applicability:{entrySurfaceExcluded:u,externalRootExcluded:l,implicitUsageSignals:c},totalCount:s.length,deadCodeCount:i,fileInternalCount:o,implicitUsageCount:c,totalLoc:d}}function lt(e,t,n,s){if(t.length===0)return;let i=new I(e),o=new Set(t.map(l=>l.symbolId)),c=new Set(t.map(l=>l.leaf).filter(Boolean)),u=new Set(i.sourceFiles());for(let l of L(e))u.add(l);i.scanSourceReferences({paths:u,includeVueSfc:!0,includeCrossLanguageDispatchNames:!0,includeRustAttributeNames:!0,identifierResolution:"permissive",candidateNames:c,skipPath:l=>s.inactiveBarrelPaths.has(l)},l=>{o.has(l.target.symbolId)&&(mt(e,l)||C(n,l.target.symbolId,l.sourceFile,ft(l),"source-fallback"))})}function ut(e,t,n,s){if(t.length===0)return;let i=new I(e),o=X(t),c=new Set(i.sourceFiles());for(let r of L(e))c.add(r);let u=new Set(o.keys()),l=new Map,d=r=>{let a=l.get(r);return a||(a=oe(e,r),l.set(r,a)),a};i.scanSourceReferences({paths:c,includeVueSfc:!0,includeCrossLanguageDispatchNames:!0,includeRustAttributeNames:!0,identifierResolution:"permissive",candidateNames:u,skipPath:r=>s.inactiveBarrelPaths.has(r),resolveTargets:({sourceFile:r,name:a,kind:p})=>{let f=o.get(a);return f?dt(r,a,f,()=>d(r),{permissive:p!=="cross-language-dispatch"}):[]},afterPath:r=>{l.delete(r),_e(e,r)}},r=>{let a=r.kind==="identifier"&&r.sourceFile===r.target.relativePath?Math.max(0,r.occurrences-1):r.occurrences;r.kind==="identifier"&&Le(e,{sourceFile:r.sourceFile,name:r.name,target:r.target,occurrences:a})||C(n,r.target.symbolId,r.sourceFile,a,"source-fallback")})}function dt(e,t,n,s,i){let o=n.filter(d=>d.relativePath===e);if(o.length>0)return o;if(!i.permissive&&n.length===1)return[...n];let c=s(),u=c.get(t);if(u)for(let d of u){let r=n.filter(a=>D(d,a.relativePath));if(r.length>0)return r}let l=new Set;for(let d of c.values())for(let r of d)l.add(r);for(let d of l){let r=n.filter(a=>D(d,a.relativePath));if(r.length>0&&r.length===n.length)return r}return i.permissive?[...n]:[]}function mt(e,t){return t.kind==="cross-language-dispatch"&&t.target.relativePath===t.sourceFile?!0:t.kind==="identifier"&&Le(e,t)}function ft(e){return e.kind==="identifier"&&e.target.relativePath===e.sourceFile?Math.max(0,e.occurrences-1):e.occurrences}function Le(e,t){return t.occurrences>1?!1:H(e,t.sourceFile).some(n=>n.used||n.sourcePath!==t.target.relativePath?!1:n.importedName===t.name||n.localName===t.name)}function pt(e,t,n,s){let i=new Set,o=s.includeSemantic!==!1,c=(r,a)=>{a===r.relativePath||e.isIgnored(a)||s.inactiveBarrelPaths.has(a)||De(n,r.symbolId,a,1,"caller-map")};if(y("dead.caller-map.per-symbol-non-semantic",()=>{for(let r of t){let a=ae(e,r,{semantic:!1,semanticEvidence:le});for(let p of a)c(r,p.file)}},()=>({definitions:t.length,semantic:!1})),!o)return i;let u=0,l=y("dead.caller-map.semantic-candidates",()=>{let r=t.filter(a=>!R(n,a.symbolId,a.relativePath));return u=r.length,r},()=>({definitions:t.length,semanticCandidates:u}));if(l.length===0)return i;let d=ce(e,l);for(let r of d.incompleteSymbolIds)i.add(r);for(let r of d.unavailableSymbolIds)i.add(r);for(let r of l){let a=d.callers.get(r.symbolId);if(a)for(let p of a)c(r,p)}return i}export{Ct as a,Yt as b};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-TEMM2FEL.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as L}from"./chunk-DGXRDLV5.js";import{c as M}from"./chunk-
|
|
1
|
+
import{a as L}from"./chunk-DGXRDLV5.js";import{c as M}from"./chunk-UMEPSVKT.js";import{c as w}from"./chunk-BPKNP3KZ.js";import{a as I}from"./chunk-57OPIQFM.js";import{f as E}from"./chunk-KLX6NSWT.js";import{f as x}from"./chunk-MSI3K7PJ.js";import{d as f}from"./chunk-SGX43S2L.js";import{d as C}from"./chunk-GVAF222T.js";import{f as h}from"./chunk-F74LZWCE.js";var H=new Set(f());function U(e,t){return P(e,t).rows}function P(e,t){let{scope:l,minLoc:o=10,limit:s=30,scanLimit:a}=t??{},c=new w(e),r=t?.semantic!==!1,u=B(r,new Set,new Set);return{rows:L({candidates:()=>c.productionCallableDefinitions({scope:l,minLoc:o,requireFunctionLikeSymbol:!0,includeSuppressed:!0,sortByLocDesc:typeof a=="number"&&a>0}),scanLimit:a,filterCandidate:R,profile:{name:"complexity-hotspots"},prepare:n=>{let i=z(e,n);(r?E(e):null)?.materializeReferences(n,{prefetchCallees:!0});let m=x(e,n,{semantic:r,semanticEvidence:I}),y=c.calleeEvidenceMap(n,{semantic:r}),g=new Set([...m.incompleteSymbolIds,...y.incompleteSymbolIds]),v=new Set([...m.unavailableSymbolIds,...y.unavailableSymbolIds]);u=B(r,g,v);let D=new Map(n.map(p=>[p.symbolId,p]));return{callerMap:new Map([...m.rows].map(([p,F])=>[p,new Set(F.filter(d=>d.file!==D.get(p)?.relativePath).map(d=>d.file))])),calleeMap:y.rows,incompleteSymbolIds:g,unavailableSymbolIds:v,languageByFile:i,clojureCallableIds:k(e,n,i),branchEstimates:M(e,n)}},evaluate:(n,i)=>i.incompleteSymbolIds.has(n.symbolId)||i.unavailableSymbolIds.has(n.symbolId)?null:j(n,i,o),orderResults:(n,i)=>i.score-n.score||i.loc-n.loc,limit:s}),coverage:u}}function B(e,t,l){let o=new Set([...t,...l]).size,s=e?t.size>0&&l.size>0?"incomplete-and-unavailable":t.size>0?"incomplete":l.size>0?"unavailable":"complete":"disabled";return{semanticEvidence:{enabled:e,status:s,incompleteSymbolCount:t.size,unavailableSymbolCount:l.size,excludedSymbolCount:o}}}function R(e){return e.symbol.startsWith("rust-analyzer ")?typeof e.kind=="number"&&H.has(e.kind):!0}function j(e,t,l){if(t.languageByFile.get(e.relativePath)==="clojure"&&!t.clojureCallableIds.has(e.symbolId))return null;let o=e.endLine-e.startLine+1;if(o<l)return null;let s=t.callerMap.get(e.symbolId)?.size??0,a=t.calleeMap.get(e.symbolId)??[],c=new Set,r=new Set;for(let b of a){let m=`${b.symbol}|${b.file}`;c.add(m),b.file!==e.relativePath&&r.add(m)}let u=r.size,S=c.size,n=t.branchEstimates.get(e.symbolId)??{branches:0,estimateBasis:"regex-fallback"},i=n.branches+1;return{symbol:e.symbol,shortName:C(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:o,fanIn:s,fanOut:u,calleeCount:S,branches:n.branches,estimateBasis:n.estimateBasis,score:Math.round(o/50*(s/5)*Math.max(u/5,1)*Math.max(i/5,1)*100)/100}}function z(e,t){let l=[...new Set(t.map(a=>a.relativePath))];if(l.length===0)return new Map;let o=l.map(()=>"?").join(", "),s=e.all(`SELECT relative_path, language
|
|
2
2
|
FROM documents
|
|
3
3
|
WHERE relative_path IN (${o})`,...l);return new Map(s.map(a=>[a.relative_path,a.language?.toLowerCase()??null]))}function k(e,t,l){let o=new Set,s=new Map;for(let a of t){if(l.get(a.relativePath)!=="clojure")continue;let c=s.get(a.relativePath);c||(c=new Set((h(e,a.relativePath)?.callables??[]).map(r=>`${r.name}:${r.startLine}`)),s.set(a.relativePath,c)),c.has(`${a.leaf}:${a.startLine}`)&&o.add(a.symbolId)}return o}export{U as a,P as b};
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
//# sourceMappingURL=chunk-TLTSESB4.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{b as k}from"./chunk-
|
|
1
|
+
import{b as k}from"./chunk-TEMM2FEL.js";import{c as D}from"./chunk-BPKNP3KZ.js";import{m as S}from"./chunk-J7AMBVWF.js";import{f as v,h as L}from"./chunk-NDKOVQFG.js";import{d as h,t as y}from"./chunk-GVAF222T.js";function z(e,n={}){let{scope:s,minLoc:c=1,maxDepth:a=5,scanLimit:f}=n,t=new D(e),i=_(e,s,c,f),o=new P;for(let r of i)o.add(r);let m=[],I=[];i.length>0&&m.push(C(e,0,i,o));let b=i.map(r=>r.definition).filter(r=>r!==null),x=new Set(i.map(r=>r.symbol));for(let r=1;r<=a&&b.length>0;r++){let u=t.calleeMap(b,{semantic:!1}),E=new Set;for(let d of b)for(let l of u.get(d.symbolId)??[])x.has(l.symbol)||E.add(l.symbol);let p=[];for(let d of E){x.add(d);let l=F(e,d);if(!l||e.isIgnored(l.relativePath)||v(e,l.relativePath)||L(e,l.symbol,l.relativePath)||t.fileKind(l.relativePath)==="test"||t.hasSuppressionComment(l))continue;let g=B(e,l,o);g.removable?p.push(w(l,"cascade")):g.blockingFiles.length>0&&I.push({shortName:h(l.symbol),file:l.relativePath,blockingFiles:g.blockingFiles.slice(0,3)})}if(p.length===0)break;for(let d of p)o.add(d);m.push(C(e,r,p,o)),b=p.map(d=>d.definition).filter(d=>d!==null)}let N=m.reduce((r,u)=>r+u.loc,0),R=m.reduce((r,u)=>r+u.entries.length,0);return{batches:m,totalSymbols:R,totalLoc:N,blocked:I}}function _(e,n,s,c){let a=k(e,{scope:n,minLoc:s,skipBarrels:!0,deadCodeOnly:!0,scanLimit:c,semantic:!1}),f=[];for(let t of a.symbols)t.kind==="dead-code"&&(v(e,t.relativePath)||L(e,t.symbol,t.relativePath)||f.push({symbol:t.symbol,shortName:t.shortName,file:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:t.loc,evidence:"graph-fact",definition:F(e,t.symbol)}));return f}function w(e,n){return{symbol:e.symbol,shortName:h(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:e.endLine-e.startLine+1,evidence:n,definition:e}}function F(e,n){let s=e.get(`SELECT d.relative_path
|
|
2
2
|
FROM global_symbols gs
|
|
3
3
|
JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
|
|
4
4
|
JOIN documents d ON d.id = der.document_id
|
|
5
5
|
WHERE gs.symbol = ?
|
|
6
6
|
LIMIT 1`,n);return s?y(e,s.relative_path).find(c=>c.symbol===n)??null:null}function B(e,n,s){let c=S(e,n);if(c.length===0)return{removable:!1,blockingFiles:[]};let a=new Set;for(let f of c)f.file===n.relativePath&&f.line>=n.startLine&&f.line<=n.endLine||s.contains(f.file,f.line)||a.add(f.file);return{removable:a.size===0,blockingFiles:[...a]}}function C(e,n,s,c){let a=[...s].sort((i,o)=>i.file.localeCompare(o.file)||i.startLine-o.startLine),f=new Set(a.map(i=>i.file)),t=[];for(let i of f){let o=y(e,i);o.length>0&&o.every(m=>c.contains(i,m.startLine))&&t.push(i)}return{depth:n,entries:a.map(({definition:i,...o})=>o),loc:a.reduce((i,o)=>i+o.loc,0),filesEmptied:t.sort()}}var P=class{ranges=new Map;add(n){let s=this.ranges.get(n.file)??[];s.push({start:n.startLine,end:n.endLine}),this.ranges.set(n.file,s)}contains(n,s){let c=this.ranges.get(n);return c?c.some(a=>s>=a.start&&s<=a.end):!1}};export{z as a,P as b};
|
|
7
|
-
//# sourceMappingURL=chunk-
|
|
7
|
+
//# sourceMappingURL=chunk-UIAUPFBJ.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as Q,b as ee,c as ne}from"./chunk-IHSLIIL3.js";import{a as Z}from"./chunk-AURCQHSG.js";import{c as Y}from"./chunk-5IZRKWTZ.js";import{a as X,b as z,c as W}from"./chunk-JCMFBF4Z.js";import{a as J,d as w}from"./chunk-VGWZ4MOY.js";import{a as K}from"./chunk-LMTSB3TB.js";import{a as H,d as V}from"./chunk-BGGB5N53.js";import{h as G}from"./chunk-GQLDYCWS.js";import{a as x}from"./chunk-BRQL7AFJ.js";import{p as q}from"./chunk-F74LZWCE.js";import{x as U}from"./chunk-7GAK2F3H.js";import{createHash as ue}from"crypto";var le=6,ve=12,be=48,Ce=2e4,te=12,L=Number.MAX_SAFE_INTEGER,ye=["definition","callers","callees"],_={search:12,"exact-source":24,definition:24,caller:8,callee:8,"production-reference":6,"test-reference":2,dependency:6,consumer:6};function tn(e,t){if(t.cursor)throw new Error("Inspect no longer accepts semantic packet cursors. Run the original inspect selectors again.");let n=xe(t),r=we(e,n),i=r.candidates.sort((c,p)=>M(c,p));n.view==="behavior"&&Pe(e,i),Re(e,i),n.view==="behavior"&&Ee(e,i);let o=Q(i.map(c=>O(c,n.view)),n.evidenceBudgets,(c,p)=>M(c.candidate,p.candidate)),{selected:u,omitted:a}=ee(o.selected,n.maxUnits,n.maxCharacters,(c,p)=>M(c.candidate,p.candidate),n.view==="source"),d=u.map(c=>c.candidate),s=[...o.omitted,...a].map(c=>c.candidate),l=d.map(Ae),m=z(d.map(c=>c.kind==="source"?c.bindingClosure:void 0),d.filter(c=>c.kind==="source").map(c=>({relativePath:c.relativePath,startLine:c.startLine,endLine:c.endLine}))),h=l.reduce((c,p)=>c+(p.kind==="source"?qe(p.source):0),0),g=l.reduce((c,p)=>c+(p.kind==="source"?p.source.length:0),0),y=l.reduce((c,p)=>c+he(p,n.view),0),v=l.filter(c=>c.kind==="source"&&(c.roles.includes("search")||c.roles.includes("location"))).map(De),b=i.filter(c=>c.kind==="source"&&(c.roles.includes("search")||c.roles.includes("location"))).length,fe=l.filter(c=>c.kind==="source"&&(c.roles.includes("search")||c.roles.includes("location"))).length,P=r.searches.map(c=>Me(c,i,d)),ge=Fe(s),N=r.locations.every(c=>c.matched)&&r.evidence.every(c=>c.kind==="matched")&&r.searches.every(c=>Te(c.textCoverage))&&s.every(c=>!c.roles.some(p=>p==="location"||p==="definition")),A=P.reduce((c,p)=>c+p.omittedMatches,0),R=s.length===0&&A===0,$=R?void 0:me(n,!0),D=$e(n,s),Se=Le(R,N,s.length+A,D,P,$),j=i.filter(c=>n.view==="behavior"&&c.kind==="source"&&c.roles.some(p=>p==="location"||p==="definition"||p==="search")).map(c=>({id:`inspect:${c.relativePath}:${c.startLine}-${c.endLine}`,label:c.ownerShort??`${c.relativePath}:${c.startLine+1}`,file:c.relativePath,startLine:c.startLine,endLine:c.endLine})),B=j.length>0?Y(e,j):void 0;return{searches:P,evidence:r.evidence,locations:r.locations,slices:v,candidateSlices:b,omittedSlices:b-fe,maxSlices:b,maxTotalLines:h,units:l,candidateUnits:i.length,omittedUnits:s.length,maxUnits:n.maxUnits,maxCharacters:n.maxCharacters,returnedLines:h,returnedCharacters:g,returnedViewCharacters:y,view:n.view,omissionGroups:D,packetCoverage:{mode:R?"complete":"bounded",candidateUnits:i.length,returnedUnits:l.length,omittedUnits:s.length,omittedByRole:ge,exactSelectorsComplete:N,maxUnits:n.maxUnits,maxCharacters:n.maxCharacters,channels:Oe(i,d,n.evidenceBudgets,n.view),...$?{expansionCommand:$}:{}},stoppingSummary:Se,...B&&B.candidateAnchors>0?{causalFrontier:B}:{},bindingClosure:m,continuation:null}}function Le(e,t,n,r,i,o){let u=f([...r.map(a=>a.drillCommand),...i.flatMap(a=>a.exactFollowup?[a.exactFollowup]:[]),...o?[o]:[]]);return e&&t?{queryStatus:"selection-complete",status:"stop-ready",openEvidence:0,guidance:"All evidence requested by this inspect query was materialized.",drillCommands:[]}:t?{queryStatus:"frontier-accounted",status:"relevance-check-required",openEvidence:n,guidance:"Withheld evidence is accounted for by recoverable groups; drill the groups relevant to the current decision.",drillCommands:u}:{queryStatus:"coverage-incomplete",status:"exact-evidence-withheld",openEvidence:n,guidance:"A requested identity, exact source unit, or current-text coverage requirement is unresolved; drill before relying on it.",drillCommands:u}}function xe(e){let t=F(e.searches),n=F(e.symbols),r=F(e.locations),i=t.length+n.length+r.length;if(i===0)throw new Error("inspect requires at least one --search, --symbol, or --at selector.");if(i>24)throw new RangeError(`inspect accepts at most ${24} selectors; received ${i}.`);let o=e.evidence??{};if(e.unitLines!==void 0&&C(e.unitLines,"unitLines"),e.totalLines!==void 0&&C(e.totalLines,"totalLines"),e.sliceLimit!==void 0&&C(e.sliceLimit,"sliceLimit"),e.maxCharacters!==void 0&&C(e.maxCharacters,"maxCharacters"),e.maxUnits!==void 0&&C(e.maxUnits,"maxUnits"),e.view!==void 0&&e.view!=="source"&&e.view!=="behavior")throw new Error(`Unknown inspect view: ${String(e.view)}. Use source or behavior.`);if(e.full&&(e.searchLimit!==void 0||e.maxUnits!==void 0||e.maxCharacters!==void 0||e.evidenceBudgets!==void 0))throw new Error("full inspect cannot be combined with searchLimit, maxUnits, maxCharacters, or evidenceBudgets.");let u=e.full??!1;return{searches:t,symbols:n,locations:r,...e.scope?.trim()?{scope:e.scope.trim()}:{},context:ae(e.context??le,"context"),searchLimit:C(e.searchLimit??(u?L:ve),"searchLimit"),maxUnits:C(u?L:e.maxUnits??be,"maxUnits"),maxCharacters:C(u?L:e.maxCharacters??Ce,"maxCharacters"),evidenceBudgets:u?Ue():Ie(e.evidenceBudgets??_),view:e.view??"source",evidence:{...o.parts?{parts:[...o.parts]}:n.length>0?{parts:[...ye]}:{},...o.referenceContext!==void 0?{referenceContext:ae(o.referenceContext,"referenceContext")}:{},relatedSourceLines:o.relatedSourceLines??60,...o.semantic!==void 0?{semantic:o.semantic}:{}}}}function Ie(e){let t={..._};for(let[n,r]of Object.entries(e)){if(!(n in t))throw new Error(`Unknown inspect evidence channel: ${n}.`);if(!Number.isSafeInteger(r)||(r??-1)<0)throw new RangeError(`Evidence budget ${n} must be a non-negative safe integer; received ${r}.`);t[n]=r}return t}function Ue(){return Object.fromEntries(Object.keys(_).map(e=>[e,L]))}function we(e,t){let n=[],r=0,i=t.searches.map(s=>{let l=ne(e,s,{scope:t.scope,context:0,limit:t.searchLimit,ranking:"structural"});return{pattern:s,result:l,matches:l.matches}}),o=Math.max(0,...i.map(s=>s.matches.length));for(let s=0;s<o;s+=1)for(let l of i){let m=l.matches[s];if(!m)continue;let h=w(e,m.relativePath,m.focusLine,L,t.context);h&&I(e,n,h,"search",`search:${l.pattern}`,m.ownerSymbol,m.ownerShort,1,r++)}let u=i.map(({pattern:s,result:l})=>{let m=l.omittedMatches>0?de(s,t.scope):void 0,h=l.fileCoverage??[],g=_e(s,h,t.scope);return{pattern:s,matchingLines:l.matchingLines,returnedMatches:l.matches.length,omittedMatches:l.omittedMatches,matchingFiles:h.length,returnedFiles:h.filter(y=>y.returnedMatches>0).length,omittedFiles:h.filter(y=>y.returnedMatches===0).length,candidateUnits:0,selectedUnits:0,omittedUnits:0,scopeHints:g.slice(0,te),omittedScopeHints:Math.max(0,g.length-te),textCoverage:l.textCoverage,...m?{exactFollowup:m}:{}}}),a=t.locations.map(s=>{let l=je(s),m=l?K(e,l.path):null,h=m?w(e,m,l.line-1,L,t.context):null;return h&&I(e,n,h,"location",`at:${s}`,null,null,0,r++),{target:s,matched:h!==null}}),d=t.symbols.map(s=>Z(e,s,t.evidence));for(let s of d)if(s.kind==="matched"){if(s.definition){let l=w(e,s.definition.relativePath,s.definition.startLine,L,t.context);l&&I(e,n,l,"definition",`definition:${s.shortName}`,s.symbol,s.shortName,0,r++)}for(let l of s.referenceWindows){let m=l.references[0];I(e,n,{...l,focusLine:m?.line??l.startLine,unitType:null,unitStartLine:l.startLine,unitEndLine:l.endLine,omittedLines:0},"reference",`reference:${s.shortName}`,m?.enclosingSymbol??null,m?.enclosingShort??null,x(l.relativePath)==="test"?5:4,r++,l.references.map(h=>h.line),s.symbol)}for(let l of s.callers)re(e,n,l,"caller",s,2,r++);for(let l of s.callees)re(e,n,l,"callee",s,3,r++);for(let l of s.dependencies)oe(e,n,"dependency",s.file,l.relativePath,s.symbol,t.context,6,r++);for(let l of s.consumers)oe(e,n,"consumer",l.relativePath,s.file,s.symbol,t.context,7,r++)}return{searches:u,evidence:d,locations:a,candidates:n}}function M(e,t){return e.priority-t.priority||t.roles.length-e.roles.length||t.reasons.length-e.reasons.length||ie(x(e.relativePath))-ie(x(t.relativePath))||e.sequence-t.sequence}function ie(e){switch(e){case"entry":case"source":case"worker":return 0;case"barrel":return 1;case"test":return 2}}function O(e,t){return{candidate:e,priority:e.priority,sequence:e.sequence,relativePath:e.relativePath,fileKind:x(e.relativePath),evidenceCharacters:he(e,t),roles:e.roles,reasons:e.reasons,symbols:e.symbols,behaviorSignals:e.kind==="source"?e.behavior?.signals??[]:[],channel:T(e)}}function T(e){let t=e.roles;return t.includes("location")?"exact-source":t.includes("definition")?"definition":t.includes("caller")?"caller":t.includes("callee")?"callee":t.includes("reference")?x(e.relativePath)==="test"?"test-reference":"production-reference":t.includes("dependency")?"dependency":t.includes("consumer")?"consumer":"search"}function Ee(e,t){let n=t.filter(i=>i.kind==="source"),r=G(e,{files:f(n.map(i=>i.relativePath))});for(let i of n){i.behavior=H(e,i.relativePath,i.startLine,i.endLine,i.focusLines)??void 0;let o=r.filter(a=>a.source.file===i.relativePath&&a.source.startLine<=i.endLine&&a.source.endLine>=i.startLine),u=o.filter(a=>!ke(a,o)).map(a=>({observationId:a.id,protocol:a.protocol,action:a.action,role:a.role,strength:a.strength,resolution:a.resolution,line:a.source.startLine,endLine:a.source.endLine,keyParts:a.keyParts.map(d=>({name:d.name,value:d.value,evidence:d.evidence})),derivation:{kind:a.derivation.kind,rule:a.derivation.rule,sourceSpans:a.derivation.sourceSpans.length}}));i.runtimeFacts=u.length>0?u:void 0}}function ke(e,t){if(e.strength!=="candidate"||e.protocol!=="http")return!1;let n=e.keyParts.find(i=>i.name==="path")?.value,r=e.keyParts.find(i=>i.name==="method")?.value;return n?t.some(i=>{if(i===e||i.action!==e.action||i.role!==e.role||i.source.startLine!==e.source.startLine||i.derivation.rule!=="http.mount-prefix")return!1;let o=i.keyParts.find(a=>a.name==="path")?.value,u=i.keyParts.find(a=>a.name==="method")?.value;return!!(o&&o!==n&&o.endsWith(n)&&(!r||r===u))}):!1}function Pe(e,t){for(let n of t){if(n.kind!=="source")continue;let r=V(e,n.relativePath,n.startLine,n.endLine,n.focusLines);r.startLine===n.startLine&&r.endLine===n.endLine||(n.startLine=r.startLine,n.endLine=r.endLine,n.source=U(e,n.relativePath).slice(r.startLine,r.endLine+1).join(`
|
|
1
|
+
import{a as Q,b as ee,c as ne}from"./chunk-IHSLIIL3.js";import{a as Z}from"./chunk-DDRA3QKN.js";import{c as Y}from"./chunk-BGYRF5YX.js";import{a as X,b as z,c as W}from"./chunk-JCMFBF4Z.js";import{a as J,d as w}from"./chunk-VGWZ4MOY.js";import{a as K}from"./chunk-LMTSB3TB.js";import{a as H,d as V}from"./chunk-BGGB5N53.js";import{h as G}from"./chunk-GQLDYCWS.js";import{a as x}from"./chunk-BRQL7AFJ.js";import{p as q}from"./chunk-F74LZWCE.js";import{x as U}from"./chunk-7GAK2F3H.js";import{createHash as ue}from"crypto";var le=6,ve=12,be=48,Ce=2e4,te=12,L=Number.MAX_SAFE_INTEGER,ye=["definition","callers","callees"],_={search:12,"exact-source":24,definition:24,caller:8,callee:8,"production-reference":6,"test-reference":2,dependency:6,consumer:6};function tn(e,t){if(t.cursor)throw new Error("Inspect no longer accepts semantic packet cursors. Run the original inspect selectors again.");let n=xe(t),r=we(e,n),i=r.candidates.sort((c,p)=>M(c,p));n.view==="behavior"&&Pe(e,i),Re(e,i),n.view==="behavior"&&Ee(e,i);let o=Q(i.map(c=>O(c,n.view)),n.evidenceBudgets,(c,p)=>M(c.candidate,p.candidate)),{selected:u,omitted:a}=ee(o.selected,n.maxUnits,n.maxCharacters,(c,p)=>M(c.candidate,p.candidate),n.view==="source"),d=u.map(c=>c.candidate),s=[...o.omitted,...a].map(c=>c.candidate),l=d.map(Ae),m=z(d.map(c=>c.kind==="source"?c.bindingClosure:void 0),d.filter(c=>c.kind==="source").map(c=>({relativePath:c.relativePath,startLine:c.startLine,endLine:c.endLine}))),h=l.reduce((c,p)=>c+(p.kind==="source"?qe(p.source):0),0),g=l.reduce((c,p)=>c+(p.kind==="source"?p.source.length:0),0),y=l.reduce((c,p)=>c+he(p,n.view),0),v=l.filter(c=>c.kind==="source"&&(c.roles.includes("search")||c.roles.includes("location"))).map(De),b=i.filter(c=>c.kind==="source"&&(c.roles.includes("search")||c.roles.includes("location"))).length,fe=l.filter(c=>c.kind==="source"&&(c.roles.includes("search")||c.roles.includes("location"))).length,P=r.searches.map(c=>Me(c,i,d)),ge=Fe(s),N=r.locations.every(c=>c.matched)&&r.evidence.every(c=>c.kind==="matched")&&r.searches.every(c=>Te(c.textCoverage))&&s.every(c=>!c.roles.some(p=>p==="location"||p==="definition")),A=P.reduce((c,p)=>c+p.omittedMatches,0),R=s.length===0&&A===0,$=R?void 0:me(n,!0),D=$e(n,s),Se=Le(R,N,s.length+A,D,P,$),j=i.filter(c=>n.view==="behavior"&&c.kind==="source"&&c.roles.some(p=>p==="location"||p==="definition"||p==="search")).map(c=>({id:`inspect:${c.relativePath}:${c.startLine}-${c.endLine}`,label:c.ownerShort??`${c.relativePath}:${c.startLine+1}`,file:c.relativePath,startLine:c.startLine,endLine:c.endLine})),B=j.length>0?Y(e,j):void 0;return{searches:P,evidence:r.evidence,locations:r.locations,slices:v,candidateSlices:b,omittedSlices:b-fe,maxSlices:b,maxTotalLines:h,units:l,candidateUnits:i.length,omittedUnits:s.length,maxUnits:n.maxUnits,maxCharacters:n.maxCharacters,returnedLines:h,returnedCharacters:g,returnedViewCharacters:y,view:n.view,omissionGroups:D,packetCoverage:{mode:R?"complete":"bounded",candidateUnits:i.length,returnedUnits:l.length,omittedUnits:s.length,omittedByRole:ge,exactSelectorsComplete:N,maxUnits:n.maxUnits,maxCharacters:n.maxCharacters,channels:Oe(i,d,n.evidenceBudgets,n.view),...$?{expansionCommand:$}:{}},stoppingSummary:Se,...B&&B.candidateAnchors>0?{causalFrontier:B}:{},bindingClosure:m,continuation:null}}function Le(e,t,n,r,i,o){let u=f([...r.map(a=>a.drillCommand),...i.flatMap(a=>a.exactFollowup?[a.exactFollowup]:[]),...o?[o]:[]]);return e&&t?{queryStatus:"selection-complete",status:"stop-ready",openEvidence:0,guidance:"All evidence requested by this inspect query was materialized.",drillCommands:[]}:t?{queryStatus:"frontier-accounted",status:"relevance-check-required",openEvidence:n,guidance:"Withheld evidence is accounted for by recoverable groups; drill the groups relevant to the current decision.",drillCommands:u}:{queryStatus:"coverage-incomplete",status:"exact-evidence-withheld",openEvidence:n,guidance:"A requested identity, exact source unit, or current-text coverage requirement is unresolved; drill before relying on it.",drillCommands:u}}function xe(e){let t=F(e.searches),n=F(e.symbols),r=F(e.locations),i=t.length+n.length+r.length;if(i===0)throw new Error("inspect requires at least one --search, --symbol, or --at selector.");if(i>24)throw new RangeError(`inspect accepts at most ${24} selectors; received ${i}.`);let o=e.evidence??{};if(e.unitLines!==void 0&&C(e.unitLines,"unitLines"),e.totalLines!==void 0&&C(e.totalLines,"totalLines"),e.sliceLimit!==void 0&&C(e.sliceLimit,"sliceLimit"),e.maxCharacters!==void 0&&C(e.maxCharacters,"maxCharacters"),e.maxUnits!==void 0&&C(e.maxUnits,"maxUnits"),e.view!==void 0&&e.view!=="source"&&e.view!=="behavior")throw new Error(`Unknown inspect view: ${String(e.view)}. Use source or behavior.`);if(e.full&&(e.searchLimit!==void 0||e.maxUnits!==void 0||e.maxCharacters!==void 0||e.evidenceBudgets!==void 0))throw new Error("full inspect cannot be combined with searchLimit, maxUnits, maxCharacters, or evidenceBudgets.");let u=e.full??!1;return{searches:t,symbols:n,locations:r,...e.scope?.trim()?{scope:e.scope.trim()}:{},context:ae(e.context??le,"context"),searchLimit:C(e.searchLimit??(u?L:ve),"searchLimit"),maxUnits:C(u?L:e.maxUnits??be,"maxUnits"),maxCharacters:C(u?L:e.maxCharacters??Ce,"maxCharacters"),evidenceBudgets:u?Ue():Ie(e.evidenceBudgets??_),view:e.view??"source",evidence:{...o.parts?{parts:[...o.parts]}:n.length>0?{parts:[...ye]}:{},...o.referenceContext!==void 0?{referenceContext:ae(o.referenceContext,"referenceContext")}:{},relatedSourceLines:o.relatedSourceLines??60,...o.semantic!==void 0?{semantic:o.semantic}:{}}}}function Ie(e){let t={..._};for(let[n,r]of Object.entries(e)){if(!(n in t))throw new Error(`Unknown inspect evidence channel: ${n}.`);if(!Number.isSafeInteger(r)||(r??-1)<0)throw new RangeError(`Evidence budget ${n} must be a non-negative safe integer; received ${r}.`);t[n]=r}return t}function Ue(){return Object.fromEntries(Object.keys(_).map(e=>[e,L]))}function we(e,t){let n=[],r=0,i=t.searches.map(s=>{let l=ne(e,s,{scope:t.scope,context:0,limit:t.searchLimit,ranking:"structural"});return{pattern:s,result:l,matches:l.matches}}),o=Math.max(0,...i.map(s=>s.matches.length));for(let s=0;s<o;s+=1)for(let l of i){let m=l.matches[s];if(!m)continue;let h=w(e,m.relativePath,m.focusLine,L,t.context);h&&I(e,n,h,"search",`search:${l.pattern}`,m.ownerSymbol,m.ownerShort,1,r++)}let u=i.map(({pattern:s,result:l})=>{let m=l.omittedMatches>0?de(s,t.scope):void 0,h=l.fileCoverage??[],g=_e(s,h,t.scope);return{pattern:s,matchingLines:l.matchingLines,returnedMatches:l.matches.length,omittedMatches:l.omittedMatches,matchingFiles:h.length,returnedFiles:h.filter(y=>y.returnedMatches>0).length,omittedFiles:h.filter(y=>y.returnedMatches===0).length,candidateUnits:0,selectedUnits:0,omittedUnits:0,scopeHints:g.slice(0,te),omittedScopeHints:Math.max(0,g.length-te),textCoverage:l.textCoverage,...m?{exactFollowup:m}:{}}}),a=t.locations.map(s=>{let l=je(s),m=l?K(e,l.path):null,h=m?w(e,m,l.line-1,L,t.context):null;return h&&I(e,n,h,"location",`at:${s}`,null,null,0,r++),{target:s,matched:h!==null}}),d=t.symbols.map(s=>Z(e,s,t.evidence));for(let s of d)if(s.kind==="matched"){if(s.definition){let l=w(e,s.definition.relativePath,s.definition.startLine,L,t.context);l&&I(e,n,l,"definition",`definition:${s.shortName}`,s.symbol,s.shortName,0,r++)}for(let l of s.referenceWindows){let m=l.references[0];I(e,n,{...l,focusLine:m?.line??l.startLine,unitType:null,unitStartLine:l.startLine,unitEndLine:l.endLine,omittedLines:0},"reference",`reference:${s.shortName}`,m?.enclosingSymbol??null,m?.enclosingShort??null,x(l.relativePath)==="test"?5:4,r++,l.references.map(h=>h.line),s.symbol)}for(let l of s.callers)re(e,n,l,"caller",s,2,r++);for(let l of s.callees)re(e,n,l,"callee",s,3,r++);for(let l of s.dependencies)oe(e,n,"dependency",s.file,l.relativePath,s.symbol,t.context,6,r++);for(let l of s.consumers)oe(e,n,"consumer",l.relativePath,s.file,s.symbol,t.context,7,r++)}return{searches:u,evidence:d,locations:a,candidates:n}}function M(e,t){return e.priority-t.priority||t.roles.length-e.roles.length||t.reasons.length-e.reasons.length||ie(x(e.relativePath))-ie(x(t.relativePath))||e.sequence-t.sequence}function ie(e){switch(e){case"entry":case"source":case"worker":return 0;case"barrel":return 1;case"test":return 2}}function O(e,t){return{candidate:e,priority:e.priority,sequence:e.sequence,relativePath:e.relativePath,fileKind:x(e.relativePath),evidenceCharacters:he(e,t),roles:e.roles,reasons:e.reasons,symbols:e.symbols,behaviorSignals:e.kind==="source"?e.behavior?.signals??[]:[],channel:T(e)}}function T(e){let t=e.roles;return t.includes("location")?"exact-source":t.includes("definition")?"definition":t.includes("caller")?"caller":t.includes("callee")?"callee":t.includes("reference")?x(e.relativePath)==="test"?"test-reference":"production-reference":t.includes("dependency")?"dependency":t.includes("consumer")?"consumer":"search"}function Ee(e,t){let n=t.filter(i=>i.kind==="source"),r=G(e,{files:f(n.map(i=>i.relativePath))});for(let i of n){i.behavior=H(e,i.relativePath,i.startLine,i.endLine,i.focusLines)??void 0;let o=r.filter(a=>a.source.file===i.relativePath&&a.source.startLine<=i.endLine&&a.source.endLine>=i.startLine),u=o.filter(a=>!ke(a,o)).map(a=>({observationId:a.id,protocol:a.protocol,action:a.action,role:a.role,strength:a.strength,resolution:a.resolution,line:a.source.startLine,endLine:a.source.endLine,keyParts:a.keyParts.map(d=>({name:d.name,value:d.value,evidence:d.evidence})),derivation:{kind:a.derivation.kind,rule:a.derivation.rule,sourceSpans:a.derivation.sourceSpans.length}}));i.runtimeFacts=u.length>0?u:void 0}}function ke(e,t){if(e.strength!=="candidate"||e.protocol!=="http")return!1;let n=e.keyParts.find(i=>i.name==="path")?.value,r=e.keyParts.find(i=>i.name==="method")?.value;return n?t.some(i=>{if(i===e||i.action!==e.action||i.role!==e.role||i.source.startLine!==e.source.startLine||i.derivation.rule!=="http.mount-prefix")return!1;let o=i.keyParts.find(a=>a.name==="path")?.value,u=i.keyParts.find(a=>a.name==="method")?.value;return!!(o&&o!==n&&o.endsWith(n)&&(!r||r===u))}):!1}function Pe(e,t){for(let n of t){if(n.kind!=="source")continue;let r=V(e,n.relativePath,n.startLine,n.endLine,n.focusLines);r.startLine===n.startLine&&r.endLine===n.endLine||(n.startLine=r.startLine,n.endLine=r.endLine,n.source=U(e,n.relativePath).slice(r.startLine,r.endLine+1).join(`
|
|
2
2
|
`),n.unitStartLine=r.startLine,n.unitEndLine=r.endLine,n.omittedLines=0)}}function Re(e,t){for(let n of t)n.kind==="source"&&(n.bindingClosure=X(e,n.relativePath,n.startLine,n.endLine))}function $e(e,t){let n=new Map;for(let r of t){let i=k(r.relativePath),o=T(r),u=[...r.roles].sort().join(","),a=r.kind==="path"?r.relationship:"",d=`${i}|${o}|${u}|${a}`,s=n.get(d)??[];s.push(r),n.set(d,s)}return[...n.entries()].map(([r,i])=>{let o=i[0],u=f(i.flatMap(d=>[...d.roles])).sort(),a=f(i.flatMap(d=>d.kind==="source"?d.behavior?.signals??[]:[])).sort();return{id:`g-${ue("sha256").update(r).digest("hex").slice(0,8)}`,scope:k(o.relativePath),channel:T(o),roles:u,behaviorSignals:a,candidateUnits:i.length,sourceCharacters:i.reduce((d,s)=>d+(s.kind==="source"?s.source.length:0),0),anchors:i.map(d=>({relativePath:d.relativePath,line:d.kind==="source"?d.focusLine:0,ownerShort:d.kind==="source"?d.ownerShort:null,roles:[...d.roles],behaviorSignals:d.kind==="source"?[...d.behavior?.signals??[]]:[]})),drillCommand:Be(e,i)}}).sort((r,i)=>i.candidateUnits-r.candidateUnits||i.sourceCharacters-r.sourceCharacters||r.scope.localeCompare(i.scope)||r.id.localeCompare(i.id))}function Be(e,t){let n=f(t.flatMap(o=>o.reasons.filter(u=>u.startsWith("search:")).map(u=>u.slice(7)))),r=k(t[0].relativePath);if(n.length>0&&t.every(o=>o.kind==="source"&&o.roles.includes("search"))){let o=["codebaseiq inspect"];for(let u of n)o.push(`--search ${S(u)}`);return o.push(`--scope ${S(r)}`,"--full"),e.view==="behavior"&&o.push("--view behavior"),o.join(" ")}let i=t.filter(o=>o.kind==="source");if(i.length>0&&i.length<=24){let o=["codebaseiq inspect"];for(let u of i)o.push(`--at ${S(`${u.relativePath}:${u.focusLine+1}`)}`);return e.view==="behavior"&&o.push("--view behavior"),o.join(" ")}return t.length===1&&t[0].kind==="path"?t[0].exactFollowup:me(e,!0)}function Me(e,t,n){let r=`search:${e.pattern}`,i=t.filter(a=>a.reasons.includes(r)).length,o=new Set(n),u=t.filter(a=>a.reasons.includes(r)&&o.has(a)).length;return{...e,candidateUnits:i,selectedUnits:u,omittedUnits:i-u}}function Fe(e){let t={};for(let n of e)for(let r of n.roles)t[r]=(t[r]??0)+1;return t}function Oe(e,t,n,r){let i=e.map(u=>O(u,r).channel),o=t.map(u=>O(u,r).channel);return Object.fromEntries(Object.keys(n).map(u=>{let a=i.filter(s=>s===u).length,d=o.filter(s=>s===u).length;return[u,{candidateUnits:a,returnedUnits:d,omittedUnits:a-d,maxUnits:n[u]}]}))}function Te(e){return!!(e&&e.skippedUnreadablePaths.length===0&&e.skippedOversizedPaths.length===0)}function _e(e,t,n){let r=new Map;for(let i of t){let o=k(i.relativePath),u=r.get(o)??{matchingLines:0,returnedMatches:0};u.matchingLines+=i.matchingLines,u.returnedMatches+=i.returnedMatches,r.set(o,u)}return[...r.entries()].map(([i,o])=>({scope:i,...o,exactFollowup:de(e,i||n)})).sort((i,o)=>o.matchingLines-i.matchingLines||o.returnedMatches-i.returnedMatches||i.scope.localeCompare(o.scope))}function k(e){let t=e.lastIndexOf("/");return t<0?e:e.slice(0,t)}function de(e,t){return`codebaseiq inspect --search ${S(e)}${t?` --scope ${S(t)}`:""} --full`}function me(e,t){let n=["codebaseiq inspect"];for(let r of e.searches)n.push(`--search ${S(r)}`);for(let r of e.symbols)n.push(`--symbol ${S(r)}`);for(let r of e.locations)n.push(`--at ${S(r)}`);return e.scope&&n.push(`--scope ${S(e.scope)}`),e.context!==le&&n.push(`--context ${e.context}`),e.evidence.parts&&n.push(`--include ${S(e.evidence.parts.join(","))}`),t&&n.push("--full"),e.view==="behavior"&&n.push("--view behavior"),n.join(" ")}function re(e,t,n,r,i,o,u){I(e,t,{...n,unitType:null,unitStartLine:n.startLine,unitEndLine:n.endLine+n.omittedLines},r,`${r}:${i.shortName}`,n.symbol,n.shortName,o,u,[n.focusLine],i.symbol)}function oe(e,t,n,r,i,o,u,a,d){let s=`${r} -> ${i}`,l=q(e,r).filter(b=>b.sourcePath===i),m=U(e,r),h=Ne(m,l,i),g=h===null?null:J(e,r,h,Math.min(u,4));if(g){I(e,t,{...g,unitType:null,unitStartLine:g.startLine,unitEndLine:g.endLine,omittedLines:0},n,`${n}:${s}`,null,null,a,d,[g.focusLine],o);return}let y=`codebaseiq inspect --search ${S(pe(i))} --scope ${S(r)}`,v=t.find(b=>b.kind==="path"&&b.relativePath===r&&b.relationship===s);if(v){v.roles=f([...v.roles,n]),v.reasons=f([...v.reasons,`${n}:${s}`]),v.symbols=f([...v.symbols,o]),v.priority=Math.min(v.priority,a);return}t.push({kind:"path",roles:[n],relativePath:r,relationship:s,reasons:[`${n}:${s}`],symbols:[o],exactFollowup:y,priority:a,sequence:d})}function Ne(e,t,n){let r=f(t.flatMap(d=>[d.importedName,d.localName??""]).filter(d=>d.length>1)),i=pe(n).replace(/\.[^.]+$/u,""),o=f([...r,i]).filter(Boolean),u=/\b(?:from|import|include|require|use)\b/u,a=e.findIndex(d=>u.test(d)&&o.some(s=>d.includes(s)));return a>=0?a:null}function I(e,t,n,r,i,o,u,a,d,s=[n.focusLine],l){let m=t.find(h=>h.kind==="source"&&h.relativePath===n.relativePath&&h.startLine<=n.endLine&&n.startLine<=h.endLine);if(m){let h=Math.min(m.startLine,n.startLine),g=Math.max(m.endLine,n.endLine);m.startLine=h,m.endLine=g,m.source=U(e,n.relativePath).slice(h,g+1).join(`
|
|
3
3
|
`),m.focusLine=Math.min(m.focusLine,n.focusLine),m.focusLines=ce([...m.focusLines,...s]),m.unitStartLine=Math.min(m.unitStartLine,n.unitStartLine),m.unitEndLine=Math.max(m.unitEndLine,n.unitEndLine),m.omittedLines=Math.max(m.omittedLines,n.omittedLines),m.reasons=f([...m.reasons,i]),m.roles=f([...m.roles,r]),m.symbols=f([...m.symbols,...l?[l]:[]]),!m.ownerSymbol&&o&&(m.ownerSymbol=o),!m.ownerShort&&u&&(m.ownerShort=u),m.priority=Math.min(m.priority,a);return}t.push({kind:"source",...n,reasons:[i],focusLines:ce(s),ownerSymbol:o,ownerShort:u,roles:[r],symbols:l?[l]:[],priority:a,sequence:d})}function Ae(e){if(e.kind==="path"){let{priority:o,sequence:u,...a}=e;return{...a,id:se(a)}}let{priority:t,sequence:n,bindingClosure:r,...i}=e;return{...i,id:se(i),omittedCharacters:0}}function De(e){let{kind:t,id:n,roles:r,symbols:i,omittedCharacters:o,behavior:u,runtimeFacts:a,...d}=e;return d}function se(e){return ue("sha256").update(JSON.stringify(e)).digest("hex").slice(0,16)}function je(e){let t=e.match(/^(.+\.\w+):(\d+)$/u);if(!t)return null;let n=Number(t[2]);return Number.isSafeInteger(n)&&n>0?{path:t[1],line:n}:null}function F(e){return f((e??[]).map(t=>t.trim()).filter(Boolean))}function f(e){return[...new Set(e)]}function ce(e){return f(e).sort((t,n)=>t-n)}function qe(e){return e.length===0?0:e.split(`
|
|
4
4
|
`).length}function he(e,t){if(e.kind==="path")return e.relationship.length+e.exactFollowup.length;let n="bindingClosure"in e?W(e.bindingClosure):0,r=(e.runtimeFacts??[]).reduce((i,o)=>i+o.action.length+o.derivation.rule.length+o.keyParts.reduce((u,a)=>u+a.name.length+a.value.length+4,0)+24,0);return t!=="behavior"?e.source.length+n:e.behavior?e.behavior.lines.reduce((i,o)=>i+o.text.length+o.signals.join(",").length+12,0)+e.behavior.testCases.reduce((i,o)=>i+o.length+2,0)+r+n:e.source.length+n+r}function pe(e){return e.split("/").at(-1)??e}function S(e){return`'${e.replaceAll("'","'\\''")}'`}function C(e,t){if(!Number.isSafeInteger(e)||e<=0)throw new RangeError(`${t} must be a positive safe integer; received ${e}`);return e}function ae(e,t){if(!Number.isSafeInteger(e)||e<0)throw new RangeError(`${t} must be a non-negative safe integer; received ${e}`);return e}export{tn as a};
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
//# sourceMappingURL=chunk-UJIXCI3L.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as x}from"./chunk-
|
|
1
|
+
import{c as x}from"./chunk-BPKNP3KZ.js";import{a as S}from"./chunk-SGMNWYTH.js";import{d as g}from"./chunk-GVAF222T.js";import{b as p}from"./chunk-F74LZWCE.js";import{C as u}from"./chunk-ICUL7XRT.js";import{f as h,g as y}from"./chunk-SX72EVMY.js";function U(e,t,s={}){let n=S(e,t);if(!n)return null;let o=new x(e),a=w(e,n),r=n.endLine-n.startLine+1,i=o.calleeEvidenceMap([n],{additive:!0,semantic:s.semantic}),l=i.rows.get(n.symbolId)??[],c=new Set(l.map(L=>L.symbol)),m=i.incompleteSymbolIds.has(n.symbolId),b=i.unavailableSymbolIds.has(n.symbolId),N=s.semantic===!1?"disabled":m&&b?"incomplete-and-unavailable":m?"incomplete":b?"unavailable":"complete",d=!m&&!b;return{symbol:n.symbol,shortName:g(n.symbol),relativePath:n.relativePath,startLine:n.startLine,endLine:n.endLine,loc:r,branches:a.branches,estimateBasis:a.estimateBasis,cyclomaticEstimate:a.branches+1,calleeCount:d?c.size:null,fanIn:C(e,n.symbolId),fanOut:d?D(l,n.relativePath):null,coverage:{semanticEvidence:N}}}function w(e,t){let s=u(e,t.relativePath);if(s){let n=v(s.rootNode,t.startLine,t.endLine);if(n)return{branches:M(n),estimateBasis:"ast"}}return{branches:P(E(e,t.relativePath,t.startLine,t.endLine),_(e,t.relativePath)),estimateBasis:"regex-fallback"}}function W(e,t){let s=new Map,n=new Map;for(let o of t){let a=n.get(o.relativePath)??[];a.push(o),n.set(o.relativePath,a)}for(let[o,a]of n){let r=u(e,o),i=r===null?[]:a.filter(c=>r.rootNode.startPosition.row<=c.startLine&&r.rootNode.endPosition.row>=c.endLine),l=new Set(i.map(c=>c.symbolId));if(r&&i.length>0){for(let c of i)s.set(c.symbolId,{branches:0,estimateBasis:"ast"});O(r.rootNode,i,s)}for(let c of a)l.has(c.symbolId)||s.set(c.symbolId,I(e,c))}return s}function I(e,t){return{branches:P(E(e,t.relativePath,t.startLine,t.endLine),_(e,t.relativePath)),estimateBasis:"regex-fallback"}}function _(e,t){return e.get("SELECT language FROM documents WHERE relative_path = ?",t)?.language??"unknown"}function E(e,t,s,n){try{return h(e.config.projectRoot,t,{inputKind:"indexed source file"}).split(`
|
|
2
2
|
`).slice(s,n+1).join(`
|
|
3
3
|
`)}catch(o){if(!y(o))throw o;return""}}function C(e,t){return e.get(`SELECT COUNT(DISTINCT c.document_id) AS c
|
|
4
4
|
FROM mentions m
|
|
@@ -13,4 +13,4 @@ import{c as x}from"./chunk-HENP2O4A.js";import{a as S}from"./chunk-SGMNWYTH.js";
|
|
|
13
13
|
WHERE m.symbol_id = ?
|
|
14
14
|
AND m.role != 1
|
|
15
15
|
AND sym_def.document_id != c.document_id`,t)?.c??0}function D(e,t){return new Set(e.filter(s=>s.file!==t).map(s=>s.symbol)).size}function M(e){let t=0;return f(e,s=>{t+=B(s)}),t}function O(e,t,s){let n=[...t].sort((o,a)=>o.startLine-a.startLine||a.endLine-o.endLine);f(e,o=>{let a=B(o);if(a===0)return;let r=o.startPosition.row,i=o.endPosition.row;for(let l of n){if(l.startLine>r)break;if(l.endLine<i)continue;let c=s.get(l.symbolId);c&&(c.branches+=a)}})}function f(e,t){t(e);for(let s of e.namedChildren)f(s,t)}function v(e,t,s){if(e.startPosition.row>t||e.endPosition.row<s)return null;for(let n of e.namedChildren){let o=v(n,t,s);if(o)return o}return e}var F=new Set(["if_statement","conditional_expression","ternary_expression","for_statement","for_in_statement","for_of_statement","while_statement","do_statement","switch_case","case_statement","catch_clause","except_clause","elif_clause","match_arm"]);function B(e){return F.has(e.type)?1:e.type==="binary_expression"&&e.parent?.type!=="binary_expression"&&(e.text.includes("&&")||e.text.includes("||"))?R(e.text):0}function R(e){return(e.match(/&&|\|\|/g)??[]).length}function P(e,t){let s=p(e),n=0,o=[/\bif\b/g,/\belse\s+if\b/g,/\belse\b/g,/\bfor\b/g,/\bwhile\b/g,/\bswitch\b/g,/\bcase\b/g,/\bcatch\b/g,/\?\s*[^?]/g,/&&/g,/\|\|/g];for(let a of o){let r=s.match(a);r&&(n+=r.length)}if(t==="python"){let a=[/\belif\b/g,/\bexcept\b/g,/\bfinally\b/g];for(let r of a){let i=s.match(r);i&&(n+=i.length)}}else if(t==="rust"){let a=[/\bmatch\b/g,/=>/g,/\bloop\b/g];for(let r of a){let i=s.match(r);i&&(n+=i.length)}}else if(t==="ruby"){let a=[/\belsif\b/g,/\bunless\b/g,/\brescue\b/g,/\bwhen\b/g];for(let r of a){let i=s.match(r);i&&(n+=i.length)}}else if(t==="go"){let a=[/\bselect\b/g,/\bdefer\b/g];for(let r of a){let i=s.match(r);i&&(n+=i.length)}}return n}export{U as a,w as b,W as c,M as d};
|
|
16
|
-
//# sourceMappingURL=chunk-
|
|
16
|
+
//# sourceMappingURL=chunk-UMEPSVKT.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{V as Ue,W as Be}from"./chunk-LONKINMJ.js";import{N as ce,O as de,Q as C,R as M,S as N}from"./chunk-6WAPPQ5F.js";import{A as $e,B as je,K as L,P as Fe,l as le,m as Me,ma as Ge,n as I,p as Ne,q as Le,z as W}from"./chunk-MEUHIDI3.js";import{b as E,j as re,k as ie,l as He,m as se,n as _e,p as De,r as ae,s as D}from"./chunk-D7DOB27N.js";import{a as _,c as qe,d as te,e as ne}from"./chunk-6O3KXIDL.js";import{J as y,N as Te,U as Oe,W as oe,X as Pe,Y as k,a as Ie,f as Z,h as f,v as ee,w as x,x as We}from"./chunk-UQYQBLJX.js";import{spawn as Zt}from"child_process";import{existsSync as en,rmSync as rt}from"fs";import{dirname as tn,resolve as V}from"path";import{fileURLToPath as nn}from"url";import{createHash as Lt,randomUUID as ue}from"crypto";import{existsSync as $t,linkSync as jt,readdirSync as Ft,rmSync as w}from"fs";import{basename as Gt,dirname as Ut,join as h}from"path";var S=1,Bt=10*6e4,Vt=10080*6e4,j="requests",T="claims",$="completions",Ke="staging";function Je(e,t,n={}){let r=n.now?.()??new Date,o=zt(n.ttlMs),i=Qt(n.idempotencyKey),s=i?`key-${Lt("sha256").update(i).digest("hex")}`:`request-${(n.randomId??ue)()}`,a={version:S,requestId:s,...i?{idempotencyKey:i}:{},createdAt:r.toISOString(),deadlineAt:new Date(r.getTime()+o).toISOString(),detail:t.trim().slice(0,2048)||"stale index observed by a command"},c=et(e,s),d=he(e,c,a,n.onStage);if(d.published)return{disposition:"accepted",request:a,achievedDurability:d.achievedDurability,directorySync:d.directorySync};let p=pe(c);if(!p)throw new Error(`Watch refresh request identity ${s} exists but is malformed.`);return{disposition:"duplicate",request:p}}function er(e,t={}){let n=t.now?.()??new Date,r=`claim-${(t.randomId??ue)()}`,o=Math.max(1,Math.floor(t.limit??64)),i=Xe(e).sort(Xt),s=[];for(let a of i){if(s.length>=o)break;if(Ve(e,a.requestId))continue;if(Date.parse(a.deadlineAt)<=n.getTime()){Qe(e,{version:S,requestId:a.requestId,outcome:"expired",completedAt:n.toISOString()});continue}let c={version:S,requestId:a.requestId,claimId:r,claimedAt:n.toISOString()};if(he(e,tt(e,a.requestId),c).published){if(Ve(e,a.requestId)){Ye(e,a.requestId,r);continue}s.push(a)}}return{claimId:r,requests:s}}function tr(e,t,n=()=>new Date,r){let o=n().toISOString();for(let i of t.requests)Qe(e,{version:S,requestId:i.requestId,claimId:t.claimId,outcome:"completed",completedAt:o});r?.("after-completion"),Kt(e,t),r?.("after-claim-release")}function Kt(e,t){for(let n of t.requests)Ye(e,n.requestId,t.claimId)}function nr(e){let t=0;for(let n of b(h(e,T)))w(n,{force:!0}),t++;return t>0&&x(h(e,T)),Ze(e),t}function rr(e){let t=Xe(e),n=new Map,r=Jt(h(e,j),pe);for(let c of b(h(e,$))){let d=F(c);if(!d){r++;continue}n.set(d.requestId,d)}let o=new Set;for(let c of b(h(e,T))){let d=ze(c);if(!d){r++;continue}o.add(d.requestId)}let i=t.filter(c=>!n.has(c.requestId)&&!o.has(c.requestId)),s=[...n.values()].filter(c=>c.outcome==="completed").length,a=[...n.values()].filter(c=>c.outcome==="expired").length;return{pending:i.length,claimed:t.filter(c=>!n.has(c.requestId)&&o.has(c.requestId)).length,completed:s,expired:a,invalid:r,...i.length>0?{oldestPendingAt:i.map(c=>c.createdAt).reduce((c,d)=>Yt(c,d))}:{}}}function or(e,t={}){let n=(t.now?.()??new Date).getTime(),r=Math.max(0,t.retentionMs??Vt),o=0;for(let i of b(h(e,$))){let s=F(i);!s||n-Date.parse(s.completedAt)<r||(w(i,{force:!0}),w(et(e,s.requestId),{force:!0}),o++)}return o>0&&(x(h(e,$)),x(h(e,j))),Ze(e),o}function pe(e){return fe(e,t=>{let n=t;return n.version===S&&q(n.requestId)&&(n.idempotencyKey===void 0||typeof n.idempotencyKey=="string")&&E(n.createdAt)&&E(n.deadlineAt)&&Date.parse(n.deadlineAt)>=Date.parse(n.createdAt)&&typeof n.detail=="string"&&n.detail.length>0})}function ze(e){return fe(e,t=>{let n=t;return n.version===S&&q(n.requestId)&&q(n.claimId)&&E(n.claimedAt)})}function F(e){return fe(e,t=>{let n=t;return n.version===S&&q(n.requestId)&&(n.claimId===void 0||q(n.claimId))&&(n.outcome==="completed"||n.outcome==="expired")&&E(n.completedAt)})}function Qe(e,t){let n=nt(e,t.requestId);if(he(e,n,t).published)return;let r=F(n);if(!r||r.requestId!==t.requestId||r.outcome!==t.outcome)throw new Error(`Watch refresh completion ${t.requestId} conflicts with an existing record.`)}function he(e,t,n,r){let o=h(e,Ke),i=Ut(t),s=ee(o),a=ee(i),c=h(o,`${Gt(t)}.${process.pid}.${ue()}.tmp`);try{let d=D(c,n,{spacing:2,trailingNewline:!0});r?.("after-staged");try{jt(c,t)}catch(u){if(u.code==="EEXIST")return{published:!1};throw u}let p=We(s,a,d.directorySync,x(i));return r?.("after-published"),{published:!0,achievedDurability:p==="synced"?"directory-durable":"file-flushed",directorySync:p}}finally{w(c,{force:!0})}}function Xe(e){let t=[];for(let n of b(h(e,j))){let r=pe(n);r&&t.push(r)}return t}function Ye(e,t,n){let r=tt(e,t),o=ze(r);!o||o.claimId!==n||(w(r,{force:!0}),x(h(e,T)))}function Ze(e){for(let t of b(h(e,Ke),".tmp"))w(t,{force:!0})}function Jt(e,t){return b(e).filter(n=>!t(n)).length}function b(e,t=".json"){return $t(e)?Ft(e,{withFileTypes:!0}).filter(n=>n.isFile()&&n.name.endsWith(t)).map(n=>h(e,n.name)).sort():[]}function fe(e,t){try{let n=JSON.parse(f(e,"watch refresh request record"));return t(n)?n:null}catch{return null}}function et(e,t){return h(e,j,`${t}.json`)}function tt(e,t){return h(e,T,`${t}.json`)}function nt(e,t){return h(e,$,`${t}.json`)}function Ve(e,t){return F(nt(e,t))!==null}function zt(e){if(e===void 0)return Bt;if(!Number.isFinite(e)||e<=0)throw new Error("Watch refresh request ttlMs must be positive.");return Math.floor(e)}function Qt(e){let t=e?.trim();return t?t.slice(0,512):void 0}function q(e){return typeof e=="string"&&/^[a-z0-9][a-z0-9-]{0,127}$/i.test(e)}function Xt(e,t){return Date.parse(e.createdAt)-Date.parse(t.createdAt)||e.requestId.localeCompare(t.requestId)}function Yt(e,t){return Date.parse(t)<Date.parse(e)?t:e}var ot=5e3,rn=6e3,on=1e3,ge=10,sn=new Set(["capabilities","check-deps","config-validate","doctor","init","install-skills","reindex","setup","setup-agent","status","suppress","uninstall","watch"]);function Rr(e){let t=e.classification;if(t.kind!=="live")return;let{state:n}=t;return n.watcher.state==="idle"&&n.lastError===void 0?n.indexGeneration:void 0}function an(e,t=process.env){return t.CODEBASEIQ_SKIP_WATCH_SERVICE!=="1"&&!e.startsWith("__")&&!sn.has(e)}function Ar(e){let t=e.env??process.env;if(t.CODEBASEIQ_SKIP_WATCH_SERVICE==="1")return{kind:"skipped",reason:"environment"};if(!an(e.commandName,t))return{kind:"skipped",reason:"excluded-command"};if(e.config.watch?.enabled!==!0)return{kind:"skipped",reason:"disabled"};try{let n=cn({projectRoot:e.projectRoot,cacheDir:e.cacheDir,cliVersion:e.cliVersion,gitContext:e.gitContext,runtime:e.runtime});return{kind:n.disposition,state:n.state}}catch(n){return{kind:"failed",message:n instanceof Error?n.message:String(n)}}}function at(e,t,n){let r=k(V(e));if(n&&k(n.projectRoot)===r)return{projectRoot:r,worktreeKind:"git",worktreeId:n.worktreeId,cliVersion:t};let o=Oe(r);if(o.kind==="error")throw new Error(`Could not establish Git worktree identity for ${r}: ${o.message}`);return o.kind==="non-git"?{projectRoot:r,worktreeKind:"non-git",cliVersion:t}:{projectRoot:r,worktreeKind:"git",worktreeId:o.identity.worktreeId,cliVersion:t}}function Er(e){return U(e,at(e.projectRoot,e.cliVersion,e.gitContext))}function U(e,t){let n=e.runtime??Se,r=C(e.cacheDir),o=M(r.statePath),i=ke(r.lockPath);return{identity:t,classification:dn(o,t,n.now(),n.isProcessAlive),lock:i,lockIsLive:i!==null&&n.isProcessAlive(i.pid),paths:r}}function cn(e){let t=e.runtime??Se,n=at(e.projectRoot,e.cliVersion,e.gitContext),r=U(e,n),o=ye("ensure",r.classification);if(o.kind==="reuse")return G(r.paths.activityPath,t),{disposition:"reused",state:o.state};if(o.kind==="refuse-replace")throw new Error(`codebaseiq watch service pid ${o.state.pid} is still alive but its heartbeat is old. Refusing automatic replacement because civil-clock age alone cannot authorize a process signal.`);if(o.kind==="replace")ve(o.state,e,t),O(r.paths,o.state.pid,t);else if(o.kind==="start"){if(r.lockIsLive){let a=it(e,n,t,Math.min(e.startupTimeoutMs??1e3,1e3));if(a)return G(r.paths.activityPath,t),{disposition:"reused",state:a};throw new Error(`codebaseiq watch is already running for ${V(e.projectRoot)} (pid ${r.lock?.pid}; lock: ${r.paths.lockPath}) without compatible daemon state. Stop the foreground watcher before starting the service.`)}r.classification.kind==="stale"&&O(r.paths,r.classification.state.pid,t)}else throw new Error(`Unexpected ensure action: ${o.kind}`);if(r=U(e,n),o=ye("ensure",r.classification),o.kind==="reuse")return G(r.paths.activityPath,t),{disposition:"reused",state:o.state};if(o.kind==="refuse-replace")throw new Error(`codebaseiq watch service pid ${o.state.pid} remains alive with an old heartbeat; automatic replacement is not authorized.`);let i=e.serverPath??nn(new URL("./watch-server.js",import.meta.url));t.spawnServer(i,n.projectRoot,e.cliVersion,e.watchOverrides??{},e.spawnEnv);let s=it(e,n,t,e.startupTimeoutMs??ot);if(!s)throw new Error(`codebaseiq watch service did not become ready within ${e.startupTimeoutMs??ot}ms.`);return G(r.paths.activityPath,t),{disposition:"started",state:s}}function Cr(e){let t=e.runtime??Se,n=C(e.cacheDir),r=M(n.statePath),o=r?t.isProcessAlive(r.pid)?{kind:"live",state:r}:{kind:"stale",state:r,reason:"dead-process"}:{kind:"stopped"},i=ye("stop",o);if(i.kind==="signal-stop")return ve(i.state,e,t),O(n,i.state.pid,t),{disposition:"stopped",pid:i.state.pid};if(i.kind==="clean-stale")return O(n,i.state.pid,t),{disposition:"stopped",pid:i.state.pid};let s=ke(n.lockPath);return i.kind==="already-stopped"&&s&&t.isProcessAlive(s.pid)?(ve(s,e,t),O(n,s.pid,t),{disposition:"stopped",pid:s.pid}):{disposition:"already-stopped"}}function Ir(e,t,n={}){let{durability:r="durable",...o}=n;r==="durable"?D(e,t,o):ae(e,t,o)}function ct(e,t=Date.now()){ae(e,{version:1,at:new Date(t).toISOString()})}function Wr(e,t,n=Date.now(),r={}){Je(C(tn(e)).refreshRequestsPath,t,{...r,now:()=>new Date(n)}),ct(e,n)}function Tr(e){try{let t=JSON.parse(f(e,"watch activity record"));return t.version!==1||!N(t.at)||t.refreshRequestedAt!==void 0&&!N(t.refreshRequestedAt)||t.refreshDetail!==void 0&&typeof t.refreshDetail!="string"?null:{atMs:Date.parse(t.at),...t.refreshRequestedAt===void 0?{}:{refreshRequestedAtMs:Date.parse(t.refreshRequestedAt)},...t.refreshDetail===void 0?{}:{refreshDetail:t.refreshDetail}}}catch{return null}}function qr(e,t,n={}){let r=n.pid??process.pid,o=n.isProcessAlive??re,i=()=>{},s=n.readProcessIdentity??ne,a=n.now??(()=>new Date),c={...ie,wallNow:()=>a().getTime(),isProcessAlive:o,readProcessIdentity:s},d=He(e,{kind:"watch",pid:r,processIdentity:s(r),detail:{projectRoot:V(t)},parseLegacy:B,runtime:c});if(d.kind==="contended"){let p=dt(d.observation);return{acquired:!1,lockPath:e,message:ln(e,t,p),release:i}}return{acquired:!0,lockPath:e,message:"",release:()=>{d.lock.release()}}}function ke(e){return dt(se(e,{parseLegacy:B}))}var B=e=>{let t=lt(e);return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function dt(e){if(e.state==="valid"&&e.record?.kind==="watch"){let t=e.record.detail?.projectRoot;return typeof t!="string"?null:{version:1,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},projectRoot:t,startedAt:e.record.startedAt}}return lt(e.parsed)}function lt(e){try{let t=e;if(t.version!==1||typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0||typeof t.projectRoot!="string"||!N(t.startedAt))return null;let n=t.processIdentity===void 0?null:qe(t.processIdentity);return t.processIdentity!==void 0&&(!n||n.pid!==t.pid)?null:{version:1,pid:t.pid,...n?{processIdentity:n}:{},projectRoot:t.projectRoot,startedAt:t.startedAt}}catch{return null}}function dn(e,t,n,r){if(!e)return{kind:"stopped"};if(e.protocolVersion!==ce)return{kind:"incompatible",state:e,reason:"protocol"};if(e.projectRoot!==t.projectRoot)return{kind:"incompatible",state:e,reason:"project"};let o=t.worktreeKind==="git"?t.worktreeId:void 0;if(e.worktreeId!==o)return{kind:"incompatible",state:e,reason:"worktree"};if(e.cliVersion!==t.cliVersion)return{kind:"incompatible",state:e,reason:"cli-version"};if(!r(e.pid))return{kind:"stale",state:e,reason:"dead-process"};let i=Date.parse(e.heartbeatAt);return n-i>de?{kind:"stale",state:e,reason:"old-heartbeat"}:{kind:"live",state:e}}function ye(e,t){switch(e){case"status":return{kind:"report",classification:t};case"ensure":switch(t.kind){case"stopped":return{kind:"start"};case"stale":return t.reason==="old-heartbeat"?{kind:"refuse-replace",state:t.state,reason:"old-heartbeat"}:{kind:"start"};case"live":return{kind:"reuse",state:t.state};case"incompatible":return{kind:"replace",state:t.state};default:return me(t)}case"stop":switch(t.kind){case"stopped":return{kind:"already-stopped"};case"stale":return t.reason==="old-heartbeat"?{kind:"signal-stop",state:t.state}:{kind:"clean-stale",state:t.state};case"live":case"incompatible":return{kind:"signal-stop",state:t.state};default:return me(t)}default:return me(e)}}function Or(e){return e.idleTimeoutMs===0||e.watcher.state!=="idle"||(e.liveSessions??0)>0?!1:e.nowMs-e.lastActivityAtMs>=e.idleTimeoutMs}function it(e,t,n,r){let o=n.monotonicNow??_,i=o()+r;for(;o()<=i;){let s=U(e,t).classification;if(s.kind==="live")return s.state;n.sleep(ge)}return null}function ve(e,t,n){let{pid:r}=e;if(!n.isProcessAlive(r))return;st(e,n),n.signalProcess(r);let o=t.stopTimeoutMs??rn,i=n.monotonicNow??_,s=i()+o;for(;i()<=s;){if(!n.isProcessAlive(r))return;n.sleep(ge)}if(!n.forceSignalProcess)throw new Error(`codebaseiq watch service pid ${r} did not stop within ${o}ms and forced termination is unavailable.`);st(e,n),n.forceSignalProcess(r);let a=t.forceStopTimeoutMs??on,c=i()+a;for(;i()<=c;){if(!n.isProcessAlive(r))return;let d=n.readProcessIdentity(r);if(e.processIdentity&&d&&!te(e.processIdentity,d))return;n.sleep(ge)}throw new Error(`codebaseiq watch service pid ${r} remained alive ${a}ms after forced termination.`)}function O(e,t,n){if(rt(e.statePath,{force:!0}),rt(e.activityPath,{force:!0}),ke(e.lockPath)?.pid===t&&!n.isProcessAlive(t)){let o={...ie,wallNow:n.now,isProcessAlive:n.isProcessAlive,readProcessIdentity:n.readProcessIdentity},i=se(e.lockPath,{parseLegacy:B,runtime:o});_e(e.lockPath,i,{parseLegacy:B,runtime:o})}}function ln(e,t,n){return`error: codebaseiq watch is already running for ${V(t)}${n?` (pid ${n.pid}, started ${n.startedAt}; lock: ${e})`:` (lock: ${e})`}. Stop that watcher before starting another.`}function G(e,t){try{(t.recordActivity??ct)(e,t.now())}catch(n){let r=un(n);if(r!=="EPERM"&&r!=="EACCES"&&r!=="EROFS")throw n}}function un(e){return e.code}var Se={now:Date.now,monotonicNow:_,isProcessAlive:re,readProcessIdentity:ne,spawnServer(e,t,n,r,o){if(!en(e))throw new Error(`Watch service helper was not found at ${e}. Run npm run build first.`);Zt(process.execPath,[e,t,n,JSON.stringify(r)],{detached:!0,stdio:"ignore",windowsHide:!0,env:{...process.env,...o,CODEBASEIQ_SKIP_WATCH_SERVICE:"1"}}).unref()},signalProcess(e){process.kill(e,"SIGTERM")},forceSignalProcess(e){process.kill(e,"SIGKILL")},sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)}};function st(e,t){if(!e.processIdentity)throw new Error(`Refusing to signal codebaseiq watch pid ${e.pid}: its ownership record has no process identity.`);let n=t.readProcessIdentity(e.pid);if(!n)throw new Error(`Refusing to signal codebaseiq watch pid ${e.pid}: its process identity is unavailable.`);if(!te(e.processIdentity,n))throw new Error(`Refusing to signal codebaseiq watch pid ${e.pid}: its process identity does not match the ownership record.`)}function me(e){throw new Error(`Unhandled watch service value: ${JSON.stringify(e)}`)}import{existsSync as m,mkdirSync as pn,rmdirSync as hn,unlinkSync as fn}from"fs";import{homedir as mn}from"os";import{basename as vt,dirname as Q,isAbsolute as gn,join as l,resolve as xe}from"path";import{fileURLToPath as yn}from"url";var ut=["- `codebaseiq search <exact-text>` \u2014 Where does this exact text occur in current project text, and which aligned compiler symbol owns each line? Requires: One exact text literal or deliberately bounded regular expression; insert `--` before a literal that starts with a dash.","- `codebaseiq outline <file>` \u2014 What symbols and nesting exist in this file? Requires: One exact current project file path.","- `codebaseiq entrypoints [text]` \u2014 Which detected external roots or entry-surface candidates match this text? Requires: Optional exact text to filter candidates; otherwise the current indexed repository.","- `codebaseiq evidence` \u2014 Which exact execution, runtime, data, state, temporal, contract, identity, ownership, or dependency relationships surround these referents? Which related source must be read only when graph evidence leaves a named implementation gap? Requires: One or more exact symbol, file:line, or literal roots plus explicit family, direction, depth, and output bound.","- `codebaseiq inspect` \u2014 Which related source units across several known text, symbol, or location anchors should be read together? Requires: One or more exact text, symbol, or file:line selectors naming the unresolved behavior.","- `codebaseiq code <selectors...>` \u2014 What exact source defines these symbols, ranges, or file surfaces? Requires: One or more exact symbols, file:line ranges, or file paths.","- Choose graph controls explicitly: `execution incoming` \u2014 Who can call or reach this?; `execution outgoing` \u2014 What can this call or reach?; `dataflow incoming` \u2014 Where can this value come from?; `dataflow outgoing` \u2014 Where can this value go?; `runtime both` \u2014 Which producer and consumer rendezvous?; `state both` \u2014 What resource is observed or changed?; `temporal both` \u2014 What occurs before or after this?; `contract both` \u2014 What interface constrains this?; `identity both` \u2014 Are these observations the same entity?; `ownership both` \u2014 What contains or owns this?; `dependencies outgoing` \u2014 What does this statically rely on?. The CLI does not infer them from English intent.","- Calibration: exact is directly observed; derived is deterministically computed; candidate needs confirmation; mixed discloses its constituents; unknown cannot support a stronger claim. Read coverage and recovery before making absence claims.","- The controls above are complete for ordinary exploration. Run `codebaseiq capabilities --matrix` only when a named claim depends on uncertain provider support; do not run it for routine orientation."],_r=[{stage:"locate",id:"search",command:"search <exact-text>",question:"Where does this exact text occur in current project text, and which aligned compiler symbol owns each line?",requiredInput:"One exact text literal or deliberately bounded regular expression; insert `--` before a literal that starts with a dash.",returnedFact:"exact cardinality, bounded identities and source, and scope commands that recover withheld matches",evidenceCeiling:"Exact current-text cardinality and locations within reported text coverage; compiler ownership only where aligned.",nonClaim:"Structural source ranking orders exact matches but does not establish task relevance. A literal co-occurrence does not establish a graph relationship.",outputCost:"small",contrasts:["outline: search locates exact text across files; outline enumerates compiler-owned constructs in one known file."],gapClosingCommands:["evidence","inspect","code"]},{stage:"locate",id:"outline",command:"outline <file>",question:"What symbols and nesting exist in this file?",requiredInput:"One exact current project file path.",returnedFact:"symbol names, nesting, and line ranges",evidenceCeiling:"Exact compiler-owned constructs and ranges when the file is indexed; no invented semantic overlay.",nonClaim:"File ownership and nesting do not establish execution or task relevance.",outputCost:"small",contrasts:["search: outline enumerates constructs in one known file; search locates exact text across current project text.","code: outline returns identities and ranges; code materializes exact source for selected identities."],gapClosingCommands:["evidence","inspect","code"]},{stage:"locate",id:"entrypoints",command:"entrypoints [text]",question:"Which detected external roots or entry-surface candidates match this text?",requiredInput:"Optional exact text to filter candidates; otherwise the current indexed repository.",returnedFact:"entry symbols with files, confidence, evidence, and indexed caller counts",evidenceCeiling:"Source/compiler-grounded entry evidence and indexed caller counts; exported-only candidates remain candidates.",nonClaim:"A package-public export or zero indexed callers is an entry candidate, not proof of runtime ingress. Entry classification does not establish that the callable executes.",outputCost:"bounded",contrasts:["entry-map: entrypoints locates possible external roots; entry-map traverses static calls from one selected root.","search: entrypoints classifies callable roots; search only locates exact text and ownership."],gapClosingCommands:["evidence","inspect","code"]},{stage:"project",id:"evidence",command:"evidence",question:"Which exact execution, runtime, data, state, temporal, contract, identity, ownership, or dependency relationships surround these referents? Which related source must be read only when graph evidence leaves a named implementation gap?",requiredInput:"One or more exact symbol, file:line, or literal roots plus explicit family, direction, depth, and output bound.",returnedFact:"batched exact selectors and typed graph relationships; compact endpoints with exact locations and follow-up commands; coverage and recoverable omissions; exact source-recovery command when source was requested with a graph projection; explicit ambiguity failure with exact rerun commands",evidenceCeiling:"Typed edges only to each registered provider ceiling within the explicitly selected projection and reported coverage.",nonClaim:"The projection does not infer which relationships are relevant to the user task. Reference, dependency, data, state, temporal, contract, and identity edges do not become execution claims.",outputCost:"bounded",contrasts:["refs: refs enumerates direct reference sites; evidence traverses explicitly selected typed relationships.","call-graph: call-graph specializes in static calls; evidence can combine execution with other selected families.","value-flow: value-flow specializes in proved transfers; evidence projects bounded dataflow alongside other families.","dependence-slice: dependence-slice computes a program-dependence slice; evidence performs bounded graph projection."],gapClosingCommands:["inspect","code"]},{stage:"read",id:"inspect",command:"inspect",question:"Which related source units across several known text, symbol, or location anchors should be read together?",requiredInput:"One or more exact text, symbol, or file:line selectors naming the unresolved behavior.",returnedFact:"one ranked, deduplicated semantic packet plus exact selector cardinality and explicit expansion coverage",evidenceCeiling:"Complete current source for every materialized syntax unit; bounded selector and packet coverage remain explicit.",nonClaim:"A source packet does not choose which implementation details are relevant to the user task. A reference mention does not establish executable reachability.",outputCost:"potentially-large",contrasts:["code: inspect batches bounded behavior or source gaps; code materializes complete exact source.","evidence: inspect reads implementation units; evidence projects typed relationships without source."],gapClosingCommands:[]},{stage:"read",id:"code",command:"code <selectors...>",question:"What exact source defines these symbols, ranges, or file surfaces?",requiredInput:"One or more exact symbols, file:line ranges, or file paths.",returnedFact:"per-selector resolution, complete definition source, exact ranges with statically attributed same-file call closure, file export surfaces, omitted-local ledgers, and line ranges",evidenceCeiling:"Exact current source bytes for every resolved selector, with omitted file-local constructs disclosed.",nonClaim:"Source materialization does not establish callers, runtime reachability, or task relevance by itself.",outputCost:"potentially-large",contrasts:["inspect: code materializes complete exact source; inspect batches bounded behavior or source gaps.","outline: code reads selected implementations; outline enumerates file structure without reading every body."],gapClosingCommands:[]}];var g="<!-- codebaseiq:agent-setup:begin -->",R="<!-- codebaseiq:agent-setup:end -->",vn="# codebaseiq:agent-setup",X=[".codex/hooks.json",".claude/settings.local.json"],pt="# codebaseiq:local-agent-hooks:begin",ht="# codebaseiq:local-agent-hooks:end",we="hook-architecture-stop",kt=["claude","codex"],P={claude:".claude/settings.local.json",codex:".codex/hooks.json"},St="sentinel-hook.mjs",kn=l("dist","sentinel-hook.js"),Sn=l("dist","cli.js"),bn="cli-path",xn="installed-projects.json";function Yr(e){let t=e.written.length+e.unchanged.length,n=e.skipped.length;return{verdict:n===0?"ready":t===0?"blocked":"partial",ready:t,skipped:n}}function Zr(e,t={}){let n={written:[],unchanged:[],skipped:[]};return wn(e,n),t.architectureHook!==!1&&En(e,n,t.architectureHook),n}function eo(e,t={}){let n={removed:[],unchanged:[],skipped:[]};return mt(e,"AGENTS.md",t,n),mt(e,"CLAUDE.md",t,n),xt(e,t,n,r=>Ot(Wn(r))),qt(e,t,n),An(e,t,n),n}function wn(e,t){let n=[g,"## codebaseiq","","This repository uses codebaseiq as its primary code exploration surface.","","codebaseiq separates two responsibilities: the agent decides what repository fact it needs, while the tool locates exact referents and reports compiler, runtime, data, state, temporal, contract, identity, ownership, and dependency evidence without guessing task relevance. The ordinary loop is locate an exact root, project explicitly chosen relationships, read behavior only for a named remaining gap, then stop when the requested claims are established.","","- Use codebaseiq for repository exploration, including literal search and exact source reads. Native tools are for applying edits, running checks, binary content, or a specific unsupported gap that codebaseiq has explicitly reported\u2014not a parallel exploration workflow.","- Before exploring, state the few material repository facts the answer depends on. Include behavior-changing predicates, authorization checks, data reshaping, hard bounds, runtime crossings, durable state changes, emitted notifications, returned values, relevant sibling outcomes, and externally visible ordering only when the request depends on them.","- For end-to-end explanations, use the installed codebaseiq-explore guidance to maintain the evidence ledger and audit the final answer; codebaseiq supplies the repository observations.",...ut,"- Any exact symbol or `file:line` returned by a locator is immediately usable as a graph root. There is no required anchor-discovery phase and locator ordering never proves task relevance. For an end-to-end question, include the initiating owner as a root or request incoming execution capable of exposing it; do not assume a core type is the ingress. Locate independent roots together when the question already implies several participants.","- A materialized evidence projection requires repeated `--symbol`, `--at`, or `--search` selectors plus one or more repeated `--edge <family>` flags, explicit `--direction incoming|outgoing|both`, `--depth <n>`, and `--max-edges <n>`. The agent chooses the relationships capable of establishing its claim; the CLI resolves identity, direction, evidence strength, provider support, and coverage. Use optional exact `--subtype <subtype>` and `--connecting` only when the selected roots themselves must be connected. Never request `complete`, `all`, or every family merely to discover what exists; use `--inventory-only` when only counts can determine the next bounded projection.","- Treat execution calls and exact runtime handoffs as executable reachability. Dataflow, state, temporal, contract, identity, ownership, and dependency edges say what a path carries, changes, orders, constrains, identifies, contains, or relies on; they do not become call claims. Treat exact edges as facts only within their stated coverage and candidate edges as leads requiring source confirmation.","- Read every packet as a coverage contract. `accounted` means the requested bounded projection reports every omission; `bounded` means requested edges were placed in stable recoverable folds by the output budget; `incomplete` means a selector or provider could not be resolved. None proves the user task complete, and missing output is no evidence of absence.","- Prefer batched locators, projections, and gap reads. Query count measures exploration efficiency; it never makes a known recoverable material fact optional. Before drilling down, name the still-missing fact. Expand only a printed fold or exact adjacent identity that can establish it; batch independent roots and gaps instead of shuttling between abstraction levels, and repeat only while a named fact remains unresolved.","- Use `codebaseiq inspect --symbol <symbol> --symbol <symbol> --at <file:line> --view behavior` for several named behavioral gaps. Connected behavior is already source evidence; do not reread lines it rendered. Use `codebaseiq code <symbol-or-range>` only when exact implementation syntax can change the decision. Do not replace these reads with `rg`, `grep`, `sed`, or `nl`.","- For a multi-step mutation, preserve later compaction, rollback, and cleanup. For every event, log, or outbox write, preserve its operation and record identity. For coordination, state the lock scope and which checks and writes occur inside it. State whether interruption is prevented, atomic, rolled back, or repaired later. Resolve exact constant values when they can change the answer.","- For a tiered policy or dispatcher, preserve the precedence of its tiers and the exact scope of every bypass; never imply that a later bypass can skip an earlier hard rejection unless the rendered condition proves it.","- For a stateful owner, preserve its lifetime and sharing scope, including whether it is a singleton, shared registry, per-session instance, or per-invocation value.","- Use `codebaseiq diff-impact` to map changed symbols and downstream consumers after a nontrivial edit.","- Use `codebaseiq architecture` to inspect explicit structural rules.","- Use `codebaseiq health` to find React, Vue, duplication, complexity, drift, and cleanup candidates.","- Before claiming a complete relationship set or an absence, inspect coverage and use `--full` only when complete coverage can change the decision. A bounded or unsupported result cannot establish that no caller, route, branch, poller, or consumer exists.","- Before claiming what every callsite passes, read the `trace` or `evidence` claim-support section. Only an eligible callsite-argument claim is backed by complete syntactic invocations; bounded context is not proof.","- Prefer human output for agent reading. Use `--json --result-only` only for a programmatic consumer.","- Never rerun a successful human command as JSON. Before each drilldown, name the still-unanswered fact and check whether an earlier packet already establishes it; if so, update the ledger or draft without another query. Stop when no unanswered fact remains because every additional reasoning step pays again for the accumulated context.","- Before answering, compare the draft to selected statement-complete behavior. Preserve every material behavior-changing predicate, returned default, separately merged field, cache invalidation, and cleanup effect. Do not collapse fields with different operations into a generic summary, and do not re-query evidence already in context.","- With an explicit CODEBASEIQ_SESSION, a complete source unit, a byte-identical exact subset of a prior exact source read, or a graph unit/edge may be replaced by a visible receipt from the same index generation. Preview coverage never suppresses an exact unit; changed bytes, changed graph content, a new generation, or --reemit force full evidence.","- If output emits `Continue exactly:`, run that command unchanged until transport is complete.","- When architecture rules are configured and clean, setup installs one checkout-local Stop hook. It checks architecture only after indexed source changes.","- Commit relevant `.codebaseiq/suppressions/*.json` records with the change. Do not commit local agent-tool settings.",R].join(`
|
|
1
|
+
import{V as Ue,W as Be}from"./chunk-JNXI6NQ7.js";import{N as ce,O as de,Q as C,R as M,S as N}from"./chunk-K4S2VH42.js";import{A as $e,B as je,K as L,P as Fe,l as le,m as Me,ma as Ge,n as I,p as Ne,q as Le,z as W}from"./chunk-MEUHIDI3.js";import{b as E,j as re,k as ie,l as He,m as se,n as _e,p as De,r as ae,s as D}from"./chunk-D7DOB27N.js";import{a as _,c as qe,d as te,e as ne}from"./chunk-6O3KXIDL.js";import{J as y,N as Te,U as Oe,W as oe,X as Pe,Y as k,a as Ie,f as Z,h as f,v as ee,w as x,x as We}from"./chunk-UQYQBLJX.js";import{spawn as Zt}from"child_process";import{existsSync as en,rmSync as rt}from"fs";import{dirname as tn,resolve as V}from"path";import{fileURLToPath as nn}from"url";import{createHash as Lt,randomUUID as ue}from"crypto";import{existsSync as $t,linkSync as jt,readdirSync as Ft,rmSync as w}from"fs";import{basename as Gt,dirname as Ut,join as h}from"path";var S=1,Bt=10*6e4,Vt=10080*6e4,j="requests",T="claims",$="completions",Ke="staging";function Je(e,t,n={}){let r=n.now?.()??new Date,o=zt(n.ttlMs),i=Qt(n.idempotencyKey),s=i?`key-${Lt("sha256").update(i).digest("hex")}`:`request-${(n.randomId??ue)()}`,a={version:S,requestId:s,...i?{idempotencyKey:i}:{},createdAt:r.toISOString(),deadlineAt:new Date(r.getTime()+o).toISOString(),detail:t.trim().slice(0,2048)||"stale index observed by a command"},c=et(e,s),d=he(e,c,a,n.onStage);if(d.published)return{disposition:"accepted",request:a,achievedDurability:d.achievedDurability,directorySync:d.directorySync};let p=pe(c);if(!p)throw new Error(`Watch refresh request identity ${s} exists but is malformed.`);return{disposition:"duplicate",request:p}}function er(e,t={}){let n=t.now?.()??new Date,r=`claim-${(t.randomId??ue)()}`,o=Math.max(1,Math.floor(t.limit??64)),i=Xe(e).sort(Xt),s=[];for(let a of i){if(s.length>=o)break;if(Ve(e,a.requestId))continue;if(Date.parse(a.deadlineAt)<=n.getTime()){Qe(e,{version:S,requestId:a.requestId,outcome:"expired",completedAt:n.toISOString()});continue}let c={version:S,requestId:a.requestId,claimId:r,claimedAt:n.toISOString()};if(he(e,tt(e,a.requestId),c).published){if(Ve(e,a.requestId)){Ye(e,a.requestId,r);continue}s.push(a)}}return{claimId:r,requests:s}}function tr(e,t,n=()=>new Date,r){let o=n().toISOString();for(let i of t.requests)Qe(e,{version:S,requestId:i.requestId,claimId:t.claimId,outcome:"completed",completedAt:o});r?.("after-completion"),Kt(e,t),r?.("after-claim-release")}function Kt(e,t){for(let n of t.requests)Ye(e,n.requestId,t.claimId)}function nr(e){let t=0;for(let n of b(h(e,T)))w(n,{force:!0}),t++;return t>0&&x(h(e,T)),Ze(e),t}function rr(e){let t=Xe(e),n=new Map,r=Jt(h(e,j),pe);for(let c of b(h(e,$))){let d=F(c);if(!d){r++;continue}n.set(d.requestId,d)}let o=new Set;for(let c of b(h(e,T))){let d=ze(c);if(!d){r++;continue}o.add(d.requestId)}let i=t.filter(c=>!n.has(c.requestId)&&!o.has(c.requestId)),s=[...n.values()].filter(c=>c.outcome==="completed").length,a=[...n.values()].filter(c=>c.outcome==="expired").length;return{pending:i.length,claimed:t.filter(c=>!n.has(c.requestId)&&o.has(c.requestId)).length,completed:s,expired:a,invalid:r,...i.length>0?{oldestPendingAt:i.map(c=>c.createdAt).reduce((c,d)=>Yt(c,d))}:{}}}function or(e,t={}){let n=(t.now?.()??new Date).getTime(),r=Math.max(0,t.retentionMs??Vt),o=0;for(let i of b(h(e,$))){let s=F(i);!s||n-Date.parse(s.completedAt)<r||(w(i,{force:!0}),w(et(e,s.requestId),{force:!0}),o++)}return o>0&&(x(h(e,$)),x(h(e,j))),Ze(e),o}function pe(e){return fe(e,t=>{let n=t;return n.version===S&&q(n.requestId)&&(n.idempotencyKey===void 0||typeof n.idempotencyKey=="string")&&E(n.createdAt)&&E(n.deadlineAt)&&Date.parse(n.deadlineAt)>=Date.parse(n.createdAt)&&typeof n.detail=="string"&&n.detail.length>0})}function ze(e){return fe(e,t=>{let n=t;return n.version===S&&q(n.requestId)&&q(n.claimId)&&E(n.claimedAt)})}function F(e){return fe(e,t=>{let n=t;return n.version===S&&q(n.requestId)&&(n.claimId===void 0||q(n.claimId))&&(n.outcome==="completed"||n.outcome==="expired")&&E(n.completedAt)})}function Qe(e,t){let n=nt(e,t.requestId);if(he(e,n,t).published)return;let r=F(n);if(!r||r.requestId!==t.requestId||r.outcome!==t.outcome)throw new Error(`Watch refresh completion ${t.requestId} conflicts with an existing record.`)}function he(e,t,n,r){let o=h(e,Ke),i=Ut(t),s=ee(o),a=ee(i),c=h(o,`${Gt(t)}.${process.pid}.${ue()}.tmp`);try{let d=D(c,n,{spacing:2,trailingNewline:!0});r?.("after-staged");try{jt(c,t)}catch(u){if(u.code==="EEXIST")return{published:!1};throw u}let p=We(s,a,d.directorySync,x(i));return r?.("after-published"),{published:!0,achievedDurability:p==="synced"?"directory-durable":"file-flushed",directorySync:p}}finally{w(c,{force:!0})}}function Xe(e){let t=[];for(let n of b(h(e,j))){let r=pe(n);r&&t.push(r)}return t}function Ye(e,t,n){let r=tt(e,t),o=ze(r);!o||o.claimId!==n||(w(r,{force:!0}),x(h(e,T)))}function Ze(e){for(let t of b(h(e,Ke),".tmp"))w(t,{force:!0})}function Jt(e,t){return b(e).filter(n=>!t(n)).length}function b(e,t=".json"){return $t(e)?Ft(e,{withFileTypes:!0}).filter(n=>n.isFile()&&n.name.endsWith(t)).map(n=>h(e,n.name)).sort():[]}function fe(e,t){try{let n=JSON.parse(f(e,"watch refresh request record"));return t(n)?n:null}catch{return null}}function et(e,t){return h(e,j,`${t}.json`)}function tt(e,t){return h(e,T,`${t}.json`)}function nt(e,t){return h(e,$,`${t}.json`)}function Ve(e,t){return F(nt(e,t))!==null}function zt(e){if(e===void 0)return Bt;if(!Number.isFinite(e)||e<=0)throw new Error("Watch refresh request ttlMs must be positive.");return Math.floor(e)}function Qt(e){let t=e?.trim();return t?t.slice(0,512):void 0}function q(e){return typeof e=="string"&&/^[a-z0-9][a-z0-9-]{0,127}$/i.test(e)}function Xt(e,t){return Date.parse(e.createdAt)-Date.parse(t.createdAt)||e.requestId.localeCompare(t.requestId)}function Yt(e,t){return Date.parse(t)<Date.parse(e)?t:e}var ot=5e3,rn=6e3,on=1e3,ge=10,sn=new Set(["capabilities","check-deps","config-validate","doctor","init","install-skills","reindex","setup","setup-agent","status","suppress","uninstall","watch"]);function Rr(e){let t=e.classification;if(t.kind!=="live")return;let{state:n}=t;return n.watcher.state==="idle"&&n.lastError===void 0?n.indexGeneration:void 0}function an(e,t=process.env){return t.CODEBASEIQ_SKIP_WATCH_SERVICE!=="1"&&!e.startsWith("__")&&!sn.has(e)}function Ar(e){let t=e.env??process.env;if(t.CODEBASEIQ_SKIP_WATCH_SERVICE==="1")return{kind:"skipped",reason:"environment"};if(!an(e.commandName,t))return{kind:"skipped",reason:"excluded-command"};if(e.config.watch?.enabled!==!0)return{kind:"skipped",reason:"disabled"};try{let n=cn({projectRoot:e.projectRoot,cacheDir:e.cacheDir,cliVersion:e.cliVersion,gitContext:e.gitContext,runtime:e.runtime});return{kind:n.disposition,state:n.state}}catch(n){return{kind:"failed",message:n instanceof Error?n.message:String(n)}}}function at(e,t,n){let r=k(V(e));if(n&&k(n.projectRoot)===r)return{projectRoot:r,worktreeKind:"git",worktreeId:n.worktreeId,cliVersion:t};let o=Oe(r);if(o.kind==="error")throw new Error(`Could not establish Git worktree identity for ${r}: ${o.message}`);return o.kind==="non-git"?{projectRoot:r,worktreeKind:"non-git",cliVersion:t}:{projectRoot:r,worktreeKind:"git",worktreeId:o.identity.worktreeId,cliVersion:t}}function Er(e){return U(e,at(e.projectRoot,e.cliVersion,e.gitContext))}function U(e,t){let n=e.runtime??Se,r=C(e.cacheDir),o=M(r.statePath),i=ke(r.lockPath);return{identity:t,classification:dn(o,t,n.now(),n.isProcessAlive),lock:i,lockIsLive:i!==null&&n.isProcessAlive(i.pid),paths:r}}function cn(e){let t=e.runtime??Se,n=at(e.projectRoot,e.cliVersion,e.gitContext),r=U(e,n),o=ye("ensure",r.classification);if(o.kind==="reuse")return G(r.paths.activityPath,t),{disposition:"reused",state:o.state};if(o.kind==="refuse-replace")throw new Error(`codebaseiq watch service pid ${o.state.pid} is still alive but its heartbeat is old. Refusing automatic replacement because civil-clock age alone cannot authorize a process signal.`);if(o.kind==="replace")ve(o.state,e,t),O(r.paths,o.state.pid,t);else if(o.kind==="start"){if(r.lockIsLive){let a=it(e,n,t,Math.min(e.startupTimeoutMs??1e3,1e3));if(a)return G(r.paths.activityPath,t),{disposition:"reused",state:a};throw new Error(`codebaseiq watch is already running for ${V(e.projectRoot)} (pid ${r.lock?.pid}; lock: ${r.paths.lockPath}) without compatible daemon state. Stop the foreground watcher before starting the service.`)}r.classification.kind==="stale"&&O(r.paths,r.classification.state.pid,t)}else throw new Error(`Unexpected ensure action: ${o.kind}`);if(r=U(e,n),o=ye("ensure",r.classification),o.kind==="reuse")return G(r.paths.activityPath,t),{disposition:"reused",state:o.state};if(o.kind==="refuse-replace")throw new Error(`codebaseiq watch service pid ${o.state.pid} remains alive with an old heartbeat; automatic replacement is not authorized.`);let i=e.serverPath??nn(new URL("./watch-server.js",import.meta.url));t.spawnServer(i,n.projectRoot,e.cliVersion,e.watchOverrides??{},e.spawnEnv);let s=it(e,n,t,e.startupTimeoutMs??ot);if(!s)throw new Error(`codebaseiq watch service did not become ready within ${e.startupTimeoutMs??ot}ms.`);return G(r.paths.activityPath,t),{disposition:"started",state:s}}function Cr(e){let t=e.runtime??Se,n=C(e.cacheDir),r=M(n.statePath),o=r?t.isProcessAlive(r.pid)?{kind:"live",state:r}:{kind:"stale",state:r,reason:"dead-process"}:{kind:"stopped"},i=ye("stop",o);if(i.kind==="signal-stop")return ve(i.state,e,t),O(n,i.state.pid,t),{disposition:"stopped",pid:i.state.pid};if(i.kind==="clean-stale")return O(n,i.state.pid,t),{disposition:"stopped",pid:i.state.pid};let s=ke(n.lockPath);return i.kind==="already-stopped"&&s&&t.isProcessAlive(s.pid)?(ve(s,e,t),O(n,s.pid,t),{disposition:"stopped",pid:s.pid}):{disposition:"already-stopped"}}function Ir(e,t,n={}){let{durability:r="durable",...o}=n;r==="durable"?D(e,t,o):ae(e,t,o)}function ct(e,t=Date.now()){ae(e,{version:1,at:new Date(t).toISOString()})}function Wr(e,t,n=Date.now(),r={}){Je(C(tn(e)).refreshRequestsPath,t,{...r,now:()=>new Date(n)}),ct(e,n)}function Tr(e){try{let t=JSON.parse(f(e,"watch activity record"));return t.version!==1||!N(t.at)||t.refreshRequestedAt!==void 0&&!N(t.refreshRequestedAt)||t.refreshDetail!==void 0&&typeof t.refreshDetail!="string"?null:{atMs:Date.parse(t.at),...t.refreshRequestedAt===void 0?{}:{refreshRequestedAtMs:Date.parse(t.refreshRequestedAt)},...t.refreshDetail===void 0?{}:{refreshDetail:t.refreshDetail}}}catch{return null}}function qr(e,t,n={}){let r=n.pid??process.pid,o=n.isProcessAlive??re,i=()=>{},s=n.readProcessIdentity??ne,a=n.now??(()=>new Date),c={...ie,wallNow:()=>a().getTime(),isProcessAlive:o,readProcessIdentity:s},d=He(e,{kind:"watch",pid:r,processIdentity:s(r),detail:{projectRoot:V(t)},parseLegacy:B,runtime:c});if(d.kind==="contended"){let p=dt(d.observation);return{acquired:!1,lockPath:e,message:ln(e,t,p),release:i}}return{acquired:!0,lockPath:e,message:"",release:()=>{d.lock.release()}}}function ke(e){return dt(se(e,{parseLegacy:B}))}var B=e=>{let t=lt(e);return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function dt(e){if(e.state==="valid"&&e.record?.kind==="watch"){let t=e.record.detail?.projectRoot;return typeof t!="string"?null:{version:1,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},projectRoot:t,startedAt:e.record.startedAt}}return lt(e.parsed)}function lt(e){try{let t=e;if(t.version!==1||typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0||typeof t.projectRoot!="string"||!N(t.startedAt))return null;let n=t.processIdentity===void 0?null:qe(t.processIdentity);return t.processIdentity!==void 0&&(!n||n.pid!==t.pid)?null:{version:1,pid:t.pid,...n?{processIdentity:n}:{},projectRoot:t.projectRoot,startedAt:t.startedAt}}catch{return null}}function dn(e,t,n,r){if(!e)return{kind:"stopped"};if(e.protocolVersion!==ce)return{kind:"incompatible",state:e,reason:"protocol"};if(e.projectRoot!==t.projectRoot)return{kind:"incompatible",state:e,reason:"project"};let o=t.worktreeKind==="git"?t.worktreeId:void 0;if(e.worktreeId!==o)return{kind:"incompatible",state:e,reason:"worktree"};if(e.cliVersion!==t.cliVersion)return{kind:"incompatible",state:e,reason:"cli-version"};if(!r(e.pid))return{kind:"stale",state:e,reason:"dead-process"};let i=Date.parse(e.heartbeatAt);return n-i>de?{kind:"stale",state:e,reason:"old-heartbeat"}:{kind:"live",state:e}}function ye(e,t){switch(e){case"status":return{kind:"report",classification:t};case"ensure":switch(t.kind){case"stopped":return{kind:"start"};case"stale":return t.reason==="old-heartbeat"?{kind:"refuse-replace",state:t.state,reason:"old-heartbeat"}:{kind:"start"};case"live":return{kind:"reuse",state:t.state};case"incompatible":return{kind:"replace",state:t.state};default:return me(t)}case"stop":switch(t.kind){case"stopped":return{kind:"already-stopped"};case"stale":return t.reason==="old-heartbeat"?{kind:"signal-stop",state:t.state}:{kind:"clean-stale",state:t.state};case"live":case"incompatible":return{kind:"signal-stop",state:t.state};default:return me(t)}default:return me(e)}}function Or(e){return e.idleTimeoutMs===0||e.watcher.state!=="idle"||(e.liveSessions??0)>0?!1:e.nowMs-e.lastActivityAtMs>=e.idleTimeoutMs}function it(e,t,n,r){let o=n.monotonicNow??_,i=o()+r;for(;o()<=i;){let s=U(e,t).classification;if(s.kind==="live")return s.state;n.sleep(ge)}return null}function ve(e,t,n){let{pid:r}=e;if(!n.isProcessAlive(r))return;st(e,n),n.signalProcess(r);let o=t.stopTimeoutMs??rn,i=n.monotonicNow??_,s=i()+o;for(;i()<=s;){if(!n.isProcessAlive(r))return;n.sleep(ge)}if(!n.forceSignalProcess)throw new Error(`codebaseiq watch service pid ${r} did not stop within ${o}ms and forced termination is unavailable.`);st(e,n),n.forceSignalProcess(r);let a=t.forceStopTimeoutMs??on,c=i()+a;for(;i()<=c;){if(!n.isProcessAlive(r))return;let d=n.readProcessIdentity(r);if(e.processIdentity&&d&&!te(e.processIdentity,d))return;n.sleep(ge)}throw new Error(`codebaseiq watch service pid ${r} remained alive ${a}ms after forced termination.`)}function O(e,t,n){if(rt(e.statePath,{force:!0}),rt(e.activityPath,{force:!0}),ke(e.lockPath)?.pid===t&&!n.isProcessAlive(t)){let o={...ie,wallNow:n.now,isProcessAlive:n.isProcessAlive,readProcessIdentity:n.readProcessIdentity},i=se(e.lockPath,{parseLegacy:B,runtime:o});_e(e.lockPath,i,{parseLegacy:B,runtime:o})}}function ln(e,t,n){return`error: codebaseiq watch is already running for ${V(t)}${n?` (pid ${n.pid}, started ${n.startedAt}; lock: ${e})`:` (lock: ${e})`}. Stop that watcher before starting another.`}function G(e,t){try{(t.recordActivity??ct)(e,t.now())}catch(n){let r=un(n);if(r!=="EPERM"&&r!=="EACCES"&&r!=="EROFS")throw n}}function un(e){return e.code}var Se={now:Date.now,monotonicNow:_,isProcessAlive:re,readProcessIdentity:ne,spawnServer(e,t,n,r,o){if(!en(e))throw new Error(`Watch service helper was not found at ${e}. Run npm run build first.`);Zt(process.execPath,[e,t,n,JSON.stringify(r)],{detached:!0,stdio:"ignore",windowsHide:!0,env:{...process.env,...o,CODEBASEIQ_SKIP_WATCH_SERVICE:"1"}}).unref()},signalProcess(e){process.kill(e,"SIGTERM")},forceSignalProcess(e){process.kill(e,"SIGKILL")},sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)}};function st(e,t){if(!e.processIdentity)throw new Error(`Refusing to signal codebaseiq watch pid ${e.pid}: its ownership record has no process identity.`);let n=t.readProcessIdentity(e.pid);if(!n)throw new Error(`Refusing to signal codebaseiq watch pid ${e.pid}: its process identity is unavailable.`);if(!te(e.processIdentity,n))throw new Error(`Refusing to signal codebaseiq watch pid ${e.pid}: its process identity does not match the ownership record.`)}function me(e){throw new Error(`Unhandled watch service value: ${JSON.stringify(e)}`)}import{existsSync as m,mkdirSync as pn,rmdirSync as hn,unlinkSync as fn}from"fs";import{homedir as mn}from"os";import{basename as vt,dirname as Q,isAbsolute as gn,join as l,resolve as xe}from"path";import{fileURLToPath as yn}from"url";var ut=["- `codebaseiq search <exact-text>` \u2014 Where does this exact text occur in current project text, and which aligned compiler symbol owns each line? Requires: One exact text literal or deliberately bounded regular expression; insert `--` before a literal that starts with a dash.","- `codebaseiq outline <file>` \u2014 What symbols and nesting exist in this file? Requires: One exact current project file path.","- `codebaseiq entrypoints [text]` \u2014 Which detected external roots or entry-surface candidates match this text? Requires: Optional exact text to filter candidates; otherwise the current indexed repository.","- `codebaseiq evidence` \u2014 Which exact execution, runtime, data, state, temporal, contract, identity, ownership, or dependency relationships surround these referents? Which related source must be read only when graph evidence leaves a named implementation gap? Requires: One or more exact symbol, file:line, or literal roots plus explicit family, direction, depth, and output bound.","- `codebaseiq inspect` \u2014 Which related source units across several known text, symbol, or location anchors should be read together? Requires: One or more exact text, symbol, or file:line selectors naming the unresolved behavior.","- `codebaseiq code <selectors...>` \u2014 What exact source defines these symbols, ranges, or file surfaces? Requires: One or more exact symbols, file:line ranges, or file paths.","- Choose graph controls explicitly: `execution incoming` \u2014 Who can call or reach this?; `execution outgoing` \u2014 What can this call or reach?; `dataflow incoming` \u2014 Where can this value come from?; `dataflow outgoing` \u2014 Where can this value go?; `runtime both` \u2014 Which producer and consumer rendezvous?; `state both` \u2014 What resource is observed or changed?; `temporal both` \u2014 What occurs before or after this?; `contract both` \u2014 What interface constrains this?; `identity both` \u2014 Are these observations the same entity?; `ownership both` \u2014 What contains or owns this?; `dependencies outgoing` \u2014 What does this statically rely on?. The CLI does not infer them from English intent.","- Calibration: exact is directly observed; derived is deterministically computed; candidate needs confirmation; mixed discloses its constituents; unknown cannot support a stronger claim. Read coverage and recovery before making absence claims.","- The controls above are complete for ordinary exploration. Run `codebaseiq capabilities --matrix` only when a named claim depends on uncertain provider support; do not run it for routine orientation."],_r=[{stage:"locate",id:"search",command:"search <exact-text>",question:"Where does this exact text occur in current project text, and which aligned compiler symbol owns each line?",requiredInput:"One exact text literal or deliberately bounded regular expression; insert `--` before a literal that starts with a dash.",returnedFact:"exact cardinality, bounded identities and source, and scope commands that recover withheld matches",evidenceCeiling:"Exact current-text cardinality and locations within reported text coverage; compiler ownership only where aligned.",nonClaim:"Structural source ranking orders exact matches but does not establish task relevance. A literal co-occurrence does not establish a graph relationship.",outputCost:"small",contrasts:["outline: search locates exact text across files; outline enumerates compiler-owned constructs in one known file."],gapClosingCommands:["evidence","inspect","code"]},{stage:"locate",id:"outline",command:"outline <file>",question:"What symbols and nesting exist in this file?",requiredInput:"One exact current project file path.",returnedFact:"symbol names, nesting, and line ranges",evidenceCeiling:"Exact compiler-owned constructs and ranges when the file is indexed; no invented semantic overlay.",nonClaim:"File ownership and nesting do not establish execution or task relevance.",outputCost:"small",contrasts:["search: outline enumerates constructs in one known file; search locates exact text across current project text.","code: outline returns identities and ranges; code materializes exact source for selected identities."],gapClosingCommands:["evidence","inspect","code"]},{stage:"locate",id:"entrypoints",command:"entrypoints [text]",question:"Which detected external roots or entry-surface candidates match this text?",requiredInput:"Optional exact text to filter candidates; otherwise the current indexed repository.",returnedFact:"entry symbols with files, confidence, evidence, and indexed caller counts",evidenceCeiling:"Source/compiler-grounded entry evidence and indexed caller counts; exported-only candidates remain candidates.",nonClaim:"A package-public export or zero indexed callers is an entry candidate, not proof of runtime ingress. Entry classification does not establish that the callable executes.",outputCost:"bounded",contrasts:["entry-map: entrypoints locates possible external roots; entry-map traverses static calls from one selected root.","search: entrypoints classifies callable roots; search only locates exact text and ownership."],gapClosingCommands:["evidence","inspect","code"]},{stage:"project",id:"evidence",command:"evidence",question:"Which exact execution, runtime, data, state, temporal, contract, identity, ownership, or dependency relationships surround these referents? Which related source must be read only when graph evidence leaves a named implementation gap?",requiredInput:"One or more exact symbol, file:line, or literal roots plus explicit family, direction, depth, and output bound.",returnedFact:"batched exact selectors and typed graph relationships; compact endpoints with exact locations and follow-up commands; coverage and recoverable omissions; exact source-recovery command when source was requested with a graph projection; explicit ambiguity failure with exact rerun commands",evidenceCeiling:"Typed edges only to each registered provider ceiling within the explicitly selected projection and reported coverage.",nonClaim:"The projection does not infer which relationships are relevant to the user task. Reference, dependency, data, state, temporal, contract, and identity edges do not become execution claims.",outputCost:"bounded",contrasts:["refs: refs enumerates direct reference sites; evidence traverses explicitly selected typed relationships.","call-graph: call-graph specializes in static calls; evidence can combine execution with other selected families.","value-flow: value-flow specializes in proved transfers; evidence projects bounded dataflow alongside other families.","dependence-slice: dependence-slice computes a program-dependence slice; evidence performs bounded graph projection."],gapClosingCommands:["inspect","code"]},{stage:"read",id:"inspect",command:"inspect",question:"Which related source units across several known text, symbol, or location anchors should be read together?",requiredInput:"One or more exact text, symbol, or file:line selectors naming the unresolved behavior.",returnedFact:"one ranked, deduplicated semantic packet plus exact selector cardinality and explicit expansion coverage",evidenceCeiling:"Complete current source for every materialized syntax unit; bounded selector and packet coverage remain explicit.",nonClaim:"A source packet does not choose which implementation details are relevant to the user task. A reference mention does not establish executable reachability.",outputCost:"potentially-large",contrasts:["code: inspect batches bounded behavior or source gaps; code materializes complete exact source.","evidence: inspect reads implementation units; evidence projects typed relationships without source."],gapClosingCommands:[]},{stage:"read",id:"code",command:"code <selectors...>",question:"What exact source defines these symbols, ranges, or file surfaces?",requiredInput:"One or more exact symbols, file:line ranges, or file paths.",returnedFact:"per-selector resolution, complete definition source, exact ranges with statically attributed same-file call closure, file export surfaces, omitted-local ledgers, and line ranges",evidenceCeiling:"Exact current source bytes for every resolved selector, with omitted file-local constructs disclosed.",nonClaim:"Source materialization does not establish callers, runtime reachability, or task relevance by itself.",outputCost:"potentially-large",contrasts:["inspect: code materializes complete exact source; inspect batches bounded behavior or source gaps.","outline: code reads selected implementations; outline enumerates file structure without reading every body."],gapClosingCommands:[]}];var g="<!-- codebaseiq:agent-setup:begin -->",R="<!-- codebaseiq:agent-setup:end -->",vn="# codebaseiq:agent-setup",X=[".codex/hooks.json",".claude/settings.local.json"],pt="# codebaseiq:local-agent-hooks:begin",ht="# codebaseiq:local-agent-hooks:end",we="hook-architecture-stop",kt=["claude","codex"],P={claude:".claude/settings.local.json",codex:".codex/hooks.json"},St="sentinel-hook.mjs",kn=l("dist","sentinel-hook.js"),Sn=l("dist","cli.js"),bn="cli-path",xn="installed-projects.json";function Yr(e){let t=e.written.length+e.unchanged.length,n=e.skipped.length;return{verdict:n===0?"ready":t===0?"blocked":"partial",ready:t,skipped:n}}function Zr(e,t={}){let n={written:[],unchanged:[],skipped:[]};return wn(e,n),t.architectureHook!==!1&&En(e,n,t.architectureHook),n}function eo(e,t={}){let n={removed:[],unchanged:[],skipped:[]};return mt(e,"AGENTS.md",t,n),mt(e,"CLAUDE.md",t,n),xt(e,t,n,r=>Ot(Wn(r))),qt(e,t,n),An(e,t,n),n}function wn(e,t){let n=[g,"## codebaseiq","","This repository uses codebaseiq as its primary code exploration surface.","","codebaseiq separates two responsibilities: the agent decides what repository fact it needs, while the tool locates exact referents and reports compiler, runtime, data, state, temporal, contract, identity, ownership, and dependency evidence without guessing task relevance. The ordinary loop is locate an exact root, project explicitly chosen relationships, read behavior only for a named remaining gap, then stop when the requested claims are established.","","- Use codebaseiq for repository exploration, including literal search and exact source reads. Native tools are for applying edits, running checks, binary content, or a specific unsupported gap that codebaseiq has explicitly reported\u2014not a parallel exploration workflow.","- Before exploring, state the few material repository facts the answer depends on. Include behavior-changing predicates, authorization checks, data reshaping, hard bounds, runtime crossings, durable state changes, emitted notifications, returned values, relevant sibling outcomes, and externally visible ordering only when the request depends on them.","- For end-to-end explanations, use the installed codebaseiq-explore guidance to maintain the evidence ledger and audit the final answer; codebaseiq supplies the repository observations.",...ut,"- Any exact symbol or `file:line` returned by a locator is immediately usable as a graph root. There is no required anchor-discovery phase and locator ordering never proves task relevance. For an end-to-end question, include the initiating owner as a root or request incoming execution capable of exposing it; do not assume a core type is the ingress. Locate independent roots together when the question already implies several participants.","- A materialized evidence projection requires repeated `--symbol`, `--at`, or `--search` selectors plus one or more repeated `--edge <family>` flags, explicit `--direction incoming|outgoing|both`, `--depth <n>`, and `--max-edges <n>`. The agent chooses the relationships capable of establishing its claim; the CLI resolves identity, direction, evidence strength, provider support, and coverage. Use optional exact `--subtype <subtype>` and `--connecting` only when the selected roots themselves must be connected. Never request `complete`, `all`, or every family merely to discover what exists; use `--inventory-only` when only counts can determine the next bounded projection.","- Treat execution calls and exact runtime handoffs as executable reachability. Dataflow, state, temporal, contract, identity, ownership, and dependency edges say what a path carries, changes, orders, constrains, identifies, contains, or relies on; they do not become call claims. Treat exact edges as facts only within their stated coverage and candidate edges as leads requiring source confirmation.","- Read every packet as a coverage contract. `accounted` means the requested bounded projection reports every omission; `bounded` means requested edges were placed in stable recoverable folds by the output budget; `incomplete` means a selector or provider could not be resolved. None proves the user task complete, and missing output is no evidence of absence.","- Prefer batched locators, projections, and gap reads. Query count measures exploration efficiency; it never makes a known recoverable material fact optional. Before drilling down, name the still-missing fact. Expand only a printed fold or exact adjacent identity that can establish it; batch independent roots and gaps instead of shuttling between abstraction levels, and repeat only while a named fact remains unresolved.","- Use `codebaseiq inspect --symbol <symbol> --symbol <symbol> --at <file:line> --view behavior` for several named behavioral gaps. Connected behavior is already source evidence; do not reread lines it rendered. Use `codebaseiq code <symbol-or-range>` only when exact implementation syntax can change the decision. Do not replace these reads with `rg`, `grep`, `sed`, or `nl`.","- For a multi-step mutation, preserve later compaction, rollback, and cleanup. For every event, log, or outbox write, preserve its operation and record identity. For coordination, state the lock scope and which checks and writes occur inside it. State whether interruption is prevented, atomic, rolled back, or repaired later. Resolve exact constant values when they can change the answer.","- For a tiered policy or dispatcher, preserve the precedence of its tiers and the exact scope of every bypass; never imply that a later bypass can skip an earlier hard rejection unless the rendered condition proves it.","- For a stateful owner, preserve its lifetime and sharing scope, including whether it is a singleton, shared registry, per-session instance, or per-invocation value.","- Use `codebaseiq diff-impact` to map changed symbols and downstream consumers after a nontrivial edit.","- Use `codebaseiq architecture` to inspect explicit structural rules.","- Use `codebaseiq health` to find React, Vue, duplication, complexity, drift, and cleanup candidates.","- Before claiming a complete relationship set or an absence, inspect coverage and use `--full` only when complete coverage can change the decision. A bounded or unsupported result cannot establish that no caller, route, branch, poller, or consumer exists.","- Before claiming what every callsite passes, read the `trace` or `evidence` claim-support section. Only an eligible callsite-argument claim is backed by complete syntactic invocations; bounded context is not proof.","- Prefer human output for agent reading. Use `--json --result-only` only for a programmatic consumer.","- Never rerun a successful human command as JSON. Before each drilldown, name the still-unanswered fact and check whether an earlier packet already establishes it; if so, update the ledger or draft without another query. Stop when no unanswered fact remains because every additional reasoning step pays again for the accumulated context.","- Before answering, compare the draft to selected statement-complete behavior. Preserve every material behavior-changing predicate, returned default, separately merged field, cache invalidation, and cleanup effect. Do not collapse fields with different operations into a generic summary, and do not re-query evidence already in context.","- With an explicit CODEBASEIQ_SESSION, a complete source unit, a byte-identical exact subset of a prior exact source read, or a graph unit/edge may be replaced by a visible receipt from the same index generation. Preview coverage never suppresses an exact unit; changed bytes, changed graph content, a new generation, or --reemit force full evidence.","- If output emits `Continue exactly:`, run that command unchanged until transport is complete.","- When architecture rules are configured and clean, setup installs one checkout-local Stop hook. It checks architecture only after indexed source changes.","- Commit relevant `.codebaseiq/suppressions/*.json` records with the change. Do not commit local agent-tool settings.",R].join(`
|
|
2
2
|
`);ft(e,"AGENTS.md",n,t);let r=[g,"@AGENTS.md",R].join(`
|
|
3
3
|
`);ft(e,"CLAUDE.md",r,t,o=>o.includes("@AGENTS.md")&&!o.includes(g))}function ft(e,t,n,r,o){let i=l(e,t),s=!1,a=Re(i,t,r,c=>{if(o?.(c.text))return s=!0,{kind:"unchanged"};let d=Rn(c.text,n);return d===c.text?{kind:"unchanged"}:{kind:"write",text:d,...c.revision.exists?{}:{mode:420}}});a&&(!a.changed||s?r.unchanged.push(t):r.written.push(t))}function mt(e,t,n,r){let o=l(e,t);if(n.dryRun){if(!m(o)){r.unchanged.push(t);return}try{let s=f(o,"agent instruction file");s.includes(g)?(gt(s),r.removed.push(t)):r.unchanged.push(t)}catch(s){r.skipped.push({target:t,reason:s instanceof Error?s.message:String(s)})}return}let i=Re(o,t,r,s=>{if(!s.revision.exists||!s.text.includes(g))return{kind:"unchanged"};let a=gt(s.text);return a.length===0?{kind:"delete"}:{kind:"write",text:a}});i&&(i.changed?r.removed.push(t):r.unchanged.push(t))}function Rn(e,t){if(bt(e)==="present"){let r=new RegExp(`${g}[\\s\\S]*?${R}`);return e.replace(r,t)}return e.length>0?`${e.replace(/\n*$/,`
|
|
4
4
|
|
|
@@ -18,4 +18,4 @@ import{V as Ue,W as Be}from"./chunk-LONKINMJ.js";import{N as ce,O as de,Q as C,R
|
|
|
18
18
|
`)),K(r.manifest,Buffer.from(o)),K(r.cliPath,Buffer.from(`${xe(t.root,Sn)}
|
|
19
19
|
`))];return{state:"installed",script:r.script,version:t.version,changed:i.some(Boolean)}}catch(o){return{state:"skipped",reason:`the hook binary could not be installed: ${v(o)}`}}}function no(e,t={}){let n=Y(t.cacheRoot??y());if(!(be(n.version,"sentinel hook version")===e&&m(n.cliPath)))return Wt(t)}function Pn(e){let t=e;for(;;){try{let r=JSON.parse(f(l(t,"package.json"),"package manifest"));if(r.name==="codebaseiq"&&typeof r.version=="string")return{root:t,version:r.version}}catch{}let n=Q(t);if(n===t)return;t=n}}function Tt(e){return{maxBytes:Ie,inputKind:e}}function K(e,t){try{if(Z(e,Tt("sentinel hook file")).equals(t))return!1}catch{}return De(e,t),!0}function ro(e,t={}){let n=t.hosts??kt,r=t.cacheRoot??y(),o=Wt({packageRoot:t.packageRoot,cacheRoot:r}),i={written:[],unchanged:[],skipped:[],binary:o,notices:[]};if(o.state==="skipped")return i.skipped.push({target:"sentinel hook binary",reason:o.reason}),i;for(let a of n){let c=P[a];if(L(e,c)){i.skipped.push({target:c,reason:"tracked repository config; the checkout-local hook installer will not modify it"});continue}let d=[];Ee(l(e,c),c,i,p=>{let u=Dn(p,Mn(a,o.script,t.nodeExecutable));return d=Hn(p,u),u}),a==="codex"&&d.length>0&&i.written.includes(c)&&i.notices.push(`Codex must re-approve the changed hooks (${d.join(", ")}): open Codex once in this project and approve them. The approval it recorded for the old command no longer applies, and codebaseiq can only see that an approval exists, not that it still matches.`)}if(Ct(e,i),n.map(a=>P[a]).some(a=>i.written.includes(a)||i.unchanged.includes(a)))try{Vn(r,e)}catch(a){i.skipped.push({target:"sentinel project registry",reason:v(a)})}return i}function Hn(e,t){let n=o=>`${o.event}:${o.group}:${o.index}:${JSON.stringify(o.hook)}`,r=new Set(z(t).map(n));return[...new Set(z(e).filter(o=>!r.has(n(o))).map(o=>o.event))]}function _n(e,t={}){let n={removed:[],unchanged:[],skipped:[]};return xt(e,t,n,Ot),qt(e,t,n),n}function oo(e={}){let t=e.cacheRoot??y(),n={removed:[],unchanged:[],skipped:[]};for(let o of Bn(t)){if(!m(o)){e.dryRun||Mt(t,o);continue}let i=_n(o,{dryRun:e.dryRun,cacheRoot:t});n.removed.push(...i.removed.map(s=>l(o,s))),n.skipped.push(...i.skipped.map(s=>({...s,target:l(o,s.target)})))}let r=Y(t);if(n.skipped.length>0)return m(r.script)&&n.skipped.push({target:r.script,reason:"kept: hooks that run it could not be removed from every project; run uninstall again once they can"}),n;for(let o of[r.script,r.version,r.manifest,r.cliPath])if(m(o)&&(n.removed.push(o),!e.dryRun))try{fn(o)}catch(i){n.skipped.push({target:o,reason:v(i)})}if(!e.dryRun)try{hn(r.directory)}catch{}return n}function qt(e,t,n){let r=X;if(!(t.dryRun||n.skipped.some(o=>r.includes(o.target))))try{Mt(t.cacheRoot??y(),e)}catch(o){n.skipped.push({target:"sentinel project registry",reason:v(o)})}}function J(e){if(!e||typeof e!="object")return!1;let{command:t,args:n}=e;return Array.isArray(n)&&n.includes(I)?!0:typeof t=="string"&&t.split(/\s+/u).includes(I)}function Dn(e,t){let n={...H(e.hooks)};for(let{event:r,...o}of t){let i=n[r];n[r]=wt(Array.isArray(i)?i:[],o,J)}return{...e,hooks:n}}function Ot(e){let t=H(e.hooks),n={},r=!1;for(let[i,s]of Object.entries(t)){if(!Array.isArray(s)){n[i]=s;continue}let a=[];for(let c of s){if(!Ae(c)||!c.hooks.some(J)){a.push(c);continue}r=!0;let d=c.hooks.filter(p=>!J(p));d.length>0&&a.push({...c,hooks:d})}(a.length>0||s.length===0)&&(n[i]=a)}if(!r)return e;let o={...e};return Object.keys(n).length>0?o.hooks=n:delete o.hooks,o}function Mn(e,t,n=process.execPath){return It[e].map(r=>({event:r.event,...r.matcher!==void 0?{matcher:r.matcher}:{},hook:e==="claude"?Nn(t,r):Ln(t,r,n)}))}function Nn(e,t){return{type:"command",command:"node",args:[e,"--host","claude",...t.async?["--async"]:[],I],...t.async?{async:!0,asyncRewake:!0}:{},timeout:t.timeout}}function Ln(e,t,n){let r=gn(n)&&/^node(?:\.exe)?$/iu.test(vt(n))?n:"node";return{type:"command",command:`${process.platform==="win32"?"& ":""}${yt(r)} ${yt(e)} --host codex ${I}`,timeout:t.timeout}}function yt(e){if((process.platform==="win32"?/["\r\n%$`]/u:/["\r\n$`]/u).test(e))throw new Error(`${JSON.stringify(e)} cannot be quoted in a Codex hook command`);return`"${e}"`}function z(e){let t=[];for(let[n,r]of Object.entries(H(e.hooks)))Array.isArray(r)&&r.forEach((o,i)=>{Ae(o)&&o.hooks.forEach((s,a)=>{J(s)&&t.push({event:n,group:i,index:a,hook:s})})});return t}function Pt(e){if(m(e))try{return At(e)}catch{return}}function io(e,t={}){let n=Y(t.cacheRoot??y()),r=be(n.version,"sentinel hook version"),o=be(n.cliPath,"sentinel hook CLI path");return{binary:{script:n.script,present:m(n.script),...r?{version:r}:{},...o?{cliTarget:o}:{}},hosts:kt.map(i=>{let s=P[i],a=Pt(l(e,s)),c=a?z(a):[],d=It[i].map(u=>u.event),p=new Set(c.map(u=>u.event));return{host:i,file:s,events:d.filter(u=>p.has(u)),missing:d.filter(u=>!p.has(u)),scripts:[...new Set(c.flatMap(u=>$n(u.hook)))]}})}}function be(e,t){try{return f(e,t).trim()||void 0}catch{return}}function $n(e){return(Array.isArray(e.args)?e.args.filter(n=>typeof n=="string"):[...e.command.matchAll(/"([^"]*)"|(\S+)/gu)].map(n=>n[1]??n[2]??"")).filter(n=>vt(n)===St)}function so(e,t={}){let n=l(e,P.codex),r=Pt(n),o=r?z(r):[];if(o.length===0)return;let i=l(t.codexHome??process.env.CODEX_HOME??l(mn(),".codex"),"config.toml"),s=Gn(i),a=[...new Set([n,l(k(e),P.codex)])];return{configPath:i,hooks:o.map(({event:c,group:d,index:p})=>{let u=`:${Un(c)}:${d}:${p}`;return{event:c,key:`${n}${u}`,trusted:a.some(A=>s.has(Ht(`${A}${u}`)))}})}}var jn=/^\s*\[hooks\.state\.(?:'([^']*)'|"((?:[^"\\]|\\.)*)")\]\s*(?:#.*)?$/u,Fn=/^\s*trusted_hash\s*=\s*"sha256:[0-9a-f]+"/u;function Gn(e){let t=new Set,n;try{n=f(e,"Codex config")}catch{return t}let r;for(let o of n.split(/\r?\n/u)){let i=jn.exec(o);i?r=Ht(i[1]??(i[2]??"").replace(/\\(["\\])/gu,"$1")):/^\s*\[/u.test(o)?r=void 0:r!==void 0&&Fn.test(o)&&t.add(r)}return t}function Un(e){return e.replace(/([a-z])([A-Z])/gu,"$1_$2").toLowerCase()}function Ht(e){return process.platform==="win32"?e.replaceAll("/","\\").toLowerCase():e}function ao(e){let t={...Le.delivery};try{let n=JSON.parse(f(l(e,le,Me),"sentinel settings")).delivery;for(let r of Ne){let o=n?.[r];(o==="shadow"||o==="live")&&(t[r]=o)}}catch{}return t}function Ce(e){return l(e,le,xn)}function Bn(e=y()){try{return _t(f(Ce(e),"sentinel project registry"))}catch{return[]}}function _t(e){try{let{projects:t}=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}function Dt(e,t){let n=Ce(e);pn(Q(n),{recursive:!0}),W(n,r=>{let o=t(r.revision.exists?_t(r.text):[]);return o===void 0?{kind:"unchanged"}:{kind:"write",text:`${JSON.stringify({projects:o},null,2)}
|
|
20
20
|
`,mode:384}})}function Vn(e,t){let n=k(xe(t));Dt(e,r=>r.includes(n)?void 0:[...r,n].sort())}function Mt(e,t){if(!m(Ce(e)))return;let n=k(xe(t));Dt(e,r=>r.includes(n)?r.filter(o=>o!==n):void 0)}export{Je as a,er as b,tr as c,Kt as d,nr as e,rr as f,or as g,Rr as h,an as i,Ar as j,at as k,Er as l,cn as m,Cr as n,Ir as o,Wr as p,Tr as q,qr as r,Or as s,_r as t,Yr as u,Zr as v,eo as w,to as x,Ct as y,no as z,ro as A,_n as B,oo as C,io as D,so as E,ao as F};
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
21
|
+
//# sourceMappingURL=chunk-V4NGDIEA.js.map
|