@socketsecurity/lib 6.0.0 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/README.md +26 -17
  3. package/dist/ai/discover.js +2 -2
  4. package/dist/ai/spawn.js +3 -3
  5. package/dist/ai/worktree.js +3 -3
  6. package/dist/argv/parse-args-string.d.ts +30 -0
  7. package/dist/argv/parse-args-string.js +42 -0
  8. package/dist/bin/check-primordials.js +15 -10
  9. package/dist/bin/check.js +2 -2
  10. package/dist/bin/exec.d.ts +1 -1
  11. package/dist/bin/exec.js +2 -2
  12. package/dist/bin/socket-lib.js +2 -2
  13. package/dist/{ttl-cache/cache.js → cache/ttl/store.js} +15 -15
  14. package/dist/{ttl-cache → cache/ttl}/types.d.ts +1 -1
  15. package/dist/checks/primordials-defaults.d.ts +20 -0
  16. package/dist/checks/primordials-defaults.js +92 -0
  17. package/dist/colors/socket-palette.d.ts +69 -0
  18. package/dist/colors/socket-palette.js +91 -0
  19. package/dist/constants/socket.js +1 -1
  20. package/dist/cover/code.js +2 -2
  21. package/dist/cover/type.js +2 -2
  22. package/dist/debug/_internal.d.ts +1 -1
  23. package/dist/debug/_internal.js +2 -2
  24. package/dist/debug/output.js +5 -5
  25. package/dist/dlx/binary-types.d.ts +2 -2
  26. package/dist/dlx/binary.d.ts +2 -2
  27. package/dist/dlx/binary.js +3 -3
  28. package/dist/dlx/firewall.js +2 -2
  29. package/dist/dlx/manifest.js +2 -2
  30. package/dist/dlx/package.d.ts +2 -2
  31. package/dist/dlx/package.js +2 -2
  32. package/dist/dlx/types.d.ts +2 -2
  33. package/dist/eco/npm/npm/exec.d.ts +2 -2
  34. package/dist/eco/npm/npm/exec.js +2 -2
  35. package/dist/eco/npm/pnpm/exec.d.ts +1 -1
  36. package/dist/eco/npm/script.d.ts +1 -1
  37. package/dist/eco/npm/script.js +3 -3
  38. package/dist/eco/npm/yarnpkg/yarn/exec.d.ts +1 -1
  39. package/dist/{signal-exit → events/exit}/_internal.d.ts +1 -1
  40. package/dist/{signal-exit/register.js → events/exit/handler.js} +4 -4
  41. package/dist/{signal-exit → events/exit}/intercept.js +2 -2
  42. package/dist/{signal-exit → events/exit}/types.d.ts +1 -1
  43. package/dist/{warnings/event-target.d.ts → events/warning/handler.d.ts} +1 -1
  44. package/dist/{warnings/event-target.js → events/warning/handler.js} +4 -4
  45. package/dist/{warnings → events/warning}/suppress.d.ts +3 -3
  46. package/dist/{warnings → events/warning}/suppress.js +2 -2
  47. package/dist/external-tools/janus/asset-names.d.ts +7 -0
  48. package/dist/external-tools/janus/asset-names.js +5 -0
  49. package/dist/external-tools/janus/from-download.d.ts +1 -1
  50. package/dist/external-tools/janus/from-download.js +12 -4
  51. package/dist/fs/read-json-cache.d.ts +83 -0
  52. package/dist/fs/read-json-cache.js +156 -0
  53. package/dist/fs/read-json.d.ts +6 -1
  54. package/dist/fs/read-json.js +80 -8
  55. package/dist/fs/types.d.ts +14 -0
  56. package/dist/git/_internal.js +3 -3
  57. package/dist/github/refs-cache.d.ts +1 -1
  58. package/dist/github/refs-cache.js +2 -2
  59. package/dist/github/token.d.ts +1 -1
  60. package/dist/github/token.js +2 -2
  61. package/dist/globs/{glob.js → match.js} +3 -3
  62. package/dist/http-request/browser-fetch.d.ts +10 -0
  63. package/dist/http-request/browser-fetch.js +32 -0
  64. package/dist/http-request/browser.d.ts +190 -0
  65. package/dist/http-request/browser.js +224 -0
  66. package/dist/http-request/download-types.d.ts +2 -2
  67. package/dist/http-request/http-request.d.ts +12 -0
  68. package/dist/http-request/http-request.js +36 -0
  69. package/dist/http-request/node.d.ts +29 -0
  70. package/dist/http-request/{convenience.js → node.js} +9 -3
  71. package/dist/http-request/request-attempt.js +4 -0
  72. package/dist/http-request/request-types.d.ts +15 -0
  73. package/dist/http-request/request.js +5 -0
  74. package/dist/links/{link.d.ts → create.d.ts} +2 -2
  75. package/dist/links/{link.js → create.js} +3 -3
  76. package/dist/logger/_internal.d.ts +1 -1
  77. package/dist/logger/browser.d.ts +18 -0
  78. package/dist/logger/browser.js +58 -0
  79. package/dist/logger/console.js +3 -3
  80. package/dist/logger/default.d.ts +11 -0
  81. package/dist/logger/default.js +37 -0
  82. package/dist/logger/logger.d.ts +8 -403
  83. package/dist/logger/logger.js +3 -827
  84. package/dist/logger/node.d.ts +400 -0
  85. package/dist/logger/node.js +856 -0
  86. package/dist/logger/symbols-builder.d.ts +1 -1
  87. package/dist/logger/types.d.ts +1 -1
  88. package/dist/packages/isolation.js +3 -3
  89. package/dist/packages/provenance.d.ts +42 -0
  90. package/dist/packages/provenance.js +71 -0
  91. package/dist/packages/types.d.ts +2 -0
  92. package/dist/primordials/globals.d.ts +6 -3
  93. package/dist/primordials/globals.js +15 -9
  94. package/dist/primordials/map-set.d.ts +35 -0
  95. package/dist/primordials/map-set.js +43 -0
  96. package/dist/primordials/url.d.ts +1 -1
  97. package/dist/process/lock-manager.js +4 -4
  98. package/dist/{spawn → process/spawn}/_internal.js +3 -3
  99. package/dist/{spawn/spawn.js → process/spawn/child.js} +13 -13
  100. package/dist/{spawn → process/spawn}/errors.js +5 -5
  101. package/dist/{spawn → process/spawn}/stdio.js +1 -1
  102. package/dist/{spawn → process/spawn}/types.d.ts +3 -3
  103. package/dist/promises/types.d.ts +15 -2
  104. package/dist/releases/github-archives.js +2 -2
  105. package/dist/releases/github-downloads.js +4 -4
  106. package/dist/spinner/{registry.d.ts → default.d.ts} +1 -1
  107. package/dist/spinner/{registry.js → default.js} +3 -3
  108. package/dist/spinner/spinner.js +4 -4
  109. package/dist/spinner/with.d.ts +1 -1
  110. package/dist/stdio/divider.js +2 -2
  111. package/dist/stdio/footer.js +2 -2
  112. package/dist/stdio/header.js +2 -2
  113. package/dist/stdio/prompts.js +2 -2
  114. package/package.json +410 -132
  115. package/dist/http-request/convenience.d.ts +0 -104
  116. package/dist/promise-queue/types.d.ts +0 -10
  117. package/dist/ttl-cache/types.js +0 -18
  118. /package/dist/{ttl-cache/cache.d.ts → cache/ttl/store.d.ts} +0 -0
  119. /package/dist/{promise-queue → cache/ttl}/types.js +0 -0
  120. /package/dist/{signal-exit → events/exit}/_internal.js +0 -0
  121. /package/dist/{signal-exit/register.d.ts → events/exit/handler.d.ts} +0 -0
  122. /package/dist/{signal-exit → events/exit}/intercept.d.ts +0 -0
  123. /package/dist/{signal-exit → events/exit}/lifecycle.d.ts +0 -0
  124. /package/dist/{signal-exit → events/exit}/lifecycle.js +0 -0
  125. /package/dist/{signal-exit → events/exit}/signals.d.ts +0 -0
  126. /package/dist/{signal-exit → events/exit}/signals.js +0 -0
  127. /package/dist/{signal-exit → events/exit}/types.js +0 -0
  128. /package/dist/globs/{glob.d.ts → match.d.ts} +0 -0
  129. /package/dist/{spawn → process/spawn}/_internal.d.ts +0 -0
  130. /package/dist/{spawn/spawn.d.ts → process/spawn/child.d.ts} +0 -0
  131. /package/dist/{spawn → process/spawn}/errors.d.ts +0 -0
  132. /package/dist/{spawn → process/spawn}/stdio.d.ts +0 -0
  133. /package/dist/{spawn → process/spawn}/types.js +0 -0
  134. /package/dist/{promise-queue → promises}/queue.d.ts +0 -0
  135. /package/dist/{promise-queue → promises}/queue.js +0 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,97 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [6.0.2](https://github.com/SocketDev/socket-lib/releases/tag/v6.0.2) - 2026-05-26
9
+
10
+ ### Added
11
+
12
+ - **`./logger/logger` and `./http-request/http-request`** as the canonical class / function-surface entries, paired with the existing `./logger/{node,browser}` and `./http-request/{node,browser}` implementations. Bundlers that honor the `'browser'` export condition pick the right impl automatically: `import { Logger } from '@socketsecurity/lib/logger/logger'` and `import { httpJson } from '@socketsecurity/lib/http-request/http-request'` work on both platforms.
13
+ - **`./logger/default`** holds the shared-singleton accessor: `getDefaultLogger()` returns one process-wide `Logger` instance (lazily constructed). Same on both platforms.
14
+ - **`./http-request` top-level export.** New canonical entry mirroring `./http-request/http-request`.
15
+ - **Package trust-status helpers in `./packages/provenance`.** `getTrustStatus(meta)` extracts `{ provenance, trustedPublisher, stagedPublish }` from an npm registry version document; `getTrustLevel(status)` maps to a 0..3 ladder and `getTrustLevelName(status)` to its name; `TRUST_LEVELS` is the single source-of-truth array (index = level); `compareTrust(a, b)` is an ascending-level comparator; `didTrustDecrease(prev, next)` flags a release that regressed its supply-chain posture.
16
+ - **`primordials/map-set` Stage 4 surface.** `getOrInsert` / `getOrInsertComputed` on `Map` / `WeakMap` plus the Set-composition methods (`union`, `intersection`, `difference`, `symmetricDifference`, `isSubsetOf`, `isSupersetOf`, `isDisjointFrom`) are ambient-declared, so consumers get types for methods Node 22+ ships but TypeScript's lib doesn't yet surface.
17
+
18
+ ### Changed (breaking)
19
+
20
+ - **`getDefaultLogger` moved from `./logger` to `./logger/default`.** The bare `./logger` entry now exposes the `Logger` class only (matching `./logger/logger`). Migration: `import { getDefaultLogger } from '@socketsecurity/lib/logger'` → `from '@socketsecurity/lib/logger/default'`.
21
+ - **`./logger/default` semantics shifted.** Previously `./logger/default` resolved to the Node logger source; that file is now `./logger/node`. The `./logger/default` path is the singleton accessor module.
22
+ - **`./http-request/convenience` removed.** `httpJson` and `httpText` live on `./http-request/node` and `./http-request/browser` alongside `httpRequest` and `HttpResponseError`. Most consumers should import from `./http-request` (auto-routing) rather than the explicit leaf.
23
+
24
+ ### Fixed
25
+
26
+ - **`./logger` auto-resolves to `./logger/browser` on browser platforms.** 6.0.1 announced this but shipped without the `'browser'` condition on the `./logger` entry, so bundlers fell through to the Node default and pulled in `node:*` builtins.
27
+
28
+ ## [6.0.1](https://github.com/SocketDev/socket-lib/releases/tag/v6.0.1) - 2026-05-25
29
+
30
+ Five additive features plus public-surface polish on top of 6.0.0. The path renames drop doubled-name leaves (`spawn/spawn`, `ttl-cache/cache`, `globs/glob`, `links/link`, `promise-queue/queue`) and regroup three top-level directories whose contents were the same concept (process events) under a new `events/` umbrella. Renames are path-only; no symbol renames or behavior changes.
31
+
32
+ ### Added
33
+
34
+ - **`colors/socket-palette`** — Socket-branded 24-bit ANSI palette. Three themes (`'light' | 'dark' | 'synthwave'`) expose status colors (`success` / `warning` / `alert` / `error` / `info`) plus the Socket brand constants (`socketPurple` `#8c50ff`, `socketPink` `#ff00aa`). Each helper emits `\x1b[38;2;R;G;Bm` directly rather than rounding to the legacy 8-color palette, so truecolor terminals render the brand hex byte-for-byte. Hex values exposed via `palette.hex.*` for callers building their own escapes. Default theme is `'dark'`.
35
+ - **`logger/browser`** — minimal `console`-backed `Logger` mirroring the public `success` / `fail` / `warn` / `error` / `info` / `log` surface, with no `node:process` / `node:console` / `node:os` imports. Usable from Chrome MV3 service workers, content scripts, and popups. Importing `@socketsecurity/lib/logger` in a bundler that resolves the `'browser'` export condition (rolldown, vite, esbuild) automatically picks up this shim; Node consumers continue to get the full `Logger` class.
36
+ - **`'browser'` export condition** on 40 leaf modules. 35 zero-Node leaf utilities (`arrays`, `colors`, `errors`, `objects`, `regexps`, `strings`, `url`, `versions`, `words` families) carry a `'browser'` condition signalling browser-safety to bundlers. Five leaves with dedicated browser implementations (`logger/browser`, `http-request/browser`, `http-request/browser-fetch`) route to the alternate file. Browser-incompatible modules (`fs`, `archives`, `bin`, subprocess / TTY / OS-secrets surfaces) deliberately omit the condition. Full compatibility matrix in [`docs/browser-compatibility.md`](./docs/browser-compatibility.md).
37
+ - **`http-request` `signal` option (Node-side parity).** `HttpRequestOptions.signal?: AbortSignal | undefined` is now plumbed through `request-attempt` → `httpModule.request()`. An aborted signal short-circuits the retry loop (caller cancel is not retryable). Brings the Node side to parity with the browser side, which already exposes `signal` via `AbortController` on `fetch()`.
38
+ - **Default-on read-result cache for `fs/read-json` `readJson` / `readJsonSync`.** Process-scoped LRU cache keyed on `path + ino + size + mtimeMs`. Safe by four guards: stat-validated keys (re-read on stat mismatch), defensive clone on both insert and hit (caller mutations can't poison the entry), reviver opt-out (function identity isn't safely hashable), and per-call `cache: false` escape hatch. Cap defaults to 256 entries (env `SOCKET_LIB_READ_JSON_CACHE_MAX` or `setReadJsonCacheMax()`); TTL defaults to 5 min (env `SOCKET_LIB_READ_JSON_CACHE_TTL_MS` or `setReadJsonCacheTtlMs()`; set to `0` to disable TTL). `clearReadJsonCache()` + `getReadJsonCacheStats()` exported for tests and long-running daemons.
39
+ - **`argv/parse-args-string`** — `parseArgsString(cmd)` tokenizes a shell-style command string into an argv array. Recognizes bare tokens, single + double quoted tokens, and mixed `key="value"` tokens. Use for turning a string representation of a command (from config, a `bin` field, a test fixture) into argv that `child_process.spawn` / `execFileSync` accepts directly, bypassing platform shell quoting differences (`cmd.exe` vs `bash`).
40
+
41
+ ### Changed (breaking)
42
+
43
+ - **`spawn/*` → `process/spawn/*`.** Directory moved under `process/` (which already housed `process/abort`); the function leaf renames from `spawn/spawn` to `process/spawn/child` (the spawned child is what `spawn()` returns). Sibling files keep their names: `process/spawn/{errors,stdio,types,_internal}`.
44
+ - **`signal-exit/*` → `events/exit/*`.** Directory merged into a new `events/` umbrella. Entry leaf renames from `signal-exit/register` to `events/exit/handler`. Sibling files unchanged: `events/exit/{intercept,lifecycle,signals,types,_internal}`.
45
+ - **`warnings/*` → `events/warning/*`.** Sibling of `events/exit/` under the new `events/` umbrella. Entry leaf renames from `warnings/event-target` to `events/warning/handler`; `warnings/suppress` becomes `events/warning/suppress`.
46
+ - **`ttl-cache/*` → `cache/ttl/*`.** Directory renamed; entry leaf renames from `ttl-cache/cache` to `cache/ttl/store`. `ttl-cache/types` becomes `cache/ttl/types`.
47
+ - **`promise-queue/*` folded into existing `promises/`.** `promise-queue/queue` becomes `promises/queue`; `promise-queue/types` merges into the existing `promises/types`.
48
+ - **`spinner/registry` → `spinner/default`.** Matches the `getDefaultSpinner()` naming pattern — the leaf is "the default spinner", not "the registry of spinners".
49
+ - **`logger/logger` → `logger/default`.** Matches the `getDefaultLogger()` naming pattern; drops the doubled segment.
50
+ - **`globs/glob` → `globs/match`.** Drops the doubled segment; `match` describes what the function does (pattern-match files), not what type the file is.
51
+ - **`links/link` → `links/create`.** Drops the doubled segment; `create` describes the verb (`createSymlink`).
52
+ - **`exports` map refreshed** for all renamed/moved leaves. The `./promises/types` entry stays unchanged — `promise-queue/types` content was folded into it.
53
+
54
+ ### Removed (breaking)
55
+
56
+ - **Top-level directories `spawn/`, `signal-exit/`, `warnings/`, `ttl-cache/`, `promise-queue/`.** All five disappear in favor of the regrouped layouts above. No backcompat aliases.
57
+
58
+ ### Migration
59
+
60
+ ```diff
61
+ - import { spawn, spawnSync } from '@socketsecurity/lib/spawn/spawn'
62
+ - import { isSpawnError, SpawnError } from '@socketsecurity/lib/spawn/errors'
63
+ - import type { SpawnOptions } from '@socketsecurity/lib/spawn/types'
64
+ + import {
65
+ + spawn,
66
+ + spawnSync,
67
+ + isSpawnError,
68
+ + SpawnError,
69
+ + } from '@socketsecurity/lib/process/spawn/child'
70
+ + import type { SpawnOptions } from '@socketsecurity/lib/process/spawn/types'
71
+
72
+ - import { onExit } from '@socketsecurity/lib/signal-exit/register'
73
+ + import { onExit } from '@socketsecurity/lib/events/exit/handler'
74
+
75
+ - import { suppressDeprecationWarnings } from '@socketsecurity/lib/warnings/suppress'
76
+ + import { suppressDeprecationWarnings } from '@socketsecurity/lib/events/warning/suppress'
77
+
78
+ - import { createTtlCache, TtlCache } from '@socketsecurity/lib/ttl-cache/cache'
79
+ + import { createTtlCache, TtlCache } from '@socketsecurity/lib/cache/ttl/store'
80
+
81
+ - import { getDefaultSpinner } from '@socketsecurity/lib/spinner/registry'
82
+ + import { getDefaultSpinner } from '@socketsecurity/lib/spinner/default'
83
+
84
+ - import { getDefaultLogger } from '@socketsecurity/lib/logger/logger'
85
+ + import { getDefaultLogger } from '@socketsecurity/lib/logger/default'
86
+
87
+ - import { PromiseQueue } from '@socketsecurity/lib/promise-queue/queue'
88
+ + import { PromiseQueue } from '@socketsecurity/lib/promises/queue'
89
+
90
+ - import { glob } from '@socketsecurity/lib/globs/glob'
91
+ + import { glob } from '@socketsecurity/lib/globs/match'
92
+
93
+ - import { createSymlink } from '@socketsecurity/lib/links/link'
94
+ + import { createSymlink } from '@socketsecurity/lib/links/create'
95
+ ```
96
+
97
+ No symbol names changed. No behavior changes.
98
+
8
99
  ## [6.0.0](https://github.com/SocketDev/socket-lib/releases/tag/v6.0.0) - 2026-05-20
9
100
 
10
101
  Public-surface reshape. All top-level barrels are gone; import from named leaf subpaths instead. `@socketsecurity/lib/logger` and `@socketsecurity/lib/errors` stay as aliases.
package/README.md CHANGED
@@ -2,20 +2,24 @@
2
2
 
3
3
  [![Socket Badge](https://socket.dev/api/badge/npm/package/@socketsecurity/lib)](https://socket.dev/npm/package/@socketsecurity/lib)
4
4
  [![CI](https://github.com/SocketDev/socket-lib/actions/workflows/ci.yml/badge.svg)](https://github.com/SocketDev/socket-lib/actions/workflows/ci.yml)
5
- ![Coverage](https://img.shields.io/badge/coverage-98%25-brightgreen)
5
+ ![Coverage](https://img.shields.io/badge/coverage-99%25-brightgreen)
6
6
 
7
7
  [![Follow @SocketSecurity](https://img.shields.io/twitter/follow/SocketSecurity?style=social)](https://twitter.com/SocketSecurity)
8
8
  [![Follow @socket.dev on Bluesky](https://img.shields.io/badge/Follow-@socket.dev-1DA1F2?style=social&logo=bluesky)](https://bsky.app/profile/socket.dev)
9
9
 
10
10
  Core utilities for [Socket.dev](https://socket.dev/) tools: file system, processes, HTTP, env detection, logging, spinners, and more. Tree-shakeable, TypeScript-first, cross-platform.
11
11
 
12
+ ## Why this repo exists
13
+
14
+ `@socketsecurity/lib` is the shared utility layer for every Socket.dev tool (the CLI, SDK, registry, MCP server, build infrastructure). It exists so we ship one battle-tested implementation of "spawn a child", "fetch JSON with retries", "delete a path safely on Windows + POSIX", etc. — rather than ten subtly different ones across the fleet. Every export is reachable via a subpath import, so tree-shaking keeps your bundle lean.
15
+
12
16
  ## Install
13
17
 
14
- ```bash
18
+ ```sh
15
19
  pnpm add @socketsecurity/lib
16
20
  ```
17
21
 
18
- ## Quick Start
22
+ ## Usage
19
23
 
20
24
  ```typescript
21
25
  import { Spinner } from '@socketsecurity/lib/spinner'
@@ -35,24 +39,14 @@ import { httpJson } from '@socketsecurity/lib/http-request'
35
39
  import { safeDelete } from '@socketsecurity/lib/fs'
36
40
  ```
37
41
 
38
- ## Documentation
39
-
40
42
  Start with the [API Index](./docs/api-index.md) — every subpath export with a one-line description.
41
43
 
42
- - [Getting Started](./docs/getting-started.md) – install + first examples
43
- - [Visual Effects](./docs/visual-effects.md) – spinners, loggers, themes
44
- - [File System](./docs/file-system.md) – files, globs, paths, safe deletion
45
- - [HTTP Utilities](./docs/http-utilities.md) – requests, downloads, retries
46
- - [Process Utilities](./docs/process-utilities.md) – spawn, IPC, locks
47
- - [Package Management](./docs/package-management.md) – npm/pnpm/yarn detection
48
- - [Environment](./docs/environment.md) – CI/platform detection, env getters
49
- - [Constants](./docs/constants.md) – Node versions, npm URLs, platform values
50
- - [Examples](./docs/examples.md) – real-world patterns
51
- - [Troubleshooting](./docs/troubleshooting.md) – common issues
52
-
53
44
  ## Development
54
45
 
55
- ```bash
46
+ <details>
47
+ <summary>Contributor commands</summary>
48
+
49
+ ```sh
56
50
  pnpm install # install
57
51
  pnpm build # build
58
52
  pnpm test # run tests
@@ -64,6 +58,21 @@ pnpm run fix # auto-fix formatting
64
58
 
65
59
  See [CLAUDE.md](./CLAUDE.md) for contributor guidelines.
66
60
 
61
+ ### Documentation map
62
+
63
+ - [Getting Started](./docs/getting-started.md) – install + first examples
64
+ - [Visual Effects](./docs/visual-effects.md) – spinners, loggers, themes
65
+ - [File System](./docs/file-system.md) – files, globs, paths, safe deletion
66
+ - [HTTP Utilities](./docs/http-utilities.md) – requests, downloads, retries
67
+ - [Process Utilities](./docs/process-utilities.md) – spawn, IPC, locks
68
+ - [Package Management](./docs/package-management.md) – npm/pnpm/yarn detection
69
+ - [Environment](./docs/environment.md) – CI/platform detection, env getters
70
+ - [Constants](./docs/constants.md) – Node versions, npm URLs, platform values
71
+ - [Examples](./docs/examples.md) – real-world patterns
72
+ - [Troubleshooting](./docs/troubleshooting.md) – common issues
73
+
74
+ </details>
75
+
67
76
  ## License
68
77
 
69
78
  MIT
@@ -44,9 +44,9 @@ var import_promises = require("node:fs/promises");
44
44
  var import_node_path = __toESM(require("node:path"), 1);
45
45
  var import_which = require("../bin/which");
46
46
  var import_message = require("../errors/message");
47
- var import_logger = require("../logger/logger");
47
+ var import_default = require("../logger/default");
48
48
  var import_json = require("../primordials/json");
49
- const logger = (0, import_logger.getDefaultLogger)();
49
+ const logger = (0, import_default.getDefaultLogger)();
50
50
  const KNOWN_AGENTS = [
51
51
  "claude",
52
52
  "codex",
package/dist/ai/spawn.js CHANGED
@@ -29,8 +29,8 @@ __export(spawn_exports, {
29
29
  module.exports = __toCommonJS(spawn_exports);
30
30
  var import_message = require("../errors/message");
31
31
  var import_object = require("../primordials/object");
32
- var import_spawn = require("../spawn/spawn");
33
- var import_errors = require("../spawn/errors");
32
+ var import_child = require("../process/spawn/child");
33
+ var import_errors = require("../process/spawn/errors");
34
34
  var import_discover = require("./discover");
35
35
  const MAX_ATTEMPTS = 3;
36
36
  const BACKOFF_BASE_MS = 5e3;
@@ -163,7 +163,7 @@ async function spawnAiAgent(opts) {
163
163
  stderr = "";
164
164
  exitCode = 0;
165
165
  try {
166
- const child = (0, import_spawn.spawn)(agent, args, {
166
+ const child = (0, import_child.spawn)(agent, args, {
167
167
  cwd: opts.cwd,
168
168
  stdio: "pipe",
169
169
  stdioString: true,
@@ -42,15 +42,15 @@ module.exports = __toCommonJS(worktree_exports);
42
42
  var import_node_fs = require("node:fs");
43
43
  var import_node_path = __toESM(require("node:path"), 1);
44
44
  var import_message = require("../errors/message");
45
- var import_spawn = require("../spawn/spawn");
46
- var import_errors = require("../spawn/errors");
45
+ var import_child = require("../process/spawn/child");
46
+ var import_errors = require("../process/spawn/errors");
47
47
  const DEFAULT_CONCURRENCY = 4;
48
48
  const MAX_CONCURRENCY = 8;
49
49
  function currentBranch(repo) {
50
50
  return git(repo, "symbolic-ref", "--short", "HEAD");
51
51
  }
52
52
  function git(cwd, ...args) {
53
- const result = (0, import_spawn.spawnSync)("git", args, {
53
+ const result = (0, import_child.spawnSync)("git", args, {
54
54
  cwd,
55
55
  stdio: "pipe",
56
56
  stdioString: true
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @file Tokenize a shell-style command string into an argv array. Modernized
3
+ * port of the `string-argv` npm package (MIT) — same regex-driven recognizer,
4
+ * native ES module shape, typed signature, no env/file prepend baggage.
5
+ * Supports bare tokens, single + double quoted tokens, and mixed tokens like
6
+ * `key="value"`. No backslash-escape processing — `\"` inside a double-quoted
7
+ * segment is two literal characters, not an escaped quote. No env-var
8
+ * expansion, no command substitution, no pipes / redirects / `&&` chains;
9
+ * this is purely a tokenizer. Common use case: turning a `string`
10
+ * representation of a command (e.g. from a config file, a `bin` field, or a
11
+ * shellout test fixture) into an argv array that `execFileSync` /
12
+ * `child_process.spawn` accepts directly — bypassing the platform shell + its
13
+ * quoting differences (`cmd.exe` vs `bash`).
14
+ */
15
+ /**
16
+ * Tokenize a shell-style command string into argv. Single + double quote pairs
17
+ * are recognized; the quote characters are stripped from the resulting token.
18
+ * Whitespace outside of quotes separates tokens.
19
+ *
20
+ * @example
21
+ * parseArgsString('git commit -m "hello world"')
22
+ * // → ['git', 'commit', '-m', 'hello world']
23
+ *
24
+ * parseArgsString('foo --bar="x y" baz')
25
+ * // → ['foo', '--bar=x y', 'baz']
26
+ *
27
+ * parseArgsString("echo 'one two' three")
28
+ * // → ['echo', 'one two', 'three']
29
+ */
30
+ export declare function parseArgsString(cmd: string): string[];
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with esbuild */
3
+ "use strict";
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var parse_args_string_exports = {};
22
+ __export(parse_args_string_exports, {
23
+ parseArgsString: () => parseArgsString
24
+ });
25
+ module.exports = __toCommonJS(parse_args_string_exports);
26
+ const TOKEN_REGEXP = /([^\s'"]([^\s'"]*(['"])([^]*?)\3)+[^\s'"]*)|[^\s'"]+|(['"])([^]*?)\5/g;
27
+ function parseArgsString(cmd) {
28
+ const argv = [];
29
+ let match;
30
+ TOKEN_REGEXP.lastIndex = 0;
31
+ while ((match = TOKEN_REGEXP.exec(cmd)) !== null) {
32
+ const token = match[1] ?? match[6] ?? match[0];
33
+ if (typeof token === "string") {
34
+ argv.push(token);
35
+ }
36
+ }
37
+ return argv;
38
+ }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ parseArgsString
42
+ });
@@ -43,14 +43,15 @@ var import_node_fs = require("node:fs");
43
43
  var import_node_path = __toESM(require("node:path"));
44
44
  var import_node_process = __toESM(require("node:process"));
45
45
  var import_message = require("../errors/message");
46
- var import_logger = require("../logger/logger");
46
+ var import_default = require("../logger/default");
47
47
  var import_array = require("../primordials/array");
48
48
  var import_error = require("../primordials/error");
49
49
  var import_json = require("../primordials/json");
50
50
  var import_object = require("../primordials/object");
51
+ var import_primordials_defaults = require("../checks/primordials-defaults");
51
52
  var import_primordials = require("../checks/primordials");
52
53
  var import_parse = require("../argv/parse");
53
- const logger = (0, import_logger.getDefaultLogger)();
54
+ const logger = (0, import_default.getDefaultLogger)();
54
55
  const DEFAULT_CONFIG_PATH = ".socket-lib.json";
55
56
  const FALLBACK_CONFIG_PATHS = [
56
57
  ".socket-lib.json",
@@ -109,14 +110,16 @@ function printHelp() {
109
110
  logger.log("Config (.socket-lib.json \u2014 primordials section):");
110
111
  logger.log(" {");
111
112
  logger.log(' "primordials": {');
112
- logger.log(' "aliasMap": { "Array": "ArrayCtor" },');
113
- logger.log(' "nodeInternalOnly": ["SafeMap", "SafeSet"],');
114
113
  logger.log(
115
114
  ' "scanDirs": ["src", "additions/source-patched/lib"]'
116
115
  );
117
116
  logger.log(" }");
118
117
  logger.log(" }");
119
118
  logger.log("");
119
+ logger.log("Only `scanDirs` is required. `aliasMap` and `nodeInternalOnly`");
120
+ logger.log("default to the fleet-canonical sets and only need entries when");
121
+ logger.log("your repo extends or overrides them.");
122
+ logger.log("");
120
123
  logger.log("A bare object (no `primordials` section) is also accepted for");
121
124
  logger.log("repos that only run this one check.");
122
125
  }
@@ -152,14 +155,16 @@ function loadConfig(configPath) {
152
155
  if (raw.nodeInternalOnly !== void 0 && !(0, import_array.ArrayIsArray)(raw.nodeInternalOnly)) {
153
156
  throw new import_error.ErrorCtor("config.nodeInternalOnly must be an array of strings");
154
157
  }
155
- const aliasMap = new Map(
156
- (0, import_object.ObjectEntries)(raw.aliasMap ?? {})
157
- );
158
- const nodeInternalOnly = new Set(
159
- (raw.nodeInternalOnly ?? []).filter(
158
+ const aliasMap = new Map([
159
+ ...(0, import_object.ObjectEntries)(import_primordials_defaults.DEFAULT_ALIAS_MAP),
160
+ ...(0, import_object.ObjectEntries)(raw.aliasMap ?? {})
161
+ ]);
162
+ const nodeInternalOnly = /* @__PURE__ */ new Set([
163
+ ...import_primordials_defaults.DEFAULT_NODE_INTERNAL_ONLY,
164
+ ...(raw.nodeInternalOnly ?? []).filter(
160
165
  (x) => typeof x === "string"
161
166
  )
162
- );
167
+ ]);
163
168
  return {
164
169
  scanDirs: raw.scanDirs,
165
170
  aliasMap,
package/dist/bin/check.js CHANGED
@@ -24,9 +24,9 @@ __export(check_exports, {
24
24
  runCheck: () => runCheck
25
25
  });
26
26
  module.exports = __toCommonJS(check_exports);
27
- var import_logger = require("../logger/logger");
27
+ var import_default = require("../logger/default");
28
28
  var import_check_primordials = require("./check-primordials");
29
- const logger = (0, import_logger.getDefaultLogger)();
29
+ const logger = (0, import_default.getDefaultLogger)();
30
30
  const CHECKS = /* @__PURE__ */ new Map([
31
31
  ["primordials", "primordials"],
32
32
  ["prim", "primordials"]
@@ -17,7 +17,7 @@
17
17
  * 4. On not-found, throw a typed `ENOENT` error with operator guidance — far
18
18
  * more useful than a bare "command not found".
19
19
  */
20
- import type { SpawnOptions } from '../spawn/types';
20
+ import type { SpawnOptions } from '../process/spawn/types';
21
21
  /**
22
22
  * Execute a binary with the given arguments.
23
23
  *
package/dist/bin/exec.js CHANGED
@@ -27,7 +27,7 @@ var import_platform = require("../constants/platform");
27
27
  var import_normalize = require("../paths/normalize");
28
28
  var import_array = require("../primordials/array");
29
29
  var import_error = require("../primordials/error");
30
- var import_spawn = require("../spawn/spawn");
30
+ var import_child = require("../process/spawn/child");
31
31
  var import_internal = require("./_internal");
32
32
  var import_resolve = require("./resolve");
33
33
  var import_which = require("./which");
@@ -68,7 +68,7 @@ To resolve:
68
68
  throw error;
69
69
  }
70
70
  const binCommand = (0, import_array.ArrayIsArray)(resolvedPath) ? resolvedPath[0] : resolvedPath;
71
- return await (0, import_spawn.spawn)(binCommand, args ?? [], {
71
+ return await (0, import_child.spawn)(binCommand, args ?? [], {
72
72
  shell: import_platform.WIN32,
73
73
  ...options
74
74
  });
@@ -36,9 +36,9 @@ __export(socket_lib_exports, {
36
36
  });
37
37
  module.exports = __toCommonJS(socket_lib_exports);
38
38
  var import_node_process = __toESM(require("node:process"));
39
- var import_logger = require("../logger/logger");
39
+ var import_default = require("../logger/default");
40
40
  var import_check = require("./check");
41
- const logger = (0, import_logger.getDefaultLogger)();
41
+ const logger = (0, import_default.getDefaultLogger)();
42
42
  function printHelp() {
43
43
  logger.log("socket-lib \u2014 fleet-wide static-analysis CLI");
44
44
  logger.log("");
@@ -28,21 +28,21 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  mod
29
29
  ));
30
30
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
- var cache_exports = {};
32
- __export(cache_exports, {
31
+ var store_exports = {};
32
+ __export(store_exports, {
33
33
  createTtlCache: () => createTtlCache
34
34
  });
35
- module.exports = __toCommonJS(cache_exports);
36
- var import_clear = require("../cacache/clear");
37
- var import_read = require("../cacache/read");
38
- var import_write = require("../cacache/write");
39
- var import_date = require("../primordials/date");
40
- var import_error = require("../primordials/error");
41
- var import_json = require("../primordials/json");
42
- var import_map_set = require("../primordials/map-set");
43
- var import_math = require("../primordials/math");
44
- var import_regexp = require("../primordials/regexp");
45
- var import_string = require("../primordials/string");
35
+ module.exports = __toCommonJS(store_exports);
36
+ var import_clear = require("../../cacache/clear");
37
+ var import_read = require("../../cacache/read");
38
+ var import_write = require("../../cacache/write");
39
+ var import_date = require("../../primordials/date");
40
+ var import_error = require("../../primordials/error");
41
+ var import_json = require("../../primordials/json");
42
+ var import_map_set = require("../../primordials/map-set");
43
+ var import_math = require("../../primordials/math");
44
+ var import_regexp = require("../../primordials/regexp");
45
+ var import_string = require("../../primordials/string");
46
46
  const DEFAULT_TTL_MS = 5 * 60 * 1e3;
47
47
  const DEFAULT_PREFIX = "ttl-cache";
48
48
  const DEFAULT_MEMO_MAX_SIZE = 1e3;
@@ -158,8 +158,8 @@ function createTtlCache(options) {
158
158
  results.set(originalKey, entry.data);
159
159
  }
160
160
  }
161
- const cacheDir = (await import("../paths/socket")).getSocketCacacheDir();
162
- const cacacheModule = await import("../cacache/_internal");
161
+ const cacheDir = (await import("../../paths/socket")).getSocketCacacheDir();
162
+ const cacacheModule = await import("../../cacache/_internal");
163
163
  const stream = cacacheModule.getCacache().ls.stream(cacheDir);
164
164
  for await (const cacheEntry of stream) {
165
165
  if (!cacheEntry.key.startsWith(`${opts.prefix}:`)) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @file Public type surface for `ttl-cache/*` modules — the `TtlCache`
2
+ * @file Public type surface for `cache/ttl/*` modules — the `TtlCache`
3
3
  * interface (the seven-method API returned by `createTtlCache`), the
4
4
  * `TtlCacheEntry` storage shape, and the `TtlCacheOptions` / `ClearOptions`
5
5
  * configuration records. Pure types, no runtime side effects.
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @file GENERATED — do not edit by hand. Run `node
3
+ * scripts/fix/generate-primordials-defaults.mts` (also runs as part of `pnpm
4
+ * run build`) to regenerate from the `globals` npm package's globals.json
5
+ * crossed against src/primordials/*.ts `Ctor` exports. Source:
6
+ * globals@<bumped via taze>, env = builtin ∪ node. Filter: identifiers
7
+ * socket-lib exports as `<name>Ctor`.
8
+ */
9
+ /**
10
+ * Fleet-canonical alias map: socket-lib mirrors standard JS + Node globals with
11
+ * a `Ctor` suffix. Downstream repos that destructure raw `primordials` use this
12
+ * map to resolve the source-side name to socket-lib's export.
13
+ */
14
+ export declare const DEFAULT_ALIAS_MAP: Readonly<Record<string, string>>;
15
+ /**
16
+ * Names that exist in Node's internal `primordials` but are intentionally NOT
17
+ * mirrored to socket-lib (mostly Safe* wrappers and prototype-method aliases).
18
+ * Adding to this set is a per-name decision; the list is hand-maintained.
19
+ */
20
+ export declare const DEFAULT_NODE_INTERNAL_ONLY: readonly string[];
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with esbuild */
3
+ "use strict";
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var primordials_defaults_exports = {};
22
+ __export(primordials_defaults_exports, {
23
+ DEFAULT_ALIAS_MAP: () => DEFAULT_ALIAS_MAP,
24
+ DEFAULT_NODE_INTERNAL_ONLY: () => DEFAULT_NODE_INTERNAL_ONLY
25
+ });
26
+ module.exports = __toCommonJS(primordials_defaults_exports);
27
+ var import_object = require("../primordials/object");
28
+ const DEFAULT_ALIAS_MAP = (0, import_object.ObjectFreeze)(
29
+ {
30
+ __proto__: null,
31
+ AggregateError: "AggregateErrorCtor",
32
+ Array: "ArrayCtor",
33
+ ArrayBuffer: "ArrayBufferCtor",
34
+ BigInt: "BigIntCtor",
35
+ Boolean: "BooleanCtor",
36
+ Buffer: "BufferCtor",
37
+ DataView: "DataViewCtor",
38
+ Date: "DateCtor",
39
+ Error: "ErrorCtor",
40
+ EvalError: "EvalErrorCtor",
41
+ Float32Array: "Float32ArrayCtor",
42
+ Float64Array: "Float64ArrayCtor",
43
+ Int16Array: "Int16ArrayCtor",
44
+ Int32Array: "Int32ArrayCtor",
45
+ Int8Array: "Int8ArrayCtor",
46
+ Map: "MapCtor",
47
+ Number: "NumberCtor",
48
+ Object: "ObjectCtor",
49
+ Promise: "PromiseCtor",
50
+ Proxy: "ProxyCtor",
51
+ RangeError: "RangeErrorCtor",
52
+ ReferenceError: "ReferenceErrorCtor",
53
+ RegExp: "RegExpCtor",
54
+ Set: "SetCtor",
55
+ SharedArrayBuffer: "SharedArrayBufferCtor",
56
+ String: "StringCtor",
57
+ Symbol: "SymbolCtor",
58
+ SyntaxError: "SyntaxErrorCtor",
59
+ TypeError: "TypeErrorCtor",
60
+ URIError: "URIErrorCtor",
61
+ URL: "URLCtor",
62
+ URLSearchParams: "URLSearchParamsCtor",
63
+ Uint16Array: "Uint16ArrayCtor",
64
+ Uint32Array: "Uint32ArrayCtor",
65
+ Uint8Array: "Uint8ArrayCtor",
66
+ Uint8ClampedArray: "Uint8ClampedArrayCtor",
67
+ WeakMap: "WeakMapCtor",
68
+ WeakRef: "WeakRefCtor",
69
+ WeakSet: "WeakSetCtor",
70
+ atob: "GlobalAtob",
71
+ btoa: "GlobalBtoa",
72
+ decodeURIComponent: "GlobalDecodeURIComponent",
73
+ encodeURIComponent: "GlobalEncodeURIComponent",
74
+ globalThis: "GlobalThis"
75
+ }
76
+ );
77
+ const DEFAULT_NODE_INTERNAL_ONLY = (0, import_object.ObjectFreeze)([
78
+ "DataViewPrototypeGetInt32",
79
+ "DataViewPrototypeGetUint32",
80
+ "SafeMap",
81
+ "SafePromise",
82
+ "SafePromiseAllReturnVoid",
83
+ "SafePromiseAllSettled",
84
+ "SafeSet",
85
+ "SafeWeakMap",
86
+ "SafeWeakSet"
87
+ ]);
88
+ // Annotate the CommonJS export names for ESM import in node:
89
+ 0 && (module.exports = {
90
+ DEFAULT_ALIAS_MAP,
91
+ DEFAULT_NODE_INTERNAL_ONLY
92
+ });