neohive 6.1.3 → 6.1.4
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/cli.js +7 -0
- package/lib/resolve-server-data-dir.js +28 -8
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -291,6 +291,13 @@ function setupAntigravity(cwd) {
|
|
|
291
291
|
|
|
292
292
|
const abDataDir = path.join(path.resolve(cwd), '.neohive').replace(/\\/g, '/');
|
|
293
293
|
|
|
294
|
+
// Antigravity uses a single global config. Warn if overwriting a different project.
|
|
295
|
+
const existing = config.mcpServers['neohive'];
|
|
296
|
+
if (existing && existing.env && existing.env.NEOHIVE_DATA_DIR && existing.env.NEOHIVE_DATA_DIR !== abDataDir) {
|
|
297
|
+
console.log(' [warn] Antigravity: overwriting previous project → ' + existing.env.NEOHIVE_DATA_DIR);
|
|
298
|
+
console.log(' Antigravity uses a single global config — only one project at a time.');
|
|
299
|
+
}
|
|
300
|
+
|
|
294
301
|
config.mcpServers['neohive'] = {
|
|
295
302
|
command: 'npx',
|
|
296
303
|
args: ['-y', 'neohive', 'mcp'],
|
|
@@ -64,29 +64,49 @@ function readNeohiveDirFromUserCursorMcp() {
|
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Neohive data directory for the MCP / CLI process.
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
67
|
+
*
|
|
68
|
+
* Resolution order:
|
|
69
|
+
* 1. NEOHIVE_DATA_DIR env var (set by `neohive init` in project .cursor/mcp.json)
|
|
70
|
+
* 2. Walk up from cwd looking for project MCP configs that define NEOHIVE_DATA_DIR
|
|
71
|
+
* 3. Sibling .neohive/ next to the package (for local dev)
|
|
72
|
+
* 4. User-level ~/.cursor/mcp.json (only if it has an absolute NEOHIVE_DATA_DIR)
|
|
73
|
+
* 5. cwd/.neohive (last resort)
|
|
74
|
+
*
|
|
75
|
+
* Cursor spawns MCP processes with cwd set to a fixed directory (often $HOME),
|
|
76
|
+
* NOT the project root. The only reliable way to identify the project is via
|
|
77
|
+
* NEOHIVE_DATA_DIR in the env. All other fallbacks are best-effort heuristics.
|
|
70
78
|
*
|
|
71
79
|
* @param {string} serverJsDir - __dirname of server.js (the agent-bridge folder)
|
|
72
80
|
*/
|
|
73
81
|
function resolveDataDirForServer(serverJsDir) {
|
|
74
82
|
const raw = process.env.NEOHIVE_DATA_DIR || process.env.NEOHIVE_DATA;
|
|
75
83
|
if (raw != null && String(raw).trim() !== '') {
|
|
76
|
-
|
|
84
|
+
const val = String(raw).trim();
|
|
85
|
+
if (/\$\{workspaceFolder\}/i.test(val)) {
|
|
86
|
+
// Cursor user-level configs don't expand ${workspaceFolder}.
|
|
87
|
+
// Don't use this broken value — fall through to cwd/.neohive so the
|
|
88
|
+
// data stays isolated to wherever the process is running.
|
|
89
|
+
console.error('[neohive] NEOHIVE_DATA_DIR contains unexpanded ${workspaceFolder}: ' + val);
|
|
90
|
+
console.error('[neohive] Run "npx neohive init --cursor" in your project to fix this.');
|
|
91
|
+
return path.join(process.cwd(), '.neohive');
|
|
92
|
+
}
|
|
93
|
+
return path.resolve(val);
|
|
77
94
|
}
|
|
78
95
|
|
|
96
|
+
// No env var at all — IDE didn't pass one. Walk up from cwd looking for a
|
|
97
|
+
// project MCP config that defines NEOHIVE_DATA_DIR (first match wins).
|
|
79
98
|
const fromWalk = findDataDirByWalkingUpFrom(process.cwd());
|
|
80
99
|
if (fromWalk) return fromWalk;
|
|
81
100
|
|
|
101
|
+
// Local dev only: server.js lives inside a project repo (e.g. agent-bridge/).
|
|
102
|
+
// Use the repo's .neohive/ — but ONLY if we aren't inside node_modules
|
|
103
|
+
// (npm-installed copies must never resolve to the package author's project).
|
|
82
104
|
const parent = path.join(serverJsDir, '..');
|
|
83
|
-
if (fs.existsSync(path.join(parent, '.cursor', 'mcp.json'))) {
|
|
105
|
+
if (!serverJsDir.includes('node_modules') && fs.existsSync(path.join(parent, '.cursor', 'mcp.json'))) {
|
|
84
106
|
return path.join(parent, '.neohive');
|
|
85
107
|
}
|
|
86
|
-
if (fs.existsSync(path.join(serverJsDir, '.cursor', 'mcp.json'))) {
|
|
87
|
-
return path.join(serverJsDir, '.neohive');
|
|
88
|
-
}
|
|
89
108
|
|
|
109
|
+
// User-level ~/.cursor/mcp.json — only if it defines an absolute path
|
|
90
110
|
const fromUser = readNeohiveDirFromUserCursorMcp();
|
|
91
111
|
if (fromUser) return fromUser;
|
|
92
112
|
|