faf-cli 7.10.0 → 7.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Context-drift engine — SINGLE SOURCE.
3
+ *
4
+ * A pure, snapshot comparison: given a `project.faf` and its directory, report
5
+ * the mtime relationship between the .faf and each AI-context file it feeds
6
+ * (CLAUDE.md, AGENTS.md, .cursorrules, GEMINI.md). A target NEWER than the .faf
7
+ * has drifted — the human edited the context file and the DNA hasn't caught up.
8
+ *
9
+ * No console, no ANSI, no process.exit. The CLI `faf drift` renders the human
10
+ * table on top of this; `faf drift --json` emits this shape with a metadata
11
+ * header; the VS Code extension imports `computeDrift` directly (faf-cli as a
12
+ * library, never a shell-out). One comparison, every consumer.
13
+ */
14
+ /** AI-context files the .faf feeds — the drift targets, in report order. */
15
+ export declare const CONTEXT_FILES: string[];
16
+ /** mtime window (ms) inside which a target counts as in sync with the .faf. */
17
+ export declare const DRIFT_TOLERANCE_MS = 1000;
18
+ /** 'newer' = target newer than the .faf → needs sync. */
19
+ export type DriftStatus = 'newer' | 'older' | 'in-sync' | 'missing';
20
+ export interface DriftTarget {
21
+ /** Context-file name, e.g. 'CLAUDE.md'. */
22
+ file: string;
23
+ /** Whether the file exists alongside the .faf. */
24
+ exists: boolean;
25
+ /** File mtime in epoch ms, or null when missing. */
26
+ mtime_ms: number | null;
27
+ /** 'newer' = target newer than the .faf → needs sync. */
28
+ status: DriftStatus;
29
+ /** mtime_ms - source_mtime_ms, or null when missing. */
30
+ delta_ms: number | null;
31
+ }
32
+ export interface DriftReport {
33
+ /** The `project.faf` path compared against. */
34
+ source: string;
35
+ /** .faf mtime in epoch ms. */
36
+ source_mtime_ms: number;
37
+ targets: DriftTarget[];
38
+ /** Count of targets with status 'newer' or 'older'. */
39
+ drifted: number;
40
+ /** Count of targets with status 'in-sync'. */
41
+ in_sync: number;
42
+ /** Count of targets with status 'missing'. */
43
+ missing: number;
44
+ }
45
+ /**
46
+ * Compare a `project.faf` against its AI-context files by mtime.
47
+ *
48
+ * @param fafPath path to `project.faf`
49
+ * @param dir directory holding the context files; defaults to the .faf's
50
+ * own directory. Never `process.cwd()` — the CLI passes it
51
+ * explicitly, and a library caller (the VS Code extension)
52
+ * passes the .faf's directory, which for a monorepo sub-package
53
+ * is the package dir, not the workspace root.
54
+ */
55
+ export declare function computeDrift(fafPath: string, dir?: string): DriftReport;
package/dist/index.d.ts CHANGED
@@ -5,6 +5,8 @@ export { FAF_HEX } from './ui/colors.js';
5
5
  export { enrichScore, scoreFafYaml } from './core/scorer.js';
6
6
  export { validateFaf } from './core/schema.js';
7
7
  export { findFafFile, readFaf, readFafRaw } from './interop/faf.js';
8
+ export { computeDrift } from './core/drift.js';
9
+ export type { DriftReport, DriftTarget, DriftStatus } from './core/drift.js';
8
10
  export { generateProjectHtml, writeProjectHtml } from './interop/projecthtml.js';
9
11
  export { generateServerCard, writeServerCard, fafContextBlock, registryMeta, registryName, REGISTRY_PUBLISHER_KEY, } from './interop/servercard.js';
10
12
  export type { ServerCardOptions } from './interop/servercard.js';