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.
Files changed (176) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/{chunk-BFBIMTCJ.js → chunk-2XBJRZEM.js} +2 -2
  3. package/dist/{chunk-GDHWOA57.js → chunk-2Z7K66D7.js} +2 -2
  4. package/dist/{chunk-HVFB3PME.js → chunk-3H2H5ODK.js} +2 -2
  5. package/dist/{chunk-LZSQ6X7E.js → chunk-3LQJRS4I.js} +2 -2
  6. package/dist/{chunk-GIDCP7KV.js → chunk-3ON3A2QV.js} +2 -2
  7. package/dist/{chunk-TPO7XC5Z.js → chunk-4GWN76B2.js} +2 -2
  8. package/dist/{chunk-GL6UTNUB.js → chunk-53ELMZRF.js} +2 -2
  9. package/dist/{chunk-6VREELBC.js → chunk-57OPIQFM.js} +2 -2
  10. package/dist/{chunk-JSNTHRLQ.js → chunk-5CR4U5X2.js} +2 -2
  11. package/dist/{chunk-GUFPEFBG.js → chunk-5MPBSFZH.js} +2 -2
  12. package/dist/{chunk-K7JLSGCJ.js → chunk-5TZNHP4T.js} +3 -3
  13. package/dist/{chunk-DVWO7RBC.js → chunk-5YBDBY5L.js} +2 -2
  14. package/dist/{chunk-T5X7DK6C.js → chunk-6EYESTJM.js} +2 -2
  15. package/dist/{chunk-AQI4N64O.js → chunk-6FXXYYQM.js} +2 -2
  16. package/dist/{chunk-VWYGCMV5.js → chunk-AGGR2BKS.js} +2 -2
  17. package/dist/{chunk-FEIZXBLH.js → chunk-ALOEHWJS.js} +2 -2
  18. package/dist/{chunk-D53LWANR.js → chunk-AXQCHG77.js} +2 -2
  19. package/dist/{chunk-7JELP5YE.js → chunk-BFANZRQ5.js} +2 -2
  20. package/dist/{chunk-5IZRKWTZ.js → chunk-BGYRF5YX.js} +2 -2
  21. package/dist/{chunk-5IC2WZAL.js → chunk-BIADXGC3.js} +2 -2
  22. package/dist/{chunk-HENP2O4A.js → chunk-BPKNP3KZ.js} +2 -2
  23. package/dist/{chunk-GP7C5VAE.js → chunk-CB5AVJMM.js} +2 -2
  24. package/dist/{chunk-HQA7EBSK.js → chunk-CJTKGAGH.js} +2 -2
  25. package/dist/{chunk-JLZLLLW5.js → chunk-CLPCFGRT.js} +2 -2
  26. package/dist/{chunk-EXZ7VLRY.js → chunk-CSPDQLLU.js} +2 -2
  27. package/dist/{chunk-AEXQYQD7.js → chunk-CYJS33YX.js} +2 -2
  28. package/dist/{chunk-AURCQHSG.js → chunk-DDRA3QKN.js} +2 -2
  29. package/dist/{chunk-3RSBGWGL.js → chunk-DECN422G.js} +2 -2
  30. package/dist/{chunk-3RR2K7EZ.js → chunk-DJKOXMNG.js} +2 -2
  31. package/dist/{chunk-PFC44E6D.js → chunk-DWBAESVW.js} +2 -2
  32. package/dist/{chunk-FQTIFWLR.js → chunk-EHPOTEQX.js} +2 -2
  33. package/dist/{chunk-NBCQZSGR.js → chunk-ELYMY5S2.js} +2 -2
  34. package/dist/{chunk-FTTV7IRX.js → chunk-EOKVZXNF.js} +42 -42
  35. package/dist/{chunk-HINZQKSY.js → chunk-F5CJO5JN.js} +2 -2
  36. package/dist/{chunk-SMDIEDM4.js → chunk-G7GVV2TV.js} +2 -2
  37. package/dist/{chunk-67VJAYVR.js → chunk-HJTM3C4Y.js} +2 -2
  38. package/dist/{chunk-I22IZYDI.js → chunk-HNXRVGMY.js} +2 -2
  39. package/dist/{chunk-NCJILOAK.js → chunk-I3OK27P7.js} +2 -2
  40. package/dist/{chunk-FWQGH2N2.js → chunk-ILGTMRMZ.js} +2 -2
  41. package/dist/{chunk-DDN2F6GB.js → chunk-JAFDMV5I.js} +2 -2
  42. package/dist/{chunk-LONKINMJ.js → chunk-JNXI6NQ7.js} +2 -2
  43. package/dist/{chunk-6BF3VYEF.js → chunk-JSB43EX6.js} +2 -2
  44. package/dist/chunk-JYRJYXUV.js +2 -0
  45. package/dist/chunk-K4S2VH42.js +82 -0
  46. package/dist/{chunk-75KJGYX7.js → chunk-K6FNTQQW.js} +2 -2
  47. package/dist/{chunk-XQPPURLQ.js → chunk-KEJ2HLRW.js} +2 -2
  48. package/dist/{chunk-D7AZAOZX.js → chunk-KFTHI2R6.js} +2 -2
  49. package/dist/{chunk-J3GLP7Q5.js → chunk-KLX6NSWT.js} +2 -2
  50. package/dist/{chunk-TJBOJUVN.js → chunk-KUKKLWJD.js} +2 -2
  51. package/dist/{chunk-2EDX3JT5.js → chunk-KUKWHP4R.js} +2 -2
  52. package/dist/{chunk-JFIA2JI3.js → chunk-KWRQVLPX.js} +2 -2
  53. package/dist/{chunk-5DSL3NT2.js → chunk-L37EQYAX.js} +2 -2
  54. package/dist/{chunk-ITSJMNUD.js → chunk-LCW3PSGL.js} +2 -2
  55. package/dist/{chunk-2PRONPAS.js → chunk-LSZYMN2A.js} +2 -2
  56. package/dist/{chunk-Q23IMHXS.js → chunk-MC46AL7B.js} +2 -2
  57. package/dist/{chunk-JYI7CV25.js → chunk-MDFT325O.js} +2 -2
  58. package/dist/{chunk-CVHOQONG.js → chunk-N2XDMNVI.js} +2 -2
  59. package/dist/chunk-NNG6M6XD.js +3 -0
  60. package/dist/{chunk-MVRGB4KJ.js → chunk-O2KWU34K.js} +2 -2
  61. package/dist/{chunk-USOAJHY7.js → chunk-OBC7HSSO.js} +2 -2
  62. package/dist/{chunk-RIYJ4L33.js → chunk-OKAF4OQS.js} +2 -2
  63. package/dist/{chunk-GQXXOS55.js → chunk-OP6BUIV6.js} +2 -2
  64. package/dist/{chunk-23C5AD3B.js → chunk-OQ3DK7FW.js} +2 -2
  65. package/dist/chunk-OT5ISJSR.js +2 -0
  66. package/dist/{chunk-C7QWUBR2.js → chunk-OWJWOEDU.js} +2 -2
  67. package/dist/{chunk-RJVAPMHF.js → chunk-PIFYOWS4.js} +2 -2
  68. package/dist/{chunk-CR3OG6SQ.js → chunk-PTR3EOXC.js} +2 -2
  69. package/dist/{chunk-NBZKSTXP.js → chunk-QY7QB7I6.js} +2 -2
  70. package/dist/{chunk-Q3ZCQY2Y.js → chunk-R4OJGTMP.js} +2 -2
  71. package/dist/{chunk-UQE4XFSA.js → chunk-RIO3JXHM.js} +2 -2
  72. package/dist/{chunk-CW6AXOLR.js → chunk-SA7G6GJX.js} +2 -2
  73. package/dist/{chunk-Q4XEU3UH.js → chunk-SB53KPWA.js} +2 -2
  74. package/dist/{chunk-36JC5BG2.js → chunk-SUE7SHZL.js} +2 -2
  75. package/dist/{chunk-ZAFGY22Q.js → chunk-SZ4P7MF7.js} +2 -2
  76. package/dist/{chunk-BBP7HVBJ.js → chunk-T2M5HWBQ.js} +2 -2
  77. package/dist/{chunk-MHWMEZDA.js → chunk-TEMM2FEL.js} +2 -2
  78. package/dist/{chunk-JX6ZWDOS.js → chunk-TLTSESB4.js} +2 -2
  79. package/dist/{chunk-FOZ74V56.js → chunk-UIAUPFBJ.js} +2 -2
  80. package/dist/{chunk-PHNCEUXX.js → chunk-UJIXCI3L.js} +2 -2
  81. package/dist/{chunk-XMJ53WG4.js → chunk-UMEPSVKT.js} +2 -2
  82. package/dist/{chunk-GWYZVVKY.js → chunk-V4NGDIEA.js} +2 -2
  83. package/dist/{chunk-E52K4L2W.js → chunk-VSGOIZMQ.js} +2 -2
  84. package/dist/{chunk-Z6RL7XOE.js → chunk-W7QDASTN.js} +2 -2
  85. package/dist/{chunk-PTQPPPG2.js → chunk-WO6OFKUC.js} +2 -2
  86. package/dist/{chunk-C7OUW52M.js → chunk-XJBK3QDV.js} +2 -2
  87. package/dist/{chunk-FH5WG4LE.js → chunk-XUPFA6GH.js} +2 -2
  88. package/dist/{chunk-DAKIGMIK.js → chunk-YPBKBYPS.js} +2 -2
  89. package/dist/{chunk-ZQ62NNKN.js → chunk-Z66XYVLZ.js} +2 -2
  90. package/dist/{chunk-OFGOOL6U.js → chunk-ZMA5HWXY.js} +2 -2
  91. package/dist/{cli-program-UO7PZD6V.js → cli-program-SCHOHOQE.js} +2 -2
  92. package/dist/cli.js +1 -1
  93. package/dist/{code-viewer-VHLBLIUM.js → code-viewer-AMRXV444.js} +2 -2
  94. package/dist/{code-viewer-KIXEYQNJ.js → code-viewer-EXI5SFFR.js} +2 -2
  95. package/dist/{command-descriptors-F5P2V3NW.js → command-descriptors-H6A4UY72.js} +3 -3
  96. package/dist/{command-descriptors-YCLATF5I.js → command-descriptors-ROIOTCCW.js} +3 -3
  97. package/dist/direct-navigation-3JOYP2MO.js +3 -0
  98. package/dist/direct-navigation-SJMJLBY7.js +2 -0
  99. package/dist/index.js +1 -1
  100. package/dist/invocation-command-descriptors-GMZX3UAD.js +2 -0
  101. package/dist/invocation-command-descriptors-HNMKDEF6.js +3 -0
  102. package/dist/{output-continuation-command-BTETTXEC.js → output-continuation-command-5NWVDQT7.js} +2 -2
  103. package/dist/output-continuation-command-RNEHNYPU.js +3 -0
  104. package/dist/project-reindex-MIW5CYEG.js +3 -0
  105. package/dist/{project-reindex-CRJU3IFG.js → project-reindex-VQ23LWDA.js} +2 -2
  106. package/dist/queries/affected.js +1 -1
  107. package/dist/queries/anchors.js +1 -1
  108. package/dist/queries/bottlenecks.js +1 -1
  109. package/dist/queries/call-graph.js +1 -1
  110. package/dist/queries/change-surface.js +1 -1
  111. package/dist/queries/cleanup-plan.js +1 -1
  112. package/dist/queries/complexity-hotspots.js +1 -1
  113. package/dist/queries/complexity.js +1 -1
  114. package/dist/queries/context.js +1 -1
  115. package/dist/queries/convergence.js +1 -1
  116. package/dist/queries/dataflow.js +1 -1
  117. package/dist/queries/dead.js +1 -1
  118. package/dist/queries/decorative-checkers.js +1 -1
  119. package/dist/queries/dependence-slice.js +1 -1
  120. package/dist/queries/diff-impact.js +1 -1
  121. package/dist/queries/drift.js +1 -1
  122. package/dist/queries/entry-map.js +1 -1
  123. package/dist/queries/evidence.js +1 -1
  124. package/dist/queries/extract-candidates.js +1 -1
  125. package/dist/queries/health.js +1 -1
  126. package/dist/queries/hotspots.js +1 -1
  127. package/dist/queries/imports.js +1 -1
  128. package/dist/queries/incomplete-migration.js +1 -1
  129. package/dist/queries/index.js +1 -1
  130. package/dist/queries/isolated.js +1 -1
  131. package/dist/queries/locality-candidates.js +1 -1
  132. package/dist/queries/members.js +1 -1
  133. package/dist/queries/methods.js +1 -1
  134. package/dist/queries/not-implemented.js +1 -1
  135. package/dist/queries/passthrough-candidates.js +1 -1
  136. package/dist/queries/plan-context.js +1 -1
  137. package/dist/queries/recent-duplicates.js +1 -1
  138. package/dist/queries/redundant-reexports.js +1 -1
  139. package/dist/queries/reference-neighborhood.js +1 -1
  140. package/dist/queries/reference-reachability.js +1 -1
  141. package/dist/queries/refs.js +1 -1
  142. package/dist/queries/self-audit.js +1 -1
  143. package/dist/queries/similar-signatures.js +1 -1
  144. package/dist/queries/similar.js +1 -1
  145. package/dist/queries/slice.js +1 -1
  146. package/dist/queries/source-inspection.js +1 -1
  147. package/dist/queries/stale-abstractions.js +1 -1
  148. package/dist/queries/surface.js +1 -1
  149. package/dist/queries/system-map.js +1 -1
  150. package/dist/queries/trace.js +1 -1
  151. package/dist/queries/twin-ab.js +1 -1
  152. package/dist/queries/unused-imports.js +1 -1
  153. package/dist/queries/unused-params.js +1 -1
  154. package/dist/queries/value-flow.js +1 -1
  155. package/dist/queries/wrapper-candidates.js +1 -1
  156. package/dist/reindex-worker.js +1 -1
  157. package/dist/reindex.js +1 -1
  158. package/dist/runtime.js +1 -1
  159. package/dist/rust-semantic-session-server.js +1 -1
  160. package/dist/rust-semantic-session-worker.js +1 -1
  161. package/dist/rust-semantic-worker.js +1 -1
  162. package/dist/{sentinel-ensure-command-SPW7XQLB.js → sentinel-ensure-command-H66AZ3VE.js} +2 -2
  163. package/dist/sentinel-ensure-command-R4YAUCJB.js +3 -0
  164. package/dist/watch-server.js +1 -1
  165. package/package.json +1 -1
  166. package/dist/chunk-6JMAVFL4.js +0 -3
  167. package/dist/chunk-6WAPPQ5F.js +0 -82
  168. package/dist/chunk-P4NVCOM7.js +0 -2
  169. package/dist/chunk-Z35GOVEH.js +0 -2
  170. package/dist/direct-navigation-4XJTXIDT.js +0 -2
  171. package/dist/direct-navigation-J5MVYYAD.js +0 -3
  172. package/dist/invocation-command-descriptors-RWV4VAI4.js +0 -2
  173. package/dist/invocation-command-descriptors-U76PN7IY.js +0 -3
  174. package/dist/output-continuation-command-BL25S26S.js +0 -3
  175. package/dist/project-reindex-TQFCOA2O.js +0 -3
  176. package/dist/sentinel-ensure-command-OSWGCFFL.js +0 -3
