/** * Session briefing computation. * * Aggregates session-start context from multiple sources for quick agent * orientation. This is the READ side of the handoff/briefing pair. * * Data sources: * - Last session handoff (session.handoff) * - Current focus (tasks.current) * - Top-N next tasks (tasks.next leverage-scored) * - Open bugs (tasks with origin:bug-report or label:bug) * - Blocked tasks (tasks.blockers) * - Active epics status (tasks.tree filtered) * - Pipeline stage data (from T4912) * - Docs context (task-attached references, ADR registrations, llmtxt summaries) * * @task T4916 * @epic T4914 */ import type { BriefingFieldContract, ContractViolation, RetrievalBundle, SessionBriefingShowParams } from '@cleocode/contracts'; import type { SessionMemoryContext } from '../memory/session-memory.js'; import { type HandoffData } from './handoff.js'; /** * Task summary for briefing output. */ export interface BriefingTask { id: string; title: string; leverage: number; score: number; } /** * Bug summary for briefing output. */ export interface BriefingBug { id: string; title: string; priority: string; } /** * Blocked task summary for briefing output. */ export interface BriefingBlockedTask { id: string; title: string; blockedBy: string[]; } /** * Active epic summary for briefing output. */ export interface BriefingEpic { id: string; title: string; completionPercent: number; } /** * Urgent task summary for briefing output (T9905). * * One entry per task that matches the unified urgency predicate: * * `priority IN ('critical','high') OR severity IN ('P0','P1')` * * `priority` is always populated; `severity` is included only when the task * row sets it (null otherwise). Sorted by axis class (P0 wins over critical * wins over P1 wins over high) so the most-urgent row surfaces first. * * @task T9905 */ export interface BriefingUrgentTask { id: string; title: string; priority: string; severity?: string | null; } /** * Pipeline stage data for briefing output. */ export interface PipelineStageInfo { currentStage: string; stageStatus: string; } /** * A single document reference entry for briefing output. * * Represents one attachment associated with a task: a file path, URL, * blob, or generated llms.txt summary that is surfaced in the briefing * so new orchestrator runs have immediate access to rationale and references. */ export interface BriefingDocRef { /** ID of the task that owns this attachment. */ taskId: string; /** Attachment identifier (UUID-like string). */ attachmentId: string; /** Attachment kind (local-file, url, blob, llms-txt, llmtxt-doc). */ kind: string; /** Optional human-readable description of the attachment. */ description?: string; /** Optional labels for categorisation (e.g. ["adr", "spec"]). */ labels?: string[]; /** ISO 8601 creation timestamp. */ createdAt: string; /** * Human-readable kebab-case slug for this attachment (when set). * Only entries with a slug are surfaced in the default briefing diet; * entries without a slug are dropped as they cannot be fetched by name. * * @task T9964 */ slug?: string; /** * Document type classification (e.g. "adr", "spec", "handoff", "research"). * Set when the attachment was created with an explicit type annotation. * * @task T9964 */ type?: string; } /** * Docs context for briefing output — the third pillar (state + rationale + references). * * Contains task-attached document references for the active task and any * in-scope tasks that have attachments. Surfaced so `cleo briefing` IS the * complete knowledge surface: a new orchestrator run gets state (tasks), * rationale (brain memory), and references (docs) in a single call. */ export interface BriefingDocsContext { /** Document references for the currently focused task. */ currentTaskDocs: BriefingDocRef[]; /** Document references for in-scope tasks with at least one attachment. */ relatedDocs: BriefingDocRef[]; /** Total number of document references surfaced. */ totalDocs: number; } /** * Last session info with handoff data. */ export interface LastSessionInfo { endedAt: string; duration: number; handoff: HandoffData; } /** * Currently active task info. */ export interface CurrentTaskInfo { id: string; title: string; status: string; blockedBy?: string[]; } /** * Session briefing result. */ export interface SessionBriefing { lastSession: LastSessionInfo | null; currentTask: CurrentTaskInfo | null; nextTasks: BriefingTask[]; openBugs: BriefingBug[]; blockedTasks: BriefingBlockedTask[]; activeEpics: BriefingEpic[]; /** * Tasks matching the unified urgency predicate (T9905): * `priority IN ('critical','high') OR severity IN ('P0','P1')`. * * Always present (empty array when nothing is urgent). Surfaces both * urgency axes in one section so a fresh orchestrator session sees * urgent work without scanning openBugs + nextTasks separately. * * @task T9905 */ urgentTasks: BriefingUrgentTask[]; pipelineStage?: PipelineStageInfo; warnings?: string[]; /** Brain memory context -- decisions/patterns/observations relevant to this scope. */ memoryContext?: SessionMemoryContext; /** * PSYCHE Wave 4 multi-pass retrieval bundle. * * Contains cold (user profile), warm (peer memory), and hot (session state) * context assembled by `buildRetrievalBundle` from `brain-retrieval.ts`. * Present when the active session and peer ID are resolvable; omitted * (undefined) when retrieval fails or is disabled. * * Consumers may use `bundle` instead of — or in addition to — `memoryContext` * for richer structured context. The existing `memoryContext` field is preserved * for backward compatibility. * * @task T1091 * @epic T1083 */ bundle?: RetrievalBundle; /** * Docs context — the third briefing pillar (references). * * Surfaces task-attached document references (ADR registrations, llmtxt * summaries, URL refs, local files) so `cleo briefing` delivers the complete * knowledge surface in one call: state + rationale + references. * * Present when at least one in-scope task has an attachment; omitted * (undefined) when the attachment store is unavailable or no attachments exist. * * @task T1616 * @epic T1611 */ docsContext?: BriefingDocsContext; /** * Contract violations detected during briefing computation (T1905 / BBTT-W1-3). * * Present when a `BriefingFieldContract` is evaluated and at least one violation * is found. Consumers can inspect violations directly; `cleo briefing --strict` * exits non-zero when this array is non-empty. */ contractViolations?: ContractViolation[]; } /** * Options for computing session briefing. */ /** @deprecated Use SessionBriefingShowParams from @cleocode/contracts. */ export type BriefingOptions = SessionBriefingShowParams; /** * Compute the complete session briefing. * Normalized Core signature: (projectRoot, params) → Result. * Aggregates data from all 6+ sources. * @task T1450 */ export declare function computeBriefing(projectRoot: string, params?: SessionBriefingShowParams): Promise; /** * Evaluate a {@link BriefingFieldContract} against a computed briefing and * return an array of {@link ContractViolation} entries. * * Each named rule in `contract` is checked against the corresponding section * of `briefing`. Violations are emitted for: * - `stale` — any item whose `capturedAt` / `createdAt` timestamp is older * than `rule.maxAgeDays`. * - `duplicate` — two or more items share the same value for `rule.dedupBy`. * - `excluded-provenance` — any item whose `provenance` property matches a * tag in `rule.excludeProvenance`. * * Returns an empty array when the briefing satisfies all rules. * * @param briefing - The output of {@link computeBriefing}. * @param contract - Field-level constraint rules. * @returns Array of violations (empty = compliant). * * @task T1905 */ export declare function assertBriefingContract(briefing: SessionBriefing, contract: BriefingFieldContract): ContractViolation[]; //# sourceMappingURL=briefing.d.ts.map