@rhizogrip/spore-cli 1.39.0 → 1.41.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/README.md CHANGED
@@ -10,10 +10,8 @@ npm install -g @rhizogrip/spore-cli
10
10
  spore # what each command does
11
11
  ```
12
12
 
13
- The terminal screen (`spore tui`, `spore here`) is an optional dependency: `--omit=optional` leaves it
14
- out, for a server, and the other commands work without it.
15
-
16
- Linux x64 or arm64, Node 24 or newer. How spore works, what a spore is and every command:
13
+ Linux x64 or arm64, Node 24 or newer; on macOS, `spore setup` runs spore in a Linux VM it makes
14
+ with Lima. How spore works, what a spore is and every command:
17
15
  [the spore README](https://github.com/RHIZOGRIP/spore/blob/main/packages/spore/README.md).
18
16
 
19
17
  ## License
package/bin/spore.js CHANGED
@@ -14,9 +14,13 @@ import { basename, resolve } from 'node:path'
14
14
 
15
15
  import minimist from 'minimist'
16
16
 
17
- import { differingDocs, fork, follow, followingDocs, grantOf, isWorkspace, lastEventSeq, loadEnvironment, mimeOf, readConfig, readInbox, RUNNING, send, stateOf, stop, turnOfMessage, turnSummary, watch, workspaceFor, errorText } from '@rhizogrip/spore'
18
- import { renderHeader } from '../src/dispatch.js'
19
- import { SERVICES } from '../src/services.js'
17
+ import { host } from '../src/vm.js'
18
+
19
+ await host(process.argv.slice(2))
20
+
21
+ const { differingDocs, fork, follow, followingDocs, grantOf, isWorkspace, lastEventSeq, loadEnvironment, mimeOf, readConfig, readInbox, RUNNING, send, stateOf, stop, turnOfMessage, turnSummary, watch, workspaceFor, errorText } = await import('@rhizogrip/spore')
22
+ const { renderHeader } = await import('../src/dispatch.js')
23
+ const { SERVICES } = await import('../src/services.js')
20
24
 
21
25
  // Detaching is neither success nor failure: the turn is still going, and 0 would claim it
22
26
  // answered. `spore show` says what actually happened once it has.
@@ -32,6 +36,7 @@ const argv = minimist(process.argv.slice(2), {
32
36
 
33
37
  const VERBS = `Usage:
34
38
  spore setup the first run: this machine, your models, a first spore
39
+ spore vm start|stop the Linux vm spore runs in, where spore setup made one
35
40
  spore define <name> say what a spore is; . for here
36
41
  spore define <name> --model <m> --plugin <p> the same, with its model and plugins filled in
37
42
  spore define <new> --from <name> the same, cut from one that has learned
@@ -179,7 +184,8 @@ const SHAPES = {
179
184
  hook: { bare: 'ls', subs: { ls: withJson(0), show: withJson(1) } },
180
185
  tui: { flags: [], most: 1 },
181
186
  here: { flags: ['sporangium', 'model', 'no-git'], most: 1 },
182
- setup: { flags: [], most: 0 }
187
+ setup: { flags: [], most: 0 },
188
+ vm: { subs: { start: { flags: [], most: 0 }, stop: { flags: [], most: 0 } } }
183
189
  }
184
190
  const verb = argv._[0]
185
191
 
@@ -245,7 +251,7 @@ try {
245
251
  }
246
252
 
