/**
 * Module: utils/task-package
 *
 * Encapsulated Taskdocs (`*.tsk/`).
 *
 * A Taskdoc is a directory ending in `.tsk`. It *may* contain:
 * - goals.md
 * - constraints.md
 * - progress.md
 *
 * These files are considered high-integrity state and MUST NOT be accessible via general file tools.
 */
import type { LanguageCode } from '@longrun-ai/kernel/types/language';
export type TaskPackageSection = 'goals' | 'constraints' | 'progress';
export type TaskPackageSectionState = {
    kind: 'present';
    content: string;
} | {
    kind: 'missing';
};
export interface TaskPackageSectionsState {
    goals: TaskPackageSectionState;
    constraints: TaskPackageSectionState;
    progress: TaskPackageSectionState;
}
export declare const BEAR_IN_MIND_SECTIONS: readonly ["contracts", "acceptance", "grants", "runbook", "decisions", "risks"];
export type BearInMindSection = (typeof BEAR_IN_MIND_SECTIONS)[number];
export type TaskPackageBearInMindSectionsState = Record<BearInMindSection, TaskPackageSectionState>;
export type TaskPackageBearInMindState = {
    kind: 'absent';
} | {
    kind: 'present';
    sections: TaskPackageBearInMindSectionsState;
    extraEntries: readonly string[];
} | {
    kind: 'invalid';
    reason: 'not_a_directory';
};
export type TaskPackageExtraCategory = Readonly<{
    category: string;
    selectors: readonly string[];
}>;
export type TaskPackageExtraSectionsState = {
    kind: 'unavailable';
    reason: 'scan_error';
} | {
    kind: 'present';
    categories: readonly TaskPackageExtraCategory[];
    truncated: boolean;
};
export type TaskPackageLayoutViolation = {
    kind: 'top_level_file_under_subdir';
    filename: string;
    foundAt: string;
} | {
    kind: 'bearinmind_file_outside_bearinmind';
    filename: string;
    foundAt: string;
} | {
    kind: 'bearinmind_extra_entry';
    foundAt: string;
} | {
    kind: 'bearinmind_not_directory';
    foundAt: string;
} | {
    kind: 'scan_limit_exceeded';
    maxEntries: number;
};
export type TaskPackageChangeMindTarget = {
    kind: 'top_level';
    section: TaskPackageSection;
} | {
    kind: 'bearinmind';
    section: BearInMindSection;
} | {
    kind: 'category';
    category: string;
    selector: string;
};
export type TaskPackageChangeMindTargetError = {
    kind: 'selector_required';
} | {
    kind: 'invalid_category_name';
    category: string;
} | {
    kind: 'invalid_category_selector';
    selector: string;
} | {
    kind: 'invalid_top_level_selector';
    selector: string;
} | {
    kind: 'invalid_bearinmind_selector';
    selector: string;
} | {
    kind: 'top_level_selector_requires_no_category';
    category: string;
    selector: string;
} | {
    kind: 'bearinmind_selector_requires_bearinmind_category';
    category: string;
    selector: string;
};
export type TaskPackageChangeMindTargetParseResult = {
    kind: 'ok';
    target: TaskPackageChangeMindTarget;
} | {
    kind: 'err';
    error: TaskPackageChangeMindTargetError;
};
export type TaskPackageContentHash = `crc32:${string}`;
export declare function isTaskPackagePath(taskDocPath: string): boolean;
export declare function taskPackageSectionFromSelector(selector: string): TaskPackageSection | null;
export declare function bearInMindSectionFromSelector(selector: string): BearInMindSection | null;
export declare function parseTaskPackageChangeMindTarget(params: {
    selector: string;
    category?: string;
}): TaskPackageChangeMindTargetParseResult;
export declare function taskPackageFilenameForSection(section: TaskPackageSection): string;
export declare function bearInMindFilenameForSection(section: BearInMindSection): string;
export declare function updateTaskPackageByChangeMindTarget(params: {
    taskPackageDirFullPath: string;
    target: TaskPackageChangeMindTarget;
    content: string;
    previousContentHash: string;
    updatedBy?: string;
}): Promise<{
    kind: 'updated';
} | {
    kind: 'missing';
} | {
    kind: 'content_hash_mismatch';
    currentContentHash: TaskPackageContentHash;
}>;
export declare function readTaskPackageByChangeMindTarget(params: {
    taskPackageDirFullPath: string;
    target: TaskPackageChangeMindTarget;
}): Promise<{
    kind: 'present';
    content: string;
    contentHash: TaskPackageContentHash;
} | {
    kind: 'missing';
}>;
export declare function createTaskPackageByChangeMindTarget(params: {
    taskPackageDirFullPath: string;
    target: TaskPackageChangeMindTarget;
    content: string;
    updatedBy?: string;
}): Promise<{
    kind: 'created';
} | {
    kind: 'exists';
}>;
export declare function appendTaskPackageByChangeMindTarget(params: {
    taskPackageDirFullPath: string;
    target: TaskPackageChangeMindTarget;
    content: string;
    sep: string;
    updatedBy?: string;
}): Promise<void>;
export declare function deleteTaskPackageByChangeMindTarget(params: {
    taskPackageDirFullPath: string;
    target: TaskPackageChangeMindTarget;
}): Promise<{
    kind: 'deleted';
} | {
    kind: 'missing';
}>;
export declare function computeTaskPackageContentHash(content: string): TaskPackageContentHash;
export declare function taskPackageRelativePathForChangeMindTarget(target: TaskPackageChangeMindTarget): string;
export declare function ensureTaskPackage(taskPackageDirFullPath: string, _updatedBy?: string): Promise<void>;
export declare function readTaskPackageSections(taskPackageDirFullPath: string): Promise<TaskPackageSectionsState>;
export declare function formatEffectiveTaskDocFromSections(language: LanguageCode, sections: TaskPackageSectionsState, bearInMind?: TaskPackageBearInMindState): string;
export declare function validateTaskPackageLayout(taskPackageDirFullPath: string): Promise<TaskPackageLayoutViolation[]>;
export declare function readTaskPackageForInjection(taskPackageDirFullPath: string): Promise<{
    sections: TaskPackageSectionsState;
    bearInMind: TaskPackageBearInMindState;
    extraSections: TaskPackageExtraSectionsState;
    violations: TaskPackageLayoutViolation[];
}>;
export declare function updateTaskPackageSection(params: {
    taskPackageDirFullPath: string;
    section: TaskPackageSection;
    content: string;
    updatedBy?: string;
}): Promise<void>;
