feat: 修复一些问题

This commit is contained in:
kite 2026-04-29 14:32:20 +08:00
parent e2d6a54d55
commit 07b6ba2ca2
7 changed files with 10 additions and 7 deletions

View file

@ -180,7 +180,7 @@ Flags:`)
fs.StringVar(&d.from, "from", "", "source ref to start diff from (e.g., 'main')")
fs.StringVar(&d.to, "to", "", "target ref to end diff at (e.g., 'feature-branch')")
fs.StringVar(&d.commit, "commit", "", "single commit hash or tag to review (vs its parent) (shorthand: -c)")
fs.IntVar(&d.concurrency, "concurrency", 4, "max concurrent file reviews")
fs.IntVar(&d.concurrency, "concurrency", 8, "max concurrent file reviews")
fs.IntVar(&d.perFileTimeout, "timeout", 10, "per-file timeout in minutes")
fs.BoolVar(&d.debug, "debug", false, "enable debug mode (write session dump to temp/)")
fs.PrintDefaults()

View file

@ -37,7 +37,7 @@ func dispatch() error {
}
switch args[0] {
case "--version", "-v":
case "--version", "-V":
printVersion()
return nil
case "version":

View file

@ -97,7 +97,7 @@ func runReview(args []string) error {
PlanToolDefs: planToolDefs,
MainToolDefs: mainToolDefs,
CommentCollector: collector,
CommentWorkerPool: agent.NewCommentWorkerPool(8),
CommentWorkerPool: agent.NewCommentWorkerPool(opts.concurrency),
MaxConcurrency: opts.concurrency,
PerFileTimeoutMinutes: opts.perFileTimeout,
Debug: opts.debug,

BIN
dist/opencodereview vendored

Binary file not shown.

View file

@ -134,7 +134,10 @@ func (p *CommentWorkerPool) Submit(f func() ([]model.LlmComment, error)) {
p.semaphore <- struct{}{} // acquire
defer func() { <-p.semaphore }() // release
comments, _ := f() // errors are logged; results are merged below
comments, err := f()
if err != nil {
fmt.Printf("[ocr] CommentWorkerPool error: %v\n", err)
}
p.resultsMu.Lock()
p.results = append(p.results, comments...)
p.resultsMu.Unlock()

View file

@ -37,7 +37,7 @@ func (p *CodeSearchProvider) Execute(args map[string]any) (string, error) {
result, err := p.gitGrep(searchText, caseSensitive, usePerlRegexp, patterns)
if err != nil {
return "The system encountered some problems when calling the code_search tool. Please try a different tool.", nil
return "", fmt.Errorf("code_search failed: %w", err)
}
return result, nil
}

View file

@ -33,7 +33,7 @@ func (p *FileReadProvider) Execute(args map[string]any) (string, error) {
content, err := p.FileReader.Read(filePath)
if err != nil {
return fmt.Sprintf("Error: file %q not found: %v", filePath, err), nil
return "", fmt.Errorf("file %q not found: %w", filePath, err)
}
lines := strings.Split(content, "\n")
@ -47,7 +47,7 @@ func (p *FileReadProvider) Execute(args map[string]any) (string, error) {
start := int(startLine) - 1
if start >= totalLines {
return fmt.Sprintf("Error: file %q has only %d lines, requested range %d-%d", filePath, totalLines, int(startLine), int(endLine)), nil
return "", fmt.Errorf("file %q has only %d lines, requested range %d-%d", filePath, totalLines, int(startLine), int(endLine))
}
// Apply 500-line cap and track truncation.