@rhizogrip/spore-cli 1.7.1 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhizogrip/spore-cli",
3
- "version": "1.7.1",
3
+ "version": "1.8.1",
4
4
  "author": {
5
5
  "name": "Christophe Le Bars",
6
6
  "email": "clb@toort.net"
@@ -50,7 +50,7 @@
50
50
  "tui": "node bin/spore.js tui"
51
51
  },
52
52
  "dependencies": {
53
- "@rhizogrip/spore": "1.7.1",
53
+ "@rhizogrip/spore": "1.8.1",
54
54
  "chalk": "^6.0.1",
55
55
  "minimist": "^1.2.8"
56
56
  },
package/src/dispatch.js CHANGED
@@ -42,7 +42,8 @@ const line = (row, under) => {
42
42
  const where = under && row.ws.startsWith(under) ? row.ws.slice(under.length + 1) || '.' : row.ws
43
43
  const spend = row.treeUsd ? `$${row.treeUsd.toFixed(4)}` : ''
44
44
  const works = row.definitionError ? ' (its spore.cmk does not parse)' : row.writes.map(path => ` → ${tilde(path)}`).join('')
45
- return ` ${stateWord(row).padEnd(STATE_WIDTH)} ${String(row.lastTurnNo).padStart(4)} turns ${spend.padStart(9)} ${size(row.bytes).padStart(8)} ${where}${works}`
45
+ const over = row.historyOver ? ' (history over its bound)' : ''
46
+ return ` ${stateWord(row).padEnd(STATE_WIDTH)} ${String(row.lastTurnNo).padStart(4)} turns ${spend.padStart(9)} ${size(row.bytes).padStart(8)} ${where}${works}${over}`
46
47
  }
47
48
 
48
49
  const block = (title, rows, under) => {
@@ -171,6 +172,7 @@ function renderShow (result) {
171
172
  for (const [i, job] of result.jobs.running.entries()) line(i ? '' : 'jobs', runningJob(job))
172
173
  }
173
174
  line('turns', `${result.lastTurnNo}${result.last?.stopReason ? ` last ${result.last.stopReason}` : ''}${result.endedAt ? ` ${result.endedAt}` : ''}`)
175
+ if (result.history) line('history', historyLine(result.history))
174
176
  line('spend', unmetered(result.billing) ? `not metered · ${result.billing.label}` : `$${result.treeUsd.toFixed(6)}`)
175
177
  line('work', `${result.workUnits} units (${result.workUnitsOwn} own rounds, ${result.workUnitsChildren} in cells)`)
176
178
  if (result.produced.length) {
@@ -519,6 +521,12 @@ const EIGHTHS = ' ▏▎▍▌▋▊▉'
519
521
 
520
522
  const dollars = (micros) => `$${(micros / 1e6).toFixed(4)}`
521
523
  const count = (n) => (n >= 1e6 ? `${(n / 1e6).toFixed(1)}M` : n >= 1e3 ? `${Math.round(n / 1e3)}k` : String(n))
524
+
525
+ function historyLine (history) {
526
+ const cache = history.cacheShare === null ? '' : ` · cache ${Math.round(history.cacheShare * 100)}% over ${plural(history.rounds ?? 0, 'round')}`
527
+ const over = history.over ? ' — OVER ITS BOUND, it was not summarized' : ''
528
+ return `${count(history.sent)} / ${count(history.bound)} at turn ${history.turnNo}${cache}${over}`
529
+ }
522
530
  const plural = (n, one) => `${n} ${one}${n === 1 ? '' : 's'}`
523
531
 
524
532
  const bar = (micros, most) => {
@@ -43,7 +43,7 @@ export function history ({ turns, inbox }) {
43
43
  return items
44
44
  }
45
45
 
46
- export const createLive = () => ({ text: '', notes: [], tools: [], rounds: 0, input: null, cost: 0, complete: null })
46
+ export const createLive = () => ({ text: '', notes: [], tools: [], rounds: 0, input: null, cached: 0, cost: 0, complete: null })
47
47
 
48
48
  /** The running turn from its events so far, or null when there are none: a turn's end is recorded before its lock is let go. */
49
49
  export function liveOf (events) {
@@ -75,7 +75,8 @@ export function applyEvent (live, event) {
75
75
  return true
76
76
  }
77
77
  case 'usage':
78
- live.input = event.input
78
+ live.input = event.input + event.cacheRead + event.cacheWrite
79
+ live.cached = event.cacheRead
79
80
  live.cost += event.cost
80
81
  return true
81
82
  case 'interject':
@@ -84,9 +85,15 @@ export function applyEvent (live, event) {
84
85
  case 'wrap':
85
86
  live.notes.push({ kind: 'note', text: `wrapping up — reached its ${event.dimension} limit` })
86
87
  return true
88
+ case 'compaction_started':
89
+ live.notes.push({ kind: 'note', text: `summarizing ${event.messages} earlier messages before the first round…` })
90
+ return true
87
91
  case 'compaction':
88
92
  live.notes.push({ kind: 'note', text: 'earlier turns summarized' })
89
93
  return true
94
+ case 'compaction_failed':
95
+ live.notes.push({ kind: 'note', text: `earlier turns are over their bound and were not summarized — ${event.why}` })
96
+ return true
90
97
  case 'complete':
91
98
  live.complete = { stopReason: event.stopReason ?? 'answer', output: event.output == null ? null : printable(event.output) }
92
99
  if (live.complete.output) live.text = live.complete.output
package/tui/status.js CHANGED
@@ -42,7 +42,7 @@ export function statusParts ({ shown, live, attention, now }) {
42
42
  if (attention.length) parts.push(`${attentionText(attention)} — Ctrl+P`)
43
43
  const limited = Boolean(shown.turnLimits) && !shown.draining
44
44
  if (limited) parts.push(limitsText(shown.turnLimits, { rounds: live.rounds, cost: unmetered(shown) ? null : live.cost, now }))
45
- if (live.input !== null) parts.push(`${thousands(live.input)} in`)
45
+ if (live.input !== null) parts.push(`${thousands(live.input)} in${live.cached ? ` (${thousands(live.cached)} cached)` : ''}`)
46
46
  if (!limited || unmetered(shown)) parts.push(spendText(shown))
47
47
  parts.push(shown.model)
48
48
  return parts