@ankurhalder/codebase-snapshot 4.0.7 → 4.1.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.
package/dist/cli.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { O as OutputFormat } from './types-x7aogSer.cjs';
1
+ import { O as OutputFormat, D as DiscoveryMode } from './types-BMP676ER.cjs';
2
2
 
3
3
  type Command = "generate" | "validate" | "report" | "init" | "explain" | "diff" | "describe" | "skill";
4
4
  /** A user-input problem: printed without a stack trace, exits 2. */
@@ -33,6 +33,8 @@ interface ParsedInvocation {
33
33
  largeFileBytes?: number;
34
34
  maxMonolithBytes?: number | null;
35
35
  skipArtifacts?: string[];
36
+ /** How candidates are discovered; `auto` when unset. */
37
+ discovery?: DiscoveryMode;
36
38
  }
37
39
  declare function parsePositiveInteger(raw: string | undefined, optionName: string, minimum: number): number | undefined;
38
40
  /**
@@ -50,5 +52,61 @@ declare function parseByteOption(raw: string | undefined, optionName: string, mi
50
52
  declare function parseCliArgs(argv: string[]): ParsedInvocation;
51
53
  /** Runs the CLI and returns the process exit code. */
52
54
  declare function main(argv?: string[]): Promise<number>;
55
+ /** Coalesce bursts of filesystem events into one run. */
56
+ declare const WATCH_DEBOUNCE_MS = 250;
57
+ /**
58
+ * Unattributed watcher events (no filename) are ignored this long after a run.
59
+ * Named source events are never ignored: that is how an edit in the quiet
60
+ * window or during a run reaches the loop.
61
+ */
62
+ declare const WATCH_SETTLE_MS = 1500;
63
+ interface WatchState {
64
+ running: boolean;
65
+ pending: boolean;
66
+ settleUntil: number;
67
+ }
68
+ interface WatchPaths {
69
+ cwd: string;
70
+ outDir: string;
71
+ tmpDir: string;
72
+ }
73
+ interface WatchEvent {
74
+ /** Absolute path, or null when `fs.watch` did not attribute the event. */
75
+ path: string | null;
76
+ /** `performance.now()` at delivery. */
77
+ now: number;
78
+ }
79
+ type WatchAction = "ignore" | "pending" | "schedule";
80
+ interface WatchDecision {
81
+ state: WatchState;
82
+ action: WatchAction;
83
+ }
84
+ declare function initialWatchState(): WatchState;
85
+ declare function beginWatchRun(state: WatchState): WatchState;
86
+ /**
87
+ * Finish one run. `schedule` is true when a source event arrived while the run
88
+ * was in flight, so exactly one follow-up run is owed.
89
+ */
90
+ declare function finishWatchRun(state: WatchState, now: number): {
91
+ state: WatchState;
92
+ schedule: boolean;
93
+ };
94
+ /**
95
+ * True only for the resolved output/staging paths and their contents.
96
+ *
97
+ * This deliberately does not match a directory just because its basename is
98
+ * `docs`: a source directory `src/docs` is not the output directory `docs`.
99
+ */
100
+ declare function isGeneratedWatchPath(candidate: string, paths: WatchPaths): boolean;
101
+ /**
102
+ * Decide what one watcher event means.
103
+ *
104
+ * - generated paths are always ignored;
105
+ * - a named source event is `pending` during a run and `schedule` otherwise,
106
+ * including inside the settle window (an edit is never swallowed);
107
+ * - an unattributed event is ignored during a run and for the settle window,
108
+ * because Windows does not always name the path our own writes produced.
109
+ */
110
+ declare function decideWatchEvent(state: WatchState, event: WatchEvent, paths: WatchPaths): WatchDecision;
53
111
 
54
- export { UsageError, main, parseByteOption, parseCliArgs, parsePositiveInteger };
112
+ export { UsageError, WATCH_DEBOUNCE_MS, WATCH_SETTLE_MS, type WatchAction, type WatchDecision, type WatchEvent, type WatchPaths, type WatchState, beginWatchRun, decideWatchEvent, finishWatchRun, initialWatchState, isGeneratedWatchPath, main, parseByteOption, parseCliArgs, parsePositiveInteger };
package/dist/cli.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { O as OutputFormat } from './types-x7aogSer.js';
1
+ import { O as OutputFormat, D as DiscoveryMode } from './types-BMP676ER.js';
2
2
 
