mia-code 0.2.0 → 0.3.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.
Files changed (410) hide show
  1. package/.miette/260321.md +1 -0
  2. package/.miette/260323.md +9 -0
  3. package/.miette/260331.md +2 -0
  4. package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/2604020008--d3417f2c-df12-4f0f-8a1b-d88e7968f822/d3417f2c-df12-4f0f-8a1b-d88e7968f822.md +63 -0
  5. package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/2604020008--e6c3fc5d-4a70-4523-ba7d-a3250da4c235/e6c3fc5d-4a70-4523-ba7d-a3250da4c235.md +72 -0
  6. package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/2604020008--efeb00a2-b17a-4d32-b1f0-b90c37a8d24e/efeb00a2-b17a-4d32-b1f0-b90c37a8d24e.md +62 -0
  7. package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/83a2d7f9-24a5-4cf4-98d5-036c82f872e8.json +302 -0
  8. package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/83a2d7f9-24a5-4cf4-98d5-036c82f872e8.md +149 -0
  9. package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/AGENTS.md +31 -0
  10. package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/meta-decomposition-3-children.md +67 -0
  11. package/.pde/2604040129--61f9dd4d-7aa6-45e6-a58b-e480b1aa6737/61f9dd4d-7aa6-45e6-a58b-e480b1aa6737--from-mia-openclaw-workspace.md +125 -0
  12. package/.pde/2604040129--61f9dd4d-7aa6-45e6-a58b-e480b1aa6737/STATUS.md +1 -0
  13. package/.pde/4f02ba94-9f52-422e-9389-b16f9b37f358.json +177 -0
  14. package/.pde/4f02ba94-9f52-422e-9389-b16f9b37f358.md +77 -0
  15. package/.pde/6ad9244d-5340-490f-b76c-c86728b9de52.json +222 -0
  16. package/.pde/6ad9244d-5340-490f-b76c-c86728b9de52.md +99 -0
  17. package/.pde/8b566792-ed15-4606-96f9-2b6f593d7e6b.json +111 -0
  18. package/.pde/8b566792-ed15-4606-96f9-2b6f593d7e6b.md +67 -0
  19. package/.pde/c7f1e74b-05a5-40e2-9f01-4cc48d2528f7.json +349 -0
  20. package/.pde/c7f1e74b-05a5-40e2-9f01-4cc48d2528f7.md +147 -0
  21. package/.pde/dfc00a78-1da0-4c09-8a16-c6982644051b.json +118 -0
  22. package/.pde/dfc00a78-1da0-4c09-8a16-c6982644051b.md +64 -0
  23. package/GUILLAUME.md +8 -0
  24. package/KINSHIP.md +9 -0
  25. package/MIA_CODE_ARCHITECTURE_REPORT.md +718 -0
  26. package/contextual_research/260119-MIA-CODE--98090899-8aff-4e11-9dc3-8b99466d1.md +1101 -0
  27. package/contextual_research/MIA.md +38 -0
  28. package/contextual_research/MIAWAPASCONE.md +59 -0
  29. package/contextual_research/MIETTE.md +38 -0
  30. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/2504.00218v2.pdf +7483 -12
  31. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/2505.00212v3.pdf +0 -0
  32. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/CONTENT.md +1014 -0
  33. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/DESIGN.gemini.md +242 -0
  34. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/INDEX.md +45 -0
  35. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/2504.00218v2.md +2025 -0
  36. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/2504.00218v2.pdf +7483 -12
  37. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/2505.00212v3.md +1755 -0
  38. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/2505.00212v3.pdf +0 -0
  39. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_12_decomposed_prompting.pdf +0 -0
  40. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_19_hugginggpt_planning.pdf +0 -0
  41. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_1_coordination_challenges.md +766 -0
  42. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_1_coordination_challenges.pdf +3431 -4
  43. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_28_guardrails_multi_agent.md +260 -0
  44. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_28_guardrails_multi_agent.pdf +0 -0
  45. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_2_navigating_complexity.md +558 -0
  46. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_2_navigating_complexity.pdf +0 -0
  47. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_34_hierarchical_multi_agent.pdf +0 -0
  48. package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_5_open_intent_extraction.pdf +0 -0
  49. package/contextual_research/PODCAST.md +109 -0
  50. package/contextual_research/langchain-principles-roadmap.md +157 -0
  51. package/contextual_research/persona-to-narrative-character-inquiry_260201.md +50 -0
  52. package/dist/cli.js +35 -11
  53. package/dist/geminiHeadless.js +8 -2
  54. package/dist/index.js +2 -1
  55. package/dist/mcp/miaco-server.js +10 -1
  56. package/dist/mcp/miatel-server.js +10 -1
  57. package/dist/mcp/miawa-server.js +10 -1
  58. package/dist/mcp/utils.d.ts +6 -1
  59. package/dist/mcp/utils.js +24 -3
  60. package/dist/sessionStore.d.ts +8 -2
  61. package/dist/sessionStore.js +39 -3
  62. package/dist/types.d.ts +1 -0
  63. package/miaco/README.md +124 -0
  64. package/miaco/dist/commands/chart.d.ts +6 -0
  65. package/miaco/dist/commands/chart.d.ts.map +1 -0
  66. package/miaco/dist/commands/chart.js +222 -0
  67. package/miaco/dist/commands/chart.js.map +1 -0
  68. package/miaco/dist/commands/decompose.d.ts +6 -0
  69. package/miaco/dist/commands/decompose.d.ts.map +1 -0
  70. package/miaco/dist/commands/decompose.js +98 -0
  71. package/miaco/dist/commands/decompose.js.map +1 -0
  72. package/miaco/dist/commands/schema.d.ts +6 -0
  73. package/miaco/dist/commands/schema.d.ts.map +1 -0
  74. package/miaco/dist/commands/schema.js +66 -0
  75. package/miaco/dist/commands/schema.js.map +1 -0
  76. package/miaco/dist/commands/stc.d.ts +11 -0
  77. package/miaco/dist/commands/stc.d.ts.map +1 -0
  78. package/miaco/dist/commands/stc.js +590 -0
  79. package/miaco/dist/commands/stc.js.map +1 -0
  80. package/miaco/dist/commands/trace.d.ts +6 -0
  81. package/miaco/dist/commands/trace.d.ts.map +1 -0
  82. package/miaco/dist/commands/trace.js +83 -0
  83. package/miaco/dist/commands/trace.js.map +1 -0
  84. package/miaco/dist/commands/validate.d.ts +6 -0
  85. package/miaco/dist/commands/validate.d.ts.map +1 -0
  86. package/miaco/dist/commands/validate.js +58 -0
  87. package/miaco/dist/commands/validate.js.map +1 -0
  88. package/miaco/dist/decompose.d.ts +93 -0
  89. package/miaco/dist/decompose.d.ts.map +1 -0
  90. package/miaco/dist/decompose.js +562 -0
  91. package/miaco/dist/decompose.js.map +1 -0
  92. package/miaco/dist/index.d.ts +18 -0
  93. package/miaco/dist/index.d.ts.map +1 -0
  94. package/miaco/dist/index.js +83 -0
  95. package/miaco/dist/index.js.map +1 -0
  96. package/miaco/dist/storage.d.ts +60 -0
  97. package/miaco/dist/storage.d.ts.map +1 -0
  98. package/miaco/dist/storage.js +100 -0
  99. package/miaco/dist/storage.js.map +1 -0
  100. package/miaco/package-lock.json +4103 -0
  101. package/miaco/package.json +40 -0
  102. package/miaco/tsconfig.json +18 -0
  103. package/miaco/version-patch-commit-and-publish.sh +1 -0
  104. package/miatel/MISSION_251231.md +3 -0
  105. package/miatel/README.md +107 -0
  106. package/miatel/dist/commands/analyze.d.ts +6 -0
  107. package/miatel/dist/commands/analyze.d.ts.map +1 -0
  108. package/miatel/dist/commands/analyze.js +100 -0
  109. package/miatel/dist/commands/analyze.js.map +1 -0
  110. package/miatel/dist/commands/arc.d.ts +6 -0
  111. package/miatel/dist/commands/arc.d.ts.map +1 -0
  112. package/miatel/dist/commands/arc.js +71 -0
  113. package/miatel/dist/commands/arc.js.map +1 -0
  114. package/miatel/dist/commands/beat.d.ts +6 -0
  115. package/miatel/dist/commands/beat.d.ts.map +1 -0
  116. package/miatel/dist/commands/beat.js +165 -0
  117. package/miatel/dist/commands/beat.js.map +1 -0
  118. package/miatel/dist/commands/theme.d.ts +6 -0
  119. package/miatel/dist/commands/theme.d.ts.map +1 -0
  120. package/miatel/dist/commands/theme.js +54 -0
  121. package/miatel/dist/commands/theme.js.map +1 -0
  122. package/miatel/dist/index.d.ts +18 -0
  123. package/miatel/dist/index.d.ts.map +1 -0
  124. package/miatel/dist/index.js +80 -0
  125. package/miatel/dist/index.js.map +1 -0
  126. package/miatel/dist/storage.d.ts +55 -0
  127. package/miatel/dist/storage.d.ts.map +1 -0
  128. package/miatel/dist/storage.js +100 -0
  129. package/miatel/dist/storage.js.map +1 -0
  130. package/miatel/package-lock.json +4103 -0
  131. package/miatel/package.json +35 -0
  132. package/miatel/src/commands/analyze.ts +109 -0
  133. package/miatel/src/commands/arc.ts +78 -0
  134. package/miatel/src/commands/beat.ts +176 -0
  135. package/miatel/src/commands/theme.ts +60 -0
  136. package/miatel/src/index.ts +94 -0
  137. package/miatel/src/storage.ts +156 -0
  138. package/miatel/tsconfig.json +18 -0
  139. package/miawa/MISSION_251231.md +144 -0
  140. package/miawa/README.md +133 -0
  141. package/miawa/dist/commands/beat.d.ts +6 -0
  142. package/miawa/dist/commands/beat.d.ts.map +1 -0
  143. package/miawa/dist/commands/beat.js +69 -0
  144. package/miawa/dist/commands/beat.js.map +1 -0
  145. package/miawa/dist/commands/ceremony.d.ts +6 -0
  146. package/miawa/dist/commands/ceremony.d.ts.map +1 -0
  147. package/miawa/dist/commands/ceremony.js +239 -0
  148. package/miawa/dist/commands/ceremony.js.map +1 -0
  149. package/miawa/dist/commands/circle.d.ts +6 -0
  150. package/miawa/dist/commands/circle.d.ts.map +1 -0
  151. package/miawa/dist/commands/circle.js +75 -0
  152. package/miawa/dist/commands/circle.js.map +1 -0
  153. package/miawa/dist/commands/eva.d.ts +6 -0
  154. package/miawa/dist/commands/eva.d.ts.map +1 -0
  155. package/miawa/dist/commands/eva.js +73 -0
  156. package/miawa/dist/commands/eva.js.map +1 -0
  157. package/miawa/dist/commands/wound.d.ts +6 -0
  158. package/miawa/dist/commands/wound.d.ts.map +1 -0
  159. package/miawa/dist/commands/wound.js +74 -0
  160. package/miawa/dist/commands/wound.js.map +1 -0
  161. package/miawa/dist/index.d.ts +19 -0
  162. package/miawa/dist/index.d.ts.map +1 -0
  163. package/miawa/dist/index.js +91 -0
  164. package/miawa/dist/index.js.map +1 -0
  165. package/miawa/dist/storage.d.ts +73 -0
  166. package/miawa/dist/storage.d.ts.map +1 -0
  167. package/miawa/dist/storage.js +100 -0
  168. package/miawa/dist/storage.js.map +1 -0
  169. package/miawa/package-lock.json +4103 -0
  170. package/miawa/package.json +36 -0
  171. package/miawa/src/commands/beat.ts +74 -0
  172. package/miawa/src/commands/ceremony.ts +256 -0
  173. package/miawa/src/commands/circle.ts +83 -0
  174. package/miawa/src/commands/eva.ts +84 -0
  175. package/miawa/src/commands/wound.ts +79 -0
  176. package/miawa/src/index.ts +108 -0
  177. package/miawa/src/storage.ts +179 -0
  178. package/miawa/tsconfig.json +18 -0
  179. package/package.json +7 -5
  180. package/references/acp/CLAUDE.md +7 -0
  181. package/references/acp/agent-plan.md +84 -0
  182. package/references/acp/clients.md +31 -0
  183. package/references/acp/extensibility.md +137 -0
  184. package/references/acp/initialization.md +225 -0
  185. package/references/acp/prompt-turn.md +321 -0
  186. package/references/acp/proxy-chains.md +562 -0
  187. package/references/acp/schema.md +3171 -0
  188. package/references/acp/session-list.md +334 -0
  189. package/references/acp/session-modes.md +170 -0
  190. package/references/acp/slash-commands.md +99 -0
  191. package/references/acp/terminals.md +281 -0
  192. package/references/acp/tool-calls.md +311 -0
  193. package/references/acp/typescript.md +29 -0
  194. package/references/claude/agent-teams.md +399 -0
  195. package/references/claude/chrome.md +231 -0
  196. package/references/claude/headless.md +158 -0
  197. package/references/claude/hooks-guide.md +708 -0
  198. package/references/claude/output-styles.md +112 -0
  199. package/references/claude/plugins.md +432 -0
  200. package/references/claude/skills.md +693 -0
  201. package/references/claude/sub-agents.md +816 -0
  202. package/references/copilot/acp/agents.md +32 -0
  203. package/references/copilot/acp/architecture.md +37 -0
  204. package/references/copilot/acp/clients.md +31 -0
  205. package/references/copilot/acp/introduction.md +42 -0
  206. package/references/copilot/acp/registry.md +339 -0
  207. package/references/copilot/acp-server.md +117 -0
  208. package/references/copilot/create-copilot-instructions.md +840 -0
  209. package/references/langchain/llms.txt +833 -0
  210. package/references/langchain/python/agents.md +677 -0
  211. package/references/langchain/python/context-engineering.md +1195 -0
  212. package/references/langchain/python/human-in-the-loop.md +326 -0
  213. package/references/langchain/python/long-term-memory.md +168 -0
  214. package/references/langchain/python/mcp.md +949 -0
  215. package/references/langchain/python/multi-agents/custom-workflow.md +187 -0
  216. package/references/langchain/python/multi-agents/handoffs.md +436 -0
  217. package/references/langchain/python/multi-agents/overview.md +295 -0
  218. package/references/langchain/python/multi-agents/router.md +150 -0
  219. package/references/langchain/python/multi-agents/skills.md +92 -0
  220. package/references/langchain/python/multi-agents/subagents.md +486 -0
  221. package/references/langchain/python/retrieval.md +320 -0
  222. package/references/langchain/python/runtime.md +141 -0
  223. package/references/langchain/python/short-term-memory.md +658 -0
  224. package/references/langchain/python/structured-output.md +712 -0
  225. package/references/langfuse/llms.txt +148 -0
  226. package/references/langgraph/javascript/llms.txt +275 -0
  227. package/references/skills/home.md +259 -0
  228. package/references/skills/integrate-skills.md +103 -0
  229. package/references/skills/specification.md +254 -0
  230. package/references/skills/what-are-skills.md +74 -0
  231. package/rispecs/README.md +164 -0
  232. package/rispecs/_sync_/miadi-code/SPEC.md +313 -0
  233. package/rispecs/_sync_/miadi-code/STATUS.md +177 -0
  234. package/rispecs/_sync_/miadi-code/dashboard/SPEC.md +465 -0
  235. package/rispecs/_sync_/miadi-code/dashboard/STATUS.md +212 -0
  236. package/rispecs/_sync_/miadi-code/multiline-input/SPEC.md +232 -0
  237. package/rispecs/_sync_/miadi-code/multiline-input/STATUS.md +108 -0
  238. package/rispecs/_sync_/miadi-code/pde/SPEC.md +253 -0
  239. package/rispecs/_sync_/miadi-code/pde/STATUS.md +56 -0
  240. package/rispecs/_sync_/miadi-code/stc/SPEC.md +397 -0
  241. package/rispecs/_sync_/miadi-code/stc/STATUS.md +70 -0
  242. package/rispecs/ava-langstack/inquiry-routing-upgrade.spec.md +119 -0
  243. package/rispecs/borrowed_from_opencode/001-client-server-architecture.rispec.md +98 -0
  244. package/rispecs/borrowed_from_opencode/002-event-bus-system.rispec.md +125 -0
  245. package/rispecs/borrowed_from_opencode/003-instance-state-pattern.rispec.md +136 -0
  246. package/rispecs/borrowed_from_opencode/004-namespace-module-pattern.rispec.md +151 -0
  247. package/rispecs/borrowed_from_opencode/005-zod-schema-validation.rispec.md +139 -0
  248. package/rispecs/borrowed_from_opencode/006-named-error-system.rispec.md +155 -0
  249. package/rispecs/borrowed_from_opencode/007-structured-logging.rispec.md +138 -0
  250. package/rispecs/borrowed_from_opencode/008-lazy-initialization.rispec.md +127 -0
  251. package/rispecs/borrowed_from_opencode/009-multi-agent-system.rispec.md +97 -0
  252. package/rispecs/borrowed_from_opencode/010-agent-definition-config.rispec.md +135 -0
  253. package/rispecs/borrowed_from_opencode/011-agent-permission-rulesets.rispec.md +151 -0
  254. package/rispecs/borrowed_from_opencode/012-agent-prompt-templates.rispec.md +141 -0
  255. package/rispecs/borrowed_from_opencode/013-agent-generation.rispec.md +142 -0
  256. package/rispecs/borrowed_from_opencode/014-plan-build-mode-toggle.rispec.md +155 -0
  257. package/rispecs/borrowed_from_opencode/015-subagent-task-delegation.rispec.md +146 -0
  258. package/rispecs/borrowed_from_opencode/016-agent-model-selection.rispec.md +151 -0
  259. package/rispecs/borrowed_from_opencode/017-compaction-agent.rispec.md +150 -0
  260. package/rispecs/borrowed_from_opencode/018-session-persistence.rispec.md +125 -0
  261. package/rispecs/borrowed_from_opencode/019-session-compaction.rispec.md +132 -0
  262. package/rispecs/borrowed_from_opencode/020-session-forking.rispec.md +134 -0
  263. package/rispecs/borrowed_from_opencode/021-session-revert-snapshot.rispec.md +135 -0
  264. package/rispecs/borrowed_from_opencode/022-session-sharing.rispec.md +165 -0
  265. package/rispecs/borrowed_from_opencode/023-session-summary-diffs.rispec.md +165 -0
  266. package/rispecs/borrowed_from_opencode/024-child-sessions.rispec.md +164 -0
  267. package/rispecs/borrowed_from_opencode/025-session-title-generation.rispec.md +162 -0
  268. package/rispecs/borrowed_from_opencode/026-message-parts-model.rispec.md +201 -0
  269. package/rispecs/borrowed_from_opencode/027-streaming-message-deltas.rispec.md +212 -0
  270. package/rispecs/borrowed_from_opencode/028-multi-provider-architecture.rispec.md +184 -0
  271. package/rispecs/borrowed_from_opencode/029-provider-authentication.rispec.md +225 -0
  272. package/rispecs/borrowed_from_opencode/030-model-registry.rispec.md +222 -0
  273. package/rispecs/borrowed_from_opencode/031-cost-tracking.rispec.md +243 -0
  274. package/rispecs/borrowed_from_opencode/032-provider-transform-pipeline.rispec.md +282 -0
  275. package/rispecs/borrowed_from_opencode/033-provider-sdk-abstraction.rispec.md +338 -0
  276. package/rispecs/borrowed_from_opencode/034-tool-registry.rispec.md +110 -0
  277. package/rispecs/borrowed_from_opencode/035-tool-context-injection.rispec.md +155 -0
  278. package/rispecs/borrowed_from_opencode/036-tool-output-truncation.rispec.md +138 -0
  279. package/rispecs/borrowed_from_opencode/037-batch-tool.rispec.md +129 -0
  280. package/rispecs/borrowed_from_opencode/038-multi-edit-tool.rispec.md +167 -0
  281. package/rispecs/borrowed_from_opencode/039-apply-patch-tool.rispec.md +161 -0
  282. package/rispecs/borrowed_from_opencode/040-code-search-tool.rispec.md +143 -0
  283. package/rispecs/borrowed_from_opencode/041-web-fetch-tool.rispec.md +131 -0
  284. package/rispecs/borrowed_from_opencode/042-web-search-tool.rispec.md +159 -0
  285. package/rispecs/borrowed_from_opencode/043-todo-tool.rispec.md +156 -0
  286. package/rispecs/borrowed_from_opencode/044-plan-mode-tool.rispec.md +139 -0
  287. package/rispecs/borrowed_from_opencode/045-task-tool.rispec.md +146 -0
  288. package/rispecs/borrowed_from_opencode/046-question-tool.rispec.md +170 -0
  289. package/rispecs/borrowed_from_opencode/047-external-directory-tool.rispec.md +166 -0
  290. package/rispecs/borrowed_from_opencode/048-file-read-write-tools.rispec.md +205 -0
  291. package/rispecs/borrowed_from_opencode/049-lsp-server-management.rispec.md +104 -0
  292. package/rispecs/borrowed_from_opencode/050-lsp-hover-completion.rispec.md +102 -0
  293. package/rispecs/borrowed_from_opencode/051-lsp-diagnostics.rispec.md +86 -0
  294. package/rispecs/borrowed_from_opencode/052-lsp-root-detection.rispec.md +109 -0
  295. package/rispecs/borrowed_from_opencode/053-remote-mcp-servers.rispec.md +119 -0
  296. package/rispecs/borrowed_from_opencode/054-mcp-oauth-flow.rispec.md +107 -0
  297. package/rispecs/borrowed_from_opencode/055-mcp-tool-conversion.rispec.md +118 -0
  298. package/rispecs/borrowed_from_opencode/056-mcp-connection-monitoring.rispec.md +106 -0
  299. package/rispecs/borrowed_from_opencode/057-local-mcp-servers.rispec.md +116 -0
  300. package/rispecs/borrowed_from_opencode/058-rich-tui.rispec.md +108 -0
  301. package/rispecs/borrowed_from_opencode/059-streaming-display.rispec.md +116 -0
  302. package/rispecs/borrowed_from_opencode/060-permission-prompts.rispec.md +130 -0
  303. package/rispecs/borrowed_from_opencode/061-session-navigation.rispec.md +155 -0
  304. package/rispecs/borrowed_from_opencode/062-syntax-highlighting.rispec.md +151 -0
  305. package/rispecs/borrowed_from_opencode/063-keybinding-system.rispec.md +181 -0
  306. package/rispecs/borrowed_from_opencode/064-multi-level-config.rispec.md +155 -0
  307. package/rispecs/borrowed_from_opencode/065-jsonc-config.rispec.md +190 -0
  308. package/rispecs/borrowed_from_opencode/066-config-env-variables.rispec.md +153 -0
  309. package/rispecs/borrowed_from_opencode/067-config-deep-merging.rispec.md +178 -0
  310. package/rispecs/borrowed_from_opencode/068-remote-org-config.rispec.md +183 -0
  311. package/rispecs/borrowed_from_opencode/069-config-markdown-frontmatter.rispec.md +206 -0
  312. package/rispecs/borrowed_from_opencode/070-managed-config-directory.rispec.md +232 -0
  313. package/rispecs/borrowed_from_opencode/071-plugin-architecture.rispec.md +104 -0
  314. package/rispecs/borrowed_from_opencode/072-plugin-hooks.rispec.md +123 -0
  315. package/rispecs/borrowed_from_opencode/073-plugin-auto-install.rispec.md +115 -0
  316. package/rispecs/borrowed_from_opencode/074-permission-system.rispec.md +133 -0
  317. package/rispecs/borrowed_from_opencode/075-git-worktree-management.rispec.md +126 -0
  318. package/rispecs/borrowed_from_opencode/076-snapshot-system.rispec.md +124 -0
  319. package/rispecs/borrowed_from_opencode/077-snapshot-diff.rispec.md +117 -0
  320. package/rispecs/borrowed_from_opencode/078-snapshot-restore.rispec.md +128 -0
  321. package/rispecs/borrowed_from_opencode/079-worktree-branch-naming.rispec.md +122 -0
  322. package/rispecs/borrowed_from_opencode/080-sqlite-storage.rispec.md +134 -0
  323. package/rispecs/borrowed_from_opencode/081-database-migrations.rispec.md +148 -0
  324. package/rispecs/borrowed_from_opencode/082-database-transactions.rispec.md +138 -0
  325. package/rispecs/borrowed_from_opencode/083-deferred-effects.rispec.md +148 -0
  326. package/rispecs/borrowed_from_opencode/084-permission-rules.rispec.md +123 -0
  327. package/rispecs/borrowed_from_opencode/085-permission-glob-patterns.rispec.md +113 -0
  328. package/rispecs/borrowed_from_opencode/086-permission-merging.rispec.md +134 -0
  329. package/rispecs/borrowed_from_opencode/087-permission-modes.rispec.md +145 -0
  330. package/rispecs/borrowed_from_opencode/088-http-api-server.rispec.md +165 -0
  331. package/rispecs/borrowed_from_opencode/089-openapi-spec-generation.rispec.md +164 -0
  332. package/rispecs/borrowed_from_opencode/090-websocket-support.rispec.md +136 -0
  333. package/rispecs/borrowed_from_opencode/091-sse-streaming.rispec.md +168 -0
  334. package/rispecs/borrowed_from_opencode/092-mdns-discovery.rispec.md +145 -0
  335. package/rispecs/borrowed_from_opencode/093-javascript-sdk.rispec.md +200 -0
  336. package/rispecs/borrowed_from_opencode/094-skill-system.rispec.md +187 -0
  337. package/rispecs/borrowed_from_opencode/095-skill-discovery.rispec.md +182 -0
  338. package/rispecs/borrowed_from_opencode/096-desktop-remote-driving.rispec.md +175 -0
  339. package/rispecs/borrowed_from_opencode/INDEX.md +255 -0
  340. package/rispecs/core.rispecs.md +261 -0
  341. package/rispecs/engines.rispecs.md +241 -0
  342. package/rispecs/formatting.rispecs.md +252 -0
  343. package/rispecs/living-specifications.rispecs.md +361 -0
  344. package/rispecs/mcp.rispecs.md +197 -0
  345. package/rispecs/pde.rispecs.md +399 -0
  346. package/rispecs/pi-mono-envisionning/ENVISIONING.md +366 -0
  347. package/rispecs/pi-mono-envisionning/storytelling-horizon.rispecs.md +76 -0
  348. package/rispecs/pi-mono-envisionning/widget.rispecs.md +2 -0
  349. package/rispecs/relation-to-mcp-structural-thinking.kin.md +72 -0
  350. package/rispecs/research-for-better-framework/CLAUDE.md +7 -0
  351. package/rispecs/research-for-better-framework/survey-pi-openclaw-opencode-openhands.md +210 -0
  352. package/rispecs/session.rispecs.md +277 -0
  353. package/rispecs/stc.rispecs.md +138 -0
  354. package/rispecs/unifier.rispecs.md +317 -0
  355. package/scripts/LAUNCH--mcp-mia-code--testing--2603141315--ac705a66-2c15-4a1c-a26d-9491018c5ba8.sh +2 -0
  356. package/scripts/RESUME--mia-code--mcps--260313--ac705a66-2c15-4a1c-a26d-9491018c5ba8.sh +1 -0
  357. package/scripts/install-widget-in-home-pi-agent-extensions.sh +4 -0
  358. package/scripts/sample-decompose--2604011535-prompt.sh +1 -0
  359. package/skills/deep-search/AGENTS.md +17 -0
  360. package/skills/deep-search/SKILL.md +281 -0
  361. package/skills/deep-search/agent-templates.md +224 -0
  362. package/skills/deep-search/orchestration-patterns.md +95 -0
  363. package/skills/miaco-pde-inquiry-routing-deep-search/AGENTS.md +13 -0
  364. package/skills/miaco-pde-inquiry-routing-deep-search/SKILL.md +136 -0
  365. package/skills/miaco-pde-inquiry-routing-internal-external-relationship/AGENTS.md +4 -0
  366. package/skills/miaco-pde-inquiry-routing-internal-external-relationship/SKILL.md +157 -0
  367. package/skills/miaco-pde-inquiry-routing-local-qmd/AGENTS.md +42 -0
  368. package/skills/miaco-pde-inquiry-routing-local-qmd/SKILL.md +135 -0
  369. package/skills/qmd/AGENTS.md +3 -0
  370. package/skills/qmd/SKILL.md +144 -0
  371. package/skills/qmd/references/mcp-setup.md +102 -0
  372. package/skills/rise-pde-inquiry-session-multi-agents-v3/SKILL.md +234 -0
  373. package/skills/rise-pde-inquiry-session-multi-agents-v3/agent-templates.md +436 -0
  374. package/skills/rise-pde-inquiry-session-multi-agents-v3/orchestration-patterns.md +197 -0
  375. package/skills/rise-pde-inquiry-session-multi-agents-v3/references/ceremonial-technology.md +102 -0
  376. package/skills/rise-pde-inquiry-session-multi-agents-v3/references/creative-orientation.md +99 -0
  377. package/skills/rise-pde-inquiry-session-multi-agents-v3/references/prompt-decomposition.md +73 -0
  378. package/skills/rise-pde-inquiry-session-multi-agents-v3/references/rise-framework.md +74 -0
  379. package/skills/rise-pde-inquiry-session-multi-agents-v3/references/structural-tension.md +82 -0
  380. package/src/cli.ts +35 -11
  381. package/src/geminiHeadless.ts +7 -2
  382. package/src/index.ts +2 -1
  383. package/src/mcp/miaco-server.ts +13 -1
  384. package/src/mcp/miatel-server.ts +13 -1
  385. package/src/mcp/miawa-server.ts +13 -1
  386. package/src/mcp/utils.ts +41 -8
  387. package/src/sessionStore.ts +44 -4
  388. package/src/types.ts +2 -1
  389. package/widget/mia-ceremony/README.md +36 -0
  390. package/widget/mia-ceremony/index.ts +143 -0
  391. package/widget/mia-interceptor/README.md +39 -0
  392. package/widget/mia-interceptor/index.ts +221 -0
  393. package/widget/mia-tools/README.md +37 -0
  394. package/widget/mia-tools/index.ts +569 -0
  395. package/widget/miette-echo/README.md +44 -0
  396. package/widget/miette-echo/index.ts +164 -0
  397. package/.claude/settings.local.json +0 -9
  398. package/.hch/issue_.env +0 -4
  399. package/.hch/issue_add__2601211715.json +0 -77
  400. package/.hch/issue_add__2601211715.md +0 -4
  401. package/.hch/issue_add__2602242020.json +0 -78
  402. package/.hch/issue_add__2602242020.md +0 -7
  403. package/.hch/issues.json +0 -2312
  404. package/.hch/issues.md +0 -30
  405. package/WS__mia-code__260214__IAIP_PDE.code-workspace +0 -29
  406. package/WS__mia-code__src332__260122.code-workspace +0 -23
  407. package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/checkpoints/index.md +0 -6
  408. package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/events.jsonl +0 -213
  409. package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/plan.md +0 -243
  410. package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/workspace.yaml +0 -5
