@infinitedusky/indusk-mcp 1.11.7 → 1.11.8
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 +61 -9
- package/package.json +1 -1
package/hooks/eval-trigger.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* PostToolUse hook: triggers the eval judge after `jj describe`.
|
|
4
5
|
*
|
|
@@ -9,9 +10,9 @@
|
|
|
9
10
|
* Exit 0 always — this is advisory, not blocking.
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
13
13
|
import { execSync, spawn } from "node:child_process";
|
|
14
|
-
import {
|
|
14
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
15
|
+
import { dirname, resolve } from "node:path";
|
|
15
16
|
import { fileURLToPath } from "node:url";
|
|
16
17
|
|
|
17
18
|
// Read hook input from stdin
|
|
@@ -85,15 +86,64 @@ try {
|
|
|
85
86
|
// Claude Code provides CLAUDE_TRANSCRIPT_PATH in the environment when hooks run,
|
|
86
87
|
// or we can search for the most recent transcript.
|
|
87
88
|
const transcriptPath =
|
|
88
|
-
process.env.CLAUDE_TRANSCRIPT_PATH ??
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
process.env.CLAUDE_TRANSCRIPT_PATH ?? process.env.TRANSCRIPT_PATH ?? "(transcript unavailable)";
|
|
90
|
+
|
|
91
|
+
// Find the indusk-mcp package — resolve from the hook's own location.
|
|
92
|
+
// The hook lives at .claude/hooks/eval-trigger.js but was copied from the package's hooks/ dir.
|
|
93
|
+
// Try multiple resolution strategies:
|
|
94
|
+
// 1. Relative to the hook's original package location (when run from the package source)
|
|
95
|
+
// 2. Via npx cache / global install
|
|
96
|
+
// 3. Via the project's node_modules
|
|
97
|
+
const hookDir = dirname(fileURLToPath(import.meta.url));
|
|
98
|
+
const candidates = [
|
|
99
|
+
// Source repo (apps/indusk-mcp/hooks/ → apps/indusk-mcp/dist/)
|
|
100
|
+
resolve(hookDir, "../dist/lib/eval/judge-runner.js"),
|
|
101
|
+
// Installed package (hooks/ → dist/)
|
|
102
|
+
resolve(hookDir, "../../node_modules/@infinitedusky/indusk-mcp/dist/lib/eval/judge-runner.js"),
|
|
103
|
+
// Global npx cache
|
|
104
|
+
...(() => {
|
|
105
|
+
try {
|
|
106
|
+
const which = execSync("which indusk", { encoding: "utf8" }).trim();
|
|
107
|
+
if (which)
|
|
108
|
+
return [
|
|
109
|
+
resolve(
|
|
110
|
+
dirname(which),
|
|
111
|
+
"../lib/node_modules/@infinitedusky/indusk-mcp/dist/lib/eval/judge-runner.js",
|
|
112
|
+
),
|
|
113
|
+
];
|
|
114
|
+
} catch {}
|
|
115
|
+
return [];
|
|
116
|
+
})(),
|
|
117
|
+
];
|
|
118
|
+
let judgeRunnerPath = null;
|
|
119
|
+
for (const c of candidates) {
|
|
120
|
+
if (existsSync(c)) {
|
|
121
|
+
judgeRunnerPath = c;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!judgeRunnerPath) {
|
|
127
|
+
// Can't find the package — log error and exit
|
|
128
|
+
const { mkdirSync, appendFileSync } = await import("node:fs");
|
|
129
|
+
const logPath = resolve(projectRoot, ".indusk", "eval", "results.log");
|
|
130
|
+
mkdirSync(dirname(logPath), { recursive: true });
|
|
131
|
+
const entry = JSON.stringify({
|
|
132
|
+
version: 1,
|
|
133
|
+
timestamp: new Date().toISOString(),
|
|
134
|
+
mode: "eval",
|
|
135
|
+
changeId,
|
|
136
|
+
error: true,
|
|
137
|
+
message:
|
|
138
|
+
"Could not find @infinitedusky/indusk-mcp package — eval judge not available. Run: npm i -g @infinitedusky/indusk-mcp",
|
|
139
|
+
});
|
|
140
|
+
appendFileSync(logPath, entry + "\n", "utf8");
|
|
141
|
+
process.exit(0);
|
|
142
|
+
}
|
|
91
143
|
|
|
92
|
-
// Spawn the judge runner as a detached background process.
|
|
93
144
|
// Spawn a detached node process that calls runJudgeSync (which awaits completion).
|
|
94
|
-
// runJudgeSync keeps the process alive until claude --print finishes and logs the result.
|
|
95
145
|
const judgeScript = `
|
|
96
|
-
import("${
|
|
146
|
+
import("${judgeRunnerPath}")
|
|
97
147
|
.then(m => m.runJudgeSync({
|
|
98
148
|
projectRoot: ${JSON.stringify(projectRoot)},
|
|
99
149
|
changeId: ${JSON.stringify(changeId)},
|
|
@@ -137,6 +187,8 @@ const output = JSON.stringify({
|
|
|
137
187
|
},
|
|
138
188
|
});
|
|
139
189
|
process.stdout.write(output);
|
|
140
|
-
process.stderr.write(
|
|
190
|
+
process.stderr.write(
|
|
191
|
+
`📊 Eval judge spawned in background for ${changeId.slice(0, 8)}. Results will appear in .indusk/eval/results.log\n`,
|
|
192
|
+
);
|
|
141
193
|
|
|
142
194
|
process.exit(0);
|