mixdog 0.7.1

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 (404) hide show
  1. package/.claude-plugin/marketplace.json +31 -0
  2. package/.claude-plugin/plugin.json +20 -0
  3. package/.gitattributes +34 -0
  4. package/.mcp.json +14 -0
  5. package/ARCHITECTURE.md +77 -0
  6. package/CHANGELOG.md +7 -0
  7. package/CONTRIBUTING.md +45 -0
  8. package/DATA-FLOW.md +79 -0
  9. package/LICENSE +21 -0
  10. package/README.md +389 -0
  11. package/SECURITY.md +138 -0
  12. package/UNINSTALL.md +112 -0
  13. package/agents/maintenance.md +5 -0
  14. package/agents/memory-classification.md +30 -0
  15. package/agents/scheduler-task.md +18 -0
  16. package/agents/webhook-handler.md +27 -0
  17. package/agents/worker.md +24 -0
  18. package/bin/bridge +133 -0
  19. package/bin/statusline-launcher.mjs +78 -0
  20. package/bin/statusline-lib.mjs +550 -0
  21. package/bin/statusline.mjs +607 -0
  22. package/bun.lock +802 -0
  23. package/commands/config.md +16 -0
  24. package/commands/doctor.md +13 -0
  25. package/commands/setup.md +17 -0
  26. package/defaults/cycle3-review-prompt.md +90 -0
  27. package/defaults/hidden-roles.json +65 -0
  28. package/defaults/memory-chunk-prompt.md +63 -0
  29. package/defaults/memory-promote-prompt.md +135 -0
  30. package/defaults/mixdog-config.template.json +27 -0
  31. package/defaults/user-workflow.json +8 -0
  32. package/defaults/user-workflow.md +12 -0
  33. package/hooks/hooks.json +73 -0
  34. package/hooks/lib/active-instance.cjs +77 -0
  35. package/hooks/lib/permission-evaluator.cjs +411 -0
  36. package/hooks/lib/permission-route.cjs +63 -0
  37. package/hooks/lib/permission-rules.cjs +170 -0
  38. package/hooks/lib/settings-loader.cjs +116 -0
  39. package/hooks/post-tool-use.cjs +84 -0
  40. package/hooks/pre-mcp-sandbox.cjs +158 -0
  41. package/hooks/pre-tool-subagent.cjs +253 -0
  42. package/hooks/session-start.cjs +1372 -0
  43. package/hooks/turn-timer.cjs +82 -0
  44. package/lib/claude-md-writer.cjs +386 -0
  45. package/lib/config-cjs.cjs +61 -0
  46. package/lib/hook-pipe-path.cjs +10 -0
  47. package/lib/keychain-cjs.cjs +263 -0
  48. package/lib/plugin-paths.cjs +61 -0
  49. package/lib/rules-builder.cjs +241 -0
  50. package/lib/text-utils.cjs +61 -0
  51. package/native/README.md +117 -0
  52. package/native/prebuilt/linux-aarch64/mixdog-shim +0 -0
  53. package/native/prebuilt/linux-x86_64/mixdog-shim +0 -0
  54. package/native/prebuilt/macos-aarch64/mixdog-shim +0 -0
  55. package/native/prebuilt/macos-x86_64/mixdog-shim +0 -0
  56. package/native/prebuilt/windows-x86_64/mixdog-shim.exe +0 -0
  57. package/package.json +107 -0
  58. package/prompts/code-review.txt +16 -0
  59. package/prompts/security-audit.txt +17 -0
  60. package/rules/bridge/00-common.md +39 -0
  61. package/rules/bridge/20-skip-protocol.md +18 -0
  62. package/rules/bridge/30-explorer.md +33 -0
  63. package/rules/bridge/40-cycle1-agent.md +52 -0
  64. package/rules/bridge/41-cycle2-agent.md +62 -0
  65. package/rules/bridge/42-cycle3-agent.md +44 -0
  66. package/rules/lead/00-tool-lead.md +61 -0
  67. package/rules/lead/01-general.md +23 -0
  68. package/rules/lead/02-channels.md +49 -0
  69. package/rules/lead/03-team.md +27 -0
  70. package/rules/lead/04-workflow.md +20 -0
  71. package/rules/shared/00-language.md +14 -0
  72. package/rules/shared/01-tool.md +138 -0
  73. package/scripts/bootstrap.mjs +184 -0
  74. package/scripts/bridge-unify-smoke.mjs +308 -0
  75. package/scripts/build-runtime-linux.sh +348 -0
  76. package/scripts/build-runtime-macos.sh +217 -0
  77. package/scripts/build-runtime-windows.ps1 +242 -0
  78. package/scripts/builtin-utils-smoke.mjs +392 -0
  79. package/scripts/check-json.mjs +45 -0
  80. package/scripts/check-syntax-changed.mjs +102 -0
  81. package/scripts/check-syntax.mjs +58 -0
  82. package/scripts/code-graph-batch.test.mjs +33 -0
  83. package/scripts/config-preserve-smoke.mjs +180 -0
  84. package/scripts/doctor.mjs +484 -0
  85. package/scripts/edit-normalize-fuzz.mjs +130 -0
  86. package/scripts/edit-normalize-smoke.mjs +401 -0
  87. package/scripts/edit-operation-smoke.mjs +369 -0
  88. package/scripts/edit2-smoke.mjs +63 -0
  89. package/scripts/fuzzy-e2e.mjs +28 -0
  90. package/scripts/fuzzy-smoke.mjs +26 -0
  91. package/scripts/generate-runtime-manifest.mjs +166 -0
  92. package/scripts/guard-smoke.mjs +66 -0
  93. package/scripts/hidden-role-schema-smoke.mjs +162 -0
  94. package/scripts/hook-routing-smoke.mjs +29 -0
  95. package/scripts/inject-input.ps1 +204 -0
  96. package/scripts/io-complex-smoke.mjs +667 -0
  97. package/scripts/io-explore-bench.mjs +424 -0
  98. package/scripts/io-guardrails-smoke.mjs +205 -0
  99. package/scripts/io-mini-bench-baseline.json +11 -0
  100. package/scripts/io-mini-bench.mjs +216 -0
  101. package/scripts/io-route-harness.mjs +933 -0
  102. package/scripts/io-telemetry-report.mjs +691 -0
  103. package/scripts/mutation-bench.mjs +564 -0
  104. package/scripts/mutation-io-smoke.mjs +1081 -0
  105. package/scripts/native-patch-bridge-smoke.mjs +288 -0
  106. package/scripts/native-patch-smoke.mjs +304 -0
  107. package/scripts/patch-interior-context-smoke.mjs +49 -0
  108. package/scripts/patch-newline-utf8-smoke.mjs +157 -0
  109. package/scripts/perf-hook-smoke.mjs +71 -0
  110. package/scripts/permission-eval-smoke.mjs +426 -0
  111. package/scripts/prep-patch.mjs +53 -0
  112. package/scripts/prep-shim.mjs +96 -0
  113. package/scripts/provider-cache-smoke.mjs +687 -0
  114. package/scripts/report-runtime-health.mjs +132 -0
  115. package/scripts/run-mcp.mjs +1547 -0
  116. package/scripts/salvage-v4a-shatter.test.mjs +58 -0
  117. package/scripts/scoped-cache-io-smoke.mjs +103 -0
  118. package/scripts/shell-policy-round3-smoke.mjs +46 -0
  119. package/scripts/smoke-runtime-negative.ps1 +100 -0
  120. package/scripts/smoke-runtime-negative.sh +95 -0
  121. package/scripts/stall-policy-smoke.mjs +50 -0
  122. package/scripts/start-memory-worker.mjs +23 -0
  123. package/scripts/statusline-launcher-smoke.mjs +82 -0
  124. package/scripts/stress-atomic-write.mjs +1028 -0
  125. package/scripts/test-config-rmw-restore.mjs +122 -0
  126. package/scripts/test-fault-inject.mjs +164 -0
  127. package/scripts/test-large-file.mjs +174 -0
  128. package/scripts/tool-edge-smoke.mjs +209 -0
  129. package/scripts/uninstall.mjs +201 -0
  130. package/scripts/webhook-selfheal-smoke.mjs +29 -0
  131. package/scripts/write-overwrite-guard-smoke.mjs +56 -0
  132. package/server-main.mjs +3055 -0
  133. package/server.mjs +468 -0
  134. package/setup/config-merge.mjs +254 -0
  135. package/setup/install.mjs +120 -0
  136. package/setup/launch-core.mjs +507 -0
  137. package/setup/launch.mjs +101 -0
  138. package/setup/setup-server.mjs +3206 -0
  139. package/setup/setup.html +3693 -0
  140. package/skills/retro-skill-proposer/SKILL.md +92 -0
  141. package/skills/schedule-add/SKILL.md +77 -0
  142. package/skills/setup/SKILL.md +346 -0
  143. package/skills/webhook-add/SKILL.md +81 -0
  144. package/src/agent/bridge-stall-watchdog.mjs +337 -0
  145. package/src/agent/index.mjs +2138 -0
  146. package/src/agent/orchestrator/activity-bus.mjs +38 -0
  147. package/src/agent/orchestrator/ai-wrapped-dispatch.mjs +1010 -0
  148. package/src/agent/orchestrator/bridge-retry.mjs +220 -0
  149. package/src/agent/orchestrator/bridge-trace.mjs +583 -0
  150. package/src/agent/orchestrator/cache-mtime.mjs +58 -0
  151. package/src/agent/orchestrator/config.mjs +358 -0
  152. package/src/agent/orchestrator/context/collect.mjs +651 -0
  153. package/src/agent/orchestrator/dispatch-persist.mjs +549 -0
  154. package/src/agent/orchestrator/drain-registry.mjs +50 -0
  155. package/src/agent/orchestrator/explore-validator.mjs +8 -0
  156. package/src/agent/orchestrator/internal-roles.mjs +118 -0
  157. package/src/agent/orchestrator/internal-tools.mjs +88 -0
  158. package/src/agent/orchestrator/jobs.mjs +116 -0
  159. package/src/agent/orchestrator/mcp/client.mjs +364 -0
  160. package/src/agent/orchestrator/providers/anthropic-betas.mjs +21 -0
  161. package/src/agent/orchestrator/providers/anthropic-oauth.mjs +1745 -0
  162. package/src/agent/orchestrator/providers/anthropic.mjs +437 -0
  163. package/src/agent/orchestrator/providers/gemini.mjs +1175 -0
  164. package/src/agent/orchestrator/providers/grok-oauth.mjs +782 -0
  165. package/src/agent/orchestrator/providers/model-catalog.mjs +241 -0
  166. package/src/agent/orchestrator/providers/openai-compat.mjs +1467 -0
  167. package/src/agent/orchestrator/providers/openai-oauth-ws.mjs +1890 -0
  168. package/src/agent/orchestrator/providers/openai-oauth.mjs +1307 -0
  169. package/src/agent/orchestrator/providers/openai-ws.mjs +104 -0
  170. package/src/agent/orchestrator/providers/registry.mjs +192 -0
  171. package/src/agent/orchestrator/providers/retry-classifier.mjs +325 -0
  172. package/src/agent/orchestrator/session/abort-lookup.mjs +13 -0
  173. package/src/agent/orchestrator/session/cache/post-edit-marks.mjs +42 -0
  174. package/src/agent/orchestrator/session/cache/prefetch-cache.mjs +142 -0
  175. package/src/agent/orchestrator/session/cache/read-cache.mjs +319 -0
  176. package/src/agent/orchestrator/session/cache/scoped-cache-outcome.mjs +11 -0
  177. package/src/agent/orchestrator/session/cache/scoped-cache.mjs +361 -0
  178. package/src/agent/orchestrator/session/cache/util.mjs +49 -0
  179. package/src/agent/orchestrator/session/loop.mjs +1478 -0
  180. package/src/agent/orchestrator/session/manager.mjs +1975 -0
  181. package/src/agent/orchestrator/session/read-dedup.mjs +6 -0
  182. package/src/agent/orchestrator/session/result-classification.mjs +65 -0
  183. package/src/agent/orchestrator/session/save-session-worker.mjs +18 -0
  184. package/src/agent/orchestrator/session/store.mjs +624 -0
  185. package/src/agent/orchestrator/session/stream-watchdog.mjs +130 -0
  186. package/src/agent/orchestrator/session/tool-result-offload.mjs +166 -0
  187. package/src/agent/orchestrator/session/trim.mjs +491 -0
  188. package/src/agent/orchestrator/smart-bridge/CACHE-SHARD.md +115 -0
  189. package/src/agent/orchestrator/smart-bridge/bridge-llm.mjs +327 -0
  190. package/src/agent/orchestrator/smart-bridge/cache-obs.mjs +150 -0
  191. package/src/agent/orchestrator/smart-bridge/cache-strategy.mjs +228 -0
  192. package/src/agent/orchestrator/smart-bridge/index.mjs +215 -0
  193. package/src/agent/orchestrator/smart-bridge/profiles.mjs +37 -0
  194. package/src/agent/orchestrator/smart-bridge/registry.mjs +348 -0
  195. package/src/agent/orchestrator/smart-bridge/session-builder.mjs +116 -0
  196. package/src/agent/orchestrator/stall-policy.mjs +195 -0
  197. package/src/agent/orchestrator/tool-loop-guard.mjs +75 -0
  198. package/src/agent/orchestrator/tools/bash-policy-scan.mjs +77 -0
  199. package/src/agent/orchestrator/tools/bash-session.mjs +721 -0
  200. package/src/agent/orchestrator/tools/builtin/advisory-lock.mjs +171 -0
  201. package/src/agent/orchestrator/tools/builtin/arg-guard.mjs +455 -0
  202. package/src/agent/orchestrator/tools/builtin/atomic-write.mjs +236 -0
  203. package/src/agent/orchestrator/tools/builtin/bash-tool.mjs +480 -0
  204. package/src/agent/orchestrator/tools/builtin/binary-file.mjs +76 -0
  205. package/src/agent/orchestrator/tools/builtin/builtin-tools.mjs +256 -0
  206. package/src/agent/orchestrator/tools/builtin/cache-layers.mjs +386 -0
  207. package/src/agent/orchestrator/tools/builtin/cwd-utils.mjs +37 -0
  208. package/src/agent/orchestrator/tools/builtin/device-paths.mjs +154 -0
  209. package/src/agent/orchestrator/tools/builtin/diagnostics-tool.mjs +292 -0
  210. package/src/agent/orchestrator/tools/builtin/diff-utils.mjs +109 -0
  211. package/src/agent/orchestrator/tools/builtin/edit-base-guard.mjs +58 -0
  212. package/src/agent/orchestrator/tools/builtin/edit-byte-plan.mjs +240 -0
  213. package/src/agent/orchestrator/tools/builtin/edit-byte-utils.mjs +113 -0
  214. package/src/agent/orchestrator/tools/builtin/edit-commit.mjs +74 -0
  215. package/src/agent/orchestrator/tools/builtin/edit-context-utils.mjs +242 -0
  216. package/src/agent/orchestrator/tools/builtin/edit-diagnostics.mjs +211 -0
  217. package/src/agent/orchestrator/tools/builtin/edit-engine.mjs +1364 -0
  218. package/src/agent/orchestrator/tools/builtin/edit-failure-context.mjs +126 -0
  219. package/src/agent/orchestrator/tools/builtin/edit-hint.mjs +141 -0
  220. package/src/agent/orchestrator/tools/builtin/edit-match-utils.mjs +194 -0
  221. package/src/agent/orchestrator/tools/builtin/edit-partial-write.mjs +60 -0
  222. package/src/agent/orchestrator/tools/builtin/edit-stale-refresh.mjs +168 -0
  223. package/src/agent/orchestrator/tools/builtin/edit-tool.mjs +173 -0
  224. package/src/agent/orchestrator/tools/builtin/edit-utf8-guard.mjs +48 -0
  225. package/src/agent/orchestrator/tools/builtin/fs-reachability.mjs +48 -0
  226. package/src/agent/orchestrator/tools/builtin/fuzzy-match.mjs +99 -0
  227. package/src/agent/orchestrator/tools/builtin/glob-walk.mjs +170 -0
  228. package/src/agent/orchestrator/tools/builtin/grep-formatting.mjs +113 -0
  229. package/src/agent/orchestrator/tools/builtin/hash-utils.mjs +6 -0
  230. package/src/agent/orchestrator/tools/builtin/list-formatting.mjs +7 -0
  231. package/src/agent/orchestrator/tools/builtin/list-tool.mjs +593 -0
  232. package/src/agent/orchestrator/tools/builtin/native-edit-runner.mjs +89 -0
  233. package/src/agent/orchestrator/tools/builtin/notebook-edit-tool.mjs +300 -0
  234. package/src/agent/orchestrator/tools/builtin/open-config-tool.mjs +26 -0
  235. package/src/agent/orchestrator/tools/builtin/path-diagnostics.mjs +152 -0
  236. package/src/agent/orchestrator/tools/builtin/path-locks.mjs +35 -0
  237. package/src/agent/orchestrator/tools/builtin/path-utils.mjs +201 -0
  238. package/src/agent/orchestrator/tools/builtin/read-args.mjs +103 -0
  239. package/src/agent/orchestrator/tools/builtin/read-batch.mjs +172 -0
  240. package/src/agent/orchestrator/tools/builtin/read-constants.mjs +40 -0
  241. package/src/agent/orchestrator/tools/builtin/read-formatting.mjs +118 -0
  242. package/src/agent/orchestrator/tools/builtin/read-image-resize.mjs +189 -0
  243. package/src/agent/orchestrator/tools/builtin/read-image.mjs +88 -0
  244. package/src/agent/orchestrator/tools/builtin/read-lines.mjs +12 -0
  245. package/src/agent/orchestrator/tools/builtin/read-mode-tool.mjs +455 -0
  246. package/src/agent/orchestrator/tools/builtin/read-open.mjs +190 -0
  247. package/src/agent/orchestrator/tools/builtin/read-range-index.mjs +271 -0
  248. package/src/agent/orchestrator/tools/builtin/read-ranges.mjs +26 -0
  249. package/src/agent/orchestrator/tools/builtin/read-single-tool.mjs +728 -0
  250. package/src/agent/orchestrator/tools/builtin/read-snapshot-runtime.mjs +173 -0
  251. package/src/agent/orchestrator/tools/builtin/read-special-files.mjs +268 -0
  252. package/src/agent/orchestrator/tools/builtin/read-streaming.mjs +602 -0
  253. package/src/agent/orchestrator/tools/builtin/read-tool.mjs +530 -0
  254. package/src/agent/orchestrator/tools/builtin/read-windows.mjs +107 -0
  255. package/src/agent/orchestrator/tools/builtin/rename-tool.mjs +196 -0
  256. package/src/agent/orchestrator/tools/builtin/rg-runner.mjs +422 -0
  257. package/src/agent/orchestrator/tools/builtin/search-builders.mjs +158 -0
  258. package/src/agent/orchestrator/tools/builtin/search-tool.mjs +869 -0
  259. package/src/agent/orchestrator/tools/builtin/shell-analysis.mjs +653 -0
  260. package/src/agent/orchestrator/tools/builtin/shell-jobs.mjs +936 -0
  261. package/src/agent/orchestrator/tools/builtin/shell-output.mjs +36 -0
  262. package/src/agent/orchestrator/tools/builtin/shell-runtime.mjs +214 -0
  263. package/src/agent/orchestrator/tools/builtin/snapshot-helpers.mjs +143 -0
  264. package/src/agent/orchestrator/tools/builtin/snapshot-store.mjs +206 -0
  265. package/src/agent/orchestrator/tools/builtin/snapshot-validation.mjs +98 -0
  266. package/src/agent/orchestrator/tools/builtin/text-stats.mjs +69 -0
  267. package/src/agent/orchestrator/tools/builtin/windows-roots.mjs +23 -0
  268. package/src/agent/orchestrator/tools/builtin/write-tool.mjs +401 -0
  269. package/src/agent/orchestrator/tools/builtin.mjs +500 -0
  270. package/src/agent/orchestrator/tools/code-graph-prewarm-worker.mjs +39 -0
  271. package/src/agent/orchestrator/tools/code-graph-tool-defs.mjs +24 -0
  272. package/src/agent/orchestrator/tools/code-graph.mjs +4095 -0
  273. package/src/agent/orchestrator/tools/cwd-tool.mjs +298 -0
  274. package/src/agent/orchestrator/tools/destructive-warning.mjs +323 -0
  275. package/src/agent/orchestrator/tools/edit-normalize.mjs +603 -0
  276. package/src/agent/orchestrator/tools/env-scrub.mjs +100 -0
  277. package/src/agent/orchestrator/tools/graph-binary-fetcher.mjs +144 -0
  278. package/src/agent/orchestrator/tools/graph-manifest.json +26 -0
  279. package/src/agent/orchestrator/tools/host-input.mjs +204 -0
  280. package/src/agent/orchestrator/tools/mutation-content-cache.mjs +67 -0
  281. package/src/agent/orchestrator/tools/mutation-planner.mjs +75 -0
  282. package/src/agent/orchestrator/tools/next-call-utils.mjs +48 -0
  283. package/src/agent/orchestrator/tools/patch-binary-fetcher.mjs +133 -0
  284. package/src/agent/orchestrator/tools/patch-manifest.json +26 -0
  285. package/src/agent/orchestrator/tools/patch-tool-defs.mjs +20 -0
  286. package/src/agent/orchestrator/tools/patch.mjs +2754 -0
  287. package/src/agent/orchestrator/tools/progress-message.mjs +118 -0
  288. package/src/agent/orchestrator/tools/result-compression.mjs +279 -0
  289. package/src/agent/orchestrator/tools/shell-command.mjs +865 -0
  290. package/src/agent/orchestrator/tools/shell-exec-policy.mjs +89 -0
  291. package/src/agent/orchestrator/tools/shell-policy-danger-target.mjs +27 -0
  292. package/src/agent/orchestrator/tools/shell-policy-imports.mjs +7 -0
  293. package/src/agent/orchestrator/tools/shell-policy.mjs +345 -0
  294. package/src/agent/orchestrator/tools/shell-snapshot.mjs +313 -0
  295. package/src/agent/orchestrator/workflow-store.mjs +93 -0
  296. package/src/agent/tool-defs.mjs +103 -0
  297. package/src/channels/backends/discord.mjs +784 -0
  298. package/src/channels/data/voice-runtime-manifest.json +138 -0
  299. package/src/channels/index.mjs +3229 -0
  300. package/src/channels/lib/cli-worker-host.mjs +12 -0
  301. package/src/channels/lib/config-lock.mjs +13 -0
  302. package/src/channels/lib/config.mjs +292 -0
  303. package/src/channels/lib/drop-trace.mjs +71 -0
  304. package/src/channels/lib/event-pipeline.mjs +81 -0
  305. package/src/channels/lib/event-queue.mjs +345 -0
  306. package/src/channels/lib/executor.mjs +168 -0
  307. package/src/channels/lib/format.mjs +188 -0
  308. package/src/channels/lib/holidays.mjs +138 -0
  309. package/src/channels/lib/hook-pipe-server.mjs +802 -0
  310. package/src/channels/lib/interaction-workflows.mjs +184 -0
  311. package/src/channels/lib/memory-client.mjs +149 -0
  312. package/src/channels/lib/output-forwarder.mjs +765 -0
  313. package/src/channels/lib/runtime-paths.mjs +479 -0
  314. package/src/channels/lib/scheduler.mjs +723 -0
  315. package/src/channels/lib/session-control.mjs +36 -0
  316. package/src/channels/lib/session-discovery.mjs +103 -0
  317. package/src/channels/lib/settings.mjs +11 -0
  318. package/src/channels/lib/state-file.mjs +68 -0
  319. package/src/channels/lib/status-snapshot.mjs +219 -0
  320. package/src/channels/lib/tool-format.mjs +140 -0
  321. package/src/channels/lib/transcript-discovery.mjs +195 -0
  322. package/src/channels/lib/voice-runtime-fetcher.mjs +734 -0
  323. package/src/channels/lib/webhook.mjs +1179 -0
  324. package/src/channels/lib/whisper-server.mjs +477 -0
  325. package/src/channels/tool-defs.mjs +170 -0
  326. package/src/daemon/host.mjs +118 -0
  327. package/src/daemon/mcp-transport.mjs +47 -0
  328. package/src/daemon/session.mjs +100 -0
  329. package/src/daemon/thin-client.mjs +71 -0
  330. package/src/daemon/transport.mjs +163 -0
  331. package/src/memory/data/runtime-manifest.json +40 -0
  332. package/src/memory/index.mjs +3305 -0
  333. package/src/memory/lib/agent-ipc.mjs +93 -0
  334. package/src/memory/lib/bridge-trace-queries.mjs +120 -0
  335. package/src/memory/lib/core-memory-store.mjs +330 -0
  336. package/src/memory/lib/embedding-provider.mjs +269 -0
  337. package/src/memory/lib/embedding-worker.mjs +323 -0
  338. package/src/memory/lib/llm-worker-host.mjs +17 -0
  339. package/src/memory/lib/memory-cycle.mjs +11 -0
  340. package/src/memory/lib/memory-cycle1.mjs +641 -0
  341. package/src/memory/lib/memory-cycle2.mjs +1284 -0
  342. package/src/memory/lib/memory-cycle3.mjs +540 -0
  343. package/src/memory/lib/memory-embed.mjs +299 -0
  344. package/src/memory/lib/memory-extraction.mjs +5 -0
  345. package/src/memory/lib/memory-maintenance-store.mjs +32 -0
  346. package/src/memory/lib/memory-ops-policy.mjs +190 -0
  347. package/src/memory/lib/memory-recall-id-patch.mjs +15 -0
  348. package/src/memory/lib/memory-recall-read-query.mjs +7 -0
  349. package/src/memory/lib/memory-recall-scope-filter.mjs +63 -0
  350. package/src/memory/lib/memory-recall-store.mjs +621 -0
  351. package/src/memory/lib/memory-retrievers.mjs +112 -0
  352. package/src/memory/lib/memory-score.mjs +71 -0
  353. package/src/memory/lib/memory-text-utils.mjs +58 -0
  354. package/src/memory/lib/memory.mjs +412 -0
  355. package/src/memory/lib/model-profile.mjs +85 -0
  356. package/src/memory/lib/pg/adapter.mjs +308 -0
  357. package/src/memory/lib/pg/process.mjs +360 -0
  358. package/src/memory/lib/pg/supervisor.mjs +396 -0
  359. package/src/memory/lib/project-id-resolver.mjs +86 -0
  360. package/src/memory/lib/runtime-fetcher.mjs +442 -0
  361. package/src/memory/lib/trace-store.mjs +728 -0
  362. package/src/memory/tool-defs.mjs +79 -0
  363. package/src/search/index.mjs +1173 -0
  364. package/src/search/lib/backends/anthropic-oauth.mjs +98 -0
  365. package/src/search/lib/backends/exa.mjs +50 -0
  366. package/src/search/lib/backends/firecrawl.mjs +61 -0
  367. package/src/search/lib/backends/gemini-api.mjs +83 -0
  368. package/src/search/lib/backends/grok-oauth.mjs +86 -0
  369. package/src/search/lib/backends/index.mjs +150 -0
  370. package/src/search/lib/backends/openai-api.mjs +144 -0
  371. package/src/search/lib/backends/openai-oauth.mjs +98 -0
  372. package/src/search/lib/backends/openai-web-search.mjs +76 -0
  373. package/src/search/lib/backends/tavily.mjs +55 -0
  374. package/src/search/lib/backends/xai-api.mjs +113 -0
  375. package/src/search/lib/cache.mjs +131 -0
  376. package/src/search/lib/config.mjs +192 -0
  377. package/src/search/lib/formatter.mjs +115 -0
  378. package/src/search/lib/provider-usage.mjs +67 -0
  379. package/src/search/lib/providers.mjs +47 -0
  380. package/src/search/lib/search-intent.mjs +109 -0
  381. package/src/search/lib/setup-handler.mjs +261 -0
  382. package/src/search/lib/state.mjs +201 -0
  383. package/src/search/lib/web-tools.mjs +1207 -0
  384. package/src/search/tool-defs.mjs +83 -0
  385. package/src/setup/defender-exclusion.mjs +183 -0
  386. package/src/shared/abort-controller.mjs +15 -0
  387. package/src/shared/atomic-file.mjs +420 -0
  388. package/src/shared/config.mjs +350 -0
  389. package/src/shared/daemon-recycle.mjs +108 -0
  390. package/src/shared/disable-claude-builtins.mjs +88 -0
  391. package/src/shared/err-text.mjs +12 -0
  392. package/src/shared/llm/cost.mjs +66 -0
  393. package/src/shared/llm/http-agent.mjs +123 -0
  394. package/src/shared/llm/index.mjs +41 -0
  395. package/src/shared/llm/pid-cleanup.mjs +27 -0
  396. package/src/shared/llm/usage-log.mjs +47 -0
  397. package/src/shared/plugin-paths.mjs +58 -0
  398. package/src/shared/schedules-store.mjs +70 -0
  399. package/src/shared/seed.mjs +119 -0
  400. package/src/shared/user-cwd.mjs +213 -0
  401. package/src/shared/user-data-guard.mjs +238 -0
  402. package/src/status/aggregator.mjs +584 -0
  403. package/src/status/server.mjs +413 -0
  404. package/tools.json +1653 -0
