@vecteur/cli 0.8.0 → 0.9.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/README.md +125 -0
- package/bin/vecteur.js +71 -19
- package/package.json +23 -3
- package/src/blocks.js +40 -0
- package/src/browser.js +18 -0
- package/src/client.js +216 -81
- package/src/commands.js +161 -0
- package/src/contract.js +18 -1
- package/src/credentials.js +56 -63
- package/src/diagnostics.js +39 -0
- package/src/download.js +33 -2
- package/src/folders.js +270 -0
- package/src/format.js +39 -29
- package/src/input.js +148 -0
- package/src/markdown.js +226 -0
- package/src/preferences.js +29 -0
- package/src/session.js +689 -0
- package/src/store.js +82 -0
- package/src/terminal.js +335 -0
- package/src/tui/view.js +319 -0
- package/src/update.js +313 -0
- package/src/vendors.js +44 -0
package/src/vendors.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
import { CliError } from "./errors.js";
|
|
6
|
+
import { shellQuote } from "./format.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Stage-2 bridge to the user's own generalist CLI, through the existing `vecteur mcp` server only.
|
|
10
|
+
* The vendor binary is unmodified and keeps its own login and billing; Vecteur never reads its
|
|
11
|
+
* credentials. Setup is the vendor's own `mcp add`; a handoff passes a per-invocation MCP
|
|
12
|
+
* configuration and changes no persistent vendor configuration.
|
|
13
|
+
*/
|
|
14
|
+
export const VENDORS = Object.freeze({ claude: "Claude Code", codex: "Codex" });
|
|
15
|
+
|
|
16
|
+
/** The exact installed launcher for a one-off handoff; the PATH launcher survives updates for setup. */
|
|
17
|
+
export function executingServer() {
|
|
18
|
+
return { command: process.execPath, args: [realpathSync(fileURLToPath(new URL("../bin/vecteur.js", import.meta.url))), "mcp"] };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function vendorArgv(vendor, mode, server = { command: "vecteur", args: ["mcp"] }) {
|
|
22
|
+
if (!Object.hasOwn(VENDORS, vendor)) throw new CliError("usage_invalid", "Choose claude or codex");
|
|
23
|
+
if (vendor === "claude") return mode === "setup"
|
|
24
|
+
? ["claude", "mcp", "add", "--scope", "user", "vecteur", "--", server.command, ...server.args]
|
|
25
|
+
: ["claude", "--mcp-config", JSON.stringify({ mcpServers: { vecteur: { type: "stdio", ...server } } })];
|
|
26
|
+
return mode === "setup" ? ["codex", "mcp", "add", "vecteur", "--", server.command, ...server.args]
|
|
27
|
+
: ["codex", "-c", `mcp_servers.vecteur.command=${JSON.stringify(server.command)}`,
|
|
28
|
+
"-c", `mcp_servers.vecteur.args=${JSON.stringify(server.args)}`];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const shellLine = argv => argv.map(part => /^[\w@%+=:,./-]+$/.test(part) ? part : shellQuote(part)).join(" ");
|
|
32
|
+
|
|
33
|
+
/** Run the vendor in this terminal; resolve with its exit code. A missing binary is a typed refusal. */
|
|
34
|
+
export function runVendor(argv, env = process.env) {
|
|
35
|
+
// Ctrl+C belongs to the vendor while it owns the terminal; this process only waits.
|
|
36
|
+
const ignore = () => {}; process.on("SIGINT", ignore);
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
const child = spawn(argv[0], argv.slice(1), { stdio: "inherit", env });
|
|
39
|
+
child.once("error", error => reject(error?.code === "ENOENT"
|
|
40
|
+
? new CliError("vendor_unavailable", `${argv[0]} is not installed or not on PATH. Install ${VENDORS[argv[0]]}, sign in with it, then run:\n ${shellLine(argv)}`)
|
|
41
|
+
: new CliError("vendor_failed", `${argv[0]} could not start: ${error?.code ?? "spawn failed"}`)));
|
|
42
|
+
child.once("exit", (code, signal) => resolve(code ?? (signal ? 1 : 0)));
|
|
43
|
+
}).finally(() => process.off("SIGINT", ignore));
|
|
44
|
+
}
|