|
1 | | -# CodeClaw |
| 1 | +# ClawCode |
2 | 2 |
|
3 | | -Telegram interface for [OpenCode](https://opencode.ai), implemented as an OpenCode plugin. |
| 3 | +OpenCode plugin for exchange logging and workspace configuration (skills, agents, commands, tools). |
4 | 4 |
|
5 | 5 | ## Prerequisites |
6 | 6 |
|
7 | 7 | - [OpenCode](https://opencode.ai) installed |
8 | 8 | - [Bun](https://bun.sh) |
9 | | -- Telegram bot token from [@BotFather](https://t.me/BotFather) |
10 | | -- Your Telegram user ID from [@userinfobot](https://t.me/userinfobot) |
| 9 | +- [qmd](https://github.com/qmd-project/qmd) |
11 | 10 |
|
12 | 11 | ## Setup |
13 | 12 |
|
14 | 13 | ```bash |
15 | 14 | bun install |
16 | 15 | ``` |
17 | 16 |
|
18 | | -Create `~/.config/opencode/clawcode.json`: |
| 17 | +Optionally create `~/.config/opencode/clawcode.json` to override the exchanges directory: |
19 | 18 |
|
20 | 19 | ```json |
21 | 20 | { |
22 | | - "token": "your-bot-token", |
23 | | - "allowedUsers": [123456789] |
| 21 | + "exchangesDir": "/custom/path/to/exchanges" |
24 | 22 | } |
25 | 23 | ``` |
26 | 24 |
|
27 | | -## Install |
28 | | - |
29 | | -Symlink the plugin into your OpenCode workspace: |
| 25 | +Default: `$XDG_DATA_HOME/opencode/exchanges` (falls back to `~/.local/share/opencode/exchanges`). |
30 | 26 |
|
31 | | -```bash |
32 | | -mkdir -p /path/to/workspace/.opencode/plugins |
33 | | -ln -s /path/to/clawcode/src/main.ts /path/to/workspace/.opencode/plugins/clawcode.ts |
34 | | -``` |
35 | | - |
36 | | -Or use the Makefile to install the systemd service, plugin, and `.opencode/` assets: |
| 27 | +## Install |
37 | 28 |
|
38 | 29 | ```bash |
39 | | -make install |
| 30 | +./install.sh install |
40 | 31 | systemctl --user enable --now opencode-server.service |
41 | 32 | ``` |
42 | 33 |
|
43 | | -The Telegram bot is **on-demand** by default. Use `/telegram connect` in the OpenCode TUI to start it. The systemd unit sets `TELEGRAM_AUTOCONNECT=1` to auto-start. |
| 34 | +This copies skills, agents, tools, and commands to `$OPENCODE_WORKSPACE/.opencode/`, symlinks the plugin, and installs the systemd service. |
44 | 35 |
|
45 | 36 | To remove: |
46 | 37 |
|
47 | 38 | ```bash |
48 | | -make uninstall |
| 39 | +./install.sh uninstall |
49 | 40 | ``` |
50 | 41 |
|
51 | | -## Bot Commands |
52 | | - |
53 | | -| Command | Description | |
54 | | -|---|---| |
55 | | -| `/new` | New session | |
56 | | -| `/sessions` | List and switch sessions | |
57 | | -| `/abort` | Abort current session | |
58 | | -| `/history` | Recent messages from current session | |
59 | | -| `/agent <name>` | Switch agent (omit name to list available) | |
60 | | -| `/remember <text>` | Save a memory to MEMORY.md via OpenCode | |
61 | | -| `/start_llama` | Start llama systemd service | |
62 | | -| `/stop_llama` | Stop llama systemd service | |
| 42 | +## Exchange Logging |
63 | 43 |
|
64 | | -Send any text message to prompt OpenCode. Responses stream in real-time. |
65 | | -Permission requests appear as inline keyboards. |
| 44 | +Every completed session exchange is automatically saved as qmd-compatible markdown to the exchanges directory. The plugin listens for `session.idle` events and captures the last user/assistant message pair. |
66 | 45 |
|
67 | | -## Memory System |
| 46 | +The install script sets up a qmd collection for semantic search. New exchanges are automatically indexed after each save. |
68 | 47 |
|
69 | | -Every exchange is automatically saved to `exchanges/` as qmd-compatible markdown. |
70 | | - |
71 | | -- `/remember <text>` — tells OpenCode to append a memory to `MEMORY.md` in the workspace (always read on startup) |
72 | | -- The `recall` skill lets the model search past exchanges via qmd on demand |
73 | | - |
74 | | -### qmd Setup |
75 | | - |
76 | | -After first run, create a qmd collection for the exchanges: |
77 | | - |
78 | | -```bash |
79 | | -qmd collection add /path/to/exchanges --name exchanges --mask "**/*.md" |
80 | | -qmd embed |
81 | | -``` |
| 48 | +## Telegram Bridge |
82 | 49 |
|
83 | | -New exchanges are automatically indexed via `qmd update && qmd embed` after each save (if `qmd` is installed). |
| 50 | +For Telegram integration, see [opencode-telegram](https://github.com/TheEdgeOfRage/opencode-telegram). |
0 commit comments