pindrop 0.1.1 → 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.1";
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;
@@ -177,27 +202,113 @@ export async function discoverOAuth(mcpUrl, fetchImpl = fetch) {
177
202
  };
178
203
  }
179
204
 
180
- function callbackHtml(title, body, ok) {
181
- const accent = ok ? "#1f9d55" : "#c8361a";
205
+ const CALLBACK_PAGES = {
206
+ connected: {
207
+ ok: true,
208
+ tab: "PinDrop CLI connected",
209
+ headline: "Connected.",
210
+ lead: "Head back to your terminal. The PinDrop CLI takes it from here.",
211
+ },
212
+ cancelled: {
213
+ ok: false,
214
+ tab: "PinDrop sign-in cancelled",
215
+ headline: "Not connected.",
216
+ lead: "Authorization was denied.",
217
+ },
218
+ invalid: {
219
+ ok: false,
220
+ tab: "PinDrop sign-in failed",
221
+ headline: "Not connected.",
222
+ lead: "State mismatch or missing authorization code.",
223
+ },
224
+ };
225
+
226
+ function escapeHtml(value) {
227
+ return String(value).replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
228
+ }
229
+
230
+ function callbackHtml(kind, { detail, port } = {}) {
231
+ const page = CALLBACK_PAGES[kind];
232
+ const { ok } = page;
233
+ const lead = detail ? escapeHtml(detail) : page.lead;
234
+ const glyph = ok
235
+ ? `<path d="M5 12.5l4.2 4.2L19 7" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"/>`
236
+ : `<path d="M7 7l10 10M17 7L7 17" stroke="currentColor" stroke-width="2.6" stroke-linecap="round"/>`;
237
+ const meta = ok ? `pindrop cli · 127.0.0.1:${port}` : "no token saved";
182
238
  return `<!doctype html>
183
239
  <html lang="en">
184
240
  <head>
185
241
  <meta charset="utf-8" />
186
242
  <meta name="viewport" content="width=device-width,initial-scale=1" />
187
- <title>${title}</title>
243
+ <meta name="referrer" content="no-referrer" />
244
+ <title>${page.tab}</title>
245
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
246
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
247
+ <link href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500;600&display=swap" rel="stylesheet" />
188
248
  <style>
189
- body { margin: 0; min-height: 100vh; display: grid; place-items: center; background: #f5f1eb; color: #1d1a17; font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
190
- .card { max-width: 420px; padding: 28px 30px; border-radius: 18px; background: #fff; box-shadow: 0 18px 40px -24px rgba(30,20,20,.35), 0 0 0 1px rgba(60,40,30,.08); }
191
- .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: ${accent}; margin-right: 8px; vertical-align: middle; }
192
- h1 { margin: 0 0 8px; font-size: 18px; font-weight: 600; }
193
- p { margin: 0; color: #5b554d; }
249
+ :root {
250
+ --paper: #ffffff; --raised: #faf7f3; --bg: #f5f1eb;
251
+ --ink: #1d1a17; --ink-2: #5b554d; --ink-3: #8b857c; --rule-2: #e2dbd1;
252
+ --radius-pin: 50% 50% 50% 14%;
253
+ --ease-out: cubic-bezier(.23,1,.32,1);
254
+ --ease-land: cubic-bezier(.34,1.56,.64,1);
255
+ --sans: Geist, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
256
+ --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
257
+ }
258
+ * { box-sizing: border-box; }
259
+ html, body { margin: 0; }
260
+ body { background: var(--raised); color: var(--ink); font: 400 13.5px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
261
+ .kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; background: var(--paper); box-shadow: 0 0 0 1px var(--rule-2), 0 1px 0 var(--rule-2); font: 500 11px/1 var(--mono); color: var(--ink-2); }
262
+ .closes { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--ink-3); }
263
+ .closes > span:last-child { margin-left: 4px; }
264
+ .cmd { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px; background: var(--paper); box-shadow: 0 0 0 1px var(--rule-2); font: 400 12.5px/1 var(--mono); color: var(--ink); margin-top: 18px; animation: up 260ms var(--ease-out) 240ms both; }
265
+ .cmd span { color: var(--ink-3); user-select: none; }
266
+ .cmd code { font: inherit; user-select: all; }
267
+ .live { width: 7px; height: 7px; border-radius: 50%; background: var(--state); box-shadow: 0 0 0 3px rgb(var(--state-rgb) / .16); }
268
+ @keyframes fade { from { opacity: 0; } }
269
+ @keyframes draw { to { stroke-dashoffset: 0; } }
270
+ @keyframes up { from { opacity: 0; transform: translateY(6px); } }
271
+
272
+ .p { min-height: 100dvh; display: grid; place-items: center; padding: 56px 16px 120px; text-align: center; overflow: hidden; --state: #1f9d55; --state-rgb: 31 157 85; --state-deep: 20 90 50; }
273
+ .p[data-state="error"] { --state: #c8361a; --state-rgb: 200 54 26; --state-deep: 140 40 15; }
274
+ .p-stage { position: relative; width: 152px; height: 152px; margin: 0 auto 44px; }
275
+ .p-ground { position: absolute; left: -26px; bottom: -22px; width: 120px; height: 22px; border-radius: 50%; background: radial-gradient(closest-side, rgba(60,40,30,.22), transparent); opacity: .85; animation: p-ground 480ms var(--ease-land) both; }
276
+ @keyframes p-ground { from { opacity: 0; transform: scale(.4); } }
277
+ .p-ring { position: absolute; left: -2px; bottom: -14px; width: 60px; height: 14px; border-radius: 50%; box-shadow: 0 0 0 2px rgb(var(--state-rgb) / .4); opacity: 0; animation: p-ring 520ms var(--ease-out) 200ms forwards; }
278
+ @keyframes p-ring { 0% { opacity: .9; transform: scale(.5); } 100% { opacity: 0; transform: scale(2.6); } }
279
+ .p-pin { position: relative; width: 152px; height: 152px; border-radius: var(--radius-pin); background: var(--state); color: var(--paper); border: 6px solid var(--paper); box-shadow: 0 34px 50px -24px rgb(var(--state-deep) / .5), 0 8px 18px -8px rgb(var(--state-deep) / .3); display: grid; place-items: center; transform-origin: 22px 140px; animation: p-drop 480ms var(--ease-land) both; }
280
+ @keyframes p-drop { from { opacity: 0; transform: translateY(-72px) scale(.94, 1.06); } }
281
+ .p-pin svg { width: 62px; height: 62px; }
282
+ .p-pin path { stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw 240ms var(--ease-out) 300ms forwards; }
283
+ .p-title { margin: 0; font: 600 clamp(46px, 9vw, 76px)/.98 var(--sans); letter-spacing: -.048em; text-wrap: balance; animation: up 260ms var(--ease-out) 140ms both; }
284
+ .p-lead { margin: 16px auto 0; max-width: 360px; font-size: 16px; color: var(--ink-2); text-wrap: pretty; overflow-wrap: anywhere; animation: up 260ms var(--ease-out) 190ms both; }
285
+ .p-meta { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 10px 18px; margin-top: 30px; animation: up 260ms var(--ease-out) 290ms both; }
286
+ .p-meta code { display: inline-flex; align-items: center; gap: 7px; font: 400 12px/1 var(--mono); color: var(--ink-3); }
287
+
288
+ @media (prefers-reduced-motion: reduce) {
289
+ .p-pin, .p-ground, .p-title, .p-lead, .p-meta, .cmd { animation: fade 200ms ease-out both !important; transform: none !important; }
290
+ .p-ring { display: none; }
291
+ .p-pin path { animation: none; stroke-dashoffset: 0; }
292
+ }
194
293
  </style>
195
294
  </head>
196
295
  <body>
197
- <div class="card">
198
- <h1><span class="dot"></span>${title}</h1>
199
- <p>${body}</p>
296
+ <main class="p" data-state="${ok ? "ok" : "error"}">
297
+ <div>
298
+ <div class="p-stage" aria-hidden="true">
299
+ <span class="p-ground"></span>
300
+ <span class="p-ring"></span>
301
+ <div class="p-pin"><svg viewBox="0 0 24 24" fill="none">${glyph}</svg></div>
302
+ </div>
303
+ <h1 class="p-title">${page.headline}</h1>
304
+ <p class="p-lead">${lead}${ok ? "" : "<br>Run this in your terminal to try again:"}</p>
305
+ ${ok ? "" : `<div class="cmd"><span aria-hidden="true">$</span><code>pindrop login</code></div>`}
306
+ <div class="p-meta"><code><span class="live"></span>${meta}</code><span class="closes"><span class="kbd" id="mod">⌘</span><span class="kbd">W</span><span>closes this tab</span></span></div>
200
307
  </div>
308
+ </main>
309
+ <script>
310
+ if (!/Mac|iPhone|iPad/.test(navigator.platform)) document.getElementById("mod").textContent = "Ctrl";
311
+ </script>
201
312
  </body>
202
313
  </html>`;
203
314
  }
@@ -226,13 +337,7 @@ function startCallbackServer(expectedState, timeoutMs = LOGIN_TIMEOUT_MS) {
226
337
 
227
338
  if (error) {
228
339
  res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
229
- res.end(
230
- callbackHtml(
231
- "PinDrop sign-in cancelled",
232
- errorDesc || error || "Authorization was denied.",
233
- false,
234
- ),
235
- );
340
+ res.end(callbackHtml("cancelled", { detail: errorDesc || error }));
236
341
  if (!settled) {
237
342
  settled = true;
238
343
  clearTimeout(timer);
@@ -244,24 +349,12 @@ function startCallbackServer(expectedState, timeoutMs = LOGIN_TIMEOUT_MS) {
244
349
 
245
350
  if (!code || state !== expectedState) {
246
351
  res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
247
- res.end(
248
- callbackHtml(
249
- "Invalid OAuth callback",
250
- "State mismatch or missing authorization code. Try running pindrop login again.",
251
- false,
252
- ),
253
- );
352
+ res.end(callbackHtml("invalid"));
254
353
  return;
255
354
  }
256
355
 
257
356
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
258
- res.end(
259
- callbackHtml(
260
- "PinDrop CLI connected",
261
- "You can close this tab and return to your terminal or coding agent.",
262
- true,
263
- ),
264
- );
357
+ res.end(callbackHtml("connected", { port: req.socket.localPort }));
265
358
  if (!settled) {
266
359
  settled = true;
267
360
  clearTimeout(timer);
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.1",
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.1",
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": {