patchcord 0.3.16 → 0.3.18
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/.claude-plugin/plugin.json +1 -1
- package/bin/patchcord.mjs +62 -15
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "patchcord",
|
|
3
3
|
"description": "Cross-machine agent messaging with auto-inbox checking. Agents automatically respond to messages from other agents without human intervention.",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.18",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "ppravdin"
|
|
7
7
|
},
|
package/bin/patchcord.mjs
CHANGED
|
@@ -150,11 +150,19 @@ if (cmd === "agent") {
|
|
|
150
150
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
151
151
|
const ask = (q) => new Promise((resolve) => rl.question(q, resolve));
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const
|
|
153
|
+
const dim = "\x1b[2m";
|
|
154
|
+
const green = "\x1b[32m";
|
|
155
|
+
const red = "\x1b[31m";
|
|
156
|
+
const cyan = "\x1b[36m";
|
|
157
|
+
const white = "\x1b[37m";
|
|
158
|
+
const bold = "\x1b[1m";
|
|
159
|
+
const r = "\x1b[0m";
|
|
160
|
+
|
|
161
|
+
console.log(`\n${bold}Which tool are you setting up?${r}\n`);
|
|
162
|
+
console.log(` ${cyan}1.${r} Claude Code`);
|
|
163
|
+
console.log(` ${cyan}2.${r} Codex CLI\n`);
|
|
164
|
+
|
|
165
|
+
const choice = (await ask(`${dim}Choose (1/2):${r} `)).trim();
|
|
158
166
|
const isCodex = choice === "2";
|
|
159
167
|
|
|
160
168
|
if (choice !== "1" && choice !== "2") {
|
|
@@ -163,12 +171,50 @@ if (cmd === "agent") {
|
|
|
163
171
|
process.exit(1);
|
|
164
172
|
}
|
|
165
173
|
|
|
174
|
+
const yellow = "\x1b[33m";
|
|
175
|
+
|
|
176
|
+
// Check if already configured
|
|
177
|
+
if (!isCodex) {
|
|
178
|
+
const mcpPath = join(cwd, ".mcp.json");
|
|
179
|
+
if (existsSync(mcpPath)) {
|
|
180
|
+
try {
|
|
181
|
+
const existing = JSON.parse(readFileSync(mcpPath, "utf-8"));
|
|
182
|
+
if (existing.mcpServers?.patchcord) {
|
|
183
|
+
const existingToken = existing.mcpServers.patchcord.headers?.Authorization || "";
|
|
184
|
+
console.log(`\n ${yellow}⚠ Claude Code already configured in this project${r}`);
|
|
185
|
+
console.log(` ${dim}${mcpPath}${r}`);
|
|
186
|
+
const replace = (await ask(` ${dim}Replace? (y/N):${r} `)).trim().toLowerCase();
|
|
187
|
+
if (replace !== "y" && replace !== "yes") {
|
|
188
|
+
console.log("Keeping existing config.");
|
|
189
|
+
rl.close();
|
|
190
|
+
process.exit(0);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
} catch {}
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
const configPath = join(cwd, ".codex", "config.toml");
|
|
197
|
+
if (existsSync(configPath)) {
|
|
198
|
+
const content = readFileSync(configPath, "utf-8");
|
|
199
|
+
if (content.includes("[mcp_servers.patchcord]")) {
|
|
200
|
+
console.log(`\n ${yellow}⚠ Codex CLI already configured in this project${r}`);
|
|
201
|
+
console.log(` ${dim}${configPath}${r}`);
|
|
202
|
+
const replace = (await ask(` ${dim}Replace? (y/N):${r} `)).trim().toLowerCase();
|
|
203
|
+
if (replace !== "y" && replace !== "yes") {
|
|
204
|
+
console.log("Keeping existing config.");
|
|
205
|
+
rl.close();
|
|
206
|
+
process.exit(0);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
166
212
|
let token = "";
|
|
167
213
|
let identity = "";
|
|
168
214
|
let serverUrl = "https://mcp.patchcord.dev";
|
|
169
215
|
|
|
170
216
|
while (!identity) {
|
|
171
|
-
token = (await ask(
|
|
217
|
+
token = (await ask(`\n${bold}Paste your agent token:${r} `)).trim();
|
|
172
218
|
|
|
173
219
|
if (!token) {
|
|
174
220
|
console.error("Token is required. Get one from your patchcord dashboard.");
|
|
@@ -182,12 +228,12 @@ if (cmd === "agent") {
|
|
|
182
228
|
try {
|
|
183
229
|
const data = JSON.parse(validateResp);
|
|
184
230
|
identity = `${data.agent_id}@${data.namespace_id}`;
|
|
185
|
-
console.log(`
|
|
231
|
+
console.log(` ${green}✓${r} ${bold}${identity}${r}`);
|
|
186
232
|
} catch {}
|
|
187
233
|
}
|
|
188
234
|
if (!identity) {
|
|
189
|
-
console.log(
|
|
190
|
-
const retry = (await ask(
|
|
235
|
+
console.log(` ${red}✗${r} Token not recognized`);
|
|
236
|
+
const retry = (await ask(`${dim}Try again? (Y/n):${r} `)).trim().toLowerCase();
|
|
191
237
|
if (retry === "n" || retry === "no") {
|
|
192
238
|
rl.close();
|
|
193
239
|
process.exit(1);
|
|
@@ -195,7 +241,7 @@ if (cmd === "agent") {
|
|
|
195
241
|
}
|
|
196
242
|
}
|
|
197
243
|
|
|
198
|
-
const customUrl = (await ask(
|
|
244
|
+
const customUrl = (await ask(`\n${dim}Custom server URL? (y/N):${r} `)).trim().toLowerCase();
|
|
199
245
|
if (customUrl === "y" || customUrl === "yes") {
|
|
200
246
|
const url = (await ask("Server URL: ")).trim();
|
|
201
247
|
if (url) serverUrl = url;
|
|
@@ -208,7 +254,7 @@ if (cmd === "agent") {
|
|
|
208
254
|
try {
|
|
209
255
|
const data = JSON.parse(resp2);
|
|
210
256
|
identity = `${data.agent_id}@${data.namespace_id}`;
|
|
211
|
-
console.log(`
|
|
257
|
+
console.log(` ${green}✓${r} ${bold}${identity}${r}`);
|
|
212
258
|
} catch {}
|
|
213
259
|
}
|
|
214
260
|
}
|
|
@@ -230,8 +276,8 @@ if (cmd === "agent") {
|
|
|
230
276
|
existing = existing.trimEnd() + `\n\n[mcp_servers.patchcord]\nurl = "${serverUrl}/mcp/bearer"\nhttp_headers = { "Authorization" = "Bearer ${token}", "X-Patchcord-Client-Type" = "codex" }\n`;
|
|
231
277
|
writeFileSync(configPath, existing);
|
|
232
278
|
}
|
|
233
|
-
console.log(`\n
|
|
234
|
-
console.log(`
|
|
279
|
+
console.log(`\n ${green}✓${r} Codex configured: ${dim}${configPath}${r}`);
|
|
280
|
+
console.log(` ${green}✓${r} Skill installed`);
|
|
235
281
|
} else {
|
|
236
282
|
// Claude Code: write .mcp.json
|
|
237
283
|
const mcpPath = join(cwd, ".mcp.json");
|
|
@@ -259,10 +305,11 @@ if (cmd === "agent") {
|
|
|
259
305
|
} else {
|
|
260
306
|
writeFileSync(mcpPath, JSON.stringify(mcpConfig, null, 2) + "\n");
|
|
261
307
|
}
|
|
262
|
-
console.log(`\n
|
|
308
|
+
console.log(`\n ${green}✓${r} Claude Code configured: ${dim}${mcpPath}${r}`);
|
|
263
309
|
}
|
|
264
310
|
|
|
265
|
-
|
|
311
|
+
const toolName = isCodex ? "Codex" : "Claude Code";
|
|
312
|
+
console.log(`\n${dim}Restart your ${toolName} session, then run:${r} ${bold}inbox()${r}`);
|
|
266
313
|
process.exit(0);
|
|
267
314
|
}
|
|
268
315
|
|