@the-librarian/cli 1.0.0-rc.3
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 +94 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +15 -0
- package/dist/bin.js.map +1 -0
- package/dist/commands/install.d.ts +22 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +152 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/shared.d.ts +16 -0
- package/dist/commands/shared.d.ts.map +1 -0
- package/dist/commands/shared.js +30 -0
- package/dist/commands/shared.js.map +1 -0
- package/dist/commands/uninstall.d.ts +18 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +67 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/commands/update.d.ts +21 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +75 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/config.d.ts +40 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +65 -0
- package/dist/config.js.map +1 -0
- package/dist/doctor.d.ts +23 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +81 -0
- package/dist/doctor.js.map +1 -0
- package/dist/env.d.ts +39 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +208 -0
- package/dist/env.js.map +1 -0
- package/dist/exec.d.ts +37 -0
- package/dist/exec.d.ts.map +1 -0
- package/dist/exec.js +81 -0
- package/dist/exec.js.map +1 -0
- package/dist/harnesses/claude.d.ts +3 -0
- package/dist/harnesses/claude.d.ts.map +1 -0
- package/dist/harnesses/claude.js +88 -0
- package/dist/harnesses/claude.js.map +1 -0
- package/dist/harnesses/cli.d.ts +4 -0
- package/dist/harnesses/cli.d.ts.map +1 -0
- package/dist/harnesses/cli.js +16 -0
- package/dist/harnesses/cli.js.map +1 -0
- package/dist/harnesses/codex.d.ts +3 -0
- package/dist/harnesses/codex.d.ts.map +1 -0
- package/dist/harnesses/codex.js +183 -0
- package/dist/harnesses/codex.js.map +1 -0
- package/dist/harnesses/hermes.d.ts +16 -0
- package/dist/harnesses/hermes.d.ts.map +1 -0
- package/dist/harnesses/hermes.js +154 -0
- package/dist/harnesses/hermes.js.map +1 -0
- package/dist/harnesses/index.d.ts +12 -0
- package/dist/harnesses/index.d.ts.map +1 -0
- package/dist/harnesses/index.js +29 -0
- package/dist/harnesses/index.js.map +1 -0
- package/dist/harnesses/opencode.d.ts +3 -0
- package/dist/harnesses/opencode.d.ts.map +1 -0
- package/dist/harnesses/opencode.js +141 -0
- package/dist/harnesses/opencode.js.map +1 -0
- package/dist/harnesses/pi.d.ts +3 -0
- package/dist/harnesses/pi.d.ts.map +1 -0
- package/dist/harnesses/pi.js +72 -0
- package/dist/harnesses/pi.js.map +1 -0
- package/dist/harnesses/types.d.ts +48 -0
- package/dist/harnesses/types.d.ts.map +1 -0
- package/dist/harnesses/types.js +22 -0
- package/dist/harnesses/types.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/machine.d.ts +10 -0
- package/dist/machine.d.ts.map +1 -0
- package/dist/machine.js +39 -0
- package/dist/machine.js.map +1 -0
- package/dist/parse-args.d.ts +12 -0
- package/dist/parse-args.d.ts.map +1 -0
- package/dist/parse-args.js +54 -0
- package/dist/parse-args.js.map +1 -0
- package/dist/paths.d.ts +32 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +75 -0
- package/dist/paths.js.map +1 -0
- package/dist/prompt.d.ts +46 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +115 -0
- package/dist/prompt.js.map +1 -0
- package/dist/runtime.d.ts +25 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +169 -0
- package/dist/runtime.js.map +1 -0
- package/dist/semver.d.ts +13 -0
- package/dist/semver.d.ts.map +1 -0
- package/dist/semver.js +98 -0
- package/dist/semver.js.map +1 -0
- package/dist/status.d.ts +18 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +113 -0
- package/dist/status.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +20 -0
- package/dist/version.js.map +1 -0
- package/package.json +37 -0
package/dist/config.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Config core: MCP URL, agent token, and derived server URL.
|
|
2
|
+
//
|
|
3
|
+
// The persisted truth is `~/.librarian/env` (token + MCP URL). The
|
|
4
|
+
// server URL is *derived* by default — it's the origin of the MCP URL —
|
|
5
|
+
// but can be set explicitly. Reading config never exposes the token: the
|
|
6
|
+
// redacted view reports only whether it's *set*, never the value.
|
|
7
|
+
//
|
|
8
|
+
// `home` is injectable everywhere so tests run against a temp dir.
|
|
9
|
+
import { detectShell, readEnvFile, writeEnvFile } from "./env.js";
|
|
10
|
+
import { applyShellBlock } from "./env.js";
|
|
11
|
+
/** Derive the server base URL (origin) from the MCP URL; "" if unparseable. */
|
|
12
|
+
export function deriveServerUrl(mcpUrl) {
|
|
13
|
+
if (!mcpUrl)
|
|
14
|
+
return "";
|
|
15
|
+
try {
|
|
16
|
+
return new URL(mcpUrl).origin;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return "";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** Load the current config from `~/.librarian/env`, or null if unset. */
|
|
23
|
+
export function readConfig(home) {
|
|
24
|
+
const env = readEnvFile(home);
|
|
25
|
+
if (!env)
|
|
26
|
+
return null;
|
|
27
|
+
return {
|
|
28
|
+
mcpUrl: env.mcpUrl,
|
|
29
|
+
token: env.token,
|
|
30
|
+
serverUrl: deriveServerUrl(env.mcpUrl),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** A display-safe view: the token is reduced to a boolean, never printed. */
|
|
34
|
+
export function redact(config) {
|
|
35
|
+
return {
|
|
36
|
+
mcpUrl: config.mcpUrl,
|
|
37
|
+
tokenSet: config.token.length > 0,
|
|
38
|
+
serverUrl: config.serverUrl,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** Render the redacted config as human-readable lines (no token value). */
|
|
42
|
+
export function formatConfig(config) {
|
|
43
|
+
return [
|
|
44
|
+
`MCP URL: ${config.mcpUrl || "(not set)"}`,
|
|
45
|
+
`Server URL: ${config.serverUrl || "(not set)"}`,
|
|
46
|
+
`Token: ${config.tokenSet ? "set (hidden)" : "(not set)"}`,
|
|
47
|
+
].join("\n");
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Update config values and persist them to `~/.librarian/env`.
|
|
51
|
+
*
|
|
52
|
+
* Merges over whatever is already stored (so setting just the token
|
|
53
|
+
* keeps the URL). Re-applies the managed shell block so a fresh `config`
|
|
54
|
+
* on a new shell still wires up sourcing. Returns the new config.
|
|
55
|
+
*/
|
|
56
|
+
export function setConfig(input, options = {}) {
|
|
57
|
+
const current = readEnvFile(options.home);
|
|
58
|
+
const mcpUrl = input.mcpUrl ?? current?.mcpUrl ?? "";
|
|
59
|
+
const token = input.token ?? current?.token ?? "";
|
|
60
|
+
writeEnvFile({ mcpUrl, token }, options.home);
|
|
61
|
+
const shell = options.shell ?? detectShell();
|
|
62
|
+
applyShellBlock(shell, { mcpUrl, token }, options.home);
|
|
63
|
+
return { mcpUrl, token, serverUrl: deriveServerUrl(mcpUrl) };
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,EAAE;AACF,mEAAmE;AACnE,wEAAwE;AACxE,yEAAyE;AACzE,kEAAkE;AAClE,EAAE;AACF,mEAAmE;AAEnE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAc,MAAM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E,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,OAAO,EAAE,MAAM,IAAI,EAAE,CAAC;IACrD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC;IAClD,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,WAAW,EAAE,CAAC;IAC7C,eAAe,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;AAC/D,CAAC"}
|
package/dist/doctor.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Outcome of a server-reachability probe. */
|
|
2
|
+
export interface ProbeResult {
|
|
3
|
+
ok: boolean;
|
|
4
|
+
/** A short human detail: the status code, or why it failed. */
|
|
5
|
+
detail: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Probe whether the configured server is reachable. INJECTABLE so tests never
|
|
9
|
+
* hit the network; OFFLINE-TOLERANT so a down server is a flagged problem, not
|
|
10
|
+
* a crash. The token is never sent here — this is an unauthenticated liveness
|
|
11
|
+
* check against public endpoints.
|
|
12
|
+
*/
|
|
13
|
+
export type ServerProbe = (serverUrl: string) => Promise<ProbeResult>;
|
|
14
|
+
/** Override the server-reachability probe (tests inject a canned one). */
|
|
15
|
+
export declare function setServerProbe(next: ServerProbe): void;
|
|
16
|
+
/** Restore the default (network) server probe (tests). */
|
|
17
|
+
export declare function resetServerProbe(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Run the diagnostic and render its report. `home` is injectable for tests.
|
|
20
|
+
* Always resolves (never rejects); the caller exits 0 regardless.
|
|
21
|
+
*/
|
|
22
|
+
export declare function doctor(home?: string): Promise<string>;
|
|
23
|
+
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAeA,8CAA8C;AAC9C,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,OAAO,CAAC;IACZ,+DAA+D;IAC/D,MAAM,EAAE,MAAM,CAAC;CAChB;AAMD;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AAwBtE,0EAA0E;AAC1E,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAEtD;AAED,0DAA0D;AAC1D,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAED;;;GAGG;AACH,wBAAsB,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAyC3D"}
|
package/dist/doctor.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// `librarian doctor` — a read-only diagnostic. Exits 0 ALWAYS (it's a
|
|
2
|
+
// report, not a gate), but clearly flags each problem it finds:
|
|
3
|
+
// - is the agent token set? (from `readConfig`; shown only as set/not — the
|
|
4
|
+
// value is NEVER printed);
|
|
5
|
+
// - is the server reachable? (a GET against `<serverUrl>/healthz`, falling
|
|
6
|
+
// back to `/primer.md`; INJECTABLE + offline-tolerant);
|
|
7
|
+
// - which harness CLIs are on PATH? (`which` from exec.ts);
|
|
8
|
+
// - the machine id + hostname (the dashboard's row key).
|
|
9
|
+
import { readConfig } from "./config.js";
|
|
10
|
+
import { which } from "./exec.js";
|
|
11
|
+
import { HARNESS_CLI } from "./harnesses/cli.js";
|
|
12
|
+
import { allHarnesses } from "./harnesses/index.js";
|
|
13
|
+
import { hostname, machineId } from "./machine.js";
|
|
14
|
+
/** The probe paths we try, in order, against the server origin. */
|
|
15
|
+
const PROBE_PATHS = ["/healthz", "/primer.md"];
|
|
16
|
+
const PROBE_TIMEOUT_MS = 3000;
|
|
17
|
+
const defaultServerProbe = async (serverUrl) => {
|
|
18
|
+
if (!serverUrl)
|
|
19
|
+
return { ok: false, detail: "no server URL configured" };
|
|
20
|
+
let lastDetail = "unreachable";
|
|
21
|
+
for (const probePath of PROBE_PATHS) {
|
|
22
|
+
const controller = new AbortController();
|
|
23
|
+
const timer = setTimeout(() => controller.abort(), PROBE_TIMEOUT_MS);
|
|
24
|
+
try {
|
|
25
|
+
const url = `${serverUrl.replace(/\/+$/, "")}${probePath}`;
|
|
26
|
+
const res = await fetch(url, { method: "GET", redirect: "error", signal: controller.signal });
|
|
27
|
+
if (res.ok)
|
|
28
|
+
return { ok: true, detail: `HTTP ${res.status} ${probePath}` };
|
|
29
|
+
lastDetail = `HTTP ${res.status} ${probePath}`;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
lastDetail = error instanceof Error ? error.message : "unreachable";
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
clearTimeout(timer);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return { ok: false, detail: lastDetail };
|
|
39
|
+
};
|
|
40
|
+
let serverProbe = defaultServerProbe;
|
|
41
|
+
/** Override the server-reachability probe (tests inject a canned one). */
|
|
42
|
+
export function setServerProbe(next) {
|
|
43
|
+
serverProbe = next;
|
|
44
|
+
}
|
|
45
|
+
/** Restore the default (network) server probe (tests). */
|
|
46
|
+
export function resetServerProbe() {
|
|
47
|
+
serverProbe = defaultServerProbe;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Run the diagnostic and render its report. `home` is injectable for tests.
|
|
51
|
+
* Always resolves (never rejects); the caller exits 0 regardless.
|
|
52
|
+
*/
|
|
53
|
+
export async function doctor(home) {
|
|
54
|
+
const cfg = readConfig(home);
|
|
55
|
+
const lines = ["librarian doctor", ""];
|
|
56
|
+
// 1) Token + URL config (token shown only as set/not — never the value).
|
|
57
|
+
const tokenSet = Boolean(cfg && cfg.token.length > 0);
|
|
58
|
+
lines.push(`Token: ${tokenSet ? "set" : "NOT SET — run `librarian config --token <token>`"}`);
|
|
59
|
+
lines.push(`MCP URL: ${cfg?.mcpUrl || "NOT SET — run `librarian config --mcp-url <url>`"}`);
|
|
60
|
+
lines.push(`Server URL: ${cfg?.serverUrl || "(not set)"}`);
|
|
61
|
+
// 2) Server reachability (injectable + offline-tolerant).
|
|
62
|
+
const probe = await serverProbe(cfg?.serverUrl ?? "");
|
|
63
|
+
lines.push(`Server: ${probe.ok ? `reachable (${probe.detail})` : `UNREACHABLE — ${probe.detail}`}`);
|
|
64
|
+
// 3) Harness CLIs on PATH.
|
|
65
|
+
lines.push("", "Harness CLIs on PATH:");
|
|
66
|
+
for (const harness of allHarnesses) {
|
|
67
|
+
const cli = HARNESS_CLI[harness.id];
|
|
68
|
+
if (cli === null) {
|
|
69
|
+
lines.push(` ${harness.displayName}: file-based (no CLI)`);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const found = await which(cli);
|
|
73
|
+
lines.push(` ${harness.displayName}: ${found ? `\`${cli}\` found` : `\`${cli}\` NOT on PATH`}`);
|
|
74
|
+
}
|
|
75
|
+
// 4) Machine identity.
|
|
76
|
+
lines.push("", `Machine id: ${machineId(home)}`, `Hostname: ${hostname()}`);
|
|
77
|
+
const problems = !tokenSet || !cfg?.mcpUrl || !probe.ok;
|
|
78
|
+
lines.push("", problems ? "Some checks need attention (see lines flagged above)." : "All checks passed.");
|
|
79
|
+
return lines.join("\n");
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=doctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAAA,s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,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** The secrets the env file carries. */
|
|
2
|
+
export interface EnvValues {
|
|
3
|
+
mcpUrl: string;
|
|
4
|
+
token: string;
|
|
5
|
+
}
|
|
6
|
+
export type Shell = "bash" | "zsh" | "fish";
|
|
7
|
+
/**
|
|
8
|
+
* Detect the user's shell from `$SHELL`, defaulting to bash.
|
|
9
|
+
*
|
|
10
|
+
* `override` (e.g. from a `--shell` flag) wins when it names a supported
|
|
11
|
+
* shell. An unrecognised `$SHELL` falls back to bash — the POSIX block
|
|
12
|
+
* is the safe default.
|
|
13
|
+
*/
|
|
14
|
+
export declare function detectShell(override?: string, env?: NodeJS.ProcessEnv): Shell;
|
|
15
|
+
/**
|
|
16
|
+
* Write `~/.librarian/env` with the two exports, chmod 600.
|
|
17
|
+
*
|
|
18
|
+
* The directory is created if missing; the file is (re)written wholesale
|
|
19
|
+
* so stale values can't linger. Never logs `values.token`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function writeEnvFile(values: EnvValues, home?: string): void;
|
|
22
|
+
/** Read the env file back into structured values, or null if absent. */
|
|
23
|
+
export declare function readEnvFile(home?: string): EnvValues | null;
|
|
24
|
+
/**
|
|
25
|
+
* Apply (or replace) the managed block in the shell rc.
|
|
26
|
+
*
|
|
27
|
+
* For bash/zsh this writes the POSIX source-block into `~/.bashrc` or
|
|
28
|
+
* `~/.zshrc`. For fish it writes `~/.config/fish/conf.d/librarian.fish`
|
|
29
|
+
* with `set -gx` reading the values directly (fish can't source POSIX).
|
|
30
|
+
*
|
|
31
|
+
* Idempotent: a second call with the rc already containing a block
|
|
32
|
+
* replaces it in place — never appends a duplicate.
|
|
33
|
+
*
|
|
34
|
+
* Returns the path that was written.
|
|
35
|
+
*/
|
|
36
|
+
export declare function applyShellBlock(shell: Shell, values: EnvValues, home?: string): string;
|
|
37
|
+
/** Remove the managed block from the shell rc (or delete the fish conf). */
|
|
38
|
+
export declare function removeShellBlock(shell: Shell, home?: string): void;
|
|
39
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAsBA,wCAAwC;AACxC,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;AAW5C;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,KAAK,CAU1F;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAanE;AAED,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAW3D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAQtF;AAED,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAclE"}
|
package/dist/env.js
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// Env-var plumbing: `~/.librarian/env` + the managed shell-rc block.
|
|
2
|
+
//
|
|
3
|
+
// The token and MCP URL never land in a committed or world-readable rc.
|
|
4
|
+
// We write them to `~/.librarian/env` (chmod 600) and add ONE idempotent
|
|
5
|
+
// managed block to the user's shell rc that sources it:
|
|
6
|
+
//
|
|
7
|
+
// # >>> librarian >>>
|
|
8
|
+
// [ -f "$HOME/.librarian/env" ] && . "$HOME/.librarian/env"
|
|
9
|
+
// # <<< librarian <<<
|
|
10
|
+
//
|
|
11
|
+
// Re-running REPLACES the block (matched on the sentinels) — never
|
|
12
|
+
// duplicates. Fish can't source a POSIX env file, so it gets a native
|
|
13
|
+
// `~/.config/fish/conf.d/librarian.fish` with `set -gx` reading the same
|
|
14
|
+
// values. The token is never logged.
|
|
15
|
+
//
|
|
16
|
+
// Every function takes an injectable `home` so tests run against a temp
|
|
17
|
+
// dir; nothing here touches the real `~`.
|
|
18
|
+
import fs from "node:fs";
|
|
19
|
+
import path from "node:path";
|
|
20
|
+
import { bashRcPath, envFilePath, fishConfPath, librarianDir, zshRcPath } from "./paths.js";
|
|
21
|
+
// The exact sentinels the spec pins. The block is matched on these so a
|
|
22
|
+
// re-run replaces it rather than appending a duplicate. Do not reword.
|
|
23
|
+
const BLOCK_OPEN = "# >>> librarian >>>";
|
|
24
|
+
const BLOCK_CLOSE = "# <<< librarian <<<";
|
|
25
|
+
const POSIX_SOURCE_LINE = '[ -f "$HOME/.librarian/env" ] && . "$HOME/.librarian/env"';
|
|
26
|
+
const FISH_OPEN = "# >>> librarian >>>";
|
|
27
|
+
const FISH_CLOSE = "# <<< librarian <<<";
|
|
28
|
+
/**
|
|
29
|
+
* Detect the user's shell from `$SHELL`, defaulting to bash.
|
|
30
|
+
*
|
|
31
|
+
* `override` (e.g. from a `--shell` flag) wins when it names a supported
|
|
32
|
+
* shell. An unrecognised `$SHELL` falls back to bash — the POSIX block
|
|
33
|
+
* is the safe default.
|
|
34
|
+
*/
|
|
35
|
+
export function detectShell(override, env = process.env) {
|
|
36
|
+
const pick = (value) => {
|
|
37
|
+
if (!value)
|
|
38
|
+
return undefined;
|
|
39
|
+
const base = value.toLowerCase();
|
|
40
|
+
if (base.includes("fish"))
|
|
41
|
+
return "fish";
|
|
42
|
+
if (base.includes("zsh"))
|
|
43
|
+
return "zsh";
|
|
44
|
+
if (base.includes("bash"))
|
|
45
|
+
return "bash";
|
|
46
|
+
return undefined;
|
|
47
|
+
};
|
|
48
|
+
return pick(override) ?? pick(env.SHELL) ?? "bash";
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Write `~/.librarian/env` with the two exports, chmod 600.
|
|
52
|
+
*
|
|
53
|
+
* The directory is created if missing; the file is (re)written wholesale
|
|
54
|
+
* so stale values can't linger. Never logs `values.token`.
|
|
55
|
+
*/
|
|
56
|
+
export function writeEnvFile(values, home) {
|
|
57
|
+
const dir = librarianDir(home);
|
|
58
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
59
|
+
const body = [
|
|
60
|
+
`export LIBRARIAN_MCP_URL=${shellQuote(values.mcpUrl)}`,
|
|
61
|
+
`export LIBRARIAN_AGENT_TOKEN=${shellQuote(values.token)}`,
|
|
62
|
+
"",
|
|
63
|
+
].join("\n");
|
|
64
|
+
const file = envFilePath(home);
|
|
65
|
+
fs.writeFileSync(file, body, { encoding: "utf8", mode: 0o600 });
|
|
66
|
+
// writeFileSync only applies `mode` on create; chmod unconditionally so a
|
|
67
|
+
// pre-existing looser file is tightened.
|
|
68
|
+
fs.chmodSync(file, 0o600);
|
|
69
|
+
}
|
|
70
|
+
/** Read the env file back into structured values, or null if absent. */
|
|
71
|
+
export function readEnvFile(home) {
|
|
72
|
+
let raw;
|
|
73
|
+
try {
|
|
74
|
+
raw = fs.readFileSync(envFilePath(home), "utf8");
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const mcpUrl = parseExport(raw, "LIBRARIAN_MCP_URL");
|
|
80
|
+
const token = parseExport(raw, "LIBRARIAN_AGENT_TOKEN");
|
|
81
|
+
if (mcpUrl === undefined && token === undefined)
|
|
82
|
+
return null;
|
|
83
|
+
return { mcpUrl: mcpUrl ?? "", token: token ?? "" };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Apply (or replace) the managed block in the shell rc.
|
|
87
|
+
*
|
|
88
|
+
* For bash/zsh this writes the POSIX source-block into `~/.bashrc` or
|
|
89
|
+
* `~/.zshrc`. For fish it writes `~/.config/fish/conf.d/librarian.fish`
|
|
90
|
+
* with `set -gx` reading the values directly (fish can't source POSIX).
|
|
91
|
+
*
|
|
92
|
+
* Idempotent: a second call with the rc already containing a block
|
|
93
|
+
* replaces it in place — never appends a duplicate.
|
|
94
|
+
*
|
|
95
|
+
* Returns the path that was written.
|
|
96
|
+
*/
|
|
97
|
+
export function applyShellBlock(shell, values, home) {
|
|
98
|
+
if (shell === "fish")
|
|
99
|
+
return writeFishConf(values, home);
|
|
100
|
+
const rcPath = shell === "zsh" ? zshRcPath(home) : bashRcPath(home);
|
|
101
|
+
const block = [BLOCK_OPEN, POSIX_SOURCE_LINE, BLOCK_CLOSE].join("\n");
|
|
102
|
+
const next = upsertBlock(readFileOrEmpty(rcPath), block);
|
|
103
|
+
fs.mkdirSync(path.dirname(rcPath), { recursive: true });
|
|
104
|
+
fs.writeFileSync(rcPath, next, { encoding: "utf8" });
|
|
105
|
+
return rcPath;
|
|
106
|
+
}
|
|
107
|
+
/** Remove the managed block from the shell rc (or delete the fish conf). */
|
|
108
|
+
export function removeShellBlock(shell, home) {
|
|
109
|
+
if (shell === "fish") {
|
|
110
|
+
try {
|
|
111
|
+
fs.rmSync(fishConfPath(home));
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
// already gone
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const rcPath = shell === "zsh" ? zshRcPath(home) : bashRcPath(home);
|
|
119
|
+
const current = readFileOrEmpty(rcPath);
|
|
120
|
+
if (!current)
|
|
121
|
+
return;
|
|
122
|
+
const stripped = stripBlock(current);
|
|
123
|
+
if (stripped !== current)
|
|
124
|
+
fs.writeFileSync(rcPath, stripped, { encoding: "utf8" });
|
|
125
|
+
}
|
|
126
|
+
function writeFishConf(values, home) {
|
|
127
|
+
const confPath = fishConfPath(home);
|
|
128
|
+
const body = [
|
|
129
|
+
FISH_OPEN,
|
|
130
|
+
`set -gx LIBRARIAN_MCP_URL ${fishQuote(values.mcpUrl)}`,
|
|
131
|
+
`set -gx LIBRARIAN_AGENT_TOKEN ${fishQuote(values.token)}`,
|
|
132
|
+
FISH_CLOSE,
|
|
133
|
+
"",
|
|
134
|
+
].join("\n");
|
|
135
|
+
fs.mkdirSync(path.dirname(confPath), { recursive: true });
|
|
136
|
+
// The fish conf carries the token directly, so tighten it to 600 too.
|
|
137
|
+
fs.writeFileSync(confPath, body, { encoding: "utf8", mode: 0o600 });
|
|
138
|
+
fs.chmodSync(confPath, 0o600);
|
|
139
|
+
return confPath;
|
|
140
|
+
}
|
|
141
|
+
// --- block manipulation (sentinel-matched, idempotent) -------------------
|
|
142
|
+
/** Replace an existing sentinel block, or append a fresh one. */
|
|
143
|
+
function upsertBlock(content, block) {
|
|
144
|
+
const stripped = stripBlock(content);
|
|
145
|
+
const base = stripped.length === 0 || stripped.endsWith("\n") ? stripped : `${stripped}\n`;
|
|
146
|
+
return `${base}${block}\n`;
|
|
147
|
+
}
|
|
148
|
+
/** Remove a sentinel-delimited block (and its surrounding blank lines). */
|
|
149
|
+
function stripBlock(content) {
|
|
150
|
+
const lines = content.split("\n");
|
|
151
|
+
const start = lines.findIndex((line) => line.trim() === BLOCK_OPEN);
|
|
152
|
+
if (start === -1)
|
|
153
|
+
return content;
|
|
154
|
+
let end = -1;
|
|
155
|
+
for (let i = start + 1; i < lines.length; i += 1) {
|
|
156
|
+
if (lines[i]?.trim() === BLOCK_CLOSE) {
|
|
157
|
+
end = i;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (end === -1)
|
|
162
|
+
return content; // unterminated — leave it alone
|
|
163
|
+
const before = lines.slice(0, start);
|
|
164
|
+
const after = lines.slice(end + 1);
|
|
165
|
+
// Drop a single trailing blank line left by the block so repeated
|
|
166
|
+
// apply/strip cycles don't accumulate whitespace.
|
|
167
|
+
while (before.length > 0 && before[before.length - 1] === "")
|
|
168
|
+
before.pop();
|
|
169
|
+
while (after.length > 0 && after[0] === "")
|
|
170
|
+
after.shift();
|
|
171
|
+
const joined = [...before, ...after].join("\n");
|
|
172
|
+
return joined;
|
|
173
|
+
}
|
|
174
|
+
// --- small helpers -------------------------------------------------------
|
|
175
|
+
function readFileOrEmpty(file) {
|
|
176
|
+
try {
|
|
177
|
+
return fs.readFileSync(file, "utf8");
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
return "";
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function parseExport(raw, name) {
|
|
184
|
+
// Matches `export NAME=value` (value optionally single/double quoted).
|
|
185
|
+
const re = new RegExp(`^\\s*export\\s+${name}=(.*)$`, "m");
|
|
186
|
+
const match = re.exec(raw);
|
|
187
|
+
if (!match)
|
|
188
|
+
return undefined;
|
|
189
|
+
return unquote((match[1] ?? "").trim());
|
|
190
|
+
}
|
|
191
|
+
/** POSIX single-quote a value so the env file is robust to special chars. */
|
|
192
|
+
function shellQuote(value) {
|
|
193
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
194
|
+
}
|
|
195
|
+
/** Fish single-quote a value (fish escapes `\` and `'` inside single quotes). */
|
|
196
|
+
function fishQuote(value) {
|
|
197
|
+
return `'${value.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
|
|
198
|
+
}
|
|
199
|
+
function unquote(value) {
|
|
200
|
+
if (value.length >= 2 && value.startsWith("'") && value.endsWith("'")) {
|
|
201
|
+
return value.slice(1, -1).replace(/'\\''/g, "'");
|
|
202
|
+
}
|
|
203
|
+
if (value.length >= 2 && value.startsWith('"') && value.endsWith('"')) {
|
|
204
|
+
return value.slice(1, -1);
|
|
205
|
+
}
|
|
206
|
+
return value;
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=env.js.map
|
package/dist/env.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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,EAAE,GAAG,CAAC,CAAC;IACnD,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACtE,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/exec.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** The result of running a command: captured streams + exit code. */
|
|
2
|
+
export interface RunResult {
|
|
3
|
+
stdout: string;
|
|
4
|
+
stderr: string;
|
|
5
|
+
/** The process exit code; `null` only if the process was signalled. */
|
|
6
|
+
code: number | null;
|
|
7
|
+
}
|
|
8
|
+
/** Options for a single command run. */
|
|
9
|
+
export interface RunOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Extra environment for the child. Merged over `process.env`. The token
|
|
12
|
+
* rides here (per a harness's native env-var mechanism) — it is passed
|
|
13
|
+
* to the child but never logged by this module.
|
|
14
|
+
*/
|
|
15
|
+
env?: Record<string, string | undefined> | undefined;
|
|
16
|
+
/** Working directory for the child. */
|
|
17
|
+
cwd?: string | undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The runner surface every harness depends on. The default implementation
|
|
21
|
+
* spawns real processes; tests inject a fake that records calls.
|
|
22
|
+
*/
|
|
23
|
+
export interface Runner {
|
|
24
|
+
/** Run `cmd args…`, resolving with captured streams + exit code. */
|
|
25
|
+
run(cmd: string, args: readonly string[], opts?: RunOptions): Promise<RunResult>;
|
|
26
|
+
/** Resolve `cmd` to its absolute path on PATH, or `null` if absent. */
|
|
27
|
+
which(cmd: string): Promise<string | null>;
|
|
28
|
+
}
|
|
29
|
+
/** Run a command through the current runner. */
|
|
30
|
+
export declare function run(cmd: string, args: readonly string[], opts?: RunOptions): Promise<RunResult>;
|
|
31
|
+
/** Resolve a command to its PATH location through the current runner. */
|
|
32
|
+
export declare function which(cmd: string): Promise<string | null>;
|
|
33
|
+
/** Swap in a fake runner (tests). Returns the previous runner. */
|
|
34
|
+
export declare function setRunner(runner: Runner): Runner;
|
|
35
|
+
/** Restore the real, process-spawning runner (tests). */
|
|
36
|
+
export declare function resetRunner(): void;
|
|
37
|
+
//# sourceMappingURL=exec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../src/exec.ts"],"names":[],"mappings":"AAkBA,qEAAqE;AACrE,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,wCAAwC;AACxC,MAAM,WAAW,UAAU;IACzB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;IACrD,uCAAuC;IACvC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,oEAAoE;IACpE,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IACjF,uEAAuE;IACvE,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC5C;AAmDD,gDAAgD;AAChD,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAE/F;AAED,yEAAyE;AACzE,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAEzD;AAED,kEAAkE;AAClE,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED,yDAAyD;AACzD,wBAAgB,WAAW,IAAI,IAAI,CAElC"}
|
package/dist/exec.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Injectable child-process runner.
|
|
2
|
+
//
|
|
3
|
+
// Every harness that drives a native CLI (`claude`, `codex`, `pi`) goes
|
|
4
|
+
// through this module rather than calling `node:child_process` directly,
|
|
5
|
+
// so tests can stub the runner and assert the exact command + args a
|
|
6
|
+
// harness invokes — WITHOUT spawning real processes or touching PATH.
|
|
7
|
+
//
|
|
8
|
+
// Security (spec §9): a command may *carry* the agent token (e.g. via an
|
|
9
|
+
// env var its native mechanism reads), but the token is NEVER logged,
|
|
10
|
+
// echoed, or placed where this module would print it. The runner returns
|
|
11
|
+
// stdout/stderr to the caller; it deliberately does not log them.
|
|
12
|
+
//
|
|
13
|
+
// Stubbing: `setRunner()` swaps the module-level default for a fake in
|
|
14
|
+
// tests; `resetRunner()` restores the real one. `run`/`which` always go
|
|
15
|
+
// through the current runner, so a single override covers both.
|
|
16
|
+
import { spawn } from "node:child_process";
|
|
17
|
+
// --- the real, process-spawning runner -----------------------------------
|
|
18
|
+
const realRunner = {
|
|
19
|
+
run(cmd, args, opts = {}) {
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
const child = spawn(cmd, [...args], {
|
|
22
|
+
cwd: opts.cwd,
|
|
23
|
+
env: opts.env ? { ...process.env, ...opts.env } : process.env,
|
|
24
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
25
|
+
});
|
|
26
|
+
let stdout = "";
|
|
27
|
+
let stderr = "";
|
|
28
|
+
child.stdout?.on("data", (chunk) => {
|
|
29
|
+
stdout += chunk.toString("utf8");
|
|
30
|
+
});
|
|
31
|
+
child.stderr?.on("data", (chunk) => {
|
|
32
|
+
stderr += chunk.toString("utf8");
|
|
33
|
+
});
|
|
34
|
+
// ENOENT (binary not on PATH) surfaces here, not as a non-zero exit.
|
|
35
|
+
child.on("error", reject);
|
|
36
|
+
child.on("close", (code) => {
|
|
37
|
+
resolve({ stdout, stderr, code });
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
async which(cmd) {
|
|
42
|
+
// Use the platform's own resolver so PATHEXT etc. are honoured. A
|
|
43
|
+
// non-zero exit (not found) resolves to null; we never throw.
|
|
44
|
+
const probe = process.platform === "win32" ? "where" : "which";
|
|
45
|
+
try {
|
|
46
|
+
const { stdout, code } = await realRunner.run(probe, [cmd]);
|
|
47
|
+
if (code !== 0)
|
|
48
|
+
return null;
|
|
49
|
+
const first = stdout
|
|
50
|
+
.split("\n")
|
|
51
|
+
.map((l) => l.trim())
|
|
52
|
+
.find((l) => l.length > 0);
|
|
53
|
+
return first ?? null;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// `which`/`where` itself missing, or some other spawn failure.
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
// --- the swappable module-level runner -----------------------------------
|
|
62
|
+
let current = realRunner;
|
|
63
|
+
/** Run a command through the current runner. */
|
|
64
|
+
export function run(cmd, args, opts) {
|
|
65
|
+
return current.run(cmd, args, opts);
|
|
66
|
+
}
|
|
67
|
+
/** Resolve a command to its PATH location through the current runner. */
|
|
68
|
+
export function which(cmd) {
|
|
69
|
+
return current.which(cmd);
|
|
70
|
+
}
|
|
71
|
+
/** Swap in a fake runner (tests). Returns the previous runner. */
|
|
72
|
+
export function setRunner(runner) {
|
|
73
|
+
const prev = current;
|
|
74
|
+
current = runner;
|
|
75
|
+
return prev;
|
|
76
|
+
}
|
|
77
|
+
/** Restore the real, process-spawning runner (tests). */
|
|
78
|
+
export function resetRunner() {
|
|
79
|
+
current = realRunner;
|
|
80
|
+
}
|
|
81
|
+
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