geneseed 5.0.0 → 5.0.1
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 +16 -0
- package/SHIPPED.md +1 -1
- package/adapters/opencode/plugins/geneseed-context.js +1 -1
- package/adapters/opencode/plugins/geneseed-guard.js +1 -1
- package/docs/PRD.md +1 -1
- package/docs/concepts/hooks.md +1 -1
- package/docs/concepts/shared-tier.md +4 -4
- package/docs/guides/migrate.md +4 -2
- package/docs/guides/upgrade-to-5.md +6 -4
- package/docs/web-ui.md +11 -4
- package/harness.config.json +1 -1
- package/js/README.md +2 -1
- package/js/build/fold.mjs +7 -7
- package/js/build/rule-decide.mjs +273 -0
- package/js/cli-table.json +1 -1
- package/js/hosts/hooks-context.mjs +1 -1
- package/js/hosts/installs.mjs +4 -4
- package/js/hosts/memory-files.mjs +2 -2
- package/js/hosts/store-watch.mjs +5 -3
- package/js/inspect/registry.mjs +4 -2
- package/js/lib/paths.mjs +13 -0
- package/js/maintain/migrate.mjs +58 -20
- package/js/web/api.mjs +13 -6
- package/js/web/handler.mjs +2 -0
- package/js/web/routes.mjs +7 -3
- package/js/web/update-check.mjs +2 -2
- package/js/web/user-files.mjs +38 -11
- package/package.json +1 -1
- package/src/skills/rule/approve.md +11 -5
- package/src/skills/rule.md +2 -1
- package/web/dist/assets/{Activity-D8G4eClY.js → Activity-Ci4PZco3.js} +1 -1
- package/web/dist/assets/{ActivityDetail-BtOBYk3M.js → ActivityDetail-C8hroCND.js} +1 -1
- package/web/dist/assets/{Bonsai-B_y20b3i.js → Bonsai-C1iBAt4v.js} +1 -1
- package/web/dist/assets/{CopyButton-CHQte7Ap.js → CopyButton-DJ3a4N88.js} +1 -1
- package/web/dist/assets/{Dashboard-B8uXeJZ_.js → Dashboard-C_On4KXw.js} +2 -2
- package/web/dist/assets/{Docs-Dgv_MWfT.js → Docs-Kffdg5uV.js} +1 -1
- package/web/dist/assets/{GreenhouseView-CSzTMSl_.js → GreenhouseView-k56_cBSF.js} +1 -1
- package/web/dist/assets/{Installs-BDk9lqBI.js → Installs-DtEKLC9h.js} +2 -2
- package/web/dist/assets/{JournalView-CvRk1-m5.js → JournalView-RQnk5l7I.js} +1 -1
- package/web/dist/assets/{Kits-CoITzxWM.js → Kits-CXkEBpnf.js} +1 -1
- package/web/dist/assets/{Laws-Ctf5r9rE.js → Laws-DhhIVqmh.js} +1 -1
- package/web/dist/assets/{Library-DNwHYVXt.js → Library-CAUiEoJo.js} +1 -1
- package/web/dist/assets/{Loops-S85PMQ8m.js → Loops-LKD8mF4E.js} +1 -1
- package/web/dist/assets/{OperatorHudView-DuGz_sTk.js → OperatorHudView-CM5jNPwL.js} +1 -1
- package/web/dist/assets/Personal-B6Uoly3C.js +2 -0
- package/web/dist/assets/{RailCats-AW92uhsX.js → RailCats-DQxxYBEP.js} +1 -1
- package/web/dist/assets/{Settings-CGDFz-6j.js → Settings-BTe6-wda.js} +1 -1
- package/web/dist/assets/{Tabs-1qLrnqmn.js → Tabs-CbdDWTp_.js} +1 -1
- package/web/dist/assets/api-D_r0Jtla.js +1 -0
- package/web/dist/assets/{index-COTd4TRZ.js → index-HfGmYXab.js} +3 -3
- package/web/dist/assets/index-ao3M-Fhm.css +1 -0
- package/web/dist/index.html +3 -3
- package/web/dist/assets/Personal-afJNwvRS.js +0 -2
- package/web/dist/assets/api-C46vAuqp.js +0 -1
- package/web/dist/assets/index-CtorA7uK.css +0 -1
package/js/hosts/store-watch.mjs
CHANGED
|
@@ -15,8 +15,10 @@
|
|
|
15
15
|
* GENESEED'S OWN WRITES. `learn`, a memory removal and the fold run inside `recordOwnWrites`, which
|
|
16
16
|
* snapshots the store around the run and logs what moved to `memory/.own-writes.json`, as an exact
|
|
17
17
|
* size and mtime. A change matching the log is not reported. Limits: a write by anything else during
|
|
18
|
-
* that window is excused too, and the log is a plain file an agent could edit.
|
|
19
|
-
*
|
|
18
|
+
* that window is excused too, and the log is a plain file an agent could edit. Nothing the web
|
|
19
|
+
* console writes is logged, its decisions on the draft included: its token is readable by anything
|
|
20
|
+
* on the machine, so a POST proves no click, and logging one would let an agent hide a write. So a
|
|
21
|
+
* real click reads as a change, and the line says that may be what it is.
|
|
20
22
|
*
|
|
21
23
|
* WHAT IT CANNOT TELL. Approval is per session, and the tier is shared: another session's approved
|
|
22
24
|
* write reads as a change here, so the line says so rather than call it unapproved. A Claude
|
|
@@ -146,7 +148,7 @@ export function storeLine(files) {
|
|
|
146
148
|
const shown = files.slice(0, NAMES_SHOWN).map((f) => f.split(/[\\/]/).slice(-2).join('/')).join(', ');
|
|
147
149
|
const more = files.length > NAMES_SHOWN ? ` (+${files.length - NAMES_SHOWN} more)` : '';
|
|
148
150
|
return `Geneseed change report: ${files.length} rule or memory file${files.length === 1 ? '' : 's'} `
|
|
149
|
-
+ `changed outside this session's approved writes (another session may have made it): ${shown}${more}. `
|
|
151
|
+
+ `changed outside this session's approved writes (another session, or a decision of yours in the web console, may have made it): ${shown}${more}. `
|
|
150
152
|
+ 'This detects a change; it prevented nothing.';
|
|
151
153
|
}
|
|
152
154
|
|
package/js/inspect/registry.mjs
CHANGED
|
@@ -158,8 +158,10 @@ export function registryRecord(dir) {
|
|
|
158
158
|
* different registries. The snapshot is taken once on purpose: comparing `kept` against a SECOND
|
|
159
159
|
* read could clobber a root a concurrent `record()` appended between the two. So the write takes
|
|
160
160
|
* the lock and adds what that second read holds and the snapshot did not.
|
|
161
|
+
*
|
|
162
|
+
* `prune: false` reads the same rows and writes nothing, for a preview that promises as much.
|
|
161
163
|
*/
|
|
162
|
-
export function registryRoots() {
|
|
164
|
+
export function registryRoots({ prune = true } = {}) {
|
|
163
165
|
const original = registryLoad();
|
|
164
166
|
if (!original) return [];
|
|
165
167
|
const file = registryPath();
|
|
@@ -189,7 +191,7 @@ export function registryRoots() {
|
|
|
189
191
|
out.push(root);
|
|
190
192
|
}
|
|
191
193
|
}
|
|
192
|
-
if (kept.length !== original.length || kept.some((v, i) => v !== original[i])) {
|
|
194
|
+
if (prune && (kept.length !== original.length || kept.some((v, i) => v !== original[i]))) {
|
|
193
195
|
try {
|
|
194
196
|
withRegistryLock(() => {
|
|
195
197
|
registrySave([...kept, ...(registryLoad() ?? []).filter((r) => !original.includes(r))]);
|
package/js/lib/paths.mjs
CHANGED
|
@@ -9,6 +9,19 @@
|
|
|
9
9
|
import { accessSync, constants, statSync } from 'node:fs';
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
|
|
12
|
+
/** Does `root` sit directly in a `node_modules`? Any name: an npm alias installs under its own. */
|
|
13
|
+
export const inNodeModules = (root) => path.basename(path.dirname(root)).toLowerCase() === 'node_modules';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Is `root` a lasting install of the npm package, `…/node_modules/geneseed`? A path rule, so
|
|
17
|
+
* `migrate` can answer under the CLI's spawn ban. An npx cache is not one: npm prunes it, and the
|
|
18
|
+
* shim would die with it.
|
|
19
|
+
* shortcut: a project-local `node_modules` passes too, and only `npm root -g` tells them apart;
|
|
20
|
+
* upgrade if a project-local `migrate` ever proves real.
|
|
21
|
+
*/
|
|
22
|
+
export const isNpmPackageDir = (root) => inNodeModules(root) && path.basename(root).toLowerCase() === 'geneseed'
|
|
23
|
+
&& !root.split(/[\\/]/).includes('_npx');
|
|
24
|
+
|
|
12
25
|
const { X_OK } = constants;
|
|
13
26
|
/**
|
|
14
27
|
* `PurePath._str_normcase` \u2014 Windows compares and sorts paths case-folded, POSIX does
|
package/js/maintain/migrate.mjs
CHANGED
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
* install must not block the rest — and for a migration it is the half-migrated machine the
|
|
16
16
|
* whole verb exists to prevent.
|
|
17
17
|
*
|
|
18
|
+
* IT RUNS FROM THE NPM PACKAGE OR NOT AT ALL. The re-emit bakes the ROOT of whatever Geneseed runs
|
|
19
|
+
* it into the shim, so a run from a clone or a bundle moves nothing and only writes the stamp. That
|
|
20
|
+
* refusal comes before the survey, because the survey's registry read can prune `installs.json`.
|
|
21
|
+
* `--dry-run` writes nothing and answers from anywhere.
|
|
22
|
+
*
|
|
18
23
|
* THE ONE TRIGGER IS THE STAMP: work is needed when `<GENESEED_HOME>/.migrated` does not name this
|
|
19
24
|
* ROOT, and the stamp is written only on success. That is what makes the verb idempotent, and it
|
|
20
25
|
* holds for an OpenCode-only machine too, which wires no hooks at all.
|
|
@@ -34,6 +39,7 @@ import { installProfile } from '../build/generate.mjs';
|
|
|
34
39
|
import { autostartPaths, autostartStale, hookShimPath, shimHome } from '../hosts/shim.mjs';
|
|
35
40
|
import { writeText, printOut, printErr } from '../lib/fs.mjs';
|
|
36
41
|
import { sharedPaths } from '../lib/machine-dir.mjs';
|
|
42
|
+
import { isNpmPackageDir } from '../lib/paths.mjs';
|
|
37
43
|
|
|
38
44
|
/** Every emit name the generator answers to — the set an unrecognised marker is NOT in. */
|
|
39
45
|
const KNOWN_EMITS = new Set(EMIT_HOST_SCOPE.keys());
|
|
@@ -78,10 +84,10 @@ function stashDir() { return path.join(shimHome(), '.migrate-backup'); }
|
|
|
78
84
|
* no rollback. That ordering is the cheapest atomicity there is and it is why the survey is a
|
|
79
85
|
* separate pass rather than a check inside the loop.
|
|
80
86
|
*/
|
|
81
|
-
function migrateSurvey() {
|
|
87
|
+
function migrateSurvey({ prune = true } = {}) {
|
|
82
88
|
const rows = [];
|
|
83
89
|
const unrecognised = [];
|
|
84
|
-
for (const [host, scope, root] of installTargets()) {
|
|
90
|
+
for (const [host, scope, root] of installTargets({ prune })) {
|
|
85
91
|
if (installState(root, host, scope) !== 'active') continue;
|
|
86
92
|
const raw = readMaybe(path.join(root, '.geneseed-emit'));
|
|
87
93
|
const marker = raw === null ? '' : raw.trim();
|
|
@@ -115,14 +121,12 @@ function autostartFindings() {
|
|
|
115
121
|
*/
|
|
116
122
|
function foldPreview(rows) {
|
|
117
123
|
let shared;
|
|
118
|
-
try { shared = sharedPaths(); } catch { return; } // no home: no tier to fold into
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
for (const f of report.failed) printOut(`[migrate] ${host}: the fold would stop at ${f}\n`);
|
|
125
|
-
}
|
|
124
|
+
try { shared = sharedPaths(); } catch { return []; } // no home: no tier to fold into
|
|
125
|
+
return rows.filter(({ host, scope, root }) => scope === 'global' && isCanonical(root, host))
|
|
126
|
+
.map(({ host, root }) => {
|
|
127
|
+
const report = foldHost({ host, cfgDir: root, shared, dryRun: true });
|
|
128
|
+
return { host, summary: foldSummary(report), failed: report.failed };
|
|
129
|
+
});
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
/**
|
|
@@ -144,23 +148,51 @@ export function orphanFindings(cfg, owned, { live = knownSkillIds(), aliases = s
|
|
|
144
148
|
.map((rel) => path.join(cfg, rel));
|
|
145
149
|
}
|
|
146
150
|
|
|
147
|
-
/** The `--dry-run` half of M5:
|
|
151
|
+
/** The `--dry-run` half of M5: the orphans of each global Claude-style install. */
|
|
148
152
|
function orphanPreview(rows) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
return rows.filter(({ host, scope, root }) => scope === 'global' && CLAUDE_STYLE.includes(host) && isCanonical(root, host))
|
|
154
|
+
.flatMap(({ root }) => {
|
|
155
|
+
const owned = claudeReadManifest(root).owned;
|
|
156
|
+
return orphanFindings(root, Array.isArray(owned) ? owned : []);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** The fold and orphan half of `--dry-run`, as the CLI prints it. */
|
|
161
|
+
function printPreview(rows) {
|
|
162
|
+
for (const { host, summary, failed } of foldPreview(rows)) {
|
|
163
|
+
printOut(summary ? `[migrate] would fold ${host}: ${summary}\n` : `[migrate] ${host}: nothing to fold\n`);
|
|
164
|
+
for (const f of failed) printOut(`[migrate] ${host}: the fold would stop at ${f}\n`);
|
|
155
165
|
}
|
|
166
|
+
for (const p of orphanPreview(rows)) {
|
|
167
|
+
printOut(`[migrate] orphan: ${p} (no manifest owns it; an earlier build may have written it, or it may be yours). Nothing moves it: if it is not yours, move it by hand.\n`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* What the next rebuild would do, for the console: `{folds: [{host, summary, failed}], orphans}`.
|
|
173
|
+
* Writes nothing. A marker `migrate` refuses is in here too: `rebuild-all` coerces it, so that
|
|
174
|
+
* install still folds. No `would re-emit` plan: that is this verb's, and a clone has none to run.
|
|
175
|
+
*/
|
|
176
|
+
export function migratePreview() {
|
|
177
|
+
const { rows, unrecognised } = migrateSurvey({ prune: false });
|
|
178
|
+
const all = [...rows, ...unrecognised];
|
|
179
|
+
return { folds: foldPreview(all), orphans: orphanPreview(all) };
|
|
156
180
|
}
|
|
157
181
|
|
|
158
182
|
/** A stash key that cannot collide across drives, and is a legal file name on both platforms. */
|
|
159
183
|
const stashKey = (p) => p.replace(/[\\/:]/g, '_');
|
|
160
184
|
|
|
161
|
-
export function cmdMigrate(args = {}) {
|
|
185
|
+
export function cmdMigrate(args = {}, { root = ROOT } = {}) {
|
|
162
186
|
const dryRun = Boolean(args.dryRun);
|
|
163
|
-
const
|
|
187
|
+
const isClone = existsSync(path.join(root, '.git'));
|
|
188
|
+
const outside = isClone || !isNpmPackageDir(root);
|
|
189
|
+
const shape = isClone ? 'a git clone' : 'a bundle';
|
|
190
|
+
if (!dryRun && outside) {
|
|
191
|
+
printErr(`[migrate] REFUSED — this Geneseed runs from ${shape}, so there is nothing to migrate. Use geneseed update.\n`);
|
|
192
|
+
printErr('[migrate] Nothing was changed.\n');
|
|
193
|
+
return 3;
|
|
194
|
+
}
|
|
195
|
+
const { rows, unrecognised, needed } = migrateSurvey({ prune: !dryRun });
|
|
164
196
|
|
|
165
197
|
if (unrecognised.length) {
|
|
166
198
|
// Refuse the WHOLE run. A migration that skipped the row it did not understand and
|
|
@@ -179,13 +211,19 @@ export function cmdMigrate(args = {}) {
|
|
|
179
211
|
return 0;
|
|
180
212
|
}
|
|
181
213
|
|
|
182
|
-
if (dryRun)
|
|
214
|
+
if (dryRun) printPreview(rows);
|
|
183
215
|
|
|
184
216
|
if (!needed) {
|
|
185
217
|
printOut(`[migrate] already on the npm shape (${rows.length} install(s)); nothing to do.\n`);
|
|
186
218
|
return 0;
|
|
187
219
|
}
|
|
188
220
|
|
|
221
|
+
if (dryRun && outside) {
|
|
222
|
+
printOut(`[migrate] this Geneseed runs from ${shape}, so a real run would refuse. Use geneseed update.\n`);
|
|
223
|
+
printOut('[migrate] --dry-run: nothing was written.\n');
|
|
224
|
+
return 0;
|
|
225
|
+
}
|
|
226
|
+
|
|
189
227
|
printOut(`[migrate] ${rows.length} install(s) to migrate.\n`);
|
|
190
228
|
if (dryRun) {
|
|
191
229
|
for (const r of rows) {
|
package/js/web/api.mjs
CHANGED
|
@@ -32,7 +32,7 @@ import { loadCatalog, catalogProblems } from '../loop/catalog.mjs';
|
|
|
32
32
|
import { activeLoops } from '../loop/registry.mjs';
|
|
33
33
|
import { EMIT_OPTIONS, themeOptions } from '../maintain/setup.mjs';
|
|
34
34
|
import { accentFor, keptKitFiles, statusData } from '../inspect/status.mjs';
|
|
35
|
-
import {
|
|
35
|
+
import { writeTextAtomic } from '../lib/fs.mjs';
|
|
36
36
|
import { sharedPaths } from '../lib/machine-dir.mjs';
|
|
37
37
|
import { comparePaths } from '../lib/paths.mjs';
|
|
38
38
|
import {
|
|
@@ -286,8 +286,8 @@ export function apiFleet(state, { now = Date.now() } = {}) {
|
|
|
286
286
|
if (files !== null) drift = driftCounts(files);
|
|
287
287
|
} catch { /* an install that cannot be re-rendered reports no drift figure, not zero */ }
|
|
288
288
|
}
|
|
289
|
-
|
|
290
|
-
|
|
289
|
+
const builtMs = builtAt(dir);
|
|
290
|
+
const built = builtMs === null ? null : Math.floor(builtMs / 1000);
|
|
291
291
|
const { cost, sessionStart } = reads(host, scope, st, root, dir);
|
|
292
292
|
const tier = tierOf({ target: dir });
|
|
293
293
|
installs.push({
|
|
@@ -317,6 +317,14 @@ export function apiFleet(state, { now = Date.now() } = {}) {
|
|
|
317
317
|
return { installs, source_fp: sourceFp, doctor: state.doctor, version: releaseLabel() };
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
+
/**
|
|
321
|
+
* When an install was built: its version marker's mtime in ms, or null. ONE rule for the Overview
|
|
322
|
+
* and the fleet: every emit writes the marker, and a Claude-family install has no root `AGENT.md`.
|
|
323
|
+
*/
|
|
324
|
+
function builtAt(dir) {
|
|
325
|
+
try { return statSync(path.join(dir, VERSION_MARKER)).mtimeMs; } catch { return null; }
|
|
326
|
+
}
|
|
327
|
+
|
|
320
328
|
/**
|
|
321
329
|
* What Settings' Server panel says about the process answering it — built FIELD BY FIELD, never from the
|
|
322
330
|
* daemon record, which holds the write token: a GET is readable by anything that passes the Host
|
|
@@ -441,9 +449,8 @@ export function apiOverview(state, counts = machineCounts(state, [{ install: nul
|
|
|
441
449
|
// engine-dependent — a plausible-but-wrong "2h" is the exact failure a second field costs
|
|
442
450
|
// nothing to prevent.
|
|
443
451
|
let buildEpoch = null;
|
|
444
|
-
const
|
|
445
|
-
if (
|
|
446
|
-
const ms = statSync(agentMd).mtimeMs;
|
|
452
|
+
const ms = builtAt(state.target);
|
|
453
|
+
if (ms !== null) {
|
|
447
454
|
buildTime = stampMinute(ms);
|
|
448
455
|
buildEpoch = Math.floor(ms / 1000);
|
|
449
456
|
}
|
package/js/web/handler.mjs
CHANGED
|
@@ -309,6 +309,8 @@ export function makeHandler(state, jm, token, dist, holder = null) {
|
|
|
309
309
|
apiPickFolder((result) => sendJson(res, result, 200, ae));
|
|
310
310
|
return;
|
|
311
311
|
}
|
|
312
|
+
// A rebuild's fold writes the same draft and ledger, so a decision waits for it.
|
|
313
|
+
if (path === '/api/rules/decide' && jm.busy) return sendJson(res, BUSY, 409, ae);
|
|
312
314
|
// The install a body `{host, path}` names, on the routes that read one (`VIEW_POSTS`).
|
|
313
315
|
// An action is looked up on the SAME segment `doAction` dispatches on (the last), so
|
|
314
316
|
// `/api/actions/x/restore` cannot run a restore on the daemon's install instead.
|
package/js/web/routes.mjs
CHANGED
|
@@ -27,7 +27,8 @@ import { FLEET_SECTIONS, NotFound, apiCatalog, apiItem } from './catalog.mjs';
|
|
|
27
27
|
import { apiUsage } from './usage-api.mjs';
|
|
28
28
|
import { fleetSort } from './state.mjs';
|
|
29
29
|
import { apiGates } from './gates-api.mjs';
|
|
30
|
-
import {
|
|
30
|
+
import { migratePreview } from '../maintain/migrate.mjs';
|
|
31
|
+
import { apiProfile, apiProfileSave, apiRules, apiRulesDecide, apiRulesMutate, apiRulesPromote } from './user-files.mjs';
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* The POSTs this daemon answers — and this table IS the dispatch, not a declaration beside
|
|
@@ -55,6 +56,7 @@ export const POST_ROUTES = new Map([
|
|
|
55
56
|
[(state, b) => apiMemoryDelete(state, isTruthy(b.name) ? formatValue(b.name) : ''), false]],
|
|
56
57
|
['/api/rules', [apiRulesMutate, true]],
|
|
57
58
|
['/api/rules/promote', [apiRulesPromote, true]],
|
|
59
|
+
['/api/rules/decide', [apiRulesDecide, true]],
|
|
58
60
|
['/api/profile', [apiProfileSave, true]],
|
|
59
61
|
// No `ok: false` arm: success returns `{ok: true, loop}`, and both refusals (unknown root,
|
|
60
62
|
// unknown preset) throw `NotFound`, which `doPost`'s catch answers 404 before this column is
|
|
@@ -70,7 +72,7 @@ export const POST_ROUTES = new Map([
|
|
|
70
72
|
* are the only actions that read the request's install.
|
|
71
73
|
*/
|
|
72
74
|
export const VIEW_POSTS = new Set(['/api/activity', '/api/memory/delete', '/api/rules',
|
|
73
|
-
'/api/rules/promote', '/api/profile', '/api/actions/restore', '/api/actions/build']);
|
|
75
|
+
'/api/rules/promote', '/api/rules/decide', '/api/profile', '/api/actions/restore', '/api/actions/build']);
|
|
74
76
|
|
|
75
77
|
/**
|
|
76
78
|
* The GETs that answer for the whole machine, not one install: they IGNORE a `?host=&path=`
|
|
@@ -86,7 +88,7 @@ export const VIEW_POSTS = new Set(['/api/activity', '/api/memory/delete', '/api/
|
|
|
86
88
|
* active install (`fleetOf`), which caches one view per install on the daemon state; the laws
|
|
87
89
|
* section, and `/api/item/`, stay install-scoped (`PREFIX_ROUTES`).
|
|
88
90
|
*/
|
|
89
|
-
export const MACHINE_GETS = new Set(['/api/update', '/api/installs', '/api/fleet', '/api/kits',
|
|
91
|
+
export const MACHINE_GETS = new Set(['/api/update', '/api/installs', '/api/fleet', '/api/migrate/preview', '/api/kits',
|
|
90
92
|
'/api/usage', '/api/gates', '/api/excludes', '/api/mcp', '/api/loops/active', '/api/activity',
|
|
91
93
|
'/api/catalog/skills', '/api/catalog/agents', '/api/catalog/memory', '/api/catalog/notebook',
|
|
92
94
|
'/api/catalog/wiki', '/api/catalog/config']);
|
|
@@ -203,6 +205,8 @@ export const STATE_ROUTES = {
|
|
|
203
205
|
new URL(url || '', 'http://x').searchParams.has('fresh')),
|
|
204
206
|
'/api/installs': apiInstalls,
|
|
205
207
|
'/api/fleet': (state) => apiFleet(state),
|
|
208
|
+
// Reads every global install, and writes nothing: the console's view of `migrate --dry-run`.
|
|
209
|
+
'/api/migrate/preview': () => migratePreview(),
|
|
206
210
|
'/api/kits': apiKits,
|
|
207
211
|
'/api/update': apiUpdate,
|
|
208
212
|
'/api/usage': apiUsage,
|
package/js/web/update-check.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import path from 'node:path';
|
|
|
24
24
|
|
|
25
25
|
import { ROOT } from '../build/source.mjs';
|
|
26
26
|
import { measureUpstream, preflight } from '../maintain/update.mjs';
|
|
27
|
-
import { normcase, which } from '../lib/paths.mjs';
|
|
27
|
+
import { inNodeModules, normcase, which } from '../lib/paths.mjs';
|
|
28
28
|
|
|
29
29
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
30
30
|
/** A failed ask is retried sooner than a good answer is refreshed: a proxy hiccup is not a day. */
|
|
@@ -162,7 +162,7 @@ export function installKind({ root = ROOT, npmRoot = npmGlobalRoot } = {}) {
|
|
|
162
162
|
let kind = 'other';
|
|
163
163
|
let unanswered = false;
|
|
164
164
|
if (existsSync(path.join(root, '.git'))) kind = 'git';
|
|
165
|
-
else if (
|
|
165
|
+
else if (inNodeModules(root)) {
|
|
166
166
|
const g = npmRoot();
|
|
167
167
|
unanswered = !g;
|
|
168
168
|
if (g && real(g) === real(path.dirname(root))) kind = 'npm-global';
|
package/js/web/user-files.mjs
CHANGED
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
import { createHash } from 'node:crypto';
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
|
|
13
|
+
import { RETIRED_RULES_FILE, decideItem, decisionState, draftItems, CHOICE_DECISIONS, RULE_DECISIONS } from '../build/rule-decide.mjs';
|
|
13
14
|
import { PROFILE_STUB } from '../build/stubs.mjs';
|
|
14
15
|
import { readMaybe } from '../hosts/installs.mjs';
|
|
15
16
|
import { splitLines } from '../hosts/hooks-prims.mjs';
|
|
16
|
-
import { frontmatter, isRuleEdge,
|
|
17
|
+
import { frontmatter, isRuleEdge, parseRules, readFoldState } from '../hosts/memory-files.mjs';
|
|
17
18
|
import { writeText, isFile, isDir } from '../lib/fs.mjs';
|
|
18
19
|
import { formatRepr, isTruthy } from '../lib/json.mjs';
|
|
19
20
|
import { WHITESPACE, codePointLength, stripWhitespace } from '../lib/text.mjs';
|
|
@@ -64,22 +65,30 @@ const userDir = (state, tier = tierOf(state)) => tier?.root ?? state.target;
|
|
|
64
65
|
const rulesPath = (state, tier) => path.join(userDir(state, tier), RULES_FILE);
|
|
65
66
|
|
|
66
67
|
/**
|
|
67
|
-
* The blocks the fold left in `<tier>/user-rules.draft.md`,
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* does not parse, still shows. Empty for a project install and for a missing draft.
|
|
68
|
+
* The blocks the fold left in `<tier>/user-rules.draft.md`, in file order (`draftItems`). A block
|
|
69
|
+
* the ledger already holds as decided is left over from a stopped write, so it is not pending; a
|
|
70
|
+
* block with no row, or a ledger that does not parse, still shows. Empty for a project install and
|
|
71
|
+
* for a missing draft. `apiRulesDecide` below decides one.
|
|
72
72
|
*/
|
|
73
73
|
function ruleDrafts(tier) {
|
|
74
74
|
if (tier === null) return [];
|
|
75
75
|
let ledger = {};
|
|
76
76
|
try { ledger = readFoldState(tier).items; } catch { /* shows all */ }
|
|
77
77
|
const decided = ({ key }) => {
|
|
78
|
-
const row = ledger[key];
|
|
78
|
+
const row = Object.hasOwn(ledger, key ?? '') ? ledger[key] : null;
|
|
79
79
|
return row != null && row.state !== 'pending';
|
|
80
80
|
};
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
// A bad draft is one row on the page, never a failed page: the rules below it still edit.
|
|
82
|
+
try {
|
|
83
|
+
return draftItems(tier).filter((d) => !decided(d));
|
|
84
|
+
} catch (e) {
|
|
85
|
+
return [{ title: 'The draft could not be read', host: null, body: String(e?.message ?? e), decisions: [] }];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The fingerprint a decision must send back: `''` where there is no tier, or no draft to read. */
|
|
90
|
+
function draftFingerprint(tier) {
|
|
91
|
+
try { return tier === null ? '' : fingerprint(decisionState(tier)); } catch { return ''; }
|
|
83
92
|
}
|
|
84
93
|
|
|
85
94
|
/**
|
|
@@ -95,7 +104,7 @@ export function apiRules(state) {
|
|
|
95
104
|
const drafts = ruleDrafts(tier);
|
|
96
105
|
if (!isFile(p)) {
|
|
97
106
|
return { exists: false, path: p, rules: [], warnings: [], fingerprint: '', shared, drafts,
|
|
98
|
-
stats: { rules: 0, lines: 0, tokens: 0 } };
|
|
107
|
+
draft_fingerprint: draftFingerprint(tier), stats: { rules: 0, lines: 0, tokens: 0 } };
|
|
99
108
|
}
|
|
100
109
|
const text = readMaybe(p) ?? '';
|
|
101
110
|
const [rules, warnings] = parseRules(text);
|
|
@@ -111,6 +120,7 @@ export function apiRules(state) {
|
|
|
111
120
|
tokens: tokensOf(stripWhitespace(lines.slice(r.start, r.end).join('\n'))),
|
|
112
121
|
}));
|
|
113
122
|
return { exists: true, path: p, rules: out, warnings, fingerprint: fingerprint(text), shared, drafts,
|
|
123
|
+
draft_fingerprint: draftFingerprint(tier),
|
|
114
124
|
// The whole file, so it holds its header too: more than the rules' own tokens added up.
|
|
115
125
|
stats: { rules: rules.length, lines: lines.length, tokens: tokensOf(text) } };
|
|
116
126
|
}
|
|
@@ -186,7 +196,6 @@ function ruleId(v) {
|
|
|
186
196
|
* mistake; it exists so a retire never loses the text. Like user-rules.md it is the user's: no
|
|
187
197
|
* install manifest claims it, so no uninstall deletes it.
|
|
188
198
|
*/
|
|
189
|
-
const RETIRED_RULES_FILE = 'user-rules-retired.md';
|
|
190
199
|
const RETIRED_HEADER = '# Retired rules — not in force, never loaded into any session.\n';
|
|
191
200
|
const isBlank = (line) => !stripWhitespace(line);
|
|
192
201
|
|
|
@@ -254,6 +263,24 @@ export function apiRulesMutate(state, body) {
|
|
|
254
263
|
return { ok: true, op, id: rid, fingerprint: fingerprint(next) };
|
|
255
264
|
}
|
|
256
265
|
|
|
266
|
+
/**
|
|
267
|
+
* One decision on a drafted item (`decideItem`). The fingerprint covers the draft, the shared rules
|
|
268
|
+
* and both files of each `Choose` block, so a click on what the page showed never lands on what an
|
|
269
|
+
* agent session or a fold wrote since: `ok: false`, 409, and the page reloads.
|
|
270
|
+
*/
|
|
271
|
+
export function apiRulesDecide(state, body) {
|
|
272
|
+
const decision = bget(body, 'decision');
|
|
273
|
+
if (![...RULE_DECISIONS, ...CHOICE_DECISIONS].includes(decision)) {
|
|
274
|
+
throw new BadRequest(`unknown decision ${formatRepr(decision)}`);
|
|
275
|
+
}
|
|
276
|
+
const tier = tierOf(state);
|
|
277
|
+
if (tier === null) throw new NotFound('shared tier');
|
|
278
|
+
if (!fpMatches(bget(body, 'fingerprint', ''), draftFingerprint(tier))) {
|
|
279
|
+
return { ok: false, error: 'conflict', detail: 'The draft changed since you loaded it.' };
|
|
280
|
+
}
|
|
281
|
+
return decideItem(tier, strOr(bget(body, 'key')), decision);
|
|
282
|
+
}
|
|
283
|
+
|
|
257
284
|
/**
|
|
258
285
|
* One memory fact promoted into a trial rule. The provenance line and the month of
|
|
259
286
|
* probation are the rule this endpoint owns, and both are DATES read from the real clock —
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"//": "Every field here is argued and gated in tests/unit/package_manifest.test.mjs. `files`, `bin`, `exports` and `engines` each have a test that fails when reality drifts from this file; `version` mirrors harness.config.json and is gated too. Read that docblock before editing this one.",
|
|
3
3
|
"name": "geneseed",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.1",
|
|
5
5
|
"description": "A portable, theme-able harness you implant once and use everywhere to grow a disciplined AI coding agent.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"ai",
|
|
@@ -9,13 +9,18 @@ binds from there, so no step here may take a rule out of force. The ledger is `.
|
|
|
9
9
|
in that folder: the `sha256` of a block is the key of its row under `items`. Writes here pass the
|
|
10
10
|
rule gate; that prompt is expected.
|
|
11
11
|
|
|
12
|
+
The console's Pending section (`js/build/rule-decide.mjs`) applies these same steps, so the user can
|
|
13
|
+
decide an item while you work. Read the draft and the ledger again before each decision: a block
|
|
14
|
+
that is gone was decided.
|
|
15
|
+
|
|
12
16
|
1. **Read the draft and the ledger.** If the draft holds no block and no row is `pending`, say so
|
|
13
17
|
and stop.
|
|
14
18
|
2. **Clear what is stale, and finish what a stop left.** Name each item to the user.
|
|
15
19
|
- A block whose row is not `pending` is already decided. For an `approved` rule, add its
|
|
16
20
|
`## Renumbered` line if that line is missing. Then delete the block and keep the row.
|
|
17
21
|
- Delete the block and the row of a `Choose` block whose host file is absent, is now its seed,
|
|
18
|
-
or now matches the shared file
|
|
22
|
+
or now matches the shared file, or whose shared file is absent or is its seed: the next fold
|
|
23
|
+
moves the host file up.
|
|
19
24
|
- Delete the block and the row of a `Choose` block whose `sha256` is not the host file's key
|
|
20
25
|
now: the host file changed, and the next fold asks about the current text. Order proves
|
|
21
26
|
nothing, because a host file can return to earlier text. Get the key from the row's `kind`
|
|
@@ -33,9 +38,10 @@ The lines under the pointer are the rule as it stands, with its own metadata lin
|
|
|
33
38
|
- **Approve** moves it to the shared file:
|
|
34
39
|
1. Apply steps 4 and 8 of Branch B: the shared file binds every host on the machine.
|
|
35
40
|
2. Read the shared file and each `user-rules-retired.md` ({{LAW:verify-before-asserting}}): the one
|
|
36
|
-
beside the shared file, the one
|
|
37
|
-
|
|
38
|
-
retired number is never reused. The new number is one above the highest in all these
|
|
41
|
+
beside the shared file, and the one in each host's own config directory, where each block's
|
|
42
|
+
`source` sits (`installs.json` holds project roots only). A host keeps its own retired rules,
|
|
43
|
+
and a retired number is never reused. The new number is one above the highest in all these
|
|
44
|
+
files.
|
|
39
45
|
3. Append to the shared file `## R<new> — <title>`, then the lines under the pointer, unchanged. The next fold
|
|
40
46
|
finds the host copy by its title and body, so never reword here. Other wording is a new
|
|
41
47
|
rule: reject this item and take the text through Branch B.
|
|
@@ -66,4 +72,4 @@ Delete the block in each case.
|
|
|
66
72
|
|
|
67
73
|
### Close
|
|
68
74
|
Tell the user that a host file changes at the next global emit of that host, and that
|
|
69
|
-
`geneseed rebuild-all
|
|
75
|
+
`geneseed rebuild-all`, or *Rebuild all* in the console, runs one for every host.
|
package/src/skills/rule.md
CHANGED
|
@@ -16,7 +16,8 @@ contradictory or stale entries (a file, flag or command that no longer exists),
|
|
|
16
16
|
a release or large refactor, or when the user says "clean up memory", "consolidate",
|
|
17
17
|
"what do you actually remember". The user's wiki is the [wiki {{SKILL}}](wiki.md)'s.
|
|
18
18
|
Run the **approval flow**, not the fork, when an emit reports items `to approve`, when
|
|
19
|
-
`user-rules.draft.md` holds pending items, or when the user asks to review them.
|
|
19
|
+
`user-rules.draft.md` holds pending items, or when the user asks to review them. The console's
|
|
20
|
+
Pending section decides the same items by the same steps; a user who decides there needs no flow here.
|
|
20
21
|
|
|
21
22
|
## Procedure
|
|
22
23
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-C1iE8mnY.js";import{t as r}from"./api-C46vAuqp.js";import{s as i}from"./motion-RlUl1osO.js";import{A as a,D as o,E as s,F as c,H as l,L as u,M as d,N as f,O as p,P as m,Q as h,T as g,X as _,Y as ee,bt as v,j as y,rt as b,st as x,u as te,w as S}from"./index-COTd4TRZ.js";import{t as C}from"./EmptyState-CY5Pm2xy.js";import{_ as w,a as T,c as E,f as D,g as O,h as k,i as A,l as j,m as M,n as N,o as P,p as F,r as I,s as L,t as R,u as z,v as ne}from"./Bonsai-B_y20b3i.js";import{t as re}from"./usePoll-o8ul-Sog.js";var B=e(t(),1),V=n(),H=4,U=56*H,W=24,G=165,K=188,q=e=>{let t=j(e);return t==null?null:Math.round(t*100)};function J(e,t,n){let r=S[e.status]||S.idle,i=t.pads.filter(e=>e.key!=null),a=t.pads.reduce((e,t)=>e+t.files.length,0)+t.fallen.reduce((e,t)=>e+t.files.length,0),o=q(e);return[`${e.title||p(e.cwd)||e.session_id}, ${e.chip||e.host||`unknown host`}, ${r.label}${e.phase?`, ${e.phase}`:``}`,`${e.turns||0} turns${o==null?``:`, context ${o} %`}${e.compactions?`, ${e.compactions} compactions`:``}`,i.length?`${i.length} sub-agent${i.length===1?``:`s`} running: ${i.map(e=>`${e.type||`agent`} (${e.files.length} file${e.files.length===1?``:`s`})`).join(`, `)}`:``,t.fallen.length?`${t.fallen.length} finished`:``,`${a} file${a===1?``:`s`} changed`,n.length?`shares ${n.length} file${n.length===1?``:`s`} with another session`:``,e.error?`error: ${e.error}`:``].filter(Boolean).join(`. `)}function Y({s:e,t,mine:n}){let r=q(e);return(0,V.jsxs)(`div`,{className:`card gd-card`,children:[(0,V.jsxs)(`dl`,{className:`gd-facts`,children:[e.model&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{children:`model`}),(0,V.jsx)(`dd`,{className:`mono`,children:e.model})]}),(0,V.jsx)(`dt`,{children:`turns`}),(0,V.jsx)(`dd`,{children:e.turns||0}),(0,V.jsx)(`dt`,{children:`context`}),(0,V.jsx)(`dd`,{children:r==null?`unknown`:`${r} %`}),(0,V.jsx)(`dt`,{children:`compactions`}),(0,V.jsx)(`dd`,{children:e.compactions||0})]}),t.fallen.length>0&&(0,V.jsxs)(`div`,{className:`dim act-xs`,children:[`finished: `,t.fallen.map(e=>`${e.type||`agent`} (${e.files.length})`).join(`, `)]}),n.map(e=>(0,V.jsxs)(`div`,{className:`act-xs ${e.kind===`same-worktree`?`t-bad`:`t-warn`}`,children:[`same file`,e.kind===`same-worktree`?``:`, other worktree`,`: `,e.path]},`${e.kind}:${e.path}`))]})}function X({s:e,worktree:t,sakura:n,mine:r,pad:i,onHover:a}){let o=ne(e,n),s=(0,B.useMemo)(()=>D(e,{sakura:n}),[o]),c=S[e.status]||S.idle,l=Array.isArray(e.loops)?e.loops[0]:null,u=e.status!==`idle`,f=L(e),m=(0,B.useRef)(null),h=(0,B.useCallback)(e=>a(f,e,Q(m.current)),[a,f]);return(0,V.jsxs)(`a`,{ref:m,className:`gd-tree${d(e)?` gd-needs`:``}`,href:e.href||z(e.session_id),"aria-label":J(e,s,r),"data-sid":e.session_id,onMouseEnter:e=>a(f,null,Q(e.currentTarget)),onMouseLeave:()=>a(null,null),onFocus:e=>a(f,null,Q(e.currentTarget)),onBlur:()=>a(null,null),onKeyDown:e=>A(e,s.pads.length,i,h),children:[(0,V.jsxs)(`div`,{className:`gd-label`,children:[(0,V.jsxs)(`div`,{className:`act-ell`,children:[(0,V.jsx)(`span`,{className:`badge mono`,title:`The install this session runs in`,children:e.chip||e.host||`?`}),` `,e.title||p(e.cwd)||e.session_id]}),(0,V.jsxs)(`div`,{className:`row gap-8 gd-sub`,children:[(0,V.jsx)(`span`,{className:`badge ${c.cls}`,children:c.label}),t&&(0,V.jsxs)(`span`,{className:`badge mono`,children:[`⎇ `,t]}),l&&(0,V.jsxs)(`span`,{className:`badge`,children:[`↻ `,l.title,l.iteration==null?``:` ${l.iteration}`]}),e.attribution===!1&&(0,V.jsx)(`span`,{className:`badge`,title:`attribution unavailable on ${e.host}`,children:`no attrib.`}),e.phase&&(0,V.jsx)(`span`,{className:`dim act-ell`,children:e.phase})]})]}),(0,V.jsx)(I,{t:s,pad:i,swaying:u,onPad:h,px:H})]})}function Z({pairs:e,count:t}){if(!e.length)return null;let n=t*U+(t-1)*W,r=e=>e*(U+W)+U/2;return(0,V.jsx)(`svg`,{className:`gd-threads`,width:n,height:56*H+20,"aria-hidden":`true`,children:e.map(({a:e,b:t,kind:n})=>{let[i,a]=e<t?[e,t]:[t,e],o=`gd-thread ${n===`same-worktree`?`red`:`amber`}`;if(a-i===1){let e=r(i)+30,t=r(a)-30,n=(e+t)/2;return(0,V.jsxs)(`g`,{className:o,children:[(0,V.jsx)(`path`,{d:`M${e} ${G} C${n} 179 ${n} 159 ${t} 169`}),(0,V.jsx)(`path`,{d:`M${e} 169 C${n} 159 ${n} 179 ${t} ${G}`})]},`${i}-${a}`)}return(0,V.jsx)(`g`,{className:o,children:(0,V.jsx)(`path`,{d:`M${r(i)} ${K} Q${(r(i)+r(a))/2} 222 ${r(a)} ${K}`})},`${i}-${a}`)})})}var Q=e=>e.offsetLeft-(e.parentElement?.scrollLeft||0);function ie({sessions:e,collisions:t}){let[n,r]=(0,B.useState)(P),[i,a]=(0,B.useState)(()=>new Set),o=()=>{let e=!n;r(e);try{window.localStorage.setItem(N,e?`1`:`0`)}catch{}},s=Array.isArray(t)?t:[],c=E(F(e)).map(e=>i.has(e.key)?{...e,collapsed:!1}:e),l=c.filter(e=>e.collapsed),u=e=>O(e,s);return(0,V.jsxs)(`section`,{className:`gd`,"aria-label":`Garden`,children:[(0,V.jsxs)(`div`,{className:`row between wrap gap-8 gd-head`,children:[(0,V.jsxs)(`span`,{className:`dim act-sm`,children:[e.length,` tree`,e.length===1?``:`s`,` · `,c.length,` `,c.length===1?`shelf`:`shelves`,` · a tree opens its session; hover or focus shows its details, and a tap or the arrow keys walk its pads`]}),(0,V.jsx)(`button`,{type:`button`,className:n?`chip-f on`:`chip-f`,"aria-pressed":n,onClick:o,children:`Pink blossom`})]}),l.length>0&&(0,V.jsx)(`div`,{className:`row wrap gap-8 gd-chips`,role:`group`,"aria-label":`Folded shelves`,children:l.map(e=>(0,V.jsxs)(`button`,{type:`button`,className:`chip-f`,"aria-expanded":!1,onClick:()=>a(t=>new Set(t).add(e.key)),children:[e.name,` · `,e.trees.length]},e.key))}),c.filter(e=>!e.collapsed).map(e=>(0,V.jsx)(ae,{sh:e,sakura:n,cols:s,mineOf:u},e.key))]})}function ae({sh:e,sakura:t,cols:n,mineOf:r}){let[i,a]=(0,B.useState)({sid:null,pad:null,x:0}),o=(0,B.useCallback)((e,t,n)=>a(r=>({sid:e,pad:t,x:n??(r.sid===e?r.x:0)})),[]),s=e.trees.find(e=>L(e.s)===i.sid)?.s,c=s?D(s,{sakura:t}):null,l=c&&i.pad!=null?c.pads[i.pad]:null;return(0,V.jsxs)(`section`,{className:`gd-shelf`,"aria-label":`${e.name} shelf`,children:[(0,V.jsxs)(`h3`,{className:`act-lbl gd-shelf-h`,children:[e.name,` `,(0,V.jsxs)(`span`,{className:`dim`,children:[`· `,e.trees.length]})]}),(0,V.jsxs)(`div`,{className:`gd-row`,children:[e.trees.map(({s:e,worktree:n})=>(0,V.jsx)(X,{s:e,worktree:n,sakura:t,mine:r(L(e)),pad:L(e)===i.sid?i.pad:null,onHover:o},L(e))),(0,V.jsx)(Z,{pairs:w(e.trees,n),count:e.trees.length})]}),(0,V.jsx)(`span`,{className:`sr-only`,role:`status`,children:T(l)}),s&&(0,V.jsx)(`div`,{className:`gd-info`,"aria-hidden":`true`,style:{left:Math.max(0,i.x)},children:l?(0,V.jsx)(R,{pad:l}):(0,V.jsx)(Y,{s,t:c,mine:r(L(s))})})]})}var $=e=>e.catch(()=>null);function oe({s:e}){let t=(0,B.useId)(),n=e.todos,r=y(e);return(0,V.jsxs)(`a`,{className:`card pad-md act-card`,href:e.href||z(e.session_id),"aria-labelledby":`${t}-t ${t}-st`,"aria-describedby":r?`${t}-c`:void 0,children:[(0,V.jsxs)(g,{s:e,id:t,heading:e.title||p(e.cwd)||e.session_id,children:[e.chip&&(0,V.jsx)(`span`,{className:`badge mono`,title:`The install this session runs in`,children:e.chip}),(0,V.jsx)(b,{name:`chevron`,className:`glyph act-chev`})]}),n&&n.total>0&&(0,V.jsx)(`div`,{className:`act-foot`,children:(0,V.jsxs)(`span`,{className:`row gap-8 dim act-sm`,children:[(0,V.jsx)(o,{done:n.done,total:n.total}),`plan `,n.done,`/`,n.total]})}),(0,V.jsxs)(`div`,{className:`dim mono act-updated`,children:[`updated `,x(e.updated_at),` ago`]})]})}var se={blocked:`is blocked`,"waiting-input":`waits for your answer`};function ce(e,t){if(!Array.isArray(t))return``;let n=t.filter(d),r=e.current;return e.current=new Set(n.map(e=>`${L(e)}:${e.status}`)),r?n.filter(e=>!r.has(`${L(e)}:${e.status}`)).map(e=>`${e.title||p(e.cwd)||e.session_id} ${se[e.status]}`).join(`. `):``}var le=[[`all`,`All`],[`needs`,`Needs you`],[`runs`,`Runs`],[`gates`,`Gate asks`]];function ue(){let e=new URLSearchParams(window.location.hash.split(`?`)[1]||``),t=e.get(`f`);return{f:le.some(([e])=>e===t)?t:`all`,host:e.get(`host`)||``,project:e.get(`project`)||``,v:e.get(`v`)===`list`?`list`:`garden`}}function de(e){let t=new URLSearchParams;e.f!==`all`&&t.set(`f`,e.f),e.v===`list`&&t.set(`v`,`list`),e.host&&t.set(`host`,e.host),e.project&&t.set(`project`,e.project);let n=t.toString();window.history.replaceState(null,``,`#/activity${n?`?${n}`:``}`)}function fe({enabled:e,installs:t,onToggle:n}){let r=M(t);return(0,V.jsxs)(`section`,{className:`card pad-md act-track`,"aria-labelledby":`act-track-h`,children:[(0,V.jsx)(b,{name:`activity`,className:`glyph act-fixed`}),(0,V.jsxs)(`div`,{className:`act-grow`,children:[(0,V.jsx)(`h2`,{id:`act-track-h`,className:`act-track-title`,children:e?`Live sessions are on`:`Live sessions are off`}),!e&&(0,V.jsx)(`p`,{className:`dim act-sm act-track-p`,children:`Runs and gate asks below come from the job log and the gate ledger. Turn tracking on to see what each session is doing now.`})]}),(0,V.jsxs)(`ul`,{className:`stack gap-8 act-fixed act-sm`,"aria-label":`Tracking per install`,children:[t.length===0&&(0,V.jsx)(`li`,{className:`dim`,children:`No active install to track.`}),t.map((e,t)=>(0,V.jsxs)(`li`,{className:`row gap-10`,children:[(0,V.jsxs)(`span`,{id:`act-track-l${t}`,title:e.path,children:[`Track live sessions in `,(0,V.jsx)(`span`,{className:`mono`,children:r.get(e.install)})]}),(0,V.jsx)(`div`,{className:`sw-toggle${e.enabled?` on`:``}`,role:`switch`,"aria-checked":e.enabled,"aria-labelledby":`act-track-l${t}`,tabIndex:0,onClick:()=>n(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.key===` `&&t.preventDefault(),n(e))}})]},e.install))]})]})}function pe({jobs:e,loading:t}){let n=typeof e?.cap==`number`?e.cap:void 0,r=f(e?.jobs,{days:14,cap:n}),i=c(r.map(e=>e.nodata?`-`:e.n).join(`,`),`scaleY`),a=Math.max(1,...r.map(e=>e.n)),o=r.reduce((e,t)=>e+t.n,0),s=r.find(e=>!e.nodata),l=r.some(e=>e.nodata),u=`Runs per day: ${r.filter(e=>e.n).map(e=>`${e.n} on ${m(e.key)}`).join(`, `)||`none`}.`+(l?s?` Days before ${m(s.key)} are older than the runs the log keeps.`:` No run is in the log yet.`:``);return(0,V.jsxs)(`section`,{className:`card pad-md act-stat`,"aria-labelledby":`act-runs-h`,children:[(0,V.jsxs)(`div`,{className:`act-stat-head`,children:[(0,V.jsx)(`h2`,{id:`act-runs-h`,className:`act-lbl`,children:`Runs per day · 14 days`}),e&&(0,V.jsx)(`span`,{className:`act-big`,children:o})]}),t?(0,V.jsx)(_,{label:`Reading the job log…`}):e?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`act-runs`,role:`img`,"aria-label":u,ref:i,children:r.map(e=>e.nodata?(0,V.jsx)(`i`,{className:`nodata`},e.key):e.n?(0,V.jsx)(`i`,{"data-sweep":!0,style:{height:`${e.n/a*100}%`},title:`${m(e.key)}: ${e.n}`},e.key):(0,V.jsx)(`i`,{className:`zero`},e.key))}),(0,V.jsxs)(`div`,{className:`mono act-axis`,"aria-hidden":`true`,children:[(0,V.jsx)(`span`,{children:m(r[0].key)}),(0,V.jsx)(`span`,{children:m(r[7].key)}),(0,V.jsx)(`span`,{children:`today`})]}),l&&(0,V.jsxs)(`span`,{className:`dim act-xs`,children:[`Hatched: older than the runs the log keeps`,n?` (last ${n})`:``,`.`]})]}):(0,V.jsx)(`p`,{className:`dim act-sm`,children:`The job log could not be read.`})]})}function me({rows:e,gates:t,loading:n}){let r=e.reduce((e,t)=>e+t.n,0);return(0,V.jsxs)(`section`,{className:`card pad-md act-stat`,"aria-labelledby":`act-gates-h`,children:[(0,V.jsxs)(`div`,{className:`act-stat-head`,children:[(0,V.jsx)(`h2`,{id:`act-gates-h`,className:`act-lbl`,children:`Gate asks by rule · 30 days`}),t&&(0,V.jsx)(`span`,{className:`act-big`,children:r})]}),n?(0,V.jsx)(_,{label:`Reading the gate ledger…`}):e.length?(0,V.jsx)(`ul`,{className:`gate-rows`,children:e.slice(0,6).map((e,t)=>(0,V.jsxs)(`li`,{children:[(0,V.jsxs)(`span`,{className:`act-ell`,children:[e.name,` `,(0,V.jsx)(`span`,{className:`mono dim act-xs`,children:e.rule})]}),(0,V.jsx)(s,{vals:e.per_day,i:t,sweep:!0}),(0,V.jsx)(`span`,{className:`mono`,children:e.n})]},e.rule))}):(0,V.jsx)(`p`,{className:`dim act-sm`,children:t?`No gate asked in 30 days.`:`The gate ledger could not be read.`})]})}var he={done:[`ok`,`done`],failed:[`bad`,`failed`],running:[``,`running`]};function ge({job:e,longest:t}){let n=u(e),r=e.duration?Math.round(e.duration*10)/10:0,[i,a]=he[e.status]||[``,e.status||`…`],o=e.status===`running`?`Still running`:r?`Took ${r} second${r===1?``:`s`}`:`No duration`,s=e.started?new Date(e.started*1e3).toLocaleTimeString(`en-GB`,{hour:`2-digit`,minute:`2-digit`}):`—`;return(0,V.jsxs)(`li`,{className:`act-row`,children:[(0,V.jsx)(`span`,{className:`mono dim act-xs`,children:s}),(0,V.jsx)(b,{name:`play`,className:`glyph act-glyph`}),(0,V.jsxs)(`span`,{className:`act-what`,children:[(0,V.jsx)(`span`,{className:`act-row-title`,children:n.verb}),n.scope&&(0,V.jsx)(`span`,{className:`dim act-xs act-ell`,title:n.command,children:n.scope})]}),(0,V.jsx)(`span`,{className:`act-dur`,role:`img`,"aria-label":o,children:(0,V.jsx)(`span`,{"data-sweep":!0,style:{width:t>0?`${(e.duration||0)/t*100}%`:`0%`}})}),(0,V.jsx)(`span`,{className:`badge ${i}`,children:a})]})}function _e({gate:e}){return(0,V.jsxs)(`li`,{className:`act-row gate`,children:[(0,V.jsx)(`span`,{className:`mono dim act-xs`,children:`—`}),(0,V.jsx)(b,{name:`rule`,className:`glyph act-glyph t-warn`}),(0,V.jsxs)(`span`,{className:`act-what`,children:[(0,V.jsx)(`span`,{className:`act-row-title`,children:e.title}),(0,V.jsx)(`span`,{className:`dim act-xs`,children:`Gate ledger`})]}),(0,V.jsx)(`span`,{className:`act-dur-none`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`badge warn`,children:`asked`})]})}var ve=5,ye=(e,t)=>[...new Set([...e.filter(Boolean),t].filter(Boolean))];function be(){let[e,t]=(0,B.useState)(null),[n,o]=(0,B.useState)(``),[s,u]=(0,B.useState)(ue),[f,m]=(0,B.useState)(!1),[g,y]=(0,B.useState)(``),b=(0,B.useRef)(null),x=e=>{let t={...s,...e};u(t),de(t)};re(e=>r.activity().then(n=>{if(e()){t(n),o(``);let e=ce(b,n?.activity);e&&y(t=>t===e?e+`\xA0`:e)}},t=>{e()&&o(t.message)}),2e3,[]);let S=v(()=>$(r.jobs()),[]),w=v(()=>$(r.gates()),[]),T=v(()=>$(r.catalog(`laws`)),[]),E=!e||e.enabled!==!1,D=Array.isArray(e?.installs)?e.installs:[],O=k(e?.activity,D).sort((e,t)=>e.session_id<t.session_id?-1:+(e.session_id>t.session_id)),A=i(),j=E&&e?O.filter(d).length:null,M=new Set(O.map(L)),N=k(e?.ended,D).filter(e=>!M.has(L(e))),P=ye([...O,...N].map(e=>e.host),s.host),F=ye([...O,...N].map(e=>p(e.cwd)),s.project),I=s.host&&s.project?`host or project`:s.host?`host`:s.project?`project`:``,R=e=>(!s.host||e.host===s.host)&&(!s.project||p(e.cwd)===s.project),z=O.filter(e=>R(e)&&(s.f!==`needs`||d(e))),ne=s.f===`all`||s.f===`needs`,H=s.f===`all`&&E?N.filter(R):[],U=f?H:H.slice(0,ve),W=!I&&(s.f===`all`||s.f===`runs`),G=!I&&(s.f===`all`||s.f===`gates`),K=S.data?.jobs||[],q=te(w.data,T.data),J=a(K,q,w.data?.days).map(e=>({...e,runs:W?e.runs:[],gate:G?e.gate:null})).filter(e=>e.runs.length||e.gate),Y=Math.max(0,...K.map(e=>e.duration||0)),X=c(J.flatMap(e=>e.runs.map(e=>`${e.id}:${e.duration}`)).join(`,`),`scaleX`),Z=async e=>{let n=!e.enabled;try{let i=await r.activityToggle(n,{host:e.host,path:e.path});if(i.ok===!1){o(i.error||`Could not change tracking`);return}let a=t=>i.enabled?t||[]:(t||[]).flatMap(t=>{let n=(t.installs||[t.install]).filter(t=>t!==e.install);return n.length?[{...t,install:n[0],installs:n}]:[]});t(t=>{let n=(t?.installs||[]).map(t=>t.install===e.install?{...t,enabled:i.enabled}:t);return{...t||{},installs:n,enabled:n.length===0||n.some(e=>e.enabled),activity:a(t?.activity),ended:a(t?.ended)}}),o(``)}catch(e){o(e.message)}},Q=(e,t,n)=>(0,V.jsxs)(`span`,{className:`row gap-8 act-sm`,children:[(0,V.jsx)(`label`,{htmlFor:`act-f-${e}`,children:t}),(0,V.jsxs)(`select`,{id:`act-f-${e}`,className:`sel`,value:s[e],disabled:n.length===0,title:n.length===0?`No source carries a ${e} yet`:void 0,onChange:t=>x({[e]:t.target.value}),children:[(0,V.jsxs)(`option`,{value:``,children:[`All `,e===`host`?`hosts`:`projects`]}),n.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]});return(0,V.jsxs)(`div`,{className:`page-fill`,children:[(0,V.jsx)(l,{title:`Activity`,sub:`What your agents ran, what the gates asked, and which sessions are waiting on you.`}),(0,V.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,children:g}),n&&(0,V.jsx)(`div`,{className:`act-gap`,children:(0,V.jsx)(ee,{error:n})}),e&&(0,V.jsx)(fe,{enabled:E,installs:D,onToggle:Z}),(0,V.jsxs)(`div`,{className:`act-today`,children:[(0,V.jsx)(pe,{jobs:S.data,loading:S.loading}),(0,V.jsx)(me,{rows:q,gates:w.data,loading:w.loading}),(0,V.jsxs)(`section`,{className:`card pad-md act-stat`,"aria-labelledby":`act-wait-h`,children:[(0,V.jsx)(`h2`,{id:`act-wait-h`,className:`act-lbl`,children:`Waiting on you`}),!e&&!n?(0,V.jsx)(_,{}):e?(0,V.jsxs)(V.Fragment,{children:[E?(0,V.jsxs)(`span`,{className:`act-big act-wait`,children:[j,` `,(0,V.jsx)(`span`,{className:`dim act-sm`,children:j===1?`session`:`sessions`})]}):null,(0,V.jsx)(`p`,{className:`dim act-sm`,children:E?`A session that waits on an approval or on your answer counts here.`:`Turn tracking on to count the sessions that wait on you.`})]}):(0,V.jsx)(`p`,{className:`dim act-sm`,children:`The sessions could not be read.`})]})]}),(0,V.jsxs)(`div`,{className:`row wrap gap-8 act-filters`,children:[(0,V.jsx)(`div`,{role:`group`,"aria-label":`Filter`,className:`row wrap gap-8`,children:le.map(([e,t])=>(0,V.jsxs)(`button`,{type:`button`,className:s.f===e?`chip-f on`:`chip-f`,"aria-pressed":s.f===e,onClick:()=>x({f:e}),children:[t,e===`needs`&&j>0?(0,V.jsxs)(`span`,{className:`mono`,children:[` `,j]}):null]},e))}),Q(`host`,`Host`,P),Q(`project`,`Project`,F),(0,V.jsx)(h,{"aria-label":`Live sessions view`,children:[[`list`,`List`],[`garden`,`Garden`]].map(([e,t])=>(0,V.jsx)(`button`,{type:`button`,className:s.v===e?`on`:``,"aria-pressed":s.v===e,onClick:()=>x({v:e}),children:t},e))})]}),I&&s.f!==`needs`&&(0,V.jsxs)(`p`,{className:`dim act-sm`,children:[`Runs and gate asks carry no `,I,`; showing sessions only.`]}),ne&&(e?!E&&s.f!==`needs`?null:z.length===0?s.f===`needs`?(0,V.jsx)(C,{title:`Nothing waits on you`}):(0,V.jsx)(C,{title:`No active sessions`,children:`Start an agent session and it appears here.`}):s.v===`garden`?(0,V.jsx)(ie,{sessions:z,collisions:e.collisions}):(0,V.jsx)(`div`,{className:`stack gap-12 act-live`,ref:A,children:z.map(e=>(0,V.jsx)(`div`,{"data-flip":L(e),children:(0,V.jsx)(oe,{s:e})},L(e)))}):(0,V.jsx)(_,{label:`Reading live sessions…`})),H.length>0&&(0,V.jsxs)(`section`,{className:`stack gap-12 act-live act-ended`,"aria-labelledby":`act-ended-h`,children:[(0,V.jsx)(`h2`,{id:`act-ended-h`,className:`act-lbl`,children:`Recently ended`}),U.map(e=>(0,V.jsx)(`div`,{children:(0,V.jsx)(oe,{s:e})},L(e))),H.length>ve&&(0,V.jsx)(`button`,{type:`button`,className:`btn ghost sm`,"aria-expanded":f,onClick:()=>m(e=>!e),children:f?`Show fewer`:`Show all ${H.length}`})]}),s.f!==`needs`&&(0,V.jsx)(`section`,{"aria-label":`Feed`,className:`stack gap-16 act-feed`,ref:X,children:J.map(e=>(0,V.jsxs)(`section`,{className:`card act-day`,children:[(0,V.jsxs)(`h3`,{className:`act-day-h`,children:[(0,V.jsx)(`span`,{children:e.title}),(0,V.jsx)(`span`,{className:`mono dim`,children:e.sum})]}),(0,V.jsxs)(`ul`,{className:`act-rows`,children:[e.runs.map(e=>(0,V.jsx)(ge,{job:e,longest:Y},e.id)),e.gate&&(0,V.jsx)(_e,{gate:e.gate})]})]},e.key))})]})}export{be as default};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-C1iE8mnY.js";import{t as r}from"./api-D_r0Jtla.js";import{s as i}from"./motion-RlUl1osO.js";import{A as a,D as o,E as s,F as c,H as l,L as u,M as d,N as f,O as p,P as m,Q as h,T as g,X as _,Y as ee,bt as v,j as y,rt as b,st as x,u as te,w as S}from"./index-HfGmYXab.js";import{t as C}from"./EmptyState-CY5Pm2xy.js";import{_ as w,a as T,c as E,f as D,g as O,h as k,i as A,l as j,m as M,n as N,o as P,p as F,r as I,s as L,t as R,u as z,v as ne}from"./Bonsai-C1iBAt4v.js";import{t as re}from"./usePoll-o8ul-Sog.js";var B=e(t(),1),V=n(),H=4,U=56*H,W=24,G=165,K=188,q=e=>{let t=j(e);return t==null?null:Math.round(t*100)};function J(e,t,n){let r=S[e.status]||S.idle,i=t.pads.filter(e=>e.key!=null),a=t.pads.reduce((e,t)=>e+t.files.length,0)+t.fallen.reduce((e,t)=>e+t.files.length,0),o=q(e);return[`${e.title||p(e.cwd)||e.session_id}, ${e.chip||e.host||`unknown host`}, ${r.label}${e.phase?`, ${e.phase}`:``}`,`${e.turns||0} turns${o==null?``:`, context ${o} %`}${e.compactions?`, ${e.compactions} compactions`:``}`,i.length?`${i.length} sub-agent${i.length===1?``:`s`} running: ${i.map(e=>`${e.type||`agent`} (${e.files.length} file${e.files.length===1?``:`s`})`).join(`, `)}`:``,t.fallen.length?`${t.fallen.length} finished`:``,`${a} file${a===1?``:`s`} changed`,n.length?`shares ${n.length} file${n.length===1?``:`s`} with another session`:``,e.error?`error: ${e.error}`:``].filter(Boolean).join(`. `)}function Y({s:e,t,mine:n}){let r=q(e);return(0,V.jsxs)(`div`,{className:`card gd-card`,children:[(0,V.jsxs)(`dl`,{className:`gd-facts`,children:[e.model&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{children:`model`}),(0,V.jsx)(`dd`,{className:`mono`,children:e.model})]}),(0,V.jsx)(`dt`,{children:`turns`}),(0,V.jsx)(`dd`,{children:e.turns||0}),(0,V.jsx)(`dt`,{children:`context`}),(0,V.jsx)(`dd`,{children:r==null?`unknown`:`${r} %`}),(0,V.jsx)(`dt`,{children:`compactions`}),(0,V.jsx)(`dd`,{children:e.compactions||0})]}),t.fallen.length>0&&(0,V.jsxs)(`div`,{className:`dim act-xs`,children:[`finished: `,t.fallen.map(e=>`${e.type||`agent`} (${e.files.length})`).join(`, `)]}),n.map(e=>(0,V.jsxs)(`div`,{className:`act-xs ${e.kind===`same-worktree`?`t-bad`:`t-warn`}`,children:[`same file`,e.kind===`same-worktree`?``:`, other worktree`,`: `,e.path]},`${e.kind}:${e.path}`))]})}function X({s:e,worktree:t,sakura:n,mine:r,pad:i,onHover:a}){let o=ne(e,n),s=(0,B.useMemo)(()=>D(e,{sakura:n}),[o]),c=S[e.status]||S.idle,l=Array.isArray(e.loops)?e.loops[0]:null,u=e.status!==`idle`,f=L(e),m=(0,B.useRef)(null),h=(0,B.useCallback)(e=>a(f,e,Q(m.current)),[a,f]);return(0,V.jsxs)(`a`,{ref:m,className:`gd-tree${d(e)?` gd-needs`:``}`,href:e.href||z(e.session_id),"aria-label":J(e,s,r),"data-sid":e.session_id,onMouseEnter:e=>a(f,null,Q(e.currentTarget)),onMouseLeave:()=>a(null,null),onFocus:e=>a(f,null,Q(e.currentTarget)),onBlur:()=>a(null,null),onKeyDown:e=>A(e,s.pads.length,i,h),children:[(0,V.jsxs)(`div`,{className:`gd-label`,children:[(0,V.jsxs)(`div`,{className:`act-ell`,children:[(0,V.jsx)(`span`,{className:`badge mono`,title:`The install this session runs in`,children:e.chip||e.host||`?`}),` `,e.title||p(e.cwd)||e.session_id]}),(0,V.jsxs)(`div`,{className:`row gap-8 gd-sub`,children:[(0,V.jsx)(`span`,{className:`badge ${c.cls}`,children:c.label}),t&&(0,V.jsxs)(`span`,{className:`badge mono`,children:[`⎇ `,t]}),l&&(0,V.jsxs)(`span`,{className:`badge`,children:[`↻ `,l.title,l.iteration==null?``:` ${l.iteration}`]}),e.attribution===!1&&(0,V.jsx)(`span`,{className:`badge`,title:`attribution unavailable on ${e.host}`,children:`no attrib.`}),e.phase&&(0,V.jsx)(`span`,{className:`dim act-ell`,children:e.phase})]})]}),(0,V.jsx)(I,{t:s,pad:i,swaying:u,onPad:h,px:H})]})}function Z({pairs:e,count:t}){if(!e.length)return null;let n=t*U+(t-1)*W,r=e=>e*(U+W)+U/2;return(0,V.jsx)(`svg`,{className:`gd-threads`,width:n,height:56*H+20,"aria-hidden":`true`,children:e.map(({a:e,b:t,kind:n})=>{let[i,a]=e<t?[e,t]:[t,e],o=`gd-thread ${n===`same-worktree`?`red`:`amber`}`;if(a-i===1){let e=r(i)+30,t=r(a)-30,n=(e+t)/2;return(0,V.jsxs)(`g`,{className:o,children:[(0,V.jsx)(`path`,{d:`M${e} ${G} C${n} 179 ${n} 159 ${t} 169`}),(0,V.jsx)(`path`,{d:`M${e} 169 C${n} 159 ${n} 179 ${t} ${G}`})]},`${i}-${a}`)}return(0,V.jsx)(`g`,{className:o,children:(0,V.jsx)(`path`,{d:`M${r(i)} ${K} Q${(r(i)+r(a))/2} 222 ${r(a)} ${K}`})},`${i}-${a}`)})})}var Q=e=>e.offsetLeft-(e.parentElement?.scrollLeft||0);function ie({sessions:e,collisions:t}){let[n,r]=(0,B.useState)(P),[i,a]=(0,B.useState)(()=>new Set),o=()=>{let e=!n;r(e);try{window.localStorage.setItem(N,e?`1`:`0`)}catch{}},s=Array.isArray(t)?t:[],c=E(F(e)).map(e=>i.has(e.key)?{...e,collapsed:!1}:e),l=c.filter(e=>e.collapsed),u=e=>O(e,s);return(0,V.jsxs)(`section`,{className:`gd`,"aria-label":`Garden`,children:[(0,V.jsxs)(`div`,{className:`row between wrap gap-8 gd-head`,children:[(0,V.jsxs)(`span`,{className:`dim act-sm`,children:[e.length,` tree`,e.length===1?``:`s`,` · `,c.length,` `,c.length===1?`shelf`:`shelves`,` · a tree opens its session; hover or focus shows its details, and a tap or the arrow keys walk its pads`]}),(0,V.jsx)(`button`,{type:`button`,className:n?`chip-f on`:`chip-f`,"aria-pressed":n,onClick:o,children:`Pink blossom`})]}),l.length>0&&(0,V.jsx)(`div`,{className:`row wrap gap-8 gd-chips`,role:`group`,"aria-label":`Folded shelves`,children:l.map(e=>(0,V.jsxs)(`button`,{type:`button`,className:`chip-f`,"aria-expanded":!1,onClick:()=>a(t=>new Set(t).add(e.key)),children:[e.name,` · `,e.trees.length]},e.key))}),c.filter(e=>!e.collapsed).map(e=>(0,V.jsx)(ae,{sh:e,sakura:n,cols:s,mineOf:u},e.key))]})}function ae({sh:e,sakura:t,cols:n,mineOf:r}){let[i,a]=(0,B.useState)({sid:null,pad:null,x:0}),o=(0,B.useCallback)((e,t,n)=>a(r=>({sid:e,pad:t,x:n??(r.sid===e?r.x:0)})),[]),s=e.trees.find(e=>L(e.s)===i.sid)?.s,c=s?D(s,{sakura:t}):null,l=c&&i.pad!=null?c.pads[i.pad]:null;return(0,V.jsxs)(`section`,{className:`gd-shelf`,"aria-label":`${e.name} shelf`,children:[(0,V.jsxs)(`h3`,{className:`act-lbl gd-shelf-h`,children:[e.name,` `,(0,V.jsxs)(`span`,{className:`dim`,children:[`· `,e.trees.length]})]}),(0,V.jsxs)(`div`,{className:`gd-row`,children:[e.trees.map(({s:e,worktree:n})=>(0,V.jsx)(X,{s:e,worktree:n,sakura:t,mine:r(L(e)),pad:L(e)===i.sid?i.pad:null,onHover:o},L(e))),(0,V.jsx)(Z,{pairs:w(e.trees,n),count:e.trees.length})]}),(0,V.jsx)(`span`,{className:`sr-only`,role:`status`,children:T(l)}),s&&(0,V.jsx)(`div`,{className:`gd-info`,"aria-hidden":`true`,style:{left:Math.max(0,i.x)},children:l?(0,V.jsx)(R,{pad:l}):(0,V.jsx)(Y,{s,t:c,mine:r(L(s))})})]})}var $=e=>e.catch(()=>null);function oe({s:e}){let t=(0,B.useId)(),n=e.todos,r=y(e);return(0,V.jsxs)(`a`,{className:`card pad-md act-card`,href:e.href||z(e.session_id),"aria-labelledby":`${t}-t ${t}-st`,"aria-describedby":r?`${t}-c`:void 0,children:[(0,V.jsxs)(g,{s:e,id:t,heading:e.title||p(e.cwd)||e.session_id,children:[e.chip&&(0,V.jsx)(`span`,{className:`badge mono`,title:`The install this session runs in`,children:e.chip}),(0,V.jsx)(b,{name:`chevron`,className:`glyph act-chev`})]}),n&&n.total>0&&(0,V.jsx)(`div`,{className:`act-foot`,children:(0,V.jsxs)(`span`,{className:`row gap-8 dim act-sm`,children:[(0,V.jsx)(o,{done:n.done,total:n.total}),`plan `,n.done,`/`,n.total]})}),(0,V.jsxs)(`div`,{className:`dim mono act-updated`,children:[`updated `,x(e.updated_at),` ago`]})]})}var se={blocked:`is blocked`,"waiting-input":`waits for your answer`};function ce(e,t){if(!Array.isArray(t))return``;let n=t.filter(d),r=e.current;return e.current=new Set(n.map(e=>`${L(e)}:${e.status}`)),r?n.filter(e=>!r.has(`${L(e)}:${e.status}`)).map(e=>`${e.title||p(e.cwd)||e.session_id} ${se[e.status]}`).join(`. `):``}var le=[[`all`,`All`],[`needs`,`Needs you`],[`runs`,`Runs`],[`gates`,`Gate asks`]];function ue(){let e=new URLSearchParams(window.location.hash.split(`?`)[1]||``),t=e.get(`f`);return{f:le.some(([e])=>e===t)?t:`all`,host:e.get(`host`)||``,project:e.get(`project`)||``,v:e.get(`v`)===`list`?`list`:`garden`}}function de(e){let t=new URLSearchParams;e.f!==`all`&&t.set(`f`,e.f),e.v===`list`&&t.set(`v`,`list`),e.host&&t.set(`host`,e.host),e.project&&t.set(`project`,e.project);let n=t.toString();window.history.replaceState(null,``,`#/activity${n?`?${n}`:``}`)}function fe({enabled:e,installs:t,onToggle:n}){let r=M(t);return(0,V.jsxs)(`section`,{className:`card pad-md act-track`,"aria-labelledby":`act-track-h`,children:[(0,V.jsx)(b,{name:`activity`,className:`glyph act-fixed`}),(0,V.jsxs)(`div`,{className:`act-grow`,children:[(0,V.jsx)(`h2`,{id:`act-track-h`,className:`act-track-title`,children:e?`Live sessions are on`:`Live sessions are off`}),!e&&(0,V.jsx)(`p`,{className:`dim act-sm act-track-p`,children:`Runs and gate asks below come from the job log and the gate ledger. Turn tracking on to see what each session is doing now.`})]}),(0,V.jsxs)(`ul`,{className:`stack gap-8 act-fixed act-sm`,"aria-label":`Tracking per install`,children:[t.length===0&&(0,V.jsx)(`li`,{className:`dim`,children:`No active install to track.`}),t.map((e,t)=>(0,V.jsxs)(`li`,{className:`row gap-10`,children:[(0,V.jsxs)(`span`,{id:`act-track-l${t}`,title:e.path,children:[`Track live sessions in `,(0,V.jsx)(`span`,{className:`mono`,children:r.get(e.install)})]}),(0,V.jsx)(`div`,{className:`sw-toggle${e.enabled?` on`:``}`,role:`switch`,"aria-checked":e.enabled,"aria-labelledby":`act-track-l${t}`,tabIndex:0,onClick:()=>n(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.key===` `&&t.preventDefault(),n(e))}})]},e.install))]})]})}function pe({jobs:e,loading:t}){let n=typeof e?.cap==`number`?e.cap:void 0,r=f(e?.jobs,{days:14,cap:n}),i=c(r.map(e=>e.nodata?`-`:e.n).join(`,`),`scaleY`),a=Math.max(1,...r.map(e=>e.n)),o=r.reduce((e,t)=>e+t.n,0),s=r.find(e=>!e.nodata),l=r.some(e=>e.nodata),u=`Runs per day: ${r.filter(e=>e.n).map(e=>`${e.n} on ${m(e.key)}`).join(`, `)||`none`}.`+(l?s?` Days before ${m(s.key)} are older than the runs the log keeps.`:` No run is in the log yet.`:``);return(0,V.jsxs)(`section`,{className:`card pad-md act-stat`,"aria-labelledby":`act-runs-h`,children:[(0,V.jsxs)(`div`,{className:`act-stat-head`,children:[(0,V.jsx)(`h2`,{id:`act-runs-h`,className:`act-lbl`,children:`Runs per day · 14 days`}),e&&(0,V.jsx)(`span`,{className:`act-big`,children:o})]}),t?(0,V.jsx)(_,{label:`Reading the job log…`}):e?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`act-runs`,role:`img`,"aria-label":u,ref:i,children:r.map(e=>e.nodata?(0,V.jsx)(`i`,{className:`nodata`},e.key):e.n?(0,V.jsx)(`i`,{"data-sweep":!0,style:{height:`${e.n/a*100}%`},title:`${m(e.key)}: ${e.n}`},e.key):(0,V.jsx)(`i`,{className:`zero`},e.key))}),(0,V.jsxs)(`div`,{className:`mono act-axis`,"aria-hidden":`true`,children:[(0,V.jsx)(`span`,{children:m(r[0].key)}),(0,V.jsx)(`span`,{children:m(r[7].key)}),(0,V.jsx)(`span`,{children:`today`})]}),l&&(0,V.jsxs)(`span`,{className:`dim act-xs`,children:[`Hatched: older than the runs the log keeps`,n?` (last ${n})`:``,`.`]})]}):(0,V.jsx)(`p`,{className:`dim act-sm`,children:`The job log could not be read.`})]})}function me({rows:e,gates:t,loading:n}){let r=e.reduce((e,t)=>e+t.n,0);return(0,V.jsxs)(`section`,{className:`card pad-md act-stat`,"aria-labelledby":`act-gates-h`,children:[(0,V.jsxs)(`div`,{className:`act-stat-head`,children:[(0,V.jsx)(`h2`,{id:`act-gates-h`,className:`act-lbl`,children:`Gate asks by rule · 30 days`}),t&&(0,V.jsx)(`span`,{className:`act-big`,children:r})]}),n?(0,V.jsx)(_,{label:`Reading the gate ledger…`}):e.length?(0,V.jsx)(`ul`,{className:`gate-rows`,children:e.slice(0,6).map((e,t)=>(0,V.jsxs)(`li`,{children:[(0,V.jsxs)(`span`,{className:`act-ell`,children:[e.name,` `,(0,V.jsx)(`span`,{className:`mono dim act-xs`,children:e.rule})]}),(0,V.jsx)(s,{vals:e.per_day,i:t,sweep:!0}),(0,V.jsx)(`span`,{className:`mono`,children:e.n})]},e.rule))}):(0,V.jsx)(`p`,{className:`dim act-sm`,children:t?`No gate asked in 30 days.`:`The gate ledger could not be read.`})]})}var he={done:[`ok`,`done`],failed:[`bad`,`failed`],running:[``,`running`]};function ge({job:e,longest:t}){let n=u(e),r=e.duration?Math.round(e.duration*10)/10:0,[i,a]=he[e.status]||[``,e.status||`…`],o=e.status===`running`?`Still running`:r?`Took ${r} second${r===1?``:`s`}`:`No duration`,s=e.started?new Date(e.started*1e3).toLocaleTimeString(`en-GB`,{hour:`2-digit`,minute:`2-digit`}):`—`;return(0,V.jsxs)(`li`,{className:`act-row`,children:[(0,V.jsx)(`span`,{className:`mono dim act-xs`,children:s}),(0,V.jsx)(b,{name:`play`,className:`glyph act-glyph`}),(0,V.jsxs)(`span`,{className:`act-what`,children:[(0,V.jsx)(`span`,{className:`act-row-title`,children:n.verb}),n.scope&&(0,V.jsx)(`span`,{className:`dim act-xs act-ell`,title:n.command,children:n.scope})]}),(0,V.jsx)(`span`,{className:`act-dur`,role:`img`,"aria-label":o,children:(0,V.jsx)(`span`,{"data-sweep":!0,style:{width:t>0?`${(e.duration||0)/t*100}%`:`0%`}})}),(0,V.jsx)(`span`,{className:`badge ${i}`,children:a})]})}function _e({gate:e}){return(0,V.jsxs)(`li`,{className:`act-row gate`,children:[(0,V.jsx)(`span`,{className:`mono dim act-xs`,children:`—`}),(0,V.jsx)(b,{name:`rule`,className:`glyph act-glyph t-warn`}),(0,V.jsxs)(`span`,{className:`act-what`,children:[(0,V.jsx)(`span`,{className:`act-row-title`,children:e.title}),(0,V.jsx)(`span`,{className:`dim act-xs`,children:`Gate ledger`})]}),(0,V.jsx)(`span`,{className:`act-dur-none`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`badge warn`,children:`asked`})]})}var ve=5,ye=(e,t)=>[...new Set([...e.filter(Boolean),t].filter(Boolean))];function be(){let[e,t]=(0,B.useState)(null),[n,o]=(0,B.useState)(``),[s,u]=(0,B.useState)(ue),[f,m]=(0,B.useState)(!1),[g,y]=(0,B.useState)(``),b=(0,B.useRef)(null),x=e=>{let t={...s,...e};u(t),de(t)};re(e=>r.activity().then(n=>{if(e()){t(n),o(``);let e=ce(b,n?.activity);e&&y(t=>t===e?e+`\xA0`:e)}},t=>{e()&&o(t.message)}),2e3,[]);let S=v(()=>$(r.jobs()),[]),w=v(()=>$(r.gates()),[]),T=v(()=>$(r.catalog(`laws`)),[]),E=!e||e.enabled!==!1,D=Array.isArray(e?.installs)?e.installs:[],O=k(e?.activity,D).sort((e,t)=>e.session_id<t.session_id?-1:+(e.session_id>t.session_id)),A=i(),j=E&&e?O.filter(d).length:null,M=new Set(O.map(L)),N=k(e?.ended,D).filter(e=>!M.has(L(e))),P=ye([...O,...N].map(e=>e.host),s.host),F=ye([...O,...N].map(e=>p(e.cwd)),s.project),I=s.host&&s.project?`host or project`:s.host?`host`:s.project?`project`:``,R=e=>(!s.host||e.host===s.host)&&(!s.project||p(e.cwd)===s.project),z=O.filter(e=>R(e)&&(s.f!==`needs`||d(e))),ne=s.f===`all`||s.f===`needs`,H=s.f===`all`&&E?N.filter(R):[],U=f?H:H.slice(0,ve),W=!I&&(s.f===`all`||s.f===`runs`),G=!I&&(s.f===`all`||s.f===`gates`),K=S.data?.jobs||[],q=te(w.data,T.data),J=a(K,q,w.data?.days).map(e=>({...e,runs:W?e.runs:[],gate:G?e.gate:null})).filter(e=>e.runs.length||e.gate),Y=Math.max(0,...K.map(e=>e.duration||0)),X=c(J.flatMap(e=>e.runs.map(e=>`${e.id}:${e.duration}`)).join(`,`),`scaleX`),Z=async e=>{let n=!e.enabled;try{let i=await r.activityToggle(n,{host:e.host,path:e.path});if(i.ok===!1){o(i.error||`Could not change tracking`);return}let a=t=>i.enabled?t||[]:(t||[]).flatMap(t=>{let n=(t.installs||[t.install]).filter(t=>t!==e.install);return n.length?[{...t,install:n[0],installs:n}]:[]});t(t=>{let n=(t?.installs||[]).map(t=>t.install===e.install?{...t,enabled:i.enabled}:t);return{...t||{},installs:n,enabled:n.length===0||n.some(e=>e.enabled),activity:a(t?.activity),ended:a(t?.ended)}}),o(``)}catch(e){o(e.message)}},Q=(e,t,n)=>(0,V.jsxs)(`span`,{className:`row gap-8 act-sm`,children:[(0,V.jsx)(`label`,{htmlFor:`act-f-${e}`,children:t}),(0,V.jsxs)(`select`,{id:`act-f-${e}`,className:`sel`,value:s[e],disabled:n.length===0,title:n.length===0?`No source carries a ${e} yet`:void 0,onChange:t=>x({[e]:t.target.value}),children:[(0,V.jsxs)(`option`,{value:``,children:[`All `,e===`host`?`hosts`:`projects`]}),n.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]});return(0,V.jsxs)(`div`,{className:`page-fill`,children:[(0,V.jsx)(l,{title:`Activity`,sub:`What your agents ran, what the gates asked, and which sessions are waiting on you.`}),(0,V.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,children:g}),n&&(0,V.jsx)(`div`,{className:`act-gap`,children:(0,V.jsx)(ee,{error:n})}),e&&(0,V.jsx)(fe,{enabled:E,installs:D,onToggle:Z}),(0,V.jsxs)(`div`,{className:`act-today`,children:[(0,V.jsx)(pe,{jobs:S.data,loading:S.loading}),(0,V.jsx)(me,{rows:q,gates:w.data,loading:w.loading}),(0,V.jsxs)(`section`,{className:`card pad-md act-stat`,"aria-labelledby":`act-wait-h`,children:[(0,V.jsx)(`h2`,{id:`act-wait-h`,className:`act-lbl`,children:`Waiting on you`}),!e&&!n?(0,V.jsx)(_,{}):e?(0,V.jsxs)(V.Fragment,{children:[E?(0,V.jsxs)(`span`,{className:`act-big act-wait`,children:[j,` `,(0,V.jsx)(`span`,{className:`dim act-sm`,children:j===1?`session`:`sessions`})]}):null,(0,V.jsx)(`p`,{className:`dim act-sm`,children:E?`A session that waits on an approval or on your answer counts here.`:`Turn tracking on to count the sessions that wait on you.`})]}):(0,V.jsx)(`p`,{className:`dim act-sm`,children:`The sessions could not be read.`})]})]}),(0,V.jsxs)(`div`,{className:`row wrap gap-8 act-filters`,children:[(0,V.jsx)(`div`,{role:`group`,"aria-label":`Filter`,className:`row wrap gap-8`,children:le.map(([e,t])=>(0,V.jsxs)(`button`,{type:`button`,className:s.f===e?`chip-f on`:`chip-f`,"aria-pressed":s.f===e,onClick:()=>x({f:e}),children:[t,e===`needs`&&j>0?(0,V.jsxs)(`span`,{className:`mono`,children:[` `,j]}):null]},e))}),Q(`host`,`Host`,P),Q(`project`,`Project`,F),(0,V.jsx)(h,{"aria-label":`Live sessions view`,children:[[`list`,`List`],[`garden`,`Garden`]].map(([e,t])=>(0,V.jsx)(`button`,{type:`button`,className:s.v===e?`on`:``,"aria-pressed":s.v===e,onClick:()=>x({v:e}),children:t},e))})]}),I&&s.f!==`needs`&&(0,V.jsxs)(`p`,{className:`dim act-sm`,children:[`Runs and gate asks carry no `,I,`; showing sessions only.`]}),ne&&(e?!E&&s.f!==`needs`?null:z.length===0?s.f===`needs`?(0,V.jsx)(C,{title:`Nothing waits on you`}):(0,V.jsx)(C,{title:`No active sessions`,children:`Start an agent session and it appears here.`}):s.v===`garden`?(0,V.jsx)(ie,{sessions:z,collisions:e.collisions}):(0,V.jsx)(`div`,{className:`stack gap-12 act-live`,ref:A,children:z.map(e=>(0,V.jsx)(`div`,{"data-flip":L(e),children:(0,V.jsx)(oe,{s:e})},L(e)))}):(0,V.jsx)(_,{label:`Reading live sessions…`})),H.length>0&&(0,V.jsxs)(`section`,{className:`stack gap-12 act-live act-ended`,"aria-labelledby":`act-ended-h`,children:[(0,V.jsx)(`h2`,{id:`act-ended-h`,className:`act-lbl`,children:`Recently ended`}),U.map(e=>(0,V.jsx)(`div`,{children:(0,V.jsx)(oe,{s:e})},L(e))),H.length>ve&&(0,V.jsx)(`button`,{type:`button`,className:`btn ghost sm`,"aria-expanded":f,onClick:()=>m(e=>!e),children:f?`Show fewer`:`Show all ${H.length}`})]}),s.f!==`needs`&&(0,V.jsx)(`section`,{"aria-label":`Feed`,className:`stack gap-16 act-feed`,ref:X,children:J.map(e=>(0,V.jsxs)(`section`,{className:`card act-day`,children:[(0,V.jsxs)(`h3`,{className:`act-day-h`,children:[(0,V.jsx)(`span`,{children:e.title}),(0,V.jsx)(`span`,{className:`mono dim`,children:e.sum})]}),(0,V.jsxs)(`ul`,{className:`act-rows`,children:[e.runs.map(e=>(0,V.jsx)(ge,{job:e,longest:Y},e.id)),e.gate&&(0,V.jsx)(_e,{gate:e.gate})]})]},e.key))})]})}export{be as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-C1iE8mnY.js";import{t as r}from"./api-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-C1iE8mnY.js";import{t as r}from"./api-D_r0Jtla.js";import{H as i,M as a,O as o,T as s,X as c,Y as l,k as u,rt as d,st as f}from"./index-HfGmYXab.js";import{t as p}from"./EmptyState-CY5Pm2xy.js";import{a as m,d as h,f as g,i as _,l as v,o as y,r as b,t as x,v as S}from"./Bonsai-C1iBAt4v.js";import{t as C}from"./usePoll-o8ul-Sog.js";var w=e(t(),1),T=n();function E(e){return e.kind===`tool`?e.status===`error`?`bad`:e.status===`completed`?`ok`:`acc`:{retry:`warn`,error:`bad`,subtask:`acc`,text:`acc`}[e.kind]||``}function D({rec:e}){let t=e.who===`you`,n=[];t||(e.kind===`tool`&&e.ms!=null&&n.push(`${(e.ms/1e3).toFixed(1)}s`),e.kind===`step`&&(e.tokens&&n.push(`${u(e.tokens)} tok`),e.cost&&n.push(`$${e.cost.toFixed(2)}`)),e.kind===`subtask`&&e.agent&&n.unshift(e.agent));let r=!t&&(e.kind===`text`||e.kind===`thinking`||e.kind===`step`),i=t?e.text:e.label||e.snippet||e.kind;return(0,T.jsxs)(`div`,{className:`row gap-10 act-line`,children:[(0,T.jsx)(`span`,{className:`badge act-who ${t?``:`acc`}`,children:t?`you`:`agent`}),(0,T.jsxs)(`div`,{className:`act-grow act-sm`,children:[!t&&(0,T.jsx)(`span`,{className:`feed-dot act-inline-dot ${E(e)||`acc`}`}),e.kind===`thinking`&&(0,T.jsx)(`span`,{className:`dim`,children:`thinking: `}),r?(0,T.jsx)(`span`,{className:`dim`,children:i}):t?i:(0,T.jsx)(`b`,{children:i}),e.error&&(0,T.jsxs)(`span`,{className:`dim`,children:[`: `,e.error]})]}),n.length>0&&(0,T.jsx)(`span`,{className:`dim mono act-xs act-fixed`,children:n.join(` · `)}),e.t?(0,T.jsx)(`time`,{className:`mono dim act-xs act-fixed`,dateTime:new Date(e.t).toISOString(),title:`${f(e.t/1e3)} ago`,children:new Date(e.t).toTimeString().slice(0,8)}):null]})}function O({turns:e}){return!e||e.length===0?(0,T.jsx)(`div`,{className:`dim act-sm`,children:`No conversation captured yet.`}):(0,T.jsx)(`div`,{className:`stack gap-12`,children:e.map((e,t)=>{let n=e.role===`user`;return(0,T.jsxs)(`div`,{className:`row gap-10 act-line`,children:[(0,T.jsx)(`span`,{className:`badge act-who ${n?``:`acc`}`,children:n?`you`:`agent`}),(0,T.jsx)(`div`,{className:`act-min act-sm${n?``:` muted`}`,children:e.text})]},t)})})}var k=5;function A({s:e}){let[t]=(0,w.useState)(y),[n,r]=(0,w.useState)(null),i=!!e.ended,o=i?{...e,status:a(e)?`busy`:e.status,error:null}:e,s=S(o,t),c=(0,w.useMemo)(()=>g(o,{sakura:t}),[s]),l=(0,w.useCallback)(e=>r(e),[]),u=v(e),d=Number(e.turns)||0,f=Number(e.compactions)||0,p=[`${d} turn${d===1?``:`s`}`,`context ${u==null?`unknown`:`${Math.round(u*100)} %`}`,`${f} compaction${f===1?``:`s`}`,`sub-agents: ${c.pads.filter(e=>e.key!=null).length} ${i?`unfinished`:`running`}, ${c.fallen.length} finished`].join(` · `),h=n==null?null:c.pads[n];return(0,T.jsxs)(`div`,{className:`card pad-md act-mt gd-detail${!i&&a(e)?` gd-needs`:``}`,children:[(0,T.jsx)(`div`,{role:`group`,tabIndex:0,"aria-label":`Bonsai pads, arrow keys walk them`,onKeyDown:e=>_(e,c.pads.length,n,l),children:(0,T.jsx)(b,{t:c,pad:n,swaying:!i&&e.status!==`idle`,onPad:l,px:k,label:`Bonsai of this session${i?`, ended`:``}: ${p}`})}),(0,T.jsxs)(`div`,{className:`stack gap-8 act-min`,children:[i&&(0,T.jsx)(`span`,{className:`dim act-xs`,children:`ended`}),(0,T.jsx)(`div`,{className:`dim act-sm`,children:p}),(0,T.jsx)(`span`,{className:`sr-only`,role:`status`,children:m(h)}),h?(0,T.jsx)(x,{pad:h}):(0,T.jsx)(`div`,{className:`dim act-xs`,children:`Hover or tap a pad, or use the arrow keys, for its files.`})]})]})}function j({sid:e}){let{sid:t,install:n}=h(e,window.location.hash),[a,u]=(0,w.useState)(null),[m,g]=(0,w.useState)(``),[_,v]=(0,w.useState)(!1),[y,b]=(0,w.useState)(!1),x=(0,w.useId)();C(e=>_?void 0:r.activityDetail(t,n).then(t=>{e()&&(u(t),g(``),v(!1))},t=>{e()&&(t.status===404?v(!0):g(t.message))}),2e3,[t,_]);let S=(0,T.jsxs)(`a`,{className:`btn ghost sm act-back`,href:`#/activity`,children:[(0,T.jsx)(d,{name:`arrow`}),` Activity`]});if(_)return(0,T.jsxs)(`div`,{className:`page-fill`,children:[S,(0,T.jsx)(p,{title:`Session ended`,action:(0,T.jsx)(`a`,{href:`#/activity`,children:`Back to Activity`}),children:`It's no longer live.`})]});if(!a)return(0,T.jsxs)(`div`,{className:`page-fill`,children:[S,m?(0,T.jsx)(l,{error:m}):(0,T.jsx)(c,{label:`Loading session…`})]});let E=a.session,k=E.files,j=E.todos,M=!!(k&&k.items&&k.items.length>0),N=!!(j&&j.items&&j.items.length>0),P=a.conversation||[],F=a.timeline||[],I=[...P.filter(e=>e.role===`user`).map(e=>({who:`you`,text:e.text,t:e.t||0})),...F.map(e=>({...e,who:`agent`}))].sort((e,t)=>(e.t||0)-(t.t||0));return(0,T.jsxs)(`div`,{className:`page-fill`,children:[S,(0,T.jsx)(i,{title:E.title||o(E.cwd)||E.session_id,sub:E.cwd?(0,T.jsx)(`span`,{className:`mono act-cwd`,title:E.cwd,children:E.cwd}):null}),m&&(0,T.jsx)(`div`,{className:`act-gap`,children:(0,T.jsx)(l,{error:m})}),(0,T.jsxs)(`div`,{className:`card pad-md`,children:[(0,T.jsx)(s,{s:E}),(0,T.jsxs)(`div`,{className:`dim act-updated`,children:[`updated `,f(E.updated_at),` ago`]})]}),(0,T.jsx)(A,{s:E}),(M||N)&&(0,T.jsxs)(`div`,{className:`grid gap-12 act-panels${M&&N?` two`:``}`,children:[M&&(0,T.jsxs)(`div`,{className:`card pad-md`,children:[(0,T.jsx)(`div`,{className:`card-head`,children:(0,T.jsxs)(`h2`,{children:[`Files touched `,(0,T.jsxs)(`span`,{className:`dim`,children:[`(`,k.count,`)`]})]})}),(0,T.jsx)(`div`,{className:`stack act-list`,children:k.items.map(e=>(0,T.jsxs)(`div`,{className:`row between gap-12 act-sm`,children:[(0,T.jsx)(`span`,{className:`mono act-ell act-grow`,title:e.file,children:e.file}),(0,T.jsxs)(`span`,{className:`act-fixed`,children:[(0,T.jsxs)(`span`,{className:`t-good`,children:[`+`,e.additions]}),` `,(0,T.jsxs)(`span`,{className:`t-bad`,children:[`−`,e.deletions]})]})]},e.file))})]}),N&&(0,T.jsxs)(`div`,{className:`card pad-md`,children:[(0,T.jsx)(`div`,{className:`card-head`,children:(0,T.jsxs)(`h2`,{children:[`Plan`,` `,(0,T.jsxs)(`span`,{className:`dim`,children:[`(`,j.done,`/`,j.total,`)`]})]})}),(0,T.jsx)(`div`,{className:`stack act-list`,children:j.items.map((e,t)=>(0,T.jsxs)(`div`,{className:`row gap-8 act-sm`,children:[(0,T.jsx)(`span`,{className:`feed-dot ${e.status===`completed`?`ok`:e.status===`in_progress`?`acc`:``}`}),(0,T.jsx)(`span`,{className:e.status===`completed`?`act-done`:void 0,children:e.content})]},t))})]})]}),(0,T.jsxs)(`div`,{className:`card pad-md act-mt`,children:[(0,T.jsxs)(`div`,{className:`card-head act-tl-head`,children:[(0,T.jsx)(`h2`,{children:`Timeline`}),F.length>0&&(0,T.jsx)(`button`,{className:`btn ghost sm`,"aria-expanded":y,"aria-controls":x,onClick:()=>b(e=>!e),children:y?`Show conversation`:`Show full stream (${I.length})`})]}),(0,T.jsx)(`div`,{id:x,children:y?(0,T.jsx)(`div`,{className:`stack gap-12`,children:I.map((e,t)=>(0,T.jsx)(D,{rec:e},t))}):(0,T.jsx)(O,{turns:P})})]})]})}export{A as SessionTree,j as default};
|