@omfalos/mokosh 0.3.3 → 0.4.1
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.js +30 -30
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +30 -30
- package/dist/cli.mjs.map +1 -1
- package/dist/duplication-worker.d.mts +1 -14
- package/dist/duplication-worker.d.ts +1 -14
- package/dist/index.d.mts +55 -16
- package/dist/index.d.ts +55 -16
- package/dist/index.js +21 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -21
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.js +22 -21
- package/dist/mcp.js.map +1 -1
- package/dist/mcp.mjs +23 -22
- package/dist/mcp.mjs.map +1 -1
- package/dist/tokenizer-BaF1eUBQ.d.mts +15 -0
- package/dist/tokenizer-BaF1eUBQ.d.ts +15 -0
- package/package.json +1 -1
|
@@ -1,19 +1,6 @@
|
|
|
1
|
+
import { N as NormalizedToken } from './tokenizer-BaF1eUBQ.mjs';
|
|
1
2
|
import { F as FileType } from './parse-CAKctgb6.mjs';
|
|
2
3
|
|
|
3
|
-
/**
|
|
4
|
-
* Language-agnostic source tokenizer for duplicate-code detection. Strips per-language
|
|
5
|
-
* comment syntax, then splits what remains into a normalized token stream shared by every
|
|
6
|
-
* language `DEFAULT_EXTENSIONS` covers — one generic tokenizer rather than a per-language
|
|
7
|
-
* lexer, so `findDuplicates` works uniformly across TS/JS, Python, Go, CoffeeScript,
|
|
8
|
-
* LiveScript, Lua, Gherkin, style files, and Markdown.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/** One normalized token plus the 1-based source line it came from. */
|
|
12
|
-
interface NormalizedToken {
|
|
13
|
-
text: string;
|
|
14
|
-
line: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
4
|
/** Piscina task handler: tokenizes a single file's content in a worker thread, for `findDuplicates`. */
|
|
18
5
|
|
|
19
6
|
declare function tokenizeInWorker(payload: {
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
+
import { N as NormalizedToken } from './tokenizer-BaF1eUBQ.js';
|
|
1
2
|
import { F as FileType } from './parse-CAKctgb6.js';
|
|
2
3
|
|
|
3
|
-
/**
|
|
4
|
-
* Language-agnostic source tokenizer for duplicate-code detection. Strips per-language
|
|
5
|
-
* comment syntax, then splits what remains into a normalized token stream shared by every
|
|
6
|
-
* language `DEFAULT_EXTENSIONS` covers — one generic tokenizer rather than a per-language
|
|
7
|
-
* lexer, so `findDuplicates` works uniformly across TS/JS, Python, Go, CoffeeScript,
|
|
8
|
-
* LiveScript, Lua, Gherkin, style files, and Markdown.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/** One normalized token plus the 1-based source line it came from. */
|
|
12
|
-
interface NormalizedToken {
|
|
13
|
-
text: string;
|
|
14
|
-
line: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
4
|
/** Piscina task handler: tokenizes a single file's content in a worker thread, for `findDuplicates`. */
|
|
18
5
|
|
|
19
6
|
declare function tokenizeInWorker(payload: {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { F as FileNode, C as CallEdge, I as ImportEdge, P as ParseResult, S as StructuredTag } from './types-BtSqoqbZ.mjs';
|
|
2
2
|
export { E as ExportedSymbol } from './types-BtSqoqbZ.mjs';
|
|
3
|
+
import { N as NormalizedToken } from './tokenizer-BaF1eUBQ.mjs';
|
|
3
4
|
import { F as FileType, N as NodeCategory } from './parse-CAKctgb6.mjs';
|
|
4
5
|
export { I as ImportType, T as TagKind } from './parse-CAKctgb6.mjs';
|
|
5
6
|
|
|
@@ -229,6 +230,13 @@ declare function configToGraphOptions(config: MokoshConfig | undefined): {
|
|
|
229
230
|
pathAliases: Record<string, string[]> | undefined;
|
|
230
231
|
};
|
|
231
232
|
|
|
233
|
+
/** Shared by the CLI's disk graph cache (`src/cli/graph-loader.ts`) and the MCP server's
|
|
234
|
+
* disk-persisted duplication token cache (`src/graph/duplication/token-cache-store.ts`) so both
|
|
235
|
+
* consumers agree on where "the cache dir" is — a CLI run and an MCP session against the same
|
|
236
|
+
* root end up sharing the same on-disk files. */
|
|
237
|
+
declare const DEFAULT_CACHE_DIR = "mokosh-cache";
|
|
238
|
+
/** Filename for the disk-persisted `find_duplicates` token cache within `DEFAULT_CACHE_DIR`. */
|
|
239
|
+
declare const DEFAULT_DUPLICATION_TOKEN_CACHE_FILE = "duplication-tokens.json";
|
|
232
240
|
declare const DEFAULT_IGNORE_DIRS: readonly string[];
|
|
233
241
|
declare const DEFAULT_EXTENSIONS: readonly string[];
|
|
234
242
|
interface ScanOptions {
|
|
@@ -492,6 +500,42 @@ interface DuplicateGroup {
|
|
|
492
500
|
family?: DuplicateFamily | undefined;
|
|
493
501
|
}
|
|
494
502
|
|
|
503
|
+
/** One file's cached tokenize result, fingerprinted by `mtime`/`size`/`ignoreLiterals` — any
|
|
504
|
+
* mismatch against the current `FileNode` (or against the `ignoreLiterals` this scan is running
|
|
505
|
+
* with) means the entry is stale and must be recomputed, exactly like `GraphBuilder`'s
|
|
506
|
+
* mtime+size node reuse for incremental graph builds. */
|
|
507
|
+
interface CachedFileTokens {
|
|
508
|
+
mtime: number;
|
|
509
|
+
size: number;
|
|
510
|
+
ignoreLiterals: boolean;
|
|
511
|
+
tokens: NormalizedToken[];
|
|
512
|
+
}
|
|
513
|
+
/** Caller-owned cache, keyed by project-relative path, reused across repeated `findDuplicates`
|
|
514
|
+
* calls against the same root (e.g. successive MCP tool calls in one session) so unchanged files
|
|
515
|
+
* never pay tokenizing cost twice. `findDuplicates` itself is stateless — callers that want this
|
|
516
|
+
* benefit own the `Map` and pass it in; the CLI's one-shot process has nothing to gain and omits
|
|
517
|
+
* it. See docs/adr-014-duplicate-detection-scale.md. */
|
|
518
|
+
type DuplicationTokenCache = Map<string, CachedFileTokens>;
|
|
519
|
+
/**
|
|
520
|
+
* @description Reads a serialized `DuplicationTokenCache` from a JSON disk file written by
|
|
521
|
+
* `saveTokenCacheToDisk`. Any problem reading or parsing the file — missing, corrupt JSON,
|
|
522
|
+
* or a value that doesn't look like `[path, CachedFileTokens][]` — degrades to an empty `Map`
|
|
523
|
+
* instead of throwing, since a token cache is pure acceleration, never a source of truth.
|
|
524
|
+
* @param cachePath - Path to the JSON file written by `saveTokenCacheToDisk`.
|
|
525
|
+
* @returns The reconstituted `DuplicationTokenCache`, empty if nothing usable was found.
|
|
526
|
+
*/
|
|
527
|
+
declare function loadTokenCacheFromDisk(cachePath: string): DuplicationTokenCache;
|
|
528
|
+
/**
|
|
529
|
+
* @description Serializes a `DuplicationTokenCache` to JSON and writes it to disk, creating any
|
|
530
|
+
* missing parent directories. Callers should save the same `Map` `findDuplicates` already
|
|
531
|
+
* prunes to the current candidate file set after each scan (see `./index.ts`'s post-scan
|
|
532
|
+
* pruning), so the file never grows to hold stale entries beyond what the in-memory cache
|
|
533
|
+
* already holds — no separate pruning step is needed here.
|
|
534
|
+
* @param cache - The token cache to persist.
|
|
535
|
+
* @param cachePath - Destination path; parent directories are created automatically.
|
|
536
|
+
*/
|
|
537
|
+
declare function saveTokenCacheToDisk(cache: DuplicationTokenCache, cachePath: string): void;
|
|
538
|
+
|
|
495
539
|
/** Configures whether/how tokenizing is offloaded to a `piscina` worker pool. `false` always
|
|
496
540
|
* tokenizes in-process. */
|
|
497
541
|
type ParallelTokenizingOption = boolean | {
|
|
@@ -514,11 +558,6 @@ interface FindDuplicatesOptions {
|
|
|
514
558
|
* CSS/Less/SCSS structural comparator, which already matches on literal declaration content.
|
|
515
559
|
* Set to 1 to disable. See docs/adr-013-duplicate-detection-noise-reduction.md. */
|
|
516
560
|
maxPunctuationRatio?: number | undefined;
|
|
517
|
-
/** Skip a hash bucket's O(k²) pairwise comparison once it holds more than this many locations
|
|
518
|
-
* (default 400) — bounds worst-case scan time on large repos where a single ubiquitous token
|
|
519
|
-
* window (a common import line, a boilerplate header) would otherwise blow past what a single
|
|
520
|
-
* scan can finish in. Set `Infinity` to disable. See docs/adr-014-duplicate-detection-scale.md. */
|
|
521
|
-
maxBucketSize?: number | undefined;
|
|
522
561
|
/** Caps the number of duplicate blocks returned, largest-first (default 50). */
|
|
523
562
|
limit?: number | undefined;
|
|
524
563
|
/** Directory names to exclude, matched against any path segment (default `DEFAULT_IGNORE_DIRS`
|
|
@@ -529,13 +568,15 @@ interface FindDuplicatesOptions {
|
|
|
529
568
|
* `false` always tokenizes in-process; an object overrides `minFiles`/`maxThreads`. See
|
|
530
569
|
* docs/adr-014-duplicate-detection-scale.md. */
|
|
531
570
|
parallelTokenizing?: ParallelTokenizingOption | undefined;
|
|
571
|
+
/** Optional caller-owned cache reused across calls against the same root — files whose
|
|
572
|
+
* `mtime`/`size` are unchanged since the cached entry (and whose `ignoreLiterals` matches this
|
|
573
|
+
* call's) skip tokenizing entirely. Mutated in place; omit for one-shot callers (e.g. the CLI).
|
|
574
|
+
* See {@link DuplicationTokenCache} and docs/adr-014-duplicate-detection-scale.md. */
|
|
575
|
+
tokenCache?: DuplicationTokenCache | undefined;
|
|
532
576
|
}
|
|
533
577
|
interface FindDuplicatesResult {
|
|
534
578
|
/** Duplicate blocks, largest-first, capped at `limit`. */
|
|
535
579
|
groups: DuplicateGroup[];
|
|
536
|
-
/** How many hash buckets were skipped for exceeding `maxBucketSize` — a non-zero count means
|
|
537
|
-
* results may under-report duplication that's unusually widespread (see `maxBucketSize`). */
|
|
538
|
-
skippedBuckets: number;
|
|
539
580
|
}
|
|
540
581
|
/**
|
|
541
582
|
* @description Scans every file already present in `graph` for cross-file (and within-file)
|
|
@@ -557,15 +598,13 @@ interface FindDuplicatesResult {
|
|
|
557
598
|
* token-shingle path only (CSS/Less/SCSS always match on literal declaration content);
|
|
558
599
|
* `maxPunctuationRatio` gates out token-shingle blocks that are mostly object/array-literal
|
|
559
600
|
* structural punctuation (e.g. schema/object-literal boilerplate) rather than substantive
|
|
560
|
-
* shared logic; `
|
|
561
|
-
*
|
|
562
|
-
*
|
|
563
|
-
*
|
|
564
|
-
* excluded, independent of `ignoreDirs`.
|
|
601
|
+
* shared logic; `ignoreDirs` excludes files under matching directory names; `limit` caps
|
|
602
|
+
* results; `parallelTokenizing` offloads per-file tokenizing to a worker pool once the
|
|
603
|
+
* candidate file count is large enough to be worth it. Lock files are always excluded,
|
|
604
|
+
* independent of `ignoreDirs`.
|
|
565
605
|
* @returns `groups` — duplicate blocks (each tagged with its `family`), two or more occurrences
|
|
566
606
|
* per block, every block that pairwise chain-matches another clustered into one group instead
|
|
567
|
-
* of one per pair, sorted largest-first across all families
|
|
568
|
-
* {@link FindDuplicatesResult}).
|
|
607
|
+
* of one per pair, sorted largest-first across all families.
|
|
569
608
|
*/
|
|
570
609
|
declare function findDuplicates(graph: Graph, rootDir: string, options?: FindDuplicatesOptions): Promise<FindDuplicatesResult>;
|
|
571
610
|
|
|
@@ -1430,4 +1469,4 @@ declare function createWorkspaceGraph(rootDir: string, options?: {
|
|
|
1430
1469
|
*/
|
|
1431
1470
|
declare function getAllProjectFiles(rootDir: string, options?: ScanOptions): string[];
|
|
1432
1471
|
|
|
1433
|
-
export { type ApiSurface, type ApplyTagsFileResult, type ApplyTagsResult, CALL_EDGE_TYPES, CallEdge, type CalleeEntry, type CallerEntry$1 as CallerEntry, type ChangeImpactCache, type ComplexFunctionEntry, DEFAULT_EXTENSIONS, DEFAULT_IGNORE_DIRS, type DependencyGraph, type DuplicateFamily, type DuplicateGroup, type DuplicateOccurrence, EXPORT_TRACKING_TYPES, type ExportKind, type FeatureDetectionOptions, type FeatureDomain, type FeatureGraph, type FeatureGraphOptions, type FeatureInfo, FileNode, FileType, type FindComplexFunctionsOptions, type FindDuplicatesOptions, type FunctionCallInfo, type GetAffectedOptions, type GetCallersOptions, Graph, type CallerEntry as GraphCallerEntry, type GraphExporter, IMPORT_SYMBOL_TYPES, ImportEdge, type LanguageCoverage, MermaidExporter, type ModuleResponsibility, type ModuleRole, type MokoshConfig, type MonorepoDetector, type MonorepoLayout, NodeCategory, type NodeMeta, type NodeQuery, type ParallelParsingOption, type PathWithSymbols, type ProposeTagsOptions, type PublicExport, type ResponsibilityGraph, type ScanOptions, type SerializedGraph, type SerializedWorkspaceGraph, type SlimNode, type SlimSerializedGraph, StructuredTag, type SymbolCaller, type SymbolImporter, type SymbolMatch, type SymbolPrecision, SymbolTraversalContext, type TestNodeIdentifier, type TraversalOptions, type TraversalVisitor, type TypeEdge, type TypeGraph, type TypeKind, type TypeNode, type TypeQueryResult, WorkspaceGraph, type WorkspacePackage, type WorkspacePackageSummary, type WorkspacePackagesSummary, applyConfig, applyTags, buildApiSurface, buildChangeImpactCache, buildFeatureGraph, buildResponsibilityGraph, buildTypeGraph, computeGraphHash, configToGraphOptions, createImportMap, createWorkspaceGraph, detectAllEntryPoints, detectEntryPoint, detectFeatures, detectMonorepo, filterGraph, findComplexFunctions, findDuplicates, findSymbol, getAffected, getAllProjectFiles, getCallers, getDependencies, getDependents, getLanguageCoverage, getNodeMeta, hasCoverageData, isChangeImpactCacheValid, loadChangeImpactCache, loadCoverageMap, loadMokoshConfig, parseQuery, proposeAffectedTests, proposeTags, queryCallGraph, queryChangeImpact, queryTypeGraph, registerConfigMatcher, registerMonorepoDetector, registerParser, registerTestLibrary, registerTestPattern, saveChangeImpactCache, slimSerialize, summarizeWorkspacePackages, toMermaid };
|
|
1472
|
+
export { type ApiSurface, type ApplyTagsFileResult, type ApplyTagsResult, CALL_EDGE_TYPES, type CachedFileTokens, CallEdge, type CalleeEntry, type CallerEntry$1 as CallerEntry, type ChangeImpactCache, type ComplexFunctionEntry, DEFAULT_CACHE_DIR, DEFAULT_DUPLICATION_TOKEN_CACHE_FILE, DEFAULT_EXTENSIONS, DEFAULT_IGNORE_DIRS, type DependencyGraph, type DuplicateFamily, type DuplicateGroup, type DuplicateOccurrence, type DuplicationTokenCache, EXPORT_TRACKING_TYPES, type ExportKind, type FeatureDetectionOptions, type FeatureDomain, type FeatureGraph, type FeatureGraphOptions, type FeatureInfo, FileNode, FileType, type FindComplexFunctionsOptions, type FindDuplicatesOptions, type FindDuplicatesResult, type FunctionCallInfo, type GetAffectedOptions, type GetCallersOptions, Graph, type CallerEntry as GraphCallerEntry, type GraphExporter, IMPORT_SYMBOL_TYPES, ImportEdge, type LanguageCoverage, MermaidExporter, type ModuleResponsibility, type ModuleRole, type MokoshConfig, type MonorepoDetector, type MonorepoLayout, NodeCategory, type NodeMeta, type NodeQuery, type ParallelParsingOption, type PathWithSymbols, type ProposeTagsOptions, type PublicExport, type ResponsibilityGraph, type ScanOptions, type SerializedGraph, type SerializedWorkspaceGraph, type SlimNode, type SlimSerializedGraph, StructuredTag, type SymbolCaller, type SymbolImporter, type SymbolMatch, type SymbolPrecision, SymbolTraversalContext, type TestNodeIdentifier, type TraversalOptions, type TraversalVisitor, type TypeEdge, type TypeGraph, type TypeKind, type TypeNode, type TypeQueryResult, WorkspaceGraph, type WorkspacePackage, type WorkspacePackageSummary, type WorkspacePackagesSummary, applyConfig, applyTags, buildApiSurface, buildChangeImpactCache, buildFeatureGraph, buildResponsibilityGraph, buildTypeGraph, computeGraphHash, configToGraphOptions, createImportMap, createWorkspaceGraph, detectAllEntryPoints, detectEntryPoint, detectFeatures, detectMonorepo, filterGraph, findComplexFunctions, findDuplicates, findSymbol, getAffected, getAllProjectFiles, getCallers, getDependencies, getDependents, getLanguageCoverage, getNodeMeta, hasCoverageData, isChangeImpactCacheValid, loadChangeImpactCache, loadCoverageMap, loadMokoshConfig, loadTokenCacheFromDisk, parseQuery, proposeAffectedTests, proposeTags, queryCallGraph, queryChangeImpact, queryTypeGraph, registerConfigMatcher, registerMonorepoDetector, registerParser, registerTestLibrary, registerTestPattern, saveChangeImpactCache, saveTokenCacheToDisk, slimSerialize, summarizeWorkspacePackages, toMermaid };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { F as FileNode, C as CallEdge, I as ImportEdge, P as ParseResult, S as StructuredTag } from './types-BlN-U5AM.js';
|
|
2
2
|
export { E as ExportedSymbol } from './types-BlN-U5AM.js';
|
|
3
|
+
import { N as NormalizedToken } from './tokenizer-BaF1eUBQ.js';
|
|
3
4
|
import { F as FileType, N as NodeCategory } from './parse-CAKctgb6.js';
|
|
4
5
|
export { I as ImportType, T as TagKind } from './parse-CAKctgb6.js';
|
|
5
6
|
|
|
@@ -229,6 +230,13 @@ declare function configToGraphOptions(config: MokoshConfig | undefined): {
|
|
|
229
230
|
pathAliases: Record<string, string[]> | undefined;
|
|
230
231
|
};
|
|
231
232
|
|
|
233
|
+
/** Shared by the CLI's disk graph cache (`src/cli/graph-loader.ts`) and the MCP server's
|
|
234
|
+
* disk-persisted duplication token cache (`src/graph/duplication/token-cache-store.ts`) so both
|
|
235
|
+
* consumers agree on where "the cache dir" is — a CLI run and an MCP session against the same
|
|
236
|
+
* root end up sharing the same on-disk files. */
|
|
237
|
+
declare const DEFAULT_CACHE_DIR = "mokosh-cache";
|
|
238
|
+
/** Filename for the disk-persisted `find_duplicates` token cache within `DEFAULT_CACHE_DIR`. */
|
|
239
|
+
declare const DEFAULT_DUPLICATION_TOKEN_CACHE_FILE = "duplication-tokens.json";
|
|
232
240
|
declare const DEFAULT_IGNORE_DIRS: readonly string[];
|
|
233
241
|
declare const DEFAULT_EXTENSIONS: readonly string[];
|
|
234
242
|
interface ScanOptions {
|
|
@@ -492,6 +500,42 @@ interface DuplicateGroup {
|
|
|
492
500
|
family?: DuplicateFamily | undefined;
|
|
493
501
|
}
|
|
494
502
|
|
|
503
|
+
/** One file's cached tokenize result, fingerprinted by `mtime`/`size`/`ignoreLiterals` — any
|
|
504
|
+
* mismatch against the current `FileNode` (or against the `ignoreLiterals` this scan is running
|
|
505
|
+
* with) means the entry is stale and must be recomputed, exactly like `GraphBuilder`'s
|
|
506
|
+
* mtime+size node reuse for incremental graph builds. */
|
|
507
|
+
interface CachedFileTokens {
|
|
508
|
+
mtime: number;
|
|
509
|
+
size: number;
|
|
510
|
+
ignoreLiterals: boolean;
|
|
511
|
+
tokens: NormalizedToken[];
|
|
512
|
+
}
|
|
513
|
+
/** Caller-owned cache, keyed by project-relative path, reused across repeated `findDuplicates`
|
|
514
|
+
* calls against the same root (e.g. successive MCP tool calls in one session) so unchanged files
|
|
515
|
+
* never pay tokenizing cost twice. `findDuplicates` itself is stateless — callers that want this
|
|
516
|
+
* benefit own the `Map` and pass it in; the CLI's one-shot process has nothing to gain and omits
|
|
517
|
+
* it. See docs/adr-014-duplicate-detection-scale.md. */
|
|
518
|
+
type DuplicationTokenCache = Map<string, CachedFileTokens>;
|
|
519
|
+
/**
|
|
520
|
+
* @description Reads a serialized `DuplicationTokenCache` from a JSON disk file written by
|
|
521
|
+
* `saveTokenCacheToDisk`. Any problem reading or parsing the file — missing, corrupt JSON,
|
|
522
|
+
* or a value that doesn't look like `[path, CachedFileTokens][]` — degrades to an empty `Map`
|
|
523
|
+
* instead of throwing, since a token cache is pure acceleration, never a source of truth.
|
|
524
|
+
* @param cachePath - Path to the JSON file written by `saveTokenCacheToDisk`.
|
|
525
|
+
* @returns The reconstituted `DuplicationTokenCache`, empty if nothing usable was found.
|
|
526
|
+
*/
|
|
527
|
+
declare function loadTokenCacheFromDisk(cachePath: string): DuplicationTokenCache;
|
|
528
|
+
/**
|
|
529
|
+
* @description Serializes a `DuplicationTokenCache` to JSON and writes it to disk, creating any
|
|
530
|
+
* missing parent directories. Callers should save the same `Map` `findDuplicates` already
|
|
531
|
+
* prunes to the current candidate file set after each scan (see `./index.ts`'s post-scan
|
|
532
|
+
* pruning), so the file never grows to hold stale entries beyond what the in-memory cache
|
|
533
|
+
* already holds — no separate pruning step is needed here.
|
|
534
|
+
* @param cache - The token cache to persist.
|
|
535
|
+
* @param cachePath - Destination path; parent directories are created automatically.
|
|
536
|
+
*/
|
|
537
|
+
declare function saveTokenCacheToDisk(cache: DuplicationTokenCache, cachePath: string): void;
|
|
538
|
+
|
|
495
539
|
/** Configures whether/how tokenizing is offloaded to a `piscina` worker pool. `false` always
|
|
496
540
|
* tokenizes in-process. */
|
|
497
541
|
type ParallelTokenizingOption = boolean | {
|
|
@@ -514,11 +558,6 @@ interface FindDuplicatesOptions {
|
|
|
514
558
|
* CSS/Less/SCSS structural comparator, which already matches on literal declaration content.
|
|
515
559
|
* Set to 1 to disable. See docs/adr-013-duplicate-detection-noise-reduction.md. */
|
|
516
560
|
maxPunctuationRatio?: number | undefined;
|
|
517
|
-
/** Skip a hash bucket's O(k²) pairwise comparison once it holds more than this many locations
|
|
518
|
-
* (default 400) — bounds worst-case scan time on large repos where a single ubiquitous token
|
|
519
|
-
* window (a common import line, a boilerplate header) would otherwise blow past what a single
|
|
520
|
-
* scan can finish in. Set `Infinity` to disable. See docs/adr-014-duplicate-detection-scale.md. */
|
|
521
|
-
maxBucketSize?: number | undefined;
|
|
522
561
|
/** Caps the number of duplicate blocks returned, largest-first (default 50). */
|
|
523
562
|
limit?: number | undefined;
|
|
524
563
|
/** Directory names to exclude, matched against any path segment (default `DEFAULT_IGNORE_DIRS`
|
|
@@ -529,13 +568,15 @@ interface FindDuplicatesOptions {
|
|
|
529
568
|
* `false` always tokenizes in-process; an object overrides `minFiles`/`maxThreads`. See
|
|
530
569
|
* docs/adr-014-duplicate-detection-scale.md. */
|
|
531
570
|
parallelTokenizing?: ParallelTokenizingOption | undefined;
|
|
571
|
+
/** Optional caller-owned cache reused across calls against the same root — files whose
|
|
572
|
+
* `mtime`/`size` are unchanged since the cached entry (and whose `ignoreLiterals` matches this
|
|
573
|
+
* call's) skip tokenizing entirely. Mutated in place; omit for one-shot callers (e.g. the CLI).
|
|
574
|
+
* See {@link DuplicationTokenCache} and docs/adr-014-duplicate-detection-scale.md. */
|
|
575
|
+
tokenCache?: DuplicationTokenCache | undefined;
|
|
532
576
|
}
|
|
533
577
|
interface FindDuplicatesResult {
|
|
534
578
|
/** Duplicate blocks, largest-first, capped at `limit`. */
|
|
535
579
|
groups: DuplicateGroup[];
|
|
536
|
-
/** How many hash buckets were skipped for exceeding `maxBucketSize` — a non-zero count means
|
|
537
|
-
* results may under-report duplication that's unusually widespread (see `maxBucketSize`). */
|
|
538
|
-
skippedBuckets: number;
|
|
539
580
|
}
|
|
540
581
|
/**
|
|
541
582
|
* @description Scans every file already present in `graph` for cross-file (and within-file)
|
|
@@ -557,15 +598,13 @@ interface FindDuplicatesResult {
|
|
|
557
598
|
* token-shingle path only (CSS/Less/SCSS always match on literal declaration content);
|
|
558
599
|
* `maxPunctuationRatio` gates out token-shingle blocks that are mostly object/array-literal
|
|
559
600
|
* structural punctuation (e.g. schema/object-literal boilerplate) rather than substantive
|
|
560
|
-
* shared logic; `
|
|
561
|
-
*
|
|
562
|
-
*
|
|
563
|
-
*
|
|
564
|
-
* excluded, independent of `ignoreDirs`.
|
|
601
|
+
* shared logic; `ignoreDirs` excludes files under matching directory names; `limit` caps
|
|
602
|
+
* results; `parallelTokenizing` offloads per-file tokenizing to a worker pool once the
|
|
603
|
+
* candidate file count is large enough to be worth it. Lock files are always excluded,
|
|
604
|
+
* independent of `ignoreDirs`.
|
|
565
605
|
* @returns `groups` — duplicate blocks (each tagged with its `family`), two or more occurrences
|
|
566
606
|
* per block, every block that pairwise chain-matches another clustered into one group instead
|
|
567
|
-
* of one per pair, sorted largest-first across all families
|
|
568
|
-
* {@link FindDuplicatesResult}).
|
|
607
|
+
* of one per pair, sorted largest-first across all families.
|
|
569
608
|
*/
|
|
570
609
|
declare function findDuplicates(graph: Graph, rootDir: string, options?: FindDuplicatesOptions): Promise<FindDuplicatesResult>;
|
|
571
610
|
|
|
@@ -1430,4 +1469,4 @@ declare function createWorkspaceGraph(rootDir: string, options?: {
|
|
|
1430
1469
|
*/
|
|
1431
1470
|
declare function getAllProjectFiles(rootDir: string, options?: ScanOptions): string[];
|
|
1432
1471
|
|
|
1433
|
-
export { type ApiSurface, type ApplyTagsFileResult, type ApplyTagsResult, CALL_EDGE_TYPES, CallEdge, type CalleeEntry, type CallerEntry$1 as CallerEntry, type ChangeImpactCache, type ComplexFunctionEntry, DEFAULT_EXTENSIONS, DEFAULT_IGNORE_DIRS, type DependencyGraph, type DuplicateFamily, type DuplicateGroup, type DuplicateOccurrence, EXPORT_TRACKING_TYPES, type ExportKind, type FeatureDetectionOptions, type FeatureDomain, type FeatureGraph, type FeatureGraphOptions, type FeatureInfo, FileNode, FileType, type FindComplexFunctionsOptions, type FindDuplicatesOptions, type FunctionCallInfo, type GetAffectedOptions, type GetCallersOptions, Graph, type CallerEntry as GraphCallerEntry, type GraphExporter, IMPORT_SYMBOL_TYPES, ImportEdge, type LanguageCoverage, MermaidExporter, type ModuleResponsibility, type ModuleRole, type MokoshConfig, type MonorepoDetector, type MonorepoLayout, NodeCategory, type NodeMeta, type NodeQuery, type ParallelParsingOption, type PathWithSymbols, type ProposeTagsOptions, type PublicExport, type ResponsibilityGraph, type ScanOptions, type SerializedGraph, type SerializedWorkspaceGraph, type SlimNode, type SlimSerializedGraph, StructuredTag, type SymbolCaller, type SymbolImporter, type SymbolMatch, type SymbolPrecision, SymbolTraversalContext, type TestNodeIdentifier, type TraversalOptions, type TraversalVisitor, type TypeEdge, type TypeGraph, type TypeKind, type TypeNode, type TypeQueryResult, WorkspaceGraph, type WorkspacePackage, type WorkspacePackageSummary, type WorkspacePackagesSummary, applyConfig, applyTags, buildApiSurface, buildChangeImpactCache, buildFeatureGraph, buildResponsibilityGraph, buildTypeGraph, computeGraphHash, configToGraphOptions, createImportMap, createWorkspaceGraph, detectAllEntryPoints, detectEntryPoint, detectFeatures, detectMonorepo, filterGraph, findComplexFunctions, findDuplicates, findSymbol, getAffected, getAllProjectFiles, getCallers, getDependencies, getDependents, getLanguageCoverage, getNodeMeta, hasCoverageData, isChangeImpactCacheValid, loadChangeImpactCache, loadCoverageMap, loadMokoshConfig, parseQuery, proposeAffectedTests, proposeTags, queryCallGraph, queryChangeImpact, queryTypeGraph, registerConfigMatcher, registerMonorepoDetector, registerParser, registerTestLibrary, registerTestPattern, saveChangeImpactCache, slimSerialize, summarizeWorkspacePackages, toMermaid };
|
|
1472
|
+
export { type ApiSurface, type ApplyTagsFileResult, type ApplyTagsResult, CALL_EDGE_TYPES, type CachedFileTokens, CallEdge, type CalleeEntry, type CallerEntry$1 as CallerEntry, type ChangeImpactCache, type ComplexFunctionEntry, DEFAULT_CACHE_DIR, DEFAULT_DUPLICATION_TOKEN_CACHE_FILE, DEFAULT_EXTENSIONS, DEFAULT_IGNORE_DIRS, type DependencyGraph, type DuplicateFamily, type DuplicateGroup, type DuplicateOccurrence, type DuplicationTokenCache, EXPORT_TRACKING_TYPES, type ExportKind, type FeatureDetectionOptions, type FeatureDomain, type FeatureGraph, type FeatureGraphOptions, type FeatureInfo, FileNode, FileType, type FindComplexFunctionsOptions, type FindDuplicatesOptions, type FindDuplicatesResult, type FunctionCallInfo, type GetAffectedOptions, type GetCallersOptions, Graph, type CallerEntry as GraphCallerEntry, type GraphExporter, IMPORT_SYMBOL_TYPES, ImportEdge, type LanguageCoverage, MermaidExporter, type ModuleResponsibility, type ModuleRole, type MokoshConfig, type MonorepoDetector, type MonorepoLayout, NodeCategory, type NodeMeta, type NodeQuery, type ParallelParsingOption, type PathWithSymbols, type ProposeTagsOptions, type PublicExport, type ResponsibilityGraph, type ScanOptions, type SerializedGraph, type SerializedWorkspaceGraph, type SlimNode, type SlimSerializedGraph, StructuredTag, type SymbolCaller, type SymbolImporter, type SymbolMatch, type SymbolPrecision, SymbolTraversalContext, type TestNodeIdentifier, type TraversalOptions, type TraversalVisitor, type TypeEdge, type TypeGraph, type TypeKind, type TypeNode, type TypeQueryResult, WorkspaceGraph, type WorkspacePackage, type WorkspacePackageSummary, type WorkspacePackagesSummary, applyConfig, applyTags, buildApiSurface, buildChangeImpactCache, buildFeatureGraph, buildResponsibilityGraph, buildTypeGraph, computeGraphHash, configToGraphOptions, createImportMap, createWorkspaceGraph, detectAllEntryPoints, detectEntryPoint, detectFeatures, detectMonorepo, filterGraph, findComplexFunctions, findDuplicates, findSymbol, getAffected, getAllProjectFiles, getCallers, getDependencies, getDependents, getLanguageCoverage, getNodeMeta, hasCoverageData, isChangeImpactCacheValid, loadChangeImpactCache, loadCoverageMap, loadMokoshConfig, loadTokenCacheFromDisk, parseQuery, proposeAffectedTests, proposeTags, queryCallGraph, queryChangeImpact, queryTypeGraph, registerConfigMatcher, registerMonorepoDetector, registerParser, registerTestLibrary, registerTestPattern, saveChangeImpactCache, saveTokenCacheToDisk, slimSerialize, summarizeWorkspacePackages, toMermaid };
|