review.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import type { ContentBlockParam } from '@anthropic-ai/sdk/resources/messages.js'
  2. import type { Command } from '../commands.js'
  3. import { isUltrareviewEnabled } from './review/ultrareviewEnabled.js'
  4. // Legal wants the explicit surface name plus a docs link visible before the
  5. // user triggers, so the description carries "Claude Code on the web" + URL.
  6. const CCR_TERMS_URL = 'https://code.claude.com/docs/en/claude-code-on-the-web'
  7. const LOCAL_REVIEW_PROMPT = (args: string) => `
  8. You are an expert code reviewer. Follow these steps:
  9. 1. If no PR number is provided in the args, run \`gh pr list\` to show open PRs
  10. 2. If a PR number is provided, run \`gh pr view <number>\` to get PR details
  11. 3. Run \`gh pr diff <number>\` to get the diff
  12. 4. Analyze the changes and provide a thorough code review that includes:
  13. - Overview of what the PR does
  14. - Analysis of code quality and style
  15. - Specific suggestions for improvements
  16. - Any potential issues or risks
  17. Keep your review concise but thorough. Focus on:
  18. - Code correctness
  19. - Following project conventions
  20. - Performance implications
  21. - Test coverage
  22. - Security considerations
  23. Format your review with clear sections and bullet points.
  24. PR number: ${args}
  25. `
  26. const review: Command = {
  27. type: 'prompt',
  28. name: 'review',
  29. description: 'Review a pull request',
  30. progressMessage: 'reviewing pull request',
  31. contentLength: 0,
  32. source: 'builtin',
  33. async getPromptForCommand(args): Promise<ContentBlockParam[]> {
  34. return [{ type: 'text', text: LOCAL_REVIEW_PROMPT(args) }]
  35. },
  36. }
  37. // /ultrareview is the ONLY entry point to the remote bughunter path —
  38. // /review stays purely local. local-jsx type renders the overage permission
  39. // dialog when free reviews are exhausted.
  40. const ultrareview: Command = {
  41. type: 'local-jsx',
  42. name: 'ultrareview',
  43. description: `~10–20 min · Finds and verifies bugs in your branch. Runs in Claude Code on the web. See ${CCR_TERMS_URL}`,
  44. isEnabled: () => isUltrareviewEnabled(),
  45. load: () => import('./review/ultrareviewCommand.js'),
  46. }
  47. export default review
  48. export { ultrareview }