@@ -1,3 +1,3 @@
1
- import{n as fe}from"./chunk-GWYZVVKY.js";import{A as me,z as M}from"./chunk-LONKINMJ.js";import{c as se,h as ae}from"./chunk-O2M3VNDY.js";import{Q as D,R as ue,U as pe,V as he}from"./chunk-6WAPPQ5F.js";import{B as N,D as ge}from"./chunk-MEUHIDI3.js";import{d as ie}from"./chunk-5FWR5HLG.js";import{K as ce,L as le,V as de,a as j,k as ne,l as k}from"./chunk-T75DS2E6.js";import{g as oe}from"./chunk-RCIGX23V.js";import{j as w,r as W}from"./chunk-D7DOB27N.js";import{a as Y,c as Z,e as ee}from"./chunk-6O3KXIDL.js";import{H,I as z,J as R,K as X,M as J,N as K,P,R as te,T as O,V as re,W as T,X as _,h as C,n as V}from"./chunk-UQYQBLJX.js";import{statSync as ye}from"fs";import{basename as He,isAbsolute as ze,join as L,relative as Xe}from"path";import{fileURLToPath as Je}from"url";import{watch as Ke}from"chokidar";import Ze from"ignore";var Ee=5e3,Re=class{projectRoot;config;watchConfig;outputDb;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onReindexError;onRefreshSuppressed;onFileChanged;onBulkChange;onError;reindexRunner;subscriptionFactory;budgetInspector;clock;activeOperation=null;stopPromise=null;stopInProgress=!1;status={state:"idle"};debounceTimer=null;cooldownTimer=null;budgetTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fileChangeTimer=null;pendingFileChanges=new Set;bulkChangePending=!1;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;observationEpoch=0;changeSequence=0;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=ge(e.config),this.outputDb=e.outputDb??L(z(this.projectRoot,e.config),"index.db"),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onReindexError=e.onReindexError??(()=>{}),this.onRefreshSuppressed=e.onRefreshSuppressed??(()=>{}),this.onFileChanged=e.onFileChanged,this.onBulkChange=e.onBulkChange;let r=e.onError??(n=>console.error(n.message));this.onError=n=>{this.observationEpoch+=1,r(n)},this.clock=e.clock??it,Ie.set(this,gt(e.stopTimeoutMs??Ee,"watcher stop timeout")),this.reindexRunner=e.reindexRunner??pt(),this.subscriptionFactory=e.subscriptionFactory??ot,this.budgetInspector=e.budgetInspector??ae,Pe.set(this,{gitReader:e.gitReader??te,languages:Te(e.languages??e.config.languages),stagedIndexEntries:null,gitSignalPaths:null,lastGitSignal:null}),this.gitignoreFilter=oe(e.projectRoot),this.extraIgnore=Ze(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){if(this.stopInProgress)throw new Error("Cannot restart a watcher while its previous ownership is still draining.");this.stopped=!1,this.stopPromise=null,G(this).errors=[],this.sourcePollingFallbackStarted=!1,this.observationEpoch+=1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(e){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let e=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearBudgetTimer(),this.clearGitPollTimer(),this.clearFileChangeWindow();let r=this.activeOperation;r&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"});let n=[...G(this).closures],i=tt(this),s=this.clock.now()+i;return this.stopPromise=this.finishStop(e,n,r,s,i).catch(a=>{throw this.stopInProgress=!1,a}),this.stopPromise}observation(){return{epoch:this.observationEpoch,changeSequence:this.changeSequence}}requestRefresh(e,r={}){if(!this.stopped){if(!r.immediate||this.reindexInFlight||this.status.state==="cooldown"||this.status.state==="budget-paused"){this.scheduleReindex(e);return}this.pendingTrigger=Se(this.pendingTrigger,e),this.changedFiles+=1,this.changeSequence+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(e=!1){let r=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(n,i)=>this.isIgnoredWatchPath(n,i?.isDirectory()??!1),usePolling:e,...e?{interval:500,binaryInterval:1e3}:{}});r.on("all",(n,i)=>{!this.stopped&&n!=="addDir"&&n!=="unlinkDir"&&this.handleFileChange(i)}),r.on("error",n=>this.handleSourceWatcherError(r,n,e)),this.fsWatchers.push(r)}handleSourceWatcherError(e,r,n){if(n||this.sourcePollingFallbackStarted||!ht(r)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`));return}this.observationEpoch+=1,this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(i=>i!==e),rt(G(this),e,i=>this.onError(i));try{this.startSourceWatcher(!0)}catch(i){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(i)}`))}}isIgnoredWatchPath(e,r){let n=this.relativeWatchPath(e);if(!n)return!1;let i=r?`${n}/`:n;return i===".git/"||i.startsWith(".git/")?!0:this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)}handleFileChange(e){let r=this.relativeWatchPath(e);!r||r===".."||r.startsWith("../")||r===".git"||r.startsWith(".git/")||this.gitignoreFilter.isIgnored(r)||this.extraIgnore.ignores(r)||r.endsWith("index.db")||r.endsWith("index.scip")||r.endsWith("index.db.tmp")||He(r).startsWith(se)||(r===".codebaseiq.json"&&Ce(this,this.projectRoot),we(this,r)&&(this.noteFileChange(r),this.scheduleReindex({kind:"watch-source",detail:r})))}noteFileChange(e){!this.onFileChanged&&!this.onBulkChange||(this.bulkChangePending||(this.pendingFileChanges.add(e),this.pendingFileChanges.size>at&&(this.pendingFileChanges.clear(),this.bulkChangePending=!0)),this.fileChangeTimer??=this.clock.setTimeout(()=>this.flushFileChangeWindow(),st))}flushFileChangeWindow(){if(this.fileChangeTimer=null,this.stopped)return;let e=[...this.pendingFileChanges],r=this.bulkChangePending;this.pendingFileChanges.clear(),this.bulkChangePending=!1;try{r?this.onBulkChange?.():this.onFileChanged?.(e)}catch{}}clearFileChangeWindow(){this.fileChangeTimer&&(this.clock.clearTimeout(this.fileChangeTimer),this.fileChangeTimer=null),this.pendingFileChanges.clear(),this.bulkChangePending=!1}relativeWatchPath(e){let r=ze(e)?e:L(this.projectRoot,e);return Xe(this.projectRoot,r).replaceAll("\\","/")}scheduleReindex(e){if(this.pendingTrigger=Se(this.pendingTrigger,e),this.changedFiles++,this.changeSequence+=1,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}if(this.status.state==="budget-paused"){this.dirty=!0,this.setStatus({...this.status,dirty:!0});return}this.clearDebounceTimer();let r=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:r}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=this.inspectBudget();if(e.state==="paused"){this.dirty=!0;let a=Math.max(this.wallNow()+1,e.until);this.setStatus({state:"budget-paused",until:a,dirty:!0,reason:e.detail,rebuilt:e.rebuilt,estimatedWriteBytes:e.estimatedWriteBytes}),this.clearBudgetTimer(),this.budgetTimer=this.clock.setTimeout(()=>{this.budgetTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},Math.min(2147483647,Math.max(1,a-this.wallNow())));return}let r=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&r<this.watchConfig.cooldownMs){let a=this.watchConfig.cooldownMs-r;this.dirty=!0;let o=this.wallNow()+a;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},a);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let n=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let i=this.wallNow();this.setStatus({state:"indexing",startedAt:i});let s=this.reindexRunner.start(this.reindexRequest(n));this.activeOperation=s,s.completion.then(a=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let o=!1;try{o=this.onReindexComplete(a,n)===!0}catch(l){this.onError(l instanceof Error?l:new Error(String(l)))}if(this.dirty&&!this.stopped){if(o){let c=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.onRefreshSuppressed(c),this.setStatus({state:"idle"});return}let l=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:l,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(a=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let o=a instanceof Error?a:new Error(String(a));this.onReindexError(o,n),this.onError(o),this.setStatus({state:"idle"})}).finally(()=>{this.activeOperation===s&&(this.activeOperation=null)})}async finishStop(e,r,n,i,s){let a=[],o=e.map(async p=>{try{await p.close()}catch(m){a.push(`watch subscription close failed: ${String(m)}`)}});o.push(...r),n&&o.push((async()=>{try{let p=await n.cancel();p.state==="degraded"&&a.push(p.reason)}catch(p){a.push(`reindex cancellation failed: ${p instanceof Error?p.message:String(p)}`)}})());let l=o.length,c=o.map(p=>p.finally(()=>{l-=1})),u=await et(c,i,this.clock),d=G(this);return a.push(...d.errors),d.errors=[],u?this.stopInProgress=!1:(a.push(`watch shutdown exceeded the ${s}ms deadline with ${l} operation(s) still pending`),Promise.all(c).then(()=>{this.stopInProgress=!1})),a.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:a.join("; ")}),{state:"degraded",reasons:a}):(this.setStatus({state:"idle"}),{state:"stopped"})}wallNow(){return this.clock.wallNow?.()??this.clock.now()}inspectBudget(){try{return this.budgetInspector(this.outputDb,this.watchConfig.resourceBudget,new Date(this.wallNow()))}catch(e){return{state:"paused",reason:"activity-evidence",until:this.wallNow()+this.watchConfig.resourceBudget.windowMs,rebuilt:0,estimatedWriteBytes:0,detail:`reindex activity evidence could not be read: ${e instanceof Error?e.message:String(e)}`}}}reindexRequest(e){return{projectRoot:this.projectRoot,config:this.config,languages:this.languages,pnpmWorkspaces:this.pnpmWorkspaces,typescriptProjectMode:this.typescriptProjectMode,typescriptProjects:this.typescriptProjects,clojureConfigPath:this.clojureConfigPath,indexerConcurrency:this.indexerConcurrency,trigger:e}}setStatus(e){this.status=e,this.onStatus(e)}clearDebounceTimer(){this.debounceTimer&&(this.clock.clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(this.clock.clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}clearBudgetTimer(){this.budgetTimer&&(this.clock.clearTimeout(this.budgetTimer),this.budgetTimer=null)}startGitStatePolling(){if(this.lastGitState=this.readGitState(),!this.lastGitState)return;let e=y(this);e.gitSignalPaths=this.resolveGitSignalPaths(),e.lastGitSignal=this.gitActivitySignal(),e.stagedIndexEntries=xe(this.projectRoot,e.gitReader),this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.()}resolveGitSignalPaths(){let e=y(this).gitReader,r=T(this.projectRoot,["rev-parse","--git-dir"],e),n=T(this.projectRoot,["rev-parse","--git-common-dir"],e);if(!r)return null;let i=_(this.projectRoot,r),s=n?_(this.projectRoot,n):i,a=this.lastGitState?.indexPath;return[L(i,"HEAD"),L(s,"packed-refs"),L(s,"refs","heads"),...a?[a]:[]]}gitActivitySignal(){let e=y(this).gitSignalPaths;if(!e)return null;let r="";for(let n of e)try{let i=ye(n);r+=`${n}:${i.mtimeMs}:${i.size};`}catch{r+=`${n}:absent;`}return r}pollGitState(){let e=this.gitActivitySignal();if(e!==null){if(e===y(this).lastGitSignal)return;y(this).lastGitSignal=e}let r=this.lastGitState,n=this.readGitState();if(!r||!n||this.stopped){this.lastGitState=n;return}this.lastGitState=n;let i=r.head!==n.head,s=r.indexPath!==n.indexPath||r.indexMtimeMs!==n.indexMtimeMs||r.indexSize!==n.indexSize;if(!i&&!s)return;let a=y(this),o=a.stagedIndexEntries,l=xe(this.projectRoot,a.gitReader);a.stagedIndexEntries=l;let c=ft(this.projectRoot,a.gitReader,r,n,o,l,i,s),u=null;c!==null&&(c.includes(".codebaseiq.json")&&Ce(this,this.projectRoot),u=c.filter(d=>we(this,d)),u.length===0)||(i&&s?this.scheduleReindex({kind:"watch-git-state",detail:F("HEAD and index changed",u)}):i?this.scheduleReindex({kind:"watch-git-head",detail:F("HEAD changed",u)}):s&&this.scheduleReindex({kind:"watch-git-index",detail:F(n.indexPath??"index changed",u)}))}readGitState(){let e=y(this).gitReader,r=T(this.projectRoot,["rev-parse","--git-path","index"],e);if(!r)return null;let n=_(this.projectRoot,r),i={head:T(this.projectRoot,["rev-parse","--verify","HEAD"],e),indexPath:n};try{let s=ye(n);i.indexMtimeMs=s.mtimeMs,i.indexSize=s.size}catch{i.indexMtimeMs=void 0,i.indexSize=void 0}return i}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};async function et(t,e,r){if(t.length===0)return!0;let n=Promise.all(t).then(()=>!0),i=Math.max(0,e-r.now()),s=null,a=new Promise(l=>{s=r.setTimeout(()=>l(!1),i)}),o=await Promise.race([n,a]);return o&&s&&r.clearTimeout(s),o}var ve=new WeakMap,Ie=new WeakMap,Pe=new WeakMap;function G(t){let e=ve.get(t);if(e)return e;let r={closures:new Set,errors:[]};return ve.set(t,r),r}function tt(t){return Ie.get(t)??Ee}function y(t){let e=Pe.get(t);if(!e)throw new Error("Watcher input state was not initialized.");return e}function rt(t,e,r){let n=Promise.resolve().then(()=>e.close()).catch(i=>{let s=`watch subscription close failed during polling fallback: ${String(i)}`;t.errors.push(s),r(new Error(s))});t.closures.add(n),n.then(()=>t.closures.delete(n))}function nt(t,e=ee){let{projectRoot:r,config:n,languages:i,pnpmWorkspaces:s,typescriptProjectMode:a,typescriptProjects:o,clojureConfigPath:l,indexerConcurrency:c,trigger:u}=t,d=N(r),p=Object.keys(d).length>0?d:n,m=K(r,p),f=p.indexer?.typescript,g=p.indexer?.clojure,I=e(process.pid);if(!I)throw new Error(`Could not establish watcher process identity for reindex worker ownership (pid ${process.pid}).`);return{workerPath:Je(new URL("./reindex-worker.js",import.meta.url)),env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:r,SCIP_REINDEX_OUTPUT_SCIP:m.indexPath,SCIP_REINDEX_OUTPUT_DB:m.dbPath,SCIP_REINDEX_LANGUAGES:(p.languages??i)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(p.indexerConcurrency??c??""),SCIP_REINDEX_PNPM_WORKSPACES:f?.pnpmWorkspaces??s?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:f?.projectMode??a,projects:f?.projects??o??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:g?.configPath??l??"",SCIP_REINDEX_TRIGGER_KIND:u.kind,SCIP_REINDEX_TRIGGER_DETAIL:u.detail??"",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1",SCIP_REINDEX_PARENT_IDENTITY:JSON.stringify(I)}}}var it={now:Y,wallNow:()=>Date.now(),setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},ot=(t,e)=>Ke(t,e),st=120,at=200,ct=15*6e4,lt=1e3,dt=64*1024;function ut(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function be(t,e){let r=t instanceof Error?t.message:String(t),n=e.stderrTail.trim()||e.stdoutTail.trim();return n?`${r}
1
+ import{n as fe}from"./chunk-V4NGDIEA.js";import{A as me,z as M}from"./chunk-JNXI6NQ7.js";import{c as se,h as ae}from"./chunk-O2M3VNDY.js";import{Q as D,R as ue,U as pe,V as he}from"./chunk-K4S2VH42.js";import{B as N,D as ge}from"./chunk-MEUHIDI3.js";import{d as ie}from"./chunk-5FWR5HLG.js";import{K as ce,L as le,V as de,a as j,k as ne,l as k}from"./chunk-T75DS2E6.js";import{g as oe}from"./chunk-RCIGX23V.js";import{j as w,r as W}from"./chunk-D7DOB27N.js";import{a as Y,c as Z,e as ee}from"./chunk-6O3KXIDL.js";import{H,I as z,J as R,K as X,M as J,N as K,P,R as te,T as O,V as re,W as T,X as _,h as C,n as V}from"./chunk-UQYQBLJX.js";import{statSync as ye}from"fs";import{basename as He,isAbsolute as ze,join as L,relative as Xe}from"path";import{fileURLToPath as Je}from"url";import{watch as Ke}from"chokidar";import Ze from"ignore";var Ee=5e3,Re=class{projectRoot;config;watchConfig;outputDb;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onReindexError;onRefreshSuppressed;onFileChanged;onBulkChange;onError;reindexRunner;subscriptionFactory;budgetInspector;clock;activeOperation=null;stopPromise=null;stopInProgress=!1;status={state:"idle"};debounceTimer=null;cooldownTimer=null;budgetTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fileChangeTimer=null;pendingFileChanges=new Set;bulkChangePending=!1;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;observationEpoch=0;changeSequence=0;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=ge(e.config),this.outputDb=e.outputDb??L(z(this.projectRoot,e.config),"index.db"),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onReindexError=e.onReindexError??(()=>{}),this.onRefreshSuppressed=e.onRefreshSuppressed??(()=>{}),this.onFileChanged=e.onFileChanged,this.onBulkChange=e.onBulkChange;let r=e.onError??(n=>console.error(n.message));this.onError=n=>{this.observationEpoch+=1,r(n)},this.clock=e.clock??it,Ie.set(this,gt(e.stopTimeoutMs??Ee,"watcher stop timeout")),this.reindexRunner=e.reindexRunner??pt(),this.subscriptionFactory=e.subscriptionFactory??ot,this.budgetInspector=e.budgetInspector??ae,Pe.set(this,{gitReader:e.gitReader??te,languages:Te(e.languages??e.config.languages),stagedIndexEntries:null,gitSignalPaths:null,lastGitSignal:null}),this.gitignoreFilter=oe(e.projectRoot),this.extraIgnore=Ze(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){if(this.stopInProgress)throw new Error("Cannot restart a watcher while its previous ownership is still draining.");this.stopped=!1,this.stopPromise=null,G(this).errors=[],this.sourcePollingFallbackStarted=!1,this.observationEpoch+=1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(e){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let e=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearBudgetTimer(),this.clearGitPollTimer(),this.clearFileChangeWindow();let r=this.activeOperation;r&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"});let n=[...G(this).closures],i=tt(this),s=this.clock.now()+i;return this.stopPromise=this.finishStop(e,n,r,s,i).catch(a=>{throw this.stopInProgress=!1,a}),this.stopPromise}observation(){return{epoch:this.observationEpoch,changeSequence:this.changeSequence}}requestRefresh(e,r={}){if(!this.stopped){if(!r.immediate||this.reindexInFlight||this.status.state==="cooldown"||this.status.state==="budget-paused"){this.scheduleReindex(e);return}this.pendingTrigger=Se(this.pendingTrigger,e),this.changedFiles+=1,this.changeSequence+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(e=!1){let r=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(n,i)=>this.isIgnoredWatchPath(n,i?.isDirectory()??!1),usePolling:e,...e?{interval:500,binaryInterval:1e3}:{}});r.on("all",(n,i)=>{!this.stopped&&n!=="addDir"&&n!=="unlinkDir"&&this.handleFileChange(i)}),r.on("error",n=>this.handleSourceWatcherError(r,n,e)),this.fsWatchers.push(r)}handleSourceWatcherError(e,r,n){if(n||this.sourcePollingFallbackStarted||!ht(r)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`));return}this.observationEpoch+=1,this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(i=>i!==e),rt(G(this),e,i=>this.onError(i));try{this.startSourceWatcher(!0)}catch(i){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(i)}`))}}isIgnoredWatchPath(e,r){let n=this.relativeWatchPath(e);if(!n)return!1;let i=r?`${n}/`:n;return i===".git/"||i.startsWith(".git/")?!0:this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)}handleFileChange(e){let r=this.relativeWatchPath(e);!r||r===".."||r.startsWith("../")||r===".git"||r.startsWith(".git/")||this.gitignoreFilter.isIgnored(r)||this.extraIgnore.ignores(r)||r.endsWith("index.db")||r.endsWith("index.scip")||r.endsWith("index.db.tmp")||He(r).startsWith(se)||(r===".codebaseiq.json"&&Ce(this,this.projectRoot),we(this,r)&&(this.noteFileChange(r),this.scheduleReindex({kind:"watch-source",detail:r})))}noteFileChange(e){!this.onFileChanged&&!this.onBulkChange||(this.bulkChangePending||(this.pendingFileChanges.add(e),this.pendingFileChanges.size>at&&(this.pendingFileChanges.clear(),this.bulkChangePending=!0)),this.fileChangeTimer??=this.clock.setTimeout(()=>this.flushFileChangeWindow(),st))}flushFileChangeWindow(){if(this.fileChangeTimer=null,this.stopped)return;let e=[...this.pendingFileChanges],r=this.bulkChangePending;this.pendingFileChanges.clear(),this.bulkChangePending=!1;try{r?this.onBulkChange?.():this.onFileChanged?.(e)}catch{}}clearFileChangeWindow(){this.fileChangeTimer&&(this.clock.clearTimeout(this.fileChangeTimer),this.fileChangeTimer=null),this.pendingFileChanges.clear(),this.bulkChangePending=!1}relativeWatchPath(e){let r=ze(e)?e:L(this.projectRoot,e);return Xe(this.projectRoot,r).replaceAll("\\","/")}scheduleReindex(e){if(this.pendingTrigger=Se(this.pendingTrigger,e),this.changedFiles++,this.changeSequence+=1,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}if(this.status.state==="budget-paused"){this.dirty=!0,this.setStatus({...this.status,dirty:!0});return}this.clearDebounceTimer();let r=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:r}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=this.inspectBudget();if(e.state==="paused"){this.dirty=!0;let a=Math.max(this.wallNow()+1,e.until);this.setStatus({state:"budget-paused",until:a,dirty:!0,reason:e.detail,rebuilt:e.rebuilt,estimatedWriteBytes:e.estimatedWriteBytes}),this.clearBudgetTimer(),this.budgetTimer=this.clock.setTimeout(()=>{this.budgetTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},Math.min(2147483647,Math.max(1,a-this.wallNow())));return}let r=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&r<this.watchConfig.cooldownMs){let a=this.watchConfig.cooldownMs-r;this.dirty=!0;let o=this.wallNow()+a;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},a);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let n=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let i=this.wallNow();this.setStatus({state:"indexing",startedAt:i});let s=this.reindexRunner.start(this.reindexRequest(n));this.activeOperation=s,s.completion.then(a=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let o=!1;try{o=this.onReindexComplete(a,n)===!0}catch(l){this.onError(l instanceof Error?l:new Error(String(l)))}if(this.dirty&&!this.stopped){if(o){let c=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.onRefreshSuppressed(c),this.setStatus({state:"idle"});return}let l=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:l,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(a=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let o=a instanceof Error?a:new Error(String(a));this.onReindexError(o,n),this.onError(o),this.setStatus({state:"idle"})}).finally(()=>{this.activeOperation===s&&(this.activeOperation=null)})}async finishStop(e,r,n,i,s){let a=[],o=e.map(async p=>{try{await p.close()}catch(m){a.push(`watch subscription close failed: ${String(m)}`)}});o.push(...r),n&&o.push((async()=>{try{let p=await n.cancel();p.state==="degraded"&&a.push(p.reason)}catch(p){a.push(`reindex cancellation failed: ${p instanceof Error?p.message:String(p)}`)}})());let l=o.length,c=o.map(p=>p.finally(()=>{l-=1})),u=await et(c,i,this.clock),d=G(this);return a.push(...d.errors),d.errors=[],u?this.stopInProgress=!1:(a.push(`watch shutdown exceeded the ${s}ms deadline with ${l} operation(s) still pending`),Promise.all(c).then(()=>{this.stopInProgress=!1})),a.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:a.join("; ")}),{state:"degraded",reasons:a}):(this.setStatus({state:"idle"}),{state:"stopped"})}wallNow(){return this.clock.wallNow?.()??this.clock.now()}inspectBudget(){try{return this.budgetInspector(this.outputDb,this.watchConfig.resourceBudget,new Date(this.wallNow()))}catch(e){return{state:"paused",reason:"activity-evidence",until:this.wallNow()+this.watchConfig.resourceBudget.windowMs,rebuilt:0,estimatedWriteBytes:0,detail:`reindex activity evidence could not be read: ${e instanceof Error?e.message:String(e)}`}}}reindexRequest(e){return{projectRoot:this.projectRoot,config:this.config,languages:this.languages,pnpmWorkspaces:this.pnpmWorkspaces,typescriptProjectMode:this.typescriptProjectMode,typescriptProjects:this.typescriptProjects,clojureConfigPath:this.clojureConfigPath,indexerConcurrency:this.indexerConcurrency,trigger:e}}setStatus(e){this.status=e,this.onStatus(e)}clearDebounceTimer(){this.debounceTimer&&(this.clock.clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(this.clock.clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}clearBudgetTimer(){this.budgetTimer&&(this.clock.clearTimeout(this.budgetTimer),this.budgetTimer=null)}startGitStatePolling(){if(this.lastGitState=this.readGitState(),!this.lastGitState)return;let e=y(this);e.gitSignalPaths=this.resolveGitSignalPaths(),e.lastGitSignal=this.gitActivitySignal(),e.stagedIndexEntries=xe(this.projectRoot,e.gitReader),this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.()}resolveGitSignalPaths(){let e=y(this).gitReader,r=T(this.projectRoot,["rev-parse","--git-dir"],e),n=T(this.projectRoot,["rev-parse","--git-common-dir"],e);if(!r)return null;let i=_(this.projectRoot,r),s=n?_(this.projectRoot,n):i,a=this.lastGitState?.indexPath;return[L(i,"HEAD"),L(s,"packed-refs"),L(s,"refs","heads"),...a?[a]:[]]}gitActivitySignal(){let e=y(this).gitSignalPaths;if(!e)return null;let r="";for(let n of e)try{let i=ye(n);r+=`${n}:${i.mtimeMs}:${i.size};`}catch{r+=`${n}:absent;`}return r}pollGitState(){let e=this.gitActivitySignal();if(e!==null){if(e===y(this).lastGitSignal)return;y(this).lastGitSignal=e}let r=this.lastGitState,n=this.readGitState();if(!r||!n||this.stopped){this.lastGitState=n;return}this.lastGitState=n;let i=r.head!==n.head,s=r.indexPath!==n.indexPath||r.indexMtimeMs!==n.indexMtimeMs||r.indexSize!==n.indexSize;if(!i&&!s)return;let a=y(this),o=a.stagedIndexEntries,l=xe(this.projectRoot,a.gitReader);a.stagedIndexEntries=l;let c=ft(this.projectRoot,a.gitReader,r,n,o,l,i,s),u=null;c!==null&&(c.includes(".codebaseiq.json")&&Ce(this,this.projectRoot),u=c.filter(d=>we(this,d)),u.length===0)||(i&&s?this.scheduleReindex({kind:"watch-git-state",detail:F("HEAD and index changed",u)}):i?this.scheduleReindex({kind:"watch-git-head",detail:F("HEAD changed",u)}):s&&this.scheduleReindex({kind:"watch-git-index",detail:F(n.indexPath??"index changed",u)}))}readGitState(){let e=y(this).gitReader,r=T(this.projectRoot,["rev-parse","--git-path","index"],e);if(!r)return null;let n=_(this.projectRoot,r),i={head:T(this.projectRoot,["rev-parse","--verify","HEAD"],e),indexPath:n};try{let s=ye(n);i.indexMtimeMs=s.mtimeMs,i.indexSize=s.size}catch{i.indexMtimeMs=void 0,i.indexSize=void 0}return i}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};async function et(t,e,r){if(t.length===0)return!0;let n=Promise.all(t).then(()=>!0),i=Math.max(0,e-r.now()),s=null,a=new Promise(l=>{s=r.setTimeout(()=>l(!1),i)}),o=await Promise.race([n,a]);return o&&s&&r.clearTimeout(s),o}var ve=new WeakMap,Ie=new WeakMap,Pe=new WeakMap;function G(t){let e=ve.get(t);if(e)return e;let r={closures:new Set,errors:[]};return ve.set(t,r),r}function tt(t){return Ie.get(t)??Ee}function y(t){let e=Pe.get(t);if(!e)throw new Error("Watcher input state was not initialized.");return e}function rt(t,e,r){let n=Promise.resolve().then(()=>e.close()).catch(i=>{let s=`watch subscription close failed during polling fallback: ${String(i)}`;t.errors.push(s),r(new Error(s))});t.closures.add(n),n.then(()=>t.closures.delete(n))}function nt(t,e=ee){let{projectRoot:r,config:n,languages:i,pnpmWorkspaces:s,typescriptProjectMode:a,typescriptProjects:o,clojureConfigPath:l,indexerConcurrency:c,trigger:u}=t,d=N(r),p=Object.keys(d).length>0?d:n,m=K(r,p),f=p.indexer?.typescript,g=p.indexer?.clojure,I=e(process.pid);if(!I)throw new Error(`Could not establish watcher process identity for reindex worker ownership (pid ${process.pid}).`);return{workerPath:Je(new URL("./reindex-worker.js",import.meta.url)),env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:r,SCIP_REINDEX_OUTPUT_SCIP:m.indexPath,SCIP_REINDEX_OUTPUT_DB:m.dbPath,SCIP_REINDEX_LANGUAGES:(p.languages??i)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(p.indexerConcurrency??c??""),SCIP_REINDEX_PNPM_WORKSPACES:f?.pnpmWorkspaces??s?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:f?.projectMode??a,projects:f?.projects??o??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:g?.configPath??l??"",SCIP_REINDEX_TRIGGER_KIND:u.kind,SCIP_REINDEX_TRIGGER_DETAIL:u.detail??"",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1",SCIP_REINDEX_PARENT_IDENTITY:JSON.stringify(I)}}}var it={now:Y,wallNow:()=>Date.now(),setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},ot=(t,e)=>Ke(t,e),st=120,at=200,ct=15*6e4,lt=1e3,dt=64*1024;function ut(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function be(t,e){let r=t instanceof Error?t.message:String(t),n=e.stderrTail.trim()||e.stdoutTail.trim();return n?`${r}
2
2
  ${n}`:r}function pt(t={}){let e=t.timeoutMs??ct,r=t.terminationGraceMs??lt,n=t.maxOutputBytes??dt,i=t.resolveLaunch??nt;return{start(s){let a=i(s),o=new AbortController,l=ut(),c=!1,u=he({command:process.execPath,args:[...process.execArgv,a.workerPath],label:"watch reindex worker",env:a.env,timeoutMs:e,terminationGraceMs:r,maxStdoutBytes:n,maxStderrBytes:n,outputLimitBehavior:"truncate-tail",signal:o.signal,detached:!0}).then(d=>{if(l={stdoutTail:d.stdout,stderrTail:d.stderr,stdoutTruncated:d.stdoutTruncated,stderrTruncated:d.stderrTruncated},d.status!==0)throw new Error(be(new Error(`Reindex worker exited with ${d.signal?`signal ${d.signal}`:`code ${d.status}`}`),l));return d.durationMs}).catch(d=>{throw d instanceof pe&&(l={stdoutTail:d.stdout,stderrTail:d.stderr,stdoutTruncated:d.stdoutTruncated,stderrTruncated:d.stderrTruncated}),new Error(be(d,l),{cause:d})}).finally(()=>{c=!0});return{completion:u,async cancel(){c||o.abort();try{await u}catch{}return{state:"exited",diagnostics:l}},diagnostics:()=>l}}}}function Se(t,e){return t?t.kind===e.kind?t.detail===e.detail?t:{kind:t.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${t.kind}, ${e.kind}`}:e}function ht(t){return t instanceof Error&&"code"in t&&t.code==="EMFILE"||String(t).includes("EMFILE: too many open files")}function gt(t,e){if(!Number.isSafeInteger(t)||t<=0)throw new Error(`${e} must be a positive integer.`);return t}function Te(t){return t&&t.length>0?[...t]:j}function Ce(t,e){try{y(t).languages=Te(N(e).languages)}catch{y(t).languages=j}}function we(t,e){return V(e,y(t).languages)!=="other"}function ft(t,e,r,n,i,s,a,o){let l=new Set;if(a){if(!r.head||!n.head)return null;let c=e.runResult(t,["diff","--name-only","-z","--no-renames","--relative",r.head,n.head,"--"]);if(c.kind!=="success")return null;for(let u of mt(c.output))l.add(u)}if(o){if(i===null||s===null)return null;for(let c of Rt(i,s))l.add(c)}return[...l].sort()}function xe(t,e){let r=e.runResult(t,["diff","--cached","--raw","-z","--no-renames","--relative","--"]);return r.kind==="success"?yt(r.output):null}function mt(t){return t.split("\0").filter(e=>e.length>0)}function yt(t){let e=t.split("\0");if(e.at(-1)===""&&e.pop(),e.length%2!==0)return null;let r=new Map;for(let n=0;n<e.length;n+=2){let i=e[n],s=e[n+1];if(!i.startsWith(":")||!s)return null;r.set(s,i)}return r}function Rt(t,e){return[...new Set([...t.keys(),...e.keys()])].filter(n=>t.get(n)!==e.get(n))}function F(t,e){return e===null?`${t}; changed paths unavailable`:e.length===0?t:e.length===1?e[0]:`${e.length} compiler inputs changed`}import{existsSync as E,lstatSync as b,readdirSync as Ae,realpathSync as ke,rmSync as v,statSync as _e}from"fs";import{join as h,resolve as A,sep as We}from"path";var vt=3600*1e3,bt=2*1024*1024*1024,B=300*1e3,St="gc-state.json",Ct="gc.lock",wt="projects-gc-state.json",xt="projects-gc.lock",Et=1440*60*1e3;function It(t){let e=t.leases.filter(o=>o.managed&&!o.live&&!o.busy),r=Ge(t.leases,t.locks),n={};for(let o of t.generations)r.has(o.generationId)||(n[o.generationId]=o.unreferencedAt??t.nowMs);let i=t.generations.filter(o=>!r.has(o.generationId)).sort((o,l)=>n[o.generationId]-n[l.generationId]||o.generationId.localeCompare(l.generationId)),s=new Set;for(let o of i)t.nowMs-n[o.generationId]>=t.policy.generationTtlMs&&s.add(o.generationId);let a=t.generations.filter(o=>!s.has(o.generationId)).reduce((o,l)=>o+l.size,0);for(let o of i){if(a<=t.policy.budgetBytes)break;s.has(o.generationId)||(s.add(o.generationId),a-=o.size)}for(let o of s)delete n[o];return{deleteWorktrees:e,deleteGenerations:t.generations.filter(o=>s.has(o.generationId)),deleteLocks:t.locks.filter(o=>!o.live),deleteTemporaries:t.temporaries.filter(o=>!o.live),protectedGenerationIds:[...r].sort(),unreferencedSince:n}}function Ge(t,e){let r=new Set(t.filter(n=>n.managed&&(n.live||n.busy)).flatMap(n=>[n.lease.baseGenerationId,n.lease.activeGenerationId]).filter(n=>n!==void 0));for(let n of e)n.live&&r.add(n.generationId);return r}function lr(t,e,r={}){if(!J())return{kind:"disabled"};let n=O(t);if(!n)return{kind:"unavailable"};let i=h(R(),"repositories",n.repositoryId),s=(r.now??Date.now)(),a=E(i)?je(t,i,n.repositoryId,e,s,r):{kind:"unavailable"};return kt(t,n.repositoryId,e,s,r),Pt(s,r),a}function Pt(t,e){let r=h(R(),"projects"),n={examined:0,reclaimed:0};if(!E(r))return n;let i=h(r,wt),s=Ne(i);if(!e.force&&s!==void 0&&t-s<B)return n;let a=k(h(r,xt));if(!a)return n;try{for(let o of x(r)){let l=h(r,o),c;try{c=b(l)}catch{continue}if(!(!c.isDirectory()||c.isSymbolicLink())&&(n.examined+=1,!!Tt(l,t)))try{v(l,{recursive:!0,force:!0}),n.reclaimed+=1}catch{}}W(i,{version:1,lastSweepAt:new Date(t).toISOString()},{spacing:2,trailingNewline:!0})}finally{a.release()}return n}function Tt(t,e){let r=h(t,H),n;try{let a=JSON.parse(C(r,"cache-ownership"));if(typeof a.canonicalProjectRoot!="string"||a.canonicalProjectRoot.length===0)return!1;n=a.canonicalProjectRoot}catch{return!1}if(E(n))return!1;try{if(e-b(t).mtimeMs<Et)return!1}catch{return!1}let i=ue(D(t).statePath);if(i&&w(i.pid))return!1;let s=k(h(t,"cache-lifecycle.lock"));return s===null?!1:(s.release(),!0)}function je(t,e,r,n,i,s){let a=h(e,"gc-state.json"),o=De(a);if(!s.force&&o&&i-Date.parse(o.lastSweepAt)<B)return{kind:"throttled",sweptAt:o.lastSweepAt};let l=ne(e,{now:()=>i});if(!l)return{kind:"busy"};try{let c=Oe(t,e,r,o?.unreferencedSince??{}),u=It({nowMs:i,...c,policy:{generationTtlMs:s.policy?.generationTtlMs??vt,budgetBytes:s.policy?.budgetBytes??bt}}),d=0,p=0;for(let g of u.deleteWorktrees){if(!Q(g.lease))continue;if(!E(g.lease.localCacheDir)){v(g.leasePath,{force:!0}),p+=1;continue}if(!At(g.lease))continue;let I=k(h(g.lease.localCacheDir,"cache-lifecycle.lock"));if(I)try{if($(g.lease,!0))continue;try{fe({projectRoot:g.lease.projectRoot,cacheDir:g.lease.localCacheDir,cliVersion:n})}catch{continue}if($(g.lease,!0))continue;v(g.lease.localCacheDir,{recursive:!0,force:!0}),v(g.leasePath,{force:!0}),p+=1}finally{I.release()}}for(let g of u.deleteLocks)v(g.path,{force:!0});for(let g of u.deleteTemporaries)v(g.path,{recursive:!0,force:!0});for(let g of u.deleteGenerations)v(g.path,{recursive:!0,force:!0}),d+=g.size;ie(h(e,"evidence.db"));let m={kind:"swept",sweptAt:new Date(i).toISOString(),deletedWorktrees:p,deletedGenerations:u.deleteGenerations.length,deletedBytes:d,protectedGenerations:u.protectedGenerationIds.length},f={version:1,lastSweepAt:m.sweptAt,unreferencedSince:u.unreferencedSince,lastResult:m};return W(a,f,{spacing:2,trailingNewline:!0}),m}catch(c){return{kind:"failed",error:c instanceof Error?c.message:String(c)}}finally{l.release()}}function kt(t,e,r,n,i){let s=h(R(),"repositories");if(!E(s))return;let a=h(s,St),o=Ne(a);if(!i.force&&o!==void 0&&n-o<B)return;let l=k(h(s,Ct));if(l)try{for(let c of x(s)){if(c===e||!/^[a-f0-9]{24}$/.test(c))continue;let u=h(s,c),d;try{d=b(u)}catch{continue}if(!d.isDirectory()||d.isSymbolicLink())continue;let p=_t(u)??t;je(p,u,c,r,n,i)}W(a,{version:1,lastSweepAt:new Date(n).toISOString()},{spacing:2,trailingNewline:!0})}finally{l.release()}}function dr(t,e,r){let n=ce(t,r.dbPath,e);if(n)return{state:"bypassed",reason:n,localCacheDir:r.cacheDir,generations:0,generationBytes:0,protectedGenerations:0,unreferencedGenerations:0,unreferencedBytes:0,temporaryGenerations:0,sharedEvidence:{exists:!1,bytes:0}};let i=O(t);if(!i)return{state:"unavailable",reason:"Git worktree identity is unavailable",localCacheDir:r.cacheDir,generations:0,generationBytes:0,protectedGenerations:0,unreferencedGenerations:0,unreferencedBytes:0,temporaryGenerations:0,sharedEvidence:{exists:!1,bytes:0}};let s=h(R(),"repositories",i.repositoryId),a=U(h(s,"worktrees",`${i.worktreeId}.json`)),o=De(h(s,"gc-state.json")),l=Oe(t,s,i.repositoryId,o?.unreferencedSince??{}),c=Ge(l.leases,l.locks),u=l.generations.filter(f=>!c.has(f.generationId)),d=l.generations.reduce((f,g)=>f+g.size,0),p=le(t,e),m=0;return p&&(m=Lt(p)),{state:"managed",repositoryId:i.repositoryId,worktreeId:i.worktreeId,localCacheDir:r.cacheDir,...a?{baseGenerationId:a.baseGenerationId,activeGenerationId:a.activeGenerationId,lastAction:a.lastAction,reason:a.lastReason,lastSeenAt:a.lastSeenAt}:{},generations:l.generations.length,generationBytes:d,protectedGenerations:l.generations.filter(f=>c.has(f.generationId)).length,unreferencedGenerations:u.length,unreferencedBytes:u.reduce((f,g)=>f+g.size,0),temporaryGenerations:l.temporaries.length,sharedEvidence:{path:p,exists:m>0,bytes:m},cleanup:o?.lastResult}}function Lt(t){return[t,`${t}-wal`,`${t}-shm`].reduce((e,r)=>{try{return e+_e(r).size}catch{return e}},0)}function Oe(t,e,r,n){let i=new Set(re(t).map(c=>A(c.path))),s=[];for(let c of x(h(e,"worktrees"))){if(!c.endsWith(".json"))continue;let u=h(e,"worktrees",c),d=U(u);if(!d)continue;let p=A(d.projectRoot);s.push({leasePath:u,lease:d,managed:d.repositoryId===r&&Q(d),live:i.has(p)||E(p),busy:$(d)})}let a=[];for(let c of x(h(e,"locks"))){let u=/^([a-f0-9]{64})\.lock$/.exec(c);if(!u)continue;let d=h(e,"locks",c),p=q(d),m=p!==void 0&&w(p),f=u[1];a.push({generationId:f,path:d,live:m})}let o=[],l=[];for(let c of x(h(e,"generations"))){let u=/^\.tmp-(\d+)-/.exec(c);if(u){let m=h(e,"generations",c),f=Number(u[1]);try{l.push({path:m,size:Le(m),live:Number.isSafeInteger(f)&&w(f)})}catch{}continue}if(!/^[a-f0-9]{64}$/.test(c))continue;let d=h(e,"generations",c),p;try{p=b(d)}catch{continue}!p.isDirectory()||p.isSymbolicLink()||o.push({generationId:c,path:d,size:Le(d),...n[c]===void 0?{}:{unreferencedAt:n[c]}})}return{leases:s,generations:o,locks:a,temporaries:l}}function Q(t){if(t.ownershipChecksum!==de(t)||P(t.localCacheDir)!==P(X(t.projectRoot)))return!1;let e=P(h(R(),"projects"));return P(t.localCacheDir).startsWith(`${e}${We}`)}function At(t){if(!Q(t))return!1;let e=A(R()),r=A(h(e,"projects")),n=A(t.localCacheDir);try{let i=b(e),s=b(r),a=b(n);if(!i.isDirectory()||i.isSymbolicLink()||!s.isDirectory()||s.isSymbolicLink()||!a.isDirectory()||a.isSymbolicLink())return!1;let o=ke(r);return ke(n).startsWith(`${o}${We}`)}catch{return!1}}function _t(t){for(let e of x(h(t,"worktrees"))){if(!e.endsWith(".json"))continue;let r=U(h(t,"worktrees",e));if(r)return r.projectRoot}}function $(t,e=!1){for(let n of e?["index.lock"]:["index.lock","cache-lifecycle.lock"]){let i=q(h(t.localCacheDir,n));if(i!==void 0&&w(i))return!0}let r=q(D(t.localCacheDir).lockPath);return r!==void 0&&w(r)}function U(t){try{let e=JSON.parse(C(t,"worktree cache lease"));return e.version!==1||typeof e.repositoryId!="string"||typeof e.worktreeId!="string"||typeof e.projectRoot!="string"||e.treeOid!==void 0&&typeof e.treeOid!="string"||typeof e.localCacheDir!="string"||e.baseGenerationId!==void 0&&typeof e.baseGenerationId!="string"||e.activeGenerationId!==void 0&&typeof e.activeGenerationId!="string"||typeof e.ownershipChecksum!="string"||!/^[a-f0-9]{64}$/.test(e.ownershipChecksum)||typeof e.lastAction!="string"||e.lastReason!==void 0&&typeof e.lastReason!="string"||typeof e.lastSeenAt!="string"?null:e}catch{return null}}function q(t){try{let e=JSON.parse(C(t,"watch lock record"));return typeof e.pid=="number"&&Number.isSafeInteger(e.pid)&&e.pid>0?e.pid:void 0}catch{return}}function De(t){try{let e=JSON.parse(C(t,"repository cache GC state"));return e.version!==1||typeof e.lastSweepAt!="string"||!Number.isFinite(Date.parse(e.lastSweepAt))||!e.unreferencedSince||typeof e.unreferencedSince!="object"||!e.lastResult?null:e}catch{return null}}function Ne(t){try{let e=JSON.parse(C(t,"global repository cache GC state"));if(e.version!==1||typeof e.lastSweepAt!="string")return;let r=Date.parse(e.lastSweepAt);return Number.isFinite(r)?r:void 0}catch{return}}function x(t){try{return Ae(t)}catch{return[]}}function Le(t){let e=0,r=[t];for(;r.length>0;){let n=r.pop();for(let i of Ae(n,{withFileTypes:!0})){let s=h(n,i.name);i.isDirectory()?r.push(s):i.isFile()&&(e+=_e(s).size)}}return e}import{createHash as Me}from"crypto";import{tmpdir as Wt,userInfo as Gt}from"os";import{join as Fe}from"path";var S=1,mr=1*1024*1024,yr=64*1024*1024,Rr=12e4,vr=["NO_COLOR","FORCE_COLOR","CLICOLOR","CLICOLOR_FORCE","TERM","CODEBASEIQ_DEBUG"];function br(t){let e=$e(),r=Me("sha256").update(`${e}\0${t}`).digest("hex");return process.platform==="win32"?`\\\\.\\pipe\\codebaseiq-lane-${r.slice(0,32)}`:Fe(jt(),`lane-${r.slice(0,24)}.sock`)}function jt(){let t=$e(),e=Me("sha256").update(t).digest("hex").slice(0,16);return Fe(Wt(),`codebaseiq-${e}`)}function $e(){try{return Gt().username}catch{return`uid-${typeof process.getuid=="function"?process.getuid():"unknown"}`}}function Sr(t,e){let r=Buffer.from(JSON.stringify(t),"utf8");if(r.byteLength>e)throw new Error(`query-lane frame of ${r.byteLength} bytes exceeds the ${e}-byte limit`);let n=Buffer.allocUnsafe(4+r.byteLength);return n.writeUInt32LE(r.byteLength,0),r.copy(n,4),n}function Cr(t,e,r){let n=Buffer.alloc(0),i=!1,s=a=>{i||(i=!0,r(new Error(a)))};return{push(a){if(!i)for(n=n.byteLength===0?a:Buffer.concat([n,a]);n.byteLength>=4;){let o=n.readUInt32LE(0);if(o>t){s(`query-lane frame of ${o} bytes exceeds the ${t}-byte limit`);return}if(n.byteLength<4+o)return;let l=n.subarray(4,4+o);n=n.subarray(4+o);let c;try{c=JSON.parse(l.toString("utf8"))}catch{s("query-lane frame carried invalid JSON");return}if(e(c),i)return}}}}function wr(t){if(!t||typeof t!="object")return null;let e=t;return e.protocolVersion!==S||typeof e.projectRoot!="string"||e.projectRoot.length===0?null:e.kind==="ping"?{protocolVersion:S,kind:"ping",projectRoot:e.projectRoot}:e.kind!=="execute"||!Array.isArray(e.argv)||!e.argv.every(r=>typeof r=="string")||typeof e.cwd!="string"||e.deadlineMs!==void 0&&!Number.isFinite(e.deadlineMs)||e.envAllowlist!==void 0&&(typeof e.envAllowlist!="object"||e.envAllowlist===null||Array.isArray(e.envAllowlist)||!Object.values(e.envAllowlist).every(r=>typeof r=="string"))||e.tty!==void 0&&(typeof e.tty!="object"||e.tty===null||typeof e.tty.isTTY!="boolean"||e.tty.columns!==void 0&&!Number.isFinite(e.tty.columns))||e.clientInvocation!==void 0&&(typeof e.clientInvocation!="object"||e.clientInvocation===null||typeof e.clientInvocation.execPath!="string"||e.clientInvocation.execPath.length===0||e.clientInvocation.scriptPath!==void 0&&typeof e.clientInvocation.scriptPath!="string")?null:{...e,kind:"execute"}}function xr(t){if(!t||typeof t!="object")return null;let e=t;if(e.protocolVersion!==S)return null;if(e.ok===!1)return e.code!=="unsupported"&&e.code!=="invalid-request"&&e.code!=="wrong-project"&&e.code!=="busy"&&e.code!=="stale-index"&&e.code!=="ineligible-command"&&e.code!=="execution-error"||typeof e.message!="string"?null:{ok:!1,protocolVersion:S,code:e.code,message:e.message};if(e.ok!==!0)return null;if(e.kind==="accepted"){let n=e.serverPid;return typeof n!="number"||!Number.isInteger(n)||n<=0?null:{ok:!0,kind:"accepted",protocolVersion:S,serverPid:n}}if(e.kind==="executed"){let n=e;return typeof n.serverPid!="number"||!Number.isInteger(n.serverPid)||n.serverPid<=0||typeof n.exitCode!="number"||!Number.isInteger(n.exitCode)||typeof n.stdout!="string"||typeof n.stderr!="string"||typeof n.generation!="string"||!/^[a-f0-9]{64}$/.test(n.generation)||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)?null:{ok:!0,kind:"executed",protocolVersion:S,serverPid:n.serverPid,exitCode:n.exitCode,stdout:n.stdout,stderr:n.stderr,generation:n.generation,durationMs:n.durationMs}}if(e.kind!=="pong"||typeof e.serverPid!="number"||!Number.isInteger(e.serverPid)||e.serverPid<=0||typeof e.cliVersion!="string"||typeof e.projectRoot!="string"||e.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(e.indexGeneration))return null;let r;if(e.processIdentity!==void 0){let n=Z(e.processIdentity);if(!n||n.pid!==e.serverPid)return null;r=n}return{ok:!0,kind:"pong",protocolVersion:S,serverPid:e.serverPid,...r?{processIdentity:r}:{},cliVersion:e.cliVersion,projectRoot:e.projectRoot,...e.indexGeneration!==void 0?{indexGeneration:e.indexGeneration}:{}}}var qe=[{question:"Who can call or reach this?",family:"execution",direction:"incoming"},{question:"What can this call or reach?",family:"execution",direction:"outgoing"},{question:"Where can this value come from?",family:"dataflow",direction:"incoming"},{question:"Where can this value go?",family:"dataflow",direction:"outgoing"},{question:"Which producer and consumer rendezvous?",family:"runtime",direction:"both"},{question:"What resource is observed or changed?",family:"state",direction:"both"},{question:"What occurs before or after this?",family:"temporal",direction:"both"},{question:"What interface constrains this?",family:"contract",direction:"both"},{question:"Are these observations the same entity?",family:"identity",direction:"both"},{question:"What contains or owns this?",family:"ownership",direction:"both"},{question:"What does this statically rely on?",family:"dependencies",direction:"outgoing"}],Be={execution:{establishes:"Static may-call reachability between resolved program constructs.",nonClaims:["A may-call edge does not prove that a runtime invocation occurred."]},runtime:{establishes:"A source-grounded handoff between producer and consumer participants through a runtime mechanism.",nonClaims:["An unresolved or candidate join does not prove a runtime handoff."]},dataflow:{establishes:"A value, definition, argument, parameter, return, or statically resolved value may flow to another construct.",nonClaims:["Current partial providers do not establish general interprocedural definition-use coverage."]},state:{establishes:"A construct reads, writes, creates, deletes, or otherwise changes an identified state resource.",nonClaims:["A state edge does not prove transactionality, durability, or exclusive ownership unless qualified."]},temporal:{establishes:"One observed construct is locally ordered before or after another under the reported source evidence.",nonClaims:["Source order does not imply cross-process happens-before or durability."]},contract:{establishes:"A program construct implements, constrains, or is typed by an identified contract.",nonClaims:["Contract identity does not prove runtime invocation or conformance outside reported checks."]},identity:{establishes:"Two observations refer to the same compiler-owned or source-owned program entity.",nonClaims:["Shared identity does not establish execution or value transfer."]},ownership:{establishes:"A source construct, symbol, runtime observation, or state resource is contained or owned by another program entity.",nonClaims:["Structural ownership does not establish lifetime, singleton scope, or runtime execution unless qualified."]},dependencies:{establishes:"A file, module, or symbol statically relies on another indexed entity.",nonClaims:["A dependency edge does not establish that the depended-on code executes."]}};function Qe(t){return M.flatMap(e=>e.relations.filter(r=>r.family===t).map(r=>({...r,providerId:e.id,providerLabel:e.label})))}function Ue(t){return[...new Set(M.filter(e=>e.relations.some(r=>r.family===t)).map(e=>e.label))]}var Tr=me.map(t=>({family:t,...Be[t],providers:Ue(t),relations:Qe(t)}));function Ve(t){return{family:t,...Be[t],providers:Ue(t),relations:Qe(t)}}var Ar=["search","outline","entrypoints","evidence","inspect","code"];function _r(){return qe.map(t=>{let e=Ve(t.family);return{...t,establishes:e.establishes,evidenceStrengths:Ye(e.relations.flatMap(r=>r.evidenceStrengths)),supportCeilings:Ye(e.relations.map(r=>r.supportCeiling)),nonClaim:e.nonClaims.join(" ")}})}function Ye(t){return[...new Set(t)]}export{Re as a,lr as b,dr as c,S as d,mr as e,yr as f,Rr as g,vr as h,br as i,Sr as j,Cr as k,wr as l,xr as m,Tr as n,Ar as o,_r as p};
