memorix 1.1.7 → 1.1.8

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 (174) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/CLAUDE.md +6 -1
  3. package/README.md +21 -0
  4. package/README.zh-CN.md +21 -0
  5. package/TEAM.md +86 -86
  6. package/dist/cli/index.js +730 -150
  7. package/dist/cli/index.js.map +1 -1
  8. package/dist/dashboard/static/index.html +201 -201
  9. package/dist/dashboard/static/style.css +3584 -3584
  10. package/dist/index.js +15 -8
  11. package/dist/index.js.map +1 -1
  12. package/dist/memcode-runtime/CHANGELOG.md +13 -0
  13. package/dist/memcode-runtime/package.json +4 -4
  14. package/dist/sdk.js +15 -8
  15. package/dist/sdk.js.map +1 -1
  16. package/docs/AGENT_OPERATOR_PLAYBOOK.md +18 -0
  17. package/docs/DESIGN_DECISIONS.md +357 -357
  18. package/docs/SETUP.md +10 -0
  19. package/docs/dev-log/progress.txt +35 -26
  20. package/package.json +1 -1
  21. package/src/audit/index.ts +156 -156
  22. package/src/cli/commands/agent-integrations.ts +623 -0
  23. package/src/cli/commands/audit-list.ts +89 -89
  24. package/src/cli/commands/background.ts +659 -659
  25. package/src/cli/commands/cleanup.ts +255 -255
  26. package/src/cli/commands/doctor.ts +23 -0
  27. package/src/cli/commands/formation.ts +48 -48
  28. package/src/cli/commands/git-hook-install.ts +111 -111
  29. package/src/cli/commands/handoff.ts +66 -66
  30. package/src/cli/commands/hooks-status.ts +63 -63
  31. package/src/cli/commands/ingest-commit.ts +153 -153
  32. package/src/cli/commands/ingest-image.ts +73 -73
  33. package/src/cli/commands/ingest-log.ts +180 -180
  34. package/src/cli/commands/ingest.ts +44 -44
  35. package/src/cli/commands/integrate-shared.ts +15 -15
  36. package/src/cli/commands/lock.ts +96 -96
  37. package/src/cli/commands/message.ts +121 -121
  38. package/src/cli/commands/poll.ts +70 -70
  39. package/src/cli/commands/purge-all-memory.ts +85 -85
  40. package/src/cli/commands/purge-project-memory.ts +83 -83
  41. package/src/cli/commands/reasoning.ts +132 -132
  42. package/src/cli/commands/repair.ts +60 -0
  43. package/src/cli/commands/retention.ts +108 -108
  44. package/src/cli/commands/serve-shared.ts +118 -118
  45. package/src/cli/commands/setup.ts +3 -3
  46. package/src/cli/commands/skills.ts +123 -123
  47. package/src/cli/commands/task.ts +192 -192
  48. package/src/cli/commands/transfer.ts +73 -73
  49. package/src/cli/commands/uninstall-project-artifacts.ts +85 -85
  50. package/src/cli/index.ts +3 -1
  51. package/src/cli/tui/ChatView.tsx +234 -234
  52. package/src/cli/tui/CommandBar.tsx +312 -312
  53. package/src/cli/tui/ContextRail.tsx +118 -118
  54. package/src/cli/tui/HeaderBar.tsx +72 -72
  55. package/src/cli/tui/LogoBanner.tsx +51 -51
  56. package/src/cli/tui/Panels.tsx +632 -632
  57. package/src/cli/tui/Sidebar.tsx +179 -179
  58. package/src/cli/tui/chat-service.ts +742 -742
  59. package/src/cli/tui/data.ts +547 -547
  60. package/src/cli/tui/index.ts +41 -41
  61. package/src/cli/tui/markdown-render.tsx +371 -371
  62. package/src/cli/tui/theme.ts +178 -178
  63. package/src/cli/tui/use-mouse.ts +157 -157
  64. package/src/cli/tui/useNavigation.ts +56 -56
  65. package/src/cli/update-checker.ts +211 -211
  66. package/src/cli/version.ts +7 -7
  67. package/src/cli/workbench.ts +1 -1
  68. package/src/codegraph/context-pack.ts +5 -1
  69. package/src/codegraph/lite-provider.ts +5 -1
  70. package/src/codegraph/project-context.ts +5 -1
  71. package/src/compact/token-budget.ts +74 -74
  72. package/src/config/behavior.ts +59 -59
  73. package/src/dashboard/project-classification.ts +64 -64
  74. package/src/dashboard/static/index.html +201 -201
  75. package/src/dashboard/static/style.css +3584 -3584
  76. package/src/embedding/fastembed-provider.ts +142 -142
  77. package/src/embedding/transformers-provider.ts +111 -111
  78. package/src/git/extractor.ts +209 -209
  79. package/src/git/hooks-path.ts +85 -85
  80. package/src/git/noise-filter.ts +210 -210
  81. package/src/hooks/installers/index.ts +4 -4
  82. package/src/hooks/official-skills.ts +1 -1
  83. package/src/hooks/pattern-detector.ts +173 -173
  84. package/src/hooks/rules/memorix-agent-rules.md +2 -2
  85. package/src/hooks/significance-filter.ts +250 -250
  86. package/src/llm/memory-manager.ts +328 -328
  87. package/src/llm/provider.ts +885 -885
  88. package/src/llm/quality.ts +248 -248
  89. package/src/memory/attribution-guard.ts +249 -249
  90. package/src/memory/auto-relations.ts +107 -107
  91. package/src/memory/consolidation.ts +302 -302
  92. package/src/memory/disclosure-policy.ts +141 -141
  93. package/src/memory/entity-extractor.ts +197 -197
  94. package/src/memory/formation/evaluate.ts +217 -217
  95. package/src/memory/formation/extract.ts +361 -361
  96. package/src/memory/formation/index.ts +417 -417
  97. package/src/memory/formation/resolve.ts +344 -344
  98. package/src/memory/formation/types.ts +315 -315
  99. package/src/memory/freshness.ts +122 -122
  100. package/src/memory/graph.ts +197 -197
  101. package/src/memory/refs.ts +94 -94
  102. package/src/memory/retention.ts +433 -433
  103. package/src/memory/secret-filter.ts +79 -79
  104. package/src/memory/session.ts +523 -523
  105. package/src/multimodal/image-loader.ts +143 -143
  106. package/src/orchestrate/adapters/claude-stream.ts +192 -192
  107. package/src/orchestrate/adapters/claude.ts +111 -111
  108. package/src/orchestrate/adapters/codex-stream.ts +134 -134
  109. package/src/orchestrate/adapters/codex.ts +41 -41
  110. package/src/orchestrate/adapters/gemini-stream.ts +166 -166
  111. package/src/orchestrate/adapters/gemini.ts +42 -42
  112. package/src/orchestrate/adapters/index.ts +73 -73
  113. package/src/orchestrate/adapters/opencode-stream.ts +143 -143
  114. package/src/orchestrate/adapters/opencode.ts +47 -47
  115. package/src/orchestrate/adapters/spawn-helper.ts +286 -286
  116. package/src/orchestrate/adapters/types.ts +77 -77
  117. package/src/orchestrate/capability-router.ts +284 -284
  118. package/src/orchestrate/context-compact.ts +188 -188
  119. package/src/orchestrate/cost-tracker.ts +219 -219
  120. package/src/orchestrate/error-recovery.ts +191 -191
  121. package/src/orchestrate/evidence.ts +140 -140
  122. package/src/orchestrate/ledger.ts +110 -110
  123. package/src/orchestrate/memorix-bridge.ts +380 -380
  124. package/src/orchestrate/output-budget.ts +80 -80
  125. package/src/orchestrate/permission.ts +152 -152
  126. package/src/orchestrate/pipeline-trace.ts +131 -131
  127. package/src/orchestrate/prompt-builder.ts +155 -155
  128. package/src/orchestrate/ring-buffer.ts +37 -37
  129. package/src/orchestrate/task-graph.ts +389 -389
  130. package/src/orchestrate/verify-gate.ts +219 -219
  131. package/src/orchestrate/worktree.ts +232 -232
  132. package/src/project/aliases.ts +374 -374
  133. package/src/project/detector.ts +268 -268
  134. package/src/rules/adapters/claude-code.ts +99 -99
  135. package/src/rules/adapters/codex.ts +97 -97
  136. package/src/rules/adapters/copilot.ts +124 -124
  137. package/src/rules/adapters/cursor.ts +114 -114
  138. package/src/rules/adapters/kiro.ts +126 -126
  139. package/src/rules/adapters/trae.ts +56 -56
  140. package/src/rules/adapters/windsurf.ts +83 -83
  141. package/src/rules/syncer.ts +235 -235
  142. package/src/sdk.ts +327 -327
  143. package/src/search/intent-detector.ts +289 -289
  144. package/src/search/query-expansion.ts +52 -52
  145. package/src/server/formation-timeout.ts +27 -27
  146. package/src/skills/mini-skills.ts +386 -386
  147. package/src/store/chat-store.ts +119 -119
  148. package/src/store/file-lock.ts +100 -100
  149. package/src/store/graph-store.ts +249 -249
  150. package/src/store/mini-skill-store.ts +349 -349
  151. package/src/store/obs-store.ts +255 -255
  152. package/src/store/persistence-json.ts +212 -212
  153. package/src/store/persistence.ts +291 -291
  154. package/src/store/project-affinity.ts +195 -195
  155. package/src/store/session-store.ts +259 -259
  156. package/src/store/sqlite-store.ts +339 -339
  157. package/src/team/event-bus.ts +76 -76
  158. package/src/team/file-locks.ts +173 -173
  159. package/src/team/handoff.ts +167 -167
  160. package/src/team/messages.ts +203 -203
  161. package/src/team/poll.ts +132 -132
  162. package/src/team/tasks.ts +211 -211
  163. package/src/wiki/generator.ts +237 -237
  164. package/src/wiki/knowledge-graph.ts +334 -334
  165. package/src/wiki/types.ts +85 -85
  166. package/src/workspace/mcp-adapters/codex.ts +191 -191
  167. package/src/workspace/mcp-adapters/copilot.ts +105 -105
  168. package/src/workspace/mcp-adapters/cursor.ts +53 -53
  169. package/src/workspace/mcp-adapters/kiro.ts +64 -64
  170. package/src/workspace/mcp-adapters/opencode.ts +123 -123
  171. package/src/workspace/mcp-adapters/trae.ts +134 -134
  172. package/src/workspace/mcp-adapters/windsurf.ts +91 -91
  173. package/src/workspace/sanitizer.ts +60 -60
  174. package/src/workspace/workflow-sync.ts +131 -131
