@automaton-labs/aib 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/dist/bin/cli.js +2 -2
  2. package/dist/commands/config-command.js +2 -1
  3. package/dist/commands/config-output.js +10 -8
  4. package/dist/commands/doctor.js +2 -1
  5. package/dist/commands/help-command.js +7 -3
  6. package/dist/commands/inspect-format.js +1 -1
  7. package/dist/commands/quick-read.js +8 -8
  8. package/dist/commands/result-view.js +5 -5
  9. package/dist/commands/session-workspace.js +8 -8
  10. package/dist/config/workspace-root.js +3 -3
  11. package/dist/help/bootstrap.md +92 -91
  12. package/dist/help/docs/config-setup.aliases.md +56 -0
  13. package/dist/help/docs/config-setup.excludes.md +45 -0
  14. package/dist/help/docs/config-setup.import-normalize.md +86 -0
  15. package/dist/help/docs/config-setup.import-rules.md +96 -0
  16. package/dist/help/docs/config-setup.tsconfigs.md +33 -0
  17. package/dist/help/docs/first-setup.md +63 -48
  18. package/dist/help/docs/help-format.md +4 -7
  19. package/dist/help/docs/help-protocol.md +26 -0
  20. package/dist/help/docs/inspect.cycles.md +38 -0
  21. package/dist/help/docs/inspect.md +1 -0
  22. package/dist/help/docs/modulePlan.md +3 -0
  23. package/dist/help/docs/move.md +3 -0
  24. package/dist/help/docs/mutation.md +3 -0
  25. package/dist/help/docs/patterns.md +7 -118
  26. package/dist/help/docs/qr.md +6 -2
  27. package/dist/help/docs/quick-map.md +30 -0
  28. package/dist/help/docs/reveal.md +30 -0
  29. package/dist/help/dsl/bootstrap.md +92 -91
  30. package/dist/help/dsl/docs/config-setup.aliases.md +56 -0
  31. package/dist/help/dsl/docs/config-setup.excludes.md +45 -0
  32. package/dist/help/dsl/docs/config-setup.import-normalize.md +86 -0
  33. package/dist/help/dsl/docs/config-setup.import-rules.md +96 -0
  34. package/dist/help/dsl/docs/config-setup.tsconfigs.md +33 -0
  35. package/dist/help/dsl/docs/first-setup.md +63 -48
  36. package/dist/help/dsl/docs/help-format.md +4 -7
  37. package/dist/help/dsl/docs/help-protocol.md +26 -0
  38. package/dist/help/dsl/docs/inspect.cycles.md +38 -0
  39. package/dist/help/dsl/docs/inspect.md +1 -0
  40. package/dist/help/dsl/docs/modulePlan.md +3 -0
  41. package/dist/help/dsl/docs/move.md +3 -0
  42. package/dist/help/dsl/docs/mutation.md +3 -0
  43. package/dist/help/dsl/docs/patterns.md +7 -118
  44. package/dist/help/dsl/docs/qr.md +6 -2
  45. package/dist/help/dsl/docs/quick-map.md +30 -0
  46. package/dist/help/dsl/docs/reveal.md +30 -0
  47. package/dist/help/dsl/full.md +92 -91
  48. package/dist/help/dsl/topics/config-setup.aliases.md +54 -0
  49. package/dist/help/dsl/topics/config-setup.excludes.md +43 -0
  50. package/dist/help/dsl/topics/config-setup.import-normalize.md +84 -0
  51. package/dist/help/dsl/topics/config-setup.import-rules.md +94 -0
  52. package/dist/help/dsl/topics/config-setup.tsconfigs.md +31 -0
  53. package/dist/help/dsl/topics/first-setup.md +63 -48
  54. package/dist/help/dsl/topics/help-format.md +4 -7
  55. package/dist/help/dsl/topics/help-protocol.md +24 -0
  56. package/dist/help/dsl/topics/inspect.cycles.md +36 -0
  57. package/dist/help/dsl/topics/inspect.md +1 -0
  58. package/dist/help/dsl/topics/modulePlan.md +3 -0
  59. package/dist/help/dsl/topics/move.md +3 -0
  60. package/dist/help/dsl/topics/mutation.md +3 -0
  61. package/dist/help/dsl/topics/patterns.md +7 -118
  62. package/dist/help/dsl/topics/qr.md +6 -2
  63. package/dist/help/dsl/topics/quick-map.md +28 -0
  64. package/dist/help/dsl/topics/reveal.md +28 -0
  65. package/dist/help/full.md +92 -91
  66. package/dist/help/help-meta.json +55 -19
  67. package/dist/help/index.md +54 -0
  68. package/dist/help/json/bootstrap.md +92 -91
  69. package/dist/help/json/docs/config-setup.aliases.md +56 -0
  70. package/dist/help/json/docs/config-setup.excludes.md +45 -0
  71. package/dist/help/json/docs/config-setup.import-normalize.md +86 -0
  72. package/dist/help/json/docs/config-setup.import-rules.md +96 -0
  73. package/dist/help/json/docs/config-setup.tsconfigs.md +33 -0
  74. package/dist/help/json/docs/first-setup.md +63 -48
  75. package/dist/help/json/docs/help-format.md +4 -7
  76. package/dist/help/json/docs/help-protocol.md +26 -0
  77. package/dist/help/json/docs/inspect.cycles.md +38 -0
  78. package/dist/help/json/docs/inspect.md +1 -0
  79. package/dist/help/json/docs/modulePlan.md +3 -0
  80. package/dist/help/json/docs/move.md +3 -0
  81. package/dist/help/json/docs/mutation.md +3 -0
  82. package/dist/help/json/docs/patterns.md +7 -118
  83. package/dist/help/json/docs/qr.md +6 -2
  84. package/dist/help/json/docs/quick-map.md +30 -0
  85. package/dist/help/json/docs/reveal.md +30 -0
  86. package/dist/help/json/full.md +92 -91
  87. package/dist/help/json/topics/config-setup.aliases.md +54 -0
  88. package/dist/help/json/topics/config-setup.excludes.md +43 -0
  89. package/dist/help/json/topics/config-setup.import-normalize.md +84 -0
  90. package/dist/help/json/topics/config-setup.import-rules.md +94 -0
  91. package/dist/help/json/topics/config-setup.tsconfigs.md +31 -0
  92. package/dist/help/json/topics/first-setup.md +63 -48
  93. package/dist/help/json/topics/help-format.md +4 -7
  94. package/dist/help/json/topics/help-protocol.md +24 -0
  95. package/dist/help/json/topics/inspect.cycles.md +36 -0
  96. package/dist/help/json/topics/inspect.md +1 -0
  97. package/dist/help/json/topics/modulePlan.md +3 -0
  98. package/dist/help/json/topics/move.md +3 -0
  99. package/dist/help/json/topics/mutation.md +3 -0
  100. package/dist/help/json/topics/patterns.md +7 -118
  101. package/dist/help/json/topics/qr.md +6 -2
  102. package/dist/help/json/topics/quick-map.md +28 -0
  103. package/dist/help/json/topics/reveal.md +28 -0
  104. package/dist/help/topics/config-setup.aliases.md +54 -0
  105. package/dist/help/topics/config-setup.excludes.md +43 -0
  106. package/dist/help/topics/config-setup.import-normalize.md +84 -0
  107. package/dist/help/topics/config-setup.import-rules.md +94 -0
  108. package/dist/help/topics/config-setup.tsconfigs.md +31 -0
  109. package/dist/help/topics/first-setup.md +63 -48
  110. package/dist/help/topics/help-format.md +4 -7
  111. package/dist/help/topics/help-protocol.md +24 -0
  112. package/dist/help/topics/inspect.cycles.md +36 -0
  113. package/dist/help/topics/inspect.md +1 -0
  114. package/dist/help/topics/modulePlan.md +3 -0
  115. package/dist/help/topics/move.md +3 -0
  116. package/dist/help/topics/mutation.md +3 -0
  117. package/dist/help/topics/patterns.md +7 -118
  118. package/dist/help/topics/qr.md +6 -2
  119. package/dist/help/topics/quick-map.md +28 -0
  120. package/dist/help/topics/reveal.md +28 -0
  121. package/dist/managed-host/serve-web-autostart.js +1 -1
  122. package/dist/managed-host/serve-web-host.cjs +193 -79
  123. package/dist/observability/config.js +1 -1
  124. package/dist/payloads/read-stdin-json.js +1 -1
  125. package/dist/runtime/managed-runtime-provisioning.js +1 -1
  126. package/dist/runtime/run-command.js +1 -1
  127. package/dist/session/server.js +7 -5
  128. package/dist/shared/diagnostic-catalog.js +1 -1
  129. package/dist/shared/errors.js +17 -15
  130. package/dist/shared/stdin-examples.js +3 -0
  131. package/dist/tracing/trace.js +5 -3
  132. package/extension/vscode-refactor-bridge-extension.vsix +0 -0
  133. package/package.json +1 -1
  134. package/runtimes/launcher/linux-x64/aib +0 -0
  135. package/runtimes/launcher/win-x64/aib.exe +0 -0
  136. package/scripts/provision-runtime.cjs +25 -1