3
- //# sourceMappingURL=chunk-OFGOOL6U.js.map
3
+ //# sourceMappingURL=chunk-ZMA5HWXY.js.map
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import{c as K}from"./chunk-2EDX3JT5.js";import{c as Q}from"./chunk-B3UYV66Z.js";import{a as J}from"./chunk-TJBOJUVN.js";import{a as h}from"./chunk-Q3ZCQY2Y.js";import"./chunk-362QOSFD.js";import{c as F,d as H,e as q,f as W,g as B,h as G}from"./chunk-JLZLLLW5.js";import{j as _,l as V,n as U}from"./chunk-AQI4N64O.js";import{p as L,q as z}from"./chunk-5IC2WZAL.js";import"./chunk-C7QWUBR2.js";import"./chunk-B2OB55RR.js";import{a as v,b as I}from"./chunk-XZEE23VG.js";import{$ as p,N as A,O as R,_ as j,ba as $,ea as k,ka as T}from"./chunk-7UCDGXRW.js";import{e as M}from"./chunk-FTTV7IRX.js";import"./chunk-D62CTZX6.js";import{aa as P,ba as O,ca as N,da as S,ea as D,l as s}from"./chunk-5T44HG5Y.js";import{d as E,r as x}from"./chunk-DUKHVPU5.js";import{Command as Pe,Help as Oe}from"commander";import{Option as se}from"commander";function y(e){return e.evidence?e.evidence:ae.has(e.id)?"mixed":e.heuristic?"heuristic":"graph-fact"}var ae=new Set(["health","context","co-change"]);function X(e){if(e.claims){if(e.claims.origin==="mixed"&&!e.claims.families?.length)throw new Error(`Mixed command ${e.id} must declare at least one claim family.`);return e.claims}let t=y(e);if(t==="mixed")throw new Error(`Mixed command ${e.id} must declare claim families.`);let n=e.agent?H(e.agent.operation):[];return n.length>0&&n.every(o=>o==="repository-observation"||o==="repository-preview")?{origin:t==="heuristic"?"heuristic":"compiler-graph",observedSources:["index-generation"],producerValidation:{status:"not-evaluated"}}:{origin:"unknown",observedSources:["process"],producerValidation:{status:"not-evaluated"}}}var Y;function Z(){return Y||{argv:process.argv.slice(2),execPath:process.execPath,...process.argv[1]!==void 0?{scriptPath:process.argv[1]}:{},cwd:process.cwd()}}function ee(e,t){return W(new Map(t.map(n=>[n.id,y(n)]))),G(new Map(t.map(n=>[n.id,X(n)]))),B(new Map(t.flatMap(n=>n.agent?[[n.id,{...n.agent,resultUnits:me(n)}]]:[]))),t.map(n=>{let i=n.hidden?e.command(n.command,{hidden:!0}):e.command(n.command);i.description(n.description),n.helpAfter&&i.addHelpText("after",`
2
+ import{c as K}from"./chunk-KUKWHP4R.js";import{c as Q}from"./chunk-B3UYV66Z.js";import{a as J}from"./chunk-KUKKLWJD.js";import{a as h}from"./chunk-R4OJGTMP.js";import"./chunk-362QOSFD.js";import{c as F,d as H,e as q,f as W,g as B,h as G}from"./chunk-CLPCFGRT.js";import{j as _,l as V,n as U}from"./chunk-6FXXYYQM.js";import{p as L,q as z}from"./chunk-BIADXGC3.js";import"./chunk-OWJWOEDU.js";import"./chunk-B2OB55RR.js";import{a as v,b as I}from"./chunk-XZEE23VG.js";import{$ as p,N as A,O as R,_ as j,ba as $,ea as k,ka as T}from"./chunk-7UCDGXRW.js";import{e as M}from"./chunk-EOKVZXNF.js";import"./chunk-D62CTZX6.js";import{aa as P,ba as O,ca as N,da as S,ea as D,l as s}from"./chunk-5T44HG5Y.js";import{d as E,r as x}from"./chunk-DUKHVPU5.js";import{Command as Pe,Help as Oe}from"commander";import{Option as se}from"commander";function y(e){return e.evidence?e.evidence:ae.has(e.id)?"mixed":e.heuristic?"heuristic":"graph-fact"}var ae=new Set(["health","context","co-change"]);function X(e){if(e.claims){if(e.claims.origin==="mixed"&&!e.claims.families?.length)throw new Error(`Mixed command ${e.id} must declare at least one claim family.`);return e.claims}let t=y(e);if(t==="mixed")throw new Error(`Mixed command ${e.id} must declare claim families.`);let n=e.agent?H(e.agent.operation):[];return n.length>0&&n.every(o=>o==="repository-observation"||o==="repository-preview")?{origin:t==="heuristic"?"heuristic":"compiler-graph",observedSources:["index-generation"],producerValidation:{status:"not-evaluated"}}:{origin:"unknown",observedSources:["process"],producerValidation:{status:"not-evaluated"}}}var Y;function Z(){return Y||{argv:process.argv.slice(2),execPath:process.execPath,...process.argv[1]!==void 0?{scriptPath:process.argv[1]}:{},cwd:process.cwd()}}function ee(e,t){return W(new Map(t.map(n=>[n.id,y(n)]))),G(new Map(t.map(n=>[n.id,X(n)]))),B(new Map(t.flatMap(n=>n.agent?[[n.id,{...n.agent,resultUnits:me(n)}]]:[]))),t.map(n=>{let i=n.hidden?e.command(n.command,{hidden:!0}):e.command(n.command);i.description(n.description),n.helpAfter&&i.addHelpText("after",`
3
3
  ${n.helpAfter.trim()}
4
4
  `);for(let o of n.arguments??[])i.argument(o.name);for(let o of n.options??[])if(o.hidden){let r=new se(o.flags,o.description).hideHelp();o.parser&&r.argParser(o.parser),Object.hasOwn(o,"defaultValue")&&r.default(o.defaultValue),i.addOption(r)}else o.parser&&Object.hasOwn(o,"defaultValue")?i.option(o.flags,o.description,o.parser,o.defaultValue):o.parser?i.option(o.flags,o.description,o.parser):Object.hasOwn(o,"defaultValue")?i.option(o.flags,o.description,o.defaultValue):i.option(o.flags,o.description);return i.action(async(...o)=>{try{let r=i.optsWithGlobals();ce(r);let a=Z(),d=()=>n.id===_?n.handler(...o):V({command:n.id,producerVersion:s,invocationPrefix:a.scriptPath?[a.execPath,a.scriptPath]:["codebaseiq"],argv:[...a.argv],cwd:a.cwd,json:r.json===!0,sourceSession:r.session!==!1,reemitSource:r.reemit===!0,...typeof r.outputPageSize=="number"?{pageSize:r.outputPageSize}:{},...typeof r.outputCursor=="string"?{cursor:r.outputCursor}:{}},()=>n.handler(...o)),c=n.agent?F(n.agent.operation,{args:o.slice(0,-1),options:r}):void 0;await(c?q(c,d):d())}catch(r){de(r)}finally{p(void 0),R()}}),{descriptor:n,command:i}})}function ce(e){if(e.resultOnly===!0&&e.json!==!0)throw new Error("--result-only requires --json.");if(e.compact===!0&&e.json!==!0)throw new Error("--compact requires --json.")}function me(e){let t=e.agent?.resultUnits;if(t?.kind==="field"&&t.field.trim()==="")throw new Error(`Command ${e.id} declares an empty result-unit field.`);return t||(e.renderShape==="list"||e.renderShape==="table"||e.renderShape==="grouped-by-file"?{kind:"rows"}:{kind:"report"})}function de(e){let t=e instanceof Error?e.message:String(e);console.error(`error: ${I(t)}`),process.exitCode=1}import{existsSync as le,mkdirSync as pe,writeFileSync as ue}from"fs";import{homedir as fe}from"os";import{join as g}from"path";var he=1440*60*1e3,ne="update-check.json",ge="https://registry.npmjs.org/codebaseiq/latest";async function oe(e={}){let t=e.env??process.env;if(t.CODEBASEIQ_UPDATE_CHECK==="0"||t.NO_UPDATE_NOTIFIER)return;let n=e.cacheDir??ye(t),i=e.now??Date.now(),o=e.currentVersion??s,r=be(n),a=r&&i-r.checkedAt<he?r.latestVersion:await we(n,e.fetchLatestVersion??xe,i);if(!a||!ve(a,o))return;(e.writeNotice??(c=>console.error(c)))(Ce(o,a))}function Ce(e,t){return[`codebaseiq update available: ${e} -> ${t}.`,"Agent: tell your human to update with: npm install -g codebaseiq@latest",""].join(`
5
5
  `)}function ve(e,t){let n=te(e),i=te(t);if(!n||!i)return e!==t;for(let o=0;o<n.length;o++){let r=n[o]-i[o];if(r>0)return!0;if(r<0)return!1}return!1}function ye(e){let t=e.XDG_CACHE_HOME||g(fe(),".cache");return g(t,"codebaseiq")}function be(e){let t=g(e,ne);if(!le(t))return null;try{let n=JSON.parse(x(t,"update notice cache"));return typeof n.checkedAt=="number"&&(typeof n.latestVersion=="string"||n.latestVersion===null)?{checkedAt:n.checkedAt,latestVersion:n.latestVersion}:null}catch{return null}}async function we(e,t,n){let i;try{i=await t()}catch{i=null}return Ee(e,{checkedAt:n,latestVersion:i}),i}function Ee(e,t){try{pe(e,{recursive:!0}),ue(g(e,ne),`${JSON.stringify(t,null,2)}
6
6
  `)}catch{}}async function xe(){let e=await fetch(ge,{signal:AbortSignal.timeout(1e3)});if(!e.ok)return null;let t=await e.json();return typeof t.version=="string"?t.version:null}function te(e){let t=/^v?(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(e);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}async function ct(e={}){let t=new Pe;e.resident&&t.exitOverride(),e.terminalOutput&&t.configureOutput({writeOut:o=>process.stdout.write(v(o)),writeErr:o=>process.stderr.write(v(o))}),t.name("codebaseiq").description("Language-agnostic code intelligence CLI powered by SCIP indexes").version(s).option("--output-page-size <characters>","Return bounded output pages with an exact continuation command",U).option("--output-cursor <cursor>","Continue a bounded output page").option("--no-session","Disable the explicit exploration evidence ledger").option("--reemit","Recovery only: render source and graph evidence again instead of citing session receipts").option("--help-all","Display every command, including compatibility and deprecated controls");let n=await K(e.invocationCommand);ee(t,n);let i=new Oe;return t.configureHelp({formatHelp:(o,r)=>o===t?Q(t,n):i.formatHelp(o,r)}),t.hook("preAction",async(o,r)=>{let a=r.name();if(e.resident){await e.resident.preAction(a);return}let d=k(a),c=L(a);if(!d&&!c){ie(),await re(a);return}let m=j(),u=E(m);A(u);let C=$(m,u);p(C),ie(),await re(a);let{config:b,paths:w}=C;if(d){let l=await J({commandName:a,projectRoot:m,config:b,paths:w,dbPathSource:C.dbPathSource,gitContext:u});process.env.CODEBASEIQ_DEBUG&&console.error(`evidence-freshness: ${l.source}`),l.service.kind==="failed"&&console.error(`warning: codebaseiq watch service did not start: ${l.service.message}`),(l.service.kind==="failed"||l.service.kind==="skipped")&&h(m,s);return}if(!c){h(m,s);return}let f=z({commandName:a,projectRoot:m,cacheDir:w.cacheDir,cliVersion:s,config:b,gitContext:u});f.kind==="failed"&&console.error(`warning: codebaseiq watch service did not start: ${f.message}`),(f.kind==="failed"||f.kind==="skipped")&&h(m,s)}),t.hook("postAction",()=>p(void 0)),{program:t,descriptors:n}}async function re(e){e.startsWith("__")||await oe({commandName:e})}function ie(){if(N(),!P()||S())return;let e=null;try{e=T(t=>M(t))}catch{}D({command:O()??`codebaseiq ${process.argv.slice(2).join(" ")}`,toolVersion:s,projectFingerprint:e})}export{ct as createCliProgram};
7
- //# sourceMappingURL=cli-program-UO7PZD6V.js.map
7
+ //# sourceMappingURL=cli-program-SCHOHOQE.js.map
package/dist/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{b as n}from"./chunk-JFIA2JI3.js";import{d as s}from"./chunk-XZEE23VG.js";import"./chunk-D62CTZX6.js";import"./chunk-DUKHVPU5.js";import{realpathSync as p}from"fs";import{fileURLToPath as y}from"url";import{constants as a,setPriority as u}from"os";var m="CODEBASEIQ_PROCESS_PRIORITY";function P(r=process.env){let o=r[m]?.trim().toLowerCase();return o==="low"||o==="idle"?o:null}function c(r=process.env,o=u){let e=P(r);if(e===null)return null;let t=e==="idle"?a.priority.PRIORITY_LOW:a.priority.PRIORITY_BELOW_NORMAL;try{o(t)}catch{}return e}f()&&(c(),s(),await d());async function d(){let r=process.argv.includes("--help-all");if(!r){let i=await n(process.argv.slice(2));if(i.served)return;process.env.CODEBASEIQ_DEBUG&&console.error(`query-lane: ${i.reason}`)}let{normalizeLegacyEvidenceInvocation:o}=await import("./invocation-command-descriptors-U76PN7IY.js");o(process.argv);let{createCliProgram:e}=await import("./cli-program-UO7PZD6V.js"),{program:t,descriptors:l}=await e({...process.argv[2]!==void 0?{invocationCommand:process.argv[2]}:{},terminalOutput:!0});if(r){let{renderRootCommandHelp:i}=await import("./command-panels-SZONPMLJ.js");process.stdout.write(i(t,l,{includeCompatibility:!0}));return}await t.parseAsync()}function f(){if(!process.argv[1])return!1;let r=y(import.meta.url);try{return p(r)===p(process.argv[1])}catch{return r===process.argv[1]}}
2
+ import{b as n}from"./chunk-KWRQVLPX.js";import{d as s}from"./chunk-XZEE23VG.js";import"./chunk-D62CTZX6.js";import"./chunk-DUKHVPU5.js";import{realpathSync as p}from"fs";import{fileURLToPath as y}from"url";import{constants as a,setPriority as u}from"os";var m="CODEBASEIQ_PROCESS_PRIORITY";function P(r=process.env){let o=r[m]?.trim().toLowerCase();return o==="low"||o==="idle"?o:null}function c(r=process.env,o=u){let e=P(r);if(e===null)return null;let t=e==="idle"?a.priority.PRIORITY_LOW:a.priority.PRIORITY_BELOW_NORMAL;try{o(t)}catch{}return e}f()&&(c(),s(),await d());async function d(){let r=process.argv.includes("--help-all");if(!r){let i=await n(process.argv.slice(2));if(i.served)return;process.env.CODEBASEIQ_DEBUG&&console.error(`query-lane: ${i.reason}`)}let{normalizeLegacyEvidenceInvocation:o}=await import("./invocation-command-descriptors-HNMKDEF6.js");o(process.argv);let{createCliProgram:e}=await import("./cli-program-SCHOHOQE.js"),{program:t,descriptors:l}=await e({...process.argv[2]!==void 0?{invocationCommand:process.argv[2]}:{},terminalOutput:!0});if(r){let{renderRootCommandHelp:i}=await import("./command-panels-SZONPMLJ.js");process.stdout.write(i(t,l,{includeCompatibility:!0}));return}await t.parseAsync()}function f(){if(!process.argv[1])return!1;let r=y(import.meta.url);try{return p(r)===p(process.argv[1])}catch{return r===process.argv[1]}}
3
3
  //# sourceMappingURL=cli.js.map
@@ -1,4 +1,4 @@
1
- import{a as Me,b as Fe}from"./chunk-RJVAPMHF.js";import"./chunk-ILMHV3KM.js";import"./chunk-XN3EKMLI.js";import{a as ke}from"./chunk-DVWO7RBC.js";import{l as ve}from"./chunk-GWYZVVKY.js";import{D as ee,T as xe,a as Re,n as Ee,o as Z}from"./chunk-LONKINMJ.js";import"./chunk-ZZ3MWF33.js";import{a as X,o as ge}from"./chunk-6WAPPQ5F.js";import"./chunk-YUKYB54I.js";import"./chunk-DDN2F6GB.js";import"./chunk-P5XHIJHI.js";import"./chunk-EQNMD62X.js";import"./chunk-2PRONPAS.js";import"./chunk-P4NVCOM7.js";import"./chunk-CIYA2KZN.js";import{H as me}from"./chunk-C6WKPKCF.js";import"./chunk-XQAVQVIL.js";import{c as q,d as C,e as U}from"./chunk-DRENNWRG.js";import"./chunk-SV2LEFVM.js";import{N as ye,a as I,b as be,c as he,da as we,ga as Q,ma as Se}from"./chunk-MEUHIDI3.js";import"./chunk-5FWR5HLG.js";import{d as ae,e as ce,n as fe}from"./chunk-T75DS2E6.js";import{e as O,g as pe}from"./chunk-YT4DVWUV.js";import"./chunk-RCIGX23V.js";import{j as ue,r as de}from"./chunk-D7DOB27N.js";import"./chunk-R2NOK63J.js";import"./chunk-6O3KXIDL.js";import{G as Y,T as le,Y as z,a as oe,f as se,h as ie}from"./chunk-UQYQBLJX.js";import{rmSync as En}from"fs";import{createConnection as xn}from"net";import{basename as Mn,join as Fn,resolve as dt}from"path";import{spawn as wt}from"child_process";var St=/^https?:\/\//iu,vt=2e3;function Le(e,t={}){let n=t.platform??process.platform,r=t.env??process.env;if(!St.test(e))return Promise.resolve({launched:!1});if(Et(r.CI))return Promise.resolve({launched:!1});if(n!=="win32"&&n!=="darwin"&&!r.DISPLAY&&!r.WAYLAND_DISPLAY)return Promise.resolve({launched:!1});let{command:s,args:o}=Rt(n,e);return new Promise(i=>{let a;try{a=(t.spawn??wt)(s,o,{detached:!0,stdio:"ignore",windowsHide:!0})}catch{i({launched:!1});return}let d=m=>{clearTimeout(p),i({launched:m})},p=setTimeout(()=>d(!0),vt);a.once("spawn",()=>d(!0)),a.on("error",()=>d(!1)),a.unref()})}function Rt(e,t){return e==="win32"?{command:"rundll32.exe",args:["url.dll,FileProtocolHandler",t]}:e==="darwin"?{command:"open",args:[t]}:{command:"xdg-open",args:[t]}}function Et(e){return e!==void 0&&e!==""&&e!=="0"&&e.toLowerCase()!=="false"}var xt=5;function j(e){let t=e.trim().replace(/\\/g,"/");for(;t.startsWith("./");)t=t.slice(2);return t=t.replace(/^\/+/,"").replace(/\/+$/,""),t==="."?"":t}function Mt(e,t,n,r){let s=j(n),o=s?`${s}/`:"",i=[...new Set(e)].filter(l=>l.startsWith(o)).sort(F);if(i.length===0)return null;let a=new Set(i),d=new Map;for(let l of i){let f=l.slice(o.length),w=f.indexOf("/"),c=w<0?l:`${o}${f.slice(0,w)}`,u=d.get(c)??{kind:w<0?"file":"dir",files:[]};u.files.push(l),d.set(c,u)}let p=new Map,m=[];for(let[l,f]of d){let w=f.kind==="dir"?Ft(f.files):l;for(let c of f.files)p.set(c,w);m.push({id:w,kind:f.kind,name:f.kind==="dir"?w.slice(o.length):l.slice(o.length),path:w,files:f.files.length,internalEdges:0,cycle:null})}m.sort((l,f)=>(l.kind===f.kind?0:l.kind==="dir"?-1:1)||F(l.name,f.name));let b=new Map(m.map(l=>[l.id,l])),M=s?s.split("/"):[],y=new Map,R=new Map,x=0,E=(l,f,w)=>{x+=1;let c=`${l}\0${f}`,u=y.get(c)??{from:l,to:f,count:0,cycle:!1,samples:[]};u.count+=1,u.samples.length<xt&&u.samples.push(w),y.set(c,u)},P=l=>{let f=kt(M,l);return R.has(f)||R.set(f,{id:f,kind:"external",path:f}),f};for(let l of[...t.keys()].sort(F)){let f=a.has(l);for(let w of[...t.get(l)].sort(F)){let c=a.has(w);if(!f&&!c||!f&&l.startsWith(o)||!c&&w.startsWith(o))continue;let u={from:l,to:w};if(f&&c){let g=p.get(l),h=p.get(w);g===h?(x+=1,b.get(g).internalEdges+=1):E(g,h,u)}else f?E(p.get(l),P(w),u):E(P(l),p.get(w),u)}}let S=Lt(m,y);for(let l of m)l.cycle=S.get(l.id)??null;for(let l of y.values()){let f=S.get(l.from);l.cycle=f!==void 0&&f===S.get(l.to)}return{scope:s,basis:r,breadcrumbs:Dt(M),nodes:m,external:[...R.values()].sort((l,f)=>F(l.path,f.path)),edges:[...y.values()].sort((l,f)=>F(l.from,f.from)||F(l.to,f.to)),totals:{files:i.length,edges:x}}}function De(e,t){return Mt(O(e,{includeIgnored:!1}),Oe(e,t.basis),t.scope,t.basis)}function Pe(e,t){let n=O(e,{includeIgnored:!1}),r=j(t);for(;r;){let s=`${r}/`;if(n.some(i=>i.startsWith(s)))return r;let o=r.lastIndexOf("/");r=o<0?"":r.slice(0,o)}return""}function Ve(e,t,n){let r=j(t);if(!O(e,{includeIgnored:!1}).includes(r))return null;let s=Oe(e,n),o=[];for(let[i,a]of s)a.has(r)&&o.push(i);return{file:r,dependsOn:[...s.get(r)??[]].sort(F),dependedOnBy:o.sort(F)}}function Oe(e,t){return t==="imports"?X(e,void 0,{scipEdges:"imports-only",sourceEdges:"imports-and-reexports"}):X(e)}function Ft(e){let t=e.map(r=>r.split("/").slice(0,-1)),n=[...t[0]];for(let r of t){let s=0;for(;s<n.length&&s<r.length&&n[s]===r[s];)s+=1;n.length=s}return n.join("/")}function kt(e,t){let n=t.split("/"),r=0;for(;r<e.length&&r<n.length&&e[r]===n[r];)r+=1;return n.slice(0,r+1).join("/")}function Lt(e,t){let n=new Map(e.map(o=>[o.id,new Set]));for(let o of t.values())n.has(o.from)&&n.has(o.to)&&n.get(o.from).add(o.to);let r=xe(n).components.filter(o=>o.length>1).map(o=>[...o].sort(F)).sort((o,i)=>F(o[0],i[0])),s=new Map;return r.forEach((o,i)=>{for(let a of o)s.set(a,i+1)}),s}function Dt(e){return[{name:"root",path:""},...e.map((t,n)=>({name:t,path:e.slice(0,n+1).join("/")}))]}function F(e,t){return e<t?-1:e>t?1:0}var Ce=["callers","callees","contracts","data","state","runtime"],Pt={families:["execution","identity","contract","dataflow","state","runtime"],subtypes:["call","result-callback","references","uses-contract-symbol","argument-to-parameter","constant-to-parameter","property-to-parameter","return-to-parameter","return-to-call-result","reads-resource","writes-resource","deletes-resource","enqueues-resource","consumes-resource","runtime-handoff","discriminator-dispatch"],direction:"both",maxDepth:1,maxEdges:2e3},Ne={exact:0,derived:1,mixed:2,candidate:3,unknown:4},N="root",Vt=new Set(["source-construct","runtime-boundary-participant","call-result","argument-expression","static-value"]);function _e(e,t){let n=t.trim();if(!n)return{status:"missing"};let r=ge(e,n),s=r.match;if(!s)return{status:"missing"};let o=new Map,i=(a,d,p)=>{o.has(a)||o.set(a,{symbol:a,name:q(a),file:d,line:p})};i(s.symbol,s.relativePath,s.startLine);for(let a of r.candidates)i(a.symbol,a.relativePath,a.startLine);return o.size===1&&At(n,s)?{status:"matched",symbol:s.symbol}:{status:"ambiguous",candidates:[...o.values()],total:r.total}}function $e(e,t,n={}){let r=ee(e,{symbols:[t]},Pt),s=r.targets[0]?.nodeIds[0],o=s?Bt(r,s):null,i=s&&o?qe(r,s,It(o)):Tt(r);if(!n.statements)return i;let a=ee(e,{symbols:[t]},{view:"complete",maxDepth:1,maxEdges:400});return{...i,statements:{inventory:a.inventory??[],edges:a.edges.map(jt)}}}function qe(e,t,n){let r=new Map(Ce.map(i=>[i,new Map])),s=[];for(let i of e.edges){let a=Te(i.from,t,n),d=Te(i.to,t,n);if(!a||!d)continue;let p,m;if(a===N&&d!==N)p=!1,m=d;else if(d===N&&a!==N)p=!0,m=a;else continue;if(i.family==="identity"){p&&i.subtype==="references"&&s.push({target:m,edge:i});continue}let b=Ot(i,p);b&&je(r.get(b),m,i,!1)}let o=r.get("callers");for(let{target:i,edge:a}of s){let d=o.get(i.key);(!d||d.reference)&&je(o,i,a,!0)}return{lanes:Object.fromEntries(Ce.map(i=>[i,Nt(r.get(i))])),coverage:{status:e.coverage.status,omittedEdges:e.coverage.omittedEdges}}}function Ot(e,t){let{family:n,subtype:r}=e;return n==="execution"&&(r==="call"||r==="result-callback")?t?"callers":"callees":n==="contract"&&r==="uses-contract-symbol"?t?null:"contracts":n==="dataflow"&&(r.endsWith("-to-parameter")||r==="return-to-call-result")?"data":n==="state"?"state":n==="runtime"?"runtime":null}function Te(e,t,n){if(e.id===t)return N;if(e.kind==="symbol"&&e.symbol)return Be(e.symbol,e.label,e);if(e.kind==="structural-region")return{key:`region:${e.id}`,kind:"region",label:e.label};if(e.kind==="program-resource"||e.kind==="runtime-state-resource")return{key:`resource:${e.id}`,kind:"resource",label:e.label,...te(e),...e.kind==="program-resource"&&Ie(e,n)?{local:!0}:{}};if(Ie(e,n))return N;if(e.location&&Vt.has(e.kind))return{key:`location:${e.id}`,kind:"location",label:e.label,...te(e)};let r=Ct(e);return r?Be(r,q(r),e):null}function Be(e,t,n){return{key:`symbol:${e}`,kind:"symbol",label:t,symbol:e,...te(n)}}function te(e){return e.location?{file:e.location.file,line:e.location.line}:{}}function Ie(e,t){return e.location!==null&&e.location.file===t.file&&e.location.line>=t.startLine&&e.location.line<=t.endLine}function Ct(e){if(e.kind!=="parameter")return null;let[t,n]=e.id.split(":");return t==="parameter"&&n?decodeURIComponent(n):null}function je(e,t,n,r){let s=e.get(t.key);if(!s){e.set(t.key,{kind:t.kind,label:t.label,...t.symbol?{symbol:t.symbol}:{},...t.file!==void 0?{file:t.file,line:t.line}:{},subtypes:[n.subtype],count:1,strength:n.evidenceStrength,...t.local?{local:!0}:{},...r?{reference:!0}:{}});return}s.count+=1,s.subtypes.includes(n.subtype)||s.subtypes.push(n.subtype),Ne[n.evidenceStrength]<Ne[s.strength]&&(s.strength=n.evidenceStrength)}function Nt(e){return[...e.values()].map(t=>({...t,subtypes:[...t.subtypes].sort()})).sort((t,n)=>Ae(t.label,n.label)||Ae(t.file??"",n.file??"")||(t.line??0)-(n.line??0))}function Tt(e){return qe({...e,edges:[]},"",{file:"",startLine:0,endLine:-1})}function Bt(e,t){for(let n of e.edges){if(n.from.id===t)return n.from;if(n.to.id===t)return n.to}return null}function It(e){return e.location?{file:e.location.file,startLine:e.location.line,endLine:e.location.endLine??e.location.line}:{file:"",startLine:0,endLine:-1}}function jt(e){return{id:e.id,family:e.family,subtype:e.subtype,from:e.from,to:e.to,strength:e.evidenceStrength,methods:e.evidenceMethods}}function At(e,t){if(e===t.symbol)return!0;let n=e.replace(/\\/g,"/").replace(/\(\)$/u,""),r=C(t.symbol);if(n===q(t.symbol).replace(/\(\)$/u,"")||n===r)return!0;let s=e.match(/^(.+):(\d+)(?:-(\d+))?$/);if(s){let i=pe(s[1]);return t.relativePath===i||t.relativePath.endsWith(`/${i}`)}let o=n.lastIndexOf("/");return o>0&&n.slice(o+1)===r&&t.relativePath.toLowerCase().includes(n.slice(0,o).toLowerCase())}function Ae(e,t){return e<t?-1:e>t?1:0}function Ue(e){let t=e.published??fe,n=e.open(),r=null,s=o=>{try{o.close()}catch{}};return{acquire(){if(!n)throw new Error("The viewer database is closed.");let o=t(e.dbPath);if(o!==null&&o!==n.generation.identity&&o!==r)try{let i=e.open();s(n),n=i,r=o}catch{}return n},generation(){return n?.generation.identity??null},close(){let o=n;n=void 0,o&&s(o)}}}import{posix as Ge,resolve as _t}from"path";var He=400,We=2e3,$t=["callers","callees","contracts","data","state","runtime"],qt=4096,Ut=/:\d+(?:-\d+)?$/u,Gt=/^\s*```[^\n]*\n[\s\S]*?```[^\S\n]*(?:\n|$)/u;function Ye(e,t){return{status:200,body:{projectRoot:t.projectRoot,projectName:t.meta.projectName,cliVersion:t.meta.cliVersion,generation:D(e),watcher:{state:t.meta.watcherState()},builder:{available:t.meta.builder.available,modes:[...I],defaultMode:t.meta.builder.defaultMode}}}}function ze(e,t,n){let r=rt(t.get("basis"));if(r===null)return k(e,'basis must be "references" or "imports".');let s=t.get("path")??"",o=B(s);if(o===null)return L(e,`Path is outside the project: ${T(s)}`,{nearest:""});let i=n.queries.normalizeMapScope(o),a=n.queries.codeMapScope(e,{scope:i,basis:r});return a?{status:200,body:{...a,generation:D(e)}}:L(e,`No indexed files under "${i}".`,{nearest:n.queries.nearestMapScope(e,i)})}function Xe(e,t,n){let r=rt(t.get("basis"));if(r===null)return k(e,'basis must be "references" or "imports".');let s=t.get("path");if(!s)return k(e,"path is required.");let o=B(s);if(o===null||o===""||!n.queries.isIndexedFile(e,o))return L(e,`No indexed file at "${T(s)}".`);let i=n.queries.codeMapFile(e,o,r);return{status:200,body:{file:o,breadcrumbs:Yt(o),editorUri:ne(n.projectRoot,o,1),outline:tt(e,o,n),dependsOn:i?.dependsOn??[],dependedOnBy:i?.dependedOnBy??[],stale:n.queries.fileIsStale(e,o),generation:D(e)}}}function Qe(e,t,n){let r=t.get("symbol"),s=t.get("focus"),o=r||s;if(!o)return k(e,"symbol or focus is required.");if(o.length>qt)return k(e,"The selector is too long.");let i=r||"";if(!r){let S=n.queries.resolveFocus(e,o);if(S.status==="ambiguous")return{status:200,body:{status:"ambiguous",candidates:S.candidates.map(l=>({symbol:l.symbol,name:l.name,file:l.file,line:l.line+1})),total:S.total,generation:D(e)}};if(S.status==="missing")return L(e,`No symbol matches "${T(o)}".`);i=S.symbol}let a=Ut.test(i)?null:n.queries.code(e,i);if(!a||a.symbol!==i||a.symbol===a.relativePath||!n.queries.isIndexedFile(e,a.relativePath))return L(e,`No indexed definition for "${T(i)}".`);let d=a.relativePath,p=nt(tt(e,d,n),i),m=n.queries.fileSymbolFacts(e,d);if(!p&&!m.has(i))return L(e,`No indexed definition for "${T(i)}".`);let b=m.get(i),M=t.get("statements")==="1",y=n.queries.symbolFocusLanes(e,i,M?{statements:!0}:void 0),R=a.startLine+1,x=a.source.split(`
1
+ import{a as Me,b as Fe}from"./chunk-PIFYOWS4.js";import"./chunk-ILMHV3KM.js";import"./chunk-XN3EKMLI.js";import{a as ke}from"./chunk-5YBDBY5L.js";import{l as ve}from"./chunk-V4NGDIEA.js";import{D as ee,T as xe,a as Re,n as Ee,o as Z}from"./chunk-JNXI6NQ7.js";import"./chunk-ZZ3MWF33.js";import{a as X,o as ge}from"./chunk-K4S2VH42.js";import"./chunk-YUKYB54I.js";import"./chunk-JAFDMV5I.js";import"./chunk-P5XHIJHI.js";import"./chunk-EQNMD62X.js";import"./chunk-LSZYMN2A.js";import"./chunk-JYRJYXUV.js";import"./chunk-CIYA2KZN.js";import{H as me}from"./chunk-C6WKPKCF.js";import"./chunk-XQAVQVIL.js";import{c as q,d as C,e as U}from"./chunk-DRENNWRG.js";import"./chunk-SV2LEFVM.js";import{N as ye,a as I,b as be,c as he,da as we,ga as Q,ma as Se}from"./chunk-MEUHIDI3.js";import"./chunk-5FWR5HLG.js";import{d as ae,e as ce,n as fe}from"./chunk-T75DS2E6.js";import{e as O,g as pe}from"./chunk-YT4DVWUV.js";import"./chunk-RCIGX23V.js";import{j as ue,r as de}from"./chunk-D7DOB27N.js";import"./chunk-R2NOK63J.js";import"./chunk-6O3KXIDL.js";import{G as Y,T as le,Y as z,a as oe,f as se,h as ie}from"./chunk-UQYQBLJX.js";import{rmSync as En}from"fs";import{createConnection as xn}from"net";import{basename as Mn,join as Fn,resolve as dt}from"path";import{spawn as wt}from"child_process";var St=/^https?:\/\//iu,vt=2e3;function Le(e,t={}){let n=t.platform??process.platform,r=t.env??process.env;if(!St.test(e))return Promise.resolve({launched:!1});if(Et(r.CI))return Promise.resolve({launched:!1});if(n!=="win32"&&n!=="darwin"&&!r.DISPLAY&&!r.WAYLAND_DISPLAY)return Promise.resolve({launched:!1});let{command:s,args:o}=Rt(n,e);return new Promise(i=>{let a;try{a=(t.spawn??wt)(s,o,{detached:!0,stdio:"ignore",windowsHide:!0})}catch{i({launched:!1});return}let d=m=>{clearTimeout(p),i({launched:m})},p=setTimeout(()=>d(!0),vt);a.once("spawn",()=>d(!0)),a.on("error",()=>d(!1)),a.unref()})}function Rt(e,t){return e==="win32"?{command:"rundll32.exe",args:["url.dll,FileProtocolHandler",t]}:e==="darwin"?{command:"open",args:[t]}:{command:"xdg-open",args:[t]}}function Et(e){return e!==void 0&&e!==""&&e!=="0"&&e.toLowerCase()!=="false"}var xt=5;function j(e){let t=e.trim().replace(/\\/g,"/");for(;t.startsWith("./");)t=t.slice(2);return t=t.replace(/^\/+/,"").replace(/\/+$/,""),t==="."?"":t}function Mt(e,t,n,r){let s=j(n),o=s?`${s}/`:"",i=[...new Set(e)].filter(l=>l.startsWith(o)).sort(F);if(i.length===0)return null;let a=new Set(i),d=new Map;for(let l of i){let f=l.slice(o.length),w=f.indexOf("/"),c=w<0?l:`${o}${f.slice(0,w)}`,u=d.get(c)??{kind:w<0?"file":"dir",files:[]};u.files.push(l),d.set(c,u)}let p=new Map,m=[];for(let[l,f]of d){let w=f.kind==="dir"?Ft(f.files):l;for(let c of f.files)p.set(c,w);m.push({id:w,kind:f.kind,name:f.kind==="dir"?w.slice(o.length):l.slice(o.length),path:w,files:f.files.length,internalEdges:0,cycle:null})}m.sort((l,f)=>(l.kind===f.kind?0:l.kind==="dir"?-1:1)||F(l.name,f.name));let b=new Map(m.map(l=>[l.id,l])),M=s?s.split("/"):[],y=new Map,R=new Map,x=0,E=(l,f,w)=>{x+=1;let c=`${l}\0${f}`,u=y.get(c)??{from:l,to:f,count:0,cycle:!1,samples:[]};u.count+=1,u.samples.length<xt&&u.samples.push(w),y.set(c,u)},P=l=>{let f=kt(M,l);return R.has(f)||R.set(f,{id:f,kind:"external",path:f}),f};for(let l of[...t.keys()].sort(F)){let f=a.has(l);for(let w of[...t.get(l)].sort(F)){let c=a.has(w);if(!f&&!c||!f&&l.startsWith(o)||!c&&w.startsWith(o))continue;let u={from:l,to:w};if(f&&c){let g=p.get(l),h=p.get(w);g===h?(x+=1,b.get(g).internalEdges+=1):E(g,h,u)}else f?E(p.get(l),P(w),u):E(P(l),p.get(w),u)}}let S=Lt(m,y);for(let l of m)l.cycle=S.get(l.id)??null;for(let l of y.values()){let f=S.get(l.from);l.cycle=f!==void 0&&f===S.get(l.to)}return{scope:s,basis:r,breadcrumbs:Dt(M),nodes:m,external:[...R.values()].sort((l,f)=>F(l.path,f.path)),edges:[...y.values()].sort((l,f)=>F(l.from,f.from)||F(l.to,f.to)),totals:{files:i.length,edges:x}}}function De(e,t){return Mt(O(e,{includeIgnored:!1}),Oe(e,t.basis),t.scope,t.basis)}function Pe(e,t){let n=O(e,{includeIgnored:!1}),r=j(t);for(;r;){let s=`${r}/`;if(n.some(i=>i.startsWith(s)))return r;let o=r.lastIndexOf("/");r=o<0?"":r.slice(0,o)}return""}function Ve(e,t,n){let r=j(t);if(!O(e,{includeIgnored:!1}).includes(r))return null;let s=Oe(e,n),o=[];for(let[i,a]of s)a.has(r)&&o.push(i);return{file:r,dependsOn:[...s.get(r)??[]].sort(F),dependedOnBy:o.sort(F)}}function Oe(e,t){return t==="imports"?X(e,void 0,{scipEdges:"imports-only",sourceEdges:"imports-and-reexports"}):X(e)}function Ft(e){let t=e.map(r=>r.split("/").slice(0,-1)),n=[...t[0]];for(let r of t){let s=0;for(;s<n.length&&s<r.length&&n[s]===r[s];)s+=1;n.length=s}return n.join("/")}function kt(e,t){let n=t.split("/"),r=0;for(;r<e.length&&r<n.length&&e[r]===n[r];)r+=1;return n.slice(0,r+1).join("/")}function Lt(e,t){let n=new Map(e.map(o=>[o.id,new Set]));for(let o of t.values())n.has(o.from)&&n.has(o.to)&&n.get(o.from).add(o.to);let r=xe(n).components.filter(o=>o.length>1).map(o=>[...o].sort(F)).sort((o,i)=>F(o[0],i[0])),s=new Map;return r.forEach((o,i)=>{for(let a of o)s.set(a,i+1)}),s}function Dt(e){return[{name:"root",path:""},...e.map((t,n)=>({name:t,path:e.slice(0,n+1).join("/")}))]}function F(e,t){return e<t?-1:e>t?1:0}var Ce=["callers","callees","contracts","data","state","runtime"],Pt={families:["execution","identity","contract","dataflow","state","runtime"],subtypes:["call","result-callback","references","uses-contract-symbol","argument-to-parameter","constant-to-parameter","property-to-parameter","return-to-parameter","return-to-call-result","reads-resource","writes-resource","deletes-resource","enqueues-resource","consumes-resource","runtime-handoff","discriminator-dispatch"],direction:"both",maxDepth:1,maxEdges:2e3},Ne={exact:0,derived:1,mixed:2,candidate:3,unknown:4},N="root",Vt=new Set(["source-construct","runtime-boundary-participant","call-result","argument-expression","static-value"]);function _e(e,t){let n=t.trim();if(!n)return{status:"missing"};let r=ge(e,n),s=r.match;if(!s)return{status:"missing"};let o=new Map,i=(a,d,p)=>{o.has(a)||o.set(a,{symbol:a,name:q(a),file:d,line:p})};i(s.symbol,s.relativePath,s.startLine);for(let a of r.candidates)i(a.symbol,a.relativePath,a.startLine);return o.size===1&&At(n,s)?{status:"matched",symbol:s.symbol}:{status:"ambiguous",candidates:[...o.values()],total:r.total}}function $e(e,t,n={}){let r=ee(e,{symbols:[t]},Pt),s=r.targets[0]?.nodeIds[0],o=s?Bt(r,s):null,i=s&&o?qe(r,s,It(o)):Tt(r);if(!n.statements)return i;let a=ee(e,{symbols:[t]},{view:"complete",maxDepth:1,maxEdges:400});return{...i,statements:{inventory:a.inventory??[],edges:a.edges.map(jt)}}}function qe(e,t,n){let r=new Map(Ce.map(i=>[i,new Map])),s=[];for(let i of e.edges){let a=Te(i.from,t,n),d=Te(i.to,t,n);if(!a||!d)continue;let p,m;if(a===N&&d!==N)p=!1,m=d;else if(d===N&&a!==N)p=!0,m=a;else continue;if(i.family==="identity"){p&&i.subtype==="references"&&s.push({target:m,edge:i});continue}let b=Ot(i,p);b&&je(r.get(b),m,i,!1)}let o=r.get("callers");for(let{target:i,edge:a}of s){let d=o.get(i.key);(!d||d.reference)&&je(o,i,a,!0)}return{lanes:Object.fromEntries(Ce.map(i=>[i,Nt(r.get(i))])),coverage:{status:e.coverage.status,omittedEdges:e.coverage.omittedEdges}}}function Ot(e,t){let{family:n,subtype:r}=e;return n==="execution"&&(r==="call"||r==="result-callback")?t?"callers":"callees":n==="contract"&&r==="uses-contract-symbol"?t?null:"contracts":n==="dataflow"&&(r.endsWith("-to-parameter")||r==="return-to-call-result")?"data":n==="state"?"state":n==="runtime"?"runtime":null}function Te(e,t,n){if(e.id===t)return N;if(e.kind==="symbol"&&e.symbol)return Be(e.symbol,e.label,e);if(e.kind==="structural-region")return{key:`region:${e.id}`,kind:"region",label:e.label};if(e.kind==="program-resource"||e.kind==="runtime-state-resource")return{key:`resource:${e.id}`,kind:"resource",label:e.label,...te(e),...e.kind==="program-resource"&&Ie(e,n)?{local:!0}:{}};if(Ie(e,n))return N;if(e.location&&Vt.has(e.kind))return{key:`location:${e.id}`,kind:"location",label:e.label,...te(e)};let r=Ct(e);return r?Be(r,q(r),e):null}function Be(e,t,n){return{key:`symbol:${e}`,kind:"symbol",label:t,symbol:e,...te(n)}}function te(e){return e.location?{file:e.location.file,line:e.location.line}:{}}function Ie(e,t){return e.location!==null&&e.location.file===t.file&&e.location.line>=t.startLine&&e.location.line<=t.endLine}function Ct(e){if(e.kind!=="parameter")return null;let[t,n]=e.id.split(":");return t==="parameter"&&n?decodeURIComponent(n):null}function je(e,t,n,r){let s=e.get(t.key);if(!s){e.set(t.key,{kind:t.kind,label:t.label,...t.symbol?{symbol:t.symbol}:{},...t.file!==void 0?{file:t.file,line:t.line}:{},subtypes:[n.subtype],count:1,strength:n.evidenceStrength,...t.local?{local:!0}:{},...r?{reference:!0}:{}});return}s.count+=1,s.subtypes.includes(n.subtype)||s.subtypes.push(n.subtype),Ne[n.evidenceStrength]<Ne[s.strength]&&(s.strength=n.evidenceStrength)}function Nt(e){return[...e.values()].map(t=>({...t,subtypes:[...t.subtypes].sort()})).sort((t,n)=>Ae(t.label,n.label)||Ae(t.file??"",n.file??"")||(t.line??0)-(n.line??0))}function Tt(e){return qe({...e,edges:[]},"",{file:"",startLine:0,endLine:-1})}function Bt(e,t){for(let n of e.edges){if(n.from.id===t)return n.from;if(n.to.id===t)return n.to}return null}function It(e){return e.location?{file:e.location.file,startLine:e.location.line,endLine:e.location.endLine??e.location.line}:{file:"",startLine:0,endLine:-1}}function jt(e){return{id:e.id,family:e.family,subtype:e.subtype,from:e.from,to:e.to,strength:e.evidenceStrength,methods:e.evidenceMethods}}function At(e,t){if(e===t.symbol)return!0;let n=e.replace(/\\/g,"/").replace(/\(\)$/u,""),r=C(t.symbol);if(n===q(t.symbol).replace(/\(\)$/u,"")||n===r)return!0;let s=e.match(/^(.+):(\d+)(?:-(\d+))?$/);if(s){let i=pe(s[1]);return t.relativePath===i||t.relativePath.endsWith(`/${i}`)}let o=n.lastIndexOf("/");return o>0&&n.slice(o+1)===r&&t.relativePath.toLowerCase().includes(n.slice(0,o).toLowerCase())}function Ae(e,t){return e<t?-1:e>t?1:0}function Ue(e){let t=e.published??fe,n=e.open(),r=null,s=o=>{try{o.close()}catch{}};return{acquire(){if(!n)throw new Error("The viewer database is closed.");let o=t(e.dbPath);if(o!==null&&o!==n.generation.identity&&o!==r)try{let i=e.open();s(n),n=i,r=o}catch{}return n},generation(){return n?.generation.identity??null},close(){let o=n;n=void 0,o&&s(o)}}}import{posix as Ge,resolve as _t}from"path";var He=400,We=2e3,$t=["callers","callees","contracts","data","state","runtime"],qt=4096,Ut=/:\d+(?:-\d+)?$/u,Gt=/^\s*```[^\n]*\n[\s\S]*?```[^\S\n]*(?:\n|$)/u;function Ye(e,t){return{status:200,body:{projectRoot:t.projectRoot,projectName:t.meta.projectName,cliVersion:t.meta.cliVersion,generation:D(e),watcher:{state:t.meta.watcherState()},builder:{available:t.meta.builder.available,modes:[...I],defaultMode:t.meta.builder.defaultMode}}}}function ze(e,t,n){let r=rt(t.get("basis"));if(r===null)return k(e,'basis must be "references" or "imports".');let s=t.get("path")??"",o=B(s);if(o===null)return L(e,`Path is outside the project: ${T(s)}`,{nearest:""});let i=n.queries.normalizeMapScope(o),a=n.queries.codeMapScope(e,{scope:i,basis:r});return a?{status:200,body:{...a,generation:D(e)}}:L(e,`No indexed files under "${i}".`,{nearest:n.queries.nearestMapScope(e,i)})}function Xe(e,t,n){let r=rt(t.get("basis"));if(r===null)return k(e,'basis must be "references" or "imports".');let s=t.get("path");if(!s)return k(e,"path is required.");let o=B(s);if(o===null||o===""||!n.queries.isIndexedFile(e,o))return L(e,`No indexed file at "${T(s)}".`);let i=n.queries.codeMapFile(e,o,r);return{status:200,body:{file:o,breadcrumbs:Yt(o),editorUri:ne(n.projectRoot,o,1),outline:tt(e,o,n),dependsOn:i?.dependsOn??[],dependedOnBy:i?.dependedOnBy??[],stale:n.queries.fileIsStale(e,o),generation:D(e)}}}function Qe(e,t,n){let r=t.get("symbol"),s=t.get("focus"),o=r||s;if(!o)return k(e,"symbol or focus is required.");if(o.length>qt)return k(e,"The selector is too long.");let i=r||"";if(!r){let S=n.queries.resolveFocus(e,o);if(S.status==="ambiguous")return{status:200,body:{status:"ambiguous",candidates:S.candidates.map(l=>({symbol:l.symbol,name:l.name,file:l.file,line:l.line+1})),total:S.total,generation:D(e)}};if(S.status==="missing")return L(e,`No symbol matches "${T(o)}".`);i=S.symbol}let a=Ut.test(i)?null:n.queries.code(e,i);if(!a||a.symbol!==i||a.symbol===a.relativePath||!n.queries.isIndexedFile(e,a.relativePath))return L(e,`No indexed definition for "${T(i)}".`);let d=a.relativePath,p=nt(tt(e,d,n),i),m=n.queries.fileSymbolFacts(e,d);if(!p&&!m.has(i))return L(e,`No indexed definition for "${T(i)}".`);let b=m.get(i),M=t.get("statements")==="1",y=n.queries.symbolFocusLanes(e,i,M?{statements:!0}:void 0),R=a.startLine+1,x=a.source.split(`
2
2
  `),E=x.length>He,P=E?x.slice(0,He):x;return{status:200,body:{status:"matched",definition:{symbol:i,name:C(i),file:d,startLine:R,endLine:a.endLine+1,signature:p?.entry.signature??null,documentation:Wt(b?.documentation),editorUri:ne(n.projectRoot,d,R)},parent:p?.parent?{symbol:p.parent.symbol,name:p.parent.name}:null,members:(p?.entry.children??[]).map(S=>({symbol:S.symbol,name:S.name,line:S.startLine})),lanes:Qt(y.lanes,n.projectRoot),fileImports:n.queries.codeMapFile(e,d,"imports")?.dependsOn??[],coverage:y.coverage,source:{startLine:R,endLine:R+P.length-1,text:P.join(`
3
3
  `),truncated:E,stale:et(a)},...M&&y.statements?{statements:Jt(y.statements)}:{},generation:D(e)}}}function Ze(e,t,n){let r=t.get("file");if(!r)return k(e,"file is required.");let s=t.get("start"),o=t.get("end"),i=s===null?1:Ke(s);if(i===null)return k(e,"start must be a positive integer.");let a=o===null?i+We-1:Ke(o);if(a===null||a<i)return k(e,"end must be an integer at or after start.");let d=B(r);if(d===null||d===""||!n.queries.isIndexedFile(e,d))return L(e,`No indexed file at "${T(r)}".`);let p=Math.min(a,i+We-1),m=n.queries.code(e,`${d}:${i}-${p}`);return m?{status:200,body:{file:d,startLine:m.startLine+1,endLine:m.endLine+1,text:m.source,stale:et(m),generation:D(e)}}:L(e,`Lines ${i}-${p} are outside "${d}".`)}function B(e){if([...e].some(r=>r.charCodeAt(0)<32))return null;let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:/u.test(t))return null;let n=t.split("/").filter(r=>r!==""&&r!==".");return n.includes("..")?null:n.join("/")}function ne(e,t,n){return Ht(_t(e,t),n)}function Ht(e,t){let r=e.replaceAll("\\","/").replace(/[%#? ]/gu,s=>encodeURIComponent(s));return`vscode://file${r.startsWith("/")?"":"/"}${r}:${t}`}function Wt(e){if(!e)return null;let t=e.replace(Gt,"").trim();return t===""?null:t}function et(e){return e.freshness?.semantic.state==="stale"}function Jt(e){return{...e,edges:e.edges.map(Kt)}}function Kt(e){return{...e,from:Je(e.from),to:Je(e.to)}}function Je(e){let{location:t}=e;return t?{...e,location:{...t,line:t.line+1,...t.endLine!==void 0?{endLine:t.endLine+1}:{}}}:e}function Yt(e){let t=[{name:"root",path:""}],n="";for(let r of e.split("/"))n=n===""?r:`${n}/${r}`,t.push({name:r,path:n});return t}function tt(e,t,n){let r=n.queries.fileSymbolFacts(e,t),s=Xt(t),o=n.queries.outline(e,t).flatMap(a=>U(a.symbol)==="namespace"&&s.has(C(a.symbol))?a.children:[a]),i=(a,d)=>({symbol:a.symbol,name:C(a.symbol),kind:r.get(a.symbol)?.kind??zt(a.symbol,d),startLine:a.startLine+1,endLine:a.endLine+1,signature:a.signature,children:a.children.map(p=>i(p,a.symbol))});return o.map(a=>i(a))}function zt(e,t){let n=U(e);return n==="method"?t!==void 0&&U(t)==="type"?"method":"function":n==="term"?"variable":n??"unknown"}function Xt(e){let t=Ge.basename(e);return new Set([t,t.slice(0,Math.max(0,t.length-Ge.extname(t).length))])}function nt(e,t,n=null){for(let r of e){if(r.symbol===t)return{entry:r,parent:n};let s=nt(r.children,t,r);if(s)return s}return null}function Qt(e,t){let n={};for(let r of $t)n[r]=(e[r]??[]).map(s=>{let{line:o,...i}=s,a={...i};return o!==void 0&&(a.line=o+1),s.file!==void 0&&(a.editorUri=ne(t,s.file,(o??0)+1)),a});return n}function rt(e){return e===null||e===""?"references":e==="references"||e==="imports"?e:null}function Ke(e){if(!/^\d{1,9}$/u.test(e))return null;let t=Number(e);return t>=1?t:null}function D(e){return e.generation.identity}function k(e,t){return{status:400,body:{error:t,generation:D(e)}}}function L(e,t,n={}){return{status:404,body:{error:t,...n,generation:D(e)}}}function T(e){return e.length>200?`${e.slice(0,200)}...`:e}import{createHash as ct,randomBytes as Zt,timingSafeEqual as en}from"crypto";import{existsSync as A}from"fs";import{createServer as tn}from"http";import{createRequire as nn}from"module";import{dirname as rn,join as H}from"path";import{fileURLToPath as on}from"url";var _="127.0.0.1",sn=80,an="__CODEBASEIQ_TOKEN__",cn="x-codebaseiq-token",ot=64*1024,un=18e4,st=50,it=["reuse","rework","compose"],ln="cytoscape.esm.min.mjs",dn=["index.html","styles.css","app.js","api.js","map.js","file-panel.js","focus.js","builder.js"],fn={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".js":"text/javascript; charset=utf-8"},pn=["default-src 'self'","script-src 'self'","style-src 'self' 'unsafe-inline'","img-src 'self' data:","connect-src 'self'","frame-ancestors 'none'"].join("; ");function mn(){for(let e of["../ui/view/","../../../ui/view/"]){let t=on(new URL(e,import.meta.url));if(A(H(t,"index.html")))return t}}function gn(){try{let e=nn(import.meta.url).resolve("cytoscape"),t=H(rn(e),ln);return A(t)?t:void 0}catch{return}}function at(e,t){return{body:se(e,{maxBytes:oe,inputKind:"viewer asset"}),contentType:t}}function bn(e,t){let n=e.uiDirectory??mn();if(!n||!A(H(n,"index.html")))throw new Error("The viewer UI files were not found; reinstall codebaseiq or rebuild the package.");let r=new Map;for(let i of dn){let a=H(n,i);if(!A(a))continue;let d=at(a,fn[i.slice(i.lastIndexOf("."))]??"application/octet-stream");r.set(i,i==="index.html"?{...d,body:Buffer.from(d.body.toString("utf8").replaceAll(an,t),"utf8")}:d)}let s=e.cytoscapePath??gn(),o=s&&A(s)?at(s,"text/javascript"):void 0;return{assets:r,...o?{vendor:o}:{}}}async function ut(e){let t=e.token??Zt(24).toString("base64url"),{assets:n,vendor:r}=bn(e,t),s=e.builderTimeoutMs??un,o=ct("sha256").update(t).digest(),i=0,a=!1,d=new Set,p=()=>lt(i),m=()=>yn(i),b=(c,u,g)=>{let h=JSON.stringify({generation:e.database.generation(),...g});c.writeHead(u,{...G(),"Content-Type":"application/json; charset=utf-8","Content-Length":Buffer.byteLength(h)}),c.end(h)},M=(c,u)=>{c.writeHead(200,{...G(),"Content-Type":u.contentType,"Content-Length":u.body.byteLength,...u.contentType.startsWith("text/html")?{"Content-Security-Policy":pn}:{}}),c.end(u.body)},y=(c,u,g,h={})=>{c.writeHead(u,{...G(),"Content-Type":"text/plain; charset=utf-8","Content-Length":Buffer.byteLength(g),...h}),c.end(g)},R=(c,u,g)=>{let h=hn.get(u);if(!h){b(c,404,{error:"Not found."});return}let v=h(e.database.acquire(),g,e.routes);b(c,v.status,v.body)},x=(c,u)=>{if(u==="/"){let v=n.get("index.html");v?M(c,v):y(c,404,"Not found.");return}if(u==="/favicon.ico"){c.writeHead(204,G()),c.end();return}if(u==="/vendor/cytoscape.mjs"&&r){M(c,r);return}let g=u.startsWith("/assets/")?u.slice(8):void 0,h=g===void 0?void 0:n.get(g);h?M(c,h):y(c,404,"Not found.")},E=async(c,u)=>{let g=c.headers.origin;if(g!==void 0&&!m().has(g)){b(u,403,{error:"Origin is not allowed."});return}if(!wn(c.headers["content-type"])){b(u,415,{error:"Content-Type must be application/json."});return}if(!Sn(o,c.headers[cn])){b(u,403,{error:"The viewer token is missing or wrong; reload the page."});return}let h=e.builder;if(!h){b(u,501,{error:"The symbol builder is not available in this viewer."});return}if(a){b(u,409,{error:"A builder query is already running."});return}a=!0;try{let v=await vn(c,ot);if(v===void 0){b(u,400,{error:`The request body must be at most ${ot/1024} KiB.`});return}let V=Rn(v);if(!V.ok){b(u,400,{error:V.error});return}await P(u,h,V.request,V.diagnostics)}finally{a=!1}},P=async(c,u,g,h)=>{let v=new AbortController;d.add(v);let V=()=>{c.writableEnded||v.abort(new Error("The client disconnected."))};c.on("close",V);let W;try{let $=await new Promise(J=>{W=setTimeout(()=>{v.abort(new Error("The builder query timed out.")),J({kind:"timeout"})},s),u(g,v.signal).then(K=>J({kind:"done",response:K}),K=>J({kind:"failed",error:K}))});if(c.destroyed)return;$.kind==="timeout"?b(c,504,{error:`The builder query took longer than ${Math.round(s/1e3)} s.`}):$.kind==="failed"?b(c,502,{error:re($.error)}):b(c,200,{...$.response,...h.length>0?{probeDiagnostics:h}:{}})}finally{W&&clearTimeout(W),c.off("close",V),d.delete(v)}},S=async(c,u)=>{if(!p().has((c.headers.host??"").toLowerCase())){y(u,403,"Forbidden host.");return}let g;try{g=new URL(c.url??"/",`http://${_}`)}catch{y(u,400,"Bad request.");return}let h=c.method??"GET";if(g.pathname==="/api/builder"){h==="POST"?await E(c,u):b(u,405,{error:"Use POST."});return}if(h!=="GET"&&h!=="HEAD"){y(u,405,"Method not allowed.",{Allow:"GET, HEAD"});return}g.pathname.startsWith("/api/")?R(u,g.pathname,g.searchParams):x(u,g.pathname)},l=tn((c,u)=>{S(c,u).catch(g=>{if(u.headersSent){u.destroy();return}b(u,500,{error:re(g)})})});await new Promise((c,u)=>{l.once("error",u),l.listen({host:_,port:e.port??0},()=>{l.off("error",u),c()})}),l.on("error",c=>{process.stderr.write(`codebaseiq view: server error: ${re(c)}
4
4
  `)});let f=l.address();i=typeof f=="object"&&f?f.port:0;let w=`http://${_}:${i}`;return{port:i,origin:w,url:`${w}/`,token:t,close(){for(let c of d)c.abort(new Error("The viewer is shutting down."));return new Promise(c=>{l.close(()=>c()),l.closeAllConnections()})}}}var hn=new Map([["/api/meta",(e,t,n)=>Ye(e,n)],["/api/scope",ze],["/api/file",Xe],["/api/symbol",Qe],["/api/source",Ze]]);function lt(e){let t=new Set([`${_}:${e}`,`localhost:${e}`]);return e===sn&&(t.add(_),t.add("localhost")),t}function yn(e){return new Set([...lt(e)].map(t=>`http://${t}`))}function G(){return{"Cache-Control":"no-store","X-Content-Type-Options":"nosniff","Referrer-Policy":"no-referrer"}}function wn(e){return e!==void 0&&e.split(";")[0].trim().toLowerCase()==="application/json"}function Sn(e,t){return typeof t!="string"||t===""?!1:en(ct("sha256").update(t).digest(),e)}function vn(e,t){return new Promise((n,r)=>{let s=[],o=0,i=!1;e.on("data",a=>{o+=a.byteLength,o>t?(i=!0,s.length=0):i||s.push(a)}),e.on("end",()=>n(i?void 0:Buffer.concat(s).toString("utf8"))),e.on("error",r)})}function Rn(e){let t;try{t=JSON.parse(e)}catch{return{ok:!1,error:"The request body must be valid JSON."}}if(typeof t!="object"||t===null||Array.isArray(t))return{ok:!1,error:"The request body must be a JSON object."};let n=t,r={},s=[];if(n.description!==void 0){if(typeof n.description!="string")return{ok:!1,error:"description must be a string."};n.description.trim()!==""&&(r.description=n.description)}if(n.probes!==void 0){let o=he(n.probes);s=o.diagnostics,(be(o.probes)||o.probes.kinds.length>0)&&(r.probes=o.probes)}if(n.mode!==void 0){if(typeof n.mode!="string"||!I.includes(n.mode))return{ok:!1,error:`mode must be one of ${I.join(", ")}.`};r.mode=n.mode}if(n.bucket!==void 0){if(typeof n.bucket!="string"||!it.includes(n.bucket))return{ok:!1,error:`bucket must be one of ${it.join(", ")}.`};r.bucket=n.bucket}if(n.limit!==void 0){let o=n.limit;if(typeof o!="number"||!Number.isInteger(o)||o<1||o>st)return{ok:!1,error:`limit must be an integer from 1 to ${st}.`};r.limit=o}return r.description===void 0&&r.probes===void 0?{ok:!1,error:"Give a description or at least one probe."}:{ok:!0,request:r,diagnostics:s}}function re(e){return e instanceof Error?e.message:String(e)}var kn="view-server.json",ft="127.0.0.1",Ln=1e3,Dn=5e3,Pn=2e3,gt={isProcessAlive:ue,canConnect(e,t){return new Promise(n=>{let r=xn({host:ft,port:e}),s=o=>{r.destroy(),n(o)};r.setTimeout(t,()=>s(!1)),r.once("connect",()=>s(!0)),r.once("error",()=>s(!1))})},async fetchProjectRoot(e,t){try{let n=await fetch(`http://${ft}:${e}/api/meta`,{signal:AbortSignal.timeout(t)});if(!n.ok)return{kind:"answered",projectRoot:void 0};let r=await n.json();return{kind:"answered",projectRoot:typeof r.projectRoot=="string"?r.projectRoot:void 0}}catch{return{kind:"unanswered"}}}};function pt(e,t){let n=new URL(e);return t.focus!==void 0?n.searchParams.set("focus",t.focus):t.file!==void 0?n.searchParams.set("file",t.file):t.scope!==void 0&&n.searchParams.set("scope",t.scope),n.toString()}async function bt(e,t,n=gt){let r=ht(e);if(!r||!n.isProcessAlive(r.pid)||!await n.canConnect(r.port,Ln))return;let s=await n.fetchProjectRoot(r.port,Dn);if(s.kind==="unanswered")return r;let o=s.projectRoot;if(!(o===void 0||z(dt(o))!==z(dt(t))))return r}async function Vn(e,t,n=gt){let r=await bt(e,t.projectRoot,n);if(r&&r.pid!==t.pid)return process.stderr.write(`warning: a viewer (pid ${r.pid}, ${r.url}) is already recorded for this project, so this one is not.
@@ -8,4 +8,4 @@ import{a as Me,b as Fe}from"./chunk-RJVAPMHF.js";import"./chunk-ILMHV3KM.js";imp
8
8
  `)}function Cn(e,t){return e?.code==="EADDRINUSE"&&t?new Error(`Port ${t} is already in use; choose another with --port.`):e instanceof Error?e:new Error(String(e))}function Nn(e,t){try{let n=ye(e.projectRoot,e.config),r=Fe({settings:n,storeRoot:Me(e.paths.cacheDir),languages:Bn(t.acquire()),openDb:()=>t.acquire(),env:Tn(process.env)});return{run:(s,o)=>r.query(s,{signal:o}),defaultMode:n.mode,close:()=>r.close()}}catch(n){return process.stderr.write(`codebaseiq view: the symbol builder is unavailable: ${yt(n)}
9
9
  `),{defaultMode:"agent",close:()=>{}}}}function Tn(e){return Object.fromEntries(Object.entries(e).filter(([t])=>t!=="CLAUDECODE"&&!t.startsWith("CODEX_")))}function Bn(e){let t=e.generation.metadataRaw;return(t?ce(ae(t))?.indexedLanguages:void 0)??[]}function In(e,t,n){let r;return()=>{let s=Date.now();if(r&&s-r.at<Pn)return r.value;let o;try{let{classification:i}=ve({projectRoot:e,cacheDir:t.paths.cacheDir,cliVersion:Y,...n?{gitContext:n}:{}});o=i.kind==="live"?i.state.watcher.state:i.kind}catch{o="unknown"}return r={at:s,value:o},o}}function jn(){let e=new WeakMap;return{normalizeMapScope:j,codeMapScope:De,nearestMapScope:Pe,codeMapFile:Ve,isIndexedFile(t,n){let r=e.get(t);return r||(r=new Set(O(t,{includeIgnored:!1})),e.set(t,r)),r.has(n)},outline:Ee,fileSymbolFacts(t,n){let r=new Map;for(let s of me(t,n))r.set(s.symbol,{kind:s.kind===null?null:An(s.kind),documentation:s.documentation});return r},resolveFocus:_e,symbolFocusLanes:$e,code:Z,fileIsStale(t,n){return Z(t,`${n}:1-1`)?.freshness?.semantic.state==="stale"}}}function An(e){let t=Re(e).toLowerCase();return t==="unknown"||t==="unspecifiedkind"?null:t}function _n(e){let t=()=>{let s=ht(e.stateFile);s?.pid===e.state.pid&&s.startedAt===e.state.startedAt&&En(e.stateFile,{force:!0})},n=!1,r=()=>{n||(n=!0,e.server.close().finally(()=>{e.builder.close(),e.database.close(),t(),console.log(`
10
10
  Stopped.`),process.exit(0)}))};process.on("SIGINT",r),process.on("SIGTERM",r),process.on("exit",t)}function yt(e){return e instanceof Error?e.message:String(e)}export{kn as VIEW_STATE_FILE,jn as createViewerQueries,bt as findRunningViewer,ht as readViewerState,Vn as recordRunningViewer,jr as runCodeViewer,Tn as viewerBuilderEnvironment,pt as viewerDeepLink};
11
- //# sourceMappingURL=code-viewer-VHLBLIUM.js.map
11
+ //# sourceMappingURL=code-viewer-AMRXV444.js.map
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{a as ke}from"./chunk-TJBOJUVN.js";import{a as Me,b as Fe}from"./chunk-5DSL3NT2.js";import{r as xe}from"./chunk-5IC2WZAL.js";import{H as ee,X as Ee,f as ve,v as Re,w as Z}from"./chunk-C7QWUBR2.js";import"./chunk-B2OB55RR.js";import"./chunk-XZEE23VG.js";import{K as ge,_ as be,a as I,b as pe,ba as X,c as me,ha as he}from"./chunk-7UCDGXRW.js";import"./chunk-EN4AHLL3.js";import{Ha as Se,ca as Q,ga as q,ha as C,ia as U,k as O,m as ye,ta as we}from"./chunk-FTTV7IRX.js";import"./chunk-D62CTZX6.js";import{E as ue,F as le,X as de,Z as fe,l as z}from"./chunk-5T44HG5Y.js";import{d as oe,i as Y,j as se,k as ie,p as ae,r as ce}from"./chunk-DUKHVPU5.js";import{rmSync as En}from"fs";import{createConnection as xn}from"net";import{basename as Mn,join as Fn,resolve as dt}from"path";import{spawn as wt}from"child_process";var St=/^https?:\/\//iu,vt=2e3;function Le(e,t={}){let n=t.platform??process.platform,r=t.env??process.env;if(!St.test(e))return Promise.resolve({launched:!1});if(Et(r.CI))return Promise.resolve({launched:!1});if(n!=="win32"&&n!=="darwin"&&!r.DISPLAY&&!r.WAYLAND_DISPLAY)return Promise.resolve({launched:!1});let{command:s,args:o}=Rt(n,e);return new Promise(i=>{let a;try{a=(t.spawn??wt)(s,o,{detached:!0,stdio:"ignore",windowsHide:!0})}catch{i({launched:!1});return}let d=m=>{clearTimeout(p),i({launched:m})},p=setTimeout(()=>d(!0),vt);a.once("spawn",()=>d(!0)),a.on("error",()=>d(!1)),a.unref()})}function Rt(e,t){return e==="win32"?{command:"rundll32.exe",args:["url.dll,FileProtocolHandler",t]}:e==="darwin"?{command:"open",args:[t]}:{command:"xdg-open",args:[t]}}function Et(e){return e!==void 0&&e!==""&&e!=="0"&&e.toLowerCase()!=="false"}var xt=5;function j(e){let t=e.trim().replace(/\\/g,"/");for(;t.startsWith("./");)t=t.slice(2);return t=t.replace(/^\/+/,"").replace(/\/+$/,""),t==="."?"":t}function Mt(e,t,n,r){let s=j(n),o=s?`${s}/`:"",i=[...new Set(e)].filter(l=>l.startsWith(o)).sort(F);if(i.length===0)return null;let a=new Set(i),d=new Map;for(let l of i){let f=l.slice(o.length),w=f.indexOf("/"),c=w<0?l:`${o}${f.slice(0,w)}`,u=d.get(c)??{kind:w<0?"file":"dir",files:[]};u.files.push(l),d.set(c,u)}let p=new Map,m=[];for(let[l,f]of d){let w=f.kind==="dir"?Ft(f.files):l;for(let c of f.files)p.set(c,w);m.push({id:w,kind:f.kind,name:f.kind==="dir"?w.slice(o.length):l.slice(o.length),path:w,files:f.files.length,internalEdges:0,cycle:null})}m.sort((l,f)=>(l.kind===f.kind?0:l.kind==="dir"?-1:1)||F(l.name,f.name));let b=new Map(m.map(l=>[l.id,l])),M=s?s.split("/"):[],y=new Map,R=new Map,x=0,E=(l,f,w)=>{x+=1;let c=`${l}\0${f}`,u=y.get(c)??{from:l,to:f,count:0,cycle:!1,samples:[]};u.count+=1,u.samples.length<xt&&u.samples.push(w),y.set(c,u)},P=l=>{let f=kt(M,l);return R.has(f)||R.set(f,{id:f,kind:"external",path:f}),f};for(let l of[...t.keys()].sort(F)){let f=a.has(l);for(let w of[...t.get(l)].sort(F)){let c=a.has(w);if(!f&&!c||!f&&l.startsWith(o)||!c&&w.startsWith(o))continue;let u={from:l,to:w};if(f&&c){let g=p.get(l),h=p.get(w);g===h?(x+=1,b.get(g).internalEdges+=1):E(g,h,u)}else f?E(p.get(l),P(w),u):E(P(l),p.get(w),u)}}let S=Lt(m,y);for(let l of m)l.cycle=S.get(l.id)??null;for(let l of y.values()){let f=S.get(l.from);l.cycle=f!==void 0&&f===S.get(l.to)}return{scope:s,basis:r,breadcrumbs:Dt(M),nodes:m,external:[...R.values()].sort((l,f)=>F(l.path,f.path)),edges:[...y.values()].sort((l,f)=>F(l.from,f.from)||F(l.to,f.to)),totals:{files:i.length,edges:x}}}function De(e,t){return Mt(O(e,{includeIgnored:!1}),Oe(e,t.basis),t.scope,t.basis)}function Pe(e,t){let n=O(e,{includeIgnored:!1}),r=j(t);for(;r;){let s=`${r}/`;if(n.some(i=>i.startsWith(s)))return r;let o=r.lastIndexOf("/");r=o<0?"":r.slice(0,o)}return""}function Ve(e,t,n){let r=j(t);if(!O(e,{includeIgnored:!1}).includes(r))return null;let s=Oe(e,n),o=[];for(let[i,a]of s)a.has(r)&&o.push(i);return{file:r,dependsOn:[...s.get(r)??[]].sort(F),dependedOnBy:o.sort(F)}}function Oe(e,t){return t==="imports"?Q(e,void 0,{scipEdges:"imports-only",sourceEdges:"imports-and-reexports"}):Q(e)}function Ft(e){let t=e.map(r=>r.split("/").slice(0,-1)),n=[...t[0]];for(let r of t){let s=0;for(;s<n.length&&s<r.length&&n[s]===r[s];)s+=1;n.length=s}return n.join("/")}function kt(e,t){let n=t.split("/"),r=0;for(;r<e.length&&r<n.length&&e[r]===n[r];)r+=1;return n.slice(0,r+1).join("/")}function Lt(e,t){let n=new Map(e.map(o=>[o.id,new Set]));for(let o of t.values())n.has(o.from)&&n.has(o.to)&&n.get(o.from).add(o.to);let r=Ee(n).components.filter(o=>o.length>1).map(o=>[...o].sort(F)).sort((o,i)=>F(o[0],i[0])),s=new Map;return r.forEach((o,i)=>{for(let a of o)s.set(a,i+1)}),s}function Dt(e){return[{name:"root",path:""},...e.map((t,n)=>({name:t,path:e.slice(0,n+1).join("/")}))]}function F(e,t){return e<t?-1:e>t?1:0}var Ce=["callers","callees","contracts","data","state","runtime"],Pt={families:["execution","identity","contract","dataflow","state","runtime"],subtypes:["call","result-callback","references","uses-contract-symbol","argument-to-parameter","constant-to-parameter","property-to-parameter","return-to-parameter","return-to-call-result","reads-resource","writes-resource","deletes-resource","enqueues-resource","consumes-resource","runtime-handoff","discriminator-dispatch"],direction:"both",maxDepth:1,maxEdges:2e3},Ne={exact:0,derived:1,mixed:2,candidate:3,unknown:4},N="root",Vt=new Set(["source-construct","runtime-boundary-participant","call-result","argument-expression","static-value"]);function _e(e,t){let n=t.trim();if(!n)return{status:"missing"};let r=Se(e,n),s=r.match;if(!s)return{status:"missing"};let o=new Map,i=(a,d,p)=>{o.has(a)||o.set(a,{symbol:a,name:q(a),file:d,line:p})};i(s.symbol,s.relativePath,s.startLine);for(let a of r.candidates)i(a.symbol,a.relativePath,a.startLine);return o.size===1&&At(n,s)?{status:"matched",symbol:s.symbol}:{status:"ambiguous",candidates:[...o.values()],total:r.total}}function $e(e,t,n={}){let r=ee(e,{symbols:[t]},Pt),s=r.targets[0]?.nodeIds[0],o=s?Bt(r,s):null,i=s&&o?qe(r,s,It(o)):Tt(r);if(!n.statements)return i;let a=ee(e,{symbols:[t]},{view:"complete",maxDepth:1,maxEdges:400});return{...i,statements:{inventory:a.inventory??[],edges:a.edges.map(jt)}}}function qe(e,t,n){let r=new Map(Ce.map(i=>[i,new Map])),s=[];for(let i of e.edges){let a=Te(i.from,t,n),d=Te(i.to,t,n);if(!a||!d)continue;let p,m;if(a===N&&d!==N)p=!1,m=d;else if(d===N&&a!==N)p=!0,m=a;else continue;if(i.family==="identity"){p&&i.subtype==="references"&&s.push({target:m,edge:i});continue}let b=Ot(i,p);b&&je(r.get(b),m,i,!1)}let o=r.get("callers");for(let{target:i,edge:a}of s){let d=o.get(i.key);(!d||d.reference)&&je(o,i,a,!0)}return{lanes:Object.fromEntries(Ce.map(i=>[i,Nt(r.get(i))])),coverage:{status:e.coverage.status,omittedEdges:e.coverage.omittedEdges}}}function Ot(e,t){let{family:n,subtype:r}=e;return n==="execution"&&(r==="call"||r==="result-callback")?t?"callers":"callees":n==="contract"&&r==="uses-contract-symbol"?t?null:"contracts":n==="dataflow"&&(r.endsWith("-to-parameter")||r==="return-to-call-result")?"data":n==="state"?"state":n==="runtime"?"runtime":null}function Te(e,t,n){if(e.id===t)return N;if(e.kind==="symbol"&&e.symbol)return Be(e.symbol,e.label,e);if(e.kind==="structural-region")return{key:`region:${e.id}`,kind:"region",label:e.label};if(e.kind==="program-resource"||e.kind==="runtime-state-resource")return{key:`resource:${e.id}`,kind:"resource",label:e.label,...te(e),...e.kind==="program-resource"&&Ie(e,n)?{local:!0}:{}};if(Ie(e,n))return N;if(e.location&&Vt.has(e.kind))return{key:`location:${e.id}`,kind:"location",label:e.label,...te(e)};let r=Ct(e);return r?Be(r,q(r),e):null}function Be(e,t,n){return{key:`symbol:${e}`,kind:"symbol",label:t,symbol:e,...te(n)}}function te(e){return e.location?{file:e.location.file,line:e.location.line}:{}}function Ie(e,t){return e.location!==null&&e.location.file===t.file&&e.location.line>=t.startLine&&e.location.line<=t.endLine}function Ct(e){if(e.kind!=="parameter")return null;let[t,n]=e.id.split(":");return t==="parameter"&&n?decodeURIComponent(n):null}function je(e,t,n,r){let s=e.get(t.key);if(!s){e.set(t.key,{kind:t.kind,label:t.label,...t.symbol?{symbol:t.symbol}:{},...t.file!==void 0?{file:t.file,line:t.line}:{},subtypes:[n.subtype],count:1,strength:n.evidenceStrength,...t.local?{local:!0}:{},...r?{reference:!0}:{}});return}s.count+=1,s.subtypes.includes(n.subtype)||s.subtypes.push(n.subtype),Ne[n.evidenceStrength]<Ne[s.strength]&&(s.strength=n.evidenceStrength)}function Nt(e){return[...e.values()].map(t=>({...t,subtypes:[...t.subtypes].sort()})).sort((t,n)=>Ae(t.label,n.label)||Ae(t.file??"",n.file??"")||(t.line??0)-(n.line??0))}function Tt(e){return qe({...e,edges:[]},"",{file:"",startLine:0,endLine:-1})}function Bt(e,t){for(let n of e.edges){if(n.from.id===t)return n.from;if(n.to.id===t)return n.to}return null}function It(e){return e.location?{file:e.location.file,startLine:e.location.line,endLine:e.location.endLine??e.location.line}:{file:"",startLine:0,endLine:-1}}function jt(e){return{id:e.id,family:e.family,subtype:e.subtype,from:e.from,to:e.to,strength:e.evidenceStrength,methods:e.evidenceMethods}}function At(e,t){if(e===t.symbol)return!0;let n=e.replace(/\\/g,"/").replace(/\(\)$/u,""),r=C(t.symbol);if(n===q(t.symbol).replace(/\(\)$/u,"")||n===r)return!0;let s=e.match(/^(.+):(\d+)(?:-(\d+))?$/);if(s){let i=ye(s[1]);return t.relativePath===i||t.relativePath.endsWith(`/${i}`)}let o=n.lastIndexOf("/");return o>0&&n.slice(o+1)===r&&t.relativePath.toLowerCase().includes(n.slice(0,o).toLowerCase())}function Ae(e,t){return e<t?-1:e>t?1:0}function Ue(e){let t=e.published??fe,n=e.open(),r=null,s=o=>{try{o.close()}catch{}};return{acquire(){if(!n)throw new Error("The viewer database is closed.");let o=t(e.dbPath);if(o!==null&&o!==n.generation.identity&&o!==r)try{let i=e.open();s(n),n=i,r=o}catch{}return n},generation(){return n?.generation.identity??null},close(){let o=n;n=void 0,o&&s(o)}}}import{posix as Ge,resolve as _t}from"path";var He=400,We=2e3,$t=["callers","callees","contracts","data","state","runtime"],qt=4096,Ut=/:\d+(?:-\d+)?$/u,Gt=/^\s*```[^\n]*\n[\s\S]*?```[^\S\n]*(?:\n|$)/u;function Ye(e,t){return{status:200,body:{projectRoot:t.projectRoot,projectName:t.meta.projectName,cliVersion:t.meta.cliVersion,generation:D(e),watcher:{state:t.meta.watcherState()},builder:{available:t.meta.builder.available,modes:[...I],defaultMode:t.meta.builder.defaultMode}}}}function ze(e,t,n){let r=rt(t.get("basis"));if(r===null)return k(e,'basis must be "references" or "imports".');let s=t.get("path")??"",o=B(s);if(o===null)return L(e,`Path is outside the project: ${T(s)}`,{nearest:""});let i=n.queries.normalizeMapScope(o),a=n.queries.codeMapScope(e,{scope:i,basis:r});return a?{status:200,body:{...a,generation:D(e)}}:L(e,`No indexed files under "${i}".`,{nearest:n.queries.nearestMapScope(e,i)})}function Xe(e,t,n){let r=rt(t.get("basis"));if(r===null)return k(e,'basis must be "references" or "imports".');let s=t.get("path");if(!s)return k(e,"path is required.");let o=B(s);if(o===null||o===""||!n.queries.isIndexedFile(e,o))return L(e,`No indexed file at "${T(s)}".`);let i=n.queries.codeMapFile(e,o,r);return{status:200,body:{file:o,breadcrumbs:Yt(o),editorUri:ne(n.projectRoot,o,1),outline:tt(e,o,n),dependsOn:i?.dependsOn??[],dependedOnBy:i?.dependedOnBy??[],stale:n.queries.fileIsStale(e,o),generation:D(e)}}}function Qe(e,t,n){let r=t.get("symbol"),s=t.get("focus"),o=r||s;if(!o)return k(e,"symbol or focus is required.");if(o.length>qt)return k(e,"The selector is too long.");let i=r||"";if(!r){let S=n.queries.resolveFocus(e,o);if(S.status==="ambiguous")return{status:200,body:{status:"ambiguous",candidates:S.candidates.map(l=>({symbol:l.symbol,name:l.name,file:l.file,line:l.line+1})),total:S.total,generation:D(e)}};if(S.status==="missing")return L(e,`No symbol matches "${T(o)}".`);i=S.symbol}let a=Ut.test(i)?null:n.queries.code(e,i);if(!a||a.symbol!==i||a.symbol===a.relativePath||!n.queries.isIndexedFile(e,a.relativePath))return L(e,`No indexed definition for "${T(i)}".`);let d=a.relativePath,p=nt(tt(e,d,n),i),m=n.queries.fileSymbolFacts(e,d);if(!p&&!m.has(i))return L(e,`No indexed definition for "${T(i)}".`);let b=m.get(i),M=t.get("statements")==="1",y=n.queries.symbolFocusLanes(e,i,M?{statements:!0}:void 0),R=a.startLine+1,x=a.source.split(`
2
+ import{a as ke}from"./chunk-KUKKLWJD.js";import{a as Me,b as Fe}from"./chunk-L37EQYAX.js";import{r as xe}from"./chunk-BIADXGC3.js";import{H as ee,X as Ee,f as ve,v as Re,w as Z}from"./chunk-OWJWOEDU.js";import"./chunk-B2OB55RR.js";import"./chunk-XZEE23VG.js";import{K as ge,_ as be,a as I,b as pe,ba as X,c as me,ha as he}from"./chunk-7UCDGXRW.js";import"./chunk-EN4AHLL3.js";import{Ha as Se,ca as Q,ga as q,ha as C,ia as U,k as O,m as ye,ta as we}from"./chunk-EOKVZXNF.js";import"./chunk-D62CTZX6.js";import{E as ue,F as le,X as de,Z as fe,l as z}from"./chunk-5T44HG5Y.js";import{d as oe,i as Y,j as se,k as ie,p as ae,r as ce}from"./chunk-DUKHVPU5.js";import{rmSync as En}from"fs";import{createConnection as xn}from"net";import{basename as Mn,join as Fn,resolve as dt}from"path";import{spawn as wt}from"child_process";var St=/^https?:\/\//iu,vt=2e3;function Le(e,t={}){let n=t.platform??process.platform,r=t.env??process.env;if(!St.test(e))return Promise.resolve({launched:!1});if(Et(r.CI))return Promise.resolve({launched:!1});if(n!=="win32"&&n!=="darwin"&&!r.DISPLAY&&!r.WAYLAND_DISPLAY)return Promise.resolve({launched:!1});let{command:s,args:o}=Rt(n,e);return new Promise(i=>{let a;try{a=(t.spawn??wt)(s,o,{detached:!0,stdio:"ignore",windowsHide:!0})}catch{i({launched:!1});return}let d=m=>{clearTimeout(p),i({launched:m})},p=setTimeout(()=>d(!0),vt);a.once("spawn",()=>d(!0)),a.on("error",()=>d(!1)),a.unref()})}function Rt(e,t){return e==="win32"?{command:"rundll32.exe",args:["url.dll,FileProtocolHandler",t]}:e==="darwin"?{command:"open",args:[t]}:{command:"xdg-open",args:[t]}}function Et(e){return e!==void 0&&e!==""&&e!=="0"&&e.toLowerCase()!=="false"}var xt=5;function j(e){let t=e.trim().replace(/\\/g,"/");for(;t.startsWith("./");)t=t.slice(2);return t=t.replace(/^\/+/,"").replace(/\/+$/,""),t==="."?"":t}function Mt(e,t,n,r){let s=j(n),o=s?`${s}/`:"",i=[...new Set(e)].filter(l=>l.startsWith(o)).sort(F);if(i.length===0)return null;let a=new Set(i),d=new Map;for(let l of i){let f=l.slice(o.length),w=f.indexOf("/"),c=w<0?l:`${o}${f.slice(0,w)}`,u=d.get(c)??{kind:w<0?"file":"dir",files:[]};u.files.push(l),d.set(c,u)}let p=new Map,m=[];for(let[l,f]of d){let w=f.kind==="dir"?Ft(f.files):l;for(let c of f.files)p.set(c,w);m.push({id:w,kind:f.kind,name:f.kind==="dir"?w.slice(o.length):l.slice(o.length),path:w,files:f.files.length,internalEdges:0,cycle:null})}m.sort((l,f)=>(l.kind===f.kind?0:l.kind==="dir"?-1:1)||F(l.name,f.name));let b=new Map(m.map(l=>[l.id,l])),M=s?s.split("/"):[],y=new Map,R=new Map,x=0,E=(l,f,w)=>{x+=1;let c=`${l}\0${f}`,u=y.get(c)??{from:l,to:f,count:0,cycle:!1,samples:[]};u.count+=1,u.samples.length<xt&&u.samples.push(w),y.set(c,u)},P=l=>{let f=kt(M,l);return R.has(f)||R.set(f,{id:f,kind:"external",path:f}),f};for(let l of[...t.keys()].sort(F)){let f=a.has(l);for(let w of[...t.get(l)].sort(F)){let c=a.has(w);if(!f&&!c||!f&&l.startsWith(o)||!c&&w.startsWith(o))continue;let u={from:l,to:w};if(f&&c){let g=p.get(l),h=p.get(w);g===h?(x+=1,b.get(g).internalEdges+=1):E(g,h,u)}else f?E(p.get(l),P(w),u):E(P(l),p.get(w),u)}}let S=Lt(m,y);for(let l of m)l.cycle=S.get(l.id)??null;for(let l of y.values()){let f=S.get(l.from);l.cycle=f!==void 0&&f===S.get(l.to)}return{scope:s,basis:r,breadcrumbs:Dt(M),nodes:m,external:[...R.values()].sort((l,f)=>F(l.path,f.path)),edges:[...y.values()].sort((l,f)=>F(l.from,f.from)||F(l.to,f.to)),totals:{files:i.length,edges:x}}}function De(e,t){return Mt(O(e,{includeIgnored:!1}),Oe(e,t.basis),t.scope,t.basis)}function Pe(e,t){let n=O(e,{includeIgnored:!1}),r=j(t);for(;r;){let s=`${r}/`;if(n.some(i=>i.startsWith(s)))return r;let o=r.lastIndexOf("/");r=o<0?"":r.slice(0,o)}return""}function Ve(e,t,n){let r=j(t);if(!O(e,{includeIgnored:!1}).includes(r))return null;let s=Oe(e,n),o=[];for(let[i,a]of s)a.has(r)&&o.push(i);return{file:r,dependsOn:[...s.get(r)??[]].sort(F),dependedOnBy:o.sort(F)}}function Oe(e,t){return t==="imports"?Q(e,void 0,{scipEdges:"imports-only",sourceEdges:"imports-and-reexports"}):Q(e)}function Ft(e){let t=e.map(r=>r.split("/").slice(0,-1)),n=[...t[0]];for(let r of t){let s=0;for(;s<n.length&&s<r.length&&n[s]===r[s];)s+=1;n.length=s}return n.join("/")}function kt(e,t){let n=t.split("/"),r=0;for(;r<e.length&&r<n.length&&e[r]===n[r];)r+=1;return n.slice(0,r+1).join("/")}function Lt(e,t){let n=new Map(e.map(o=>[o.id,new Set]));for(let o of t.values())n.has(o.from)&&n.has(o.to)&&n.get(o.from).add(o.to);let r=Ee(n).components.filter(o=>o.length>1).map(o=>[...o].sort(F)).sort((o,i)=>F(o[0],i[0])),s=new Map;return r.forEach((o,i)=>{for(let a of o)s.set(a,i+1)}),s}function Dt(e){return[{name:"root",path:""},...e.map((t,n)=>({name:t,path:e.slice(0,n+1).join("/")}))]}function F(e,t){return e<t?-1:e>t?1:0}var Ce=["callers","callees","contracts","data","state","runtime"],Pt={families:["execution","identity","contract","dataflow","state","runtime"],subtypes:["call","result-callback","references","uses-contract-symbol","argument-to-parameter","constant-to-parameter","property-to-parameter","return-to-parameter","return-to-call-result","reads-resource","writes-resource","deletes-resource","enqueues-resource","consumes-resource","runtime-handoff","discriminator-dispatch"],direction:"both",maxDepth:1,maxEdges:2e3},Ne={exact:0,derived:1,mixed:2,candidate:3,unknown:4},N="root",Vt=new Set(["source-construct","runtime-boundary-participant","call-result","argument-expression","static-value"]);function _e(e,t){let n=t.trim();if(!n)return{status:"missing"};let r=Se(e,n),s=r.match;if(!s)return{status:"missing"};let o=new Map,i=(a,d,p)=>{o.has(a)||o.set(a,{symbol:a,name:q(a),file:d,line:p})};i(s.symbol,s.relativePath,s.startLine);for(let a of r.candidates)i(a.symbol,a.relativePath,a.startLine);return o.size===1&&At(n,s)?{status:"matched",symbol:s.symbol}:{status:"ambiguous",candidates:[...o.values()],total:r.total}}function $e(e,t,n={}){let r=ee(e,{symbols:[t]},Pt),s=r.targets[0]?.nodeIds[0],o=s?Bt(r,s):null,i=s&&o?qe(r,s,It(o)):Tt(r);if(!n.statements)return i;let a=ee(e,{symbols:[t]},{view:"complete",maxDepth:1,maxEdges:400});return{...i,statements:{inventory:a.inventory??[],edges:a.edges.map(jt)}}}function qe(e,t,n){let r=new Map(Ce.map(i=>[i,new Map])),s=[];for(let i of e.edges){let a=Te(i.from,t,n),d=Te(i.to,t,n);if(!a||!d)continue;let p,m;if(a===N&&d!==N)p=!1,m=d;else if(d===N&&a!==N)p=!0,m=a;else continue;if(i.family==="identity"){p&&i.subtype==="references"&&s.push({target:m,edge:i});continue}let b=Ot(i,p);b&&je(r.get(b),m,i,!1)}let o=r.get("callers");for(let{target:i,edge:a}of s){let d=o.get(i.key);(!d||d.reference)&&je(o,i,a,!0)}return{lanes:Object.fromEntries(Ce.map(i=>[i,Nt(r.get(i))])),coverage:{status:e.coverage.status,omittedEdges:e.coverage.omittedEdges}}}function Ot(e,t){let{family:n,subtype:r}=e;return n==="execution"&&(r==="call"||r==="result-callback")?t?"callers":"callees":n==="contract"&&r==="uses-contract-symbol"?t?null:"contracts":n==="dataflow"&&(r.endsWith("-to-parameter")||r==="return-to-call-result")?"data":n==="state"?"state":n==="runtime"?"runtime":null}function Te(e,t,n){if(e.id===t)return N;if(e.kind==="symbol"&&e.symbol)return Be(e.symbol,e.label,e);if(e.kind==="structural-region")return{key:`region:${e.id}`,kind:"region",label:e.label};if(e.kind==="program-resource"||e.kind==="runtime-state-resource")return{key:`resource:${e.id}`,kind:"resource",label:e.label,...te(e),...e.kind==="program-resource"&&Ie(e,n)?{local:!0}:{}};if(Ie(e,n))return N;if(e.location&&Vt.has(e.kind))return{key:`location:${e.id}`,kind:"location",label:e.label,...te(e)};let r=Ct(e);return r?Be(r,q(r),e):null}function Be(e,t,n){return{key:`symbol:${e}`,kind:"symbol",label:t,symbol:e,...te(n)}}function te(e){return e.location?{file:e.location.file,line:e.location.line}:{}}function Ie(e,t){return e.location!==null&&e.location.file===t.file&&e.location.line>=t.startLine&&e.location.line<=t.endLine}function Ct(e){if(e.kind!=="parameter")return null;let[t,n]=e.id.split(":");return t==="parameter"&&n?decodeURIComponent(n):null}function je(e,t,n,r){let s=e.get(t.key);if(!s){e.set(t.key,{kind:t.kind,label:t.label,...t.symbol?{symbol:t.symbol}:{},...t.file!==void 0?{file:t.file,line:t.line}:{},subtypes:[n.subtype],count:1,strength:n.evidenceStrength,...t.local?{local:!0}:{},...r?{reference:!0}:{}});return}s.count+=1,s.subtypes.includes(n.subtype)||s.subtypes.push(n.subtype),Ne[n.evidenceStrength]<Ne[s.strength]&&(s.strength=n.evidenceStrength)}function Nt(e){return[...e.values()].map(t=>({...t,subtypes:[...t.subtypes].sort()})).sort((t,n)=>Ae(t.label,n.label)||Ae(t.file??"",n.file??"")||(t.line??0)-(n.line??0))}function Tt(e){return qe({...e,edges:[]},"",{file:"",startLine:0,endLine:-1})}function Bt(e,t){for(let n of e.edges){if(n.from.id===t)return n.from;if(n.to.id===t)return n.to}return null}function It(e){return e.location?{file:e.location.file,startLine:e.location.line,endLine:e.location.endLine??e.location.line}:{file:"",startLine:0,endLine:-1}}function jt(e){return{id:e.id,family:e.family,subtype:e.subtype,from:e.from,to:e.to,strength:e.evidenceStrength,methods:e.evidenceMethods}}function At(e,t){if(e===t.symbol)return!0;let n=e.replace(/\\/g,"/").replace(/\(\)$/u,""),r=C(t.symbol);if(n===q(t.symbol).replace(/\(\)$/u,"")||n===r)return!0;let s=e.match(/^(.+):(\d+)(?:-(\d+))?$/);if(s){let i=ye(s[1]);return t.relativePath===i||t.relativePath.endsWith(`/${i}`)}let o=n.lastIndexOf("/");return o>0&&n.slice(o+1)===r&&t.relativePath.toLowerCase().includes(n.slice(0,o).toLowerCase())}function Ae(e,t){return e<t?-1:e>t?1:0}function Ue(e){let t=e.published??fe,n=e.open(),r=null,s=o=>{try{o.close()}catch{}};return{acquire(){if(!n)throw new Error("The viewer database is closed.");let o=t(e.dbPath);if(o!==null&&o!==n.generation.identity&&o!==r)try{let i=e.open();s(n),n=i,r=o}catch{}return n},generation(){return n?.generation.identity??null},close(){let o=n;n=void 0,o&&s(o)}}}import{posix as Ge,resolve as _t}from"path";var He=400,We=2e3,$t=["callers","callees","contracts","data","state","runtime"],qt=4096,Ut=/:\d+(?:-\d+)?$/u,Gt=/^\s*```[^\n]*\n[\s\S]*?```[^\S\n]*(?:\n|$)/u;function Ye(e,t){return{status:200,body:{projectRoot:t.projectRoot,projectName:t.meta.projectName,cliVersion:t.meta.cliVersion,generation:D(e),watcher:{state:t.meta.watcherState()},builder:{available:t.meta.builder.available,modes:[...I],defaultMode:t.meta.builder.defaultMode}}}}function ze(e,t,n){let r=rt(t.get("basis"));if(r===null)return k(e,'basis must be "references" or "imports".');let s=t.get("path")??"",o=B(s);if(o===null)return L(e,`Path is outside the project: ${T(s)}`,{nearest:""});let i=n.queries.normalizeMapScope(o),a=n.queries.codeMapScope(e,{scope:i,basis:r});return a?{status:200,body:{...a,generation:D(e)}}:L(e,`No indexed files under "${i}".`,{nearest:n.queries.nearestMapScope(e,i)})}function Xe(e,t,n){let r=rt(t.get("basis"));if(r===null)return k(e,'basis must be "references" or "imports".');let s=t.get("path");if(!s)return k(e,"path is required.");let o=B(s);if(o===null||o===""||!n.queries.isIndexedFile(e,o))return L(e,`No indexed file at "${T(s)}".`);let i=n.queries.codeMapFile(e,o,r);return{status:200,body:{file:o,breadcrumbs:Yt(o),editorUri:ne(n.projectRoot,o,1),outline:tt(e,o,n),dependsOn:i?.dependsOn??[],dependedOnBy:i?.dependedOnBy??[],stale:n.queries.fileIsStale(e,o),generation:D(e)}}}function Qe(e,t,n){let r=t.get("symbol"),s=t.get("focus"),o=r||s;if(!o)return k(e,"symbol or focus is required.");if(o.length>qt)return k(e,"The selector is too long.");let i=r||"";if(!r){let S=n.queries.resolveFocus(e,o);if(S.status==="ambiguous")return{status:200,body:{status:"ambiguous",candidates:S.candidates.map(l=>({symbol:l.symbol,name:l.name,file:l.file,line:l.line+1})),total:S.total,generation:D(e)}};if(S.status==="missing")return L(e,`No symbol matches "${T(o)}".`);i=S.symbol}let a=Ut.test(i)?null:n.queries.code(e,i);if(!a||a.symbol!==i||a.symbol===a.relativePath||!n.queries.isIndexedFile(e,a.relativePath))return L(e,`No indexed definition for "${T(i)}".`);let d=a.relativePath,p=nt(tt(e,d,n),i),m=n.queries.fileSymbolFacts(e,d);if(!p&&!m.has(i))return L(e,`No indexed definition for "${T(i)}".`);let b=m.get(i),M=t.get("statements")==="1",y=n.queries.symbolFocusLanes(e,i,M?{statements:!0}:void 0),R=a.startLine+1,x=a.source.split(`
3
3
  `),E=x.length>He,P=E?x.slice(0,He):x;return{status:200,body:{status:"matched",definition:{symbol:i,name:C(i),file:d,startLine:R,endLine:a.endLine+1,signature:p?.entry.signature??null,documentation:Wt(b?.documentation),editorUri:ne(n.projectRoot,d,R)},parent:p?.parent?{symbol:p.parent.symbol,name:p.parent.name}:null,members:(p?.entry.children??[]).map(S=>({symbol:S.symbol,name:S.name,line:S.startLine})),lanes:Qt(y.lanes,n.projectRoot),fileImports:n.queries.codeMapFile(e,d,"imports")?.dependsOn??[],coverage:y.coverage,source:{startLine:R,endLine:R+P.length-1,text:P.join(`
4
4
  `),truncated:E,stale:et(a)},...M&&y.statements?{statements:Jt(y.statements)}:{},generation:D(e)}}}function Ze(e,t,n){let r=t.get("file");if(!r)return k(e,"file is required.");let s=t.get("start"),o=t.get("end"),i=s===null?1:Ke(s);if(i===null)return k(e,"start must be a positive integer.");let a=o===null?i+We-1:Ke(o);if(a===null||a<i)return k(e,"end must be an integer at or after start.");let d=B(r);if(d===null||d===""||!n.queries.isIndexedFile(e,d))return L(e,`No indexed file at "${T(r)}".`);let p=Math.min(a,i+We-1),m=n.queries.code(e,`${d}:${i}-${p}`);return m?{status:200,body:{file:d,startLine:m.startLine+1,endLine:m.endLine+1,text:m.source,stale:et(m),generation:D(e)}}:L(e,`Lines ${i}-${p} are outside "${d}".`)}function B(e){if([...e].some(r=>r.charCodeAt(0)<32))return null;let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:/u.test(t))return null;let n=t.split("/").filter(r=>r!==""&&r!==".");return n.includes("..")?null:n.join("/")}function ne(e,t,n){return Ht(_t(e,t),n)}function Ht(e,t){let r=e.replaceAll("\\","/").replace(/[%#? ]/gu,s=>encodeURIComponent(s));return`vscode://file${r.startsWith("/")?"":"/"}${r}:${t}`}function Wt(e){if(!e)return null;let t=e.replace(Gt,"").trim();return t===""?null:t}function et(e){return e.freshness?.semantic.state==="stale"}function Jt(e){return{...e,edges:e.edges.map(Kt)}}function Kt(e){return{...e,from:Je(e.from),to:Je(e.to)}}function Je(e){let{location:t}=e;return t?{...e,location:{...t,line:t.line+1,...t.endLine!==void 0?{endLine:t.endLine+1}:{}}}:e}function Yt(e){let t=[{name:"root",path:""}],n="";for(let r of e.split("/"))n=n===""?r:`${n}/${r}`,t.push({name:r,path:n});return t}function tt(e,t,n){let r=n.queries.fileSymbolFacts(e,t),s=Xt(t),o=n.queries.outline(e,t).flatMap(a=>U(a.symbol)==="namespace"&&s.has(C(a.symbol))?a.children:[a]),i=(a,d)=>({symbol:a.symbol,name:C(a.symbol),kind:r.get(a.symbol)?.kind??zt(a.symbol,d),startLine:a.startLine+1,endLine:a.endLine+1,signature:a.signature,children:a.children.map(p=>i(p,a.symbol))});return o.map(a=>i(a))}function zt(e,t){let n=U(e);return n==="method"?t!==void 0&&U(t)==="type"?"method":"function":n==="term"?"variable":n??"unknown"}function Xt(e){let t=Ge.basename(e);return new Set([t,t.slice(0,Math.max(0,t.length-Ge.extname(t).length))])}function nt(e,t,n=null){for(let r of e){if(r.symbol===t)return{entry:r,parent:n};let s=nt(r.children,t,r);if(s)return s}return null}function Qt(e,t){let n={};for(let r of $t)n[r]=(e[r]??[]).map(s=>{let{line:o,...i}=s,a={...i};return o!==void 0&&(a.line=o+1),s.file!==void 0&&(a.editorUri=ne(t,s.file,(o??0)+1)),a});return n}function rt(e){return e===null||e===""?"references":e==="references"||e==="imports"?e:null}function Ke(e){if(!/^\d{1,9}$/u.test(e))return null;let t=Number(e);return t>=1?t:null}function D(e){return e.generation.identity}function k(e,t){return{status:400,body:{error:t,generation:D(e)}}}function L(e,t,n={}){return{status:404,body:{error:t,...n,generation:D(e)}}}function T(e){return e.length>200?`${e.slice(0,200)}...`:e}import{createHash as ct,randomBytes as Zt,timingSafeEqual as en}from"crypto";import{existsSync as A}from"fs";import{createServer as tn}from"http";import{createRequire as nn}from"module";import{dirname as rn,join as H}from"path";import{fileURLToPath as on}from"url";var _="127.0.0.1",sn=80,an="__CODEBASEIQ_TOKEN__",cn="x-codebaseiq-token",ot=64*1024,un=18e4,st=50,it=["reuse","rework","compose"],ln="cytoscape.esm.min.mjs",dn=["index.html","styles.css","app.js","api.js","map.js","file-panel.js","focus.js","builder.js"],fn={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".js":"text/javascript; charset=utf-8"},pn=["default-src 'self'","script-src 'self'","style-src 'self' 'unsafe-inline'","img-src 'self' data:","connect-src 'self'","frame-ancestors 'none'"].join("; ");function mn(){for(let e of["../ui/view/","../../../ui/view/"]){let t=on(new URL(e,import.meta.url));if(A(H(t,"index.html")))return t}}function gn(){try{let e=nn(import.meta.url).resolve("cytoscape"),t=H(rn(e),ln);return A(t)?t:void 0}catch{return}}function at(e,t){return{body:ae(e,{maxBytes:ie,inputKind:"viewer asset"}),contentType:t}}function bn(e,t){let n=e.uiDirectory??mn();if(!n||!A(H(n,"index.html")))throw new Error("The viewer UI files were not found; reinstall codebaseiq or rebuild the package.");let r=new Map;for(let i of dn){let a=H(n,i);if(!A(a))continue;let d=at(a,fn[i.slice(i.lastIndexOf("."))]??"application/octet-stream");r.set(i,i==="index.html"?{...d,body:Buffer.from(d.body.toString("utf8").replaceAll(an,t),"utf8")}:d)}let s=e.cytoscapePath??gn(),o=s&&A(s)?at(s,"text/javascript"):void 0;return{assets:r,...o?{vendor:o}:{}}}async function ut(e){let t=e.token??Zt(24).toString("base64url"),{assets:n,vendor:r}=bn(e,t),s=e.builderTimeoutMs??un,o=ct("sha256").update(t).digest(),i=0,a=!1,d=new Set,p=()=>lt(i),m=()=>yn(i),b=(c,u,g)=>{let h=JSON.stringify({generation:e.database.generation(),...g});c.writeHead(u,{...G(),"Content-Type":"application/json; charset=utf-8","Content-Length":Buffer.byteLength(h)}),c.end(h)},M=(c,u)=>{c.writeHead(200,{...G(),"Content-Type":u.contentType,"Content-Length":u.body.byteLength,...u.contentType.startsWith("text/html")?{"Content-Security-Policy":pn}:{}}),c.end(u.body)},y=(c,u,g,h={})=>{c.writeHead(u,{...G(),"Content-Type":"text/plain; charset=utf-8","Content-Length":Buffer.byteLength(g),...h}),c.end(g)},R=(c,u,g)=>{let h=hn.get(u);if(!h){b(c,404,{error:"Not found."});return}let v=h(e.database.acquire(),g,e.routes);b(c,v.status,v.body)},x=(c,u)=>{if(u==="/"){let v=n.get("index.html");v?M(c,v):y(c,404,"Not found.");return}if(u==="/favicon.ico"){c.writeHead(204,G()),c.end();return}if(u==="/vendor/cytoscape.mjs"&&r){M(c,r);return}let g=u.startsWith("/assets/")?u.slice(8):void 0,h=g===void 0?void 0:n.get(g);h?M(c,h):y(c,404,"Not found.")},E=async(c,u)=>{let g=c.headers.origin;if(g!==void 0&&!m().has(g)){b(u,403,{error:"Origin is not allowed."});return}if(!wn(c.headers["content-type"])){b(u,415,{error:"Content-Type must be application/json."});return}if(!Sn(o,c.headers[cn])){b(u,403,{error:"The viewer token is missing or wrong; reload the page."});return}let h=e.builder;if(!h){b(u,501,{error:"The symbol builder is not available in this viewer."});return}if(a){b(u,409,{error:"A builder query is already running."});return}a=!0;try{let v=await vn(c,ot);if(v===void 0){b(u,400,{error:`The request body must be at most ${ot/1024} KiB.`});return}let V=Rn(v);if(!V.ok){b(u,400,{error:V.error});return}await P(u,h,V.request,V.diagnostics)}finally{a=!1}},P=async(c,u,g,h)=>{let v=new AbortController;d.add(v);let V=()=>{c.writableEnded||v.abort(new Error("The client disconnected."))};c.on("close",V);let W;try{let $=await new Promise(J=>{W=setTimeout(()=>{v.abort(new Error("The builder query timed out.")),J({kind:"timeout"})},s),u(g,v.signal).then(K=>J({kind:"done",response:K}),K=>J({kind:"failed",error:K}))});if(c.destroyed)return;$.kind==="timeout"?b(c,504,{error:`The builder query took longer than ${Math.round(s/1e3)} s.`}):$.kind==="failed"?b(c,502,{error:re($.error)}):b(c,200,{...$.response,...h.length>0?{probeDiagnostics:h}:{}})}finally{W&&clearTimeout(W),c.off("close",V),d.delete(v)}},S=async(c,u)=>{if(!p().has((c.headers.host??"").toLowerCase())){y(u,403,"Forbidden host.");return}let g;try{g=new URL(c.url??"/",`http://${_}`)}catch{y(u,400,"Bad request.");return}let h=c.method??"GET";if(g.pathname==="/api/builder"){h==="POST"?await E(c,u):b(u,405,{error:"Use POST."});return}if(h!=="GET"&&h!=="HEAD"){y(u,405,"Method not allowed.",{Allow:"GET, HEAD"});return}g.pathname.startsWith("/api/")?R(u,g.pathname,g.searchParams):x(u,g.pathname)},l=tn((c,u)=>{S(c,u).catch(g=>{if(u.headersSent){u.destroy();return}b(u,500,{error:re(g)})})});await new Promise((c,u)=>{l.once("error",u),l.listen({host:_,port:e.port??0},()=>{l.off("error",u),c()})}),l.on("error",c=>{process.stderr.write(`codebaseiq view: server error: ${re(c)}
5
5
  `)});let f=l.address();i=typeof f=="object"&&f?f.port:0;let w=`http://${_}:${i}`;return{port:i,origin:w,url:`${w}/`,token:t,close(){for(let c of d)c.abort(new Error("The viewer is shutting down."));return new Promise(c=>{l.close(()=>c()),l.closeAllConnections()})}}}var hn=new Map([["/api/meta",(e,t,n)=>Ye(e,n)],["/api/scope",ze],["/api/file",Xe],["/api/symbol",Qe],["/api/source",Ze]]);function lt(e){let t=new Set([`${_}:${e}`,`localhost:${e}`]);return e===sn&&(t.add(_),t.add("localhost")),t}function yn(e){return new Set([...lt(e)].map(t=>`http://${t}`))}function G(){return{"Cache-Control":"no-store","X-Content-Type-Options":"nosniff","Referrer-Policy":"no-referrer"}}function wn(e){return e!==void 0&&e.split(";")[0].trim().toLowerCase()==="application/json"}function Sn(e,t){return typeof t!="string"||t===""?!1:en(ct("sha256").update(t).digest(),e)}function vn(e,t){return new Promise((n,r)=>{let s=[],o=0,i=!1;e.on("data",a=>{o+=a.byteLength,o>t?(i=!0,s.length=0):i||s.push(a)}),e.on("end",()=>n(i?void 0:Buffer.concat(s).toString("utf8"))),e.on("error",r)})}function Rn(e){let t;try{t=JSON.parse(e)}catch{return{ok:!1,error:"The request body must be valid JSON."}}if(typeof t!="object"||t===null||Array.isArray(t))return{ok:!1,error:"The request body must be a JSON object."};let n=t,r={},s=[];if(n.description!==void 0){if(typeof n.description!="string")return{ok:!1,error:"description must be a string."};n.description.trim()!==""&&(r.description=n.description)}if(n.probes!==void 0){let o=me(n.probes);s=o.diagnostics,(pe(o.probes)||o.probes.kinds.length>0)&&(r.probes=o.probes)}if(n.mode!==void 0){if(typeof n.mode!="string"||!I.includes(n.mode))return{ok:!1,error:`mode must be one of ${I.join(", ")}.`};r.mode=n.mode}if(n.bucket!==void 0){if(typeof n.bucket!="string"||!it.includes(n.bucket))return{ok:!1,error:`bucket must be one of ${it.join(", ")}.`};r.bucket=n.bucket}if(n.limit!==void 0){let o=n.limit;if(typeof o!="number"||!Number.isInteger(o)||o<1||o>st)return{ok:!1,error:`limit must be an integer from 1 to ${st}.`};r.limit=o}return r.description===void 0&&r.probes===void 0?{ok:!1,error:"Give a description or at least one probe."}:{ok:!0,request:r,diagnostics:s}}function re(e){return e instanceof Error?e.message:String(e)}var kn="view-server.json",ft="127.0.0.1",Ln=1e3,Dn=5e3,Pn=2e3,gt={isProcessAlive:se,canConnect(e,t){return new Promise(n=>{let r=xn({host:ft,port:e}),s=o=>{r.destroy(),n(o)};r.setTimeout(t,()=>s(!1)),r.once("connect",()=>s(!0)),r.once("error",()=>s(!1))})},async fetchProjectRoot(e,t){try{let n=await fetch(`http://${ft}:${e}/api/meta`,{signal:AbortSignal.timeout(t)});if(!n.ok)return{kind:"answered",projectRoot:void 0};let r=await n.json();return{kind:"answered",projectRoot:typeof r.projectRoot=="string"?r.projectRoot:void 0}}catch{return{kind:"unanswered"}}}};function pt(e,t){let n=new URL(e);return t.focus!==void 0?n.searchParams.set("focus",t.focus):t.file!==void 0?n.searchParams.set("file",t.file):t.scope!==void 0&&n.searchParams.set("scope",t.scope),n.toString()}async function bt(e,t,n=gt){let r=ht(e);if(!r||!n.isProcessAlive(r.pid)||!await n.canConnect(r.port,Ln))return;let s=await n.fetchProjectRoot(r.port,Dn);if(s.kind==="unanswered")return r;let o=s.projectRoot;if(!(o===void 0||Y(dt(o))!==Y(dt(t))))return r}async function Vn(e,t,n=gt){let r=await bt(e,t.projectRoot,n);if(r&&r.pid!==t.pid)return process.stderr.write(`warning: a viewer (pid ${r.pid}, ${r.url}) is already recorded for this project, so this one is not.
@@ -9,4 +9,4 @@ import{a as ke}from"./chunk-TJBOJUVN.js";import{a as Me,b as Fe}from"./chunk-5DS
9
9
  `)}function Cn(e,t){return e?.code==="EADDRINUSE"&&t?new Error(`Port ${t} is already in use; choose another with --port.`):e instanceof Error?e:new Error(String(e))}function Nn(e,t){try{let n=ge(e.projectRoot,e.config),r=Fe({settings:n,storeRoot:Me(e.paths.cacheDir),languages:Bn(t.acquire()),openDb:()=>t.acquire(),env:Tn(process.env)});return{run:(s,o)=>r.query(s,{signal:o}),defaultMode:n.mode,close:()=>r.close()}}catch(n){return process.stderr.write(`codebaseiq view: the symbol builder is unavailable: ${yt(n)}
10
10
  `),{defaultMode:"agent",close:()=>{}}}}function Tn(e){return Object.fromEntries(Object.entries(e).filter(([t])=>t!=="CLAUDECODE"&&!t.startsWith("CODEX_")))}function Bn(e){let t=e.generation.metadataRaw;return(t?le(ue(t))?.indexedLanguages:void 0)??[]}function In(e,t,n){let r;return()=>{let s=Date.now();if(r&&s-r.at<Pn)return r.value;let o;try{let{classification:i}=xe({projectRoot:e,cacheDir:t.paths.cacheDir,cliVersion:z,...n?{gitContext:n}:{}});o=i.kind==="live"?i.state.watcher.state:i.kind}catch{o="unknown"}return r={at:s,value:o},o}}function jn(){let e=new WeakMap;return{normalizeMapScope:j,codeMapScope:De,nearestMapScope:Pe,codeMapFile:Ve,isIndexedFile(t,n){let r=e.get(t);return r||(r=new Set(O(t,{includeIgnored:!1})),e.set(t,r)),r.has(n)},outline:Re,fileSymbolFacts(t,n){let r=new Map;for(let s of we(t,n))r.set(s.symbol,{kind:s.kind===null?null:An(s.kind),documentation:s.documentation});return r},resolveFocus:_e,symbolFocusLanes:$e,code:Z,fileIsStale(t,n){return Z(t,`${n}:1-1`)?.freshness?.semantic.state==="stale"}}}function An(e){let t=ve(e).toLowerCase();return t==="unknown"||t==="unspecifiedkind"?null:t}function _n(e){let t=()=>{let s=ht(e.stateFile);s?.pid===e.state.pid&&s.startedAt===e.state.startedAt&&En(e.stateFile,{force:!0})},n=!1,r=()=>{n||(n=!0,e.server.close().finally(()=>{e.builder.close(),e.database.close(),t(),console.log(`
11
11
  Stopped.`),process.exit(0)}))};process.on("SIGINT",r),process.on("SIGTERM",r),process.on("exit",t)}function yt(e){return e instanceof Error?e.message:String(e)}export{kn as VIEW_STATE_FILE,jn as createViewerQueries,bt as findRunningViewer,ht as readViewerState,Vn as recordRunningViewer,jr as runCodeViewer,Tn as viewerBuilderEnvironment,pt as viewerDeepLink};
12
- //# sourceMappingURL=code-viewer-KIXEYQNJ.js.map
12
+ //# sourceMappingURL=code-viewer-EXI5SFFR.js.map
@@ -1,4 +1,4 @@
1
- import{a as Aa,b as mt,c as Pa}from"./chunk-SB7NASHU.js";import{a as da}from"./chunk-I22IZYDI.js";import{b as ya}from"./chunk-GQXXOS55.js";import{a as q,b as x,c as Te,d as te,e as Le,f as l,g as Yt,h as va,i as R,j as C,k as Me,l as $a,m as J,n as Sa,o as je,p as k,q as le,r as pn,s as Tn,t as Xt,u as rn,v as de,w as ue,x as Se,y as Ln,z as La}from"./chunk-PTQPPPG2.js";import{a as Ia}from"./chunk-23C5AD3B.js";import{a as gt,b as ht}from"./chunk-RJVAPMHF.js";import{a as $i,b as Si,c as Xn,d as Ti,e as Ai}from"./chunk-MVRGB4KJ.js";import{b as bi,d as Li}from"./chunk-YTJHCGYB.js";import"./chunk-ILMHV3KM.js";import"./chunk-XN3EKMLI.js";import{a as cs,c as ps,d as ot,e as ms,f as fs,i as gs,j as hs,k as bs,m as ys,n as ja,p as ft}from"./chunk-OFGOOL6U.js";import{A as E,B as D,C as Ta,D as A,E as pt,F as se,a as ce,b as z,i as Y,j as ne,k as wa,l as xa,m as Ca,n as He,o as Ra,p as be,q as ka,r as $e,s as Ea,t as N,v as U,w as S,x as K,y as b,z as P}from"./chunk-FH5WG4LE.js";import{a as ca,e as Xe,f as En,h as la,i as Jt}from"./chunk-DAKIGMIK.js";import{A as ga,B as ha,C as ba,D as lt,E as dt,F as ut,f as ls,l as nt,m as tt,n as ds,r as us,t as at,u as ua,v as ct,w as pa,x as ma,y as fa}from"./chunk-GWYZVVKY.js";import{$ as Zs,$a as Zr,A as Ue,Aa as kr,B as js,Ba as Er,C as zt,Ca as Tr,D as Is,Da as Lr,E as Ns,Ea as Ar,F as Ds,Fa as Pr,Ga as jr,H as Os,Ha as Ir,I as Ms,Ia as Nr,J as qs,Ja as Dr,K as Bs,Ka as Or,L as Fs,La as Mr,M as _s,Ma as qr,N as Vs,Na as Br,O as Ws,Oa as Fr,P as Us,Pa as _r,Q as Hs,Qa as Vr,R as Gs,Ra as Wr,S as Ks,Sa as Ur,Ta as Hr,U as zs,Ua as Gr,V as st,Va as Kr,W as Cn,Wa as zr,X as Qs,Xa as Qr,Y as Js,Ya as Jr,Z as Ys,Za as Yr,_ as Xs,_a as Xr,a as $n,aa as er,ab as ea,b as vs,ba as nr,bb as na,c as $s,ca as tr,cb as ta,d as Ss,da as or,db as Qt,e as Sn,ea as ir,eb as I,f as ws,fa as sr,fb as he,g as xs,ga as rr,gb as W,ha as ar,hb as rt,ia as cr,ib as T,ja as lr,jb as Rn,ka as dr,kb as kn,l as Cs,la as ur,lb as Pe,m as wn,ma as pr,na as mr,nb as oa,oa as fr,ob as ia,pa as gr,pb as sa,q as Rs,qa as hr,qb as ra,r as ks,ra as br,rb as aa,s as Es,sa as yr,t as Ts,ta as vr,u as Ls,ua as $r,v as As,va as Sr,wa as wr,x as xn,xa as xr,y as it,ya as Cr,z as Ps,za as Rr}from"./chunk-LONKINMJ.js";import{f as wi}from"./chunk-O2M3VNDY.js";import{b as Pi}from"./chunk-ZZ3MWF33.js";import{P as Ri,Q as ki,R as Ei,n as vi,o as Jn}from"./chunk-6WAPPQ5F.js";import"./chunk-YUKYB54I.js";import{c as ji,m as Zn}from"./chunk-DDN2F6GB.js";import"./chunk-P5XHIJHI.js";import{a as We,d as pi,m as Gn}from"./chunk-EQNMD62X.js";import"./chunk-2PRONPAS.js";import"./chunk-P4NVCOM7.js";import{b as is}from"./chunk-CIYA2KZN.js";import"./chunk-4LK5OIPW.js";import{H as Qn,c as Kn,n as hi}from"./chunk-C6WKPKCF.js";import"./chunk-XQAVQVIL.js";import{c as ie,d as yi}from"./chunk-DRENNWRG.js";import{d as ss,h as rs,k as as}from"./chunk-PUVNH4PO.js";import"./chunk-SV2LEFVM.js";import{$ as Xi,A as Ht,B as Ye,C as on,D as dn,E as Bi,F as Fi,G as _i,H as Vi,I as Wi,J as Ui,L as Hi,M as Gi,N as un,O as Ki,P as sn,X as zi,Y as Qi,Z as Ji,_ as Yi,a as vn,aa as Zi,b as Vt,ba as es,c as Wt,ca as ns,da as pe,g as Ii,ga as fe,h as Ni,ha as Gt,i as Di,j as Oi,la as ts,ma as os,p as Ut,pa as Ee,ra as ge,sa as Kt,x as Mi,y as et,z as qi}from"./chunk-MEUHIDI3.js";import{A as zn,B as gi,G as _t,q as yn,r as fi}from"./chunk-5FWR5HLG.js";import{H as xi,I as Ci,a as ni,b as Mt,d as ti,e as oi,m as ui,p as oe,q as me,r as Yn}from"./chunk-T75DS2E6.js";import{e as mi}from"./chunk-YT4DVWUV.js";import"./chunk-RCIGX23V.js";import{i as ii,j as di}from"./chunk-D7DOB27N.js";import"./chunk-R2NOK63J.js";import{d as li}from"./chunk-6O3KXIDL.js";import{E as nn,F as ri,G as Ve,I as ai,J as ci,N as Bt,Y as Ft,a as Hn,b as en,ca as tn,g as ke,h as ln,s as si,t as qt}from"./chunk-UQYQBLJX.js";import{existsSync as Nn}from"fs";import{dirname as ho,join as go}from"path";import{execFileSync as Wp}from"child_process";import{createRequire as tp}from"module";var op=tp(import.meta.url);function Na(e,n=[]){let t=ip(),o=is(e,n),i=o[0];return t?o.length===0?{available:!1,dependencyAvailable:t,reason:"no tsconfig found"}:{available:!0,dependencyAvailable:t,tsconfigPath:i,tsconfigPaths:o}:{available:!1,dependencyAvailable:t,tsconfigPath:i,tsconfigPaths:o,reason:"ts-morph is not installed"}}function ip(){try{return op.resolve("ts-morph"),!0}catch{return!1}}import{execFileSync as An,spawnSync as sp}from"child_process";import{existsSync as Ie,mkdtempSync as rp,readdirSync as ap,rmSync as Da,symlinkSync as cp,writeFileSync as lp}from"fs";import{tmpdir as dp}from"os";import{join as ye}from"path";var up=3e5,pp=12,Ba=3e4,eo=1024*1024,mp={readWorkingTreeStatus(e){return An("git",["-C",e,"status","--porcelain"],{encoding:"utf-8",timeout:Ba,maxBuffer:eo,windowsHide:!0,killSignal:"SIGKILL"})}};function Fa(e,n,t={}){let o=xp(e,t.workingTreeRuntime),i=o.state==="known"?o.files:[],s=wp(n,o),r=no(e);if(r.length===0)return{checkers:[],uncoveredFiles:[],baselineErrors:0,workingTree:o,dirtyOverlap:s,dirtyWorkingTree:i,batches:[]};let a=bp(n,r),c=t.timeoutMs??up,d=[],u=new Map,m;try{m=Va(e,"scip-cleanup-verify-")}catch(f){return{checkers:r.map(p=>p.label),uncoveredFiles:a,baselineErrors:0,workingTree:o,dirtyOverlap:s,dirtyWorkingTree:i,unavailableReason:kp(f),batches:[]}}try{Rp(e,m.root);for(let f of r)u.set(f.label,Ma(f,m.root,c).rawErrors);for(let f of n.batches){Wa(m.root,f);let p=null;for(let g of r){let h=Ma(g,m.root,c),y=fp(h,u.get(g.label)??[],h.rawErrors);if(y.status==="failed"){let v=y.errors.length>0?y.errors:h.outputTail;p={depth:f.depth,status:"failed",reason:`${g.label}: ${y.reason}`,errors:v.slice(0,pp)};break}}if(!p)d.push({depth:f.depth,status:"verified"});else{d.push(p);break}}}finally{m.dispose()}return{checkers:r.map(f=>f.label),uncoveredFiles:a,baselineErrors:[...u.values()].reduce((f,p)=>f+p.length,0),workingTree:o,dirtyOverlap:s,dirtyWorkingTree:i,batches:d}}function fp(e,n,t){let o=gp(n,t);return o.length>0?{status:"failed",reason:"checker reported new errors",errors:o}:e.ok?{status:"verified",reason:"checker passed",errors:[]}:{status:"failed",reason:`checker exited ${e.exitCode===null?"unknown":String(e.exitCode)} with unparsed output`,errors:[...e.outputTail??[]]}}function gp(e,n){let t=hp(e),o=new Map,i=[];for(let s of n){let r=_a(s),a=(o.get(r)??0)+1;o.set(r,a),a>(t.get(r)??0)&&i.push(s)}return i}function hp(e){let n=new Map;for(let t of e){let o=_a(t);n.set(o,(n.get(o)??0)+1)}return n}function bp(e,n){let t=new Set(n.flatMap(i=>i.coversExtensions));return[...new Set(e.batches.flatMap(i=>i.entries.map(s=>s.file)))].filter(i=>{let s=i.slice(i.lastIndexOf("."));return!t.has(s)}).sort()}function _a(e){return e.replace(/\(\d+,\d+\)|:\d+(?::\d+)?/g,"").trim()}var Oa=[".ts",".tsx",".mts",".cts",".js",".jsx",".vue"],yp=["deps.edn","project.clj","bb.edn","shadow-cljs.edn"];function no(e){let n=[];if(Ie(ye(e,"tsconfig.json"))){let t=ye(e,"node_modules",".bin","tsc");n.push(Ie(t)?{label:"tsc --noEmit",binary:t,args:["--noEmit"],coversExtensions:Oa,strength:"reference-aware"}:{label:"npx tsc --noEmit",binary:"npx",args:["tsc","--noEmit"],coversExtensions:Oa,strength:"reference-aware"})}if(Ie(ye(e,"go.mod"))&&n.push({label:"go build ./...",binary:"go",args:["build","./..."],coversExtensions:[".go"],strength:"reference-aware"}),["pyproject.toml","setup.py","requirements.txt"].some(t=>Ie(ye(e,t)))){let t=vp();t&&n.push(t)}if(yp.some(t=>Ie(ye(e,t)))){let t=$p(e);t&&n.push(t)}for(let t of Sp(e))n.push({label:`cargo check --quiet --manifest-path ${t}`,binary:"cargo",args:["check","--quiet","--message-format","json","--manifest-path",t],coversExtensions:[".rs"],strength:"reference-aware",env:{...process.env,CARGO_TARGET_DIR:ye(e,t,"..","target")}});return n}function vp(){return We("ruff")?{label:"ruff check --select E9,F821,F822",binary:"ruff",args:["check","--quiet","--output-format","json","--select","E9,F821,F822","."],coversExtensions:[".py"],strength:"reference-aware"}:We("python3")?{label:"python3 -m compileall (syntax only)",binary:"python3",args:["-m","compileall","-q","."],coversExtensions:[".py"],strength:"syntax-only"}:null}function $p(e){let n=ye(e,"node_modules",".bin","clj-kondo");return Ie(n)?{label:"clj-kondo --lint .",binary:n,args:["--lint",".","--config","{:output {:format :json}}"],coversExtensions:[...Kn],strength:"reference-aware"}:We("clj-kondo")?{label:"clj-kondo --lint .",binary:"clj-kondo",args:["--lint",".","--config","{:output {:format :json}}"],coversExtensions:[...Kn],strength:"reference-aware"}:We("npx")?{label:"npx clj-kondo --lint .",binary:"npx",args:["--yes","clj-kondo","--lint",".","--config","{:output {:format :json}}"],coversExtensions:[...Kn],strength:"reference-aware"}:null}function Sp(e){let n=[];if(Ie(ye(e,"Cargo.toml")))return n.push("Cargo.toml"),n;let t;try{t=ap(e)}catch{return n}for(let o of t)o==="node_modules"||o.startsWith(".")||Ie(ye(e,o,"Cargo.toml"))&&n.push(`${o}/Cargo.toml`);return n}function wp(e,n){if(n.state==="unavailable")return[];let t=new Set(n.files);return[...new Set(e.batches.flatMap(i=>i.entries.map(s=>s.file)))].filter(i=>t.has(i)).sort()}function xp(e,n=mp){try{return{state:"known",files:n.readWorkingTreeStatus(e).split(`
1
+ import{a as Aa,b as mt,c as Pa}from"./chunk-SB7NASHU.js";import{a as da}from"./chunk-HNXRVGMY.js";import{b as ya}from"./chunk-OP6BUIV6.js";import{a as q,b as x,c as Te,d as te,e as Le,f as l,g as Yt,h as va,i as R,j as C,k as Me,l as $a,m as J,n as Sa,o as je,p as k,q as le,r as pn,s as Tn,t as Xt,u as rn,v as de,w as ue,x as Se,y as Ln,z as La}from"./chunk-WO6OFKUC.js";import{a as Ia}from"./chunk-OQ3DK7FW.js";import{a as gt,b as ht}from"./chunk-PIFYOWS4.js";import{a as $i,b as Si,c as Xn,d as Ti,e as Ai}from"./chunk-O2KWU34K.js";import{b as bi,d as Li}from"./chunk-YTJHCGYB.js";import"./chunk-ILMHV3KM.js";import"./chunk-XN3EKMLI.js";import{a as cs,c as ps,d as ot,e as ms,f as fs,i as gs,j as hs,k as bs,m as ys,n as ja,p as ft}from"./chunk-ZMA5HWXY.js";import{A as E,B as D,C as Ta,D as A,E as pt,F as se,a as ce,b as z,i as Y,j as ne,k as wa,l as xa,m as Ca,n as He,o as Ra,p as be,q as ka,r as $e,s as Ea,t as N,v as U,w as S,x as K,y as b,z as P}from"./chunk-XUPFA6GH.js";import{a as ca,e as Xe,f as En,h as la,i as Jt}from"./chunk-YPBKBYPS.js";import{A as ga,B as ha,C as ba,D as lt,E as dt,F as ut,f as ls,l as nt,m as tt,n as ds,r as us,t as at,u as ua,v as ct,w as pa,x as ma,y as fa}from"./chunk-V4NGDIEA.js";import{$ as Zs,$a as Zr,A as Ue,Aa as kr,B as js,Ba as Er,C as zt,Ca as Tr,D as Is,Da as Lr,E as Ns,Ea as Ar,F as Ds,Fa as Pr,Ga as jr,H as Os,Ha as Ir,I as Ms,Ia as Nr,J as qs,Ja as Dr,K as Bs,Ka as Or,L as Fs,La as Mr,M as _s,Ma as qr,N as Vs,Na as Br,O as Ws,Oa as Fr,P as Us,Pa as _r,Q as Hs,Qa as Vr,R as Gs,Ra as Wr,S as Ks,Sa as Ur,Ta as Hr,U as zs,Ua as Gr,V as st,Va as Kr,W as Cn,Wa as zr,X as Qs,Xa as Qr,Y as Js,Ya as Jr,Z as Ys,Za as Yr,_ as Xs,_a as Xr,a as $n,aa as er,ab as ea,b as vs,ba as nr,bb as na,c as $s,ca as tr,cb as ta,d as Ss,da as or,db as Qt,e as Sn,ea as ir,eb as I,f as ws,fa as sr,fb as he,g as xs,ga as rr,gb as W,ha as ar,hb as rt,ia as cr,ib as T,ja as lr,jb as Rn,ka as dr,kb as kn,l as Cs,la as ur,lb as Pe,m as wn,ma as pr,na as mr,nb as oa,oa as fr,ob as ia,pa as gr,pb as sa,q as Rs,qa as hr,qb as ra,r as ks,ra as br,rb as aa,s as Es,sa as yr,t as Ts,ta as vr,u as Ls,ua as $r,v as As,va as Sr,wa as wr,x as xn,xa as xr,y as it,ya as Cr,z as Ps,za as Rr}from"./chunk-JNXI6NQ7.js";import{f as wi}from"./chunk-O2M3VNDY.js";import{b as Pi}from"./chunk-ZZ3MWF33.js";import{P as Ri,Q as ki,R as Ei,n as vi,o as Jn}from"./chunk-K4S2VH42.js";import"./chunk-YUKYB54I.js";import{c as ji,m as Zn}from"./chunk-JAFDMV5I.js";import"./chunk-P5XHIJHI.js";import{a as We,d as pi,m as Gn}from"./chunk-EQNMD62X.js";import"./chunk-LSZYMN2A.js";import"./chunk-JYRJYXUV.js";import{b as is}from"./chunk-CIYA2KZN.js";import"./chunk-4LK5OIPW.js";import{H as Qn,c as Kn,n as hi}from"./chunk-C6WKPKCF.js";import"./chunk-XQAVQVIL.js";import{c as ie,d as yi}from"./chunk-DRENNWRG.js";import{d as ss,h as rs,k as as}from"./chunk-PUVNH4PO.js";import"./chunk-SV2LEFVM.js";import{$ as Xi,A as Ht,B as Ye,C as on,D as dn,E as Bi,F as Fi,G as _i,H as Vi,I as Wi,J as Ui,L as Hi,M as Gi,N as un,O as Ki,P as sn,X as zi,Y as Qi,Z as Ji,_ as Yi,a as vn,aa as Zi,b as Vt,ba as es,c as Wt,ca as ns,da as pe,g as Ii,ga as fe,h as Ni,ha as Gt,i as Di,j as Oi,la as ts,ma as os,p as Ut,pa as Ee,ra as ge,sa as Kt,x as Mi,y as et,z as qi}from"./chunk-MEUHIDI3.js";import{A as zn,B as gi,G as _t,q as yn,r as fi}from"./chunk-5FWR5HLG.js";import{H as xi,I as Ci,a as ni,b as Mt,d as ti,e as oi,m as ui,p as oe,q as me,r as Yn}from"./chunk-T75DS2E6.js";import{e as mi}from"./chunk-YT4DVWUV.js";import"./chunk-RCIGX23V.js";import{i as ii,j as di}from"./chunk-D7DOB27N.js";import"./chunk-R2NOK63J.js";import{d as li}from"./chunk-6O3KXIDL.js";import{E as nn,F as ri,G as Ve,I as ai,J as ci,N as Bt,Y as Ft,a as Hn,b as en,ca as tn,g as ke,h as ln,s as si,t as qt}from"./chunk-UQYQBLJX.js";import{existsSync as Nn}from"fs";import{dirname as ho,join as go}from"path";import{execFileSync as Wp}from"child_process";import{createRequire as tp}from"module";var op=tp(import.meta.url);function Na(e,n=[]){let t=ip(),o=is(e,n),i=o[0];return t?o.length===0?{available:!1,dependencyAvailable:t,reason:"no tsconfig found"}:{available:!0,dependencyAvailable:t,tsconfigPath:i,tsconfigPaths:o}:{available:!1,dependencyAvailable:t,tsconfigPath:i,tsconfigPaths:o,reason:"ts-morph is not installed"}}function ip(){try{return op.resolve("ts-morph"),!0}catch{return!1}}import{execFileSync as An,spawnSync as sp}from"child_process";import{existsSync as Ie,mkdtempSync as rp,readdirSync as ap,rmSync as Da,symlinkSync as cp,writeFileSync as lp}from"fs";import{tmpdir as dp}from"os";import{join as ye}from"path";var up=3e5,pp=12,Ba=3e4,eo=1024*1024,mp={readWorkingTreeStatus(e){return An("git",["-C",e,"status","--porcelain"],{encoding:"utf-8",timeout:Ba,maxBuffer:eo,windowsHide:!0,killSignal:"SIGKILL"})}};function Fa(e,n,t={}){let o=xp(e,t.workingTreeRuntime),i=o.state==="known"?o.files:[],s=wp(n,o),r=no(e);if(r.length===0)return{checkers:[],uncoveredFiles:[],baselineErrors:0,workingTree:o,dirtyOverlap:s,dirtyWorkingTree:i,batches:[]};let a=bp(n,r),c=t.timeoutMs??up,d=[],u=new Map,m;try{m=Va(e,"scip-cleanup-verify-")}catch(f){return{checkers:r.map(p=>p.label),uncoveredFiles:a,baselineErrors:0,workingTree:o,dirtyOverlap:s,dirtyWorkingTree:i,unavailableReason:kp(f),batches:[]}}try{Rp(e,m.root);for(let f of r)u.set(f.label,Ma(f,m.root,c).rawErrors);for(let f of n.batches){Wa(m.root,f);let p=null;for(let g of r){let h=Ma(g,m.root,c),y=fp(h,u.get(g.label)??[],h.rawErrors);if(y.status==="failed"){let v=y.errors.length>0?y.errors:h.outputTail;p={depth:f.depth,status:"failed",reason:`${g.label}: ${y.reason}`,errors:v.slice(0,pp)};break}}if(!p)d.push({depth:f.depth,status:"verified"});else{d.push(p);break}}}finally{m.dispose()}return{checkers:r.map(f=>f.label),uncoveredFiles:a,baselineErrors:[...u.values()].reduce((f,p)=>f+p.length,0),workingTree:o,dirtyOverlap:s,dirtyWorkingTree:i,batches:d}}function fp(e,n,t){let o=gp(n,t);return o.length>0?{status:"failed",reason:"checker reported new errors",errors:o}:e.ok?{status:"verified",reason:"checker passed",errors:[]}:{status:"failed",reason:`checker exited ${e.exitCode===null?"unknown":String(e.exitCode)} with unparsed output`,errors:[...e.outputTail??[]]}}function gp(e,n){let t=hp(e),o=new Map,i=[];for(let s of n){let r=_a(s),a=(o.get(r)??0)+1;o.set(r,a),a>(t.get(r)??0)&&i.push(s)}return i}function hp(e){let n=new Map;for(let t of e){let o=_a(t);n.set(o,(n.get(o)??0)+1)}return n}function bp(e,n){let t=new Set(n.flatMap(i=>i.coversExtensions));return[...new Set(e.batches.flatMap(i=>i.entries.map(s=>s.file)))].filter(i=>{let s=i.slice(i.lastIndexOf("."));return!t.has(s)}).sort()}function _a(e){return e.replace(/\(\d+,\d+\)|:\d+(?::\d+)?/g,"").trim()}var Oa=[".ts",".tsx",".mts",".cts",".js",".jsx",".vue"],yp=["deps.edn","project.clj","bb.edn","shadow-cljs.edn"];function no(e){let n=[];if(Ie(ye(e,"tsconfig.json"))){let t=ye(e,"node_modules",".bin","tsc");n.push(Ie(t)?{label:"tsc --noEmit",binary:t,args:["--noEmit"],coversExtensions:Oa,strength:"reference-aware"}:{label:"npx tsc --noEmit",binary:"npx",args:["tsc","--noEmit"],coversExtensions:Oa,strength:"reference-aware"})}if(Ie(ye(e,"go.mod"))&&n.push({label:"go build ./...",binary:"go",args:["build","./..."],coversExtensions:[".go"],strength:"reference-aware"}),["pyproject.toml","setup.py","requirements.txt"].some(t=>Ie(ye(e,t)))){let t=vp();t&&n.push(t)}if(yp.some(t=>Ie(ye(e,t)))){let t=$p(e);t&&n.push(t)}for(let t of Sp(e))n.push({label:`cargo check --quiet --manifest-path ${t}`,binary:"cargo",args:["check","--quiet","--message-format","json","--manifest-path",t],coversExtensions:[".rs"],strength:"reference-aware",env:{...process.env,CARGO_TARGET_DIR:ye(e,t,"..","target")}});return n}function vp(){return We("ruff")?{label:"ruff check --select E9,F821,F822",binary:"ruff",args:["check","--quiet","--output-format","json","--select","E9,F821,F822","."],coversExtensions:[".py"],strength:"reference-aware"}:We("python3")?{label:"python3 -m compileall (syntax only)",binary:"python3",args:["-m","compileall","-q","."],coversExtensions:[".py"],strength:"syntax-only"}:null}function $p(e){let n=ye(e,"node_modules",".bin","clj-kondo");return Ie(n)?{label:"clj-kondo --lint .",binary:n,args:["--lint",".","--config","{:output {:format :json}}"],coversExtensions:[...Kn],strength:"reference-aware"}:We("clj-kondo")?{label:"clj-kondo --lint .",binary:"clj-kondo",args:["--lint",".","--config","{:output {:format :json}}"],coversExtensions:[...Kn],strength:"reference-aware"}:We("npx")?{label:"npx clj-kondo --lint .",binary:"npx",args:["--yes","clj-kondo","--lint",".","--config","{:output {:format :json}}"],coversExtensions:[...Kn],strength:"reference-aware"}:null}function Sp(e){let n=[];if(Ie(ye(e,"Cargo.toml")))return n.push("Cargo.toml"),n;let t;try{t=ap(e)}catch{return n}for(let o of t)o==="node_modules"||o.startsWith(".")||Ie(ye(e,o,"Cargo.toml"))&&n.push(`${o}/Cargo.toml`);return n}function wp(e,n){if(n.state==="unavailable")return[];let t=new Set(n.files);return[...new Set(e.batches.flatMap(i=>i.entries.map(s=>s.file)))].filter(i=>t.has(i)).sort()}function xp(e,n=mp){try{return{state:"known",files:n.readWorkingTreeStatus(e).split(`
2
2
  `).map(o=>o.slice(3).trim()).filter(o=>o!=="").sort()}}catch(t){return{state:"unavailable",reason:Cp(t)}}}function Cp(e){let n=e&&typeof e=="object"?e:{};if(n.code==="ETIMEDOUT"||n.killed===!0)return`git status timed out after ${Ba}ms`;if(n.code==="ENOBUFS"||typeof n.message=="string"&&/maxBuffer|stdout.*buffer/i.test(n.message))return`git status exceeded its ${eo}-byte output limit`;if(typeof n.signal=="string"&&n.signal!=="")return`git status was terminated by ${n.signal}`;if(typeof n.status=="number")return`git status exited with status ${n.status}`;let t=typeof n.message=="string"?n.message.replaceAll(/\s+/g," ").trim().slice(0,240):String(e).replaceAll(/\s+/g," ").trim().slice(0,240);return t===""?"git status failed for an unknown reason":`git status failed: ${t}`}function Rp(e,n){for(let t of["node_modules"]){let o=ye(e,t),i=ye(n,t);if(Ie(o)&&!Ie(i))try{cp(o,i,"junction")}catch{}}}function Va(e,n){let t=rp(ye(dp(),n)),o=ye(t,"checkout");try{let i=An("git",["-C",e,"rev-parse","--verify","HEAD"],{encoding:"utf-8",timeout:3e4,maxBuffer:eo,killSignal:"SIGKILL"}).trim();return An("git",["clone","--quiet","--no-checkout","--shared","--",e,o],{stdio:"ignore",windowsHide:!0,timeout:3e4,killSignal:"SIGKILL"}),An("git",["-C",o,"checkout","--quiet","--detach","--force",i],{stdio:"ignore",windowsHide:!0,timeout:3e4,killSignal:"SIGKILL"}),{root:o,dispose(){Da(t,{recursive:!0,force:!0})}}}catch(i){throw Da(t,{recursive:!0,force:!0}),i}}function kp(e){let n=e;return n?.code==="ETIMEDOUT"||n?.killed===!0?"isolated HEAD snapshot timed out after 30000ms":typeof n?.signal=="string"&&n.signal!==""?`isolated HEAD snapshot was terminated by ${n.signal}`:typeof n?.status=="number"?`isolated HEAD snapshot failed because Git exited with status ${n.status}`:"isolated HEAD snapshot failed; confirm that Git can read the repository and committed HEAD"}function Wa(e,n){let t=new Map;for(let o of n.entries){let i=t.get(o.file)??[];i.push({start:o.startLine,end:o.endLine}),t.set(o.file,i)}for(let[o,i]of t){let s=ye(e,o);if(!Ie(s))continue;let r=ke(s,{maxBytes:en,inputKind:"cleanup verification source file"});lp(s,Lp(r,i,{rust:o.endsWith(".rs")}))}}function Ep(e,n={}){let t=e.flatMap(o=>o.entries.map(i=>({batch:o.depth,file:i.file,startLine:i.startLine,endLine:i.endLine,loc:i.loc,symbol:i.shortName})));return{dryRun:n.dryRun===!0,batches:e.length,symbols:t.length,loc:e.reduce((o,i)=>o+i.loc,0),files:[...new Set(t.map(o=>o.file))],filesEmptied:[...new Set(e.flatMap(o=>o.filesEmptied))],targets:t}}function Tp(e,n,t={}){let o=Ep(n,t);if(!o.dryRun)for(let i of n)Wa(e,i);return o}function Ua(e,n){let t=Va(e,"scip-cleanup-patch-");try{return Tp(t.root,n),An("git",["-C",t.root,"diff","--binary"],{encoding:"utf-8",maxBuffer:32*1024*1024,windowsHide:!0,timeout:3e4,killSignal:"SIGKILL"})}finally{t.dispose()}}function Ha(e,n={}){if(n.all)return[...e.batches];if(n.batch!==void 0){let t=e.batches.find(o=>o.depth===n.batch);return t?[t]:[]}return[...e.batches]}function Ga(e,n,t={}){if(e.unavailableReason)return[`Cleanup verification is unavailable: ${e.unavailableReason}.`];let o=[];e.checkers.length===0&&o.push("No project checker was detected, so no deletion patch is compiler-verified."),e.uncoveredFiles.length>0&&o.push(`No detected checker covers: ${e.uncoveredFiles.join(", ")}.`),!t.allowUnknownWorkingTree&&e.workingTree.state==="unavailable"&&o.push(`Working-tree inspection is unavailable: ${e.workingTree.reason}.`),!t.allowDirty&&e.dirtyOverlap.length>0&&o.push(`Plan files are dirty in the working tree: ${e.dirtyOverlap.join(", ")}.`);let i=new Set(e.batches.filter(s=>s.status==="verified").map(s=>s.depth));for(let s of n)i.has(s.depth)||o.push(`Batch ${s.depth} is not verified by the detected checker(s).`);return o}function Lp(e,n,t={}){let o=e.split(`
3
3
  `),i=(t.rust===!0?Ap(e):fi(e)).split(`
4
4
  `),s=new Set;for(let r of n){let a=Pp(o,r.start),c=Ip(i,a,Math.min(r.end,o.length-1));for(let d=a;d<=c&&d<o.length;d++)s.add(d)}return o.filter((r,a)=>!s.has(a)).join(`
@@ -330,6 +330,6 @@ export function tlaRecord(action: string, before: Record<string, unknown>, after
330
330
  Conformance: ${e.conformance.mappedVariables} variable(s), ${e.conformance.mappedActions} action(s), ${e.conformance.resolvedReferents} resolved referent(s).`),console.log(`Proof: ${i}`);for(let s of h$(e))console.log(`WARNING: ${s}`);if(e.conformance.waivers.length>0){console.log("Waivers:");for(let s of e.conformance.waivers){let r=s.legacy?" legacy":"",a=s.action?`${s.action} ${s.kind}`:`variable ${s.kind}`;console.log(` - ${a} ${s.variable}:${r} ${s.reason}`)}}if(e.conformance.findings.length===0){console.log(e.conformance.waivers.length===0?`PASS: model, mapping, and checked code evidence agree (model parsed by: ${e.conformance.modelParse}).`:`PASS: model checker and unwaived conformance checks passed (model parsed by: ${e.conformance.modelParse}); see waived facts above.`);return}if(console.log(`Findings: ${t.length} error(s), ${o.length} unknown(s), ${e.conformance.findings.length} total.`),n){for(let s of e.conformance.findings)Qu(s);return}f$(e.conformance)}function f$(e){let n=new Map(e.findings.map(t=>[t.id,t]));console.log(`
331
331
  Finding groups (${e.findingGroups.length}) \u2014 pass --full for every finding ungrouped:`);for(let t of e.findingGroups){console.log(`
332
332
  [${t.severity}] ${t.category}${t.modelElement?` (${t.modelElement})`:""} \u2014 ${t.count} finding(s)`);for(let i of t.findingIds.slice(0,Hu)){let s=n.get(i);s&&Qu(s)}let o=t.count-Hu;o>0&&console.log(` ... and ${o} more in this group (use --full to show all)`)}}function g$(e){let n=`${e.checker.checker} ${e.checker.status==="passed"?"PASS":e.checker.status.toUpperCase()}`,t=e.conformance.waivers.filter(r=>r.kind==="write").length,o=e.conformance.waivers.filter(r=>r.kind==="read").length,i=e.conformance.waivers.filter(r=>r.kind==="referent").length,s=e.conformance.findings.filter(r=>r.category==="missing-call").length;return[`checker: ${n}`,`model parsed by: ${e.conformance.modelParse}`,`writes: ${e.conformance.staticWrites.length} verified, ${t} waived`,`reads: ${e.conformance.staticReads.length} verified, ${o} waived`,`calls: ${s===0?"checked":`${s} missing`}`,`traces: ${e.conformance.traceStepsChecked} steps (key-diff; 'tla trace-check' proves acceptance)`,...i>0?[`referents: ${i} waived`]:[]].join(" | ")}function h$(e){let n=[],t=e.conformance.waivers.filter(i=>i.kind==="write").length,o=e.conformance.waivers.filter(i=>i.kind==="read").length;return t>0&&e.conformance.staticWrites.length===0&&n.push("NOTHING PROVEN ABOUT WRITES: every write fact found in this run was waived or unobserved."),o>0&&e.conformance.staticReads.length===0&&n.push("NOTHING PROVEN ABOUT READS: every read fact found in this run was waived or unobserved."),n}function Qu(e){let n=e.file&&e.startLine!==void 0&&e.endLine!==void 0?` ${W(e.file,e.startLine,e.endLine)}`:e.file?` ${e.file}`:"";console.log(`
333
- [${e.severity}] ${e.category} (${e.evidence})${n}`),console.log(` ${e.message}`);for(let t of e.why)console.log(` why: ${t}`);console.log(` fix: ${e.remediation}`)}var Ju=["stats","files","session","inspect","search","anchors","methods","refs","trace","evidence","evidence-source","deps","rdeps","system","surface","dead","hotspots","imports","imported-by","unused-imports","outline","members","fan-in","fan-out","coupling","cycles","architecture","bottlenecks","isolated","by-kind","kind-counts","dependency-depth","deep-chains","hierarchy","entrypoints","entry-map","system-map","call-graph","similar","similar-files","react-component-duplicates","react-hook-candidates","react-large-component-pressure","vue-component-duplicates","vue-composable-candidates","vue-large-view-pressure","similar-chains","extract-candidates","locality-candidates","affected","change-surface","cleanup-plan","co-change","recent-duplicates","doc-drift","unused-params","incomplete-migration","tla","context","reuse","drift","wrapper-candidates","passthrough-candidates","stale-abstractions","complexity-hotspots","self-audit","convergence","code","complexity","reference-neighborhood","dataflow","value-flow","dependence-slice","reference-reachability","slice","redundant-reexports","duplicate-bodies","twin-drift","twin-ab","not-implemented","decorative-checkers","test-quality","similar-signatures"],b$=[kd,Yd,Nd,Ct,Md,eu,Ll,zu,Dd],Yu=b$.flat(),y$=new Map(Yu.map(e=>[e.id,e]));for(let e of Yu)if(!Ju.includes(e.id))throw new Error(`Query command descriptor is not ordered: ${e.id}`);var Xu=Ju.map(e=>v$(e));function v$(e){let n=y$.get(e);if(!n)throw new Error(`Unknown query command descriptor: ${e}`);return n}async function $$(e){let n=se(e),t=S(n,"focus"),o=S(n,"scope"),i=S(n,"file"),s=K(n,"port"),{runCodeViewer:r}=await import("./code-viewer-VHLBLIUM.js");await r({...t!==void 0?{focus:t}:{},...o!==void 0?{scope:o}:{},...i!==void 0?{file:i}:{},...s!==void 0?{port:s}:{},open:n.open!==!1})}var Zu={id:"view",command:"view",agent:le("Can a person see this folder, file, or symbol on a browsable map of the repository?","the local viewer address, with a deep link when a target is named",[],"complete","repository",z("composite")),description:"Open a local browser map of folders, files, and one symbol at a time",helpAfter:`Serves 127.0.0.1 only and runs until interrupted. With a viewer already running for this project,
333
+ [${e.severity}] ${e.category} (${e.evidence})${n}`),console.log(` ${e.message}`);for(let t of e.why)console.log(` why: ${t}`);console.log(` fix: ${e.remediation}`)}var Ju=["stats","files","session","inspect","search","anchors","methods","refs","trace","evidence","evidence-source","deps","rdeps","system","surface","dead","hotspots","imports","imported-by","unused-imports","outline","members","fan-in","fan-out","coupling","cycles","architecture","bottlenecks","isolated","by-kind","kind-counts","dependency-depth","deep-chains","hierarchy","entrypoints","entry-map","system-map","call-graph","similar","similar-files","react-component-duplicates","react-hook-candidates","react-large-component-pressure","vue-component-duplicates","vue-composable-candidates","vue-large-view-pressure","similar-chains","extract-candidates","locality-candidates","affected","change-surface","cleanup-plan","co-change","recent-duplicates","doc-drift","unused-params","incomplete-migration","tla","context","reuse","drift","wrapper-candidates","passthrough-candidates","stale-abstractions","complexity-hotspots","self-audit","convergence","code","complexity","reference-neighborhood","dataflow","value-flow","dependence-slice","reference-reachability","slice","redundant-reexports","duplicate-bodies","twin-drift","twin-ab","not-implemented","decorative-checkers","test-quality","similar-signatures"],b$=[kd,Yd,Nd,Ct,Md,eu,Ll,zu,Dd],Yu=b$.flat(),y$=new Map(Yu.map(e=>[e.id,e]));for(let e of Yu)if(!Ju.includes(e.id))throw new Error(`Query command descriptor is not ordered: ${e.id}`);var Xu=Ju.map(e=>v$(e));function v$(e){let n=y$.get(e);if(!n)throw new Error(`Unknown query command descriptor: ${e}`);return n}async function $$(e){let n=se(e),t=S(n,"focus"),o=S(n,"scope"),i=S(n,"file"),s=K(n,"port"),{runCodeViewer:r}=await import("./code-viewer-AMRXV444.js");await r({...t!==void 0?{focus:t}:{},...o!==void 0?{scope:o}:{},...i!==void 0?{file:i}:{},...s!==void 0?{port:s}:{},open:n.open!==!1})}var Zu={id:"view",command:"view",agent:le("Can a person see this folder, file, or symbol on a browsable map of the repository?","the local viewer address, with a deep link when a target is named",[],"complete","repository",z("composite")),description:"Open a local browser map of folders, files, and one symbol at a time",helpAfter:`Serves 127.0.0.1 only and runs until interrupted. With a viewer already running for this project,
334
334
  --focus, --scope, or --file points that viewer at the target and returns at once, so an agent can show a person a symbol.`,options:[l("--focus <selector>","Open the focus view of one symbol"),l("--scope <dir>","Open the map at one folder"),l("--file <path>","Open one file"),l("--port <n>","Listen on this port instead of a free one",Te),l("--no-open","Print the address without opening a browser")],renderShape:"custom",docs:C("Graph",["codebaseiq view","codebaseiq view --focus handleRequest","codebaseiq view --scope src/runtime"]),handler:$$};var Rk=[da,ya,{id:"hook-architecture-stop",command:"hook-architecture-stop",hidden:!0,agent:le("Did indexed source changes preserve the repository architecture policy?","architecture policy decision and enforced finding identities",[],"complete","diff",z("repository-observation")),description:"Internal architecture-only Stop hook",renderShape:"custom",handler:Jc},{id:"reindex",command:"reindex",agent:le("Can the repository index be refreshed, and which language shards succeeded?","index generation, shard statuses, reuse diagnostics, and failures",[],"complete","repository",z("composite")),description:"Index the codebase and convert to SQLite",options:R([l("-l, --language <lang>","Index only this language (can be repeated)",q,[]),l("--pnpm-workspaces","Enable pnpm workspace support (TypeScript)"),l("--force","Rebuild even if source inputs are unchanged"),l("--allow-partial","Write an incomplete index when one or more detected languages fail"),l("--trust-project-tools","Permit reviewed indexers from this repository for this run"),l("--install-missing","Install missing global tools at reviewed immutable versions for this run"),l("--indexer-concurrency <n>","Number of language indexers to run at once",te)]),renderShape:"custom",docs:C("Indexing",["codebaseiq reindex"]),handler:Yc},{id:"augment-sources",command:"augment-sources",agent:le("Can source files omitted by upstream indexers be added to the index?","added document counts and augmentation status",[],"complete","repository",z("composite")),description:"Add source files skipped by upstream SCIP indexers to the SQLite documents table",renderShape:"custom",docs:C("Indexing"),handler:Xc},{id:"augment-vue",command:"augment-vue",agent:le("Can Vue SFC references be compiler-resolved and added to the index?","Vue augmentation counts, project, and diagnostics",[],"complete","repository",z("composite")),description:"Add compiler-resolved Vue SFC references to the SQLite index using Volar",options:[l("--project <tsconfig>","Vue tsconfig path",void 0,"frontend/tsconfig.scip.json")],renderShape:"custom",docs:C("Indexing"),handler:Zc},...Xu,{id:"__query-lane-ping",command:"__query-lane-ping",description:"Internal query lane transport probe",hidden:!0,renderShape:"custom",handler:wl},{id:kn,command:kn,description:"Internal diff-impact batch worker",hidden:!0,options:[l("--json","Emit the private worker envelope without transport pagination"),l("--base <ref>","Git ref to diff against (default: HEAD)")],renderShape:"custom",handler:el},{id:"diff-impact",command:"diff-impact",agent:k("Which symbols changed in this diff and which downstream consumers are affected?","changed symbols, downstream consumer identities, and impact paths",[],"bounded","diff"),description:"Map changed symbols and downstream consumers from the current git diff",options:R([l("--base <ref>","Git ref to diff against (default: HEAD)")]),claims:Me(["index-generation","live-workspace"],[J("changed-files","changedFiles[]","repository-source"),J("changed-symbols","changedSymbols[]","compiler-graph"),J("downstream-consumers","affected[]","compiler-graph")]),renderShape:"custom",docs:C("Impact"),handler:nl},{id:Rn,command:Rn,description:"Internal health phase worker",hidden:!0,arguments:[{name:"<phase>"}],options:[l("--json","Emit the private worker envelope without transport pagination"),l("-s, --scope <path>","Limit to files matching path"),l("--full","Run unbounded candidate analyses on large indexes")],renderShape:"custom",handler:tl},{id:"health",command:"health",agent:le("Where has this repository accumulated drift, duplication, complexity, or cleanup pressure?","health score, findings, priorities, baselines, and coverage notes",[],"bounded","repository",z("repository-observation",[{when:{kind:"option",name:"writeBaseline",equals:!0},role:"composite"}])),description:"Composite repository health report with React, Vue, and general cleanup findings",options:R([l("-s, --scope <path>","Limit to files matching path"),l("--full","Run unbounded candidate analyses on large indexes"),l("--baseline","Compare findings against the committed baseline; exit 1 on new findings"),l("--write-baseline","Snapshot current finding identities to the baseline file")]),claims:Me(["index-generation","live-workspace","process"],[Sa("actions","actions[]","evidence",{"graph-fact":"compiler-graph",heuristic:"heuristic","change-graph":"change-history"}),J("coverage-notes","coverage","repository-source")]),renderShape:"custom",docs:C("Health",["codebaseiq health --json","codebaseiq health --baseline"]),handler:ol},{id:"install-skills",command:"install-skills",agent:le("Which codebaseiq skills were installed, updated, skipped, or conflicted?","skill target paths and install outcomes",[],"complete","repository",z("mutation")),description:`Install skills (${Aa.join(", ")}) into Claude Code, Codex, and shared agent roots`,renderShape:"custom",docs:C("Maintenance"),handler:il},{id:"check-deps",command:"check-deps",agent:k("Which codebaseiq and language-indexer dependencies are runnable?","dependency readiness statuses and remediation",[],"complete","repository",z("environment-observation")),description:"Check whether codebaseiq and the detected language indexers are runnable",renderShape:"custom",docs:C("Maintenance"),handler:sl},{id:"capabilities",command:"capabilities",agent:k("Which repository-mapping and analysis capabilities are available here?","capability matrix with availability and reasons",[],"complete","repository",z("environment-observation")),description:"Report which mapping and analysis capabilities are available in this project",options:R([l("--matrix","Add exhaustive provider and language support details")]),renderShape:"custom",docs:C("Maintenance"),handler:rl},{id:"init",command:"init",agent:le("Can a starter codebaseiq configuration be created for this project?","configuration path and creation outcome",[],"complete","repository",z("mutation")),description:"Create a .codebaseiq.json configuration file for this project",renderShape:"custom",docs:C("Maintenance"),handler:al},{id:"config-validate",command:"config-validate",agent:k("Is this project configuration valid and internally consistent?","validation diagnostics with configuration paths",[],"complete","repository"),description:"Validate .codebaseiq.json, structured suppressions, architecture, and coupling groups",options:R(),claims:$a("repository-source",["live-workspace"]),renderShape:"custom",docs:C("Maintenance",["codebaseiq config-validate"]),handler:cl},{id:"suppress",command:"suppress <id>",agent:le("Can this accepted finding be recorded with an auditable reason?","suppression identity, path, scope, and expiry",["finding"],"complete",void 0,z("mutation")),description:"Record an accepted finding under .codebaseiq/suppressions with a required reason",options:R([l("--reason <text>","Required concrete claim explaining why the detector remediation is inapplicable"),l("--reason-code <code>","Required adjudication code"),l("--evidence <kind:referent>","Required counterevidence; repeat for more evidence",q,[]),l("--check <check>","Optional detector name to narrow the suppression"),l("--file <path>","Optional file path to narrow the suppression"),l("--expires-at <iso>","Optional ISO date after which the suppression expires"),l("--replace <revision>","Replace a prior decision with this exact SHA-256 revision")]),renderShape:"custom",docs:C("Maintenance"),handler:ll},{id:"doctor",command:"doctor",agent:k("Why is codebaseiq unhealthy or unavailable in this project?","configuration, freshness, dependency, and capability diagnostics",[],"complete","repository",z("environment-observation")),description:"Diagnose configuration, index freshness, dependencies, and project capabilities",options:R(),renderShape:"custom",docs:C("Maintenance"),handler:dl},{id:"setup",command:"setup",agent:le("Can codebaseiq be bootstrapped end to end in this project?","setup step outcomes, files, capabilities, smoke tests, and warnings",[],"complete","repository",z("composite")),description:"Install skills, write agent guidance, refresh the index, and report repository health",options:R([l("--guided","Require and open the interactive terminal checklist"),l("--yes","Accept recommended setup defaults without prompting"),l("--no-skills","Skip user-level agent skill installation"),l("--no-parsers","Skip Tree-sitter AST parser installation and repair"),l("--install-missing","Install missing global tools at reviewed immutable versions"),l("--no-health","Skip the optional full health report and dossier"),l("--dossier-dir <path>","Directory for generated setup health dossier files"),l("--builder-mode <mode>","Symbol builder provider mode: agent, embeddings, or auto"),l("--embeddings-endpoint <name=url>","Add an OpenAI-compatible embeddings endpoint (repeatable; needs --embeddings-model)",q,[]),l("--embeddings-model <model>","Model the --embeddings-endpoint servers should be asked for"),l("--agent-command <name>","Configure a built-in agent probe command: claude or codex"),l("--builder-scope <scope>","Where builder settings go: local (.codebaseiq.local.json, default) or project (.codebaseiq.json)"),l("--sentinel","Enable the trailing sentinel for agent sessions (also enables automatic indexing)"),l("--no-sentinel","Disable the trailing sentinel for agent sessions"),l("--sentinel-live [families]","Deliver sentinel findings to the agent, not only record them (implies --sentinel); name families (reuse-match,unwired) to promote only those")]),renderShape:"custom",docs:C("Maintenance",["codebaseiq setup","codebaseiq setup --install-missing","codebaseiq setup --json"]),handler:ml},{id:"setup-agent",command:"setup-agent",agent:le("Can concise project guidance for codebaseiq be written?","written, unchanged, and skipped agent instruction files",[],"complete","repository",z("mutation")),description:"Write concise codebaseiq mapping and cleanup guidance to AGENTS.md and CLAUDE.md",renderShape:"custom",docs:C("Maintenance",["codebaseiq setup-agent"]),handler:pl},{id:"uninstall",command:"uninstall",agent:le("Which codebaseiq-owned integrations can be removed without touching user-owned files?","removed, retained, skipped, and dry-run targets",[],"complete","repository",z("mutation",[{when:{kind:"option",name:"dryRun",equals:!0},role:"repository-preview"}])),description:"Remove selected codebaseiq-owned skills or project guidance",options:R([l("--global","Remove codebaseiq-owned skill symlinks from user-level agent skill roots"),l("--project","Remove managed AGENTS.md and CLAUDE.md blocks"),l("--dry-run","List what would be removed without changing files"),l("--verbose","List every unrelated global skill entry left in place")]),renderShape:"custom",docs:C("Maintenance",["codebaseiq uninstall --dry-run","codebaseiq uninstall --project"]),handler:fl},{id:"watch",command:"watch",agent:le("What is the watcher doing, or can its background service be started or stopped?","watcher state, generation, activity, and errors",[],"complete","repository",z("composite",[{when:{kind:"option",name:"status",equals:!0},role:"environment-observation"}])),description:"Watch in the foreground or manage the project refresh service",options:R([l("--daemon","Make sure that the background service is running"),l("--status","Show the watcher state"),l("--stop","Stop the watcher for this project"),l("--debounce <ms>","Milliseconds after the last change",Te),l("--cooldown <ms>","Minimum milliseconds between indexes",Te),l("--git-poll <ms>","Milliseconds between Git state checks",Te),l("--idle-timeout <ms>","Milliseconds before a clean idle daemon exits",Te)]),renderShape:"custom",docs:C("Maintenance"),handler:gl},{id:"status",command:"status",agent:k("Is the index fresh, complete, and usable for this project?","freshness, generation, language shards, and watcher state",[],"complete","repository",z("environment-observation")),description:"Show index status for this project",options:R([{...l("--capabilities","Compatibility: include a concise capability-readiness summary"),hidden:!0}]),renderShape:"custom",docs:C("Maintenance"),handler:yl},Zu];export{Rk as commandDescriptors};
335
- //# sourceMappingURL=command-descriptors-F5P2V3NW.js.map
335
+ //# sourceMappingURL=command-descriptors-H6A4UY72.js.map