@pxlabz/tasq-cli 0.1.13 → 0.1.15

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.
Files changed (2) hide show
  1. package/dist/tasq.js +142 -12
  2. package/package.json +2 -2
package/dist/tasq.js CHANGED
@@ -6502,6 +6502,7 @@ function toTasqError(status, body, retryAfterHeader) {
6502
6502
  }
6503
6503
 
6504
6504
  // ../sdk/src/client.ts
6505
+ var PROJECT_UPDATES_PAGE_MAX = 100;
6505
6506
  function assertPrefix(token, prefix, label) {
6506
6507
  if (!token.startsWith(prefix)) {
6507
6508
  throw new Error(
@@ -6675,10 +6676,32 @@ var TasqClient = class _TasqClient {
6675
6676
  * approving it.
6676
6677
  */
6677
6678
  projectUpdates = {
6678
- /** Every update on the project, drafts included, newest first. */
6679
- list: async (slug, projectId) => (await this.#get(
6680
- `/workspaces/${encodeURIComponent(slug)}/projects/${encodeURIComponent(projectId)}/updates`
6681
- )).updates,
6679
+ /**
6680
+ * Every update on the project, drafts included, newest first. Follows
6681
+ * `nextCursor` until the last page; use `listPage` for one page.
6682
+ */
6683
+ list: async (slug, projectId) => {
6684
+ const updates = [];
6685
+ let before;
6686
+ do {
6687
+ const page = await this.projectUpdates.listPage(slug, projectId, {
6688
+ limit: PROJECT_UPDATES_PAGE_MAX,
6689
+ before
6690
+ });
6691
+ updates.push(...page.updates);
6692
+ before = page.nextCursor ?? void 0;
6693
+ } while (before !== void 0);
6694
+ return updates;
6695
+ },
6696
+ /**
6697
+ * One page of the project's updates, drafts included, newest first; pass
6698
+ * `nextCursor` as `before` for the next. The API returns 20 by default,
6699
+ * at most 100.
6700
+ */
6701
+ listPage: (slug, projectId, query = {}) => this.#get(
6702
+ `/workspaces/${encodeURIComponent(slug)}/projects/${encodeURIComponent(projectId)}/updates`,
6703
+ { limit: query.limit, before: query.before }
6704
+ ),
6682
6705
  draft: (slug, input) => this.dispatch("projectUpdate.create", slug, input),
6683
6706
  create: (slug, input) => this.dispatch("projectUpdate.create", slug, input),
6684
6707
  update: (slug, input) => this.dispatch("projectUpdate.update", slug, input),
@@ -6798,6 +6821,19 @@ var TasqClient = class _TasqClient {
6798
6821
  { unread: query.unread === true ? 1 : void 0 }
6799
6822
  )
6800
6823
  };
6824
+ activity = {
6825
+ /** The workspace activity feed, newest first; page with `nextCursor`. */
6826
+ list: (slug, query = {}) => this.#get(
6827
+ `/workspaces/${encodeURIComponent(slug)}/activity`,
6828
+ { limit: query.limit, before: query.before }
6829
+ )
6830
+ };
6831
+ waiting = {
6832
+ /** Approvals and agent drafts waiting on the caller. People only. */
6833
+ get: (slug) => this.#get(
6834
+ `/workspaces/${encodeURIComponent(slug)}/waiting`
6835
+ )
6836
+ };
6801
6837
  auth = {
6802
6838
  /** The principal behind the current credential. */
6803
6839
  me: async () => (await this.#get("/auth/me")).user,
@@ -6910,7 +6946,7 @@ function reportError(error, io2) {
6910
6946
  // package.json
6911
6947
  var package_default = {
6912
6948
  name: "@pxlabz/tasq-cli",
6913
- version: "0.1.13",
6949
+ version: "0.1.15",
6914
6950
  description: "Command-line client for Tasq, for humans and agents alike",
6915
6951
  keywords: [
6916
6952
  "tasq",
@@ -7050,9 +7086,6 @@ function requireWorkspace(config) {
7050
7086
  return config.workspace;
7051
7087
  }
7052
7088
 
7053
- // src/commands/auth.ts
7054
- import { hostname } from "os";
7055
-
7056
7089
  // src/output.ts
7057
7090
  var import_cli_table3 = __toESM(require_cli_table3(), 1);
7058
7091
  function jsonOutput(value) {
@@ -7158,7 +7191,88 @@ function line(io2, value) {
7158
7191
  io2.out(JSON.stringify(value));
7159
7192
  }
7160
7193
 
7194
+ // src/commands/activity.ts
7195
+ var MAX_LIMIT = 100;
7196
+ function parseLimit(raw) {
7197
+ if (raw === void 0) return void 0;
7198
+ const limit = Number(raw);
7199
+ if (!Number.isInteger(limit) || limit < 1 || limit > MAX_LIMIT) {
7200
+ throw new UsageError(
7201
+ `--limit must be a whole number from 1 to ${MAX_LIMIT}.`
7202
+ );
7203
+ }
7204
+ return limit;
7205
+ }
7206
+ function timestamp(iso) {
7207
+ return `${iso.slice(0, 10)} ${iso.slice(11, 16)}`;
7208
+ }
7209
+ function activityLine(item) {
7210
+ const actor = item.actor.kind === "agent" ? `${item.actor.name} (agent)` : item.actor.name;
7211
+ const subject = item.subject.key ? `${item.subject.key} ${item.subject.title}` : item.subject.title;
7212
+ return `${timestamp(item.occurredAt)} ${actor} ${item.summary} ${subject}`;
7213
+ }
7214
+ async function activityList(ctx, options) {
7215
+ const limit = parseLimit(options.limit);
7216
+ const slug = requireWorkspace(ctx.config);
7217
+ const page = await ctx.client.activity.list(slug, { limit });
7218
+ if (ctx.config.json) {
7219
+ ctx.io.out(jsonOutput(page));
7220
+ return;
7221
+ }
7222
+ if (page.items.length === 0) {
7223
+ ctx.io.out("No activity yet.");
7224
+ return;
7225
+ }
7226
+ for (const item of page.items) ctx.io.out(activityLine(item));
7227
+ }
7228
+ function waitingLines(waiting) {
7229
+ const lines = [];
7230
+ if (waiting.approvals.length > 0) {
7231
+ lines.push(`Approvals (${waiting.approvals.length})`);
7232
+ for (const approval of waiting.approvals) {
7233
+ const parts = [`${approval.taskKey} ${approval.title}`];
7234
+ if (approval.projectName) parts.push(approval.projectName);
7235
+ if (approval.requestedBy) {
7236
+ parts.push(`asked by ${approval.requestedBy.name}`);
7237
+ }
7238
+ lines.push(` ${parts.join(" \xB7 ")}`);
7239
+ }
7240
+ }
7241
+ if (waiting.drafts.length > 0) {
7242
+ if (lines.length > 0) lines.push("");
7243
+ lines.push(`Drafts to review (${waiting.drafts.length})`);
7244
+ for (const draft of waiting.drafts) {
7245
+ lines.push(
7246
+ ` ${draft.updateId} ${draft.projectName} \xB7 ${draft.health} \xB7 by ${draft.author.name}`
7247
+ );
7248
+ if (draft.bodyExcerpt) lines.push(` ${draft.bodyExcerpt}`);
7249
+ }
7250
+ }
7251
+ return lines;
7252
+ }
7253
+ async function waitingShow(ctx) {
7254
+ const slug = requireWorkspace(ctx.config);
7255
+ const credential2 = ctx.config.credential;
7256
+ if (credential2 !== void 0 && "agentKey" in credential2) {
7257
+ throw new PersonOnlyError(
7258
+ "Waiting items belong to a person. Sign in with `tasq auth login` to see yours."
7259
+ );
7260
+ }
7261
+ const waiting = await ctx.client.waiting.get(slug);
7262
+ if (ctx.config.json) {
7263
+ ctx.io.out(jsonOutput(waiting));
7264
+ return;
7265
+ }
7266
+ const lines = waitingLines(waiting);
7267
+ if (lines.length === 0) {
7268
+ ctx.io.out("Nothing is waiting for you.");
7269
+ return;
7270
+ }
7271
+ for (const line2 of lines) ctx.io.out(line2);
7272
+ }
7273
+
7161
7274
  // src/commands/auth.ts
7275
+ import { hostname } from "os";
7162
7276
  var EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
7163
7277
  var CODE_PATTERN = /^\d{6}$/;
7164
7278
  async function authLogin(ctx, options, prompts) {
@@ -8275,10 +8389,22 @@ function draftBody(options, deps) {
8275
8389
  "Pass the update with --body <markdown> or --file <path>."
8276
8390
  );
8277
8391
  }
8278
- async function updateList(ctx, projectRef) {
8392
+ var MAX_LIST_LIMIT = 100;
8393
+ function parseListLimit(raw) {
8394
+ if (raw === void 0) return void 0;
8395
+ const limit = Number(raw);
8396
+ if (!Number.isInteger(limit) || limit < 1 || limit > MAX_LIST_LIMIT) {
8397
+ throw new UsageError(
8398
+ `--limit must be a whole number from 1 to ${MAX_LIST_LIMIT}.`
8399
+ );
8400
+ }
8401
+ return limit;
8402
+ }
8403
+ async function updateList(ctx, projectRef, options) {
8404
+ const limit = parseListLimit(options.limit);
8279
8405
  const slug = requireWorkspace(ctx.config);
8280
8406
  const projectId = await resolveProjectId(ctx, slug, projectRef);
8281
- const updates = await ctx.client.projectUpdates.list(slug, projectId);
8407
+ const updates = limit === void 0 ? await ctx.client.projectUpdates.list(slug, projectId) : (await ctx.client.projectUpdates.listPage(slug, projectId, { limit })).updates;
8282
8408
  ctx.io.out(
8283
8409
  ctx.config.json ? jsonOutput(updates) : formatProjectUpdates(updates)
8284
8410
  );
@@ -8496,8 +8622,8 @@ function buildProgram(io2) {
8496
8622
  await initiativeUnlink(contextFor(program2, io2), ref, projectRef);
8497
8623
  });
8498
8624
  const update = program2.command("update").description("Project updates: agents draft, a person sends");
8499
- update.command("list").argument("<project>", "project id or name").description("List a project's updates, drafts included, newest first").action(async (projectRef) => {
8500
- await updateList(contextFor(program2, io2), projectRef);
8625
+ update.command("list").argument("<project>", "project id or name").description("List a project's updates, drafts included, newest first").option("--limit <n>", "only the latest n updates, 1-100 (default: all)").action(async (projectRef, options) => {
8626
+ await updateList(contextFor(program2, io2), projectRef, options);
8501
8627
  });
8502
8628
  update.command("draft").argument("<project>", "project id or name").description("Draft an update for a person to review and send").option("--health <health>", "on_track | at_risk | off_track").option("--body <markdown>", "the update itself").option("--file <path>", "read the update from a file").action(
8503
8629
  async (projectRef, options) => {
@@ -8510,6 +8636,10 @@ function buildProgram(io2) {
8510
8636
  update.command("delete").argument("<updateId>", "update id").description("Delete a draft").action(async (updateId) => {
8511
8637
  await updateDelete(contextFor(program2, io2), updateId);
8512
8638
  });
8639
+ program2.command("activity").description("Recent activity in the workspace, newest first").option("--limit <n>", "how many rows, 1-100 (default 30)").action(async (options) => {
8640
+ await activityList(contextFor(program2, io2), options);
8641
+ });
8642
+ program2.command("waiting").description("Approvals and agent drafts waiting on you (people only)").action(run((ctx) => waitingShow(ctx)));
8513
8643
  const cycle = program2.command("cycle").description("Cycles");
8514
8644
  cycle.command("current").description("Show the active cycle and its tasks").option("--team <identifier>", "team identifier").action(async (options) => {
8515
8645
  await cycleCurrent(contextFor(program2, io2), { team: options.team });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pxlabz/tasq-cli",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Command-line client for Tasq, for humans and agents alike",
5
5
  "keywords": [
6
6
  "tasq",
@@ -49,7 +49,7 @@
49
49
  "commander": "^14.0.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@pxlabz/tasq-sdk": "0.1.4",
52
+ "@pxlabz/tasq-sdk": "0.1.13",
53
53
  "@types/bun": "^1.3.12",
54
54
  "tsup": "^8.5.0",
55
55
  "typescript": "^5.7.2"