@@ -1,29 +1,29 @@
1
- "use strict";var De=exports&&exports.__createBinding||(Object.create?(function(e,t,n,s){s===void 0&&(s=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,s,i)}):(function(e,t,n,s){s===void 0&&(s=n),e[s]=t[n]})),$e=exports&&exports.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),ie=exports&&exports.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(n){var s=[];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[s.length]=i);return s},e(t)};return function(t){if(t&&t.__esModule)return t;var n={};if(t!=null)for(var s=e(t),i=0;i<s.length;i++)s[i]!=="default"&&De(n,t,s[i]);return $e(n,t),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.isSessionHandle=M,exports.runWithSessionOverride=Ue,exports.runSessionWorkspaceCommand=Fe,exports.resolveSessionFileArgument=B,exports.saveSessionOutputJson=qe,exports.saveSessionOutputText=et,exports.saveSessionResultJson=tt,exports.saveSessionResultViewJson=nt,exports.readSessionResultViewJson=st,exports.readSessionResultJson=it,exports.captureSessionInputJson=rt,exports.captureSessionInput=ae,exports.sessionWorkspaceExists=ot,exports.useSessionGuidance=ue,exports.readSessionBooleanPref=at,exports.readSessionNumberPref=ut,exports.readSessionStringPref=ct,exports.readEffectiveSessionPathAliases=lt,exports.readSessionPathAliasOverrides=ft,exports.tryResolveCurrentSessionId=Ut;const l=ie(require("node:fs")),c=ie(require("node:path")),xe=require("node:async_hooks"),E=require("../config/env-vars"),N=require("../config/workspace-root"),b=require("../config/path-aliases"),m=require("../shared/agent-text"),u=require("../shared/errors"),je=c.join(".tmp","aib"),U="sessionDir",Ce="session.json",we="active.json",Re="aib:",Le="s_",Pe="last",Te="_last.json",F=new xe.AsyncLocalStorage,ke=["graph","inspect","code","slice","members","exports","deps","usages","duplicates","execution","rename","move","refactor","modulePlan","imports"],We=["inspect","graph","rename","move","refactor","modulePlan","imports","generic"],O={"guidance.nextLimit":{type:"number",default:2,min:0,max:100,hidden:!0},"diagnostics.hintLimit":{type:"number",default:2,min:0,max:100,hidden:!0},"inspect.code.show":{type:"boolean",default:!0,hidden:!0},"inspect.code.maxNonEmptyLines":{type:"number",default:120,min:1,max:1e4},"inspect.code.meta":{type:"boolean",default:!0,hidden:!0},"inspect.members.maxItems":{type:"number",default:20,min:1,max:1e3},"inspect.members.all":{type:"boolean",default:!1,hidden:!0},"inspect.exports.ranges":{type:"boolean",default:!1,hidden:!0},"inspect.exports.resolveStar":{type:"boolean",default:!1,hidden:!0},"inspect.graph.hubs":{type:"boolean",default:!0},"inspect.graph.entrypoints":{type:"boolean",default:!0},"inspect.graph.leaves":{type:"boolean",default:!0},"inspect.graph.edges":{type:"boolean",default:!0},"inspect.graph.symbols":{type:"boolean",default:!1,hidden:!0},"inspect.graph.symbolUsage":{type:"boolean",default:!1},"inspect.usages.detail":{type:"string",default:"locations",values:["summary","locations","code"],hidden:!0},"inspect.usages.maxLocations":{type:"number",default:12,min:1,max:1e4},"inspect.usages.maxCodeBlocks":{type:"number",default:8,min:1,max:1e4},"inspect.usages.excludeTarget":{type:"boolean",default:!1,hidden:!0}};function M(e){return e.startsWith(Re)}function Ue(e,t){return e?F.run(e,t):t()}function Fe(e,t,n){const s=t[0]??"status",i=(0,N.resolveWorkspaceRoot)(e);if(!i){if(s==="status")return(0,m.attachAgentText)({initialized:!1,active:null,source:"none",available:[],next:"Run aib init"},["session not ready","","No aib.json was found.","Run:","aib init"].join(`
2
- `));(0,N.resolveRequiredWorkspaceRoot)(e)}const r=i?.root??e;if(Rt(r),s==="init")return dt(r,t.slice(1));if(s==="status")return Dt(r);if(s==="list")return St(r);if(s==="use")return ht(r,t.slice(1));if(s==="where")return mt(r,t.slice(1));if(s==="read")return It(r,t.slice(1),n);if(s==="write")return Je(r,t.slice(1),n);if(s==="prefs")return Be(r,t.slice(1),n);if(s==="aliases")return Me(r,t.slice(1),n);if(s==="clear")return Ct(r);throw new u.CliError("UNKNOWN_SESSION_WORKSPACE_COMMAND",`Unknown session workspace command: ${s}`)}function Me(e,t,n){const s=t[0]??"get";if(s==="get"){const i=A(e),r=(0,b.readConfigPathAliases)(e),o=(0,b.normalizePathAliasMap)(i.pathAliases??{},"session path aliases"),a={aliases:(0,b.effectivePathAliases)(e,o),config:r,session:o};return(0,m.attachAgentText)(a,V(a))}if(s==="set"){const i=A(e),r=t.includes("--stdin")?Ve(n):ze(t.slice(1)),o=(0,b.normalizePathAliasMap)(i.pathAliases??{},"session path aliases"),a={};for(const[d,p]of Object.entries(r)){const S=(0,b.normalizePathAliasName)(d,"session path aliases");if(typeof p!="string"||p.trim()==="")throw new u.CliError("INVALID_PATH_ALIAS_TARGET",`session path alias ${d} must be a non-empty path string.`);o[S]=p.trim().replace(/\\/g,"/"),a[S]=o[S]}i.pathAliases=o,g(e,i);const f={updated:a,aliases:(0,b.effectivePathAliases)(e,o)};return(0,m.attachAgentText)(f,V(f))}if(s==="clear"){const i=A(e),r=t.slice(1).filter(d=>!d.startsWith("--")),o=(0,b.normalizePathAliasMap)(i.pathAliases??{},"session path aliases"),a=[];if(r.length===0)a.push(...Object.keys(o).sort()),delete i.pathAliases;else{for(const d of r){const p=(0,b.normalizePathAliasName)(d,"session path aliases");Object.prototype.hasOwnProperty.call(o,p)&&(a.push(p),delete o[p])}Object.keys(o).length>0?i.pathAliases=o:delete i.pathAliases}g(e,i);const f={cleared:a,aliases:(0,b.effectivePathAliases)(e,i.pathAliases??{})};return(0,m.attachAgentText)(f,V(f))}throw new u.CliError("UNKNOWN_SESSION_ALIASES_COMMAND",`Unknown session aliases command: ${s}`,{expected:"aib session aliases get | set | clear"})}function Ve(e){if(!y(e))throw new u.CliError("INVALID_SESSION_ALIASES_STDIN","session aliases set --stdin expects a JSON object.");const t=y(e.aliases)?e.aliases:e,n={};for(const[s,i]of Object.entries(t))typeof i=="string"&&(n[s]=i);return n}function ze(e){if(e.length===0||e.length%2!==0)throw new u.CliError("SESSION_ALIASES_SET_USAGE","Usage: aib session aliases set <name> <path> [<name> <path>...] or session aliases set --stdin");const t={};for(let n=0;n<e.length;n+=2)t[e[n]??""]=e[n+1]??"";return t}function V(e){if(y(e.updated))return re("aliases.updated",e.updated);if(Array.isArray(e.cleared)){const t=e.cleared.filter(n=>typeof n=="string");return t.length>0?["aliases.cleared",...t].join(`
1
+ "use strict";var De=exports&&exports.__createBinding||(Object.create?(function(e,t,n,s){s===void 0&&(s=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,s,i)}):(function(e,t,n,s){s===void 0&&(s=n),e[s]=t[n]})),$e=exports&&exports.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),ie=exports&&exports.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(n){var s=[];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[s.length]=i);return s},e(t)};return function(t){if(t&&t.__esModule)return t;var n={};if(t!=null)for(var s=e(t),i=0;i<s.length;i++)s[i]!=="default"&&De(n,t,s[i]);return $e(n,t),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.isSessionHandle=M,exports.runWithSessionOverride=Ue,exports.runSessionWorkspaceCommand=Fe,exports.resolveSessionFileArgument=B,exports.saveSessionOutputJson=qe,exports.saveSessionOutputText=et,exports.saveSessionResultJson=tt,exports.saveSessionResultViewJson=nt,exports.readSessionResultViewJson=st,exports.readSessionResultJson=it,exports.captureSessionInputJson=rt,exports.captureSessionInput=ae,exports.sessionWorkspaceExists=ot,exports.useSessionGuidance=ue,exports.readSessionBooleanPref=at,exports.readSessionNumberPref=ut,exports.readSessionStringPref=ct,exports.readEffectiveSessionPathAliases=lt,exports.readSessionPathAliasOverrides=ft,exports.tryResolveCurrentSessionId=Ut;const l=ie(require("node:fs")),c=ie(require("node:path")),xe=require("node:async_hooks"),E=require("../config/env-vars"),_=require("../config/workspace-root"),b=require("../config/path-aliases"),m=require("../shared/agent-text"),u=require("../shared/errors"),je=c.join(".tmp","aib"),U="sessionDir",Ce="session.json",we="active.json",Re="aib:",Le="s_",Pe="last",Te="_last.json",F=new xe.AsyncLocalStorage,ke=["graph","inspect","code","slice","members","exports","deps","usages","duplicates","execution","rename","move","refactor","modulePlan","imports"],We=["inspect","graph","rename","move","refactor","modulePlan","imports","generic"],O={"guidance.nextLimit":{type:"number",default:2,min:0,max:100,hidden:!0},"diagnostics.hintLimit":{type:"number",default:2,min:0,max:100,hidden:!0},"inspect.code.show":{type:"boolean",default:!0,hidden:!0},"inspect.code.maxNonEmptyLines":{type:"number",default:120,min:1,max:1e4},"inspect.code.meta":{type:"boolean",default:!0,hidden:!0},"inspect.members.maxItems":{type:"number",default:20,min:1,max:1e3},"inspect.members.all":{type:"boolean",default:!1,hidden:!0},"inspect.exports.ranges":{type:"boolean",default:!1,hidden:!0},"inspect.exports.resolveStar":{type:"boolean",default:!1,hidden:!0},"inspect.graph.hubs":{type:"boolean",default:!0},"inspect.graph.entrypoints":{type:"boolean",default:!0},"inspect.graph.leaves":{type:"boolean",default:!0},"inspect.graph.edges":{type:"boolean",default:!0},"inspect.graph.symbols":{type:"boolean",default:!1,hidden:!0},"inspect.graph.symbolUsage":{type:"boolean",default:!1},"inspect.usages.detail":{type:"string",default:"locations",values:["summary","locations","code"],hidden:!0},"inspect.usages.maxLocations":{type:"number",default:12,min:1,max:1e4},"inspect.usages.maxCodeBlocks":{type:"number",default:8,min:1,max:1e4},"inspect.usages.excludeTarget":{type:"boolean",default:!1,hidden:!0}};function M(e){return e.startsWith(Re)}function Ue(e,t){return e?F.run(e,t):t()}function Fe(e,t,n){const s=t[0]??"status",i=(0,_.resolveWorkspaceRoot)(e);if(!i){if(s==="status")return(0,m.attachAgentText)({initialized:!1,active:null,source:"none",available:[],next:"Run aib help first-setup"},["session not ready","","No aib.json was found.","","If you are a user:","ask your agent to set up AIB for this repo:","aib help first-setup","","If you are an agent:","run:","aib help first-setup","","Then follow the setup from the intended repository root."].join(`
2
+ `));(0,_.resolveRequiredWorkspaceRoot)(e)}const r=i?.root??e;if(Rt(r),s==="init")return dt(r,t.slice(1));if(s==="status")return Dt(r);if(s==="list")return St(r);if(s==="use")return ht(r,t.slice(1));if(s==="where")return mt(r,t.slice(1));if(s==="read")return It(r,t.slice(1),n);if(s==="write")return Je(r,t.slice(1),n);if(s==="prefs")return Be(r,t.slice(1),n);if(s==="aliases")return Me(r,t.slice(1),n);if(s==="clear")return Ct(r);throw new u.CliError("UNKNOWN_SESSION_WORKSPACE_COMMAND",`Unknown session workspace command: ${s}`)}function Me(e,t,n){const s=t[0]??"get";if(s==="get"){const i=A(e),r=(0,b.readConfigPathAliases)(e),o=(0,b.normalizePathAliasMap)(i.pathAliases??{},"session path aliases"),a={aliases:(0,b.effectivePathAliases)(e,o),config:r,session:o};return(0,m.attachAgentText)(a,V(a))}if(s==="set"){const i=A(e),r=t.includes("--stdin")?Ve(n):ze(t.slice(1)),o=(0,b.normalizePathAliasMap)(i.pathAliases??{},"session path aliases"),a={};for(const[d,p]of Object.entries(r)){const S=(0,b.normalizePathAliasName)(d,"session path aliases");if(typeof p!="string"||p.trim()==="")throw new u.CliError("INVALID_PATH_ALIAS_TARGET",`session path alias ${d} must be a non-empty path string.`);o[S]=p.trim().replace(/\\/g,"/"),a[S]=o[S]}i.pathAliases=o,g(e,i);const f={updated:a,aliases:(0,b.effectivePathAliases)(e,o)};return(0,m.attachAgentText)(f,V(f))}if(s==="clear"){const i=A(e),r=t.slice(1).filter(d=>!d.startsWith("--")),o=(0,b.normalizePathAliasMap)(i.pathAliases??{},"session path aliases"),a=[];if(r.length===0)a.push(...Object.keys(o).sort()),delete i.pathAliases;else{for(const d of r){const p=(0,b.normalizePathAliasName)(d,"session path aliases");Object.prototype.hasOwnProperty.call(o,p)&&(a.push(p),delete o[p])}Object.keys(o).length>0?i.pathAliases=o:delete i.pathAliases}g(e,i);const f={cleared:a,aliases:(0,b.effectivePathAliases)(e,i.pathAliases??{})};return(0,m.attachAgentText)(f,V(f))}throw new u.CliError("UNKNOWN_SESSION_ALIASES_COMMAND",`Unknown session aliases command: ${s}`,{expected:"aib session aliases get | set | clear"})}function Ve(e){if(!y(e))throw new u.CliError("INVALID_SESSION_ALIASES_STDIN","session aliases set --stdin expects a JSON object.");const t=y(e.aliases)?e.aliases:e,n={};for(const[s,i]of Object.entries(t))typeof i=="string"&&(n[s]=i);return n}function ze(e){if(e.length===0||e.length%2!==0)throw new u.CliError("SESSION_ALIASES_SET_USAGE","Usage: aib session aliases set <name> <path> [<name> <path>...] or session aliases set --stdin");const t={};for(let n=0;n<e.length;n+=2)t[e[n]??""]=e[n+1]??"";return t}function V(e){if(y(e.updated))return re("aliases.updated",e.updated);if(Array.isArray(e.cleared)){const t=e.cleared.filter(n=>typeof n=="string");return t.length>0?["aliases.cleared",...t].join(`
3
3
  `):"aliases.cleared none"}if(y(e.aliases)){const t=re("aliases",e.aliases).split(`
4
4
  `);return t.length===1&&t.push("none"),t.join(`
5
5
  `)}return null}function re(e,t){const n=[e];for(const[s,i]of Object.entries(t).sort(([r],[o])=>r.localeCompare(o)))n.push(`@${s}/=${String(i)}`);return n.join(`
6
- `)}function Je(e,t,n){const s=t[0]??"",i=t[1]??"";if(!s||!i)throw new u.CliError("SESSION_WRITE_USAGE","Usage: aib session write <kind> <name> --stdin");if(n===void 0)throw new u.CliError("STDIN_REQUIRED","session write expects JSON on stdin and the --stdin flag.");const r=A(e),o=Z(r,s,i);x(o,n);const a=C(r,"inputs",s,i,o);Ne(r,s,n),g(e,r);const f={written:a.handle,file:h(e,o)},d=ue(e,"session.write.from",`Use with --from ${a.handle}`);return d&&(f.next=d),f}function Be(e,t,n){const s=t[0]??"get";if(s==="get"){const i=A(e),r=t.includes("--all"),o=t.slice(1).find(p=>!p.startsWith("--")),a=r?Ye(i):Ze(i.prefs??{}),f=Ke(a,o),d=r?{prefs:f}:{overrides:f,defaults:"omitted; use session prefs get --all"};return(0,m.attachAgentText)(d,z(d))}if(s==="set"){const i=A(e),r=t.includes("--stdin")?He(n):Ge(t.slice(1)),o=i.prefs??{},a={};for(const[d,p]of Object.entries(r)){const S=oe(d),_=Qe(S,p);o[S]=_,a[S]=_}i.prefs=o,g(e,i);const f={updated:a};return(0,m.attachAgentText)(f,z(f))}if(s==="clear"){const i=A(e),r=t.slice(1).filter(d=>!d.startsWith("--")),o=i.prefs??{},a=[];if(r.length===0)a.push(...Object.keys(o).sort()),delete i.prefs;else{for(const d of r){const p=oe(d);Object.prototype.hasOwnProperty.call(o,p)&&(a.push(p),delete o[p])}Object.keys(o).length>0?i.prefs=o:delete i.prefs}g(e,i);const f={cleared:a};return(0,m.attachAgentText)(f,z(f))}throw new u.CliError("UNKNOWN_SESSION_PREFS_COMMAND",`Unknown session prefs command: ${s}`,{expected:"aib session prefs get | set | clear"})}function Ke(e,t){if(!t)return e;const n={};for(const[s,i]of Object.entries(e))(s===t||s.startsWith(`${t}.`))&&(n[s]=i);return n}function z(e){if(y(e.updated))return J("prefs.updated",e.updated);if(Array.isArray(e.cleared)){const t=e.cleared.filter(n=>typeof n=="string");return t.length>0?["prefs.cleared",...t].join(`
6
+ `)}function Je(e,t,n){const s=t[0]??"",i=t[1]??"";if(!s||!i)throw new u.CliError("SESSION_WRITE_USAGE","Usage: aib session write <kind> <name> --stdin");if(n===void 0)throw new u.CliError("STDIN_REQUIRED","session write expects JSON on stdin and the --stdin flag.");const r=A(e),o=Z(r,s,i);x(o,n);const a=C(r,"inputs",s,i,o);Ne(r,s,n),g(e,r);const f={written:a.handle,file:h(e,o)},d=ue(e,"session.write.from",`Use with --from ${a.handle}`);return d&&(f.next=d),f}function Be(e,t,n){const s=t[0]??"get";if(s==="get"){const i=A(e),r=t.includes("--all"),o=t.slice(1).find(p=>!p.startsWith("--")),a=r?Ye(i):Ze(i.prefs??{}),f=Ke(a,o),d=r?{prefs:f}:{overrides:f,defaults:"omitted; use session prefs get --all"};return(0,m.attachAgentText)(d,z(d))}if(s==="set"){const i=A(e),r=t.includes("--stdin")?He(n):Ge(t.slice(1)),o=i.prefs??{},a={};for(const[d,p]of Object.entries(r)){const S=oe(d),N=Qe(S,p);o[S]=N,a[S]=N}i.prefs=o,g(e,i);const f={updated:a};return(0,m.attachAgentText)(f,z(f))}if(s==="clear"){const i=A(e),r=t.slice(1).filter(d=>!d.startsWith("--")),o=i.prefs??{},a=[];if(r.length===0)a.push(...Object.keys(o).sort()),delete i.prefs;else{for(const d of r){const p=oe(d);Object.prototype.hasOwnProperty.call(o,p)&&(a.push(p),delete o[p])}Object.keys(o).length>0?i.prefs=o:delete i.prefs}g(e,i);const f={cleared:a};return(0,m.attachAgentText)(f,z(f))}throw new u.CliError("UNKNOWN_SESSION_PREFS_COMMAND",`Unknown session prefs command: ${s}`,{expected:"aib session prefs get | set | clear"})}function Ke(e,t){if(!t)return e;const n={};for(const[s,i]of Object.entries(e))(s===t||s.startsWith(`${t}.`))&&(n[s]=i);return n}function z(e){if(y(e.updated))return J("prefs.updated",e.updated);if(Array.isArray(e.cleared)){const t=e.cleared.filter(n=>typeof n=="string");return t.length>0?["prefs.cleared",...t].join(`
7
7
  `):"prefs.cleared none"}if(y(e.overrides)){const t=J("prefs",e.overrides).split(`
8
8
  `);return t.length===1&&t.push("no overrides"),typeof e.defaults=="string"&&t.push(e.defaults),t.join(`
9
9
  `)}return y(e.prefs)?J("prefs",e.prefs):null}function J(e,t){const n=[e];for(const[s,i]of Object.entries(t).sort(([r],[o])=>r.localeCompare(o)))n.push(`${s}=${String(i)}`);return n.join(`
10
10
  `)}function He(e){if(!y(e))throw new u.CliError("INVALID_SESSION_PREFS_STDIN","session prefs set --stdin expects a JSON object.");const t=y(e.prefs)?e.prefs:e,n={};for(const[s,i]of Object.entries(t))n[s]=i;return n}function Ge(e){if(e.length===0||e.length%2!==0)throw new u.CliError("SESSION_PREFS_SET_USAGE","Usage: aib session prefs set <key> <value> [<key> <value>...] or session prefs set --stdin");const t={};for(let n=0;n<e.length;n+=2){const s=e[n]??"",i=e[n+1]??"";t[s]=i}return t}function oe(e){if(Object.prototype.hasOwnProperty.call(O,e))return e;throw new u.CliError("UNKNOWN_SESSION_PREF",`Unknown session preference: ${e}`,{available:Object.keys(O)})}function Qe(e,t){const n=O[e];if(n.type==="boolean"){if(typeof t=="boolean")return t;if(typeof t=="string"){const i=t.trim().toLowerCase();if(i==="true")return!0;if(i==="false")return!1}throw new u.CliError("INVALID_SESSION_PREF_VALUE",`${e} expects true or false.`)}if(n.type==="string"){if(typeof t!="string")throw new u.CliError("INVALID_SESSION_PREF_VALUE",`${e} expects one of: ${n.values.join(", ")}.`);const i=t.trim();if(!n.values.includes(i))throw new u.CliError("INVALID_SESSION_PREF_VALUE",`${e} expects one of: ${n.values.join(", ")}.`);return i}const s=typeof t=="number"?t:typeof t=="string"?Number(t):NaN;if(!Number.isInteger(s)||s<n.min||s>n.max)throw new u.CliError("INVALID_SESSION_PREF_VALUE",`${e} expects an integer from ${n.min} to ${n.max}.`);return s}function Ye(e){const t={};for(const n of Object.keys(O)){const s=O[n];"hidden"in s&&s.hidden||(s.type==="boolean"?t[n]=ce(e,n,s.default):s.type==="number"?t[n]=K(e,n,s.default):t[n]=le(e,n,s.default))}return t}function Ze(e){const t={};for(const[n,s]of Object.entries(e))Xe(n)||(t[n]=s);return t}function Xe(e){if(!Object.prototype.hasOwnProperty.call(O,e))return!1;const t=O[e];return"hidden"in t&&t.hidden===!0}function B(e,t){if(!M(t))return t;const n=A(e),s=Oe(t),i=s.scope==="input"?n.inputs:n.outputs,r=s.scope==="input"?s.kind:s.scope,o=i[r],a=s.name==="last"?o?.last:s.name,f=a?o?.items[a]:void 0;if(!f)throw new u.CliError("SESSION_HANDLE_NOT_FOUND",`Session handle not found: ${t}`,{handle:t,sessionDir:h(e,n.rootDir)});return f.file}function qe(e,t,n,s){const i=A(e),r=Ae(i,t,n,".json");l.mkdirSync(c.dirname(r),{recursive:!0}),l.writeFileSync(r,`${JSON.stringify(s,null,2)}
11
- `);const o=C(i,"outputs",t,n,r);return g(e,i),{saved:o.handle,last:`aib:${t}:last`,file:h(e,r)}}function et(e,t,n,s,i=".txt"){const r=A(e),o=Ae(r,t,n,i);l.mkdirSync(c.dirname(o),{recursive:!0}),l.writeFileSync(o,s);const a=C(r,"outputs",t,n,o);return g(e,r),{saved:a.handle,last:`aib:${t}:last`,file:h(e,o)}}function tt(e,t,n,s){const i=v(e);if(!i)return null;const r=I(t),o=I(n),a=c.join(i.rootDir,"outputs","result",r,`${o}.json`);return x(a,s),{saved:`aib:result:${r}:${o}`,file:h(e,a)}}function nt(e,t,n){const s=v(e);if(!s)return null;const i=I(t),r=c.join(s.rootDir,"outputs","result",`${i}.json`);return x(r,n),{saved:`aib:${i}`,file:h(e,r)}}function st(e,t){const n=A(e),s=I(t),i=c.join(n.rootDir,"outputs","result",`${s}.json`);if(!l.existsSync(i))throw new u.CliError("SESSION_RESULT_NOT_FOUND",`Result handle not found: aib:${s}`,{handle:`aib:${s}`,sessionDir:h(e,n.rootDir)});const r=JSON.parse(l.readFileSync(i,"utf8"));if(!r||typeof r!="object"||Array.isArray(r))throw new u.CliError("INVALID_SESSION_RESULT",`Result artifact is not a JSON object: aib:${s}`);return r}function it(e,t,n){const s=A(e),i=I(t),r=I(n),o=c.join(s.rootDir,"outputs","result",i,`${r}.json`);if(!l.existsSync(o))throw new u.CliError("SESSION_RESULT_NOT_FOUND",`Result handle not found: aib:result:${i}:${r}`,{handle:`aib:result:${i}:${r}`,sessionDir:h(e,s.rootDir)});const a=JSON.parse(l.readFileSync(o,"utf8"));if(!a||typeof a!="object"||Array.isArray(a))throw new u.CliError("INVALID_SESSION_RESULT",`Result artifact is not a JSON object: aib:result:${i}:${r}`);return a}function rt(e,t,n,s){return ae(e,t,n,s,{format:"json",text:JSON.stringify(s,null,2)})}function ae(e,t,n,s,i){const r=v(e);if(!r)return null;const o=i??{format:"json",text:JSON.stringify(s,null,2)},a=o.format==="dsl"?Z(r,t,n,".dsl"):Z(r,t,n,".json");o.format==="dsl"?(_e(a,o.text),x(Ft(r,t,n),s)):x(a,s);const f=C(r,"inputs",t,n,a);return Ne(r,t,s,o),g(e,r),{handle:f.handle,file:h(e,a)}}function ot(e){return l.existsSync(L(e))}function ue(e,t,n,s=-1){const i=v(e);if(!i)return n;const r=s>=0?s:K(i,"guidance.nextLimit",2),o=i.guidance??{},a=o[t]??{shown:0,limit:r};if(a.limit=r,a.shown>=a.limit){o[t]=a,i.guidance=o,g(e,i);return}return a.shown+=1,o[t]=a,i.guidance=o,g(e,i),n}function at(e,t,n){const s=v(e),i=O[t],r=typeof n=="boolean"?n:i.type==="boolean"?i.default:!1;return s?ce(s,t,r):r}function ut(e,t,n){const s=v(e),i=O[t],r=typeof n=="number"?n:i.type==="number"?i.default:0;return s?K(s,t,r):r}function ct(e,t,n){const s=v(e),i=O[t],r=typeof n=="string"?n:i.type==="string"?i.default:"";return s?le(s,t,r):r}function lt(e){try{const t=v(e);return(0,b.effectivePathAliases)(e,t?.pathAliases??{})}catch(t){if(t instanceof u.CliError&&t.code==="MULTIPLE_AIB_SESSIONS")return(0,b.effectivePathAliases)(e,{});throw t}}function ft(e){try{const t=v(e);return(0,b.normalizePathAliasMap)(t?.pathAliases??{},"session path aliases")}catch(t){if(t instanceof u.CliError&&t.code==="MULTIPLE_AIB_SESSIONS")return{};throw t}}function ce(e,t,n){const s=e.prefs?.[t];return typeof s=="boolean"?s:n}function K(e,t,n){const s=e.prefs?.[t];return typeof s=="number"&&Number.isFinite(s)?s:n}function le(e,t,n){const s=e.prefs?.[t];return typeof s=="string"?s:n}function dt(e,t){const n=w(t,"--dir"),s=Q(e,n,!0),i=w(t,"--name"),r=$(i??Y()??Jt()),o=c.join(s.rootDir,r),a=new Date().toISOString(),d=R(e,r)??{version:1,sessionId:r,cwd:c.resolve(e),rootDir:o,createdAt:a,updatedAt:a,outputs:{},inputs:{},guidance:{}};d.sessionId=r,d.rootDir=o,d.updatedAt=a,me(d),g(e,d),be(e,d,!0);const p=D(e),S=p?Object.keys(p.sessions).length:1,_={session:r,dir:h(e,d.rootDir),sessionDir:h(e,s.rootDir),sessionDirSource:s.source,sessionCount:S,bind:`${E.CLI_ENV.session}=${r}`,next:S===1?"Run AIB commands without -s for now. AIB will tell you if multiple sessions exist.":`Use aib -s ${r} <command> or set ${E.CLI_ENV.session}=${r}.`};return s.ignoredRequestedDir&&(_.note=`${U} from aib.json is in effect; --dir was ignored.`,_.requestedDir=s.ignoredRequestedDir),(0,m.attachAgentText)(_,pt(_))}function pt(e){const t=String(e.session??""),n=String(e.dir??""),s=typeof e.sessionCount=="number"?e.sessionCount:1,i=[`session ready: ${t}`,""];typeof e.note=="string"&&e.note&&(i.push("aib.json sessionDir is in effect; --dir was ignored."),i.push("Next time do not use --dir when creating a session."),i.push(""));const r=n.replace(/[\\/]+$/,"");return i.push(`outputs: ${r}/outputs`),i.push(`inputs: ${r}/inputs`),i.push(""),s===1?(i.push("Only one AIB session exists in this repo."),i.push("You can run AIB commands without -s for now."),i.push("AIB will tell you if multiple sessions exist and you need to choose one.")):(i.push("Multiple AIB sessions exist in this repo."),i.push("Use this session explicitly:"),i.push(`aib -s ${t} <command>`),i.push(""),i.push("Or bind it in this shell:"),i.push(`${E.CLI_ENV.session}=${t}`)),i.join(`
11
+ `);const o=C(i,"outputs",t,n,r);return g(e,i),{saved:o.handle,last:`aib:${t}:last`,file:h(e,r)}}function et(e,t,n,s,i=".txt"){const r=A(e),o=Ae(r,t,n,i);l.mkdirSync(c.dirname(o),{recursive:!0}),l.writeFileSync(o,s);const a=C(r,"outputs",t,n,o);return g(e,r),{saved:a.handle,last:`aib:${t}:last`,file:h(e,o)}}function tt(e,t,n,s){const i=v(e);if(!i)return null;const r=I(t),o=I(n),a=c.join(i.rootDir,"outputs","result",r,`${o}.json`);return x(a,s),{saved:`aib:result:${r}:${o}`,file:h(e,a)}}function nt(e,t,n){const s=v(e);if(!s)return null;const i=I(t),r=c.join(s.rootDir,"outputs","result",`${i}.json`);return x(r,n),{saved:`aib:${i}`,file:h(e,r)}}function st(e,t){const n=A(e),s=I(t),i=c.join(n.rootDir,"outputs","result",`${s}.json`);if(!l.existsSync(i))throw new u.CliError("SESSION_RESULT_NOT_FOUND",`Result handle not found: aib:${s}`,{handle:`aib:${s}`,sessionDir:h(e,n.rootDir)});const r=JSON.parse(l.readFileSync(i,"utf8"));if(!r||typeof r!="object"||Array.isArray(r))throw new u.CliError("INVALID_SESSION_RESULT",`Result artifact is not a JSON object: aib:${s}`);return r}function it(e,t,n){const s=A(e),i=I(t),r=I(n),o=c.join(s.rootDir,"outputs","result",i,`${r}.json`);if(!l.existsSync(o))throw new u.CliError("SESSION_RESULT_NOT_FOUND",`Result handle not found: aib:result:${i}:${r}`,{handle:`aib:result:${i}:${r}`,sessionDir:h(e,s.rootDir)});const a=JSON.parse(l.readFileSync(o,"utf8"));if(!a||typeof a!="object"||Array.isArray(a))throw new u.CliError("INVALID_SESSION_RESULT",`Result artifact is not a JSON object: aib:result:${i}:${r}`);return a}function rt(e,t,n,s){return ae(e,t,n,s,{format:"json",text:JSON.stringify(s,null,2)})}function ae(e,t,n,s,i){const r=v(e);if(!r)return null;const o=i??{format:"json",text:JSON.stringify(s,null,2)},a=o.format==="dsl"?Z(r,t,n,".dsl"):Z(r,t,n,".json");o.format==="dsl"?(_e(a,o.text),x(Ft(r,t,n),s)):x(a,s);const f=C(r,"inputs",t,n,a);return Ne(r,t,s,o),g(e,r),{handle:f.handle,file:h(e,a)}}function ot(e){return l.existsSync(L(e))}function ue(e,t,n,s=-1){const i=v(e);if(!i)return n;const r=s>=0?s:K(i,"guidance.nextLimit",2),o=i.guidance??{},a=o[t]??{shown:0,limit:r};if(a.limit=r,a.shown>=a.limit){o[t]=a,i.guidance=o,g(e,i);return}return a.shown+=1,o[t]=a,i.guidance=o,g(e,i),n}function at(e,t,n){const s=v(e),i=O[t],r=typeof n=="boolean"?n:i.type==="boolean"?i.default:!1;return s?ce(s,t,r):r}function ut(e,t,n){const s=v(e),i=O[t],r=typeof n=="number"?n:i.type==="number"?i.default:0,o=(0,_.readWorkspaceNumberConfig)(e,t,r);return s?K(s,t,o):o}function ct(e,t,n){const s=v(e),i=O[t],r=typeof n=="string"?n:i.type==="string"?i.default:"";return s?le(s,t,r):r}function lt(e){try{const t=v(e);return(0,b.effectivePathAliases)(e,t?.pathAliases??{})}catch(t){if(t instanceof u.CliError&&t.code==="MULTIPLE_AIB_SESSIONS")return(0,b.effectivePathAliases)(e,{});throw t}}function ft(e){try{const t=v(e);return(0,b.normalizePathAliasMap)(t?.pathAliases??{},"session path aliases")}catch(t){if(t instanceof u.CliError&&t.code==="MULTIPLE_AIB_SESSIONS")return{};throw t}}function ce(e,t,n){const s=e.prefs?.[t];return typeof s=="boolean"?s:n}function K(e,t,n){const s=e.prefs?.[t];return typeof s=="number"&&Number.isFinite(s)?s:n}function le(e,t,n){const s=e.prefs?.[t];return typeof s=="string"?s:n}function dt(e,t){const n=w(t,"--dir"),s=Q(e,n,!0),i=w(t,"--name"),r=$(i??Y()??Jt()),o=c.join(s.rootDir,r),a=new Date().toISOString(),d=R(e,r)??{version:1,sessionId:r,cwd:c.resolve(e),rootDir:o,createdAt:a,updatedAt:a,outputs:{},inputs:{},guidance:{}};d.sessionId=r,d.rootDir=o,d.updatedAt=a,me(d),g(e,d),be(e,d,!0);const p=D(e),S=p?Object.keys(p.sessions).length:1,N={session:r,dir:h(e,d.rootDir),sessionDir:h(e,s.rootDir),sessionDirSource:s.source,sessionCount:S,bind:`${E.CLI_ENV.session}=${r}`,next:S===1?"Run AIB commands without -s for now. AIB will tell you if multiple sessions exist.":`Use aib -s ${r} <command> or set ${E.CLI_ENV.session}=${r}.`};return s.ignoredRequestedDir&&(N.note=`${U} from aib.json is in effect; --dir was ignored.`,N.requestedDir=s.ignoredRequestedDir),(0,m.attachAgentText)(N,pt(N))}function pt(e){const t=String(e.session??""),n=typeof e.sessionCount=="number"?e.sessionCount:1,s=[`session ready: ${t}`,""];return typeof e.note=="string"&&e.note&&(s.push("aib.json sessionDir is in effect; --dir was ignored."),s.push("")),n===1?(s.push("Only one AIB session exists in this repo."),s.push("You can run AIB commands without -s for now."),s.push("AIB will tell you if multiple sessions exist and you need to choose one.")):(s.push("Multiple AIB sessions exist in this repo."),s.push("Use this session explicitly:"),s.push(`aib -s ${t} <command>`),s.push(""),s.push("Or bind it in this shell:"),s.push(`${E.CLI_ENV.session}=${t}`)),s.join(`
12
12
  `)}function St(e){const t=D(e),n=k(e);return{active:n.sessionId??t?.activeSessionId??null,source:n.source,sessions:t?Object.values(t.sessions).sort((s,i)=>s.sessionId.localeCompare(i.sessionId)).map(s=>`${s.sessionId} -> ${h(e,s.rootDir)}`):[]}}function ht(e,t){const n=t[0]??"";if(!n)throw new u.CliError("SESSION_USE_ID_REQUIRED","Usage: aib session use <sessionId>");const s=$(n),i=D(e),r=i?.sessions[s];if(!r)throw new u.CliError("SESSION_NOT_FOUND",`Session not found: ${s}`,{available:i?Object.keys(i.sessions).sort():[]});return T(e,{...i??ge(e),activeSessionId:s}),{session:s,dir:h(e,r.rootDir),bind:`${E.CLI_ENV.session}=${s}`,next:`Use aib -s ${s} <command> or set ${E.CLI_ENV.session}=${s}.`}}function mt(e,t){const n=t[0]??"";if(!n)throw new u.CliError("SESSION_WHERE_HANDLE_REQUIRED","Usage: aib session where <handle>");const s=B(e,n),i={handle:n,file:h(e,s)};return(0,m.attachAgentText)(i,[n,i.file].join(`
13
- `))}function It(e,t,n){if(t.includes("--stdin")){if(!y(n))throw new u.CliError("INVALID_SESSION_READ_STDIN","session read --stdin expects a JSON object payload.");const r=yt(n);if(r.length===1){const a=H(e,r[0]);return(0,m.attachAgentText)(a,G(a))}const o={reads:r.map(a=>gt(e,a))};return(0,m.attachAgentText)(o,G(o))}const s=t[0]??"";if(!s)throw new u.CliError("SESSION_READ_HANDLE_REQUIRED","Usage: aib session read <handle> [--head <n> | --offset <n> --limit <n>]");const i=H(e,{handle:s,...vt(t.slice(1))});return(0,m.attachAgentText)(i,G(i))}function yt(e){if(Array.isArray(e.reads))return e.reads.map((t,n)=>{if(typeof t=="string"){if(!M(t))throw new u.CliError("INVALID_SESSION_READ_ROW",`session read row at index ${n} must be an aib: handle string or an object.`);return{handle:t}}if(!y(t))throw new u.CliError("INVALID_SESSION_READ_ROW",`session read row at index ${n} must be an aib: handle string or an object.`);return fe(t,n)});if(typeof e.handle=="string"||typeof e.read=="string")return[fe(e,0)];throw new u.CliError("INVALID_SESSION_READ_STDIN","Expected { reads: [{ handle }] } or { handle }.")}function fe(e,t){const n=X(e.handle)??X(e.read);if(!n)throw new u.CliError("SESSION_READ_HANDLE_REQUIRED",`session read row at index ${t} requires handle.`);return{handle:n,...e.rawInput===!0?{rawInput:!0}:{},...pe(e,t)}}function gt(e,t){try{return H(e,t)}catch(n){if(n instanceof u.CliError){const s=y(n.details)?n.details:{};return{read:t.handle,error:n.code,...typeof s.next=="string"?{next:s.next}:{}}}return{read:t.handle,error:"UNEXPECTED_ERROR"}}}function H(e,t){Ot(t);const n=Oe(t.handle),s=B(e,t.handle);if(n.scope==="input"&&!t.rawInput){const r=Nt(n.kind,t.handle);return{read:t.handle,file:h(e,s),next:r?`Edit file, then rerun: ${r}`:"Edit file, then rerun the command with --from <handle>."}}if(n.scope==="graph"||n.scope==="usages"){const r=n.scope==="graph"?`aib inspect graph --from-file ${t.handle} --focus <file>`:`aib inspect usages --from-file ${t.handle} --focus <name>`;throw new u.CliError("SESSION_ARTIFACT_NOT_READABLE",`${n.scope} artifacts are reusable indexes, not agent-readable context.`,{handle:t.handle,kind:n.scope,next:r})}if(n.scope==="duplicates"){const r=l.readFileSync(s,"utf8");return{read:t.handle,content:bt(e,t.handle,s,r,t)}}const i=l.readFileSync(s,"utf8");return{read:t.handle,content:At(s,i,t)}}function bt(e,t,n,s,i){const r=Et(e,t,n,s);return i.head!==void 0||i.offset!==void 0||i.limit!==void 0?Se(r,i):r}function Et(e,t,n,s){let i;try{i=JSON.parse(s)}catch{return de(t,n,s)}if(!y(i))return de(t,n,s);const r=[],o=Array.isArray(i.targetPaths)?i.targetPaths.filter(S=>typeof S=="string"&&S!==""):[],a=o.length===1?h(e,o[0]):o.length>1?`${o.length} scopes`:"";r.push(a?`duplicates ${a}`:"duplicates");const f=typeof i.summary=="string"?i.summary:`${j(i.itemCount)} ${te(j(i.itemCount),"name")}`;r.push(f);const d=Array.isArray(i.items)?i.items.filter(y):[];for(const S of d){const _=typeof S.name=="string"?S.name:"",ve=j(S.declarationCount),ne=j(S.variantCount),se=j(S.exactCopyCount);_&&r.push(`${_} x${ve}, ${ne} ${te(ne,"variant")}${se>0?`, exact x${se}`:""}`)}const p=j(i.hiddenItemCount);return p>0&&r.push(`+ ${p} ${te(p,"name")}`),r.push(`raw: aib session where ${t}`),r.join(`
13
+ `))}function It(e,t,n){if(t.includes("--stdin")){if(!y(n))throw new u.CliError("INVALID_SESSION_READ_STDIN","session read --stdin expects a JSON object payload.");const r=yt(n);if(r.length===1){const a=H(e,r[0]);return(0,m.attachAgentText)(a,G(a))}const o={reads:r.map(a=>gt(e,a))};return(0,m.attachAgentText)(o,G(o))}const s=t[0]??"";if(!s)throw new u.CliError("SESSION_READ_HANDLE_REQUIRED","Usage: aib session read <handle> [--head <n> | --offset <n> --limit <n>]");const i=H(e,{handle:s,...vt(t.slice(1))});return(0,m.attachAgentText)(i,G(i))}function yt(e){if(Array.isArray(e.reads))return e.reads.map((t,n)=>{if(typeof t=="string"){if(!M(t))throw new u.CliError("INVALID_SESSION_READ_ROW",`session read row at index ${n} must be an aib: handle string or an object.`);return{handle:t}}if(!y(t))throw new u.CliError("INVALID_SESSION_READ_ROW",`session read row at index ${n} must be an aib: handle string or an object.`);return fe(t,n)});if(typeof e.handle=="string"||typeof e.read=="string")return[fe(e,0)];throw new u.CliError("INVALID_SESSION_READ_STDIN","Expected { reads: [{ handle }] } or { handle }.")}function fe(e,t){const n=X(e.handle)??X(e.read);if(!n)throw new u.CliError("SESSION_READ_HANDLE_REQUIRED",`session read row at index ${t} requires handle.`);return{handle:n,...e.rawInput===!0?{rawInput:!0}:{},...pe(e,t)}}function gt(e,t){try{return H(e,t)}catch(n){if(n instanceof u.CliError){const s=y(n.details)?n.details:{};return{read:t.handle,error:n.code,...typeof s.next=="string"?{next:s.next}:{}}}return{read:t.handle,error:"UNEXPECTED_ERROR"}}}function H(e,t){Ot(t);const n=Oe(t.handle),s=B(e,t.handle);if(n.scope==="input"&&!t.rawInput){const r=Nt(n.kind,t.handle);return{read:t.handle,file:h(e,s),next:r?`Edit file, then rerun: ${r}`:"Edit file, then rerun the command with --from <handle>."}}if(n.scope==="graph"||n.scope==="usages"){const r=n.scope==="graph"?`aib inspect graph --from-file ${t.handle} --focus <file>`:`aib inspect usages --from-file ${t.handle} --focus <name>`;throw new u.CliError("SESSION_ARTIFACT_NOT_READABLE",`${n.scope} artifacts are reusable indexes, not agent-readable context.`,{handle:t.handle,kind:n.scope,next:r})}if(n.scope==="duplicates"){const r=l.readFileSync(s,"utf8");return{read:t.handle,content:bt(e,t.handle,s,r,t)}}const i=l.readFileSync(s,"utf8");return{read:t.handle,content:At(s,i,t)}}function bt(e,t,n,s,i){const r=Et(e,t,n,s);return i.head!==void 0||i.offset!==void 0||i.limit!==void 0?Se(r,i):r}function Et(e,t,n,s){let i;try{i=JSON.parse(s)}catch{return de(t,n,s)}if(!y(i))return de(t,n,s);const r=[],o=Array.isArray(i.targetPaths)?i.targetPaths.filter(S=>typeof S=="string"&&S!==""):[],a=o.length===1?h(e,o[0]):o.length>1?`${o.length} scopes`:"";r.push(a?`duplicates ${a}`:"duplicates");const f=typeof i.summary=="string"?i.summary:`${j(i.itemCount)} ${te(j(i.itemCount),"name")}`;r.push(f);const d=Array.isArray(i.items)?i.items.filter(y):[];for(const S of d){const N=typeof S.name=="string"?S.name:"",ve=j(S.declarationCount),ne=j(S.variantCount),se=j(S.exactCopyCount);N&&r.push(`${N} x${ve}, ${ne} ${te(ne,"variant")}${se>0?`, exact x${se}`:""}`)}const p=j(i.hiddenItemCount);return p>0&&r.push(`+ ${p} ${te(p,"name")}`),r.push(`raw: aib session where ${t}`),r.join(`
14
14
  `)}function de(e,t,n){return[`saved artifact ${e}`,`${n.length} bytes`,`raw: ${t}`].join(`
15
15
  `)}function At(e,t,n){if(n.head!==void 0||n.offset!==void 0||n.limit!==void 0)return Se(t,n);if(c.extname(e).toLowerCase()!==".json")return t;try{return JSON.parse(t)}catch{return t}}function G(e){const t=Array.isArray(e.reads)?e.reads.filter(y):[e];if(t.length===0)return null;const n=[],s=t.length>1;for(const i of t){const r=typeof i.read=="string"?i.read:"",o=i.content,a=_t(o);if(a!==null){s&&r&&n.push(`// ${r}`),n.push(a.trimEnd());continue}if(typeof i.file=="string"){s&&r?n.push(`// ${r}`):r&&n.push(`input ${r}`),n.push(`file: ${i.file}`),typeof i.next=="string"&&n.push(`next: ${i.next}`);continue}const f=typeof i.error=="string"?i.error:"";if(f){s&&r&&n.push(`// ${r}`),n.push(`error: ${f}`),typeof i.next=="string"&&n.push(`next: ${i.next}`);continue}return null}return n.join(`
16
16
  `)}function _t(e){return typeof e=="string"?e:e===void 0?null:JSON.stringify(e,null,2)}function Nt(e,t){return e==="inspect"?`aib inspect --from ${t}`:e==="graph"?`aib inspect graph --from ${t}`:e==="rename"?`aib rename preview --from ${t}`:e==="move"?`aib move toFile preview --from ${t}`:e==="refactor"?`aib refactor batch preview --from ${t}`:e==="modulePlan"?`aib modulePlan preview --from ${t}`:e==="imports"?`aib imports normalize preview --from ${t}`:null}function Ot(e){if(e.head!==void 0&&(e.offset!==void 0||e.limit!==void 0))throw new u.CliError("SESSION_READ_RANGE_CONFLICT","Use either head or offset/limit, not both.")}function vt(e){const t={},n=w(e,"--head"),s=w(e,"--offset"),i=w(e,"--limit");return n!==void 0&&(t.head=n),s!==void 0&&(t.offset=s),i!==void 0&&(t.limit=i),{...e.includes("--raw-input")?{rawInput:!0}:{},...pe(t,0)}}function pe(e,t){const n=q(e.head,`session read row at index ${t} has invalid head.`),s=q(e.offset,`session read row at index ${t} has invalid offset.`),i=zt(e.limit,`session read row at index ${t} has invalid limit.`);return{...n!==void 0?{head:n}:{},...s!==void 0?{offset:s}:{},...i!==void 0?{limit:i}:{}}}function Se(e,t){if(t.head===void 0&&t.offset===void 0&&t.limit===void 0)return e;const n=e.split(/\r?\n/),s=t.head!==void 0?0:t.offset??0,i=t.head!==void 0?t.head:t.limit!==void 0?s+t.limit:void 0;return n.slice(s,i).join(`
17
17
  `)}function Dt(e){const t=D(e),n=k(e),s=t?Object.keys(t.sessions).sort():[];if(n.source==="ambiguous")return(0,m.attachAgentText)({ok:!1,code:"MULTIPLE_AIB_SESSIONS",error:"Multiple AIB sessions exist. Select one explicitly.",available:s,next:`Use aib -s <session> <command> or set ${E.CLI_ENV.session}=<session>.`},jt(s));const i=n.sessionId?R(e,n.sessionId):null;if(!i){const o={initialized:!1,active:n.sessionId??null,source:n.source,available:s,next:n.sessionId?`Run aib session init --name ${n.sessionId}`:"Run aib session init --name <name>"};return(0,m.attachAgentText)(o,$t(o))}g(e,i);const r={initialized:!0,session:i.sessionId??n.sessionId,active:i.sessionId??n.sessionId,source:n.source,available:s,sessionDir:h(e,i.rootDir),aliases:(0,b.effectivePathAliases)(e,i.pathAliases??{}),latest:Mt(i),dirs:Vt(e,i)};return(0,m.attachAgentText)(r,xt(r))}function $t(e){const t=typeof e.active=="string"&&e.active?e.active:null;return t?["session not ready","",`Session ${t} was not found.`,"Create it:",`aib session init --name ${t}`].join(`
18
18
  `):["session not ready","","No AIB sessions exist in this repo.","Create one:","aib session init --name <name>"].join(`
19
- `)}function xt(e){const t=String(e.session??""),n=e.dirs&&typeof e.dirs=="object"&&!Array.isArray(e.dirs)?e.dirs:{},s=e.aliases&&typeof e.aliases=="object"&&!Array.isArray(e.aliases)?e.aliases:{},i=[`session: ${t}`,`outputs: ${String(n.outputs??"")}`,`inputs: ${String(n.inputs??"")}`],r=Object.entries(s).filter(([,o])=>typeof o=="string"&&o.trim()!=="").sort(([o],[a])=>o.localeCompare(a)).map(([o,a])=>`@${o} -> ${String(a)}`);return r.length>0&&i.push("","aliases:",...r),e.source==="single"&&i.push("","Only one AIB session exists in this repo.","You can run AIB commands without -s."),i.join(`
19
+ `)}function xt(e){const t=String(e.session??""),n=e.aliases&&typeof e.aliases=="object"&&!Array.isArray(e.aliases)?e.aliases:{},s=[`session: ${t}`],i=Object.entries(n).filter(([,r])=>typeof r=="string"&&r.trim()!=="").sort(([r],[o])=>r.localeCompare(o)).map(([r,o])=>`@${r} -> ${String(o)}`);return i.length>0&&s.push("","aliases:",...i),e.source==="single"&&s.push("","Only one AIB session exists in this repo.","You can run AIB commands without -s."),s.join(`
20
20
  `)}function jt(e){return["multiple AIB sessions","","available:",...e,"","Choose one:","aib -s <session> <command>","","Or bind it in this shell:",`${E.CLI_ENV.session}=<session>`,"","If none of these sessions is yours, create a new one:","aib session init --name <name>"].join(`
21
21
  `)}function Ct(e){const t=k(e),n=D(e),s=n?Object.keys(n.sessions).sort():[];if(t.source==="ambiguous")return(0,m.attachAgentText)({ok:!1,code:"MULTIPLE_AIB_SESSIONS",error:"Multiple AIB sessions exist. Select one explicitly.",available:s,next:"Use aib -s <session> session clear."},wt(s));const i=t.sessionId?R(e,t.sessionId):null;if(!i)return(0,m.attachAgentText)({cleared:!1,reason:"session-not-initialized"},["No AIB sessions exist in this repo.","","Create one:","aib session init --name <name>"].join(`
22
22
  `));he(i,{touch:!0}),g(e,i);const r=i.sessionId??t.sessionId??"";return(0,m.attachAgentText)({cleared:!0,session:r,dir:h(e,i.rootDir)},[`session cleared: ${r}`,"","Inputs and outputs were pruned.","You can keep using this session."].join(`
23
23
  `))}function he(e,t){l.rmSync(c.join(e.rootDir,"inputs"),{recursive:!0,force:!0}),l.rmSync(c.join(e.rootDir,"outputs"),{recursive:!0,force:!0}),e.inputs={},e.outputs={},e.guidance={},t.touch&&(e.updatedAt=new Date().toISOString()),me(e)}function wt(e){return["multiple AIB sessions","","available:",...e,"","Clear one explicitly only if it is yours:","aib -s <session> session clear","","If none of these sessions is yours, create a new one:","aib session init --name <name>"].join(`
24
- `)}function Rt(e){const t=Lt(e),n=D(e);if(!n)return;const s=Date.now();let i=!1;for(const[r,o]of Object.entries(n.sessions)){const a=P(o.rootDir);if(!l.existsSync(a)){delete n.sessions[r],i=!0,n.activeSessionId===r&&delete n.activeSessionId;continue}const f=Date.parse(o.updatedAt);if(!Number.isFinite(f))continue;const d=s-f;if(t.autoDelete&&t.ttlDeleteMs>0&&d>t.ttlDeleteMs){l.rmSync(o.rootDir,{recursive:!0,force:!0}),delete n.sessions[r],i=!0,n.activeSessionId===r&&delete n.activeSessionId;continue}if(t.autoClean&&t.ttlCleanMs>0&&d>t.ttlCleanMs){const p=Ie(e,o.rootDir,r);p&&(he(p,{touch:!1}),Pt(p))}}if(i){if(!n.activeSessionId){const r=Object.keys(n.sessions).sort()[0];r&&(n.activeSessionId=r)}T(e,n)}}function Lt(e){const t=(0,N.readWorkspaceNumberConfig)(e,"session.ttlMinutes",60),n=(0,N.readWorkspaceNumberConfig)(e,"session.ttlDeleteMinutes",t),s=(0,N.readWorkspaceNumberConfig)(e,"session.ttlCleanMinutes",t);return{autoDelete:(0,N.readWorkspaceBooleanConfig)(e,"session.autoDelete",!0),ttlDeleteMs:n>0?n*6e4:0,autoClean:(0,N.readWorkspaceBooleanConfig)(e,"session.autoClean",!0),ttlCleanMs:s>0?s*6e4:0}}function me(e){for(const t of ke)l.mkdirSync(c.join(e.rootDir,"outputs",t),{recursive:!0});for(const t of We)l.mkdirSync(c.join(e.rootDir,"inputs",t),{recursive:!0})}function R(e,t){const s=D(e)?.sessions[t];return s?Ie(e,s.rootDir,t):null}function v(e){const t=Ee(e);return t.sessionId?R(e,t.sessionId):null}function Ie(e,t,n){try{const s=JSON.parse(l.readFileSync(P(t),"utf8"));if(!s||typeof s!="object"||Array.isArray(s))return null;const i=s;return i.version!==1||typeof i.rootDir!="string"?null:(i.sessionId=i.sessionId??n,i)}catch{return null}}function A(e){const t=v(e);if(!t)throw new u.CliError("SESSION_WORKSPACE_NOT_INITIALIZED","Session workspace is not initialized.",{session:Y()??null,next:"Run aib session init --dir .tmp/aib"});return g(e,t),t}function g(e,t){t.updatedAt=new Date().toISOString(),l.mkdirSync(t.rootDir,{recursive:!0}),l.writeFileSync(P(t.rootDir),`${JSON.stringify(t,null,2)}
24
+ `)}function Rt(e){const t=Lt(e),n=D(e);if(!n)return;const s=Date.now();let i=!1;for(const[r,o]of Object.entries(n.sessions)){const a=P(o.rootDir);if(!l.existsSync(a)){delete n.sessions[r],i=!0,n.activeSessionId===r&&delete n.activeSessionId;continue}const f=Date.parse(o.updatedAt);if(!Number.isFinite(f))continue;const d=s-f;if(t.autoDelete&&t.ttlDeleteMs>0&&d>t.ttlDeleteMs){l.rmSync(o.rootDir,{recursive:!0,force:!0}),delete n.sessions[r],i=!0,n.activeSessionId===r&&delete n.activeSessionId;continue}if(t.autoClean&&t.ttlCleanMs>0&&d>t.ttlCleanMs){const p=Ie(e,o.rootDir,r);p&&(he(p,{touch:!1}),Pt(p))}}if(i){if(!n.activeSessionId){const r=Object.keys(n.sessions).sort()[0];r&&(n.activeSessionId=r)}T(e,n)}}function Lt(e){const t=(0,_.readWorkspaceNumberConfig)(e,"session.ttlMinutes",60),n=(0,_.readWorkspaceNumberConfig)(e,"session.ttlDeleteMinutes",t),s=(0,_.readWorkspaceNumberConfig)(e,"session.ttlCleanMinutes",t);return{autoDelete:(0,_.readWorkspaceBooleanConfig)(e,"session.autoDelete",!0),ttlDeleteMs:n>0?n*6e4:0,autoClean:(0,_.readWorkspaceBooleanConfig)(e,"session.autoClean",!0),ttlCleanMs:s>0?s*6e4:0}}function me(e){for(const t of ke)l.mkdirSync(c.join(e.rootDir,"outputs",t),{recursive:!0});for(const t of We)l.mkdirSync(c.join(e.rootDir,"inputs",t),{recursive:!0})}function R(e,t){const s=D(e)?.sessions[t];return s?Ie(e,s.rootDir,t):null}function v(e){const t=Ee(e);return t.sessionId?R(e,t.sessionId):null}function Ie(e,t,n){try{const s=JSON.parse(l.readFileSync(P(t),"utf8"));if(!s||typeof s!="object"||Array.isArray(s))return null;const i=s;return i.version!==1||typeof i.rootDir!="string"?null:(i.sessionId=i.sessionId??n,i)}catch{return null}}function A(e){const t=v(e);if(!t)throw new u.CliError("SESSION_WORKSPACE_NOT_INITIALIZED","Session workspace is not initialized.",{session:Y()??null,next:"Run aib session init --name <name>",help:"aib help session"});return g(e,t),t}function g(e,t){t.updatedAt=new Date().toISOString(),l.mkdirSync(t.rootDir,{recursive:!0}),l.writeFileSync(P(t.rootDir),`${JSON.stringify(t,null,2)}
25
25
  `),be(e,t,!1)}function Pt(e){l.mkdirSync(e.rootDir,{recursive:!0}),l.writeFileSync(P(e.rootDir),`${JSON.stringify(e,null,2)}
26
- `)}function Q(e,t,n=!1){const s=(0,N.resolveWorkspaceRoot)(e),i=s?.root??e,r=s?X(s.config[U]):void 0;if(r)return{rootDir:ye(i,r),source:"aib.json",...t?{ignoredRequestedDir:t}:{}};const a=ye(i,t??je);return n&&s&&(0,N.updateWorkspaceConfig)(i,{[U]:Tt(i,a)}),{rootDir:a,source:t?"request":"default"}}function ye(e,t){const n=c.resolve(e,t);return c.basename(n).toLowerCase()==="aib"?n:c.join(n,"aib")}function Tt(e,t){const n=c.relative(e,t);return n&&!n.startsWith("..")&&!c.isAbsolute(n)?n.replace(/\\/g,"/"):t.replace(/\\/g,"/")}function L(e){return c.join(Q(e).rootDir,Ce)}function kt(e){return c.join(Q(e).rootDir,we)}function P(e){return c.join(e,"session.json")}function D(e){try{const t=JSON.parse(l.readFileSync(L(e),"utf8"));if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t;return n.version!==1||!n.sessions||typeof n.sessions!="object"?null:{version:1,cwd:typeof n.cwd=="string"?n.cwd:c.resolve(e),...typeof n.activeSessionId=="string"?{activeSessionId:n.activeSessionId}:{},sessions:n.sessions}}catch{return null}}function T(e,t){t.cwd=c.resolve((0,N.resolveWorkspaceRoot)(e)?.root??e),l.mkdirSync(c.dirname(L(e)),{recursive:!0}),l.writeFileSync(L(e),`${JSON.stringify(t,null,2)}
26
+ `)}function Q(e,t,n=!1){const s=(0,_.resolveWorkspaceRoot)(e),i=s?.root??e,r=s?X(s.config[U]):void 0;if(r)return{rootDir:ye(i,r),source:"aib.json",...t?{ignoredRequestedDir:t}:{}};const a=ye(i,t??je);return n&&s&&(0,_.updateWorkspaceConfig)(i,{[U]:Tt(i,a)}),{rootDir:a,source:t?"request":"default"}}function ye(e,t){const n=c.resolve(e,t);return c.basename(n).toLowerCase()==="aib"?n:c.join(n,"aib")}function Tt(e,t){const n=c.relative(e,t);return n&&!n.startsWith("..")&&!c.isAbsolute(n)?n.replace(/\\/g,"/"):t.replace(/\\/g,"/")}function L(e){return c.join(Q(e).rootDir,Ce)}function kt(e){return c.join(Q(e).rootDir,we)}function P(e){return c.join(e,"session.json")}function D(e){try{const t=JSON.parse(l.readFileSync(L(e),"utf8"));if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t;return n.version!==1||!n.sessions||typeof n.sessions!="object"?null:{version:1,cwd:typeof n.cwd=="string"?n.cwd:c.resolve(e),...typeof n.activeSessionId=="string"?{activeSessionId:n.activeSessionId}:{},sessions:n.sessions}}catch{return null}}function T(e,t){t.cwd=c.resolve((0,_.resolveWorkspaceRoot)(e)?.root??e),l.mkdirSync(c.dirname(L(e)),{recursive:!0}),l.writeFileSync(L(e),`${JSON.stringify(t,null,2)}
27
27
  `),Wt(e,t.activeSessionId)}function ge(e){return{version:1,cwd:c.resolve(e),sessions:{}}}function Wt(e,t){const n=kt(e);if(l.mkdirSync(c.dirname(n),{recursive:!0}),!t){l.rmSync(n,{force:!0});return}l.writeFileSync(n,`${JSON.stringify({sessionId:t,updatedAt:new Date().toISOString()},null,2)}
28
28
  `)}function be(e,t,n){const s=t.sessionId??Y()??"";if(!s)return;const i=D(e)??ge(e);i.sessions[s]={sessionId:s,rootDir:t.rootDir,createdAt:i.sessions[s]?.createdAt??t.createdAt,updatedAt:t.updatedAt},(n||!i.activeSessionId)&&(i.activeSessionId=s),T(e,i)}function Bt(e,t){const n=D(e);if(!(!n||!t)){if(delete n.sessions[t],n.activeSessionId===t){const s=Object.keys(n.sessions).sort()[0];s?n.activeSessionId=s:delete n.activeSessionId}T(e,n)}}function Ee(e){const t=F.getStore();if(t)return{sessionId:$(t),source:"override"};const n=process.env[E.CLI_ENV.session];if(n&&n.trim())return{sessionId:$(n),source:"env"};const s=process.env[E.CLI_ENV.legacySession];if(s&&s.trim())return{sessionId:$(s),source:"legacy-env"};const i=D(e),r=i?Object.keys(i.sessions).sort():[];if(r.length===1)return{sessionId:r[0],source:"single"};if(r.length>1)throw new u.CliError("MULTIPLE_AIB_SESSIONS","Multiple AIB sessions exist. Select one explicitly.",{available:r,next:`Use aib -s <session> <command> or set ${E.CLI_ENV.session}=<session>.`});return{sessionId:null,source:"none"}}function k(e){try{return Ee(e)}catch(t){if(t instanceof u.CliError&&t.code==="MULTIPLE_AIB_SESSIONS")return{sessionId:null,source:"ambiguous"};throw t}}function Ut(e){const t=k(e);return{sessionId:t.sessionId,sessionSource:t.source}}function Y(){const e=F.getStore();if(e)return $(e);const t=process.env[E.CLI_ENV.session];if(t&&t.trim())return $(t);const n=process.env[E.CLI_ENV.legacySession];return n&&n.trim()?$(n):null}function Ae(e,t,n,s){return c.join(e.rootDir,"outputs",I(t),`${I(n)}${ee(s)}`)}function Z(e,t,n,s=".json"){return c.join(e.rootDir,"inputs",I(t),`${I(n)}${ee(s)}`)}function Ft(e,t,n){return c.join(e.rootDir,"inputs",I(t),`${I(n)}.compiled.json`)}function W(e,t,n=".json"){return c.join(e.rootDir,"inputs",I(t),n===".json"?Te:`_last${ee(n)}`)}function x(e,t){l.mkdirSync(c.dirname(e),{recursive:!0}),l.writeFileSync(e,`${JSON.stringify(t,null,2)}
29
29
  `)}function _e(e,t){l.mkdirSync(c.dirname(e),{recursive:!0}),l.writeFileSync(e,t.endsWith(`
@@ -1,3 +1,3 @@
1
- "use strict";var S=exports&&exports.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),O=exports&&exports.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),m=exports&&exports.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(n){var r=[];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[r.length]=o);return r},e(t)};return function(t){if(t&&t.__esModule)return t;var n={};if(t!=null)for(var r=e(t),o=0;o<r.length;o++)r[o]!=="default"&&S(n,t,r[o]);return O(n,t),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.AIB_CONFIG_FILE_NAME=void 0,exports.initWorkspaceRoot=h,exports.resolveWorkspaceRoot=p,exports.resolveRequiredWorkspaceRoot=C,exports.readWorkspaceNumberConfig=D,exports.readWorkspaceBooleanConfig=w,exports.readWorkspaceStringConfig=k,exports.updateWorkspaceConfig=E,exports.workspaceConfigSummary=W,exports.isPathInsideOrEqual=A;const c=m(require("node:fs")),s=m(require("node:path")),N=require("./env-vars"),M=require("../shared/errors");exports.AIB_CONFIG_FILE_NAME="aib.json";function h(e,t={}){const n=s.join(s.resolve(e),exports.AIB_CONFIG_FILE_NAME),r=c.existsSync(n),o=r?_(n):{},f=a(t.sessionDir)??a(o.sessionDir),d=i(o["session.ttlMinutes"]),g=i(o["session.ttlCleanMinutes"])??d??60,I=i(o["session.ttlDeleteMinutes"])??d??60,l={...o,"workspace.root":a(o["workspace.root"])??".",...f?{sessionDir:f}:{},"session.autoDelete":u(o["session.autoDelete"])??!0,"session.ttlDeleteMinutes":I,"session.autoClean":u(o["session.autoClean"])??!0,"session.ttlCleanMinutes":g,"runtime.managedIdeTtlMinutes":i(o["runtime.managedIdeTtlMinutes"])??15,"runtime.managedIdeWatchdogIntervalMs":i(o["runtime.managedIdeWatchdogIntervalMs"])??3e4,"runtime.autoStopManagedIde":u(o["runtime.autoStopManagedIde"])??!0};c.writeFileSync(n,`${JSON.stringify(l,null,2)}
2
- `,"utf8");const y=i(l["session.ttlCleanMinutes"])??60,v=i(l["runtime.managedIdeTtlMinutes"])??15,b=!r||JSON.stringify(o)!==JSON.stringify(l);return{status:r?b?"updated":"unchanged":"created",...r?{}:{created:exports.AIB_CONFIG_FILE_NAME},configPath:n,root:s.resolve(e),"workspace.root":a(l["workspace.root"])??".",...f?{sessionDir:f}:{},"session.autoClean":u(l["session.autoClean"])??!0,"session.ttlCleanMinutes":y,"session.autoDelete":u(l["session.autoDelete"])??!0,"session.ttlDeleteMinutes":i(l["session.ttlDeleteMinutes"])??60,"runtime.autoStopManagedIde":u(l["runtime.autoStopManagedIde"])??!0,"runtime.managedIdeTtlMinutes":v,...f?{}:{next:"Set the default session directory: aib config --session-dir .tmp/aib"}}}function p(e){const t=a(process.env[N.CLI_ENV.workspaceRoot]);if(t){const d=s.resolve(e,t),g=s.join(d,exports.AIB_CONFIG_FILE_NAME),I=c.existsSync(g)?_(g):{"workspace.root":"."};return{root:d,configPath:g,config:I}}const n=F(e);if(!n)return null;const r=_(n),o=s.dirname(n),f=a(r["workspace.root"])??".";return{root:s.resolve(o,f),configPath:n,config:r}}function C(e){const t=p(e);if(t)return t;const n=j(e,".git");throw new M.CliError("WORKSPACE_ROOT_NOT_INITIALIZED","Workspace root is not initialized.",{cwd:s.resolve(e),...n?{detectedGitRoot:n}:{},next:"Go to your repo root and run: aib init"})}function D(e,t,n){const r=p(e);return(r?i(r.config[t]):null)??n}function w(e,t,n){const r=p(e);return(r?u(r.config[t]):null)??n}function k(e,t,n){const r=p(e);return(r?a(r.config[t]):null)??n}function E(e,t){const n=C(e),r={...n.config,...t};return c.writeFileSync(n.configPath,`${JSON.stringify(r,null,2)}
3
- `,"utf8"),r}function W(e){const t=i(e["session.ttlMinutes"]);return{"workspace.root":a(e["workspace.root"])??".",...a(e.sessionDir)?{sessionDir:a(e.sessionDir)}:{},"session.autoClean":u(e["session.autoClean"])??!0,"session.ttlCleanMinutes":i(e["session.ttlCleanMinutes"])??t??60,"session.autoDelete":u(e["session.autoDelete"])??!0,"session.ttlDeleteMinutes":i(e["session.ttlDeleteMinutes"])??t??60,"runtime.autoStopManagedIde":u(e["runtime.autoStopManagedIde"])??!0,"runtime.managedIdeTtlMinutes":i(e["runtime.managedIdeTtlMinutes"])??15}}function A(e,t){const n=s.resolve(e).toLowerCase(),r=s.resolve(t).toLowerCase();return r===n||r.startsWith(`${n}${s.sep}`)}function F(e){let t=s.resolve(e);const n=s.parse(t).root;for(;;){const r=s.join(t,exports.AIB_CONFIG_FILE_NAME);if(c.existsSync(r)&&c.statSync(r).isFile())return r;if(t===n)break;const o=s.dirname(t);if(o===t)break;t=o}return null}function j(e,t){let n=s.resolve(e);const r=s.parse(n).root;for(;;){if(c.existsSync(s.join(n,t)))return n;if(n===r)break;const o=s.dirname(n);if(o===n)break;n=o}return null}function _(e){try{const t=JSON.parse(c.readFileSync(e,"utf8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch(t){throw new M.CliError("AIB_CONFIG_INVALID","aib.json must be valid JSON.",{file:e,error:t instanceof Error?t.message:String(t)})}}function a(e){return typeof e=="string"&&e.trim()?e.trim():null}function i(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const t=Number(e);return Number.isFinite(t)?t:null}return null}function u(e){if(typeof e=="boolean")return e;if(typeof e!="string")return null;const t=e.trim().toLowerCase();return["1","true","yes","on"].includes(t)?!0:["0","false","no","off"].includes(t)?!1:null}
1
+ "use strict";var b=exports&&exports.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var s=Object.getOwnPropertyDescriptor(t,n);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,s)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),v=exports&&exports.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),_=exports&&exports.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(n){var r=[];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[r.length]=s);return r},e(t)};return function(t){if(t&&t.__esModule)return t;var n={};if(t!=null)for(var r=e(t),s=0;s<r.length;s++)r[s]!=="default"&&b(n,t,r[s]);return v(n,t),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.MATERIALIZED_INSPECT_DEFAULTS=exports.AIB_CONFIG_FILE_NAME=void 0,exports.initWorkspaceRoot=D,exports.resolveWorkspaceRoot=g,exports.resolveRequiredWorkspaceRoot=C,exports.readWorkspaceNumberConfig=O,exports.readWorkspaceBooleanConfig=h,exports.readWorkspaceStringConfig=A,exports.updateWorkspaceConfig=w,exports.workspaceConfigSummary=k,exports.isPathInsideOrEqual=F;const l=_(require("node:fs")),o=_(require("node:path")),E=require("./env-vars"),M=require("../shared/errors");exports.AIB_CONFIG_FILE_NAME="aib.json",exports.MATERIALIZED_INSPECT_DEFAULTS={"inspect.code.maxNonEmptyLines":120,"inspect.usages.maxLocations":12,"inspect.usages.maxCodeBlocks":8,"inspect.members.maxItems":20};function D(e,t={}){const n=o.join(o.resolve(e),exports.AIB_CONFIG_FILE_NAME),r=l.existsSync(n),s=r?m(n):{},f=a(t.sessionDir)??a(s.sessionDir),d=i(s["session.ttlMinutes"]),p=i(s["session.ttlCleanMinutes"])??d??60,I=i(s["session.ttlDeleteMinutes"])??d??60,c={...s,"workspace.root":a(s["workspace.root"])??".",...f?{sessionDir:f}:{},"session.autoDelete":u(s["session.autoDelete"])??!0,"session.ttlDeleteMinutes":I,"session.autoClean":u(s["session.autoClean"])??!0,"session.ttlCleanMinutes":p,"runtime.managedIdeTtlMinutes":i(s["runtime.managedIdeTtlMinutes"])??15,"runtime.managedIdeWatchdogIntervalMs":i(s["runtime.managedIdeWatchdogIntervalMs"])??3e4,"runtime.autoStopManagedIde":u(s["runtime.autoStopManagedIde"])??!0,...r?{}:exports.MATERIALIZED_INSPECT_DEFAULTS};l.writeFileSync(n,`${JSON.stringify(c,null,2)}
2
+ `,"utf8");const S=i(c["session.ttlCleanMinutes"])??60,y=i(c["runtime.managedIdeTtlMinutes"])??15,N=!r||JSON.stringify(s)!==JSON.stringify(c);return{status:r?N?"updated":"unchanged":"created",...r?{}:{created:exports.AIB_CONFIG_FILE_NAME},configPath:n,root:o.resolve(e),"workspace.root":a(c["workspace.root"])??".",...f?{sessionDir:f}:{},"session.autoClean":u(c["session.autoClean"])??!0,"session.ttlCleanMinutes":S,"session.autoDelete":u(c["session.autoDelete"])??!0,"session.ttlDeleteMinutes":i(c["session.ttlDeleteMinutes"])??60,"runtime.autoStopManagedIde":u(c["runtime.autoStopManagedIde"])??!0,"runtime.managedIdeTtlMinutes":y,...f?{}:{next:"Set the default session directory: aib config --session-dir .tmp/aib"}}}function g(e){const t=a(process.env[E.CLI_ENV.workspaceRoot]);if(t){const d=o.resolve(e,t),p=o.join(d,exports.AIB_CONFIG_FILE_NAME),I=l.existsSync(p)?m(p):{"workspace.root":"."};return{root:d,configPath:p,config:I}}const n=T(e);if(!n)return null;const r=m(n),s=o.dirname(n),f=a(r["workspace.root"])??".";return{root:o.resolve(s,f),configPath:n,config:r}}function C(e){const t=g(e);if(t)return t;const n=L(e,".git");throw new M.CliError("WORKSPACE_ROOT_NOT_INITIALIZED","Workspace root is not initialized.",{cwd:o.resolve(e),...n?{detectedGitRoot:n}:{},next:"Run aib help first-setup from the intended repository root."})}function O(e,t,n){const r=g(e);return(r?i(r.config[t]):null)??n}function h(e,t,n){const r=g(e);return(r?u(r.config[t]):null)??n}function A(e,t,n){const r=g(e);return(r?a(r.config[t]):null)??n}function w(e,t){const n=C(e),r={...n.config,...t};return l.writeFileSync(n.configPath,`${JSON.stringify(r,null,2)}
3
+ `,"utf8"),r}function k(e){const t=i(e["session.ttlMinutes"]);return{"workspace.root":a(e["workspace.root"])??".",...a(e.sessionDir)?{sessionDir:a(e.sessionDir)}:{},"session.autoClean":u(e["session.autoClean"])??!0,"session.ttlCleanMinutes":i(e["session.ttlCleanMinutes"])??t??60,"session.autoDelete":u(e["session.autoDelete"])??!0,"session.ttlDeleteMinutes":i(e["session.ttlDeleteMinutes"])??t??60,"runtime.autoStopManagedIde":u(e["runtime.autoStopManagedIde"])??!0,"runtime.managedIdeTtlMinutes":i(e["runtime.managedIdeTtlMinutes"])??15}}function F(e,t){const n=o.resolve(e).toLowerCase(),r=o.resolve(t).toLowerCase();return r===n||r.startsWith(`${n}${o.sep}`)}function T(e){let t=o.resolve(e);const n=o.parse(t).root;for(;;){const r=o.join(t,exports.AIB_CONFIG_FILE_NAME);if(l.existsSync(r)&&l.statSync(r).isFile())return r;if(t===n)break;const s=o.dirname(t);if(s===t)break;t=s}return null}function L(e,t){let n=o.resolve(e);const r=o.parse(n).root;for(;;){if(l.existsSync(o.join(n,t)))return n;if(n===r)break;const s=o.dirname(n);if(s===n)break;n=s}return null}function m(e){try{const t=JSON.parse(l.readFileSync(e,"utf8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch(t){throw new M.CliError("AIB_CONFIG_INVALID","aib.json must be valid JSON.",{file:e,error:t instanceof Error?t.message:String(t)})}}function a(e){return typeof e=="string"&&e.trim()?e.trim():null}function i(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const t=Number(e);return Number.isFinite(t)?t:null}return null}function u(e){if(typeof e=="boolean")return e;if(typeof e!="string")return null;const t=e.trim().toLowerCase();return["1","true","yes","on"].includes(t)?!0:["0","false","no","off"].includes(t)?!1:null}
@@ -13,13 +13,10 @@ session prefs get
13
13
  Run:
14
14
  aib session prefs get
15
15
 
16
- Stdin examples show command and input separately to avoid shell-specific syntax.
17
- Stdin Run lines include the aib prefix to avoid confusion.
18
-
19
- PowerShell stdin shape:
20
- @'
21
- <input>
22
- '@ | aib <command> --stdin
16
+ Stdin examples show command and input separately to avoid shell-specific syntax.
17
+ Stdin Run lines include the aib prefix to avoid confusion.
18
+
19
+ {{stdin.examples}}
23
20
 
24
21
  Basics
25
22
 
@@ -36,9 +33,28 @@ Use one-off commands only for small checks/changes.
36
33
  For mutations, aib asks TS/IDE refactors to update affected references and imports.
37
34
  After a successful mutation, do not manually patch the same imports unless aib reports a follow-up or the build/checks show a real issue.
38
35
 
39
- Working patterns
40
-
36
+ Working patterns
37
+
38
+ Help refresh
39
+
40
+ After context compaction, always run:
41
+ aib help help-protocol quick-map
42
+ aib config aliases
43
+
44
+ Use focused help when you would otherwise guess how a known AIB capability works.
45
+
46
+ Reread bootstrap when you need to restore the overall AIB workflow faster than piecing it together from focused topics.
47
+ If you just reread bootstrap, do not also read focused topics unless you need details that bootstrap does not cover.
48
+
49
+ Do not reread bootstrap automatically if focused help is enough.
50
+ When refreshing multiple areas, request them together instead of one by one.
51
+
52
+ Example:
53
+ aib help patterns mutation inspect inspect.file inspect.code imports.normalize
54
+
41
55
  Use aib before broad file reads when the question is about TS/JS structure, references, dependencies, or focused code.
56
+ Use qr for cross-OS quick reads of text files, logs, JSON, scripts, and line windows.
57
+ It is not a replacement for inspect.
42
58
  Use normal text search when the question is just text.
43
59
 
44
60
  For a first pass in a new codebase, map directories before reading files:
@@ -52,9 +68,9 @@ If output hides data and shows `view: aib:res_<id>`, use `aib view ...` to fetch
52
68
 
53
69
  Compact output is a starting point, not a substitute for needed code.
54
70
  Fetch exact code when correctness depends on implementation details.
55
-
56
- Use prefs when the current phase repeats the same output shape.
57
- Turn details off when they stop helping.
71
+
72
+ Use prefs when the current phase repeats the same output shape.
73
+ Turn details off when they stop helping.
58
74
  Turn them back on when they matter.
59
75
 
60
76
  For mutation commands, set the shell/tool harness timeout to 3 minutes.
@@ -65,15 +81,30 @@ aib execution status last
65
81
 
66
82
  This is an escape hatch for recovering the latest mutation status/result.
67
83
 
68
- Before repeated mutation work, check aib config:
69
-
70
- aib config
71
-
72
- Set pathAliases for repeated request paths.
73
- Set importRules so move/modulePlan create imports in the project style.
74
-
75
- This avoids repeating long paths in requests and avoids manual import cleanup after mutations.
76
- Do this before large move/modulePlan work, not after cleanup becomes repetitive.
84
+ After reading bootstrap for the first time in a repo, run:
85
+
86
+ aib config
87
+
88
+ Use the output as the repo-local AIB map:
89
+ - pathAliases show short paths to use in AIB requests;
90
+ - importRules show how move/modulePlan should create imports;
91
+ - importNormalize shows defaults for explicit imports normalize;
92
+ - excludes show which noise is intentionally hidden from tree/graph/sync.
93
+
94
+ If pathAliases are missing, stale, or weak for repeated paths, run:
95
+ aib help config-setup.aliases
96
+
97
+ If move/modulePlan imports do not match the repo style, run:
98
+ aib help config-setup.import-rules
99
+
100
+ If you are about to change import style across files, add or adopt tsconfig aliases, or clean imports repeatedly, run:
101
+ aib help config-setup.import-normalize
102
+
103
+ If tree/graph output includes known repo noise, run:
104
+ aib help config-setup.excludes
105
+
106
+ If sync or reveal shows too many visible TypeScript configs, run:
107
+ aib help config-setup.tsconfigs
77
108
 
78
109
  Example aib.json config:
79
110
 
@@ -110,72 +141,18 @@ Use them to reduce input tokens for repeated inspect and mutation work.
110
141
  Aliases are for aib request paths. They do not change TypeScript imports by themselves.
111
142
  For import style after mutations, use importRules.
112
143
 
113
- importRules control imports created or expanded by move/modulePlan mutation cleanup.
114
- They do not rewrite the whole project.
115
-
116
- AIB starts from IDE/TS import preferences.
117
- For mutation cleanup, matching importRules in aib.json take priority.
118
-
119
- Do not assume IDE/TS defaults match the repo style.
120
- Set importRules before large move/modulePlan work so imports do not need manual cleanup.
121
-
122
- Fields:
123
- scope repo-relative file or directory scope; most specific scope wins
124
- specifier relative|shortest|project-relative|non-relative
125
- ending auto|minimal|index|js
126
- builtin node|bare
127
- unusedImports remove|preserve
128
-
129
- Defaults:
130
- specifier omitted IDE/TS decides
131
- ending omitted IDE/TS decides
132
- builtin omitted keep TS/project builtin style
133
- unusedImports omitted keep unused imports
134
-
135
- specifier:
136
- relative best for local relative imports
137
- shortest best for shortest valid alias/path output
138
- project-relative best for root-relative project imports
139
- non-relative best for package or alias imports
140
-
141
- ending:
142
- minimal best for extensionless TS imports
143
- js best for ESM-style TS projects that require .js
144
- auto leaves the decision to TypeScript
145
- index best for explicit index import style
146
-
147
- builtin:
148
- node path -> node:path; best for explicit Node builtin imports
149
- bare node:path -> path; best for bare Node builtin imports
150
- omit field keeps TypeScript/project output; add builtin if agents keep fixing this manually
151
-
152
- unusedImports:
153
- remove clean unused imports in mutation-touched files
154
- preserve keep unused imports
155
- omit same as preserve
156
-
157
- Mutation-touched files are files where TS produced edits: source/target files and any reference/update files TS changed.
158
- Recommended value: remove
159
-
160
- importNormalize defines reusable defaults for aib imports normalize.
161
- Use it when the same normalize request would otherwise be repeated.
162
-
163
- It affects explicit import normalize commands only.
164
- It does not run automatically during move/modulePlan; use importRules for mutation-time cleanup.
165
-
166
- Fields:
167
- scope repo-relative file or directory scope; most specific scope wins
168
- to relative|alias|shortestAlias
169
- preferAlias tsconfig paths pattern used when to=alias
170
- exclude files, directories, or glob-like patterns to skip
171
-
172
- to:
173
- relative rewrite resolved local imports to relative paths
174
- alias rewrite resolved local imports to a matching tsconfig alias
175
- shortestAlias rewrite to the shortest valid alias specifier
176
-
177
- preferAlias:
178
- @shared/* prefer one alias pattern when several aliases can resolve the same file
144
+ importRules control imports created or expanded by move/modulePlan mutation cleanup.
145
+ They do not rewrite the whole project.
146
+
147
+ AIB starts from IDE/TS import preferences.
148
+ For mutation cleanup, matching importRules in aib.json take priority.
149
+
150
+ Do not assume IDE/TS defaults match the repo style.
151
+ Set importRules before large move/modulePlan work so imports do not need manual cleanup.
152
+
153
+ importNormalize defines default rules for explicit aib imports normalize commands.
154
+
155
+ It does not run automatically during move/modulePlan; use importRules for mutation-time cleanup.
179
156
 
180
157
  AIB has four config exclude fields:
181
158
  inspect.graph.exclude
@@ -189,9 +166,10 @@ Use config excludes for generated files, backups, local copies, nested workspace
189
166
 
190
167
  Graph excludes affect graph counts, hubs, entrypoints, leaves, edges, imports, importedBy, and saved graph files.
191
168
  Tree excludes affect directory/file discovery output.
192
- Tsconfig excludes affect which TypeScript configs AIB syncs and watches.
169
+ AIB syncs and watches visible tsconfigs.
170
+ sync.tsconfig.exclude affects which TypeScript configs AIB syncs and watches.
193
171
 
194
- Leave feedback while working.
172
+ Important: leave feedback while working.
195
173
 
196
174
  aib is built for agents. Agent feedback is the main signal for improving output, docs, mutations, and token efficiency.
197
175
 
@@ -347,6 +325,10 @@ incoming references/callers usages
347
325
  file/module connectivity graph
348
326
  compact directory layout tree
349
327
  repeated declarations/helpers duplicates
328
+ local import cycles cycles
329
+
330
+ Cycles are available but not expanded in bootstrap:
331
+ aib help inspect.cycles
350
332
 
351
333
  Prefer one batch DSL request for related questions.
352
334
 
@@ -701,6 +683,9 @@ Successful mutations update affected references and imports.
701
683
 
702
684
  After a successful mutation, do not manually patch the same imports unless aib reports a follow-up or checks show a real issue.
703
685
 
686
+ If move/modulePlan imports do not match the repo style, run:
687
+ aib help config-setup.import-rules
688
+
704
689
  AIB mutations are designed to reduce manual checking.
705
690
  Your job is to express the intent in DSL.
706
691
  AIB's job is to convert that intent into code changes.
@@ -762,6 +747,9 @@ Move is semantic; it moves supported declarations and updates affected imports/r
762
747
  Use it for focused extraction into a single target file.
763
748
  For large file splitting across several target files, use modulePlan.
764
749
 
750
+ If imports created by move do not match the repo style, run:
751
+ aib help config-setup.import-rules
752
+
765
753
  Move several entities into one target:
766
754
  Run:
767
755
  aib move toFile execute --stdin
@@ -777,6 +765,9 @@ Use it when a large file should be refactored into several target files.
777
765
 
778
766
  modulePlan orchestrates semantic moves and updates affected references/imports.
779
767
 
768
+ If imports created by modulePlan do not match the repo style, run:
769
+ aib help config-setup.import-rules
770
+
780
771
  Use +expectEmpty when your modulePlan intent is to move all declarations out of the source file.
781
772
  It does not change the move behavior; it only asks output to report remaining source declarations if any remain.
782
773
  Use it only when remaining declarations would mean the split did not match your intent.
@@ -901,12 +892,16 @@ aib view aib:res_<id_2> --except ClassB.bigB --except ClassC.bigC
901
892
 
902
893
  Quick Read
903
894
 
904
- Use qr to read arbitrary text files with compact, cross-platform line windows.
895
+ Use qr for cross-OS quick reads of text files: ts, js, cmd, sh, json, log, txt, ndjson, etc.
896
+ Use it for compact line windows and batching.
905
897
  qr supports AIB path aliases.
906
898
 
907
- qr is not a replacement for inspect.
899
+ It is not a replacement for inspect.
908
900
  Use it as a token-efficient way to read text data when semantic inspect is not needed.
909
901
 
902
+ For focused text reads, prefer qr over cat/Get-Content/type, especially when aliases, line windows, or batching help.
903
+ Use shell reads only when piping into shell tooling or qr is unavailable.
904
+
910
905
  Controls:
911
906
  -h N head; first N lines
912
907
  -t N tail; last N lines
@@ -932,3 +927,9 @@ aib qr @scripts/b.py -o 300 -l 50
932
927
  aib qr @logs/app.log -a
933
928
 
934
929
  Use stdin for several reads.
930
+
931
+ Need to see TypeScript configs in the repo:
932
+ aib reveal tsconfigs
933
+
934
+ Need to see TypeScript aliases across the repo:
935
+ aib reveal tsaliases
@@ -0,0 +1,56 @@
1
+ # Config Setup: Aliases
2
+
3
+ If you have not just checked the full config, check current aliases:
4
+
5
+ aib config aliases
6
+
7
+ pathAliases define short request aliases for paths agents repeat in AIB commands.
8
+ Use them to reduce input tokens for repeated inspect and mutation work.
9
+
10
+ Aliases are for AIB request paths.
11
+ They do not change TypeScript imports by themselves.
12
+ For import style after mutations, use importRules.
13
+
14
+ Check TypeScript aliases for hints:
15
+
16
+ aib reveal tsaliases
17
+
18
+ Use this to see existing tsconfig paths and baseUrl values.
19
+ They can reveal stable work areas, but they are not a list to copy.
20
+
21
+ Add pathAliases for long paths that are likely to appear repeatedly in AIB requests.
22
+ Prefer aliases for real work areas, package roots, or deep directories.
23
+
24
+ A good alias:
25
+ - saves meaningful path tokens;
26
+ - points to a stable work area;
27
+ - is easy to recognize later.
28
+
29
+ A bad alias:
30
+ - duplicates a short path like "src": "src", "packages": "packages", "scripts": "scripts";
31
+ - points to a rarely used folder;
32
+ - mirrors the directory tree without a workflow reason.
33
+
34
+ Having 20-30 good aliases is fine for a large repo or monorepo.
35
+
36
+ Example:
37
+
38
+ "pathAliases": {
39
+ "wstore": "apps/web/src/shared/store",
40
+ "wapi": "apps/web/src/shared/api",
41
+ "whooks": "apps/web/src/shared/utils/hooks",
42
+ "pmail": "packages/email/src",
43
+ "putils": "packages/utils/src",
44
+ "arules": "docs/agent/rules"
45
+ }
46
+
47
+ After editing aib.json, run:
48
+
49
+ aib sync
50
+
51
+ Verify aliases with a small tree or inspect request:
52
+
53
+ aib inspect --stdin
54
+
55
+ Input:
56
+ tree @<alias> depth=3 +onlyDirs limit=80
@@ -0,0 +1,45 @@
1
+ # Config Setup: Excludes
2
+
3
+ Tree excludes affect directory and file discovery output.
4
+ Graph excludes affect graph counts, hubs, entrypoints, leaves, edges, imports, importedBy, and saved graph views.
5
+
6
+ Built-in excludes already skip common noise such as node_modules, .git, dist, build, out, and .tmp.
7
+ Add config excludes for repository-specific noise.
8
+
9
+ For example, if the user often creates hard-copy directories or backup files before risky edits, those copies can make tree and graph output noisy.
10
+ Exclude them explicitly:
11
+
12
+ "inspect.tree.onlyDirs.exclude": [
13
+ "**/*copy",
14
+ "**/*copy/**"
15
+ ],
16
+ "inspect.tree.files.exclude": [
17
+ "**/* copy.ts",
18
+ "**/*.generated.ts"
19
+ ],
20
+ "inspect.graph.exclude": [
21
+ "**/* copy.ts",
22
+ "**/*.generated.ts",
23
+ "src/generated/**"
24
+ ]
25
+
26
+ Prefer narrow patterns for known noise:
27
+ - generated files;
28
+ - local copy/backup folders;
29
+ - build artifacts not already skipped by defaults;
30
+ - vendored or checked-in output.
31
+
32
+ These are common cases, not mandatory rules.
33
+ If the repository needs one of these areas for reasoning or mutation impact checks, do not exclude it.
34
+
35
+ Do not exclude broad source areas to make output smaller.
36
+ If output is too large, use scope, depth, limit, graph view, or graph toggles first.
37
+
38
+ After editing aib.json, run:
39
+
40
+ aib sync
41
+
42
+ Then verify with a compact tree request and the graph view that was noisy.
43
+
44
+ If excluded paths still appear, check the glob pattern against repo-relative paths.
45
+ If important source disappeared, narrow or remove the exclude.