UNPKG

@phren/cli

Version:

Knowledge layer for AI agents - CLI, MCP server, and data layer

87 lines (86 loc) • 3.77 kB
import { type PhrenErrorCode } from "../phren-core.js"; import { type FindingTier } from "./locate.js"; interface FindingDecayConfig { maxAgeDays: number; decayMultiplier: number; } /** * Decay rule per finding tag. Keyed with `satisfies Record<FindingTag, ...>` * so this object is required to have exactly one row per tag in FINDING_TAGS * (phren-core.ts) — no more, no less. Add a tag there and TypeScript forces a * decay row here; remove one and the corresponding row becomes a compile * error instead of silently-dead data. * * Previously this table had 9 rows against a 6-entry offered enum that * disagreed with it in both directions: `anti-pattern`, `observation`, and * `tooling` had rows here but nothing ever wrote those tags, while * `tradeoff` and `architecture` were offered/writable but had no row here * (so they never decayed and had no max-age). The exported type stays * `Record<string, FindingDecayConfig>` so existing string-keyed lookups * (e.g. content/citation.ts) don't need to change. */ export declare const FINDING_TYPE_DECAY: Record<string, FindingDecayConfig>; export declare function extractFindingType(line: string): string | null; export declare const FINDING_LIFECYCLE_STATUSES: readonly ["active", "superseded", "contradicted", "stale", "invalid_citation", "retracted"]; export type FindingLifecycleStatus = typeof FINDING_LIFECYCLE_STATUSES[number]; export interface FindingLifecycleMetadata { status: FindingLifecycleStatus; status_updated?: string; status_reason?: string; status_ref?: string; } export declare function parseFindingLifecycle(line: string): FindingLifecycleMetadata; export declare function buildLifecycleComments(lifecycle: Partial<FindingLifecycleMetadata> | undefined, fallbackDate?: string): string; export declare function stripLifecycleComments(line: string): string; export declare function isInactiveFindingLine(line: string): boolean; export type ContradictionResolution = "keep_a" | "keep_b" | "keep_both" | "retract_both"; /** One of several findings an archive lookup matched; the caller picks one by fid. */ export interface LifecycleCandidate { tier: FindingTier; file: string; /** 1-based line in the file. */ line: number; fid?: string; text: string; } /** A PhrenResult whose ambiguous archive lookups also list the candidates. */ export type LifecycleResult<T> = { ok: true; data: T; } | { ok: false; error: string; code?: PhrenErrorCode; candidates?: LifecycleCandidate[]; }; export declare function supersedeFinding(phrenPath: string, project: string, findingText: string, supersededBy: string, expectedFindings?: Record<string, string>): LifecycleResult<{ finding: string; superseded_by: string; status: FindingLifecycleStatus; tier: FindingTier; file: string; }>; export declare function retractFinding(phrenPath: string, project: string, findingText: string, reason: string, expectedFindings?: Record<string, string>): LifecycleResult<{ finding: string; reason: string; status: FindingLifecycleStatus; tier: FindingTier; file: string; }>; /** " (archived in reference/topics/<file>)" for a finding outside FINDINGS.md, for messages. */ export declare function archiveNote({ tier, file }: { tier: FindingTier; file: string; }): string; type ResolvedFinding = { text: string; status: FindingLifecycleStatus; tier: FindingTier; file: string; }; export declare function resolveFindingContradiction(phrenPath: string, project: string, findingA: string, findingB: string, resolution: ContradictionResolution): LifecycleResult<{ resolution: ContradictionResolution; finding_a: ResolvedFinding; finding_b: ResolvedFinding; }>; export {};