pindrop 0.0.0-stage → 0.1.1

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.
@@ -0,0 +1,148 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { existsSync, readFileSync } from "node:fs";
3
+ import { basename, join } from "node:path";
4
+
5
+ const IGNORED_HOSTS = new Set([
6
+ "localhost",
7
+ "127.0.0.1",
8
+ "0.0.0.0",
9
+ "example.com",
10
+ "www.example.com",
11
+ "your-domain.com",
12
+ "yourdomain.com",
13
+ "github.com",
14
+ "gitlab.com",
15
+ "bitbucket.org",
16
+ "npmjs.com",
17
+ "www.npmjs.com",
18
+ "vercel.com",
19
+ ]);
20
+
21
+ function normalizeCandidateUrl(raw) {
22
+ if (!raw || typeof raw !== "string") return null;
23
+ let value = raw.trim().replace(/^["'`]+|["'`.,;)>]+$/g, "");
24
+ if (!value || value.includes("${") || value.includes("<") || value.includes(" ")) {
25
+ return null;
26
+ }
27
+ if (!/^https?:\/\//i.test(value)) {
28
+ if (!/^[a-z0-9.-]+\.[a-z]{2,}(\/.*)?$/i.test(value)) return null;
29
+ value = `https://${value}`;
30
+ }
31
+ try {
32
+ const parsed = new URL(value);
33
+ const host = parsed.hostname.toLowerCase();
34
+ if (
35
+ IGNORED_HOSTS.has(host) ||
36
+ host.endsWith(".local") ||
37
+ host.endsWith(".localhost") ||
38
+ host.endsWith(".example") ||
39
+ host.endsWith(".test")
40
+ ) {
41
+ return null;
42
+ }
43
+ return `${parsed.protocol}//${parsed.host}${parsed.pathname === "/" ? "" : parsed.pathname.replace(/\/+$/, "")}`;
44
+ } catch {
45
+ return null;
46
+ }
47
+ }
48
+
49
+ export function inferProjectHint(cwd = process.cwd()) {
50
+ try {
51
+ const remote = execFileSync("git", ["remote", "get-url", "origin"], {
52
+ cwd,
53
+ stdio: ["ignore", "pipe", "ignore"],
54
+ encoding: "utf8",
55
+ }).trim();
56
+ if (remote) return remote;
57
+ } catch {
58
+ // Not a git repo or no origin remote.
59
+ }
60
+
61
+ const pkgPath = join(cwd, "package.json");
62
+ if (existsSync(pkgPath)) {
63
+ try {
64
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
65
+ if (typeof pkg.name === "string" && pkg.name.trim()) {
66
+ return pkg.name.trim();
67
+ }
68
+ } catch {
69
+ // Ignore invalid package.json.
70
+ }
71
+ }
72
+
73
+ return basename(cwd);
74
+ }
75
+
76
+ export function inferSiteUrl(cwd = process.cwd()) {
77
+ // 1. CNAME (GitHub Pages / Cloudflare / static hosts)
78
+ for (const rel of ["CNAME", "public/CNAME"]) {
79
+ const file = join(cwd, rel);
80
+ if (!existsSync(file)) continue;
81
+ const firstLine = readFileSync(file, "utf8").split(/\r?\n/)[0];
82
+ const url = normalizeCandidateUrl(firstLine);
83
+ if (url) return { url, source: rel };
84
+ }
85
+
86
+ // 2. package.json homepage
87
+ const pkgPath = join(cwd, "package.json");
88
+ if (existsSync(pkgPath)) {
89
+ try {
90
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
91
+ const url = normalizeCandidateUrl(pkg.homepage);
92
+ if (url) return { url, source: "package.json" };
93
+ } catch {
94
+ // Ignore invalid JSON.
95
+ }
96
+ }
97
+
98
+ // 3. Public site URL env vars in .env* (strictly allowlisted public keys only)
99
+ const PUBLIC_URL_KEYS = new Set([
100
+ "NEXT_PUBLIC_SITE_URL",
101
+ "SITE_URL",
102
+ "PUBLIC_SITE_URL",
103
+ "VITE_SITE_URL",
104
+ "ASTRO_SITE",
105
+ "NUXT_PUBLIC_SITE_URL",
106
+ ]);
107
+ for (const rel of [".env.production", ".env.local", ".env"]) {
108
+ const file = join(cwd, rel);
109
+ if (!existsSync(file)) continue;
110
+ try {
111
+ const lines = readFileSync(file, "utf8").split(/\r?\n/);
112
+ for (const line of lines) {
113
+ const match = line.match(/^\s*([A-Z0-9_]+)\s*=\s*(.+)\s*$/);
114
+ if (!match || !PUBLIC_URL_KEYS.has(match[1])) continue;
115
+ const url = normalizeCandidateUrl(match[2]);
116
+ if (url) return { url, source: `${rel} (${match[1]})` };
117
+ }
118
+ } catch {
119
+ // Ignore unreadable env files.
120
+ }
121
+ }
122
+
123
+ // 4. Astro / Next config `site:` or `SITE_URL`
124
+ for (const rel of [
125
+ "astro.config.mjs",
126
+ "astro.config.ts",
127
+ "astro.config.js",
128
+ "src/lib/seo.ts",
129
+ "lib/seo.ts",
130
+ ]) {
131
+ const file = join(cwd, rel);
132
+ if (!existsSync(file)) continue;
133
+ try {
134
+ const content = readFileSync(file, "utf8");
135
+ const match = content.match(
136
+ /(?:site\s*:|SITE_URL\s*=)\s*["'`](https?:\/\/[^"'`\s]+)["'`]/,
137
+ );
138
+ if (match) {
139
+ const url = normalizeCandidateUrl(match[1]);
140
+ if (url) return { url, source: rel };
141
+ }
142
+ } catch {
143
+ // Ignore read errors.
144
+ }
145
+ }
146
+
147
+ return null;
148
+ }
package/lib/skill.mjs ADDED
@@ -0,0 +1,87 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const SKILL_SOURCE_PATH = fileURLToPath(new URL("../skill/SKILL.md", import.meta.url));
7
+
8
+ export function readBundledSkill() {
9
+ return readFileSync(SKILL_SOURCE_PATH, "utf8");
10
+ }
11
+
12
+ export function resolveSkillTargets({
13
+ scope = "global",
14
+ cwd = process.cwd(),
15
+ home = homedir(),
16
+ agent,
17
+ }) {
18
+ if (scope === "local" || scope === "project") {
19
+ const targets = [];
20
+ if (!agent || agent === "claude-code" || agent === "claude") {
21
+ targets.push({ label: "Claude Code (project)", path: join(cwd, ".claude", "skills", "pindrop", "SKILL.md") });
22
+ }
23
+ if (!agent || agent === "agents" || agent === "codex" || agent === "cursor" || agent === "antigravity") {
24
+ targets.push({ label: "Agents (project)", path: join(cwd, ".agents", "skills", "pindrop", "SKILL.md") });
25
+ }
26
+ return targets;
27
+ }
28
+
29
+ const targets = [];
30
+ const claudeDir = join(home, ".claude");
31
+ const agentsDir = join(home, ".agents");
32
+ const codexDir = join(home, ".codex");
33
+
34
+ if (agent === "claude-code" || agent === "claude") {
35
+ targets.push({ label: "Claude Code", path: join(claudeDir, "skills", "pindrop", "SKILL.md") });
36
+ return targets;
37
+ }
38
+ if (agent === "codex") {
39
+ targets.push({ label: "Codex", path: join(codexDir, "skills", "pindrop", "SKILL.md") });
40
+ return targets;
41
+ }
42
+ if (agent === "agents") {
43
+ targets.push({ label: "Shared agents", path: join(agentsDir, "skills", "pindrop", "SKILL.md") });
44
+ return targets;
45
+ }
46
+
47
+ // Global auto-detect: install to detected agent homes, always including ~/.agents/skills.
48
+ if (existsSync(claudeDir)) {
49
+ targets.push({ label: "Claude Code", path: join(claudeDir, "skills", "pindrop", "SKILL.md") });
50
+ }
51
+ if (existsSync(codexDir)) {
52
+ targets.push({ label: "Codex", path: join(codexDir, "skills", "pindrop", "SKILL.md") });
53
+ }
54
+ targets.push({ label: "Shared agents", path: join(agentsDir, "skills", "pindrop", "SKILL.md") });
55
+ return targets;
56
+ }
57
+
58
+ export function installSkillFiles({
59
+ scope = "global",
60
+ cwd = process.cwd(),
61
+ home = homedir(),
62
+ agent,
63
+ force = false,
64
+ }) {
65
+ const content = readBundledSkill();
66
+ const targets = resolveSkillTargets({ scope, cwd, home, agent });
67
+ const results = [];
68
+
69
+ for (const target of targets) {
70
+ if (existsSync(target.path)) {
71
+ const existing = readFileSync(target.path, "utf8");
72
+ if (existing === content) {
73
+ results.push({ ...target, status: "unchanged" });
74
+ continue;
75
+ }
76
+ if (!force) {
77
+ results.push({ ...target, status: "skipped_modified" });
78
+ continue;
79
+ }
80
+ }
81
+ mkdirSync(dirname(target.path), { recursive: true });
82
+ writeFileSync(target.path, content, "utf8");
83
+ results.push({ ...target, status: "installed" });
84
+ }
85
+
86
+ return results;
87
+ }
package/package.json CHANGED
@@ -1,6 +1,36 @@
1
1
  {
2
2
  "name": "pindrop",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
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
+ "type": "module",
6
+ "bin": {
7
+ "pindrop": "cli.mjs"
8
+ },
9
+ "files": [
10
+ "cli.mjs",
11
+ "lib/",
12
+ "skill/",
13
+ "README.md"
14
+ ],
15
+ "engines": {
16
+ "node": ">=18"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/Quirk2237/pindrop.git",
21
+ "directory": "packages/pindrop-cli"
22
+ },
23
+ "homepage": "https://www.pindrop.page/guide",
24
+ "license": "MIT",
25
+ "keywords": [
26
+ "pindrop",
27
+ "cli",
28
+ "feedback",
29
+ "pins",
30
+ "coding-agent",
31
+ "claude-code",
32
+ "codex",
33
+ "cursor",
34
+ "mcp"
35
+ ]
36
+ }
package/skill/SKILL.md ADDED
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: pindrop
3
+ description:
4
+ Work PinDrop feedback pins for this project using the pindrop CLI (or MCP tools
5
+ if connected): create a review link from a live URL, list open pins, inspect a
6
+ pin's context and screenshot, fix the underlying code, reply, and resolve. Use
7
+ when the user says "Put PinDrop on my site", "fix pin 4", "check pins", "any
8
+ feedback?", "what did the client say", or after deploying changes a reviewer
9
+ was waiting on.
10
+ ---
11
+
12
+ # PinDrop pins
13
+
14
+ PinDrop pins are numbered feedback comments anchored to a live page of this
15
+ project's deployed site. Prefer the `pindrop` CLI (compact output, zero context
16
+ bloat, works without restarting a session); PinDrop MCP tools (`pindrop_*`) are
17
+ equivalent when already connected.
18
+
19
+ ## Setup & creating a review link
20
+
21
+ - `"Put PinDrop on my site"` (with or without a URL): run `pindrop create [url]`.
22
+ If no URL is passed, `pindrop` checks the repo for a live URL; ask the user
23
+ if none is found. Hand back the returned `shareUrl` and note that clients need
24
+ no account or script tag.
25
+ - First-time login opens PinDrop in the browser automatically (`pindrop login`).
26
+ Never ask the user to paste tokens or credit card details in chat.
27
+
28
+ ## The fix loop
29
+
30
+ 1. `pindrop pins` — lists open pins for this repo (auto-matches the project from
31
+ git remote or folder name). If unmatched, ask which candidate project to use
32
+ and pass `--project <shareId>`.
33
+ 2. For `"fix pin N"`: `pindrop pin N` (add `--screenshot` when the fix depends
34
+ on what the reviewer saw, then read the saved image path).
35
+ 3. Fix the issue in the codebase and verify it. Mark it in progress while
36
+ awaiting deploy: `pindrop mark N in_progress`.
37
+ 4. Confirm the specific fix is live on the customer-facing production site
38
+ (verified production deploy, live URL check, or the user's confirmation).
39
+ Local fixes, passing tests, commits, pushes, previews, and staging do not
40
+ qualify.
41
+ 5. Only then resolve:
42
+ `pindrop resolve N --comment "<one plain past-tense sentence>"`
43
+ Hand back the printed pin link.
44
+
45
+ ## Rules
46
+
47
+ - Never resolve a pin before its fix is confirmed live in production. If
48
+ undeployed, leave it open or `in_progress` and report "Fixed locally; awaiting
49
+ production deployment" in chat.
50
+ - Write resolve comments in plain language for non-technical clients (1–2 short
51
+ past-tense sentences, no jargon or file paths).
52
+ - For `/try` demo sandboxes: run `pindrop sandbox claim <projectId> <claimCode>`,
53
+ list open pins, and resolve each immediately with `--new-text "<replacement>"`
54
+ (change no code).
55
+ - If the user asks "anything from the client?", run `pindrop pins` first.