@buildinternet/uploads 0.33.0 → 0.33.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.
package/README.md CHANGED
@@ -17,6 +17,8 @@ uploads --version
17
17
  uploads attach ./before.png ./after.png
18
18
  uploads screenshot https://app.example --pr 123 --comment # capture + host in one step
19
19
  uploads screenshot ./report.html --dark --selector "main"
20
+ uploads screenshot http://localhost:3000 --via local --annotate ./callouts.json
21
+ uploads annotate ./shot.png --spec ./callouts.json --out ./shot.marked.png
20
22
  uploads put ./shot.png
21
23
  uploads put ./shot.png --destination screenshots
22
24
  uploads put ./shot.png --no-optimize
@@ -8,6 +8,17 @@ export interface StepResult {
8
8
  error?: string;
9
9
  output?: string;
10
10
  }
11
+ /** npm 7+ for `npx -y`. Node 22 ships npm 10+; this catches ancient/system npm. */
12
+ export declare const MIN_NPM_MAJOR_FOR_SKILLS = 7;
13
+ /** Install guidance when a host binary is missing (not "run manually: <same binary>"). */
14
+ export declare function missingBinaryHint(binary: string): string;
15
+ export declare function npmTooOldHint(version: string): string;
16
+ /**
17
+ * Probe npx/npm once before the per-skill loop. Returns an error string when
18
+ * tooling is missing/too old; undefined means skill steps should proceed.
19
+ * Non-ENOENT npx failures are left for the real `skills add` to surface.
20
+ */
21
+ export declare function probeSkillTooling(run: CommandRunner): string | undefined;
11
22
  export declare function runStep(run: CommandRunner, command: string[]): StepResult;
