open-code-review/internal/delegate/format.go
kite 4ee453fd79
Some checks are pending
CI / test (push) Waiting to run
feat(delegate): add delegation mode for host-agent driven code review (#383)
* feat(delegate): add delegation mode for host-agent driven code review

Add `ocr delegate` subcommand that provides deterministic file selection
and rule resolution without calling any LLM. This enables AI coding agents
to perform reviews themselves using OCR only for engineering scaffolding
(preview which files to review, resolve grouped rules by path).

Includes:
- `ocr delegate preview` — outputs reviewable file list with mode/ref metadata
- `ocr delegate rule <path...>` — outputs review rules grouped by content
- Claude Code plugin command (delegate-review.md)
- Skill definitions for Claude Code, Codex, and Cursor
- Unit tests for internal/delegate package
- README documentation synced across all 5 locales

* fix(delegate): group rules by source, pattern and text

GroupRules keyed groups on rule text alone, so files sharing identical
rule text but resolved from different sources or matched by different
patterns were merged into one group that kept only the first file's
Source/Pattern metadata. Use a composite (source, pattern, text) key so
each group's provenance is accurate for every file it contains.
2026-07-16 13:10:54 +08:00

25 lines
550 B
Go

package delegate
import (
"fmt"
"strings"
)
// RuleGroupsMarkdown renders rule groups into a markdown section.
func RuleGroupsMarkdown(groups []RuleGroup) string {
var b strings.Builder
for i, g := range groups {
if i > 0 {
b.WriteString("\n---\n\n")
}
fmt.Fprintf(&b, "### Rule Group %d: %s / %s\n\n", g.ID, g.Source, g.Pattern)
b.WriteString("Applies to:\n")
for _, f := range g.Files {
fmt.Fprintf(&b, "- %s\n", f)
}
b.WriteString("\n#### Content\n\n")
b.WriteString(g.Text)
b.WriteByte('\n')
}
return b.String()
}