Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ TELEGRAM_ALLOWED_USER_ID=
# environment where IPv6 DNS exists but outbound IPv6 connectivity is broken.
# TELEGRAM_FORCE_IPV4=false

# OpenCode API URL (optional, default: http://localhost:4096)
# OpenCode server API version: v1 or v2 (optional, default: v1)
# Must match the OpenCode server you run; the bot does not detect it.
# The setup wizard writes it: v2 on a first setup, the saved value on a re-run.
# OPENCODE_SERVER_VERSION=v1

# OpenCode API URL (optional, default: http://localhost:4096 for v1, http://127.0.0.1:49374 for v2)
# OPENCODE_API_URL=http://localhost:4096

# Set automatically by docker compose. Enables Telegram warnings for commands
Expand All @@ -42,7 +47,8 @@ TELEGRAM_ALLOWED_USER_ID=
# OpenCode health monitor interval in seconds when auto-restart is enabled (default: 300)
# OPENCODE_MONITOR_INTERVAL_SEC=300

# OpenCode Server Authentication (optional)
# OpenCode Server Authentication (password optional on V1, required on V2:
# run `opencode service get password`)
# OPENCODE_SERVER_USERNAME=opencode
# OPENCODE_SERVER_PASSWORD=

Expand Down Expand Up @@ -127,7 +133,8 @@ OPENCODE_MODEL_ID=big-pickle
# showThinkingContent (bool), showAssistantRunFooter (bool),
# pinnedDashboardEnabled (bool),
# responseStreamingMode ("edit"|"draft"), sendDiffFileAttachments (bool),
# promptQueueEnabled (bool)
# promptQueueEnabled (bool; seeds the OpenCode V1 message queue only —
# on V2 the queue starts in Steer)
# The preset is validated at startup: invalid JSON, a non-object value, unknown
# keys, or wrong value types abort startup with a clear error (fail fast).
# Example — hide the run footer and enable compact mode by default:
Expand Down
14 changes: 12 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,10 @@ For multi-step tasks, state a brief plan:

- **Commits:** Never create commits automatically. Commit only when the user explicitly asks.

### Windows / PowerShell
### Working on Windows

If your shell runs on Windows:

- Keep in mind the runtime environment is Windows.
- Avoid fragile one-liners that can break in PowerShell.
- Use absolute paths when working with file tools (`read`, `write`, `edit`).

Expand All @@ -163,6 +164,13 @@ For multi-step tasks, state a brief plan:
- Send understandable error messages to users.
- Never expose stack traces to users.

### Cross-platform

- The bot runs on Linux, macOS, and Windows; CI runs tests on Linux.
- Code must work on all three regardless of the OS you develop on: passing checks locally does not prove it works elsewhere.
- Code that touches paths, processes, shells, or the filesystem must work on all three: no hardcoded `\` or `/` separators, no assumptions about line endings or path case.
- Windows-only logic runs behind a `process.platform` check. A test for it either passes on every OS or is skipped outside Windows.

### Bot commands

The command list is centralized in `src/bot/commands/definitions.ts`.
Expand Down Expand Up @@ -240,6 +248,8 @@ Important:

## OpenCode SDK quick reference

The example below is the V1 client. OpenCode V2 goes through `@opencode/client`, wrapped in `src/opencode/v2/`.

```typescript
import { createOpencodeClient } from "@opencode-ai/sdk";

Expand Down
12 changes: 9 additions & 3 deletions PRODUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ No public inbound ports are required for normal usage.

### OpenCode server management

- Works with OpenCode V1 and OpenCode V2 servers; the API version is set in configuration (`OPENCODE_SERVER_VERSION`, default V1) and a server of the other version is reported in the log
- Check OpenCode server status (running / not running)
- Start OpenCode server from the app (`opencode serve`)
- Start OpenCode server from the app: `opencode serve` on V1, the registered background server (`opencode serve --service`) on V2; no start while the configured address answers with the wrong password or as the other version, while the local `opencode` executable is the other version, or on V2 while a registered V2 server runs on another port — the reason goes to the log
- Stop OpenCode server from the app
- Optionally monitor and auto-restart a local OpenCode server
- Optionally monitor and auto-restart a local OpenCode server, with the same start rules

