@automaton-labs/aib 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (291) hide show
  1. package/README.md +578 -0
  2. package/dist/bin/aib.js +2 -0
  3. package/dist/bin/cli.js +3 -0
  4. package/dist/client/http-client.js +1 -0
  5. package/dist/client/transport-options.js +1 -0
  6. package/dist/client/websocket-client.js +1 -0
  7. package/dist/commands/add-missing-imports-preview-cache.js +2 -0
  8. package/dist/commands/add-missing-imports.js +2 -0
  9. package/dist/commands/apply-module-plan.js +3 -0
  10. package/dist/commands/captured-input.js +2 -0
  11. package/dist/commands/config-command.js +3 -0
  12. package/dist/commands/diagnostics-command.js +3 -0
  13. package/dist/commands/doctor.js +1 -0
  14. package/dist/commands/entity-resolution.js +1 -0
  15. package/dist/commands/execution-command.js +1 -0
  16. package/dist/commands/feedback-command.js +3 -0
  17. package/dist/commands/find-importers.js +1 -0
  18. package/dist/commands/find-unused-imports.js +1 -0
  19. package/dist/commands/generate-docs-command.js +6 -0
  20. package/dist/commands/help-command.js +3 -0
  21. package/dist/commands/imports-command.js +1 -0
  22. package/dist/commands/init-skill-usage.js +3 -0
  23. package/dist/commands/init-workspace.js +3 -0
  24. package/dist/commands/inspect-cycles.js +5 -0
  25. package/dist/commands/inspect-format.js +18 -0
  26. package/dist/commands/inspect-graph.js +9 -0
  27. package/dist/commands/inspect-imports.js +2 -0
  28. package/dist/commands/inspect-symbol-query.js +1 -0
  29. package/dist/commands/inspect-tree.js +5 -0
  30. package/dist/commands/inspect.js +16 -0
  31. package/dist/commands/json-file-input.js +1 -0
  32. package/dist/commands/list-instances.js +1 -0
  33. package/dist/commands/module-plan-cache.js +2 -0
  34. package/dist/commands/module-plan-command.js +1 -0
  35. package/dist/commands/module-plan-timeout.js +1 -0
  36. package/dist/commands/move-command.js +1 -0
  37. package/dist/commands/move-preview-cache.js +2 -0
  38. package/dist/commands/move-to-file.js +2 -0
  39. package/dist/commands/mutation-execution-cache.js +3 -0
  40. package/dist/commands/normalize-imports.js +4 -0
  41. package/dist/commands/observability-command.js +3 -0
  42. package/dist/commands/ping.js +1 -0
  43. package/dist/commands/print-config.js +1 -0
  44. package/dist/commands/quick-read.js +11 -0
  45. package/dist/commands/refactor-batch-builder.js +1 -0
  46. package/dist/commands/refactor-batch-execution-cache.js +1 -0
  47. package/dist/commands/refactor-batch-preview-cache.js +2 -0
  48. package/dist/commands/refactor-batch.js +4 -0
  49. package/dist/commands/refactor-command.js +1 -0
  50. package/dist/commands/rename-command.js +1 -0
  51. package/dist/commands/rename-entities.js +4 -0
  52. package/dist/commands/rename-execution-cache.js +1 -0
  53. package/dist/commands/rename-input.js +1 -0
  54. package/dist/commands/rename-preview-cache.js +2 -0
  55. package/dist/commands/result-view.js +6 -0
  56. package/dist/commands/runtime-command.js +4 -0
  57. package/dist/commands/runtime-info.js +1 -0
  58. package/dist/commands/session-workspace.js +31 -0
  59. package/dist/commands/shared.js +1 -0
  60. package/dist/commands/sync-command.js +2 -0
  61. package/dist/commands/validate-module-plan.js +2 -0
  62. package/dist/commands/workspace-cache.js +1 -0
  63. package/dist/compatibility/policy.js +1 -0
  64. package/dist/config/auto-start-ide.js +1 -0
  65. package/dist/config/defaults.js +1 -0
  66. package/dist/config/env-vars.js +1 -0
  67. package/dist/config/glob-match.js +1 -0
  68. package/dist/config/import-rules.js +1 -0
  69. package/dist/config/local-config.js +3 -0
  70. package/dist/config/mutation-comments.js +1 -0
  71. package/dist/config/path-aliases.js +1 -0
  72. package/dist/config/path-display.js +1 -0
  73. package/dist/config/product-storage.js +1 -0
  74. package/dist/config/resolve-command-alias.js +1 -0
  75. package/dist/config/resolve.js +1 -0
  76. package/dist/config/workspace-root.js +3 -0
  77. package/dist/config/workspace-state.js +1 -0
  78. package/dist/content/content-bundle.js +1 -0
  79. package/dist/diagnostics/module-plan-timeline.js +2 -0
  80. package/dist/diagnostics/readiness-text.js +8 -0
  81. package/dist/discovery/registry.js +1 -0
  82. package/dist/discovery/select-instance.js +1 -0
  83. package/dist/dsl/aib-dsl.js +1 -0
  84. package/dist/help/bootstrap.md +924 -0
  85. package/dist/help/diagnostics/doctor.json +70 -0
  86. package/dist/help/docs/basics.md +14 -0
  87. package/dist/help/docs/dsl.md +25 -0
  88. package/dist/help/docs/help-format.md +12 -0
  89. package/dist/help/docs/imports.normalize.md +36 -0
  90. package/dist/help/docs/inspect.code.md +29 -0
  91. package/dist/help/docs/inspect.deps.md +32 -0
  92. package/dist/help/docs/inspect.duplicates.md +72 -0
  93. package/dist/help/docs/inspect.exports.md +34 -0
  94. package/dist/help/docs/inspect.file.md +32 -0
  95. package/dist/help/docs/inspect.graph.md +112 -0
  96. package/dist/help/docs/inspect.imports.md +15 -0
  97. package/dist/help/docs/inspect.md +71 -0
  98. package/dist/help/docs/inspect.members.md +24 -0
  99. package/dist/help/docs/inspect.tree.md +30 -0
  100. package/dist/help/docs/inspect.usages.md +48 -0
  101. package/dist/help/docs/modulePlan.md +51 -0
  102. package/dist/help/docs/move.md +37 -0
  103. package/dist/help/docs/mutation.md +47 -0
  104. package/dist/help/docs/patterns.md +178 -0
  105. package/dist/help/docs/prefs.md +40 -0
  106. package/dist/help/docs/qr.md +33 -0
  107. package/dist/help/docs/refactor.batch.md +44 -0
  108. package/dist/help/docs/rename.md +39 -0
  109. package/dist/help/docs/selectors.md +23 -0
  110. package/dist/help/docs/session.md +61 -0
  111. package/dist/help/docs/view.md +30 -0
  112. package/dist/help/dsl/bootstrap.md +924 -0
  113. package/dist/help/dsl/docs/basics.md +14 -0
  114. package/dist/help/dsl/docs/dsl.md +25 -0
  115. package/dist/help/dsl/docs/help-format.md +12 -0
  116. package/dist/help/dsl/docs/imports.normalize.md +36 -0
  117. package/dist/help/dsl/docs/inspect.code.md +29 -0
  118. package/dist/help/dsl/docs/inspect.deps.md +32 -0
  119. package/dist/help/dsl/docs/inspect.duplicates.md +72 -0
  120. package/dist/help/dsl/docs/inspect.exports.md +34 -0
  121. package/dist/help/dsl/docs/inspect.file.md +32 -0
  122. package/dist/help/dsl/docs/inspect.graph.md +112 -0
  123. package/dist/help/dsl/docs/inspect.imports.md +15 -0
  124. package/dist/help/dsl/docs/inspect.md +71 -0
  125. package/dist/help/dsl/docs/inspect.members.md +24 -0
  126. package/dist/help/dsl/docs/inspect.tree.md +30 -0
  127. package/dist/help/dsl/docs/inspect.usages.md +48 -0
  128. package/dist/help/dsl/docs/modulePlan.md +51 -0
  129. package/dist/help/dsl/docs/move.md +37 -0
  130. package/dist/help/dsl/docs/mutation.md +47 -0
  131. package/dist/help/dsl/docs/patterns.md +178 -0
  132. package/dist/help/dsl/docs/prefs.md +40 -0
  133. package/dist/help/dsl/docs/qr.md +33 -0
  134. package/dist/help/dsl/docs/refactor.batch.md +44 -0
  135. package/dist/help/dsl/docs/rename.md +39 -0
  136. package/dist/help/dsl/docs/selectors.md +23 -0
  137. package/dist/help/dsl/docs/session.md +61 -0
  138. package/dist/help/dsl/docs/view.md +30 -0
  139. package/dist/help/dsl/full.md +924 -0
  140. package/dist/help/dsl/snippets/agents.md +14 -0
  141. package/dist/help/dsl/topics/basics.md +12 -0
  142. package/dist/help/dsl/topics/dsl.md +23 -0
  143. package/dist/help/dsl/topics/help-format.md +10 -0
  144. package/dist/help/dsl/topics/imports.normalize.md +34 -0
  145. package/dist/help/dsl/topics/inspect.code.md +27 -0
  146. package/dist/help/dsl/topics/inspect.deps.md +30 -0
  147. package/dist/help/dsl/topics/inspect.duplicates.md +43 -0
  148. package/dist/help/dsl/topics/inspect.exports.md +32 -0
  149. package/dist/help/dsl/topics/inspect.file.md +30 -0
  150. package/dist/help/dsl/topics/inspect.graph.md +110 -0
  151. package/dist/help/dsl/topics/inspect.imports.md +13 -0
  152. package/dist/help/dsl/topics/inspect.md +69 -0
  153. package/dist/help/dsl/topics/inspect.members.md +22 -0
  154. package/dist/help/dsl/topics/inspect.tree.md +20 -0
  155. package/dist/help/dsl/topics/inspect.usages.md +46 -0
  156. package/dist/help/dsl/topics/modulePlan.md +38 -0
  157. package/dist/help/dsl/topics/move.md +27 -0
  158. package/dist/help/dsl/topics/mutation.md +45 -0
  159. package/dist/help/dsl/topics/patterns.md +176 -0
  160. package/dist/help/dsl/topics/prefs.md +38 -0
  161. package/dist/help/dsl/topics/qr.md +31 -0
  162. package/dist/help/dsl/topics/refactor.batch.md +33 -0
  163. package/dist/help/dsl/topics/rename.md +25 -0
  164. package/dist/help/dsl/topics/selectors.md +21 -0
  165. package/dist/help/dsl/topics/session.md +59 -0
  166. package/dist/help/dsl/topics/view.md +28 -0
  167. package/dist/help/full.md +924 -0
  168. package/dist/help/help-meta.json +113 -0
  169. package/dist/help/index.md +167 -0
  170. package/dist/help/json/bootstrap.md +1074 -0
  171. package/dist/help/json/docs/basics.md +15 -0
  172. package/dist/help/json/docs/dsl.md +25 -0
  173. package/dist/help/json/docs/help-format.md +12 -0
  174. package/dist/help/json/docs/imports.normalize.md +47 -0
  175. package/dist/help/json/docs/inspect.code.md +41 -0
  176. package/dist/help/json/docs/inspect.deps.md +46 -0
  177. package/dist/help/json/docs/inspect.duplicates.md +65 -0
  178. package/dist/help/json/docs/inspect.exports.md +40 -0
  179. package/dist/help/json/docs/inspect.file.md +38 -0
  180. package/dist/help/json/docs/inspect.graph.md +139 -0
  181. package/dist/help/json/docs/inspect.imports.md +15 -0
  182. package/dist/help/json/docs/inspect.md +87 -0
  183. package/dist/help/json/docs/inspect.members.md +32 -0
  184. package/dist/help/json/docs/inspect.tree.md +30 -0
  185. package/dist/help/json/docs/inspect.usages.md +61 -0
  186. package/dist/help/json/docs/modulePlan.md +70 -0
  187. package/dist/help/json/docs/move.md +53 -0
  188. package/dist/help/json/docs/mutation.md +62 -0
  189. package/dist/help/json/docs/patterns.md +178 -0
  190. package/dist/help/json/docs/prefs.md +40 -0
  191. package/dist/help/json/docs/qr.md +33 -0
  192. package/dist/help/json/docs/refactor.batch.md +72 -0
  193. package/dist/help/json/docs/rename.md +47 -0
  194. package/dist/help/json/docs/selectors.md +23 -0
  195. package/dist/help/json/docs/session.md +77 -0
  196. package/dist/help/json/docs/view.md +30 -0
  197. package/dist/help/json/full.md +1074 -0
  198. package/dist/help/json/snippets/agents.md +14 -0
  199. package/dist/help/json/topics/basics.md +13 -0
  200. package/dist/help/json/topics/dsl.md +23 -0
  201. package/dist/help/json/topics/help-format.md +10 -0
  202. package/dist/help/json/topics/imports.normalize.md +45 -0
  203. package/dist/help/json/topics/inspect.code.md +39 -0
  204. package/dist/help/json/topics/inspect.deps.md +44 -0
  205. package/dist/help/json/topics/inspect.duplicates.md +37 -0
  206. package/dist/help/json/topics/inspect.exports.md +38 -0
  207. package/dist/help/json/topics/inspect.file.md +36 -0
  208. package/dist/help/json/topics/inspect.graph.md +137 -0
  209. package/dist/help/json/topics/inspect.imports.md +13 -0
  210. package/dist/help/json/topics/inspect.md +85 -0
  211. package/dist/help/json/topics/inspect.members.md +30 -0
  212. package/dist/help/json/topics/inspect.tree.md +20 -0
  213. package/dist/help/json/topics/inspect.usages.md +59 -0
  214. package/dist/help/json/topics/modulePlan.md +57 -0
  215. package/dist/help/json/topics/move.md +43 -0
  216. package/dist/help/json/topics/mutation.md +60 -0
  217. package/dist/help/json/topics/patterns.md +176 -0
  218. package/dist/help/json/topics/prefs.md +38 -0
  219. package/dist/help/json/topics/qr.md +31 -0
  220. package/dist/help/json/topics/refactor.batch.md +61 -0
  221. package/dist/help/json/topics/rename.md +42 -0
  222. package/dist/help/json/topics/selectors.md +21 -0
  223. package/dist/help/json/topics/session.md +59 -0
  224. package/dist/help/json/topics/view.md +28 -0
  225. package/dist/help/snippets/agents.md +14 -0
  226. package/dist/help/topics/basics.md +12 -0
  227. package/dist/help/topics/dsl.md +23 -0
  228. package/dist/help/topics/help-format.md +10 -0
  229. package/dist/help/topics/imports.normalize.md +34 -0
  230. package/dist/help/topics/inspect.code.md +27 -0
  231. package/dist/help/topics/inspect.deps.md +30 -0
  232. package/dist/help/topics/inspect.duplicates.md +43 -0
  233. package/dist/help/topics/inspect.exports.md +32 -0
  234. package/dist/help/topics/inspect.file.md +30 -0
  235. package/dist/help/topics/inspect.graph.md +110 -0
  236. package/dist/help/topics/inspect.imports.md +13 -0
  237. package/dist/help/topics/inspect.md +69 -0
  238. package/dist/help/topics/inspect.members.md +22 -0
  239. package/dist/help/topics/inspect.tree.md +20 -0
  240. package/dist/help/topics/inspect.usages.md +46 -0
  241. package/dist/help/topics/modulePlan.md +38 -0
  242. package/dist/help/topics/move.md +27 -0
  243. package/dist/help/topics/mutation.md +45 -0
  244. package/dist/help/topics/patterns.md +176 -0
  245. package/dist/help/topics/prefs.md +38 -0
  246. package/dist/help/topics/qr.md +31 -0
  247. package/dist/help/topics/refactor.batch.md +33 -0
  248. package/dist/help/topics/rename.md +25 -0
  249. package/dist/help/topics/selectors.md +21 -0
  250. package/dist/help/topics/session.md +59 -0
  251. package/dist/help/topics/view.md +28 -0
  252. package/dist/ide-launch/common.cjs +162 -0
  253. package/dist/managed-host/extension-vsix-resolver.js +1 -0
  254. package/dist/managed-host/manage-serve-web-host.cjs +141 -0
  255. package/dist/managed-host/serve-web-autostart.js +1 -0
  256. package/dist/managed-host/serve-web-host.cjs +1790 -0
  257. package/dist/metrics/central-metrics.js +2 -0
  258. package/dist/observability/config.js +1 -0
  259. package/dist/observability/context.js +1 -0
  260. package/dist/observability/failure-snapshot.js +2 -0
  261. package/dist/observability/recent.js +2 -0
  262. package/dist/payloads/read-stdin-json.js +1 -0
  263. package/dist/runtime/bundled-node.js +1 -0
  264. package/dist/runtime/input-source.js +1 -0
  265. package/dist/runtime/managed-runtime-provisioning.js +1 -0
  266. package/dist/runtime/run-command.js +1 -0
  267. package/dist/selectors/parse-entities.js +1 -0
  268. package/dist/session/client.js +1 -0
  269. package/dist/session/paths.js +1 -0
  270. package/dist/session/server.js +6 -0
  271. package/dist/shared/agent-text.js +1 -0
  272. package/dist/shared/diagnostic-catalog.js +1 -0
  273. package/dist/shared/diagnostics.js +1 -0
  274. package/dist/shared/errors.js +28 -0
  275. package/dist/shared/event-loop.js +1 -0
  276. package/dist/shared/hints.js +1 -0
  277. package/dist/shared/metrics.js +1 -0
  278. package/dist/shared/operations.js +1 -0
  279. package/dist/shared/presentation.js +4 -0
  280. package/dist/shared/protocol.js +1 -0
  281. package/dist/shared/routes.js +1 -0
  282. package/dist/shared/stdout.js +2 -0
  283. package/dist/shared/types.js +1 -0
  284. package/dist/tracing/config.js +2 -0
  285. package/dist/tracing/trace.js +3 -0
  286. package/extension/vscode-refactor-bridge-extension.vsix +0 -0
  287. package/package.json +39 -0
  288. package/runtimes/launcher/win-x64/aib.exe +0 -0
  289. package/scripts/install-windows-launcher.cjs +58 -0
  290. package/scripts/postinstall.cjs +28 -0
  291. package/scripts/provision-runtime.cjs +299 -0
