Expand description
Shared data-access context threaded through every segment’s
render call.
DataContext owns the eagerly-parsed stdin payload
(StatusContext at ctx.status) plus
lazy OnceCell accessors for every other
source (settings, ~/.claude.json, JSONL transcripts, OAuth usage,
credentials, live sessions, git).
This module ships the v0.1 skeleton: the struct shape, the accessor
surface, and stub NotImplemented
errors. Real source implementations arrive with their owning epics
(lsm-y6m for usage, lsm-8jl for git, etc.). Plugin scripts see a
uniform { kind: "error", error: "NotImplemented" } shape until
those land.
Canonical definition: docs/specs/data-fetching.md §DataContext.
Re-exports§
pub use credentials::CredentialSource;pub use credentials::Credentials;pub use deps::DataDep;pub use error::ClaudeJsonError;pub use error::CredentialError;pub use error::GitError;pub use error::JsonlError;pub use error::SessionError;pub use error::SettingsError;pub use error::UsageError;pub use git::DirtyCounts;pub use git::DirtyState;pub use git::GitContext;pub use git::Head;pub use git::RepoKind;pub use git::UpstreamState;pub use jsonl::FiveHourBlock;pub use jsonl::JsonlAggregate;pub use jsonl::TokenCounts;pub use usage::EndpointUsage;pub use usage::ExtraUsage;pub use usage::FiveHourWindow;pub use usage::JsonlUsage;pub use usage::SevenDayWindow;pub use usage::UsageApiResponse;pub use usage::UsageBucket;pub use usage::UsageData;
Modules§
- cache
- Disk-backed OAuth usage cache + lock file.
- cascade
- OAuth usage fallback cascade.
- credentials
- OAuth credential resolution for the OAuth
/api/oauth/usageendpoint. Reads the access token from macOS Keychain (primary + multi-account fallback) or from a file cascade ($CLAUDE_CONFIG_DIR, XDG,~/.claude/). - deps
DataDepenumerates the data sources a segment may declare viaSegment::data_deps.- error
- Error types for lazy
DataContextsources. - fetcher
- OAuth
/api/oauth/usageHTTP client. - git
- Git repository inspection state via
gix. - jsonl
- JSONL transcript aggregator — terminal fallback for the rate-limit data pipeline.
- usage
- OAuth
/api/oauth/usageresponse + internal usage-data types. - xdg
- Single source of truth for the linesmith XDG cascade.
Structs§
- Claude
Json - Parsed
~/.claude.jsonper-user state. Stub. - Data
Context - Bundle of every source a segment may read during a single render
invocation.
statusis populated eagerly from the stdin payload; all other sources lazy-init on first access and cache theirResult(including errors) for the lifetime of this context. - Live
Sessions - Snapshot of
~/.claude/sessions/{pid}.jsonentries. Stub. - Settings
- Parsed
~/.claude/settings.json+ overlays. Stub.