package/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.1.8] - 2026-07-08
6
+
7
+ ### Added
8
+ - **Agent integration doctor and repair** -- Added `memorix doctor agents` and `memorix repair agents` to inspect and repair Memorix-owned agent integration files. The doctor flags stale MCP command paths, missing Claude `alwaysLoad`, missing `memorix` MCP entries, and outdated Memory Autopilot guidance without printing environment secrets.
9
+
10
+ ### Changed
11
+ - **Memory Autopilot adoption** -- Setup-generated agent guidance now makes `memorix_project_context` the default first step for non-trivial coding work before progress files, dev logs, broad file reads, or git archaeology.
12
+
13
+ ### Fixed
14
+ - **Claude Code local MCP repair** -- `memorix doctor agents` and `memorix repair agents` now inspect and repair Claude Code 2.x project-private local MCP entries in `~/.claude.json`, replacing stale worktree commands with `memorix serve` and `alwaysLoad: true`.
15
+ - **Cleaner CodeGraph Memory briefs** -- CodeGraph Lite and Memory Autopilot now ignore `.tmp`, nested `.worktrees`, and `.claude/worktrees` directories, so suggested reads point at the real project instead of local caches or agent scratch worktrees.
16
+ - **All-scope doctor noise** -- Agent doctor now treats one healthy local, project, or global scope as sufficient in all-scope mode, while still flagging genuinely stale or repairable configs.
17
+
5
18
  ## [1.1.7] - 2026-07-07
