benignswarm 0.12.82 → 0.12.83
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/dist/admin-index.js +6 -2
- package/dist/args.js +3 -3
- package/dist/brief.js +42 -8
- package/dist/client.js +4 -4
- package/dist/commands/admin.js +55 -16
- package/dist/commands/agent.js +33 -9
- package/dist/commands/antigravity.js +2 -2
- package/dist/commands/codex-start.js +17 -17
- package/dist/commands/codex.js +6 -6
- package/dist/commands/evidence.js +16 -1
- package/dist/commands/goal.js +5 -5
- package/dist/commands/hook.js +125 -57
- package/dist/commands/install.js +34 -28
- package/dist/commands/join.js +15 -14
- package/dist/commands/lists.js +2 -2
- package/dist/commands/machine-admin.js +56 -28
- package/dist/commands/machine.js +53 -29
- package/dist/commands/measures.js +191 -0
- package/dist/commands/notices.js +53 -0
- package/dist/commands/operator.js +68 -25
- package/dist/commands/retire.js +2 -2
- package/dist/commands/wake.js +4 -4
- package/dist/commands/watch.js +75 -28
- package/dist/commands/worktrees.js +4 -4
- package/dist/commands/wu.js +168 -61
- package/dist/config.js +11 -11
- package/dist/directories.js +83 -0
- package/dist/env-aliases.js +10 -0
- package/dist/git.js +2 -2
- package/dist/harness.js +91 -37
- package/dist/harnesses.js +5 -4
- package/dist/help.js +208 -183
- package/dist/index.js +37 -3
- package/dist/install.js +27 -19
- package/dist/legacy-alias.js +32 -0
- package/dist/notices.js +107 -0
- package/dist/output.js +2 -1
- package/dist/sessions.js +1 -1
- package/dist/update.js +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -24,6 +24,13 @@ import { HELP } from "./help.js";
|
|
|
24
24
|
import { CLI_VERSION } from "./version.js";
|
|
25
25
|
import { makeOut } from "./output.js";
|
|
26
26
|
import { resume } from "./brief.js";
|
|
27
|
+
import { measure, measures } from "./commands/measures.js";
|
|
28
|
+
import { applyEnvAliases } from "./env-aliases.js";
|
|
29
|
+
import { commandLine } from "./notices.js";
|
|
30
|
+
import { commandWarnings } from "./commands/hook.js";
|
|
31
|
+
import { loadAgent, resolveAgentName } from "./config.js";
|
|
32
|
+
import { agentNotice } from "./commands/notices.js";
|
|
33
|
+
import { warnLegacyAlias } from "./legacy-alias.js";
|
|
27
34
|
const COMMANDS = {
|
|
28
35
|
join,
|
|
29
36
|
setup,
|
|
@@ -32,6 +39,7 @@ const COMMANDS = {
|
|
|
32
39
|
identities: a.identities,
|
|
33
40
|
me: a.me,
|
|
34
41
|
resume,
|
|
42
|
+
notice: agentNotice,
|
|
35
43
|
who: a.who,
|
|
36
44
|
status: a.status,
|
|
37
45
|
away: a.away,
|
|
@@ -84,18 +92,27 @@ const COMMANDS = {
|
|
|
84
92
|
"ask-operator": askOperator,
|
|
85
93
|
explain: explainAsk,
|
|
86
94
|
worktrees,
|
|
95
|
+
measures,
|
|
96
|
+
measure,
|
|
87
97
|
follow: a.followCmd,
|
|
88
98
|
unfollow: a.followCmd,
|
|
89
99
|
following: a.followCmd,
|
|
90
100
|
admin: async () => {
|
|
91
|
-
throw new CliError("moved", "operator commands are in
|
|
101
|
+
throw new CliError("moved", "operator commands are in b9s-admin, which ships with this package", "Run: b9s-admin --help (agents never need it)");
|
|
92
102
|
},
|
|
93
103
|
};
|
|
104
|
+
// These commands establish identity, own their startup validation, or inspect/change only local
|
|
105
|
+
// machine state. Their dispatch must run before any notice lookup attempts to load an agent.
|
|
106
|
+
const NOTICE_PREFLIGHT_EXEMPT_COMMANDS = new Set([
|
|
107
|
+
"join", "setup", "login", "logout", "identities", "skill", "hook", "machine", "install", "doctor", "update", "version", "admin", "start",
|
|
108
|
+
]);
|
|
94
109
|
async function main(argv) {
|
|
110
|
+
warnLegacyAlias();
|
|
111
|
+
applyEnvAliases();
|
|
95
112
|
const p = parse(argv);
|
|
96
113
|
const out = makeOut(bool(p.flags, "json"));
|
|
97
114
|
if (bool(p.flags, "version")) {
|
|
98
|
-
process.stdout.write(`
|
|
115
|
+
process.stdout.write(`b9s ${CLI_VERSION}\n`);
|
|
99
116
|
return 0;
|
|
100
117
|
}
|
|
101
118
|
const cmd = p.positionals[0];
|
|
@@ -105,8 +122,25 @@ async function main(argv) {
|
|
|
105
122
|
}
|
|
106
123
|
const fn = COMMANDS[cmd];
|
|
107
124
|
if (!fn)
|
|
108
|
-
throw new CliError("usage", `unknown command ${cmd}`, "Run:
|
|
125
|
+
throw new CliError("usage", `unknown command ${cmd}`, "Run: b9s --help");
|
|
109
126
|
warnIfForeignCopy(cmd, CLI_VERSION);
|
|
127
|
+
const codexSubcommand = cmd === "codex" ? p.positionals[1] : undefined;
|
|
128
|
+
const antigravitySubcommand = cmd === "antigravity" ? p.positionals[1] : undefined;
|
|
129
|
+
// These sync/setup subcommands only inspect or configure local harness session state.
|
|
130
|
+
const localHarnessDispatch = (cmd === "codex" && ["hooks", "sync", "start"].includes(codexSubcommand ?? "")) || (cmd === "antigravity" && antigravitySubcommand === "sync");
|
|
131
|
+
const noticePreflightExempt = NOTICE_PREFLIGHT_EXEMPT_COMMANDS.has(cmd) || localHarnessDispatch;
|
|
132
|
+
if (!noticePreflightExempt) {
|
|
133
|
+
const agentName = resolveAgentName(str(p.flags, "as"));
|
|
134
|
+
loadAgent(agentName);
|
|
135
|
+
const command = commandLine(["b9s", ...process.argv.slice(2)]);
|
|
136
|
+
try {
|
|
137
|
+
for (const warning of await commandWarnings(agentName, command))
|
|
138
|
+
process.stderr.write(`[b9s] ${warning}\n`);
|
|
139
|
+
}
|
|
140
|
+
catch (e) {
|
|
141
|
+
process.stderr.write(`[b9s] command notice check failed; command will continue unchecked: ${e.message}\n`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
110
144
|
const code = await fn(p, out);
|
|
111
145
|
return code ?? 0;
|
|
112
146
|
}
|
package/dist/install.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { homedir, userInfo } from "node:os";
|
|
4
|
-
import { dirname, join } from "node:path";
|
|
4
|
+
import { basename, dirname, join } from "node:path";
|
|
5
5
|
import { configRoot } from "./config.js";
|
|
6
6
|
import { CliError } from "./errors.js";
|
|
7
7
|
import { cmp } from "./update.js";
|
|
@@ -21,22 +21,30 @@ export function readInstall() {
|
|
|
21
21
|
export function requireInstall() {
|
|
22
22
|
const r = readInstall();
|
|
23
23
|
if (!r)
|
|
24
|
-
throw new CliError("not_installed", "
|
|
24
|
+
throw new CliError("not_installed", "b9s has no recorded install on this machine", "Run: npx -y benignswarm install (installs b9s once and records where; join does this too)");
|
|
25
25
|
if (!existsSync(r.bin))
|
|
26
|
-
throw new CliError("install_missing", `the recorded
|
|
26
|
+
throw new CliError("install_missing", `the recorded b9s install ${r.bin} no longer exists`, "Run: npx -y benignswarm install");
|
|
27
|
+
if (basename(r.bin) === "bschat") {
|
|
28
|
+
const primaryBin = join(dirname(r.bin), "b9s");
|
|
29
|
+
if (!existsSync(primaryBin))
|
|
30
|
+
throw new CliError("install_primary_missing", `the recorded legacy install has no b9s sibling at ${primaryBin}`, "Run: b9s install --latest to install both command names before writing new hooks or watcher services");
|
|
31
|
+
if (realpathSync(primaryBin) !== realpathSync(r.bin))
|
|
32
|
+
throw new CliError("install_primary_mismatch", `the b9s sibling at ${primaryBin} is not the recorded legacy executable`, "Run: b9s install --latest to repair the recorded install");
|
|
33
|
+
return { ...r, bin: primaryBin };
|
|
34
|
+
}
|
|
27
35
|
return r;
|
|
28
36
|
}
|
|
29
|
-
/** "
|
|
37
|
+
/** "b9s 0.12.38" -> "0.12.38"; null when the binary cannot run. */
|
|
30
38
|
export function binVersion(bin) {
|
|
31
39
|
const r = spawnSync(bin, ["--version"], { encoding: "utf8", timeout: 20_000 });
|
|
32
|
-
const m = r.status === 0 ?
|
|
40
|
+
const m = r.status === 0 ? /^(?:b9s|bschat)\s*(\d+\.\d+\.\d+)\s*$/.exec((r.stdout ?? "").trim()) : null;
|
|
33
41
|
return m ? m[1] : null;
|
|
34
42
|
}
|
|
35
|
-
/** The npm belonging to the Node running this process: the same runtime installs and runs
|
|
43
|
+
/** The npm belonging to the Node running this process: the same runtime installs and runs b9s. */
|
|
36
44
|
function ownNpm() {
|
|
37
45
|
const npm = join(dirname(process.execPath), "npm");
|
|
38
46
|
if (!existsSync(npm))
|
|
39
|
-
throw new CliError("no_npm", `no npm next to the Node running
|
|
47
|
+
throw new CliError("no_npm", `no npm next to the Node running b9s (${process.execPath})`, "Install b9s with that Node's npm yourself (npm i -g benignswarm), then run: b9s install");
|
|
40
48
|
return npm;
|
|
41
49
|
}
|
|
42
50
|
export function latestPublished(npm) {
|
|
@@ -47,7 +55,7 @@ export function latestPublished(npm) {
|
|
|
47
55
|
return v;
|
|
48
56
|
}
|
|
49
57
|
/**
|
|
50
|
-
* Makes sure this machine's global
|
|
58
|
+
* Makes sure this machine's global b9s is at least `version`, installing with the npm next to
|
|
51
59
|
* the running Node when it is missing or older, and records it. Progress goes to stderr so a
|
|
52
60
|
* JSON caller's stdout stays clean. A failed install throws: nothing is recorded.
|
|
53
61
|
*/
|
|
@@ -56,16 +64,16 @@ export function ensureInstall(version, log, npmOverride) {
|
|
|
56
64
|
const pre = spawnSync(npm, ["prefix", "-g"], { encoding: "utf8", timeout: 30_000 });
|
|
57
65
|
if (pre.status !== 0)
|
|
58
66
|
throw new CliError("npm_prefix_failed", `${npm} prefix -g failed`, (pre.stderr ?? "").trim().slice(0, 300));
|
|
59
|
-
const bin = join(pre.stdout.trim(), "bin", "
|
|
67
|
+
const bin = join(pre.stdout.trim(), "bin", "b9s");
|
|
60
68
|
const current = existsSync(bin) ? binVersion(bin) : null;
|
|
61
69
|
if (current && cmp(current, version) >= 0) {
|
|
62
|
-
log(`
|
|
70
|
+
log(`b9s ${current} is installed at ${bin}`);
|
|
63
71
|
}
|
|
64
72
|
else {
|
|
65
|
-
log(`${current ? `upgrading
|
|
73
|
+
log(`${current ? `upgrading b9s ${current}` : "installing b9s"} to ${version} with ${npm}`);
|
|
66
74
|
const r = spawnSync(npm, ["i", "-g", `benignswarm@${version}`, "--prefer-online"], { stdio: ["ignore", 2, 2], timeout: 300_000 });
|
|
67
75
|
if (r.status !== 0)
|
|
68
|
-
throw new CliError("install_failed", `npm i -g benignswarm@${version} failed (exit ${r.status}) using ${npm}`, "Fix that npm's global prefix (permissions, network) or install it yourself, then run:
|
|
76
|
+
throw new CliError("install_failed", `npm i -g benignswarm@${version} failed (exit ${r.status}) using ${npm}`, "Fix that npm's global prefix (permissions, network) or install it yourself, then run: b9s install");
|
|
69
77
|
const got = binVersion(bin);
|
|
70
78
|
if (got !== version)
|
|
71
79
|
throw new CliError("install_unverified", `after installing, ${bin} reports ${got ?? "nothing"} instead of ${version}`);
|
|
@@ -82,7 +90,7 @@ export function ensureInstall(version, log, npmOverride) {
|
|
|
82
90
|
export const shellPath = (p) => (/^[A-Za-z0-9_./-]+$/.test(p) ? p : `'${p.replace(/'/g, `'\\''`)}'`);
|
|
83
91
|
export const launchAgentsDir = () => join(homedir(), "Library", "LaunchAgents");
|
|
84
92
|
export const WATCH_LABEL_PREFIX = "org.benignswarm.watch.";
|
|
85
|
-
/** The machine daemon's service (
|
|
93
|
+
/** The machine daemon's service (b9s machine run), next to the watchers. */
|
|
86
94
|
export const MACHINE_LABEL = "org.benignswarm.machine";
|
|
87
95
|
const isOurService = (label) => label.startsWith(WATCH_LABEL_PREFIX) || label === MACHINE_LABEL;
|
|
88
96
|
/** This machine's watcher LaunchAgent plists (macOS). */
|
|
@@ -149,10 +157,10 @@ const sdq = (s) => `"${s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/%/
|
|
|
149
157
|
*/
|
|
150
158
|
export function systemdUnit(label, args, cwd, env, logDir, slug = label.slice(WATCH_LABEL_PREFIX.length)) {
|
|
151
159
|
return [
|
|
152
|
-
`# Written by
|
|
160
|
+
`# Written by b9s; re-run its b9s watch ... --service (or b9s codex start) to change it.`,
|
|
153
161
|
`# bschat-args: ${JSON.stringify(args)}`,
|
|
154
162
|
`[Unit]`,
|
|
155
|
-
`Description=
|
|
163
|
+
`Description=b9s ${label === MACHINE_LABEL ? "machine daemon" : `watcher for ${slug}`}`,
|
|
156
164
|
`After=network-online.target`,
|
|
157
165
|
``,
|
|
158
166
|
`[Service]`,
|
|
@@ -187,10 +195,10 @@ export function loadSystemdUnit(label) {
|
|
|
187
195
|
}
|
|
188
196
|
/**
|
|
189
197
|
* Installs and (re)starts a service running `args` from `cwd`: a LaunchAgent on macOS, a systemd user
|
|
190
|
-
* unit on Linux. Logs go to ~/.
|
|
198
|
+
* unit on Linux. Logs go to ~/.b9s/logs/<logName>.{out,err}.log. Returns the definition's path.
|
|
191
199
|
*/
|
|
192
200
|
export function installService(label, args, cwd, env, logName) {
|
|
193
|
-
const logDir = join(
|
|
201
|
+
const logDir = join(configRoot(), "logs");
|
|
194
202
|
mkdirSync(logDir, { recursive: true });
|
|
195
203
|
if (process.platform === "linux") {
|
|
196
204
|
mkdirSync(systemdUserDir(), { recursive: true });
|
|
@@ -269,10 +277,10 @@ export function foreignCopyNotice(cmd, self, selfVersion, rec, recorded, lastAt,
|
|
|
269
277
|
return null;
|
|
270
278
|
if (lastAt !== null && now - lastAt < 24 * 3600_000)
|
|
271
279
|
return null;
|
|
272
|
-
return `[
|
|
280
|
+
return `[b9s] this is ${self} (${selfVersion}), not this machine's install ${rec.bin} (${rec.version}). Run that one (put ${dirname(rec.bin)} first on PATH, or remove this copy), or see: b9s doctor`;
|
|
273
281
|
}
|
|
274
282
|
/**
|
|
275
|
-
* Warns once a day per copy when a
|
|
283
|
+
* Warns once a day per copy when a b9s other than the recorded install runs: another
|
|
276
284
|
* `npm i -g` with a different Node quietly puts a second copy ahead on PATH (a publish routine
|
|
277
285
|
* did exactly that and an operator's shell ran 0.12.37, which had no install command).
|
|
278
286
|
* Never fails a command: a machine state it cannot read only skips the notice.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { basename, join } from "node:path";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { configRoot } from "./config.js";
|
|
4
|
+
import { CLI_VERSION } from "./version.js";
|
|
5
|
+
export function invokedProduct(argv1 = process.argv[1]) {
|
|
6
|
+
return basename(argv1 ?? "") === "bschat" || basename(argv1 ?? "") === "bschat-admin" ? "bschat-cli" : "b9s-cli";
|
|
7
|
+
}
|
|
8
|
+
export function cliUserAgent(argv1 = process.argv[1]) { return `${invokedProduct(argv1)}/${CLI_VERSION}`; }
|
|
9
|
+
/** Keep legacy alias messaging on stderr and at most once per alias per UTC day. */
|
|
10
|
+
export function warnLegacyAlias(argv1 = process.argv[1], now = new Date(), root) {
|
|
11
|
+
const name = basename(argv1 ?? "");
|
|
12
|
+
const replacement = name === "bschat-admin" ? "b9s-admin" : name === "bschat" ? "b9s" : null;
|
|
13
|
+
if (!replacement)
|
|
14
|
+
return;
|
|
15
|
+
const stateRoot = root ?? configRoot();
|
|
16
|
+
const file = join(stateRoot, "state", "legacy-alias-notice.json");
|
|
17
|
+
let seen = {};
|
|
18
|
+
if (existsSync(file)) {
|
|
19
|
+
try {
|
|
20
|
+
seen = JSON.parse(readFileSync(file, "utf8"));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
throw new Error(`${file} is not valid JSON; refusing to suppress or repeat the legacy alias notice`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const day = now.toISOString().slice(0, 10);
|
|
27
|
+
if (seen[name] === day)
|
|
28
|
+
return;
|
|
29
|
+
mkdirSync(join(stateRoot, "state"), { recursive: true });
|
|
30
|
+
writeFileSync(file, JSON.stringify({ ...seen, [name]: day }, null, 2) + "\n", { mode: 0o600 });
|
|
31
|
+
process.stderr.write(`[b9s] ${name} is a compatibility alias; use ${replacement}.\n`);
|
|
32
|
+
}
|
package/dist/notices.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/** Compare an active server snapshot with the last snapshot this agent was shown. */
|
|
2
|
+
export function changedNotices(notices, seen) {
|
|
3
|
+
const next = Object.fromEntries(notices.map((n) => [n.id, { version: n.version, text: n.text }]));
|
|
4
|
+
const changed = notices.filter((n) => seen[n.id]?.version !== n.version);
|
|
5
|
+
const removed = Object.entries(seen).filter(([id]) => !(id in next)).map(([id, old]) => ({ id, text: old.text }));
|
|
6
|
+
return { changed, removed, next };
|
|
7
|
+
}
|
|
8
|
+
/** Notices warn; they do not block. Invalid stored patterns are a broken API contract and throw. */
|
|
9
|
+
export function commandNoticeWarning(notice, command) {
|
|
10
|
+
if (!notice.command_pattern)
|
|
11
|
+
return null;
|
|
12
|
+
if (new RegExp(notice.command_pattern).test(command))
|
|
13
|
+
return `Notice: ${notice.text}`;
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const SAFE_COMMAND_WORD = /^[A-Za-z0-9_./:@%+=,-]+$/;
|
|
17
|
+
const SHELL_OPERATORS = new Set([";", "&", "&&", "|", "||", "<", ">", "<<", ">>"]);
|
|
18
|
+
function renderCommandWord(word) {
|
|
19
|
+
if (SAFE_COMMAND_WORD.test(word))
|
|
20
|
+
return word;
|
|
21
|
+
return `'${word.replace(/'/g, `'\\''`)}'`;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The command-pattern representation: shell-safe words stay bare, other arguments are
|
|
25
|
+
* single-quoted with shell escaping, and shell operators remain separate. This lets ordinary
|
|
26
|
+
* prefixes such as `^b9s wu submit` match both CLI argv and Claude's shell command text.
|
|
27
|
+
*/
|
|
28
|
+
export function normalizeShellCommand(command) {
|
|
29
|
+
const tokens = [];
|
|
30
|
+
let word = "";
|
|
31
|
+
let started = false;
|
|
32
|
+
let wordQuoted = false;
|
|
33
|
+
let quote = null;
|
|
34
|
+
const flush = () => {
|
|
35
|
+
if (!started)
|
|
36
|
+
return;
|
|
37
|
+
const operator = !wordQuoted && SHELL_OPERATORS.has(word);
|
|
38
|
+
tokens.push({ value: word, operator });
|
|
39
|
+
word = "";
|
|
40
|
+
started = false;
|
|
41
|
+
wordQuoted = false;
|
|
42
|
+
};
|
|
43
|
+
for (let i = 0; i < command.length; i++) {
|
|
44
|
+
const ch = command[i];
|
|
45
|
+
if (quote === "'") {
|
|
46
|
+
if (ch === "'")
|
|
47
|
+
quote = null;
|
|
48
|
+
else
|
|
49
|
+
word += ch;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (quote === '"') {
|
|
53
|
+
if (ch === '"')
|
|
54
|
+
quote = null;
|
|
55
|
+
else if (ch === "\\" && i + 1 < command.length)
|
|
56
|
+
word += command[++i];
|
|
57
|
+
else
|
|
58
|
+
word += ch;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (ch === "'" || ch === '"') {
|
|
62
|
+
quote = ch;
|
|
63
|
+
started = true;
|
|
64
|
+
wordQuoted = true;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (ch === "\\" && i + 1 < command.length) {
|
|
68
|
+
word += command[++i];
|
|
69
|
+
started = true;
|
|
70
|
+
wordQuoted = true;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (/\s/.test(ch)) {
|
|
74
|
+
flush();
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (/[;&|<>]/.test(ch)) {
|
|
78
|
+
flush();
|
|
79
|
+
const pair = command.slice(i, i + 2);
|
|
80
|
+
const op = SHELL_OPERATORS.has(pair) ? pair : ch;
|
|
81
|
+
tokens.push({ value: op, operator: true });
|
|
82
|
+
if (op.length === 2)
|
|
83
|
+
i++;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
word += ch;
|
|
87
|
+
started = true;
|
|
88
|
+
}
|
|
89
|
+
flush();
|
|
90
|
+
return tokens.map((token) => token.operator ? token.value : renderCommandWord(token.value)).join(" ");
|
|
91
|
+
}
|
|
92
|
+
/** Render CLI argv in the same shell-like notation used to normalize hook command text. */
|
|
93
|
+
export function commandLine(args) {
|
|
94
|
+
return args.map(renderCommandWord).join(" ");
|
|
95
|
+
}
|
|
96
|
+
/** undefined means at least one volume could not be measured; do not falsely clear an active alert. */
|
|
97
|
+
export function diskSpaceNotice(home, workdir) {
|
|
98
|
+
const readings = [home, workdir];
|
|
99
|
+
const low = readings.filter((v) => v !== null && v.totalBytes > 0 && v.freeBytes / v.totalBytes < 0.1);
|
|
100
|
+
if (low.length) {
|
|
101
|
+
const parts = low.map((v) => `${v.label} volume has ${Math.floor((v.freeBytes / v.totalBytes) * 100)}% free (${Math.round(v.freeBytes / 1024 ** 3 * 10) / 10} GiB)`);
|
|
102
|
+
return `Disk space is below 10% free: ${parts.join("; ")}. Avoid large materialisations until space recovers.`;
|
|
103
|
+
}
|
|
104
|
+
if (readings.some((v) => v === null || v.totalBytes <= 0))
|
|
105
|
+
return undefined;
|
|
106
|
+
return null;
|
|
107
|
+
}
|
package/dist/output.js
CHANGED
|
@@ -16,8 +16,9 @@ export function fmtMessage(m) {
|
|
|
16
16
|
}
|
|
17
17
|
export function fmtStatus(s) {
|
|
18
18
|
const parts = [
|
|
19
|
-
`${s.agent_name}${s.role_name ? `[${s.role_name}]` : ""}${s.away ? ` (away until ${s.away.until}: ${s.away.reason})` : s.liveness === "quiet" ? " (quiet: harness went silent)" : s.liveness === "unknown" ? " (stale, harness unmonitored)" : s.liveness === "scheduled" ? ` (checks every ${s.checks_every} min, next ${(s.next_check_at ?? "").slice(11, 16)} UTC)` : s.liveness === "missed" ? ` (missed its ${s.checks_every}-min check)` : ""}`,
|
|
19
|
+
`${s.state === "benched" ? "BENCHED " : ""}${s.agent_name}${s.role_name ? `[${s.role_name}]` : ""}${s.away ? ` (away until ${s.away.until}: ${s.away.reason})` : s.liveness === "quiet" ? " (quiet: harness went silent)" : s.liveness === "unknown" ? " (stale, harness unmonitored)" : s.liveness === "scheduled" ? ` (checks every ${s.checks_every} min, next ${(s.next_check_at ?? "").slice(11, 16)} UTC)` : s.liveness === "missed" ? ` (missed its ${s.checks_every}-min check)` : ""}`,
|
|
20
20
|
`state=${s.state ?? "-"}`,
|
|
21
|
+
`tier=${s.tier ?? "routine"}`,
|
|
21
22
|
s.goal ? `goal="${s.goal}"` : null,
|
|
22
23
|
s.task ? `task="${s.task}"` : null,
|
|
23
24
|
s.blocked_on ? `blocked_on="${s.blocked_on}"` : null,
|
package/dist/sessions.js
CHANGED
|
@@ -13,7 +13,7 @@ function read(kind) {
|
|
|
13
13
|
return JSON.parse(readFileSync(file(kind), "utf8"));
|
|
14
14
|
}
|
|
15
15
|
catch {
|
|
16
|
-
throw new CliError("bad_session_map", `${file(kind)} is not valid JSON`, `Remove it and run:
|
|
16
|
+
throw new CliError("bad_session_map", `${file(kind)} is not valid JSON`, `Remove it and run: b9s ${kind} sync`);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
export function bindSession(kind, id, ref) {
|
package/dist/update.js
CHANGED
|
@@ -39,5 +39,5 @@ export function noteServerVersions(headers, agent) {
|
|
|
39
39
|
catch {
|
|
40
40
|
/* unwritable state dir: notice simply repeats next time */
|
|
41
41
|
}
|
|
42
|
-
process.stderr.write(`[
|
|
42
|
+
process.stderr.write(`[b9s] CLI ${CLI_VERSION} is installed, ${latest} is available: b9s update (upgrades this machine's one install and restarts its watchers)\n`);
|
|
43
43
|
}
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = "0.12.
|
|
1
|
+
export const CLI_VERSION = "0.12.83";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "benignswarm",
|
|
3
|
-
"version": "0.12.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.12.83",
|
|
4
|
+
"description": "b9s: chat, status board and evidence store for coding agents (benignswarm.org)",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
],
|
|
17
17
|
"type": "module",
|
|
18
18
|
"bin": {
|
|
19
|
+
"b9s": "dist/index.js",
|
|
20
|
+
"b9s-admin": "dist/admin-index.js",
|
|
19
21
|
"benignswarm": "dist/index.js",
|
|
20
22
|
"bschat": "dist/index.js",
|
|
21
23
|
"bschat-admin": "dist/admin-index.js"
|
|
@@ -29,7 +31,7 @@
|
|
|
29
31
|
"scripts": {
|
|
30
32
|
"build": "tsc -p tsconfig.build.json",
|
|
31
33
|
"typecheck": "tsc --noEmit",
|
|
32
|
-
"test": "vitest run",
|
|
34
|
+
"test": "npm run build && vitest run",
|
|
33
35
|
"prepack": "npm run build"
|
|
34
36
|
},
|
|
35
37
|
"devDependencies": {
|