import type { NodeStatus } from './types.js'; export type HistorySource = 'report' | 'doc' | 'roadmap' | 'meta' | 'inbox'; /** One searchable unit of the episodic record: a report, a context doc, a * node's roadmap, or a node's meta (name/description/kind). */ export interface HistoryArtifact { /** Stable handle passed verbatim to `history read` — `:`. */ ref: string; nodeId: string; /** Path under the node dir (`reports/x.md`, `context/design.md`) or `meta`. */ relpath: string; source: HistorySource; /** final | update | urgent — reports only. */ reportKind?: string; /** ISO 8601 artifact timestamp. */ ts: string; /** Sort key: epoch ms of ts. */ tsMs: number; /** Report title / doc first heading / node name. */ title: string; nodeName: string; nodeKind: string; nodeStatus: NodeStatus; nodeCwd: string; nodeDesc: string; /** Absolute file path; null for the synthetic `meta` artifact. */ path: string | null; /** Frontmatter-stripped body, loaded once and cached. Empty on read error. */ loadBody: () => string; } export interface ScopeFilter { /** A specific cwd. Default (all flags absent) = the caller's cwd. */ cwd?: string; /** Every cwd on the canvas. */ allCwds?: boolean; /** A node and its subscription descendants (one initiative / sub-DAG). */ under?: string; /** Explicit node ids. */ nodes?: string[]; } export interface CorpusFilter { types?: HistorySource[]; /** Narrow reports to one report-kind (final | update). Implies type report. */ reportKind?: string; /** Node kinds (developer, spec, …). */ kinds?: string[]; /** Node lifecycle statuses. */ statuses?: NodeStatus[]; /** Inclusive lower / upper bound on artifact ts, epoch ms. */ sinceMs?: number; untilMs?: number; } /** The cwd the caller means by default: the calling node's cwd (resolved from * CRTR_NODE_ID via the canvas data layer), falling back to the process cwd * when not run as a node. */ export declare function callerCwd(): string; /** Build the searchable artifact set for a scope + corpus filter. Node facets * are applied against the db rows first (cheap); only surviving nodes' files * are read. */ export declare function buildCorpus(scope: ScopeFilter, corpus: CorpusFilter): HistoryArtifact[]; export interface ResolvedRef { nodeId: string; relpath: string; source: HistorySource; reportKind?: string; ts: string; nodeName: string; /** Frontmatter-stripped body. */ body: string; /** Raw file content (frontmatter included); null for meta. */ raw: string | null; path: string | null; } /** Resolve a `:` handle to its content. Returns null when the * node is unknown or the artifact does not exist. Throws on path traversal. */ export declare function resolveRef(ref: string): ResolvedRef | null; /** Enumerate one node's artifacts (for `history show`). */ export declare function nodeArtifacts(nodeId: string, types?: HistorySource[]): HistoryArtifact[]; export interface CorpusStats { cwd: string; nodes: number; reports: number; docs: number; /** ISO date min → max across all artifacts, or null when empty. */ span: { from: string; to: string; } | null; } /** Bounded per-cwd aggregate for the branch `-h` `` block. Counts files * on disk without reading bodies. */ export declare function corpusStats(cwd: string): CorpusStats;