@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,2 @@
|
|
|
1
|
+
"use strict";var s=exports&&exports.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.centralMetricsEnabled=c,exports.mutationImpactMetricsEnabled=p,exports.mutationImpactStreamEnabled=_,exports.startCentralMetricSpan=v,exports.recordCentralMetric=f,exports.resolveCentralMetricsDir=l;const a=s(require("node:fs")),o=s(require("node:path")),n=require("../config/env-vars"),d=require("../config/product-storage"),m=require("../observability/context"),u=require("../observability/config");function c(){const t=process.env[n.CLI_ENV.metrics]?.trim().toLowerCase();return t==="0"||t==="false"||t==="off"?!1:(0,u.resolveObservabilityConfig)().metrics==="on"}function p(){if(!c())return!1;const t=process.env[n.CLI_ENV.mutationImpactMetrics]?.trim().toLowerCase();return t==="0"||t==="false"||t==="off"?!1:t==="1"||t==="true"||t==="on"?!0:(0,u.resolveObservabilityConfig)().mutationImpactMetrics==="on"}function _(){return process.env[n.CLI_ENV.mutationImpactStream]==="1"}function v(t){const r=Date.now(),i=new Date(r).toISOString();return{end(e={}){f({...t,...e,startedAt:i,completedAt:new Date().toISOString(),durationMs:Date.now()-r})}}}function f(t){if(c())try{const r=l(),i=typeof t.cwd=="string"?(0,m.buildCorrelationContext)(t.cwd):{};a.default.mkdirSync(r,{recursive:!0});const e=C({version:1,recordedAt:new Date().toISOString(),pid:process.pid,platform:process.platform,...process.env[n.CLI_ENV.metricsTag]?{tag:process.env[n.CLI_ENV.metricsTag]}:{},...i,...t});a.default.appendFileSync(o.default.join(r,"metrics.jsonl"),`${JSON.stringify(e)}
|
|
2
|
+
`,"utf8")}catch{}}function l(){const t=process.env[n.CLI_ENV.metricsDir];return t&&t.trim()?o.default.resolve(t):o.default.join((0,d.productStorageRoot)(),"metrics")}function C(t){const r={};for(const[i,e]of Object.entries(t))e!=null&&(Array.isArray(e)&&e.length===0||typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0||(r[i]=e));return r}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var b=exports&&exports.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_OBSERVABILITY_CONFIG=void 0,exports.resolveObservabilityConfig=l,exports.traceEnabled=S,exports.failureSnapshotsEnabled=v,exports.defaultTraceWorkspaceDir=h,exports.feedbackFilePath=_,exports.failureSnapshotsRoot=I,exports.observabilityStatus=R;const c=b(require("node:fs")),n=b(require("node:path")),s=require("../config/env-vars"),u=require("../config/product-storage"),y=require("./context");exports.DEFAULT_OBSERVABILITY_CONFIG={metrics:"on",mutationImpactMetrics:"on",trace:"full",failureSnapshots:"on",feedback:"on",retention:{metrics:{maxAgeDays:30,maxTotalMb:512,maxPerWorkspaceMb:128},trace:{maxAgeDays:14,maxTotalMb:512,maxPerWorkspaceMb:128},failureSnapshots:{maxAgeDays:14,maxTotalMb:512,maxPerWorkspaceMb:128,maxFileMb:2,maxFilesPerFailure:5},feedback:{cleanup:"dangerOnly"}}};function l(){const e=JSON.parse(JSON.stringify(exports.DEFAULT_OBSERVABILITY_CONFIG)),t=d(process.env[s.CLI_ENV.metrics]);t&&(e.metrics=t);const r=d(process.env[s.CLI_ENV.mutationImpactMetrics]);r&&(e.mutationImpactMetrics=r);const o=E(process.env[s.CLI_ENV.trace]);o&&(e.trace=o);const a=d(process.env[s.CLI_ENV.failureSnapshots]);return a&&(e.failureSnapshots=a),e}function S(){return l().trace!=="off"}function v(){return l().failureSnapshots==="on"&&S()}function h(e){const t=(0,y.resolveWorkspaceIdentity)(e);return n.default.join((0,u.productStorageRoot)(),"trace","workspaces",t.workspaceId,"runs",D())}function _(){return n.default.join((0,u.productStorageRoot)(),"feedback","feedback.jsonl")}function I(e){const t=(0,y.resolveWorkspaceIdentity)(e);return n.default.join((0,u.productStorageRoot)(),"failure-snapshots","workspaces",t.workspaceId)}function R(e){const t=l(),r=(0,u.productStorageRoot)(),o=h(e),a=_(),i=process.env[s.CLI_ENV.metricsDir]?.trim()?n.default.resolve(process.env[s.CLI_ENV.metricsDir]):n.default.join(r,"metrics"),f=I(e);return{ok:!0,command:"observability",action:"status",productStorageRoot:r,config:t,effective:{metrics:t.metrics,mutationImpactMetrics:t.mutationImpactMetrics,trace:t.trace,failureSnapshots:t.failureSnapshots,feedback:t.feedback},storage:{metricsDir:i,metricsFile:n.default.join(i,"metrics.jsonl"),traceDir:o,feedbackFile:a,failureSnapshotsRoot:f},counters:{metricsRows:k(n.default.join(i,"metrics.jsonl")),metricsBytes:p(n.default.join(i,"metrics.jsonl")),traceBytes:m(n.default.dirname(n.default.dirname(o))),feedbackRows:k(a),feedbackBytes:p(a),failureSnapshotBytes:m(f),failureSnapshotCount:g(f)},cleanup:{enforced:!1,dryRunAvailable:!0,note:"Retention config is visible but automatic cleanup is not enforced yet."}}}function D(){return`run_${new Date().toISOString().replace(/[:.]/g,"-")}_${process.pid}`}function d(e){if(e===void 0)return null;const t=e.trim().toLowerCase();return["0","false","off","disabled","no"].includes(t)?"off":["1","true","on","enabled","yes"].includes(t)?"on":null}function E(e){if(e===void 0)return null;const t=e.trim().toLowerCase();return["0","false","off","disabled","no"].includes(t)?"off":t==="light"?"light":["1","true","on","enabled","yes","full"].includes(t)?"full":null}function p(e){try{return c.default.statSync(e).size}catch{return 0}}function k(e){try{return c.default.readFileSync(e,"utf8").split(/\r?\n/).filter(Boolean).length}catch{return 0}}function m(e){let t=0;try{for(const r of c.default.readdirSync(e,{withFileTypes:!0})){const o=n.default.join(e,r.name);r.isDirectory()?t+=m(o):r.isFile()&&(t+=p(o))}}catch{return 0}return t}function g(e){let t=0;try{for(const r of c.default.readdirSync(e,{withFileTypes:!0}))r.isDirectory()&&(t+=1+g(n.default.join(e,r.name)))}catch{return 0}return t}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var i=exports&&exports.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveWorkspaceIdentity=a,exports.resolveSessionIdentity=c,exports.buildCorrelationContext=d;const r=i(require("node:path")),u=require("node:crypto"),n=require("../config/env-vars"),l=require("../config/workspace-root"),p=require("../commands/session-workspace"),_=require("../shared/errors");function a(e){const o=k(e),s=r.default.resolve(o),t=(0,u.createHash)("sha1").update(s.toLowerCase()).digest("hex").slice(0,12);return{workspaceId:`${r.default.basename(s).replace(/[^A-Za-z0-9._-]/g,"-")||"workspace"}-${t}`,workspacePathHash:t,workspaceRoot:s}}function c(e){try{return(0,p.tryResolveCurrentSessionId)(e)}catch{const o=process.env[n.CLI_ENV.session]?.trim()||process.env[n.CLI_ENV.legacySession]?.trim();return{sessionId:o||null,sessionSource:o?"env":"none"}}}function d(e){const o=a(e),s=c(e);return{workspaceId:o.workspaceId,workspacePathHash:o.workspacePathHash,workspaceRoot:o.workspaceRoot,...s.sessionId?{sessionId:s.sessionId}:{},sessionSource:s.sessionSource}}function k(e){try{return(0,l.resolveWorkspaceRoot)(e)?.root??r.default.resolve(e)}catch(o){if(o instanceof _.CliError&&o.code==="AIB_CONFIG_INVALID")return r.default.resolve(e);throw o}}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var y=exports&&exports.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.captureFailureSnapshot=F;const c=y(require("node:fs")),i=y(require("node:path")),h=require("node:crypto"),f=require("./config"),_=require("./context"),p=new Set(["inspect","imports","move","rename","refactor","modulePlan"]);function F(e){if(!(0,f.failureSnapshotsEnabled)()||e.output.ok!==!1||!p.has(e.command))return null;try{const t=(0,f.resolveObservabilityConfig)().retention.failureSnapshots,n=`fail_${new Date().toISOString().replace(/[:.]/g,"-")}_${(0,h.randomUUID)().slice(0,8)}`,r=i.default.join((0,f.failureSnapshotsRoot)(e.cwd),n),o=j(e.cwd,e.stdinPayload,e.output).slice(0,t.maxFilesPerFailure),a=[];c.default.mkdirSync(r,{recursive:!0});for(const s of o){if(!c.default.existsSync(s)||!c.default.statSync(s).isFile()||c.default.statSync(s).size>t.maxFileMb*1024*1024)continue;const S=A(i.default.relative(e.cwd,s)),u=i.default.join(r,"files",S);c.default.mkdirSync(i.default.dirname(u),{recursive:!0}),c.default.copyFileSync(s,u),a.push(s)}const g={snapshotId:n,createdAt:new Date().toISOString(),highSensitivity:!0,command:e.command,restArgs:e.restArgs,cwd:i.default.resolve(e.cwd),...(0,_.buildCorrelationContext)(e.cwd),...e.traceCallId?{traceCallId:e.traceCallId}:{},...e.traceRunId?{traceRunId:e.traceRunId}:{},request:d(e.stdinPayload),error:{code:typeof e.output.code=="string"?e.output.code:null,error:typeof e.output.error=="string"?e.output.error:null},files:a.map(s=>i.default.relative(e.cwd,s).replace(/\\/g,"/"))};return c.default.writeFileSync(i.default.join(r,"manifest.json"),`${JSON.stringify(g,null,2)}
|
|
2
|
+
`,"utf8"),{snapshotId:n,snapshotDir:r,filesCaptured:a.length}}catch{return null}}function j(e,t,n){const r=new Set;l(t,r),l(n,r);for(const o of["aib.json","tsconfig.json"]){const a=i.default.join(e,o);c.default.existsSync(a)&&r.add(a)}return Array.from(r).map(o=>i.default.resolve(e,o)).filter(o=>m(o))}function l(e,t,n=""){if(typeof e=="string"){(b(n)||m(e))&&t.add(e);return}if(Array.isArray(e)){for(const r of e)l(r,t,n);return}if(!(!e||typeof e!="object"))for(const[r,o]of Object.entries(e))l(o,t,r)}function b(e){return/(?:^|\.)(file|sourceFile|targetFile|facadeFile|configFilePath|inputFile|outputFile)$/i.test(e)}function m(e){return/\.(?:tsx?|jsx?|mts|cts|json)$/i.test(e)}function A(e){const t=e.replace(/^[A-Za-z]:/,"").replace(/\\/g,"/").replace(/\.\./g,"__");return t.startsWith("/")?t.slice(1):t}function d(e){return e===void 0?null:e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:Array.isArray(e)?e.map(d):typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,d(n)])):String(e)}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var c=exports&&exports.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.recordRecentTraceCall=y,exports.readRecentTraceCalls=o;const n=c(require("node:fs")),i=c(require("node:path")),l=require("../config/product-storage"),u=require("./context");function y(t,e){try{const r=s(t),a=o(t),d=[e,...a.filter(f=>f.traceCallId!==e.traceCallId)].slice(0,20);n.default.mkdirSync(i.default.dirname(r),{recursive:!0}),n.default.writeFileSync(r,`${JSON.stringify({calls:d},null,2)}
|
|
2
|
+
`,"utf8")}catch{}}function o(t){try{const e=JSON.parse(n.default.readFileSync(s(t),"utf8"));return Array.isArray(e.calls)?e.calls.filter(_).map(p).filter(r=>r!==null):[]}catch{return[]}}function s(t){const e=(0,u.resolveWorkspaceIdentity)(t);return i.default.join((0,l.productStorageRoot)(),"observability","recent",`${e.workspaceId}.json`)}function p(t){return typeof t.traceCallId!="string"||typeof t.traceDir!="string"||typeof t.command!="string"||typeof t.cwd!="string"||typeof t.startedAt!="string"||typeof t.finishedAt!="string"||typeof t.ok!="boolean"?null:{traceCallId:t.traceCallId,...typeof t.traceRunId=="string"?{traceRunId:t.traceRunId}:{},traceDir:t.traceDir,command:t.command,cwd:t.cwd,startedAt:t.startedAt,finishedAt:t.finishedAt,ok:t.ok,...typeof t.executionId=="string"?{executionId:t.executionId}:{}}}function _(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.readStdinJson=f,exports.readStdinPayload=p,exports.readStdinPayloadWithSource=S,exports.parseStdinPayload=s,exports.parseInputPayloadWithSource=d,exports.stripStdinFormatFlags=y;const i=require("../dsl/aib-dsl"),m=require("../config/env-vars"),a=require("../shared/errors");async function f(e){const r=await u();return s(r,e??{command:"",restArgs:[]})}async function p(e){const r=await u();return s(r,e)}async function S(e){const r=await u();return d(r,e)}function s(e,r){return d(e,r).payload}function d(e,r){const t=e.replace(/^\uFEFF/,"").trim();if(!t)throw new a.CliError("EMPTY_STDIN","Expected JSON or DSL payload on stdin.");if(D(r.format)==="dsl"){const c=l(t,r);return{payload:c.payload,source:{format:"dsl",text:t,command:c.command}}}if(h(t))return{payload:w(t),source:{format:"json",text:t}};const o=l(t,r);return{payload:o.payload,source:{format:"dsl",text:t,command:o.command}}}function y(e){const r=[];let t;for(let n=0;n<e.length;n+=1){const o=e[n];if(o==="--dsl"||o==="--force-dsl"){t="dsl";continue}if(o==="--stdin-format"){const c=e[n+1];if(c!=="auto"&&c!=="dsl")throw new a.CliError("INVALID_STDIN_FORMAT","Expected --stdin-format to be auto or dsl.");t=c,n+=1;continue}o!==void 0&&r.push(o)}return{restArgs:r,...t!==void 0?{format:t}:{}}}function D(e){return e!==void 0?e:process.env[m.CLI_ENV.forceDsl]==="1"?"dsl":"auto"}async function u(){const e=[];for await(const r of process.stdin)e.push(Buffer.isBuffer(r)?r:Buffer.from(String(r)));return Buffer.concat(e).toString("utf8")}function h(e){const r=e[0];return r==="{"||r==="["}function w(e){try{const r=JSON.parse(e);if(!r||typeof r!="object"||Array.isArray(r))throw new a.CliError("INVALID_STDIN_JSON","Expected a JSON object on stdin.");return r}catch(r){throw r instanceof a.CliError?r:new a.CliError("INVALID_STDIN_JSON","Failed to parse JSON from stdin.",{cause:r instanceof Error?r.message:String(r)})}}function l(e,r){const t=I(r.command,r.restArgs);if(!t)throw new a.CliError("STDIN_DSL_UNSUPPORTED",`${r.command||"This command"} does not support DSL stdin. Use JSON for this command.`);let n;try{if(t==="inspect")try{n=(0,i.compileAibDsl)(e)}catch{n=(0,i.compileAibDsl)(e,{tolerantInspect:!0})}else n=(0,i.compileAibDsl)(e)}catch(o){throw new a.CliError("INVALID_STDIN_DSL","Failed to compile DSL from stdin.",{cause:o instanceof Error?o.message:String(o)})}if(n.command!==t&&!_(t,n.command))throw new a.CliError("STDIN_DSL_COMMAND_MISMATCH",`DSL compiles to ${n.command}, but current command expects ${t}.`);return n}function _(e,r){return e==="move.toFile"&&r==="refactor.batch"}function I(e,r){switch(e){case"inspect":return"inspect";case"rename":return"rename";case"modulePlan":return"modulePlan";case"move":return r[0]==="toFile"?"move.toFile":null;case"refactor":return r[0]==="batch"?"refactor.batch":null;case"imports":return r[0]==="normalize"?"imports.normalize":null;case"view":return"view";default:return null}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var f=exports&&exports.__createBinding||(Object.create?(function(r,e,n,t){t===void 0&&(t=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(r,t,i)}):(function(r,e,n,t){t===void 0&&(t=n),r[t]=e[n]})),l=exports&&exports.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),a=exports&&exports.__importStar||(function(){var r=function(e){return r=Object.getOwnPropertyNames||function(n){var t=[];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[t.length]=i);return t},r(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var t=r(e),i=0;i<t.length;i++)t[i]!=="default"&&f(n,e,t[i]);return l(n,e),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.defaultPackageRoot=c,exports.resolveNodeRuntime=p,exports.findPackagedNodeRuntime=s;const o=a(require("node:fs")),u=a(require("node:path")),d=require("../config/env-vars");function c(){return u.resolve(__dirname,"..","..")}function p(r=c()){const e=process.env[d.CLI_ENV.nodePath]?.trim();if(e&&o.existsSync(e)){const t=u.resolve(e);return{command:t,source:"env",path:t}}const n=s(r);return n?{command:n,source:"packaged",path:n}:{command:process.execPath,source:"process",path:process.execPath}}function s(r){const e=m();if(!e)return null;const n=process.platform==="win32"?u.join(r,"runtimes","node",e,"node.exe"):u.join(r,"runtimes","node",e,"bin","node");return o.existsSync(n)?n:null}function m(){const r=process.arch;return process.platform==="win32"&&r==="x64"?"win-x64":process.platform==="linux"&&r==="x64"?"linux-x64":process.platform==="linux"&&r==="arm64"?"linux-arm64":process.platform==="darwin"&&r==="x64"?"darwin-x64":process.platform==="darwin"&&r==="arm64"?"darwin-arm64":null}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var P=exports&&exports.__createBinding||(Object.create?(function(e,n,r,o){o===void 0&&(o=r);var t=Object.getOwnPropertyDescriptor(n,r);(!t||("get"in t?!n.__esModule:t.writable||t.configurable))&&(t={enumerable:!0,get:function(){return n[r]}}),Object.defineProperty(e,o,t)}):(function(e,n,r,o){o===void 0&&(o=r),e[o]=n[r]})),C=exports&&exports.__setModuleDefault||(Object.create?(function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}):function(e,n){e.default=n}),m=exports&&exports.__importStar||(function(){var e=function(n){return e=Object.getOwnPropertyNames||function(r){var o=[];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(o[o.length]=t);return o},e(n)};return function(n){if(n&&n.__esModule)return n;var r={};if(n!=null)for(var o=e(n),t=0;t<o.length;t++)o[t]!=="default"&&P(r,n,o[t]);return C(r,n),r}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.COMMAND_INPUT_CAPABILITIES=void 0,exports.resolveCommandInputSource=v,exports.getCommandInputCapability=O,exports.commandRequiresPayload=D;const E=m(require("node:fs")),y=m(require("node:path")),M=require("../commands/json-file-input"),S=require("../commands/session-workspace"),h=require("../payloads/read-stdin-json"),u=require("../shared/errors"),L={stdin:!1,fromJson:!1,fromJsonMode:"central",requiredPayload:!1};exports.COMMAND_INPUT_CAPABILITIES={inspect:{stdin:!0,fromJson:!0,fromJsonMode:"command",requiredPayload:!1},move:{stdin:!0,fromJson:!0,fromJsonMode:"central",requiredPayload:!0,allowNoPayload:e=>e[0]==="help"||e[0]==="--help"||e[1]==="help"||e[1]==="--help"||e[0]==="toFile"&&e[1]==="apply"&&typeof e[2]=="string"&&!e[2].startsWith("--"),invalidJsonCode:"INVALID_MOVE_TO_FILE_JSON_FILE"},rename:{stdin:!0,fromJson:!0,fromJsonMode:"central",requiredPayload:!0,allowNoPayload:e=>e.includes("--help")||e[0]==="help"||e.includes("--preview")||e.includes("--preview-id")||e[0]==="preview"&&typeof e[1]=="string"&&typeof e[2]=="string"&&typeof e[3]=="string"||e[0]==="validate"&&typeof e[1]=="string"&&typeof e[2]=="string"&&typeof e[3]=="string"||e[0]==="apply"&&typeof e[1]=="string"&&!e[1].startsWith("--"),invalidJsonCode:"INVALID_RENAME_ENTITIES_JSON_FILE"},refactor:{stdin:!0,fromJson:!0,fromJsonMode:"central",requiredPayload:!0,allowNoPayload:e=>e[0]==="help"||e[0]==="--help"||e[1]==="help"||e[1]==="--help"||e[0]==="batch"&&e[1]==="apply"&&typeof e[2]=="string"&&!e[2].startsWith("--"),invalidJsonCode:"INVALID_REFACTOR_BATCH_JSON_FILE"},modulePlan:{stdin:!0,fromJson:!0,fromJsonMode:"command",requiredPayload:!1},imports:{stdin:!0,fromJson:!0,fromJsonMode:"central",requiredPayload:!1,invalidJsonCode:"INVALID_NORMALIZE_IMPORTS_JSON_FILE"},moveToFile:{stdin:!0,fromJson:!0,fromJsonMode:"central",requiredPayload:!1,invalidJsonCode:"INVALID_MOVE_TO_FILE_JSON_FILE"},renameEntities:{stdin:!0,fromJson:!0,fromJsonMode:"central",requiredPayload:!1,invalidJsonCode:"INVALID_RENAME_ENTITIES_JSON_FILE"},refactorBatch:{stdin:!0,fromJson:!0,fromJsonMode:"central",requiredPayload:!1,invalidJsonCode:"INVALID_REFACTOR_BATCH_JSON_FILE"},session:{stdin:!0,fromJson:!1,fromJsonMode:"central",requiredPayload:!1},view:{stdin:!0,fromJson:!0,fromJsonMode:"central",requiredPayload:!1,invalidJsonCode:"INVALID_VIEW_INPUT_FILE"}};async function v(e){const{command:n,cwd:r,restArgs:o,preResolvedPayload:t,preResolvedSource:a,readStdinJson:c,readStdinInput:I}=e,i=O(n),_=o.includes("--stdin"),d=p(o,"--from-json"),s=p(o,"--from-dsl"),f=p(o,"--from");if(Number(_)+ +(d!==null)+ +(s!==null)+ +(f!==null)>1)throw new u.CliError("INPUT_SOURCE_CONFLICT",`Use only one input source for ${n}: --stdin, --from, --from-json, or --from-dsl.`);if(_&&!i.stdin)throw new u.CliError("INPUT_STDIN_UNSUPPORTED",`${n} does not support --stdin input.`);if((d!==null||s!==null||f!==null)&&!i.fromJson)throw new u.CliError("INPUT_FROM_UNSUPPORTED",`${n} does not support file input.`);if(t!==void 0)return{kind:f!==null?"from":s!==null?"from-dsl":d!==null?"from-json":"stdin",payload:T(t,n),...a!==void 0?{source:a}:{},capability:i};if(_){if(I){const l=await I();return{kind:"stdin",payload:l.payload,source:l.source,capability:i}}if(!c)throw new u.CliError("STDIN_REQUIRED",`${n} expects JSON on stdin and the --stdin flag.`);return{kind:"stdin",payload:await c(),capability:i}}if(d!==null)return i.fromJsonMode==="command"?{kind:"delegated-from-json",capability:i}:{kind:"from-json",payload:(0,M.readJsonObjectFile)(r,d,i.invalidJsonCode??"INVALID_COMMAND_JSON_FILE"),source:{format:"json",text:J(r,d,i.invalidJsonCode??"INVALID_COMMAND_JSON_FILE")},capability:i};if(s!==null){const l=N(r,s,n,o,"dsl",i.invalidJsonCode??"INVALID_COMMAND_DSL_FILE");return{kind:"from-dsl",payload:l.payload,source:l.source,capability:i}}if(f!==null){const l=N(r,f,n,o,"auto",i.invalidJsonCode??"INVALID_COMMAND_INPUT_FILE");return{kind:"from",payload:l.payload,source:l.source,capability:i}}return{kind:"none",capability:i}}function N(e,n,r,o,t,a){const c=J(e,n,a);return(0,h.parseInputPayloadWithSource)(c,{command:r,restArgs:o,...t==="dsl"?{format:"dsl"}:{}})}function J(e,n,r){const o=(0,S.resolveSessionFileArgument)(e,n),t=y.isAbsolute(o)?o:y.resolve(e,o);try{return E.readFileSync(t,"utf8")}catch(a){throw new u.CliError(r,`Failed to read input file: ${n}`,{file:n,error:a instanceof Error?a.message:String(a)})}}function O(e){return exports.COMMAND_INPUT_CAPABILITIES[e]??L}function D(e,n,r){return r.capability.requiredPayload===!0&&r.payload===void 0&&r.kind!=="delegated-from-json"&&r.capability.allowNoPayload?.(n)!==!0}function T(e,n){if(e&&typeof e=="object"&&!Array.isArray(e))return e;throw new u.CliError("INVALID_COMMAND_JSON_PAYLOAD",`${n} expects a JSON object payload.`)}function p(e,n){const r=e.indexOf(n);if(r<0)return null;const o=e[r+1];return o&&!o.startsWith("--")?o:null}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var l=exports&&exports.__createBinding||(Object.create?(function(e,n,t,i){i===void 0&&(i=t);var r=Object.getOwnPropertyDescriptor(n,t);(!r||("get"in r?!n.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return n[t]}}),Object.defineProperty(e,i,r)}):(function(e,n,t,i){i===void 0&&(i=t),e[i]=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}),c=exports&&exports.__importStar||(function(){var e=function(n){return e=Object.getOwnPropertyNames||function(t){var i=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[i.length]=r);return i},e(n)};return function(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var i=e(n),r=0;r<i.length;r++)i[r]!=="default"&&l(t,n,i[r]);return d(t,n),t}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.ensureManagedRuntimeProvisioned=p,exports.isManagedRuntimeComplete=f;const o=c(require("node:fs")),u=c(require("node:path")),m=require("node:child_process");function p(e){if(f(e))return;const n=u.join(e,"scripts","provision-runtime.cjs");o.existsSync(n)&&(0,m.spawnSync)(process.execPath,[n,"--quiet"],{cwd:e,env:process.env,encoding:"utf8",stdio:["ignore","pipe","pipe"],windowsHide:!0,timeout:6e5})}function f(e){return o.existsSync(u.join(e,"runtimes","code-server","node_modules","code-server","out","node","entry.js"))&&!!w(e)&&!!h(e)}function h(e){const n=_();if(!n)return null;const t=process.platform==="win32"?u.join(e,"runtimes","node",n,"node.exe"):u.join(e,"runtimes","node",n,"bin","node");return o.existsSync(t)?t:null}function _(){const e=process.arch;return process.platform==="win32"&&e==="x64"?"win-x64":process.platform==="linux"&&e==="x64"?"linux-x64":process.platform==="linux"&&e==="arm64"?"linux-arm64":process.platform==="darwin"&&e==="x64"?"darwin-x64":process.platform==="darwin"&&e==="arm64"?"darwin-arm64":null}function w(e){const n=[u.join(e,"runtimes","browser"),u.join(e,"runtimes","chrome"),u.join(e,"runtimes","chromium")],t=process.platform==="win32"?new Set(["chrome.exe","chromium.exe","msedge.exe"]):new Set(["chrome","chromium"]);for(const i of n){const r=a(i,t,5);if(r)return r}return null}function a(e,n,t){if(!o.existsSync(e)||t<0)return null;let i;try{i=o.readdirSync(e,{withFileTypes:!0})}catch{return null}for(const r of i){const s=u.join(e,r.name);if(r.isFile()&&n.has(r.name))return s}for(const r of i){if(!r.isDirectory())continue;const s=a(u.join(e,r.name),n,t-1);if(s)return s}return null}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.runCommand=$;const P=require("../commands/list-instances"),b=require("../commands/ping"),k=require("../commands/runtime-info"),S=require("../commands/print-config"),x=require("../commands/init-skill-usage"),R=require("../commands/init-workspace"),A=require("../commands/inspect"),c=require("../commands/captured-input"),E=require("../commands/module-plan-command"),D=require("../commands/rename-command"),N=require("../commands/move-command"),O=require("../commands/refactor-command"),U=require("../commands/imports-command"),W=require("../commands/execution-command"),T=require("../commands/observability-command"),M=require("../commands/help-command"),F=require("../commands/generate-docs-command"),j=require("../commands/feedback-command"),Q=require("../commands/doctor"),G=require("../commands/diagnostics-command"),H=require("../commands/session-workspace"),I=require("../commands/session-workspace"),v=require("../config/path-aliases"),J=require("../commands/runtime-command"),K=require("../commands/sync-command"),l=require("../client/transport-options"),m=require("../shared/errors"),p=require("./input-source"),L=require("../config/workspace-state");async function $(n){return(0,I.runWithSessionOverride)(n.sessionId,()=>z(n))}async function z(n){const{command:o,restArgs:d,cwd:r,instanceId:_,metricsSpans:g}=n,u=B(o)?(0,L.ensureWorkspaceState)(r):null,w=u?(0,I.readSessionPathAliasOverrides)(r):{},f={...u?.pathAliases??{},...w},e=(0,v.expandPathAliasesInArgs)(r,d,f),a=await(0,p.resolveCommandInputSource)({command:o,cwd:r,restArgs:e,...n.stdinPayload!==void 0?{preResolvedPayload:(0,v.expandPathAliasesInJson)(r,n.stdinPayload,f)}:{},...n.stdinInputSource!==void 0?{preResolvedSource:n.stdinInputSource}:{}}),s=a.payload,t={};_!==void 0&&(t.explicitInstanceId=_),n.autoStartIde!==void 0&&(t.autoStartIde=n.autoStartIde),n.transport!==void 0&&(t.transport=n.transport),n.metricsEnabled===!0&&(t.metricsEnabled=!0),u&&(t.importRules=u.importRules,t.mutationComments=u.mutationComments);const C=(0,l.getPreferredTransport)();n.transport&&(0,l.setPreferredTransport)(n.transport);try{switch(o){case"doctor":return(0,Q.runDoctor)({cwd:r,runtime:e.includes("--runtime"),verbose:e.includes("--verbose"),json:e.includes("--json")});case"diagnostics":return await(0,G.runDiagnosticsCommand)(e),{ok:!0,command:"diagnostics"};case"session":return(0,H.runSessionWorkspaceCommand)(r,e,s);case"init":return(0,R.runInitWorkspace)(r,d);case"help":return(0,M.runHelpCommand)(e);case"generate-docs":return(0,F.runGenerateDocsCommand)(r,d);case"sync":return(0,K.runSyncCommand)(r,e);case"observability":return(0,T.runObservabilityCommand)(r,e);case"feedback":case"note":return(0,j.runFeedbackCommand)(r,d,o);case"runtime":return(0,J.runRuntimeCommand)(r,e);case"imports":return(0,c.attachCapturedInput)(r,"imports",s,await(0,U.runImportsCommand)(r,e,s,t,g),a.source);case"listInstances":return(0,P.runListInstances)();case"ping":return(0,b.runPing)(r,t);case"runtimeInfo":return(0,k.runRuntimeInfo)(r,t);case"printConfig":return(0,S.runPrintConfig)(r,t);case"initSkillUsage":case"init-skill-usage":{const i=e.findIndex(h=>h==="--cli-name"),q=i>=0&&e[i+1]?e[i+1]:"aib",y={cwd:r,cliName:q??"aib"};return y.resolveOptions=t,(0,x.runInitSkillUsage)(y)}case"inspect":return(0,c.attachCapturedInput)(r,e[0]==="graph"?"graph":"inspect",s,await(0,A.runInspect)(r,e,s,t),a.source);case"modulePlan":return(0,c.attachCapturedInput)(r,"modulePlan",s,await(0,E.runModulePlanCommand)(r,e,s,t,n.modulePlanExecutionId?{executionId:n.modulePlanExecutionId}:{}),a.source);case"execution":return(0,W.runExecutionCommand)(r,e);case"rename":{if(!(e[0]==="apply"&&typeof e[1]=="string"&&!e[1].startsWith("--"))&&(0,p.commandRequiresPayload)(o,e,a))throw new m.CliError("STDIN_REQUIRED","rename preview/apply/validate expects a payload on stdin or --from, except preview-id apply/help.");return(0,c.attachCapturedInput)(r,"rename",s,await(0,D.runRenameCommand)(r,e,s,t),a.source)}case"move":{if(!(e[0]==="toFile"&&e[1]==="apply"&&typeof e[2]=="string"&&!e[2].startsWith("--"))&&(0,p.commandRequiresPayload)(o,e,a))throw new m.CliError("STDIN_REQUIRED","move toFile preview/apply/validate expects a payload on stdin or --from.");return(0,c.attachCapturedInput)(r,"move",s,await(0,N.runMoveCommand)(r,e,s,t),a.source)}case"refactor":{if(!(e[0]==="batch"&&e[1]==="apply"&&typeof e[2]=="string"&&!e[2].startsWith("--"))&&(0,p.commandRequiresPayload)(o,e,a))throw new m.CliError("STDIN_REQUIRED","refactor batch preview/apply/validate expects a payload on stdin or --from, except preview-id apply/help.");return(0,c.attachCapturedInput)(r,"refactor",s,await(0,O.runRefactorCommand)(r,e,s,t),a.source)}default:throw new m.CliError("UNKNOWN_COMMAND",`Unknown command: ${o}`,{availableCommands:["doctor","diagnostics","listInstances","ping","runtimeInfo","printConfig","init-skill-usage","init","help","generate-docs","sync","inspect","imports","execution","move","rename","refactor","modulePlan","session","runtime","trace","observability","feedback","note"]})}}finally{(0,l.setPreferredTransport)(C)}}function B(n){return n!=="init"&&n!=="help"&&n!=="generate-docs"&&n!=="observability"&&n!=="feedback"&&n!=="note"&&n!=="runtime"&&n!=="diagnostics"&&n!=="doctor"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.parseEntitySelectors=p;const s=require("../shared/errors"),a=require("../shared/types");function d(r,n){const e=r.trim();if(!e)throw new s.CliError("INVALID_ENTITY_SELECTOR","Entity selector cannot be empty.");const t=l(e,n.selectorSeparator,n);if(t)return t;const i=l(e,":",n);if(i)return i;const o=l(e,"-",n);return o||{raw:e,symbolName:e,symbolKind:null}}function l(r,n,e){const t=r.indexOf(n);if(t<=0)return null;const i=r.slice(0,t),o=r.slice(t+n.length).trim();if(!o)throw new s.CliError("INVALID_ENTITY_SELECTOR",`Invalid entity selector: ${r}`);const c=f(i,e);return c?{raw:r,symbolName:o,symbolKind:c}:null}function f(r,n){if(u(r))return r;const e=Object.entries(n.entityKindAliases).find(([,i])=>i===r);if(!e)return null;const[t]=e;return u(t)?t:null}function u(r){return a.ENTITY_KIND_IDS.includes(r)}function p(r,n){const e=Array.isArray(r)?r:r.split(/\s+/).map(t=>t.trim()).filter(Boolean);if(e.length===0)throw new s.CliError("MISSING_ENTITIES","At least one entity selector is required.");return e.map(t=>d(t,n))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var b=exports&&exports.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,s)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),O=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 s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[n.length]=s);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),s=0;s<n.length;s++)n[s]!=="default"&&b(r,e,n[s]);return O(r,e),r}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.readSessionInfo=c,exports.removeSessionInfo=p,exports.isProcessAlive=u,exports.isSessionHealthy=h,exports.getSessionStatus=I,exports.stopSession=m,exports.ensureSession=_,exports.startSession=P,exports.callSession=j;const f=g(require("node:fs")),v=g(require("node:path")),A=require("node:child_process"),w=require("../shared/errors"),o=require("../shared/metrics"),N=require("../runtime/bundled-node"),d=require("./paths");function c(){try{const t=JSON.parse(f.readFileSync((0,d.getSessionInfoPath)(),"utf8"));if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t;return typeof e.pid!="number"||typeof e.host!="string"||typeof e.port!="number"||typeof e.url!="string"||typeof e.startedAt!="string"?null:{pid:e.pid,host:e.host,port:e.port,url:e.url,startedAt:e.startedAt}}catch{return null}}function p(){f.rmSync((0,d.getSessionInfoPath)(),{force:!0}),f.rmSync((0,d.getSessionUrlPath)(),{force:!0})}function u(t){if(!Number.isInteger(t)||t<=0)return!1;try{return process.kill(t,0),!0}catch{return!1}}async function h(t){try{return(await fetch(`${t.url}/health`)).ok}catch{return!1}}async function I(){const t=c();if(!t)return{ok:!0,running:!1};const e=u(t.pid),r=e?await h(t):!1;return{ok:!0,running:e&&r,processAlive:e,healthy:r,session:{pid:t.pid,host:t.host,port:t.port,url:t.url,startedAt:t.startedAt}}}async function m(){const t=c();if(!t)return{ok:!0,stopped:!1,reason:"session-not-found"};let e=!1;if(u(t.pid))try{process.kill(t.pid),e=!0}catch{e=!1}return p(),{ok:!0,stopped:e,pid:t.pid}}async function _(t){const e=c();if(e&&u(e.pid)){const i=(0,o.metricsNow)(),y=await h(e);if((0,o.recordSpan)(t,"cli.session.healthCheckExisting",i),y)return e}p(),f.mkdirSync((0,d.getSessionDir)(),{recursive:!0});const r=v.resolve(__dirname,"..","bin","aib.js"),n=(0,N.resolveNodeRuntime)(),s=(0,o.metricsNow)();(0,A.spawn)(n.command,[r,"session","serve"],{detached:!0,stdio:"ignore",windowsHide:!0}).unref(),(0,o.recordSpan)(t,"cli.session.spawnProcess",s);const l=Date.now()+1e4,a=(0,o.metricsNow)();for(;Date.now()<l;){const i=c();if(i&&u(i.pid)&&await h(i))return(0,o.recordSpan)(t,"cli.session.waitForHealthy",a),i;await new Promise(y=>setTimeout(y,250))}throw new w.CliError("SESSION_START_TIMEOUT","Timed out waiting for the aib CLI session to start.")}async function P(){const t=await _();return{ok:!0,running:!0,session:{pid:t.pid,host:t.host,port:t.port,url:t.url,startedAt:t.startedAt}}}async function j(t,e){const r=(0,o.metricsNow)(),n=await _(e);(0,o.recordSpan)(e,"cli.session.ensure",r);let s;const S=(0,o.metricsNow)();try{s=await fetch(`${n.url}/run`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}),(0,o.recordSpan)(e,"cli.session.request",S)}catch(a){throw(0,o.recordSpan)(e,"cli.session.request",S),p(),new w.CliError("SESSION_TRANSPORT_ERROR","Failed to reach the local aib CLI session.",{cause:a instanceof Error?a.message:String(a)})}const l=await s.text();try{return JSON.parse(l)}catch{throw new w.CliError("SESSION_INVALID_JSON","The local aib CLI session returned non-JSON output.",{responseText:l})}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var u=exports&&exports.__createBinding||(Object.create?(function(r,e,n,t){t===void 0&&(t=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(r,t,i)}):(function(r,e,n,t){t===void 0&&(t=n),r[t]=e[n]})),c=exports&&exports.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),s=exports&&exports.__importStar||(function(){var r=function(e){return r=Object.getOwnPropertyNames||function(n){var t=[];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[t.length]=i);return t},r(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var t=r(e),i=0;i<t.length;i++)t[i]!=="default"&&u(n,e,t[i]);return c(n,e),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSessionDir=o,exports.getSessionInfoPath=b,exports.getSessionUrlPath=g;const a=s(require("node:os")),f=s(require("node:path")),l=require("../config/env-vars");function o(){const r=process.env[l.CLI_ENV.cliSessionDir]?.trim();if(r)return f.resolve(r);const e=f.resolve(__dirname,"..","bin","aib.js"),n=process.platform==="win32"?e.toLowerCase():e,t=_(n);return f.join(a.tmpdir(),"aib",`cli-session-${t}`)}function _(r){let e=0xcbf29ce484222325n;const n=0x100000001b3n,t=0xffffffffffffffffn;for(const i of Buffer.from(r,"utf8"))e^=BigInt(i),e=e*n&t;return e.toString(16).slice(0,12)}function b(){return f.join(o(),"cli-session.json")}function g(){return f.join(o(),"cli-session.url")}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";var ee=exports&&exports.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var s=Object.getOwnPropertyDescriptor(t,n);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,s)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),te=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 s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[r.length]=s);return r},e(t)};return function(t){if(t&&t.__esModule)return t;var n={};if(t!=null)for(var r=e(t),s=0;s<r.length;s++)r[s]!=="default"&&ee(n,t,r[s]);return te(n,t),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.CliSessionServer=void 0,exports.runSessionServerCli=Ce;const x=H(require("node:fs")),ne=H(require("node:http")),re=require("../shared/agent-text"),oe=require("../shared/event-loop"),g=require("../shared/errors"),S=require("../shared/metrics"),se=require("../shared/stdout"),U=require("../shared/presentation"),ie=require("../tracing/trace"),V=require("../runtime/run-command"),ae=require("../config/resolve-command-alias"),D=require("../config/auto-start-ide"),a=require("../config/env-vars"),ue=require("../client/transport-options"),N=require("./paths"),O=require("../commands/module-plan-cache"),de=require("../commands/execution-command"),R=require("../payloads/read-stdin-json"),A=require("../commands/module-plan-timeout"),d=require("../diagnostics/module-plan-timeline"),G=require("../commands/mutation-execution-cache"),ce=!1,le=!1;function me(e){x.mkdirSync((0,N.getSessionDir)(),{recursive:!0}),x.writeFileSync((0,N.getSessionInfoPath)(),JSON.stringify(e,null,2)),x.writeFileSync((0,N.getSessionUrlPath)(),`${e.url}
|
|
2
|
+
`)}function fe(){x.rmSync((0,N.getSessionInfoPath)(),{force:!0}),x.rmSync((0,N.getSessionUrlPath)(),{force:!0})}async function k(e){const t=[];for await(const n of e)t.push(Buffer.isBuffer(n)?n:Buffer.from(String(n)));return Buffer.concat(t).toString("utf8")}function E(e,t,n){const r=JSON.stringify(n,null,2);e.writeHead(t,{"content-type":"application/json; charset=utf-8","content-length":Buffer.byteLength(r)}),e.end(r)}function C(e,t){if(e.destroyed||e.writableEnded)return;e.write(`${JSON.stringify(t)}
|
|
3
|
+
`);const n=e;typeof n.flush=="function"&&n.flush()}function pe(e,t,n,r){if(e!==null)return(0,R.parseStdinPayload)(e,{command:t,restArgs:n,...r!==void 0?{format:r}:{}})}function Se(e,t,n,r){if(e!==null)return(0,R.parseInputPayloadWithSource)(e,{command:t,restArgs:n,...r!==void 0?{format:r}:{}}).source}function Pe(e){if(e==null)return;if(!e||typeof e!="object"||Array.isArray(e))throw new g.CliError("INVALID_SESSION_REQUEST","Invalid stdin input source.");const t=e;if(t.format!=="json"&&t.format!=="dsl"||typeof t.text!="string")throw new g.CliError("INVALID_SESSION_REQUEST","Invalid stdin input source.");return{format:t.format,text:t.text}}function J(e){if(e==null||e==="")return;const t=(0,ue.parseExtensionTransport)(e);if(!t)throw new g.CliError("INVALID_TRANSPORT","Expected transport to be either http or websocket.");return t}function Ie(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t=new Set([a.CLI_ENV.managedHostScript,a.CLI_ENV.managedHostKind,a.CLI_ENV.managedHostRunDir,a.CLI_ENV.codeServerPath,a.CLI_ENV.extensionVsix,a.CLI_ENV.ideCommand,a.CLI_ENV.chromePath,a.CLI_ENV.managedHostWaitMs,a.CLI_ENV.workspaceRoot,a.CLI_ENV.disableWatchers,a.CLI_ENV.trace,a.CLI_ENV.traceDir,a.CLI_ENV.failureSnapshots,a.CLI_ENV.productStorageDir,a.CLI_ENV.metrics,a.CLI_ENV.metricsDir,a.CLI_ENV.metricsTag,a.CLI_ENV.mutationImpactMetrics,a.CLI_ENV.mutationImpactStream,a.CLI_ENV.testMoveToFileFailEntity,a.CLI_ENV.testPostMutationCyclesDelayMs,a.CLI_ENV.testRefactorBatchDelayMs,a.CLI_ENV.testRenameDelayMs,a.CLI_ENV.modulePlanSyncWaitMs,a.CLI_ENV.refactorBatchSyncWaitMs,a.CLI_ENV.renameSyncWaitMs,a.CLI_ENV.modulePlanDebugTimeline]),n={};for(const[r,s]of Object.entries(e))t.has(r)&&typeof s=="string"&&(n[r]=s);return n}async function F(e,t){const n=Object.entries(e);if(n.length===0)return t();const r=new Map;for(const[s,i]of n)r.set(s,process.env[s]),process.env[s]=i;try{return await t()}finally{for(const[s,i]of r)i===void 0?delete process.env[s]:process.env[s]=i}}async function W(e,t,n){return(0,d.recordModulePlanTimeline)(e.cwd,e.modulePlanExecutionId,"session.deadline.wait.start",{deadlineMs:n}),(0,G.waitForMutationDeadline)(t.then(r=>((0,d.recordModulePlanTimeline)(e.cwd,e.modulePlanExecutionId,"session.deadline.runPromise.resolved"),r)),n,()=>(0,d.recordModulePlanTimeline)(e.cwd,e.modulePlanExecutionId,"session.deadline.timer.fired",{deadlineMs:n}))}function j(e){if(e.command!=="modulePlan")return 0;const t=e.restArgs[0]??"";return t!=="execute"&&t!=="apply"?0:(0,G.readMutationSyncWaitMs)(process.env[a.CLI_ENV.modulePlanSyncWaitMs],12e4)}async function B(e,t){const n=e.modulePlanExecutionId??"last";await(0,oe.yieldToEventLoop)();let r;try{(0,d.recordModulePlanTimeline)(e.cwd,n,"session.inProgress.status.read.start",{elapsedMs:t}),r=(0,de.runExecutionCommand)(e.cwd,["status",n]),(0,d.recordModulePlanTimeline)(e.cwd,n,"session.inProgress.status.read.end",{status:typeof r.status=="string"?r.status:null,phase:typeof r.phase=="string"?r.phase:null,summary:typeof r.summary=="string"?r.summary:null})}catch{(0,d.recordModulePlanTimeline)(e.cwd,n,"session.inProgress.status.read.failed",{elapsedMs:t}),r={operation:"execution.status",executionId:n,status:"running",summary:"in progress"}}const s=Z(e),i=s?s.estimatedDurationMs-t:null,o=ye(r,e,i);return(0,re.attachAgentText)({...r,operation:r.operation??"execution.status",executionId:n,status:r.status??"running",...i!==null?{estimatedRemainingMs:Math.max(0,i)}:{}},o)}function ye(e,t,n){const r=typeof e.executionId=="string"?e.executionId:t.modulePlanExecutionId??"last",i=[`modulePlan.${t.restArgs[0]??"execute"} ${r}`];return typeof e.summary=="string"&&e.summary.length>0&&i.push(e.summary),e.phase==="preview"&&i.push("previewing plan"),e.phase==="mutation"&&i.push("applying mutation"),e.phase==="postMutation.cycles"&&(i.push("mutation completed"),i.push("checking cycles")),i.push(`status: aib execution status ${r}`),n!==null&&i.push(n>0?`estimated remaining: ${(0,A.formatModulePlanTimeoutEstimate)(Math.max(n,5e3))}`:"estimated remaining: check status again soon"),i.join(`
|
|
4
|
+
`)}class K{server;constructor(){this.server=ne.createServer((t,n)=>{this.handleRequest(t,n)})}async handleRequest(t,n){if(t.method==="GET"&&t.url==="/health"){E(n,200,{ok:!0,pid:process.pid});return}if(t.method==="POST"&&t.url==="/run")try{const r=await k(t),s=r?JSON.parse(r):{};if(typeof s.command!="string"||!Array.isArray(s.restArgs)||typeof s.cwd!="string")throw new g.CliError("INVALID_SESSION_REQUEST","Invalid session request payload.");const i=Pe(s.stdinInputSource),o={command:s.command,restArgs:s.restArgs.filter(p=>typeof p=="string"),cwd:s.cwd,stdinPayload:s.stdinPayload,metricsEnabled:s.metricsEnabled===!0};i!==void 0&&(o.stdinInputSource=i);const u=J(s.transport),f=Ie(s.env);u&&(o.transport=u),o.autoStartIde=(0,D.autoStartIdePolicyFromSession)(s.autoStartIde)??(0,D.resolveAutoStartIdePolicy)();const c=o.metricsEnabled?[]:void 0;c&&(o.metricsSpans=c),typeof s.instanceId=="string"&&(o.instanceId=s.instanceId),typeof s.sessionId=="string"&&(o.sessionId=s.sessionId),typeof s.modulePlanExecutionId=="string"&&(o.modulePlanExecutionId=s.modulePlanExecutionId),s.suppressModulePlanStreamStart===!0&&(o.suppressModulePlanStreamStart=!0);const I=(0,S.metricsNow)(),y=F(f,()=>(0,V.runCommand)(o)).then(p=>((0,S.recordSpan)(c,"session.runCommand",I),p),p=>{throw(0,S.recordSpan)(c,"session.runCommand",I),p}),l=j(o);if(l>0){const p=await W(o,y,l);if(p.status==="deadline"){y.catch(()=>{}),(0,d.recordModulePlanTimeline)(o.cwd,o.modulePlanExecutionId,"session.run.deadline.output.start",{deadlineMs:l});const v=await B(o,l);(0,d.recordModulePlanTimeline)(o.cwd,o.modulePlanExecutionId,"session.run.response.write.start",{mode:"deadline"}),E(n,200,v),(0,d.recordModulePlanTimeline)(o.cwd,o.modulePlanExecutionId,"session.run.response.write.end",{mode:"deadline"});return}const P=p.result;(0,d.recordModulePlanTimeline)(o.cwd,o.modulePlanExecutionId,"session.run.response.write.start",{mode:"result"}),E(n,200,c?(0,S.appendMetrics)(P,c):P),(0,d.recordModulePlanTimeline)(o.cwd,o.modulePlanExecutionId,"session.run.response.write.end",{mode:"result"});return}const m=await y;(0,d.recordModulePlanTimeline)(o.cwd,o.modulePlanExecutionId,"session.run.response.write.start",{mode:"no-deadline"}),E(n,200,c?(0,S.appendMetrics)(m,c):m),(0,d.recordModulePlanTimeline)(o.cwd,o.modulePlanExecutionId,"session.run.response.write.end",{mode:"no-deadline"});return}catch(r){E(n,500,(0,g.errorPayload)(r));return}if(t.method==="POST"&&t.url==="/cli"){let r=null,s=0,i=null;try{i=await X(t),(0,d.recordModulePlanTimeline)(i.input.cwd,i.input.modulePlanExecutionId,"session.cli.request.parsed",{command:i.input.command,args:i.input.restArgs}),s=Date.now(),r=Y(i,s);const o=i.env,u=(0,S.metricsNow)();(0,d.recordModulePlanTimeline)(i.input.cwd,i.input.modulePlanExecutionId,"session.cli.runCommand.start");const f=F(o,()=>(0,V.runCommand)(i.input)).then(l=>((0,S.recordSpan)(i.spans,"session.runCommand",u),(0,d.recordModulePlanTimeline)(i.input.cwd,i.input.modulePlanExecutionId,"session.cli.runCommand.resolved"),l),l=>{throw(0,S.recordSpan)(i.spans,"session.runCommand",u),(0,d.recordModulePlanTimeline)(i.input.cwd,i.input.modulePlanExecutionId,"session.cli.runCommand.rejected",{error:l instanceof Error?l.message:String(l)}),l}),c=j(i.input);if(c>0){const l=await W(i.input,f,c);if(l.status==="deadline"){f.catch(()=>{}),(0,d.recordModulePlanTimeline)(i.input.cwd,i.input.modulePlanExecutionId,"session.cli.deadline.output.start",{deadlineMs:c});const P=h(await B(i.input,c));M(r,i,P,0,s),(0,d.recordModulePlanTimeline)(i.input.cwd,i.input.modulePlanExecutionId,"session.cli.response.write.start",{mode:"deadline"}),E(n,200,P),(0,d.recordModulePlanTimeline)(i.input.cwd,i.input.modulePlanExecutionId,"session.cli.response.write.end",{mode:"deadline"});return}const m=l.result,p=h(i.spans?(0,S.appendMetrics)(m,i.spans):m);M(r,i,p,0,s),(0,d.recordModulePlanTimeline)(i.input.cwd,i.input.modulePlanExecutionId,"session.cli.response.write.start",{mode:"result"}),E(n,200,p),(0,d.recordModulePlanTimeline)(i.input.cwd,i.input.modulePlanExecutionId,"session.cli.response.write.end",{mode:"result"});return}const I=await f,y=h(i.spans?(0,S.appendMetrics)(I,i.spans):I);M(r,i,y,0,s),E(n,200,y);return}catch(o){const u=h((0,g.errorPayload)(o));M(r,i,u,1,s),E(n,500,u);return}}if(t.method==="POST"&&t.url==="/cli/stream"){let r=null,s=null,i=0,o=null;try{if(o=await X(t,{streamGate:!0}),!Q(o.input)){n.writeHead(204),n.end();return}z(n),(0,d.recordModulePlanTimeline)(o.input.cwd,o.input.modulePlanExecutionId,"session.cliStream.request.parsed",{command:o.input.command,args:o.input.restArgs}),i=Date.now(),s=Y(o,i),r=we(n,o.input);const u=o.env,f=(0,S.metricsNow)();(0,d.recordModulePlanTimeline)(o.input.cwd,o.input.modulePlanExecutionId,"session.cliStream.runCommand.start");const c=F(u,()=>(0,V.runCommand)(o.input)).then(m=>((0,S.recordSpan)(o.spans,"session.runCommand",f),(0,d.recordModulePlanTimeline)(o.input.cwd,o.input.modulePlanExecutionId,"session.cliStream.runCommand.resolved"),m),m=>{throw(0,S.recordSpan)(o.spans,"session.runCommand",f),(0,d.recordModulePlanTimeline)(o.input.cwd,o.input.modulePlanExecutionId,"session.cliStream.runCommand.rejected",{error:m instanceof Error?m.message:String(m)}),m}),I=j(o.input);if(I>0){const m=await W(o.input,c,I);if(m.status==="deadline"){c.catch(()=>{}),(0,d.recordModulePlanTimeline)(o.input.cwd,o.input.modulePlanExecutionId,"session.cliStream.deadline.output.start",{deadlineMs:I});const v=h(await B(o.input,I));M(s,o,v,0,i),(0,d.recordModulePlanTimeline)(o.input.cwd,o.input.modulePlanExecutionId,"session.cliStream.response.write.start",{mode:"deadline"}),C(n,{type:"result",payload:v}),n.end(),(0,d.recordModulePlanTimeline)(o.input.cwd,o.input.modulePlanExecutionId,"session.cliStream.response.write.end",{mode:"deadline"});return}const p=m.result,P=h(o.spans?(0,S.appendMetrics)(p,o.spans):p);M(s,o,P,0,i),C(n,{type:"result",payload:P}),n.end();return}const y=await c,l=h(o.spans?(0,S.appendMetrics)(y,o.spans):y);M(s,o,l,0,i),C(n,{type:"result",payload:l}),n.end();return}catch(u){n.headersSent||z(n);const f=h((0,g.errorPayload)(u));M(s,o,f,1,i),C(n,{type:"error",payload:f}),n.end();return}finally{r&&clearInterval(r)}}E(n,404,{ok:!1,error:"Not found"})}async serve(){await new Promise((s,i)=>{this.server.once("error",i),this.server.listen(0,"127.0.0.1",()=>s())});const t=this.server.address();if(!t||typeof t=="string")throw new Error("Failed to determine aib session address.");me({pid:process.pid,host:"127.0.0.1",port:t.port,url:`http://127.0.0.1:${t.port}`,startedAt:new Date().toISOString()});let n=!1;const r=()=>{n||(n=!0,fe(),this.server.close(()=>{process.exit(0)}),setTimeout(()=>{process.exit(0)},1e3).unref())};process.on("SIGTERM",r),process.on("SIGINT",r)}}exports.CliSessionServer=K;function Q(e){return e.command==="diagnostics"&&e.restArgs[0]==="timeout-stream"}function z(e){e.writeHead(200,{"content-type":"application/x-ndjson; charset=utf-8","cache-control":"no-cache","x-accel-buffering":"no"}),e.flushHeaders()}async function X(e,t={}){const n=await k(e),r=new URLSearchParams(n),s=r.get("command")??r.get("method")??"",i=r.get("cwd")??"",o=r.get("instanceId")??void 0,u=r.get("sessionId")??void 0,f=r.get("modulePlanExecutionId")??void 0,c=r.get("suppressModulePlanStreamStart")==="true",I=r.get("metricsEnabled")==="true",y=J(r.get("transport")),l=(0,D.autoStartIdePolicyFromSession)(r.get("autoStartIde"))??(0,D.resolveAutoStartIdePolicy)(),m=Ee(r.get("traceDir")),p=ge(r);if(!s.trim())throw new g.CliError("MISSING_COMMAND","Missing command.");if(!i.trim())throw new g.CliError("MISSING_CWD","Missing cwd.");const P=I?[]:void 0,v=(0,S.metricsNow)(),T=await(0,ae.resolveCanonicalCommandAlias)(s.trim(),i,o,l);(0,S.recordSpan)(P,"session.aliasResolution",v);const b=(0,R.stripStdinFormatFlags)(r.getAll("arg")),L=b.restArgs,w={command:T,restArgs:L,cwd:i,metricsEnabled:I,autoStartIde:l};if(y&&(w.transport=y),o&&(w.instanceId=o),u&&(w.sessionId=u),f&&(w.modulePlanExecutionId=f),c&&(w.suppressModulePlanStreamStart=!0),P&&(w.metricsSpans=P),t.streamGate===!0&&!Q(w))return{input:w,spans:P,...m!==void 0?{traceDir:m}:{},env:p};const q=Se(r.get("stdin"),T,L,b.format),_={command:T,restArgs:L,cwd:i,stdinPayload:pe(r.get("stdin"),T,L,b.format),metricsEnabled:I,autoStartIde:l};return q!==void 0&&(_.stdinInputSource=q),y&&(_.transport=y),o&&(_.instanceId=o),u&&(_.sessionId=u),f&&(_.modulePlanExecutionId=f),c&&(_.suppressModulePlanStreamStart=!0),P&&(_.metricsSpans=P),{input:_,spans:P,...m!==void 0?{traceDir:m}:{},env:p}}function ge(e){const t={},n=[[a.CLI_ENV.metrics,e.get("metrics")??""],[a.CLI_ENV.metricsDir,e.get("metricsDir")??""],[a.CLI_ENV.metricsTag,e.get("metricsTag")??""],[a.CLI_ENV.mutationImpactMetrics,e.get("mutationImpactMetrics")??""],[a.CLI_ENV.mutationImpactStream,e.get("mutationImpactStream")??""],[a.CLI_ENV.testMoveToFileFailEntity,e.get("testMoveToFileFailEntity")??""],[a.CLI_ENV.testPostMutationCyclesDelayMs,e.get("testPostMutationCyclesDelayMs")??""],[a.CLI_ENV.testRefactorBatchDelayMs,e.get("testRefactorBatchDelayMs")??""],[a.CLI_ENV.testRenameDelayMs,e.get("testRenameDelayMs")??""],[a.CLI_ENV.modulePlanSyncWaitMs,e.get("modulePlanSyncWaitMs")??""],[a.CLI_ENV.refactorBatchSyncWaitMs,e.get("refactorBatchSyncWaitMs")??""],[a.CLI_ENV.renameSyncWaitMs,e.get("renameSyncWaitMs")??""],[a.CLI_ENV.modulePlanDebugTimeline,e.get("modulePlanDebugTimeline")??""],[a.CLI_ENV.trace,e.get("trace")??""],[a.CLI_ENV.failureSnapshots,e.get("failureSnapshots")??""],[a.CLI_ENV.productStorageDir,e.get("productStorageDir")??""]];for(const[r,s]of n){const i=s.trim();i&&(t[r]=i)}return t}function Ee(e){if(e===null)return;const t=e.trim();return t||void 0}function Y(e,t){return e.traceDir?(0,ie.startTrace)({cwd:e.input.cwd,argv:[e.input.command,...e.input.restArgs],command:e.input.command,restArgs:e.input.restArgs,...e.input.stdinPayload!==void 0?{stdinPayload:e.input.stdinPayload}:{},traceDir:e.traceDir,startedAtMs:t}):null}function M(e,t,n,r,s){if(!e?.enabled||!t)return;const i=(0,U.createCliPresentationEnvelope)(n);e.complete({output:i.tracePayload,exitCode:n.ok===!1?1:r,durationMs:Date.now()-s,...t.input.transport?{transport:t.input.transport}:{}})}function h(e){return(0,U.createCliPresentationEnvelope)(e).payload}function we(e,t){if(!Me(t))return null;const n=t.modulePlanExecutionId??(0,O.buildModulePlanExecutionId)();t.modulePlanExecutionId=n;const r=Date.now(),s=Z(t),i=s?`
|
|
5
|
+
estimated: ${(0,A.formatModulePlanTimeoutEstimate)(s.estimatedDurationMs)}`:"";if(t.suppressModulePlanStreamStart||C(e,{type:"start",text:`modulePlan.${t.restArgs[0]??"execute"} ${n}
|
|
6
|
+
status: aib execution status ${n}${i}`,data:{operation:`modulePlan.${t.restArgs[0]??"execute"}`,executionId:n,...s?{estimatedTimeoutMs:s.recommendedTimeoutMs,estimatedDurationMs:s.estimatedDurationMs,suggestedFirstCheckMs:s.suggestedFirstCheckMs,rowCount:s.rowCount,symbolCount:s.symbolCount}:{}}}),!le)return null;let o=r;return setInterval(()=>{try{const u=(0,O.readModulePlanExecutionStatus)(t.cwd,n),f=Date.parse(u.startedAt);if(Number.isFinite(f)&&f+1e3<r){o=$(e,o);return}if(!(u.completedRows>0||u.failedRows>0||u.filesWritten.length>0)){o=$(e,o);return}C(e,{type:"progress",text:`progress: ${u.completedRows}/${u.rowCount} rows${_e(u.completedEntities,u.entityCount)}, ${u.filesWritten.length} files`,data:{operation:u.operation,executionId:u.executionId,status:u.status,completedRows:u.completedRows,failedRows:u.failedRows,rowCount:u.rowCount,completedEntities:u.completedEntities,entityCount:u.entityCount,filesWritten:u.filesWritten.length}})}catch{o=$(e,o)}},5e3)}function $(e,t){if(!ce)return t;const n=Date.now();return n-t<3e4?t:(C(e,{type:"progress",text:"modulePlan still running",data:{operation:"modulePlan",status:"running"}}),n)}function _e(e,t){return!t||t<=0?"":`, ${Math.floor((e??0)/t*100)}% entities`}function Me(e){if(e.command!=="modulePlan")return!1;const t=e.restArgs[0]??"";return t==="execute"||t==="apply"}function Z(e){const t=e.restArgs[0]??"";if(t==="execute")return(0,A.estimateModulePlanTimeoutFromRequest)(e.stdinPayload);if(t!=="apply")return null;const n=he(e.restArgs);if(!n)return null;try{return(0,A.estimateModulePlanTimeoutFromRequest)((0,O.readModulePlanRecord)(e.cwd,n).normalizedRequest)}catch{return null}}function he(e){const t=e.indexOf("--plan");if(t>=0){const r=e[t+1];return r&&!r.startsWith("--")?r:null}return e.slice(1).find(r=>!r.startsWith("--"))??null}async function Ce(){const e=process.argv[3]||"status";if(e!=="serve"){(0,se.printJson)((0,g.errorPayload)(new g.CliError("UNKNOWN_SESSION_COMMAND",`Unknown aib session command: ${e}`))),process.exitCode=1;return}await new K().serve()}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AGENT_TEXT_FIELD=void 0,exports.attachAgentText=T,exports.readAgentText=n,exports.stripAgentText=r,exports.AGENT_TEXT_FIELD="__aibText";function T(t,e){return e?{...t,[exports.AGENT_TEXT_FIELD]:e}:t}function n(t){const e=t[exports.AGENT_TEXT_FIELD];return typeof e=="string"&&e!==""?e:null}function r(t){if(t[exports.AGENT_TEXT_FIELD]===void 0)return t;const e={...t};return delete e[exports.AGENT_TEXT_FIELD],e}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.withHints=o,exports.noIdeInstance=p,exports.protocolVersionUnsupported=d,exports.capabilityNotAvailable=I,exports.transportNotAvailable=h,exports.buildAutoStartHints=b;const r=require("../config/env-vars"),i=require("./errors"),n=require("./hints"),s=require("./protocol");function o(t,e){return{...t,hints:e}}function p(t={}){return new i.CliError("NO_IDE_INSTANCE","No compatible IDE instance was found for the requested cwd.",o(t,[(0,n.commandHint)("aib --cwd <path> --auto-start-ide ping","Retry with managed VS Code serve-web auto-start."),(0,n.actionHint)("Open the target project in VS Code or Cursor with the extension installed.")]))}function d(t,e=null){return new i.CliError("PROTOCOL_VERSION_UNSUPPORTED",`The selected IDE instance uses protocol version ${String(t.protocolVersion??"unknown")}, but this CLI requires version ${s.SUPPORTED_PROTOCOL_VERSION}.`,o({instanceId:t.instanceId,requiredProtocolVersion:s.SUPPORTED_PROTOCOL_VERSION,actualProtocolVersion:l(t.protocolVersion),extensionVersion:c(t.extensionVersion),requiredCapability:e},[(0,n.actionHint)("Install a newer extension VSIX that supports this CLI protocol."),(0,n.actionHint)("Reload the IDE window after installing the latest extension."),(0,n.commandHint)("aib listInstances","Check which IDE instances are currently registered.")]))}function I(t,e){return new i.CliError("CAPABILITY_NOT_AVAILABLE",`The selected IDE instance does not support ${e}.`,o({instanceId:t.instanceId,protocolVersion:l(t.protocolVersion),extensionVersion:c(t.extensionVersion),requiredCapability:e,availableCapabilities:m(t.capabilities)},[(0,n.actionHint)("Install a newer extension VSIX that supports this capability."),(0,n.commandHint)("npm --prefix packages/extension run package:vsix","Build a fresh local VSIX artifact."),(0,n.actionHint)("Reload the IDE window after installing the latest extension.")]))}function h(t,e){const a=Object.keys(t.transports??{}),u=e==="websocket"&&a.includes("http")?[(0,n.commandHint)("aib --transport http <command>","Retry with the available HTTP transport.")]:[];return new i.CliError("TRANSPORT_NOT_AVAILABLE",`The selected IDE instance does not expose ${e} transport.`,o({instanceId:t.instanceId,requestedTransport:e,availableTransports:a},[...u,(0,n.actionHint)("Install or reload an extension build that exposes the requested transport.")]))}function b(){return[(0,n.commandHint)("aib init","Initialize aib.json at the repository root before managed IDE auto-start."),(0,n.commandHint)("aib --no-auto-start-ide <command>","Disable environment auto-start for a single command."),(0,n.configHint)(r.CLI_ENV.installConfig,"Optional product-boundary config file with an extensionVsix path."),(0,n.configHint)(r.CLI_ENV.extensionVsix,"Optional product-boundary path to the packaged VSIX used by managed IDE startup."),(0,n.configHint)(r.CLI_ENV.managedHostScript,"Optional managed host script override when packaged CLI assets are not available.")]}function l(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function c(t){return typeof t=="string"?t:null}function m(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildAutoStartIdeHints=e;const t=require("./diagnostic-catalog");function e(){return(0,t.buildAutoStartHints)()}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CliError=void 0,exports.errorPayload=I;const m=require("./agent-text");class f extends Error{code;details;constructor(n,s,i){super(s),this.code=n,this.details=i}}exports.CliError=f;function A(e){return Array.isArray(e)&&e.every(n=>n!==null&&typeof n=="object"&&typeof n.kind=="string"&&typeof n.description=="string")}function r(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:Array.isArray(e)?e.map(n=>r(n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([n,s])=>[n,r(s)])):String(e)}function p(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const n=e.hints;return A(n)?r(n):null}function _(e){return!!(e&&typeof e=="object"&&Array.isArray(e.issues))}function N(e){return!e||e.length===0?"<root>":e.map(n=>String(n)).join(".")}function E(e){return e.issues.map(n=>({path:N(n.path),message:typeof n.message=="string"?n.message:"Invalid value.",...typeof n.code=="string"?{code:n.code}:{}}))}function I(e){if(e instanceof f){const n={ok:!1,code:e.code,error:e.message,details:e.details?r(e.details):null},s=g(e);s&&(n[m.AGENT_TEXT_FIELD]=s);const i=p(e.details);return i?{...n,hints:i}:n}return _(e)?{ok:!1,code:"INVALID_INPUT",error:"Input JSON does not match the expected command shape.",details:{issues:E(e)}}:{ok:!1,code:"UNEXPECTED_ERROR",error:e instanceof Error?e.message:String(e),details:null}}function g(e){if(e.code==="EMPTY_STDIN")return["DSL payload on stdin","","PowerShell:","@'","<input>","'@ | aib <command> --stdin","","Bash/Zsh:","cat <<'EOF' | aib <command> --stdin","<input>","EOF","","cmd.exe:","type request.dsl | aib <command> --stdin"].join(`
|
|
2
|
+
`);if(e.code==="INVALID_STDIN_DSL"){const n=a(e.details),s=c(n.cause);return["invalid DSL stdin",...s?["",s]:[],"","Fix the DSL line and rerun the command."].join(`
|
|
3
|
+
`)}if(e.code==="INVALID_STDIN_FORMAT")return["invalid stdin format","","Use:","--stdin-format auto","--stdin-format dsl"].join(`
|
|
4
|
+
`);if(e.code==="INPUT_SOURCE_CONFLICT"||e.code.endsWith("_INPUT_SOURCE_CONFLICT"))return["input source conflict","","Use only one input source:","--stdin","--from <handle-or-file>","--from-json <file>","--from-dsl <file>"].join(`
|
|
5
|
+
`);if(e.code==="INPUT_FROM_UNSUPPORTED")return["file input is not supported for this command","","Run the command without --from."].join(`
|
|
6
|
+
`);if(e.code==="INPUT_STDIN_UNSUPPORTED")return["stdin input is not supported for this command","","Run the command without --stdin."].join(`
|
|
7
|
+
`);if(e.code==="STDIN_DSL_COMMAND_MISMATCH")return["DSL command mismatch","",e.message,"","Run the command that matches the DSL intent, or change the DSL operation."].join(`
|
|
8
|
+
`);if(e.code==="STDIN_DSL_UNSUPPORTED")return["DSL stdin is not supported for this command","","Use JSON input for this command, or run a DSL-capable command."].join(`
|
|
9
|
+
`);if(e.code.startsWith("INVALID_")&&e.code.endsWith("_JSON_FILE")){const n=a(e.details),s=c(n.file);return["input file could not be read",...s?["",`file: ${s}`]:[],"","Check the path or saved input handle."].join(`
|
|
10
|
+
`)}if(e.code==="UNKNOWN_COMMAND"){const n=a(e.details),s=Array.isArray(n.availableCommands)?n.availableCommands.filter(o=>typeof o=="string"):[],i=["help","config","sync","inspect","modulePlan","move","rename","imports","session","feedback"],t=s.length>0?i.filter(o=>o==="config"||s.includes(o)):i;return[e.message.replace(/^Unknown command:/,"unknown command:"),...t.length>0?["",`Common commands: ${t.join(", ")}`]:[],"","Run:","aib help"].join(`
|
|
11
|
+
`)}if(e.code==="INVALID_INSPECT_OP")return["invalid inspect operation","","Use: file, imports, exports, members, code, deps, usages, duplicates, graph, tree, cycles","","Example:","aib inspect file src/service.ts"].join(`
|
|
12
|
+
`);if(e.code==="MODULE_PLAN_SOURCE_REQUIRED")return["modulePlan needs a source file","","DSL:","@source src/large-service.ts","module src/large-service.core.ts: LargeService createLargeService"].join(`
|
|
13
|
+
`);if(e.code==="MODULE_PLAN_MODULES_REQUIRED")return["modulePlan needs at least one target module","","DSL:","@source src/large-service.ts","module src/large-service.core.ts: LargeService createLargeService"].join(`
|
|
14
|
+
`);if(e.code==="NORMALIZE_IMPORTS_SCOPE_REQUIRED")return["imports normalize needs a file or directory scope","","DSL:","imports.normalize scope=src/features to=shortestAlias","","CLI:","aib imports normalize preview src/features"].join(`
|
|
15
|
+
`);if(e.code==="INVALID_NORMALIZE_IMPORTS_MODE")return["imports normalize --to expects relative, alias, or shortestAlias","","Example:","aib imports normalize preview src/features --to shortestAlias"].join(`
|
|
16
|
+
`);if(e.code==="WORKSPACE_ROOT_NOT_INITIALIZED")return["aib workspace not initialized","","No aib.json was found.","Go to your repo root and run:","aib init"].join(`
|
|
17
|
+
`);if(e.code==="EXECUTION_NOT_FOUND"||e.code==="MODULE_PLAN_EXECUTION_NOT_FOUND"||e.code==="REFACTOR_BATCH_EXECUTION_NOT_FOUND"){const n=a(e.details);return[`execution not found: ${c(n.executionId)??"last"}`,"","No execution status exists for this id.","Run a long mutation first, or check the execution id."].join(`
|
|
18
|
+
`)}if(e.code==="SESSION_HANDLE_NOT_FOUND"){const n=a(e.details),s=c(n.handle)??"unknown",i=c(n.sessionDir);return[`handle not found: ${s}`,...i?["",`session: ${i}`]:[],"","The artifact may have been cleared or was never saved."].join(`
|
|
19
|
+
`)}if(e.code==="AMBIGUOUS_ENTITY_SELECTOR")return S(e);if(e.code==="INVALID_PATH_ALIAS_TARGET"||e.code==="SESSION_ALIASES_SET_USAGE")return["invalid path alias","","Use:","aib session aliases set <name> <path>","","Example:","aib session aliases set svc src/services"].join(`
|
|
20
|
+
`);if(e.code==="AIB_CONFIG_INVALID"||e.code==="INVALID_PATH_ALIASES"||e.code==="INVALID_PATH_ALIAS_NAME"||e.code==="INVALID_PATH_ALIAS_TARGET"||e.code==="RESERVED_PATH_ALIAS_NAME")return h(e);if(e.code==="UNKNOWN_SESSION_PREF"){const n=a(e.details),s=Array.isArray(n.available)?n.available.filter(i=>typeof i=="string"):[];return[e.message.toLowerCase(),...s.length>0?["","Available prefs:",...s.slice(0,12).map(i=>`- ${i}`),...s.length>12?[`+ ${s.length-12} more`]:[]]:[],"","Run:","aib session prefs get --all"].join(`
|
|
21
|
+
`)}if(e.code==="INVALID_SESSION_PREF_VALUE")return["invalid session preference value","",e.message,"","Run:","aib session prefs get --all"].join(`
|
|
22
|
+
`);if(e.code==="UNKNOWN_SESSION_PREFS_COMMAND")return["unknown session prefs command","","Use:","aib session prefs get","aib session prefs set <key> <value>","aib session prefs clear [key]"].join(`
|
|
23
|
+
`);if(e.code==="UNKNOWN_SESSION_ALIASES_COMMAND")return["unknown session aliases command","","Use:","aib session aliases get","aib session aliases set <name> <path>","aib session aliases clear [name]"].join(`
|
|
24
|
+
`);if(e.code==="UNKNOWN_PATH_ALIAS"){const n=a(e.details),s=c(n.alias),i=Array.isArray(n.available)?n.available.filter(t=>typeof t=="string"):[];return[`unknown AIB path alias: @${s??""}`,"",i.length>0?`Available aliases: ${i.map(t=>`@${t}`).join(", ")}`:"No AIB path aliases are configured.",...i.length>0?["Run:","aib sync"]:["Check config:","aib config","or run:","aib sync"]].join(`
|
|
25
|
+
`)}return null}function S(e){const n=a(e.details),s=Array.isArray(n.ambiguities)?n.ambiguities.filter(t=>t!==null&&typeof t=="object"&&!Array.isArray(t)):[];if(s.length>0){const t=s.map(l=>c(l.entity)).filter(l=>l!==null),o=[t.length===1?`ambiguous entity: ${t[0]}`:`ambiguous entities: ${t.join(", ")}`,"","Use available:"];for(const l of s){const d=Array.isArray(l.suggestions)?l.suggestions.filter(u=>typeof u=="string"&&u.length>0):[];d.length>0&&o.push(`- ${d.join(", ")}`)}return o.join(`
|
|
26
|
+
`)}const i=Array.isArray(n.suggestions)?n.suggestions.filter(t=>typeof t=="string"&&t.length>0):[];return[e.message,...i.length>0?["","Use available:",`- ${i.join(", ")}`]:[]].join(`
|
|
27
|
+
`)}function h(e){const n=["aib config invalid","",e.message];if(e.code==="INVALID_PATH_ALIAS_NAME"&&n.push("Use alias names without @, for example:",'"pathAliases": {',' "svc": "src/services"',"}"),e.code==="RESERVED_PATH_ALIAS_NAME"){const s=a(e.details),i=Array.isArray(s.reserved)?s.reserved.filter(t=>typeof t=="string"):[];i.length>0&&n.push(`Reserved aliases: ${i.join(", ")}`)}return n.push("","Edit aib.json, then run:","aib sync"),n.join(`
|
|
28
|
+
`)}function a(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function c(e){return typeof e=="string"&&e.length>0?e:null}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.yieldToEventLoop=t;async function t(){await new Promise(e=>setImmediate(e))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.commandHint=e,exports.actionHint=i,exports.docsHint=a,exports.configHint=c,exports.buildUpgradeExtensionHints=s;function e(n,t){return{kind:"command",command:n,description:t}}function i(n){return{kind:"action",description:n}}function a(n,t){return{kind:"docs",path:n,description:t}}function c(n,t,o){const r={kind:"config",name:n,description:t};return o!==void 0&&(r.value=o),r}function s(){return[i("Install a newer extension VSIX that supports the requested operation."),e("npm --prefix packages/extension run package:vsix","Build a fresh local VSIX artifact."),i("Reload the IDE window after installing the latest extension."),e("aib listInstances","Check which IDE instances are currently registered.")]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.metricsNow=i,exports.recordSpan=o,exports.appendMetrics=c;const t=require("node:perf_hooks");function i(){return t.performance.now()}function o(e,r,n){e&&e.push({name:r,durationMs:Number((t.performance.now()-n).toFixed(3))})}function s(e){const r=e._metrics;if(!r||typeof r!="object"||Array.isArray(r))return[];const n=r.spans;return Array.isArray(n)?n:[]}function c(e,r){return r.length===0?e:{...e,_metrics:{spans:[...s(e),...r.map(n=>({name:n.name,durationMs:n.durationMs}))]}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OPERATION_IDS=void 0,exports.OPERATION_IDS={health:"health",runtimeInfo:"runtimeInfo",effectiveConfig:"effectiveConfig",inspect:"inspect",findImporters:"findImporters",findUnusedImports:"findUnusedImports",addMissingImports:"addMissingImports",moveRefactor:"moveRefactor",renameSymbol:"renameSymbol",refactorBatch:"refactorBatch"};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createCliPresentationEnvelope=l,exports.presentCliEnvelope=c;const i=require("./agent-text");function l(e){const r=(0,i.readAgentText)(e),n=r?null:f(e),s=r??n,t=s&&!r?(0,i.attachAgentText)(e,s):e,a=typeof t.code=="string"?t.code:void 0;return{ok:t.ok!==!1,payload:t,tracePayload:(0,i.stripAgentText)(t),text:s,...a?{code:a}:{}}}function c(e,r){return r==="agent"&&e.text?`${e.text.trimEnd()}
|
|
2
|
+
`:`${JSON.stringify(e.tracePayload,null,2)}
|
|
3
|
+
`}function f(e){if(e.ok!==!1)return null;const r=typeof e.code=="string"&&e.code.length>0?e.code:"ERROR",n=typeof e.error=="string"&&e.error.length>0?e.error:"AIB command failed.",s=[r,"",n],t=g(e.details);t.length>0&&s.push("","issues:",...t);const a=Array.isArray(e.hints)?e.hints.filter(o=>typeof o=="string"&&o.length>0):[];return a.length>0&&s.push("","hints:",...a.map(o=>`- ${o}`)),s.join(`
|
|
4
|
+
`)}function g(e){if(!e||typeof e!="object"||Array.isArray(e))return[];const r=e.issues;return Array.isArray(r)?r.map(n=>{if(!n||typeof n!="object"||Array.isArray(n))return null;const s=typeof n.path=="string"&&n.path.length>0?n.path:"<root>",t=typeof n.message=="string"&&n.message.length>0?n.message:"Invalid value.";return`- ${s}: ${t}`}).filter(n=>n!==null):[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.COMMAND_CAPABILITY_REQUIREMENTS=exports.COMPATIBILITY_EXEMPT_COMMANDS=exports.CLI_COMMAND_IDS=exports.CAPABILITY_IDS=exports.SUPPORTED_PROTOCOL_VERSION=void 0,exports.getRequiredCapabilityForCommand=I,exports.isCompatibilityExemptCommand=e,exports.SUPPORTED_PROTOCOL_VERSION=1,exports.CAPABILITY_IDS={ping:"ping",runtimeInfo:"runtimeInfo",printConfig:"printConfig",inspect:"inspect",imports:"imports",move:"move",rename:"rename",refactor:"refactor",findImporters:"findImporters",findUnusedImports:"findUnusedImports",addMissingImports:"addMissingImports",moveToFile:"moveToFile",renameEntities:"renameEntities",refactorBatch:"refactorBatch"},exports.CLI_COMMAND_IDS={listInstances:"listInstances",ping:"ping",runtimeInfo:"runtimeInfo",printConfig:"printConfig",initSkillUsage:"initSkillUsage",initSkillUsageKebab:"init-skill-usage",inspect:"inspect",findImporters:"findImporters",findUnusedImports:"findUnusedImports",addMissingImports:"addMissingImports",moveToFile:"moveToFile",renameEntities:"renameEntities",refactorBatch:"refactorBatch",modulePlan:"modulePlan",session:"session",trace:"trace",observability:"observability"},exports.COMPATIBILITY_EXEMPT_COMMANDS=[exports.CLI_COMMAND_IDS.listInstances,exports.CLI_COMMAND_IDS.ping,exports.CLI_COMMAND_IDS.runtimeInfo,exports.CLI_COMMAND_IDS.session,exports.CLI_COMMAND_IDS.trace,exports.CLI_COMMAND_IDS.observability],exports.COMMAND_CAPABILITY_REQUIREMENTS={[exports.CLI_COMMAND_IDS.printConfig]:exports.CAPABILITY_IDS.printConfig,[exports.CLI_COMMAND_IDS.initSkillUsage]:exports.CAPABILITY_IDS.printConfig,[exports.CLI_COMMAND_IDS.initSkillUsageKebab]:exports.CAPABILITY_IDS.printConfig,[exports.CLI_COMMAND_IDS.inspect]:exports.CAPABILITY_IDS.inspect,[exports.CLI_COMMAND_IDS.findImporters]:exports.CAPABILITY_IDS.findImporters,[exports.CLI_COMMAND_IDS.findUnusedImports]:exports.CAPABILITY_IDS.findUnusedImports,[exports.CLI_COMMAND_IDS.addMissingImports]:exports.CAPABILITY_IDS.addMissingImports,[exports.CLI_COMMAND_IDS.moveToFile]:exports.CAPABILITY_IDS.moveToFile,[exports.CLI_COMMAND_IDS.renameEntities]:exports.CAPABILITY_IDS.renameEntities,[exports.CLI_COMMAND_IDS.refactorBatch]:exports.CAPABILITY_IDS.refactorBatch,[exports.CLI_COMMAND_IDS.modulePlan]:exports.CAPABILITY_IDS.inspect};function I(i){return exports.COMMAND_CAPABILITY_REQUIREMENTS[i]??null}function e(i){return exports.COMPATIBILITY_EXEMPT_COMMANDS.includes(i)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EXTENSION_ROUTE_OPERATIONS=exports.EXTENSION_ROUTES=void 0;const e=require("./operations");exports.EXTENSION_ROUTES={health:"/health",runtimeInfo:"/dev/runtime-info",effectiveConfig:"/config/effective",inspect:"/ide/inspect",findImporters:"/tsapi/find-importers",findUnusedImports:"/tsapi/find-unused-imports",addMissingImports:"/tsapi/add-missing-imports",moveRefactor:"/tsapi/move-refactor",renameSymbol:"/tsapi/rename-symbol",refactorBatch:"/tsapi/refactor-batch"},exports.EXTENSION_ROUTE_OPERATIONS={[exports.EXTENSION_ROUTES.health]:e.OPERATION_IDS.health,[exports.EXTENSION_ROUTES.runtimeInfo]:e.OPERATION_IDS.runtimeInfo,[exports.EXTENSION_ROUTES.effectiveConfig]:e.OPERATION_IDS.effectiveConfig,[exports.EXTENSION_ROUTES.inspect]:e.OPERATION_IDS.inspect,[exports.EXTENSION_ROUTES.findImporters]:e.OPERATION_IDS.findImporters,[exports.EXTENSION_ROUTES.findUnusedImports]:e.OPERATION_IDS.findUnusedImports,[exports.EXTENSION_ROUTES.addMissingImports]:e.OPERATION_IDS.addMissingImports,[exports.EXTENSION_ROUTES.moveRefactor]:e.OPERATION_IDS.moveRefactor,[exports.EXTENSION_ROUTES.renameSymbol]:e.OPERATION_IDS.renameSymbol,[exports.EXTENSION_ROUTES.refactorBatch]:e.OPERATION_IDS.refactorBatch};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ENTITY_KIND_IDS=exports.CANONICAL_METHOD_IDS=void 0,exports.CANONICAL_METHOD_IDS=["ping","runtimeInfo","printConfig","listInstances","initSkillUsage","help","inspect","imports","move","rename","refactor","execution","modulePlan"],exports.ENTITY_KIND_IDS=["class","interface","type","function","variable","enum","method","property"];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var D=exports&&exports.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveTraceConfig=d,exports.runTraceCommand=I;const i=D(require("node:fs")),o=D(require("node:path")),p=require("node:crypto"),s=require("../config/env-vars"),E=require("../config/product-storage"),v=require("../config/workspace-root"),T=require("../observability/config"),u=require("../shared/errors"),y="trace.json",h="trace";function d(e,r={}){const a=C(e),t=f(r.flagTraceDir);if(t)return g(e,a,"flag",t,"cwd");const n=process.env[s.CLI_ENV.trace]?.trim().toLowerCase();if(n&&["0","false","off","disabled","no"].includes(n))return{enabled:!1,source:"disabled",configPath:a,envVar:s.CLI_ENV.trace};const c=f(r.envTraceDir);if(c)return g(e,a,"env",c,"cwd");const l=f(A(a)?.traceDir);if(l)return g(e,a,"user",l,"product");if((0,T.resolveObservabilityConfig)().trace!=="off"){const b=(0,T.defaultTraceWorkspaceDir)(e);return{enabled:!0,source:"default",traceDir:b,absoluteTraceDir:b,configPath:a,envVar:s.CLI_ENV.trace}}return{enabled:!1,source:"none",configPath:a,envVar:s.CLI_ENV.traceDir}}function I(e,r,a){const t=r[0]??"status";if(t==="status")return{ok:!0,command:"trace",action:"status",trace:_(a)};if(t==="set"){const n=f(r[1]);if(!n)throw new u.CliError("TRACE_DIR_REQUIRED","Expected a trace directory after: aib trace set <dir>.",{examples:["aib trace set traces","aib --cwd D:\\dev\\project trace set traces"]});const c=N(e,n),l=d(e);return{ok:!0,command:"trace",action:"set",trace:_(l),configPath:c}}if(t==="clear"){const n=S(e),c=d(e);return{ok:!0,command:"trace",action:"clear",trace:_(c),configPath:n,note:"Cleared the persistent trace setting only. Existing trace files were not deleted."}}throw new u.CliError("UNKNOWN_TRACE_COMMAND",`Unknown aib trace command: ${t}`,{availableCommands:["status","set","clear"]})}function _(e){const r={enabled:e.enabled,source:e.source,configPath:e.configPath,envVar:e.envVar};return e.traceDir!==void 0&&(r.traceDir=e.traceDir),e.absoluteTraceDir!==void 0&&(r.absoluteTraceDir=e.absoluteTraceDir),r}function N(e,r){const a=C(e);i.default.mkdirSync(o.default.dirname(a),{recursive:!0});const t={traceDir:r,updatedAt:new Date().toISOString()};return i.default.writeFileSync(a,`${JSON.stringify(t,null,2)}
|
|
2
|
+
`,"utf8"),a}function S(e){const r=C(e);return i.default.existsSync(r)&&i.default.unlinkSync(r),r}function A(e){if(!i.default.existsSync(e))return null;let r;try{r=JSON.parse(i.default.readFileSync(e,"utf8"))}catch(n){throw new u.CliError("TRACE_CONFIG_INVALID","Project trace config is invalid JSON.",{configPath:e,reason:n instanceof Error?n.message:String(n)})}if(!r||typeof r!="object"||Array.isArray(r))throw new u.CliError("TRACE_CONFIG_INVALID","Project trace config must be a JSON object.",{configPath:e});const t=f(r.traceDir);return t?{traceDir:t}:{}}function g(e,r,a,t,n){const c=o.default.resolve(o.default.isAbsolute(t)?t:n==="product"?o.default.join(m(e),t):o.default.join(e,t));return{enabled:!0,source:a,traceDir:t,absoluteTraceDir:c,configPath:r,envVar:s.CLI_ENV.traceDir}}function C(e){return o.default.join(m(e),y)}function m(e){let r=o.default.resolve(e);try{r=(0,v.resolveWorkspaceRoot)(e)?.root??r}catch(n){if(!(n instanceof u.CliError&&n.code==="AIB_CONFIG_INVALID"))throw n}const a=o.default.basename(r).replace(/[^A-Za-z0-9._-]/g,"-")||"workspace",t=(0,p.createHash)("sha1").update(o.default.resolve(r).toLowerCase()).digest("hex").slice(0,12);return o.default.join((0,E.productStorageRoot)(),h,"workspaces",`${a}-${t}`)}function f(e){return typeof e=="string"&&e.trim()!==""?e.trim():null}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";var S=exports&&exports.__createBinding||(Object.create?(function(e,r,n,c){c===void 0&&(c=n);var t=Object.getOwnPropertyDescriptor(r,n);(!t||("get"in t?!r.__esModule:t.writable||t.configurable))&&(t={enumerable:!0,get:function(){return r[n]}}),Object.defineProperty(e,c,t)}):(function(e,r,n,c){c===void 0&&(c=n),e[c]=r[n]})),h=exports&&exports.__setModuleDefault||(Object.create?(function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}):function(e,r){e.default=r}),_=exports&&exports.__importStar||(function(){var e=function(r){return e=Object.getOwnPropertyNames||function(n){var c=[];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(c[c.length]=t);return c},e(r)};return function(r){if(r&&r.__esModule)return r;var n={};if(r!=null)for(var c=e(r),t=0;t<c.length;t++)c[t]!=="default"&&S(n,r,c[t]);return h(n,r),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.startTrace=D;const i=_(require("node:fs")),a=_(require("node:path")),w=require("node:crypto"),A=require("../observability/context"),C=require("../observability/failure-snapshot"),P=require("../observability/recent");function D(e){if(!e.traceDir||e.traceDir.trim()==="")return M();const r=x(e.cwd,e.traceDir.trim()),n=a.basename(r),c=new Date(e.startedAtMs).toISOString(),t=k(e.command,e.startedAtMs),u=a.join(r,"calls",t),m=a.join(u,"request.json"),b=(0,A.buildCorrelationContext)(e.cwd);return i.mkdirSync(u,{recursive:!0}),f(m,{callId:t,traceCallId:t,traceRunId:n,startedAt:c,cwd:a.resolve(e.cwd),...b,argv:e.argv,command:e.command,restArgs:e.restArgs,hasStdinPayload:e.stdinPayload!==void 0,stdinPayload:v(e.stdinPayload)}),{enabled:!0,traceDir:r,callId:t,callDir:u,complete(s){const g=new Date(e.startedAtMs+s.durationMs).toISOString(),I=a.join(u,"response.json"),p=a.join(u,"meta.json");f(I,s.output);const O=T(s),j=(0,C.captureFailureSnapshot)({cwd:e.cwd,command:e.command,restArgs:e.restArgs,...e.stdinPayload!==void 0?{stdinPayload:e.stdinPayload}:{},output:s.output,traceCallId:t,traceRunId:n}),d={callId:t,traceCallId:t,traceRunId:n,startedAt:c,finishedAt:g,durationMs:s.durationMs,exitCode:s.exitCode,ok:O,command:e.command,cwd:a.resolve(e.cwd),...b,selectedInstance:J(s.output),responseSummary:N(s.output),transport:s.transport??F(s.output)??null,executionId:E(s.output),...j?{failureSnapshot:j}:{},requestPath:m,responsePath:I,metaPath:p};f(p,d),$(a.join(r,"trace.jsonl"),d),(0,P.recordRecentTraceCall)(e.cwd,{traceCallId:t,traceRunId:n,traceDir:r,command:e.command,cwd:a.resolve(e.cwd),startedAt:c,finishedAt:g,ok:O,...typeof d.executionId=="string"?{executionId:d.executionId}:{}})}}}function M(){return{enabled:!1,traceDir:null,callId:null,callDir:null,complete(){}}}function x(e,r){return a.resolve(a.isAbsolute(r)?r:a.join(e,r))}function k(e,r){return`${new Date(r).toISOString().replace(/[:.]/g,"-")}-${q(e)}-${process.pid}-${(0,w.randomUUID)().slice(0,8)}`}function q(e){return e.replace(/[^a-z0-9]+/gi,"-").replace(/^-|-$/g,"").toLowerCase()||"command"}function f(e,r){i.mkdirSync(a.dirname(e),{recursive:!0}),i.writeFileSync(e,`${JSON.stringify(r,null,2)}
|
|
2
|
+
`)}function $(e,r){i.mkdirSync(a.dirname(e),{recursive:!0}),i.appendFileSync(e,`${JSON.stringify(r)}
|
|
3
|
+
`)}function v(e){return e===void 0?null:y(e)}function y(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:Array.isArray(e)?e.map(r=>y(r)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([r,n])=>[r,y(n)])):String(e)}function J(e){const r=e.selectedInstance;if(!r||typeof r!="object"||Array.isArray(r))return null;const n=r;return{instanceId:o(n.instanceId),reason:o(n.reason),matchedWorkspace:o(n.matchedWorkspace),port:typeof n.port=="number"?n.port:null}}function N(e){return{ok:typeof e.ok=="boolean"?e.ok:null,code:o(e.code),error:o(e.error),command:o(e.command),responseOk:V(e),responseCode:B(e),batchOk:typeof e.batchOk=="boolean"?e.batchOk:null,result:l(e.result)}}function T(e){return e.output.ok===!1?!1:e.exitCode===0}function F(e){const r=e.selectedInstance;!r||typeof r!="object"||Array.isArray(r)}function V(e){const r=l(e.response);return typeof r?.ok=="boolean"?r.ok:null}function B(e){const r=l(e.response);return r?o(r.code):null}function l(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function o(e){return typeof e=="string"?e:null}function E(e){if(typeof e.executionId=="string")return e.executionId;const r=l(e.response);return typeof r?.executionId=="string"?r.executionId:null}
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@automaton-labs/aib",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "CLI for discovering and calling the local aib IDE extension runtime.",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"bin": {
|
|
9
|
+
"aib": "dist/bin/aib.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"extension",
|
|
14
|
+
"scripts/install-windows-launcher.cjs",
|
|
15
|
+
"scripts/postinstall.cjs",
|
|
16
|
+
"scripts/provision-runtime.cjs",
|
|
17
|
+
"runtimes/launcher",
|
|
18
|
+
"README.md",
|
|
19
|
+
"package.json"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc -p . && node scripts/copy-managed-host-assets.cjs",
|
|
23
|
+
"build:package": "node ../../scripts/package/clean-paths.cjs dist && tsc -p tsconfig.package.json && node scripts/copy-managed-host-assets.cjs && node ../../scripts/package/minify-js.cjs dist",
|
|
24
|
+
"typecheck": "tsc -p . --noEmit",
|
|
25
|
+
"postinstall": "node scripts/postinstall.cjs",
|
|
26
|
+
"prepack": "npm run build:package && node scripts/copy-extension-vsix.cjs",
|
|
27
|
+
"pack:local": "npm pack --pack-destination ../../.tmp"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"ws": "^8.20.0",
|
|
31
|
+
"zod": "^4.1.12"
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=20"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/ws": "^8.18.1"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("node:fs");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const { spawnSync } = require("node:child_process");
|
|
6
|
+
|
|
7
|
+
const packageRoot = path.resolve(__dirname, "..");
|
|
8
|
+
const launcherPath = path.join(packageRoot, "runtimes", "launcher", "win-x64", "aib.exe");
|
|
9
|
+
|
|
10
|
+
function resolveNpmPrefix() {
|
|
11
|
+
if (process.env.npm_config_prefix && process.env.npm_config_prefix.trim()) {
|
|
12
|
+
return path.resolve(process.env.npm_config_prefix.trim());
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (process.platform === "win32") {
|
|
16
|
+
const result = spawnSync(process.env.ComSpec ?? "cmd.exe", ["/d", "/s", "/c", "npm config get prefix"], {
|
|
17
|
+
cwd: packageRoot,
|
|
18
|
+
encoding: "utf8",
|
|
19
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
20
|
+
windowsHide: true
|
|
21
|
+
});
|
|
22
|
+
if (result.status === 0 && result.stdout.trim()) {
|
|
23
|
+
return result.stdout.trim();
|
|
24
|
+
}
|
|
25
|
+
if (process.env.APPDATA) {
|
|
26
|
+
return path.join(process.env.APPDATA, "npm");
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const result = spawnSync("npm", ["config", "get", "prefix"], {
|
|
31
|
+
cwd: packageRoot,
|
|
32
|
+
encoding: "utf8",
|
|
33
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
34
|
+
});
|
|
35
|
+
return result.status === 0 && result.stdout.trim() ? result.stdout.trim() : null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (process.platform !== "win32") {
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!fs.existsSync(launcherPath)) {
|
|
43
|
+
process.exit(0);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const npmPrefix = resolveNpmPrefix();
|
|
47
|
+
if (!npmPrefix) {
|
|
48
|
+
process.exit(0);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
fs.mkdirSync(npmPrefix, { recursive: true });
|
|
52
|
+
fs.copyFileSync(launcherPath, path.join(npmPrefix, "aib.exe"));
|
|
53
|
+
|
|
54
|
+
const ps1ShimPath = path.join(npmPrefix, "aib.ps1");
|
|
55
|
+
const ps1BackupPath = path.join(npmPrefix, "aib.ps1.bak");
|
|
56
|
+
if (fs.existsSync(ps1ShimPath)) {
|
|
57
|
+
fs.renameSync(ps1ShimPath, ps1BackupPath);
|
|
58
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const path = require("node:path");
|
|
4
|
+
const { spawnSync } = require("node:child_process");
|
|
5
|
+
|
|
6
|
+
const packageRoot = path.resolve(__dirname, "..");
|
|
7
|
+
|
|
8
|
+
runBestEffort(path.join(__dirname, "install-windows-launcher.cjs"));
|
|
9
|
+
runBestEffort(path.join(__dirname, "provision-runtime.cjs"), ["--quiet"]);
|
|
10
|
+
|
|
11
|
+
function runBestEffort(scriptPath, args = []) {
|
|
12
|
+
const result = spawnSync(process.execPath, [scriptPath, ...args], {
|
|
13
|
+
cwd: packageRoot,
|
|
14
|
+
env: process.env,
|
|
15
|
+
encoding: "utf8",
|
|
16
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
17
|
+
windowsHide: true
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
if (result.status === 0) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (process.env.AIB_POSTINSTALL_STRICT === "1") {
|
|
25
|
+
process.stderr.write(result.stderr || result.stdout || `postinstall helper failed: ${scriptPath}\n`);
|
|
26
|
+
process.exit(result.status ?? 1);
|
|
27
|
+
}
|
|
28
|
+
}
|