@automaton-labs/aib 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +578 -0
- package/dist/bin/aib.js +2 -0
- package/dist/bin/cli.js +3 -0
- package/dist/client/http-client.js +1 -0
- package/dist/client/transport-options.js +1 -0
- package/dist/client/websocket-client.js +1 -0
- package/dist/commands/add-missing-imports-preview-cache.js +2 -0
- package/dist/commands/add-missing-imports.js +2 -0
- package/dist/commands/apply-module-plan.js +3 -0
- package/dist/commands/captured-input.js +2 -0
- package/dist/commands/config-command.js +3 -0
- package/dist/commands/diagnostics-command.js +3 -0
- package/dist/commands/doctor.js +1 -0
- package/dist/commands/entity-resolution.js +1 -0
- package/dist/commands/execution-command.js +1 -0
- package/dist/commands/feedback-command.js +3 -0
- package/dist/commands/find-importers.js +1 -0
- package/dist/commands/find-unused-imports.js +1 -0
- package/dist/commands/generate-docs-command.js +6 -0
- package/dist/commands/help-command.js +3 -0
- package/dist/commands/imports-command.js +1 -0
- package/dist/commands/init-skill-usage.js +3 -0
- package/dist/commands/init-workspace.js +3 -0
- package/dist/commands/inspect-cycles.js +5 -0
- package/dist/commands/inspect-format.js +18 -0
- package/dist/commands/inspect-graph.js +9 -0
- package/dist/commands/inspect-imports.js +2 -0
- package/dist/commands/inspect-symbol-query.js +1 -0
- package/dist/commands/inspect-tree.js +5 -0
- package/dist/commands/inspect.js +16 -0
- package/dist/commands/json-file-input.js +1 -0
- package/dist/commands/list-instances.js +1 -0
- package/dist/commands/module-plan-cache.js +2 -0
- package/dist/commands/module-plan-command.js +1 -0
- package/dist/commands/module-plan-timeout.js +1 -0
- package/dist/commands/move-command.js +1 -0
- package/dist/commands/move-preview-cache.js +2 -0
- package/dist/commands/move-to-file.js +2 -0
- package/dist/commands/mutation-execution-cache.js +3 -0
- package/dist/commands/normalize-imports.js +4 -0
- package/dist/commands/observability-command.js +3 -0
- package/dist/commands/ping.js +1 -0
- package/dist/commands/print-config.js +1 -0
- package/dist/commands/quick-read.js +11 -0
- package/dist/commands/refactor-batch-builder.js +1 -0
- package/dist/commands/refactor-batch-execution-cache.js +1 -0
- package/dist/commands/refactor-batch-preview-cache.js +2 -0
- package/dist/commands/refactor-batch.js +4 -0
- package/dist/commands/refactor-command.js +1 -0
- package/dist/commands/rename-command.js +1 -0
- package/dist/commands/rename-entities.js +4 -0
- package/dist/commands/rename-execution-cache.js +1 -0
- package/dist/commands/rename-input.js +1 -0
- package/dist/commands/rename-preview-cache.js +2 -0
- package/dist/commands/result-view.js +6 -0
- package/dist/commands/runtime-command.js +4 -0
- package/dist/commands/runtime-info.js +1 -0
- package/dist/commands/session-workspace.js +31 -0
- package/dist/commands/shared.js +1 -0
- package/dist/commands/sync-command.js +2 -0
- package/dist/commands/validate-module-plan.js +2 -0
- package/dist/commands/workspace-cache.js +1 -0
- package/dist/compatibility/policy.js +1 -0
- package/dist/config/auto-start-ide.js +1 -0
- package/dist/config/defaults.js +1 -0
- package/dist/config/env-vars.js +1 -0
- package/dist/config/glob-match.js +1 -0
- package/dist/config/import-rules.js +1 -0
- package/dist/config/local-config.js +3 -0
- package/dist/config/mutation-comments.js +1 -0
- package/dist/config/path-aliases.js +1 -0
- package/dist/config/path-display.js +1 -0
- package/dist/config/product-storage.js +1 -0
- package/dist/config/resolve-command-alias.js +1 -0
- package/dist/config/resolve.js +1 -0
- package/dist/config/workspace-root.js +3 -0
- package/dist/config/workspace-state.js +1 -0
- package/dist/content/content-bundle.js +1 -0
- package/dist/diagnostics/module-plan-timeline.js +2 -0
- package/dist/diagnostics/readiness-text.js +8 -0
- package/dist/discovery/registry.js +1 -0
- package/dist/discovery/select-instance.js +1 -0
- package/dist/dsl/aib-dsl.js +1 -0
- package/dist/help/bootstrap.md +924 -0
- package/dist/help/diagnostics/doctor.json +70 -0
- package/dist/help/docs/basics.md +14 -0
- package/dist/help/docs/dsl.md +25 -0
- package/dist/help/docs/help-format.md +12 -0
- package/dist/help/docs/imports.normalize.md +36 -0
- package/dist/help/docs/inspect.code.md +29 -0
- package/dist/help/docs/inspect.deps.md +32 -0
- package/dist/help/docs/inspect.duplicates.md +72 -0
- package/dist/help/docs/inspect.exports.md +34 -0
- package/dist/help/docs/inspect.file.md +32 -0
- package/dist/help/docs/inspect.graph.md +112 -0
- package/dist/help/docs/inspect.imports.md +15 -0
- package/dist/help/docs/inspect.md +71 -0
- package/dist/help/docs/inspect.members.md +24 -0
- package/dist/help/docs/inspect.tree.md +30 -0
- package/dist/help/docs/inspect.usages.md +48 -0
- package/dist/help/docs/modulePlan.md +51 -0
- package/dist/help/docs/move.md +37 -0
- package/dist/help/docs/mutation.md +47 -0
- package/dist/help/docs/patterns.md +178 -0
- package/dist/help/docs/prefs.md +40 -0
- package/dist/help/docs/qr.md +33 -0
- package/dist/help/docs/refactor.batch.md +44 -0
- package/dist/help/docs/rename.md +39 -0
- package/dist/help/docs/selectors.md +23 -0
- package/dist/help/docs/session.md +61 -0
- package/dist/help/docs/view.md +30 -0
- package/dist/help/dsl/bootstrap.md +924 -0
- package/dist/help/dsl/docs/basics.md +14 -0
- package/dist/help/dsl/docs/dsl.md +25 -0
- package/dist/help/dsl/docs/help-format.md +12 -0
- package/dist/help/dsl/docs/imports.normalize.md +36 -0
- package/dist/help/dsl/docs/inspect.code.md +29 -0
- package/dist/help/dsl/docs/inspect.deps.md +32 -0
- package/dist/help/dsl/docs/inspect.duplicates.md +72 -0
- package/dist/help/dsl/docs/inspect.exports.md +34 -0
- package/dist/help/dsl/docs/inspect.file.md +32 -0
- package/dist/help/dsl/docs/inspect.graph.md +112 -0
- package/dist/help/dsl/docs/inspect.imports.md +15 -0
- package/dist/help/dsl/docs/inspect.md +71 -0
- package/dist/help/dsl/docs/inspect.members.md +24 -0
- package/dist/help/dsl/docs/inspect.tree.md +30 -0
- package/dist/help/dsl/docs/inspect.usages.md +48 -0
- package/dist/help/dsl/docs/modulePlan.md +51 -0
- package/dist/help/dsl/docs/move.md +37 -0
- package/dist/help/dsl/docs/mutation.md +47 -0
- package/dist/help/dsl/docs/patterns.md +178 -0
- package/dist/help/dsl/docs/prefs.md +40 -0
- package/dist/help/dsl/docs/qr.md +33 -0
- package/dist/help/dsl/docs/refactor.batch.md +44 -0
- package/dist/help/dsl/docs/rename.md +39 -0
- package/dist/help/dsl/docs/selectors.md +23 -0
- package/dist/help/dsl/docs/session.md +61 -0
- package/dist/help/dsl/docs/view.md +30 -0
- package/dist/help/dsl/full.md +924 -0
- package/dist/help/dsl/snippets/agents.md +14 -0
- package/dist/help/dsl/topics/basics.md +12 -0
- package/dist/help/dsl/topics/dsl.md +23 -0
- package/dist/help/dsl/topics/help-format.md +10 -0
- package/dist/help/dsl/topics/imports.normalize.md +34 -0
- package/dist/help/dsl/topics/inspect.code.md +27 -0
- package/dist/help/dsl/topics/inspect.deps.md +30 -0
- package/dist/help/dsl/topics/inspect.duplicates.md +43 -0
- package/dist/help/dsl/topics/inspect.exports.md +32 -0
- package/dist/help/dsl/topics/inspect.file.md +30 -0
- package/dist/help/dsl/topics/inspect.graph.md +110 -0
- package/dist/help/dsl/topics/inspect.imports.md +13 -0
- package/dist/help/dsl/topics/inspect.md +69 -0
- package/dist/help/dsl/topics/inspect.members.md +22 -0
- package/dist/help/dsl/topics/inspect.tree.md +20 -0
- package/dist/help/dsl/topics/inspect.usages.md +46 -0
- package/dist/help/dsl/topics/modulePlan.md +38 -0
- package/dist/help/dsl/topics/move.md +27 -0
- package/dist/help/dsl/topics/mutation.md +45 -0
- package/dist/help/dsl/topics/patterns.md +176 -0
- package/dist/help/dsl/topics/prefs.md +38 -0
- package/dist/help/dsl/topics/qr.md +31 -0
- package/dist/help/dsl/topics/refactor.batch.md +33 -0
- package/dist/help/dsl/topics/rename.md +25 -0
- package/dist/help/dsl/topics/selectors.md +21 -0
- package/dist/help/dsl/topics/session.md +59 -0
- package/dist/help/dsl/topics/view.md +28 -0
- package/dist/help/full.md +924 -0
- package/dist/help/help-meta.json +113 -0
- package/dist/help/index.md +167 -0
- package/dist/help/json/bootstrap.md +1074 -0
- package/dist/help/json/docs/basics.md +15 -0
- package/dist/help/json/docs/dsl.md +25 -0
- package/dist/help/json/docs/help-format.md +12 -0
- package/dist/help/json/docs/imports.normalize.md +47 -0
- package/dist/help/json/docs/inspect.code.md +41 -0
- package/dist/help/json/docs/inspect.deps.md +46 -0
- package/dist/help/json/docs/inspect.duplicates.md +65 -0
- package/dist/help/json/docs/inspect.exports.md +40 -0
- package/dist/help/json/docs/inspect.file.md +38 -0
- package/dist/help/json/docs/inspect.graph.md +139 -0
- package/dist/help/json/docs/inspect.imports.md +15 -0
- package/dist/help/json/docs/inspect.md +87 -0
- package/dist/help/json/docs/inspect.members.md +32 -0
- package/dist/help/json/docs/inspect.tree.md +30 -0
- package/dist/help/json/docs/inspect.usages.md +61 -0
- package/dist/help/json/docs/modulePlan.md +70 -0
- package/dist/help/json/docs/move.md +53 -0
- package/dist/help/json/docs/mutation.md +62 -0
- package/dist/help/json/docs/patterns.md +178 -0
- package/dist/help/json/docs/prefs.md +40 -0
- package/dist/help/json/docs/qr.md +33 -0
- package/dist/help/json/docs/refactor.batch.md +72 -0
- package/dist/help/json/docs/rename.md +47 -0
- package/dist/help/json/docs/selectors.md +23 -0
- package/dist/help/json/docs/session.md +77 -0
- package/dist/help/json/docs/view.md +30 -0
- package/dist/help/json/full.md +1074 -0
- package/dist/help/json/snippets/agents.md +14 -0
- package/dist/help/json/topics/basics.md +13 -0
- package/dist/help/json/topics/dsl.md +23 -0
- package/dist/help/json/topics/help-format.md +10 -0
- package/dist/help/json/topics/imports.normalize.md +45 -0
- package/dist/help/json/topics/inspect.code.md +39 -0
- package/dist/help/json/topics/inspect.deps.md +44 -0
- package/dist/help/json/topics/inspect.duplicates.md +37 -0
- package/dist/help/json/topics/inspect.exports.md +38 -0
- package/dist/help/json/topics/inspect.file.md +36 -0
- package/dist/help/json/topics/inspect.graph.md +137 -0
- package/dist/help/json/topics/inspect.imports.md +13 -0
- package/dist/help/json/topics/inspect.md +85 -0
- package/dist/help/json/topics/inspect.members.md +30 -0
- package/dist/help/json/topics/inspect.tree.md +20 -0
- package/dist/help/json/topics/inspect.usages.md +59 -0
- package/dist/help/json/topics/modulePlan.md +57 -0
- package/dist/help/json/topics/move.md +43 -0
- package/dist/help/json/topics/mutation.md +60 -0
- package/dist/help/json/topics/patterns.md +176 -0
- package/dist/help/json/topics/prefs.md +38 -0
- package/dist/help/json/topics/qr.md +31 -0
- package/dist/help/json/topics/refactor.batch.md +61 -0
- package/dist/help/json/topics/rename.md +42 -0
- package/dist/help/json/topics/selectors.md +21 -0
- package/dist/help/json/topics/session.md +59 -0
- package/dist/help/json/topics/view.md +28 -0
- package/dist/help/snippets/agents.md +14 -0
- package/dist/help/topics/basics.md +12 -0
- package/dist/help/topics/dsl.md +23 -0
- package/dist/help/topics/help-format.md +10 -0
- package/dist/help/topics/imports.normalize.md +34 -0
- package/dist/help/topics/inspect.code.md +27 -0
- package/dist/help/topics/inspect.deps.md +30 -0
- package/dist/help/topics/inspect.duplicates.md +43 -0
- package/dist/help/topics/inspect.exports.md +32 -0
- package/dist/help/topics/inspect.file.md +30 -0
- package/dist/help/topics/inspect.graph.md +110 -0
- package/dist/help/topics/inspect.imports.md +13 -0
- package/dist/help/topics/inspect.md +69 -0
- package/dist/help/topics/inspect.members.md +22 -0
- package/dist/help/topics/inspect.tree.md +20 -0
- package/dist/help/topics/inspect.usages.md +46 -0
- package/dist/help/topics/modulePlan.md +38 -0
- package/dist/help/topics/move.md +27 -0
- package/dist/help/topics/mutation.md +45 -0
- package/dist/help/topics/patterns.md +176 -0
- package/dist/help/topics/prefs.md +38 -0
- package/dist/help/topics/qr.md +31 -0
- package/dist/help/topics/refactor.batch.md +33 -0
- package/dist/help/topics/rename.md +25 -0
- package/dist/help/topics/selectors.md +21 -0
- package/dist/help/topics/session.md +59 -0
- package/dist/help/topics/view.md +28 -0
- package/dist/ide-launch/common.cjs +162 -0
- package/dist/managed-host/extension-vsix-resolver.js +1 -0
- package/dist/managed-host/manage-serve-web-host.cjs +141 -0
- package/dist/managed-host/serve-web-autostart.js +1 -0
- package/dist/managed-host/serve-web-host.cjs +1790 -0
- package/dist/metrics/central-metrics.js +2 -0
- package/dist/observability/config.js +1 -0
- package/dist/observability/context.js +1 -0
- package/dist/observability/failure-snapshot.js +2 -0
- package/dist/observability/recent.js +2 -0
- package/dist/payloads/read-stdin-json.js +1 -0
- package/dist/runtime/bundled-node.js +1 -0
- package/dist/runtime/input-source.js +1 -0
- package/dist/runtime/managed-runtime-provisioning.js +1 -0
- package/dist/runtime/run-command.js +1 -0
- package/dist/selectors/parse-entities.js +1 -0
- package/dist/session/client.js +1 -0
- package/dist/session/paths.js +1 -0
- package/dist/session/server.js +6 -0
- package/dist/shared/agent-text.js +1 -0
- package/dist/shared/diagnostic-catalog.js +1 -0
- package/dist/shared/diagnostics.js +1 -0
- package/dist/shared/errors.js +28 -0
- package/dist/shared/event-loop.js +1 -0
- package/dist/shared/hints.js +1 -0
- package/dist/shared/metrics.js +1 -0
- package/dist/shared/operations.js +1 -0
- package/dist/shared/presentation.js +4 -0
- package/dist/shared/protocol.js +1 -0
- package/dist/shared/routes.js +1 -0
- package/dist/shared/stdout.js +2 -0
- package/dist/shared/types.js +1 -0
- package/dist/tracing/config.js +2 -0
- package/dist/tracing/trace.js +3 -0
- package/extension/vscode-refactor-bridge-extension.vsix +0 -0
- package/package.json +39 -0
- package/runtimes/launcher/win-x64/aib.exe +0 -0
- package/scripts/install-windows-launcher.cjs +58 -0
- package/scripts/postinstall.cjs +28 -0
- package/scripts/provision-runtime.cjs +299 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.runRuntimeInfo=c;const n=require("./shared"),o=require("../client/http-client"),a=require("../shared/routes");async function c(r,t={}){const e=await(0,n.resolveTargetInstance)(r,t),s=await(0,o.postJson)(e.entry,a.EXTENSION_ROUTES.runtimeInfo,{},(0,n.extensionRequestOptions)(t));return{ok:!0,selectedInstance:{instanceId:e.entry.instanceId,reason:e.reason,matchedWorkspace:e.matchedWorkspace,port:e.entry.port},response:s}}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";var De=exports&&exports.__createBinding||(Object.create?(function(e,t,n,s){s===void 0&&(s=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,s,i)}):(function(e,t,n,s){s===void 0&&(s=n),e[s]=t[n]})),$e=exports&&exports.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),ie=exports&&exports.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(n){var s=[];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[s.length]=i);return s},e(t)};return function(t){if(t&&t.__esModule)return t;var n={};if(t!=null)for(var s=e(t),i=0;i<s.length;i++)s[i]!=="default"&&De(n,t,s[i]);return $e(n,t),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.isSessionHandle=M,exports.runWithSessionOverride=Ue,exports.runSessionWorkspaceCommand=Fe,exports.resolveSessionFileArgument=B,exports.saveSessionOutputJson=qe,exports.saveSessionOutputText=et,exports.saveSessionResultJson=tt,exports.saveSessionResultViewJson=nt,exports.readSessionResultViewJson=st,exports.readSessionResultJson=it,exports.captureSessionInputJson=rt,exports.captureSessionInput=ae,exports.sessionWorkspaceExists=ot,exports.useSessionGuidance=ue,exports.readSessionBooleanPref=at,exports.readSessionNumberPref=ut,exports.readSessionStringPref=ct,exports.readEffectiveSessionPathAliases=lt,exports.readSessionPathAliasOverrides=ft,exports.tryResolveCurrentSessionId=Ut;const l=ie(require("node:fs")),c=ie(require("node:path")),xe=require("node:async_hooks"),E=require("../config/env-vars"),N=require("../config/workspace-root"),b=require("../config/path-aliases"),m=require("../shared/agent-text"),u=require("../shared/errors"),je=c.join(".tmp","aib"),U="sessionDir",Ce="session.json",we="active.json",Re="aib:",Le="s_",Pe="last",Te="_last.json",F=new xe.AsyncLocalStorage,ke=["graph","inspect","code","slice","members","exports","deps","usages","duplicates","execution","rename","move","refactor","modulePlan","imports"],We=["inspect","graph","rename","move","refactor","modulePlan","imports","generic"],O={"guidance.nextLimit":{type:"number",default:2,min:0,max:100,hidden:!0},"diagnostics.hintLimit":{type:"number",default:2,min:0,max:100,hidden:!0},"inspect.code.show":{type:"boolean",default:!0,hidden:!0},"inspect.code.maxNonEmptyLines":{type:"number",default:120,min:1,max:1e4},"inspect.code.meta":{type:"boolean",default:!0,hidden:!0},"inspect.members.maxItems":{type:"number",default:20,min:1,max:1e3},"inspect.members.all":{type:"boolean",default:!1,hidden:!0},"inspect.exports.ranges":{type:"boolean",default:!1,hidden:!0},"inspect.exports.resolveStar":{type:"boolean",default:!1,hidden:!0},"inspect.graph.hubs":{type:"boolean",default:!0},"inspect.graph.entrypoints":{type:"boolean",default:!0},"inspect.graph.leaves":{type:"boolean",default:!0},"inspect.graph.edges":{type:"boolean",default:!0},"inspect.graph.symbols":{type:"boolean",default:!1,hidden:!0},"inspect.graph.symbolUsage":{type:"boolean",default:!1},"inspect.usages.detail":{type:"string",default:"locations",values:["summary","locations","code"],hidden:!0},"inspect.usages.maxLocations":{type:"number",default:12,min:1,max:1e4},"inspect.usages.maxCodeBlocks":{type:"number",default:8,min:1,max:1e4},"inspect.usages.excludeTarget":{type:"boolean",default:!1,hidden:!0}};function M(e){return e.startsWith(Re)}function Ue(e,t){return e?F.run(e,t):t()}function Fe(e,t,n){const s=t[0]??"status",i=(0,N.resolveWorkspaceRoot)(e);if(!i){if(s==="status")return(0,m.attachAgentText)({initialized:!1,active:null,source:"none",available:[],next:"Run aib init"},["session not ready","","No aib.json was found.","Run:","aib init"].join(`
|
|
2
|
+
`));(0,N.resolveRequiredWorkspaceRoot)(e)}const r=i?.root??e;if(Rt(r),s==="init")return dt(r,t.slice(1));if(s==="status")return Dt(r);if(s==="list")return St(r);if(s==="use")return ht(r,t.slice(1));if(s==="where")return mt(r,t.slice(1));if(s==="read")return It(r,t.slice(1),n);if(s==="write")return Je(r,t.slice(1),n);if(s==="prefs")return Be(r,t.slice(1),n);if(s==="aliases")return Me(r,t.slice(1),n);if(s==="clear")return Ct(r);throw new u.CliError("UNKNOWN_SESSION_WORKSPACE_COMMAND",`Unknown session workspace command: ${s}`)}function Me(e,t,n){const s=t[0]??"get";if(s==="get"){const i=A(e),r=(0,b.readConfigPathAliases)(e),o=(0,b.normalizePathAliasMap)(i.pathAliases??{},"session path aliases"),a={aliases:(0,b.effectivePathAliases)(e,o),config:r,session:o};return(0,m.attachAgentText)(a,V(a))}if(s==="set"){const i=A(e),r=t.includes("--stdin")?Ve(n):ze(t.slice(1)),o=(0,b.normalizePathAliasMap)(i.pathAliases??{},"session path aliases"),a={};for(const[d,p]of Object.entries(r)){const S=(0,b.normalizePathAliasName)(d,"session path aliases");if(typeof p!="string"||p.trim()==="")throw new u.CliError("INVALID_PATH_ALIAS_TARGET",`session path alias ${d} must be a non-empty path string.`);o[S]=p.trim().replace(/\\/g,"/"),a[S]=o[S]}i.pathAliases=o,g(e,i);const f={updated:a,aliases:(0,b.effectivePathAliases)(e,o)};return(0,m.attachAgentText)(f,V(f))}if(s==="clear"){const i=A(e),r=t.slice(1).filter(d=>!d.startsWith("--")),o=(0,b.normalizePathAliasMap)(i.pathAliases??{},"session path aliases"),a=[];if(r.length===0)a.push(...Object.keys(o).sort()),delete i.pathAliases;else{for(const d of r){const p=(0,b.normalizePathAliasName)(d,"session path aliases");Object.prototype.hasOwnProperty.call(o,p)&&(a.push(p),delete o[p])}Object.keys(o).length>0?i.pathAliases=o:delete i.pathAliases}g(e,i);const f={cleared:a,aliases:(0,b.effectivePathAliases)(e,i.pathAliases??{})};return(0,m.attachAgentText)(f,V(f))}throw new u.CliError("UNKNOWN_SESSION_ALIASES_COMMAND",`Unknown session aliases command: ${s}`,{expected:"aib session aliases get | set | clear"})}function Ve(e){if(!y(e))throw new u.CliError("INVALID_SESSION_ALIASES_STDIN","session aliases set --stdin expects a JSON object.");const t=y(e.aliases)?e.aliases:e,n={};for(const[s,i]of Object.entries(t))typeof i=="string"&&(n[s]=i);return n}function ze(e){if(e.length===0||e.length%2!==0)throw new u.CliError("SESSION_ALIASES_SET_USAGE","Usage: aib session aliases set <name> <path> [<name> <path>...] or session aliases set --stdin");const t={};for(let n=0;n<e.length;n+=2)t[e[n]??""]=e[n+1]??"";return t}function V(e){if(y(e.updated))return re("aliases.updated",e.updated);if(Array.isArray(e.cleared)){const t=e.cleared.filter(n=>typeof n=="string");return t.length>0?["aliases.cleared",...t].join(`
|
|
3
|
+
`):"aliases.cleared none"}if(y(e.aliases)){const t=re("aliases",e.aliases).split(`
|
|
4
|
+
`);return t.length===1&&t.push("none"),t.join(`
|
|
5
|
+
`)}return null}function re(e,t){const n=[e];for(const[s,i]of Object.entries(t).sort(([r],[o])=>r.localeCompare(o)))n.push(`@${s}/=${String(i)}`);return n.join(`
|
|
6
|
+
`)}function Je(e,t,n){const s=t[0]??"",i=t[1]??"";if(!s||!i)throw new u.CliError("SESSION_WRITE_USAGE","Usage: aib session write <kind> <name> --stdin");if(n===void 0)throw new u.CliError("STDIN_REQUIRED","session write expects JSON on stdin and the --stdin flag.");const r=A(e),o=Z(r,s,i);x(o,n);const a=C(r,"inputs",s,i,o);Ne(r,s,n),g(e,r);const f={written:a.handle,file:h(e,o)},d=ue(e,"session.write.from",`Use with --from ${a.handle}`);return d&&(f.next=d),f}function Be(e,t,n){const s=t[0]??"get";if(s==="get"){const i=A(e),r=t.includes("--all"),o=t.slice(1).find(p=>!p.startsWith("--")),a=r?Ye(i):Ze(i.prefs??{}),f=Ke(a,o),d=r?{prefs:f}:{overrides:f,defaults:"omitted; use session prefs get --all"};return(0,m.attachAgentText)(d,z(d))}if(s==="set"){const i=A(e),r=t.includes("--stdin")?He(n):Ge(t.slice(1)),o=i.prefs??{},a={};for(const[d,p]of Object.entries(r)){const S=oe(d),_=Qe(S,p);o[S]=_,a[S]=_}i.prefs=o,g(e,i);const f={updated:a};return(0,m.attachAgentText)(f,z(f))}if(s==="clear"){const i=A(e),r=t.slice(1).filter(d=>!d.startsWith("--")),o=i.prefs??{},a=[];if(r.length===0)a.push(...Object.keys(o).sort()),delete i.prefs;else{for(const d of r){const p=oe(d);Object.prototype.hasOwnProperty.call(o,p)&&(a.push(p),delete o[p])}Object.keys(o).length>0?i.prefs=o:delete i.prefs}g(e,i);const f={cleared:a};return(0,m.attachAgentText)(f,z(f))}throw new u.CliError("UNKNOWN_SESSION_PREFS_COMMAND",`Unknown session prefs command: ${s}`,{expected:"aib session prefs get | set | clear"})}function Ke(e,t){if(!t)return e;const n={};for(const[s,i]of Object.entries(e))(s===t||s.startsWith(`${t}.`))&&(n[s]=i);return n}function z(e){if(y(e.updated))return J("prefs.updated",e.updated);if(Array.isArray(e.cleared)){const t=e.cleared.filter(n=>typeof n=="string");return t.length>0?["prefs.cleared",...t].join(`
|
|
7
|
+
`):"prefs.cleared none"}if(y(e.overrides)){const t=J("prefs",e.overrides).split(`
|
|
8
|
+
`);return t.length===1&&t.push("no overrides"),typeof e.defaults=="string"&&t.push(e.defaults),t.join(`
|
|
9
|
+
`)}return y(e.prefs)?J("prefs",e.prefs):null}function J(e,t){const n=[e];for(const[s,i]of Object.entries(t).sort(([r],[o])=>r.localeCompare(o)))n.push(`${s}=${String(i)}`);return n.join(`
|
|
10
|
+
`)}function He(e){if(!y(e))throw new u.CliError("INVALID_SESSION_PREFS_STDIN","session prefs set --stdin expects a JSON object.");const t=y(e.prefs)?e.prefs:e,n={};for(const[s,i]of Object.entries(t))n[s]=i;return n}function Ge(e){if(e.length===0||e.length%2!==0)throw new u.CliError("SESSION_PREFS_SET_USAGE","Usage: aib session prefs set <key> <value> [<key> <value>...] or session prefs set --stdin");const t={};for(let n=0;n<e.length;n+=2){const s=e[n]??"",i=e[n+1]??"";t[s]=i}return t}function oe(e){if(Object.prototype.hasOwnProperty.call(O,e))return e;throw new u.CliError("UNKNOWN_SESSION_PREF",`Unknown session preference: ${e}`,{available:Object.keys(O)})}function Qe(e,t){const n=O[e];if(n.type==="boolean"){if(typeof t=="boolean")return t;if(typeof t=="string"){const i=t.trim().toLowerCase();if(i==="true")return!0;if(i==="false")return!1}throw new u.CliError("INVALID_SESSION_PREF_VALUE",`${e} expects true or false.`)}if(n.type==="string"){if(typeof t!="string")throw new u.CliError("INVALID_SESSION_PREF_VALUE",`${e} expects one of: ${n.values.join(", ")}.`);const i=t.trim();if(!n.values.includes(i))throw new u.CliError("INVALID_SESSION_PREF_VALUE",`${e} expects one of: ${n.values.join(", ")}.`);return i}const s=typeof t=="number"?t:typeof t=="string"?Number(t):NaN;if(!Number.isInteger(s)||s<n.min||s>n.max)throw new u.CliError("INVALID_SESSION_PREF_VALUE",`${e} expects an integer from ${n.min} to ${n.max}.`);return s}function Ye(e){const t={};for(const n of Object.keys(O)){const s=O[n];"hidden"in s&&s.hidden||(s.type==="boolean"?t[n]=ce(e,n,s.default):s.type==="number"?t[n]=K(e,n,s.default):t[n]=le(e,n,s.default))}return t}function Ze(e){const t={};for(const[n,s]of Object.entries(e))Xe(n)||(t[n]=s);return t}function Xe(e){if(!Object.prototype.hasOwnProperty.call(O,e))return!1;const t=O[e];return"hidden"in t&&t.hidden===!0}function B(e,t){if(!M(t))return t;const n=A(e),s=Oe(t),i=s.scope==="input"?n.inputs:n.outputs,r=s.scope==="input"?s.kind:s.scope,o=i[r],a=s.name==="last"?o?.last:s.name,f=a?o?.items[a]:void 0;if(!f)throw new u.CliError("SESSION_HANDLE_NOT_FOUND",`Session handle not found: ${t}`,{handle:t,sessionDir:h(e,n.rootDir)});return f.file}function qe(e,t,n,s){const i=A(e),r=Ae(i,t,n,".json");l.mkdirSync(c.dirname(r),{recursive:!0}),l.writeFileSync(r,`${JSON.stringify(s,null,2)}
|
|
11
|
+
`);const o=C(i,"outputs",t,n,r);return g(e,i),{saved:o.handle,last:`aib:${t}:last`,file:h(e,r)}}function et(e,t,n,s,i=".txt"){const r=A(e),o=Ae(r,t,n,i);l.mkdirSync(c.dirname(o),{recursive:!0}),l.writeFileSync(o,s);const a=C(r,"outputs",t,n,o);return g(e,r),{saved:a.handle,last:`aib:${t}:last`,file:h(e,o)}}function tt(e,t,n,s){const i=v(e);if(!i)return null;const r=I(t),o=I(n),a=c.join(i.rootDir,"outputs","result",r,`${o}.json`);return x(a,s),{saved:`aib:result:${r}:${o}`,file:h(e,a)}}function nt(e,t,n){const s=v(e);if(!s)return null;const i=I(t),r=c.join(s.rootDir,"outputs","result",`${i}.json`);return x(r,n),{saved:`aib:${i}`,file:h(e,r)}}function st(e,t){const n=A(e),s=I(t),i=c.join(n.rootDir,"outputs","result",`${s}.json`);if(!l.existsSync(i))throw new u.CliError("SESSION_RESULT_NOT_FOUND",`Result handle not found: aib:${s}`,{handle:`aib:${s}`,sessionDir:h(e,n.rootDir)});const r=JSON.parse(l.readFileSync(i,"utf8"));if(!r||typeof r!="object"||Array.isArray(r))throw new u.CliError("INVALID_SESSION_RESULT",`Result artifact is not a JSON object: aib:${s}`);return r}function it(e,t,n){const s=A(e),i=I(t),r=I(n),o=c.join(s.rootDir,"outputs","result",i,`${r}.json`);if(!l.existsSync(o))throw new u.CliError("SESSION_RESULT_NOT_FOUND",`Result handle not found: aib:result:${i}:${r}`,{handle:`aib:result:${i}:${r}`,sessionDir:h(e,s.rootDir)});const a=JSON.parse(l.readFileSync(o,"utf8"));if(!a||typeof a!="object"||Array.isArray(a))throw new u.CliError("INVALID_SESSION_RESULT",`Result artifact is not a JSON object: aib:result:${i}:${r}`);return a}function rt(e,t,n,s){return ae(e,t,n,s,{format:"json",text:JSON.stringify(s,null,2)})}function ae(e,t,n,s,i){const r=v(e);if(!r)return null;const o=i??{format:"json",text:JSON.stringify(s,null,2)},a=o.format==="dsl"?Z(r,t,n,".dsl"):Z(r,t,n,".json");o.format==="dsl"?(_e(a,o.text),x(Ft(r,t,n),s)):x(a,s);const f=C(r,"inputs",t,n,a);return Ne(r,t,s,o),g(e,r),{handle:f.handle,file:h(e,a)}}function ot(e){return l.existsSync(L(e))}function ue(e,t,n,s=-1){const i=v(e);if(!i)return n;const r=s>=0?s:K(i,"guidance.nextLimit",2),o=i.guidance??{},a=o[t]??{shown:0,limit:r};if(a.limit=r,a.shown>=a.limit){o[t]=a,i.guidance=o,g(e,i);return}return a.shown+=1,o[t]=a,i.guidance=o,g(e,i),n}function at(e,t,n){const s=v(e),i=O[t],r=typeof n=="boolean"?n:i.type==="boolean"?i.default:!1;return s?ce(s,t,r):r}function ut(e,t,n){const s=v(e),i=O[t],r=typeof n=="number"?n:i.type==="number"?i.default:0;return s?K(s,t,r):r}function ct(e,t,n){const s=v(e),i=O[t],r=typeof n=="string"?n:i.type==="string"?i.default:"";return s?le(s,t,r):r}function lt(e){try{const t=v(e);return(0,b.effectivePathAliases)(e,t?.pathAliases??{})}catch(t){if(t instanceof u.CliError&&t.code==="MULTIPLE_AIB_SESSIONS")return(0,b.effectivePathAliases)(e,{});throw t}}function ft(e){try{const t=v(e);return(0,b.normalizePathAliasMap)(t?.pathAliases??{},"session path aliases")}catch(t){if(t instanceof u.CliError&&t.code==="MULTIPLE_AIB_SESSIONS")return{};throw t}}function ce(e,t,n){const s=e.prefs?.[t];return typeof s=="boolean"?s:n}function K(e,t,n){const s=e.prefs?.[t];return typeof s=="number"&&Number.isFinite(s)?s:n}function le(e,t,n){const s=e.prefs?.[t];return typeof s=="string"?s:n}function dt(e,t){const n=w(t,"--dir"),s=Q(e,n,!0),i=w(t,"--name"),r=$(i??Y()??Jt()),o=c.join(s.rootDir,r),a=new Date().toISOString(),d=R(e,r)??{version:1,sessionId:r,cwd:c.resolve(e),rootDir:o,createdAt:a,updatedAt:a,outputs:{},inputs:{},guidance:{}};d.sessionId=r,d.rootDir=o,d.updatedAt=a,me(d),g(e,d),be(e,d,!0);const p=D(e),S=p?Object.keys(p.sessions).length:1,_={session:r,dir:h(e,d.rootDir),sessionDir:h(e,s.rootDir),sessionDirSource:s.source,sessionCount:S,bind:`${E.CLI_ENV.session}=${r}`,next:S===1?"Run AIB commands without -s for now. AIB will tell you if multiple sessions exist.":`Use aib -s ${r} <command> or set ${E.CLI_ENV.session}=${r}.`};return s.ignoredRequestedDir&&(_.note=`${U} from aib.json is in effect; --dir was ignored.`,_.requestedDir=s.ignoredRequestedDir),(0,m.attachAgentText)(_,pt(_))}function pt(e){const t=String(e.session??""),n=String(e.dir??""),s=typeof e.sessionCount=="number"?e.sessionCount:1,i=[`session ready: ${t}`,""];typeof e.note=="string"&&e.note&&(i.push("aib.json sessionDir is in effect; --dir was ignored."),i.push("Next time do not use --dir when creating a session."),i.push(""));const r=n.replace(/[\\/]+$/,"");return i.push(`outputs: ${r}/outputs`),i.push(`inputs: ${r}/inputs`),i.push(""),s===1?(i.push("Only one AIB session exists in this repo."),i.push("You can run AIB commands without -s for now."),i.push("AIB will tell you if multiple sessions exist and you need to choose one.")):(i.push("Multiple AIB sessions exist in this repo."),i.push("Use this session explicitly:"),i.push(`aib -s ${t} <command>`),i.push(""),i.push("Or bind it in this shell:"),i.push(`${E.CLI_ENV.session}=${t}`)),i.join(`
|
|
12
|
+
`)}function St(e){const t=D(e),n=k(e);return{active:n.sessionId??t?.activeSessionId??null,source:n.source,sessions:t?Object.values(t.sessions).sort((s,i)=>s.sessionId.localeCompare(i.sessionId)).map(s=>`${s.sessionId} -> ${h(e,s.rootDir)}`):[]}}function ht(e,t){const n=t[0]??"";if(!n)throw new u.CliError("SESSION_USE_ID_REQUIRED","Usage: aib session use <sessionId>");const s=$(n),i=D(e),r=i?.sessions[s];if(!r)throw new u.CliError("SESSION_NOT_FOUND",`Session not found: ${s}`,{available:i?Object.keys(i.sessions).sort():[]});return T(e,{...i??ge(e),activeSessionId:s}),{session:s,dir:h(e,r.rootDir),bind:`${E.CLI_ENV.session}=${s}`,next:`Use aib -s ${s} <command> or set ${E.CLI_ENV.session}=${s}.`}}function mt(e,t){const n=t[0]??"";if(!n)throw new u.CliError("SESSION_WHERE_HANDLE_REQUIRED","Usage: aib session where <handle>");const s=B(e,n),i={handle:n,file:h(e,s)};return(0,m.attachAgentText)(i,[n,i.file].join(`
|
|
13
|
+
`))}function It(e,t,n){if(t.includes("--stdin")){if(!y(n))throw new u.CliError("INVALID_SESSION_READ_STDIN","session read --stdin expects a JSON object payload.");const r=yt(n);if(r.length===1){const a=H(e,r[0]);return(0,m.attachAgentText)(a,G(a))}const o={reads:r.map(a=>gt(e,a))};return(0,m.attachAgentText)(o,G(o))}const s=t[0]??"";if(!s)throw new u.CliError("SESSION_READ_HANDLE_REQUIRED","Usage: aib session read <handle> [--head <n> | --offset <n> --limit <n>]");const i=H(e,{handle:s,...vt(t.slice(1))});return(0,m.attachAgentText)(i,G(i))}function yt(e){if(Array.isArray(e.reads))return e.reads.map((t,n)=>{if(typeof t=="string"){if(!M(t))throw new u.CliError("INVALID_SESSION_READ_ROW",`session read row at index ${n} must be an aib: handle string or an object.`);return{handle:t}}if(!y(t))throw new u.CliError("INVALID_SESSION_READ_ROW",`session read row at index ${n} must be an aib: handle string or an object.`);return fe(t,n)});if(typeof e.handle=="string"||typeof e.read=="string")return[fe(e,0)];throw new u.CliError("INVALID_SESSION_READ_STDIN","Expected { reads: [{ handle }] } or { handle }.")}function fe(e,t){const n=X(e.handle)??X(e.read);if(!n)throw new u.CliError("SESSION_READ_HANDLE_REQUIRED",`session read row at index ${t} requires handle.`);return{handle:n,...e.rawInput===!0?{rawInput:!0}:{},...pe(e,t)}}function gt(e,t){try{return H(e,t)}catch(n){if(n instanceof u.CliError){const s=y(n.details)?n.details:{};return{read:t.handle,error:n.code,...typeof s.next=="string"?{next:s.next}:{}}}return{read:t.handle,error:"UNEXPECTED_ERROR"}}}function H(e,t){Ot(t);const n=Oe(t.handle),s=B(e,t.handle);if(n.scope==="input"&&!t.rawInput){const r=Nt(n.kind,t.handle);return{read:t.handle,file:h(e,s),next:r?`Edit file, then rerun: ${r}`:"Edit file, then rerun the command with --from <handle>."}}if(n.scope==="graph"||n.scope==="usages"){const r=n.scope==="graph"?`aib inspect graph --from-file ${t.handle} --focus <file>`:`aib inspect usages --from-file ${t.handle} --focus <name>`;throw new u.CliError("SESSION_ARTIFACT_NOT_READABLE",`${n.scope} artifacts are reusable indexes, not agent-readable context.`,{handle:t.handle,kind:n.scope,next:r})}if(n.scope==="duplicates"){const r=l.readFileSync(s,"utf8");return{read:t.handle,content:bt(e,t.handle,s,r,t)}}const i=l.readFileSync(s,"utf8");return{read:t.handle,content:At(s,i,t)}}function bt(e,t,n,s,i){const r=Et(e,t,n,s);return i.head!==void 0||i.offset!==void 0||i.limit!==void 0?Se(r,i):r}function Et(e,t,n,s){let i;try{i=JSON.parse(s)}catch{return de(t,n,s)}if(!y(i))return de(t,n,s);const r=[],o=Array.isArray(i.targetPaths)?i.targetPaths.filter(S=>typeof S=="string"&&S!==""):[],a=o.length===1?h(e,o[0]):o.length>1?`${o.length} scopes`:"";r.push(a?`duplicates ${a}`:"duplicates");const f=typeof i.summary=="string"?i.summary:`${j(i.itemCount)} ${te(j(i.itemCount),"name")}`;r.push(f);const d=Array.isArray(i.items)?i.items.filter(y):[];for(const S of d){const _=typeof S.name=="string"?S.name:"",ve=j(S.declarationCount),ne=j(S.variantCount),se=j(S.exactCopyCount);_&&r.push(`${_} x${ve}, ${ne} ${te(ne,"variant")}${se>0?`, exact x${se}`:""}`)}const p=j(i.hiddenItemCount);return p>0&&r.push(`+ ${p} ${te(p,"name")}`),r.push(`raw: aib session where ${t}`),r.join(`
|
|
14
|
+
`)}function de(e,t,n){return[`saved artifact ${e}`,`${n.length} bytes`,`raw: ${t}`].join(`
|
|
15
|
+
`)}function At(e,t,n){if(n.head!==void 0||n.offset!==void 0||n.limit!==void 0)return Se(t,n);if(c.extname(e).toLowerCase()!==".json")return t;try{return JSON.parse(t)}catch{return t}}function G(e){const t=Array.isArray(e.reads)?e.reads.filter(y):[e];if(t.length===0)return null;const n=[],s=t.length>1;for(const i of t){const r=typeof i.read=="string"?i.read:"",o=i.content,a=_t(o);if(a!==null){s&&r&&n.push(`// ${r}`),n.push(a.trimEnd());continue}if(typeof i.file=="string"){s&&r?n.push(`// ${r}`):r&&n.push(`input ${r}`),n.push(`file: ${i.file}`),typeof i.next=="string"&&n.push(`next: ${i.next}`);continue}const f=typeof i.error=="string"?i.error:"";if(f){s&&r&&n.push(`// ${r}`),n.push(`error: ${f}`),typeof i.next=="string"&&n.push(`next: ${i.next}`);continue}return null}return n.join(`
|
|
16
|
+
`)}function _t(e){return typeof e=="string"?e:e===void 0?null:JSON.stringify(e,null,2)}function Nt(e,t){return e==="inspect"?`aib inspect --from ${t}`:e==="graph"?`aib inspect graph --from ${t}`:e==="rename"?`aib rename preview --from ${t}`:e==="move"?`aib move toFile preview --from ${t}`:e==="refactor"?`aib refactor batch preview --from ${t}`:e==="modulePlan"?`aib modulePlan preview --from ${t}`:e==="imports"?`aib imports normalize preview --from ${t}`:null}function Ot(e){if(e.head!==void 0&&(e.offset!==void 0||e.limit!==void 0))throw new u.CliError("SESSION_READ_RANGE_CONFLICT","Use either head or offset/limit, not both.")}function vt(e){const t={},n=w(e,"--head"),s=w(e,"--offset"),i=w(e,"--limit");return n!==void 0&&(t.head=n),s!==void 0&&(t.offset=s),i!==void 0&&(t.limit=i),{...e.includes("--raw-input")?{rawInput:!0}:{},...pe(t,0)}}function pe(e,t){const n=q(e.head,`session read row at index ${t} has invalid head.`),s=q(e.offset,`session read row at index ${t} has invalid offset.`),i=zt(e.limit,`session read row at index ${t} has invalid limit.`);return{...n!==void 0?{head:n}:{},...s!==void 0?{offset:s}:{},...i!==void 0?{limit:i}:{}}}function Se(e,t){if(t.head===void 0&&t.offset===void 0&&t.limit===void 0)return e;const n=e.split(/\r?\n/),s=t.head!==void 0?0:t.offset??0,i=t.head!==void 0?t.head:t.limit!==void 0?s+t.limit:void 0;return n.slice(s,i).join(`
|
|
17
|
+
`)}function Dt(e){const t=D(e),n=k(e),s=t?Object.keys(t.sessions).sort():[];if(n.source==="ambiguous")return(0,m.attachAgentText)({ok:!1,code:"MULTIPLE_AIB_SESSIONS",error:"Multiple AIB sessions exist. Select one explicitly.",available:s,next:`Use aib -s <session> <command> or set ${E.CLI_ENV.session}=<session>.`},jt(s));const i=n.sessionId?R(e,n.sessionId):null;if(!i){const o={initialized:!1,active:n.sessionId??null,source:n.source,available:s,next:n.sessionId?`Run aib session init --name ${n.sessionId}`:"Run aib session init --name <name>"};return(0,m.attachAgentText)(o,$t(o))}g(e,i);const r={initialized:!0,session:i.sessionId??n.sessionId,active:i.sessionId??n.sessionId,source:n.source,available:s,sessionDir:h(e,i.rootDir),aliases:(0,b.effectivePathAliases)(e,i.pathAliases??{}),latest:Mt(i),dirs:Vt(e,i)};return(0,m.attachAgentText)(r,xt(r))}function $t(e){const t=typeof e.active=="string"&&e.active?e.active:null;return t?["session not ready","",`Session ${t} was not found.`,"Create it:",`aib session init --name ${t}`].join(`
|
|
18
|
+
`):["session not ready","","No AIB sessions exist in this repo.","Create one:","aib session init --name <name>"].join(`
|
|
19
|
+
`)}function xt(e){const t=String(e.session??""),n=e.dirs&&typeof e.dirs=="object"&&!Array.isArray(e.dirs)?e.dirs:{},s=e.aliases&&typeof e.aliases=="object"&&!Array.isArray(e.aliases)?e.aliases:{},i=[`session: ${t}`,`outputs: ${String(n.outputs??"")}`,`inputs: ${String(n.inputs??"")}`],r=Object.entries(s).filter(([,o])=>typeof o=="string"&&o.trim()!=="").sort(([o],[a])=>o.localeCompare(a)).map(([o,a])=>`@${o} -> ${String(a)}`);return r.length>0&&i.push("","aliases:",...r),e.source==="single"&&i.push("","Only one AIB session exists in this repo.","You can run AIB commands without -s."),i.join(`
|
|
20
|
+
`)}function jt(e){return["multiple AIB sessions","","available:",...e,"","Choose one:","aib -s <session> <command>","","Or bind it in this shell:",`${E.CLI_ENV.session}=<session>`,"","If none of these sessions is yours, create a new one:","aib session init --name <name>"].join(`
|
|
21
|
+
`)}function Ct(e){const t=k(e),n=D(e),s=n?Object.keys(n.sessions).sort():[];if(t.source==="ambiguous")return(0,m.attachAgentText)({ok:!1,code:"MULTIPLE_AIB_SESSIONS",error:"Multiple AIB sessions exist. Select one explicitly.",available:s,next:"Use aib -s <session> session clear."},wt(s));const i=t.sessionId?R(e,t.sessionId):null;if(!i)return(0,m.attachAgentText)({cleared:!1,reason:"session-not-initialized"},["No AIB sessions exist in this repo.","","Create one:","aib session init --name <name>"].join(`
|
|
22
|
+
`));he(i,{touch:!0}),g(e,i);const r=i.sessionId??t.sessionId??"";return(0,m.attachAgentText)({cleared:!0,session:r,dir:h(e,i.rootDir)},[`session cleared: ${r}`,"","Inputs and outputs were pruned.","You can keep using this session."].join(`
|
|
23
|
+
`))}function he(e,t){l.rmSync(c.join(e.rootDir,"inputs"),{recursive:!0,force:!0}),l.rmSync(c.join(e.rootDir,"outputs"),{recursive:!0,force:!0}),e.inputs={},e.outputs={},e.guidance={},t.touch&&(e.updatedAt=new Date().toISOString()),me(e)}function wt(e){return["multiple AIB sessions","","available:",...e,"","Clear one explicitly only if it is yours:","aib -s <session> session clear","","If none of these sessions is yours, create a new one:","aib session init --name <name>"].join(`
|
|
24
|
+
`)}function Rt(e){const t=Lt(e),n=D(e);if(!n)return;const s=Date.now();let i=!1;for(const[r,o]of Object.entries(n.sessions)){const a=P(o.rootDir);if(!l.existsSync(a)){delete n.sessions[r],i=!0,n.activeSessionId===r&&delete n.activeSessionId;continue}const f=Date.parse(o.updatedAt);if(!Number.isFinite(f))continue;const d=s-f;if(t.autoDelete&&t.ttlDeleteMs>0&&d>t.ttlDeleteMs){l.rmSync(o.rootDir,{recursive:!0,force:!0}),delete n.sessions[r],i=!0,n.activeSessionId===r&&delete n.activeSessionId;continue}if(t.autoClean&&t.ttlCleanMs>0&&d>t.ttlCleanMs){const p=Ie(e,o.rootDir,r);p&&(he(p,{touch:!1}),Pt(p))}}if(i){if(!n.activeSessionId){const r=Object.keys(n.sessions).sort()[0];r&&(n.activeSessionId=r)}T(e,n)}}function Lt(e){const t=(0,N.readWorkspaceNumberConfig)(e,"session.ttlMinutes",60),n=(0,N.readWorkspaceNumberConfig)(e,"session.ttlDeleteMinutes",t),s=(0,N.readWorkspaceNumberConfig)(e,"session.ttlCleanMinutes",t);return{autoDelete:(0,N.readWorkspaceBooleanConfig)(e,"session.autoDelete",!0),ttlDeleteMs:n>0?n*6e4:0,autoClean:(0,N.readWorkspaceBooleanConfig)(e,"session.autoClean",!0),ttlCleanMs:s>0?s*6e4:0}}function me(e){for(const t of ke)l.mkdirSync(c.join(e.rootDir,"outputs",t),{recursive:!0});for(const t of We)l.mkdirSync(c.join(e.rootDir,"inputs",t),{recursive:!0})}function R(e,t){const s=D(e)?.sessions[t];return s?Ie(e,s.rootDir,t):null}function v(e){const t=Ee(e);return t.sessionId?R(e,t.sessionId):null}function Ie(e,t,n){try{const s=JSON.parse(l.readFileSync(P(t),"utf8"));if(!s||typeof s!="object"||Array.isArray(s))return null;const i=s;return i.version!==1||typeof i.rootDir!="string"?null:(i.sessionId=i.sessionId??n,i)}catch{return null}}function A(e){const t=v(e);if(!t)throw new u.CliError("SESSION_WORKSPACE_NOT_INITIALIZED","Session workspace is not initialized.",{session:Y()??null,next:"Run aib session init --dir .tmp/aib"});return g(e,t),t}function g(e,t){t.updatedAt=new Date().toISOString(),l.mkdirSync(t.rootDir,{recursive:!0}),l.writeFileSync(P(t.rootDir),`${JSON.stringify(t,null,2)}
|
|
25
|
+
`),be(e,t,!1)}function Pt(e){l.mkdirSync(e.rootDir,{recursive:!0}),l.writeFileSync(P(e.rootDir),`${JSON.stringify(e,null,2)}
|
|
26
|
+
`)}function Q(e,t,n=!1){const s=(0,N.resolveWorkspaceRoot)(e),i=s?.root??e,r=s?X(s.config[U]):void 0;if(r)return{rootDir:ye(i,r),source:"aib.json",...t?{ignoredRequestedDir:t}:{}};const a=ye(i,t??je);return n&&s&&(0,N.updateWorkspaceConfig)(i,{[U]:Tt(i,a)}),{rootDir:a,source:t?"request":"default"}}function ye(e,t){const n=c.resolve(e,t);return c.basename(n).toLowerCase()==="aib"?n:c.join(n,"aib")}function Tt(e,t){const n=c.relative(e,t);return n&&!n.startsWith("..")&&!c.isAbsolute(n)?n.replace(/\\/g,"/"):t.replace(/\\/g,"/")}function L(e){return c.join(Q(e).rootDir,Ce)}function kt(e){return c.join(Q(e).rootDir,we)}function P(e){return c.join(e,"session.json")}function D(e){try{const t=JSON.parse(l.readFileSync(L(e),"utf8"));if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t;return n.version!==1||!n.sessions||typeof n.sessions!="object"?null:{version:1,cwd:typeof n.cwd=="string"?n.cwd:c.resolve(e),...typeof n.activeSessionId=="string"?{activeSessionId:n.activeSessionId}:{},sessions:n.sessions}}catch{return null}}function T(e,t){t.cwd=c.resolve((0,N.resolveWorkspaceRoot)(e)?.root??e),l.mkdirSync(c.dirname(L(e)),{recursive:!0}),l.writeFileSync(L(e),`${JSON.stringify(t,null,2)}
|
|
27
|
+
`),Wt(e,t.activeSessionId)}function ge(e){return{version:1,cwd:c.resolve(e),sessions:{}}}function Wt(e,t){const n=kt(e);if(l.mkdirSync(c.dirname(n),{recursive:!0}),!t){l.rmSync(n,{force:!0});return}l.writeFileSync(n,`${JSON.stringify({sessionId:t,updatedAt:new Date().toISOString()},null,2)}
|
|
28
|
+
`)}function be(e,t,n){const s=t.sessionId??Y()??"";if(!s)return;const i=D(e)??ge(e);i.sessions[s]={sessionId:s,rootDir:t.rootDir,createdAt:i.sessions[s]?.createdAt??t.createdAt,updatedAt:t.updatedAt},(n||!i.activeSessionId)&&(i.activeSessionId=s),T(e,i)}function Bt(e,t){const n=D(e);if(!(!n||!t)){if(delete n.sessions[t],n.activeSessionId===t){const s=Object.keys(n.sessions).sort()[0];s?n.activeSessionId=s:delete n.activeSessionId}T(e,n)}}function Ee(e){const t=F.getStore();if(t)return{sessionId:$(t),source:"override"};const n=process.env[E.CLI_ENV.session];if(n&&n.trim())return{sessionId:$(n),source:"env"};const s=process.env[E.CLI_ENV.legacySession];if(s&&s.trim())return{sessionId:$(s),source:"legacy-env"};const i=D(e),r=i?Object.keys(i.sessions).sort():[];if(r.length===1)return{sessionId:r[0],source:"single"};if(r.length>1)throw new u.CliError("MULTIPLE_AIB_SESSIONS","Multiple AIB sessions exist. Select one explicitly.",{available:r,next:`Use aib -s <session> <command> or set ${E.CLI_ENV.session}=<session>.`});return{sessionId:null,source:"none"}}function k(e){try{return Ee(e)}catch(t){if(t instanceof u.CliError&&t.code==="MULTIPLE_AIB_SESSIONS")return{sessionId:null,source:"ambiguous"};throw t}}function Ut(e){const t=k(e);return{sessionId:t.sessionId,sessionSource:t.source}}function Y(){const e=F.getStore();if(e)return $(e);const t=process.env[E.CLI_ENV.session];if(t&&t.trim())return $(t);const n=process.env[E.CLI_ENV.legacySession];return n&&n.trim()?$(n):null}function Ae(e,t,n,s){return c.join(e.rootDir,"outputs",I(t),`${I(n)}${ee(s)}`)}function Z(e,t,n,s=".json"){return c.join(e.rootDir,"inputs",I(t),`${I(n)}${ee(s)}`)}function Ft(e,t,n){return c.join(e.rootDir,"inputs",I(t),`${I(n)}.compiled.json`)}function W(e,t,n=".json"){return c.join(e.rootDir,"inputs",I(t),n===".json"?Te:`_last${ee(n)}`)}function x(e,t){l.mkdirSync(c.dirname(e),{recursive:!0}),l.writeFileSync(e,`${JSON.stringify(t,null,2)}
|
|
29
|
+
`)}function _e(e,t){l.mkdirSync(c.dirname(e),{recursive:!0}),l.writeFileSync(e,t.endsWith(`
|
|
30
|
+
`)?t:`${t}
|
|
31
|
+
`,"utf8")}function Ne(e,t,n,s){const i=I(t),r=s??{format:"json",text:JSON.stringify(n,null,2)},o=r.format==="dsl"?W(e,i,".dsl"):W(e,i,".json");r.format==="dsl"?(_e(o,r.text),x(c.join(e.rootDir,"inputs",i,"_last.compiled.json"),n),l.rmSync(W(e,i,".json"),{force:!0})):(x(o,n),l.rmSync(W(e,i,".dsl"),{force:!0}),l.rmSync(c.join(e.rootDir,"inputs",i,"_last.compiled.json"),{force:!0})),C(e,"inputs",i,Pe,o)}function C(e,t,n,s,i){const r=I(n),o=I(s),a=t==="inputs"?`aib:input:${r}:${o}`:`aib:${r}:${o}`,f=new Date().toISOString(),d=e[t],p=d[r]??{items:{}},S={handle:a,file:i,createdAt:p.items[o]?.createdAt??f,updatedAt:f};return p.items[o]=S,p.last=o,d[r]=p,S}function Oe(e){const t=e.split(":");if(t[0]!=="aib")throw new u.CliError("INVALID_SESSION_HANDLE",`Invalid session handle: ${e}`);if(t[1]==="input"&&t.length===4)return{scope:"input",kind:t[2]??"",name:t[3]??""};if(t.length===3)return{scope:t[1]??"",kind:t[1]??"",name:t[2]??""};throw new u.CliError("INVALID_SESSION_HANDLE",`Invalid session handle: ${e}`,{expected:"aib:<kind>:<name> or aib:input:<kind>:<name>"})}function Mt(e){const t={};for(const[n,s]of Object.entries(e.outputs))s.last&&(t[n]=`aib:${n}:${s.last}`);for(const[n,s]of Object.entries(e.inputs))s.last&&(t[`input:${n}`]=`aib:input:${n}:${s.last}`);return t}function Vt(e,t){return{outputs:h(e,c.join(t.rootDir,"outputs")),inputs:h(e,c.join(t.rootDir,"inputs"))}}function w(e,t){const n=e.indexOf(t);return n>=0?e[n+1]:void 0}function X(e){return typeof e=="string"&&e.trim()!==""?e.trim():void 0}function q(e,t){if(e===void 0)return;const n=typeof e=="number"?e:typeof e=="string"?Number(e):Number.NaN;if(!Number.isInteger(n)||n<0)throw new u.CliError("INVALID_SESSION_READ_RANGE",t);return n}function zt(e,t){if(e===void 0)return;const n=q(e,t);if(n!==void 0){if(n<=0)throw new u.CliError("INVALID_SESSION_READ_RANGE",t);return n}}function y(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function I(e){const t=e.trim().replace(/[^A-Za-z0-9._-]/g,"-").replace(/^-+|-+$/g,"");if(!t)throw new u.CliError("INVALID_SESSION_ARTIFACT_NAME",`Invalid session artifact name: ${e}`);return t}function $(e){const t=e.trim().replace(/[^A-Za-z0-9._-]/g,"-").replace(/^-+|-+$/g,"");if(!t)throw new u.CliError("INVALID_SESSION_ID",`Invalid session id: ${e}`);return t}function Jt(){return`${Le}${Math.random().toString(16).slice(2,8)}`}function ee(e){return(e.startsWith(".")?e:`.${e}`).replace(/[^A-Za-z0-9.]/g,"")||".txt"}function j(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function te(e,t){return e===1?t:`${t}s`}function h(e,t){const n=c.relative(e,t);return n&&!n.startsWith("..")?n.replace(/\\/g,"/"):t}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.extensionRequestOptions=u,exports.resolveTargetInstance=p,exports.resolveCompatibleTargetInstance=g,exports.fetchRuntimeInfo=_,exports.fetchEffectiveConfig=v,exports.assertInstanceCompatible=h;const i=require("../discovery/registry"),c=require("../discovery/select-instance"),f=require("../client/http-client"),b=require("../config/resolve"),o=require("../shared/errors"),y=require("../shared/diagnostics"),I=require("../shared/routes"),l=require("../compatibility/policy"),C=require("../managed-host/serve-web-autostart");function u(e){const t={};return e.transport!==void 0&&(t.transport=e.transport),e.metricsEnabled!==void 0&&(t.metricsEnabled=e.metricsEnabled),t}async function p(e,t={}){if(t.explicitInstanceId)return(0,c.selectInstanceById)((0,i.readRegistryEntries)(),t.explicitInstanceId);const n=t.autoStartIde?.mode!=="serve-web";if(t.autoStartIde?.mode==="serve-web")return await(0,C.startManagedServeWebForCwd)(e),(0,c.selectInstanceForCwd)(m((0,i.readRegistryEntries)()),e,{allowSingleInstanceFallback:!1});const a=(0,i.readRegistryEntries)();try{return(0,c.selectInstanceForCwd)(a,e,{allowSingleInstanceFallback:n})}catch(r){throw!(r instanceof o.CliError)||r.code!=="NO_MATCHING_INSTANCE"?r:E(r)}}function m(e){return e.filter(t=>t.appHost==="server-distro")}async function g(e,t,n={}){const a=await p(e,n),r={command:t,instance:a.entry};n.transport!==void 0&&(r.requestedTransport=n.transport);const s=(0,l.checkCommandCompatibility)(r);if(s.ok)return a;if(n.autoStartIde?.mode==="serve-web"&&n.explicitInstanceId===void 0)return await(0,C.startManagedServeWebForCwd)(e),w(e,t,n,s.error);throw s.error}function w(e,t,n,a){const r=(0,i.readRegistryEntries)().filter(s=>{const d={command:t,instance:s};return n.transport!==void 0&&(d.requestedTransport=n.transport),(0,l.checkCommandCompatibility)(d).ok});try{return(0,c.selectInstanceForCwd)(r,e,{allowSingleInstanceFallback:!1})}catch(s){throw s instanceof o.CliError&&s.code==="NO_MATCHING_INSTANCE"?a:s}}function E(e){const t=e.details&&typeof e.details=="object"&&!Array.isArray(e.details)?{...e.details}:{};return new o.CliError(e.code,e.message,{...t,hints:(0,y.buildAutoStartIdeHints)()})}async function _(e,t={}){return await(0,f.postJson)(e,I.EXTENSION_ROUTES.runtimeInfo,{},u(t))}async function v(e,t={}){const a=(await(0,f.postJson)(e,I.EXTENSION_ROUTES.effectiveConfig,{},u(t))).config;return(0,b.resolveCliConfig)(a??null)}function h(e,t){(0,l.assertCapabilityCompatible)(e,t)}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.runSyncCommand=u;const i=require("../shared/agent-text"),r=require("../config/workspace-state");function u(s,n){const t=n.includes("--status"),e=t?(0,r.workspaceStateStatus)(s):(0,r.syncWorkspaceState)(s),o=e?{ok:!0,synced:!t,state:(0,r.formatWorkspaceStateSummary)(e)}:{ok:!0,synced:!1,state:null};return(0,i.attachAgentText)(o,y(o))}function y(s){const n=s.state;if(!n||typeof n!="object"||Array.isArray(n))return"sync not initialized";const t=n,e=Object.keys(c(t.aliases)?t.aliases:{}).length,o=String(t.tsconfigCount??0),a=s.synced===!1?["sync status",`root: ${String(t.root??"")}`,`config: ${String(t.config??"")}`,`AIB path aliases: ${e}`,`TypeScript configs: ${o}`,`watchers: ${String(t.watchers??"")}`]:["sync ok","config loaded",`AIB path aliases: ${e===0?"none":e}`,`TypeScript configs: ${o}`];return s.synced!==!1&&e===0&&a.push("","If you repeatedly use long paths, add pathAliases to aib.json."),c(t.lastError)&&a.push(`lastError: ${String(t.lastError.code??"SYNC_ERROR")}`),a.join(`
|
|
2
|
+
`)}function c(s){return!!s&&typeof s=="object"&&!Array.isArray(s)}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var v=exports&&exports.__createBinding||(Object.create?(function(e,t,i,n){n===void 0&&(n=i);var s=Object.getOwnPropertyDescriptor(t,i);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,s)}):(function(e,t,i,n){n===void 0&&(n=i),e[n]=t[i]})),x=exports&&exports.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),y=exports&&exports.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(i){var n=[];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[n.length]=s);return n},e(t)};return function(t){if(t&&t.__esModule)return t;var i={};if(t!=null)for(var n=e(t),s=0;s<n.length;s++)n[s]!=="default"&&v(i,t,n[s]);return x(i,t),i}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.runValidateModulePlan=A;const m=y(require("node:fs")),f=y(require("node:path")),_=require("../shared/errors"),S=require("../shared/agent-text"),p=require("./module-plan-cache");function A(e,t){const i=B(t,"--plan")??V(t);if(!i)throw new _.CliError("VALIDATE_MODULE_PLAN_PLAN_REQUIRED","modulePlan validate expects --plan <planId>.");const n=(0,p.readModulePlanRecord)(e,i),s=R(e,n),r=E(e,n),l=[];l.push(...O(e,s)),l.push(...w(e,n,s)),l.push(...r.map(a=>({check:"movedSymbolsAbsentFromSource",entity:a,message:"Moved symbol is still declared in source file."})));const u=l.filter(a=>a.check==="expectedFiles").map(a=>a.file).filter(a=>typeof a=="string"),o=P(s,u,r),g=l.length===0,h={operation:"modulePlan.validate",planId:n.planId,applied:o,ok:g,summary:F(o,s.length,r.length,g),targetFiles:{expected:s.length,missing:u},source:{movedSymbolsRemaining:r},typecheck:"notRun",...l.length>0?{issues:l.slice(0,12)}:{},...o==="no"?{next:`aib modulePlan apply ${n.planId}`}:{}};return(0,S.attachAgentText)(h,$(h))}function $(e){const t=[`modulePlan.validate ${String(e.planId??"")}`.trim()],i=typeof e.applied=="string"?e.applied:null;i&&t.push(`applied: ${i}`),e.ok!==!0&&typeof e.summary=="string"&&t.push(e.summary);const n=c(e.targetFiles)?e.targetFiles:{},s=typeof n.expected=="number"?n.expected:null,r=Array.isArray(n.missing)?n.missing.filter(o=>typeof o=="string"):[];r.length===0&&typeof s=="number"?t.push(`target files exist: ${s}`):r.length>0&&(t.push("missing target files:"),t.push(...r));const l=c(e.source)?e.source:{},u=Array.isArray(l.movedSymbolsRemaining)?l.movedSymbolsRemaining.filter(o=>typeof o=="string"):[];if(u.length>0&&(t.push("symbols still in source:"),t.push(...u)),Array.isArray(e.issues)&&e.issues.length>0){t.push("issues:");for(const o of e.issues.filter(c)){const g=typeof o.check=="string"?o.check:"check",h=typeof o.file=="string"?`${o.file}: `:"",a=typeof o.entity=="string"?`${o.entity}: `:"",b=typeof o.message=="string"?o.message:"";t.push(`${g}: ${h}${a}${b}`)}}return typeof e.next=="string"&&t.push(`next: ${e.next}`),t.join(`
|
|
2
|
+
`)}function F(e,t,i,n){return e==="no"?`${t} target ${t===1?"file":"files"} missing`:e==="partial"?`${i} moved ${i===1?"symbol is":"symbols are"} still in source`:n?`applied; ${t} target ${t===1?"file exists":"files exist"}; moved symbols absent from source`:"applied with validation issues"}function P(e,t,i){return t.length===e.length&&i.length>0?"no":t.length>0||i.length>0?"partial":"yes"}function R(e,t){const i=new Set;if(Array.isArray(t.normalizedRequest.modules))for(const r of t.normalizedRequest.modules.filter(c)){const l=d(r.targetFile);l&&i.add((0,p.resolveCliFilePath)(e,l))}const n=c(t.previewResult.preview)?t.previewResult.preview:{},s=Array.isArray(n.files)?n.files.filter(c):[];for(const r of s){const l=d(r.targetFile);l&&i.add((0,p.resolveCliFilePath)(e,l))}return Array.from(i)}function O(e,t){return t.filter(i=>!m.existsSync(i)).map(i=>({check:"expectedFiles",file:(0,p.formatRelativePath)(e,i),message:"Expected generated file is missing."}))}function w(e,t,i){if(!t.sourceFile)return[];const n=(0,p.resolveCliFilePath)(e,t.sourceFile),s=[];for(const r of i){if(r===n||!m.existsSync(r))continue;const l=N(f.dirname(r),n);D(m.readFileSync(r,"utf8")).includes(l)&&s.push({check:"sourceBackImports",file:(0,p.formatRelativePath)(e,r),message:`Moved module imports from source file: ${l}`})}return s}function E(e,t){if(!t.sourceFile||!m.existsSync(t.sourceFile))return[];const i=m.readFileSync(t.sourceFile,"utf8"),n=[];for(const s of I(t)){const r=M(s);r&&j(i,r)&&n.push(s)}return n}function I(e){const t=Array.isArray(e.normalizedRequest.modules)?e.normalizedRequest.modules.filter(c):[],i=[];for(const n of t){const s=Array.isArray(n.symbols)?n.symbols.filter(c):[];for(const r of s){const l=d(r.raw)??d(r.selector)??d(r.entity);l&&i.push(l)}}return i}function M(e){const t=e.indexOf("-");if(t>=0&&t<e.length-1)return e.slice(t+1);const i=e.indexOf(":");return i>=0&&i<e.length-1?e.slice(i+1):e}function j(e,t){const i=q(t);return new RegExp(`(?:^|\\n)\\s*export\\s+(?:abstract\\s+)?(?:class|interface|type|enum|function|const|let|var)\\s+${i}\\b`).test(e)||new RegExp(`(?:^|\\n)\\s*(?:abstract\\s+)?(?:class|interface|type|enum|function|const|let|var)\\s+${i}\\b`).test(e)}function q(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function D(e){const t=[],i=/\b(?:import|export)\b(?:[\s\S]*?\bfrom\s*)?["']([^"']+)["']/g;let n;for(;(n=i.exec(e))!==null;)n[1]&&t.push(n[1]);return t}function N(e,t){const i=f.join(f.dirname(t),f.basename(t,f.extname(t)));let n=f.relative(e,i).replace(/\\/g,"/");return n.startsWith(".")||(n=`./${n}`),`${n}.js`}function V(e){return e.find((t,i)=>!t.startsWith("--")&&e[i-1]!=="--plan")??null}function B(e,t){const i=e.indexOf(t);if(i<0)return null;const n=e[i+1];return n&&!n.startsWith("--")?n:null}function d(e){return typeof e=="string"&&e.trim()!==""?e.trim():null}function c(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var i=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]})),s=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),c=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(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"&&i(r,e,n[a]);return s(r,e),r}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.workspaceCachePath=h,exports.workspaceCachePathInProductStorageRoot=_;const f=c(require("node:crypto")),o=c(require("node:path")),l=require("../config/product-storage");function h(t,...e){return o.join(d(t),...e)}function _(t,e,...r){return o.join(u(e,t),...r)}function d(t){return u(t,(0,l.productStorageRoot)())}function u(t,e){const r=o.resolve(t),n=f.createHash("sha256").update(r.toLowerCase()).digest("hex").slice(0,16),a=o.basename(r).replace(/[^a-z0-9._-]+/gi,"-")||"workspace";return o.join(e,"workspace-cache",`${a}-${n}`)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_COMPATIBILITY_POLICY=void 0,exports.checkCommandCompatibility=n,exports.assertCommandCompatible=s,exports.assertCapabilityCompatible=l;const i=require("../shared/diagnostic-catalog"),a=require("../shared/protocol");exports.DEFAULT_COMPATIBILITY_POLICY={minimumProtocolVersion:a.SUPPORTED_PROTOCOL_VERSION,allowUnknownProtocolForProtectedCommands:!1,requireCapabilityListForProtectedCommands:!0,exemptCommands:a.COMPATIBILITY_EXEMPT_COMMANDS};function n(o){const e=o.policy??exports.DEFAULT_COMPATIBILITY_POLICY,r=(0,a.getRequiredCapabilityForCommand)(o.command),t=e.exemptCommands.includes(o.command);return t||r===null?{ok:!0,requiredCapability:r,exempt:t}:c(o.instance,e)?m(o.instance,r,e)?o.requestedTransport&&!u(o.instance,o.requestedTransport)?{ok:!1,error:(0,i.transportNotAvailable)(o.instance,o.requestedTransport),requiredCapability:r,exempt:t}:{ok:!0,requiredCapability:r,exempt:t}:{ok:!1,error:(0,i.capabilityNotAvailable)(o.instance,r),requiredCapability:r,exempt:t}:{ok:!1,error:(0,i.protocolVersionUnsupported)(o.instance,r),requiredCapability:r,exempt:t}}function s(o){const e=n(o);if(!e.ok)throw e.error}function l(o,e,r){const t={command:e,instance:o};r!==void 0&&(t.requestedTransport=r),s(t)}function c(o,e){return typeof o.protocolVersion!="number"?e.allowUnknownProtocolForProtectedCommands:o.protocolVersion>=e.minimumProtocolVersion}function m(o,e,r){return Array.isArray(o.capabilities)?o.capabilities.includes(e):!r.requireCapabilityListForProtectedCommands}function u(o,e){return e==="http"?typeof o.host=="string"&&Number.isInteger(o.port):!!o.transports?.websocket?.url}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_AUTO_START_IDE=void 0,exports.parseAutoStartIdeMode=n,exports.resolveAutoStartIdePolicy=s,exports.autoStartIdePolicyFromSession=i;const u=require("../shared/errors"),o=require("./env-vars");exports.DEFAULT_AUTO_START_IDE="serve-web";function n(e){if(typeof e!="string")return null;const r=e.trim().toLowerCase();return r?["1","true","yes","on","serve-web"].includes(r)?"serve-web":["0","false","no","off"].includes(r)?"off":null:null}function s(e){if(e)return{mode:e,source:"flag"};const r=process.env[o.CLI_ENV.autoStartIde],t=n(r);if(r!==void 0&&!t)throw new u.CliError("INVALID_AUTO_START_IDE",`Expected ${o.CLI_ENV.autoStartIde} to be one of: 1, true, yes, on, serve-web, 0, false, no, off.`,{env:o.CLI_ENV.autoStartIde,value:r});return t?{mode:t,source:"env"}:{mode:exports.DEFAULT_AUTO_START_IDE,source:"default"}}function i(e){if(e==null||e==="")return;const r=n(String(e));if(!r)throw new u.CliError("INVALID_AUTO_START_IDE","Expected autoStartIde to be off or serve-web.",{value:String(e)});return{mode:r,source:"session"}}
|
|
@@ -0,0 +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:"-"};
|
|
@@ -0,0 +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"};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.matchesAnyGlob=l,exports.normalizeGlobPath=c;function l(n,o){const e=c(n);return o.some(t=>a(t).test(e))}function c(n){return n.replace(/\\/g,"/").replace(/^\.\//,"")}function a(n){const o=c(n.trim());let e="^";for(let t=0;t<o.length;t+=1){const r=o[t],i=o[t+1],u=o[t+2];if(r==="*"&&i==="*"&&u==="/"){e+="(?:.*/)?",t+=2;continue}if(r==="*"&&i==="*"){e+=".*",t+=1;continue}if(r==="*"){e+="[^/]*";continue}if(r==="?"){e+="[^/]";continue}e+=s(r??"")}return e+="$",new RegExp(e)}function s(n){return n.replace(/[\\^$+?.()|[\]{}]/g,"\\$&")}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var d=exports&&exports.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),b=exports&&exports.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),h=exports&&exports.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(n){var r=[];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[r.length]=i);return r},e(t)};return function(t){if(t&&t.__esModule)return t;var n={};if(t!=null)for(var r=e(t),i=0;i<r.length;i++)r[i]!=="default"&&d(n,t,r[i]);return b(n,t),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.readConfigImportRules=I,exports.normalizeImportRules=m,exports.resolveImportRuleForFile=_,exports.importRulesToJson=y;const p=h(require("node:path")),g=require("./workspace-root"),a=require("../shared/errors");function I(e){const t=(0,g.resolveWorkspaceRoot)(e);return t?m(t.root,t.config.importRules):[]}function m(e,t){if(t==null)return[];if(!Array.isArray(t))throw new a.CliError("AIB_CONFIG_INVALID","aib.json importRules must be an array.",{key:"importRules"});return t.map((n,r)=>j(e,n,r))}function _(e,t){const n=p.resolve(e).toLowerCase();let r=null,i=-1,s=-1;return t.forEach((u,c)=>{const o=p.resolve(u.scopePath).toLowerCase();(n===o||n.startsWith(`${o}${p.sep}`))&&(o.length>s||o.length===s&&c>i)&&(r=u,i=c,s=o.length)}),r}function y(e){return e.map(t=>({scope:t.scope,scopePath:t.scopePath,...t.specifier?{specifier:t.specifier}:{},...t.ending?{ending:t.ending}:{},...t.builtin?{builtin:t.builtin}:{},...t.unusedImports?{unusedImports:t.unusedImports}:{}}))}function j(e,t,n){if(!A(t))throw f(n,"must be an object");const r=w(t.scope);if(!r)throw f(n,"must include non-empty scope");const i={scope:r,scopePath:p.resolve(e,r)},s=l(t.specifier),u=l(t.ending),c=l(t.builtin),o=l(t.unusedImports);if(s!==void 0){if(!v(s))throw f(n,"specifier must be one of shortest, project-relative, relative, non-relative");i.specifier=s}if(u!==void 0){if(!O(u))throw f(n,"ending must be one of auto, minimal, index, js");i.ending=u}if(c!==void 0){if(!P(c))throw f(n,"builtin must be one of preserve, node, bare");i.builtin=c}if(o!==void 0){if(!R(o))throw f(n,"unusedImports must be one of preserve, remove");i.unusedImports=o}return i}function f(e,t){return new a.CliError("AIB_CONFIG_INVALID",`aib.json importRules[${e}] ${t}.`,{key:`importRules[${e}]`})}function v(e){return e==="shortest"||e==="project-relative"||e==="relative"||e==="non-relative"}function O(e){return e==="auto"||e==="minimal"||e==="index"||e==="js"}function P(e){return e==="preserve"||e==="node"||e==="bare"}function R(e){return e==="preserve"||e==="remove"}function w(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function l(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function A(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";var A=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]})),D=exports&&exports.__setModuleDefault||(Object.create?(function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}):function(e,n){e.default=n}),L=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"&&A(t,n,r[i]);return D(t,n),t}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_LOCAL_CLI_CONFIG=exports.LOCAL_CLI_CONFIG_FILE_NAMES=void 0,exports.resolveLocalCliConfig=F;const _=L(require("node:fs")),p=L(require("node:path"));exports.LOCAL_CLI_CONFIG_FILE_NAMES=["aib.json"],exports.DEFAULT_LOCAL_CLI_CONFIG={inspect:{graph:{exclude:[]},tree:{onlyDirs:{exclude:[],include:[]},files:{exclude:[],include:[]}}}};function F(e){const n=x(e);let t=E();const r=[];for(const i of n)for(const c of exports.LOCAL_CLI_CONFIG_FILE_NAMES){const l=p.join(i,c),o=I(l);o&&(t=N(t,o),r.push(l))}return{config:t,sources:r}}function x(e){const n=[];let t=p.resolve(e);const r=p.parse(t).root;for(;n.push(t),t!==r;){const i=p.dirname(t);if(i===t)break;t=i}return n.reverse()}function I(e){if(!_.existsSync(e)||!_.statSync(e).isFile())return null;try{const n=S(_.readFileSync(e,"utf8"));return b(n)}catch{return null}}function b(e){const n=d(e.aib)?e.aib:{},t=d(e.inspect)?e.inspect:void 0,r=d(n.inspect)?n.inspect:void 0,i=t&&d(t.graph)?t.graph:void 0,c=r&&d(r.graph)?r.graph:void 0,l=t&&d(t.tree)?t.tree:void 0,o=r&&d(r.tree)?r.tree:void 0,C=u(e["inspect.graph.exclude"]),h=i?u(i.exclude):[],O=c?u(c.exclude):[],g=f([...h,...O,...C]),a={onlyDirs:{exclude:f([...u(e["inspect.tree.onlyDirs.exclude"]),...u(e["inspect.tree.only_dirs.exclude"]),...s(l,"onlyDirs","exclude"),...s(l,"only_dirs","exclude"),...s(o,"onlyDirs","exclude"),...s(o,"only_dirs","exclude")]),include:f([...u(e["inspect.tree.onlyDirs.include"]),...u(e["inspect.tree.only_dirs.include"]),...s(l,"onlyDirs","include"),...s(l,"only_dirs","include"),...s(o,"onlyDirs","include"),...s(o,"only_dirs","include")])},files:{exclude:f([...u(e["inspect.tree.files.exclude"]),...s(l,"files","exclude"),...s(o,"files","exclude")]),include:f([...u(e["inspect.tree.files.include"]),...s(l,"files","include"),...s(o,"files","include")])}};return g.length===0&&a.onlyDirs.exclude.length===0&&a.onlyDirs.include.length===0&&a.files.exclude.length===0&&a.files.include.length===0?null:{inspect:{graph:{exclude:g},tree:a}}}function s(e,n,t){if(!e)return[];const r=d(e[n])?e[n]:void 0;return r?u(r[t]):[]}function y(e,n){return{exclude:f([...e.exclude,...n?.exclude??[]]),include:f([...e.include,...n?.include??[]])}}function N(e,n){return{inspect:{graph:{exclude:f([...e.inspect.graph.exclude,...n.inspect?.graph?.exclude??[]])},tree:{onlyDirs:y(e.inspect.tree.onlyDirs,n.inspect?.tree?.onlyDirs),files:y(e.inspect.tree.files,n.inspect?.tree?.files)}}}}function E(){return{inspect:{graph:{exclude:[...exports.DEFAULT_LOCAL_CLI_CONFIG.inspect.graph.exclude]},tree:{onlyDirs:{exclude:[...exports.DEFAULT_LOCAL_CLI_CONFIG.inspect.tree.onlyDirs.exclude],include:[...exports.DEFAULT_LOCAL_CLI_CONFIG.inspect.tree.onlyDirs.include]},files:{exclude:[...exports.DEFAULT_LOCAL_CLI_CONFIG.inspect.tree.files.exclude],include:[...exports.DEFAULT_LOCAL_CLI_CONFIG.inspect.tree.files.include]}}}}}function S(e){const n=v(e),t=JSON.parse(n.replace(/,\s*([}\]])/g,"$1"));return d(t)?t:{}}function v(e){let n="",t=!1,r=!1;for(let i=0;i<e.length;i+=1){const c=e[i]??"",l=e[i+1]??"";if(t){n+=c,r?r=!1:c==="\\"?r=!0:c==='"'&&(t=!1);continue}if(c==='"'){t=!0,n+=c;continue}if(c==="/"&&l==="/"){for(;i<e.length&&e[i]!==`
|
|
2
|
+
`;)i+=1;n+=`
|
|
3
|
+
`;continue}if(c==="/"&&l==="*"){for(i+=2;i<e.length&&!(e[i]==="*"&&e[i+1]==="/");)i+=1;i+=1;continue}n+=c}return n}function u(e){return Array.isArray(e)?e.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0):[]}function f(e){return Array.from(new Set(e))}function d(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_MUTATION_COMMENTS_POLICY=void 0,exports.normalizeMutationCommentsPolicy=n,exports.mutationCommentsPolicyToJson=r;const t=require("../shared/errors");exports.DEFAULT_MUTATION_COMMENTS_POLICY={topFileHeader:"preserveInSource"};function n(e){if(e==null)return{...exports.DEFAULT_MUTATION_COMMENTS_POLICY};if(!s(e))throw new t.CliError("AIB_CONFIG_INVALID","aib.json mutationComments must be an object.",{key:"mutationComments"});const o=m(e.topFileHeader);if(o!==void 0&&!i(o))throw new t.CliError("AIB_CONFIG_INVALID","aib.json mutationComments.topFileHeader must be one of preserveInSource, moveWithDeclaration, fail.",{key:"mutationComments.topFileHeader"});return{topFileHeader:o??exports.DEFAULT_MUTATION_COMMENTS_POLICY.topFileHeader}}function r(e){return{topFileHeader:e.topFileHeader}}function i(e){return e==="preserveInSource"||e==="moveWithDeclaration"||e==="fail"}function m(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function s(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}
|
|
@@ -0,0 +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]})),m=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 m(r,e),r}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.readConfigPathAliases=_,exports.effectivePathAliases=O,exports.expandPathAliasesInArgs=w,exports.expandPathAliasesInJson=E,exports.expandPathAliasValue=o,exports.normalizePathAliasMap=f,exports.normalizePathAliasName=p;const l=g(require("node:path")),A=require("./workspace-root"),i=require("../shared/errors"),y="pathAliases",h=new Set(["aib","file","source","target","scope","save","op"]);function _(t){const e=(0,A.resolveWorkspaceRoot)(t);return e?f(e.config[y],"aib.json pathAliases"):{}}function O(t,e={}){return{..._(t),...f(e,"session path aliases")}}function w(t,e,r){return Object.keys(r).length===0?e:e.map(n=>o(t,n,r))}function E(t,e,r){return e===void 0||Object.keys(r).length===0?e:c(t,e,r)}function o(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]??"",s=n[2]??"",u=r[a];if(!u)throw new i.CliError("UNKNOWN_PATH_ALIAS",`Unknown path alias: @${a}`,{alias:a,available:Object.keys(r).sort()});const d=(0,A.resolveWorkspaceRoot)(t)?.root??t;return l.normalize(l.resolve(d,u,s))}function f(t,e){if(t==null)return{};if(!b(t))throw new i.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 s=p(n,e);if(typeof a!="string"||a.trim()==="")throw new i.CliError("INVALID_PATH_ALIAS_TARGET",`${e}.${n} must be a non-empty path string.`);r[s]=a.trim().replace(/\\/g,"/")}return r}function p(t,e){const r=t.trim();if(!/^[A-Za-z][A-Za-z0-9_-]*$/.test(r))throw new i.CliError("INVALID_PATH_ALIAS_NAME",`${e} has invalid alias name: ${t}`,{expected:"Alias names must match /^[A-Za-z][A-Za-z0-9_-]*$/."});if(h.has(r))throw new i.CliError("RESERVED_PATH_ALIAS_NAME",`${e} uses reserved alias name: ${r}`,{alias:r,reserved:Array.from(h).sort()});return r}function c(t,e,r){return typeof e=="string"?o(t,e,r):Array.isArray(e)?e.map(n=>c(t,n,r)):b(e)?Object.fromEntries(Object.entries(e).map(([n,a])=>[n,c(t,a,r)])):e}function b(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var u=exports&&exports.__createBinding||(Object.create?(function(a,e,n,r){r===void 0&&(r=n);var t=Object.getOwnPropertyDescriptor(e,n);(!t||("get"in t?!e.__esModule:t.writable||t.configurable))&&(t={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(a,r,t)}):(function(a,e,n,r){r===void 0&&(r=n),a[r]=e[n]})),p=exports&&exports.__setModuleDefault||(Object.create?(function(a,e){Object.defineProperty(a,"default",{enumerable:!0,value:e})}):function(a,e){a.default=e}),f=exports&&exports.__importStar||(function(){var a=function(e){return a=Object.getOwnPropertyNames||function(n){var r=[];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[r.length]=t);return r},a(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var r=a(e),t=0;t<r.length;t++)r[t]!=="default"&&u(n,e,r[t]);return p(n,e),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildDisplayPathAliases=y,exports.compactDisplayPath=d,exports.compactDisplayPathWithMatch=c,exports.toDisplayPath=o;const s=f(require("node:path")),h=require("./workspace-root");function y(a,e){const r=(0,h.resolveWorkspaceRoot)(a)?.root??a;return Object.entries(e).map(([t,i])=>({token:`@${t}`,prefix:o(a,s.resolve(r,i))})).filter(t=>t.prefix.length>0).sort((t,i)=>i.prefix.length-t.prefix.length||t.token.localeCompare(i.token))}function d(a,e,n){const r=o(a,e);return c(a,e,n).displayPath}function c(a,e,n){const r=o(a,e);let t=null;for(const i of n){if(r!==i.prefix&&!r.startsWith(`${i.prefix}/`))continue;const l=r===i.prefix?i.token:`${i.token}/${r.slice(i.prefix.length+1)}`;(t===null||l.length<t.displayPath.length||l.length===t.displayPath.length&&l.localeCompare(t.displayPath)<0)&&(t={displayPath:l,alias:i})}return!t||t.displayPath.length>=r.length?{displayPath:r,alias:null}:t}function o(a,e){if(!s.isAbsolute(e))return e.replace(/\\/g,"/").replace(/^\.\//,"");const n=s.relative(a,e);return(n&&!n.startsWith("..")&&!s.isAbsolute(n)?n:e).replace(/\\/g,"/")}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var u=exports&&exports.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.productStorageRoot=d,exports.runWithProductStorageOverride=_;const s=u(require("node:os")),t=u(require("node:path")),c=require("node:async_hooks"),a=require("./env-vars"),o="aib",i=new c.AsyncLocalStorage;function d(){const e=i.getStore();if(e)return e;const r=process.env[a.CLI_ENV.productStorageDir];return r&&r.trim()?t.default.resolve(r):process.platform==="win32"&&process.env.LOCALAPPDATA?t.default.join(process.env.LOCALAPPDATA,o):process.env.XDG_STATE_HOME?t.default.join(process.env.XDG_STATE_HOME,o):t.default.join(s.default.homedir(),".local","state",o)}function _(e,r){const n=e?.trim();return n?i.run(t.default.resolve(n),r):r()}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isRemovedAgentCommand=h,exports.resolveCanonicalCommandAlias=p;const r=require("../commands/shared"),c=require("../shared/errors"),M=require("../shared/types"),d=new Set(["doctor","diagnostics","init","runtime","session","sync","trace","observability","feedback","note","generate-docs","config","view","qr"]),a=new Set(M.CANONICAL_METHOD_IDS),l=new Set(["applyModulePlan","validateModulePlan","findImporters","findUnusedImports","moveToFile","renameEntities","refactorBatch","normalizeImports","input"]);function h(e){return l.has(e)}function v(e){const s=new Map;for(const[i,t]of Object.entries(e)){if(!a.has(i)||!t)continue;const n=s.get(t)??[];n.push(i),s.set(t,n)}return s}async function p(e,s,i,t){if(l.has(e)||d.has(e)||a.has(e))return e;try{const n={};i!==void 0&&(n.explicitInstanceId=i),t!==void 0&&(n.autoStartIde=t);const f=await(0,r.resolveTargetInstance)(s,n),u=await(0,r.fetchEffectiveConfig)(f.entry),o=v(u.methodAliases).get(e);if(!o||o.length===0)return e;if(o.length>1)throw new c.CliError("AMBIGUOUS_COMMAND_ALIAS",`Alias "${e}" resolves to multiple commands.`,{alias:e,canonicalCommands:o});const[A]=o;return A??e}catch(n){if(n instanceof c.CliError&&n.code==="AMBIGUOUS_COMMAND_ALIAS")throw n;return e}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveCliConfig=t;const e=require("./defaults"),s=!1;function t(E){return!s||!E?e.DEFAULT_EFFECTIVE_CONFIG:{methodAliases:{...e.DEFAULT_EFFECTIVE_CONFIG.methodAliases,...E.methodAliases},entityKindAliases:{...e.DEFAULT_EFFECTIVE_CONFIG.entityKindAliases,...E.entityKindAliases},selectorSeparator:E.selectorSeparator||e.DEFAULT_EFFECTIVE_CONFIG.selectorSeparator}}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";var b=exports&&exports.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),v=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),m=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[n.length]=o);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),o=0;o<n.length;o++)n[o]!=="default"&&b(r,e,n[o]);return v(r,e),r}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.AIB_CONFIG_FILE_NAME=void 0,exports.initWorkspaceRoot=O,exports.resolveWorkspaceRoot=f,exports.resolveRequiredWorkspaceRoot=M,exports.readWorkspaceNumberConfig=w,exports.readWorkspaceBooleanConfig=h,exports.readWorkspaceStringConfig=S,exports.updateWorkspaceConfig=k,exports.workspaceConfigSummary=D,exports.isPathInsideOrEqual=E;const u=m(require("node:fs")),s=m(require("node:path")),N=require("./env-vars"),I=require("../shared/errors");exports.AIB_CONFIG_FILE_NAME="aib.json";function O(t,e={}){const r=s.join(s.resolve(t),exports.AIB_CONFIG_FILE_NAME),n=u.existsSync(r)?_(r):{},o=a(e.sessionDir)??a(n.sessionDir),d=i(n["session.ttlMinutes"]),g=i(n["session.ttlCleanMinutes"])??d??60,l=i(n["session.ttlDeleteMinutes"])??d??60,c={...n,"workspace.root":a(n["workspace.root"])??".",...o?{sessionDir:o}:{},"session.autoDelete":p(n["session.autoDelete"])??!0,"session.ttlDeleteMinutes":l,"session.autoClean":p(n["session.autoClean"])??!0,"session.ttlCleanMinutes":g,"runtime.managedIdeTtlMinutes":i(n["runtime.managedIdeTtlMinutes"])??15,"runtime.managedIdeWatchdogIntervalMs":i(n["runtime.managedIdeWatchdogIntervalMs"])??3e4,"runtime.autoStopManagedIde":p(n["runtime.autoStopManagedIde"])??!0};u.writeFileSync(r,`${JSON.stringify(c,null,2)}
|
|
2
|
+
`,"utf8");const C=i(c["session.ttlCleanMinutes"])??60,y=i(c["runtime.managedIdeTtlMinutes"])??15;return{created:exports.AIB_CONFIG_FILE_NAME,"workspace.root":a(c["workspace.root"])??".",...o?{sessionDir:o}:{},"session.ttlCleanMinutes":C,"session.ttlDeleteMinutes":i(c["session.ttlDeleteMinutes"])??60,"runtime.managedIdeTtlMinutes":y,next:o?"Now create a session without --dir: aib session init --name <name>":"Set the default session directory: aib config --session-dir .tmp/aib"}}function f(t){const e=a(process.env[N.CLI_ENV.workspaceRoot]);if(e){const g=s.resolve(t,e),l=s.join(g,exports.AIB_CONFIG_FILE_NAME),c=u.existsSync(l)?_(l):{"workspace.root":"."};return{root:g,configPath:l,config:c}}const r=W(t);if(!r)return null;const n=_(r),o=s.dirname(r),d=a(n["workspace.root"])??".";return{root:s.resolve(o,d),configPath:r,config:n}}function M(t){const e=f(t);if(e)return e;const r=A(t,".git");throw new I.CliError("WORKSPACE_ROOT_NOT_INITIALIZED","Workspace root is not initialized.",{cwd:s.resolve(t),...r?{detectedGitRoot:r}:{},next:"Go to your repo root and run: aib init"})}function w(t,e,r){const n=f(t);return(n?i(n.config[e]):null)??r}function h(t,e,r){const n=f(t);return(n?p(n.config[e]):null)??r}function S(t,e,r){const n=f(t);return(n?a(n.config[e]):null)??r}function k(t,e){const r=M(t),n={...r.config,...e};return u.writeFileSync(r.configPath,`${JSON.stringify(n,null,2)}
|
|
3
|
+
`,"utf8"),n}function D(t){const e=i(t["session.ttlMinutes"]);return{"workspace.root":a(t["workspace.root"])??".",...a(t.sessionDir)?{sessionDir:a(t.sessionDir)}:{},"session.ttlCleanMinutes":i(t["session.ttlCleanMinutes"])??e??60,"session.ttlDeleteMinutes":i(t["session.ttlDeleteMinutes"])??e??60,"runtime.managedIdeTtlMinutes":i(t["runtime.managedIdeTtlMinutes"])??15}}function E(t,e){const r=s.resolve(t).toLowerCase(),n=s.resolve(e).toLowerCase();return n===r||n.startsWith(`${r}${s.sep}`)}function W(t){let e=s.resolve(t);const r=s.parse(e).root;for(;;){const n=s.join(e,exports.AIB_CONFIG_FILE_NAME);if(u.existsSync(n)&&u.statSync(n).isFile())return n;if(e===r)break;const o=s.dirname(e);if(o===e)break;e=o}return null}function A(t,e){let r=s.resolve(t);const n=s.parse(r).root;for(;;){if(u.existsSync(s.join(r,e)))return r;if(r===n)break;const o=s.dirname(r);if(o===r)break;r=o}return null}function _(t){try{const e=JSON.parse(u.readFileSync(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch(e){throw new I.CliError("AIB_CONFIG_INVALID","aib.json must be valid JSON.",{file:t,error:e instanceof Error?e.message:String(e)})}}function a(t){return typeof t=="string"&&t.trim()?t.trim():null}function i(t){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"&&t.trim()){const e=Number(t);return Number.isFinite(e)?e:null}return null}function p(t){if(typeof t=="boolean")return t;if(typeof t!="string")return null;const e=t.trim().toLowerCase();return["1","true","yes","on"].includes(e)?!0:["0","false","no","off"].includes(e)?!1:null}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var k=exports&&exports.__createBinding||(Object.create?(function(e,t,r,o){o===void 0&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}):(function(e,t,r,o){o===void 0&&(o=r),e[o]=t[r]})),A=exports&&exports.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),_=exports&&exports.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var o=[];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(o[o.length]=n);return o},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null)for(var o=e(t),n=0;n<o.length;n++)o[n]!=="default"&&k(r,t,o[n]);return A(r,t),r}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.ensureWorkspaceState=M,exports.syncWorkspaceState=d,exports.workspaceStateStatus=q,exports.workspaceStateSummary=F,exports.formatWorkspaceStateSummary=v;const f=_(require("node:fs")),s=_(require("node:path")),E=require("./env-vars"),b=require("./import-rules"),C=require("./mutation-comments"),j=require("./path-aliases"),m=require("./workspace-root"),D=require("../shared/errors"),a=new Map,p=new Map;function M(e){const t=O(e),r=a.get(l(t.root));return r?S(r):R(t)}function d(e){const t=(0,m.resolveRequiredWorkspaceRoot)(e);return g(e,t),R(t)}function R(e){const t=s.resolve(e.root),r=l(t),o=a.get(r);try{const n=(0,j.normalizePathAliasMap)(e.config.pathAliases,"aib.json pathAliases"),h=(0,b.normalizeImportRules)(t,e.config.importRules),u=(0,C.normalizeMutationCommentsPolicy)(e.config.mutationComments),y=K(t),c=process.env[E.CLI_ENV.disableWatchers]==="1",i={root:t,configPath:e.configPath,config:e.config,pathAliases:n,importRules:h,mutationComments:u,tsconfigs:y,lastSyncAt:new Date().toISOString(),watchersStarted:o?.watchersStarted===!0&&o.watchersDisabled===c,watchersDisabled:c,watchers:o?.watchers??[]};return a.set(r,i),g(t,e),!c&&!i.watchersStarted&&L(i),c&&o&&o.watchers.length>0&&(W(o),i.watchers=[],i.watchersStarted=!1),S(i)}catch(n){throw o&&(o.lastError=T(n)),n}}function q(e){const t=O(e),r=a.get(l(t.root));return r?S(r):null}function F(e){const t=d(e);return v(t)}function v(e){return{root:e.root,config:e.configPath,aliases:e.pathAliases,importRules:(0,b.importRulesToJson)(e.importRules),mutationComments:(0,C.mutationCommentsPolicyToJson)(e.mutationComments),tsconfigCount:e.tsconfigs.length,watchers:e.watchersDisabled?"disabled":e.watchersStarted?"started":"not-started",lastSyncAt:e.lastSyncAt,...e.lastError?{lastError:e.lastError}:{}}}function L(e){W(e);const t=[e.configPath,...e.tsconfigs].filter(r=>f.existsSync(r));e.watchers=t.flatMap(r=>{try{return[f.watch(r,{persistent:!1},()=>N(e.root))]}catch{return[]}}),e.watchersStarted=e.watchers.length>0}function W(e){for(const t of e.watchers)try{t.close()}catch{}e.watchers=[],e.watchersStarted=!1,e.debounceTimer&&(clearTimeout(e.debounceTimer),delete e.debounceTimer)}function N(e){const t=a.get(l(e));t&&(t.debounceTimer&&clearTimeout(t.debounceTimer),t.debounceTimer=setTimeout(()=>{const r=a.get(l(e));if(r)try{d(e)}catch(o){r.lastError=T(o)}},100),t.debounceTimer.unref())}function O(e){const t=w(e),r=p.get(t);if(r&&!I(e,r.configPath))return r;const o=(0,m.resolveRequiredWorkspaceRoot)(e);return g(e,o),o}function I(e,t){const r=s.resolve(t).toLowerCase(),o=s.dirname(r);let n=s.resolve(e);const h=s.parse(n).root;for(;;){const u=s.join(n,m.AIB_CONFIG_FILE_NAME);if(f.existsSync(u)&&f.statSync(u).isFile())return s.resolve(u).toLowerCase()!==r;if(n.toLowerCase()===o||n===h)return!1;const c=s.dirname(n);if(c===n)return!1;n=c}}function g(e,t){p.set(w(e),t),p.set(w(t.root),t)}function l(e){return s.resolve(e).toLowerCase()}function w(e){return s.resolve(e).toLowerCase()}function K(e){const t=[];return P(e,0,t),t.sort((r,o)=>r.localeCompare(o))}function P(e,t,r){if(t>5)return;let o;try{o=f.readdirSync(e,{withFileTypes:!0})}catch{return}for(const n of o){if(n.isDirectory()){if(z(n.name))continue;P(s.join(e,n.name),t+1,r);continue}n.isFile()&&/^tsconfig(?:\..+)?\.json$/i.test(n.name)&&r.push(s.join(e,n.name))}}function z(e){return e==="node_modules"||e===".git"||e===".tmp"||e==="dist"||e==="build"||e==="out"}function S(e){return{root:e.root,configPath:e.configPath,config:e.config,pathAliases:e.pathAliases,importRules:[...e.importRules],mutationComments:{...e.mutationComments},tsconfigs:[...e.tsconfigs],lastSyncAt:e.lastSyncAt,watchersStarted:e.watchersStarted,watchersDisabled:e.watchersDisabled,...e.lastError?{lastError:e.lastError}:{}}}function T(e){return e instanceof D.CliError?{code:e.code,message:e.message,...e.details?{details:JSON.parse(JSON.stringify(e.details))}:{}}:{code:"SYNC_ERROR",message:e instanceof Error?e.message:String(e)}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var f=exports&&exports.__createBinding||(Object.create?(function(e,n,r,t){t===void 0&&(t=r);var i=Object.getOwnPropertyDescriptor(n,r);(!i||("get"in i?!n.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return n[r]}}),Object.defineProperty(e,t,i)}):(function(e,n,r,t){t===void 0&&(t=r),e[t]=n[r]})),d=exports&&exports.__setModuleDefault||(Object.create?(function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}):function(e,n){e.default=n}),c=exports&&exports.__importStar||(function(){var e=function(n){return e=Object.getOwnPropertyNames||function(r){var t=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[t.length]=i);return t},e(n)};return function(n){if(n&&n.__esModule)return n;var r={};if(n!=null)for(var t=e(n),i=0;i<t.length;i++)t[i]!=="default"&&f(r,n,t[i]);return d(r,n),r}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveContentRoot=v,exports.collectContentCandidates=u,exports.directoryHasHelp=h;const s=c(require("node:fs")),_=c(require("node:os")),o=c(require("node:path")),a=require("../config/env-vars"),p=require("../shared/errors");function v(){for(const e of u())if(e.valid)return{dir:e.dir,source:e.source};throw new p.CliError("HELP_ASSETS_NOT_FOUND","AIB content assets were not found.",{env:a.CLI_ENV.helpDir,checked:u().map(e=>e.dir)})}function u(){const e=process.env[a.CLI_ENV.helpDir],n=b(),r=o.resolve(__dirname,"..","help"),t=[];return e&&t.push(l(a.CLI_ENV.helpDir,o.resolve(e))),t.push(l("cache",n)),t.push(l("bundled",r)),t}function h(e){return s.existsSync(o.join(e,"bootstrap.md"))&&s.existsSync(o.join(e,"topics"))}function l(e,n){return s.existsSync(n)?s.existsSync(o.join(n,"bootstrap.md"))?s.existsSync(o.join(n,"topics"))?{source:e,dir:n,valid:!0}:{source:e,dir:n,valid:!1,reason:"missing topics"}:{source:e,dir:n,valid:!1,reason:"missing bootstrap.md"}:{source:e,dir:n,valid:!1,reason:"missing"}}function b(){const e=process.env.LOCALAPPDATA?o.join(process.env.LOCALAPPDATA,"aib"):process.env.XDG_CACHE_HOME?o.join(process.env.XDG_CACHE_HOME,"aib"):o.join(_.homedir(),".cache","aib");return o.join(e,"help","current")}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var b=exports&&exports.__createBinding||(Object.create?(function(n,e,i,r){r===void 0&&(r=i);var t=Object.getOwnPropertyDescriptor(e,i);(!t||("get"in t?!e.__esModule:t.writable||t.configurable))&&(t={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(n,r,t)}):(function(n,e,i,r){r===void 0&&(r=i),n[r]=e[i]})),g=exports&&exports.__setModuleDefault||(Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e}),f=exports&&exports.__importStar||(function(){var n=function(e){return n=Object.getOwnPropertyNames||function(i){var r=[];for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(r[r.length]=t);return r},n(e)};return function(e){if(e&&e.__esModule)return e;var i={};if(e!=null)for(var r=n(e),t=0;t<r.length;t++)r[t]!=="default"&&b(i,e,r[t]);return g(i,e),i}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.modulePlanTimelineEnabled=_,exports.recordModulePlanTimeline=y;const l=f(require("node:fs")),c=f(require("node:path")),v=require("../config/env-vars"),d=new Map;function _(){const n=process.env[v.CLI_ENV.modulePlanDebugTimeline];return n==="1"||n==="true"||n==="TRUE"}function y(n,e,i,r={}){if(!_())return;const t=e&&e.trim()?e.trim():"unknown",u=Date.now(),o=d.get(t)??u;d.set(t,o);const p={at:new Date(u).toISOString(),elapsedMs:u-o,pid:process.pid,executionId:t,event:i,...r},a=c.join(n,".tmp","aib","debug");try{l.mkdirSync(a,{recursive:!0});const s=`${JSON.stringify(p)}
|
|
2
|
+
`;l.appendFileSync(c.join(a,`module-plan-timeline-${j(t)}.jsonl`),s),l.appendFileSync(c.join(a,"module-plan-timeline-last.jsonl"),s)}catch{}}function j(n){return n.replace(/[^a-z0-9_-]+/gi,"-")}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";var p=exports&&exports.__createBinding||(Object.create?(function(e,t,n,o){o===void 0&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);(!r||("get"in r?!t.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}):(function(e,t,n,o){o===void 0&&(o=n),e[o]=t[n]})),b=exports&&exports.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),m=exports&&exports.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(n){var o=[];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(o[o.length]=r);return o},e(t)};return function(t){if(t&&t.__esModule)return t;var n={};if(t!=null)for(var o=e(t),r=0;r<o.length;r++)o[r]!=="default"&&p(n,t,o[r]);return b(n,t),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.formatDoctorText=_,exports.formatRuntimeStatusText=v,exports.formatRuntimeStopText=j;const h=m(require("node:fs")),y=m(require("node:path")),$=require("../content/content-bundle");let a;function _(e,t={}){const n=D(e.checks),o=n.filter(u=>u.severity==="required"&&!u.ok),r=n.filter(u=>u.severity==="optional"&&!u.ok),i=e.mode==="runtime-install-gate";return o.length===0?S(n,r,i,t.verbose===!0):O(o,r,t.verbose===!0)}function v(e,t={}){if(e.ok===!1){const o=typeof e.code=="string"?e.code:"MANAGED_IDE_STATUS_FAILED",r=f(o);return["runtime status failed","",`${r.component??"managed runtime"}: failed`,`reason: ${r.reason??String(e.error??"status could not be read")}`,`next: ${r.next??"Run aib runtime status --verbose."}`,...t.verbose===!0?["","details:",JSON.stringify(e,null,2)]:[]].join(`
|
|
2
|
+
`)}if(e.running!==!0)return["runtime stopped","","next: aib doctor --runtime"].join(`
|
|
3
|
+
`);const n=[e.healthy===!0?"runtime running":"runtime unhealthy","",`workspace: ${String(e.workspace??".")}`,`host: ${String(e.host??"managed")}`,`bridge: ${e.healthy===!0?"ok":"not ready"}`];return t.verbose===!0&&n.push("","details:",JSON.stringify(e,null,2)),n.join(`
|
|
4
|
+
`)}function j(e,t={}){if(e.ok===!1){const o=typeof e.code=="string"?e.code:"MANAGED_IDE_STOP_FAILED",r=f(o);return["runtime stop failed","",`${r.component??"managed runtime"}: failed`,`reason: ${r.reason??String(e.error??"runtime could not be stopped")}`,`next: ${r.next??"Run aib runtime status --verbose."}`,...t.verbose===!0?["","details:",JSON.stringify(e,null,2)]:[]].join(`
|
|
5
|
+
`)}const n=[e.stopped===!0?"runtime stopped":"runtime already stopped"];return t.verbose===!0&&n.push("","details:",JSON.stringify(e,null,2)),n.join(`
|
|
6
|
+
`)}function S(e,t,n,o){const r=[n?"aib runtime ready":"aib ready","","cli: ok",`managed runtime assets: ${c(e,["managed-host-assets","extension-vsix","ide-command","managed-runtime-node"])?"ok":"optional"}`,`bundled node: ${c(e,["managed-runtime-node"])?"ok":"not required"}`,`browser: ${c(e,["headless-browser"])?"ok":"missing"}`,`platform: ${c(e,["managed-runtime-platform"])?"ok":"static-only"}`];return n&&r.push(`managed runtime: ${c(e,["managed-runtime-start"])?"started":"not checked"}`,`bridge: ${c(e,["bridge-ping"])?"ok":"not checked"}`,`runtime cleanup: ${c(e,["managed-runtime-stop"])?"ok":"not checked"}`),t.length>0&&r.push("","optional:",...t.map(i=>`${d(i)}: ${l(i)}`)),o&&r.push("","checks:",...e.map(i=>g(i))),r.join(`
|
|
7
|
+
`)}function O(e,t,n){const[o]=e,r=o?f(o.code):{},i=["aib not ready","",`${r.component??d(o)}: failed`,`reason: ${r.reason??l(o)}`,`next: ${r.next??"Run aib doctor --verbose."}`],u=e.slice(1);return u.length>0&&i.push("","also:",...u.map(s=>`${d(s)}: ${l(s)}`)),t.length>0&&i.push("","optional:",...t.map(s=>`${d(s)}: ${l(s)}`)),n?i.push("","checks:",...[...e,...t].map(s=>g(s))):i.push("","details: aib doctor --verbose"),i.join(`
|
|
8
|
+
`)}function D(e){return Array.isArray(e)?e.filter(t=>!!t&&typeof t=="object"):[]}function c(e,t){const n=e.filter(o=>t.includes(o.id));return n.length>0&&n.every(o=>o.ok)}function d(e){if(!e)return"aib";const t=f(e.code);return t.component?t.component:e.id.includes("browser")?"browser":e.id.includes("extension")?"extension":e.id.includes("platform")?"platform":e.id.includes("runtime")||e.id.includes("host")||e.id.includes("ide")?"managed runtime":"cli"}function l(e){return e?f(e.code).reason??e.message:"unknown failure"}function g(e){const t=e.ok?"ok":"failed",n=e.code?` ${e.code}`:"";return`${e.id}: ${t}${n}`}function f(e){return e?w()?.codes?.[e]??{}:{}}function w(){if(a!==void 0)return a;try{const e=(0,$.resolveContentRoot)(),t=y.join(e.dir,"diagnostics","doctor.json"),n=JSON.parse(h.readFileSync(t,"utf8"));a=n&&typeof n=="object"?n:null}catch{a=null}return a}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var l=exports&&exports.__createBinding||(Object.create?(function(e,r,n,t){t===void 0&&(t=n);var i=Object.getOwnPropertyDescriptor(r,n);(!i||("get"in i?!r.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return r[n]}}),Object.defineProperty(e,t,i)}):(function(e,r,n,t){t===void 0&&(t=n),e[t]=r[n]})),d=exports&&exports.__setModuleDefault||(Object.create?(function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}):function(e,r){e.default=r}),c=exports&&exports.__importStar||(function(){var e=function(r){return e=Object.getOwnPropertyNames||function(n){var t=[];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[t.length]=i);return t},e(r)};return function(r){if(r&&r.__esModule)return r;var n={};if(r!=null)for(var t=e(r),i=0;i<t.length;i++)t[i]!=="default"&&l(n,r,t[i]);return d(n,r),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.readRegistryEntries=f,exports.ensureRegistryEntries=h;const u=c(require("node:fs")),y=c(require("node:os")),a=c(require("node:path")),g=require("../shared/errors");function _(){return a.join(y.tmpdir(),"aib","instances")}function b(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch{return!1}}function f(){const e=_();if(!u.existsSync(e))return[];const r=[];for(const n of u.readdirSync(e)){if(!n.endsWith(".json"))continue;const t=a.join(e,n);try{const i=u.readFileSync(t,"utf8"),s=JSON.parse(i);if(typeof s.instanceId=="string"&&Number.isInteger(s.pid)&&Array.isArray(s.workspaceFolders)&&typeof s.host=="string"&&Number.isInteger(s.port)){const o=Number(s.pid);if(!b(o)){u.rmSync(t,{force:!0});continue}r.push({...s,pid:o})}}catch{continue}}return r}function h(){const e=f();if(e.length===0)throw new g.CliError("NO_INSTANCES_FOUND","No running aib extension instances were found.");return e}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var p=exports&&exports.__createBinding||(Object.create?(function(n,e,r,a){a===void 0&&(a=r);var t=Object.getOwnPropertyDescriptor(e,r);(!t||("get"in t?!e.__esModule:t.writable||t.configurable))&&(t={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(n,a,t)}):(function(n,e,r,a){a===void 0&&(a=r),n[a]=e[r]})),g=exports&&exports.__setModuleDefault||(Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e}),w=exports&&exports.__importStar||(function(){var n=function(e){return n=Object.getOwnPropertyNames||function(r){var a=[];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(a[a.length]=t);return a},n(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var a=n(e),t=0;t<a.length;t++)a[t]!=="default"&&p(r,e,a[t]);return g(r,e),r}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.selectInstanceForCwd=_,exports.selectInstanceById=N;const d=w(require("node:path")),s=require("../shared/errors");function u(n){return d.resolve(n).toLowerCase()}function I(n,e){const r=u(n);return e.map(t=>u(t)).filter(t=>r===t||r.startsWith(`${t}${d.sep}`)).sort((t,c)=>c.length-t.length)[0]??null}function _(n,e,r={}){const a=r.allowSingleInstanceFallback!==!1,t=n.map(c=>({entry:c,matchedWorkspace:I(e,c.workspaceFolders)})).filter(c=>c.matchedWorkspace);if(t.length===1){const c=t[0];if(!c)throw new s.CliError("NO_MATCHING_INSTANCE","No matching IDE instance was found.");return{entry:c.entry,matchedWorkspace:c.matchedWorkspace,reason:"cwd-match"}}if(t.length>1){const c=[...t].sort((o,h)=>{const f=o.matchedWorkspace?.length??0;return(h.matchedWorkspace?.length??0)-f}),i=c[0],l=c[1];if(i&&l&&(i.matchedWorkspace?.length??0)>(l.matchedWorkspace?.length??0))return{entry:i.entry,matchedWorkspace:i.matchedWorkspace,reason:"cwd-match"};throw new s.CliError("AMBIGUOUS_INSTANCE_SELECTION","Multiple IDE instances match the current working directory.",{cwd:e,candidates:t.map(o=>({instanceId:o.entry.instanceId,appName:o.entry.appName,port:o.entry.port,workspaceFolders:o.entry.workspaceFolders,matchedWorkspace:o.matchedWorkspace}))})}if(n.length===1&&a){const c=n[0];if(!c)throw new s.CliError("NO_MATCHING_INSTANCE","No matching IDE instance was found.");return{entry:c,matchedWorkspace:c.workspaceFolders[0]??null,reason:"single-instance"}}throw new s.CliError("NO_MATCHING_INSTANCE","No IDE instance matched the current working directory.",{cwd:e,candidates:n.map(c=>({instanceId:c.instanceId,appName:c.appName,port:c.port,workspaceFolders:c.workspaceFolders}))})}function N(n,e){const r=n.find(a=>a.instanceId===e);if(!r)throw new s.CliError("INSTANCE_NOT_FOUND",`IDE instance not found: ${e}`,{instanceId:e,availableInstanceIds:n.map(a=>a.instanceId)});return{entry:r,matchedWorkspace:r.workspaceFolders[0]??null,reason:"single-instance"}}
|
|
@@ -0,0 +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,s={}){if(s.tolerantInspect===!0)return j(e);const t={},n=[],i=[],o=[],r=[],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),r.push(se(p,t,u.lineNumber));continue}if(K.has(f)){c=y(c,"view",u.lineNumber),a.push(re(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(r.length>0)return{command:"imports.normalize",payload:r.length===1?r[0]:{requests:r}};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 s={},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(s,m,T,c);continue}if(L.has(m)){i=y(i,"inspect",c);try{t.push(U(m,T,s,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 r=C(s,t);return n.length>0&&(r.dslDiagnostics=n.map(a=>({line:a.line,message:a.message}))),{command:"inspect",payload:r,...n.length>0?{diagnostics:n}:{}}}function I(e){return e.replace(/^DSL(?: line \d+)?:\s*/,"")}function N(e){return e.split(/\r?\n/).flatMap((s,t)=>{const n=_(s).trim();return n?[{lineNumber:t+1,tokens:O(n,t+1)}]:[]})}function _(e){let s=null;for(let t=0;t<e.length;t+=1){const n=e[t];if((n==='"'||n==="'")&&e[t-1]!=="\\"&&(s=s===n?null:s??n),n==="#"&&s===null)return e.slice(0,t)}return e}function O(e,s){const t=[];let n="",i=null;for(let o=0;o<e.length;o+=1){const r=e[o];if(i){r===i&&e[o-1]!=="\\"?i=null:n+=r;continue}if(r==='"'||r==="'"){i=r;continue}if(/\s/.test(r)){n&&(t.push(n),n="");continue}n+=r}if(i)throw l(s,"Unclosed quote.");return n&&t.push(n),t}function M(e,s,t,n){const i=t.join(" ").trim();if(!i)throw l(n,`${s} requires a value.`);switch(s){case"@file":e.file=i;return;case"@source":{const{value:o,flags:r}=B(t,n,s);e.sourceFile=o,r.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: ${s}`)}}function B(e,s,t){const n=new Set,i=[];for(const r of e){if(r.startsWith("+")&&r.length>1){n.add(r.slice(1));continue}i.push(r)}const o=i.join(" ").trim();if(!o)throw l(s,`${t} requires a value.`);return{value:o,flags:n}}function y(e,s,t){if(e&&e!==s)throw l(t,"Cannot mix inspect, mutation, and imports operations in one DSL document.");return s}function U(e,s,t,n){const{positional:i,fields:o}=S(s,n),r={op:e};if(Object.assign(r,o),e==="file"||e==="exports"||e==="imports"){const a=i[0]??o.file,c=a??t.file;return c&&(r.file=c,a||h(r,w)),r}if(e==="members"){const c=W(r,i,t).map(v);return c.length===1&&!o.entity&&!o.entities?r.entity=c[0]:c.length>0&&!o.entities&&(r.entities=c),r}if(e==="code"||e==="deps"){const c=W(r,i,t).map(v);return e==="deps"&&c.length===1&&!o.entities&&!o.entity?r.entity=c[0]:c.length>0&&!o.entities&&!o.entity&&(r.entities=c),r}if(e==="usages"){const a=o.target??i[0],c=a??t.target??t.file;c&&(r.target=c,a||h(r,A));const u=o.entity??o.entities,p=(c===i[0]?i.slice(1):i).map(v);return!u&&p.length===1?r.entity=p[0]:!u&&p.length>1&&(r.entities=p),r}if(e==="duplicates"){const a=o.scope??i[0],c=a??t.scope;return c&&(r.scope=c,a||h(r,g)),r}if(e==="tree"){const a=o.scope??i[0],c=a??t.scope;return c&&(r.scope=c,a||h(r,g)),r}if(e==="cycles"){const a=o.scope??i[0],c=a??t.scope;return c&&(r.scope=c,a||h(r,g)),r}if(e==="graph"){const a=o.scope??i[0],c=a??t.scope;return c&&!r.fromFile&&(r.scope=c,a||h(r,g)),r}return r}function G(e,s){!e.file&&!e.fromFile&&s.file&&(e.file=s.file,h(e,w))}function W(e,s,t){return!e.file&&!e.fromFile&&s.length>0&&H(s[0])?(e.file=s[0],s.slice(1)):(G(e,t),s)}function H(e){return e.includes("/")||e.includes("\\")||/^@[^/\\]+[/\\]/.test(e)||/\.(?:[cm]?[jt]sx?|d\.ts)$/i.test(e)}function h(e,s){Object.defineProperty(e,s,{value:!0,enumerable:!1})}function S(e,s){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 r=i.slice(0,o),a=i.slice(o+1);x(n,q(r),J(r,a));continue}if(i==="->")throw l(s,"Unexpected move separator in inspect request.");t.push(i)}return{positional:t,fields:n}}function x(e,s,t){const n=e[s];if(n===void 0){e[s]=t;return}if(b(s)){e[s]=[...z(n),...z(t)];return}e[s]=t}function b(e){return e==="focus"||e==="scope"||e==="scopes"||e==="file"||e==="files"||e==="exclude"||e==="excludes"||e==="include"||e==="includes"||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}function J(e,s){const t=X(s),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 s=e.slice(1,-1).trim();return s?F(s):[]}function F(e){const s=[];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()&&s.push(t.trim()),t="";continue}t+=o}return t.trim()&&s.push(t.trim()),s}function X(e){return e==="sum"?"summary":e==="loc"?"locations":e}function v(e){const s=e.match(/^(.+)\.\{(.+)\}$/);if(s){const n=s[1],i=s[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 s=e.match(/^(.+)\.\{(.+)\}$/);if(s){const t=s[1],n=s[2];if(t&&n)return n.split(",").map(i=>i.trim()).filter(Boolean).map(i=>`${t}.${i}`)}return[e]}function C(e,s){const t=s.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 s={...e};for(const t of[w,g,A])e[t]===!0&&h(s,t);return s}function P(e,s,t){if(t.defaultValue===void 0)return;const n=s.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,s){for(const t of s){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,s,t){if(e==="rename"){const i={};for(const o of s){if(o.startsWith(">")&&o.length>1)throw l(t,"Use @save <name> for mutation payload saves.");const r=o.indexOf("->");if(r<=0||r===o.length-2)throw l(t,`Invalid rename pair: ${o}`);i[o.slice(0,r)]=o.slice(r+2)}return{op:"rename",renames:i}}if(s.some(i=>i.startsWith(">")&&i.length>1))throw l(t,"Use @save <name> for mutation payload saves.");const n=s[0];if(typeof n=="string"&&n.endsWith(":")&&n.length>1){const i=s.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 se(e,s,t){const{positional:n,fields:i}=S(e,t),o={...i},r=o.scope??n[0]??s.scope;if(r!==void 0&&(o.scope=r),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 re(e,s){const{positional:t,fields:n}=S(e,s),i=n.handle??n.from??t[0];if(typeof i!="string"||i.length===0)throw l(s,"view requires a result handle.");if(t.length>1)throw l(s,"view accepts one positional handle; use key=value fields for options.");const o={handle:i};for(const[r,a]of Object.entries(n))r==="handle"||r==="from"||(o[r]=a);return o}function oe(e,s){if(e.findIndex(o=>o.endsWith(":"))!==0)throw l(s,"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(s,"Plan row requires target and at least one entity.");return{target:n,entities:i}}function E(e,s,t){if(!e)throw l(t,`${s} is required.`)}function l(e,s){const t=e>0?`DSL line ${e}: `:"DSL: ";return new Error(`${t}${s}`)}function D(e){return Object.fromEntries(Object.entries(e).filter(s=>s[1]!==void 0))}
|