Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ Without `--install`, the script is printed to stdout. `crabcode completion` with

If you previously ran `crabcode completion >> ~/.zshrc`, re-run `--install` so that dump is stripped and replaced by the autoload hook.

### Pull Requests

Fetch and checkout a GitHub pull request as `pr/<number>`, then start Crabcode in the checked-out worktree:

```sh
crabcode pr <number>
```

This command requires the authenticated [GitHub CLI](https://cli.github.com/). For pull requests from forks, Crabcode also adds the fork as a Git remote when needed and configures the local branch to track the contributor's branch.

### Agent Types

- **PLAN** - Read-only analysis and planning agent. Best for understanding codebases, architecture questions, and planning changes.
Expand Down
10 changes: 10 additions & 0 deletions npm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ Without `--install`, the script is printed to stdout. `crabcode completion` with

If you previously ran `crabcode completion >> ~/.zshrc`, re-run `--install` so that dump is stripped and replaced by the autoload hook.

### Pull Requests

Fetch and checkout a GitHub pull request as `pr/<number>`, then start Crabcode in the checked-out worktree:

```sh
crabcode pr <number>
```

This command requires the authenticated [GitHub CLI](https://cli.github.com/). For pull requests from forks, Crabcode also adds the fork as a Git remote when needed and configures the local branch to track the contributor's branch.

### Agent Types

- **PLAN** - Read-only analysis and planning agent. Best for understanding codebases, architecture questions, and planning changes.
Expand Down
22 changes: 22 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mod mcp;
mod model;
mod notify;
mod persistence;
mod pr;
mod prompt;
mod remote;
mod remote_mcp;
Expand Down Expand Up @@ -791,6 +792,12 @@ enum Command {
target: Option<String>,
},

/// Fetch and checkout a GitHub PR branch, then run crabcode
Pr {
/// PR number to checkout
number: u64,
},

/// Show token usage and cost statistics
Stats {
/// Show stats for the last N days (default: all time)
Expand Down Expand Up @@ -1027,6 +1034,9 @@ async fn main() -> Result<()> {
Some(Command::Upgrade { target }) => {
return crate::upgrade::upgrade(target.as_deref());
}
Some(Command::Pr { number }) => {
return crate::pr::run(*number);
}
Some(Command::Stats {
days,
tools,
Expand Down Expand Up @@ -1441,6 +1451,8 @@ mod tests {
assert!(help.contains("Generate or install shell completions"));
assert!(help.contains("stats"));
assert!(help.contains("Show token usage and cost statistics"));
assert!(help.contains("pr"));
assert!(help.contains("Fetch and checkout a GitHub PR branch, then run crabcode"));
assert!(
help.contains("serve Host the current workspace for browser and CLI clients")
);
Expand Down Expand Up @@ -1488,6 +1500,16 @@ mod tests {
}
}

#[test]
fn parses_pr_command() {
let args = Args::try_parse_from(["crabcode", "pr", "123"]).unwrap();

match args.command {
Some(Command::Pr { number }) => assert_eq!(number, 123),
other => panic!("expected pr command, got {other:?}"),
}
}

#[test]
fn parses_print_attach_flag() {
let args = Args::try_parse_from([
Expand Down
Loading
Loading