pindrop 0.1.3 → 0.1.4
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/cli.mjs +158 -21
- package/lib/client.mjs +44 -1
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -12,11 +12,11 @@ import {
|
|
|
12
12
|
saveApiKeyProfile,
|
|
13
13
|
saveLinkedProject,
|
|
14
14
|
} from "./lib/auth.mjs";
|
|
15
|
-
import { CliError, callPinDropTool } from "./lib/client.mjs";
|
|
15
|
+
import { CliError, callPinDropTool, callSandboxApi } from "./lib/client.mjs";
|
|
16
16
|
import { inferProjectHint, inferSiteUrl } from "./lib/project.mjs";
|
|
17
17
|
import { installSkillFiles } from "./lib/skill.mjs";
|
|
18
18
|
|
|
19
|
-
const VERSION = "0.1.
|
|
19
|
+
const VERSION = "0.1.4";
|
|
20
20
|
|
|
21
21
|
function parseArgv(argv) {
|
|
22
22
|
const positionals = [];
|
|
@@ -30,6 +30,9 @@ function parseArgv(argv) {
|
|
|
30
30
|
"full",
|
|
31
31
|
"resolved",
|
|
32
32
|
"open",
|
|
33
|
+
"watch",
|
|
34
|
+
"w",
|
|
35
|
+
"once",
|
|
33
36
|
"no-browser",
|
|
34
37
|
"no-login",
|
|
35
38
|
"force",
|
|
@@ -206,10 +209,10 @@ Usage:
|
|
|
206
209
|
pindrop status Show connected account, plan, and limits
|
|
207
210
|
|
|
208
211
|
pindrop projects List active PinDrop projects
|
|
209
|
-
pindrop create [url] [--
|
|
212
|
+
pindrop create [url] [--open] Create (or reuse) a review link for a live URL
|
|
210
213
|
pindrop open [n] [--project <id>] Open the review link (or pin #n) in your browser
|
|
211
|
-
pindrop pins [--project <id>] [--resolved] [--full] [--json]
|
|
212
|
-
List pins for this repo
|
|
214
|
+
pindrop pins [--watch] [--once] [--project <id>] [--resolved] [--full] [--json]
|
|
215
|
+
List (or live-watch) pins for this repo
|
|
213
216
|
pindrop pin <n> [--screenshot [path]] [--project <id>] [--json]
|
|
214
217
|
Read full context (and optionally save screenshot)
|
|
215
218
|
pindrop comment <n> --body <text> Reply on a pin
|
|
@@ -221,8 +224,10 @@ Usage:
|
|
|
221
224
|
pindrop delete <n> Soft-delete a pin
|
|
222
225
|
pindrop drop --path <p> --x <n> --y <n> --vw <n> --comment <text>
|
|
223
226
|
Drop a new pin from measured coordinates
|
|
224
|
-
pindrop sandbox
|
|
225
|
-
|
|
227
|
+
pindrop sandbox pins <id> <code> List open pins on a /try sandbox (no signup)
|
|
228
|
+
pindrop sandbox resolve <id> <code> <n> --new-text <text>
|
|
229
|
+
Resolve a /try sandbox pin live (no signup)
|
|
230
|
+
pindrop sandbox claim <id> <code> Claim a /try sandbox into your PinDrop account
|
|
226
231
|
pindrop billing [--action trial|upgrade|manage] [--plan pro|studio]
|
|
227
232
|
Get a secure browser checkout/billing link
|
|
228
233
|
pindrop skill install [--global|--local] [--agent <id>] [--force]
|
|
@@ -353,10 +358,13 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
353
358
|
targetUrl: p.targetUrl || targetUrl,
|
|
354
359
|
});
|
|
355
360
|
}
|
|
361
|
+
const shouldOpen = Boolean((flags.open || p.isFirstProject) && openBrowser && p.shareUrl);
|
|
362
|
+
if (shouldOpen) openInBrowser(p.shareUrl);
|
|
356
363
|
if (asJson) {
|
|
357
364
|
printJson({
|
|
358
365
|
ok: true,
|
|
359
366
|
inferredFrom,
|
|
367
|
+
opened: shouldOpen,
|
|
360
368
|
skills: skillResults,
|
|
361
369
|
project: res.structured,
|
|
362
370
|
});
|
|
@@ -366,6 +374,7 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
366
374
|
}
|
|
367
375
|
process.stdout.write(`Review link: ${p.shareUrl || res.text}\n`);
|
|
368
376
|
if (p.projectId) process.stdout.write(`Project ID: ${p.projectId}\n`);
|
|
377
|
+
if (shouldOpen) process.stderr.write(`Opened review link in your browser.\n`);
|
|
369
378
|
for (const r of skillResults) {
|
|
370
379
|
if (r.status === "installed") {
|
|
371
380
|
process.stdout.write(`Installed skill: ${r.path}\n`);
|
|
@@ -436,14 +445,21 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
436
445
|
targetUrl: p.targetUrl || targetUrl,
|
|
437
446
|
});
|
|
438
447
|
}
|
|
448
|
+
const shouldOpen = Boolean((flags.open || p.isFirstProject) && openBrowser && p.shareUrl);
|
|
449
|
+
if (shouldOpen) openInBrowser(p.shareUrl);
|
|
439
450
|
if (asJson) {
|
|
440
|
-
printJson({
|
|
451
|
+
printJson({
|
|
452
|
+
...(res.structured || {}),
|
|
453
|
+
...(inferredFrom ? { inferredFrom } : {}),
|
|
454
|
+
...(shouldOpen ? { opened: true } : {}),
|
|
455
|
+
});
|
|
441
456
|
} else {
|
|
442
457
|
if (inferredFrom) {
|
|
443
458
|
process.stderr.write(`Detected site URL ${targetUrl} from ${inferredFrom}\n`);
|
|
444
459
|
}
|
|
445
460
|
process.stdout.write(`Review link: ${p.shareUrl || res.text}\n`);
|
|
446
461
|
if (p.projectId) process.stdout.write(`Project ID: ${p.projectId}\n`);
|
|
462
|
+
if (shouldOpen) process.stderr.write(`Opened review link in your browser.\n`);
|
|
447
463
|
if (p.wasReused) process.stdout.write(`Reused existing project for ${p.targetUrl || targetUrl}\n`);
|
|
448
464
|
writeProjectNextSteps(p.projectId);
|
|
449
465
|
}
|
|
@@ -500,6 +516,73 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
500
516
|
...(flagStr(flags, "path") ? { path: flagStr(flags, "path") } : {}),
|
|
501
517
|
...(flagStr(flags, "priority") ? { priority: flagStr(flags, "priority") } : {}),
|
|
502
518
|
};
|
|
519
|
+
if (flags.watch || flags.w) {
|
|
520
|
+
const intervalSec = Math.max(1, flagNum(flags, "interval") ?? 3);
|
|
521
|
+
const once = Boolean(flags.once);
|
|
522
|
+
const seen = new Map();
|
|
523
|
+
let stopped = false;
|
|
524
|
+
const stop = () => {
|
|
525
|
+
stopped = true;
|
|
526
|
+
};
|
|
527
|
+
process.on("SIGINT", stop);
|
|
528
|
+
process.on("SIGTERM", stop);
|
|
529
|
+
process.stderr.write(
|
|
530
|
+
`Watching ${projectId || hint || "PinDrop"} for pins (every ${intervalSec}s; Ctrl+C to stop)…\n`,
|
|
531
|
+
);
|
|
532
|
+
try {
|
|
533
|
+
while (!stopped) {
|
|
534
|
+
const res = await callPinDropTool({
|
|
535
|
+
mcpUrl,
|
|
536
|
+
toolName,
|
|
537
|
+
args,
|
|
538
|
+
autoLogin,
|
|
539
|
+
openBrowser,
|
|
540
|
+
onAuthorizeUrl: announceBrowserAuth,
|
|
541
|
+
});
|
|
542
|
+
const s = res.structured || {};
|
|
543
|
+
if (s.scope === "unmatched" && Array.isArray(s.candidates) && s.candidates.length > 0) {
|
|
544
|
+
process.stderr.write("No project matched this folder. Pass --project <id>:\n");
|
|
545
|
+
for (const c of s.candidates) {
|
|
546
|
+
process.stderr.write(` ${c.id} · ${c.title || c.targetUrl} (${c.targetUrl})\n`);
|
|
547
|
+
}
|
|
548
|
+
return 3;
|
|
549
|
+
}
|
|
550
|
+
const pins = Array.isArray(s.pins) ? s.pins : [];
|
|
551
|
+
const changed = [];
|
|
552
|
+
for (const pin of pins) {
|
|
553
|
+
const key = String(pin.pinNumber ?? pin.number ?? pin.id ?? "");
|
|
554
|
+
const fp = JSON.stringify([
|
|
555
|
+
pin.status,
|
|
556
|
+
pin.comment,
|
|
557
|
+
Array.isArray(pin.thread) ? pin.thread.length : 0,
|
|
558
|
+
]);
|
|
559
|
+
if (seen.get(key) !== fp) {
|
|
560
|
+
seen.set(key, fp);
|
|
561
|
+
changed.push(pin);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
if (changed.length > 0) {
|
|
565
|
+
if (asJson) {
|
|
566
|
+
for (const pin of changed) {
|
|
567
|
+
process.stdout.write(JSON.stringify(pin) + "\n");
|
|
568
|
+
}
|
|
569
|
+
} else {
|
|
570
|
+
for (const pin of changed) {
|
|
571
|
+
process.stdout.write(formatPinCompact(pin) + "\n");
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
if (once) return 0;
|
|
575
|
+
}
|
|
576
|
+
if (stopped) break;
|
|
577
|
+
await new Promise((r) => setTimeout(r, intervalSec * 1000));
|
|
578
|
+
}
|
|
579
|
+
} finally {
|
|
580
|
+
process.off("SIGINT", stop);
|
|
581
|
+
process.off("SIGTERM", stop);
|
|
582
|
+
}
|
|
583
|
+
return 0;
|
|
584
|
+
}
|
|
585
|
+
|
|
503
586
|
const res = await callPinDropTool({
|
|
504
587
|
mcpUrl,
|
|
505
588
|
toolName,
|
|
@@ -735,20 +818,74 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
735
818
|
|
|
736
819
|
case "sandbox": {
|
|
737
820
|
const sub = positionals[1];
|
|
738
|
-
if (sub
|
|
739
|
-
|
|
821
|
+
if (sub === "pins") {
|
|
822
|
+
const projectId = positionals[2] || flagStr(flags, "project", "p");
|
|
823
|
+
const claimCode = positionals[3] || flagStr(flags, "claim-code", "code");
|
|
824
|
+
if (!projectId || !claimCode) {
|
|
825
|
+
throw new CliError("Usage: pindrop sandbox pins <projectId> <claimCode> [--json]", 1);
|
|
826
|
+
}
|
|
827
|
+
const data = await callSandboxApi({
|
|
828
|
+
mcpUrl,
|
|
829
|
+
method: "GET",
|
|
830
|
+
path: `/api/v1/sandbox/pins?project=${encodeURIComponent(projectId)}`,
|
|
831
|
+
claimCode,
|
|
832
|
+
});
|
|
833
|
+
if (asJson) {
|
|
834
|
+
printJson(data);
|
|
835
|
+
} else {
|
|
836
|
+
const pins = Array.isArray(data?.pins) ? data.pins : [];
|
|
837
|
+
if (pins.length === 0) process.stdout.write("No open pins.\n");
|
|
838
|
+
else for (const pin of pins) process.stdout.write(formatPinCompact(pin) + "\n");
|
|
839
|
+
}
|
|
840
|
+
return 0;
|
|
740
841
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
842
|
+
if (sub === "resolve") {
|
|
843
|
+
const projectId = positionals[2] || flagStr(flags, "project", "p");
|
|
844
|
+
const claimCode = positionals[3] || flagStr(flags, "claim-code", "code");
|
|
845
|
+
const pinNumber = parsePinNumber(positionals[4]);
|
|
846
|
+
const newText = flagStr(flags, "new-text", "newText");
|
|
847
|
+
const comment = flagStr(flags, "comment", "c", "m");
|
|
848
|
+
const authorName = flagStr(flags, "author") || process.env.PINDROP_AGENT_NAME;
|
|
849
|
+
if (!projectId || !claimCode) {
|
|
850
|
+
throw new CliError(
|
|
851
|
+
'Usage: pindrop sandbox resolve <projectId> <claimCode> <pinNumber> --new-text "<text>"',
|
|
852
|
+
1,
|
|
853
|
+
);
|
|
854
|
+
}
|
|
855
|
+
const data = await callSandboxApi({
|
|
856
|
+
mcpUrl,
|
|
857
|
+
method: "POST",
|
|
858
|
+
path: "/api/v1/sandbox/resolve",
|
|
859
|
+
claimCode,
|
|
860
|
+
body: {
|
|
861
|
+
projectId,
|
|
862
|
+
pinNumber,
|
|
863
|
+
...(newText ? { newText } : {}),
|
|
864
|
+
...(comment ? { comment } : {}),
|
|
865
|
+
...(authorName ? { authorName } : {}),
|
|
866
|
+
},
|
|
867
|
+
});
|
|
868
|
+
if (asJson) printJson(data);
|
|
869
|
+
else process.stdout.write(`${data?.pinShareUrl || `Resolved sandbox pin #${pinNumber}.`}\n`);
|
|
870
|
+
return 0;
|
|
871
|
+
}
|
|
872
|
+
if (sub === "claim" && positionals[2] && positionals[3]) {
|
|
873
|
+
const res = await callPinDropTool({
|
|
874
|
+
mcpUrl,
|
|
875
|
+
toolName: "pindrop_claim_sandbox",
|
|
876
|
+
args: { projectId: positionals[2], claimCode: positionals[3] },
|
|
877
|
+
autoLogin,
|
|
878
|
+
openBrowser,
|
|
879
|
+
onAuthorizeUrl: announceBrowserAuth,
|
|
880
|
+
});
|
|
881
|
+
if (asJson) printJson(res.structured ?? { text: res.text });
|
|
882
|
+
else process.stdout.write((res.text || `Claimed sandbox ${positionals[2]}`) + "\n");
|
|
883
|
+
return 0;
|
|
884
|
+
}
|
|
885
|
+
throw new CliError(
|
|
886
|
+
"Usage: pindrop sandbox <pins|resolve|claim> <projectId> <claimCode> [pinNumber]",
|
|
887
|
+
1,
|
|
888
|
+
);
|
|
752
889
|
}
|
|
753
890
|
|
|
754
891
|
case "billing": {
|
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.4",
|
|
24
24
|
},
|
|
25
25
|
body: JSON.stringify({
|
|
26
26
|
jsonrpc: "2.0",
|
|
@@ -139,3 +139,46 @@ export async function callPinDropTool({
|
|
|
139
139
|
content: Array.isArray(result.content) ? result.content : [],
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
|
+
|
|
143
|
+
export async function callSandboxApi({
|
|
144
|
+
mcpUrl,
|
|
145
|
+
method,
|
|
146
|
+
path,
|
|
147
|
+
claimCode,
|
|
148
|
+
body,
|
|
149
|
+
fetchImpl = fetch,
|
|
150
|
+
}) {
|
|
151
|
+
const base = mcpUrl.replace(/\/mcp$/, "").replace(/\/+$/, "");
|
|
152
|
+
const response = await fetchWithRetry(
|
|
153
|
+
`${base}${path}`,
|
|
154
|
+
{
|
|
155
|
+
method,
|
|
156
|
+
headers: {
|
|
157
|
+
Accept: "application/json",
|
|
158
|
+
Authorization: `Sandbox ${claimCode}`,
|
|
159
|
+
"User-Agent": "pindrop-cli/0.1.4",
|
|
160
|
+
...(body !== undefined ? { "Content-Type": "application/json" } : {}),
|
|
161
|
+
},
|
|
162
|
+
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
163
|
+
},
|
|
164
|
+
fetchImpl,
|
|
165
|
+
);
|
|
166
|
+
const text = await response.text();
|
|
167
|
+
let payload = null;
|
|
168
|
+
try {
|
|
169
|
+
payload = JSON.parse(text);
|
|
170
|
+
} catch {
|
|
171
|
+
payload = null;
|
|
172
|
+
}
|
|
173
|
+
if (!response.ok) {
|
|
174
|
+
const msg =
|
|
175
|
+
payload?.error?.message ||
|
|
176
|
+
payload?.error ||
|
|
177
|
+
`PinDrop sandbox request failed (${response.status}).`;
|
|
178
|
+
throw new CliError(
|
|
179
|
+
String(msg),
|
|
180
|
+
response.status === 401 ? 2 : response.status === 404 ? 3 : 1,
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
return payload;
|
|
184
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pindrop",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
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": {
|