mio-agent-runtime 0.5.9 → 0.5.10

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.
Files changed (3) hide show
  1. package/README.md +3 -0
  2. package/bin/mio.js +100 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -54,6 +54,8 @@ Restart your agent after install. That's it.
54
54
  | `mio init` | Create `~/.mio-intelligence` and default config |
55
55
  | `mio install <host>` | Wire MCP + rules + observer into a host |
56
56
  | `mio uninstall <host>` | Remove Mio MCP, rules, approvals, and observer from a host |
57
+ | `mio upgrade` | Upgrade Mio via npm and re-wire all installed hosts to the new server |
58
+ | `mio doctor` | Diagnose install/runtime issues: hosts, observer, version drift, PATH |
57
59
  | `mio mcp` | Start MCP server (stdio, for agent integration) |
58
60
  | `mio status` | Show runtime state, adapter status, observer PID |
59
61
  | `mio agents` | List installed hosts |
@@ -239,6 +241,7 @@ WorkBuddy ─┘ + Observer ......... automatic data collection
239
241
  | >= 0.5.0 | Idea generation + evolution suggestions |
240
242
  | >= 0.5.6 | Rewritten documentation |
241
243
  | >= 0.5.9 | `mio uninstall <host>` command |
244
+ | >= 0.5.10 | `mio upgrade` and `mio doctor` commands |
242
245
 
243
246
  ---
244
247
 
package/bin/mio.js CHANGED
@@ -4,6 +4,7 @@
4
4
  const fs = require('fs')
5
5
  const path = require('path')
6
6
  const os = require('os')
7
+ const { spawnSync } = require('child_process')
7
8
 
8
9
  const SERVER_SCRIPT = path.resolve(__dirname, '..', 'server', 'mio-intelligence-mcp', 'index.js')
9
10
  const MIO_HOME = process.env.MIO_HOME || path.join(os.homedir(), '.mio-intelligence')
@@ -262,6 +263,99 @@ function uninstallCommand(host, useJson) {
262
263
  console.log(result.message || `${host} adapter removed.`)
263
264
  }
264
265
 
