agenteval-cli 0.8.1 → 0.8.3
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/bin/agenteval.js +113 -0
- package/package.json +3 -8
- package/bin/agenteval +0 -38
package/bin/agenteval.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execFileSync, execSync } = require("child_process");
|
|
4
|
+
const { existsSync, mkdirSync, chmodSync, renameSync, unlinkSync } = require("fs");
|
|
5
|
+
const { join } = require("path");
|
|
6
|
+
const https = require("https");
|
|
7
|
+
|
|
8
|
+
const REPO = "lukasmetzler/agenteval";
|
|
9
|
+
const CACHE_DIR = join(require("os").homedir(), ".agenteval", "bin");
|
|
10
|
+
const BIN_PATH = join(CACHE_DIR, "agenteval");
|
|
11
|
+
const VERSION_PATH = join(CACHE_DIR, ".version");
|
|
12
|
+
|
|
13
|
+
function getPlatformKey() {
|
|
14
|
+
const platform = process.platform;
|
|
15
|
+
const arch = process.arch;
|
|
16
|
+
if (platform === "darwin" && arch === "arm64") return "agenteval-darwin-arm64";
|
|
17
|
+
if (platform === "darwin" && arch === "x64") return "agenteval-darwin-x64";
|
|
18
|
+
if (platform === "linux" && arch === "x64") return "agenteval-linux-x64";
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getPackageVersion() {
|
|
23
|
+
try {
|
|
24
|
+
return require("../package.json").version;
|
|
25
|
+
} catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getCachedVersion() {
|
|
31
|
+
try {
|
|
32
|
+
return require("fs").readFileSync(VERSION_PATH, "utf8").trim();
|
|
33
|
+
} catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function download(url) {
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
https.get(url, (res) => {
|
|
41
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
42
|
+
return download(res.headers.location).then(resolve, reject);
|
|
43
|
+
}
|
|
44
|
+
if (res.statusCode !== 200) {
|
|
45
|
+
reject(new Error(`HTTP ${res.statusCode}`));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const chunks = [];
|
|
49
|
+
res.on("data", (chunk) => chunks.push(chunk));
|
|
50
|
+
res.on("end", () => resolve(Buffer.concat(chunks)));
|
|
51
|
+
res.on("error", reject);
|
|
52
|
+
}).on("error", reject);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function ensureBinary() {
|
|
57
|
+
const pkgVersion = getPackageVersion();
|
|
58
|
+
const cachedVersion = getCachedVersion();
|
|
59
|
+
|
|
60
|
+
// Binary exists and matches current package version
|
|
61
|
+
if (existsSync(BIN_PATH) && cachedVersion === pkgVersion) {
|
|
62
|
+
return BIN_PATH;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const binary = getPlatformKey();
|
|
66
|
+
if (!binary) {
|
|
67
|
+
console.error(`agenteval: unsupported platform ${process.platform}-${process.arch}`);
|
|
68
|
+
console.error("Supported: linux-x64, darwin-arm64, darwin-x64");
|
|
69
|
+
console.error("Install manually: https://github.com/lukasmetzler/agenteval/releases");
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const version = pkgVersion ? `v${pkgVersion}` : "latest";
|
|
74
|
+
const url = `https://github.com/${REPO}/releases/download/${version}/${binary}`;
|
|
75
|
+
|
|
76
|
+
console.error(`Downloading agenteval ${version} (${binary})...`);
|
|
77
|
+
|
|
78
|
+
mkdirSync(CACHE_DIR, { recursive: true });
|
|
79
|
+
|
|
80
|
+
const tmpPath = `${BIN_PATH}.tmp.${Date.now()}`;
|
|
81
|
+
try {
|
|
82
|
+
const data = await download(url);
|
|
83
|
+
require("fs").writeFileSync(tmpPath, data);
|
|
84
|
+
chmodSync(tmpPath, 0o755);
|
|
85
|
+
|
|
86
|
+
// Atomic replace
|
|
87
|
+
if (existsSync(BIN_PATH)) {
|
|
88
|
+
try { unlinkSync(BIN_PATH); } catch {}
|
|
89
|
+
}
|
|
90
|
+
renameSync(tmpPath, BIN_PATH);
|
|
91
|
+
require("fs").writeFileSync(VERSION_PATH, pkgVersion || version);
|
|
92
|
+
|
|
93
|
+
console.error("Done.");
|
|
94
|
+
} catch (err) {
|
|
95
|
+
try { unlinkSync(tmpPath); } catch {}
|
|
96
|
+
console.error(`agenteval: download failed (${err.message})`);
|
|
97
|
+
console.error(`Install manually: https://github.com/${REPO}/releases`);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return BIN_PATH;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
ensureBinary().then((binPath) => {
|
|
105
|
+
try {
|
|
106
|
+
const result = execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" });
|
|
107
|
+
} catch (err) {
|
|
108
|
+
process.exit(err && typeof err === "object" && "status" in err ? err.status : 1);
|
|
109
|
+
}
|
|
110
|
+
}).catch((err) => {
|
|
111
|
+
console.error(`agenteval: ${err.message}`);
|
|
112
|
+
process.exit(1);
|
|
113
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agenteval-cli",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Lint, benchmark, and CI gate for AI coding instructions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -30,15 +30,10 @@
|
|
|
30
30
|
"node": ">=18"
|
|
31
31
|
},
|
|
32
32
|
"bin": {
|
|
33
|
-
"agenteval": "bin/agenteval"
|
|
33
|
+
"agenteval": "bin/agenteval.js"
|
|
34
34
|
},
|
|
35
35
|
"files": [
|
|
36
36
|
"bin/",
|
|
37
37
|
"README.md"
|
|
38
|
-
]
|
|
39
|
-
"optionalDependencies": {
|
|
40
|
-
"@agenteval/linux-x64": "0.8.1",
|
|
41
|
-
"@agenteval/darwin-arm64": "0.8.1",
|
|
42
|
-
"@agenteval/darwin-x64": "0.8.1"
|
|
43
|
-
}
|
|
38
|
+
]
|
|
44
39
|
}
|
package/bin/agenteval
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { execFileSync } = require("child_process");
|
|
4
|
-
const { join } = require("path");
|
|
5
|
-
|
|
6
|
-
const PLATFORMS = {
|
|
7
|
-
"linux-x64": "@agenteval/linux-x64",
|
|
8
|
-
"darwin-arm64": "@agenteval/darwin-arm64",
|
|
9
|
-
"darwin-x64": "@agenteval/darwin-x64",
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const key = `${process.platform === "win32" ? "win32" : process.platform}-${process.arch}`;
|
|
13
|
-
const pkg = PLATFORMS[key];
|
|
14
|
-
|
|
15
|
-
if (!pkg) {
|
|
16
|
-
console.error(`agenteval: unsupported platform ${process.platform}-${process.arch}`);
|
|
17
|
-
console.error("Supported: linux-x64, darwin-arm64, darwin-x64");
|
|
18
|
-
console.error("Install manually: https://github.com/lukasmetzler/agenteval/releases");
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let binPath;
|
|
23
|
-
try {
|
|
24
|
-
binPath = join(require.resolve(`${pkg}/package.json`), "..", "bin", "agenteval");
|
|
25
|
-
} catch {
|
|
26
|
-
console.error(`agenteval: platform package ${pkg} not installed.`);
|
|
27
|
-
console.error("Try reinstalling: npm install -g agenteval-cli");
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" });
|
|
33
|
-
} catch (err) {
|
|
34
|
-
if (err && typeof err === "object" && "status" in err) {
|
|
35
|
-
process.exit(err.status);
|
|
36
|
-
}
|
|
37
|
-
process.exit(1);
|
|
38
|
-
}
|