mirror of
https://github.com/wassname/pi-telegram.git
synced 2026-06-27 16:16:14 +08:00
3.5 KiB
3.5 KiB
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(), includingsource: "prompt"andsource: "skill". Done means: a test with prompt commandpproduces asetMyCommandspayload containingp. 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
/startrefreshes 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
- 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 invalidbad-name/review:1, and has length 100. - likely_fail: code still filters to extension only; test shows
pmissing. - sneaky_fail: registration includes invalid names or too many commands; test checks both.
- UAT: "when I send
/start, Telegram's command menu offers/pif pi exposes it as a valid command."
- steps: move local command definitions into a reusable helper, include all valid
- 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
/startrefresh 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 innode_modules/@mariozechner/pi-coding-agent/docs/extensions.mdstate 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
/startcommand-menu refresh and prompt/skill/extension publication in README, architecture, changelog, and this spec.
TODO
- None.
Errors
| Task | Error | Resolution |
|---|