@rhizogrip/spore-cli 1.13.0 → 1.15.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhizogrip/spore-cli",
3
- "version": "1.13.0",
3
+ "version": "1.15.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.13.0",
53
+ "@rhizogrip/spore": "1.15.0",
54
54
  "chalk": "^6.0.1",
55
55
  "minimist": "^1.2.8"
56
56
  },
package/src/dispatch.js CHANGED
@@ -16,12 +16,13 @@ import { basename, join, resolve } from 'node:path'
16
16
  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
- removeFrom, removeSchedule, runningLines, saidOf, schedules, setDefaultModel, setKey, setSchedule, settings,
19
+ removeFrom, removeSchedule, runningLines, schedules, setDefaultModel, setKey, setSchedule, settings,
20
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'
24
24
  import { createServices } from './services.js'
25
+ import { saidBy, saidText } from '../tui/conversation.js'
25
26
 
26
27
  const STATE_WIDTH = 9
27
28
 
@@ -298,7 +299,8 @@ async function readStdin () {
298
299
 
299
300
  const when = (iso) => (iso ? iso.replace('T', ' ').slice(0, 19) : '—'.padEnd(19))
300
301
 
301
- const quoted = (said) => (said.length ? said.map(one => JSON.stringify(one.length > 60 ? one.slice(0, 57) + '…' : one)).join(' ') : '')
302
+ const cut = (text) => (text.length > 60 ? text.slice(0, 57) + '…' : text)
303
+ const quoted = (entries) => entries.map(entry => `${saidBy(entry) ? `${saidBy(entry)}: ` : ''}${JSON.stringify(cut(saidText(entry)))}`).join(' ')
302
304
 
303
305
  function renderLog (result) {
304
306
  if (!result.turns.length && !result.waiting.length && !result.held.length) {
@@ -318,7 +320,7 @@ function renderLog (result) {
318
320
  // The time column is when a turn ended, and a waiting message has not been answered by
319
321
  // one. Blank says that; when it was said is in the record for anyone who needs it.
320
322
  for (const entry of result.waiting) {
321
- console.log(` ${' '.repeat(19)} ${'waiting'.padEnd(12)} ${' '.repeat(19)} ${quoted([saidOf(entry)])}`)
323
+ console.log(` ${' '.repeat(19)} ${'waiting'.padEnd(12)} ${' '.repeat(19)} ${quoted([entry])}`)
322
324
  }
323
325
  for (const one of result.held) {
324
326
  console.log(` ${' '.repeat(19)} ${one.state.padEnd(12)} ${' '.repeat(19)} schedule ${one.name} — ${one.why}`)
@@ -6,12 +6,19 @@
6
6
 
7
7
  import { printable } from './printable.js'
8
8
 
9
- export function originOf (entry) {
9
+ /** Who said an entry, when that is known: a person by name, or the schedule, webhook or job. */
10
+ export function saidBy (entry) {
11
+ if (entry.fromName) return printable(entry.fromName)
10
12
  if (entry.schedule) return `schedule "${entry.schedule}"`
11
13
  if (entry.hook) return `webhook "${entry.hook}"`
12
14
  if (entry.job) return `job "${entry.job}"`
13
- if (entry.replyTo) return entry.replyTo.split(':')[0]
14
- return 'elsewhere'
15
+ return null
16
+ }
17
+
18
+ export function originOf (entry) {
19
+ const kind = entry.replyTo?.split(':')[0]
20
+ if (entry.fromName) return kind ? `${saidBy(entry)} · ${kind}` : saidBy(entry)
21
+ return saidBy(entry) ?? kind ?? 'elsewhere'
15
22
  }
16
23
 
17
24
  export function saidText (entry) {