@infinitedusky/indusk-mcp 1.13.1 → 1.13.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/hooks/eval-trigger.js +39 -23
- package/package.json +1 -1
package/hooks/eval-trigger.js
CHANGED
|
@@ -15,15 +15,12 @@ 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
|
-
//
|
|
19
|
-
function
|
|
18
|
+
// System log — writes to .indusk/eval/system.log for full visibility into eval lifecycle
|
|
19
|
+
function syslog(projectRoot, msg) {
|
|
20
20
|
try {
|
|
21
21
|
const logDir = resolve(projectRoot || ".", ".indusk", "eval");
|
|
22
22
|
mkdirSync(logDir, { recursive: true });
|
|
23
|
-
appendFileSync(
|
|
24
|
-
resolve(logDir, "hook.log"),
|
|
25
|
-
`${new Date().toISOString()} ${msg}\n`,
|
|
26
|
-
);
|
|
23
|
+
appendFileSync(resolve(logDir, "system.log"), `${new Date().toISOString()} ${msg}\n`);
|
|
27
24
|
} catch {
|
|
28
25
|
// ignore — logging should never break the hook
|
|
29
26
|
}
|
|
@@ -40,11 +37,11 @@ const toolInput = event.tool_input ?? {};
|
|
|
40
37
|
const command = toolInput.command ?? "";
|
|
41
38
|
const cwd = event.cwd ?? process.cwd();
|
|
42
39
|
|
|
43
|
-
|
|
40
|
+
syslog(cwd, `hook fired — tool: ${event.tool_name}, command: ${command.slice(0, 100)}`);
|
|
44
41
|
|
|
45
42
|
// Fast path: not a jj describe command
|
|
46
43
|
if (!command.includes("jj describe")) {
|
|
47
|
-
|
|
44
|
+
syslog(cwd, "skip — no jj describe in command");
|
|
48
45
|
process.exit(0);
|
|
49
46
|
}
|
|
50
47
|
|
|
@@ -82,11 +79,11 @@ function readEvalConfig(projectRoot) {
|
|
|
82
79
|
const projectRoot = findProjectRoot(cwd);
|
|
83
80
|
const evalConfig = readEvalConfig(projectRoot);
|
|
84
81
|
|
|
85
|
-
|
|
82
|
+
syslog(projectRoot, `projectRoot: ${projectRoot}, eval.enabled: ${evalConfig.enabled}`);
|
|
86
83
|
|
|
87
84
|
// Check if eval is disabled
|
|
88
85
|
if (!evalConfig.enabled) {
|
|
89
|
-
|
|
86
|
+
syslog(projectRoot, "skip — eval disabled in config");
|
|
90
87
|
process.exit(0);
|
|
91
88
|
}
|
|
92
89
|
|
|
@@ -138,13 +135,13 @@ const candidates = [
|
|
|
138
135
|
];
|
|
139
136
|
let judgeRunnerPath = null;
|
|
140
137
|
for (const c of candidates) {
|
|
141
|
-
|
|
138
|
+
syslog(projectRoot, `candidate: ${c} — ${existsSync(c) ? "found" : "missing"}`);
|
|
142
139
|
if (existsSync(c)) {
|
|
143
140
|
judgeRunnerPath = c;
|
|
144
141
|
break;
|
|
145
142
|
}
|
|
146
143
|
}
|
|
147
|
-
|
|
144
|
+
syslog(projectRoot, `judgeRunnerPath: ${judgeRunnerPath ?? "NOT FOUND"}`);
|
|
148
145
|
|
|
149
146
|
if (!judgeRunnerPath) {
|
|
150
147
|
// Can't find the package — log error and exit
|
|
@@ -188,21 +185,40 @@ const persistentJudgePath = judgeRunnerPath.replace("judge-runner.js", "persiste
|
|
|
188
185
|
const useModule = existsSync(persistentJudgePath) ? persistentJudgePath : judgeRunnerPath;
|
|
189
186
|
const useFunction = existsSync(persistentJudgePath) ? "runPersistentEval" : "runJudgeSync";
|
|
190
187
|
|
|
191
|
-
|
|
188
|
+
syslog(
|
|
189
|
+
projectRoot,
|
|
190
|
+
`spawning judge — module: ${useModule}, function: ${useFunction}, changeId: ${changeId}`,
|
|
191
|
+
);
|
|
192
192
|
|
|
193
|
+
const syslogPath = resolve(projectRoot, ".indusk", "eval", "system.log");
|
|
193
194
|
const judgeScript = `
|
|
195
|
+
const fs = require("fs");
|
|
196
|
+
const path = require("path");
|
|
197
|
+
function syslog(msg) {
|
|
198
|
+
try {
|
|
199
|
+
fs.mkdirSync(path.dirname("${syslogPath}"), { recursive: true });
|
|
200
|
+
fs.appendFileSync("${syslogPath}", new Date().toISOString() + " " + msg + "\\n");
|
|
201
|
+
} catch {}
|
|
202
|
+
}
|
|
203
|
+
syslog("judge process started — changeId: ${changeId}");
|
|
194
204
|
import("${useModule}")
|
|
195
|
-
.then(m =>
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
205
|
+
.then(m => {
|
|
206
|
+
syslog("judge module loaded — calling ${useFunction}");
|
|
207
|
+
return m.${useFunction}({
|
|
208
|
+
projectRoot: ${JSON.stringify(projectRoot)},
|
|
209
|
+
changeId: ${JSON.stringify(changeId)},
|
|
210
|
+
transcriptPath: ${JSON.stringify(transcriptPath)},
|
|
211
|
+
mode: "eval",
|
|
212
|
+
evalEndpoint: ${JSON.stringify(evalConfig.endpoint)},
|
|
213
|
+
});
|
|
214
|
+
})
|
|
215
|
+
.then((result) => {
|
|
216
|
+
const hasError = result && result.error;
|
|
217
|
+
syslog("judge completed — " + (hasError ? "error: " + result.message : "scorecard written"));
|
|
218
|
+
process.exit(0);
|
|
219
|
+
})
|
|
203
220
|
.catch(err => {
|
|
204
|
-
|
|
205
|
-
const path = require("path");
|
|
221
|
+
syslog("judge crashed — " + (err.message || String(err)));
|
|
206
222
|
const logPath = path.join(${JSON.stringify(projectRoot)}, ".indusk", "eval", "results.log");
|
|
207
223
|
fs.mkdirSync(path.dirname(logPath), { recursive: true });
|
|
208
224
|
const entry = JSON.stringify({
|