Expand description
OpenCode lifecycle telemetry reader.
OpenCode persists session state in a sqlite database and a
opencode.json config file. Lifeloop keeps the dependency surface
conservative: we expose a pure-data parser
(build_observation) that callers feed pre-extracted session
metrics into, plus a config-file parser
(read_context_window_from_config). Callers who want the full
sqlite probe can implement it themselves and use these functions to
produce the neutral observation.
The JSONC config form CCD’s reader supported is not handled here —
standard serde_json parses plain JSON, and JSONC support can be
added as a non-breaking extension if needed.
Structs§
- Session
Metrics - Pre-extracted session metrics fed in by the caller (typically read from the OpenCode sqlite database).
Functions§
- build_
observation - Compose a neutral
PressureObservationfrom pre-extracted OpenCode session metrics. - data_
dir_ hint - Resolve the OpenCode data dir (defaults to
$HOME/.local/share/opencode). - database_
path_ hint - Resolve the path the caller would point its sqlite probe at, if any.
Lifeloop does not shell out to
sqlite3; this helper exists so callers can apply the same env-alias resolution Lifeloop does. - read_
context_ window_ from_ config - Parse a plain-JSON OpenCode config and return the configured context
window if present (
limit.context). JSONC inputs are not supported. - read_
model_ name_ from_ config - Parse a plain-JSON OpenCode config and return the first model name
declared under any
modelsobject. - resolve_
context_ window - Resolve the context window using OpenCode-aware precedence: adapter env alias → config files → general env fallback.
- resolve_
model_ name - Resolve the model name using OpenCode-aware precedence: config files → adapter env alias → general env fallback.