Skip to content

refactor: merge bot/cli.ts into bot/index.ts, add serve subcommand#198

Open
snomiao wants to merge 4 commits intomainfrom
refactor/merge-bot-cli-into-index
Open

refactor: merge bot/cli.ts into bot/index.ts, add serve subcommand#198
snomiao wants to merge 4 commits intomainfrom
refactor/merge-bot-cli-into-index

Conversation

@snomiao
Copy link
Copy Markdown
Member

@snomiao snomiao commented Apr 10, 2026

Summary

Consolidates bot/cli.ts and bot/index.ts into a single bot/index.ts entry point.

Changes

  • Merged the yargs CLI (bot/cli.ts) into bot/index.ts
  • Original Slack bot startup is now the serve subcommand: prbot serve --continue
  • Updated all startup scripts (bot/up.sh, bot-start.sh, bot/start-with-status.sh)
  • Updated bot/Dockerfile, docker-compose.yml, package.json bin entries
  • Deleted bot/cli.ts

Usage

# Start Slack bot (was: bun bot/index.ts)
bun bot/index.ts serve --continue

# CLI commands unchanged
prbot slack read-thread -c C123 -t 123
prbot code pr -r Comfy-Org/ComfyUI -p 'Fix bug'
prbot --help

Motivation

Single entry point is simpler — no ambiguity between two bot files. Net +6 lines, no logic changes.

Copilot AI review requested due to automatic review settings April 10, 2026 19:07
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
comfy-pr Ready Ready Preview, Comment Apr 11, 2026 5:16pm

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts into bot/index.ts and introduced prbot serve for 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.

Comment thread bot/index.ts Outdated
Comment on lines +131 to +135
y.option("continue", {
type: "boolean",
describe: "Resume in-progress tasks on restart",
default: false,
}),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a1f7864 — added --no-watch boolean option to the serve command.

Comment thread bot/index.ts Outdated
Comment on lines +136 to +140
async (args) => {
console.log("Starting ComfyPR Slack Bot...");
const client = await (await import("./slack-bot.ts")).startSlackBot();
console.log("ComfyPR Slack Bot Done.");
},
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a1f7864loadEnvLocal() is now called in the serve handler before importing slack-bot.

Comment thread bot/index.ts Outdated
}),
async (args) => {
console.log("Starting ComfyPR Slack Bot...");
const client = await (await import("./slack-bot.ts")).startSlackBot();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a1f7864 — removed the client variable, now just awaits the call directly.

Comment thread bot/index.ts Outdated
" 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'",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a1f7864 — corrected to prbot slack upload-file.

Comment thread bot/README.md
- 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>
@snomiao snomiao force-pushed the refactor/merge-bot-cli-into-index branch from 2d8e4fc to fd3271c Compare April 11, 2026 14:35
@snomiao snomiao enabled auto-merge (squash) April 11, 2026 14:35
snomiao and others added 2 commits April 11, 2026 14:44
- 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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts into bot/index.ts and deleted bot/cli.ts.
  • Introduced prbot serve as the long-running Slack bot command and updated all scripts/docs to use bun bot/index.ts serve ....
  • Updated Docker/compose and package.json bin + 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.

Comment thread package.json
Comment on lines 12 to 17
"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"
},
Comment thread docs/RESTART-QUICKREF.md
Comment on lines 172 to 178
```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
```
Comment thread bot/index.ts
Comment on lines +1248 to +1286
.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", {
@snomiao snomiao enabled auto-merge (squash) April 22, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants