@mnemonik/shared 7.119.2 → 7.120.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/codeScanner.d.ts +87 -18
- package/dist/codeScanner.d.ts.map +1 -1
- package/dist/codeScanner.js +229 -74
- package/dist/codeScanner.js.map +1 -1
- package/dist/gitEditDetector.d.ts +91 -0
- package/dist/gitEditDetector.d.ts.map +1 -1
- package/dist/gitEditDetector.js +515 -3
- package/dist/gitEditDetector.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/indexClassifier.d.ts +178 -0
- package/dist/indexClassifier.d.ts.map +1 -0
- package/dist/indexClassifier.js +585 -0
- package/dist/indexClassifier.js.map +1 -0
- package/dist/indexJudge.d.ts +50 -0
- package/dist/indexJudge.d.ts.map +1 -0
- package/dist/indexJudge.js +116 -0
- package/dist/indexJudge.js.map +1 -0
- package/package.json +1 -1
- package/src/codeScanner.ts +305 -81
- package/src/gitEditDetector.ts +578 -3
- package/src/index.ts +34 -0
- package/src/indexClassifier.ts +681 -0
- package/src/indexJudge.ts +149 -0
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
export { MCP_INSTRUCTIONS, MCP_INSTRUCTIONS_RAW, getMcpInstructions } from './instructions.js';
|
|
8
8
|
export { USAGE_GUIDE } from './usageGuide.js';
|
|
9
9
|
export declare const SCANNER_HEARTBEAT_INTERVAL_MS = 300000;
|
|
10
|
-
export { CodeScanner, MAX_SCANNED_FILE_BYTES, MAX_PUSH_CHUNK_CONTENT_LENGTH, AUTHORITY_FILE_MATCHERS, BUILT_IN_IGNORE_DIRS, DEFAULT_INCLUDE_EXTENSIONS, languageForExtension, makeIgnoreMatcher, isGitBoundary, FIXTURE_PATH_RE, isFixturePath, isSecretFile, isAuthorityOnlyPath, isCursorRulePath, logAstCapabilityOnce, type CodeChunk, type ScanOptions, } from './codeScanner.js';
|
|
10
|
+
export { CodeScanner, MAX_SCANNED_FILE_BYTES, MAX_PUSH_CHUNK_CONTENT_LENGTH, AUTHORITY_FILE_MATCHERS, BUILT_IN_IGNORE_DIRS, DEFAULT_INCLUDE_EXTENSIONS, languageForExtension, makeIgnoreMatcher, isGitBoundary, FIXTURE_PATH_RE, isFixturePath, isSecretFile, isAuthorityOnlyPath, isCursorRulePath, logAstCapabilityOnce, type CodeChunk, type ScanOptions, type IndexExcludedFile, type IndexRuleFiles, } from './codeScanner.js';
|
|
11
|
+
export { INDEX_EXCLUSION_REASONS, BINARY_SNIFF_BYTES, MINIFIED_AVERAGE_LINE_LENGTH, MINIFIED_LONG_LINE_BYTES, DATA_DUMP_INSERT_THRESHOLD, NESTED_IGNORE_TAG, GITATTRIBUTES_TAG, classifyForIndex, softDefaultForPath, softDefaultForDirectory, softDefaultForContent, parseGitattributes, linguistAttributesFor, gitattributesCanReinclude, indexExclusionLabel, indexExclusionNotice, isIndexExclusionReason, encodeNestedIgnoreLine, encodeGitattributesLine, decodeIndexRules, type IndexExclusionReason, type IndexExclusion, type IndexClassification, type IgnoreFileVerdict, type GitattributesLayer, type GitattributesRule, type LinguistAttributes, type ClassifyForIndexOptions, type DecodedIndexRules, } from './indexClassifier.js';
|
|
12
|
+
export { makeIndexJudge, type IndexJudge, type IndexJudgement } from './indexJudge.js';
|
|
11
13
|
export { AST_LANGUAGE_IDS, QUERY_CHAIN, VENDORED_ARTIFACT_DIR, astArtifactReport, astCapabilityReport, grammarArtifactBasename, loadGrammar, loadedGrammarIds, resolveAstLanguage, type AstLanguageId, type GrammarBinding, type GrammarLoad, type GrammarUnavailableReason, } from './ast/grammars.js';
|
|
12
14
|
export { MAX_AST_PARSE_BYTES, chunkWithAst, type AstChunk, type AstChunkResult, } from './ast/astChunker.js';
|
|
13
15
|
export { SECRET_PATTERNS, SECRET_REDACTION_PLACEHOLDER, scrubSecrets, redactHighEntropyTokens, } from './secretPatterns.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,eAAO,MAAM,6BAA6B,SAAU,CAAC;AACrD,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,SAAS,EACd,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,eAAO,MAAM,6BAA6B,SAAU,CAAC;AACrD,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,cAAc,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,4BAA4B,EAC5B,wBAAwB,EACxB,0BAA0B,EAC1B,i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,EAC/B,uBAAuB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAEhC,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,GACd,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EACL,yBAAyB,EACzB,iCAAiC,EACjC,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,wBAAwB,EACxB,6BAA6B,EAC7B,sBAAsB,EACtB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,8 @@ export { MCP_INSTRUCTIONS, MCP_INSTRUCTIONS_RAW, getMcpInstructions } from './in
|
|
|
8
8
|
export { USAGE_GUIDE } from './usageGuide.js';
|
|
9
9
|
export const SCANNER_HEARTBEAT_INTERVAL_MS = 300_000;
|
|
10
10
|
export { CodeScanner, MAX_SCANNED_FILE_BYTES, MAX_PUSH_CHUNK_CONTENT_LENGTH, AUTHORITY_FILE_MATCHERS, BUILT_IN_IGNORE_DIRS, DEFAULT_INCLUDE_EXTENSIONS, languageForExtension, makeIgnoreMatcher, isGitBoundary, FIXTURE_PATH_RE, isFixturePath, isSecretFile, isAuthorityOnlyPath, isCursorRulePath, logAstCapabilityOnce, } from './codeScanner.js';
|
|
11
|
+
export { INDEX_EXCLUSION_REASONS, BINARY_SNIFF_BYTES, MINIFIED_AVERAGE_LINE_LENGTH, MINIFIED_LONG_LINE_BYTES, DATA_DUMP_INSERT_THRESHOLD, NESTED_IGNORE_TAG, GITATTRIBUTES_TAG, classifyForIndex, softDefaultForPath, softDefaultForDirectory, softDefaultForContent, parseGitattributes, linguistAttributesFor, gitattributesCanReinclude, indexExclusionLabel, indexExclusionNotice, isIndexExclusionReason, encodeNestedIgnoreLine, encodeGitattributesLine, decodeIndexRules, } from './indexClassifier.js';
|
|
12
|
+
export { makeIndexJudge } from './indexJudge.js';
|
|
11
13
|
export { AST_LANGUAGE_IDS, QUERY_CHAIN, VENDORED_ARTIFACT_DIR, astArtifactReport, astCapabilityReport, grammarArtifactBasename, loadGrammar, loadedGrammarIds, resolveAstLanguage, } from './ast/grammars.js';
|
|
12
14
|
export { MAX_AST_PARSE_BYTES, chunkWithAst, } from './ast/astChunker.js';
|
|
13
15
|
export { SECRET_PATTERNS, SECRET_REDACTION_PLACEHOLDER, scrubSecrets, redactHighEntropyTokens, } from './secretPatterns.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,MAAM,CAAC,MAAM,6BAA6B,GAAG,OAAO,CAAC;AACrD,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,MAAM,CAAC,MAAM,6BAA6B,GAAG,OAAO,CAAC;AACrD,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,GAKrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,4BAA4B,EAC5B,wBAAwB,EACxB,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,GAUjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAwC,MAAM,iBAAiB,CAAC;AACvF,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,EACvB,WAAW,EACX,gBAAgB,EAChB,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MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default indexing rules: which files are not code an agent works with.
|
|
3
|
+
*
|
|
4
|
+
* Code search should return the code agents edit, not generated clients,
|
|
5
|
+
* minified bundles, binary files, vendored dependencies or data dumps. These
|
|
6
|
+
* rules are SOFT defaults: a project can re-include any path they exclude, and
|
|
7
|
+
* that is what separates them from the hard rules that stay where they are
|
|
8
|
+
* (`isSecretFile`, protected paths, symlinks, nested git boundaries and
|
|
9
|
+
* `BUILT_IN_IGNORE_DIRS`, none of which can be overridden).
|
|
10
|
+
*
|
|
11
|
+
* Precedence, highest first:
|
|
12
|
+
* 1. hard rules - applied by the callers before this module is consulted;
|
|
13
|
+
* 2. the project's .gitignore / .mnemonikignore - a path they ignore is out,
|
|
14
|
+
* and a `!pattern` that matches the path ITSELF re-includes it from every
|
|
15
|
+
* soft default (a re-included parent directory does not: `.yarn/*` plus
|
|
16
|
+
* `!.yarn/releases`, Yarn's own recommended .gitignore, must not opt the
|
|
17
|
+
* bundled Yarn release back in);
|
|
18
|
+
* 3. .gitattributes - `linguist-vendored` / `linguist-generated` set or
|
|
19
|
+
* `=true` excludes, `-linguist-...` or `=false` re-includes, `binary` or
|
|
20
|
+
* `-text` means binary. Hierarchical, last match wins, as git resolves it;
|
|
21
|
+
* 4. the soft defaults below - path rules first, then content rules.
|
|
22
|
+
*
|
|
23
|
+
* ONE implementation for every place a path is judged: the daemon walk, its
|
|
24
|
+
* watcher and discovery walk, the server's push backstop and the retirement
|
|
25
|
+
* of stored rows. Two copies of a rule drift, and here drift means the daemon
|
|
26
|
+
* and the server disagree about what exists.
|
|
27
|
+
*
|
|
28
|
+
* Content rules read the SCRUBBED text (`scrubSecrets`), because that is the
|
|
29
|
+
* text the server receives: classifying the raw bytes on one side and the
|
|
30
|
+
* scrubbed bytes on the other would let a redaction placeholder move a file
|
|
31
|
+
* across the minified threshold on one side only.
|
|
32
|
+
*/
|
|
33
|
+
export declare const INDEX_EXCLUSION_REASONS: readonly ['vendored', 'generated', 'minified', 'binary', 'data_dump', 'changelog'];
|
|
34
|
+
export type IndexExclusionReason = (typeof INDEX_EXCLUSION_REASONS)[number];
|
|
35
|
+
/** A soft default (or a .gitattributes attribute) excluded the path. */
|
|
36
|
+
export interface IndexExclusion {
|
|
37
|
+
reason: IndexExclusionReason;
|
|
38
|
+
/**
|
|
39
|
+
* The concrete rule, for operators and the retirement shape guard. Never
|
|
40
|
+
* carries a per-file number, so paths group by rule.
|
|
41
|
+
*/
|
|
42
|
+
rule: string;
|
|
43
|
+
}
|
|
44
|
+
export type IndexClassification = {
|
|
45
|
+
include: true;
|
|
46
|
+
/**
|
|
47
|
+
* Set when a project rule re-included the path. Content rules do not run
|
|
48
|
+
* for an overridden path: the project has said it is code.
|
|
49
|
+
*/
|
|
50
|
+
override?: 'ignore_file' | 'gitattributes';
|
|
51
|
+
} | ({
|
|
52
|
+
include: false;
|
|
53
|
+
} & IndexExclusion);
|
|
54
|
+
/** What a project's .gitignore / .mnemonikignore stack says about one path. */
|
|
55
|
+
export type IgnoreFileVerdict = 'ignored' | 'unignored' | 'unmatched';
|
|
56
|
+
/** Human phrase for a reason: "generated code", "a binary file". */
|
|
57
|
+
export declare function indexExclusionLabel(reason: IndexExclusionReason): string;
|
|
58
|
+
/**
|
|
59
|
+
* The one line an agent sees when it asks about an excluded path. Short on
|
|
60
|
+
* purpose: the agent needs to know the absence is deliberate and that its own
|
|
61
|
+
* file tools still reach the file.
|
|
62
|
+
*/
|
|
63
|
+
export declare function indexExclusionNotice(reason: IndexExclusionReason, subject?: string): string;
|
|
64
|
+
export declare function isIndexExclusionReason(value: unknown): value is IndexExclusionReason;
|
|
65
|
+
/**
|
|
66
|
+
* Soft default for a directory, from its path alone. `dirRel` is the
|
|
67
|
+
* directory's root-relative path, with or without a trailing slash. Used to
|
|
68
|
+
* prune walks: nothing under a vendored or generated directory can be
|
|
69
|
+
* included by a soft default.
|
|
70
|
+
*/
|
|
71
|
+
export declare function softDefaultForDirectory(dirRel: string): IndexExclusion | null;
|
|
72
|
+
/** Soft default for a file from its path alone (R2, R3 by name, R8 AppleDouble, R9). */
|
|
73
|
+
export declare function softDefaultForPath(relPath: string): IndexExclusion | null;
|
|
74
|
+
/** git's binary heuristic window. */
|
|
75
|
+
export declare const BINARY_SNIFF_BYTES = 8000;
|
|
76
|
+
/** R5: average line length above which a .js/.mjs/.cjs/.css file is minified. */
|
|
77
|
+
export declare const MINIFIED_AVERAGE_LINE_LENGTH = 110;
|
|
78
|
+
/** R5: a line longer than this, in UTF-8 bytes, is a minified line. */
|
|
79
|
+
export declare const MINIFIED_LONG_LINE_BYTES = 4096;
|
|
80
|
+
/** R7: a .sql file with at least this many INSERT INTO statements is a dump. */
|
|
81
|
+
export declare const DATA_DUMP_INSERT_THRESHOLD = 50;
|
|
82
|
+
/**
|
|
83
|
+
* Soft default from a file's content (R4, R5, R7, R8). `content` is the
|
|
84
|
+
* decoded, scrubbed text. R8 uses git's heuristic: a NUL in the first 8,000
|
|
85
|
+
* characters (which cover at least the first 8,000 bytes).
|
|
86
|
+
*/
|
|
87
|
+
export declare function softDefaultForContent(relPath: string, content: string): IndexExclusion | null;
|
|
88
|
+
/** Attribute state after git's rules: set, unset (`-a`), or a value. */
|
|
89
|
+
type AttributeValue = true | false | string;
|
|
90
|
+
export interface GitattributesRule {
|
|
91
|
+
/** Matched against the path relative to the attributes file's directory. */
|
|
92
|
+
re: RegExp;
|
|
93
|
+
/** No '/' in the pattern: match the base name at any depth. */
|
|
94
|
+
basenameOnly: boolean;
|
|
95
|
+
/** `undefined` = `!attr` (reset to unspecified). */
|
|
96
|
+
attrs: ReadonlyMap<string, AttributeValue | undefined>;
|
|
97
|
+
}
|
|
98
|
+
/** One .gitattributes file: its directory relative to the root ('' = root). */
|
|
99
|
+
export interface GitattributesLayer {
|
|
100
|
+
baseRel: string;
|
|
101
|
+
rules: readonly GitattributesRule[];
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Parse one .gitattributes file. Comments, blank lines, macro definitions
|
|
105
|
+
* (`[attr]...`) and negative patterns (forbidden by git) are skipped. The
|
|
106
|
+
* built-in `binary` macro is expanded to `-text`, which is the part of it this
|
|
107
|
+
* module reads.
|
|
108
|
+
*/
|
|
109
|
+
export declare function parseGitattributes(text: string): GitattributesRule[];
|
|
110
|
+
/** The attributes this module reads, resolved for one path. */
|
|
111
|
+
export interface LinguistAttributes {
|
|
112
|
+
/** true = vendored, false = explicitly not vendored, undefined = unspecified. */
|
|
113
|
+
vendored?: boolean;
|
|
114
|
+
generated?: boolean;
|
|
115
|
+
binary: boolean;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Resolve `linguist-vendored`, `linguist-generated` and binary-ness for one
|
|
119
|
+
* root-relative path. `layers` are applied root first, then deeper; within a
|
|
120
|
+
* file, later lines win - git's own order. `linguist-documentation` is not
|
|
121
|
+
* read: documentation is what agents read.
|
|
122
|
+
*/
|
|
123
|
+
export declare function linguistAttributesFor(relPath: string, layers: readonly GitattributesLayer[]): LinguistAttributes;
|
|
124
|
+
/** True when any rule in these layers can re-include a path (`-linguist-*` or `=false`). */
|
|
125
|
+
export declare function gitattributesCanReinclude(layers: readonly GitattributesLayer[]): boolean;
|
|
126
|
+
export interface ClassifyForIndexOptions {
|
|
127
|
+
/**
|
|
128
|
+
* Decoded, scrubbed file content. Omit to classify by path only; the
|
|
129
|
+
* result then says nothing about content rules, which the caller applies
|
|
130
|
+
* later unless `override` is set.
|
|
131
|
+
*/
|
|
132
|
+
content?: string;
|
|
133
|
+
/**
|
|
134
|
+
* The project's .gitignore / .mnemonikignore verdict for this path. An
|
|
135
|
+
* `'ignored'` path is excluded before this function is consulted;
|
|
136
|
+
* `'unignored'` - a `!pattern` matched the path itself - re-includes it.
|
|
137
|
+
*/
|
|
138
|
+
ignoreFileVerdict?: IgnoreFileVerdict;
|
|
139
|
+
/** The .gitattributes files that apply, any order (resolved root first). */
|
|
140
|
+
attributes?: readonly GitattributesLayer[];
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Should this path be indexed? `{ include: true }`, or
|
|
144
|
+
* `{ include: false, reason, rule }`. Hard rules are not this function's
|
|
145
|
+
* business: a caller excludes secrets, protected paths, symlinks, nested git
|
|
146
|
+
* boundaries, built-in directories and user-ignored paths first.
|
|
147
|
+
*/
|
|
148
|
+
export declare function classifyForIndex(relPath: string, options?: ClassifyForIndexOptions): IndexClassification;
|
|
149
|
+
/**
|
|
150
|
+
* The daemon uploads its root .gitignore / .mnemonikignore lines verbatim
|
|
151
|
+
* (`ignorePatterns`, the server's privacy list). The other rule lines the
|
|
152
|
+
* walk applied ride along as gitignore COMMENT lines, so a server or matcher
|
|
153
|
+
* that predates them reads them as comments and changes nothing:
|
|
154
|
+
*
|
|
155
|
+
* `#mnemonik:gitignore <dir>\t<line>` - a nested .gitignore /
|
|
156
|
+
* .mnemonikignore line, for
|
|
157
|
+
* `!pattern` overrides
|
|
158
|
+
* `#mnemonik:gitattributes <dir>\t<line>` - a .gitattributes line; <dir>
|
|
159
|
+
* is empty for the root file
|
|
160
|
+
*
|
|
161
|
+
* With them the server and retirement judge a path exactly as the daemon did.
|
|
162
|
+
*/
|
|
163
|
+
export declare const NESTED_IGNORE_TAG = "#mnemonik:gitignore ";
|
|
164
|
+
export declare const GITATTRIBUTES_TAG = "#mnemonik:gitattributes ";
|
|
165
|
+
export declare function encodeNestedIgnoreLine(baseRel: string, line: string): string;
|
|
166
|
+
export declare function encodeGitattributesLine(baseRel: string, line: string): string;
|
|
167
|
+
/** Uploaded rules, split back into their layers. */
|
|
168
|
+
export interface DecodedIndexRules {
|
|
169
|
+
/** Root .gitignore / .mnemonikignore lines (the privacy list), in order. */
|
|
170
|
+
rootIgnore: string[];
|
|
171
|
+
/** Nested ignore-file lines by directory, in upload order. */
|
|
172
|
+
nestedIgnore: Map<string, string[]>;
|
|
173
|
+
/** .gitattributes lines by directory ('' = root), in upload order. */
|
|
174
|
+
attributes: Map<string, string[]>;
|
|
175
|
+
}
|
|
176
|
+
export declare function decodeIndexRules(patterns: readonly string[]): DecodedIndexRules;
|
|
177
|
+
export {};
|
|
178
|
+
//# sourceMappingURL=indexClassifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexClassifier.d.ts","sourceRoot":"","sources":["../src/indexClassifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAIH,eAAO,MAAM,uBAAuB,YAClC,UAAU,EACV,WAAW,EACX,UAAU,EACV,QAAQ,EACR,WAAW,EACX,WAAW,CACH,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5E,wEAAwE;AACxE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,oBAAoB,CAAC;IAC7B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,mBAAmB,GAC3B;IACE,OAAO,EAAE,IAAI,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,aAAa,GAAG,eAAe,CAAC;CAC5C,GACD,CAAC;IAAE,OAAO,EAAE,KAAK,CAAA;CAAE,GAAG,cAAc,CAAC,CAAC;AAE1C,+EAA+E;AAC/E,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC;AAWtE,oEAAoE;AACpE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAExE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAI3F;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CA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