/** * Core Chi Commons types. * * A "source" is one discoverable unit of historical context for the current * project: a raw Pi session or a reduced artifact. Artifacts remain ordinary * Pi v3 JSONL sessions with custom reduction-metadata entries; reducer * metadata is the source of truth for lineage and titles. * * z is the zoom/reduction level (python-style tree depth indexing, see * DESIGN.md): z >= 0 is leaf-relative (z=0 raw records, z=1 adjacent pairs), * z < 0 is root-relative (z=-1 the single root record). */ export type ZLevel = -1 | 0 | 1; /** Lineage carried by reduced artifacts; every field survives reload. */ export interface SourceLineage { sourceRepo?: string; sourceSessionIds: string[]; sourceEntryIds: string[]; reducerVersion?: string; promptVersion?: string; model?: string; /** Content hash / reduction key from the reducer or planner. */ contentHash?: string; } /** One discoverable Commons source for the current project. */ export interface CommonsSource { /** Session UUID from the JSONL header. */ id: string; /** Absolute path of the JSONL file. */ path: string; z: ZLevel; /** Source title: session name, reducer title, or pre-reduction first-request fallback. */ title: string; /** ISO timestamp of the most recent entry (recency ordering key). */ timestamp: string; /** Number of tree entries in the file (excluding the header). */ entryCount: number; /** * Rough token estimate (~4 chars/token) of the model-visible content: * text, thinking, and tool-call arguments — what replaying the session * costs in context, approximating the statusline count (minus system * prompt and tool schemas, which belong to the resuming runtime). */ approxTokens: number; /** Present for reduced (z != 0) artifacts. */ lineage?: SourceLineage; }