mio-agent-runtime 0.7.0 → 0.9.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
@@ -58,6 +58,7 @@ mio creativity generate Generate hypotheses from 2+ --source "name|content"
58
58
  mio creativity ferment Review and refine active hypotheses (calls an LLM)
59
59
  mio insight status Insight counts: total, reported, unreported, high-value (needs @akemi-mio/insight)
60
60
  mio insight list List insights (--unreported, --min-score N, --detector X, --limit N)
61
+ mio insight generate Generate insights from context (--memory "kind|content"/--summary "text"; calls an LLM)
61
62
  mio insight mark-reported Mark insights as reported (--ids a,b)
62
63
  mio observer <view> Observer research pipeline views (research pipeline, not the observe daemon):
63
64
  status|world-model|trends|research|insights|essays|dag (--base-dir DIR)
@@ -442,6 +443,7 @@ LLM_API_URL=http://localhost:11434/v1/chat/completions mio creativity ferment
442
443
  mio insight status
443
444
  mio insight list --unreported --min-score 0.7
444
445
  mio insight mark-reported --ids ins_1,ins_2
446
+ mio insight generate --memory "decision|把记忆解析抽到共享 store" --summary "刚发了 0.7.0"
445
447
 
446
448
  # 观察研究管线(纯文件读取,不依赖可选包)
447
449
  mio observer status
package/bin/mio.js CHANGED
@@ -99,6 +99,19 @@ function flagPresent(args, name) {
99
99
  return args.includes(name)
100
100
  }
101
101
 
