@automaton-labs/aib 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +4 -2
- package/dist/commands/apply-module-plan.js +3 -3
- package/dist/commands/background-command.js +2 -0
- package/dist/commands/captured-input.js +1 -2
- package/dist/commands/config-command.js +2 -2
- package/dist/commands/config-output.js +10 -10
- package/dist/commands/control-plane-command.js +1 -0
- package/dist/commands/declaration-command.js +7 -0
- package/dist/commands/declaration-execution-cache.js +1 -0
- package/dist/commands/declaration-format.js +1 -0
- package/dist/commands/declaration-preview-cache.js +2 -0
- package/dist/commands/doctor.js +3 -2
- package/dist/commands/execution-command.js +1 -1
- package/dist/commands/file-command.js +1 -0
- package/dist/commands/file-move-to-dir-execution-cache.js +1 -0
- package/dist/commands/file-move-to-dir-preview-cache.js +2 -0
- package/dist/commands/file-move-to-dir.js +5 -0
- package/dist/commands/file-mutation-runtime.js +1 -0
- package/dist/commands/file-refactor-batch-execution-cache.js +1 -0
- package/dist/commands/file-refactor-batch-preview-cache.js +2 -0
- package/dist/commands/file-refactor-batch.js +5 -0
- package/dist/commands/file-rename-execution-cache.js +1 -0
- package/dist/commands/file-rename-preview-cache.js +2 -0
- package/dist/commands/file-rename.js +5 -0
- package/dist/commands/help-command.js +5 -5
- package/dist/commands/host-command.js +1 -0
- package/dist/commands/inspect-cycles.js +3 -3
- package/dist/commands/inspect-format.js +15 -15
- package/dist/commands/inspect-tree.js +2 -2
- package/dist/commands/inspect.js +12 -12
- package/dist/commands/move-to-file.js +2 -2
- package/dist/commands/ota-command.js +2 -0
- package/dist/commands/quick-read.js +4 -4
- package/dist/commands/refactor-batch.js +4 -4
- package/dist/commands/rename-entities.js +4 -4
- package/dist/commands/result-view.js +6 -5
- package/dist/commands/worker-command.js +1 -0
- package/dist/config/defaults.js +1 -1
- package/dist/config/env-vars.js +1 -1
- package/dist/config/path-aliases.js +1 -1
- package/dist/config/resolve-command-alias.js +1 -1
- package/dist/content/content-bundle.js +1 -1
- package/dist/dsl/aib-dsl.js +1 -1
- package/dist/dsl/declaration-dsl.js +1 -0
- package/dist/dsl/file-move-to-dir-dsl.js +1 -0
- package/dist/dsl/file-refactor-batch-dsl.js +1 -0
- package/dist/dsl/file-rename-dsl.js +1 -0
- package/dist/help/{json/bootstrap.md → bootstrap.bash.md} +214 -392
- package/dist/help/bootstrap.md +101 -137
- package/dist/help/{json/full.md → bootstrap.pwsh.md} +214 -392
- package/dist/help/docs/dsl.md +4 -3
- package/dist/help/docs/file.move.md +46 -0
- package/dist/help/docs/file.rename.md +35 -0
- package/dist/help/docs/inspect.code.md +5 -5
- package/dist/help/docs/inspect.deps.md +7 -7
- package/dist/help/docs/inspect.file.md +2 -1
- package/dist/help/docs/inspect.graph.md +3 -3
- package/dist/help/docs/inspect.md +5 -5
- package/dist/help/docs/mutation.md +23 -13
- package/dist/help/docs/patterns.md +1 -5
- package/dist/help/docs/qr.md +7 -22
- package/dist/help/docs/quick-map.md +1 -0
- package/dist/help/docs/recipe.file-layout.md +15 -0
- package/dist/help/docs/rg.md +22 -0
- package/dist/help/docs/selectors.md +3 -2
- package/dist/help/docs/session.md +1 -1
- package/dist/help/dsl/bootstrap.bash.md +907 -0
- package/dist/help/dsl/bootstrap.md +101 -137
- package/dist/help/dsl/bootstrap.pwsh.md +907 -0
- package/dist/help/dsl/docs/dsl.md +4 -3
- package/dist/help/dsl/docs/file.move.md +46 -0
- package/dist/help/dsl/docs/file.rename.md +35 -0
- package/dist/help/dsl/docs/inspect.code.md +5 -5
- package/dist/help/dsl/docs/inspect.deps.md +7 -7
- package/dist/help/dsl/docs/inspect.file.md +2 -1
- package/dist/help/dsl/docs/inspect.graph.md +3 -3
- package/dist/help/dsl/docs/inspect.md +5 -5
- package/dist/help/dsl/docs/mutation.md +23 -13
- package/dist/help/dsl/docs/patterns.md +1 -5
- package/dist/help/dsl/docs/qr.md +7 -22
- package/dist/help/dsl/docs/quick-map.md +1 -0
- package/dist/help/dsl/docs/recipe.file-layout.md +15 -0
- package/dist/help/dsl/docs/rg.md +22 -0
- package/dist/help/dsl/docs/selectors.md +3 -2
- package/dist/help/dsl/docs/session.md +1 -1
- package/dist/help/dsl/full.md +101 -137
- package/dist/help/dsl/help-index.md +44 -0
- package/dist/help/dsl/tokens/qr.inline.examples.md +2 -0
- package/dist/help/dsl/tokens/stdin.examples.bash.md +8 -0
- package/dist/help/dsl/tokens/stdin.examples.pwsh.md +8 -0
- package/dist/help/dsl/tokens/stdin.examples.with-qr.bash.md +12 -0
- package/dist/help/dsl/tokens/stdin.examples.with-qr.pwsh.md +12 -0
- package/dist/help/dsl/topics/dsl.md +4 -3
- package/dist/help/dsl/topics/file.move.md +44 -0
- package/dist/help/dsl/topics/file.rename.md +33 -0
- package/dist/help/dsl/topics/inspect.code.md +5 -5
- package/dist/help/dsl/topics/inspect.deps.md +7 -7
- package/dist/help/dsl/topics/inspect.file.md +2 -1
- package/dist/help/dsl/topics/inspect.graph.md +3 -3
- package/dist/help/dsl/topics/inspect.md +5 -5
- package/dist/help/dsl/topics/mutation.md +23 -13
- package/dist/help/dsl/topics/patterns.md +1 -5
- package/dist/help/dsl/topics/qr.md +7 -22
- package/dist/help/dsl/topics/quick-map.md +1 -0
- package/dist/help/dsl/topics/recipe.file-layout.md +13 -0
- package/dist/help/dsl/topics/rg.md +20 -0
- package/dist/help/dsl/topics/selectors.md +3 -2
- package/dist/help/dsl/topics/session.md +1 -1
- package/dist/help/full.md +101 -137
- package/dist/help/help-index.md +44 -0
- package/dist/help/help-meta.json +43 -27
- package/dist/help/index.md +32 -75
- package/dist/help/tokens/qr.inline.examples.md +2 -0
- package/dist/help/tokens/stdin.examples.bash.md +8 -0
- package/dist/help/tokens/stdin.examples.pwsh.md +8 -0
- package/dist/help/tokens/stdin.examples.with-qr.bash.md +12 -0
- package/dist/help/tokens/stdin.examples.with-qr.pwsh.md +12 -0
- package/dist/help/topics/dsl.md +4 -3
- package/dist/help/topics/file.move.md +44 -0
- package/dist/help/topics/file.rename.md +33 -0
- package/dist/help/topics/inspect.code.md +5 -5
- package/dist/help/topics/inspect.deps.md +7 -7
- package/dist/help/topics/inspect.file.md +2 -1
- package/dist/help/topics/inspect.graph.md +3 -3
- package/dist/help/topics/inspect.md +5 -5
- package/dist/help/topics/mutation.md +23 -13
- package/dist/help/topics/patterns.md +1 -5
- package/dist/help/topics/qr.md +7 -22
- package/dist/help/topics/quick-map.md +1 -0
- package/dist/help/topics/recipe.file-layout.md +13 -0
- package/dist/help/topics/rg.md +20 -0
- package/dist/help/topics/selectors.md +3 -2
- package/dist/help/topics/session.md +1 -1
- package/dist/host/capabilities.js +1 -0
- package/dist/ide-launch/common.cjs +162 -162
- package/dist/managed-host/extension-vsix-resolver.js +1 -1
- package/dist/managed-host/manage-serve-web-host.cjs +141 -141
- package/dist/managed-host/serve-web-autostart.js +1 -1
- package/dist/managed-host/serve-web-host.cjs +1781 -1570
- package/dist/payloads/read-stdin-json.js +1 -1
- package/dist/rg-wrapper/core.js +6 -0
- package/dist/rg-wrapper/options.js +1 -0
- package/dist/rtk-wrapper/core.js +2 -0
- package/dist/runtime/input-source.js +1 -1
- package/dist/runtime/run-command.js +1 -1
- package/dist/selectors/parse-entities.js +1 -1
- package/dist/session/daemon-state.js +2 -0
- package/dist/session/server.js +7 -8
- package/dist/shared/operations.js +1 -1
- package/dist/shared/protocol.js +1 -1
- package/dist/shared/routes.js +1 -1
- package/dist/shared/stdin-examples.js +1 -3
- package/dist/shared/types.js +1 -1
- package/dist/tool-runtime/runtime-tools.js +1 -0
- package/dist/workers/control-plane/aib-control-plane-worker.cjs +80 -0
- package/dist/workers/control-plane/client-config.default.json +3 -0
- package/dist/workers/product-storage.js +1 -0
- package/dist/workers/registry.js +1 -0
- package/extension/vscode-refactor-bridge-extension.vsix +0 -0
- package/package.json +6 -4
- package/runtimes/launcher/linux-x64/aib +0 -0
- package/runtimes/launcher/win-x64/aib.exe +0 -0
- package/runtimes/tools/rg/darwin-arm64/rg +0 -0
- package/runtimes/tools/rg/darwin-x64/rg +0 -0
- package/runtimes/tools/rg/linux-arm64/rg +0 -0
- package/runtimes/tools/rg/linux-x64/rg +0 -0
- package/runtimes/tools/rg/manifest.json +36 -0
- package/runtimes/tools/rg/win32-x64/rg.exe +0 -0
- package/runtimes/tools/rtk/darwin-arm64/rtk +0 -0
- package/runtimes/tools/rtk/darwin-x64/rtk +0 -0
- package/runtimes/tools/rtk/linux-arm64/rtk +0 -0
- package/runtimes/tools/rtk/linux-x64/rtk +0 -0
- package/runtimes/tools/rtk/manifest.json +36 -0
- package/runtimes/tools/rtk/win32-x64/rtk.exe +0 -0
- package/dist/help/json/docs/basics.md +0 -15
- package/dist/help/json/docs/config-setup.aliases.md +0 -56
- package/dist/help/json/docs/config-setup.excludes.md +0 -45
- package/dist/help/json/docs/config-setup.import-normalize.md +0 -86
- package/dist/help/json/docs/config-setup.import-rules.md +0 -96
- package/dist/help/json/docs/config-setup.tsconfigs.md +0 -33
- package/dist/help/json/docs/dsl.md +0 -25
- package/dist/help/json/docs/first-setup.md +0 -292
- package/dist/help/json/docs/help-format.md +0 -9
- package/dist/help/json/docs/help-protocol.md +0 -26
- package/dist/help/json/docs/imports.normalize.md +0 -47
- package/dist/help/json/docs/inspect.code.md +0 -41
- package/dist/help/json/docs/inspect.cycles.md +0 -38
- package/dist/help/json/docs/inspect.deps.md +0 -46
- package/dist/help/json/docs/inspect.duplicates.md +0 -65
- package/dist/help/json/docs/inspect.exports.md +0 -40
- package/dist/help/json/docs/inspect.file.md +0 -38
- package/dist/help/json/docs/inspect.graph.md +0 -139
- package/dist/help/json/docs/inspect.imports.md +0 -15
- package/dist/help/json/docs/inspect.md +0 -88
- package/dist/help/json/docs/inspect.members.md +0 -32
- package/dist/help/json/docs/inspect.tree.md +0 -32
- package/dist/help/json/docs/inspect.usages.md +0 -61
- package/dist/help/json/docs/modulePlan.md +0 -73
- package/dist/help/json/docs/move.md +0 -56
- package/dist/help/json/docs/mutation.md +0 -65
- package/dist/help/json/docs/patterns.md +0 -76
- package/dist/help/json/docs/prefs.md +0 -40
- package/dist/help/json/docs/qr.md +0 -37
- package/dist/help/json/docs/quick-map.md +0 -30
- package/dist/help/json/docs/refactor.batch.md +0 -72
- package/dist/help/json/docs/rename.md +0 -47
- package/dist/help/json/docs/reveal.md +0 -30
- package/dist/help/json/docs/selectors.md +0 -23
- package/dist/help/json/docs/session.md +0 -77
- package/dist/help/json/docs/view.md +0 -30
- package/dist/help/json/snippets/agents.md +0 -14
- package/dist/help/json/topics/basics.md +0 -13
- package/dist/help/json/topics/config-setup.aliases.md +0 -54
- package/dist/help/json/topics/config-setup.excludes.md +0 -43
- package/dist/help/json/topics/config-setup.import-normalize.md +0 -84
- package/dist/help/json/topics/config-setup.import-rules.md +0 -94
- package/dist/help/json/topics/config-setup.tsconfigs.md +0 -31
- package/dist/help/json/topics/dsl.md +0 -23
- package/dist/help/json/topics/first-setup.md +0 -290
- package/dist/help/json/topics/help-format.md +0 -7
- package/dist/help/json/topics/help-protocol.md +0 -24
- package/dist/help/json/topics/imports.normalize.md +0 -45
- package/dist/help/json/topics/inspect.code.md +0 -39
- package/dist/help/json/topics/inspect.cycles.md +0 -36
- package/dist/help/json/topics/inspect.deps.md +0 -44
- package/dist/help/json/topics/inspect.duplicates.md +0 -37
- package/dist/help/json/topics/inspect.exports.md +0 -38
- package/dist/help/json/topics/inspect.file.md +0 -36
- package/dist/help/json/topics/inspect.graph.md +0 -137
- package/dist/help/json/topics/inspect.imports.md +0 -13
- package/dist/help/json/topics/inspect.md +0 -86
- package/dist/help/json/topics/inspect.members.md +0 -30
- package/dist/help/json/topics/inspect.tree.md +0 -22
- package/dist/help/json/topics/inspect.usages.md +0 -59
- package/dist/help/json/topics/modulePlan.md +0 -60
- package/dist/help/json/topics/move.md +0 -46
- package/dist/help/json/topics/mutation.md +0 -63
- package/dist/help/json/topics/patterns.md +0 -74
- package/dist/help/json/topics/prefs.md +0 -38
- package/dist/help/json/topics/qr.md +0 -35
- package/dist/help/json/topics/quick-map.md +0 -28
- package/dist/help/json/topics/refactor.batch.md +0 -61
- package/dist/help/json/topics/rename.md +0 -42
- package/dist/help/json/topics/reveal.md +0 -28
- package/dist/help/json/topics/selectors.md +0 -21
- package/dist/help/json/topics/session.md +0 -59
- package/dist/help/json/topics/view.md +0 -28
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Assumption:
|
|
2
|
+
You are changing whole-file layout.
|
|
3
|
+
You are not moving TypeScript declarations or renaming TypeScript symbols.
|
|
4
|
+
|
|
5
|
+
Related topics:
|
|
6
|
+
aib help mutation file.move file.rename
|
|
7
|
+
|
|
8
|
+
If you only need to move files, do not read file.rename.
|
|
9
|
+
If you only need to rename files, do not read file.move.
|
|
10
|
+
|
|
11
|
+
Use focused topic syntax to express the file layout refactor.
|
|
12
|
+
Do not move or rename files manually.
|
|
13
|
+
Use AIB file mutations so references/imports are updated.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
aib rg
|
|
2
|
+
|
|
3
|
+
Run ripgrep through AIB.
|
|
4
|
+
|
|
5
|
+
Regular rg:
|
|
6
|
+
rg <args>
|
|
7
|
+
|
|
8
|
+
AIB rg:
|
|
9
|
+
aib rg -- <args>
|
|
10
|
+
|
|
11
|
+
Everything after `--` is passed as normal ripgrep arguments.
|
|
12
|
+
Use the same args you would pass to `rg`.
|
|
13
|
+
Use normal paths in input. Do not use AIB path aliases here.
|
|
14
|
+
|
|
15
|
+
Examples:
|
|
16
|
+
rg -n "TODO" src/core
|
|
17
|
+
aib rg -- -n "TODO" src/core
|
|
18
|
+
|
|
19
|
+
rg -n --column "SomeValue" ws/commands ws/config
|
|
20
|
+
aib rg -- -n --column "SomeValue" ws/commands ws/config
|
|
@@ -2,7 +2,7 @@ Start by creating or selecting your session.
|
|
|
2
2
|
Create it once, then reuse it.
|
|
3
3
|
Do not create a new session for every command or subtask.
|
|
4
4
|
|
|
5
|
-
Session stores saved artifacts
|
|
5
|
+
Session stores saved artifacts and aliases.
|
|
6
6
|
|
|
7
7
|
Prefer short session names:
|
|
8
8
|
aa, tr, qa, a2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var o=exports&&exports.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.AIB_SUPPORTED_ACTIVATION_POLICIES=exports.AIB_SUPPORTED_INVOKE_MODES=exports.AIB_HOST_CAPABILITIES=exports.AIB_WORKER_ABI=void 0,exports.readHostCapabilities=i;const a=o(require("node:fs")),r=o(require("node:path"));exports.AIB_WORKER_ABI="1",exports.AIB_HOST_CAPABILITIES=["productStorage","jsonStdout","traceUploadLedger","backgroundSchedule","policyConfig","workerRegistry","workerBundleOta","cliPackageOta"],exports.AIB_SUPPORTED_INVOKE_MODES=["structured","process","stream"],exports.AIB_SUPPORTED_ACTIVATION_POLICIES=["ota-activation","cli-package-activation","extension-vsix-activation","ota-watch","ota-cleanup"];function i(e=n()){return{schemaVersion:1,hostVersion:s(e),workerAbi:exports.AIB_WORKER_ABI,platform:process.platform,arch:process.arch,nodeRuntime:`node-${process.versions.node.split(".")[0]}`,launcherProtocol:"1",daemonInvokeProtocol:"http-session-v1",supportedInvokeModes:exports.AIB_SUPPORTED_INVOKE_MODES,productStorageSchema:1,supportedActivationPolicies:exports.AIB_SUPPORTED_ACTIVATION_POLICIES,runtime:"cjs-node20",capabilities:exports.AIB_HOST_CAPABILITIES}}function n(){return r.default.resolve(__dirname,"..","..")}function s(e){try{const t=JSON.parse(a.default.readFileSync(r.default.join(e,"package.json"),"utf8"));return typeof t.version=="string"&&t.version.trim()?t.version:"0.0.0"}catch{return"0.0.0"}}
|
|
@@ -1,162 +1,162 @@
|
|
|
1
|
-
const fs = require("node:fs");
|
|
2
|
-
const os = require("node:os");
|
|
3
|
-
const path = require("node:path");
|
|
4
|
-
const { spawnSync } = require("node:child_process");
|
|
5
|
-
|
|
6
|
-
const rootDir = path.resolve(__dirname, "..", "..");
|
|
7
|
-
const defaultFixtureDir = path.join(rootDir, "fixtures", "ts-sandbox");
|
|
8
|
-
const defaultVsixPath = path.join(rootDir, ".tmp", "vscode-refactor-bridge-extension.vsix");
|
|
9
|
-
const defaultRunsDir = path.join(rootDir, ".tmp", "ide-launch-runs");
|
|
10
|
-
|
|
11
|
-
function timestampForPath() {
|
|
12
|
-
return new Date().toISOString().replace(/[:.]/g, "-");
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function ensureDir(dirPath) {
|
|
16
|
-
fs.mkdirSync(dirPath, { recursive: true });
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function writeJson(filePath, payload) {
|
|
20
|
-
ensureDir(path.dirname(filePath));
|
|
21
|
-
fs.writeFileSync(filePath, `${JSON.stringify(payload, null, 2)}\n`);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function run(command, args, options = {}) {
|
|
25
|
-
const startedAt = Date.now();
|
|
26
|
-
const spawnCommand = prepareSpawnCommand(command, args, options);
|
|
27
|
-
const result = spawnSync(spawnCommand.command, spawnCommand.args, {
|
|
28
|
-
cwd: options.cwd ?? rootDir,
|
|
29
|
-
env: buildEnv(options.env),
|
|
30
|
-
input: options.input,
|
|
31
|
-
encoding: "utf8",
|
|
32
|
-
windowsHide: true,
|
|
33
|
-
windowsVerbatimArguments: spawnCommand.windowsVerbatimArguments ?? false,
|
|
34
|
-
timeout: options.timeoutMs ?? 30_000,
|
|
35
|
-
shell: options.shell ?? false,
|
|
36
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
command,
|
|
41
|
-
args,
|
|
42
|
-
status: result.status,
|
|
43
|
-
signal: result.signal,
|
|
44
|
-
error: result.error ? result.error.message : null,
|
|
45
|
-
stdout: result.stdout ?? "",
|
|
46
|
-
stderr: result.stderr ?? "",
|
|
47
|
-
durationMs: Date.now() - startedAt
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function buildEnv(overrides) {
|
|
52
|
-
if (!overrides) {
|
|
53
|
-
return process.env;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const env = { ...process.env };
|
|
57
|
-
for (const [key, value] of Object.entries(overrides)) {
|
|
58
|
-
if (value === null || value === undefined) {
|
|
59
|
-
delete env[key];
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
env[key] = String(value);
|
|
63
|
-
}
|
|
64
|
-
return env;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function resolveIdeCommand(options) {
|
|
68
|
-
if (options.ideCommand) {
|
|
69
|
-
return options.ideCommand;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return resolveCommandFromPath(options.ide === "cursor" ? "cursor" : "code");
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function isWindowsCommandScript(command) {
|
|
76
|
-
const extension = path.extname(command).toLowerCase();
|
|
77
|
-
return extension === ".cmd" || extension === ".bat";
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function quoteCmdArg(value) {
|
|
81
|
-
const raw = String(value);
|
|
82
|
-
return `"${raw.replace(/"/g, '\\"')}"`;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function prepareSpawnCommand(command, args, options = {}) {
|
|
86
|
-
if (process.platform !== "win32" || options.shell !== undefined || !isWindowsCommandScript(command)) {
|
|
87
|
-
return { command, args };
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return {
|
|
91
|
-
command: "cmd.exe",
|
|
92
|
-
args: ["/d", "/s", "/c", ["call", quoteCmdArg(command), ...args.map(quoteCmdArg)].join(" ")],
|
|
93
|
-
windowsVerbatimArguments: true
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function resolveCommandFromPath(commandName) {
|
|
98
|
-
const result = spawnSync("where.exe", [commandName], {
|
|
99
|
-
cwd: rootDir,
|
|
100
|
-
encoding: "utf8",
|
|
101
|
-
windowsHide: true,
|
|
102
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
if (result.status !== 0) {
|
|
106
|
-
return commandName;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const candidates = result.stdout
|
|
110
|
-
.split(/\r?\n/)
|
|
111
|
-
.map((line) => line.trim())
|
|
112
|
-
.filter(Boolean);
|
|
113
|
-
|
|
114
|
-
const commandScript = candidates.find((candidate) => path.extname(candidate).toLowerCase() === ".cmd");
|
|
115
|
-
return commandScript ?? candidates[0] ?? commandName;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function readRegistryEntries() {
|
|
119
|
-
const registryDir = path.join(os.tmpdir(), "aib", "instances");
|
|
120
|
-
if (!fs.existsSync(registryDir)) {
|
|
121
|
-
return [];
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const entries = [];
|
|
125
|
-
for (const fileName of fs.readdirSync(registryDir)) {
|
|
126
|
-
if (!fileName.endsWith(".json")) {
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const filePath = path.join(registryDir, fileName);
|
|
131
|
-
try {
|
|
132
|
-
const parsed = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
133
|
-
entries.push({
|
|
134
|
-
...parsed,
|
|
135
|
-
registryPath: filePath
|
|
136
|
-
});
|
|
137
|
-
} catch {
|
|
138
|
-
// Ignore corrupt/stale entries in probe output.
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return entries;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function sleep(ms) {
|
|
146
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
module.exports = {
|
|
150
|
-
rootDir,
|
|
151
|
-
defaultFixtureDir,
|
|
152
|
-
defaultVsixPath,
|
|
153
|
-
defaultRunsDir,
|
|
154
|
-
prepareSpawnCommand,
|
|
155
|
-
readRegistryEntries,
|
|
156
|
-
resolveCommandFromPath,
|
|
157
|
-
resolveIdeCommand,
|
|
158
|
-
run,
|
|
159
|
-
sleep,
|
|
160
|
-
timestampForPath,
|
|
161
|
-
writeJson
|
|
162
|
-
};
|
|
1
|
+
const fs = require("node:fs");
|
|
2
|
+
const os = require("node:os");
|
|
3
|
+
const path = require("node:path");
|
|
4
|
+
const { spawnSync } = require("node:child_process");
|
|
5
|
+
|
|
6
|
+
const rootDir = path.resolve(__dirname, "..", "..");
|
|
7
|
+
const defaultFixtureDir = path.join(rootDir, "fixtures", "ts-sandbox");
|
|
8
|
+
const defaultVsixPath = path.join(rootDir, ".tmp", "vscode-refactor-bridge-extension.vsix");
|
|
9
|
+
const defaultRunsDir = path.join(rootDir, ".tmp", "ide-launch-runs");
|
|
10
|
+
|
|
11
|
+
function timestampForPath() {
|
|
12
|
+
return new Date().toISOString().replace(/[:.]/g, "-");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function ensureDir(dirPath) {
|
|
16
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function writeJson(filePath, payload) {
|
|
20
|
+
ensureDir(path.dirname(filePath));
|
|
21
|
+
fs.writeFileSync(filePath, `${JSON.stringify(payload, null, 2)}\n`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function run(command, args, options = {}) {
|
|
25
|
+
const startedAt = Date.now();
|
|
26
|
+
const spawnCommand = prepareSpawnCommand(command, args, options);
|
|
27
|
+
const result = spawnSync(spawnCommand.command, spawnCommand.args, {
|
|
28
|
+
cwd: options.cwd ?? rootDir,
|
|
29
|
+
env: buildEnv(options.env),
|
|
30
|
+
input: options.input,
|
|
31
|
+
encoding: "utf8",
|
|
32
|
+
windowsHide: true,
|
|
33
|
+
windowsVerbatimArguments: spawnCommand.windowsVerbatimArguments ?? false,
|
|
34
|
+
timeout: options.timeoutMs ?? 30_000,
|
|
35
|
+
shell: options.shell ?? false,
|
|
36
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
command,
|
|
41
|
+
args,
|
|
42
|
+
status: result.status,
|
|
43
|
+
signal: result.signal,
|
|
44
|
+
error: result.error ? result.error.message : null,
|
|
45
|
+
stdout: result.stdout ?? "",
|
|
46
|
+
stderr: result.stderr ?? "",
|
|
47
|
+
durationMs: Date.now() - startedAt
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function buildEnv(overrides) {
|
|
52
|
+
if (!overrides) {
|
|
53
|
+
return process.env;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const env = { ...process.env };
|
|
57
|
+
for (const [key, value] of Object.entries(overrides)) {
|
|
58
|
+
if (value === null || value === undefined) {
|
|
59
|
+
delete env[key];
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
env[key] = String(value);
|
|
63
|
+
}
|
|
64
|
+
return env;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function resolveIdeCommand(options) {
|
|
68
|
+
if (options.ideCommand) {
|
|
69
|
+
return options.ideCommand;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return resolveCommandFromPath(options.ide === "cursor" ? "cursor" : "code");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function isWindowsCommandScript(command) {
|
|
76
|
+
const extension = path.extname(command).toLowerCase();
|
|
77
|
+
return extension === ".cmd" || extension === ".bat";
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function quoteCmdArg(value) {
|
|
81
|
+
const raw = String(value);
|
|
82
|
+
return `"${raw.replace(/"/g, '\\"')}"`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function prepareSpawnCommand(command, args, options = {}) {
|
|
86
|
+
if (process.platform !== "win32" || options.shell !== undefined || !isWindowsCommandScript(command)) {
|
|
87
|
+
return { command, args };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
command: "cmd.exe",
|
|
92
|
+
args: ["/d", "/s", "/c", ["call", quoteCmdArg(command), ...args.map(quoteCmdArg)].join(" ")],
|
|
93
|
+
windowsVerbatimArguments: true
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function resolveCommandFromPath(commandName) {
|
|
98
|
+
const result = spawnSync("where.exe", [commandName], {
|
|
99
|
+
cwd: rootDir,
|
|
100
|
+
encoding: "utf8",
|
|
101
|
+
windowsHide: true,
|
|
102
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
if (result.status !== 0) {
|
|
106
|
+
return commandName;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const candidates = result.stdout
|
|
110
|
+
.split(/\r?\n/)
|
|
111
|
+
.map((line) => line.trim())
|
|
112
|
+
.filter(Boolean);
|
|
113
|
+
|
|
114
|
+
const commandScript = candidates.find((candidate) => path.extname(candidate).toLowerCase() === ".cmd");
|
|
115
|
+
return commandScript ?? candidates[0] ?? commandName;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function readRegistryEntries() {
|
|
119
|
+
const registryDir = path.join(os.tmpdir(), "aib", "instances");
|
|
120
|
+
if (!fs.existsSync(registryDir)) {
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const entries = [];
|
|
125
|
+
for (const fileName of fs.readdirSync(registryDir)) {
|
|
126
|
+
if (!fileName.endsWith(".json")) {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const filePath = path.join(registryDir, fileName);
|
|
131
|
+
try {
|
|
132
|
+
const parsed = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
133
|
+
entries.push({
|
|
134
|
+
...parsed,
|
|
135
|
+
registryPath: filePath
|
|
136
|
+
});
|
|
137
|
+
} catch {
|
|
138
|
+
// Ignore corrupt/stale entries in probe output.
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return entries;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function sleep(ms) {
|
|
146
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
module.exports = {
|
|
150
|
+
rootDir,
|
|
151
|
+
defaultFixtureDir,
|
|
152
|
+
defaultVsixPath,
|
|
153
|
+
defaultRunsDir,
|
|
154
|
+
prepareSpawnCommand,
|
|
155
|
+
readRegistryEntries,
|
|
156
|
+
resolveCommandFromPath,
|
|
157
|
+
resolveIdeCommand,
|
|
158
|
+
run,
|
|
159
|
+
sleep,
|
|
160
|
+
timestampForPath,
|
|
161
|
+
writeJson
|
|
162
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var x=exports&&exports.__createBinding||(Object.create?(function(e,t,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}):(function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]})),h=exports&&exports.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),a=exports&&exports.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var n=[];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[n.length]=o);return n},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null)for(var n=e(t),o=0;o<n.length;o++)n[o]!=="default"&&x(r,t,n[o]);return h(r,t),r}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveExtensionVsixPath=P;const s=a(require("node:fs")),_=a(require("node:os")),i=a(require("node:path")),u=require("../config/env-vars"),b=require("../shared/diagnostics"),j=require("../shared/errors");function P(e){const t=v(u.CLI_ENV.extensionVsix);if(t)return{path:t,source:"env"};const r=O();if(r)return r;const n=y();if(n)return n;const o=E(e.packageRoot);if(o)return o;if(e.repoRoot){const l=i.join(e.repoRoot,".tmp","vscode-refactor-bridge-extension.vsix");if(s.existsSync(l))return{path:l,source:"repo-dev-fallback"}}const f=i.join(e.packageRoot,"extension","vscode-refactor-bridge-extension.vsix");return s.existsSync(f)?{path:f,source:"package-extension"}:e.repoRoot?{path:i.join(e.repoRoot,".tmp","vscode-refactor-bridge-extension.vsix"),source:"repo-dev-fallback"}:{path:i.join(e.packageRoot,".tmp","vscode-refactor-bridge-extension.vsix"),source:"package-adjacent"}}function y(){const e=i.join(S(),"extension","activation-status.json");if(!s.existsSync(e))return null;const t=p(e),r=c(t.activeVsixPath)??c(C(t.active)?.vsixPath);if(!r)return null;const n=i.resolve(r);return s.existsSync(n)?{path:n,source:"product-storage",configPath:e}:null}function S(){const e=process.env[u.CLI_ENV.productStorageDir];return e?.trim()?i.resolve(e):process.platform==="win32"&&process.env.LOCALAPPDATA?i.join(process.env.LOCALAPPDATA,"aib"):process.env.XDG_STATE_HOME?i.join(process.env.XDG_STATE_HOME,"aib"):i.join(_.homedir(),".local","state","aib")}function v(e){const t=process.env[e];return t&&t.trim()?i.resolve(t.trim()):null}function O(){const e=v(u.CLI_ENV.installConfig);return e?d(e):null}function E(e){const t=i.join(e,"config.json");return s.existsSync(t)?d(t):null}function d(e){const t=p(e),r=A(t);if(!r)throw g(e,"Expected config to include extensionVsix.");return{path:i.resolve(i.dirname(e),r),source:"install-config",configPath:e}}function p(e){try{const t=JSON.parse(s.readFileSync(e,"utf8"));if(t&&typeof t=="object"&&!Array.isArray(t))return t;throw new Error("Config root must be an object.")}catch(t){throw g(e,t instanceof Error?t.message:String(t))}}function A(e){const t=c(e.extensionVsix);if(t)return t;const r=e.extension;if(!r||typeof r!="object"||Array.isArray(r))return null;const n=r;return c(n.vsixPath)??c(n.vsix)}function C(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function c(e){return typeof e=="string"&&e.trim()?e.trim():null}function g(e,t){return new j.CliError("EXTENSION_VSIX_CONFIG_INVALID","Extension VSIX install config is invalid.",{configPath:e,reason:t,expected:{extensionVsix:"relative/or/absolute/path/to/extension.vsix"},hints:(0,b.buildAutoStartIdeHints)()})}
|