package/README.md ADDED
@@ -0,0 +1,578 @@
1
+ # aib CLI
2
+
3
+ CLI для подключения к живому `aib` extension instance.
4
+
5
+ Текущая цель пакета:
6
+
7
+ - discovery instance по локальному registry;
8
+ - session runtime, который переиспользуется между вызовами;
9
+ - базовые debug-команды;
10
+ - semantic operations поверх extension runtime.
11
+
12
+ ## Current Commands
13
+
14
+ - `aib listInstances`
15
+ - `aib ping`
16
+ - `aib runtimeInfo`
17
+ - `aib printConfig`
18
+ - `aib init-skill-usage`
19
+ - `aib inspect file <file> [--ranges] [--local-only]`
20
+ - `aib inspect exports <file> [--ranges]`
21
+ - `aib inspect exports <file> --resolve-star`
22
+ - `aib inspect members <file> <entity> [--ranges] [--offset <n>] [--limit <n>] [--all]`
23
+ - `aib inspect code <file> <entity> [--parent <entity>] [--ranges] [--max-lines <n>] [--to-file <path>]`
24
+ - `aib inspect dependencies <file> <entity> [--ranges]`
25
+ - `aib inspect slice <file> <entity> [--max-lines <n>] [--to-file <path>]`
26
+ - `aib modulePlan preview --stdin [--details]`
27
+ - `aib modulePlan preview --from-json <plan.json> [--details]`
28
+ - `aib inspect graph <file-or-directory> [--depth 0|1|2] [--exclude <glob>] [--exclude-from <file>]`
29
+ - `aib inspect graph --from-file <graph.json> --focus <file> [--symbols] [--symbol-usage]`
30
+ - `aib inspect --stdin`
31
+ - `aib imports importers <file-or-directory>`
32
+ - `aib imports unused <file>`
33
+ - `aib move toFile preview --stdin`
34
+ - `aib rename preview --stdin`
35
+ - `aib modulePlan apply --stdin`
36
+ - `aib modulePlan apply --from-json <plan.json>`
37
+ - `aib modulePlan apply <planId>`
38
+ - `aib modulePlan validate --plan <planId>`
39
+ - `aib trace status|set|clear`
40
+ - `aib session init|status|where|read|write|clear`
41
+ - `aib session start|stop`
42
+
43
+ ## Global Flags
44
+
45
+ - `--cwd <path>`: resolve the target IDE instance for this workspace path.
46
+ - `--instance <id>`: target a specific registry instance. This never auto-starts another IDE host.
47
+ - `--transport http|websocket`: choose the extension transport for the request.
48
+ - `--metrics`: include opt-in timing spans.
49
+ - `--auto-start-ide`: if no live IDE matches `--cwd`, start or reuse a managed Windows VS Code `serve-web + headless client` host.
50
+ - `--no-auto-start-ide`: disable auto-start for one command, even if the environment enables it.
51
+
52
+ Environment:
53
+
54
+ - `AIB_AUTO_START_IDE=1` enables the same opt-in managed IDE startup as `--auto-start-ide`.
55
+ - `AIB_EXTENSION_VSIX=<path>` points managed startup at a packaged extension VSIX.
56
+ - `AIB_INSTALL_CONFIG=<path>` points managed startup at an install config JSON with `extensionVsix`.
57
+ - `AIB_TRACE_DIR=<path>` enables opt-in CLI trace capture for every command in that environment.
58
+
59
+ Auto-start is conservative for now:
60
+
61
+ - it is off by default;
62
+ - it is Windows VS Code `serve-web` only;
63
+ - canonical commands are the validated path;
64
+ - workspace alias settings in managed serve-web mode still need separate verification.
65
+
66
+ ## Trace Capture
67
+
68
+ Trace capture is off by default.
69
+
70
+ Enable it for one command:
71
+
72
+ ```powershell
73
+ aib --trace-dir .aib-trace doctor
74
+ ```
75
+
76
+ Enable it for a trial session:
77
+
78
+ ```powershell
79
+ $env:AIB_TRACE_DIR = ".aib-trace"
80
+ aib move toFile preview --stdin
81
+ ```
82
+
83
+ Enable it for the current project so it survives new shells:
84
+
85
+ ```powershell
86
+ aib trace set .aib-trace
87
+ aib trace status
88
+ ```
89
+
90
+ Clear the project trace setting without deleting existing trace files:
91
+
92
+ ```powershell
93
+ aib trace clear
94
+ ```
95
+
96
+ Priority is `--trace-dir`, then `AIB_TRACE_DIR`, then the project trace setting.
97
+ Relative trace paths are resolved against the CLI `cwd`. Trace output includes `trace.jsonl` plus per-call request/response/meta artifacts under `calls/`.
98
+
99
+ ## Inspect / Progressive Disclosure
100
+
101
+ Use `inspect` when an agent needs a compact semantic map before refactoring.
102
+
103
+ ```powershell
104
+ aib inspect file src/service.ts
105
+ aib inspect exports src/service.ts
106
+ aib inspect members src/service.ts c-Service
107
+ aib inspect members src/service.ts c-Service --offset 20 --limit 20
108
+ aib inspect members src/service.ts c-Service --all
109
+ aib inspect code src/service.ts m-save --parent c-Service
110
+ aib inspect code src/service.ts v-LARGE_TABLE --to-file .aib-slices/large-table.ts
111
+ aib inspect dependencies src/service.ts c-Service
112
+ aib inspect slice src/service.ts c-Service --to-file .aib-slices/service.ts
113
+ aib inspect exports src/index.ts --resolve-star
114
+ aib inspect file src/service.ts --ranges
115
+ aib inspect file src/index.ts --local-only
116
+ ```
117
+
118
+ Batch inspect requests:
119
+
120
+ ```powershell
121
+ @'
122
+ {
123
+ "file": "src/service.ts",
124
+ "requests": [
125
+ { "op": "file" },
126
+ { "op": "exports" },
127
+ { "op": "members", "entity": "c-Service" },
128
+ { "op": "code", "entity": "m-save", "parent": "c-Service" },
129
+ { "op": "slice", "entity": "c-Service", "toFile": ".aib-slices/service.ts" }
130
+ ]
131
+ }
132
+ '@ | aib inspect --stdin
133
+ ```
134
+
135
+ Uniform batch requests can avoid repeating both `file` and `op`:
136
+
137
+ ```powershell
138
+ @'
139
+ {
140
+ "file": "src/service.ts",
141
+ "op": "dependencies",
142
+ "entities": [
143
+ "f-createService",
144
+ "c-Service"
145
+ ]
146
+ }
147
+ '@ | aib inspect --stdin
148
+ ```
149
+
150
+ Uniform `dependencies` and `members` batches return grouped compact output keyed by entity selector.
151
+
152
+ `dependencies` output is grouped by usage:
153
+
154
+ ```json
155
+ {
156
+ "typeOnly": ["i-CartLine", "t-CurrencyCode"],
157
+ "value": ["f-createMoney", "v-TIER_DISCOUNT"]
158
+ }
159
+ ```
160
+
161
+ `unclassified` is shown only when nonempty. It means the inspect layer found a local dependency but could not safely classify the usage position with the current syntax heuristic.
162
+
163
+ Default inspect output is compact and uses fixed selector aliases (`c-`, `i-`, `t-`, `f-`, `v-`, `e-`, `m-`, `p-`). Workspace selector alias overrides are intentionally ignored.
164
+
165
+ `inspect file --local-only` answers the physical-file question. It reports local declarations and re-export modules without resolving `export *` through a facade:
166
+
167
+ ```json
168
+ {
169
+ "file": "src/index.ts",
170
+ "results": [
171
+ {
172
+ "op": "file",
173
+ "mode": "local",
174
+ "summary": "facade only; 3 re-exports; 0 local declarations",
175
+ "symbols": [],
176
+ "reexports": ["./core/types.js", "./core/service.js", "./core/index.js"]
177
+ }
178
+ ]
179
+ }
180
+ ```
181
+
182
+ Use `inspect exports <file> --resolve-star` for the public API visible through a facade.
183
+
184
+ `inspect graph` gives a compact local file relationship map. It is local CLI logic and does not require an IDE runtime:
185
+
186
+ ```powershell
187
+ aib inspect graph src/main --depth 1
188
+ aib inspect graph src/main --depth 1 --exclude "**/* copy.ts"
189
+ aib inspect graph src/main --depth 1 --exclude-from .aib-graph-ignore
190
+ ```
191
+
192
+ Graph excludes can also be configured in `.aib.json`, `.aib.json`, or `.vscode/settings.json`:
193
+
194
+ ```json
195
+ {
196
+ "inspect": {
197
+ "graph": {
198
+ "exclude": ["**/* copy.ts", "src/generated/**"]
199
+ }
200
+ }
201
+ }
202
+ ```
203
+
204
+ Excludes are applied before the graph model is built, so excluded files do not affect counts, hubs, leaves, edges, or saved graph files.
205
+
206
+ `members` is compact by default: it returns the first page of members plus a hidden-count marker when more members exist. Use `--all` for the full list or `--offset <n> --limit <n>` to page through a large class/interface without printing every member.
207
+
208
+ `code --to-file <path>` writes exact selected code to disk without printing it to stdout. Use it for large declarations that an agent needs to mechanically move or inspect without polluting context.
209
+
210
+ `inspect --stdin` supports per-request `toFile` / `outputFile` for `code` and `slice` rows. This lets an agent extract several selected declarations in one CLI call while stdout only reports compact `writtenTo` paths.
211
+
212
+ With a session workspace, use `save` to write selected code/slices and keep stdout compact:
213
+
214
+ ```powershell
215
+ aib session init --dir .tmp/aib
216
+ @'
217
+ {
218
+ "file": "src/service.ts",
219
+ "parent": "c-Service",
220
+ "requests": [
221
+ { "op": "code", "entity": "m-save", "save": "service-save-method" },
222
+ { "op": "slice", "entity": "c-Service", "parent": null, "save": "service-class" }
223
+ ]
224
+ }
225
+ '@ | aib inspect --stdin
226
+ ```
227
+
228
+ Use `bundleSave` when several inspect rows form one reusable context packet. Per-request `save` still works:
229
+
230
+ ```powershell
231
+ @'
232
+ {
233
+ "file": "src/service.ts",
234
+ "parent": "c-Service",
235
+ "bundleSave": "service-context",
236
+ "requests": [
237
+ { "op": "members", "entity": "c-Service" },
238
+ { "op": "code", "entity": "m-save", "save": "service-save-method" },
239
+ { "op": "slice", "entity": "c-Service", "parent": null, "save": "service-class" }
240
+ ]
241
+ }
242
+ '@ | aib inspect --stdin
243
+ ```
244
+
245
+ The bundle is saved as `aib:inspect:service-context` and can be read with `session read`.
246
+
247
+ Read saved artifacts back into context by handle:
248
+
249
+ ```powershell
250
+ aib session read aib:code:service-save-method
251
+ aib session read aib:slice:service-class --head 80
252
+ ```
253
+
254
+ Batch reads avoid repeated CLI calls:
255
+
256
+ ```powershell
257
+ @'
258
+ {
259
+ "reads": [
260
+ { "handle": "aib:code:service-save-method" },
261
+ { "handle": "aib:slice:service-class", "offset": 30, "limit": 50 }
262
+ ]
263
+ }
264
+ '@ | aib session read --stdin
265
+ ```
266
+
267
+ `modulePlan` validates an agent-proposed module split without editing source files. It reports compact per-target summaries with exported symbols, private symbols, type-only imports, runtime imports, unassigned dependencies, runtime cycles, and facade export suggestions:
268
+
269
+ ```powershell
270
+ @'
271
+ {
272
+ "file": "src/service.ts",
273
+ "op": "modulePlan",
274
+ "facade": "src/service.ts",
275
+ "modules": [
276
+ {
277
+ "target": "src/core/types.ts",
278
+ "symbols": ["i-ServiceOptions", "t-ServiceMode"]
279
+ },
280
+ {
281
+ "target": "src/core/service.ts",
282
+ "symbols": ["c-Service", "f-createService"]
283
+ }
284
+ ]
285
+ }
286
+ '@ | aib modulePlan preview --stdin
287
+ ```
288
+
289
+ For large plans, write the same JSON to a temporary file and edit that file with normal file tools instead of repeatedly printing long heredocs:
290
+
291
+ ```powershell
292
+ aib modulePlan preview --from-json .aib-plan/module-plan.json
293
+ ```
294
+
295
+ Add `"previewFiles": true` to write read-only preview artifacts without changing source files:
296
+
297
+ ```json
298
+ {
299
+ "file": "src/service.ts",
300
+ "op": "modulePlan",
301
+ "facade": "src/service.ts",
302
+ "previewFiles": true,
303
+ "previewDir": ".aib-preview/service-split",
304
+ "modules": [
305
+ {
306
+ "target": "src/core/types.ts",
307
+ "symbols": ["i-ServiceOptions", "t-ServiceMode"]
308
+ },
309
+ {
310
+ "target": "src/core/service.ts",
311
+ "symbols": ["c-Service", "f-createService"]
312
+ }
313
+ ]
314
+ }
315
+ ```
316
+
317
+ The response stays compact and points to generated artifacts:
318
+
319
+ ```json
320
+ {
321
+ "planId": "plan_abc123",
322
+ "planHash": "sha256:...",
323
+ "next": "Run modulePlan apply plan_abc123 if the plan matches intent.",
324
+ "preview": {
325
+ "dir": ".aib-plan-cache/previews/plan_abc123",
326
+ "summary": "2 files; facade 2l; patch 120l; cycles none",
327
+ "files": {
328
+ "src/core/service.ts": {
329
+ "file": ".aib-plan-cache/previews/plan_abc123/files/core/service.ts",
330
+ "lines": 80
331
+ }
332
+ },
333
+ "facade": {
334
+ "file": ".aib-preview/service-split/facade/service.ts",
335
+ "lines": 2
336
+ },
337
+ "patch": {
338
+ "file": ".aib-preview/service-split/module-plan.preview.patch",
339
+ "lines": 120
340
+ },
341
+ "next": ["check summary/api/cycles/imports", "read targeted preview artifacts only if a warning/check points there", "use top-level next for apply/revise action"]
342
+ }
343
+ }
344
+ ```
345
+
346
+ Default `modulePlan` output uses compact `targets[].summary` rows, for example `exports c-Service; private f-normalize; imports type src/core/types.ts: i-Options; run src/core/helpers.ts: f-createHelper`. Add `--details` only when an agent needs the full module ownership/import map in stdout.
347
+
348
+ When `modulePlan preview` includes preview files, the plan is cached under `.aib-plan-cache/` and can be applied without resending the module JSON if it is executable:
349
+
350
+ ```powershell
351
+ aib modulePlan apply plan_abc123
352
+ ```
353
+
354
+ After apply, run a compact generated-module validation:
355
+
356
+ ```powershell
357
+ aib modulePlan validate --plan plan_abc123
358
+ ```
359
+
360
+ It checks that expected generated files exist, generated relative import/export specifiers use `.js`, generated modules do not import back from the facade, and the cached facade/API expectation is still visible.
361
+
362
+ `modulePlan` also reports public API preservation when a facade is requested:
363
+
364
+ ```json
365
+ {
366
+ "api": {
367
+ "status": "preserved",
368
+ "before": 44,
369
+ "after": 44
370
+ }
371
+ }
372
+ ```
373
+
374
+ If a generated module would import a symbol from another generated module that is not exported there, `modulePlan` returns a compact diagnostic-first response. The plan is cached as non-executable, so it can be revised by id but cannot be applied:
375
+
376
+ ```json
377
+ {
378
+ "ok": false,
379
+ "planId": "plan_blocked123",
380
+ "executable": false,
381
+ "blocking": [
382
+ {
383
+ "from": "src/commerce/pricing.ts",
384
+ "source": "src/commerce/customer.ts",
385
+ "usage": "value",
386
+ "symbols": ["v-TIER_DISCOUNT"],
387
+ "suggestedFixes": [{ "kind": "moveSymbol", "symbol": "v-TIER_DISCOUNT", "to": "src/commerce/pricing.ts" }],
388
+ "hint": "Move the symbol into the importing module, move the dependent symbol into the owner module, or intentionally export it before applying."
389
+ }
390
+ ],
391
+ "next": "Revise with: aib modulePlan revise --plan plan_blocked123 --stdin"
392
+ }
393
+ ```
394
+
395
+ Revise a blocked plan without resending the full module JSON:
396
+
397
+ ```powershell
398
+ @'
399
+ {
400
+ "applySuggestedFixes": [0]
401
+ }
402
+ '@ | aib modulePlan revise --plan plan_blocked123 --stdin
403
+ ```
404
+
405
+ Or move a symbol explicitly:
406
+
407
+ ```powershell
408
+ @'
409
+ {
410
+ "moves": [
411
+ { "symbol": "v-TIER_DISCOUNT", "to": "src/commerce/pricing.ts" }
412
+ ]
413
+ }
414
+ '@ | aib modulePlan revise --plan plan_blocked123 --stdin
415
+ ```
416
+
417
+ When generated preview artifacts are large, the response adds a compact `large` list and changes the first `next` hint so agents do not read large files or patches by default:
418
+
419
+ ```json
420
+ {
421
+ "preview": {
422
+ "summary": "11 files; facade 11l; patch 2687l; cycles none",
423
+ "large": ["src/commerce/workflow.ts 1336l", "patch 2687l"],
424
+ "next": ["check summary/imports/exports before reading large preview artifacts", "copy preview if acceptable", "run project checks"]
425
+ }
426
+ }
427
+ ```
428
+
429
+ If runtime cycles are detected, the preview response warns and points the next action back at the plan instead of applying files.
430
+
431
+ Preview artifacts are intentionally read-only planning outputs. They do not remove declarations from the source file or apply edits.
432
+
433
+ `modulePlan apply` is the apply gate for a validated module plan. Its preview accepts the same layout shape as `modulePlan preview`, writes cached preview artifacts, and returns a compact apply summary instead of repeating the full module map:
434
+
435
+ ```powershell
436
+ @'
437
+ {
438
+ "sourceFile": "src/service.ts",
439
+ "facadeFile": "src/service.ts",
440
+ "modules": [
441
+ {
442
+ "targetFile": "src/core/types.ts",
443
+ "symbols": ["i-ServiceOptions", "t-ServiceMode"]
444
+ },
445
+ {
446
+ "targetFile": "src/core/service.ts",
447
+ "symbols": ["c-Service", "f-createService"]
448
+ }
449
+ ],
450
+ "execute": false
451
+ }
452
+ '@ | aib modulePlan apply --stdin
453
+ ```
454
+
455
+ Compact preview:
456
+
457
+ ```json
458
+ {
459
+ "operation": "modulePlan.apply",
460
+ "execute": false,
461
+ "planId": "plan_abc123",
462
+ "summary": "2 files; facade 2l; patch 120l; cycles none; public API preserved",
463
+ "targets": [
464
+ {
465
+ "file": "src/core/types.ts",
466
+ "summary": "exports i-ServiceOptions, t-ServiceMode"
467
+ },
468
+ {
469
+ "file": "src/core/service.ts",
470
+ "summary": "exports c-Service, f-createService; imports type ./types.js: i-ServiceOptions, t-ServiceMode"
471
+ }
472
+ ],
473
+ "api": {
474
+ "status": "preserved",
475
+ "before": 4,
476
+ "after": 4,
477
+ "removed": [],
478
+ "added": []
479
+ },
480
+ "integrity": "2 declarations moved unchanged; 1 imports generated; facade exports 2",
481
+ "writes": ["src/core/types.ts", "src/core/service.ts", "src/service.ts"],
482
+ "warnings": [],
483
+ "next": "Run modulePlan apply plan_abc123 if the summary matches intent."
484
+ }
485
+ ```
486
+
487
+ Apply:
488
+
489
+ ```powershell
490
+ aib modulePlan apply plan_abc123
491
+ ```
492
+
493
+ Apply echoes the validation signals that matter after mutation:
494
+
495
+ ```json
496
+ {
497
+ "operation": "modulePlan.apply",
498
+ "execute": true,
499
+ "applied": true,
500
+ "planId": "plan_abc123",
501
+ "api": { "status": "preserved", "before": 4, "after": 4 },
502
+ "cycles": "none",
503
+ "facade": { "file": "src/service.ts", "exports": 2 },
504
+ "integrity": "2 declarations moved unchanged; 1 imports generated; facade exports 2",
505
+ "filesWritten": ["src/core/types.ts", "src/core/service.ts", "src/service.ts"],
506
+ "summary": "3 files written"
507
+ }
508
+ ```
509
+
510
+ `integrity` summarizes the current module-plan mutation strategy: selected declarations are moved unchanged from original source ranges, while imports and facade exports are generated around those declarations.
511
+
512
+ Inspect output intentionally avoids IDE/debug-only details in the agent-facing path:
513
+
514
+ - file paths are relative to the CLI `cwd` when possible;
515
+ - a shared file path is emitted once at response level instead of repeated on every result;
516
+ - successful results omit noisy `ok: true` wrappers;
517
+ - `--ranges` emits compact line metadata such as `l19 1260..1278`;
518
+ - character offsets and `selectionRange` stay out of stdout; use trace/debug artifacts if exact IDE ranges are needed.
519
+
520
+ Line metadata is 1-based and inclusive for human/agent navigation. Add `--ranges` only when line/range navigation is needed.
521
+
522
+ ## Workspace Config And Aliases
523
+
524
+ Agent-facing command and selector aliases are fixed product defaults. The CLI ignores workspace-level selector alias overrides so agents can rely on one selector contract across repositories.
525
+
526
+ CLI также умеет генерировать agent-facing usage instructions на основе effective config:
527
+
528
+ ```powershell
529
+ aib --cwd D:\dev\agent-ide\fixtures\ts-sandbox init-skill-usage
530
+ aib --cwd D:\dev\agent-ide\fixtures\ts-sandbox init-skill-usage --cli-name myagentcli
531
+ ```
532
+
533
+ ## Local Development
534
+
535
+ Из корня workspace:
536
+
537
+ ```powershell
538
+ cd D:\dev\agent-ide
539
+ npm run cli:typecheck
540
+ npm run cli:build
541
+ npm run cli:link
542
+ ```
543
+
544
+ После `npm link` команда доступна как:
545
+
546
+ ```powershell
547
+ aib ping
548
+ ```
549
+
550
+ ## Local Tarball / npx-Oriented Flow
551
+
552
+ Собрать локальный tarball:
553
+
554
+ ```powershell
555
+ cd D:\dev\agent-ide
556
+ npm run cli:pack
557
+ ```
558
+
559
+ Tarball появится в:
560
+
561
+ - `D:\dev\agent-ide\.tmp\aib-<version>.tgz`
562
+
563
+ Дальше можно запускать CLI не через `npm link`, а через временную установку tarball.
564
+
565
+ Пример:
566
+
567
+ ```powershell
568
+ npx --yes --package D:\dev\agent-ide\.tmp\aib-0.0.1.tgz aib ping --cwd D:\dev\agent-ide
569
+ ```
570
+
571
+ Это полезно как переходный локальный шаг перед будущим publishable `npx aib ...` flow.
572
+
573
+ Примеры semantic-команд через tarball:
574
+
575
+ ```powershell
576
+ npx --yes --package D:\dev\agent-ide\.tmp\aib-0.0.1.tgz aib imports importers fixtures\ts-sandbox\src\utils --cwd D:\dev\agent-ide
577
+ npx --yes --package D:\dev\agent-ide\.tmp\aib-0.0.1.tgz aib imports unused fixtures\ts-sandbox\src\services\unused-imports.ts --cwd D:\dev\agent-ide
578
+ ```
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("./cli");
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ "use strict";var O=exports&&exports.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const F=O(require("node:fs")),Z=O(require("node:path")),W=require("../payloads/read-stdin-json"),ee=require("../commands/doctor"),te=require("../commands/init-workspace"),j=require("../commands/inspect"),re=require("../commands/imports-command"),ne=require("../commands/config-command"),se=require("../commands/diagnostics-command"),ie=require("../commands/execution-command"),oe=require("../commands/feedback-command"),ae=require("../commands/observability-command"),ce=require("../commands/generate-docs-command"),ue=require("../commands/help-command"),de=require("../commands/runtime-command"),le=require("../commands/result-view"),fe=require("../commands/quick-read"),q=require("../commands/captured-input"),G=require("../commands/session-workspace"),U=require("../commands/session-workspace"),$=require("../config/path-aliases"),g=require("../session/client"),pe=require("../session/server"),me=require("../commands/module-plan-cache"),H=require("../config/resolve-command-alias"),_e=require("../config/auto-start-ide"),o=require("../config/env-vars"),B=require("../client/transport-options"),v=require("../shared/errors"),C=require("../shared/metrics"),J=require("../shared/presentation"),K=require("../tracing/config"),z=require("../tracing/trace"),Q=require("../runtime/input-source");function Ce(e){return e.ok===!1}let L=null,V=Date.now();function Ie(e){const t=[];let i=process.cwd(),r,E,N=process.env[o.CLI_ENV.metrics]==="1",p=(0,B.parseExtensionTransport)(process.env[o.CLI_ENV.transport])??void 0,m,y,I;for(let l=0;l<e.length;l+=1){const f=e[l];if(f){if(f==="--cwd"){const c=e[l+1];if(!c)throw new v.CliError("MISSING_FLAG_VALUE","Expected a value after --cwd.");i=c,l+=1;continue}if(f==="--instance"){const c=e[l+1];if(!c)throw new v.CliError("MISSING_FLAG_VALUE","Expected a value after --instance.");r=c,l+=1;continue}if(f==="--session"||f==="-s"){const c=e[l+1];if(!c)throw new v.CliError("MISSING_FLAG_VALUE",`Expected a value after ${f}.`);E=c,l+=1;continue}if(f==="--metrics"){N=!0;continue}if(f==="--dsl"||f==="--force-dsl"){I="dsl";continue}if(f==="--stdin-format"){const c=e[l+1];if(c!=="auto"&&c!=="dsl")throw new v.CliError("INVALID_STDIN_FORMAT","Expected --stdin-format to be auto or dsl.");I=c,l+=1;continue}if(f==="--trace-dir"){const c=e[l+1];if(!c)throw new v.CliError("MISSING_FLAG_VALUE","Expected a value after --trace-dir.");y=c,l+=1;continue}if(f==="--auto-start-ide"){m="serve-web";continue}if(f==="--no-auto-start-ide"){m="off";continue}if(f==="--transport"){const c=e[l+1],u=(0,B.parseExtensionTransport)(c);if(!u)throw new v.CliError("INVALID_TRANSPORT","Expected --transport to be either http or websocket.");p=u,l+=1;continue}t.push(f)}}const h=process.env[o.CLI_ENV.traceDir];return{commandArgs:t,cwd:i,instanceId:r,sessionId:E,metricsEnabled:N,transport:p,autoStartIde:(0,_e.resolveAutoStartIdePolicy)(m),trace:(0,K.resolveTraceConfig)(i,{...y!==void 0?{flagTraceDir:y}:{},...h!==void 0?{envTraceDir:h}:{}}),...I!==void 0?{stdinFormat:I}:{}}}async function Ee(){V=Date.now();const e=(0,C.metricsNow)(),t=[],{commandArgs:i,cwd:r,instanceId:E,sessionId:N,metricsEnabled:p,transport:m,autoStartIde:y,trace:I,stdinFormat:h}=Ie(process.argv.slice(2));await(0,U.runWithSessionOverride)(N,async()=>{const[l,...f]=i,c=(0,W.stripStdinFormatFlags)(f),u=c.restArgs,X=(0,C.metricsNow)(),s=await(0,H.resolveCanonicalCommandAlias)(l??"ping",r,E,y);if(p&&(0,C.recordSpan)(t,"cli.aliasResolution",X),(0,H.isRemovedAgentCommand)(s))throw new v.CliError("UNKNOWN_COMMAND",`Unknown command: ${s}`,{availableCommands:["doctor","diagnostics","listInstances","ping","runtimeInfo","printConfig","init-skill-usage","init","help","generate-docs","config","qr","sync","inspect","imports","view","execution","move","rename","refactor","modulePlan","session","runtime","trace","observability","feedback","note"]});if(s==="session"&&(u[0]??"status")==="serve"){await(0,pe.runSessionServerCli)();return}if(s==="trace"){const n=(0,K.runTraceCommand)(r,u,I);d(n);return}if(s==="diagnostics"){await(0,se.runDiagnosticsCommand)(u);return}if(s==="observability"){x(r,s,u,I);const n=(0,ae.runObservabilityCommand)(r,u);d(n);return}if(s==="feedback"||s==="note"){x(r,s,u,I);const n=(0,oe.runFeedbackCommand)(r,u,s);d(n);return}if(s==="init"){const n=(0,te.runInitWorkspace)(r,u);d(n);return}if(s==="help"){const n=(0,ue.runHelpCommand)(u);d(n);return}if(s==="generate-docs"){const n=(0,ce.runGenerateDocsCommand)(r,u);d(n);return}if(s==="config"){x(r,s,u,I);const n=(0,ne.runConfigCommand)(r,u);d(n);return}if(s==="runtime"){const n=await(0,de.runRuntimeCommand)(r,u);n.ok===!1&&(process.exitCode=1),d(n);return}if(s==="qr"){x(r,s,u,I);const n=await(0,fe.runQuickReadCommand)(r,u);n.ok===!1&&(process.exitCode=1),d(n);return}const D=ye(s,u),P=D?(0,U.readEffectiveSessionPathAliases)(r):{},a=D?(0,$.expandPathAliasesInArgs)(r,u,P):u,A=await(0,Q.resolveCommandInputSource)({command:s,cwd:r,restArgs:a,readStdinInput:()=>(0,W.readStdinPayloadWithSource)({command:s,restArgs:a,...c.format!==void 0||h!==void 0?{format:c.format??h}:{}})}),_=D?(0,$.expandPathAliasesInJson)(r,A.payload,P):A.payload;if(L=(0,z.startTrace)({cwd:r,argv:process.argv.slice(2),command:s,restArgs:a,...I.absoluteTraceDir!==void 0?{traceDir:I.absoluteTraceDir}:I.traceDir!==void 0?{traceDir:I.traceDir}:{},..._!==void 0?{stdinPayload:_}:{},startedAtMs:V}),s==="session"){const n=a[0]??"status";if(n==="init"||n==="clear"||n==="where"||n==="read"||n==="write"||n==="prefs"||n==="aliases"||n==="list"||n==="use"){const S=(0,G.runSessionWorkspaceCommand)(r,a,_);d(S);return}if(n==="status"){const S=(0,G.runSessionWorkspaceCommand)(r,a,_),b=await(0,g.getSessionStatus)();d({...S,runtime:Ae(b)});return}if(n==="start"){const S=await(0,g.startSession)();d(S);return}if(n==="stop"){const S=await(0,g.stopSession)();d(S);return}throw new v.CliError("UNKNOWN_SESSION_COMMAND",`Unknown aib session command: ${n}`)}if(s==="imports"&&a[0]==="normalize"){const n=(0,q.attachCapturedInput)(r,"imports",_,await(0,re.runImportsCommand)(r,a,_,{...E!==void 0?{explicitInstanceId:E}:{},autoStartIde:y,...m!==void 0?{transport:m}:{},...p?{metricsEnabled:!0}:{}},p?t:void 0),A.source);d(n);return}if(s==="execution"){const n=(0,ie.runExecutionCommand)(r,a);d(n);return}if(s==="view"){const n=(0,le.runResultViewCommand)(r,a,_);d(n);return}if(s==="doctor"){const n=await(0,ee.runDoctor)({cwd:r,runtime:a.includes("--runtime"),verbose:a.includes("--verbose"),json:a.includes("--json")});n.ok===!1&&(process.exitCode=1),d(n);return}if(s==="inspect"&&(a[0]==="graph"||a[0]==="tree"||a[0]==="cycles")){const n=(0,C.metricsNow)(),S=a[0]==="tree"?"tree":a[0]==="cycles"?"cycles":"graph",b=(0,q.attachCapturedInput)(r,S,_,await(0,j.runInspect)(r,a,_,{...E!==void 0?{explicitInstanceId:E}:{},autoStartIde:y,...m!==void 0?{transport:m}:{},...p?{metricsEnabled:!0}:{}}),A.source);p&&((0,C.recordSpan)(t,"cli.inspectGraph",n),(0,C.recordSpan)(t,"cli.total",e)),d(p?(0,C.appendMetrics)(b,t):b,m);return}if(s==="inspect"&&a.includes("--stdin")&&Ne(_)){const n=(0,C.metricsNow)(),S=(0,q.attachCapturedInput)(r,he(_),_,await(0,j.runInspect)(r,a,_,{...E!==void 0?{explicitInstanceId:E}:{},autoStartIde:y,...m!==void 0?{transport:m}:{},...p?{metricsEnabled:!0}:{}}),A.source);p&&((0,C.recordSpan)(t,"cli.inspectLocal",n),(0,C.recordSpan)(t,"cli.total",e)),d(p?(0,C.appendMetrics)(S,t):S,m);return}if((0,Q.commandRequiresPayload)(s,a,A))throw new v.CliError("STDIN_REQUIRED",`${s} currently expects a payload on stdin or --from.`);const w={command:s,restArgs:a,cwd:r},M=we(s,a);M&&(w.modulePlanExecutionId=M),N!==void 0&&(w.sessionId=N),E!==void 0&&(w.instanceId=E),_!==void 0&&(w.stdinPayload=_),A.source!==void 0&&(w.stdinInputSource=A.source),p&&(w.metricsEnabled=!0),m&&(w.transport=m),w.autoStartIde=y.mode;const k=Se();Object.keys(k).length>0&&(w.env=k);const Y=(0,C.metricsNow)(),T=await(0,g.callSession)(w,p?t:void 0);p&&((0,C.recordSpan)(t,"cli.callSession",Y),(0,C.recordSpan)(t,"cli.total",e));const R=p?(0,C.appendMetrics)(T,t):T;Ce(R)&&(process.exitCode=1),d(R,m)})}function Se(){const e=[o.CLI_ENV.managedHostScript,o.CLI_ENV.managedHostKind,o.CLI_ENV.managedHostRunDir,o.CLI_ENV.codeServerPath,o.CLI_ENV.extensionVsix,o.CLI_ENV.ideCommand,o.CLI_ENV.chromePath,o.CLI_ENV.managedHostWaitMs,o.CLI_ENV.workspaceRoot,o.CLI_ENV.disableWatchers,o.CLI_ENV.trace,o.CLI_ENV.traceDir,o.CLI_ENV.failureSnapshots,o.CLI_ENV.productStorageDir,o.CLI_ENV.metrics,o.CLI_ENV.metricsDir,o.CLI_ENV.metricsTag,o.CLI_ENV.mutationImpactMetrics,o.CLI_ENV.mutationImpactStream,o.CLI_ENV.testPostMutationCyclesDelayMs,o.CLI_ENV.testRefactorBatchDelayMs,o.CLI_ENV.testRenameDelayMs,o.CLI_ENV.modulePlanSyncWaitMs,o.CLI_ENV.refactorBatchSyncWaitMs,o.CLI_ENV.renameSyncWaitMs],t={};for(const i of e){const r=process.env[i];r!==void 0&&(t[i]=r)}return t}function we(e,t){if(e!=="modulePlan")return null;const i=t[0]??"";return i!=="execute"&&i!=="apply"?null:ve()??(0,me.buildModulePlanExecutionId)()}function ve(){const e=process.env.AIB_MODULE_PLAN_EXECUTION_ID;return e&&/^exec_[a-z0-9_-]+$/i.test(e)?e:null}function x(e,t,i,r){L=(0,z.startTrace)({cwd:e,argv:process.argv.slice(2),command:t,restArgs:i,...r.absoluteTraceDir!==void 0?{traceDir:r.absoluteTraceDir}:r.traceDir!==void 0?{traceDir:r.traceDir}:{},startedAtMs:V})}function ye(e,t){return e==="session"||e==="execution"||e==="observability"||e==="doctor"||e==="view"||e==="imports"&&t[0]==="normalize"||e==="inspect"&&(t[0]==="graph"||t[0]==="tree"||t[0]==="cycles"||t[0]==="imports"||t.includes("--stdin"))}function Ae(e){if(e.running===!0){const t=e.session&&typeof e.session=="object"&&!Array.isArray(e.session)?e.session:{},i=typeof t.pid=="number"?` pid ${t.pid}`:"",r=typeof t.port=="number"?` port ${t.port}`:"";return`running${i}${r}`.trim()}return e.processAlive===!0&&e.healthy===!1?"unhealthy":"stopped"}function Ne(e){return!e||typeof e!="object"||Array.isArray(e)?!1:e.op==="tree"||e.op==="cycles"||e.op==="imports"?!0:Array.isArray(e.requests)&&e.requests.some(t=>t&&typeof t=="object"&&!Array.isArray(t)&&(t.op==="tree"||t.op==="cycles"||t.op==="imports"))}function he(e){if(!e||typeof e!="object"||Array.isArray(e))return"inspect";const t=Array.isArray(e.requests)?e.requests.filter(i=>i&&typeof i=="object"&&!Array.isArray(i)):[e];return t.every(i=>i.op==="cycles")?"cycles":t.every(i=>i.op==="tree")?"tree":t.every(i=>i.op==="imports")?"imports":"inspect"}Ee().catch(e=>{const t=(0,v.errorPayload)(e);d(t),process.exitCode=1});function d(e,t){const i=(0,J.createCliPresentationEnvelope)(e);L?.enabled&&L.complete({output:i.tracePayload,exitCode:e.ok===!1?1:be(process.exitCode),durationMs:Date.now()-V,...t?{transport:t}:{}});const r=process.env.AIB_CANONICAL_JSON_PATH;r&&(F.default.mkdirSync(Z.default.dirname(r),{recursive:!0}),F.default.writeFileSync(r,`${JSON.stringify(i.tracePayload,null,2)}
3
+ `)),process.stdout.write((0,J.presentCliEnvelope)(i,process.env.AIB_FORCE_JSON==="1"?"json":"agent"))}function be(e){return typeof e=="number"?e:0}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.postJson=E;const c=require("../shared/errors"),d=require("./transport-options"),l=require("./websocket-client");async function E(e,r,n,u={}){const a=p(n,u);if((u.transport??(0,d.getPreferredTransport)())==="websocket")return(0,l.postJsonOverWebSocket)(e,r,a);const o=`http://${e.host}:${e.port}${r}`;let s;try{s=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}catch(t){throw new c.CliError("TRANSPORT_ERROR",`Failed to reach ${o}`,{url:o,cause:t instanceof Error?t.message:String(t)})}const f=await s.text();let i={};try{i=JSON.parse(f)}catch{throw new c.CliError("INVALID_JSON_RESPONSE",`Instance returned non-JSON response for ${r}`,{url:o,status:s.status,responseText:f})}if(!s.ok){const t=w(i);throw t?new c.CliError(t.code,t.message,{url:o,status:s.status,details:t.details}):new c.CliError("REMOTE_ERROR",`Instance returned ${s.status} for ${r}`,{url:o,status:s.status,payload:i})}return i}function p(e,r){return r.metricsEnabled!==!0||!e||typeof e!="object"||Array.isArray(e)?e:{...e,metricsEnabled:!0}}function w(e){return e.ok!==!1||typeof e.code!="string"?null:{code:e.code,message:typeof e.error=="string"?e.error:e.code,details:e.details??R(e)}}function R(e){const r={};for(const n of["hint","hints","sourceFile","targetFile","execute","candidates","sourceConsistency","diagnostic","symbol","newName"])e[n]!==void 0&&(r[n]=e[n]);return r}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.parseExtensionTransport=t,exports.getPreferredTransport=s,exports.setPreferredTransport=o;const n=require("../config/env-vars");let e=t(process.env[n.CLI_ENV.transport])??"http";function t(r){return r==="http"||r==="websocket"?r:null}function s(){return e}function o(r){e=r}
@@ -0,0 +1 @@
1
+ "use strict";var c=exports&&exports.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.postJsonOverWebSocket=f;const l=c(require("ws")),n=require("../shared/errors"),E=require("../shared/routes");async function f(e,t,u){const i=E.EXTENSION_ROUTE_OPERATIONS[t];if(!i)throw new n.CliError("UNSUPPORTED_WEBSOCKET_ROUTE",`Route is not available over WebSocket: ${t}`,{pathname:t});const o=e.transports?.websocket?.url??`ws://${e.host}:${e.port}/ws`,r=await d(o,{id:Date.now(),operation:i,body:u});if(r.payload&&typeof r.payload=="object"&&!Array.isArray(r.payload)){const s=r.payload;if(r.ok===!1||typeof r.statusCode=="number"&&r.statusCode>=400){const a=S(s);throw a?new n.CliError(a.code,a.message,{url:o,status:typeof r.statusCode=="number"?r.statusCode:null,details:a.details}):new n.CliError("REMOTE_ERROR",`Instance returned ${String(r.statusCode??"error")} for ${t}`,{url:o,status:typeof r.statusCode=="number"?r.statusCode:null,payload:s})}return s}throw new n.CliError("INVALID_WEBSOCKET_RESPONSE",`Instance returned an invalid WebSocket payload for ${t}`,{url:o,envelope:r})}function d(e,t){return new Promise((u,i)=>{const o=new l.default(e);o.once("open",()=>{o.send(JSON.stringify(t))}),o.once("message",r=>{try{u(JSON.parse(r.toString("utf8")))}catch(s){i(new n.CliError("INVALID_WEBSOCKET_RESPONSE",`Instance returned non-JSON WebSocket response for ${e}`,{url:e,cause:s instanceof Error?s.message:String(s)}))}finally{o.close()}}),o.once("error",r=>{i(new n.CliError("TRANSPORT_ERROR",`Failed to reach ${e}`,{url:e,cause:r.message}))})})}function S(e){return e.ok!==!1||typeof e.code!="string"?null:{code:e.code,message:typeof e.error=="string"?e.error:e.code,details:e.details??null}}
@@ -0,0 +1,2 @@
1
+ "use strict";var f=exports&&exports.__createBinding||(Object.create?(function(r,e,t,i){i===void 0&&(i=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,i,n)}):(function(r,e,t,i){i===void 0&&(i=t),r[i]=e[t]})),d=exports&&exports.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),c=exports&&exports.__importStar||(function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var i=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[i.length]=n);return i},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i=r(e),n=0;n<i.length;n++)i[n]!=="default"&&f(t,e,i[n]);return d(t,e),t}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildAddMissingImportsPreviewId=g,exports.buildAddMissingImportsPreviewHash=y,exports.readAddMissingImportsPreviewRecord=P,exports.writeAddMissingImportsPreviewRecord=m,exports.hashFiles=w;const l=c(require("node:crypto")),s=c(require("node:fs")),h=c(require("node:path")),p=require("../shared/errors"),_=require("./workspace-cache");function g(r){return`imports_${o(u(r)).slice(0,10)}`}function y(r,e,t){return`sha256:${o(u({normalizedPayload:r,fileHashes:e,summary:t.summary,files:t.files}))}`}function P(r,e){const t=a(r,e);if(!s.existsSync(t))throw new p.CliError("ADD_MISSING_IMPORTS_PREVIEW_NOT_FOUND",`Add missing imports preview not found: ${e}`,{previewId:e,expectedPath:t});return JSON.parse(s.readFileSync(t,"utf8"))}function m(r,e){const t=a(r,e.previewId);s.mkdirSync(h.dirname(t),{recursive:!0}),s.writeFileSync(t,`${JSON.stringify(e,null,2)}
2
+ `)}function w(r){const e={};for(const t of r)e[t]=s.existsSync(t)?o(s.readFileSync(t)):"missing";return e}function a(r,e){return(0,_.workspaceCachePath)(r,"add-missing-imports-previews",`${b(e)}.json`)}function o(r){return l.createHash("sha256").update(r).digest("hex")}function u(r){return r===null||typeof r!="object"?JSON.stringify(r):Array.isArray(r)?`[${r.map(e=>u(e)).join(",")}]`:`{${Object.entries(r).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${u(t)}`).join(",")}}`}function b(r){return r.replace(/[^a-z0-9_-]+/gi,"-")}
@@ -0,0 +1,2 @@
1
+ "use strict";var R=exports&&exports.__createBinding||(Object.create?(function(t,e,i,r){r===void 0&&(r=i);var n=Object.getOwnPropertyDescriptor(e,i);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,r,n)}):(function(t,e,i,r){r===void 0&&(r=i),t[r]=e[i]})),D=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),x=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(i){var r=[];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(r[r.length]=n);return r},t(e)};return function(e){if(e&&e.__esModule)return e;var i={};if(e!=null)for(var r=t(e),n=0;n<r.length;n++)r[n]!=="default"&&R(i,e,r[n]);return D(i,e),i}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.runAddMissingImports=C;const y=x(require("node:path")),h=require("zod"),j=require("../client/http-client"),I=require("../shared/agent-text"),f=require("../shared/errors"),$=require("../shared/protocol"),F=require("../shared/routes"),M=require("./shared"),d=require("./add-missing-imports-preview-cache"),v=h.z.object({scope:h.z.string().min(1),execute:h.z.boolean().optional()});async function C(t,e,i={},r=[]){const n=r[0]??"preview";if(n==="help"||n==="--help")return{command:"imports addMissing",usage:["aib imports addMissing preview <file-or-dir>","aib imports addMissing apply <previewId>","aib imports addMissing execute <file-or-dir>"]};if(n==="apply"){const s=r[1];if(!s||s.startsWith("--"))throw new f.CliError("ADD_MISSING_IMPORTS_PREVIEW_ID_REQUIRED","imports addMissing apply expects a preview id.",{usage:"aib imports addMissing apply <previewId>"});return T(t,s,i)}const c=W(r),a=O(e??c,n==="execute");return b(t,a,i)}async function T(t,e,i){const r=(0,d.readAddMissingImportsPreviewRecord)(t,e),n=(0,d.hashFiles)(Object.keys(r.fileHashes));for(const[u,o]of Object.entries(r.fileHashes))if(n[u]!==o)throw new f.CliError("ADD_MISSING_IMPORTS_PREVIEW_FILES_CHANGED","Files changed after imports addMissing preview. Rerun preview.",{previewId:e,file:m(t,u)});const c=v.parse({...r.normalizedPayload,execute:!0}),s={...await b(t,c,i,e),operation:"imports.addMissing.apply"};return(0,I.attachAgentText)(s,A(s))}async function b(t,e,i,r){const n=await(0,M.resolveCompatibleTargetInstance)(t,$.CLI_COMMAND_IDS.addMissingImports,i),c=e.execute===!0,a=await(0,j.postJson)(n.entry,F.EXTENSION_ROUTES.addMissingImports,{scope:e.scope,execute:c},(0,M.extensionRequestOptions)(i)),s=q(t,a,c,r);if(!c&&s.ok!==!1){const u=O(e,!1),o=(0,d.buildAddMissingImportsPreviewId)(u),S=Array.isArray(s.allTouchedFiles)?s.allTouchedFiles.filter(E=>typeof E=="string"):[],_=(0,d.hashFiles)(S),w=(0,d.buildAddMissingImportsPreviewHash)(u,_,s);(0,d.writeAddMissingImportsPreviewRecord)(t,{previewId:o,previewHash:w,createdAt:new Date().toISOString(),cwd:y.resolve(t),normalizedPayload:u,fileHashes:_,previewResult:s}),s.previewId=o,s.next=`aib imports addMissing apply ${o}`}return(0,I.attachAgentText)(s,A(s))}function q(t,e,i,r){if(e.ok===!1)return e;const c=(Array.isArray(e.files)?e.files.filter(z):[]).filter(o=>l(o,"editCount")>0),a=Array.isArray(e.changedFiles)?e.changedFiles.filter(o=>typeof o=="string"):c.map(o=>typeof o.file=="string"?o.file:"").filter(Boolean),s=a.map(o=>m(t,o));return H({operation:r?"imports.addMissing.apply":i?"imports.addMissing.execute":"imports.addMissing.preview",scope:typeof e.scope=="string"?m(t,e.scope):null,summary:N(i,l(e,"changedFileCount"),l(e,"editCount"),l(e,"fileCount")),files:i?null:P(s,8),filesWritten:i?P(s,8):null,allTouchedFiles:a,fileCount:l(e,"fileCount"),changedFileCount:l(e,"changedFileCount"),editCount:l(e,"editCount"),previewId:r??null})}function N(t,e,i,r){return i===0?`${r} ${g(r,"file")} checked, no missing imports fixed`:`${t?`${e} ${g(e,"file")} written`:`${e} ${g(e,"file")} with edits`}, ${i} ${g(i,"edit")}`}function A(t){const e=[],i=typeof t.operation=="string"?t.operation:"imports.addMissing",r=typeof t.previewId=="string"&&i.endsWith(".preview")?` ${t.previewId}`:"";e.push(`${i}${r}`),typeof t.scope=="string"&&e.push(t.scope),typeof t.summary=="string"&&e.push(t.summary);const n=Array.isArray(t.filesWritten)?t.filesWritten:Array.isArray(t.files)?t.files:[];for(const c of n)typeof c=="string"&&e.push(c);return typeof t.next=="string"&&e.push(`next: ${t.next}`),e.join(`
2
+ `)}function W(t){const e=t[0]??"preview",i=t.slice(1).find(r=>!r.startsWith("--"));return i?{scope:i,execute:e==="execute"}:void 0}function O(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new f.CliError("ADD_MISSING_IMPORTS_SCOPE_REQUIRED","imports addMissing expects a file or directory scope.");const i=t,r=p(i.scope)??p(i.file)??p(i.dir)??p(i.directory);if(!r)throw new f.CliError("ADD_MISSING_IMPORTS_SCOPE_REQUIRED","imports addMissing expects scope, file, dir, or directory.");const n=v.parse({scope:r,execute:e||i.execute===!0});return{scope:n.scope,execute:n.execute===!0}}function P(t,e){return t.length<=e?t:[...t.slice(0,e),`+ ${t.length-e} more`]}function H(t){const e={};for(const[i,r]of Object.entries(t))r!=null&&(e[i]=r);return e}function z(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function p(t){return typeof t=="string"&&t.trim()!==""?t.trim():null}function l(t,e){const i=t[e];return typeof i=="number"&&Number.isFinite(i)?i:0}function m(t,e){const i=y.relative(t,e);return i&&!i.startsWith("..")&&!y.isAbsolute(i)?i.replace(/\\/g,"/"):e.replace(/\\/g,"/")}function g(t,e){return t===1?e:`${e}s`}