@drisp/cli 0.3.39
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 +284 -0
- package/dist/WorkflowInstallWizard-5JWVHIVJ.js +93 -0
- package/dist/athena-gateway.js +3998 -0
- package/dist/chunk-3FVULBV4.js +839 -0
- package/dist/chunk-LPG5WBPV.js +2621 -0
- package/dist/chunk-PSD3WBN4.js +150 -0
- package/dist/cli.js +29284 -0
- package/dist/hook-forwarder.js +142 -0
- package/package.json +118 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
ATHENA_HOOK_SOCKET_ENV,
|
|
4
|
+
generateId
|
|
5
|
+
} from "./chunk-PSD3WBN4.js";
|
|
6
|
+
|
|
7
|
+
// src/harnesses/claude/hook-forwarder.ts
|
|
8
|
+
import * as net from "net";
|
|
9
|
+
import * as path from "path";
|
|
10
|
+
var SOCKET_TIMEOUT_MS = 5e3;
|
|
11
|
+
var PERMISSION_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
12
|
+
function getSocketPath(cwd) {
|
|
13
|
+
const explicitSocketPath = process.env[ATHENA_HOOK_SOCKET_ENV];
|
|
14
|
+
if (explicitSocketPath) {
|
|
15
|
+
return explicitSocketPath;
|
|
16
|
+
}
|
|
17
|
+
const instanceId = process.env["ATHENA_INSTANCE_ID"];
|
|
18
|
+
const socketFilename = instanceId ? `ink-${instanceId}.sock` : "ink.sock";
|
|
19
|
+
return path.join(cwd, ".claude", "run", socketFilename);
|
|
20
|
+
}
|
|
21
|
+
async function readStdin() {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
let data = "";
|
|
24
|
+
process.stdin.setEncoding("utf8");
|
|
25
|
+
process.stdin.on("data", (chunk) => {
|
|
26
|
+
data += chunk;
|
|
27
|
+
});
|
|
28
|
+
process.stdin.on("end", () => {
|
|
29
|
+
resolve(data);
|
|
30
|
+
});
|
|
31
|
+
process.stdin.on("error", reject);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async function connectAndSend(socketPath, envelope, timeoutMs) {
|
|
35
|
+
return new Promise((resolve) => {
|
|
36
|
+
const socket = new net.Socket();
|
|
37
|
+
let responseData = "";
|
|
38
|
+
let resolved = false;
|
|
39
|
+
const cleanup = (error) => {
|
|
40
|
+
if (!resolved) {
|
|
41
|
+
resolved = true;
|
|
42
|
+
socket.destroy();
|
|
43
|
+
resolve({ envelope: null, error });
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const timeoutId = setTimeout(() => cleanup("TIMEOUT"), timeoutMs);
|
|
47
|
+
socket.on("connect", () => {
|
|
48
|
+
socket.write(JSON.stringify(envelope) + "\n");
|
|
49
|
+
});
|
|
50
|
+
socket.on("data", (chunk) => {
|
|
51
|
+
responseData += chunk.toString();
|
|
52
|
+
const lines = responseData.split("\n");
|
|
53
|
+
if (lines.length > 1 && lines[0]) {
|
|
54
|
+
clearTimeout(timeoutId);
|
|
55
|
+
resolved = true;
|
|
56
|
+
socket.destroy();
|
|
57
|
+
try {
|
|
58
|
+
const result = JSON.parse(lines[0]);
|
|
59
|
+
resolve({ envelope: result });
|
|
60
|
+
} catch {
|
|
61
|
+
resolve({ envelope: null, error: "UNKNOWN" });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
socket.on("error", (err) => {
|
|
66
|
+
clearTimeout(timeoutId);
|
|
67
|
+
if (err.code === "ENOENT") {
|
|
68
|
+
cleanup("ENOENT");
|
|
69
|
+
} else if (err.code === "ECONNREFUSED") {
|
|
70
|
+
cleanup("ECONNREFUSED");
|
|
71
|
+
} else {
|
|
72
|
+
cleanup("UNKNOWN");
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
socket.on("close", () => {
|
|
76
|
+
clearTimeout(timeoutId);
|
|
77
|
+
if (!resolved) {
|
|
78
|
+
resolved = true;
|
|
79
|
+
resolve({ envelope: null });
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
socket.connect(socketPath);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async function main() {
|
|
86
|
+
try {
|
|
87
|
+
const stdinData = await readStdin();
|
|
88
|
+
if (!stdinData.trim()) {
|
|
89
|
+
process.exit(0);
|
|
90
|
+
}
|
|
91
|
+
let hookInput;
|
|
92
|
+
try {
|
|
93
|
+
hookInput = JSON.parse(stdinData);
|
|
94
|
+
} catch {
|
|
95
|
+
process.exit(0);
|
|
96
|
+
}
|
|
97
|
+
const requestId = generateId();
|
|
98
|
+
const envelope = {
|
|
99
|
+
request_id: requestId,
|
|
100
|
+
ts: Date.now(),
|
|
101
|
+
session_id: hookInput.session_id,
|
|
102
|
+
hook_event_name: hookInput.hook_event_name,
|
|
103
|
+
payload: hookInput
|
|
104
|
+
};
|
|
105
|
+
const timeoutMs = hookInput.hook_event_name === "PreToolUse" || hookInput.hook_event_name === "PermissionRequest" ? PERMISSION_TIMEOUT_MS : SOCKET_TIMEOUT_MS;
|
|
106
|
+
const socketPath = getSocketPath(hookInput.cwd);
|
|
107
|
+
const { envelope: result, error } = await connectAndSend(
|
|
108
|
+
socketPath,
|
|
109
|
+
envelope,
|
|
110
|
+
timeoutMs
|
|
111
|
+
);
|
|
112
|
+
if (error === "ENOENT") {
|
|
113
|
+
process.stderr.write(
|
|
114
|
+
`[hook-forwarder] Ink CLI not running (socket not found: ${socketPath})
|
|
115
|
+
`
|
|
116
|
+
);
|
|
117
|
+
process.exit(0);
|
|
118
|
+
}
|
|
119
|
+
if (error === "ECONNREFUSED") {
|
|
120
|
+
process.stderr.write(
|
|
121
|
+
`[hook-forwarder] Ink CLI not responding (stale socket: ${socketPath})
|
|
122
|
+
`
|
|
123
|
+
);
|
|
124
|
+
process.exit(0);
|
|
125
|
+
}
|
|
126
|
+
if (!result || result.payload.action === "passthrough") {
|
|
127
|
+
process.exit(0);
|
|
128
|
+
}
|
|
129
|
+
if (result.payload.action === "block_with_stderr") {
|
|
130
|
+
process.stderr.write(result.payload.stderr ?? "Blocked by Ink CLI");
|
|
131
|
+
process.exit(2);
|
|
132
|
+
}
|
|
133
|
+
if (result.payload.stdout_json) {
|
|
134
|
+
process.stdout.write(JSON.stringify(result.payload.stdout_json));
|
|
135
|
+
}
|
|
136
|
+
process.exit(0);
|
|
137
|
+
} catch {
|
|
138
|
+
process.exit(0);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
main();
|
|
142
|
+
//# sourceMappingURL=hook-forwarder.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@drisp/cli",
|
|
3
|
+
"description": "Workflow runtime for Claude Code with hooks, plugins, and interactive terminal observability",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/drisplabs/cli.git"
|
|
7
|
+
},
|
|
8
|
+
"homepage": "https://github.com/drisplabs/cli#readme",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/drisplabs/cli/issues"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"cli",
|
|
14
|
+
"claude",
|
|
15
|
+
"terminal",
|
|
16
|
+
"ink",
|
|
17
|
+
"hooks",
|
|
18
|
+
"dashboard"
|
|
19
|
+
],
|
|
20
|
+
"version": "0.3.39",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"bin": {
|
|
23
|
+
"drisp": "dist/cli.js",
|
|
24
|
+
"drisp-hook-forwarder": "dist/hook-forwarder.js"
|
|
25
|
+
},
|
|
26
|
+
"type": "module",
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=20"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsup",
|
|
35
|
+
"typecheck": "tsc --noEmit",
|
|
36
|
+
"dev": "tsup --watch",
|
|
37
|
+
"start": "tsup && node dist/cli.js",
|
|
38
|
+
"dev:debug": "tsup && DEV=true node dist/cli.js",
|
|
39
|
+
"devtools": "ELECTRON_DISABLE_SANDBOX=1 react-devtools",
|
|
40
|
+
"perf:tui": "node scripts/perf-runner.mjs --mode=full",
|
|
41
|
+
"perf:cpu": "node scripts/perf-runner.mjs --mode=cpu --no-app-profile",
|
|
42
|
+
"perf:trace": "node scripts/perf-runner.mjs --mode=trace --no-app-profile",
|
|
43
|
+
"perf:heap": "node scripts/perf-runner.mjs --mode=heap --no-app-profile",
|
|
44
|
+
"perf:summary": "node scripts/perf-summary.mjs",
|
|
45
|
+
"protocol:codex": "node scripts/update-codex-protocol-snapshot.mjs",
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"test:watch": "vitest",
|
|
48
|
+
"lint:format": "git ls-files -z | xargs -0 prettier --check --ignore-unknown",
|
|
49
|
+
"lint:eslint": "eslint .",
|
|
50
|
+
"lint:staged": "lint-staged",
|
|
51
|
+
"lint:dead": "knip --strict --exclude dependencies,unlisted,binaries",
|
|
52
|
+
"lint": "npm run lint:format && npm run lint:eslint",
|
|
53
|
+
"format": "prettier --write .",
|
|
54
|
+
"prepare": "simple-git-hooks",
|
|
55
|
+
"prepublishOnly": "npm run lint && npm run typecheck && npm run lint:dead && npm test && npm run build"
|
|
56
|
+
},
|
|
57
|
+
"files": [
|
|
58
|
+
"dist",
|
|
59
|
+
"!dist/**/*.js.map",
|
|
60
|
+
"dist/channel-daemon.js",
|
|
61
|
+
"dist/channel-telegram.js"
|
|
62
|
+
],
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@inkjs/ui": "^2.0.0",
|
|
65
|
+
"better-sqlite3": "^12.6.2",
|
|
66
|
+
"cli-highlight": "^2.1.11",
|
|
67
|
+
"cli-table3": "^0.6.5",
|
|
68
|
+
"ink": "^6.8.0",
|
|
69
|
+
"marked": "^15.0.12",
|
|
70
|
+
"marked-terminal": "^7.3.0",
|
|
71
|
+
"meow": "^14.1.0",
|
|
72
|
+
"posthog-node": "^5.28.0",
|
|
73
|
+
"react": "^19.0.0",
|
|
74
|
+
"react-dom": "^19.2.4",
|
|
75
|
+
"use-context-selector": "^1.4.4",
|
|
76
|
+
"ws": "^8.20.0"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@commitlint/cli": "^20.4.3",
|
|
80
|
+
"@commitlint/config-conventional": "^20.4.3",
|
|
81
|
+
"@eslint/js": "^9.0.0",
|
|
82
|
+
"@testing-library/react": "^16.3.2",
|
|
83
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
84
|
+
"@types/marked-terminal": "^6.1.1",
|
|
85
|
+
"@types/node": "^25.0.10",
|
|
86
|
+
"@types/react": "^19.0.0",
|
|
87
|
+
"@types/ws": "^8.18.1",
|
|
88
|
+
"@vdemedes/prettier-config": "^2.0.1",
|
|
89
|
+
"chalk": "^5.3.0",
|
|
90
|
+
"eslint": "^9.0.0",
|
|
91
|
+
"eslint-plugin-react": "^7.37.0",
|
|
92
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
93
|
+
"ink-testing-library": "^4.0.0",
|
|
94
|
+
"jsdom": "^27.4.0",
|
|
95
|
+
"knip": "^5.85.0",
|
|
96
|
+
"lint-staged": "^16.3.2",
|
|
97
|
+
"prettier": "^3.0.0",
|
|
98
|
+
"react-devtools": "^6.1.5",
|
|
99
|
+
"react-devtools-core": "^6.1.5",
|
|
100
|
+
"simple-git-hooks": "^2.13.1",
|
|
101
|
+
"tsup": "^8.5.1",
|
|
102
|
+
"typescript": "^5.7.0",
|
|
103
|
+
"typescript-eslint": "^8.0.0",
|
|
104
|
+
"vitest": "^3.0.0"
|
|
105
|
+
},
|
|
106
|
+
"simple-git-hooks": {
|
|
107
|
+
"pre-commit": "npm run lint:staged",
|
|
108
|
+
"commit-msg": "npx --no -- commitlint --edit $1"
|
|
109
|
+
},
|
|
110
|
+
"lint-staged": {
|
|
111
|
+
"*.{js,jsx,ts,tsx,mjs,cjs}": [
|
|
112
|
+
"eslint --fix",
|
|
113
|
+
"prettier --write"
|
|
114
|
+
],
|
|
115
|
+
"*.{json,md,yml,yaml}": "prettier --write"
|
|
116
|
+
},
|
|
117
|
+
"prettier": "@vdemedes/prettier-config"
|
|
118
|
+
}
|