@wechatbot/pi-agent
Pi extension — type /wechat, scan QR code, chat with Pi from WeChat
Package details
Install @wechatbot/pi-agent from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@wechatbot/pi-agent- Package
@wechatbot/pi-agent- Version
0.1.3- Published
- Apr 7, 2026
- Downloads
- 247/mo · 18/wk
- Author
- agmod
- License
- MIT
- Types
- extension
- Size
- 16.6 KB
- Dependencies
- 2 dependencies · 1 peer
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
@wechatbot/pi-agent
Pi extension — type /wechat in pi, scan QR code in terminal, chat with Pi from WeChat.
Install
From npm (recommended)
pi install npm:@wechatbot/pi-agent
Done. The extension auto-loads on next pi session. Type /wechat to start.
From git
pi install https://github.com/jiweiyuan/wechatbot
Quick test (no install)
pi -e npm:@wechatbot/pi-agent
Manual (local development)
git clone https://github.com/jiweiyuan/wechatbot
cd wechatbot/pi-agent && npm install
# Load directly
pi -e ./src/index.ts
# Or copy to auto-discovery directory
cp -r . ~/.pi/agent/extensions/wechat/
Usage
/wechat Scan QR code → connect WeChat to this pi session
/weixin Alias for /wechat
/wechat --force Force re-login (new QR code)
/wechat-disconnect Disconnect
/wechat-send <text> Send text to WeChat user manually
What happens
> /wechat
📱 Scan this QR code in WeChat:
▄▄▄▄▄▄▄ ▄▄▄ ▄▄▄▄▄▄▄
█ ▄▄▄ █ █▀█ █ ▄▄▄ █
█ ███ █ ▄▀▄ █ ███ █
█▄▄▄▄▄█ █ ▄ █▄▄▄▄▄█
▄▄▄▄▄ ▄▄▄█▄▄▄ ▄▄▄▄▄
█▄█▀█▄▄ ▀▀▄▀▀█▄▀█▀▄
▄▄▄▄▄▄▄ ▀▄ █▀▄█▄█▀▄
█▄▄▄▄▄█ █▀▄█▀▀█▀███
[wechat] ✓ Connected: e06c1ceea05e@im.bot
# Now send "帮我看看这个bug" from WeChat...
# Pi processes it, sends reply back to WeChat.
# "对方正在输入中..." shown while Pi thinks.
How It Works
WeChat User (phone)
│
▼
iLink API (Tencent) ←── @wechatbot/wechatbot SDK
│
▼
Pi Extension
│
├── WeChat msg → pi.sendUserMessage(text) → pi processes as prompt
│
└── pi.on('agent_end') → bot.reply(text) → sent back to WeChat
/wechatcreates aWeChatBotinstance (SDK)- SDK calls iLink API → gets QR URL
qrcode-terminalrenders QR code in pi TUI viactx.ui.setWidget()- User scans QR in WeChat → login confirmed → credentials saved
- SDK starts long-poll → incoming WeChat messages trigger
pi.sendUserMessage() - When pi finishes (
agent_endevent), response is sent back viabot.reply() bot.sendTyping()shows "对方正在输入中..." while pi thinks
QR Code Display
The QR code is rendered using qrcode-terminal — a real scannable QR code in the terminal.
The SDK does NOT render QR codes — that is the developer's responsibility.
This extension is the developer. It receives the URL via onQrUrl callback and renders it.
Dependencies
| Package | Purpose |
|---|---|
@wechatbot/wechatbot |
WeChat iLink Bot SDK — login, poll, send, typing, context_token |
qrcode-terminal |
Render scannable QR code in terminal |
@mariozechner/pi-coding-agent |
Pi extension API (peer dependency) |
Pi Package
This is a pi package. It declares "keywords": ["pi-package"] and "pi": { "extensions": [...] } in package.json. Pi auto-discovers the extension after install.