revise

package
v1.0.61 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectEditor

func DetectEditor() string

DetectEditor returns the user's preferred editor from the environment. It checks $EDITOR and $VISUAL first, then falls back to common editors.

func EditPrompt

func EditPrompt(prompt string) (string, error)

EditPrompt writes prompt to a temp file, opens it in the user's editor, and returns the (possibly modified) content after the editor exits.

func EstimateTokens

func EstimateTokens(text string) int

EstimateTokens estimates the number of tokens in text using the ~3.5 chars/token heuristic. See plan.md §6 and research.md R12 for the rationale. Accuracy is within ~20%.

func PrintTokenWarnings

func PrintTokenWarnings(tokens int)

PrintTokenWarnings prints warnings when the prompt is too short or too long.

func RenderPrompt

func RenderPrompt(ctx RevisionContext) (string, error)

RenderPrompt renders the revision prompt template with the given context.

Types

type AutoFixture

type AutoFixture struct {
	Branch   string           `json:"branch"`
	Comments []FixtureComment `json:"comments"`
}

AutoFixture is the fixture file structure for non-interactive automation mode.

func ParseFixture

func ParseFixture(path string) (*AutoFixture, error)

ParseFixture reads and parses a fixture JSON file for --auto mode.

type FixtureComment

type FixtureComment struct {
	FilePath     string `json:"file_path"`
	SelectedText string `json:"selected_text"`
	Guidance     string `json:"guidance"`
}

FixtureComment is a single comment entry in the automation fixture.

type ProcessedComment

type ProcessedComment struct {
	Comment  ReviewComment
	Guidance string
	Index    int
}

func MatchFixtureComments

func MatchFixtureComments(fixture *AutoFixture, comments []ReviewComment) ([]ProcessedComment, []string)

MatchFixtureComments matches fixture entries to fetched review comments by file_path + selected_text. Returns matched ProcessedComments (with guidance from fixture) and warning messages for unmatched entries. Warnings are intended for stderr so they do not contaminate stdout prompt output.

type PromptComment

type PromptComment struct {
	Index    int    // 1-based display index
	ID       string // Comment UUID (internal, for resolution)
	FilePath string
	Target   string // selected_text, "Line N", or "General"
	Feedback string // Comment content
	Guidance string // Optional user guidance
	Replies  []ThreadReply
}

PromptComment is a single comment entry in the revision prompt template.

type ReviewComment

type ReviewComment = comment.ReviewComment

type ReviseClient

type ReviseClient struct {
	*comment.Client
}

func NewReviseClient

func NewReviseClient(accessToken string) *ReviseClient

func (*ReviseClient) ListSpecsWithComments

func (c *ReviseClient) ListSpecsWithComments(projectID string) ([]SpecWithCommentCount, error)

func (*ReviseClient) ResolveComment

func (c *ReviseClient) ResolveComment(commentID string) error

func (*ReviseClient) ResolveCommentWithReplies added in v1.0.34

func (c *ReviseClient) ResolveCommentWithReplies(commentID string, replyIDs []string) error

type RevisionContext

type RevisionContext struct {
	SpecKey  string
	Comments []PromptComment
}

func BuildRevisionContext

func BuildRevisionContext(specKey string, processed []ProcessedComment, replies []ReviewComment) RevisionContext

BuildRevisionContext converts processed comments into the template rendering context. The replies slice contains all thread reply comments; they are grouped by parent_comment_id and attached to the corresponding PromptComment.

type SpecWithCommentCount

type SpecWithCommentCount struct {
	SpecKey      string
	CommentCount int
}

type ThreadReply added in v1.0.34

type ThreadReply = comment.ThreadReply

Jump to

Keyboard shortcuts

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