agent-mockingbird 0.0.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 (227) hide show
  1. package/.agents/skills/btca-cli/SKILL.md +64 -0
  2. package/.agents/skills/btca-cli/agents/openai.yaml +3 -0
  3. package/.agents/skills/frontend-design/SKILL.md +42 -0
  4. package/.agents/skills/frontend-design/agents/openai.yaml +3 -0
  5. package/.env.example +36 -0
  6. package/.githooks/pre-commit +33 -0
  7. package/.github/workflows/ci.yml +309 -0
  8. package/.opencode/bun.lock +18 -0
  9. package/.opencode/package.json +5 -0
  10. package/.opencode/tools/agent_type_manager.ts +100 -0
  11. package/.opencode/tools/config_manager.ts +87 -0
  12. package/.opencode/tools/cron_manager.ts +145 -0
  13. package/.opencode/tools/memory_get.ts +43 -0
  14. package/.opencode/tools/memory_remember.ts +53 -0
  15. package/.opencode/tools/memory_search.ts +48 -0
  16. package/AGENTS.md +126 -0
  17. package/MEMORY.md +2 -0
  18. package/README.md +451 -0
  19. package/THIRD_PARTY_NOTICES.md +11 -0
  20. package/agent-mockingbird.config.example.json +135 -0
  21. package/apps/server/package.json +32 -0
  22. package/apps/server/src/backend/agents/bootstrapContext.ts +362 -0
  23. package/apps/server/src/backend/agents/openclawImport.test.ts +133 -0
  24. package/apps/server/src/backend/agents/openclawImport.ts +797 -0
  25. package/apps/server/src/backend/agents/opencodeConfig.ts +428 -0
  26. package/apps/server/src/backend/agents/service.ts +10 -0
  27. package/apps/server/src/backend/config/example-config.test.ts +20 -0
  28. package/apps/server/src/backend/config/orchestration.ts +243 -0
  29. package/apps/server/src/backend/config/policy.ts +158 -0
  30. package/apps/server/src/backend/config/schema.test.ts +15 -0
  31. package/apps/server/src/backend/config/schema.ts +391 -0
  32. package/apps/server/src/backend/config/semantic.test.ts +34 -0
  33. package/apps/server/src/backend/config/semantic.ts +149 -0
  34. package/apps/server/src/backend/config/service.test.ts +75 -0
  35. package/apps/server/src/backend/config/service.ts +207 -0
  36. package/apps/server/src/backend/config/smoke.ts +77 -0
  37. package/apps/server/src/backend/config/store.test.ts +123 -0
  38. package/apps/server/src/backend/config/store.ts +581 -0
  39. package/apps/server/src/backend/config/testFixtures.ts +5 -0
  40. package/apps/server/src/backend/config/types.ts +56 -0
  41. package/apps/server/src/backend/contracts/events.ts +320 -0
  42. package/apps/server/src/backend/contracts/runtime.ts +111 -0
  43. package/apps/server/src/backend/cron/executor.ts +435 -0
  44. package/apps/server/src/backend/cron/repository.ts +170 -0
  45. package/apps/server/src/backend/cron/service.ts +660 -0
  46. package/apps/server/src/backend/cron/storage.ts +92 -0
  47. package/apps/server/src/backend/cron/types.ts +138 -0
  48. package/apps/server/src/backend/cron/utils.ts +351 -0
  49. package/apps/server/src/backend/db/client.ts +20 -0
  50. package/apps/server/src/backend/db/migrate.ts +40 -0
  51. package/apps/server/src/backend/db/repository.ts +1762 -0
  52. package/apps/server/src/backend/db/schema.ts +113 -0
  53. package/apps/server/src/backend/db/usageDashboard.test.ts +102 -0
  54. package/apps/server/src/backend/db/wipe.ts +13 -0
  55. package/apps/server/src/backend/defaults.ts +32 -0
  56. package/apps/server/src/backend/env.ts +48 -0
  57. package/apps/server/src/backend/heartbeat/activeHours.ts +45 -0
  58. package/apps/server/src/backend/heartbeat/defaultJob.ts +88 -0
  59. package/apps/server/src/backend/heartbeat/heartbeat.test.ts +110 -0
  60. package/apps/server/src/backend/heartbeat/runtimeService.ts +190 -0
  61. package/apps/server/src/backend/heartbeat/service.ts +176 -0
  62. package/apps/server/src/backend/heartbeat/state.test.ts +63 -0
  63. package/apps/server/src/backend/heartbeat/state.ts +167 -0
  64. package/apps/server/src/backend/heartbeat/types.ts +54 -0
  65. package/apps/server/src/backend/http/boundedQueue.test.ts +49 -0
  66. package/apps/server/src/backend/http/boundedQueue.ts +92 -0
  67. package/apps/server/src/backend/http/parsers.ts +40 -0
  68. package/apps/server/src/backend/http/router.ts +61 -0
  69. package/apps/server/src/backend/http/routes/agentRoutes.ts +67 -0
  70. package/apps/server/src/backend/http/routes/backgroundRoutes.ts +203 -0
  71. package/apps/server/src/backend/http/routes/chatRoutes.ts +107 -0
  72. package/apps/server/src/backend/http/routes/configRoutes.ts +602 -0
  73. package/apps/server/src/backend/http/routes/cronRoutes.ts +221 -0
  74. package/apps/server/src/backend/http/routes/dashboardRoutes.ts +308 -0
  75. package/apps/server/src/backend/http/routes/eventRoutes.ts +7 -0
  76. package/apps/server/src/backend/http/routes/heartbeatRoutes.test.ts +41 -0
  77. package/apps/server/src/backend/http/routes/heartbeatRoutes.ts +28 -0
  78. package/apps/server/src/backend/http/routes/index.ts +101 -0
  79. package/apps/server/src/backend/http/routes/mcpRoutes.ts +213 -0
  80. package/apps/server/src/backend/http/routes/memoryRoutes.ts +154 -0
  81. package/apps/server/src/backend/http/routes/runRoutes.ts +310 -0
  82. package/apps/server/src/backend/http/routes/runtimeRoutes.ts +197 -0
  83. package/apps/server/src/backend/http/routes/skillRoutes.ts +112 -0
  84. package/apps/server/src/backend/http/routes/uiRoutes.test.ts +161 -0
  85. package/apps/server/src/backend/http/routes/uiRoutes.ts +177 -0
  86. package/apps/server/src/backend/http/routes/usageRoutes.test.ts +104 -0
  87. package/apps/server/src/backend/http/routes/usageRoutes.ts +767 -0
  88. package/apps/server/src/backend/http/schemas.ts +64 -0
  89. package/apps/server/src/backend/http/sse.ts +144 -0
  90. package/apps/server/src/backend/integration/backend-core.test.ts +2316 -0
  91. package/apps/server/src/backend/logging/logger.ts +64 -0
  92. package/apps/server/src/backend/mcp/service.ts +326 -0
  93. package/apps/server/src/backend/memory/cli.ts +170 -0
  94. package/apps/server/src/backend/memory/conceptExpansion.test.ts +28 -0
  95. package/apps/server/src/backend/memory/conceptExpansion.ts +80 -0
  96. package/apps/server/src/backend/memory/qmdPort.test.ts +54 -0
  97. package/apps/server/src/backend/memory/qmdPort.ts +61 -0
  98. package/apps/server/src/backend/memory/records.test.ts +66 -0
  99. package/apps/server/src/backend/memory/records.ts +229 -0
  100. package/apps/server/src/backend/memory/service.ts +2012 -0
  101. package/apps/server/src/backend/memory/sqliteVec.ts +58 -0
  102. package/apps/server/src/backend/memory/types.ts +104 -0
  103. package/apps/server/src/backend/opencode/agentMockingbirdPlugin.test.ts +396 -0
  104. package/apps/server/src/backend/opencode/client.ts +98 -0
  105. package/apps/server/src/backend/opencode/models.ts +41 -0
  106. package/apps/server/src/backend/opencode/systemPrompt.test.ts +146 -0
  107. package/apps/server/src/backend/opencode/systemPrompt.ts +284 -0
  108. package/apps/server/src/backend/paths.ts +57 -0
  109. package/apps/server/src/backend/prompts/service.ts +100 -0
  110. package/apps/server/src/backend/queue/queue.test.ts +189 -0
  111. package/apps/server/src/backend/queue/service.ts +177 -0
  112. package/apps/server/src/backend/queue/types.ts +39 -0
  113. package/apps/server/src/backend/run/service.ts +576 -0
  114. package/apps/server/src/backend/run/storage.ts +47 -0
  115. package/apps/server/src/backend/run/types.ts +44 -0
  116. package/apps/server/src/backend/runtime/errors.ts +61 -0
  117. package/apps/server/src/backend/runtime/index.ts +72 -0
  118. package/apps/server/src/backend/runtime/memoryPromptDedup.test.ts +153 -0
  119. package/apps/server/src/backend/runtime/memoryPromptDedup.ts +76 -0
  120. package/apps/server/src/backend/runtime/opencodeRuntime/backgroundMethods.ts +765 -0
  121. package/apps/server/src/backend/runtime/opencodeRuntime/coreMethods.ts +705 -0
  122. package/apps/server/src/backend/runtime/opencodeRuntime/eventMethods.ts +503 -0
  123. package/apps/server/src/backend/runtime/opencodeRuntime/memoryMethods.ts +462 -0
  124. package/apps/server/src/backend/runtime/opencodeRuntime/promptMethods.ts +1167 -0
  125. package/apps/server/src/backend/runtime/opencodeRuntime/shared.ts +254 -0
  126. package/apps/server/src/backend/runtime/opencodeRuntime.test.ts +2899 -0
  127. package/apps/server/src/backend/runtime/opencodeRuntime.ts +135 -0
  128. package/apps/server/src/backend/runtime/sessionScope.ts +45 -0
  129. package/apps/server/src/backend/skills/service.ts +442 -0
  130. package/apps/server/src/backend/workspace/resolve.ts +27 -0
  131. package/apps/server/src/cli/agent-mockingbird.mjs +2522 -0
  132. package/apps/server/src/cli/agent-mockingbird.test.ts +68 -0
  133. package/apps/server/src/cli/runtime-assets.mjs +269 -0
  134. package/apps/server/src/cli/runtime-assets.test.ts +52 -0
  135. package/apps/server/src/cli/runtime-layout.mjs +75 -0
  136. package/apps/server/src/cli/standaloneBuild.test.ts +19 -0
  137. package/apps/server/src/cli/standaloneBuild.ts +19 -0
  138. package/apps/server/src/cli/standaloneCronBinary.test.ts +187 -0
  139. package/apps/server/src/index.ts +178 -0
  140. package/apps/server/tsconfig.json +12 -0
  141. package/backlog.md +5 -0
  142. package/bin/agent-mockingbird +2522 -0
  143. package/bin/runtime-layout.mjs +75 -0
  144. package/build-bin.ts +34 -0
  145. package/build-cli.mjs +37 -0
  146. package/build.ts +40 -0
  147. package/bun-env.d.ts +11 -0
  148. package/bun.lock +888 -0
  149. package/bunfig.toml +2 -0
  150. package/components.json +21 -0
  151. package/config.json +130 -0
  152. package/deploy/RELEASE_INSTALL.md +112 -0
  153. package/deploy/docker-compose.yml +42 -0
  154. package/deploy/systemd/README.md +46 -0
  155. package/deploy/systemd/agent-mockingbird.service +28 -0
  156. package/deploy/systemd/opencode.service +25 -0
  157. package/docs/legacy-config-ui-reference.md +51 -0
  158. package/docs/memory-e2e-trace-2026-03-04.md +63 -0
  159. package/docs/memory-ops.md +96 -0
  160. package/docs/memory-runtime-contract.md +42 -0
  161. package/docs/memory-tuning-remote-2026-03-04.md +59 -0
  162. package/docs/opencode-rebase-workflow-plan.md +614 -0
  163. package/docs/opencode-startup-sync-plan.md +94 -0
  164. package/docs/vendor-opencode.md +41 -0
  165. package/drizzle/0000_famous_turbo.sql +49 -0
  166. package/drizzle/0001_cron_memory_aux.sql +160 -0
  167. package/drizzle/0002_runtime_session_bindings.sql +28 -0
  168. package/drizzle/0003_background_runs.sql +27 -0
  169. package/drizzle/0004_memory_open_write.sql +63 -0
  170. package/drizzle/0005_signal_channel.sql +47 -0
  171. package/drizzle/0006_usage_event_dimensions.sql +7 -0
  172. package/drizzle/meta/0000_snapshot.json +341 -0
  173. package/drizzle/meta/_journal.json +55 -0
  174. package/drizzle.config.ts +14 -0
  175. package/eslint.config.mjs +77 -0
  176. package/knip.json +18 -0
  177. package/memory/2026-03-04.md +4 -0
  178. package/opencode.lock.json +16 -0
  179. package/package.json +67 -0
  180. package/packages/agent-mockingbird-installer/README.md +31 -0
  181. package/packages/agent-mockingbird-installer/bin/agent-mockingbird-installer.mjs +44 -0
  182. package/packages/agent-mockingbird-installer/opencode.lock.json +16 -0
  183. package/packages/agent-mockingbird-installer/package.json +23 -0
  184. package/packages/contracts/package.json +19 -0
  185. package/packages/contracts/src/agentTypes.ts +122 -0
  186. package/packages/contracts/src/cron.ts +146 -0
  187. package/packages/contracts/src/dashboard.ts +378 -0
  188. package/packages/contracts/src/index.ts +3 -0
  189. package/packages/contracts/tsconfig.json +4 -0
  190. package/patches/opencode/0001-Wafflebot-OpenCode-baseline.patch +2341 -0
  191. package/patches/opencode/0002-Fix-OpenCode-web-entry-and-settings-icons.patch +104 -0
  192. package/patches/opencode/0003-fix-app-remove-duplicate-sidebar-mount.patch +32 -0
  193. package/patches/opencode/0004-Add-heartbeat-settings-and-usage-nav.patch +506 -0
  194. package/patches/opencode/0005-Use-chart-icon-for-usage-nav.patch +38 -0
  195. package/patches/opencode/0006-Modernize-cron-settings.patch +399 -0
  196. package/patches/opencode/0007-Rename-waffle-namespaces-to-mockingbird.patch +1110 -0
  197. package/patches/opencode/0008-Remove-cron-contract-section.patch +178 -0
  198. package/patches/opencode/0009-Rework-cron-tab-as-operations-console.patch +414 -0
  199. package/patches/opencode/0010-Refine-heartbeat-settings-controls.patch +208 -0
  200. package/runtime-assets/opencode-config/opencode.jsonc +25 -0
  201. package/runtime-assets/opencode-config/package.json +5 -0
  202. package/runtime-assets/opencode-config/plugins/agent-mockingbird.ts +715 -0
  203. package/runtime-assets/workspace/.agents/skills/config-auditor/SKILL.md +25 -0
  204. package/runtime-assets/workspace/.agents/skills/config-editor/SKILL.md +24 -0
  205. package/runtime-assets/workspace/.agents/skills/cron-manager/SKILL.md +57 -0
  206. package/runtime-assets/workspace/.agents/skills/memory-ops/SKILL.md +120 -0
  207. package/runtime-assets/workspace/.agents/skills/runtime-diagnose/SKILL.md +25 -0
  208. package/runtime-assets/workspace/AGENTS.md +56 -0
  209. package/runtime-assets/workspace/MEMORY.md +4 -0
  210. package/scripts/build-release-bundle.sh +66 -0
  211. package/scripts/check-ship.ts +383 -0
  212. package/scripts/dev-opencode.sh +17 -0
  213. package/scripts/dev-stack-opencode.sh +15 -0
  214. package/scripts/dev-stack.sh +61 -0
  215. package/scripts/install-systemd.sh +87 -0
  216. package/scripts/memory-e2e.sh +76 -0
  217. package/scripts/memory-trace-e2e.sh +141 -0
  218. package/scripts/migrate-opencode-env.ts +108 -0
  219. package/scripts/onboard/bootstrap.sh +32 -0
  220. package/scripts/opencode-swap.ts +78 -0
  221. package/scripts/opencode-sync.ts +715 -0
  222. package/scripts/runtime-assets-sync.mjs +83 -0
  223. package/scripts/setup-git-hooks.ts +39 -0
  224. package/tsconfig.json +45 -0
  225. package/tui.json +98 -0
  226. package/turbo.json +36 -0
  227. package/vendor/OPENCODE_VENDOR.md +13 -0
