docreview

package
v0.227.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package docreview is the logic of review annotations on project documents: finding an annotation's quote again in the current text and rendering the annotations of a review round as the feedback an agent receives. It reads no files and holds no state: the entry layers read the document, the stage service decides when to send the feedback.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoDocInRound = errors.New("the review round did not record this document")

ErrNoDocInRound is returned when a review round did not record the document.

View Source
var ErrNoRound = errors.New("review round not found")

ErrNoRound is returned by the round-based diff when the flow has no such review round.

View Source
var ErrUnknownProject = errors.New("unknown project")

ErrUnknownProject is returned when the project key is not registered.

Functions

func Section

func Section(content string, a jobstore.DocAnnotation) string

Section is the title of the nearest markdown heading above the annotation's quote ("" when the quote cannot be found or sits above every heading).

func Summary

func Summary(lang i18n.Lang, round int, anns []jobstore.DocAnnotation, content ContentFunc) string

Summary renders annotations as the structured feedback of a review round:

## 评审意见(第 N 轮,M 条)
1. [change] docs/design/x.md §「2.1 存储」
   原文:> …
   建议改成:…

It is "" for no annotations. content may be nil (no section is named then).

Types

type Annotation

type Annotation struct {
	jobstore.DocAnnotation
	Located *Located `json:"located,omitempty"`
}

Annotation is a stored annotation with where its quote sits in the current document text.

type ContentFunc

type ContentFunc func(project, path string) string

ContentFunc returns the current text of a project document ("" when it cannot be read); it lets the summary name the section an annotation sits in.

type CreateInput

type CreateInput struct {
	Project, Base, Path     string
	Quote, Prefix, Suffix   string
	Kind, Body, Replacement string
	WorkItemID, Author      string
}

CreateInput is a new annotation. Path is as the doc reader takes it (Base, when set, is the reader's base): the stored path is the resolved project-root-relative one.

type Deps

type Deps struct {
	Store *jobstore.Store
	// Config returns the current server configuration; it is called per request.
	Config func() *config.Config
	// Project resolves a project key (the registry's Get).
	Project func(key string) (config.ProjectConfig, error)
}

Deps is what the service needs from the process.

type Located

type Located struct {
	// Found is false when the quote cannot be found any more (the annotation is stale).
	Found bool `json:"found"`
	// Line is the 1-based line of the quote's first character (0 when not found).
	Line int `json:"line,omitempty"`
}

Located is where an annotation sits in a document.

func Locate

func Locate(content string, a jobstore.DocAnnotation) Located

Locate finds the annotation in the current text of its document.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service stores and serves review annotations and the document diffs between review rounds.

func New

func New(d Deps) *Service

New builds the service.

func (*Service) Create

func (s *Service) Create(in CreateInput) (Annotation, error)

Create stores an annotation on a document. The document must be readable by the doc reader and still contain the quote. In a work item's context (WorkItemID set) the item must belong to the project, and the annotation joins the flow's newest review round.

func (*Service) Delete

func (s *Service) Delete(projectKey, id string) error

Delete removes an annotation of the project.

func (*Service) Diff

func (s *Service) Diff(projectKey, base, path, from, to string) (project.DocDiffResult, error)

Diff is the line diff of a document between two commits (to "" = HEAD).

func (*Service) ItemDiff

func (s *Service) ItemDiff(id, path string, from, to int) (project.DocDiffResult, error)

ItemDiff is the diff of a flow's document between review round from and round to (to 0 = the document's HEAD now); the commits are the ones the rounds recorded.

func (*Service) ListDoc

func (s *Service) ListDoc(projectKey, base, path, state, workItem string, round int) ([]Annotation, error)

ListDoc lists the annotations of a project: of one document when path is set (resolved like the doc reader), narrowed by state, work item and round (round < 0 = any).

func (*Service) ListItem

func (s *Service) ListItem(id string, round int, state string) (int, []Annotation, error)

ListItem lists the annotations of a work item in a review round (round < 0 = the newest round; 0 = those made before any round was recorded), optionally only one state.

func (*Service) SetState

func (s *Service) SetState(projectKey, id, state, by string) (Annotation, error)

SetState resolves (state "resolved") or reopens (state "open") an annotation of the project.

Jump to

Keyboard shortcuts

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