@elliotding/ai-agent-mcp 0.1.7 → 0.1.9

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.
@@ -29,6 +29,11 @@ export const CURSOR_TYPE_DIRS: Record<string, string> = {
29
29
  *
30
30
  * macOS / Linux : ~/.cursor
31
31
  * Windows : %APPDATA%\Cursor\User
32
+ *
33
+ * NOTE: Only use this when running code on the USER's local machine.
34
+ * When generating paths for LocalAction instructions (which are executed by the
35
+ * AI on the user's machine, not on this server), use getCursorRootDirForClient()
36
+ * instead to avoid returning the server's home directory.
32
37
  */
33
38
  export function getCursorRootDir(): string {
34
39
  if (process.platform === 'win32') {
@@ -40,6 +45,40 @@ export function getCursorRootDir(): string {
40
45
  return path.join(os.homedir(), '.cursor');
41
46
  }
42
47
 
48
+ /**
49
+ * Returns a platform-neutral Cursor root path for use in LocalAction instructions.
50
+ *
51
+ * LocalAction paths are sent to the AI Agent running on the USER's local machine,
52
+ * not executed on this (possibly remote) server. Using os.homedir() here would
53
+ * produce the server's home directory (e.g. /root/.cursor on a Linux server),
54
+ * which is wrong when the user is on macOS or Windows.
55
+ *
56
+ * We return a tilde-prefixed path ("~/.cursor") which the AI / shell on the
57
+ * user's machine will expand to the correct home directory automatically.
58
+ * For Windows we still return the APPDATA-relative form as a hint, but note
59
+ * that the AI is expected to expand %APPDATA% on the client side.
60
+ */
61
+ export function getCursorRootDirForClient(): string {
62
+ // Return a portable ~-based path; the AI on the user's machine expands it.
63
+ return '~/.cursor';
64
+ }
65
+
66
+ /**
67
+ * Returns the Cursor subdirectory for a given resource type, using a
68
+ * client-side portable path (tilde-based). Use this when building paths
69
+ * that will be included in LocalAction instructions.
70
+ */
71
+ export function getCursorTypeDirForClient(resourceType: string): string {
72
+ const subdir = CURSOR_TYPE_DIRS[resourceType.toLowerCase()];
73
+ if (!subdir) {
74
+ throw new Error(
75
+ `Unknown resource type "${resourceType}". ` +
76
+ `Supported types: ${Object.keys(CURSOR_TYPE_DIRS).join(', ')}`
77
+ );
78
+ }
79
+ return `${getCursorRootDirForClient()}/${subdir}`;
80
+ }
81
+
43
82
  /**
44
83
  * Returns the Cursor subdirectory for a given resource type.
45
84
  *