@vitest-agent/sidecar 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +32 -0
- package/index.d.ts +47 -0
- package/index.js +3 -0
- package/package.json +45 -0
- package/resolve-sidecar-binary-path.js +57 -0
- package/tsdoc-metadata.json +11 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 C. Spencer Beggs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @vitest-agent/sidecar
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@vitest-agent/sidecar)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
|
|
7
|
+
> **Part of the [vitest-agent](https://vitest-agent.dev) ecosystem.** Most users want **[@vitest-agent/plugin](https://www.npmjs.com/package/@vitest-agent/plugin)**, which pulls this package in automatically (it installs automatically with the CLI; you rarely add it directly).
|
|
8
|
+
|
|
9
|
+
A Node Single Executable Application (SEA) binary for the per-Bash-call `inject-env` hot path. Every Bash tool call from a Claude Code agent fires the plugin's `pre-tool-use/bash.sh` hook, which detects Vitest invocations and prepends the canonical `VITEST_AGENT_*` env prefix. Running that through the full `vitest-agent` CLI pays Node cold-start latency on every call; this binary runs the same logic with a fraction of the startup cost.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Native binary** — Node SEA wrapping the same `inject-env` TypeScript that ships in `@vitest-agent/cli`; JS fallback and binary stay byte-identical
|
|
14
|
+
- **Per-platform sub-packages** — `@vitest-agent/sidecar-darwin-arm64`, `@vitest-agent/sidecar-linux-arm64`, `@vitest-agent/sidecar-linux-x64`, `@vitest-agent/sidecar-win32-x64` as `optionalDependencies`; only the matching one installs
|
|
15
|
+
- **`resolveSidecarBinaryPath()`** — exported function that returns the absolute path of the installed binary, or `null` on unsupported platforms
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install --save-dev @vitest-agent/plugin
|
|
21
|
+
# @vitest-agent/sidecar arrives transitively through @vitest-agent/cli
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The plugin's SessionStart hook resolves the binary path once per session via `vitest-agent agent sidecar-path` and exports `VITEST_AGENT_SIDECAR_BIN`. The PreToolUse Bash hook reads that env var and execs the binary directly — no PATH lookup, no Node startup. On unsupported platforms the hook falls back to the `vitest-agent` JS CLI automatically.
|
|
25
|
+
|
|
26
|
+
## Documentation
|
|
27
|
+
|
|
28
|
+
Package reference at [vitest-agent.dev/sidecar](https://vitest-agent.dev/sidecar).
|
|
29
|
+
|
|
30
|
+
## License
|
|
31
|
+
|
|
32
|
+
[MIT](LICENSE)
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/resolve-sidecar-binary-path.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* \@vitest-agent/sidecar
|
|
4
|
+
*
|
|
5
|
+
* Resolves the absolute path of the platform-specific sidecar binary
|
|
6
|
+
* by using `require.resolve` on the optional platform package's bin entry.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Platform and architecture resolver options for dependency injection in tests.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
interface ResolveSidecarBinaryPathOptions {
|
|
16
|
+
/** Override the platform (defaults to `process.platform`). */
|
|
17
|
+
readonly platform?: NodeJS.Platform;
|
|
18
|
+
/** Override the architecture (defaults to `process.arch`). */
|
|
19
|
+
readonly arch?: string;
|
|
20
|
+
/** Override the module resolver (defaults to `createRequire`-backed resolver). */
|
|
21
|
+
readonly resolver?: (path: string) => string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Resolve the absolute path of the platform-specific sidecar binary.
|
|
25
|
+
*
|
|
26
|
+
* The four platform packages that ship SEA binaries are:
|
|
27
|
+
* - `@vitest-agent/sidecar-darwin-arm64` → `bin/vitest-agent-sidecar`
|
|
28
|
+
* - `@vitest-agent/sidecar-linux-arm64` → `bin/vitest-agent-sidecar`
|
|
29
|
+
* - `@vitest-agent/sidecar-linux-x64` → `bin/vitest-agent-sidecar`
|
|
30
|
+
* - `@vitest-agent/sidecar-win32-x64` → `bin/vitest-agent-sidecar.exe`
|
|
31
|
+
*
|
|
32
|
+
* The binary path is resolved via `require.resolve` of the platform package's
|
|
33
|
+
* bin entry (not discovered on PATH), so transitive optional dependencies that
|
|
34
|
+
* are never hoisted to `node_modules/.bin/` are still found correctly.
|
|
35
|
+
*
|
|
36
|
+
* Returns `null` when:
|
|
37
|
+
* - The platform/arch combination has no matching package (e.g. darwin-x64).
|
|
38
|
+
* - The matching optional dependency was not installed (MODULE_NOT_FOUND).
|
|
39
|
+
*
|
|
40
|
+
* @param options - Optional overrides for platform, arch, and resolver (for testing).
|
|
41
|
+
* @returns The absolute path to the binary, or `null` when not resolvable.
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
declare function resolveSidecarBinaryPath(options?: ResolveSidecarBinaryPathOptions): string | null;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { type ResolveSidecarBinaryPathOptions, resolveSidecarBinaryPath };
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vitest-agent/sidecar",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Fast-path native binary for vitest-agent. Ships a Node SEA executable that handles the per-Bash-call inject-env hot path.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"vitest",
|
|
8
|
+
"agent",
|
|
9
|
+
"sidecar",
|
|
10
|
+
"sea",
|
|
11
|
+
"binary"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/spencerbeggs/vitest-agent#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/spencerbeggs/vitest-agent/issues"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/spencerbeggs/vitest-agent.git",
|
|
20
|
+
"directory": "packages/sidecar"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": {
|
|
24
|
+
"name": "C. Spencer Beggs",
|
|
25
|
+
"email": "spencer@beggs.codes",
|
|
26
|
+
"url": "https://spencerbeg.gs"
|
|
27
|
+
},
|
|
28
|
+
"type": "module",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./index.d.ts",
|
|
32
|
+
"import": "./index.js"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"optionalDependencies": {
|
|
37
|
+
"@vitest-agent/sidecar-darwin-arm64": "1.0.0",
|
|
38
|
+
"@vitest-agent/sidecar-linux-arm64": "1.0.0",
|
|
39
|
+
"@vitest-agent/sidecar-linux-x64": "1.0.0",
|
|
40
|
+
"@vitest-agent/sidecar-win32-x64": "1.0.0"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=24.11.0"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
//#region src/resolve-sidecar-binary-path.ts
|
|
4
|
+
/**
|
|
5
|
+
* \@vitest-agent/sidecar
|
|
6
|
+
*
|
|
7
|
+
* Resolves the absolute path of the platform-specific sidecar binary
|
|
8
|
+
* by using `require.resolve` on the optional platform package's bin entry.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* The four platform/arch combinations that have a matching sidecar package.
|
|
14
|
+
* darwin-x64 is intentionally absent — there is no such package.
|
|
15
|
+
*/
|
|
16
|
+
const SUPPORTED_PLATFORMS = /* @__PURE__ */ new Map([
|
|
17
|
+
["darwin-arm64", "@vitest-agent/sidecar-darwin-arm64"],
|
|
18
|
+
["linux-arm64", "@vitest-agent/sidecar-linux-arm64"],
|
|
19
|
+
["linux-x64", "@vitest-agent/sidecar-linux-x64"],
|
|
20
|
+
["win32-x64", "@vitest-agent/sidecar-win32-x64"]
|
|
21
|
+
]);
|
|
22
|
+
/**
|
|
23
|
+
* Resolve the absolute path of the platform-specific sidecar binary.
|
|
24
|
+
*
|
|
25
|
+
* The four platform packages that ship SEA binaries are:
|
|
26
|
+
* - `@vitest-agent/sidecar-darwin-arm64` → `bin/vitest-agent-sidecar`
|
|
27
|
+
* - `@vitest-agent/sidecar-linux-arm64` → `bin/vitest-agent-sidecar`
|
|
28
|
+
* - `@vitest-agent/sidecar-linux-x64` → `bin/vitest-agent-sidecar`
|
|
29
|
+
* - `@vitest-agent/sidecar-win32-x64` → `bin/vitest-agent-sidecar.exe`
|
|
30
|
+
*
|
|
31
|
+
* The binary path is resolved via `require.resolve` of the platform package's
|
|
32
|
+
* bin entry (not discovered on PATH), so transitive optional dependencies that
|
|
33
|
+
* are never hoisted to `node_modules/.bin/` are still found correctly.
|
|
34
|
+
*
|
|
35
|
+
* Returns `null` when:
|
|
36
|
+
* - The platform/arch combination has no matching package (e.g. darwin-x64).
|
|
37
|
+
* - The matching optional dependency was not installed (MODULE_NOT_FOUND).
|
|
38
|
+
*
|
|
39
|
+
* @param options - Optional overrides for platform, arch, and resolver (for testing).
|
|
40
|
+
* @returns The absolute path to the binary, or `null` when not resolvable.
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
function resolveSidecarBinaryPath(options = {}) {
|
|
44
|
+
const key = `${options.platform ?? process.platform}-${options.arch ?? process.arch}`;
|
|
45
|
+
const packageName = SUPPORTED_PLATFORMS.get(key);
|
|
46
|
+
if (packageName === void 0) return null;
|
|
47
|
+
const resolve = options.resolver ?? createRequire(import.meta.url).resolve;
|
|
48
|
+
try {
|
|
49
|
+
return resolve(packageName);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
if (err.code === "MODULE_NOT_FOUND") return null;
|
|
52
|
+
throw err;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { resolveSidecarBinaryPath };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.58.9"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|