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" // `anchor` is an opaque JSON blob (the content the comment was // anchored to at creation time) used internally to re-locate a // comment when the file changes. The skill must NOT parse it. ColAnchor = "anchor" // `anchor_status` is "ok" | "moved" | "outdated" (empty == "ok" for // legacy rows). A flat scalar the skill filters exactly like // `resolved`: treat `outdated` like `resolved=true` — the line // numbers no longer point at the intended content. ColAnchorStatus = "anchor_status" // `kind` classifies the comment shape: "line" (or empty for // pre-kind rows) for line-anchored comments where `from_line` and // `to_line` are meaningful; "file" for whole-file comments where // `from_line` / `to_line` / `side` / `anchor` / `anchor_status` // are all zero/empty; "area" for image-overlay annotations where // `area` (column 12) carries the rectangle. ColKind = "kind" // `area` is a JSON blob {"x":0.1,"y":0.2,"w":0.3,"h":0.15} where // each value is a 0..1 fraction of the image's natural dimensions. // Only populated when `kind` is "area"; empty for line / file // rows. Fractions (not pixels) so a re-encoded image at different // dimensions still highlights the same logical region. ColArea = "area" )
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, ColAnchor, ColAnchorStatus, ColKind, ColArea, }
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
// Anchor is an opaque JSON string (the main package owns its shape);
// the csv package stays free of main-package types. AnchorStatus is
// "ok" | "moved" | "outdated".
Anchor string
AnchorStatus string
// Kind is "line" (or "" for legacy/back-compat) for line-anchored
// comments, "file" for whole-file comments, and "area" for image-
// overlay annotations (geometry lives in Area).
Kind string
// Area is a JSON blob {"x":0.1,"y":0.2,"w":0.3,"h":0.15} (each
// value a 0..1 fraction of the image's natural dimensions) when
// Kind=="area"; "" otherwise. Treated as opaque on the CSV side —
// the main package owns the schema.
Area string
}
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.