@rozek/nanoclaw 1.2.17

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 (305) hide show
  1. package/.claude/settings.json +1 -0
  2. package/.claude/skills/add-compact/SKILL.md +135 -0
  3. package/.claude/skills/add-discord/SKILL.md +203 -0
  4. package/.claude/skills/add-gmail/SKILL.md +220 -0
  5. package/.claude/skills/add-image-vision/SKILL.md +94 -0
  6. package/.claude/skills/add-ollama-tool/SKILL.md +153 -0
  7. package/.claude/skills/add-parallel/SKILL.md +290 -0
  8. package/.claude/skills/add-pdf-reader/SKILL.md +104 -0
  9. package/.claude/skills/add-reactions/SKILL.md +117 -0
  10. package/.claude/skills/add-slack/SKILL.md +207 -0
  11. package/.claude/skills/add-telegram/SKILL.md +222 -0
  12. package/.claude/skills/add-telegram-swarm/SKILL.md +384 -0
  13. package/.claude/skills/add-voice-transcription/SKILL.md +148 -0
  14. package/.claude/skills/add-whatsapp/SKILL.md +372 -0
  15. package/.claude/skills/convert-to-apple-container/SKILL.md +175 -0
  16. package/.claude/skills/customize/SKILL.md +110 -0
  17. package/.claude/skills/debug/SKILL.md +349 -0
  18. package/.claude/skills/get-qodo-rules/SKILL.md +122 -0
  19. package/.claude/skills/get-qodo-rules/references/output-format.md +41 -0
  20. package/.claude/skills/get-qodo-rules/references/pagination.md +33 -0
  21. package/.claude/skills/get-qodo-rules/references/repository-scope.md +26 -0
  22. package/.claude/skills/qodo-pr-resolver/SKILL.md +326 -0
  23. package/.claude/skills/qodo-pr-resolver/resources/providers.md +329 -0
  24. package/.claude/skills/setup/SKILL.md +218 -0
  25. package/.claude/skills/update-nanoclaw/SKILL.md +235 -0
  26. package/.claude/skills/update-skills/SKILL.md +130 -0
  27. package/.claude/skills/use-local-whisper/SKILL.md +152 -0
  28. package/.claude/skills/x-integration/SKILL.md +417 -0
  29. package/.claude/skills/x-integration/agent.ts +243 -0
  30. package/.claude/skills/x-integration/host.ts +159 -0
  31. package/.claude/skills/x-integration/lib/browser.ts +148 -0
  32. package/.claude/skills/x-integration/lib/config.ts +62 -0
  33. package/.claude/skills/x-integration/scripts/like.ts +56 -0
  34. package/.claude/skills/x-integration/scripts/post.ts +66 -0
  35. package/.claude/skills/x-integration/scripts/quote.ts +80 -0
  36. package/.claude/skills/x-integration/scripts/reply.ts +74 -0
  37. package/.claude/skills/x-integration/scripts/retweet.ts +62 -0
  38. package/.claude/skills/x-integration/scripts/setup.ts +87 -0
  39. package/.env.example +1 -0
  40. package/.github/CODEOWNERS +10 -0
  41. package/.github/PULL_REQUEST_TEMPLATE.md +14 -0
  42. package/.github/workflows/bump-version.yml +32 -0
  43. package/.github/workflows/ci.yml +25 -0
  44. package/.github/workflows/merge-forward-skills.yml +160 -0
  45. package/.github/workflows/update-tokens.yml +42 -0
  46. package/.husky/pre-commit +1 -0
  47. package/.mcp.json +3 -0
  48. package/.nvmrc +1 -0
  49. package/.prettierrc +3 -0
  50. package/CHANGELOG.md +8 -0
  51. package/CLAUDE.md +64 -0
  52. package/CONTRIBUTING.md +23 -0
  53. package/CONTRIBUTORS.md +15 -0
  54. package/LICENSE +21 -0
  55. package/NanoClaw_with_Web-Support.md +290 -0
  56. package/README.md +261 -0
  57. package/README_zh.md +200 -0
  58. package/assets/nanoclaw-favicon.png +0 -0
  59. package/assets/nanoclaw-icon.png +0 -0
  60. package/assets/nanoclaw-logo-dark.png +0 -0
  61. package/assets/nanoclaw-logo.png +0 -0
  62. package/assets/nanoclaw-profile.jpeg +0 -0
  63. package/assets/nanoclaw-sales.png +0 -0
  64. package/assets/social-preview.jpg +0 -0
  65. package/config-examples/mount-allowlist.json +25 -0
  66. package/container/Dockerfile +70 -0
  67. package/container/agent-runner/package-lock.json +1524 -0
  68. package/container/agent-runner/package.json +21 -0
  69. package/container/agent-runner/src/index.ts +558 -0
  70. package/container/agent-runner/src/ipc-mcp-stdio.ts +338 -0
  71. package/container/agent-runner/tsconfig.json +15 -0
  72. package/container/build.sh +23 -0
  73. package/container/skills/agent-browser/SKILL.md +159 -0
  74. package/container/skills/capabilities/SKILL.md +100 -0
  75. package/container/skills/status/SKILL.md +104 -0
  76. package/dist/channels/index.d.ts +2 -0
  77. package/dist/channels/index.d.ts.map +1 -0
  78. package/dist/channels/index.js +9 -0
  79. package/dist/channels/index.js.map +1 -0
  80. package/dist/channels/registry.d.ts +13 -0
  81. package/dist/channels/registry.d.ts.map +1 -0
  82. package/dist/channels/registry.js +11 -0
  83. package/dist/channels/registry.js.map +1 -0
  84. package/dist/channels/registry.test.d.ts +2 -0
  85. package/dist/channels/registry.test.d.ts.map +1 -0
  86. package/dist/channels/registry.test.js +32 -0
  87. package/dist/channels/registry.test.js.map +1 -0
  88. package/dist/channels/web.d.ts +2 -0
  89. package/dist/channels/web.d.ts.map +1 -0
  90. package/dist/channels/web.js +1738 -0
  91. package/dist/channels/web.js.map +1 -0
  92. package/dist/cli.d.ts +11 -0
  93. package/dist/cli.d.ts.map +1 -0
  94. package/dist/cli.js +182 -0
  95. package/dist/cli.js.map +1 -0
  96. package/dist/config.d.ts +19 -0
  97. package/dist/config.d.ts.map +1 -0
  98. package/dist/config.js +36 -0
  99. package/dist/config.js.map +1 -0
  100. package/dist/container-runner.d.ts +44 -0
  101. package/dist/container-runner.d.ts.map +1 -0
  102. package/dist/container-runner.js +467 -0
  103. package/dist/container-runner.js.map +1 -0
  104. package/dist/container-runner.test.d.ts +2 -0
  105. package/dist/container-runner.test.d.ts.map +1 -0
  106. package/dist/container-runner.test.js +150 -0
  107. package/dist/container-runner.test.js.map +1 -0
  108. package/dist/container-runtime.d.ts +22 -0
  109. package/dist/container-runtime.d.ts.map +1 -0
  110. package/dist/container-runtime.js +96 -0
  111. package/dist/container-runtime.js.map +1 -0
  112. package/dist/container-runtime.test.d.ts +2 -0
  113. package/dist/container-runtime.test.d.ts.map +1 -0
  114. package/dist/container-runtime.test.js +93 -0
  115. package/dist/container-runtime.test.js.map +1 -0
  116. package/dist/credential-proxy.d.ts +21 -0
  117. package/dist/credential-proxy.d.ts.map +1 -0
  118. package/dist/credential-proxy.js +95 -0
  119. package/dist/credential-proxy.js.map +1 -0
  120. package/dist/credential-proxy.test.d.ts +2 -0
  121. package/dist/credential-proxy.test.d.ts.map +1 -0
  122. package/dist/credential-proxy.test.js +134 -0
  123. package/dist/credential-proxy.test.js.map +1 -0
  124. package/dist/db.d.ts +115 -0
  125. package/dist/db.d.ts.map +1 -0
  126. package/dist/db.js +549 -0
  127. package/dist/db.js.map +1 -0
  128. package/dist/db.test.d.ts +2 -0
  129. package/dist/db.test.d.ts.map +1 -0
  130. package/dist/db.test.js +360 -0
  131. package/dist/db.test.js.map +1 -0
  132. package/dist/env.d.ts +8 -0
  133. package/dist/env.d.ts.map +1 -0
  134. package/dist/env.js +42 -0
  135. package/dist/env.js.map +1 -0
  136. package/dist/formatting.test.d.ts +2 -0
  137. package/dist/formatting.test.d.ts.map +1 -0
  138. package/dist/formatting.test.js +183 -0
  139. package/dist/formatting.test.js.map +1 -0
  140. package/dist/group-folder.d.ts +5 -0
  141. package/dist/group-folder.d.ts.map +1 -0
  142. package/dist/group-folder.js +44 -0
  143. package/dist/group-folder.js.map +1 -0
  144. package/dist/group-folder.test.d.ts +2 -0
  145. package/dist/group-folder.test.d.ts.map +1 -0
  146. package/dist/group-folder.test.js +29 -0
  147. package/dist/group-folder.test.js.map +1 -0
  148. package/dist/group-queue.d.ts +34 -0
  149. package/dist/group-queue.d.ts.map +1 -0
  150. package/dist/group-queue.js +263 -0
  151. package/dist/group-queue.js.map +1 -0
  152. package/dist/group-queue.test.d.ts +2 -0
  153. package/dist/group-queue.test.d.ts.map +1 -0
  154. package/dist/group-queue.test.js +341 -0
  155. package/dist/group-queue.test.js.map +1 -0
  156. package/dist/index.d.ts +12 -0
  157. package/dist/index.d.ts.map +1 -0
  158. package/dist/index.js +518 -0
  159. package/dist/index.js.map +1 -0
  160. package/dist/ipc-auth.test.d.ts +2 -0
  161. package/dist/ipc-auth.test.d.ts.map +1 -0
  162. package/dist/ipc-auth.test.js +434 -0
  163. package/dist/ipc-auth.test.js.map +1 -0
  164. package/dist/ipc.d.ts +32 -0
  165. package/dist/ipc.d.ts.map +1 -0
  166. package/dist/ipc.js +311 -0
  167. package/dist/ipc.js.map +1 -0
  168. package/dist/logger.d.ts +3 -0
  169. package/dist/logger.d.ts.map +1 -0
  170. package/dist/logger.js +14 -0
  171. package/dist/logger.js.map +1 -0
  172. package/dist/mount-security.d.ts +34 -0
  173. package/dist/mount-security.d.ts.map +1 -0
  174. package/dist/mount-security.js +325 -0
  175. package/dist/mount-security.js.map +1 -0
  176. package/dist/remote-control.d.ts +32 -0
  177. package/dist/remote-control.d.ts.map +1 -0
  178. package/dist/remote-control.js +185 -0
  179. package/dist/remote-control.js.map +1 -0
  180. package/dist/remote-control.test.d.ts +2 -0
  181. package/dist/remote-control.test.d.ts.map +1 -0
  182. package/dist/remote-control.test.js +321 -0
  183. package/dist/remote-control.test.js.map +1 -0
  184. package/dist/router.d.ts +8 -0
  185. package/dist/router.d.ts.map +1 -0
  186. package/dist/router.js +37 -0
  187. package/dist/router.js.map +1 -0
  188. package/dist/routing.test.d.ts +2 -0
  189. package/dist/routing.test.d.ts.map +1 -0
  190. package/dist/routing.test.js +81 -0
  191. package/dist/routing.test.js.map +1 -0
  192. package/dist/sender-allowlist.d.ts +14 -0
  193. package/dist/sender-allowlist.d.ts.map +1 -0
  194. package/dist/sender-allowlist.js +79 -0
  195. package/dist/sender-allowlist.js.map +1 -0
  196. package/dist/sender-allowlist.test.d.ts +2 -0
  197. package/dist/sender-allowlist.test.d.ts.map +1 -0
  198. package/dist/sender-allowlist.test.js +186 -0
  199. package/dist/sender-allowlist.test.js.map +1 -0
  200. package/dist/session-commands.d.ts +47 -0
  201. package/dist/session-commands.d.ts.map +1 -0
  202. package/dist/session-commands.js +102 -0
  203. package/dist/session-commands.js.map +1 -0
  204. package/dist/session-commands.test.d.ts +2 -0
  205. package/dist/session-commands.test.d.ts.map +1 -0
  206. package/dist/session-commands.test.js +190 -0
  207. package/dist/session-commands.test.js.map +1 -0
  208. package/dist/task-scheduler.d.ts +22 -0
  209. package/dist/task-scheduler.d.ts.map +1 -0
  210. package/dist/task-scheduler.js +210 -0
  211. package/dist/task-scheduler.js.map +1 -0
  212. package/dist/task-scheduler.test.d.ts +2 -0
  213. package/dist/task-scheduler.test.d.ts.map +1 -0
  214. package/dist/task-scheduler.test.js +107 -0
  215. package/dist/task-scheduler.test.js.map +1 -0
  216. package/dist/timezone.d.ts +6 -0
  217. package/dist/timezone.d.ts.map +1 -0
  218. package/dist/timezone.js +17 -0
  219. package/dist/timezone.js.map +1 -0
  220. package/dist/timezone.test.d.ts +2 -0
  221. package/dist/timezone.test.d.ts.map +1 -0
  222. package/dist/timezone.test.js +23 -0
  223. package/dist/timezone.test.js.map +1 -0
  224. package/dist/types.d.ts +78 -0
  225. package/dist/types.d.ts.map +1 -0
  226. package/dist/types.js +2 -0
  227. package/dist/types.js.map +1 -0
  228. package/docs/APPLE-CONTAINER-NETWORKING.md +90 -0
  229. package/docs/DEBUG_CHECKLIST.md +143 -0
  230. package/docs/REQUIREMENTS.md +196 -0
  231. package/docs/SDK_DEEP_DIVE.md +643 -0
  232. package/docs/SECURITY.md +122 -0
  233. package/docs/SPEC.md +785 -0
  234. package/docs/docker-sandboxes.md +359 -0
  235. package/docs/nanoclaw-architecture-final.md +1063 -0
  236. package/docs/nanorepo-architecture.md +168 -0
  237. package/docs/skills-as-branches.md +662 -0
  238. package/groups/global/CLAUDE.md +58 -0
  239. package/groups/main/CLAUDE.md +246 -0
  240. package/launchd/com.nanoclaw.plist +32 -0
  241. package/package.json +45 -0
  242. package/repo-tokens/README.md +113 -0
  243. package/repo-tokens/action.yml +186 -0
  244. package/repo-tokens/badge.svg +23 -0
  245. package/repo-tokens/examples/green.svg +14 -0
  246. package/repo-tokens/examples/red.svg +14 -0
  247. package/repo-tokens/examples/yellow-green.svg +14 -0
  248. package/repo-tokens/examples/yellow.svg +14 -0
  249. package/scripts/run-migrations.ts +105 -0
  250. package/setup/container.ts +144 -0
  251. package/setup/environment.test.ts +121 -0
  252. package/setup/environment.ts +94 -0
  253. package/setup/groups.ts +229 -0
  254. package/setup/index.ts +58 -0
  255. package/setup/mounts.ts +115 -0
  256. package/setup/platform.test.ts +120 -0
  257. package/setup/platform.ts +132 -0
  258. package/setup/register.test.ts +257 -0
  259. package/setup/register.ts +177 -0
  260. package/setup/service.test.ts +187 -0
  261. package/setup/service.ts +362 -0
  262. package/setup/status.ts +16 -0
  263. package/setup/verify.ts +192 -0
  264. package/setup.sh +161 -0
  265. package/src/channels/index.ts +12 -0
  266. package/src/channels/registry.test.ts +42 -0
  267. package/src/channels/registry.ts +32 -0
  268. package/src/channels/web.ts +1856 -0
  269. package/src/cli.ts +209 -0
  270. package/src/config.ts +73 -0
  271. package/src/container-runner.test.ts +210 -0
  272. package/src/container-runner.ts +707 -0
  273. package/src/container-runtime.test.ts +149 -0
  274. package/src/container-runtime.ts +127 -0
  275. package/src/credential-proxy.test.ts +192 -0
  276. package/src/credential-proxy.ts +125 -0
  277. package/src/db.test.ts +484 -0
  278. package/src/db.ts +803 -0
  279. package/src/env.ts +42 -0
  280. package/src/formatting.test.ts +256 -0
  281. package/src/group-folder.test.ts +43 -0
  282. package/src/group-folder.ts +44 -0
  283. package/src/group-queue.test.ts +484 -0
  284. package/src/group-queue.ts +365 -0
  285. package/src/index.ts +731 -0
  286. package/src/ipc-auth.test.ts +679 -0
  287. package/src/ipc.ts +461 -0
  288. package/src/logger.ts +16 -0
  289. package/src/mount-security.ts +419 -0
  290. package/src/remote-control.test.ts +397 -0
  291. package/src/remote-control.ts +224 -0
  292. package/src/router.ts +52 -0
  293. package/src/routing.test.ts +170 -0
  294. package/src/sender-allowlist.test.ts +216 -0
  295. package/src/sender-allowlist.ts +128 -0
  296. package/src/session-commands.test.ts +247 -0
  297. package/src/session-commands.ts +163 -0
  298. package/src/task-scheduler.test.ts +129 -0
  299. package/src/task-scheduler.ts +295 -0
  300. package/src/timezone.test.ts +29 -0
  301. package/src/timezone.ts +16 -0
  302. package/src/types.ts +107 -0
  303. package/tsconfig.json +20 -0
  304. package/vitest.config.ts +7 -0
  305. package/vitest.skills.config.ts +7 -0
