exponential-cli 1.30.0 → 1.32.0

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/dist/index.js CHANGED
@@ -1665,13 +1665,23 @@ function transformDecisionListRow(d) {
1665
1665
  product: d.product ?? null,
1666
1666
  project: d.project ?? null,
1667
1667
  meeting: d.transcriptionSession ?? null,
1668
- supersededBy: d.supersededBy ?? null
1668
+ supersededBy: d.supersededBy ?? null,
1669
+ // Pillars (category "pillar") and labels (anything else), oldest first.
1670
+ tags: d.tags ?? []
1669
1671
  };
1670
1672
  }
1671
1673
  function outputDecisionJson(decision, extra = {}) {
1672
1674
  console.log(JSON.stringify({ ...transformDecision(decision), ...extra }, null, 2));
1673
1675
  }
1674
- function outputDecisionPretty(decision) {
1676
+ function decisionTagParts(tags) {
1677
+ const pillars = tags.filter((t) => t.category === "pillar").map((t) => t.name);
1678
+ const labels = tags.filter((t) => t.category !== "pillar").map((t) => t.name);
1679
+ return [
1680
+ pillars.length > 0 ? `Pillars: ${pillars.join(", ")}` : null,
1681
+ labels.length > 0 ? `Labels: ${labels.join(", ")}` : null
1682
+ ].filter((part) => part !== null);
1683
+ }
1684
+ function outputDecisionPretty(decision, tags) {
1675
1685
  const color = getDecisionStatusColor(decision.status);
1676
1686
  const kind = decision.status === "OPEN" ? chalk2.yellow(" [open question]") : "";
1677
1687
  console.log(chalk2.gray("\u2500".repeat(50)));
@@ -1704,6 +1714,12 @@ ${chalk2.gray(decision.label)} ${chalk2.bold(decision.statement)}${kind}`
1704
1714
  if (decision.owner) {
1705
1715
  console.log(` ${chalk2.gray("Owner:")} ${decision.owner.name ?? decision.owner.id}`);
1706
1716
  }
1717
+ if (tags) {
1718
+ const pillars = tags.filter((t) => t.category === "pillar").map((t) => t.name);
1719
+ const labels = tags.filter((t) => t.category !== "pillar").map((t) => t.name);
1720
+ console.log(` ${chalk2.gray("Pillars:")} ${pillars.length > 0 ? pillars.join(", ") : chalk2.dim("none")}`);
1721
+ console.log(` ${chalk2.gray("Labels:")} ${labels.length > 0 ? labels.join(", ") : chalk2.dim("none")}`);
1722
+ }
1707
1723
  if (decision.deciders && decision.deciders.length > 0) {
1708
1724
  const people = decision.deciders.map((d) => d.email ? `${d.name} <${d.email}>` : d.name).join(", ");
1709
1725
  console.log(` ${chalk2.gray("Deciders:")} ${people}`);
@@ -1784,6 +1800,10 @@ Decisions (${decisions.length} total, ${openCount} open question${openCount ===
1784
1800
  if (context.length > 0) {
1785
1801
  console.log(chalk2.gray(` ${context.join(" \xB7 ")}`));
1786
1802
  }
1803
+ const tagParts = decisionTagParts(d.tags ?? []);
1804
+ if (tagParts.length > 0) {
1805
+ console.log(chalk2.cyan(` ${tagParts.join(" \xB7 ")}`));
1806
+ }
1787
1807
  }
1788
1808
  console.log();
1789
1809
  }
@@ -3207,6 +3227,7 @@ function createAuthCommand() {
3207
3227
 
3208
3228
  // src/commands/actions.ts
3209
3229
  import { Command as Command3 } from "commander";
3230
+ import { splitAssigneeRefs } from "exponential-sdk";
3210
3231
  var VALID_PRIORITIES = [
3211
3232
  "Quick",
3212
3233
  "Scheduled",
@@ -3236,6 +3257,10 @@ function parseIds(raw) {
3236
3257
  }
3237
3258
  return ids;
3238
3259
  }
3260
+ function collect(value, previous = []) {
3261
+ return [...previous, value];
3262
+ }
3263
+ var ASSIGNEE_REF_HELP = "user id or email; repeat the flag or comma-separate values";
3239
3264
  function createActionsCommand() {
3240
3265
  const actions = new Command3("actions").description("Manage actions/tasks");
3241
3266
  actions.command("list").description("List all actions").option("--project <id>", "Filter by project ID").option("--status <status>", "Filter by kanban status (BACKLOG, TODO, IN_PROGRESS, IN_REVIEW, DONE)").option("--assignee <id>", "Filter by assignee ID").action(async (options, cmd) => {
@@ -3379,7 +3404,7 @@ function createActionsCommand() {
3379
3404
  handleError(error, useJson);
3380
3405
  }
3381
3406
  });
3382
- actions.command("update").description("Update an existing action").requiredOption("--id <id>", "Action ID to update").option("-n, --name <name>", "New action name").option("-d, --description <text>", "New description").option("-p, --project <id>", "Move to project ID").option("--priority <priority>", "Priority (Quick, Scheduled, 1st Priority, etc.)").option("--status <status>", "Status (ACTIVE, COMPLETED, CANCELLED)").option("--kanban <status>", "Kanban status (BACKLOG, TODO, IN_PROGRESS, IN_REVIEW, DONE)").option("--due <date>", 'Due date (YYYY-MM-DD or "null" to clear)').option("--scheduled-start <datetime>", 'Do-date: when you plan to work on it (YYYY-MM-DD, ISO datetime, or "null" to clear). This is what /today partitions on.').option("--scheduled-end <datetime>", 'End of the time block (YYYY-MM-DD, ISO datetime, or "null" to clear)').action(async (options, cmd) => {
3407
+ actions.command("update").description("Update an existing action").requiredOption("--id <id>", "Action ID to update").option("-n, --name <name>", "New action name").option("-d, --description <text>", "New description").option("-p, --project <id>", "Move to project ID").option("--priority <priority>", "Priority (Quick, Scheduled, 1st Priority, etc.)").option("--status <status>", "Status (ACTIVE, COMPLETED, CANCELLED)").option("--kanban <status>", "Kanban status (BACKLOG, TODO, IN_PROGRESS, IN_REVIEW, DONE)").option("--due <date>", 'Due date (YYYY-MM-DD or "null" to clear)').option("--scheduled-start <datetime>", 'Do-date: when you plan to work on it (YYYY-MM-DD, ISO datetime, or "null" to clear). This is what /today partitions on.').option("--scheduled-end <datetime>", 'End of the time block (YYYY-MM-DD, ISO datetime, or "null" to clear)').option("--assignee <ref>", `Add an assignee (${ASSIGNEE_REF_HELP}). Additive: existing assignees stay. Must be assignable in the action's project or workspace`, collect).option("--unassign <ref>", `Remove an assignee (${ASSIGNEE_REF_HELP}). Users not assigned are ignored`, collect).option("--clear-assignees", "Remove every assignee (runs before --assignee, so the two together replace the set)").action(async (options, cmd) => {
3383
3408
  const globalOpts = cmd.optsWithGlobals();
3384
3409
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3385
3410
  try {
@@ -3398,8 +3423,7 @@ function createActionsCommand() {
3398
3423
  const scheduledStart = parseNullableDate(options.scheduledStart, "scheduled-start");
3399
3424
  const scheduledEnd = parseNullableDate(options.scheduledEnd, "scheduled-end");
3400
3425
  const client = getClient();
3401
- const action = await client.actions.update({
3402
- id: options.id,
3426
+ const fieldPatch = {
3403
3427
  name: options.name,
3404
3428
  description: options.description,
3405
3429
  projectId: options.project,
@@ -3409,18 +3433,26 @@ function createActionsCommand() {
3409
3433
  dueDate,
3410
3434
  scheduledStart,
3411
3435
  scheduledEnd
3412
- });
3436
+ };
3437
+ const hasFieldChanges = Object.values(fieldPatch).some((v) => v !== void 0);
3438
+ const hasAssigneeChanges = Boolean(options.clearAssignees || options.unassign?.length || options.assignee?.length);
3439
+ let action;
3440
+ if (hasFieldChanges || !hasAssigneeChanges) {
3441
+ action = await client.actions.update({ id: options.id, ...fieldPatch });
3442
+ }
3443
+ const assigned = await applyAssigneeChanges(client, options.id, options);
3444
+ const result = assigned ?? action;
3413
3445
  if (useJson) {
3414
- outputActionJson(action);
3446
+ outputActionJson(result);
3415
3447
  } else {
3416
3448
  console.log("\n\u2713 Action updated successfully");
3417
- outputActionPretty(action);
3449
+ outputActionPretty(result);
3418
3450
  }
3419
3451
  } catch (error) {
3420
3452
  handleError(error, useJson);
3421
3453
  }
3422
3454
  });
3423
- actions.command("create").description("Create a new action").requiredOption("-n, --name <name>", "Action name/title").option("-d, --description <text>", "Action description").option("-p, --project <id>", "Project ID to assign the action to").option("--priority <priority>", "Priority (Quick, Scheduled, 1st Priority, etc.)").option("--due <date>", "Due date (YYYY-MM-DD)").option("--effort <minutes>", "Effort estimate in minutes", parseInt).option("--ticket <id>", "Link action to a product ticket (CUID) after creation").option("--epic <id>", "Epic CUID to attach the action to").action(async (options, cmd) => {
3455
+ actions.command("create").description("Create a new action").requiredOption("-n, --name <name>", "Action name/title").option("-d, --description <text>", "Action description").option("-p, --project <id>", "Project ID to assign the action to").option("--priority <priority>", "Priority (Quick, Scheduled, 1st Priority, etc.)").option("--due <date>", "Due date (YYYY-MM-DD)").option("--effort <minutes>", "Effort estimate in minutes", parseInt).option("--ticket <id>", "Link action to a product ticket (CUID) after creation").option("--epic <id>", "Epic CUID to attach the action to").option("--assignee <ref>", `Assign the new action (${ASSIGNEE_REF_HELP}). Each must be assignable in the project or workspace, or nothing is created`, collect).action(async (options, cmd) => {
3424
3456
  const globalOpts = cmd.optsWithGlobals();
3425
3457
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3426
3458
  try {
@@ -3442,7 +3474,8 @@ function createActionsCommand() {
3442
3474
  priority: options.priority,
3443
3475
  dueDate,
3444
3476
  effortEstimate: options.effort,
3445
- epicId: options.epic
3477
+ epicId: options.epic,
3478
+ ...assigneesForCreate(options.assignee)
3446
3479
  });
3447
3480
  if (options.ticket) {
3448
3481
  action = await client.tickets.linkAction(options.ticket, action.id);
@@ -3555,6 +3588,27 @@ function createActionsCommand() {
3555
3588
  actions.addCommand(comment);
3556
3589
  return actions;
3557
3590
  }
3591
+ function assigneesForCreate(refs) {
3592
+ if (!refs?.length) return {};
3593
+ const { userIds, emails } = splitAssigneeRefs(refs);
3594
+ return {
3595
+ ...userIds.length ? { assigneeIds: userIds } : {},
3596
+ ...emails.length ? { assigneeEmails: emails } : {}
3597
+ };
3598
+ }
3599
+ async function applyAssigneeChanges(client, actionId, options) {
3600
+ let result;
3601
+ if (options.clearAssignees) {
3602
+ result = await client.actions.unassign(actionId, { all: true });
3603
+ }
3604
+ if (options.unassign?.length) {
3605
+ result = await client.actions.unassign(actionId, splitAssigneeRefs(options.unassign));
3606
+ }
3607
+ if (options.assignee?.length) {
3608
+ result = await client.actions.assign(actionId, splitAssigneeRefs(options.assignee));
3609
+ }
3610
+ return result;
3611
+ }
3558
3612
 
3559
3613
  // src/commands/contacts.ts
3560
3614
  import { Command as Command4 } from "commander";
@@ -3804,7 +3858,7 @@ function parseIntInRange(value, flag, min, max) {
3804
3858
  }
3805
3859
  return n;
3806
3860
  }
3807
- var collect = (value, previous) => [...previous, value];
3861
+ var collect2 = (value, previous) => [...previous, value];
3808
3862
  var DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
3809
3863
  function parseCalendarDate(value) {
3810
3864
  const parsed = parseDate(value);
@@ -3883,7 +3937,7 @@ function addDefinitionOptions(cmd) {
3883
3937
  return cmd.option("--name <name>", "Display name (max 120 chars)").option("--slug <slug>", "Workspace-unique slug (derived from the name when omitted)").option("--kind <kind>", `One of: ${KINDS.join(", ")}`).option(
3884
3938
  "--cadence <rrule>",
3885
3939
  'RRULE body, e.g. "FREQ=WEEKLY;BYDAY=MO;BYHOUR=10;BYMINUTE=0"'
3886
- ).option("--timezone <iana>", "IANA zone the cadence runs in, e.g. Europe/Madrid").option("--starts-on <date>", "Anchor date the cadence expands from (YYYY-MM-DD)").option("--duration <minutes>", "Length in minutes (5-1440)").option("--lead-time <hours>", "Hours before the start to generate and circulate the agenda (0-336)").option("--owner <userId>", "Owner user id (defaults to you on create)").option("--participant <userId>", "Participant user id (repeatable; replaces the set on update)", collect, []).option("--project <projectId>", "Reviewed project id (repeatable; replaces the set on update)", collect, []).option("--alias <title>", "Meeting-title alias for auto-attach (repeatable; replaces the set on update)", collect, []).option("--product <productId>", "Scope to a product id").option("--purpose <markdown>", "Purpose (Markdown)").option("--purpose-file <path>", 'Purpose from a file ("-" = stdin)').option("--not-for <markdown>", "What this ceremony is NOT for (Markdown)").option("--inputs <markdown>", "Required inputs (Markdown)").option("--outputs <markdown>", "Expected outputs (Markdown)").option("--agenda-file <path>", 'Agenda template: JSON array of { key, type, title, minutes? } ("-" = stdin)').option("--include-projects", "Append the linked-projects section to agendas").option("--no-include-projects", "Do not append the linked-projects section to agendas").option("--meeting-url <url>", 'Video room the ceremony meets in; recordings from it file themselves here ("" clears it)').option("--auto-extract-outputs", "Extract outputs from every recording attached to an occurrence").option("--no-auto-extract-outputs", "Stop extracting outputs automatically");
3940
+ ).option("--timezone <iana>", "IANA zone the cadence runs in, e.g. Europe/Madrid").option("--starts-on <date>", "Anchor date the cadence expands from (YYYY-MM-DD)").option("--duration <minutes>", "Length in minutes (5-1440)").option("--lead-time <hours>", "Hours before the start to generate and circulate the agenda (0-336)").option("--owner <userId>", "Owner user id (defaults to you on create)").option("--participant <userId>", "Participant user id (repeatable; replaces the set on update)", collect2, []).option("--project <projectId>", "Reviewed project id (repeatable; replaces the set on update)", collect2, []).option("--alias <title>", "Meeting-title alias for auto-attach (repeatable; replaces the set on update)", collect2, []).option("--product <productId>", "Scope to a product id").option("--purpose <markdown>", "Purpose (Markdown)").option("--purpose-file <path>", 'Purpose from a file ("-" = stdin)').option("--not-for <markdown>", "What this ceremony is NOT for (Markdown)").option("--inputs <markdown>", "Required inputs (Markdown)").option("--outputs <markdown>", "Expected outputs (Markdown)").option("--agenda-file <path>", 'Agenda template: JSON array of { key, type, title, minutes? } ("-" = stdin)').option("--include-projects", "Append the linked-projects section to agendas").option("--no-include-projects", "Do not append the linked-projects section to agendas").option("--meeting-url <url>", 'Video room the ceremony meets in; recordings from it file themselves here ("" clears it)').option("--auto-extract-outputs", "Extract outputs from every recording attached to an occurrence").option("--no-auto-extract-outputs", "Stop extracting outputs automatically");
3887
3941
  }
3888
3942
  function definitionFields(options, cmd) {
3889
3943
  const fields = {};
@@ -4061,7 +4115,7 @@ function createOccurrencesCommand() {
4061
4115
  "No flags: show it. --draft: fill a draft from your activity since the last occurrence.",
4062
4116
  "--answer key=markdown (repeatable) saves answers; --submit / --reopen changes its state."
4063
4117
  ].join(" ")
4064
- ).option("--workspace <slug|id>", "Workspace (not needed when you pass the URL)").option("--draft", "Draft answers from your activity (leaves anything you wrote alone)").option("--answer <key=markdown>", "An answer by question key (repeatable)", collect, []).option("--answers-file <path>", 'Answers as a JSON object { key: markdown } ("-" = stdin)').option("--blocker", "Flag that something is blocking you").option("--no-blocker", "Clear the blocker flag").option("--submit", "Submit the update (refused if every answer is empty; see --allow-empty)").option("--allow-empty", "With --submit: submit even though every answer is empty").option("--reopen", "Reopen a submitted update").action(
4118
+ ).option("--workspace <slug|id>", "Workspace (not needed when you pass the URL)").option("--draft", "Draft answers from your activity (leaves anything you wrote alone)").option("--answer <key=markdown>", "An answer by question key (repeatable)", collect2, []).option("--answers-file <path>", 'Answers as a JSON object { key: markdown } ("-" = stdin)').option("--blocker", "Flag that something is blocking you").option("--no-blocker", "Clear the blocker flag").option("--submit", "Submit the update (refused if every answer is empty; see --allow-empty)").option("--allow-empty", "With --submit: submit even though every answer is empty").option("--reopen", "Reopen a submitted update").action(
4065
4119
  async (value, options, cmd) => {
4066
4120
  const globalOpts = cmd.optsWithGlobals();
4067
4121
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -4544,7 +4598,7 @@ var ADDABLE_TYPES = [
4544
4598
  "lastEditedTime",
4545
4599
  "createdBy"
4546
4600
  ];
4547
- function collect2(value, previous) {
4601
+ function collect3(value, previous) {
4548
4602
  return [...previous, value];
4549
4603
  }
4550
4604
  function parseLimit(value) {
@@ -4851,7 +4905,7 @@ function createRowsCommand() {
4851
4905
  );
4852
4906
  rows.command("list <databaseId>").description(
4853
4907
  'Rows through the saved view, or with your own --filter/--sort: "Status=Tracked", "Score>5", "Owner!=", "Name~latency", "Status in Tracked,Instrumenting".'
4854
- ).option("--filter <expr>", "Filter (repeatable); replaces the saved filters", collect2, []).option("--sort <prop[:asc|desc]>", "Sort; replaces the saved sort").option("-l, --limit <n>", "Rows per page (1-200, default 50)").option("--cursor <cursor>", "Continue from a previous page (nextCursor)").action(
4908
+ ).option("--filter <expr>", "Filter (repeatable); replaces the saved filters", collect3, []).option("--sort <prop[:asc|desc]>", "Sort; replaces the saved sort").option("-l, --limit <n>", "Rows per page (1-200, default 50)").option("--cursor <cursor>", "Continue from a previous page (nextCursor)").action(
4855
4909
  async (databaseId, options, cmd) => {
4856
4910
  const globalOpts = cmd.optsWithGlobals();
4857
4911
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -4872,7 +4926,7 @@ function createRowsCommand() {
4872
4926
  );
4873
4927
  rows.command("add <databaseId>").description(
4874
4928
  'Add a row. --set Name="Alert latency" --set Status=Tracked (repeatable; property by name or id; a select by option name, lists comma-separated, dates ISO, checkboxes yes/no).'
4875
- ).option("--set <Property=value>", "A cell value (repeatable)", collect2, []).option("-n, --note <text>", "Why: recorded on the row page's first revision").action(async (databaseId, options, cmd) => {
4929
+ ).option("--set <Property=value>", "A cell value (repeatable)", collect3, []).option("-n, --note <text>", "Why: recorded on the row page's first revision").action(async (databaseId, options, cmd) => {
4876
4930
  const globalOpts = cmd.optsWithGlobals();
4877
4931
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4878
4932
  try {
@@ -4889,7 +4943,7 @@ function createRowsCommand() {
4889
4943
  });
4890
4944
  rows.command("import <databaseId>").description(
4891
4945
  'Import a CSV: --csv file (or - for stdin). Columns map to properties by header name; --map "Col=Property", --new "Col=type" (or "Col=Name:type") and --skip Col override. --dry-run shows the typed preview and creates nothing. Rows with a cell that does not fit are reported and left out.'
4892
- ).requiredOption("--csv <file>", "The CSV file, or - for stdin").option("--map <Col=Property>", "Send a column to an existing property (repeatable)", collect2, []).option("--new <Col=type>", "Create a property for a column (repeatable)", collect2, []).option("--skip <Col>", "Leave a column out (repeatable)", collect2, []).option("--dry-run", "Preview only: type every row, create nothing").option("-n, --note <text>", "Why: recorded on each new row's first revision").action(
4946
+ ).requiredOption("--csv <file>", "The CSV file, or - for stdin").option("--map <Col=Property>", "Send a column to an existing property (repeatable)", collect3, []).option("--new <Col=type>", "Create a property for a column (repeatable)", collect3, []).option("--skip <Col>", "Leave a column out (repeatable)", collect3, []).option("--dry-run", "Preview only: type every row, create nothing").option("-n, --note <text>", "Why: recorded on each new row's first revision").action(
4893
4947
  async (databaseId, options, cmd) => {
4894
4948
  const globalOpts = cmd.optsWithGlobals();
4895
4949
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -4920,7 +4974,7 @@ function createRowsCommand() {
4920
4974
  }
4921
4975
  }
4922
4976
  );
4923
- rows.command("update <rowId>").description("Write some of a row's cells: --set Property=value (repeatable), --clear Property to empty one. Other cells are kept. Recorded in the row page's history.").option("--set <Property=value>", "A cell value (repeatable)", collect2, []).option("--clear <Property>", "Empty a cell (repeatable)", collect2, []).option("-n, --note <text>", "Why: shown in the row page's history").action(
4977
+ rows.command("update <rowId>").description("Write some of a row's cells: --set Property=value (repeatable), --clear Property to empty one. Other cells are kept. Recorded in the row page's history.").option("--set <Property=value>", "A cell value (repeatable)", collect3, []).option("--clear <Property>", "Empty a cell (repeatable)", collect3, []).option("-n, --note <text>", "Why: shown in the row page's history").action(
4924
4978
  async (rowId, options, cmd) => {
4925
4979
  const globalOpts = cmd.optsWithGlobals();
4926
4980
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -4960,6 +5014,118 @@ function createRowsCommand() {
4960
5014
  // src/commands/decisions.ts
4961
5015
  import { Command as Command7 } from "commander";
4962
5016
  import chalk7 from "chalk";
5017
+
5018
+ // src/commands/decisionTags.ts
5019
+ var PILLAR_CATEGORY = "pillar";
5020
+ function isPillar(tag) {
5021
+ return tag.category === PILLAR_CATEGORY;
5022
+ }
5023
+ function tagKind(tag) {
5024
+ return isPillar(tag) ? "pillar" : "label";
5025
+ }
5026
+ function kindNoun(kind) {
5027
+ return kind === "pillar" ? "Pillar" : "label";
5028
+ }
5029
+ function matchTag(candidates, ref, kind) {
5030
+ const value = ref.trim();
5031
+ if (value === "") throw new Error(`Empty ${kindNoun(kind)} name.`);
5032
+ const lower = value.toLowerCase();
5033
+ const byId = candidates.filter((t) => t.id === value);
5034
+ const bySlug = byId.length > 0 ? [] : candidates.filter((t) => t.slug.toLowerCase() === lower);
5035
+ const byName = byId.length > 0 || bySlug.length > 0 ? [] : candidates.filter((t) => t.name.trim().toLowerCase() === lower);
5036
+ const found = byId.length > 0 ? byId : bySlug.length > 0 ? bySlug : byName;
5037
+ const ofKind = found.filter((t) => tagKind(t) === kind);
5038
+ if (ofKind.length === 1) return ofKind[0];
5039
+ if (ofKind.length > 1) {
5040
+ const list = ofKind.map((t) => `${t.name} (slug ${t.slug}, id ${t.id})`).join("; ");
5041
+ throw new Error(
5042
+ `"${ref}" matches ${ofKind.length} ${kindNoun(kind)}s: ${list}. Pass the slug or id instead.`
5043
+ );
5044
+ }
5045
+ if (found.length > 0) {
5046
+ const other = kind === "pillar" ? "label" : "Pillar";
5047
+ const flag = kind === "pillar" ? "--label" : "--pillar";
5048
+ throw new Error(`"${ref}" is a ${other}, not a ${kindNoun(kind)}. Use ${flag} for it.`);
5049
+ }
5050
+ const listCmd = kind === "pillar" ? "exponential labels list --category pillar --workspace <slug>" : "exponential labels list --workspace <slug>";
5051
+ throw new Error(
5052
+ `No ${kindNoun(kind)} named "${ref}" in this workspace (matched by name, slug or id). Run \`${listCmd}\` to see them.`
5053
+ );
5054
+ }
5055
+ async function loadWorkspaceTags(client, workspaceId) {
5056
+ const list = await client.labels.list({ workspaceId });
5057
+ return list.allTags.filter((t) => t.workspaceId === null || t.workspaceId === workspaceId);
5058
+ }
5059
+ function isArchived(tag) {
5060
+ return tag.archivedAt !== void 0 && tag.archivedAt !== null;
5061
+ }
5062
+ function resolveTagRefs(candidates, refs, kind) {
5063
+ const live = candidates.filter((t) => !isArchived(t));
5064
+ return refs.map((ref) => {
5065
+ try {
5066
+ return matchTag(live, ref, kind);
5067
+ } catch (liveError) {
5068
+ try {
5069
+ return matchTag(candidates, ref, kind);
5070
+ } catch {
5071
+ throw liveError;
5072
+ }
5073
+ }
5074
+ });
5075
+ }
5076
+ function resolveRemovals(current, workspaceTags, refs, kind) {
5077
+ return refs.map((ref) => {
5078
+ try {
5079
+ return resolveTagRefs(current, [ref], kind)[0];
5080
+ } catch {
5081
+ return resolveTagRefs(workspaceTags, [ref], kind)[0];
5082
+ }
5083
+ });
5084
+ }
5085
+ function hasTagChanges(c) {
5086
+ return Boolean(
5087
+ c.clearPillars || c.clearLabels || c.addPillar?.length || c.removePillar?.length || c.addLabel?.length || c.removeLabel?.length
5088
+ );
5089
+ }
5090
+ function computeTagIds(current, workspaceTags, changes) {
5091
+ const removeIds = /* @__PURE__ */ new Set();
5092
+ for (const t of resolveRemovals(current, workspaceTags, changes.removePillar ?? [], "pillar")) {
5093
+ removeIds.add(t.id);
5094
+ }
5095
+ for (const t of resolveRemovals(current, workspaceTags, changes.removeLabel ?? [], "label")) {
5096
+ removeIds.add(t.id);
5097
+ }
5098
+ const added = [
5099
+ ...resolveTagRefs(workspaceTags, changes.addPillar ?? [], "pillar"),
5100
+ ...resolveTagRefs(workspaceTags, changes.addLabel ?? [], "label")
5101
+ ];
5102
+ const kept = current.filter((t) => {
5103
+ if (changes.clearPillars && isPillar(t)) return false;
5104
+ if (changes.clearLabels && !isPillar(t)) return false;
5105
+ return !removeIds.has(t.id);
5106
+ });
5107
+ const ids = kept.map((t) => t.id);
5108
+ for (const t of added) if (!ids.includes(t.id)) ids.push(t.id);
5109
+ return ids;
5110
+ }
5111
+ async function applyDecisionTagChanges(client, workspaceId, decisionId, changes) {
5112
+ const current = await client.labels.listForEntity({ entityType: "decision", entityId: decisionId });
5113
+ const needsWorkspaceTags = Boolean(
5114
+ changes.addPillar?.length || changes.addLabel?.length || changes.removePillar?.length || changes.removeLabel?.length
5115
+ );
5116
+ const workspaceTags = needsWorkspaceTags ? await loadWorkspaceTags(client, workspaceId) : [];
5117
+ const tagIds = computeTagIds(current, workspaceTags, changes);
5118
+ const unchanged = tagIds.length === current.length && tagIds.every((id, i) => current[i]?.id === id);
5119
+ if (unchanged) return current;
5120
+ const result = await client.labels.setEntityTags({
5121
+ entityType: "decision",
5122
+ entityId: decisionId,
5123
+ tagIds
5124
+ });
5125
+ return result.tags;
5126
+ }
5127
+
5128
+ // src/commands/decisions.ts
4963
5129
  var STATUSES = [
4964
5130
  "OPEN",
4965
5131
  "PROPOSED",
@@ -5059,6 +5225,24 @@ function parseNullableInt(v) {
5059
5225
  if (Number.isNaN(n)) throw new Error(`Expected a number, got "${v}".`);
5060
5226
  return n;
5061
5227
  }
5228
+ function collect4(value, previous) {
5229
+ return [...previous, value];
5230
+ }
5231
+ var PILLAR_REF_HELP = "a Pillar name, slug or id";
5232
+ var LABEL_REF_HELP = "a label name, slug or id";
5233
+ async function resolveListTagIds(client, workspaceId, pillars, labels) {
5234
+ if (pillars.length === 0 && labels.length === 0) return void 0;
5235
+ const tags = await loadWorkspaceTags(client, workspaceId);
5236
+ return [
5237
+ ...resolveTagRefs(tags, pillars, "pillar"),
5238
+ ...resolveTagRefs(tags, labels, "label")
5239
+ ].map((t) => t.id);
5240
+ }
5241
+ function filterRowsByTags(rows, tagIds) {
5242
+ if (!tagIds) return rows;
5243
+ const wanted = new Set(tagIds);
5244
+ return rows.filter((d) => (d.tags ?? []).some((t) => wanted.has(t.id)));
5245
+ }
5062
5246
  var DECISION_LABEL = /^D-(\d+)$/i;
5063
5247
  function pickDecisionRef(positional, flag) {
5064
5248
  if (positional && flag && positional !== flag) {
@@ -5161,6 +5345,10 @@ function notLinkedMessage(decision, featureId, error) {
5161
5345
  const reason = error instanceof Error ? error.message : String(error);
5162
5346
  return `Logged ${decision.label} (${decision.id}) but could not link it to feature ${featureId}: ${reason}. Link it with: exponential decisions link ${decision.id} --feature ${featureId}`;
5163
5347
  }
5348
+ function notTaggedMessage(decision, error) {
5349
+ const reason = error instanceof Error ? error.message : String(error);
5350
+ return `Logged ${decision.label} (${decision.id}) but could not file it under its Pillars/labels: ${reason}. Add them with: exponential decisions update ${decision.id} --add-pillar <ref> --add-label <ref>`;
5351
+ }
5164
5352
  function addConfirmCommand(parent) {
5165
5353
  parent.command("confirm [id]").description(
5166
5354
  "Publish a draft decision into the log, as the signed-in person. Takes a D-number (D-0006) or an id. --status ACCEPTED also accepts it. Agents cannot confirm: this needs a person's login."
@@ -5233,7 +5421,17 @@ function createDecisionsCommand() {
5233
5421
  "Filter by source (repeatable): MEETING, MANUAL, AGENT",
5234
5422
  (value, previous) => [...previous, parseSource(value)],
5235
5423
  []
5236
- ).option("--product <slug|id>", 'Filter by product, or "workspace" for decisions with no product').option("--include-workspace-wide", "With --product: also include decisions that have no product").option("--project <id>", "Filter by project CUID").option("--search <text>", "Free-text over statement and body").option("--number <n>", "One decision by its workspace sequence number (D-0003 is 3)").option("--limit <n>", "Cap the rows returned (1-500)").option("--adr <id>", "Decisions formalised as this ADR document").option("--occurrence <id|url>", "Only decisions logged in this ceremony occurrence (the URL brings its own workspace)").action(
5424
+ ).option("--product <slug|id>", 'Filter by product, or "workspace" for decisions with no product').option("--include-workspace-wide", "With --product: also include decisions that have no product").option("--project <id>", "Filter by project CUID").option("--search <text>", "Free-text over statement and body").option("--number <n>", "One decision by its workspace sequence number (D-0003 is 3)").option("--limit <n>", "Cap the rows returned (1-500)").option("--adr <id>", "Decisions formalised as this ADR document").option("--occurrence <id|url>", "Only decisions logged in this ceremony occurrence (the URL brings its own workspace)").option(
5425
+ "--pillar <ref>",
5426
+ `Only decisions filed under this Pillar (${PILLAR_REF_HELP}; repeatable, matches ANY of --pillar/--label)`,
5427
+ collect4,
5428
+ []
5429
+ ).option(
5430
+ "--label <ref>",
5431
+ `Only decisions carrying this label (${LABEL_REF_HELP}; repeatable, matches ANY of --pillar/--label)`,
5432
+ collect4,
5433
+ []
5434
+ ).action(
5237
5435
  async (options, cmd) => {
5238
5436
  const globalOpts = cmd.optsWithGlobals();
5239
5437
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -5246,6 +5444,15 @@ function createDecisionsCommand() {
5246
5444
  if (options.meeting) {
5247
5445
  const result = await client.decisions.listForMeeting(options.meeting);
5248
5446
  let rows2 = result.decisions;
5447
+ if (options.pillar.length > 0 || options.label.length > 0) {
5448
+ if (!result.workspaceId) {
5449
+ throw new Error("This meeting has no workspace, so --pillar and --label cannot be resolved.");
5450
+ }
5451
+ rows2 = filterRowsByTags(
5452
+ rows2,
5453
+ await resolveListTagIds(client, result.workspaceId, options.pillar, options.label)
5454
+ );
5455
+ }
5249
5456
  if (options.status.length > 0) {
5250
5457
  rows2 = rows2.filter((d) => options.status.includes(d.status));
5251
5458
  }
@@ -5272,7 +5479,8 @@ function createDecisionsCommand() {
5272
5479
  }
5273
5480
  const workspaceId = await resolveWorkspaceId(client, occurrence?.workspaceSlug ?? options.workspace);
5274
5481
  const limit = parsePositiveInt(options.limit, "--limit");
5275
- const all = options.adr ? await client.decisions.listForAdr(workspaceId, options.adr) : await client.decisions.list({
5482
+ const tagIds = await resolveListTagIds(client, workspaceId, options.pillar, options.label);
5483
+ const all = options.adr ? filterRowsByTags(await client.decisions.listForAdr(workspaceId, options.adr), tagIds) : await client.decisions.list({
5276
5484
  workspaceId,
5277
5485
  statuses: options.status.length > 0 ? options.status : void 0,
5278
5486
  sources: options.source.length > 0 ? options.source : void 0,
@@ -5281,6 +5489,7 @@ function createDecisionsCommand() {
5281
5489
  projectId: options.project,
5282
5490
  search: options.search,
5283
5491
  number: parsePositiveInt(options.number, "--number"),
5492
+ tagIds,
5284
5493
  // With --occurrence the cap applies after filtering, below.
5285
5494
  limit: occurrence ? void 0 : limit
5286
5495
  });
@@ -5297,7 +5506,7 @@ function createDecisionsCommand() {
5297
5506
  }
5298
5507
  );
5299
5508
  decisions.command("get <id>").description(
5300
- "Show one decision in full: body, evidence, deciders, chain and links. Takes a D-number (D-0006) or an id."
5509
+ "Show one decision in full: body, evidence, deciders, chain, links, Pillars and labels. Takes a D-number (D-0006) or an id."
5301
5510
  ).option("--workspace <slug|id>", "Workspace (defaults to your default workspace)").action(async (id, options, cmd) => {
5302
5511
  const globalOpts = cmd.optsWithGlobals();
5303
5512
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -5305,9 +5514,12 @@ function createDecisionsCommand() {
5305
5514
  const client = getClient();
5306
5515
  const workspaceId = await resolveWorkspaceId(client, options.workspace);
5307
5516
  const decisionId = await resolveDecisionRef(client, workspaceId, id);
5308
- const decision = await client.decisions.get(workspaceId, decisionId);
5309
- if (useJson) outputDecisionJson(decision);
5310
- else outputDecisionPretty(decision);
5517
+ const [decision, tags] = await Promise.all([
5518
+ client.decisions.get(workspaceId, decisionId),
5519
+ client.labels.listForEntity({ entityType: "decision", entityId: decisionId })
5520
+ ]);
5521
+ if (useJson) outputDecisionJson(decision, { tags });
5522
+ else outputDecisionPretty(decision, tags);
5311
5523
  } catch (error) {
5312
5524
  handleError(error, useJson);
5313
5525
  }
@@ -5330,6 +5542,16 @@ function createDecisionsCommand() {
5330
5542
  ).option(
5331
5543
  "--evidence-file <path>",
5332
5544
  'JSON array of {turnIndex, text} transcript quotes ("-" = stdin). Needs --meeting: the server checks every quote against that transcript and silently drops the ones that do not match.'
5545
+ ).option(
5546
+ "--pillar <ref>",
5547
+ `File it under this Pillar (${PILLAR_REF_HELP}; repeatable). Applied right after the create, which takes no tags`,
5548
+ collect4,
5549
+ []
5550
+ ).option(
5551
+ "--label <ref>",
5552
+ `Attach this label (${LABEL_REF_HELP}; repeatable). Applied right after the create`,
5553
+ collect4,
5554
+ []
5333
5555
  ).option("--from-file <path>", 'Bulk create from a JSON array of decisions ("-" = stdin)').action(
5334
5556
  async (options, cmd) => {
5335
5557
  const globalOpts = cmd.optsWithGlobals();
@@ -5355,6 +5577,21 @@ function createDecisionsCommand() {
5355
5577
  if (goalId !== void 0 && Number.isNaN(goalId)) {
5356
5578
  throw new Error(`--goal must be an integer id, got "${options.goal}".`);
5357
5579
  }
5580
+ const createTagIds = await resolveListTagIds(
5581
+ client,
5582
+ workspaceId,
5583
+ options.pillar,
5584
+ options.label
5585
+ );
5586
+ const tagNew = async (decision2) => {
5587
+ if (!createTagIds) return void 0;
5588
+ const result = await client.labels.setEntityTags({
5589
+ entityType: "decision",
5590
+ entityId: decision2.id,
5591
+ tagIds: createTagIds
5592
+ });
5593
+ return result.tags;
5594
+ };
5358
5595
  const defaults = {
5359
5596
  workspaceId,
5360
5597
  status,
@@ -5408,6 +5645,18 @@ function createDecisionsCommand() {
5408
5645
  );
5409
5646
  }
5410
5647
  const decision2 = await client.decisions.create(input);
5648
+ try {
5649
+ await tagNew(decision2);
5650
+ } catch (error) {
5651
+ results.push({
5652
+ index,
5653
+ success: false,
5654
+ decision: decision2,
5655
+ statement,
5656
+ error: notTaggedMessage(decision2, error)
5657
+ });
5658
+ continue;
5659
+ }
5411
5660
  if (options.feature) {
5412
5661
  try {
5413
5662
  await client.decisions.linkFeature(workspaceId, decision2.id, options.feature);
@@ -5450,6 +5699,12 @@ function createDecisionsCommand() {
5450
5699
  deciders: options.decider.length > 0 ? options.decider : void 0,
5451
5700
  evidence: evidenceRaw === void 0 ? void 0 : parseEvidence(evidenceRaw)
5452
5701
  });
5702
+ let tags;
5703
+ try {
5704
+ tags = await tagNew(decision);
5705
+ } catch (error) {
5706
+ throw new Error(notTaggedMessage(decision, error));
5707
+ }
5453
5708
  let featureLink;
5454
5709
  if (options.feature) {
5455
5710
  try {
@@ -5462,13 +5717,17 @@ function createDecisionsCommand() {
5462
5717
  throw new Error(notLinkedMessage(decision, options.feature, error));
5463
5718
  }
5464
5719
  }
5465
- if (useJson) outputDecisionJson(decision, featureLink ? { featureLink } : {});
5466
- else {
5720
+ if (useJson) {
5721
+ outputDecisionJson(decision, {
5722
+ ...featureLink ? { featureLink } : {},
5723
+ ...tags ? { tags } : {}
5724
+ });
5725
+ } else {
5467
5726
  console.log(
5468
5727
  `
5469
5728
  \u2713 ${decision.status === "OPEN" ? "Open question" : "Decision"} logged`
5470
5729
  );
5471
- outputDecisionPretty(decision);
5730
+ outputDecisionPretty(decision, tags);
5472
5731
  if (featureLink) console.log(chalk7.gray(` Linked to feature ${options.feature}`));
5473
5732
  }
5474
5733
  } catch (error) {
@@ -5478,7 +5737,7 @@ function createDecisionsCommand() {
5478
5737
  );
5479
5738
  decisions.command("update [id]").description(
5480
5739
  `Update a decision's content and scope; only the fields you pass are written. Takes a D-number (D-0006) or an id. Status changes go through "decisions status".`
5481
- ).option("--id <id>", "Decision id (alternative to the positional <id>)").option("--workspace <slug|id>", "Workspace (defaults to your default workspace)").option("-s, --statement <text>", "New statement").option("-b, --body <markdown>", 'New Markdown body (or "null" to clear)').option("--body-file <path>", 'Read the new body from a file ("-" = stdin)').option("--decided-at <iso>", 'When it was decided (or "null" to clear)').option("--owner <userId>", 'Owner user ID (or "null" to clear)').option("--product <slug|id>", 'Product (or "null" to detach)').option("--project <id>", 'Project CUID (or "null" to detach)').option("--goal <id>", 'Goal integer id (or "null" to detach)').option("--key-result <id>", 'Key result CUID (or "null" to detach)').option("--adr <id>", 'ADR document CUID (or "null" to detach)').action(
5740
+ ).option("--id <id>", "Decision id (alternative to the positional <id>)").option("--workspace <slug|id>", "Workspace (defaults to your default workspace)").option("-s, --statement <text>", "New statement").option("-b, --body <markdown>", 'New Markdown body (or "null" to clear)').option("--body-file <path>", 'Read the new body from a file ("-" = stdin)').option("--decided-at <iso>", 'When it was decided (or "null" to clear)').option("--owner <userId>", 'Owner user ID (or "null" to clear)').option("--product <slug|id>", 'Product (or "null" to detach)').option("--project <id>", 'Project CUID (or "null" to detach)').option("--goal <id>", 'Goal integer id (or "null" to detach)').option("--key-result <id>", 'Key result CUID (or "null" to detach)').option("--adr <id>", 'ADR document CUID (or "null" to detach)').option("--add-pillar <ref>", `File the decision under this Pillar (${PILLAR_REF_HELP}; repeatable)`, collect4, []).option("--remove-pillar <ref>", `Take the decision out of this Pillar (${PILLAR_REF_HELP}; repeatable)`, collect4, []).option("--clear-pillars", "Remove every Pillar (runs before --add-pillar, so the two together replace the Pillars)").option("--add-label <ref>", `Label to attach (${LABEL_REF_HELP}; repeatable)`, collect4, []).option("--remove-label <ref>", `Label to detach (${LABEL_REF_HELP}; repeatable)`, collect4, []).option("--clear-labels", "Remove every label (runs before --add-label, so the two together replace the labels). Pillars are untouched").action(
5482
5741
  async (idArg, options, cmd) => {
5483
5742
  const globalOpts = cmd.optsWithGlobals();
5484
5743
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -5495,24 +5754,52 @@ function createDecisionsCommand() {
5495
5754
  keyResultId: parseNullableString(options.keyResult),
5496
5755
  adrDocumentId: parseNullableString(options.adr)
5497
5756
  };
5498
- if (options.product === void 0 && Object.values(patch).every((v) => v === void 0)) {
5757
+ const tagChanges = {
5758
+ addPillar: options.addPillar,
5759
+ removePillar: options.removePillar,
5760
+ clearPillars: options.clearPillars,
5761
+ addLabel: options.addLabel,
5762
+ removeLabel: options.removeLabel,
5763
+ clearLabels: options.clearLabels
5764
+ };
5765
+ const changesTags = hasTagChanges(tagChanges);
5766
+ const changesContent = options.product !== void 0 || Object.values(patch).some((v) => v !== void 0);
5767
+ if (!changesContent && !changesTags) {
5499
5768
  throw new Error(
5500
- "Nothing to update. Pass at least one of --statement, --body, --body-file, --decided-at, --owner, --product, --project, --goal, --key-result, --adr."
5769
+ "Nothing to update. Pass at least one of --statement, --body, --body-file, --decided-at, --owner, --product, --project, --goal, --key-result, --adr, --add-pillar, --remove-pillar, --clear-pillars, --add-label, --remove-label, --clear-labels."
5501
5770
  );
5502
5771
  }
5503
5772
  const client = getClient();
5504
5773
  const workspaceId = await resolveWorkspaceId(client, options.workspace);
5505
- const productId = options.product === void 0 ? void 0 : options.product === "null" ? null : await resolveProductId(client, workspaceId, options.product);
5506
- const decision = await client.decisions.update({
5507
- workspaceId,
5508
- decisionId: await resolveDecisionRef(client, workspaceId, ref),
5509
- ...patch,
5510
- productId
5511
- });
5512
- if (useJson) outputDecisionJson(decision);
5774
+ const decisionId = await resolveDecisionRef(client, workspaceId, ref);
5775
+ let decision;
5776
+ if (changesContent) {
5777
+ const productId = options.product === void 0 ? void 0 : options.product === "null" ? null : await resolveProductId(client, workspaceId, options.product);
5778
+ decision = await client.decisions.update({
5779
+ workspaceId,
5780
+ decisionId,
5781
+ ...patch,
5782
+ productId
5783
+ });
5784
+ } else {
5785
+ decision = await client.decisions.get(workspaceId, decisionId);
5786
+ }
5787
+ let tags;
5788
+ try {
5789
+ tags = changesTags ? await applyDecisionTagChanges(client, workspaceId, decisionId, tagChanges) : await client.labels.listForEntity({ entityType: "decision", entityId: decisionId });
5790
+ } catch (error) {
5791
+ if (changesContent && changesTags) {
5792
+ const reason = error instanceof Error ? error.message : String(error);
5793
+ throw new Error(
5794
+ `Updated ${decision.label}'s content, but its Pillars/labels were not changed: ${reason}`
5795
+ );
5796
+ }
5797
+ throw error;
5798
+ }
5799
+ if (useJson) outputDecisionJson(decision, { tags });
5513
5800
  else {
5514
5801
  console.log("\n\u2713 Decision updated");
5515
- outputDecisionPretty(decision);
5802
+ outputDecisionPretty(decision, tags);
5516
5803
  }
5517
5804
  } catch (error) {
5518
5805
  handleError(error, useJson);
@@ -7066,7 +7353,7 @@ async function resolveLabelIds(client, workspaceId, values) {
7066
7353
  }
7067
7354
  function createLabelsCommand() {
7068
7355
  const labels = new Command16("labels").description(
7069
- "Manage labels (orthogonal tags applied to actions, tickets, features, and epics)."
7356
+ 'Manage labels (orthogonal tags applied to actions, tickets, features, epics and decisions). Pillars are tags with category "pillar": list them with --category pillar.'
7070
7357
  );
7071
7358
  labels.command("list").description("List labels visible in a workspace").option("--workspace <slug|id>", "Workspace slug or CUID").option(
7072
7359
  "--category <category>",