mirror of
https://github.com/wassname/pi-telegram.git
synced 2026-06-27 18:05:53 +08:00
Register pi commands in Telegram menu
This commit is contained in:
@@ -135,6 +135,7 @@ The bridge exposes Telegram-side session controls in addition to regular chat fo
|
||||
|
||||
Current operator controls include:
|
||||
|
||||
- `/start` for help and Telegram bot command-menu refresh. The menu publishes bridge-local controls first, then Telegram-valid pi commands from `pi.getCommands()`, including prompt, skill, and extension commands such as `/p` when pi exposes them.
|
||||
- `/status` for model, usage, cost, and context visibility, queued as a high-priority control item when needed
|
||||
- Inline status buttons for model and thinking adjustments, applying idle selections immediately while still respecting busy-run restart rules
|
||||
- `/model` for interactive model selection, queued as a high-priority control item when needed and supporting in-flight restart of the active Telegram-owned run on a newly selected model
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# Telegram Bot Command Menu Registration
|
||||
|
||||
## Goal
|
||||
Make Telegram's bot command menu match the commands that are useful from the DM bridge, including pi prompt and skill commands such as `/p`, not just bridge-local and extension commands.
|
||||
|
||||
## Scope
|
||||
In: bot command menu construction, command registration call, docs, changelog, focused regression tests.
|
||||
Out: changing Telegram slash-command execution semantics or making Telegram accept command names the Bot API rejects.
|
||||
|
||||
## Requirements
|
||||
- R1: The Telegram bot command menu includes bridge-local commands and every Telegram-valid command returned by `pi.getCommands()`, including `source: "prompt"` and `source: "skill"`. Done means: a test with prompt command `p` produces a `setMyCommands` payload containing `p`. VERIFY: `node --experimental-strip-types --test tests/registration.test.ts`.
|
||||
- R2: The command menu registration remains Bot API-compatible. Done means: invalid command names are filtered, duplicates are de-duped with bridge-local commands first, and the final list is capped at Telegram's 100-command limit. VERIFY: a pure builder test asserts invalid names and overflow commands are excluded.
|
||||
- R3: User-facing docs mention that `/start` refreshes the Telegram menu with bridge-local commands plus Telegram-valid pi prompt/skill/extension commands. VERIFY: docs grep shows command-menu behavior in README, architecture, and changelog.
|
||||
|
||||
## Tasks
|
||||
- [x] T1 (R1, R2): Extract/test pure Telegram bot-command menu builder.
|
||||
- steps: move local command definitions into a reusable helper, include all valid `pi.getCommands()` entries, de-dupe, cap at 100.
|
||||
- verify: `node --experimental-strip-types --test tests/registration.test.ts`.
|
||||
- success: test payload includes `p`, `skill_cmd`, excludes invalid `bad-name`/`review:1`, and has length 100.
|
||||
- likely_fail: code still filters to extension only; test shows `p` missing.
|
||||
- sneaky_fail: registration includes invalid names or too many commands; test checks both.
|
||||
- UAT: "when I send `/start`, Telegram's command menu offers `/p` if pi exposes it as a valid command."
|
||||
- [x] T2 (R3): Update docs and changelog.
|
||||
- steps: update README usage/streaming area, architecture controls, changelog current entries.
|
||||
- verify: `rg -n "bot command|/start|/p|setMyCommands|prompt" README.md docs/architecture.md CHANGELOG.md`.
|
||||
- success: docs mention `/start` refresh and prompt/skill/extension publication.
|
||||
- likely_fail: docs only mention local commands; grep misses prompt/skill command menu text.
|
||||
- sneaky_fail: docs imply invalid command names can appear; wording says Telegram-valid commands only.
|
||||
|
||||
## Context
|
||||
- Telegram Bot API command names must match lowercase/digit/underscore and max 32 characters.
|
||||
- Telegram supports at most 100 commands in the bot command menu.
|
||||
- `pi.getCommands()` returns extension, prompt, and skill commands; built-in interactive commands are not included.
|
||||
- The bridge handles local commands in Telegram before queueing a pi turn; other slash commands pass through to pi.
|
||||
|
||||
## Log
|
||||
- `pi.getCommands()` docs in `node_modules/@mariozechner/pi-coding-agent/docs/extensions.md` state it includes extension, prompt, and skill commands, but not built-in interactive commands.
|
||||
- `node --experimental-strip-types --test tests/registration.test.ts`: 8 tests passed, including the `/p`-style command and Bot API cap cases.
|
||||
- `npm test`: 142 tests passed.
|
||||
- Docs grep verified `/start` command-menu refresh and prompt/skill/extension publication in README, architecture, changelog, and this spec.
|
||||
|
||||
## TODO
|
||||
- None.
|
||||
|
||||
## Errors
|
||||
| Task | Error | Resolution |
|
||||
|------|-------|------------|
|
||||
Reference in New Issue
Block a user