@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
@@ -1,3 +1,3 @@
1
- "use strict";var S=exports&&exports.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),O=exports&&exports.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),_=exports&&exports.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(n){var r=[];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[r.length]=o);return r},e(t)};return function(t){if(t&&t.__esModule)return t;var n={};if(t!=null)for(var r=e(t),o=0;o<r.length;o++)r[o]!=="default"&&S(n,t,r[o]);return O(n,t),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.AIB_CONFIG_FILE_NAME=void 0,exports.initWorkspaceRoot=h,exports.resolveWorkspaceRoot=g,exports.resolveRequiredWorkspaceRoot=C,exports.readWorkspaceNumberConfig=D,exports.readWorkspaceBooleanConfig=w,exports.readWorkspaceStringConfig=k,exports.updateWorkspaceConfig=E,exports.workspaceConfigSummary=W,exports.isPathInsideOrEqual=A;const c=_(require("node:fs")),s=_(require("node:path")),N=require("./env-vars"),M=require("../shared/errors");exports.AIB_CONFIG_FILE_NAME="aib.json";function h(e,t={}){const n=s.join(s.resolve(e),exports.AIB_CONFIG_FILE_NAME),r=c.existsSync(n),o=r?I(n):{},f=a(t.sessionDir)??a(o.sessionDir),d=i(o["session.ttlMinutes"]),p=i(o["session.ttlCleanMinutes"])??d??60,m=i(o["session.ttlDeleteMinutes"])??d??60,l={...o,"workspace.root":a(o["workspace.root"])??".",...f?{sessionDir:f}:{},"session.autoDelete":u(o["session.autoDelete"])??!0,"session.ttlDeleteMinutes":m,"session.autoClean":u(o["session.autoClean"])??!0,"session.ttlCleanMinutes":p,"runtime.managedIdeTtlMinutes":i(o["runtime.managedIdeTtlMinutes"])??15,"runtime.managedIdeWatchdogIntervalMs":i(o["runtime.managedIdeWatchdogIntervalMs"])??3e4,"runtime.autoStopManagedIde":u(o["runtime.autoStopManagedIde"])??!0};c.writeFileSync(n,`${JSON.stringify(l,null,2)}
2
- `,"utf8");const y=i(l["session.ttlCleanMinutes"])??60,v=i(l["runtime.managedIdeTtlMinutes"])??15,b=!r||JSON.stringify(o)!==JSON.stringify(l);return{status:r?b?"updated":"unchanged":"created",...r?{}:{created:exports.AIB_CONFIG_FILE_NAME},configPath:n,root:s.resolve(e),"workspace.root":a(l["workspace.root"])??".",...f?{sessionDir:f}:{},"session.autoClean":u(l["session.autoClean"])??!0,"session.ttlCleanMinutes":y,"session.autoDelete":u(l["session.autoDelete"])??!0,"session.ttlDeleteMinutes":i(l["session.ttlDeleteMinutes"])??60,"runtime.autoStopManagedIde":u(l["runtime.autoStopManagedIde"])??!0,"runtime.managedIdeTtlMinutes":v,...f?{}:{next:"Set the default session directory: aib config --session-dir .tmp/aib"}}}function g(e){const t=a(process.env[N.CLI_ENV.workspaceRoot]);if(t){const d=s.resolve(e,t),p=s.join(d,exports.AIB_CONFIG_FILE_NAME),m=c.existsSync(p)?I(p):{"workspace.root":"."};return{root:d,configPath:p,config:m}}const n=F(e);if(!n)return null;const r=I(n),o=s.dirname(n),f=a(r["workspace.root"])??".";return{root:s.resolve(o,f),configPath:n,config:r}}function C(e){const t=g(e);if(t)return t;const n=R(e,".git");throw new M.CliError("WORKSPACE_ROOT_NOT_INITIALIZED","Workspace root is not initialized.",{cwd:s.resolve(e),...n?{detectedGitRoot:n}:{},next:"Run aib help first-setup from the intended repository root."})}function D(e,t,n){const r=g(e);return(r?i(r.config[t]):null)??n}function w(e,t,n){const r=g(e);return(r?u(r.config[t]):null)??n}function k(e,t,n){const r=g(e);return(r?a(r.config[t]):null)??n}function E(e,t){const n=C(e),r={...n.config,...t};return c.writeFileSync(n.configPath,`${JSON.stringify(r,null,2)}
3
- `,"utf8"),r}function W(e){const t=i(e["session.ttlMinutes"]);return{"workspace.root":a(e["workspace.root"])??".",...a(e.sessionDir)?{sessionDir:a(e.sessionDir)}:{},"session.autoClean":u(e["session.autoClean"])??!0,"session.ttlCleanMinutes":i(e["session.ttlCleanMinutes"])??t??60,"session.autoDelete":u(e["session.autoDelete"])??!0,"session.ttlDeleteMinutes":i(e["session.ttlDeleteMinutes"])??t??60,"runtime.autoStopManagedIde":u(e["runtime.autoStopManagedIde"])??!0,"runtime.managedIdeTtlMinutes":i(e["runtime.managedIdeTtlMinutes"])??15}}function A(e,t){const n=s.resolve(e).toLowerCase(),r=s.resolve(t).toLowerCase();return r===n||r.startsWith(`${n}${s.sep}`)}function F(e){let t=s.resolve(e);const n=s.parse(t).root;for(;;){const r=s.join(t,exports.AIB_CONFIG_FILE_NAME);if(c.existsSync(r)&&c.statSync(r).isFile())return r;if(t===n)break;const o=s.dirname(t);if(o===t)break;t=o}return null}function R(e,t){let n=s.resolve(e);const r=s.parse(n).root;for(;;){if(c.existsSync(s.join(n,t)))return n;if(n===r)break;const o=s.dirname(n);if(o===n)break;n=o}return null}function I(e){try{const t=JSON.parse(c.readFileSync(e,"utf8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch(t){throw new M.CliError("AIB_CONFIG_INVALID","aib.json must be valid JSON.",{file:e,error:t instanceof Error?t.message:String(t)})}}function a(e){return typeof e=="string"&&e.trim()?e.trim():null}function i(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const t=Number(e);return Number.isFinite(t)?t:null}return null}function u(e){if(typeof e=="boolean")return e;if(typeof e!="string")return null;const t=e.trim().toLowerCase();return["1","true","yes","on"].includes(t)?!0:["0","false","no","off"].includes(t)?!1:null}
1
+ "use strict";var b=exports&&exports.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var s=Object.getOwnPropertyDescriptor(t,n);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,s)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),v=exports&&exports.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),_=exports&&exports.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(n){var r=[];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[r.length]=s);return r},e(t)};return function(t){if(t&&t.__esModule)return t;var n={};if(t!=null)for(var r=e(t),s=0;s<r.length;s++)r[s]!=="default"&&b(n,t,r[s]);return v(n,t),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.MATERIALIZED_INSPECT_DEFAULTS=exports.AIB_CONFIG_FILE_NAME=void 0,exports.initWorkspaceRoot=D,exports.resolveWorkspaceRoot=g,exports.resolveRequiredWorkspaceRoot=C,exports.readWorkspaceNumberConfig=O,exports.readWorkspaceBooleanConfig=h,exports.readWorkspaceStringConfig=A,exports.updateWorkspaceConfig=w,exports.workspaceConfigSummary=k,exports.isPathInsideOrEqual=F;const l=_(require("node:fs")),o=_(require("node:path")),E=require("./env-vars"),M=require("../shared/errors");exports.AIB_CONFIG_FILE_NAME="aib.json",exports.MATERIALIZED_INSPECT_DEFAULTS={"inspect.code.maxNonEmptyLines":120,"inspect.usages.maxLocations":12,"inspect.usages.maxCodeBlocks":8,"inspect.members.maxItems":20};function D(e,t={}){const n=o.join(o.resolve(e),exports.AIB_CONFIG_FILE_NAME),r=l.existsSync(n),s=r?m(n):{},f=a(t.sessionDir)??a(s.sessionDir),d=i(s["session.ttlMinutes"]),p=i(s["session.ttlCleanMinutes"])??d??60,I=i(s["session.ttlDeleteMinutes"])??d??60,c={...s,"workspace.root":a(s["workspace.root"])??".",...f?{sessionDir:f}:{},"session.autoDelete":u(s["session.autoDelete"])??!0,"session.ttlDeleteMinutes":I,"session.autoClean":u(s["session.autoClean"])??!0,"session.ttlCleanMinutes":p,"runtime.managedIdeTtlMinutes":i(s["runtime.managedIdeTtlMinutes"])??15,"runtime.managedIdeWatchdogIntervalMs":i(s["runtime.managedIdeWatchdogIntervalMs"])??3e4,"runtime.autoStopManagedIde":u(s["runtime.autoStopManagedIde"])??!0,...r?{}:exports.MATERIALIZED_INSPECT_DEFAULTS};l.writeFileSync(n,`${JSON.stringify(c,null,2)}
2
+ `,"utf8");const S=i(c["session.ttlCleanMinutes"])??60,y=i(c["runtime.managedIdeTtlMinutes"])??15,N=!r||JSON.stringify(s)!==JSON.stringify(c);return{status:r?N?"updated":"unchanged":"created",...r?{}:{created:exports.AIB_CONFIG_FILE_NAME},configPath:n,root:o.resolve(e),"workspace.root":a(c["workspace.root"])??".",...f?{sessionDir:f}:{},"session.autoClean":u(c["session.autoClean"])??!0,"session.ttlCleanMinutes":S,"session.autoDelete":u(c["session.autoDelete"])??!0,"session.ttlDeleteMinutes":i(c["session.ttlDeleteMinutes"])??60,"runtime.autoStopManagedIde":u(c["runtime.autoStopManagedIde"])??!0,"runtime.managedIdeTtlMinutes":y,...f?{}:{next:"Set the default session directory: aib config --session-dir .tmp/aib"}}}function g(e){const t=a(process.env[E.CLI_ENV.workspaceRoot]);if(t){const d=o.resolve(e,t),p=o.join(d,exports.AIB_CONFIG_FILE_NAME),I=l.existsSync(p)?m(p):{"workspace.root":"."};return{root:d,configPath:p,config:I}}const n=T(e);if(!n)return null;const r=m(n),s=o.dirname(n),f=a(r["workspace.root"])??".";return{root:o.resolve(s,f),configPath:n,config:r}}function C(e){const t=g(e);if(t)return t;const n=L(e,".git");throw new M.CliError("WORKSPACE_ROOT_NOT_INITIALIZED","Workspace root is not initialized.",{cwd:o.resolve(e),...n?{detectedGitRoot:n}:{},next:"Run aib help first-setup from the intended repository root."})}function O(e,t,n){const r=g(e);return(r?i(r.config[t]):null)??n}function h(e,t,n){const r=g(e);return(r?u(r.config[t]):null)??n}function A(e,t,n){const r=g(e);return(r?a(r.config[t]):null)??n}function w(e,t){const n=C(e),r={...n.config,...t};return l.writeFileSync(n.configPath,`${JSON.stringify(r,null,2)}
3
+ `,"utf8"),r}function k(e){const t=i(e["session.ttlMinutes"]);return{"workspace.root":a(e["workspace.root"])??".",...a(e.sessionDir)?{sessionDir:a(e.sessionDir)}:{},"session.autoClean":u(e["session.autoClean"])??!0,"session.ttlCleanMinutes":i(e["session.ttlCleanMinutes"])??t??60,"session.autoDelete":u(e["session.autoDelete"])??!0,"session.ttlDeleteMinutes":i(e["session.ttlDeleteMinutes"])??t??60,"runtime.autoStopManagedIde":u(e["runtime.autoStopManagedIde"])??!0,"runtime.managedIdeTtlMinutes":i(e["runtime.managedIdeTtlMinutes"])??15}}function F(e,t){const n=o.resolve(e).toLowerCase(),r=o.resolve(t).toLowerCase();return r===n||r.startsWith(`${n}${o.sep}`)}function T(e){let t=o.resolve(e);const n=o.parse(t).root;for(;;){const r=o.join(t,exports.AIB_CONFIG_FILE_NAME);if(l.existsSync(r)&&l.statSync(r).isFile())return r;if(t===n)break;const s=o.dirname(t);if(s===t)break;t=s}return null}function L(e,t){let n=o.resolve(e);const r=o.parse(n).root;for(;;){if(l.existsSync(o.join(n,t)))return n;if(n===r)break;const s=o.dirname(n);if(s===n)break;n=s}return null}function m(e){try{const t=JSON.parse(l.readFileSync(e,"utf8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch(t){throw new M.CliError("AIB_CONFIG_INVALID","aib.json must be valid JSON.",{file:e,error:t instanceof Error?t.message:String(t)})}}function a(e){return typeof e=="string"&&e.trim()?e.trim():null}function i(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const t=Number(e);return Number.isFinite(t)?t:null}return null}function u(e){if(typeof e=="boolean")return e;if(typeof e!="string")return null;const t=e.trim().toLowerCase();return["1","true","yes","on"].includes(t)?!0:["0","false","no","off"].includes(t)?!1:null}
@@ -1 +1 @@
1
- "use strict";var f=exports&&exports.__createBinding||(Object.create?(function(e,n,r,t){t===void 0&&(t=r);var i=Object.getOwnPropertyDescriptor(n,r);(!i||("get"in i?!n.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return n[r]}}),Object.defineProperty(e,t,i)}):(function(e,n,r,t){t===void 0&&(t=r),e[t]=n[r]})),d=exports&&exports.__setModuleDefault||(Object.create?(function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}):function(e,n){e.default=n}),c=exports&&exports.__importStar||(function(){var e=function(n){return e=Object.getOwnPropertyNames||function(r){var t=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[t.length]=i);return t},e(n)};return function(n){if(n&&n.__esModule)return n;var r={};if(n!=null)for(var t=e(n),i=0;i<t.length;i++)t[i]!=="default"&&f(r,n,t[i]);return d(r,n),r}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveContentRoot=v,exports.collectContentCandidates=u,exports.directoryHasHelp=h;const s=c(require("node:fs")),_=c(require("node:os")),o=c(require("node:path")),a=require("../config/env-vars"),p=require("../shared/errors");function v(){for(const e of u())if(e.valid)return{dir:e.dir,source:e.source};throw new p.CliError("HELP_ASSETS_NOT_FOUND","AIB content assets were not found.",{env:a.CLI_ENV.helpDir,checked:u().map(e=>e.dir)})}function u(){const e=process.env[a.CLI_ENV.helpDir],n=b(),r=o.resolve(__dirname,"..","help"),t=[];return e&&t.push(l(a.CLI_ENV.helpDir,o.resolve(e))),t.push(l("cache",n)),t.push(l("bundled",r)),t}function h(e){return s.existsSync(o.join(e,"bootstrap.md"))&&s.existsSync(o.join(e,"topics"))}function l(e,n){return s.existsSync(n)?s.existsSync(o.join(n,"bootstrap.md"))?s.existsSync(o.join(n,"topics"))?{source:e,dir:n,valid:!0}:{source:e,dir:n,valid:!1,reason:"missing topics"}:{source:e,dir:n,valid:!1,reason:"missing bootstrap.md"}:{source:e,dir:n,valid:!1,reason:"missing"}}function b(){const e=process.env.LOCALAPPDATA?o.join(process.env.LOCALAPPDATA,"aib"):process.env.XDG_CACHE_HOME?o.join(process.env.XDG_CACHE_HOME,"aib"):o.join(_.homedir(),".cache","aib");return o.join(e,"help","current")}
1
+ "use strict";var f=exports&&exports.__createBinding||(Object.create?(function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}):(function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]})),d=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 i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null)for(var n=e(t),i=0;i<n.length;i++)n[i]!=="default"&&f(r,t,n[i]);return d(r,t),r}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveContentRoot=v,exports.collectContentCandidates=u,exports.directoryHasHelp=h;const s=a(require("node:fs")),_=a(require("node:os")),o=a(require("node:path")),c=require("../config/env-vars"),p=require("../shared/errors");function v(){for(const e of u())if(e.valid)return{dir:e.dir,source:e.source};throw new p.CliError("HELP_ASSETS_NOT_FOUND","AIB content assets were not found.",{env:c.CLI_ENV.helpDir,checked:u().map(e=>e.dir)})}function u(){const e=process.env[c.CLI_ENV.helpDir],t=b(),r=o.resolve(__dirname,"..","help"),n=[];return e&&n.push(l(c.CLI_ENV.helpDir,o.resolve(e))),n.push(l("cache",t)),n.push(l("bundled",r)),n}function h(e){return s.existsSync(o.join(e,"bootstrap.md"))&&s.existsSync(o.join(e,"topics"))}function l(e,t){return s.existsSync(t)?s.existsSync(o.join(t,"bootstrap.md"))?s.existsSync(o.join(t,"topics"))?{source:e,dir:t,valid:!0}:{source:e,dir:t,valid:!1,reason:"missing topics"}:{source:e,dir:t,valid:!1,reason:"missing bootstrap.md"}:{source:e,dir:t,valid:!1,reason:"missing"}}function b(){if(process.env[c.CLI_ENV.productStorageDir]?.trim())return o.join(o.resolve(process.env[c.CLI_ENV.productStorageDir]),"help","current");const e=process.env.LOCALAPPDATA?o.join(process.env.LOCALAPPDATA,"aib"):process.env.XDG_STATE_HOME?o.join(process.env.XDG_STATE_HOME,"aib"):o.join(_.homedir(),".local","state","aib");return o.join(e,"help","current")}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compileAibDsl=V;const L=new Set(["file","exports","members","code","deps","usages","duplicates","graph","tree","cycles","imports"]),R=new Set(["rename","move","plan","module"]),$=new Set(["imports.normalize"]),K=new Set(["view"]),w="__aibDslDefaultFile",g="__aibDslDefaultScope",A="__aibDslDefaultTarget";function V(e,r={}){if(r.tolerantInspect===!0)return j(e);const t={},n=[],i=[],o=[],s=[],a=[];let c=null;for(const u of N(e)){const[f,...p]=u.tokens;if(f){if(f.startsWith("@")){M(t,f,p,u.lineNumber);continue}if(L.has(f)){c=y(c,"inspect",u.lineNumber),n.push(U(f,p,t,u.lineNumber));continue}if(R.has(f)){c=y(c,"mutation",u.lineNumber),f==="plan"||f==="module"?o.push(oe(p,u.lineNumber)):i.push(ie(f,p,u.lineNumber));continue}if($.has(f)){c=y(c,"imports",u.lineNumber),s.push(re(p,t,u.lineNumber));continue}if(K.has(f)){c=y(c,"view",u.lineNumber),a.push(se(p,u.lineNumber));continue}throw l(u.lineNumber,`Unknown DSL operation: ${f}`)}}if(c==="inspect")return{command:"inspect",payload:C(t,n)};if(o.length>0&&i.length>0)throw l(0,"Cannot mix modulePlan rows with rename/move mutation rows.");if(o.length>0)return E(t.sourceFile,"@source",0),{command:"modulePlan",payload:D({sourceFile:t.sourceFile,modules:o,expectEmpty:t.expectEmpty===!0?!0:void 0,save:t.save})};if(i.length===1){E(t.sourceFile,"@source",0);const u=i[0];return u.op==="rename"?{command:"rename",payload:D({sourceFile:t.sourceFile,renames:u.renames,save:t.save})}:{command:"move.toFile",payload:D({sourceFile:t.sourceFile,targetFile:u.targetFile,entities:u.entities,save:t.save})}}if(i.length>1)return E(t.sourceFile,"@source",0),{command:"refactor.batch",payload:D({sourceFile:t.sourceFile,requests:i,save:t.save})};if(s.length>0)return{command:"imports.normalize",payload:s.length===1?s[0]:{requests:s}};if(a.length>0)return{command:"view",payload:a.length===1?a[0]:{views:a}};throw l(0,"DSL document has no operations.")}function j(e){const r={},t=[],n=[];let i=null;const o=e.split(/\r?\n/);for(let a=0;a<o.length;a+=1){const c=a+1,u=o[a]??"",f=_(u).trim();if(!f)continue;let p;try{p=O(f,c)}catch(d){n.push({line:c,message:I(d instanceof Error?d.message:String(d))});continue}const[m,...T]=p;if(m){if(m.startsWith("@")){M(r,m,T,c);continue}if(L.has(m)){i=y(i,"inspect",c);try{t.push(U(m,T,r,c))}catch(d){n.push({line:c,message:I(d instanceof Error?d.message:String(d))})}continue}if(R.has(m)||$.has(m))throw l(c,"Cannot mix inspect, mutation, and imports operations in one DSL document.");n.push({line:c,message:`Unknown DSL operation: ${m}`})}}if(t.length===0)throw n.length>0?l(n[0].line,n[0].message):l(0,"DSL document has no operations.");const s=C(r,t);return n.length>0&&(s.dslDiagnostics=n.map(a=>({line:a.line,message:a.message}))),{command:"inspect",payload:s,...n.length>0?{diagnostics:n}:{}}}function I(e){return e.replace(/^DSL(?: line \d+)?:\s*/,"")}function N(e){return e.split(/\r?\n/).flatMap((r,t)=>{const n=_(r).trim();return n?[{lineNumber:t+1,tokens:O(n,t+1)}]:[]})}function _(e){let r=null;for(let t=0;t<e.length;t+=1){const n=e[t];if((n==='"'||n==="'")&&e[t-1]!=="\\"&&(r=r===n?null:r??n),n==="#"&&r===null)return e.slice(0,t)}return e}function O(e,r){const t=[];let n="",i=null;for(let o=0;o<e.length;o+=1){const s=e[o];if(i){s===i&&e[o-1]!=="\\"?i=null:n+=s;continue}if(s==='"'||s==="'"){i=s;continue}if(/\s/.test(s)){n&&(t.push(n),n="");continue}n+=s}if(i)throw l(r,"Unclosed quote.");return n&&t.push(n),t}function M(e,r,t,n){const i=t.join(" ").trim();if(!i)throw l(n,`${r} requires a value.`);switch(r){case"@file":e.file=i;return;case"@source":{const{value:o,flags:s}=B(t,n,r);e.sourceFile=o,s.has("expectEmpty")&&(e.expectEmpty=!0);return}case"@scope":e.scope=i;return;case"@target":e.target=i;return;case"@save":e.save=i;return;default:throw l(n,`Unknown DSL default: ${r}`)}}function B(e,r,t){const n=new Set,i=[];for(const s of e){if(s.startsWith("+")&&s.length>1){n.add(s.slice(1));continue}i.push(s)}const o=i.join(" ").trim();if(!o)throw l(r,`${t} requires a value.`);return{value:o,flags:n}}function y(e,r,t){if(e&&e!==r)throw l(t,"Cannot mix inspect, mutation, and imports operations in one DSL document.");return r}function U(e,r,t,n){const{positional:i,fields:o}=S(r,n),s={op:e};if(Object.assign(s,o),e==="file"||e==="exports"||e==="imports"){const a=i[0]??o.file,c=a??t.file;return c&&(s.file=c,a||h(s,w)),s}if(e==="members"){const c=W(s,i,t).map(v);return c.length===1&&!o.entity&&!o.entities?s.entity=c[0]:c.length>0&&!o.entities&&(s.entities=c),s}if(e==="code"||e==="deps"){const c=W(s,i,t).map(v);return e==="deps"&&c.length===1&&!o.entities&&!o.entity?s.entity=c[0]:c.length>0&&!o.entities&&!o.entity&&(s.entities=c),s}if(e==="usages"){const a=o.target??i[0],c=a??t.target??t.file;c&&(s.target=c,a||h(s,A));const u=o.entity??o.entities,p=(c===i[0]?i.slice(1):i).map(v);return!u&&p.length===1?s.entity=p[0]:!u&&p.length>1&&(s.entities=p),s}if(e==="duplicates"){const a=o.scope??i[0],c=a??t.scope;return c&&(s.scope=c,a||h(s,g)),s}if(e==="tree"){const a=o.scope??i[0],c=a??t.scope;return c&&(s.scope=c,a||h(s,g)),s}if(e==="cycles"){const a=o.scope??i[0],c=a??t.scope;return c&&(s.scope=c,a||h(s,g)),s}if(e==="graph"){const a=o.scope??i[0],c=a??t.scope;return c&&!s.fromFile&&(s.scope=c,a||h(s,g)),s}return s}function G(e,r){!e.file&&!e.fromFile&&r.file&&(e.file=r.file,h(e,w))}function W(e,r,t){return!e.file&&!e.fromFile&&r.length>0&&H(r[0])?(e.file=r[0],r.slice(1)):(G(e,t),r)}function H(e){return e.includes("/")||e.includes("\\")||/^@[^/\\]+[/\\]/.test(e)||/\.(?:[cm]?[jt]sx?|d\.ts)$/i.test(e)}function h(e,r){Object.defineProperty(e,r,{value:!0,enumerable:!1})}function S(e,r){const t=[],n={};for(const i of e){if(i.startsWith("+")&&i.length>1){x(n,i.slice(1),!0);continue}if(i.startsWith("-")&&i.length>1){x(n,i.slice(1),!1);continue}if(i.startsWith(">")&&i.length>1){x(n,"save",i.slice(1));continue}const o=i.indexOf("=");if(o>0){const s=i.slice(0,o),a=i.slice(o+1);x(n,q(s),J(s,a));continue}if(i==="->")throw l(r,"Unexpected move separator in inspect request.");t.push(i)}return{positional:t,fields:n}}function x(e,r,t){const n=e[r];if(n===void 0){e[r]=t;return}if(b(r)){e[r]=[...z(n),...z(t)];return}e[r]=t}function b(e){return e==="focus"||e==="scope"||e==="scopes"||e==="file"||e==="files"||e==="exclude"||e==="excludes"||e==="pathExclude"||e==="pathExcludes"||e==="excludePath"||e==="excludePaths"||e==="entities"||e==="only"||e==="except"||e==="kinds"}function z(e){return Array.isArray(e)?e:[e]}function q(e){return e==="from"?"fromFile":e==="no-default-exclude"?"noDefaultExclude":e==="no-config-exclude"?"noConfigExclude":e}function J(e,r){const t=X(r),n=Q(t);if(/^-?\d+$/.test(t))return Number(t);if(t==="true")return!0;if(t==="false")return!1;if(e==="entity"||e==="entities"){const i=(n??F(t)).map(v);return e==="entity"&&i.length===1?i[0]:i}return e==="only"||e==="except"?(n??F(t)).flatMap(Y):n&&b(q(e))?n:b(q(e))&&t.includes(",")?F(t):t}function Q(e){if(!e.startsWith("[")||!e.endsWith("]"))return null;const r=e.slice(1,-1).trim();return r?F(r):[]}function F(e){const r=[];let t="",n=0,i=0;for(const o of e){if(o==="{"?n+=1:o==="}"&&n>0?n-=1:o==="["?i+=1:o==="]"&&i>0&&(i-=1),o===","&&n===0&&i===0){t.trim()&&r.push(t.trim()),t="";continue}t+=o}return t.trim()&&r.push(t.trim()),r}function X(e){return e==="sum"?"summary":e==="loc"?"locations":e}function v(e){const r=e.match(/^(.+)\.\{(.+)\}$/);if(r){const n=r[1],i=r[2];return!n||!i?e:{parent:n,entities:i.split(",").map(o=>o.trim()).filter(Boolean)}}const t=e.match(/^(.+)\.([^./{}]+)$/);if(t){const n=t[1],i=t[2];return!n||!i?e:{parent:n,entities:[i]}}return e}function Y(e){const r=e.match(/^(.+)\.\{(.+)\}$/);if(r){const t=r[1],n=r[2];if(t&&n)return n.split(",").map(i=>i.trim()).filter(Boolean).map(i=>`${t}.${i}`)}return[e]}function C(e,r){const t=r.map(Z),n={requests:t};return P(n,t,{payloadKey:"file",defaultValue:e.file,predicate:ee,marker:w}),P(n,t,{payloadKey:"scope",defaultValue:e.scope,predicate:te,marker:g}),P(n,t,{payloadKey:"target",defaultValue:e.target,predicate:ne,marker:A}),e.save&&(n.save=e.save),k(n,t),n}function Z(e){const r={...e};for(const t of[w,g,A])e[t]===!0&&h(r,t);return r}function P(e,r,t){if(t.defaultValue===void 0)return;const n=r.filter(t.predicate);if(n.some(i=>i[t.payloadKey]!==void 0)){e[t.payloadKey]=t.defaultValue;for(const i of n)i[t.marker]===!0&&i[t.payloadKey]===t.defaultValue&&delete i[t.payloadKey]}}function k(e,r){for(const t of r){const n=String(t.op??"");if((n==="file"||n==="exports"||n==="imports")&&typeof t.file!="string"&&typeof e.file!="string")throw l(0,`${n} requires file=... or @file.`);if((n==="members"||n==="code"||n==="deps")&&typeof t.file!="string"&&typeof t.fromFile!="string"&&typeof e.file!="string")throw l(0,`${n} requires file=..., from=..., or @file.`);if(n==="usages"&&typeof t.target!="string"&&typeof e.target!="string")throw l(0,"usages requires target=..., positional target, @target, or @file.");if(n==="duplicates"&&typeof t.scope!="string"&&!Array.isArray(t.scope)&&typeof e.scope!="string"&&!Array.isArray(e.scope))throw l(0,"duplicates requires scope=..., positional scope, or @scope.");if(n==="graph"&&typeof t.fromFile!="string"&&typeof t.scope!="string"&&!Array.isArray(t.scope)&&typeof e.scope!="string"&&!Array.isArray(e.scope))throw l(0,"graph requires scope=..., positional scope, @scope, or from=...");if(n==="tree"&&typeof t.scope!="string"&&typeof e.scope!="string")throw l(0,"tree requires scope=..., positional scope, or @scope.");if(n==="cycles"&&typeof t.scope!="string"&&!Array.isArray(t.scope)&&typeof t.file!="string"&&!Array.isArray(t.files)&&typeof e.scope!="string"&&!Array.isArray(e.scope))throw l(0,"cycles requires scope=..., files=[...], positional scope, or @scope.")}}function ee(e){return(e.op==="file"||e.op==="exports"||e.op==="imports"||e.op==="members"||e.op==="code"||e.op==="deps")&&!e.fromFile}function te(e){return(e.op==="duplicates"||e.op==="graph"||e.op==="tree"||e.op==="cycles")&&!e.fromFile}function ne(e){return e.op==="usages"}function ie(e,r,t){if(e==="rename"){const i={};for(const o of r){if(o.startsWith(">")&&o.length>1)throw l(t,"Use @save <name> for mutation payload saves.");const s=o.indexOf("->");if(s<=0||s===o.length-2)throw l(t,`Invalid rename pair: ${o}`);i[o.slice(0,s)]=o.slice(s+2)}return{op:"rename",renames:i}}if(r.some(i=>i.startsWith(">")&&i.length>1))throw l(t,"Use @save <name> for mutation payload saves.");const n=r[0];if(typeof n=="string"&&n.endsWith(":")&&n.length>1){const i=r.slice(1);if(i.length===0)throw l(t,"Move entities are required.");return{op:"move",entities:i,targetFile:n.slice(0,-1)}}throw l(t,"Invalid move syntax. Expected: move target.ts: entity entity")}function re(e,r,t){const{positional:n,fields:i}=S(e,t),o={...i},s=o.scope??n[0]??r.scope;if(s!==void 0&&(o.scope=s),Array.isArray(o.scope))throw l(t,"imports.normalize scope expects one file/dir; use multiple imports.normalize lines for multiple scopes.");if(typeof o.scope!="string"||o.scope.length===0)throw l(t,"imports.normalize requires scope=..., positional scope, or @scope.");if(n.length>1)throw l(t,"imports.normalize accepts one positional scope; use key=value fields for options.");return o}function se(e,r){const{positional:t,fields:n}=S(e,r),i=n.handle??n.from??t[0];if(typeof i!="string"||i.length===0)throw l(r,"view requires a result handle.");if(t.length>1)throw l(r,"view accepts one positional handle; use key=value fields for options.");const o={handle:i};for(const[s,a]of Object.entries(n))s==="handle"||s==="from"||(o[s]=a);return o}function oe(e,r){if(e.findIndex(o=>o.endsWith(":"))!==0)throw l(r,"Plan syntax is: plan target.ts: entity entity");const n=e[0].slice(0,-1),i=e.slice(1);if(!n||i.length===0)throw l(r,"Plan row requires target and at least one entity.");return{target:n,entities:i}}function E(e,r,t){if(!e)throw l(t,`${r} is required.`)}function l(e,r){const t=e>0?`DSL line ${e}: `:"DSL: ";return new Error(`${t}${r}`)}function D(e){return Object.fromEntries(Object.entries(e).filter(r=>r[1]!==void 0))}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compileAibDsl=V;const L=new Set(["file","exports","members","code","deps","usages","duplicates","graph","tree","cycles","imports"]),R=new Set(["rename","move","plan","module"]),$=new Set(["imports.normalize"]),K=new Set(["view"]),w="__aibDslDefaultFile",g="__aibDslDefaultScope",A="__aibDslDefaultTarget";function V(e,r={}){if(r.tolerantInspect===!0)return j(e);const t={},n=[],i=[],o=[],s=[],a=[];let c=null;for(const f of N(e)){const[u,...p]=f.tokens;if(u){if(u.startsWith("@")){M(t,u,p,f.lineNumber);continue}if(L.has(u)){c=y(c,"inspect",f.lineNumber),n.push(U(u,p,t,f.lineNumber));continue}if(R.has(u)){c=y(c,"mutation",f.lineNumber),u==="plan"||u==="module"?o.push(oe(p,f.lineNumber)):i.push(ie(u,p,f.lineNumber));continue}if($.has(u)){c=y(c,"imports",f.lineNumber),s.push(re(p,t,f.lineNumber));continue}if(K.has(u)){c=y(c,"view",f.lineNumber),a.push(se(p,f.lineNumber));continue}throw l(f.lineNumber,`Unknown DSL operation: ${u}`)}}if(c==="inspect")return{command:"inspect",payload:C(t,n)};if(o.length>0&&i.length>0)throw l(0,"Cannot mix modulePlan rows with rename/move mutation rows.");if(o.length>0)return E(t.sourceFile,"@source",0),{command:"modulePlan",payload:D({sourceFile:t.sourceFile,modules:o,expectEmpty:t.expectEmpty===!0?!0:void 0,save:t.save})};if(i.length===1){E(t.sourceFile,"@source",0);const f=i[0];return f.op==="rename"?{command:"rename",payload:D({sourceFile:t.sourceFile,renames:f.renames,save:t.save})}:{command:"move.toFile",payload:D({sourceFile:t.sourceFile,targetFile:f.targetFile,entities:f.entities,save:t.save})}}if(i.length>1)return E(t.sourceFile,"@source",0),{command:"refactor.batch",payload:D({sourceFile:t.sourceFile,requests:i,save:t.save})};if(s.length>0)return{command:"imports.normalize",payload:s.length===1?s[0]:{requests:s}};if(a.length>0)return{command:"view",payload:a.length===1?a[0]:{views:a}};throw l(0,"DSL document has no operations.")}function j(e){const r={},t=[],n=[];let i=null;const o=e.split(/\r?\n/);for(let a=0;a<o.length;a+=1){const c=a+1,f=o[a]??"",u=_(f).trim();if(!u)continue;let p;try{p=O(u,c)}catch(d){n.push({line:c,message:I(d instanceof Error?d.message:String(d))});continue}const[m,...T]=p;if(m){if(m.startsWith("@")){M(r,m,T,c);continue}if(L.has(m)){i=y(i,"inspect",c);try{t.push(U(m,T,r,c))}catch(d){n.push({line:c,message:I(d instanceof Error?d.message:String(d))})}continue}if(R.has(m)||$.has(m))throw l(c,"Cannot mix inspect, mutation, and imports operations in one DSL document.");n.push({line:c,message:`Unknown DSL operation: ${m}`})}}if(t.length===0)throw n.length>0?l(n[0].line,n[0].message):l(0,"DSL document has no operations.");const s=C(r,t);return n.length>0&&(s.dslDiagnostics=n.map(a=>({line:a.line,message:a.message}))),{command:"inspect",payload:s,...n.length>0?{diagnostics:n}:{}}}function I(e){return e.replace(/^DSL(?: line \d+)?:\s*/,"")}function N(e){return e.split(/\r?\n/).flatMap((r,t)=>{const n=_(r).trim();return n?[{lineNumber:t+1,tokens:O(n,t+1)}]:[]})}function _(e){let r=null;for(let t=0;t<e.length;t+=1){const n=e[t];if((n==='"'||n==="'")&&e[t-1]!=="\\"&&(r=r===n?null:r??n),n==="#"&&r===null&&(t===0||/\s/.test(e[t-1]??"")))return e.slice(0,t)}return e}function O(e,r){const t=[];let n="",i=null;for(let o=0;o<e.length;o+=1){const s=e[o];if(i){s===i&&e[o-1]!=="\\"?i=null:n+=s;continue}if(s==='"'||s==="'"){i=s;continue}if(/\s/.test(s)){n&&(t.push(n),n="");continue}n+=s}if(i)throw l(r,"Unclosed quote.");return n&&t.push(n),t}function M(e,r,t,n){const i=t.join(" ").trim();if(!i)throw l(n,`${r} requires a value.`);switch(r){case"@file":e.file=i;return;case"@source":{const{value:o,flags:s}=B(t,n,r);e.sourceFile=o,s.has("expectEmpty")&&(e.expectEmpty=!0);return}case"@scope":e.scope=i;return;case"@target":e.target=i;return;case"@save":e.save=i;return;default:throw l(n,`Unknown DSL default: ${r}`)}}function B(e,r,t){const n=new Set,i=[];for(const s of e){if(s.startsWith("+")&&s.length>1){n.add(s.slice(1));continue}i.push(s)}const o=i.join(" ").trim();if(!o)throw l(r,`${t} requires a value.`);return{value:o,flags:n}}function y(e,r,t){if(e&&e!==r)throw l(t,"Cannot mix inspect, mutation, and imports operations in one DSL document.");return r}function U(e,r,t,n){const{positional:i,fields:o}=S(r,n),s={op:e};if(Object.assign(s,o),e==="file"||e==="exports"||e==="imports"){const a=i[0]??o.file,c=a??t.file;return c&&(s.file=c,a||h(s,w)),s}if(e==="members"){const c=W(s,i,t).map(v);return c.length===1&&!o.entity&&!o.entities?s.entity=c[0]:c.length>0&&!o.entities&&(s.entities=c),s}if(e==="code"||e==="deps"){const c=W(s,i,t).map(v);return e==="deps"&&c.length===1&&typeof c[0]=="string"&&!o.entities&&!o.entity?s.entity=c[0]:c.length>0&&!o.entities&&!o.entity&&(s.entities=c),s}if(e==="usages"){const a=o.target??i[0],c=a??t.target??t.file;c&&(s.target=c,a||h(s,A));const f=o.entity??o.entities,p=(c===i[0]?i.slice(1):i).map(v);return!f&&p.length===1?s.entity=p[0]:!f&&p.length>1&&(s.entities=p),s}if(e==="duplicates"){const a=o.scope??i[0],c=a??t.scope;return c&&(s.scope=c,a||h(s,g)),s}if(e==="tree"){const a=o.scope??i[0],c=a??t.scope;return c&&(s.scope=c,a||h(s,g)),s}if(e==="cycles"){const a=o.scope??i[0],c=a??t.scope;return c&&(s.scope=c,a||h(s,g)),s}if(e==="graph"){const a=o.scope??i[0],c=a??t.scope;return c&&!s.fromFile&&(s.scope=c,a||h(s,g)),s}return s}function G(e,r){!e.file&&!e.fromFile&&r.file&&(e.file=r.file,h(e,w))}function W(e,r,t){return!e.file&&!e.fromFile&&r.length>0&&H(r[0])?(e.file=r[0],r.slice(1)):(G(e,t),r)}function H(e){return e.includes("/")||e.includes("\\")||/^@[^/\\]+[/\\]/.test(e)||/\.(?:[cm]?[jt]sx?|d\.ts)$/i.test(e)}function h(e,r){Object.defineProperty(e,r,{value:!0,enumerable:!1})}function S(e,r){const t=[],n={};for(const i of e){if(i.startsWith("+")&&i.length>1){x(n,i.slice(1),!0);continue}if(i.startsWith("-")&&i.length>1){x(n,i.slice(1),!1);continue}if(i.startsWith(">")&&i.length>1){x(n,"save",i.slice(1));continue}const o=i.indexOf("=");if(o>0){const s=i.slice(0,o),a=i.slice(o+1);x(n,q(s),J(s,a));continue}if(i==="->")throw l(r,"Unexpected move separator in inspect request.");t.push(i)}return{positional:t,fields:n}}function x(e,r,t){const n=e[r];if(n===void 0){e[r]=t;return}if(b(r)){e[r]=[...z(n),...z(t)];return}e[r]=t}function b(e){return e==="focus"||e==="scope"||e==="scopes"||e==="file"||e==="files"||e==="exclude"||e==="excludes"||e==="pathExclude"||e==="pathExcludes"||e==="excludePath"||e==="excludePaths"||e==="entities"||e==="only"||e==="except"||e==="kinds"}function z(e){return Array.isArray(e)?e:[e]}function q(e){return e==="from"?"fromFile":e==="no-default-exclude"?"noDefaultExclude":e==="no-config-exclude"?"noConfigExclude":e}function J(e,r){const t=X(r),n=Q(t);if(/^-?\d+$/.test(t))return Number(t);if(t==="true")return!0;if(t==="false")return!1;if(e==="entity"||e==="entities"){const i=(n??F(t)).map(v);return e==="entity"&&i.length===1?i[0]:i}return e==="only"||e==="except"?(n??F(t)).flatMap(Y):n&&b(q(e))?n:b(q(e))&&t.includes(",")?F(t):t}function Q(e){if(!e.startsWith("[")||!e.endsWith("]"))return null;const r=e.slice(1,-1).trim();return r?F(r):[]}function F(e){const r=[];let t="",n=0,i=0;for(const o of e){if(o==="{"?n+=1:o==="}"&&n>0?n-=1:o==="["?i+=1:o==="]"&&i>0&&(i-=1),o===","&&n===0&&i===0){t.trim()&&r.push(t.trim()),t="";continue}t+=o}return t.trim()&&r.push(t.trim()),r}function X(e){return e==="sum"?"summary":e==="loc"?"locations":e}function v(e){const r=e.match(/^(.+)\.\{(.+)\}$/);if(r){const n=r[1],i=r[2];return!n||!i?e:{parent:n,entities:i.split(",").map(o=>o.trim()).filter(Boolean)}}const t=e.match(/^(.+)\.([^./{}]+)$/);if(t){const n=t[1],i=t[2];return!n||!i?e:{parent:n,entities:[i]}}return e}function Y(e){const r=e.match(/^(.+)\.\{(.+)\}$/);if(r){const t=r[1],n=r[2];if(t&&n)return n.split(",").map(i=>i.trim()).filter(Boolean).map(i=>`${t}.${i}`)}return[e]}function C(e,r){const t=r.map(Z),n={requests:t};return P(n,t,{payloadKey:"file",defaultValue:e.file,predicate:ee,marker:w}),P(n,t,{payloadKey:"scope",defaultValue:e.scope,predicate:te,marker:g}),P(n,t,{payloadKey:"target",defaultValue:e.target,predicate:ne,marker:A}),e.save&&(n.save=e.save),k(n,t),n}function Z(e){const r={...e};for(const t of[w,g,A])e[t]===!0&&h(r,t);return r}function P(e,r,t){if(t.defaultValue===void 0)return;const n=r.filter(t.predicate);if(n.some(i=>i[t.payloadKey]!==void 0)){e[t.payloadKey]=t.defaultValue;for(const i of n)i[t.marker]===!0&&i[t.payloadKey]===t.defaultValue&&delete i[t.payloadKey]}}function k(e,r){for(const t of r){const n=String(t.op??"");if((n==="file"||n==="exports"||n==="imports")&&typeof t.file!="string"&&typeof e.file!="string")throw l(0,`${n} requires file=... or @file.`);if((n==="members"||n==="code"||n==="deps")&&typeof t.file!="string"&&typeof t.fromFile!="string"&&typeof e.file!="string")throw l(0,`${n} requires file=..., from=..., or @file.`);if(n==="usages"&&typeof t.target!="string"&&typeof e.target!="string")throw l(0,"usages requires target=..., positional target, @target, or @file.");if(n==="duplicates"&&typeof t.scope!="string"&&!Array.isArray(t.scope)&&typeof e.scope!="string"&&!Array.isArray(e.scope))throw l(0,"duplicates requires scope=..., positional scope, or @scope.");if(n==="graph"&&typeof t.fromFile!="string"&&typeof t.scope!="string"&&!Array.isArray(t.scope)&&typeof e.scope!="string"&&!Array.isArray(e.scope))throw l(0,"graph requires scope=..., positional scope, @scope, or from=...");if(n==="tree"&&typeof t.scope!="string"&&typeof e.scope!="string")throw l(0,"tree requires scope=..., positional scope, or @scope.");if(n==="cycles"&&typeof t.scope!="string"&&!Array.isArray(t.scope)&&typeof t.file!="string"&&!Array.isArray(t.files)&&typeof e.scope!="string"&&!Array.isArray(e.scope))throw l(0,"cycles requires scope=..., files=[...], positional scope, or @scope.")}}function ee(e){return(e.op==="file"||e.op==="exports"||e.op==="imports"||e.op==="members"||e.op==="code"||e.op==="deps")&&!e.fromFile}function te(e){return(e.op==="duplicates"||e.op==="graph"||e.op==="tree"||e.op==="cycles")&&!e.fromFile}function ne(e){return e.op==="usages"}function ie(e,r,t){if(e==="rename"){const i={};for(const o of r){if(o.startsWith(">")&&o.length>1)throw l(t,"Use @save <name> for mutation payload saves.");const s=o.indexOf("->");if(s<=0||s===o.length-2)throw l(t,`Invalid rename pair: ${o}`);i[o.slice(0,s)]=o.slice(s+2)}return{op:"rename",renames:i}}if(r.some(i=>i.startsWith(">")&&i.length>1))throw l(t,"Use @save <name> for mutation payload saves.");const n=r[0];if(typeof n=="string"&&n.endsWith(":")&&n.length>1){const i=r.slice(1);if(i.length===0)throw l(t,"Move entities are required.");return{op:"move",entities:i,targetFile:n.slice(0,-1)}}throw l(t,"Invalid move syntax. Expected: move target.ts: entity entity")}function re(e,r,t){const{positional:n,fields:i}=S(e,t),o={...i},s=o.scope??n[0]??r.scope;if(s!==void 0&&(o.scope=s),Array.isArray(o.scope))throw l(t,"imports.normalize scope expects one file/dir; use multiple imports.normalize lines for multiple scopes.");if(typeof o.scope!="string"||o.scope.length===0)throw l(t,"imports.normalize requires scope=..., positional scope, or @scope.");if(n.length>1)throw l(t,"imports.normalize accepts one positional scope; use key=value fields for options.");return o}function se(e,r){const{positional:t,fields:n}=S(e,r),i=n.handle??n.from??t[0];if(typeof i!="string"||i.length===0)throw l(r,"view requires a result handle.");if(t.length>1)throw l(r,"view accepts one positional handle; use key=value fields for options.");const o={handle:i};for(const[s,a]of Object.entries(n))s==="handle"||s==="from"||(o[s]=a);return o}function oe(e,r){if(e.findIndex(o=>o.endsWith(":"))!==0)throw l(r,"Plan syntax is: plan target.ts: entity entity");const n=e[0].slice(0,-1),i=e.slice(1);if(!n||i.length===0)throw l(r,"Plan row requires target and at least one entity.");return{target:n,entities:i}}function E(e,r,t){if(!e)throw l(t,`${r} is required.`)}function l(e,r){const t=e>0?`DSL line ${e}: `:"DSL: ";return new Error(`${t}${r}`)}function D(e){return Object.fromEntries(Object.entries(e).filter(r=>r[1]!==void 0))}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compileDeclarationDsl=E;const c=require("../shared/errors");function E(n,e){const t={scope:void 0,files:void 0,operation:void 0,selectors:[],exclude:[],prefer:[],details:!1},i=n.split(/\r?\n/);for(let o=0;o<i.length;o+=1){const s=o+1,r=m(i[o]??"").trim();if(r){if(r.startsWith("@scope ")){t.scope=A(r,s,t),t.files=void 0;continue}if(r.startsWith("@files ")){if(t.files=I(r,s,t),t.scope=void 0,t.files.length===0)throw new c.CliError("DECLARATION_FILES_REQUIRED",`@files expects at least one file at line ${s}.`,{line:s});continue}if(r.startsWith("remove ")||r==="remove"){D(t,"remove",r.slice(6).trim(),s);continue}if(r.startsWith("addMissing ")||r==="addMissing"){D(t,"addMissing",r.slice(10).trim(),s);continue}throw new c.CliError("INVALID_DECLARATION_DSL",`Invalid declaration DSL at line ${s}: ${r}`,{line:s,expected:"@scope <dir>, @files <file>..., remove <selector>..., or addMissing [selector]..."})}}if(!t.scope&&(!t.files||t.files.length===0))throw new c.CliError("DECLARATION_TARGET_REQUIRED","declaration DSL expects @scope <dir> or @files <file> ...");if(!t.operation)throw new c.CliError("DECLARATION_OPERATION_REQUIRED","declaration DSL expects remove or addMissing.");if(e&&t.operation!==e)throw new c.CliError("DECLARATION_OPERATION_MISMATCH",`DSL operation is ${t.operation}, but command expects ${e}.`);if(t.operation==="remove"&&t.selectors.length===0)throw new c.CliError("DECLARATION_REMOVE_SELECTORS_REQUIRED","declaration remove expects at least one selector.");return C({operation:t.operation,scope:t.scope,files:t.files,selectors:t.selectors,exclude:t.exclude.length>0?t.exclude:void 0,prefer:t.prefer.length>0?t.prefer:void 0,details:t.details===!0?!0:void 0})}function A(n,e,t){const i=d(n.slice(6).trim(),e),o=[];for(const s of i)u(s,t)||o.push(s);if(o.length!==1)throw new c.CliError("INVALID_DECLARATION_DSL",`@scope expects one path at line ${e}.`,{line:e});return o[0]}function I(n,e,t){const i=[];for(const o of d(n.slice(6).trim(),e))u(o,t)||i.push(o);return i}function D(n,e,t,i){if(n.operation)throw new c.CliError("DECLARATION_OPERATION_DUPLICATE",`Only one declaration operation is supported at line ${i}.`,{line:i});n.operation=e;const o=[];for(const s of t?d(t,i):[]){if(u(s,n))continue;const r=L(s);if(!r){o.push(s);continue}if(r.key==="entities"||r.key==="selectors"){o.push(...a(r.value));continue}if(r.key==="exclude"){n.exclude.push(...a(r.value));continue}if(r.key==="prefer"){n.prefer.push(...a(r.value));continue}throw new c.CliError("INVALID_DECLARATION_DSL_FIELD",`Unknown declaration DSL field at line ${i}: ${r.key}`,{line:i})}n.selectors.push(..._(o))}function u(n,e){return n!=="+details"&&n!=="+detail"?!1:(e.details=!0,!0)}function w(n,e,t){const i=n.slice(e.length).trim();if(!i)throw new c.CliError("INVALID_DECLARATION_DSL",`${e} expects a value at line ${t}.`,{line:t});return i}function L(n){const e=n.indexOf("=");return e<=0?null:{key:n.slice(0,e),value:n.slice(e+1)}}function a(n){const e=n.trim();if(!e)return[];if(!e.startsWith("[")||!e.endsWith("]"))return[p(e)];const t=e.slice(1,-1),i=[];let o="",s=null;for(let l=0;l<t.length;l+=1){const f=t[l];if(s){f===s?s=null:o+=f;continue}if(f==="'"||f==='"'){s=f;continue}if(f===","){const h=o.trim();h&&i.push(p(h)),o="";continue}o+=f}const r=o.trim();return r&&i.push(p(r)),i}function d(n,e){const t=[];let i="",o=null,s=0;for(let r=0;r<n.length;r+=1){const l=n[r];if(o){l===o?o=null:i+=l;continue}if(l==="'"||l==='"'){o=l;continue}if(l==="["){s+=1,i+=l;continue}if(l==="]"){s=Math.max(0,s-1),i+=l;continue}if(/\s/.test(l)&&s===0){i&&(t.push(i),i="");continue}i+=l}if(o)throw new c.CliError("INVALID_DECLARATION_DSL",`Unterminated quote at line ${e}.`,{line:e});if(s!==0)throw new c.CliError("INVALID_DECLARATION_DSL",`Unterminated list at line ${e}.`,{line:e});return i&&t.push(i),t}function m(n){const e=n.indexOf("#");return e>=0?n.slice(0,e):n}function p(n){const e=n.trim();return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function _(n){return[...new Set(n.filter(e=>e.trim()!==""))]}function C(n){const e={};for(const[t,i]of Object.entries(n))i!==void 0&&(e[t]=i);return e}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compileFileMoveToDirDsl=E;const s=require("../shared/errors");function E(n){let t=null;const i=[];let e=null;const l=n.split(/\r?\n/);for(let r=0;r<l.length;r+=1){const o=r+1,f=l[r]??"",c=I(f).trim();if(c){if(c.startsWith("@base ")){t=u(c,"@base",o),e=null;continue}if(c.startsWith("moveToDir ")){const a=_(c,o);i.push(a),e=a;continue}if(f.match(/^\s+/)&&e){e.files.push(...D(c,o));continue}throw new s.CliError("INVALID_FILE_MOVE_DSL",`Invalid file move DSL at line ${o}: ${c}`,{line:o,expected:"@base <dir> or moveToDir <targetDir>: <file> ..."})}}if(!t)throw new s.CliError("FILE_MOVE_BASE_REQUIRED","file move toDir DSL expects @base <dir>.");if(i.length===0)throw new s.CliError("FILE_MOVE_ROWS_REQUIRED","file move toDir DSL expects at least one moveToDir row.");for(const[r,o]of i.entries())if(o.files.length===0)throw new s.CliError("FILE_MOVE_FILES_REQUIRED",`moveToDir row ${r+1} expects at least one file.`);return{base:t,moves:i}}function u(n,t,i){const e=n.slice(t.length).trim();if(!e)throw new s.CliError("INVALID_FILE_MOVE_DSL",`${t} expects a value at line ${i}.`,{line:i});return e}function _(n,t){const i=n.slice(9).trim(),e=i.indexOf(":");if(e<0)throw new s.CliError("INVALID_FILE_MOVE_DSL",`moveToDir expects ':' at line ${t}.`,{line:t});const l=i.slice(0,e).trim();if(!l)throw new s.CliError("INVALID_FILE_MOVE_DSL",`moveToDir expects a target directory at line ${t}.`,{line:t});const r=i.slice(e+1).trim();return{targetDir:l,files:r?D(r,t):[]}}function I(n){const t=n.indexOf("#");return t>=0?n.slice(0,t):n}function D(n,t){const i=[];let e="",l=null;for(let r=0;r<n.length;r+=1){const o=n[r];if(l){o===l?l=null:e+=o;continue}if(o==="'"||o==='"'){l=o;continue}if(/\s/.test(o)){e&&(i.push(e),e="");continue}e+=o}if(l)throw new s.CliError("INVALID_FILE_MOVE_DSL",`Unterminated quote at line ${t}.`,{line:t});return e&&i.push(e),i}
@@ -0,0 +1 @@
1
+ "use strict";var E=exports&&exports.__createBinding||(Object.create?(function(r,e,n,t){t===void 0&&(t=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(r,t,i)}):(function(r,e,n,t){t===void 0&&(t=n),r[t]=e[n]})),p=exports&&exports.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),L=exports&&exports.__importStar||(function(){var r=function(e){return r=Object.getOwnPropertyNames||function(n){var t=[];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[t.length]=i);return t},r(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var t=r(e),i=0;i<t.length;i++)t[i]!=="default"&&E(n,e,t[i]);return p(n,e),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.compileFileRefactorBatchDsl=R;const c=L(require("node:path")),a=require("../shared/errors");function R(r){let e=null;const n=[],t=r.split(/\r?\n/);for(let i=0;i<t.length;i+=1){const o=i+1,s=t[i]??"",l=v(s).trim();if(l){if(l.startsWith("@base ")){e=A(l,"@base",o);continue}if(!e)throw new a.CliError("FILE_REFACTOR_BATCH_BASE_REQUIRED",`file refactor batch DSL expects @base before line ${o}.`,{line:o});if(l.startsWith("moveToDir ")){const u=C(l,o);for(const _ of u.files){const f=h(e,_),D=h(e,u.targetDir);n.push({kind:"fileMoveToDir",sourceFile:f,targetDir:D,targetFile:c.normalize(c.join(D,c.basename(f)))})}continue}if(l.startsWith("rename ")){for(const u of g(l,o)){const _=h(e,u.source),f=m(e,_,u.target);n.push({kind:"fileRename",sourceFile:_,targetDir:c.dirname(f),targetFile:f})}continue}throw new a.CliError("INVALID_FILE_REFACTOR_BATCH_DSL",`Invalid file refactor batch DSL at line ${o}: ${l}`,{line:o,expected:"@base <dir>, moveToDir <targetDir>: <file> ..., or rename <source>-><target>"})}}if(n.length===0)throw new a.CliError("FILE_REFACTOR_BATCH_ROWS_REQUIRED","file refactor batch DSL expects at least one operation.");return{operations:n}}function A(r,e,n){const t=r.slice(e.length).trim();if(!t)throw new a.CliError("INVALID_FILE_REFACTOR_BATCH_DSL",`${e} expects a value at line ${n}.`,{line:n});return t}function C(r,e){const n=r.slice(9).trim(),t=n.indexOf(":");if(t<0)throw new a.CliError("INVALID_FILE_REFACTOR_BATCH_DSL",`moveToDir expects ':' at line ${e}.`,{line:e});const i=n.slice(0,t).trim(),o=n.slice(t+1).trim();if(!i||!o)throw new a.CliError("INVALID_FILE_REFACTOR_BATCH_DSL",`moveToDir expects a target directory and at least one file at line ${e}.`,{line:e});return{targetDir:i,files:d(o,e)}}function g(r,e){const n=r.slice(6).trim(),t=d(n,e),i=[];for(let o=0;o<t.length;o+=1){const s=t[o];if(t[o+1]!=="->"||!t[o+2])throw new a.CliError("INVALID_FILE_REFACTOR_BATCH_DSL",`rename expects <source>-><target> at line ${e}.`,{line:e});i.push({source:s,target:t[o+2]}),o+=2}return i}function h(r,e){return c.normalize(c.isAbsolute(e)?e:c.join(r,e))}function m(r,e,n){return c.isAbsolute(n)?c.normalize(n):n.includes("/")||n.includes("\\")?c.normalize(c.join(r,n)):c.normalize(c.join(c.dirname(e),n))}function v(r){const e=r.indexOf("#");return e>=0?r.slice(0,e):r}function d(r,e){const n=[];let t="",i=null;for(let o=0;o<r.length;o+=1){const s=r[o];if(i){s===i?i=null:t+=s;continue}if(s==="'"||s==='"'){i=s;continue}if(/\s/.test(s)){t&&(n.push(t),t="");continue}if(s==="-"&&r[o+1]===">"){t&&(n.push(t),t=""),n.push("->"),o+=1;continue}t+=s}if(i)throw new a.CliError("INVALID_FILE_REFACTOR_BATCH_DSL",`Unterminated quote at line ${e}.`,{line:e});return t&&n.push(t),n}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compileFileRenameDsl=E;const l=require("../shared/errors");function E(i){let n=null;const o=[],e=i.split(/\r?\n/);for(let s=0;s<e.length;s+=1){const r=s+1,t=L(e[s]??"").trim();if(t){if(t.startsWith("@base ")){n=h(t,"@base",r);continue}if(t.startsWith("rename ")){o.push(..._(t,r));continue}throw new l.CliError("INVALID_FILE_RENAME_DSL",`Invalid file rename DSL at line ${r}: ${t}`,{line:r,expected:"@base <dir> or rename <source>-><target>"})}}if(!n)throw new l.CliError("FILE_RENAME_BASE_REQUIRED","file rename DSL expects @base <dir>.");if(o.length===0)throw new l.CliError("FILE_RENAME_ROWS_REQUIRED","file rename DSL expects at least one rename pair.");return{base:n,renames:o}}function h(i,n,o){const e=i.slice(n.length).trim();if(!e)throw new l.CliError("INVALID_FILE_RENAME_DSL",`${n} expects a value at line ${o}.`,{line:o});return e}function _(i,n){const o=i.slice(6).trim();if(!o)throw new l.CliError("INVALID_FILE_RENAME_DSL",`rename expects at least one pair at line ${n}.`,{line:n});const e=p(o,n),s=[];for(let r=0;r<e.length;r+=1){const t=e[r];if(t==="->")throw a(n);const c=t.indexOf("->");if(c>=0){const u=t.slice(0,c).trim(),f=t.slice(c+2).trim();if(!u||!f)throw a(n);s.push({source:u,target:f});continue}if(e[r+1]!=="->"||!e[r+2])throw a(n);s.push({source:t,target:e[r+2]}),r+=2}return s}function a(i){return new l.CliError("INVALID_FILE_RENAME_DSL",`rename expects <source>-><target> at line ${i}.`,{line:i})}function L(i){const n=i.indexOf("#");return n>=0?i.slice(0,n):i}function p(i,n){const o=[];let e="",s=null;for(let r=0;r<i.length;r+=1){const t=i[r];if(s){t===s?s=null:e+=t;continue}if(t==="'"||t==='"'){s=t;continue}if(/\s/.test(t)){e&&(o.push(e),e="");continue}if(t==="-"&&i[r+1]===">"){e&&(o.push(e),e=""),o.push("->"),r+=1;continue}e+=t}if(s)throw new l.CliError("INVALID_FILE_RENAME_DSL",`Unterminated quote at line ${n}.`,{line:n});return e&&o.push(e),o}