cli

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 44 Imported by: 0

Documentation

Overview

Package cli implements the Telescope command-line interface using cobra.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute()

Execute runs the CLI. Call from main.go.

func GeneratePRComment

func GeneratePRComment(report *LintReport, repo, headRef string) []string

GeneratePRComment creates markdown comment bodies from a lint report, grouped by rule with clickable GitHub links. It returns one or more chunks under githubMaxIssueCommentBytes, splitting at rule-group boundaries and splitting large single-rule tables by row.

func SaveBaseline

func SaveBaseline(allDiags []fileDiagnostics) error

SaveBaseline writes the current diagnostics as a baseline file.

Types

type Baseline

type Baseline struct {
	Version     string                       `json:"version"`
	Diagnostics map[string][]DiagFingerprint `json:"diagnostics"` // file → fingerprints
}

Baseline stores fingerprinted diagnostics for comparison.

func LoadBaseline

func LoadBaseline() (*Baseline, error)

LoadBaseline reads a baseline file.

type BaselineComparison

type BaselineComparison struct {
	BaselineCount int
	CurrentCount  int
	NewCount      int
	FixedCount    int
	NewDiags      []fileDiagnostics // only new diagnostics
}

BaselineComparison holds the result of comparing current diagnostics against a baseline.

func CompareBaseline

func CompareBaseline(baseline *Baseline, current []fileDiagnostics) BaselineComparison

CompareBaseline compares current diagnostics against a saved baseline.

type BreakingChangeFile

type BreakingChangeFile struct {
	Path                 string `json:"path"`
	TotalChanges         int    `json:"totalChanges"`
	TotalBreakingChanges int    `json:"totalBreakingChanges"`
	SkipReason           string `json:"skipReason,omitempty"`
}

BreakingChangeFile summarizes semantic diff vs the CI base ref for one file.

type DiagFingerprint

type DiagFingerprint struct {
	RuleID string `json:"ruleId"`
	Line   uint32 `json:"line"`
	Hash   string `json:"hash"` // sha256 of message
}

DiagFingerprint uniquely identifies a diagnostic for baseline comparison.

type FileDetail

type FileDetail struct {
	Path     string `json:"path"`
	Count    int    `json:"count"`
	Errors   int    `json:"errors"`
	Warnings int    `json:"warnings"`
}

FileDetail provides per-file diagnostic breakdown for reports.

type GitHubClient

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

GitHubClient posts comments and reviews to GitHub PRs.

func NewGitHubClient

func NewGitHubClient() (*GitHubClient, error)

NewGitHubClient creates a client from environment variables.

func (*GitHubClient) CreateReview

func (c *GitHubClient) CreateReview(prNumber int, commitSHA, body string, comments []reviewComment) error

CreateReview posts a pull request review with inline comments.

func (*GitHubClient) DeleteComment

func (c *GitHubClient) DeleteComment(commentID int64) error

DeleteComment deletes an issue comment by ID.

func (*GitHubClient) ListComments

func (c *GitHubClient) ListComments(prNumber int) ([]ghComment, error)

ListComments retrieves comments on a PR, following pagination up to 5 pages.

func (*GitHubClient) ListPRFiles

func (c *GitHubClient) ListPRFiles(prNumber int) ([]prFile, error)

ListPRFiles retrieves files changed in a PR with pagination.

func (*GitHubClient) PostComment

func (c *GitHubClient) PostComment(prNumber int, body string) error

PostComment posts a comment on a PR.

func (*GitHubClient) UpdateComment

func (c *GitHubClient) UpdateComment(commentID int64, body string) error

UpdateComment updates an existing comment by ID.

func (*GitHubClient) UpsertComments

func (c *GitHubClient) UpsertComments(prNumber int, bodies []string) error

UpsertComments creates or updates Telescope comments on a PR. Each element of bodies is one chunk (e.g. from GeneratePRComment). Existing comments with the same marker index are updated; extra chunks are created; leftover comments (when chunks shrink) are deleted.

type LintReport

type LintReport struct {
	Workspace       string               `json:"workspace"`
	RepoRoot        string               `json:"repoRoot,omitempty"`
	GeneratedAt     string               `json:"generatedAt"`
	DiagnosticCount int                  `json:"diagnosticCount"`
	Files           []fileDiagnostics    `json:"files"`
	Counts          SeverityCounts       `json:"counts"`
	ByFile          map[string]int       `json:"byFile"`
	ByRule          map[string]int       `json:"byRule"`
	RuleDocs        map[string]string    `json:"ruleDocs,omitempty"`
	FileDetails     []FileDetail         `json:"fileDetails"`
	Scope           *ScopeMetadata       `json:"scope,omitempty"`
	BreakingChanges []BreakingChangeFile `json:"breakingChanges,omitempty"`
}

LintReport is the structured output written by --report-json.

type ScopeMetadata

type ScopeMetadata struct {
	Mode              string `json:"mode,omitempty"`
	ChangedFileCount  int    `json:"changedFileCount,omitempty"`
	ImpactedFileCount int    `json:"impactedFileCount,omitempty"`
	AnalyzedFileCount int    `json:"analyzedFileCount,omitempty"`
	FallbackReason    string `json:"fallbackReason,omitempty"`
}

ScopeMetadata describes how the CI run selected files for analysis.

type SeverityCounts

type SeverityCounts struct {
	Error   int `json:"error"`
	Warning int `json:"warning"`
	Info    int `json:"info"`
	Hint    int `json:"hint"`
}

SeverityCounts breaks down diagnostic counts by severity.

Jump to

Keyboard shortcuts

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