@rhizogrip/spore-cli 1.8.1 → 1.10.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.8.1",
3
+ "version": "1.10.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.8.1",
53
+ "@rhizogrip/spore": "1.10.0",
54
54
  "chalk": "^6.0.1",
55
55
  "minimist": "^1.2.8"
56
56
  },
package/src/dispatch.js CHANGED
@@ -451,6 +451,7 @@ function renderPlugin (result) {
451
451
  }
452
452
  for (const [i, [name, path]] of Object.entries(result.programs).entries()) line(i ? '' : 'programs', `${name} → ${path}`)
453
453
  for (const [i, [name, value]] of Object.entries(result.env).entries()) line(i ? '' : 'env', `${name}=${value}`)
454
+ if (result.contain) line('contain', `${result.contain.keep}, and nothing else of ${result.contain.hide}`)
454
455
  if (result.modules.length) line('modules', `${result.modules.join(', ')} → node_modules/, for the agent's programs`)
455
456
  if (result.sources.length) line('sources', `${result.sources.join(', ')} — granted with the plugin, held by the runner`)
456
457
  if (result.reference) line('reference', `${result.reference} → plugins/${result.name}.md`)
package/src/services.js CHANGED
@@ -46,20 +46,18 @@ const sshKeysCheck = (keys) => [
46
46
  ].join('\n')
47
47
 
48
48
  /**
49
- * The sluice broker spores reach: its rules and the list its agents read are the operator's, in
50
- * sluice's own config folder; the binary is the one on PATH, or where `cargo install` puts it.
49
+ * The sluice broker spores reach: one socket per spore, each serving `<spore>.rules` from this
50
+ * folder beside `config.json`; the binary is the one on PATH, or where `cargo install` puts it.
51
51
  */
52
- const SLUICE_DIR = join(process.env.XDG_CONFIG_HOME || join(homedir(), '.config'), 'sluice')
53
- const SLUICE_RULES = join(SLUICE_DIR, 'spore.rules')
54
- const SLUICE_LIST = join(SLUICE_DIR, 'spore.md')
52
+ export const SLUICE_RULES_DIR = join(CONFIG_DIR, 'sluice')
55
53
  const sluiceBinary = () => (process.env.PATH ?? '').split(':').filter(Boolean).map(dir => join(dir, 'sluice')).find(path => existsSync(path)) ??
56
54
  join(homedir(), '.cargo', 'bin', 'sluice')
57
55
 
