@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.
- package/.claude/settings.json +1 -0
- package/.claude/skills/add-compact/SKILL.md +135 -0
- package/.claude/skills/add-discord/SKILL.md +203 -0
- package/.claude/skills/add-gmail/SKILL.md +220 -0
- package/.claude/skills/add-image-vision/SKILL.md +94 -0
- package/.claude/skills/add-ollama-tool/SKILL.md +153 -0
- package/.claude/skills/add-parallel/SKILL.md +290 -0
- package/.claude/skills/add-pdf-reader/SKILL.md +104 -0
- package/.claude/skills/add-reactions/SKILL.md +117 -0
- package/.claude/skills/add-slack/SKILL.md +207 -0
- package/.claude/skills/add-telegram/SKILL.md +222 -0
- package/.claude/skills/add-telegram-swarm/SKILL.md +384 -0
- package/.claude/skills/add-voice-transcription/SKILL.md +148 -0
- package/.claude/skills/add-whatsapp/SKILL.md +372 -0
- package/.claude/skills/convert-to-apple-container/SKILL.md +175 -0
- package/.claude/skills/customize/SKILL.md +110 -0
- package/.claude/skills/debug/SKILL.md +349 -0
- package/.claude/skills/get-qodo-rules/SKILL.md +122 -0
- package/.claude/skills/get-qodo-rules/references/output-format.md +41 -0
- package/.claude/skills/get-qodo-rules/references/pagination.md +33 -0
- package/.claude/skills/get-qodo-rules/references/repository-scope.md +26 -0
- package/.claude/skills/qodo-pr-resolver/SKILL.md +326 -0
- package/.claude/skills/qodo-pr-resolver/resources/providers.md +329 -0
- package/.claude/skills/setup/SKILL.md +218 -0
- package/.claude/skills/update-nanoclaw/SKILL.md +235 -0
- package/.claude/skills/update-skills/SKILL.md +130 -0
- package/.claude/skills/use-local-whisper/SKILL.md +152 -0
- package/.claude/skills/x-integration/SKILL.md +417 -0
- package/.claude/skills/x-integration/agent.ts +243 -0
- package/.claude/skills/x-integration/host.ts +159 -0
- package/.claude/skills/x-integration/lib/browser.ts +148 -0
- package/.claude/skills/x-integration/lib/config.ts +62 -0
- package/.claude/skills/x-integration/scripts/like.ts +56 -0
- package/.claude/skills/x-integration/scripts/post.ts +66 -0
- package/.claude/skills/x-integration/scripts/quote.ts +80 -0
- package/.claude/skills/x-integration/scripts/reply.ts +74 -0
- package/.claude/skills/x-integration/scripts/retweet.ts +62 -0
- package/.claude/skills/x-integration/scripts/setup.ts +87 -0
- package/.env.example +1 -0
- package/.github/CODEOWNERS +10 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +14 -0
- package/.github/workflows/bump-version.yml +32 -0
- package/.github/workflows/ci.yml +25 -0
- package/.github/workflows/merge-forward-skills.yml +160 -0
- package/.github/workflows/update-tokens.yml +42 -0
- package/.husky/pre-commit +1 -0
- package/.mcp.json +3 -0
- package/.nvmrc +1 -0
- package/.prettierrc +3 -0
- package/CHANGELOG.md +8 -0
- package/CLAUDE.md +64 -0
- package/CONTRIBUTING.md +23 -0
- package/CONTRIBUTORS.md +15 -0
- package/LICENSE +21 -0
- package/NanoClaw_with_Web-Support.md +290 -0
- package/README.md +261 -0
- package/README_zh.md +200 -0
- package/assets/nanoclaw-favicon.png +0 -0
- package/assets/nanoclaw-icon.png +0 -0
- package/assets/nanoclaw-logo-dark.png +0 -0
- package/assets/nanoclaw-logo.png +0 -0
- package/assets/nanoclaw-profile.jpeg +0 -0
- package/assets/nanoclaw-sales.png +0 -0
- package/assets/social-preview.jpg +0 -0
- package/config-examples/mount-allowlist.json +25 -0
- package/container/Dockerfile +70 -0
- package/container/agent-runner/package-lock.json +1524 -0
- package/container/agent-runner/package.json +21 -0
- package/container/agent-runner/src/index.ts +558 -0
- package/container/agent-runner/src/ipc-mcp-stdio.ts +338 -0
- package/container/agent-runner/tsconfig.json +15 -0
- package/container/build.sh +23 -0
- package/container/skills/agent-browser/SKILL.md +159 -0
- package/container/skills/capabilities/SKILL.md +100 -0
- package/container/skills/status/SKILL.md +104 -0
- package/dist/channels/index.d.ts +2 -0
- package/dist/channels/index.d.ts.map +1 -0
- package/dist/channels/index.js +9 -0
- package/dist/channels/index.js.map +1 -0
- package/dist/channels/registry.d.ts +13 -0
- package/dist/channels/registry.d.ts.map +1 -0
- package/dist/channels/registry.js +11 -0
- package/dist/channels/registry.js.map +1 -0
- package/dist/channels/registry.test.d.ts +2 -0
- package/dist/channels/registry.test.d.ts.map +1 -0
- package/dist/channels/registry.test.js +32 -0
- package/dist/channels/registry.test.js.map +1 -0
- package/dist/channels/web.d.ts +2 -0
- package/dist/channels/web.d.ts.map +1 -0
- package/dist/channels/web.js +1738 -0
- package/dist/channels/web.js.map +1 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +182 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +36 -0
- package/dist/config.js.map +1 -0
- package/dist/container-runner.d.ts +44 -0
- package/dist/container-runner.d.ts.map +1 -0
- package/dist/container-runner.js +467 -0
- package/dist/container-runner.js.map +1 -0
- package/dist/container-runner.test.d.ts +2 -0
- package/dist/container-runner.test.d.ts.map +1 -0
- package/dist/container-runner.test.js +150 -0
- package/dist/container-runner.test.js.map +1 -0
- package/dist/container-runtime.d.ts +22 -0
- package/dist/container-runtime.d.ts.map +1 -0
- package/dist/container-runtime.js +96 -0
- package/dist/container-runtime.js.map +1 -0
- package/dist/container-runtime.test.d.ts +2 -0
- package/dist/container-runtime.test.d.ts.map +1 -0
- package/dist/container-runtime.test.js +93 -0
- package/dist/container-runtime.test.js.map +1 -0
- package/dist/credential-proxy.d.ts +21 -0
- package/dist/credential-proxy.d.ts.map +1 -0
- package/dist/credential-proxy.js +95 -0
- package/dist/credential-proxy.js.map +1 -0
- package/dist/credential-proxy.test.d.ts +2 -0
- package/dist/credential-proxy.test.d.ts.map +1 -0
- package/dist/credential-proxy.test.js +134 -0
- package/dist/credential-proxy.test.js.map +1 -0
- package/dist/db.d.ts +115 -0
- package/dist/db.d.ts.map +1 -0
- package/dist/db.js +549 -0
- package/dist/db.js.map +1 -0
- package/dist/db.test.d.ts +2 -0
- package/dist/db.test.d.ts.map +1 -0
- package/dist/db.test.js +360 -0
- package/dist/db.test.js.map +1 -0
- package/dist/env.d.ts +8 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +42 -0
- package/dist/env.js.map +1 -0
- package/dist/formatting.test.d.ts +2 -0
- package/dist/formatting.test.d.ts.map +1 -0
- package/dist/formatting.test.js +183 -0
- package/dist/formatting.test.js.map +1 -0
- package/dist/group-folder.d.ts +5 -0
- package/dist/group-folder.d.ts.map +1 -0
- package/dist/group-folder.js +44 -0
- package/dist/group-folder.js.map +1 -0
- package/dist/group-folder.test.d.ts +2 -0
- package/dist/group-folder.test.d.ts.map +1 -0
- package/dist/group-folder.test.js +29 -0
- package/dist/group-folder.test.js.map +1 -0
- package/dist/group-queue.d.ts +34 -0
- package/dist/group-queue.d.ts.map +1 -0
- package/dist/group-queue.js +263 -0
- package/dist/group-queue.js.map +1 -0
- package/dist/group-queue.test.d.ts +2 -0
- package/dist/group-queue.test.d.ts.map +1 -0
- package/dist/group-queue.test.js +341 -0
- package/dist/group-queue.test.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +518 -0
- package/dist/index.js.map +1 -0
- package/dist/ipc-auth.test.d.ts +2 -0
- package/dist/ipc-auth.test.d.ts.map +1 -0
- package/dist/ipc-auth.test.js +434 -0
- package/dist/ipc-auth.test.js.map +1 -0
- package/dist/ipc.d.ts +32 -0
- package/dist/ipc.d.ts.map +1 -0
- package/dist/ipc.js +311 -0
- package/dist/ipc.js.map +1 -0
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +14 -0
- package/dist/logger.js.map +1 -0
- package/dist/mount-security.d.ts +34 -0
- package/dist/mount-security.d.ts.map +1 -0
- package/dist/mount-security.js +325 -0
- package/dist/mount-security.js.map +1 -0
- package/dist/remote-control.d.ts +32 -0
- package/dist/remote-control.d.ts.map +1 -0
- package/dist/remote-control.js +185 -0
- package/dist/remote-control.js.map +1 -0
- package/dist/remote-control.test.d.ts +2 -0
- package/dist/remote-control.test.d.ts.map +1 -0
- package/dist/remote-control.test.js +321 -0
- package/dist/remote-control.test.js.map +1 -0
- package/dist/router.d.ts +8 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +37 -0
- package/dist/router.js.map +1 -0
- package/dist/routing.test.d.ts +2 -0
- package/dist/routing.test.d.ts.map +1 -0
- package/dist/routing.test.js +81 -0
- package/dist/routing.test.js.map +1 -0
- package/dist/sender-allowlist.d.ts +14 -0
- package/dist/sender-allowlist.d.ts.map +1 -0
- package/dist/sender-allowlist.js +79 -0
- package/dist/sender-allowlist.js.map +1 -0
- package/dist/sender-allowlist.test.d.ts +2 -0
- package/dist/sender-allowlist.test.d.ts.map +1 -0
- package/dist/sender-allowlist.test.js +186 -0
- package/dist/sender-allowlist.test.js.map +1 -0
- package/dist/session-commands.d.ts +47 -0
- package/dist/session-commands.d.ts.map +1 -0
- package/dist/session-commands.js +102 -0
- package/dist/session-commands.js.map +1 -0
- package/dist/session-commands.test.d.ts +2 -0
- package/dist/session-commands.test.d.ts.map +1 -0
- package/dist/session-commands.test.js +190 -0
- package/dist/session-commands.test.js.map +1 -0
- package/dist/task-scheduler.d.ts +22 -0
- package/dist/task-scheduler.d.ts.map +1 -0
- package/dist/task-scheduler.js +210 -0
- package/dist/task-scheduler.js.map +1 -0
- package/dist/task-scheduler.test.d.ts +2 -0
- package/dist/task-scheduler.test.d.ts.map +1 -0
- package/dist/task-scheduler.test.js +107 -0
- package/dist/task-scheduler.test.js.map +1 -0
- package/dist/timezone.d.ts +6 -0
- package/dist/timezone.d.ts.map +1 -0
- package/dist/timezone.js +17 -0
- package/dist/timezone.js.map +1 -0
- package/dist/timezone.test.d.ts +2 -0
- package/dist/timezone.test.d.ts.map +1 -0
- package/dist/timezone.test.js +23 -0
- package/dist/timezone.test.js.map +1 -0
- package/dist/types.d.ts +78 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/docs/APPLE-CONTAINER-NETWORKING.md +90 -0
- package/docs/DEBUG_CHECKLIST.md +143 -0
- package/docs/REQUIREMENTS.md +196 -0
- package/docs/SDK_DEEP_DIVE.md +643 -0
- package/docs/SECURITY.md +122 -0
- package/docs/SPEC.md +785 -0
- package/docs/docker-sandboxes.md +359 -0
- package/docs/nanoclaw-architecture-final.md +1063 -0
- package/docs/nanorepo-architecture.md +168 -0
- package/docs/skills-as-branches.md +662 -0
- package/groups/global/CLAUDE.md +58 -0
- package/groups/main/CLAUDE.md +246 -0
- package/launchd/com.nanoclaw.plist +32 -0
- package/package.json +45 -0
- package/repo-tokens/README.md +113 -0
- package/repo-tokens/action.yml +186 -0
- package/repo-tokens/badge.svg +23 -0
- package/repo-tokens/examples/green.svg +14 -0
- package/repo-tokens/examples/red.svg +14 -0
- package/repo-tokens/examples/yellow-green.svg +14 -0
- package/repo-tokens/examples/yellow.svg +14 -0
- package/scripts/run-migrations.ts +105 -0
- package/setup/container.ts +144 -0
- package/setup/environment.test.ts +121 -0
- package/setup/environment.ts +94 -0
- package/setup/groups.ts +229 -0
- package/setup/index.ts +58 -0
- package/setup/mounts.ts +115 -0
- package/setup/platform.test.ts +120 -0
- package/setup/platform.ts +132 -0
- package/setup/register.test.ts +257 -0
- package/setup/register.ts +177 -0
- package/setup/service.test.ts +187 -0
- package/setup/service.ts +362 -0
- package/setup/status.ts +16 -0
- package/setup/verify.ts +192 -0
- package/setup.sh +161 -0
- package/src/channels/index.ts +12 -0
- package/src/channels/registry.test.ts +42 -0
- package/src/channels/registry.ts +32 -0
- package/src/channels/web.ts +1856 -0
- package/src/cli.ts +209 -0
- package/src/config.ts +73 -0
- package/src/container-runner.test.ts +210 -0
- package/src/container-runner.ts +707 -0
- package/src/container-runtime.test.ts +149 -0
- package/src/container-runtime.ts +127 -0
- package/src/credential-proxy.test.ts +192 -0
- package/src/credential-proxy.ts +125 -0
- package/src/db.test.ts +484 -0
- package/src/db.ts +803 -0
- package/src/env.ts +42 -0
- package/src/formatting.test.ts +256 -0
- package/src/group-folder.test.ts +43 -0
- package/src/group-folder.ts +44 -0
- package/src/group-queue.test.ts +484 -0
- package/src/group-queue.ts +365 -0
- package/src/index.ts +731 -0
- package/src/ipc-auth.test.ts +679 -0
- package/src/ipc.ts +461 -0
- package/src/logger.ts +16 -0
- package/src/mount-security.ts +419 -0
- package/src/remote-control.test.ts +397 -0
- package/src/remote-control.ts +224 -0
- package/src/router.ts +52 -0
- package/src/routing.test.ts +170 -0
- package/src/sender-allowlist.test.ts +216 -0
- package/src/sender-allowlist.ts +128 -0
- package/src/session-commands.test.ts +247 -0
- package/src/session-commands.ts +163 -0
- package/src/task-scheduler.test.ts +129 -0
- package/src/task-scheduler.ts +295 -0
- package/src/timezone.test.ts +29 -0
- package/src/timezone.ts +16 -0
- package/src/types.ts +107 -0
- package/tsconfig.json +20 -0
- package/vitest.config.ts +7 -0
- 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.
|