@automaton-labs/aib 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +4 -2
- package/dist/commands/apply-module-plan.js +3 -3
- package/dist/commands/background-command.js +2 -0
- package/dist/commands/captured-input.js +1 -2
- package/dist/commands/config-command.js +2 -1
- package/dist/commands/config-output.js +10 -8
- package/dist/commands/control-plane-command.js +1 -0
- package/dist/commands/declaration-command.js +7 -0
- package/dist/commands/declaration-execution-cache.js +1 -0
- package/dist/commands/declaration-format.js +1 -0
- package/dist/commands/declaration-preview-cache.js +2 -0
- package/dist/commands/doctor.js +3 -1
- package/dist/commands/execution-command.js +1 -1
- package/dist/commands/file-command.js +1 -0
- package/dist/commands/file-move-to-dir-execution-cache.js +1 -0
- package/dist/commands/file-move-to-dir-preview-cache.js +2 -0
- package/dist/commands/file-move-to-dir.js +5 -0
- package/dist/commands/file-mutation-runtime.js +1 -0
- package/dist/commands/file-refactor-batch-execution-cache.js +1 -0
- package/dist/commands/file-refactor-batch-preview-cache.js +2 -0
- package/dist/commands/file-refactor-batch.js +5 -0
- package/dist/commands/file-rename-execution-cache.js +1 -0
- package/dist/commands/file-rename-preview-cache.js +2 -0
- package/dist/commands/file-rename.js +5 -0
- package/dist/commands/help-command.js +5 -5
- package/dist/commands/host-command.js +1 -0
- package/dist/commands/inspect-cycles.js +3 -3
- package/dist/commands/inspect-format.js +15 -15
- package/dist/commands/inspect-tree.js +2 -2
- package/dist/commands/inspect.js +12 -12
- package/dist/commands/move-to-file.js +2 -2
- package/dist/commands/ota-command.js +2 -0
- package/dist/commands/quick-read.js +8 -8
- package/dist/commands/refactor-batch.js +4 -4
- package/dist/commands/rename-entities.js +4 -4
- package/dist/commands/result-view.js +6 -5
- package/dist/commands/session-workspace.js +7 -7
- package/dist/commands/worker-command.js +1 -0
- package/dist/config/defaults.js +1 -1
- package/dist/config/env-vars.js +1 -1
- package/dist/config/path-aliases.js +1 -1
- package/dist/config/resolve-command-alias.js +1 -1
- package/dist/config/workspace-root.js +3 -3
- package/dist/content/content-bundle.js +1 -1
- package/dist/dsl/aib-dsl.js +1 -1
- package/dist/dsl/declaration-dsl.js +1 -0
- package/dist/dsl/file-move-to-dir-dsl.js +1 -0
- package/dist/dsl/file-refactor-batch-dsl.js +1 -0
- package/dist/dsl/file-rename-dsl.js +1 -0
- package/dist/help/bootstrap.bash.md +907 -0
- package/dist/help/bootstrap.md +105 -144
- package/dist/help/{json/bootstrap.md → bootstrap.pwsh.md} +216 -397
- package/dist/help/docs/dsl.md +4 -3
- package/dist/help/docs/file.move.md +46 -0
- package/dist/help/docs/file.rename.md +35 -0
- package/dist/help/docs/help-format.md +4 -7
- package/dist/help/docs/inspect.code.md +5 -5
- package/dist/help/docs/inspect.deps.md +7 -7
- package/dist/help/docs/inspect.file.md +2 -1
- package/dist/help/docs/inspect.graph.md +3 -3
- package/dist/help/docs/inspect.md +5 -5
- package/dist/help/docs/mutation.md +23 -13
- package/dist/help/docs/patterns.md +1 -5
- package/dist/help/docs/qr.md +7 -22
- package/dist/help/docs/quick-map.md +1 -0
- package/dist/help/docs/recipe.file-layout.md +15 -0
- package/dist/help/docs/rg.md +22 -0
- package/dist/help/docs/selectors.md +3 -2
- package/dist/help/docs/session.md +1 -1
- package/dist/help/dsl/bootstrap.bash.md +907 -0
- package/dist/help/dsl/bootstrap.md +105 -144
- package/dist/help/{json/full.md → dsl/bootstrap.pwsh.md} +216 -397
- package/dist/help/dsl/docs/dsl.md +4 -3
- package/dist/help/dsl/docs/file.move.md +46 -0
- package/dist/help/dsl/docs/file.rename.md +35 -0
- package/dist/help/dsl/docs/help-format.md +4 -7
- package/dist/help/dsl/docs/inspect.code.md +5 -5
- package/dist/help/dsl/docs/inspect.deps.md +7 -7
- package/dist/help/dsl/docs/inspect.file.md +2 -1
- package/dist/help/dsl/docs/inspect.graph.md +3 -3
- package/dist/help/dsl/docs/inspect.md +5 -5
- package/dist/help/dsl/docs/mutation.md +23 -13
- package/dist/help/dsl/docs/patterns.md +1 -5
- package/dist/help/dsl/docs/qr.md +7 -22
- package/dist/help/dsl/docs/quick-map.md +1 -0
- package/dist/help/dsl/docs/recipe.file-layout.md +15 -0
- package/dist/help/dsl/docs/rg.md +22 -0
- package/dist/help/dsl/docs/selectors.md +3 -2
- package/dist/help/dsl/docs/session.md +1 -1
- package/dist/help/dsl/full.md +105 -144
- package/dist/help/dsl/help-index.md +44 -0
- package/dist/help/dsl/tokens/qr.inline.examples.md +2 -0
- package/dist/help/dsl/tokens/stdin.examples.bash.md +8 -0
- package/dist/help/dsl/tokens/stdin.examples.pwsh.md +8 -0
- package/dist/help/dsl/tokens/stdin.examples.with-qr.bash.md +12 -0
- package/dist/help/dsl/tokens/stdin.examples.with-qr.pwsh.md +12 -0
- package/dist/help/dsl/topics/dsl.md +4 -3
- package/dist/help/dsl/topics/file.move.md +44 -0
- package/dist/help/dsl/topics/file.rename.md +33 -0
- package/dist/help/dsl/topics/help-format.md +4 -7
- package/dist/help/dsl/topics/inspect.code.md +5 -5
- package/dist/help/dsl/topics/inspect.deps.md +7 -7
- package/dist/help/dsl/topics/inspect.file.md +2 -1
- package/dist/help/dsl/topics/inspect.graph.md +3 -3
- package/dist/help/dsl/topics/inspect.md +5 -5
- package/dist/help/dsl/topics/mutation.md +23 -13
- package/dist/help/dsl/topics/patterns.md +1 -5
- package/dist/help/dsl/topics/qr.md +7 -22
- package/dist/help/dsl/topics/quick-map.md +1 -0
- package/dist/help/dsl/topics/recipe.file-layout.md +13 -0
- package/dist/help/dsl/topics/rg.md +20 -0
- package/dist/help/dsl/topics/selectors.md +3 -2
- package/dist/help/dsl/topics/session.md +1 -1
- package/dist/help/full.md +105 -144
- package/dist/help/help-index.md +44 -0
- package/dist/help/help-meta.json +45 -29
- package/dist/help/index.md +32 -75
- package/dist/help/tokens/qr.inline.examples.md +2 -0
- package/dist/help/tokens/stdin.examples.bash.md +8 -0
- package/dist/help/tokens/stdin.examples.pwsh.md +8 -0
- package/dist/help/tokens/stdin.examples.with-qr.bash.md +12 -0
- package/dist/help/tokens/stdin.examples.with-qr.pwsh.md +12 -0
- package/dist/help/topics/dsl.md +4 -3
- package/dist/help/topics/file.move.md +44 -0
- package/dist/help/topics/file.rename.md +33 -0
- package/dist/help/topics/help-format.md +4 -7
- package/dist/help/topics/inspect.code.md +5 -5
- package/dist/help/topics/inspect.deps.md +7 -7
- package/dist/help/topics/inspect.file.md +2 -1
- package/dist/help/topics/inspect.graph.md +3 -3
- package/dist/help/topics/inspect.md +5 -5
- package/dist/help/topics/mutation.md +23 -13
- package/dist/help/topics/patterns.md +1 -5
- package/dist/help/topics/qr.md +7 -22
- package/dist/help/topics/quick-map.md +1 -0
- package/dist/help/topics/recipe.file-layout.md +13 -0
- package/dist/help/topics/rg.md +20 -0
- package/dist/help/topics/selectors.md +3 -2
- package/dist/help/topics/session.md +1 -1
- package/dist/host/capabilities.js +1 -0
- package/dist/ide-launch/common.cjs +162 -162
- package/dist/managed-host/extension-vsix-resolver.js +1 -1
- package/dist/managed-host/manage-serve-web-host.cjs +141 -141
- package/dist/managed-host/serve-web-autostart.js +1 -1
- package/dist/managed-host/serve-web-host.cjs +1985 -1660
- package/dist/observability/config.js +1 -1
- package/dist/payloads/read-stdin-json.js +1 -1
- package/dist/rg-wrapper/core.js +6 -0
- package/dist/rg-wrapper/options.js +1 -0
- package/dist/rtk-wrapper/core.js +2 -0
- package/dist/runtime/input-source.js +1 -1
- package/dist/runtime/managed-runtime-provisioning.js +1 -1
- package/dist/runtime/run-command.js +1 -1
- package/dist/selectors/parse-entities.js +1 -1
- package/dist/session/daemon-state.js +2 -0
- package/dist/session/server.js +7 -6
- package/dist/shared/errors.js +14 -13
- package/dist/shared/operations.js +1 -1
- package/dist/shared/protocol.js +1 -1
- package/dist/shared/routes.js +1 -1
- package/dist/shared/stdin-examples.js +1 -0
- package/dist/shared/types.js +1 -1
- package/dist/tool-runtime/runtime-tools.js +1 -0
- package/dist/tracing/trace.js +5 -3
- package/dist/workers/control-plane/aib-control-plane-worker.cjs +80 -0
- package/dist/workers/control-plane/client-config.default.json +3 -0
- package/dist/workers/product-storage.js +1 -0
- package/dist/workers/registry.js +1 -0
- package/extension/vscode-refactor-bridge-extension.vsix +0 -0
- package/package.json +6 -4
- package/runtimes/launcher/linux-x64/aib +0 -0
- package/runtimes/launcher/win-x64/aib.exe +0 -0
- package/runtimes/tools/rg/darwin-arm64/rg +0 -0
- package/runtimes/tools/rg/darwin-x64/rg +0 -0
- package/runtimes/tools/rg/linux-arm64/rg +0 -0
- package/runtimes/tools/rg/linux-x64/rg +0 -0
- package/runtimes/tools/rg/manifest.json +36 -0
- package/runtimes/tools/rg/win32-x64/rg.exe +0 -0
- package/runtimes/tools/rtk/darwin-arm64/rtk +0 -0
- package/runtimes/tools/rtk/darwin-x64/rtk +0 -0
- package/runtimes/tools/rtk/linux-arm64/rtk +0 -0
- package/runtimes/tools/rtk/linux-x64/rtk +0 -0
- package/runtimes/tools/rtk/manifest.json +36 -0
- package/runtimes/tools/rtk/win32-x64/rtk.exe +0 -0
- package/scripts/provision-runtime.cjs +25 -1
- package/dist/help/json/docs/basics.md +0 -15
- package/dist/help/json/docs/config-setup.aliases.md +0 -56
- package/dist/help/json/docs/config-setup.excludes.md +0 -45
- package/dist/help/json/docs/config-setup.import-normalize.md +0 -86
- package/dist/help/json/docs/config-setup.import-rules.md +0 -96
- package/dist/help/json/docs/config-setup.tsconfigs.md +0 -33
- package/dist/help/json/docs/dsl.md +0 -25
- package/dist/help/json/docs/first-setup.md +0 -292
- package/dist/help/json/docs/help-format.md +0 -12
- package/dist/help/json/docs/help-protocol.md +0 -26
- package/dist/help/json/docs/imports.normalize.md +0 -47
- package/dist/help/json/docs/inspect.code.md +0 -41
- package/dist/help/json/docs/inspect.cycles.md +0 -38
- package/dist/help/json/docs/inspect.deps.md +0 -46
- package/dist/help/json/docs/inspect.duplicates.md +0 -65
- package/dist/help/json/docs/inspect.exports.md +0 -40
- package/dist/help/json/docs/inspect.file.md +0 -38
- package/dist/help/json/docs/inspect.graph.md +0 -139
- package/dist/help/json/docs/inspect.imports.md +0 -15
- package/dist/help/json/docs/inspect.md +0 -88
- package/dist/help/json/docs/inspect.members.md +0 -32
- package/dist/help/json/docs/inspect.tree.md +0 -32
- package/dist/help/json/docs/inspect.usages.md +0 -61
- package/dist/help/json/docs/modulePlan.md +0 -73
- package/dist/help/json/docs/move.md +0 -56
- package/dist/help/json/docs/mutation.md +0 -65
- package/dist/help/json/docs/patterns.md +0 -76
- package/dist/help/json/docs/prefs.md +0 -40
- package/dist/help/json/docs/qr.md +0 -37
- package/dist/help/json/docs/quick-map.md +0 -30
- package/dist/help/json/docs/refactor.batch.md +0 -72
- package/dist/help/json/docs/rename.md +0 -47
- package/dist/help/json/docs/reveal.md +0 -30
- package/dist/help/json/docs/selectors.md +0 -23
- package/dist/help/json/docs/session.md +0 -77
- package/dist/help/json/docs/view.md +0 -30
- package/dist/help/json/snippets/agents.md +0 -14
- package/dist/help/json/topics/basics.md +0 -13
- package/dist/help/json/topics/config-setup.aliases.md +0 -54
- package/dist/help/json/topics/config-setup.excludes.md +0 -43
- package/dist/help/json/topics/config-setup.import-normalize.md +0 -84
- package/dist/help/json/topics/config-setup.import-rules.md +0 -94
- package/dist/help/json/topics/config-setup.tsconfigs.md +0 -31
- package/dist/help/json/topics/dsl.md +0 -23
- package/dist/help/json/topics/first-setup.md +0 -290
- package/dist/help/json/topics/help-format.md +0 -10
- package/dist/help/json/topics/help-protocol.md +0 -24
- package/dist/help/json/topics/imports.normalize.md +0 -45
- package/dist/help/json/topics/inspect.code.md +0 -39
- package/dist/help/json/topics/inspect.cycles.md +0 -36
- package/dist/help/json/topics/inspect.deps.md +0 -44
- package/dist/help/json/topics/inspect.duplicates.md +0 -37
- package/dist/help/json/topics/inspect.exports.md +0 -38
- package/dist/help/json/topics/inspect.file.md +0 -36
- package/dist/help/json/topics/inspect.graph.md +0 -137
- package/dist/help/json/topics/inspect.imports.md +0 -13
- package/dist/help/json/topics/inspect.md +0 -86
- package/dist/help/json/topics/inspect.members.md +0 -30
- package/dist/help/json/topics/inspect.tree.md +0 -22
- package/dist/help/json/topics/inspect.usages.md +0 -59
- package/dist/help/json/topics/modulePlan.md +0 -60
- package/dist/help/json/topics/move.md +0 -46
- package/dist/help/json/topics/mutation.md +0 -63
- package/dist/help/json/topics/patterns.md +0 -74
- package/dist/help/json/topics/prefs.md +0 -38
- package/dist/help/json/topics/qr.md +0 -35
- package/dist/help/json/topics/quick-map.md +0 -28
- package/dist/help/json/topics/refactor.batch.md +0 -61
- package/dist/help/json/topics/rename.md +0 -42
- package/dist/help/json/topics/reveal.md +0 -28
- package/dist/help/json/topics/selectors.md +0 -21
- package/dist/help/json/topics/session.md +0 -59
- package/dist/help/json/topics/view.md +0 -28
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`).trim()})}).filter(
|
|
3
|
-
`):null}function
|
|
4
|
-
`):null}function
|
|
5
|
-
`)}function
|
|
6
|
-
`)}const t=[`usages ${
|
|
1
|
+
"use strict";var at=exports&&exports.__createBinding||(Object.create?(function(e,n,t,r){r===void 0&&(r=t);var s=Object.getOwnPropertyDescriptor(n,t);(!s||("get"in s?!n.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return n[t]}}),Object.defineProperty(e,r,s)}):(function(e,n,t,r){r===void 0&&(r=t),e[r]=n[t]})),ut=exports&&exports.__setModuleDefault||(Object.create?(function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}):function(e,n){e.default=n}),ve=exports&&exports.__importStar||(function(){var e=function(n){return e=Object.getOwnPropertyNames||function(t){var r=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[r.length]=s);return r},e(n)};return function(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var r=e(n),s=0;s<r.length;s++)r[s]!=="default"&&at(t,n,r[s]);return ut(t,n),t}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.parseInspectSelector=St,exports.formatInspectResponse=Ct,exports.formatInspectMixedAgentText=Ft;const b=ve(require("node:path")),U=ve(require("node:fs")),lt=require("node:crypto"),$=require("./session-workspace"),xe=require("../shared/agent-text"),pt=require("../shared/types"),dt=require("./inspect-graph"),yt=require("./inspect-imports"),gt=require("./inspect-tree"),mt=require("./inspect-cycles"),ht=require("../config/path-display"),At=["class","interface","function","type","enum","namespace","variable","method","property","constructor","runtime","export"],vt=500,xt=500,K=10,R=12,$t=12,bt=8;function St(e,n){const t=e.trim();return t==="constructor"?{raw:t,symbolName:"constructor",symbolKind:"constructor"}:ye(t,n.selectorSeparator,n)??ye(t,":",n)??ye(t,"-",n)??{raw:t,symbolName:t,symbolKind:null}}function Ct(e,n,t){const r=Array.isArray(e.results)?e.results:[],s=It(t),i=mr(r,t),o=r.map((u,p)=>Fe(u,n,ee(s,p),i));Pt(r,o,s,i),kt(r,o,s,n,i),Ot(r,o,s,n);const f=o.filter(u=>l(u)&&u.ok===!1).length;if(s.bundleSave)return Mt(r,o,n,s,i,f);const a=f===0&&s.forceResults!==!0?_t(r,o,n,i,s):null;if(a)return z(a),(0,xe.attachAgentText)(a,be(r,a,s,i));const c={results:o};return i&&(c.file=i),(f>0||e.ok===!1)&&(c.ok=!1,c.summary={requestCount:o.length,failedCount:f}),z(c),(0,xe.attachAgentText)(c,be(r,c,s,i))}function z(e){if(Array.isArray(e)){for(const n of e)z(n);return}if(l(e)){for(const n of["symbols","exports","members"])ne(e,n);for(const n of Object.values(e))z(n)}}function kt(e,n,t,r,s){for(let i=0;i<n.length;i+=1){const o=e[i],f=n[i];if(!l(o)||!f||o.op!=="members"||g(o.hiddenMemberCount)<=0)continue;const a=fe(o.hiddenMembers,r,ee(t,i),"members").filter(m=>typeof m=="string"&&m!=="");if(a.length===0)continue;const c=typeof f.file=="string"?f.file:s??"",u=typeof f.entity=="string"?f.entity:N(o.entity,r),p=I({version:1,kind:"members",source:"inspect",file:c,entity:u,items:a.map(m=>I({text:m}))}),d=(0,$.saveSessionResultViewJson)(t.cwd,W(p),p);d&&(f.view=d.saved)}}function Ot(e,n,t,r){for(let s=0;s<n.length;s+=1){const i=e[s],o=n[s];if(!l(i)||!o||i.op!=="duplicates"||g(i.hiddenItemCount)<=0)continue;const f=Array.isArray(i.hiddenDuplicateItems)?i.hiddenDuplicateItems.filter(l):Array.isArray(i.hiddenItems)?i.hiddenItems.filter(l):[];if(f.length===0)continue;const a=tt(),c=typeof i.detail=="string"?i.detail:"locations",u=f.map(m=>{const h=je(m,r,ee(t,s),a);return I({name:typeof h.name=="string"?h.name:"",text:Ge(h,c).join(`
|
|
2
|
+
`).trim()})}).filter(m=>typeof m.text=="string"&&m.text!=="");if(u.length===0)continue;const p=I({version:1,kind:"duplicates",source:"inspect",detail:c,target:typeof o.target=="string"?o.target:"",items:u}),d=(0,$.saveSessionResultViewJson)(t.cwd,W(p),p);d&&(o.view=d.saved)}}function ee(e,n){const t=e.toFiles?.[n],r=e.saves?.[n],s=e.shows?.[n],i=e.ranges?.[n],o=e.parentNames?.[n];if(t===void 0&&r===void 0&&s===void 0&&i===void 0&&o===void 0)return e;const f={...e};return delete f.toFiles,delete f.toFile,delete f.saves,delete f.save,delete f.shows,delete f.ranges,delete f.parentNames,delete f.parentName,t&&(f.toFile=t),r&&!e.sharedSaves?.has(r)&&(f.save=r),s!==void 0&&(f.show=s),i!==void 0&&(f.includeRanges=i),o&&(f.parentName=o),f}function It(e){if(!e.saves||e.saves.length<2)return e;const n=new Map;for(const r of e.saves)r&&n.set(r,(n.get(r)??0)+1);const t=new Set(Array.from(n.entries()).filter(([,r])=>r>1).map(([r])=>r));return t.size>0?{...e,sharedSaves:t}:e}function Mt(e,n,t,r,s,i){const o=r.bundleSave;if(!o)throw new Error("bundleSave is required for inspect bundle output.");const f={...r,maxCodeLines:Number.MAX_SAFE_INTEGER};delete f.toFile,delete f.toFiles,delete f.save,delete f.saves,delete f.bundleSave;const a=e.map((h,v)=>{const y=Fe(h,t,f,s),x=n[v]?.saved;return typeof x=="string"&&(y.saved=x),delete y.next,delete y.last,y}),c=Et(a,s),u=(0,$.saveSessionOutputJson)(r.cwd,"inspect",o,c),p={saved:u.saved,last:u.last,items:a.length},d=n.map(h=>typeof h.saved=="string"?h.saved:"").filter(h=>h!=="");d.length>0&&(p.savedRows=d),i>0&&(p.ok=!1,p.summary={requestCount:a.length,failedCount:i});const m=(0,$.useSessionGuidance)(r.cwd,"inspect.bundle.read",`Read bundle with: aib session read ${u.saved}`);return m&&(p.next=m),p}function Et(e,n){const t={source:"inspect.bundle"};n&&(t.file=n);const r=e.map(o=>({...o})),s=$e(r,"op"),i=$e(r,"parent");return s&&(t.op=s,te(r,"op")),i&&(t.parent=i,te(r,"parent")),n&&te(r,"file"),t.items=r,t}function $e(e,n){const t=e.map(s=>s[n]).filter(s=>typeof s=="string"&&s!=="");if(t.length!==e.length||t.length===0)return null;const[r]=t;return t.every(s=>s===r)?r??null:null}function te(e,n){for(const t of e)delete t[n]}function _t(e,n,t,r,s){if(e.length===0||n.length===0)return null;const i=e.filter(l);if(i.length!==e.length||i.some(a=>a.ok===!1))return null;const o=Array.from(new Set(i.map(a=>typeof a.op=="string"?a.op:"")));if(o.length!==1)return{results:n.map(a=>O(a,{omitOp:!1,commonFile:r}))};const f=o[0];if(f==="modulePlan")return null;if(f==="usages")return e.length===1?O(n[0],{omitOp:!0,omitFile:!0}):{results:n.map(a=>O(a,{omitOp:!0,commonFile:r}))};if(e.length===1)return O(n[0],{omitOp:!0,omitFile:!0});if(f==="dependencies"){if(r){const a={};for(const c of i){const u=pe(c.entity);if(!u)return null;a[u]=In(c,t)}return{file:r,deps:a}}return{results:n.map(a=>O(a,{omitOp:!0,commonFile:r}))}}if(f==="members"){if(r){const a={};for(const c of n){const u=typeof c.entity=="string"?c.entity:"";if(!u||!Array.isArray(c.members))return null;a[u]=Lt(c)}return{file:r,members:a}}return{results:n.map(a=>O(a,{omitOp:!0,commonFile:r}))}}if(f==="code"||f==="slice"){const a=n.map(d=>O(d,{omitOp:!0,commonFile:r})),c={items:a};r&&(c.file=r);const u=sn(f,e,s,t);if(u.length===1?c.saved=u[0].saved:u.length>1&&(c.saved=u.map(d=>d.saved)),u.length>0){const d=u.length===1?u[0].saved:"--stdin",m=(0,$.useSessionGuidance)(s.cwd,`inspect.${f}.read`,`Read saved artifact with: aib session read ${d}`);m&&(c.next=m)}if(Tt(a).length>1){for(const d of a)delete d.next;c.next="Read saved artifacts with: aib session read --stdin"}return c}return{results:n.map(a=>O(a,{omitOp:!0,commonFile:r}))}}function O(e,n){const t={...e};return n.omitOp?delete t.op:t.op==="dependencies"&&(t.op="deps"),(n.omitFile||typeof t.file=="string"&&t.file===n.commonFile)&&delete t.file,delete t.last,typeof t.entity=="string"&&(t.entity=Qe(t.entity)),typeof t.count=="number"&&t.count<=K&&typeof t.page!="string"&&typeof t.hint!="string"&&delete t.count,ne(t,"symbols"),ne(t,"exports"),t}function ne(e,n){Array.isArray(e[n])&&(e[n]=e[n].filter(t=>typeof t=="string").map(t=>V(t)))}function Lt(e){const n={};return typeof e.count=="number"&&e.count>K&&(n.count=e.count),Array.isArray(e.members)&&(n.members=e.members),typeof e.hint=="string"&&(n.hint=e.hint),typeof e.page=="string"&&(n.page=e.page),n}function Tt(e){return e.map(n=>typeof n.saved=="string"?n.saved:"").filter(n=>n!=="")}function Pt(e,n,t,r){const s=new Map;for(let c=0;c<n.length;c+=1){const u=n[c],p=e[c];if(!u||!l(p)||!G(u))continue;const d=typeof p.op=="string"?p.op:"code";if(d!=="code"&&d!=="slice")continue;const m=re(u,t,e,c),h=typeof u.file=="string"?u.file:r??"",v=[d,m,h,t.parentNames?.[c]??t.parentName??""].join("\0"),y=s.get(v)??[];y.push({raw:p,result:u,index:c}),s.set(v,y)}for(const c of s.values()){const u=c.map(({raw:h,result:v,index:y})=>{const x=typeof h.code=="string"?h.code:"",_=typeof v.rangeMeta=="string"?v.rangeMeta:typeof v.meta=="string"?v.meta:"",D=typeof v.file=="string"?v.file:r??"",F=typeof v.entity=="string"?v.entity:typeof h.entity=="string"?h.entity:"";return I({file:D,entity:F,meta:_,code:x,nonEmptyLines:typeof v.nonEmptyLines=="number"?v.nonEmptyLines:oe(x),lineCount:x===""?g(h.lineCount):x.split(/\r?\n/).length,parent:t.parentNames?.[y]??t.parentName})});if(u.length===0)continue;const p=I({version:1,kind:"code",source:"inspect",items:u}),d=W(p),m=(0,$.saveSessionResultViewJson)(t.cwd,d,p);if(m)for(const h of c)h.result.view=m.saved}if(new Set(Array.from(s.values()).flatMap(c=>c.map(u=>typeof u.result.view=="string"?u.result.view:"")).filter(c=>c!=="")).size<=1)return;const o=Array.from(s.values()).flatMap(c=>c.map(u=>Dt(u.raw,u.result,u.index,t,r))),f=I({version:1,kind:"code",source:"inspect",items:o}),a=(0,$.saveSessionResultViewJson)(t.cwd,W(f),f);if(a)for(const c of s.values())for(const u of c)u.result.viewAllCode=a.saved}function Dt(e,n,t,r,s){const i=typeof e.code=="string"?e.code:"",o=typeof n.rangeMeta=="string"?n.rangeMeta:typeof n.meta=="string"?n.meta:"",f=typeof n.file=="string"?n.file:s??"",a=typeof n.entity=="string"?n.entity:typeof e.entity=="string"?e.entity:"";return I({file:f,entity:a,meta:o,code:i,nonEmptyLines:typeof n.nonEmptyLines=="number"?n.nonEmptyLines:oe(i),lineCount:i===""?g(e.lineCount):i.split(/\r?\n/).length,parent:r.parentNames?.[t]??r.parentName})}function W(e){return`res_${(0,lt.createHash)("sha256").update(JSON.stringify(e)).digest("hex").slice(0,8)}`}function I(e){const n={};for(const[t,r]of Object.entries(e))r!==void 0&&r!==""&&(n[t]=r);return n}function be(e,n,t,r){if(k(e,"file"))return Pe(n,"symbols",r);if(k(e,"exports"))return Pe(n,"exports",r);if(k(e,"members"))return Rt(n,r);if(k(e,"dependencies"))return en(n,r);if(k(e,"modulePlan"))return Yt(n);if(k(e,"usages"))return Ne(n);if(k(e,"duplicates"))return Ue(n);if(k(e,"directoryFallback"))return Oe(n);if(!k(e,"code"))return Se(n,r);const s=nn(n);if(s.length!==e.length||s.length===0||s.some(y=>typeof y.code!="string"&&typeof y.meta!="string"&&!j(y)&&!G(y)&&!se(y)))return null;const i=[],o=n.saved,f=s.some((y,x)=>re(y,t,e,x)!=="");if(!f&&typeof o=="string")i.push(`// ${o}`);else if(!f&&Array.isArray(o))for(const y of o)typeof y=="string"&&i.push(`// ${y}`);let a="",c="",u="",p=[],d=[];const m=l(e[0])&&typeof e[0].op=="string"?e[0].op:"code",h=()=>{Te(i,d,m),d=[]},v=()=>{p.length!==0&&(h(),i.push("// code:"),i.push(`not found symbols: ${p.join(", ")}`),p=[])};return s.forEach((y,x)=>{const _=l(e[x])?e[x]:{},D=re(y,t,e,x);D&&D!==u&&(v(),h(),M(i),i.push(`// ${D}`),u=D,a="",c="");const F=rn(y,_,t,r);if(F&&F!==a&&(v(),h(),i.push(`// ${F}`),a=F,c=""),j(y)){p.push(...E(y));return}v();const B=t.parentNames?.[x]??t.parentName??"";if(B&&B!==c?(h(),i.push(`// ${B}:`),c=B):B||(c=""),G(y)){d.push(y);return}const me=t.ranges?.[x]??t.includeRanges;if(t.codeMeta!==!1&&me&&typeof y.meta=="string"&&y.meta!=="")i.push(`// ${y.meta}`);else if(t.codeMeta!==!1&&me){const he=typeof y.code=="string"?y.code:"",ct=he===""?g(_.lineCount):he.split(/\r?\n/).length,Ae=P(_.entity,ct);Ae&&i.push(`// ${Ae}`)}typeof y.code=="string"?i.push(y.code.trimEnd()):se(y)&&Le(i,y)}),h(),v(),ke(i,s,!1),i.length>0?i.join(`
|
|
3
|
+
`):null}function re(e,n,t,r){if(typeof e.saved=="string"&&e.saved!=="")return e.saved;const s=n.saves?.[r];if(typeof s!="string"||s==="")return"";const i=l(t[r])?t[r]:{};return`aib:${typeof i.op=="string"&&i.op!==""?i.op==="dependencies"?"deps":i.op:"inspect"}:${s}`}function Ft(e,n=null){return Se(e,n)}function Se(e,n){if(!Array.isArray(e.results))return null;const t=[],r=Y(t);let s=[];const i=()=>{s.length!==0&&(M(t),t.push("// code:"),t.push(`not found symbols: ${s.join(", ")}`),s=[])},o=c=>{i(),M(t),r(typeof c.file=="string"?c.file:n??"")},f=e.results.filter(l),a=f.filter(c=>c.op==="runtimeFailure");a.length>0&&t.push("partial: runtime skipped");for(let c=0;c<f.length;c+=1){const u=f[c];if(!l(u))return null;const p=typeof u.op=="string"?u.op:"";if((p==="code"||p==="slice")&&j(u)){s.push(...E(u));continue}if(i(),p==="file")o(u),Ee(t,"file:",u.symbols),_e(t,u);else if(p==="exports")o(u),Ee(t,"exports:",u.exports);else if(p==="members")o(u),J(t,`members ${typeof u.entity=="string"?u.entity:""}`.trim(),u);else if(p==="deps"||p==="dependencies"){o(u);const d=[];for(;c<f.length;){const m=f[c],h=typeof m.op=="string"?m.op:"";if(h!=="deps"&&h!=="dependencies"){c-=1;break}d.push({entity:typeof m.entity=="string"?m.entity:"",missingSymbols:E(m),type:m.depsType,value:m.depsValue,unknown:m.depsUnknown}),c+=1}c>=f.length&&(c-=1),Z(t,d)}else if(p==="code"||p==="slice"){o(u);const d=[],m=typeof u.file=="string"?u.file:n??"";for(;c<f.length;){const h=f[c],v=typeof h.op=="string"?h.op:"",y=typeof h.file=="string"?h.file:n??"";if(v!==p||y!==m||j(h)){c-=1;break}d.push(h),c+=1}c>=f.length&&(c-=1),Xt(t,p,d)}else if(p==="graph")o(u),Gt(t,u);else if(p==="imports")(0,yt.appendImportsBlock)(t,u);else if(p==="tree")o(u),Ce(t,(0,gt.formatTreeResponse)(u));else if(p==="cycles")o(u),Ce(t,(0,mt.formatCyclesResponse)(u));else{if(p==="runtimeFailure")continue;if(p==="usages")o(u),Vt(t,u);else if(p==="duplicates")o(u),Jt(t,u);else if(p==="directoryFallback")o(u),Ht(t,u);else return null}}return i(),jt(t,a),ke(t,f,!0),t.length>0?t.join(`
|
|
4
|
+
`):null}function Ce(e,n){n&&e.push(...n.split(/\r?\n/))}function jt(e,n){if(n.length!==0){M(e),e.push("runtime skipped:");for(const t of Nt(n))e.push(t);e.push(`skipped ops: ${Bt(n)}`)}}function Nt(e){return Array.from(new Set(e.map(n=>{const t=typeof n.code=="string"?n.code:"RUNTIME_INSPECT_FAILED",r=typeof n.error=="string"?n.error:"runtime-backed inspect failed";return`${t}: ${r}`})))}function Bt(e){const n=new Map;for(const t of e){const r=Ut(typeof t.requestedOp=="string"?t.requestedOp:"inspect");n.set(r,(n.get(r)??0)+1)}return Array.from(n.entries()).map(([t,r])=>r>1?`${t} x${r}`:t).join(", ")}function Ut(e){return e==="dependencies"?"deps":e}function ke(e,n,t){const r=Array.from(new Set(n.map(s=>typeof s.viewAllCode=="string"?s.viewAllCode:"").filter(s=>s!=="")));if(r.length!==0){if(M(e),t){e.push("view all:"),e.push(`code: ${r[0]}`);return}e.push(`view all code: ${r[0]}`)}}function Gt(e,n){const t=(0,dt.formatGraphAgentText)({...n,operation:"inspect.graph"});t&&(e.push("// graph:"),e.push(...t.split(/\r?\n/).filter(r=>r!=="inspect.graph")))}function Ht(e,n){const t=Oe(n);t&&e.push(...t.split(/\r?\n/))}function Oe(e){const n=qt(Array.isArray(e.lines)?e.lines.filter(i=>typeof i=="string").filter((i,o)=>o!==0||!i.startsWith("tree ")):[]);if(n.length===0)return null;const t=typeof e.directory=="string"?e.directory:"directory",r=Array.isArray(e.skippedOps)?e.skippedOps.filter(i=>typeof i=="string"):[],s=[`inspect expected file, got directory: ${t}`];return r.length>0&&(s.push(""),s.push("Skipped file-based operations:"),s.push(r.join(", "))),typeof e.command=="string"&&e.command!==""&&(s.push(""),s.push("Showing tree instead:"),s.push(e.command)),s.push(""),s.push(...n),s.join(`
|
|
5
|
+
`)}function qt(e){let n=0;for(;n<e.length&&e[n]==="";)n+=1;return e.slice(n)}function Vt(e,n){const t=typeof n.detail=="string"?n.detail:"",r=t==="locations"||t==="code"?Kt(n):Ne(n);r&&e.push(...r.split(/\r?\n/))}function Kt(e){const n=typeof e.detail=="string"?e.detail:"detail";if(g(e.referenceCount)===0){const s=typeof e.target=="string"?e.target:"",i=typeof e.scopeLabel=="string"?e.scopeLabel:"project",o=[s?`usages ${s}`:"usages",`0 refs in ${i}`];return X(o,e),o.join(`
|
|
6
|
+
`)}const t=[`usages ${n}`];X(t,e),n==="code"?Wt(t,e):zt(t,e),Ve(t,e,Array.isArray(e.items)?e.items.filter(l):[]);const r=typeof e.view=="string"?e.view:"";return r&&(M(t),t.push(`view: ${r}`)),t.join(`
|
|
7
7
|
`).replace(/\n{3,}/g,`
|
|
8
8
|
|
|
9
|
-
`).trimEnd()}function
|
|
10
|
-
`)}function
|
|
11
|
-
`):null}function
|
|
12
|
-
`):null}function
|
|
13
|
-
`):null}function
|
|
14
|
-
${p}`:p}).filter(
|
|
9
|
+
`).trimEnd()}function zt(e,n){const t=Array.isArray(n.items)?n.items.filter(l).filter(i=>g(i.referenceCount)>0):[];t.length>0&&M(e);const{ownerGroups:r,standalone:s}=ie(t);for(const[i,o]of r){e.push(""),e.push(`// ${i}:`);for(const f of o)e.push(...Ie(f,!1))}s.length>0&&r.length>0&&e.push("");for(const i of s)e.push(...Ie(i,!0))}function Ie(e,n){const t=typeof e.entity=="string"?e.entity:"",r=H(t),i=[`${n?t:r.name}: ${g(e.referenceCount)} refs`],o=Array.isArray(e.usedBy)?e.usedBy.filter(l):[];for(const f of o){const a=typeof f.file=="string"?f.file:"";a&&i.push(`${a}:`);const c=Array.isArray(f.locations)?f.locations.filter(l):[];for(const u of c){const p=typeof u.line=="number"?` l${u.line}`:"",d=typeof u.container=="string"?u.container:"";i.push(`${d}${p}`.trim())}}return typeof e.hidden=="string"&&i.push(e.hidden),i}function Wt(e,n){const t=Array.isArray(n.blocks)?n.blocks.filter(l):[];t.length>0&&M(e);const{ownerGroups:r,standalone:s}=ie(t);for(const[o,f]of r){e.push(`// ${o}:`);for(const[a,c]of Be(f,u=>H(typeof u.entity=="string"?u.entity:"").name)){a&&e.push(`// ${a}`);for(const u of c)e.push(...Me(u,!1,!1))}}s.length>0&&r.length>0&&e.push("");for(const[o,f]of Be(s,a=>typeof a.entity=="string"?a.entity:"")){o&&e.push(`// ${o}`);for(const a of f)e.push(...Me(a,!1,!1))}const i=Array.isArray(n.hiddenBlocks)?n.hiddenBlocks.filter(l):[];for(const o of i){const f=typeof o.entity=="string"?o.entity:"",a=typeof o.hidden=="string"?o.hidden:"";a&&e.push(f?`${f}: ${a}`:a)}}function Me(e,n,t=!0){const r=typeof e.entity=="string"?e.entity:"",s=H(r),i=n?r:s.name,o=[];t&&i&&o.push(`// ${i}`);const f=typeof e.file=="string"?e.file:"",a=typeof e.line=="number"?` l${e.line}`:"";if((f||a)&&o.push(`// ${f}${a}`.trim()),typeof e.code=="string")o.push(e.code.trimEnd());else if(l(e.omitted)){const c=typeof e.omitted.reason=="string"?e.omitted.reason:"omitted";o.push(`// ${c}`)}return o}function Jt(e,n){const t=Ue(n);t&&e.push(...t.split(/\r?\n/))}function Yt(e){const n=Array.isArray(e.results)?e.results.filter(l):l(e)?[e]:[];if(n.length===0)return null;const t=[];for(const r of n){const s=typeof r.operation=="string"?r.operation:"modulePlan.preview",i=typeof r.planId=="string"?r.planId:"";if(t.push(i?`${s} ${i}`:s),r.ok===!1&&typeof r.code=="string"&&t.push(`blocked: ${r.code}`),typeof r.summary=="string"&&t.push(r.summary),typeof r.integrity=="string"&&t.push(r.integrity),l(r.api)&&typeof r.api.status=="string"){const o=typeof r.api.before=="number"?r.api.before:null,f=typeof r.api.after=="number"?r.api.after:null;t.push(o!==null&&f!==null?`api: ${r.api.status} ${o}->${f}`:`api: ${r.api.status}`)}if(typeof r.cycles=="string"&&t.push(`cycles: ${r.cycles}`),Array.isArray(r.targets)&&r.targets.length>0){t.push("targets:");for(const o of r.targets.filter(l)){const f=typeof o.file=="string"?o.file:"",a=typeof o.summary=="string"?o.summary:"";f&&a&&t.push(`${f}: ${a}`)}}if(Array.isArray(r.blocking)&&r.blocking.length>0){t.push("blocking:");for(const o of r.blocking.filter(l)){const f=typeof o.code=="string"?o.code:"MODULE_PLAN_BLOCKING",a=Array.isArray(o.symbols)?o.symbols.filter(c=>typeof c=="string"):[];t.push(a.length>0?`${f}: ${a.join(", ")}`:f),Array.isArray(o.suggestedFixes)&&o.suggestedFixes.length>0&&t.push(`suggestedFixes: ${o.suggestedFixes.length}`)}}if(Array.isArray(r.remainingBlocking)&&r.remainingBlocking.length>0&&t.push(`remainingBlocking: ${r.remainingBlocking.length}`),Array.isArray(r.resolved)&&r.resolved.length>0&&t.push(`resolved: ${r.resolved.length}`),Array.isArray(r.changes)&&r.changes.length>0){t.push("changes:");for(const o of r.changes.filter(f=>typeof f=="string"))t.push(o)}l(r.preview)&&typeof r.preview.summary=="string"&&t.push(`preview: ${r.preview.summary}`),typeof r.next=="string"&&t.push(`next: ${r.next}`)}return t.join(`
|
|
10
|
+
`)}function Ee(e,n,t){const r=L(t);if(e.push(n),r.length===0){e.push(n==="exports:"?"no exports":"no top-level declarations");return}for(const s of r)e.push(s)}function _e(e,n){n.hasNonDeclarationText===!0&&e.push("file has non-declaration text")}function Zt(e,n,t){const r=typeof t.entity=="string"?t.entity:"";if(e.push(`// ${[n,r].filter(s=>s!=="").join(" ")}:`),j(t)){e.push(`not found symbols: ${E(t).join(", ")}`);return}typeof t.meta=="string"&&t.meta!==""&&e.push(`// ${t.meta}`),typeof t.saved=="string"&&t.saved!==""&&e.push(`saved: ${t.saved}`),typeof t.code=="string"?e.push(t.code.trimEnd()):G(t)?Qt(e,t):se(t)&&Le(e,t)}function Xt(e,n,t){const r=[];for(const s of t){if(G(s)){r.push(s);continue}Zt(e,n,s)}Te(e,r,n)}function se(e){return typeof e.saved=="string"&&e.saved!==""}function Le(e,n){e.push(`saved: ${n.saved}`),typeof n.next=="string"&&n.next!==""&&e.push(`next: ${n.next}`)}function G(e){return e.reason==="CODE_TOO_LARGE_FOR_STDOUT"||e.reason==="SLICE_TOO_LARGE_FOR_STDOUT"}function Qt(e,n){const t=typeof n.reason=="string"?n.reason:"CODE_TOO_LARGE_FOR_STDOUT",r=wt(n)??t;e.push(`code omitted: ${r}`),typeof n.hint=="string"&&n.hint!==""&&e.push(`hint: ${n.hint}`)}function Te(e,n,t){if(n.length===0)return;const r=t==="slice"?"slice":"code",s=Array.from(new Set(n.map(f=>typeof f.limit=="number"?f.limit:null).filter(f=>f!==null))),i=s.length===1?`; limit ${s[0]} NEL`:"";e.push(`// ${r} omitted${i}`);for(const f of n){const a=typeof f.entity=="string"&&f.entity!==""?f.entity:"unknown",c=typeof f.meta=="string"?f.meta:typeof f.rangeMeta=="string"?f.rangeMeta:"",u=typeof f.nonEmptyLines=="number"&&f.nonEmptyLines>0?f.nonEmptyLines:typeof f.lineCount=="number"&&f.lineCount>0?f.lineCount:0,p=u>0?`${u} NEL`:"";e.push(`// ${[a,c,p].filter(d=>d!=="").join(" ")}`)}const o=Array.from(new Set(n.map(f=>typeof f.view=="string"?f.view:"").filter(f=>f!=="")));for(const f of o)e.push(`view: ${f}`)}function wt(e){const n=typeof e.hint=="string"?e.hint:"";return/^(?:Code|Slice) is ([^.]+)\./.exec(n)?.[1]??null}function Pe(e,n,t){const r=[],s=Y(r);if(Array.isArray(e.results))for(const i of e.results)l(i)&&De(r,s,i,n,t);else De(r,s,e,n,t);return r.length>0?r.join(`
|
|
11
|
+
`):null}function De(e,n,t,r,s){n(typeof t.file=="string"?t.file:s??"");const i=L(t[r]).map(f=>V(f));if(i.length===0)e.push(`${r==="exports"?"exports":"file"}:`),e.push(r==="exports"?"no exports":"no top-level declarations");else for(const f of i)e.push(f);r==="symbols"&&_e(e,t),typeof t.summary=="string"&&e.push(`summary: ${t.summary}`);const o=L(t.reexports);o.length>0&&e.push(`reexports: ${o.join(", ")}`),typeof t.page=="string"&&e.push(`page: ${t.page}`),typeof t.hint=="string"&&e.push(`hint: ${t.hint}`)}function Rt(e,n){const t=[],r=Y(t);if(l(e.members)&&!Array.isArray(e.members)){r(typeof e.file=="string"?e.file:n??"");for(const[s,i]of Object.entries(e.members))l(i)&&J(t,s,i)}else if(Array.isArray(e.results))for(const s of e.results)l(s)&&(r(typeof s.file=="string"?s.file:n??""),J(t,typeof s.entity=="string"?s.entity:"",s));else r(typeof e.file=="string"?e.file:n??""),J(t,typeof e.entity=="string"?e.entity:"",e);return t.length>0?t.join(`
|
|
12
|
+
`):null}function J(e,n,t){if(j(t)){e.push("members:"),e.push(`not found symbols: ${E(t).join(", ")}`);return}const r=L(t.members);if(!(!n&&r.length===0)){if(n&&e.push(`// ${n}:`),r.length===0){e.push("no members");return}typeof t.count=="number"&&e.push(`// count: ${t.count}`),typeof t.page=="string"&&e.push(`// page: ${t.page}`);for(const s of r)e.push(s);typeof t.view=="string"&&e.push(`view: ${t.view}`)}}function en(e,n){const t=[],r=Y(t);if(l(e.deps)){r(typeof e.file=="string"?e.file:n??"");const s=[];for(const[i,o]of Object.entries(e.deps))l(o)&&s.push({entity:i,type:o.type,value:o.value,unknown:o.unknown});Z(t,s)}else if(Array.isArray(e.results)){const s=[];for(const i of e.results)l(i)&&(r(typeof i.file=="string"?i.file:n??""),s.push({entity:typeof i.entity=="string"?i.entity:"",missingSymbols:E(i),type:i.depsType,value:i.depsValue,unknown:i.depsUnknown}));Z(t,s)}else r(typeof e.file=="string"?e.file:n??""),Z(t,[{entity:typeof e.entity=="string"?e.entity:"",missingSymbols:E(e),type:e.depsType,value:e.depsValue,unknown:e.depsUnknown}]);return t.length>0?t.join(`
|
|
13
|
+
`):null}function M(e){e.length>0&&e[e.length-1]!==""&&e.push("")}function Y(e){let n="";return t=>{t&&t!==n&&(e.push(`// ${t}`),n=t)}}function Z(e,n){const t=[],r=[];let s=!1;for(const i of n){if(i.missingSymbols&&i.missingSymbols.length>0){r.push(...i.missingSymbols);continue}const o=L(i.type),f=L(i.value),a=L(i.unknown);if(o.length===0&&f.length===0&&a.length===0){i.entity&&t.push(i.entity);continue}s||(e.push("deps"),s=!0),tn(e,i.entity,{type:o,value:f,unknown:a})}t.length>0&&(s||(e.push("deps"),s=!0),e.push(`No deps for: ${t.join(", ")}`)),r.length>0&&(s||e.push("deps"),e.push(`not found symbols: ${r.join(", ")}`))}function tn(e,n,t){!n&&t.type.length===0&&t.value.length===0&&t.unknown.length===0||(n&&e.push(`${n}:`),t.type.length>0&&e.push(`type: ${t.type.join(", ")}`),t.value.length>0&&e.push(`value: ${t.value.join(", ")}`),t.unknown.length>0&&e.push(`unknown: ${t.unknown.join(", ")}`))}function L(e){return Array.isArray(e)?e.filter(n=>typeof n=="string"&&n!==""):[]}function k(e,n){return e.length>0&&e.every(t=>l(t)&&t.op===n)}function nn(e){return Array.isArray(e.items)?e.items.filter(l):Array.isArray(e.results)?e.results.filter(l):[e]}function rn(e,n,t,r){return typeof e.file=="string"&&e.file!==""?e.file:r||(typeof n.sourceFile=="string"&&n.sourceFile!==""?A(n.sourceFile,t):"")}function sn(e,n,t,r){if(e!=="code"&&e!=="slice")return[];const s=on(t.saves,t.sharedSaves,n.length);return s.length===0?[]:s.map(i=>{const o=n.map((c,u)=>({rawResult:c,save:t.saves?.[u]??null,includeRanges:t.ranges?.[u]??t.includeRanges})).filter(c=>c.save===i&&l(c.rawResult)).map(c=>({rawResult:c.rawResult,includeRanges:c.includeRanges})).map(({rawResult:c,includeRanges:u})=>{const p=typeof c.code=="string"?c.code:"",d=N(c.entity,r),m=p===""?g(c.lineCount):p.split(/\r?\n/).length,h=t.codeMeta===!1||!u?"":P(c.entity,m),v=[d,h].filter(y=>y!=="").join(" ");return v?`// ${v}
|
|
14
|
+
${p}`:p}).filter(c=>c!==""),f=fn(n),a=(0,$.saveSessionOutputText)(t.cwd,e,i,o.join(`
|
|
15
15
|
|
|
16
|
-
`),f);return{saved:
|
|
17
|
-
`)}function
|
|
18
|
-
`)}function on(e,r,t){if(!l(e))return[];const n=Object.entries(e).filter(s=>typeof s[1]=="string");return r!=="summary"?n:n.filter(([s])=>t.includes(s))}function fn(e,r,t){e.push(...je(r,t))}function je(e,r){const t=[],n=typeof e.name=="string"?e.name:"",s=y(e.count),i=y(e.variants),o=y(e.exactCopies);if(r!=="summary"&&t.push(""),t.push(`${n} x${s}, ${i} ${Ke(i,"variant")}${o>0?`, exact x${o}`:""}`),r==="summary")return t;const f=Array.isArray(e.groups)?e.groups.filter(l):[];if(r==="code")return f.forEach((c,a)=>cn(t,c,a+1)),t;for(const c of f){const u=(Array.isArray(c.declarations)?c.declarations.filter(l):[]).map(p=>Fe(p,!1));t.push(...ce(u))}return t}function cn(e,r,t){const n=Array.isArray(r.declarations)?r.declarations.filter(l):[],s=y(r.count);e.push(`// variant ${t} x${s}`);const i=ce(n.map(o=>Fe(o,!1)));i.length>0&&e.push(`// ${i.join(", ")}`),typeof r.code=="string"&&e.push(r.code.trimEnd())}function Fe(e,r){const t=typeof e.file=="string"?e.file:"",n=typeof e.meta=="string"?e.meta:"",s=r&&typeof e.sameAs=="string"&&e.sameAs!==""?` same as ${e.sameAs}`:"";return[t,n].filter(i=>i!=="").join(" ")+s}function Ne(e,r,t){const n=t.filter(s=>(typeof s.summary=="string"?s.summary:"").startsWith("0 refs")).map(s=>typeof s.entity=="string"?s.entity:"").filter(s=>s!=="");if(n.length!==0){if(r.queryMode==="explicit"){e.push(`unused: ${V(n,2,"more")}`);return}r.targetMode==="file"&&e.push(`unused symbols: ${n.length}`)}}function an(e){const r=[],t=e.filter(i=>!un(i)),{ownerGroups:n,standalone:s}=ne(t);for(const[i,o]of n){r.length>0&&r.push(""),r.push(`// ${i}:`);for(const f of o)r.push(...Be(f,!1))}s.length>0&&r.length>0&&r.push("");for(const i of s)r.push(...Be(i,!0));return r}function un(e){return typeof e.referenceCount=="number"?e.referenceCount===0:(typeof e.summary=="string"?e.summary:"").startsWith("0 refs")}function Be(e,r){const t=typeof e.entity=="string"?e.entity:"",n=H(t),s=r?t:n.name,i=typeof e.declaredIn=="string"?` [${e.declaredIn}]`:"",o=typeof e.summary=="string"?e.summary:"",f=[`${s}${i}: ${o}`.trim()],c=Array.isArray(e.usedBy)?e.usedBy.filter(a=>typeof a=="string"):[];return f.push(...c),f}function ne(e){const r=new Map,t=[];for(const n of e){const s=typeof n.entity=="string"?n.entity:"",i=H(s);if(!i.owner){t.push(n);continue}const o=r.get(i.owner)??[];o.push(n),r.set(i.owner,o)}return{ownerGroups:Array.from(r.entries()),standalone:t}}function H(e){const r=e.lastIndexOf(".");return r<=0||r>=e.length-1?{owner:null,name:e}:{owner:e.slice(0,r),name:e.slice(r+1)}}function ln(e,r,t,n){const s=typeof e.code=="string"?e.code:"",i=s===""?y(e.lineCount):s.split(/\r?\n/).length,o={...S(e,t,n),entity:F(e.entity,r)},f=L(e.entity,i);if(t.includeRanges&&f&&(o.meta=f),t.toFile){const c=et(t.cwd,t.toFile,s);if(o.writtenTo=c,!t.show)return o}if(t.save){const c=tt(t.cwd,"slice",t.save,e,s);o.saved=c.saved;const a=(0,x.useSessionGuidance)(t.cwd,"inspect.slice.read",`Read saved artifact with: aib session read ${c.saved}`);if(a&&(o.next=a),!t.show)return o}return t.show||i<=t.maxCodeLines?o.code=s:(o.reason="SLICE_TOO_LARGE_FOR_STDOUT",o.lineCount=i,o.limit=t.maxCodeLines,f&&(o.rangeMeta=f)),o}function pn(e,r,t,n){const s=typeof e.code=="string"?e.code:"",i=s===""?0:s.split(/\r?\n/).length,o=re(s),f={...S(e,t,n),entity:F(e.entity,r)},c=L(e.entity,i);if(t.codeMeta!==!1&&t.includeRanges&&c&&(f.meta=c),t.toFile){const a=et(t.cwd,t.toFile,s);if(f.writtenTo=a,!t.show)return f}if(t.save){const a=tt(t.cwd,"code",t.save,e,s);f.saved=a.saved;const u=(0,x.useSessionGuidance)(t.cwd,"inspect.code.read",`Read saved artifact with: aib session read ${a.saved}`);if(u&&(f.next=u),!t.show)return f}return t.show&&(o<=t.maxCodeLines?f.code=s:(f.reason="CODE_TOO_LARGE_FOR_STDOUT",f.nonEmptyLines=o,f.limit=t.maxCodeLines,c&&(f.rangeMeta=c))),f}function re(e){return e===""?0:e.split(/\r?\n/).filter(r=>r.trim()!=="").length}function dn(e){if(typeof e!="string"||e==="")return!1;try{return U.existsSync(e)&&U.statSync(e).isFile()&&U.readFileSync(e,"utf8").trim()!==""}catch{return!1}}function S(e,r,t){const n={op:typeof e.op=="string"?e.op:"unknown"};if(typeof e.id=="string"&&(n.id=e.id),typeof e.sourceFile=="string"){const s=h(e.sourceFile,r);s!==t&&(n.file=s)}return n}function se(e,r,t,n="generic"){return Array.isArray(e)?e.filter(l).map(s=>oe(s,r,t,n)):[]}function yn(e,r,t){if(!Array.isArray(e))return[];const n=e.filter(l);if(t.includeRanges)return n.map(f=>oe(f,r,t,"exports"));const s=[],i=new Map;for(const f of n){const c=oe(f,r,t,"exports"),a=typeof f.sourceModule=="string"?f.sourceModule:"";if(!a){s.push(c);continue}const u=c.replace(` from ${a}`,""),p=i.get(a)??[];p.push(u),i.set(a,p)}if(i.size===0)return s;const o=[];s.length>0&&o.push(`local: ${s.join(", ")}`);for(const[f,c]of i.entries())o.push(`${f}: ${c.join(", ")}`);return o}function k(e,r){return Array.isArray(e)?e.filter(l).map(t=>j(t,r)).filter(t=>t!==""):[]}function gn(e,r,t){const n=Ue(e,r,t),s={};return n.type.length>0&&(s.depsType=n.type),n.value.length>0&&(s.depsValue=n.value),n.unknown.length>0&&(s.depsUnknown=n.unknown),s}function mn(e,r){const t=Ue(e,r),n={};return t.type.length>0&&(n.type=t.type),t.value.length>0&&(n.value=t.value),t.unknown.length>0&&(n.unknown=t.unknown),n}function Ue(e,r,t){if(!(Array.isArray(e.typeOnlyDependencies)||Array.isArray(e.valueDependencies)||Array.isArray(e.unclassifiedDependencies))){const f=Z(e.dependencies,r,t);return{type:[],value:[],unknown:f}}const s=Z(e.typeOnlyDependencies,r,t),i=Z(e.valueDependencies,r,t),o=Z(e.unclassifiedDependencies,r,t);return{type:s,value:i,unknown:o}}function hn(e,r,t,n){const s=e.ok===!1,i={...S(e,t,n)};if(!s){const c=Cn(e.modules,r,t);c.length>0&&(i.targets=c,i.moduleCount=c.length),t.details===!0&&(i.modules=kn(e.modules,r,t))}for(const c of["planId","executable","next"])e[c]!==void 0&&(i[c]=e[c]);if(s&&(i.ok=!1,i.code=typeof e.code=="string"?e.code:"MODULE_PLAN_BLOCKED"),l(e.api)&&(i.api=An(e.api,r)),l(e.boundary)&&(i.boundary=vn(e.boundary,r,t),s&&l(i.boundary))){const c=bn(i.boundary);c.length>0&&(i.blocking=c,delete i.boundary)}const o=Sn(i.boundary);if(o.length>0?i.warnings=o:Array.isArray(e.warnings)&&e.warnings.length>0&&(i.warnings=e.warnings.filter(c=>typeof c=="string").map(c=>tr(c,t))),l(e.facade)){const c=Tn(e.facade,t);i.facade=s?xn(c):c}const f=Bn(e);if(f&&(i.integrity=f),Array.isArray(e.cycles)&&e.cycles.length>0?i.cycles=e.cycles:i.cycles="none",!s&&l(e.preview)&&(i.preview=Dn(e.preview,t,e)),Array.isArray(e.symbolErrors)&&e.symbolErrors.length>0&&(i.ok=!1,i.symbolErrors=e.symbolErrors),s){const c=$n(i);c.length>0&&(i.affected=c),i.next||(i.next="Revise the plan, then rerun modulePlan preview.")}return i}function An(e,r){const t={};typeof e.status=="string"&&(t.status=e.status),typeof e.before=="number"&&(t.before=e.before),typeof e.after=="number"&&(t.after=e.after);const n=k(e.removed,r),s=k(e.added,r);return n.length>0&&(t.removed=n),s.length>0&&(t.added=s),t}function vn(e,r,t){const s=(Array.isArray(e.nonExportedImports)?e.nonExportedImports:[]).filter(l).map(i=>{const o={code:typeof i.code=="string"?i.code:"MODULE_PLAN_BOUNDARY_WARNING",from:typeof i.importerFile=="string"?h(i.importerFile,t):"",source:typeof i.sourceFile=="string"?h(i.sourceFile,t):"",usage:typeof i.usageKind=="string"?i.usageKind:"unknown",symbols:k(i.symbols,r)},f=Ge(i.suggestedFixes,r,t);return f.length>0&&(o.suggestedFixes=f),typeof i.hint=="string"&&(o.hint=i.hint),o}).filter(i=>Array.isArray(i.symbols)&&i.symbols.length>0);return s.length>0?{nonExportedImports:s}:{}}function Ge(e,r,t){return Array.isArray(e)?e.filter(l).map(n=>{const s={kind:typeof n.kind=="string"?n.kind:"unknown"},i=j(n.symbol,r);if(i&&(s.symbol=i),typeof n.toFile=="string"&&(s.to=h(n.toFile,t)),typeof n.fromFile=="string"&&(s.from=h(n.fromFile,t)),typeof n.risk=="string"&&(s.risk=n.risk),typeof n.warning=="string"&&(s.warning=n.warning),l(n.saferAlternative)){const f=Ge([n.saferAlternative],r,t)[0];f&&(s.saferAlternative=f)}return s}).filter(n=>typeof n.symbol=="string"):[]}function bn(e){return(Array.isArray(e.nonExportedImports)?e.nonExportedImports.filter(l):[]).map(t=>{const n={code:t.code??"MODULE_PLAN_BOUNDARY_WARNING",from:t.from??"",source:t.source??"",usage:t.usage??"unknown",symbols:Array.isArray(t.symbols)?t.symbols:[]};return Array.isArray(t.suggestedFixes)&&t.suggestedFixes.length>0&&(n.suggestedFixes=t.suggestedFixes),typeof t.hint=="string"&&(n.hint=t.hint),n})}function xn(e){const r={};return typeof e.file=="string"&&(r.file=e.file),Array.isArray(e.exports)&&(r.exports=e.exports.length),r}function $n(e){const r=new Set,t=Array.isArray(e.blocking)?e.blocking.filter(l):[];for(const n of t)typeof n.from=="string"&&n.from&&r.add(n.from),typeof n.source=="string"&&n.source&&r.add(n.source);return Array.from(r)}function Sn(e){return!l(e)||!Array.isArray(e.nonExportedImports)?[]:e.nonExportedImports.filter(l).map(r=>{const t=typeof r.from=="string"?r.from:"",n=typeof r.source=="string"?r.source:"",s=Array.isArray(r.symbols)?r.symbols.filter(i=>typeof i=="string"):[];return t&&n&&s.length>0?`${t} imports non-exported ${s.join(", ")} from ${n}`:""}).filter(r=>r!=="")}function kn(e,r,t){if(!Array.isArray(e))return{};const n={};for(const s of e){if(!l(s)||typeof s.targetFile!="string")continue;const i=h(s.targetFile,t),o={owns:k(s.symbols,r)},f=_n(s.imports,r,t);Object.keys(f).length>0&&(o.uses=f);const c=k(s.internalDependencies,r);c.length>0&&(o.internalDeps=c);const a=Pn(s.unassignedDependencies,r);Object.keys(a).length>0&&(o.unassigned=a),n[i]=o}return n}function Cn(e,r,t){return Array.isArray(e)?e.filter(l).filter(n=>typeof n.targetFile=="string").map(n=>{const s={file:h(String(n.targetFile),t),summary:On(n,r,t)},i=En(n.unassignedDependencies);return i!==""&&(s.warning=`unassigned ${i}`),s}):[]}function On(e,r,t){const n=He(e.symbols,r,!0),s=He(e.symbols,r,!1),i=In(e.imports,r,t),o=k(e.internalDependencies,r).length,f=[`exports ${V(n,4)||"none"}`];return s.length>0&&f.push(`private ${V(s,3)}`),i!==""&&f.push(`imports ${i}`),o>0&&f.push(`internalDeps ${o}`),f.join("; ")}function He(e,r,t){return Array.isArray(e)?e.filter(l).filter(n=>n.exported===!0===t).map(n=>j(n,r)).filter(n=>n!==""):[]}function In(e,r,t){if(!l(e))return"";const n=[],s={typeOnly:"type",value:"run",unclassified:"unclassified"};for(const i of["typeOnly","value","unclassified"]){const o=Mn(e[i],r,t);o!==""&&n.push(`${s[i]} ${o}`)}return n.join("; ")}function Mn(e,r,t){if(!Array.isArray(e))return"";const n=e.filter(l).filter(s=>typeof s.targetFile=="string").map(s=>{const i=h(String(s.targetFile),t),o=k(s.symbols,r).filter(f=>typeof f=="string");return`${i}: ${V(o,3)||"none"}`});return V(n,2,"more imports")}function En(e){if(!l(e))return"";const r=[];for(const t of["typeOnly","value","unclassified"]){const n=e[t];Array.isArray(n)&&n.length>0&&r.push(`${t} ${n.length}`)}return r.join("; ")}function V(e,r,t="more"){if(e.length===0)return"";const n=e.slice(0,r),s=e.length-n.length;return s>0?`${n.join(", ")}, +${s} ${t}`:n.join(", ")}function _n(e,r,t){if(!l(e))return{};const n={},s={typeOnly:"type",value:"run",unclassified:"unclassified"};for(const i of["typeOnly","value","unclassified"]){const o=Ln(e[i],r,t);Object.keys(o).length>0&&(n[s[i]]=o)}return n}function Ln(e,r,t){if(!Array.isArray(e))return{};const n={};for(const s of e)!l(s)||typeof s.targetFile!="string"||(n[h(s.targetFile,t)]=k(s.symbols,r));return n}function Pn(e,r){if(!l(e))return{};const t={};for(const n of["typeOnly","value","unclassified"]){const s=k(e[n],r);s.length>0&&(t[n]=s)}return t}function Tn(e,r){const t={};return typeof e.file=="string"&&(t.file=h(e.file,r)),Array.isArray(e.exports)&&e.exports.length>0&&(t.exports=e.exports.filter(n=>typeof n=="string").map(n=>n.match(/from\s+"([^"]+)"/)?.[1]??n)),t}function Dn(e,r,t){const n={};typeof e.dir=="string"&&(n.dir=h(e.dir,r));const s=[];let i=0,o=0,f=0;if(Array.isArray(e.files)){const a={};for(const u of e.files){if(!l(u)||typeof u.targetFile!="string"||typeof u.previewFile!="string")continue;i+=1;const p=h(u.targetFile,r),d=y(u.lineCount);a[h(u.targetFile,r)]={file:h(u.previewFile,r),lines:d},d>=pt&&s.push(`${p} ${d}l`)}Object.keys(a).length>0&&(n.files=a)}l(e.facade)&&typeof e.facade.previewFile=="string"&&(o=y(e.facade.lineCount),n.facade={file:h(e.facade.previewFile,r),lines:o}),l(e.patch)&&typeof e.patch.file=="string"&&(f=y(e.patch.lineCount),n.patch={file:h(e.patch.file,r),lines:f},f>=dt&&s.push(`patch ${f}l`)),n.summary=jn(i,o,f,t),s.length>0&&(n.large=s);const c=Fn(t);return c.length>0&&(n.warnings=c),n.next=Nn(t,s.length>0),n}function jn(e,r,t,n){const s=[`${e} ${e===1?"file":"files"}`];return r>0&&s.push(`facade ${r}l`),t>0&&s.push(`patch ${t}l`),s.push(ie(n)?"cycles detected":"cycles none"),s.join("; ")}function Fn(e){return ie(e)?["runtime cycles detected"]:[]}function Nn(e,r){return ie(e)?["fix module plan before applying","rerun modulePlan"]:[r?"check summary/api/cycles/imports before reading large preview artifacts":"check summary/api/cycles/imports","read targeted preview artifacts only if a warning/check points there","use top-level next for apply/revise action"]}function ie(e){return Array.isArray(e.cycles)&&e.cycles.length>0}function Bn(e){const r=Array.isArray(e.modules)?e.modules.filter(l):[];if(r.length===0)return"";const t=r.reduce((o,f)=>o+(Array.isArray(f.symbols)?f.symbols.length:0),0),n=r.reduce((o,f)=>o+Un(f.imports),0),s=l(e.facade)&&Array.isArray(e.facade.exports)?e.facade.exports.length:0,i=[`${t} declarations moved unchanged`,`${n} imports generated`];return s>0&&i.push(`facade exports ${s}`),i.join("; ")}function Un(e){if(!l(e))return 0;let r=0;for(const t of["typeOnly","value","unclassified"]){const n=e[t];if(Array.isArray(n))for(const s of n)l(s)&&Array.isArray(s.symbols)&&(r+=s.symbols.length)}return r}function Z(e,r,t){return k(e,r)}function Gn(e,r,t){const n=y(e.memberCount),s=y(e.memberOffset),i=y(e.memberLimit),o=y(e.hiddenMemberCount),f=se(e.members,r,t,"members"),c=f.length;o>0&&f.push(`+ ${o} hidden members`);const a={members:f};return o>0?(a.count=n,a.page=`${s}..${s+c-1} of ${n}`,a.hint="Use --all to list all members, --offset <n> --limit <n> to page, or inspect code <member> --parent <entity>."):n>q&&(a.count=n),s>0&&o===0&&(a.page=`${s}..${s+f.length-1} of ${n}`),a}function Hn(e){const r=y(e.localDeclarationCount),t=Ve(e.reexports);return r===0&&t.length>0?`facade only; ${t.length} ${t.length===1?"re-export":"re-exports"}; 0 local declarations`:r===0?"0 local declarations":`${r} local ${r===1?"declaration":"declarations"}; ${t.length} ${t.length===1?"re-export":"re-exports"}`}function Ve(e){return Array.isArray(e)?e.filter(l).map(r=>typeof r.module=="string"?r.module:"").filter(r=>r!==""):[]}function oe(e,r,t,n){const s=j(e,r),i=typeof e.signature=="string"?e.signature:"",o=t.includeRanges?L(e):"",f=typeof e.sourceModule=="string"?`from ${e.sourceModule}`:"";return n==="file"||n==="exports"?Vn(e,s,i,o,f,n):n==="members"?Wn(e,s,i,o):s==="constructor"?[o,f,i||s].filter(a=>a!=="").join(" "):[s,o,f,i].filter(a=>a!=="").join(" ")}function Vn(e,r,t,n,s,i){const o=i==="file"&&e.exported===!0?"export ":"",f=qn(e,t);return[`${o}${r}${f}`,n,s].filter(a=>a!=="").join(" ")}function qn(e,r){const t=typeof e.name=="string"?e.name:"",n=typeof e.kind=="string"?le(e.kind):null;if(!t||!r||n!=="function"&&n!=="method")return"";const s=r.indexOf(t);if(s<0)return"";const i=r.slice(s+t.length).trim();return i.startsWith("(")?i:""}function Wn(e,r,t,n){const s=typeof e.kind=="string"?le(e.kind):null,i=typeof e.name=="string"?e.name:"";let o=t||qe(r);if(s==="property"&&i){o=r;const f=Kn(t,i);f&&(o+=f)}return[o,n].filter(f=>f!=="").join(" ")}function Kn(e,r){if(!e)return"";const t=e.indexOf(r);if(t<0)return"";const n=e.slice(t+r.length).trim();return n.startsWith(":")?n:""}function zn(e,r,t){const n=Rn(e,["id","op","ok","code","error"]);if(typeof e.sourceFile=="string"){const s=h(e.sourceFile,r);s!==t&&(n.file=s)}if(e.code==="INSPECT_SYMBOL_NOT_FOUND"){const s=Jn(e);s&&(n.missingSymbols=[s])}return n}function D(e){return e.code==="INSPECT_SYMBOL_NOT_FOUND"&&E(e).length>0}function E(e){return Array.isArray(e.missingSymbols)?e.missingSymbols.filter(r=>typeof r=="string"&&r.length>0):[]}function Jn(e){const r=typeof e.error=="string"?e.error:"",t="Symbol not found:";if(!r.startsWith(t))return null;const n=r.slice(t.length).trim();if(!n)return null;const s=n.indexOf(":");return s>0?n.slice(s+1).trim():n}function j(e,r){if(!l(e))return"";const t=typeof e.name=="string"?e.name:"",n=typeof e.kind=="string"?le(e.kind):null;return t?n==="constructor"?"constructor":n?`${Qn(n,r)}${wn(n,r)}${t}`:t:""}function F(e,r){return fe(e)||j(e,r)}function X(e){if(!l(e))return"";const r=Array.isArray(e.path)?e.path.filter(t=>typeof t=="string"&&t.trim()!==""):[];return r.length>0?r.join("."):fe(e)}function fe(e){return l(e)&&typeof e.name=="string"?e.name:""}function qe(e){const r=e.indexOf("-");if(r>0&&r<=3)return e.slice(r+1);const t=e.indexOf(":");return t>0?e.slice(t+1):e}function We(e,r){return r>q?{[e]:r}:{}}function Ke(e,r){return e===1?r:`${r}s`}function ze(e,r){return e.localeCompare(r,void 0,{numeric:!0})}function Yn(e,r,t){const n=new Set(r?[r]:[]);for(const s of e){typeof s.declaredIn=="string"&&n.add(h(s.declaredIn,t));const i=Array.isArray(s.usedBy)?s.usedBy.filter(l):[];for(const o of i)typeof o.file=="string"&&n.add(h(o.file,t))}return Array.from(n)}function Je(e,r,t){const n=new Set(r);for(const s of e){const i=Array.isArray(s.variants)?s.variants.filter(l):[];for(const o of i){const f=Array.isArray(o.declarations)?o.declarations.filter(l):[];for(const c of f){typeof c.file=="string"&&n.add(h(c.file,t));const a=l(c.sameAs)?c.sameAs:null;a&&typeof a.file=="string"&&n.add(h(a.file,t))}}}return Array.from(n)}function Zn(e){const r=Xe(e.map(t=>t.replace(/\\/g,"/")));return Ze(r)}function Ye(e,r){const t=e.map(s=>s.replace(/\\/g,"/")),n=Xe(t);for(const s of r.map(i=>ae(i)).filter(i=>i.includes("/"))){const i=`<${$.basename(s)}>`;n.some(o=>o.token===i||o.prefix===s)||t.some(o=>o===s||o.startsWith(`${s}/`))&&n.push({token:i,prefix:s})}return n.sort((s,i)=>i.prefix.length-s.prefix.length),Ze(n)}function Ze(e){return{aliases:e,compactPath(r){const t=ae(r),n=e.find(s=>t===s.prefix||t.startsWith(`${s.prefix}/`));return n?t===n.prefix?n.token:`${n.token}/${t.slice(n.prefix.length+1)}`:t}}}function Xe(e){const r=new Map;for(const n of e){const s=ae(n).split("/");for(let i=2;i<s.length;i+=1){const o=s.slice(0,i).join("/");o.length>=8&&r.set(o,(r.get(o)??0)+1)}}const t=new Set;return Array.from(r.entries()).map(([n,s])=>{const i=`<${$.basename(n)}>`;return{prefix:n,count:s,token:i,score:Math.max(0,n.length-i.length)*s}}).filter(n=>n.count>=2&&n.score>=12).sort((n,s)=>s.score-n.score||n.prefix.localeCompare(s.prefix)).filter(n=>t.has(n.token)?!1:(t.add(n.token),!0)).slice(0,6).sort((n,s)=>s.prefix.length-n.prefix.length).map(n=>({token:n.token,prefix:n.prefix}))}function Qe(e,r){if(e.aliases.length===0)return null;const t=JSON.stringify(r),n={};for(const s of e.aliases)t.includes(s.token)&&(n[s.token]=s.prefix);return Object.keys(n).length>0?n:null}function ce(e){const r=new Map,t=[];for(const n of e){const s=n.startsWith("<")?n.indexOf(">"):-1;if(s<=0){t.push(n);continue}const i=n.indexOf("/",s);if(i<0){t.push(n);continue}const o=n.slice(0,i),f=n.slice(i+1),c=r.get(o)??[];c.push(f),r.set(o,c)}return[...Array.from(r.entries()).map(([n,s])=>s.length===1?`${n}/${s[0]}`:`${n}/: ${s.join(", ")}`),...t].sort()}function ae(e){return e.replace(/\\/g,"/")}function ue(e,r,t){const n=e.indexOf(r);if(n<=0)return null;const s=e.slice(0,n).trim(),i=e.slice(n+r.length).trim();if(!s||!i)return null;const o=Xn(s,t);return o?{raw:e,symbolName:i,symbolKind:o}:null}function Xn(e,r){const t=e.toLowerCase();return we(t)?t:Object.entries(r.entityKindAliases).find(([,s])=>s===e)?.[0]??null}function Qn(e,r){return Re(e)?r.entityKindAliases[e]:e}function wn(e,r){return Re(e)?r.selectorSeparator:":"}function le(e){const r=e.toLowerCase();return we(r)?r:null}function we(e){return lt.includes(e)}function Re(e){return ft.ENTITY_KIND_IDS.includes(e)}function Rn(e,r){const t={};for(const n of r)e[n]!==void 0&&(t[n]=e[n]);return t}function er(e,r){const t=e.filter(l).map(s=>typeof s.sourceFile=="string"?h(s.sourceFile,r):null).filter(s=>!!s),n=Array.from(new Set(t));return n.length===1?n[0]??null:null}function h(e,r){const t=$.isAbsolute(e)?e:$.resolve(r.cwd,e),n=$.relative(r.cwd,t),i=(n&&!n.startsWith("..")&&!$.isAbsolute(n)?n:e).replace(/\\/g,"/"),o=(0,ut.compactDisplayPathWithMatch)(r.cwd,t,r.displayPathAliases??[]);return o.alias&&r.pathAliasHints&&(r.pathAliasHints.some(c=>c.alias===o.alias.token&&c.original===i&&c.display===o.displayPath)||r.pathAliasHints.push({alias:o.alias.token,original:i,display:o.displayPath})),o.displayPath}function tr(e,r){const t=$.resolve(r.cwd),n=t.replace(/\\/g,"/");return e.replaceAll(`${t}\\`,"").replaceAll(`${n}/`,"").replace(/\\/g,"/")}function et(e,r,t){const n=$.isAbsolute(r)?r:$.resolve(e,r);return U.mkdirSync($.dirname(n),{recursive:!0}),U.writeFileSync(n,t,"utf8"),$.relative(e,n).replace(/\\/g,"/")}function tt(e,r,t,n,s){const i=typeof n.sourceFile=="string"&&$.extname(n.sourceFile)||".ts",o=(0,x.saveSessionOutputText)(e,r,t,s,i);return{saved:o.saved,last:o.last}}function L(e,r){if(!l(e)||!l(e.range))return"";const t=nt(e.range,"start"),n=nt(e.range,"end");if(!t||!n)return"";const s=t.line+1,i=n.line+1;return`@${s}..${i}`}function nt(e,r){const t=e[r];return!l(t)||typeof t.line!="number"?null:{line:t.line}}function y(e){return typeof e=="number"?e:0}function l(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}
|
|
16
|
+
`),f);return{saved:a.saved,last:a.last}})}function on(e,n,t){return!e||!n||t<2||e.length<t?[]:Array.from(new Set(e.slice(0,t).filter(r=>typeof r=="string"&&r!==""&&n.has(r))))}function fn(e){for(const n of e)if(l(n)&&typeof n.sourceFile=="string")return b.extname(n.sourceFile)||".ts";return".ts"}function Fe(e,n,t,r){if(!l(e))return{ok:!1,code:"INVALID_INSPECT_RESULT",error:"Inspect result is not an object."};const s=typeof e.op=="string"?e.op:"unknown";if(e.ok===!1&&s!=="modulePlan")return ir(e,t,r);if(s==="file"){const i={...S(e,t,r),...we("count",g(e.symbolCount)),symbols:fe(e.symbols,n,t,"file")};return(e.hasNonDeclarationText===!0||Array.isArray(i.symbols)&&i.symbols.length===0&&Cn(e.sourceFile))&&(i.hasNonDeclarationText=!0),e.mode==="local"&&(i.mode="local",i.summary=wn(e),i.localDeclarationCount=g(e.localDeclarationCount),i.reexports=Ye(e.reexports)),i}return s==="exports"?{...S(e,t,r),...we("count",g(e.exportCount)),exports:kn(e.exports,n,t)}:s==="members"?{...S(e,t,r),entity:N(e.entity,n),...Qn(e,n,t)}:s==="code"?Sn(e,n,t,r):s==="dependencies"?{...S(e,t,r),entity:N(e.entity,n),...On(e,n,t)}:s==="modulePlan"?Mn(e,n,t,r):s==="usages"?cn(e,n,t,r):s==="duplicates"?an(e,n,t,r):s==="directoryFallback"?{...e}:s==="slice"?bn(e,n,t,r):{...S(e,t,r),warning:"Unknown inspect operation result."}}function cn(e,n,t,r){const s=typeof e.targetPath=="string"?A(e.targetPath,t):typeof e.sourceFile=="string"?A(e.sourceFile,t):r??"",i=Array.isArray(e.items)?e.items.filter(l):[],o=cr(fr(i,s,t)),f=pn(i),a=e.targetMode==="directory"&&e.queryMode!=="explicit",c={...S(e,t,r),target:o.compactPath(s),summary:typeof e.summary=="string"?e.summary:`${f.length} symbols`,referenceCount:g(e.referenceCount),itemCount:g(e.itemCount),fileCount:g(e.fileCount),scopeLabel:mn(e,t),targetMode:typeof e.targetMode=="string"?e.targetMode:"",queryMode:typeof e.queryMode=="string"?e.queryMode:""};if(delete c.file,e.excludeTarget===!0&&e.targetLocalUsagesHidden!==!0&&(c.scope="excluding target"),e.targetLocalUsagesHidden===!0&&(c.targetLocalUsagesHidden=!0),a){const p=yn(f,n,o,t);c.usedBy=p.usedBy,p.hiddenConsumers>0&&(c.hiddenConsumers=`+ ${p.hiddenConsumers} files`)}else{const p=f.slice(0,R);c.items=p.map(d=>dn(d,n,o,t,e.targetMode==="directory"))}const u=ur(o,c);if(u&&(c.paths=u),!a&&f.length>R&&(c.hidden=`+ ${f.length-R} symbols`),t.save){const p=(0,$.saveSessionOutputJson)(t.cwd,"usages",t.save,e);c.saved=p.saved;const d=(0,$.useSessionGuidance)(t.cwd,"inspect.usages.focus",`Expand saved usages with: aib inspect usages --from-file ${p.saved} --focus <name> --detail locations|code`);d&&(c.next=d)}return c}function an(e,n,t,r){const s=Array.isArray(e.targetPaths)?e.targetPaths.filter(c=>typeof c=="string").map(c=>A(c,t)):[],i=Array.isArray(e.items)?e.items.filter(l):[],o=tt(),f={...S(e,t,r),target:s.length===1?o.compactPath(s[0]):s.map(c=>o.compactPath(c)),summary:typeof e.summary=="string"?e.summary:`${i.length} names`,itemCount:g(e.itemCount),returnedItemCount:g(e.returnedItemCount),declarationCount:g(e.declarationCount),exactCopyCount:g(e.exactCopyCount),offset:g(e.offset),limit:g(e.limit),detail:typeof e.detail=="string"?e.detail:"locations",mode:typeof e.mode=="string"?e.mode:"both",items:i.map(c=>je(c,n,t,o))},a=g(e.hiddenItemCount);if(a>0&&(f.hidden=`+ ${a} names`),t.save){const c=(0,$.saveSessionOutputJson)(t.cwd,"duplicates",t.save,e);f.saved=c.saved;const u=(0,$.useSessionGuidance)(t.cwd,"inspect.duplicates.read",`Read saved duplicates with: aib session read ${c.saved}`);u&&(f.next=u)}return f}function je(e,n,t,r){const s=Array.isArray(e.variants)?e.variants.filter(l):[];return{name:typeof e.name=="string"?e.name:"",count:g(e.declarationCount),variants:g(e.variantCount),exactCopies:g(e.exactCopyCount),groups:s.map(i=>un(i,n,t,r))}}function un(e,n,t,r){const s=Array.isArray(e.declarations)?e.declarations.filter(l):[],i={count:g(e.count),declarations:s.map(o=>ln(o,n,t,r))};return typeof e.code=="string"&&(i.code=e.code),i}function ln(e,n,t,r){const s=l(e.symbol)?e.symbol:{},i=l(e.sameAs)?e.sameAs:null,o={file:typeof e.file=="string"?r.compactPath(A(e.file,t)):"",selector:T(s,n)},f=t.includeRanges?P(s):"";if(f&&(o.meta=f),i){const a=l(i.symbol)?i.symbol:{},c=typeof i.file=="string"?r.compactPath(A(i.file,t)):"",u=t.includeRanges?P(a):"";o.sameAs=[c,u].filter(p=>p!=="").join(" ")}return o}function pn(e){return[...e].sort((n,t)=>g(t.referenceCount)-g(n.referenceCount)||et(w(n.entity),w(t.entity)))}function dn(e,n,t,r,s=!1){const i={entity:w(e.entity),summary:typeof e.summary=="string"?e.summary:`${g(e.referenceCount)} refs, ${g(e.fileCount)} files`,usedBy:gn(e.usedBy,t,r)};return s&&typeof e.declaredIn=="string"&&(i.declaredIn=t.compactPath(A(e.declaredIn,r))),e.role==="member"&&(i.role="member"),i}function yn(e,n,t,r){const s=new Map;for(const f of e){const a=w(f.entity),c=Array.isArray(f.usedBy)?f.usedBy.filter(l):[];for(const u of c){const p=typeof u.file=="string"?u.file:"";if(!p)continue;const d=g(u.count),m=s.get(p)??{refs:0,symbols:new Map};m.refs+=d,m.symbols.set(a,(m.symbols.get(a)??0)+d),s.set(p,m)}}const i=Array.from(s.entries()).sort(([f,a],[c,u])=>u.refs-a.refs||f.localeCompare(c)),o=i.slice(0,$t).map(([f,a])=>{const c=Array.from(a.symbols.entries()).sort(([p,d],[m,h])=>h-d||et(p,m)),u=c.slice(0,bt).map(([p,d])=>d>1?`${p} x${d}`:p);return c.length>u.length&&u.push(`+ ${c.length-u.length} more`),{file:t.compactPath(A(f,r)),summary:`${a.refs} ${Re(a.refs,"ref")}`,symbols:u}});return{usedBy:o,hiddenConsumers:Math.max(0,i.length-o.length)}}function gn(e,n,t){if(!Array.isArray(e))return[];const r=e.filter(l).map(s=>{const i=typeof s.file=="string"?n.compactPath(A(s.file,t)):"",o=g(s.count);return i?`${i} x${o}`:""}).filter(s=>s!=="");return lr(r)}function mn(e,n){const t=Array.isArray(e.usageScopes)?e.usageScopes.filter(r=>typeof r=="string"&&r.trim()!==""):[];return t.length===0?"project":t.length===1?A(t[0],n):`${t.length} scopes`}function Ne(e){const n=Array.isArray(e.results)?e.results.filter(l):[e];if(n.length===0)return null;const t=[];for(const r of n){const s=typeof r.detail=="string"?r.detail:"locations";if(l(r.paths)&&Object.keys(r.paths).length>0){t.push("paths:");for(const[a,c]of Object.entries(r.paths))t.push(`${a} = ${String(c)}`)}const i=typeof r.target=="string"?r.target:"";if(t.push(i?`usages ${i}`:"usages"),g(r.referenceCount)===0){t.push(`0 refs in ${typeof r.scopeLabel=="string"?r.scopeLabel:"project"}`),X(t,r);const a=g(r.itemCount);(r.targetMode==="directory"||r.queryMode!=="explicit")&&a>0&&t.push(`symbols checked: ${a}`);continue}typeof r.summary=="string"&&t.push(r.summary),typeof r.scope=="string"&&t.push(r.scope),X(t,r);const o=Array.isArray(r.usedBy)?r.usedBy.filter(l):[];for(const a of o){const c=typeof a.file=="string"?a.file:"",u=typeof a.summary=="string"?a.summary:"",p=Array.isArray(a.symbols)?a.symbols.filter(d=>typeof d=="string"):[];t.push(`${c}: ${u}; ${p.join(", ")}`.trim())}typeof r.hiddenConsumers=="string"&&t.push(r.hiddenConsumers);const f=Array.isArray(r.items)?r.items.filter(l):[];t.push(...xn(f)),Ve(t,r,f),typeof r.hidden=="string"&&t.push(r.hidden),typeof r.view=="string"&&t.push(`view: ${r.view}`),typeof r.saved=="string"&&t.push(`saved: ${r.saved}`),typeof r.next=="string"&&t.push(`next: ${r.next}`)}return t.join(`
|
|
17
|
+
`)}function X(e,n){n.targetLocalUsagesHidden===!0&&e.push("target-local usages hidden; use +includeTarget to show")}function Be(e,n){const t=new Map;for(const r of e){const s=n(r),i=t.get(s)??[];i.push(r),t.set(s,i)}return Array.from(t.entries())}function Ue(e){const n=Array.isArray(e.results)?e.results.filter(l):[e];if(n.length===0)return null;const t=[];for(const r of n){const s=typeof r.detail=="string"?r.detail:"locations",i=Array.isArray(r.target)?r.target.filter(a=>typeof a=="string").join(", "):typeof r.target=="string"?r.target:"",o=hn(r.paths,s,i);if(o.length>0){t.push("paths:");for(const[a,c]of o)t.push(`${a} = ${c}`)}t.push(i?`duplicates ${i}`:"duplicates"),typeof r.summary=="string"&&t.push(r.summary);const f=Array.isArray(r.items)?r.items.filter(l):[];if(f.length===0){t.push("no duplicates");continue}for(const a of f)An(t,a,s);typeof r.hidden=="string"&&t.push(r.hidden),typeof r.view=="string"&&t.push(`view: ${r.view}`),typeof r.saved=="string"&&t.push(`saved: ${r.saved}`),typeof r.next=="string"&&t.push(`next: ${r.next}`)}return t.join(`
|
|
18
|
+
`)}function hn(e,n,t){if(!l(e))return[];const r=Object.entries(e).filter(s=>typeof s[1]=="string");return n!=="summary"?r:r.filter(([s])=>t.includes(s))}function An(e,n,t){e.push(...Ge(n,t))}function Ge(e,n){const t=[],r=typeof e.name=="string"?e.name:"",s=g(e.count),i=g(e.variants),o=g(e.exactCopies);if(n!=="summary"&&t.push(""),t.push(`${r} x${s}, ${i} ${Re(i,"variant")}${o>0?`, exact x${o}`:""}`),n==="summary")return t;const f=Array.isArray(e.groups)?e.groups.filter(l):[];if(n==="code"){let a=1;const c=[];for(const u of f){if(g(u.count)===1){c.push(u);continue}He(t,u,`variant#${a}`),a+=1}if(c.length>0){t.push("// single variants");for(const u of c)He(t,u,null)}return t}for(const a of f){const c=Array.isArray(a.declarations)?a.declarations.filter(l):[];t.push(...qe(c,!1))}return t}function He(e,n,t){const r=Array.isArray(n.declarations)?n.declarations.filter(l):[],s=g(n.count);t&&e.push(`// ${t} x${s}`);const i=qe(r,!1);for(const o of i)e.push(`// ${o}`);typeof n.code=="string"&&e.push(n.code.trimEnd())}function vn(e,n){const t=typeof e.file=="string"?e.file:"",r=typeof e.meta=="string"?e.meta:"",s=n&&typeof e.sameAs=="string"&&e.sameAs!==""?` same as ${e.sameAs}`:"";return[t,r].filter(i=>i!=="").join(" ")+s}function qe(e,n){const t=new Map,r=[];for(const i of e){const o=typeof i.file=="string"?de(i.file):"";if(!o)continue;const f=o.lastIndexOf("/");if(f<=0){r.push(vn(i,n));continue}const a=o.slice(0,f),c=o.slice(f+1),u=typeof i.meta=="string"&&i.meta!==""?` ${i.meta}`:"",p=n&&typeof i.sameAs=="string"&&i.sameAs!==""?` same as ${i.sameAs}`:"",d=t.get(a)??[];d.push(`${c}${u}${p}`),t.set(a,d)}return[...Array.from(t.entries()).flatMap(([i,o])=>o.length>1?[`${i}/: ${o.join(", ")}`]:[`${i}/${o[0]}`]),...r].sort()}function Ve(e,n,t){const r=t.filter(s=>(typeof s.summary=="string"?s.summary:"").startsWith("0 refs")).map(s=>typeof s.entity=="string"?s.entity:"").filter(s=>s!=="");if(r.length!==0){if(n.queryMode==="explicit"){e.push(`unused: ${q(r,2,"more")}`);return}n.targetMode==="file"&&e.push(`unused symbols: ${r.length}`)}}function xn(e){const n=[],t=e.filter(i=>!$n(i)),{ownerGroups:r,standalone:s}=ie(t);for(const[i,o]of r){n.length>0&&n.push(""),n.push(`// ${i}:`);for(const f of o)n.push(...Ke(f,!1))}s.length>0&&n.length>0&&n.push("");for(const i of s)n.push(...Ke(i,!0));return n}function $n(e){return typeof e.referenceCount=="number"?e.referenceCount===0:(typeof e.summary=="string"?e.summary:"").startsWith("0 refs")}function Ke(e,n){const t=typeof e.entity=="string"?e.entity:"",r=H(t),s=n?t:r.name,i=typeof e.declaredIn=="string"?` [${e.declaredIn}]`:"",o=typeof e.summary=="string"?e.summary:"",f=[`${s}${i}: ${o}`.trim()],a=Array.isArray(e.usedBy)?e.usedBy.filter(c=>typeof c=="string"):[];return f.push(...a),f}function ie(e){const n=new Map,t=[];for(const r of e){const s=typeof r.entity=="string"?r.entity:"",i=H(s);if(!i.owner){t.push(r);continue}const o=n.get(i.owner)??[];o.push(r),n.set(i.owner,o)}return{ownerGroups:Array.from(n.entries()),standalone:t}}function H(e){const n=e.lastIndexOf(".");return n<=0||n>=e.length-1?{owner:null,name:e}:{owner:e.slice(0,n),name:e.slice(n+1)}}function bn(e,n,t,r){const s=typeof e.code=="string"?e.code:"",i=s===""?g(e.lineCount):s.split(/\r?\n/).length,o={...S(e,t,r),entity:N(e.entity,n)},f=P(e.entity,i);if(t.includeRanges&&f&&(o.meta=f),t.toFile){const a=it(t.cwd,t.toFile,s);if(o.writtenTo=a,!t.show)return o}if(t.save){const a=ot(t.cwd,"slice",t.save,e,s);o.saved=a.saved;const c=(0,$.useSessionGuidance)(t.cwd,"inspect.slice.read",`Read saved artifact with: aib session read ${a.saved}`);if(c&&(o.next=c),!t.show)return o}return t.show||i<=t.maxCodeLines?o.code=s:(o.reason="SLICE_TOO_LARGE_FOR_STDOUT",o.lineCount=i,o.limit=t.maxCodeLines,f&&(o.rangeMeta=f)),o}function Sn(e,n,t,r){const s=typeof e.code=="string"?e.code:"",i=s===""?0:s.split(/\r?\n/).length,o=oe(s),f={...S(e,t,r),entity:N(e.entity,n)},a=P(e.entity,i);if(t.codeMeta!==!1&&t.includeRanges&&a&&(f.meta=a),t.toFile){const c=it(t.cwd,t.toFile,s);if(f.writtenTo=c,!t.show)return f}if(t.save){const c=ot(t.cwd,"code",t.save,e,s);f.saved=c.saved;const u=(0,$.useSessionGuidance)(t.cwd,"inspect.code.read",`Read saved artifact with: aib session read ${c.saved}`);if(u&&(f.next=u),!t.show)return f}return t.show&&(o<=t.maxCodeLines?f.code=s:(f.reason="CODE_TOO_LARGE_FOR_STDOUT",f.nonEmptyLines=o,f.limit=t.maxCodeLines,a&&(f.rangeMeta=a))),f}function oe(e){return e===""?0:e.split(/\r?\n/).filter(n=>n.trim()!=="").length}function Cn(e){if(typeof e!="string"||e==="")return!1;try{return U.existsSync(e)&&U.statSync(e).isFile()&&U.readFileSync(e,"utf8").trim()!==""}catch{return!1}}function S(e,n,t){const r={op:typeof e.op=="string"?e.op:"unknown"};if(typeof e.id=="string"&&(r.id=e.id),typeof e.sourceFile=="string"){const s=A(e.sourceFile,n);s!==t&&(r.file=s)}return r}function fe(e,n,t,r="generic"){return Array.isArray(e)?e.filter(l).map(s=>V(ae(s,n,t,r))):[]}function kn(e,n,t){if(!Array.isArray(e))return[];const r=e.filter(l);if(t.includeRanges)return r.map(f=>V(ae(f,n,t,"exports")));const s=[],i=new Map;for(const f of r){const a=V(ae(f,n,t,"exports")),c=typeof f.sourceModule=="string"?f.sourceModule:"";if(!c){s.push(a);continue}const u=er(f,a,c),p=i.get(c)??[];p.push(u),i.set(c,p)}if(i.size===0)return s;const o=[];s.length>0&&o.push(`local: ${s.join(", ")}`);for(const[f,a]of i.entries())o.push(`${f}: ${a.join(", ")}`);return o}function C(e,n){return Array.isArray(e)?e.filter(l).map(t=>T(t,n)).filter(t=>t!==""):[]}function On(e,n,t){const r=ze(e,n,t),s={};return r.type.length>0&&(s.depsType=r.type),r.value.length>0&&(s.depsValue=r.value),r.unknown.length>0&&(s.depsUnknown=r.unknown),s}function In(e,n){const t=ze(e,n),r={};return t.type.length>0&&(r.type=t.type),t.value.length>0&&(r.value=t.value),t.unknown.length>0&&(r.unknown=t.unknown),r}function ze(e,n,t){if(!(Array.isArray(e.typeOnlyDependencies)||Array.isArray(e.valueDependencies)||Array.isArray(e.unclassifiedDependencies))){const f=Q(e.dependencies,n,t);return{type:[],value:[],unknown:f}}const s=Q(e.typeOnlyDependencies,n,t),i=Q(e.valueDependencies,n,t),o=Q(e.unclassifiedDependencies,n,t);return{type:s,value:i,unknown:o}}function Mn(e,n,t,r){const s=e.ok===!1,i={...S(e,t,r)};if(!s){const a=jn(e.modules,n,t);a.length>0&&(i.targets=a,i.moduleCount=a.length),t.details===!0&&(i.modules=Fn(e.modules,n,t))}for(const a of["planId","executable","next"])e[a]!==void 0&&(i[a]=e[a]);if(s&&(i.ok=!1,i.code=typeof e.code=="string"?e.code:"MODULE_PLAN_BLOCKED"),l(e.api)&&(i.api=En(e.api,n)),l(e.boundary)&&(i.boundary=_n(e.boundary,n,t),s&&l(i.boundary))){const a=Ln(i.boundary);a.length>0&&(i.blocking=a,delete i.boundary)}const o=Dn(i.boundary);if(o.length>0?i.warnings=o:Array.isArray(e.warnings)&&e.warnings.length>0&&(i.warnings=e.warnings.filter(a=>typeof a=="string").map(a=>hr(a,t))),l(e.facade)){const a=Kn(e.facade,t);i.facade=s?Tn(a):a}const f=Zn(e);if(f&&(i.integrity=f),Array.isArray(e.cycles)&&e.cycles.length>0?i.cycles=e.cycles:i.cycles="none",!s&&l(e.preview)&&(i.preview=zn(e.preview,t,e)),Array.isArray(e.symbolErrors)&&e.symbolErrors.length>0&&(i.ok=!1,i.symbolErrors=e.symbolErrors),s){const a=Pn(i);a.length>0&&(i.affected=a),i.next||(i.next="Revise the plan, then rerun modulePlan preview.")}return i}function En(e,n){const t={};typeof e.status=="string"&&(t.status=e.status),typeof e.before=="number"&&(t.before=e.before),typeof e.after=="number"&&(t.after=e.after);const r=C(e.removed,n),s=C(e.added,n);return r.length>0&&(t.removed=r),s.length>0&&(t.added=s),t}function _n(e,n,t){const s=(Array.isArray(e.nonExportedImports)?e.nonExportedImports:[]).filter(l).map(i=>{const o={code:typeof i.code=="string"?i.code:"MODULE_PLAN_BOUNDARY_WARNING",from:typeof i.importerFile=="string"?A(i.importerFile,t):"",source:typeof i.sourceFile=="string"?A(i.sourceFile,t):"",usage:typeof i.usageKind=="string"?i.usageKind:"unknown",symbols:C(i.symbols,n)},f=We(i.suggestedFixes,n,t);return f.length>0&&(o.suggestedFixes=f),typeof i.hint=="string"&&(o.hint=i.hint),o}).filter(i=>Array.isArray(i.symbols)&&i.symbols.length>0);return s.length>0?{nonExportedImports:s}:{}}function We(e,n,t){return Array.isArray(e)?e.filter(l).map(r=>{const s={kind:typeof r.kind=="string"?r.kind:"unknown"},i=T(r.symbol,n);if(i&&(s.symbol=i),typeof r.toFile=="string"&&(s.to=A(r.toFile,t)),typeof r.fromFile=="string"&&(s.from=A(r.fromFile,t)),typeof r.risk=="string"&&(s.risk=r.risk),typeof r.warning=="string"&&(s.warning=r.warning),l(r.saferAlternative)){const f=We([r.saferAlternative],n,t)[0];f&&(s.saferAlternative=f)}return s}).filter(r=>typeof r.symbol=="string"):[]}function Ln(e){return(Array.isArray(e.nonExportedImports)?e.nonExportedImports.filter(l):[]).map(t=>{const r={code:t.code??"MODULE_PLAN_BOUNDARY_WARNING",from:t.from??"",source:t.source??"",usage:t.usage??"unknown",symbols:Array.isArray(t.symbols)?t.symbols:[]};return Array.isArray(t.suggestedFixes)&&t.suggestedFixes.length>0&&(r.suggestedFixes=t.suggestedFixes),typeof t.hint=="string"&&(r.hint=t.hint),r})}function Tn(e){const n={};return typeof e.file=="string"&&(n.file=e.file),Array.isArray(e.exports)&&(n.exports=e.exports.length),n}function Pn(e){const n=new Set,t=Array.isArray(e.blocking)?e.blocking.filter(l):[];for(const r of t)typeof r.from=="string"&&r.from&&n.add(r.from),typeof r.source=="string"&&r.source&&n.add(r.source);return Array.from(n)}function Dn(e){return!l(e)||!Array.isArray(e.nonExportedImports)?[]:e.nonExportedImports.filter(l).map(n=>{const t=typeof n.from=="string"?n.from:"",r=typeof n.source=="string"?n.source:"",s=Array.isArray(n.symbols)?n.symbols.filter(i=>typeof i=="string"):[];return t&&r&&s.length>0?`${t} imports non-exported ${s.join(", ")} from ${r}`:""}).filter(n=>n!=="")}function Fn(e,n,t){if(!Array.isArray(e))return{};const r={};for(const s of e){if(!l(s)||typeof s.targetFile!="string")continue;const i=A(s.targetFile,t),o={owns:C(s.symbols,n)},f=Hn(s.imports,n,t);Object.keys(f).length>0&&(o.uses=f);const a=C(s.internalDependencies,n);a.length>0&&(o.internalDeps=a);const c=Vn(s.unassignedDependencies,n);Object.keys(c).length>0&&(o.unassigned=c),r[i]=o}return r}function jn(e,n,t){return Array.isArray(e)?e.filter(l).filter(r=>typeof r.targetFile=="string").map(r=>{const s={file:A(String(r.targetFile),t),summary:Nn(r,n,t)},i=Gn(r.unassignedDependencies);return i!==""&&(s.warning=`unassigned ${i}`),s}):[]}function Nn(e,n,t){const r=Je(e.symbols,n,!0),s=Je(e.symbols,n,!1),i=Bn(e.imports,n,t),o=C(e.internalDependencies,n).length,f=[`exports ${q(r,4)||"none"}`];return s.length>0&&f.push(`private ${q(s,3)}`),i!==""&&f.push(`imports ${i}`),o>0&&f.push(`internalDeps ${o}`),f.join("; ")}function Je(e,n,t){return Array.isArray(e)?e.filter(l).filter(r=>r.exported===!0===t).map(r=>T(r,n)).filter(r=>r!==""):[]}function Bn(e,n,t){if(!l(e))return"";const r=[],s={typeOnly:"type",value:"run",unclassified:"unclassified"};for(const i of["typeOnly","value","unclassified"]){const o=Un(e[i],n,t);o!==""&&r.push(`${s[i]} ${o}`)}return r.join("; ")}function Un(e,n,t){if(!Array.isArray(e))return"";const r=e.filter(l).filter(s=>typeof s.targetFile=="string").map(s=>{const i=A(String(s.targetFile),t),o=C(s.symbols,n).filter(f=>typeof f=="string");return`${i}: ${q(o,3)||"none"}`});return q(r,2,"more imports")}function Gn(e){if(!l(e))return"";const n=[];for(const t of["typeOnly","value","unclassified"]){const r=e[t];Array.isArray(r)&&r.length>0&&n.push(`${t} ${r.length}`)}return n.join("; ")}function q(e,n,t="more"){if(e.length===0)return"";const r=e.slice(0,n),s=e.length-r.length;return s>0?`${r.join(", ")}, +${s} ${t}`:r.join(", ")}function Hn(e,n,t){if(!l(e))return{};const r={},s={typeOnly:"type",value:"run",unclassified:"unclassified"};for(const i of["typeOnly","value","unclassified"]){const o=qn(e[i],n,t);Object.keys(o).length>0&&(r[s[i]]=o)}return r}function qn(e,n,t){if(!Array.isArray(e))return{};const r={};for(const s of e)!l(s)||typeof s.targetFile!="string"||(r[A(s.targetFile,t)]=C(s.symbols,n));return r}function Vn(e,n){if(!l(e))return{};const t={};for(const r of["typeOnly","value","unclassified"]){const s=C(e[r],n);s.length>0&&(t[r]=s)}return t}function Kn(e,n){const t={};return typeof e.file=="string"&&(t.file=A(e.file,n)),Array.isArray(e.exports)&&e.exports.length>0&&(t.exports=e.exports.filter(r=>typeof r=="string").map(r=>r.match(/from\s+"([^"]+)"/)?.[1]??r)),t}function zn(e,n,t){const r={};typeof e.dir=="string"&&(r.dir=A(e.dir,n));const s=[];let i=0,o=0,f=0;if(Array.isArray(e.files)){const c={};for(const u of e.files){if(!l(u)||typeof u.targetFile!="string"||typeof u.previewFile!="string")continue;i+=1;const p=A(u.targetFile,n),d=g(u.lineCount);c[A(u.targetFile,n)]={file:A(u.previewFile,n),lines:d},d>=vt&&s.push(`${p} ${d}l`)}Object.keys(c).length>0&&(r.files=c)}l(e.facade)&&typeof e.facade.previewFile=="string"&&(o=g(e.facade.lineCount),r.facade={file:A(e.facade.previewFile,n),lines:o}),l(e.patch)&&typeof e.patch.file=="string"&&(f=g(e.patch.lineCount),r.patch={file:A(e.patch.file,n),lines:f},f>=xt&&s.push(`patch ${f}l`)),r.summary=Wn(i,o,f,t),s.length>0&&(r.large=s);const a=Jn(t);return a.length>0&&(r.warnings=a),r.next=Yn(t,s.length>0),r}function Wn(e,n,t,r){const s=[`${e} ${e===1?"file":"files"}`];return n>0&&s.push(`facade ${n}l`),t>0&&s.push(`patch ${t}l`),s.push(ce(r)?"cycles detected":"cycles none"),s.join("; ")}function Jn(e){return ce(e)?["runtime cycles detected"]:[]}function Yn(e,n){return ce(e)?["fix module plan before applying","rerun modulePlan"]:[n?"check summary/api/cycles/imports before reading large preview artifacts":"check summary/api/cycles/imports","read targeted preview artifacts only if a warning/check points there","use top-level next for apply/revise action"]}function ce(e){return Array.isArray(e.cycles)&&e.cycles.length>0}function Zn(e){const n=Array.isArray(e.modules)?e.modules.filter(l):[];if(n.length===0)return"";const t=n.reduce((o,f)=>o+(Array.isArray(f.symbols)?f.symbols.length:0),0),r=n.reduce((o,f)=>o+Xn(f.imports),0),s=l(e.facade)&&Array.isArray(e.facade.exports)?e.facade.exports.length:0,i=[`${t} declarations moved unchanged`,`${r} imports generated`];return s>0&&i.push(`facade exports ${s}`),i.join("; ")}function Xn(e){if(!l(e))return 0;let n=0;for(const t of["typeOnly","value","unclassified"]){const r=e[t];if(Array.isArray(r))for(const s of r)l(s)&&Array.isArray(s.symbols)&&(n+=s.symbols.length)}return n}function Q(e,n,t){return C(e,n)}function Qn(e,n,t){const r=g(e.memberCount),s=g(e.memberOffset),i=g(e.memberLimit),o=g(e.hiddenMemberCount),f=fe(e.members,n,t,"members"),a=f.length;o>0&&f.push(`+ ${o} hidden members`);const c={members:f};return o>0?(c.count=r,c.page=`${s}..${s+a-1} of ${r}`,c.hint="Use --all to list all members, --offset <n> --limit <n> to page, or inspect code <member> --parent <entity>."):r>K&&(c.count=r),s>0&&o===0&&(c.page=`${s}..${s+f.length-1} of ${r}`),c}function wn(e){const n=g(e.localDeclarationCount),t=Ye(e.reexports);return n===0&&t.length>0?`facade only; ${t.length} ${t.length===1?"re-export":"re-exports"}; 0 local declarations`:n===0?"0 local declarations":`${n} local ${n===1?"declaration":"declarations"}; ${t.length} ${t.length===1?"re-export":"re-exports"}`}function Ye(e){return Array.isArray(e)?e.filter(l).map(n=>typeof n.module=="string"?n.module:"").filter(n=>n!==""):[]}function ae(e,n,t,r){const s=T(e,n),i=typeof e.signature=="string"?e.signature:"",o=t.includeRanges?P(e):"",f=typeof e.sourceModule=="string"?`from ${e.sourceModule}`:"";return r==="file"||r==="exports"?Rn(e,s,i,o,f,r,n):r==="members"?rr(e,s,i,o):s==="constructor"?[o,f,i||s].filter(c=>c!=="").join(" "):[s,o,f,i].filter(c=>c!=="").join(" ")}function Rn(e,n,t,r,s,i,o){const f=typeof e.display=="string"?e.display:"";if(f)return[f,r].filter(y=>y!=="").join(" ");const a=le(e),c=typeof e.exportKind=="string"?e.exportKind:"",u=tr(e,o);if(c==="default"){const x=`${a}${i==="file"?"export default ":"default "}${u||n}${Xe(e,t)}`;return[x,r,ue(x,s)].filter(_=>_!=="").join(" ")}if(c==="exportEquals"){const y=`${a}export = ${u||n}`;return[y,r,ue(y,s)].filter(x=>x!=="").join(" ")}const p=i==="file"&&e.exported===!0?"export ":"",d=Xe(e,t),m=e.iife===!0?`${e.async===!0?" IIFE async":" IIFE"}`:"",h=nr(e),v=`${a}${p}${n}${d}${m}`;return[v,r,h,ue(v,s)].filter(y=>y!=="").join(" ")}function ue(e,n){return n?/\bfrom\s+["']?/.test(e)?"":n:""}function er(e,n,t){const r=typeof e.display=="string"?e.display:"",i=(r||n).match(/\bexport\s+\{\s*(.*?)\s*\}\s+from\s+/);return i?.[1]?i[1]:/^export\s+\*\s+from\s+/.test(r)?"*":e.exportKind==="default"?"default":n.replace(` from ${t}`,"")}function V(e){const n=e.match(/^(.*\bfrom\s+["']([^"']+)["'][^\r\n]*?)\s+from\s+([^\s]+)$/);if(!n)return e;const t=n[2]??"",r=n[3]??"";return Ze(t)===Ze(r)?n[1]??e:e}function Ze(e){return e.replace(/^["']|["']$/g,"")}function le(e){if(!Array.isArray(e.decorators))return"";const n=e.decorators.filter(t=>typeof t=="string"&&t.trim()!=="").join(" ");return n?`${n} `:""}function tr(e,n){return l(e.exportTarget)?T(e.exportTarget,n):""}function Xe(e,n){if(typeof e.overloadCount=="number"&&e.overloadCount>1)return"";const t=typeof e.name=="string"?e.name:"",r=typeof e.kind=="string"?ge(e.kind):null;if(!t||!n||r!=="function"&&r!=="method")return"";const s=n.indexOf(t);if(s<0)return"";const i=n.slice(s+t.length).trim();return i.startsWith("(")?i:""}function nr(e){const n=typeof e.overloadCount=="number"?e.overloadCount:0;return n>1?`overloads=${n}`:""}function rr(e,n,t,r){const s=typeof e.kind=="string"?ge(e.kind):null,i=typeof e.name=="string"?e.name:"";let o=`${le(e)}${t||Qe(n)}`.trim();if(s==="property"&&i){o=`${le(e)}${n}`.trim();const f=sr(t,i);f&&(o+=f)}return[o,r].filter(f=>f!=="").join(" ")}function sr(e,n){if(!e)return"";const t=e.indexOf(n);if(t<0)return"";const r=e.slice(t+n.length).trim();return r.startsWith(":")?r:""}function ir(e,n,t){const r=gr(e,["id","op","ok","code","error"]);if(typeof e.sourceFile=="string"){const s=A(e.sourceFile,n);s!==t&&(r.file=s)}if(e.code==="INSPECT_SYMBOL_NOT_FOUND"){const s=or(e);s&&(r.missingSymbols=[s])}return r}function j(e){return e.code==="INSPECT_SYMBOL_NOT_FOUND"&&E(e).length>0}function E(e){return Array.isArray(e.missingSymbols)?e.missingSymbols.filter(n=>typeof n=="string"&&n.length>0):[]}function or(e){const n=typeof e.error=="string"?e.error:"",t="Symbol not found:";if(!n.startsWith(t))return null;const r=n.slice(t.length).trim();if(!r)return null;const s=r.indexOf(":");return s>0?r.slice(s+1).trim():r}function T(e,n){if(!l(e))return"";if(typeof e.selector=="string"&&e.selector.trim()!=="")return e.selector;const t=typeof e.name=="string"?e.name:"",r=typeof e.kind=="string"?ge(e.kind):null;return t?r==="constructor"?"constructor":r?`${dr(r,n)}${yr(r,n)}${t}`:t:""}function N(e,n){return pe(e)||T(e,n)}function w(e){if(!l(e))return"";const n=Array.isArray(e.path)?e.path.filter(t=>typeof t=="string"&&t.trim()!==""):[];return n.length>0?n.join("."):pe(e)}function pe(e){return l(e)&&typeof e.name=="string"?e.name:""}function Qe(e){const n=e.indexOf("-");if(n>0&&n<=3)return e.slice(n+1);const t=e.indexOf(":");return t>0?e.slice(t+1):e}function we(e,n){return n>K?{[e]:n}:{}}function Re(e,n){return e===1?n:`${n}s`}function et(e,n){return e.localeCompare(n,void 0,{numeric:!0})}function fr(e,n,t){const r=new Set(n?[n]:[]);for(const s of e){typeof s.declaredIn=="string"&&r.add(A(s.declaredIn,t));const i=Array.isArray(s.usedBy)?s.usedBy.filter(l):[];for(const o of i)typeof o.file=="string"&&r.add(A(o.file,t))}return Array.from(r)}function cr(e){const n=ar(e.map(t=>t.replace(/\\/g,"/")));return nt(n)}function tt(){return nt([])}function nt(e){return{aliases:e,compactPath(n){const t=de(n),r=e.find(s=>t===s.prefix||t.startsWith(`${s.prefix}/`));return r?t===r.prefix?r.token:`${r.token}/${t.slice(r.prefix.length+1)}`:t}}}function ar(e){const n=new Map;for(const r of e){const s=de(r).split("/");for(let i=2;i<s.length;i+=1){const o=s.slice(0,i).join("/");o.length>=8&&n.set(o,(n.get(o)??0)+1)}}const t=new Set;return Array.from(n.entries()).map(([r,s])=>{const i=`<${b.basename(r)}>`;return{prefix:r,count:s,token:i,score:Math.max(0,r.length-i.length)*s}}).filter(r=>r.count>=2&&r.score>=12).sort((r,s)=>s.score-r.score||r.prefix.localeCompare(s.prefix)).filter(r=>t.has(r.token)?!1:(t.add(r.token),!0)).slice(0,6).sort((r,s)=>s.prefix.length-r.prefix.length).map(r=>({token:r.token,prefix:r.prefix}))}function ur(e,n){if(e.aliases.length===0)return null;const t=JSON.stringify(n),r={};for(const s of e.aliases)t.includes(s.token)&&(r[s.token]=s.prefix);return Object.keys(r).length>0?r:null}function lr(e){const n=new Map,t=[];for(const r of e){const s=r.startsWith("<")?r.indexOf(">"):-1;if(s<=0){t.push(r);continue}const i=r.indexOf("/",s);if(i<0){t.push(r);continue}const o=r.slice(0,i),f=r.slice(i+1),a=n.get(o)??[];a.push(f),n.set(o,a)}return[...Array.from(n.entries()).map(([r,s])=>s.length===1?`${r}/${s[0]}`:`${r}/: ${s.join(", ")}`),...t].sort()}function de(e){return e.replace(/\\/g,"/")}function ye(e,n,t){const r=e.indexOf(n);if(r<=0)return null;const s=e.slice(0,r).trim(),i=e.slice(r+n.length).trim();if(!s||!i)return null;const o=pr(s,t);return o?{raw:e,symbolName:i,symbolKind:o}:null}function pr(e,n){const t=e.toLowerCase();return rt(t)?t:Object.entries(n.entityKindAliases).find(([,s])=>s===e)?.[0]??null}function dr(e,n){return st(e)?n.entityKindAliases[e]:e}function yr(e,n){return st(e)?n.selectorSeparator:":"}function ge(e){const n=e.toLowerCase();return rt(n)?n:null}function rt(e){return At.includes(e)}function st(e){return pt.ENTITY_KIND_IDS.includes(e)}function gr(e,n){const t={};for(const r of n)e[r]!==void 0&&(t[r]=e[r]);return t}function mr(e,n){const t=e.filter(l).map(s=>typeof s.sourceFile=="string"?A(s.sourceFile,n):null).filter(s=>!!s),r=Array.from(new Set(t));return r.length===1?r[0]??null:null}function A(e,n){const t=b.isAbsolute(e)?e:b.resolve(n.cwd,e),r=b.relative(n.cwd,t),i=(r&&!r.startsWith("..")&&!b.isAbsolute(r)?r:e).replace(/\\/g,"/"),o=(0,ht.compactDisplayPathWithMatch)(n.cwd,t,n.displayPathAliases??[]);return o.alias&&n.pathAliasHints&&(n.pathAliasHints.some(a=>a.alias===o.alias.token&&a.original===i&&a.display===o.displayPath)||n.pathAliasHints.push({alias:o.alias.token,original:i,display:o.displayPath})),o.displayPath}function hr(e,n){const t=b.resolve(n.cwd),r=t.replace(/\\/g,"/");return e.replaceAll(`${t}\\`,"").replaceAll(`${r}/`,"").replace(/\\/g,"/")}function it(e,n,t){const r=b.isAbsolute(n)?n:b.resolve(e,n);return U.mkdirSync(b.dirname(r),{recursive:!0}),U.writeFileSync(r,t,"utf8"),b.relative(e,r).replace(/\\/g,"/")}function ot(e,n,t,r,s){const i=typeof r.sourceFile=="string"&&b.extname(r.sourceFile)||".ts",o=(0,$.saveSessionOutputText)(e,n,t,s,i);return{saved:o.saved,last:o.last}}function P(e,n){if(!l(e)||!l(e.range))return"";const t=ft(e.range,"start"),r=ft(e.range,"end");if(!t||!r)return"";const s=t.line+1,i=r.line+1;return s===i?`@${s}`:`@${s}..${i}`}function ft(e,n){const t=e[n];return!l(t)||typeof t.line!="number"?null:{line:t.line}}function g(e){return typeof e=="number"?e:0}function l(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var H=exports&&exports.__createBinding||(Object.create?(function(n,e,t,i){i===void 0&&(i=t);var o=Object.getOwnPropertyDescriptor(e,t);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,i,o)}):(function(n,e,t,i){i===void 0&&(i=t),n[i]=e[t]})),Q=exports&&exports.__setModuleDefault||(Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e}),I=exports&&exports.__importStar||(function(){var n=function(e){return n=Object.getOwnPropertyNames||function(t){var i=[];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(i[i.length]=o);return i},n(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i=n(e),o=0;o<i.length;o++)i[o]!=="default"&&H(t,e,i[o]);return Q(t,e),t}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.isInspectTreeRequest=J,exports.runInspectTree=Y,exports.buildInspectTreeResult=Z,exports.formatTreeResponse=F;const R=I(require("node:fs")),d=I(require("node:path")),X=require("../shared/agent-text"),y=require("../shared/errors"),E=require("../config/path-display"),A=require("../config/local-config"),O=require("./session-workspace"),K=2,G=80,$=["node_modules/**","**/node_modules/**",".git/**","**/.git/**","dist/**","**/dist/**","build/**","**/build/**","out/**","**/out/**",".tmp/**","**/.tmp/**"];function J(n,e){if(n[0]==="tree")return!0;if(!n.includes("--stdin")||!x(e))return!1;const t=L(e);return t.length>0&&t.some(i=>m(i.op)==="tree")}function Y(n,e,t){const i=(0,E.buildDisplayPathAliases)(n,(0,O.readEffectiveSessionPathAliases)(n)),o=(0,A.resolveLocalCliConfig)(n),r=k(n,e,t,i).map(u=>M(n,u,i,o.config.inspect.tree)),s=r.length===1?r[0]:{results:r};return(0,X.attachAgentText)(s,F(s))}function Z(n,e){const t=(0,E.buildDisplayPathAliases)(n,e.aliases??(0,O.readEffectiveSessionPathAliases)(n)),i={scope:e.scope,only:e.only??[],exclude:e.exclude??[],onlyDirs:e.onlyDirs??!1,noDefaultExclude:!1,noConfigExclude:!1};e.displayScope!==void 0&&(i.displayScope=e.displayScope),e.depth!==void 0&&(i.depth=e.depth),e.minDepth!==void 0&&(i.minDepth=e.minDepth),e.limit!==void 0&&(i.limit=e.limit);const o=b(n,i);return M(n,o,t,(0,A.resolveLocalCliConfig)(n).config.inspect.tree)}function k(n,e,t,i){if(e[0]==="tree")return[w(n,e.slice(1),i)];if(!e.includes("--stdin")||!x(t))throw new y.CliError("INSPECT_TREE_SCOPE_REQUIRED","inspect tree expects a file or directory scope.");const o=L(t);if(o.some(l=>m(l.op)!=="tree"))throw new y.CliError("INSPECT_TREE_MIXED_BATCH_UNSUPPORTED","inspect tree --stdin expects only tree requests.");return o.map((l,r)=>q(n,l,r,i))}function w(n,e,t){const o=e.filter(l=>!l.startsWith("--")&&!ue(e,l))[0];if(!o)throw new y.CliError("INSPECT_TREE_SCOPE_REQUIRED","inspect tree expects a file or directory scope.");return b(n,{scope:o,depth:W(e,"--depth"),minDepth:z(e,"--min-depth")??z(e,"--minDepth"),limit:W(e,"--limit"),only:C(e,"--only"),exclude:[...C(e,"--exclude"),...C(e,"--excludes")],onlyDirs:e.includes("--only-dirs")||e.includes("--onlyDirs"),noDefaultExclude:e.includes("--no-default-exclude")||e.includes("--noDefaultExclude")||e.includes("--ned"),noConfigExclude:e.includes("--no-config-exclude")||e.includes("--noConfigExclude")||e.includes("--nec")},t)}function q(n,e,t,i){const o=m(e.scope)??m(e.file)??m(e.dir)??m(e.directory);if(!o)throw new y.CliError("INSPECT_TREE_SCOPE_REQUIRED",`Inspect tree request at index ${t} requires scope.`);return b(n,{scope:o,depth:P(e.depth),minDepth:N(e.minDepth)??N(e.min_depth),limit:P(e.limit),only:S(e.only)??[],exclude:S(e.exclude)??S(e.excludes)??[],onlyDirs:a(e.onlyDirs)??a(e.only_dirs)??!1,noDefaultExclude:a(e.noDefaultExclude)??a(e.no_default_exclude)??a(e.ned)??!1,noConfigExclude:a(e.noConfigExclude)??a(e.no_config_exclude)??a(e.nec)??!1},i)}function b(n,e,t=[]){const i=e.depth??K,o=e.minDepth??0,l=ce(n,e.scope);if(o>i)throw new y.CliError("INSPECT_TREE_DEPTH_INVALID","inspect tree minDepth must be <= depth.");return{scope:l,displayScope:e.displayScope??(0,E.compactDisplayPath)(n,l,t),depth:i,minDepth:o,limit:e.limit??G,only:e.only,exclude:e.exclude,onlyDirs:e.onlyDirs,noDefaultExclude:e.noDefaultExclude,noConfigExclude:e.noConfigExclude}}function M(n,e,t=[],i={onlyDirs:{exclude:[]},files:{exclude:[]}}){const o=se(e.scope);if(!o)throw new y.CliError("INSPECT_TREE_SCOPE_NOT_FOUND","inspect tree scope was not found.",{scope:B(n,e.scope)});const l=o.isDirectory()?e.scope:d.dirname(e.scope),r=e.displayScope??(0,E.compactDisplayPath)(n,e.scope,t),s=e.onlyDirs?i.onlyDirs:i.files,u=ee(e,s),c=u.only.map(D),f=[...e.noDefaultExclude?[]:$,...u.exclude].map(D),p=j(n,l,e.depth,f).filter(h=>e.onlyDirs?h.kind==="dir":h.kind==="file").filter(h=>c.length===0||T(c,h.relative)).filter(h=>h.depth>=e.minDepth),g=p.slice(0,e.limit),V=ne(n,e,l,r,g,u);return{ok:!0,op:"tree",scope:r,depth:e.depth,minDepth:e.minDepth,onlyDirs:e.onlyDirs,[e.onlyDirs?"dirs":"files"]:p.length,shown:g.length,...e.only.length>0?{only:e.only}:{},...e.exclude.length>0?{exclude:e.exclude}:{},...e.noDefaultExclude?{noDefaultExclude:!0}:{},...e.noConfigExclude?{noConfigExclude:!0}:{},...p.length>g.length?{hidden:p.length-g.length}:{},lines:V}}function ee(n,e){return{only:n.only,exclude:re([...n.noConfigExclude?[]:e.exclude,...n.exclude])}}function j(n,e,t,i){const o=[],l=(r,s)=>{if(s>t)return;const u=R.readdirSync(r,{withFileTypes:!0}).sort((c,f)=>Number(f.isDirectory())-Number(c.isDirectory())||c.name.localeCompare(f.name));for(const c of u){const f=d.join(r,c.name),_=B(n,f),p=c.isDirectory()?"dir":"file";T(i,_)||(o.push({absolute:f,relative:_,depth:s,kind:p}),c.isDirectory()&&l(f,s+1))}};return l(e,1),o}function ne(n,e,t,i,o,l){const r=[`tree ${i.replace(/\\/g,"/")}`];if(e.minDepth>0&&r.push(`depth: ${e.minDepth}..${e.depth}`),e.only.length>0&&r.push(`only: ${e.only.join(", ")}`),e.exclude.length>0&&r.push(`exclude: ${e.exclude.join(", ")}`),e.noDefaultExclude&&r.push("noDefaultExclude: true"),e.noConfigExclude&&r.push("noConfigExclude: true"),e.onlyDirs&&r.push("onlyDirs: true"),r.push(""),o.length===0)return r.push("no matching paths"),r;if(te(r,i,t,o),typeof e.limit=="number"&&e.limit>0&&o.length===e.limit){const s=oe(n,e,t,l);s>o.length&&r.push(`+ ${s-o.length} more paths`)}return r}function te(n,e,t,i){const o=ie(t,i);n.push(`${e.replace(/\\/g,"/").replace(/\/?$/,"/")}`),v(n,o," ")}function ie(n,e){const t=new Map;for(const i of e){const o=d.relative(n,i.absolute).replace(/\\/g,"/").split("/").filter(Boolean);let l=t;for(let r=0;r<o.length;r+=1){const s=o[r];if(r===o.length-1)l.get(s)instanceof Map||l.set(s,i.kind);else{let c=l.get(s);c instanceof Map||(c=new Map,l.set(s,c)),l=c}}}return t}function v(n,e,t){for(const[i,o]of Array.from(e.entries()).sort(([l,r],[s,u])=>+(u instanceof Map)-+(r instanceof Map)||l.localeCompare(s)))o instanceof Map?(n.push(`${t}${i}/`),v(n,o,`${t} `)):o==="dir"?n.push(`${t}${i}/`):n.push(`${t}${i}`)}function oe(n,e,t,i){const o=i.only.map(D),l=[...e.noDefaultExclude?[]:$,...i.exclude].map(D);return j(n,t,e.depth,l).filter(r=>e.onlyDirs?r.kind==="dir":r.kind==="file").filter(r=>o.length===0||T(o,r.relative)).filter(r=>r.depth>=e.minDepth).length}function F(n){if(Array.isArray(n.results)){const e=n.results.filter(x).map(t=>Array.isArray(t.lines)?t.lines.filter(i=>typeof i=="string").join(`
|
|
2
2
|
`):"").filter(Boolean);return e.length>0?e.join(`
|
|
3
3
|
|
|
4
4
|
`):null}return Array.isArray(n.lines)?n.lines.filter(e=>typeof e=="string").join(`
|
|
5
|
-
`):null}function
|
|
5
|
+
`):null}function L(n){return Array.isArray(n.requests)?n.requests.filter(x):[n]}function D(n){const e=n.replace(/\\/g,"/").replace(/^\.?\//,"");let t="";for(let i=0;i<e.length;i+=1){const o=e[i];if(o==="*"){e[i+1]==="*"?(t+=".*",i+=1):t+="[^/]*";continue}t+=le(o)}return new RegExp(`^${t}$`)}function T(n,e){return n.some(t=>t.test(e)||t.test(`${e}/`))}function re(n){return Array.from(new Set(n))}function le(n){return n.replace(/[|\\{}()[\]^$+?.]/g,"\\$&")}function se(n){try{return R.statSync(n)}catch{return null}}function ce(n,e){return d.normalize(d.isAbsolute(e)?e:d.resolve(n,e))}function B(n,e){const t=d.relative(n,e);return(t&&!t.startsWith("..")&&!d.isAbsolute(t)?t:e).replace(/\\/g,"/")}function U(n,e){const t=n.indexOf(e);if(t<0)return null;const i=n[t+1];return i&&!i.startsWith("--")?i:null}function C(n,e){const t=[];for(let i=0;i<n.length;i+=1){if(n[i]!==e)continue;const o=n[i+1];o&&!o.startsWith("--")&&(t.push(...o.split(",").map(l=>l.trim()).filter(Boolean)),i+=1)}return t}function ue(n,e){const t=n.indexOf(e);return t>0&&n[t-1]?.startsWith("--")===!0}function W(n,e){return P(U(n,e))}function z(n,e){return N(U(n,e))}function P(n){const e=typeof n=="number"?n:typeof n=="string"?Number(n):NaN;return Number.isInteger(e)&&e>0?e:null}function N(n){const e=typeof n=="number"?n:typeof n=="string"?Number(n):NaN;return Number.isInteger(e)&&e>=0?e:null}function m(n){return typeof n=="string"&&n.length>0?n:null}function S(n){return typeof n=="string"&&n.length>0?n.split(",").map(e=>e.trim()).filter(Boolean):Array.isArray(n)?n.filter(e=>typeof e=="string"&&e.length>0):null}function a(n){if(typeof n=="boolean")return n;if(typeof n!="string")return null;const e=n.trim().toLowerCase();return e==="true"?!0:e==="false"?!1:null}function x(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}
|