@descryy/adapter-common 0.1.0 → 0.3.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/LICENSE +8 -0
- package/dist/degrade.d.ts +49 -0
- package/dist/degrade.d.ts.map +1 -0
- package/dist/degrade.js +60 -0
- package/dist/degrade.js.map +1 -0
- package/dist/discover.d.ts +21 -38
- package/dist/discover.d.ts.map +1 -1
- package/dist/discover.js +25 -42
- package/dist/discover.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/isolate.d.ts +17 -27
- package/dist/isolate.d.ts.map +1 -1
- package/dist/isolate.js +17 -27
- package/dist/isolate.js.map +1 -1
- package/package.json +10 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Copyright (c) 2026 Descry
|
|
2
|
+
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
This software is proprietary and confidential. No license, express or
|
|
6
|
+
implied, to use, copy, modify, merge, publish, distribute, sublicense, or
|
|
7
|
+
sell copies of this software is granted without prior written permission
|
|
8
|
+
from the copyright holder.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The guard between "extraction gave up" and "this adapter is broken".
|
|
3
|
+
*
|
|
4
|
+
* Several adapters already refuse to return an empty graph over a non-empty
|
|
5
|
+
* repository: they build a filesystem-level graph — one node per file, nothing
|
|
6
|
+
* claimed about contents — plus one loud row saying the analysis failed rather
|
|
7
|
+
* than the repository being empty. That rule was earned, not designed: two real
|
|
8
|
+
* repositories came back with 0 nodes over ~18,000 files and a successful R0
|
|
9
|
+
* status, because a transport failure and an empty repository were
|
|
10
|
+
* indistinguishable downstream.
|
|
11
|
+
*
|
|
12
|
+
* Every one of those guards covered extraction **returning** nothing, and none
|
|
13
|
+
* covered it **throwing**. The two outcomes differ only in how the extractor
|
|
14
|
+
* gave up, and the thrown one is strictly worse for the reader: an exception
|
|
15
|
+
* out of `emit()` cannot be told apart from the adapter being broken for every
|
|
16
|
+
* repository, so the caller reports the whole language as not analysable. It
|
|
17
|
+
* fires exactly when someone is analysing code they just wrote — the worst
|
|
18
|
+
* possible moment for a tool trying to earn trust.
|
|
19
|
+
*
|
|
20
|
+
* ## Degrading is not swallowing
|
|
21
|
+
*
|
|
22
|
+
* The `degrade` callback an adapter supplies still says loudly that no graph was
|
|
23
|
+
* produced and that findings over the repository are unsupported. The only thing
|
|
24
|
+
* that changes is that the caller receives that sentence instead of a stack
|
|
25
|
+
* trace it has to interpret. A silent `catch` returning an empty extraction
|
|
26
|
+
* would be the exact failure these guards exist to prevent, arriving by a
|
|
27
|
+
* shorter route — so this helper cannot express that: it has no empty-result
|
|
28
|
+
* path, and an adapter with no degraded graph to fall back to must not call it.
|
|
29
|
+
*
|
|
30
|
+
* ## Language-blind, and it has to be
|
|
31
|
+
*
|
|
32
|
+
* Nothing here knows what a node is. `T` is the adapter's own extraction shape,
|
|
33
|
+
* and the disclosure text lives in the adapter's `degrade` callback, where the
|
|
34
|
+
* vocabulary for "module" or "compilation unit" belongs. This file only decides
|
|
35
|
+
* that a throw becomes a disclosure, and formats the cause.
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* Run `extract`; on a throw, return `degrade(cause)` instead of propagating.
|
|
39
|
+
*
|
|
40
|
+
* `cause` names the thrown value's own type and message, because they are the
|
|
41
|
+
* cheapest real diagnosis available and the reader's alternative is reading the
|
|
42
|
+
* adapter's source. A non-`Error` throw is stringified rather than having
|
|
43
|
+
* `.message` read off it — doing that yields the literal text "undefined",
|
|
44
|
+
* which is a disclosure that names nothing.
|
|
45
|
+
*/
|
|
46
|
+
export declare function extractOrDegrade<T>(extract: () => T, degrade: (cause: string) => T): T;
|
|
47
|
+
/** `Name: message` for an `Error`; an explicitly-labelled stringification otherwise. */
|
|
48
|
+
export declare function describeThrown(error: unknown): string;
|
|
49
|
+
//# sourceMappingURL=degrade.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"degrade.d.ts","sourceRoot":"","sources":["../src/degrade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,CAMtF;AAED,wFAAwF;AACxF,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAGrD"}
|
package/dist/degrade.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The guard between "extraction gave up" and "this adapter is broken".
|
|
3
|
+
*
|
|
4
|
+
* Several adapters already refuse to return an empty graph over a non-empty
|
|
5
|
+
* repository: they build a filesystem-level graph — one node per file, nothing
|
|
6
|
+
* claimed about contents — plus one loud row saying the analysis failed rather
|
|
7
|
+
* than the repository being empty. That rule was earned, not designed: two real
|
|
8
|
+
* repositories came back with 0 nodes over ~18,000 files and a successful R0
|
|
9
|
+
* status, because a transport failure and an empty repository were
|
|
10
|
+
* indistinguishable downstream.
|
|
11
|
+
*
|
|
12
|
+
* Every one of those guards covered extraction **returning** nothing, and none
|
|
13
|
+
* covered it **throwing**. The two outcomes differ only in how the extractor
|
|
14
|
+
* gave up, and the thrown one is strictly worse for the reader: an exception
|
|
15
|
+
* out of `emit()` cannot be told apart from the adapter being broken for every
|
|
16
|
+
* repository, so the caller reports the whole language as not analysable. It
|
|
17
|
+
* fires exactly when someone is analysing code they just wrote — the worst
|
|
18
|
+
* possible moment for a tool trying to earn trust.
|
|
19
|
+
*
|
|
20
|
+
* ## Degrading is not swallowing
|
|
21
|
+
*
|
|
22
|
+
* The `degrade` callback an adapter supplies still says loudly that no graph was
|
|
23
|
+
* produced and that findings over the repository are unsupported. The only thing
|
|
24
|
+
* that changes is that the caller receives that sentence instead of a stack
|
|
25
|
+
* trace it has to interpret. A silent `catch` returning an empty extraction
|
|
26
|
+
* would be the exact failure these guards exist to prevent, arriving by a
|
|
27
|
+
* shorter route — so this helper cannot express that: it has no empty-result
|
|
28
|
+
* path, and an adapter with no degraded graph to fall back to must not call it.
|
|
29
|
+
*
|
|
30
|
+
* ## Language-blind, and it has to be
|
|
31
|
+
*
|
|
32
|
+
* Nothing here knows what a node is. `T` is the adapter's own extraction shape,
|
|
33
|
+
* and the disclosure text lives in the adapter's `degrade` callback, where the
|
|
34
|
+
* vocabulary for "module" or "compilation unit" belongs. This file only decides
|
|
35
|
+
* that a throw becomes a disclosure, and formats the cause.
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* Run `extract`; on a throw, return `degrade(cause)` instead of propagating.
|
|
39
|
+
*
|
|
40
|
+
* `cause` names the thrown value's own type and message, because they are the
|
|
41
|
+
* cheapest real diagnosis available and the reader's alternative is reading the
|
|
42
|
+
* adapter's source. A non-`Error` throw is stringified rather than having
|
|
43
|
+
* `.message` read off it — doing that yields the literal text "undefined",
|
|
44
|
+
* which is a disclosure that names nothing.
|
|
45
|
+
*/
|
|
46
|
+
export function extractOrDegrade(extract, degrade) {
|
|
47
|
+
try {
|
|
48
|
+
return extract();
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
return degrade(`extraction failed (${describeThrown(error)})`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** `Name: message` for an `Error`; an explicitly-labelled stringification otherwise. */
|
|
55
|
+
export function describeThrown(error) {
|
|
56
|
+
if (error instanceof Error)
|
|
57
|
+
return `${error.name}: ${error.message}`;
|
|
58
|
+
return `a non-Error value was thrown: ${String(error)}`;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=degrade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"degrade.js","sourceRoot":"","sources":["../src/degrade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAI,OAAgB,EAAE,OAA6B;IACjF,IAAI,CAAC;QACH,OAAO,OAAO,EAAE,CAAC;IACnB,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,OAAO,OAAO,CAAC,sBAAsB,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjE,CAAC;AACH,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;IACrE,OAAO,iCAAiC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AAC1D,CAAC"}
|
package/dist/discover.d.ts
CHANGED
|
@@ -1,58 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* File discovery.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* uses are `src/**` + extension, which is three regex constructs, and an adapter
|
|
6
|
-
* that ships one dependency ships that dependency's transitive tree into every
|
|
7
|
-
* install of a locally-installed developer tool.
|
|
2
|
+
* File discovery. Hand-rolled rather than a glob dependency: corpus manifests
|
|
3
|
+
* only need `src/**` + extension (three regex constructs), and a dependency
|
|
4
|
+
* here ships its whole transitive tree into every install of this tool.
|
|
8
5
|
*/
|
|
9
6
|
/**
|
|
10
|
-
* Directory patterns a repository's own `.gitignore`
|
|
11
|
-
*
|
|
12
|
-
* **Deliberately only directories, and deliberately only unambiguous ones.** A
|
|
13
|
-
* full gitignore implementation has negation, nesting, anchoring and precedence,
|
|
14
|
-
* and every one of those is a way to exclude a file that is real source. The
|
|
15
|
-
* asymmetry decides the design: a build directory wrongly walked costs parse
|
|
16
|
-
* time and some junk nodes, while a source directory wrongly skipped removes
|
|
17
|
-
* real code from the graph and *cannot be seen* in any recall measurement,
|
|
18
|
-
* because the files never entered the denominator.
|
|
7
|
+
* Directory patterns a repository's own `.gitignore` excludes.
|
|
19
8
|
*
|
|
20
|
-
*
|
|
21
|
-
* `coverage` on
|
|
22
|
-
*
|
|
23
|
-
*
|
|
9
|
+
* Deliberately only directories, and only unambiguous ones (`dist/`, `/build`,
|
|
10
|
+
* `coverage` alone on a line — no globs, negation, or path separators). A full
|
|
11
|
+
* gitignore implementation has negation, nesting, anchoring and precedence,
|
|
12
|
+
* and each is a way to wrongly exclude real source; a wrongly-walked build dir
|
|
13
|
+
* just costs parse time, but a wrongly-skipped source dir removes code from
|
|
14
|
+
* the graph invisibly — it never enters the recall denominator. What this
|
|
15
|
+
* declines to interpret is simply walked, as before.
|
|
24
16
|
*/
|
|
25
17
|
export declare function ignoredDirectories(root: string): ReadonlySet<string>;
|
|
26
18
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* characters within one segment) and `?`. That is the whole surface the corpus
|
|
31
|
-
* manifests use; anything more would be inventing requirements.
|
|
19
|
+
* Glob to anchored regex. Supports `**` (any path depth, incl. zero), `*`
|
|
20
|
+
* (any run within one segment) and `?` — the whole surface corpus manifests
|
|
21
|
+
* use; more would be inventing requirements.
|
|
32
22
|
*/
|
|
33
23
|
export declare function globToRegExp(glob: string): RegExp;
|
|
34
24
|
export declare function matchesAny(path: string, globs: readonly string[]): boolean;
|
|
35
25
|
/**
|
|
36
26
|
* Every file under `root` matching any glob, repo-relative and sorted.
|
|
37
27
|
*
|
|
38
|
-
* Sorted
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* filesystem rather than on this one.
|
|
28
|
+
* Sorted so batch contents don't depend on directory-entry order: the engine
|
|
29
|
+
* asserts that ingesting the same repo twice is byte-identical, and an
|
|
30
|
+
* unsorted walk breaks that on a different filesystem, not this one.
|
|
42
31
|
*/
|
|
43
32
|
export interface DiscoverOptions {
|
|
44
|
-
/**
|
|
45
|
-
* Called once with every directory name `.gitignore` excluded, so the count
|
|
46
|
-
* reaches the report rather than vanishing into the walk.
|
|
47
|
-
*/
|
|
33
|
+
/** Called once with every directory `.gitignore` excluded, so the count reaches the report. */
|
|
48
34
|
readonly onIgnored?: (names: readonly string[]) => void;
|
|
49
35
|
/**
|
|
50
|
-
* Called for each nested checkout skipped, repo-relative.
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* itself is a fact the report has to be able to state, because the difference
|
|
54
|
-
* between "we analysed 1,087 files" and "we analysed 1,087 of 4,300" is the
|
|
55
|
-
* difference between a result and a misleading one.
|
|
36
|
+
* Called for each nested checkout skipped, repo-relative. Surfaced rather
|
|
37
|
+
* than logged — "analysed 1,087 files" and "analysed 1,087 of 4,300" are
|
|
38
|
+
* different claims, and the report must be able to state which one is true.
|
|
56
39
|
*/
|
|
57
40
|
readonly onNestedCheckout?: (repoRelativeDir: string) => void;
|
|
58
41
|
}
|
package/dist/discover.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAqBpE;AAMD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAkBjD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAE1E;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,+FAA+F;IAC/F,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,KAAK,IAAI,CAAC;IACxD;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,eAAe,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/D;AAcD,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,GAAE,eAAoB,GAC5B,MAAM,EAAE,CA+BV;AAED,qFAAqF;AACrF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIrE"}
|
package/dist/discover.js
CHANGED
|
@@ -1,39 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* File discovery.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* uses are `src/**` + extension, which is three regex constructs, and an adapter
|
|
6
|
-
* that ships one dependency ships that dependency's transitive tree into every
|
|
7
|
-
* install of a locally-installed developer tool.
|
|
2
|
+
* File discovery. Hand-rolled rather than a glob dependency: corpus manifests
|
|
3
|
+
* only need `src/**` + extension (three regex constructs), and a dependency
|
|
4
|
+
* here ships its whole transitive tree into every install of this tool.
|
|
8
5
|
*/
|
|
9
6
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
10
7
|
import { join, sep } from "node:path";
|
|
11
8
|
/**
|
|
12
|
-
* Directories never worth walking
|
|
9
|
+
* Directories never worth walking, skipped before `readdir`.
|
|
13
10
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* standing rule is that where the project will tell you, you never infer. So the
|
|
18
|
-
* list stays for repositories with no `.gitignore` and for `.git` itself, and
|
|
19
|
-
* `ignoredDirectories` reads the declaration on top of it.
|
|
11
|
+
* A **floor, not the policy**: a guess about build output, kept only for repos
|
|
12
|
+
* with no `.gitignore` (and for `.git` itself). Where the project declares its
|
|
13
|
+
* own exclusions, `ignoredDirectories` reads that instead of guessing.
|
|
20
14
|
*/
|
|
21
15
|
const SKIP = new Set(["node_modules", ".git", "dist", "build", "out", "coverage", ".next"]);
|
|
22
16
|
/**
|
|
23
|
-
* Directory patterns a repository's own `.gitignore`
|
|
24
|
-
*
|
|
25
|
-
* **Deliberately only directories, and deliberately only unambiguous ones.** A
|
|
26
|
-
* full gitignore implementation has negation, nesting, anchoring and precedence,
|
|
27
|
-
* and every one of those is a way to exclude a file that is real source. The
|
|
28
|
-
* asymmetry decides the design: a build directory wrongly walked costs parse
|
|
29
|
-
* time and some junk nodes, while a source directory wrongly skipped removes
|
|
30
|
-
* real code from the graph and *cannot be seen* in any recall measurement,
|
|
31
|
-
* because the files never entered the denominator.
|
|
17
|
+
* Directory patterns a repository's own `.gitignore` excludes.
|
|
32
18
|
*
|
|
33
|
-
*
|
|
34
|
-
* `coverage` on
|
|
35
|
-
*
|
|
36
|
-
*
|
|
19
|
+
* Deliberately only directories, and only unambiguous ones (`dist/`, `/build`,
|
|
20
|
+
* `coverage` alone on a line — no globs, negation, or path separators). A full
|
|
21
|
+
* gitignore implementation has negation, nesting, anchoring and precedence,
|
|
22
|
+
* and each is a way to wrongly exclude real source; a wrongly-walked build dir
|
|
23
|
+
* just costs parse time, but a wrongly-skipped source dir removes code from
|
|
24
|
+
* the graph invisibly — it never enters the recall denominator. What this
|
|
25
|
+
* declines to interpret is simply walked, as before.
|
|
37
26
|
*/
|
|
38
27
|
export function ignoredDirectories(root) {
|
|
39
28
|
const names = new Set();
|
|
@@ -65,11 +54,9 @@ function escape(literal) {
|
|
|
65
54
|
return literal.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
66
55
|
}
|
|
67
56
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* characters within one segment) and `?`. That is the whole surface the corpus
|
|
72
|
-
* manifests use; anything more would be inventing requirements.
|
|
57
|
+
* Glob to anchored regex. Supports `**` (any path depth, incl. zero), `*`
|
|
58
|
+
* (any run within one segment) and `?` — the whole surface corpus manifests
|
|
59
|
+
* use; more would be inventing requirements.
|
|
73
60
|
*/
|
|
74
61
|
export function globToRegExp(glob) {
|
|
75
62
|
let out = "";
|
|
@@ -77,8 +64,7 @@ export function globToRegExp(glob) {
|
|
|
77
64
|
const char = glob[i];
|
|
78
65
|
if (char === "*") {
|
|
79
66
|
if (glob[i + 1] === "*") {
|
|
80
|
-
// `**/`
|
|
81
|
-
// `src/**/*.ts` matches `src/money.ts` as well as `src/ui/Page.ts`.
|
|
67
|
+
// `**/` = any depth incl. zero, so `src/**/*.ts` matches `src/money.ts` too.
|
|
82
68
|
const slash = glob[i + 2] === "/";
|
|
83
69
|
out += slash ? "(?:[^/]+/)*" : ".*";
|
|
84
70
|
i += slash ? 2 : 1;
|
|
@@ -95,15 +81,12 @@ export function matchesAny(path, globs) {
|
|
|
95
81
|
return globs.some((glob) => globToRegExp(glob).test(path));
|
|
96
82
|
}
|
|
97
83
|
/**
|
|
98
|
-
* A directory holding its own `.git` is a different
|
|
99
|
-
*
|
|
100
|
-
* `
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* Found on real code. One repository contained three worktrees of itself, each
|
|
105
|
-
* with the same `package.json` name — 6,309 of 8,902 emitted nodes were exact
|
|
106
|
-
* identity collisions with their own copies.
|
|
84
|
+
* A directory holding its own `.git` is a different repo (submodule, vendored
|
|
85
|
+
* checkout, worktree) and is skipped: node identity is `hash(repo, kind,
|
|
86
|
+
* path)` (DEC-011), so analysing it as part of the parent stamps the parent's
|
|
87
|
+
* repo id onto another repo's symbols. Measured on real code — one repo with
|
|
88
|
+
* three worktrees of itself produced 6,309 of 8,902 emitted nodes as exact
|
|
89
|
+
* identity collisions.
|
|
107
90
|
*/
|
|
108
91
|
function isNestedCheckout(dir) {
|
|
109
92
|
return existsSync(join(dir, ".git"));
|
package/dist/discover.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover.js","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAAA
|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index.d.ts
CHANGED
|
@@ -10,4 +10,5 @@ export { discover, globToRegExp, ignoredDirectories, matchesAny, toRepoRelative
|
|
|
10
10
|
export type { DiscoverOptions } from "./discover.ts";
|
|
11
11
|
export { isolateFile } from "./isolate.ts";
|
|
12
12
|
export type { Isolated, IsolatedFailure } from "./isolate.ts";
|
|
13
|
+
export { extractOrDegrade, describeThrown } from "./degrade.ts";
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACvG,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACvG,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEvG,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEvG,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/isolate.d.ts
CHANGED
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Per-file isolation for the work
|
|
2
|
+
* Per-file isolation for the work *after* a file parses. Read/parse errors are
|
|
3
|
+
* already isolated (`unreadable`, `too-large`, `parseText`'s caught failure);
|
|
4
|
+
* the unguarded step is walking a parsed tree into an adapter's per-file unit,
|
|
5
|
+
* which indexes children and assumes shapes a grammar can decline to produce —
|
|
6
|
+
* a throw there takes the whole pass down, not just one file (real failure
|
|
7
|
+
* mode: `Cannot read properties of undefined (reading 'length')`, worst when
|
|
8
|
+
* a developer is analysing the file they just half-finished writing).
|
|
3
9
|
*
|
|
4
|
-
*
|
|
5
|
-
* `
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* per-file unit. That code indexes children, reads `.length`, and assumes shapes
|
|
9
|
-
* a real grammar can decline to produce, and a throw there does not degrade one
|
|
10
|
-
* file: it takes the whole pass down, along with every file that had already
|
|
11
|
-
* succeeded.
|
|
12
|
-
*
|
|
13
|
-
* That failure mode is not hypothetical. `Cannot read properties of undefined
|
|
14
|
-
* (reading 'length')` is exactly its shape, and it fires hardest at the worst
|
|
15
|
-
* moment — a developer analysing code they just wrote is analysing the file most
|
|
16
|
-
* likely to be half-finished.
|
|
17
|
-
*
|
|
18
|
-
* The vocabulary does not grow to accommodate this. A step that throws is a file
|
|
19
|
-
* we could not finish reading, disclosed through `skippedFiles` with reason
|
|
20
|
-
* `other` and the real error message as its detail — the same route
|
|
21
|
-
* `adapter-go` already uses for a file it can see but cannot place in a module.
|
|
22
|
-
* `SkipReason` stays at four values.
|
|
10
|
+
* The vocabulary doesn't grow for this: a throw becomes a `skippedFiles` entry
|
|
11
|
+
* with reason `other` and the real error as detail — same route `adapter-go`
|
|
12
|
+
* uses for a file it can see but can't place in a module. `SkipReason` stays
|
|
13
|
+
* at four values.
|
|
23
14
|
*/
|
|
24
15
|
/** A file the adapter parsed but could not finish, and why. */
|
|
25
16
|
export interface IsolatedFailure {
|
|
@@ -37,14 +28,13 @@ export type Isolated<T> = {
|
|
|
37
28
|
/**
|
|
38
29
|
* Run one file's step, converting a throw into a disclosed skip for that file.
|
|
39
30
|
*
|
|
40
|
-
* Deliberately synchronous
|
|
41
|
-
* already-parsed tree, and
|
|
42
|
-
*
|
|
43
|
-
*
|
|
31
|
+
* Deliberately synchronous — every adapter's per-file walk is synchronous over
|
|
32
|
+
* an already-parsed tree, and async here would invite I/O inside the boundary,
|
|
33
|
+
* where a partially-written unit is harder to reason about than a
|
|
34
|
+
* partially-read directory.
|
|
44
35
|
*
|
|
45
|
-
*
|
|
46
|
-
* recording it as one would
|
|
47
|
-
* disclosure about the repository for every file that had not been reached yet.
|
|
36
|
+
* An abort is re-thrown: a cancelled run isn't a corpus of broken files, and
|
|
37
|
+
* recording it as one would misreport every file not yet reached as broken.
|
|
48
38
|
*/
|
|
49
39
|
export declare function isolateFile<T>(file: string, step: () => T): Isolated<T>;
|
|
50
40
|
//# sourceMappingURL=isolate.d.ts.map
|
package/dist/isolate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isolate.d.ts","sourceRoot":"","sources":["../src/isolate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"isolate.d.ts","sourceRoot":"","sources":["../src/isolate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,+DAA+D;AAC/D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,IAClB;IAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAA;CAAE,GAClD;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAA;CAAE,CAAC;AAErE;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAUvE"}
|
package/dist/isolate.js
CHANGED
|
@@ -1,37 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Per-file isolation for the work
|
|
2
|
+
* Per-file isolation for the work *after* a file parses. Read/parse errors are
|
|
3
|
+
* already isolated (`unreadable`, `too-large`, `parseText`'s caught failure);
|
|
4
|
+
* the unguarded step is walking a parsed tree into an adapter's per-file unit,
|
|
5
|
+
* which indexes children and assumes shapes a grammar can decline to produce —
|
|
6
|
+
* a throw there takes the whole pass down, not just one file (real failure
|
|
7
|
+
* mode: `Cannot read properties of undefined (reading 'length')`, worst when
|
|
8
|
+
* a developer is analysing the file they just half-finished writing).
|
|
3
9
|
*
|
|
4
|
-
*
|
|
5
|
-
* `
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* per-file unit. That code indexes children, reads `.length`, and assumes shapes
|
|
9
|
-
* a real grammar can decline to produce, and a throw there does not degrade one
|
|
10
|
-
* file: it takes the whole pass down, along with every file that had already
|
|
11
|
-
* succeeded.
|
|
12
|
-
*
|
|
13
|
-
* That failure mode is not hypothetical. `Cannot read properties of undefined
|
|
14
|
-
* (reading 'length')` is exactly its shape, and it fires hardest at the worst
|
|
15
|
-
* moment — a developer analysing code they just wrote is analysing the file most
|
|
16
|
-
* likely to be half-finished.
|
|
17
|
-
*
|
|
18
|
-
* The vocabulary does not grow to accommodate this. A step that throws is a file
|
|
19
|
-
* we could not finish reading, disclosed through `skippedFiles` with reason
|
|
20
|
-
* `other` and the real error message as its detail — the same route
|
|
21
|
-
* `adapter-go` already uses for a file it can see but cannot place in a module.
|
|
22
|
-
* `SkipReason` stays at four values.
|
|
10
|
+
* The vocabulary doesn't grow for this: a throw becomes a `skippedFiles` entry
|
|
11
|
+
* with reason `other` and the real error as detail — same route `adapter-go`
|
|
12
|
+
* uses for a file it can see but can't place in a module. `SkipReason` stays
|
|
13
|
+
* at four values.
|
|
23
14
|
*/
|
|
24
15
|
/**
|
|
25
16
|
* Run one file's step, converting a throw into a disclosed skip for that file.
|
|
26
17
|
*
|
|
27
|
-
* Deliberately synchronous
|
|
28
|
-
* already-parsed tree, and
|
|
29
|
-
*
|
|
30
|
-
*
|
|
18
|
+
* Deliberately synchronous — every adapter's per-file walk is synchronous over
|
|
19
|
+
* an already-parsed tree, and async here would invite I/O inside the boundary,
|
|
20
|
+
* where a partially-written unit is harder to reason about than a
|
|
21
|
+
* partially-read directory.
|
|
31
22
|
*
|
|
32
|
-
*
|
|
33
|
-
* recording it as one would
|
|
34
|
-
* disclosure about the repository for every file that had not been reached yet.
|
|
23
|
+
* An abort is re-thrown: a cancelled run isn't a corpus of broken files, and
|
|
24
|
+
* recording it as one would misreport every file not yet reached as broken.
|
|
35
25
|
*/
|
|
36
26
|
export function isolateFile(file, step) {
|
|
37
27
|
try {
|
package/dist/isolate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isolate.js","sourceRoot":"","sources":["../src/isolate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"isolate.js","sourceRoot":"","sources":["../src/isolate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAaH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAI,IAAY,EAAE,IAAa;IACxD,IAAI,CAAC;QACH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY;YAAE,MAAM,KAAK,CAAC;QACvE,OAAO;YACL,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;SAClF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@descryy/adapter-common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shared adapter infrastructure: file discovery, glob matching, path normalisation. No language knowledge.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/descryhq-wq/descry-adapters.git",
|
|
10
|
+
"directory": "packages/adapter-common"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/descryhq-wq/descry-adapters/issues"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/descryhq-wq/descry-adapters#readme",
|
|
7
16
|
"engines": {
|
|
8
17
|
"node": ">=22.5"
|
|
9
18
|
},
|