102
+ // Same option repeated: `mio insight generate --memory a --memory b`. A value
103
+ // that is itself another flag is skipped, so a trailing `--json` is not eaten
104
+ // as the value of an option that was left empty.
105
+ function optionValues(args, name) {
106
+ const values = []
107
+ for (let i = 0; i < args.length; i += 1) {
108
+ if (args[i] !== name) continue
109
+ const raw = args[i + 1]
110
+ if (raw && !raw.startsWith('--')) values.push(raw)
111
+ }
112
+ return values
113
+ }
114
+
102
115
  function parseJsonOption(args, name) {
103
116
  const raw = optionValue(args, name)
104
117
  if (raw === undefined) throw new Error(`${name} is required`)
@@ -1235,8 +1248,12 @@ function policyCommand(args, useJson) {
1235
1248
  // commands delegate to the same shared store as the MCP tools, so the two
1236
1249
  // cannot disagree.
1237
1250
  //
1238
- // `generate` is deliberately not exposed. It needs an LLM and the CLI has no
1239
- // LLM wiring; the same call was made for creativity generate/ferment.
1251
+ // `generate` was deliberately not exposed when this command shipped: it needs
1252
+ // an LLM and the CLI had no LLM wiring. `mio config llm` (and creativity
1253
+ // generate before it) changed that, so it is exposed now — otherwise
1254
+ // mio.insight.generate was the only tool of the 48 with no terminal entry
1255
+ // point. Like creativity generate it calls an LLM and appends records, so it
1256
+ // warns when no LLM is configured and accepts --json like every other command.
1240
1257
  // ═════════════════════════════════════════════════════════════
1241
1258
  function cliInsightStore() {
1242
1259
  return createInsightStore({ dataDir: MIO_HOME })
@@ -1246,6 +1263,7 @@ function insightUsage() {
1246
1263
  console.log(`Usage:
1247
1264
  mio insight status Insight counts: total, reported, unreported, high-value
1248
1265
  mio insight list List insights
1266
+ mio insight generate Generate insights from context (calls an LLM)
1249
1267
  mio insight mark-reported --ids a,b Mark insights as reported (acknowledged)
1250
1268
 
1251
1269
  Options:
@@ -1253,6 +1271,8 @@ Options:
1253
1271
  --min-score N Minimum score (list)
1254
1272
  --detector name Filter by detector (list)
1255
1273
  --limit N Max insights (list)
1274
+ --memory "kind|content" Context entry for generate (repeatable)
1275
+ --summary "text" Pre-summarised context for generate (repeatable)
1256
1276
  --ids a,b Comma-separated insight ids (mark-reported)
1257
1277
  --json Machine-readable output (same shape as mio.insight.*)
1258
1278
 
@@ -1294,12 +1314,16 @@ function insightCommand(args, useJson) {
1294
1314
  if (!sub) process.exitCode = 1
1295
1315
  return
1296
1316
  }
1297
- if (!['status', 'list', 'mark-reported'].includes(sub)) {
1317
+ const known = ['status', 'list', 'generate', 'mark-reported']
1318
+ if (!known.includes(sub)) {
1298
1319
  console.error(`Unknown insight subcommand: ${sub}`)
1299
1320
  insightUsage()
1300
1321
  process.exitCode = 1
1301
1322
  return
1302
1323
  }
1324
+ // Handled before the store is touched: generate needs no readable store when
1325
+ // it fails on missing context, and it is async while the rest are not.
1326
+ if (sub === 'generate') return insightGenerateCommand(args, useJson)
1303
1327
 
1304
1328
  const flags = args.slice(2)
1305
1329
  const store = cliInsightStore()
@@ -1334,6 +1358,51 @@ function insightCommand(args, useJson) {
1334
1358
  }
1335
1359
  }
1336
1360
 
1361
+ // --memory "kind|content": the "|" is optional — without it the whole string is
1362
+ // the content and insight-store falls back to its default kind.
1363
+ function parseInsightMemory(raw) {
1364
+ const sep = raw.indexOf('|')
1365
+ if (sep === -1) return { content: raw }
1366
+ const kind = raw.slice(0, sep).trim()
1367
+ return kind ? { kind, content: raw.slice(sep + 1).trim() } : { content: raw.slice(sep + 1).trim() }
1368
+ }
1369
+
1370
+ function insightGenerateCommand(args, useJson) {
1371
+ const flags = args.slice(2)
1372
+ const memories = optionValues(flags, '--memory').map(parseInsightMemory)
1373
+ const summaries = optionValues(flags, '--summary')
1374
+
1375
+ if (memories.length === 0 && summaries.length === 0) {
1376
+ console.error('mio insight generate needs context: --memory "kind|content" and/or --summary "text"')
1377
+ console.error('Example: mio insight generate --memory "decision|memory parsing moved into a shared store"')
1378
+ process.exitCode = 1
1379
+ return
1380
+ }
1381
+
1382
+ if (!useJson) warnIfLlmUnconfigured()
1383
+
1384
+ let result
1385
+ try {
1386
+ result = cliInsightStore().generate({ memories, summaries })
1387
+ } catch (error) {
1388
+ console.error(error.message || error)
1389
+ process.exitCode = 1
1390
+ return
1391
+ }
1392
+ // generate is async in the store.
1393
+ return Promise.resolve(result).then((resolved) => {
1394
+ if (useJson) return jsonOrText(resolved, true)
1395
+ if (!resolved || resolved.generated === 0) {
1396
+ console.log(
1397
+ `No insights generated: ${(resolved && resolved.reason) || 'nothing notable in the given context'}`
1398
+ )
1399
+ return
1400
+ }
1401
+ console.log(`Generated ${resolved.generated} insight(s)`)
1402
+ printInsightList(resolved.insights || [])
1403
+ })
1404
+ }
1405
+
1337
1406
  // ═════════════════════════════════════════════════════════════
1338
1407
  // mio observer — terminal entry point for the observer research pipeline
1339
1408
  // (mio.observer.*). Not to be confused with `mio observe`, which is the
@@ -2772,6 +2841,7 @@ Usage:
2772
2841
  mio creativity ferment Review and refine active hypotheses (calls an LLM)
2773
2842
  mio insight status Insight counts: total, reported, unreported, high-value
2774
2843
  mio insight list List insights (--unreported, --min-score N, --detector X, --limit N)
2844
+ mio insight generate Generate insights from context (--memory "kind|content"/--summary "text"; calls an LLM)
2775
2845
  mio insight mark-reported Mark insights as reported (--ids a,b)
2776
2846
  mio observer <view> Observer pipeline views (research pipeline, not the observe daemon):
2777
2847
  status | world-model | trends | research | insights | essays | dag
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mio-agent-runtime",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Mio Agent Runtime installer and MCP intelligence layer",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -11,10 +11,24 @@
11
11
 
12
12
  const path = require('path')
13
13
 
14
+ // Same two-step resolution as server/runtime-modules.js: the published package
15
+ // first, then the workspace source. In a checkout the @akemi-mio/* packages are
16
+ // NOT linked into node_modules (there is no node_modules/@akemi-mio at all), so
17
+ // without the fallback every mio.insight.* tool stayed gated off even though the
18
+ // source sits right there in packages/insight. In a published install only the
19
+ // package exists, so the fallback never runs.
20
+ function loadInsight() {
21
+ try {
22
+ return require('@akemi-mio/insight')
23
+ } catch (_) {
24
+ return require(path.resolve(__dirname, '..', '..', 'insight'))
25
+ }
26
+ }
27
+
14
28
  let InsightStore = null
15
29
  let InsightGenerator = null
16
30
  try {
17
- const insight = require('@akemi-mio/insight')
31
+ const insight = loadInsight()
18
32
  InsightStore = insight.InsightStore
19
33
  InsightGenerator = insight.InsightGenerator
20
34
  } catch {}
@@ -17,10 +17,22 @@ const path = require('path')
17
17
  // Observer research pipeline (optional -- installed via @akemi-mio/observer).
18
18
  // Loaded lazily at module level so the CLI can report availability without the
19
19
  // MCP server having to pass its own handles down.
20
+ // Two-step resolution, same as server/runtime-modules.js and insight-store.js:
21
+ // the published package first, then the workspace source. A checkout has no
22
+ // node_modules/@akemi-mio, so without the fallback the whole mio.observer.*
23
+ // family stays gated off while its source is sitting in packages/observer.
24
+ function loadObserver() {
25
+ try {
26
+ return require('@akemi-mio/observer')
27
+ } catch (_) {
28
+ return require(path.resolve(__dirname, '..', '..', 'observer'))
29
+ }
30
+ }
31
+
20
32
  let ObserverStore = null
21
33
  let ObserverService = null
22
34
  try {
23
- const obs = require('@akemi-mio/observer')
35
+ const obs = loadObserver()
24
36
  ObserverStore = obs.ObserverStore
25
37
  ObserverService = obs.ObserverService
26
38
  } catch {}