3
3
  type Command = "generate" | "validate" | "report" | "init" | "explain" | "diff" | "describe" | "skill";
4
4
  /** A user-input problem: printed without a stack trace, exits 2. */
@@ -33,6 +33,8 @@ interface ParsedInvocation {
33
33
  largeFileBytes?: number;
34
34
  maxMonolithBytes?: number | null;
35
35
  skipArtifacts?: string[];
36
+ /** How candidates are discovered; `auto` when unset. */
37
+ discovery?: DiscoveryMode;
36
38
  }
37
39
  declare function parsePositiveInteger(raw: string | undefined, optionName: string, minimum: number): number | undefined;
38
40
  /**
@@ -50,5 +52,61 @@ declare function parseByteOption(raw: string | undefined, optionName: string, mi
50
52
  declare function parseCliArgs(argv: string[]): ParsedInvocation;
51
53
  /** Runs the CLI and returns the process exit code. */
52
54
  declare function main(argv?: string[]): Promise<number>;
55
+ /** Coalesce bursts of filesystem events into one run. */
56
+ declare const WATCH_DEBOUNCE_MS = 250;
57
+ /**
58
+ * Unattributed watcher events (no filename) are ignored this long after a run.
59
+ * Named source events are never ignored: that is how an edit in the quiet
60
+ * window or during a run reaches the loop.
61
+ */
62
+ declare const WATCH_SETTLE_MS = 1500;
63
+ interface WatchState {
64
+ running: boolean;
65
+ pending: boolean;
66
+ settleUntil: number;
67
+ }
68
+ interface WatchPaths {
69
+ cwd: string;
70
+ outDir: string;
71
+ tmpDir: string;
72
+ }
73
+ interface WatchEvent {
74
+ /** Absolute path, or null when `fs.watch` did not attribute the event. */
75
+ path: string | null;
76
+ /** `performance.now()` at delivery. */
77
+ now: number;
78
+ }
79
+ type WatchAction = "ignore" | "pending" | "schedule";
80
+ interface WatchDecision {
81
+ state: WatchState;
82
+ action: WatchAction;
83
+ }
84
+ declare function initialWatchState(): WatchState;
85
+ declare function beginWatchRun(state: WatchState): WatchState;
86
+ /**
87
+ * Finish one run. `schedule` is true when a source event arrived while the run
88
+ * was in flight, so exactly one follow-up run is owed.
89
+ */
90
+ declare function finishWatchRun(state: WatchState, now: number): {
91
+ state: WatchState;
92
+ schedule: boolean;
93
+ };
94
+ /**
95
+ * True only for the resolved output/staging paths and their contents.
96
+ *
97
+ * This deliberately does not match a directory just because its basename is
98
+ * `docs`: a source directory `src/docs` is not the output directory `docs`.
99
+ */
100
+ declare function isGeneratedWatchPath(candidate: string, paths: WatchPaths): boolean;
101
+ /**
102
+ * Decide what one watcher event means.
103
+ *
104
+ * - generated paths are always ignored;
105
+ * - a named source event is `pending` during a run and `schedule` otherwise,
106
+ * including inside the settle window (an edit is never swallowed);
107
+ * - an unattributed event is ignored during a run and for the settle window,
108
+ * because Windows does not always name the path our own writes produced.
109
+ */
110
+ declare function decideWatchEvent(state: WatchState, event: WatchEvent, paths: WatchPaths): WatchDecision;
53
111
 
54
- export { UsageError, main, parseByteOption, parseCliArgs, parsePositiveInteger };
112
+ export { UsageError, WATCH_DEBOUNCE_MS, WATCH_SETTLE_MS, type WatchAction, type WatchDecision, type WatchEvent, type WatchPaths, type WatchState, beginWatchRun, decideWatchEvent, finishWatchRun, initialWatchState, isGeneratedWatchPath, main, parseByteOption, parseCliArgs, parsePositiveInteger };