mio-agent-runtime 0.2.5 → 0.2.7

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/CODEBUDDY.md` (user-level memory rules, auto-loaded by
36
+ WorkBuddy into every session; the CLI hardcodes the CodeBuddy product name, so the file is CODEBUDDY.md not WORKBUDDY.md) 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,18 @@ 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 (a CodeBuddy fork)
29
+ // auto-loads CODEBUDDY.md (or CODEBUDDY.mdc) from the config dir into every
30
+ // session (MemoryLoader user scope -> system-reminder-md / prompt context).
31
+ // Note: PRODUCT_UPPERCASE_NAME in the CLI bundle is "CODEBUDDY", not "WORKBUDDY".
32
+ function memoryRulesPath() {
33
+ return path.join(configDir(), 'CODEBUDDY.md')
34
+ }
35
+
36
+ // Project-level memory rules. WorkBuddy walks up from the workspace dir and
37
+ // auto-loads CODEBUDDY.md / AGENTS.md (project scope) into every session.
38
+ function projectInstructionsPath(workspace) {
39
+ return path.join(workspace || process.cwd(), 'AGENTS.md')
30
40
  }
31
41
 
32
42
  function readJson(file) {
@@ -55,8 +65,7 @@ Mio MCP tools are available. Treat these as mandatory runtime rules for every wo
55
65
  - Do not store secrets, credentials, or raw sensitive content in Mio memory.
56
66
  ${MEMORY_END}`
57
67
 
58
- function ensureMemoryRules() {
59
- const target = memoryPath()
68
+ function ensureBlock(target) {
60
69
  let content = fs.existsSync(target) ? fs.readFileSync(target, 'utf8') : ''
61
70
  const original = content
62
71
  const start = content.indexOf(MEMORY_BEGIN)
@@ -67,10 +76,12 @@ function ensureMemoryRules() {
67
76
  }
68
77
  if (content) content += '\n\n'
69
78
  content += MEMORY_BLOCK + '\n'
70
- if (content === original) return false
79
+ if (content === original) return { changed: false, target, backup: null }
80
+ const backup = `${target}.bak-mio-${Date.now()}`
81
+ if (fs.existsSync(target)) fs.copyFileSync(target, backup)
71
82
  fs.mkdirSync(path.dirname(target), { recursive: true })
72
83
  fs.writeFileSync(target, content, 'utf8')
73
- return true
84
+ return { changed: true, target, backup }
74
85
  }
75
86
 
76
87
  function isInstalled() {
@@ -79,7 +90,7 @@ function isInstalled() {
79
90
  if (!entry) return false
80
91
 
81
92
  const approvals = readJson(approvalsPath()) || {}
82
- const memory = fs.existsSync(memoryPath()) ? fs.readFileSync(memoryPath(), 'utf8') : ''
93
+ const memory = fs.existsSync(memoryRulesPath()) ? fs.readFileSync(memoryRulesPath(), 'utf8') : ''
83
94
  return Boolean(
84
95
  approvals[approvalKey('mio-intelligence', entry)] &&
85
96
  memory.includes(MEMORY_BEGIN) &&
@@ -151,7 +162,6 @@ function install({ node, serverScript, home, workspace, project }) {
151
162
  }
152
163
 
153
164
  writeApproval('mio-intelligence', config.mcpServers['mio-intelligence'])
154
- const memoryChanged = ensureMemoryRules()
155
165
 
156
166
  const backup = `${target}.bak-mio-${Date.now()}`
157
167
  if (fs.existsSync(target)) {
@@ -161,15 +171,26 @@ function install({ node, serverScript, home, workspace, project }) {
161
171
  fs.mkdirSync(path.dirname(target), { recursive: true })
162
172
  fs.writeFileSync(target, `${JSON.stringify(config, null, 2)}\n`, 'utf8')
163
173
 
174
+ const userRules = ensureBlock(memoryRulesPath())
175
+ let projectRules = null
176
+ const workspaceDir = workspace || process.cwd()
177
+ if (workspaceDir && path.isAbsolute(workspaceDir)) {
178
+ projectRules = ensureBlock(projectInstructionsPath(workspaceDir))
179
+ }
180
+
181
+ const changed = userRules.changed || Boolean(projectRules && projectRules.changed)
182
+
164
183
  return {
165
- changed: true,
184
+ changed,
166
185
  configPath: target,
167
186
  approvalsPath: approvalsPath(),
168
- memoryPath: memoryPath(),
169
- memoryChanged,
187
+ memoryRulesPath: userRules.target,
188
+ projectInstructionsPath: projectRules ? projectRules.target : null,
189
+ userRulesChanged: userRules.changed,
190
+ projectRulesChanged: projectRules ? projectRules.changed : false,
170
191
  backup,
171
- message: 'WorkBuddy Mio MCP installed, approved, and auto-memory rules injected. WorkBuddy should auto-load it; restart if it was already running.',
192
+ message: 'WorkBuddy Mio MCP installed, approved, and Mio rules injected into CODEBUDDY.md (auto-loaded user memory) and the workspace AGENTS.md. Restart WorkBuddy to load them.',
172
193
  }
173
194
  }
174
195
 
175
- module.exports = { configDir, configPath, approvalsPath, memoryPath, approvalKey, isInstalled, install }
196
+ module.exports = { configDir, configPath, approvalsPath, memoryRulesPath, projectInstructionsPath, approvalKey, isInstalled, install }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mio-agent-runtime",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "Mio Agent Runtime installer and MCP intelligence layer",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",