mio-agent-runtime 0.2.5 → 0.2.6

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
@@ -31,9 +31,11 @@ mio --json agents Machine-readable agents
31
31
  running, restart it once so it reloads both files.
32
32
  - WorkBuddy uses `~/.workbuddy/mcp.json` and requires each custom MCP server to
33
33
  be approved in `~/.workbuddy/mcp-approvals.json`. `mio install workbuddy`
34
- writes both files and injects Mio usage rules into `~/.workbuddy/MEMORY.md`
35
- so WorkBuddy calls Mio memory/observer/policy automatically. If WorkBuddy is
36
- already running, restart it once so it reloads the approval and memory files.
34
+ writes both files and injects Mio usage rules into
35
+ `~/.workbuddy/WORKBUDDY.md` (user-level memory rules, auto-loaded by
36
+ WorkBuddy into every session) plus `<workspace>/AGENTS.md` (project-level).
37
+ If WorkBuddy is already running, restart it once so it reloads the approval
38
+ and memory rule files.
37
39
 
38
40
  ## MIO_HOME
39
41
 
@@ -51,4 +53,4 @@ packages/mio-cli
51
53
  ├── server/
52
54
  │ └── mio-intelligence-mcp/index.js
53
55
  └── package.json
54
- ```
56
+ ```
@@ -25,8 +25,17 @@ 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')
28
+ // User-level memory rules file. WorkBuddy's codebuddy CLI auto-loads
29
+ // WORKBUDDY.md (or WORKBUDDY.mdc) from the config dir into every session
30
+ // (MemoryLoader user scope -> system-reminder-md / prompt context).
31
+ function memoryRulesPath() {
32
+ return path.join(configDir(), 'WORKBUDDY.md')
33
+ }
34
+
35
+ // Project-level memory rules. WorkBuddy walks up from the workspace dir and
36
+ // auto-loads WORKBUDDY.md / AGENTS.md (project scope) into every session.
37
+ function projectInstructionsPath(workspace) {
38
+ return path.join(workspace || process.cwd(), 'AGENTS.md')
30
39
  }
31
40
 
