import { AcceptanceCriterion } from '@kjerneverk/riotplan-verify'; import { Blocker } from '@kjerneverk/riotplan-core'; import { checkCompletion } from '@kjerneverk/riotplan-verify'; import { checkCoverage } from '@kjerneverk/riotplan-verify'; import { CompletionReport } from '@kjerneverk/riotplan-verify'; import { ContextId } from '@kjerneverk/riotplan-core'; import { CoverageOptions } from '@kjerneverk/riotplan-verify'; import { CoverageReport } from '@kjerneverk/riotplan-verify'; import { CRITERIA_PATTERNS } from '@kjerneverk/riotplan-verify'; import { CriteriaPriority } from '@kjerneverk/riotplan-verify'; import { CriteriaStatus } from '@kjerneverk/riotplan-verify'; import { CriterionResult } from '@kjerneverk/riotplan-verify'; import { EvidenceEntry } from '@kjerneverk/riotplan-core/artifacts'; import { EvidenceRecord } from '@kjerneverk/riotplan-core'; import { EvidenceType } from '@kjerneverk/riotplan-core'; import { ExecutionPlanDocument } from '@kjerneverk/riotplan-core'; import { FeedbackContext } from '@kjerneverk/riotplan-core'; import { FeedbackParticipant } from '@kjerneverk/riotplan-core'; import { FeedbackPlatform } from '@kjerneverk/riotplan-core'; import { FeedbackRecord } from '@kjerneverk/riotplan-core'; import { getCriteriaSummary } from '@kjerneverk/riotplan-verify'; import { HEALTH_THRESHOLDS } from '@kjerneverk/riotplan-verify'; import { HtmlRenderOptions } from '@kjerneverk/riotplan-render'; import { Issue } from '@kjerneverk/riotplan-core'; import { JsonRenderOptions } from '@kjerneverk/riotplan-render'; import { MarkdownRenderOptions } from '@kjerneverk/riotplan-render'; import { MergedCatalyst } from '@kjerneverk/riotplan-catalyst'; import { parseCriteria } from '@kjerneverk/riotplan-verify'; import { parseCriteriaFromContent } from '@kjerneverk/riotplan-verify'; import { ParsedCriteria } from '@kjerneverk/riotplan-verify'; import { Plan } from '@kjerneverk/riotplan-core'; import { PLAN_CONVENTIONS } from '@kjerneverk/riotplan-core'; import { PlanContext } from '@kjerneverk/riotplan-core'; import { PlanContextDefinition } from '@kjerneverk/riotplan-core'; import { PlanDoc } from '@kjerneverk/riotplan-core/artifacts'; import { PlanFiles } from '@kjerneverk/riotplan-core'; import { PlanHistory } from '@kjerneverk/riotplan-core'; import { PlanMetadata } from '@kjerneverk/riotplan-core'; import { PlanMilestone } from '@kjerneverk/riotplan-core'; import { PlanPhase } from '@kjerneverk/riotplan-core'; import { PlanRelationship } from '@kjerneverk/riotplan-core'; import { PlanResult } from '@kjerneverk/riotplan-core'; import { PlanRevision } from '@kjerneverk/riotplan-core'; import { PlanState } from '@kjerneverk/riotplan-core'; import { PlanStep } from '@kjerneverk/riotplan-core'; import { Priority } from '@kjerneverk/riotplan-core'; import { PRIORITY_WEIGHTS } from '@kjerneverk/riotplan-verify'; import { readEvidenceRecords } from '@kjerneverk/riotplan-core/artifacts'; import { readIdeaDoc } from '@kjerneverk/riotplan-core/artifacts'; import { readPlanDoc } from '@kjerneverk/riotplan-core/artifacts'; import { readPlanIdentity } from '@kjerneverk/riotplan-core/artifacts'; import { readShapingDoc } from '@kjerneverk/riotplan-core/artifacts'; import { readStatusDoc } from '@kjerneverk/riotplan-core/artifacts'; import { readTimelineEvents } from '@kjerneverk/riotplan-core/artifacts'; import { RelationshipType } from '@kjerneverk/riotplan-core'; import { RenderFormat } from '@kjerneverk/riotplan-render'; import { RenderOptions } from '@kjerneverk/riotplan-render'; import { renderPlan } from '@kjerneverk/riotplan-render'; import { RenderResult } from '@kjerneverk/riotplan-render'; import { renderToHtml } from '@kjerneverk/riotplan-render'; import { renderToJson } from '@kjerneverk/riotplan-render'; import { renderToMarkdown } from '@kjerneverk/riotplan-render'; import { saveIdeaDoc } from '@kjerneverk/riotplan-core/artifacts'; import { savePlanDoc } from '@kjerneverk/riotplan-core/artifacts'; import { saveShapingDoc } from '@kjerneverk/riotplan-core/artifacts'; import { saveStatusDoc } from '@kjerneverk/riotplan-core/artifacts'; import { StatusDocument } from '@kjerneverk/riotplan-core'; import { StepCompletionResult } from '@kjerneverk/riotplan-verify'; import { StepCompletionStatus } from '@kjerneverk/riotplan-verify'; import { StepResult } from '@kjerneverk/riotplan-core'; import { TaskStatus } from '@kjerneverk/riotplan-core'; import { TimelineEventEntry } from '@kjerneverk/riotplan-core/artifacts'; import { VerificationCriterion } from '@kjerneverk/riotplan-verify'; import { VerificationReport } from '@kjerneverk/riotplan-verify'; import { z } from 'zod'; export { AcceptanceCriterion } /** * Add a relationship to a plan * * @param plan - The source plan * @param options - Relationship options * @returns Result with the created relationship */ export declare function addRelationship(plan: Plan, options: AddRelationshipOptions): Promise; /** * Options for adding a relationship */ export declare interface AddRelationshipOptions { /** Type of relationship */ type: RelationshipType; /** Path to the related plan (absolute or relative to current plan) */ targetPath: string; /** Specific steps involved in the relationship */ steps?: number[]; /** Reason/description for the relationship */ reason?: string; } /** * Result of adding a relationship */ export declare interface AddRelationshipResult { /** The created relationship */ relationship: PlanRelationship; /** Whether the target plan was found and valid */ targetValid: boolean; /** Target plan metadata if found */ targetPlan?: { code: string; name: string; path: string; }; } export declare interface Analysis { /** Path to analysis directory */ path: string; /** Requirements document content */ requirements: string; /** Philosophy/approach document (optional) */ philosophy?: string; /** All elaboration prompts */ elaborations: ElaborationRecord[]; /** Analysis metadata */ metadata: AnalysisMetadata; } export declare interface AnalysisMetadata { createdAt: Date; updatedAt: Date; elaborationCount: number; status: "draft" | "ready" | "converted"; } export { Blocker } export declare function blockStep(plan: Plan, stepNumber: number, reason: string): PlanStep; /** * Build a dependency graph from a plan * * @param plan - The plan to analyze * @returns Dependency graph */ export declare function buildDependencyGraph(plan: Plan): Promise; /** * Build a dependency graph from a pre-parsed dependency map * * @param plan - The plan * @param rawDeps - Map of step number to dependencies * @returns Dependency graph */ export declare function buildDependencyGraphFromMap(plan: Plan, rawDeps: Map): DependencyGraph; export { checkCompletion } /** * Run CardiganTime's built-in configuration diagnostics output. * * This prints source-tracked configuration details directly via CardiganTime. */ export declare function checkConfigWithCardiganTime(args?: Record): Promise; export { checkCoverage } /** * Clear the catalyst cache * * Useful for testing or when configuration might have changed. */ export declare function clearCatalystCache(): void; /** * Clear the configuration cache * * Useful for testing or when configuration might have changed. */ export declare function clearConfigCache(): void; /** * Clear the resolver cache * * Useful for testing or when configuration or filesystem structure might have changed. * This forces the resolver to re-run the four-tier resolution on the next call. */ export declare function clearResolverCache(): void; /** * Clear the walk-up cache * * Useful for testing or when the filesystem structure might have changed. * This allows the walk-up function to re-scan directories on the next call. */ export declare function clearWalkUpCache(): void; /** * Compare two revisions */ export declare function compareRevisions(history: PlanHistory, fromVersion: string, toVersion: string): RevisionComparison | undefined; export declare function completeStep(plan: Plan, stepNumber: number, options?: CompleteStepOptions): Promise; declare interface CompleteStepOptions { notes?: string; force?: boolean; skipVerification?: boolean; } export { CompletionReport } /** * Compute execution order that respects dependencies * * Returns both a linear order and parallel execution levels. * * @param plan - The plan to analyze * @param graph - Optional pre-built dependency graph * @returns Execution order information */ export declare function computeExecutionOrder(plan: Plan, graph?: DependencyGraph): Promise; export { ContextId } export { CoverageOptions } export { CoverageReport } /** * Create analysis entries in a .plan SQLite file */ export declare function createAnalysisDirectory(options: CreateAnalysisOptions): Promise; export declare interface CreateAnalysisOptions { planPath: string; planName: string; initialPrompt: string; } /** * Create a bidirectional relationship between two plans * * @param sourcePlan - The source plan * @param targetPlan - The target plan * @param type - Relationship type from source's perspective * @param reason - Optional reason */ export declare function createBidirectionalRelationship(sourcePlan: Plan, targetPlan: Plan, type: RelationshipType, reason?: string): void; /** * Create a new milestone */ export declare function createMilestone(history: PlanHistory, name: string, description?: string): PlanMilestone; /** * Create a new plan from configuration * * @param config - Plan creation configuration * @returns Result with plan path on success */ export declare function createPlan(config: CreatePlanConfig): Promise; /** * Plan Creator Module * * High-level API for creating new plans. */ export declare interface CreatePlanConfig { /** Plan code (directory name) */ code: string; /** Plan display name */ name: string; /** Plan description (optional) */ description?: string; /** Base path for plans (default: current directory) */ basePath?: string; /** Steps for the plan */ steps: Array<{ title: string; description?: string; }>; /** Tags for the plan */ tags?: string[]; } declare interface CreatePlanResult { success: boolean; path?: string; error?: string; } /** * Create a new empty registry */ export declare function createRegistry(searchPaths?: string[]): PlanRegistry; /** * Create and save a RETROSPECTIVE.md file */ export declare function createRetrospective(plan: Plan, options?: GenerateRetrospectiveOptions): Promise; /** * Create a new revision */ export declare function createRevision(history: PlanHistory, message: string, options?: { author?: string; feedbackId?: string; }): PlanRevision; export { CRITERIA_PATTERNS } export { CriteriaPriority } export { CriteriaStatus } export { CriterionResult } /** * Critical path analysis result */ export declare interface CriticalPath { /** Steps in the critical path (in order) */ path: number[]; /** Total length of the critical path */ length: number; /** Estimated duration (if steps have duration estimates) */ estimatedDuration?: number; } /** * A dependency error */ export declare interface DependencyError { /** Error type */ type: "circular" | "missing" | "self-reference" | "invalid-step" | "duplicate"; /** Affected step */ stepNumber: number; /** Related steps */ relatedSteps?: number[]; /** Error message */ message: string; } /** * A dependency graph for the entire plan */ export declare interface DependencyGraph { /** Map of step number to its dependencies */ dependencies: Map; /** Steps with no dependencies (can start immediately) */ roots: number[]; /** Steps with no dependents (end points) */ leaves: number[]; /** Whether the graph has circular dependencies */ hasCircular: boolean; /** Circular dependency chains if any */ circularChains: number[][]; } /** * Result of dependency validation */ export declare interface DependencyValidation { /** Whether all dependencies are valid */ valid: boolean; /** Errors found */ errors: DependencyError[]; /** Warnings found */ warnings: DependencyWarning[]; } /** * A dependency warning */ export declare interface DependencyWarning { /** Warning type */ type: "long-chain" | "bottleneck" | "orphan"; /** Affected step */ stepNumber: number; /** Warning message */ message: string; } export declare interface ElaborationRecord { id: string; timestamp: Date; content: string; } export { EvidenceEntry } export { EvidenceRecord } export { EvidenceType } /** * Execution order for steps */ export declare interface ExecutionOrder { /** Steps in execution order (respects dependencies) */ order: number[]; /** Steps grouped by parallel execution level */ levels: number[][]; } export { ExecutionPlanDocument } export declare function failStep(plan: Plan, stepNumber: number, reason?: string): PlanStep; export { FeedbackContext } export { FeedbackParticipant } export { FeedbackPlatform } export { FeedbackRecord } /** * Find the critical path through the plan * * The critical path is the longest sequence of dependent steps * that determines the minimum time to complete the plan. * * @param plan - The plan to analyze * @param graph - Optional pre-built dependency graph * @returns Critical path information */ export declare function findCriticalPath(plan: Plan, graph?: DependencyGraph): Promise; /** * Walk-Up Detection for Plan Directory * * This module implements tier 3 of the plan directory resolution strategy: * walking up the directory tree to find an existing `plans/` subdirectory. * * This provides zero-config experience - users can run riotplan from any * subdirectory and it will automatically find the plans/ directory in their * project root. * * Algorithm: * 1. Start from the given path (typically process.cwd()) * 2. Walk up the directory tree * 3. At each level, check if a `plans/` subdirectory exists * 4. Return the first match found (parent directory containing plans/) * 5. Stop at filesystem root if no match found * * Example: * Running from `/Users/tobrien/gitw/kjerneverk/riotplan/src/analysis` * will find `/Users/tobrien/gitw/kjerneverk/plans` and return * `/Users/tobrien/gitw/kjerneverk` (the parent directory). */ /** * Find the first directory containing a `plans/` subdirectory by walking up * the directory tree from the given starting path. * * This function implements tier 3 of the plan directory resolution strategy. * It walks up from the starting path, checking each level for a `plans/` * subdirectory, and returns the parent directory of the first match found. * * @param startPath - The path to start walking up from (typically process.cwd()) * @returns The parent directory containing `plans/`, or `null` if not found * * @example * ```typescript * // Running from /Users/me/project/src/utils * const plansDir = findPlansDirectory(process.cwd()); * // If /Users/me/project/plans exists, returns '/Users/me/project' * // If not found, returns null * ``` */ export declare function findPlansDirectory(startPath: string): string | null; /** * Generate markdown for a plan's relationships section * * @param plan - The plan with relationships * @returns Markdown string for ## Related Plans section */ export declare function generateRelationshipsMarkdown(plan: Plan): string; /** * Generate retrospective data from a plan */ export declare function generateRetrospective(plan: Plan, options?: GenerateRetrospectiveOptions): Retrospective; /** * Generate RETROSPECTIVE.md content */ export declare function generateRetrospectiveMarkdown(retro: Retrospective): string; /** * Options for generating a retrospective */ export declare interface GenerateRetrospectiveOptions { /** Custom "what went well" entries */ whatWentWell?: string[]; /** Custom "what could improve" entries */ whatCouldImprove?: string[]; /** Custom key learnings */ keyLearnings?: string[]; /** Custom action items */ actionItems?: string[]; /** Author */ author?: string; } /** * Generate a complete STATUS.md document from a plan */ export declare function generateStatus(plan: Plan, options?: GenerateStatusOptions): Promise; export declare interface GenerateStatusOptions { /** Preserve existing notes section */ preserveNotes?: boolean; /** Existing STATUS.md content (for preservation) */ existingContent?: string; /** Include phase progress if phases defined */ includePhases?: boolean; /** Date format for timestamps */ dateFormat?: "iso" | "short" | "long"; } /** * Find all plans that this plan blocks * * @param plan - The plan to check * @returns Paths to blocked plans */ export declare function getBlockedPlans(plan: Plan): string[]; /** * Get steps that are blocked by a specific step * * @param plan - The plan * @param stepNumber - The blocking step * @param graph - Optional pre-built dependency graph * @returns Steps blocked by this step */ export declare function getBlockedSteps(plan: Plan, stepNumber: number, graph?: DependencyGraph): Promise; /** * Find all plans that block this plan * * @param plan - The plan to check * @returns Paths to blocking plans */ export declare function getBlockingPlans(plan: Plan): string[]; /** * Check if environment variables override catalyst configuration * * Supports: * - RIOTPLAN_CATALYSTS: comma-separated list of catalyst identifiers * - RIOTPLAN_CATALYST_DIRECTORY: directory containing local catalysts * * @returns Partial config with environment variable overrides, or null if no overrides */ export declare function getCatalystEnvOverrides(): Partial | null; /** * Find all child plans (plans spawned from this one) * * @param plan - The plan to check * @returns Paths to child plans */ export declare function getChildPlans(plan: Plan): string[]; export { getCriteriaSummary } /** * Get the default registry path */ export declare function getDefaultRegistryPath(): string; /** * Get the dependency chain for a step (all transitive dependencies) * * @param plan - The plan * @param stepNumber - The step to analyze * @param graph - Optional pre-built dependency graph * @returns All steps that must be completed before this step */ export declare function getDependencyChain(plan: Plan, stepNumber: number, graph?: DependencyGraph): Promise; /** * Get the inverse relationship type */ export declare function getInverseRelationType(type: RelationshipType): RelationshipType; /** * Get the latest milestone */ export declare function getLatestMilestone(history: PlanHistory): MilestoneInfo | undefined; /** * Get the latest revision */ export declare function getLatestRevision(history: PlanHistory): RevisionInfo | undefined; /** * Get a milestone by name */ export declare function getMilestone(history: PlanHistory, name: string): MilestoneInfo | undefined; /** * Find the parent plan (if this plan was spawned from another) * * @param plan - The plan to check * @returns Path to parent plan or null */ export declare function getParentPlan(plan: Plan): string | null; /** * Get a plan by code */ export declare function getPlanByCode(registry: PlanRegistry, code: string): RegisteredPlan | null; /** * Get a plan by path */ export declare function getPlanByPath(registry: PlanRegistry, path: string): RegisteredPlan | null; export declare function getPlanCategory(planFilePath: string): PlanCategory; /** * Get all plans with a specific status */ export declare function getPlansByStatus(registry: PlanRegistry, status: TaskStatus): RegisteredPlan[]; /** * Get steps that can be started now (all dependencies completed) * * @param plan - The plan * @param graph - Optional pre-built dependency graph * @returns Steps ready to start */ export declare function getReadySteps(plan: Plan, graph?: DependencyGraph): Promise; /** * Get statistics about the registry */ export declare function getRegistryStats(registry: PlanRegistry): RegistryStats; /** * Find all related plans (general relationships) * * @param plan - The plan to check * @returns Paths to related plans */ export declare function getRelatedPlans(plan: Plan): string[]; /** * Get all relationships of a specific type * * @param plan - The plan to query * @param type - Relationship type to filter by * @returns Matching relationships */ export declare function getRelationshipsByType(plan: Plan, type: RelationshipType): PlanRelationship[]; /** * Get a specific revision by version */ export declare function getRevision(history: PlanHistory, version: string): RevisionInfo | undefined; /** * Check if a plan has an analysis */ export declare function hasAnalysis(planPath: string): Promise; export { HEALTH_THRESHOLDS } export declare interface HistoryManager { history: PlanHistory; path: string; save(): Promise; reload(): Promise; } export { HtmlRenderOptions } export declare function initHistory(initialVersion?: string): PlanHistory; export declare function insertStep(plan: Plan, options: InsertStepOptions): Promise; export declare interface InsertStepOptions { title: string; description?: string; position?: number; after?: number; status?: TaskStatus; } export declare interface InsertStepResult { step: PlanStep; renamedFiles: Array<{ from: string; to: string; }>; createdFile: string; } /** * An invalid relationship */ export declare interface InvalidRelationship { relationship: PlanRelationship; reason: string; } export { Issue } export { JsonRenderOptions } /** * List all milestones */ export declare function listMilestones(history: PlanHistory): MilestoneInfo[]; /** * List all revisions */ export declare function listRevisions(history: PlanHistory): RevisionInfo[]; /** * Load an analysis from a .plan SQLite file */ export declare function loadAnalysis(planPath: string): Promise; /** * Load and validate RiotPlan configuration * * Uses CardiganTime to: * 1. Check environment variables (RIOTPLAN_PLAN_DIRECTORY, etc.) * 2. Search for config files (riotplan.config.*, .riotplan/config.*, etc.) * 3. Walk up directory tree (hierarchical discovery) * 4. Validate against Zod schema * 5. Apply defaults * * @returns Validated configuration, or null if no config found and defaults applied * @throws Error if config file exists but is invalid */ export declare function loadConfig(): Promise; /** * Load and merge catalysts declared in the configuration * * This function: * 1. Resolves catalyst identifiers to absolute paths * 2. Loads each catalyst using @kjerneverk/riotplan-catalyst * 3. Merges catalysts in the order specified * 4. Caches the result to avoid re-reading * * @param config - RiotPlan configuration * @param configFileDir - Directory containing the config file (for path resolution) * @returns Merged catalyst, or null if no catalysts configured * @throws Error if any catalyst fails to load or is invalid */ export declare function loadConfiguredCatalysts(config: RiotPlanConfig | null, configFileDir?: string): Promise; export declare function loadHistory(planPath: string): Promise; /** * Load multiple retrospectives and combine them * * @param references - Array of {path, reason} objects * @returns Combined wrapped content */ export declare function loadMultipleRetrospectives(references: Array<{ path: string; reason: string; }>): Promise; /** * Load a plan from a .plan SQLite file * * @param path - Path to the .plan file * @param options - Loading options * @returns The loaded plan */ export declare function loadPlan(path: string, options?: LoadPlanOptions): Promise; /** * Options for loading a plan */ export declare interface LoadPlanOptions { /** Parse STATUS.md for state (default: true) */ parseStatus?: boolean; } /** * Load registry from file * * @param path - Path to registry file (defaults to home directory) */ export declare function loadRegistry(path?: string): Promise; /** * Retrospective Reference Reader * * Loads retrospective files from completed plans and wraps them with context * for inclusion in idea exploration. This enables the outer learning loop where * past plan execution informs future plan creation. */ /** * Load a retrospective file and wrap it with contextual framing * * @param retrospectivePath - Path to the plan directory or .plan file * @param reason - User's explanation of why this retrospective is relevant * @returns Wrapped retrospective content ready for context inclusion * @throws Error if retrospective file doesn't exist */ export declare function loadRetrospectiveAsContext(retrospectivePath: string, reason: string): Promise; export { MarkdownRenderOptions } /** * Extended milestone info */ export declare interface MilestoneInfo extends PlanMilestone { /** Milestone index */ index: number; } export declare function moveStep(plan: Plan, fromNumber: number, toNumber: number): Promise; export declare interface MoveStepResult { step: PlanStep; newPosition: number; renamedFiles: Array<{ from: string; to: string; }>; } /** * Generate a new version number */ export declare function nextVersion(currentVersion: string): string; /** * Parse all dependencies from a plan * * @param plan - The plan to analyze * @returns Map of step number to its dependencies */ export declare function parseAllDependencies(plan: Plan): Promise>; export { parseCriteria } export { parseCriteriaFromContent } export { ParsedCriteria } /** * Parse dependencies from step content * * Looks for dependency declarations in the markdown: * - `## Dependencies` section with bullet points * - `depends-on: 1, 2, 3` in frontmatter * - Inline references like `(depends on Step 01)` * * @param content - Step file content * @returns Array of step numbers this step depends on */ export declare function parseDependenciesFromContent(content: string): number[]; /** * Parse dependencies from a step file * * @param filePath - Path to step file * @returns Array of step numbers this step depends on */ export declare function parseDependenciesFromFile(filePath: string): Promise; /** * Parsed relationship from file content */ export declare interface ParsedRelationship { type: RelationshipType; targetPath: string; steps?: number[]; reason?: string; } /** * Parse relationships from plan content * * Looks for relationship declarations in markdown: * - `## Related Plans` section with formatted links * - `spawned-from: path/to/plan` in frontmatter * - `blocks: path/to/plan` in frontmatter * * Supported formats in ## Related Plans: * - `- **spawned-from**: path/to/plan - reason` * - `- [plan-name](path/to/plan) - blocks Step 3` * - `- path/to/plan (related)` * * @param content - Plan file content (typically SUMMARY.md or meta-prompt) * @returns Array of parsed relationships */ export declare function parseRelationshipsFromContent(content: string): ParsedRelationship[]; /** * Parse relationships from a plan's SUMMARY.md or meta-prompt * * @param planPath - Path to the plan directory * @returns Array of parsed relationships */ export declare function parseRelationshipsFromPlan(planPath: string): Promise; /** * Parse STATUS.md content into structured data * * @param content - The STATUS.md file content * @param options - Parsing options * @returns Parsed document, state, and any warnings * * @example * ```typescript * const content = await readFile('STATUS.md', 'utf-8'); * const result = parseStatus(content); * console.log(result.state.progress); // 40 * console.log(result.document.stepProgress.length); // 5 * ``` */ export declare function parseStatus(content: string, options?: ParseStatusOptions): ParseStatusResult; /** * Options for parsing STATUS.md */ export declare interface ParseStatusOptions { /** Steps to cross-reference for status updates */ steps?: PlanStep[]; } /** * Result of parsing STATUS.md */ export declare interface ParseStatusResult { /** Parsed status document */ document: StatusDocument; /** Derived plan state */ state: PlanState; /** Parsing warnings */ warnings: string[]; } export { Plan } export { PLAN_CONVENTIONS } export declare type PlanCategory = 'active' | 'done' | 'hold'; export { PlanContext } export { PlanContextDefinition } export { PlanDoc } export { PlanFiles } export { PlanHistory } export { PlanMetadata } export { PlanMilestone } export { PlanPhase } /** * Plan registry containing all discovered plans */ export declare interface PlanRegistry { /** Version of the registry format */ version: string; /** When last updated */ lastUpdatedAt: Date; /** Search paths for plan discovery */ searchPaths: string[]; /** All registered plans indexed by path */ plans: Map; /** Index by code for quick lookup */ byCode: Map; /** Index by status */ byStatus: Map; } export { PlanRelationship } export { PlanResult } export { PlanRevision } export { PlanState } export { PlanStep } export { Priority } export { PRIORITY_WEIGHTS } /** * Read all step reflections from the plan's SQLite database. */ export declare function readAllReflections(planPath: string): Promise; export { readEvidenceRecords } export { readIdeaDoc } export { readPlanDoc } export { readPlanIdentity } /** * Read reflections for steps prior to a given step number. */ export declare function readPriorReflections(planPath: string, beforeStep: number): Promise; export { readShapingDoc } export { readStatusDoc } /** * Read a single step reflection from the plan's SQLite database. */ export declare function readStepReflection(planPath: string, stepNumber: number): Promise; export { readTimelineEvents } /** * Refresh all plans in the registry */ export declare function refreshAllPlans(registry: PlanRegistry): Promise<{ updated: number; removed: number; }>; /** * Refresh a single plan's entry * * @param registry - The registry * @param path - Path to the plan * @returns Updated entry or null if plan no longer exists */ export declare function refreshPlan(registry: PlanRegistry, path: string): Promise; /** * A registered plan entry */ export declare interface RegisteredPlan { /** Plan code (directory name) */ code: string; /** Human-readable name */ name: string; /** Absolute path to plan directory */ path: string; /** Overall status */ status: TaskStatus; /** Progress percentage */ progress: number; /** Number of steps */ stepCount: number; /** Number of completed steps */ completedSteps: number; /** When discovered/registered */ registeredAt: Date; /** When last scanned */ lastScannedAt: Date; /** Tags (if any) */ tags?: string[]; /** Description snippet */ description?: string; /** Parent plan path (if spawned from another) */ parentPlan?: string; } /** * Register a plan in the registry */ export declare function registerPlan(registry: PlanRegistry, entry: RegisteredPlan): void; /** * Options for creating/loading a registry */ export declare interface RegistryOptions { /** Search paths to scan for plans */ searchPaths?: string[]; /** Maximum depth to scan (default: 3) */ maxDepth?: number; /** Include hidden directories (default: false) */ includeHidden?: boolean; /** Directories to skip */ excludeDirs?: string[]; } /** * Get registry statistics */ export declare interface RegistryStats { totalPlans: number; byStatus: Record; averageProgress: number; oldestPlan?: RegisteredPlan; newestPlan?: RegisteredPlan; searchPathCount: number; } export { RelationshipType } /** * Relationship validation result */ export declare interface RelationshipValidation { /** All relationships valid */ valid: boolean; /** Invalid relationships */ invalid: InvalidRelationship[]; /** Valid relationships */ validRelationships: PlanRelationship[]; } /** * Remove a relationship from a plan * * @param plan - The source plan * @param targetPath - Path to the related plan to remove * @param type - Optional type to match (removes all types if not specified) * @returns Removed relationships */ export declare function removeRelationship(plan: Plan, targetPath: string, type?: RelationshipType): PlanRelationship[]; export declare function removeStep(plan: Plan, stepNumber: number): Promise; export declare interface RemoveStepResult { removedStep: PlanStep; renamedFiles: Array<{ from: string; to: string; }>; deletedFile: string; } export { RenderFormat } export { RenderOptions } export { renderPlan } export { RenderResult } export { renderToHtml } export { renderToJson } export { renderToMarkdown } /** * Plan Directory Resolver * * This module implements the main four-tier plan directory resolution strategy: * * 1. **Environment Variable** (Tier 1) - RIOTPLAN_PLAN_DIRECTORY * Handled by CardiganTime automatically * * 2. **Configuration File** (Tier 2) - riotplan.config.*, .riotplan/config.*, etc. * Handled by CardiganTime with hierarchical discovery * * 3. **Walk-Up Detection** (Tier 3) - Find existing plans/ directory * Custom logic to walk up directory tree * * 4. **Fallback** (Tier 4) - Default to ./plans in current directory * Ensures zero-config experience always works * * This is the main entry point for resolving the plan directory throughout riotplan. */ /** * Resolve the plan directory using the four-tier strategy * * This function orchestrates all four tiers of plan directory resolution: * * 1. **Tier 1 & 2**: Check CardiganTime config (env var + config files) * - If `planDirectory` is set in config, use it (resolved relative to config file) * - CardiganTime handles environment variable RIOTPLAN_PLAN_DIRECTORY * * 2. **Tier 3**: Walk up directory tree looking for existing `plans/` directory * - Starts from `process.cwd()` * - Returns first `plans/` directory found * * 3. **Tier 4**: Fallback to `./plans` relative to current directory * - Ensures zero-config experience always works * - Directory will be created on first use if needed * * @returns Absolute path to the plan directory * * @example * ```typescript * // With RIOTPLAN_PLAN_DIRECTORY=/custom/plans * resolvePlanDirectory() // Returns '/custom/plans' * * // With config file: planDirectory: './my-plans' * resolvePlanDirectory() // Returns '/path/to/config/my-plans' * * // With plans/ in project root * resolvePlanDirectory() // Returns '/path/to/project/plans' * * // No config, no plans/ found * resolvePlanDirectory() // Returns '/current/dir/plans' * ``` */ export declare function resolvePlanDirectory(): Promise; /** * Synchronous version of resolvePlanDirectory for cases where async isn't possible * * This uses cached results if available, otherwise falls back to tier 3 and 4 * (which are synchronous). Tier 1-2 require async config loading. * * @returns Absolute path to the plan directory */ export declare function resolvePlanDirectorySync(): string; /** * Retrospective data structure */ export declare interface Retrospective { /** Plan name */ planName: string; /** Plan code */ planCode: string; /** When the plan started */ startedAt?: Date; /** When the plan completed */ completedAt?: Date; /** Total duration in milliseconds */ duration?: number; /** Total steps */ totalSteps: number; /** Completed steps */ completedSteps: number; /** Skipped steps */ skippedSteps: number; /** What went well */ whatWentWell: string[]; /** What could improve */ whatCouldImprove: string[]; /** Key learnings */ keyLearnings: string[]; /** Action items for future */ actionItems: string[]; /** Steps summary */ stepsSummary: Array<{ number: number; title: string; status: string; duration?: number; notes?: string; }>; } /** * Check if a retrospective exists for a given plan * * @param planPath - Path to the plan directory or .plan file * @returns True if retrospective exists */ export declare function retrospectiveExists(planPath: string): Promise; /** * Comparison result between revisions */ export declare interface RevisionComparison { /** Earlier revision */ from: RevisionInfo; /** Later revision */ to: RevisionInfo; /** Time difference in milliseconds */ timeDiff: number; /** Number of revisions between */ revisionCount: number; } /** * Extended revision info with computed fields */ export declare interface RevisionInfo extends PlanRevision { /** Revision index in history */ index: number; /** Whether this is the current revision */ isCurrent: boolean; } /** * TypeScript type inferred from the Zod schema * * This type is exported for use throughout the codebase. * It matches the RiotPlanConfig interface in types.ts. */ export declare type RiotPlanConfig = z.infer; /** * Zod schema for RiotPlan configuration * * Defines all configuration options with validation rules and defaults. * This schema is used by CardiganTime to: * - Validate configuration files * - Provide type-safe configuration access * - Handle environment variable overrides */ export declare const RiotPlanConfigSchema: z.ZodObject<{ planDirectory: z.ZodDefault; defaultProvider: z.ZodOptional>; defaultModel: z.ZodOptional; templateDirectory: z.ZodOptional; catalysts: z.ZodOptional>; catalystDirectory: z.ZodOptional; verification: z.ZodDefault>; checkAcceptanceCriteria: z.ZodDefault; checkArtifacts: z.ZodDefault; autoRetrospective: z.ZodDefault; requireEvidence: z.ZodDefault; }, z.core.$strip>>; cloud: z.ZodOptional; incrementalSyncEnabled: z.ZodDefault; syncFreshnessTtlMs: z.ZodDefault; syncTimeoutMs: z.ZodDefault; planBucket: z.ZodOptional; planPrefix: z.ZodOptional; contextBucket: z.ZodOptional; contextPrefix: z.ZodOptional; projectId: z.ZodOptional; keyFilename: z.ZodOptional; credentialsJson: z.ZodOptional; cacheDirectory: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>; /** * Rollback result */ export declare interface RollbackResult { /** Whether rollback succeeded */ success: boolean; /** Target milestone */ milestone?: MilestoneInfo; /** New current version */ newVersion?: string; /** Revisions rolled back */ revisionsRolledBack?: number; /** Error message if failed */ error?: string; } /** * Rollback to a milestone * * This resets the current version to the milestone's version. * Revisions after the milestone are kept but no longer current. */ export declare function rollbackToMilestone(history: PlanHistory, milestoneName: string): RollbackResult; export declare function saveHistory(history: PlanHistory, planPath: string): Promise; export { saveIdeaDoc } export { savePlanDoc } /** * Save registry to file * * @param registry - The registry to save * @param path - Path to save to (defaults to home directory) */ export declare function saveRegistry(registry: PlanRegistry, path?: string): Promise; export { saveShapingDoc } export { saveStatusDoc } /** * Scan directories for plans and add them to registry * * @param registry - The registry to update * @param options - Scan options */ export declare function scanForPlans(registry: PlanRegistry, options?: RegistryOptions): Promise; /** * Options for searching plans */ export declare interface SearchOptions { /** Filter by status */ status?: TaskStatus | TaskStatus[]; /** Filter by code pattern (glob or regex) */ codePattern?: string; /** Filter by name pattern */ namePattern?: string; /** Filter by tag */ tags?: string[]; /** Minimum progress */ minProgress?: number; /** Maximum progress */ maxProgress?: number; /** Sort by field */ sortBy?: "name" | "code" | "progress" | "status" | "registeredAt"; /** Sort direction */ sortDir?: "asc" | "desc"; /** Limit results */ limit?: number; /** Offset for pagination */ offset?: number; } /** * Search for plans in the registry */ export declare function searchPlans(registry: PlanRegistry, options?: SearchOptions): SearchResult; /** * Result of a plan search */ export declare interface SearchResult { /** Matching plans */ plans: RegisteredPlan[]; /** Total matches */ total: number; } export declare function skipStep(plan: Plan, stepNumber: number, reason?: string): PlanStep; export declare function startStep(plan: Plan, stepNumber: number): PlanStep; export { StatusDocument } export { StepCompletionResult } export { StepCompletionStatus } /** * Dependency information for a step */ export declare interface StepDependency { /** The step that has dependencies */ stepNumber: number; /** Steps this step depends on (must be completed before this step) */ dependsOn: number[]; /** Steps that depend on this step (blocked until this completes) */ blockedBy: number[]; } /** * Reflection File Reader * * Reads step reflection files from SQLite .plan storage. */ export declare interface StepReflection { step: number; content: string; } export { StepResult } export { TaskStatus } export { TimelineEventEntry } export declare function unblockStep(plan: Plan, stepNumber: number): PlanStep; /** * Unregister a plan from the registry */ export declare function unregisterPlan(registry: PlanRegistry, path: string): boolean; /** * Update a plan's SUMMARY.md with relationships * * @param plan - The plan to update */ export declare function updatePlanRelationships(plan: Plan): Promise; /** * Update a plan's state based on status changes */ export declare function updateStatus(plan: Plan, updates: UpdateStatusOptions): Plan; export declare interface UpdateStatusOptions { /** Step that was completed/updated */ step?: number; /** New status for step */ stepStatus?: TaskStatus; /** Add blocker */ addBlocker?: string; /** Remove blocker by description match */ removeBlocker?: string; /** Add issue */ addIssue?: { title: string; description: string; }; /** Add note */ addNote?: string; } /** * Update step dependencies in memory * * @param step - The step to update * @param dependencies - New dependency list * @returns Updated step */ export declare function updateStepDependencies(step: PlanStep, dependencies: number[]): PlanStep; /** * Validate dependencies in a plan * * @param plan - The plan to validate * @param graph - Optional pre-built dependency graph * @param rawDeps - Optional raw dependencies map (before filtering) * @returns Validation result */ export declare function validateDependencies(plan: Plan, graph?: DependencyGraph, rawDeps?: Map): Promise; /** * Validate all relationships in a plan * * @param plan - The plan to validate * @returns Validation result */ export declare function validateRelationships(plan: Plan): Promise; export { VerificationCriterion } export { VerificationReport } export declare const VERSION = "0.0.1"; /** * Reflection File Writer * * Writes step reflection files to SQLite .plan storage. */ /** * Write a step reflection to the plan's SQLite database. */ export declare function writeStepReflection(planPath: string, stepNumber: number, content: string): Promise; export { }