@catheadowl/pathscope 0.0.0-stage → 0.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/LICENSE +21 -0
  3. package/README.md +127 -2
  4. package/dist/cascade.d.ts +16 -0
  5. package/dist/cascade.js +69 -0
  6. package/dist/cascade.js.map +1 -0
  7. package/dist/cjs/cascade.d.ts +16 -0
  8. package/dist/cjs/discover.d.ts +11 -0
  9. package/dist/cjs/engine.d.ts +6 -0
  10. package/dist/cjs/exclusion-engine.d.ts +79 -0
  11. package/dist/cjs/index.d.ts +22 -0
  12. package/dist/cjs/index.js +2102 -0
  13. package/dist/cjs/package.json +1 -0
  14. package/dist/cjs/paths.d.ts +13 -0
  15. package/dist/cjs/presets.d.ts +28 -0
  16. package/dist/cjs/types.d.ts +235 -0
  17. package/dist/cjs/universe.d.ts +27 -0
  18. package/dist/discover.d.ts +11 -0
  19. package/dist/discover.js +66 -0
  20. package/dist/discover.js.map +1 -0
  21. package/dist/engine.d.ts +6 -0
  22. package/dist/engine.js +117 -0
  23. package/dist/engine.js.map +1 -0
  24. package/dist/exclusion-engine.d.ts +79 -0
  25. package/dist/exclusion-engine.js +352 -0
  26. package/dist/exclusion-engine.js.map +1 -0
  27. package/dist/index.d.ts +22 -0
  28. package/dist/index.js +21 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/paths.d.ts +13 -0
  31. package/dist/paths.js +28 -0
  32. package/dist/paths.js.map +1 -0
  33. package/dist/presets.d.ts +28 -0
  34. package/dist/presets.js +77 -0
  35. package/dist/presets.js.map +1 -0
  36. package/dist/types.d.ts +235 -0
  37. package/dist/types.js +28 -0
  38. package/dist/types.js.map +1 -0
  39. package/dist/universe.d.ts +27 -0
  40. package/dist/universe.js +219 -0
  41. package/dist/universe.js.map +1 -0
  42. package/docs/glossary.md +59 -0
  43. package/docs/semantics.md +73 -0
  44. package/package.json +53 -4
