@pxlabz/tasq-cli 0.1.12 → 0.1.14

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/.tasq-skill.md CHANGED
@@ -71,6 +71,11 @@ tasq release diff <releaseId>
71
71
  tasq release export <releaseId> [--out <file>]
72
72
  tasq release narrate <releaseId> (--body <markdown> | --file <path>)
73
73
 
74
+ tasq update list <project>
75
+ tasq update draft <project> --health <on_track|at_risk|off_track> (--body <markdown> | --file <path>)
76
+ tasq update send <updateId>
77
+ tasq update delete <updateId>
78
+
74
79
  tasq auth login [--email <email>]
75
80
  tasq auth logout
76
81
  tasq auth whoami
@@ -154,6 +159,12 @@ Three things to know before you write:
154
159
 
155
160
  `tasq release list --team ENG` is the timeline, newest first; `tasq release view <releaseId>` shows one in full; `tasq release export <releaseId>` prints it as Markdown for a changelog. `examples/release-narrator.sh` in this package is a working reference for the loop above, minus the writing.
156
161
 
162
+ ## Project updates
163
+
164
+ A project update is a health call (`on_track`, `at_risk` or `off_track`) and a Markdown body for the project's client. `<project>` is a project id or its exact name, ignoring case.
165
+
166
+ You draft; a person sends. `tasq update draft` always writes a draft, and nothing an agent drafts goes to a client until a person reviews and sends it. `tasq update send` is refused for an agent key before any request (exit 4), and no policy can grant it. Drafts can be edited or deleted by their author; a sent update is final. `tasq update list` shows drafts and sent updates, newest first, and the project's health is its latest sent update.
167
+
157
168
  ## Exit codes
158
169
 
159
170
  | Code | Meaning |
@@ -162,7 +173,7 @@ Three things to know before you write:
162
173
  | 1 | Error; details on stderr |
163
174
  | 2 | Usage error — a bad flag, or a `--mention` name matching no agent or more than one |
164
175
  | 3 | Rate limited; the message says when to retry. `events listen` never exits here — it waits and continues |
165
- | 4 | Your policy denied the action. Do not retry it; say what was refused |
176
+ | 4 | Your policy denied the action, or it is one only a person may run (`update send`). Do not retry it; say what was refused |
166
177
 
167
178
  ## Working with other agents
168
179
 
package/README.md CHANGED
@@ -30,7 +30,9 @@ tasq task list | view <ref> | create | update <ref>
30
30
  tasq comment add <ref> <body> [--reply-to <commentRef>] [--mention <agentName>]…
31
31
  tasq events listen [--wait <seconds>] [--once]
32
32
  tasq events ack <id>…
33
- tasq project list
33
+ tasq project list | star <project> | unstar <project>
34
+ tasq initiative list | create <name> | rename <initiative> <name> | archive <initiative>
35
+ tasq initiative link <initiative> <project> | unlink <initiative> <project>
34
36
  tasq cycle current
35
37
  tasq auth login | logout
