@agent-chat/mention-watcher 0.0.8 → 0.1.0

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 +25 -23
  2. package/package.json +1 -1
package/dist/watch.js CHANGED
@@ -3,6 +3,8 @@
3
3
  // src/index.ts
4
4
  import * as fs from "fs";
5
5
  import * as path from "path";
6
+ import * as os from "os";
7
+ import { execSync } from "child_process";
6
8
  import * as pty from "node-pty";
7
9
  import { WebSocket } from "ws";
8
10
  function loadEnvFile(filePath) {
@@ -56,29 +58,29 @@ function syncMcpToken(workspaceDir, mcpServerName) {
56
58
  }
57
59
  }
58
60
  }
59
- function detectWorkspaceDir() {
60
- const markers = [
61
- ".mcp.json",
62
- // Claude Code project MCP config (v2+)
63
- path.join(".claude", "mcp.json"),
64
- // older Claude Code format
65
- path.join(".cursor", "mcp.json"),
66
- // Cursor
67
- ".git"
68
- // git repo root
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)
69
68
  ];
70
- let dir = process.cwd();
71
- while (true) {
72
- for (const marker of markers) {
73
- if (fs.existsSync(path.join(dir, marker))) return dir;
69
+ for (const cmd of attempts) {
70
+ 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;
78
+ } catch {
74
79
  }
75
- const parent = path.dirname(dir);
76
- if (parent === dir) break;
77
- dir = parent;
78
80
  }
79
- return process.cwd();
81
+ return process.env.PATH || "";
80
82
  }
81
- var _WORKSPACE = process.env.WORKSPACE_DIR ?? detectWorkspaceDir();
83
+ var _WORKSPACE = process.env.WORKSPACE_DIR ?? process.cwd();
82
84
  {
83
85
  const dirsToCheck = [.../* @__PURE__ */ new Set([process.cwd(), _WORKSPACE])];
84
86
  for (const dir of dirsToCheck) {
@@ -219,6 +221,8 @@ async function main() {
219
221
  `);
220
222
  process.stderr.write(`[mention-watcher] Spawning: ${COMMAND} ${CMD_ARGS.join(" ")}
221
223
  `);
224
+ const shellPath = resolveShellPath();
225
+ const spawnEnv = { ...process.env, PATH: shellPath };
222
226
  let proc;
223
227
  try {
224
228
  proc = pty.spawn(COMMAND, CMD_ARGS, {
@@ -226,14 +230,12 @@ async function main() {
226
230
  cols,
227
231
  rows,
228
232
  cwd: WORKSPACE_DIR,
229
- env: process.env
233
+ env: spawnEnv
230
234
  });
231
235
  } catch (err) {
232
236
  process.stderr.write(`[mention-watcher] Failed to spawn "${COMMAND}": ${err.message}
233
237
  `);
234
- process.stderr.write(` Make sure "${COMMAND}" is installed and on your PATH.
235
- `);
236
- process.stderr.write(` Current PATH: ${process.env.PATH}
238
+ process.stderr.write(` Run "which ${COMMAND}" in your terminal to check it is installed.
237
239
  `);
238
240
  process.exit(1);
239
241
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-chat/mention-watcher",
3
- "version": "0.0.8",
3
+ "version": "0.1.0",
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": {