Documentation
¶
Overview ¶
Package csv writes comment rows to a CSV file that the launching Claude skill consumes. RFC-4180 quoting via encoding/csv handles multi-line bodies and embedded commas/quotes correctly without ad-hoc escaping.
Index ¶
Constants ¶
const ( ColID = "id" ColFile = "file" ColFromLine = "from_line" ColToLine = "to_line" ColSide = "side" ColBody = "body" ColCreatedAt = "created_at" // `resolved` is "true" or "false". The skill should act only on // unresolved comments; resolved ones are kept as historical record. ColResolved = "resolved" )
Column names — load-bearing. The skill's reference docs and any LLM-side parser depend on these exact strings. Reordering breaks the contract.
Variables ¶
var Header = []string{ ColID, ColFile, ColFromLine, ColToLine, ColSide, ColBody, ColCreatedAt, ColResolved, }
Header is the row written before any data. Position-stable.
Functions ¶
This section is empty.
Types ¶
type Row ¶
type Row struct {
ID string
File string
FromLine int
ToLine int
Side string
Body string
CreatedAt time.Time
Resolved bool
}
Row is one comment serialized to the CSV. The csv package stays free of prereview's main-package types so the schema layer stays independent and reusable (and avoids an import cycle with the main package).
func Read ¶
Read parses every Row from a CSV written by Writer. Returns an empty slice (and nil error) if the file doesn't exist — that's the "fresh session" case, indistinguishable from "session with zero comments". Skips the header row and any malformed rows (logging would be a caller concern; here we stay quiet to keep the CSV-as-truth contract simple).
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer serializes Rows to a CSV file atomically. Each Write replaces the entire file (write-tmp → fsync → rename → fsync parent dir), so the file on disk is either the pre-write state or the post-write state — never half-written, even if the process is killed mid-call.
All operations are serialized by an internal mutex; multiple WebSocket sessions for the same prereview process can call Write concurrently without corruption.
func NewWriter ¶
NewWriter returns a Writer targeting path. The file is not created until the first Write call.