12
23
  export declare function runInstall(args: string[], opts: {
13
24
  globals: GlobalFlags;
@@ -33,9 +33,11 @@ What it does:
33
33
 
34
34
  What runs under the hood:
35
35
  skill npx -y skills add ${SKILL_SOURCE} --skill <name> -g -y -a '*'
36
- (once per skill: ${SKILL_NAMES.join(", ")})
36
+ (once per skill: ${SKILL_NAMES.join(", ")}; needs Node 22+ / npm 7+
37
+ with npx on PATH — missing tooling fails once with install guidance)
37
38
  mcp claude mcp add --transport http uploads ${DEFAULT_MCP_URL} \\
38
39
  --header "Authorization: Bearer <token>"
40
+ (needs the Claude Code CLI on PATH)
39
41
  hooks write/merge ~/.grok/hooks/… and ~/.cursor/hooks.json when present
40
42
 
41
43
  Options:
@@ -51,6 +53,8 @@ Examples:
51
53
  uploads install hooks
52
54
  uploads install --dry-run
53
55
  `;
56
+ /** npm 7+ for `npx -y`. Node 22 ships npm 10+; this catches ancient/system npm. */
57
+ export const MIN_NPM_MAJOR_FOR_SKILLS = 7;
54
58
  /** Mask Bearer credentials and the configured token in any printed text. */
55
59
  function redactor(token) {
56
60
  return (text) => {
@@ -60,6 +64,55 @@ function redactor(token) {
60
64
  return out;
61
65
  };
62
66
  }
67
+ function isEnoent(err) {
68
+ return err?.code === "ENOENT";
69
+ }
70
+ /** Install guidance when a host binary is missing (not "run manually: <same binary>"). */
71
+ export function missingBinaryHint(binary) {
72
+ switch (binary) {
73
+ case "npx":
74
+ case "npm":
75
+ return (`${binary} not found on PATH — skill install needs Node.js (npm includes npx). ` +
76
+ `Install Node 22+ from https://nodejs.org (or your package manager), open a new shell, ` +
77
+ `confirm \`${binary} --version\` works, then re-run \`uploads install skill\`.`);
78
+ case "claude":
79
+ return (`claude not found on PATH — MCP install needs the Claude Code CLI. ` +
80
+ `Install it from https://docs.anthropic.com/en/docs/claude-code, ensure \`claude\` is on PATH, ` +
81
+ `then re-run \`uploads install mcp\`. Skills and hooks still work without Claude Code.`);
82
+ default:
83
+ return `${binary} not found on PATH — install it and ensure it is available in this shell.`;
84
+ }
85
+ }
86
+ export function npmTooOldHint(version) {
87
+ return (`npm ${version} is too old for skill install (need npm ${MIN_NPM_MAJOR_FOR_SKILLS}+ for \`npx -y\`). ` +
88
+ `Upgrade Node/npm (Node 22+ recommended: https://nodejs.org), confirm \`npm --version\`, ` +
89
+ `then re-run \`uploads install skill\`.`);
90
+ }
91
+ /**
92
+ * Probe npx/npm once before the per-skill loop. Returns an error string when
93
+ * tooling is missing/too old; undefined means skill steps should proceed.
94
+ * Non-ENOENT npx failures are left for the real `skills add` to surface.
95
+ */
96
+ export function probeSkillTooling(run) {
97
+ try {
98
+ run("npx", ["--version"]);
99
+ }
100
+ catch (err) {
101
+ return isEnoent(err) ? missingBinaryHint("npx") : undefined;
102
+ }
103
+ try {
104
+ const out = run("npm", ["--version"]).trim();
105
+ const major = Number.parseInt(out.split(".")[0] ?? "", 10);
106
+ if (Number.isFinite(major) && major < MIN_NPM_MAJOR_FOR_SKILLS) {
107
+ return npmTooOldHint(out);
108
+ }
109
+ }
110
+ catch (err) {
111
+ if (isEnoent(err))
112
+ return missingBinaryHint("npm");
113
+ }
114
+ return undefined;
115
+ }
63
116
  export function runStep(run, command) {
64
117
  try {
65
118
  const output = run(command[0], command.slice(1)).trim();
@@ -67,10 +120,11 @@ export function runStep(run, command) {
67
120
  }
68
121
  catch (err) {
69
122
  const message = err instanceof Error ? err.message : String(err);
70
- const hint = err.code === "ENOENT"
71
- ? `${command[0]} not found on PATH — install it, or run manually: ${command.join(" ")}`
72
- : message;
73
- return { command, ok: false, error: hint };
123
+ return {
124
+ command,
125
+ ok: false,
126
+ error: isEnoent(err) ? missingBinaryHint(command[0]) : message,
127
+ };
74
128
  }
75
129
  }
76
130
  function skillCommand(skill) {
@@ -115,31 +169,63 @@ function peekToken(globals) {
115
169
  return undefined;
116
170
  }
117
171
  }
118
- function printHumanSteps(results, redact, verbose, mcpName) {
119
- for (const [step, r] of Object.entries(results)) {
120
- const cmd = redact(r.command.join(" "));
121
- if (r.skipped === "dry-run") {
122
- process.stdout.write(`${step}: would run — ${cmd}\n`);
123
- }
124
- else if (r.skipped === "sign-in") {
125
- process.stdout.write(`${step}: skipped — ${redact(r.error ?? "needs sign-in")}\n`);
126
- }
127
- else if (r.skipped === "already-configured") {
128
- process.stdout.write(`${step}: already configured "${mcpName}" is registered in Claude Code (nothing to do)\n` +
129
- ` To re-register (e.g. with a new token): claude mcp remove ${mcpName} && uploads install mcp\n`);
172
+ function printOneHumanStep(step, r, redact, verbose, mcpName) {
173
+ const cmd = redact(r.command.join(" "));
174
+ if (r.skipped === "dry-run") {
175
+ process.stdout.write(`${step}: would run — ${cmd}\n`);
176
+ }
177
+ else if (r.skipped === "sign-in") {
178
+ process.stdout.write(`${step}: skipped — ${redact(r.error ?? "needs sign-in")}\n`);
179
+ }
180
+ else if (r.skipped === "already-configured") {
181
+ process.stdout.write(`${step}: already configured "${mcpName}" is registered in Claude Code (nothing to do)\n` +
182
+ ` To re-register (e.g. with a new token): claude mcp remove ${mcpName} && uploads install mcp\n`);
183
+ }
184
+ else if (r.ok) {
185
+ process.stdout.write(`${step}: ok\n`);
186
+ if (verbose && r.output) {
187
+ process.stdout.write(` ${redact(r.output).split("\n").join("\n ")}\n`);
130
188
  }
131
- else if (r.ok) {
132
- process.stdout.write(`${step}: ok\n`);
133
- if (verbose && r.output) {
134
- process.stdout.write(` ${redact(r.output).split("\n").join("\n ")}\n`);
189
+ }
190
+ else {
191
+ process.stderr.write(`${step}: failed — ${redact(r.error ?? "")}\n`);
192
+ if (verbose)
193
+ process.stderr.write(` command: ${cmd}\n`);
194
+ }
195
+ }
196
+ /** Shared error when every skill step failed identically; otherwise undefined. */
197
+ function identicalSkillFailure(skillEntries) {
198
+ if (skillEntries.length < 2)
199
+ return undefined;
200
+ const error = skillEntries[0]?.[1].error;
201
+ if (!error)
202
+ return undefined;
203
+ const allSame = skillEntries.every(([, r]) => !r.ok && !r.skipped && r.error === error);
204
+ return allSame ? error : undefined;
205
+ }
206
+ /** Collapse identical skill failures to one `skills:` line (missing npx, old npm, …). */
207
+ function printHumanSteps(results, redact, verbose, mcpName) {
208
+ const entries = Object.entries(results);
209
+ const skillEntries = entries.filter(([step]) => step.startsWith("skill:"));
210
+ const sharedError = identicalSkillFailure(skillEntries);
211
+ if (sharedError !== undefined) {
212
+ process.stderr.write(`skills: failed — ${redact(sharedError)}\n`);
213
+ if (verbose) {
214
+ for (const [step, r] of skillEntries) {
215
+ process.stderr.write(` ${step}: ${redact(r.command.join(" "))}\n`);
135
216
  }
136
217
  }
137
- else {
138
- process.stderr.write(`${step}: failed — ${redact(r.error ?? "")}\n`);
139
- if (verbose)
140
- process.stderr.write(` command: ${cmd}\n`);
218
+ }
219
+ else {
220
+ for (const [step, r] of skillEntries) {
221
+ printOneHumanStep(step, r, redact, verbose, mcpName);
141
222
  }
142
223
  }
224
+ for (const [step, r] of entries) {
225
+ if (step.startsWith("skill:"))
226
+ continue;
227
+ printOneHumanStep(step, r, redact, verbose, mcpName);
228
+ }
143
229
  }
144
230
  function printSuccessFooter(steps, signedIn) {
145
231
  process.stdout.write(`\nDone — ${steps.join(" and ")} ready.\n` +
@@ -187,11 +273,18 @@ export async function runInstall(args, opts, help = false) {
187
273
  if (target === "skill" || target === "all") {
188
274
  if (human)
189
275
  process.stdout.write("Installing skills…\n");
276
+ const toolingError = dryRun ? undefined : probeSkillTooling(run);
190
277
  for (const skill of SKILL_NAMES) {
191
278
  const command = skillCommand(skill);
192
- results[`skill:${skill}`] = dryRun
193
- ? { command, ok: true, skipped: "dry-run" }
194
- : runStep(run, command);
279
+ if (dryRun) {
280
+ results[`skill:${skill}`] = { command, ok: true, skipped: "dry-run" };
281
+ }
282
+ else if (toolingError) {
283
+ results[`skill:${skill}`] = { command, ok: false, error: toolingError };
284
+ }
285
+ else {
286
+ results[`skill:${skill}`] = runStep(run, command);
287
+ }
195
288
  }
196
289
  }
197
290
  if (target === "mcp" || target === "all") {
@@ -264,14 +357,26 @@ export async function runInstall(args, opts, help = false) {
264
357
  printSuccessFooter(stepLabels, signedIn);
265
358
  }
266
359
  else if (failed && !dryRun && skillsOk && results.mcp && !results.mcp.ok) {
267
- const next = results.mcp.skipped === "sign-in"
268
- ? "Sign in with `uploads login`, then re-run `uploads install mcp`."
269
- : "Fix the MCP step above, then re-run `uploads install mcp`.";
360
+ let next;
361
+ if (results.mcp.skipped === "sign-in") {
362
+ next = "Sign in with `uploads login`, then re-run `uploads install mcp`.";
363
+ }
364
+ else if (results.mcp.error?.includes("not found on PATH")) {
365
+ next = "Install the Claude Code CLI (or skip MCP), then re-run `uploads install mcp`.";
366
+ }
367
+ else {
368
+ next = "Fix the MCP step above, then re-run `uploads install mcp`.";
369
+ }
270
370
  process.stdout.write(`\nSkills are installed. ${next}\n`);
271
371
  }
272
372
  else if (failed && !dryRun && skillsFailed) {
273
- // Mixed or total skill failure used to print only per-step lines (#191).
274
- process.stdout.write("\nSkill install incomplete. Fix the errors above, then re-run `uploads install skill`.\n");
373
+ // Closing guidance when skills fail (issue #191: used to be per-step only).
374
+ const skillErrText = skillResults.map((r) => r.error ?? "").join("\n");
375
+ const toolingMissing = /npx not found|npm not found|too old for skill install/i.test(skillErrText);
376
+ process.stdout.write(toolingMissing
377
+ ? "\nSkill install needs a working Node.js toolchain (npx + npm 7+ on PATH). " +
378
+ "Fix that, then re-run `uploads install skill`.\n"
379
+ : "\nSkill install incomplete. Fix the errors above, then re-run `uploads install skill`.\n");
275
380
  }
276
381
  return failed ? 1 : 0;
277
382
  }
package/dist/commands.js CHANGED
@@ -12,7 +12,7 @@ import { imageFactsFromBytes } from "./image-facts.js";
12
12
  import { parseMetaFlags, validateMetaMap } from "./metadata.js";
13
13
  import { mergeDerivedMeta, nearMissMetaWarnings, validateStateValue } from "./metadata-vocab.js";
14
14
  import { mergeSidecarMeta } from "./sidecar.js";
15
- import { ghAttachmentKey, ghBranchAttachmentKey, ghBranchKeyPrefix, ghKeyPrefix, ghMetadataFromTarget, parseGhKey, ghMetadataForBranch, attachmentsCommentBody, attachmentsMarker, normalizeGithubCoordinate, } from "./github.js";
15
+ import { ghAttachmentKey, ghBranchAttachmentKey, ghBranchKeyPrefix, ghKeyPrefix, ghMetadataFromTarget, parseGhKey, ghMetadataForBranch, attachmentsCommentBody, attachmentsMarker, GH_FALLBACK_AUTHOR_NOTE, normalizeGithubCoordinate, } from "./github.js";
16
16
  import { resolveRepo, resolveCurrentPullRequest, resolveCurrentBranch, resolveDefaultBranch, classifyGhNumber, execRunner, timedExecRunner, ghMetadataFromTargetWithTitle, upsertAttachmentsComment, } from "./github-gh.js";
17
17
  import { deriveRepoFromGit } from "./keys.js";
18
18
  import { resolvePutPrefix } from "./destinations.js";
@@ -543,7 +543,9 @@ export async function syncAttachmentsComment(client, target, run, workspace, opt
543
543
  }
544
544
  }));
545
545
  const marker = attachmentsMarker(workspace);
546
- const body = attachmentsCommentBody(items, previewGalleries, marker);
546
+ // Append only on the local-gh path: bot posts already carry the uploads-sh
547
+ // bot identity, so this note would be wrong there.
548
+ const body = `${attachmentsCommentBody(items, previewGalleries, marker)}\n${GH_FALLBACK_AUTHOR_NOTE}`;
547
549
  const count = items.length + previewGalleries.length;
548
550
  // Empty (count 0) renders the neutral empty-state body but must not create a
549
551
  // comment — it only rewrites one that already exists (`action: "skipped"`
package/dist/github-gh.js CHANGED
@@ -2,7 +2,26 @@ import { execFileSync } from "node:child_process";
2
2
  import { UsageError } from "./cli-args.js";
3
3
  import { ATTACHMENTS_MARKER, ghMetadataFromTarget, isValidRepo, parseRepoFromRemoteUrl, } from "./github.js";
4
4
  import { META_VALUE_MAX, isMetaValueSafe } from "./metadata.js";
5
- export const execRunner = (cmd, args, input) => execFileSync(cmd, args, { encoding: "utf8", input, stdio: ["pipe", "pipe", "pipe"] });
5
+ /**
6
+ * Windows npm shims are `.cmd`/`.bat`; bare `execFileSync` ENOENTs them.
7
+ * Retry once with `shell: true` so PATHEXT resolves the shim. Other platforms
8
+ * and non-ENOENT errors stay on the no-shell path. Args are from our CLI, not
9
+ * free-form shell strings.
10
+ */
11
+ function execFileSyncCompat(cmd, args, opts) {
12
+ try {
13
+ return execFileSync(cmd, args, opts);
14
+ }
15
+ catch (err) {
16
+ const isWinShim = process.platform === "win32" &&
17
+ err.code === "ENOENT" &&
18
+ !/\.(cmd|bat|exe|com)$/i.test(cmd);
19
+ if (isWinShim)
20
+ return execFileSync(cmd, args, { ...opts, shell: true });
21
+ throw err;
22
+ }
23
+ }
24
+ export const execRunner = (cmd, args, input) => execFileSyncCompat(cmd, args, { encoding: "utf8", input, stdio: ["pipe", "pipe", "pipe"] });
6
25
  /**
7
26
  * A `CommandRunner` bounded by `timeoutMs` (node's native `execFileSync`
8
27
  * `timeout` option). There is no other subprocess-timeout wrapper in this
@@ -10,7 +29,7 @@ export const execRunner = (cmd, args, input) => execFileSync(cmd, args, { encodi
10
29
  * that must never block its caller for long (e.g. the bare-`put` nudge's `gh
11
30
  * pr view` check, issue #393), pass this instead of the default `execRunner`.
12
31
  */
13
- export const timedExecRunner = (timeoutMs) => (cmd, args, input) => execFileSync(cmd, args, {
32
+ export const timedExecRunner = (timeoutMs) => (cmd, args, input) => execFileSyncCompat(cmd, args, {
14
33
  encoding: "utf8",
15
34
  input,
16
35
  stdio: ["pipe", "pipe", "pipe"],
package/dist/github.d.ts CHANGED
@@ -138,3 +138,8 @@ export declare const ATTACHMENT_IMAGE_WIDTH_PAIR = 320;
138
138
  * intentionally preserves the legacy attachment-only body byte-for-byte.
139
139
  */
140
140
  export declare function attachmentsCommentBody(items: AttachmentItem[], galleries?: GalleryCommentItem[], marker?: string): string;
141
+ /**
142
+ * Extra footer line appended only on the local-`gh` fallback path (never on
143
+ * bot-authored comments). Short note that the App isn't on this repo yet.
144
+ */
145
+ export declare const GH_FALLBACK_AUTHOR_NOTE = "<sub><a href=\"https://github.com/apps/uploads-sh\">Install the uploads GitHub App</a> for bot-managed comments.</sub>";
package/dist/github.js CHANGED
@@ -506,3 +506,8 @@ export function attachmentsCommentBody(items, galleries = [], marker = ATTACHMEN
506
506
  lines.push('<sub>Add media: <code>uploads put &lt;file&gt; --pr &lt;N&gt; --comment</code> (or <code>--issue &lt;N&gt;</code>) · <a href="https://uploads.sh/docs/github-app">docs</a></sub>');
507
507
  return lines.join("\n");
508
508
  }
509
+ /**
510
+ * Extra footer line appended only on the local-`gh` fallback path (never on
511
+ * bot-authored comments). Short note that the App isn't on this repo yet.
512
+ */
513
+ export const GH_FALLBACK_AUTHOR_NOTE = '<sub><a href="https://github.com/apps/uploads-sh">Install the uploads GitHub App</a> for bot-managed comments.</sub>';
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ export { UploadsError, type UploadsErrorCode } from "./errors.js";
7
7
  export { createUploadsClient, type UploadsClient, type PutOptions, type ProvenanceInput, type ListOptions, type PutResult, type ListItem, type ListResult, type HeadResult, type DeleteResult, type GalleryItem, type Gallery, type GallerySummary, type GalleryListOptions, type GalleryListResult, type CreateGalleryOptions, type AddGalleryItemOptions, type DeleteGalleryOptions, type HealthResult, type UsageResult, type ReconcileResult, type PurgeExpiredResult, type PurgeExpiredResponse, type FindFilesOptions, type FindFilesItem, type FindFilesResult, type GetMetadataResult, type PatchMetadataOptions, } from "./client.js";
8
8
  export { buildCliProvenance } from "./provenance.js";
9
9
  export { META_KEY_RE, META_VALUE_MAX, META_MAX_KEYS, META_MAX_TOTAL_BYTES, validateMetaEntry, parseMetaPair, parseMetaFlags, } from "./metadata.js";
10
- export { ATTACHMENTS_MARKER, attachmentsCommentBody, ghAttachmentKey, ghKeyPrefix, ghMetadataFromTarget, ghBranchAttachmentKey, ghBranchKeyPrefix, ghMetadataForBranch, isValidRepo, parseRepoFromRemoteUrl, type AttachmentItem, type GhTarget, type GhTargetKind, } from "./github.js";
10
+ export { ATTACHMENTS_MARKER, attachmentsCommentBody, GH_FALLBACK_AUTHOR_NOTE, ghAttachmentKey, ghKeyPrefix, ghMetadataFromTarget, ghBranchAttachmentKey, ghBranchKeyPrefix, ghMetadataForBranch, isValidRepo, parseRepoFromRemoteUrl, type AttachmentItem, type GhTarget, type GhTargetKind, } from "./github.js";
11
11
  export { DEFAULT_OPTIMIZE_MAX_EDGE, DEFAULT_OPTIMIZE_QUALITY, optimizeImageForUpload, rewriteKeyExtension, withImageExtension, type OptimizeImageOptions, type OptimizeImageResult, type OptimizeOutputFormat, } from "./optimize.js";
12
12
  export { FRAME_PRESETS, applyFrame, listFramePresets, resolveFrameId, type FrameFit, type FrameOptions, type FrameResult, } from "./frame.js";
13
13
  export { execRunner, resolveRepo, upsertAttachmentsComment, type CommandRunner, } from "./github-gh.js";
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ export { UploadsError } from "./errors.js";
7
7
  export { createUploadsClient, } from "./client.js";
8
8
  export { buildCliProvenance } from "./provenance.js";
9
9
  export { META_KEY_RE, META_VALUE_MAX, META_MAX_KEYS, META_MAX_TOTAL_BYTES, validateMetaEntry, parseMetaPair, parseMetaFlags, } from "./metadata.js";
10
- export { ATTACHMENTS_MARKER, attachmentsCommentBody, ghAttachmentKey, ghKeyPrefix, ghMetadataFromTarget, ghBranchAttachmentKey, ghBranchKeyPrefix, ghMetadataForBranch, isValidRepo, parseRepoFromRemoteUrl, } from "./github.js";
10
+ export { ATTACHMENTS_MARKER, attachmentsCommentBody, GH_FALLBACK_AUTHOR_NOTE, ghAttachmentKey, ghKeyPrefix, ghMetadataFromTarget, ghBranchAttachmentKey, ghBranchKeyPrefix, ghMetadataForBranch, isValidRepo, parseRepoFromRemoteUrl, } from "./github.js";
11
11
  export { DEFAULT_OPTIMIZE_MAX_EDGE, DEFAULT_OPTIMIZE_QUALITY, optimizeImageForUpload, rewriteKeyExtension, withImageExtension, } from "./optimize.js";
12
12
  export { FRAME_PRESETS, applyFrame, listFramePresets, resolveFrameId, } from "./frame.js";
13
13
  export { execRunner, resolveRepo, upsertAttachmentsComment, } from "./github-gh.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildinternet/uploads",
3
- "version": "0.33.0",
3
+ "version": "0.33.1",
4
4
  "description": "CLI and client for uploads.sh — workspace-scoped image hosting for GitHub embeds",
5
5
  "type": "module",
6
6
  "sideEffects": false,