Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.ja-JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ ocr review --commit abc123
ocr session list
ocr review --from main --to feature-branch --resume <session-id>

# 保存済みセッションの確認:メタデータ、ファイルごとの項目、具体化されたコメント
ocr session show <session-id>
ocr session comments <session-id> # ocr review スタイルでコメントを表示
ocr session comments <session-id> --severity high # 重要度で絞り込み
ocr session comments <session-id> --json # スクリプト用に JSON を出力

# フルファイルスキャン — diffではなくファイル全体をレビュー(git履歴不要)
ocr scan # リポジトリ全体をスキャン
ocr scan --path internal/agent # ディレクトリまたは特定のファイルをスキャン
Expand Down
6 changes: 6 additions & 0 deletions README.ko-KR.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ ocr review --commit abc123
ocr session list
ocr review --from main --to feature-branch --resume <session-id>

# 저장된 세션 확인: 메타데이터, 파일별 항목, 구체화된 코멘트
ocr session show <session-id>
ocr session comments <session-id> # ocr review 스타일로 코멘트 보기
ocr session comments <session-id> --severity high # 심각도로 필터링
ocr session comments <session-id> --json # 스크립트용 JSON 출력

# 전체 파일 스캔 — diff 대신 파일 전체를 리뷰 (git 이력 불필요)
ocr scan # 전체 repository 스캔
ocr scan --path internal/agent # 디렉터리 또는 특정 파일 스캔
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ ocr review --commit abc123
ocr session list
ocr review --from main --to feature-branch --resume <session-id>

# Inspect a saved session: metadata, per-file items, and the materialized comments
ocr session show <session-id>
ocr session comments <session-id> # view comments in ocr review style
ocr session comments <session-id> --severity high # filter by severity
ocr session comments <session-id> --json # emit JSON for scripting

# Full-file scan — review whole files instead of a diff (no git history needed)
ocr scan # scan the entire repository
ocr scan --path internal/agent # scan a directory or specific files
Expand Down
6 changes: 6 additions & 0 deletions README.ru-RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ ocr review --commit abc123
ocr session list
ocr review --from main --to feature-branch --resume <session-id>

# Просмотр сохранённой сессии: метаданные, записи по файлам и сами комментарии
ocr session show <session-id>
ocr session comments <session-id> # комментарии в стиле ocr review
ocr session comments <session-id> --severity high # фильтр по критичности
ocr session comments <session-id> --json # вывод JSON для скриптов

# Полнофайловое сканирование — ревью целых файлов вместо диффа (история git не нужна)
ocr scan # сканировать весь репозиторий
ocr scan --path internal/agent # сканировать каталог или конкретные файлы
Expand Down
6 changes: 6 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ ocr review --commit abc123
ocr session list
ocr review --from main --to feature-branch --resume <session-id>

# 查看已保存的会话:元数据、按文件汇总的条目以及具体评论内容
ocr session show <session-id>
ocr session comments <session-id> # 以 ocr review 风格查看评论
ocr session comments <session-id> --severity high # 按严重程度筛选
ocr session comments <session-id> --json # 输出 JSON 以便脚本处理

# 全量文件扫描 —— 审查整个文件而非 diff(无需 git 历史)
ocr scan # 扫描整个仓库
ocr scan --path internal/agent # 扫描指定目录或文件
Expand Down
101 changes: 98 additions & 3 deletions cmd/opencodereview/session_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"text/tabwriter"
"time"

"github.com/open-code-review/open-code-review/internal/model"
"github.com/open-code-review/open-code-review/internal/session"
)

Expand All @@ -22,6 +23,8 @@ func runSession(args []string) error {
return runSessionList(args[1:])
case "show":
return runSessionShow(args[1:])
case "comments":
return runSessionComments(args[1:])
case "-h", "--help":
printSessionUsage()
return nil
Expand Down Expand Up @@ -116,6 +119,82 @@ func runSessionShow(args []string) error {
return nil
}

func runSessionComments(args []string) error {
a := newOcrFlagSet("ocr session comments")
var repoDir string
var asJSON bool
var severity string
var category string
a.StringVar(&repoDir, "repo", "", "root directory of the git repository (default: current dir)")
a.BoolVar(&asJSON, "json", false, "emit JSON instead of text")
a.StringVar(&severity, "severity", "", "show only comments with this exact severity (e.g. high)")
a.StringVar(&category, "category", "", "show only comments with this exact category (e.g. bug)")
if err := a.Parse(args); err != nil {
return err
}
if a.showHelp {
printSessionCommentsUsage()
return nil
}

rest := a.fs.Args()
if len(rest) == 0 {
printSessionCommentsUsage()
return fmt.Errorf("session comments requires a session ID")
}
sessionID := rest[0]

resolvedRepo, err := resolveWorkingDirForSession(repoDir)
if err != nil {
return err
}
summary, entries, err := session.LoadComments(resolvedRepo, sessionID)
if err != nil {
return fmt.Errorf("load session %q: %w", sessionID, err)
}

// Flatten surviving comments in on-disk record order; filters are exact
// match and select but never reorder, so two runs over the same session
// diff cleanly.
var comments []model.LlmComment
for _, e := range entries {
for _, c := range e.Comments {
if severity != "" && c.Severity != severity {
continue
}
if category != "" && c.Category != category {
continue
}
comments = append(comments, c)
}
}

if asJSON {
payload := struct {
SessionID string `json:"session_id"`
Comments []model.LlmComment `json:"comments"`
}{
SessionID: summary.SessionID,
Comments: comments, // nil → marshals as null; normalize to []
}
if payload.Comments == nil {
payload.Comments = []model.LlmComment{}
}
enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", " ")
return enc.Encode(payload)
}

if len(comments) == 0 {
fmt.Println("No comments found for this session.")
return nil
}
for _, c := range comments {
renderComment(c)
}
return nil
}

// resolveWorkingDirForSession accepts an explicit --repo flag value and falls
// back to the current working directory. Unlike resolveRepoDir it does not
// require the target to be a git repository, so users can inspect sessions
Expand Down Expand Up @@ -267,10 +346,11 @@ func printSessionUsage() {
ocr session <sub-command>

Sub-commands:
list, ls List recent review sessions for the current repo
show <id> Show one session's metadata and per-file items
list, ls List recent review sessions for the current repo
show <id> Show one session's metadata and per-file items
comments <id> Show the materialized comments of one session

Use "ocr session list -h" or "ocr session show -h" for details.`)
Use "ocr session list -h", "ocr session show -h", or "ocr session comments -h" for details.`)
}

func printSessionListUsage() {
Expand All @@ -297,3 +377,18 @@ Flags:
--repo string Root directory of the git repository (default: current dir)
--json Emit JSON instead of a table`)
}

func printSessionCommentsUsage() {
fmt.Println(`Usage:
ocr session comments [flags] <session-id>

Show the materialized review comments of a single session, in the same style as
'ocr review'. Comments are sourced from review_item_done and review_item_reused
records, in on-disk order.

Flags:
--repo string Root directory of the git repository (default: current dir)
--json Emit {"session_id","comments":[...]} JSON instead of text
--severity string Show only comments with this exact severity (e.g. high)
--category string Show only comments with this exact category (e.g. bug)`)
}
Loading
Loading