@automaton-labs/aib 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/dist/bin/cli.js +4 -2
  2. package/dist/commands/apply-module-plan.js +3 -3
  3. package/dist/commands/background-command.js +2 -0
  4. package/dist/commands/captured-input.js +1 -2
  5. package/dist/commands/config-command.js +2 -1
  6. package/dist/commands/config-output.js +10 -8
  7. package/dist/commands/control-plane-command.js +1 -0
  8. package/dist/commands/declaration-command.js +7 -0
  9. package/dist/commands/declaration-execution-cache.js +1 -0
  10. package/dist/commands/declaration-format.js +1 -0
  11. package/dist/commands/declaration-preview-cache.js +2 -0
  12. package/dist/commands/doctor.js +3 -1
  13. package/dist/commands/execution-command.js +1 -1
  14. package/dist/commands/file-command.js +1 -0
  15. package/dist/commands/file-move-to-dir-execution-cache.js +1 -0
  16. package/dist/commands/file-move-to-dir-preview-cache.js +2 -0
  17. package/dist/commands/file-move-to-dir.js +5 -0
  18. package/dist/commands/file-mutation-runtime.js +1 -0
  19. package/dist/commands/file-refactor-batch-execution-cache.js +1 -0
  20. package/dist/commands/file-refactor-batch-preview-cache.js +2 -0
  21. package/dist/commands/file-refactor-batch.js +5 -0
  22. package/dist/commands/file-rename-execution-cache.js +1 -0
  23. package/dist/commands/file-rename-preview-cache.js +2 -0
  24. package/dist/commands/file-rename.js +5 -0
  25. package/dist/commands/help-command.js +5 -5
  26. package/dist/commands/host-command.js +1 -0
  27. package/dist/commands/inspect-cycles.js +3 -3
  28. package/dist/commands/inspect-format.js +15 -15
  29. package/dist/commands/inspect-tree.js +2 -2
  30. package/dist/commands/inspect.js +12 -12
  31. package/dist/commands/move-to-file.js +2 -2
  32. package/dist/commands/ota-command.js +2 -0
  33. package/dist/commands/quick-read.js +8 -8
  34. package/dist/commands/refactor-batch.js +4 -4
  35. package/dist/commands/rename-entities.js +4 -4
  36. package/dist/commands/result-view.js +6 -5
  37. package/dist/commands/session-workspace.js +7 -7
  38. package/dist/commands/worker-command.js +1 -0
  39. package/dist/config/defaults.js +1 -1
  40. package/dist/config/env-vars.js +1 -1
  41. package/dist/config/path-aliases.js +1 -1
  42. package/dist/config/resolve-command-alias.js +1 -1
  43. package/dist/config/workspace-root.js +3 -3
  44. package/dist/content/content-bundle.js +1 -1
  45. package/dist/dsl/aib-dsl.js +1 -1
  46. package/dist/dsl/declaration-dsl.js +1 -0
  47. package/dist/dsl/file-move-to-dir-dsl.js +1 -0
  48. package/dist/dsl/file-refactor-batch-dsl.js +1 -0
  49. package/dist/dsl/file-rename-dsl.js +1 -0
  50. package/dist/help/bootstrap.bash.md +907 -0
  51. package/dist/help/bootstrap.md +105 -144
  52. package/dist/help/{json/bootstrap.md → bootstrap.pwsh.md} +216 -397
  53. package/dist/help/docs/dsl.md +4 -3
  54. package/dist/help/docs/file.move.md +46 -0
  55. package/dist/help/docs/file.rename.md +35 -0
  56. package/dist/help/docs/help-format.md +4 -7
  57. package/dist/help/docs/inspect.code.md +5 -5
  58. package/dist/help/docs/inspect.deps.md +7 -7
  59. package/dist/help/docs/inspect.file.md +2 -1
  60. package/dist/help/docs/inspect.graph.md +3 -3
  61. package/dist/help/docs/inspect.md +5 -5
  62. package/dist/help/docs/mutation.md +23 -13
  63. package/dist/help/docs/patterns.md +1 -5
  64. package/dist/help/docs/qr.md +7 -22
  65. package/dist/help/docs/quick-map.md +1 -0
  66. package/dist/help/docs/recipe.file-layout.md +15 -0
  67. package/dist/help/docs/rg.md +22 -0
  68. package/dist/help/docs/selectors.md +3 -2
  69. package/dist/help/docs/session.md +1 -1
  70. package/dist/help/dsl/bootstrap.bash.md +907 -0
  71. package/dist/help/dsl/bootstrap.md +105 -144
  72. package/dist/help/{json/full.md → dsl/bootstrap.pwsh.md} +216 -397
  73. package/dist/help/dsl/docs/dsl.md +4 -3
  74. package/dist/help/dsl/docs/file.move.md +46 -0
  75. package/dist/help/dsl/docs/file.rename.md +35 -0
  76. package/dist/help/dsl/docs/help-format.md +4 -7
  77. package/dist/help/dsl/docs/inspect.code.md +5 -5
  78. package/dist/help/dsl/docs/inspect.deps.md +7 -7
  79. package/dist/help/dsl/docs/inspect.file.md +2 -1
  80. package/dist/help/dsl/docs/inspect.graph.md +3 -3
  81. package/dist/help/dsl/docs/inspect.md +5 -5
  82. package/dist/help/dsl/docs/mutation.md +23 -13
  83. package/dist/help/dsl/docs/patterns.md +1 -5
  84. package/dist/help/dsl/docs/qr.md +7 -22
  85. package/dist/help/dsl/docs/quick-map.md +1 -0
  86. package/dist/help/dsl/docs/recipe.file-layout.md +15 -0
  87. package/dist/help/dsl/docs/rg.md +22 -0
  88. package/dist/help/dsl/docs/selectors.md +3 -2
  89. package/dist/help/dsl/docs/session.md +1 -1
  90. package/dist/help/dsl/full.md +105 -144
  91. package/dist/help/dsl/help-index.md +44 -0
  92. package/dist/help/dsl/tokens/qr.inline.examples.md +2 -0
  93. package/dist/help/dsl/tokens/stdin.examples.bash.md +8 -0
  94. package/dist/help/dsl/tokens/stdin.examples.pwsh.md +8 -0
  95. package/dist/help/dsl/tokens/stdin.examples.with-qr.bash.md +12 -0
  96. package/dist/help/dsl/tokens/stdin.examples.with-qr.pwsh.md +12 -0
  97. package/dist/help/dsl/topics/dsl.md +4 -3
  98. package/dist/help/dsl/topics/file.move.md +44 -0
  99. package/dist/help/dsl/topics/file.rename.md +33 -0
  100. package/dist/help/dsl/topics/help-format.md +4 -7
  101. package/dist/help/dsl/topics/inspect.code.md +5 -5
  102. package/dist/help/dsl/topics/inspect.deps.md +7 -7
  103. package/dist/help/dsl/topics/inspect.file.md +2 -1
  104. package/dist/help/dsl/topics/inspect.graph.md +3 -3
  105. package/dist/help/dsl/topics/inspect.md +5 -5
  106. package/dist/help/dsl/topics/mutation.md +23 -13
  107. package/dist/help/dsl/topics/patterns.md +1 -5
  108. package/dist/help/dsl/topics/qr.md +7 -22
  109. package/dist/help/dsl/topics/quick-map.md +1 -0
  110. package/dist/help/dsl/topics/recipe.file-layout.md +13 -0
  111. package/dist/help/dsl/topics/rg.md +20 -0
  112. package/dist/help/dsl/topics/selectors.md +3 -2
  113. package/dist/help/dsl/topics/session.md +1 -1
  114. package/dist/help/full.md +105 -144
  115. package/dist/help/help-index.md +44 -0
  116. package/dist/help/help-meta.json +45 -29
  117. package/dist/help/index.md +32 -75
  118. package/dist/help/tokens/qr.inline.examples.md +2 -0
  119. package/dist/help/tokens/stdin.examples.bash.md +8 -0
  120. package/dist/help/tokens/stdin.examples.pwsh.md +8 -0
  121. package/dist/help/tokens/stdin.examples.with-qr.bash.md +12 -0
  122. package/dist/help/tokens/stdin.examples.with-qr.pwsh.md +12 -0
  123. package/dist/help/topics/dsl.md +4 -3
  124. package/dist/help/topics/file.move.md +44 -0
  125. package/dist/help/topics/file.rename.md +33 -0
  126. package/dist/help/topics/help-format.md +4 -7
  127. package/dist/help/topics/inspect.code.md +5 -5
  128. package/dist/help/topics/inspect.deps.md +7 -7
  129. package/dist/help/topics/inspect.file.md +2 -1
  130. package/dist/help/topics/inspect.graph.md +3 -3
  131. package/dist/help/topics/inspect.md +5 -5
  132. package/dist/help/topics/mutation.md +23 -13
  133. package/dist/help/topics/patterns.md +1 -5
  134. package/dist/help/topics/qr.md +7 -22
  135. package/dist/help/topics/quick-map.md +1 -0
  136. package/dist/help/topics/recipe.file-layout.md +13 -0
  137. package/dist/help/topics/rg.md +20 -0
  138. package/dist/help/topics/selectors.md +3 -2
  139. package/dist/help/topics/session.md +1 -1
  140. package/dist/host/capabilities.js +1 -0
  141. package/dist/ide-launch/common.cjs +162 -162
  142. package/dist/managed-host/extension-vsix-resolver.js +1 -1
  143. package/dist/managed-host/manage-serve-web-host.cjs +141 -141
  144. package/dist/managed-host/serve-web-autostart.js +1 -1
  145. package/dist/managed-host/serve-web-host.cjs +1985 -1660
  146. package/dist/observability/config.js +1 -1
  147. package/dist/payloads/read-stdin-json.js +1 -1
  148. package/dist/rg-wrapper/core.js +6 -0
  149. package/dist/rg-wrapper/options.js +1 -0
  150. package/dist/rtk-wrapper/core.js +2 -0
  151. package/dist/runtime/input-source.js +1 -1
  152. package/dist/runtime/managed-runtime-provisioning.js +1 -1
  153. package/dist/runtime/run-command.js +1 -1
  154. package/dist/selectors/parse-entities.js +1 -1
  155. package/dist/session/daemon-state.js +2 -0
  156. package/dist/session/server.js +7 -6
  157. package/dist/shared/errors.js +14 -13
  158. package/dist/shared/operations.js +1 -1
  159. package/dist/shared/protocol.js +1 -1
  160. package/dist/shared/routes.js +1 -1
  161. package/dist/shared/stdin-examples.js +1 -0
  162. package/dist/shared/types.js +1 -1
  163. package/dist/tool-runtime/runtime-tools.js +1 -0
  164. package/dist/tracing/trace.js +5 -3
  165. package/dist/workers/control-plane/aib-control-plane-worker.cjs +80 -0
  166. package/dist/workers/control-plane/client-config.default.json +3 -0
  167. package/dist/workers/product-storage.js +1 -0
  168. package/dist/workers/registry.js +1 -0
  169. package/extension/vscode-refactor-bridge-extension.vsix +0 -0
  170. package/package.json +6 -4
  171. package/runtimes/launcher/linux-x64/aib +0 -0
  172. package/runtimes/launcher/win-x64/aib.exe +0 -0
  173. package/runtimes/tools/rg/darwin-arm64/rg +0 -0
  174. package/runtimes/tools/rg/darwin-x64/rg +0 -0
  175. package/runtimes/tools/rg/linux-arm64/rg +0 -0
  176. package/runtimes/tools/rg/linux-x64/rg +0 -0
  177. package/runtimes/tools/rg/manifest.json +36 -0
  178. package/runtimes/tools/rg/win32-x64/rg.exe +0 -0
  179. package/runtimes/tools/rtk/darwin-arm64/rtk +0 -0
  180. package/runtimes/tools/rtk/darwin-x64/rtk +0 -0
  181. package/runtimes/tools/rtk/linux-arm64/rtk +0 -0
  182. package/runtimes/tools/rtk/linux-x64/rtk +0 -0
  183. package/runtimes/tools/rtk/manifest.json +36 -0
  184. package/runtimes/tools/rtk/win32-x64/rtk.exe +0 -0
  185. package/scripts/provision-runtime.cjs +25 -1
  186. package/dist/help/json/docs/basics.md +0 -15
  187. package/dist/help/json/docs/config-setup.aliases.md +0 -56
  188. package/dist/help/json/docs/config-setup.excludes.md +0 -45
  189. package/dist/help/json/docs/config-setup.import-normalize.md +0 -86
  190. package/dist/help/json/docs/config-setup.import-rules.md +0 -96
  191. package/dist/help/json/docs/config-setup.tsconfigs.md +0 -33
  192. package/dist/help/json/docs/dsl.md +0 -25
  193. package/dist/help/json/docs/first-setup.md +0 -292
  194. package/dist/help/json/docs/help-format.md +0 -12
  195. package/dist/help/json/docs/help-protocol.md +0 -26
  196. package/dist/help/json/docs/imports.normalize.md +0 -47
  197. package/dist/help/json/docs/inspect.code.md +0 -41
  198. package/dist/help/json/docs/inspect.cycles.md +0 -38
  199. package/dist/help/json/docs/inspect.deps.md +0 -46
  200. package/dist/help/json/docs/inspect.duplicates.md +0 -65
  201. package/dist/help/json/docs/inspect.exports.md +0 -40
  202. package/dist/help/json/docs/inspect.file.md +0 -38
  203. package/dist/help/json/docs/inspect.graph.md +0 -139
  204. package/dist/help/json/docs/inspect.imports.md +0 -15
  205. package/dist/help/json/docs/inspect.md +0 -88
  206. package/dist/help/json/docs/inspect.members.md +0 -32
  207. package/dist/help/json/docs/inspect.tree.md +0 -32
  208. package/dist/help/json/docs/inspect.usages.md +0 -61
  209. package/dist/help/json/docs/modulePlan.md +0 -73
  210. package/dist/help/json/docs/move.md +0 -56
  211. package/dist/help/json/docs/mutation.md +0 -65
  212. package/dist/help/json/docs/patterns.md +0 -76
  213. package/dist/help/json/docs/prefs.md +0 -40
  214. package/dist/help/json/docs/qr.md +0 -37
  215. package/dist/help/json/docs/quick-map.md +0 -30
  216. package/dist/help/json/docs/refactor.batch.md +0 -72
  217. package/dist/help/json/docs/rename.md +0 -47
  218. package/dist/help/json/docs/reveal.md +0 -30
  219. package/dist/help/json/docs/selectors.md +0 -23
  220. package/dist/help/json/docs/session.md +0 -77
  221. package/dist/help/json/docs/view.md +0 -30
  222. package/dist/help/json/snippets/agents.md +0 -14
  223. package/dist/help/json/topics/basics.md +0 -13
  224. package/dist/help/json/topics/config-setup.aliases.md +0 -54
  225. package/dist/help/json/topics/config-setup.excludes.md +0 -43
  226. package/dist/help/json/topics/config-setup.import-normalize.md +0 -84
  227. package/dist/help/json/topics/config-setup.import-rules.md +0 -94
  228. package/dist/help/json/topics/config-setup.tsconfigs.md +0 -31
  229. package/dist/help/json/topics/dsl.md +0 -23
  230. package/dist/help/json/topics/first-setup.md +0 -290
  231. package/dist/help/json/topics/help-format.md +0 -10
  232. package/dist/help/json/topics/help-protocol.md +0 -24
  233. package/dist/help/json/topics/imports.normalize.md +0 -45
  234. package/dist/help/json/topics/inspect.code.md +0 -39
  235. package/dist/help/json/topics/inspect.cycles.md +0 -36
  236. package/dist/help/json/topics/inspect.deps.md +0 -44
  237. package/dist/help/json/topics/inspect.duplicates.md +0 -37
  238. package/dist/help/json/topics/inspect.exports.md +0 -38
  239. package/dist/help/json/topics/inspect.file.md +0 -36
  240. package/dist/help/json/topics/inspect.graph.md +0 -137
  241. package/dist/help/json/topics/inspect.imports.md +0 -13
  242. package/dist/help/json/topics/inspect.md +0 -86
  243. package/dist/help/json/topics/inspect.members.md +0 -30
  244. package/dist/help/json/topics/inspect.tree.md +0 -22
  245. package/dist/help/json/topics/inspect.usages.md +0 -59
  246. package/dist/help/json/topics/modulePlan.md +0 -60
  247. package/dist/help/json/topics/move.md +0 -46
  248. package/dist/help/json/topics/mutation.md +0 -63
  249. package/dist/help/json/topics/patterns.md +0 -74
  250. package/dist/help/json/topics/prefs.md +0 -38
  251. package/dist/help/json/topics/qr.md +0 -35
  252. package/dist/help/json/topics/quick-map.md +0 -28
  253. package/dist/help/json/topics/refactor.batch.md +0 -61
  254. package/dist/help/json/topics/rename.md +0 -42
  255. package/dist/help/json/topics/reveal.md +0 -28
  256. package/dist/help/json/topics/selectors.md +0 -21
  257. package/dist/help/json/topics/session.md +0 -59
  258. package/dist/help/json/topics/view.md +0 -28