6
19
 
7
20
  ### Added
package/CLAUDE.md CHANGED
@@ -7,9 +7,14 @@ You have access to Memorix, an open-source cross-agent memory layer for coding a
7
7
  This project has Memorix MCP tools available for persistent cross-session memory.
8
8
 
9
9
  For broad continuation or a fresh handoff, start with Memory Autopilot before
10
- ad-hoc file reads:
10
+ progress files, dev-log reads, ad-hoc file reads, or git archaeology:
11
11
 
12
12
  - MCP: `memorix_project_context` with the current task
13
+ - Default first step for non-trivial coding work: call
14
+ `memorix_project_context` with the user's actual task. Memorix will choose a
15
+ task-lensed brief (bugfix, feature, release, onboarding, refactor, docs, test,
16
+ or general). Treat its "Start here" files as the first project files to
17
+ inspect.
13
18
  - Claude Code exposes MCP tools through dynamic tool loading. If the tool is not
14
19
  directly visible in the first tool list, search/select the Memorix project
15
20
  context tool before using shell fallback.
package/README.md CHANGED
@@ -24,6 +24,7 @@
24
24
  <p align="center">
25
25
  <a href="README.zh-CN.md">Chinese</a> |
26
26
  <a href="#install">Install</a> |
27
+ <a href="#capabilities">Capabilities</a> |
27
28
  <a href="#works-with-your-agent">Agents</a> |
