geneseed 6.0.2 → 6.0.3

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/SHIPPED.md +1 -1
  3. package/adapters/opencode/plugins/geneseed-context.js +53 -10
  4. package/adapters/opencode/plugins/geneseed-learn.js +11 -4
  5. package/docs/web-ui.md +25 -0
  6. package/harness.config.json +1 -1
  7. package/js/build/bundle.mjs +2 -11
  8. package/js/build/fold.mjs +3 -20
  9. package/js/build/stubs.mjs +42 -5
  10. package/js/hosts/hooks-context.mjs +65 -9
  11. package/js/hosts/memory-files.mjs +166 -13
  12. package/js/inspect/doctor.mjs +2 -0
  13. package/js/inspect/status.mjs +4 -1
  14. package/js/maintain/memory.mjs +2 -2
  15. package/js/web/catalog.mjs +5 -3
  16. package/package.json +1 -1
  17. package/src/agents/memory-curator.md +1 -1
  18. package/src/memory/README.md +24 -5
  19. package/src/skills/rule/approve.md +3 -1
  20. package/src/skills/rule/consolidate.md +1 -1
  21. package/web/dist/assets/ActiveLoops-paFbiZyt.js +1 -0
  22. package/web/dist/assets/Activity-IAxWF2wK.js +1 -0
  23. package/web/dist/assets/ActivityDetail-CtC2DLvh.js +1 -0
  24. package/web/dist/assets/{Bonsai-Bry-kOFb.js → Bonsai-BoKo68Kw.js} +1 -1
  25. package/web/dist/assets/{CopyButton-Cnnvjgkg.js → CopyButton-C0VTiqmb.js} +1 -1
  26. package/web/dist/assets/Dashboard-CRGCp2cV.js +2 -0
  27. package/web/dist/assets/{Docs-BJ23-fIx.js → Docs-DwOwzaD6.js} +2 -2
  28. package/web/dist/assets/Factories-DxHD2T-1.js +1 -0
  29. package/web/dist/assets/{GreenhouseView-VL_ZKJUR.js → GreenhouseView-D5VOmhmR.js} +1 -1
  30. package/web/dist/assets/Installs-B5hFSUeN.js +3 -0
  31. package/web/dist/assets/JournalView-gUSGysTm.js +1 -0
  32. package/web/dist/assets/{Kits-DDSerkJk.js → Kits-DYQvykZ0.js} +1 -1
  33. package/web/dist/assets/Laws-UVk0uojS.js +4 -0
  34. package/web/dist/assets/{LibRows-QsUBjOF7.js → LibRows-CwK63kjB.js} +1 -1
  35. package/web/dist/assets/Library-DdzyrwUK.js +3 -0
  36. package/web/dist/assets/Loops-yHga7xdr.js +2 -0
  37. package/web/dist/assets/Models-DAgkQ4CE.js +1 -0
  38. package/web/dist/assets/{OperatorHudView-Bdupodlc.js → OperatorHudView-D1lQF-ZY.js} +1 -1
  39. package/web/dist/assets/Personal-DjhIfa9v.js +2 -0
  40. package/web/dist/assets/Settings-Brgec4M0.js +1 -0
  41. package/web/dist/assets/Tabs-BHjxciOL.js +1 -0
  42. package/web/dist/assets/index-BILaKHbH.js +6 -0
  43. package/web/dist/assets/index-BfyZCNu7.css +1 -0
  44. package/web/dist/assets/router-1EhRJy1C.js +1 -0
  45. package/web/dist/assets/useLocalStorage-54tkqXN7.js +1 -0
  46. package/web/dist/index.html +4 -2
  47. package/web/dist/assets/ActiveLoops-BWkImeYa.js +0 -1
  48. package/web/dist/assets/Activity-DJlPhk8q.js +0 -1
  49. package/web/dist/assets/ActivityDetail-Dk7UPnE_.js +0 -1
  50. package/web/dist/assets/Dashboard-CWhh_GSc.js +0 -2
  51. package/web/dist/assets/Factories-CjsIACyi.js +0 -1
  52. package/web/dist/assets/Installs-qcfOZNzF.js +0 -3
  53. package/web/dist/assets/JournalView-KrmFUC-X.js +0 -1
  54. package/web/dist/assets/Laws-DDffPs6O.js +0 -4
  55. package/web/dist/assets/Library-DzT3Mebh.js +0 -3
  56. package/web/dist/assets/Loops-CjsX3brz.js +0 -2
  57. package/web/dist/assets/Models-DPrAv3FG.js +0 -1
  58. package/web/dist/assets/Personal-D-dpCUU5.js +0 -2
  59. package/web/dist/assets/Settings-Dz33_Sys.js +0 -1
  60. package/web/dist/assets/Tabs-qY40S34V.js +0 -1
  61. package/web/dist/assets/index-BhT94v2q.js +0 -6
  62. package/web/dist/assets/index-DcusoHzF.css +0 -1
  63. package/web/dist/assets/usePoll-D5c_qIFZ.js +0 -1
@@ -15,10 +15,11 @@
15
15
  * import `js/web` (spec C20).
16
16
  */
17
17
  import { isUtf8 } from 'node:buffer';
18
+ import { createHash } from 'node:crypto';
18
19
  import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmdirSync, unlinkSync } from 'node:fs';
19
20
  import path from 'node:path';
20
21
  import { readText, writeText, writeTextAtomic } from '../lib/fs.mjs';
21
- import { isDict } from '../lib/json.mjs';
22
+ import { isDict, jsonDumpsIndent } from '../lib/json.mjs';
22
23
  import { normcase } from '../lib/paths.mjs';
23
24
  import { WHITESPACE, stripWhitespace } from '../lib/text.mjs';
24
25
  import { isFile, listDir, sortPaths, splitLines, splitWords } from './hooks-prims.mjs';
