@get-bb/plugin-sdk 0.6.80 → 0.6.89

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/app.js CHANGED
@@ -216,6 +216,9 @@ var experimental_useQuestionFormHost = runtimeFunction(
216
216
  "experimental_useQuestionFormHost"
217
217
  );
218
218
  var useBbNavigate = runtimeFunction("useBbNavigate");
219
+ var experimental_useCanOpenFileExternally = runtimeFunction(
220
+ "experimental_useCanOpenFileExternally"
221
+ );
219
222
  var experimental_useAppPanel = runtimeFunction(
220
223
  "experimental_useAppPanel"
221
224
  );
@@ -390,6 +393,7 @@ export {
390
393
  experimental_useAppPanel,
391
394
  experimental_useArchiveEnvironmentThreads,
392
395
  experimental_useBranches,
396
+ experimental_useCanOpenFileExternally,
393
397
  experimental_useCheckoutState,
394
398
  experimental_useCodeTheme,
395
399
  experimental_useComposerCommandSearch,
package/dist/host.js CHANGED
@@ -792,10 +792,556 @@ async function experimental_resolveClaudePluginRoots(args) {
792
792
  return { claudeDir: dirs.claudeDir, ...roots };
793
793
  }
794
794
 
795
- // ../process-utils/src/spawn.ts
795
+ // ../process-utils/src/host-process.ts
796
+ import parse from "cross-spawn/lib/parse.js";
797
+ import {
798
+ spawn as nodeSpawn,
799
+ fork as nodeFork,
800
+ execFile as nodeExecFile
801
+ } from "node:child_process";
796
802
  import crossSpawn from "cross-spawn";
803
+
804
+ // ../process-utils/src/host-toolchain.ts
805
+ import { spawn, spawnSync } from "node:child_process";
806
+ import {
807
+ accessSync,
808
+ constants,
809
+ existsSync,
810
+ readdirSync,
811
+ realpathSync,
812
+ statSync
813
+ } from "node:fs";
814
+ import { createRequire } from "node:module";
815
+ import { homedir } from "node:os";
816
+ import {
817
+ basename,
818
+ delimiter,
819
+ dirname,
820
+ extname,
821
+ isAbsolute,
822
+ join
823
+ } from "node:path";
824
+ import { fileURLToPath } from "node:url";
825
+
826
+ // ../../node_modules/.pnpm/which-command@0.1.0/node_modules/which-command/index.js
827
+ import fs2 from "node:fs";
828
+ import path2 from "node:path";
829
+ import process2 from "node:process";
830
+ var isWindows = process2.platform === "win32";
831
+ var separatorPattern = isWindows ? new RegExp("[\\/\\\\]", "v") : new RegExp("\\/", "v");
832
+ var defaultPathExt = ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC";
833
+ function resolveOptions(command, options) {
834
+ if (typeof command !== "string" || command.length === 0) {
835
+ throw new TypeError("Expected a non-empty string.");
836
+ }
837
+ const {
838
+ cwd = process2.cwd(),
839
+ // On Windows, `process.env.PATH` can be undefined in some contexts (for example, worker threads), where it's only exposed as `Path`.
840
+ path: searchPath = process2.env.PATH ?? (isWindows ? process2.env.Path : void 0) ?? "",
841
+ // `||` (not `??`) so an empty `PATHEXT` falls back to the default instead of disabling all lookup on Windows.
842
+ pathExt = process2.env.PATHEXT || defaultPathExt
843
+ } = options;
844
+ return { cwd, searchPath, pathExt };
845
+ }
846
+ function windowsExtensions(command, pathExt) {
847
+ const extensions = pathExt.split(path2.delimiter).filter(Boolean);
848
+ const commandExtension = path2.extname(command).toLowerCase();
849
+ if (commandExtension !== "" && extensions.some((extension) => extension.toLowerCase() === commandExtension)) {
850
+ return ["", ...extensions];
851
+ }
852
+ return extensions;
853
+ }
854
+ function* candidatePaths(command, { cwd, searchPath, pathExt }) {
855
+ const extensions = isWindows ? windowsExtensions(command, pathExt) : [""];
856
+ if (separatorPattern.test(command)) {
857
+ const base = path2.resolve(cwd, command);
858
+ for (const extension of extensions) {
859
+ yield base + extension;
860
+ }
861
+ return;
862
+ }
863
+ const directories = [
864
+ // Windows searches the current directory before `PATH`.
865
+ ...isWindows ? [cwd] : [],
866
+ ...searchPath.split(path2.delimiter)
867
+ ];
868
+ for (const directory of directories) {
869
+ const unquoted = isWindows && directory.length > 1 && directory.startsWith('"') && directory.endsWith('"') ? directory.slice(1, -1) : directory;
870
+ if (unquoted === "") {
871
+ continue;
872
+ }
873
+ const base = path2.resolve(cwd, unquoted, command);
874
+ for (const extension of extensions) {
875
+ yield base + extension;
876
+ }
877
+ }
878
+ }
879
+ function isExecutableSync(filePath) {
880
+ let stats;
881
+ try {
882
+ stats = fs2.statSync(filePath);
883
+ } catch (error) {
884
+ return isWindows && error.code === "EACCES";
885
+ }
886
+ if (!stats.isFile()) {
887
+ return false;
888
+ }
889
+ if (isWindows) {
890
+ return true;
891
+ }
892
+ try {
893
+ fs2.accessSync(filePath, fs2.constants.X_OK);
894
+ return true;
895
+ } catch {
896
+ return false;
897
+ }
898
+ }
899
+ function whichCommandSync(command, options = {}) {
900
+ const resolved = resolveOptions(command, options);
901
+ for (const candidate of candidatePaths(command, resolved)) {
902
+ if (isExecutableSync(candidate)) {
903
+ return candidate;
904
+ }
905
+ }
906
+ return void 0;
907
+ }
908
+
909
+ // ../process-utils/src/host-toolchain.ts
910
+ var NETWORK_KEYS = [
911
+ "HTTP_PROXY",
912
+ "HTTPS_PROXY",
913
+ "NO_PROXY",
914
+ "http_proxy",
915
+ "https_proxy",
916
+ "no_proxy",
917
+ "NODE_EXTRA_CA_CERTS",
918
+ "SSL_CERT_FILE",
919
+ "SSL_CERT_DIR"
920
+ ];
921
+ var SHELL_START = "__BB_SHELL_ENV_START__";
922
+ var SHELL_END = "__BB_SHELL_ENV_END__";
923
+ var PROBE_TIMEOUT_MS = 3e3;
924
+ var PROBE_OUTPUT_MAX_CHARS = 1024 * 1024;
925
+ function executable(file) {
926
+ try {
927
+ accessSync(
928
+ file,
929
+ process.platform === "win32" ? constants.F_OK : constants.X_OK
930
+ );
931
+ return statSync(file).isFile();
932
+ } catch {
933
+ return false;
934
+ }
935
+ }
936
+ function envValue(env, key) {
937
+ if (process.platform !== "win32") return env[key];
938
+ return env[Object.keys(env).find(
939
+ (entry) => entry.toUpperCase() === key.toUpperCase()
940
+ ) ?? key];
941
+ }
942
+ function mergePath(...paths) {
943
+ const seen = /* @__PURE__ */ new Set();
944
+ return paths.flatMap((value) => (value ?? "").split(delimiter)).filter((entry) => {
945
+ if (!entry) return false;
946
+ const key = process.platform === "win32" ? entry.replace(/[\\/]+$/u, "").toLowerCase() : entry;
947
+ if (seen.has(key)) return false;
948
+ seen.add(key);
949
+ return true;
950
+ }).join(delimiter);
951
+ }
952
+ function onDiskName(file) {
953
+ if (process.platform !== "win32") return file;
954
+ try {
955
+ const name = basename(file).toLowerCase();
956
+ const entry = readdirSync(dirname(file)).find(
957
+ (candidate) => candidate.toLowerCase() === name
958
+ );
959
+ return entry === void 0 ? file : join(dirname(file), entry);
960
+ } catch {
961
+ return file;
962
+ }
963
+ }
964
+ function runProbe(command, args, env) {
965
+ return new Promise((resolve2) => {
966
+ let stdout = "";
967
+ let settled = false;
968
+ let timer;
969
+ const finish = (status) => {
970
+ if (settled) return;
971
+ settled = true;
972
+ clearTimeout(timer);
973
+ resolve2({ status, stdout });
974
+ };
975
+ let child;
976
+ try {
977
+ child = spawn(command, args, {
978
+ cwd: homedir(),
979
+ env,
980
+ stdio: ["ignore", "pipe", "ignore"],
981
+ windowsHide: true
982
+ });
983
+ } catch {
984
+ finish(null);
985
+ return;
986
+ }
987
+ timer = setTimeout(() => {
988
+ child.kill("SIGKILL");
989
+ finish(null);
990
+ }, PROBE_TIMEOUT_MS);
991
+ child.stdout?.setEncoding("utf8");
992
+ child.stdout?.on("data", (chunk) => {
993
+ if (stdout.length < PROBE_OUTPUT_MAX_CHARS) stdout += chunk;
994
+ });
995
+ child.once("error", () => finish(null));
996
+ child.once("close", (code) => finish(code));
997
+ });
998
+ }
999
+ async function readShellEnvironment(env, retainPrevious) {
1000
+ if (process.platform === "win32") {
1001
+ const registry2 = join(
1002
+ envValue(env, "SystemRoot") ?? "C:\\Windows",
1003
+ "System32",
1004
+ "reg.exe"
1005
+ );
1006
+ const values = { ...env };
1007
+ const paths = [];
1008
+ for (const key of [
1009
+ "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment",
1010
+ "HKCU\\Environment"
1011
+ ]) {
1012
+ const result = await runProbe(registry2, ["query", key], env);
1013
+ if (result.status !== 0) continue;
1014
+ for (const match of result.stdout.matchAll(
1015
+ /^ {4}(.+?) {4}REG_[A-Z_]+ {4}(.*)$/gmu
1016
+ )) {
1017
+ const name = match[1]?.trim();
1018
+ if (!name) continue;
1019
+ const value = (match[2] ?? "").trim();
1020
+ if (name.toUpperCase() === "PATH") paths.push(value);
1021
+ else {
1022
+ const existing = Object.keys(values).find(
1023
+ (key2) => key2.toUpperCase() === name.toUpperCase()
1024
+ );
1025
+ values[existing ?? name] = value;
1026
+ }
1027
+ }
1028
+ }
1029
+ const expand = (value) => {
1030
+ for (let depth = 0; depth < 10; depth += 1) {
1031
+ const expanded = value.replace(
1032
+ /%([^%;\\/]+)%/gu,
1033
+ (reference, variable) => envValue(values, variable) ?? reference
1034
+ );
1035
+ if (expanded === value) break;
1036
+ value = expanded;
1037
+ }
1038
+ return value;
1039
+ };
1040
+ return paths.length === 0 ? null : { PATH: mergePath(...paths.map(expand), envValue(env, "PATH")) };
1041
+ }
1042
+ const shell = env.SHELL?.trim() || (process.platform === "darwin" ? "/bin/zsh" : "/bin/sh");
1043
+ const command = `printf '%s\\n' ${SHELL_START}; /usr/bin/env; printf '%s\\n' ${SHELL_END}`;
1044
+ const shellArgs = ["sh", "dash"].includes(basename(shell)) ? ["-lc"] : ["-ilc", "-lc"];
1045
+ for (const arg of shellArgs) {
1046
+ const result = await runProbe(shell, [arg, command], env);
1047
+ if (result.status !== 0) {
1048
+ if (retainPrevious) return null;
1049
+ continue;
1050
+ }
1051
+ const start = result.stdout.indexOf(`${SHELL_START}
1052
+ `);
1053
+ const end = result.stdout.indexOf(`
1054
+ ${SHELL_END}`, start);
1055
+ if (start < 0 || end < 0) {
1056
+ if (retainPrevious) return null;
1057
+ continue;
1058
+ }
1059
+ const values = {};
1060
+ for (const line of result.stdout.slice(start + SHELL_START.length + 1, end).split("\n")) {
1061
+ const separator = line.indexOf("=");
1062
+ const key = line.slice(0, separator);
1063
+ if (key === "PATH" || NETWORK_KEYS.includes(key))
1064
+ values[key] = line.slice(separator + 1);
1065
+ }
1066
+ if (values.PATH) return values;
1067
+ }
1068
+ return null;
1069
+ }
1070
+ var HostToolchain = class {
1071
+ constructor(baseEnv = process.env, runtimePath = process.execPath) {
1072
+ this.baseEnv = baseEnv;
1073
+ this.runtimePath = runtimePath;
1074
+ this.inheritedPath = envValue(baseEnv, "PATH");
1075
+ this.nodePath = runtimePath;
1076
+ }
1077
+ baseEnv;
1078
+ runtimePath;
1079
+ shellEnv = {};
1080
+ inheritedPath;
1081
+ misses = /* @__PURE__ */ new Set();
1082
+ nodePath;
1083
+ refreshing = null;
1084
+ refreshedAt = 0;
1085
+ refresh() {
1086
+ if (this.refreshing !== null) return this.refreshing;
1087
+ this.misses.clear();
1088
+ this.refreshedAt = Date.now();
1089
+ const retainPrevious = this.shellEnv.PATH !== void 0;
1090
+ this.refreshing = readShellEnvironment(this.baseEnv, retainPrevious).then((env) => {
1091
+ if (env !== null) this.shellEnv = env;
1092
+ }).finally(() => {
1093
+ this.refreshing = null;
1094
+ });
1095
+ return this.refreshing;
1096
+ }
1097
+ invalidateFailure(errorOrCode) {
1098
+ const code = typeof errorOrCode === "object" && errorOrCode !== null && "code" in errorOrCode ? errorOrCode.code : errorOrCode;
1099
+ if (code === "ENOENT" || code === 127) void this.refresh();
1100
+ }
1101
+ searchPath(env) {
1102
+ const inherited = envValue(env, "PATH");
1103
+ const home = envValue(env, process.platform === "win32" ? "USERPROFILE" : "HOME") ?? homedir();
1104
+ const fallbacks = [
1105
+ join(home, ".local", "bin"),
1106
+ join(home, ".local", "share", "mise", "shims"),
1107
+ join(home, ".asdf", "shims"),
1108
+ join(home, ".asdf", "bin"),
1109
+ join(home, ".volta", "bin")
1110
+ ];
1111
+ if (process.platform === "darwin") fallbacks.push("/opt/homebrew/bin");
1112
+ if (process.platform !== "win32")
1113
+ fallbacks.push("/usr/local/bin", "/usr/bin", "/bin");
1114
+ const [first, second] = inherited === void 0 || inherited === this.inheritedPath ? [this.shellEnv.PATH, inherited] : [inherited, this.shellEnv.PATH];
1115
+ return mergePath(
1116
+ first,
1117
+ second,
1118
+ executable(this.nodePath) && /^node(?:\.exe)?$/iu.test(basename(this.nodePath)) ? dirname(this.nodePath) : void 0,
1119
+ ...fallbacks
1120
+ );
1121
+ }
1122
+ environment(env = this.baseEnv) {
1123
+ const path4 = this.searchPath(env);
1124
+ const result = { ...env };
1125
+ if (process.platform === "win32") {
1126
+ for (const key of Object.keys(result))
1127
+ if (key !== "PATH" && key.toUpperCase() === "PATH") delete result[key];
1128
+ }
1129
+ if (path4 !== "") result.PATH = path4;
1130
+ const callerKeys = new Set(
1131
+ Object.keys(env).filter((key) => env[key] !== void 0).map((key) => key.toUpperCase())
1132
+ );
1133
+ for (const key of NETWORK_KEYS)
1134
+ if (!callerKeys.has(key.toUpperCase()) && this.shellEnv[key] !== void 0)
1135
+ result[key] = this.shellEnv[key];
1136
+ return result;
1137
+ }
1138
+ lookup(command, options) {
1139
+ const env = this.environment(options.env);
1140
+ const cwd = options.cwd instanceof URL ? fileURLToPath(options.cwd) : options.cwd ?? process.cwd();
1141
+ if (command === "bb") {
1142
+ for (const candidate of [
1143
+ env.BB_CLI_LAUNCHER,
1144
+ env.BB_CLI,
1145
+ env.BB_CLI_DIR ? join(env.BB_CLI_DIR, "bb") : void 0
1146
+ ]) {
1147
+ if (candidate?.trim() && isAbsolute(candidate.trim()) && executable(candidate.trim()))
1148
+ return candidate.trim();
1149
+ }
1150
+ }
1151
+ const extension = extname(command);
1152
+ const pathExt = envValue(env, "PATHEXT");
1153
+ const path4 = envValue(env, "PATH") ?? "";
1154
+ const lookupOptions = {
1155
+ cwd,
1156
+ path: path4,
1157
+ pathExt: extension ? `${extension};${pathExt ?? ".EXE;.COM;.CMD;.BAT"}` : pathExt
1158
+ };
1159
+ const found = command === "bb" ? path4.split(delimiter).filter(isAbsolute).map(
1160
+ (directory) => whichCommandSync(join(directory, command), lookupOptions)
1161
+ ).find(Boolean) : whichCommandSync(command, lookupOptions);
1162
+ return found ? onDiskName(found) : null;
1163
+ }
1164
+ resolve(command, options = {}) {
1165
+ const found = this.lookup(command, options);
1166
+ if (found !== null) return found;
1167
+ const key = `${command}\0${String(options.cwd ?? "")}\0${envValue(options.env ?? this.baseEnv, "PATH") ?? ""}`;
1168
+ const sinceRefresh = Date.now() - this.refreshedAt;
1169
+ if (!(this.misses.has(key) && sinceRefresh < 3e4) && (this.misses.size === 0 || sinceRefresh >= 1e3))
1170
+ void this.refresh();
1171
+ this.misses.add(key);
1172
+ return null;
1173
+ }
1174
+ node(options = {}) {
1175
+ if (executable(this.nodePath)) return this.nodePath;
1176
+ const stableHomebrew = this.runtimePath.replace(
1177
+ /\/Cellar\/([^/]+)\/[^/]+\//u,
1178
+ "/opt/$1/"
1179
+ );
1180
+ const candidates = [
1181
+ stableHomebrew,
1182
+ process.argv0,
1183
+ this.lookup(process.platform === "win32" ? "node.exe" : "node", options)
1184
+ ];
1185
+ for (const candidate of candidates) {
1186
+ if (!candidate || !isAbsolute(candidate) || !executable(candidate))
1187
+ continue;
1188
+ const probe = spawnSync(
1189
+ candidate,
1190
+ [
1191
+ "-p",
1192
+ "JSON.stringify({path:process.execPath,abi:process.versions.modules,electron:!!process.versions.electron})"
1193
+ ],
1194
+ {
1195
+ env: this.environment(options.env),
1196
+ cwd: options.cwd,
1197
+ encoding: "utf8",
1198
+ timeout: PROBE_TIMEOUT_MS,
1199
+ killSignal: "SIGKILL",
1200
+ windowsHide: true
1201
+ }
1202
+ );
1203
+ if (probe.status !== 0) continue;
1204
+ try {
1205
+ const runtime = JSON.parse(probe.stdout.trim());
1206
+ if (typeof runtime !== "object" || runtime === null || !("path" in runtime) || typeof runtime.path !== "string" || !("abi" in runtime) || runtime.abi !== process.versions.modules || !("electron" in runtime) || runtime.electron !== Boolean(process.versions.electron))
1207
+ continue;
1208
+ if (isAbsolute(runtime.path) && executable(runtime.path)) {
1209
+ this.nodePath = runtime.path;
1210
+ return runtime.path;
1211
+ }
1212
+ } catch {
1213
+ }
1214
+ }
1215
+ throw Object.assign(
1216
+ new Error(
1217
+ "The Node runtime was removed and no replacement was found. Reinstall Node or restart bb with an available runtime."
1218
+ ),
1219
+ { code: "ENOENT" }
1220
+ );
1221
+ }
1222
+ bundledNpmCli(command = "npm") {
1223
+ const require2 = createRequire(import.meta.url);
1224
+ return join(
1225
+ dirname(require2.resolve("npm/package.json")),
1226
+ "bin",
1227
+ `${command}-cli.js`
1228
+ );
1229
+ }
1230
+ npmCli(command = "npm", options = {}) {
1231
+ const bin = `${command}-cli.js`;
1232
+ const runtime = process.versions.electron ? null : this.node(options);
1233
+ const candidates = [];
1234
+ if (runtime !== null)
1235
+ for (const cli of [
1236
+ join(dirname(runtime), "..", "lib", "node_modules", "npm", "bin", bin),
1237
+ join(dirname(runtime), "node_modules", "npm", "bin", bin)
1238
+ ])
1239
+ candidates.push({ node: runtime, cli });
1240
+ const installed = this.resolve(command, options);
1241
+ if (installed) {
1242
+ try {
1243
+ const cli = realpathSync(installed);
1244
+ const npmRoot = dirname(dirname(cli));
1245
+ const node = [
1246
+ join(npmRoot, "..", "..", "..", "bin", "node"),
1247
+ join(npmRoot, "..", "..", "node.exe"),
1248
+ join(dirname(installed), "node")
1249
+ ].find(executable);
1250
+ if (basename(cli) === bin && node !== void 0)
1251
+ candidates.push({ node: realpathSync(node), cli });
1252
+ } catch {
1253
+ }
1254
+ }
1255
+ if (runtime !== null) {
1256
+ try {
1257
+ candidates.push({ node: runtime, cli: this.bundledNpmCli(command) });
1258
+ } catch {
1259
+ }
1260
+ }
1261
+ return candidates.find((candidate) => existsSync(candidate.cli)) ?? null;
1262
+ }
1263
+ command(command, args = [], options = {}) {
1264
+ const file = command === this.runtimePath ? this.node(options) : this.resolve(command, options) ?? command;
1265
+ const env = this.environment(options.env);
1266
+ if (/(?:^|[\\/])(?:npm|npx)-cli\.js$/u.test(args[0] ?? "")) {
1267
+ env.PATH = mergePath(dirname(file), env.PATH);
1268
+ }
1269
+ return { command: file, args: [...args], env };
1270
+ }
1271
+ };
1272
+ var toolchainKey = /* @__PURE__ */ Symbol.for("@bb/process-utils/host-toolchain");
1273
+ var shared = globalThis;
1274
+ var hostToolchain = shared[toolchainKey] ??= new HostToolchain();
1275
+
1276
+ // ../process-utils/src/host-process.ts
1277
+ function observe(child) {
1278
+ child.once("error", (error) => hostToolchain.invalidateFailure(error));
1279
+ child.once("exit", (code) => hostToolchain.invalidateFailure(code));
1280
+ return child;
1281
+ }
1282
+ function spawnHostProcess(command, args = [], options = {}) {
1283
+ const launch = options.shell ? { command, args: [...args], env: hostToolchain.environment(options.env) } : hostToolchain.command(command, args, options);
1284
+ const spawn2 = options.shell ? nodeSpawn : crossSpawn;
1285
+ return observe(
1286
+ spawn2(launch.command, launch.args, {
1287
+ ...options,
1288
+ env: launch.env,
1289
+ windowsHide: options.windowsHide ?? true
1290
+ })
1291
+ );
1292
+ }
1293
+ function prepareExecFile(command, args, options) {
1294
+ const launch = hostToolchain.command(command, args, options);
1295
+ const parsed = process.platform === "win32" && hostToolchain.resolve(launch.command, {
1296
+ env: launch.env,
1297
+ cwd: options.cwd
1298
+ }) === null ? { command: launch.command, args: launch.args, options } : parse(launch.command, launch.args, { ...options, env: launch.env });
1299
+ return {
1300
+ command: parsed.command,
1301
+ args: parsed.args,
1302
+ options: {
1303
+ ...options,
1304
+ ...parsed.options,
1305
+ env: launch.env,
1306
+ windowsHide: options.windowsHide ?? true
1307
+ }
1308
+ };
1309
+ }
1310
+ function execHostFileCallback(command, args, options, callback) {
1311
+ const launch = prepareExecFile(command, args, options);
1312
+ return observe(
1313
+ nodeExecFile(
1314
+ launch.command,
1315
+ launch.args,
1316
+ { ...launch.options, encoding: options.encoding ?? "utf8" },
1317
+ callback
1318
+ )
1319
+ );
1320
+ }
1321
+ function settleExecFile(start) {
1322
+ let resolve2;
1323
+ let reject;
1324
+ const promise = new Promise(
1325
+ (resolvePromise, rejectPromise) => {
1326
+ resolve2 = resolvePromise;
1327
+ reject = rejectPromise;
1328
+ }
1329
+ );
1330
+ const child = start((error, stdout, stderr) => {
1331
+ if (error) reject(Object.assign(error, { stdout, stderr }));
1332
+ else resolve2({ stdout, stderr });
1333
+ });
1334
+ return Object.assign(promise, { child });
1335
+ }
1336
+ function execHostFile(command, args = [], options = {}) {
1337
+ return settleExecFile(
1338
+ (callback) => execHostFileCallback(command, args, options, callback)
1339
+ );
1340
+ }
1341
+
1342
+ // ../process-utils/src/spawn.ts
797
1343
  function spawnPortableProcess(request) {
798
- return crossSpawn(request.command, request.args, {
1344
+ return spawnHostProcess(request.command, request.args, {
799
1345
  cwd: request.cwd,
800
1346
  detached: request.detached,
801
1347
  env: request.env,
@@ -968,7 +1514,7 @@ async function runVcsProcess(command, args, operation, options = {}) {
968
1514
 
969
1515
  // ../process-utils/src/cwd-processes.ts
970
1516
  import { lstat, readdir, readlink, realpath } from "node:fs/promises";
971
- import { basename, dirname, join, resolve, sep } from "node:path";
1517
+ import { basename as basename2, dirname as dirname2, join as join2, resolve, sep } from "node:path";
972
1518
  function isPathUnderDirectory(candidate, directory) {
973
1519
  const normalized = candidate.endsWith(" (deleted)") ? candidate.slice(0, -" (deleted)".length) : candidate;
974
1520
  return normalized === directory || normalized.startsWith(`${directory}${sep}`);
@@ -1015,22 +1561,22 @@ async function listLsofProcessCwds() {
1015
1561
  }
1016
1562
  async function resolveSweepDirectory(directory) {
1017
1563
  const resolved = resolve(directory);
1018
- let ancestor = dirname(resolved);
1019
- const missing = [basename(resolved)];
1564
+ let ancestor = dirname2(resolved);
1565
+ const missing = [basename2(resolved)];
1020
1566
  for (; ; ) {
1021
1567
  try {
1022
1568
  ancestor = await realpath(ancestor);
1023
1569
  break;
1024
1570
  } catch {
1025
1571
  }
1026
- const parent = dirname(ancestor);
1572
+ const parent = dirname2(ancestor);
1027
1573
  if (parent === ancestor) {
1028
1574
  break;
1029
1575
  }
1030
- missing.unshift(basename(ancestor));
1576
+ missing.unshift(basename2(ancestor));
1031
1577
  ancestor = parent;
1032
1578
  }
1033
- const canonical = join(ancestor, ...missing);
1579
+ const canonical = join2(ancestor, ...missing);
1034
1580
  try {
1035
1581
  if ((await lstat(canonical)).isSymbolicLink()) {
1036
1582
  return null;
@@ -1122,10 +1668,8 @@ function sanitizeInheritedChildProcessEnv(args) {
1122
1668
  }
1123
1669
 
1124
1670
  // ../process-utils/src/process-info.ts
1125
- import { execFile } from "node:child_process";
1126
- import path2 from "node:path";
1127
- import { promisify } from "node:util";
1128
- var execFileAsync = promisify(execFile);
1671
+ import path3 from "node:path";
1672
+ var execFileAsync = execHostFile;
1129
1673
  async function readProcessIdentity(pid) {
1130
1674
  if (!Number.isSafeInteger(pid) || pid <= 0) return null;
1131
1675
  if (process.platform === "win32") return readWindowsProcess(pid);
@@ -1152,7 +1696,7 @@ async function readProcessIdentity(pid) {
1152
1696
  async function readWindowsProcess(pid) {
1153
1697
  try {
1154
1698
  const pending = execFileAsync(
1155
- path2.join(
1699
+ path3.join(
1156
1700
  process.env.SystemRoot ?? "C:\\Windows",
1157
1701
  "System32",
1158
1702
  "WindowsPowerShell",
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/backend-contract.ts
2
- var PLUGIN_CLI_OUTPUT_MAX_BYTES = 1024 * 1024;
2
+ var PLUGIN_CLI_OUTPUT_MAX_BYTES = 32 * 1024 * 1024;
3
3
 
4
4
  // src/cli-spec.ts
5
5
  var PluginCliError = class extends Error {
@@ -2,6 +2,7 @@
2
2
  var FILE_PATH_MAX_LENGTH = 32768;
3
3
  var WINDOWS_DRIVE_ABSOLUTE_PATH = /^[A-Za-z]:[\\/]/u;
4
4
  var WINDOWS_UNC_ABSOLUTE_PATH = /^\\\\/u;
5
+ var REVISION_REF = /^(?:HEAD|[0-9a-f]{4,40})$/iu;
5
6
  function isJsonObject(value) {
6
7
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
7
8
  return false;
@@ -40,6 +41,9 @@ function hasUnpairedSurrogate(value) {
40
41
  function isValidPathSegment(segment) {
41
42
  return segment.length > 0 && segment !== "." && segment !== "..";
42
43
  }
44
+ function isValidRevisionRef(value) {
45
+ return typeof value === "string" && REVISION_REF.test(value);
46
+ }
43
47
  function isPositiveSafeInteger(value) {
44
48
  return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
45
49
  }
@@ -70,15 +74,22 @@ function isValidAbsoluteHostFilePath(value) {
70
74
  function normalizeExperimentalLiveFileTarget(value) {
71
75
  if (!isJsonObject(value) || typeof value.kind !== "string") return null;
72
76
  switch (value.kind) {
73
- case "workspace":
74
- if (!hasExactKeys(value, ["kind", "environmentId", "path"]) || !isNonEmptyIdentity(value.environmentId) || !isValidRelativeFilePath(value.path)) {
77
+ case "workspace": {
78
+ const ref = value.experimental_ref;
79
+ if (!hasExactKeys(
80
+ value,
81
+ ref === void 0 ? ["kind", "environmentId", "path"] : ["kind", "environmentId", "path", "experimental_ref"]
82
+ ) || !isNonEmptyIdentity(value.environmentId) || !isValidRelativeFilePath(value.path)) {
75
83
  return null;
76
84
  }
77
- return {
85
+ const target = {
78
86
  kind: value.kind,
79
87
  environmentId: value.environmentId,
80
88
  path: value.path
81
89
  };
90
+ if (ref === void 0) return target;
91
+ return isValidRevisionRef(ref) ? { ...target, experimental_ref: ref } : null;
92
+ }
82
93
  case "host":
83
94
  if (!hasExactKeys(value, ["kind", "hostId", "path"]) || !isNonEmptyIdentity(value.hostId) || !isValidAbsoluteHostFilePath(value.path)) {
84
95
  return null;
@@ -288,7 +288,7 @@ var providerNativeRootSetSchema = z4.object({
288
288
  }).strict();
289
289
 
290
290
  // src/backend-contract.ts
291
- var PLUGIN_CLI_OUTPUT_MAX_BYTES = 1024 * 1024;
291
+ var PLUGIN_CLI_OUTPUT_MAX_BYTES = 32 * 1024 * 1024;
292
292
 
293
293
  // src/internal/host-policy.ts
294
294
  function pluginCliCollisionWarning(pluginId, commandName) {