@jev-kit/cli 0.1.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 +16 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +130 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 keiffff
|
|
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,16 @@
|
|
|
1
|
+
# @jev-kit/cli
|
|
2
|
+
|
|
3
|
+
Run Jev agent review from hooks, shell scripts, Python or any process that can exchange JSON over stdin/stdout.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
jev-agent-review --adapter normalized --config ./policy.json < request.json
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Hook adapters:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
jev-agent-review --adapter codex-permission --config ./policy.json
|
|
13
|
+
jev-agent-review --adapter claude-permission --config ./policy.json
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The API key is read by the official TypeSafe SDK from `TYPESAFE_API_KEY`. Do not place credentials in the policy file. Hook adapters print native allow JSON only after the configured policy passes; a deferred decision produces no hook output.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname } from "node:path";
|
|
4
|
+
import { definePermissionReviewPolicy, reviewAgentAction, unavailableReviewResult, validateAgentReviewRequest, } from "@jev-kit/agent-review";
|
|
5
|
+
import { JevClient } from "@jev-kit/decision-contract";
|
|
6
|
+
import { fromClaudeCodePermissionRequest, fromCodexPermissionRequest, renderPermissionHookResult, } from "@jev-kit/hook-adapters";
|
|
7
|
+
import { parseCliConfig } from "./index.js";
|
|
8
|
+
async function main() {
|
|
9
|
+
const args = parseArguments(process.argv.slice(2));
|
|
10
|
+
const config = parseCliConfig(JSON.parse(await readFile(args.configPath, "utf8")));
|
|
11
|
+
const policy = definePermissionReviewPolicy(config.policy);
|
|
12
|
+
const inputText = await readStdin();
|
|
13
|
+
if (inputText.trim() === "")
|
|
14
|
+
throw new TypeError("stdin must contain one JSON document");
|
|
15
|
+
const rawInput = JSON.parse(inputText);
|
|
16
|
+
const request = await normalizeRequest(args.adapter, rawInput, config);
|
|
17
|
+
let result;
|
|
18
|
+
try {
|
|
19
|
+
const client = new JevClient({ ...(config.model === undefined ? {} : { defaultModel: config.model }) });
|
|
20
|
+
result = await reviewAgentAction({ client, policy, request });
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
if (error instanceof TypeError)
|
|
24
|
+
throw error;
|
|
25
|
+
result = unavailableReviewResult(policy, error instanceof Error ? error.name : "unknown");
|
|
26
|
+
}
|
|
27
|
+
if (args.statusFile !== undefined) {
|
|
28
|
+
try {
|
|
29
|
+
await recordStatus(args.statusFile, request.action.tool, result);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Observability must not change an already-computed permission decision.
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (args.adapter === "normalized") {
|
|
36
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const hookOutput = renderPermissionHookResult(result);
|
|
40
|
+
if (hookOutput !== undefined)
|
|
41
|
+
process.stdout.write(`${JSON.stringify(hookOutput)}\n`);
|
|
42
|
+
}
|
|
43
|
+
async function normalizeRequest(adapter, input, config) {
|
|
44
|
+
if (adapter === "normalized") {
|
|
45
|
+
validateAgentReviewRequest(input);
|
|
46
|
+
return input;
|
|
47
|
+
}
|
|
48
|
+
const options = {
|
|
49
|
+
standingPolicy: config.standingPolicy,
|
|
50
|
+
...(config.userMessageCount === undefined ? {} : { userMessageCount: config.userMessageCount }),
|
|
51
|
+
};
|
|
52
|
+
return adapter === "codex-permission"
|
|
53
|
+
? fromCodexPermissionRequest(input, options)
|
|
54
|
+
: fromClaudeCodePermissionRequest(input, options);
|
|
55
|
+
}
|
|
56
|
+
function parseArguments(argv) {
|
|
57
|
+
let adapter;
|
|
58
|
+
let configPath;
|
|
59
|
+
let statusFile;
|
|
60
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
61
|
+
const flag = argv[index];
|
|
62
|
+
const value = argv[index + 1];
|
|
63
|
+
if ((flag === "--adapter" || flag === "--config" || flag === "--status-file") && value === undefined) {
|
|
64
|
+
throw new TypeError(`${flag} requires a value`);
|
|
65
|
+
}
|
|
66
|
+
if (flag === "--adapter") {
|
|
67
|
+
if (value !== "normalized" && value !== "codex-permission" && value !== "claude-permission") {
|
|
68
|
+
throw new TypeError(`unsupported adapter: ${value}`);
|
|
69
|
+
}
|
|
70
|
+
adapter = value;
|
|
71
|
+
index += 1;
|
|
72
|
+
}
|
|
73
|
+
else if (flag === "--config") {
|
|
74
|
+
configPath = value;
|
|
75
|
+
index += 1;
|
|
76
|
+
}
|
|
77
|
+
else if (flag === "--status-file") {
|
|
78
|
+
statusFile = value;
|
|
79
|
+
index += 1;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
throw new TypeError(`unknown argument: ${flag}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (adapter === undefined)
|
|
86
|
+
throw new TypeError("--adapter is required");
|
|
87
|
+
if (configPath === undefined)
|
|
88
|
+
throw new TypeError("--config is required");
|
|
89
|
+
return { adapter, configPath, ...(statusFile === undefined ? {} : { statusFile }) };
|
|
90
|
+
}
|
|
91
|
+
async function readStdin() {
|
|
92
|
+
const chunks = [];
|
|
93
|
+
for await (const chunk of process.stdin)
|
|
94
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
95
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
96
|
+
}
|
|
97
|
+
async function recordStatus(path, tool, result) {
|
|
98
|
+
let current = {};
|
|
99
|
+
try {
|
|
100
|
+
const parsed = JSON.parse(await readFile(path, "utf8"));
|
|
101
|
+
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed))
|
|
102
|
+
current = parsed;
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
// A missing or unreadable status file starts a new aggregate; it does not affect the decision.
|
|
106
|
+
}
|
|
107
|
+
const previousCounts = typeof current.counts === "object" && current.counts !== null && !Array.isArray(current.counts)
|
|
108
|
+
? current.counts : {};
|
|
109
|
+
const previousCount = previousCounts[result.reason];
|
|
110
|
+
const count = typeof previousCount === "number" && Number.isSafeInteger(previousCount) && previousCount >= 0
|
|
111
|
+
? previousCount : 0;
|
|
112
|
+
const status = {
|
|
113
|
+
schemaVersion: 1,
|
|
114
|
+
counts: { ...previousCounts, [result.reason]: count + 1 },
|
|
115
|
+
last: {
|
|
116
|
+
at: new Date().toISOString(), tool, outcome: result.outcome, reason: result.reason,
|
|
117
|
+
contract: result.contract, scores: result.scores ?? {},
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
await mkdir(dirname(path), { recursive: true });
|
|
121
|
+
const temporary = `${path}.${process.pid}.tmp`;
|
|
122
|
+
await writeFile(temporary, JSON.stringify(status));
|
|
123
|
+
await rename(temporary, path);
|
|
124
|
+
}
|
|
125
|
+
main().catch((error) => {
|
|
126
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
127
|
+
process.stderr.write(`jev-agent-review: ${message}\n`);
|
|
128
|
+
process.exitCode = 2;
|
|
129
|
+
});
|
|
130
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,4BAA4B,EAC5B,iBAAiB,EACjB,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EACL,+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CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,OAAO,IAAI,CAAC,CAAC;IACvD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface AgentReviewCliConfig {
|
|
2
|
+
readonly schemaVersion: 1;
|
|
3
|
+
readonly policy: {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly version: string;
|
|
6
|
+
readonly thresholds: {
|
|
7
|
+
readonly policyCompliant: number;
|
|
8
|
+
readonly instructionAligned: number;
|
|
9
|
+
readonly highRisk: number;
|
|
10
|
+
};
|
|
11
|
+
readonly questions?: {
|
|
12
|
+
readonly policyCompliant?: string;
|
|
13
|
+
readonly instructionAligned?: string;
|
|
14
|
+
readonly highRisk?: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
readonly standingPolicy: string;
|
|
18
|
+
readonly userMessageCount?: number;
|
|
19
|
+
readonly model?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function parseCliConfig(value: unknown): AgentReviewCliConfig;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,UAAU,EAAE;YACnB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;YACjC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;YACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;SAC3B,CAAC;QACF,QAAQ,CAAC,SAAS,CAAC,EAAE;YACnB,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;YAClC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;YACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;SAC5B,CAAC;KACH,CAAC;IACF,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,CAiBnE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export function parseCliConfig(value) {
|
|
2
|
+
const config = record(value, "config");
|
|
3
|
+
if (config.schemaVersion !== 1)
|
|
4
|
+
throw new TypeError("config.schemaVersion must equal 1");
|
|
5
|
+
const policy = record(config.policy, "config.policy");
|
|
6
|
+
nonempty(policy.id, "config.policy.id");
|
|
7
|
+
nonempty(policy.version, "config.policy.version");
|
|
8
|
+
const thresholds = record(policy.thresholds, "config.policy.thresholds");
|
|
9
|
+
for (const name of ["policyCompliant", "instructionAligned", "highRisk"]) {
|
|
10
|
+
probability(thresholds[name], `config.policy.thresholds.${name}`);
|
|
11
|
+
}
|
|
12
|
+
nonempty(config.standingPolicy, "config.standingPolicy");
|
|
13
|
+
if (config.userMessageCount !== undefined
|
|
14
|
+
&& (!Number.isInteger(config.userMessageCount) || config.userMessageCount < 1)) {
|
|
15
|
+
throw new TypeError("config.userMessageCount must be a positive integer");
|
|
16
|
+
}
|
|
17
|
+
if (config.model !== undefined)
|
|
18
|
+
nonempty(config.model, "config.model");
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
function record(value, path) {
|
|
22
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
23
|
+
throw new TypeError(`${path} must be an object`);
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
function nonempty(value, path) {
|
|
27
|
+
if (typeof value !== "string" || value.trim() === "")
|
|
28
|
+
throw new TypeError(`${path} must be a nonempty string`);
|
|
29
|
+
}
|
|
30
|
+
function probability(value, path) {
|
|
31
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > 1) {
|
|
32
|
+
throw new TypeError(`${path} must be a finite number from 0 to 1`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqBA,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACvC,IAAI,MAAM,CAAC,aAAa,KAAK,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,mCAAmC,CAAC,CAAC;IACzF,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACtD,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,kBAAkB,CAAC,CAAC;IACxC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,uBAAuB,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC,CAAC;IACzE,KAAK,MAAM,IAAI,IAAI,CAAC,iBAAiB,EAAE,oBAAoB,EAAE,UAAU,CAAU,EAAE,CAAC;QAClF,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,4BAA4B,IAAI,EAAE,CAAC,CAAC;IACpE,CAAC;IACD,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,uBAAuB,CAAC,CAAC;IACzD,IAAI,MAAM,CAAC,gBAAgB,KAAK,SAAS;WACpC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAK,MAAM,CAAC,gBAA2B,GAAG,CAAC,CAAC,EAAE,CAAC;QAC7F,MAAM,IAAI,SAAS,CAAC,oDAAoD,CAAC,CAAC;IAC5E,CAAC;IACD,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS;QAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;IACvE,OAAO,KAA6B,CAAC;AACvC,CAAC;AAED,SAAS,MAAM,CAAC,KAAc,EAAE,IAAY;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,oBAAoB,CAAC,CAAC;IAC1H,OAAO,KAAgC,CAAC;AAC1C,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc,EAAE,IAAY;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,4BAA4B,CAAC,CAAC;AACjH,CAAC;AAED,SAAS,WAAW,CAAC,KAAc,EAAE,IAAY;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACnF,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,sCAAsC,CAAC,CAAC;IACrE,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jev-kit/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Run Jev Kit agent review over JSON stdin for hooks, scripts and non-TypeScript agents.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/keiffff/jev-kit.git",
|
|
10
|
+
"directory": "packages/cli"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/keiffff/jev-kit#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/keiffff/jev-kit/issues"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=22.6"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public",
|
|
21
|
+
"registry": "https://registry.npmjs.org/"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist/**/*.js",
|
|
25
|
+
"dist/**/*.d.ts",
|
|
26
|
+
"dist/**/*.map"
|
|
27
|
+
],
|
|
28
|
+
"bin": {
|
|
29
|
+
"jev-agent-review": "./dist/cli.js"
|
|
30
|
+
},
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/index.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@jev-kit/agent-review": "0.1.0",
|
|
39
|
+
"@jev-kit/hook-adapters": "0.1.0",
|
|
40
|
+
"@jev-kit/decision-contract": "0.1.0"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc -b"
|
|
44
|
+
}
|
|
45
|
+
}
|