vexp-mcp 3.2.2 → 3.2.5
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/dist/daemon-client.js +49 -8
- package/package.json +1 -1
package/dist/daemon-client.js
CHANGED
|
@@ -122,6 +122,10 @@ export class DaemonClient {
|
|
|
122
122
|
return;
|
|
123
123
|
if (!fs.existsSync(path.join(workspaceRoot, ".vexp", "manifest.json")))
|
|
124
124
|
return;
|
|
125
|
+
// The daemon refuses the home directory itself; not asking spares the
|
|
126
|
+
// spawn and the "daemon did not start" it would answer with.
|
|
127
|
+
if (isVexpStateHome(workspaceRoot))
|
|
128
|
+
return;
|
|
125
129
|
const binary = resolveVexpCoreBinary();
|
|
126
130
|
if (!binary)
|
|
127
131
|
return;
|
|
@@ -567,6 +571,19 @@ export function fnvHash(input) {
|
|
|
567
571
|
}
|
|
568
572
|
return hash.toString(16);
|
|
569
573
|
}
|
|
574
|
+
/** True when `dir` is the home / VEXP_HOME directory: vexp's own STATE dir
|
|
575
|
+
* (config, licence, daemons.json), never a workspace — initialized-looking or
|
|
576
|
+
* not, because a stray daemon that indexed home leaves an index.db there and
|
|
577
|
+
* that residue must not read as consent (field report, 2026-09-19).
|
|
578
|
+
* Lockstep with vexp-core utils::forbidden_workspace_reason; the same
|
|
579
|
+
* VEXP_ALLOW_HOME_WORKSPACE=1 lifts it. */
|
|
580
|
+
export function isVexpStateHome(dir) {
|
|
581
|
+
if (process.env.VEXP_ALLOW_HOME_WORKSPACE === "1")
|
|
582
|
+
return false;
|
|
583
|
+
const stateHome = path.resolve(process.env.VEXP_HOME && path.isAbsolute(process.env.VEXP_HOME) ? process.env.VEXP_HOME : os.homedir());
|
|
584
|
+
const a = path.resolve(dir);
|
|
585
|
+
return process.platform === "win32" ? a.toLowerCase() === stateHome.toLowerCase() : a === stateHome;
|
|
586
|
+
}
|
|
570
587
|
/**
|
|
571
588
|
* Walk up from cwd looking for .vexp/ or .git/ to find the workspace root.
|
|
572
589
|
* Used when VEXP_WORKSPACE is not set (e.g., agent spawns MCP server
|
|
@@ -575,12 +592,14 @@ export function fnvHash(input) {
|
|
|
575
592
|
function discoverWorkspaceRoot() {
|
|
576
593
|
const cwd = process.cwd();
|
|
577
594
|
// Pass 1: nearest ancestor with an INITIALIZED .vexp/ (manifest.json or
|
|
578
|
-
// index.db) — a real indexed workspace, not a stray/empty .vexp/ dir.
|
|
595
|
+
// index.db) — a real indexed workspace, not a stray/empty .vexp/ dir. The
|
|
596
|
+
// home directory never qualifies (isVexpStateHome).
|
|
579
597
|
// MUST stay in lockstep with vexp-core/src/utils.rs::discover_workspace_root.
|
|
580
598
|
let current = cwd;
|
|
581
599
|
while (true) {
|
|
582
600
|
const vexp = path.join(current, ".vexp");
|
|
583
|
-
if (fs.existsSync(path.join(vexp, "manifest.json")) || fs.existsSync(path.join(vexp, "index.db")))
|
|
601
|
+
if ((fs.existsSync(path.join(vexp, "manifest.json")) || fs.existsSync(path.join(vexp, "index.db"))) &&
|
|
602
|
+
!isVexpStateHome(current)) {
|
|
584
603
|
return current;
|
|
585
604
|
}
|
|
586
605
|
const parent = path.dirname(current);
|
|
@@ -593,10 +612,9 @@ function discoverWorkspaceRoot() {
|
|
|
593
612
|
// dir: treating it as a workspace let an agent that spawns servers from
|
|
594
613
|
// the home dir target the whole home (field report, 2026-09-02). Lockstep
|
|
595
614
|
// with vexp-core utils::discover_workspace_root.
|
|
596
|
-
const stateHome = path.resolve(process.env.VEXP_HOME && path.isAbsolute(process.env.VEXP_HOME) ? process.env.VEXP_HOME : os.homedir());
|
|
597
615
|
current = cwd;
|
|
598
616
|
while (true) {
|
|
599
|
-
if (fs.existsSync(path.join(current, ".vexp")) &&
|
|
617
|
+
if (fs.existsSync(path.join(current, ".vexp")) && !isVexpStateHome(current))
|
|
600
618
|
return current;
|
|
601
619
|
const parent = path.dirname(current);
|
|
602
620
|
if (parent === current)
|
|
@@ -654,7 +672,7 @@ function resolveWorkspaceWithSource(explicit) {
|
|
|
654
672
|
return { root: explicit, source: "VEXP_WORKSPACE" };
|
|
655
673
|
const vw = process.env["VEXP_WORKSPACE"];
|
|
656
674
|
const cpd = process.env["CLAUDE_PROJECT_DIR"];
|
|
657
|
-
if (vw && cpd && path.resolve(vw).toLowerCase() !== path.resolve(cpd).toLowerCase()) {
|
|
675
|
+
if (vw && cpd && canonicalWorkspaceRoot(path.resolve(vw)).toLowerCase() !== canonicalWorkspaceRoot(path.resolve(cpd)).toLowerCase()) {
|
|
658
676
|
warnOnce(`[vexp-mcp] VEXP_WORKSPACE=${vw} disagrees with this session's ` +
|
|
659
677
|
`CLAUDE_PROJECT_DIR=${cpd}; using CLAUDE_PROJECT_DIR for per-session ` +
|
|
660
678
|
`targeting. Unset the global VEXP_WORKSPACE env var to silence this.`);
|
|
@@ -723,7 +741,7 @@ function pickFromDaemonRegistry(workspaceHint) {
|
|
|
723
741
|
});
|
|
724
742
|
if (entries.length === 0)
|
|
725
743
|
return null;
|
|
726
|
-
const hintNorm = workspaceHint.toLowerCase();
|
|
744
|
+
const hintNorm = canonicalWorkspaceRoot(workspaceHint).toLowerCase();
|
|
727
745
|
for (const [ws, sock] of entries) {
|
|
728
746
|
if (ws.toLowerCase() === hintNorm)
|
|
729
747
|
return sock;
|
|
@@ -809,7 +827,7 @@ export function resolveTargeting() {
|
|
|
809
827
|
if (fromRegistry)
|
|
810
828
|
return { socket: fromRegistry, source, socketOrigin: "registry", workspaceRoot };
|
|
811
829
|
// Hash-based last-ditch (daemon should always register, so this is rare)
|
|
812
|
-
const hash = fnvHash(workspaceRoot.toLowerCase());
|
|
830
|
+
const hash = fnvHash(canonicalWorkspaceRoot(workspaceRoot).toLowerCase());
|
|
813
831
|
return { socket: `\\\\.\\pipe\\vexp-${hash.slice(0, 8)}`, source, socketOrigin: "hash-fallback", workspaceRoot };
|
|
814
832
|
}
|
|
815
833
|
// Unix: prefer workspace-local if the socket file actually exists
|
|
@@ -967,11 +985,34 @@ export function resolveWorkspaceByHash(hashPrefix) {
|
|
|
967
985
|
}
|
|
968
986
|
return null;
|
|
969
987
|
}
|
|
988
|
+
/**
|
|
989
|
+
* The workspace root as the daemon spells it. vexp-core canonicalizes the
|
|
990
|
+
* root before deriving the pipe name and the daemons.json key, and on
|
|
991
|
+
* Windows a folder on a mapped drive canonicalizes to its share:
|
|
992
|
+
* `X:\proj` becomes `\\server\share\proj`. Every hash computed from the
|
|
993
|
+
* drive-letter spelling named a pipe the daemon never bound, so `vexp
|
|
994
|
+
* status` on a share reported the daemon as down and started a second one,
|
|
995
|
+
* and the MCP bridge could not reach it (field report, Samba share from
|
|
996
|
+
* Windows 11, 2026-09-20). Node's native realpath resolves the same way; a
|
|
997
|
+
* local path only gets its case corrected, which the lowercase hash never
|
|
998
|
+
* saw. Falls back to the spelling given when the folder cannot be resolved
|
|
999
|
+
* (a stale registry row, a path that is not there yet).
|
|
1000
|
+
*/
|
|
1001
|
+
export function canonicalWorkspaceRoot(root) {
|
|
1002
|
+
if (process.platform !== "win32")
|
|
1003
|
+
return root;
|
|
1004
|
+
try {
|
|
1005
|
+
return fs.realpathSync.native(root);
|
|
1006
|
+
}
|
|
1007
|
+
catch {
|
|
1008
|
+
return root;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
970
1011
|
/** Deterministic socket/pipe path for a workspace root — mirrors the Rust
|
|
971
1012
|
* daemon's get_socket_path (vexp-core/src/utils.rs). */
|
|
972
1013
|
function socketPathForWorkspace(ws) {
|
|
973
1014
|
if (process.platform === "win32") {
|
|
974
|
-
return `\\\\.\\pipe\\vexp-${fnvHash(ws.toLowerCase()).slice(0, 8)}`;
|
|
1015
|
+
return `\\\\.\\pipe\\vexp-${fnvHash(canonicalWorkspaceRoot(ws).toLowerCase()).slice(0, 8)}`;
|
|
975
1016
|
}
|
|
976
1017
|
return path.join(ws, ".vexp", "daemon.sock");
|
|
977
1018
|
}
|