pindrop 0.1.4 → 0.1.6
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/README.md +2 -1
- package/cli.mjs +124 -13
- package/lib/auth.mjs +200 -6
- package/lib/client.mjs +22 -7
- package/lib/project.mjs +56 -2
- package/lib/skill.mjs +34 -2
- package/package.json +1 -1
- package/skill/SKILL.md +4 -0
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Works in any coding agent (Claude Code, Codex, Cursor, Antigravity, Gemini CLI,
|
|
|
7
7
|
## Quick start
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
npx -y pindrop init
|
|
10
|
+
npx -y pindrop@latest init
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
Or install globally:
|
|
@@ -23,6 +23,7 @@ On first run, `pindrop` opens PinDrop in your browser (PKCE OAuth), saves creden
|
|
|
23
23
|
|
|
24
24
|
```sh
|
|
25
25
|
pindrop create [url] # create (or reuse) a project review link
|
|
26
|
+
pindrop link [projectId] # save .pindrop.json in this repo for your team
|
|
26
27
|
pindrop projects # list active projects
|
|
27
28
|
pindrop pins # list open pins for this repo
|
|
28
29
|
pindrop pin 4 --screenshot # full context + save screenshot locally
|
package/cli.mjs
CHANGED
|
@@ -3,9 +3,11 @@ import { mkdirSync, realpathSync, writeFileSync } from "node:fs";
|
|
|
3
3
|
import { dirname, join, resolve } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import {
|
|
6
|
+
completePairing,
|
|
6
7
|
getLinkedProject,
|
|
7
8
|
getSavedProfile,
|
|
8
9
|
loginWithBrowser,
|
|
10
|
+
loginWithPairing,
|
|
9
11
|
openInBrowser,
|
|
10
12
|
resolveMcpUrl,
|
|
11
13
|
revokeAndLogout,
|
|
@@ -13,10 +15,15 @@ import {
|
|
|
13
15
|
saveLinkedProject,
|
|
14
16
|
} from "./lib/auth.mjs";
|
|
15
17
|
import { CliError, callPinDropTool, callSandboxApi } from "./lib/client.mjs";
|
|
16
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
inferProjectHint,
|
|
20
|
+
inferSiteUrl,
|
|
21
|
+
readRepoProjectConfig,
|
|
22
|
+
writeRepoProjectConfig,
|
|
23
|
+
} from "./lib/project.mjs";
|
|
17
24
|
import { installSkillFiles } from "./lib/skill.mjs";
|
|
18
25
|
|
|
19
|
-
const VERSION = "0.1.
|
|
26
|
+
const VERSION = "0.1.6";
|
|
20
27
|
|
|
21
28
|
function parseArgv(argv) {
|
|
22
29
|
const positionals = [];
|
|
@@ -131,6 +138,10 @@ function announceBrowserAuth(url) {
|
|
|
131
138
|
process.stderr.write(`If it didn't open, visit:\n${url}\n`);
|
|
132
139
|
}
|
|
133
140
|
|
|
141
|
+
function announcePairingWait() {
|
|
142
|
+
process.stderr.write(`Approve PinDrop in your open browser tab…\n`);
|
|
143
|
+
}
|
|
144
|
+
|
|
134
145
|
function parsePinNumber(raw) {
|
|
135
146
|
const cleaned = String(raw || "").replace(/^#/, "");
|
|
136
147
|
const n = Number(cleaned);
|
|
@@ -140,10 +151,14 @@ function parsePinNumber(raw) {
|
|
|
140
151
|
return n;
|
|
141
152
|
}
|
|
142
153
|
|
|
154
|
+
function resolveSavedProjectLink(mcpUrl) {
|
|
155
|
+
return readRepoProjectConfig() ?? getLinkedProject(mcpUrl);
|
|
156
|
+
}
|
|
157
|
+
|
|
143
158
|
async function resolveProjectIdForPin({ mcpUrl, flags, autoLogin }) {
|
|
144
159
|
const explicit = flagStr(flags, "project", "p", "project-id");
|
|
145
160
|
if (explicit) return explicit;
|
|
146
|
-
const linked =
|
|
161
|
+
const linked = resolveSavedProjectLink(mcpUrl);
|
|
147
162
|
if (linked?.projectId && !flagStr(flags, "hint")) {
|
|
148
163
|
return linked.projectId;
|
|
149
164
|
}
|
|
@@ -195,7 +210,7 @@ function writeProjectNextSteps(projectId) {
|
|
|
195
210
|
`Next: send the review link (no client account or script tag needed).\n`,
|
|
196
211
|
);
|
|
197
212
|
process.stdout.write(
|
|
198
|
-
`Commands: npx -y pindrop pins${flag} · npx -y pindrop pin <n> --screenshot${flag} · npx -y pindrop resolve <n>${flag} --comment "<what changed>"\n`,
|
|
213
|
+
`Commands: npx -y pindrop@latest pins${flag} · npx -y pindrop@latest pin <n> --screenshot${flag} · npx -y pindrop@latest resolve <n>${flag} --comment "<what changed>"\n`,
|
|
199
214
|
);
|
|
200
215
|
}
|
|
201
216
|
|
|
@@ -210,6 +225,7 @@ Usage:
|
|
|
210
225
|
|
|
211
226
|
pindrop projects List active PinDrop projects
|
|
212
227
|
pindrop create [url] [--open] Create (or reuse) a review link for a live URL
|
|
228
|
+
pindrop link [projectId] Save .pindrop.json in this repo for your team
|
|
213
229
|
pindrop open [n] [--project <id>] Open the review link (or pin #n) in your browser
|
|
214
230
|
pindrop pins [--watch] [--once] [--project <id>] [--resolved] [--full] [--json]
|
|
215
231
|
List (or live-watch) pins for this repo
|
|
@@ -258,6 +274,7 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
258
274
|
const autoLogin = !flags["no-login"];
|
|
259
275
|
const openBrowser = !flags["no-browser"];
|
|
260
276
|
const asJson = Boolean(flags.json);
|
|
277
|
+
const pairId = flagStr(flags, "pair");
|
|
261
278
|
|
|
262
279
|
switch (cmd) {
|
|
263
280
|
case "login": {
|
|
@@ -268,6 +285,18 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
268
285
|
else process.stdout.write(`Saved API key for ${mcpUrl}\n`);
|
|
269
286
|
return 0;
|
|
270
287
|
}
|
|
288
|
+
if (pairId) {
|
|
289
|
+
const paired = await loginWithPairing({
|
|
290
|
+
mcpUrl,
|
|
291
|
+
pairId,
|
|
292
|
+
onWaiting: announcePairingWait,
|
|
293
|
+
});
|
|
294
|
+
if (paired?.token) {
|
|
295
|
+
if (asJson) printJson({ ok: true, mode: "paired", mcpUrl });
|
|
296
|
+
else process.stdout.write(`Connected to PinDrop (${mcpUrl})\n`);
|
|
297
|
+
return 0;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
271
300
|
await loginWithBrowser({
|
|
272
301
|
mcpUrl,
|
|
273
302
|
openBrowser,
|
|
@@ -322,11 +351,21 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
322
351
|
});
|
|
323
352
|
|
|
324
353
|
if (!targetUrl) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
354
|
+
let paired = null;
|
|
355
|
+
if (pairId) {
|
|
356
|
+
paired = await loginWithPairing({
|
|
357
|
+
mcpUrl,
|
|
358
|
+
pairId,
|
|
359
|
+
onWaiting: announcePairingWait,
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
if (!paired?.token) {
|
|
363
|
+
await loginWithBrowser({
|
|
364
|
+
mcpUrl,
|
|
365
|
+
openBrowser,
|
|
366
|
+
onAuthorizeUrl: announceBrowserAuth,
|
|
367
|
+
});
|
|
368
|
+
}
|
|
330
369
|
if (asJson) {
|
|
331
370
|
printJson({ ok: true, connected: true, skills: skillResults, project: null });
|
|
332
371
|
} else {
|
|
@@ -348,6 +387,9 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
348
387
|
args: { targetUrl, ...(title ? { title } : {}) },
|
|
349
388
|
autoLogin,
|
|
350
389
|
openBrowser,
|
|
390
|
+
pairId,
|
|
391
|
+
targetUrl,
|
|
392
|
+
onPairingWaiting: announcePairingWait,
|
|
351
393
|
onAuthorizeUrl: announceBrowserAuth,
|
|
352
394
|
});
|
|
353
395
|
const p = res.structured || {};
|
|
@@ -357,6 +399,18 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
357
399
|
shareUrl: p.shareUrl,
|
|
358
400
|
targetUrl: p.targetUrl || targetUrl,
|
|
359
401
|
});
|
|
402
|
+
if (pairId && p.shareUrl) {
|
|
403
|
+
await completePairing({
|
|
404
|
+
mcpUrl,
|
|
405
|
+
pairId,
|
|
406
|
+
cliSecret: res.cliSecret,
|
|
407
|
+
token: res.authToken,
|
|
408
|
+
projectId: p.projectId,
|
|
409
|
+
shareUrl: p.shareUrl,
|
|
410
|
+
targetUrl: p.targetUrl || targetUrl,
|
|
411
|
+
projectTitle: p.title || title,
|
|
412
|
+
});
|
|
413
|
+
}
|
|
360
414
|
}
|
|
361
415
|
const shouldOpen = Boolean((flags.open || p.isFirstProject) && openBrowser && p.shareUrl);
|
|
362
416
|
if (shouldOpen) openInBrowser(p.shareUrl);
|
|
@@ -376,8 +430,10 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
376
430
|
if (p.projectId) process.stdout.write(`Project ID: ${p.projectId}\n`);
|
|
377
431
|
if (shouldOpen) process.stderr.write(`Opened review link in your browser.\n`);
|
|
378
432
|
for (const r of skillResults) {
|
|
379
|
-
if (r.status === "installed") {
|
|
380
|
-
process.stdout.write(
|
|
433
|
+
if (r.status === "installed" || r.status === "updated") {
|
|
434
|
+
process.stdout.write(
|
|
435
|
+
`${r.status === "updated" ? "Updated" : "Installed"} skill: ${r.path}\n`,
|
|
436
|
+
);
|
|
381
437
|
}
|
|
382
438
|
}
|
|
383
439
|
writeProjectNextSteps(p.projectId);
|
|
@@ -392,6 +448,8 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
392
448
|
args: {},
|
|
393
449
|
autoLogin,
|
|
394
450
|
openBrowser,
|
|
451
|
+
pairId,
|
|
452
|
+
onPairingWaiting: announcePairingWait,
|
|
395
453
|
onAuthorizeUrl: announceBrowserAuth,
|
|
396
454
|
});
|
|
397
455
|
if (asJson) {
|
|
@@ -435,6 +493,9 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
435
493
|
args: { targetUrl, ...(title ? { title } : {}) },
|
|
436
494
|
autoLogin,
|
|
437
495
|
openBrowser,
|
|
496
|
+
pairId,
|
|
497
|
+
targetUrl,
|
|
498
|
+
onPairingWaiting: announcePairingWait,
|
|
438
499
|
onAuthorizeUrl: announceBrowserAuth,
|
|
439
500
|
});
|
|
440
501
|
const p = res.structured || {};
|
|
@@ -444,6 +505,18 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
444
505
|
shareUrl: p.shareUrl,
|
|
445
506
|
targetUrl: p.targetUrl || targetUrl,
|
|
446
507
|
});
|
|
508
|
+
if (pairId && p.shareUrl) {
|
|
509
|
+
await completePairing({
|
|
510
|
+
mcpUrl,
|
|
511
|
+
pairId,
|
|
512
|
+
cliSecret: res.cliSecret,
|
|
513
|
+
token: res.authToken,
|
|
514
|
+
projectId: p.projectId,
|
|
515
|
+
shareUrl: p.shareUrl,
|
|
516
|
+
targetUrl: p.targetUrl || targetUrl,
|
|
517
|
+
projectTitle: p.title || title,
|
|
518
|
+
});
|
|
519
|
+
}
|
|
447
520
|
}
|
|
448
521
|
const shouldOpen = Boolean((flags.open || p.isFirstProject) && openBrowser && p.shareUrl);
|
|
449
522
|
if (shouldOpen) openInBrowser(p.shareUrl);
|
|
@@ -466,6 +539,40 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
466
539
|
return 0;
|
|
467
540
|
}
|
|
468
541
|
|
|
542
|
+
case "link": {
|
|
543
|
+
const explicitProject = positionals[1] || flagStr(flags, "project", "p", "project-id");
|
|
544
|
+
const existingLink = resolveSavedProjectLink(mcpUrl);
|
|
545
|
+
let projectId = explicitProject || existingLink?.projectId || null;
|
|
546
|
+
let shareUrl = explicitProject ? null : existingLink?.shareUrl || null;
|
|
547
|
+
let targetUrl = explicitProject ? null : existingLink?.targetUrl || null;
|
|
548
|
+
|
|
549
|
+
if (!projectId) {
|
|
550
|
+
projectId = await resolveProjectIdForPin({ mcpUrl, flags, autoLogin });
|
|
551
|
+
}
|
|
552
|
+
if (!shareUrl) {
|
|
553
|
+
shareUrl = `https://www.pindrop.page/s/${encodeURIComponent(projectId)}`;
|
|
554
|
+
}
|
|
555
|
+
const written = writeRepoProjectConfig(process.cwd(), {
|
|
556
|
+
projectId,
|
|
557
|
+
shareUrl,
|
|
558
|
+
targetUrl,
|
|
559
|
+
});
|
|
560
|
+
saveLinkedProject(mcpUrl, process.cwd(), {
|
|
561
|
+
projectId,
|
|
562
|
+
shareUrl,
|
|
563
|
+
targetUrl,
|
|
564
|
+
});
|
|
565
|
+
if (asJson) {
|
|
566
|
+
printJson({ ok: true, ...written });
|
|
567
|
+
} else {
|
|
568
|
+
process.stdout.write(`Linked repo to project ${projectId} -> ${written.path}\n`);
|
|
569
|
+
process.stdout.write(
|
|
570
|
+
`Commit .pindrop.json (no secrets) so teammates automatically target this project.\n`,
|
|
571
|
+
);
|
|
572
|
+
}
|
|
573
|
+
return 0;
|
|
574
|
+
}
|
|
575
|
+
|
|
469
576
|
case "open": {
|
|
470
577
|
if (positionals[1]) {
|
|
471
578
|
const pinNumber = parsePinNumber(positionals[1]);
|
|
@@ -486,7 +593,7 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
486
593
|
return 0;
|
|
487
594
|
}
|
|
488
595
|
const explicitProject = flagStr(flags, "project", "p", "project-id");
|
|
489
|
-
const linked = !explicitProject ?
|
|
596
|
+
const linked = !explicitProject ? resolveSavedProjectLink(mcpUrl) : null;
|
|
490
597
|
let url = linked?.shareUrl || null;
|
|
491
598
|
let projectId = explicitProject || linked?.projectId || null;
|
|
492
599
|
if (!url) {
|
|
@@ -503,7 +610,9 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
503
610
|
case "pins": {
|
|
504
611
|
const explicitProject = flagStr(flags, "project", "p", "project-id");
|
|
505
612
|
const linkedProject =
|
|
506
|
-
!explicitProject && !flagStr(flags, "hint")
|
|
613
|
+
!explicitProject && !flagStr(flags, "hint")
|
|
614
|
+
? resolveSavedProjectLink(mcpUrl)?.projectId
|
|
615
|
+
: undefined;
|
|
507
616
|
const projectId = explicitProject || linkedProject;
|
|
508
617
|
const hint = projectId ? undefined : flagStr(flags, "hint") || inferProjectHint();
|
|
509
618
|
const limit = flagInt(flags, "limit", "n");
|
|
@@ -589,6 +698,8 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
589
698
|
args,
|
|
590
699
|
autoLogin,
|
|
591
700
|
openBrowser,
|
|
701
|
+
pairId,
|
|
702
|
+
onPairingWaiting: announcePairingWait,
|
|
592
703
|
onAuthorizeUrl: announceBrowserAuth,
|
|
593
704
|
});
|
|
594
705
|
if (asJson) {
|
package/lib/auth.mjs
CHANGED
|
@@ -11,13 +11,48 @@ import {
|
|
|
11
11
|
} from "node:fs";
|
|
12
12
|
import { createServer } from "node:http";
|
|
13
13
|
import { homedir, platform } from "node:os";
|
|
14
|
-
import { dirname, join, resolve } from "node:path";
|
|
14
|
+
import { dirname, join, resolve, basename } from "node:path";
|
|
15
15
|
|
|
16
16
|
export const DEFAULT_MCP_URL = "https://mcp.pindrop.page";
|
|
17
17
|
const EXPIRY_BUFFER_MS = 60_000;
|
|
18
18
|
const LOGIN_TIMEOUT_MS = 180_000;
|
|
19
|
+
const PAIR_POLL_INTERVAL_MS = 1_000;
|
|
19
20
|
const FETCH_RETRY_DELAY_MS = 400;
|
|
20
21
|
|
|
22
|
+
export function detectAgentName(env = process.env) {
|
|
23
|
+
if (env.CLAUDECODE || env.CLAUDE_CODE_ENTRYPOINT || env.CLAUDE_CODE_SSE_PORT) {
|
|
24
|
+
return "Claude Code";
|
|
25
|
+
}
|
|
26
|
+
if (env.CODEX_SANDBOX || env.CODEX_THREAD_ID || env.CODEX_CI || env.OPENAI_CODEX) {
|
|
27
|
+
return "Codex";
|
|
28
|
+
}
|
|
29
|
+
if (env.CURSOR_AGENT || env.CURSOR_TRACE_ID || env.TERM_PROGRAM === "cursor") {
|
|
30
|
+
return "Cursor";
|
|
31
|
+
}
|
|
32
|
+
if (env.ANTIGRAVITY_AGENT || env.AGY_SESSION_ID) {
|
|
33
|
+
return "Antigravity";
|
|
34
|
+
}
|
|
35
|
+
if (env.GEMINI_CLI) {
|
|
36
|
+
return "Gemini CLI";
|
|
37
|
+
}
|
|
38
|
+
if (env.GROK_BUILD) {
|
|
39
|
+
return "Grok";
|
|
40
|
+
}
|
|
41
|
+
if (env.VSCODE_PID || env.TERM_PROGRAM === "vscode") {
|
|
42
|
+
return "VS Code";
|
|
43
|
+
}
|
|
44
|
+
return "PinDrop CLI";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function detectMachineLabel(cwd = process.cwd()) {
|
|
48
|
+
const folder = basename(resolve(cwd));
|
|
49
|
+
return folder && folder !== "/" ? folder : undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function pairBaseUrl(mcpUrl) {
|
|
53
|
+
return resolveMcpUrl(mcpUrl).replace(/\/mcp$/, "");
|
|
54
|
+
}
|
|
55
|
+
|
|
21
56
|
export async function fetchWithRetry(url, init, fetchImpl = fetch) {
|
|
22
57
|
let lastErr;
|
|
23
58
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
@@ -570,43 +605,202 @@ export async function revokeAndLogout(mcpUrl, fetchImpl = fetch) {
|
|
|
570
605
|
return clearProfile(mcpUrl);
|
|
571
606
|
}
|
|
572
607
|
|
|
608
|
+
export async function loginWithPairing({
|
|
609
|
+
mcpUrl,
|
|
610
|
+
pairId,
|
|
611
|
+
agentName = detectAgentName(),
|
|
612
|
+
machineLabel = detectMachineLabel(),
|
|
613
|
+
targetUrl,
|
|
614
|
+
timeoutMs = LOGIN_TIMEOUT_MS,
|
|
615
|
+
pollIntervalMs = PAIR_POLL_INTERVAL_MS,
|
|
616
|
+
onWaiting,
|
|
617
|
+
fetchImpl = fetch,
|
|
618
|
+
}) {
|
|
619
|
+
if (!pairId || typeof pairId !== "string") return null;
|
|
620
|
+
const cleanedPairId = pairId.trim();
|
|
621
|
+
if (!/^pair_[a-f0-9]{16}$/.test(cleanedPairId)) return null;
|
|
622
|
+
|
|
623
|
+
const base = pairBaseUrl(mcpUrl);
|
|
624
|
+
const cliSecret = randomBytes(16).toString("hex");
|
|
625
|
+
|
|
626
|
+
let connectResp;
|
|
627
|
+
try {
|
|
628
|
+
connectResp = await fetchWithRetry(
|
|
629
|
+
`${base}/api/v1/pair/connect`,
|
|
630
|
+
{
|
|
631
|
+
method: "POST",
|
|
632
|
+
headers: {
|
|
633
|
+
"Content-Type": "application/json",
|
|
634
|
+
Accept: "application/json",
|
|
635
|
+
},
|
|
636
|
+
body: JSON.stringify({
|
|
637
|
+
pairId: cleanedPairId,
|
|
638
|
+
cliSecret,
|
|
639
|
+
agentName,
|
|
640
|
+
...(machineLabel ? { machineLabel } : {}),
|
|
641
|
+
...(targetUrl ? { targetUrl } : {}),
|
|
642
|
+
}),
|
|
643
|
+
},
|
|
644
|
+
fetchImpl,
|
|
645
|
+
);
|
|
646
|
+
} catch {
|
|
647
|
+
return null;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
const connectData = await connectResp.json().catch(() => ({}));
|
|
651
|
+
if (!connectResp.ok || !connectData.ok) {
|
|
652
|
+
return null;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
onWaiting?.({ pairId: cleanedPairId, agentName, machineLabel });
|
|
656
|
+
|
|
657
|
+
const deadline = Date.now() + timeoutMs;
|
|
658
|
+
while (Date.now() < deadline) {
|
|
659
|
+
await new Promise((r) => setTimeout(r, pollIntervalMs));
|
|
660
|
+
let pollResp;
|
|
661
|
+
try {
|
|
662
|
+
pollResp = await fetchImpl(`${base}/api/v1/pair/poll`, {
|
|
663
|
+
method: "POST",
|
|
664
|
+
headers: {
|
|
665
|
+
"Content-Type": "application/json",
|
|
666
|
+
Accept: "application/json",
|
|
667
|
+
},
|
|
668
|
+
body: JSON.stringify({
|
|
669
|
+
pairId: cleanedPairId,
|
|
670
|
+
cliSecret,
|
|
671
|
+
}),
|
|
672
|
+
});
|
|
673
|
+
} catch {
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
const pollData = await pollResp.json().catch(() => ({}));
|
|
678
|
+
if (pollData.status === "approved" && typeof pollData.token === "string") {
|
|
679
|
+
const profile = saveApiKeyProfile(mcpUrl, pollData.token);
|
|
680
|
+
return {
|
|
681
|
+
profile,
|
|
682
|
+
token: pollData.token,
|
|
683
|
+
cliSecret,
|
|
684
|
+
ownerEmail: pollData.ownerEmail ?? null,
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
if (pollData.status === "denied") {
|
|
688
|
+
throw new Error("Connection was canceled in your browser tab.");
|
|
689
|
+
}
|
|
690
|
+
if (
|
|
691
|
+
pollData.status === "expired" ||
|
|
692
|
+
pollData.status === "not_found" ||
|
|
693
|
+
pollData.status === "unauthorized" ||
|
|
694
|
+
pollData.status === "already_claimed"
|
|
695
|
+
) {
|
|
696
|
+
return null;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
return null;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
export async function completePairing({
|
|
704
|
+
mcpUrl,
|
|
705
|
+
pairId,
|
|
706
|
+
cliSecret,
|
|
707
|
+
token,
|
|
708
|
+
agentName = detectAgentName(),
|
|
709
|
+
projectId,
|
|
710
|
+
shareUrl,
|
|
711
|
+
targetUrl,
|
|
712
|
+
projectTitle,
|
|
713
|
+
fetchImpl = fetch,
|
|
714
|
+
}) {
|
|
715
|
+
if (!pairId || !projectId || !shareUrl) return false;
|
|
716
|
+
const cleanedPairId = String(pairId).trim();
|
|
717
|
+
if (!/^pair_[a-f0-9]{16}$/.test(cleanedPairId)) return false;
|
|
718
|
+
|
|
719
|
+
const base = pairBaseUrl(mcpUrl);
|
|
720
|
+
const headers = {
|
|
721
|
+
"Content-Type": "application/json",
|
|
722
|
+
Accept: "application/json",
|
|
723
|
+
};
|
|
724
|
+
if (token) {
|
|
725
|
+
headers.Authorization = `Bearer ${token}`;
|
|
726
|
+
}
|
|
727
|
+
try {
|
|
728
|
+
const resp = await fetchImpl(`${base}/api/v1/pair/complete`, {
|
|
729
|
+
method: "POST",
|
|
730
|
+
headers,
|
|
731
|
+
body: JSON.stringify({
|
|
732
|
+
pairId: cleanedPairId,
|
|
733
|
+
...(cliSecret ? { cliSecret } : {}),
|
|
734
|
+
agentName,
|
|
735
|
+
projectId,
|
|
736
|
+
shareUrl,
|
|
737
|
+
...(targetUrl ? { targetUrl } : {}),
|
|
738
|
+
...(projectTitle ? { projectTitle } : {}),
|
|
739
|
+
}),
|
|
740
|
+
});
|
|
741
|
+
return resp.ok;
|
|
742
|
+
} catch {
|
|
743
|
+
return false;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
573
747
|
export async function resolveBearerToken({
|
|
574
748
|
mcpUrl,
|
|
575
749
|
autoLogin = false,
|
|
576
750
|
openBrowser = true,
|
|
751
|
+
pairId,
|
|
752
|
+
targetUrl,
|
|
753
|
+
onPairingWaiting,
|
|
577
754
|
onAuthorizeUrl,
|
|
578
755
|
fetchImpl = fetch,
|
|
579
756
|
}) {
|
|
580
757
|
const envKey = process.env.PINDROP_API_KEY?.trim();
|
|
581
758
|
if (envKey) {
|
|
582
|
-
return { token: envKey, source: "env", profile: null };
|
|
759
|
+
return { token: envKey, source: "env", profile: null, cliSecret: null };
|
|
583
760
|
}
|
|
584
761
|
|
|
585
762
|
const saved = getSavedProfile(mcpUrl);
|
|
586
763
|
if (saved?.type === "api_key" && saved.apiKey) {
|
|
587
|
-
return { token: saved.apiKey, source: "api_key", profile: saved };
|
|
764
|
+
return { token: saved.apiKey, source: "api_key", profile: saved, cliSecret: null };
|
|
588
765
|
}
|
|
589
766
|
|
|
590
767
|
if (saved?.type === "oauth" && saved.accessToken) {
|
|
591
768
|
const expired =
|
|
592
769
|
typeof saved.expiresAt === "number" && Date.now() + EXPIRY_BUFFER_MS >= saved.expiresAt;
|
|
593
770
|
if (!expired) {
|
|
594
|
-
return { token: saved.accessToken, source: "oauth", profile: saved };
|
|
771
|
+
return { token: saved.accessToken, source: "oauth", profile: saved, cliSecret: null };
|
|
595
772
|
}
|
|
596
773
|
const refreshed = await refreshSavedToken(mcpUrl, saved, fetchImpl);
|
|
597
774
|
if (refreshed?.accessToken) {
|
|
598
|
-
return { token: refreshed.accessToken, source: "oauth", profile: refreshed };
|
|
775
|
+
return { token: refreshed.accessToken, source: "oauth", profile: refreshed, cliSecret: null };
|
|
599
776
|
}
|
|
600
777
|
}
|
|
601
778
|
|
|
602
779
|
if (autoLogin) {
|
|
780
|
+
if (pairId) {
|
|
781
|
+
const paired = await loginWithPairing({
|
|
782
|
+
mcpUrl,
|
|
783
|
+
pairId,
|
|
784
|
+
targetUrl,
|
|
785
|
+
onWaiting: onPairingWaiting,
|
|
786
|
+
fetchImpl,
|
|
787
|
+
});
|
|
788
|
+
if (paired?.token) {
|
|
789
|
+
return {
|
|
790
|
+
token: paired.token,
|
|
791
|
+
source: "paired",
|
|
792
|
+
profile: paired.profile,
|
|
793
|
+
cliSecret: paired.cliSecret,
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
}
|
|
603
797
|
const loggedIn = await loginWithBrowser({
|
|
604
798
|
mcpUrl,
|
|
605
799
|
openBrowser,
|
|
606
800
|
onAuthorizeUrl,
|
|
607
801
|
fetchImpl,
|
|
608
802
|
});
|
|
609
|
-
return { token: loggedIn.accessToken, source: "oauth", profile: loggedIn };
|
|
803
|
+
return { token: loggedIn.accessToken, source: "oauth", profile: loggedIn, cliSecret: null };
|
|
610
804
|
}
|
|
611
805
|
|
|
612
806
|
return null;
|
package/lib/client.mjs
CHANGED
|
@@ -20,7 +20,7 @@ async function postMcp(mcpUrl, token, toolName, args, fetchImpl = fetch) {
|
|
|
20
20
|
"Content-Type": "application/json",
|
|
21
21
|
Accept: "application/json, text/event-stream",
|
|
22
22
|
Authorization: `Bearer ${token}`,
|
|
23
|
-
"User-Agent": "pindrop-cli/0.1.
|
|
23
|
+
"User-Agent": "pindrop-cli/0.1.6",
|
|
24
24
|
},
|
|
25
25
|
body: JSON.stringify({
|
|
26
26
|
jsonrpc: "2.0",
|
|
@@ -56,13 +56,19 @@ export async function callPinDropTool({
|
|
|
56
56
|
args = {},
|
|
57
57
|
autoLogin = false,
|
|
58
58
|
openBrowser = true,
|
|
59
|
+
pairId,
|
|
60
|
+
targetUrl,
|
|
61
|
+
onPairingWaiting,
|
|
59
62
|
onAuthorizeUrl,
|
|
60
63
|
fetchImpl = fetch,
|
|
61
64
|
}) {
|
|
62
|
-
|
|
65
|
+
let auth = await resolveBearerToken({
|
|
63
66
|
mcpUrl,
|
|
64
67
|
autoLogin,
|
|
65
68
|
openBrowser,
|
|
69
|
+
pairId,
|
|
70
|
+
targetUrl,
|
|
71
|
+
onPairingWaiting,
|
|
66
72
|
onAuthorizeUrl,
|
|
67
73
|
fetchImpl,
|
|
68
74
|
});
|
|
@@ -73,12 +79,14 @@ export async function callPinDropTool({
|
|
|
73
79
|
);
|
|
74
80
|
}
|
|
75
81
|
|
|
76
|
-
let
|
|
82
|
+
let activeToken = auth.token;
|
|
83
|
+
let res = await postMcp(mcpUrl, activeToken, toolName, args, fetchImpl);
|
|
77
84
|
|
|
78
85
|
if (res.status === 401 && auth.source === "oauth" && auth.profile) {
|
|
79
86
|
const refreshed = await refreshSavedToken(mcpUrl, auth.profile, fetchImpl);
|
|
80
87
|
if (refreshed?.accessToken) {
|
|
81
|
-
|
|
88
|
+
activeToken = refreshed.accessToken;
|
|
89
|
+
res = await postMcp(mcpUrl, activeToken, toolName, args, fetchImpl);
|
|
82
90
|
}
|
|
83
91
|
}
|
|
84
92
|
|
|
@@ -88,11 +96,16 @@ export async function callPinDropTool({
|
|
|
88
96
|
mcpUrl,
|
|
89
97
|
autoLogin: true,
|
|
90
98
|
openBrowser,
|
|
99
|
+
pairId,
|
|
100
|
+
targetUrl,
|
|
101
|
+
onPairingWaiting,
|
|
91
102
|
onAuthorizeUrl,
|
|
92
103
|
fetchImpl,
|
|
93
104
|
});
|
|
94
|
-
if (fresh?.token && fresh.token !==
|
|
95
|
-
|
|
105
|
+
if (fresh?.token && fresh.token !== activeToken) {
|
|
106
|
+
auth = fresh;
|
|
107
|
+
activeToken = fresh.token;
|
|
108
|
+
res = await postMcp(mcpUrl, activeToken, toolName, args, fetchImpl);
|
|
96
109
|
}
|
|
97
110
|
}
|
|
98
111
|
}
|
|
@@ -137,6 +150,8 @@ export async function callPinDropTool({
|
|
|
137
150
|
structured: result.structuredContent ?? null,
|
|
138
151
|
text: textBlocks.join("\n").trim(),
|
|
139
152
|
content: Array.isArray(result.content) ? result.content : [],
|
|
153
|
+
authToken: activeToken,
|
|
154
|
+
cliSecret: auth.cliSecret ?? null,
|
|
140
155
|
};
|
|
141
156
|
}
|
|
142
157
|
|
|
@@ -156,7 +171,7 @@ export async function callSandboxApi({
|
|
|
156
171
|
headers: {
|
|
157
172
|
Accept: "application/json",
|
|
158
173
|
Authorization: `Sandbox ${claimCode}`,
|
|
159
|
-
"User-Agent": "pindrop-cli/0.1.
|
|
174
|
+
"User-Agent": "pindrop-cli/0.1.6",
|
|
160
175
|
...(body !== undefined ? { "Content-Type": "application/json" } : {}),
|
|
161
176
|
},
|
|
162
177
|
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
package/lib/project.mjs
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
import { execFileSync } from "node:child_process";
|
|
2
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
-
import { basename, join } from "node:path";
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
4
|
+
|
|
5
|
+
export const REPO_CONFIG_FILENAME = ".pindrop.json";
|
|
6
|
+
|
|
7
|
+
export function readRepoProjectConfig(cwd = process.cwd()) {
|
|
8
|
+
let dir = resolve(cwd);
|
|
9
|
+
for (let depth = 0; depth < 25; depth += 1) {
|
|
10
|
+
const file = join(dir, REPO_CONFIG_FILENAME);
|
|
11
|
+
if (existsSync(file)) {
|
|
12
|
+
try {
|
|
13
|
+
const parsed = JSON.parse(readFileSync(file, "utf8"));
|
|
14
|
+
const projectId =
|
|
15
|
+
typeof parsed?.projectId === "string" && parsed.projectId.trim().length > 0
|
|
16
|
+
? parsed.projectId.trim()
|
|
17
|
+
: null;
|
|
18
|
+
if (projectId) {
|
|
19
|
+
return {
|
|
20
|
+
path: file,
|
|
21
|
+
projectId,
|
|
22
|
+
shareUrl:
|
|
23
|
+
typeof parsed.shareUrl === "string" && parsed.shareUrl.trim().length > 0
|
|
24
|
+
? parsed.shareUrl.trim()
|
|
25
|
+
: null,
|
|
26
|
+
targetUrl:
|
|
27
|
+
typeof parsed.targetUrl === "string" && parsed.targetUrl.trim().length > 0
|
|
28
|
+
? parsed.targetUrl.trim()
|
|
29
|
+
: null,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
} catch {
|
|
33
|
+
// Ignore malformed .pindrop.json and fall back to other project hints.
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
if (existsSync(join(dir, ".git"))) break;
|
|
38
|
+
const parent = dirname(dir);
|
|
39
|
+
if (parent === dir) break;
|
|
40
|
+
dir = parent;
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function writeRepoProjectConfig(cwd, { projectId, shareUrl, targetUrl }) {
|
|
46
|
+
if (!projectId || typeof projectId !== "string" || !projectId.trim()) {
|
|
47
|
+
throw new Error("projectId is required to write .pindrop.json.");
|
|
48
|
+
}
|
|
49
|
+
const file = join(resolve(cwd), REPO_CONFIG_FILENAME);
|
|
50
|
+
const payload = {
|
|
51
|
+
projectId: projectId.trim(),
|
|
52
|
+
...(shareUrl ? { shareUrl } : {}),
|
|
53
|
+
...(targetUrl ? { targetUrl } : {}),
|
|
54
|
+
};
|
|
55
|
+
writeFileSync(file, JSON.stringify(payload, null, 2) + "\n", "utf8");
|
|
56
|
+
return { path: file, ...payload };
|
|
57
|
+
}
|
|
4
58
|
|
|
5
59
|
const IGNORED_HOSTS = new Set([
|
|
6
60
|
"localhost",
|
package/lib/skill.mjs
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
3
|
import { homedir } from "node:os";
|
|
3
4
|
import { dirname, join } from "node:path";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
5
6
|
|
|
6
7
|
const SKILL_SOURCE_PATH = fileURLToPath(new URL("../skill/SKILL.md", import.meta.url));
|
|
8
|
+
const MANAGED_SKILL_MARKER = /<!--\s*pindrop-skill-managed:\s*[^\s>]+\s*-->/;
|
|
9
|
+
// Unmodified SHA-256 digests of earlier bundled SKILL.md releases (v0.1.0-v0.1.5)
|
|
10
|
+
// that predate the managed marker, so re-running `pindrop init` / `skill install`
|
|
11
|
+
// upgrades them cleanly without clobbering user-edited skills.
|
|
12
|
+
const KNOWN_BUNDLED_SKILL_HASHES = new Set([
|
|
13
|
+
"c985698acaf0efb14f28d1c1f3766a429bfac0c74a1067435282691970cd57e1",
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
function isManagedBundledSkill(content) {
|
|
17
|
+
if (MANAGED_SKILL_MARKER.test(content)) return true;
|
|
18
|
+
const digest = createHash("sha256").update(content, "utf8").digest("hex");
|
|
19
|
+
return KNOWN_BUNDLED_SKILL_HASHES.has(digest);
|
|
20
|
+
}
|
|
7
21
|
|
|
8
22
|
export function readBundledSkill() {
|
|
9
23
|
return readFileSync(SKILL_SOURCE_PATH, "utf8");
|
|
@@ -30,6 +44,8 @@ export function resolveSkillTargets({
|
|
|
30
44
|
const claudeDir = join(home, ".claude");
|
|
31
45
|
const agentsDir = join(home, ".agents");
|
|
32
46
|
const codexDir = join(home, ".codex");
|
|
47
|
+
const cursorDir = join(home, ".cursor");
|
|
48
|
+
const geminiDir = join(home, ".gemini");
|
|
33
49
|
|
|
34
50
|
if (agent === "claude-code" || agent === "claude") {
|
|
35
51
|
targets.push({ label: "Claude Code", path: join(claudeDir, "skills", "pindrop", "SKILL.md") });
|
|
@@ -39,6 +55,14 @@ export function resolveSkillTargets({
|
|
|
39
55
|
targets.push({ label: "Codex", path: join(codexDir, "skills", "pindrop", "SKILL.md") });
|
|
40
56
|
return targets;
|
|
41
57
|
}
|
|
58
|
+
if (agent === "cursor") {
|
|
59
|
+
targets.push({ label: "Cursor", path: join(cursorDir, "skills", "pindrop", "SKILL.md") });
|
|
60
|
+
return targets;
|
|
61
|
+
}
|
|
62
|
+
if (agent === "gemini") {
|
|
63
|
+
targets.push({ label: "Gemini CLI", path: join(geminiDir, "skills", "pindrop", "SKILL.md") });
|
|
64
|
+
return targets;
|
|
65
|
+
}
|
|
42
66
|
if (agent === "agents") {
|
|
43
67
|
targets.push({ label: "Shared agents", path: join(agentsDir, "skills", "pindrop", "SKILL.md") });
|
|
44
68
|
return targets;
|
|
@@ -51,6 +75,12 @@ export function resolveSkillTargets({
|
|
|
51
75
|
if (existsSync(codexDir)) {
|
|
52
76
|
targets.push({ label: "Codex", path: join(codexDir, "skills", "pindrop", "SKILL.md") });
|
|
53
77
|
}
|
|
78
|
+
if (existsSync(cursorDir)) {
|
|
79
|
+
targets.push({ label: "Cursor", path: join(cursorDir, "skills", "pindrop", "SKILL.md") });
|
|
80
|
+
}
|
|
81
|
+
if (existsSync(geminiDir)) {
|
|
82
|
+
targets.push({ label: "Gemini CLI", path: join(geminiDir, "skills", "pindrop", "SKILL.md") });
|
|
83
|
+
}
|
|
54
84
|
targets.push({ label: "Shared agents", path: join(agentsDir, "skills", "pindrop", "SKILL.md") });
|
|
55
85
|
return targets;
|
|
56
86
|
}
|
|
@@ -67,20 +97,22 @@ export function installSkillFiles({
|
|
|
67
97
|
const results = [];
|
|
68
98
|
|
|
69
99
|
for (const target of targets) {
|
|
100
|
+
let wasManagedUpdate = false;
|
|
70
101
|
if (existsSync(target.path)) {
|
|
71
102
|
const existing = readFileSync(target.path, "utf8");
|
|
72
103
|
if (existing === content) {
|
|
73
104
|
results.push({ ...target, status: "unchanged" });
|
|
74
105
|
continue;
|
|
75
106
|
}
|
|
76
|
-
if (!force) {
|
|
107
|
+
if (!force && !isManagedBundledSkill(existing)) {
|
|
77
108
|
results.push({ ...target, status: "skipped_modified" });
|
|
78
109
|
continue;
|
|
79
110
|
}
|
|
111
|
+
wasManagedUpdate = !force && isManagedBundledSkill(existing);
|
|
80
112
|
}
|
|
81
113
|
mkdirSync(dirname(target.path), { recursive: true });
|
|
82
114
|
writeFileSync(target.path, content, "utf8");
|
|
83
|
-
results.push({ ...target, status: "installed" });
|
|
115
|
+
results.push({ ...target, status: wasManagedUpdate ? "updated" : "installed" });
|
|
84
116
|
}
|
|
85
117
|
|
|
86
118
|
return results;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pindrop",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Zero-dependency CLI for PinDrop visual client feedback pins. Browser OAuth login, instant project creation, pin context & screenshots, and agent skill setup.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/skill/SKILL.md
CHANGED
|
@@ -53,3 +53,7 @@ equivalent when already connected.
|
|
|
53
53
|
list open pins, and resolve each immediately with `--new-text "<replacement>"`
|
|
54
54
|
(change no code).
|
|
55
55
|
- If the user asks "anything from the client?", run `pindrop pins` first.
|
|
56
|
+
- For teams sharing a repo, `.pindrop.json` (created with `pindrop link`) pins
|
|
57
|
+
the repo to its PinDrop project without storing credentials.
|
|
58
|
+
|
|
59
|
+
<!-- pindrop-skill-managed: v2 -->
|