247
253
  if (verb === 'tui') {
248
- const { mostRecentSpore, rememberedSpore, runTui } = await screen('../tui/index.js')
254
+ const { mostRecentSpore, rememberedSpore, runTui } = await import('../tui/index.js')
249
255
  const remembered = rememberedSpore()
250
256
  const ws = argv._[1] ? spore(argv._[1]) : remembered && isWorkspace(remembered) ? remembered : mostRecentSpore()
251
257
  if (!ws) fail('no spore yet — spore define <name>')
@@ -267,7 +273,7 @@ if (verb === 'setup') {
267
273
  }
268
274
 
269
275
  if (verb === 'here') {
270
- const { here } = await screen('../tui/here.js')
276
+ const { here } = await import('../tui/here.js')
271
277
  try {
272
278
  process.exit(await here({ dir: argv._[1], sporangium: argv.sporangium, model: argv.model, git: argv.git !== false }))
273
279
  } catch (err) {
@@ -308,18 +314,6 @@ async function events (ws, after) {
308
314
  return leaving.signal.aborted
309
315
  }
310
316
 
311
- /** The terminal screen, which an install made with --omit=optional leaves out. */
312
- async function screen (path) {
313
- try {
314
- return await import(path)
315
- } catch (err) {
316
- if (err.code === 'ERR_MODULE_NOT_FOUND' && err.message.includes('@earendil-works/pi-tui')) {
317
- fail(`${verb} opens the terminal screen, which this install left out — npm install -g @rhizogrip/spore-cli without --omit=optional adds it`)
318
- }
319
- throw err
320
- }
321
- }
322
-
323
317
  function fail (problem) {
324
318
  console.error(`spore: ${problem}`)
325
319
  process.exit(2)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhizogrip/spore-cli",
3
- "version": "1.39.0",
3
+ "version": "1.41.0",
4
4
  "author": {
5
5
  "name": "Christophe Le Bars",
6
6
  "email": "clb@toort.net"
@@ -28,9 +28,6 @@
28
28
  "engines": {
29
29
  "node": ">=24"
30
30
  },
31
- "os": [
32
- "linux"
33
- ],
34
31
  "cpu": [
35
32
  "x64",
36
33
  "arm64"
@@ -51,12 +48,13 @@
51
48
  "tui": "node bin/spore.js tui"
52
49
  },
53
50
  "dependencies": {
54
- "@rhizogrip/spore": "1.39.0",
51
+ "@clack/prompts": "^1.8.1",
52
+ "@earendil-works/pi-tui": "1.2.0",
55
53
  "chalk": "^6.0.1",
56
54
  "minimist": "^1.2.8"
57
55
  },
58
56
  "optionalDependencies": {
59
- "@earendil-works/pi-tui": "1.2.0"
57
+ "@rhizogrip/spore": "1.41.0"
60
58
  },
61
59
  "license": "Apache-2.0"
62
60
  }
package/src/setup.js CHANGED
@@ -5,7 +5,8 @@
5
5
 
6
6
  import { spawnSync } from 'node:child_process'
7
7
  import { basename } from 'node:path'
8
- import { createInterface } from 'node:readline/promises'
8
+
9
+ import { autocomplete, cancel, confirm, intro, isCancel, log, note, outro, text } from '@clack/prompts'
9
10
 
10
11
  import {
11
12
  checkSqlite, CONFIG_FILE, defaultModel, define, doctor, list, loadMohdelEnvironment, MO,
@@ -27,43 +28,34 @@ const providerOf = (model) => model.split('/')[0]
27
28
 
28
29
  const SHOWN = 20
29
30
 
30
- /**
31
- * A pick from a numbered list on the plain terminal, so setup runs where the screen is not installed:
32
- * a number picks, words narrow the list, empty leaves it. The value picked, or null when left.
33
- */
31
+ const line = (label, text) => log.step(`${label.padEnd(10)}${text}`)
32
+
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
- const say = console.log
36
- say('')
37
- say(title)
38
- for (const line of header) say(` ${line}`)
39
- let shown = items
40
- while (true) {
41
- const width = String(Math.min(shown.length, SHOWN)).length
42
- shown.slice(0, SHOWN).forEach((item, i) => say(` ${String(i + 1).padStart(width)} ${item.label}${item.description ? ` — ${item.description}` : ''}`))
43
- if (shown.length > SHOWN) say(` … and ${shown.length - SHOWN} more — words narrow the list`)
44
- const answer = await ask('a number, or words to narrow the list — empty to leave:')
45
- if (!answer) return null
46
- if (/^\d+$/.test(answer)) {
47
- const chosen = shown.slice(0, SHOWN)[Number(answer) - 1]
48
- if (chosen) return chosen.value
49
- say(` ${answer} is not in the list`)
50
- continue
51
- }
52
- const words = answer.toLowerCase().split(/\s+/)
53
- const narrowed = items.filter(item => words.every(word => `${item.label} ${item.description ?? ''}`.toLowerCase().includes(word)))
54
- if (narrowed.length) shown = narrowed
55
- else say(` nothing matches ${answer}`)
56
- }
35
+ const picked = await autocomplete({
36
+ message: [title, ...header].join('\n'),
37
+ options: items.map(({ value, label, description }) => ({ value, label, hint: description })),
38
+ maxItems: SHOWN,
39
+ filter: (search, option) => search.toLowerCase().split(/\s+/).every(word => `${option.label} ${option.hint ?? ''}`.toLowerCase().includes(word))
40
+ })
41
+ return isCancel(picked) ? null : picked
57
42
  }
58
43
 
59
- export async function ask (question, preset = '') {
60
- const prompt = createInterface({ input: process.stdin, output: process.stdout })
61
- prompt.on('SIGINT', () => process.exit(130))
62
- try {
63
- return (await prompt.question(preset ? `${question} [${preset}] ` : `${question} `)).trim() || preset
64
- } finally {
65
- prompt.close()
66
- }
44
+ function left () {
45
+ cancel('left — spore setup again carries on from here')
46
+ process.exit(130)
47
+ }
48
+
49
+ async function ask (message, defaultValue) {
50
+ const answer = await text({ message, placeholder: defaultValue, defaultValue })
51
+ if (isCancel(answer)) left()
52
+ return answer.trim()
53
+ }
54
+
55
+ async function yes (message) {
56
+ const answer = await confirm({ message, initialValue: false })
57
+ if (isCancel(answer)) left()
58
+ return answer
67
59
  }
68
60
 
69
61
  export const onboardWithMo = (provider) => spawnSync(process.execPath, [MO, 'onboard', ...(provider ? [provider] : [])], { stdio: 'inherit' }).status
@@ -77,10 +69,8 @@ const billingText = ({ billing, priced }) => billing === 'plan'
77
69
  * before running it again.
78
70
  */
79
71
  export async function setup () {
80
- const say = console.log
81
72
  const services = createServices()
82
- const yes = async (question) => /^y(es)?$/i.test(await ask(`${question} [y/N]`))
83
- const line = (label, text) => say(`${label.padEnd(10)}${text}`)
73
+ intro('spore setup')
84
74
 
85
75
  line('node', `${process.version}, SQLite ${checkSqlite()}`)
86
76
 
@@ -98,9 +88,9 @@ export async function setup () {
98
88
  const processes = machine.find(one => one.subject === 'processes')
99
89
  if (processes?.severity === 'problem') {
100
90
  line('processes', processes.problem)
101
- say(`${''.padEnd(10)}without them, a turn sees the processes and command lines of every other spore of yours —\n${''.padEnd(10)}which matters only when spores of other people run as this user`)
91
+ log.message('without them, a turn sees the processes and command lines of every other spore of yours —\nwhich matters only when spores of other people run as this user')
102
92
  if (!await yes('run your spores uncontained?')) {
103
- say(`${''.padEnd(10)}${processes.fix}, then spore setup again`)
93
+ log.warn(`${processes.fix}, then spore setup again`)
104
94
  return 1
105
95
  }
106
96
  setKey('contain', 'off')
@@ -120,18 +110,16 @@ export async function setup () {
120
110
  line('home', `${readConfig().home} — spore config set home <dir> moves where new ones are made`)
121
111
  }
122
112
 
123
- const model = await chooseModel({ line, say })
113
+ const model = await chooseModel()
124
114
  if (model === null) return 1
125
115
 
126
- await tickTimer({ line, yes, services })
116
+ await tickTimer({ services })
127
117
 
128
- say('')
129
118
  const diagnosed = await diagnose({ services })
130
119
  if (diagnosed.findings.length) renderDoctor(diagnosed)
131
120
  else line('checked', 'this machine, your config and your spores — nothing to fix')
132
- say('')
133
121
  if (diagnosed.findings.some(one => one.severity === 'problem')) {
134
- say('fix those, then spore setup again — spore doctor checks just that part')
122
+ log.warn('fix those, then spore setup again — spore doctor checks just that part')
135
123
  return 1
136
124
  }
137
125
 
@@ -144,26 +132,26 @@ export async function setup () {
144
132
  line('made', `main, your first spore, in ${made.ws}`)
145
133
  }
146
134
  const first = names.includes('main') ? 'main' : names[0]
147
- say('')
148
- say('next')
149
- for (const [command, what] of [
135
+ note([
150
136
  [`spore tui ${first}`, `talk to ${first} in a terminal screen`],
151
137
  [`spore send ${first} "…"`, 'or send it one message; the answer is printed'],
152
138
  ['cd <project> && spore here', 'a spore that works on that project\'s files — git undoes what it changes'],
153
139
  ['spore', 'every command']
154
- ]) say(` ${command.padEnd(30)}${what}`)
140
+ ].map(([command, what]) => `${command.padEnd(30)}${what}`).join('\n'), 'next')
141
+ outro('spore setup again checks all of this')
155
142
  return 0
156
143
  }
157
144
 
158
145
  /** Where another model comes from, and how a spore is given it: said, never done, by setup. */
159
- function otherModels (say, provider) {
160
- const pad = ''.padEnd(10)
161
- say(`${pad}another model: /curate in spore tui, or mo curate ${provider}, adds it to your catalog —`)
162
- say(`${pad}then spore config set model <provider>/<name> for new spores, or spore edit <spore> and add it to models:`)
146
+ function otherModels (provider) {
147
+ log.message([
148
+ `another model: /curate in spore tui, or mo curate ${provider}, adds it to your catalog —`,
149
+ 'then spore config set model <provider>/<name> for new spores, or spore edit <spore> and add it to models:'
150
+ ])
163
151
  }
164
152
 
165
153
  /** The default model, ready to run: the one set, or a provider set up through mohdel and one of its models picked. Null stops setup. */
166
- async function chooseModel ({ line, say }) {
154
+ async function chooseModel () {
167
155
  loadMohdelEnvironment()
168
156
  const current = defaultModel().model
169
157
  if (current) {
@@ -179,7 +167,7 @@ async function chooseModel ({ line, say }) {
179
167
  }
180
168
  }
181
169
  line('model', `${current}, ${ready.priced === false ? `${billingText(ready)} — ${ready.fix}` : 'ready'}`)
182
- otherModels(say, providerOf(current))
170
+ otherModels(providerOf(current))
183
171
  return current
184
172
  }
185
173
 
@@ -218,12 +206,12 @@ async function chooseModel ({ line, say }) {
218
206
  const chosen = usable.find(one => one.model === model)
219
207
  setDefaultModel(model)
220
208
  line('model', `${model}, ${chosen.priced === false ? `${billingText(chosen)} — mo model instructions ${providerOf(model)} fills them` : 'ready'}`)
221
- say(`${''.padEnd(10)}new spores run on it`)
222
- otherModels(say, providerOf(model))
209
+ log.message('new spores run on it')
210
+ otherModels(providerOf(model))
223
211
  return model
224
212
  }
225
213
 
226
- async function tickTimer ({ line, yes, services }) {
214
+ async function tickTimer ({ services }) {
227
215
  let tick
228
216
  try {
229
217
  tick = services.show('tick')
@@ -0,0 +1,30 @@
1
+ #!/bin/sh
2
+ # Brings a Debian vm to what spore needs: its packages, the Node the host runs, and the host's
3
+ # spore-cli. Each step looks first, so a second run changes nothing.
4
+ # vm-prepare.sh <node version, as v24.11.1> <spore-cli version>
5
+ set -eu
6
+ node_version=$1
7
+ spore_version=$2
8
+
9
+ missing=
10
+ for package in curl xz-utils git kitty-terminfo; do
11
+ dpkg -s "$package" >/dev/null 2>&1 || missing="$missing $package"
12
+ done
13
+ if [ -n "$missing" ]; then
14
+ sudo apt-get update -q
15
+ sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq $missing
16
+ fi
17
+
18
+ if [ "$(node --version 2>/dev/null || true)" != "$node_version" ]; then
19
+ case $(uname -m) in
20
+ aarch64) arch=arm64 ;;
21
+ x86_64) arch=x64 ;;
22
+ *) echo "no Node build for $(uname -m)" >&2; exit 1 ;;
23
+ esac
24
+ curl -fsSL "https://nodejs.org/dist/$node_version/node-$node_version-linux-$arch.tar.xz" |
25
+ sudo tar -xJ -C /usr/local --strip-components=1 --exclude=CHANGELOG.md --exclude=README.md --exclude=LICENSE
26
+ fi
27
+
28
+ if [ "$(spore --version 2>/dev/null || true)" != "$spore_version" ]; then
29
+ sudo npm install -g "@rhizogrip/spore-cli@$spore_version"
30
+ fi
package/src/vm.js ADDED
@@ -0,0 +1,170 @@
1
+ /**
2
+ * spore in a Linux vm: always on macOS and Windows, where the core does not install, and by choice
3
+ * on Linux. `vm.json` beside `config.json` names the vm, and then every command but `setup` and
4
+ * `vm` runs in it, through `limactl shell`. Nothing here loads the core, which a machine running
5
+ * spore in a vm may not have.
6
+ */
7
+
8
+ import { spawnSync } from 'node:child_process'
9
+ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
10
+ import { constants, homedir } from 'node:os'
11
+ import { join } from 'node:path'
12
+
13
+ import { cancel, isCancel, select } from '@clack/prompts'
14
+
15
+ // The core's CONFIG_DIR, which this cannot import.
16
+ const CONFIG_DIR = process.env.XDG_CONFIG_HOME ? join(process.env.XDG_CONFIG_HOME, 'spore') : join(homedir(), '.config', 'spore')
17
+ const VM_FILE = join(CONFIG_DIR, 'vm.json')
18
+ const NAME = 'spore'
19
+ const TEMPLATE = 'template:debian-13'
20
+ const INSTALL_LIMA = 'https://lima-vm.io/docs/installation/'
21
+ const VERSION = JSON.parse(readFileSync(join(import.meta.dirname, '../package.json'), 'utf8')).version
22
+ const PREPARE = readFileSync(join(import.meta.dirname, 'vm-prepare.sh'), 'utf8')
23
+
24
+ function fail (problem) {
25
+ console.error(`spore: ${problem}`)
26
+ process.exit(2)
27
+ }
28
+
29
+ function hasCore () {
30
+ try {
31
+ import.meta.resolve('@rhizogrip/spore')
32
+ return true
33
+ } catch (err) {
34
+ if (err.code === 'ERR_MODULE_NOT_FOUND') return false
35
+ throw err
36
+ }
37
+ }
38
+
39
+ const noCore = () => process.platform === 'linux'
40
+ ? 'this install has no @rhizogrip/spore, which runs spore on this machine — it is built for x64 and arm64 and left out by ' +
41
+ '--omit=optional; npm install -g @rhizogrip/spore-cli adds it, or spore setup runs spore in a vm'
42
+ : 'spore runs in a Linux vm on this machine — run spore setup'
43
+
44
+ function vmNamed () {
45
+ if (!existsSync(VM_FILE)) return null
46
+ let named
47
+ try {
48
+ named = JSON.parse(readFileSync(VM_FILE, 'utf8'))
49
+ } catch (err) {
50
+ fail(`${VM_FILE} is not readable JSON — ${err.message}; remove it, then spore setup`)
51
+ }
52
+ if (typeof named?.lima !== 'string' || !named.lima) fail(`${VM_FILE} names no vm, as { "lima": "<instance>" } — remove it, then spore setup`)
53
+ return named.lima
54
+ }
55
+
56
+ function writeVm (vm) {
57
+ mkdirSync(CONFIG_DIR, { recursive: true })
58
+ const temporary = `${VM_FILE}.${process.pid}.tmp`
59
+ writeFileSync(temporary, JSON.stringify({ lima: vm }, null, 2) + '\n')
60
+ renameSync(temporary, VM_FILE)
61
+ }
62
+
63
+ /** Lima's status for the vm — Running, Stopped, Broken — or null when Lima has no such instance. */
64
+ function statusOf (vm, { missing }) {
65
+ const listed = spawnSync('limactl', ['list', '--format', '{{.Name}} {{.Status}}'], { encoding: 'utf8' })
66
+ if (listed.error?.code === 'ENOENT') fail(missing)
67
+ if (listed.error) throw listed.error
68
+ if (listed.status !== 0) fail(`limactl list failed — ${listed.stderr.trim()}`)
69
+ const found = listed.stdout.split('\n').map(line => line.split(' ')).find(([name]) => name === vm)
70
+ return found ? found[1] : null
71
+ }
72
+
73
+ const notOnPath = (vm) => `spore runs in the vm ${vm}, made with Lima, and limactl is not on PATH — ${INSTALL_LIMA}`
74
+
75
+ function limactl (args) {
76
+ const ran = spawnSync('limactl', args, { stdio: 'inherit' })
77
+ if (ran.error) throw ran.error
78
+ if (ran.status !== 0) fail(`limactl ${args.join(' ')} failed`)
79
+ }
80
+
81
+ /**
82
+ * `command` run in the vm, in the directory this one is in where the vm sees it. Lima takes that
83
+ * directory from `$PWD`, which a shell leaves as typed — through symlinks the vm cannot enter.
84
+ */
85
+ function shell (vm, command) {
86
+ const ran = spawnSync('limactl', ['shell', vm, ...command], { stdio: 'inherit', env: { ...process.env, PWD: process.cwd() } })
87
+ if (ran.error) throw ran.error
88
+ return ran
89
+ }
90
+
91
+ function forward (vm, args) {
92
+ const ran = shell(vm, ['spore', ...args])
93
+ process.exit(ran.status ?? 128 + constants.signals[ran.signal])
94
+ }
95
+
96
+ function running (vm) {
97
+ const status = statusOf(vm, { missing: notOnPath(vm) })
98
+ if (status === null) fail(`the vm ${vm} is gone — run spore setup`)
99
+ if (status === 'Stopped') fail(`the vm ${vm} is stopped — run spore vm start`)
100
+ if (status !== 'Running') fail(`the vm ${vm} is ${status} — limactl list ${vm} says why`)
101
+ }
102
+
103
+ function vmVerb (vm, args) {
104
+ const [, sub, ...extra] = args
105
+ if (!['start', 'stop'].includes(sub) || extra.length) fail('vm takes start or stop — spore vm start|stop')
106
+ if (!vm) {
107
+ if (!hasCore()) fail(noCore())
108
+ console.error('spore: no vm — spore runs on this machine')
109
+ process.exit(0)
110
+ }
111
+ const status = statusOf(vm, { missing: notOnPath(vm) })
112
+ if (status === null) fail(`the vm ${vm} is gone — run spore setup`)
113
+ if (sub === 'start' && status === 'Running') console.error(`spore: the vm ${vm} is running`)
114
+ else if (sub === 'stop' && status === 'Stopped') console.error(`spore: the vm ${vm} is stopped`)
115
+ else limactl([sub, vm])
116
+ process.exit(0)
117
+ }
118
+
119
+ /** Whether `spore setup` makes a vm: where the core is not installed, or on a first run that chose one. */
120
+ async function wantsVm () {
121
+ if (!hasCore()) return true
122
+ if (existsSync(join(CONFIG_DIR, 'config.json')) || !process.stdin.isTTY || !process.stdout.isTTY) return false
123
+ const where = await select({
124
+ message: 'where should spore run?',
125
+ options: [
126
+ { value: 'here', label: 'this machine' },
127
+ { value: 'vm', label: 'a vm', hint: 'made with Lima' }
128
+ ],
129
+ initialValue: 'here'
130
+ })
131
+ if (isCancel(where)) {
132
+ cancel('left — spore setup again asks again')
133
+ process.exit(130)
134
+ }
135
+ return where === 'vm'
136
+ }
137
+
138
+ /**
139
+ * Makes the vm, or starts it, brings it to the Node this machine runs and the same spore-cli, names
140
+ * it in `vm.json`, then runs its own `spore setup` — where the model and its key are chosen, so
141
+ * this machine never holds a key.
142
+ */
143
+ function setupVm (named) {
144
+ if (process.platform === 'win32') fail('on Windows spore runs in WSL, which spore setup does not prepare yet')
145
+ if (!process.stdin.isTTY || !process.stdout.isTTY) fail('setup asks questions, and this is not a terminal')
146
+ const vm = named ?? NAME
147
+ const status = statusOf(vm, { missing: `spore runs in a Linux vm made with Lima — install it, ${INSTALL_LIMA}, then spore setup again` })
148
+ if (status === null) limactl(['start', `--name=${vm}`, '--tty=false', '--containerd=none', TEMPLATE])
149
+ else if (status !== 'Running') limactl(['start', vm])
150
+ const prepared = shell(vm, ['sh', '-c', PREPARE, 'vm-prepare', process.version, VERSION])
151
+ if (prepared.status !== 0) fail(`preparing the vm ${vm} failed — fix what it said, then spore setup again`)
152
+ writeVm(vm)
153
+ forward(vm, ['setup'])
154
+ }
155
+
156
+ /**
157
+ * Runs before the core is loaded: settles `vm` and a `setup` that makes a vm, forwards everything
158
+ * else to a vm `vm.json` names, and returns only when the command runs here.
159
+ */
160
+ export async function host (args) {
161
+ const [verb] = args
162
+ const vm = vmNamed()
163
+ if (verb === 'vm') vmVerb(vm, args)
164
+ if (verb === 'setup' && (vm || await wantsVm())) setupVm(vm)
165
+ if (vm) {
166
+ running(vm)
167
+ forward(vm, args)
168
+ }
169
+ if (!hasCore()) fail(noCore())
170
+ }