@@ -9,27 +9,12 @@ For focused text reads, prefer qr over cat/Get-Content/type, especially when ali
9
9
  Use shell reads only when piping into shell tooling or qr is unavailable.
10
10
 
11
11
  Controls:
12
- -h N head; first N lines
13
- -t N tail; last N lines
14
- -o N offset; starting line, 1-based
15
- -l N limit; line count for offset reads
16
- -a all; whole file
12
+ h=N head; first N lines
13
+ t=N tail; last N lines
14
+ o=N l=N range; starting line and line count
15
+ all whole file
17
16
 
18
- If no window is provided, qr uses -h 80.
19
- If -a is present, it wins over other window flags.
17
+ If no window is provided, qr uses h=80.
18
+ If all is present, it wins over other window flags.
20
19
 
21
- Run:
22
- aib qr --stdin
23
-
24
- Input:
25
- qr @scripts/a.txt h=80
26
- qr @scripts/b.py o=300 l=50
27
- qr @scripts/c.md t=120
28
- qr @logs/app.log all
29
-
30
- Inline:
31
- aib qr @scripts/a.txt -h 80
32
- aib qr @scripts/b.py -o 300 -l 50
33
- aib qr @logs/app.log -a
34
-
35
- Use stdin for several reads.
20
+ {{qr.inline.examples}}
@@ -1,5 +1,6 @@
1
1
  Read:
2
2
  qr quick reads: ts, js, cmd, sh, json, log, txt, etc.
3
+ rg use `aib rg -- <args>` instead of `rg <args>`
3
4
  view hidden/truncated output
4
5
 
5
6
  Inspect:
@@ -0,0 +1,13 @@
1
+ Assumption:
2
+ You are changing whole-file layout.
3
+ You are not moving TypeScript declarations or renaming TypeScript symbols.
4
+
5
+ Related topics:
6
+ aib help mutation file.move file.rename
7
+
8
+ If you only need to move files, do not read file.rename.
9
+ If you only need to rename files, do not read file.move.
10
+
11
+ Use focused topic syntax to express the file layout refactor.
12
+ Do not move or rename files manually.
13
+ Use AIB file mutations so references/imports are updated.
@@ -0,0 +1,20 @@
1
+ aib rg
2
+
3
+ Run ripgrep through AIB.
4
+
5
+ Regular rg:
6
+ rg <args>
7
+
8
+ AIB rg:
9
+ aib rg -- <args>
10
+
11
+ Everything after `--` is passed as normal ripgrep arguments.
12
+ Use the same args you would pass to `rg`.
13
+ Use normal paths in input. Do not use AIB path aliases here.
14
+
15
+ Examples:
16
+ rg -n "TODO" src/core
17
+ aib rg -- -n "TODO" src/core
18
+
19
+ rg -n --column "SomeValue" ws/commands ws/config
20
+ aib rg -- -n --column "SomeValue" ws/commands ws/config
@@ -16,6 +16,7 @@ c-Name class
16
16
  i-Name interface