@@ -0,0 +1,119 @@
1
+ # RISE-053: Remote MCP Servers
2
+
3
+ > RISE Framework Specification — Borrowed from OpenCode for mia-code
4
+ > Document: rispecs/borrowed_from_opencode/053-remote-mcp-servers.rispec.md
5
+
6
+ ## Creative Intent
7
+
8
+ mia-code connects to remote MCP servers over HTTP/SSE, extending the agent's capabilities beyond locally-installed tools. A developer configures a remote GitHub MCP server, a Jira server, or a custom deployment API — and the agent uses their tools as naturally as built-in ones. Remote servers bring organizational tooling, cloud APIs, and shared infrastructure into the agent's reach without requiring local installation.
9
+
10
+ ## Structural Tension Analysis
11
+
12
+ **Current Reality:**
13
+ - mia-code's MCP integration supports only locally-spawned servers communicating over stdio
14
+ - Remote APIs require custom tool implementations or shell commands with `curl`
15
+ - No SSE (Server-Sent Events) client for real-time updates from remote services
16
+ - Authentication tokens for remote services are passed ad-hoc through environment variables
17
+ - Each remote service integration requires custom code in mia-code's codebase
18
+ - No connection lifecycle management: no reconnection, no timeout, no health monitoring for remote endpoints
19
+
20
+ **Desired State:**
21
+ - Remote MCP servers are configured in `mia-code.json` alongside local servers
22
+ - HTTP/SSE transport connects to any MCP-compliant remote server
23
+ - Connection lifecycle is managed: connect on first use, reconnect on disconnect, timeout on inactivity
24
+ - Authentication headers (Bearer tokens, API keys) are configurable with environment variable substitution
25
+ - Remote server tools appear in the tool registry identically to local tools
26
+ - Multiple remote servers coexist with their tools namespaced by server name
27
+
28
+ ## Desired Outcome Definition
29
+
30
+ A developer adds a remote GitHub MCP server to `mia-code.json`. When the agent first needs to create an issue, mia-code connects to the remote server via SSE, fetches the tool list, and registers `github_create_issue` as an available tool. The agent calls it with parameters; mia-code forwards the request over HTTP. If the connection drops, mia-code reconnects automatically. The developer also adds a Jira server — both run simultaneously with no conflicts.
31
+
32
+ ## Natural Language Functional Description
33
+
34
+ ### Configuration
35
+
36
+ Remote MCP servers are declared in `mia-code.json`:
37
+
38
+ ```json
39
+ {
40
+ "mcp": {
41
+ "github": {
42
+ "type": "remote",
43
+ "url": "https://mcp.github.example.com/sse",
44
+ "headers": {
45
+ "Authorization": "Bearer ${GITHUB_TOKEN}"
46
+ },
47
+ "timeout": 30000,
48
+ "reconnect": true
49
+ },
50
+ "jira": {
51
+ "type": "remote",
52
+ "url": "https://jira-mcp.internal.company.com/sse",
53
+ "headers": {
54
+ "X-API-Key": "${JIRA_API_KEY}"
55
+ }
56
+ }
57
+ }
58
+ }
59
+ ```
60
+
61
+ **Environment variable substitution:** Values wrapped in `${VAR_NAME}` are resolved from environment variables at connection time. Missing variables produce a clear error before attempting connection.
62
+
63
+ ### Connection Lifecycle
64
+
65
+ **Connect on first use:** When an agent attempts to use a tool that belongs to a remote server (or when the tool list is first needed), mia-code initiates the SSE connection. No connections are opened at session start — only when needed.
66
+
67
+ **SSE Connection:** The client opens an SSE stream to the configured URL. The server sends events:
68
+ - `endpoint` — provides the HTTP POST endpoint for sending requests
69
+ - `message` — JSON-RPC responses and notifications from the server
70
+
71
+ **Tool discovery:** On connection, mia-code sends a `tools/list` request. The server responds with available tools, their schemas, and descriptions. These are registered in the tool registry with the server name prefix.
72
+
73
+ **Reconnection:** If the SSE connection drops, mia-code attempts reconnection with exponential backoff: 1s, 2s, 4s, 8s, up to 60s maximum. During reconnection, tool calls to this server queue and execute once reconnected. After 10 failed reconnection attempts, the server is marked as unavailable.
74
+
75
+ **Timeout:** If no communication occurs for the configured timeout period (default 30s for tool calls), the request is aborted with an error. The SSE connection itself has no idle timeout — it remains open as long as the session is active.
76
+
77
+ **Graceful disconnect:** On session end, mia-code closes all SSE connections cleanly.
78
+
79
+ ### Tool Namespacing
80
+
81
+ Each remote server's tools are prefixed with the server name to avoid conflicts:
82
+
83
+ | Server Config Key | MCP Tool Name | Registered As |
84
+ |-------------------|---------------|---------------|
85
+ | `github` | `create_issue` | `github_create_issue` |
86
+ | `github` | `search_code` | `github_search_code` |
87
+ | `jira` | `create_issue` | `jira_create_issue` |
88
+
89
+ The prefix is configurable per server: `"prefix": "gh"` would produce `gh_create_issue`. Setting `"prefix": ""` disables prefixing (use with caution for conflicts).
90
+
91
+ ### Tool List Refresh
92
+
93
+ When the remote server sends a `notifications/tools/list_changed` notification, mia-code re-fetches the tool list. Tools that no longer exist are deregistered. New tools are registered. This allows remote servers to dynamically add or remove capabilities.
94
+
95
+ ### Request Forwarding and Server Isolation
96
+
97
+ When an agent calls a remote tool, mia-code constructs a `tools/call` JSON-RPC request (using the original unprefixed name), POSTs it to the SSE-provided endpoint, and correlates the response by request ID. Each remote server has its own SSE connection, auth headers, tool namespace, and reconnection state — servers cannot interfere with each other.
98
+
99
+ ## Supporting Structures
100
+
101
+ - **MCP Tool Conversion (RISE-055)** wraps remote tools as native mia-code tools
102
+ - **MCP Connection Monitoring (RISE-056)** tracks health of remote connections
103
+ - **MCP OAuth Flow (RISE-054)** handles OAuth authentication for servers that require it
104
+ - **Event Bus (RISE-002)** publishes `mcp.connected`, `mcp.disconnected` events for remote servers
105
+ - **Structured Logging (RISE-007)** logs connection lifecycle events and request/response pairs
106
+
107
+ ## Creative Advancement Scenarios
108
+
109
+ **Scenario 1 — GitHub Integration:**
110
+ A developer configures a remote GitHub MCP server. The agent can now create issues, search code, open PRs, and review diffs using `github_create_issue`, `github_search_code`, etc. All tool calls route through the remote server — no GitHub CLI installation needed locally.
111
+
112
+ **Scenario 2 — Multi-Server Workflow:**
113
+ An agent working on a bug report reads the issue from Jira (`jira_get_issue`), searches the codebase for the relevant code (`github_search_code`), writes a fix, then creates a PR (`github_create_pr`) and updates the Jira ticket (`jira_update_issue`). Three remote servers participate seamlessly in one workflow.
114
+
115
+ **Scenario 3 — Reconnection Under Flaky Network:**
116
+ During a long coding session, the developer's VPN reconnects. The GitHub SSE connection drops. mia-code detects the disconnect, waits 1 second, reconnects successfully, and re-fetches the tool list. The agent's next `github_create_issue` call works without the agent knowing anything happened.
117
+
118
+ **Scenario 4 — Dynamic Tool Updates:**
119
+ A remote MCP server is updated to add new tools. It sends a `list_changed` notification. mia-code re-fetches the tool list and discovers `deploy_preview` — a new tool. The agent can immediately use it in the current session without restart.
@@ -0,0 +1,107 @@
1
+ # RISE-054: MCP OAuth Flow
2
+
3
+ > RISE Framework Specification — Borrowed from OpenCode for mia-code
4
+ > Document: rispecs/borrowed_from_opencode/054-mcp-oauth-flow.rispec.md
5
+
6
+ ## Creative Intent
7
+
8
+ mia-code handles OAuth 2.0 authentication for MCP servers that require it, so developers authorize once and agents use secured APIs seamlessly. The developer sees a browser prompt, clicks "Authorize," and mia-code stores tokens securely for all future sessions. No manual token management, no copying secrets into config files — the authentication flow is as smooth as logging into a web app.
9
+
10
+ ## Structural Tension Analysis
11
+
12
+ **Current Reality:**
13
+ - MCP server authentication requires manually generating tokens and pasting them into configuration files
14
+ - Bearer tokens in `mia-code.json` are static — they expire and require manual rotation
15
+ - No mechanism for the OAuth authorization code flow (browser redirect, callback handling)
16
+ - Token refresh is manual: when a token expires, the agent fails and the developer must regenerate
17
+ - Credential storage is ad-hoc: tokens in config files, environment variables, or `.env` files with varying security
18
+ - Dynamic client registration (RFC 7591) is not supported — developers must manually register OAuth apps
19
+
20
+ **Desired State:**
21
+ - MCP servers declare OAuth requirements in their configuration
22
+ - mia-code runs the full OAuth 2.0 authorization code flow with PKCE
23
+ - A local HTTP server handles the callback redirect
24
+ - Tokens are stored securely in `~/.mia-code/auth/` with appropriate file permissions
25
+ - Access tokens are refreshed automatically using refresh tokens before expiration
26
+ - Dynamic client registration creates client credentials automatically when supported
27
+ - Multiple OAuth-authenticated servers can run simultaneously
28
+
29
+ ## Desired Outcome Definition
30
+
31
+ A developer adds a remote MCP server that requires OAuth. On first connection, mia-code opens the browser to the authorization URL. The developer logs in and clicks "Authorize." The browser redirects to `localhost:9876/callback`. mia-code exchanges the code for tokens, stores them in `~/.mia-code/auth/mcp-github.json`, and connects to the server. On subsequent sessions, stored tokens are used automatically — refreshed if expired.
32
+
33
+ ## Natural Language Functional Description
34
+
35
+ ### OAuth Configuration
36
+
37
+ MCP servers declare OAuth requirements in `mia-code.json`:
38
+
39
+ ```json
40
+ {
41
+ "mcp": {
42
+ "github": {
43
+ "type": "remote",
44
+ "url": "https://mcp.github.example.com/sse",
45
+ "auth": {
46
+ "type": "oauth",
47
+ "authorizationUrl": "https://github.com/login/oauth/authorize",
48
+ "tokenUrl": "https://github.com/login/oauth/access_token",
49
+ "clientId": "abc123",
50
+ "scopes": ["repo", "read:org"],
51
+ "callbackPort": 9876
52
+ }
53
+ }
54
+ }
55
+ }
56
+ ```
57
+
58
+ Alternatively, the server may advertise its OAuth metadata via a well-known endpoint (RFC 8414), and mia-code discovers endpoints automatically.
59
+
60
+ ### Authorization Flow
61
+
62
+ When the MCP server requires auth and no valid token exists, mia-code: (1) generates a PKCE code verifier/challenge and state parameter, (2) constructs the authorization URL with `client_id`, `redirect_uri`, `response_type=code`, `scope`, `state`, `code_challenge`, (3) opens the browser (or displays URL for headless/SSH sessions), (4) starts a temporary callback server on `localhost:PORT` (default 9876), (5) validates the state parameter and exchanges the code for tokens, (6) stores tokens in `~/.mia-code/auth/mcp-{serverId}.json` with 0600 permissions containing `accessToken`, `refreshToken`, `expiresAt`, `scopes`.
63
+
64
+ ### Token Refresh
65
+
66
+ When an access token is within 5 minutes of expiration (or has already expired):
67
+ 1. POST to the token endpoint with: `grant_type=refresh_token`, `refresh_token`, `client_id`
68
+ 2. Receive new `access_token` and optionally new `refresh_token`
69
+ 3. Update the stored credential file
70
+ 4. Retry the failed request with the new token
71
+
72
+ If refresh fails (refresh token revoked or expired), initiate a new authorization flow.
73
+
74
+ ### Dynamic Client Registration
75
+
76
+ If the MCP server's OAuth metadata includes a `registration_endpoint` (RFC 7591):
77
+ 1. POST client metadata: `redirect_uris`, `client_name` ("mia-code"), `grant_types`, `response_types`, `token_endpoint_auth_method`
78
+ 2. Receive `client_id` and optionally `client_secret`
79
+ 3. Store registration in `~/.mia-code/auth/mcp-{serverId}-client.json`
80
+ 4. Use these credentials for subsequent authorization flows
81
+
82
+ This eliminates the need for developers to manually register OAuth applications.
83
+
84
+ ### Security and Multi-Server Support
85
+
86
+ All flows require PKCE (RFC 7636) and state parameters for CSRF protection. Token files have restrictive 0600 permissions. Tokens are never logged. The callback server runs only during authorization (seconds). If the callback port is in use, the next 5 ports are tried. Each OAuth server has independent token storage — re-authorizing one does not affect others.
87
+
88
+ ## Supporting Structures
89
+
90
+ - **Remote MCP Servers (RISE-053)** initiates OAuth when connecting to servers that require it
91
+ - **MCP Connection Monitoring (RISE-056)** reports auth failures as connection errors
92
+ - **Structured Logging (RISE-007)** logs OAuth flow steps (without tokens) for debugging
93
+ - **Event Bus (RISE-002)** publishes `mcp.auth.started`, `mcp.auth.completed`, `mcp.auth.failed` events
94
+
95
+ ## Creative Advancement Scenarios
96
+
97
+ **Scenario 1 — First-Time Authorization:**
98
+ A developer adds a GitHub MCP server with OAuth config. On first `github_create_issue` call, mia-code opens the browser to GitHub's authorization page. The developer logs in, authorizes the app, and the browser shows "Authorization successful — you may close this tab." mia-code stores the tokens and the tool call completes.
99
+
100
+ **Scenario 2 — Silent Token Refresh:**
101
+ Three hours into a session, the GitHub access token expires. The agent calls `github_search_code`. mia-code detects the expired token, uses the refresh token to get a new access token, retries the request, and returns results. The agent never knows auth happened.
102
+
103
+ **Scenario 3 — Headless Environment:**
104
+ A developer runs mia-code over SSH with no browser. When OAuth is needed, mia-code prints: "Open this URL to authorize: https://github.com/login/oauth/authorize?..." and waits. The developer opens the URL on their phone, authorizes, and the callback is received on the SSH host's localhost. Tokens are stored and the session continues.
105
+
106
+ **Scenario 4 — Dynamic Registration:**
107
+ A company deploys a custom MCP server with dynamic client registration. A new developer runs mia-code for the first time. mia-code auto-registers a client, initiates OAuth, and the developer authorizes. No admin needed to create OAuth app credentials — it's all automatic.
@@ -0,0 +1,118 @@
1
+ # RISE-055: MCP Tool Conversion
2
+
3
+ > RISE Framework Specification — Borrowed from OpenCode for mia-code
4
+ > Document: rispecs/borrowed_from_opencode/055-mcp-tool-conversion.rispec.md
5
+
6
+ ## Creative Intent
7
+
8
+ mia-code converts MCP server tools into native tools so agents use them identically to built-in capabilities. A tool from a remote GitHub server and a tool from a local file-system server go through the same permission checks, receive the same context injection, and produce the same output format. The agent doesn't know or care whether a tool is built-in, from a local MCP server, or from a remote one — it just works.
9
+
10
+ ## Structural Tension Analysis
11
+
12
+ **Current Reality:**
13
+ - MCP tools exist in a separate namespace from native mia-code tools
14
+ - Agents must use different invocation patterns for MCP tools vs. built-in tools
15
+ - MCP tool schemas are JSON Schema; mia-code internal tools use Zod schemas — no conversion bridge
16
+ - Permission checks (RISE-011) apply only to built-in tools; MCP tools bypass the permission system
17
+ - MCP tool output format varies by server; agents must handle different response structures
18
+ - No duplicate detection: an MCP server could register a tool named `read_file` that conflicts with the built-in
19
+
20
+ **Desired State:**
21
+ - Every MCP tool is automatically wrapped as a native mia-code tool on registration
22
+ - JSON Schema parameters are converted to Zod schemas for validation
23
+ - Converted tools pass through the same permission system as built-in tools
24
+ - Tool output is normalized to a consistent format regardless of source
25
+ - Naming conflicts are detected and reported with configurable resolution
26
+ - Tool availability updates dynamically when MCP servers send `list_changed` notifications
27
+
28
+ ## Desired Outcome Definition
29
+
30
+ A remote MCP server connects and provides 5 tools. mia-code wraps each one: JSON Schema → Zod schema, MCP description → tool description, MCP execute → wrapped call. The 5 tools appear in the agent's tool list alongside built-in tools. The agent calls `github_create_issue({title: "Bug", body: "Details"})` — mia-code validates parameters with the Zod schema, checks permissions, forwards to the MCP server, normalizes the response, and returns it to the agent.
31
+
32
+ ## Natural Language Functional Description
33
+
34
+ ### Conversion Pipeline
35
+
36
+ When an MCP server provides its tool list (via `tools/list` response), each tool goes through a conversion pipeline:
37
+
38
+ **Step 1 — Schema Conversion:**
39
+ The MCP tool's `inputSchema` (JSON Schema) is converted to a Zod schema:
40
+ - `type: "string"` → `z.string()`
41
+ - `type: "number"` → `z.number()`
42
+ - `type: "boolean"` → `z.boolean()`
43
+ - `type: "object"` with `properties` → `z.object({...})` with nested conversion
44
+ - `type: "array"` with `items` → `z.array(z.string())` etc.
45
+ - `required` fields → non-optional; others → `.optional()`
46
+ - `enum` values → `z.enum([...])`
47
+ - `description` → `.describe("...")`
48
+
49
+ Complex schemas (oneOf, anyOf, allOf, $ref) are handled via recursive conversion. Unsupported constructs fall back to `z.any()` with a warning.
50
+
51
+ **Step 2 — Name Registration:**
52
+ The tool name is prefixed with the server name: `create_issue` → `github_create_issue`. The prefix is configurable (RISE-053). The converted name is checked against the existing tool registry:
53
+ - If no conflict: register normally
54
+ - If conflicts with a built-in tool: log a warning, keep the MCP tool with its prefix
55
+ - If conflicts with another MCP tool: log an error, the later tool is registered with a numeric suffix (`github_create_issue_2`)
56
+
57
+ **Step 3 — Description Mapping:**
58
+ The MCP tool's `description` becomes the native tool's description. If the MCP tool has no description, a default is generated: `"Tool '{name}' from MCP server '{serverId}'"`.
59
+
60
+ **Step 4 — Execute Wrapper:**
61
+ A wrapper function is created that:
62
+ 1. Receives validated parameters (already checked by Zod schema)
63
+ 2. Constructs a `tools/call` MCP request with the original tool name and parameters
64
+ 3. Sends the request via the MCP client (local stdio or remote HTTP)
65
+ 4. Receives the MCP result
66
+ 5. Normalizes the output format
67
+ 6. Returns the result in standard tool output format
68
+
69
+ ### Output Normalization
70
+
71
+ MCP tool results follow the MCP content format (`content: [{type: "text", text: "..."}]`). The normalizer converts to mia-code's standard output:
72
+
73
+ - **Text content:** extracted and joined with newlines
74
+ - **Image content:** converted to markdown image references or base64 data URIs
75
+ - **Resource content:** embedded with metadata (URI, MIME type)
76
+ - **Error results:** mapped to tool error format with `isError: true`
77
+
78
+ ```
79
+ MCP Response:
80
+ {content: [{type: "text", text: "Issue #42 created"}, {type: "text", text: "URL: https://..."}]}
81
+
82
+ Normalized Output:
83
+ "Issue #42 created\nURL: https://..."
84
+ ```
85
+
86
+ ### Permission Integration
87
+
88
+ Converted MCP tools are subject to the same permission system as built-in tools (RISE-011):
89
+ - The agent's permission ruleset includes MCP tool permissions
90
+ - Default: MCP tools require explicit approval on first use per session
91
+ - Configurable auto-approve per server: `"autoApprove": ["create_issue", "search_code"]`
92
+ - Dangerous operations (delete, deploy) default to require approval regardless of config
93
+
94
+ ### Dynamic Updates and Introspection
95
+
96
+ When an MCP server sends `notifications/tools/list_changed`, mia-code re-fetches the tool list, registers new tools, deregisters removed ones, and updates changed schemas. Agents can query tool metadata to see provenance: `{name: "github_create_issue", source: "mcp", serverId: "github", originalName: "create_issue"}`.
97
+
98
+ ## Supporting Structures
99
+
100
+ - **Remote MCP Servers (RISE-053)** provides the remote tools to convert
101
+ - **Local MCP Servers (RISE-057)** provides locally-spawned server tools to convert
102
+ - **Zod Schema Validation (RISE-005)** provides the schema system tools are converted into
103
+ - **Agent Permission Rulesets (RISE-011)** governs approval for converted MCP tools
104
+ - **Event Bus (RISE-002)** publishes `tools.registered`, `tools.deregistered`, `tools.updated` events
105
+
106
+ ## Creative Advancement Scenarios
107
+
108
+ **Scenario 1 — Seamless Integration:**
109
+ A developer configures a local database MCP server and a remote GitHub MCP server. The agent sees `db_query`, `db_insert`, `github_create_issue`, `github_search_code` alongside built-in tools like `read_file` and `write_file`. It uses them interchangeably in the same workflow: read a file, query the database, create a GitHub issue — all with identical invocation patterns.
110
+
111
+ **Scenario 2 — Schema Validation Catches Errors:**
112
+ An agent tries to call `github_create_issue` with `{title: 42}` (number instead of string). The Zod schema validation catches the error before the request reaches the MCP server: `"Expected string, received number at 'title'"`. The agent corrects the parameter type.
113
+
114
+ **Scenario 3 — Conflict Detection:**
115
+ A developer adds two MCP servers that both provide a `search` tool. mia-code detects the conflict and registers them as `server1_search` and `server2_search`. A warning is logged: `"Tool name conflict: 'search' provided by both 'server1' and 'server2'"`. The agent can use both tools without ambiguity.
116
+
117
+ **Scenario 4 — Live Tool Updates:**
118
+ A custom MCP server is redeployed with a new `deploy_preview` tool added. The server sends `list_changed`. mia-code re-fetches, converts the new tool, and registers it. The agent discovers it in its next tool list query and starts using it — all within the same session, no restart needed.
@@ -0,0 +1,106 @@
1
+ # RISE-056: MCP Connection Monitoring
2
+
3
+ > RISE Framework Specification — Borrowed from OpenCode for mia-code
4
+ > Document: rispecs/borrowed_from_opencode/056-mcp-connection-monitoring.rispec.md
5
+
6
+ ## Creative Intent
7
+
8
+ mia-code monitors the health of every MCP server connection, giving agents and developers clear visibility into what's working, what's broken, and what's recovering. A dashboard shows status at a glance — green for connected, red for failed, yellow for reconnecting. Auto-reconnect with exponential backoff keeps transient failures invisible to the agent. When something is truly down, the error details are immediate and actionable.
9
+
10
+ ## Structural Tension Analysis
11
+
12
+ **Current Reality:**
13
+ - MCP server connections have no health tracking — a crashed server is discovered only when a tool call fails
14
+ - No reconnection logic: if a server disconnects, it stays disconnected until the session is restarted
15
+ - Error details are lost: server crashes produce generic "tool failed" messages without context
16
+ - No visibility into connection state — the developer cannot see which servers are up or down
17
+ - Stale connections sit open indefinitely, consuming resources even when unused
18
+ - Multiple simultaneous server failures create cascading confusing error messages
19
+
20
+ **Desired State:**
21
+ - Every MCP server connection has a tracked status: connected, disconnected, connecting, error
22
+ - Auto-reconnect with exponential backoff handles transient failures transparently
23
+ - A `/mcp` slash command shows a live dashboard of all server states
24
+ - Health events are published to the event bus for programmatic consumption
25
+ - Stale connections are detected via periodic pings
26
+ - Error details include last error message, retry count, and next retry time
27
+
28
+ ## Desired Outcome Definition
29
+
30
+ A developer types `/mcp` and sees a table: GitHub (🟢 connected, 12 tools, last active 30s ago), Jira (🔴 disconnected, retrying in 8s, "connection refused"), Local DB (🟢 connected, 5 tools, last active 2m ago). The GitHub server briefly disconnects — within 1 second it reconnects automatically, the agent never notices. The Jira server is down for maintenance — after 10 retries, it's marked as unavailable, and the agent gets a clear error if it tries to use a Jira tool.
31
+
32
+ ## Natural Language Functional Description
33
+
34
+ ### Connection State Model
35
+
36
+ Each MCP server connection tracks: `serverId`, `status` (connected/disconnected/connecting/error), `lastSuccessfulCommunication`, `lastError`, `errorCount`, `consecutiveFailures`, `toolCount`, `connectTime`, `nextRetryTime`, `retryAttempt`. Transitions: disconnected → connecting → connected (success) or error (failure); connected → disconnected (on drop); error → connecting (on retry) or disconnected (max retries).
37
+
38
+ ### Auto-Reconnect
39
+
40
+ On disconnect: exponential backoff at `min(2^attempt * 1000, 60000)ms` — 1s, 2s, 4s, 8s, up to 60s max. On success: reset counters, re-fetch tools. After 10 consecutive failures: stop retrying, mark disconnected.
41
+
42
+ ### Stale Connection Detection
43
+
44
+ Every 5 minutes (configurable), check `lastSuccessfulCommunication` for each server. If stale: check process liveness (local) or send ping (remote). No response within 10s triggers reconnection.
45
+
46
+ ### Health Events
47
+
48
+ All state transitions are published to the event bus (RISE-002):
49
+
50
+ - `mcp.connecting` — `{serverId, attempt, maxAttempts}`
51
+ - `mcp.connected` — `{serverId, toolCount, connectTime}`
52
+ - `mcp.disconnected` — `{serverId, reason, wasClean}`
53
+ - `mcp.error` — `{serverId, error, retryIn, attempt}`
54
+ - `mcp.health.stale` — `{serverId, lastCommunication}`
55
+ - `mcp.health.recovered` — `{serverId, downtime}`
56
+
57
+ Agents can listen for these events to adapt behavior (e.g., fall back to alternative tools when a server is down).
58
+
59
+ ### Dashboard — `/mcp` Slash Command
60
+
61
+ The `/mcp` command renders a status table:
62
+
63
+ ```
64
+ MCP Server Status
65
+ ─────────────────────────────────────────────────────────
66
+ Server Status Tools Last Active Details
67
+ ─────────────────────────────────────────────────────────
68
+ github 🟢 12 30s ago
69
+ jira 🔴 0 — connection refused (retry 5/10 in 8s)
70
+ local-db 🟢 5 2m ago
71
+ custom-api 🟡 — — connecting (attempt 2)
72
+ ─────────────────────────────────────────────────────────
73
+ 3 servers configured | 2 connected | 17 tools available
74
+ ```
75
+
76
+ Status emojis:
77
+ - 🟢 Connected and healthy
78
+ - 🟡 Connecting or reconnecting
79
+ - 🔴 Disconnected or error
80
+ - ⚪ Not yet started (lazy initialization)
81
+
82
+ ### Error Reporting and Metrics
83
+
84
+ When an agent calls a tool from a disconnected server, it receives actionable details: server name, last error, retry state, and URL. Session metrics track per-server uptime, downtime, reconnection count, average reconnection time, and tool call success rates — available via `mcp.metrics` and included in session summaries.
85
+
86
+ ## Supporting Structures
87
+
88
+ - **Remote MCP Servers (RISE-053)** provides the remote connections to monitor
89
+ - **Local MCP Servers (RISE-057)** provides the local server processes to monitor
90
+ - **Event Bus (RISE-002)** distributes health events to interested subscribers
91
+ - **Structured Logging (RISE-007)** records all health state transitions
92
+ - **Session Persistence (RISE-018)** includes MCP health state in session snapshots
93
+
94
+ ## Creative Advancement Scenarios
95
+
96
+ **Scenario 1 — Transparent Recovery:**
97
+ A remote GitHub server experiences a brief network glitch. The SSE connection drops. mia-code detects the disconnect, publishes `mcp.disconnected`, waits 1 second, reconnects successfully, publishes `mcp.connected`. The agent's next tool call works normally. The developer sees nothing — the recovery was invisible.
98
+
99
+ **Scenario 2 — Informed Failure:**
100
+ The Jira server is down for maintenance. After 10 reconnection attempts over ~2 minutes of exponential backoff, mia-code marks it as disconnected and stops retrying. The agent tries `jira_create_issue` and receives a clear error: "MCP server 'jira' is disconnected after 10 retry attempts. Last error: connection refused." The agent reports to the developer instead of silently failing.
101
+
102
+ **Scenario 3 — Developer Debugging:**
103
+ A developer notices tool calls are slow. They type `/mcp` and see the custom API server has reconnected 15 times in the last hour with average reconnection time of 4 seconds. The health metrics reveal the server is unstable. The developer contacts the server maintainer with specific data.
104
+
105
+ **Scenario 4 — Multi-Server Resilience:**
106
+ Three remote servers are configured. One goes down. The agent detects via health events that `jira` is disconnected and automatically falls back to creating a TODO comment in the code instead of a Jira ticket. When Jira recovers, the agent can retroactively create the tickets from the TODOs.
@@ -0,0 +1,116 @@
1
+ # RISE-057: Local MCP Servers
2
+
3
+ > RISE Framework Specification — Borrowed from OpenCode for mia-code
4
+ > Document: rispecs/borrowed_from_opencode/057-local-mcp-servers.rispec.md
5
+
6
+ ## Creative Intent
7
+
8
+ mia-code spawns and manages locally-running MCP servers that communicate over stdio, giving developers a simple way to extend the agent with custom tools. A developer writes an MCP server as a Node.js script, adds it to configuration, and the agent gains new capabilities — database queries, deployment commands, proprietary API wrappers. The server runs as a child process: mia-code handles spawning, health monitoring, restart on crash, and clean shutdown, so developers focus on tool logic, not infrastructure.
9
+
10
+ ## Structural Tension Analysis
11
+
12
+ **Current Reality:**
13
+ - mia-code can define MCP server configurations in its three-world model but lacks robust local server lifecycle management
14
+ - No standardized process spawning with health monitoring and automatic restart
15
+ - Environment variable substitution in server configs is limited
16
+ - Process cleanup on session end is not guaranteed — orphaned processes can persist
17
+ - Stderr from child processes is discarded, making debugging server issues difficult
18
+ - No initialization timeout — a broken server can hang the agent indefinitely on startup
19
+
20
+ **Desired State:**
21
+ - Local MCP servers are configured declaratively in `mia-code.json` with command, args, env, and working directory
22
+ - Servers spawn lazily on first tool use, not at session start
23
+ - Communication uses JSON-RPC 2.0 over stdin/stdout (the MCP stdio transport)
24
+ - Health monitoring detects crashes and restarts servers automatically
25
+ - Environment variables support `${VAR}` substitution from the host environment
26
+ - Stderr is captured and routed to structured logging for debugging
27
+ - Graceful shutdown ensures no orphaned processes when the session ends
28
+ - Initialization timeout prevents hung servers from blocking the agent
29
+
30
+ ## Desired Outcome Definition
31
+
32
+ A developer adds a local database MCP server to `mia-code.json`. The agent calls `db_query({sql: "SELECT * FROM users"})`. mia-code spawns `node db-mcp-server.js`, initializes the MCP protocol, discovers `query` and `insert` tools, wraps them as `db_query` and `db_insert`, and forwards the call. The server responds with query results. If the server crashes, mia-code restarts it. When the session ends, the server process is terminated cleanly.
33
+
34
+ ## Natural Language Functional Description
35
+
36
+ ### Configuration
37
+
38
+ Local MCP servers are declared in `mia-code.json`:
39
+
40
+ ```json
41
+ {
42
+ "mcp": {
43
+ "local-db": {
44
+ "type": "local",
45
+ "command": ["node", "tools/db-mcp-server.js"],
46
+ "args": ["--connection-string", "${DATABASE_URL}"],
47
+ "env": {
48
+ "DB_PASSWORD": "${DB_PASSWORD}",
49
+ "NODE_ENV": "production"
50
+ },
51
+ "cwd": "./tools",
52
+ "initTimeout": 15000,
53
+ "restartOnCrash": true,
54
+ "maxRestarts": 5
55
+ },
56
+ "code-analyzer": {
57
+ "type": "local",
58
+ "command": ["python", "-m", "analyzer_mcp"],
59
+ "env": {
60
+ "PYTHONPATH": "${PROJECT_ROOT}/lib"
61
+ }
62
+ }
63
+ }
64
+ }
65
+ ```
66
+
67
+ **Configuration fields:**
68
+ - `command`: executable and base arguments (required)
69
+ - `args`: additional arguments appended to command (optional)
70
+ - `env`: environment variables for the spawned process (optional)
71
+ - `cwd`: working directory, relative to project root (default: project root)
72
+ - `initTimeout`: milliseconds to wait for server initialization (default: 10000)
73
+ - `restartOnCrash`: whether to auto-restart on unexpected exit (default: true)
74
+ - `maxRestarts`: maximum restart attempts before giving up (default: 5)
75
+
76
+ ### Environment Variable Substitution
77
+
78
+ Values containing `${VAR_NAME}` are resolved from the host environment at spawn time. Missing variables log a warning. Special variable `${PROJECT_ROOT}` resolves to the session's project root.
79
+
80
+ ### Process Spawning
81
+
82
+ On first tool use: resolve command with env substitution, spawn via `child_process.spawn()` with piped stdin/stdout/stderr and configured cwd/env, start init timeout, send MCP `initialize`, wait for `initialized` notification, fetch tools via `tools/list`, register via conversion pipeline (RISE-055). If init doesn't complete within `initTimeout`, kill and report error.
83
+
84
+ ### Communication Protocol
85
+
86
+ All communication uses JSON-RPC 2.0 over stdin/stdout with newline-delimited messages. Each outgoing request has a unique numeric ID for response correlation. A configurable request timeout (default 30s) prevents hung calls.
87
+
88
+ ### Health Monitoring and Crash Recovery
89
+
90
+ mia-code listens for the `exit` event on each child process. On unexpected exit (code ≠ 0 or signal), it logs the exit details and stderr output, then restarts with exponential backoff (1s, 2s, 4s, max 30s) up to `maxRestarts` attempts. Stderr is captured line-by-line and routed to structured logging at debug level for server-side debugging.
91
+
92
+ ### Graceful Shutdown and Process Isolation
93
+
94
+ On session end, each server receives a `shutdown` request, then `exit` notification, with escalation to SIGTERM and SIGKILL if needed. Each server runs in its own process with independent streams, environment, and working directory — a crash in one server has no effect on others.
95
+
96
+ ## Supporting Structures
97
+
98
+ - **MCP Tool Conversion (RISE-055)** wraps discovered tools as native mia-code tools
99
+ - **MCP Connection Monitoring (RISE-056)** tracks the health state of local server processes
100
+ - **Event Bus (RISE-002)** publishes `mcp.local.spawned`, `mcp.local.crashed`, `mcp.local.shutdown` events
101
+ - **Structured Logging (RISE-007)** captures stderr output and lifecycle events
102
+ - **Lazy Initialization (RISE-008)** provides the deferred-start pattern for local servers
103
+
104
+ ## Creative Advancement Scenarios
105
+
106
+ **Scenario 1 — Custom Database Tool:**
107
+ A developer writes a 50-line Node.js MCP server that wraps their PostgreSQL database with `query` and `schema` tools. They add it to `mia-code.json`. The agent can now query the database, inspect table schemas, and write migration SQL — all through standard tool calls. The server persists a connection pool across calls for efficiency.
108
+
109
+ **Scenario 2 — Crash Recovery:**
110
+ A Python MCP server hits an unhandled exception and crashes. mia-code detects the exit (code 1), logs the traceback from stderr, waits 1 second, respawns the process, reinitializes, and re-registers tools. The agent's next tool call works seamlessly. The developer later reads the debug log to fix the server bug.
111
+
112
+ **Scenario 3 — Multi-Server Workspace:**
113
+ A project has three local MCP servers: a database tool, a deployment tool, and a documentation indexer. All three spawn lazily — the database tool on first `db_query`, the deployment tool when the agent needs to deploy, and the indexer when asked about documentation. Each runs in isolation. If the deployment tool crashes, queries and docs continue working.
114
+
115
+ **Scenario 4 — Sensitive Credentials:**
116
+ A local MCP server needs a database password. The developer sets `DB_PASSWORD` in their shell environment and references `${DB_PASSWORD}` in the server's env config. The password never appears in `mia-code.json` or in logs. The spawned process receives it via its environment. If the variable is missing, mia-code warns before spawning rather than passing an empty string to the database.