review

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package review holds the comment model and on-disk store for the workbench review tab. Derived from kevindutra/crit (see NOTICE.md); unlike upstream, every path is rooted at an explicit worktree root rather than the process working directory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComposePrompt

func ComposePrompt(root string, states []*ReviewState) string

ComposePrompt formats review comments as a single instruction prompt for the session's agent. File paths are shown relative to root (the agent's working directory). Returns "" when there are no comments.

func EnsureDirs

func EnsureDirs(root string) error

EnsureDirs creates <root>/.crit/reviews and a self-ignoring .gitignore so review state never shows up in git status or loom's diff stats.

func ReviewPath

func ReviewPath(root, docPath string) string

ReviewPath maps a document path to its review file under root. The hash covers the absolute doc path so renaming the worktree parent (loom never does) is the only way to orphan a review.

func Save

func Save(root string, state *ReviewState) error

Save writes state atomically (tmp + rename) under a flock so a concurrently running crit CLI in the same worktree can't interleave.

func SaveSession

func SaveSession(root string, session *CodeReviewSession) error

Types

type CodeReviewSession

type CodeReviewSession struct {
	Files     []string  `yaml:"files"`
	DiffBase  string    `yaml:"diff_base"`
	CreatedAt time.Time `yaml:"created_at"`
}

CodeReviewSession tracks which files belong to the current code review. Written for interop: an agent running the crit CLI in the worktree reads the same manifest.

func LoadSession

func LoadSession(root string) (*CodeReviewSession, error)

type Comment

type Comment struct {
	ID             string    `json:"id" yaml:"id"`
	Line           int       `json:"line" yaml:"line"`
	EndLine        int       `json:"end_line,omitempty" yaml:"end_line,omitempty"`
	ContentSnippet string    `json:"content_snippet" yaml:"content_snippet"`
	Body           string    `json:"body" yaml:"body"`
	CreatedAt      time.Time `json:"created_at" yaml:"created_at"`
}

type Document

type Document struct {
	Path    string
	Content string
	Lines   []string
	Hash    string
}

func LoadDocument

func LoadDocument(path string) (*Document, error)

func (*Document) LineAt

func (d *Document) LineAt(n int) string

func (*Document) LineCount

func (d *Document) LineCount() int

type ReviewState

type ReviewState struct {
	File     string    `json:"file" yaml:"file"`
	Comments []Comment `json:"comments" yaml:"comments"`
}

func Load

func Load(root, docPath string) (*ReviewState, error)

Load reads the review state for docPath, returning an empty state when none exists yet.

func (*ReviewState) AddComment

func (s *ReviewState) AddComment(c Comment)

func (*ReviewState) DeleteComment

func (s *ReviewState) DeleteComment(id string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL