@indigoai-us/hq-cli 5.47.16 → 5.47.17

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.
@@ -104,8 +104,8 @@ jobs:
104
104
  fi
105
105
  export SENTRY_AUTH_TOKEN
106
106
  VER=$(jq -r .version package.json)
107
- npx -y @sentry/cli@^2 sourcemaps upload --release "hq-cli@$VER" dist/
107
+ npx -y @sentry/cli@^2 sourcemaps upload --release "hq-cli@$VER" dist/ node_modules/@indigoai-us/hq-cloud/dist/
108
108
  env:
109
109
  SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
110
110
  SENTRY_ORG: indigo-d0
111
- SENTRY_PROJECT: hq
111
+ SENTRY_PROJECT: hq-cli
@@ -9,6 +9,8 @@ export interface FeedbackSubmitOptions {
9
9
  body: string;
10
10
  company?: string;
11
11
  token: string;
12
+ /** S3 object keys of already-uploaded screenshots (see uploadScreenshots). */
13
+ screenshots?: string[];
12
14
  }
13
15
  export declare function readBodyFile(bodyFile: string, stdin?: NodeJS.ReadableStream): Promise<string>;
14
16
  export declare function submitFeedback(opts: FeedbackSubmitOptions): Promise<FeedbackResult>;
@@ -1,10 +1,11 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3e8d95ee-bfb4-5ca3-8177-7bc3ca618bd4")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ee78c7b6-6e93-5217-8a1d-ddc51afcf9c3")}catch(e){}}();
3
3
  import * as fs from "node:fs";
4
4
  import chalk from "chalk";
5
5
  import { ensureCognitoToken } from "../utils/cognito-session.js";
6
6
  import { vaultApiFetch } from "../utils/vault-api.js";
7
7
  import { collectDiagnostics } from "../utils/feedback-diagnostics.js";
8
+ import { MAX_SCREENSHOTS, uploadScreenshots } from "../utils/feedback-screenshots.js";
8
9
  export const BODY_MAX_BYTES = 64 * 1024;
9
10
  export async function readBodyFile(bodyFile, stdin) {
10
11
  if (bodyFile === "-") {
@@ -25,6 +26,16 @@ export async function readBodyFile(bodyFile, stdin) {
25
26
  return fs.promises.readFile(bodyFile, "utf-8");
26
27
  }
27
28
  export async function submitFeedback(opts) {
29
+ // Validate the title locally, symmetric with the body check below. Commander's
30
+ // `requiredOption("--title")` only requires the flag to be PRESENT — an empty
31
+ // or whitespace-only value (`--title ""`, or a title the /hq-bug skill derived
32
+ // to nothing) passes the flag check, then the server rejects it with a 400
33
+ // "title (non-empty string) is required" that floods Sentry as a context-free
34
+ // warning (HQ-AB). Catch it here so the caller gets a clear, actionable error
35
+ // and the bad request never reaches the server.
36
+ if (opts.title.trim().length === 0) {
37
+ throw new Error("title must not be empty. Provide a short, non-whitespace title via --title.");
38
+ }
28
39
  if (opts.body.trim().length === 0) {
29
40
  throw new Error("body must not be empty. Provide at least one non-whitespace character.");
30
41
  }
@@ -42,6 +53,9 @@ export async function submitFeedback(opts) {
42
53
  if (opts.company) {
43
54
  requestBody.company = opts.company;
44
55
  }
56
+ if (opts.screenshots && opts.screenshots.length > 0) {
57
+ requestBody.screenshots = opts.screenshots;
58
+ }
45
59
  const res = await vaultApiFetch({
46
60
  token: opts.token,
47
61
  path: "/v1/feedback",
@@ -68,16 +82,24 @@ function registerSubcommand(feedbackCmd, type) {
68
82
  .requiredOption("--title <text>", "Short title for the report")
69
83
  .requiredOption("--body-file <path>", "Path to a markdown file with the body; use - to read from stdin")
70
84
  .option("--company <slug>", "Company slug to associate with the report")
85
+ .option("--screenshot <path>", `Attach a screenshot (repeatable, up to ${MAX_SCREENSHOTS}; .png/.jpg/.jpeg/.webp/.gif)`, (value, prev) => [...prev, value], [])
71
86
  .action(async (opts) => {
72
87
  try {
73
88
  const token = await ensureCognitoToken({ interactive: false });
74
89
  const body = await readBodyFile(opts.bodyFile);
90
+ // Validate + upload screenshots (direct-to-S3 via presigned PUT)
91
+ // before submitting, so the row references uploaded objects.
92
+ const screenshots = await uploadScreenshots({
93
+ paths: opts.screenshot ?? [],
94
+ token,
95
+ });
75
96
  const result = await submitFeedback({
76
97
  type,
77
98
  title: opts.title,
78
99
  body,
79
100
  company: opts.company,
80
101
  token,
102
+ screenshots,
81
103
  });
82
104
  console.log(`Submitted: ${result.id}`);
83
105
  }
@@ -95,4 +117,4 @@ export function registerFeedbackCommand(program) {
95
117
  registerSubcommand(feedbackCmd, "feature");
96
118
  }
97
119
  //# sourceMappingURL=feedback.js.map
98
- //# debugId=3e8d95ee-bfb4-5ca3-8177-7bc3ca618bd4
120
+ //# debugId=ee78c7b6-6e93-5217-8a1d-ddc51afcf9c3
@@ -68,6 +68,25 @@ interface RunFilesDeleteParams {
68
68
  yes: boolean;
69
69
  companySlug: string | undefined;
70
70
  }
71
+ /**
72
+ * The vault bucket is already company-scoped, so a delete prefix must be
73
+ * BUCKET-RELATIVE (e.g. `projects/foo/*`). A caller who pastes an HQ *local*
74
+ * tree path (`companies/<slug>/projects/foo`) over-prefixes it; the server then
75
+ * rejects it with INVALID_PREFIX_COMPANIES_SCOPED (HTTP 400), the source of the
76
+ * recurring Sentry warning HQ-8F. Strip a redundant leading `companies/<slug>/`
77
+ * so the local-looking path is normalized to the bucket-relative key the vault
78
+ * actually stores. Returns the stripped slug for a one-line notice, or null when
79
+ * there was nothing to strip. Pure → unit-testable.
80
+ *
81
+ * This runs UPSTREAM of the server's exact-vs-glob branch, so it covers both
82
+ * the glob spelling (`companies/<slug>/projects/foo/*` → `validatePrefix`,
83
+ * HQ-8F) and the EXACT-key spelling (`companies/<slug>/notes/foo.md` →
84
+ * `validateObjectKey`, HQ-CA) with the same normalization.
85
+ */
86
+ export declare function stripRedundantCompanyScope(prefix: string): {
87
+ prefix: string;
88
+ strippedSlug: string;
89
+ } | null;
71
90
  export declare function runFilesDelete(params: RunFilesDeleteParams, deps?: {
72
91
  confirm?: ConfirmFn;
73
92
  }): Promise<void>;
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5f5242f3-b24f-58b0-a3ee-381c42c755fc")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="bc564dd4-d8c1-5d09-ad49-3bcd9f7328a6")}catch(e){}}();
3
3
  import chalk from "chalk";
4
4
  import open from "open";
5
5
  import * as readline from "node:readline";
@@ -566,13 +566,47 @@ function printKeyPreview(resp) {
566
566
  console.log(chalk.dim(` … and ${resp.matched - resp.keys.length} more`));
567
567
  }
568
568
  }
569
+ /**
570
+ * The vault bucket is already company-scoped, so a delete prefix must be
571
+ * BUCKET-RELATIVE (e.g. `projects/foo/*`). A caller who pastes an HQ *local*
572
+ * tree path (`companies/<slug>/projects/foo`) over-prefixes it; the server then
573
+ * rejects it with INVALID_PREFIX_COMPANIES_SCOPED (HTTP 400), the source of the
574
+ * recurring Sentry warning HQ-8F. Strip a redundant leading `companies/<slug>/`
575
+ * so the local-looking path is normalized to the bucket-relative key the vault
576
+ * actually stores. Returns the stripped slug for a one-line notice, or null when
577
+ * there was nothing to strip. Pure → unit-testable.
578
+ *
579
+ * This runs UPSTREAM of the server's exact-vs-glob branch, so it covers both
580
+ * the glob spelling (`companies/<slug>/projects/foo/*` → `validatePrefix`,
581
+ * HQ-8F) and the EXACT-key spelling (`companies/<slug>/notes/foo.md` →
582
+ * `validateObjectKey`, HQ-CA) with the same normalization.
583
+ */
584
+ export function stripRedundantCompanyScope(prefix) {
585
+ const m = /^companies\/([^/]+)(?:\/(.*))?$/.exec(prefix);
586
+ if (!m)
587
+ return null;
588
+ return { prefix: m[2] ?? "", strippedSlug: m[1] };
589
+ }
569
590
  export async function runFilesDelete(params, deps = {}) {
570
591
  const confirm = deps.confirm ?? realConfirm;
592
+ // The vault is already company-scoped — a `companies/<slug>/` prefix is the HQ
593
+ // LOCAL tree layout, not a vault key, and the server 400s it (HQ-8F). Strip it
594
+ // here so a pasted local path is gracefully normalized to bucket-relative
595
+ // BEFORE the dry-run/preview (so the operator still sees the exact keys and
596
+ // confirms the right target). If stripping empties the prefix, the root-reject
597
+ // below catches it with a clear message.
598
+ const scope = stripRedundantCompanyScope(params.prefix);
599
+ if (scope) {
600
+ console.error(chalk.yellow(`Note: stripped redundant 'companies/${scope.strippedSlug}/' — the vault ` +
601
+ `is already company-scoped; using bucket-relative ` +
602
+ `'${scope.prefix || "(root)"}'.`));
603
+ }
604
+ const rawPrefix = scope ? scope.prefix : params.prefix;
571
605
  // Normalize exactly as the share/unshare/acl paths do (trailing `/` → `/*`),
572
606
  // then reject the root/empty prefix CLIENT-side so a typo never reaches the
573
607
  // server as a vault-wide delete. The server enforces this too (defense in
574
608
  // depth), but failing fast here is clearer and avoids a wasted round-trip.
575
- const normalized = normalizeFilePrefix(params.prefix);
609
+ const normalized = normalizeFilePrefix(rawPrefix);
576
610
  if (normalized === "" || normalized === "*" || normalized === "/*") {
577
611
  console.error(chalk.red("Refusing to delete the vault root. Pass a bounded prefix (e.g. 'projects/foo/' or 'projects/foo/*') or an exact key."));
578
612
  process.exit(1);
@@ -648,4 +682,4 @@ export async function runFilesDelete(params, deps = {}) {
648
682
  }
649
683
  }
650
684
  //# sourceMappingURL=files.js.map
651
- //# debugId=5f5242f3-b24f-58b0-a3ee-381c42c755fc
685
+ //# debugId=bc564dd4-d8c1-5d09-ad49-3bcd9f7328a6
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d01cb1a1-b851-5ffe-9608-e505e55dcdc8")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3049e431-c5db-5430-90fe-82866c35e95b")}catch(e){}}();
3
3
  import chalk from "chalk";
4
4
  import * as readline from "node:readline";
5
5
  import { spawn } from "node:child_process";
@@ -251,6 +251,11 @@ export async function loadRevealedSecrets(token, companyUid, keys, usage) {
251
251
  if (!res.ok) {
252
252
  const body = (await res.json().catch(() => ({})));
253
253
  const message = extractApiMessage(body, res.statusText);
254
+ // High-security ("nuclear") refusal surfaced at the batch level (rather
255
+ // than per-name): point the caller at the proxy and never leak plaintext.
256
+ if (body.code === "high_security_denied" || body.highSecurity === true) {
257
+ throw new Error("A requested secret is high-security and cannot be injected locally — it can only be used through the HQ secret proxy, which keeps the plaintext server-side.");
258
+ }
254
259
  if (res.status >= 400 &&
255
260
  res.status < 500 &&
256
261
  typeof body.code === "string") {
@@ -280,6 +285,15 @@ export async function loadRevealedSecrets(token, companyUid, keys, usage) {
280
285
  if (resolved.has(key))
281
286
  continue;
282
287
  const err = errorsByName.get(key);
288
+ // High-security ("nuclear") secret: the server refuses to vend it on the
289
+ // local-injection (batch-load) path — per-name code `high_security_denied`,
290
+ // no plaintext returned. Every caller of loadRevealedSecrets injects or
291
+ // prints the plaintext locally (`secrets get --reveal`, `secrets exec`,
292
+ // `secrets env`), so a high-security secret can NEVER be used here. Surface
293
+ // a clear, actionable error pointing at the proxy instead of a raw failure.
294
+ if (err?.code === "high_security_denied") {
295
+ throw new Error(`Secret '${key}' is high-security and cannot be injected locally — it can only be used through the HQ secret proxy, which keeps the plaintext server-side.`);
296
+ }
283
297
  const reason = err?.code === "not_found"
284
298
  ? "Secret not found"
285
299
  : err?.code === "forbidden"
@@ -364,6 +378,15 @@ export function registerSecretsCommand(program) {
364
378
  });
365
379
  if (!res.ok) {
366
380
  const body = (await res.json().catch(() => ({})));
381
+ // High-security ("nuclear") secret: the server refuses to reveal it on
382
+ // the local-injection path (403, no plaintext). Surface a clear,
383
+ // actionable error pointing the user at the proxy rather than a raw
384
+ // 4xx — the value can ONLY be used through the server-side proxy.
385
+ if (res.status === 403 && body.highSecurity === true) {
386
+ console.error(chalk.red(`Secret '${name}' is high-security and cannot be revealed locally.`));
387
+ console.error(chalk.dim(" It can only be used through the HQ secret proxy, which keeps the plaintext server-side."));
388
+ process.exit(1);
389
+ }
367
390
  console.error(chalk.red(`Failed to get secret: ${extractApiMessage(body, res.statusText)}`));
368
391
  process.exit(1);
369
392
  }
@@ -1125,4 +1148,4 @@ export function registerSecretsCommand(program) {
1125
1148
  });
1126
1149
  }
1127
1150
  //# sourceMappingURL=secrets.js.map
1128
- //# debugId=d01cb1a1-b851-5ffe-9608-e505e55dcdc8
1151
+ //# debugId=3049e431-c5db-5430-90fe-82866c35e95b
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="63aeb21a-b1e7-5bff-8c7d-560fad3cc0dd")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="20ece834-f9b5-5295-8620-87eb4f13ba7c")}catch(e){}}();
3
3
  import { ResolutionError } from 'varlock/plugin-lib';
4
4
  import { DEFAULT_SECRETS_CACHE_TTL_MS, readCache, writeCache, } from '../utils/secrets-cache.js';
5
5
  function normalizeCacheTtlMs(cacheTtlMs) {
@@ -59,6 +59,13 @@ export function installHqPlugin(graph /* EnvGraph */, opts) {
59
59
  if (err.code === 'not_found') {
60
60
  throw new ResolutionError(`Secret "${secretName}" does not exist in company`);
61
61
  }
62
+ // High-security ("nuclear") secret: the server refuses to vend it on
63
+ // the local-injection path. It can ONLY be used through the
64
+ // server-side proxy, so `hq run` (which injects plaintext into the
65
+ // child env) can never load it. Surface a clear, actionable error.
66
+ if (err.code === 'high_security_denied') {
67
+ throw new ResolutionError(`Secret "${secretName}" is high-security and cannot be injected locally — it can only be used via the HQ secret proxy (POST /secrets/{companyUid}/proxy/{path}), which keeps the plaintext server-side. Remove it from this schema's locally-injected vars.`);
68
+ }
62
69
  throw new ResolutionError(`Failed to load secret "${secretName}": ${err.message ?? err.code}`);
63
70
  }
64
71
  // Sentinel-check style throughout: `readCache` returns `string | null`
@@ -158,4 +165,4 @@ export async function prewarmHqSecrets(graph /* EnvGraph */, opts, state) {
158
165
  state.uid = uid;
159
166
  }
160
167
  //# sourceMappingURL=hq-plugin.js.map
161
- //# debugId=63aeb21a-b1e7-5bff-8c7d-560fad3cc0dd
168
+ //# debugId=20ece834-f9b5-5295-8620-87eb4f13ba7c
@@ -1,2 +1,2 @@
1
- export declare const BUNDLED_DSN = "https://ed8c1f7624b67945b43d485bbf98d0f7@o4507292345892864.ingest.us.sentry.io/4511263744786432";
1
+ export declare const BUNDLED_DSN = "https://467061dc39fb64644f5640a82d8949cf@o4507292345892864.ingest.us.sentry.io/4511597516226560";
2
2
  //# sourceMappingURL=sentry-dsn.generated.d.ts.map
@@ -1,5 +1,5 @@
1
1
 
2
2
  !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="55f2362e-5cf7-5dac-b6a3-ef0f9ccde645")}catch(e){}}();
3
- export const BUNDLED_DSN = "https://ed8c1f7624b67945b43d485bbf98d0f7@o4507292345892864.ingest.us.sentry.io/4511263744786432";
3
+ export const BUNDLED_DSN = "https://467061dc39fb64644f5640a82d8949cf@o4507292345892864.ingest.us.sentry.io/4511597516226560";
4
4
  //# sourceMappingURL=sentry-dsn.generated.js.map
5
5
  //# debugId=55f2362e-5cf7-5dac-b6a3-ef0f9ccde645
@@ -1,3 +1,4 @@
1
+ import { type VersionInfo } from "./feedback-versions.js";
1
2
  export interface GitContext {
2
3
  branch: string | null;
3
4
  head: string | null;
@@ -6,6 +7,12 @@ export interface GitContext {
6
7
  }
7
8
  export interface DiagnosticsBlob {
8
9
  cliVersion: string;
10
+ /**
11
+ * The hq-cli, hq-core, and hq-sync versions from the submitter's
12
+ * environment. `cliVersion` above is retained for back-compat; new
13
+ * consumers should read `versions` (which carries core + sync too).
14
+ */
15
+ versions: VersionInfo;
9
16
  nodeVersion: string;
10
17
  os: {
11
18
  platform: string;
@@ -1,9 +1,10 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ee39c63b-ddaa-553d-b5db-77633d323d88")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ae4c924b-fe3d-558c-8b44-e1bac1f5a73e")}catch(e){}}();
3
3
  import * as os from "os";
4
4
  import { execFileSync } from "child_process";
5
5
  import { getRecentBreadcrumbs } from "./breadcrumb-buffer.js";
6
6
  import { CLI_VERSION } from "../cli-version.js";
7
+ import { collectVersions } from "./feedback-versions.js";
7
8
  const SECRET_FLAGS = new Set([
8
9
  "--token",
9
10
  "--secret",
@@ -79,6 +80,7 @@ function collectGitContext() {
79
80
  export function collectDiagnostics() {
80
81
  return {
81
82
  cliVersion: CLI_VERSION,
83
+ versions: collectVersions(),
82
84
  nodeVersion: process.version,
83
85
  os: {
84
86
  platform: os.platform(),
@@ -92,4 +94,4 @@ export function collectDiagnostics() {
92
94
  };
93
95
  }
94
96
  //# sourceMappingURL=feedback-diagnostics.js.map
95
- //# debugId=ee39c63b-ddaa-553d-b5db-77633d323d88
97
+ //# debugId=ae4c924b-fe3d-558c-8b44-e1bac1f5a73e
@@ -0,0 +1,23 @@
1
+ export declare const MAX_SCREENSHOTS = 5;
2
+ export declare const MAX_SCREENSHOT_BYTES: number;
3
+ export declare function contentTypeForPath(filePath: string): string;
4
+ export interface ScreenshotInput {
5
+ path: string;
6
+ contentType: string;
7
+ bytes: Buffer;
8
+ }
9
+ /** Validate + read the given screenshot paths (count, type, existence, size). */
10
+ export declare function loadScreenshots(paths: string[]): ScreenshotInput[];
11
+ /**
12
+ * Validate the screenshot paths, request presigned PUT URLs from the feedback
13
+ * endpoint, upload each image direct to S3, and return the object keys to
14
+ * attach to the feedback submission. Returns [] for no screenshots.
15
+ *
16
+ * `fetchImpl` is injectable for tests; defaults to the global fetch.
17
+ */
18
+ export declare function uploadScreenshots(opts: {
19
+ paths: string[];
20
+ token: string;
21
+ fetchImpl?: typeof fetch;
22
+ }): Promise<string[]>;
23
+ //# sourceMappingURL=feedback-screenshots.d.ts.map
@@ -0,0 +1,98 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="13f46978-c3c8-532d-b0bb-e8febf876587")}catch(e){}}();
3
+ import * as fs from "node:fs";
4
+ import * as path from "node:path";
5
+ import { vaultApiFetch } from "./vault-api.js";
6
+ export const MAX_SCREENSHOTS = 5;
7
+ // Per-image ceiling. Screenshots are PNG/JPEG captures; 10 MB is generous.
8
+ export const MAX_SCREENSHOT_BYTES = 10 * 1024 * 1024;
9
+ // Extension → content type. Must stay in sync with the server's allowed set
10
+ // (hq-pro feedback-screenshots.ts ALLOWED_CONTENT_TYPES).
11
+ const EXT_CONTENT_TYPE = {
12
+ ".png": "image/png",
13
+ ".jpg": "image/jpeg",
14
+ ".jpeg": "image/jpeg",
15
+ ".webp": "image/webp",
16
+ ".gif": "image/gif",
17
+ };
18
+ export function contentTypeForPath(filePath) {
19
+ const ext = path.extname(filePath).toLowerCase();
20
+ const contentType = EXT_CONTENT_TYPE[ext];
21
+ if (!contentType) {
22
+ throw new Error(`unsupported screenshot type: ${filePath} (allowed: ${Object.keys(EXT_CONTENT_TYPE).join(", ")})`);
23
+ }
24
+ return contentType;
25
+ }
26
+ /** Validate + read the given screenshot paths (count, type, existence, size). */
27
+ export function loadScreenshots(paths) {
28
+ if (paths.length > MAX_SCREENSHOTS) {
29
+ throw new Error(`at most ${MAX_SCREENSHOTS} screenshots are allowed (got ${paths.length})`);
30
+ }
31
+ return paths.map((filePath) => {
32
+ const contentType = contentTypeForPath(filePath);
33
+ let bytes;
34
+ try {
35
+ bytes = fs.readFileSync(filePath);
36
+ }
37
+ catch {
38
+ throw new Error(`cannot read screenshot: ${filePath}`);
39
+ }
40
+ if (bytes.byteLength === 0) {
41
+ throw new Error(`screenshot is empty: ${filePath}`);
42
+ }
43
+ if (bytes.byteLength > MAX_SCREENSHOT_BYTES) {
44
+ throw new Error(`screenshot too large: ${filePath} (${bytes.byteLength} bytes, max ${MAX_SCREENSHOT_BYTES})`);
45
+ }
46
+ return { path: filePath, contentType, bytes };
47
+ });
48
+ }
49
+ /**
50
+ * Validate the screenshot paths, request presigned PUT URLs from the feedback
51
+ * endpoint, upload each image direct to S3, and return the object keys to
52
+ * attach to the feedback submission. Returns [] for no screenshots.
53
+ *
54
+ * `fetchImpl` is injectable for tests; defaults to the global fetch.
55
+ */
56
+ export async function uploadScreenshots(opts) {
57
+ if (opts.paths.length === 0)
58
+ return [];
59
+ const inputs = loadScreenshots(opts.paths);
60
+ const res = await vaultApiFetch({
61
+ token: opts.token,
62
+ path: "/v1/feedback/screenshots/presign",
63
+ method: "POST",
64
+ body: { contentTypes: inputs.map((i) => i.contentType) },
65
+ });
66
+ if (!res.ok) {
67
+ const data = await res.json().catch(() => ({}));
68
+ const msg = data &&
69
+ typeof data === "object" &&
70
+ typeof data.error === "string"
71
+ ? data.error
72
+ : res.statusText;
73
+ throw new Error(`Failed to presign screenshots: ${msg}`);
74
+ }
75
+ const parsed = (await res.json());
76
+ if (!parsed ||
77
+ !Array.isArray(parsed.screenshots) ||
78
+ parsed.screenshots.length !== inputs.length) {
79
+ throw new Error("Presign response did not match the requested screenshots");
80
+ }
81
+ const doFetch = opts.fetchImpl ?? fetch;
82
+ const keys = [];
83
+ for (let i = 0; i < inputs.length; i++) {
84
+ const slot = parsed.screenshots[i];
85
+ const put = await doFetch(slot.url, {
86
+ method: "PUT",
87
+ headers: { "Content-Type": slot.contentType },
88
+ body: inputs[i].bytes,
89
+ });
90
+ if (!put.ok) {
91
+ throw new Error(`Failed to upload screenshot ${inputs[i].path}: HTTP ${put.status}`);
92
+ }
93
+ keys.push(slot.key);
94
+ }
95
+ return keys;
96
+ }
97
+ //# sourceMappingURL=feedback-screenshots.js.map
98
+ //# debugId=13f46978-c3c8-532d-b0bb-e8febf876587
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The three HQ component versions captured from the submitter's environment
3
+ * and attached to a feedback submission so triage can see exactly which
4
+ * versions a report came from.
5
+ *
6
+ * - `cli` — this hq-cli build (always known).
7
+ * - `core` — the HQ scaffold version from `core/core.yaml` (`hqVersion`);
8
+ * null when the command runs outside an HQ tree.
9
+ * - `sync` — the installed hq-sync menubar app version, which the app
10
+ * records at `~/.hq/sync-version.json` on startup; null when
11
+ * hq-sync is not installed (e.g. CLI-only / CI environments).
12
+ */
13
+ export interface VersionInfo {
14
+ cli: string;
15
+ core: string | null;
16
+ sync: string | null;
17
+ }
18
+ /**
19
+ * Best-effort read of the hq-core scaffold version (`core/core.yaml`
20
+ * `hqVersion`). Resolves the HQ root from the working directory; returns
21
+ * null when no HQ root / core.yaml is found rather than throwing — version
22
+ * capture must never break a feedback submission.
23
+ */
24
+ export declare function readCoreVersion(): string | null;
25
+ /**
26
+ * Best-effort read of the hq-sync menubar app version. The app writes
27
+ * `{ version, updatedAt }` to `~/.hq/sync-version.json` on startup; the CLI
28
+ * reads it here. Returns null when the file is absent or malformed (hq-sync
29
+ * not installed, or an older build that predates the marker).
30
+ */
31
+ export declare function readSyncVersion(homeDir?: string): string | null;
32
+ /** Collect all three component versions, each independently best-effort. */
33
+ export declare function collectVersions(): VersionInfo;
34
+ //# sourceMappingURL=feedback-versions.d.ts.map
@@ -0,0 +1,50 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ea3328d1-5c42-5d60-ad24-f96c11a37f22")}catch(e){}}();
3
+ import * as fs from "node:fs";
4
+ import * as os from "node:os";
5
+ import * as path from "node:path";
6
+ import { CLI_VERSION } from "../cli-version.js";
7
+ import { findHqRoot } from "./manifest.js";
8
+ import { readHqVersion } from "./pack-contributions.js";
9
+ /**
10
+ * Best-effort read of the hq-core scaffold version (`core/core.yaml`
11
+ * `hqVersion`). Resolves the HQ root from the working directory; returns
12
+ * null when no HQ root / core.yaml is found rather than throwing — version
13
+ * capture must never break a feedback submission.
14
+ */
15
+ export function readCoreVersion() {
16
+ try {
17
+ return readHqVersion(findHqRoot());
18
+ }
19
+ catch {
20
+ return null;
21
+ }
22
+ }
23
+ /**
24
+ * Best-effort read of the hq-sync menubar app version. The app writes
25
+ * `{ version, updatedAt }` to `~/.hq/sync-version.json` on startup; the CLI
26
+ * reads it here. Returns null when the file is absent or malformed (hq-sync
27
+ * not installed, or an older build that predates the marker).
28
+ */
29
+ export function readSyncVersion(homeDir = os.homedir()) {
30
+ try {
31
+ const raw = fs.readFileSync(path.join(homeDir, ".hq", "sync-version.json"), "utf-8");
32
+ const parsed = JSON.parse(raw);
33
+ return typeof parsed.version === "string" && parsed.version.length > 0
34
+ ? parsed.version
35
+ : null;
36
+ }
37
+ catch {
38
+ return null;
39
+ }
40
+ }
41
+ /** Collect all three component versions, each independently best-effort. */
42
+ export function collectVersions() {
43
+ return {
44
+ cli: CLI_VERSION,
45
+ core: readCoreVersion(),
46
+ sync: readSyncVersion(),
47
+ };
48
+ }
49
+ //# sourceMappingURL=feedback-versions.js.map
50
+ //# debugId=ea3328d1-5c42-5d60-ad24-f96c11a37f22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigoai-us/hq-cli",
3
- "version": "5.47.16",
3
+ "version": "5.47.17",
4
4
  "description": "HQ by Indigo management CLI — modules and cloud sync",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -156,6 +156,24 @@ describe("submitFeedback", () => {
156
156
  expect((call.body as Record<string, unknown>)).not.toHaveProperty("company");
157
157
  });
158
158
 
159
+ it("includes screenshot keys when provided, omits the key otherwise", async () => {
160
+ mockVaultApiFetch.mockResolvedValueOnce(jsonResponse(200, { id: "feedback_s1" }));
161
+ await submitFeedback({
162
+ type: "bug",
163
+ title: "With shots",
164
+ body: "Details",
165
+ token: "tok",
166
+ screenshots: ["feedback-screenshots/prs_a/sub/0.png"],
167
+ });
168
+ expect((mockVaultApiFetch.mock.calls[0][0].body as Record<string, unknown>).screenshots).toEqual([
169
+ "feedback-screenshots/prs_a/sub/0.png",
170
+ ]);
171
+
172
+ mockVaultApiFetch.mockResolvedValueOnce(jsonResponse(200, { id: "feedback_s2" }));
173
+ await submitFeedback({ type: "bug", title: "No shots", body: "Details", token: "tok", screenshots: [] });
174
+ expect(mockVaultApiFetch.mock.calls[1][0].body).not.toHaveProperty("screenshots");
175
+ });
176
+
159
177
  it("attaches diagnostics from collectDiagnostics to the request body", async () => {
160
178
  mockVaultApiFetch.mockResolvedValueOnce(
161
179
  jsonResponse(200, { id: "feedback_diag" }),
@@ -249,6 +267,32 @@ describe("submitFeedback", () => {
249
267
 
250
268
  expect(mockVaultApiFetch).not.toHaveBeenCalled();
251
269
  });
270
+
271
+ // HQ-AB: an empty/whitespace title (e.g. `--title ""`, or a title the /hq-bug
272
+ // skill derived to nothing) used to slip past Commander's required-flag check
273
+ // and 400 server-side, flooding Sentry with a context-free warning. The local
274
+ // guard now rejects it before any network call.
275
+ it("throws before fetching when title is empty or whitespace-only", async () => {
276
+ await expect(
277
+ submitFeedback({
278
+ type: "bug",
279
+ title: " \n\t ",
280
+ body: "Real body",
281
+ token: "tok",
282
+ }),
283
+ ).rejects.toThrow(/title must not be empty/);
284
+
285
+ await expect(
286
+ submitFeedback({
287
+ type: "feature",
288
+ title: "",
289
+ body: "Real body",
290
+ token: "tok",
291
+ }),
292
+ ).rejects.toThrow(/title must not be empty/);
293
+
294
+ expect(mockVaultApiFetch).not.toHaveBeenCalled();
295
+ });
252
296
  });
253
297
 
254
298
  // ---------------------------------------------------------------------------