@pasko70/pibo 1.2.0 → 1.3.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/dist/apps/chat/static-assets.js +1 -1
- package/dist/apps/chat-vscode-web/assets/index-B5QK07zO.css +2 -0
- package/dist/apps/chat-vscode-web/assets/index-C3GTPyDo.js +41 -0
- package/dist/apps/chat-vscode-web/index.html +14 -0
- package/dist/apps/vscode-artifacts/latest.vsix +0 -0
- package/dist/apps/vscode-artifacts/pibo-vscode-1.3.0.vsix +0 -0
- package/dist/cli.js +17 -0
- package/dist/vscode/cli.js +90 -0
- package/dist/vscode/code-cli.js +119 -0
- package/dist/vscode/install.js +177 -0
- package/dist/vscode/status.js +80 -0
- package/dist/vscode/types.js +14 -0
- package/dist/vscode/uninstall.js +49 -0
- package/dist/vscode/vsix-fetcher.js +131 -0
- package/docs/ops/vscode-extension-release.md +138 -0
- package/package.json +5 -4
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="de" class="dark">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<meta name="theme-color" content="#101d22" />
|
|
7
|
+
<title>Pibo</title>
|
|
8
|
+
<script type="module" crossorigin src="/apps/chat-vscode/assets/index-C3GTPyDo.js"></script>
|
|
9
|
+
<link rel="stylesheet" crossorigin href="/apps/chat-vscode/assets/index-B5QK07zO.css">
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<div id="root"></div>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
Binary file
|
|
Binary file
|
package/dist/cli.js
CHANGED
|
@@ -97,6 +97,11 @@ export async function runPiboCli(argv = process.argv) {
|
|
|
97
97
|
await runRalphCli([argv[0] ?? "node", "pibo ralph", ...argv.slice(3)]);
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
|
+
if (argv[2] === "vscode") {
|
|
101
|
+
const { runVscodeCli } = await import("./vscode/cli.js");
|
|
102
|
+
await runVscodeCli([argv[0] ?? "node", "pibo vscode", ...argv.slice(3)]);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
100
105
|
if (argv[2] === "config" && (argv[3] === "--help" || argv[3] === "-h" || argv.length === 3)) {
|
|
101
106
|
printConfigDiscovery();
|
|
102
107
|
return;
|
|
@@ -218,6 +223,17 @@ export async function runPiboCli(argv = process.argv) {
|
|
|
218
223
|
const { runRalphCli } = await import("./ralph/cli.js");
|
|
219
224
|
await runRalphCli([argv[0] ?? "node", "pibo ralph", ...args]);
|
|
220
225
|
});
|
|
226
|
+
program
|
|
227
|
+
.command("vscode")
|
|
228
|
+
.description("Manage the Pibo VS Code extension")
|
|
229
|
+
.helpOption(false)
|
|
230
|
+
.allowUnknownOption(true)
|
|
231
|
+
.allowExcessArguments(true)
|
|
232
|
+
.argument("[args...]")
|
|
233
|
+
.action(async (args) => {
|
|
234
|
+
const { runVscodeCli } = await import("./vscode/cli.js");
|
|
235
|
+
await runVscodeCli([argv[0] ?? "node", "pibo vscode", ...args]);
|
|
236
|
+
});
|
|
221
237
|
const config = program.command("config").description(`Manage pibo config at ${getDefaultPiboConfigPath()}`).helpOption(false);
|
|
222
238
|
config.action(() => {
|
|
223
239
|
printConfigDiscovery();
|
|
@@ -365,6 +381,7 @@ Commands:
|
|
|
365
381
|
skills Manage Pibo user skills
|
|
366
382
|
cron Manage scheduled Pibo jobs
|
|
367
383
|
ralph Manage continuous Ralph jobs
|
|
384
|
+
vscode Manage the Pibo VS Code extension
|
|
368
385
|
profile Inspect a pibo profile
|
|
369
386
|
tui Start the direct Pi TUI
|
|
370
387
|
tui:routed Start the local routed Pibo TUI
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `pibo vscode` sub-command — manage the Pibo VS Code extension.
|
|
3
|
+
*
|
|
4
|
+
* Sub-commands:
|
|
5
|
+
* install Download and install the latest Pibo VS Code extension.
|
|
6
|
+
* uninstall Remove the installed Pibo VS Code extension.
|
|
7
|
+
* status Show whether the extension is installed and which CLI is used.
|
|
8
|
+
*/
|
|
9
|
+
import { Command } from "commander";
|
|
10
|
+
import { runInstall } from "./install.js";
|
|
11
|
+
import { runStatus, formatStatusText } from "./status.js";
|
|
12
|
+
import { runUninstall } from "./uninstall.js";
|
|
13
|
+
function printDiscovery() {
|
|
14
|
+
console.log(`pibo vscode
|
|
15
|
+
|
|
16
|
+
Manage the Pibo VS Code extension.
|
|
17
|
+
|
|
18
|
+
Commands:
|
|
19
|
+
install Download and install the latest Pibo VS Code extension
|
|
20
|
+
uninstall Remove the installed Pibo VS Code extension
|
|
21
|
+
status Show whether the extension is installed
|
|
22
|
+
|
|
23
|
+
Next: pibo vscode install --help`);
|
|
24
|
+
}
|
|
25
|
+
export async function runVscodeCli(argv = process.argv) {
|
|
26
|
+
const program = new Command();
|
|
27
|
+
program.name("pibo vscode").description("Manage the Pibo VS Code extension").helpOption("-h, --help");
|
|
28
|
+
program
|
|
29
|
+
.command("install")
|
|
30
|
+
.description("Download and install the Pibo VS Code extension")
|
|
31
|
+
.option("--version <tag>", "Pibo release tag to install (e.g., v1.3.0). Defaults to latest.")
|
|
32
|
+
.option("--vsix <path>", "Install from a local .vsix file instead of fetching a release")
|
|
33
|
+
.option("--from-url <url>", "Fetch a .vsix from the given URL (release tag will be inferred)")
|
|
34
|
+
.option("--owner <owner>", "GitHub owner for the release source", "Pascapone")
|
|
35
|
+
.option("--repo <repo>", "GitHub repo for the release source", "pibo")
|
|
36
|
+
.option("--no-cache", "Skip the VSIX download cache")
|
|
37
|
+
.option("--json", "Print JSON")
|
|
38
|
+
.action(async (options) => {
|
|
39
|
+
const result = await runInstall({
|
|
40
|
+
vsixPath: options.vsix,
|
|
41
|
+
fromUrl: options.fromUrl,
|
|
42
|
+
version: options.version,
|
|
43
|
+
owner: options.owner,
|
|
44
|
+
repo: options.repo,
|
|
45
|
+
skipCache: options.cache === false,
|
|
46
|
+
});
|
|
47
|
+
if (options.json) {
|
|
48
|
+
console.log(JSON.stringify(result, null, 2));
|
|
49
|
+
}
|
|
50
|
+
else if (result.status === "installed") {
|
|
51
|
+
console.log(`installed\t${result.tagName}\t${result.vsixPath}`);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
process.exitCode = 1;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
program
|
|
58
|
+
.command("uninstall")
|
|
59
|
+
.description("Remove the installed Pibo VS Code extension")
|
|
60
|
+
.option("--json", "Print JSON")
|
|
61
|
+
.action(async (options) => {
|
|
62
|
+
const result = await runUninstall();
|
|
63
|
+
if (options.json) {
|
|
64
|
+
console.log(JSON.stringify(result, null, 2));
|
|
65
|
+
}
|
|
66
|
+
else if (result.status !== "uninstalled") {
|
|
67
|
+
process.exitCode = 1;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
program
|
|
71
|
+
.command("status")
|
|
72
|
+
.description("Show the Pibo VS Code extension install status")
|
|
73
|
+
.option("--owner <owner>", "GitHub owner for the release source", "Pascapone")
|
|
74
|
+
.option("--repo <repo>", "GitHub repo for the release source", "pibo")
|
|
75
|
+
.option("--json", "Print JSON")
|
|
76
|
+
.action(async (options) => {
|
|
77
|
+
const status = await runStatus({ owner: options.owner, repo: options.repo });
|
|
78
|
+
if (options.json) {
|
|
79
|
+
console.log(JSON.stringify(status, null, 2));
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
console.log(formatStatusText(status));
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
if (argv.length <= 2 || argv.includes("--help") || argv.includes("-h")) {
|
|
86
|
+
printDiscovery();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
await program.parseAsync(argv);
|
|
90
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detection of the VS Code CLI binary and wrapper around it.
|
|
3
|
+
*
|
|
4
|
+
* The `code` binary is what VS Code installs on `$PATH` when the user enables
|
|
5
|
+
* "Shell Command: Install 'code' command in PATH" from the VS Code command
|
|
6
|
+
* palette. It is the only supported way for `pibo vscode install` to install
|
|
7
|
+
* the extension. If no supported binary is on `$PATH`, install fails with a
|
|
8
|
+
* clear error pointing at https://code.visualstudio.com/.
|
|
9
|
+
*/
|
|
10
|
+
import { spawn as defaultSpawn } from "node:child_process";
|
|
11
|
+
import { existsSync } from "node:fs";
|
|
12
|
+
import { delimiter, join } from "node:path";
|
|
13
|
+
export const SUPPORTED_CODE_BINARIES = ["code", "code-insiders", "codium"];
|
|
14
|
+
function splitPathEnv(pathValue) {
|
|
15
|
+
if (!pathValue)
|
|
16
|
+
return [];
|
|
17
|
+
return pathValue.split(delimiter).filter((entry) => entry.length > 0);
|
|
18
|
+
}
|
|
19
|
+
function firstExisting(candidates) {
|
|
20
|
+
for (const candidate of candidates) {
|
|
21
|
+
if (existsSync(candidate))
|
|
22
|
+
return candidate;
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
export function detectCodeBinary(options = {}) {
|
|
27
|
+
const pathValue = options.path ?? options.env?.PATH ?? process.env.PATH ?? "";
|
|
28
|
+
const directories = splitPathEnv(pathValue);
|
|
29
|
+
for (const binary of SUPPORTED_CODE_BINARIES) {
|
|
30
|
+
const candidates = directories.map((dir) => join(dir, binary));
|
|
31
|
+
const found = firstExisting(candidates);
|
|
32
|
+
if (found)
|
|
33
|
+
return { binary, path: found };
|
|
34
|
+
}
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
const COLLECT_BUFFER_LIMIT = 1024 * 1024; // 1 MiB
|
|
38
|
+
export function runCodeCommand(options) {
|
|
39
|
+
const spawnImpl = options.spawnImpl ?? defaultSpawn;
|
|
40
|
+
const env = options.env ?? process.env;
|
|
41
|
+
return new Promise((resolveInvocation, rejectInvocation) => {
|
|
42
|
+
let child;
|
|
43
|
+
try {
|
|
44
|
+
child = spawnImpl(options.binary, [...options.args], {
|
|
45
|
+
env,
|
|
46
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
rejectInvocation(error instanceof Error ? error : new Error(String(error)));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const stdoutChunks = [];
|
|
54
|
+
const stderrChunks = [];
|
|
55
|
+
let stdoutLength = 0;
|
|
56
|
+
let stderrLength = 0;
|
|
57
|
+
let timedOut = false;
|
|
58
|
+
const timeoutHandle = typeof options.timeoutMs === "number"
|
|
59
|
+
? setTimeout(() => {
|
|
60
|
+
timedOut = true;
|
|
61
|
+
child.kill("SIGKILL");
|
|
62
|
+
}, options.timeoutMs)
|
|
63
|
+
: null;
|
|
64
|
+
child.stdout?.on("data", (chunk) => {
|
|
65
|
+
stdoutLength += chunk.length;
|
|
66
|
+
if (stdoutLength <= COLLECT_BUFFER_LIMIT)
|
|
67
|
+
stdoutChunks.push(chunk);
|
|
68
|
+
});
|
|
69
|
+
child.stderr?.on("data", (chunk) => {
|
|
70
|
+
stderrLength += chunk.length;
|
|
71
|
+
if (stderrLength <= COLLECT_BUFFER_LIMIT)
|
|
72
|
+
stderrChunks.push(chunk);
|
|
73
|
+
});
|
|
74
|
+
child.on("error", (error) => {
|
|
75
|
+
if (timeoutHandle)
|
|
76
|
+
clearTimeout(timeoutHandle);
|
|
77
|
+
rejectInvocation(error);
|
|
78
|
+
});
|
|
79
|
+
child.on("close", (code) => {
|
|
80
|
+
if (timeoutHandle)
|
|
81
|
+
clearTimeout(timeoutHandle);
|
|
82
|
+
if (timedOut) {
|
|
83
|
+
rejectInvocation(new Error(`code command timed out after ${options.timeoutMs}ms`));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
resolveInvocation({
|
|
87
|
+
stdout: Buffer.concat(stdoutChunks).toString("utf8"),
|
|
88
|
+
stderr: Buffer.concat(stderrChunks).toString("utf8"),
|
|
89
|
+
exitCode: code ?? -1,
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
export async function listInstalledExtensions(options) {
|
|
95
|
+
const result = await runCodeCommand({
|
|
96
|
+
binary: options.binary,
|
|
97
|
+
args: ["--list-extensions", "--show-versions"],
|
|
98
|
+
spawnImpl: options.spawnImpl,
|
|
99
|
+
env: options.env,
|
|
100
|
+
timeoutMs: 30_000,
|
|
101
|
+
});
|
|
102
|
+
if (result.exitCode !== 0) {
|
|
103
|
+
throw new Error(`code --list-extensions failed: ${result.stderr || result.stdout || `exit ${result.exitCode}`}`);
|
|
104
|
+
}
|
|
105
|
+
const entries = [];
|
|
106
|
+
for (const rawLine of result.stdout.split(/\r?\n/)) {
|
|
107
|
+
const line = rawLine.trim();
|
|
108
|
+
if (!line)
|
|
109
|
+
continue;
|
|
110
|
+
const atIndex = line.lastIndexOf("@");
|
|
111
|
+
if (atIndex > 0) {
|
|
112
|
+
entries.push({ id: line.slice(0, atIndex), version: line.slice(atIndex + 1) });
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
entries.push({ id: line });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return entries;
|
|
119
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `pibo vscode install` — install the Pibo VS Code extension.
|
|
3
|
+
*
|
|
4
|
+
* Resolution order for the VSIX artifact:
|
|
5
|
+
* 1. `--vsix <path>` → use the local file directly
|
|
6
|
+
* 2. `--from-url <url>` → download from the given URL
|
|
7
|
+
* 3. default → fetch the latest GitHub Release for the repo and
|
|
8
|
+
* use its `.vsix` asset (optionally pinned by
|
|
9
|
+
* `--version <tag>`)
|
|
10
|
+
*
|
|
11
|
+
* The resolved VSIX is cached under `~/.pibo/vscode/cache/<tagName>/` so
|
|
12
|
+
* repeated installs do not re-download.
|
|
13
|
+
*/
|
|
14
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
15
|
+
import { homedir } from "node:os";
|
|
16
|
+
import { join, resolve } from "node:path";
|
|
17
|
+
import { detectCodeBinary, listInstalledExtensions, runCodeCommand } from "./code-cli.js";
|
|
18
|
+
import { downloadVsixAsset, fetchLatestVsix, isVsixAsset } from "./vsix-fetcher.js";
|
|
19
|
+
import { DEFAULT_GITHUB_OWNER, DEFAULT_GITHUB_REPO, PIBO_VSCODE_CACHE_DIR, PIBO_VSCODE_EXTENSION_ID, } from "./types.js";
|
|
20
|
+
import { findVsixAsset, fetchRelease } from "./vsix-fetcher.js";
|
|
21
|
+
const DEFAULT_LOG = (message) => {
|
|
22
|
+
console.log(message);
|
|
23
|
+
};
|
|
24
|
+
const DEFAULT_ERROR = (message) => {
|
|
25
|
+
process.stderr.write(`${message}\n`);
|
|
26
|
+
};
|
|
27
|
+
function getCacheDir(options) {
|
|
28
|
+
if (options.cacheDir)
|
|
29
|
+
return options.cacheDir;
|
|
30
|
+
const base = options.env?.PIBO_HOME ?? join(homedir(), ".pibo");
|
|
31
|
+
return join(base, PIBO_VSCODE_CACHE_DIR, "cache");
|
|
32
|
+
}
|
|
33
|
+
function cacheKeyForVersion(tagName) {
|
|
34
|
+
return tagName.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
35
|
+
}
|
|
36
|
+
function readCachedVsix(cacheDir, tagName) {
|
|
37
|
+
const dir = join(cacheDir, cacheKeyForVersion(tagName));
|
|
38
|
+
const path = join(dir, "pibo.vsix");
|
|
39
|
+
return existsSync(path) ? path : undefined;
|
|
40
|
+
}
|
|
41
|
+
function writeCachedVsix(cacheDir, tagName, bytes) {
|
|
42
|
+
const dir = join(cacheDir, cacheKeyForVersion(tagName));
|
|
43
|
+
mkdirSync(dir, { recursive: true });
|
|
44
|
+
const path = join(dir, "pibo.vsix");
|
|
45
|
+
writeFileSync(path, bytes);
|
|
46
|
+
return path;
|
|
47
|
+
}
|
|
48
|
+
function cachedTagManifestPath(cacheDir) {
|
|
49
|
+
return join(cacheDir, "last-installed.json");
|
|
50
|
+
}
|
|
51
|
+
function readCachedTagManifest(cacheDir) {
|
|
52
|
+
const path = cachedTagManifestPath(cacheDir);
|
|
53
|
+
if (!existsSync(path))
|
|
54
|
+
return undefined;
|
|
55
|
+
try {
|
|
56
|
+
const json = JSON.parse(readFileSync(path, "utf8"));
|
|
57
|
+
return json;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function writeCachedTagManifest(cacheDir, tagName, vsixPath) {
|
|
64
|
+
const path = cachedTagManifestPath(cacheDir);
|
|
65
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
66
|
+
writeFileSync(path, JSON.stringify({ tagName, vsixPath, installedAt: new Date().toISOString() }, null, 2));
|
|
67
|
+
}
|
|
68
|
+
export async function resolveVsixArtifact(options) {
|
|
69
|
+
if (options.vsixPath) {
|
|
70
|
+
const absolute = resolve(options.vsixPath);
|
|
71
|
+
if (!existsSync(absolute)) {
|
|
72
|
+
throw new Error(`VSIX file not found at ${absolute}`);
|
|
73
|
+
}
|
|
74
|
+
return { tagName: "local", vsixPath: absolute };
|
|
75
|
+
}
|
|
76
|
+
if (!options.skipCache && !options.version) {
|
|
77
|
+
const cachedTag = readCachedTagManifest(options.cacheDir);
|
|
78
|
+
if (cachedTag?.tagName && cachedTag.vsixPath && existsSync(cachedTag.vsixPath)) {
|
|
79
|
+
return { tagName: cachedTag.tagName, vsixPath: cachedTag.vsixPath };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (options.fromUrl) {
|
|
83
|
+
const release = await fetchRelease({ owner: options.owner, repo: options.repo, fetchImpl: options.fetchImpl });
|
|
84
|
+
const asset = findVsixAsset(release) ?? { name: "remote.vsix", browserDownloadUrl: options.fromUrl, size: 0, contentType: "application/octet-stream" };
|
|
85
|
+
const bytes = await downloadVsixAsset({ url: options.fromUrl, fetchImpl: options.fetchImpl });
|
|
86
|
+
const cachedPath = writeCachedVsix(options.cacheDir, release.tagName, bytes);
|
|
87
|
+
return { tagName: release.tagName, vsixPath: cachedPath, bytes };
|
|
88
|
+
}
|
|
89
|
+
const result = await fetchLatestVsix({
|
|
90
|
+
owner: options.owner,
|
|
91
|
+
repo: options.repo,
|
|
92
|
+
tagName: options.version,
|
|
93
|
+
fetchImpl: options.fetchImpl,
|
|
94
|
+
});
|
|
95
|
+
if (!options.skipCache) {
|
|
96
|
+
const cached = readCachedVsix(options.cacheDir, result.tagName);
|
|
97
|
+
if (cached)
|
|
98
|
+
return { tagName: result.tagName, vsixPath: cached };
|
|
99
|
+
}
|
|
100
|
+
const cachedPath = writeCachedVsix(options.cacheDir, result.tagName, result.bytes);
|
|
101
|
+
return { tagName: result.tagName, vsixPath: cachedPath, bytes: result.bytes };
|
|
102
|
+
}
|
|
103
|
+
export async function runInstall(options) {
|
|
104
|
+
const log = options.log ?? DEFAULT_LOG;
|
|
105
|
+
const errorLog = options.error ?? DEFAULT_ERROR;
|
|
106
|
+
const owner = options.owner ?? DEFAULT_GITHUB_OWNER;
|
|
107
|
+
const repo = options.repo ?? DEFAULT_GITHUB_REPO;
|
|
108
|
+
const cacheDir = getCacheDir(options);
|
|
109
|
+
const detected = detectCodeBinary({ env: options.env });
|
|
110
|
+
if (!detected) {
|
|
111
|
+
const message = `No VS Code CLI found on PATH. Install VS Code (https://code.visualstudio.com/) and run 'Shell Command: Install code command in PATH' from the VS Code command palette.`;
|
|
112
|
+
errorLog(message);
|
|
113
|
+
return { status: "failed", reason: "no-code-cli" };
|
|
114
|
+
}
|
|
115
|
+
let artifact;
|
|
116
|
+
try {
|
|
117
|
+
artifact = await resolveVsixArtifact({
|
|
118
|
+
vsixPath: options.vsixPath,
|
|
119
|
+
fromUrl: options.fromUrl,
|
|
120
|
+
version: options.version,
|
|
121
|
+
owner,
|
|
122
|
+
repo,
|
|
123
|
+
fetchImpl: options.fetchImpl,
|
|
124
|
+
cacheDir,
|
|
125
|
+
skipCache: options.skipCache,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
catch (fetchError) {
|
|
129
|
+
const reason = fetchError instanceof Error ? fetchError.message : String(fetchError);
|
|
130
|
+
errorLog(`Failed to obtain VSIX: ${reason}`);
|
|
131
|
+
return { status: "failed", reason };
|
|
132
|
+
}
|
|
133
|
+
log(`Installing pibo VS Code extension ${artifact.tagName} from ${artifact.vsixPath} via ${detected.path}…`);
|
|
134
|
+
let installResult;
|
|
135
|
+
try {
|
|
136
|
+
installResult = await runCodeCommand({
|
|
137
|
+
binary: detected.path,
|
|
138
|
+
args: ["--install-extension", artifact.vsixPath, "--force"],
|
|
139
|
+
spawnImpl: options.spawnImpl,
|
|
140
|
+
env: options.env,
|
|
141
|
+
timeoutMs: 120_000,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
catch (spawnError) {
|
|
145
|
+
const reason = spawnError instanceof Error ? spawnError.message : String(spawnError);
|
|
146
|
+
errorLog(`Failed to invoke ${detected.binary}: ${reason}`);
|
|
147
|
+
return { status: "failed", reason, codeBinary: detected.path, tagName: artifact.tagName };
|
|
148
|
+
}
|
|
149
|
+
if (installResult.exitCode !== 0) {
|
|
150
|
+
const reason = `code --install-extension exited with code ${installResult.exitCode}: ${installResult.stderr || installResult.stdout}`;
|
|
151
|
+
errorLog(reason);
|
|
152
|
+
return { status: "failed", reason, codeBinary: detected.path, tagName: artifact.tagName };
|
|
153
|
+
}
|
|
154
|
+
writeCachedTagManifest(cacheDir, artifact.tagName, artifact.vsixPath);
|
|
155
|
+
try {
|
|
156
|
+
const installed = await listInstalledExtensions({
|
|
157
|
+
binary: detected.path,
|
|
158
|
+
spawnImpl: options.spawnImpl,
|
|
159
|
+
env: options.env,
|
|
160
|
+
});
|
|
161
|
+
const ours = installed.find((entry) => entry.id === PIBO_VSCODE_EXTENSION_ID);
|
|
162
|
+
if (ours) {
|
|
163
|
+
log(`Installed ${ours.id}@${ours.version ?? "?"} via ${detected.path}`);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
log(`code --install-extension reported success but ${PIBO_VSCODE_EXTENSION_ID} is not in the installed list.`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
catch (listError) {
|
|
170
|
+
// Listing the installed extensions is a best-effort check; do not fail the install on a listing error.
|
|
171
|
+
const reason = listError instanceof Error ? listError.message : String(listError);
|
|
172
|
+
log(`Install completed; failed to verify via --list-extensions: ${reason}`);
|
|
173
|
+
}
|
|
174
|
+
return { status: "installed", tagName: artifact.tagName, vsixPath: artifact.vsixPath, codeBinary: detected.path };
|
|
175
|
+
}
|
|
176
|
+
// Re-export for symmetry with code-cli.ts consumers.
|
|
177
|
+
export { isVsixAsset };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `pibo vscode status` — report whether the Pibo VS Code extension is
|
|
3
|
+
* installed, the local VS Code CLI binary, and the cached VSIX artifacts.
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
6
|
+
import { homedir } from "node:os";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { detectCodeBinary, listInstalledExtensions } from "./code-cli.js";
|
|
9
|
+
import { fetchRelease } from "./vsix-fetcher.js";
|
|
10
|
+
import { DEFAULT_GITHUB_OWNER, DEFAULT_GITHUB_REPO, PIBO_VSCODE_CACHE_DIR, PIBO_VSCODE_EXTENSION_ID, } from "./types.js";
|
|
11
|
+
function getCacheDir(options) {
|
|
12
|
+
if (options.cacheDir)
|
|
13
|
+
return options.cacheDir;
|
|
14
|
+
const base = options.env?.PIBO_HOME ?? join(homedir(), ".pibo");
|
|
15
|
+
return join(base, PIBO_VSCODE_CACHE_DIR, "cache");
|
|
16
|
+
}
|
|
17
|
+
function listCachedReleases(cacheDir, limit) {
|
|
18
|
+
if (!existsSync(cacheDir))
|
|
19
|
+
return [];
|
|
20
|
+
const entries = readdirSync(cacheDir, { withFileTypes: true })
|
|
21
|
+
.filter((entry) => entry.isDirectory() && entry.name !== "node_modules")
|
|
22
|
+
.map((entry) => ({ name: entry.name, mtimeMs: statSync(join(cacheDir, entry.name)).mtimeMs }))
|
|
23
|
+
.sort((a, b) => b.mtimeMs - a.mtimeMs)
|
|
24
|
+
.slice(0, limit)
|
|
25
|
+
.map((entry) => entry.name);
|
|
26
|
+
return entries;
|
|
27
|
+
}
|
|
28
|
+
export async function runStatus(options = {}) {
|
|
29
|
+
const owner = options.owner ?? DEFAULT_GITHUB_OWNER;
|
|
30
|
+
const repo = options.repo ?? DEFAULT_GITHUB_REPO;
|
|
31
|
+
const cacheDir = getCacheDir(options);
|
|
32
|
+
const limit = options.limit ?? 5;
|
|
33
|
+
const detected = detectCodeBinary({ env: options.env });
|
|
34
|
+
let installed = false;
|
|
35
|
+
let version;
|
|
36
|
+
if (detected) {
|
|
37
|
+
try {
|
|
38
|
+
const installedExtensions = await listInstalledExtensions({
|
|
39
|
+
binary: detected.path,
|
|
40
|
+
spawnImpl: options.spawnImpl,
|
|
41
|
+
env: options.env,
|
|
42
|
+
});
|
|
43
|
+
const ours = installedExtensions.find((entry) => entry.id === PIBO_VSCODE_EXTENSION_ID);
|
|
44
|
+
if (ours) {
|
|
45
|
+
installed = true;
|
|
46
|
+
version = ours.version;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// Listing failed; treat as not-installed for status purposes.
|
|
51
|
+
installed = false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const cachedReleases = listCachedReleases(cacheDir, limit);
|
|
55
|
+
let availableReleases = [];
|
|
56
|
+
try {
|
|
57
|
+
const release = await fetchRelease({ owner, repo, fetchImpl: options.fetchImpl });
|
|
58
|
+
availableReleases = [release.tagName];
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// Network failure is non-fatal for status.
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
installed,
|
|
65
|
+
version,
|
|
66
|
+
codeBinary: detected?.path,
|
|
67
|
+
vsixCacheDir: cacheDir,
|
|
68
|
+
availableReleases,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export function formatStatusText(status) {
|
|
72
|
+
const lines = [];
|
|
73
|
+
lines.push(`extension: ${status.installed ? `${PIBO_VSCODE_EXTENSION_ID}@${status.version ?? "?"}` : "not installed"}`);
|
|
74
|
+
lines.push(`code binary: ${status.codeBinary ?? "(not on PATH)"}`);
|
|
75
|
+
lines.push(`vsix cache: ${status.vsixCacheDir}`);
|
|
76
|
+
if (status.availableReleases.length > 0) {
|
|
77
|
+
lines.push(`latest release: ${status.availableReleases[0]}`);
|
|
78
|
+
}
|
|
79
|
+
return lines.join("\n");
|
|
80
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types and constants for the `pibo vscode` sub-command.
|
|
3
|
+
*
|
|
4
|
+
* The pibo VS Code extension is a thin VS Code client that opens a WebView
|
|
5
|
+
* pointing at the gateway-served chat-vscode-web app. The extension itself
|
|
6
|
+
* ships as a `.vsix` artifact, published to the VS Code Marketplace and
|
|
7
|
+
* mirrored on GitHub Releases.
|
|
8
|
+
*/
|
|
9
|
+
export const PIBO_VSCODE_EXTENSION_PUBLISHER = "pibo";
|
|
10
|
+
export const PIBO_VSCODE_EXTENSION_NAME = "pibo-vscode";
|
|
11
|
+
export const PIBO_VSCODE_EXTENSION_ID = `${PIBO_VSCODE_EXTENSION_PUBLISHER}.${PIBO_VSCODE_EXTENSION_NAME}`;
|
|
12
|
+
export const DEFAULT_GITHUB_OWNER = "Pascapone";
|
|
13
|
+
export const DEFAULT_GITHUB_REPO = "pibo";
|
|
14
|
+
export const PIBO_VSCODE_CACHE_DIR = "vscode";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `pibo vscode uninstall` — remove the installed Pibo VS Code extension.
|
|
3
|
+
*/
|
|
4
|
+
import { detectCodeBinary, runCodeCommand } from "./code-cli.js";
|
|
5
|
+
import { PIBO_VSCODE_EXTENSION_ID } from "./types.js";
|
|
6
|
+
const DEFAULT_LOG = (message) => {
|
|
7
|
+
console.log(message);
|
|
8
|
+
};
|
|
9
|
+
const DEFAULT_ERROR = (message) => {
|
|
10
|
+
process.stderr.write(`${message}\n`);
|
|
11
|
+
};
|
|
12
|
+
export async function runUninstall(options = {}) {
|
|
13
|
+
const log = options.log ?? DEFAULT_LOG;
|
|
14
|
+
const errorLog = options.error ?? DEFAULT_ERROR;
|
|
15
|
+
const detected = detectCodeBinary({ env: options.env });
|
|
16
|
+
if (!detected) {
|
|
17
|
+
errorLog(`No VS Code CLI found on PATH.`);
|
|
18
|
+
return { status: "failed", reason: "no-code-cli" };
|
|
19
|
+
}
|
|
20
|
+
log(`Uninstalling ${PIBO_VSCODE_EXTENSION_ID} via ${detected.path}…`);
|
|
21
|
+
let result;
|
|
22
|
+
try {
|
|
23
|
+
result = await runCodeCommand({
|
|
24
|
+
binary: detected.path,
|
|
25
|
+
args: ["--uninstall-extension", PIBO_VSCODE_EXTENSION_ID],
|
|
26
|
+
spawnImpl: options.spawnImpl,
|
|
27
|
+
env: options.env,
|
|
28
|
+
timeoutMs: 60_000,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
catch (spawnError) {
|
|
32
|
+
const reason = spawnError instanceof Error ? spawnError.message : String(spawnError);
|
|
33
|
+
errorLog(`Failed to invoke ${detected.binary}: ${reason}`);
|
|
34
|
+
return { status: "failed", reason, codeBinary: detected.path };
|
|
35
|
+
}
|
|
36
|
+
if (result.exitCode !== 0) {
|
|
37
|
+
const stderr = result.stderr || result.stdout;
|
|
38
|
+
// VS Code returns a non-zero exit when the extension is not installed; treat that as "not-installed".
|
|
39
|
+
if (/not found|not installed|Cannot find extension/i.test(stderr)) {
|
|
40
|
+
log(`${PIBO_VSCODE_EXTENSION_ID} was not installed.`);
|
|
41
|
+
return { status: "not-installed", codeBinary: detected.path };
|
|
42
|
+
}
|
|
43
|
+
const reason = `code --uninstall-extension exited with code ${result.exitCode}: ${stderr}`;
|
|
44
|
+
errorLog(reason);
|
|
45
|
+
return { status: "failed", reason, codeBinary: detected.path };
|
|
46
|
+
}
|
|
47
|
+
log(`Uninstalled ${PIBO_VSCODE_EXTENSION_ID}`);
|
|
48
|
+
return { status: "uninstalled", codeBinary: detected.path };
|
|
49
|
+
}
|