@the-librarian/cli 1.0.0-rc.21
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/LICENSE +201 -0
- 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 +28 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +204 -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 +158 -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 +53 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +165 -0
- package/dist/prompt.js.map +1 -0
- package/dist/runtime.d.ts +45 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +370 -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/server/admin.d.ts +31 -0
- package/dist/server/admin.d.ts.map +1 -0
- package/dist/server/admin.js +110 -0
- package/dist/server/admin.js.map +1 -0
- package/dist/server/boot.d.ts +51 -0
- package/dist/server/boot.d.ts.map +1 -0
- package/dist/server/boot.js +233 -0
- package/dist/server/boot.js.map +1 -0
- package/dist/server/deploy-state.d.ts +33 -0
- package/dist/server/deploy-state.d.ts.map +1 -0
- package/dist/server/deploy-state.js +79 -0
- package/dist/server/deploy-state.js.map +1 -0
- package/dist/server/docker.d.ts +37 -0
- package/dist/server/docker.d.ts.map +1 -0
- package/dist/server/docker.js +138 -0
- package/dist/server/docker.js.map +1 -0
- package/dist/server/down.d.ts +19 -0
- package/dist/server/down.d.ts.map +1 -0
- package/dist/server/down.js +62 -0
- package/dist/server/down.js.map +1 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +48 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/logs.d.ts +50 -0
- package/dist/server/logs.d.ts.map +1 -0
- package/dist/server/logs.js +162 -0
- package/dist/server/logs.js.map +1 -0
- package/dist/server/preflight.d.ts +24 -0
- package/dist/server/preflight.d.ts.map +1 -0
- package/dist/server/preflight.js +58 -0
- package/dist/server/preflight.js.map +1 -0
- package/dist/server/redact.d.ts +2 -0
- package/dist/server/redact.d.ts.map +1 -0
- package/dist/server/redact.js +26 -0
- package/dist/server/redact.js.map +1 -0
- package/dist/server/status.d.ts +20 -0
- package/dist/server/status.d.ts.map +1 -0
- package/dist/server/status.js +103 -0
- package/dist/server/status.js.map +1 -0
- package/dist/server/up.d.ts +211 -0
- package/dist/server/up.d.ts.map +1 -0
- package/dist/server/up.js +625 -0
- package/dist/server/up.js.map +1 -0
- package/dist/server/update.d.ts +35 -0
- package/dist/server/update.d.ts.map +1 -0
- package/dist/server/update.js +308 -0
- package/dist/server/update.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 +36 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Pi harness.
|
|
2
|
+
//
|
|
3
|
+
// Drives the native `pi` CLI — we never hand-edit Pi config. The extension
|
|
4
|
+
// is the npm package `@the-librarian/pi-extension`.
|
|
5
|
+
//
|
|
6
|
+
// detect `pi` on PATH AND `pi list` shows @the-librarian/pi-extension
|
|
7
|
+
// install `pi install npm:@the-librarian/pi-extension`
|
|
8
|
+
// uninstall `pi uninstall @the-librarian/pi-extension`
|
|
9
|
+
// update re-run install (idempotent; pulls the current version)
|
|
10
|
+
//
|
|
11
|
+
// The token plays no part here — Pi's MCP auth is configured by the
|
|
12
|
+
// extension/env — so nothing token-shaped is ever passed or logged.
|
|
13
|
+
import { run, which } from "../exec.js";
|
|
14
|
+
const CLI = "pi";
|
|
15
|
+
const EXTENSION = "@the-librarian/pi-extension";
|
|
16
|
+
const INSTALL_SPEC = `npm:${EXTENSION}`;
|
|
17
|
+
function notFound() {
|
|
18
|
+
return new Error("Pi CLI not found on PATH (expected `pi`).");
|
|
19
|
+
}
|
|
20
|
+
/** True iff `pi list` output shows our extension. */
|
|
21
|
+
function extensionListed(listOutput) {
|
|
22
|
+
return listOutput.split("\n").some((line) => line.includes(EXTENSION));
|
|
23
|
+
}
|
|
24
|
+
/** Pull the extension's version from a `pi list` line, if formatted. */
|
|
25
|
+
function parseExtensionVersion(listOutput) {
|
|
26
|
+
for (const line of listOutput.split("\n")) {
|
|
27
|
+
if (!line.includes(EXTENSION))
|
|
28
|
+
continue;
|
|
29
|
+
const m = /\bv?(\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?)\b/.exec(line);
|
|
30
|
+
if (m?.[1])
|
|
31
|
+
return m[1];
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
export const pi = {
|
|
36
|
+
id: "pi",
|
|
37
|
+
displayName: "Pi",
|
|
38
|
+
async detect() {
|
|
39
|
+
if (!(await which(CLI)))
|
|
40
|
+
return { installed: false };
|
|
41
|
+
const { stdout, code } = await run(CLI, ["list"]);
|
|
42
|
+
if (code !== 0 || !extensionListed(stdout))
|
|
43
|
+
return { installed: false };
|
|
44
|
+
const version = parseExtensionVersion(stdout);
|
|
45
|
+
return version === undefined ? { installed: true } : { installed: true, version };
|
|
46
|
+
},
|
|
47
|
+
async install(_cfg) {
|
|
48
|
+
if (!(await which(CLI)))
|
|
49
|
+
throw notFound();
|
|
50
|
+
// Idempotent: if already listed, installing again is a no-op.
|
|
51
|
+
const { stdout: listed } = await run(CLI, ["list"]);
|
|
52
|
+
if (extensionListed(listed))
|
|
53
|
+
return;
|
|
54
|
+
const result = await run(CLI, ["install", INSTALL_SPEC]);
|
|
55
|
+
if (result.code !== 0) {
|
|
56
|
+
throw new Error(`pi install failed: ${oneLine(result.stderr || result.stdout)}`);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
async uninstall() {
|
|
60
|
+
if (!(await which(CLI)))
|
|
61
|
+
return; // nothing to remove if the CLI is gone
|
|
62
|
+
// `pi uninstall` of an absent extension is a no-op; surface only real errors.
|
|
63
|
+
await run(CLI, ["uninstall", EXTENSION]);
|
|
64
|
+
},
|
|
65
|
+
async update(cfg) {
|
|
66
|
+
await this.install(cfg);
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
function oneLine(text) {
|
|
70
|
+
return text.replace(/\s+/g, " ").trim();
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=pi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi.js","sourceRoot":"","sources":["../../src/harnesses/pi.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,EAAE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;IAED,KAAK,CAAC,MAAM,CAAC,GAAkB;QAC7B,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;CACF,CAAC;AAEF,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** The five supported harness ids. */
|
|
2
|
+
export type HarnessId = "claude" | "codex" | "opencode" | "hermes" | "pi";
|
|
3
|
+
/** The config a harness needs to wire The Librarian into itself. */
|
|
4
|
+
export interface HarnessConfig {
|
|
5
|
+
/** The MCP endpoint URL the harness should talk to. */
|
|
6
|
+
mcpUrl: string;
|
|
7
|
+
/** The bearer token. Goes in a header / env var — never a URL or log. */
|
|
8
|
+
token: string;
|
|
9
|
+
/** The server base URL (origin of the MCP URL by default). */
|
|
10
|
+
serverUrl: string;
|
|
11
|
+
}
|
|
12
|
+
/** What `detect()` reports about a harness's current state. */
|
|
13
|
+
export interface DetectResult {
|
|
14
|
+
/** True iff The Librarian is currently installed into this harness. */
|
|
15
|
+
installed: boolean;
|
|
16
|
+
/** The installed integration version, when detectable. */
|
|
17
|
+
version?: string;
|
|
18
|
+
}
|
|
19
|
+
/** A single harness integration module. */
|
|
20
|
+
export interface HarnessModule {
|
|
21
|
+
/** Stable id used on the CLI and as the dashboard harness key. */
|
|
22
|
+
readonly id: HarnessId;
|
|
23
|
+
/** Human-readable name for tables and prompts. */
|
|
24
|
+
readonly displayName: string;
|
|
25
|
+
/**
|
|
26
|
+
* Live-probe whether The Librarian is installed into this harness and,
|
|
27
|
+
* if so, at what version. A harness whose CLI/binary isn't present
|
|
28
|
+
* should resolve `{ installed: false }` — absence is not an error.
|
|
29
|
+
*/
|
|
30
|
+
detect(): Promise<DetectResult>;
|
|
31
|
+
/** Install The Librarian into this harness via its native path. */
|
|
32
|
+
install(cfg: HarnessConfig): Promise<void>;
|
|
33
|
+
/** Remove The Librarian's entry from this harness. */
|
|
34
|
+
uninstall(): Promise<void>;
|
|
35
|
+
/** Update the integration to the current version (idempotent). */
|
|
36
|
+
update(cfg: HarnessConfig): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Thrown by a harness operation that hasn't been implemented yet.
|
|
40
|
+
*
|
|
41
|
+
* The stub modules throw this from install/uninstall/update so the
|
|
42
|
+
* orchestration wave has a clear, typed signal — distinct from a real
|
|
43
|
+
* harness failure.
|
|
44
|
+
*/
|
|
45
|
+
export declare class NotImplemented extends Error {
|
|
46
|
+
constructor(harness: HarnessId, op: string);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/harnesses/types.ts"],"names":[],"mappings":"AASA,sCAAsC;AACtC,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,IAAI,CAAC;AAE1E,oEAAoE;AACpE,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,+DAA+D;AAC/D,MAAM,WAAW,YAAY;IAC3B,uEAAuE;IACvE,SAAS,EAAE,OAAO,CAAC;IACnB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,2CAA2C;AAC3C,MAAM,WAAW,aAAa;IAC5B,kEAAkE;IAClE,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;IACvB,kDAAkD;IAClD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B;;;;OAIG;IACH,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAEhC,mEAAmE;IACnE,OAAO,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3C,sDAAsD;IACtD,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3B,kEAAkE;IAClE,MAAM,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C;AAED;;;;;;GAMG;AACH,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM;CAI3C"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// The harness-module contract.
|
|
2
|
+
//
|
|
3
|
+
// Every harness (claude, codex, opencode, hermes, pi) is a module that
|
|
4
|
+
// implements this interface. The installer CLI is a thin orchestrator: it
|
|
5
|
+
// drives each harness's *native* install path rather than hand-editing
|
|
6
|
+
// five config formats. The real per-harness logic lands in a later wave;
|
|
7
|
+
// this file is the stable contract the stubs (and that wave) implement
|
|
8
|
+
// against.
|
|
9
|
+
/**
|
|
10
|
+
* Thrown by a harness operation that hasn't been implemented yet.
|
|
11
|
+
*
|
|
12
|
+
* The stub modules throw this from install/uninstall/update so the
|
|
13
|
+
* orchestration wave has a clear, typed signal — distinct from a real
|
|
14
|
+
* harness failure.
|
|
15
|
+
*/
|
|
16
|
+
export class NotImplemented extends Error {
|
|
17
|
+
constructor(harness, op) {
|
|
18
|
+
super(`${harness}.${op}() is not implemented yet`);
|
|
19
|
+
this.name = "NotImplemented";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/harnesses/types.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,EAAE;AACF,uEAAuE;AACvE,0EAA0E;AAC1E,uEAAuE;AACvE,yEAAyE;AACzE,uEAAuE;AACvE,WAAW;AA+CX;;;;;;GAMG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAkB,EAAE,EAAU;QACxC,KAAK,CAAC,GAAG,OAAO,IAAI,EAAE,2BAA2B,CAAC,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { runCli, usage, type CliResult, type RuntimeOptions } from "./runtime.js";
|
|
2
|
+
export { readConfig, setConfig, redact, formatConfig, deriveServerUrl, type LibrarianConfig, type RedactedConfig, type SetConfigInput, } from "./config.js";
|
|
3
|
+
export { detectShell, applyShellBlock, removeShellBlock, writeEnvFile, readEnvFile, type EnvValues, type Shell, } from "./env.js";
|
|
4
|
+
export { machineId, hostname } from "./machine.js";
|
|
5
|
+
export { cliVersion } from "./version.js";
|
|
6
|
+
export { status, fetchLatestVersion, setLatestFetcher, resetLatestFetcher, type LatestFetcher, } from "./status.js";
|
|
7
|
+
export { doctor, setServerProbe, resetServerProbe, type ServerProbe, type ProbeResult, } from "./doctor.js";
|
|
8
|
+
export { createPrompter, resolveSelection, MissingValueError, type Prompter, type PrompterOptions, type PromptFn, type PromptTextOptions, type HarnessChoice, } from "./prompt.js";
|
|
9
|
+
export { compareVersions, isBehind } from "./semver.js";
|
|
10
|
+
export { registry, allHarnesses, HARNESS_IDS, isHarnessId, NotImplemented, type HarnessId, type HarnessModule, type HarnessConfig, type DetectResult, } from "./harnesses/index.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,EACL,UAAU,EACV,SAAS,EACT,MAAM,EACN,YAAY,EACZ,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,KAAK,SAAS,EACd,KAAK,KAAK,GACX,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,MAAM,EACN,cAAc,EACd,gBAAgB,EAChB,KAAK,WAAW,EAChB,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,WAAW,EACX,cAAc,EACd,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Public surface of `@the-librarian/cli` as a library.
|
|
2
|
+
//
|
|
3
|
+
// The bin is the primary consumer, but exporting the runtime + core lets
|
|
4
|
+
// the next wave (and tests) import the pieces directly.
|
|
5
|
+
export { runCli, usage } from "./runtime.js";
|
|
6
|
+
export { readConfig, setConfig, redact, formatConfig, deriveServerUrl, } from "./config.js";
|
|
7
|
+
export { detectShell, applyShellBlock, removeShellBlock, writeEnvFile, readEnvFile, } from "./env.js";
|
|
8
|
+
export { machineId, hostname } from "./machine.js";
|
|
9
|
+
export { cliVersion } from "./version.js";
|
|
10
|
+
export { status, fetchLatestVersion, setLatestFetcher, resetLatestFetcher, } from "./status.js";
|
|
11
|
+
export { doctor, setServerProbe, resetServerProbe, } from "./doctor.js";
|
|
12
|
+
export { createPrompter, resolveSelection, MissingValueError, } from "./prompt.js";
|
|
13
|
+
export { compareVersions, isBehind } from "./semver.js";
|
|
14
|
+
export { registry, allHarnesses, HARNESS_IDS, isHarnessId, NotImplemented, } from "./harnesses/index.js";
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,EAAE;AACF,yEAAyE;AACzE,wDAAwD;AAExD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAuC,MAAM,cAAc,CAAC;AAClF,OAAO,EACL,UAAU,EACV,SAAS,EACT,MAAM,EACN,YAAY,EACZ,eAAe,GAIhB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,WAAW,GAGZ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,GAEnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,MAAM,EACN,cAAc,EACd,gBAAgB,GAGjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,iBAAiB,GAMlB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,WAAW,EACX,cAAc,GAKf,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read the machine id, generating and persisting one on first call.
|
|
3
|
+
*
|
|
4
|
+
* Stable across calls: once written, the same UUID is returned forever.
|
|
5
|
+
* A blank/whitespace-only file is treated as missing and regenerated.
|
|
6
|
+
*/
|
|
7
|
+
export declare function machineId(home?: string): string;
|
|
8
|
+
/** The machine's hostname, for human-readable dashboard display. */
|
|
9
|
+
export declare function hostname(): string;
|
|
10
|
+
//# sourceMappingURL=machine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../src/machine.ts"],"names":[],"mappings":"AAeA;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAY/C;AAED,oEAAoE;AACpE,wBAAgB,QAAQ,IAAI,MAAM,CAEjC"}
|
package/dist/machine.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Machine identity for the dashboard's Installs view.
|
|
2
|
+
//
|
|
3
|
+
// Each machine gets a stable UUID, generated on first run and stored
|
|
4
|
+
// at `~/.librarian/machine-id`. It's the dashboard's row key (Phase 2),
|
|
5
|
+
// so two identical setups on different machines stay distinct. The
|
|
6
|
+
// hostname rides along for human-readable display.
|
|
7
|
+
//
|
|
8
|
+
// The `home` argument is injectable for tests — pass a temp dir to keep
|
|
9
|
+
// the real `~/.librarian/machine-id` untouched.
|
|
10
|
+
import { randomUUID } from "node:crypto";
|
|
11
|
+
import fs from "node:fs";
|
|
12
|
+
import os from "node:os";
|
|
13
|
+
import { librarianDir, machineIdPath } from "./paths.js";
|
|
14
|
+
/**
|
|
15
|
+
* Read the machine id, generating and persisting one on first call.
|
|
16
|
+
*
|
|
17
|
+
* Stable across calls: once written, the same UUID is returned forever.
|
|
18
|
+
* A blank/whitespace-only file is treated as missing and regenerated.
|
|
19
|
+
*/
|
|
20
|
+
export function machineId(home) {
|
|
21
|
+
const idPath = machineIdPath(home);
|
|
22
|
+
try {
|
|
23
|
+
const existing = fs.readFileSync(idPath, "utf8").trim();
|
|
24
|
+
if (existing)
|
|
25
|
+
return existing;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// not yet written — fall through and create it
|
|
29
|
+
}
|
|
30
|
+
const id = randomUUID();
|
|
31
|
+
fs.mkdirSync(librarianDir(home), { recursive: true });
|
|
32
|
+
fs.writeFileSync(idPath, `${id}\n`, { encoding: "utf8" });
|
|
33
|
+
return id;
|
|
34
|
+
}
|
|
35
|
+
/** The machine's hostname, for human-readable dashboard display. */
|
|
36
|
+
export function hostname() {
|
|
37
|
+
return os.hostname();
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=machine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machine.js","sourceRoot":"","sources":["../src/machine.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,EAAE;AACF,qEAAqE;AACrE,wEAAwE;AACxE,mEAAmE;AACnE,mDAAmD;AACnD,EAAE;AACF,wEAAwE;AACxE,gDAAgD;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,IAAa;IACrC,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;QACxD,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,+CAA+C;IACjD,CAAC;IACD,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC;IACxB,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACtD,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1D,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,QAAQ;IACtB,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type FlagValue = string | boolean | string[];
|
|
2
|
+
export type FlagMap = Record<string, FlagValue>;
|
|
3
|
+
export interface ParsedArgs {
|
|
4
|
+
positionals: string[];
|
|
5
|
+
flags: FlagMap;
|
|
6
|
+
}
|
|
7
|
+
export declare function parseArgs(args: string[]): ParsedArgs;
|
|
8
|
+
/** Coerce a flag to a string, or undefined when it isn't a plain string. */
|
|
9
|
+
export declare function flagString(value: FlagValue | undefined): string | undefined;
|
|
10
|
+
/** True iff the flag was passed as a bare boolean (`--foo`) or set truthy. */
|
|
11
|
+
export declare function flagBool(value: FlagValue | undefined): boolean;
|
|
12
|
+
//# sourceMappingURL=parse-args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-args.d.ts","sourceRoot":"","sources":["../src/parse-args.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,CAAC;AACpD,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAEhD,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAiCpD;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAE3E;AAED,8EAA8E;AAC9E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAE9D"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// A tiny dependency-light arg parser, matching the repo's lean style
|
|
2
|
+
// (see packages/cli/src/parse-flags.ts). No framework.
|
|
3
|
+
//
|
|
4
|
+
// `parseArgs(argv)` splits a verb's arguments into `{ positionals, flags }`.
|
|
5
|
+
// Bare `--foo` → `true`; `--no-foo` → `false`; `--foo bar` → `"bar"`;
|
|
6
|
+
// repeated `--foo a --foo b` → `["a", "b"]`.
|
|
7
|
+
export function parseArgs(args) {
|
|
8
|
+
const positionals = [];
|
|
9
|
+
const flags = {};
|
|
10
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
11
|
+
const arg = args[i];
|
|
12
|
+
if (typeof arg !== "string")
|
|
13
|
+
continue;
|
|
14
|
+
if (arg.startsWith("--no-")) {
|
|
15
|
+
flags[arg.slice("--no-".length)] = false;
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (arg.startsWith("--")) {
|
|
19
|
+
const key = arg.slice(2);
|
|
20
|
+
const next = args[i + 1];
|
|
21
|
+
if (next === undefined || (typeof next === "string" && next.startsWith("--"))) {
|
|
22
|
+
flags[key] = true;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const existing = flags[key];
|
|
26
|
+
if (existing === undefined) {
|
|
27
|
+
flags[key] = next;
|
|
28
|
+
}
|
|
29
|
+
else if (Array.isArray(existing)) {
|
|
30
|
+
existing.push(next);
|
|
31
|
+
}
|
|
32
|
+
else if (typeof existing === "string") {
|
|
33
|
+
flags[key] = [existing, next];
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
flags[key] = next;
|
|
37
|
+
}
|
|
38
|
+
i += 1;
|
|
39
|
+
}
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
positionals.push(arg);
|
|
43
|
+
}
|
|
44
|
+
return { positionals, flags };
|
|
45
|
+
}
|
|
46
|
+
/** Coerce a flag to a string, or undefined when it isn't a plain string. */
|
|
47
|
+
export function flagString(value) {
|
|
48
|
+
return typeof value === "string" ? value : undefined;
|
|
49
|
+
}
|
|
50
|
+
/** True iff the flag was passed as a bare boolean (`--foo`) or set truthy. */
|
|
51
|
+
export function flagBool(value) {
|
|
52
|
+
return value === true;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=parse-args.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-args.js","sourceRoot":"","sources":["../src/parse-args.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,uDAAuD;AACvD,EAAE;AACF,6EAA6E;AAC7E,sEAAsE;AACtE,6CAA6C;AAU7C,MAAM,UAAU,SAAS,CAAC,IAAc;IACtC,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,MAAM,KAAK,GAAY,EAAE,CAAC;IAC1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,SAAS;QACtC,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC;YACzC,SAAS;QACX,CAAC;QACD,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC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.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Override the resolved home dir for every path helper (tests). */
|
|
2
|
+
export declare function setHomeOverride(home: string | undefined): void;
|
|
3
|
+
/** Clear the home override, restoring `os.homedir()` (tests). */
|
|
4
|
+
export declare function resetHomeOverride(): void;
|
|
5
|
+
/**
|
|
6
|
+
* The user's home directory. An explicit `home` arg wins; then the
|
|
7
|
+
* module-level override (tests); otherwise the real `os.homedir()`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function homeDir(home?: string): string;
|
|
10
|
+
/** `~/.librarian` — the root of everything the CLI persists. */
|
|
11
|
+
export declare function librarianDir(home?: string): string;
|
|
12
|
+
/** `~/.librarian/env` — the chmod-600 POSIX env file (bash/zsh source it). */
|
|
13
|
+
export declare function envFilePath(home?: string): string;
|
|
14
|
+
/** `~/.librarian/machine-id` — the dashboard's per-machine row key. */
|
|
15
|
+
export declare function machineIdPath(home?: string): string;
|
|
16
|
+
/** `~/.config/fish/conf.d/librarian.fish` — fish's native env hook. */
|
|
17
|
+
export declare function fishConfPath(home?: string): string;
|
|
18
|
+
/** `~/.bashrc`. */
|
|
19
|
+
export declare function bashRcPath(home?: string): string;
|
|
20
|
+
/** `~/.zshrc`. */
|
|
21
|
+
export declare function zshRcPath(home?: string): string;
|
|
22
|
+
/** `~/.codex/config.toml` — Codex's MCP-server config. */
|
|
23
|
+
export declare function codexConfigPath(home?: string): string;
|
|
24
|
+
/** `~/.config/opencode/opencode.json` — OpenCode's global config. */
|
|
25
|
+
export declare function opencodeConfigPath(home?: string): string;
|
|
26
|
+
/** `~/.hermes` — Hermes's home (plugins + config live under here). */
|
|
27
|
+
export declare function hermesHomeDir(home?: string): string;
|
|
28
|
+
/** `~/.hermes/plugins/librarian` — where the Hermes adapter is installed. */
|
|
29
|
+
export declare function hermesPluginDir(home?: string): string;
|
|
30
|
+
/** `~/.hermes/config.json` — Hermes config carrying `memory.provider`. */
|
|
31
|
+
export declare function hermesConfigPath(home?: string):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B,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtD"}
|
package/dist/paths.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Filesystem path resolution for the installer CLI.
|
|
2
|
+
//
|
|
3
|
+
// Everything the CLI persists lives under `~/.librarian/`. The home
|
|
4
|
+
// directory is *injectable* — every path helper takes an optional
|
|
5
|
+
// `home` argument that defaults to `os.homedir()`. Tests pass a temp
|
|
6
|
+
// dir so they never touch the real `~/.librarian`. Production code
|
|
7
|
+
// passes nothing and gets the real home.
|
|
8
|
+
import os from "node:os";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
// A module-level home override. The harness modules implement a fixed
|
|
11
|
+
// `HarnessModule` interface (no `home` param), so file-based harnesses
|
|
12
|
+
// (codex/opencode/hermes) resolve paths against this when set. Tests point
|
|
13
|
+
// it at a temp dir via `setHomeOverride`; production leaves it unset and
|
|
14
|
+
// gets the real `os.homedir()`.
|
|
15
|
+
let homeOverride;
|
|
16
|
+
/** Override the resolved home dir for every path helper (tests). */
|
|
17
|
+
export function setHomeOverride(home) {
|
|
18
|
+
homeOverride = home;
|
|
19
|
+
}
|
|
20
|
+
/** Clear the home override, restoring `os.homedir()` (tests). */
|
|
21
|
+
export function resetHomeOverride() {
|
|
22
|
+
homeOverride = undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The user's home directory. An explicit `home` arg wins; then the
|
|
26
|
+
* module-level override (tests); otherwise the real `os.homedir()`.
|
|
27
|
+
*/
|
|
28
|
+
export function homeDir(home) {
|
|
29
|
+
return home ?? homeOverride ?? os.homedir();
|
|
30
|
+
}
|
|
31
|
+
/** `~/.librarian` — the root of everything the CLI persists. */
|
|
32
|
+
export function librarianDir(home) {
|
|
33
|
+
return path.join(homeDir(home), ".librarian");
|
|
34
|
+
}
|
|
35
|
+
/** `~/.librarian/env` — the chmod-600 POSIX env file (bash/zsh source it). */
|
|
36
|
+
export function envFilePath(home) {
|
|
37
|
+
return path.join(librarianDir(home), "env");
|
|
38
|
+
}
|
|
39
|
+
/** `~/.librarian/machine-id` — the dashboard's per-machine row key. */
|
|
40
|
+
export function machineIdPath(home) {
|
|
41
|
+
return path.join(librarianDir(home), "machine-id");
|
|
42
|
+
}
|
|
43
|
+
/** `~/.config/fish/conf.d/librarian.fish` — fish's native env hook. */
|
|
44
|
+
export function fishConfPath(home) {
|
|
45
|
+
return path.join(homeDir(home), ".config", "fish", "conf.d", "librarian.fish");
|
|
46
|
+
}
|
|
47
|
+
/** `~/.bashrc`. */
|
|
48
|
+
export function bashRcPath(home) {
|
|
49
|
+
return path.join(homeDir(home), ".bashrc");
|
|
50
|
+
}
|
|
51
|
+
/** `~/.zshrc`. */
|
|
52
|
+
export function zshRcPath(home) {
|
|
53
|
+
return path.join(homeDir(home), ".zshrc");
|
|
54
|
+
}
|
|
55
|
+
/** `~/.codex/config.toml` — Codex's MCP-server config. */
|
|
56
|
+
export function codexConfigPath(home) {
|
|
57
|
+
return path.join(homeDir(home), ".codex", "config.toml");
|
|
58
|
+
}
|
|
59
|
+
/** `~/.config/opencode/opencode.json` — OpenCode's global config. */
|
|
60
|
+
export function opencodeConfigPath(home) {
|
|
61
|
+
return path.join(homeDir(home), ".config", "opencode", "opencode.json");
|
|
62
|
+
}
|
|
63
|
+
/** `~/.hermes` — Hermes's home (plugins + config live under here). */
|
|
64
|
+
export function hermesHomeDir(home) {
|
|
65
|
+
return path.join(homeDir(home), ".hermes");
|
|
66
|
+
}
|
|
67
|
+
/** `~/.hermes/plugins/librarian` — where the Hermes adapter is installed. */
|
|
68
|
+
export function hermesPluginDir(home) {
|
|
69
|
+
return path.join(hermesHomeDir(home), "plugins", "librarian");
|
|
70
|
+
}
|
|
71
|
+
/** `~/.hermes/config.json` — Hermes config carrying `memory.provider`. */
|
|
72
|
+
export function hermesConfigPath(home) {
|
|
73
|
+
return path.join(hermesHomeDir(home), "config.json");
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=paths.js.map
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node:stream";
|
|
2
|
+
export interface PromptTextOptions {
|
|
3
|
+
/** Value used when the user just hits enter (or in non-interactive mode). */
|
|
4
|
+
default?: string;
|
|
5
|
+
/** Don't echo the typed characters (used for the token). */
|
|
6
|
+
secret?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The injectable prompt function. Given a fully-rendered question (the caller
|
|
10
|
+
* has already appended any `[default]` hint), it resolves the user's raw
|
|
11
|
+
* answer. `secret` lets a fake distinguish a token prompt if it wants to.
|
|
12
|
+
*/
|
|
13
|
+
export type PromptFn = (question: string, opts: {
|
|
14
|
+
secret: boolean;
|
|
15
|
+
}) => Promise<string>;
|
|
16
|
+
export interface Prompter {
|
|
17
|
+
selectHarnesses(available: HarnessChoice[]): Promise<string[]>;
|
|
18
|
+
promptText(question: string, opts?: PromptTextOptions): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Release any resources held for interactive prompting (the shared readline
|
|
21
|
+
* interface). Safe to call when nothing was opened, and idempotent. Callers
|
|
22
|
+
* MUST invoke this once the prompting phase is done — an open readline keeps
|
|
23
|
+
* the Node event loop alive, so the process won't exit until it's closed.
|
|
24
|
+
*/
|
|
25
|
+
close(): void;
|
|
26
|
+
}
|
|
27
|
+
/** A pickable harness in the multi-select. */
|
|
28
|
+
export interface HarnessChoice {
|
|
29
|
+
id: string;
|
|
30
|
+
label: string;
|
|
31
|
+
}
|
|
32
|
+
export interface PrompterOptions {
|
|
33
|
+
/** Inject a deterministic answer function (tests). Wins over streams. */
|
|
34
|
+
prompt?: PromptFn;
|
|
35
|
+
/** The stream questions are read from. Defaults to `process.stdin`. */
|
|
36
|
+
input?: Readable;
|
|
37
|
+
/** The stream prompts/labels are written to. Defaults to `process.stdout`. */
|
|
38
|
+
output?: Writable;
|
|
39
|
+
/**
|
|
40
|
+
* Force interactive vs non-interactive. Defaults to whether `input` is a
|
|
41
|
+
* TTY. Non-interactive never blocks on a read.
|
|
42
|
+
*/
|
|
43
|
+
interactive?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/** A clear, typed error thrown when a required value can't be obtained. */
|
|
46
|
+
export declare class MissingValueError extends Error {
|
|
47
|
+
constructor(what: string);
|
|
48
|
+
}
|
|
49
|
+
/** Build a Prompter over the given options (defaults to the real stdio). */
|
|
50
|
+
export declare function createPrompter(options?: PrompterOptions): Prompter;
|
|
51
|
+
/** Map a multi-select answer string to the chosen harness ids. */
|
|
52
|
+
export declare function resolveSelection(answer: string, available: HarnessChoice[]): string[];
|
|
53
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAChC,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAExF,MAAM,WAAW,QAAQ;IACvB,eAAe,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/D,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACxE;;;;;OAKG;IACH,KAAK,IAAI,IAAI,CAAC;CACf;AAED,8CAA8C;AAC9C,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,yEAAyE;IACzE,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