@dench.com/cli 3.12.29 → 3.12.31-staging.1469

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/members.ts CHANGED
@@ -32,11 +32,18 @@
32
32
  * Both surfaces share this implementation so the CLI auth + payload
33
33
  * shape stays in lockstep.
34
34
  */
35
+ import { createHash } from "node:crypto";
35
36
  import { readFile } from "node:fs/promises";
36
37
  import { extname } from "node:path";
37
38
  import type { ConvexHttpClient } from "convex/browser";
38
39
  import { makeFunctionReference } from "convex/server";
39
- import { CliArgError, getFlag, hasFlag, shift } from "./lib/cli-args";
40
+ import {
41
+ CliArgError,
42
+ getFlag,
43
+ hasFlag,
44
+ parsePositiveInt,
45
+ shift,
46
+ } from "./lib/cli-args";
40
47
 
41
48
  class MembersCliError extends Error {}
42
49
 
@@ -253,11 +260,7 @@ async function runMemberActivity(ctx: MembersCliContext): Promise<void> {
253
260
  const rawLimit = getFlag(ctx.args, "--limit");
254
261
  const rawKinds = getFlag(ctx.args, "--kinds");
255
262
  assertNoFlags(ctx, "dench members activity");
256
- const limit =
257
- rawLimit === undefined ? undefined : Number.parseInt(rawLimit, 10);
258
- if (limit !== undefined && (!Number.isFinite(limit) || limit < 1)) {
259
- throw new MembersCliError("--limit must be a positive integer");
260
- }
263
+ const limit = parsePositiveInt(rawLimit, "--limit");
261
264
  const kinds = rawKinds
262
265
  ?.split(",")
263
266
  .map((kind) => kind.trim())
@@ -284,6 +287,7 @@ async function runMemberTasks(ctx: MembersCliContext): Promise<void> {
284
287
  const paged = hasFlag(ctx.args, "--page") || cursor !== undefined;
285
288
  const done = hasFlag(ctx.args, "--done");
286
289
  assertNoFlags(ctx, "dench members tasks");
290
+ const limit = parsePositiveInt(rawLimit, "--limit");
287
291
  const userId = await resolveMemberId(ctx, target);
288
292
  const todayStart = new Date();
289
293
  todayStart.setHours(0, 0, 0, 0);
@@ -303,11 +307,11 @@ async function runMemberTasks(ctx: MembersCliContext): Promise<void> {
303
307
  done,
304
308
  paginationOpts: {
305
309
  cursor: cursor ?? null,
306
- numItems: Number.parseInt(rawLimit ?? "25", 10),
310
+ numItems: limit ?? 25,
307
311
  },
308
312
  }
309
- : rawLimit
310
- ? { limit: Number.parseInt(rawLimit, 10) }
313
+ : limit !== undefined
314
+ ? { limit }
311
315
  : {}),
312
316
  },
313
317
  ),
@@ -377,11 +381,11 @@ async function uploadAvatar(
377
381
  if (bytes.byteLength > 2 * 1024 * 1024) {
378
382
  throw new MembersCliError("--avatar must be under 2 MB");
379
383
  }
380
- const uploadUrl = (await callMutation(
381
- ctx,
382
- api.profiles.avatarUploadUrl,
383
- {},
384
- )) as string;
384
+ const sha256 = createHash("sha256").update(bytes).digest("hex");
385
+ const uploadUrl = (await callMutation(ctx, api.profiles.avatarUploadUrl, {
386
+ sha256,
387
+ size: bytes.byteLength,
388
+ })) as string;
385
389
  const response = await fetch(uploadUrl, {
386
390
  method: "POST",
387
391
  headers: { "Content-Type": contentType },
@@ -391,7 +395,7 @@ async function uploadAvatar(
391
395
  throw new MembersCliError(`Avatar upload failed (${response.status})`);
392
396
  }
393
397
  const { storageId } = (await response.json()) as { storageId: string };
394
- await callMutation(ctx, api.profiles.setAvatar, { storageId });
398
+ await callMutation(ctx, api.profiles.setAvatar, { storageId, sha256 });
395
399
  }
396
400
 
397
401
  function shiftArg(ctx: MembersCliContext, expected: string): string {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dench.com/cli",
3
- "version": "3.12.29",
3
+ "version": "3.12.31-staging.1469",
4
4
  "description": "Dench agent workspace CLI.",
5
5
  "type": "module",
6
6
  "bin": {
package/search.ts CHANGED
@@ -478,6 +478,7 @@ async function runContentsSubcommand(ctx: SearchCliContext): Promise<void> {
478
478
  getFlag(ctx.args, "--max-chars"),
479
479
  );
480
480
  const summary = getFlag(ctx.args, "--summary");
481
+ assertNoUnknownFlags(ctx.args, "search contents");
481
482
  const urls = ctx.args.slice();
482
483
  ctx.args.length = 0;
483
484
  if (urls.length === 0) {
@@ -501,6 +502,7 @@ async function runContentsSubcommand(ctx: SearchCliContext): Promise<void> {
501
502
  }
502
503
 
503
504
  async function runAnswerSubcommand(ctx: SearchCliContext): Promise<void> {
505
+ assertNoUnknownFlags(ctx.args, "search answer");
504
506
  const queryParts = ctx.args.slice();
505
507
  ctx.args.length = 0;
506
508
  const query = queryParts.join(" ").trim();
package/web.ts CHANGED
@@ -358,7 +358,13 @@ export async function runWebCommand(ctx: WebCliContext): Promise<void> {
358
358
  await runWebSubcommand(ctx);
359
359
  } catch (error) {
360
360
  if (error instanceof WebCliError) {
361
- console.error(error.message);
361
+ if (ctx.jsonOutput) {
362
+ console.error(
363
+ JSON.stringify({ ok: false, error: error.message }, null, 2),
364
+ );
365
+ } else {
366
+ console.error(error.message);
367
+ }
362
368
  process.exitCode = 1;
363
369
  return;
364
370
  }