28
29
  <a href="#quick-start">Quick Start</a> |
29
30
  <a href="#memory-model">Memory Model</a> |
@@ -52,6 +53,25 @@ Use Claude Code today, Codex tomorrow, and Cursor in the afternoon. The agent ca
52
53
 
53
54
  Memorix is local-first. SQLite is the canonical store, Orama handles search, and LLM-backed formation/embedding is optional. Without model keys, Memorix still works with local full-text retrieval.
54
55
 
56
+ ### Capabilities
57
+
58
+ Memorix is more than a memory store. It also installs agent integrations, keeps useful work events, turns commits into project facts, exposes a local control plane, and can coordinate multi-agent work when a task needs it.
59
+
60
+ | Capability | What it does | Entry point |
61
+ | --- | --- | --- |
62
+ | Memory Autopilot | A task-shaped project brief for a new agent session, with start files, trusted memories, cautions, and verification hints | `memorix context --task "..."`, `memorix_project_context` |
63
+ | Observation Memory | Searchable facts, fixes, gotchas, session summaries, and implementation notes scoped to the current Git project | `memorix memory`, MCP memory tools |
64
+ | Code Memory | File/symbol links and freshness checks so old memories point to current code or show up as suspect/stale | `memorix codegraph`, automatic context refresh |
65
+ | Git Memory | Commit-derived engineering facts that answer what changed, where, and why it matters | `memorix ingest commit`, git hook |
66
+ | Reasoning Memory | Design rationale, alternatives, trade-offs, and risks that should survive beyond one chat | `memorix reasoning`, memory formation |
67
+ | Agent setup | One setup path for MCP, rules, hooks, skills, plugins, bundles, or extensions depending on the agent | `memorix setup --agent <agent>` |
68
+ | Agent doctor | Checks whether agent MCP config and guidance are current, then repairs Memorix-owned entries when needed | `memorix doctor agents`, `memorix repair agents` |
69
+ | Hooks and skills | Optional capture from supported agents, plus reusable project skills promoted from durable knowledge | `memorix hooks`, `memorix skills` |
70
+ | Dashboard and HTTP | A local web UI and shared MCP endpoint for browsing memory, project state, teams, and diagnostics | `memorix dashboard`, `memorix background start` |
71
+ | Orchestration and team work | Task planning, worker handoffs, file locks, messages, verification gates, and review loops | `memorix orchestrate`, `memorix team`, `memorix lock` |
72
+ | memcode | A bundled terminal coding agent that already reads and writes the same project memory | `memorix`, `memcode` |
73
+ | CLI and SDK | Scriptable access for automation, imports/exports, diagnostics, and custom integrations | `memorix ...`, `createMemoryClient()` |
74
+
55
75
  <h2 id="works-with-your-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-agents.svg"><img src="assets/tags/section-agents.svg" alt="Works with every agent" height="32" /></picture></h2>
56
76
 