266
+ function runNpm(args) {
267
+ try {
268
+ const res = spawnSync('npm', args, { encoding: 'utf8', shell: true, windowsHide: true })
269
+ if (res.error) return { ok: false, error: res.error.message, stdout: '', stderr: '' }
270
+ return { ok: true, status: res.status, stdout: res.stdout || '', stderr: res.stderr || '' }
271
+ } catch (e) {
272
+ return { ok: false, error: e.message, stdout: '', stderr: '' }
273
+ }
274
+ }
275
+
276
+ function npmGlobalVersion() {
277
+ const r = runNpm(['ls', '-g', 'mio-agent-runtime'])
278
+ const m = r.stdout && r.stdout.match(/mio-agent-runtime@(\d+\.\d+\.\d+)/)
279
+ return m ? m[1] : null
280
+ }
281
+
282
+ function npmLatestVersion() {
283
+ const r = runNpm(['view', 'mio-agent-runtime', 'version'])
284
+ const m = r.stdout && r.stdout.trim().match(/(\d+\.\d+\.\d+)/)
285
+ return m ? m[1] : null
286
+ }
287
+
288
+ function upgradeCommand(useJson) {
289
+ const before = npmGlobalVersion()
290
+ const installRes = runNpm(['install', '-g', 'mio-agent-runtime@latest'])
291
+ if (!installRes.ok || installRes.status !== 0) {
292
+ const msg = 'npm install failed: ' + (installRes.error || installRes.stderr || 'unknown error')
293
+ if (useJson) return jsonOrText({ ok: false, error: msg }, true)
294
+ console.error(msg)
295
+ process.exitCode = 1
296
+ return
297
+ }
298
+ const after = npmGlobalVersion()
299
+ const prefix = (() => { const r = runNpm(['config', 'get', 'prefix']); return r.stdout ? r.stdout.trim() : '' })()
300
+ const isWin = process.platform === 'win32'
301
+ const globalServer = prefix ? path.join(prefix, 'node_modules', 'mio-agent-runtime', 'server', 'mio-intelligence-mcp', 'index.js') : SERVER_SCRIPT
302
+ const globalNode = prefix ? (isWin ? path.join(prefix, 'node.exe') : path.join(prefix, 'bin', 'node')) : process.execPath
303
+ const nodeBin = fs.existsSync(globalNode) ? globalNode : process.execPath
304
+ const config = readConfig()
305
+ const hosts = Object.keys(config.agents || {})
306
+ const rewired = []
307
+ for (const host of hosts) {
308
+ const adapter = adapters[host]
309
+ if (!adapter) continue
310
+ try {
311
+ const result = adapter.install({ node: nodeBin, serverScript: globalServer, home: MIO_HOME, workspace: process.cwd() })
312
+ if (result.changed) rewired.push(host)
313
+ } catch (_) {}
314
+ }
315
+ let observerStarted = false
316
+ try { observerStarted = observer.startBackground(MIO_HOME).started } catch (_) {}
317
+ const payload = { ok: true, before, after, rewiredHosts: rewired, observerStarted }
318
+ if (useJson) return jsonOrText(payload, true)
319
+ console.log('Upgraded Mio: ' + (before || '?') + ' -> ' + (after || '?'))
320
+ if (rewired.length) console.log('Re-wired hosts: ' + rewired.join(', '))
321
+ else console.log('All installed hosts already up to date.')
322
+ console.log(observerStarted ? 'Observer started.' : 'Observer already running.')
323
+ }
324
+
325
+ function doctorCommand(useJson) {
326
+ const checks = []
327
+ function add(name, ok, detail) { checks.push({ name: name, ok: Boolean(ok), detail: detail || '' }) }
328
+ add('MIO_HOME exists', fs.existsSync(MIO_HOME), MIO_HOME)
329
+ if (fs.existsSync(MIO_HOME)) {
330
+ try { fs.accessSync(MIO_HOME, fs.constants.W_OK); add('MIO_HOME writable', true) }
331
+ catch (_) { add('MIO_HOME writable', false, 'no write permission') }
332
+ }
333
+ add('MCP server present', fs.existsSync(SERVER_SCRIPT), SERVER_SCRIPT)
334
+ for (const host of ['codex', 'opencode', 'workbuddy', 'hermes']) {
335
+ const adapter = adapters[host]
336
+ const installed = adapter ? adapter.isInstalled() : false
337
+ add('host:' + host + ' installed', installed)
338
+ }
339
+ const obsRunning = observer.isRunning(MIO_HOME)
340
+ add('observer running', obsRunning, obsRunning ? 'pid ' + observer.readPid(MIO_HOME) : 'not running')
341
+ const installed = npmGlobalVersion()
342
+ const latest = npmLatestVersion()
343
+ add('npm up to date', installed === latest, 'installed ' + installed + ' / latest ' + latest)
344
+ const prefix = (() => { const r = runNpm(['config', 'get', 'prefix']); return r.stdout ? r.stdout.trim() : '' })()
345
+ const execPrefix = path.dirname(process.execPath)
346
+ add('global bin on PATH', prefix && execPrefix && prefix.toLowerCase() === execPrefix.toLowerCase(), 'npm prefix ' + prefix + ' / node ' + execPrefix)
347
+ const stray0 = path.join(process.cwd(), '0')
348
+ add('no stray 0 file', !fs.existsSync(stray0), fs.existsSync(stray0) ? stray0 : '')
349
+ const failed = checks.filter(function (c) { return !c.ok })
350
+ const payload = { ok: failed.length === 0, checks: checks, failedCount: failed.length }
351
+ if (useJson) return jsonOrText(payload, true)
352
+ for (const c of checks) {
353
+ console.log((c.ok ? 'OK ' : 'FAIL ') + c.name + (c.detail ? ' (' + c.detail + ')' : ''))
354
+ }
355
+ console.log('')
356
+ console.log(failed.length === 0 ? 'All checks passed.' : failed.length + ' check(s) failed. Run `mio upgrade` or reinstall affected hosts.')
357
+ }
358
+
265
359
  function help() {
266
360
  console.log(`Mio Agent Runtime CLI
267
361
 
@@ -271,6 +365,8 @@ Usage:
271
365
  mio mcp Start Mio MCP server (stdio)
272
366
  mio install <host> Install Mio into a host (codex|opencode|workbuddy|hermes)
273
367
  mio uninstall <host> Remove Mio from a host
368
+ mio upgrade Upgrade Mio and re-wire all installed hosts
369
+ mio doctor Diagnose install and runtime issues
274
370
  mio status Show runtime and adapter status
275
371
  mio agents List installed agents
276
372
  mio observe Watch WorkBuddy transcripts and auto-ingest task outcomes
@@ -299,6 +395,10 @@ function main() {
299
395
  return installCommand(args[1], useJson)
300
396
  case 'uninstall':
301
397
  return uninstallCommand(args[1], useJson)
398
+ case 'upgrade':
399
+ return upgradeCommand(useJson)
400
+ case 'doctor':
401
+ return doctorCommand(useJson)
302
402
  case 'status':
303
403
  return statusCommand(useJson)
304
404
  case 'agents':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mio-agent-runtime",
3
- "version": "0.5.9",
3
+ "version": "0.5.10",
4
4
  "description": "Mio Agent Runtime installer and MCP intelligence layer",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",