@infinitedusky/indusk-mcp 1.13.0 → 1.13.1
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/hooks/eval-trigger.js +27 -2
- package/package.json +1 -1
package/hooks/eval-trigger.js
CHANGED
|
@@ -11,10 +11,24 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { execSync, spawn } from "node:child_process";
|
|
14
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
14
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
15
15
|
import { dirname, resolve } from "node:path";
|
|
16
16
|
import { fileURLToPath } from "node:url";
|
|
17
17
|
|
|
18
|
+
// Hook debug log — writes to .indusk/eval/hook.log so we can see what's happening
|
|
19
|
+
function hookLog(projectRoot, msg) {
|
|
20
|
+
try {
|
|
21
|
+
const logDir = resolve(projectRoot || ".", ".indusk", "eval");
|
|
22
|
+
mkdirSync(logDir, { recursive: true });
|
|
23
|
+
appendFileSync(
|
|
24
|
+
resolve(logDir, "hook.log"),
|
|
25
|
+
`${new Date().toISOString()} ${msg}\n`,
|
|
26
|
+
);
|
|
27
|
+
} catch {
|
|
28
|
+
// ignore — logging should never break the hook
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
18
32
|
// Read hook input from stdin
|
|
19
33
|
let input = "";
|
|
20
34
|
for await (const chunk of process.stdin) {
|
|
@@ -24,9 +38,13 @@ for await (const chunk of process.stdin) {
|
|
|
24
38
|
const event = JSON.parse(input);
|
|
25
39
|
const toolInput = event.tool_input ?? {};
|
|
26
40
|
const command = toolInput.command ?? "";
|
|
41
|
+
const cwd = event.cwd ?? process.cwd();
|
|
42
|
+
|
|
43
|
+
hookLog(cwd, `hook fired — tool: ${event.tool_name}, command: ${command.slice(0, 100)}`);
|
|
27
44
|
|
|
28
45
|
// Fast path: not a jj describe command
|
|
29
46
|
if (!command.includes("jj describe")) {
|
|
47
|
+
hookLog(cwd, "skip — no jj describe in command");
|
|
30
48
|
process.exit(0);
|
|
31
49
|
}
|
|
32
50
|
|
|
@@ -61,11 +79,14 @@ function readEvalConfig(projectRoot) {
|
|
|
61
79
|
}
|
|
62
80
|
}
|
|
63
81
|
|
|
64
|
-
const projectRoot = findProjectRoot(
|
|
82
|
+
const projectRoot = findProjectRoot(cwd);
|
|
65
83
|
const evalConfig = readEvalConfig(projectRoot);
|
|
66
84
|
|
|
85
|
+
hookLog(projectRoot, `projectRoot: ${projectRoot}, eval.enabled: ${evalConfig.enabled}`);
|
|
86
|
+
|
|
67
87
|
// Check if eval is disabled
|
|
68
88
|
if (!evalConfig.enabled) {
|
|
89
|
+
hookLog(projectRoot, "skip — eval disabled in config");
|
|
69
90
|
process.exit(0);
|
|
70
91
|
}
|
|
71
92
|
|
|
@@ -117,11 +138,13 @@ const candidates = [
|
|
|
117
138
|
];
|
|
118
139
|
let judgeRunnerPath = null;
|
|
119
140
|
for (const c of candidates) {
|
|
141
|
+
hookLog(projectRoot, `candidate: ${c} — ${existsSync(c) ? "found" : "missing"}`);
|
|
120
142
|
if (existsSync(c)) {
|
|
121
143
|
judgeRunnerPath = c;
|
|
122
144
|
break;
|
|
123
145
|
}
|
|
124
146
|
}
|
|
147
|
+
hookLog(projectRoot, `judgeRunnerPath: ${judgeRunnerPath ?? "NOT FOUND"}`);
|
|
125
148
|
|
|
126
149
|
if (!judgeRunnerPath) {
|
|
127
150
|
// Can't find the package — log error and exit
|
|
@@ -165,6 +188,8 @@ const persistentJudgePath = judgeRunnerPath.replace("judge-runner.js", "persiste
|
|
|
165
188
|
const useModule = existsSync(persistentJudgePath) ? persistentJudgePath : judgeRunnerPath;
|
|
166
189
|
const useFunction = existsSync(persistentJudgePath) ? "runPersistentEval" : "runJudgeSync";
|
|
167
190
|
|
|
191
|
+
hookLog(projectRoot, `spawning judge — module: ${useModule}, function: ${useFunction}, changeId: ${changeId}`);
|
|
192
|
+
|
|
168
193
|
const judgeScript = `
|
|
169
194
|
import("${useModule}")
|
|
170
195
|
.then(m => m.${useFunction}({
|