@rhizogrip/spore-cli 1.3.0 → 1.4.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 +2 -2
- package/tui/README.md +3 -2
- package/tui/index.js +6 -4
- package/tui/prompt.js +10 -1
- package/tui/status.js +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhizogrip/spore-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.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.
|
|
53
|
+
"@rhizogrip/spore": "1.4.1",
|
|
54
54
|
"chalk": "^6.0.1",
|
|
55
55
|
"minimist": "^1.2.8"
|
|
56
56
|
},
|
package/tui/README.md
CHANGED
|
@@ -22,8 +22,9 @@ ctrl+d leave, on an empty line
|
|
|
22
22
|
//text a message that starts with /
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
The
|
|
26
|
-
|
|
25
|
+
The line you type on names the spore and its state at its right. The status line under it gives
|
|
26
|
+
the running turn's limits, the spend and the model. When another spore answers or asks, the
|
|
27
|
+
status line says so and the terminal gets a notification
|
|
27
28
|
(OSC 9); so does the open one when a turn ran longer than a minute.
|
|
28
29
|
|
|
29
30
|
## In a directory
|
package/tui/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import { changeOf, counts, hunks } from './diff.js'
|
|
|
14
14
|
import { printable } from './printable.js'
|
|
15
15
|
import { PromptEditor } from './prompt.js'
|
|
16
16
|
import { Answer } from './answer.js'
|
|
17
|
-
import { matching, priceText, statusParts } from './status.js'
|
|
17
|
+
import { matching, priceText, sporeLabel, statusParts } from './status.js'
|
|
18
18
|
|
|
19
19
|
const REFRESH_MS = 1000
|
|
20
20
|
const TWICE_MS = 1500
|
|
@@ -283,8 +283,8 @@ export async function runTui ({ ws, commands = [], renderTool = null, greeting =
|
|
|
283
283
|
const view = new ScrollView(conversation, { follow: 'end', primary: true })
|
|
284
284
|
tui.setLayoutRoot(new VStack([
|
|
285
285
|
{ component: view, basis: 0, grow: 1, minSize: 1 },
|
|
286
|
-
{ component:
|
|
287
|
-
{ component:
|
|
286
|
+
{ component: editor, basis: 'auto', shrink: 1, minSize: 3 },
|
|
287
|
+
{ component: status, basis: 'auto' }
|
|
288
288
|
]))
|
|
289
289
|
const allCommands = [...COMMANDS, ...commands]
|
|
290
290
|
editor.setAutocompleteProvider(new CombinedAutocompleteProvider(allCommands.map(({ name, description, argumentHint }) => ({ name, description, argumentHint })), process.cwd()))
|
|
@@ -308,7 +308,9 @@ export async function runTui ({ ws, commands = [], renderTool = null, greeting =
|
|
|
308
308
|
else if (!state.limits) state.limits = show({ ws: state.ws }).turnLimits
|
|
309
309
|
state.shown = { ws: state.ws, model: state.grant.model, billing: state.grant.billing, ...now, turnLimits: state.limits }
|
|
310
310
|
const live = conversation.live ?? createLive()
|
|
311
|
-
|
|
311
|
+
const at = Date.now()
|
|
312
|
+
editor.label = sporeLabel({ shown: state.shown, paused: Boolean(paused()), now: at })
|
|
313
|
+
status.parts = statusParts({ shown: state.shown, live, attention: [...state.attention.values()], now: at })
|
|
312
314
|
tui.requestRender()
|
|
313
315
|
}
|
|
314
316
|
|
package/tui/prompt.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import { Editor } from '@earendil-works/pi-tui'
|
|
1
|
+
import { Editor, visibleWidth } from '@earendil-works/pi-tui'
|
|
2
2
|
|
|
3
3
|
export const PROMPT = '> '
|
|
4
4
|
|
|
5
5
|
export class PromptEditor extends Editor {
|
|
6
|
+
label = ''
|
|
7
|
+
|
|
8
|
+
renderBottomBorder (width, hiddenLineCount) {
|
|
9
|
+
const tag = this.label ? ` ${this.label} ` : ''
|
|
10
|
+
const room = width - visibleWidth(tag) - 1
|
|
11
|
+
if (!tag || room < 4) return super.renderBottomBorder(width, hiddenLineCount)
|
|
12
|
+
return super.renderBottomBorder(room, hiddenLineCount) + tag + this.borderColor('─')
|
|
13
|
+
}
|
|
14
|
+
|
|
6
15
|
render (width) {
|
|
7
16
|
const lines = super.render(width - PROMPT.length)
|
|
8
17
|
const bottom = this.renderedVisibleLineCount + 1
|
package/tui/status.js
CHANGED
|
@@ -34,8 +34,10 @@ export function spendText (shown) {
|
|
|
34
34
|
|
|
35
35
|
export const attentionText = (attention) => attention.map(({ name, asked }) => `${name} ${asked ? 'asked' : 'answered'}`).join(' · ')
|
|
36
36
|
|
|
37
|
-
export
|
|
38
|
-
|
|
37
|
+
export const sporeLabel = ({ shown, paused, now }) => `${basename(shown.ws)} · ${stateText(shown, { paused, now })}`
|
|
38
|
+
|
|
39
|
+
export function statusParts ({ shown, live, attention, now }) {
|
|
40
|
+
const parts = []
|
|
39
41
|
if (attention.length) parts.push(`${attentionText(attention)} — Ctrl+P`)
|
|
40
42
|
const limited = Boolean(shown.turnLimits) && !shown.draining
|
|
41
43
|
if (limited) parts.push(limitsText(shown.turnLimits, { rounds: live.rounds, cost: unmetered(shown) ? null : live.cost, now }))
|