@the-librarian/cli 1.0.0-rc.5 → 1.0.0-rc.50
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 +53 -7
- package/dist/archive.d.ts +15 -0
- package/dist/archive.d.ts.map +1 -0
- package/dist/archive.js +58 -0
- package/dist/archive.js.map +1 -0
- package/dist/harnesses/codex.d.ts +13 -0
- package/dist/harnesses/codex.d.ts.map +1 -1
- package/dist/harnesses/codex.js +210 -26
- package/dist/harnesses/codex.js.map +1 -1
- package/dist/harnesses/hermes.d.ts +1 -1
- package/dist/harnesses/hermes.d.ts.map +1 -1
- package/dist/harnesses/hermes.js +42 -23
- package/dist/harnesses/hermes.js.map +1 -1
- package/dist/harnesses/opencode.d.ts +12 -0
- package/dist/harnesses/opencode.d.ts.map +1 -1
- package/dist/harnesses/opencode.js +122 -5
- package/dist/harnesses/opencode.js.map +1 -1
- package/dist/paths.d.ts +16 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/paths.js.map +1 -1
- package/dist/runtime.d.ts +14 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +230 -1
- package/dist/runtime.js.map +1 -1
- package/dist/server/admin.d.ts +31 -0
- package/dist/server/admin.d.ts.map +1 -0
- package/dist/server/admin.js +131 -0
- package/dist/server/admin.js.map +1 -0
- package/dist/server/autoupdate.d.ts +184 -0
- package/dist/server/autoupdate.d.ts.map +1 -0
- package/dist/server/autoupdate.js +794 -0
- package/dist/server/autoupdate.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 +40 -0
- package/dist/server/deploy-state.d.ts.map +1 -0
- package/dist/server/deploy-state.js +89 -0
- package/dist/server/deploy-state.js.map +1 -0
- package/dist/server/docker.d.ts +53 -0
- package/dist/server/docker.d.ts.map +1 -0
- package/dist/server/docker.js +166 -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 +50 -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 +244 -0
- package/dist/server/up.d.ts.map +1 -0
- package/dist/server/up.js +758 -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 +313 -0
- package/dist/server/update.js.map +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hermes.js","sourceRoot":"","sources":["../../src/harnesses/hermes.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAClB,EAAE;AACF,qEAAqE;AACrE,+DAA+D;AAC/D,oEAAoE;AACpE,EAAE;AACF,iEAAiE;AACjE,
|
|
1
|
+
{"version":3,"file":"hermes.js","sourceRoot":"","sources":["../../src/harnesses/hermes.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAClB,EAAE;AACF,qEAAqE;AACrE,+DAA+D;AAC/D,oEAAoE;AACpE,EAAE;AACF,iEAAiE;AACjE,8EAA8E;AAC9E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|
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
import type { HarnessModule } from "./types.js";
|
|
2
|
+
export declare const OPENCODE_CAPTURE_PINNED_REF: string;
|
|
3
|
+
/**
|
|
4
|
+
* Fetches the OpenCode capture integration for a pinned ref and returns the
|
|
5
|
+
* absolute path to a directory whose contents ARE the integration (the equivalent
|
|
6
|
+
* of `integrations/opencode/`, i.e. holding `plugin/**`). The caller copies from
|
|
7
|
+
* there. Injectable so tests substitute a local fixture instead of the network.
|
|
8
|
+
*/
|
|
9
|
+
export type CaptureFetcher = (ref: string) => Promise<string>;
|
|
10
|
+
/** Override the capture-adapter fetcher (tests inject a local-fixture fetcher). */
|
|
11
|
+
export declare function setOpencodeCaptureFetcher(next: CaptureFetcher): void;
|
|
12
|
+
/** Restore the default (network) capture-adapter fetcher (tests). */
|
|
13
|
+
export declare function resetOpencodeCaptureFetcher(): void;
|
|
2
14
|
export declare const opencode: HarnessModule;
|
|
3
15
|
//# sourceMappingURL=opencode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opencode.d.ts","sourceRoot":"","sources":["../../src/harnesses/opencode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"opencode.d.ts","sourceRoot":"","sources":["../../src/harnesses/opencode.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAiB,aAAa,EAAE,MAAM,YAAY,CAAC;AAyB/D,eAAO,MAAM,2BAA2B,QAAqB,CAAC;AA+E9D;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AA0B9D,mFAAmF;AACnF,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAEpE;AAED,qEAAqE;AACrE,wBAAgB,2BAA2B,IAAI,IAAI,CAElD;AAiDD,eAAO,MAAM,QAAQ,EAAE,aAoFtB,CAAC"}
|
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
//
|
|
3
3
|
// OpenCode has no native install command, so we edit its global config
|
|
4
4
|
// (`~/.config/opencode/opencode.json`) idempotently, preserving every key
|
|
5
|
-
// the user already had. We add
|
|
5
|
+
// the user already had. We add three things:
|
|
6
6
|
//
|
|
7
7
|
// - `mcp.librarian`: a remote MCP block (type/url/enabled/headers). The
|
|
8
8
|
// Authorization header references the env var, not the token value —
|
|
9
9
|
// `Bearer {env:LIBRARIAN_AGENT_TOKEN}` — so the secret never lands in
|
|
10
10
|
// the file (spec §9).
|
|
11
11
|
// - the primer entry `<serverUrl>/primer.md` in the `instructions` array.
|
|
12
|
+
// - the per-turn auto-capture PLUGIN (spec 2026-06-16-harness-auto-capture,
|
|
13
|
+
// Phase 2A): the OpenCode integration's `plugin/` tree is fetched from the
|
|
14
|
+
// pinned release tarball into `~/.librarian/opencode-capture` (exactly like
|
|
15
|
+
// the Codex/Hermes adapters), and the entry's absolute path is registered in
|
|
16
|
+
// opencode.json's `plugin` array so OpenCode loads it at startup.
|
|
12
17
|
//
|
|
13
18
|
// We stamp a managed version marker (`mcp.librarian._librarianVersion`) so
|
|
14
19
|
// detect can report a version, plus the EXACT primer URL we added
|
|
@@ -17,15 +22,39 @@
|
|
|
17
22
|
// `mcp.librarian` present. uninstall removes only the keys/entries we added,
|
|
18
23
|
// leaving the rest of the JSON intact.
|
|
19
24
|
import fs from "node:fs";
|
|
25
|
+
import os from "node:os";
|
|
20
26
|
import path from "node:path";
|
|
21
|
-
import {
|
|
27
|
+
import { extractAdapterSubtree } from "../archive.js";
|
|
28
|
+
import { opencodeCaptureDir, opencodeConfigPath } from "../paths.js";
|
|
29
|
+
import { cliVersion } from "../version.js";
|
|
22
30
|
const SERVER_ID = "librarian";
|
|
23
31
|
const TOKEN_ENV_VAR = "LIBRARIAN_AGENT_TOKEN";
|
|
24
|
-
|
|
32
|
+
// Stamp the CLI's own version into the managed block (DERIVED, not hardcoded)
|
|
33
|
+
// so `librarian status`/`update` can compare installed-vs-latest honestly. A
|
|
34
|
+
// static literal would freeze the label and — since semver ranks `1.0.0` above
|
|
35
|
+
// `1.0.0-rc.N` — make status report "no update" against a newer pre-release.
|
|
36
|
+
const MANAGED_VERSION = cliVersion();
|
|
25
37
|
const VERSION_KEY = "_librarianVersion";
|
|
26
38
|
// The exact primer instruction we added, stamped into the managed block so
|
|
27
39
|
// uninstall can target only it (and not a foreign `…/primer.md`).
|
|
28
40
|
const PRIMER_KEY = "_librarianPrimer";
|
|
41
|
+
// ── Auto-capture plugin wiring (spec 2026-06-16-harness-auto-capture, Phase 2A) ─
|
|
42
|
+
// The capture-adapter source (integrations/opencode/plugin/**) does NOT ship with
|
|
43
|
+
// the published installer (it ships only dist/), so — exactly like the
|
|
44
|
+
// Codex/Hermes adapters — we FETCH it from the pinned release tarball and copy it
|
|
45
|
+
// under ~/.librarian/opencode-capture; opencode.json's `plugin` array points at
|
|
46
|
+
// the entry there. SC1 (true e2e against a running OpenCode) is DEFERRED — there
|
|
47
|
+
// is no `opencode` CLI on the build machine to confirm a live turn.
|
|
48
|
+
// The pinned monorepo release we fetch the adapter from: the tag matching this
|
|
49
|
+
// CLI's own version. DERIVED (not hardcoded) so it can't drift — same rationale
|
|
50
|
+
// as the Codex/Hermes adapters' pinned refs.
|
|
51
|
+
export const OPENCODE_CAPTURE_PINNED_REF = `v${cliVersion()}`;
|
|
52
|
+
/** The capture plugin entry, relative to the fetched integration / install dir. */
|
|
53
|
+
const PLUGIN_ENTRY_REL = path.join("plugin", "librarian-capture.ts");
|
|
54
|
+
/** Absolute path of the installed capture-plugin entry (what `plugin[]` points at). */
|
|
55
|
+
function pluginEntryPath() {
|
|
56
|
+
return path.join(opencodeCaptureDir(), PLUGIN_ENTRY_REL);
|
|
57
|
+
}
|
|
29
58
|
/** The primer instruction entry derived from the server URL. */
|
|
30
59
|
function primerEntry(serverUrl) {
|
|
31
60
|
return `${serverUrl.replace(/\/+$/, "")}/primer.md`;
|
|
@@ -74,6 +103,83 @@ function getMcpEntry(config) {
|
|
|
74
103
|
}
|
|
75
104
|
return undefined;
|
|
76
105
|
}
|
|
106
|
+
/** The default fetcher: codeload tarball → `tar` extract → integration dir. */
|
|
107
|
+
const defaultCaptureFetcher = async (ref) => {
|
|
108
|
+
const url = `https://codeload.github.com/JimJafar/the-librarian/tar.gz/refs/tags/${ref}`;
|
|
109
|
+
const work = fs.mkdtempSync(path.join(os.tmpdir(), "librarian-opencode-fetch-"));
|
|
110
|
+
const tarball = path.join(work, "src.tar.gz");
|
|
111
|
+
const res = await fetch(url, { redirect: "error" });
|
|
112
|
+
if (!res.ok) {
|
|
113
|
+
throw new Error(`Failed to fetch OpenCode capture adapter (${ref}): HTTP ${res.status}`);
|
|
114
|
+
}
|
|
115
|
+
const buf = Buffer.from(await res.arrayBuffer());
|
|
116
|
+
fs.writeFileSync(tarball, buf);
|
|
117
|
+
// codeload nests the integration at `the-librarian-<ref>/integrations/opencode/**`;
|
|
118
|
+
// the returned dir holds its contents (`plugin/`), which is what the caller
|
|
119
|
+
// copies into ~/.librarian/.
|
|
120
|
+
try {
|
|
121
|
+
return await extractAdapterSubtree(tarball, work, "integrations/opencode");
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
125
|
+
throw new Error(`Failed to extract OpenCode capture adapter: ${msg}`);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
let captureFetcher = defaultCaptureFetcher;
|
|
129
|
+
/** Override the capture-adapter fetcher (tests inject a local-fixture fetcher). */
|
|
130
|
+
export function setOpencodeCaptureFetcher(next) {
|
|
131
|
+
captureFetcher = next;
|
|
132
|
+
}
|
|
133
|
+
/** Restore the default (network) capture-adapter fetcher (tests). */
|
|
134
|
+
export function resetOpencodeCaptureFetcher() {
|
|
135
|
+
captureFetcher = defaultCaptureFetcher;
|
|
136
|
+
}
|
|
137
|
+
/** Recursively copy a directory tree, overwriting any prior copy (idempotent). */
|
|
138
|
+
function copyDir(from, to) {
|
|
139
|
+
fs.rmSync(to, { recursive: true, force: true });
|
|
140
|
+
fs.mkdirSync(path.dirname(to), { recursive: true });
|
|
141
|
+
fs.cpSync(from, to, { recursive: true });
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Fetch + copy the capture plugin under ~/.librarian/opencode-capture, then
|
|
145
|
+
* register the entry's absolute path in opencode.json's `plugin` array
|
|
146
|
+
* (idempotent — never a duplicate, preserving any foreign plugins). Mutates +
|
|
147
|
+
* returns `config` so the caller writes it once alongside the mcp/primer edits.
|
|
148
|
+
*/
|
|
149
|
+
async function installCapturePlugin(config) {
|
|
150
|
+
const integrationDir = await captureFetcher(OPENCODE_CAPTURE_PINNED_REF);
|
|
151
|
+
copyDir(integrationDir, opencodeCaptureDir());
|
|
152
|
+
const entry = pluginEntryPath();
|
|
153
|
+
const existing = Array.isArray(config.plugin)
|
|
154
|
+
? config.plugin.filter((x) => typeof x === "string")
|
|
155
|
+
: [];
|
|
156
|
+
if (!existing.includes(entry))
|
|
157
|
+
existing.push(entry);
|
|
158
|
+
config.plugin = existing;
|
|
159
|
+
return config;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Remove our capture wiring: strip ONLY our `plugin` entry (preserving foreigns,
|
|
163
|
+
* dropping an emptied array) and delete the scripts dir. Mutates `config`; returns
|
|
164
|
+
* whether anything changed so the caller can decide to write.
|
|
165
|
+
*/
|
|
166
|
+
function uninstallCapturePlugin(config) {
|
|
167
|
+
let changed = false;
|
|
168
|
+
const ours = pluginEntryPath();
|
|
169
|
+
if (Array.isArray(config.plugin)) {
|
|
170
|
+
const before = config.plugin;
|
|
171
|
+
const kept = before.filter((x) => x !== ours);
|
|
172
|
+
if (kept.length !== before.length) {
|
|
173
|
+
changed = true;
|
|
174
|
+
if (kept.length === 0)
|
|
175
|
+
delete config.plugin;
|
|
176
|
+
else
|
|
177
|
+
config.plugin = kept;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
fs.rmSync(opencodeCaptureDir(), { recursive: true, force: true });
|
|
181
|
+
return changed;
|
|
182
|
+
}
|
|
77
183
|
export const opencode = {
|
|
78
184
|
id: "opencode",
|
|
79
185
|
displayName: "OpenCode",
|
|
@@ -100,12 +206,19 @@ export const opencode = {
|
|
|
100
206
|
if (!existing.includes(entry))
|
|
101
207
|
existing.push(entry);
|
|
102
208
|
config.instructions = existing;
|
|
209
|
+
// plugin — fetch + copy the per-turn capture plugin and register its entry in
|
|
210
|
+
// the `plugin` array (idempotent). Mutates `config`; written once below.
|
|
211
|
+
await installCapturePlugin(config);
|
|
103
212
|
writeConfig(config);
|
|
104
213
|
},
|
|
105
214
|
async uninstall() {
|
|
106
215
|
const config = readConfig();
|
|
107
|
-
if (!config)
|
|
108
|
-
|
|
216
|
+
if (!config) {
|
|
217
|
+
// No config to edit — but still remove the fetched capture scripts dir so an
|
|
218
|
+
// uninstall always cleans ~/.librarian/opencode-capture (mirrors Codex).
|
|
219
|
+
fs.rmSync(opencodeCaptureDir(), { recursive: true, force: true });
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
109
222
|
let changed = false;
|
|
110
223
|
// Read the EXACT primer entry we stamped before removing our block, so we
|
|
111
224
|
// can target only our own instruction and never a foreign `…/primer.md`.
|
|
@@ -131,6 +244,10 @@ export const opencode = {
|
|
|
131
244
|
config.instructions = kept;
|
|
132
245
|
}
|
|
133
246
|
}
|
|
247
|
+
// Remove our capture-plugin entry + delete the fetched scripts dir (always —
|
|
248
|
+
// the dir removal is independent of whether the config carried our entry).
|
|
249
|
+
if (uninstallCapturePlugin(config))
|
|
250
|
+
changed = true;
|
|
134
251
|
if (changed)
|
|
135
252
|
writeConfig(config);
|
|
136
253
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opencode.js","sourceRoot":"","sources":["../../src/harnesses/opencode.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,EAAE;AACF,uEAAuE;AACvE,0EAA0E;AAC1E,
|
|
1
|
+
{"version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AC;YAChD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;YACnD,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;gBAClC,OAAO,GAAG,IAAI,CAAC;gBACf,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;oBAAE,OAAO,MAAM,CAAC,YAAY,CAAC;;oBAC7C,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;YAClC,CAAC;QACH,CAAC;QAED,6EAA6E;QAC7E,2EAA2E;QAC3E,IAAI,sBAAsB,CAAC,MAAM,CAAC;YAAE,OAAO,GAAG,IAAI,CAAC;QAEnD,IAAI,OAAO;YAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAkB;QAC7B,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;CACF,CAAC"}
|
package/dist/paths.d.ts
CHANGED
|
@@ -21,8 +21,24 @@ export declare function bashRcPath(home?: string): string;
|
|
|
21
21
|
export declare function zshRcPath(home?: string): string;
|
|
22
22
|
/** `~/.codex/config.toml` — Codex's MCP-server config. */
|
|
23
23
|
export declare function codexConfigPath(home?: string): string;
|
|
24
|
+
/** `~/.codex/hooks.json` — Codex's lifecycle-hooks config (merged into, not owned). */
|
|
25
|
+
export declare function codexHooksPath(home?: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* `~/.librarian/codex-capture` — where the Codex auto-capture adapter scripts are
|
|
28
|
+
* installed (fetched from the pinned release tarball, like the Hermes adapter).
|
|
29
|
+
* The merged `~/.codex/hooks.json` entries point their `${LIBRARIAN_CODEX_ROOT}`
|
|
30
|
+
* here. Kept under `~/.librarian/` so an uninstall can remove it cleanly.
|
|
31
|
+
*/
|
|
32
|
+
export declare function codexCaptureDir(home?: string): string;
|
|
24
33
|
/** `~/.config/opencode/opencode.json` — OpenCode's global config. */
|
|
25
34
|
export declare function opencodeConfigPath(home?: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* `~/.librarian/opencode-capture` — where the OpenCode auto-capture plugin is
|
|
37
|
+
* installed (fetched from the pinned release tarball, like the Codex/Hermes
|
|
38
|
+
* adapters). opencode.json's `plugin` array points at the entry under here. Kept
|
|
39
|
+
* under `~/.librarian/` so an uninstall can remove it cleanly.
|
|
40
|
+
*/
|
|
41
|
+
export declare function opencodeCaptureDir(home?: string): string;
|
|
26
42
|
/** `~/.hermes` — Hermes's home (plugins + config live under here). */
|
|
27
43
|
export declare function hermesHomeDir(home?: string): string;
|
|
28
44
|
/** `~/.hermes/plugins/librarian` — where the Hermes adapter is installed. */
|
package/dist/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAkBA,oEAAoE;AACpE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAE9D;AAED,iEAAiE;AACjE,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,gEAAgE;AAChE,wBAAgB,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,uEAAuE;AACvE,wBAAgB,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,mBAAmB;AACnB,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,k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B,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,0DAA0D;AAC1D,wBAAgB,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,uFAAuF;AACvF,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,sEAAsE;AACtE,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtD"}
|
package/dist/paths.js
CHANGED
|
@@ -56,10 +56,32 @@ export function zshRcPath(home) {
|
|
|
56
56
|
export function codexConfigPath(home) {
|
|
57
57
|
return path.join(homeDir(home), ".codex", "config.toml");
|
|
58
58
|
}
|
|
59
|
+
/** `~/.codex/hooks.json` — Codex's lifecycle-hooks config (merged into, not owned). */
|
|
60
|
+
export function codexHooksPath(home) {
|
|
61
|
+
return path.join(homeDir(home), ".codex", "hooks.json");
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* `~/.librarian/codex-capture` — where the Codex auto-capture adapter scripts are
|
|
65
|
+
* installed (fetched from the pinned release tarball, like the Hermes adapter).
|
|
66
|
+
* The merged `~/.codex/hooks.json` entries point their `${LIBRARIAN_CODEX_ROOT}`
|
|
67
|
+
* here. Kept under `~/.librarian/` so an uninstall can remove it cleanly.
|
|
68
|
+
*/
|
|
69
|
+
export function codexCaptureDir(home) {
|
|
70
|
+
return path.join(librarianDir(home), "codex-capture");
|
|
71
|
+
}
|
|
59
72
|
/** `~/.config/opencode/opencode.json` — OpenCode's global config. */
|
|
60
73
|
export function opencodeConfigPath(home) {
|
|
61
74
|
return path.join(homeDir(home), ".config", "opencode", "opencode.json");
|
|
62
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* `~/.librarian/opencode-capture` — where the OpenCode auto-capture plugin is
|
|
78
|
+
* installed (fetched from the pinned release tarball, like the Codex/Hermes
|
|
79
|
+
* adapters). opencode.json's `plugin` array points at the entry under here. Kept
|
|
80
|
+
* under `~/.librarian/` so an uninstall can remove it cleanly.
|
|
81
|
+
*/
|
|
82
|
+
export function opencodeCaptureDir(home) {
|
|
83
|
+
return path.join(librarianDir(home), "opencode-capture");
|
|
84
|
+
}
|
|
63
85
|
/** `~/.hermes` — Hermes's home (plugins + config live under here). */
|
|
64
86
|
export function hermesHomeDir(home) {
|
|
65
87
|
return path.join(homeDir(home), ".hermes");
|
package/dist/paths.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,EAAE;AACF,oEAAoE;AACpE,kEAAkE;AAClE,qEAAqE;AACrE,mEAAmE;AACnE,yCAAyC;AAEzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,sEAAsE;AACtE,uEAAuE;AACvE,2EAA2E;AAC3E,yEAAyE;AACzE,gCAAgC;AAChC,IAAI,YAAgC,CAAC;AAErC,oEAAoE;AACpE,MAAM,UAAU,eAAe,CAAC,IAAwB;IACtD,YAAY,GAAG,IAAI,CAAC;AACtB,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,iBAAiB;IAC/B,YAAY,GAAG,SAAS,C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AAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;AAC1D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,IAAa;IAC3C,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC,CAAC;AACxD,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,kBAAkB,CAAC,IAAa;IAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAa;IAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,kBAAkB,CAAC,CAAC;AAC3D,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,aAAa,CAAC,IAAa;IACzC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;AAC7C,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,eAAe,CAAC,IAAa;IAC3C,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AAChE,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,gBAAgB,CAAC,IAAa;IAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,CAAC;AACvD,CAAC"}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -18,6 +18,20 @@ export interface RuntimeOptions {
|
|
|
18
18
|
* token. Defaults to `process.env` in `runInstall`.
|
|
19
19
|
*/
|
|
20
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;
|
|
21
35
|
}
|
|
22
36
|
/**
|
|
23
37
|
* The CLI entrypoint. Dispatches to the command handlers and — crucially —
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +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;
|
|
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;AAmB/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;AAoXD,wBAAgB,KAAK,IAAI,MAAM,CAyB9B"}
|
package/dist/runtime.js
CHANGED
|
@@ -15,8 +15,17 @@ import { formatConfig, readConfig, redact, setConfig } from "./config.js";
|
|
|
15
15
|
import { doctor } from "./doctor.js";
|
|
16
16
|
import { detectShell } from "./env.js";
|
|
17
17
|
import { allHarnesses } from "./harnesses/index.js";
|
|
18
|
-
import { flagString, parseArgs } from "./parse-args.js";
|
|
18
|
+
import { flagBool, flagString, parseArgs } from "./parse-args.js";
|
|
19
19
|
import { createPrompter, MissingValueError } from "./prompt.js";
|
|
20
|
+
import { runAdmin } from "./server/admin.js";
|
|
21
|
+
import { autoUpdateStatus, disableAutoUpdate, enableAutoUpdate, runAutoUpdate, uninstallAutoUpdate, } from "./server/autoupdate.js";
|
|
22
|
+
import { disableBoot, enableBoot } from "./server/boot.js";
|
|
23
|
+
import { runDown } from "./server/down.js";
|
|
24
|
+
import { serverUsage } from "./server/index.js";
|
|
25
|
+
import { runLogs } from "./server/logs.js";
|
|
26
|
+
import { serverStatus } from "./server/status.js";
|
|
27
|
+
import { runUp } from "./server/up.js";
|
|
28
|
+
import { runUpdate as runServerUpdate } from "./server/update.js";
|
|
20
29
|
import { status } from "./status.js";
|
|
21
30
|
import { cliVersion } from "./version.js";
|
|
22
31
|
const PHASE_2_STUBS = new Set(["report", "self-update"]);
|
|
@@ -66,6 +75,9 @@ async function dispatch(argv, options) {
|
|
|
66
75
|
// Diagnostic: exits 0 even when it flags problems.
|
|
67
76
|
return ok(await doctor(options.home));
|
|
68
77
|
}
|
|
78
|
+
if (command === "server") {
|
|
79
|
+
return runServerCommand(rest, options);
|
|
80
|
+
}
|
|
69
81
|
if (PHASE_2_STUBS.has(command)) {
|
|
70
82
|
return runPhase2Stub(command);
|
|
71
83
|
}
|
|
@@ -139,6 +151,222 @@ async function runUpdateCommand(rest, options) {
|
|
|
139
151
|
const outcome = await runUpdate(positionals, { home: options.home });
|
|
140
152
|
return outcome.failed.length > 0 ? errOut(outcome.output) : ok(outcome.output);
|
|
141
153
|
}
|
|
154
|
+
// --- server command group (self-host) ------------------------------------
|
|
155
|
+
/**
|
|
156
|
+
* `librarian server [subcommand]`. With no subcommand (or `--help`/`-h`) it
|
|
157
|
+
* prints the command surface (§4). Implemented: `up` (S2/S3), `down` / `logs` /
|
|
158
|
+
* `status` (S4), `update` (S5), `enable-boot` / `disable-boot` (S6), `admin`
|
|
159
|
+
* (S7a). An unknown subcommand errors with the surface. Preflight + the
|
|
160
|
+
* `docker.ts` seam (S1) back every container op.
|
|
161
|
+
*/
|
|
162
|
+
async function runServerCommand(rest, options) {
|
|
163
|
+
const [subcommand, ...subRest] = rest;
|
|
164
|
+
if (!subcommand || subcommand === "--help" || subcommand === "-h") {
|
|
165
|
+
return ok(serverUsage());
|
|
166
|
+
}
|
|
167
|
+
if (subcommand === "up") {
|
|
168
|
+
return runServerUpCommand(subRest, options);
|
|
169
|
+
}
|
|
170
|
+
if (subcommand === "update") {
|
|
171
|
+
return runServerUpdateCommand(subRest, options);
|
|
172
|
+
}
|
|
173
|
+
if (subcommand === "down") {
|
|
174
|
+
return runServerDownCommand();
|
|
175
|
+
}
|
|
176
|
+
if (subcommand === "logs") {
|
|
177
|
+
return runServerLogsCommand(subRest);
|
|
178
|
+
}
|
|
179
|
+
if (subcommand === "status") {
|
|
180
|
+
return runServerStatusCommand(subRest, options);
|
|
181
|
+
}
|
|
182
|
+
if (subcommand === "enable-boot") {
|
|
183
|
+
return runServerEnableBootCommand(options);
|
|
184
|
+
}
|
|
185
|
+
if (subcommand === "disable-boot") {
|
|
186
|
+
return runServerDisableBootCommand(options);
|
|
187
|
+
}
|
|
188
|
+
if (subcommand === "autoupdate") {
|
|
189
|
+
return runServerAutoUpdateCommand(subRest, options);
|
|
190
|
+
}
|
|
191
|
+
if (subcommand === "admin") {
|
|
192
|
+
return runServerAdminCommand(subRest, options);
|
|
193
|
+
}
|
|
194
|
+
return err(`Unknown server subcommand: ${subcommand}\n\n${serverUsage()}`);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* `librarian server up [flags]` (S2, localhost path). Parses the flags, builds
|
|
198
|
+
* a prompter (for the loop-closer env offer), and runs the orchestrated flow.
|
|
199
|
+
* A failure surfaces as one clean stderr line via the top-level catch — no
|
|
200
|
+
* stack trace, and the master key (carried only on the success stdout) never
|
|
201
|
+
* reaches an error path.
|
|
202
|
+
*/
|
|
203
|
+
async function runServerUpCommand(rest, options) {
|
|
204
|
+
const { flags } = parseArgs(rest);
|
|
205
|
+
const prompter = options.prompter ?? createPrompter();
|
|
206
|
+
// Interactivity gates the best-effort offers (Tailscale; the `0.0.0.0`
|
|
207
|
+
// confirm). Explicit override wins; otherwise a TTY means interactive. A
|
|
208
|
+
// non-interactive run never silently exposes the server beyond localhost.
|
|
209
|
+
const interactive = options.interactive ?? Boolean(process.stdin.isTTY);
|
|
210
|
+
try {
|
|
211
|
+
const result = await runUp({
|
|
212
|
+
ref: flagString(flags.ref),
|
|
213
|
+
dir: flagString(flags.dir),
|
|
214
|
+
host: flagString(flags.host),
|
|
215
|
+
dataVolume: flagString(flags["data-volume"]),
|
|
216
|
+
dataDir: flagString(flags["data-dir"]),
|
|
217
|
+
enableBoot: flagBool(flags["enable-boot"]),
|
|
218
|
+
yes: flagBool(flags.yes),
|
|
219
|
+
}, {
|
|
220
|
+
home: options.home,
|
|
221
|
+
prompter,
|
|
222
|
+
interactive,
|
|
223
|
+
...(options.platform ? { platform: options.platform } : {}),
|
|
224
|
+
});
|
|
225
|
+
return ok(result.output);
|
|
226
|
+
}
|
|
227
|
+
finally {
|
|
228
|
+
prompter.close();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* `librarian server enable-boot` (S6). On Linux, installs + enables the systemd
|
|
233
|
+
* unit that starts the existing named container on boot (the unit references the
|
|
234
|
+
* container by name and carries NO secret). On macOS, prints the deferred notice
|
|
235
|
+
* and exits 0 (NOT an error). A real failure surfaces as one clean stderr line.
|
|
236
|
+
*/
|
|
237
|
+
async function runServerEnableBootCommand(options) {
|
|
238
|
+
const result = await enableBoot(options.platform ? { platform: options.platform } : {});
|
|
239
|
+
return ok(result.output);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* `librarian server disable-boot` (S6). On Linux, disables + removes the systemd
|
|
243
|
+
* unit and reloads systemd; safe if already disabled/absent (a teaching message,
|
|
244
|
+
* no crash). On macOS, prints the deferred notice and exits 0.
|
|
245
|
+
*/
|
|
246
|
+
async function runServerDisableBootCommand(options) {
|
|
247
|
+
const result = await disableBoot(options.platform ? { platform: options.platform } : {});
|
|
248
|
+
return ok(result.output);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* `librarian server autoupdate <enable|disable|uninstall|status> [--cadence …]`
|
|
252
|
+
* and the internal `--run` (T3). `enable` installs a host scheduler (systemd timer
|
|
253
|
+
* / cron fallback) that fires hourly and runs `--run`, plus writes enabled+cadence
|
|
254
|
+
* into the running server (so the dashboard reflects it). `disable` flips the
|
|
255
|
+
* setting off (timer stays). `uninstall` removes the timer/cron. `status` reports
|
|
256
|
+
* timer-installed + the server's enabled/cadence/last-run + up-to-date. `--run` is
|
|
257
|
+
* the wrapper the timer calls: it reads the settings from the running server,
|
|
258
|
+
* applies the due-check, and conditionally runs `server update` — FULLY fail-soft
|
|
259
|
+
* (never throws out of the timer). A real failure on the operator-facing verbs
|
|
260
|
+
* surfaces as one clean stderr line via the top-level catch.
|
|
261
|
+
*/
|
|
262
|
+
async function runServerAutoUpdateCommand(subRest, options) {
|
|
263
|
+
const { positionals, flags } = parseArgs(subRest);
|
|
264
|
+
const platformOpt = options.platform ? { platform: options.platform } : {};
|
|
265
|
+
const base = { home: options.home, dir: flagString(flags.dir), ...platformOpt };
|
|
266
|
+
// `--run` is the timer's wrapper. It is fail-soft by construction (it never
|
|
267
|
+
// throws) and always exits 0 so the timer's unit never fails; its one-line
|
|
268
|
+
// outcome is its stdout.
|
|
269
|
+
if (flagBool(flags.run)) {
|
|
270
|
+
const result = await runAutoUpdate(base);
|
|
271
|
+
return ok(result.output);
|
|
272
|
+
}
|
|
273
|
+
const [verb] = positionals;
|
|
274
|
+
if (verb === "enable") {
|
|
275
|
+
const result = await enableAutoUpdate({ ...base, cadence: flagString(flags.cadence) });
|
|
276
|
+
return ok(result.output);
|
|
277
|
+
}
|
|
278
|
+
if (verb === "disable") {
|
|
279
|
+
return ok((await disableAutoUpdate(base)).output);
|
|
280
|
+
}
|
|
281
|
+
if (verb === "uninstall") {
|
|
282
|
+
return ok((await uninstallAutoUpdate(base)).output);
|
|
283
|
+
}
|
|
284
|
+
if (verb === "status" || verb === undefined) {
|
|
285
|
+
return ok((await autoUpdateStatus(base)).output);
|
|
286
|
+
}
|
|
287
|
+
return err(`Unknown autoupdate subcommand: ${verb}\n\n` +
|
|
288
|
+
"Usage: librarian server autoupdate <enable|disable|uninstall|status> [--cadence daily|weekly]");
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* `librarian server admin <backup|restore|auth|rebuild> [args…]` (S7a). Runs a
|
|
292
|
+
* curated admin verb inside the running container via
|
|
293
|
+
* `docker exec [-it] the-librarian the-librarian <verb> [args…]` (spec §7). The
|
|
294
|
+
* args are passed through VERBATIM — so we do NOT run them through `parseArgs`
|
|
295
|
+
* (that would reorder/strip flags); the in-container CLI parses them. An
|
|
296
|
+
* interactive run adds `-it` so the CLI can prompt (e.g. `restore`'s
|
|
297
|
+
* `--secret-key`). A rejected verb or a down container surfaces as one clean
|
|
298
|
+
* stderr line via the top-level catch, with no `docker exec`.
|
|
299
|
+
*/
|
|
300
|
+
async function runServerAdminCommand(subRest, options) {
|
|
301
|
+
const interactive = options.interactive ?? Boolean(process.stdin.isTTY);
|
|
302
|
+
const result = await runAdmin(subRest, {
|
|
303
|
+
interactive,
|
|
304
|
+
...(options.platform ? { platform: options.platform } : {}),
|
|
305
|
+
});
|
|
306
|
+
return ok(result.output);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* `librarian server update [--ref <tag|main>] [--yes]` (S5). Re-pins the deploy
|
|
310
|
+
* dir to the resolved ref, rebuilds the image, recreates the container
|
|
311
|
+
* (PRESERVING the data volume), waits for health (rolling back on failure), and
|
|
312
|
+
* applies pending data-dir migrations. Idempotent: already at the ref + healthy
|
|
313
|
+
* → a clean no-op. The agent token is reused from the running container (clients
|
|
314
|
+
* keep working) and never reaches an error path or a file. A failure surfaces as
|
|
315
|
+
* one clean stderr line via the top-level catch (already secret-redacted).
|
|
316
|
+
*/
|
|
317
|
+
async function runServerUpdateCommand(rest, options) {
|
|
318
|
+
const { flags } = parseArgs(rest);
|
|
319
|
+
const result = await runServerUpdate({
|
|
320
|
+
ref: flagString(flags.ref),
|
|
321
|
+
dir: flagString(flags.dir),
|
|
322
|
+
yes: flagBool(flags.yes),
|
|
323
|
+
home: options.home,
|
|
324
|
+
});
|
|
325
|
+
return ok(result.output);
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* `librarian server down` (S4). Stops the container — DATA SACRED (it issues
|
|
329
|
+
* only `docker stop`, never any `rm`/volume op). A not-running container is a
|
|
330
|
+
* friendly success; a real failure surfaces via the top-level catch as one
|
|
331
|
+
* clean stderr line. No flags today.
|
|
332
|
+
*/
|
|
333
|
+
async function runServerDownCommand() {
|
|
334
|
+
const result = await runDown({});
|
|
335
|
+
return ok(result.output);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* `librarian server logs [-f] [--service mcp|dashboard|all]` (S4). `-f` is a
|
|
339
|
+
* short flag the tiny parser treats as a positional, so we accept it there (or
|
|
340
|
+
* `--follow`). `--service` selects which of the two co-located services to show
|
|
341
|
+
* (filtered from the combined stream). A bad `--service` value is a teaching
|
|
342
|
+
* error via the top-level catch.
|
|
343
|
+
*
|
|
344
|
+
* A FOLLOW (`-f`) streams its lines straight to `process.stdout` LIVE inside
|
|
345
|
+
* `runLogs` (a tail never closes on its own — buffering it to return here is the
|
|
346
|
+
* old hang), so there's no captured `output` to print; we just propagate the
|
|
347
|
+
* followed process's exit code. The one-shot path returns its captured output.
|
|
348
|
+
*/
|
|
349
|
+
async function runServerLogsCommand(rest) {
|
|
350
|
+
const { positionals, flags } = parseArgs(rest);
|
|
351
|
+
const follow = positionals.includes("-f") || flagBool(flags.follow) || flagBool(flags.f);
|
|
352
|
+
const result = await runLogs({ follow, service: flagString(flags.service) });
|
|
353
|
+
if (follow) {
|
|
354
|
+
// Lines already streamed live; pass through the follow's exit code.
|
|
355
|
+
return { stdout: "", stderr: "", exitCode: result.exitCode ?? 0 };
|
|
356
|
+
}
|
|
357
|
+
return ok(result.output);
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* `librarian server status` (S4). Reports running/health (from `docker inspect`)
|
|
361
|
+
* and the deployed-vs-latest badge (deploy-state ref vs `fetchLatestVersion`).
|
|
362
|
+
* Offline/unknown degrades to `unknown`/`?` and still exits 0 — only a missing
|
|
363
|
+
* docker (preflight) makes it non-zero, via the top-level catch.
|
|
364
|
+
*/
|
|
365
|
+
async function runServerStatusCommand(rest, options) {
|
|
366
|
+
const { flags } = parseArgs(rest);
|
|
367
|
+
const result = await serverStatus({ home: options.home, dir: flagString(flags.dir) });
|
|
368
|
+
return ok(result.output);
|
|
369
|
+
}
|
|
142
370
|
// --- Phase 2 stubs (friendly "coming later") -----------------------------
|
|
143
371
|
function runPhase2Stub(command) {
|
|
144
372
|
const detail = command === "report"
|
|
@@ -159,6 +387,7 @@ export function usage() {
|
|
|
159
387
|
" status Live table of harness / installed / version",
|
|
160
388
|
" doctor Diagnose token, server reachability, harness CLIs",
|
|
161
389
|
" config Show or set MCP URL, token, server URL",
|
|
390
|
+
" server Self-host the Librarian server (run `server` for its commands)",
|
|
162
391
|
" self-update Update the librarian CLI itself",
|
|
163
392
|
" report Push this machine's state to the server",
|
|
164
393
|
"",
|