cc-brain 0.1.7 → 0.1.9
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/bin/cc-brain.js +3 -2
- package/hooks/hooks.json +1 -1
- package/package.json +1 -1
- package/scripts/install.js +12 -4
- package/scripts/uninstall.js +1 -1
package/bin/cc-brain.js
CHANGED
|
@@ -68,8 +68,9 @@ if (!command || command === '--help' || command === '-h') {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
if (command === '--version' || command === '-v') {
|
|
71
|
-
const
|
|
72
|
-
|
|
71
|
+
const { readFileSync } = await import('fs');
|
|
72
|
+
const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8'));
|
|
73
|
+
console.log(pkg.version);
|
|
73
74
|
process.exit(0);
|
|
74
75
|
}
|
|
75
76
|
|
package/hooks/hooks.json
CHANGED
package/package.json
CHANGED
package/scripts/install.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Sets up brain directory and hooks
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { existsSync, mkdirSync, copyFileSync, readFileSync, writeFileSync, unlinkSync } from 'fs';
|
|
8
|
+
import { existsSync, mkdirSync, copyFileSync, readFileSync, writeFileSync, unlinkSync, realpathSync } from 'fs';
|
|
9
9
|
import { join, dirname } from 'path';
|
|
10
10
|
import { homedir } from 'os';
|
|
11
11
|
import { fileURLToPath } from 'url';
|
|
@@ -66,14 +66,22 @@ if (existsSync(settingsPath)) {
|
|
|
66
66
|
// Read our hooks config
|
|
67
67
|
const hooks = JSON.parse(readFileSync(join(PROJECT_ROOT, 'hooks', 'hooks.json'), 'utf-8'));
|
|
68
68
|
|
|
69
|
-
//
|
|
70
|
-
|
|
69
|
+
// Resolve absolute paths — avoids PATH issues on macOS with nvm/fnm/volta
|
|
70
|
+
// Hook subprocesses don't source shell profiles, so npx/node may not be on PATH
|
|
71
|
+
let nodePath;
|
|
72
|
+
try {
|
|
73
|
+
nodePath = realpathSync(process.execPath);
|
|
74
|
+
} catch {
|
|
75
|
+
nodePath = process.execPath;
|
|
76
|
+
}
|
|
77
|
+
const loaderScript = join(PROJECT_ROOT, 'src', 'loader.js');
|
|
78
|
+
hooks.SessionStart[0].hooks[0].command = `"${nodePath}" "${loaderScript}"`;
|
|
71
79
|
|
|
72
80
|
// Merge hooks — preserve user's other hooks, replace/append ours
|
|
73
81
|
function isCcBrainHook(entry) {
|
|
74
82
|
if (!entry || !entry.hooks) return false;
|
|
75
83
|
return entry.hooks.some(h =>
|
|
76
|
-
(h.command && h.command.includes('loader.js')) ||
|
|
84
|
+
(h.command && (h.command.includes('cc-brain') || h.command.includes('loader.js'))) ||
|
|
77
85
|
(h.prompt && h.prompt.includes('structured saver'))
|
|
78
86
|
);
|
|
79
87
|
}
|
package/scripts/uninstall.js
CHANGED
|
@@ -23,7 +23,7 @@ console.log('Uninstalling cc-brain...\n');
|
|
|
23
23
|
function isCcBrainHook(entry) {
|
|
24
24
|
if (!entry || !entry.hooks) return false;
|
|
25
25
|
return entry.hooks.some(h =>
|
|
26
|
-
(h.command && h.command.includes('loader.js')) ||
|
|
26
|
+
(h.command && (h.command.includes('cc-brain') || h.command.includes('loader.js'))) ||
|
|
27
27
|
(h.prompt && h.prompt.includes('structured saver'))
|
|
28
28
|
);
|
|
29
29
|
}
|