bajaclaw 0.10.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 (248) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +639 -0
  3. package/bin/bajaclaw.js +35 -0
  4. package/bin/create-bajaclaw.js +17 -0
  5. package/dist/agent.d.ts +29 -0
  6. package/dist/agent.js +231 -0
  7. package/dist/agent.js.map +1 -0
  8. package/dist/api/server.d.ts +15 -0
  9. package/dist/api/server.js +215 -0
  10. package/dist/api/server.js.map +1 -0
  11. package/dist/api/translate.d.ts +61 -0
  12. package/dist/api/translate.js +109 -0
  13. package/dist/api/translate.js.map +1 -0
  14. package/dist/banner.d.ts +7 -0
  15. package/dist/banner.js +31 -0
  16. package/dist/banner.js.map +1 -0
  17. package/dist/channels/gateway.d.ts +1 -0
  18. package/dist/channels/gateway.js +76 -0
  19. package/dist/channels/gateway.js.map +1 -0
  20. package/dist/claude.d.ts +9 -0
  21. package/dist/claude.js +170 -0
  22. package/dist/claude.js.map +1 -0
  23. package/dist/cli.d.ts +2 -0
  24. package/dist/cli.js +303 -0
  25. package/dist/cli.js.map +1 -0
  26. package/dist/commands/channel.d.ts +3 -0
  27. package/dist/commands/channel.js +27 -0
  28. package/dist/commands/channel.js.map +1 -0
  29. package/dist/commands/compact.d.ts +8 -0
  30. package/dist/commands/compact.js +60 -0
  31. package/dist/commands/compact.js.map +1 -0
  32. package/dist/commands/daemon.d.ts +7 -0
  33. package/dist/commands/daemon.js +129 -0
  34. package/dist/commands/daemon.js.map +1 -0
  35. package/dist/commands/dashboard.d.ts +1 -0
  36. package/dist/commands/dashboard.js +78 -0
  37. package/dist/commands/dashboard.js.map +1 -0
  38. package/dist/commands/doctor.d.ts +1 -0
  39. package/dist/commands/doctor.js +25 -0
  40. package/dist/commands/doctor.js.map +1 -0
  41. package/dist/commands/dry-run.d.ts +1 -0
  42. package/dist/commands/dry-run.js +5 -0
  43. package/dist/commands/dry-run.js.map +1 -0
  44. package/dist/commands/effort.d.ts +6 -0
  45. package/dist/commands/effort.js +33 -0
  46. package/dist/commands/effort.js.map +1 -0
  47. package/dist/commands/guide.d.ts +4 -0
  48. package/dist/commands/guide.js +52 -0
  49. package/dist/commands/guide.js.map +1 -0
  50. package/dist/commands/health.d.ts +1 -0
  51. package/dist/commands/health.js +20 -0
  52. package/dist/commands/health.js.map +1 -0
  53. package/dist/commands/init.d.ts +12 -0
  54. package/dist/commands/init.js +114 -0
  55. package/dist/commands/init.js.map +1 -0
  56. package/dist/commands/mcp.d.ts +9 -0
  57. package/dist/commands/mcp.js +63 -0
  58. package/dist/commands/mcp.js.map +1 -0
  59. package/dist/commands/migrate.d.ts +1 -0
  60. package/dist/commands/migrate.js +58 -0
  61. package/dist/commands/migrate.js.map +1 -0
  62. package/dist/commands/model.d.ts +5 -0
  63. package/dist/commands/model.js +31 -0
  64. package/dist/commands/model.js.map +1 -0
  65. package/dist/commands/persona.d.ts +6 -0
  66. package/dist/commands/persona.js +67 -0
  67. package/dist/commands/persona.js.map +1 -0
  68. package/dist/commands/port.d.ts +15 -0
  69. package/dist/commands/port.js +88 -0
  70. package/dist/commands/port.js.map +1 -0
  71. package/dist/commands/profile.d.ts +4 -0
  72. package/dist/commands/profile.js +41 -0
  73. package/dist/commands/profile.js.map +1 -0
  74. package/dist/commands/serve.d.ts +14 -0
  75. package/dist/commands/serve.js +62 -0
  76. package/dist/commands/serve.js.map +1 -0
  77. package/dist/commands/setup.d.ts +17 -0
  78. package/dist/commands/setup.js +228 -0
  79. package/dist/commands/setup.js.map +1 -0
  80. package/dist/commands/skill.d.ts +7 -0
  81. package/dist/commands/skill.js +137 -0
  82. package/dist/commands/skill.js.map +1 -0
  83. package/dist/commands/start.d.ts +6 -0
  84. package/dist/commands/start.js +25 -0
  85. package/dist/commands/start.js.map +1 -0
  86. package/dist/commands/status.d.ts +1 -0
  87. package/dist/commands/status.js +35 -0
  88. package/dist/commands/status.js.map +1 -0
  89. package/dist/commands/subagent.d.ts +14 -0
  90. package/dist/commands/subagent.js +173 -0
  91. package/dist/commands/subagent.js.map +1 -0
  92. package/dist/commands/trigger.d.ts +1 -0
  93. package/dist/commands/trigger.js +13 -0
  94. package/dist/commands/trigger.js.map +1 -0
  95. package/dist/commands/uninstall.d.ts +5 -0
  96. package/dist/commands/uninstall.js +165 -0
  97. package/dist/commands/uninstall.js.map +1 -0
  98. package/dist/commands/update.d.ts +7 -0
  99. package/dist/commands/update.js +49 -0
  100. package/dist/commands/update.js.map +1 -0
  101. package/dist/concurrency.d.ts +1 -0
  102. package/dist/concurrency.js +17 -0
  103. package/dist/concurrency.js.map +1 -0
  104. package/dist/config.d.ts +5 -0
  105. package/dist/config.js +42 -0
  106. package/dist/config.js.map +1 -0
  107. package/dist/db.d.ts +3 -0
  108. package/dist/db.js +124 -0
  109. package/dist/db.js.map +1 -0
  110. package/dist/delegation.d.ts +6 -0
  111. package/dist/delegation.js +21 -0
  112. package/dist/delegation.js.map +1 -0
  113. package/dist/health-check.d.ts +6 -0
  114. package/dist/health-check.js +38 -0
  115. package/dist/health-check.js.map +1 -0
  116. package/dist/logger.d.ts +11 -0
  117. package/dist/logger.js +53 -0
  118. package/dist/logger.js.map +1 -0
  119. package/dist/mcp/consumer.d.ts +15 -0
  120. package/dist/mcp/consumer.js +74 -0
  121. package/dist/mcp/consumer.js.map +1 -0
  122. package/dist/mcp/server.d.ts +6 -0
  123. package/dist/mcp/server.js +260 -0
  124. package/dist/mcp/server.js.map +1 -0
  125. package/dist/memory/claude-compat.d.ts +4 -0
  126. package/dist/memory/claude-compat.js +56 -0
  127. package/dist/memory/claude-compat.js.map +1 -0
  128. package/dist/memory/compact.d.ts +25 -0
  129. package/dist/memory/compact.js +195 -0
  130. package/dist/memory/compact.js.map +1 -0
  131. package/dist/memory/extract.d.ts +3 -0
  132. package/dist/memory/extract.js +56 -0
  133. package/dist/memory/extract.js.map +1 -0
  134. package/dist/memory/recall.d.ts +5 -0
  135. package/dist/memory/recall.js +47 -0
  136. package/dist/memory/recall.js.map +1 -0
  137. package/dist/model-picker.d.ts +33 -0
  138. package/dist/model-picker.js +104 -0
  139. package/dist/model-picker.js.map +1 -0
  140. package/dist/paths.d.ts +12 -0
  141. package/dist/paths.js +49 -0
  142. package/dist/paths.js.map +1 -0
  143. package/dist/persona-io.d.ts +5 -0
  144. package/dist/persona-io.js +29 -0
  145. package/dist/persona-io.js.map +1 -0
  146. package/dist/persona.d.ts +12 -0
  147. package/dist/persona.js +54 -0
  148. package/dist/persona.js.map +1 -0
  149. package/dist/prompt.d.ts +5 -0
  150. package/dist/prompt.js +56 -0
  151. package/dist/prompt.js.map +1 -0
  152. package/dist/safety.d.ts +17 -0
  153. package/dist/safety.js +47 -0
  154. package/dist/safety.js.map +1 -0
  155. package/dist/scheduler/cron.d.ts +4 -0
  156. package/dist/scheduler/cron.js +44 -0
  157. package/dist/scheduler/cron.js.map +1 -0
  158. package/dist/scheduler/index.d.ts +7 -0
  159. package/dist/scheduler/index.js +15 -0
  160. package/dist/scheduler/index.js.map +1 -0
  161. package/dist/scheduler/launchd.d.ts +4 -0
  162. package/dist/scheduler/launchd.js +73 -0
  163. package/dist/scheduler/launchd.js.map +1 -0
  164. package/dist/scheduler/schtasks.d.ts +4 -0
  165. package/dist/scheduler/schtasks.js +45 -0
  166. package/dist/scheduler/schtasks.js.map +1 -0
  167. package/dist/scheduler/systemd.d.ts +5 -0
  168. package/dist/scheduler/systemd.js +86 -0
  169. package/dist/scheduler/systemd.js.map +1 -0
  170. package/dist/self-improve.d.ts +4 -0
  171. package/dist/self-improve.js +48 -0
  172. package/dist/self-improve.js.map +1 -0
  173. package/dist/skills/auto-skiller.d.ts +21 -0
  174. package/dist/skills/auto-skiller.js +156 -0
  175. package/dist/skills/auto-skiller.js.map +1 -0
  176. package/dist/skills/loader.d.ts +3 -0
  177. package/dist/skills/loader.js +127 -0
  178. package/dist/skills/loader.js.map +1 -0
  179. package/dist/skills/matcher.d.ts +2 -0
  180. package/dist/skills/matcher.js +27 -0
  181. package/dist/skills/matcher.js.map +1 -0
  182. package/dist/skills/porter.d.ts +27 -0
  183. package/dist/skills/porter.js +109 -0
  184. package/dist/skills/porter.js.map +1 -0
  185. package/dist/types.d.ts +110 -0
  186. package/dist/types.js +2 -0
  187. package/dist/types.js.map +1 -0
  188. package/dist/updater.d.ts +25 -0
  189. package/dist/updater.js +185 -0
  190. package/dist/updater.js.map +1 -0
  191. package/package.json +53 -0
  192. package/scripts/postinstall.js +33 -0
  193. package/skills/configure-effort/SKILL.md +36 -0
  194. package/skills/configure-model/SKILL.md +41 -0
  195. package/skills/configure-tools/SKILL.md +51 -0
  196. package/skills/daily-briefing/SKILL.md +19 -0
  197. package/skills/delegate-to-subagent/SKILL.md +63 -0
  198. package/skills/email-triage/SKILL.md +21 -0
  199. package/skills/setup-api/SKILL.md +115 -0
  200. package/skills/setup-compaction/SKILL.md +102 -0
  201. package/skills/setup-daemon/SKILL.md +49 -0
  202. package/skills/setup-dashboard/SKILL.md +39 -0
  203. package/skills/setup-discord/SKILL.md +54 -0
  204. package/skills/setup-heartbeat/SKILL.md +51 -0
  205. package/skills/setup-mcp-port/SKILL.md +54 -0
  206. package/skills/setup-memory-sync/SKILL.md +45 -0
  207. package/skills/setup-profile/SKILL.md +44 -0
  208. package/skills/setup-self-update/SKILL.md +45 -0
  209. package/skills/setup-subagent/SKILL.md +102 -0
  210. package/skills/setup-telegram/SKILL.md +54 -0
  211. package/skills/setup-uninstall/SKILL.md +55 -0
  212. package/skills/web-research/SKILL.md +20 -0
  213. package/templates/code/AGENT.md +15 -0
  214. package/templates/code/HEARTBEAT.md +11 -0
  215. package/templates/code/SOUL.md +10 -0
  216. package/templates/code/bajaclaw.config.json +5 -0
  217. package/templates/code/scripts/launch.bat +4 -0
  218. package/templates/code/scripts/launch.sh +4 -0
  219. package/templates/custom/AGENT.md +14 -0
  220. package/templates/custom/HEARTBEAT.md +11 -0
  221. package/templates/custom/SOUL.md +10 -0
  222. package/templates/custom/bajaclaw.config.json +5 -0
  223. package/templates/custom/scripts/launch.bat +4 -0
  224. package/templates/custom/scripts/launch.sh +4 -0
  225. package/templates/outreach/AGENT.md +11 -0
  226. package/templates/outreach/HEARTBEAT.md +11 -0
  227. package/templates/outreach/SOUL.md +10 -0
  228. package/templates/outreach/bajaclaw.config.json +5 -0
  229. package/templates/outreach/scripts/launch.bat +4 -0
  230. package/templates/outreach/scripts/launch.sh +4 -0
  231. package/templates/research/AGENT.md +27 -0
  232. package/templates/research/HEARTBEAT.md +11 -0
  233. package/templates/research/SOUL.md +10 -0
  234. package/templates/research/bajaclaw.config.json +5 -0
  235. package/templates/research/scripts/launch.bat +4 -0
  236. package/templates/research/scripts/launch.sh +4 -0
  237. package/templates/social/AGENT.md +10 -0
  238. package/templates/social/HEARTBEAT.md +11 -0
  239. package/templates/social/SOUL.md +10 -0
  240. package/templates/social/bajaclaw.config.json +5 -0
  241. package/templates/social/scripts/launch.bat +4 -0
  242. package/templates/social/scripts/launch.sh +4 -0
  243. package/templates/support/AGENT.md +10 -0
  244. package/templates/support/HEARTBEAT.md +11 -0
  245. package/templates/support/SOUL.md +10 -0
  246. package/templates/support/bajaclaw.config.json +5 -0
  247. package/templates/support/scripts/launch.bat +4 -0
  248. package/templates/support/scripts/launch.sh +4 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BajaClaw contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,639 @@