@@ -115,12 +116,25 @@ function globMd(dir) {
115
116
  /** Stems that name the store's own files, never a fact — `MEMORY` is the index itself. */
116
117
  export const RESERVED_STEMS = new Set(['memory', 'readme']);
117
118
 
119
+ /**
120
+ * IS THIS TOP-LEVEL STEM A STORE DOCUMENT RATHER THAN A FACT? (D2) `memory` and `readme` in any case,
121
+ * and any stem written wholly in capitals: `MEMORY`, `README`, `ARCHIVE-INDEX`. A person names the
122
+ * documents that describe a store in capitals, and a fact is a lower-case slug. Without
123
+ * this a hand-written `ARCHIVE-INDEX.md` was indexed as a fact under `misc`, listed to `learn`, and
124
+ * counted by the curation nudge. A stem with no letter in it (`2026`) is no document: it has no case.
125
+ *
126
+ * ONE PREDICATE, EVERY READER: the plugins carry a twin (`geneseed-learn.js`), the console's
127
+ * `isFurniture` and `geneseed memory rm` call this one, so a list and its count cannot disagree.
128
+ */
129
+ export const isReservedStem = (stem) => RESERVED_STEMS.has(stem.toLowerCase())
130
+ || (stem === stem.toUpperCase() && stem !== stem.toLowerCase());
131
+
118
132
  /**
119
133
  * `_existing_slugs` — slugs already stored. learn never CREATES one of these; it may only
120
134
  * update or archive it by name (`writeMemories`).
121
135
  */
122
136
  export function existingSlugs(memDir) {
123
- return new Set(globMd(memDir).map(stem).filter((s) => !RESERVED_STEMS.has(s.toLowerCase())));
137
+ return new Set(globMd(memDir).map(stem).filter((s) => !isReservedStem(s)));
124
138
  }
125
139
 
126
140
  /**
@@ -169,7 +183,7 @@ export function readFacts(memDir) {
169
183
  const facts = new Map();
170
184
  for (const name of sortPaths(globMd(memDir))) {
171
185
  const s = stem(name);
172
- if (RESERVED_STEMS.has(s.toLowerCase())) continue;
186
+ if (isReservedStem(s)) continue;
173
187
  try {
174
188
  const [fm] = frontmatter(readText(path.join(memDir, name)));
175
189
  facts.set(s, { desc: fmGet(fm, 'description').trim(), topic: topicOf(fm) });
@@ -212,13 +226,14 @@ export function indexNotes(memDir, generated) {
212
226
  * Rewrite MEMORY.md as the map: one line per topic file with its fact count.
213
227
  *
214
228
  * LINES THE MAP DID NOT GENERATE ARE CARRIED, so a note the user wrote into the index
215
- * survives. `dropFlat` also drops legacy flat fact pointers; a rebuild passes it because it
216
- * has just moved them into topic files. With no topic and nothing carried, the file goes
217
- * back to the seed.
229
+ * survives. `generated(slug)` says which legacy flat fact pointers a rebuild has just moved into
230
+ * topic files, and only those are dropped (D4): a pointer to a store document (`ARCHIVE-INDEX`) or
231
+ * to a fact that is not on disk is no fact line, so it stays like any other line a person wrote.
232
+ * With no topic and nothing carried, the file goes back to the seed.
218
233
  */
219
- function writeMap(memDir, dropFlat) {
234
+ function writeMap(memDir, generated) {
220
235
  const idx = path.join(memDir, 'MEMORY.md');
221
- const carried = indexNotes(memDir, () => dropFlat);
236
+ const carried = indexNotes(memDir, generated);
222
237
  const tdir = path.join(memDir, TOPICS);
223
238
  const topics = globMd(tdir).map(stem).sort().map((t) => {
224
239
  const n = (readLines(path.join(tdir, `${t}.md`)) ?? [])
@@ -264,7 +279,12 @@ function rebuildIndex(memDir, refresh, fresh = new Set()) {
264
279
  writeIfChanged(path.join(tdir, `${topic}.md`), `# ${topic}\n\n${lines.join('\n')}\n`);
265
280
  }
266
281
  if (!byTopic.size) pruneTopicsDir(memDir);
267
- writeMap(memDir, true);
282
+ // A flat pointer is generated, and so dropped, unless it names a STORE DOCUMENT (`ARCHIVE-INDEX.md`):
283
+ // a fact's pointer has moved into a topic file, a dead one (no such file) is the old rule's, and
284
+ // a document is no fact, so its line is one a person wrote and stays (D4).
285
+ const known = new Set([...facts.keys()].map((slug) => slug.toLowerCase()));
286
+ const documents = new Set(globMd(memDir).map((n) => stem(n).toLowerCase()).filter((s) => !known.has(s)));
287
+ writeMap(memDir, (slug) => !documents.has(slug.toLowerCase()));
268
288
  return { facts, old };
269
289
  }
270
290
 
@@ -276,12 +296,27 @@ function rebuildIndex(memDir, refresh, fresh = new Set()) {
276
296
  * `topics/*.md` only, never a fact file, and it keeps each pointer's own title and hook.
277
297
  */
278
298
  export function migrateMemoryIndex(memDir) {
279
- const lines = readLines(path.join(memDir, 'MEMORY.md'));
280
- if (!lines?.some((l) => FACT_LINE_RE.test(l.trim())) || !existingSlugs(memDir).size) return false;
299
+ if (!holdsFlatFacts(memDir)) return false;
281
300
  rebuildIndex(memDir, false);
282
301
  return true;
283
302
  }
284
303
 
304
+ /**
305
+ * Does MEMORY.md still hold a flat pointer to a STORED fact? The one test of "this index is flat",
306
+ * for the migration and for the pick of always-on candidates (`alwaysOnCandidates`). A pointer to a
307
+ * store document or to a fact that is gone is carried by the migration (D4) and is no fact to move,
308
+ * so a migrated index that carries one is not flat, and the next emit finds nothing to do.
309
+ */
310
+ export function holdsFlatFacts(memDir) {
311
+ const lines = readLines(path.join(memDir, 'MEMORY.md'));
312
+ if (!lines) return false;
313
+ const slugs = new Set([...existingSlugs(memDir)].map((s) => s.toLowerCase()));
314
+ return lines.some((l) => {
315
+ const m = FACT_LINE_RE.exec(l.trim());
316
+ return m !== null && slugs.has(m[2].toLowerCase());
317
+ });
318
+ }
319
+
285
320
  /** The chunk without its frontmatter `action:` line, which is an instruction, not the fact. */
286
321
  function stripAction(chunk) {
287
322
  const lines = chunk.split('\n');
@@ -350,7 +385,7 @@ export function writeMemories(modelOutput, memDir, existing) {
350
385
  const name = fmGet(fm, 'name').trim();
351
386
  const key = name.toLowerCase();
352
387
  const action = fmGet(fm, 'action').trim().toLowerCase() || 'create';
353
- if (!MEMORY_SLUG_RE.test(name) || RESERVED_STEMS.has(key) || done.has(key)) continue;
388
+ if (!MEMORY_SLUG_RE.test(name) || isReservedStem(name) || done.has(key)) continue;
354
389
  const slug = stored.get(key);
355
390
  if (slug && action !== 'create' && hasForce(memDir, slug)) continue;
356
391
  const body = `${stripAction(chunk).replace(/\n+$/, '')}\n`;
@@ -414,7 +449,7 @@ export function memoryDropIndex(memDir, name) {
414
449
  }
415
450
  if (!touched) return;
416
451
  pruneTopicsDir(memDir);
417
- try { writeMap(memDir, false); } catch { /* best-effort */ }
452
+ try { writeMap(memDir, () => false); } catch { /* best-effort */ }
418
453
  }
419
454
 
420
455
  /** Drop every line holding `needle`; the kept lines when something went, else null. */
@@ -618,3 +653,121 @@ export function readFoldState(shared) {
618
653
  if (blank(state.items)) state.items = {};
619
654
  return state;
620
655
  }
656
+
657
+ export const itemKey = (kind, host, bytes) => createHash('sha256').update(`${kind}\0${host}\0`).update(bytes).digest('hex');
658
+
659
+ const DRAFT_HEAD = '# User rules — draft\n\nNot active. The rule Rite or the console applies decisions.\n';
660
+
661
+ /**
662
+ * A block in the draft and a C7 record. The key names the host too, so two hosts holding the same
663
+ * text are two decisions. Draft first: a stop between the writes leaves a block the next run
664
+ * recognises, not a lost one. `extra` rides on the ledger row (`fact`, for a memory candidate).
665
+ *
666
+ * HERE, NOT IN THE FOLD, since D31: the tier's memory step (`ensureSharedTier`, `stubs.mjs`) drafts too,
667
+ * and `fold.mjs` imports `stubs.mjs` for its seeds, so the fold's home for this would be a cycle.
668
+ */
669
+ export function draftItem(kind, key, block, tally, { host, shared, dryRun, report }, extra = {}) {
670
+ const state = readFoldState(shared);
671
+ if (state.items[key]) return;
672
+ report[tally] += 1;
673
+ if (dryRun) return;
674
+ const text = existsSync(shared.draft) ? readText(shared.draft) : DRAFT_HEAD;
675
+ if (!text.includes(`sha256: ${key}`)) writeTextAtomic(shared.draft, `${text}\n${block}`);
676
+ state.items[key] = { kind, host, state: 'pending', ...extra };
677
+ writeTextAtomic(shared.foldState, `${jsonDumpsIndent(state)}\n`);
678
+ }
679
+
680
+ /**
681
+ * The part of a flat MEMORY.md the session hook used to inject, in characters. Memory was the 4th
682
+ * of 5 session files, and what the 9 000-character payload left after the rules, profile and
683
+ * wiki was cut by position (`capToRoom`): 3 072 of 8 509 characters on the machine this was
684
+ * measured on (2026-11-18). A rule whose pointer sat inside that part was in force by ACCIDENT of
685
+ * its line number, which is exactly what a draft asks the user to turn into a decision.
686
+ */
687
+ export const LEGACY_INJECT_CHARS = 3072;
688
+ /** At most this many candidates are drafted at one migration: a console of 100 drafts is noise. */
689
+ export const MAX_ALWAYS_ON = 30;
690
+ const ALWAYS_WORDS_RE = /\b(?:always|never|toujours|jamais)\b/i;
691
+ const DRAFT_BODY_MAX = 1500;
692
+ const DRAFT_TITLE_MAX = 100;
693
+ export const MEMORY_DRAFT_HOST = 'memory';
694
+
695
+ /**
696
+ * Whether `learn` can run here (D12): it needs `$GENESEED_LLM`, and with it unset the Stop hook
697
+ * returns early and no fact is ever distilled, which nothing used to say. One wording for `status`
698
+ * and `doctor`.
699
+ */
700
+ export const learnState = (env = process.env) => (env.GENESEED_LLM ? 'active' : 'dormant ($GENESEED_LLM unset)');
701
+
702
+ const oneLine = (text, max) => {
703
+ const t = text.replace(/\s+/g, ' ').trim();
704
+ return t.length > max ? `${t.slice(0, max - 1)}…` : t;
705
+ };
706
+
707
+ /**
708
+ * A fact's text as a rule body. A `## ` line would end the draft's block and open another, so it
709
+ * is demoted to `### `; a long fact is cut and says where the rest is. The description stands in
710
+ * for an empty body.
711
+ */
712
+ function draftBody(body, desc) {
713
+ const text = stripWhitespace(body.replace(/^## /gm, '### ')) || desc;
714
+ return text.length > DRAFT_BODY_MAX ? `${text.slice(0, DRAFT_BODY_MAX)}…\n(cut: the whole fact is in memory/)` : text;
715
+ }
716
+
717
+ /**
718
+ * The facts a FLAT index would have loaded at every session and that read as standing rules (D31),
719
+ * picked without a model: `force: constraint`, or a `feedback` fact whose pointer sat in the
720
+ * injected part (`LEGACY_INJECT_CHARS`), or a `feedback` fact whose description says always,
721
+ * never (or toujours, jamais). Priority in that order, then slug; `[]` for a store that is
722
+ * not flat, so a second emit picks nothing. Read BEFORE `migrateMemoryIndex`, which erases the
723
+ * flat index. Each is `{ slug, title, body, reason }`.
724
+ */
725
+ export function alwaysOnCandidates(memDir) {
726
+ if (!holdsFlatFacts(memDir)) return [];
727
+ const lines = readLines(path.join(memDir, 'MEMORY.md'));
728
+ const injected = new Set();
729
+ let at = 0;
730
+ for (const line of lines) {
731
+ at += line.length + 1;
732
+ const m = FACT_LINE_RE.exec(line.trim());
733
+ if (m && at <= LEGACY_INJECT_CHARS) injected.add(m[2].toLowerCase());
734
+ }
735
+ const rank = { constraint: 0, injected: 1, described: 2 };
736
+ const found = [];
737
+ for (const slug of [...existingSlugs(memDir)].sort()) {
738
+ let fm; let body;
739
+ try { [fm, body] = frontmatter(readText(path.join(memDir, `${slug}.md`))); } catch { continue; }
740
+ const desc = fmGet(fm, 'description').trim();
741
+ // The TYPE, not the topic: `topic:` only files the fact, and a `type: feedback` fact filed under
742
+ // `topic: git` is still a rule about how to work. (A nested `metadata: type:` reads as `type`.)
743
+ const feedback = topicSlug(fmGet(fm, 'type')) === 'feedback';
744
+ const reason = fmGet(fm, 'force').trim().toLowerCase() === 'constraint' ? 'constraint'
745
+ : feedback && injected.has(slug.toLowerCase()) ? 'injected'
746
+ : feedback && ALWAYS_WORDS_RE.test(desc) ? 'described' : null;
747
+ if (!reason) continue;
748
+ found.push({ slug, reason, title: oneLine(desc || slug, DRAFT_TITLE_MAX), body: draftBody(body, desc) });
749
+ }
750
+ return found.sort((a, b) => rank[a.reason] - rank[b.reason]).slice(0, MAX_ALWAYS_ON);
751
+ }
752
+
753
+ /**
754
+ * Write each candidate as a draft through the fold's own path, one block and one ledger row, with
755
+ * the fact's slug on the row: the session hook reads it for the bridge slot (D31), and the row
756
+ * leaves the slot when the user decides. Idempotent: `draftItem` skips a key the ledger holds,
757
+ * decided or not. Never touches `user-rules.md`; approval is the console's or the Rite's.
758
+ */
759
+ export function draftAlwaysOn(shared, candidates) {
760
+ const ctx = { host: MEMORY_DRAFT_HOST, shared, dryRun: false, report: { rules: 0 } };
761
+ let n = 0;
762
+ for (const c of candidates) {
763
+ // The key is the text the way `rule-decide.mjs` re-reads it, so the block can be decided.
764
+ const [rules] = parseRules(`## R0 — ${c.title}\n${c.body}\n`);
765
+ if (rules.length !== 1) continue;
766
+ n += 1;
767
+ const key = itemKey('rule', MEMORY_DRAFT_HOST, `${rules[0].title}\n${rules[0].body}`);
768
+ draftItem('rule', key, `${draftRuleHead(MEMORY_DRAFT_HOST, c.title)}\n`
769
+ + `(source: ${path.join(shared.memory, `${c.slug}.md`)} | old: R${n} | sha256: ${key})\n`
770
+ + `${c.body}\n`, 'rules', ctx, { fact: c.slug });
771
+ }
772
+ return ctx.report.rules;
773
+ }
@@ -40,6 +40,7 @@ import {
40
40
  import { installProfile } from '../build/profile.mjs';
41
41
  import { providerWarning } from '../maintain/kit-migration.mjs';
42
42
  import { validateIsVendored } from '../hosts/native.mjs';
43
+ import { learnState } from '../hosts/memory-files.mjs';
43
44
  import { printErr, printOut } from '../lib/fs.mjs';
44
45
  import { authoringProblems, factoryProblems, loopProblems } from './checks-authoring.mjs';
45
46
  import { gateProbe, guardProbe } from './checks-probe.mjs';
@@ -290,6 +291,7 @@ export function doctorCollect({
290
291
  problems = problems.concat(ran('shared_paths', 'Rendered shared paths', renderedPathNotes()));
291
292
  problems = problems.concat(ran('providers', 'Workflow provider', providerNotes()));
292
293
  problems = problems.concat(ran('tier_env', 'Model tier aliases', tierEnvNotes()));
294
+ problems = problems.concat(ran('learn', 'Memory learning', [`${NOTE}learn: ${learnState()}`]));
293
295
  problems = problems.concat(ran('map', 'Module map', moduleMapProblems()));
294
296
  problems = problems.concat(ran('host_matrix', 'Host tables', hostMatrixProblems()));
295
297
  problems = problems.concat(ran('host_claims', 'Host claims',
@@ -55,7 +55,7 @@ import { installProfile, rebuildCommand } from '../build/generate.mjs';
55
55
  import { providerWarning } from '../maintain/kit-migration.mjs';
56
56
  import { isDoctorNote } from './scan.mjs';
57
57
  import { pendingDrafts } from '../hosts/hooks-context.mjs';
58
- import { factCount } from '../hosts/memory-files.mjs';
58
+ import { factCount, learnState } from '../hosts/memory-files.mjs';
59
59
  import { lastStoreReport } from '../hosts/store-watch.mjs';
60
60
  import { hookShimPath, shimDead } from '../hosts/shim.mjs';
61
61
  import { printErr, printOut } from '../lib/fs.mjs';
@@ -365,6 +365,7 @@ export function statusData() {
365
365
  agent_md_present: Boolean(agentMd && existsSync(agentMd)),
366
366
  gates: gateSummary([...(cfgDir ? [cfgDir] : []), ...otherCfg]),
367
367
  drafts_pending: pendingDrafts(),
368
+ learn: learnState(),
368
369
  store_report: lastStoreReport(),
369
370
  opencode_shadow: opencodeShadowedInstall(),
370
371
  openclaude_dual_harness: openclaudeDualHarnessRoots(),
@@ -477,6 +478,8 @@ export function statusLines(d, color = false, boxed = true) {
477
478
  rows.push(['gates', `${armed} ${DOT} ${g.total} ask${g.total === 1 ? '' : 's'}`
478
479
  + (byRule ? ` (${byRule})` : '')]);
479
480
  }
481
+ // Conditional for the recording reason again; says why no fact is ever distilled on a machine without a model (D12).
482
+ if (d.learn) rows.push(['learn', d.learn]);
480
483
  if (d.drafts_pending) {
481
484
  rows.push(['drafts', `${d.drafts_pending} in user-rules.draft.md wait${d.drafts_pending === 1 ? 's' : ''} for your decision`]);
482
485
  }
@@ -48,7 +48,7 @@
48
48
  import { readdirSync, unlinkSync } from 'node:fs';
49
49
  import path from 'node:path';
50
50
 
51
- import { RESERVED_STEMS, archiveFact, consolidateMemory, memoryDropIndex } from '../hosts/memory-files.mjs';
51
+ import { archiveFact, consolidateMemory, isReservedStem, memoryDropIndex } from '../hosts/memory-files.mjs';
52
52
  import { recordOwnWrites } from '../hosts/store-watch.mjs';
53
53
  import { resolveMemoryDir } from '../hosts/hosts.mjs';
54
54
  import { printOut, printErr, isFile } from '../lib/fs.mjs';
@@ -57,7 +57,7 @@ import { printOut, printErr, isFile } from '../lib/fs.mjs';
57
57
  export function isFactName(name) {
58
58
  return Boolean(name) && !name.includes('/') && !name.includes('\\')
59
59
  && ![...name].some((c) => c.charCodeAt(0) < 0x20 || c.charCodeAt(0) === 0x7f)
60
- && !RESERVED_STEMS.has(name.toLowerCase());
60
+ && !isReservedStem(name);
61
61
  }
62
62
 
63
63
  /**
@@ -30,7 +30,7 @@ import { comparePaths, normcase, within } from '../lib/paths.mjs';
30
30
  import { stripWhitespace } from '../lib/text.mjs';
31
31
  import { readJsonc } from '../hosts/settings.mjs';
32
32
  import { SRC, loadKits, makeCfg, ruleCanon, ruleSummaries } from '../build/source.mjs';
33
- import { RESERVED_STEMS } from '../hosts/memory-files.mjs';
33
+ import { RESERVED_STEMS, isReservedStem } from '../hosts/memory-files.mjs';
34
34
  import { loadTheme } from '../build/render.mjs';
35
35
 
36
36
  /** A requested catalog section or item that does not exist. */
@@ -213,8 +213,10 @@ export const stemOf = (name) => name.slice(0, name.length - path.extname(name).l
213
213
  * map) but no list holds them, so a list and its count cannot disagree.
214
214
  */
215
215
  export const isFurniture = (file, index) => {
216
- const stem = stemOf(file).toLowerCase();
217
- return stem === index || (stem !== 'memory' && RESERVED_STEMS.has(stem));
216
+ const raw = stemOf(file);
217
+ const stem = raw.toLowerCase();
218
+ // The memory store also treats a stem in capitals alone as a document (`ARCHIVE-INDEX`, D2).
219
+ return stem === index || (index === 'memory' ? isReservedStem(raw) : stem !== 'memory' && RESERVED_STEMS.has(stem));
218
220
  };
219
221
 
220
222
  /**
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": "6.0.2",
4
+ "version": "6.0.3",
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",
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## When to dispatch
6
6
  - The {{MEMORY}} store needs tidying in bulk. The session context says so in one
7
- line when a topic holds over 40 facts or a `misc` topic exists; or the user asks
7
+ line when a `misc` topic exists; or the user asks
8
8
  to tidy, dedupe or re-topic their memory.
9
9
  - `geneseed memory consolidate` reported duplicate descriptions that need a merge.
10
10
 
@@ -87,9 +87,10 @@ memory that carries a `force`; revising one stays with the agent and the user.
87
87
  `archive/` needs the user's consent ({{LAW:deletion-is-deliberate}}):
88
88
  `geneseed memory list --archived`, then `geneseed memory rm <name> --archived --purge`.
89
89
  `archive/` is part of this git-ignored store.
90
- - When the store outgrows one careful read — a topic over 40 facts, or facts in
91
- `misc` — the session context says so in one line; the memory-curator {{AGENT}} then
92
- merges, assigns topics and archives in bulk, and proposes deletions for approval.
90
+ - When facts sit in `misc` (no `topic:` and no `type:`), the session context says so in
91
+ one line; the memory-curator {{AGENT}} then assigns topics, merges and archives in
92
+ bulk, and proposes deletions for approval. The size of a topic never raises it: a large
93
+ store is read through its topic files, not curated for its size.
93
94
  - Don't store what the repo already records (code structure, git history, the
94
95
  {{LAWS}}, `user-rules.md`). Store what was *non-obvious*.
95
96
  - When the same `feedback` lesson keeps recurring, propose promoting it into a
@@ -114,8 +115,26 @@ lowercase `[a-z0-9-]`. Both levels are generated from the fact files:
114
115
  `geneseed memory consolidate --memory <this dir>` rebuilds them (refreshing each
115
116
  hook from its `description`), and the `learn` hook rebuilds them after every fact it
116
117
  writes, updates or archives. Only top-level fact files are indexed; `archive/` and
117
- `agents/` never are. A build moves a flat, one-line-per-fact `MEMORY.md` from an older install to
118
- this layout once, keeping each line's own title and hook; it never touches a fact file.
118
+ `agents/` never are.
119
+
120
+ **A top-level file whose name is all capitals is a store document, not a fact:** `MEMORY.md`,
121
+ `README.md`, `ARCHIVE-INDEX.md`. It is never indexed, never filed under `misc`, never shown to
122
+ `learn`, and `geneseed memory rm` refuses it. Name a fact in lower case.
123
+
124
+ **A build moves a flat index to this layout, once, in every store it manages** — each install's
125
+ and the machine tier's. It keeps each pointer's own title and hook and
126
+ every other line of the old `MEMORY.md` (headings, prose, a pointer to a store document), and it
127
+ never touches a fact file. The hand-written headings that grouped the old fact lines now sit above
128
+ nothing; delete them once if they bother you.
129
+
130
+ **Rules the old index loaded every session become drafts.** A flat index was cut by position at
131
+ session start, so what sat in its first 3 072 characters loaded by accident. At the move, a
132
+ `feedback` fact whose line sat there, any fact with `force: constraint`, and a `feedback` fact whose
133
+ description says *always* or *never* (*toujours*, *jamais*) are written to `user-rules.draft.md`
134
+ (at most 30), exactly as the fold drafts a rule; `user-rules.md` is never written without your
135
+ decision. Until you approve or reject a draft in the console or with the rule {{SKILL}}, its fact
136
+ keeps loading at session start, in a slot of at most 1 800 characters under the map; a decided
137
+ draft leaves it. A second build drafts nothing new.
119
138
 
120
139
  ## Per-{{AGENT}} memory (`agents/` subdirectory)
121
140
 
@@ -52,7 +52,9 @@ The lines under the pointer are the rule as it stands, with its own metadata lin
52
52
  blocks after it. This line is a record: leave every `R<n>` citation in the facts as it is.
53
53
  6. Delete the block.
54
54
 
55
- Leave the host file alone. The next fold of that host removes the rule from it.
55
+ Leave the host file alone. The next fold of that host removes the rule from it. A block from host
56
+ `memory` is a fact of the store the build migrated: its `source` is the fact file, and nothing
57
+ removes the fact. Either decision ends the fact's loading under the memory map at session start.
56
58
  - **Reject** means "keep it on this host only". Set the row's `state` to `rejected`, and delete
57
59
  the block. The rule stays in the host file, and the fold never drafts it again.
58
60
 
@@ -1,7 +1,7 @@
1
1
  # {{SKILL}}: rule — consolidation flow
2
2
 
3
3
  Tends the {{MEMORY}} set as a whole. A store too large for one careful read (a
4
- topic over 40 facts, or a `misc` topic) goes to the memory-curator {{AGENT}}
4
+ topic over 40 facts, or a `misc` topic) may go to the memory-curator {{AGENT}}
5
5
  instead: it runs this flow topic by topic in its own context and also assigns topics.
6
6
 
7
7
  1. **Read the whole set once**: `MEMORY.md`, its `topics/` files, every fact they
@@ -0,0 +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"./DataTable-b9zTShqJ.js";var i=e(t(),1),a={x:260,y:190},o=110,s=28,c=14,l=44,u=e=>e*Math.PI/180,d=e=>Math.round(e*10)/10,f=(e,t=o,n=a)=>({x:d(n.x+t*Math.cos(u(e))),y:d(n.y+t*Math.sin(u(e)))}),p=e=>e/o*(180/Math.PI)+3,m=(e,t,n,r=0)=>`M${t.x},${t.y} A${e},${e} 0 ${r} 1 ${n.x},${n.y}`,h=d(f(205).x-6),g=e=>e.length*6.4,_=e=>({x:e.x-g(e.name)/2,y:e.y-7,w:g(e.name),h:14}),v=(e,t)=>e.x<t.x+t.w&&t.x<e.x+e.w&&e.y<t.y+t.h&&t.y<e.y+e.h,y=(e,t)=>e.some((n,r)=>[...e.slice(r+1),...t.filter(e=>!e.gate)].some(e=>v(_(n),_(e))));function b(e){return e?.gate===`human`?e.gateOn?.length?`Human gate on ${e.gateOn.join(`, `)}`:`Human gate`:null}function x(e,t=[]){let n=S(e,t,0);if(n.mode!==`ring`)return n;let r=Math.min(...n.entry.map(e=>e.y-30),...n.nodes.map(e=>e.y-e.r-12),...n.inner.map(e=>e.cy-e.r-12),...n.exit?[n.exit.y-24]:[]);return r<0?S(e,t,Math.ceil(-r)):n}function S(e,t,n){let r={x:a.x,y:a.y+n},i=(e,t=o)=>f(e,t,r),u=e=>t.find(t=>t.name===e),h=e=>u(e)?.effect??null,_=e=>b(u(e)),v=e.loops||[],x=v.find(e=>e.iteration);if(!x||x.nodes.length>8)return C(e,h,_);let S=Math.max(...e.nodes.map(e=>v.filter(t=>t.nodes.includes(e)).length)),w=v.filter(e=>e!==x);if(S>3||w.some(e=>!e.nodes.every(e=>x.nodes.includes(e))))return C(e,h,_);let T=x.nodes[0],E=new Set(e.edges.filter(e=>e.to===T).map(e=>e.from)),D=new Map;for(let e of[...w].sort((e,t)=>e.nodes.length-t.nodes.length))for(let t of e.nodes.slice(1))t!==T&&!E.has(t)&&!D.has(t)&&D.set(t,e);let O=x.nodes.filter(e=>!D.has(e));if(O.length<2||w.some(e=>D.has(e.nodes[0])))return C(e,h,_);let k=360/O.length,A=O.map((e,t)=>({name:e,a:-90+t*k,r:s})),j=A.findIndex(e=>h(e.name)===`mutate`);j>=0&&A.splice(j,0,{name:`validate`,a:A[j].a-k/2,r:c,gate:!0});let M=A.map(e=>({name:e.name,...i(e.a),r:e.r,effect:e.gate?null:h(e.name),gate:!!e.gate,inner:!1,human:e.gate?null:_(e.name)})),N=A.map((e,t)=>{let n=A[(t+1)%A.length],r=(t+1===A.length?n.a+360:n.a)-p(n.r)-2,a=e.a+p(e.r);return{d:m(o,i(a),i(r),+(r-a>180)),kind:`ring`}}),P=[],F=new Map;for(let e of w)F.set(e.nodes[0],[...F.get(e.nodes[0])||[],e]);for(let[e,t]of F){let n=A.find(t=>t.name===e),r=i(n.a),c=t.length>1;t.sort((e,t)=>e.nodes.length-t.nodes.length).forEach((e,t)=>{let u=i(n.a+(c?t?18:-18:0),o+(c?54:44)),p=Math.atan2(u.y-r.y,u.x-r.x)*(180/Math.PI),g=e.nodes.filter(t=>D.get(t)===e),v=e=>g.map((t,n)=>({name:t,...f(p+(n-(g.length-1)/2)*e,l,u)})),b=105;for(;b<150&&y(v(b),M);)b+=5;v(b).forEach(({name:e,...t})=>{M.push({name:e,...t,r:s,effect:h(e),gate:!1,inner:!0,human:_(e)})});let x=p+180;N.push({d:m(l,f(x+42,l,u),f(x+138,l,u)),kind:`inner`}),N.push({d:m(l,f(x+222,l,u),f(x+318,l,u)),kind:`inner`});let S=`${e.nodes.join(e.nodes.length===2?` ⇄ `:` → `)} · max ${e.max}`,C={lx:u.x,ly:u.y+l+20,anchor:`middle`};if(c){let e=u.x>=a.x,t=Math.max(l,...g.map(e=>{let t=M.find(t=>t.name===e);return Math.abs(t.x-u.x)+s}));C={lx:d(u.x+(e?t+8:-t-8)),ly:d(u.y+4),anchor:e?`start`:`end`}}P.push({loop:e.name,cx:u.x,cy:u.y,r:l,label:S,...C})})}let I=i(205).y,L=e.nodes.filter(e=>!x.nodes.includes(e)),R=L.map((e,t)=>({name:e,x:40,y:d(I-44*(L.length-1-t)),human:_(e)})),z=e.edges.find(e=>e.to===`$close`)?.from,B=M.find(e=>e.name===z),V=B?{from:z,x:B.x+200,y:B.y-30,d:`M${B.x+s},${B.y-6} C${B.x+90},${B.y-40} ${B.x+170},${B.y-40} ${B.x+200},${B.y-30}`}:null,H=Math.max(540,...M.map(e=>e.x+e.r+8),...V?[V.x+6+g(`close`)+8]:[],...P.map(e=>e.cx+e.r+8),...P.map(e=>e.anchor===`start`?e.lx+g(e.label)+8:e.lx+g(e.label)/2+8)),U=Math.max(300,...M.map(e=>e.y+e.r+12),...P.map(e=>Math.max(e.cy+e.r,e.ly)+12));return{mode:`ring`,width:Math.ceil(H),height:Math.ceil(U),center:{x:r.x,y:r.y,r:o},nodes:M,arcs:N,inner:P,entry:R,exit:V}}function C(e,t,n){let r=e.loops||[],i=e=>36+16*r.filter(t=>t!==e&&t.nodes.every(t=>e.nodes.includes(t))).length,a=Math.max(s,...r.map(i))+30,o=new Map(e.nodes.map((e,t)=>[e,60+t*100])),c=e.nodes.map(e=>({name:e,x:o.get(e),y:a,r:s,effect:t(e),gate:!1,inner:!1,human:n(e)})),l=e.nodes.slice(1).map((t,n)=>({d:`M${o.get(e.nodes[n])+s},${a} L${o.get(t)-s-4},${a}`,kind:`flow`})),u=r.map(e=>{let t=i(e),n=Math.min(...e.nodes.map(e=>o.get(e))),r=Math.max(...e.nodes.map(e=>o.get(e))),s={x:n-t,y:a-t,w:r-n+2*t,h:2*t};return l.push({d:`M${r},${s.y+s.h} L${n+4},${s.y+s.h}`,kind:`flow`}),{loop:e.name,label:`${e.name} · max ${e.max}`,box:s}});return{mode:`flow`,width:60+e.nodes.length*100,height:2*a,center:null,nodes:c,arcs:l,inner:u,entry:[],exit:null}}var w=n();function T({x:e,y:t,label:n}){return(0,w.jsxs)(`g`,{className:`lr-human`,children:[(0,w.jsx)(`title`,{children:n}),(0,w.jsx)(`circle`,{cx:e,cy:t,r:`9`}),(0,w.jsx)(`circle`,{cx:e,cy:t-2.4,r:`2.6`,className:`lr-human-fig`}),(0,w.jsx)(`path`,{d:`M${e-4.6},${t+5.6} a4.6,4.6 0 0 1 9.2,0 Z`,className:`lr-human-fig`})]})}function E({graph:e,bricks:t,onSelect:n,highlight:r}){let i=x(e,t),a=(e.loops||[]).find(e=>e.iteration),o=e=>`${e.name} brick${e.human?`, ${e.human.toLowerCase()}`:``}`,s=e=>t=>{(t.type===`click`||t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n?.(e))};return(0,w.jsxs)(`svg`,{className:`loop-ring`,viewBox:`0 0 ${i.width} ${i.height}`,style:{"--loop-w":`${i.width}px`},role:`group`,"aria-label":`${e.name} loop: ${e.nodes.join(`, `)}`,children:[(0,w.jsx)(`defs`,{children:[`ring`,`inner`,`flow`].map(e=>(0,w.jsx)(`marker`,{id:`lr-arrow-${e}`,markerWidth:`10`,markerHeight:`10`,refX:`7`,refY:`4`,orient:`auto`,children:(0,w.jsx)(`path`,{d:`M0,0 L8,4 L0,8 Z`,className:`lr-head-${e}`})},e))}),i.mode===`ring`&&i.inner.map(e=>(0,w.jsxs)(`g`,{children:[(0,w.jsx)(`circle`,{cx:e.cx,cy:e.cy,r:e.r,className:`lr-inner`}),(0,w.jsx)(`text`,{x:e.lx,y:e.ly,textAnchor:e.anchor,className:`lr-sub lr-good`,children:e.label})]},e.loop)),i.mode===`flow`&&i.inner.map(e=>(0,w.jsxs)(`g`,{children:[(0,w.jsx)(`rect`,{x:e.box.x,y:e.box.y,width:e.box.w,height:e.box.h,rx:`14`,className:`lr-box`}),(0,w.jsx)(`text`,{x:e.box.x+10,y:e.box.y-6,className:`lr-sub lr-good`,children:e.label})]},e.loop)),i.arcs.map((e,t)=>(0,w.jsx)(`path`,{d:e.d,className:`lr-${e.kind}`,markerEnd:`url(#lr-arrow-${e.kind})`},t)),i.entry.length>0&&(0,w.jsxs)(`g`,{children:[(0,w.jsx)(`path`,{d:`M40,${i.entry.at(-1).y} L${h},${i.entry.at(-1).y}`,className:`lr-flow`,markerEnd:`url(#lr-arrow-flow)`}),i.entry.map(e=>(0,w.jsxs)(`g`,{children:[(0,w.jsx)(`text`,{x:e.x,y:e.y-10,className:`lr-lbl`,children:e.name}),(0,w.jsx)(`text`,{x:e.x,y:e.y+18,className:`lr-sub`,children:`setup · 1×`}),e.human?(0,w.jsx)(T,{x:e.x-14,y:e.y-14,label:e.human}):null]},e.name))]}),i.nodes.map(e=>e.gate?(0,w.jsxs)(`g`,{className:`lr-gate`,children:[(0,w.jsx)(`title`,{children:`validate — the engine scores the change before the first mutate step`}),(0,w.jsx)(`circle`,{cx:e.x,cy:e.y,r:e.r}),(0,w.jsx)(`text`,{x:e.x,y:e.y+5,textAnchor:`middle`,children:`⛨`}),(0,w.jsx)(`text`,{x:e.x+20,y:e.y-10,className:`lr-sub lr-warn`,children:`validate`})]},e.name):(0,w.jsxs)(`g`,{className:`lr-node${e.inner?` inner`:``}${e.effect===`mutate`?` mutate`:``}${e.name===r?` current`:``}`,"aria-current":e.name===r?`step`:void 0,...n?{role:`button`,tabIndex:0,"aria-label":o(e),onClick:s(e.name),onKeyDown:s(e.name)}:{role:`img`,"aria-label":`${o(e)}${e.name===r?`, current step`:``}`},children:[(0,w.jsx)(`circle`,{cx:e.x,cy:e.y,r:e.r}),(0,w.jsx)(`text`,{x:e.x,y:e.y+4,textAnchor:`middle`,children:e.name}),e.human?(0,w.jsx)(T,{x:e.x+e.r*.74,y:e.y-e.r*.74,label:e.human}):null]},e.name)),i.exit&&(0,w.jsxs)(`g`,{children:[(0,w.jsx)(`path`,{d:i.exit.d,className:`lr-flow`,markerEnd:`url(#lr-arrow-flow)`}),(0,w.jsx)(`text`,{x:i.exit.x+6,y:i.exit.y+4,className:`lr-lbl`,children:`close`}),(0,w.jsx)(`text`,{x:i.exit.x-90,y:i.exit.y-10,textAnchor:`middle`,className:`lr-sub`,children:`done`})]}),i.center&&a&&(0,w.jsxs)(`g`,{children:[(0,w.jsx)(`text`,{x:i.center.x,y:i.center.y-4,textAnchor:`middle`,className:`lr-title`,children:e.name}),(0,w.jsxs)(`text`,{x:i.center.x,y:i.center.y+16,textAnchor:`middle`,className:`lr-sub lr-acc`,children:[`iterations · max `,a.max]})]})]})}var D=[`prudent`,`balanced`,`aggressive`],O={running:`acc`,awaiting:`warn`,unreadable:`bad`},k=e=>!!e.graph,A=e=>({key:e,label:e,align:`right`,render:t=>(0,w.jsx)(`span`,{className:`num`,children:t[e]})}),j=[A(`iteration`),{key:`intent`,label:`intent`},A(`declared`),A(`actual`),{key:`decision`,label:`decision`},{key:`tests`,label:`tests`}];function M({history:e}){return e.length?(0,w.jsx)(`div`,{className:`loop-history`,children:(0,w.jsx)(r,{caption:`Iterations`,captionHidden:!0,columns:j,rows:e,rowKey:e=>e.iteration})}):(0,w.jsx)(`p`,{className:`panel-note`,children:`No iteration finished yet.`})}function N({loop:e,bricks:t,onPreset:n}){let r=k(e)?(e.graph.loops||[]).find(e=>e.iteration):null,[a,o]=(0,i.useState)(!1);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`reader-tags`,children:[(0,w.jsx)(`span`,{className:`tag acc`,children:`Active loop`}),(0,w.jsx)(`span`,{className:`tag${O[e.status]?` ${O[e.status]}`:``}`,children:e.status})]}),(0,w.jsx)(`h2`,{className:`reader-title`,children:e.title}),(0,w.jsxs)(`p`,{className:`mono dim reader-src`,children:[e.branch,` · `,e.root]}),k(e)?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`p`,{className:`reader-lede`,children:[`Iteration `,e.iteration,r?` / ${r.max}`:``,` · at `,e.node]}),e.awaiting?(0,w.jsxs)(`p`,{className:`loop-run-wait t-warn`,children:[(0,w.jsxs)(`b`,{children:[`Awaiting `,e.awaiting.kind,e.awaiting.kind===`gate`?` at ${e.awaiting.node}`:``]}),` `,`— Answer in the agent's session.`]}):null,(0,w.jsxs)(`label`,{className:`panel-note loop-run-preset`,children:[`preset`,(0,w.jsx)(`select`,{className:`sel`,"aria-label":`Preset for ${e.title}`,value:e.preset,disabled:a,onChange:t=>{o(!0),Promise.resolve(n(e.root,t.target.value)).finally(()=>o(!1))},children:D.map(e=>(0,w.jsx)(`option`,{children:e},e))})]}),(0,w.jsx)(`a`,{href:`#/docs/loop-risk`,children:`What presets mean →`}),(0,w.jsx)(`hr`,{className:`hr`}),(0,w.jsx)(`div`,{className:`loop-graph`,children:(0,w.jsx)(E,{graph:e.graph,bricks:t,highlight:e.node})}),(0,w.jsx)(`h3`,{className:`loop-h2`,children:`Iterations`}),(0,w.jsx)(M,{history:e.history})]}):(0,w.jsx)(`p`,{className:`reader-lede`,children:e.status===`unreadable`?`Its LOOP.md cannot be read, so there is no state to show.`:`Its LOOP.md is gone: the loop closed and its state went with it.`})]})}export{E as a,T as i,O as n,b as o,k as r,x as s,N as t};
@@ -0,0 +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-C8nMUU1i.js";import{A as i,At as a,Ct as o,D as s,E as c,F as l,H as u,L as d,M as f,N as p,O as m,Ot as h,P as g,T as _,bt as ee,et as te,it as ne,j as v,o as re,tt as y,w as b,xt as ie}from"./index-BILaKHbH.js";import{t as x}from"./EmptyState-CY5Pm2xy.js";import{_ as S,a as ae,c as C,f as w,g as T,h as E,i as D,l as O,m as k,n as A,o as j,p as M,r as N,s as P,t as F,u as I,v as L}from"./Bonsai-BoKo68Kw.js";import{s as oe}from"./motion-RlUl1osO.js";var R=e(t(),1),z=n(),B=4,V=56*B,H=24,U=165,W=188,G=(e,t)=>e>0?Math.max(1,Math.floor((e-32+H)/(V+H))):Math.max(1,t),K=e=>e.status===`blocked`?`bad`:f(e)?`warn`:e.status===`busy`?`ok`:``,q=e=>{let t=O(e);return t==null?null:Math.round(t*100)};function J(e,t,n){let r=b[e.status]||b.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||m(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,z.jsxs)(`div`,{className:`card gd-card`,children:[(0,z.jsxs)(`dl`,{className:`gd-facts`,children:[e.model&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`model`}),(0,z.jsx)(`dd`,{className:`mono`,children:e.model})]}),(0,z.jsx)(`dt`,{children:`turns`}),(0,z.jsx)(`dd`,{children:e.turns||0}),(0,z.jsx)(`dt`,{children:`context`}),(0,z.jsx)(`dd`,{children:r==null?`unknown`:`${r} %`}),(0,z.jsx)(`dt`,{children:`compactions`}),(0,z.jsx)(`dd`,{children:e.compactions||0})]}),t.fallen.length>0&&(0,z.jsxs)(`div`,{className:`dim act-xs`,children:[`finished: `,t.fallen.map(e=>`${e.type||`agent`} (${e.files.length})`).join(`, `)]}),n.map(e=>(0,z.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=L(e,n),s=(0,R.useMemo)(()=>w(e,{sakura:n}),[o]),c=b[e.status]||b.idle,l=Array.isArray(e.loops)?e.loops[0]:null,u=e.status!==`idle`,d=P(e),p=e.title||m(e.cwd)||e.session_id,h=q(e),g=(0,R.useRef)(null),_=(0,R.useCallback)(e=>a(d,e,Z(g.current)),[a,d]);return(0,z.jsxs)(`a`,{ref:g,className:`gd-tree${f(e)?` gd-needs`:``}`,href:e.href||I(e.session_id),"aria-label":J(e,s,r),"data-sid":e.session_id,onMouseEnter:e=>a(d,null,Z(e.currentTarget)),onMouseLeave:()=>a(null,null),onFocus:e=>a(d,null,Z(e.currentTarget)),onBlur:()=>a(null,null),onKeyDown:e=>D(e,s.pads.length,i,_),children:[(0,z.jsx)(N,{t:s,pad:i,swaying:u,onPad:_,px:B}),(0,z.jsxs)(`div`,{className:`gd-cap`,children:[(0,z.jsx)(`div`,{className:`gd-title`,title:p,children:p}),(0,z.jsxs)(`div`,{className:`row wrap gd-pills`,children:[(0,z.jsx)(`span`,{className:`badge mono`,title:`The install this session runs in`,children:e.chip||e.host||`?`}),(0,z.jsx)(`span`,{className:`badge ${K(e)}`,children:c.label}),t&&(0,z.jsxs)(`span`,{className:`badge mono`,children:[`⎇ `,t]}),l&&(0,z.jsxs)(`span`,{className:`badge`,children:[`↻ `,l.title,l.iteration==null?``:` ${l.iteration}`]}),e.attribution===!1&&(0,z.jsx)(`span`,{className:`badge`,title:`attribution unavailable on ${e.host}`,children:`no attrib.`})]}),(0,z.jsxs)(`div`,{className:`mono gd-meta`,children:[e.turns||0,` turns`,h==null?``:` · ${h}%`]})]})]})}function se({pairs:e,count:t}){if(!e.length)return null;let n=t*V+(t-1)*H,r=e=>e*(V+H)+V/2;return(0,z.jsx)(`svg`,{className:`gd-threads`,width:n,height:56*B+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,z.jsxs)(`g`,{className:o,children:[(0,z.jsx)(`path`,{d:`M${e} ${U} C${n} 179 ${n} 159 ${t} 169`}),(0,z.jsx)(`path`,{d:`M${e} 169 C${n} 159 ${n} 179 ${t} ${U}`})]},`${i}-${a}`)}return(0,z.jsx)(`g`,{className:o,children:(0,z.jsx)(`path`,{d:`M${r(i)} ${W} Q${(r(i)+r(a))/2} 222 ${r(a)} ${W}`})},`${i}-${a}`)})})}var Z=e=>e.offsetLeft;function ce({sessions:e,collisions:t}){let[n,r]=(0,R.useState)(j),[i,a]=(0,R.useState)(()=>new Set),o=()=>{let e=!n;r(e);try{window.localStorage.setItem(A,e?`1`:`0`)}catch{}},s=Array.isArray(t)?t:[],c=C(M(e)).map(e=>i.has(e.key)?{...e,collapsed:!1}:e),l=c.filter(e=>e.collapsed),u=e=>T(e,s);return(0,z.jsxs)(`section`,{className:`gd`,"aria-label":`Garden`,children:[(0,z.jsxs)(`div`,{className:`row between wrap gap-8 gd-head`,children:[(0,z.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,z.jsx)(`button`,{type:`button`,className:n?`chip-f on`:`chip-f`,"aria-pressed":n,onClick:o,children:`Pink blossom`})]}),l.length>0&&(0,z.jsx)(`div`,{className:`row wrap gap-8 gd-chips`,role:`group`,"aria-label":`Folded shelves`,children:l.map(e=>(0,z.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,z.jsx)(le,{sh:e,sakura:n,cols:s,mineOf:u},e.key))]})}function le({sh:e,sakura:t,cols:n,mineOf:r}){let[i,a]=(0,R.useState)({sid:null,pad:null,x:0}),o=(0,R.useCallback)((e,t,n)=>a(r=>({sid:e,pad:t,x:n??(r.sid===e?r.x:0)})),[]),s=(0,R.useRef)(null),[c,l]=(0,R.useState)(0);(0,R.useLayoutEffect)(()=>{let e=s.current,t=()=>l(e.clientWidth);if(t(),typeof ResizeObserver>`u`)return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t);let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let u=G(c,e.trees.length),d=S(e.trees,n),f=[];for(let t=0;t<e.trees.length;t+=u)f.push(t);let p=e.trees.findIndex(e=>P(e.s)===i.sid),m=p<0?null:e.trees[p].s,h=m?w(m,{sakura:t}):null,g=h&&i.pad!=null?h.pads[i.pad]:null,_=e.trees.length;return(0,z.jsxs)(`section`,{className:`gd-shelf`,"aria-label":`${e.name} shelf`,ref:s,children:[f.map(n=>{let a=e.trees.slice(n,n+u),s=n+a.length,c=d.filter(e=>e.a>=n&&e.a<s&&e.b>=n&&e.b<s).map(e=>({...e,a:e.a-n,b:e.b-n}));return(0,z.jsxs)(`div`,{className:`gd-row`,children:[(0,z.jsx)(`div`,{className:`gd-plank`,children:n===0&&(0,z.jsxs)(`h3`,{className:`gd-plate`,children:[e.name,` · `,_,` session`,_===1?``:`s`]})}),a.map(({s:e,worktree:n})=>(0,z.jsx)(X,{s:e,worktree:n,sakura:t,mine:r(P(e)),pad:P(e)===i.sid?i.pad:null,onHover:o},P(e))),(0,z.jsx)(se,{pairs:c,count:a.length}),m&&p>=n&&p<s&&(0,z.jsx)(`div`,{className:`gd-info`,"aria-hidden":`true`,style:{left:Math.max(0,i.x)},children:g?(0,z.jsx)(F,{pad:g}):(0,z.jsx)(Y,{s:m,t:h,mine:r(P(m))})})]},n)}),(0,z.jsx)(`span`,{className:`sr-only`,role:`status`,children:ae(g)})]})}var Q=e=>e.catch(()=>null);function ue({s:e}){let t=(0,R.useId)(),n=e.todos,r=v(e);return(0,z.jsxs)(`a`,{className:`card pad-md act-card`,href:e.href||I(e.session_id),"aria-labelledby":`${t}-t ${t}-st`,"aria-describedby":r?`${t}-c`:void 0,children:[(0,z.jsxs)(_,{s:e,id:t,heading:e.title||m(e.cwd)||e.session_id,children:[e.chip&&(0,z.jsx)(`span`,{className:`badge mono`,title:`The install this session runs in`,children:e.chip}),(0,z.jsx)(o,{name:`chevron`,className:`glyph act-chev`})]}),n&&n.total>0&&(0,z.jsx)(`div`,{className:`act-foot`,children:(0,z.jsxs)(`span`,{className:`row gap-8 dim act-sm`,children:[(0,z.jsx)(s,{done:n.done,total:n.total}),`plan `,n.done,`/`,n.total]})}),(0,z.jsxs)(`div`,{className:`dim mono act-updated`,children:[`updated `,h(e.updated_at),` ago`]})]})}var de={blocked:`is blocked`,"waiting-input":`waits for your answer`};function fe(e,t){if(!Array.isArray(t))return``;let n=t.filter(f),r=e.current;return e.current=new Set(n.map(e=>`${P(e)}:${e.status}`)),r?n.filter(e=>!r.has(`${P(e)}:${e.status}`)).map(e=>`${e.title||m(e.cwd)||e.session_id} ${de[e.status]}`).join(`. `):``}var pe=[[`all`,`All`],[`needs`,`Needs you`],[`runs`,`Runs`],[`gates`,`Gate asks`]];function me(){let e=new URLSearchParams(window.location.hash.split(`?`)[1]||``),t=e.get(`f`);return{f:pe.some(([e])=>e===t)?t:`all`,host:e.get(`host`)||``,project:e.get(`project`)||``,v:e.get(`v`)===`list`?`list`:`garden`}}function he(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 ge({enabled:e,installs:t,onToggle:n}){let r=k(t);return(0,z.jsxs)(`section`,{className:`card pad-md act-track`,"aria-labelledby":`act-track-h`,children:[(0,z.jsx)(o,{name:`activity`,className:`glyph act-fixed`}),(0,z.jsxs)(`div`,{className:`act-grow`,children:[(0,z.jsx)(`h2`,{id:`act-track-h`,className:`act-track-title`,children:e?`Live sessions are on`:`Live sessions are off`}),!e&&(0,z.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,z.jsxs)(`ul`,{className:`stack gap-8 act-fixed act-sm`,"aria-label":`Tracking per install`,children:[t.length===0&&(0,z.jsx)(`li`,{className:`dim`,children:`No active install to track.`}),t.map((e,t)=>(0,z.jsxs)(`li`,{className:`row gap-10`,children:[(0,z.jsxs)(`span`,{id:`act-track-l${t}`,title:e.path,children:[`Track live sessions in `,(0,z.jsx)(`span`,{className:`mono`,children:r.get(e.install)})]}),(0,z.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 _e({jobs:e,loading:t}){let n=typeof e?.cap==`number`?e.cap:void 0,r=p(e?.jobs,{days:14,cap:n}),i=l(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),c=r.some(e=>e.nodata),u=`Runs per day: ${r.filter(e=>e.n).map(e=>`${e.n} on ${g(e.key)}`).join(`, `)||`none`}.`+(c?s?` Days before ${g(s.key)} are older than the runs the log keeps.`:` No run is in the log yet.`:``);return(0,z.jsxs)(`section`,{className:`card pad-md act-stat`,"aria-labelledby":`act-runs-h`,children:[(0,z.jsxs)(`div`,{className:`act-stat-head`,children:[(0,z.jsx)(`h2`,{id:`act-runs-h`,className:`act-lbl`,children:`Runs per day · 14 days`}),e&&(0,z.jsx)(`span`,{className:`act-big`,children:o})]}),t?(0,z.jsx)(y,{label:`Reading the job log…`}):e?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`act-runs`,role:`img`,"aria-label":u,ref:i,children:r.map(e=>e.nodata?(0,z.jsx)(`i`,{className:`nodata`},e.key):e.n?(0,z.jsx)(`i`,{"data-sweep":!0,style:{height:`${e.n/a*100}%`},title:`${g(e.key)}: ${e.n}`},e.key):(0,z.jsx)(`i`,{className:`zero`},e.key))}),(0,z.jsxs)(`div`,{className:`mono act-axis`,"aria-hidden":`true`,children:[(0,z.jsx)(`span`,{children:g(r[0].key)}),(0,z.jsx)(`span`,{children:g(r[7].key)}),(0,z.jsx)(`span`,{children:`today`})]}),c&&(0,z.jsxs)(`span`,{className:`dim act-xs`,children:[`Hatched: older than the runs the log keeps`,n?` (last ${n})`:``,`.`]})]}):(0,z.jsx)(`p`,{className:`dim act-sm`,children:`The job log could not be read.`})]})}function ve({rows:e,gates:t,loading:n}){let r=e.reduce((e,t)=>e+t.n,0);return(0,z.jsxs)(`section`,{className:`card pad-md act-stat`,"aria-labelledby":`act-gates-h`,children:[(0,z.jsxs)(`div`,{className:`act-stat-head`,children:[(0,z.jsx)(`h2`,{id:`act-gates-h`,className:`act-lbl`,children:`Gate asks by rule · 30 days`}),t&&(0,z.jsx)(`span`,{className:`act-big`,children:r})]}),n?(0,z.jsx)(y,{label:`Reading the gate ledger…`}):e.length?(0,z.jsx)(`ul`,{className:`gate-rows`,children:e.slice(0,6).map((e,t)=>(0,z.jsxs)(`li`,{children:[(0,z.jsxs)(`span`,{className:`act-ell`,children:[e.name,` `,(0,z.jsx)(`span`,{className:`mono dim act-xs`,children:e.rule})]}),(0,z.jsx)(c,{vals:e.per_day,i:t,sweep:!0}),(0,z.jsx)(`span`,{className:`mono`,children:e.n})]},e.rule))}):(0,z.jsx)(`p`,{className:`dim act-sm`,children:t?`No gate asked in 30 days.`:`The gate ledger could not be read.`})]})}var ye={done:[`ok`,`done`],failed:[`bad`,`failed`],running:[``,`running`]};function be({job:e,longest:t}){let n=d(e),r=e.duration?Math.round(e.duration*10)/10:0,[i,a]=ye[e.status]||[``,e.status||`…`],s=e.status===`running`?`Still running`:r?`Took ${r} second${r===1?``:`s`}`:`No duration`,c=e.started?new Date(e.started*1e3).toLocaleTimeString(`en-GB`,{hour:`2-digit`,minute:`2-digit`}):`—`;return(0,z.jsxs)(`li`,{className:`act-row`,children:[(0,z.jsx)(`span`,{className:`mono dim act-xs`,children:c}),(0,z.jsx)(o,{name:`play`,className:`glyph act-glyph`}),(0,z.jsxs)(`span`,{className:`act-what`,children:[(0,z.jsx)(`span`,{className:`act-row-title`,children:n.verb}),n.scope&&(0,z.jsx)(`span`,{className:`dim act-xs act-ell`,title:n.command,children:n.scope})]}),(0,z.jsx)(`span`,{className:`act-dur`,role:`img`,"aria-label":s,children:(0,z.jsx)(`span`,{"data-sweep":!0,style:{width:t>0?`${(e.duration||0)/t*100}%`:`0%`}})}),(0,z.jsx)(`span`,{className:`badge ${i}`,children:a})]})}function xe({gate:e}){return(0,z.jsxs)(`li`,{className:`act-row gate`,children:[(0,z.jsx)(`span`,{className:`mono dim act-xs`,children:`—`}),(0,z.jsx)(o,{name:`rule`,className:`glyph act-glyph t-warn`}),(0,z.jsxs)(`span`,{className:`act-what`,children:[(0,z.jsx)(`span`,{className:`act-row-title`,children:e.title}),(0,z.jsx)(`span`,{className:`dim act-xs`,children:`Gate ledger`})]}),(0,z.jsx)(`span`,{className:`act-dur-none`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`badge warn`,children:`asked`})]})}var Se=5,$=(e,t)=>[...new Set([...e.filter(Boolean),t].filter(Boolean))];function Ce(){let[e,t]=(0,R.useState)(null),[n,o]=(0,R.useState)(``),[s,c]=(0,R.useState)(me),[d,p]=(0,R.useState)(!1),[h,g]=(0,R.useState)(``),_=(0,R.useRef)(null),v=e=>{let t={...s,...e};c(t),he(t)};ie(e=>r.activity().then(n=>{if(e()){t(ee(n)),o(``);let e=fe(_,n?.activity);e&&g(t=>t===e?e+`\xA0`:e)}},t=>{e()&&o(t.message)}),2e3,[]);let b=a(()=>Q(r.jobs()),[]),S=a(()=>Q(r.gates()),[]),ae=a(()=>Q(r.catalog(`laws`)),[]),C=!e||e.enabled!==!1,w=Array.isArray(e?.installs)?e.installs:[],T=E(e?.activity,w).sort((e,t)=>e.session_id<t.session_id?-1:+(e.session_id>t.session_id)),D=oe(),O=C&&e?T.filter(f).length:null,k=new Set(T.map(P)),A=s.v===`list`?E(e?.ended,w).filter(e=>!k.has(P(e))):[],j=$([...T,...A].map(e=>e.host),s.host),M=$([...T,...A].map(e=>m(e.cwd)),s.project),N=s.host&&s.project?`host or project`:s.host?`host`:s.project?`project`:``,F=e=>(!s.host||e.host===s.host)&&(!s.project||m(e.cwd)===s.project),I=T.filter(e=>F(e)&&(s.f!==`needs`||f(e))),L=s.f===`all`||s.f===`needs`,B=s.f===`all`&&C?A.filter(F):[],V=d?B:B.slice(0,Se),H=!N&&(s.f===`all`||s.f===`runs`),U=!N&&(s.f===`all`||s.f===`gates`),W=b.data?.jobs||[],G=re(S.data,ae.data),K=i(W,G,S.data?.days).map(e=>({...e,runs:H?e.runs:[],gate:U?e.gate:null})).filter(e=>e.runs.length||e.gate),q=Math.max(0,...W.map(e=>e.duration||0)),J=l(K.flatMap(e=>e.runs.map(e=>`${e.id}:${e.duration}`)).join(`,`),`scaleX`),Y=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)}},X=(e,t,n)=>(0,z.jsxs)(`span`,{className:`row gap-8 act-sm`,children:[(0,z.jsx)(`label`,{htmlFor:`act-f-${e}`,children:t}),(0,z.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=>v({[e]:t.target.value}),children:[(0,z.jsxs)(`option`,{value:``,children:[`All `,e===`host`?`hosts`:`projects`]}),n.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]})]});return(0,z.jsxs)(`div`,{className:`page-fill`,children:[(0,z.jsx)(u,{title:`Activity`,sub:`What your agents ran, what the gates asked, and which sessions are waiting on you.`}),(0,z.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,children:h}),n&&(0,z.jsx)(`div`,{className:`act-gap`,children:(0,z.jsx)(te,{error:n})}),e&&(0,z.jsx)(ge,{enabled:C,installs:w,onToggle:Y}),(0,z.jsxs)(`div`,{className:`act-today`,children:[(0,z.jsx)(_e,{jobs:b.data,loading:b.loading}),(0,z.jsx)(ve,{rows:G,gates:S.data,loading:S.loading}),(0,z.jsxs)(`section`,{className:`card pad-md act-stat`,"aria-labelledby":`act-wait-h`,children:[(0,z.jsx)(`h2`,{id:`act-wait-h`,className:`act-lbl`,children:`Waiting on you`}),!e&&!n?(0,z.jsx)(y,{}):e?(0,z.jsxs)(z.Fragment,{children:[C?(0,z.jsxs)(`span`,{className:`act-big act-wait`,children:[O,` `,(0,z.jsx)(`span`,{className:`dim act-sm`,children:O===1?`session`:`sessions`})]}):null,(0,z.jsx)(`p`,{className:`dim act-sm`,children:C?`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,z.jsx)(`p`,{className:`dim act-sm`,children:`The sessions could not be read.`})]})]}),(0,z.jsxs)(`div`,{className:`row wrap gap-8 act-filters`,children:[(0,z.jsx)(`div`,{role:`group`,"aria-label":`Filter`,className:`row wrap gap-8`,children:pe.map(([e,t])=>(0,z.jsxs)(`button`,{type:`button`,className:s.f===e?`chip-f on`:`chip-f`,"aria-pressed":s.f===e,onClick:()=>v({f:e}),children:[t,e===`needs`&&O>0?(0,z.jsxs)(`span`,{className:`mono`,children:[` `,O]}):null]},e))}),X(`host`,`Host`,j),X(`project`,`Project`,M),(0,z.jsx)(ne,{"aria-label":`Live sessions view`,children:[[`list`,`List`],[`garden`,`Garden`]].map(([e,t])=>(0,z.jsx)(`button`,{type:`button`,className:s.v===e?`on`:``,"aria-pressed":s.v===e,onClick:()=>v({v:e}),children:t},e))})]}),N&&s.f!==`needs`&&(0,z.jsxs)(`p`,{className:`dim act-sm`,children:[`Runs and gate asks carry no `,N,`; showing sessions only.`]}),L&&(e?!C&&s.f!==`needs`?null:I.length===0?s.f===`needs`?(0,z.jsx)(x,{title:`Nothing waits on you`}):(0,z.jsx)(x,{title:`No active sessions`,children:`Start an agent session and it appears here.`}):s.v===`garden`?(0,z.jsx)(ce,{sessions:I,collisions:e.collisions}):(0,z.jsx)(`div`,{className:`stack gap-12 act-live`,ref:D,children:I.map(e=>(0,z.jsx)(`div`,{"data-flip":P(e),children:(0,z.jsx)(ue,{s:e})},P(e)))}):(0,z.jsx)(y,{label:`Reading live sessions…`})),B.length>0&&(0,z.jsxs)(`section`,{className:`stack gap-12 act-live act-ended`,"aria-labelledby":`act-ended-h`,children:[(0,z.jsx)(`h2`,{id:`act-ended-h`,className:`act-lbl`,children:`Recently ended`}),V.map(e=>(0,z.jsx)(`div`,{children:(0,z.jsx)(ue,{s:e})},P(e))),B.length>Se&&(0,z.jsx)(`button`,{type:`button`,className:`btn ghost sm`,"aria-expanded":d,onClick:()=>p(e=>!e),children:d?`Show fewer`:`Show all ${B.length}`})]}),s.f!==`needs`&&(0,z.jsx)(`section`,{"aria-label":`Feed`,className:`stack gap-16 act-feed`,ref:J,children:K.map(e=>(0,z.jsxs)(`section`,{className:`card act-day`,children:[(0,z.jsxs)(`h3`,{className:`act-day-h`,children:[(0,z.jsx)(`span`,{children:e.title}),(0,z.jsx)(`span`,{className:`mono dim`,children:e.sum})]}),(0,z.jsxs)(`ul`,{className:`act-rows`,children:[e.runs.map(e=>(0,z.jsx)(be,{job:e,longest:q},e.id)),e.gate&&(0,z.jsx)(xe,{gate:e.gate})]})]},e.key))})]})}export{Ce as default};
@@ -0,0 +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-C8nMUU1i.js";import{Ct as i,H as a,M as o,O as s,Ot as c,T as l,bt as u,et as d,k as f,tt as p,xt as m}from"./index-BILaKHbH.js";import{a as h,d as g,f as _,i as v,l as y,o as b,r as x,t as S,v as C}from"./Bonsai-BoKo68Kw.js";import{t as w}from"./EmptyState-CY5Pm2xy.js";var T=e(t(),1),E=n();function D(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 O({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(`${f(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,E.jsxs)(`div`,{className:`row gap-10 act-line`,children:[(0,E.jsx)(`span`,{className:`badge act-who ${t?``:`acc`}`,children:t?`you`:`agent`}),(0,E.jsxs)(`div`,{className:`act-grow act-sm`,children:[!t&&(0,E.jsx)(`span`,{className:`feed-dot act-inline-dot ${D(e)||`acc`}`}),e.kind===`thinking`&&(0,E.jsx)(`span`,{className:`dim`,children:`thinking: `}),r?(0,E.jsx)(`span`,{className:`dim`,children:i}):t?i:(0,E.jsx)(`b`,{children:i}),e.error&&(0,E.jsxs)(`span`,{className:`dim`,children:[`: `,e.error]})]}),n.length>0&&(0,E.jsx)(`span`,{className:`dim mono act-xs act-fixed`,children:n.join(` · `)}),e.t?(0,E.jsx)(`time`,{className:`mono dim act-xs act-fixed`,dateTime:new Date(e.t).toISOString(),title:`${c(e.t/1e3)} ago`,children:new Date(e.t).toTimeString().slice(0,8)}):null]})}function k({turns:e}){return!e||e.length===0?(0,E.jsx)(`div`,{className:`dim act-sm`,children:`No conversation captured yet.`}):(0,E.jsx)(`div`,{className:`stack gap-12`,children:e.map((e,t)=>{let n=e.role===`user`;return(0,E.jsxs)(`div`,{className:`row gap-10 act-line`,children:[(0,E.jsx)(`span`,{className:`badge act-who ${n?``:`acc`}`,children:n?`you`:`agent`}),(0,E.jsx)(`div`,{className:`act-min act-sm${n?``:` muted`}`,children:e.text})]},t)})})}var A=5;function j({s:e}){let[t]=(0,T.useState)(b),[n,r]=(0,T.useState)(null),i=!!e.ended,a=i?{...e,status:o(e)?`busy`:e.status,error:null}:e,s=C(a,t),c=(0,T.useMemo)(()=>_(a,{sakura:t}),[s]),l=(0,T.useCallback)(e=>r(e),[]),u=y(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(` · `),m=n==null?null:c.pads[n];return(0,E.jsxs)(`div`,{className:`card pad-md act-mt gd-detail${!i&&o(e)?` gd-needs`:``}`,children:[(0,E.jsx)(`div`,{role:`group`,tabIndex:0,"aria-label":`Bonsai pads, arrow keys walk them`,onKeyDown:e=>v(e,c.pads.length,n,l),children:(0,E.jsx)(x,{t:c,pad:n,swaying:!i&&e.status!==`idle`,onPad:l,px:A,label:`Bonsai of this session${i?`, ended`:``}: ${p}`})}),(0,E.jsxs)(`div`,{className:`stack gap-8 act-min`,children:[i&&(0,E.jsx)(`span`,{className:`dim act-xs`,children:`ended`}),(0,E.jsx)(`div`,{className:`dim act-sm`,children:p}),(0,E.jsx)(`span`,{className:`sr-only`,role:`status`,children:h(m)}),m?(0,E.jsx)(S,{pad:m}):(0,E.jsx)(`div`,{className:`dim act-xs`,children:`Hover or tap a pad, or use the arrow keys, for its files.`})]})]})}function M({sid:e}){let{sid:t,install:n}=g(e,window.location.hash),[o,f]=(0,T.useState)(null),[h,_]=(0,T.useState)(``),[v,y]=(0,T.useState)(!1),[b,x]=(0,T.useState)(!1),S=(0,T.useId)();m(e=>v?void 0:r.activityDetail(t,n).then(t=>{e()&&(f(u(t)),_(``),y(!1))},t=>{e()&&(t.status===404?y(!0):_(t.message))}),2e3,[t,v]);let C=(0,E.jsxs)(`a`,{className:`btn ghost sm act-back`,href:`#/activity`,children:[(0,E.jsx)(i,{name:`arrow`}),` Activity`]});if(v)return(0,E.jsxs)(`div`,{className:`page-fill`,children:[C,(0,E.jsx)(w,{title:`Session ended`,action:(0,E.jsx)(`a`,{href:`#/activity`,children:`Back to Activity`}),children:`It's no longer live.`})]});if(!o)return(0,E.jsxs)(`div`,{className:`page-fill`,children:[C,h?(0,E.jsx)(d,{error:h}):(0,E.jsx)(p,{label:`Loading session…`})]});let D=o.session,A=D.files,M=D.todos,N=!!(A&&A.items&&A.items.length>0),P=!!(M&&M.items&&M.items.length>0),F=o.conversation||[],I=o.timeline||[],L=[...F.filter(e=>e.role===`user`).map(e=>({who:`you`,text:e.text,t:e.t||0})),...I.map(e=>({...e,who:`agent`}))].sort((e,t)=>(e.t||0)-(t.t||0));return(0,E.jsxs)(`div`,{className:`page-fill`,children:[C,(0,E.jsx)(a,{title:D.title||s(D.cwd)||D.session_id,sub:D.cwd?(0,E.jsx)(`span`,{className:`mono act-cwd`,title:D.cwd,children:D.cwd}):null}),h&&(0,E.jsx)(`div`,{className:`act-gap`,children:(0,E.jsx)(d,{error:h})}),(0,E.jsxs)(`div`,{className:`card pad-md`,children:[(0,E.jsx)(l,{s:D}),(0,E.jsxs)(`div`,{className:`dim act-updated`,children:[`updated `,c(D.updated_at),` ago`]})]}),(0,E.jsx)(j,{s:D}),(N||P)&&(0,E.jsxs)(`div`,{className:`grid gap-12 act-panels${N&&P?` two`:``}`,children:[N&&(0,E.jsxs)(`div`,{className:`card pad-md`,children:[(0,E.jsx)(`div`,{className:`card-head`,children:(0,E.jsxs)(`h2`,{children:[`Files touched `,(0,E.jsxs)(`span`,{className:`dim`,children:[`(`,A.count,`)`]})]})}),(0,E.jsx)(`div`,{className:`stack act-list`,children:A.items.map(e=>(0,E.jsxs)(`div`,{className:`row between gap-12 act-sm`,children:[(0,E.jsx)(`span`,{className:`mono act-ell act-grow`,title:e.file,children:e.file}),(0,E.jsxs)(`span`,{className:`act-fixed`,children:[(0,E.jsxs)(`span`,{className:`t-good`,children:[`+`,e.additions]}),` `,(0,E.jsxs)(`span`,{className:`t-bad`,children:[`−`,e.deletions]})]})]},e.file))})]}),P&&(0,E.jsxs)(`div`,{className:`card pad-md`,children:[(0,E.jsx)(`div`,{className:`card-head`,children:(0,E.jsxs)(`h2`,{children:[`Plan`,` `,(0,E.jsxs)(`span`,{className:`dim`,children:[`(`,M.done,`/`,M.total,`)`]})]})}),(0,E.jsx)(`div`,{className:`stack act-list`,children:M.items.map((e,t)=>(0,E.jsxs)(`div`,{className:`row gap-8 act-sm`,children:[(0,E.jsx)(`span`,{className:`feed-dot ${e.status===`completed`?`ok`:e.status===`in_progress`?`acc`:``}`}),(0,E.jsx)(`span`,{className:e.status===`completed`?`act-done`:void 0,children:e.content})]},t))})]})]}),(0,E.jsxs)(`div`,{className:`card pad-md act-mt`,children:[(0,E.jsxs)(`div`,{className:`card-head act-tl-head`,children:[(0,E.jsx)(`h2`,{children:`Timeline`}),I.length>0&&(0,E.jsx)(`button`,{className:`btn ghost sm`,"aria-expanded":b,"aria-controls":S,onClick:()=>x(e=>!e),children:b?`Show conversation`:`Show full stream (${L.length})`})]}),(0,E.jsx)(`div`,{id:S,children:b?(0,E.jsx)(`div`,{className:`stack gap-12`,children:L.map((e,t)=>(0,E.jsx)(O,{rec:e},t))}):(0,E.jsx)(k,{turns:F})})]})]})}export{j as SessionTree,M 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{ft as r}from"./index-BhT94v2q.js";var i=e(t(),1),a=e=>{let t=2166136261;for(let n of String(e))t=Math.imul(t^n.charCodeAt(0),16777619);return t>>>0},o=e=>()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296},s=e=>Math.max(0,Math.min(1,e)),c={claude:[`#8E4A33`,`#C46A4C`,`#E3906F`],bob:[`#173F8C`,`#2A5CC0`,`#6A96E8`],opencode:[`#5E6670`,`#98A2AD`,`#C8D0D8`],openclaude:[`#2F1F55`,`#4E3484`,`#8A6CC8`]},l={live:[`#16393D`,`#1F5A55`,`#2C7D55`,`#5DA845`,`#A8D23E`],sakura:[`#16393D`,`#6E2A55`,`#B83C80`,`#E9649F`,`#FFB0D2`],done:[`#5A2E14`,`#8A4A1C`,`#B8702A`,`#DB9A3E`,`#F2C46A`],idle:[`#2E3236`,`#44494E`,`#5E646A`,`#7C8288`,`#A2A7AC`]},u={developer:[`#123A3F`,`#1A5A5E`,`#24806F`,`#3FB08A`,`#8EE6C2`],explorer:[`#2C3A12`,`#4A6418`,`#6E9424`,`#9CC23A`,`#DDF07A`],reviewer:[`#16283F`,`#1F3E66`,`#2E5E92`,`#4A86C4`,`#9AC8F0`],tester:[`#3A3012`,`#5E4C18`,`#8A6E22`,`#B8952E`,`#EAD27A`]},d=[`#4E2E1C`,`#7A4A2E`,`#A2683F`,`#C78A5A`],f=[`#34312F`,`#4F4A46`,`#6B6560`,`#8A847E`],p=[`#3E8E41`,`#5FB14F`],m=[`#4A4F54`,`#62686E`],h=`#FFF6E0`,g=[`#E3C24A`,`#C9A23A`],_=[`#9BDD6A`,`#D8F59A`],v={"!":`#E8B04A`,x:`#FF6F69`},y=12;function b(e){let t=String(e||``).toLowerCase();return/implement|develop/.test(t)?`developer`:/explor/.test(t)?`explorer`:/review/.test(t)?`reviewer`:/test/.test(t)?`tester`:null}var x=e=>e?.status===`blocked`||e?.status===`waiting-input`;function S(e){return Array.isArray(e.files_all)?e.files_all.filter(e=>e&&typeof e==`object`):(Array.isArray(e.files?.items)?e.files.items:[]).filter(e=>e&&typeof e==`object`).map(e=>({file:e.file??null,path:e.path??null,additions:e.additions??0,deletions:e.deletions??0,by:e.by??null}))}var C=e=>e==null||e===``?NaN:Number(e);function w(e){let t=C(e?.context?.used),n=C(e?.context?.window);return Number.isFinite(t)&&Number.isFinite(n)&&n>0?s(t/n):null}function T(e){let t=S(e),n=(Array.isArray(e.agents)?e.agents:[]).filter(e=>e&&typeof e==`object`).map((e,t)=>({key:e.id??`#${t}`,id:e.id??null,type:e.type||null,running:e.status!==`done`,files:[]})),r=new Map(n.map(e=>[e.key,e])),i=[],a=e.attribution!==!1;for(let e of t){if(!a||e.by==null){i.push(e);continue}let t=r.get(e.by);t||(t={key:e.by,id:e.by,type:`agent`,running:!0,files:[]},n.push(t),r.set(e.by,t)),t.files.push(e)}let o=w(e),l=o!=null,u=l?C(e.context.used):NaN,d=l?o:.5,f=Math.max(0,Math.floor(Number(e.compactions)||0)),p=C(e.context_at_compaction),m=f===0?1:l&&Number.isFinite(p)&&p>0?s(u/p):0;return{id:String(e.session_id??``),host:c[e.host]?e.host:`claude`,idle:e.status===`idle`,bubble:x(e)?`!`:e.error?`x`:null,turns:Math.max(0,Number(e.turns)||0),ctx:d,compactions:f,compacted:f>0&&m<1,regrow:m,crown:i,agents:n}}function E(e,t=!1){let n=T(e);return JSON.stringify([n.id,n.host,n.idle,n.bubble,n.turns,Math.round(n.ctx*100),n.compactions,Math.round(n.regrow*100),n.crown.length,n.agents.map(e=>[e.key,e.type,e.running,e.files.length]),!!t])}function D(e,{sakura:t=!1}={}){let n=T(e),{id:r,idle:i}=n,s=Math.min(1,Math.log1p(n.turns)/Math.log1p(40)),x=.55+.45*s,S=o(a(r)),C=Array.from({length:56},()=>Array(56).fill(null)),w=Array.from({length:56},()=>Array(56).fill(-1)),E=-1,D=(e,t,n)=>{e=Math.round(e),t=Math.round(t),e>=0&&e<56&&t>=0&&t<56&&(C[t][e]=n,w[t][e]=E)},O=i?f:d,k=i?m:p,A=i?l.idle:t?l.sakura:l.live,j=Math.round(41-(9+18*s)),M=1+S()*2+3*s,N=S()*Math.PI*2,P=.9+S()*.6,F=e=>28+M*Math.sin(e*Math.PI*P+N)-M*Math.sin(N);for(let e=41;e>=j;e--){let t=(41-e)/(41-j),n=F(t),r=3+4.5*s-(1.5+3.5*s)*t;for(let t=Math.floor(n-r/2);t<=Math.ceil(n+r/2);t++){let i=(t-(n-r/2))/r;D(t,e,i<.25?O[3]:i>.75?O[0]:S()<.15?O[1]:O[2])}}for(let e=-6;e<=6;e++)D(28+e,41,Math.abs(e)>4?O[1]:O[2]),Math.abs(e)<=5&&D(28+e,40,Math.abs(e)>3?O[1]:O[2]);let I=[],L=(e,t,n,i,s,c)=>{n*=1.15,e=Math.max(n+2,Math.min(53-n,e));let l=o(a(`${r}:pad:${c}`)),u=n*.72;t=Math.max(t,u+6);for(let r=0;r<6;r++){let r=-Math.PI*(.15+.7*l()),i=n*(.4+.5*l());for(let n=0;n<i;n++)D(e+Math.cos(r)*n,t+u*.5+Math.sin(r)*n*.8,O[0])}let d=Math.round(10+n*1.6),f=[];for(let r=0;r<d;r++){let r=l()*Math.PI*2,i=Math.sqrt(l());f.push([e+Math.cos(r)*i*n,t+Math.sin(r)*i*u,1.8+l()*2.2])}f.sort((e,t)=>t[1]-e[1]);for(let[e,n,r]of f){let a=Math.max(0,Math.min(4,Math.round(4*(1-(n-(t-u))/(2*u))+(l()-.5))));for(let t=Math.floor(n-r);t<=n+r;t++)for(let o=Math.floor(e-r);o<=e+r;o++){if(((o-e)**2+(t-n)**2)/(r*r)>1+(l()-.5)*.5)continue;let s=o-e+(t-n)<-r*.3?1:t-n>r*.5?-1:0;D(o,t,i[Math.max(0,Math.min(4,a+s))])}}let p=o(a(`${r}:bloom:${c}`));for(let r=0;r<Math.min(s,y);r++)D(e+(p()*2-1)*n*.8,t-p()*u*.9,h);return{rx:n,cy:t}},R=o(a(`${r}:side`))()<.5?-1:1,z=[];n.agents.forEach((e,t)=>{let c=.25+.55*(t/Math.max(1,n.agents.length-1)),l=Math.round(41-c*(41-j)),d=F(c);if(!e.running){let t=(3+4.5*s-(1.5+3.5*s)*c)/2;E=-1,D(d+R*(t+1),l,O[3]),D(d+R*(t+2),l-1,O[2]),z.push({agentId:e.id,type:e.type,files:e.files}),R=-R;return}let f=Math.round((12+Math.floor(o(a(`${r}:branch:${e.key}`))()*4))*x);E=-1;for(let e=0;e<=f;e++){let t=d+R*e,n=l-e*.45;D(t,n,O[e<f/2?1:2]),D(t,n+1,O[0]),e<f*.6&&D(t,n+2,O[0])}let p=i?null:b(e.type),m=p?u[p]:A;E=I.length,I.push({agentId:e.id,key:e.key,type:e.type,family:p,files:e.files,bbox:null}),L(d+R*f,l-f*.45-2,(8+Math.min(e.files.length,6)*.6)*x,m,e.files.length,e.key),R=-R});let B=I.length;I.push({agentId:null,key:null,type:null,family:null,files:n.crown,bbox:null}),E=B;let V=(4+7*n.ctx+Math.min(n.crown.length,6)*.5)*x*1.35,{rx:H,cy:U}=L(F(1),j-3,V,A,n.crown.length,`crown`);if(n.ctx>.8&&!n.compacted){let e=o(a(`${r}:yellow`));for(let t=0;t<56;t++)for(let n=0;n<56;n++)w[t][n]===B&&C[t][n]!==h&&t<U-H*.2&&e()<.55&&(C[t][n]=e()<.5?g[0]:g[1])}if(n.compacted){let e=o(a(`${r}:shoots`)),t=Math.round(U-H*.15-n.regrow*H*.5);for(let e=0;e<Math.max(0,t);e++)for(let t=0;t<56;t++)w[e][t]===B&&(C[e][t]=null,w[e][t]=-1);if(t>=0&&t<56)for(let r=0;r<56;r++){if(w[t][r]!==B||e()>=.12+n.regrow*.5)continue;let i=1+Math.floor(e()*(1+n.regrow*3));for(let e=1;e<=i;e++)D(r,t-e,e===i?_[1]:_[0])}}E=-1;let W=o(a(`${r}:fallen`));z.forEach((e,t)=>D(16+(t*7+Math.floor(W()*4))%24,40,l.done[2+t%2]));for(let e=0;e<Math.min(n.compactions,6);e++)D(15+e*2,42,h);let[G,K,q]=c[n.host];for(let e=42;e<=46;e++){let t=e<=43?0:Math.floor((e-43)*.45)+2;for(let n=13+t;n<=42-t;n++){if(e===42&&C[e][n]===h)continue;let r=K;e<=43?r=e===42?q:G:(e===46||n===13+t||n===42-t)&&(r=G),D(n,e,r)}}let J=o(a(`${r}:moss`));for(let e=15;e<=40;e++)D(e,41,J()<.5?k[0]:k[1]),J()<.35&&D(e,40,k[0]);for(let e=16;e<=39;e++)D(e,47,`#00000055`);if(n.bubble){let e=v[n.bubble];for(let t=3;t<10;t++)for(let n=40;n<47;n++)D(n,t,t===3||t===9||n===40||n===46?e:`#14191F`);if(D(41,10,e),n.bubble===`!`){for(let t=5;t<=6;t++)D(43,t,e);D(43,8,e)}else for(let[t,n]of[[2,2],[4,2],[3,3],[2,4],[4,4]])D(40+t,3+n,e)}let Y=[],X=I.map(()=>null);for(let e=0;e<56;e++){let t=0;for(;t<56;){let n=C[e][t],r=w[e][t];if(!n){t++;continue}let i=t;for(;i+1<56&&C[e][i+1]===n&&w[e][i+1]===r;)i++;if(Y.push({x:t,y:e,w:i-t+1,c:n,p:r}),r>=0){let n=X[r]||={x0:t,y0:e,x1:i,y1:e};n.x0=Math.min(n.x0,t),n.x1=Math.max(n.x1,i),n.y1=e}t=i+1}}return I.forEach((e,t)=>{let n=X[t];e.bbox=n?{x:n.x0,y:n.y0,w:n.x1-n.x0+1,h:n.y1-n.y0+1}:null}),{width:56,height:56,runs:Y,pads:I,bubble:n.bubble,fallen:z}}var O=e=>{if(!e)return``;let t=String(e).replace(/\\/g,`/`).replace(/\/+$/,``).split(`/`);return t[t.length-1]||String(e)},k=e=>e?String(e).replace(/\\/g,`/`).replace(/\/+$/,``).toLowerCase():``;function A(e){let t=new Map;for(let n of e||[]){let e=n.repo||n.root,r=n.repo_key||(e?k(e):n.cwd?`cwd:${k(n.cwd)}`:`outside a repo`),i=O(e||n.cwd)||`outside a repo`;t.has(r)||t.set(r,{key:r,name:i,trees:[]});let a=n.root&&e&&k(n.root)!==k(e)?O(n.root):null;t.get(r).trees.push({s:n,worktree:a})}let n=(e,t)=>e<t?-1:+(e>t),r=[...t.values()];for(let e of r)e.trees.sort((e,t)=>n(e.worktree||``,t.worktree||``)||n(String(e.s.session_id),String(t.s.session_id)));return r.sort((e,t)=>n(e.name.toLowerCase(),t.name.toLowerCase())||n(e.key,t.key))}var j=e=>e.key??(e.install?`${e.install}\0${e.session_id}`:String(e.session_id)),M=e=>j({key:e.key??void 0,install:e.install,session_id:e.sid}),N=(e,t)=>String(e).split(/[\\/]+/).filter(Boolean).slice(-t).join(`/`),P=e=>r(e.host).label;function F(e){let t=e||[],n=e=>n=>t.filter(t=>e(t)===e(n)).length,r=n(e=>e.host),i=n(e=>`${e.host} ${e.scope}`),a=new Map(t.map(e=>[e.install,r(e)<2?P(e):i(e)<2||e.scope===`global`?`${P(e)} · ${e.scope}`:`${P(e)} · ${O(e.path)}`])),o=()=>t.filter(e=>t.some(t=>t!==e&&a.get(t.install)===a.get(e.install)));for(let e=2,t=o();t.length;e++,t=o()){for(let n of t){let t=String(n.path).split(/[\\/]+/).filter(Boolean).length;a.set(n.install,`${P(n)} · ${e>t?n.path:N(n.path,e)}`)}if(e>64)break}return a}var I=(e,t)=>`#/activity/${encodeURIComponent(e)}`+(t?`?${new URLSearchParams({host:t.host,path:t.path})}`:``);function L(e,t){let n=String(e).indexOf(`?`),r=new URLSearchParams(String(t||``).split(`?`)[1]||``),i=r.get(`host`),a=r.get(`path`);return{sid:n<0?e:String(e).slice(0,n),install:i&&a?{host:i,path:a}:void 0}}function R(e,t){let n=new Map((t||[]).map(e=>[e.install,e])),i=F(t);return(e||[]).map(e=>{let t=n.get(e.install);return{...e,host:t?.host??e.host,chip:i.get(e.install)??(e.host?r(e.host).label:null),href:I(e.session_id,t)}})}var z=(e,t)=>new Set((e.writers||[]).filter(e=>M(e)===t).map(e=>k(e.root)));function B(e,t,n){let r=z(e,t);for(let t of z(e,n))if(r.has(t))return`same-worktree`;return`cross-worktree`}var V=e=>[...new Set((e.writers||[]).map(M))];function H(e,t){let n=new Map(e.map((e,t)=>[j(e.s),t])),r=new Map;for(let e of t||[]){let t=V(e).filter(e=>n.has(e));for(let i=0;i<t.length;i++)for(let a=i+1;a<t.length;a++){let o=n.get(t[i]),s=n.get(t[a]),c=o<s?`${o}-${s}`:`${s}-${o}`,l=B(e,t[i],t[a]);r.has(c)&&l!==`same-worktree`||r.set(c,{a:o,b:s,kind:l})}}return[...r.values()]}function U(e,t){let n=[];for(let r of t||[]){let t=V(r).filter(t=>t!==e);if(!t.length||!V(r).includes(e))continue;let i=t.some(t=>B(r,e,t)===`same-worktree`);n.push({path:r.path,kind:i?`same-worktree`:`cross-worktree`})}return n}var W=e=>e?.status===`busy`||x(e);function G(e,t=10){let n=e.map(e=>({...e,collapsed:!1})),r=n.reduce((e,t)=>e+t.trees.length,0);if(r<=t)return n;let i=n.length,a=n.filter(e=>!e.trees.some(e=>W(e.s))).sort((e,t)=>t.trees.length-e.trees.length||(e.key<t.key?-1:1));for(let e of a){if(r<=t||i<=1)break;e.collapsed=!0,r-=e.trees.length,i--}return n}var K=n(),q=12,J=10,Y=`geneseed-garden-sakura`;function X(){try{return window.localStorage.getItem(Y)===`1`}catch{return!1}}var Z=e=>e.key==null?`the session`:e.type||`agent`,Q=e=>e.path||e.file||`?`;function $({pad:e}){let t=e.files.slice(0,q);return(0,K.jsxs)(`div`,{className:`card gd-card`,children:[(0,K.jsxs)(`div`,{className:`act-lbl`,children:[Z(e),` · `,e.files.length,` file`,e.files.length===1?``:`s`]}),(0,K.jsx)(`ul`,{className:`gd-files`,children:t.map((e,t)=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mono act-ell`,children:Q(e)}),(0,K.jsxs)(`span`,{className:`mono act-xs`,children:[(0,K.jsxs)(`span`,{className:`t-good`,children:[`+`,e.additions??0]}),` `,(0,K.jsxs)(`span`,{className:`t-bad`,children:[`−`,e.deletions??0]})]})]},`${Q(e)}:${t}`))}),e.files.length>t.length&&(0,K.jsxs)(`div`,{className:`dim act-xs`,children:[`+`,e.files.length-t.length,` more`]})]})}var ee=e=>e?`${Z(e)}: ${e.files.length} file${e.files.length===1?``:`s`}`:``;function te(e,t,n,r){let i={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[e.key];e.key===`Escape`&&n!=null&&r(null),i&&t&&(e.preventDefault(),r(n==null?i>0?0:t-1:(n+i+t)%t))}var ne=(0,i.memo)(function({t:e,pad:t,swaying:n,onPad:r,px:a,label:o}){let s=(0,i.useMemo)(()=>{let t=new Map;for(let n of e.runs)t.has(n.p)||t.set(n.p,[]),t.get(n.p).push(n);return[...t.entries()]},[e]),c=(0,i.useRef)(null),l=e=>{let[t,n]=[c.current,e.changedTouches?.[0]];return!!t&&!!n&&Math.hypot(n.clientX-t.x,n.clientY-t.y)>J};return(0,K.jsx)(`svg`,{onTouchStart:e=>{let t=e.touches?.[0];c.current=t?{x:t.clientX,y:t.clientY}:null},className:`gd-svg${t==null?``:` gd-dimming`}`,viewBox:`0 0 56 56`,width:56*a,height:56*a,shapeRendering:`crispEdges`,"data-bubble":e.bubble||void 0,...o?{role:`img`,"aria-label":o}:{"aria-hidden":`true`},children:s.map(([i,a])=>(0,K.jsx)(`g`,{"data-p":i,className:[i===t&&`gd-hot`,n&&i>=0&&e.pads[i].key!=null&&`gd-sway`].filter(Boolean).join(` `)||void 0,onMouseEnter:i>=0?()=>r(i):void 0,onMouseLeave:i>=0?()=>r(null):void 0,onTouchEnd:i>=0?e=>{l(e)||(e.cancelable&&e.preventDefault(),r(i===t?null:i))}:void 0,children:a.map(e=>(0,K.jsx)(`rect`,{x:e.x,y:e.y,width:e.w,height:1,fill:e.c},`${e.x},${e.y}`))},i))})});export{H as _,ee as a,G as c,L as d,D as f,U as g,R as h,te as i,w as l,F as m,Y as n,X as o,A as p,ne as r,j as s,$ as t,I as u,E as v};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-C1iE8mnY.js";import{pt as r}from"./index-BILaKHbH.js";var i=e(t(),1),a=e=>{let t=2166136261;for(let n of String(e))t=Math.imul(t^n.charCodeAt(0),16777619);return t>>>0},o=e=>()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296},s=e=>Math.max(0,Math.min(1,e)),c={claude:[`#8E4A33`,`#C46A4C`,`#E3906F`],bob:[`#173F8C`,`#2A5CC0`,`#6A96E8`],opencode:[`#5E6670`,`#98A2AD`,`#C8D0D8`],openclaude:[`#2F1F55`,`#4E3484`,`#8A6CC8`]},l={live:[`#16393D`,`#1F5A55`,`#2C7D55`,`#5DA845`,`#A8D23E`],sakura:[`#16393D`,`#6E2A55`,`#B83C80`,`#E9649F`,`#FFB0D2`],done:[`#5A2E14`,`#8A4A1C`,`#B8702A`,`#DB9A3E`,`#F2C46A`],idle:[`#2E3236`,`#44494E`,`#5E646A`,`#7C8288`,`#A2A7AC`]},u={developer:[`#123A3F`,`#1A5A5E`,`#24806F`,`#3FB08A`,`#8EE6C2`],explorer:[`#2C3A12`,`#4A6418`,`#6E9424`,`#9CC23A`,`#DDF07A`],reviewer:[`#16283F`,`#1F3E66`,`#2E5E92`,`#4A86C4`,`#9AC8F0`],tester:[`#3A3012`,`#5E4C18`,`#8A6E22`,`#B8952E`,`#EAD27A`]},d=[`#4E2E1C`,`#7A4A2E`,`#A2683F`,`#C78A5A`],f=[`#34312F`,`#4F4A46`,`#6B6560`,`#8A847E`],p=[`#3E8E41`,`#5FB14F`],m=[`#4A4F54`,`#62686E`],h=`#FFF6E0`,g=[`#E3C24A`,`#C9A23A`],_=[`#9BDD6A`,`#D8F59A`],v={"!":`#E8B04A`,x:`#FF6F69`},y=12;function b(e){let t=String(e||``).toLowerCase();return/implement|develop/.test(t)?`developer`:/explor/.test(t)?`explorer`:/review/.test(t)?`reviewer`:/test/.test(t)?`tester`:null}var x=e=>e?.status===`blocked`||e?.status===`waiting-input`;function S(e){return Array.isArray(e.files_all)?e.files_all.filter(e=>e&&typeof e==`object`):(Array.isArray(e.files?.items)?e.files.items:[]).filter(e=>e&&typeof e==`object`).map(e=>({file:e.file??null,path:e.path??null,additions:e.additions??0,deletions:e.deletions??0,by:e.by??null}))}var C=e=>e==null||e===``?NaN:Number(e);function w(e){let t=C(e?.context?.used),n=C(e?.context?.window);return Number.isFinite(t)&&Number.isFinite(n)&&n>0?s(t/n):null}function T(e){let t=S(e),n=(Array.isArray(e.agents)?e.agents:[]).filter(e=>e&&typeof e==`object`).map((e,t)=>({key:e.id??`#${t}`,id:e.id??null,type:e.type||null,running:e.status!==`done`,files:[]})),r=new Map(n.map(e=>[e.key,e])),i=[],a=e.attribution!==!1;for(let e of t){if(!a||e.by==null){i.push(e);continue}let t=r.get(e.by);t||(t={key:e.by,id:e.by,type:`agent`,running:!0,files:[]},n.push(t),r.set(e.by,t)),t.files.push(e)}let o=w(e),l=o!=null,u=l?C(e.context.used):NaN,d=l?o:.5,f=Math.max(0,Math.floor(Number(e.compactions)||0)),p=C(e.context_at_compaction),m=f===0?1:l&&Number.isFinite(p)&&p>0?s(u/p):0;return{id:String(e.session_id??``),host:c[e.host]?e.host:`claude`,idle:e.status===`idle`,bubble:x(e)?`!`:e.error?`x`:null,turns:Math.max(0,Number(e.turns)||0),ctx:d,compactions:f,compacted:f>0&&m<1,regrow:m,crown:i,agents:n}}function E(e,t=!1){let n=T(e);return JSON.stringify([n.id,n.host,n.idle,n.bubble,n.turns,Math.round(n.ctx*100),n.compactions,Math.round(n.regrow*100),n.crown.length,n.agents.map(e=>[e.key,e.type,e.running,e.files.length]),!!t])}function D(e,{sakura:t=!1}={}){let n=T(e),{id:r,idle:i}=n,s=Math.min(1,Math.log1p(n.turns)/Math.log1p(40)),x=.55+.45*s,S=o(a(r)),C=Array.from({length:56},()=>Array(56).fill(null)),w=Array.from({length:56},()=>Array(56).fill(-1)),E=-1,D=(e,t,n)=>{e=Math.round(e),t=Math.round(t),e>=0&&e<56&&t>=0&&t<56&&(C[t][e]=n,w[t][e]=E)},O=i?f:d,k=i?m:p,A=i?l.idle:t?l.sakura:l.live,j=Math.round(41-(9+18*s)),M=1+S()*2+3*s,N=S()*Math.PI*2,P=.9+S()*.6,F=e=>28+M*Math.sin(e*Math.PI*P+N)-M*Math.sin(N);for(let e=41;e>=j;e--){let t=(41-e)/(41-j),n=F(t),r=3+4.5*s-(1.5+3.5*s)*t;for(let t=Math.floor(n-r/2);t<=Math.ceil(n+r/2);t++){let i=(t-(n-r/2))/r;D(t,e,i<.25?O[3]:i>.75?O[0]:S()<.15?O[1]:O[2])}}for(let e=-6;e<=6;e++)D(28+e,41,Math.abs(e)>4?O[1]:O[2]),Math.abs(e)<=5&&D(28+e,40,Math.abs(e)>3?O[1]:O[2]);let I=[],L=(e,t,n,i,s,c)=>{n*=1.15,e=Math.max(n+2,Math.min(53-n,e));let l=o(a(`${r}:pad:${c}`)),u=n*.72;t=Math.max(t,u+6);for(let r=0;r<6;r++){let r=-Math.PI*(.15+.7*l()),i=n*(.4+.5*l());for(let n=0;n<i;n++)D(e+Math.cos(r)*n,t+u*.5+Math.sin(r)*n*.8,O[0])}let d=Math.round(10+n*1.6),f=[];for(let r=0;r<d;r++){let r=l()*Math.PI*2,i=Math.sqrt(l());f.push([e+Math.cos(r)*i*n,t+Math.sin(r)*i*u,1.8+l()*2.2])}f.sort((e,t)=>t[1]-e[1]);for(let[e,n,r]of f){let a=Math.max(0,Math.min(4,Math.round(4*(1-(n-(t-u))/(2*u))+(l()-.5))));for(let t=Math.floor(n-r);t<=n+r;t++)for(let o=Math.floor(e-r);o<=e+r;o++){if(((o-e)**2+(t-n)**2)/(r*r)>1+(l()-.5)*.5)continue;let s=o-e+(t-n)<-r*.3?1:t-n>r*.5?-1:0;D(o,t,i[Math.max(0,Math.min(4,a+s))])}}let p=o(a(`${r}:bloom:${c}`));for(let r=0;r<Math.min(s,y);r++)D(e+(p()*2-1)*n*.8,t-p()*u*.9,h);return{rx:n,cy:t}},R=o(a(`${r}:side`))()<.5?-1:1,z=[];n.agents.forEach((e,t)=>{let c=.25+.55*(t/Math.max(1,n.agents.length-1)),l=Math.round(41-c*(41-j)),d=F(c);if(!e.running){let t=(3+4.5*s-(1.5+3.5*s)*c)/2;E=-1,D(d+R*(t+1),l,O[3]),D(d+R*(t+2),l-1,O[2]),z.push({agentId:e.id,type:e.type,files:e.files}),R=-R;return}let f=Math.round((12+Math.floor(o(a(`${r}:branch:${e.key}`))()*4))*x);E=-1;for(let e=0;e<=f;e++){let t=d+R*e,n=l-e*.45;D(t,n,O[e<f/2?1:2]),D(t,n+1,O[0]),e<f*.6&&D(t,n+2,O[0])}let p=i?null:b(e.type),m=p?u[p]:A;E=I.length,I.push({agentId:e.id,key:e.key,type:e.type,family:p,files:e.files,bbox:null}),L(d+R*f,l-f*.45-2,(8+Math.min(e.files.length,6)*.6)*x,m,e.files.length,e.key),R=-R});let B=I.length;I.push({agentId:null,key:null,type:null,family:null,files:n.crown,bbox:null}),E=B;let V=(4+7*n.ctx+Math.min(n.crown.length,6)*.5)*x*1.35,{rx:H,cy:U}=L(F(1),j-3,V,A,n.crown.length,`crown`);if(n.ctx>.8&&!n.compacted){let e=o(a(`${r}:yellow`));for(let t=0;t<56;t++)for(let n=0;n<56;n++)w[t][n]===B&&C[t][n]!==h&&t<U-H*.2&&e()<.55&&(C[t][n]=e()<.5?g[0]:g[1])}if(n.compacted){let e=o(a(`${r}:shoots`)),t=Math.round(U-H*.15-n.regrow*H*.5);for(let e=0;e<Math.max(0,t);e++)for(let t=0;t<56;t++)w[e][t]===B&&(C[e][t]=null,w[e][t]=-1);if(t>=0&&t<56)for(let r=0;r<56;r++){if(w[t][r]!==B||e()>=.12+n.regrow*.5)continue;let i=1+Math.floor(e()*(1+n.regrow*3));for(let e=1;e<=i;e++)D(r,t-e,e===i?_[1]:_[0])}}E=-1;let W=o(a(`${r}:fallen`));z.forEach((e,t)=>D(16+(t*7+Math.floor(W()*4))%24,40,l.done[2+t%2]));for(let e=0;e<Math.min(n.compactions,6);e++)D(15+e*2,42,h);let[G,K,q]=c[n.host];for(let e=42;e<=46;e++){let t=e<=43?0:Math.floor((e-43)*.45)+2;for(let n=13+t;n<=42-t;n++){if(e===42&&C[e][n]===h)continue;let r=K;e<=43?r=e===42?q:G:(e===46||n===13+t||n===42-t)&&(r=G),D(n,e,r)}}let J=o(a(`${r}:moss`));for(let e=15;e<=40;e++)D(e,41,J()<.5?k[0]:k[1]),J()<.35&&D(e,40,k[0]);for(let e=16;e<=39;e++)D(e,47,`#00000055`);if(n.bubble){let e=v[n.bubble];for(let t=3;t<10;t++)for(let n=40;n<47;n++)D(n,t,t===3||t===9||n===40||n===46?e:`#14191F`);if(D(41,10,e),n.bubble===`!`){for(let t=5;t<=6;t++)D(43,t,e);D(43,8,e)}else for(let[t,n]of[[2,2],[4,2],[3,3],[2,4],[4,4]])D(40+t,3+n,e)}let Y=[],X=I.map(()=>null);for(let e=0;e<56;e++){let t=0;for(;t<56;){let n=C[e][t],r=w[e][t];if(!n){t++;continue}let i=t;for(;i+1<56&&C[e][i+1]===n&&w[e][i+1]===r;)i++;if(Y.push({x:t,y:e,w:i-t+1,c:n,p:r}),r>=0){let n=X[r]||={x0:t,y0:e,x1:i,y1:e};n.x0=Math.min(n.x0,t),n.x1=Math.max(n.x1,i),n.y1=e}t=i+1}}return I.forEach((e,t)=>{let n=X[t];e.bbox=n?{x:n.x0,y:n.y0,w:n.x1-n.x0+1,h:n.y1-n.y0+1}:null}),{width:56,height:56,runs:Y,pads:I,bubble:n.bubble,fallen:z}}var O=e=>{if(!e)return``;let t=String(e).replace(/\\/g,`/`).replace(/\/+$/,``).split(`/`);return t[t.length-1]||String(e)},k=e=>e?String(e).replace(/\\/g,`/`).replace(/\/+$/,``).toLowerCase():``;function A(e){let t=new Map;for(let n of e||[]){let e=n.repo||n.root,r=n.repo_key||(e?k(e):n.cwd?`cwd:${k(n.cwd)}`:`outside a repo`),i=O(e||n.cwd)||`outside a repo`;t.has(r)||t.set(r,{key:r,name:i,trees:[]});let a=n.root&&e&&k(n.root)!==k(e)?O(n.root):null;t.get(r).trees.push({s:n,worktree:a})}let n=(e,t)=>e<t?-1:+(e>t),r=[...t.values()];for(let e of r)e.trees.sort((e,t)=>n(e.worktree||``,t.worktree||``)||n(String(e.s.session_id),String(t.s.session_id)));return r.sort((e,t)=>n(e.name.toLowerCase(),t.name.toLowerCase())||n(e.key,t.key))}var j=e=>e.key??(e.install?`${e.install}\0${e.session_id}`:String(e.session_id)),M=e=>j({key:e.key??void 0,install:e.install,session_id:e.sid}),N=(e,t)=>String(e).split(/[\\/]+/).filter(Boolean).slice(-t).join(`/`),P=e=>r(e.host).label;function F(e){let t=e||[],n=e=>n=>t.filter(t=>e(t)===e(n)).length,r=n(e=>e.host),i=n(e=>`${e.host} ${e.scope}`),a=new Map(t.map(e=>[e.install,r(e)<2?P(e):i(e)<2||e.scope===`global`?`${P(e)} · ${e.scope}`:`${P(e)} · ${O(e.path)}`])),o=()=>t.filter(e=>t.some(t=>t!==e&&a.get(t.install)===a.get(e.install)));for(let e=2,t=o();t.length;e++,t=o()){for(let n of t){let t=String(n.path).split(/[\\/]+/).filter(Boolean).length;a.set(n.install,`${P(n)} · ${e>t?n.path:N(n.path,e)}`)}if(e>64)break}return a}var I=(e,t)=>`#/activity/${encodeURIComponent(e)}`+(t?`?${new URLSearchParams({host:t.host,path:t.path})}`:``);function L(e,t){let n=String(e).indexOf(`?`),r=new URLSearchParams(String(t||``).split(`?`)[1]||``),i=r.get(`host`),a=r.get(`path`);return{sid:n<0?e:String(e).slice(0,n),install:i&&a?{host:i,path:a}:void 0}}function R(e,t){let n=new Map((t||[]).map(e=>[e.install,e])),i=F(t);return(e||[]).map(e=>{let t=n.get(e.install);return{...e,host:t?.host??e.host,chip:i.get(e.install)??(e.host?r(e.host).label:null),href:I(e.session_id,t)}})}var z=(e,t)=>new Set((e.writers||[]).filter(e=>M(e)===t).map(e=>k(e.root)));function B(e,t,n){let r=z(e,t);for(let t of z(e,n))if(r.has(t))return`same-worktree`;return`cross-worktree`}var V=e=>[...new Set((e.writers||[]).map(M))];function H(e,t){let n=new Map(e.map((e,t)=>[j(e.s),t])),r=new Map;for(let e of t||[]){let t=V(e).filter(e=>n.has(e));for(let i=0;i<t.length;i++)for(let a=i+1;a<t.length;a++){let o=n.get(t[i]),s=n.get(t[a]),c=o<s?`${o}-${s}`:`${s}-${o}`,l=B(e,t[i],t[a]);r.has(c)&&l!==`same-worktree`||r.set(c,{a:o,b:s,kind:l})}}return[...r.values()]}function U(e,t){let n=[];for(let r of t||[]){let t=V(r).filter(t=>t!==e);if(!t.length||!V(r).includes(e))continue;let i=t.some(t=>B(r,e,t)===`same-worktree`);n.push({path:r.path,kind:i?`same-worktree`:`cross-worktree`})}return n}var W=e=>e?.status===`busy`||x(e);function G(e,t=10){let n=e.map(e=>({...e,collapsed:!1})),r=n.reduce((e,t)=>e+t.trees.length,0);if(r<=t)return n;let i=n.length,a=n.filter(e=>!e.trees.some(e=>W(e.s))).sort((e,t)=>t.trees.length-e.trees.length||(e.key<t.key?-1:1));for(let e of a){if(r<=t||i<=1)break;e.collapsed=!0,r-=e.trees.length,i--}return n}var K=n(),q=12,J=10,Y=`geneseed-garden-sakura`;function X(){try{return window.localStorage.getItem(Y)===`1`}catch{return!1}}var Z=e=>e.key==null?`the session`:e.type||`agent`,Q=e=>e.path||e.file||`?`;function $({pad:e}){let t=e.files.slice(0,q);return(0,K.jsxs)(`div`,{className:`card gd-card`,children:[(0,K.jsxs)(`div`,{className:`act-lbl`,children:[Z(e),` · `,e.files.length,` file`,e.files.length===1?``:`s`]}),(0,K.jsx)(`ul`,{className:`gd-files`,children:t.map((e,t)=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mono act-ell`,children:Q(e)}),(0,K.jsxs)(`span`,{className:`mono act-xs`,children:[(0,K.jsxs)(`span`,{className:`t-good`,children:[`+`,e.additions??0]}),` `,(0,K.jsxs)(`span`,{className:`t-bad`,children:[`−`,e.deletions??0]})]})]},`${Q(e)}:${t}`))}),e.files.length>t.length&&(0,K.jsxs)(`div`,{className:`dim act-xs`,children:[`+`,e.files.length-t.length,` more`]})]})}var ee=e=>e?`${Z(e)}: ${e.files.length} file${e.files.length===1?``:`s`}`:``;function te(e,t,n,r){let i={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[e.key];e.key===`Escape`&&n!=null&&r(null),i&&t&&(e.preventDefault(),r(n==null?i>0?0:t-1:(n+i+t)%t))}var ne=(0,i.memo)(function({t:e,pad:t,swaying:n,onPad:r,px:a,label:o}){let s=(0,i.useMemo)(()=>{let t=new Map;for(let n of e.runs)t.has(n.p)||t.set(n.p,[]),t.get(n.p).push(n);return[...t.entries()]},[e]),c=(0,i.useRef)(null),l=e=>{let[t,n]=[c.current,e.changedTouches?.[0]];return!!t&&!!n&&Math.hypot(n.clientX-t.x,n.clientY-t.y)>J};return(0,K.jsx)(`svg`,{onTouchStart:e=>{let t=e.touches?.[0];c.current=t?{x:t.clientX,y:t.clientY}:null},className:`gd-svg${t==null?``:` gd-dimming`}`,viewBox:`0 0 56 56`,width:56*a,height:56*a,shapeRendering:`crispEdges`,"data-bubble":e.bubble||void 0,...o?{role:`img`,"aria-label":o}:{"aria-hidden":`true`},children:s.map(([i,a])=>(0,K.jsx)(`g`,{"data-p":i,className:[i===t&&`gd-hot`,n&&i>=0&&e.pads[i].key!=null&&`gd-sway`].filter(Boolean).join(` `)||void 0,onMouseEnter:i>=0?()=>r(i):void 0,onMouseLeave:i>=0?()=>r(null):void 0,onTouchEnd:i>=0?e=>{l(e)||(e.cancelable&&e.preventDefault(),r(i===t?null:i))}:void 0,children:a.map(e=>(0,K.jsx)(`rect`,{x:e.x,y:e.y,width:e.w,height:1,fill:e.c},`${e.x},${e.y}`))},i))})});export{H as _,ee as a,G as c,L as d,D as f,U as g,R as h,te as i,w as l,F as m,Y as n,X as o,A as p,ne as r,j as s,$ as t,I as u,E as v};
@@ -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"./index-BhT94v2q.js";var i=e(t(),1),a=n(),o=1200;function s({text:e,label:t,title:n,className:s=`btn ghost sm`}){let[c,l]=(0,i.useState)(null),u=(0,i.useRef)(null),d=(0,i.useRef)(!1);(0,i.useEffect)(()=>(d.current=!1,()=>{d.current=!0,clearTimeout(u.current)}),[]);let f=e=>{d.current||(l(e),clearTimeout(u.current),u.current=setTimeout(()=>l(null),o))};return(0,a.jsxs)(`button`,{type:`button`,className:s,onClick:async()=>{try{await navigator.clipboard.writeText(e),f(`ok`)}catch{f(`fail`)}},"aria-label":t,title:n,children:[(0,a.jsx)(r,{name:c===`ok`?`check`:c===`fail`?`x`:`copy`}),c===`ok`?`Copied`:c===`fail`?`Copy failed`:`Copy`]})}export{s as t};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-C1iE8mnY.js";import{Ct as r}from"./index-BILaKHbH.js";var i=e(t(),1),a=n(),o=1200;function s({text:e,label:t,title:n,className:s=`btn ghost sm`}){let[c,l]=(0,i.useState)(null),u=(0,i.useRef)(null),d=(0,i.useRef)(!1);(0,i.useEffect)(()=>(d.current=!1,()=>{d.current=!0,clearTimeout(u.current)}),[]);let f=e=>{d.current||(l(e),clearTimeout(u.current),u.current=setTimeout(()=>l(null),o))};return(0,a.jsxs)(`button`,{type:`button`,className:s,onClick:async()=>{try{await navigator.clipboard.writeText(e),f(`ok`)}catch{f(`fail`)}},"aria-label":t,title:n,children:[(0,a.jsx)(r,{name:c===`ok`?`check`:c===`fail`?`x`:`copy`}),c===`ok`?`Copied`:c===`fail`?`Copy failed`:`Copy`]})}export{s as t};