@agent-chat/mention-watcher 0.1.1 → 0.1.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.
Files changed (2) hide show
  1. package/dist/watch.js +29 -18
  2. package/package.json +1 -1
package/dist/watch.js CHANGED
@@ -59,26 +59,32 @@ function syncMcpToken(workspaceDir, mcpServerName) {
59
59
  }
60
60
  }
61
61
  function resolveShellPath() {
62
- const shell = process.env.SHELL || "/bin/zsh";
63
- const attempts = [
64
- `${shell} -i -c 'echo $PATH'`,
65
- // interactive (sources .zshrc, nvm)
66
- `${shell} -l -c 'echo $PATH'`
67
- // login (sources .zprofile)
68
- ];
69
- for (const cmd of attempts) {
62
+ const parts = new Set((process.env.PATH || "").split(":").filter(Boolean));
63
+ const nvmDir = process.env.NVM_DIR || path.join(os.homedir(), ".nvm");
64
+ const nvmNodeDir = path.join(nvmDir, "versions", "node");
65
+ if (fs.existsSync(nvmNodeDir)) {
70
66
  try {
71
- const raw = execSync(cmd, {
72
- encoding: "utf8",
73
- timeout: 4e3,
74
- stdio: ["ignore", "pipe", "ignore"]
75
- });
76
- const pathLine = raw.split("\n").map((l) => l.trim()).find((l) => l.startsWith("/") && l.includes(":"));
77
- if (pathLine) return pathLine;
67
+ for (const v of fs.readdirSync(nvmNodeDir)) {
68
+ const bin = path.join(nvmNodeDir, v, "bin");
69
+ if (fs.existsSync(bin)) parts.add(bin);
70
+ }
78
71
  } catch {
79
72
  }
80
73
  }
81
- return process.env.PATH || "";
74
+ try {
75
+ const shell = process.env.SHELL || "/bin/zsh";
76
+ const nvmSh = path.join(nvmDir, "nvm.sh");
77
+ const raw = execSync(
78
+ `${shell} -c 'source "${nvmSh}" 2>/dev/null; echo $PATH'`,
79
+ { encoding: "utf8", timeout: 4e3 }
80
+ ).trim();
81
+ for (const p of raw.split(":").filter(Boolean)) parts.add(p);
82
+ } catch {
83
+ }
84
+ for (const p of ["/opt/homebrew/bin", "/usr/local/bin", "/usr/bin", "/bin"]) {
85
+ parts.add(p);
86
+ }
87
+ return [...parts].join(":");
82
88
  }
83
89
  var _WORKSPACE = process.env.WORKSPACE_DIR ?? process.cwd();
84
90
  {
@@ -223,9 +229,14 @@ async function main() {
223
229
  `);
224
230
  const shellPath = resolveShellPath();
225
231
  const spawnEnv = { ...process.env, PATH: shellPath };
232
+ const userShell = process.env.SHELL || "/bin/zsh";
233
+ const quotedArgs = [COMMAND, ...CMD_ARGS].map((a) => `'${a.replace(/'/g, "'\\''")}'`).join(" ");
234
+ const shellCmd = `exec ${quotedArgs}`;
235
+ process.stderr.write(`[mention-watcher] Shell: ${userShell} -c "${shellCmd}"
236
+ `);
226
237
  let proc;
227
238
  try {
228
- proc = pty.spawn(COMMAND, CMD_ARGS, {
239
+ proc = pty.spawn(userShell, ["-c", shellCmd], {
229
240
  name: "xterm-256color",
230
241
  cols,
231
242
  rows,
@@ -235,7 +246,7 @@ async function main() {
235
246
  } catch (err) {
236
247
  process.stderr.write(`[mention-watcher] Failed to spawn "${COMMAND}": ${err.message}
237
248
  `);
238
- process.stderr.write(` Run "which ${COMMAND}" in your terminal to check it is installed.
249
+ process.stderr.write(` Run "which ${COMMAND}" in your terminal to confirm it is installed.
239
250
  `);
240
251
  process.exit(1);
241
252
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-chat/mention-watcher",
3
- "version": "0.1.1",
3
+ "version": "0.1.5",
4
4
  "description": "PTY wrapper that pushes @mentions from agent-chat into Claude Code (or any LLM CLI)",
5
5
  "type": "module",
6
6
  "bin": {