@automaton-labs/aib 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +2 -2
- package/dist/commands/config-command.js +2 -1
- package/dist/commands/config-output.js +10 -8
- package/dist/commands/doctor.js +2 -1
- package/dist/commands/help-command.js +7 -3
- package/dist/commands/inspect-format.js +1 -1
- package/dist/commands/quick-read.js +8 -8
- package/dist/commands/result-view.js +5 -5
- package/dist/commands/session-workspace.js +8 -8
- package/dist/config/workspace-root.js +3 -3
- package/dist/help/bootstrap.md +92 -91
- package/dist/help/docs/config-setup.aliases.md +56 -0
- package/dist/help/docs/config-setup.excludes.md +45 -0
- package/dist/help/docs/config-setup.import-normalize.md +86 -0
- package/dist/help/docs/config-setup.import-rules.md +96 -0
- package/dist/help/docs/config-setup.tsconfigs.md +33 -0
- package/dist/help/docs/first-setup.md +63 -48
- package/dist/help/docs/help-format.md +4 -7
- package/dist/help/docs/help-protocol.md +26 -0
- package/dist/help/docs/inspect.cycles.md +38 -0
- package/dist/help/docs/inspect.md +1 -0
- package/dist/help/docs/modulePlan.md +3 -0
- package/dist/help/docs/move.md +3 -0
- package/dist/help/docs/mutation.md +3 -0
- package/dist/help/docs/patterns.md +7 -118
- package/dist/help/docs/qr.md +6 -2
- package/dist/help/docs/quick-map.md +30 -0
- package/dist/help/docs/reveal.md +30 -0
- package/dist/help/dsl/bootstrap.md +92 -91
- package/dist/help/dsl/docs/config-setup.aliases.md +56 -0
- package/dist/help/dsl/docs/config-setup.excludes.md +45 -0
- package/dist/help/dsl/docs/config-setup.import-normalize.md +86 -0
- package/dist/help/dsl/docs/config-setup.import-rules.md +96 -0
- package/dist/help/dsl/docs/config-setup.tsconfigs.md +33 -0
- package/dist/help/dsl/docs/first-setup.md +63 -48
- package/dist/help/dsl/docs/help-format.md +4 -7
- package/dist/help/dsl/docs/help-protocol.md +26 -0
- package/dist/help/dsl/docs/inspect.cycles.md +38 -0
- package/dist/help/dsl/docs/inspect.md +1 -0
- package/dist/help/dsl/docs/modulePlan.md +3 -0
- package/dist/help/dsl/docs/move.md +3 -0
- package/dist/help/dsl/docs/mutation.md +3 -0
- package/dist/help/dsl/docs/patterns.md +7 -118
- package/dist/help/dsl/docs/qr.md +6 -2
- package/dist/help/dsl/docs/quick-map.md +30 -0
- package/dist/help/dsl/docs/reveal.md +30 -0
- package/dist/help/dsl/full.md +92 -91
- package/dist/help/dsl/topics/config-setup.aliases.md +54 -0
- package/dist/help/dsl/topics/config-setup.excludes.md +43 -0
- package/dist/help/dsl/topics/config-setup.import-normalize.md +84 -0
- package/dist/help/dsl/topics/config-setup.import-rules.md +94 -0
- package/dist/help/dsl/topics/config-setup.tsconfigs.md +31 -0
- package/dist/help/dsl/topics/first-setup.md +63 -48
- package/dist/help/dsl/topics/help-format.md +4 -7
- package/dist/help/dsl/topics/help-protocol.md +24 -0
- package/dist/help/dsl/topics/inspect.cycles.md +36 -0
- package/dist/help/dsl/topics/inspect.md +1 -0
- package/dist/help/dsl/topics/modulePlan.md +3 -0
- package/dist/help/dsl/topics/move.md +3 -0
- package/dist/help/dsl/topics/mutation.md +3 -0
- package/dist/help/dsl/topics/patterns.md +7 -118
- package/dist/help/dsl/topics/qr.md +6 -2
- package/dist/help/dsl/topics/quick-map.md +28 -0
- package/dist/help/dsl/topics/reveal.md +28 -0
- package/dist/help/full.md +92 -91
- package/dist/help/help-meta.json +55 -19
- package/dist/help/index.md +54 -0
- package/dist/help/json/bootstrap.md +92 -91
- package/dist/help/json/docs/config-setup.aliases.md +56 -0
- package/dist/help/json/docs/config-setup.excludes.md +45 -0
- package/dist/help/json/docs/config-setup.import-normalize.md +86 -0
- package/dist/help/json/docs/config-setup.import-rules.md +96 -0
- package/dist/help/json/docs/config-setup.tsconfigs.md +33 -0
- package/dist/help/json/docs/first-setup.md +63 -48
- package/dist/help/json/docs/help-format.md +4 -7
- package/dist/help/json/docs/help-protocol.md +26 -0
- package/dist/help/json/docs/inspect.cycles.md +38 -0
- package/dist/help/json/docs/inspect.md +1 -0
- package/dist/help/json/docs/modulePlan.md +3 -0
- package/dist/help/json/docs/move.md +3 -0
- package/dist/help/json/docs/mutation.md +3 -0
- package/dist/help/json/docs/patterns.md +7 -118
- package/dist/help/json/docs/qr.md +6 -2
- package/dist/help/json/docs/quick-map.md +30 -0
- package/dist/help/json/docs/reveal.md +30 -0
- package/dist/help/json/full.md +92 -91
- package/dist/help/json/topics/config-setup.aliases.md +54 -0
- package/dist/help/json/topics/config-setup.excludes.md +43 -0
- package/dist/help/json/topics/config-setup.import-normalize.md +84 -0
- package/dist/help/json/topics/config-setup.import-rules.md +94 -0
- package/dist/help/json/topics/config-setup.tsconfigs.md +31 -0
- package/dist/help/json/topics/first-setup.md +63 -48
- package/dist/help/json/topics/help-format.md +4 -7
- package/dist/help/json/topics/help-protocol.md +24 -0
- package/dist/help/json/topics/inspect.cycles.md +36 -0
- package/dist/help/json/topics/inspect.md +1 -0
- package/dist/help/json/topics/modulePlan.md +3 -0
- package/dist/help/json/topics/move.md +3 -0
- package/dist/help/json/topics/mutation.md +3 -0
- package/dist/help/json/topics/patterns.md +7 -118
- package/dist/help/json/topics/qr.md +6 -2
- package/dist/help/json/topics/quick-map.md +28 -0
- package/dist/help/json/topics/reveal.md +28 -0
- package/dist/help/topics/config-setup.aliases.md +54 -0
- package/dist/help/topics/config-setup.excludes.md +43 -0
- package/dist/help/topics/config-setup.import-normalize.md +84 -0
- package/dist/help/topics/config-setup.import-rules.md +94 -0
- package/dist/help/topics/config-setup.tsconfigs.md +31 -0
- package/dist/help/topics/first-setup.md +63 -48
- package/dist/help/topics/help-format.md +4 -7
- package/dist/help/topics/help-protocol.md +24 -0
- package/dist/help/topics/inspect.cycles.md +36 -0
- package/dist/help/topics/inspect.md +1 -0
- package/dist/help/topics/modulePlan.md +3 -0
- package/dist/help/topics/move.md +3 -0
- package/dist/help/topics/mutation.md +3 -0
- package/dist/help/topics/patterns.md +7 -118
- package/dist/help/topics/qr.md +6 -2
- package/dist/help/topics/quick-map.md +28 -0
- package/dist/help/topics/reveal.md +28 -0
- package/dist/managed-host/serve-web-autostart.js +1 -1
- package/dist/managed-host/serve-web-host.cjs +193 -79
- package/dist/observability/config.js +1 -1
- package/dist/payloads/read-stdin-json.js +1 -1
- package/dist/runtime/managed-runtime-provisioning.js +1 -1
- package/dist/runtime/run-command.js +1 -1
- package/dist/session/server.js +7 -5
- package/dist/shared/diagnostic-catalog.js +1 -1
- package/dist/shared/errors.js +17 -15
- package/dist/shared/stdin-examples.js +3 -0
- package/dist/tracing/trace.js +5 -3
- package/extension/vscode-refactor-bridge-extension.vsix +0 -0
- package/package.json +1 -1
- package/runtimes/launcher/linux-x64/aib +0 -0
- package/runtimes/launcher/win-x64/aib.exe +0 -0
- package/scripts/provision-runtime.cjs +25 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Read:
|
|
2
|
+
qr quick reads: ts, js, cmd, sh, json, log, txt, etc.
|
|
3
|
+
view hidden/truncated output
|
|
4
|
+
|
|
5
|
+
Inspect:
|
|
6
|
+
file
|
|
7
|
+
imports
|
|
8
|
+
exports
|
|
9
|
+
members
|
|
10
|
+
code
|
|
11
|
+
deps
|
|
12
|
+
usages
|
|
13
|
+
graph
|
|
14
|
+
tree
|
|
15
|
+
duplicates
|
|
16
|
+
cycles
|
|
17
|
+
|
|
18
|
+
Mutate:
|
|
19
|
+
rename
|
|
20
|
+
move
|
|
21
|
+
modulePlan
|
|
22
|
+
refactor batch
|
|
23
|
+
imports normalize
|
|
24
|
+
|
|
25
|
+
Other:
|
|
26
|
+
config
|
|
27
|
+
prefs
|
|
28
|
+
reveal tsconfig and tsconfig alias discovery
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Use reveal to inspect TypeScript config discovery used by AIB.
|
|
2
|
+
|
|
3
|
+
Reveal is for config/setup diagnosis.
|
|
4
|
+
Use it when aliases, sync, imports normalize, or tsconfig excludes depend on which tsconfig files AIB sees.
|
|
5
|
+
|
|
6
|
+
Commands:
|
|
7
|
+
aib reveal tsconfigs
|
|
8
|
+
aib reveal tsaliases
|
|
9
|
+
|
|
10
|
+
tsconfigs shows visible TypeScript configs and config-excluded configs.
|
|
11
|
+
tsaliases shows baseUrl, paths, extends, inherited paths, duplicated inherited paths, and overridden inherited paths.
|
|
12
|
+
|
|
13
|
+
Controls:
|
|
14
|
+
all show all output instead of compact output
|
|
15
|
+
nec no config excludes; ignore sync.tsconfig.exclude
|
|
16
|
+
ned no default excludes
|
|
17
|
+
limit max visible groups/items before + N more
|
|
18
|
+
|
|
19
|
+
Examples:
|
|
20
|
+
aib reveal tsconfigs
|
|
21
|
+
aib reveal tsconfigs +all
|
|
22
|
+
aib reveal tsconfigs +nec limit=20
|
|
23
|
+
aib reveal tsaliases
|
|
24
|
+
aib reveal tsaliases +all
|
|
25
|
+
aib reveal tsaliases +nec
|
|
26
|
+
|
|
27
|
+
Use tsconfigs before tuning sync.tsconfig.exclude.
|
|
28
|
+
Use tsaliases before creating AIB pathAliases or configuring import normalization.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var x=exports&&exports.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var s=Object.getOwnPropertyDescriptor(e,n);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,s)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),D=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),M=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var r=[];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[r.length]=s);return r},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var r=t(e),s=0;s<r.length;s++)r[s]!=="default"&&x(n,e,r[s]);return D(n,e),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.startManagedServeWebForCwd=W,exports.stopManagedServeWebForCwd=R,exports.stopAllManagedServeWeb=L,exports.killAllManagedServeWeb=O,exports.statusManagedServeWebForCwd=V,exports.statusAllManagedServeWeb=H,exports.cleanupExpiredManagedServeWebForCwd=j;const g=M(require("node:fs")),c=M(require("node:path")),_=require("node:child_process"),u=require("../config/env-vars"),l=require("../shared/errors"),w=require("../shared/diagnostics"),S=require("./extension-vsix-resolver"),h=require("../config/workspace-root"),
|
|
1
|
+
"use strict";var x=exports&&exports.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var s=Object.getOwnPropertyDescriptor(e,n);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,s)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),D=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),M=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var r=[];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[r.length]=s);return r},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var r=t(e),s=0;s<r.length;s++)r[s]!=="default"&&x(n,e,r[s]);return D(n,e),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.startManagedServeWebForCwd=W,exports.stopManagedServeWebForCwd=R,exports.stopAllManagedServeWeb=L,exports.killAllManagedServeWeb=O,exports.statusManagedServeWebForCwd=V,exports.statusAllManagedServeWeb=H,exports.cleanupExpiredManagedServeWebForCwd=j;const g=M(require("node:fs")),c=M(require("node:path")),_=require("node:child_process"),u=require("../config/env-vars"),l=require("../shared/errors"),w=require("../shared/diagnostics"),S=require("./extension-vsix-resolver"),h=require("../config/workspace-root"),k=require("../runtime/bundled-node"),A=require("../runtime/managed-runtime-provisioning");function N(){const t=[c.resolve(__dirname),process.cwd()];for(const e of t){let n=e;for(;;){const r=c.join(n,"scripts","managed-host","manage-serve-web-host.cjs"),s=c.join(n,"package.json");if(g.existsSync(r)&&g.existsSync(s))return n;const o=c.dirname(n);if(o===n)break;n=o}}return null}function E(t){const e=process.env[t];return e&&e.trim()?c.resolve(e.trim()):null}function C(t){const e=process.env[t];return e&&e.trim()?e.trim():null}function T(){const t=process.env[u.CLI_ENV.managedHostWaitMs];if(t===void 0||t.trim()==="")return 45e3;const e=Number(t);if(!Number.isInteger(e)||e<=0)throw new l.CliError("AUTO_START_IDE_INVALID_WAIT_MS",`Expected ${u.CLI_ENV.managedHostWaitMs} to be a positive integer.`,{env:u.CLI_ENV.managedHostWaitMs,value:t,hints:(0,w.buildAutoStartIdeHints)()});return e}function f(){const t=E(u.CLI_ENV.managedHostScript),e=T(),n=C(u.CLI_ENV.ideCommand),r=E(u.CLI_ENV.chromePath),s=E(u.CLI_ENV.managedHostRunDir),o=N(),a=c.resolve(__dirname,"..","..");(0,A.ensureManagedRuntimeProvisioned)(a);const i=C(u.CLI_ENV.managedHostKind)??y(a),d=(0,k.resolveNodeRuntime)(a);if(t){const m=(0,S.resolveExtensionVsixPath)({repoRoot:o,packageRoot:a});return{scriptPath:t,vsixPath:m.path,vsixSource:m.source,cwd:c.dirname(t),waitMs:e,ideCommand:n,hostKind:i,chromePath:r,runDir:s,nodeCommand:d.command,nodeSource:d.source,source:"env"}}const p=c.join(__dirname,"manage-serve-web-host.cjs");if(g.existsSync(p)){const m=(0,S.resolveExtensionVsixPath)({repoRoot:o,packageRoot:a});return{scriptPath:p,vsixPath:m.path,vsixSource:m.source,cwd:c.resolve(__dirname,"..",".."),waitMs:e,ideCommand:n,hostKind:i,chromePath:r,runDir:s,nodeCommand:d.command,nodeSource:d.source,source:"packaged-cli"}}if(o){const m=(0,S.resolveExtensionVsixPath)({repoRoot:o,packageRoot:a});return{scriptPath:c.join(o,"scripts","managed-host","manage-serve-web-host.cjs"),vsixPath:m.path,vsixSource:m.source,cwd:o,waitMs:e,ideCommand:n,hostKind:i,chromePath:r,runDir:s,nodeCommand:d.command,nodeSource:d.source,source:"repo-dev-fallback"}}throw new l.CliError("AUTO_START_IDE_UNAVAILABLE","Managed IDE auto-start is unavailable because no packaged managed-host assets or development repo managed-host scripts were found.",{searchedFrom:[c.resolve(__dirname),process.cwd()],optionalEnv:[u.CLI_ENV.managedHostScript,u.CLI_ENV.extensionVsix],hints:(0,w.buildAutoStartIdeHints)()})}function y(t){const e=c.join(t,"runtimes","code-server","node_modules","code-server","out","node","entry.js");return g.existsSync(e)&&(0,A.managedRuntimePlatformStatus)(t).ok?"code-server":null}function b(t,e,n,r){if(!g.existsSync(t))throw new l.CliError(e,n,{...r,hints:(0,w.buildAutoStartIdeHints)(),path:t})}function v(t){try{return JSON.parse(t)}catch(e){throw new l.CliError("AUTO_START_IDE_INVALID_OUTPUT","Managed IDE host returned non-JSON output.",{stdout:t,parseError:e instanceof Error?e.message:String(e)})}}async function W(t){const e=f(),r=(0,h.resolveRequiredWorkspaceRoot)(t).root,s=P(r),o=F(r);b(e.scriptPath,"AUTO_START_IDE_SCRIPT_NOT_FOUND","Managed IDE auto-start needs a managed host script.",{env:u.CLI_ENV.managedHostScript,source:e.source}),b(e.vsixPath,"AUTO_START_IDE_VSIX_NOT_FOUND","Managed IDE auto-start needs a packaged extension VSIX.",{env:u.CLI_ENV.extensionVsix,source:e.source,vsixSource:e.vsixSource,hint:e.source==="repo-dev-fallback"?"Run npm --prefix packages/extension run package:vsix before using --auto-start-ide.":`Set ${u.CLI_ENV.extensionVsix} to an existing packaged VSIX path.`});const a=[e.scriptPath,"start","--fixture",r,"--vsix",e.vsixPath,"--wait-ms",String(e.waitMs),"--ttl-ms",String(s),"--interval-ms",String(o)];e.ideCommand&&a.push("--ide-command",e.ideCommand),e.hostKind&&a.push("--host-kind",e.hostKind),e.chromePath&&a.push("--chrome-path",e.chromePath),e.runDir&&a.push("--run-dir",e.runDir);const i=(0,_.spawnSync)(e.nodeCommand,a,{cwd:e.cwd,encoding:"utf8",windowsHide:!0,timeout:e.waitMs+45e3,stdio:["ignore","pipe","pipe"]}),d=i.stdout??"",p=d.trim()?v(d):null;if(i.status!==0||!p||p.ok!==!0)throw new l.CliError("AUTO_START_IDE_FAILED","Managed IDE auto-start failed.",{status:i.status,signal:i.signal,error:i.error?i.error.message:null,stdout:d,stderr:i.stderr??"",runtime:{source:e.source,scriptPath:e.scriptPath,vsixPath:e.vsixPath,vsixSource:e.vsixSource,waitMs:e.waitMs,ideCommand:e.ideCommand,hostKind:e.hostKind,chromePath:e.chromePath,runDir:e.runDir,nodeCommand:e.nodeCommand,nodeSource:e.nodeSource},hints:(0,w.buildAutoStartIdeHints)(),payload:p});return p}async function R(t){const e=f(),n=(0,h.resolveRequiredWorkspaceRoot)(t),r=[e.scriptPath,"stop","--fixture",n.root];e.ideCommand&&r.push("--ide-command",e.ideCommand),e.hostKind&&r.push("--host-kind",e.hostKind);const s=(0,_.spawnSync)(e.nodeCommand,r,{cwd:e.cwd,encoding:"utf8",windowsHide:!0,timeout:3e4,stdio:["ignore","pipe","pipe"]}),o=s.stdout??"",a=o.trim()?v(o):null;if(s.status!==0||!a||a.ok!==!0)throw new l.CliError("MANAGED_IDE_STOP_FAILED","Managed IDE stop failed.",{status:s.status,signal:s.signal,error:s.error?s.error.message:null,stdout:o,stderr:s.stderr??"",workspaceRoot:n.root});return K(n.root,a)}async function L(){return I(["stop","--all"],"MANAGED_IDE_STOP_FAILED")}async function O(){return I(["kill","--all"],"MANAGED_IDE_KILL_FAILED")}async function V(t){const e=f(),n=(0,h.resolveRequiredWorkspaceRoot)(t),r=[e.scriptPath,"status","--fixture",n.root];e.ideCommand&&r.push("--ide-command",e.ideCommand),e.hostKind&&r.push("--host-kind",e.hostKind);const s=(0,_.spawnSync)(e.nodeCommand,r,{cwd:e.cwd,encoding:"utf8",windowsHide:!0,timeout:3e4,stdio:["ignore","pipe","pipe"]}),o=s.stdout??"",a=o.trim()?v(o):null;if(s.status!==0||!a||a.ok!==!0)throw new l.CliError("MANAGED_IDE_STATUS_FAILED","Managed IDE status failed.",{status:s.status,signal:s.signal,error:s.error?s.error.message:null,stdout:o,stderr:s.stderr??"",workspaceRoot:n.root});return q(n.root,a)}async function H(){return I(["status","--all"],"MANAGED_IDE_STATUS_FAILED")}async function j(t){const e=f(),n=(0,h.resolveRequiredWorkspaceRoot)(t),r=P(n.root),s=[e.scriptPath,"cleanup","--ttl-ms",String(r)];e.ideCommand&&s.push("--ide-command",e.ideCommand),e.hostKind&&s.push("--host-kind",e.hostKind);const o=(0,_.spawnSync)(e.nodeCommand,s,{cwd:e.cwd,encoding:"utf8",windowsHide:!0,timeout:3e4,stdio:["ignore","pipe","pipe"]}),a=o.stdout??"",i=a.trim()?v(a):null;if(o.status!==0||!i||i.ok!==!0)throw new l.CliError("MANAGED_IDE_CLEANUP_FAILED","Managed IDE cleanup failed.",{status:o.status,signal:o.signal,error:o.error?o.error.message:null,stdout:a,stderr:o.stderr??"",workspaceRoot:n.root});return i}function I(t,e){const n=f(),r=(0,_.spawnSync)(n.nodeCommand,[n.scriptPath,...t],{cwd:n.cwd,encoding:"utf8",windowsHide:!0,timeout:45e3,stdio:["ignore","pipe","pipe"]}),s=r.stdout??"",o=s.trim()?v(s):null;if(r.status!==0||!o||o.ok!==!0)throw new l.CliError(e,"Managed IDE runtime command failed.",{status:r.status,signal:r.signal,error:r.error?r.error.message:null,stdout:s,stderr:r.stderr??"",args:t});return o}function P(t){if(!(0,h.readWorkspaceBooleanConfig)(t,"runtime.autoStopManagedIde",!0))return 0;const n=(0,h.readWorkspaceNumberConfig)(t,"runtime.managedIdeTtlMinutes",15);return n>0?Math.round(n*6e4):0}function F(t){const e=(0,h.readWorkspaceNumberConfig)(t,"runtime.managedIdeWatchdogIntervalMs",3e4);return e>0?Math.round(e):3e4}function K(t,e){return{stopped:e.stopped===!0,workspaceRoot:t,...typeof e.hostId=="string"?{hostId:e.hostId}:{},...typeof e.reason=="string"?{reason:e.reason}:{}}}function q(t,e){const n=e.metadata&&typeof e.metadata=="object"&&!Array.isArray(e.metadata)?e.metadata:{},r=e.health&&typeof e.health=="object"&&!Array.isArray(e.health)?e.health:{};return{ok:!0,workspaceRoot:t,workspace:".",hostId:typeof e.hostId=="string"?e.hostId:null,host:typeof n.hostKind=="string"?n.hostKind:"managed",running:e.running===!0,healthy:e.healthy===!0,reason:typeof e.reason=="string"?e.reason:null,health:{serveWebAlive:r.serveWebAlive===!0,browserAlive:r.browserAlive===!0,extensionHostAlive:r.extensionHostAlive===!0,workspaceMatches:r.workspaceMatches===!0,vsixMatches:r.vsixMatches===!0}}}
|
|
@@ -339,21 +339,51 @@ function startLoggedCommand(commandSpec, args, options) {
|
|
|
339
339
|
return startLoggedProcess(commandExecutable(commandSpec), commandArgs(commandSpec, args), options);
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
-
function resolvePackagedCodeServerCommand() {
|
|
343
|
-
const nodeRuntime = resolvePackagedNodeRuntime();
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
342
|
+
function resolvePackagedCodeServerCommand() {
|
|
343
|
+
const nodeRuntime = resolvePackagedNodeRuntime();
|
|
344
|
+
const candidates = [
|
|
345
|
+
{
|
|
346
|
+
packageRoot: rootDir,
|
|
347
|
+
entryPath: path.join(rootDir, "runtimes", "code-server", "node_modules", "code-server", "out", "node", "entry.js")
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
packageRoot: path.join(rootDir, "packages", "cli"),
|
|
351
|
+
entryPath: path.join(rootDir, "packages", "cli", "runtimes", "code-server", "node_modules", "code-server", "out", "node", "entry.js")
|
|
352
|
+
}
|
|
353
|
+
];
|
|
354
|
+
for (const { packageRoot, entryPath } of candidates) {
|
|
355
|
+
if (fs.existsSync(entryPath) && managedRuntimePlatformStatus(packageRoot).ok) {
|
|
356
|
+
return makeCommandSpec(nodeRuntime.command, [entryPath], nodeRuntime.source === "packaged-node"
|
|
357
|
+
? "packaged-code-server-entry-bundled-node"
|
|
358
|
+
: "packaged-code-server-entry");
|
|
353
359
|
}
|
|
354
360
|
}
|
|
355
|
-
return null;
|
|
356
|
-
}
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function managedRuntimePlatformStatus(packageRoot) {
|
|
365
|
+
const markerPath = path.join(packageRoot, "runtimes", ".aib-runtime-platform.json");
|
|
366
|
+
const expectedPlatformKey = `${process.platform}-${process.arch}`;
|
|
367
|
+
if (!fs.existsSync(markerPath)) {
|
|
368
|
+
return { ok: true, reason: "missing", expectedPlatformKey, actualPlatformKey: null };
|
|
369
|
+
}
|
|
370
|
+
try {
|
|
371
|
+
const marker = JSON.parse(fs.readFileSync(markerPath, "utf8"));
|
|
372
|
+
const actualPlatformKey = typeof marker.platformKey === "string"
|
|
373
|
+
? marker.platformKey
|
|
374
|
+
: typeof marker.platform === "string" && typeof marker.arch === "string"
|
|
375
|
+
? `${marker.platform}-${marker.arch}`
|
|
376
|
+
: null;
|
|
377
|
+
return {
|
|
378
|
+
ok: actualPlatformKey === expectedPlatformKey,
|
|
379
|
+
reason: actualPlatformKey === expectedPlatformKey ? "ok" : "mismatch",
|
|
380
|
+
expectedPlatformKey,
|
|
381
|
+
actualPlatformKey
|
|
382
|
+
};
|
|
383
|
+
} catch {
|
|
384
|
+
return { ok: false, reason: "invalid", expectedPlatformKey, actualPlatformKey: null };
|
|
385
|
+
}
|
|
386
|
+
}
|
|
357
387
|
|
|
358
388
|
function resolveManagedHostKind(options, commandSpec) {
|
|
359
389
|
const raw = options.hostKind ?? process.env.AIB_MANAGED_HOST_KIND ?? "";
|
|
@@ -652,33 +682,108 @@ function stopProcessTree(pid) {
|
|
|
652
682
|
}
|
|
653
683
|
}
|
|
654
684
|
|
|
655
|
-
function stopProcessesByCommandLineFragment(fragment) {
|
|
656
|
-
if (
|
|
657
|
-
return {
|
|
658
|
-
attempted: false,
|
|
659
|
-
fragment
|
|
660
|
-
};
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
"
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
685
|
+
function stopProcessesByCommandLineFragment(fragment) {
|
|
686
|
+
if (!fragment) {
|
|
687
|
+
return {
|
|
688
|
+
attempted: false,
|
|
689
|
+
fragment
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
if (process.platform !== "win32") {
|
|
693
|
+
return stopProcessesByCommandLineFragmentUnix(fragment);
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
const escaped = String(fragment).replace(/'/g, "''");
|
|
697
|
+
const script = [
|
|
698
|
+
"$self = $PID",
|
|
699
|
+
"$fragment = '" + escaped + "'",
|
|
700
|
+
"Get-CimInstance Win32_Process |",
|
|
701
|
+
"Where-Object { $_.ProcessId -ne $self -and $_.CommandLine -and $_.CommandLine.Contains($fragment) } |",
|
|
702
|
+
"ForEach-Object { try { Stop-Process -Id $_.ProcessId -Force -ErrorAction Stop; $_.ProcessId } catch {} }"
|
|
703
|
+
].join("\n");
|
|
704
|
+
const result = run("powershell.exe", ["-NoProfile", "-Command", script], { timeoutMs: 10_000 });
|
|
705
|
+
const killed = result.stdout
|
|
706
|
+
.split(/\r?\n/)
|
|
707
|
+
.map((line) => line.trim())
|
|
708
|
+
.filter(Boolean).length;
|
|
709
|
+
return {
|
|
710
|
+
attempted: true,
|
|
711
|
+
fragment,
|
|
712
|
+
killed,
|
|
713
|
+
status: result.status,
|
|
714
|
+
error: result.error,
|
|
715
|
+
stdoutTail: tail(result.stdout, 1000),
|
|
677
716
|
stderrTail: tail(result.stderr, 1000)
|
|
678
|
-
};
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
function
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
function stopProcessesByCommandLineFragmentUnix(fragment) {
|
|
721
|
+
const result = run("ps", ["-eo", "pid=,args="], { timeoutMs: 10_000 });
|
|
722
|
+
if (result.status !== 0) {
|
|
723
|
+
return {
|
|
724
|
+
attempted: true,
|
|
725
|
+
fragment,
|
|
726
|
+
killed: 0,
|
|
727
|
+
status: result.status,
|
|
728
|
+
error: result.error,
|
|
729
|
+
stdoutTail: tail(result.stdout, 1000),
|
|
730
|
+
stderrTail: tail(result.stderr, 1000)
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
const currentPid = process.pid;
|
|
735
|
+
const parentPid = process.ppid;
|
|
736
|
+
const pids = result.stdout
|
|
737
|
+
.split(/\r?\n/)
|
|
738
|
+
.map((line) => {
|
|
739
|
+
const match = line.match(/^\s*(\d+)\s+(.*)$/);
|
|
740
|
+
if (!match) {
|
|
741
|
+
return null;
|
|
742
|
+
}
|
|
743
|
+
return {
|
|
744
|
+
pid: Number(match[1]),
|
|
745
|
+
commandLine: match[2] ?? ""
|
|
746
|
+
};
|
|
747
|
+
})
|
|
748
|
+
.filter(Boolean)
|
|
749
|
+
.filter((row) => row.pid !== currentPid && row.pid !== parentPid)
|
|
750
|
+
.filter((row) => row.commandLine.includes(fragment))
|
|
751
|
+
.map((row) => row.pid);
|
|
752
|
+
|
|
753
|
+
const uniquePids = [...new Set(pids)].filter((pid) => Number.isInteger(pid) && pid > 0);
|
|
754
|
+
let killed = 0;
|
|
755
|
+
const errors = [];
|
|
756
|
+
for (const pid of uniquePids) {
|
|
757
|
+
try {
|
|
758
|
+
process.kill(pid, "SIGTERM");
|
|
759
|
+
killed += 1;
|
|
760
|
+
} catch (error) {
|
|
761
|
+
errors.push(`${pid}: ${error instanceof Error ? error.message : String(error)}`);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
if (killed > 0) {
|
|
765
|
+
sleepSync(250);
|
|
766
|
+
}
|
|
767
|
+
for (const pid of uniquePids) {
|
|
768
|
+
if (!isProcessAlive(pid)) {
|
|
769
|
+
continue;
|
|
770
|
+
}
|
|
771
|
+
try {
|
|
772
|
+
process.kill(pid, "SIGKILL");
|
|
773
|
+
} catch (error) {
|
|
774
|
+
errors.push(`${pid}: ${error instanceof Error ? error.message : String(error)}`);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
return {
|
|
778
|
+
attempted: true,
|
|
779
|
+
fragment,
|
|
780
|
+
killed,
|
|
781
|
+
status: errors.length === 0 ? 0 : 1,
|
|
782
|
+
error: errors.join("; ") || null
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
function stopOrphanedPackagedRuntimeProcesses(activeRunDirs = []) {
|
|
682
787
|
if (process.platform !== "win32") {
|
|
683
788
|
return {
|
|
684
789
|
attempted: false,
|
|
@@ -962,13 +1067,16 @@ async function acquireLock(hostId, timeoutMs = 15_000, staleMs = 120_000) {
|
|
|
962
1067
|
fs.rmSync(lockDir, { recursive: true, force: true });
|
|
963
1068
|
}
|
|
964
1069
|
};
|
|
965
|
-
} catch (error) {
|
|
966
|
-
if (error && error.code === "EEXIST") {
|
|
967
|
-
const
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
1070
|
+
} catch (error) {
|
|
1071
|
+
if (error && error.code === "EEXIST") {
|
|
1072
|
+
const owner = readJsonFile(path.join(lockDir, "owner.json"));
|
|
1073
|
+
const ownerPid = Number.isInteger(owner?.pid) ? owner.pid : null;
|
|
1074
|
+
const ownerAlive = ownerPid !== null && isProcessAlive(ownerPid);
|
|
1075
|
+
const stat = fs.statSync(lockDir);
|
|
1076
|
+
if ((ownerPid !== null && !ownerAlive) || Date.now() - stat.mtimeMs > staleMs) {
|
|
1077
|
+
fs.rmSync(lockDir, { recursive: true, force: true });
|
|
1078
|
+
continue;
|
|
1079
|
+
}
|
|
972
1080
|
await sleep(250);
|
|
973
1081
|
continue;
|
|
974
1082
|
}
|
|
@@ -1130,9 +1238,10 @@ async function startManagedServeWebHost(options = {}) {
|
|
|
1130
1238
|
return record;
|
|
1131
1239
|
}
|
|
1132
1240
|
|
|
1133
|
-
const lock = await acquireLock(hostId);
|
|
1134
|
-
try {
|
|
1135
|
-
|
|
1241
|
+
const lock = await acquireLock(hostId, Math.max(90_000, waitMs + 45_000));
|
|
1242
|
+
try {
|
|
1243
|
+
const orphanCleanup = readMetadataByHostId(hostId) ? null : stopProcessesByCommandLineFragment(hostId);
|
|
1244
|
+
if (reuse) {
|
|
1136
1245
|
const existingStatus = await getManagedServeWebHostStatus({ fixture, hostId, vsix, ideCommand: options.ideCommand, hostKind });
|
|
1137
1246
|
if (existingStatus.healthy) {
|
|
1138
1247
|
const updatedMetadata = {
|
|
@@ -1156,11 +1265,12 @@ async function startManagedServeWebHost(options = {}) {
|
|
|
1156
1265
|
runDir: existingStatus.metadata.runDir ?? runDir,
|
|
1157
1266
|
logsDir: existingStatus.metadata.logsDir ?? logsDir,
|
|
1158
1267
|
stepsDir: existingStatus.metadata.stepsDir ?? stepsDir,
|
|
1159
|
-
metadata: updatedMetadata,
|
|
1160
|
-
steps,
|
|
1161
|
-
failures
|
|
1162
|
-
|
|
1163
|
-
|
|
1268
|
+
metadata: updatedMetadata,
|
|
1269
|
+
steps,
|
|
1270
|
+
failures,
|
|
1271
|
+
orphanCleanup
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1164
1274
|
if (existingStatus.metadata) {
|
|
1165
1275
|
await stopManagedServeWebHost({ fixture, hostId, removeMetadataOnlyIfKnown: true });
|
|
1166
1276
|
}
|
|
@@ -1221,7 +1331,7 @@ async function startManagedServeWebHost(options = {}) {
|
|
|
1221
1331
|
};
|
|
1222
1332
|
});
|
|
1223
1333
|
if (failures.length > 0) {
|
|
1224
|
-
return buildStartSummary({ ok: false, reused: false, startedAt, hostId, fixture, vsix, codeCommand, hostKind, runDir, logsDir, stepsDir, metadata, steps, failures });
|
|
1334
|
+
return buildStartSummary({ ok: false, reused: false, startedAt, hostId, fixture, vsix, codeCommand, hostKind, runDir, logsDir, stepsDir, metadata, steps, failures, orphanCleanup });
|
|
1225
1335
|
}
|
|
1226
1336
|
|
|
1227
1337
|
const port = Number.isInteger(options.port) ? options.port : await allocatePort();
|
|
@@ -1317,7 +1427,7 @@ async function startManagedServeWebHost(options = {}) {
|
|
|
1317
1427
|
});
|
|
1318
1428
|
if (failures.length > 0) {
|
|
1319
1429
|
stopProcessTree(serveWebProcess?.child?.pid);
|
|
1320
|
-
return buildStartSummary({ ok: false, reused: false, startedAt, hostId, fixture, vsix, codeCommand, hostKind, runDir, logsDir, stepsDir, metadata, steps, failures });
|
|
1430
|
+
return buildStartSummary({ ok: false, reused: false, startedAt, hostId, fixture, vsix, codeCommand, hostKind, runDir, logsDir, stepsDir, metadata, steps, failures, orphanCleanup });
|
|
1321
1431
|
}
|
|
1322
1432
|
|
|
1323
1433
|
await step("open headless browser client", async () => {
|
|
@@ -1408,7 +1518,7 @@ async function startManagedServeWebHost(options = {}) {
|
|
|
1408
1518
|
if (failures.length > 0) {
|
|
1409
1519
|
stopProcessTree(browserProcess?.pid);
|
|
1410
1520
|
stopProcessTree(serveWebProcess?.child?.pid);
|
|
1411
|
-
return buildStartSummary({ ok: false, reused: false, startedAt, hostId, fixture, vsix, codeCommand, hostKind, runDir, logsDir, stepsDir, metadata, steps, failures });
|
|
1521
|
+
return buildStartSummary({ ok: false, reused: false, startedAt, hostId, fixture, vsix, codeCommand, hostKind, runDir, logsDir, stepsDir, metadata, steps, failures, orphanCleanup });
|
|
1412
1522
|
}
|
|
1413
1523
|
|
|
1414
1524
|
const registryEntry = steps.at(-1)?.detail?.state?.entry ?? null;
|
|
@@ -1454,10 +1564,11 @@ async function startManagedServeWebHost(options = {}) {
|
|
|
1454
1564
|
logsDir,
|
|
1455
1565
|
stepsDir,
|
|
1456
1566
|
metadata,
|
|
1457
|
-
registryEntry,
|
|
1458
|
-
steps,
|
|
1459
|
-
failures
|
|
1460
|
-
|
|
1567
|
+
registryEntry,
|
|
1568
|
+
steps,
|
|
1569
|
+
failures,
|
|
1570
|
+
orphanCleanup
|
|
1571
|
+
});
|
|
1461
1572
|
} finally {
|
|
1462
1573
|
lock.release();
|
|
1463
1574
|
}
|
|
@@ -1470,18 +1581,20 @@ async function stopManagedServeWebHost(options = {}) {
|
|
|
1470
1581
|
|
|
1471
1582
|
const fixture = path.resolve(options.fixture ?? defaultFixtureDir);
|
|
1472
1583
|
const codeCommand = resolveManagedIdeCommand(options);
|
|
1473
|
-
const hostKind = resolveManagedHostKind(options, codeCommand);
|
|
1474
|
-
const hostId = options.hostId ?? buildHostId({ fixture, hostKind });
|
|
1475
|
-
const metadata = readMetadataByHostId(hostId);
|
|
1476
|
-
if (!metadata) {
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1584
|
+
const hostKind = resolveManagedHostKind(options, codeCommand);
|
|
1585
|
+
const hostId = options.hostId ?? buildHostId({ fixture, hostKind });
|
|
1586
|
+
const metadata = readMetadataByHostId(hostId);
|
|
1587
|
+
if (!metadata) {
|
|
1588
|
+
const orphanCleanup = stopProcessesByCommandLineFragment(hostId);
|
|
1589
|
+
return {
|
|
1590
|
+
ok: true,
|
|
1591
|
+
hostId,
|
|
1592
|
+
hostKind,
|
|
1593
|
+
stopped: (orphanCleanup.killed ?? 0) > 0,
|
|
1594
|
+
reason: (orphanCleanup.killed ?? 0) > 0 ? "orphan-processes-stopped" : "metadata-not-found",
|
|
1595
|
+
orphanCleanup
|
|
1596
|
+
};
|
|
1597
|
+
}
|
|
1485
1598
|
|
|
1486
1599
|
const stopResults = [];
|
|
1487
1600
|
const watchdog = readJsonFile(getWatchdogPath(hostId));
|
|
@@ -1762,12 +1875,13 @@ function buildStartSummary(input) {
|
|
|
1762
1875
|
runDir: input.runDir,
|
|
1763
1876
|
metadata: input.metadata,
|
|
1764
1877
|
registryEntry: input.registryEntry ?? null,
|
|
1765
|
-
artifacts: {
|
|
1766
|
-
logsDir: input.logsDir,
|
|
1767
|
-
stepsDir: input.stepsDir,
|
|
1768
|
-
summaryPath
|
|
1769
|
-
},
|
|
1770
|
-
|
|
1878
|
+
artifacts: {
|
|
1879
|
+
logsDir: input.logsDir,
|
|
1880
|
+
stepsDir: input.stepsDir,
|
|
1881
|
+
summaryPath
|
|
1882
|
+
},
|
|
1883
|
+
orphanCleanup: input.orphanCleanup ?? null,
|
|
1884
|
+
steps: input.steps.map((record) => ({
|
|
1771
1885
|
name: record.name,
|
|
1772
1886
|
ok: record.ok,
|
|
1773
1887
|
durationMs: record.durationMs,
|
|
@@ -1 +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=
|
|
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=h,exports.failureSnapshotsEnabled=g,exports.defaultTraceWorkspaceDir=S,exports.feedbackFilePath=_,exports.failureSnapshotsRoot=k,exports.observabilityStatus=E;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=R(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 h(){return l().trace!=="off"}function g(){return l().failureSnapshots==="on"&&h()}function S(e){const t=(0,y.resolveWorkspaceIdentity)(e);return n.default.join((0,u.productStorageRoot)(),"trace","workspaces",t.workspaceId)}function _(){return n.default.join((0,u.productStorageRoot)(),"feedback","feedback.jsonl")}function k(e){const t=(0,y.resolveWorkspaceIdentity)(e);return n.default.join((0,u.productStorageRoot)(),"failure-snapshots","workspaces",t.workspaceId)}function E(e){const t=l(),r=(0,u.productStorageRoot)(),o=S(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=k(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:v(n.default.join(i,"metrics.jsonl")),metricsBytes:p(n.default.join(i,"metrics.jsonl")),traceBytes:m(n.default.dirname(n.default.dirname(o))),feedbackRows:v(a),feedbackBytes:p(a),failureSnapshotBytes:m(f),failureSnapshotCount:I(f)},cleanup:{enforced:!1,dryRunAvailable:!0,note:"Retention config is visible but automatic cleanup is not enforced yet."}}}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 R(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 v(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 I(e){let t=0;try{for(const r of c.default.readdirSync(e,{withFileTypes:!0}))r.isDirectory()&&(t+=1+I(n.default.join(e,r.name)))}catch{return 0}return t}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.readStdinJson=f,exports.readStdinPayload=p,exports.readStdinPayloadWithSource=S,exports.parseStdinPayload=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.readStdinJson=f,exports.readStdinPayload=p,exports.readStdinPayloadWithSource=S,exports.parseStdinPayload=d,exports.parseInputPayloadWithSource=u,exports.stripStdinFormatFlags=w,exports.readRawStdinText=c;const s=require("../dsl/aib-dsl"),m=require("../config/env-vars"),a=require("../shared/errors");async function f(e){const r=await c();return d(r,e??{command:"",restArgs:[]})}async function p(e){const r=await c();return d(r,e)}async function S(e){const r=await c();return u(r,e)}function d(e,r){return u(e,r).payload}function u(e,r){const t=e.replace(/^\uFEFF/,"").trim();if(!t)throw new a.CliError("EMPTY_STDIN","Expected JSON or DSL payload on stdin.");if(y(r.format)==="dsl"){const i=l(t,r);return{payload:i.payload,source:{format:"dsl",text:t,command:i.command}}}if(D(t))return{payload:h(t),source:{format:"json",text:t}};const o=l(t,r);return{payload:o.payload,source:{format:"dsl",text:t,command:o.command}}}function w(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 i=e[n+1];if(i!=="auto"&&i!=="dsl")throw new a.CliError("INVALID_STDIN_FORMAT","Expected --stdin-format to be auto or dsl.");t=i,n+=1;continue}o!==void 0&&r.push(o)}return{restArgs:r,...t!==void 0?{format:t}:{}}}function y(e){return e!==void 0?e:process.env[m.CLI_ENV.forceDsl]==="1"?"dsl":"auto"}async function c(){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 D(e){const r=e[0];return r==="{"||r==="["}function h(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,s.compileAibDsl)(e)}catch{n=(0,s.compileAibDsl)(e,{tolerantInspect:!0})}else n=(0,s.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}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=exports&&exports.__createBinding||(Object.create?(function(e,n,i,r){r===void 0&&(r=i);var t=Object.getOwnPropertyDescriptor(n,i);(!t||("get"in t?!n.__esModule:t.writable||t.configurable))&&(t={enumerable:!0,get:function(){return n[i]}}),Object.defineProperty(e,r,t)}):(function(e,n,i,r){r===void 0&&(r=i),e[r]=n[i]})),p=exports&&exports.__setModuleDefault||(Object.create?(function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}):function(e,n){e.default=n}),a=exports&&exports.__importStar||(function(){var e=function(n){return e=Object.getOwnPropertyNames||function(i){var r=[];for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(r[r.length]=t);return r},e(n)};return function(n){if(n&&n.__esModule)return n;var i={};if(n!=null)for(var r=e(n),t=0;t<r.length;t++)r[t]!=="default"&&d(i,n,r[t]);return p(i,n),i}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.ensureManagedRuntimeProvisioned=h,exports.isManagedRuntimeComplete=c,exports.managedRuntimePlatformStatus=f,exports.runtimePlatformKey=l;const u=a(require("node:fs")),o=a(require("node:path")),y=require("node:child_process");function h(e){if(c(e))return;const n=o.join(e,"scripts","provision-runtime.cjs");u.existsSync(n)&&(0,y.spawnSync)(process.execPath,[n,"--quiet"],{cwd:e,env:process.env,encoding:"utf8",stdio:["ignore","pipe","pipe"],windowsHide:!0,timeout:6e5})}function c(e){return u.existsSync(o.join(e,"runtimes","code-server","node_modules","code-server","out","node","entry.js"))&&!!w(e)&&!!P(e)&&f(e).ok}function f(e){const n=o.join(e,"runtimes",".aib-runtime-platform.json"),i=l();if(!u.existsSync(n))return{ok:!0,markerPath:n,expectedPlatformKey:i,actualPlatformKey:null,reason:"missing"};try{const r=JSON.parse(u.readFileSync(n,"utf8")),t=typeof r.platformKey=="string"?r.platformKey:typeof r.platform=="string"&&typeof r.arch=="string"?`${r.platform}-${r.arch}`:null;return{ok:t===i,markerPath:n,expectedPlatformKey:i,actualPlatformKey:t,reason:t===i?"ok":"mismatch"}}catch{return{ok:!1,markerPath:n,expectedPlatformKey:i,actualPlatformKey:null,reason:"invalid"}}}function l(){return`${process.platform}-${process.arch}`}function P(e){const n=_();if(!n)return null;const i=process.platform==="win32"?o.join(e,"runtimes","node",n,"node.exe"):o.join(e,"runtimes","node",n,"bin","node");return u.existsSync(i)?i: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=[o.join(e,"runtimes","browser"),o.join(e,"runtimes","chrome"),o.join(e,"runtimes","chromium")],i=process.platform==="win32"?new Set(["chrome.exe","chromium.exe","msedge.exe"]):new Set(["chrome","chromium"]);for(const r of n){const t=m(r,i,5);if(t)return t}return null}function m(e,n,i){if(!u.existsSync(e)||i<0)return null;let r;try{r=u.readdirSync(e,{withFileTypes:!0})}catch{return null}for(const t of r){const s=o.join(e,t.name);if(t.isFile()&&n.has(t.name))return s}for(const t of r){if(!t.isDirectory())continue;const s=m(o.join(e,t.name),n,i-1);if(s)return s}return null}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.runCommand=z;const P=require("../commands/list-instances"),b=require("../commands/ping"),k=require("../commands/runtime-info"),S=require("../commands/print-config"),R=require("../commands/init-skill-usage"),x=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"),y=require("../commands/session-workspace"),I=require("../config/path-aliases"),J=require("../commands/runtime-command"),K=require("../commands/sync-command"),L=require("../commands/reveal-command"),p=require("../client/transport-options"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.runCommand=z;const P=require("../commands/list-instances"),b=require("../commands/ping"),k=require("../commands/runtime-info"),S=require("../commands/print-config"),R=require("../commands/init-skill-usage"),x=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"),y=require("../commands/session-workspace"),I=require("../config/path-aliases"),J=require("../commands/runtime-command"),K=require("../commands/sync-command"),L=require("../commands/reveal-command"),p=require("../client/transport-options"),l=require("../shared/errors"),m=require("./input-source"),$=require("../config/workspace-state");async function z(n){return(0,y.runWithSessionOverride)(n.sessionId,()=>B(n))}async function B(n){const{command:o,restArgs:d,cwd:r,instanceId:_,metricsSpans:g}=n,u=V(o)?(0,$.ensureWorkspaceState)(r):null,C=u?(0,y.readSessionPathAliasOverrides)(r):{},f={...u?.pathAliases??{},...C},e=(0,I.expandPathAliasesInArgs)(r,d,f),a=await(0,m.resolveCommandInputSource)({command:o,cwd:r,restArgs:e,...n.stdinPayload!==void 0?{preResolvedPayload:(0,I.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 w=(0,p.getPreferredTransport)();n.transport&&(0,p.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"),progress:e.includes("--progress")});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,x.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"reveal":return(0,L.runRevealCommand)(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",v={cwd:r,cliName:q??"aib"};return v.resolveOptions=t,(0,R.runInitSkillUsage)(v)}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,m.commandRequiresPayload)(o,e,a))throw new l.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,m.commandRequiresPayload)(o,e,a))throw new l.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,m.commandRequiresPayload)(o,e,a))throw new l.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 l.CliError("UNKNOWN_COMMAND",`Unknown command: ${o}`,{availableCommands:["doctor","diagnostics","listInstances","ping","runtimeInfo","printConfig","init-skill-usage","init","help","generate-docs","sync","reveal","inspect","imports","execution","move","rename","refactor","modulePlan","session","runtime","trace","observability","feedback","note"]})}}finally{(0,p.setPreferredTransport)(w)}}function V(n){return n!=="init"&&n!=="help"&&n!=="generate-docs"&&n!=="observability"&&n!=="feedback"&&n!=="note"&&n!=="runtime"&&n!=="diagnostics"&&n!=="doctor"&&n!=="reveal"}
|