### Project management

Expand All @@ -54,8 +55,9 @@ No public inbound ports are required for normal usage.
- Send text prompts to OpenCode
- Accept voice/audio messages, transcribe via Whisper-compatible STT API, and forward recognized text as prompts
- Interrupt current task (ESC equivalent)
- Optionally queue text, transcribed voice, photos, rich formatted messages with photos, supported documents, and media groups sent while a task is running; hold at most `MAX_QUEUED_PROMPTS` (5) items and 20 MiB of raw Telegram media bytes, checked from reliable `file_size` before downloads
- Optionally accept text, transcribed voice, photos, rich formatted messages with photos, supported documents, and media groups sent while a task is running, at most `MAX_QUEUED_PROMPTS` (5) waiting at a time: on OpenCode V2 they wait in the session inbox and are steered into the running turn (Steer, the V2 default) or start their own run after it (Queue); on V1 the bot holds them, with at most 20 MiB of raw Telegram media bytes checked from reliable `file_size` before downloads; the V1 On/Off choice and the V2 mode are kept separately, so switching versions changes neither
- Handle OpenCode questions with inline options and custom text answers
- In a multi-select question the custom text becomes one more tickable row next to the options, and Done sends it together with the ticked options
- Send selected/custom answers back to OpenCode (`question.reply`)
- Handle permission requests interactively (`allow once` / `always` / `reject`)

Expand Down Expand Up @@ -96,6 +98,7 @@ No public inbound ports are required for normal usage.
- Telegram bot token
- Allowed Telegram user ID
- Default model provider and model ID
- OpenCode server API version (`OPENCODE_SERVER_VERSION`: `v1` or `v2`) with a version-dependent default URL; the installed-mode setup wizard asks for it (V2 on a first setup, the saved choice on a re-run) and requires the server password for V2
- Selected project persisted in `settings.json`
- Configurable sessions list size (default: 10)
- Configurable commands list size (default: 10)
Expand Down Expand Up @@ -169,6 +172,8 @@ Agent picker behavior:

- [x] Single-user access control by allowed Telegram user ID
- [x] OpenCode server control from Telegram (`/status`, `/opencode_start`, `/opencode_stop`)
- [x] OpenCode V1 and V2 servers, selected by `OPENCODE_SERVER_VERSION`; pending questions and permissions come back after the event stream reconnects
- [x] OpenCode V2 set up and started out of the box: the setup wizard asks for the version and the V2 password, and `/opencode_start`, `/opencode_stop` and auto-restart manage the V2 background server
- [x] Project and session management from Telegram (`/projects`, `/worktree`, `/sessions`, `/new`)
- [x] Cross-project recent sessions with status and direct attachment (`/recent`)
- [x] Automatic tracking of the current OpenCode CLI session, including continuing it from Telegram, live updates, and external text input notifications
Expand Down Expand Up @@ -202,6 +207,7 @@ Agent picker behavior:
- [x] Attaching a project file from `/ls` to the next prompt as a native OpenCode file part
- [x] `/messages` command: browse session messages with revert and fork functionality
- [x] Optional message queue for text, voice, photos, rich formatted messages with photos, documents, and media groups sent while the agent is busy, managed from the bottom keyboard
- [x] OpenCode V2: messages sent mid-run are steered into the running turn or queued in the session inbox (Off / Queue / Steer in `/settings`), withdrawable until picked up
- [x] Native Telegram rich message formatting for assistant replies (Bot API 10.1)
- [x] Incoming Telegram rich formatted messages (Bot API 10.1): converted to Markdown, accepted anywhere text is accepted, with photos attached and unsupported message types answered explicitly
- [x] Startup either reaches Telegram polling or the process exits: transient Telegram failures are retried in-process; a bad token or other fatal startup error exits with code 1
Expand Down
Loading
Loading