@vibe-agent-toolkit/utils 0.2.0-rc.10 → 0.2.0-rc.12
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/README.md +112 -10
- package/dist/archive/archive.d.ts +129 -0
- package/dist/archive/archive.d.ts.map +1 -0
- package/dist/archive/archive.js +223 -0
- package/dist/archive/archive.js.map +1 -0
- package/dist/archive/entries.d.ts +132 -0
- package/dist/archive/entries.d.ts.map +1 -0
- package/dist/archive/entries.js +223 -0
- package/dist/archive/entries.js.map +1 -0
- package/dist/archive/limits.d.ts +39 -0
- package/dist/archive/limits.d.ts.map +1 -0
- package/dist/archive/limits.js +59 -0
- package/dist/archive/limits.js.map +1 -0
- package/dist/archive/records.d.ts +14 -0
- package/dist/archive/records.d.ts.map +1 -0
- package/dist/archive/records.js +3 -0
- package/dist/archive/records.js.map +1 -0
- package/dist/archive/tar-reader.d.ts +18 -0
- package/dist/archive/tar-reader.d.ts.map +1 -0
- package/dist/archive/tar-reader.js +173 -0
- package/dist/archive/tar-reader.js.map +1 -0
- package/dist/archive/zip-reader.d.ts +76 -0
- package/dist/archive/zip-reader.d.ts.map +1 -0
- package/dist/archive/zip-reader.js +376 -0
- package/dist/archive/zip-reader.js.map +1 -0
- package/dist/archive.d.ts +14 -0
- package/dist/archive.d.ts.map +1 -0
- package/dist/archive.js +12 -0
- package/dist/archive.js.map +1 -0
- package/dist/asset-reference.d.ts +17 -1
- package/dist/asset-reference.d.ts.map +1 -1
- package/dist/asset-reference.js +31 -7
- package/dist/asset-reference.js.map +1 -1
- package/dist/dirent-kind.d.ts +13 -40
- package/dist/dirent-kind.d.ts.map +1 -1
- package/dist/dirent-kind.js +21 -69
- package/dist/dirent-kind.js.map +1 -1
- package/dist/entrypoint.d.ts +2 -2
- package/dist/entrypoint.d.ts.map +1 -1
- package/dist/entrypoint.js +4 -3
- package/dist/entrypoint.js.map +1 -1
- package/dist/env-flag.d.ts +13 -5
- package/dist/env-flag.d.ts.map +1 -1
- package/dist/env-flag.js +13 -5
- package/dist/env-flag.js.map +1 -1
- package/dist/errors/confirmed-absent.d.ts +41 -0
- package/dist/errors/confirmed-absent.d.ts.map +1 -0
- package/dist/errors/confirmed-absent.js +43 -0
- package/dist/errors/confirmed-absent.js.map +1 -0
- package/dist/errors/errno-table.d.ts +177 -0
- package/dist/errors/errno-table.d.ts.map +1 -0
- package/dist/errors/errno-table.js +343 -0
- package/dist/errors/errno-table.js.map +1 -0
- package/dist/errors/fs-boundary.d.ts +36 -0
- package/dist/errors/fs-boundary.d.ts.map +1 -0
- package/dist/errors/fs-boundary.js +121 -0
- package/dist/errors/fs-boundary.js.map +1 -0
- package/dist/errors/fs-fault.d.ts +176 -0
- package/dist/errors/fs-fault.d.ts.map +1 -0
- package/dist/errors/fs-fault.js +215 -0
- package/dist/errors/fs-fault.js.map +1 -0
- package/dist/errors/git-errno.d.ts +13 -0
- package/dist/errors/git-errno.d.ts.map +1 -0
- package/dist/errors/git-errno.js +45 -0
- package/dist/errors/git-errno.js.map +1 -0
- package/dist/errors/path-present.d.ts +72 -0
- package/dist/errors/path-present.d.ts.map +1 -0
- package/dist/errors/path-present.js +110 -0
- package/dist/errors/path-present.js.map +1 -0
- package/dist/errors/rag-index-empty.d.ts +16 -0
- package/dist/errors/rag-index-empty.d.ts.map +1 -0
- package/dist/errors/rag-index-empty.js +16 -0
- package/dist/errors/rag-index-empty.js.map +1 -0
- package/dist/errors/suppressed-faults.d.ts +34 -0
- package/dist/errors/suppressed-faults.d.ts.map +1 -0
- package/dist/errors/suppressed-faults.js +66 -0
- package/dist/errors/suppressed-faults.js.map +1 -0
- package/dist/file-crawler.d.ts +13 -18
- package/dist/file-crawler.d.ts.map +1 -1
- package/dist/file-crawler.js +140 -24
- package/dist/file-crawler.js.map +1 -1
- package/dist/fs-utils.d.ts +75 -50
- package/dist/fs-utils.d.ts.map +1 -1
- package/dist/fs-utils.js +148 -158
- package/dist/fs-utils.js.map +1 -1
- package/dist/fs.d.ts +5 -4
- package/dist/fs.d.ts.map +1 -1
- package/dist/fs.js +5 -4
- package/dist/fs.js.map +1 -1
- package/dist/git-snapshot.d.ts +25 -17
- package/dist/git-snapshot.d.ts.map +1 -1
- package/dist/git-snapshot.js +65 -11
- package/dist/git-snapshot.js.map +1 -1
- package/dist/git-tracker.d.ts +11 -3
- package/dist/git-tracker.d.ts.map +1 -1
- package/dist/git-tracker.js +29 -6
- package/dist/git-tracker.js.map +1 -1
- package/dist/git-utils.d.ts.map +1 -1
- package/dist/git-utils.js +7 -35
- package/dist/git-utils.js.map +1 -1
- package/dist/git.d.ts +1 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/git.js +1 -1
- package/dist/git.js.map +1 -1
- package/dist/gitignore-checker.d.ts.map +1 -1
- package/dist/gitignore-checker.js +5 -4
- package/dist/gitignore-checker.js.map +1 -1
- package/dist/in-order.d.ts +93 -0
- package/dist/in-order.d.ts.map +1 -0
- package/dist/in-order.js +165 -0
- package/dist/in-order.js.map +1 -0
- package/dist/index.d.ts +20 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -4
- package/dist/index.js.map +1 -1
- package/dist/kill-process-tree.d.ts +43 -0
- package/dist/kill-process-tree.d.ts.map +1 -0
- package/dist/kill-process-tree.js +48 -0
- package/dist/kill-process-tree.js.map +1 -0
- package/dist/link-following.d.ts +115 -0
- package/dist/link-following.d.ts.map +1 -0
- package/dist/link-following.js +283 -0
- package/dist/link-following.js.map +1 -0
- package/dist/listing-refusal.d.ts +44 -0
- package/dist/listing-refusal.d.ts.map +1 -1
- package/dist/listing-refusal.js +79 -2
- package/dist/listing-refusal.js.map +1 -1
- package/dist/name-fold.d.ts +25 -0
- package/dist/name-fold.d.ts.map +1 -0
- package/dist/name-fold.js +40 -0
- package/dist/name-fold.js.map +1 -0
- package/dist/path-containment.d.ts +17 -0
- package/dist/path-containment.d.ts.map +1 -1
- package/dist/path-containment.js +28 -5
- package/dist/path-containment.js.map +1 -1
- package/dist/path-utils.d.ts +14 -17
- package/dist/path-utils.d.ts.map +1 -1
- package/dist/path-utils.js +37 -55
- package/dist/path-utils.js.map +1 -1
- package/dist/process.d.ts +2 -0
- package/dist/process.d.ts.map +1 -1
- package/dist/process.js +2 -0
- package/dist/process.js.map +1 -1
- package/dist/project-utils.d.ts.map +1 -1
- package/dist/project-utils.js +8 -9
- package/dist/project-utils.js.map +1 -1
- package/dist/safe-exec.d.ts +6 -2
- package/dist/safe-exec.d.ts.map +1 -1
- package/dist/safe-exec.js +1 -1
- package/dist/safe-exec.js.map +1 -1
- package/dist/skill-targets.d.ts.map +1 -1
- package/dist/skill-targets.js +3 -1
- package/dist/skill-targets.js.map +1 -1
- package/dist/skill-test/spawn-claude.d.ts +0 -15
- package/dist/skill-test/spawn-claude.d.ts.map +1 -1
- package/dist/skill-test/spawn-claude.js +11 -50
- package/dist/skill-test/spawn-claude.js.map +1 -1
- package/dist/special-file.d.ts +18 -0
- package/dist/special-file.d.ts.map +1 -0
- package/dist/special-file.js +21 -0
- package/dist/special-file.js.map +1 -0
- package/dist/terminating-signals.d.ts +129 -0
- package/dist/terminating-signals.d.ts.map +1 -0
- package/dist/terminating-signals.js +210 -0
- package/dist/terminating-signals.js.map +1 -0
- package/dist/test-helpers.d.ts +9 -5
- package/dist/test-helpers.d.ts.map +1 -1
- package/dist/test-helpers.js +18 -21
- package/dist/test-helpers.js.map +1 -1
- package/dist/test-scratch-guard.d.ts +34 -0
- package/dist/test-scratch-guard.d.ts.map +1 -0
- package/dist/test-scratch-guard.js +45 -0
- package/dist/test-scratch-guard.js.map +1 -0
- package/dist/testing/archive-fixtures.d.ts +147 -0
- package/dist/testing/archive-fixtures.d.ts.map +1 -0
- package/dist/testing/archive-fixtures.js +449 -0
- package/dist/testing/archive-fixtures.js.map +1 -0
- package/dist/testing/executables.d.ts +6 -0
- package/dist/testing/executables.d.ts.map +1 -1
- package/dist/testing/executables.js +20 -9
- package/dist/testing/executables.js.map +1 -1
- package/dist/testing/fault-fs-preload.d.ts +16 -0
- package/dist/testing/fault-fs-preload.d.ts.map +1 -0
- package/dist/testing/fault-fs-preload.js +22 -0
- package/dist/testing/fault-fs-preload.js.map +1 -0
- package/dist/testing/fault-fs.d.ts +115 -0
- package/dist/testing/fault-fs.d.ts.map +1 -0
- package/dist/testing/fault-fs.js +411 -0
- package/dist/testing/fault-fs.js.map +1 -0
- package/dist/testing/fault-spec.d.ts +83 -0
- package/dist/testing/fault-spec.d.ts.map +1 -0
- package/dist/testing/fault-spec.js +132 -0
- package/dist/testing/fault-spec.js.map +1 -0
- package/dist/testing/hostile-tree.d.ts.map +1 -1
- package/dist/testing/hostile-tree.js +3 -4
- package/dist/testing/hostile-tree.js.map +1 -1
- package/dist/testing/platform-gates.d.ts +8 -0
- package/dist/testing/platform-gates.d.ts.map +1 -1
- package/dist/testing/platform-gates.js +24 -0
- package/dist/testing/platform-gates.js.map +1 -1
- package/dist/testing/temp-dir.d.ts +31 -0
- package/dist/testing/temp-dir.d.ts.map +1 -1
- package/dist/testing/temp-dir.js +63 -0
- package/dist/testing/temp-dir.js.map +1 -1
- package/dist/testing/tier-timeout.d.ts +34 -0
- package/dist/testing/tier-timeout.d.ts.map +1 -0
- package/dist/testing/tier-timeout.js +45 -0
- package/dist/testing/tier-timeout.js.map +1 -0
- package/dist/testing/tree-snapshot.d.ts +71 -0
- package/dist/testing/tree-snapshot.d.ts.map +1 -0
- package/dist/testing/tree-snapshot.js +163 -0
- package/dist/testing/tree-snapshot.js.map +1 -0
- package/dist/testing.d.ts +6 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +8 -1
- package/dist/testing.js.map +1 -1
- package/dist/text-content.d.ts +29 -0
- package/dist/text-content.d.ts.map +1 -1
- package/dist/text-content.js +64 -0
- package/dist/text-content.js.map +1 -1
- package/dist/text-file.d.ts +58 -6
- package/dist/text-file.d.ts.map +1 -1
- package/dist/text-file.js +111 -11
- package/dist/text-file.js.map +1 -1
- package/dist/text.d.ts +1 -1
- package/dist/text.d.ts.map +1 -1
- package/dist/text.js +1 -1
- package/dist/text.js.map +1 -1
- package/dist/timing-dump.d.ts.map +1 -1
- package/dist/timing-dump.js +2 -10
- package/dist/timing-dump.js.map +1 -1
- package/dist/tree-change/apply-decisions.d.ts +101 -0
- package/dist/tree-change/apply-decisions.d.ts.map +1 -0
- package/dist/tree-change/apply-decisions.js +139 -0
- package/dist/tree-change/apply-decisions.js.map +1 -0
- package/dist/tree-change/apply.d.ts +98 -0
- package/dist/tree-change/apply.d.ts.map +1 -0
- package/dist/tree-change/apply.js +364 -0
- package/dist/tree-change/apply.js.map +1 -0
- package/dist/tree-change/copy-decisions.d.ts +58 -0
- package/dist/tree-change/copy-decisions.d.ts.map +1 -0
- package/dist/tree-change/copy-decisions.js +66 -0
- package/dist/tree-change/copy-decisions.js.map +1 -0
- package/dist/tree-change/copy-tree.d.ts +125 -0
- package/dist/tree-change/copy-tree.d.ts.map +1 -0
- package/dist/tree-change/copy-tree.js +279 -0
- package/dist/tree-change/copy-tree.js.map +1 -0
- package/dist/tree-change/files.d.ts +167 -0
- package/dist/tree-change/files.d.ts.map +1 -0
- package/dist/tree-change/files.js +423 -0
- package/dist/tree-change/files.js.map +1 -0
- package/dist/tree-change/followed-walk.d.ts +54 -0
- package/dist/tree-change/followed-walk.d.ts.map +1 -0
- package/dist/tree-change/followed-walk.js +81 -0
- package/dist/tree-change/followed-walk.js.map +1 -0
- package/dist/tree-change/host-chain.d.ts +48 -0
- package/dist/tree-change/host-chain.d.ts.map +1 -0
- package/dist/tree-change/host-chain.js +85 -0
- package/dist/tree-change/host-chain.js.map +1 -0
- package/dist/tree-change/identity-compare.d.ts +61 -0
- package/dist/tree-change/identity-compare.d.ts.map +1 -0
- package/dist/tree-change/identity-compare.js +115 -0
- package/dist/tree-change/identity-compare.js.map +1 -0
- package/dist/tree-change/identity.d.ts +62 -0
- package/dist/tree-change/identity.d.ts.map +1 -0
- package/dist/tree-change/identity.js +152 -0
- package/dist/tree-change/identity.js.map +1 -0
- package/dist/tree-change/index.d.ts +24 -0
- package/dist/tree-change/index.d.ts.map +1 -0
- package/dist/tree-change/index.js +14 -0
- package/dist/tree-change/index.js.map +1 -0
- package/dist/tree-change/link-chain.d.ts +180 -0
- package/dist/tree-change/link-chain.d.ts.map +1 -0
- package/dist/tree-change/link-chain.js +377 -0
- package/dist/tree-change/link-chain.js.map +1 -0
- package/dist/tree-change/link-containment.d.ts +105 -0
- package/dist/tree-change/link-containment.d.ts.map +1 -0
- package/dist/tree-change/link-containment.js +196 -0
- package/dist/tree-change/link-containment.js.map +1 -0
- package/dist/tree-change/link-walk.d.ts +49 -0
- package/dist/tree-change/link-walk.d.ts.map +1 -0
- package/dist/tree-change/link-walk.js +69 -0
- package/dist/tree-change/link-walk.js.map +1 -0
- package/dist/tree-change/plan.d.ts +206 -0
- package/dist/tree-change/plan.d.ts.map +1 -0
- package/dist/tree-change/plan.js +320 -0
- package/dist/tree-change/plan.js.map +1 -0
- package/dist/tree-change/readable-tree.d.ts +44 -0
- package/dist/tree-change/readable-tree.d.ts.map +1 -0
- package/dist/tree-change/readable-tree.js +52 -0
- package/dist/tree-change/readable-tree.js.map +1 -0
- package/dist/tree-change/rollback-error.d.ts +29 -0
- package/dist/tree-change/rollback-error.d.ts.map +1 -0
- package/dist/tree-change/rollback-error.js +31 -0
- package/dist/tree-change/rollback-error.js.map +1 -0
- package/dist/tree-change/staging-names.d.ts +27 -0
- package/dist/tree-change/staging-names.d.ts.map +1 -0
- package/dist/tree-change/staging-names.js +40 -0
- package/dist/tree-change/staging-names.js.map +1 -0
- package/dist/tree-change/tree-walk.d.ts +81 -0
- package/dist/tree-change/tree-walk.d.ts.map +1 -0
- package/dist/tree-change/tree-walk.js +212 -0
- package/dist/tree-change/tree-walk.js.map +1 -0
- package/dist/win32-namespace.d.ts +24 -0
- package/dist/win32-namespace.d.ts.map +1 -0
- package/dist/win32-namespace.js +31 -0
- package/dist/win32-namespace.js.map +1 -0
- package/dist/yaml/surgical-yaml.d.ts +12 -3
- package/dist/yaml/surgical-yaml.d.ts.map +1 -1
- package/dist/yaml/surgical-yaml.js +16 -6
- package/dist/yaml/surgical-yaml.js.map +1 -1
- package/eslint/README.md +12 -4
- package/eslint/rules/fs-binding-scan.cjs +278 -0
- package/eslint/rules/no-adhoc-errno.cjs +364 -0
- package/eslint/rules/no-bare-symlink-in-tests.cjs +2 -3
- package/eslint/rules/no-blind-catch.cjs +1 -1
- package/eslint/rules/no-destructive-fs.cjs +359 -0
- package/eslint/rules/no-existssync.cjs +70 -0
- package/eslint/rules/no-fragile-entrypoint-guard.cjs +3 -2
- package/eslint/rules/no-link-following-fs.cjs +68 -0
- package/eslint/rules/no-literal-process-exit.cjs +96 -8
- package/eslint/rules/no-literal-test-timeout.cjs +214 -0
- package/eslint/rules/no-raw-signal-listener.cjs +224 -0
- package/eslint/rules/no-stdout-outside-writer.cjs +135 -0
- package/package.json +10 -2
- package/dist/errors/errno.d.ts +0 -51
- package/dist/errors/errno.d.ts.map +0 -1
- package/dist/errors/errno.js +0 -112
- package/dist/errors/errno.js.map +0 -1
- package/eslint/rules/no-fs-promises-cp.cjs +0 -43
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ordered and bounded-parallel iteration over async work — THE replacement for
|
|
3
|
+
* `await` inside a loop.
|
|
4
|
+
*
|
|
5
|
+
* `no-await-in-loop` (Sonar S9382) is on repo-wide, and it is right about the
|
|
6
|
+
* default: independent work belongs in `Promise.all` / `mapWithConcurrency`.
|
|
7
|
+
* When the order IS the contract, say so by name with one of the `*InOrder`
|
|
8
|
+
* helpers instead of a disable. None of them is written with `async` or with a
|
|
9
|
+
* loop: each step is chained onto the previous one's promise, so the rule has
|
|
10
|
+
* nothing to see here and a caller's `await` sits behind a function boundary.
|
|
11
|
+
*
|
|
12
|
+
* Every helper starts its callback synchronously and turns a synchronous throw into
|
|
13
|
+
* a rejection — exactly what the body of an `async` loop does — and a callback may
|
|
14
|
+
* return a plain value.
|
|
15
|
+
*/
|
|
16
|
+
/** One item's callback: its value and its position in the run. */
|
|
17
|
+
type InOrderCallback<T, R> = (item: T, index: number) => Promise<R> | R;
|
|
18
|
+
/**
|
|
19
|
+
* Enough parallelism to hide per-call filesystem latency, low enough to stay far
|
|
20
|
+
* from the default file-descriptor ceiling even with several builds at once.
|
|
21
|
+
* The default bound of `mapWithConcurrency`, and the bound every population-sized
|
|
22
|
+
* parallel fs fan-out uses instead of a bare `Promise.all`.
|
|
23
|
+
*/
|
|
24
|
+
export declare const FS_CONCURRENCY = 16;
|
|
25
|
+
/**
|
|
26
|
+
* `work()` as a promise — its value resolved, a synchronous throw rejected — for a
|
|
27
|
+
* Promise-shaped API whose body is synchronous. `Promise.try`, until the Node floor
|
|
28
|
+
* has it. A body that returns a promise is adopted, so its own throw still rejects.
|
|
29
|
+
*/
|
|
30
|
+
export declare function promised<T>(work: () => T): Promise<Awaited<T>>;
|
|
31
|
+
/**
|
|
32
|
+
* Run `fn` over `items` one at a time, each call starting only after the previous
|
|
33
|
+
* one settles.
|
|
34
|
+
*
|
|
35
|
+
* Reach for it when order is the CONTRACT, not an accident: ordered filesystem
|
|
36
|
+
* mutation (mkdir before recursing, a later entry deliberately overwriting an
|
|
37
|
+
* earlier one), first-refusal-wins (the error a user sees must name the FIRST bad
|
|
38
|
+
* item, deterministically — `Promise.all` rejects with the first in time), a
|
|
39
|
+
* shared memo/sink/walk-guard whose first use must not race, a report whose line
|
|
40
|
+
* order is its meaning, or a measurement that must not overlap itself.
|
|
41
|
+
*
|
|
42
|
+
* A rejection stops the run there: later items are never started, exactly as
|
|
43
|
+
* with `await` in `for…of`. Items are pulled lazily from the iterator, so an
|
|
44
|
+
* array that grows during the run is seen. If the items are independent, use
|
|
45
|
+
* `Promise.all` or {@link mapWithConcurrency} instead.
|
|
46
|
+
*/
|
|
47
|
+
export declare function forEachInOrder<T>(items: Iterable<T>, fn: InOrderCallback<T, void>): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* {@link forEachInOrder} that collects each call's result, in input order.
|
|
50
|
+
*
|
|
51
|
+
* For a sequential transform whose steps depend on shared state — a resolver that
|
|
52
|
+
* stages into one root, a cache whose first user must not race — where the caller
|
|
53
|
+
* also needs every result. Stops at the first rejection, like `forEachInOrder`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function mapInOrder<T, R>(items: Iterable<T>, fn: InOrderCallback<T, R>): Promise<R[]>;
|
|
56
|
+
/**
|
|
57
|
+
* `Array#every`, in order and awaited: resolves `false` at the first callback that
|
|
58
|
+
* answers `false`, without starting any later item; resolves `true` when every item
|
|
59
|
+
* answered `true` (vacuously so for no items).
|
|
60
|
+
*
|
|
61
|
+
* The idiom for a loop that used to `break` or `return` early: stop at the first
|
|
62
|
+
* failure and leave the rest untouched — capture whatever the early exit carried in
|
|
63
|
+
* a closure. A rejection stops the run too, and rejects.
|
|
64
|
+
*/
|
|
65
|
+
export declare function everyInOrder<T>(items: Iterable<T>, fn: InOrderCallback<T, boolean>): Promise<boolean>;
|
|
66
|
+
/**
|
|
67
|
+
* `Promise.all`-shaped, but with at most `limit` calls in flight. Results are in
|
|
68
|
+
* input order whatever order the calls finish in.
|
|
69
|
+
*
|
|
70
|
+
* For INDEPENDENT work over a population-sized list — the files in a skill, the
|
|
71
|
+
* skill directories of a plugin — where a bare `Promise.all` would open one file
|
|
72
|
+
* descriptor per item at once. Results are returned rather than pushed into a
|
|
73
|
+
* shared sink from inside the callbacks: concurrent pushes land in finish order,
|
|
74
|
+
* not input order, so fold the returned array afterwards.
|
|
75
|
+
*
|
|
76
|
+
* Rejects with the first rejection in TIME, and stops starting new items once one
|
|
77
|
+
* has rejected (calls already in flight run to completion). When the error a user
|
|
78
|
+
* sees must name the first bad item in input order, this is the wrong tool — use
|
|
79
|
+
* {@link forEachInOrder}.
|
|
80
|
+
*
|
|
81
|
+
* @throws RangeError when `limit` is not a whole number of at least 1 — a `NaN`
|
|
82
|
+
* or `0` limit would otherwise start no workers and silently resolve holes.
|
|
83
|
+
*/
|
|
84
|
+
export declare function mapWithConcurrency<T, R>(items: readonly T[], fn: InOrderCallback<T, R>, limit?: number): Promise<R[]>;
|
|
85
|
+
/**
|
|
86
|
+
* {@link mapWithConcurrency} for independent read-only work whose failure must
|
|
87
|
+
* still be the one a sequential loop would have raised: every call settles, then
|
|
88
|
+
* the rejection of the EARLIEST item by position is rethrown. Results are in
|
|
89
|
+
* input order.
|
|
90
|
+
*/
|
|
91
|
+
export declare function mapConcurrentFailingInOrder<T, R>(items: readonly T[], fn: InOrderCallback<T, R>): Promise<R[]>;
|
|
92
|
+
export {};
|
|
93
|
+
//# sourceMappingURL=in-order.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-order.d.ts","sourceRoot":"","sources":["../src/in-order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,kEAAkE;AAClE,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAO9D;AAuCD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAClB,EAAE,EAAE,eAAe,CAAC,CAAC,EAAE,IAAI,CAAC,GAC3B,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAC7B,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAClB,EAAE,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GACxB,OAAO,CAAC,CAAC,EAAE,CAAC,CAMd;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAClB,EAAE,EAAE,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,OAAO,CAAC,CAElB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,CAAC,EACrC,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,EAAE,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,EACzB,KAAK,GAAE,MAAuB,GAC7B,OAAO,CAAC,CAAC,EAAE,CAAC,CAuBd;AAID;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,CAAC,EAC9C,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,EAAE,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GACxB,OAAO,CAAC,CAAC,EAAE,CAAC,CAYd"}
|
package/dist/in-order.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ordered and bounded-parallel iteration over async work — THE replacement for
|
|
3
|
+
* `await` inside a loop.
|
|
4
|
+
*
|
|
5
|
+
* `no-await-in-loop` (Sonar S9382) is on repo-wide, and it is right about the
|
|
6
|
+
* default: independent work belongs in `Promise.all` / `mapWithConcurrency`.
|
|
7
|
+
* When the order IS the contract, say so by name with one of the `*InOrder`
|
|
8
|
+
* helpers instead of a disable. None of them is written with `async` or with a
|
|
9
|
+
* loop: each step is chained onto the previous one's promise, so the rule has
|
|
10
|
+
* nothing to see here and a caller's `await` sits behind a function boundary.
|
|
11
|
+
*
|
|
12
|
+
* Every helper starts its callback synchronously and turns a synchronous throw into
|
|
13
|
+
* a rejection — exactly what the body of an `async` loop does — and a callback may
|
|
14
|
+
* return a plain value.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Enough parallelism to hide per-call filesystem latency, low enough to stay far
|
|
18
|
+
* from the default file-descriptor ceiling even with several builds at once.
|
|
19
|
+
* The default bound of `mapWithConcurrency`, and the bound every population-sized
|
|
20
|
+
* parallel fs fan-out uses instead of a bare `Promise.all`.
|
|
21
|
+
*/
|
|
22
|
+
export const FS_CONCURRENCY = 16;
|
|
23
|
+
/**
|
|
24
|
+
* `work()` as a promise — its value resolved, a synchronous throw rejected — for a
|
|
25
|
+
* Promise-shaped API whose body is synchronous. `Promise.try`, until the Node floor
|
|
26
|
+
* has it. A body that returns a promise is adopted, so its own throw still rejects.
|
|
27
|
+
*/
|
|
28
|
+
export function promised(work) {
|
|
29
|
+
try {
|
|
30
|
+
return Promise.resolve(work());
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
// Re-raised as-is: the caller's catch must see exactly what `work` threw.
|
|
34
|
+
return Promise.reject(error);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** Start `fn` now, turning a synchronous throw into a rejection. */
|
|
38
|
+
function settle(fn, item, index) {
|
|
39
|
+
return promised(() => fn(item, index));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The shared chain: pull the next item, run `fn`, hand the result to `keepGoing`,
|
|
43
|
+
* and continue only when it says so. The iterator is closed on an early stop or a
|
|
44
|
+
* rejection, as `for…of` closes it on `break` or `throw`.
|
|
45
|
+
*/
|
|
46
|
+
function chainInOrder(items, fn, keepGoing) {
|
|
47
|
+
return new Promise((resolveRun) => {
|
|
48
|
+
const iterator = items[Symbol.iterator]();
|
|
49
|
+
let index = 0;
|
|
50
|
+
const step = () => {
|
|
51
|
+
const next = iterator.next();
|
|
52
|
+
if (next.done === true)
|
|
53
|
+
return Promise.resolve(true);
|
|
54
|
+
return settle(fn, next.value, index++).then((result) => {
|
|
55
|
+
const more = keepGoing(result);
|
|
56
|
+
if (!more)
|
|
57
|
+
iterator.return?.();
|
|
58
|
+
return more ? step() : false;
|
|
59
|
+
}, (error) => {
|
|
60
|
+
iterator.return?.();
|
|
61
|
+
throw error;
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
resolveRun(step());
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Run `fn` over `items` one at a time, each call starting only after the previous
|
|
69
|
+
* one settles.
|
|
70
|
+
*
|
|
71
|
+
* Reach for it when order is the CONTRACT, not an accident: ordered filesystem
|
|
72
|
+
* mutation (mkdir before recursing, a later entry deliberately overwriting an
|
|
73
|
+
* earlier one), first-refusal-wins (the error a user sees must name the FIRST bad
|
|
74
|
+
* item, deterministically — `Promise.all` rejects with the first in time), a
|
|
75
|
+
* shared memo/sink/walk-guard whose first use must not race, a report whose line
|
|
76
|
+
* order is its meaning, or a measurement that must not overlap itself.
|
|
77
|
+
*
|
|
78
|
+
* A rejection stops the run there: later items are never started, exactly as
|
|
79
|
+
* with `await` in `for…of`. Items are pulled lazily from the iterator, so an
|
|
80
|
+
* array that grows during the run is seen. If the items are independent, use
|
|
81
|
+
* `Promise.all` or {@link mapWithConcurrency} instead.
|
|
82
|
+
*/
|
|
83
|
+
export function forEachInOrder(items, fn) {
|
|
84
|
+
return chainInOrder(items, fn, () => true).then(() => undefined);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* {@link forEachInOrder} that collects each call's result, in input order.
|
|
88
|
+
*
|
|
89
|
+
* For a sequential transform whose steps depend on shared state — a resolver that
|
|
90
|
+
* stages into one root, a cache whose first user must not race — where the caller
|
|
91
|
+
* also needs every result. Stops at the first rejection, like `forEachInOrder`.
|
|
92
|
+
*/
|
|
93
|
+
export function mapInOrder(items, fn) {
|
|
94
|
+
const results = [];
|
|
95
|
+
return chainInOrder(items, fn, (result) => {
|
|
96
|
+
results.push(result);
|
|
97
|
+
return true;
|
|
98
|
+
}).then(() => results);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* `Array#every`, in order and awaited: resolves `false` at the first callback that
|
|
102
|
+
* answers `false`, without starting any later item; resolves `true` when every item
|
|
103
|
+
* answered `true` (vacuously so for no items).
|
|
104
|
+
*
|
|
105
|
+
* The idiom for a loop that used to `break` or `return` early: stop at the first
|
|
106
|
+
* failure and leave the rest untouched — capture whatever the early exit carried in
|
|
107
|
+
* a closure. A rejection stops the run too, and rejects.
|
|
108
|
+
*/
|
|
109
|
+
export function everyInOrder(items, fn) {
|
|
110
|
+
return chainInOrder(items, fn, (result) => result);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* `Promise.all`-shaped, but with at most `limit` calls in flight. Results are in
|
|
114
|
+
* input order whatever order the calls finish in.
|
|
115
|
+
*
|
|
116
|
+
* For INDEPENDENT work over a population-sized list — the files in a skill, the
|
|
117
|
+
* skill directories of a plugin — where a bare `Promise.all` would open one file
|
|
118
|
+
* descriptor per item at once. Results are returned rather than pushed into a
|
|
119
|
+
* shared sink from inside the callbacks: concurrent pushes land in finish order,
|
|
120
|
+
* not input order, so fold the returned array afterwards.
|
|
121
|
+
*
|
|
122
|
+
* Rejects with the first rejection in TIME, and stops starting new items once one
|
|
123
|
+
* has rejected (calls already in flight run to completion). When the error a user
|
|
124
|
+
* sees must name the first bad item in input order, this is the wrong tool — use
|
|
125
|
+
* {@link forEachInOrder}.
|
|
126
|
+
*
|
|
127
|
+
* @throws RangeError when `limit` is not a whole number of at least 1 — a `NaN`
|
|
128
|
+
* or `0` limit would otherwise start no workers and silently resolve holes.
|
|
129
|
+
*/
|
|
130
|
+
export function mapWithConcurrency(items, fn, limit = FS_CONCURRENCY) {
|
|
131
|
+
if (!Number.isInteger(limit) || limit < 1) {
|
|
132
|
+
return Promise.reject(new RangeError(`mapWithConcurrency limit must be a whole number of at least 1, got ${String(limit)}`));
|
|
133
|
+
}
|
|
134
|
+
const results = Array.from({ length: items.length });
|
|
135
|
+
let next = 0;
|
|
136
|
+
let failed = false;
|
|
137
|
+
const worker = () => {
|
|
138
|
+
if (failed || next >= items.length)
|
|
139
|
+
return Promise.resolve();
|
|
140
|
+
const index = next++;
|
|
141
|
+
return settle(fn, items[index], index).then((result) => {
|
|
142
|
+
results[index] = result;
|
|
143
|
+
return worker();
|
|
144
|
+
}, (error) => {
|
|
145
|
+
failed = true;
|
|
146
|
+
throw error;
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
const workers = Array.from({ length: Math.min(limit, items.length) }, () => worker());
|
|
150
|
+
return Promise.all(workers).then(() => results);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* {@link mapWithConcurrency} for independent read-only work whose failure must
|
|
154
|
+
* still be the one a sequential loop would have raised: every call settles, then
|
|
155
|
+
* the rejection of the EARLIEST item by position is rethrown. Results are in
|
|
156
|
+
* input order.
|
|
157
|
+
*/
|
|
158
|
+
export function mapConcurrentFailingInOrder(items, fn) {
|
|
159
|
+
return mapWithConcurrency(items, (item, index) => settle(fn, item, index).then((value) => ({ ok: true, value }), (error) => ({ ok: false, error }))).then((outcomes) => outcomes.map((outcome) => {
|
|
160
|
+
if (!outcome.ok)
|
|
161
|
+
throw outcome.error;
|
|
162
|
+
return outcome.value;
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=in-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-order.js","sourceRoot":"","sources":["../src/in-order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAEjC;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAI,IAAa;IACvC,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,0EAA0E;QAC1E,OAAO,OAAO,CAAC,MAAM,CAAC,KAAc,CAAC,CAAC;IACxC,CAAC;AACH,CAAC;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,CAAC,OAAO,CAAC,EAAE;YAAE,MAAM,OAAO,CAAC,KAAK,CAAC;QACrC,OAAO,OAAO,CAAC,KAAK,CAAC;IACvB,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -23,24 +23,40 @@
|
|
|
23
23
|
* and has to be an argued edit rather than an unnoticed one.
|
|
24
24
|
*/
|
|
25
25
|
export * from './errors/vat-error.js';
|
|
26
|
+
export { RAG_DATABASE_UNREADABLE_CODE, RAG_INDEX_EMPTY_CODE } from './errors/rag-index-empty.js';
|
|
27
|
+
export { ARCHIVE_ENTRY_UNREADABLE_CODE, ARCHIVE_REFUSED_CODE, isArchiveEntryReadRefusal, placeOf as archiveEntryPlace } from './archive/entries.js';
|
|
26
28
|
export * from './path-utils.js';
|
|
27
29
|
export * from './path-containment.js';
|
|
28
30
|
export * from './dirent-kind.js';
|
|
29
31
|
export * from './text-content.js';
|
|
30
32
|
export * from './text-file.js';
|
|
31
33
|
export * from './asset-reference.js';
|
|
32
|
-
export {
|
|
33
|
-
export {
|
|
34
|
-
export {
|
|
35
|
-
export type {
|
|
34
|
+
export { FS_FAULT_ERRNOS_BY_CLASS, fsFaultOf, isAlreadyExistsError, isFileInTheWayError, isFinalPathUnanswerableError, isInvalidArgumentError, isNoSuchEntryError, isNotARegularFileError, isPathAbsentError, isProcessGoneError, isRenameContentionError, isSymlinkUnsupportedError, isTimedOutError, isUnresolvableLinkError, isWouldBlockError, LINK_CHAIN_REFUSED_CODE, } from './errors/errno-table.js';
|
|
35
|
+
export type { FsFaultClass, FsFaultFacts } from './errors/errno-table.js';
|
|
36
|
+
export { assertUnresolvableLink, classifyFsFault, everywhere, FS_FAULT_CODE, FS_SIDES, FsFaultError, isCapacityFault, isFsFaultError, isLayoutFault, linkResolutionFault, refusedPathOf, sideWithin, SOURCE_ORIGINS, withFsFault, withFsFaultSync, } from './errors/fs-fault.js';
|
|
37
|
+
export type { FsFaultContext, FsSide, SideOfPath, SourceOrigin } from './errors/fs-fault.js';
|
|
38
|
+
export { fsBoundary } from './errors/fs-boundary.js';
|
|
39
|
+
export { requireConfirmedAbsent, type ConfirmationContext, type ConfirmationProbe } from './errors/confirmed-absent.js';
|
|
40
|
+
export { pathPresent, type PresenceMode } from './errors/path-present.js';
|
|
41
|
+
export { assertLocalChain, type FollowedPathKind, followedKind, followedKindSync, followedRealpath, followedRealpathSync, followedStat, followedStatSync, realpathNative, realpathNativeSync, requireFollowedStat, requireFollowedStatSync, } from './link-following.js';
|
|
42
|
+
export { foldedSegment } from './name-fold.js';
|
|
43
|
+
export { recordSuppressedFault, suppressedFaultsOf } from './errors/suppressed-faults.js';
|
|
44
|
+
export type { FsBoundary, FsRoots } from './errors/fs-boundary.js';
|
|
45
|
+
export { FsLookupCache, transientRefusalClause } from './fs-utils.js';
|
|
46
|
+
export { DirectorySpellingIndex, fillPathSpellings, fillRealpaths, pathSpellingFrom, realpathRowFrom, spellingWalkRoot, } from './fs-utils.js';
|
|
47
|
+
export type { AbsenceCause, ComponentMatch, FilenameMatch, PathProbe, PathProbeStats, PathSpelling, PathSpellingRequest, PathSpellingTable, RealpathFault, RealpathRow, RealpathTable, VerifiedPrefix, } from './fs-utils.js';
|
|
36
48
|
export * from './project-utils.js';
|
|
37
49
|
export { createSymlink, createSymlinkAsync, detachGitEnv, errnoError, INHERITED_GIT_ENV, symlinkCapability, type SymlinkCapability, } from './test-helpers.js';
|
|
38
50
|
export * from './zod-introspection.js';
|
|
39
51
|
export * from './skill-targets.js';
|
|
52
|
+
export { requireTestScratch, TEST_USER_STATE_UNDER } from './test-scratch-guard.js';
|
|
40
53
|
export * from './glob/glob-pattern.js';
|
|
41
54
|
export * from './fs/file-hash.js';
|
|
55
|
+
export { applyTreePlan, applyTreePlanOrLeftover, COPY_LINK_ESCAPES_SOURCE_CODE, copyRegularFile, copyTree, CopyLinkEscapesSourceError, DIRECTORY_WALK_REVISITED_CODE, DirectoryWalkRevisitedError, disposeTempDir, disposeTempDirAfterFailure, disposeTempDirSync, entryIdentities, FollowedWalk, isLinkChainRefusedError, HOST_PATH_FLAVOR, isInsideByIdentity, isParkedTreeEntry, isTreeChangeResidue, planTreeChanges, proveTreeReadable, readRegularFile, makeDirectoryUnder, refuseEscapingLinks, renameFileAtomic, replaceFile, writeFileUnder, sameEntry, TEMP_DIR_OUTSIDE_TMPDIR_CODE, TREE_CLEANUP_INCOMPLETE_CODE, TREE_DEST_HOLDS_SOURCE_CODE, TREE_DEST_NOT_OWNED_CODE, TREE_DEST_OCCUPIED_CODE, TREE_DESTS_OVERLAP_CODE, TREE_ROLLBACK_INCOMPLETE_CODE, TREE_SOURCE_HOLDS_DEST_CODE, treeChain, treeContainment, TreeRollbackIncompleteError, untrustedTextRefusal, untrustedLinkRefusal, isWithinUnder, win32FoldedName, withTempDir, } from './tree-change/index.js';
|
|
56
|
+
export type { ApplyOptions, ApplyOutcome, ApplyResult, CopyOnto, CopyRegularFileOptions, CopyTreeOptions, EntryContainment, EntryKind, EntrySameness, FileContents, Identity, LinkContainmentCheck, LinkPolicy, Ownership, OwnershipVerdict, PlannedAction, PlannedChange, ProveTreeReadableOptions, TempDirOutcome, TreeChange, TreeChangeWarning, TreeFill, TreePlan, TreeRollbackStranded, TreeWalkOptions, } from './tree-change/index.js';
|
|
42
57
|
export { parseWholeNumberAtLeast } from './numeric-args.js';
|
|
43
58
|
export { parseEnvBoolean } from './env-flag.js';
|
|
59
|
+
export { everyInOrder, forEachInOrder, FS_CONCURRENCY, mapConcurrentFailingInOrder, mapInOrder, mapWithConcurrency, promised, } from './in-order.js';
|
|
44
60
|
export { compareCodeUnits } from './compare-code-units.js';
|
|
45
61
|
export { CRAWL_BLOB_POPULATE_ID, CRAWL_CLOSURE_CONTRIBUTE_ID, CRAWL_CLOSURE_RESOLVE_ID, CRAWL_PASS_INSIDE, CRAWL_REGISTRY_ADMIT_ID, CRAWL_REGISTRY_ENUMERATE_ID, CRAWL_REGISTRY_ID_PREFIX, CRAWL_REGISTRY_RESOLVE_LINKS_ID, CRAWL_SHARED_GIT_TRACKER_ID, CRAWL_STORE_READ_ID, CRAWL_STORE_WRITE_ID, CRAWL_STRATA, CRAWL_WALKER_GITIGNORE_ID, CRAWL_WALKER_ID, crawlTimingStart, recordContributorInvocation, recordCrawlPass, recordRegistryPass, recordSharedPass, withContributorStratum, withOuterBracket, type CrawlDriverStratum, type CrawlStratum, type CrawlTimingDump, type CrawlTimingEntry, type CrawlTimingProcess, } from './crawl-timing.js';
|
|
46
62
|
export { ensureTimingDirectory, normalizeTimingDirectory, readTimingProcess, type TimingProcess, writeTimingDump, } from './timing-dump.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;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,cAAc,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAGjG,OAAO,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAIpJ,cAAc,iBAAiB,CAAC;AAEhC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,kBAAkB,CAAC;AASjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,sBAAsB,CAAC;AAyCrC,OAAO,EACL,wBAAwB,EACxB,SAAS,EACT,oBAAoB,EACpB,mBAAmB,EACnB,4BAA4B,EAC5B,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,yB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B,EAChB,SAAS,EACT,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,oBAAoB,EACpB,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,wBAAwB,EACxB,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,oBAAoB,EACpB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAK5D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAMhD,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,2BAA2B,EAC3B,UAAU,EACV,kBAAkB,EAClB,QAAQ,GACT,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAgB3D,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAC3B,wBAAwB,EACxB,iBAAiB,EACjB,uBAAuB,EACvB,2BAA2B,EAC3B,wBAAwB,EACxB,+BAA+B,EAC/B,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,yBAAyB,EACzB,eAAe,EACf,gBAAgB,EAChB,2BAA2B,EAC3B,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,GACxB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,EACjB,KAAK,aAAa,EAClB,eAAe,GAChB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,11 @@
|
|
|
25
25
|
// The base of every error VAT throws on purpose; `code` is what a catch
|
|
26
26
|
// block dispatches on, never `message`.
|
|
27
27
|
export * from './errors/vat-error.js';
|
|
28
|
+
export { RAG_DATABASE_UNREADABLE_CODE, RAG_INDEX_EMPTY_CODE } from './errors/rag-index-empty.js';
|
|
29
|
+
// The code and the one-entry predicate alone: the archive readers are on `./archive` (they load
|
|
30
|
+
// `tar` and `adm-zip`), and a refusal map, or a lane that skips one member, needs only these.
|
|
31
|
+
export { ARCHIVE_ENTRY_UNREADABLE_CODE, ARCHIVE_REFUSED_CODE, isArchiveEntryReadRefusal, placeOf as archiveEntryPlace } from './archive/entries.js';
|
|
32
|
+
// The code alone: its error class is on `./crawl`, and the CLI's refusal map needs only the code.
|
|
28
33
|
// Cross-platform path utilities
|
|
29
34
|
export * from './path-utils.js';
|
|
30
35
|
// The filesystem-backed containment verdict every delete/copy/uninstall sink asks.
|
|
@@ -61,7 +66,7 @@ export * from './asset-reference.js';
|
|
|
61
66
|
// published too, for the lazy caller that cannot enumerate its targets up
|
|
62
67
|
// front.
|
|
63
68
|
// - realpaths — `fillRealpaths` (every canonicalization, once, up front) plus
|
|
64
|
-
// `
|
|
69
|
+
// `realpathRowFrom`.
|
|
65
70
|
//
|
|
66
71
|
// In both, the row lookup IS the judge: the row is the answer, so there is
|
|
67
72
|
// nothing left to keep internal.
|
|
@@ -81,11 +86,21 @@ export * from './asset-reference.js';
|
|
|
81
86
|
// symptom is a type that cannot be imported, which surfaces the first time
|
|
82
87
|
// someone tries — not a silent break in existing code.
|
|
83
88
|
// The lookups themselves, plus the memo every fill shares.
|
|
84
|
-
export {
|
|
85
|
-
export {
|
|
89
|
+
export { FS_FAULT_ERRNOS_BY_CLASS, fsFaultOf, isAlreadyExistsError, isFileInTheWayError, isFinalPathUnanswerableError, isInvalidArgumentError, isNoSuchEntryError, isNotARegularFileError, isPathAbsentError, isProcessGoneError, isRenameContentionError, isSymlinkUnsupportedError, isTimedOutError, isUnresolvableLinkError, isWouldBlockError, LINK_CHAIN_REFUSED_CODE, } from './errors/errno-table.js';
|
|
90
|
+
export { assertUnresolvableLink, classifyFsFault, everywhere, FS_FAULT_CODE, FS_SIDES, FsFaultError, isCapacityFault, isFsFaultError, isLayoutFault, linkResolutionFault, refusedPathOf, sideWithin, SOURCE_ORIGINS, withFsFault, withFsFaultSync, } from './errors/fs-fault.js';
|
|
91
|
+
export { fsBoundary } from './errors/fs-boundary.js';
|
|
92
|
+
export { requireConfirmedAbsent } from './errors/confirmed-absent.js';
|
|
93
|
+
export { pathPresent } from './errors/path-present.js';
|
|
94
|
+
// The one module that asks the kernel to follow a link, each call once the chain beneath `within` is read.
|
|
95
|
+
export { assertLocalChain, followedKind, followedKindSync, followedRealpath, followedRealpathSync, followedStat, followedStatSync, realpathNative, realpathNativeSync, requireFollowedStat, requireFollowedStatSync, } from './link-following.js';
|
|
96
|
+
// The one fold for "are these two names one entry on some volume".
|
|
97
|
+
export { foldedSegment } from './name-fold.js';
|
|
98
|
+
// Faults raised while a failure was being handled, recorded beside it (never on its cause chain).
|
|
99
|
+
export { recordSuppressedFault, suppressedFaultsOf } from './errors/suppressed-faults.js';
|
|
100
|
+
export { FsLookupCache, transientRefusalClause } from './fs-utils.js';
|
|
86
101
|
// The two fill+judge pairs, in the order the note above lists them, plus the
|
|
87
102
|
// lazy index a caller that cannot enumerate its targets up front reaches for.
|
|
88
|
-
export { DirectorySpellingIndex, fillPathSpellings, fillRealpaths, pathSpellingFrom,
|
|
103
|
+
export { DirectorySpellingIndex, fillPathSpellings, fillRealpaths, pathSpellingFrom, realpathRowFrom, spellingWalkRoot, } from './fs-utils.js';
|
|
89
104
|
// Project root discovery (canonical: config → git → null).
|
|
90
105
|
// CLI-boundary use only — see docs/concepts/roots-and-config.md.
|
|
91
106
|
export * from './project-utils.js';
|
|
@@ -101,15 +116,26 @@ export { createSymlink, createSymlinkAsync, detachGitEnv, errnoError, INHERITED_
|
|
|
101
116
|
export * from './zod-introspection.js';
|
|
102
117
|
// Skill target resolution (cross-platform flat skill install paths)
|
|
103
118
|
export * from './skill-targets.js';
|
|
119
|
+
// The fail-closed guard for user state in a test process
|
|
120
|
+
export { requireTestScratch, TEST_USER_STATE_UNDER } from './test-scratch-guard.js';
|
|
104
121
|
// Glob pattern helpers (isGlob, staticGlobBase, globMagicRemainder)
|
|
105
122
|
export * from './glob/glob-pattern.js';
|
|
106
123
|
// Filesystem hashing (sha256 of raw file bytes)
|
|
107
124
|
export * from './fs/file-hash.js';
|
|
125
|
+
// Tree-change primitive: entry identity (`sameEntry`) for the planner and uninstall; the
|
|
126
|
+
// readable-tree proof and the copy, with the two refusals a following walk raises.
|
|
127
|
+
// The planner and applier every destructive verb goes through, and the file helpers beside them.
|
|
128
|
+
export { applyTreePlan, applyTreePlanOrLeftover, COPY_LINK_ESCAPES_SOURCE_CODE, copyRegularFile, copyTree, CopyLinkEscapesSourceError, DIRECTORY_WALK_REVISITED_CODE, DirectoryWalkRevisitedError, disposeTempDir, disposeTempDirAfterFailure, disposeTempDirSync, entryIdentities, FollowedWalk, isLinkChainRefusedError, HOST_PATH_FLAVOR, isInsideByIdentity, isParkedTreeEntry, isTreeChangeResidue, planTreeChanges, proveTreeReadable, readRegularFile, makeDirectoryUnder, refuseEscapingLinks, renameFileAtomic, replaceFile, writeFileUnder, sameEntry, TEMP_DIR_OUTSIDE_TMPDIR_CODE, TREE_CLEANUP_INCOMPLETE_CODE, TREE_DEST_HOLDS_SOURCE_CODE, TREE_DEST_NOT_OWNED_CODE, TREE_DEST_OCCUPIED_CODE, TREE_DESTS_OVERLAP_CODE, TREE_ROLLBACK_INCOMPLETE_CODE, TREE_SOURCE_HOLDS_DEST_CODE, treeChain, treeContainment, TreeRollbackIncompleteError, untrustedTextRefusal, untrustedLinkRefusal, isWithinUnder, win32FoldedName, withTempDir, } from './tree-change/index.js';
|
|
108
129
|
export { parseWholeNumberAtLeast } from './numeric-args.js';
|
|
109
130
|
// THE reading of an environment variable as a boolean. One implementation
|
|
110
131
|
// because three switches each had their own `!== '0'` comparison and none of
|
|
111
132
|
// them turned off for `=false`.
|
|
112
133
|
export { parseEnvBoolean } from './env-flag.js';
|
|
134
|
+
// Ordered (`forEachInOrder`, `mapInOrder`, `everyInOrder`) and bounded-parallel
|
|
135
|
+
// (`mapWithConcurrency`, `mapConcurrentFailingInOrder`) async iteration — what
|
|
136
|
+
// replaces `await` in a loop, which `no-await-in-loop` refuses repo-wide — and
|
|
137
|
+
// `promised`, a synchronous body behind a Promise-shaped API.
|
|
138
|
+
export { everyInOrder, forEachInOrder, FS_CONCURRENCY, mapConcurrentFailingInOrder, mapInOrder, mapWithConcurrency, promised, } from './in-order.js';
|
|
113
139
|
// Machine-independent string ordering for hashed/serialized output — never `localeCompare`.
|
|
114
140
|
export { compareCodeUnits } from './compare-code-units.js';
|
|
115
141
|
// The crawl-timing seam: which contributor, stratum and fixpoint pass owns the
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,wEAAwE;AACxE,wCAAwC;AACxC,cAAc,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,wEAAwE;AACxE,wCAAwC;AACxC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACjG,gGAAgG;AAChG,8FAA8F;AAC9F,OAAO,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACpJ,kGAAkG;AAElG,gCAAgC;AAChC,cAAc,iBAAiB,CAAC;AAChC,mFAAmF;AACnF,cAAc,uBAAuB,CAAC;AACtC,+EAA+E;AAC/E,cAAc,kBAAkB,CAAC;AAEjC,iFAAiF;AACjF,2EAA2E;AAC3E,iFAAiF;AACjF,gEAAgE;AAChE,6EAA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sBAAsB,EACtB,2BAA2B,EAC3B,wBAAwB,EACxB,iBAAiB,EACjB,uBAAuB,EACvB,2BAA2B,EAC3B,wBAAwB,EACxB,+BAA+B,EAC/B,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,yBAAyB,EACzB,eAAe,EACf,gBAAgB,EAChB,2BAA2B,EAC3B,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,GAMjB,MAAM,mBAAmB,CAAC;AAC3B,gFAAgF;AAEhF,iEAAiE;AACjE,8EAA8E;AAC9E,0CAA0C;AAC1C,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,EAEjB,eAAe,GAChB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** A spawned child, as {@link killProcessTree} needs it. */
|
|
2
|
+
export interface KillableChild {
|
|
3
|
+
readonly pid?: number | undefined;
|
|
4
|
+
kill(signal: NodeJS.Signals): boolean;
|
|
5
|
+
}
|
|
6
|
+
/** How {@link killProcessTree} reaches the child's descendants, and whether it also goes through the child. */
|
|
7
|
+
export interface KillProcessTreeOptions {
|
|
8
|
+
/**
|
|
9
|
+
* POSIX: the child was spawned `detached`, so it leads a process group and the kill takes the
|
|
10
|
+
* whole GROUP (the negated pid) — its grandchildren included. False: the child's pid alone (a
|
|
11
|
+
* child that is not a leader has no group of its own to kill). Ignored on Windows, where
|
|
12
|
+
* `taskkill /T` walks the tree from the child.
|
|
13
|
+
*/
|
|
14
|
+
readonly groupLeader: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Also SIGKILL through `child.kill`, the call whose refusal Node reports as the child's `error`
|
|
17
|
+
* event — for a caller that watches that event to retry or report a kill that did not land.
|
|
18
|
+
*/
|
|
19
|
+
readonly throughChild: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* SIGKILL a child and every process it started — the ONE way VAT kills a process tree.
|
|
23
|
+
*
|
|
24
|
+
* - **POSIX**: the child's process group when it leads one (`groupLeader`), else its pid.
|
|
25
|
+
* - **Windows**: `taskkill /T /F`, which terminates the child and its whole tree. Windows has no
|
|
26
|
+
* process groups, and `child.kill` there is `TerminateProcess` of the child alone.
|
|
27
|
+
* - A child with no pid (never spawned) has nothing to kill. A kill whose target is already gone
|
|
28
|
+
* ({@link isProcessGoneError}) is absorbed; anything else the kill throws stays loud — a reaper
|
|
29
|
+
* that says nothing about a tree it did not reap leaves processes running unseen.
|
|
30
|
+
* - **`throughChild` goes FIRST.** On Windows only the child's own kill records the signal: libuv's
|
|
31
|
+
* `uv_process_kill` sets the handle's `exit_signal` when ITS `TerminateProcess` lands, so `exit`
|
|
32
|
+
* reports `(null, 'SIGKILL')`. A `taskkill` first leaves `child.kill` nothing to kill (ESRCH, no
|
|
33
|
+
* signal recorded) and `exit` reads `(1, null)` — the supervisor's kill reported as the child
|
|
34
|
+
* exiting 1 on its own. The `taskkill /T` sweep after it is best-effort: `TerminateProcess` is
|
|
35
|
+
* asynchronous and Node still holds the child's handle (so its pid is not recycled), but whether
|
|
36
|
+
* taskkill can still walk the tree from a root already terminating is not established — a
|
|
37
|
+
* grandchild may run on, as it does on POSIX for a child that does not lead a group.
|
|
38
|
+
*
|
|
39
|
+
* @param child - The spawned child
|
|
40
|
+
* @param options - See {@link KillProcessTreeOptions}
|
|
41
|
+
*/
|
|
42
|
+
export declare function killProcessTree(child: KillableChild, options: KillProcessTreeOptions): void;
|
|
43
|
+
//# sourceMappingURL=kill-process-tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kill-process-tree.d.ts","sourceRoot":"","sources":["../src/kill-process-tree.ts"],"names":[],"mappings":"AAIA,4DAA4D;AAC5D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;CACvC;AAED,+GAA+G;AAC/G,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,sBAAsB,GAAG,IAAI,CAW3F"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { isProcessGoneError } from './errors/errno-table.js';
|
|
3
|
+
/**
|
|
4
|
+
* SIGKILL a child and every process it started — the ONE way VAT kills a process tree.
|
|
5
|
+
*
|
|
6
|
+
* - **POSIX**: the child's process group when it leads one (`groupLeader`), else its pid.
|
|
7
|
+
* - **Windows**: `taskkill /T /F`, which terminates the child and its whole tree. Windows has no
|
|
8
|
+
* process groups, and `child.kill` there is `TerminateProcess` of the child alone.
|
|
9
|
+
* - A child with no pid (never spawned) has nothing to kill. A kill whose target is already gone
|
|
10
|
+
* ({@link isProcessGoneError}) is absorbed; anything else the kill throws stays loud — a reaper
|
|
11
|
+
* that says nothing about a tree it did not reap leaves processes running unseen.
|
|
12
|
+
* - **`throughChild` goes FIRST.** On Windows only the child's own kill records the signal: libuv's
|
|
13
|
+
* `uv_process_kill` sets the handle's `exit_signal` when ITS `TerminateProcess` lands, so `exit`
|
|
14
|
+
* reports `(null, 'SIGKILL')`. A `taskkill` first leaves `child.kill` nothing to kill (ESRCH, no
|
|
15
|
+
* signal recorded) and `exit` reads `(1, null)` — the supervisor's kill reported as the child
|
|
16
|
+
* exiting 1 on its own. The `taskkill /T` sweep after it is best-effort: `TerminateProcess` is
|
|
17
|
+
* asynchronous and Node still holds the child's handle (so its pid is not recycled), but whether
|
|
18
|
+
* taskkill can still walk the tree from a root already terminating is not established — a
|
|
19
|
+
* grandchild may run on, as it does on POSIX for a child that does not lead a group.
|
|
20
|
+
*
|
|
21
|
+
* @param child - The spawned child
|
|
22
|
+
* @param options - See {@link KillProcessTreeOptions}
|
|
23
|
+
*/
|
|
24
|
+
export function killProcessTree(child, options) {
|
|
25
|
+
if (options.throughChild)
|
|
26
|
+
child.kill('SIGKILL');
|
|
27
|
+
const { pid } = child;
|
|
28
|
+
if (pid !== undefined) {
|
|
29
|
+
if (process.platform === 'win32') {
|
|
30
|
+
// eslint-disable-next-line sonarjs/no-os-command-from-path -- taskkill is a fixed Windows system command (no PATH-injection surface); it is the only way to terminate a Windows process tree.
|
|
31
|
+
spawnSync('taskkill', ['/pid', String(pid), '/T', '/F'], { stdio: 'ignore', windowsHide: true });
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
killAbsorbingGone(options.groupLeader ? -pid : pid);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** SIGKILL `target` (a pid, or a negated group id); a target already gone has nothing left to kill. */
|
|
39
|
+
function killAbsorbingGone(target) {
|
|
40
|
+
try {
|
|
41
|
+
process.kill(target, 'SIGKILL');
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
if (!isProcessGoneError(error))
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=kill-process-tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kill-process-tree.js","sourceRoot":"","sources":["../src/kill-process-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAwB7D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,eAAe,CAAC,KAAoB,EAAE,OAA+B;IACnF,IAAI,OAAO,CAAC,YAAY;QAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAChD,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;IACtB,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;YACjC,8LAA8L;YAC9L,SAAS,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QACnG,CAAC;aAAM,CAAC;YACN,iBAAiB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;AACH,CAAC;AAED,uGAAuG;AACvG,SAAS,iBAAiB,CAAC,MAAc;IACvC,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;IAC9C,CAAC;AACH,CAAC"}
|