57
77
  Memorix connects through the interfaces each agent already supports: plugin packages, MCP, project rules, hooks, skills, or the bundled terminal agent. `memorix setup` chooses the right setup for each agent and keeps stdio MCP as the default transport.
@@ -330,6 +350,7 @@ Search is project-scoped by default. `scope="global"` searches across projects.
330
350
  | You want | Run |
331
351
  | --- | --- |
332
352
  | Install an agent integration package | `memorix setup --agent <agent> --global` |
353
+ | Check or repair an agent integration | `memorix doctor agents --agent <agent>`, `memorix repair agents --agent <agent>` |
333
354
  | Manually expose stdio MCP | `memorix serve` |
334
355
  | Run shared HTTP MCP plus dashboard | `memorix background start` |
335
356
  | Debug HTTP MCP in the foreground | `memorix serve-http --port 3211` |
package/README.zh-CN.md CHANGED
@@ -24,6 +24,7 @@
24
24
  <p align="center">
25
25
  <a href="README.md">English</a> |
26
26
  <a href="#安装">安装</a> |
27
+ <a href="#能力矩阵">能力矩阵</a> |
27
28
  <a href="#支持你的-agent">Agents</a> |
28
29
  <a href="#快速开始">快速开始</a> |
29
30
  <a href="#记忆模型">记忆模型</a> |
@@ -52,6 +53,25 @@ Memorix 给你已经在用的 AI 编程 Agent 加上一套共享、可检索的
52
53
 
53
54
  Memorix 是本地优先的。SQLite 是权威存储,Orama 负责搜索,LLM 记忆整理和 embedding 是可选能力。没有模型 key 时,Memorix 仍然可以用本地全文检索工作。
54
55
 
56
+ ### 能力矩阵
57
+
58
+ Memorix 不只是一个记忆库。它还负责安装 Agent 接入、保留有用的工作事件、把 commit 转成工程事实、提供本地控制面,并在需要时协调多 Agent 工作。
59
+
60
+ | 能力 | 作用 | 入口 |
61
+ | --- | --- | --- |
62
+ | Memory Autopilot | 给新 Agent session 一份按当前任务整理的项目 brief,包含起步文件、可信记忆、风险提示和验证建议 | `memorix context --task "..."`、`memorix_project_context` |
63
+ | Observation Memory | 当前 Git 项目内可检索的事实、修复、坑点、session 摘要和实现记录 | `memorix memory`、MCP memory tools |
64
+ | Code Memory | 文件 / symbol 关联和 freshness 检查;旧记忆会指向当前代码,或标记为 suspect/stale | `memorix codegraph`、自动 context refresh |
65
+ | Git Memory | 从 commit 中提取工程事实,回答改了什么、在哪里改、为什么重要 | `memorix ingest commit`、git hook |
66
+ | Reasoning Memory | 保存设计原因、备选方案、trade-off 和风险,不让决策只留在一次聊天里 | `memorix reasoning`、memory formation |
67
+ | Agent setup | 按目标 Agent 写入 MCP、rules、hooks、skills、plugin、bundle 或 extension | `memorix setup --agent <agent>` |
68
+ | Agent doctor | 检查 Agent 的 MCP 配置和规则是否是当前版本,并修复 Memorix 自己管理的条目 | `memorix doctor agents`、`memorix repair agents` |
69
+ | Hooks 和 skills | 在支持的 Agent 中可选捕获工作事件,并把稳定知识提升成可复用项目技能 | `memorix hooks`、`memorix skills` |
70
+ | Dashboard 和 HTTP | 本地 Web UI 与共享 MCP endpoint,用于浏览记忆、项目状态、团队和诊断信息 | `memorix dashboard`、`memorix background start` |
71
+ | Orchestration 和团队协作 | 任务规划、worker 交接、文件锁、消息、验证门和 review loop | `memorix orchestrate`、`memorix team`、`memorix lock` |
72
+ | memcode | 内置终端 Coding Agent,默认读写同一套项目记忆 | `memorix`、`memcode` |
73
+ | CLI 和 SDK | 给自动化、导入导出、诊断和自定义集成使用的本地接口 | `memorix ...`、`createMemoryClient()` |
74
+
55
75
  <h2 id="支持你的-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-agents.svg"><img src="assets/tags/section-agents.svg" alt="Works with every agent" height="32" /></picture></h2>
