refactor: merge bot/cli.ts into bot/index.ts, add serve subcommand#198
refactor: merge bot/cli.ts into bot/index.ts, add serve subcommand#198
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR consolidates the bot’s yargs-based CLI and Slack-bot entrypoint into bot/index.ts, making prbot/pr-bot point at a single executable and moving the long-running Slack bot startup behind a new serve subcommand.
Changes:
- Merged
bot/cli.tsintobot/index.tsand introducedprbot servefor starting the Slack bot. - Updated runtime entrypoints (npm bin, Dockerfile, docker-compose, and shell scripts) to call
serve. - Removed
bot/cli.ts.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Updates prbot/pr-bot bin entrypoints and dev:bot to use serve. |
| docker-compose.yml | Runs the bot container with bun bot/index.ts serve. |
| bot/Dockerfile | Updates CMD to bun bot/index.ts serve. |
| bot/index.ts | Becomes the unified CLI entrypoint; adds serve subcommand and retains existing CLI commands. |
| bot/README.md | Updates CLI usage examples to point to bot/index.ts and serve. |
| bot/up.sh | PM2 start command updated to include serve --continue. |
| bot/start-with-status.sh | tmux startup command updated to include serve --continue. |
| bot-start.sh | Legacy wrapper updated to include serve --continue. |
| bot/cli.ts | Deleted (merged into bot/index.ts). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| y.option("continue", { | ||
| type: "boolean", | ||
| describe: "Resume in-progress tasks on restart", | ||
| default: false, | ||
| }), |
There was a problem hiding this comment.
Fixed in a1f7864 — added --no-watch boolean option to the serve command.
| async (args) => { | ||
| console.log("Starting ComfyPR Slack Bot..."); | ||
| const client = await (await import("./slack-bot.ts")).startSlackBot(); | ||
| console.log("ComfyPR Slack Bot Done."); | ||
| }, |
There was a problem hiding this comment.
Fixed in a1f7864 — loadEnvLocal() is now called in the serve handler before importing slack-bot.
| }), | ||
| async (args) => { | ||
| console.log("Starting ComfyPR Slack Bot..."); | ||
| const client = await (await import("./slack-bot.ts")).startSlackBot(); |
There was a problem hiding this comment.
Fixed in a1f7864 — removed the client variable, now just awaits the call directly.
| " prbot slack read-thread -c C123 -t 1234567890.123456", | ||
| " prbot slack read-thread -u 'https://workspace.slack.com/archives/C123/p1234567890'", | ||
| " prbot slack read-nearby -u 'https://workspace.slack.com/archives/C123/p1234567890' -b 20 -a 20", | ||
| " prbot slack upload -c C123 -f ./report.pdf -m 'Here is the report'", |
There was a problem hiding this comment.
Fixed in a1f7864 — corrected to prbot slack upload-file.
- Combined bot/cli.ts (yargs CLI) and bot/index.ts (Slack bot) into a single bot/index.ts - Original Slack bot startup migrated to 'serve' subcommand - Updated all startup scripts, Dockerfiles, and package.json bin entries - Deleted bot/cli.ts Amp-Thread-ID: https://ampcode.com/threads/T-019d7765-8ad5-75e9-b1f5-3ed839cd104f Co-authored-by: Amp <amp@ampcode.com>
2d8e4fc to
fd3271c
Compare
- Add --no-watch option to serve command for RestartManager disable - Call loadEnvLocal() in serve handler for standalone usage - Remove unused client variable in serve handler - Fix epilog: slack upload → slack upload-file Amp-Thread-ID: https://ampcode.com/threads/T-019d7765-8ad5-75e9-b1f5-3ed839cd104f Co-authored-by: Amp <amp@ampcode.com>
- CLAUDE.md: update PM2 command, CLI file references - docs/RESTART*.md: all bot/index.ts invocations now use serve subcommand - run-bot.md: update startup commands Amp-Thread-ID: https://ampcode.com/threads/T-019d7765-8ad5-75e9-b1f5-3ed839cd104f Co-authored-by: Amp <amp@ampcode.com>
Resolves conflict from #199 by porting the top-level `read <url>` command (Slack + Notion unified reader) from bot/cli.ts into bot/index.ts, which now owns the CLI after this refactor. bot/cli.ts is deleted. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR consolidates the bot’s two entrypoints (bot/cli.ts and bot/index.ts) into a single yargs-based CLI at bot/index.ts, and moves the Slack bot startup behind an explicit serve subcommand to remove ambiguity around how the bot is launched.
Changes:
- Merged the yargs CLI functionality from
bot/cli.tsintobot/index.tsand deletedbot/cli.ts. - Introduced
prbot serveas the long-running Slack bot command and updated all scripts/docs to usebun bot/index.ts serve .... - Updated Docker/compose and
package.jsonbin + dev script wiring to point at the unified entrypoint.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| run-bot.md | Updates Bun startup instructions to use serve. |
| package.json | Points prbot/pr-bot bin to bot/index.ts and updates dev:bot to run serve. |
| docs/RESTART.md | Updates restart docs to use serve. |
| docs/RESTART-SUMMARY.md | Updates restart summary examples to use serve. |
| docs/RESTART-QUICKREF.md | Updates quickref examples to use serve. |
| docs/RESTART-FLOW.md | Updates flow diagram command to include serve. |
| docker-compose.yml | Updates service command to bun bot/index.ts serve. |
| CLAUDE.md | Updates operational docs and CLI file references to bot/index.ts. |
| bot/up.sh | Updates PM2 start arguments to include serve. |
| bot/start-with-status.sh | Updates tmux startup command to include serve. |
| bot/README.md | Updates CLI docs and examples to use bot/index.ts and adds serve usage. |
| bot/index.ts | Becomes the unified CLI entrypoint and adds the serve subcommand. |
| bot/Dockerfile | Updates default CMD to run serve. |
| bot/cli.ts | Deleted (merged into bot/index.ts). |
| bot-start.sh | Updates restart loop command to include serve. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "bin": { | ||
| "cmpr": "./src/cli.ts", | ||
| "comfy-pr": "./src/cli.ts", | ||
| "pr-bot": "./bot/cli.ts", | ||
| "prbot": "./bot/cli.ts" | ||
| "pr-bot": "./bot/index.ts", | ||
| "prbot": "./bot/index.ts" | ||
| }, |
| ```bash | ||
| # Disable smart restart | ||
| bun bot/index.ts --continue --no-watch | ||
| bun bot/index.ts serve --continue --no-watch | ||
|
|
||
| # Or set environment variable | ||
| NO_WATCH=1 bun bot/index.ts --continue | ||
| NO_WATCH=1 bun bot/index.ts serve --continue | ||
| ``` |
| .command( | ||
| "status <task_dir>", | ||
| "Show status file for a task", | ||
| (y) => | ||
| y.positional("task_dir", { | ||
| type: "string", | ||
| describe: "Task directory path", | ||
| demandOption: true, | ||
| }), | ||
| async (args) => { | ||
| const statusPath = `${args.task_dir}/.logs/STATUS.txt`; | ||
| const { $ } = await import("bun"); | ||
| await $`cat ${statusPath}`; | ||
| }, | ||
| ) | ||
| .command( | ||
| "tail <task_dir>", | ||
| "Tail live stdout logs for a task", | ||
| (y) => | ||
| y.positional("task_dir", { | ||
| type: "string", | ||
| describe: "Task directory path", | ||
| demandOption: true, | ||
| }), | ||
| async (args) => { | ||
| const logPath = `${args.task_dir}/.logs/claude-yes-stdout.log`; | ||
| const { $ } = await import("bun"); | ||
| await $`tail -f ${logPath}`; | ||
| }, | ||
| ) | ||
| .demandCommand(1, "Please specify a debug subcommand") | ||
| .help(); | ||
| }) | ||
| .command( | ||
| "feedback", | ||
| "Submit feedback (bugs, feature requests, errors) to the private #prbot-feedback Slack channel", | ||
| (y) => | ||
| y | ||
| .option("message", { |
Summary
Consolidates
bot/cli.tsandbot/index.tsinto a singlebot/index.tsentry point.Changes
bot/cli.ts) intobot/index.tsservesubcommand:prbot serve --continuebot/up.sh,bot-start.sh,bot/start-with-status.sh)bot/Dockerfile,docker-compose.yml,package.jsonbin entriesbot/cli.tsUsage
Motivation
Single entry point is simpler — no ambiguity between two bot files. Net +6 lines, no logic changes.