diff --git a/cmd/opencodereview/delegate_helpers_test.go b/cmd/opencodereview/delegate_helpers_test.go index 1e72b3bc5..1247d5dee 100644 --- a/cmd/opencodereview/delegate_helpers_test.go +++ b/cmd/opencodereview/delegate_helpers_test.go @@ -6,6 +6,8 @@ package main import ( "context" "testing" + + "github.com/spf13/cobra" ) func TestValidateDelegateOptions(t *testing.T) { @@ -34,6 +36,42 @@ func TestValidateDelegateOptions(t *testing.T) { } } +func TestDelegateFlags_RegisterJSONFormat(t *testing.T) { + var opts delegateOptions + cmd := &cobra.Command{ + Use: "preview", + SilenceUsage: true, + SilenceErrors: true, + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + return validateDelegateOptions(&opts) + }, + } + registerDelegateFlags(cmd, &opts) + cmd.SetArgs([]string{"--format", "json"}) + + if err := cmd.Execute(); err != nil { + t.Fatalf("delegate preview rejected --format json: %v", err) + } + if opts.format != "json" { + t.Fatalf("format = %q, want json", opts.format) + } + + formatFlag := cmd.Flags().Lookup("format") + if formatFlag == nil { + t.Fatal("delegate preview did not register --format") + } + if formatFlag.Shorthand != "f" { + t.Fatalf("format shorthand = %q, want f", formatFlag.Shorthand) + } + + for _, command := range []*cobra.Command{delegatePreviewCmd, delegateRuleCmd} { + if command.Flags().Lookup("format") == nil { + t.Errorf("%s did not register --format", command.Name()) + } + } +} + func TestDelegateContextReviewMode(t *testing.T) { cases := []struct { name string diff --git a/plugins/open-code-review/skills/open-code-review-delegate/SKILL.md b/plugins/open-code-review/skills/open-code-review-delegate/SKILL.md index ff161f187..d4444569a 100644 --- a/plugins/open-code-review/skills/open-code-review-delegate/SKILL.md +++ b/plugins/open-code-review/skills/open-code-review-delegate/SKILL.md @@ -41,6 +41,20 @@ npm install -g @alibaba-group/open-code-review No LLM configuration is needed for delegation mode. +The delegation JSON workflow requires an OCR CLI release that supports the +`--format` flag on both `delegate preview` and `delegate rule`. Verify the +installed binary before starting: + +```bash +ocr delegate preview --help +``` + +Continue only when the help output includes `--format` (or `-f`). If the flag +is missing, the installed CLI is older than this skill's JSON protocol. Upgrade +OCR to a release that supports delegation JSON output before continuing; do not +silently fall back to text output because the steps below consume structured +fields such as `reviewable_files`, `mode`, and `merge_base`. + ## Workflow ### Step 1: Preview — Determine What to Review diff --git a/skills/open-code-review-delegate/SKILL.md b/skills/open-code-review-delegate/SKILL.md index e5bec836e..2276edd27 100644 --- a/skills/open-code-review-delegate/SKILL.md +++ b/skills/open-code-review-delegate/SKILL.md @@ -36,6 +36,20 @@ npm install -g @alibaba-group/open-code-review No LLM configuration is needed for delegation mode. +The delegation JSON workflow requires an OCR CLI release that supports the +`--format` flag on both `delegate preview` and `delegate rule`. Verify the +installed binary before starting: + +```bash +ocr delegate preview --help +``` + +Continue only when the help output includes `--format` (or `-f`). If the flag +is missing, the installed CLI is older than this skill's JSON protocol. Upgrade +OCR to a release that supports delegation JSON output before continuing; do not +silently fall back to text output because the steps below consume structured +fields such as `reviewable_files`, `mode`, and `merge_base`. + ## Workflow ### Step 1: Preview — Determine What to Review