@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
package/dist/prompt.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// A tiny `node:readline`-based prompt layer, injectable for tests.
|
|
2
|
+
//
|
|
3
|
+
// Two surfaces:
|
|
4
|
+
// - `selectHarnesses(available)` — a numbered multi-select; the user types
|
|
5
|
+
// numbers (`1 3`), `all`, or `none`.
|
|
6
|
+
// - `promptText(question, opts)` — a single line; `secret` suppresses the
|
|
7
|
+
// echo (for the token).
|
|
8
|
+
//
|
|
9
|
+
// EVERYTHING is injectable so tests never touch a real TTY or stdin:
|
|
10
|
+
// - pass a `prompt` fn to answer questions deterministically, OR
|
|
11
|
+
// - pass `input`/`output` streams the readline reads from / writes to.
|
|
12
|
+
// Non-interactive (no TTY, no injected prompt) NEVER hangs: `selectHarnesses`
|
|
13
|
+
// falls back to "everything available", and `promptText` returns the default
|
|
14
|
+
// (or throws a clear error when a required value has no default).
|
|
15
|
+
import readline from "node:readline";
|
|
16
|
+
/** A clear, typed error thrown when a required value can't be obtained. */
|
|
17
|
+
export class MissingValueError extends Error {
|
|
18
|
+
constructor(what) {
|
|
19
|
+
super(`${what} is required but no value was provided (non-interactive run).`);
|
|
20
|
+
this.name = "MissingValueError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Build a Prompter over the given options (defaults to the real stdio). */
|
|
24
|
+
export function createPrompter(options = {}) {
|
|
25
|
+
const input = options.input ?? process.stdin;
|
|
26
|
+
const output = options.output ?? process.stdout;
|
|
27
|
+
const interactive = options.interactive ??
|
|
28
|
+
(options.prompt !== undefined ? true : Boolean(input.isTTY));
|
|
29
|
+
// ONE line reader (over ONE readline interface) for this prompter's whole
|
|
30
|
+
// lifetime. Created lazily on the first real prompt — so a non-interactive
|
|
31
|
+
// or injected-`prompt` run never opens stdin — and reused for EVERY question.
|
|
32
|
+
//
|
|
33
|
+
// The old code built a FRESH `createInterface` per question and `rl.close()`d
|
|
34
|
+
// it. Closing the first interface discarded the input buffered past its line,
|
|
35
|
+
// so a second read over a single shared stream (e.g. a piped
|
|
36
|
+
// `librarian install <<EOF`, where both answers arrive in one chunk) never
|
|
37
|
+
// saw its input and the read hung — `resolveConfig` then threw "required".
|
|
38
|
+
// `close()` (called from the command lifecycle) tears the reader down exactly
|
|
39
|
+
// once so the open readline doesn't keep the Node event loop alive.
|
|
40
|
+
let reader;
|
|
41
|
+
const lineReader = () => {
|
|
42
|
+
if (!reader)
|
|
43
|
+
reader = createLineReader(input, output);
|
|
44
|
+
return reader;
|
|
45
|
+
};
|
|
46
|
+
const ask = options.prompt ?? ((question, opts) => lineReader().ask(question, opts.secret));
|
|
47
|
+
return {
|
|
48
|
+
async selectHarnesses(available) {
|
|
49
|
+
if (available.length === 0)
|
|
50
|
+
return [];
|
|
51
|
+
if (!interactive && options.prompt === undefined) {
|
|
52
|
+
// No way to ask — default to every available harness.
|
|
53
|
+
return available.map((h) => h.id);
|
|
54
|
+
}
|
|
55
|
+
write(output, "Select harnesses to install:\n");
|
|
56
|
+
available.forEach((h, i) => write(output, ` ${i + 1}) ${h.label}\n`));
|
|
57
|
+
write(output, "Enter numbers (e.g. 1 3), 'all', or 'none' [all]: ");
|
|
58
|
+
const answer = (await ask("", { secret: false })).trim();
|
|
59
|
+
return resolveSelection(answer, available);
|
|
60
|
+
},
|
|
61
|
+
async promptText(question, opts = {}) {
|
|
62
|
+
const hasDefault = opts.default !== undefined;
|
|
63
|
+
if (!interactive && options.prompt === undefined) {
|
|
64
|
+
if (hasDefault)
|
|
65
|
+
return opts.default;
|
|
66
|
+
throw new MissingValueError(question);
|
|
67
|
+
}
|
|
68
|
+
const hint = hasDefault && !opts.secret ? ` [${opts.default}]` : "";
|
|
69
|
+
const raw = (await ask(`${question}${hint}: `, { secret: Boolean(opts.secret) })).trim();
|
|
70
|
+
if (raw.length === 0 && hasDefault)
|
|
71
|
+
return opts.default;
|
|
72
|
+
if (raw.length === 0 && !hasDefault)
|
|
73
|
+
throw new MissingValueError(question);
|
|
74
|
+
return raw;
|
|
75
|
+
},
|
|
76
|
+
close() {
|
|
77
|
+
// Idempotent: only the shared reader (if one was ever opened) is torn
|
|
78
|
+
// down. An open readline keeps the Node event loop alive, so the command
|
|
79
|
+
// lifecycle MUST call this once prompting is done or the process hangs.
|
|
80
|
+
if (reader) {
|
|
81
|
+
reader.close();
|
|
82
|
+
reader = undefined;
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** Map a multi-select answer string to the chosen harness ids. */
|
|
88
|
+
export function resolveSelection(answer, available) {
|
|
89
|
+
const normalized = answer.trim().toLowerCase();
|
|
90
|
+
if (normalized === "" || normalized === "all")
|
|
91
|
+
return available.map((h) => h.id);
|
|
92
|
+
if (normalized === "none")
|
|
93
|
+
return [];
|
|
94
|
+
const picked = new Set();
|
|
95
|
+
for (const token of normalized.split(/[\s,]+/).filter(Boolean)) {
|
|
96
|
+
const n = Number.parseInt(token, 10);
|
|
97
|
+
if (Number.isInteger(n) && n >= 1 && n <= available.length) {
|
|
98
|
+
const choice = available[n - 1];
|
|
99
|
+
if (choice)
|
|
100
|
+
picked.add(choice.id);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return available.filter((h) => picked.has(h.id)).map((h) => h.id);
|
|
104
|
+
}
|
|
105
|
+
// --- readline plumbing ---------------------------------------------------
|
|
106
|
+
function write(output, text) {
|
|
107
|
+
output.write(text);
|
|
108
|
+
}
|
|
109
|
+
function createLineReader(input, output) {
|
|
110
|
+
const rl = readline.createInterface({ input, output, terminal: true });
|
|
111
|
+
const queue = [];
|
|
112
|
+
let waiting = null;
|
|
113
|
+
rl.on("line", (line) => {
|
|
114
|
+
if (waiting) {
|
|
115
|
+
const resolve = waiting;
|
|
116
|
+
waiting = null;
|
|
117
|
+
resolve(line);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
queue.push(line);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
// The original echo writer; restored after each secret question so a later
|
|
124
|
+
// non-secret prompt renders normally. Typed to allow `undefined` so the
|
|
125
|
+
// restore assignment is sound under `exactOptionalPropertyTypes`.
|
|
126
|
+
const ref = rl;
|
|
127
|
+
const nextLine = () => new Promise((resolve) => {
|
|
128
|
+
const queued = queue.shift();
|
|
129
|
+
if (queued !== undefined)
|
|
130
|
+
resolve(queued);
|
|
131
|
+
else
|
|
132
|
+
waiting = resolve;
|
|
133
|
+
});
|
|
134
|
+
return {
|
|
135
|
+
async ask(question, secret) {
|
|
136
|
+
if (!secret) {
|
|
137
|
+
if (question)
|
|
138
|
+
write(output, question);
|
|
139
|
+
return nextLine();
|
|
140
|
+
}
|
|
141
|
+
// Mute the echo just for this question: swallow each typed character so
|
|
142
|
+
// the token never renders, passing only newlines through. Restore the
|
|
143
|
+
// original writer afterwards so a following non-secret prompt echoes.
|
|
144
|
+
const original = ref._writeToOutput;
|
|
145
|
+
ref._writeToOutput = (s) => {
|
|
146
|
+
if (s.includes("\n") || s.includes("\r"))
|
|
147
|
+
original?.call(rl, s);
|
|
148
|
+
};
|
|
149
|
+
try {
|
|
150
|
+
if (question)
|
|
151
|
+
write(output, question);
|
|
152
|
+
const line = await nextLine();
|
|
153
|
+
return line;
|
|
154
|
+
}
|
|
155
|
+
finally {
|
|
156
|
+
ref._writeToOutput = original;
|
|
157
|
+
write(output, "\n");
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
close() {
|
|
161
|
+
rl.close();
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","s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,EAAE,CAAC,KAAK,EAAE,CAAC;QACb,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type Shell } from "./env.js";
|
|
2
|
+
import { type Prompter } from "./prompt.js";
|
|
3
|
+
export interface CliResult {
|
|
4
|
+
stdout: string;
|
|
5
|
+
stderr: string;
|
|
6
|
+
exitCode: number;
|
|
7
|
+
}
|
|
8
|
+
export interface RuntimeOptions {
|
|
9
|
+
/** Override the home dir (tests). Defaults to the real `os.homedir()`. */
|
|
10
|
+
home?: string;
|
|
11
|
+
/** Override the detected shell (tests / `--shell`). */
|
|
12
|
+
shell?: Shell;
|
|
13
|
+
/** Inject a prompter (tests). Defaults to a real stdio-backed prompter. */
|
|
14
|
+
prompter?: Prompter;
|
|
15
|
+
/**
|
|
16
|
+
* The process environment to read existing `LIBRARIAN_*` vars from (BUG 2).
|
|
17
|
+
* Injectable so tests never touch the real `process.env` and never log a
|
|
18
|
+
* token. Defaults to `process.env` in `runInstall`.
|
|
19
|
+
*/
|
|
20
|
+
env?: NodeJS.ProcessEnv;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the run is interactive (a TTY is attached). Gates `server up`'s
|
|
23
|
+
* best-effort offers (the Tailscale offer; the `0.0.0.0` confirm). Defaults
|
|
24
|
+
* to `process.stdin.isTTY` — a non-interactive run never silently exposes the
|
|
25
|
+
* server beyond localhost (it keeps `127.0.0.1`). Injectable for tests.
|
|
26
|
+
*/
|
|
27
|
+
interactive?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The host platform, defaulting to `process.platform`. Threads into the
|
|
30
|
+
* `server` ops that branch on it: preflight's daemon hint and boot
|
|
31
|
+
* persistence (Linux systemd vs the macOS deferred notice). Injectable so the
|
|
32
|
+
* darwin path is testable from a Linux host.
|
|
33
|
+
*/
|
|
34
|
+
platform?: NodeJS.Platform;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The CLI entrypoint. Dispatches to the command handlers and — crucially —
|
|
38
|
+
* turns any escaped error into one clean stderr line + exit 1, so a failure
|
|
39
|
+
* never leaks a stack trace into the user's terminal (house rule: "never
|
|
40
|
+
* leak a stack trace"). `MissingValueError` (a required prompt with no value
|
|
41
|
+
* in a non-interactive run) gets a specific, actionable message.
|
|
42
|
+
*/
|
|
43
|
+
export declare function runCli(argv: string[], options?: RuntimeOptions): Promise<CliResult>;
|
|
44
|
+
export declare function usage(): string;
|
|
45
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,UAAU,CAAC;AAGnD,OAAO,EAAqC,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAY/E,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;CAC5B;AAID;;;;;;GAMG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,SAAS,CAAC,CAY7F;AAgUD,wBAAgB,KAAK,IAAI,MAAM,CAyB9B"}
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
// The `librarian` CLI runtime — an async function over argv.
|
|
2
|
+
//
|
|
3
|
+
// `runCli(argv, options)` resolves to `{ stdout, stderr, exitCode }` so the
|
|
4
|
+
// bin entry shapes it into a real process exit and tests assert against
|
|
5
|
+
// captured output without spawning a subprocess. Everything that touches the
|
|
6
|
+
// system is injectable through `options`: `home` (temp dir), `shell`, a
|
|
7
|
+
// `prompter` (prompt answers), and the per-module seams the commands pull in
|
|
8
|
+
// (`setRunner` / `setHomeOverride` / `setAdapterFetcher` / `setLatestFetcher`
|
|
9
|
+
// / `setServerProbe`). NOTHING here touches the real system, network, or
|
|
10
|
+
// stdin in tests.
|
|
11
|
+
import { runInstall } from "./commands/install.js";
|
|
12
|
+
import { runUninstall } from "./commands/uninstall.js";
|
|
13
|
+
import { runUpdate } from "./commands/update.js";
|
|
14
|
+
import { formatConfig, readConfig, redact, setConfig } from "./config.js";
|
|
15
|
+
import { doctor } from "./doctor.js";
|
|
16
|
+
import { detectShell } from "./env.js";
|
|
17
|
+
import { allHarnesses } from "./harnesses/index.js";
|
|
18
|
+
import { flagBool, flagString, parseArgs } from "./parse-args.js";
|
|
19
|
+
import { createPrompter, MissingValueError } from "./prompt.js";
|
|
20
|
+
import { runAdmin } from "./server/admin.js";
|
|
21
|
+
import { disableBoot, enableBoot } from "./server/boot.js";
|
|
22
|
+
import { runDown } from "./server/down.js";
|
|
23
|
+
import { serverUsage } from "./server/index.js";
|
|
24
|
+
import { runLogs } from "./server/logs.js";
|
|
25
|
+
import { serverStatus } from "./server/status.js";
|
|
26
|
+
import { runUp } from "./server/up.js";
|
|
27
|
+
import { runUpdate as runServerUpdate } from "./server/update.js";
|
|
28
|
+
import { status } from "./status.js";
|
|
29
|
+
import { cliVersion } from "./version.js";
|
|
30
|
+
const PHASE_2_STUBS = new Set(["report", "self-update"]);
|
|
31
|
+
/**
|
|
32
|
+
* The CLI entrypoint. Dispatches to the command handlers and — crucially —
|
|
33
|
+
* turns any escaped error into one clean stderr line + exit 1, so a failure
|
|
34
|
+
* never leaks a stack trace into the user's terminal (house rule: "never
|
|
35
|
+
* leak a stack trace"). `MissingValueError` (a required prompt with no value
|
|
36
|
+
* in a non-interactive run) gets a specific, actionable message.
|
|
37
|
+
*/
|
|
38
|
+
export async function runCli(argv, options = {}) {
|
|
39
|
+
try {
|
|
40
|
+
return await dispatch(argv, options);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (error instanceof MissingValueError) {
|
|
44
|
+
return err("MCP URL and token are required — re-run interactively, or pass --mcp-url/--token.");
|
|
45
|
+
}
|
|
46
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
47
|
+
return err(`librarian: ${message}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function dispatch(argv, options) {
|
|
51
|
+
const [command, ...rest] = argv;
|
|
52
|
+
if (!command || command === "--help" || command === "-h" || command === "help") {
|
|
53
|
+
return ok(usage());
|
|
54
|
+
}
|
|
55
|
+
if (command === "--version" || command === "-v" || command === "version") {
|
|
56
|
+
return ok(cliVersion());
|
|
57
|
+
}
|
|
58
|
+
if (command === "config") {
|
|
59
|
+
return runConfig(rest, options);
|
|
60
|
+
}
|
|
61
|
+
if (command === "install") {
|
|
62
|
+
return runInstallCommand(rest, options);
|
|
63
|
+
}
|
|
64
|
+
if (command === "uninstall") {
|
|
65
|
+
return runUninstallCommand(rest, options);
|
|
66
|
+
}
|
|
67
|
+
if (command === "update") {
|
|
68
|
+
return runUpdateCommand(rest, options);
|
|
69
|
+
}
|
|
70
|
+
if (command === "status") {
|
|
71
|
+
return ok(await status(options.home));
|
|
72
|
+
}
|
|
73
|
+
if (command === "doctor") {
|
|
74
|
+
// Diagnostic: exits 0 even when it flags problems.
|
|
75
|
+
return ok(await doctor(options.home));
|
|
76
|
+
}
|
|
77
|
+
if (command === "server") {
|
|
78
|
+
return runServerCommand(rest, options);
|
|
79
|
+
}
|
|
80
|
+
if (PHASE_2_STUBS.has(command)) {
|
|
81
|
+
return runPhase2Stub(command);
|
|
82
|
+
}
|
|
83
|
+
return err(`Unknown command: ${command}\n\n${usage()}`);
|
|
84
|
+
}
|
|
85
|
+
// --- config (fully implemented) ------------------------------------------
|
|
86
|
+
function runConfig(rest, options) {
|
|
87
|
+
const { flags } = parseArgs(rest);
|
|
88
|
+
const mcpUrl = flagString(flags["mcp-url"]) ?? flagString(flags.url);
|
|
89
|
+
const token = flagString(flags.token);
|
|
90
|
+
const shell = options.shell ?? resolveShellFlag(flags);
|
|
91
|
+
const wantsSet = mcpUrl !== undefined || token !== undefined;
|
|
92
|
+
if (wantsSet) {
|
|
93
|
+
const updated = setConfig({ mcpUrl, token }, { home: options.home, shell });
|
|
94
|
+
// Confirm what changed WITHOUT echoing the token.
|
|
95
|
+
return ok(["Updated config.", "", formatConfig(redact(updated))].join("\n"));
|
|
96
|
+
}
|
|
97
|
+
const current = readConfig(options.home);
|
|
98
|
+
if (!current) {
|
|
99
|
+
return ok([
|
|
100
|
+
"No config set yet.",
|
|
101
|
+
"",
|
|
102
|
+
"Set it with:",
|
|
103
|
+
" librarian config --mcp-url <url> --token <token>",
|
|
104
|
+
].join("\n"));
|
|
105
|
+
}
|
|
106
|
+
return ok(formatConfig(redact(current)));
|
|
107
|
+
}
|
|
108
|
+
function resolveShellFlag(flags) {
|
|
109
|
+
const raw = flagString(flags.shell);
|
|
110
|
+
if (!raw)
|
|
111
|
+
return undefined;
|
|
112
|
+
return detectShell(raw);
|
|
113
|
+
}
|
|
114
|
+
// --- harness-touching commands -------------------------------------------
|
|
115
|
+
async function runInstallCommand(rest, options) {
|
|
116
|
+
const { positionals, flags } = parseArgs(rest);
|
|
117
|
+
const shell = options.shell ?? resolveShellFlag(flags);
|
|
118
|
+
const prompter = options.prompter ?? createPrompter();
|
|
119
|
+
try {
|
|
120
|
+
const outcome = await runInstall(positionals, {
|
|
121
|
+
home: options.home,
|
|
122
|
+
shell,
|
|
123
|
+
prompter,
|
|
124
|
+
env: options.env,
|
|
125
|
+
});
|
|
126
|
+
// A mid-install failure makes the command non-zero so scripts notice; a
|
|
127
|
+
// pure skip (CLI absent) is a success.
|
|
128
|
+
return outcome.failed.length > 0 ? errOut(outcome.output) : ok(outcome.output);
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
// Tear down the shared readline (BUG 1) so an open interface doesn't keep
|
|
132
|
+
// the event loop alive and hang the process after the command completes.
|
|
133
|
+
prompter.close();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async function runUninstallCommand(rest, options) {
|
|
137
|
+
const { positionals, flags } = parseArgs(rest);
|
|
138
|
+
const shell = options.shell ?? resolveShellFlag(flags);
|
|
139
|
+
const prompter = options.prompter ?? createPrompter();
|
|
140
|
+
try {
|
|
141
|
+
const outcome = await runUninstall(positionals, { home: options.home, shell, prompter });
|
|
142
|
+
return outcome.failed.length > 0 ? errOut(outcome.output) : ok(outcome.output);
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
prompter.close();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
async function runUpdateCommand(rest, options) {
|
|
149
|
+
const { positionals } = parseArgs(rest);
|
|
150
|
+
const outcome = await runUpdate(positionals, { home: options.home });
|
|
151
|
+
return outcome.failed.length > 0 ? errOut(outcome.output) : ok(outcome.output);
|
|
152
|
+
}
|
|
153
|
+
// --- server command group (self-host) ------------------------------------
|
|
154
|
+
/**
|
|
155
|
+
* `librarian server [subcommand]`. With no subcommand (or `--help`/`-h`) it
|
|
156
|
+
* prints the command surface (§4). Implemented: `up` (S2/S3), `down` / `logs` /
|
|
157
|
+
* `status` (S4), `update` (S5), `enable-boot` / `disable-boot` (S6), `admin`
|
|
158
|
+
* (S7a). An unknown subcommand errors with the surface. Preflight + the
|
|
159
|
+
* `docker.ts` seam (S1) back every container op.
|
|
160
|
+
*/
|
|
161
|
+
async function runServerCommand(rest, options) {
|
|
162
|
+
const [subcommand, ...subRest] = rest;
|
|
163
|
+
if (!subcommand || subcommand === "--help" || subcommand === "-h") {
|
|
164
|
+
return ok(serverUsage());
|
|
165
|
+
}
|
|
166
|
+
if (subcommand === "up") {
|
|
167
|
+
return runServerUpCommand(subRest, options);
|
|
168
|
+
}
|
|
169
|
+
if (subcommand === "update") {
|
|
170
|
+
return runServerUpdateCommand(subRest, options);
|
|
171
|
+
}
|
|
172
|
+
if (subcommand === "down") {
|
|
173
|
+
return runServerDownCommand();
|
|
174
|
+
}
|
|
175
|
+
if (subcommand === "logs") {
|
|
176
|
+
return runServerLogsCommand(subRest);
|
|
177
|
+
}
|
|
178
|
+
if (subcommand === "status") {
|
|
179
|
+
return runServerStatusCommand(subRest, options);
|
|
180
|
+
}
|
|
181
|
+
if (subcommand === "enable-boot") {
|
|
182
|
+
return runServerEnableBootCommand(options);
|
|
183
|
+
}
|
|
184
|
+
if (subcommand === "disable-boot") {
|
|
185
|
+
return runServerDisableBootCommand(options);
|
|
186
|
+
}
|
|
187
|
+
if (subcommand === "admin") {
|
|
188
|
+
return runServerAdminCommand(subRest, options);
|
|
189
|
+
}
|
|
190
|
+
return err(`Unknown server subcommand: ${subcommand}\n\n${serverUsage()}`);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* `librarian server up [flags]` (S2, localhost path). Parses the flags, builds
|
|
194
|
+
* a prompter (for the loop-closer env offer), and runs the orchestrated flow.
|
|
195
|
+
* A failure surfaces as one clean stderr line via the top-level catch — no
|
|
196
|
+
* stack trace, and the master key (carried only on the success stdout) never
|
|
197
|
+
* reaches an error path.
|
|
198
|
+
*/
|
|
199
|
+
async function runServerUpCommand(rest, options) {
|
|
200
|
+
const { flags } = parseArgs(rest);
|
|
201
|
+
const prompter = options.prompter ?? createPrompter();
|
|
202
|
+
// Interactivity gates the best-effort offers (Tailscale; the `0.0.0.0`
|
|
203
|
+
// confirm). Explicit override wins; otherwise a TTY means interactive. A
|
|
204
|
+
// non-interactive run never silently exposes the server beyond localhost.
|
|
205
|
+
const interactive = options.interactive ?? Boolean(process.stdin.isTTY);
|
|
206
|
+
try {
|
|
207
|
+
const result = await runUp({
|
|
208
|
+
ref: flagString(flags.ref),
|
|
209
|
+
dir: flagString(flags.dir),
|
|
210
|
+
host: flagString(flags.host),
|
|
211
|
+
dataVolume: flagString(flags["data-volume"]),
|
|
212
|
+
enableBoot: flagBool(flags["enable-boot"]),
|
|
213
|
+
yes: flagBool(flags.yes),
|
|
214
|
+
}, {
|
|
215
|
+
home: options.home,
|
|
216
|
+
prompter,
|
|
217
|
+
interactive,
|
|
218
|
+
...(options.platform ? { platform: options.platform } : {}),
|
|
219
|
+
});
|
|
220
|
+
return ok(result.output);
|
|
221
|
+
}
|
|
222
|
+
finally {
|
|
223
|
+
prompter.close();
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* `librarian server enable-boot` (S6). On Linux, installs + enables the systemd
|
|
228
|
+
* unit that starts the existing named container on boot (the unit references the
|
|
229
|
+
* container by name and carries NO secret). On macOS, prints the deferred notice
|
|
230
|
+
* and exits 0 (NOT an error). A real failure surfaces as one clean stderr line.
|
|
231
|
+
*/
|
|
232
|
+
async function runServerEnableBootCommand(options) {
|
|
233
|
+
const result = await enableBoot(options.platform ? { platform: options.platform } : {});
|
|
234
|
+
return ok(result.output);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* `librarian server disable-boot` (S6). On Linux, disables + removes the systemd
|
|
238
|
+
* unit and reloads systemd; safe if already disabled/absent (a teaching message,
|
|
239
|
+
* no crash). On macOS, prints the deferred notice and exits 0.
|
|
240
|
+
*/
|
|
241
|
+
async function runServerDisableBootCommand(options) {
|
|
242
|
+
const result = await disableBoot(options.platform ? { platform: options.platform } : {});
|
|
243
|
+
return ok(result.output);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* `librarian server admin <backup|restore|auth|rebuild> [args…]` (S7a). Runs a
|
|
247
|
+
* curated admin verb inside the running container via
|
|
248
|
+
* `docker exec [-it] the-librarian the-librarian <verb> [args…]` (spec §7). The
|
|
249
|
+
* args are passed through VERBATIM — so we do NOT run them through `parseArgs`
|
|
250
|
+
* (that would reorder/strip flags); the in-container CLI parses them. An
|
|
251
|
+
* interactive run adds `-it` so the CLI can prompt (e.g. `restore`'s
|
|
252
|
+
* `--secret-key`). A rejected verb or a down container surfaces as one clean
|
|
253
|
+
* stderr line via the top-level catch, with no `docker exec`.
|
|
254
|
+
*/
|
|
255
|
+
async function runServerAdminCommand(subRest, options) {
|
|
256
|
+
const interactive = options.interactive ?? Boolean(process.stdin.isTTY);
|
|
257
|
+
const result = await runAdmin(subRest, {
|
|
258
|
+
interactive,
|
|
259
|
+
...(options.platform ? { platform: options.platform } : {}),
|
|
260
|
+
});
|
|
261
|
+
return ok(result.output);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* `librarian server update [--ref <tag|main>] [--yes]` (S5). Re-pins the deploy
|
|
265
|
+
* dir to the resolved ref, rebuilds the image, recreates the container
|
|
266
|
+
* (PRESERVING the data volume), waits for health (rolling back on failure), and
|
|
267
|
+
* applies pending data-dir migrations. Idempotent: already at the ref + healthy
|
|
268
|
+
* → a clean no-op. The agent token is reused from the running container (clients
|
|
269
|
+
* keep working) and never reaches an error path or a file. A failure surfaces as
|
|
270
|
+
* one clean stderr line via the top-level catch (already secret-redacted).
|
|
271
|
+
*/
|
|
272
|
+
async function runServerUpdateCommand(rest, options) {
|
|
273
|
+
const { flags } = parseArgs(rest);
|
|
274
|
+
const result = await runServerUpdate({
|
|
275
|
+
ref: flagString(flags.ref),
|
|
276
|
+
dir: flagString(flags.dir),
|
|
277
|
+
yes: flagBool(flags.yes),
|
|
278
|
+
home: options.home,
|
|
279
|
+
});
|
|
280
|
+
return ok(result.output);
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* `librarian server down` (S4). Stops the container — DATA SACRED (it issues
|
|
284
|
+
* only `docker stop`, never any `rm`/volume op). A not-running container is a
|
|
285
|
+
* friendly success; a real failure surfaces via the top-level catch as one
|
|
286
|
+
* clean stderr line. No flags today.
|
|
287
|
+
*/
|
|
288
|
+
async function runServerDownCommand() {
|
|
289
|
+
const result = await runDown({});
|
|
290
|
+
return ok(result.output);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* `librarian server logs [-f] [--service mcp|dashboard|all]` (S4). `-f` is a
|
|
294
|
+
* short flag the tiny parser treats as a positional, so we accept it there (or
|
|
295
|
+
* `--follow`). `--service` selects which of the two co-located services to show
|
|
296
|
+
* (filtered from the combined stream). A bad `--service` value is a teaching
|
|
297
|
+
* error via the top-level catch.
|
|
298
|
+
*
|
|
299
|
+
* A FOLLOW (`-f`) streams its lines straight to `process.stdout` LIVE inside
|
|
300
|
+
* `runLogs` (a tail never closes on its own — buffering it to return here is the
|
|
301
|
+
* old hang), so there's no captured `output` to print; we just propagate the
|
|
302
|
+
* followed process's exit code. The one-shot path returns its captured output.
|
|
303
|
+
*/
|
|
304
|
+
async function runServerLogsCommand(rest) {
|
|
305
|
+
const { positionals, flags } = parseArgs(rest);
|
|
306
|
+
const follow = positionals.includes("-f") || flagBool(flags.follow) || flagBool(flags.f);
|
|
307
|
+
const result = await runLogs({ follow, service: flagString(flags.service) });
|
|
308
|
+
if (follow) {
|
|
309
|
+
// Lines already streamed live; pass through the follow's exit code.
|
|
310
|
+
return { stdout: "", stderr: "", exitCode: result.exitCode ?? 0 };
|
|
311
|
+
}
|
|
312
|
+
return ok(result.output);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* `librarian server status` (S4). Reports running/health (from `docker inspect`)
|
|
316
|
+
* and the deployed-vs-latest badge (deploy-state ref vs `fetchLatestVersion`).
|
|
317
|
+
* Offline/unknown degrades to `unknown`/`?` and still exits 0 — only a missing
|
|
318
|
+
* docker (preflight) makes it non-zero, via the top-level catch.
|
|
319
|
+
*/
|
|
320
|
+
async function runServerStatusCommand(rest, options) {
|
|
321
|
+
const { flags } = parseArgs(rest);
|
|
322
|
+
const result = await serverStatus({ home: options.home, dir: flagString(flags.dir) });
|
|
323
|
+
return ok(result.output);
|
|
324
|
+
}
|
|
325
|
+
// --- Phase 2 stubs (friendly "coming later") -----------------------------
|
|
326
|
+
function runPhase2Stub(command) {
|
|
327
|
+
const detail = command === "report"
|
|
328
|
+
? "Server reporting (the dashboard's Installs view) arrives in a later release."
|
|
329
|
+
: "Self-update of the CLI arrives in a later release. For now: `npm i -g @the-librarian/cli`.";
|
|
330
|
+
return ok(`librarian ${command}: coming in a later release.\n\n${detail}`);
|
|
331
|
+
}
|
|
332
|
+
// --- usage ---------------------------------------------------------------
|
|
333
|
+
export function usage() {
|
|
334
|
+
const harnesses = allHarnesses.map((h) => h.id).join(", ");
|
|
335
|
+
return [
|
|
336
|
+
"Usage: librarian <command> [harness…] [flags]",
|
|
337
|
+
"",
|
|
338
|
+
"Commands:",
|
|
339
|
+
" install [harness…] Install The Librarian into one or more harnesses",
|
|
340
|
+
" uninstall [harness…] Remove The Librarian from one or more harnesses",
|
|
341
|
+
" update [harness…] Update the integration to the current version",
|
|
342
|
+
" status Live table of harness / installed / version",
|
|
343
|
+
" doctor Diagnose token, server reachability, harness CLIs",
|
|
344
|
+
" config Show or set MCP URL, token, server URL",
|
|
345
|
+
" server Self-host the Librarian server (run `server` for its commands)",
|
|
346
|
+
" self-update Update the librarian CLI itself",
|
|
347
|
+
" report Push this machine's state to the server",
|
|
348
|
+
"",
|
|
349
|
+
"Flags:",
|
|
350
|
+
" --mcp-url <url> config: set the MCP endpoint URL",
|
|
351
|
+
" --token <token> config: set the bearer token (never printed)",
|
|
352
|
+
" --shell <bash|zsh|fish> override shell detection for the rc block",
|
|
353
|
+
" -h, --help Show this help",
|
|
354
|
+
" -v, --version Show the CLI version",
|
|
355
|
+
"",
|
|
356
|
+
`Harnesses: ${harnesses}`,
|
|
357
|
+
].join("\n");
|
|
358
|
+
}
|
|
359
|
+
// --- result helpers ------------------------------------------------------
|
|
360
|
+
function ok(stdout) {
|
|
361
|
+
return { stdout, stderr: "", exitCode: 0 };
|
|
362
|
+
}
|
|
363
|
+
function err(stderr) {
|
|
364
|
+
return { stdout: "", stderr, exitCode: 1 };
|
|
365
|
+
}
|
|
366
|
+
/** A non-zero result that still carries its (already-formatted) report on stdout. */
|
|
367
|
+
function errOut(stdout) {
|
|
368
|
+
return { stdout, stderr: "", exitCode: 1 };
|
|
369
|
+
}
|
|
370
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,EAAE;AACF,4EAA4E;AAC5E,wEAAwE;AACxE,6EAA6E;AAC7E,wEAAwE;AACxE,6EAA6E;AAC7E,8EAA8E;AAC9E,yEAAyE;AACzE,kBAAkB;AAElB,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAwB,MAAM,aAAa,CAAC;AAChG,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAc,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAgB,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAiB,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mB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sEAAsE;QACtE,4EAA4E;QAC5E,iEAAiE;QACjE,yFAAyF;QACzF,0DAA0D;QAC1D,kEAAkE;QAClE,EAAE;QACF,QAAQ;QACR,2DAA2D;QAC3D,uEAAuE;QACvE,sEAAsE;QACtE,wCAAwC;QACxC,8CAA8C;QAC9C,EAAE;QACF,cAAc,SAAS,EAAE;KAC1B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,4EAA4E;AAE5E,SAAS,EAAE,CAAC,MAAc;IACxB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;AAC7C,CAAC;AAED,SAAS,GAAG,CAAC,MAAc;IACzB,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;AAC7C,CAAC;AAED,qFAAqF;AACrF,SAAS,MAAM,CAAC,MAAc;IAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;AAC7C,CAAC"}
|
package/dist/semver.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compare two version strings. Returns <0 if `a` precedes `b`, >0 if `a`
|
|
3
|
+
* follows `b`, 0 if equal or either is unparseable (so an unknown version
|
|
4
|
+
* never reads as "behind").
|
|
5
|
+
*/
|
|
6
|
+
export declare function compareVersions(a: string, b: string): number;
|
|
7
|
+
/**
|
|
8
|
+
* True iff `installed` is strictly behind `latest`. Either side being unknown
|
|
9
|
+
* (empty / unparseable) yields `false` — the caller renders `?`, never a
|
|
10
|
+
* false "update available".
|
|
11
|
+
*/
|
|
12
|
+
export declare function isBehind(installed: string, latest: string): boolean;
|
|
13
|
+
//# sourceMappingURL=semver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semver.d.ts","sourceRoot":"","sources":["../src/semver.ts"],"names":[],"mappings":"AAoCA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAqB5D;AAyBD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAGnE"}
|