You are managing the Claude-to-IM bridge.
User data is stored at ~/.claude-to-im/.
The skill directory (SKILL_DIR) is at ~/.claude/skills/claude-to-im.
If that path doesn't exist, fall back to Glob with pattern /skills//claude-to-im/SKILL.md and derive the root from the result.
Parse the user's intent from $ARGUMENTS into one of these subcommands:
| User says (examples) | Subcommand |
|---|---|
| --- | --- |
setup, configure, 配置, 我想在飞书上用 Claude, 帮我连接 Telegram | setup |
start, start bridge, 启动, 启动桥接 | start |
stop, stop bridge, 停止, 停止桥接 | stop |
status, bridge status, 状态, 运行状态, 怎么看桥接的运行状态 | status |
logs, logs 200, 查看日志, 查看日志 200 | logs |
reconfigure, 修改配置, 帮我改一下 token, 换个 bot | reconfigure |
doctor, diagnose, 诊断, 挂了, 没反应了, bot 没反应, 出问题了 | doctor |
Disambiguation: status vs doctor — Use status when the user just wants to check if the bridge is running (informational). Use doctor when the user reports a problem or suspects something is broken (diagnostic). When in doubt and the user describes a symptom (e.g., "没反应了", "挂了"), prefer doctor.
Extract optional numeric argument for logs (default 50).
Before asking users for any platform credentials, first read SKILL_DIR/references/setup-guides.md to get the detailed step-by-step guidance for that platform. Present the relevant guide text to the user via AskUserQuestion — users often don't know where to find bot tokens or app secrets, so showing the guide upfront saves back-and-forth.
Before executing any subcommand, detect which environment you are running in:
AskUserQuestion tool is available. Use it for interactive setup wizards.AskUserQuestion is NOT available. Fall back to non-interactive guidance: explain the steps, show SKILL_DIR/config.env.example, and ask the user to create ~/.claude-to-im/config.env manually.You can test this by checking if AskUserQuestion is in your available tools list.
start, stop, status, logs, reconfigure, doctor)Before running any subcommand other than setup, check if ~/.claude-to-im/config.env exists:
setup wizard using AskUserQuestion.~/.claude-to-im/config.env based on the example:" then show the contents of SKILL_DIR/config.env.example and stop. Don't attempt to start the daemon — without config.env the process will crash on startup and leave behind a stale PID file that blocks future starts.setupRun an interactive setup wizard. This subcommand requires AskUserQuestion. If it is not available (Codex environment), instead show the contents of SKILL_DIR/config.env.example with field-by-field explanations and instruct the user to create the config file manually.
When AskUserQuestion IS available, collect input one field at a time. After each answer, confirm the value back to the user (masking secrets to last 4 chars only) before moving to the next question.
Step 1 — Choose channels
Ask which channels to enable (telegram, discord, feishu, qq). Accept comma-separated input. Briefly describe each:
/perm ... commands.Step 2 — Collect tokens per channel
For each enabled channel, read SKILL_DIR/references/setup-guides.md and present the relevant platform guide to the user. Collect one credential at a time:
user_openid, NOT QQ number. If the user doesn't have openid yet, they can leave it empty.Step 3 — General settings
Ask for runtime, default working directory, model, and mode:
claude (default), codex, autoclaude — uses Claude Code CLI + Claude Agent SDK (requires claude CLI installed)codex — uses OpenAI Codex SDK (requires codex CLI; auth via codex auth login or OPENAI_API_KEY)auto — tries Claude first, falls back to Codex if Claude CLI not found$CWDcode (default), plan, askStep 4 — Write config and validate
mkdir -p ~/.claude-to-im/{data,logs,runtime,data/messages}~/.claude-to-im/config.env with all settings in KEY=VALUE formatchmod 600 ~/.claude-to-im/config.envSKILL_DIR/references/token-validation.md for the exact commands and expected responses for each platform. This catches typos and wrong credentials before the user tries to start the daemon./claude-to-im start to start the bridge."startPre-check: Verify ~/.claude-to-im/config.env exists (see "Config check" above). Without it, the daemon will crash immediately and leave a stale PID file.
Run: bash "SKILL_DIR/scripts/daemon.sh" start
Show the output to the user. If it fails, tell the user:
doctor to diagnose: /claude-to-im doctor/claude-to-im logsstopRun: bash "SKILL_DIR/scripts/daemon.sh" stop
statusRun: bash "SKILL_DIR/scripts/daemon.sh" status
logsExtract optional line count N from arguments (default 50).
Run: bash "SKILL_DIR/scripts/daemon.sh" logs N
reconfigure~/.claude-to-im/config.envSKILL_DIR/references/setup-guides.md and present the relevant guide for that field/claude-to-im stop then /claude-to-im start to apply the changes."doctorRun: bash "SKILL_DIR/scripts/doctor.sh"
Show results and suggest fixes for any failures. Common fixes:
cd SKILL_DIR && npm installcd SKILL_DIR && npm run buildsetupFor more complex issues (messages not received, permission timeouts, high memory, stale PID files), read SKILL_DIR/references/troubleshooting.md for detailed diagnosis steps.
~/.claude-to-im/config.env — survives across sessions.~/.claude-to-im/config.env with chmod 600 permissions — secrets written to other files or with broader permissions persist as uncontrolled attack surface.共 1 个版本