knoxis-collab 1.1.0 → 1.1.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/knoxis-collab.js +50 -11
- package/package.json +1 -1
package/knoxis-collab.js
CHANGED
|
@@ -85,19 +85,57 @@ const GROQ_API_KEY = process.env.GROQ_API_KEY || config.groqApiKey || '';
|
|
|
85
85
|
const BACKEND_URL = process.env.KNOXIS_BACKEND_URL || config.backendUrl || '';
|
|
86
86
|
const USER_ID = process.env.KNOXIS_USER_ID || config.userId || '';
|
|
87
87
|
|
|
88
|
-
// Resolve Claude binary —
|
|
88
|
+
// Resolve Claude binary — check every reasonable location
|
|
89
|
+
const IS_WIN = process.platform === 'win32';
|
|
90
|
+
|
|
91
|
+
function existsAny(basePath) {
|
|
92
|
+
// On Windows, .bin has claude.cmd / claude.ps1 rather than a bare 'claude'
|
|
93
|
+
const candidates = IS_WIN
|
|
94
|
+
? [basePath + '.cmd', basePath + '.ps1', basePath]
|
|
95
|
+
: [basePath];
|
|
96
|
+
for (const c of candidates) {
|
|
97
|
+
if (fs.existsSync(c)) return c;
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
89
102
|
function resolveClaudeBin() {
|
|
90
|
-
//
|
|
91
|
-
const localBin = path.join(__dirname, 'node_modules', '.bin', 'claude');
|
|
92
|
-
if (
|
|
103
|
+
// 1. Local node_modules (when installed as npm package)
|
|
104
|
+
const localBin = existsAny(path.join(__dirname, 'node_modules', '.bin', 'claude'));
|
|
105
|
+
if (localBin) return localBin;
|
|
106
|
+
|
|
107
|
+
// 2. Parent node_modules (when this is a dep of another package)
|
|
108
|
+
const parentBin = existsAny(path.join(__dirname, '..', '.bin', 'claude'));
|
|
109
|
+
if (parentBin) return parentBin;
|
|
110
|
+
|
|
111
|
+
// 3. Global npm prefix bin (same dir where knoxis-collab bin lands)
|
|
112
|
+
try {
|
|
113
|
+
const { status, stdout } = spawnSync('npm', ['prefix', '-g'], { stdio: 'pipe', shell: IS_WIN });
|
|
114
|
+
if (status === 0) {
|
|
115
|
+
const prefix = stdout.toString().trim();
|
|
116
|
+
// npm global bins: prefix/bin on unix, prefix on windows
|
|
117
|
+
const globalBin = existsAny(path.join(prefix, IS_WIN ? '' : 'bin', 'claude'));
|
|
118
|
+
if (globalBin) return globalBin;
|
|
119
|
+
}
|
|
120
|
+
} catch (e) {}
|
|
93
121
|
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
|
|
122
|
+
// 4. Resolve via require (finds the package even if bin symlink is missing)
|
|
123
|
+
try {
|
|
124
|
+
const claudePkg = path.dirname(require.resolve('@anthropic-ai/claude-code/package.json'));
|
|
125
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(claudePkg, 'package.json'), 'utf8'));
|
|
126
|
+
const binEntry = typeof pkg.bin === 'string' ? pkg.bin : (pkg.bin && pkg.bin.claude);
|
|
127
|
+
if (binEntry) {
|
|
128
|
+
const resolved = path.join(claudePkg, binEntry);
|
|
129
|
+
if (fs.existsSync(resolved)) return resolved;
|
|
130
|
+
}
|
|
131
|
+
} catch (e) {}
|
|
97
132
|
|
|
98
|
-
// Fall back to global PATH
|
|
99
|
-
|
|
100
|
-
|
|
133
|
+
// 5. Fall back to global PATH
|
|
134
|
+
try {
|
|
135
|
+
const cmd = IS_WIN ? 'where' : 'which';
|
|
136
|
+
const { status, stdout } = spawnSync(cmd, ['claude'], { stdio: 'pipe', shell: IS_WIN });
|
|
137
|
+
if (status === 0 && stdout.toString().trim()) return stdout.toString().trim().split('\n')[0];
|
|
138
|
+
} catch (e) {}
|
|
101
139
|
|
|
102
140
|
return null;
|
|
103
141
|
}
|
|
@@ -456,7 +494,8 @@ function dispatchToClaude(prompt) {
|
|
|
456
494
|
const proc = spawn(CLAUDE_BIN, args, {
|
|
457
495
|
cwd: WORKSPACE,
|
|
458
496
|
env: { ...process.env },
|
|
459
|
-
stdio: ['pipe', 'pipe', 'pipe']
|
|
497
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
498
|
+
shell: IS_WIN
|
|
460
499
|
});
|
|
461
500
|
|
|
462
501
|
activeClaudeProc = proc;
|