58
- const sluiceCheck = (binary) => [
56
+ const sluiceCheck = (binary, rules) => [
59
57
  `[ -x ${quoted(binary)} ] || { echo "no sluice at ${binary} — cargo install sluicify" >&2; exit 1; }`,
60
- `[ -f ${quoted(SLUICE_RULES)} ] || { echo "no ${SLUICE_RULES} — the commands spores may run; the plugin's examples/spore.rules is a start" >&2; exit 1; }`,
61
- `[ -f ${quoted(SLUICE_LIST)} ] || { echo "no ${SLUICE_LIST} — what the agent reads with --list; the plugin's examples/spore.md is a start" >&2; exit 1; }`,
62
- `${quoted(binary)} check ${quoted(SLUICE_RULES)}`
58
+ `${quoted(binary)} serve --help | grep -q -- --rules-dir || { echo "${binary} serves one rules file only — cargo install sluicify for 0.4 or later" >&2; exit 1; }`,
59
+ `[ -d ${quoted(rules)} ] || { echo "no ${rules} — mkdir -m 700 -p ${rules}, then one <spore>.rules per spore; the plugin's examples/spore.rules is a start" >&2; exit 1; }`,
60
+ `${quoted(binary)} check --rules-dir ${quoted(rules)}`
63
61
  ].join('\n')
64
62
 
65
63
  /**
@@ -147,21 +145,19 @@ export const SERVICES = Object.freeze({
147
145
  })
148
146
  },
149
147
  sluice: {
150
- what: 'runs the host commands spores may ask for, as ~/.config/sluice/spore.rules allows',
148
+ what: 'runs the host commands each spore may ask for, as ~/.config/spore/sluice/<spore>.rules allows',
151
149
  primary: 'spore-sluice.service',
152
150
  runs: 'spore-sluice.service',
153
- check: () => ['/bin/sh', ['-c', sluiceCheck(sluiceBinary())]],
154
- next: ({ uid }) => `spore plugin allow sluice socket=/run/user/${uid}/sluice/spore.sock`,
151
+ check: () => ['/bin/sh', ['-c', sluiceCheck(sluiceBinary(), SLUICE_RULES_DIR)]],
152
+ next: ({ uid }) => `spore plugin allow sluice dir=/run/user/${uid}/sluice`,
155
153
  units: () => ({
156
154
  'spore-sluice.service': [
157
155
  '[Unit]',
158
- 'Description=spore sluice: the host commands spores may ask for',
156
+ 'Description=spore sluice: the host commands each spore may ask for',
159
157
  `${MARKER}=sluice`,
160
158
  '',
161
159
  '[Service]',
162
- 'ExecStartPre=/bin/mkdir -p %t/sluice',
163
- `ExecStartPre=/bin/cp ${quoted(SLUICE_LIST)} %t/sluice/spore.md`,
164
- `ExecStart=${quoted(sluiceBinary())} serve --rules ${quoted(SLUICE_RULES)} --socket %t/sluice/spore.sock`,
160
+ `ExecStart=${quoted(sluiceBinary())} serve --rules-dir ${quoted(SLUICE_RULES_DIR)} --socket-dir %t/sluice/spores`,
165
161
  'Restart=on-failure',
166
162
  '',
167
163
  '[Install]',
package/tui/README.md CHANGED
@@ -22,6 +22,10 @@ ctrl+d leave, on an empty line
22
22
  //text a message that starts with /
23
23
  ```
24
24
 
25
+ A tool call's line starts with `✓` when it worked, with the exit code (`1`) when a command ran
26
+ to its end and exited non-zero — which may be its answer, `grep` finding nothing — and with `✗`
27
+ and how when the call failed: `✗ idle`, `✗ deadline`, `✗ SIGKILL`, `✗ refused`.
28
+
25
29
  The line you type on names the spore and its state at its right. The status line under it gives
26
30
  the running turn's limits, the spend and the model. When another spore answers or asks, the
27
31
  status line says so and the terminal gets a notification
@@ -71,7 +71,15 @@ export function applyEvent (live, event) {
71
71
  case 'tool_end': {
72
72
  const tool = live.tools.find(t => t.callId === event.callId)
73
73
  if (!tool) return false
74
- Object.assign(tool, { done: true, durationMs: event.durationMs, error: Boolean(event.error) })
74
+ Object.assign(tool, {
75
+ done: true,
76
+ durationMs: event.durationMs,
77
+ error: Boolean(event.error),
78
+ outcome: event.outcome,
79
+ exit: event.exit,
80
+ killed: event.killed,
81
+ signal: event.signal
82
+ })
75
83
  return true
76
84
  }
77
85
  case 'usage':
@@ -102,3 +110,15 @@ export function applyEvent (live, event) {
102
110
  return false
103
111
  }
104
112
  }
113
+
114
+ /**
115
+ * What a call's line starts with: whether it worked, the exit code of a command that ran to its
116
+ * end and said no, or how it failed. A tool_end a runtime before outcomes recorded has only `error`.
117
+ */
118
+ export function markOf (tool) {
119
+ if (!tool.done) return { text: '…', tone: 'running' }
120
+ if (tool.outcome === undefined) return tool.error ? { text: '✗', tone: 'failed' } : { text: '✓', tone: 'ok' }
121
+ if (tool.outcome === 'ok') return { text: '✓', tone: 'ok' }
122
+ if (tool.outcome === 'exit') return { text: String(tool.exit), tone: 'exit' }
123
+ return { text: `✗ ${tool.killed ?? tool.signal ?? tool.outcome}`, tone: 'failed' }
124
+ }
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, liveOf } from './conversation.js'
12
+ import { applyEvent, createLive, history, liveOf, markOf } 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'
@@ -17,6 +17,7 @@ import { Answer } from './answer.js'
17
17
  import { matching, priceText, sporeLabel, statusParts } from './status.js'
18
18
 
19
19
  const REFRESH_MS = 1000
20
+ const MARK_TONE = { running: chalk.yellow, ok: chalk.green, exit: chalk.yellow, failed: chalk.red }
20
21
  const TWICE_MS = 1500
21
22
  const NOTICE_MS = 4000
22
23
  const LONG_TURN_MS = 60_000
@@ -80,7 +81,8 @@ function changeLines (tool, change, { expanded, width, mark, time }) {
80
81
  }
81
82
 
82
83
  function toolLine (tool, { expanded, width }) {
83
- const mark = !tool.done ? chalk.yellow('…') : tool.error ? chalk.red('✗') : chalk.green('✓')
84
+ const { text, tone } = markOf(tool)
85
+ const mark = MARK_TONE[tone](text)
84
86
  const time = tool.done ? dim(` ${durationText(tool.durationMs)}`) : ''
85
87
  const change = changeOf(tool)
86
88
  if (change) return changeLines(tool, change, { expanded, width, mark, time })