@mnemonik/shared 6.47.0 → 6.50.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/codeScanner.d.ts +79 -2
- package/dist/codeScanner.d.ts.map +1 -1
- package/dist/codeScanner.js +394 -68
- package/dist/codeScanner.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/secretPatterns.d.ts +25 -1
- package/dist/secretPatterns.d.ts.map +1 -1
- package/dist/secretPatterns.js +182 -2
- package/dist/secretPatterns.js.map +1 -1
- package/package.json +1 -1
- package/src/codeScanner.ts +405 -68
- package/src/index.ts +11 -1
- package/src/secretPatterns.ts +180 -2
package/dist/codeScanner.d.ts
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Code Scanner - Parse and chunk source files for embedding
|
|
3
3
|
*/
|
|
4
|
+
/**
|
|
5
|
+
* The one file-size ceiling in Mnemonik. A file at or below this is scanned,
|
|
6
|
+
* chunked, AND pushed verbatim; a file above it is uniformly outside the
|
|
7
|
+
* system — not scanned, not chunked, not citable. "Scanned ⟺ verifiable".
|
|
8
|
+
*
|
|
9
|
+
* This is deliberately a single exported constant rather than a number
|
|
10
|
+
* repeated per layer. Three ceilings previously existed and had drifted:
|
|
11
|
+
* the scan ceiling here (10 MB), a 5 MB whole-file push cap in the scanner
|
|
12
|
+
* daemon, and a 5 MB `content` cap in the server's scanPushSchema. Files
|
|
13
|
+
* between 5 and 10 MB were therefore indexed as chunks whose source content
|
|
14
|
+
* the server never received — chunks that could be retrieved but never
|
|
15
|
+
* verified against, a silent fidelity split. Every consumer now imports this:
|
|
16
|
+
*
|
|
17
|
+
* - `CodeScanner.MAX_FILE_SIZE` / `collectAuthorityFilesWithStatus` (this file)
|
|
18
|
+
* - `MAX_PUSH_CONTENT_BYTES` (packages/scanner/src/daemon.ts)
|
|
19
|
+
* - `scanFileSchema.content` (src/server/routes/schemas.ts)
|
|
20
|
+
*
|
|
21
|
+
* Raising it means widening the stored-content pipe end to end; do not raise
|
|
22
|
+
* one site alone.
|
|
23
|
+
*/
|
|
24
|
+
export declare const MAX_SCANNED_FILE_BYTES: number;
|
|
4
25
|
export interface CodeChunk {
|
|
5
26
|
content: string;
|
|
6
27
|
filePath: string;
|
|
@@ -34,6 +55,46 @@ export interface ScanOptions {
|
|
|
34
55
|
* project-specific cases (`vendor/`, custom dirs) hierarchically.
|
|
35
56
|
*/
|
|
36
57
|
export declare const BUILT_IN_IGNORE_DIRS: readonly string[];
|
|
58
|
+
/**
|
|
59
|
+
* True when `relPath` names a file whose contents are credentials. Applied
|
|
60
|
+
* by `shouldIgnore` (every walker: directory scan, explicit file lists, and
|
|
61
|
+
* the authority-file walk) and by `makeIgnoreMatcher` (server-side backstop
|
|
62
|
+
* for older or misbehaving daemons). Accepts OS-native or POSIX separators.
|
|
63
|
+
*/
|
|
64
|
+
export declare function isSecretFile(relPath: string): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Every file type the scanner will chunk, by extension. Matched
|
|
67
|
+
* case-INSENSITIVELY (see `isIncludedExtension`), so lowercase spellings here
|
|
68
|
+
* also cover `.R`, `.SQL`, `.PS1` and the uppercase `.C`/`.H` of older trees.
|
|
69
|
+
*
|
|
70
|
+
* Exported because this list IS the product's language coverage: a project
|
|
71
|
+
* written in something absent from it indexes zero code, and `code_search`
|
|
72
|
+
* reports that as "no indexed matches" rather than "I do not read this
|
|
73
|
+
* language" — invisible to the developer and to us. Coverage is a separate
|
|
74
|
+
* dial from parse quality: a language with no structured extractor falls
|
|
75
|
+
* through to `chunkRaw`, which is what Go, Java and C already get in
|
|
76
|
+
* production, and crude chunks beat no chunks by an enormous margin.
|
|
77
|
+
*
|
|
78
|
+
* Data formats (`.json`, `.yaml`, `.toml`, `.lock`) are deliberately absent:
|
|
79
|
+
* the ones that carry meaning are already collected verbatim by
|
|
80
|
+
* `AUTHORITY_FILE_MATCHERS`, and blanket-indexing the extension would pull in
|
|
81
|
+
* lockfiles and generated output. `.tfvars` is absent for a different reason —
|
|
82
|
+
* `terraform.tfvars` is a conventional home for provider credentials and
|
|
83
|
+
* `isSecretFile` now excludes it outright.
|
|
84
|
+
*/
|
|
85
|
+
export declare const DEFAULT_INCLUDE_EXTENSIONS: readonly string[];
|
|
86
|
+
/**
|
|
87
|
+
* Language string for a file path or a bare extension, `'unknown'` when the
|
|
88
|
+
* extension is unmapped. A free function rather than a method because callers
|
|
89
|
+
* that never scan anything (AST grammar resolution, server-side symbol
|
|
90
|
+
* preference) need the same answer without constructing a scanner.
|
|
91
|
+
*/
|
|
92
|
+
export declare function languageForExtension(filePathOrExt: string): string;
|
|
93
|
+
/**
|
|
94
|
+
* True when `relPath` is collected verbatim as authority content and must not
|
|
95
|
+
* additionally be chunked. Accepts OS-native or POSIX separators.
|
|
96
|
+
*/
|
|
97
|
+
export declare function isAuthorityOnlyPath(relPath: string): boolean;
|
|
37
98
|
/**
|
|
38
99
|
* Matchers for authority manifest / config / CI files whose verbatim content
|
|
39
100
|
* is collected by `collectAuthorityFiles` and pushed to the server for
|
|
@@ -75,7 +136,21 @@ export declare function makeIgnoreMatcher(extraPatterns?: readonly string[]): (r
|
|
|
75
136
|
export declare function isGitBoundary(dirPath: string): Promise<boolean>;
|
|
76
137
|
export declare class CodeScanner {
|
|
77
138
|
private options;
|
|
139
|
+
/**
|
|
140
|
+
* `includeExtensions` folded to lowercase for matching. The gate used to
|
|
141
|
+
* compare `extname()` verbatim while `detectLanguage` lowercased, so a
|
|
142
|
+
* project spelling its files the canonical way — `.R` for R, `.SQL`/`.PS1`
|
|
143
|
+
* on Windows, `.C`/`.H` in older C trees — indexed zero of them and nothing
|
|
144
|
+
* said why.
|
|
145
|
+
*/
|
|
146
|
+
private readonly includeExtensionSet;
|
|
78
147
|
constructor(options?: ScanOptions);
|
|
148
|
+
/**
|
|
149
|
+
* The chunkable-file gate, shared by every walker and by the explicit
|
|
150
|
+
* file-list path so all three agree on what exists. `relPath` is the path
|
|
151
|
+
* relative to the scan root (OS-native separators accepted).
|
|
152
|
+
*/
|
|
153
|
+
private isChunkable;
|
|
79
154
|
/**
|
|
80
155
|
* Read `.gitignore` + `.mnemonikignore` in `absDir` and compile them into one
|
|
81
156
|
* ignore layer (the two files are unioned — `.mnemonikignore` is just an
|
|
@@ -196,8 +271,10 @@ export declare class CodeScanner {
|
|
|
196
271
|
*/
|
|
197
272
|
private shouldIgnore;
|
|
198
273
|
/**
|
|
199
|
-
* Parse a file and extract code chunks
|
|
200
|
-
*
|
|
274
|
+
* Parse a file and extract code chunks.
|
|
275
|
+
* Size limit is the shared `MAX_SCANNED_FILE_BYTES` ceiling — the same
|
|
276
|
+
* number the daemon and the server's scanPushSchema enforce, so anything
|
|
277
|
+
* chunked here can always be shipped and stored verbatim.
|
|
201
278
|
*/
|
|
202
279
|
private static readonly MAX_FILE_SIZE;
|
|
203
280
|
private parseFile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codeScanner.d.ts","sourceRoot":"","sources":["../src/codeScanner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAeH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,WAAW;IAC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