36
38
  ```
package/dist/tasq.js CHANGED
@@ -6625,7 +6625,18 @@ var TasqClient = class _TasqClient {
6625
6625
  )).tasks,
6626
6626
  get: async (slug, taskId) => (await this.#get(
6627
6627
  `/workspaces/${encodeURIComponent(slug)}/tasks/${encodeURIComponent(taskId)}`
6628
- )).task
6628
+ )).task,
6629
+ /**
6630
+ * Ask a person to sign off on a task (6.3). Asking again while a
6631
+ * request stands replaces the approver. The approver cannot be an agent.
6632
+ */
6633
+ requestApproval: (slug, taskId, approverId) => this.dispatch("task.requestApproval", slug, { taskId, approverId }),
6634
+ /**
6635
+ * The approver's answer (6.3). `approve` also moves the task to the next
6636
+ * status in its team's category order. Person credentials only: no
6637
+ * agent policy can include it.
6638
+ */
6639
+ decide: (slug, taskId, decision) => this.dispatch("task.decide", slug, { taskId, decision })
6629
6640
  };
6630
6641
  projects = {
6631
6642
  list: async (slug) => (await this.#get(
@@ -6633,7 +6644,46 @@ var TasqClient = class _TasqClient {
6633
6644
  )).projects,
6634
6645
  get: async (slug, projectId) => (await this.#get(
6635
6646
  `/workspaces/${encodeURIComponent(slug)}/projects/${encodeURIComponent(projectId)}`
6636
- )).project
6647
+ )).project,
6648
+ /**
6649
+ * Pin a project to the caller's own sidebar. People only: an agent
6650
+ * key is refused by policy whatever its preset.
6651
+ */
6652
+ star: (slug, input) => this.dispatch("project.star", slug, input),
6653
+ unstar: (slug, input) => this.dispatch("project.unstar", slug, input)
6654
+ };
6655
+ /**
6656
+ * Initiatives group projects across teams. Any member reads them; every
6657
+ * write is admin-level, so an agent key (always a member) cannot make one.
6658
+ */
6659
+ initiatives = {
6660
+ list: async (slug) => (await this.#get(
6661
+ `/workspaces/${encodeURIComponent(slug)}/initiatives`
6662
+ )).initiatives,
6663
+ create: (slug, input) => this.dispatch("initiative.create", slug, input),
6664
+ update: (slug, input) => this.dispatch("initiative.update", slug, input),
6665
+ delete: (slug, input) => this.dispatch("initiative.delete", slug, input),
6666
+ linkProject: (slug, input) => this.dispatch("initiative.linkProject", slug, input),
6667
+ unlinkProject: (slug, input) => this.dispatch("initiative.unlinkProject", slug, input)
6668
+ };
6669
+ /**
6670
+ * Project updates: a health call and a body for the project's client (7.5).
6671
+ *
6672
+ * `draft` is what an agent calls; an agent's update is always a draft
6673
+ * whatever it passes. `send` is people only: no agent policy can grant it,
6674
+ * because nothing an agent drafts goes to a client without a person
6675
+ * approving it.
6676
+ */
6677
+ 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,
6682
+ draft: (slug, input) => this.dispatch("projectUpdate.create", slug, input),
6683
+ create: (slug, input) => this.dispatch("projectUpdate.create", slug, input),
6684
+ update: (slug, input) => this.dispatch("projectUpdate.update", slug, input),
6685
+ send: (slug, input) => this.dispatch("projectUpdate.send", slug, input),
6686
+ delete: (slug, input) => this.dispatch("projectUpdate.delete", slug, input)
6637
6687
  };
6638
6688
  threads = {
6639
6689
  /**
@@ -6748,6 +6798,19 @@ var TasqClient = class _TasqClient {
6748
6798
  { unread: query.unread === true ? 1 : void 0 }
6749
6799
  )
6750
6800
  };
6801
+ activity = {
6802
+ /** The workspace activity feed, newest first; page with `nextCursor`. */
6803
+ list: (slug, query = {}) => this.#get(
6804
+ `/workspaces/${encodeURIComponent(slug)}/activity`,
6805
+ { limit: query.limit, before: query.before }
6806
+ )
6807
+ };
6808
+ waiting = {
6809
+ /** Approvals and agent drafts waiting on the caller. People only. */
6810
+ get: (slug) => this.#get(
6811
+ `/workspaces/${encodeURIComponent(slug)}/waiting`
6812
+ )
6813
+ };
6751
6814
  auth = {
6752
6815
  /** The principal behind the current credential. */
6753
6816
  me: async () => (await this.#get("/auth/me")).user,
@@ -6780,6 +6843,11 @@ var TasqClient = class _TasqClient {
6780
6843
  };
6781
6844
 
6782
6845
  // ../sdk/src/types.ts
6846
+ var PROJECT_HEALTH_VALUES = [
6847
+ "on_track",
6848
+ "at_risk",
6849
+ "off_track"
6850
+ ];
6783
6851
  var MAX_AGENT_WAKES_PER_MESSAGE = 10;
6784
6852
  var MAX_CONSECUTIVE_AGENT_MESSAGES = 5;
6785
6853
  var RELEASE_NARRATIVE_MAX = 5e4;
@@ -6796,6 +6864,12 @@ var UsageError = class extends Error {
6796
6864
  this.name = "UsageError";
6797
6865
  }
6798
6866
  };
6867
+ var PersonOnlyError = class extends Error {
6868
+ constructor(message) {
6869
+ super(message);
6870
+ this.name = "PersonOnlyError";
6871
+ }
6872
+ };
6799
6873
  var STEP_CONTEXT = /* @__PURE__ */ Symbol.for("tasq.stepContext");
6800
6874
  function attachStepContext(error, context) {
6801
6875
  error[STEP_CONTEXT] = context;
@@ -6817,6 +6891,10 @@ function reportError(error, io2) {
6817
6891
  io2.err(error.message);
6818
6892
  return EXIT_USAGE;
6819
6893
  }
6894
+ if (error instanceof PersonOnlyError) {
6895
+ io2.err(error.message);
6896
+ return EXIT_POLICY_DENIED;
6897
+ }
6820
6898
  if (error instanceof TasqRateLimitError) {
6821
6899
  io2.err(`Rate limited. Retry after ${error.retryAfterSeconds}s.`);
6822
6900
  return EXIT_RATE_LIMITED;
@@ -6845,7 +6923,7 @@ function reportError(error, io2) {
6845
6923
  // package.json
6846
6924
  var package_default = {
6847
6925
  name: "@pxlabz/tasq-cli",
6848
- version: "0.1.12",
6926
+ version: "0.1.14",
6849
6927
  description: "Command-line client for Tasq, for humans and agents alike",
6850
6928
  keywords: [
6851
6929
  "tasq",
@@ -6985,9 +7063,6 @@ function requireWorkspace(config) {
6985
7063
  return config.workspace;
6986
7064
  }
6987
7065
 
6988
- // src/commands/auth.ts
6989
- import { hostname } from "os";
6990
-
6991
7066
  // src/output.ts
6992
7067
  var import_cli_table3 = __toESM(require_cli_table3(), 1);
6993
7068
  function jsonOutput(value) {
@@ -7026,6 +7101,30 @@ function formatProjects(projects) {
7026
7101
  ])
7027
7102
  );
7028
7103
  }
7104
+ function formatInitiatives(initiatives) {
7105
+ if (initiatives.length === 0) return "No initiatives.";
7106
+ return table(
7107
+ ["Name", "Status", "Projects"],
7108
+ initiatives.map((initiative) => [
7109
+ initiative.name,
7110
+ initiative.status,
7111
+ String(initiative.projectIds.length)
7112
+ ])
7113
+ );
7114
+ }
7115
+ function formatProjectUpdates(updates) {
7116
+ if (updates.length === 0) return "No updates.";
7117
+ return table(
7118
+ ["Id", "Health", "State", "Author", "Date"],
7119
+ updates.map((update) => [
7120
+ update.id,
7121
+ update.health,
7122
+ update.sentAt === null ? "Draft" : "Sent",
7123
+ dash(update.author?.name),
7124
+ (update.sentAt ?? update.createdAt).slice(0, 10)
7125
+ ])
7126
+ );
7127
+ }
7029
7128
  function formatCycles(cycles) {
7030
7129
  if (cycles.length === 0) return "No cycles.";
7031
7130
  return table(
@@ -7069,7 +7168,88 @@ function line(io2, value) {
7069
7168
  io2.out(JSON.stringify(value));
7070
7169
  }
7071
7170
 
7171
+ // src/commands/activity.ts
7172
+ var MAX_LIMIT = 100;
7173
+ function parseLimit(raw) {
7174
+ if (raw === void 0) return void 0;
7175
+ const limit = Number(raw);
7176
+ if (!Number.isInteger(limit) || limit < 1 || limit > MAX_LIMIT) {
7177
+ throw new UsageError(
7178
+ `--limit must be a whole number from 1 to ${MAX_LIMIT}.`
7179
+ );
7180
+ }
7181
+ return limit;
7182
+ }
7183
+ function timestamp(iso) {
7184
+ return `${iso.slice(0, 10)} ${iso.slice(11, 16)}`;
7185
+ }
7186
+ function activityLine(item) {
7187
+ const actor = item.actor.kind === "agent" ? `${item.actor.name} (agent)` : item.actor.name;
7188
+ const subject = item.subject.key ? `${item.subject.key} ${item.subject.title}` : item.subject.title;
7189
+ return `${timestamp(item.occurredAt)} ${actor} ${item.summary} ${subject}`;
7190
+ }
7191
+ async function activityList(ctx, options) {
7192
+ const limit = parseLimit(options.limit);
7193
+ const slug = requireWorkspace(ctx.config);
7194
+ const page = await ctx.client.activity.list(slug, { limit });
7195
+ if (ctx.config.json) {
7196
+ ctx.io.out(jsonOutput(page));
7197
+ return;
7198
+ }
7199
+ if (page.items.length === 0) {
7200
+ ctx.io.out("No activity yet.");
7201
+ return;
7202
+ }
7203
+ for (const item of page.items) ctx.io.out(activityLine(item));
7204
+ }
7205
+ function waitingLines(waiting) {
7206
+ const lines = [];
7207
+ if (waiting.approvals.length > 0) {
7208
+ lines.push(`Approvals (${waiting.approvals.length})`);
7209
+ for (const approval of waiting.approvals) {
7210
+ const parts = [`${approval.taskKey} ${approval.title}`];
7211
+ if (approval.projectName) parts.push(approval.projectName);
7212
+ if (approval.requestedBy) {
7213
+ parts.push(`asked by ${approval.requestedBy.name}`);
7214
+ }
7215
+ lines.push(` ${parts.join(" \xB7 ")}`);
7216
+ }
7217
+ }
7218
+ if (waiting.drafts.length > 0) {
7219
+ if (lines.length > 0) lines.push("");
7220
+ lines.push(`Drafts to review (${waiting.drafts.length})`);
7221
+ for (const draft of waiting.drafts) {
7222
+ lines.push(
7223
+ ` ${draft.updateId} ${draft.projectName} \xB7 ${draft.health} \xB7 by ${draft.author.name}`
7224
+ );
7225
+ if (draft.bodyExcerpt) lines.push(` ${draft.bodyExcerpt}`);
7226
+ }
7227
+ }
7228
+ return lines;
7229
+ }
7230
+ async function waitingShow(ctx) {
7231
+ const slug = requireWorkspace(ctx.config);
7232
+ const credential2 = ctx.config.credential;
7233
+ if (credential2 !== void 0 && "agentKey" in credential2) {
7234
+ throw new PersonOnlyError(
7235
+ "Waiting items belong to a person. Sign in with `tasq auth login` to see yours."
7236
+ );
7237
+ }
7238
+ const waiting = await ctx.client.waiting.get(slug);
7239
+ if (ctx.config.json) {
7240
+ ctx.io.out(jsonOutput(waiting));
7241
+ return;
7242
+ }
7243
+ const lines = waitingLines(waiting);
7244
+ if (lines.length === 0) {
7245
+ ctx.io.out("Nothing is waiting for you.");
7246
+ return;
7247
+ }
7248
+ for (const line2 of lines) ctx.io.out(line2);
7249
+ }
7250
+
7072
7251
  // src/commands/auth.ts
7252
+ import { hostname } from "os";
7073
7253
  var EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
7074
7254
  var CODE_PATTERN = /^\d{6}$/;
7075
7255
  async function authLogin(ctx, options, prompts) {
@@ -7414,12 +7594,160 @@ async function eventsAck(ctx, ids) {
7414
7594
  line(ctx.io, { acked: page.acked });
7415
7595
  }
7416
7596
 
7597
+ // src/project-ref.ts
7598
+ var UUID_PATTERN3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
7599
+ async function resolveProject(client, slug, ref) {
7600
+ const trimmed = ref.trim();
7601
+ const projects = await client.projects.list(slug);
7602
+ if (UUID_PATTERN3.test(trimmed)) {
7603
+ const found = projects.find((project2) => project2.id === trimmed);
7604
+ return { id: trimmed, name: found?.name ?? trimmed };
7605
+ }
7606
+ const wanted = trimmed.toLowerCase();
7607
+ const matched = projects.filter(
7608
+ (project2) => project2.name.toLowerCase() === wanted
7609
+ );
7610
+ if (matched.length === 0) {
7611
+ throw new UsageError(
7612
+ `No project named "${ref}" in this workspace. Run "tasq project list" to see the names.`
7613
+ );
7614
+ }
7615
+ if (matched.length > 1) {
7616
+ throw new UsageError(
7617
+ `"${ref}" matches ${matched.length} projects. Pass the project id.`
7618
+ );
7619
+ }
7620
+ const [project] = matched;
7621
+ return { id: project?.id ?? "", name: project?.name ?? "" };
7622
+ }
7623
+
7624
+ // src/commands/initiative.ts
7625
+ async function resolveInitiative(ctx, slug, ref) {
7626
+ const trimmed = ref.trim();
7627
+ const wanted = trimmed.toLowerCase();
7628
+ const initiatives = await ctx.client.initiatives.list(slug);
7629
+ const byId = initiatives.find((initiative) => initiative.id === trimmed);
7630
+ if (byId !== void 0) return byId;
7631
+ const matched = initiatives.filter(
7632
+ (initiative) => initiative.name.toLowerCase() === wanted
7633
+ );
7634
+ const [only] = matched;
7635
+ if (only === void 0) {
7636
+ throw new UsageError(
7637
+ `No initiative named "${ref}" in this workspace. Run "tasq initiative list" to see the names.`
7638
+ );
7639
+ }
7640
+ if (matched.length > 1) {
7641
+ throw new UsageError(
7642
+ `"${ref}" matches ${matched.length} initiatives. Pass the initiative id.`
7643
+ );
7644
+ }
7645
+ return only;
7646
+ }
7647
+ function requireName(name) {
7648
+ const trimmed = name.trim();
7649
+ if (trimmed === "") {
7650
+ throw new UsageError("The initiative name is empty.");
7651
+ }
7652
+ return trimmed;
7653
+ }
7654
+ async function initiativeList(ctx) {
7655
+ const slug = requireWorkspace(ctx.config);
7656
+ const initiatives = await ctx.client.initiatives.list(slug);
7657
+ ctx.io.out(
7658
+ ctx.config.json ? jsonOutput(initiatives) : formatInitiatives(initiatives)
7659
+ );
7660
+ }
7661
+ async function initiativeCreate(ctx, name) {
7662
+ const trimmed = requireName(name);
7663
+ const slug = requireWorkspace(ctx.config);
7664
+ const { result } = await ctx.client.initiatives.create(slug, {
7665
+ name: trimmed
7666
+ });
7667
+ ctx.io.out(
7668
+ ctx.config.json ? jsonOutput(result.initiative) : `Created initiative ${result.initiative.name}.`
7669
+ );
7670
+ }
7671
+ async function initiativeRename(ctx, ref, name) {
7672
+ const trimmed = requireName(name);
7673
+ const slug = requireWorkspace(ctx.config);
7674
+ const initiative = await resolveInitiative(ctx, slug, ref);
7675
+ const { result } = await ctx.client.initiatives.update(slug, {
7676
+ initiativeId: initiative.id,
7677
+ name: trimmed
7678
+ });
7679
+ ctx.io.out(
7680
+ ctx.config.json ? jsonOutput(result.initiative) : `Renamed initiative ${initiative.name} to ${result.initiative.name}.`
7681
+ );
7682
+ }
7683
+ async function initiativeArchive(ctx, ref) {
7684
+ const slug = requireWorkspace(ctx.config);
7685
+ const initiative = await resolveInitiative(ctx, slug, ref);
7686
+ const { result } = await ctx.client.initiatives.update(slug, {
7687
+ initiativeId: initiative.id,
7688
+ status: "archived"
7689
+ });
7690
+ ctx.io.out(
7691
+ ctx.config.json ? jsonOutput(result.initiative) : `Archived initiative ${initiative.name}.`
7692
+ );
7693
+ }
7694
+ async function initiativeLink(ctx, initiativeRef, projectRef) {
7695
+ const slug = requireWorkspace(ctx.config);
7696
+ const initiative = await resolveInitiative(ctx, slug, initiativeRef);
7697
+ const project = await resolveProject(ctx.client, slug, projectRef);
7698
+ const { result } = await ctx.client.initiatives.linkProject(slug, {
7699
+ initiativeId: initiative.id,
7700
+ projectId: project.id
7701
+ });
7702
+ if (ctx.config.json) {
7703
+ ctx.io.out(jsonOutput(result));
7704
+ return;
7705
+ }
7706
+ ctx.io.out(
7707
+ result.linked ? `Linked ${project.name} to initiative ${initiative.name}.` : `${project.name} was already in initiative ${initiative.name}.`
7708
+ );
7709
+ }
7710
+ async function initiativeUnlink(ctx, initiativeRef, projectRef) {
7711
+ const slug = requireWorkspace(ctx.config);
7712
+ const initiative = await resolveInitiative(ctx, slug, initiativeRef);
7713
+ const project = await resolveProject(ctx.client, slug, projectRef);
7714
+ const { result } = await ctx.client.initiatives.unlinkProject(slug, {
7715
+ initiativeId: initiative.id,
7716
+ projectId: project.id
7717
+ });
7718
+ if (ctx.config.json) {
7719
+ ctx.io.out(jsonOutput(result));
7720
+ return;
7721
+ }
7722
+ ctx.io.out(
7723
+ result.unlinked ? `Unlinked ${project.name} from initiative ${initiative.name}.` : `${project.name} was not in initiative ${initiative.name}.`
7724
+ );
7725
+ }
7726
+
7417
7727
  // src/commands/project.ts
7418
7728
  async function projectList(ctx) {
7419
7729
  const slug = requireWorkspace(ctx.config);
7420
7730
  const projects = await ctx.client.projects.list(slug);
7421
7731
  ctx.io.out(ctx.config.json ? jsonOutput(projects) : formatProjects(projects));
7422
7732
  }
7733
+ async function projectStar(ctx, ref) {
7734
+ const slug = requireWorkspace(ctx.config);
7735
+ const project = await resolveProject(ctx.client, slug, ref);
7736
+ const { result } = await ctx.client.projects.star(slug, {
7737
+ projectId: project.id
7738
+ });
7739
+ ctx.io.out(ctx.config.json ? jsonOutput(result) : `Starred ${project.name}.`);
7740
+ }
7741
+ async function projectUnstar(ctx, ref) {
7742
+ const slug = requireWorkspace(ctx.config);
7743
+ const project = await resolveProject(ctx.client, slug, ref);
7744
+ const { result } = await ctx.client.projects.unstar(slug, {
7745
+ projectId: project.id
7746
+ });
7747
+ ctx.io.out(
7748
+ ctx.config.json ? jsonOutput(result) : `Unstarred ${project.name}.`
7749
+ );
7750
+ }
7423
7751
 
7424
7752
  // src/commands/release.ts
7425
7753
  import { writeFileSync as writeFileSync2 } from "fs";
@@ -7766,6 +8094,9 @@ async function taskView(ctx, taskRef) {
7766
8094
  `Start: ${task.startDate ?? "\u2014"} Due: ${task.dueDate ?? "\u2014"}`
7767
8095
  );
7768
8096
  }
8097
+ if (task.approval) {
8098
+ ctx.io.out(`Approval: ${approvalLine(task.approval)}`);
8099
+ }
7769
8100
  if (task.parent) {
7770
8101
  ctx.io.out(`Parent: ${task.parent.identifier} ${task.parent.title}`);
7771
8102
  }
@@ -7946,6 +8277,147 @@ async function taskUpdate(ctx, taskRef, options) {
7946
8277
  ctx.config.json ? jsonOutput(updated) : `Updated ${updated.identifier}: ${updated.title}`
7947
8278
  );
7948
8279
  }
8280
+ var APPROVAL_STATE_WORDS = {
8281
+ requested: ["requested", "from"],
8282
+ approved: ["approved", "by"],
8283
+ changes_requested: ["changes requested", "by"],
8284
+ rejected: ["rejected", "by"]
8285
+ };
8286
+ function approvalLine(approval) {
8287
+ const [state, preposition] = APPROVAL_STATE_WORDS[approval.state];
8288
+ if (approval.approver === null) {
8289
+ return `${state} (the approver has left the workspace)`;
8290
+ }
8291
+ return `${state} ${preposition} ${approval.approver.name ?? approval.approver.memberId}`;
8292
+ }
8293
+ var UUID_PATTERN4 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
8294
+ function resolveApprover(members, ref) {
8295
+ const wanted = ref.trim().toLowerCase();
8296
+ const matched = members.filter(
8297
+ (member) => member.type === "user" && ((member.name ?? "").toLowerCase() === wanted || (member.email ?? "").toLowerCase() === wanted)
8298
+ );
8299
+ const [only] = matched;
8300
+ if (only === void 0) {
8301
+ throw new UsageError(
8302
+ `No person named "${ref}" in this workspace. Agents cannot approve. Run "tasq workspace members" to see the names.`
8303
+ );
8304
+ }
8305
+ if (matched.length > 1) {
8306
+ throw new UsageError(
8307
+ `"${ref}" matches ${matched.length} people. Pass their email or member id instead.`
8308
+ );
8309
+ }
8310
+ return only;
8311
+ }
8312
+ async function taskRequestApproval(ctx, taskRef, options) {
8313
+ const slug = requireWorkspace(ctx.config);
8314
+ if (options.approver === void 0 || options.approver.trim() === "") {
8315
+ throw new UsageError("--approver is required: a person's name, email or member id.");
8316
+ }
8317
+ const ref = options.approver.trim();
8318
+ const approver = UUID_PATTERN4.test(ref) ? { id: ref, name: null } : resolveApprover(await ctx.client.members.list(slug), ref);
8319
+ const taskId = await resolveTaskId(ctx.client, slug, taskRef);
8320
+ const response = await ctx.client.dispatch("task.requestApproval", slug, {
8321
+ taskId,
8322
+ approverId: approver.id
8323
+ });
8324
+ ctx.io.out(
8325
+ ctx.config.json ? jsonOutput(response.result) : `Requested approval on ${taskRef} from ${approver.name ?? approver.id}`
8326
+ );
8327
+ }
8328
+ var DECISION_SENTENCES = {
8329
+ approve: (task) => `Approved ${task}`,
8330
+ changes: (task) => `Requested changes on ${task}`,
8331
+ reject: (task) => `Rejected ${task}`
8332
+ };
8333
+ async function taskDecide(ctx, taskRef, decision) {
8334
+ const slug = requireWorkspace(ctx.config);
8335
+ const taskId = await resolveTaskId(ctx.client, slug, taskRef);
8336
+ const response = await ctx.client.dispatch("task.decide", slug, {
8337
+ taskId,
8338
+ decision
8339
+ });
8340
+ ctx.io.out(
8341
+ ctx.config.json ? jsonOutput(response.result) : DECISION_SENTENCES[decision](taskRef)
8342
+ );
8343
+ }
8344
+
8345
+ // src/commands/update.ts
8346
+ import { readFileSync as readFileSync3 } from "fs";
8347
+ function isHealth(value) {
8348
+ return PROJECT_HEALTH_VALUES.includes(value);
8349
+ }
8350
+ function requireHealth(value) {
8351
+ if (value === void 0 || !isHealth(value)) {
8352
+ throw new UsageError(`Pass --health ${PROJECT_HEALTH_VALUES.join(" | ")}.`);
8353
+ }
8354
+ return value;
8355
+ }
8356
+ function draftBody(options, deps) {
8357
+ if (options.body !== void 0 && options.file !== void 0) {
8358
+ throw new UsageError("Pass --body or --file, not both.");
8359
+ }
8360
+ if (options.body !== void 0) return options.body;
8361
+ if (options.file !== void 0) {
8362
+ const read = deps.readFile ?? ((path) => readFileSync3(path, "utf8"));
8363
+ return read(options.file);
8364
+ }
8365
+ throw new UsageError(
8366
+ "Pass the update with --body <markdown> or --file <path>."
8367
+ );
8368
+ }
8369
+ async function updateList(ctx, projectRef) {
8370
+ const slug = requireWorkspace(ctx.config);
8371
+ const projectId = await resolveProjectId(ctx, slug, projectRef);
8372
+ const updates = await ctx.client.projectUpdates.list(slug, projectId);
8373
+ ctx.io.out(
8374
+ ctx.config.json ? jsonOutput(updates) : formatProjectUpdates(updates)
8375
+ );
8376
+ }
8377
+ async function updateDraft(ctx, projectRef, options, deps = {}) {
8378
+ const slug = requireWorkspace(ctx.config);
8379
+ const health = requireHealth(options.health);
8380
+ const body = draftBody(options, deps);
8381
+ const projectId = await resolveProjectId(ctx, slug, projectRef);
8382
+ const { result } = await ctx.client.projectUpdates.draft(slug, {
8383
+ projectId,
8384
+ health,
8385
+ body
8386
+ });
8387
+ if (ctx.config.json) {
8388
+ ctx.io.out(jsonOutput(result.update));
8389
+ return;
8390
+ }
8391
+ ctx.io.out(
8392
+ `Drafted update ${result.update.id}. A person sends it with: tasq update send ${result.update.id}`
8393
+ );
8394
+ }
8395
+ async function updateSend(ctx, updateId) {
8396
+ const slug = requireWorkspace(ctx.config);
8397
+ const credential2 = ctx.config.credential;
8398
+ if (credential2 !== void 0 && "agentKey" in credential2) {
8399
+ throw new PersonOnlyError(
8400
+ "Only a person can send a project update. An agent drafts it; a person reviews and sends it."
8401
+ );
8402
+ }
8403
+ const { result } = await ctx.client.projectUpdates.send(slug, { updateId });
8404
+ if (ctx.config.json) {
8405
+ ctx.io.out(jsonOutput(result.update));
8406
+ return;
8407
+ }
8408
+ ctx.io.out(`Sent update ${result.update.id} (${result.update.health}).`);
8409
+ }
8410
+ async function updateDelete(ctx, updateId) {
8411
+ const slug = requireWorkspace(ctx.config);
8412
+ const { result } = await ctx.client.projectUpdates.delete(slug, {
8413
+ updateId
8414
+ });
8415
+ if (ctx.config.json) {
8416
+ ctx.io.out(jsonOutput(result));
8417
+ return;
8418
+ }
8419
+ ctx.io.out(`Deleted draft ${result.deletedUpdateId}.`);
8420
+ }
7949
8421
 
7950
8422
  // src/commands/workspace.ts
7951
8423
  async function workspaceList(ctx) {
@@ -8029,6 +8501,23 @@ function buildProgram(io2) {
8029
8501
  parent: options.parent
8030
8502
  });
8031
8503
  });
8504
+ task.command("request-approval").argument("<id>", "task identifier or id").description("Ask a person to approve a task").requiredOption(
8505
+ "--approver <member>",
8506
+ "the person's name, email or member id"
8507
+ ).action(async (id, options) => {
8508
+ await taskRequestApproval(contextFor(program2, io2), id, {
8509
+ approver: options.approver
8510
+ });
8511
+ });
8512
+ for (const [name, decision, description] of [
8513
+ ["approve", "approve", "Approve a task you were asked to approve"],
8514
+ ["request-changes", "changes", "Ask for changes on a task you were asked to approve"],
8515
+ ["reject", "reject", "Reject a task you were asked to approve"]
8516
+ ]) {
8517
+ task.command(name).argument("<id>", "task identifier or id").description(description).action(async (id) => {
8518
+ await taskDecide(contextFor(program2, io2), id, decision);
8519
+ });
8520
+ }
8032
8521
  const comment = program2.command("comment").description("Task and project comments");
8033
8522
  comment.command("add").argument("<taskRefOrBody>", "task identifier or id, or the body with --project").argument("[body]", "comment body, when a task was given").description("Add a comment to a task or a project").usage("[options] <taskRef> <body>\n tasq comment add [options] --project <projectRef> <body>").option("--project <projectRef>", "project id or name, instead of a task").option("--reply-to <commentRef>", "comment id, or ENG-42#<id>, to reply to").option("--thread <threadId>", "thread root id, an alias for --reply-to").option(
8034
8523
  "--mention <agentName>",
@@ -8074,6 +8563,48 @@ function buildProgram(io2) {
8074
8563
  });
8075
8564
  const project = program2.command("project").description("Projects");
8076
8565
  project.command("list").description("List projects").action(run((ctx) => projectList(ctx)));
8566
+ project.command("star").argument("<project>", "project id or name").description("Star a project for yourself").action(async (ref) => {
8567
+ await projectStar(contextFor(program2, io2), ref);
8568
+ });
8569
+ project.command("unstar").argument("<project>", "project id or name").description("Remove your star from a project").action(async (ref) => {
8570
+ await projectUnstar(contextFor(program2, io2), ref);
8571
+ });
8572
+ const initiative = program2.command("initiative").description("Initiatives: groups of projects across teams");
8573
+ initiative.command("list").description("List initiatives, archived ones included").action(run((ctx) => initiativeList(ctx)));
8574
+ initiative.command("create").argument("<name>", "initiative name").description("Create an initiative (admins)").action(async (name) => {
8575
+ await initiativeCreate(contextFor(program2, io2), name);
8576
+ });
8577
+ initiative.command("rename").argument("<initiative>", "initiative id or name").argument("<name>", "new name").description("Rename an initiative (admins)").action(async (ref, name) => {
8578
+ await initiativeRename(contextFor(program2, io2), ref, name);
8579
+ });
8580
+ initiative.command("archive").argument("<initiative>", "initiative id or name").description("Archive an initiative (admins)").action(async (ref) => {
8581
+ await initiativeArchive(contextFor(program2, io2), ref);
8582
+ });
8583
+ initiative.command("link").argument("<initiative>", "initiative id or name").argument("<project>", "project id or name").description("Add a project to an initiative (admins)").action(async (ref, projectRef) => {
8584
+ await initiativeLink(contextFor(program2, io2), ref, projectRef);
8585
+ });
8586
+ initiative.command("unlink").argument("<initiative>", "initiative id or name").argument("<project>", "project id or name").description("Remove a project from an initiative (admins)").action(async (ref, projectRef) => {
8587
+ await initiativeUnlink(contextFor(program2, io2), ref, projectRef);
8588
+ });
8589
+ const update = program2.command("update").description("Project updates: agents draft, a person sends");
8590
+ update.command("list").argument("<project>", "project id or name").description("List a project's updates, drafts included, newest first").action(async (projectRef) => {
8591
+ await updateList(contextFor(program2, io2), projectRef);
8592
+ });
8593
+ 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(
8594
+ async (projectRef, options) => {
8595
+ await updateDraft(contextFor(program2, io2), projectRef, options);
8596
+ }
8597
+ );
8598
+ update.command("send").argument("<updateId>", "update id").description("Send a draft to the client (people only)").action(async (updateId) => {
8599
+ await updateSend(contextFor(program2, io2), updateId);
8600
+ });
8601
+ update.command("delete").argument("<updateId>", "update id").description("Delete a draft").action(async (updateId) => {
8602
+ await updateDelete(contextFor(program2, io2), updateId);
8603
+ });
8604
+ program2.command("activity").description("Recent activity in the workspace, newest first").option("--limit <n>", "how many rows, 1-100 (default 30)").action(async (options) => {
8605
+ await activityList(contextFor(program2, io2), options);
8606
+ });
8607
+ program2.command("waiting").description("Approvals and agent drafts waiting on you (people only)").action(run((ctx) => waitingShow(ctx)));
8077
8608
  const cycle = program2.command("cycle").description("Cycles");
8078
8609
  cycle.command("current").description("Show the active cycle and its tasks").option("--team <identifier>", "team identifier").action(async (options) => {
8079
8610
  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.12",
3
+ "version": "0.1.14",
4
4
  "description": "Command-line client for Tasq, for humans and agents alike",
5
5
  "keywords": [
6
6
  "tasq",