56
76
 
57
77
  Memorix 通过目标 Agent 已有的接口接入:插件包、MCP、项目规则、hooks、skills,或者内置终端 Agent。`memorix setup` 会为每个 Agent 选择合适的接入方式,默认使用 stdio MCP。
@@ -330,6 +350,7 @@ memcode
330
350
  | 你想做什么 | 运行 |
331
351
  | --- | --- |
332
352
  | 安装某个 Agent 的接入包 | `memorix setup --agent <agent> --global` |
353
+ | 检查或修复某个 Agent 接入 | `memorix doctor agents --agent <agent>`、`memorix repair agents --agent <agent>` |
333
354
  | 手动暴露 stdio MCP | `memorix serve` |
334
355
  | 启动共享 HTTP MCP 和 Dashboard | `memorix background start` |
335
356
  | 前台调试 HTTP MCP | `memorix serve-http --port 3211` |
package/TEAM.md CHANGED
@@ -1,18 +1,18 @@
1
- # Memorix Team Protocol
2
-
1
+ # Memorix Team Protocol
2
+
3
3
  Rules for project-scoped autonomous-agent coordination via Memorix team tools. The Team page is an **Agent Team status surface** — it shows explicitly joined autonomous agents, open tasks, locks, messages, handoffs, and what needs attention. It is NOT an organization backend, staffing admin tool, or automatic chat room between separate IDE windows.
4
4
 
5
5
  Only agents that are intentionally participating in team/task/message/lock workflows need this protocol. Memory-only sessions should stay lightweight and do not need a team identity.
6
6
 
7
7
  For real autonomous multi-agent development, prefer `memorix orchestrate`: it launches and supervises CLI agent workers through Memorix tasks, context, verification, and fix loops. The team tools support that workflow; they should not be interpreted as proof that unrelated IDE conversation windows can autonomously contact each other.
8
-
9
- There are 4 team tools, each with an `action` parameter:
10
-
11
- - `team_manage` — action: join / leave / status
12
- - `team_file_lock` — action: lock / unlock / status
13
- - `team_task` — action: create / claim / complete / list
14
- - `team_message` — action: send / broadcast / inbox
15
-
8
+
9
+ There are 4 team tools, each with an `action` parameter:
10
+
11
+ - `team_manage` — action: join / leave / status
12
+ - `team_file_lock` — action: lock / unlock / status
13
+ - `team_task` — action: create / claim / complete / list
14
+ - `team_message` — action: send / broadcast / inbox
15
+
16
16
  ## RULE 1: Start Lightweight, Join Team Explicitly
17
17
 
18
18
  At the **beginning of every memory session**, before project-scoped memory work:
@@ -25,82 +25,82 @@ At the **beginning of every memory session**, before project-scoped memory work:
25
25
  4. Store the returned **agent ID** only after an explicit join — you will need it for subsequent team operations.
26
26
  5. Call `memorix_poll` with your agent ID to see current autonomous agents, check available tasks, and read unread messages.
27
27
  6. If you need a custom role or capabilities, use explicit `team_manage(join)` so the role overrides the default mapping cleanly.
