@journeykit/atip-check 0.0.0-stage → 0.3.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.
- package/README.md +21 -2
- package/bin.js +58 -0
- package/package.json +39 -4
package/README.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @journeykit/atip-check
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`atip check`: the conformance checker of [ATIP](https://github.com/journeyWorker/atip) (`atip/1`), the Agent Terminal
|
|
4
|
+
Invocation Protocol. It runs a built binary and checks the contract from outside: argv in; stdout, stderr, exit status
|
|
5
|
+
and file-system changes out. What it reports is evidence for or against a conformance claim, never the definition of
|
|
6
|
+
one.
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
bunx @journeykit/atip-check check --bin target/release/<tool> --fixture atip.fixture.json --level L2
|
|
10
|
+
bun add -g @journeykit/atip-check # or npm install -g; then: atip check ...
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The package's command is `atip`. It installs a prebuilt binary for macOS arm64, Linux x64 or Linux arm64 as an
|
|
14
|
+
optional dependency, and `atip` runs it with your arguments and exit status. The Linux binaries are static (musl):
|
|
15
|
+
no glibc requirement, any distribution. On another unix, build it from source with `cargo install atip-check`. Its
|
|
16
|
+
version is the version of the Rust crate
|
|
17
|
+
[`atip-check`](https://crates.io/crates/atip-check).
|
|
18
|
+
|
|
19
|
+
The checks, their strengths and the fixture format are in
|
|
20
|
+
[`approaches/checker.md`](https://github.com/journeyWorker/atip/blob/main/approaches/checker.md).
|
|
21
|
+
|
|
22
|
+
MIT.
|
package/bin.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// `@journeykit/atip-check`: runs the `atip` binary of the platform package installed next to it (an optional dependency,
|
|
3
|
+
// one per platform), with this process's arguments and stdio, and ends with the binary's exit status, or as close to
|
|
4
|
+
// its signal as Node allows. The checker's own output, exit statuses and refusals are the binary's; this file only
|
|
5
|
+
// finds it.
|
|
6
|
+
import { spawnSync } from "node:child_process";
|
|
7
|
+
import { existsSync } from "node:fs";
|
|
8
|
+
import { createRequire } from "node:module";
|
|
9
|
+
import { constants } from "node:os";
|
|
10
|
+
import { dirname, join } from "node:path";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
12
|
+
|
|
13
|
+
const SCOPE = "@journeykit/";
|
|
14
|
+
// `${process.platform}-${process.arch}` → the package that carries the binary for it (npm/atip-check-<platform>/).
|
|
15
|
+
const PLATFORMS = {
|
|
16
|
+
"darwin-arm64": `${SCOPE}atip-check-darwin-arm64`,
|
|
17
|
+
"linux-x64": `${SCOPE}atip-check-linux-x64`,
|
|
18
|
+
"linux-arm64": `${SCOPE}atip-check-linux-arm64`,
|
|
19
|
+
};
|
|
20
|
+
const FROM_SOURCE = "build it from source with `cargo install atip-check`";
|
|
21
|
+
|
|
22
|
+
function fail(message) {
|
|
23
|
+
process.stderr.write(`atip (npm launcher): ${message}\n`);
|
|
24
|
+
process.exit(2);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// The installed platform package, else its sibling directory in the repository's npm/ (a checkout, or CI before
|
|
28
|
+
// publishing), where each package directory is the package name without the scope.
|
|
29
|
+
function binaryPath(pkg) {
|
|
30
|
+
try {
|
|
31
|
+
const manifest = createRequire(import.meta.url).resolve(`${pkg}/package.json`);
|
|
32
|
+
return join(dirname(manifest), "bin", "atip");
|
|
33
|
+
} catch {
|
|
34
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
35
|
+
return join(here, "..", pkg.slice(SCOPE.length), "bin", "atip");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const platform = `${process.platform}-${process.arch}`;
|
|
40
|
+
const pkg = PLATFORMS[platform];
|
|
41
|
+
if (pkg === undefined) {
|
|
42
|
+
fail(`no prebuilt binary for ${platform} (there are ${Object.keys(PLATFORMS).join(", ")}); on another unix, ${FROM_SOURCE}`);
|
|
43
|
+
}
|
|
44
|
+
const bin = binaryPath(pkg);
|
|
45
|
+
if (!existsSync(bin)) {
|
|
46
|
+
fail(`${pkg} is not installed, so there is no ${bin}; install again without omitting optional dependencies, or ${FROM_SOURCE}`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const run = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
50
|
+
if (run.error) {
|
|
51
|
+
fail(`could not run ${bin}: ${run.error.message}; ${FROM_SOURCE}`);
|
|
52
|
+
}
|
|
53
|
+
if (run.signal !== null) {
|
|
54
|
+
// End by the same signal. Node ignores some (SIGPIPE), so fall back to the shell's status for a signal.
|
|
55
|
+
process.kill(process.pid, run.signal);
|
|
56
|
+
process.exit(128 + (constants.signals[run.signal] ?? 0));
|
|
57
|
+
}
|
|
58
|
+
process.exit(run.status ?? 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@journeykit/atip-check",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.3.2",
|
|
4
|
+
"description": "atip check: the conformance checker of ATIP (atip/1), the Agent Terminal Invocation Protocol. It runs a built binary and checks the contract from outside.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"atip",
|
|
7
|
+
"cli",
|
|
8
|
+
"conformance",
|
|
9
|
+
"checker",
|
|
10
|
+
"agent"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"homepage": "https://github.com/journeyWorker/atip",
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/journeyWorker/atip.git",
|
|
20
|
+
"directory": "npm/atip-check"
|
|
21
|
+
},
|
|
22
|
+
"type": "module",
|
|
23
|
+
"bin": {
|
|
24
|
+
"atip": "bin.js"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"bin.js"
|
|
28
|
+
],
|
|
29
|
+
"os": [
|
|
30
|
+
"darwin",
|
|
31
|
+
"linux"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=18"
|
|
35
|
+
},
|
|
36
|
+
"optionalDependencies": {
|
|
37
|
+
"@journeykit/atip-check-darwin-arm64": "0.3.2",
|
|
38
|
+
"@journeykit/atip-check-linux-x64": "0.3.2",
|
|
39
|
+
"@journeykit/atip-check-linux-arm64": "0.3.2"
|
|
40
|
+
}
|
|
41
|
+
}
|