@wechatbot/pi-agent
v0.1.2
Published
Pi extension — type /wechat, scan QR code, chat with Pi from WeChat
Downloads
246
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-agentDone. The extension auto-loads on next pi session. Type /wechat to start.
From git
pi install https://github.com/jiweiyuan/wechatbotQuick test (no install)
pi -e npm:@wechatbot/pi-agentManual (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 manuallyWhat happens
> /wechat
📱 Scan this QR code in WeChat:
▄▄▄▄▄▄▄ ▄▄▄ ▄▄▄▄▄▄▄
█ ▄▄▄ █ █▀█ █ ▄▄▄ █
█ ███ █ ▄▀▄ █ ███ █
█▄▄▄▄▄█ █ ▄ █▄▄▄▄▄█
▄▄▄▄▄ ▄▄▄█▄▄▄ ▄▄▄▄▄
█▄█▀█▄▄ ▀▀▄▀▀█▄▀█▀▄
▄▄▄▄▄▄▄ ▀▄ █▀▄█▄█▀▄
█▄▄▄▄▄█ █▀▄█▀▀█▀███
[wechat] ✓ Connected: [email protected]
# 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.
