@automaton-labs/aib 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +4 -2
- package/dist/commands/apply-module-plan.js +3 -3
- package/dist/commands/background-command.js +2 -0
- package/dist/commands/captured-input.js +1 -2
- package/dist/commands/config-command.js +2 -2
- package/dist/commands/config-output.js +10 -10
- package/dist/commands/control-plane-command.js +1 -0
- package/dist/commands/declaration-command.js +7 -0
- package/dist/commands/declaration-execution-cache.js +1 -0
- package/dist/commands/declaration-format.js +1 -0
- package/dist/commands/declaration-preview-cache.js +2 -0
- package/dist/commands/doctor.js +3 -2
- package/dist/commands/execution-command.js +1 -1
- package/dist/commands/file-command.js +1 -0
- package/dist/commands/file-move-to-dir-execution-cache.js +1 -0
- package/dist/commands/file-move-to-dir-preview-cache.js +2 -0
- package/dist/commands/file-move-to-dir.js +5 -0
- package/dist/commands/file-mutation-runtime.js +1 -0
- package/dist/commands/file-refactor-batch-execution-cache.js +1 -0
- package/dist/commands/file-refactor-batch-preview-cache.js +2 -0
- package/dist/commands/file-refactor-batch.js +5 -0
- package/dist/commands/file-rename-execution-cache.js +1 -0
- package/dist/commands/file-rename-preview-cache.js +2 -0
- package/dist/commands/file-rename.js +5 -0
- package/dist/commands/help-command.js +5 -5
- package/dist/commands/host-command.js +1 -0
- package/dist/commands/inspect-cycles.js +3 -3
- package/dist/commands/inspect-format.js +15 -15
- package/dist/commands/inspect-tree.js +2 -2
- package/dist/commands/inspect.js +12 -12
- package/dist/commands/move-to-file.js +2 -2
- package/dist/commands/ota-command.js +2 -0
- package/dist/commands/quick-read.js +4 -4
- package/dist/commands/refactor-batch.js +4 -4
- package/dist/commands/rename-entities.js +4 -4
- package/dist/commands/result-view.js +6 -5
- package/dist/commands/worker-command.js +1 -0
- package/dist/config/defaults.js +1 -1
- package/dist/config/env-vars.js +1 -1
- package/dist/config/path-aliases.js +1 -1
- package/dist/config/resolve-command-alias.js +1 -1
- package/dist/content/content-bundle.js +1 -1
- package/dist/dsl/aib-dsl.js +1 -1
- package/dist/dsl/declaration-dsl.js +1 -0
- package/dist/dsl/file-move-to-dir-dsl.js +1 -0
- package/dist/dsl/file-refactor-batch-dsl.js +1 -0
- package/dist/dsl/file-rename-dsl.js +1 -0
- package/dist/help/{json/bootstrap.md → bootstrap.bash.md} +214 -392
- package/dist/help/bootstrap.md +101 -137
- package/dist/help/{json/full.md → bootstrap.pwsh.md} +214 -392
- package/dist/help/docs/dsl.md +4 -3
- package/dist/help/docs/file.move.md +46 -0
- package/dist/help/docs/file.rename.md +35 -0
- package/dist/help/docs/inspect.code.md +5 -5
- package/dist/help/docs/inspect.deps.md +7 -7
- package/dist/help/docs/inspect.file.md +2 -1
- package/dist/help/docs/inspect.graph.md +3 -3
- package/dist/help/docs/inspect.md +5 -5
- package/dist/help/docs/mutation.md +23 -13
- package/dist/help/docs/patterns.md +1 -5
- package/dist/help/docs/qr.md +7 -22
- package/dist/help/docs/quick-map.md +1 -0
- package/dist/help/docs/recipe.file-layout.md +15 -0
- package/dist/help/docs/rg.md +22 -0
- package/dist/help/docs/selectors.md +3 -2
- package/dist/help/docs/session.md +1 -1
- package/dist/help/dsl/bootstrap.bash.md +907 -0
- package/dist/help/dsl/bootstrap.md +101 -137
- package/dist/help/dsl/bootstrap.pwsh.md +907 -0
- package/dist/help/dsl/docs/dsl.md +4 -3
- package/dist/help/dsl/docs/file.move.md +46 -0
- package/dist/help/dsl/docs/file.rename.md +35 -0
- package/dist/help/dsl/docs/inspect.code.md +5 -5
- package/dist/help/dsl/docs/inspect.deps.md +7 -7
- package/dist/help/dsl/docs/inspect.file.md +2 -1
- package/dist/help/dsl/docs/inspect.graph.md +3 -3
- package/dist/help/dsl/docs/inspect.md +5 -5
- package/dist/help/dsl/docs/mutation.md +23 -13
- package/dist/help/dsl/docs/patterns.md +1 -5
- package/dist/help/dsl/docs/qr.md +7 -22
- package/dist/help/dsl/docs/quick-map.md +1 -0
- package/dist/help/dsl/docs/recipe.file-layout.md +15 -0
- package/dist/help/dsl/docs/rg.md +22 -0
- package/dist/help/dsl/docs/selectors.md +3 -2
- package/dist/help/dsl/docs/session.md +1 -1
- package/dist/help/dsl/full.md +101 -137
- package/dist/help/dsl/help-index.md +44 -0
- package/dist/help/dsl/tokens/qr.inline.examples.md +2 -0
- package/dist/help/dsl/tokens/stdin.examples.bash.md +8 -0
- package/dist/help/dsl/tokens/stdin.examples.pwsh.md +8 -0
- package/dist/help/dsl/tokens/stdin.examples.with-qr.bash.md +12 -0
- package/dist/help/dsl/tokens/stdin.examples.with-qr.pwsh.md +12 -0
- package/dist/help/dsl/topics/dsl.md +4 -3
- package/dist/help/dsl/topics/file.move.md +44 -0
- package/dist/help/dsl/topics/file.rename.md +33 -0
- package/dist/help/dsl/topics/inspect.code.md +5 -5
- package/dist/help/dsl/topics/inspect.deps.md +7 -7
- package/dist/help/dsl/topics/inspect.file.md +2 -1
- package/dist/help/dsl/topics/inspect.graph.md +3 -3
- package/dist/help/dsl/topics/inspect.md +5 -5
- package/dist/help/dsl/topics/mutation.md +23 -13
- package/dist/help/dsl/topics/patterns.md +1 -5
- package/dist/help/dsl/topics/qr.md +7 -22
- package/dist/help/dsl/topics/quick-map.md +1 -0
- package/dist/help/dsl/topics/recipe.file-layout.md +13 -0
- package/dist/help/dsl/topics/rg.md +20 -0
- package/dist/help/dsl/topics/selectors.md +3 -2
- package/dist/help/dsl/topics/session.md +1 -1
- package/dist/help/full.md +101 -137
- package/dist/help/help-index.md +44 -0
- package/dist/help/help-meta.json +43 -27
- package/dist/help/index.md +32 -75
- package/dist/help/tokens/qr.inline.examples.md +2 -0
- package/dist/help/tokens/stdin.examples.bash.md +8 -0
- package/dist/help/tokens/stdin.examples.pwsh.md +8 -0
- package/dist/help/tokens/stdin.examples.with-qr.bash.md +12 -0
- package/dist/help/tokens/stdin.examples.with-qr.pwsh.md +12 -0
- package/dist/help/topics/dsl.md +4 -3
- package/dist/help/topics/file.move.md +44 -0
- package/dist/help/topics/file.rename.md +33 -0
- package/dist/help/topics/inspect.code.md +5 -5
- package/dist/help/topics/inspect.deps.md +7 -7
- package/dist/help/topics/inspect.file.md +2 -1
- package/dist/help/topics/inspect.graph.md +3 -3
- package/dist/help/topics/inspect.md +5 -5
- package/dist/help/topics/mutation.md +23 -13
- package/dist/help/topics/patterns.md +1 -5
- package/dist/help/topics/qr.md +7 -22
- package/dist/help/topics/quick-map.md +1 -0
- package/dist/help/topics/recipe.file-layout.md +13 -0
- package/dist/help/topics/rg.md +20 -0
- package/dist/help/topics/selectors.md +3 -2
- package/dist/help/topics/session.md +1 -1
- package/dist/host/capabilities.js +1 -0
- package/dist/ide-launch/common.cjs +162 -162
- package/dist/managed-host/extension-vsix-resolver.js +1 -1
- package/dist/managed-host/manage-serve-web-host.cjs +141 -141
- package/dist/managed-host/serve-web-autostart.js +1 -1
- package/dist/managed-host/serve-web-host.cjs +1781 -1570
- package/dist/payloads/read-stdin-json.js +1 -1
- package/dist/rg-wrapper/core.js +6 -0
- package/dist/rg-wrapper/options.js +1 -0
- package/dist/rtk-wrapper/core.js +2 -0
- package/dist/runtime/input-source.js +1 -1
- package/dist/runtime/run-command.js +1 -1
- package/dist/selectors/parse-entities.js +1 -1
- package/dist/session/daemon-state.js +2 -0
- package/dist/session/server.js +7 -8
- package/dist/shared/operations.js +1 -1
- package/dist/shared/protocol.js +1 -1
- package/dist/shared/routes.js +1 -1
- package/dist/shared/stdin-examples.js +1 -3
- package/dist/shared/types.js +1 -1
- package/dist/tool-runtime/runtime-tools.js +1 -0
- package/dist/workers/control-plane/aib-control-plane-worker.cjs +80 -0
- package/dist/workers/control-plane/client-config.default.json +3 -0
- package/dist/workers/product-storage.js +1 -0
- package/dist/workers/registry.js +1 -0
- package/extension/vscode-refactor-bridge-extension.vsix +0 -0
- package/package.json +6 -4
- package/runtimes/launcher/linux-x64/aib +0 -0
- package/runtimes/launcher/win-x64/aib.exe +0 -0
- package/runtimes/tools/rg/darwin-arm64/rg +0 -0
- package/runtimes/tools/rg/darwin-x64/rg +0 -0
- package/runtimes/tools/rg/linux-arm64/rg +0 -0
- package/runtimes/tools/rg/linux-x64/rg +0 -0
- package/runtimes/tools/rg/manifest.json +36 -0
- package/runtimes/tools/rg/win32-x64/rg.exe +0 -0
- package/runtimes/tools/rtk/darwin-arm64/rtk +0 -0
- package/runtimes/tools/rtk/darwin-x64/rtk +0 -0
- package/runtimes/tools/rtk/linux-arm64/rtk +0 -0
- package/runtimes/tools/rtk/linux-x64/rtk +0 -0
- package/runtimes/tools/rtk/manifest.json +36 -0
- package/runtimes/tools/rtk/win32-x64/rtk.exe +0 -0
- package/dist/help/json/docs/basics.md +0 -15
- package/dist/help/json/docs/config-setup.aliases.md +0 -56
- package/dist/help/json/docs/config-setup.excludes.md +0 -45
- package/dist/help/json/docs/config-setup.import-normalize.md +0 -86
- package/dist/help/json/docs/config-setup.import-rules.md +0 -96
- package/dist/help/json/docs/config-setup.tsconfigs.md +0 -33
- package/dist/help/json/docs/dsl.md +0 -25
- package/dist/help/json/docs/first-setup.md +0 -292
- package/dist/help/json/docs/help-format.md +0 -9
- package/dist/help/json/docs/help-protocol.md +0 -26
- package/dist/help/json/docs/imports.normalize.md +0 -47
- package/dist/help/json/docs/inspect.code.md +0 -41
- package/dist/help/json/docs/inspect.cycles.md +0 -38
- package/dist/help/json/docs/inspect.deps.md +0 -46
- package/dist/help/json/docs/inspect.duplicates.md +0 -65
- package/dist/help/json/docs/inspect.exports.md +0 -40
- package/dist/help/json/docs/inspect.file.md +0 -38
- package/dist/help/json/docs/inspect.graph.md +0 -139
- package/dist/help/json/docs/inspect.imports.md +0 -15
- package/dist/help/json/docs/inspect.md +0 -88
- package/dist/help/json/docs/inspect.members.md +0 -32
- package/dist/help/json/docs/inspect.tree.md +0 -32
- package/dist/help/json/docs/inspect.usages.md +0 -61
- package/dist/help/json/docs/modulePlan.md +0 -73
- package/dist/help/json/docs/move.md +0 -56
- package/dist/help/json/docs/mutation.md +0 -65
- package/dist/help/json/docs/patterns.md +0 -76
- package/dist/help/json/docs/prefs.md +0 -40
- package/dist/help/json/docs/qr.md +0 -37
- package/dist/help/json/docs/quick-map.md +0 -30
- package/dist/help/json/docs/refactor.batch.md +0 -72
- package/dist/help/json/docs/rename.md +0 -47
- package/dist/help/json/docs/reveal.md +0 -30
- package/dist/help/json/docs/selectors.md +0 -23
- package/dist/help/json/docs/session.md +0 -77
- package/dist/help/json/docs/view.md +0 -30
- package/dist/help/json/snippets/agents.md +0 -14
- package/dist/help/json/topics/basics.md +0 -13
- package/dist/help/json/topics/config-setup.aliases.md +0 -54
- package/dist/help/json/topics/config-setup.excludes.md +0 -43
- package/dist/help/json/topics/config-setup.import-normalize.md +0 -84
- package/dist/help/json/topics/config-setup.import-rules.md +0 -94
- package/dist/help/json/topics/config-setup.tsconfigs.md +0 -31
- package/dist/help/json/topics/dsl.md +0 -23
- package/dist/help/json/topics/first-setup.md +0 -290
- package/dist/help/json/topics/help-format.md +0 -7
- package/dist/help/json/topics/help-protocol.md +0 -24
- package/dist/help/json/topics/imports.normalize.md +0 -45
- package/dist/help/json/topics/inspect.code.md +0 -39
- package/dist/help/json/topics/inspect.cycles.md +0 -36
- package/dist/help/json/topics/inspect.deps.md +0 -44
- package/dist/help/json/topics/inspect.duplicates.md +0 -37
- package/dist/help/json/topics/inspect.exports.md +0 -38
- package/dist/help/json/topics/inspect.file.md +0 -36
- package/dist/help/json/topics/inspect.graph.md +0 -137
- package/dist/help/json/topics/inspect.imports.md +0 -13
- package/dist/help/json/topics/inspect.md +0 -86
- package/dist/help/json/topics/inspect.members.md +0 -30
- package/dist/help/json/topics/inspect.tree.md +0 -22
- package/dist/help/json/topics/inspect.usages.md +0 -59
- package/dist/help/json/topics/modulePlan.md +0 -60
- package/dist/help/json/topics/move.md +0 -46
- package/dist/help/json/topics/mutation.md +0 -63
- package/dist/help/json/topics/patterns.md +0 -74
- package/dist/help/json/topics/prefs.md +0 -38
- package/dist/help/json/topics/qr.md +0 -35
- package/dist/help/json/topics/quick-map.md +0 -28
- package/dist/help/json/topics/refactor.batch.md +0 -61
- package/dist/help/json/topics/rename.md +0 -42
- package/dist/help/json/topics/reveal.md +0 -28
- package/dist/help/json/topics/selectors.md +0 -21
- package/dist/help/json/topics/session.md +0 -59
- package/dist/help/json/topics/view.md +0 -28
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var oe=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]})),ae=exports&&exports.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),J=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"&&oe(r,t,n[o]);return ae(r,t),r}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.runRefactorBatch=de,exports.readCachedRefactorBatchExecution=he;const G=J(require("node:fs")),M=J(require("node:path")),A=require("zod"),ie=require("../client/http-client"),w=require("../config/env-vars"),se=require("../config/product-storage"),ce=require("../shared/routes"),ue=require("../shared/protocol"),P=require("../shared/agent-text"),le=require("../shared/errors"),fe=require("./refactor-batch-builder"),
|
|
2
|
-
`)}function we(e,t,r,n,o){const a=(0,x.readRefactorBatchExecutionStatus)(e,t),u=Math.max(0,n-o),s={operation:"execution.status",executionId:a.executionId,status:a.status,phase:a.phase,summary:F(a),progress:`${a.completedRows}/${a.rowCount}`,filesWritten:a.filesWritten,updatedAt:a.updatedAt,estimatedRemainingMs:u};return(0,P.attachAgentText)(s,ge(r,a,u))}function ge(e,t,r){return[`${e} ${t.executionId}`,F(t),"applying mutation"
|
|
3
|
-
`)}function
|
|
4
|
-
`)}function F(e){return e.status==="completed"?`completed, ${e.completedRows}/${e.rowCount} rows, ${e.filesWritten.length} files written`:e.status==="failed"?`failed, ${e.completedRows}/${e.rowCount} rows, ${e.failedRows} failed`:`in progress, ${e.completedRows}/${e.rowCount} rows`}function
|
|
1
|
+
"use strict";var oe=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]})),ae=exports&&exports.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),J=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"&&oe(r,t,n[o]);return ae(r,t),r}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.runRefactorBatch=de,exports.readCachedRefactorBatchExecution=he;const G=J(require("node:fs")),M=J(require("node:path")),A=require("zod"),ie=require("../client/http-client"),w=require("../config/env-vars"),se=require("../config/product-storage"),ce=require("../shared/routes"),ue=require("../shared/protocol"),P=require("../shared/agent-text"),le=require("../shared/errors"),fe=require("./refactor-batch-builder"),C=require("./refactor-batch-preview-cache"),x=require("./refactor-batch-execution-cache"),K=require("./mutation-execution-cache"),j=require("./shared"),q=A.z.object({operations:A.z.array(A.z.unknown()).min(1).optional(),requests:A.z.array(A.z.unknown()).min(1).optional(),continueOnError:A.z.boolean().optional(),execution:A.z.literal("sequential").optional()}).passthrough().refine(e=>Array.isArray(e.operations)||Array.isArray(e.requests),{message:"refactor batch expects operations[] or requests[]."});async function de(e,t,r={},n="preview",o={}){if(n==="apply"&&o.previewId){const u=L();if(u>0){const s=U(e,o.previewId),h=q.parse(z(s.normalizedPayload,!0));return X(e,h,r,"apply",{...o,previewId:o.previewId},u)}return pe(e,o.previewId,r,o)}const a=q.parse(t);return(n==="execute"||n==="apply")&&L()>0?X(e,a,r,n,o,L()):N(e,a,r,n,o)}async function pe(e,t,r,n){const o=U(e,t),a=q.parse(z(o.normalizedPayload,!0));return N(e,a,r,"apply",{...n,previewId:t})}function U(e,t){const r=(0,C.readRefactorBatchPreviewRecord)(e,t),n=r.files.find(o=>G.existsSync(o.file)!==o.existed||(0,C.hashFileIfExists)(o.file)!==o.hash);if(n)throw new le.CliError("REFACTOR_BATCH_PREVIEW_FILES_CHANGED","Touched files changed after refactor batch preview. Rerun preview.",{previewId:t,file:k(e,n.file)});return r}async function X(e,t,r,n,o,a){const u=(0,x.buildRefactorBatchExecutionId)(),s=`refactor.batch.${n}`,h=Ae(t),p=(0,x.createRefactorBatchExecutionStatus)(e,u,s,Q(t));(0,x.writeRefactorBatchExecutionStatus)(e,p);const f=Date.now(),y=$e(),R=be(()=>(0,se.runWithProductStorageOverride)(y[w.CLI_ENV.productStorageDir],()=>Ce(y,async()=>{try{const l=await N(e,t,r,n,o),g=Y(l);return p.status=l.ok===!1?"failed":"completed",p.phase="completed",p.completedRows=g.filter(i=>i.ok!==!1).length,p.failedRows=g.filter(i=>i.ok===!1).length,p.filesWritten=xe(l),p.result=l,l.ok===!1&&(p.error=c(l.code)??"REFACTOR_BATCH_FAILED"),(0,x.writeRefactorBatchExecutionStatus)(e,p),l}catch(l){throw p.status="failed",p.phase="completed",p.error=l instanceof Error?l.message:String(l),(0,x.writeRefactorBatchExecutionStatus)(e,p),l}}))),m=await _e(R,a);return m.status==="result"?m.result:(R.catch(()=>{}),we(e,u,s,h,Date.now()-f))}async function N(e,t,r,n,o){await Be();const a=await(0,j.resolveCompatibleTargetInstance)(e,ue.CLI_COMMAND_IDS.refactorBatch,r),u=await(0,j.fetchEffectiveConfig)(a.entry,r),s=(0,fe.buildExtensionRefactorBatchPayload)(t,u),h=await(0,ie.postJson)(a.entry,ce.EXTENSION_ROUTES.refactorBatch,s.payload,(0,j.extensionRequestOptions)(r)),p=me(e,h),f={ok:p.batchOk===!0,...p.batchOk===!0?{}:{code:"REFACTOR_BATCH_FAILED"},operation:`refactor.batch.${n}`,builder:s.summary,response:p};if(n==="preview"&&f.ok!==!1){const R=z(t,!1),m=(0,C.buildRefactorBatchPreviewId)(R),l=Ie(e,s.payload),g=(0,C.buildRefactorBatchPreviewHash)(R,l,f);(0,C.writeRefactorBatchPreviewRecord)(e,{previewId:m,previewHash:g,createdAt:new Date().toISOString(),cwd:M.resolve(e),normalizedPayload:R,files:l,builder:s.summary,previewResult:f}),f.previewId=m,f.next=`aib refactor batch apply ${m}`}const y={...o,...typeof f.previewId=="string"?{previewId:f.previewId}:{},...typeof f.next=="string"?{next:f.next}:{}};return(0,P.attachAgentText)(f,Re(e,s.summary,p,n,y))}function he(e,t){const r=(0,x.readRefactorBatchExecutionStatus)(e,t);if((r.status==="completed"||r.status==="failed")&&r.result)return r.result;const n={operation:"execution.status",executionId:r.executionId,status:r.status,phase:r.phase,summary:F(r),progress:`${r.completedRows}/${r.rowCount}`,filesWritten:r.filesWritten,updatedAt:r.updatedAt,...r.error?{error:r.error}:{}};return(0,P.attachAgentText)(n,ve(r))}function me(e,t){const r=Array.isArray(t.rows)?t.rows.map(n=>ye(e,n)):[];return{ok:t.ok===!0,operation:c(t.operation),contract:t.contract??null,execution:c(t.execution),continueOnError:t.continueOnError===!0,batchOk:t.batchOk===!0,batchStatus:c(t.batchStatus),requestedOperationCount:v(t.requestedOperationCount),plannedOperationCount:v(t.plannedOperationCount),attemptedRowCount:v(t.attemptedRowCount),rowCount:v(t.rowCount),passedRowCount:v(t.passedRowCount),failedRowCount:v(t.failedRowCount),skippedRowCount:v(t.skippedRowCount),guidance:t.guidance??null,rows:r,...t._metrics?{_metrics:t._metrics}:{}}}function ye(e,t){if(!t||typeof t!="object"||Array.isArray(t))return{ok:!1,error:"Invalid batch row shape."};const r=t;return r.skipped===!0?T({index:v(r.index),id:c(r.id),kind:c(r.kind),planned:r.planned===!0,attempted:!1,outcome:c(r.outcome),skipped:!0,skipReason:c(r.skipReason),error:c(r.error)}):T({index:v(r.index),id:c(r.id),kind:c(r.kind),planned:r.planned===!0,attempted:r.attempted===!0,outcome:c(r.outcome),ok:r.ok===!0,statusCode:v(r.statusCode),durationMs:v(r.durationMs),applied:r.applied===!0,touchedFiles:E(r.touchedFiles).map(n=>k(e,n)),savedFiles:E(r.savedFiles).map(n=>k(e,n)),error:c(r.error),response:Le(r.response)})}function Re(e,t,r,n,o={}){const a=Array.isArray(r.rows)?r.rows.filter(l=>!!l&&typeof l=="object"&&!Array.isArray(l)):[],u=a.filter(l=>l.outcome==="applied").length,s=a.filter(l=>l.outcome==="validated").length,h=typeof r.failedRowCount=="number"?r.failedRowCount:a.filter(l=>l.ok===!1).length,p=n==="execute"||n==="apply"||n==="validate"?n:u>0?"apply":"preview",f=[];o.routedFrom==="move.toFile"&&(f.push("move.toFile routed to refactor.batch"),f.push(""));const y=Me(t,e),R=Fe(t);if(f.push(Ee(p,o)),f.push(Se(p,{movePlan:y,renamePlan:R},a,u,s,h)),(y||R)&&a.length>0)ke(f,{movePlan:y,renamePlan:R},a);else for(const l of a){const g=c(l.id)??`row ${v(l.index)??"?"}`,i=c(l.kind)??"operation",b=c(l.outcome)??(l.ok===!0?"ok":"failed");f.push(`${Pe(i)} ${je(g)} ${b}`)}const m=D(a.flatMap(l=>E(l.savedFiles)));return m.length>0&&(f.push("filesWritten:"),f.push(...m)),o.next&&f.push(`next: ${o.next}`),f.join(`
|
|
2
|
+
`)}function we(e,t,r,n,o){const a=(0,x.readRefactorBatchExecutionStatus)(e,t),u=Math.max(0,n-o),s={operation:"execution.status",executionId:a.executionId,status:a.status,phase:a.phase,summary:F(a),progress:`${a.completedRows}/${a.rowCount}`,filesWritten:a.filesWritten,updatedAt:a.updatedAt,estimatedRemainingMs:u};return(0,P.attachAgentText)(s,ge(r,a,u))}function ge(e,t,r){return[`${e} ${t.executionId}`,F(t),"applying mutation",r>0?`estimated remaining: ${Ne(Math.max(r,5e3))}`:"estimated remaining: check status again soon"].join(`
|
|
3
|
+
`)}function ve(e){const t=[`${e.operation} ${e.executionId}`,F(e)];return e.status==="running"&&t.push("applying mutation"),e.error&&t.push(e.error),t.join(`
|
|
4
|
+
`)}function F(e){return e.status==="completed"?`completed, ${e.completedRows}/${e.rowCount} rows, ${e.filesWritten.length} files written`:e.status==="failed"?`failed, ${e.completedRows}/${e.rowCount} rows, ${e.failedRows} failed`:`in progress, ${e.completedRows}/${e.rowCount} rows`}function be(e){return new Promise((t,r)=>{setImmediate(()=>{e().then(t,r)})})}async function _e(e,t){return(0,K.waitForMutationDeadline)(e,t)}function L(){return(0,K.readMutationSyncWaitMs)(process.env[w.CLI_ENV.refactorBatchSyncWaitMs],12e4)}function Ae(e){return 12e3+Q(e)*2e3}function Q(e){const t=Array.isArray(e.operations)?e.operations:Array.isArray(e.requests)?e.requests:[];let r=0;for(const n of t){if(!_(n)){r+=1;continue}const o=Array.isArray(n.entities)?n.entities:Array.isArray(n.symbols)?n.symbols:[],a=Array.isArray(n.renames)?n.renames:[];r+=Math.max(1,o.length,a.length)}return Math.max(1,r)}function xe(e){const t=Y(e);return D(t.flatMap(r=>E(r.savedFiles)))}function Y(e){const t=_(e.response)?e.response:null;return Array.isArray(t?.rows)?t.rows.filter(_):[]}async function Be(){const e=process.env[w.CLI_ENV.testRefactorBatchDelayMs];if(!e)return;const t=Number.parseInt(e,10);!Number.isFinite(t)||t<=0||await new Promise(r=>setTimeout(r,Math.min(t,12e4)))}function $e(){const e=[w.CLI_ENV.productStorageDir,w.CLI_ENV.trace,w.CLI_ENV.traceDir,w.CLI_ENV.metrics,w.CLI_ENV.metricsDir,w.CLI_ENV.metricsTag,w.CLI_ENV.mutationImpactMetrics,w.CLI_ENV.mutationImpactStream,w.CLI_ENV.testMoveToFileFailEntity,w.CLI_ENV.testRefactorBatchDelayMs],t={};for(const r of e)t[r]=process.env[r];return t}async function Ce(e,t){const r={};for(const[n,o]of Object.entries(e))r[n]=process.env[n],o===void 0?delete process.env[n]:process.env[n]=o;try{return await t()}finally{for(const[n,o]of Object.entries(r))o===void 0?delete process.env[n]:process.env[n]=o}}function Ie(e,t){const r=Array.isArray(t.operations)?t.operations.filter(_):[],n=new Set;for(const o of r){const a=_(o.body)?o.body:{},u=c(a.sourceFile),s=c(a.targetFile);u&&n.add(Z(e,u)),s&&n.add(Z(e,s))}return Array.from(n).sort((o,a)=>o.localeCompare(a)).map(o=>({file:o,existed:G.existsSync(o),hash:(0,C.hashFileIfExists)(o)}))}function Z(e,t){return M.normalize(M.isAbsolute(t)?t:M.resolve(e,t))}function Ee(e,t){return e==="preview"&&t.previewId?`refactor.batch.preview ${t.previewId}`:`refactor.batch.${e}`}function Se(e,t,r,n,o,a){const u=t.movePlan?.rows??[],s=t.renamePlan?.rows??[];if(u.length===0&&s.length===0)return`${r.length} rows, ${n>0?`${n} applied`:`${o} validated`}${a>0?`, ${a} failed`:""}`;const h=new Map(r.map(d=>[c(d.id),d]).filter(d=>!!d[0])),p=r.find(d=>d.ok===!1||d.outcome==="failed")??null,f=p?c(p.id):null,y=f?u.some(d=>d.id===f):!1,R=f?s.some(d=>d.id===f):!1,m=new Set(r.filter(d=>d.outcome==="applied").map(d=>c(d.id)).filter(d=>!!d)),l=new Set(r.filter(d=>d.outcome==="validated").map(d=>c(d.id)).filter(d=>!!d)),g=new Set(u.map(d=>d.targetFile)).size,i=D(r.flatMap(d=>E(d.savedFiles))).length,b=u.filter(d=>m.has(d.id)||l.has(d.id)).length,B=s.filter(d=>m.has(d.id)||l.has(d.id)).length;if(p){const d=[...s,...u],V=f?d.findIndex($=>$.id===f):-1,H=d.filter(($,ne)=>!m.has($.id)&&!l.has($.id)&&$.id!==f&&(V<0||ne>V||!h.has($.id))).length,I=[];return B>0&&I.push(`${B} ${B===1?"rename":"renames"} applied`),b>0&&I.push(`${b} ${b===1?"symbol":"symbols"} moved`),I.push(y?"1 symbol failed":R?"1 rename failed":"1 failed"),H>0&&I.push(`${H} not run`),I.join(", ")}const S=[];s.length>0&&S.push(`${s.length} ${s.length===1?"rename":"renames"}`),u.length>0&&(S.push(`${u.length} ${u.length===1?"symbol":"symbols"}`),S.push(`${g} ${g===1?"target":"targets"}`));const O=S.join(", ");if(e==="preview"||e==="validate")return`${O} ready`;const W=s.length>0?"applied":"moved";return i>0?`${O} ${W}; ${i} ${i===1?"file":"files"} written`:`${O} ${W}`}function Me(e,t){const n=(Array.isArray(e.rows)?e.rows.filter(_):[]).filter(a=>c(a.op)==="move");if(n.length===0)return null;const o=[];for(const a of n){const u=Array.isArray(a.builtRows)?a.builtRows.filter(_):[];for(const s of u){const h=c(s.id),p=c(s.entity),f=c(s.targetFile);h&&p&&f&&o.push({id:h,entity:p,targetFile:k(t,f)})}}return o.length>0?{rows:o}:null}function Fe(e){const r=(Array.isArray(e.rows)?e.rows.filter(_):[]).filter(o=>c(o.op)==="rename");if(r.length===0)return null;const n=[];for(const o of r){const a=Array.isArray(o.builtRows)?o.builtRows.filter(_):[];for(const u of a){const s=c(u.id),h=c(u.entity),p=c(u.newName);s&&h&&p&&n.push({id:s,entity:h,newName:p})}}return n.length>0?{rows:n}:null}function ke(e,t,r){const n=t.movePlan?.rows??[],o=t.renamePlan?.rows??[],a=new Map(r.map(i=>[c(i.id),i]).filter(i=>!!i[0])),u=new Set(r.filter(i=>i.outcome==="applied").map(i=>c(i.id)).filter(i=>!!i)),s=r.find(i=>i.ok===!1||i.outcome==="failed")??null,h=s?c(s.id):null,p=h?n.find(i=>i.id===h)??null:null,f=h?o.find(i=>i.id===h)??null:null,y=[...o,...n];if(s===null&&y.every(i=>u.has(i.id)||a.get(i.id)?.outcome==="validated")){ee(e,o,a,u),te(e,n,a,u);return}if(ee(e,o.filter(i=>u.has(i.id)),a,u),te(e,n.filter(i=>u.has(i.id)),a,u),s){e.push("failed:"),p?e.push(`${p.entity} -> ${p.targetFile}`):f&&e.push(`${f.entity} -> ${f.newName}`);const i=_(s.response)?s.response:null,b=c(i?.code)??c(i?.errorCode)??c(s.statusCode),B=qe(c(s.error)??(i?c(i.error):null));b&&e.push(`code: ${b}`),B&&e.push(B)}const m=h??null,l=m?y.findIndex(i=>i.id===m):-1,g=y.filter((i,b)=>!u.has(i.id)&&i.id!==h&&(l<0||b>l||!a.has(i.id)));g.length>0&&(e.push("not run:"),e.push(re(g.map(i=>i.entity),15)))}function ee(e,t,r,n){const o=t.filter(a=>n.has(a.id)||r.get(a.id)?.outcome==="validated");if(o.length!==0){e.push("renames:");for(const a of o)e.push(`${a.entity} -> ${a.newName}`)}}function te(e,t,r,n){const o=t.filter(a=>n.has(a.id)||r.get(a.id)?.outcome==="validated");o.length!==0&&(e.push("moves:"),Oe(e,o))}function Oe(e,t){const r=new Map;for(const n of t){const o=r.get(n.targetFile)??[];o.push(n.entity),r.set(n.targetFile,o)}for(const[n,o]of r)e.push(`${n}: ${re(o,15)}`)}function Pe(e){return e==="moveRefactor"?"move":e==="renameSymbol"?"rename":e}function je(e){const t=e.indexOf(":");return t>=0?e.slice(t+1):e}function D(e){return Array.from(new Set(e))}function re(e,t){const r=e.slice(0,t),n=e.length-r.length;return n>0?`${r.join(", ")}, + ${n} more`:r.join(", ")}function qe(e){return e?.replace(/^TypeScript refactor failed: Debug Failure\. False expression: /,"")??null}function Ne(e){const t=Math.max(1,Math.round(e/1e3));return t<60?`~${t} sec`:`~${Math.max(1,Math.round(t/60))} min`}function _(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function k(e,t){const r=t.replace(/\\/g,"/"),n=e.replace(/\\/g,"/").replace(/\/$/,""),o=r.toLowerCase(),a=n.toLowerCase();return o.startsWith(`${a}/`)?r.slice(n.length+1):r}function Le(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;return T({ok:t.ok===!0,code:c(t.code),errorCode:c(t.errorCode),error:c(t.error),hint:c(t.hint),execute:typeof t.execute=="boolean"?t.execute:null,applied:typeof t.applied=="boolean"?t.applied:null})}function c(e){return typeof e=="string"?e:null}function v(e){return typeof e=="number"?e:null}function E(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function T(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t==null?!1:!(Array.isArray(t)&&t.length===0)))}function z(e,t){const r=Array.isArray(e.operations)?e.operations:Array.isArray(e.requests)?e.requests:null;if(!r)return{...e,execute:t};const{operations:n,...o}=e;return{...o,requests:r.map(a=>a&&typeof a=="object"&&!Array.isArray(a)?{...a,execute:t}:a),execute:t}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ie=exports&&exports.__createBinding||(Object.create?(function(e,n,t,
|
|
2
|
-
`)}function be(e){const n=[`${e.operation} ${e.executionId}`,k(e)];return e.status==="running"&&
|
|
3
|
-
`)}function k(e){return e.status==="completed"?`completed, ${e.completedRows}/${e.rowCount} renames, ${e.filesWritten.length} files written`:e.status==="failed"?`failed, ${e.completedRows}/${e.rowCount} renames, ${e.failedRows} failed`:`in progress, ${e.completedRows}/${e.rowCount} renames`}function
|
|
4
|
-
`)}function
|
|
1
|
+
"use strict";var ie=exports&&exports.__createBinding||(Object.create?(function(e,n,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(n,t);(!i||("get"in i?!n.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return n[t]}}),Object.defineProperty(e,r,i)}):(function(e,n,t,r){r===void 0&&(r=t),e[r]=n[t]})),oe=exports&&exports.__setModuleDefault||(Object.create?(function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}):function(e,n){e.default=n}),T=exports&&exports.__importStar||(function(){var e=function(n){return e=Object.getOwnPropertyNames||function(t){var r=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[r.length]=i);return r},e(n)};return function(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var r=e(n),i=0;i<r.length;i++)r[i]!=="default"&&ie(t,n,r[i]);return oe(t,n),t}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.runRenameEntities=de,exports.readCachedRenameExecution=ge;const N=T(require("node:fs")),d=T(require("node:path")),R=require("zod"),se=require("../client/http-client"),v=require("../config/env-vars"),ae=require("../config/product-storage"),ce=require("../shared/routes"),le=require("../shared/protocol"),E=require("../shared/agent-text"),I=require("../shared/errors"),_=require("./shared"),ue=require("../selectors/parse-entities"),fe=require("./entity-resolution"),me=require("../shared/types"),$=require("./rename-preview-cache"),x=require("./rename-execution-cache"),j=require("./mutation-execution-cache"),pe=require("./inspect-symbol-query"),V=require("./rename-input"),M=require("../metrics/central-metrics"),K=R.z.object({sourceFile:R.z.string().min(1).optional(),file:R.z.string().min(1).optional(),renames:V.RenamesInputSchema,execute:R.z.boolean().optional()}).superRefine((e,n)=>{!e.sourceFile&&!e.file&&n.addIssue({code:"custom",path:["sourceFile"],message:"rename expects sourceFile or file."})}).transform(e=>({sourceFile:e.sourceFile??e.file??"",renames:(0,V.normalizeRenamesInput)(e.renames),...e.execute!==void 0?{execute:e.execute}:{}}));async function de(e,n,t={},r=[]){if(r.includes("--help"))return ot();const i=ne(r,"--preview")??ne(r,"--preview-id");if(i){const s=W();return s>0?he(e,i,t,s):ye(e,i,t)}const o=K.parse(n);return o.execute===!0&&W()>0?U(e,o,t,"execute",W()):P(e,o,t)}async function ye(e,n,t){const r=z(e,n),i=B(r),o=await P(e,i,t,{previewId:n});return H(o,r)}async function he(e,n,t,r){const i=z(e,n),o=B(i);return U(e,o,t,"apply",r,{previewId:n,record:i})}function z(e,n){const t=(0,$.readRenamePreviewRecord)(e,n);if((0,$.hashFile)(t.sourceFile)!==t.sourceHash)throw new I.CliError("RENAME_PREVIEW_SOURCE_CHANGED","Source file changed after rename preview. Rerun rename preview.",{previewId:n,sourceFile:S(e,t.sourceFile)});return t}function B(e){return K.parse({...e.normalizedPayload,execute:!0})}function H(e,n){const t=A(e.api)&&e.api.status==="preserved-via-alias",r=e.ok===!1?"Fix the rename request and rerun preview.":t||e.api!==void 0?"If public API rename is intended, update consumers explicitly.":null,i=A(n.previewResult)?n.previewResult.api:void 0,o={...e,operation:"rename.apply",...i!==void 0?{api:i}:{},...r?{next:r}:{}};return(0,E.attachAgentText)(o,G(o))}async function U(e,n,t,r,i,o){const s=(0,x.buildRenameExecutionId)(),c=`rename.${r}`,l=Fe(n),a=(0,x.createRenameExecutionStatus)(e,s,c,J(n));(0,x.writeRenameExecutionStatus)(e,a);const p=Date.now(),h=$e(),m=we(()=>(0,ae.runWithProductStorageOverride)(h[v.CLI_ENV.productStorageDir],()=>_e(h,async()=>{try{const u=o?H(await P(e,n,t,{previewId:o.previewId}),o.record):await P(e,n,t),f=Se(u);return a.status=u.ok===!1?"failed":"completed",a.phase="completed",a.completedRows=f.filter(g=>g.ok!==!1).length,a.failedRows=f.filter(g=>g.ok===!1).length,a.filesWritten=xe(u),a.result=u,u.ok===!1&&(a.error=rt(u.code)??"RENAME_FAILED"),(0,x.writeRenameExecutionStatus)(e,a),u}catch(u){throw a.status="failed",a.phase="completed",a.error=u instanceof Error?u.message:String(u),(0,x.writeRenameExecutionStatus)(e,a),u}}))),y=await(0,j.waitForMutationDeadline)(m,i);return y.status==="result"?y.result:(m.catch(()=>{}),ve(e,s,c,l,Date.now()-p))}async function P(e,n,t,r){await Ne();const i=await(0,_.resolveCompatibleTargetInstance)(e,le.CLI_COMMAND_IDS.renameEntities,t),o=await(0,_.fetchEffectiveConfig)(i.entry,t),s=Ie(e,n.sourceFile),c=n.execute===!0,l=(0,ue.parseEntitySelectors)(n.renames.map(f=>f.entity),o),a=new Map;for(const f of n.renames)a.set(f.entity.trim(),f);await(0,fe.ensureSelectorsResolvable)(i.entry,s,l,o,(0,_.extensionRequestOptions)(t));const p=[];for(const f of l){const g=a.get(f.raw);if(!g)throw new Error(`Rename operation not found for selector: ${f.raw}`);const F=(0,M.startCentralMetricSpan)({kind:"mutation.entity",operation:c?"rename.execute":"rename.preview",cwd:d.resolve(e),sourceFile:S(e,s),entity:f.raw,newName:g.newName,totalEntities:l.length});try{const b=await(0,se.postJson)(i.entry,ce.EXTENSION_ROUTES.renameSymbol,{sourceFile:s,symbolName:f.symbolName,symbolKind:f.symbolKind,...f.parentName?{parentName:f.parentName}:{},newName:g.newName,execute:c,impactMetrics:(0,M.mutationImpactMetricsEnabled)()},(0,_.extensionRequestOptions)(t)),O=Pe(e,o,f,g.newName,b);p.push(O),F.end(Re(b,O,l.length))}catch(b){p.push(Me(o,f,g.newName,b)),F.end({ok:!1,code:b instanceof I.CliError?b.code:"RENAME_FAILED",error:b instanceof Error?b.message:String(b),totalEntities:l.length})}}const h=p.every(f=>f.ok!==!1),m=nt(s,n.renames,l,c),y=await Ze(i.entry,s,l,n.renames,p,o,e,t),u=Ee(e,s,c,l,p,h,y,i.entry.workspaceFolders);if(!c&&h){const f=(0,$.buildRenamePreviewId)(m),g=(0,$.hashFile)(s),F=(0,$.buildRenamePreviewHash)(m,g,u);(0,$.writeRenamePreviewRecord)(e,{previewId:f,previewHash:F,createdAt:new Date().toISOString(),cwd:d.resolve(e),sourceFile:s,sourceHash:g,normalizedPayload:m,previewResult:u}),u.previewId=f,u.next=`aib rename apply ${f}`}return Ce(e,u),(0,E.attachAgentText)(u,G(u))}function ge(e,n){const t=(0,x.readRenameExecutionStatus)(e,n);if((t.status==="completed"||t.status==="failed")&&t.result)return t.result;const r={operation:"execution.status",executionId:t.executionId,status:t.status,phase:t.phase,summary:k(t),progress:`${t.completedRows}/${t.rowCount}`,filesWritten:t.filesWritten,updatedAt:t.updatedAt,...t.error?{error:t.error}:{}};return(0,E.attachAgentText)(r,be(t))}function ve(e,n,t,r,i){const o=(0,x.readRenameExecutionStatus)(e,n),s=Math.max(0,r-i),c={operation:"execution.status",executionId:o.executionId,status:o.status,phase:o.phase,summary:k(o),progress:`${o.completedRows}/${o.rowCount}`,filesWritten:o.filesWritten,updatedAt:o.updatedAt,estimatedRemainingMs:s};return(0,E.attachAgentText)(c,Ae(t,o,s))}function Ae(e,n,t){return[`${e} ${n.executionId}`,k(n),"applying mutation",t>0?`estimated remaining: ${it(Math.max(t,5e3))}`:"estimated remaining: check status again soon"].join(`
|
|
2
|
+
`)}function be(e){const n=[`${e.operation} ${e.executionId}`,k(e)];return e.status==="running"&&n.push("applying mutation"),e.error&&n.push(e.error),n.join(`
|
|
3
|
+
`)}function k(e){return e.status==="completed"?`completed, ${e.completedRows}/${e.rowCount} renames, ${e.filesWritten.length} files written`:e.status==="failed"?`failed, ${e.completedRows}/${e.rowCount} renames, ${e.failedRows} failed`:`in progress, ${e.completedRows}/${e.rowCount} renames`}function we(e){return new Promise((n,t)=>{setImmediate(()=>{e().then(n,t)})})}function W(){return(0,j.readMutationSyncWaitMs)(process.env[v.CLI_ENV.renameSyncWaitMs],12e4)}function Fe(e){return 12e3+J(e)*2e3}function J(e){return Math.max(1,e.renames.length)}function xe(e){return(Array.isArray(e.filesWritten)?e.filesWritten:Array.isArray(e.files)?e.files:[]).filter(t=>typeof t=="string"&&!t.startsWith("+"))}function Se(e){const n=Array.isArray(e.renames)?e.renames.map(r=>({ok:typeof r=="string"&&!r.includes("failed")})):e.rename?[{ok:e.ok!==!1}]:[];if(n.length>0)return n;const t=Array.isArray(e.failed)?e.failed.filter(A):[];return t.length>0?t.map(r=>({...r,ok:!1})):[{ok:e.ok!==!1}]}async function Ne(){const e=process.env[v.CLI_ENV.testRenameDelayMs];if(!e)return;const n=Number.parseInt(e,10);!Number.isFinite(n)||n<=0||await new Promise(t=>setTimeout(t,Math.min(n,12e4)))}function $e(){const e=[v.CLI_ENV.productStorageDir,v.CLI_ENV.trace,v.CLI_ENV.traceDir,v.CLI_ENV.metrics,v.CLI_ENV.metricsDir,v.CLI_ENV.metricsTag,v.CLI_ENV.mutationImpactMetrics,v.CLI_ENV.mutationImpactStream,v.CLI_ENV.testRenameDelayMs],n={};for(const t of e)n[t]=process.env[t];return n}async function _e(e,n){const t={};for(const[r,i]of Object.entries(e))t[r]=process.env[r],i===void 0?delete process.env[r]:process.env[r]=i;try{return await n()}finally{for(const[r,i]of Object.entries(t))i===void 0?delete process.env[r]:process.env[r]=i}}function Ce(e,n){(0,M.recordCentralMetric)({kind:"mutation.summary",operation:typeof n.operation=="string"?n.operation:"rename",cwd:d.resolve(e),ok:n.ok!==!1,sourceFile:typeof n.file=="string"?n.file:null,summary:typeof n.summary=="string"?n.summary:null,filesWrittenCount:Array.isArray(n.filesWritten)?n.filesWritten.filter(t=>typeof t=="string"&&!t.startsWith("+")).length:0})}function Re(e,n,t){const r=A(e.renameImpact)?e.renameImpact:{};return{ok:e.ok!==!1,totalEntities:t,editCount:typeof n.editCount=="number"?n.editCount:0,changedFileCount:Array.isArray(n.allFiles)?n.allFiles.length:0,savedFileCount:Array.isArray(n.allSavedFiles)?n.allSavedFiles.length:0,...(0,M.mutationImpactMetricsEnabled)()?{impactCollectionMs:typeof r.impactCollectionMs=="number"?r.impactCollectionMs:null,impact:{locationCount:typeof r.locationCount=="number"?r.locationCount:null,fileCount:typeof r.fileCount=="number"?r.fileCount:null,impactCollectionMs:typeof r.impactCollectionMs=="number"?r.impactCollectionMs:null},changedFiles:Array.isArray(n.allFiles)?n.allFiles:[],savedFiles:Array.isArray(n.allSavedFiles)?n.allSavedFiles:[]}:{},configFilePath:typeof e.configFilePath=="string"?e.configFilePath:null}}function Ee(e,n,t,r,i,o,s,c){const l=i.reduce((u,f)=>u+te(f.editCount),0),a=Qe(i),p=De(i),h=i.map((u,f)=>({oldName:r[f]?.symbolName??(typeof u.oldName=="string"?u.oldName:u.entity),newName:u.newName})),m=Oe(e,c,i,h,a,n)??Te(e,c,a,h);return{...o?{}:{ok:!1},operation:t?"rename.execute":"rename.preview",file:S(e,n),...r.length===1?{rename:q(i[0],!1)}:{renames:i.map(u=>q(u,!0))},summary:t?`${p.length} ${p.length===1?"file":"files"} written, ${l} edits`:r.length===1?`${a.length} ${a.length===1?"file":"files"}, ${l} edits`:`${r.length} symbols, ${a.length} ${a.length===1?"file":"files"}, ${l} edits`,...t?{}:{files:D(a,5)},...t?{filesWritten:D(p,5)}:{},...o?{}:{failed:i.filter(u=>u.ok===!1).map(u=>ke(u))},...m?{api:We(m)}:{},...o?{}:{next:"Fix failed rename rows and rerun preview."}}}function Ie(e,n){const t=n.trim();return d.normalize(d.isAbsolute(t)?t:d.resolve(e,t))}function Me(e,n,t,r){const i=r instanceof I.CliError&&A(r.details)?r.details:{},o=A(i.details)?i.details:{},s=Z(e,o.candidates),c=A(o.sourceConsistency)?Q(o.sourceConsistency):null;return{entity:n.raw,oldName:n.symbolName,acceptedSelector:C(n,e),newName:t,ok:!1,code:r instanceof I.CliError?r.code:"RENAME_FAILED",error:r instanceof Error?r.message:String(r),...c?{source:c}:{},...s.length>0?{candidates:s}:{},next:s.length>0?"Retry with one of the candidate selectors.":"Run inspect file for this source file, then retry with a canonical selector."}}function Pe(e,n,t,r,i){const o=A(i.locationPreview)?i.locationPreview:{},s=Array.isArray(o.locations)?o.locations.filter(A):[],c=tt(e,s),l=Be(s,t.symbolName,r),a=l.length>0?[]:He(e,c,t.symbolName,r,typeof i.sourceFile=="string"?i.sourceFile:null),p=A(i.sourceConsistency)?Q(i.sourceConsistency):null;return i.ok!==!1?{entity:t.raw,oldName:t.symbolName,...typeof i.sourceFile=="string"?{sourceFilePath:i.sourceFile}:{},acceptedSelector:C(t,n),newName:r,ok:!0,editCount:s.length,...typeof i.configFilePath=="string"?{projectConfig:S(e,i.configFilePath)}:{},allFiles:c.map(({file:m,count:y})=>`${m} x${y}`),files:D(c.map(({file:m,count:y})=>`${m} x${y}`),5),...l.length+a.length>0?{apiAliases:[...l,...a]}:{},...p?{source:p}:{},...i.applied!==void 0?{applied:i.applied===!0}:{},...Array.isArray(i.savedFiles)?{allSavedFiles:i.savedFiles.filter(m=>typeof m=="string").map(m=>S(e,m)),savedFiles:D(i.savedFiles.filter(m=>typeof m=="string").map(m=>S(e,m)),5)}:{}}:{entity:t.raw,acceptedSelector:C(t,n),newName:r,ok:!1,code:typeof i.code=="string"?i.code:"RENAME_FAILED",error:typeof i.error=="string"?i.error:"Rename failed.",...p?{source:p}:{},candidates:Z(n,i.candidates),next:"Use one of the candidates or rerun inspect file if the file changed."}}function q(e,n){const t=typeof e.acceptedSelector=="string"?e.acceptedSelector:e.entity,r=e.ok===!1?"failed":`${te(e.editCount)} edits`,i=n?`, ${r}`:"";return`${t} -> ${e.newName}${i}`}function ke(e){const n={rename:q(e,!1),code:typeof e.code=="string"?e.code:"RENAME_FAILED",error:typeof e.error=="string"?e.error:"Rename failed."};for(const t of["source","candidates","next"])e[t]!==void 0&&(n[t]=e[t]);return n}function De(e){const n=new Set;for(const t of e){const r=Array.isArray(t.allSavedFiles)?t.allSavedFiles:t.savedFiles;if(Array.isArray(r))for(const i of r)typeof i=="string"&&!i.startsWith("+")&&n.add(i)}return Array.from(n)}function We(e){const n=typeof e.aliases=="string"?e.aliases:"aliases",t=typeof e.consumers=="string"?e.consumers:"",r=/^(\d+)\s+/.exec(t),i=r?Number(r[1]):0,o=n.startsWith("1 ")?"name":"names";return i>0?`old ${o} preserved by ${n}; ${t} still use old names`:`old ${o} preserved by ${n}`}function G(e){if(e.ok===!1)return null;const n=typeof e.operation=="string"?e.operation:"";if(n!=="rename.preview"&&n!=="rename.execute"&&n!=="rename.apply")return null;const t=[],r=typeof e.previewId=="string"?e.previewId:"";if(t.push(r&&n==="rename.preview"?`${n} ${r}`:n),typeof e.file=="string"&&t.push(e.file),typeof e.rename=="string")t.push(e.rename);else if(Array.isArray(e.renames))for(const i of e.renames)typeof i=="string"&&t.push(qe(i));return typeof e.summary=="string"&&t.push(e.summary),Le(t,Array.isArray(e.filesWritten)?e.filesWritten:e.files),typeof e.api=="string"&&t.push(`api: ${e.api}`),typeof e.next=="string"&&t.push(`next: ${e.next}`),t.join(`
|
|
4
|
+
`)}function qe(e){return e.replace(/,\s+\d+\s+edits$/,"")}function Le(e,n){if(Array.isArray(n))for(const t of n)typeof t=="string"&&e.push(t)}function Oe(e,n,t,r,i,o){const s=Ke(t),c=ze(e,t,r),l=Ve(e,i,o,r),a=L([...s,...c,...l]);if(a.length===0)return null;const p=Je(e,t),h=ee(e,n),m=X(h,a.map(y=>y.oldName),p);return{status:"preserved-via-alias",aliases:`${a.length} ${a.length===1?"alias":"aliases"}`,consumers:`${m.length} ${m.length===1?"file":"files"} not rewritten`,hint:"Public API names were preserved through re-export aliases. Consumers still use old names."}}function Te(e,n,t,r){if(!t.some(l=>/(^|[/\\])index\.(ts|tsx|mts|cts) x\d+$/i.test(l))||r.length===0)return null;const o=je(e,t),s=ee(e,n),c=X(s,r.map(l=>l.oldName),o);return{status:"preserved-via-alias",aliases:`${r.length} ${r.length===1?"alias":"aliases"}`,consumers:`${c.length} ${c.length===1?"file":"files"} not rewritten`,hint:"Public API names were preserved through re-export aliases. Consumers still use old names."}}function je(e,n){const t=new Set;for(const r of n){if(typeof r!="string"||r.startsWith("+"))continue;const i=/^(.*) x(\d+)$/.exec(r);i&&t.add(w(d.resolve(e,i[1])))}return t}function Ve(e,n,t,r){const i=w(t),o=[];for(const s of n){if(typeof s!="string"||s.startsWith("+"))continue;const c=/^(.*) x(\d+)$/.exec(s);if(!c)continue;const l=d.resolve(e,c[1]);if(w(l)===i)continue;if(/^index\.(ts|tsx|mts|cts)$/i.test(d.basename(l))){o.push(...r);continue}let a="";try{a=N.readFileSync(l,"utf8")}catch{continue}if(!(!a.includes("export")||!a.includes("from")))for(const p of r)a.includes(p.oldName)&&o.push(p)}return L(o)}function Ke(e){const n=[];for(const t of e)if(Array.isArray(t.apiAliases))for(const r of t.apiAliases)A(r)&&typeof r.oldName=="string"&&typeof r.newName=="string"&&n.push({oldName:r.oldName,newName:r.newName});return L(n)}function L(e){const n=new Set;return e.filter(t=>{const r=`${t.newName} as ${t.oldName}`;return n.has(r)?!1:(n.add(r),!0)})}function ze(e,n,t){const r=[];for(const o of n){const s=typeof o.sourceFilePath=="string"?w(o.sourceFilePath):null,c=Array.isArray(o.allFiles)?o.allFiles:[];for(const l of c){if(typeof l!="string"||l.startsWith("+"))continue;const a=/^(.*) x(\d+)$/.exec(l);if(!a)continue;const p=d.resolve(e,a[1]);if(s&&w(p)===s)continue;let h="";try{h=N.readFileSync(p,"utf8")}catch{continue}if(!(!h.includes("export")||!h.includes("from")))for(const m of t)h.includes(m.oldName)&&r.push(m)}}const i=new Set;return r.filter(o=>{const s=`${o.newName} as ${o.oldName}`;return i.has(s)?!1:(i.add(s),!0)})}function Be(e,n,t){const r=new RegExp(`\\b${Y(t)}\\s+as\\s+${Y(n)}\\b`);return e.filter(o=>typeof o.replacementPreview=="string"&&(r.test(o.replacementPreview)||Ue(o,n,t))).map(o=>({oldName:n,newName:t,...typeof o.fileName=="string"?{fileName:o.fileName}:{}})).slice(0,20)}function He(e,n,t,r,i){const o=i?w(i):null,s=[];for(const{file:c}of n){const l=d.resolve(e,c);if(o&&w(l)===o)continue;let a="";try{a=N.readFileSync(l,"utf8")}catch{continue}!a.includes(t)||!a.includes("export")||!a.includes("from")||s.push({oldName:t,newName:r,fileName:l})}return s.slice(0,20)}function Ue(e,n,t){if(typeof e.fileName!="string"||typeof e.replacementPreview!="string"||!e.replacementPreview.includes(t))return!1;let r="";try{r=N.readFileSync(e.fileName,"utf8")}catch{return!1}return r.includes(n)&&r.includes("export")&&r.includes("from")}function Je(e,n){const t=new Set;for(const r of n){const i=Array.isArray(r.allFiles)?r.allFiles:[];for(const o of i){if(typeof o!="string"||o.startsWith("+"))continue;const s=/^(.*) x(\d+)$/.exec(o);s&&t.add(w(d.resolve(e,s[1])))}}return t}function X(e,n,t){const r=Array.from(new Set(n.filter(s=>s.length>0)));if(r.length===0)return[];const i=[],o=new Set;for(const s of e)for(const c of Ge(s,5e3)){const l=w(c);if(t.has(l)||o.has(l))continue;o.add(l);let a="";try{a=N.readFileSync(c,"utf8")}catch{continue}r.some(p=>a.includes(p))&&i.push(c)}return i}function Ge(e,n){const t=[],r=[d.resolve(e)];for(;r.length>0&&t.length<n;){const i=r.pop();if(!i)continue;let o=[];try{o=N.readdirSync(i,{withFileTypes:!0})}catch{continue}for(const s of o){if(t.length>=n)break;if(s.isDirectory()){if(Xe(s.name))continue;r.push(d.join(i,s.name));continue}s.isFile()&&Ye(s.name)&&t.push(d.join(i,s.name))}}return t}function Xe(e){return[".git",".aib-plan-cache",".aib-preview",".aib-trace",".tmp","dist","node_modules","out"].includes(e)}function Ye(e){return/\.(ts|tsx|mts|cts)$/i.test(e)&&!/\.d\.(ts|mts|cts)$/i.test(e)}function w(e){return d.normalize(e).toLowerCase()}function Y(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Qe(e){const n=new Map;for(const t of e){const r=Array.isArray(t.allFiles)?t.allFiles:t.files;if(Array.isArray(r))for(const i of r){if(typeof i!="string"||i.startsWith("+"))continue;const o=/^(.*) x(\d+)$/.exec(i);if(!o)continue;const s=o[1],c=Number(o[2]);n.set(s,(n.get(s)??0)+c)}}return Array.from(n.entries()).sort((t,r)=>t[0].localeCompare(r[0])).map(([t,r])=>`${t} x${r}`)}function st(e,n){return Array.from(new Set(n.map(t=>t.projectConfig).filter(t=>typeof t=="string"&&t.length>0))).sort((t,r)=>t.localeCompare(r))}async function Ze(e,n,t,r,i,o,s,c){const l=new Set(t.map(y=>y.symbolName)),a=new Set(r.map(y=>y.newName.trim())),p=Array.from(l).filter(y=>y.length>0);if(p.length===0)return[];const h=et(n,i,s).slice(0,40),m=[];for(const y of h){let u;try{u=await(0,pe.queryTopLevelInspectSymbols)(e,y,(0,_.extensionRequestOptions)(c))}catch{continue}for(const f of u){if(typeof f.name!="string")continue;const g=f.name;if(!p.some(b=>g.includes(b))||l.has(g)||a.has(g))continue;const F=typeof f.kind=="string"?f.kind.toLowerCase():"";m.push(C({raw:g,symbolName:g,symbolKind:re(F)?F:null},o))}}return Array.from(new Set(m)).sort((y,u)=>y.localeCompare(u))}function et(e,n,t){const r=new Set([e]);for(const i of n){const o=Array.isArray(i.allFiles)?i.allFiles:[];for(const s of o){if(typeof s!="string"||s.startsWith("+"))continue;const c=/^(.*) x(\d+)$/.exec(s);c&&r.add(d.resolve(t,c[1]))}}return Array.from(r)}function tt(e,n){const t=new Map;for(const r of n){if(typeof r.fileName!="string")continue;const i=S(e,r.fileName);t.set(i,(t.get(i)??0)+1)}return Array.from(t.entries()).sort((r,i)=>r[0].localeCompare(i[0])).map(([r,i])=>({file:r,count:i}))}function Q(e){return e.documentMatchesDisk===!0&&e.documentIsDirty!==!0?null:{documentMatchesDisk:e.documentMatchesDisk===!0,documentIsDirty:e.documentIsDirty===!0}}function nt(e,n,t,r){return{sourceFile:e,renames:n.map((i,o)=>({entity:t[o]?.raw??i.entity.trim(),symbolName:t[o]?.symbolName??i.entity.trim(),...t[o]?.symbolKind?{symbolKind:t[o]?.symbolKind}:{},...t[o]?.parentName?{parentName:t[o]?.parentName}:{},newName:i.newName})),execute:r}}function Z(e,n){return Array.isArray(n)?n.filter(A).slice(0,8).map(t=>{const r=typeof t.name=="string"?t.name:"",i=typeof t.kind=="string"?t.kind.toLowerCase():"",o=Array.isArray(t.path)?t.path.filter(c=>typeof c=="string"):[],s=o.length>1?o[o.length-2]:void 0;return{name:r,kind:i,selector:C({raw:s?`${s}.${r}`:r,symbolName:r,symbolKind:re(i)?i:null,...s?{parentName:s}:{}},e)}}):[]}function C(e,n){const t=e.parentName?`${e.parentName}.${e.symbolName}`:e.symbolName;return e.symbolKind?`${n.entityKindAliases[e.symbolKind]}${n.selectorSeparator}${t}`:e.raw}function ee(e,n){const t=w(d.resolve(e)),r=[];for(const i of n.map(o=>d.resolve(o))){const o=w(i);if(t===o||o.startsWith(`${t}/`)){r.push(i);continue}t.startsWith(`${o}/`)&&r.push(d.resolve(e))}return r.length===0?[d.resolve(e)]:Array.from(new Set(r))}function D(e,n){const t=e.slice(0,n),r=e.length-t.length;return r>0?[...t,`+ ${r} more`]:t}function te(e){return typeof e=="number"?e:0}function rt(e){return typeof e=="string"?e:null}function it(e){const n=Math.max(1,Math.ceil(e/1e3));return n<60?`~${n} sec`:`~${Math.ceil(n/60)} min`}function S(e,n){return d.relative(e,n).replace(/\\/g,"/")}function ne(e,n){const t=e.indexOf(n);if(t<0)return null;const r=e[t+1];return r&&!r.startsWith("--")?r:null}function ot(){return{ok:!0,command:"rename",usage:"aib rename preview <sourceFile> <entity> <newName> | aib rename preview --stdin | aib rename execute --stdin | aib rename apply <previewId>",preview:{sourceFile:"src/path/to/source-file.ts",renames:[{entity:"OldSymbolName",newName:"NewSymbolName"}],execute:!1},apply:"aib rename apply rename_abc123",notes:["Use execute:false first when selector resolution is uncertain.","Preview returns previewId, file/edit summary, and candidate selectors on failure.","Apply by previewId refuses to run if the source file changed after preview."]}}function A(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function re(e){return me.ENTITY_KIND_IDS.includes(e)}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.runResultViewCommand=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.runResultViewCommand=S;const h=require("../shared/agent-text"),p=require("../shared/errors"),D=require("./declaration-format"),b=require("./inspect-cycles"),x=require("./session-workspace");function S(t,e,n){if(n!==void 0)return N(t,n);const r=e.find(u=>!u.startsWith("--"));if(!r)throw new p.CliError("VIEW_HANDLE_REQUIRED","Usage: aib view aib:res_<id>");const i=R(r),s=U(e.slice(1));if(i.short)return M(t,(0,x.readSessionResultViewJson)(t,i.id),s,r);if(i.kind==="cycles")return(0,b.buildCyclesViewResponse)((0,x.readSessionResultJson)(t,i.kind,i.id),{...s.detail!==void 0?{detail:A(s.detail)}:{},...s.offset!==void 0?{offset:s.offset}:{},...s.limit!==void 0?{limit:s.limit}:{},...s.index!==void 0?{index:s.index}:{},...s.kind!==void 0?{kind:E(s.kind)}:{},resultHandle:r});const d={ok:!1,code:"UNSUPPORTED_RESULT_VIEW",error:`aib view does not support result kind: ${i.kind}`};return(0,h.attachAgentText)(d,`unsupported result view: ${i.kind}`)}function N(t,e){const n=Array.isArray(e.views),r=Array.isArray(e.views)?e.views:[],i=n?r.filter(m):m(e.view)?[e.view]:m(e)?[e]:[];if(i.length===0)throw new p.CliError("VIEW_HANDLE_REQUIRED","view expects a handle.");const s=i.map((u,f)=>{try{return T(t,u)}catch(c){if(!n||i.length===1)throw c;return{...(0,p.errorPayload)(c),index:f}}});if(s.length===1)return s[0];const d=s.filter(u=>m(u)&&u.ok===!1).length;return(0,h.attachAgentText)({ok:d===0,...d>0?{batchOk:!1,failedCount:d}:{},results:s},s.map(u=>{if(!m(u))return"";const f=(0,h.readAgentText)(u);return typeof f=="string"?f.trimEnd():""}).filter(u=>u!=="").join(`
|
|
2
2
|
|
|
3
|
-
`))}function
|
|
4
|
-
`);let
|
|
5
|
-
`)}function P(t){const e=[],
|
|
6
|
-
`)}function
|
|
3
|
+
`))}function T(t,e){const n=o(e.handle)??o(e.from)??"";if(!n)throw new p.CliError("VIEW_HANDLE_REQUIRED","view expects a handle.");const r=R(n),i={...o(e.detail)!==void 0?{detail:o(e.detail)}:{},...y(e.offset)!==void 0?{offset:y(e.offset)}:{},...y(e.limit)!==void 0?{limit:y(e.limit)}:{},...y(e.index)!==void 0?{index:y(e.index)}:{},...o(e.kind)!==void 0?{kind:o(e.kind)}:{},...k(e.only).length>0?{only:k(e.only)}:{},...k(e.except).length>0?{except:k(e.except)}:{}};return r.short?M(t,(0,x.readSessionResultViewJson)(t,r.id),i,n):r.kind==="cycles"?(0,b.buildCyclesViewResponse)((0,x.readSessionResultJson)(t,r.kind,r.id),{...i.detail!==void 0?{detail:A(i.detail)}:{},...i.offset!==void 0?{offset:i.offset}:{},...i.limit!==void 0?{limit:i.limit}:{},...i.index!==void 0?{index:i.index}:{},...i.kind!==void 0?{kind:E(i.kind)}:{},resultHandle:n}):(0,h.attachAgentText)({ok:!1,code:"UNSUPPORTED_RESULT_VIEW",error:`aib view does not support result kind: ${r.kind}`},`unsupported result view: ${r.kind}`)}function R(t){if(/^aib:res_[A-Za-z0-9_-]+$/.test(t))return{kind:"view",id:t.slice(4),short:!0};const e=t.split(":");if(e.length!==4||e[0]!=="aib"||e[1]!=="result"||!e[2]||!e[3])throw new p.CliError("INVALID_RESULT_HANDLE",`Invalid result handle: ${t}`,{expected:"aib:res_<id>"});return{kind:e[2],id:e[3],short:!1}}function U(t){const e={},n=_(t,"--detail"),r=I(t,"--offset"),i=I(t,"--limit"),s=I(t,"--index"),d=_(t,"--kind"),u=$(t,"--only").flatMap(w),f=$(t,"--except").flatMap(w);return n!==void 0&&(e.detail=n),r!==void 0&&(e.offset=r),i!==void 0&&(e.limit=i),s!==void 0&&(e.index=s),d!==void 0&&(e.kind=d),u.length>0&&(e.only=u),f.length>0&&(e.except=f),e}function M(t,e,n,r){const i=o(e.kind);return e.op==="cycles"?(0,b.buildCyclesViewResponse)(e,{...n.detail!==void 0?{detail:A(n.detail)}:{},...n.offset!==void 0?{offset:n.offset}:{},...n.limit!==void 0?{limit:n.limit}:{},...n.index!==void 0?{index:n.index}:{},...n.kind!==void 0?{kind:E(n.kind)}:{},resultHandle:r}):i==="code"?O(e,n,r):i==="members"||i==="duplicates"||i==="usages"?W(e,n,r,i):i==="declarationMutation"?F(t,e,r):(0,h.attachAgentText)({ok:!1,code:"UNSUPPORTED_RESULT_VIEW",error:`aib view does not support result kind: ${i??"unknown"}`},`unsupported result view: ${i??"unknown"}`)}function W(t,e,n,r){const i=Array.isArray(t.items)?t.items.filter(m):[],s=L(i,e,g=>[o(g.name),o(g.text)?.split(/\s+/)[0]]),d=Math.max(0,e.offset??0),u=s.length||1,f=Math.max(1,e.limit??u),c=s.slice(d,d+f),l=Math.max(0,s.length-d-c.length),a={ok:!0,op:"view",handle:n,kind:r,source:o(t.source)??"inspect",...o(t.file)!==void 0?{file:o(t.file)}:{},...o(t.entity)!==void 0?{entity:o(t.entity)}:{},...o(t.target)!==void 0?{target:o(t.target)}:{},...o(t.detail)!==void 0?{detail:o(t.detail)}:{},items:c,offset:d,limit:f,...l>0?{hidden:l}:{}};return(0,h.attachAgentText)(a,P(a))}function O(t,e,n){const r=Array.isArray(t.items)?t.items.filter(m):[],i=L(r,e,a=>[o(a.entity),o(a.name)]),s=Math.max(0,e.offset??0),d=i.length||1,u=Math.max(1,e.limit??d),f=i.slice(s,s+u),c=Math.max(0,i.length-s-f.length),l={ok:!0,op:"view",handle:n,kind:"code",source:o(t.source)??"inspect",items:f,offset:s,limit:u,...c>0?{hidden:c}:{},...f.length===0&&r.length>0&&J(e)?{noMatches:!0}:{}};return(0,h.attachAgentText)(l,j(l))}function j(t){const e=[],n=Array.isArray(t.items)?t.items.filter(m):[];if(n.length===0&&t.noMatches===!0)return e.push("no hidden code matched view filters"),e.join(`
|
|
4
|
+
`);let r="";for(const s of n){const d=o(s.file)??"";d&&d!==r&&(e.length>0&&e.push(""),e.push(`// ${d}`),r=d);const u=o(s.entity)??"",f=o(s.meta)??o(s.rangeMeta)??"",c=[u,f].filter(a=>a!=="").join(" ");c&&e.push(`// ${c}`);const l=o(s.code);l&&e.push(l.trimEnd())}const i=y(t.hidden)??0;return i>0&&e.push(`+ ${i} more hidden code blocks`),e.join(`
|
|
5
|
+
`)}function P(t){const e=[],n=o(t.file),r=o(t.target),i=o(t.kind)??"",s=o(t.detail);n?e.push(`// ${n}`):i==="usages"?e.push(s?`usages ${s}`:"usages"):r&&e.push(`duplicates ${r}`);const d=o(t.entity);d&&e.push(`// ${d}:`);const u=Array.isArray(t.items)?t.items.filter(m):[];if(i==="usages")for(const[c,l]of H(u,a=>o(a.name)??"")){c&&e.push(`${c}:`);for(const a of l){const g=o(a.text);g&&e.push(g.trimEnd())}}else for(const c of u){const l=o(c.text);l&&e.push(l.trimEnd())}const f=y(t.hidden)??0;return f>0&&e.push(`+ ${f} more hidden ${i==="members"?"members":i==="usages"?"usages":"items"}`),e.join(`
|
|
6
|
+
`)}function H(t,e){const n=new Map;for(const r of t){const i=e(r),s=n.get(i)??[];s.push(r),n.set(i,s)}return Array.from(n.entries())}function A(t){if(t==="summary"||t==="sum")return"summary";if(t==="imports"||t==="files")return t;throw new p.CliError("INVALID_CYCLES_DETAIL","aib view cycles --detail expects summary, imports, or files.")}function E(t){if(t==="runtime"||t==="type-only"||t==="mixed")return t;throw new p.CliError("INVALID_CYCLES_KIND","aib view cycles --kind expects runtime, type-only, or mixed.")}function _(t,e){const n=t.indexOf(e),r=n>=0?t[n+1]:void 0;return r&&!r.startsWith("--")?r:void 0}function F(t,e,n){const r=Array.isArray(e.rows)?e.rows.filter(m):[],i=o(e.operation)==="addMissing"?"addMissing":"remove",s={ok:!0,op:"view",handle:n,kind:"declarationMutation",operation:i,rows:r};return(0,h.attachAgentText)(s,q(t,s))}function q(t,e){const n=[`${o(e.operation)??"declaration"} ${o(e.handle)??""}`.trim()],r=Array.isArray(e.rows)?e.rows.filter(m):[];return n.push(...(0,D.formatDeclarationMutationDetails)(t,o(e.operation)==="addMissing"?"addMissing":"remove",r)),n.join(`
|
|
7
|
+
`)}function $(t,e){const n=[];for(let r=0;r<t.length;r+=1){if(t[r]!==e)continue;const i=t[r+1];i&&!i.startsWith("--")&&n.push(i)}return n}function I(t,e){const n=_(t,e);if(n===void 0)return;const r=Number(n),i=e==="--offset"?0:1;if(!Number.isInteger(r)||r<i)throw new p.CliError("INVALID_VIEW_OPTION",`${e} expects ${i===0?"a non-negative":"a positive"} integer.`);return r}function m(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function o(t){return typeof t=="string"&&t!==""?t:void 0}function y(t){return typeof t=="number"&&Number.isFinite(t)?t:void 0}function Y(t,e){const n=t[e];return typeof n=="number"&&Number.isFinite(n)?n:0}function k(t){return typeof t=="string"&&t!==""?w(t):Array.isArray(t)?t.filter(e=>typeof e=="string"&&e!=="").flatMap(w):[]}function L(t,e,n){const r=e.only??[],i=e.except??[],s=r.length>0?t.filter(d=>C(n(d),r)):t;return i.length===0?s:s.filter(d=>!C(n(d),i))}function J(t){return(t.only?.length??0)>0||(t.except?.length??0)>0}function C(t,e){return t.some(n=>n!==void 0&&e.some(r=>B(n,r)))}function B(t,e){if(t===e)return!0;const n=t.split(".").pop()??t,r=e.split(".").pop()??e;return n===r&&!e.includes(".")}function w(t){const e=t.trim();return(K(e)??V(e)).flatMap(Q)}function Q(t){const e=t.trim(),n=e.match(/^(.+)\.\{(.+)\}$/);if(n){const r=n[1],i=n[2];if(r&&i)return V(i).map(s=>`${r}.${s}`)}return e?[e]:[]}function K(t){if(!t.startsWith("[")||!t.endsWith("]"))return null;const e=t.slice(1,-1).trim();return e?V(e):[]}function V(t){const e=[];let n="",r=0;for(const i of t){if(i==="{"?r+=1:i==="}"&&r>0&&(r-=1),i===","&&r===0){n.trim()&&e.push(n.trim()),n="";continue}n+=i}return n.trim()&&e.push(n.trim()),e}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var d=exports&&exports.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.runWorkerCommand=_;const c=d(require("node:fs")),i=d(require("node:path")),p=require("node:child_process"),y=require("../shared/errors"),k=require("../workers/registry"),g=require("../workers/product-storage");function _(r,e){if((e[0]??"")==="status")return h();const o=w(e),n=S(),t=(0,k.resolveWorkerRoute)({route:o.route,cliVersion:n,...o.registryPath?{registryPath:o.registryPath}:{}}),s=(0,p.spawnSync)(process.execPath,[t.script,...o.workerArgs],{cwd:r,encoding:"utf8",env:{...process.env,AIB_WORKER_ROUTE:t.route.route,AIB_WORKER_ID:t.route.workerId,AIB_WORKER_VERSION:t.route.version,AIB_WORKER_CWD:r}}),u=v(s.stdout),a=s.status===0&&u.ok!==!1;return{ok:a,command:"worker",route:t.route.route,worker:{workerId:t.route.workerId,version:t.route.version,script:t.script,registryPath:t.registryPath,status:s.status??null},payload:u,...a?{}:{error:m(u)??(s.stderr.trim()||"worker failed"),stderr:s.stderr.trim()}}}function h(){const r=(0,g.productStorageRoot)(),e=i.default.join(r,"workers","worker-routes.json"),o=i.default.join(r,"workers","activation-status.json"),n=l(e),t=l(o),s=j(i.default.join(r,"workers","bundles"));return{ok:!0,command:"worker",action:"status",registryPath:e,statusPath:o,registryVersion:f(n?.registryVersion)??f(t?.active?.registryVersion)??null,routeCount:Array.isArray(n?.routes)?n.routes.length:0,active:t?.active??null,previous:t?.previous??null,lastError:t?.lastError??null,workerBundles:s}}function w(r){let e,o;const n=[];let t=!1;for(let s=0;s<r.length;s+=1){const u=r[s],a=r[s+1];if(u!==void 0){if(!t&&u==="--registry"&&a){e=i.default.resolve(a),s+=1;continue}if(!t&&u==="--"){t=!0;continue}if(!o&&!t){o=u;continue}n.push(u)}}if(!o)throw new y.CliError("WORKER_USAGE","Usage: aib worker [--registry <path>] <route> -- <worker args>");return{route:o,...e?{registryPath:e}:{},workerArgs:n}}function v(r){try{const e=JSON.parse(r);return e&&typeof e=="object"&&!Array.isArray(e)?e:{ok:!1,error:"worker produced non-object json stdout"}}catch{return{ok:!1,error:r.trim()?`worker produced non-json stdout: ${r.trim()}`:"worker produced no stdout"}}}function m(r){return typeof r.error=="string"?r.error:null}function S(){const r=i.default.resolve(__dirname,"..","..","package.json");try{const e=JSON.parse(c.default.readFileSync(r,"utf8"));return typeof e.version=="string"?e.version:"0.0.0"}catch{return"0.0.0"}}function l(r){try{const e=JSON.parse(c.default.readFileSync(r,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}}function f(r){return typeof r=="string"&&r.trim()?r:null}function j(r){if(!c.default.existsSync(r))return[];const e=[];for(const o of c.default.readdirSync(r,{withFileTypes:!0})){if(!o.isDirectory())continue;const n=i.default.join(r,o.name,"activation-status.json"),t=l(n);t&&e.push({workerId:o.name,statusPath:n,active:t.active??null,previous:t.previous??null,lastError:t.lastError??null})}return e.sort((o,n)=>String(o.workerId).localeCompare(String(n.workerId)))}
|
package/dist/config/defaults.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_EFFECTIVE_CONFIG=void 0,exports.DEFAULT_EFFECTIVE_CONFIG={methodAliases:{ping:"ping",runtimeInfo:"runtimeInfo",printConfig:"printConfig",listInstances:"listInstances",initSkillUsage:"init-skill-usage",help:"help",inspect:"inspect",imports:"imports",move:"move",rename:"rename",refactor:"refactor",execution:"execution",modulePlan:"modulePlan"},entityKindAliases:{class:"c",interface:"i",type:"t",function:"f",variable:"v",enum:"e",method:"m",property:"p"},selectorSeparator:"-"};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_EFFECTIVE_CONFIG=void 0,exports.DEFAULT_EFFECTIVE_CONFIG={methodAliases:{ping:"ping",runtimeInfo:"runtimeInfo",printConfig:"printConfig",listInstances:"listInstances",initSkillUsage:"init-skill-usage",help:"help",inspect:"inspect",imports:"imports",move:"move",rename:"rename",refactor:"refactor",execution:"execution",modulePlan:"modulePlan"},entityKindAliases:{class:"c",interface:"i",type:"t",function:"f",variable:"v",enum:"e",namespace:"ns",method:"m",property:"p"},selectorSeparator:"-"};
|
package/dist/config/env-vars.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CLI_ENV=void 0,exports.CLI_ENV={autoStartIde:"AIB_AUTO_START_IDE",installConfig:"AIB_INSTALL_CONFIG",managedHostScript:"AIB_MANAGED_HOST_SCRIPT",managedHostKind:"AIB_MANAGED_HOST_KIND",managedHostRunDir:"AIB_MANAGED_HOST_RUN_DIR",codeServerPath:"AIB_CODE_SERVER_PATH",nodePath:"AIB_NODE_PATH",extensionVsix:"AIB_EXTENSION_VSIX",ideCommand:"AIB_IDE_COMMAND",chromePath:"AIB_CHROME_PATH",runtimeArchive:"AIB_RUNTIME_ARCHIVE",runtimeUrl:"AIB_RUNTIME_URL",runtimeManifest:"AIB_RUNTIME_MANIFEST",runtimeManifestUrl:"AIB_RUNTIME_MANIFEST_URL",managedHostWaitMs:"AIB_MANAGED_HOST_WAIT_MS",workspaceRoot:"AIB_WORKSPACE_ROOT",helpDir:"AIB_HELP_DIR",trace:"AIB_TRACE",traceDir:"AIB_TRACE_DIR",failureSnapshots:"AIB_FAILURE_SNAPSHOTS",productStorageDir:"AIB_PRODUCT_STORAGE_DIR",cliSessionDir:"AIB_CLI_SESSION_DIR",disableWatchers:"AIB_DISABLE_WATCHERS",session:"AIB",legacySession:"AIB_SESSION",transport:"AIB_TRANSPORT",metrics:"AIB_METRICS",metricsDir:"AIB_METRICS_DIR",metricsTag:"AIB_METRICS_TAG",mutationImpactMetrics:"AIB_MUTATION_IMPACT_METRICS",mutationImpactStream:"AIB_MUTATION_IMPACT_STREAM",testPostMutationCyclesDelayMs:"AIB_TEST_POST_MUTATION_CYCLES_DELAY_MS",testMoveToFileFailEntity:"AIB_TEST_MOVE_TO_FILE_FAIL_ENTITY",testRefactorBatchDelayMs:"AIB_TEST_REFACTOR_BATCH_DELAY_MS",testRenameDelayMs:"AIB_TEST_RENAME_DELAY_MS",modulePlanSyncWaitMs:"AIB_MODULE_PLAN_SYNC_WAIT_MS",refactorBatchSyncWaitMs:"AIB_REFACTOR_BATCH_SYNC_WAIT_MS",renameSyncWaitMs:"AIB_RENAME_SYNC_WAIT_MS",modulePlanDebugTimeline:"AIB_DEBUG_MODULE_PLAN_TIMELINE",forceDsl:"AIB_FORCE_DSL"};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CLI_ENV=void 0,exports.CLI_ENV={autoStartIde:"AIB_AUTO_START_IDE",installConfig:"AIB_INSTALL_CONFIG",managedHostScript:"AIB_MANAGED_HOST_SCRIPT",managedHostKind:"AIB_MANAGED_HOST_KIND",managedHostRunDir:"AIB_MANAGED_HOST_RUN_DIR",codeServerPath:"AIB_CODE_SERVER_PATH",nodePath:"AIB_NODE_PATH",extensionVsix:"AIB_EXTENSION_VSIX",ideCommand:"AIB_IDE_COMMAND",chromePath:"AIB_CHROME_PATH",rtkPath:"AIB_RTK_PATH",rgPath:"AIB_RG_PATH",runtimeArchive:"AIB_RUNTIME_ARCHIVE",runtimeUrl:"AIB_RUNTIME_URL",runtimeManifest:"AIB_RUNTIME_MANIFEST",runtimeManifestUrl:"AIB_RUNTIME_MANIFEST_URL",managedHostWaitMs:"AIB_MANAGED_HOST_WAIT_MS",workspaceRoot:"AIB_WORKSPACE_ROOT",helpDir:"AIB_HELP_DIR",helpShell:"AIB_HELP_SHELL",trace:"AIB_TRACE",traceDir:"AIB_TRACE_DIR",failureSnapshots:"AIB_FAILURE_SNAPSHOTS",productStorageDir:"AIB_PRODUCT_STORAGE_DIR",cliSessionDir:"AIB_CLI_SESSION_DIR",disableWatchers:"AIB_DISABLE_WATCHERS",session:"AIB",legacySession:"AIB_SESSION",transport:"AIB_TRANSPORT",metrics:"AIB_METRICS",metricsDir:"AIB_METRICS_DIR",metricsTag:"AIB_METRICS_TAG",controlPlaneUrl:"AIB_CONTROL_PLANE_URL",controlPlaneUpload:"AIB_CONTROL_PLANE_UPLOAD",controlPlaneChannel:"AIB_CONTROL_PLANE_CHANNEL",mutationImpactMetrics:"AIB_MUTATION_IMPACT_METRICS",mutationImpactStream:"AIB_MUTATION_IMPACT_STREAM",testPostMutationCyclesDelayMs:"AIB_TEST_POST_MUTATION_CYCLES_DELAY_MS",testMoveToFileFailEntity:"AIB_TEST_MOVE_TO_FILE_FAIL_ENTITY",testRefactorBatchDelayMs:"AIB_TEST_REFACTOR_BATCH_DELAY_MS",testRenameDelayMs:"AIB_TEST_RENAME_DELAY_MS",testFileMoveToDirDelayMs:"AIB_TEST_FILE_MOVE_TO_DIR_DELAY_MS",testFileMoveToDirRowDelayMs:"AIB_TEST_FILE_MOVE_TO_DIR_ROW_DELAY_MS",testFileMoveToDirImportsDelayMs:"AIB_TEST_FILE_MOVE_TO_DIR_IMPORTS_DELAY_MS",testFileMoveToDirFailImports:"AIB_TEST_FILE_MOVE_TO_DIR_FAIL_IMPORTS",testFileRenameDelayMs:"AIB_TEST_FILE_RENAME_DELAY_MS",testFileRenameRowDelayMs:"AIB_TEST_FILE_RENAME_ROW_DELAY_MS",testFileRenameImportsDelayMs:"AIB_TEST_FILE_RENAME_IMPORTS_DELAY_MS",testFileRenameFailImports:"AIB_TEST_FILE_RENAME_FAIL_IMPORTS",testFileRefactorBatchDelayMs:"AIB_TEST_FILE_REFACTOR_BATCH_DELAY_MS",testFileRefactorBatchRowDelayMs:"AIB_TEST_FILE_REFACTOR_BATCH_ROW_DELAY_MS",testFileRefactorBatchImportsDelayMs:"AIB_TEST_FILE_REFACTOR_BATCH_IMPORTS_DELAY_MS",testFileRefactorBatchFailImports:"AIB_TEST_FILE_REFACTOR_BATCH_FAIL_IMPORTS",disableFileMutationImportPostProcess:"AIB_DISABLE_FILE_MUTATION_IMPORT_POST_PROCESS",disableFileMoveImportPostProcess:"AIB_DISABLE_FILE_MOVE_IMPORT_POST_PROCESS",modulePlanSyncWaitMs:"AIB_MODULE_PLAN_SYNC_WAIT_MS",refactorBatchSyncWaitMs:"AIB_REFACTOR_BATCH_SYNC_WAIT_MS",renameSyncWaitMs:"AIB_RENAME_SYNC_WAIT_MS",fileMoveToDirSyncWaitMs:"AIB_FILE_MOVE_TO_DIR_SYNC_WAIT_MS",fileRenameSyncWaitMs:"AIB_FILE_RENAME_SYNC_WAIT_MS",fileRefactorBatchSyncWaitMs:"AIB_FILE_REFACTOR_BATCH_SYNC_WAIT_MS",modulePlanDebugTimeline:"AIB_DEBUG_MODULE_PLAN_TIMELINE",forceDsl:"AIB_FORCE_DSL"};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var P=exports&&exports.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var a=Object.getOwnPropertyDescriptor(e,r);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,a)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),
|
|
1
|
+
"use strict";var P=exports&&exports.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var a=Object.getOwnPropertyDescriptor(e,r);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,a)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),y=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),g=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(n[n.length]=a);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),a=0;a<n.length;a++)n[a]!=="default"&&P(r,e,n[a]);return y(r,e),r}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.readConfigPathAliases=h,exports.effectivePathAliases=w,exports.expandPathAliasesInArgs=O,exports.expandPathAliasesInJson=E,exports.expandPathAliasValue=c,exports.normalizePathAliasMap=f,exports.normalizePathAliasName=_;const l=g(require("node:path")),A=require("./workspace-root"),s=require("../shared/errors"),m="pathAliases",p=new Set(["aib","file","source","target","scope","save","op"]);function h(t){const e=(0,A.resolveWorkspaceRoot)(t);return e?f(e.config[m],"aib.json pathAliases"):{}}function w(t,e={}){return{...h(t),...f(e,"session path aliases")}}function O(t,e,r){return Object.keys(r).length===0?e:e.map(n=>c(t,n,r))}function E(t,e,r){return e===void 0||Object.keys(r).length===0?e:u(t,e,r)}function c(t,e,r){if(e.includes("*"))return e;const n=e.match(/^@([A-Za-z][A-Za-z0-9_-]*)(?:(?:\/|\\)(.*))?$/);if(!n)return e;const a=n[1]??"",i=n[2]??"",o=r[a];if(!o)throw new s.CliError("UNKNOWN_PATH_ALIAS",`Unknown path alias: @${a}`,{alias:a,available:Object.keys(r).sort()});const b=(0,A.resolveWorkspaceRoot)(t)?.root??t;return l.normalize(l.resolve(b,o,i))}function f(t,e){if(t==null)return{};if(!d(t))throw new s.CliError("INVALID_PATH_ALIASES",`${e} must be an object of alias name to path.`);const r={};for(const[n,a]of Object.entries(t)){const i=_(n,e);if(typeof a!="string"||a.trim()==="")throw new s.CliError("INVALID_PATH_ALIAS_TARGET",`${e}.${n} must be a non-empty path string.`);r[i]=a.trim().replace(/\\/g,"/")}return r}function _(t,e){const r=t.trim();if(!/^[A-Za-z][A-Za-z0-9_-]*$/.test(r))throw new s.CliError("INVALID_PATH_ALIAS_NAME",`${e} has invalid alias name: ${t}`,{expected:"Alias names must match /^[A-Za-z][A-Za-z0-9_-]*$/."});if(p.has(r))throw new s.CliError("RESERVED_PATH_ALIAS_NAME",`${e} uses reserved alias name: ${r}`,{alias:r,reserved:Array.from(p).sort()});return r}function u(t,e,r){if(typeof e=="string")return c(t,e,r);if(Array.isArray(e))return e.map(n=>u(t,n,r));if(d(e)){const n=Object.fromEntries(Object.entries(e).map(([i,o])=>[i,u(t,o,r)])),a=typeof e.scope=="string"?e.scope:"";return a.startsWith("@")&&n.scope!==a&&typeof n.displayScope!="string"&&typeof n.display_scope!="string"&&(n.displayScope=a),n}return e}function d(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isRemovedAgentCommand=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isRemovedAgentCommand=v,exports.resolveCanonicalCommandAlias=O;const r=require("../commands/shared"),c=require("../shared/errors"),M=require("../shared/types"),d=require("../rtk-wrapper/core"),h=new Set(["doctor","diagnostics","init","runtime","session","sync","reveal","trace","control-plane","background","worker","host","ota","observability","feedback","note","generate-docs","config","view","qr","rg",...d.RTK_PASSTHROUGH_COMMANDS]),a=new Set(M.CANONICAL_METHOD_IDS),l=new Set(["applyModulePlan","validateModulePlan","findImporters","findUnusedImports","moveToFile","renameEntities","refactorBatch","normalizeImports","input"]);function v(e){return l.has(e)}function _(e){const s=new Map;for(const[o,t]of Object.entries(e)){if(!a.has(o)||!t)continue;const n=s.get(t)??[];n.push(o),s.set(t,n)}return s}async function O(e,s,o,t){if(l.has(e)||h.has(e)||a.has(e))return e;try{const n={};o!==void 0&&(n.explicitInstanceId=o),t!==void 0&&(n.autoStartIde=t);const u=await(0,r.resolveTargetInstance)(s,n),f=await(0,r.fetchEffectiveConfig)(u.entry),i=_(f.methodAliases).get(e);if(!i||i.length===0)return e;if(i.length>1)throw new c.CliError("AMBIGUOUS_COMMAND_ALIAS",`Alias "${e}" resolves to multiple commands.`,{alias:e,canonicalCommands:i});const[A]=i;return A??e}catch(n){if(n instanceof c.CliError&&n.code==="AMBIGUOUS_COMMAND_ALIAS")throw n;return e}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var f=exports&&exports.__createBinding||(Object.create?(function(e,
|
|
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")}
|
package/dist/dsl/aib-dsl.js
CHANGED
|
@@ -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}
|