@zookanalytics/agent-env 1.1.0 → 1.2.0
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/config/baseline/devcontainer.json +4 -1
- package/config/baseline/init-host.sh +18 -6
- package/dist/cli.js +258 -80
- package/package.json +1 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
2
|
+
// This value is replaced at runtime by agent-env (see getManagedImage() in
|
|
3
|
+
// packages/agent-env/src/lib/devcontainer.ts). To change the image source,
|
|
4
|
+
// edit MANAGED_IMAGE_REPO in that file.
|
|
5
|
+
"image": "MANAGED_BY_AGENT_ENV_DO_NOT_EDIT",
|
|
3
6
|
"initializeCommand": "bash .agent-env/init-host.sh",
|
|
4
7
|
"mounts": [
|
|
5
8
|
"source=${localWorkspaceFolder}/.agent-env,target=/etc/agent-env,type=bind"
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# init-host.sh - Runs on the HOST before container creation (initializeCommand)
|
|
3
3
|
# Ensures mount sources exist to prevent devcontainer up failures.
|
|
4
|
-
# The .gitconfig
|
|
4
|
+
# The .gitconfig mount is provided by the image LABEL metadata; the SSH agent
|
|
5
|
+
# socket mount is injected per-platform by agent-env (resolveSshAgentMount).
|
|
5
6
|
|
|
6
7
|
set -euo pipefail
|
|
7
8
|
|
|
8
9
|
GITCONFIG="$HOME/.gitconfig"
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
# Host SSH agent socket. macOS Docker Desktop/OrbStack expose it at a fixed path;
|
|
12
|
+
# on Linux it is the host's real $SSH_AUTH_SOCK. Used only for a pre-flight warning.
|
|
13
|
+
if [ "$(uname -s)" = "Darwin" ]; then
|
|
14
|
+
SSH_SOCKET="/run/host-services/ssh-auth.sock"
|
|
15
|
+
else
|
|
16
|
+
SSH_SOCKET="${SSH_AUTH_SOCK:-}"
|
|
17
|
+
fi
|
|
10
18
|
|
|
11
19
|
# Ensure ~/.gitconfig exists (mounted read-only into container)
|
|
12
20
|
if [ ! -f "$GITCONFIG" ]; then
|
|
@@ -48,11 +56,15 @@ if [ -f "$PULSE_COOKIE_SRC" ]; then
|
|
|
48
56
|
echo "agent-env: Staged PulseAudio cookie for audio passthrough"
|
|
49
57
|
fi
|
|
50
58
|
|
|
51
|
-
# Verify SSH agent socket
|
|
52
|
-
if [ ! -S "$SSH_SOCKET" ]; then
|
|
53
|
-
echo "agent-env: Warning: SSH agent socket
|
|
59
|
+
# Verify a host SSH agent socket is available to forward into the container.
|
|
60
|
+
if [ -z "$SSH_SOCKET" ] || [ ! -S "$SSH_SOCKET" ]; then
|
|
61
|
+
echo "agent-env: Warning: no SSH agent socket found${SSH_SOCKET:+ at $SSH_SOCKET}"
|
|
54
62
|
echo "agent-env: SSH operations (git clone/push) may not work inside the container."
|
|
55
|
-
|
|
63
|
+
if [ "$(uname -s)" = "Darwin" ]; then
|
|
64
|
+
echo "agent-env: Ensure Docker Desktop or OrbStack is running."
|
|
65
|
+
else
|
|
66
|
+
echo "agent-env: Start an SSH agent and load your key (eval \"\$(ssh-agent -s)\" && ssh-add)."
|
|
67
|
+
fi
|
|
56
68
|
fi
|
|
57
69
|
|
|
58
70
|
echo "agent-env: Host initialization complete"
|
package/dist/cli.js
CHANGED
|
@@ -57,7 +57,7 @@ import React5 from "react";
|
|
|
57
57
|
// package.json
|
|
58
58
|
var package_default = {
|
|
59
59
|
name: "@zookanalytics/agent-env",
|
|
60
|
-
version: "1.
|
|
60
|
+
version: "1.2.0",
|
|
61
61
|
description: "CLI for creating isolated, AI-ready development environments",
|
|
62
62
|
type: "module",
|
|
63
63
|
bin: {
|
|
@@ -125,7 +125,7 @@ import { join as join8 } from "path";
|
|
|
125
125
|
// src/lib/container.ts
|
|
126
126
|
var DEVCONTAINER_UP_TIMEOUT = 3e5;
|
|
127
127
|
var DEVCONTAINER_UP_NO_CACHE_TIMEOUT = 3e5;
|
|
128
|
-
var DOCKER_PULL_TIMEOUT =
|
|
128
|
+
var DOCKER_PULL_TIMEOUT = 9e5;
|
|
129
129
|
var DOCKER_INSPECT_TIMEOUT = 1e4;
|
|
130
130
|
var DOCKER_INFO_TIMEOUT = 5e3;
|
|
131
131
|
var DOCKER_STOP_TIMEOUT = 3e4;
|
|
@@ -194,6 +194,37 @@ function createContainerLifecycle(executor = createExecutor()) {
|
|
|
194
194
|
const result = await executor("docker", ["info"], { timeout: DOCKER_INFO_TIMEOUT });
|
|
195
195
|
return result.ok;
|
|
196
196
|
}
|
|
197
|
+
async function isDevcontainerCliAvailable() {
|
|
198
|
+
const result = await executor("devcontainer", ["--version"], { timeout: DOCKER_INFO_TIMEOUT });
|
|
199
|
+
return result.ok;
|
|
200
|
+
}
|
|
201
|
+
async function checkDevcontainerPrerequisites() {
|
|
202
|
+
if (!await isDockerAvailable()) {
|
|
203
|
+
return {
|
|
204
|
+
ok: false,
|
|
205
|
+
status: "not-found",
|
|
206
|
+
containerId: null,
|
|
207
|
+
error: {
|
|
208
|
+
code: "ORBSTACK_REQUIRED",
|
|
209
|
+
message: "Docker is not available. OrbStack or Docker Desktop must be running.",
|
|
210
|
+
suggestion: "Start OrbStack or Docker Desktop, then try again."
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
if (!await isDevcontainerCliAvailable()) {
|
|
215
|
+
return {
|
|
216
|
+
ok: false,
|
|
217
|
+
status: "not-found",
|
|
218
|
+
containerId: null,
|
|
219
|
+
error: {
|
|
220
|
+
code: "DEVCONTAINER_CLI_MISSING",
|
|
221
|
+
message: "The `devcontainer` CLI was not found on your PATH.",
|
|
222
|
+
suggestion: 'Install it with `npm install -g @devcontainers/cli`, or \u2014 if you use VS Code \u2014 run the "Dev Containers: Install devcontainer CLI" command and ensure the resulting binary is on your PATH.'
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
197
228
|
async function containerStatus(containerName) {
|
|
198
229
|
const result = await executor("docker", ["inspect", containerName], {
|
|
199
230
|
timeout: DOCKER_INSPECT_TIMEOUT
|
|
@@ -296,18 +327,9 @@ function createContainerLifecycle(executor = createExecutor()) {
|
|
|
296
327
|
return name || null;
|
|
297
328
|
}
|
|
298
329
|
async function devcontainerUp(workspacePath, containerName, options) {
|
|
299
|
-
const
|
|
300
|
-
if (
|
|
301
|
-
return
|
|
302
|
-
ok: false,
|
|
303
|
-
status: "not-found",
|
|
304
|
-
containerId: null,
|
|
305
|
-
error: {
|
|
306
|
-
code: "ORBSTACK_REQUIRED",
|
|
307
|
-
message: "Docker is not available. OrbStack or Docker Desktop must be running.",
|
|
308
|
-
suggestion: "Start OrbStack or Docker Desktop, then try again."
|
|
309
|
-
}
|
|
310
|
-
};
|
|
330
|
+
const prereqError = await checkDevcontainerPrerequisites();
|
|
331
|
+
if (prereqError) {
|
|
332
|
+
return prereqError;
|
|
311
333
|
}
|
|
312
334
|
const buildNoCache = options?.buildNoCache === true;
|
|
313
335
|
const remoteEnvArgs = Object.entries(options?.remoteEnv ?? {}).flatMap(([key, value]) => [
|
|
@@ -401,17 +423,34 @@ function createContainerLifecycle(executor = createExecutor()) {
|
|
|
401
423
|
if (result.ok) {
|
|
402
424
|
return { ok: true };
|
|
403
425
|
}
|
|
426
|
+
const stderr = result.stderr ?? "";
|
|
427
|
+
const stderrLower = stderr.toLowerCase();
|
|
428
|
+
const isManifestUnknown = stderrLower.includes("manifest unknown") || stderrLower.includes("manifest for") && stderrLower.includes("not found");
|
|
429
|
+
if (isManifestUnknown) {
|
|
430
|
+
return {
|
|
431
|
+
ok: false,
|
|
432
|
+
error: {
|
|
433
|
+
code: "IMAGE_VERSION_NOT_PUBLISHED",
|
|
434
|
+
message: `Image '${image}' is not available in the registry: ${stderr.trim()}`,
|
|
435
|
+
suggestion: `The container image for this agent-env version may not be published yet. Image publishes complete shortly after each release; check workflow status to estimate readiness.
|
|
436
|
+
\u2022 Workflow runs: https://github.com/ZookAnalytics/bmad-orchestrator/actions/workflows/publish-image.yml
|
|
437
|
+
\u2022 Available tags: https://github.com/ZookAnalytics/bmad-orchestrator/pkgs/container/bmad-orchestrator%2Fdevcontainer
|
|
438
|
+
\u2022 Emergency unblock (ONLY if you already have a previously cached image): retry with --no-pull. The container will start with the locally cached image, which may not match agent-env's current version. If no image is cached, you must wait for the registry tag to publish.`
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
}
|
|
404
442
|
return {
|
|
405
443
|
ok: false,
|
|
406
444
|
error: {
|
|
407
445
|
code: "IMAGE_PULL_FAILED",
|
|
408
|
-
message: `Failed to pull '${image}': ${
|
|
409
|
-
suggestion: "Check network connectivity and image name. Use --no-pull
|
|
446
|
+
message: `Failed to pull '${image}': ${stderr}`,
|
|
447
|
+
suggestion: "Check network connectivity and image name. Use --no-pull ONLY if you already have a previously cached image \u2014 the container will start with whatever is cached locally and may not match the current agent-env version."
|
|
410
448
|
}
|
|
411
449
|
};
|
|
412
450
|
}
|
|
413
451
|
return {
|
|
414
452
|
isDockerAvailable,
|
|
453
|
+
isDevcontainerCliAvailable,
|
|
415
454
|
containerStatus,
|
|
416
455
|
getContainerNameById,
|
|
417
456
|
findContainerByWorkspaceLabel,
|
|
@@ -442,7 +481,6 @@ import { dirname as dirname2, join as join7 } from "path";
|
|
|
442
481
|
import { parse as parseJsonc2 } from "jsonc-parser";
|
|
443
482
|
import { constants } from "fs";
|
|
444
483
|
import { access as access2, lstat, readFile as readFile2, readlink, rename, writeFile as writeFile2 } from "fs/promises";
|
|
445
|
-
import { createRequire } from "module";
|
|
446
484
|
import { join as join2 } from "path";
|
|
447
485
|
|
|
448
486
|
// src/lib/container-env.ts
|
|
@@ -495,6 +533,10 @@ var defaultFsDeps = { access, cp, mkdir, readdir, readFile, stat, writeFile };
|
|
|
495
533
|
var DEVCONTAINER_DIR = ".devcontainer";
|
|
496
534
|
var DEVCONTAINER_JSON = "devcontainer.json";
|
|
497
535
|
var DOT_DEVCONTAINER_JSON = ".devcontainer.json";
|
|
536
|
+
var MANAGED_IMAGE_REPO = "ghcr.io/zookanalytics/bmad-orchestrator/devcontainer";
|
|
537
|
+
function getManagedImage() {
|
|
538
|
+
return `${MANAGED_IMAGE_REPO}:${package_default.version}`;
|
|
539
|
+
}
|
|
498
540
|
var cachedPackageRoot;
|
|
499
541
|
function getPackageRoot(checkAccess = accessSync) {
|
|
500
542
|
if (cachedPackageRoot) return cachedPackageRoot;
|
|
@@ -692,7 +734,9 @@ async function readRepoConfig(workspacePath, deps = defaultMergeDeps, logger) {
|
|
|
692
734
|
}
|
|
693
735
|
return void 0;
|
|
694
736
|
}
|
|
695
|
-
|
|
737
|
+
var MAX_WARNED_MISMATCHES = 100;
|
|
738
|
+
var warnedMismatches = /* @__PURE__ */ new Set();
|
|
739
|
+
function validateRepoConfig(config, managedImage, logger, workspaceKey) {
|
|
696
740
|
const rejectedProps = ["build", "dockerFile", "dockerfile", "dockerComposeFile"];
|
|
697
741
|
for (const prop of rejectedProps) {
|
|
698
742
|
if (prop in config && config[prop] !== void 0) {
|
|
@@ -704,9 +748,17 @@ function validateRepoConfig(config, managedImage, logger) {
|
|
|
704
748
|
if ("image" in config && config.image !== void 0) {
|
|
705
749
|
const repoImage = String(config.image);
|
|
706
750
|
if (repoImage !== managedImage) {
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
751
|
+
const key = `${workspaceKey ?? "*"}|${repoImage}|${managedImage}`;
|
|
752
|
+
if (!warnedMismatches.has(key)) {
|
|
753
|
+
if (warnedMismatches.size >= MAX_WARNED_MISMATCHES) {
|
|
754
|
+
const first = warnedMismatches.values().next().value;
|
|
755
|
+
if (first !== void 0) warnedMismatches.delete(first);
|
|
756
|
+
}
|
|
757
|
+
warnedMismatches.add(key);
|
|
758
|
+
logger?.warn(
|
|
759
|
+
`Repo config specifies image '${repoImage}' which will be overridden by agent-env managed image '${managedImage}'.`
|
|
760
|
+
);
|
|
761
|
+
}
|
|
710
762
|
}
|
|
711
763
|
}
|
|
712
764
|
}
|
|
@@ -963,22 +1015,16 @@ async function loadManagedDefaults(deps = defaultMergeDeps) {
|
|
|
963
1015
|
}
|
|
964
1016
|
}
|
|
965
1017
|
return {
|
|
966
|
-
image
|
|
1018
|
+
// The baseline file's `image` field is a sentinel (MANAGED_BY_AGENT_ENV_DO_NOT_EDIT)
|
|
1019
|
+
// — the real image is computed at runtime from packageJson.version via getManagedImage().
|
|
1020
|
+
// Edit MANAGED_IMAGE_REPO in devcontainer.ts to change the image source.
|
|
1021
|
+
image: getManagedImage(),
|
|
967
1022
|
initializeCmd: config.initializeCommand,
|
|
968
1023
|
baseContainerEnv
|
|
969
1024
|
};
|
|
970
1025
|
}
|
|
971
|
-
function getPackageVersion() {
|
|
972
|
-
try {
|
|
973
|
-
const req = createRequire(import.meta.url);
|
|
974
|
-
const pkg = req("../../package.json");
|
|
975
|
-
return pkg.version;
|
|
976
|
-
} catch {
|
|
977
|
-
return "unknown";
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
1026
|
async function writeGeneratedConfig(outputPath, config, deps = defaultMergeDeps) {
|
|
981
|
-
const version2 =
|
|
1027
|
+
const version2 = package_default.version;
|
|
982
1028
|
const header = `${AUTO_GENERATED_HEADER} v${version2}. Do not edit.
|
|
983
1029
|
`;
|
|
984
1030
|
const json = JSON.stringify(config, null, 2);
|
|
@@ -988,12 +1034,28 @@ async function writeGeneratedConfig(outputPath, config, deps = defaultMergeDeps)
|
|
|
988
1034
|
await deps.writeFile(tmpPath, content, "utf-8");
|
|
989
1035
|
await deps.rename(tmpPath, outputPath);
|
|
990
1036
|
}
|
|
1037
|
+
var SSH_AGENT_CONTAINER_SOCKET = "/run/host-services/ssh-auth.sock";
|
|
1038
|
+
function resolveSshAgentMount(platform2 = process.platform, sshAuthSock = process.env.SSH_AUTH_SOCK) {
|
|
1039
|
+
const target = SSH_AGENT_CONTAINER_SOCKET;
|
|
1040
|
+
const forwarding = (source) => ({
|
|
1041
|
+
mount: `source=${source},target=${target},type=bind`,
|
|
1042
|
+
env: { SSH_AUTH_SOCK: target }
|
|
1043
|
+
});
|
|
1044
|
+
if (platform2 === "darwin") {
|
|
1045
|
+
return forwarding(target);
|
|
1046
|
+
}
|
|
1047
|
+
if (sshAuthSock && sshAuthSock.length > 0) {
|
|
1048
|
+
return forwarding("${localEnv:SSH_AUTH_SOCK}");
|
|
1049
|
+
}
|
|
1050
|
+
return null;
|
|
1051
|
+
}
|
|
991
1052
|
function buildManagedConfig(defaults, params) {
|
|
992
1053
|
const statusBarWatcher = {
|
|
993
1054
|
match: `${STATUS_BAR_JSON_FILENAME}$`,
|
|
994
1055
|
event: "onFolderChange",
|
|
995
1056
|
vscodeTask: "betterStatusBar.refreshButtons"
|
|
996
1057
|
};
|
|
1058
|
+
const sshAgent = params.sshAgent === void 0 ? resolveSshAgentMount() : params.sshAgent;
|
|
997
1059
|
return {
|
|
998
1060
|
image: defaults.image,
|
|
999
1061
|
instanceName: params.instanceName,
|
|
@@ -1005,9 +1067,10 @@ function buildManagedConfig(defaults, params) {
|
|
|
1005
1067
|
...defaults.baseContainerEnv,
|
|
1006
1068
|
AGENT_ENV_INSTANCE: params.instanceName,
|
|
1007
1069
|
AGENT_ENV_REPO: params.repoSlug,
|
|
1008
|
-
AGENT_ENV_PURPOSE: params.purpose
|
|
1070
|
+
AGENT_ENV_PURPOSE: params.purpose,
|
|
1071
|
+
...sshAgent?.env ?? {}
|
|
1009
1072
|
},
|
|
1010
|
-
mounts: [],
|
|
1073
|
+
mounts: sshAgent ? [sshAgent.mount] : [],
|
|
1011
1074
|
customizations: {
|
|
1012
1075
|
vscode: {
|
|
1013
1076
|
settings: {
|
|
@@ -1020,6 +1083,23 @@ function buildManagedConfig(defaults, params) {
|
|
|
1020
1083
|
};
|
|
1021
1084
|
}
|
|
1022
1085
|
|
|
1086
|
+
// src/lib/managed-image-pull.ts
|
|
1087
|
+
async function pullManagedImage(managedImage, pull, deps) {
|
|
1088
|
+
if (!pull) {
|
|
1089
|
+
deps.logger?.warn(
|
|
1090
|
+
`Using cached image; not matched to current agent-env version. Skipping pull of ${managedImage} (--no-pull). The container will start with whichever image is already cached locally. Re-run without --no-pull to fetch the pinned image.`
|
|
1091
|
+
);
|
|
1092
|
+
return { ok: true };
|
|
1093
|
+
}
|
|
1094
|
+
deps.logger?.info(
|
|
1095
|
+
`Pulling ${managedImage}... (no progress output; a first download of this multi-GB image may take several minutes)`
|
|
1096
|
+
);
|
|
1097
|
+
const result = await deps.container.dockerPull(managedImage);
|
|
1098
|
+
if (!result.ok) return { ok: false, error: result.error };
|
|
1099
|
+
deps.logger?.info(`Pulled ${managedImage}`);
|
|
1100
|
+
return { ok: true };
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1023
1103
|
// src/lib/purpose-instance.ts
|
|
1024
1104
|
import { appendFile as appendFile2, mkdir as mkdir4, readdir as readdir3, readFile as readFile6, rename as rename3, stat as stat3, writeFile as writeFile5 } from "fs/promises";
|
|
1025
1105
|
import { homedir as homedir2 } from "os";
|
|
@@ -1708,7 +1788,7 @@ async function setupMergedConfig(wsPath, containerName, repoName, purposeText, d
|
|
|
1708
1788
|
await copyRepoEnvFiles(repoName, wsPath.root);
|
|
1709
1789
|
const repoConfig = await readRepoConfig(wsPath.root, deps.mergeDeps, deps.logger);
|
|
1710
1790
|
if (repoConfig) {
|
|
1711
|
-
validateRepoConfig(repoConfig, defaults.image, deps.logger);
|
|
1791
|
+
validateRepoConfig(repoConfig, defaults.image, deps.logger, wsPath.root);
|
|
1712
1792
|
}
|
|
1713
1793
|
const merged = mergeDevcontainerConfigs(managed, repoConfig);
|
|
1714
1794
|
await copyManagedAssets(wsPath.root, deps.devcontainerFsDeps);
|
|
@@ -1812,6 +1892,21 @@ async function createInstance(instanceName, repoUrl, deps, options) {
|
|
|
1812
1892
|
}
|
|
1813
1893
|
};
|
|
1814
1894
|
}
|
|
1895
|
+
const dockerAvailable = await deps.container.isDockerAvailable();
|
|
1896
|
+
if (!dockerAvailable) {
|
|
1897
|
+
return {
|
|
1898
|
+
ok: false,
|
|
1899
|
+
error: {
|
|
1900
|
+
code: "ORBSTACK_REQUIRED",
|
|
1901
|
+
message: "Docker is not available. OrbStack or Docker Desktop must be running.",
|
|
1902
|
+
suggestion: "Start OrbStack or Docker Desktop, then try again."
|
|
1903
|
+
}
|
|
1904
|
+
};
|
|
1905
|
+
}
|
|
1906
|
+
const managedPullResult = await pullManagedImage(getManagedImage(), options?.pull ?? true, deps);
|
|
1907
|
+
if (!managedPullResult.ok) {
|
|
1908
|
+
return { ok: false, error: managedPullResult.error };
|
|
1909
|
+
}
|
|
1815
1910
|
const prepResult = await cloneAndPrepareWorkspace(repoUrl, wsPath, deps);
|
|
1816
1911
|
if (!prepResult.ok) return prepResult;
|
|
1817
1912
|
const configResult = await setupMergedConfig(wsPath, containerName, repoName, purposeText, deps);
|
|
@@ -2698,7 +2793,7 @@ async function resolveRepoArg(repoArg, deps) {
|
|
|
2698
2793
|
}
|
|
2699
2794
|
|
|
2700
2795
|
// src/commands/create.ts
|
|
2701
|
-
var createCommand = new Command4("create").description("Create a new isolated development environment").argument("<name>", "Name for the new instance").option("--repo <url|slug>", 'Git repo URL, registered slug, or "." for current directory').option("--purpose <text>", "Set the instance purpose/label at creation time").option("--attach", "Attach immediately after creation").option("--baseline", "[REMOVED] Config merge replaces this flag").option("--no-baseline", "[REMOVED] Config merge replaces this flag").action(async (name, options) => {
|
|
2796
|
+
var createCommand = new Command4("create").description("Create a new isolated development environment").argument("<name>", "Name for the new instance").option("--repo <url|slug>", 'Git repo URL, registered slug, or "." for current directory').option("--purpose <text>", "Set the instance purpose/label at creation time").option("--attach", "Attach immediately after creation").option("--no-pull", "Skip pulling the managed image (use cached image)").option("--baseline", "[REMOVED] Config merge replaces this flag").option("--no-baseline", "[REMOVED] Config merge replaces this flag").action(async (name, options) => {
|
|
2702
2797
|
if (options.baseline !== void 0) {
|
|
2703
2798
|
console.error(
|
|
2704
2799
|
formatError(
|
|
@@ -2746,7 +2841,8 @@ var createCommand = new Command4("create").description("Create a new isolated de
|
|
|
2746
2841
|
try {
|
|
2747
2842
|
const result = await createInstance(name, repoUrl, deps, {
|
|
2748
2843
|
purpose: options.purpose,
|
|
2749
|
-
onProgress: progress.update
|
|
2844
|
+
onProgress: progress.update,
|
|
2845
|
+
pull: options.pull
|
|
2750
2846
|
});
|
|
2751
2847
|
progress.clear();
|
|
2752
2848
|
if (!result.ok) {
|
|
@@ -3243,8 +3339,9 @@ var listCommand = new Command6("list").alias("ps").description("List all instanc
|
|
|
3243
3339
|
import { Command as Command7 } from "commander";
|
|
3244
3340
|
|
|
3245
3341
|
// src/lib/version-drift.ts
|
|
3342
|
+
import { parse as parseJsonc3 } from "jsonc-parser";
|
|
3246
3343
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
3247
|
-
import { access as access4, constants as constants2 } from "fs/promises";
|
|
3344
|
+
import { access as access4, constants as constants2, readFile as readFile11 } from "fs/promises";
|
|
3248
3345
|
import { homedir as homedir7 } from "os";
|
|
3249
3346
|
import { join as join10 } from "path";
|
|
3250
3347
|
|
|
@@ -3320,13 +3417,13 @@ async function checkForUpdate(opts) {
|
|
|
3320
3417
|
cachePath,
|
|
3321
3418
|
cacheTtlMs,
|
|
3322
3419
|
fetchFn = fetch,
|
|
3323
|
-
readFile:
|
|
3420
|
+
readFile: readFile18 = (p, enc) => fs.readFile(p, enc),
|
|
3324
3421
|
writeFile: writeFile14 = (p, d, enc) => fs.writeFile(p, d, enc),
|
|
3325
3422
|
mkdir: mkdir15 = (p, o) => fs.mkdir(p, o),
|
|
3326
3423
|
now = () => Date.now()
|
|
3327
3424
|
} = opts;
|
|
3328
3425
|
const currentTime = now();
|
|
3329
|
-
const cache = await readCache(cachePath,
|
|
3426
|
+
const cache = await readCache(cachePath, readFile18);
|
|
3330
3427
|
let latestVersion = null;
|
|
3331
3428
|
const isCacheFresh = cache !== null && currentTime - cache.lastCheck < cacheTtlMs;
|
|
3332
3429
|
if (isCacheFresh) {
|
|
@@ -3385,6 +3482,31 @@ async function isPackagePathStale(deps = {}) {
|
|
|
3385
3482
|
return true;
|
|
3386
3483
|
}
|
|
3387
3484
|
}
|
|
3485
|
+
async function detectImageDrift(managedConfigPath, deps = {}) {
|
|
3486
|
+
const read = deps.readFile ?? readFile11;
|
|
3487
|
+
const expected = (deps.getExpectedImage ?? getManagedImage)();
|
|
3488
|
+
let content;
|
|
3489
|
+
try {
|
|
3490
|
+
content = await read(managedConfigPath, "utf-8");
|
|
3491
|
+
} catch {
|
|
3492
|
+
return null;
|
|
3493
|
+
}
|
|
3494
|
+
const errors = [];
|
|
3495
|
+
const parsed = parseJsonc3(content, errors, { allowTrailingComma: true });
|
|
3496
|
+
if (errors.length > 0 || parsed === null) {
|
|
3497
|
+
deps.logger?.warn(
|
|
3498
|
+
`Could not parse ${managedConfigPath} to check image drift \u2014 file may be corrupted. Rebuild to regenerate.`
|
|
3499
|
+
);
|
|
3500
|
+
return null;
|
|
3501
|
+
}
|
|
3502
|
+
if (typeof parsed.image !== "string") return null;
|
|
3503
|
+
if (parsed.image === expected) return null;
|
|
3504
|
+
return { configuredImage: parsed.image, expectedImage: expected };
|
|
3505
|
+
}
|
|
3506
|
+
function getManagedConfigPath(workspaceName, fsDeps) {
|
|
3507
|
+
const wsPath = getWorkspacePathByName(workspaceName, fsDeps);
|
|
3508
|
+
return join10(wsPath.agentEnvDir, "devcontainer.json");
|
|
3509
|
+
}
|
|
3388
3510
|
var UPDATE_CHECK_CACHE_PATH = join10(homedir7(), ".agent-env", "update-check.json");
|
|
3389
3511
|
var UPDATE_CHECK_CACHE_TTL_MS = 36e5;
|
|
3390
3512
|
async function fetchUpdateMessageFromRegistry(force = false) {
|
|
@@ -3399,22 +3521,30 @@ async function fetchUpdateMessageFromRegistry(force = false) {
|
|
|
3399
3521
|
return null;
|
|
3400
3522
|
}
|
|
3401
3523
|
}
|
|
3402
|
-
async function detectDriftState(deps = {}, options = {}) {
|
|
3524
|
+
async function detectDriftState(workspaceName, deps = {}, options = {}) {
|
|
3403
3525
|
const {
|
|
3404
3526
|
isPackagePathStale: probe = isPackagePathStale,
|
|
3405
3527
|
fetchUpdateMessage = (force) => fetchUpdateMessageFromRegistry(force),
|
|
3406
|
-
getInstalledVersion: resolveInstalled = getInstalledVersion
|
|
3528
|
+
getInstalledVersion: resolveInstalled = getInstalledVersion,
|
|
3529
|
+
detectImageDrift: imageProbe = (path) => detectImageDrift(path)
|
|
3407
3530
|
} = deps;
|
|
3408
3531
|
const installedVersion = resolveInstalled();
|
|
3409
|
-
const [packageMoved, updateMessage] = await Promise.all([
|
|
3532
|
+
const [packageMoved, updateMessage, imageDrift] = await Promise.all([
|
|
3410
3533
|
probe(),
|
|
3411
|
-
fetchUpdateMessage(options.forceRefresh ?? false)
|
|
3534
|
+
fetchUpdateMessage(options.forceRefresh ?? false),
|
|
3535
|
+
// Resilience: a buggy override could reject. Built-in detectImageDrift
|
|
3536
|
+
// already swallows its own errors, but treat the whole probe as best-effort
|
|
3537
|
+
// so the entire drift state never rejects on the menu's poll loop.
|
|
3538
|
+
workspaceName !== void 0 ? imageProbe(getManagedConfigPath(workspaceName)).catch(
|
|
3539
|
+
() => null
|
|
3540
|
+
) : Promise.resolve(null)
|
|
3412
3541
|
]);
|
|
3413
3542
|
return {
|
|
3414
3543
|
packageMoved,
|
|
3415
3544
|
updateMessage,
|
|
3416
3545
|
installedVersion,
|
|
3417
|
-
currentVersion: package_default.version
|
|
3546
|
+
currentVersion: package_default.version,
|
|
3547
|
+
imageDrift
|
|
3418
3548
|
};
|
|
3419
3549
|
}
|
|
3420
3550
|
function getCurrentVersion() {
|
|
@@ -3562,6 +3692,14 @@ function hasNewerInstall(driftState) {
|
|
|
3562
3692
|
if (!driftState?.installedVersion) return false;
|
|
3563
3693
|
return isNewerVersion2(driftState.currentVersion, driftState.installedVersion);
|
|
3564
3694
|
}
|
|
3695
|
+
function formatImageTagForLabel(image) {
|
|
3696
|
+
const noDigest = image.split("@")[0];
|
|
3697
|
+
const m = /:([^:/]+)$/.exec(noDigest);
|
|
3698
|
+
if (!m) return "refresh";
|
|
3699
|
+
const tag = m[1];
|
|
3700
|
+
if (/^\d+\.\d+\.\d+(?:[-+].+)?$/.test(tag)) return `v${tag}`;
|
|
3701
|
+
return "refresh";
|
|
3702
|
+
}
|
|
3565
3703
|
function buildActionOptions(driftState) {
|
|
3566
3704
|
if (driftState?.packageMoved) {
|
|
3567
3705
|
return [RESTART_REQUIRED_OPTION, ...BASE_ACTION_OPTIONS, EXIT_OPTION];
|
|
@@ -3570,6 +3708,13 @@ function buildActionOptions(driftState) {
|
|
|
3570
3708
|
const label = `\u267B\uFE0F Restart menu (v${driftState.installedVersion} installed)`;
|
|
3571
3709
|
return [{ label, value: "restart" }, ...BASE_ACTION_OPTIONS, EXIT_OPTION];
|
|
3572
3710
|
}
|
|
3711
|
+
if (driftState?.imageDrift) {
|
|
3712
|
+
const imageLabel = formatImageTagForLabel(driftState.imageDrift.expectedImage);
|
|
3713
|
+
const updatedOptions = BASE_ACTION_OPTIONS.map(
|
|
3714
|
+
(o) => o.value === "rebuild" ? { label: `\u{1F6E0} Rebuild container (image ${imageLabel} available)`, value: "rebuild" } : o
|
|
3715
|
+
);
|
|
3716
|
+
return [...updatedOptions, CHECK_FOR_UPDATES_OPTION, EXIT_OPTION];
|
|
3717
|
+
}
|
|
3573
3718
|
if (driftState?.updateMessage) {
|
|
3574
3719
|
return [...BASE_ACTION_OPTIONS, CHECK_FOR_UPDATES_OPTION, EXIT_OPTION];
|
|
3575
3720
|
}
|
|
@@ -3592,6 +3737,15 @@ function DriftBanner({ driftState }) {
|
|
|
3592
3737
|
" is installed \u2014 restart to use it"
|
|
3593
3738
|
] }) });
|
|
3594
3739
|
}
|
|
3740
|
+
if (driftState.imageDrift) {
|
|
3741
|
+
return /* @__PURE__ */ jsx3(Box2, { marginBottom: 1, children: /* @__PURE__ */ jsxs3(Text3, { color: "cyan", children: [
|
|
3742
|
+
"Container image will refresh on next rebuild: ",
|
|
3743
|
+
driftState.imageDrift.configuredImage,
|
|
3744
|
+
" \u2192",
|
|
3745
|
+
" ",
|
|
3746
|
+
driftState.imageDrift.expectedImage
|
|
3747
|
+
] }) });
|
|
3748
|
+
}
|
|
3595
3749
|
if (driftState.updateMessage) {
|
|
3596
3750
|
return /* @__PURE__ */ jsx3(Box2, { marginBottom: 1, flexDirection: "column", children: /* @__PURE__ */ jsx3(Text3, { color: "yellow", children: driftState.updateMessage }) });
|
|
3597
3751
|
}
|
|
@@ -3646,7 +3800,8 @@ function makeNeutralDriftState() {
|
|
|
3646
3800
|
packageMoved: false,
|
|
3647
3801
|
updateMessage: null,
|
|
3648
3802
|
installedVersion: null,
|
|
3649
|
-
currentVersion: getCurrentVersion()
|
|
3803
|
+
currentVersion: getCurrentVersion(),
|
|
3804
|
+
imageDrift: null
|
|
3650
3805
|
};
|
|
3651
3806
|
}
|
|
3652
3807
|
function MenuContainer({
|
|
@@ -3664,7 +3819,7 @@ function MenuContainer({
|
|
|
3664
3819
|
let cancelled = false;
|
|
3665
3820
|
const runProbe = async () => {
|
|
3666
3821
|
try {
|
|
3667
|
-
const next = await detectDriftStateFn();
|
|
3822
|
+
const next = await detectDriftStateFn(instanceInfo.name);
|
|
3668
3823
|
if (!cancelled) {
|
|
3669
3824
|
setDriftState(next);
|
|
3670
3825
|
}
|
|
@@ -3679,7 +3834,7 @@ function MenuContainer({
|
|
|
3679
3834
|
cancelled = true;
|
|
3680
3835
|
clearInterval(handle);
|
|
3681
3836
|
};
|
|
3682
|
-
}, [detectDriftStateFn, pollIntervalMs]);
|
|
3837
|
+
}, [detectDriftStateFn, pollIntervalMs, instanceInfo.name]);
|
|
3683
3838
|
return /* @__PURE__ */ jsx4(
|
|
3684
3839
|
InteractiveMenu,
|
|
3685
3840
|
{
|
|
@@ -3697,7 +3852,7 @@ import {
|
|
|
3697
3852
|
cp as cp3,
|
|
3698
3853
|
mkdir as mkdir9,
|
|
3699
3854
|
readdir as readdir7,
|
|
3700
|
-
readFile as
|
|
3855
|
+
readFile as readFile12,
|
|
3701
3856
|
rename as rename7,
|
|
3702
3857
|
rm as rm3,
|
|
3703
3858
|
stat as stat7,
|
|
@@ -3735,9 +3890,9 @@ function createRebuildDefaultDeps() {
|
|
|
3735
3890
|
executor,
|
|
3736
3891
|
container: createContainerLifecycle(executor),
|
|
3737
3892
|
workspaceFsDeps: { mkdir: mkdir9, readdir: readdir7, stat: stat7, homedir: homedir8 },
|
|
3738
|
-
stateFsDeps: { readFile:
|
|
3739
|
-
devcontainerFsDeps: { cp: cp3, mkdir: mkdir9, readdir: readdir7, readFile:
|
|
3740
|
-
mergeDeps: { readFile:
|
|
3893
|
+
stateFsDeps: { readFile: readFile12, writeFile: writeFile10, rename: rename7, mkdir: mkdir9, appendFile: appendFile6 },
|
|
3894
|
+
devcontainerFsDeps: { cp: cp3, mkdir: mkdir9, readdir: readdir7, readFile: readFile12, stat: stat7, writeFile: writeFile10 },
|
|
3895
|
+
mergeDeps: { readFile: readFile12, writeFile: writeFile10, rename: rename7, access: access5 },
|
|
3741
3896
|
rm: rm3,
|
|
3742
3897
|
rename: rename7,
|
|
3743
3898
|
logger: { warn: (msg) => console.warn(msg), info: (msg) => console.info(msg) }
|
|
@@ -3765,13 +3920,16 @@ async function refreshMergedConfig(wsRoot, containerName, wsName, repoSlug, purp
|
|
|
3765
3920
|
};
|
|
3766
3921
|
}
|
|
3767
3922
|
if (repoConfig) {
|
|
3768
|
-
validateRepoConfig(repoConfig, defaults.image, deps.logger);
|
|
3923
|
+
validateRepoConfig(repoConfig, defaults.image, deps.logger, wsRoot);
|
|
3769
3924
|
}
|
|
3770
3925
|
const merged = mergeDevcontainerConfigs(managed, repoConfig);
|
|
3771
3926
|
await copyManagedAssets(wsRoot, deps.devcontainerFsDeps);
|
|
3772
3927
|
const configPath = join11(wsRoot, AGENT_ENV_DIR, "devcontainer.json");
|
|
3773
3928
|
await writeGeneratedConfig(configPath, merged, deps.mergeDeps);
|
|
3774
|
-
return {
|
|
3929
|
+
return {
|
|
3930
|
+
ok: true,
|
|
3931
|
+
repoConfigDetected: repoConfig !== void 0
|
|
3932
|
+
};
|
|
3775
3933
|
} catch (err) {
|
|
3776
3934
|
return {
|
|
3777
3935
|
ok: false,
|
|
@@ -3795,7 +3953,11 @@ async function lookupWorkspace(instanceName, deps, repoSlug) {
|
|
|
3795
3953
|
const state = await readState(wsPath, deps.stateFsDeps);
|
|
3796
3954
|
return { ok: true, wsPath, state };
|
|
3797
3955
|
}
|
|
3798
|
-
async function executePullStep(wsRoot, pull, deps) {
|
|
3956
|
+
async function executePullStep(wsRoot, pull, managedImage, deps) {
|
|
3957
|
+
const managedPullResult = await pullManagedImage(managedImage, pull, deps);
|
|
3958
|
+
if (!managedPullResult.ok) {
|
|
3959
|
+
return { ok: false, error: managedPullResult.error };
|
|
3960
|
+
}
|
|
3799
3961
|
let dockerfilePath;
|
|
3800
3962
|
try {
|
|
3801
3963
|
dockerfilePath = await resolveDockerfilePath(wsRoot, deps.devcontainerFsDeps);
|
|
@@ -3814,7 +3976,7 @@ async function executePullStep(wsRoot, pull, deps) {
|
|
|
3814
3976
|
return { ok: true, hasDockerfile };
|
|
3815
3977
|
}
|
|
3816
3978
|
if (dockerfilePath === null) {
|
|
3817
|
-
deps.logger?.info("No Dockerfile found \u2014
|
|
3979
|
+
deps.logger?.info("No Dockerfile found \u2014 only managed image pulled.");
|
|
3818
3980
|
return { ok: true, hasDockerfile: false };
|
|
3819
3981
|
}
|
|
3820
3982
|
let dockerfileContent;
|
|
@@ -3909,6 +4071,11 @@ async function rebuildInstance(instanceName, deps, options, repoSlug) {
|
|
|
3909
4071
|
}
|
|
3910
4072
|
};
|
|
3911
4073
|
}
|
|
4074
|
+
const pullStepResult = await executePullStep(wsPath.root, pull, getManagedImage(), deps);
|
|
4075
|
+
if (!pullStepResult.ok) {
|
|
4076
|
+
return { ok: false, error: pullStepResult.error };
|
|
4077
|
+
}
|
|
4078
|
+
const { hasDockerfile } = pullStepResult;
|
|
3912
4079
|
const configResult = await refreshMergedConfig(
|
|
3913
4080
|
wsPath.root,
|
|
3914
4081
|
containerName,
|
|
@@ -3921,11 +4088,6 @@ async function rebuildInstance(instanceName, deps, options, repoSlug) {
|
|
|
3921
4088
|
if (!configResult.ok) {
|
|
3922
4089
|
return { ok: false, error: configResult.error };
|
|
3923
4090
|
}
|
|
3924
|
-
const pullStepResult = await executePullStep(wsPath.root, pull, deps);
|
|
3925
|
-
if (!pullStepResult.ok) {
|
|
3926
|
-
return { ok: false, error: pullStepResult.error };
|
|
3927
|
-
}
|
|
3928
|
-
const { hasDockerfile } = pullStepResult;
|
|
3929
4091
|
const statusResult = await deps.container.containerStatus(oldContainerName);
|
|
3930
4092
|
const wasRunning = statusResult.ok && statusResult.status === "running";
|
|
3931
4093
|
if (wasRunning && !force) {
|
|
@@ -3972,7 +4134,7 @@ async function rebuildInstance(instanceName, deps, options, repoSlug) {
|
|
|
3972
4134
|
}
|
|
3973
4135
|
|
|
3974
4136
|
// src/lib/shutdown-instance.ts
|
|
3975
|
-
import { appendFile as appendFile7, mkdir as mkdir10, readdir as readdir8, readFile as
|
|
4137
|
+
import { appendFile as appendFile7, mkdir as mkdir10, readdir as readdir8, readFile as readFile13, rename as rename8, stat as stat8, writeFile as writeFile11 } from "fs/promises";
|
|
3976
4138
|
import { homedir as homedir9 } from "os";
|
|
3977
4139
|
function createShutdownDefaultDeps() {
|
|
3978
4140
|
const executor = createExecutor();
|
|
@@ -3980,7 +4142,7 @@ function createShutdownDefaultDeps() {
|
|
|
3980
4142
|
executor,
|
|
3981
4143
|
container: createContainerLifecycle(executor),
|
|
3982
4144
|
workspaceFsDeps: { mkdir: mkdir10, readdir: readdir8, stat: stat8, homedir: homedir9 },
|
|
3983
|
-
stateFsDeps: { readFile:
|
|
4145
|
+
stateFsDeps: { readFile: readFile13, writeFile: writeFile11, rename: rename8, mkdir: mkdir10, appendFile: appendFile7 },
|
|
3984
4146
|
logger: { warn: (msg) => console.warn(msg), info: (msg) => console.info(msg) }
|
|
3985
4147
|
};
|
|
3986
4148
|
}
|
|
@@ -4029,7 +4191,7 @@ async function shutdownInstance(instanceName, deps, repoSlug) {
|
|
|
4029
4191
|
}
|
|
4030
4192
|
|
|
4031
4193
|
// src/lib/menu-deps.ts
|
|
4032
|
-
function buildMenuDeps() {
|
|
4194
|
+
function buildMenuDeps(workspaceName) {
|
|
4033
4195
|
return {
|
|
4034
4196
|
attachInstance: (wsName, slug) => {
|
|
4035
4197
|
const deps = createAttachDefaultDeps();
|
|
@@ -4095,7 +4257,15 @@ function buildMenuDeps() {
|
|
|
4095
4257
|
},
|
|
4096
4258
|
checkForUpdates: async () => {
|
|
4097
4259
|
console.log("Checking for updates...");
|
|
4098
|
-
const state = await detectDriftState(
|
|
4260
|
+
const state = await detectDriftState(
|
|
4261
|
+
workspaceName,
|
|
4262
|
+
{
|
|
4263
|
+
// Outside the Ink render loop console output is safe — surface
|
|
4264
|
+
// corrupt-config warnings from the image-drift probe here.
|
|
4265
|
+
detectImageDrift: (path) => detectImageDrift(path, { logger: { warn: (m) => console.warn(m) } })
|
|
4266
|
+
},
|
|
4267
|
+
{ forceRefresh: true }
|
|
4268
|
+
);
|
|
4099
4269
|
const current = getCurrentVersion();
|
|
4100
4270
|
if (state.packageMoved) {
|
|
4101
4271
|
console.log(
|
|
@@ -4105,10 +4275,18 @@ function buildMenuDeps() {
|
|
|
4105
4275
|
console.log(
|
|
4106
4276
|
`\x1B[33magent-env v${state.installedVersion} is installed \u2014 pick "Restart menu" to use it.\x1B[0m`
|
|
4107
4277
|
);
|
|
4108
|
-
} else if (state.updateMessage) {
|
|
4109
|
-
console.log(state.updateMessage);
|
|
4110
4278
|
} else {
|
|
4111
|
-
|
|
4279
|
+
if (state.updateMessage) {
|
|
4280
|
+
console.log(state.updateMessage);
|
|
4281
|
+
}
|
|
4282
|
+
if (state.imageDrift) {
|
|
4283
|
+
console.log(
|
|
4284
|
+
`\x1B[36mContainer image will refresh on next rebuild: ${state.imageDrift.configuredImage} \u2192 ${state.imageDrift.expectedImage}\x1B[0m`
|
|
4285
|
+
);
|
|
4286
|
+
}
|
|
4287
|
+
if (!state.updateMessage && !state.imageDrift) {
|
|
4288
|
+
console.log(`\x1B[32m\u2713\x1B[0m agent-env ${current} is up to date`);
|
|
4289
|
+
}
|
|
4112
4290
|
}
|
|
4113
4291
|
return { ok: true };
|
|
4114
4292
|
},
|
|
@@ -4158,7 +4336,7 @@ var onCommand = new Command7("on").description("Open the interactive menu for an
|
|
|
4158
4336
|
return;
|
|
4159
4337
|
}
|
|
4160
4338
|
const { workspaceName } = lookup;
|
|
4161
|
-
const menuDeps = buildMenuDeps();
|
|
4339
|
+
const menuDeps = buildMenuDeps(workspaceName);
|
|
4162
4340
|
await launchActionLoop(workspaceName, menuDeps, repoSlug);
|
|
4163
4341
|
});
|
|
4164
4342
|
|
|
@@ -4259,7 +4437,7 @@ function handleSetResult(result) {
|
|
|
4259
4437
|
// src/commands/rebuild.ts
|
|
4260
4438
|
import chalk2 from "chalk";
|
|
4261
4439
|
import { Command as Command10 } from "commander";
|
|
4262
|
-
var rebuildCommand = new Command10("rebuild").description("Rebuild an instance by recreating its container").argument("<name>", "Instance name to rebuild").option("--force", "Rebuild even if the container is currently running").option("--yes", "Skip confirmation prompt").option("--no-pull", "Skip pulling
|
|
4440
|
+
var rebuildCommand = new Command10("rebuild").description("Rebuild an instance by recreating its container").argument("<name>", "Instance name to rebuild").option("--force", "Rebuild even if the container is currently running").option("--yes", "Skip confirmation prompt").option("--no-pull", "Skip pulling the managed image and base images (use cached images)").option("--use-cache", "Allow Docker build layer cache reuse").option("--repo <slug>", "Repo slug or URL to scope instance lookup").action(
|
|
4263
4441
|
async (name, options) => {
|
|
4264
4442
|
const deps = createRebuildDefaultDeps();
|
|
4265
4443
|
const repoSlug = await resolveRepoOrExit({ repo: options.repo, cwd: process.cwd() });
|
|
@@ -4346,7 +4524,7 @@ function createAuditEntry(instanceName, gitState, confirmationMethod) {
|
|
|
4346
4524
|
}
|
|
4347
4525
|
|
|
4348
4526
|
// src/lib/remove-instance.ts
|
|
4349
|
-
import { mkdir as mkdir12, readdir as readdir9, readFile as
|
|
4527
|
+
import { mkdir as mkdir12, readdir as readdir9, readFile as readFile14, rm as rm4, stat as stat9 } from "fs/promises";
|
|
4350
4528
|
import { homedir as homedir11 } from "os";
|
|
4351
4529
|
function createRemoveDefaultDeps() {
|
|
4352
4530
|
const executor = createExecutor();
|
|
@@ -4355,7 +4533,7 @@ function createRemoveDefaultDeps() {
|
|
|
4355
4533
|
container: createContainerLifecycle(executor),
|
|
4356
4534
|
gitDetector: createGitStateDetector(executor),
|
|
4357
4535
|
workspaceFsDeps: { mkdir: mkdir12, readdir: readdir9, stat: stat9, homedir: homedir11 },
|
|
4358
|
-
stateFsDeps: { readFile:
|
|
4536
|
+
stateFsDeps: { readFile: readFile14 },
|
|
4359
4537
|
deleteFsDeps: { rm: rm4 }
|
|
4360
4538
|
};
|
|
4361
4539
|
}
|
|
@@ -4751,7 +4929,7 @@ var reposCommand = new Command12("repos").description("List tracked repositories
|
|
|
4751
4929
|
|
|
4752
4930
|
// src/commands/setup-audio.ts
|
|
4753
4931
|
import { Command as Command13 } from "commander";
|
|
4754
|
-
import { copyFile, mkdir as mkdir13, readFile as
|
|
4932
|
+
import { copyFile, mkdir as mkdir13, readFile as readFile15, writeFile as writeFile12, access as access6 } from "fs/promises";
|
|
4755
4933
|
import { homedir as homedir12, platform } from "os";
|
|
4756
4934
|
|
|
4757
4935
|
// src/lib/setup-audio.ts
|
|
@@ -4849,7 +5027,7 @@ function createDefaultSetupAudioDeps() {
|
|
|
4849
5027
|
platform: platform(),
|
|
4850
5028
|
homeDir: homedir12(),
|
|
4851
5029
|
execute: exec,
|
|
4852
|
-
readFile: (path, encoding) =>
|
|
5030
|
+
readFile: (path, encoding) => readFile15(path, encoding),
|
|
4853
5031
|
writeFile: (path, content, encoding) => writeFile12(path, content, encoding),
|
|
4854
5032
|
copyFile,
|
|
4855
5033
|
mkdir: (path, opts) => mkdir13(path, opts),
|
|
@@ -4917,11 +5095,11 @@ import { execSync } from "child_process";
|
|
|
4917
5095
|
import { join as join14 } from "path";
|
|
4918
5096
|
|
|
4919
5097
|
// src/lib/tmux-session.ts
|
|
4920
|
-
import { readFile as
|
|
5098
|
+
import { readFile as readFile16, writeFile as writeFile13, rename as rename9, mkdir as mkdir14 } from "fs/promises";
|
|
4921
5099
|
import { dirname as dirname4, join as join13 } from "path";
|
|
4922
5100
|
async function readPanesState(path) {
|
|
4923
5101
|
try {
|
|
4924
|
-
const content = await
|
|
5102
|
+
const content = await readFile16(path, "utf-8");
|
|
4925
5103
|
const parsed = JSON.parse(content);
|
|
4926
5104
|
if (typeof parsed === "object" && parsed !== null && parsed.version === 1) {
|
|
4927
5105
|
return parsed;
|
|
@@ -4939,7 +5117,7 @@ async function writePanesState(path, state) {
|
|
|
4939
5117
|
}
|
|
4940
5118
|
async function readSessionState(path) {
|
|
4941
5119
|
try {
|
|
4942
|
-
const content = await
|
|
5120
|
+
const content = await readFile16(path, "utf-8");
|
|
4943
5121
|
const parsed = JSON.parse(content);
|
|
4944
5122
|
if (typeof parsed === "object" && parsed !== null && parsed.version === 1 && Array.isArray(parsed.windows)) {
|
|
4945
5123
|
return parsed;
|
|
@@ -5127,9 +5305,9 @@ var tmuxSaveCommand = new Command16("tmux-save").description("Save current tmux
|
|
|
5127
5305
|
import { Command as Command17 } from "commander";
|
|
5128
5306
|
|
|
5129
5307
|
// src/lib/tmux-status.ts
|
|
5130
|
-
import { readFile as
|
|
5308
|
+
import { readFile as readFile17 } from "fs/promises";
|
|
5131
5309
|
var MAX_PURPOSE_DISPLAY_LEN = 40;
|
|
5132
|
-
var defaultDeps3 = { readFile:
|
|
5310
|
+
var defaultDeps3 = { readFile: readFile17 };
|
|
5133
5311
|
function formatTmuxStatus(instance, purpose) {
|
|
5134
5312
|
if (!instance) return "?";
|
|
5135
5313
|
if (!purpose) return instance;
|
|
@@ -5250,7 +5428,7 @@ program.action(async () => {
|
|
|
5250
5428
|
if (pickerResult.kind === "cancelled") {
|
|
5251
5429
|
return;
|
|
5252
5430
|
}
|
|
5253
|
-
const menuDeps = buildMenuDeps();
|
|
5431
|
+
const menuDeps = buildMenuDeps(pickerResult.name);
|
|
5254
5432
|
await launchActionLoop(pickerResult.name, menuDeps);
|
|
5255
5433
|
});
|
|
5256
5434
|
var shouldCheck = !!process.stderr.isTTY && !isInsideContainer() && !isLinked && !isBakedDev;
|