mio-agent-runtime 0.13.3 → 0.13.4

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.
@@ -46,12 +46,12 @@ const MEMORY_BLOCK = `${MEMORY_BEGIN}
46
46
 
47
47
  Mio MCP tools are available. Treat these as mandatory runtime rules for every workspace.
48
48
 
49
- - Before designing or implementing a solution, or when unsure about prior decisions, call \`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 \`mio-intelligence_mio.memory.record\` with \`kind\`: \`decision\`, \`context\`, \`problem\`, or \`note\`.
51
- - When a tool call fails, retries, or returns an error, call \`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 \`mio-intelligence_mio.policy.check\` and follow its suggestion when available.
53
- - At the end of every task, before producing the final answer, call \`mio-intelligence_mio.observer.ingest\` with \`event_type\` = \`task_outcome\`, a stable \`trace_id\`, \`outcome\` = \`success\` / \`failure\` / \`aborted\`, and a brief non-sensitive \`payload\`. If Mio is unavailable, do not block the final answer.
54
- - When you reuse a prior decision or experience returned by \`mio-intelligence_mio.memory.query\` and it changes your approach or outcome, call \`mio-intelligence_mio.experience.reuse\` with \`sourceAgent\`, \`targetAgent\`, \`experienceId\`, \`reuse\`, \`behaviorChanged\`, and \`outcomeImproved\`.
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
+ - At the end of every task, before producing the final answer, call \`mcp__mio-intelligence__mio.observer.ingest\` with \`event_type\` = \`task_outcome\`, a stable \`trace_id\`, \`outcome\` = \`success\` / \`failure\` / \`aborted\`, and a brief non-sensitive \`payload\`. If Mio is unavailable, do not block the final answer.
54
+ - When you reuse a prior decision or experience returned by \`mcp__mio-intelligence__mio.memory.query\` and it changes your approach or outcome, call \`mcp__mio-intelligence__mio.experience.reuse\` with \`sourceAgent\`, \`targetAgent\`, \`experienceId\`, \`reuse\`, \`behaviorChanged\`, and \`outcomeImproved\`.
55
55
  - If Mio MCP is unavailable, do not block the task. Continue normally and note the missed memory or observation.
56
56
  - Do not store secrets, credentials, or raw sensitive content in Mio memory.
57
57
  ${MEMORY_END}`
@@ -86,6 +86,25 @@ function configNeedsRepair(serverScript) {
86
86
  return configured !== needle
87
87
  }
88
88
 
