patchcord 0.3.38 → 0.3.40

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/bin/patchcord.mjs +62 -6
  2. package/package.json +1 -1
package/bin/patchcord.mjs CHANGED
@@ -206,23 +206,25 @@ if (!cmd || cmd === "install" || cmd === "agent") {
206
206
  console.log(` ${cyan}3.${r} Cursor`);
207
207
  console.log(` ${cyan}4.${r} Windsurf`);
208
208
  console.log(` ${cyan}5.${r} Gemini CLI`);
209
- console.log(` ${cyan}6.${r} VS Code (Copilot)\n`);
209
+ console.log(` ${cyan}6.${r} VS Code (Copilot)`);
210
+ console.log(` ${cyan}7.${r} Zed\n`);
210
211
 
211
- const choice = (await ask(`${dim}Choose (1-6):${r} `)).trim();
212
+ const choice = (await ask(`${dim}Choose (1-7):${r} `)).trim();
212
213
  const isCodex = choice === "2";
213
214
  const isCursor = choice === "3";
214
215
  const isWindsurf = choice === "4";
215
216
  const isGemini = choice === "5";
216
217
  const isVSCode = choice === "6";
218
+ const isZed = choice === "7";
217
219
 
218
- if (!["1", "2", "3", "4", "5", "6"].includes(choice)) {
220
+ if (!["1", "2", "3", "4", "5", "6", "7"].includes(choice)) {
219
221
  console.error("Invalid choice.");
220
222
  rl.close();
221
223
  process.exit(1);
222
224
  }
223
225
 
224
- if (isWindsurf || isGemini) {
225
- const toolLabel = isWindsurf ? "Windsurf" : "Gemini CLI";
226
+ if (isWindsurf || isGemini || isZed) {
227
+ const toolLabel = isZed ? "Zed" : isWindsurf ? "Windsurf" : "Gemini CLI";
226
228
  console.log(`\n ${yellow}Note: ${toolLabel} uses global config — applies to all projects.${r}`);
227
229
  } else {
228
230
  console.log(`\n${dim}Project folder:${r} ${bold}${cwd}${r}`);
@@ -335,6 +337,25 @@ if (!cmd || cmd === "install" || cmd === "agent") {
335
337
  }
336
338
  } catch {}
337
339
  }
340
+ } else if (isZed) {
341
+ const zedPath = process.platform === "darwin"
342
+ ? join(process.env.HOME || "", "Library", "Application Support", "Zed", "settings.json")
343
+ : join(process.env.HOME || "", ".config", "zed", "settings.json");
344
+ if (existsSync(zedPath)) {
345
+ try {
346
+ const existing = JSON.parse(readFileSync(zedPath, "utf-8"));
347
+ if (existing.context_servers?.patchcord) {
348
+ console.log(`\n ${yellow}⚠ Zed already configured${r}`);
349
+ console.log(` ${dim}${zedPath}${r}`);
350
+ const replace = (await ask(` ${dim}Replace? (y/N):${r} `)).trim().toLowerCase();
351
+ if (replace !== "y" && replace !== "yes") {
352
+ console.log("Keeping existing config.");
353
+ rl.close();
354
+ process.exit(0);
355
+ }
356
+ }
357
+ } catch {}
358
+ }
338
359
  } else if (isCodex) {
339
360
  const configPath = join(cwd, ".codex", "config.toml");
340
361
  if (existsSync(configPath)) {
@@ -408,6 +429,8 @@ if (!cmd || cmd === "install" || cmd === "agent") {
408
429
 
409
430
  rl.close();
410
431
 
432
+ const hostname = run("hostname -s") || run("hostname") || "unknown";
433
+
411
434
  if (isCursor) {
412
435
  // Cursor: write .cursor/mcp.json (per-project)
413
436
  const cursorDir = join(cwd, ".cursor");
@@ -422,6 +445,8 @@ if (!cmd || cmd === "install" || cmd === "agent") {
422
445
  serverUrl,
423
446
  "--header",
424
447
  `Authorization: Bearer ${token}`,
448
+ "--header",
449
+ `X-Patchcord-Machine: ${hostname}`,
425
450
  ],
426
451
  },
427
452
  },
@@ -453,6 +478,8 @@ if (!cmd || cmd === "install" || cmd === "agent") {
453
478
  serverUrl,
454
479
  "--header",
455
480
  `Authorization: Bearer ${token}`,
481
+ "--header",
482
+ `X-Patchcord-Machine: ${hostname}`,
456
483
  ],
457
484
  },
458
485
  },
@@ -494,6 +521,7 @@ if (!cmd || cmd === "install" || cmd === "agent") {
494
521
  httpUrl: `${serverUrl}/mcp`,
495
522
  headers: {
496
523
  Authorization: `Bearer ${token}`,
524
+ "X-Patchcord-Machine": hostname,
497
525
  },
498
526
  };
499
527
  // Clean up deprecated tools.allowed if present (removed in Gemini CLI 1.0)
@@ -505,6 +533,32 @@ if (!cmd || cmd === "install" || cmd === "agent") {
505
533
  writeFileSync(geminiPath, JSON.stringify(geminiSettings, null, 2) + "\n");
506
534
  console.log(`\n ${green}✓${r} Gemini CLI configured: ${dim}${geminiPath}${r}`);
507
535
  console.log(` ${yellow}Global config — all Gemini CLI projects share this agent.${r}`);
536
+ } else if (isZed) {
537
+ // Zed: global settings.json → context_servers
538
+ const zedPath = process.platform === "darwin"
539
+ ? join(process.env.HOME || "", "Library", "Application Support", "Zed", "settings.json")
540
+ : join(process.env.HOME || "", ".config", "zed", "settings.json");
541
+ let zedSettings = {};
542
+ if (existsSync(zedPath)) {
543
+ try {
544
+ zedSettings = JSON.parse(readFileSync(zedPath, "utf-8"));
545
+ } catch {}
546
+ }
547
+ if (!zedSettings.context_servers) zedSettings.context_servers = {};
548
+ zedSettings.context_servers.patchcord = {
549
+ url: `${serverUrl}/mcp`,
550
+ headers: {
551
+ Authorization: `Bearer ${token}`,
552
+ "X-Patchcord-Machine": hostname,
553
+ },
554
+ };
555
+ const zedDir = process.platform === "darwin"
556
+ ? join(process.env.HOME || "", "Library", "Application Support", "Zed")
557
+ : join(process.env.HOME || "", ".config", "zed");
558
+ mkdirSync(zedDir, { recursive: true });
559
+ writeFileSync(zedPath, JSON.stringify(zedSettings, null, 2) + "\n");
560
+ console.log(`\n ${green}✓${r} Zed configured: ${dim}${zedPath}${r}`);
561
+ console.log(` ${yellow}Global config — all Zed projects share this agent.${r}`);
508
562
  } else if (isVSCode) {
509
563
  // VS Code: write .vscode/mcp.json (per-project)
510
564
  const vscodeDir = join(cwd, ".vscode");
@@ -517,6 +571,7 @@ if (!cmd || cmd === "install" || cmd === "agent") {
517
571
  url: `${serverUrl}/mcp`,
518
572
  headers: {
519
573
  Authorization: `Bearer ${token}`,
574
+ "X-Patchcord-Machine": hostname,
520
575
  },
521
576
  },
522
577
  },
@@ -578,6 +633,7 @@ if (!cmd || cmd === "install" || cmd === "agent") {
578
633
  url: `${serverUrl}/mcp`,
579
634
  headers: {
580
635
  Authorization: `Bearer ${token}`,
636
+ "X-Patchcord-Machine": hostname,
581
637
  },
582
638
  },
583
639
  },
@@ -598,7 +654,7 @@ if (!cmd || cmd === "install" || cmd === "agent") {
598
654
  console.log(`\n ${green}✓${r} Claude Code configured: ${dim}${mcpPath}${r}`);
599
655
  }
600
656
 
601
- const toolName = isVSCode ? "VS Code" : isGemini ? "Gemini CLI" : isWindsurf ? "Windsurf" : isCursor ? "Cursor" : isCodex ? "Codex" : "Claude Code";
657
+ const toolName = isZed ? "Zed" : isVSCode ? "VS Code" : isGemini ? "Gemini CLI" : isWindsurf ? "Windsurf" : isCursor ? "Cursor" : isCodex ? "Codex" : "Claude Code";
602
658
  console.log(`\n${dim}Restart your ${toolName} session, then run:${r} ${bold}inbox()${r}`);
603
659
  process.exit(0);
604
660
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchcord",
3
- "version": "0.3.38",
3
+ "version": "0.3.40",
4
4
  "description": "Cross-machine agent messaging for Claude Code and Codex",
5
5
  "author": "ppravdin",
6
6
  "license": "MIT",