@rhizogrip/spore-cli 1.57.0 → 1.58.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 +2 -1
- package/package.json +3 -3
- package/src/dispatch.js +2 -1
- package/src/doctor.js +2 -1
- package/src/mo.js +34 -0
- package/src/setup.js +6 -3
- package/tui/answer.js +16 -13
- package/tui/index.js +4 -2
- package/tui/links.js +1 -1
package/bin/spore.js
CHANGED
|
@@ -14,6 +14,7 @@ import { basename, resolve } from 'node:path'
|
|
|
14
14
|
|
|
15
15
|
import minimist from 'minimist'
|
|
16
16
|
|
|
17
|
+
import { withMoHint } from '../src/mo.js'
|
|
17
18
|
import { host } from '../src/vm.js'
|
|
18
19
|
|
|
19
20
|
await host(process.argv.slice(2))
|
|
@@ -320,7 +321,7 @@ async function events (ws, after) {
|
|
|
320
321
|
}
|
|
321
322
|
|
|
322
323
|
function fail (problem) {
|
|
323
|
-
console.error(`spore: ${problem}`)
|
|
324
|
+
console.error(`spore: ${withMoHint(problem)}`)
|
|
324
325
|
process.exit(2)
|
|
325
326
|
}
|
|
326
327
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhizogrip/spore-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.58.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Christophe Le Bars",
|
|
6
6
|
"email": "clb@toort.net"
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@clack/prompts": "^1.8.1",
|
|
52
|
-
"@earendil-works/pi-tui": "1.
|
|
52
|
+
"@earendil-works/pi-tui": "1.5.0",
|
|
53
53
|
"chalk": "^6.0.1",
|
|
54
54
|
"minimist": "^1.2.8"
|
|
55
55
|
},
|
|
56
56
|
"optionalDependencies": {
|
|
57
|
-
"@rhizogrip/spore": "1.
|
|
57
|
+
"@rhizogrip/spore": "1.58.0"
|
|
58
58
|
},
|
|
59
59
|
"license": "Apache-2.0"
|
|
60
60
|
}
|
package/src/dispatch.js
CHANGED
|
@@ -16,6 +16,7 @@ import { basename, join, resolve } from 'node:path'
|
|
|
16
16
|
import { addTo, allowPlugin, annotate, billingFor, bytesText, changeText, define, defaultModel, disallowPlugin, durationText, edit, extend, flush, getKey, jobs, list, listApprovals, listPlugins, log, pause, remake, remove, removeFrom, removeSchedule, requestApproval, runningLines, schedules, setDefaultModel, setKey, setSchedule, settings, show, showPlugin, sql, stateWord, stopJob, switchModel, tick, tickReport, unmetered, unpause, upgrade, usage, wrap, CONFIG_FILE, DEFAULT_SPORANGIUM, errorText } from '@rhizogrip/spore'
|
|
17
17
|
import { diagnose, hostReport, renderDoctor, renderReport } from './doctor.js'
|
|
18
18
|
import { hook } from './hooks.js'
|
|
19
|
+
import { withMoHint } from './mo.js'
|
|
19
20
|
import { createServices } from './services.js'
|
|
20
21
|
import { saidBy, saidText } from '../tui/conversation.js'
|
|
21
22
|
|
|
@@ -787,7 +788,7 @@ export async function manage (verb, argv) {
|
|
|
787
788
|
if (verb === 'ls') return emit(list({ where: argv._[1], disk: true }), renderList, listExit)
|
|
788
789
|
if (verb === 'show') return emit(show({ ws: argv._[1] }), renderShow)
|
|
789
790
|
} catch (err) {
|
|
790
|
-
console.error(`spore: ${errorText(err)}`)
|
|
791
|
+
console.error(`spore: ${withMoHint(errorText(err))}`)
|
|
791
792
|
return 2
|
|
792
793
|
}
|
|
793
794
|
}
|
package/src/doctor.js
CHANGED
|
@@ -4,6 +4,7 @@ import { getSystemErrorName } from 'node:util'
|
|
|
4
4
|
|
|
5
5
|
import { boundary, describeHost, doctor, loadMohdelEnvironment, modelFindings } from '@rhizogrip/spore'
|
|
6
6
|
|
|
7
|
+
import { withMoHint } from './mo.js'
|
|
7
8
|
import { createServices } from './services.js'
|
|
8
9
|
|
|
9
10
|
const AREAS = ['operator', 'spores', 'models', 'plugins', 'services', 'machine']
|
|
@@ -116,7 +117,7 @@ export function renderDoctor ({ findings, boundary }) {
|
|
|
116
117
|
console.log(area)
|
|
117
118
|
for (const found of here) {
|
|
118
119
|
console.log(` ${found.severity === 'note' ? 'note: ' : ''}${found.subject} — ${found.problem}`)
|
|
119
|
-
if (found.fix) console.log(found.fix.split('\n').map(line => ` ${line}`).join('\n'))
|
|
120
|
+
if (found.fix) console.log(withMoHint(found.fix).split('\n').map(line => ` ${line}`).join('\n'))
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
if (boundary.length) {
|
package/src/mo.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mo` comes inside spore for spore's own use, and npm does not put it on PATH. A message naming a
|
|
3
|
+
* `mo` command says how to install it where it is missing, at the mohdel spore pins, since the two
|
|
4
|
+
* share one catalog.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { accessSync, constants, statSync } from 'node:fs'
|
|
8
|
+
import { createRequire } from 'node:module'
|
|
9
|
+
import { delimiter, join } from 'node:path'
|
|
10
|
+
|
|
11
|
+
const MO_COMMAND = /(?:^|[\s"'`(])mo (?:chatgpt|curate|ls|model|onboard|providers)\b/
|
|
12
|
+
|
|
13
|
+
function runnable (path) {
|
|
14
|
+
try {
|
|
15
|
+
accessSync(path, constants.X_OK)
|
|
16
|
+
return statSync(path).isFile()
|
|
17
|
+
} catch {
|
|
18
|
+
return false
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const moOnPath = () => (process.env.PATH ?? '').split(delimiter).some(dir => runnable(join(dir, 'mo')))
|
|
23
|
+
|
|
24
|
+
/** What to install, when `text` names a `mo` command and `mo` is not on PATH; null otherwise. */
|
|
25
|
+
export function moHint (text) {
|
|
26
|
+
if (!MO_COMMAND.test(text) || moOnPath()) return null
|
|
27
|
+
const { mohdel } = createRequire(import.meta.url)('@rhizogrip/spore/package.json').dependencies
|
|
28
|
+
return `mo is a separate install: npm install -g mohdel@${mohdel}`
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function withMoHint (text) {
|
|
32
|
+
const hint = moHint(text)
|
|
33
|
+
return hint ? `${text} — ${hint}` : text
|
|
34
|
+
}
|
package/src/setup.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
|
|
17
17
|
import { createServices } from './services.js'
|
|
18
18
|
import { diagnose, renderDoctor } from './doctor.js'
|
|
19
|
+
import { moHint, withMoHint } from './mo.js'
|
|
19
20
|
|
|
20
21
|
const EXPERT = 'expert'
|
|
21
22
|
const ANOTHER_MODEL = 'another model'
|
|
@@ -29,7 +30,7 @@ const providerOf = (model) => model.split('/')[0]
|
|
|
29
30
|
|
|
30
31
|
const SHOWN = 20
|
|
31
32
|
|
|
32
|
-
const line = (label, text) => log.step(`${label.padEnd(10)}${text}`)
|
|
33
|
+
const line = (label, text) => log.step(`${label.padEnd(10)}${withMoHint(text)}`)
|
|
33
34
|
|
|
34
35
|
/** A pick from a list that words narrow, each matched in the label or the description; null when left. */
|
|
35
36
|
export async function pickFromList ({ title, header = [], items }) {
|
|
@@ -171,11 +172,13 @@ export async function setup () {
|
|
|
171
172
|
|
|
172
173
|
/** Where another model comes from, and how a spore is given it: said, never done, by setup. */
|
|
173
174
|
function otherModels (provider) {
|
|
174
|
-
|
|
175
|
+
const lines = [
|
|
175
176
|
'another model: spore setup model offers the recommended ones, from any provider —',
|
|
176
177
|
`or /curate in spore tui, or mo curate ${provider}, adds any other ${provider} model,`,
|
|
177
178
|
'then spore config set model <provider>/<name> for new spores, or spore edit <spore> and add it to models:'
|
|
178
|
-
]
|
|
179
|
+
]
|
|
180
|
+
const hint = moHint(lines.join('\n'))
|
|
181
|
+
log.message(hint ? [...lines, hint] : lines)
|
|
179
182
|
}
|
|
180
183
|
|
|
181
184
|
/** One line when the model set is not among those mohdex recommends. Nothing here stops setup. */
|
package/tui/answer.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Markdown } from '@earendil-works/pi-tui'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* An answer as pi-tui draws it, keeping the code blocks it drew: `
|
|
4
|
+
* An answer as pi-tui draws it, keeping the code blocks it drew: `codeBlocks` is each one's text
|
|
5
5
|
* exactly as written, in the order shown. Labelled, each opening fence says how to copy it.
|
|
6
|
+
* It reads them line by line through `codeBlock` because pi-tui remembers what `highlightCode`
|
|
7
|
+
* returned, so that hook is not called again on a later pass.
|
|
6
8
|
*/
|
|
7
9
|
export class Answer extends Markdown {
|
|
8
10
|
constructor (text, theme, { labelled = false } = {}) {
|
|
@@ -10,12 +12,12 @@ export class Answer extends Markdown {
|
|
|
10
12
|
this.theme = {
|
|
11
13
|
...theme,
|
|
12
14
|
codeBlockBorder: (fence) => this.fence(fence),
|
|
13
|
-
|
|
15
|
+
codeBlock: (line) => this.codeLine(line)
|
|
14
16
|
}
|
|
15
17
|
this.base = theme
|
|
16
18
|
this.labelled = labelled
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
+
this.codeBlocks = []
|
|
20
|
+
this.opened = null
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
label (on) {
|
|
@@ -26,23 +28,24 @@ export class Answer extends Markdown {
|
|
|
26
28
|
|
|
27
29
|
render (width) {
|
|
28
30
|
if (this.cachedText !== this.text || this.cachedWidth !== width) {
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
+
this.codeBlocks = []
|
|
32
|
+
this.opened = null
|
|
31
33
|
}
|
|
32
34
|
return super.render(width)
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
fence (fence) {
|
|
36
|
-
if (this.
|
|
37
|
-
this.
|
|
38
|
+
if (this.opened) {
|
|
39
|
+
this.codeBlocks.push({ lang: this.opened.lang, text: this.opened.lines.join('\n') })
|
|
40
|
+
this.opened = null
|
|
38
41
|
return this.base.codeBlockBorder(fence)
|
|
39
42
|
}
|
|
40
|
-
this.
|
|
41
|
-
return this.base.codeBlockBorder(this.labelled ? `${fence} · /copy ${this.
|
|
43
|
+
this.opened = { lang: fence.replace(/^`+/, ''), lines: [] }
|
|
44
|
+
return this.base.codeBlockBorder(this.labelled ? `${fence} · /copy ${this.codeBlocks.length + 1}` : fence)
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
this.
|
|
46
|
-
return
|
|
47
|
+
codeLine (line) {
|
|
48
|
+
this.opened.lines.push(line)
|
|
49
|
+
return this.base.codeBlock(line)
|
|
47
50
|
}
|
|
48
51
|
}
|
package/tui/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { applyEvent, changeText, createLive, curate, durationText, errorText, ex
|
|
|
8
8
|
import chalk from 'chalk'
|
|
9
9
|
|
|
10
10
|
import { runningJob, scheduleLine } from '../src/dispatch.js'
|
|
11
|
+
import { withMoHint } from '../src/mo.js'
|
|
11
12
|
import { COMMANDS, parseCommand } from './commands.js'
|
|
12
13
|
import { history, markOf } from './conversation.js'
|
|
13
14
|
import { changeOf, counts, hunks } from './diff.js'
|
|
@@ -114,7 +115,7 @@ class Conversation {
|
|
|
114
115
|
/** The code blocks of the last answer, numbered on screen from 1. */
|
|
115
116
|
lastBlocks () {
|
|
116
117
|
const last = this.lastAnswer()
|
|
117
|
-
return last ? this.markdown(last).
|
|
118
|
+
return last ? this.markdown(last).codeBlocks : []
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
render (width) {
|
|
@@ -319,7 +320,8 @@ export async function runTui ({ ws, commands = [], renderTool = null, greeting =
|
|
|
319
320
|
const state = { ws: null, grant: null, limits: null, shown: null, attention: new Map(), lastSeq: 0, overlay: null, pressed: {} }
|
|
320
321
|
let finish
|
|
321
322
|
|
|
322
|
-
const notice = (
|
|
323
|
+
const notice = (message) => {
|
|
324
|
+
const text = withMoHint(message)
|
|
323
325
|
status.notice = text
|
|
324
326
|
clearTimeout(state.noticeTimer)
|
|
325
327
|
state.noticeTimer = setTimeout(() => { status.notice = ''; tui.requestRender() }, Math.max(NOTICE_MS, text.length * 60))
|
package/tui/links.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `· /copy <n>` label on a code block's opening fence, made a link. It is drawn as an OSC 8
|
|
3
|
-
* hyperlink
|
|
3
|
+
* hyperlink, so a click on it reaches pi-tui's `openUrl` with a
|
|
4
4
|
* URL this module reads back into the number of the block to copy. The label's own look is
|
|
5
5
|
* unchanged, and the link adds no width to the line.
|
|
6
6
|
*/
|