1
+ # BajaClaw
2
+
3
+ ```
4
+ ██████╗ █████╗ ██╗ █████╗ ██████╗██╗ █████╗ ██╗ ██╗
5
+ ██╔══██╗██╔══██╗ ██║██╔══██╗ ██╔════╝██║ ██╔══██╗██║ ██║
6
+ ██████╔╝███████║ ██║███████║ ██║ ██║ ███████║██║ █╗ ██║
7
+ ██╔══██╗██╔══██║██ ██║██╔══██║ ██║ ██║ ██╔══██║██║███╗██║
8
+ ██████╔╝██║ ██║╚█████╔╝██║ ██║ ╚██████╗███████╗██║ ██║╚███╔███╔╝
9
+ ╚═════╝ ╚═╝ ╚═╝ ╚════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝╚═╝ ╚═╝ ╚══╝╚══╝
10
+ autonomous agents on your terms · MIT · v0.10.1
11
+ ```
12
+
13
+ **BajaClaw is a long-running agent runtime for the `claude` CLI.** It turns
14
+ the one-shot `claude -p` command into an always-on, scheduled, memory-backed,
15
+ skill-matching autonomous agent — with a local dashboard, multiple profiles,
16
+ OS-native scheduling, and first-class MCP integration.
17
+
18
+ You install it once. It sets itself up. You run `bajaclaw start`. It goes.
19
+
20
+ ---
21
+
22
+ ## Install
23
+
24
+ ```
25
+ npm install -g bajaclaw
26
+ ```
27
+
28
+ That's it. The post-install runs `bajaclaw setup` automatically, which:
29
+
30
+ - Creates the default profile at `~/.bajaclaw/profiles/default/`
31
+ - Writes the matching agent descriptor at `~/.claude/agents/default/default.md`
32
+ - Registers BajaClaw as an MCP server in your desktop MCP config
33
+ - Runs the health check and tells you if anything's off
34
+
35
+ **Requirements**: Node 20+ and the `claude` CLI backend on your `PATH`.
36
+ BajaClaw drives the backend as a subprocess — whatever login/subscription
37
+ that CLI uses is what BajaClaw uses. BajaClaw itself never sees credentials.
38
+
39
+ First run, end-to-end:
40
+
41
+ ```
42
+ npm install -g bajaclaw # installs + auto-setup
43
+ bajaclaw start # runs a cycle on the default profile
44
+ ```
45
+
46
+ > Prefer to track the bleeding edge? `npm install -g github:backyarddd/BajaClaw`
47
+ > installs straight from main (runs the `prepare` script to build `dist/`).
48
+
49
+ No profile name to pick. No config to fill in. No decisions to make.
50
+
51
+ ---
52
+
53
+ ## What it actually does
54
+
55
+ A BajaClaw **cycle** is one pass of the 13-step loop in
56
+ [`src/agent.ts`](src/agent.ts):
57
+
58
+ 1. Load the profile config
59
+ 2. Open the SQLite DB and apply migrations
60
+ 3. Check the circuit breaker + rate limiter
61
+ 4. Pop a task from the queue (or generate a heartbeat prompt if empty)
62
+ 5. Full-text recall the top 10 relevant memories
63
+ 6. Load `AGENT.md`, `SOUL.md`, `HEARTBEAT.md`
64
+ 7. Score all available skills against the task; inject the top 3
65
+ 8. Merge the MCP config (desktop + profile + agent)
66
+ 9. Assemble the final system prompt
67
+ 10. Exec `claude -p` with `--model`, `--max-turns`, `--allowedTools`,
68
+ `--disallowedTools`, `--mcp-config`, `--output-format json`
69
+ 11. Parse the JSON response; persist the cycle row
70
+ 12. Post-cycle Haiku call extracts 0-5 durable memories into the FTS table
71
+ 13. Dispatch follow-ups (channel replies, queued tasks, reflection cycle)
72
+
73
+ You can run a cycle manually (`bajaclaw start`), schedule it (`bajaclaw
74
+ daemon install`), or trigger it externally (`bajaclaw trigger <event>`).
75
+ Cycles are idempotent — safe to re-run.
76
+
77
+ ---
78
+
79
+ ## Integration with the Claude ecosystem
80
+
81
+ BajaClaw is designed to slot *into* your existing Claude Code setup, not
82
+ replace it. Everything you've already configured for `claude` is inherited
83
+ for free.
84
+
85
+ ### Claude Code agent descriptors
86
+
87
+ Every BajaClaw profile writes a standard agent frontmatter file to
88
+ `~/.claude/agents/<profile>/<name>.md`. That means the moment you run
89
+ `bajaclaw setup`, a new `@default` agent appears inside Claude Code itself.
90
+ You can invoke it from a Claude Code session the same way you invoke any
91
+ other agent. The BajaClaw profile is the durable side; the Claude Code
92
+ descriptor is the handle.
93
+
94
+ ### Claude Code skills — compatible format, **isolated scope**
95
+
96
+ A BajaClaw skill is a `SKILL.md` file with YAML frontmatter — byte-for-byte
97
+ the same shape Claude Code uses. But BajaClaw reads only BajaClaw-owned
98
+ directories:
99
+
100
+ | priority | path |
101
+ |---|---|
102
+ | 1 | `<agent-dir>/skills/` |
103
+ | 2 | `~/.bajaclaw/profiles/<name>/skills/` |
104
+ | 3 | `~/.bajaclaw/skills/` |
105
+ | 4 | `<repo>/skills/` (built-ins) |
106
+
107
+ `~/.claude/skills/` is **not** read automatically — that keeps the two
108
+ agents from stepping on each other's skill libraries.
109
+
110
+ **Porting skills from Claude Code is a one-liner:**
111
+
112
+ ```
113
+ bajaclaw skill port # copy all from ~/.claude/skills
114
+ bajaclaw skill port --names my-skill # just one
115
+ bajaclaw skill port --link # symlink (live sync from Claude Code)
116
+ bajaclaw skill port --scope profile --profile default
117
+ ```
118
+
119
+ When BajaClaw matches skills for a cycle, scoring is:
120
+ - Trigger phrase hit: +5
121
+ - Name token hit: +2
122
+ - Description token hit: +1
123
+
124
+ Top 3 (where score > 0) are injected into the system prompt as `# Active
125
+ Skills`. See [`docs/skills.md`](docs/skills.md).
126
+
127
+ ### Self-knowledge (built-in guides)
128
+
129
+ BajaClaw knows how to configure itself. Ship 13 built-in skills describe
130
+ the procedure for every integration — ask your agent in plain language:
131
+
132
+ > "Help me set up Telegram."
133
+ > "Walk me through connecting Discord."
134
+ > "Switch to Opus for this profile."
135
+ > "Turn on memory sync."
136
+
137
+ The matching skill (`setup-telegram`, `setup-discord`, `configure-model`,
138
+ `setup-memory-sync`, …) fires, the agent sees the full procedure with
139
+ Quick Reference / Procedure / Pitfalls / Verification sections, and walks
140
+ you through it (running the right `bajaclaw` subcommands via Bash when
141
+ useful).
142
+
143
+ Run them directly from the CLI too:
144
+
145
+ ```
146
+ bajaclaw guide # list all guides
147
+ bajaclaw guide telegram # print the telegram setup walkthrough
148
+ bajaclaw guide mcp-port # print the MCP port walkthrough
149
+ ```
150
+
151
+ Built-in guides cover: `telegram`, `discord`, `heartbeat`, `daemon`,
152
+ `dashboard`, `mcp-port`, `memory-sync`, `profile`, `self-update`,
153
+ `uninstall`, `model`, `effort`, `tools`.
154
+
155
+ ### Auto-generated skills
156
+
157
+ After any cycle that uses 5+ tools (configurable), BajaClaw calls the
158
+ backend once more to decide whether the procedure is worth saving. If yes,
159
+ it writes a structured `SKILL.md` with When-to-use / Quick-reference /
160
+ Procedure / Pitfalls / Verification sections into
161
+ `~/.bajaclaw/skills/auto/<name>/` for review.
162
+
163
+ This is BajaClaw's take on the "create a skill after a complex task"
164
+ behavior from agents like Hermes — capture procedures the first time you
165
+ solve them so repeats are faster.
166
+
167
+ Candidates live in `auto/` until you promote them:
168
+
169
+ ```
170
+ bajaclaw skill review # print every candidate
171
+ bajaclaw skill promote <name> # move candidate into user scope
172
+ ```
173
+
174
+ Tune the trigger in the profile's `config.json`:
175
+
176
+ ```json
177
+ { "autoSkill": { "enabled": true, "minToolUses": 5, "maxPerDay": 10 } }
178
+ ```
179
+
180
+ ### MCP — isolated by default
181
+
182
+ BajaClaw uses its own MCP config. The desktop CLI's `mcpServers` is **not**
183
+ inherited by default. Merge order per cycle (highest wins):
184
+
185
+ 1. `<profile>/agent-mcp-config.json`
186
+ 2. `<profile>/mcp-config.json`
187
+ 3. `~/.bajaclaw/mcp-config.json` (user-global BajaClaw)
188
+ 4. Desktop CLI config — **only if `mergeDesktopMcp: true`** in the profile
189
+
190
+ Port servers from Claude Code on demand:
191
+
192
+ ```
193
+ bajaclaw mcp port --list # show what Claude Code has
194
+ bajaclaw mcp port # copy every server into BajaClaw
195
+ bajaclaw mcp port --names fs git # just these two
196
+ bajaclaw mcp port --force # overwrite existing BajaClaw entries
197
+ ```
198
+
199
+ Or set `"mergeDesktopMcp": true` in a profile's config to inherit the
200
+ desktop MCP list on every cycle (pre-0.4 behavior).
201
+
202
+ BajaClaw's own MCP entry (`bajaclaw`) is skipped automatically during port
203
+ to avoid self-references.
204
+
205
+ ### MCP — expose
206
+
207
+ BajaClaw is itself an MCP server. `bajaclaw setup` auto-registers it so your
208
+ desktop MCP client (Claude Desktop and anything else that reads that config)
209
+ can query BajaClaw's state directly.
210
+
211
+ **Resources:**
212
+
213
+ - `bajaclaw://profiles` — list of profiles
214
+ - `bajaclaw://profile/<n>/agents`
215
+ - `bajaclaw://profile/<n>/memories` — FTS5-searchable
216
+ - `bajaclaw://profile/<n>/cycles` — recent cycle history
217
+ - `bajaclaw://profile/<n>/schedules`
218
+
219
+ **Tools:**
220
+
221
+ - `bajaclaw_memory_search({ query, limit, profile })`
222
+ - `bajaclaw_task_create({ agent, task, priority })`
223
+ - `bajaclaw_agent_status({ agent })`
224
+ - `bajaclaw_skill_list({ profile })`
225
+
226
+ Which means: from any MCP client, you can ask "what does BajaClaw remember
227
+ about X?" or "queue a task for the default agent" — without leaving your
228
+ current session.
229
+
230
+ Run it manually with `bajaclaw mcp serve --stdio` or as HTTP SSE with
231
+ `bajaclaw mcp serve --port 8765`.
232
+
233
+ ### Claude Code memory sync
234
+
235
+ Set `memorySync: true` in the profile config and BajaClaw will:
236
+
237
+ - Ingest new/modified files in `~/.claude/memory/` into its FTS table before
238
+ each cycle
239
+ - Write a digest to `~/.claude/memory/bajaclaw-<profile>.md` after each
240
+ cycle, so Claude Code sessions can see what BajaClaw has been learning
241
+
242
+ Disabled by default — memory sharing is deliberate, not automatic. See
243
+ [`docs/memory.md`](docs/memory.md).
244
+
245
+ ### Sub-agent delegation
246
+
247
+ For heavy coding work, an agent using the `code` template plans and then
248
+ delegates to a dedicated Claude Code sub-session via `delegateCoding` in
249
+ [`src/delegation.ts`](src/delegation.ts). The orchestrator never writes code
250
+ itself — that keeps its transcript reviewable before any code exists. See
251
+ [`docs/integration.md`](docs/integration.md).
252
+
253
+ ---
254
+
255
+ ## First-run
256
+
257
+ ```
258
+ bajaclaw start # runs a cycle against the default profile
259
+ bajaclaw start --dry-run # shows the assembled prompt + exact argv
260
+ bajaclaw dashboard # http://localhost:7337 — live cycle feed, memories
261
+ bajaclaw daemon install # schedule a 15-minute heartbeat via your OS
262
+ bajaclaw daemon start # supervisor loop with exponential backoff
263
+ ```
264
+
265
+ The default profile has **full tool access** — Read, Write, Edit, Bash,
266
+ Grep, Glob, WebSearch, WebFetch, plus every MCP tool you've configured. It's
267
+ a real autonomous agent, not a sandboxed assistant.
268
+
269
+ To tighten it later, edit `~/.bajaclaw/profiles/default/config.json`:
270
+
271
+ ```json
272
+ {
273
+ "name": "default",
274
+ "template": "custom",
275
+ "model": "auto",
276
+ "effort": "medium",
277
+ "maxTurns": 10,
278
+ "allowedTools": ["Read", "Write", "Edit", "Bash"],
279
+ "disallowedTools": []
280
+ }
281
+ ```
282
+
283
+ ---
284
+
285
+ ## Multiple agents (optional)
286
+
287
+ The default profile is enough for most people. If you want more:
288
+
289
+ ```
290
+ bajaclaw init researcher --template research
291
+ bajaclaw init triage --template support
292
+ bajaclaw init coder --template code
293
+ ```
294
+
295
+ Each gets its own DB, skills, schedule, logs. Switch between them with:
296
+
297
+ ```
298
+ bajaclaw start researcher
299
+ BAJACLAW_PROFILE=triage bajaclaw daemon start
300
+ ```
301
+
302
+ **Templates:**
303
+
304
+ | template | shape |
305
+ |---|---|
306
+ | `custom` | blank slate, full tools — the default |
307
+ | `research` | research + synthesis + artifacts; full tools |
308
+ | `outreach` | email prospecting + drafting |
309
+ | `support` | inbox triage + reply drafts |
310
+ | `social` | content drafting + scheduling |
311
+ | `code` | orchestrator; delegates to a coding sub-agent (read-only itself) |
312
+
313
+ ---
314
+
315
+ ## Auto model (default)
316
+
317
+ New profiles ship with `model: auto`. Before every cycle, BajaClaw
318
+ classifies the task and routes it to the cheapest capable model:
319
+
320
+ | tier | when it fires | context budget |
321
+ |---|---|---|
322
+ | **Haiku** | triage, status checks, heartbeats, very short tasks | 3 memories, 1 skill, 4 turns |
323
+ | **Sonnet** | normal work, answers, summaries | 5 memories, 2 skills, 8 turns |
324
+ | **Opus** | planning, coding, refactoring, deep research, reflection | 7 memories, 3 skills, 14 turns |
325
+
326
+ The classifier is a heuristic — zero extra backend calls for routing.
327
+ Post-cycle memory extract + auto-skill synthesis are **skipped**
328
+ entirely for Haiku cycles. This keeps cheap tasks cheap.
329
+
330
+ Override per profile:
331
+
332
+ ```
333
+ bajaclaw model # show current + list
334
+ bajaclaw model auto # (default) route per task
335
+ bajaclaw model claude-opus-4-7 # pin to a single model
336
+ ```
337
+
338
+ ## Use BajaClaw as an OpenAI-compatible HTTP endpoint
339
+
340
+ ```
341
+ bajaclaw serve # 127.0.0.1:8765, no auth
342
+ bajaclaw serve --api-key $(openssl rand -hex 32) # with auth
343
+ bajaclaw serve --host 0.0.0.0 --api-key <key> # bind all (auth required)
344
+ ```
345
+
346
+ Anything that speaks the OpenAI chat API — Cursor, Open WebUI, LibreChat,
347
+ `openai` SDKs, curl, LangChain, LlamaIndex — can drive BajaClaw as an LLM.
348
+ The request's `model` field is a profile name; each request is one full
349
+ cycle (memory recall, skill matching, MCP inheritance, backend call,
350
+ post-cycle extract).
351
+
352
+ ```
353
+ curl http://localhost:8765/v1/chat/completions \
354
+ -H "Content-Type: application/json" \
355
+ -d '{
356
+ "model": "default",
357
+ "messages": [{"role": "user", "content": "what is on my plate today"}]
358
+ }'
359
+ ```
360
+
361
+ ```python
362
+ from openai import OpenAI
363
+ client = OpenAI(base_url="http://localhost:8765/v1", api_key="any")
364
+ r = client.chat.completions.create(
365
+ model="default",
366
+ messages=[{"role": "user", "content": "hello"}],
367
+ )
368
+ print(r.choices[0].message.content)
369
+ ```
370
+
371
+ Endpoints: `GET /health`, `GET /v1/models`, `POST /v1/chat/completions`
372
+ (non-stream + SSE), `POST /v1/bajaclaw/cycle` (native full `CycleOutput`),
373
+ `POST /v1/bajaclaw/tasks` (enqueue without waiting). Non-localhost binds
374
+ require `--api-key`. Full reference + client examples in
375
+ [`docs/api.md`](docs/api.md). Guided setup: `bajaclaw guide api`.
376
+
377
+ ---
378
+
379
+ ## Auto-update
380
+
381
+ BajaClaw checks the npm registry at most once per 24h. When a newer version
382
+ is published, a one-line notice appears after any command:
383
+
384
+ ```
385
+ ╭──────────────────────────────────────────────────────────────╮
386
+ │ update available 0.3.0 → 0.4.0 · run: bajaclaw update │
387
+ ╰──────────────────────────────────────────────────────────────╯
388
+ ```
389
+
390
+ Commands:
391
+
392
+ ```
393
+ bajaclaw update --check # print delta, don't install
394
+ bajaclaw update --yes # install immediately
395
+ ```
396
+
397
+ On a global npm install, update runs `npm install -g bajaclaw@latest`.
398
+ On a git clone, it runs `git pull && npm install && npm run build`. Silence
399
+ the notice with `BAJACLAW_NO_UPDATE_NOTICE=1`.
400
+
401
+ ---
402
+
403
+ ## Setup / Reset / Uninstall
404
+
405
+ ```
406
+ bajaclaw setup # idempotent bootstrap; safe to re-run
407
+ bajaclaw setup --profile foo # use a different default profile name
408
+ bajaclaw uninstall # dry-run — shows what would be removed
409
+ bajaclaw uninstall --yes # actually tear everything down
410
+ bajaclaw uninstall --yes --keep-data # remove integrations, keep ~/.bajaclaw/
411
+ ```
412
+
413
+ `setup` is the re-run button. If the MCP registration gets knocked out of
414
+ the desktop config, or the agent descriptor is missing, or you moved your
415
+ home directory — `bajaclaw setup` fixes it all without touching existing
416
+ data.
417
+
418
+ `uninstall` tears down everything BajaClaw has created:
419
+
420
+ - Stops any running daemons (via pid file)
421
+ - Removes OS scheduler entries (launchd plist / systemd unit / crontab line
422
+ / schtasks entry) for every profile
423
+ - Removes `~/.claude/agents/<profile>/` dirs for every profile
424
+ - Removes the `bajaclaw` MCP entry from every desktop MCP config it finds
425
+ - Removes `~/.claude/memory/bajaclaw-*.md` sync files
426
+ - Removes `~/.bajaclaw/` entirely (unless `--keep-data`)
427
+
428
+ It does **not** `npm uninstall` itself — that's one command you still run by
429
+ hand, printed at the end of the teardown.
430
+
431
+ ---
432
+
433
+ ## What's in `~/.bajaclaw/`
434
+
435
+ ```
436
+ ~/.bajaclaw/
437
+ ├── profiles/
438
+ │ └── default/
439
+ │ ├── config.json # name, template, model, tools, channels
440
+ │ ├── bajaclaw.db # SQLite + FTS5
441
+ │ ├── AGENT.md # operating guide (edited freely)
442
+ │ ├── SOUL.md # identity / voice
443
+ │ ├── HEARTBEAT.md # `<cron> | <task>` schedule entries
444
+ │ ├── skills/ # profile-scoped skills
445
+ │ ├── logs/YYYY-MM-DD.jsonl # 30-day rotation
446
+ │ ├── mcp-config.json # profile MCP additions
447
+ │ ├── .mcp-merged.json # regenerated each cycle
448
+ │ └── daemon.pid / daemon.log # when daemon is running
449
+ ├── skills/ # user-global skills
450
+ │ └── auto/ # reflection-generated candidates
451
+ └── .update-check.json # 24h update-check cache
452
+ ```
453
+
454
+ Every profile is self-contained. Delete one directory and that profile is
455
+ gone. Back one up and you can restore it anywhere.
456
+
457
+ ---
458
+
459
+ ## Memory
460
+
461
+ Every cycle queries an FTS5 virtual table over `memories.content` with the
462
+ current task's terms; the top 10 matches land in the prompt as `# Recalled
463
+ Memories`. After the cycle finishes, a 1-turn Haiku call reads the
464
+ (task, response) pair and emits up to 5 structured facts as JSON:
465
+
466
+ ```json
467
+ {"memories": [
468
+ {"kind": "decision", "content": "Use PostgreSQL 16 for the new service."},
469
+ {"kind": "fact", "content": "Alice owns the billing pipeline."}
470
+ ]}
471
+ ```
472
+
473
+ Those facts become FTS-indexed rows with `source=cycle` and
474
+ `source_cycle_id=<id>`. Next cycle, they're eligible for recall again.
475
+
476
+ Kinds are a soft taxonomy — BajaClaw doesn't enforce them: `fact`,
477
+ `decision`, `preference`, `todo`, `reference`, `claude-code`, `imported`.
478
+
479
+ Full detail: [`docs/memory.md`](docs/memory.md).
480
+
481
+ ---
482
+
483
+ ## Channels (optional)
484
+
485
+ BajaClaw ships optional adapters for **Telegram** and **Discord** bots.
486
+ They're `optionalDependencies` — not installed unless you use them.
487
+
488
+ ```
489
+ bajaclaw channel add default telegram --token <BOT_TOKEN>
490
+ bajaclaw channel add default discord --token <BOT_TOKEN> --channel-id <ID>
491
+ ```
492
+
493
+ Inbound messages (from an allowlist of sender IDs) are normalized into the
494
+ tasks queue. The next cycle picks them up. Outbound replies route back
495
+ through the same channel.
496
+
497
+ Details + allowlist config: [`docs/channels.md`](docs/channels.md).
498
+
499
+ Out of scope in v0.3: WhatsApp, Signal, iMessage, Slack, voice.
500
+
501
+ ---
502
+
503
+ ## Dashboard
504
+
505
+ ```
506
+ bajaclaw dashboard
507
+ ```
508
+
509
+ Single HTML file served at `http://localhost:7337` (port in `config.json`).
510
+ Dark theme, vanilla JS, Tailwind CDN. Live cycle feed, FTS-searchable
511
+ memory browser, schedule editor, inbox/tasks list. Reads directly from the
512
+ SQLite DB — no extra service.
513
+
514
+ ---
515
+
516
+ ## Safety + fair use
517
+
518
+ BajaClaw is a thin wrapper around the `claude` CLI. It never sees your
519
+ credentials, never calls the Anthropic API directly, and only uses
520
+ documented CLI flags. See [`docs/fair-use.md`](docs/fair-use.md) for
521
+ the full boundary story.
522
+
523
+ Built-in guards:
524
+
525
+ - **Circuit breaker**: 5 consecutive failed cycles open the breaker for 15
526
+ minutes.
527
+ - **Rate limiter**: 30 cycles/hour/profile by default.
528
+ - **Cycle serialization**: at most one `claude` subprocess per profile at
529
+ a time (see [`src/concurrency.ts`](src/concurrency.ts)). HTTP API hits
530
+ queue instead of spawning parallel processes.
531
+ - **Auto tier caps**: Haiku cycles use fewer memories/skills/turns than
532
+ Sonnet, and Sonnet less than Opus. Small tasks stay small.
533
+ - **Dry run**: `bajaclaw start --dry-run` prints the full prompt + exact
534
+ argv without executing.
535
+ - **Dry install**: `bajaclaw uninstall` without `--yes` prints the plan and
536
+ changes nothing.
537
+ - **No shell string concat**: every `execa` call uses an argv array with
538
+ `shell: false`.
539
+ - **Skill install requires confirmation**: `BAJACLAW_CONFIRM=yes` in env,
540
+ full SKILL.md printed before writing.
541
+ - **No telemetry**: the only outbound call BajaClaw makes on its own behalf
542
+ is the once-per-24h update check to the npm registry.
543
+
544
+ See [`docs/security.md`](docs/security.md) and
545
+ [`docs/fair-use.md`](docs/fair-use.md).
546
+
547
+ ---
548
+
549
+ ## Command reference
550
+
551
+ Full detail in [`docs/commands.md`](docs/commands.md). Summary:
552
+
553
+ | command | purpose |
554
+ |---|---|
555
+ | `setup` | idempotent first-run bootstrap; run anytime to repair integrations |
556
+ | `uninstall` | full teardown (or `--keep-data` to keep your profiles) |
557
+ | `init <name>` | scaffold an additional named profile |
558
+ | `start [profile]` | run one cycle (auto-bootstraps default profile if missing) |
559
+ | `dry-run [profile]` | print the assembled prompt + argv, no exec |
560
+ | `status [profile]` | per-profile stats |
561
+ | `health [profile]` | breaker + rate-limit state |
562
+ | `doctor` | toolchain + backend verification |
563
+ | `dashboard [profile]` | serve dashboard HTML |
564
+ | `daemon` | supervisor loop (start/stop/status/logs/install/run/restart) |
565
+ | `mcp` | consume + expose (list/add/remove/serve/register/port) |
566
+ | `skill` | list/new/install/review/promote/port |
567
+ | `profile` | list/create/switch/delete |
568
+ | `channel` | add/remove/list telegram + discord bridges |
569
+ | `trigger [profile] <event>` | enqueue a task |
570
+ | `migrate [profile]` | import from a foreign profile dir |
571
+ | `model [id] [profile]` | show/set the model (lists known if no id) |
572
+ | `effort [level] [profile]` | show/set effort (low/medium/high) |
573
+ | `guide [topic]` | print a built-in setup walkthrough |
574
+ | `serve` | OpenAI-compatible HTTP endpoint |
575
+ | `update` | check for / install a newer version |
576
+ | `banner` | print the ASCII banner |
577
+
578
+ **Environment variables:**
579
+
580
+ | var | effect |
581
+ |---|---|
582
+ | `BAJACLAW_PROFILE` | default profile when `[profile]` is omitted |
583
+ | `BAJACLAW_DEFAULT_PROFILE` | override the "default" profile name |
584
+ | `BAJACLAW_HOME` | override `~/.bajaclaw/` |
585
+ | `CLAUDE_HOME` | override `~/.claude/` |
586
+ | `BAJACLAW_DRY_RUN=1` | force all cycles to dry-run |
587
+ | `BAJACLAW_VERBOSE=1` | mirror log events to stdout |
588
+ | `BAJACLAW_CONFIRM=yes` | allow `skill install` to write |
589
+ | `BAJACLAW_NO_UPDATE_NOTICE=1` | silence the post-command update notice |
590
+
591
+ ---
592
+
593
+ ## Architecture
594
+
595
+ ```
596
+ OS scheduler ┌──────────────────┐
597
+ (launchd / ─────▶ │ agent cycle (13) │
598
+ systemd / │ runOnce → CLI │
599
+ cron / └─────┬────────────┘
600
+ schtasks) │
601
+
602
+ ┌───────────┐ ┌──────────────┐ ┌────────────┐
603
+ │ dashboard │ ◀──│ SQLite (WAL) │ │ claude CLI │
604
+ │ (HTML) │ │ + FTS5 │ ◀──│ subprocess │
605
+ └───────────┘ └──────────────┘ │ --mcp │
606
+ └─────┬──────┘
607
+ ┌───────────┐ │
608
+ │ desktop │ ┌─────▼──────┐
609
+ │ MCP client│ ◀─── bajaclaw:// ◀──── │ MCP servers│
610
+ └───────────┘ (resources + │ (inherited)│
611
+ tools) └────────────┘
612
+ ```
613
+
614
+ Deeper in [`docs/architecture.md`](docs/architecture.md).
615
+
616
+ ---
617
+
618
+ ## Docs
619
+
620
+ - [`architecture.md`](docs/architecture.md) — module map, cycle, on-disk layout
621
+ - [`integration.md`](docs/integration.md) — Claude Code + MCP seams in detail
622
+ - [`commands.md`](docs/commands.md) — full command reference
623
+ - [`agents.md`](docs/agents.md) — profiles, templates, AGENT.md / SOUL.md / HEARTBEAT.md
624
+ - [`skills.md`](docs/skills.md) — scoping, matching, self-generated skills
625
+ - [`memory.md`](docs/memory.md) — FTS5 recall + extract, cross-tool sync
626
+ - [`heartbeat.md`](docs/heartbeat.md) — scheduling + supervisor
627
+ - [`channels.md`](docs/channels.md)
628
+ - [`api.md`](docs/api.md) — OpenAI-compatible HTTP endpoint — Telegram + Discord
629
+ - [`security.md`](docs/security.md) — threat model + mitigations
630
+ - [`fair-use.md`](docs/fair-use.md) — how BajaClaw stays a thin wrapper
631
+ - [`troubleshooting.md`](docs/troubleshooting.md) — common fixes
632
+ - [`faq.md`](docs/faq.md) — frequently asked
633
+ - [`contributing.md`](docs/contributing.md) — dev setup, style, release
634
+
635
+ ---
636
+
637
+ ## License
638
+
639
+ MIT. No company attribution. You own what your agent makes.
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+ // Thin launcher — resolves tsx and invokes src/cli.ts, or dist/cli.js if built.
3
+ import { spawnSync } from "node:child_process";
4
+ import { existsSync } from "node:fs";
5
+ import { dirname, join } from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ const __dirname = dirname(fileURLToPath(import.meta.url));
9
+ const root = join(__dirname, "..");
10
+ const built = join(root, "dist", "cli.js");
11
+ const src = join(root, "src", "cli.ts");
12
+
13
+ const args = process.argv.slice(2);
14
+
15
+ if (existsSync(built)) {
16
+ const r = spawnSync(process.execPath, [built, ...args], { stdio: "inherit" });
17
+ process.exit(r.status ?? 1);
18
+ }
19
+
20
+ // Dev path: find tsx in common locations
21
+ const tsxCandidates = [
22
+ join(root, "node_modules", ".bin", process.platform === "win32" ? "tsx.cmd" : "tsx"),
23
+ join(root, "..", ".bin", process.platform === "win32" ? "tsx.cmd" : "tsx"),
24
+ ];
25
+
26
+ let tsx = null;
27
+ for (const c of tsxCandidates) if (existsSync(c)) { tsx = c; break; }
28
+
29
+ if (!tsx) {
30
+ console.error("bajaclaw: build missing and tsx not found. Run `npm install` then `npm run build`.");
31
+ process.exit(1);
32
+ }
33
+
34
+ const r = spawnSync(tsx, [src, ...args], { stdio: "inherit", shell: tsx.endsWith(".cmd") });
35
+ process.exit(r.status ?? 1);