Documentation
¶
Overview ¶
Package reader holds the reader feature's filesystem scope and confinement rules — which paths a session's reader may list and serve — independent of HTTP handling (kb:spec/reader). Pure filesystem logic, like internal/locate: it imports nothing from internal/server, internal/session or internal/claudecode. Features: reader.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListMarkdown ¶
func ListMarkdown(ctx context.Context, dir string, gitFiles ListFilesFunc) (paths []string, listing string, truncated bool, gitErr error)
ListMarkdown lists every `.md` (case-insensitive) file under dir: gitFiles's (typically gitutil.ListFiles) `git ls-files -co --exclude-standard` listing when dir is a git checkout, filtered to `.md`, or a bounded dot-directory-skipping walk otherwise (kb:spec/reader). A git failure (not a checkout, or a real error) is not itself fatal — ListMarkdown falls back to the walk and returns the git error as gitErr solely so the caller can log it; the walk's own result is never an error.
Types ¶
type ListFilesFunc ¶
ListFilesFunc lists the files git sees under dir — ListMarkdown's consumer-side seam over gitutil.ListFiles (docs/conventions.md § Testing): production is gitutil.ListFiles, callers fake a neutral file list at this seam rather than git's own byte stream, since git's argv is gitutil's concern, not this package's.
type Scope ¶
Scope is one session's reader domain: the directory whose markdown may be listed and served, and the plan path served alongside it even though it usually sits outside Dir (kb:spec/reader). An empty PlanPath means no plan is bound yet.
func (Scope) Confine ¶
Confine reports whether requested may be served from this scope, and its symlink-resolved form when so (kb:spec/reader's confinement rule): after filepath.EvalSymlinks of both s.Dir and requested, requested must sit under s.Dir and end in `.md` (case-insensitive), or equal the resolved s.PlanPath. Existence/directory- ness beyond symlink resolution is the caller's job (a Stat after Confine, distinguishing 404 from 413).
func (Scope) PathQualifies ¶
PathQualifies is the change-signal's scope test (kb:adr/reader-change-signal-is-the-write-hook): after filepath.Clean, path sits lexically under s.Dir and ends in `.md` (case-insensitive), or equals s.PlanPath — no symlink resolution (that confinement belongs to serving, in Confine, not to the change signal).
type WriteLog ¶
type WriteLog struct {
// contains filtered or unexported fields
}
WriteLog is the daemon's in-memory record of routed writes, per session — forgotten on daemon restart, like shells: nothing here is written to disk. Record is called from internal/server's single ingest worker; Get and Forget are called from HTTP handlers and session removal. mu guards bySession against that concurrent access.