import { IdAllocator, type ImportPlan } from './importBacklog.js'; import { type ResolvedSource } from './sources.js'; import type { TrackerSourceConfig } from './types.js'; /** Directories of every configured `issue-per-file` source — one of the default excludes (Design * point 0): importing a directory that's already a one-issue-per-file store makes no sense (those * files are individually canonical already, not a freeform backlog). */ export declare function issuePerFileSourceDirs(projectRoot: string, config: { sources?: TrackerSourceConfig[]; }): string[]; /** Expand `patterns` (files, directories, or quoted globs) into a sorted, de-duplicated list of * absolute `.md` file paths, applying the default excludes. Throws if a literal (non-glob) path * doesn't exist. */ export declare function expandInputs(patterns: readonly string[], cwd: string, excludeDirs: readonly string[]): string[]; /** Every issue id already present anywhere in the configured tracker (both `issue-per-file` and * `document` sources) — used to seed the batch's `IdAllocator` so a freshly minted id can never * collide with one that already exists ANYWHERE, not just within the files being imported. */ export declare function collectConfiguredIds(projectRoot: string, config: { sources?: TrackerSourceConfig[]; }): string[]; /** `--prefix` else inferred from an id already present in the file's HEADINGS (headings ONLY — * a prose line is not an id: an any-line fallback matched ordinary hyphenated words, so a * preamble like "Follow-up items are tracked below." inferred the bogus prefix "Follow" and * shadowed the configured teamKey) else the tracker config's `local.teamKey` else `null` * (caller must report a clear error asking for --prefix). */ export declare function resolveIssuePrefix(text: string, explicit: string | undefined, teamKey: string | undefined): string | null; export type FileOutcome = { kind: 'materialized'; path: string; plan: ImportPlan; before: string; after: string; } | { kind: 'noop'; path: string; plan: ImportPlan; } | { kind: 'skipped'; path: string; reason: string; }; export interface BatchOptions { prefix?: string; teamKey?: string; allocator: IdAllocator; /** false (--dry-run): plan only, never touch disk. */ write: boolean; } /** Run the import over an already-expanded, deterministically ORDERED file list — single pass, * one shared allocator (so numbering is collision-safe across the whole batch), one outcome per * file. Files are processed in the given order; callers wanting reproducible numbering should * pass a stable (e.g. sorted) order — `expandInputs` already sorts. */ export declare function runImportBatch(files: readonly string[], opts: BatchOptions): FileOutcome[]; export interface RegisterPlan { configPath: string; /** Entries that would be appended — empty if every file is already a declared source. */ toAdd: TrackerSourceConfig[]; } /** Compute (never write) which `sources` entries `--register` would append for the given * materialized/no-op file paths: one `{path, format:"document"}` per file NOT already present in * `config.sources` (by resolved absolute path, so a differently-spelled but equivalent path is * still recognized as a duplicate). * * PINNED SAFETY DECISION: declaring ANY explicit `sources` entry turns OFF the implicit * "no `sources:` key means one default issue-per-file store" fallback (src/sources.ts — * pre-existing behavior, not introduced here). If `config.sources` is absent/empty, registering * a document source alone would therefore silently stop the tracker from reading its pre-existing * default store. So when there's nothing declared yet, the default store's own entry is added * FIRST — still additive (nothing removed), and still fully visible: it's part of the SAME * printed/appended list `--register` (or the without-`--register` hint) shows, never a hidden * mutation. */ export declare function planRegister(projectRoot: string, config: { sources?: TrackerSourceConfig[]; }, filePaths: readonly string[]): TrackerSourceConfig[]; /** Plan `--register --dialect ` (docs/DIALECTS.md): one `{dialect, path}` entry per file — * a read-only LENS declaration, config-only by definition (the file itself is never rewritten * on this path; `resolveSources` forces the lens readonly). Same default-store preservation and * duplicate-path de-dupe as `planRegister` above. */ export declare function planDialectRegister(projectRoot: string, config: { sources?: TrackerSourceConfig[]; }, filePaths: readonly string[], dialectName: string): TrackerSourceConfig[]; /** The declared-lens subset of `filePaths` (docs/DIALECTS.md WP6): absolute file path -> the * ResolvedSource whose `dialect` reads it. These files take the MATERIALIZE-upgrade path in * `ztrack import` (dialect parse -> native grammar + config-entry upgrade), never the freeform * heuristics — the registered dialect already says exactly what the file means. */ export declare function registeredLensSources(projectRoot: string, config: { sources?: TrackerSourceConfig[]; }, filePaths: readonly string[]): Map; /** Upgrade one source's config entry after its file was materialized (docs/DIALECTS.md WP6): * `dialect` and `readonly` drop (the file now speaks the native grammar and is writable within * the document source's own rules), `path`/`format`/`name` survive, and the id renames the * materialization performed are recorded as `aliases` (old -> new) so references keep * resolving. Same fail-loudly validation discipline as `applyRegister` below. */ export declare function applyMaterializeUpgrade(configPath: string, projectRoot: string, absPath: string, aliases: Record): void; /** Apply `--register`: append `toAdd` to `config.sources` in the on-disk config file and rewrite * it. The ONLY config mutation this whole feature ever performs, and only additive. * * ZTB-26 dev/03: this used to blindly `JSON.parse(...) as TrackerConfig` the file and rewrite it — * an unvalidated cast that would silently rewrite ON TOP OF a malformed config. It now validates * through the same schema `loadTrackerConfig` does before mutating: a malformed config fails * loudly here instead of being blindly preserved-and-rewritten. In the normal CLI flow this file * was already validated moments earlier by the caller's own `loadTrackerConfig` (cliImport.ts) — * this is defense in depth against calling `applyRegister` directly with a stale/hand-edited path. */ export declare function applyRegister(configPath: string, toAdd: readonly TrackerSourceConfig[]): void;