claude-spotter 1.4.10 → 1.4.11
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/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import { existsSync } from 'node:fs';
|
|
2
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
3
3
|
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
|
-
import { dirname, join, resolve } from 'node:path';
|
|
5
|
+
import { delimiter, dirname, join, resolve } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
import { createAuditorBackend } from '../core/auditor-backend.mjs';
|
|
8
8
|
import { codexLastAssistantMessage, readCodexUsedTools } from '../core/codex-transcript.mjs';
|
|
@@ -315,7 +315,7 @@ export async function runCodexHookDiagnosticsCommand({
|
|
|
315
315
|
writeOutput(JSON.stringify(result, null, 2) + '\n');
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
-
export async function installCodexHooks({ codexHome = defaultCodexHome(), nodePath =
|
|
318
|
+
export async function installCodexHooks({ codexHome = defaultCodexHome(), nodePath = resolveCodexHookNodePath(), spotterBin = SPOTTER_BIN } = {}) {
|
|
319
319
|
const hooksPath = join(codexHome, 'hooks.json');
|
|
320
320
|
const configPath = join(codexHome, 'config.toml');
|
|
321
321
|
const current = await loadJson(hooksPath);
|
|
@@ -340,6 +340,41 @@ export async function installCodexHooks({ codexHome = defaultCodexHome(), nodePa
|
|
|
340
340
|
};
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
+
function safeRealpath(path, realpath = realpathSync.native) {
|
|
344
|
+
try {
|
|
345
|
+
return realpath(path);
|
|
346
|
+
} catch {
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export function resolveCodexHookNodePath({
|
|
352
|
+
env = process.env,
|
|
353
|
+
execPath = process.execPath,
|
|
354
|
+
platform = process.platform,
|
|
355
|
+
exists = existsSync,
|
|
356
|
+
realpath = realpathSync.native,
|
|
357
|
+
} = {}) {
|
|
358
|
+
const execRealpath = safeRealpath(execPath, realpath);
|
|
359
|
+
const pathEnv = env.PATH || env.Path || '';
|
|
360
|
+
const names = platform === 'win32'
|
|
361
|
+
? ['node.exe', 'node.cmd', 'node.bat', 'node']
|
|
362
|
+
: ['node'];
|
|
363
|
+
|
|
364
|
+
for (const dir of pathEnv.split(delimiter).filter(Boolean)) {
|
|
365
|
+
for (const name of names) {
|
|
366
|
+
const candidate = join(dir, name);
|
|
367
|
+
if (!exists(candidate)) continue;
|
|
368
|
+
const candidateRealpath = safeRealpath(candidate, realpath);
|
|
369
|
+
if (execRealpath && candidateRealpath && candidateRealpath === execRealpath) {
|
|
370
|
+
return candidate;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return execPath;
|
|
376
|
+
}
|
|
377
|
+
|
|
343
378
|
export async function uninstallCodexHooks({ codexHome = defaultCodexHome() } = {}) {
|
|
344
379
|
const hooksPath = join(codexHome, 'hooks.json');
|
|
345
380
|
const current = await loadJson(hooksPath);
|
|
@@ -468,7 +468,7 @@ function execPortable(execFileFn, cmd, args, spawnOptions) {
|
|
|
468
468
|
windowsHide: true,
|
|
469
469
|
maxBuffer: 10 * 1024 * 1024,
|
|
470
470
|
};
|
|
471
|
-
if (process.platform === 'win32') {
|
|
471
|
+
if (process.platform === 'win32' && cmd !== process.execPath) {
|
|
472
472
|
return execFileFn('cmd.exe', ['/c', cmd, ...args], options);
|
|
473
473
|
}
|
|
474
474
|
return execFileFn(cmd, args, options);
|
package/src/version.mjs
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname, resolve } from 'node:path';
|
|
4
|
+
|
|
5
|
+
const pkgPath = resolve(dirname(fileURLToPath(import.meta.url)), '..', 'package.json');
|
|
6
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
2
7
|
export const version = pkg.version;
|