package/README.md ADDED
@@ -0,0 +1,451 @@
1
+ # agent-mockingbird
2
+
3
+ Bun-native orchestration dashboard scaffold for a long-running agent stack.
4
+
5
+ ## Stack
6
+
7
+ - Runtime: `bun`
8
+ - Frontend: `react` + `typescript`
9
+ - Styling: `tailwindcss v4`
10
+ - UI primitives: `@base-ui-components/react` with shadcn-style component structure
11
+ - Linting: `eslint` (flat config) + `typescript-eslint` + `react-hooks` + `jsx-a11y`
12
+
13
+ ## Commands
14
+
15
+ ```bash
16
+ bun install
17
+ bun run dev
18
+ bun run build:cli
19
+ ```
20
+
21
+ Canonical install flow for end users on Linux:
22
+
23
+ ```bash
24
+ npx --yes \
25
+ --package "@waffleophagus/agent-mockingbird-installer@latest" \
26
+ agent-mockingbird-installer install
27
+ ```
28
+
29
+ That command installs the packaged CLI `agent-mockingbird` from npm, installs and starts the `opencode` and `agent-mockingbird` user services, and then launches the interactive onboarding wizard on TTY installs.
30
+
31
+ Local development installs a git `pre-commit` hook automatically via `core.hooksPath=.githooks`. The hook runs:
32
+
33
+ ```bash
34
+ bun run build:cli
35
+ bun run lint
36
+ bun run typecheck
37
+ bun run build
38
+ bun run build:bin
39
+ ```
40
+
41
+ and builds local output into `dist/app` plus the tracked CLI shim.
42
+
43
+ Run agent-mockingbird + OpenCode together for smoke testing:
44
+
45
+ ```bash
46
+ bun run dev:stack
47
+ ```
48
+
49
+ `dev:stack` now builds the bundled app, starts the local OpenCode sidecar on `127.0.0.1:4096`, and starts the Agent Mockingbird server in one command. `bun run dev:opencode` is also available if you want to run the sidecar separately.
50
+
51
+ Production build and run:
52
+
53
+ ```bash
54
+ bun run build
55
+ ./dist/agent-mockingbird
56
+ ```
57
+
58
+ Code quality:
59
+
60
+ ```bash
61
+ bun run test
62
+ bun run lint
63
+ bun run typecheck
64
+ bun run check:ship
65
+ ```
66
+
67
+ `bun run test` is intentionally scoped to `src` so local `opencode/` clone tests are not included.
68
+
69
+ `bun run check:ship` is the full ship-readiness gate. It bootstraps `vendor/opencode` if needed, verifies the OpenCode patch stack is reproducible, runs the repo lint/typecheck/build checks, checks generated artifacts, and compares full OpenCode workspace typecheck results against cleanroom so upstream-only baseline failures can be ignored.
70
+
71
+ OpenCode workflow:
72
+
73
+ ```bash
74
+ bun run opencode:sync --status
75
+ bun run opencode:sync --rebuild-only
76
+ bun run opencode:sync --check
77
+ ```
78
+
79
+ The repo now treats `cleanroom/opencode` as a pristine upstream clone, `vendor/opencode` as a generated editable worktree, and `patches/opencode/*.patch` as the tracked patch stack. If `vendor/opencode` is missing, run `bun run opencode:sync --rebuild-only` before local build/dev commands that need OpenCode sources.
80
+
81
+ Database migrations (Drizzle + SQLite):
82
+
83
+ ```bash
84
+ bun run db:generate
85
+ bun run db:migrate
86
+ bun run db:check
87
+ ```
88
+
89
+ By default the SQLite file is `./data/agent-mockingbird.db`. Override with `AGENT_MOCKINGBIRD_DB_PATH`.
90
+
91
+ Reset local database to defaults (including cron job tables):
92
+
93
+ ```bash
94
+ bun run db:wipe
95
+ ```
96
+
97
+ Memory CLI:
98
+
99
+ ```bash
100
+ bun run memory:status
101
+ bun run memory:sync
102
+ bun run memory:reindex
103
+ bun run memory:search "query"
104
+ bun run memory:e2e
105
+ bun run memory:trace:e2e
106
+ bun run src/backend/memory/cli.ts remember "some note to store"
107
+ bun run src/backend/memory/cli.ts activity 20
108
+ bun run memory:lint
109
+ ```
110
+
111
+ `memory:trace:e2e` auto-selects a model from existing sessions (prefers `main`). Override with `AGENT_MOCKINGBIRD_E2E_MODEL=provider/model`.
112
+
113
+ Memory operator references:
114
+
115
+ - `docs/memory-ops.md`
116
+ - `docs/memory-runtime-contract.md`
117
+ - `runtime-assets/workspace/.agents/skills/memory-ops/SKILL.md` (runtime bundle source)
118
+ - `.agents/skills/memory-ops/SKILL.md` (development copy)
119
+
120
+ ## Runtime
121
+
122
+ Agent Mockingbird runs with an OpenCode-backed runtime that forwards prompts to OpenCode and stores mirrored messages locally.
123
+
124
+ Runtime configuration is stored in JSON (`./data/agent-mockingbird.config.json` by default). On first boot, agent-mockingbird migrates legacy env/DB runtime settings into this file.
125
+ Example config template: `agent-mockingbird.config.example.json`.
126
+ `./config.json` at repo root is OpenCode config, not agent-mockingbird runtime config.
127
+ Runtime behavior is sourced from agent-mockingbird config JSON. OpenCode runtime env vars are no longer accepted for model/provider/timeouts/directory.
128
+ If you still have legacy `AGENT_MOCKINGBIRD_OPENCODE_*` runtime vars, run `bun run config:migrate-opencode-env` once, then unset them.
129
+
130
+ Skill deployment behavior (install/update):
131
+
132
+ - Runtime bundle source files live in `runtime-assets/workspace` and `runtime-assets/opencode-config`.
133
+ - Install/update syncs workspace files into the active workspace root, and syncs OpenCode managed config into an external config dir under `data/opencode-config/...`.
134
+ - Sync state is tracked separately in `data/runtime-assets-workspace-state.json` and `data/runtime-assets-opencode-config-state.json`.
135
+ - On update, interactive installs prompt only when both:
136
+ - local file changed since last sync
137
+ - packaged runtime asset also changed since last sync
138
+ - On non-interactive update conflicts, install creates `<file>.backup-<UTCSTAMP>` then overwrites with packaged content.
139
+ - Runtime OpenCode `skills.paths` is synced to include workspace `.agents/skills`.
140
+ - If `ui.skills` is empty, install/update initializes defaults:
141
+ - `config-editor`
142
+ - `config-auditor`
143
+ - `runtime-diagnose`
144
+ - `memory-ops`
145
+ - Install/update also seeds managed OpenCode config at `data/opencode-config/<fingerprint>/opencode.jsonc` from `runtime-assets/opencode-config`:
146
+ - default `agent.general.tools` enables `memory_search`, `memory_get`, and `memory_remember`.
147
+
148
+ Config API:
149
+
150
+ - `GET /api/config`
151
+ - `PATCH /api/config` (partial update with optimistic `expectedHash`)
152
+ - `PUT /api/config` (full replace with optimistic `expectedHash`)
153
+ - `GET /api/runtime/info` (effective OpenCode connection + directory/config persistence metadata)
154
+
155
+ After every config change, agent-mockingbird performs:
156
+
157
+ - schema validation
158
+ - semantic provider/model validation via OpenCode `config/providers`
159
+ - gateway smoke test prompt (expects an `OK` response pattern)
160
+
161
+ If any validation step fails, the config change is not persisted.
162
+
163
+ Auth and path env variables:
164
+
165
+ - `AGENT_MOCKINGBIRD_DB_PATH` (default `./data/agent-mockingbird.db`)
166
+ - `AGENT_MOCKINGBIRD_CONFIG_PATH` (default `./data/agent-mockingbird.config.json`)
167
+ - `AGENT_MOCKINGBIRD_OPENCODE_AUTH_HEADER` (optional full `Authorization` header)
168
+ - `AGENT_MOCKINGBIRD_OPENCODE_USERNAME` / `AGENT_MOCKINGBIRD_OPENCODE_PASSWORD` (optional Basic auth fallback)
169
+
170
+ Cron environment variables:
171
+
172
+ - `AGENT_MOCKINGBIRD_CRON_ENABLED` (default `true`)
173
+ - `AGENT_MOCKINGBIRD_CRON_SCHEDULER_POLL_MS` (default `1000`)
174
+ - `AGENT_MOCKINGBIRD_CRON_WORKER_POLL_MS` (default `1000`)
175
+ - `AGENT_MOCKINGBIRD_CRON_LEASE_MS` (default `30000`)
176
+ - `AGENT_MOCKINGBIRD_CRON_MAX_ENQUEUE_PER_JOB_TICK` (default `25`)
177
+
178
+ Memory mode environment variables:
179
+
180
+ - `AGENT_MOCKINGBIRD_MEMORY_ENABLED` (default `true`)
181
+ - `AGENT_MOCKINGBIRD_MEMORY_WORKSPACE_DIR` (default `./data/workspace`)
182
+ - `AGENT_MOCKINGBIRD_MEMORY_EMBED_PROVIDER` (`ollama` or `none`, default `ollama`)
183
+ - `AGENT_MOCKINGBIRD_MEMORY_EMBED_MODEL` (default `qwen3-embedding:4b`)
184
+ - `AGENT_MOCKINGBIRD_MEMORY_OLLAMA_BASE_URL` (default `http://127.0.0.1:11434`)
185
+ - `AGENT_MOCKINGBIRD_MEMORY_CHUNK_TOKENS` (default `400`)
186
+ - `AGENT_MOCKINGBIRD_MEMORY_CHUNK_OVERLAP` (default `80`)
187
+ - `AGENT_MOCKINGBIRD_MEMORY_MAX_RESULTS` (default `6`)
188
+ - `AGENT_MOCKINGBIRD_MEMORY_MIN_SCORE` (default `0.25`)
189
+ - `AGENT_MOCKINGBIRD_MEMORY_SYNC_COOLDOWN_MS` (default `10000`)
190
+ - `AGENT_MOCKINGBIRD_MEMORY_TOOL_MODE` (`hybrid`, `inject_only`, `tool_only`; default `hybrid`)
191
+ - `AGENT_MOCKINGBIRD_MEMORY_INJECTION_DEDUPE_ENABLED` (default `true`)
192
+ - `AGENT_MOCKINGBIRD_MEMORY_INJECTION_DEDUPE_FALLBACK_RECALL_ONLY` (default `true`)
193
+ - `AGENT_MOCKINGBIRD_MEMORY_INJECTION_DEDUPE_MAX_TRACKED` (default `256`)
194
+
195
+ OpenCode local Agent Mockingbird plugin:
196
+
197
+ - `data/opencode-config/<fingerprint>/plugins/agent-mockingbird.ts`
198
+
199
+ The plugin registers these custom tools against Agent Mockingbird APIs:
200
+
201
+ - `memory_search`
202
+ - `memory_get`
203
+ - `memory_remember`
204
+ - `cron_manager`
205
+ - `config_manager`
206
+ - `agent_type_manager`
207
+
208
+ Set `AGENT_MOCKINGBIRD_MEMORY_API_BASE_URL`, `AGENT_MOCKINGBIRD_CRON_API_BASE_URL`, and/or `AGENT_MOCKINGBIRD_CONFIG_API_BASE_URL` for the OpenCode process if needed (default `http://127.0.0.1:3001`).
209
+
210
+ Memory API endpoints used by tools:
211
+
212
+ - `POST /api/memory/retrieve`
213
+ - `POST /api/memory/read`
214
+ - `POST /api/memory/remember`
215
+ - `POST /api/memory/remember/validate`
216
+ - `GET /api/memory/activity`
217
+
218
+ Run API endpoints:
219
+
220
+ - `POST /api/runs`
221
+ - `GET /api/runs/:id`
222
+ - `GET /api/runs/:id/events`
223
+ - `GET /api/runs/:id/events/stream`
224
+
225
+ Cron API endpoints:
226
+
227
+ - `GET /api/mockingbird/cron/health`
228
+ - `GET /api/mockingbird/cron/jobs`
229
+ - `POST /api/mockingbird/cron/jobs`
230
+ - `GET /api/mockingbird/cron/jobs/:id`
231
+ - `PATCH /api/mockingbird/cron/jobs/:id`
232
+ - `DELETE /api/mockingbird/cron/jobs/:id`
233
+ - `POST /api/mockingbird/cron/jobs/:id/run`
234
+ - `GET /api/mockingbird/cron/instances`
235
+ - `GET /api/mockingbird/cron/instances/:id/steps`
236
+ - `POST /api/mockingbird/cron/manage` (used by `cron_manager` and `describe_contract`)
237
+
238
+ Cron jobs no longer support `handlerKey`; use the current `runMode` contract with `conditionModulePath` and/or `agentPromptTemplate` instead.
239
+
240
+ Environment variables are parsed and validated at startup via `@t3-oss/env-core` + `zod`.
241
+
242
+ `bun run dev:stack` launcher env knobs:
243
+
244
+ - `OPENCODE_HOST` (default `127.0.0.1`)
245
+ - `OPENCODE_PORT` (default `4096`)
246
+ - `AGENT_MOCKINGBIRD_PORT` (default `3001`)
247
+ - `OPENCODE_LOG_LEVEL` (default `INFO`)
248
+
249
+ ## OpenCode Agent Persistence
250
+
251
+ Agent Mockingbird now manages OpenCode agents directly in an external managed OpenCode config dir.
252
+
253
+ - Save target is `data/opencode-config/<fingerprint>/opencode.jsonc` by default.
254
+ - Managed agent markdown files live under that external config dir as well.
255
+ - Agents UI shows both the bound workspace and the effective config path.
256
+
257
+ ## Workspace Bootstrap Context (OpenClaw-style)
258
+
259
+ Agent Mockingbird now injects workspace markdown context into runtime system prompts using OpenClaw-style files from your bound workspace root (not `.opencode/`):
260
+
261
+ - `AGENTS.md`
262
+ - `SOUL.md`
263
+ - `TOOLS.md`
264
+ - `IDENTITY.md`
265
+ - `USER.md`
266
+ - `HEARTBEAT.md`
267
+ - `BOOTSTRAP.md`
268
+ - `MEMORY.md` / `memory.md`
269
+
270
+ Behavior:
271
+
272
+ - Per-file and total prompt injection caps are configurable at `runtime.opencode.bootstrap`.
273
+ - If a selected OpenCode agent is `mode: "subagent"` and `runtime.opencode.bootstrap.subagentMinimal=true`, only `AGENTS.md` and `TOOLS.md` are injected.
274
+ - `IDENTITY.md` is parsed for metadata (name/emoji/avatar/theme/creature/vibe) and returned via `GET /api/runtime/info`.
275
+ - Selected agent prompt text can also be mirrored into runtime system prompts with `runtime.opencode.bootstrap.includeAgentPrompt=true`.
276
+
277
+ - `POST /api/config/opencode/bootstrap/import-openclaw`
278
+ - Body:
279
+ - Local source: `{ "source": { "mode": "local", "path": "/path/to/openclaw/workspace" } }`
280
+ - Git source: `{ "source": { "mode": "git", "url": "git@github.com:you/openclaw-memory.git", "ref": "main" } }`
281
+ - Optional: `targetDirectory`
282
+ - Performs one-shot migration with conflict rules:
283
+ - Missing target path: copy source file wholesale.
284
+ - Existing target path: keep target by default.
285
+ - `AGENTS.md` conflicts: attempt model-assisted rewrite/merge; if unavailable/invalid, keep target.
286
+ - Compatibility bridge: if source has no `AGENTS.md` but has `CLAUDE.md`, importer maps `CLAUDE.md -> AGENTS.md` during migration.
287
+ - Preserves protected Agent Mockingbird runtime files and triggers a memory index sync after import.
288
+
289
+ CLI migration UX is now integrated into `agent-mockingbird onboard`:
290
+
291
+ - Choose onboarding path: `quickstart`, `model-only`, `memory-only`, `openclaw-only`, or `skip`.
292
+ - OpenClaw migration runs through an onboarding wizard (git clone or local folder source).
293
+ - `AGENTS.md` conflicts go through a model-assisted rewrite/merge pass via OpenCode; on failure, existing target content is kept.
294
+ - If memory is enabled, onboarding runs memory sync after successful migration.
295
+ - Legacy `agent-mockingbird import openclaw ...` commands are removed.
296
+
297
+ If OpenCode UI/TUI looks different from Agent Mockingbird:
298
+
299
+ 1. Confirm `GET /api/runtime/info` reports the directory you expect.
300
+ 2. Launch/attach OpenCode against the same workspace directory.
301
+ 3. Verify the same external `opencode.jsonc` file path is being used.
302
+
303
+ ## Deployment
304
+
305
+ Recommended production topology is **single VM + systemd sidecar**:
306
+
307
+ - `opencode.service` running on `127.0.0.1:4096`
308
+ - `agent-mockingbird.service` running on `127.0.0.1:3001`
309
+ - both pinned to one workspace path via `runtime.opencode.directory` in agent-mockingbird config
310
+ - `runtime.memory.workspaceDir` must resolve to the same path as `runtime.opencode.directory`
311
+
312
+ Deployment artifacts:
313
+
314
+ - `deploy/systemd/opencode.service`
315
+ - `deploy/systemd/agent-mockingbird.service`
316
+ - `deploy/systemd/README.md`
317
+ - `deploy/docker-compose.yml` (reference stack)
318
+
319
+ ## CI/CD Release Bundles
320
+
321
+ This repo uses one CI/CD workflow:
322
+
323
+ - `.github/workflows/ci.yml` runs `bun run check:ship`, verifies the committed ship artifacts, and publishes the same packed artifact to npm from GitHub Actions.
324
+ - Pull requests run checks only (no publish).
325
+ - Pushes to `main` run checks only. `latest` is reserved for versioned releases.
326
+ - Pushes to matching `v*` tags publish the exact `package.json` version with npm tag `latest`.
327
+ - Pushes to non-`main` branches by `waffleophagus` publish preview builds to npm tag `next`.
328
+ - Manual dispatch runs the workflow but does not publish by itself.
329
+ - Tag pushes must match `v<package.json version>` or CI fails.
330
+
331
+ Published package artifact:
332
+
333
+ - `agent-mockingbird@<version>` generated from a single packed `.tgz` built in CI after `bun run check:ship`.
334
+ - `@waffleophagus/agent-mockingbird-installer@<version>` published alongside it.
335
+
336
+ Detailed install instructions are in `deploy/RELEASE_INSTALL.md`.
337
+
338
+ ## Linux Onboarding (GitHub + npm)
339
+
340
+ Primary path (interactive by default):
341
+
342
+ ```bash
343
+ curl -fsSL "https://raw.githubusercontent.com/waffleophagus/agent-mockingbird/main/scripts/onboard/bootstrap.sh" | bash
344
+ ```
345
+
346
+ Run a different lifecycle command:
347
+
348
+ ```bash
349
+ curl -fsSL "https://raw.githubusercontent.com/waffleophagus/agent-mockingbird/main/scripts/onboard/bootstrap.sh" | bash -s -- status
350
+ ```
351
+
352
+ Install from a feature branch preview:
353
+
354
+ ```bash
355
+ BRANCH="<branch-name>"
356
+ VERSION="<published-preview-version>"
357
+ AGENT_MOCKINGBIRD_TAG="${VERSION}" \
358
+ curl -fsSL "https://raw.githubusercontent.com/waffleophagus/agent-mockingbird/${BRANCH}/scripts/onboard/bootstrap.sh" | bash
359
+ ```
360
+
361
+ Branch preview installs should pin `AGENT_MOCKINGBIRD_TAG` to the exact published `next` version so the bootstrap script and installed package stay aligned.
362
+
363
+ Direct package execution from npm:
364
+
365
+ ```bash
366
+ npx --yes \
367
+ --package "@waffleophagus/agent-mockingbird-installer@latest" \
368
+ agent-mockingbird-installer install
369
+ ```
370
+
371
+ ```bash
372
+ bunx --bun npm exec --yes \
373
+ --package "@waffleophagus/agent-mockingbird-installer@latest" \
374
+ agent-mockingbird-installer -- install
375
+ ```
376
+
377
+ Agent Mockingbird commands:
378
+
379
+ ```bash
380
+ agent-mockingbird install
381
+ agent-mockingbird update
382
+ agent-mockingbird onboard
383
+ agent-mockingbird status
384
+ agent-mockingbird restart
385
+ agent-mockingbird start
386
+ agent-mockingbird stop
387
+ agent-mockingbird uninstall
388
+ ```
389
+
390
+ `agent-mockingbird install` and `agent-mockingbird update` now show a mode-specific action plan before confirmation.
391
+
392
+ - `install` flow now launches interactive provider/model onboarding immediately (interactive installs).
393
+ - `update` plan explicitly calls out what is refreshed vs what is preserved (data/workspace/config are not reset).
394
+ - `update --dry-run` previews planned update actions without mutating files/services.
395
+ - `onboard` reruns interactive provider/model onboarding without reinstalling.
396
+ - Install/update now also maintain an `opencode` shim in `~/.local/bin` so the OpenCode CLI is directly available.
397
+ - Onboarding model selection is searchable + paginated (works with providers that expose large model catalogs).
398
+ - During onboarding, provider-auth changes trigger a transparent `opencode.service` refresh before model selection, so newly added providers/models show up immediately.
399
+ - Onboarding can now configure memory embeddings for Ollama: set the Ollama URL, discover `/api/tags` models live, then select an embedding model with searchable pagination.
400
+ - `agent-mockingbird onboard` supports `memory-only` and `openclaw-only` paths for focused setup.
401
+
402
+ Compatibility alias remains available:
403
+
404
+ ```bash
405
+ agent-mockingbird-installer install
406
+ ```
407
+
408
+ Default install root is `~/.agent-mockingbird`, with systemd **user** services:
409
+
410
+ - `opencode.service` (local sidecar on `127.0.0.1:4096`)
411
+ - `agent-mockingbird.service` (dashboard/API on `127.0.0.1:3001`)
412
+
413
+ On Linux, installer attempts `loginctl enable-linger $USER` so services keep running after logout.
414
+
415
+ ## Install Directly From GitHub (No npmjs.org)
416
+
417
+ You can still install the main CLI directly from git:
418
+
419
+ ```bash
420
+ OWNER="<github-owner>"
421
+ REPO="<repo-name>"
422
+ VERSION="v0.1.0"
423
+ bun add -g "github:${OWNER}/${REPO}#${VERSION}"
424
+ ```
425
+
426
+ 2. Run:
427
+
428
+ ```bash
429
+ agent-mockingbird
430
+ ```
431
+
432
+ ## Publish To Package Registry
433
+
434
+ `ci.yml` publish steps expect this repository secret:
435
+
436
+ - `NPM_TOKEN` with publish permission for `agent-mockingbird` and `@waffleophagus/agent-mockingbird-installer` on npmjs
437
+
438
+ On a tag push like `v0.1.0`, CI publishes `agent-mockingbird@0.1.0` and `@waffleophagus/agent-mockingbird-installer@0.1.0` to npm with the `latest` tag.
439
+
440
+ `main` pushes do not publish. To update `latest`, tag a version from `main`.
441
+
442
+ Non-`main` branch pushes by `waffleophagus` publish preview builds like `0.0.1-next.<branch>.<run-number>` with the `next` tag.
443
+
444
+ Install from npm with Bun:
445
+
446
+ ```bash
447
+ bun add -g agent-mockingbird
448
+ agent-mockingbird
449
+ ```
450
+
451
+ If you need to publish or consume the package from a non-default registry later, `AGENT_MOCKINGBIRD_REGISTRY_URL` and `--registry-url` still exist, but the repo now assumes npmjs by default.
@@ -0,0 +1,11 @@
1
+ # Third-Party Notices
2
+
3
+ ## qmd
4
+
5
+ Portions of `src/backend/memory/qmdPort.ts` are adapted from qmd:
6
+
7
+ - Repository: https://github.com/tobi/qmd
8
+ - License: MIT
9
+ - Copyright (c) 2024-2026 Tobi Lutke
10
+
11
+ The qmd MIT license terms apply to those adapted portions.
@@ -0,0 +1,135 @@
1
+ {
2
+ "version": 2,
3
+ "workspace": {
4
+ "pinnedDirectory": "./data/workspace"
5
+ },
6
+ "runtime": {
7
+ "opencode": {
8
+ "baseUrl": "http://127.0.0.1:4096",
9
+ "providerId": "opencode",
10
+ "modelId": "big-pickle",
11
+ "fallbackModels": [],
12
+ "imageModel": null,
13
+ "smallModel": "opencode/big-pickle",
14
+ "timeoutMs": 120000,
15
+ "promptTimeoutMs": 300000,
16
+ "runWaitTimeoutMs": 180000,
17
+ "childSessionHideAfterDays": 3,
18
+ "directory": "./data/workspace",
19
+ "bootstrap": {
20
+ "enabled": true,
21
+ "maxCharsPerFile": 20000,
22
+ "maxCharsTotal": 150000,
23
+ "subagentMinimal": true,
24
+ "includeAgentPrompt": true
25
+ }
26
+ },
27
+ "smokeTest": {
28
+ "prompt": "Just respond \"OK\" to this to confirm the gateway is working.",
29
+ "expectedResponsePattern": "\\bok\\b"
30
+ },
31
+ "runStream": {
32
+ "heartbeatMs": 15000,
33
+ "replayPageSize": 200
34
+ },
35
+ "memory": {
36
+ "enabled": true,
37
+ "workspaceDir": "./data/workspace",
38
+ "embedProvider": "ollama",
39
+ "embedModel": "granite-embedding:278m",
40
+ "ollamaBaseUrl": "http://127.0.0.1:11434",
41
+ "chunkTokens": 400,
42
+ "chunkOverlap": 80,
43
+ "maxResults": 4,
44
+ "minScore": 0.35,
45
+ "syncCooldownMs": 10000,
46
+ "toolMode": "tool_only",
47
+ "injectionDedupeEnabled": true,
48
+ "injectionDedupeFallbackRecallOnly": true,
49
+ "injectionDedupeMaxTracked": 256,
50
+ "retrieval": {
51
+ "engine": "qmd_hybrid",
52
+ "strongSignalMinScore": 0.85,
53
+ "strongSignalMinGap": 0.15,
54
+ "candidateLimit": 40,
55
+ "rrfK": 60,
56
+ "expansionEnabled": true,
57
+ "conceptExpansionEnabled": true,
58
+ "conceptExpansionMaxPacks": 3,
59
+ "conceptExpansionMaxTerms": 10,
60
+ "rerankEnabled": true,
61
+ "rerankTopN": 40,
62
+ "semanticRescueEnabled": true,
63
+ "semanticRescueMinVectorScore": 0.75,
64
+ "semanticRescueMaxResults": 2,
65
+ "expansionModel": null,
66
+ "rerankModel": null,
67
+ "vectorBackend": "sqlite_vec",
68
+ "vectorUnavailableFallback": "disabled",
69
+ "vectorK": 60,
70
+ "vectorProbeLimit": 20
71
+ }
72
+ },
73
+ "heartbeat": {
74
+ "enabled": true,
75
+ "interval": "30m",
76
+ "agentId": "build",
77
+ "model": "opencode/big-pickle",
78
+ "prompt": "Read HEARTBEAT.md if it exists (workspace context). Follow it strictly. Do not infer or repeat old tasks from prior chats. If nothing needs attention, reply HEARTBEAT_OK.",
79
+ "ackMaxChars": 300,
80
+ "activeHours": null
81
+ },
82
+ "cron": {
83
+ "defaultMaxAttempts": 3,
84
+ "defaultRetryBackoffMs": 30000,
85
+ "retryBackoffCapMs": 3600000,
86
+ "conditionalModuleTimeoutMs": 30000
87
+ },
88
+ "configPolicy": {
89
+ "mode": "builder",
90
+ "denyPaths": [
91
+ "version",
92
+ "runtime.configPolicy",
93
+ "runtime.smokeTest"
94
+ ],
95
+ "strictAllowPaths": [
96
+ "runtime.opencode.runWaitTimeoutMs",
97
+ "runtime.opencode.childSessionHideAfterDays",
98
+ "runtime.opencode.bootstrap",
99
+ "runtime.runStream",
100
+ "runtime.memory",
101
+ "runtime.heartbeat",
102
+ "runtime.cron",
103
+ "ui.skills",
104
+ "ui.mcps",
105
+ "ui.mcpServers",
106
+ "ui.agents",
107
+ "ui.agentTypes"
108
+ ],
109
+ "requireExpectedHash": true,
110
+ "requireSmokeTest": true,
111
+ "autoRollbackOnFailure": true
112
+ }
113
+ },
114
+ "ui": {
115
+ "skills": [
116
+ "config-editor",
117
+ "config-auditor",
118
+ "runtime-diagnose"
119
+ ],
120
+ "mcps": [],
121
+ "mcpServers": [],
122
+ "agents": [],
123
+ "agentTypes": [
124
+ {
125
+ "id": "build",
126
+ "name": "Agent Mockingbird",
127
+ "description": "Default primary agent.",
128
+ "mode": "primary",
129
+ "hidden": false,
130
+ "disable": false,
131
+ "options": {}
132
+ }
133
+ ]
134
+ }
135
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@agent-mockingbird/server",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "type": "module",
6
+ "module": "src/index.ts",
7
+ "scripts": {
8
+ "dev": "bun --hot src/index.ts",
9
+ "start": "NODE_ENV=production bun src/index.ts",
10
+ "build": "bun run ../../build.ts",
11
+ "build:bin": "bun run ../../build-bin.ts",
12
+ "lint": "eslint .",
13
+ "test": "bun test ./src",
14
+ "typecheck": "tsc -p tsconfig.json --noEmit",
15
+ "db:generate": "drizzle-kit generate --config ../../drizzle.config.ts",
16
+ "db:migrate": "bun run src/backend/db/migrate.ts",
17
+ "db:check": "drizzle-kit check --config ../../drizzle.config.ts",
18
+ "db:wipe": "bun run src/backend/db/wipe.ts"
19
+ },
20
+ "dependencies": {
21
+ "hono": "^4.10.7",
22
+ "@opencode-ai/plugin": "^1.2.15",
23
+ "@opencode-ai/sdk": "^1.2.15",
24
+ "@t3-oss/env-core": "^0.13.10",
25
+ "@agent-mockingbird/contracts": "workspace:*",
26
+ "cron": "^4.4.0",
27
+ "drizzle-orm": "^0.45.1",
28
+ "jsonc-parser": "^3.3.1",
29
+ "sqlite-vec": "0.1.7-alpha.2",
30
+ "zod": "^4.3.6"
31
+ }
32
+ }