(opts delegateOptions)
| 82 | } |
| 83 | |
| 84 | func loadDelegateContext(opts delegateOptions) (*delegateContext, error) { |
| 85 | cc, err := loadCommonContext(opts.repoDir, opts.rulePath, 0, opts.maxGitProcs, true) |
| 86 | if err != nil { |
| 87 | return nil, err |
| 88 | } |
| 89 | applyCLIExcludes(cc, splitPaths(opts.excludes)) |
| 90 | |
| 91 | // Security: reject ref-option injection. |
| 92 | reviewOpts := reviewOptions{from: opts.from, to: opts.to, commit: opts.commit} |
| 93 | if err := validateReviewRefs(cc.RepoDir, reviewOpts); err != nil { |
| 94 | return nil, err |
| 95 | } |
| 96 | |
| 97 | // Resolve background from --background-file if set. |
| 98 | if opts.backgroundFile != "" { |
| 99 | bgPath := resolveBackgroundFilePath(cc.RepoDir, opts.backgroundFile) |
| 100 | fileBackground, err := loadBackgroundFile(bgPath) |
| 101 | if err != nil { |
| 102 | return nil, err |
| 103 | } |
| 104 | opts.background = mergeBackground(opts.background, fileBackground) |
| 105 | } |
| 106 | |
| 107 | // Auto-fill background from commit message when reviewing a single commit. |
| 108 | if opts.commit != "" && opts.background == "" { |
| 109 | if msg, err := getCommitMessage(cc.RepoDir, opts.commit); err == nil && msg != "" { |
| 110 | opts.background = msg |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | return &delegateContext{cc: cc, opts: opts}, nil |
| 115 | } |
| 116 | |
| 117 | // preview runs the agent's file-selection logic and returns the preview result. |
| 118 | func (dc *delegateContext) preview(ctx context.Context) (*agent.DiffPreview, error) { |
no test coverage detected