28
-
29
- ## RULE 2: Lock Before Edit
30
-
31
- Before modifying any file that another agent might also be working on:
32
-
33
- 1. Call `team_file_lock` with `action: "status"` and the file path to check if it is already locked.
34
- 2. If unlocked, call `team_file_lock` with `action: "lock"`, the file path, and your agent ID.
35
- 3. If locked by another agent, **do not edit that file**. Either:
36
- - Work on a different file.
37
- - Send a `request` message to the lock owner asking them to release it.
38
- - Wait and re-check later.
39
- 4. When you are done editing, call `team_file_lock` with `action: "unlock"` to release the lock.
40
-
41
- **Never edit a file locked by another agent.** Lock violations cause merge conflicts and data loss.
42
-
43
- Locks auto-expire after 10 minutes. If you hold a lock for extended work, re-lock periodically to refresh the TTL.
44
-
45
- ## RULE 3: Use Tasks for Work Coordination
46
-
47
- When the user assigns work that involves multiple agents or multiple steps:
48
-
49
- 1. Call `team_task` with `action: "create"` to break the work into discrete tasks with clear descriptions.
50
- 2. Use `deps` to declare dependencies between tasks (a task cannot be claimed until its dependencies are completed).
51
- 3. Call `team_task` with `action: "claim"` to assign a task to yourself before starting work on it.
52
- 4. Call `team_task` with `action: "complete"` and a `result` summary when the task is done.
53
- 5. Call `team_task` with `action: "list"` to see overall progress and find available work.
54
-
55
- Rules:
56
- - Only claim tasks whose dependencies are all completed.
57
- - Only one agent may claim a given task.
58
- - If you cannot complete a claimed task, leave the team so the task returns to pending and another agent can pick it up.
59
-
60
- ## RULE 4: Communication Protocol
61
-
62
- Use `team_message` with `action: "send"` for direct messages and `action: "broadcast"` for announcements. Message types and their intended use:
63
-
64
- | Type | Use |
65
- |------|-----|
66
- | `request` | Ask another agent to do something, release a lock, or provide information. |
67
- | `response` | Reply to a prior request. |
68
- | `info` | Share context: discoveries, status updates, warnings about tricky code. |
69
- | `announcement` | Broadcast to all agents: major state changes, deployment events, breaking changes. |
70
- | `contract` | Propose or agree on a division of work. Both agents should acknowledge. |
71
- | `error` | Report a blocking issue that requires another agent's attention. |
72
-
73
- Rules:
74
- - `action: "send"` requires the full UUID of the target agent. Get it from `team_manage` with `action: "status"`.
75
- - Check your inbox (`action: "inbox"`) at least once before starting new work and once before ending a session.
76
- - Keep message content under 10KB. Be concise and actionable.
77
-
78
- ## RULE 5: Leave on Session End
79
-
80
- When the session is ending:
81
-
82
- 1. Call `team_file_lock` with `action: "unlock"` for every file you have locked, or they will remain locked until TTL expiry (10 min).
83
- 2. If you have in-progress tasks you cannot finish, leave them — leaving releases your tasks back to pending.
84
- 3. Call `team_manage` with `action: "leave"` and your agent ID. This marks you inactive, releases all your locks, and clears your inbox.
85
-
86
- ## RULE 6: Conflict Prevention
87
-
88
- - **Check before acting.** Always check team status and file lock status before starting work to understand the current state.
89
- - **Communicate before diverging.** If you plan to refactor shared code, broadcast an `announcement` first so other agents can save their work.
90
- - **Respect lock ownership.** The lock holder has exclusive write access. No exceptions.
91
- - **Prefer small, scoped changes.** Large cross-cutting changes increase conflict risk. Coordinate via tasks and messages if a change touches files other agents are working on.
92
- - **Do not duplicate work.** Check the task list before creating new tasks. If a similar task exists, claim it instead of creating a duplicate.
93
-
94
- ## Summary of Required Calls
95
-
96
- | When | Tool Call |
97
- |------|-----------|
28
+
29
+ ## RULE 2: Lock Before Edit
30
+
31
+ Before modifying any file that another agent might also be working on:
32
+
33
+ 1. Call `team_file_lock` with `action: "status"` and the file path to check if it is already locked.
34
+ 2. If unlocked, call `team_file_lock` with `action: "lock"`, the file path, and your agent ID.
35
+ 3. If locked by another agent, **do not edit that file**. Either:
36
+ - Work on a different file.
37
+ - Send a `request` message to the lock owner asking them to release it.
38
+ - Wait and re-check later.
39
+ 4. When you are done editing, call `team_file_lock` with `action: "unlock"` to release the lock.
40
+
41
+ **Never edit a file locked by another agent.** Lock violations cause merge conflicts and data loss.
42
+
43
+ Locks auto-expire after 10 minutes. If you hold a lock for extended work, re-lock periodically to refresh the TTL.
44
+
45
+ ## RULE 3: Use Tasks for Work Coordination
46
+
47
+ When the user assigns work that involves multiple agents or multiple steps:
48
+
49
+ 1. Call `team_task` with `action: "create"` to break the work into discrete tasks with clear descriptions.
50
+ 2. Use `deps` to declare dependencies between tasks (a task cannot be claimed until its dependencies are completed).
51
+ 3. Call `team_task` with `action: "claim"` to assign a task to yourself before starting work on it.
52
+ 4. Call `team_task` with `action: "complete"` and a `result` summary when the task is done.
53
+ 5. Call `team_task` with `action: "list"` to see overall progress and find available work.
54
+
55
+ Rules:
56
+ - Only claim tasks whose dependencies are all completed.
57
+ - Only one agent may claim a given task.
58
+ - If you cannot complete a claimed task, leave the team so the task returns to pending and another agent can pick it up.
59
+
60
+ ## RULE 4: Communication Protocol
61
+
62
+ Use `team_message` with `action: "send"` for direct messages and `action: "broadcast"` for announcements. Message types and their intended use:
63
+
64
+ | Type | Use |
65
+ |------|-----|
66
+ | `request` | Ask another agent to do something, release a lock, or provide information. |
67
+ | `response` | Reply to a prior request. |
68
+ | `info` | Share context: discoveries, status updates, warnings about tricky code. |
69
+ | `announcement` | Broadcast to all agents: major state changes, deployment events, breaking changes. |
70
+ | `contract` | Propose or agree on a division of work. Both agents should acknowledge. |
71
+ | `error` | Report a blocking issue that requires another agent's attention. |
72
+
73
+ Rules:
74
+ - `action: "send"` requires the full UUID of the target agent. Get it from `team_manage` with `action: "status"`.
75
+ - Check your inbox (`action: "inbox"`) at least once before starting new work and once before ending a session.
76
+ - Keep message content under 10KB. Be concise and actionable.
77
+
78
+ ## RULE 5: Leave on Session End
79
+
80
+ When the session is ending:
81
+
82
+ 1. Call `team_file_lock` with `action: "unlock"` for every file you have locked, or they will remain locked until TTL expiry (10 min).
83
+ 2. If you have in-progress tasks you cannot finish, leave them — leaving releases your tasks back to pending.
84
+ 3. Call `team_manage` with `action: "leave"` and your agent ID. This marks you inactive, releases all your locks, and clears your inbox.
85
+
86
+ ## RULE 6: Conflict Prevention
87
+
88
+ - **Check before acting.** Always check team status and file lock status before starting work to understand the current state.
89
+ - **Communicate before diverging.** If you plan to refactor shared code, broadcast an `announcement` first so other agents can save their work.
90
+ - **Respect lock ownership.** The lock holder has exclusive write access. No exceptions.
91
+ - **Prefer small, scoped changes.** Large cross-cutting changes increase conflict risk. Coordinate via tasks and messages if a change touches files other agents are working on.
92
+ - **Do not duplicate work.** Check the task list before creating new tasks. If a similar task exists, claim it instead of creating a duplicate.
93
+
94
+ ## Summary of Required Calls
95
+
96
+ | When | Tool Call |
97
+ |------|-----------|
98
98
  | Session start | `memorix_session_start` (lightweight) |
99
99
  | Join Agent Team | `memorix_session_start(joinTeam=true)` or `team_manage(join)` |
100
100
  | After joining | `memorix_poll` (check status + inbox) |
101
- | Before editing a shared file | `team_file_lock(status)`, `team_file_lock(lock)` |
102
- | After editing | `team_file_lock(unlock)` |
103
- | Starting a unit of work | `team_task(claim)` or `team_task(create)` + `team_task(claim)` |
104
- | Finishing a unit of work | `team_task(complete)` |
105
- | Need to coordinate | `team_message(send)` or `team_message(broadcast)` |
106
- | Session end | `team_file_lock(unlock)` (all), `team_manage(leave)` |
101
+ | Before editing a shared file | `team_file_lock(status)`, `team_file_lock(lock)` |
102
+ | After editing | `team_file_lock(unlock)` |
103
+ | Starting a unit of work | `team_task(claim)` or `team_task(create)` + `team_task(claim)` |
104
+ | Finishing a unit of work | `team_task(complete)` |
105
+ | Need to coordinate | `team_message(send)` or `team_message(broadcast)` |
106
+ | Session end | `team_file_lock(unlock)` (all), `team_manage(leave)` |