@ajdev0/token-shrink 2.0.1 → 2.0.3

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.
@@ -1,96 +0,0 @@
1
- import * as chokidar from 'chokidar';
2
- import { Matcher, FSWatcher } from 'chokidar';
3
- import * as fastify from 'fastify';
4
- import * as http from 'http';
5
-
6
- /**
7
- * Incremental synchronization layer (Phase 3).
8
- *
9
- * - Watches the repository with chokidar (ignoring vendor/build dirs).
10
- * - On add/change, hashes the file and, if the hash changed, re-prunes it and
11
- * updates the in-memory graph cache.
12
- * - Extracts import/require specifiers from each file and normalizes relative
13
- * and aliased paths to absolute file paths on disk.
14
- *
15
- * The graph cache is shared with the Context Assembler, which reads ring-1
16
- * skeletons out of it.
17
- */
18
-
19
- /** Default paths that will never be indexed or watched. */
20
- declare const DEFAULT_IGNORED: RegExp[];
21
- interface CacheEntry {
22
- /** sha1 of the last-indexed file content. */
23
- hash: string;
24
- /** Pruned skeleton for this file. */
25
- skeleton: string;
26
- /** The language name used to prune it (or null if unsupported). */
27
- language: string | null;
28
- /** Absolute paths of the files this file imports. */
29
- imports: string[];
30
- }
31
- type GraphCache = Map<string, CacheEntry>;
32
- declare class ContextCache {
33
- readonly entries: GraphCache;
34
- private initPromise;
35
- ensureInit(): Promise<void>;
36
- /** Returns the cached skeleton for a file, if present. */
37
- getSkeleton(filePath: string): CacheEntry | null;
38
- get imports(): GraphCache;
39
- }
40
- /** Compute a sha1 of a string. */
41
- declare function hashOf(text: string): string;
42
- /**
43
- * Extract import/require specifiers from source text using a robust,
44
- * language-agnostic regex (AST-based import queries are grammar-fragile and
45
- * occasionally malformed; regex covers the common import forms across JS/TS,
46
- * Python, Go, Rust, Dart, Swift, Java, Kotlin, PHP, C/C++).
47
- * Returns the matched specifier strings (may be relative or absolute).
48
- */
49
- declare function extractImports(_filePath: string, source: string): string[];
50
- /** Normalize a specifier to an absolute file path when it resolves locally. */
51
- declare function resolveImport(importer: string, specifier: string, root: string): string | null;
52
- interface SyncOptions {
53
- root: string;
54
- ignored?: Matcher[];
55
- onIndexed?: (filePath: string, entry: CacheEntry) => void;
56
- }
57
- /**
58
- * Watch a project root and keep the graph cache fresh. Returns the cache and
59
- * a close() handle. `prune` is awaited per change to keep hot-reload latency
60
- * predictable.
61
- */
62
- declare function createWatcher(opts: SyncOptions): {
63
- cache: ContextCache;
64
- watcher: FSWatcher;
65
- /** Index an existing file right now (bypasses the watcher). */
66
- index: (filePath: string) => Promise<void>;
67
- /**
68
- * Index the whole tree once (cold start). Returns the number of files
69
- * successfully indexed.
70
- */
71
- indexAll(): Promise<number>;
72
- close: () => Promise<void>;
73
- };
74
-
75
- interface CliOptions {
76
- port?: number;
77
- host?: string;
78
- root?: string;
79
- ignored?: Matcher[];
80
- silent?: boolean;
81
- }
82
- /** Start the Fastify server; returns the running instance + watcher handle. */
83
- declare function startServer(opts?: CliOptions): Promise<{
84
- app: fastify.FastifyInstance<http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>, http.IncomingMessage, http.ServerResponse<http.IncomingMessage>, fastify.FastifyBaseLogger, fastify.FastifyTypeProviderDefault> & PromiseLike<fastify.FastifyInstance<http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>, http.IncomingMessage, http.ServerResponse<http.IncomingMessage>, fastify.FastifyBaseLogger, fastify.FastifyTypeProviderDefault>> & {
85
- __linterBrands: "SafePromiseLike";
86
- };
87
- watcher: {
88
- cache: ContextCache;
89
- watcher: chokidar.FSWatcher;
90
- index: (filePath: string) => Promise<void>;
91
- indexAll(): Promise<number>;
92
- close: () => Promise<void>;
93
- };
94
- }>;
95
-
96
- export { type CacheEntry as C, DEFAULT_IGNORED as D, type GraphCache as G, type SyncOptions as S, type CliOptions as a, createWatcher as c, extractImports as e, hashOf as h, resolveImport as r, startServer as s };
@@ -1,96 +0,0 @@
1
- import * as chokidar from 'chokidar';
2
- import { Matcher, FSWatcher } from 'chokidar';
3
- import * as fastify from 'fastify';
4
- import * as http from 'http';
5
-
6
- /**
7
- * Incremental synchronization layer (Phase 3).
8
- *
9
- * - Watches the repository with chokidar (ignoring vendor/build dirs).
10
- * - On add/change, hashes the file and, if the hash changed, re-prunes it and
11
- * updates the in-memory graph cache.
12
- * - Extracts import/require specifiers from each file and normalizes relative
13
- * and aliased paths to absolute file paths on disk.
14
- *
15
- * The graph cache is shared with the Context Assembler, which reads ring-1
16
- * skeletons out of it.
17
- */
18
-
19
- /** Default paths that will never be indexed or watched. */
20
- declare const DEFAULT_IGNORED: RegExp[];
21
- interface CacheEntry {
22
- /** sha1 of the last-indexed file content. */
23
- hash: string;
24
- /** Pruned skeleton for this file. */
25
- skeleton: string;
26
- /** The language name used to prune it (or null if unsupported). */
27
- language: string | null;
28
- /** Absolute paths of the files this file imports. */
29
- imports: string[];
30
- }
31
- type GraphCache = Map<string, CacheEntry>;
32
- declare class ContextCache {
33
- readonly entries: GraphCache;
34
- private initPromise;
35
- ensureInit(): Promise<void>;
36
- /** Returns the cached skeleton for a file, if present. */
37
- getSkeleton(filePath: string): CacheEntry | null;
38
- get imports(): GraphCache;
39
- }
40
- /** Compute a sha1 of a string. */
41
- declare function hashOf(text: string): string;
42
- /**
43
- * Extract import/require specifiers from source text using a robust,
44
- * language-agnostic regex (AST-based import queries are grammar-fragile and
45
- * occasionally malformed; regex covers the common import forms across JS/TS,
46
- * Python, Go, Rust, Dart, Swift, Java, Kotlin, PHP, C/C++).
47
- * Returns the matched specifier strings (may be relative or absolute).
48
- */
49
- declare function extractImports(_filePath: string, source: string): string[];
50
- /** Normalize a specifier to an absolute file path when it resolves locally. */
51
- declare function resolveImport(importer: string, specifier: string, root: string): string | null;
52
- interface SyncOptions {
53
- root: string;
54
- ignored?: Matcher[];
55
- onIndexed?: (filePath: string, entry: CacheEntry) => void;
56
- }
57
- /**
58
- * Watch a project root and keep the graph cache fresh. Returns the cache and
59
- * a close() handle. `prune` is awaited per change to keep hot-reload latency
60
- * predictable.
61
- */
62
- declare function createWatcher(opts: SyncOptions): {
63
- cache: ContextCache;
64
- watcher: FSWatcher;
65
- /** Index an existing file right now (bypasses the watcher). */
66
- index: (filePath: string) => Promise<void>;
67
- /**
68
- * Index the whole tree once (cold start). Returns the number of files
69
- * successfully indexed.
70
- */
71
- indexAll(): Promise<number>;
72
- close: () => Promise<void>;
73
- };
74
-
75
- interface CliOptions {
76
- port?: number;
77
- host?: string;
78
- root?: string;
79
- ignored?: Matcher[];
80
- silent?: boolean;
81
- }
82
- /** Start the Fastify server; returns the running instance + watcher handle. */
83
- declare function startServer(opts?: CliOptions): Promise<{
84
- app: fastify.FastifyInstance<http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>, http.IncomingMessage, http.ServerResponse<http.IncomingMessage>, fastify.FastifyBaseLogger, fastify.FastifyTypeProviderDefault> & PromiseLike<fastify.FastifyInstance<http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>, http.IncomingMessage, http.ServerResponse<http.IncomingMessage>, fastify.FastifyBaseLogger, fastify.FastifyTypeProviderDefault>> & {
85
- __linterBrands: "SafePromiseLike";
86
- };
87
- watcher: {
88
- cache: ContextCache;
89
- watcher: chokidar.FSWatcher;
90
- index: (filePath: string) => Promise<void>;
91
- indexAll(): Promise<number>;
92
- close: () => Promise<void>;
93
- };
94
- }>;
95
-
96
- export { type CacheEntry as C, DEFAULT_IGNORED as D, type GraphCache as G, type SyncOptions as S, type CliOptions as a, createWatcher as c, extractImports as e, hashOf as h, resolveImport as r, startServer as s };