@rhizogrip/spore-cli 1.38.0 → 1.39.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/README.md +1 -1
- package/bin/spore.js +1 -1
- package/package.json +4 -3
- package/tui/index.js +46 -4
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ spore # what each command does
|
|
|
13
13
|
The terminal screen (`spore tui`, `spore here`) is an optional dependency: `--omit=optional` leaves it
|
|
14
14
|
out, for a server, and the other commands work without it.
|
|
15
15
|
|
|
16
|
-
Linux x64, Node 24 or newer. How spore works, what a spore is and every command:
|
|
16
|
+
Linux x64 or arm64, Node 24 or newer. How spore works, what a spore is and every command:
|
|
17
17
|
[the spore README](https://github.com/RHIZOGRIP/spore/blob/main/packages/spore/README.md).
|
|
18
18
|
|
|
19
19
|
## License
|
package/bin/spore.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Contract: ARCHITECTURE.md, "The spore command".
|
|
5
5
|
*
|
|
6
6
|
* This is the follower and holds nothing: `send` appends to the inbox and races
|
|
7
|
-
* for the lock, the runner (native
|
|
7
|
+
* for the lock, the runner (native/<arch>/spore-runner) holds the lock and the slot, and
|
|
8
8
|
* bin/spore-agent.js is the confined half. Ctrl-C here leaves the turn running.
|
|
9
9
|
*/
|
|
10
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhizogrip/spore-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.39.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Christophe Le Bars",
|
|
6
6
|
"email": "clb@toort.net"
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"linux"
|
|
33
33
|
],
|
|
34
34
|
"cpu": [
|
|
35
|
-
"x64"
|
|
35
|
+
"x64",
|
|
36
|
+
"arm64"
|
|
36
37
|
],
|
|
37
38
|
"bin": {
|
|
38
39
|
"spore": "bin/spore.js"
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
"tui": "node bin/spore.js tui"
|
|
51
52
|
},
|
|
52
53
|
"dependencies": {
|
|
53
|
-
"@rhizogrip/spore": "1.
|
|
54
|
+
"@rhizogrip/spore": "1.39.0",
|
|
54
55
|
"chalk": "^6.0.1",
|
|
55
56
|
"minimist": "^1.2.8"
|
|
56
57
|
},
|
package/tui/index.js
CHANGED
|
@@ -247,12 +247,32 @@ class Panel {
|
|
|
247
247
|
invalidate () {}
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
/**
|
|
251
|
+
* pi-tui gives the terminal back — the alternate screen, mouse reports, the keyboard protocol —
|
|
252
|
+
* only in `stop()`, so an error nothing caught would leave the shell unusable. Until the screen is
|
|
253
|
+
* left, such an error stops it first, then is reported and exits as Node would.
|
|
254
|
+
*/
|
|
255
|
+
function stoppedOnCrash (tui) {
|
|
256
|
+
const crashed = (err) => {
|
|
257
|
+
tui.stop({ preserveScreen: true })
|
|
258
|
+
console.error(err)
|
|
259
|
+
process.exit(1)
|
|
260
|
+
}
|
|
261
|
+
process.on('uncaughtException', crashed)
|
|
262
|
+
process.on('unhandledRejection', crashed)
|
|
263
|
+
return () => {
|
|
264
|
+
process.off('uncaughtException', crashed)
|
|
265
|
+
process.off('unhandledRejection', crashed)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
250
269
|
/** A choice made before any spore is open: the value picked, or null when it was left. */
|
|
251
270
|
export function choose ({ title, header = [], items, terminal = new ProcessTerminal() }) {
|
|
252
271
|
const tui = new TuiAltScreen(terminal)
|
|
253
272
|
return new Promise(resolve => {
|
|
254
273
|
const done = (value) => {
|
|
255
274
|
tui.stop({ preserveScreen: true })
|
|
275
|
+
released()
|
|
256
276
|
resolve(value)
|
|
257
277
|
}
|
|
258
278
|
const picker = new Picker({ title, header, items, onSelect: (item) => done(item.value), onCancel: () => done(null) })
|
|
@@ -265,6 +285,7 @@ export function choose ({ title, header = [], items, terminal = new ProcessTermi
|
|
|
265
285
|
})
|
|
266
286
|
tui.setLayoutRoot(new VStack([{ component: picker, basis: 'auto' }]))
|
|
267
287
|
tui.setFocus(picker)
|
|
288
|
+
const released = stoppedOnCrash(tui)
|
|
268
289
|
tui.start()
|
|
269
290
|
})
|
|
270
291
|
}
|
|
@@ -304,12 +325,23 @@ export async function runTui ({ ws, commands = [], renderTool = null, greeting =
|
|
|
304
325
|
state.noticeTimer = setTimeout(() => { status.notice = ''; tui.requestRender() }, Math.max(NOTICE_MS, text.length * 60))
|
|
305
326
|
tui.requestRender()
|
|
306
327
|
}
|
|
328
|
+
// spore.cmk is edited while the screen is open: one that does not parse is shown until it does.
|
|
329
|
+
const invalid = (err) => {
|
|
330
|
+
if (err.type !== 'DEFINITION_INVALID') throw err
|
|
331
|
+
notice(errorText(err))
|
|
332
|
+
}
|
|
307
333
|
const notify = (text) => terminal.write(`\x1b]9;${printable(text).replace(/\n/g, ' ')}\x07`)
|
|
308
334
|
|
|
309
335
|
const refresh = () => {
|
|
310
336
|
const now = stateOf(state.ws)
|
|
311
337
|
if (now.state !== RUNNING) state.limits = null
|
|
312
|
-
else if (!state.limits)
|
|
338
|
+
else if (!state.limits) {
|
|
339
|
+
try {
|
|
340
|
+
state.limits = show({ ws: state.ws }).turnLimits
|
|
341
|
+
} catch (err) {
|
|
342
|
+
invalid(err)
|
|
343
|
+
}
|
|
344
|
+
}
|
|
313
345
|
state.shown = { ws: state.ws, model: state.grant.model, billing: state.grant.billing, ...now, turnLimits: state.limits }
|
|
314
346
|
const live = conversation.live ?? createLive()
|
|
315
347
|
const at = Date.now()
|
|
@@ -332,9 +364,10 @@ export async function runTui ({ ws, commands = [], renderTool = null, greeting =
|
|
|
332
364
|
}
|
|
333
365
|
|
|
334
366
|
const open = (ws) => {
|
|
367
|
+
const grant = grantOf(ws)
|
|
335
368
|
state.ws = ws
|
|
336
369
|
state.attention.delete(ws)
|
|
337
|
-
state.grant =
|
|
370
|
+
state.grant = grant
|
|
338
371
|
state.lastSeq = 0
|
|
339
372
|
remember(ws)
|
|
340
373
|
reload()
|
|
@@ -362,7 +395,14 @@ export async function runTui ({ ws, commands = [], renderTool = null, greeting =
|
|
|
362
395
|
label: `${state.attention.has(row.ws) ? '● ' : ''}${basename(row.ws)}`,
|
|
363
396
|
description: `${row.state} · ${row.lastTurnNo} turns · $${row.treeUsd.toFixed(4)} · ${ago(row.last?.endedAt, now)}`
|
|
364
397
|
})),
|
|
365
|
-
onSelect: (item) => {
|
|
398
|
+
onSelect: (item) => {
|
|
399
|
+
closeOverlay()
|
|
400
|
+
try {
|
|
401
|
+
open(item.value)
|
|
402
|
+
} catch (err) {
|
|
403
|
+
invalid(err)
|
|
404
|
+
}
|
|
405
|
+
},
|
|
366
406
|
onCancel: closeOverlay
|
|
367
407
|
}))
|
|
368
408
|
}
|
|
@@ -397,6 +437,7 @@ export async function runTui ({ ws, commands = [], renderTool = null, greeting =
|
|
|
397
437
|
following.abort()
|
|
398
438
|
clearInterval(ticking)
|
|
399
439
|
tui.stop({ preserveScreen: true })
|
|
440
|
+
released()
|
|
400
441
|
finish(0)
|
|
401
442
|
}
|
|
402
443
|
|
|
@@ -538,7 +579,7 @@ export async function runTui ({ ws, commands = [], renderTool = null, greeting =
|
|
|
538
579
|
if (!trimmed) return
|
|
539
580
|
editor.setText('')
|
|
540
581
|
const command = parseCommand(trimmed)
|
|
541
|
-
if (command) return run(command)
|
|
582
|
+
if (command) return run(command).catch(invalid)
|
|
542
583
|
say(trimmed.startsWith('//') ? trimmed.slice(1) : trimmed)
|
|
543
584
|
}
|
|
544
585
|
|
|
@@ -646,6 +687,7 @@ export async function runTui ({ ws, commands = [], renderTool = null, greeting =
|
|
|
646
687
|
|
|
647
688
|
open(ws)
|
|
648
689
|
if (greeting) notice(greeting)
|
|
690
|
+
const released = stoppedOnCrash(tui)
|
|
649
691
|
tui.start()
|
|
650
692
|
const ticking = setInterval(refresh, REFRESH_MS)
|
|
651
693
|
follow().catch(err => notice(`stopped following the spores — ${err.message}`))
|