package/README.md ADDED
@@ -0,0 +1,389 @@
1
+ # mixdog
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
4
+  [![Runtime: bun](https://img.shields.io/badge/runtime-bun-black.svg)](https://bun.sh)
5
+  ![Version: 0.7.1](https://img.shields.io/badge/version-0.7.1-blue.svg)
6
+
7
+ All-in-one agent plugin for the Claude Code CLI — autonomous sub-agents,
8
+ continuous memory, multi-provider routing, and syntax-aware code tools,
9
+ behind a single MCP server. Zero telemetry; all state under
10
+ `~/.claude/plugins/data/mixdog-trib-plugin/`.
11
+
12
+ - **Role-based sub-agents** — delegate scoped work to any provider through one `bridge` entry point
13
+ - **Continuous memory** — conversations, decisions, and work persist across sessions; a prebuilt Postgres + pgvector runtime is auto-downloaded and supervised, with no database to install
14
+ - **Lower cost** — session-spanning prompt cache with per-provider / per-role token tracking
15
+ - **Natural-language search** — web search and URL scraping in one tool
16
+ - **Syntax-aware code tools** — AST-based symbol / reference / caller lookup, keyword→symbol search via `code_graph` `search`, and precise edits
17
+ - **Channels & automation** — Discord front-end, cron schedules, and inbound webhooks
18
+
19
+ ## Contents
20
+
21
+ - [Why mixdog](#why-mixdog)
22
+ - [Install](#install) · [Quick start](#quick-start)
23
+ - [Modules & tools](#modules--tools)
24
+ - [Skills & commands](#skills--commands)
25
+ - [Providers](#providers)
26
+ - [Channels & automation](#channels--automation)
27
+ - [Configuration](#configuration)
28
+ - [Architecture & hooks](#architecture--hooks)
29
+ - [Safety](#safety) · [Windows support](#windows-support)
30
+ - [Contributing](#contributing) · [License](#license)
31
+
32
+ ## Why mixdog
33
+
34
+ Claude Code is powerful, but out of the box it forgets everything between
35
+ sessions, treats every request as a fresh context, and has no built-in way
36
+ to delegate to cheaper or specialised models. Cost runs high, answers
37
+ drift, and long-lived projects lose the thread.
38
+
39
+ mixdog replaces that pattern with a single MCP server that bundles four
40
+ cooperating modules — **agent**, **memory**, **search**, and **channels** —
41
+ so your Claude Code session gains persistent memory, multi-provider
42
+ sub-agents, web lookup, and an optional Discord front-end,
43
+ all behind one install.
44
+
45
+ The goal is deployment-grade: plain ESM, zero build step for runtime
46
+ code, documented local state, and every configuration surface readable
47
+ as JSON you can diff.
48
+
49
+ ## Install
50
+
51
+ ```
52
+ /plugin marketplace add trib-plugin/mixdog
53
+ /plugin install mixdog@trib-plugin
54
+ ```
55
+
56
+ Claude Code will register the repository as a marketplace, clone it,
57
+ run `bun install --frozen-lockfile`, and register the MCP server declared in
58
+ `.mcp.json`. bun is auto-installed on first launch if missing (node + npm
59
+ provided by Claude Code). To skip the first-boot install step, install bun
60
+ manually: https://bun.sh
61
+
62
+ First-launch flow: `scripts/bootstrap.mjs` (node, no deps) locates bun via
63
+ system PATH, falls back to plugin-local `node_modules/.bin/bun`, and finally
64
+ runs `npm install --no-save bun` if neither is present. node + npm are
65
+ provided by Claude Code, so the npm fallback works on a clean machine.
66
+
67
+ ## Quick start
68
+
69
+ 1. **Install.**
70
+ ```
71
+ /plugin marketplace add trib-plugin/mixdog
72
+ /plugin install mixdog@trib-plugin
73
+ ```
74
+
75
+ 2. **Restart Claude Code.** The node bootstrap layer locates or installs
76
+ bun, then bun installs runtime dependencies into a shared data
77
+ directory and seeds working defaults under
78
+ `~/.claude/plugins/data/mixdog-trib-plugin/`. On first boot the memory
79
+ runtime (a prebuilt Postgres + pgvector build) is also downloaded and
80
+ checksum-verified once, then reused on every later boot. First boot
81
+ takes 10-15 extra seconds if bun was not pre-installed, plus the
82
+ one-time runtime download; subsequent boots are unaffected.
83
+
84
+ First boot also reconfigures two Claude Code surfaces, with the
85
+ originals preserved for restore: the built-in `autoMemoryEnabled` and
86
+ `awaySummaryEnabled` settings are turned off in `~/.claude/settings.json`
87
+ (mixdog's continuous memory and recap replace both), and rules
88
+ persistence takes over `~/.claude/CLAUDE.md` (see **Configuration**).
89
+ Prior values and the original file are snapshotted under
90
+ `~/.claude/backups/mixdog-user-data/install-restore/`, and
91
+ `node scripts/uninstall.mjs` restores them (`CLAUDE.md` + the two
92
+ settings keys; see UNINSTALL.md for the full manual teardown).
93
+
94
+ 3. **That's it.** Anthropic OAuth (the Claude Code login) is the default
95
+ provider, so `bridge` / `recall` / `explore` / `memory` work immediately —
96
+ no API keys required.
97
+
98
+ 4. **Config UI.** On first launch the config UI opens automatically at
99
+ `http://localhost:3458` for providers, presets, and role bindings.
100
+ You can re-open it any time with `/mixdog:config`.
101
+
102
+ 5. **Optional external web search.** Add a Firecrawl / Tavily / Exa key in
103
+ the config UI (or edit the `search` section of `mixdog-config.json`
104
+ directly in the data directory). xAI search uses the Agent xAI key (set
105
+ in the config UI / keychain), not a separate search key.
106
+
107
+ 6. **Optional channels.** To enable Discord / voice / schedule / webhook
108
+ channels, restart Claude Code with the development channel flag
109
+ (see **Channels & automation** below), then set the Discord bot token and
110
+ channel IDs in the config UI — the token is stored in the OS keychain,
111
+ not a file — and enable channels.
112
+
113
+ ## Modules & tools
114
+
115
+ mixdog is one MCP server composing four user-facing modules. Code and
116
+ filesystem tools are shared across all of them.
117
+
118
+ ### agent
119
+
120
+ A session orchestrator with a single `bridge` entry point: delegated
121
+ sub-agent sessions, role → preset bindings (`user-workflow.json`),
122
+ multi-provider routing, and session-spanning cache / cost handling.
123
+ Sessions run as long-lived loops with trim / compress, a stream
124
+ watchdog, and background job tracking. A `<final-answer>` tag protocol
125
+ separates a worker's final reply from its internal deliberation.
126
+
127
+ | Tool | Purpose |
128
+ | --- | --- |
129
+ | `bridge` | Unified worker session control: `type=spawn` (default) delegates one scoped task to a role-bound worker; `type=send` resumes a worker by `tag`; `type=close` stops one; `type=list` enumerates active worker sessions |
130
+ | `explore` | Open-ended codebase exploration when scope is unknown; fans out one read-only sub-agent per query, each pinned to its own topic, and is ESC-cancellable mid-run |
131
+ | `list_models` | List configured provider presets |
132
+ | `open_config` | Open the settings UI (Providers + Presets) in the browser; starts the resident config server if needed and returns the UI URL |
133
+
134
+ ### memory
135
+
136
+ Native PostgreSQL with `pgvector` and `pg_trgm` backs a hybrid FTS +
137
+ vector store; a prebuilt runtime is fetched from the release manifest on
138
+ first boot, checksum-verified, and supervised automatically — there is no
139
+ separate database to install or configure. Every conversation chunk is
140
+ scored, deduped, and — if durable — promoted to core memory. A three-cycle
141
+ pipeline keeps it compact: cycle 1 extracts and scores chunks, cycle 2 is a
142
+ unified curator gate that holds the active set to a cap (~100 entries), and
143
+ cycle 3 reviews user-curated core memory. Keep/discard decisions follow a
144
+ 3-layer framework — L1 relationship/communication, L2 behavior rules, L3
145
+ current project map — so only durable standing knowledge survives. SessionStart
146
+ injects durable context plus a recent recap.
147
+
148
+ | Tool | Purpose |
149
+ | --- | --- |
150
+ | `recall` | Retrieve stored memory (string or array fan-out; category / period / scope filters) |
151
+ | `memory` | Persistent memory operations (status / core add-edit-delete-list / manage / prune / rebuild / cycle1-3 / flush / backfill / purge) |
152
+
153
+ ### search
154
+
155
+ One natural-language entry point routes across multiple search
156
+ providers and scrapes URLs through a Readability + Puppeteer pipeline.
157
+ Results are cached and formatted for model
158
+ consumption, not browser consumption.
159
+
160
+ | Tool | Purpose |
161
+ | --- | --- |
162
+ | `search` | Web SERP search (string or array of queries) |
163
+ | `web_fetch` | Fetch a full page body from a URL (follow-up to `search`) |
164
+
165
+ ### channels
166
+
167
+ Discord, cron schedules, inbound webhooks, voice STT, and a heartbeat
168
+ status surface. Inbound chat / webhook events drive a turn, schedules
169
+ fire on cadence, and the status feed keeps long-running sessions
170
+ observable. (Requires the channel flag — see **Channels & automation**.)
171
+
172
+ | Tool | Purpose |
173
+ | --- | --- |
174
+ | `reply` / `react` / `edit_message` / `download_attachment` / `fetch` | Discord message operations |
175
+ | `schedule_status` / `trigger_schedule` / `schedule_control` | Inspect, fire, or defer / skip schedules |
176
+ | `activate_channel_bridge` / `reload_config` / `inject_command` | Runtime channel control |
177
+
178
+ ### Code & filesystem tools
179
+
180
+ Shared across all modules — AST navigation (`@ast-grep/cli`) plus
181
+ content-addressed edits with a session read-dedup cache, so navigation
182
+ stays syntax-correct without dumping whole files into context. Tool
183
+ results are compressed before they hit the model (head/tail truncation,
184
+ ANSI / repeated-line dedup, file-grouped grep output). The `Module` column
185
+ matches the `module` tag in `tools.json`. `apply_patch` accepts unified and
186
+ V4A hunks with order-independent matching, so multi-hunk patches apply
187
+ regardless of the order the hunks are listed. `read` decodes UTF-8 and
188
+ UTF-16 (LE/BE, with or without BOM). `bash` auto-backgrounds a foreground
189
+ command that outlives 30s into a tracked job and streams live progress over
190
+ MCP, so long commands never block the session.
191
+
192
+ | Tool | Module | Purpose |
193
+ | --- | --- | --- |
194
+ | `code_graph` (`find_symbol`, `references`, `callers`, `search`, …) | `code_graph` | AST symbol lookup, keyword→symbols (`search`), references, callers |
195
+ | `read` / `glob` / `list` / `grep` | `builtin` | Read files, find paths, list dirs, ripgrep content |
196
+ | `edit` / `write` | `builtin` | Exact-string edit, whole-file write |
197
+ | `apply_patch` | `patch` | Unified / V4A multi-hunk, multi-file patch |
198
+ | `bash` / `job_wait` | `builtin` | Run shell commands; await background jobs |
199
+ | `diagnostics` | `builtin` | Run the matching project type/lint checker (tsc / eslint / ruff / …) once; no resident LSP |
200
+ | `inject_input` | `host_input` | Inject input into the host Claude Code session (Windows only) |
201
+ | `cwd` | `cwd` | Get / set / list the session working directory for relative-path resolution |
202
+
203
+ ## Skills & commands
204
+
205
+ **Skills** (auto-triggered by intent; Claude Code also surfaces them by name):
206
+
207
+ | Skill | Use |
208
+ | --- | --- |
209
+ | `schedule-add` | Register a recurring cron schedule |
210
+ | `webhook-add` | Register an inbound webhook endpoint |
211
+ | `setup` | Onboarding and config editing (channels, presets, roles, memory) |
212
+ | `retro-skill-proposer` | Propose a reusable skill draft after a session |
213
+
214
+ **Commands** (`/mixdog:<name>`):
215
+
216
+ | Command | Purpose |
217
+ | --- | --- |
218
+ | `/mixdog:setup` | Check prerequisites and open the config UI |
219
+ | `/mixdog:doctor` | Health diagnostics (versions, runtime, cache, deps, log count/size, Postgres `pgdata` size, hook-pipe reachability) |
220
+ | `/mixdog:config` | Open the in-browser config page directly |
221
+
222
+ **Hidden maintenance roles** (under `agents/`, not user-invoked):
223
+ `scheduler-task`, `webhook-handler`, `maintenance`, `memory-classification`.
224
+ Any public roles (worker, reviewer, debugger, etc.) are defined locally in
225
+ `user-workflow.json`, not bundled.
226
+
227
+ ## Providers
228
+
229
+ Anthropic (direct or OAuth), OpenAI (direct or OAuth), Google Gemini,
230
+ and any OpenAI-compatible endpoint (LM Studio, Ollama, vLLM, LiteLLM)
231
+ are first-class providers. Switch a role to a cheaper or faster model by
232
+ editing one line in `user-workflow.json`. A shared-prefix cache strategy
233
+ propagates Anthropic and OpenAI prompt caching across every role in a
234
+ session, and token usage is logged per provider and per role so you can
235
+ see where cost lands before the bill arrives.
236
+
237
+ ## Channels & automation
238
+
239
+ Channel-driven features require launching Claude Code with the channel flag.
240
+ mixdog is not in Anthropic's curated channel allowlist, so `--channels` is
241
+ rejected at boot. Use the development variant instead:
242
+
243
+ ```sh
244
+ claude --dangerously-load-development-channels plugin:mixdog@trib-plugin
245
+ ```
246
+
247
+ This activates the Discord backend, voice STT, schedule runner, and webhook
248
+ receiver. Without the flag the plugin still works for direct tools (`recall`,
249
+ `memory`, `bridge`, `explore`, `search`, `bash`, etc.) — channel inbound
250
+ events are silently disabled.
251
+
252
+ **Schedules and webhooks** each live as a per-entry directory under the data
253
+ directory (`schedules/<name>/`, `webhooks/<name>/`), holding `config.json`
254
+ (cron `time` / `secret` / optional `channel` / `model`) and `instructions.md`
255
+ (what to do on fire / delivery). Routing is decided purely by **channel
256
+ presence**:
257
+
258
+ - **No `channel`** → the delivery is **injected into the current (Lead)
259
+ session**, which handles it with full context.
260
+ - **`channel` set** → it is **dispatched directly to that Discord channel** by
261
+ a standalone handler (which then requires a `model` preset).
262
+
263
+ When a handler has nothing to report (no code change, non-default branch,
264
+ docs-only, dedup), it emits `[meta:silent]` as the first line — the
265
+ notification is then dropped entirely (no session turn, no channel post).
266
+
267
+ Outbound notifications respect a shared quiet-hours window (timezone-aware,
268
+ with weekend and holiday handling); each channel system can opt out of
269
+ quieting via its own `respectQuiet` flag in the config UI's DND tab.
270
+
271
+ To switch to plain `--channels`, either submit mixdog to
272
+ `claude-plugins-official` (Anthropic curates the allowlist), or add
273
+ `{marketplace: "trib-plugin", plugin: "mixdog"}` to your organization's
274
+ `allowedChannelPlugins` managed setting (Team / Enterprise).
275
+
276
+ ## Configuration
277
+
278
+ All user-editable config lives in the plugin data directory
279
+ (`~/.claude/plugins/data/mixdog-trib-plugin/`), NOT in the repository.
280
+ The easiest way to edit it is `/mixdog:config` — this opens the in-browser
281
+ UI. Editing the JSON files directly is also fully supported.
282
+
283
+ New installs default to `CLAUDE.md` mode: mixdog persists its rules block
284
+ into `~/.claude/CLAUDE.md`. On the first takeover of an existing file, the
285
+ original is backed up once to
286
+ `~/.claude/backups/mixdog-user-data/install-restore/claude-md-original.md`
287
+ and the file is replaced with the marker-delimited managed block; if that
288
+ backup cannot be written, mixdog appends the block instead and leaves your
289
+ content in place. If you prefer ephemeral injection, switch to SessionStart
290
+ hook mode in the config UI — that mode never writes to `~/.claude/CLAUDE.md`.
291
+
292
+ First install also disables Claude Code's built-in `autoMemoryEnabled` and
293
+ `awaySummaryEnabled` in `~/.claude/settings.json` — mixdog's memory and
294
+ recap replace both — after snapshotting the prior values to
295
+ `install-restore/claude-settings-original.json`. Run
296
+ `node scripts/uninstall.mjs` to restore the original file and settings.
297
+
298
+ The following files are managed in the data directory:
299
+
300
+ | File | How it gets there | Purpose |
301
+ | --- | --- | --- |
302
+ | `mixdog-config.json` | Auto-seeded on first boot | All user-configurable settings under named sections (`channels`, `memory`, `agent`, `search`, plus UI-managed extras). See `src/shared/seed.mjs` for the default structure. |
303
+ | `user-workflow.json` | Seeded by the setup server when missing | Role → preset bindings for delegated agents |
304
+ | `user-workflow.md` | Auto-generated on first launch | Human-readable workflow description derived from `user-workflow.json`; used by the Lead as a role reference |
305
+ | `schedules/<name>/` | Created via config UI or `schedule-add` | Per-schedule `config.json` + `instructions.md` |
306
+ | `webhooks/<name>/` | Created via config UI or `webhook-add` | Per-webhook `config.json` + `instructions.md` |
307
+
308
+ Seed defaults and templates live under `defaults/`
309
+ (`mixdog-config.template.json`, `user-workflow.json`) — useful as a
310
+ reference or for diffing after manual edits.
311
+
312
+ **Discord setup (optional).** Set the Discord bot token in the config UI
313
+ (`/mixdog:config`) — it is stored in the OS keychain, not a file — and add
314
+ your channel IDs there, then enable channels.
315
+
316
+ ## Architecture & hooks
317
+
318
+ The MCP server starts via `scripts/bootstrap.mjs → scripts/run-mcp.mjs`
319
+ (stdio supervisor) `→ server.mjs` (thin client or shared daemon) `→
320
+ server-main.mjs`. Hooks are declared in `hooks/hooks.json` and routed through
321
+ a native shim + CJS files. SessionStart is split into three parts — `rules`
322
+ (workflow / rules injection + first-boot setup), `core` (durable memory
323
+ context), and `recap` (recent-session recap); PreToolUse / PostToolUse enforce
324
+ permission gates, sandbox checks, and status updates. Session state is
325
+ journalled every turn, so a mid-session crash resumes cleanly on next boot.
326
+ SessionStart also installs a version-independent status line: a stable launcher
327
+ is copied into the data directory and registered in `~/.claude/settings.json`
328
+ (tagged `"source": "mixdog-auto"`), so the status line survives plugin version
329
+ bumps and self-heals without a restart. A genuine user-configured `statusLine`
330
+ is left untouched.
331
+ See [ARCHITECTURE.md](ARCHITECTURE.md) and [DATA-FLOW.md](DATA-FLOW.md).
332
+
333
+ ## Safety
334
+
335
+ - **Protected paths.** The MCP server hard-blocks destructive shell
336
+ patterns (recursive root deletes, force pushes, disk formatting) —
337
+ these are unconditional, with no override flag.
338
+ - **Approval gates.** Out-of-workspace filesystem writes by sub-agents
339
+ require a confirmation prompt, and system paths are hard-denied.
340
+ - **Tool scope.** Each role has an explicit tool preset
341
+ (`readonly` / `full` / custom) — there is no ambient access.
342
+ - **Untrusted inbound data.** Webhook payloads are fenced as untrusted
343
+ data and never executed as instructions.
344
+ - **No background exfiltration.** The plugin makes no outbound calls
345
+ beyond the providers you configure and the search endpoints you
346
+ opt into.
347
+ - **Fail-open hooks.** Permission hooks are a guard layer, not a
348
+ sandbox: if the mixdog daemon or its hook pipe is down, hook
349
+ decisions default to allow. `/mixdog:doctor` warns explicitly when
350
+ the hook pipe is unreachable. See the "Fail-open Hook Model" section
351
+ in [SECURITY.md](SECURITY.md).
352
+
353
+ For the full local state, secret, and network model, see
354
+ [SECURITY.md](SECURITY.md) and [DATA-FLOW.md](DATA-FLOW.md). To restore the
355
+ pre-install `CLAUDE.md` and Claude Code settings, run
356
+ `node scripts/uninstall.mjs`; for full removal, see
357
+ [UNINSTALL.md](UNINSTALL.md).
358
+
359
+ ## Windows support
360
+
361
+ mixdog is developed on Windows and tested on Windows + Linux.
362
+ All scripts use forward slashes or `path.join`, line endings are
363
+ normalised to LF via `.gitattributes` (except `.cmd` / `.bat` /
364
+ `.ps1`, which stay CRLF), and Node child-process calls resolve
365
+ binaries through `process.platform`-aware shims.
366
+
367
+ The prebuilt memory runtime ships for Windows (`win32-x64`), Linux
368
+ (`linux-x64`), and macOS on both Apple Silicon (`darwin-arm64`) and Intel
369
+ (`darwin-x64`); the optional voice helper publishes verified assets for the
370
+ same platforms. `linux-arm64` is not yet built.
371
+
372
+ The `bash` MCP tool is OS-native: Windows runs commands through PowerShell
373
+ (`pwsh.exe` when available, otherwise Windows PowerShell), while macOS/Linux
374
+ use `/bin/sh`. No extra Windows shell runtime is required or auto-installed.
375
+
376
+ ## Contributing
377
+
378
+ Architecture notes live in [ARCHITECTURE.md](ARCHITECTURE.md). Contributor
379
+ setup and PR expectations live in [CONTRIBUTING.md](CONTRIBUTING.md).
380
+
381
+ Before opening a PR, run:
382
+
383
+ ```sh
384
+ bun run ci
385
+ ```
386
+
387
+ ## License
388
+
389
+ MIT — see [LICENSE](LICENSE).
package/SECURITY.md ADDED
@@ -0,0 +1,138 @@
1
+ # Security Policy
2
+
3
+ mixdog is a local Claude Code plugin. Its security boundary is the user's
4
+ machine, the active Claude Code workspace, and any external providers the user
5
+ explicitly configures.
6
+
7
+ ## Supported Versions
8
+
9
+ Security fixes are accepted for the latest published version. If you maintain a
10
+ fork or an older pinned install, upgrade to the latest release before reporting
11
+ an issue unless the vulnerability is only present in a new release.
12
+
13
+ ## Reporting a Vulnerability
14
+
15
+ Please report suspected vulnerabilities privately first. Use a private GitHub
16
+ security advisory on the repository when advisories are enabled, or email the
17
+ address listed in the `author` field of `package.json`.
18
+
19
+ Include:
20
+
21
+ - The mixdog version.
22
+ - Operating system and Claude Code version.
23
+ - Whether channels, Discord, webhooks, voice, or external search providers were
24
+ enabled.
25
+ - A minimal reproduction or the smallest relevant log excerpt.
26
+
27
+ Do not include real API keys, Discord tokens, OAuth tokens, private prompts, or
28
+ conversation transcripts in public issues.
29
+
30
+ ## Security Model
31
+
32
+ mixdog exposes one MCP server plus Claude Code hooks. It is designed around
33
+ explicit local state and layered permission gates:
34
+
35
+ - Destructive shell patterns are hard-blocked before execution, with no escape
36
+ flag: recursive deletes of root/home (`rm -rf /`, `rd /s`,
37
+ `Remove-Item -Recurse -Force`), `git push --force`, `git reset --hard`, disk
38
+ formatting (`format`, `mkfs`, `diskpart clean`, `dd if=/dev/...`), and system
39
+ shutdown/reboot. PowerShell `-EncodedCommand` payloads are decoded first so
40
+ base64-smuggled variants are caught too. Other risky commands (`git clean -f`,
41
+ `kubectl delete`, `terraform destroy`, `DROP TABLE`, …) get a non-blocking
42
+ inline warning instead of a block.
43
+ - File tools are scoped to the active working directory by default; HOME-wide
44
+ writes require the `homeAccess` capability opt-in.
45
+ - Bridge sub-agent `Edit`/`Write` to any path outside the session workspace is
46
+ routed through a Discord approval prompt before it runs.
47
+ - Dangerous system paths (`/etc`, `/proc`, `/sys`, `/dev`, `C:\Windows`,
48
+ `System32`, Program Files, UNC shares) are hard-denied by hook policy before
49
+ any permission-mode check.
50
+ - Each role runs with a fixed permission preset — `full` (read/write tools) or
51
+ `read` (write/edit/bash refused at the session runtime guard). Roles do not
52
+ gain ambient access beyond their preset.
53
+ - Discord tokens, webhook authtokens, and LLM provider API keys are read only
54
+ from `MIXDOG_*` (or standard provider) environment variables or the OS
55
+ keychain — never from `mixdog-config.json`, which is itself written
56
+ owner-only.
57
+ - Webhook payloads and headers are wrapped in untrusted-data fences and handed
58
+ to the agent as data to inspect, never executed as instructions.
59
+ - Discord, webhooks, schedules, and voice are disabled unless the user starts
60
+ Claude Code with the development channel flag
61
+ (`--dangerously-load-development-channels`).
62
+
63
+ ## Fail-open Hook Model
64
+
65
+ The permission hooks are a convenience and guard layer, not a sandbox. They
66
+ raise the cost of an accidental destructive action; they do not contain a
67
+ determined or compromised agent.
68
+
69
+ Hook decisions travel over a local IPC channel between Claude Code and the
70
+ mixdog daemon:
71
+
72
+ - A small Rust shim (`mixdog-shim`) receives the hook payload from Claude Code
73
+ and forwards it to the daemon over a named pipe (`\\.\pipe\mixdog-hooks` on
74
+ Windows) or a Unix domain socket (`${XDG_RUNTIME_DIR:-/tmp}/mixdog-hooks.sock`).
75
+ - A long-lived listener inside the channels worker
76
+ (`src/channels/lib/hook-pipe-server.mjs`) evaluates the payload and returns a
77
+ decision, or `"null"` to allow.
78
+
79
+ This path is **fail-open by design**. When the daemon is not running, the pipe
80
+ is unreachable, or dispatch raises an error, the components default to allow:
81
+ the server emits `"null"` and the shim exits `0`, so nothing is blocked. A
82
+ missing daemon therefore never wedges the user's session — but it also means
83
+ permission hooks are silently bypassed until the daemon is restored.
84
+
85
+ Run `bun scripts/doctor.mjs` to confirm the supervisor and hook pipe are
86
+ healthy. Do not rely on the hooks alone as a security boundary; the operating
87
+ system account, workspace isolation, and provider-side credentials remain the
88
+ real perimeter.
89
+
90
+ ## Local Writes
91
+
92
+ New installs seed configuration under:
93
+
94
+ ```text
95
+ ~/.claude/plugins/data/mixdog-trib-plugin/
96
+ ```
97
+
98
+ The seeded default prompt-injection mode is `CLAUDE.md`, which writes a
99
+ marker-delimited managed block to the configured target file, usually
100
+ `~/.claude/CLAUDE.md`:
101
+
102
+ ```text
103
+ <!-- BEGIN mixdog managed -->
104
+ ...
105
+ <!-- END mixdog managed -->
106
+ ```
107
+
108
+ mixdog only owns the content inside those markers.
109
+
110
+ ## Network Surface
111
+
112
+ mixdog makes outbound requests only for features the user configures or invokes:
113
+
114
+ - LLM providers: Anthropic, OpenAI, Gemini, or OpenAI-compatible endpoints.
115
+ - Search providers: Firecrawl, Tavily, Exa, the configured LLM search backends,
116
+ and URL fetches requested through search/fetch tools.
117
+ - Discord and webhook endpoints when channels are enabled.
118
+ - Runtime downloads when the user installs those optional components: signed
119
+ manifests from `raw.githubusercontent.com` (the memory, voice, code-graph, and
120
+ patch manifests, plus the LiteLLM model-pricing catalog) and the
121
+ checksum-verified binaries/archives they point at, served from GitHub release
122
+ assets (`github.com/trib-plugin/mixdog/releases`) and the upstream
123
+ `ffmpeg-static` releases for voice.
124
+
125
+ The config UI binds to `127.0.0.1` and rejects cross-origin requests.
126
+
127
+ ## Dependency Hygiene
128
+
129
+ Run these before publishing:
130
+
131
+ ```sh
132
+ bun install --frozen-lockfile
133
+ bun run ci
134
+ ```
135
+
136
+ `bun audit` is part of `bun run ci`. If a transitive dependency is vulnerable,
137
+ prefer a narrow `overrides` pin and document why the pin exists.
138
+
package/UNINSTALL.md ADDED
@@ -0,0 +1,112 @@
1
+ # Uninstall
2
+
3
+ This guide removes mixdog code, local state, and optional global rule injection.
4
+
5
+ ## 0. Restore User-Owned Files (recommended)
6
+
7
+ Run the restore helper first. It restores your pre-mixdog `~/.claude/CLAUDE.md`
8
+ and the `autoMemoryEnabled` / `awaySummaryEnabled` keys in
9
+ `~/.claude/settings.json` from the snapshot captured at install time. It deletes
10
+ nothing — data/plugin/backup removal stays manual (it prints those steps).
11
+
12
+ ```text
13
+ node scripts/uninstall.mjs # or: bun scripts/uninstall.mjs
14
+ node scripts/uninstall.mjs --dry-run # preview without modifying anything
15
+ ```
16
+
17
+ The helper covers only the restore portion (CLAUDE.md and the two settings
18
+ keys) and prints guidance. The remaining steps below — plugin removal, deleting
19
+ the data and backups directories, and statusLine/secrets/credential cleanup —
20
+ are required regardless of whether you run it.
21
+
22
+ ## 1. Uninstall the Plugin
23
+
24
+ From Claude Code:
25
+
26
+ ```text
27
+ /plugin uninstall mixdog@trib-plugin
28
+ ```
29
+
30
+ If the marketplace is no longer needed:
31
+
32
+ ```text
33
+ /plugin marketplace remove trib-plugin
34
+ ```
35
+
36
+ ## 2. Remove Local Data
37
+
38
+ Delete the plugin data directory if you do not want to keep memory, schedules,
39
+ webhooks, logs, or local configuration (the unified `mixdog-config.json`):
40
+
41
+ ```text
42
+ ~/.claude/plugins/data/mixdog-trib-plugin/
43
+ ```
44
+
45
+ This removes local memory and runtime state. It does not revoke external API
46
+ keys at their providers.
47
+
48
+ If you ran the config-preserving reinstall flow, mixdog may also have stored a
49
+ backup of your user data. Remove it as well if you do not need it:
50
+
51
+ ```text
52
+ ~/.claude/backups/mixdog-user-data
53
+ ```
54
+
55
+ ## 3. Remove the Managed CLAUDE.md Block
56
+
57
+ The restore helper in step 0 handles this automatically. To do it by hand,
58
+ open the configured target file, usually:
59
+
60
+ ```text
61
+ ~/.claude/CLAUDE.md
62
+ ```
63
+
64
+ Remove only the marker-delimited block:
65
+
66
+ ```text
67
+ <!-- BEGIN mixdog managed -->
68
+ ...
69
+ <!-- END mixdog managed -->
70
+ ```
71
+
72
+ Older installs may contain legacy markers:
73
+
74
+ ```text
75
+ <!-- BEGIN trib-plugin managed -->
76
+ ...
77
+ <!-- END trib-plugin managed -->
78
+ ```
79
+
80
+ Remove those legacy blocks as well if present.
81
+
82
+ ## 4. Remove the statusLine Entry
83
+
84
+ If a status line appeared, mixdog injected a `statusLine` entry into:
85
+
86
+ ```text
87
+ ~/.claude/settings.json
88
+ ```
89
+
90
+ Open that file and delete the `statusLine` object whose
91
+ `"source": "mixdog-auto"`. Leave any status line you configured yourself
92
+ untouched — mixdog only manages entries tagged `mixdog-auto`.
93
+
94
+ ## 5. Remove Secrets
95
+
96
+ Delete any mixdog-related secrets from your OS keychain or credential manager.
97
+ Common account names include:
98
+
99
+ - `discord.token`
100
+ - `webhook.authtoken`
101
+ - `search.firecrawl.apiKey`
102
+ - `search.tavily.apiKey`
103
+ - `search.exa.apiKey`
104
+ - `agent.<provider>.apiKey` (e.g. `agent.openai.apiKey`, `agent.xai.apiKey`)
105
+
106
+ Also remove any `MIXDOG_*` environment variables you created.
107
+
108
+ ## 6. Revoke External Credentials
109
+
110
+ If you configured Discord, search providers, webhooks, or direct LLM API keys,
111
+ rotate or revoke those credentials in the provider dashboards.
112
+
@@ -0,0 +1,5 @@
1
+ # Maintenance
2
+
3
+ Memory cycle maintenance agent. Runs periodically (~10min) to process transcript chunks, promote facts, and keep the memory system healthy.
4
+
5
+ Stateless: no transcript carried between dispatches. Each cycle is independent.
@@ -0,0 +1,30 @@
1
+ # Memory Classification Shared
2
+
3
+ Shared category taxonomy referenced by the memory cycle agents (cycle1 chunker/classifier, cycle2 curator).
4
+
5
+ ## Category grades
6
+
7
+ Higher grade = more permanent weight.
8
+
9
+ | grade | category | meaning |
10
+ |---|---|---|
11
+ | 2.0 | `rule` | permanent rules, identity, operating policies |
12
+ | 1.9 | `constraint` | hard limits (security / cost / time) |
13
+ | 1.8 | `decision` | agreed decisions |
14
+ | 1.6 | `fact` | verified facts / observed patterns |
15
+ | 1.5 | `goal` | long-term direction |
16
+ | 1.4 | `preference` | user taste / style |
17
+ | 1.1 | `task` | active work (volatile; rarely core) |
18
+ | 1.0 | `issue` | known problems (only if permanently relevant) |
19
+
20
+ When ambiguous, pick the higher-grade category that fits (rule > constraint > decision > fact > goal > preference > task > issue).
21
+
22
+ ## Edge examples
23
+
24
+ | contrast | A | B |
25
+ |---|---|---|
26
+ | rule / constraint | rule: "Commit uses `YYYY-MM-DD HH:MM` prefix" | constraint: "Never push to main without approval" |
27
+ | decision / fact | decision: "Use bridge as the single agent entry point" | fact: "bridge dispatches via role mapping in user-workflow.json" |
28
+ | fact / preference | fact: "User prefers Korean replies" (verified, hard) | preference: "User prefers warm polite tone" (taste) |
29
+ | task / issue | task: "Implement chunk grouping in cycle1" | issue: "vec_memory has 6,000 stale rows" |
30
+ | goal / decision | goal: "Cut LLM cost 50% next quarter" | decision: "Drop semantic_cache to simplify" |