geneseed 4.20.0 → 4.22.0
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/CHANGELOG.md +27 -0
- package/DESIGN.md +1 -1
- package/README.md +2 -2
- package/SHIPPED.md +1 -1
- package/adapters/bob/README.md +5 -0
- package/adapters/claude-code/README.md +4 -0
- package/adapters/openclaude/README.md +2 -1
- package/adapters/opencode/plugins/geneseed-activity.js +2 -2
- package/adapters/opencode/plugins/geneseed-guard.js +1 -1
- package/bin/geneseed-cli.mjs +1 -1
- package/bin/geneseed-hook.mjs +44 -3
- package/docs/concepts/hooks.md +4 -0
- package/docs/concepts/host-matrix.md +1 -0
- package/docs/guides/upgrade.md +1 -1
- package/docs/reference/environment.md +1 -0
- package/docs/reference/plugin-activity.md +7 -3
- package/docs/web-ui.md +13 -11
- package/harness.config.json +1 -1
- package/js/README.md +3 -2
- package/js/cli-table.json +39 -0
- package/js/hosts/activity.mjs +429 -0
- package/js/hosts/hooks-prims.mjs +47 -4
- package/js/hosts/hooks.mjs +6 -9
- package/js/hosts/settings.mjs +9 -0
- package/js/web/actions.mjs +39 -0
- package/js/web/activity.mjs +76 -108
- package/js/web/api.mjs +24 -2
- package/js/web/handler.mjs +20 -1
- package/js/web/jobs.mjs +6 -6
- package/js/web/server.mjs +6 -0
- package/js/web/usage-api.mjs +24 -3
- package/package.json +1 -1
- package/src/modes/foreman.md +2 -1
- package/src/skills/pipeline.md +2 -2
- package/src/skills/rule.md +3 -3
- package/web/dist/assets/Activity-DsKkFGhT.js +1 -0
- package/web/dist/assets/{ActivityDetail-CMeNtKIN.js → ActivityDetail-BWY-vaiK.js} +1 -1
- package/web/dist/assets/Dashboard-BZmw2a7d.js +2 -0
- package/web/dist/assets/Docs-CNuRuMin.js +4 -0
- package/web/dist/assets/GreenhouseView-BCiZP9f9.js +1 -0
- package/web/dist/assets/Installs-xkBX6OjK.js +3 -0
- package/web/dist/assets/JournalView-BSR51TKR.js +1 -0
- package/web/dist/assets/{KitApply-DZGqaZpV.js → KitApply-BR8AcZ62.js} +1 -1
- package/web/dist/assets/{Kits-C1VS-BtR.js → Kits-e0DCj9sT.js} +1 -1
- package/web/dist/assets/{Laws-Cu3pj44B.js → Laws-BuG2_HFE.js} +2 -2
- package/web/dist/assets/Library-BYfB4mhf.js +2 -0
- package/web/dist/assets/Loops-r6L7a1g1.js +2 -0
- package/web/dist/assets/OperatorHudView-BLXm0zzn.js +1 -0
- package/web/dist/assets/Personal-kEfKCxlh.js +1 -0
- package/web/dist/assets/{StackBar-CXARiXzd.js → StackBar-Y_gkoC3t.js} +1 -1
- package/web/dist/assets/Tabs-2uMB511T.js +1 -0
- package/web/dist/assets/activity-BEWV9er4.js +1 -0
- package/web/dist/assets/drawable-ixCquffB.js +1 -0
- package/web/dist/assets/{index-BJlfPvpv.css → index-CDSHv_7s.css} +1 -1
- package/web/dist/assets/index-Dwo3Gxek.js +2 -0
- package/web/dist/assets/jobBuckets-Dpjvbfm1.js +2 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/Activity-nRkdnrgE.js +0 -1
- package/web/dist/assets/Dashboard-B5-wUlXC.js +0 -3
- package/web/dist/assets/Docs-QmZs08QG.js +0 -4
- package/web/dist/assets/GreenhouseView-tHIvpI6U.js +0 -1
- package/web/dist/assets/Installs-DDWjgFDY.js +0 -3
- package/web/dist/assets/JournalView-DO0pPutM.js +0 -1
- package/web/dist/assets/Library-CrTK5XsD.js +0 -2
- package/web/dist/assets/Loops-C7DPrKbV.js +0 -2
- package/web/dist/assets/OperatorHudView-BN27gXFS.js +0 -1
- package/web/dist/assets/Personal-Cz2rcqYw.js +0 -1
- package/web/dist/assets/Tabs-ChiCgm2F.js +0 -1
- package/web/dist/assets/activity-BGy8Bb_l.js +0 -1
- package/web/dist/assets/drawable-r1qCgRMK.js +0 -1
- package/web/dist/assets/index-osXUqzdX.js +0 -2
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hook-side activity writer, and the one owner of what an activity snapshot's LIVENESS means.
|
|
3
|
+
*
|
|
4
|
+
* The OpenCode plugin (`adapters/opencode/plugins/geneseed-activity.js`) writes one snapshot per
|
|
5
|
+
* session into `<cfg>/activity/`; this module writes the same files for the hosts whose hooks are
|
|
6
|
+
* processes rather than a resident plugin — Claude Code, OpenClaude and Bob. The web reader
|
|
7
|
+
* (`js/web/activity.mjs`) cannot tell the two writers apart, and must not need to: the schema is
|
|
8
|
+
* the plugin's, plus `writer: "hook"`, `host`, and the two private cursors below (`normalizeEntry`
|
|
9
|
+
* never returns them).
|
|
10
|
+
*
|
|
11
|
+
* NOT A NEW HOOK ON EVERY TOOL CALL. `bin/geneseed-hook.mjs` calls `recordActivity` after the verb
|
|
12
|
+
* the host ran anyway has decided (the gates, `context`, `learn`), plus the `activity` verb for
|
|
13
|
+
* the two events no other verb is wired to (UserPromptSubmit, SessionEnd). So a Claude session's
|
|
14
|
+
* live phase moves only on the gated tools (`Bash|PowerShell`, `Write|Edit|NotebookEdit`,
|
|
15
|
+
* `Skill|Agent|Task`); the rest of the turn's tool calls arrive at Stop, read out of the
|
|
16
|
+
* transcript from a stored byte offset (`readTranscriptDelta`). Bob sends no `transcript_path`,
|
|
17
|
+
* so a Bob session shows only what its matcher-less `tool-gate` sees, call by call.
|
|
18
|
+
*
|
|
19
|
+
* THIS MODULE IS NEVER LOADED WHEN TRACKING IS OFF — the entry checks the flag first, then imports
|
|
20
|
+
* this file dynamically. It must never print: a hook's stdout is its verdict, and every write
|
|
21
|
+
* here is best-effort (a hook that fails is a tool call that fails).
|
|
22
|
+
*
|
|
23
|
+
* WHAT IS RECORDED, AND WHAT NEVER IS. A tool's name, a file path's BASENAME, line counts, todo
|
|
24
|
+
* text, a prompt snippet and the last assistant message snippet (240 characters each). Never a
|
|
25
|
+
* shell command, a file's content or an edit's text: those are where secrets live.
|
|
26
|
+
*
|
|
27
|
+
* Liveness is owned here because two writers need it now. The hooks have no resident process,
|
|
28
|
+
* so they record `pid: null` and are live by staleness alone; a plugin snapshot keeps its pid
|
|
29
|
+
* probe. `status: "ended"` (SessionEnd) is never live. `sweepActivity` moves what is not live
|
|
30
|
+
* into `activity/archive/`, and the reader lists the archive as ended sessions without ever
|
|
31
|
+
* deleting or moving anything itself.
|
|
32
|
+
*/
|
|
33
|
+
import {
|
|
34
|
+
closeSync, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readSync,
|
|
35
|
+
renameSync, statSync, unlinkSync, writeFileSync,
|
|
36
|
+
} from 'node:fs';
|
|
37
|
+
import path from 'node:path';
|
|
38
|
+
import { parseIntStrict, stripWhitespace } from '../lib/text.mjs';
|
|
39
|
+
import { SECRET_RE } from './hooks-prims.mjs';
|
|
40
|
+
import { sovereignBypass } from './hosts.mjs';
|
|
41
|
+
|
|
42
|
+
// Every snippet passes Law I's own pattern before it reaches disk; a match becomes this.
|
|
43
|
+
const SECRET_ALL = new RegExp(SECRET_RE.source, 'g');
|
|
44
|
+
// The names `safeStem` can produce, and only those: the sweep moves or deletes nothing else.
|
|
45
|
+
const SNAPSHOT_NAME = /^[A-Za-z0-9_.-]{1,128}\.json$/;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A snapshot not touched in this long is not live. pid-liveness is the plugin's real signal; for
|
|
49
|
+
* a hook writer, with no pid, this is the only one, so a session left waiting on the user for
|
|
50
|
+
* longer than this moves to the archive at the next sweep and comes back on its next prompt.
|
|
51
|
+
*/
|
|
52
|
+
export const ACTIVITY_STALE_SECONDS = 1800;
|
|
53
|
+
/** The archive keeps the newest this many ended sessions, and none older than a week. */
|
|
54
|
+
export const ARCHIVE_KEEP = 50;
|
|
55
|
+
export const ARCHIVE_MAX_AGE_SECONDS = 7 * 24 * 3600;
|
|
56
|
+
/** One Stop reads at most this much new transcript; a longer delta keeps its newest bytes. */
|
|
57
|
+
export const TRANSCRIPT_CAP = 2 * 1024 * 1024;
|
|
58
|
+
|
|
59
|
+
// The plugin's caps, so a hook snapshot is the same size as a plugin one.
|
|
60
|
+
const FILE_CAP = 8;
|
|
61
|
+
const TODO_CAP = 12;
|
|
62
|
+
const LOG_CAP = 200;
|
|
63
|
+
const CONV_CAP = 60;
|
|
64
|
+
const CONV_LEN = 240;
|
|
65
|
+
const SNIPPET_LEN = 160;
|
|
66
|
+
const SID_CAP = 128;
|
|
67
|
+
// Edit tools count as touching a file only when they carry an edit, so a Read never counts.
|
|
68
|
+
const EDIT_FIELDS = ['content', 'new_string', 'new_source', 'diff'];
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The plugin's safe-name scheme, capped: every separator, `..`-forming slash and drive colon
|
|
72
|
+
* becomes `_`, so a hostile session id can never steer the join out of the directory. The `u`
|
|
73
|
+
* flag makes an astral character ONE replacement rather than one per surrogate half.
|
|
74
|
+
*/
|
|
75
|
+
export const safeStem = (sid) => String(sid).replace(/[^A-Za-z0-9_.-]/gu, '_').slice(0, SID_CAP);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* A raw pid value as an integer, or `null`. A parsed JSON number may be the reader's `JsonNumber`
|
|
79
|
+
* wrapper, recognised by its numeric `valueOf`; a decimal string, a boolean and a float (truncated)
|
|
80
|
+
* are what a hand-edited snapshot can produce.
|
|
81
|
+
*/
|
|
82
|
+
function toIntOr(raw) {
|
|
83
|
+
if (raw === true) return 1;
|
|
84
|
+
if (raw === false) return 0;
|
|
85
|
+
if (typeof raw === 'string') return parseIntStrict(stripWhitespace(raw));
|
|
86
|
+
const n = (raw !== null && typeof raw === 'object' && !Array.isArray(raw)) ? raw.valueOf() : raw;
|
|
87
|
+
if (typeof n !== 'number' || !Number.isFinite(n)) return null;
|
|
88
|
+
return Math.trunc(n);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* `process.kill(pid, 0)` probes without a spawn. ESRCH is dead; anything else (EPERM, a
|
|
93
|
+
* locked-down host) errs toward alive, and staleness decides.
|
|
94
|
+
*/
|
|
95
|
+
function pidAlive(raw) {
|
|
96
|
+
const pid = toIntOr(raw);
|
|
97
|
+
if (pid === null || pid <= 0) return false;
|
|
98
|
+
try {
|
|
99
|
+
process.kill(pid, 0);
|
|
100
|
+
return true;
|
|
101
|
+
} catch (e) {
|
|
102
|
+
return !(e && e.code === 'ESRCH');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Not ended, not stale, and — when the snapshot names a writer pid — that pid alive. A missing or
|
|
108
|
+
* null pid is a hook writer's: staleness alone decides.
|
|
109
|
+
*/
|
|
110
|
+
export function isLive(entry, now) {
|
|
111
|
+
if (entry.status === 'ended') return false;
|
|
112
|
+
if ((now - (Number(entry.updated_at) || 0)) > ACTIVITY_STALE_SECONDS) return false;
|
|
113
|
+
const pid = Object.hasOwn(entry, 'pid') ? entry.pid : null;
|
|
114
|
+
return pid === null || pidAlive(pid);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** A JSON object from `p`, or `null` for a missing, garbage or non-object file. */
|
|
118
|
+
function readJson(p) {
|
|
119
|
+
try {
|
|
120
|
+
const v = JSON.parse(readFileSync(p, 'utf8'));
|
|
121
|
+
return v && typeof v === 'object' && !Array.isArray(v) ? v : null;
|
|
122
|
+
} catch {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** tmp + rename, so a reader never sees half a file; last writer wins. */
|
|
128
|
+
function writeAtomic(file, obj) {
|
|
129
|
+
const tmp = `${file}.${process.pid}.${Math.random().toString(36).slice(2, 8)}.tmp`;
|
|
130
|
+
writeFileSync(tmp, JSON.stringify(obj), { mode: 0o600 });
|
|
131
|
+
try {
|
|
132
|
+
renameSync(tmp, file);
|
|
133
|
+
} catch (e) {
|
|
134
|
+
// A reader holding the file open on Windows: drop this write, the next event rewrites it.
|
|
135
|
+
try { unlinkSync(tmp); } catch { /* nothing more to do */ }
|
|
136
|
+
if (!['EPERM', 'EBUSY', 'EACCES'].includes(e && e.code)) throw e;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Redacted on the WHOLE text, before the cut, so a secret the cut lands in is still whole.
|
|
141
|
+
const snip = (s, n = SNIPPET_LEN) => String(s ?? '').replace(SECRET_ALL, '[redacted]')
|
|
142
|
+
.replace(/\s+/g, ' ').trim().slice(0, n);
|
|
143
|
+
|
|
144
|
+
/** True when `p` exists and is a symlink (or junction): the writer and sweep never follow one. */
|
|
145
|
+
function isLink(p) {
|
|
146
|
+
try { return lstatSync(p).isSymbolicLink(); } catch { return false; }
|
|
147
|
+
}
|
|
148
|
+
const lineCount = (s) => (typeof s === 'string' && s ? s.split('\n').length : 0);
|
|
149
|
+
const baseOf = (p) => (typeof p === 'string' && p ? path.basename(p.replace(/\\/g, '/')) : null);
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* The bytes of `file` written since `offset`, as parsed JSONL objects, and the offset to resume
|
|
153
|
+
* from. Only COMPLETE lines are consumed, so a line the host is still writing is read next time.
|
|
154
|
+
* A file shorter than the offset was replaced, and is read from the start; a delta longer than
|
|
155
|
+
* `cap` keeps its newest `cap` bytes, minus the partial line the cut lands in.
|
|
156
|
+
*/
|
|
157
|
+
export function readTranscriptDelta(file, offset = 0, cap = TRANSCRIPT_CAP) {
|
|
158
|
+
let fd;
|
|
159
|
+
try {
|
|
160
|
+
// A regular file only: opening a FIFO or a named pipe blocks the hook until a writer comes.
|
|
161
|
+
if (!statSync(file).isFile()) return { entries: [], offset };
|
|
162
|
+
fd = openSync(file, 'r');
|
|
163
|
+
} catch {
|
|
164
|
+
return { entries: [], offset };
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
const size = fstatSync(fd).size;
|
|
168
|
+
let start = Number.isInteger(offset) && offset >= 0 && offset <= size ? offset : 0;
|
|
169
|
+
let cut = false;
|
|
170
|
+
if (size - start > cap) { start = size - cap; cut = true; }
|
|
171
|
+
const buf = Buffer.alloc(size - start);
|
|
172
|
+
const got = buf.length ? readSync(fd, buf, 0, buf.length, start) : 0;
|
|
173
|
+
const end = buf.subarray(0, got).lastIndexOf(10);
|
|
174
|
+
if (end < 0) return { entries: [], offset: start };
|
|
175
|
+
let lines = buf.subarray(0, end).toString('utf8').split('\n');
|
|
176
|
+
if (cut) lines = lines.slice(1);
|
|
177
|
+
const entries = [];
|
|
178
|
+
for (const l of lines) {
|
|
179
|
+
try {
|
|
180
|
+
const v = JSON.parse(l);
|
|
181
|
+
if (v && typeof v === 'object') entries.push(v);
|
|
182
|
+
} catch { /* a line that is not JSON is skipped, never fatal */ }
|
|
183
|
+
}
|
|
184
|
+
return { entries, offset: start + end + 1 };
|
|
185
|
+
} finally {
|
|
186
|
+
closeSync(fd);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** A tool call's one-line label: the tool and, at most, a file's basename or a skill's name. */
|
|
191
|
+
function toolLabel(name, input) {
|
|
192
|
+
const file = baseOf(input.file_path ?? input.path ?? input.notebook_path);
|
|
193
|
+
if (file) return `${name} ${file}`;
|
|
194
|
+
const named = input.skill ?? input.subagent_type;
|
|
195
|
+
return typeof named === 'string' && named ? `${name} ${snip(named, 60)}` : name;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Folds one tool call into the session's state: a timeline row, and its file or todo list. */
|
|
199
|
+
function applyTool(st, name, input, t, id, status) {
|
|
200
|
+
if (typeof name !== 'string' || !name) return;
|
|
201
|
+
const label = toolLabel(name, input);
|
|
202
|
+
const kind = ['Agent', 'Task'].includes(name) ? 'subtask' : 'tool';
|
|
203
|
+
const row = id ? st.timeline.find((r) => r.id === id) : null;
|
|
204
|
+
if (row) {
|
|
205
|
+
row.status = status;
|
|
206
|
+
} else {
|
|
207
|
+
st.timeline.push({ t, kind, label, tool: name, status, ...(id ? { id } : {}) });
|
|
208
|
+
const file = baseOf(input.file_path ?? input.path ?? input.notebook_path);
|
|
209
|
+
if (file && EDIT_FIELDS.some((k) => typeof input[k] === 'string')) {
|
|
210
|
+
let f = st.files.find((x) => x.file === file);
|
|
211
|
+
if (!f) { f = { file, additions: 0, deletions: 0 }; st.files.push(f); }
|
|
212
|
+
f.additions += lineCount(input.content ?? input.new_string ?? input.new_source);
|
|
213
|
+
f.deletions += lineCount(input.old_string);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (Array.isArray(input.todos)) {
|
|
217
|
+
st.todos = input.todos.filter((x) => x && typeof x === 'object')
|
|
218
|
+
.map((x) => ({ content: snip(x.content, CONV_LEN), status: String(x.status ?? 'pending') }));
|
|
219
|
+
}
|
|
220
|
+
return label;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** Folds a transcript delta (Claude's JSONL) in: model, token totals, tool calls, last reply. */
|
|
224
|
+
function applyTranscript(st, entries, nowMs) {
|
|
225
|
+
const counted = new Set(st.last_message_id ? [st.last_message_id] : []);
|
|
226
|
+
let reply = null;
|
|
227
|
+
for (const e of entries) {
|
|
228
|
+
const m = e.type === 'assistant' && e.message && typeof e.message === 'object' ? e.message : null;
|
|
229
|
+
if (!m) continue;
|
|
230
|
+
if (typeof m.model === 'string' && m.model && !m.model.startsWith('<')) st.model = m.model;
|
|
231
|
+
if (typeof m.id === 'string' && m.usage && !counted.has(m.id)) {
|
|
232
|
+
counted.add(m.id);
|
|
233
|
+
st.last_message_id = m.id;
|
|
234
|
+
st.tokens += (Number(m.usage.input_tokens) || 0) + (Number(m.usage.output_tokens) || 0);
|
|
235
|
+
}
|
|
236
|
+
const t = Date.parse(e.timestamp) || nowMs;
|
|
237
|
+
for (const b of Array.isArray(m.content) ? m.content : []) {
|
|
238
|
+
if (b && b.type === 'tool_use') {
|
|
239
|
+
applyTool(st, b.name, b.input && typeof b.input === 'object' ? b.input : {}, t, b.id, 'completed');
|
|
240
|
+
} else if (b && b.type === 'text' && typeof b.text === 'string' && b.text.trim()) {
|
|
241
|
+
reply = { text: b.text, t };
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return reply;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** `{count, additions, deletions, items}` over a file list, `items` capped at `cap`. */
|
|
249
|
+
function filesSummary(items, cap) {
|
|
250
|
+
if (!items.length) return null;
|
|
251
|
+
const sum = (k) => items.reduce((a, f) => a + f[k], 0);
|
|
252
|
+
return { count: items.length, additions: sum('additions'), deletions: sum('deletions'),
|
|
253
|
+
items: items.slice(0, cap) };
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function todosSummary(items, cap) {
|
|
257
|
+
if (!items) return null;
|
|
258
|
+
return { done: items.filter((x) => x.status === 'completed').length, total: items.length,
|
|
259
|
+
items: items.slice(0, cap) };
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const ROLL = { SessionStart: 'idle', UserPromptSubmit: 'busy', PreToolUse: 'busy',
|
|
263
|
+
Stop: 'waiting-input', SessionEnd: 'ended' };
|
|
264
|
+
const KNOWN = new Set([...Object.keys(ROLL), 'SubagentStop', 'PreCompact']);
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* The previous snapshot and detail (or null), a hook payload, and the clock → the next
|
|
268
|
+
* `{snap, detail}`, or `null` when the event is not one this writer records. NOT pure: the new
|
|
269
|
+
* detail reuses, and updates in place, `prevDetail`'s lists — the caller writes the result and
|
|
270
|
+
* discards the input, so a copy would only cost time on the hook path. `delta` is what
|
|
271
|
+
* `readTranscriptDelta` returned for a Stop, or null. Claude-shaped and Bob-shaped payloads
|
|
272
|
+
* (`{event, tool, input}`) are both read; a tool payload with no event name is a PreToolUse.
|
|
273
|
+
*/
|
|
274
|
+
export function applyHookEvent(prev, prevDetail, payload, now, { host = 'claude', delta = null } = {}) {
|
|
275
|
+
const p = payload;
|
|
276
|
+
const tool = typeof p.tool_name === 'string' ? p.tool_name : (typeof p.tool === 'string' ? p.tool : null);
|
|
277
|
+
let ev = typeof p.hook_event_name === 'string' ? p.hook_event_name
|
|
278
|
+
: (typeof p.event === 'string' ? p.event : null);
|
|
279
|
+
if (!ev && tool) ev = 'PreToolUse';
|
|
280
|
+
if (!KNOWN.has(ev)) return null;
|
|
281
|
+
const nowMs = Math.round(now * 1000);
|
|
282
|
+
const det = prevDetail || {};
|
|
283
|
+
const snap = prev ? { ...prev } : {
|
|
284
|
+
session_id: p.session_id, agent: null, title: null, cwd: null, status: 'idle', pid: null,
|
|
285
|
+
writer: 'hook', host,
|
|
286
|
+
};
|
|
287
|
+
const st = {
|
|
288
|
+
timeline: Array.isArray(det.timeline) ? det.timeline : [],
|
|
289
|
+
conversation: Array.isArray(det.conversation) ? det.conversation : [],
|
|
290
|
+
files: Array.isArray(det.files?.items) ? det.files.items : [],
|
|
291
|
+
todos: Array.isArray(det.todos?.items) ? det.todos.items : null,
|
|
292
|
+
model: snap.model ?? null,
|
|
293
|
+
tokens: Number(snap.tokens) || 0,
|
|
294
|
+
last_message_id: snap.last_message_id ?? null,
|
|
295
|
+
};
|
|
296
|
+
snap.updated_at = now;
|
|
297
|
+
if (typeof p.cwd === 'string' && p.cwd) snap.cwd = p.cwd;
|
|
298
|
+
if (typeof p.model === 'string' && p.model) st.model = p.model;
|
|
299
|
+
if (ROLL[ev]) snap.status = ROLL[ev];
|
|
300
|
+
if (ev === 'SessionStart') {
|
|
301
|
+
st.timeline.push({ t: nowMs, kind: 'step', label: `Session ${snip(p.source || 'start', 20)}`, status: 'completed' });
|
|
302
|
+
} else if (ev === 'UserPromptSubmit') {
|
|
303
|
+
snap.turn_started_at = now;
|
|
304
|
+
snap.phase = null;
|
|
305
|
+
if (typeof p.prompt === 'string' && p.prompt.trim()) {
|
|
306
|
+
if (!snap.title) snap.title = snip(p.prompt);
|
|
307
|
+
st.conversation.push({ role: 'user', text: snip(p.prompt, CONV_LEN), t: nowMs });
|
|
308
|
+
}
|
|
309
|
+
} else if (ev === 'PreToolUse') {
|
|
310
|
+
const input = (p.tool_input && typeof p.tool_input === 'object') ? p.tool_input
|
|
311
|
+
: ((p.input && typeof p.input === 'object') ? p.input : {});
|
|
312
|
+
const label = applyTool(st, tool, input, nowMs, typeof p.tool_use_id === 'string' ? p.tool_use_id : null, 'running');
|
|
313
|
+
if (label) snap.phase = label;
|
|
314
|
+
} else if (ev === 'Stop') {
|
|
315
|
+
const reply = delta ? applyTranscript(st, delta.entries, nowMs) : null;
|
|
316
|
+
if (delta) snap.transcript_offset = delta.offset;
|
|
317
|
+
const last = typeof p.last_assistant_message === 'string' ? p.last_assistant_message : reply?.text;
|
|
318
|
+
if (last && last.trim()) st.conversation.push({ role: 'assistant', text: snip(last, CONV_LEN), t: nowMs });
|
|
319
|
+
for (const r of st.timeline) if (r.status === 'running') r.status = 'completed';
|
|
320
|
+
snap.phase = null;
|
|
321
|
+
snap.turn_started_at = null;
|
|
322
|
+
} else if (ev === 'SubagentStop') {
|
|
323
|
+
const who = typeof p.agent_type === 'string' && p.agent_type ? ` ${snip(p.agent_type, 60)}` : '';
|
|
324
|
+
st.timeline.push({ t: nowMs, kind: 'subtask', label: `Subagent${who} done`, status: 'completed' });
|
|
325
|
+
} else if (ev === 'PreCompact') {
|
|
326
|
+
st.timeline.push({ t: nowMs, kind: 'step', label: 'Compacting', status: 'completed' });
|
|
327
|
+
} else if (ev === 'SessionEnd') {
|
|
328
|
+
snap.phase = null;
|
|
329
|
+
snap.turn_started_at = null;
|
|
330
|
+
}
|
|
331
|
+
snap.model = st.model;
|
|
332
|
+
snap.tokens = st.tokens;
|
|
333
|
+
if (st.last_message_id) snap.last_message_id = st.last_message_id;
|
|
334
|
+
snap.files = filesSummary(st.files, FILE_CAP);
|
|
335
|
+
snap.todos = todosSummary(st.todos, TODO_CAP);
|
|
336
|
+
const detail = {
|
|
337
|
+
files: filesSummary(st.files, Infinity),
|
|
338
|
+
todos: todosSummary(st.todos, Infinity),
|
|
339
|
+
conversation: st.conversation.slice(-CONV_CAP),
|
|
340
|
+
timeline: st.timeline.slice(-LOG_CAP),
|
|
341
|
+
};
|
|
342
|
+
return { snap, detail };
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* One hook event, recorded. `raw` is the payload text exactly as the host sent it on stdin.
|
|
347
|
+
* Returns whether a snapshot was written. Throws only on an unexpected filesystem error, which
|
|
348
|
+
* the entry swallows; a payload with no `session_id` or a sovereign-bypassed repo writes nothing.
|
|
349
|
+
*/
|
|
350
|
+
export function recordActivity(root, raw, { host = 'claude', now = Date.now() / 1000 } = {}) {
|
|
351
|
+
let p;
|
|
352
|
+
try { p = JSON.parse(raw); } catch { return false; }
|
|
353
|
+
if (!p || typeof p !== 'object' || typeof p.session_id !== 'string' || !p.session_id.trim()) return false;
|
|
354
|
+
if (sovereignBypass(root)) return false;
|
|
355
|
+
const dir = path.join(root, 'activity');
|
|
356
|
+
// A linked `activity/` (one a repo could commit) is never written through.
|
|
357
|
+
if (isLink(dir)) return false;
|
|
358
|
+
const stem = safeStem(p.session_id);
|
|
359
|
+
const snapFile = path.join(dir, `${stem}.json`);
|
|
360
|
+
const detFile = path.join(dir, `${stem}.detail.json`);
|
|
361
|
+
// A session the sweep archived (stale while waiting on the user) resumes from its archived
|
|
362
|
+
// copy, so its title and totals survive; the reader lets the live copy win the duplicate.
|
|
363
|
+
let prev = readJson(snapFile);
|
|
364
|
+
let prevDet = prev ? readJson(detFile) : null;
|
|
365
|
+
if (!prev) {
|
|
366
|
+
prev = readJson(path.join(dir, 'archive', `${stem}.json`));
|
|
367
|
+
if (prev) prevDet = readJson(path.join(dir, 'archive', `${stem}.detail.json`));
|
|
368
|
+
}
|
|
369
|
+
const ev = p.hook_event_name ?? p.event;
|
|
370
|
+
const delta = ev === 'Stop' && typeof p.transcript_path === 'string'
|
|
371
|
+
? readTranscriptDelta(p.transcript_path, prev ? Number(prev.transcript_offset) || 0 : 0) : null;
|
|
372
|
+
const next = applyHookEvent(prev, prevDet, p, now, { host, delta });
|
|
373
|
+
if (!next) return false;
|
|
374
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
375
|
+
// A project install's `activity/` sits inside the repo (`<repo>/.claude/activity/`): it must
|
|
376
|
+
// never be committed. Create-if-absent, so a user's own edit to the file survives.
|
|
377
|
+
try { writeFileSync(path.join(dir, '.gitignore'), '*\n', { flag: 'wx', mode: 0o600 }); } catch { /* exists */ }
|
|
378
|
+
writeAtomic(detFile, next.detail);
|
|
379
|
+
writeAtomic(snapFile, next.snap);
|
|
380
|
+
if (ev === 'SessionStart' || ev === 'SessionEnd') sweepActivity(dir, now);
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* `[name, entry]` for every session snapshot in `d` that this module may touch: a name
|
|
386
|
+
* `safeStem` can produce, and a JSON object carrying a string `session_id` — what both writers
|
|
387
|
+
* put in every snapshot. A file that fails either test (a user's file, a garbage file) is never
|
|
388
|
+
* listed, so it is never moved or deleted.
|
|
389
|
+
*/
|
|
390
|
+
function snapshots(d) {
|
|
391
|
+
let names;
|
|
392
|
+
try {
|
|
393
|
+
names = readdirSync(d);
|
|
394
|
+
} catch {
|
|
395
|
+
return [];
|
|
396
|
+
}
|
|
397
|
+
return names.filter((n) => SNAPSHOT_NAME.test(n) && !n.endsWith('.detail.json')).sort()
|
|
398
|
+
.map((n) => [n, readJson(path.join(d, n))])
|
|
399
|
+
.filter(([, e]) => e !== null && typeof e.session_id === 'string');
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Moves every snapshot in `dir` that is not live into `dir/archive/` (its detail file with it),
|
|
404
|
+
* then keeps the archive to the newest `ARCHIVE_KEEP`, none older than `ARCHIVE_MAX_AGE_SECONDS`.
|
|
405
|
+
* Called by the writer on SessionStart and SessionEnd — never by a GET. Stands down when `dir`
|
|
406
|
+
* or `archive/` is a link: a repo that committed `activity/archive` as a link to elsewhere
|
|
407
|
+
* would otherwise have the sweep move and delete files there.
|
|
408
|
+
*/
|
|
409
|
+
export function sweepActivity(dir, now = Date.now() / 1000) {
|
|
410
|
+
const arch = path.join(dir, 'archive');
|
|
411
|
+
if (isLink(dir) || isLink(arch)) return;
|
|
412
|
+
const move = (name) => {
|
|
413
|
+
try { renameSync(path.join(dir, name), path.join(arch, name)); } catch { /* best-effort */ }
|
|
414
|
+
};
|
|
415
|
+
for (const [name, e] of snapshots(dir)) {
|
|
416
|
+
if (isLive(e, now)) continue;
|
|
417
|
+
try { mkdirSync(arch, { recursive: true, mode: 0o700 }); } catch { return; }
|
|
418
|
+
move(`${name.slice(0, -'.json'.length)}.detail.json`);
|
|
419
|
+
move(name);
|
|
420
|
+
}
|
|
421
|
+
const kept = snapshots(arch).map(([name, e]) => ({ name, updated: Number(e.updated_at) || 0 }))
|
|
422
|
+
.sort((a, b) => b.updated - a.updated);
|
|
423
|
+
kept.forEach(({ name, updated }, i) => {
|
|
424
|
+
if (i < ARCHIVE_KEEP && now - updated <= ARCHIVE_MAX_AGE_SECONDS) return;
|
|
425
|
+
for (const n of [name, `${name.slice(0, -'.json'.length)}.detail.json`]) {
|
|
426
|
+
try { unlinkSync(path.join(arch, n)); } catch { /* already gone */ }
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
}
|
package/js/hosts/hooks-prims.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The primitives the hook verbs share — `js/hosts/hooks.mjs` (the gates), `hooks-context.mjs`,
|
|
3
|
-
* `hooks-learn.mjs` and `memory-files.mjs
|
|
3
|
+
* `hooks-learn.mjs` and `memory-files.mjs` — plus the activity writer's off switch and its
|
|
4
|
+
* do-nothing `activity` verb, which `bin/geneseed-hook.mjs` reaches without loading the writer.
|
|
4
5
|
*
|
|
5
6
|
* Its own module because the verbs no longer share one: each loads only the code its verb runs
|
|
6
7
|
* (`bin/geneseed-hook.mjs` imports per verb), and a gate is paid on every tool call. What lives
|
|
@@ -105,15 +106,57 @@ export function splitWords(s) {
|
|
|
105
106
|
return s.split(/\s+/).filter(Boolean);
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* stdin, decoded as UTF-8 with Python's universal newlines. Absent stdin reads empty.
|
|
111
|
+
*
|
|
112
|
+
* Read ONCE per process and kept: fd 0 drains on the first read, and the activity writer
|
|
113
|
+
* (`bin/geneseed-hook.mjs`'s `trackActivity`) needs the payload the verb already consumed.
|
|
114
|
+
*/
|
|
115
|
+
let stdinText = null;
|
|
109
116
|
export function readStdin() {
|
|
117
|
+
if (stdinText !== null) return stdinText;
|
|
110
118
|
try {
|
|
111
|
-
|
|
119
|
+
stdinText = readFileSync(0, 'utf8').replaceAll('\r\n', '\n').replaceAll('\r', '\n');
|
|
112
120
|
} catch {
|
|
113
|
-
|
|
121
|
+
stdinText = '';
|
|
114
122
|
}
|
|
123
|
+
return stdinText;
|
|
115
124
|
}
|
|
116
125
|
|
|
126
|
+
// Law I's boundary half — rule-gate's credential scan, and the activity writer's redaction of
|
|
127
|
+
// every snippet it puts on disk. Here, not in `./hooks.mjs`, so the writer reads the one copy
|
|
128
|
+
// without loading the gates. High-precision vendor prefixes only — a generic "looks like
|
|
129
|
+
// entropy" scan would fire on every hash and lockfile, and a gate that cries wolf gets
|
|
130
|
+
// allow-listed. `sk-ant-` takes `_`: Anthropic keys are base64url, and a key whose first `_`
|
|
131
|
+
// fell inside the first 20 characters slipped through. GitHub's classic `ghp_` tokens really are
|
|
132
|
+
// alphanumeric only.
|
|
133
|
+
export const SECRET_RE =
|
|
134
|
+
/\b(?:AKIA[0-9A-Z]{16}|ghp_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{30,}|sk-ant-[A-Za-z0-9_-]{20,}|xox[abprs]-[0-9A-Za-z-]{10,})\b|-----BEGIN [A-Z ]*PRIVATE KEY-----/;
|
|
135
|
+
|
|
136
|
+
const OFF = ['off', '0', 'false', 'no'];
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Whether the activity writer runs for the install at `root`: on unless `$GENESEED_ACTIVITY` or
|
|
140
|
+
* the web console's `<root>/.geneseed-activity` flag says off — the same words, and the same
|
|
141
|
+
* absent-means-on default, as the OpenCode plugin and `js/web/activity.mjs`. One file read: this
|
|
142
|
+
* is paid on every hook call, and it is the only thing paid when tracking is off.
|
|
143
|
+
*/
|
|
144
|
+
export function activityOn(root) {
|
|
145
|
+
if (OFF.includes(String(process.env.GENESEED_ACTIVITY ?? 'on').trim().toLowerCase())) return false;
|
|
146
|
+
try {
|
|
147
|
+
return !OFF.includes(readFileSync(path.join(root, '.geneseed-activity'), 'utf8').trim().toLowerCase());
|
|
148
|
+
} catch {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The `activity` verb, wired to the two events no other verb runs on (UserPromptSubmit;
|
|
155
|
+
* SessionEnd on Claude and OpenClaude). It decides nothing and prints nothing: the entry's
|
|
156
|
+
* `trackActivity` records the payload after every verb alike, this one included.
|
|
157
|
+
*/
|
|
158
|
+
export const cmdActivity = () => 0;
|
|
159
|
+
|
|
117
160
|
// The two output funnels, with Python's newline translation reproduced, are `printOut`/`printErr`
|
|
118
161
|
// in `js/lib/fs.mjs` — they moved there in P5c, beside `writeText`, which is the same rule for
|
|
119
162
|
// FILES, when `js/inspect/excludes.mjs` became the second caller; see that docblock for why the
|
package/js/hosts/hooks.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Five of the six HOOK verbs — `context`, `git-gate`, `rule-gate`, `tool-gate`, `learn` — in Node.
|
|
3
|
+
* The sixth, `activity`, decides nothing and lives in `./hooks-prims.mjs`; the activity writer
|
|
4
|
+
* every verb feeds after it decides is `./activity.mjs`, called from `bin/geneseed-hook.mjs`.
|
|
3
5
|
*
|
|
4
6
|
* These are the commands the emitted `settings.json` actually invokes on a user's machine,
|
|
5
7
|
* every session: a SessionStart injector, two PreToolUse gates (and `tool-gate`, the two
|
|
@@ -59,7 +61,7 @@ import {
|
|
|
59
61
|
} from './hosts.mjs';
|
|
60
62
|
import { currentBranch, gitRootOf, loopLaunched } from './gitref.mjs';
|
|
61
63
|
import { LOSS_CANDIDATE_RE, catastrophic, lossReason, stripStructure } from './loss.mjs';
|
|
62
|
-
import { selfAndParents, readStdin } from './hooks-prims.mjs';
|
|
64
|
+
import { selfAndParents, readStdin, SECRET_RE } from './hooks-prims.mjs';
|
|
63
65
|
import { recordUse } from './usage.mjs';
|
|
64
66
|
|
|
65
67
|
// ======================================================================================
|
|
@@ -527,13 +529,8 @@ function ruleGateTarget(p, root) {
|
|
|
527
529
|
}
|
|
528
530
|
}
|
|
529
531
|
|
|
530
|
-
// Law I's boundary half
|
|
531
|
-
//
|
|
532
|
-
// `.env*` is exempt because Law I names it as the place a secret may live. `sk-ant-` takes `_`:
|
|
533
|
-
// Anthropic keys are base64url, and a key whose first `_` fell inside the first 20 characters
|
|
534
|
-
// slipped through. GitHub's classic `ghp_` tokens really are alphanumeric only.
|
|
535
|
-
const SECRET_RE =
|
|
536
|
-
/\b(?:AKIA[0-9A-Z]{16}|ghp_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{30,}|sk-ant-[A-Za-z0-9_-]{20,}|xox[abprs]-[0-9A-Za-z-]{10,})\b|-----BEGIN [A-Z ]*PRIVATE KEY-----/;
|
|
532
|
+
// Law I's boundary half is `SECRET_RE` (`./hooks-prims.mjs`, where the activity writer reads it
|
|
533
|
+
// too). `.env*` is exempt because Law I names it as the place a secret may live.
|
|
537
534
|
const DOTENV_RE = /(^|[\\/])\.env(\.[^\\/]*)?$/;
|
|
538
535
|
|
|
539
536
|
export const SENSOR_LIST = '.geneseed/protected-checks.txt';
|
package/js/hosts/settings.mjs
CHANGED
|
@@ -781,6 +781,9 @@ export function claudeHookGroups(cfg, hookOpts, doctrines = null, excluded = [],
|
|
|
781
781
|
// if Bob ever starts sending one, learning on Bob starts working with no emit change —
|
|
782
782
|
// dropping the group would need a second one re-added later for the same reason.
|
|
783
783
|
Stop: [{ hooks: [{ type: 'command', command: `${run} learn ${mem}${b}${dn} || exit 0` }] }],
|
|
784
|
+
// The activity view's turn start (js/hosts/activity.mjs). Bob has no SessionEnd, so a Bob
|
|
785
|
+
// session leaves the live list by staleness alone.
|
|
786
|
+
UserPromptSubmit: [{ hooks: [{ type: 'command', command: `${run} activity --root "${cfg}"${b} || exit 0` }] }],
|
|
784
787
|
};
|
|
785
788
|
}
|
|
786
789
|
// OpenClaude takes Claude's whole group set and verdicts unchanged. `context` needs the host
|
|
@@ -798,6 +801,7 @@ export function claudeHookGroups(cfg, hookOpts, doctrines = null, excluded = [],
|
|
|
798
801
|
// feeds Stop, SubagentStop and PreCompact, and the flag sits before `|| exit 0`.
|
|
799
802
|
const ruleGate = `${run} rule-gate --root "${cfg}"${secretsGate === false ? ' --no-secrets-gate' : ''}`;
|
|
800
803
|
const learn = `${run} learn ${mem}${h}${doneGate === false ? ' --no-done-gate' : ''} || exit 0`;
|
|
804
|
+
const activity = `${run} activity --root "${cfg}"${h} || exit 0`;
|
|
801
805
|
// Claude Code only (hooks.md, v2.1.295+; Task 1): a `command` hook that can't start, times
|
|
802
806
|
// out, or exits anything but 0 or 2 — even one whose stdout happens to be valid JSON — now
|
|
803
807
|
// BLOCKS the tool call instead of sliding through as the non-blocking default. Only safe to
|
|
@@ -849,6 +853,11 @@ export function claudeHookGroups(cfg, hookOpts, doctrines = null, excluded = [],
|
|
|
849
853
|
// (its `compact` source) re-seeds context AFTER, this captures memory BEFORE. Same
|
|
850
854
|
// `|| exit 0`: never block.
|
|
851
855
|
PreCompact: [{ hooks: [{ type: 'command', command: learn }] }],
|
|
856
|
+
// The activity view's turn start and session end (js/hosts/activity.mjs) — the two events no
|
|
857
|
+
// other verb runs on. Never `onFailure: 'block'`: on UserPromptSubmit a block erases the
|
|
858
|
+
// user's prompt, and the `activity` verb decides nothing.
|
|
859
|
+
UserPromptSubmit: [{ hooks: [{ type: 'command', command: activity }] }],
|
|
860
|
+
SessionEnd: [{ hooks: [{ type: 'command', command: activity }] }],
|
|
852
861
|
};
|
|
853
862
|
// Claude Code only: OpenClaude always runs Git Bash on Windows (its `findGitBashPath` exits
|
|
854
863
|
// without one), and Bob takes the early return above.
|
package/js/web/actions.mjs
CHANGED
|
@@ -715,6 +715,45 @@ export function apiInstallCmd(state, body) {
|
|
|
715
715
|
return { cmd: [process.execPath, path.join(ROOT, 'bin', 'build-driver.mjs'), ...argv] };
|
|
716
716
|
}
|
|
717
717
|
|
|
718
|
+
/**
|
|
719
|
+
* The job steps for the `rebuild` action: the Overview's per-row Rebuild and its "Rebuild all
|
|
720
|
+
* behind", which name the installs to rebuild rather than every one on the machine.
|
|
721
|
+
*
|
|
722
|
+
* Body `{ installs: [{host, path}, ...] }`. Each pair must be an ACTIVE detected install, matched
|
|
723
|
+
* on the same serialised key as `detectedInstall` against a fresh `installTargets()` — the client
|
|
724
|
+
* echoes the raw `path` `/api/fleet` gave it, so an exact match is the honest test. The argv is
|
|
725
|
+
* built from the REGISTRY's host/scope/root, never from body strings, and it is what `rebuildAll`
|
|
726
|
+
* replays (`installProfile`), so a console rebuild of one row equals the CLI's of all of them.
|
|
727
|
+
*
|
|
728
|
+
* ALL OR NOTHING: one unknown, inactive or legacy entry (or a malformed body) is `{ error }` and no
|
|
729
|
+
* job starts. `detectedInstall`'s `NotFound` would answer 404; a refusal here means the world
|
|
730
|
+
* changed under the client, so the dispatcher answers 409, as for `install`. The shape is checked
|
|
731
|
+
* before the registry is read, so a bad body never costs a detect.
|
|
732
|
+
*/
|
|
733
|
+
export function rebuildCmds(body) {
|
|
734
|
+
const list = bget(body, 'installs');
|
|
735
|
+
if (!Array.isArray(list) || !list.length || !list.every(isDict)) {
|
|
736
|
+
return { error: 'installs must be a non-empty list of {host, path}' };
|
|
737
|
+
}
|
|
738
|
+
const active = installTargets().filter(([h, s, r]) => installState(r, h, s) === 'active');
|
|
739
|
+
const keys = [...new Set(list.map((e) => JSON.stringify([strOr(bget(e, 'host')),
|
|
740
|
+
strOr(bget(e, 'path'))])))];
|
|
741
|
+
if (keys.length > active.length) return { error: 'more installs named than are active' };
|
|
742
|
+
const steps = [];
|
|
743
|
+
for (const key of keys) {
|
|
744
|
+
const hit = active.findLast(([host, , root]) => JSON.stringify([host, String(root)]) === key);
|
|
745
|
+
if (hit === undefined) return { error: `not an active install: ${key}` };
|
|
746
|
+
const [host, scope, root] = hit;
|
|
747
|
+
// Asked BEFORE `installProfile`, as `rebuildAll` does: a legacy carrier must never be rebuilt.
|
|
748
|
+
if (legacyProcessCarrierOfDir(root, host)) {
|
|
749
|
+
return { error: `${host}:${scope} (${root}) predates the comms pack (its carrier names `
|
|
750
|
+
+ "'process 8') — run `geneseed setup` for it before rebuilding from the console" };
|
|
751
|
+
}
|
|
752
|
+
steps.push(...actionCommands('build', { buildArgv: installProfile(host, scope, root).argv }));
|
|
753
|
+
}
|
|
754
|
+
return { cmds: steps };
|
|
755
|
+
}
|
|
756
|
+
|
|
718
757
|
/**
|
|
719
758
|
* Deactivate, reactivate, or REMOVE one install.
|
|
720
759
|
*
|