/** * Filesystem layer for skill bundles: the injectable fs surface, bundle * inspection, and reconciliation of a skills directory against the effective * skill entries. Split out of `skills.ts` (2026-09-29): that module keeps the * pure SKILL.md format, limits and structural validation; this one touches disk. * @module dsh-continual-harness */ import type { SkillEntryLike } from './skills.ts'; import type { MaterializationResult } from './types.ts'; /** Injectable fs surface so materialization write faults are testable (spec §7.11). */ export interface SkillFsOps { existsSync(path: string): boolean; readdirSync(path: string): string[]; lstatSync(path: string): { isDirectory(): boolean; isSymbolicLink(): boolean; isFile(): boolean; }; mkdirSync(path: string, opts?: { recursive?: boolean; }): void; writeFileSync(path: string, data: string, encoding: 'utf8'): void; renameSync(oldPath: string, newPath: string): void; readFileSync(path: string, encoding: 'utf8'): string; rmSync(path: string, opts?: { recursive?: boolean; force?: boolean; }): void; /** Remove an empty directory only; non-empty or missing throws (walk abort). */ rmdirSync(path: string): void; } /** The default fs surface: direct `node:fs` bindings. */ export declare const defaultSkillFsOps: SkillFsOps; export interface DiscoveredEntry { rel: string; kind: 'file' | 'symlink' | 'other'; } /** On-disk state of one skill bundle path (spec §7.4 ownership decision). */ export type SkillBundleInspection = { state: 'missing'; } | { state: 'non-directory'; bundle: string; } | { state: 'present'; bundle: string; harnessOwned: boolean; }; /** * Inspect a skill bundle path without mutating anything: missing, an existing * non-directory, or a directory whose SKILL.md provenance decides ownership. * Both `reconcileSkillFiles` and the store's create-conflict gate share this * single ownership decision so policy cannot drift between call sites. */ export declare function inspectSkillBundle(fsOps: SkillFsOps, dir: string, id: string): SkillBundleInspection; /** * Materialize the bundle files (SKILL.md + entry.files) for the skill ids * touched by a committed refinement (spec §7.5/§7.7). JSON is the source of * truth; the disk is a renderable projection. Only kebab-case ids are ever * touched; ids outside `touchedIds` are never touched. A bundle is only * written to or deleted when its existing SKILL.md carries the full harness * provenance; otherwise it is skipped with a `not-harness-owned` entry. * Stale regular files in owned bundles are deleted; symlink/special files * are skipped with warnings. Write faults are collected; the committed * refinement is never failed by this function. */ export declare function reconcileSkillFiles(dir: string, effectiveSkills: Readonly>, touchedIds: ReadonlyArray, fsOps?: SkillFsOps): MaterializationResult; //# sourceMappingURL=skills-fs.d.ts.map