opencode-docker-panel 0.4.8 → 0.5.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/CHANGELOG.md +69 -44
- package/README.md +30 -137
- package/README.ru.md +12 -129
- package/dist/commands.js +8 -6
- package/dist/compose.js +34 -12
- package/dist/docker.js +26 -6
- package/dist/logs.js +3 -5
- package/dist/panel.js +225 -110
- package/dist/poll.js +67 -7
- package/dist/runtime.js +67 -0
- package/dist/tui.js +2 -2
- package/package.json +76 -76
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
const COMMAND = "docker";
|
|
3
|
+
/**
|
|
4
|
+
* Measured with Docker Desktop stopped on this machine: three runs took 3497, 4439 and 4453 ms.
|
|
5
|
+
* The CLI plugin spends those seconds waiting on a named pipe that is not answering, so a four second
|
|
6
|
+
* timeout like the `docker ps` one kills the call and turns a provable `stopped` into `unknown`,
|
|
7
|
+
* which hides the Start button. Nine seconds clears the measured worst case with room to spare.
|
|
8
|
+
*/
|
|
9
|
+
const TIMEOUT_MS = 9000;
|
|
10
|
+
const MAX_BUFFER = 1024 * 1024;
|
|
11
|
+
/**
|
|
12
|
+
* `docker desktop status` has no output contract for the stopped case: it exits 1 and writes the
|
|
13
|
+
* reason to stderr, so the state comes from the exit code plus the wording rather than from a value.
|
|
14
|
+
*
|
|
15
|
+
* Measured on Docker Desktop CLI plugin v0.2.0, stopped: exit 1, stderr
|
|
16
|
+
* `Could not retrieve status. Is Docker Desktop running?`, stdout `You can start Docker Desktop by
|
|
17
|
+
* running 'docker desktop start'.`. The stdout half is the independent half: it asserts the engine is
|
|
18
|
+
* down and names the command, where the stderr half only asks a question.
|
|
19
|
+
* Measured with an unknown flag on the same build: exit 125, which is docker's own code for a command
|
|
20
|
+
* or flag it does not know, so the code alone cannot tell stopped from missing. `docker desktop engine ls`
|
|
21
|
+
* also exits 1 when the engine is down, but says `unable to retrieve the engine list`, so exit 1 alone
|
|
22
|
+
* would be wrong and the wording is what makes the state provable.
|
|
23
|
+
*/
|
|
24
|
+
export function parseDesktopStatus(code, stdout, stderr) {
|
|
25
|
+
const text = `${stdout}\n${stderr}`.toLowerCase();
|
|
26
|
+
// Both wordings are real: older docker says `is not a docker command`, this build says `unknown command`
|
|
27
|
+
if (text.includes("is not a docker command") || text.includes("unknown command")) return "absent";
|
|
28
|
+
if (code === 0) return "running";
|
|
29
|
+
// Exit 1 alone is not enough, `docker desktop engine ls` shares it. Both wordings name the engine as
|
|
30
|
+
// down, so either one plus the code makes the state provable rather than inferred
|
|
31
|
+
if (code === 1 && (text.includes("is docker desktop running") || text.includes("you can start docker desktop"))) {
|
|
32
|
+
return "stopped";
|
|
33
|
+
}
|
|
34
|
+
return "unknown";
|
|
35
|
+
}
|
|
36
|
+
export const ENGINE_TIMEOUT_MS = TIMEOUT_MS;
|
|
37
|
+
export function runDesktopStatus(timeoutMs = TIMEOUT_MS) {
|
|
38
|
+
return new Promise(resolve => {
|
|
39
|
+
execFile(COMMAND, ["desktop", "status"], {
|
|
40
|
+
timeout: timeoutMs,
|
|
41
|
+
windowsHide: true,
|
|
42
|
+
maxBuffer: MAX_BUFFER
|
|
43
|
+
}, (error, stdout, stderr) => {
|
|
44
|
+
if (!error) {
|
|
45
|
+
resolve("running");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const killed = error.killed === true;
|
|
49
|
+
if (killed) {
|
|
50
|
+
resolve("unknown");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const failure = error;
|
|
54
|
+
const code = failure.code === "ENOENT" ? null : failure.code ?? null;
|
|
55
|
+
resolve(parseDesktopStatus(typeof code === "number" ? code : null, String(stdout), String(stderr)));
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** An app-level stop kills every container of every project, so it needs a confirmation the container actions do not */
|
|
61
|
+
export function buildRuntimeArgs(action) {
|
|
62
|
+
return ["desktop", action === "engine-start" ? "start" : "stop"];
|
|
63
|
+
}
|
|
64
|
+
export const ENGINE_ACTION_LABEL = {
|
|
65
|
+
"engine-start": "Start Docker Desktop",
|
|
66
|
+
"engine-stop": "Stop Docker Desktop"
|
|
67
|
+
};
|
package/dist/tui.js
CHANGED
|
@@ -15,7 +15,7 @@ const plugin = {
|
|
|
15
15
|
});
|
|
16
16
|
let dispose;
|
|
17
17
|
|
|
18
|
-
/** Durable storage is the host's own, so a pin outlives the TUI without this plugin owning
|
|
18
|
+
/** Durable storage is the host's own, so a pin outlives the TUI without this plugin owning a user file */
|
|
19
19
|
async function togglePin(name) {
|
|
20
20
|
await setPinned(draft => {
|
|
21
21
|
const index = draft.names.indexOf(name);
|
|
@@ -23,7 +23,7 @@ const plugin = {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/** Drops the
|
|
26
|
+
/** Drops the claim and registers it again, the only way to make the host paint the slot anew */
|
|
27
27
|
function reload() {
|
|
28
28
|
queueMicrotask(() => {
|
|
29
29
|
dispose?.();
|
package/package.json
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "opencode-docker-panel",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Docker container panel for the OpenCode 2 TUI sidebar",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"opencode",
|
|
7
|
-
"opencode-plugin",
|
|
8
|
-
"opencode-tui",
|
|
9
|
-
"docker",
|
|
10
|
-
"docker-compose",
|
|
11
|
-
"sidebar",
|
|
12
|
-
"tui"
|
|
13
|
-
],
|
|
14
|
-
"homepage": "https://github.com/victor-ochenin/opencodeDockerPlugin#readme",
|
|
15
|
-
"bugs": {
|
|
16
|
-
"url": "https://github.com/victor-ochenin/opencodeDockerPlugin/issues"
|
|
17
|
-
},
|
|
18
|
-
"repository": {
|
|
19
|
-
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/victor-ochenin/opencodeDockerPlugin.git",
|
|
21
|
-
"directory": "."
|
|
22
|
-
},
|
|
23
|
-
"type": "module",
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"exports": {
|
|
26
|
-
"./tui": "./dist/tui.js"
|
|
27
|
-
},
|
|
28
|
-
"files": [
|
|
29
|
-
"dist",
|
|
30
|
-
"README.md",
|
|
31
|
-
"CHANGELOG.md",
|
|
32
|
-
"LICENSE"
|
|
33
|
-
],
|
|
34
|
-
"scripts": {
|
|
35
|
-
"build": "node --experimental-strip-types scripts/build.ts",
|
|
36
|
-
"check": "node --experimental-strip-types scripts/check-parser.ts",
|
|
37
|
-
"typecheck": "tsc --noEmit",
|
|
38
|
-
"check-build": "node --experimental-strip-types scripts/check-build.ts"
|
|
39
|
-
},
|
|
40
|
-
"peerDependencies": {
|
|
41
|
-
"@opencode/plugin": "^2.0.20",
|
|
42
|
-
"@opencode/theme": "^2.0.20",
|
|
43
|
-
"@opentui/core": ">=0.5.8",
|
|
44
|
-
"@opentui/solid": ">=0.5.8",
|
|
45
|
-
"solid-js": "^1.9.0"
|
|
46
|
-
},
|
|
47
|
-
"peerDependenciesMeta": {
|
|
48
|
-
"@opencode/plugin": {
|
|
49
|
-
"optional": true
|
|
50
|
-
},
|
|
51
|
-
"@opencode/theme": {
|
|
52
|
-
"optional": true
|
|
53
|
-
},
|
|
54
|
-
"@opentui/core": {
|
|
55
|
-
"optional": true
|
|
56
|
-
},
|
|
57
|
-
"@opentui/solid": {
|
|
58
|
-
"optional": true
|
|
59
|
-
},
|
|
60
|
-
"solid-js": {
|
|
61
|
-
"optional": true
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
"devDependencies": {
|
|
65
|
-
"@babel/core": "^7.28.0",
|
|
66
|
-
"@babel/preset-typescript": "^7.27.1",
|
|
67
|
-
"@opencode/plugin": "^2.0.20",
|
|
68
|
-
"@opencode/theme": "^2.0.20",
|
|
69
|
-
"@opentui/core": "0.5.12",
|
|
70
|
-
"@opentui/solid": "0.5.12",
|
|
71
|
-
"@types/babel__core": "^7.20.5",
|
|
72
|
-
"babel-preset-solid": "^1.9.12",
|
|
73
|
-
"solid-js": "1.9.12",
|
|
74
|
-
"typescript": "^5.9.2"
|
|
75
|
-
}
|
|
76
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "opencode-docker-panel",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Docker container panel for the OpenCode 2 TUI sidebar",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"opencode",
|
|
7
|
+
"opencode-plugin",
|
|
8
|
+
"opencode-tui",
|
|
9
|
+
"docker",
|
|
10
|
+
"docker-compose",
|
|
11
|
+
"sidebar",
|
|
12
|
+
"tui"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/victor-ochenin/opencodeDockerPlugin#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/victor-ochenin/opencodeDockerPlugin/issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/victor-ochenin/opencodeDockerPlugin.git",
|
|
21
|
+
"directory": "."
|
|
22
|
+
},
|
|
23
|
+
"type": "module",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"exports": {
|
|
26
|
+
"./tui": "./dist/tui.js"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"README.md",
|
|
31
|
+
"CHANGELOG.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "node --experimental-strip-types scripts/build.ts",
|
|
36
|
+
"check": "node --experimental-strip-types scripts/check-parser.ts",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"check-build": "node --experimental-strip-types scripts/check-build.ts"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@opencode/plugin": "^2.0.20",
|
|
42
|
+
"@opencode/theme": "^2.0.20",
|
|
43
|
+
"@opentui/core": ">=0.5.8",
|
|
44
|
+
"@opentui/solid": ">=0.5.8",
|
|
45
|
+
"solid-js": "^1.9.0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependenciesMeta": {
|
|
48
|
+
"@opencode/plugin": {
|
|
49
|
+
"optional": true
|
|
50
|
+
},
|
|
51
|
+
"@opencode/theme": {
|
|
52
|
+
"optional": true
|
|
53
|
+
},
|
|
54
|
+
"@opentui/core": {
|
|
55
|
+
"optional": true
|
|
56
|
+
},
|
|
57
|
+
"@opentui/solid": {
|
|
58
|
+
"optional": true
|
|
59
|
+
},
|
|
60
|
+
"solid-js": {
|
|
61
|
+
"optional": true
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@babel/core": "^7.28.0",
|
|
66
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
67
|
+
"@opencode/plugin": "^2.0.20",
|
|
68
|
+
"@opencode/theme": "^2.0.20",
|
|
69
|
+
"@opentui/core": "0.5.12",
|
|
70
|
+
"@opentui/solid": "0.5.12",
|
|
71
|
+
"@types/babel__core": "^7.20.5",
|
|
72
|
+
"babel-preset-solid": "^1.9.12",
|
|
73
|
+
"solid-js": "1.9.12",
|
|
74
|
+
"typescript": "^5.9.2"
|
|
75
|
+
}
|
|
76
|
+
}
|