Skip to main content

Module opencode

Module opencode 

Source
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§

SessionMetrics
Pre-extracted session metrics fed in by the caller (typically read from the OpenCode sqlite database).

Functions§

build_observation
Compose a neutral PressureObservation from 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 models object.
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.