32
41
  function readJson(file) {
@@ -55,8 +64,7 @@ Mio MCP tools are available. Treat these as mandatory runtime rules for every wo
55
64
  - Do not store secrets, credentials, or raw sensitive content in Mio memory.
56
65
  ${MEMORY_END}`
57
66
 
58
- function ensureMemoryRules() {
59
- const target = memoryPath()
67
+ function ensureBlock(target) {
60
68
  let content = fs.existsSync(target) ? fs.readFileSync(target, 'utf8') : ''
61
69
  const original = content
62
70
  const start = content.indexOf(MEMORY_BEGIN)
@@ -67,10 +75,12 @@ function ensureMemoryRules() {
67
75
  }
68
76
  if (content) content += '\n\n'
69
77
  content += MEMORY_BLOCK + '\n'
70
- if (content === original) return false
78
+ if (content === original) return { changed: false, target, backup: null }
79
+ const backup = `${target}.bak-mio-${Date.now()}`
80
+ if (fs.existsSync(target)) fs.copyFileSync(target, backup)
71
81
  fs.mkdirSync(path.dirname(target), { recursive: true })
72
82
  fs.writeFileSync(target, content, 'utf8')
73
- return true
83
+ return { changed: true, target, backup }
74
84
  }
75
85
 
76
86
  function isInstalled() {
@@ -79,7 +89,7 @@ function isInstalled() {
79
89
  if (!entry) return false
80
90
 
81
91
  const approvals = readJson(approvalsPath()) || {}
82
- const memory = fs.existsSync(memoryPath()) ? fs.readFileSync(memoryPath(), 'utf8') : ''
92
+ const memory = fs.existsSync(memoryRulesPath()) ? fs.readFileSync(memoryRulesPath(), 'utf8') : ''
83
93
  return Boolean(
84
94
  approvals[approvalKey('mio-intelligence', entry)] &&
85
95
  memory.includes(MEMORY_BEGIN) &&
@@ -151,7 +161,6 @@ function install({ node, serverScript, home, workspace, project }) {
151
161
  }
152
162
 
153
163
  writeApproval('mio-intelligence', config.mcpServers['mio-intelligence'])
154
- const memoryChanged = ensureMemoryRules()
155
164
 
156
165
  const backup = `${target}.bak-mio-${Date.now()}`
157
166
  if (fs.existsSync(target)) {
@@ -161,15 +170,26 @@ function install({ node, serverScript, home, workspace, project }) {
161
170
  fs.mkdirSync(path.dirname(target), { recursive: true })
162
171
  fs.writeFileSync(target, `${JSON.stringify(config, null, 2)}\n`, 'utf8')
163
172
 
173
+ const userRules = ensureBlock(memoryRulesPath())
174
+ let projectRules = null
175
+ const workspaceDir = workspace || process.cwd()
176
+ if (workspaceDir && path.isAbsolute(workspaceDir)) {
177
+ projectRules = ensureBlock(projectInstructionsPath(workspaceDir))
178
+ }
179
+
180
+ const changed = userRules.changed || Boolean(projectRules && projectRules.changed)
181
+
164
182
  return {
165
- changed: true,
183
+ changed,
166
184
  configPath: target,
167
185
  approvalsPath: approvalsPath(),
168
- memoryPath: memoryPath(),
169
- memoryChanged,
186
+ memoryRulesPath: userRules.target,
187
+ projectInstructionsPath: projectRules ? projectRules.target : null,
188
+ userRulesChanged: userRules.changed,
189
+ projectRulesChanged: projectRules ? projectRules.changed : false,
170
190
  backup,
171
- message: 'WorkBuddy Mio MCP installed, approved, and auto-memory rules injected. WorkBuddy should auto-load it; restart if it was already running.',
191
+ message: 'WorkBuddy Mio MCP installed, approved, and Mio rules injected into WORKBUDDY.md (auto-loaded user memory) and the workspace AGENTS.md. Restart WorkBuddy to load them.',
172
192
  }
173
193
  }
174
194
 
175
- module.exports = { configDir, configPath, approvalsPath, memoryPath, approvalKey, isInstalled, install }
195
+ module.exports = { configDir, configPath, approvalsPath, memoryRulesPath, projectInstructionsPath, approvalKey, isInstalled, install }
package/package.json CHANGED
@@ -1,23 +1,23 @@
1
- {
2
- "name": "mio-agent-runtime",
3
- "version": "0.2.5",
4
- "description": "Mio Agent Runtime installer and MCP intelligence layer",
5
- "license": "MIT",
6
- "type": "commonjs",
7
- "bin": {
8
- "mio": "bin/mio.js"
9
- },
10
- "files": [
11
- "bin/",
12
- "server/",
13
- "adapters/",
14
- "README.md"
15
- ],
16
- "scripts": {
17
- "check": "node --check bin/mio.js && node --check adapters/codex.js && node --check adapters/opencode.js && node --check adapters/workbuddy.js && node --check server/mio-intelligence-mcp/index.js",
18
- "prepack": "npm run check"
19
- },
20
- "engines": {
21
- "node": ">=18"
22
- }
23
- }
1
+ {
2
+ "name": "mio-agent-runtime",
3
+ "version": "0.2.6",
4
+ "description": "Mio Agent Runtime installer and MCP intelligence layer",
5
+ "license": "MIT",
6
+ "type": "commonjs",
7
+ "bin": {
8
+ "mio": "bin/mio.js"
9
+ },
10
+ "files": [
11
+ "bin/",
12
+ "server/",
13
+ "adapters/",
14
+ "README.md"
15
+ ],
16
+ "scripts": {
17
+ "check": "node --check bin/mio.js && node --check adapters/codex.js && node --check adapters/opencode.js && node --check adapters/workbuddy.js && node --check server/mio-intelligence-mcp/index.js",
18
+ "prepack": "npm run check"
19
+ },
20
+ "engines": {
21
+ "node": ">=18"
22
+ }
23
+ }