@@ -0,0 +1,218 @@
1
+ ---
2
+ name: setup
3
+ description: Run initial NanoClaw setup. Use when user wants to install dependencies, authenticate messaging channels, register their main channel, or start the background services. Triggers on "setup", "install", "configure nanoclaw", or first-time setup requests.
4
+ ---
5
+
6
+ # NanoClaw Setup
7
+
8
+ Run setup steps automatically. Only pause when user action is required (channel authentication, configuration choices). Setup uses `bash setup.sh` for bootstrap, then `npx tsx setup/index.ts --step <name>` for all other steps. Steps emit structured status blocks to stdout. Verbose logs go to `logs/setup.log`.
9
+
10
+ **Principle:** When something is broken or missing, fix it. Don't tell the user to go fix it themselves unless it genuinely requires their manual action (e.g. authenticating a channel, pasting a secret token). If a dependency is missing, install it. If a service won't start, diagnose and repair. Ask the user for permission when needed, then do the work.
11
+
12
+ **UX Note:** Use `AskUserQuestion` for all user-facing questions.
13
+
14
+ ## 0. Git & Fork Setup
15
+
16
+ Check the git remote configuration to ensure the user has a fork and upstream is configured.
17
+
18
+ Run:
19
+ - `git remote -v`
20
+
21
+ **Case A — `origin` points to `qwibitai/nanoclaw` (user cloned directly):**
22
+
23
+ The user cloned instead of forking. AskUserQuestion: "You cloned NanoClaw directly. We recommend forking so you can push your customizations. Would you like to set up a fork?"
24
+ - Fork now (recommended) — walk them through it
25
+ - Continue without fork — they'll only have local changes
26
+
27
+ If fork: instruct the user to fork `qwibitai/nanoclaw` on GitHub (they need to do this in their browser), then ask them for their GitHub username. Run:
28
+ ```bash
29
+ git remote rename origin upstream
30
+ git remote add origin https://github.com/<their-username>/nanoclaw.git
31
+ git push --force origin main
32
+ ```
33
+ Verify with `git remote -v`.
34
+
35
+ If continue without fork: add upstream so they can still pull updates:
36
+ ```bash
37
+ git remote add upstream https://github.com/qwibitai/nanoclaw.git
38
+ ```
39
+
40
+ **Case B — `origin` points to user's fork, no `upstream` remote:**
41
+
42
+ Add upstream:
43
+ ```bash
44
+ git remote add upstream https://github.com/qwibitai/nanoclaw.git
45
+ ```
46
+
47
+ **Case C — both `origin` (user's fork) and `upstream` (qwibitai) exist:**
48
+
49
+ Already configured. Continue.
50
+
51
+ **Verify:** `git remote -v` should show `origin` → user's repo, `upstream` → `qwibitai/nanoclaw.git`.
52
+
53
+ ## 1. Bootstrap (Node.js + Dependencies)
54
+
55
+ Run `bash setup.sh` and parse the status block.
56
+
57
+ - If NODE_OK=false → Node.js is missing or too old. Use `AskUserQuestion: Would you like me to install Node.js 22?` If confirmed:
58
+ - macOS: `brew install node@22` (if brew available) or install nvm then `nvm install 22`
59
+ - Linux: `curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - && sudo apt-get install -y nodejs`, or nvm
60
+ - After installing Node, re-run `bash setup.sh`
61
+ - If DEPS_OK=false → Read `logs/setup.log`. Try: delete `node_modules`, re-run `bash setup.sh`. If native module build fails, install build tools (`xcode-select --install` on macOS, `build-essential` on Linux), then retry.
62
+ - If NATIVE_OK=false → better-sqlite3 failed to load. Install build tools and re-run.
63
+ - Record PLATFORM and IS_WSL for later steps.
64
+
65
+ ## 2. Check Environment
66
+
67
+ Run `npx tsx setup/index.ts --step environment` and parse the status block.
68
+
69
+ - If HAS_AUTH=true → WhatsApp is already configured, note for step 5
70
+ - If HAS_REGISTERED_GROUPS=true → note existing config, offer to skip or reconfigure
71
+ - Record APPLE_CONTAINER and DOCKER values for step 3
72
+
73
+ ## 3. Container Runtime
74
+
75
+ ### 3a. Choose runtime
76
+
77
+ Check the preflight results for `APPLE_CONTAINER` and `DOCKER`, and the PLATFORM from step 1.
78
+
79
+ - PLATFORM=linux → Docker (only option)
80
+ - PLATFORM=macos + APPLE_CONTAINER=installed → Use `AskUserQuestion: Docker (cross-platform) or Apple Container (native macOS)?` If Apple Container, run `/convert-to-apple-container` now, then skip to 3c.
81
+ - PLATFORM=macos + APPLE_CONTAINER=not_found → Docker
82
+
83
+ ### 3a-docker. Install Docker
84
+
85
+ - DOCKER=running → continue to 4b
86
+ - DOCKER=installed_not_running → start Docker: `open -a Docker` (macOS) or `sudo systemctl start docker` (Linux). Wait 15s, re-check with `docker info`.
87
+ - DOCKER=not_found → Use `AskUserQuestion: Docker is required for running agents. Would you like me to install it?` If confirmed:
88
+ - macOS: install via `brew install --cask docker`, then `open -a Docker` and wait for it to start. If brew not available, direct to Docker Desktop download at https://docker.com/products/docker-desktop
89
+ - Linux: install with `curl -fsSL https://get.docker.com | sh && sudo usermod -aG docker $USER`. Note: user may need to log out/in for group membership.
90
+
91
+ ### 3b. Apple Container conversion gate (if needed)
92
+
93
+ **If the chosen runtime is Apple Container**, you MUST check whether the source code has already been converted from Docker to Apple Container. Do NOT skip this step. Run:
94
+
95
+ ```bash
96
+ grep -q "CONTAINER_RUNTIME_BIN = 'container'" src/container-runtime.ts && echo "ALREADY_CONVERTED" || echo "NEEDS_CONVERSION"
97
+ ```
98
+
99
+ **If NEEDS_CONVERSION**, the source code still uses Docker as the runtime. You MUST run the `/convert-to-apple-container` skill NOW, before proceeding to the build step.
100
+
101
+ **If ALREADY_CONVERTED**, the code already uses Apple Container. Continue to 3c.
102
+
103
+ **If the chosen runtime is Docker**, no conversion is needed. Continue to 3c.
104
+
105
+ ### 3c. Build and test
106
+
107
+ Run `npx tsx setup/index.ts --step container -- --runtime <chosen>` and parse the status block.
108
+
109
+ **If BUILD_OK=false:** Read `logs/setup.log` tail for the build error.
110
+ - Cache issue (stale layers): `docker builder prune -f` (Docker) or `container builder stop && container builder rm && container builder start` (Apple Container). Retry.
111
+ - Dockerfile syntax or missing files: diagnose from the log and fix, then retry.
112
+
113
+ **If TEST_OK=false but BUILD_OK=true:** The image built but won't run. Check logs — common cause is runtime not fully started. Wait a moment and retry the test.
114
+
115
+ ## 4. Claude Authentication (No Script)
116
+
117
+ If HAS_ENV=true from step 2, read `.env` and check for `CLAUDE_CODE_OAUTH_TOKEN` or `ANTHROPIC_API_KEY`. If present, confirm with user: keep or reconfigure?
118
+
119
+ AskUserQuestion: Claude subscription (Pro/Max) vs Anthropic API key?
120
+
121
+ **Subscription:** Tell user to run `claude setup-token` in another terminal, copy the token, add `CLAUDE_CODE_OAUTH_TOKEN=<token>` to `.env`. Do NOT collect the token in chat.
122
+
123
+ **API key:** Tell user to add `ANTHROPIC_API_KEY=<key>` to `.env`.
124
+
125
+ ## 5. Set Up Channels
126
+
127
+ AskUserQuestion (multiSelect): Which messaging channels do you want to enable?
128
+ - WhatsApp (authenticates via QR code or pairing code)
129
+ - Telegram (authenticates via bot token from @BotFather)
130
+ - Slack (authenticates via Slack app with Socket Mode)
131
+ - Discord (authenticates via Discord bot token)
132
+
133
+ **Delegate to each selected channel's own skill.** Each channel skill handles its own code installation, authentication, registration, and JID resolution. This avoids duplicating channel-specific logic and ensures JIDs are always correct.
134
+
135
+ For each selected channel, invoke its skill:
136
+
137
+ - **WhatsApp:** Invoke `/add-whatsapp`
138
+ - **Telegram:** Invoke `/add-telegram`
139
+ - **Slack:** Invoke `/add-slack`
140
+ - **Discord:** Invoke `/add-discord`
141
+
142
+ Each skill will:
143
+ 1. Install the channel code (via `git merge` of the skill branch)
144
+ 2. Collect credentials/tokens and write to `.env`
145
+ 3. Authenticate (WhatsApp QR/pairing, or verify token-based connection)
146
+ 4. Register the chat with the correct JID format
147
+ 5. Build and verify
148
+
149
+ **After all channel skills complete**, install dependencies and rebuild — channel merges may introduce new packages:
150
+
151
+ ```bash
152
+ npm install && npm run build
153
+ ```
154
+
155
+ If the build fails, read the error output and fix it (usually a missing dependency). Then continue to step 6.
156
+
157
+ ## 6. Mount Allowlist
158
+
159
+ AskUserQuestion: Agent access to external directories?
160
+
161
+ **No:** `npx tsx setup/index.ts --step mounts -- --empty`
162
+ **Yes:** Collect paths/permissions. `npx tsx setup/index.ts --step mounts -- --json '{"allowedRoots":[...],"blockedPatterns":[],"nonMainReadOnly":true}'`
163
+
164
+ ## 7. Start Service
165
+
166
+ If service already running: unload first.
167
+ - macOS: `launchctl unload ~/Library/LaunchAgents/com.nanoclaw.plist`
168
+ - Linux: `systemctl --user stop nanoclaw` (or `systemctl stop nanoclaw` if root)
169
+
170
+ Run `npx tsx setup/index.ts --step service` and parse the status block.
171
+
172
+ **If FALLBACK=wsl_no_systemd:** WSL without systemd detected. Tell user they can either enable systemd in WSL (`echo -e "[boot]\nsystemd=true" | sudo tee /etc/wsl.conf` then restart WSL) or use the generated `start-nanoclaw.sh` wrapper.
173
+
174
+ **If DOCKER_GROUP_STALE=true:** The user was added to the docker group after their session started — the systemd service can't reach the Docker socket. Ask user to run these two commands:
175
+
176
+ 1. Immediate fix: `sudo setfacl -m u:$(whoami):rw /var/run/docker.sock`
177
+ 2. Persistent fix (re-applies after every Docker restart):
178
+ ```bash
179
+ sudo mkdir -p /etc/systemd/system/docker.service.d
180
+ sudo tee /etc/systemd/system/docker.service.d/socket-acl.conf << 'EOF'
181
+ [Service]
182
+ ExecStartPost=/usr/bin/setfacl -m u:USERNAME:rw /var/run/docker.sock
183
+ EOF
184
+ sudo systemctl daemon-reload
185
+ ```
186
+ Replace `USERNAME` with the actual username (from `whoami`). Run the two `sudo` commands separately — the `tee` heredoc first, then `daemon-reload`. After user confirms setfacl ran, re-run the service step.
187
+
188
+ **If SERVICE_LOADED=false:**
189
+ - Read `logs/setup.log` for the error.
190
+ - macOS: check `launchctl list | grep nanoclaw`. If PID=`-` and status non-zero, read `logs/nanoclaw.error.log`.
191
+ - Linux: check `systemctl --user status nanoclaw`.
192
+ - Re-run the service step after fixing.
193
+
194
+ ## 8. Verify
195
+
196
+ Run `npx tsx setup/index.ts --step verify` and parse the status block.
197
+
198
+ **If STATUS=failed, fix each:**
199
+ - SERVICE=stopped → `npm run build`, then restart: `launchctl kickstart -k gui/$(id -u)/com.nanoclaw` (macOS) or `systemctl --user restart nanoclaw` (Linux) or `bash start-nanoclaw.sh` (WSL nohup)
200
+ - SERVICE=not_found → re-run step 7
201
+ - CREDENTIALS=missing → re-run step 4
202
+ - CHANNEL_AUTH shows `not_found` for any channel → re-invoke that channel's skill (e.g. `/add-telegram`)
203
+ - REGISTERED_GROUPS=0 → re-invoke the channel skills from step 5
204
+ - MOUNT_ALLOWLIST=missing → `npx tsx setup/index.ts --step mounts -- --empty`
205
+
206
+ Tell user to test: send a message in their registered chat. Show: `tail -f logs/nanoclaw.log`
207
+
208
+ ## Troubleshooting
209
+
210
+ **Service not starting:** Check `logs/nanoclaw.error.log`. Common: wrong Node path (re-run step 7), missing `.env` (step 4), missing channel credentials (re-invoke channel skill).
211
+
212
+ **Container agent fails ("Claude Code process exited with code 1"):** Ensure the container runtime is running — `open -a Docker` (macOS Docker), `container system start` (Apple Container), or `sudo systemctl start docker` (Linux). Check container logs in `groups/main/logs/container-*.log`.
213
+
214
+ **No response to messages:** Check trigger pattern. Main channel doesn't need prefix. Check DB: `npx tsx setup/index.ts --step verify`. Check `logs/nanoclaw.log`.
215
+
216
+ **Channel not connecting:** Verify the channel's credentials are set in `.env`. Channels auto-enable when their credentials are present. For WhatsApp: check `store/auth/creds.json` exists. For token-based channels: check token values in `.env`. Restart the service after any `.env` change.
217
+
218
+ **Unload service:** macOS: `launchctl unload ~/Library/LaunchAgents/com.nanoclaw.plist` | Linux: `systemctl --user stop nanoclaw`
@@ -0,0 +1,235 @@
1
+ ---
2
+ name: update-nanoclaw
3
+ description: Efficiently bring upstream NanoClaw updates into a customized install, with preview, selective cherry-pick, and low token usage.
4
+ ---
5
+
6
+ # About
7
+
8
+ Your NanoClaw fork drifts from upstream as you customize it. This skill pulls upstream changes into your install without losing your modifications.
9
+
10
+ Run `/update-nanoclaw` in Claude Code.
11
+
12
+ ## How it works
13
+
14
+ **Preflight**: checks for clean working tree (`git status --porcelain`). If `upstream` remote is missing, asks you for the URL (defaults to `https://github.com/qwibitai/nanoclaw.git`) and adds it. Detects the upstream branch name (`main` or `master`).
15
+
16
+ **Backup**: creates a timestamped backup branch and tag (`backup/pre-update-<hash>-<timestamp>`, `pre-update-<hash>-<timestamp>`) before touching anything. Safe to run multiple times.
17
+
18
+ **Preview**: runs `git log` and `git diff` against the merge base to show upstream changes since your last sync. Groups changed files into categories:
19
+ - **Skills** (`.claude/skills/`): unlikely to conflict unless you edited an upstream skill
20
+ - **Source** (`src/`): may conflict if you modified the same files
21
+ - **Build/config** (`package.json`, `tsconfig*.json`, `container/`): review needed
22
+
23
+ **Update paths** (you pick one):
24
+ - `merge` (default): `git merge upstream/<branch>`. Resolves all conflicts in one pass.
25
+ - `cherry-pick`: `git cherry-pick <hashes>`. Pull in only the commits you want.
26
+ - `rebase`: `git rebase upstream/<branch>`. Linear history, but conflicts resolve per-commit.
27
+ - `abort`: just view the changelog, change nothing.
28
+
29
+ **Conflict preview**: before merging, runs a dry-run (`git merge --no-commit --no-ff`) to show which files would conflict. You can still abort at this point.
30
+
31
+ **Conflict resolution**: opens only conflicted files, resolves the conflict markers, keeps your local customizations intact.
32
+
33
+ **Validation**: runs `npm run build` and `npm test`.
34
+
35
+ **Breaking changes check**: after validation, reads CHANGELOG.md for any `[BREAKING]` entries introduced by the update. If found, shows each breaking change and offers to run the recommended skill to migrate.
36
+
37
+ ## Rollback
38
+
39
+ The backup tag is printed at the end of each run:
40
+ ```
41
+ git reset --hard pre-update-<hash>-<timestamp>
42
+ ```
43
+
44
+ Backup branch `backup/pre-update-<hash>-<timestamp>` also exists.
45
+
46
+ ## Token usage
47
+
48
+ Only opens files with actual conflicts. Uses `git log`, `git diff`, and `git status` for everything else. Does not scan or refactor unrelated code.
49
+
50
+ ---
51
+
52
+ # Goal
53
+ Help a user with a customized NanoClaw install safely incorporate upstream changes without a fresh reinstall and without blowing tokens.
54
+
55
+ # Operating principles
56
+ - Never proceed with a dirty working tree.
57
+ - Always create a rollback point (backup branch + tag) before touching anything.
58
+ - Prefer git-native operations (fetch, merge, cherry-pick). Do not manually rewrite files except conflict markers.
59
+ - Default to MERGE (one-pass conflict resolution). Offer REBASE as an explicit option.
60
+ - Keep token usage low: rely on `git status`, `git log`, `git diff`, and open only conflicted files.
61
+
62
+ # Step 0: Preflight (stop early if unsafe)
63
+ Run:
64
+ - `git status --porcelain`
65
+ If output is non-empty:
66
+ - Tell the user to commit or stash first, then stop.
67
+
68
+ Confirm remotes:
69
+ - `git remote -v`
70
+ If `upstream` is missing:
71
+ - Ask the user for the upstream repo URL (default: `https://github.com/qwibitai/nanoclaw.git`).
72
+ - Add it: `git remote add upstream <user-provided-url>`
73
+ - Then: `git fetch upstream --prune`
74
+
75
+ Determine the upstream branch name:
76
+ - `git branch -r | grep upstream/`
77
+ - If `upstream/main` exists, use `main`.
78
+ - If only `upstream/master` exists, use `master`.
79
+ - Otherwise, ask the user which branch to use.
80
+ - Store this as UPSTREAM_BRANCH for all subsequent commands. Every command below that references `upstream/main` should use `upstream/$UPSTREAM_BRANCH` instead.
81
+
82
+ Fetch:
83
+ - `git fetch upstream --prune`
84
+
85
+ # Step 1: Create a safety net
86
+ Capture current state:
87
+ - `HASH=$(git rev-parse --short HEAD)`
88
+ - `TIMESTAMP=$(date +%Y%m%d-%H%M%S)`
89
+
90
+ Create backup branch and tag (using timestamp to avoid collisions on retry):
91
+ - `git branch backup/pre-update-$HASH-$TIMESTAMP`
92
+ - `git tag pre-update-$HASH-$TIMESTAMP`
93
+
94
+ Save the tag name for later reference in the summary and rollback instructions.
95
+
96
+ # Step 2: Preview what upstream changed (no edits yet)
97
+ Compute common base:
98
+ - `BASE=$(git merge-base HEAD upstream/$UPSTREAM_BRANCH)`
99
+
100
+ Show upstream commits since BASE:
101
+ - `git log --oneline $BASE..upstream/$UPSTREAM_BRANCH`
102
+
103
+ Show local commits since BASE (custom drift):
104
+ - `git log --oneline $BASE..HEAD`
105
+
106
+ Show file-level impact from upstream:
107
+ - `git diff --name-only $BASE..upstream/$UPSTREAM_BRANCH`
108
+
109
+ Bucket the upstream changed files:
110
+ - **Skills** (`.claude/skills/`): unlikely to conflict unless the user edited an upstream skill
111
+ - **Source** (`src/`): may conflict if user modified the same files
112
+ - **Build/config** (`package.json`, `package-lock.json`, `tsconfig*.json`, `container/`, `launchd/`): review needed
113
+ - **Other**: docs, tests, misc
114
+
115
+ Present these buckets to the user and ask them to choose one path using AskUserQuestion:
116
+ - A) **Full update**: merge all upstream changes
117
+ - B) **Selective update**: cherry-pick specific upstream commits
118
+ - C) **Abort**: they only wanted the preview
119
+ - D) **Rebase mode**: advanced, linear history (warn: resolves conflicts per-commit)
120
+
121
+ If Abort: stop here.
122
+
123
+ # Step 3: Conflict preview (before committing anything)
124
+ If Full update or Rebase:
125
+ - Dry-run merge to preview conflicts. Run these as a single chained command so the abort always executes:
126
+ ```
127
+ git merge --no-commit --no-ff upstream/$UPSTREAM_BRANCH; git diff --name-only --diff-filter=U; git merge --abort
128
+ ```
129
+ - If conflicts were listed: show them and ask user if they want to proceed.
130
+ - If no conflicts: tell user it is clean and proceed.
131
+
132
+ # Step 4A: Full update (MERGE, default)
133
+ Run:
134
+ - `git merge upstream/$UPSTREAM_BRANCH --no-edit`
135
+
136
+ If conflicts occur:
137
+ - Run `git status` and identify conflicted files.
138
+ - For each conflicted file:
139
+ - Open the file.
140
+ - Resolve only conflict markers.
141
+ - Preserve intentional local customizations.
142
+ - Incorporate upstream fixes/improvements.
143
+ - Do not refactor surrounding code.
144
+ - `git add <file>`
145
+ - When all resolved:
146
+ - If merge did not auto-commit: `git commit --no-edit`
147
+
148
+ # Step 4B: Selective update (CHERRY-PICK)
149
+ If user chose Selective:
150
+ - Recompute BASE if needed: `BASE=$(git merge-base HEAD upstream/$UPSTREAM_BRANCH)`
151
+ - Show commit list again: `git log --oneline $BASE..upstream/$UPSTREAM_BRANCH`
152
+ - Ask user which commit hashes they want.
153
+ - Apply: `git cherry-pick <hash1> <hash2> ...`
154
+
155
+ If conflicts during cherry-pick:
156
+ - Resolve only conflict markers, then:
157
+ - `git add <file>`
158
+ - `git cherry-pick --continue`
159
+ If user wants to stop:
160
+ - `git cherry-pick --abort`
161
+
162
+ # Step 4C: Rebase (only if user explicitly chose option D)
163
+ Run:
164
+ - `git rebase upstream/$UPSTREAM_BRANCH`
165
+
166
+ If conflicts:
167
+ - Resolve conflict markers only, then:
168
+ - `git add <file>`
169
+ - `git rebase --continue`
170
+ If it gets messy (more than 3 rounds of conflicts):
171
+ - `git rebase --abort`
172
+ - Recommend merge instead.
173
+
174
+ # Step 5: Validation
175
+ Run:
176
+ - `npm run build`
177
+ - `npm test` (do not fail the flow if tests are not configured)
178
+
179
+ If build fails:
180
+ - Show the error.
181
+ - Only fix issues clearly caused by the merge (missing imports, type mismatches from merged code).
182
+ - Do not refactor unrelated code.
183
+ - If unclear, ask the user before making changes.
184
+
185
+ # Step 6: Breaking changes check
186
+ After validation succeeds, check if the update introduced any breaking changes.
187
+
188
+ Determine which CHANGELOG entries are new by diffing against the backup tag:
189
+ - `git diff <backup-tag-from-step-1>..HEAD -- CHANGELOG.md`
190
+
191
+ Parse the diff output for lines starting with `+[BREAKING]`. Each such line is one breaking change entry. The format is:
192
+ ```
193
+ [BREAKING] <description>. Run `/<skill-name>` to <action>.
194
+ ```
195
+
196
+ If no `[BREAKING]` lines are found:
197
+ - Skip this step silently. Proceed to Step 7 (skill updates check).
198
+
199
+ If one or more `[BREAKING]` lines are found:
200
+ - Display a warning header to the user: "This update includes breaking changes that may require action:"
201
+ - For each breaking change, display the full description.
202
+ - Collect all skill names referenced in the breaking change entries (the `/<skill-name>` part).
203
+ - Use AskUserQuestion to ask the user which migration skills they want to run now. Options:
204
+ - One option per referenced skill (e.g., "Run /add-whatsapp to re-add WhatsApp channel")
205
+ - "Skip — I'll handle these manually"
206
+ - Set `multiSelect: true` so the user can pick multiple skills if there are several breaking changes.
207
+ - For each skill the user selects, invoke it using the Skill tool.
208
+ - After all selected skills complete (or if user chose Skip), proceed to Step 7 (skill updates check).
209
+
210
+ # Step 7: Check for skill updates
211
+ After the summary, check if skills are distributed as branches in this repo:
212
+ - `git branch -r --list 'upstream/skill/*'`
213
+
214
+ If any `upstream/skill/*` branches exist:
215
+ - Use AskUserQuestion to ask: "Upstream has skill branches. Would you like to check for skill updates?"
216
+ - Option 1: "Yes, check for updates" (description: "Runs /update-skills to check for and apply skill branch updates")
217
+ - Option 2: "No, skip" (description: "You can run /update-skills later any time")
218
+ - If user selects yes, invoke `/update-skills` using the Skill tool.
219
+ - After the skill completes (or if user selected no), proceed to Step 8.
220
+
221
+ # Step 8: Summary + rollback instructions
222
+ Show:
223
+ - Backup tag: the tag name created in Step 1
224
+ - New HEAD: `git rev-parse --short HEAD`
225
+ - Upstream HEAD: `git rev-parse --short upstream/$UPSTREAM_BRANCH`
226
+ - Conflicts resolved (list files, if any)
227
+ - Breaking changes applied (list skills run, if any)
228
+ - Remaining local diff vs upstream: `git diff --name-only upstream/$UPSTREAM_BRANCH..HEAD`
229
+
230
+ Tell the user:
231
+ - To rollback: `git reset --hard <backup-tag-from-step-1>`
232
+ - Backup branch also exists: `backup/pre-update-<HASH>-<TIMESTAMP>`
233
+ - Restart the service to apply changes:
234
+ - If using launchd: `launchctl unload ~/Library/LaunchAgents/com.nanoclaw.plist && launchctl load ~/Library/LaunchAgents/com.nanoclaw.plist`
235
+ - If running manually: restart `npm run dev`
@@ -0,0 +1,130 @@
1
+ ---
2
+ name: update-skills
3
+ description: Check for and apply updates to installed skill branches from upstream.
4
+ ---
5
+
6
+ # About
7
+
8
+ Skills are distributed as git branches (`skill/*`). When you install a skill, you merge its branch into your repo. This skill checks upstream for newer commits on those skill branches and helps you update.
9
+
10
+ Run `/update-skills` in Claude Code.
11
+
12
+ ## How it works
13
+
14
+ **Preflight**: checks for clean working tree and upstream remote.
15
+
16
+ **Detection**: fetches upstream, lists all `upstream/skill/*` branches, determines which ones you've previously merged (via merge-base), and checks if any have new commits.
17
+
18
+ **Selection**: presents a list of skills with available updates. You pick which to update.
19
+
20
+ **Update**: merges each selected skill branch, resolves conflicts if any, then validates with build + test.
21
+
22
+ ---
23
+
24
+ # Goal
25
+ Help users update their installed skill branches from upstream without losing local customizations.
26
+
27
+ # Operating principles
28
+ - Never proceed with a dirty working tree.
29
+ - Only offer updates for skills the user has already merged (installed).
30
+ - Use git-native operations. Do not manually rewrite files except conflict markers.
31
+ - Keep token usage low: rely on `git` commands, only open files with actual conflicts.
32
+
33
+ # Step 0: Preflight
34
+
35
+ Run:
36
+ - `git status --porcelain`
37
+
38
+ If output is non-empty:
39
+ - Tell the user to commit or stash first, then stop.
40
+
41
+ Check remotes:
42
+ - `git remote -v`
43
+
44
+ If `upstream` is missing:
45
+ - Ask the user for the upstream repo URL (default: `https://github.com/qwibitai/nanoclaw.git`).
46
+ - `git remote add upstream <url>`
47
+
48
+ Fetch:
49
+ - `git fetch upstream --prune`
50
+
51
+ # Step 1: Detect installed skills with available updates
52
+
53
+ List all upstream skill branches:
54
+ - `git branch -r --list 'upstream/skill/*'`
55
+
56
+ For each `upstream/skill/<name>`:
57
+ 1. Check if the user has merged this skill branch before:
58
+ - `git merge-base --is-ancestor upstream/skill/<name>~1 HEAD` — if this succeeds (exit 0) for any ancestor commit of the skill branch, the user has merged it at some point. A simpler check: `git log --oneline --merges --grep="skill/<name>" HEAD` to see if there's a merge commit referencing this branch.
59
+ - Alternative: `MERGE_BASE=$(git merge-base HEAD upstream/skill/<name>)` — if the merge base is NOT the initial commit and the merge base includes commits unique to the skill branch, it has been merged.
60
+ - Simplest reliable check: compare `git merge-base HEAD upstream/skill/<name>` with `git merge-base HEAD upstream/main`. If the skill merge-base is strictly ahead of (or different from) the main merge-base, the user has merged this skill.
61
+ 2. Check if there are new commits on the skill branch not yet in HEAD:
62
+ - `git log --oneline HEAD..upstream/skill/<name>`
63
+ - If this produces output, there are updates available.
64
+
65
+ Build three lists:
66
+ - **Updates available**: skills that are merged AND have new commits
67
+ - **Up to date**: skills that are merged and have no new commits
68
+ - **Not installed**: skills that have never been merged
69
+
70
+ # Step 2: Present results
71
+
72
+ If no skills have updates available:
73
+ - Tell the user all installed skills are up to date. List them.
74
+ - If there are uninstalled skills, mention them briefly (e.g., "3 other skills available in upstream that you haven't installed").
75
+ - Stop here.
76
+
77
+ If updates are available:
78
+ - Show the list of skills with updates, including the number of new commits for each:
79
+ ```
80
+ skill/<name>: 3 new commits
81
+ skill/<other>: 1 new commit
82
+ ```
83
+ - Also show skills that are up to date (for context).
84
+ - Use AskUserQuestion with `multiSelect: true` to let the user pick which skills to update.
85
+ - One option per skill with updates, labeled with the skill name and commit count.
86
+ - Add an option: "Skip — don't update any skills now"
87
+ - If user selects Skip, stop here.
88
+
89
+ # Step 3: Apply updates
90
+
91
+ For each selected skill (process one at a time):
92
+
93
+ 1. Tell the user which skill is being updated.
94
+ 2. Run: `git merge upstream/skill/<name> --no-edit`
95
+ 3. If the merge is clean, move to the next skill.
96
+ 4. If conflicts occur:
97
+ - Run `git status` to identify conflicted files.
98
+ - For each conflicted file:
99
+ - Open the file.
100
+ - Resolve only conflict markers.
101
+ - Preserve intentional local customizations.
102
+ - `git add <file>`
103
+ - Complete the merge: `git commit --no-edit`
104
+
105
+ If a merge fails badly (e.g., cannot resolve conflicts):
106
+ - `git merge --abort`
107
+ - Tell the user this skill could not be auto-updated and they should resolve it manually.
108
+ - Continue with the remaining skills.
109
+
110
+ # Step 4: Validation
111
+
112
+ After all selected skills are merged:
113
+ - `npm run build`
114
+ - `npm test` (do not fail the flow if tests are not configured)
115
+
116
+ If build fails:
117
+ - Show the error.
118
+ - Only fix issues clearly caused by the merge (missing imports, type mismatches).
119
+ - Do not refactor unrelated code.
120
+ - If unclear, ask the user.
121
+
122
+ # Step 5: Summary
123
+
124
+ Show:
125
+ - Skills updated (list)
126
+ - Skills skipped or failed (if any)
127
+ - New HEAD: `git rev-parse --short HEAD`
128
+ - Any conflicts that were resolved (list files)
129
+
130
+ If the service is running, remind the user to restart it to pick up changes.