@rhizogrip/spore-cli 1.49.3 → 1.49.4
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/src/setup.js +9 -8
- package/src/vm.js +16 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhizogrip/spore-cli",
|
|
3
|
-
"version": "1.49.
|
|
3
|
+
"version": "1.49.4",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Christophe Le Bars",
|
|
6
6
|
"email": "clb@toort.net"
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"minimist": "^1.2.8"
|
|
55
55
|
},
|
|
56
56
|
"optionalDependencies": {
|
|
57
|
-
"@rhizogrip/spore": "1.49.
|
|
57
|
+
"@rhizogrip/spore": "1.49.4"
|
|
58
58
|
},
|
|
59
59
|
"license": "Apache-2.0"
|
|
60
60
|
}
|
package/src/setup.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { spawnSync } from 'node:child_process'
|
|
7
7
|
import { basename } from 'node:path'
|
|
8
8
|
|
|
9
|
-
import { autocomplete, cancel, confirm,
|
|
9
|
+
import { autocomplete, cancel, confirm, isCancel, log, note, outro, text } from '@clack/prompts'
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
12
|
checkSqlite, CONFIG_FILE, defaultModel, define, doctor, list, loadMohdelEnvironment, MO,
|
|
@@ -32,8 +32,9 @@ const line = (label, text) => log.step(`${label.padEnd(10)}${text}`)
|
|
|
32
32
|
|
|
33
33
|
/** A pick from a list that words narrow, each matched in the label or the description; null when left. */
|
|
34
34
|
export async function pickFromList ({ title, header = [], items }) {
|
|
35
|
+
if (header.length) log.message(header.join('\n'))
|
|
35
36
|
const picked = await autocomplete({
|
|
36
|
-
message:
|
|
37
|
+
message: title,
|
|
37
38
|
options: items.map(({ value, label, description }) => ({ value, label, hint: description })),
|
|
38
39
|
maxItems: SHOWN,
|
|
39
40
|
filter: (search, option) => search.toLowerCase().split(/\s+/).every(word => `${option.label} ${option.hint ?? ''}`.toLowerCase().includes(word))
|
|
@@ -58,7 +59,7 @@ async function yes (message) {
|
|
|
58
59
|
return answer
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
export const onboardWithMo = (provider) => spawnSync(process.execPath, [MO, 'onboard', ...(provider ? [provider] : [])], { stdio: 'inherit' }).status
|
|
62
|
+
export const onboardWithMo = (provider) => spawnSync(process.execPath, [MO, 'onboard', ...(provider ? [provider] : []), '--caller', 'spore'], { stdio: 'inherit' }).status
|
|
62
63
|
|
|
63
64
|
const billingText = ({ billing, priced }) => billing === 'plan'
|
|
64
65
|
? 'your plan — not metered'
|
|
@@ -70,7 +71,6 @@ const billingText = ({ billing, priced }) => billing === 'plan'
|
|
|
70
71
|
*/
|
|
71
72
|
export async function setup () {
|
|
72
73
|
const services = createServices()
|
|
73
|
-
intro('spore setup')
|
|
74
74
|
|
|
75
75
|
line('node', `${process.version}, SQLite ${checkSqlite()}`)
|
|
76
76
|
|
|
@@ -98,14 +98,15 @@ export async function setup () {
|
|
|
98
98
|
} else if (processes) {
|
|
99
99
|
line('processes', processes.problem)
|
|
100
100
|
} else {
|
|
101
|
-
line('
|
|
101
|
+
line('sandbox', 'ready — each turn sees only the files it is given, and none of your other programs')
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
const { home } = readConfig()
|
|
105
105
|
if (home) {
|
|
106
106
|
line('home', home)
|
|
107
107
|
} else {
|
|
108
|
-
|
|
108
|
+
log.message('each spore is a directory of its own: what it is told to be, what was said to it, a record of\neverything it ran, and the files it works on')
|
|
109
|
+
const dir = await ask('which directory should hold your spores?', '~/.spore')
|
|
109
110
|
setKey('home', dir)
|
|
110
111
|
line('home', `${readConfig().home} — spore config set home <dir> moves where new ones are made`)
|
|
111
112
|
}
|
|
@@ -176,7 +177,7 @@ async function chooseModel () {
|
|
|
176
177
|
return current
|
|
177
178
|
}
|
|
178
179
|
|
|
179
|
-
const provider = await pickFromList({ title: '
|
|
180
|
+
const provider = await pickFromList({ title: 'which provider should they come from?', header: ['mohdel calls the models your spores run on — a provider set up here is set up for mo as well'], items: PROVIDERS })
|
|
180
181
|
if (!provider) return null
|
|
181
182
|
if (provider === ANOTHER) {
|
|
182
183
|
onboardWithMo(null)
|
|
@@ -204,7 +205,7 @@ async function chooseModel () {
|
|
|
204
205
|
}
|
|
205
206
|
const model = await pickFromList({
|
|
206
207
|
title: 'the model new spores run on',
|
|
207
|
-
header: ['spore model <name> <model> changes one spore
|
|
208
|
+
header: ['later, spore model <name> <model> changes the model of one spore'],
|
|
208
209
|
items: usable.map(one => ({ value: one.model, label: one.model, description: billingText(one) }))
|
|
209
210
|
})
|
|
210
211
|
if (!model) return null
|
package/src/vm.js
CHANGED
|
@@ -10,7 +10,7 @@ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from '
|
|
|
10
10
|
import { constants, homedir } from 'node:os'
|
|
11
11
|
import { join } from 'node:path'
|
|
12
12
|
|
|
13
|
-
import { cancel, isCancel, select } from '@clack/prompts'
|
|
13
|
+
import { cancel, intro, isCancel, select } from '@clack/prompts'
|
|
14
14
|
|
|
15
15
|
// The core's CONFIG_DIR, which this cannot import.
|
|
16
16
|
const CONFIG_DIR = process.env.XDG_CONFIG_HOME ? join(process.env.XDG_CONFIG_HOME, 'spore') : join(homedir(), '.config', 'spore')
|
|
@@ -117,9 +117,22 @@ function vmVerb (vm, args) {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/** Whether `spore setup` makes a vm: where the core is not installed, or on a first run that chose one. */
|
|
120
|
+
/**
|
|
121
|
+
* Whether this machine is itself a vm or a container — WSL, spore's own Lima guest, a cloud server —
|
|
122
|
+
* by `systemd-detect-virt`, which exits 0 inside one. Lima inside one is no choice to offer. A
|
|
123
|
+
* machine without the program cannot say, and is asked.
|
|
124
|
+
*/
|
|
125
|
+
function virtualized () {
|
|
126
|
+
const ran = spawnSync('systemd-detect-virt', ['--quiet'])
|
|
127
|
+
if (ran.error?.code === 'ENOENT') return false
|
|
128
|
+
if (ran.error) throw ran.error
|
|
129
|
+
return ran.status === 0
|
|
130
|
+
}
|
|
131
|
+
|
|
120
132
|
async function wantsVm () {
|
|
121
133
|
if (!hasCore()) return true
|
|
122
134
|
if (existsSync(join(CONFIG_DIR, 'config.json')) || !process.stdin.isTTY || !process.stdout.isTTY) return false
|
|
135
|
+
if (virtualized()) return false
|
|
123
136
|
const where = await select({
|
|
124
137
|
message: 'where should spore run?',
|
|
125
138
|
options: [
|
|
@@ -141,7 +154,7 @@ async function wantsVm () {
|
|
|
141
154
|
* this machine never holds a key.
|
|
142
155
|
*/
|
|
143
156
|
function setupVm (named) {
|
|
144
|
-
if (process.platform === 'win32') fail('on Windows spore runs in WSL, which spore setup does not prepare
|
|
157
|
+
if (process.platform === 'win32') fail('on Windows spore runs in WSL 2, which spore setup does not prepare — wsl --install, then in it install Node 24 and @rhizogrip/spore-cli and run spore setup there')
|
|
145
158
|
if (!process.stdin.isTTY || !process.stdout.isTTY) fail('setup asks questions, and this is not a terminal')
|
|
146
159
|
const vm = named ?? NAME
|
|
147
160
|
const status = statusOf(vm, { missing: `spore runs in a Linux vm made with Lima — install it, ${INSTALL_LIMA}, then spore setup again` })
|
|
@@ -161,6 +174,7 @@ export async function host (args) {
|
|
|
161
174
|
const [verb] = args
|
|
162
175
|
const vm = vmNamed()
|
|
163
176
|
if (verb === 'vm') vmVerb(vm, args)
|
|
177
|
+
if (verb === 'setup' && !vm && process.stdin.isTTY && process.stdout.isTTY) intro('spore setup')
|
|
164
178
|
if (verb === 'setup' && (vm || await wantsVm())) setupVm(vm)
|
|
165
179
|
if (vm) {
|
|
166
180
|
running(vm)
|