89
+ // Installed configs written before 0.13.4 baked an install-time project into
90
+ // MIO_CONTEXT, which overrides the server's git-based project derivation and
91
+ // mis-attributes memory writes. Rewriting the entry drops it; `cwd` pins the
92
+ // server process to the workspace so derivation has a stable starting point.
93
+ function contextNeedsRepair() {
94
+ const config = readConfig()
95
+ const mcp = config && config.mcp && config.mcp['mio-intelligence']
96
+ if (!mcp) return false
97
+ const raw = mcp.environment && mcp.environment.MIO_CONTEXT
98
+ if (typeof raw !== 'string') return true
99
+ let context
100
+ try {
101
+ context = JSON.parse(raw)
102
+ } catch (_) {
103
+ return true
104
+ }
105
+ return Boolean(context && typeof context === 'object' && ('project' in context || 'workspace' in context))
106
+ }
107
+
89
108
  function restartWarningMessage() {
90
109
  return restartWarning({
91
110
  hostLabel: 'OpenCode Desktop',
@@ -102,11 +121,11 @@ function isInstalled() {
102
121
  return instructions.includes(INSTRUCTIONS_BEGIN) && instructions.includes(INSTRUCTIONS_END)
103
122
  }
104
123
 
105
- function install({ node, serverScript, home, workspace, project }) {
124
+ function install({ node, serverScript, home }) {
106
125
  const target = configPath()
107
126
  const config = readConfig() || {}
108
127
  const configInstalled = Boolean(config.mcp && config.mcp['mio-intelligence'])
109
- const needsRepair = configInstalled && configNeedsRepair(serverScript)
128
+ const needsRepair = configInstalled && (configNeedsRepair(serverScript) || contextNeedsRepair())
110
129
 
111
130
  let configChanged = false
112
131
  let backup = null
@@ -120,8 +139,6 @@ function install({ node, serverScript, home, workspace, project }) {
120
139
  const existingMcp = config.mcp && typeof config.mcp === 'object' ? config.mcp : {}
121
140
  const context = JSON.stringify({
122
141
  agentId: 'opencode',
123
- project: project || path.basename(workspace || process.cwd()),
124
- workspace: workspace || process.cwd(),
125
142
  sessionId: 'opencode-session',
126
143
  })
127
144
  const next = {
@@ -132,6 +149,7 @@ function install({ node, serverScript, home, workspace, project }) {
132
149
  enabled: true,
133
150
  type: 'local',
134
151
  command: [node, serverScript],
152
+ cwd: '.',
135
153
  environment: {
136
154
  MIO_DATA_DIR: home,
137
155
  MIO_CONTEXT: context,
@@ -152,7 +170,7 @@ function install({ node, serverScript, home, workspace, project }) {
152
170
  if (configChanged && instructionsResult.changed) {
153
171
  message = 'OpenCode Mio MCP installed and global Mio rules injected into AGENTS.md. Restart OpenCode to load them.'
154
172
  } else if (needsRepair && !instructionsResult.changed) {
155
- message = 'OpenCode Mio MCP repaired (server path updated). Restart OpenCode to load it.'
173
+ message = 'OpenCode Mio MCP repaired (server path or context updated). Restart OpenCode to load it.'
156
174
  } else if (instructionsResult.changed) {
157
175
  message = 'OpenCode Mio MCP already installed. Injected global Mio rules into AGENTS.md. Restart OpenCode to load them.'
158
176
  } else {
@@ -173,4 +191,12 @@ function install({ node, serverScript, home, workspace, project }) {
173
191
  }
174
192
  }
175
193
 
176
- module.exports = { configPath, globalInstructionsPath, isInstalled, install, configNeedsRepair, restartWarningMessage }
194
+ module.exports = {
195
+ configPath,
196
+ globalInstructionsPath,
197
+ isInstalled,
198
+ install,
199
+ configNeedsRepair,
200
+ contextNeedsRepair,
201
+ restartWarningMessage,
202
+ }
@@ -55,12 +55,12 @@ const MEMORY_BLOCK = `${MEMORY_BEGIN}
55
55
 
56
56
  Mio MCP tools are available. Treat these as mandatory runtime rules for every workspace.
57
57
 
58
- - Before designing or implementing a solution, or when unsure about prior decisions, call \`mio-intelligence_mio.memory.query\` first. Omit \`project\` unless a specific project is required; Mio derives it from the current Git repository.
59
- - After a decision affecting architecture, deployment, dependencies, or long-term behavior, call \`mio-intelligence_mio.memory.record\` with \`kind\`: \`decision\`, \`context\`, \`problem\`, or \`note\`.
60
- - When a tool call fails, retries, or returns an error, call \`mio-intelligence_mio.observer.ingest\` with a stable \`trace_id\`, relevant \`event_type\`, \`payload\`, and \`outcome\`.
61
- - Before a high-risk operation such as deletion, migration, credential change, or production change, call \`mio-intelligence_mio.policy.check\` and follow its suggestion when available.
62
- - At the end of every task, before producing the final answer, call \`mio-intelligence_mio.observer.ingest\` with \`event_type\` = \`task_outcome\`, a stable \`trace_id\`, \`outcome\` = \`success\` / \`failure\` / \`aborted\`, and a brief non-sensitive \`payload\`. If Mio is unavailable, do not block the final answer.
63
- - When you reuse a prior decision or experience returned by \`mio-intelligence_mio.memory.query\` and it changes your approach or outcome, call \`mio-intelligence_mio.experience.reuse\` with \`sourceAgent\`, \`targetAgent\`, \`experienceId\`, \`reuse\`, \`behaviorChanged\`, and \`outcomeImproved\`.
58
+ - 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.
59
+ - 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\`.
60
+ - 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\`.
61
+ - 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.
62
+ - At the end of every task, before producing the final answer, call \`mcp__mio-intelligence__mio.observer.ingest\` with \`event_type\` = \`task_outcome\`, a stable \`trace_id\`, \`outcome\` = \`success\` / \`failure\` / \`aborted\`, and a brief non-sensitive \`payload\`. If Mio is unavailable, do not block the final answer.
63
+ - When you reuse a prior decision or experience returned by \`mcp__mio-intelligence__mio.memory.query\` and it changes your approach or outcome, call \`mcp__mio-intelligence__mio.experience.reuse\` with \`sourceAgent\`, \`targetAgent\`, \`experienceId\`, \`reuse\`, \`behaviorChanged\`, and \`outcomeImproved\`.
64
64
  - If Mio MCP is unavailable, do not block the task. Continue normally and note the missed memory or observation.
65
65
  - Do not store secrets, credentials, or raw sensitive content in Mio memory.
66
66
  ${MEMORY_END}`
@@ -124,7 +124,7 @@ function writeApproval(name, entry) {
124
124
  fs.writeFileSync(target, `${JSON.stringify(approvals, null, 2)}\n`, 'utf8')
125
125
  }
126
126
 
127
- function install({ node, serverScript, home, workspace, project }) {
127
+ function install({ node, serverScript, home, workspace }) {
128
128
  const target = configPath()
129
129
  const canonical = readJson(target) || {}
130
130
  const legacy = readJson(legacyConfigPath()) || {}
@@ -142,10 +142,11 @@ function install({ node, serverScript, home, workspace, project }) {
142
142
  },
143
143
  }
144
144
 
145
+ // No project/workspace here: the MCP server derives the project from its own
146
+ // git cwd. A baked value from install-time cwd overrides that derivation and
147
+ // mis-attributes every memory write for the host's lifetime.
145
148
  const context = JSON.stringify({
146
149
  agentId: 'workbuddy',
147
- project: project || path.basename(workspace || process.cwd()),
148
- workspace: workspace || process.cwd(),
149
150
  sessionId: 'workbuddy-session',
150
151
  })
151
152
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mio-agent-runtime",
3
- "version": "0.13.3",
3
+ "version": "0.13.4",
4
4
  "description": "Mio Agent Runtime installer and MCP intelligence layer",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",