pindrop 0.1.2 → 0.1.3

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 CHANGED
@@ -3,17 +3,20 @@ 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
+ getLinkedProject,
6
7
  getSavedProfile,
7
8
  loginWithBrowser,
9
+ openInBrowser,
8
10
  resolveMcpUrl,
9
11
  revokeAndLogout,
10
12
  saveApiKeyProfile,
13
+ saveLinkedProject,
11
14
  } from "./lib/auth.mjs";
12
15
  import { CliError, callPinDropTool } from "./lib/client.mjs";
13
16
  import { inferProjectHint, inferSiteUrl } from "./lib/project.mjs";
14
17
  import { installSkillFiles } from "./lib/skill.mjs";
15
18
 
16
- const VERSION = "0.1.2";
19
+ const VERSION = "0.1.3";
17
20
 
18
21
  function parseArgv(argv) {
19
22
  const positionals = [];
@@ -137,6 +140,10 @@ function parsePinNumber(raw) {
137
140
  async function resolveProjectIdForPin({ mcpUrl, flags, autoLogin }) {
138
141
  const explicit = flagStr(flags, "project", "p", "project-id");
139
142
  if (explicit) return explicit;
143
+ const linked = getLinkedProject(mcpUrl);
144
+ if (linked?.projectId && !flagStr(flags, "hint")) {
145
+ return linked.projectId;
146
+ }
140
147
  const hint = flagStr(flags, "hint") || inferProjectHint();
141
148
  const res = await callPinDropTool({
142
149
  mcpUrl,
@@ -175,9 +182,20 @@ function formatPinCompact(pin) {
175
182
  const parts = [`#${num}`, path, JSON.stringify(comment)];
176
183
  if (vp) parts.push(vp);
177
184
  parts.push(status);
185
+ if (pin.pinShareUrl) parts.push(pin.pinShareUrl);
178
186
  return parts.join(" · ");
179
187
  }
180
188
 
189
+ function writeProjectNextSteps(projectId) {
190
+ const flag = projectId ? ` --project ${projectId}` : "";
191
+ process.stdout.write(
192
+ `Next: send the review link (no client account or script tag needed).\n`,
193
+ );
194
+ process.stdout.write(
195
+ `Commands: npx -y pindrop pins${flag} · npx -y pindrop pin <n> --screenshot${flag} · npx -y pindrop resolve <n>${flag} --comment "<what changed>"\n`,
196
+ );
197
+ }
198
+
181
199
  function printHelp() {
182
200
  process.stdout.write(`pindrop v${VERSION} — visual client feedback pins for your coding agent
183
201
 
@@ -189,6 +207,7 @@ Usage:
189
207
 
190
208
  pindrop projects List active PinDrop projects
191
209
  pindrop create [url] [--title <name>] Create (or reuse) a review link for a live URL
210
+ pindrop open [n] [--project <id>] Open the review link (or pin #n) in your browser
192
211
  pindrop pins [--project <id>] [--resolved] [--full] [--json]
193
212
  List pins for this repo (auto-matched by git remote)
194
213
  pindrop pin <n> [--screenshot [path]] [--project <id>] [--json]
@@ -326,6 +345,14 @@ export async function runCli(argv = process.argv.slice(2)) {
326
345
  openBrowser,
327
346
  onAuthorizeUrl: announceBrowserAuth,
328
347
  });
348
+ const p = res.structured || {};
349
+ if (p.projectId) {
350
+ saveLinkedProject(mcpUrl, process.cwd(), {
351
+ projectId: p.projectId,
352
+ shareUrl: p.shareUrl,
353
+ targetUrl: p.targetUrl || targetUrl,
354
+ });
355
+ }
329
356
  if (asJson) {
330
357
  printJson({
331
358
  ok: true,
@@ -334,7 +361,6 @@ export async function runCli(argv = process.argv.slice(2)) {
334
361
  project: res.structured,
335
362
  });
336
363
  } else {
337
- const p = res.structured || {};
338
364
  if (inferredFrom) {
339
365
  process.stderr.write(`Detected site URL ${targetUrl} from ${inferredFrom}\n`);
340
366
  }
@@ -345,6 +371,7 @@ export async function runCli(argv = process.argv.slice(2)) {
345
371
  process.stdout.write(`Installed skill: ${r.path}\n`);
346
372
  }
347
373
  }
374
+ writeProjectNextSteps(p.projectId);
348
375
  }
349
376
  return 0;
350
377
  }
@@ -401,22 +428,67 @@ export async function runCli(argv = process.argv.slice(2)) {
401
428
  openBrowser,
402
429
  onAuthorizeUrl: announceBrowserAuth,
403
430
  });
431
+ const p = res.structured || {};
432
+ if (p.projectId) {
433
+ saveLinkedProject(mcpUrl, process.cwd(), {
434
+ projectId: p.projectId,
435
+ shareUrl: p.shareUrl,
436
+ targetUrl: p.targetUrl || targetUrl,
437
+ });
438
+ }
404
439
  if (asJson) {
405
440
  printJson({ ...(res.structured || {}), ...(inferredFrom ? { inferredFrom } : {}) });
406
441
  } else {
407
- const p = res.structured || {};
408
442
  if (inferredFrom) {
409
443
  process.stderr.write(`Detected site URL ${targetUrl} from ${inferredFrom}\n`);
410
444
  }
411
445
  process.stdout.write(`Review link: ${p.shareUrl || res.text}\n`);
412
446
  if (p.projectId) process.stdout.write(`Project ID: ${p.projectId}\n`);
413
447
  if (p.wasReused) process.stdout.write(`Reused existing project for ${p.targetUrl || targetUrl}\n`);
448
+ writeProjectNextSteps(p.projectId);
449
+ }
450
+ return 0;
451
+ }
452
+
453
+ case "open": {
454
+ if (positionals[1]) {
455
+ const pinNumber = parsePinNumber(positionals[1]);
456
+ const projectId = await resolveProjectIdForPin({ mcpUrl, flags, autoLogin });
457
+ const res = await callPinDropTool({
458
+ mcpUrl,
459
+ toolName: "pindrop_get_pin_context",
460
+ args: { projectId, pinNumber },
461
+ autoLogin,
462
+ openBrowser,
463
+ onAuthorizeUrl: announceBrowserAuth,
464
+ });
465
+ const url = res.structured?.pinShareUrl;
466
+ if (!url) throw new CliError(`Could not find share URL for pin #${pinNumber}.`, 3);
467
+ if (openBrowser) openInBrowser(url);
468
+ if (asJson) printJson({ url, projectId, pinNumber });
469
+ else process.stdout.write(`${url}\n`);
470
+ return 0;
471
+ }
472
+ const explicitProject = flagStr(flags, "project", "p", "project-id");
473
+ const linked = !explicitProject ? getLinkedProject(mcpUrl) : null;
474
+ let url = linked?.shareUrl || null;
475
+ let projectId = explicitProject || linked?.projectId || null;
476
+ if (!url) {
477
+ const resolvedId = projectId || (await resolveProjectIdForPin({ mcpUrl, flags, autoLogin }));
478
+ projectId = resolvedId;
479
+ url = `https://www.pindrop.page/s/${encodeURIComponent(resolvedId)}`;
414
480
  }
481
+ if (openBrowser) openInBrowser(url);
482
+ if (asJson) printJson({ url, projectId });
483
+ else process.stdout.write(`${url}\n`);
415
484
  return 0;
416
485
  }
417
486
 
418
487
  case "pins": {
419
- const projectId = flagStr(flags, "project", "p", "project-id");
488
+ const explicitProject = flagStr(flags, "project", "p", "project-id");
489
+ const linkedProject =
490
+ !explicitProject && !flagStr(flags, "hint") ? getLinkedProject(mcpUrl)?.projectId : undefined;
491
+ const projectId = explicitProject || linkedProject;
420
492
  const hint = projectId ? undefined : flagStr(flags, "hint") || inferProjectHint();
421
493
  const limit = flagInt(flags, "limit", "n");
422
494
  const toolName = flags.resolved ? "pindrop_list_resolved_pins" : "pindrop_list_open_pins";
package/lib/auth.mjs CHANGED
@@ -11,7 +11,7 @@ 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 } from "node:path";
14
+ import { dirname, join, resolve } from "node:path";
15
15
 
16
16
  export const DEFAULT_MCP_URL = "https://mcp.pindrop.page";
17
17
  const EXPIRY_BUFFER_MS = 60_000;
@@ -104,6 +104,31 @@ export function clearProfile(mcpUrl) {
104
104
  return existed;
105
105
  }
106
106
 
107
+ export function getLinkedProject(mcpUrl, cwd = process.cwd()) {
108
+ const store = readAuthStore();
109
+ const byHost = store.projects?.[mcpUrl];
110
+ if (!byHost || typeof byHost !== "object") return null;
111
+ return byHost[resolve(cwd)] ?? null;
112
+ }
113
+
114
+ export function saveLinkedProject(mcpUrl, cwd, link) {
115
+ if (!link?.projectId) return;
116
+ const store = readAuthStore();
117
+ if (!store.projects || typeof store.projects !== "object") {
118
+ store.projects = {};
119
+ }
120
+ if (!store.projects[mcpUrl] || typeof store.projects[mcpUrl] !== "object") {
121
+ store.projects[mcpUrl] = {};
122
+ }
123
+ store.projects[mcpUrl][resolve(cwd)] = {
124
+ projectId: link.projectId,
125
+ shareUrl: link.shareUrl || null,
126
+ targetUrl: link.targetUrl || null,
127
+ updatedAt: Date.now(),
128
+ };
129
+ writeAuthStore(store);
130
+ }
131
+
107
132
  export function openInBrowser(url) {
108
133
  const os = platform();
109
134
  let cmd;
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.2",
23
+ "User-Agent": "pindrop-cli/0.1.3",
24
24
  },
25
25
  body: JSON.stringify({
26
26
  jsonrpc: "2.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pindrop",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
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": {