mio-agent-runtime 0.2.1 → 0.2.2

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
@@ -26,8 +26,9 @@ mio --json agents Machine-readable agents
26
26
 
27
27
  - WorkBuddy uses `~/.workbuddy/mcp.json` and requires each custom MCP server to
28
28
  be approved in `~/.workbuddy/mcp-approvals.json`. `mio install workbuddy`
29
- writes both files. If WorkBuddy is already running, restart it once so it
30
- reloads the approval file.
29
+ writes both files and injects Mio usage rules into `~/.workbuddy/MEMORY.md`
30
+ so WorkBuddy calls Mio memory/observer/policy automatically. If WorkBuddy is
31
+ already running, restart it once so it reloads the approval and memory files.
31
32
 
32
33
  ## MIO_HOME
33
34
 
@@ -25,6 +25,10 @@ function approvalsPath() {
25
25
  return path.join(configDir(), 'mcp-approvals.json')
26
26
  }
27
27
 
28
+ function memoryPath() {
29
+ return path.join(configDir(), 'MEMORY.md')
30
+ }
31
+
28
32
  function readJson(file) {
29
33
  if (!fs.existsSync(file)) return null
30
34
  try {
@@ -34,13 +38,52 @@ function readJson(file) {
34
38
  }
35
39
  }
36
40
 
41
+
42
+ const MEMORY_BEGIN = '<!-- MIO_INTELLIGENCE_BEGIN -->'
43
+ const MEMORY_END = '<!-- MIO_INTELLIGENCE_END -->'
44
+ const MEMORY_BLOCK = `${MEMORY_BEGIN}
45
+ ## Mio Intelligence Layer
46
+
47
+ Mio MCP tools are available. Treat these as mandatory runtime rules for every workspace.
48
+
49
+ - Before designing or implementing a solution, or when unsure about prior decisions, call \`mcp__mio-intelligence__mio.memory.query\` first. Omit \`project\` unless a specific project is required; Mio derives it from the current Git repository.
50
+ - After a decision affecting architecture, deployment, dependencies, or long-term behavior, call \`mcp__mio-intelligence__mio.memory.record\` with \`kind\`: \`decision\`, \`context\`, \`problem\`, or \`note\`.
51
+ - When a tool call fails, retries, or returns an error, call \`mcp__mio-intelligence__mio.observer.ingest\` with a stable \`trace_id\`, relevant \`event_type\`, \`payload\`, and \`outcome\`.
52
+ - Before a high-risk operation such as deletion, migration, credential change, or production change, call \`mcp__mio-intelligence__mio.policy.check\` and follow its suggestion when available.
53
+ - If Mio MCP is unavailable, do not block the task. Continue normally and note the missed memory or observation.
54
+ - Do not store secrets, credentials, or raw sensitive content in Mio memory.
55
+ ${MEMORY_END}`
56
+
57
+ function ensureMemoryRules() {
58
+ const target = memoryPath()
59
+ let content = fs.existsSync(target) ? fs.readFileSync(target, 'utf8') : ''
60
+ const start = content.indexOf(MEMORY_BEGIN)
61
+ if (start !== -1) {
62
+ const end = content.indexOf(MEMORY_END, start)
63
+ content = end === -1 ? content.slice(0, start) : content.slice(0, start) + content.slice(end + MEMORY_END.length)
64
+ content = content.trimEnd()
65
+ }
66
+ const before = content
67
+ if (content) content += '\n\n'
68
+ content += MEMORY_BLOCK + '\n'
69
+ if (content === before) return false
70
+ fs.mkdirSync(path.dirname(target), { recursive: true })
71
+ fs.writeFileSync(target, content, 'utf8')
72
+ return true
73
+ }
74
+
37
75
  function isInstalled() {
38
76
  const config = readJson(configPath())
39
77
  const entry = config && config.mcpServers && config.mcpServers['mio-intelligence']
40
78
  if (!entry) return false
41
79
 
42
80
  const approvals = readJson(approvalsPath()) || {}
43
- return Boolean(approvals[approvalKey('mio-intelligence', entry)])
81
+ const memory = fs.existsSync(memoryPath()) ? fs.readFileSync(memoryPath(), 'utf8') : ''
82
+ return Boolean(
83
+ approvals[approvalKey('mio-intelligence', entry)] &&
84
+ memory.includes(MEMORY_BEGIN) &&
85
+ memory.includes(MEMORY_END)
86
+ )
44
87
  }
45
88
 
46
89
  function approvalKey(name, entry) {
@@ -107,6 +150,7 @@ function install({ node, serverScript, home, workspace, project }) {
107
150
  }
108
151
 
109
152
  writeApproval('mio-intelligence', config.mcpServers['mio-intelligence'])
153
+ const memoryChanged = ensureMemoryRules()
110
154
 
111
155
  const backup = `${target}.bak-mio-${Date.now()}`
112
156
  if (fs.existsSync(target)) {
@@ -120,9 +164,11 @@ function install({ node, serverScript, home, workspace, project }) {
120
164
  changed: true,
121
165
  configPath: target,
122
166
  approvalsPath: approvalsPath(),
167
+ memoryPath: memoryPath(),
168
+ memoryChanged,
123
169
  backup,
124
- message: 'WorkBuddy Mio MCP installed and approved. WorkBuddy should auto-load it; restart if it was already running.',
170
+ message: 'WorkBuddy Mio MCP installed, approved, and auto-memory rules injected. WorkBuddy should auto-load it; restart if it was already running.',
125
171
  }
126
172
  }
127
173
 
128
- module.exports = { configDir, configPath, approvalsPath, approvalKey, isInstalled, install }
174
+ module.exports = { configDir, configPath, approvalsPath, memoryPath, approvalKey, isInstalled, install }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mio-agent-runtime",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Mio Agent Runtime installer and MCP intelligence layer",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",