@rhizogrip/spore-cli 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/spore.js +3 -0
- package/package.json +2 -2
- package/src/dispatch.js +3 -3
- package/tui/conversation.js +8 -0
- package/tui/index.js +4 -7
- package/tui/status.js +1 -0
package/bin/spore.js
CHANGED
|
@@ -435,6 +435,9 @@ try {
|
|
|
435
435
|
// the record.
|
|
436
436
|
const settled = sent.repeated && !sent.started && stateOf(ws).state !== RUNNING
|
|
437
437
|
|
|
438
|
+
const dreaming = !sent.started && !settled && stateOf(ws).dreaming
|
|
439
|
+
if (dreaming) console.error('spore: it is dreaming — your message waits for it to wake, and the turn after the dream reads it')
|
|
440
|
+
|
|
438
441
|
if (argv.unsafe && !sent.started && !settled) {
|
|
439
442
|
console.error('spore: --unsafe took no effect — the message went to the turn already running, which keeps the confinement it was started with')
|
|
440
443
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhizogrip/spore-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
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.
|
|
53
|
+
"@rhizogrip/spore": "1.6.0",
|
|
54
54
|
"chalk": "^6.0.1",
|
|
55
55
|
"minimist": "^1.2.8"
|
|
56
56
|
},
|
package/src/dispatch.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
addTo, allowPlugin, billingFor, changeText, define, defaultModel, disallowPlugin, durationText,
|
|
18
18
|
edit, extend, getKey, jobs, list, listPlugins, log, pause, precursors, remake, remove,
|
|
19
19
|
removeFrom, removeSchedule, runningLines, saidOf, schedules, setDefaultModel, setKey, setSchedule, settings,
|
|
20
|
-
show, showPlugin, sql, stopJob, switchModel, tick, tickReport, unmetered, unpause, upgrade, usage, wrap, CONFIG_FILE, DEFAULT_SPORANGIUM
|
|
20
|
+
show, showPlugin, sql, stateWord, stopJob, switchModel, tick, tickReport, unmetered, unpause, upgrade, usage, wrap, CONFIG_FILE, DEFAULT_SPORANGIUM
|
|
21
21
|
} from '@rhizogrip/spore'
|
|
22
22
|
import { diagnose, renderDoctor } from './doctor.js'
|
|
23
23
|
import { hook } from './hooks.js'
|
|
@@ -42,7 +42,7 @@ 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 ` ${row.
|
|
45
|
+
return ` ${stateWord(row).padEnd(STATE_WIDTH)} ${String(row.lastTurnNo).padStart(4)} turns ${spend.padStart(9)} ${size(row.bytes).padStart(8)} ${where}${works}`
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const block = (title, rows, under) => {
|
|
@@ -137,7 +137,7 @@ export function renderHeader (ws, grant) {
|
|
|
137
137
|
function renderShow (result) {
|
|
138
138
|
const line = (label, value) => console.log(` ${label.padEnd(10)} ${value}`)
|
|
139
139
|
console.log(result.ws)
|
|
140
|
-
line('state', `${result
|
|
140
|
+
line('state', `${stateWord(result)}${result.pid ? ` pid ${result.pid} since ${result.startedAt}` : ''}`)
|
|
141
141
|
line('name', result.name)
|
|
142
142
|
if (result.description) line('description', result.description)
|
|
143
143
|
line('sporangium', result.sporangium)
|
package/tui/conversation.js
CHANGED
|
@@ -45,6 +45,14 @@ export function history ({ turns, inbox }) {
|
|
|
45
45
|
|
|
46
46
|
export const createLive = () => ({ text: '', notes: [], tools: [], rounds: 0, input: null, cost: 0, complete: null })
|
|
47
47
|
|
|
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
|
+
export function liveOf (events) {
|
|
50
|
+
if (!events.length) return null
|
|
51
|
+
const live = createLive()
|
|
52
|
+
for (const event of events) applyEvent(live, event)
|
|
53
|
+
return live
|
|
54
|
+
}
|
|
55
|
+
|
|
48
56
|
/** False when the event changes nothing shown. Text written before a tool call is a note: the answer is what comes last. */
|
|
49
57
|
export function applyEvent (live, event) {
|
|
50
58
|
switch (event.event) {
|
package/tui/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import chalk from 'chalk'
|
|
|
9
9
|
|
|
10
10
|
import { runningJob, scheduleLine } from '../src/dispatch.js'
|
|
11
11
|
import { COMMANDS, parseCommand } from './commands.js'
|
|
12
|
-
import { applyEvent, createLive, history } from './conversation.js'
|
|
12
|
+
import { applyEvent, createLive, history, liveOf } from './conversation.js'
|
|
13
13
|
import { changeOf, counts, hunks } from './diff.js'
|
|
14
14
|
import { printable } from './printable.js'
|
|
15
15
|
import { PromptEditor } from './prompt.js'
|
|
@@ -320,12 +320,9 @@ export async function runTui ({ ws, commands = [], renderTool = null, greeting =
|
|
|
320
320
|
state.limits = null
|
|
321
321
|
if (stateOf(state.ws).state === RUNNING) {
|
|
322
322
|
const ends = readEvents(state.ws, { event: 'turn_end' })
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
state.lastSeq = event.seq
|
|
327
|
-
}
|
|
328
|
-
conversation.live = live
|
|
323
|
+
const events = readEvents(state.ws, { after: ends.at(-1)?.seq ?? 0 })
|
|
324
|
+
if (events.length) state.lastSeq = events.at(-1).seq
|
|
325
|
+
conversation.live = liveOf(events)
|
|
329
326
|
}
|
|
330
327
|
conversation.invalidate()
|
|
331
328
|
refresh()
|
package/tui/status.js
CHANGED
|
@@ -11,6 +11,7 @@ const unmetered = (shown) => shown.billing && shown.billing.kind !== 'metered'
|
|
|
11
11
|
export function stateText (shown, { paused, now }) {
|
|
12
12
|
if (paused) return 'paused'
|
|
13
13
|
if (shown.state !== RUNNING) return shown.state
|
|
14
|
+
if (shown.dreaming) return `dreaming ${durationText(now - Date.parse(shown.startedAt))}`
|
|
14
15
|
if (shown.draining) return 'finishing'
|
|
15
16
|
if (shown.turnLimits?.limits.wall) return 'running'
|
|
16
17
|
return `running ${durationText(now - Date.parse(shown.startedAt))}`
|