@@ -0,0 +1,352 @@
1
+ /**
2
+ * Composable exclusion engine — the decision core behind walkScope.
3
+ *
4
+ * walkScope bundles three concerns: the exclusion stack (stones → strict →
5
+ * override → combined table → dot category), the gitignore cascade (inherited
6
+ * phase + walk-time folding), and the fdir chassis with its loud budget.
7
+ * Consumers that own their own traversal (incremental snapshots, watcher
8
+ * feeds, URI/remote filesystems) cannot ride the chassis — this module
9
+ * exposes the first two concerns as a standalone, composable engine:
10
+ *
11
+ * - construction runs the inherited phase through an injectable async
12
+ * {@link ExclusionIO} (default: node fs), building the canonical rule
13
+ * space exactly as walkScope does;
14
+ * - adjudication is PURE and synchronous: the caller pre-fetches the two
15
+ * per-directory facts the engine cannot fetch synchronously (the stone
16
+ * existence probes and the directory's own `.gitignore` text) and drives
17
+ * the engine through the same verdict order walkScope applies;
18
+ * - `excludeDirectory` → (descend) → `foldGitignore` → adjudicate children
19
+ * mirrors walkScope's per-directory sequence: a directory excluded with
20
+ * no directory-level rescue prunes the subtree and its `.gitignore` is
21
+ * never folded, so its `!` rules cannot leak onto the rest of the walk.
22
+ *
23
+ * The full-stack priority is the walkScope contract verbatim:
24
+ * boundary stones (structural terminal) → strict immune channel → override
25
+ * whitelist (terminal include; naming a directory restores descent) →
26
+ * combined table (presets front → gitignore cascade shallow→deep → policy
27
+ * layer rear seat, git last-match-wins) → dot category. The budget stays
28
+ * chassis-side: an engine has no file limit and emits no diagnostics.
29
+ */
30
+ import { existsSync } from 'node:fs';
31
+ import { join } from 'node:path';
32
+ import ignore from 'ignore';
33
+ import { readGitignoreText, reanchorLines, splitLines } from './cascade.js';
34
+ import { compilePresetPatterns, DEFAULT_MOUNTED_PRESETS, isPresetName } from './presets.js';
35
+ import { baseNamePosix, joinPosix } from './paths.js';
36
+ import { PathscopeConfigError } from './types.js';
37
+ /** Default IO over the node filesystem (existsSync / readFileSync). */
38
+ export const nodeExclusionIO = {
39
+ exists: (dirKey, name) => Promise.resolve(existsSync(join(dirKey, ...name.split('/')))),
40
+ readGitignore: (dirKey) => Promise.resolve(readGitignoreText(dirKey)),
41
+ };
42
+ /** Validate options; malformed configuration fails loudly instead of scanning differently. */
43
+ export function validateOptions(options) {
44
+ if (options.mountPresets !== undefined) {
45
+ for (const name of options.mountPresets) {
46
+ if (!isPresetName(name)) {
47
+ throw new PathscopeConfigError(`unknown preset "${String(name)}" — the five groups are vcs | deps | build | caches | agentDocs`);
48
+ }
49
+ }
50
+ }
51
+ for (const rule of options.strict ?? []) {
52
+ if (typeof rule.pattern !== 'string' || rule.pattern.trim() === '') {
53
+ throw new PathscopeConfigError('every strict rule needs a non-empty gitignore-style pattern');
54
+ }
55
+ if (typeof rule.reason !== 'string' || rule.reason.trim() === '') {
56
+ throw new PathscopeConfigError(`strict rule "${rule.pattern}" carries no written reason — the immune channel serves outbound artifact boundaries only and does not open without one`);
57
+ }
58
+ }
59
+ if (options.maxFiles !== undefined && (!Number.isInteger(options.maxFiles) || options.maxFiles <= 0)) {
60
+ throw new PathscopeConfigError(`maxFiles must be a positive integer, got ${String(options.maxFiles)}`);
61
+ }
62
+ if (options.alignment !== undefined && options.alignment !== 'git' && options.alignment !== 'scanner') {
63
+ throw new PathscopeConfigError(`unknown alignment "${String(options.alignment)}" — the faces are git | scanner`);
64
+ }
65
+ if (options.alignment === 'scanner' && options.boundaryStones?.gitignoreProxy === true) {
66
+ throw new PathscopeConfigError('gitignoreProxy is mounted under the scanner alignment face — the proxy stone treats a nested .gitignore as territory while the face treats it as rules; the contradiction is rejected instead of adjudicated');
67
+ }
68
+ for (const key of ['exclude', 'override']) {
69
+ for (const entry of options[key] ?? []) {
70
+ if (typeof entry !== 'string' || entry.trim() === '') {
71
+ throw new PathscopeConfigError(`${key} entries must be non-empty gitignore-style pattern strings`);
72
+ }
73
+ }
74
+ }
75
+ for (const home of options.boundaryStones?.configHomes ?? []) {
76
+ if (typeof home !== 'string' ||
77
+ home.trim() === '' ||
78
+ home.startsWith('/') ||
79
+ home.split('/').includes('..')) {
80
+ throw new PathscopeConfigError(`config home "${String(home)}" must be a non-empty relative name (e.g. ".specs/collect.config.toml")`);
81
+ }
82
+ // Degenerate name collision: with the proxy
83
+ // stone mounted, a `.gitignore` config home could not adjudicate between
84
+ // an exemptible proxy hit and a declared sub-domain — rejected loudly.
85
+ if (options.boundaryStones?.gitignoreProxy === true && (home === '.gitignore' || home.startsWith('.gitignore/'))) {
86
+ throw new PathscopeConfigError(`config home "${home}" collides with the .gitignore proxy stone name — the degenerate collision is rejected instead of adjudicated`);
87
+ }
88
+ }
89
+ for (const entry of options.boundaryStones?.exempt ?? []) {
90
+ if (typeof entry !== 'string' || entry.trim() === '') {
91
+ throw new PathscopeConfigError('boundaryStones.exempt entries must be non-empty gitignore-style pattern strings naming subtrees (e.g. "embedded-toolkit/")');
92
+ }
93
+ }
94
+ }
95
+ /** Parent of a POSIX-separator absolute key, keeping the separator ('' guard); undefined at the top. */
96
+ function parentDirKey(key) {
97
+ const stripped = key.replace(/\/+$/, '');
98
+ // A URI-form drive root ('/C:') stops here — on win32 the drive root is its
99
+ // own parent (dirname('C:/') === 'C:/'), so the walk must not descend to
100
+ // the string '/' (a different, unexpressible universe above the drive).
101
+ if (/^\/[A-Za-z]:$/.test(stripped))
102
+ return undefined;
103
+ const idx = stripped.lastIndexOf('/');
104
+ if (idx < 0)
105
+ return undefined; // bare drive key ('D:') or degenerate
106
+ const parent = stripped.slice(0, idx + 1);
107
+ return parent === stripped ? undefined : parent;
108
+ }
109
+ /**
110
+ * Build the composable exclusion engine for `rootKey` (a POSIX-separator
111
+ * absolute path key — native roots must be resolved and separator-normalized
112
+ * by the caller first, as walkScope does). Options are the shared
113
+ * {@link ScopeOptions} face; the chassis fields (`maxFiles`,
114
+ * `followSymlinks`) are accepted and ignored — the engine has no budget and
115
+ * never touches symlinks.
116
+ */
117
+ export async function createExclusionEngine(rootKey, options = {}, io = nodeExclusionIO) {
118
+ validateOptions(options);
119
+ const respectGitignore = options.respectGitignore !== false;
120
+ // ---- inherited phase ----------------------------------------------------
121
+ // Locate the enclosing git root by probing `.git` upward (dual file|dir
122
+ // form), the scan root itself included; without a hit the inheritance top
123
+ // is the disk root (a stray parent `.gitignore` is honored on the way
124
+ // down). respectGitignore=false skips the whole phase.
125
+ let top;
126
+ if (respectGitignore) {
127
+ let dir = rootKey;
128
+ for (;;) {
129
+ if (await io.exists(dir, '.git')) {
130
+ top = dir;
131
+ break;
132
+ }
133
+ const parent = parentDirKey(dir);
134
+ if (parent === undefined) {
135
+ top = dir;
136
+ break;
137
+ }
138
+ dir = parent;
139
+ }
140
+ }
141
+ const inheritedLines = [];
142
+ if (top !== undefined && top !== rootKey) {
143
+ const ancestors = [];
144
+ let cur = parentDirKey(rootKey);
145
+ while (cur !== undefined) {
146
+ ancestors.push(cur);
147
+ if (cur === top)
148
+ break;
149
+ cur = parentDirKey(cur);
150
+ }
151
+ ancestors.reverse(); // git reads the cascade shallow first
152
+ for (const ancestor of ancestors) {
153
+ const text = await io.readGitignore(ancestor);
154
+ if (text !== null)
155
+ inheritedLines.push(...splitLines(text));
156
+ }
157
+ }
158
+ const rootPrefix = top !== undefined && rootKey.startsWith(top) ? top : rootKey;
159
+ const offRel = rootKey.slice(rootPrefix.length).replace(/^\//, '');
160
+ // ---- canonical rule space ------------------------------------------------
161
+ const toCanonical = (rel) => (offRel === '' ? rel : `${offRel}/${rel}`);
162
+ /** Re-anchor scan-root-based patterns (relDir '' = the scan root itself) into the canonical space. */
163
+ const mount = (patterns, relDir = '') => {
164
+ const prefix = joinPosix(offRel, relDir);
165
+ return prefix === '' ? patterns : reanchorLines(patterns, prefix);
166
+ };
167
+ // Combined table, front segment first: presets → inherited gitignores
168
+ // (verbatim — natively expressed in canonical space) → scan root's own
169
+ // .gitignore. Nested layers are appended by foldGitignore mid-walk.
170
+ const core = ignore();
171
+ const presetPatterns = compilePresetPatterns(options.mountPresets ?? DEFAULT_MOUNTED_PRESETS);
172
+ if (presetPatterns.length > 0)
173
+ core.add(mount(presetPatterns));
174
+ if (inheritedLines.length > 0)
175
+ core.add(inheritedLines);
176
+ const rootIgnoreText = respectGitignore ? await io.readGitignore(rootKey) : null;
177
+ if (rootIgnoreText !== null) {
178
+ const lines = mount(splitLines(rootIgnoreText));
179
+ if (lines.length > 0)
180
+ core.add(lines);
181
+ }
182
+ // Policy layer holds the rear seat of the combined table: after the whole
183
+ // gitignore cascade, so its match (either polarity) wins over the cascade.
184
+ const policy = ignore();
185
+ if (options.exclude !== undefined && options.exclude.length > 0) {
186
+ policy.add(mount(options.exclude));
187
+ }
188
+ const overrideIg = ignore();
189
+ if (options.override !== undefined && options.override.length > 0) {
190
+ overrideIg.add(mount(options.override));
191
+ }
192
+ const strictIg = ignore();
193
+ if (options.strict !== undefined && options.strict.length > 0) {
194
+ strictIg.add(mount(options.strict.map((rule) => rule.pattern)));
195
+ }
196
+ const configHomes = options.boundaryStones?.configHomes ?? [];
197
+ const gitignoreProxy = options.boundaryStones?.gitignoreProxy === true;
198
+ const stoneNames = [
199
+ '.git',
200
+ ...configHomes,
201
+ ...(gitignoreProxy ? ['.gitignore'] : []),
202
+ ];
203
+ const excludeDotEntries = options.excludeDotEntries !== false;
204
+ // ---- named-subtree stone exemption (boundaryStones.exempt) ---------------
205
+ // Patterns live in scan-root-relative space, like every consumer-facing
206
+ // pattern channel. A directory is exempt iff a pattern matches the
207
+ // directory's OWN path: gitignore matching propagates a directory match
208
+ // onto its descendants (that is exclusion semantics), so a match that an
209
+ // ancestor already explains does not count — `embedded-toolkit/` exempts
210
+ // embedded-toolkit itself, never embedded-toolkit/pkg/nested-repo. The
211
+ // scan root is the pattern base and cannot be matched by construction.
212
+ const exemptPatterns = options.boundaryStones?.exempt ?? [];
213
+ const exemptIg = exemptPatterns.length > 0 ? ignore() : null;
214
+ if (exemptIg !== null)
215
+ exemptIg.add(exemptPatterns);
216
+ const isExemptDir = (relDir) => {
217
+ if (exemptIg === null)
218
+ return false;
219
+ if (!exemptIg.test(`${relDir}/`).ignored)
220
+ return false;
221
+ const cut = relDir.lastIndexOf('/');
222
+ if (cut === -1)
223
+ return true; // top level: no ancestor could have matched
224
+ return !exemptIg.test(`${relDir.slice(0, cut)}/`).ignored;
225
+ };
226
+ // The exemptible stone KINDS: the core `.git` plus, when
227
+ // the proxy stone is mounted, `.gitignore` itself. The two anchors write
228
+ // differently — the core-stone exemption is the submodule-registration
229
+ // isomorphism; the proxy exemption is the named REVOCATION of a
230
+ // registration deviation: the named subtree returns to the git-native
231
+ // default (a nested .gitignore is rules, not territory). Config homes
232
+ // stay non-exemptible (dissolving a consumer's declared governance
233
+ // sub-domain by pattern is a different
234
+ // safety flavor). A co-hit of exemptible stones in one directory is
235
+ // symmetric: one naming neutralizes every exemptible stone's own hit.
236
+ const exemptibleNames = gitignoreProxy
237
+ ? new Set(['.git', '.gitignore'])
238
+ : new Set(['.git']);
239
+ // The alignment face's enforcement policy: under the scanner face the
240
+ // core `.git` stone is REPORTED but
241
+ // not ENFORCED — the hit still flows in the per-stone array form
242
+ // (consumer-visible metadata: this subtree is a nested repository) while
243
+ // the cut never executes, at any depth. Config homes are consumer
244
+ // self-declared governance and keep their verdict under every face.
245
+ const unenforcedNames = options.alignment === 'scanner' ? new Set(['.git']) : null;
246
+ /**
247
+ * Stone verdict over one directory (the scan root itself never truncates).
248
+ * The exemption neutralizes the named directory's own hits of the
249
+ * exemptible stone kinds (the core `.git`; `.gitignore` too when the proxy
250
+ * stone is mounted); the alignment face then drops the unenforced kinds
251
+ * (the core `.git` under the scanner face — reported, never enforced); any
252
+ * remaining hit (a config home) still truncates. The boolean form reports
253
+ * an unspecified hit and truncates unconditionally.
254
+ */
255
+ const stoneTruncates = (hit, key) => {
256
+ if (hit === true)
257
+ return true;
258
+ if (hit == null || !Array.isArray(hit) || hit.length === 0)
259
+ return false;
260
+ let names = hit;
261
+ if (isExemptDir(key.slice(rootKey.length + 1))) {
262
+ names = names.filter((name) => !exemptibleNames.has(name));
263
+ }
264
+ if (unenforcedNames !== null) {
265
+ names = names.filter((name) => !unenforcedNames.has(name));
266
+ }
267
+ return names.length > 0;
268
+ };
269
+ /** Combined-table verdict for a canonical path: policy after the cascade. */
270
+ const combinedExcludes = (canonical) => {
271
+ const policyResult = policy.test(canonical);
272
+ if (policyResult.ignored)
273
+ return true;
274
+ if (policyResult.unignored)
275
+ return false;
276
+ return core.test(canonical).ignored;
277
+ };
278
+ return {
279
+ rootKey,
280
+ stoneNames,
281
+ excludeDirectory(name, dirPath, stoneHit) {
282
+ const key = dirPath.replace(/\/+$/, '');
283
+ // 0. boundary stones — structural terminal; the scan
284
+ // root itself is the universe boundary and never truncates. The
285
+ // named-subtree exemption (boundaryStones.exempt) adjudicates
286
+ // inside this verdict: the named directory's own hits of the
287
+ // exemptible stone kinds are neutralized, everything else keeps
288
+ // its cut.
289
+ if (key !== rootKey && stoneTruncates(stoneHit, key))
290
+ return true;
291
+ const relDir = key.slice(rootKey.length + 1);
292
+ const canonicalDir = toCanonical(`${relDir}/`);
293
+ // 1. strict immune channel — not rescuable, not even by the override whitelist.
294
+ if (strictIg.test(canonicalDir).ignored)
295
+ return true;
296
+ // 2. override whitelist — terminal include; naming the directory itself
297
+ // rescues descent into it.
298
+ if (overrideIg.test(canonicalDir).ignored)
299
+ return false;
300
+ // 3. combined rule table — the policy layer holds the rear seat. A
301
+ // directory excluded with no directory-level rescue prunes the
302
+ // subtree (structural, the only non-revivable). When the rescue
303
+ // comes from a policy NEGATION, the negation is restated into the
304
+ // core stream at its cascade-equivalent position as an anchored,
305
+ // exactly-subtree-scoped rule: node-ignore reports a negation as a
306
+ // match only when it hits the pathname itself, so without the
307
+ // restatement files beneath the rescued directory would fall back
308
+ // to the core stream's component match (e.g. the mounted preset)
309
+ // and be re-excluded — diverging from the same rule pair written
310
+ // in one .gitignore file.
311
+ const policyResult = policy.test(canonicalDir);
312
+ if (policyResult.ignored)
313
+ return true;
314
+ if (policyResult.unignored) {
315
+ if (core.test(canonicalDir).ignored) {
316
+ core.add(`!/${canonicalDir}`);
317
+ }
318
+ }
319
+ else if (core.test(canonicalDir).ignored) {
320
+ return true;
321
+ }
322
+ // 4. dot category — walk-layer option; the whitelist had its chance at 2.
323
+ if (excludeDotEntries && name.startsWith('.'))
324
+ return true;
325
+ return false;
326
+ },
327
+ foldGitignore(dirPath, text) {
328
+ if (text == null || !respectGitignore)
329
+ return;
330
+ const key = dirPath.replace(/\/+$/, '');
331
+ if (key === rootKey)
332
+ return; // consumed at construction
333
+ const relDir = key.slice(rootKey.length + 1);
334
+ const lines = mount(splitLines(text), relDir);
335
+ if (lines.length > 0)
336
+ core.add(lines);
337
+ },
338
+ admitFile(relPath) {
339
+ const canonical = toCanonical(relPath);
340
+ if (strictIg.test(canonical).ignored)
341
+ return false;
342
+ if (overrideIg.test(canonical).ignored)
343
+ return true;
344
+ if (combinedExcludes(canonical))
345
+ return false;
346
+ if (excludeDotEntries && baseNamePosix(relPath).startsWith('.'))
347
+ return false;
348
+ return true;
349
+ },
350
+ };
351
+ }
352
+ //# sourceMappingURL=exclusion-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exclusion-engine.js","sourceRoot":"","sources":["../src/exclusion-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAsC,MAAM,YAAY,CAAC;AAkBtF,uEAAuE;AACvE,MAAM,CAAC,MAAM,eAAe,GAAgB;IAC1C,MAAM,EAAE,C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OAAO;gBAAE,OAAO,KAAK,CAAC;YACnD,IAAI,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO;gBAAE,OAAO,IAAI,CAAC;YACpD,IAAI,gBAAgB,CAAC,SAAS,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC9C,IAAI,iBAAiB,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC9E,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * pathscope — cross-repo file-scope engine, public surface.
3
+ *
4
+ * Two mutually exclusive ways to resolve the in-scope set (the "circle"
5
+ * axis): walk mode (walkScope over the fdir chassis with the gitignore
6
+ * cascade on the node-ignore kernel, mounted exclusion presets, override
7
+ * whitelist, strict immune channel, boundary stones, and a loud budget) or
8
+ * ask-git mode (gitUniverse — git is the truth, the exclusion stack does not
9
+ * participate). Config discovery (locateNearest) locates the nearest config
10
+ * residence and never parses it. Consumers that own their own traversal
11
+ * (incremental snapshots, watcher feeds, URI/remote filesystems) compose the
12
+ * same exclusion stack + cascade as a standalone decision core:
13
+ * createExclusionEngine.
14
+ */
15
+ export { walkScope } from './engine.ts';
16
+ export { createExclusionEngine, nodeExclusionIO } from './exclusion-engine.ts';
17
+ export type { ExclusionEngine, ExclusionIO } from './exclusion-engine.ts';
18
+ export { clearUniverseCache, gitUniverse } from './universe.ts';
19
+ export { locateNearest } from './discover.ts';
20
+ export { PRESETS, DEFAULT_MOUNTED_PRESETS } from './presets.ts';
21
+ export { PathscopeConfigError, PathscopeGitError } from './types.ts';
22
+ export type { AlignmentFace, BoundaryStonesOptions, DiscoveryResult, LocateNearestOptions, PresetName, ScanDiagnostic, ScopeOptions, StrictRule, UniverseFilter, UniverseOptions, UniverseResult, UniverseVariant, WalkResult, } from './types.ts';
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * pathscope — cross-repo file-scope engine, public surface.
3
+ *
4
+ * Two mutually exclusive ways to resolve the in-scope set (the "circle"
5
+ * axis): walk mode (walkScope over the fdir chassis with the gitignore
6
+ * cascade on the node-ignore kernel, mounted exclusion presets, override
7
+ * whitelist, strict immune channel, boundary stones, and a loud budget) or
8
+ * ask-git mode (gitUniverse — git is the truth, the exclusion stack does not
9
+ * participate). Config discovery (locateNearest) locates the nearest config
10
+ * residence and never parses it. Consumers that own their own traversal
11
+ * (incremental snapshots, watcher feeds, URI/remote filesystems) compose the
12
+ * same exclusion stack + cascade as a standalone decision core:
13
+ * createExclusionEngine.
14
+ */
15
+ export { walkScope } from './engine.js';
16
+ export { createExclusionEngine, nodeExclusionIO } from './exclusion-engine.js';
17
+ export { clearUniverseCache, gitUniverse } from './universe.js';
18
+ export { locateNearest } from './discover.js';
19
+ export { PRESETS, DEFAULT_MOUNTED_PRESETS } from './presets.js';
20
+ export { PathscopeConfigError, PathscopeGitError } from './types.js';
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Path normalization helpers (the matching kernel is fed
3
+ * POSIX forward-slash paths relative to each rule base; win32 native paths
4
+ * are normalized here before they reach node-ignore).
5
+ */
6
+ /** Native → POSIX separators (win32 backslashes become forward slashes). */
7
+ export declare function toPosix(p: string): string;
8
+ /** POSIX join where '' absorbs on either side ('' + 'x' = 'x'; 'a' + '' = 'a'). */
9
+ export declare function joinPosix(a: string, b: string): string;
10
+ /** Final path segment ('a/b.md' → 'b.md'; 'x' → 'x'). */
11
+ export declare function baseNamePosix(rel: string): string;
12
+ /** Directory portion of a POSIX relative path ('' when at the top level). */
13
+ export declare function dirNamePosix(rel: string): string;
package/dist/paths.js ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Path normalization helpers (the matching kernel is fed
3
+ * POSIX forward-slash paths relative to each rule base; win32 native paths
4
+ * are normalized here before they reach node-ignore).
5
+ */
6
+ /** Native → POSIX separators (win32 backslashes become forward slashes). */
7
+ export function toPosix(p) {
8
+ return p.includes('\\') ? p.replace(/\\/g, '/') : p;
9
+ }
10
+ /** POSIX join where '' absorbs on either side ('' + 'x' = 'x'; 'a' + '' = 'a'). */
11
+ export function joinPosix(a, b) {
12
+ if (a === '')
13
+ return b;
14
+ if (b === '')
15
+ return a;
16
+ return `${a}/${b}`;
17
+ }
18
+ /** Final path segment ('a/b.md' → 'b.md'; 'x' → 'x'). */
19
+ export function baseNamePosix(rel) {
20
+ const i = rel.lastIndexOf('/');
21
+ return i === -1 ? rel : rel.slice(i + 1);
22
+ }
23
+ /** Directory portion of a POSIX relative path ('' when at the top level). */
24
+ export function dirNamePosix(rel) {
25
+ const i = rel.lastIndexOf('/');
26
+ return i === -1 ? '' : rel.slice(0, i);
27
+ }
28
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,4EAA4E;AAC5E,MAAM,UAAU,OAAO,CAAC,CAAS;IAC/B,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,SAAS,CAAC,CAAS,EAAE,CAAS;IAC5C,IAAI,CAAC,KAAK,EAAE;QAAE,OAAO,CAAC,CAAC;IACvB,IAAI,CAAC,KAAK,EAAE;QAAE,OAAO,CAAC,CAAC;IACvB,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;AACrB,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC/B,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC/B,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The five mounted exclusion presets.
3
+ *
4
+ * Mounting is append-only and presets sit at the FRONT of the combined rule
5
+ * table: a named negation in any gitignore layer or in the policy layer can
6
+ * walk an entry back out (ESLint globalIgnores precedent — user `!` and
7
+ * deeper rules un-exclude preset defaults); no wholesale-replacement channel
8
+ * exists. Entry additions/removals are deliberate, versioned changes — the
9
+ * test suite pins the content snapshot as an anti-drift gate.
10
+ */
11
+ import type { PresetName } from './types.ts';
12
+ /** Type guard used by option validation — unknown preset names fail loudly. */
13
+ export declare function isPresetName(value: unknown): value is PresetName;
14
+ /** Preset content: directory names (matched as dir-only `name/` patterns at any depth) and file names. */
15
+ export type Preset = {
16
+ dirs: string[];
17
+ files?: string[];
18
+ };
19
+ /**
20
+ * The five preset groups. `dirs` entries compile to dir-only gitignore
21
+ * patterns (`name/` — a plain file with the same name stays in scope);
22
+ * `files` entries compile to bare names.
23
+ */
24
+ export declare const PRESETS: Record<PresetName, Preset>;
25
+ /** The default mount set. */
26
+ export declare const DEFAULT_MOUNTED_PRESETS: readonly PresetName[];
27
+ /** Compile mounted presets (in mount order) into gitignore-style patterns. */
28
+ export declare function compilePresetPatterns(names: readonly PresetName[]): string[];
@@ -0,0 +1,77 @@
1
+ const PRESET_NAMES = ['vcs', 'deps', 'build', 'caches', 'agentDocs'];
2
+ /** Type guard used by option validation — unknown preset names fail loudly. */
3
+ export function isPresetName(value) {
4
+ return typeof value === 'string' && PRESET_NAMES.includes(value);
5
+ }
6
+ /**
7
+ * The five preset groups. `dirs` entries compile to dir-only gitignore
8
+ * patterns (`name/` — a plain file with the same name stays in scope);
9
+ * `files` entries compile to bare names.
10
+ */
11
+ export const PRESETS = {
12
+ vcs: {
13
+ // Version-control homes. `.git` here only guards the scan root's own VCS
14
+ // directory as content; nested `.git` presence is the core boundary stone
15
+ // and truncates regardless of presets.
16
+ dirs: ['.git', '.hg', '.svn'],
17
+ },
18
+ deps: {
19
+ // Dependency homes (node ecosystem + the generic vendor tree; `.pnpm` is
20
+ // pnpm's store directory, also matched wherever it appears).
21
+ dirs: ['node_modules', '.pnpm', 'vendor'],
22
+ },
23
+ build: {
24
+ // Build outputs and coverage. These are collision-grade names (a project's
25
+ // source can legitimately live in `lib/`) — that is exactly why they ride
26
+ // the un-excludable preset channel (`!lib/` names its way out) instead of
27
+ // a separate immune layer.
28
+ dirs: ['dist', 'build', 'lib', 'out', 'coverage'],
29
+ },
30
+ caches: {
31
+ // Python & front-end cache/generated trees. Vendor lineage of the entries:
32
+ // - repomix `defaultIgnore.ts` (MIT): __pycache__, .mypy_cache,
33
+ // .pytest_cache, .tox, .venv, .cache, .next, .nuxt, .turbo, .vite,
34
+ // .parcel-cache, .svelte-kit
35
+ // - watchfiles `DefaultFilter` (Python-side alignment): __pycache__,
36
+ // .mypy_cache, .pytest_cache, .ruff_cache, .tox, .nox, .venv
37
+ // This group is NOT in the default mount set.
38
+ dirs: [
39
+ '__pycache__',
40
+ '.mypy_cache',
41
+ '.pytest_cache',
42
+ '.ruff_cache',
43
+ '.tox',
44
+ '.venv',
45
+ '.cache',
46
+ '.next',
47
+ '.nuxt',
48
+ '.turbo',
49
+ '.vite',
50
+ '.parcel-cache',
51
+ '.svelte-kit',
52
+ '.nox',
53
+ '.vscode-test',
54
+ ],
55
+ },
56
+ agentDocs: {
57
+ // Agent-carried instruction files: they are agent self-loading
58
+ // instructions, not project content. Not in the default mount set.
59
+ dirs: [],
60
+ files: ['AGENTS.md', 'CLAUDE.md'],
61
+ },
62
+ };
63
+ /** The default mount set. */
64
+ export const DEFAULT_MOUNTED_PRESETS = ['vcs', 'deps', 'build'];
65
+ /** Compile mounted presets (in mount order) into gitignore-style patterns. */
66
+ export function compilePresetPatterns(names) {
67
+ const patterns = [];
68
+ for (const name of names) {
69
+ const preset = PRESETS[name];
70
+ for (const dir of preset.dirs ?? [])
71
+ patterns.push(`${dir}/`);
72
+ for (const file of preset.files ?? [])
73
+ patterns.push(file);
74
+ }
75
+ return patterns;
76
+ }
77
+ //# sourceMappingURL=presets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presets.js","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":"AAYA,MAAM,YAAY,GAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;AAE5F,+EAA+E;AAC/E,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,YAAkC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC1F,CAAC;AAKD;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAA+B;IACjD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