Documentation
¶
Index ¶
- func DetectEditor() string
- func EditPrompt(prompt string) (string, error)
- func EstimateTokens(text string) int
- func PrintTokenWarnings(tokens int)
- func RenderPrompt(ctx RevisionContext) (string, error)
- type AutoFixture
- type FixtureComment
- type ProcessedComment
- type PromptComment
- type ReviewComment
- type ReviseClient
- func (c *ReviseClient) FetchComments(changeID string) ([]ReviewComment, error)
- func (c *ReviseClient) GetChange(specID string) (*apiChange, error)
- func (c *ReviseClient) GetProject(repoOwner, repoName string) (*apiProject, error)
- func (c *ReviseClient) GetSpec(projectID, specKey string) (*apiSpec, error)
- func (c *ReviseClient) ListSpecsWithComments(projectID string) ([]SpecWithCommentCount, error)
- func (c *ReviseClient) ResolveComment(commentID string) error
- type RevisionContext
- type SpecWithCommentCount
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 ¶
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 ¶
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 // 1-based display index
}
ProcessedComment is an in-memory struct for a comment the user chose to process.
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
}
PromptComment is a single comment entry in the revision prompt template.
type ReviewComment ¶
type ReviewComment struct {
ID string `json:"id"`
ChangeID string `json:"change_id"`
FilePath string `json:"file_path"`
Content string `json:"content"`
SelectedText string `json:"selected_text"`
Line *int `json:"line"`
StartLine *int `json:"start_line"`
IsResolved bool `json:"is_resolved"`
AuthorID string `json:"author_id"`
AuthorName string `json:"author_name"`
AuthorEmail string `json:"author_email"`
ParentCommentID string `json:"parent_comment_id"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
ReviewComment maps to the review_comments table in Supabase.
type ReviseClient ¶
type ReviseClient struct {
// contains filtered or unexported fields
}
ReviseClient handles all Supabase PostgREST calls for the revise command.
func NewReviseClient ¶
func NewReviseClient(accessToken string) *ReviseClient
NewReviseClient creates a ReviseClient using the configured Supabase URL and anon key. The provided accessToken is used for Authorization headers; call doWithRetry to handle 401s.
func (*ReviseClient) FetchComments ¶
func (c *ReviseClient) FetchComments(changeID string) ([]ReviewComment, error)
FetchComments fetches all unresolved top-level review comments for the given change. Results are ordered by created_at ascending (oldest first).
func (*ReviseClient) GetChange ¶
func (c *ReviseClient) GetChange(specID string) (*apiChange, error)
GetChange fetches the open change record for the given spec.
func (*ReviseClient) GetProject ¶
func (c *ReviseClient) GetProject(repoOwner, repoName string) (*apiProject, error)
GetProject fetches the project record for the given GitHub repo.
func (*ReviseClient) GetSpec ¶
func (c *ReviseClient) GetSpec(projectID, specKey string) (*apiSpec, error)
GetSpec fetches the spec record for the given project and spec key (branch name).
func (*ReviseClient) ListSpecsWithComments ¶
func (c *ReviseClient) ListSpecsWithComments(projectID string) ([]SpecWithCommentCount, error)
ListSpecsWithComments returns all specs for the project that have unresolved review comments.
Implementation: 3 sequential calls + client-side aggregation.
- GET /rest/v1/specs?project_id=eq.{pid}&select=id,spec_key
- GET /rest/v1/changes?spec_id=in.({spec_ids})&select=id,spec_id
- GET /rest/v1/review_comments?change_id=in.({change_ids})&is_resolved=eq.false&select=id,change_id
Client-side: group comments by change → map change to spec → count per spec_key. See contracts/postgrest-api.md §6 for the rationale.
func (*ReviseClient) ResolveComment ¶
func (c *ReviseClient) ResolveComment(commentID string) error
ResolveComment marks a review comment as resolved via PATCH.
type RevisionContext ¶
type RevisionContext struct {
SpecKey string
Comments []PromptComment
}
RevisionContext is the template rendering context for the combined prompt.
func BuildRevisionContext ¶
func BuildRevisionContext(specKey string, processed []ProcessedComment) RevisionContext
BuildRevisionContext converts processed comments into the template rendering context.
type SpecWithCommentCount ¶
SpecWithCommentCount is used by the branch picker to list specs with pending review comments.