@socketsecurity/lib 6.0.8 → 6.0.9
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/CHANGELOG.md +22 -0
- package/dist/ai/route.d.mts +21 -8
- package/dist/ai/route.js +21 -6
- package/dist/ai/spawn.d.mts +32 -0
- package/dist/ai/spawn.js +91 -2
- package/dist/ai/types.d.mts +10 -0
- package/dist/bin/prim.cjs +18797 -13627
- package/dist/bin/resolve.js +1 -1
- package/dist/cache/ttl/store.js +1 -1
- package/dist/compression/brotli.js +1 -1
- package/dist/compression/gzip.js +1 -1
- package/dist/config/layers.d.ts +53 -0
- package/dist/config/layers.js +83 -0
- package/dist/constants/socket.js +1 -1
- package/dist/debug/caller-info.js +1 -1
- package/dist/dlx/binary-cache.js +1 -1
- package/dist/dlx/binary-resolution.js +1 -1
- package/dist/dlx/firewall.js +1 -1
- package/dist/dlx/lockfile.js +1 -1
- package/dist/eco/npm/npm/parse-lockfile.js +1 -1
- package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.js +1 -1
- package/dist/env/rewire.d.ts +5 -3
- package/dist/env/rewire.js +6 -7
- package/dist/env/xdg.d.ts +17 -0
- package/dist/env/xdg.js +21 -1
- package/dist/errors/stack.js +1 -2
- package/dist/external/@npmcli/package-json.js +3455 -4881
- package/dist/external/@yarnpkg/extensions.js +1 -1
- package/dist/external/external-pack.js +1 -1
- package/dist/external/npm-pack.js +29164 -31799
- package/dist/external/tar-fs.js +63 -16
- package/dist/external-tools/jre/detect-platform-arch.js +1 -1
- package/dist/external-tools/manifest.js +1 -1
- package/dist/external-tools/python/asset-names.js +1 -1
- package/dist/external-tools/python/uv-install.d.ts +89 -0
- package/dist/external-tools/python/uv-install.js +165 -0
- package/dist/external-tools/skillspector/from-uv.d.ts +30 -0
- package/dist/external-tools/skillspector/from-uv.js +56 -0
- package/dist/external-tools/skillspector/resolve.d.ts +18 -3
- package/dist/external-tools/skillspector/resolve.js +21 -8
- package/dist/external-tools/skillspector/types.d.ts +3 -1
- package/dist/external-tools/uv/asset-names.d.ts +36 -0
- package/dist/external-tools/uv/asset-names.js +73 -0
- package/dist/external-tools/uv/from-download.d.ts +17 -0
- package/dist/external-tools/uv/from-download.js +50 -0
- package/dist/external-tools/uv/from-path.d.ts +5 -0
- package/dist/external-tools/uv/from-path.js +22 -0
- package/dist/external-tools/uv/from-vfs.d.ts +7 -0
- package/dist/external-tools/uv/from-vfs.js +26 -0
- package/dist/external-tools/uv/resolve.d.ts +25 -0
- package/dist/external-tools/uv/resolve.js +61 -0
- package/dist/external-tools/uv/types.d.ts +24 -0
- package/dist/external-tools/uv/types.js +2 -0
- package/dist/fleet/repo-config.d.ts +53 -0
- package/dist/fleet/repo-config.js +79 -0
- package/dist/fs/allowed-dirs-cache.js +3 -5
- package/dist/fs/copy.d.ts +88 -0
- package/dist/fs/copy.js +89 -0
- package/dist/fs/safe.js +1 -1
- package/dist/git/_internal.js +2 -2
- package/dist/github/refs.js +10 -15
- package/dist/globs/_internal.js +1 -1
- package/dist/http-request/browser.js +1 -1
- package/dist/http-request/checksum-file.js +1 -1
- package/dist/http-request/headers.js +1 -1
- package/dist/integrity.d.ts +125 -78
- package/dist/integrity.js +168 -84
- package/dist/logger/colors.d.ts +1 -2
- package/dist/logger/colors.js +2 -2
- package/dist/logger/symbols-builder.js +7 -8
- package/dist/logger/symbols.js +8 -8
- package/dist/node/module.d.ts +73 -2
- package/dist/node/module.js +97 -12
- package/dist/objects/predicates.js +1 -1
- package/dist/packages/exports.js +2 -2
- package/dist/packages/isolation.js +1 -1
- package/dist/packages/manifest.d.ts +29 -0
- package/dist/packages/manifest.js +38 -2
- package/dist/packages/normalize.js +1 -1
- package/dist/packages/provenance.js +2 -2
- package/dist/packages/specs.js +1 -1
- package/dist/paths/_internal.d.ts +1 -7
- package/dist/paths/_internal.js +9 -15
- package/dist/paths/conversion.js +1 -1
- package/dist/paths/normalize.js +1 -1
- package/dist/paths/predicates.js +2 -1
- package/dist/paths/socket.d.ts +74 -23
- package/dist/paths/socket.js +97 -23
- package/dist/perf/metrics.js +1 -1
- package/dist/perf/report.js +1 -1
- package/dist/regexps/spec.js +1 -1
- package/dist/schema/validate.js +1 -1
- package/dist/secrets/broker.d.ts +35 -0
- package/dist/secrets/broker.js +72 -0
- package/dist/secrets/find.d.ts +6 -4
- package/dist/secrets/find.js +15 -1
- package/dist/secrets/rc.js +1 -1
- package/dist/smol/detect.js +1 -1
- package/dist/smol/http.js +1 -1
- package/dist/smol/https.js +1 -1
- package/dist/smol/manifest.js +1 -1
- package/dist/smol/path.js +1 -1
- package/dist/smol/primordial.js +1 -1
- package/dist/smol/purl.js +1 -1
- package/dist/smol/versions.js +1 -1
- package/dist/smol/vfs.js +1 -1
- package/dist/sorts/_internal.d.ts +1 -2
- package/dist/sorts/_internal.js +2 -6
- package/dist/sorts/semver.js +2 -2
- package/dist/spinner/create-spinner-class.js +1 -1
- package/dist/stdio/progress.js +1 -1
- package/dist/stdio/prompts.d.ts +0 -8
- package/dist/stdio/prompts.js +10 -23
- package/dist/strings/format.js +1 -1
- package/dist/strings/search.js +1 -1
- package/dist/themes/context.d.ts +5 -3
- package/dist/themes/context.js +5 -6
- package/llms.txt +750 -0
- package/package.json +79 -13
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* third-party-skill scanner (sibling to AgentShield); pinned to a git SHA
|
|
4
4
|
* because upstream has no PyPI release or GH tags as of 2026-06-01.
|
|
5
5
|
*/
|
|
6
|
-
export type SkillSpectorSource = 'vfs' | 'pipx' | 'path' | 'dlx';
|
|
6
|
+
export type SkillSpectorSource = 'vfs' | 'pipx' | 'path' | 'uv' | 'dlx';
|
|
7
7
|
/**
|
|
8
8
|
* A resolved SkillSpector installation.
|
|
9
9
|
*/
|
|
@@ -18,6 +18,8 @@ export interface ResolvedSkillSpector {
|
|
|
18
18
|
* - 'vfs' — extracted from the SEA binary's VFS
|
|
19
19
|
* - 'pipx' — `which skillspector` returned a pipx-installed venv binary
|
|
20
20
|
* - 'path' — `which skillspector` returned a non-pipx binary on PATH
|
|
21
|
+
* - 'uv' — `uv sync --locked` against a uv project's .venv (the most
|
|
22
|
+
* locked-down tier; every transitive version pinned in uv.lock)
|
|
21
23
|
* - 'dlx' — created a venv under ~/.socket/_dlx/skillspector/<sha>/
|
|
22
24
|
*/
|
|
23
25
|
readonly source: SkillSpectorSource;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Upstream uv release asset-name mapping per `platform-arch`. uv
|
|
3
|
+
* publishes per-platform archives under
|
|
4
|
+
* https://github.com/astral-sh/uv/releases/download/<X.Y.Z>/. The release tag
|
|
5
|
+
* is the bare semver (no `v` prefix), unlike most upstream projects. Each
|
|
6
|
+
* archive wraps the binary one directory deep (`uv-<triple>/uv[.exe]`), so
|
|
7
|
+
* callers should pass `strip: 1` to the extractor — or, equivalently, look up
|
|
8
|
+
* the binary inside the archive's stem directory.
|
|
9
|
+
*/
|
|
10
|
+
export interface UvAssetEntry {
|
|
11
|
+
/**
|
|
12
|
+
* Full asset filename (no version interpolation — uv asset names are
|
|
13
|
+
* version-free).
|
|
14
|
+
*/
|
|
15
|
+
readonly asset: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const UV_ASSET_MAP: Readonly<Record<string, UvAssetEntry>>;
|
|
18
|
+
export declare function getUvAssetEntry(platformArch: string): UvAssetEntry | undefined;
|
|
19
|
+
export interface UvDownloadOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Uv release version, e.g. `'0.10.11'` (no `v` prefix — astral-sh/uv tags
|
|
22
|
+
* releases as bare semver).
|
|
23
|
+
*/
|
|
24
|
+
version: string;
|
|
25
|
+
/**
|
|
26
|
+
* Fleet platform-arch token — looked up in `UV_ASSET_MAP`.
|
|
27
|
+
*/
|
|
28
|
+
platformArch: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Build the GitHub release-asset download URL for an upstream uv binary.
|
|
32
|
+
* Returns `undefined` when no entry exists for the requested platform-arch.
|
|
33
|
+
*
|
|
34
|
+
* Reference: https://github.com/astral-sh/uv/releases.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getUvDownloadUrl(options: UvDownloadOptions): string | undefined;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with rolldown */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_primordials_object = require('../../primordials/object.js');
|
|
5
|
+
|
|
6
|
+
//#region src/external-tools/uv/asset-names.ts
|
|
7
|
+
/**
|
|
8
|
+
* @file Upstream uv release asset-name mapping per `platform-arch`. uv
|
|
9
|
+
* publishes per-platform archives under
|
|
10
|
+
* https://github.com/astral-sh/uv/releases/download/<X.Y.Z>/. The release tag
|
|
11
|
+
* is the bare semver (no `v` prefix), unlike most upstream projects. Each
|
|
12
|
+
* archive wraps the binary one directory deep (`uv-<triple>/uv[.exe]`), so
|
|
13
|
+
* callers should pass `strip: 1` to the extractor — or, equivalently, look up
|
|
14
|
+
* the binary inside the archive's stem directory.
|
|
15
|
+
*/
|
|
16
|
+
const UV_ASSET_MAP = require_primordials_object.ObjectFreeze({
|
|
17
|
+
__proto__: null,
|
|
18
|
+
"darwin-arm64": require_primordials_object.ObjectFreeze({
|
|
19
|
+
__proto__: null,
|
|
20
|
+
asset: "uv-aarch64-apple-darwin.tar.gz"
|
|
21
|
+
}),
|
|
22
|
+
"darwin-x64": require_primordials_object.ObjectFreeze({
|
|
23
|
+
__proto__: null,
|
|
24
|
+
asset: "uv-x86_64-apple-darwin.tar.gz"
|
|
25
|
+
}),
|
|
26
|
+
"linux-arm64": require_primordials_object.ObjectFreeze({
|
|
27
|
+
__proto__: null,
|
|
28
|
+
asset: "uv-aarch64-unknown-linux-gnu.tar.gz"
|
|
29
|
+
}),
|
|
30
|
+
"linux-arm64-musl": require_primordials_object.ObjectFreeze({
|
|
31
|
+
__proto__: null,
|
|
32
|
+
asset: "uv-aarch64-unknown-linux-musl.tar.gz"
|
|
33
|
+
}),
|
|
34
|
+
"linux-x64": require_primordials_object.ObjectFreeze({
|
|
35
|
+
__proto__: null,
|
|
36
|
+
asset: "uv-x86_64-unknown-linux-gnu.tar.gz"
|
|
37
|
+
}),
|
|
38
|
+
"linux-x64-musl": require_primordials_object.ObjectFreeze({
|
|
39
|
+
__proto__: null,
|
|
40
|
+
asset: "uv-x86_64-unknown-linux-musl.tar.gz"
|
|
41
|
+
}),
|
|
42
|
+
"win-arm64": require_primordials_object.ObjectFreeze({
|
|
43
|
+
__proto__: null,
|
|
44
|
+
asset: "uv-aarch64-pc-windows-msvc.zip"
|
|
45
|
+
}),
|
|
46
|
+
"win-x64": require_primordials_object.ObjectFreeze({
|
|
47
|
+
__proto__: null,
|
|
48
|
+
asset: "uv-x86_64-pc-windows-msvc.zip"
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
function getUvAssetEntry(platformArch) {
|
|
52
|
+
return UV_ASSET_MAP[platformArch];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Build the GitHub release-asset download URL for an upstream uv binary.
|
|
56
|
+
* Returns `undefined` when no entry exists for the requested platform-arch.
|
|
57
|
+
*
|
|
58
|
+
* Reference: https://github.com/astral-sh/uv/releases.
|
|
59
|
+
*/
|
|
60
|
+
function getUvDownloadUrl(options) {
|
|
61
|
+
const { platformArch, version } = {
|
|
62
|
+
__proto__: null,
|
|
63
|
+
...options
|
|
64
|
+
};
|
|
65
|
+
const entry = UV_ASSET_MAP[platformArch];
|
|
66
|
+
if (!entry) return;
|
|
67
|
+
return `https://github.com/astral-sh/uv/releases/download/${version}/` + entry.asset;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
exports.UV_ASSET_MAP = UV_ASSET_MAP;
|
|
72
|
+
exports.getUvAssetEntry = getUvAssetEntry;
|
|
73
|
+
exports.getUvDownloadUrl = getUvDownloadUrl;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file `uvFromDownload()` — fetches upstream uv and returns a `ResolvedUv`
|
|
3
|
+
* pointing at the extracted binary. uv tarballs wrap the binary in a
|
|
4
|
+
* `<asset-stem>/` directory; the extractor strips that level so the binary
|
|
5
|
+
* sits at the cache-dir root.
|
|
6
|
+
*/
|
|
7
|
+
import type { BinaryDownloader } from '../from-download';
|
|
8
|
+
import type { HashSpec } from '../../integrity';
|
|
9
|
+
import type { ResolvedUv } from './types';
|
|
10
|
+
export interface UvFromDownloadOptions {
|
|
11
|
+
version: string;
|
|
12
|
+
platformArch: string;
|
|
13
|
+
integrity?: HashSpec | undefined;
|
|
14
|
+
cacheDir?: string | undefined;
|
|
15
|
+
downloader?: BinaryDownloader | undefined;
|
|
16
|
+
}
|
|
17
|
+
export declare function uvFromDownload(options: UvFromDownloadOptions): Promise<ResolvedUv | undefined>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with rolldown */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
|
|
5
|
+
const require_paths_socket = require('../../paths/socket.js');
|
|
6
|
+
const require_external_tools_from_download = require('../from-download.js');
|
|
7
|
+
const require_external_tools_uv_asset_names = require('./asset-names.js');
|
|
8
|
+
let node_process = require("node:process");
|
|
9
|
+
node_process = require_runtime.__toESM(node_process);
|
|
10
|
+
let node_path = require("node:path");
|
|
11
|
+
node_path = require_runtime.__toESM(node_path);
|
|
12
|
+
|
|
13
|
+
//#region src/external-tools/uv/from-download.ts
|
|
14
|
+
/**
|
|
15
|
+
* @file `uvFromDownload()` — fetches upstream uv and returns a `ResolvedUv`
|
|
16
|
+
* pointing at the extracted binary. uv tarballs wrap the binary in a
|
|
17
|
+
* `<asset-stem>/` directory; the extractor strips that level so the binary
|
|
18
|
+
* sits at the cache-dir root.
|
|
19
|
+
*/
|
|
20
|
+
async function uvFromDownload(options) {
|
|
21
|
+
const { cacheDir, downloader, integrity, platformArch, version } = {
|
|
22
|
+
__proto__: null,
|
|
23
|
+
...options
|
|
24
|
+
};
|
|
25
|
+
const url = require_external_tools_uv_asset_names.getUvDownloadUrl({
|
|
26
|
+
version,
|
|
27
|
+
platformArch
|
|
28
|
+
});
|
|
29
|
+
const entry = require_external_tools_uv_asset_names.getUvAssetEntry(platformArch);
|
|
30
|
+
if (!url || !entry) return;
|
|
31
|
+
const archiveExt = entry.asset.endsWith(".zip") ? ".zip" : ".tar.gz";
|
|
32
|
+
const extractedDir = cacheDir ?? node_path.default.join(require_paths_socket.getSocketDlxDir(), "uv", version, platformArch);
|
|
33
|
+
const archive = await require_external_tools_from_download.downloadAndExtractTool({
|
|
34
|
+
url,
|
|
35
|
+
name: `uv-${version}-${platformArch}${archiveExt}`,
|
|
36
|
+
integrity,
|
|
37
|
+
extractedDir,
|
|
38
|
+
extractOptions: { strip: 1 },
|
|
39
|
+
downloader
|
|
40
|
+
});
|
|
41
|
+
const binary = node_process.default.platform === "win32" ? "uv.exe" : "uv";
|
|
42
|
+
return {
|
|
43
|
+
path: node_path.default.join(extractedDir, binary),
|
|
44
|
+
source: "download",
|
|
45
|
+
integrity: archive.integrity
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
exports.uvFromDownload = uvFromDownload;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with rolldown */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_bin_which = require('../../bin/which.js');
|
|
5
|
+
|
|
6
|
+
//#region src/external-tools/uv/from-path.ts
|
|
7
|
+
/**
|
|
8
|
+
* @file `uvFromPath()` — looks for `uv` on the system PATH.
|
|
9
|
+
*/
|
|
10
|
+
async function uvFromPath() {
|
|
11
|
+
const onPath = await require_bin_which.which("uv", { nothrow: true });
|
|
12
|
+
/* c8 ignore start - reached only when uv is NOT on PATH. */
|
|
13
|
+
if (typeof onPath !== "string") return;
|
|
14
|
+
/* c8 ignore stop */
|
|
15
|
+
return {
|
|
16
|
+
path: onPath,
|
|
17
|
+
source: "path"
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.uvFromPath = uvFromPath;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file `uvFromVfs()` — extracts the uv binary from the smol binary's VFS.
|
|
3
|
+
* Returns `undefined` when the binary doesn't have uv bundled.
|
|
4
|
+
*/
|
|
5
|
+
import type { ResolvedUv } from './types';
|
|
6
|
+
export declare const UV_VFS_KEY = "uv";
|
|
7
|
+
export declare function uvFromVfs(): Promise<ResolvedUv | undefined>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with rolldown */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_smol_vfs = require('../../smol/vfs.js');
|
|
5
|
+
|
|
6
|
+
//#region src/external-tools/uv/from-vfs.ts
|
|
7
|
+
/**
|
|
8
|
+
* @file `uvFromVfs()` — extracts the uv binary from the smol binary's VFS.
|
|
9
|
+
* Returns `undefined` when the binary doesn't have uv bundled.
|
|
10
|
+
*/
|
|
11
|
+
const UV_VFS_KEY = "uv";
|
|
12
|
+
async function uvFromVfs() {
|
|
13
|
+
const vfs = require_smol_vfs.getSmolVfs();
|
|
14
|
+
if (!vfs) return;
|
|
15
|
+
/* c8 ignore start - smol Node binary only. */
|
|
16
|
+
if (!vfs.has("uv")) return;
|
|
17
|
+
return {
|
|
18
|
+
path: await vfs.extract("uv"),
|
|
19
|
+
source: "vfs"
|
|
20
|
+
};
|
|
21
|
+
/* c8 ignore stop */
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.UV_VFS_KEY = UV_VFS_KEY;
|
|
26
|
+
exports.uvFromVfs = uvFromVfs;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file `resolveUv()` — uv resolution entry point. Tries each source in order:
|
|
3
|
+
*
|
|
4
|
+
* 1. VFS — smol binary's embedded uv (if packed)
|
|
5
|
+
* 2. PATH — `uv` on the system PATH
|
|
6
|
+
* 3. download — upstream GitHub release archive (only when `downloadIfMissing`
|
|
7
|
+
* is passed) Returns `undefined` if all of the enabled sources miss.
|
|
8
|
+
* Memoized per option-shape.
|
|
9
|
+
*/
|
|
10
|
+
import type { BinaryDownloader } from '../from-download';
|
|
11
|
+
import type { HashSpec } from '../../integrity';
|
|
12
|
+
import type { ResolvedUv } from './types';
|
|
13
|
+
export interface ResolveUvOptions {
|
|
14
|
+
downloadIfMissing?: {
|
|
15
|
+
version: string;
|
|
16
|
+
platformArch: string;
|
|
17
|
+
integrity?: HashSpec | undefined;
|
|
18
|
+
cacheDir?: string | undefined;
|
|
19
|
+
downloader?: BinaryDownloader | undefined;
|
|
20
|
+
} | undefined;
|
|
21
|
+
}
|
|
22
|
+
export declare function cacheKey(options: ResolveUvOptions | undefined): string;
|
|
23
|
+
export declare function doResolveUv(options?: ResolveUvOptions | undefined): Promise<ResolvedUv | undefined>;
|
|
24
|
+
export declare function resetUvResolution(): void;
|
|
25
|
+
export declare function resolveUv(options?: ResolveUvOptions | undefined): Promise<ResolvedUv | undefined>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with rolldown */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_primordials_map_set = require('../../primordials/map-set.js');
|
|
5
|
+
const require_external_tools_uv_from_download = require('./from-download.js');
|
|
6
|
+
const require_external_tools_uv_from_path = require('./from-path.js');
|
|
7
|
+
const require_external_tools_uv_from_vfs = require('./from-vfs.js');
|
|
8
|
+
|
|
9
|
+
//#region src/external-tools/uv/resolve.ts
|
|
10
|
+
/**
|
|
11
|
+
* @file `resolveUv()` — uv resolution entry point. Tries each source in order:
|
|
12
|
+
*
|
|
13
|
+
* 1. VFS — smol binary's embedded uv (if packed)
|
|
14
|
+
* 2. PATH — `uv` on the system PATH
|
|
15
|
+
* 3. download — upstream GitHub release archive (only when `downloadIfMissing`
|
|
16
|
+
* is passed) Returns `undefined` if all of the enabled sources miss.
|
|
17
|
+
* Memoized per option-shape.
|
|
18
|
+
*/
|
|
19
|
+
const resolutionCache = new require_primordials_map_set.MapCtor();
|
|
20
|
+
function cacheKey(options) {
|
|
21
|
+
const opts = {
|
|
22
|
+
__proto__: null,
|
|
23
|
+
...options
|
|
24
|
+
};
|
|
25
|
+
if (!opts?.downloadIfMissing) return "local-only";
|
|
26
|
+
const { cacheDir, integrity, platformArch, version } = opts.downloadIfMissing;
|
|
27
|
+
return `dl:${version}:${platformArch}:${typeof integrity === "string" ? integrity : integrity ? `${integrity.type}:${integrity.value}` : ""}:${cacheDir ?? ""}`;
|
|
28
|
+
}
|
|
29
|
+
async function doResolveUv(options) {
|
|
30
|
+
const opts = {
|
|
31
|
+
__proto__: null,
|
|
32
|
+
...options
|
|
33
|
+
};
|
|
34
|
+
const fromVfs = await require_external_tools_uv_from_vfs.uvFromVfs();
|
|
35
|
+
/* c8 ignore start - smol Node binary only. */
|
|
36
|
+
if (fromVfs) return fromVfs;
|
|
37
|
+
/* c8 ignore stop */
|
|
38
|
+
const fromPath = await require_external_tools_uv_from_path.uvFromPath();
|
|
39
|
+
if (fromPath) return fromPath;
|
|
40
|
+
if (opts?.downloadIfMissing) return require_external_tools_uv_from_download.uvFromDownload(opts.downloadIfMissing);
|
|
41
|
+
}
|
|
42
|
+
/* c8 ignore start - test-only escape hatch. */
|
|
43
|
+
function resetUvResolution() {
|
|
44
|
+
resolutionCache.clear();
|
|
45
|
+
}
|
|
46
|
+
/* c8 ignore stop */
|
|
47
|
+
function resolveUv(options) {
|
|
48
|
+
const key = cacheKey(options);
|
|
49
|
+
let cached = resolutionCache.get(key);
|
|
50
|
+
if (!cached) {
|
|
51
|
+
cached = doResolveUv(options);
|
|
52
|
+
resolutionCache.set(key, cached);
|
|
53
|
+
}
|
|
54
|
+
return cached;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
exports.cacheKey = cacheKey;
|
|
59
|
+
exports.doResolveUv = doResolveUv;
|
|
60
|
+
exports.resetUvResolution = resetUvResolution;
|
|
61
|
+
exports.resolveUv = resolveUv;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Shared types for uv resolution. uv is Astral's Python package manager
|
|
3
|
+
* used by socket-basics for Python project bootstrap. Ships per-platform
|
|
4
|
+
* archives that wrap the `uv` binary one level deep.
|
|
5
|
+
*/
|
|
6
|
+
import type { ResolvedToolIntegrity } from '../from-download';
|
|
7
|
+
export type UvSource = 'download' | 'path' | 'vfs';
|
|
8
|
+
/**
|
|
9
|
+
* A resolved uv installation.
|
|
10
|
+
*/
|
|
11
|
+
export interface ResolvedUv {
|
|
12
|
+
/**
|
|
13
|
+
* Absolute path to the `uv` executable.
|
|
14
|
+
*/
|
|
15
|
+
readonly path: string;
|
|
16
|
+
/**
|
|
17
|
+
* Which resolver tier found this.
|
|
18
|
+
*/
|
|
19
|
+
readonly source: UvSource;
|
|
20
|
+
/**
|
|
21
|
+
* See {@link ResolvedToolIntegrity}.
|
|
22
|
+
*/
|
|
23
|
+
readonly integrity?: ResolvedToolIntegrity | undefined;
|
|
24
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Fleet-convention config reader: a per-repo override (`.config/repo`)
|
|
3
|
+
* layered over the cascaded fleet default (`.config/fleet`). A thin wrapper
|
|
4
|
+
* over the generic `config/layers` reader that returns the named `{ fleet,
|
|
5
|
+
* repo }` shape fleet callers use, plus the `{ fleet, repo }` array-merge
|
|
6
|
+
* convenience. The generic, fleet-agnostic primitives (`readConfigLayers`,
|
|
7
|
+
* `mergeConfigArray`) live in `config/layers`. Lives in the published lib
|
|
8
|
+
* because it is the only import root the `.git-hooks/_shared` and
|
|
9
|
+
* `.claude/hooks/_shared` trees (which do not cross-import) plus `.config/*`
|
|
10
|
+
* can all reach.
|
|
11
|
+
*/
|
|
12
|
+
export declare const FLEET_LAYER_DIRS: readonly string[];
|
|
13
|
+
export interface RepoConfigTiers<T> {
|
|
14
|
+
fleet: T | undefined;
|
|
15
|
+
repo: T | undefined;
|
|
16
|
+
}
|
|
17
|
+
export interface ResolveRepoConfigOptions {
|
|
18
|
+
repoRoot?: string | undefined;
|
|
19
|
+
cwd?: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Concatenate one array-valued key across the fleet + repo tiers. Fleet entries
|
|
23
|
+
* first, then repo entries. Convenience over `mergeConfigArray` for the `{
|
|
24
|
+
* fleet, repo }` shape.
|
|
25
|
+
*
|
|
26
|
+
* @param tiers - The `{ fleet, repo }` from `resolveRepoConfig`.
|
|
27
|
+
* @param key - The array-valued property to concatenate.
|
|
28
|
+
*
|
|
29
|
+
* @returns Fleet entries followed by repo entries; `[]` when neither is an
|
|
30
|
+
* array.
|
|
31
|
+
*/
|
|
32
|
+
export declare function mergeRepoConfigArray<T extends Record<string, unknown>, K extends keyof T>(tiers: RepoConfigTiers<T>, key: K): Array<T[K] extends Array<infer E> ? E : never>;
|
|
33
|
+
/**
|
|
34
|
+
* Fleet-convention reader: a repo override (`.config/repo`) layered over the
|
|
35
|
+
* cascaded fleet default (`.config/fleet`). A thin wrapper over
|
|
36
|
+
* `readConfigLayers` that returns the named `{ fleet, repo }` shape callers
|
|
37
|
+
* already use; either tier is `undefined` when absent or unparseable.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ;```typescript
|
|
41
|
+
* const { fleet, repo } = resolveRepoConfig<VitestTiers>('vitest')
|
|
42
|
+
* const nonIsolated = [
|
|
43
|
+
* ...(fleet?.nonIsolated ?? []),
|
|
44
|
+
* ...(repo?.nonIsolated ?? []),
|
|
45
|
+
* ]
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @param name - Base name of the config file (no directory, no `.json`).
|
|
49
|
+
* @param options - `repoRoot` / `cwd` for path resolution.
|
|
50
|
+
*
|
|
51
|
+
* @returns `{ fleet, repo }` parsed tiers; either may be `undefined`.
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveRepoConfig<T = unknown>(name: string, options?: ResolveRepoConfigOptions | undefined): RepoConfigTiers<T>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with rolldown */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_config_layers = require('../config/layers.js');
|
|
5
|
+
|
|
6
|
+
//#region src/fleet/repo-config.ts
|
|
7
|
+
/**
|
|
8
|
+
* @file Fleet-convention config reader: a per-repo override (`.config/repo`)
|
|
9
|
+
* layered over the cascaded fleet default (`.config/fleet`). A thin wrapper
|
|
10
|
+
* over the generic `config/layers` reader that returns the named `{ fleet,
|
|
11
|
+
* repo }` shape fleet callers use, plus the `{ fleet, repo }` array-merge
|
|
12
|
+
* convenience. The generic, fleet-agnostic primitives (`readConfigLayers`,
|
|
13
|
+
* `mergeConfigArray`) live in `config/layers`. Lives in the published lib
|
|
14
|
+
* because it is the only import root the `.git-hooks/_shared` and
|
|
15
|
+
* `.claude/hooks/_shared` trees (which do not cross-import) plus `.config/*`
|
|
16
|
+
* can all reach.
|
|
17
|
+
*/
|
|
18
|
+
const FLEET_LAYER_DIRS = [".config/fleet", ".config/repo"];
|
|
19
|
+
/**
|
|
20
|
+
* Concatenate one array-valued key across the fleet + repo tiers. Fleet entries
|
|
21
|
+
* first, then repo entries. Convenience over `mergeConfigArray` for the `{
|
|
22
|
+
* fleet, repo }` shape.
|
|
23
|
+
*
|
|
24
|
+
* @param tiers - The `{ fleet, repo }` from `resolveRepoConfig`.
|
|
25
|
+
* @param key - The array-valued property to concatenate.
|
|
26
|
+
*
|
|
27
|
+
* @returns Fleet entries followed by repo entries; `[]` when neither is an
|
|
28
|
+
* array.
|
|
29
|
+
*/
|
|
30
|
+
function mergeRepoConfigArray(tiers, key) {
|
|
31
|
+
return require_config_layers.mergeConfigArray([tiers.fleet, tiers.repo], key);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Fleet-convention reader: a repo override (`.config/repo`) layered over the
|
|
35
|
+
* cascaded fleet default (`.config/fleet`). A thin wrapper over
|
|
36
|
+
* `readConfigLayers` that returns the named `{ fleet, repo }` shape callers
|
|
37
|
+
* already use; either tier is `undefined` when absent or unparseable.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ;```typescript
|
|
41
|
+
* const { fleet, repo } = resolveRepoConfig<VitestTiers>('vitest')
|
|
42
|
+
* const nonIsolated = [
|
|
43
|
+
* ...(fleet?.nonIsolated ?? []),
|
|
44
|
+
* ...(repo?.nonIsolated ?? []),
|
|
45
|
+
* ]
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @param name - Base name of the config file (no directory, no `.json`).
|
|
49
|
+
* @param options - `repoRoot` / `cwd` for path resolution.
|
|
50
|
+
*
|
|
51
|
+
* @returns `{ fleet, repo }` parsed tiers; either may be `undefined`.
|
|
52
|
+
*/
|
|
53
|
+
function resolveRepoConfig(name, options) {
|
|
54
|
+
const opts = {
|
|
55
|
+
__proto__: null,
|
|
56
|
+
...options
|
|
57
|
+
};
|
|
58
|
+
const base = {
|
|
59
|
+
cwd: opts.cwd,
|
|
60
|
+
rootDir: opts.repoRoot
|
|
61
|
+
};
|
|
62
|
+
const [fleet] = require_config_layers.readConfigLayers(name, {
|
|
63
|
+
...base,
|
|
64
|
+
dirs: [FLEET_LAYER_DIRS[0]]
|
|
65
|
+
});
|
|
66
|
+
const [repo] = require_config_layers.readConfigLayers(name, {
|
|
67
|
+
...base,
|
|
68
|
+
dirs: [FLEET_LAYER_DIRS[1]]
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
fleet,
|
|
72
|
+
repo
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
exports.FLEET_LAYER_DIRS = FLEET_LAYER_DIRS;
|
|
78
|
+
exports.mergeRepoConfigArray = mergeRepoConfigArray;
|
|
79
|
+
exports.resolveRepoConfig = resolveRepoConfig;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with rolldown */
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_paths_rewire = require('../paths/rewire.js');
|
|
5
|
-
const require_fs__internal = require('./_internal.js');
|
|
6
4
|
|
|
7
5
|
//#region src/fs/allowed-dirs-cache.ts
|
|
8
6
|
/**
|
|
@@ -36,7 +34,7 @@ const require_fs__internal = require('./_internal.js');
|
|
|
36
34
|
* @internal Used for test rewiring
|
|
37
35
|
*/
|
|
38
36
|
function invalidatePathCache() {
|
|
39
|
-
|
|
37
|
+
clearAllowedDirectories();
|
|
40
38
|
}
|
|
41
39
|
/**
|
|
42
40
|
* Register `invalidatePathCache` with the rewire module after the current
|
|
@@ -55,8 +53,8 @@ function invalidatePathCache() {
|
|
|
55
53
|
*/
|
|
56
54
|
function registerInvalidationCallback(attempt = 0) {
|
|
57
55
|
try {
|
|
58
|
-
if (typeof
|
|
59
|
-
|
|
56
|
+
if (typeof registerCacheInvalidation === "function") {
|
|
57
|
+
registerCacheInvalidation(invalidatePathCache);
|
|
60
58
|
return;
|
|
61
59
|
}
|
|
62
60
|
} catch {}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Recursive copy for a file or directory tree, with three destination
|
|
3
|
+
* modes (see {@link CopyMode}). Plain `fs.cp` (even with `force`) overwrites
|
|
4
|
+
* files present in the source but never deletes destination files absent from
|
|
5
|
+
* it, so copying onto an existing target leaves stale leftovers behind. The
|
|
6
|
+
* `'pave'` mode makes the destination an exact copy of the source by staging
|
|
7
|
+
* a fresh tree in a sibling temp directory and swapping it in with a single
|
|
8
|
+
* rename — atomic, with no stale survivors.
|
|
9
|
+
*/
|
|
10
|
+
import type { PathLike } from 'node:fs';
|
|
11
|
+
/**
|
|
12
|
+
* Named values for {@link CopyMode}. A frozen object rather than a TypeScript
|
|
13
|
+
* `enum` so the declaration is erasable (enums emit runtime helper code).
|
|
14
|
+
*/
|
|
15
|
+
export declare const CopyMode: Readonly<{
|
|
16
|
+
readonly Fill: 'fill';
|
|
17
|
+
readonly Overlay: 'overlay';
|
|
18
|
+
readonly Pave: 'pave';
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* How {@link copy} treats an existing destination.
|
|
22
|
+
*
|
|
23
|
+
* - `'overlay'` (default) — overwrite files present in the source but leave any
|
|
24
|
+
* pre-existing destination-only files in place (a recursive `fs.cp`).
|
|
25
|
+
* - `'pave'` — replace the destination so it becomes an exact copy of the source;
|
|
26
|
+
* destination entries absent from the source do not survive. The swap is
|
|
27
|
+
* atomic (a sibling temp directory is renamed into place), so a partial tree
|
|
28
|
+
* is never observable.
|
|
29
|
+
* - `'fill'` — copy only what the destination lacks: existing files stay
|
|
30
|
+
* untouched (no-clobber), missing ones are added. Never throws on an existing
|
|
31
|
+
* file.
|
|
32
|
+
*
|
|
33
|
+
* Maps to `cp` (overlay), `rsync --delete` / robocopy `/MIR` (pave), and
|
|
34
|
+
* `cp -n` (fill).
|
|
35
|
+
*/
|
|
36
|
+
export type CopyMode = (typeof CopyMode)[keyof typeof CopyMode];
|
|
37
|
+
/**
|
|
38
|
+
* Options for {@link copy}.
|
|
39
|
+
*/
|
|
40
|
+
export interface CopyOptions {
|
|
41
|
+
/**
|
|
42
|
+
* Dereference symlinks — copy what each points to rather than the link
|
|
43
|
+
* itself.
|
|
44
|
+
*
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
dereference?: boolean | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Predicate deciding which entries to copy. Return `false` to skip an entry
|
|
50
|
+
* (and, for a directory, everything beneath it). Receives resolved source
|
|
51
|
+
* and destination paths, matching `node:fs` `cp`'s `filter`.
|
|
52
|
+
*/
|
|
53
|
+
filter?: ((source: string, destination: string) => boolean) | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* How to treat an existing destination. See {@link CopyMode}.
|
|
56
|
+
*
|
|
57
|
+
* @default 'overlay'
|
|
58
|
+
*/
|
|
59
|
+
mode?: CopyMode | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Abort signal to cancel the operation.
|
|
62
|
+
*/
|
|
63
|
+
signal?: AbortSignal | undefined;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Recursively copy a file or directory tree from `from` to `to`.
|
|
67
|
+
*
|
|
68
|
+
* Works for both files and directories. The `mode` option chooses how an
|
|
69
|
+
* existing destination is treated — overlay (default), pave, or fill; see
|
|
70
|
+
* {@link CopyMode}.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ;```ts
|
|
74
|
+
* // Overlay (default) — overwrite collisions, keep files already in dest:
|
|
75
|
+
* await copy('./src', './dest')
|
|
76
|
+
*
|
|
77
|
+
* // Pave — dest ends up identical to src, no stale survivors:
|
|
78
|
+
* await copy('./vendor/upstream', './deps/upstream', { mode: CopyMode.Pave })
|
|
79
|
+
*
|
|
80
|
+
* // Fill — add only what's missing, never overwrite an existing file:
|
|
81
|
+
* await copy('./defaults', './config', { mode: CopyMode.Fill })
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @param from - Source file or directory to copy.
|
|
85
|
+
* @param to - Destination path.
|
|
86
|
+
* @param options - Copy options (mode, filter, dereference, abort signal).
|
|
87
|
+
*/
|
|
88
|
+
export declare function copy(from: PathLike, to: PathLike, options?: CopyOptions | undefined): Promise<void>;
|