17
17
  t-Name type
18
18
  v-name variable
19
- e-Name enum
20
- m-name method, usually with parent
19
+ e-Name enum
20
+ ns-Name namespace
21
+ m-name method, usually with parent
21
22
  p-name property, usually with parent
@@ -2,7 +2,7 @@ Start by creating or selecting your session.
2
2
  Create it once, then reuse it.
3
3
  Do not create a new session for every command or subtask.
4
4
 
5
- Session stores saved artifacts, aliases, and prefs.
5
+ Session stores saved artifacts and aliases.
6
6
 
7
7
  Prefer short session names:
8
8
  aa, tr, qa, a2
@@ -0,0 +1 @@
1
+ "use strict";var o=exports&&exports.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.AIB_SUPPORTED_ACTIVATION_POLICIES=exports.AIB_SUPPORTED_INVOKE_MODES=exports.AIB_HOST_CAPABILITIES=exports.AIB_WORKER_ABI=void 0,exports.readHostCapabilities=i;const a=o(require("node:fs")),r=o(require("node:path"));exports.AIB_WORKER_ABI="1",exports.AIB_HOST_CAPABILITIES=["productStorage","jsonStdout","traceUploadLedger","backgroundSchedule","policyConfig","workerRegistry","workerBundleOta","cliPackageOta"],exports.AIB_SUPPORTED_INVOKE_MODES=["structured","process","stream"],exports.AIB_SUPPORTED_ACTIVATION_POLICIES=["ota-activation","cli-package-activation","extension-vsix-activation","ota-watch","ota-cleanup"];function i(e=n()){return{schemaVersion:1,hostVersion:s(e),workerAbi:exports.AIB_WORKER_ABI,platform:process.platform,arch:process.arch,nodeRuntime:`node-${process.versions.node.split(".")[0]}`,launcherProtocol:"1",daemonInvokeProtocol:"http-session-v1",supportedInvokeModes:exports.AIB_SUPPORTED_INVOKE_MODES,productStorageSchema:1,supportedActivationPolicies:exports.AIB_SUPPORTED_ACTIVATION_POLICIES,runtime:"cjs-node20",capabilities:exports.AIB_HOST_CAPABILITIES}}function n(){return r.default.resolve(__dirname,"..","..")}function s(e){try{const t=JSON.parse(a.default.readFileSync(r.default.join(e,"package.json"),"utf8"));return typeof t.version=="string"&&t.version.trim()?t.version:"0.0.0"}catch{return"0.0.0"}}
@@ -1,162 +1,162 @@
1
- const fs = require("node:fs");
2
- const os = require("node:os");
3
- const path = require("node:path");
4
- const { spawnSync } = require("node:child_process");
5
-
6
- const rootDir = path.resolve(__dirname, "..", "..");
7
- const defaultFixtureDir = path.join(rootDir, "fixtures", "ts-sandbox");
8
- const defaultVsixPath = path.join(rootDir, ".tmp", "vscode-refactor-bridge-extension.vsix");
9
- const defaultRunsDir = path.join(rootDir, ".tmp", "ide-launch-runs");
10
-
11
- function timestampForPath() {
12
- return new Date().toISOString().replace(/[:.]/g, "-");
13
- }
14
-
15
- function ensureDir(dirPath) {
16
- fs.mkdirSync(dirPath, { recursive: true });
17
- }
18
-
19
- function writeJson(filePath, payload) {
20
- ensureDir(path.dirname(filePath));
21
- fs.writeFileSync(filePath, `${JSON.stringify(payload, null, 2)}\n`);
22
- }
23
-
24
- function run(command, args, options = {}) {
25
- const startedAt = Date.now();
26
- const spawnCommand = prepareSpawnCommand(command, args, options);
27
- const result = spawnSync(spawnCommand.command, spawnCommand.args, {
28
- cwd: options.cwd ?? rootDir,
29
- env: buildEnv(options.env),
30
- input: options.input,
31
- encoding: "utf8",
32
- windowsHide: true,
33
- windowsVerbatimArguments: spawnCommand.windowsVerbatimArguments ?? false,
34
- timeout: options.timeoutMs ?? 30_000,
35
- shell: options.shell ?? false,
36
- stdio: ["pipe", "pipe", "pipe"]
37
- });
38
-
39
- return {
40
- command,
41
- args,
42
- status: result.status,
43
- signal: result.signal,
44
- error: result.error ? result.error.message : null,
45
- stdout: result.stdout ?? "",
46
- stderr: result.stderr ?? "",
47
- durationMs: Date.now() - startedAt
48
- };
49
- }
50
-
51
- function buildEnv(overrides) {
52
- if (!overrides) {
53
- return process.env;
54
- }
55
-
56
- const env = { ...process.env };
57
- for (const [key, value] of Object.entries(overrides)) {
58
- if (value === null || value === undefined) {
59
- delete env[key];
60
- continue;
61
- }
62
- env[key] = String(value);
63
- }
64
- return env;
65
- }
66
-
67
- function resolveIdeCommand(options) {
68
- if (options.ideCommand) {
69
- return options.ideCommand;
70
- }
71
-
72
- return resolveCommandFromPath(options.ide === "cursor" ? "cursor" : "code");
73
- }
74
-
75
- function isWindowsCommandScript(command) {
76
- const extension = path.extname(command).toLowerCase();
77
- return extension === ".cmd" || extension === ".bat";
78
- }
79
-
80
- function quoteCmdArg(value) {
81
- const raw = String(value);
82
- return `"${raw.replace(/"/g, '\\"')}"`;
83
- }
84
-
85
- function prepareSpawnCommand(command, args, options = {}) {
86
- if (process.platform !== "win32" || options.shell !== undefined || !isWindowsCommandScript(command)) {
87
- return { command, args };
88
- }
89
-
90
- return {
91
- command: "cmd.exe",
92
- args: ["/d", "/s", "/c", ["call", quoteCmdArg(command), ...args.map(quoteCmdArg)].join(" ")],
93
- windowsVerbatimArguments: true
94
- };
95
- }
96
-
97
- function resolveCommandFromPath(commandName) {
98
- const result = spawnSync("where.exe", [commandName], {
99
- cwd: rootDir,
100
- encoding: "utf8",
101
- windowsHide: true,
102
- stdio: ["ignore", "pipe", "pipe"]
103
- });
104
-
105
- if (result.status !== 0) {
106
- return commandName;
107
- }
108
-
109
- const candidates = result.stdout
110
- .split(/\r?\n/)
111
- .map((line) => line.trim())
112
- .filter(Boolean);
113
-
114
- const commandScript = candidates.find((candidate) => path.extname(candidate).toLowerCase() === ".cmd");
115
- return commandScript ?? candidates[0] ?? commandName;
116
- }
117
-
118
- function readRegistryEntries() {
119
- const registryDir = path.join(os.tmpdir(), "aib", "instances");
120
- if (!fs.existsSync(registryDir)) {
121
- return [];
122
- }
123
-
124
- const entries = [];
125
- for (const fileName of fs.readdirSync(registryDir)) {
126
- if (!fileName.endsWith(".json")) {
127
- continue;
128
- }
129
-
130
- const filePath = path.join(registryDir, fileName);
131
- try {
132
- const parsed = JSON.parse(fs.readFileSync(filePath, "utf8"));
133
- entries.push({
134
- ...parsed,
135
- registryPath: filePath
136
- });
137
- } catch {
138
- // Ignore corrupt/stale entries in probe output.
139
- }
140
- }
141
-
142
- return entries;
143
- }
144
-
145
- function sleep(ms) {
146
- return new Promise((resolve) => setTimeout(resolve, ms));
147
- }
148
-
149
- module.exports = {
150
- rootDir,
151
- defaultFixtureDir,
152
- defaultVsixPath,
153
- defaultRunsDir,
154
- prepareSpawnCommand,
155
- readRegistryEntries,
156
- resolveCommandFromPath,
157
- resolveIdeCommand,
158
- run,
159
- sleep,
160
- timestampForPath,
161
- writeJson
162
- };
1
+ const fs = require("node:fs");
2
+ const os = require("node:os");
3
+ const path = require("node:path");
4
+ const { spawnSync } = require("node:child_process");
5
+
6
+ const rootDir = path.resolve(__dirname, "..", "..");
7
+ const defaultFixtureDir = path.join(rootDir, "fixtures", "ts-sandbox");
8
+ const defaultVsixPath = path.join(rootDir, ".tmp", "vscode-refactor-bridge-extension.vsix");
9
+ const defaultRunsDir = path.join(rootDir, ".tmp", "ide-launch-runs");
10
+
11
+ function timestampForPath() {
12
+ return new Date().toISOString().replace(/[:.]/g, "-");
13
+ }
14
+
15
+ function ensureDir(dirPath) {
16
+ fs.mkdirSync(dirPath, { recursive: true });
17
+ }
18
+
19
+ function writeJson(filePath, payload) {
20
+ ensureDir(path.dirname(filePath));
21
+ fs.writeFileSync(filePath, `${JSON.stringify(payload, null, 2)}\n`);
22
+ }
23
+
24
+ function run(command, args, options = {}) {
25
+ const startedAt = Date.now();
26
+ const spawnCommand = prepareSpawnCommand(command, args, options);
27
+ const result = spawnSync(spawnCommand.command, spawnCommand.args, {
28
+ cwd: options.cwd ?? rootDir,
29
+ env: buildEnv(options.env),
30
+ input: options.input,
31
+ encoding: "utf8",
32
+ windowsHide: true,
33
+ windowsVerbatimArguments: spawnCommand.windowsVerbatimArguments ?? false,
34
+ timeout: options.timeoutMs ?? 30_000,
35
+ shell: options.shell ?? false,
36
+ stdio: ["pipe", "pipe", "pipe"]
37
+ });
38
+
39
+ return {
40
+ command,
41
+ args,
42
+ status: result.status,
43
+ signal: result.signal,
44
+ error: result.error ? result.error.message : null,
45
+ stdout: result.stdout ?? "",
46
+ stderr: result.stderr ?? "",
47
+ durationMs: Date.now() - startedAt
48
+ };
49
+ }
50
+
51
+ function buildEnv(overrides) {
52
+ if (!overrides) {
53
+ return process.env;
54
+ }
55
+
56
+ const env = { ...process.env };
57
+ for (const [key, value] of Object.entries(overrides)) {
58
+ if (value === null || value === undefined) {
59
+ delete env[key];
60
+ continue;
61
+ }
62
+ env[key] = String(value);
63
+ }
64
+ return env;
65
+ }
66
+
67
+ function resolveIdeCommand(options) {
68
+ if (options.ideCommand) {
69
+ return options.ideCommand;
70
+ }
71
+
72
+ return resolveCommandFromPath(options.ide === "cursor" ? "cursor" : "code");
73
+ }
74
+
75
+ function isWindowsCommandScript(command) {
76
+ const extension = path.extname(command).toLowerCase();
77
+ return extension === ".cmd" || extension === ".bat";
78
+ }
79
+
80
+ function quoteCmdArg(value) {
81
+ const raw = String(value);
82
+ return `"${raw.replace(/"/g, '\\"')}"`;
83
+ }
84
+
85
+ function prepareSpawnCommand(command, args, options = {}) {
86
+ if (process.platform !== "win32" || options.shell !== undefined || !isWindowsCommandScript(command)) {
87
+ return { command, args };
88
+ }
89
+
90
+ return {
91
+ command: "cmd.exe",
92
+ args: ["/d", "/s", "/c", ["call", quoteCmdArg(command), ...args.map(quoteCmdArg)].join(" ")],
93
+ windowsVerbatimArguments: true
94
+ };
95
+ }
96
+
97
+ function resolveCommandFromPath(commandName) {
98
+ const result = spawnSync("where.exe", [commandName], {
99
+ cwd: rootDir,
100
+ encoding: "utf8",
101
+ windowsHide: true,
102
+ stdio: ["ignore", "pipe", "pipe"]
103
+ });
104
+
105
+ if (result.status !== 0) {
106
+ return commandName;
107
+ }
108
+
109
+ const candidates = result.stdout
110
+ .split(/\r?\n/)
111
+ .map((line) => line.trim())
112
+ .filter(Boolean);
113
+
114
+ const commandScript = candidates.find((candidate) => path.extname(candidate).toLowerCase() === ".cmd");
115
+ return commandScript ?? candidates[0] ?? commandName;
116
+ }
117
+
118
+ function readRegistryEntries() {
119
+ const registryDir = path.join(os.tmpdir(), "aib", "instances");
120
+ if (!fs.existsSync(registryDir)) {
121
+ return [];
122
+ }
123
+
124
+ const entries = [];
125
+ for (const fileName of fs.readdirSync(registryDir)) {
126
+ if (!fileName.endsWith(".json")) {
127
+ continue;
128
+ }
129
+
130
+ const filePath = path.join(registryDir, fileName);
131
+ try {
132
+ const parsed = JSON.parse(fs.readFileSync(filePath, "utf8"));
133
+ entries.push({
134
+ ...parsed,
135
+ registryPath: filePath
136
+ });
137
+ } catch {
138
+ // Ignore corrupt/stale entries in probe output.
139
+ }
140
+ }
141
+
142
+ return entries;
143
+ }
144
+
145
+ function sleep(ms) {
146
+ return new Promise((resolve) => setTimeout(resolve, ms));
147
+ }
148
+
149
+ module.exports = {
150
+ rootDir,
151
+ defaultFixtureDir,
152
+ defaultVsixPath,
153
+ defaultRunsDir,
154
+ prepareSpawnCommand,
155
+ readRegistryEntries,
156
+ resolveCommandFromPath,
157
+ resolveIdeCommand,
158
+ run,
159
+ sleep,
160
+ timestampForPath,
161
+ writeJson
162
+ };
@@ -1 +1 @@
1
- "use strict";var d=exports&&exports.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),g=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),c=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var r=[];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[r.length]=i);return r},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var r=t(e),i=0;i<r.length;i++)r[i]!=="default"&&d(n,e,r[i]);return g(n,e),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveExtensionVsixPath=h;const s=c(require("node:fs")),o=c(require("node:path")),u=require("../config/env-vars"),v=require("../shared/diagnostics"),x=require("../shared/errors");function h(t){const e=f(u.CLI_ENV.extensionVsix);if(e)return{path:e,source:"env"};const n=p(t.packageRoot);if(n)return n;const r=o.join(t.packageRoot,"extension","vscode-refactor-bridge-extension.vsix");return s.existsSync(r)?{path:r,source:"package-extension"}:t.repoRoot?{path:o.join(t.repoRoot,".tmp","vscode-refactor-bridge-extension.vsix"),source:"repo-dev-fallback"}:{path:o.join(t.packageRoot,".tmp","vscode-refactor-bridge-extension.vsix"),source:"package-adjacent"}}function f(t){const e=process.env[t];return e&&e.trim()?o.resolve(e.trim()):null}function p(t){const n=f(u.CLI_ENV.installConfig)??o.join(t,"config.json");if(!s.existsSync(n))return null;const r=_(n),i=b(r);if(!i)throw l(n,"Expected config to include extensionVsix.");return{path:o.resolve(o.dirname(n),i),source:"install-config",configPath:n}}function _(t){try{const e=JSON.parse(s.readFileSync(t,"utf8"));if(e&&typeof e=="object"&&!Array.isArray(e))return e;throw new Error("Config root must be an object.")}catch(e){throw l(t,e instanceof Error?e.message:String(e))}}function b(t){const e=a(t.extensionVsix);if(e)return e;const n=t.extension;if(!n||typeof n!="object"||Array.isArray(n))return null;const r=n;return a(r.vsixPath)??a(r.vsix)}function a(t){return typeof t=="string"&&t.trim()?t.trim():null}function l(t,e){return new x.CliError("EXTENSION_VSIX_CONFIG_INVALID","Extension VSIX install config is invalid.",{configPath:t,reason:e,expected:{extensionVsix:"relative/or/absolute/path/to/extension.vsix"},hints:(0,v.buildAutoStartIdeHints)()})}
1
+ "use strict";var x=exports&&exports.__createBinding||(Object.create?(function(e,t,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}):(function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]})),h=exports&&exports.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),a=exports&&exports.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var n=[];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[n.length]=o);return n},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null)for(var n=e(t),o=0;o<n.length;o++)n[o]!=="default"&&x(r,t,n[o]);return h(r,t),r}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveExtensionVsixPath=P;const s=a(require("node:fs")),_=a(require("node:os")),i=a(require("node:path")),u=require("../config/env-vars"),b=require("../shared/diagnostics"),j=require("../shared/errors");function P(e){const t=v(u.CLI_ENV.extensionVsix);if(t)return{path:t,source:"env"};const r=O();if(r)return r;const n=y();if(n)return n;const o=E(e.packageRoot);if(o)return o;if(e.repoRoot){const l=i.join(e.repoRoot,".tmp","vscode-refactor-bridge-extension.vsix");if(s.existsSync(l))return{path:l,source:"repo-dev-fallback"}}const f=i.join(e.packageRoot,"extension","vscode-refactor-bridge-extension.vsix");return s.existsSync(f)?{path:f,source:"package-extension"}:e.repoRoot?{path:i.join(e.repoRoot,".tmp","vscode-refactor-bridge-extension.vsix"),source:"repo-dev-fallback"}:{path:i.join(e.packageRoot,".tmp","vscode-refactor-bridge-extension.vsix"),source:"package-adjacent"}}function y(){const e=i.join(S(),"extension","activation-status.json");if(!s.existsSync(e))return null;const t=p(e),r=c(t.activeVsixPath)??c(C(t.active)?.vsixPath);if(!r)return null;const n=i.resolve(r);return s.existsSync(n)?{path:n,source:"product-storage",configPath:e}:null}function S(){const e=process.env[u.CLI_ENV.productStorageDir];return e?.trim()?i.resolve(e):process.platform==="win32"&&process.env.LOCALAPPDATA?i.join(process.env.LOCALAPPDATA,"aib"):process.env.XDG_STATE_HOME?i.join(process.env.XDG_STATE_HOME,"aib"):i.join(_.homedir(),".local","state","aib")}function v(e){const t=process.env[e];return t&&t.trim()?i.resolve(t.trim()):null}function O(){const e=v(u.CLI_ENV.installConfig);return e?d(e):null}function E(e){const t=i.join(e,"config.json");return s.existsSync(t)?d(t):null}function d(e){const t=p(e),r=A(t);if(!r)throw g(e,"Expected config to include extensionVsix.");return{path:i.resolve(i.dirname(e),r),source:"install-config",configPath:e}}function p(e){try{const t=JSON.parse(s.readFileSync(e,"utf8"));if(t&&typeof t=="object"&&!Array.isArray(t))return t;throw new Error("Config root must be an object.")}catch(t){throw g(e,t instanceof Error?t.message:String(t))}}function A(e){const t=c(e.extensionVsix);if(t)return t;const r=e.extension;if(!r||typeof r!="object"||Array.isArray(r))return null;const n=r;return c(n.vsixPath)??c(n.vsix)}function C(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function c(e){return typeof e=="string"&&e.trim()?e.trim():null}function g(e,t){return new j.CliError("EXTENSION_VSIX_CONFIG_INVALID","Extension VSIX install config is invalid.",{configPath:e,reason:t,expected:{extensionVsix:"relative/or/absolute/path/to/extension.vsix"},hints:(0,b.buildAutoStartIdeHints)()})}