exponential-cli 1.31.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/README.md CHANGED
@@ -295,7 +295,7 @@ exponential decisions list --meeting <meeting-cuid>
295
295
  # Everything logged in one ceremony occurrence
296
296
  exponential decisions list --workspace clear --occurrence <occurrence-cuid>
297
297
 
298
- # One decision in full: body, evidence, deciders, chain and links.
298
+ # One decision in full: body, evidence, deciders, chain, links, Pillars and labels.
299
299
  # Anything that takes a decision accepts its D-number or its id.
300
300
  exponential decisions get D-0006
301
301
  exponential decisions get <cuid>
@@ -375,6 +375,39 @@ refuses it without one rather than letting the server reject the whole call.
375
375
  Statuses: `OPEN` (an open question) · `PROPOSED` · `ACCEPTED` · `SUPERSEDED` ·
376
376
  `DEPRECATED`. The last two are reached with `decisions status`, never at creation.
377
377
 
378
+ #### Pillars and labels
379
+
380
+ A decision is filed under Pillars and carries labels. Each flag takes a name
381
+ (case-insensitive), a slug or an id, resolved within the decision's workspace;
382
+ a name that matches nothing, or more than one tag, is an error and nothing is
383
+ written. A Pillar passed as `--label` (or the reverse) is refused too.
384
+
385
+ ```bash
386
+ # The log, filtered: a decision carrying ANY of the given Pillars or labels.
387
+ # Each row shows its Pillars and labels; --json rows carry `tags`.
388
+ exponential decisions list --workspace clear --pillar "Data Quality"
389
+ exponential decisions list --workspace clear --pillar data-quality --label infra --label urgent
390
+
391
+ # `get` shows them (and --json adds `tags`)
392
+ exponential decisions get D-0006
393
+
394
+ # File under a Pillar, take one off, add and remove labels
395
+ exponential decisions update D-0006 --add-pillar "Data Quality"
396
+ exponential decisions update D-0006 --remove-pillar "Data Quality" --remove-label urgent
397
+
398
+ # Replace all Pillars (labels untouched), or all labels (Pillars untouched)
399
+ exponential decisions update D-0006 --clear-pillars --add-pillar Platform
400
+ exponential decisions update D-0006 --clear-labels --add-label infra
401
+
402
+ # Tag at creation (applied right after the create; works with --from-file too)
403
+ exponential decisions create -s "Dedupe on ingest" --pillar "Data Quality" --label infra
404
+ ```
405
+
406
+ The server only replaces a decision's whole tag set, so `--add-*` and
407
+ `--remove-*` read the current set first and write the result back; with nothing
408
+ to change, nothing is written. Clears run first, then removes, then adds.
409
+ Creating or promoting a Pillar needs a workspace admin, in the app.
410
+
378
411
  ### Projects
379
412
 
380
413
  ```bash
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
  }
@@ -4994,6 +5014,118 @@ function createRowsCommand() {
4994
5014
  // src/commands/decisions.ts
4995
5015
  import { Command as Command7 } from "commander";
4996
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
4997
5129
  var STATUSES = [
4998
5130
  "OPEN",
4999
5131
  "PROPOSED",
@@ -5093,6 +5225,24 @@ function parseNullableInt(v) {
5093
5225
  if (Number.isNaN(n)) throw new Error(`Expected a number, got "${v}".`);
5094
5226
  return n;
5095
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
+ }
5096
5246
  var DECISION_LABEL = /^D-(\d+)$/i;
5097
5247
  function pickDecisionRef(positional, flag) {
5098
5248
  if (positional && flag && positional !== flag) {
@@ -5195,6 +5345,10 @@ function notLinkedMessage(decision, featureId, error) {
5195
5345
  const reason = error instanceof Error ? error.message : String(error);
5196
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}`;
5197
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
+ }
5198
5352
  function addConfirmCommand(parent) {
5199
5353
  parent.command("confirm [id]").description(
5200
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."
@@ -5267,7 +5421,17 @@ function createDecisionsCommand() {
5267
5421
  "Filter by source (repeatable): MEETING, MANUAL, AGENT",
5268
5422
  (value, previous) => [...previous, parseSource(value)],
5269
5423
  []
5270
- ).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(
5271
5435
  async (options, cmd) => {
5272
5436
  const globalOpts = cmd.optsWithGlobals();
5273
5437
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -5280,6 +5444,15 @@ function createDecisionsCommand() {
5280
5444
  if (options.meeting) {
5281
5445
  const result = await client.decisions.listForMeeting(options.meeting);
5282
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
+ }
5283
5456
  if (options.status.length > 0) {
5284
5457
  rows2 = rows2.filter((d) => options.status.includes(d.status));
5285
5458
  }
@@ -5306,7 +5479,8 @@ function createDecisionsCommand() {
5306
5479
  }
5307
5480
  const workspaceId = await resolveWorkspaceId(client, occurrence?.workspaceSlug ?? options.workspace);
5308
5481
  const limit = parsePositiveInt(options.limit, "--limit");
5309
- 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({
5310
5484
  workspaceId,
5311
5485
  statuses: options.status.length > 0 ? options.status : void 0,
5312
5486
  sources: options.source.length > 0 ? options.source : void 0,
@@ -5315,6 +5489,7 @@ function createDecisionsCommand() {
5315
5489
  projectId: options.project,
5316
5490
  search: options.search,
5317
5491
  number: parsePositiveInt(options.number, "--number"),
5492
+ tagIds,
5318
5493
  // With --occurrence the cap applies after filtering, below.
5319
5494
  limit: occurrence ? void 0 : limit
5320
5495
  });
@@ -5331,7 +5506,7 @@ function createDecisionsCommand() {
5331
5506
  }
5332
5507
  );
5333
5508
  decisions.command("get <id>").description(
5334
- "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."
5335
5510
  ).option("--workspace <slug|id>", "Workspace (defaults to your default workspace)").action(async (id, options, cmd) => {
5336
5511
  const globalOpts = cmd.optsWithGlobals();
5337
5512
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -5339,9 +5514,12 @@ function createDecisionsCommand() {
5339
5514
  const client = getClient();
5340
5515
  const workspaceId = await resolveWorkspaceId(client, options.workspace);
5341
5516
  const decisionId = await resolveDecisionRef(client, workspaceId, id);
5342
- const decision = await client.decisions.get(workspaceId, decisionId);
5343
- if (useJson) outputDecisionJson(decision);
5344
- 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);
5345
5523
  } catch (error) {
5346
5524
  handleError(error, useJson);
5347
5525
  }
@@ -5364,6 +5542,16 @@ function createDecisionsCommand() {
5364
5542
  ).option(
5365
5543
  "--evidence-file <path>",
5366
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
+ []
5367
5555
  ).option("--from-file <path>", 'Bulk create from a JSON array of decisions ("-" = stdin)').action(
5368
5556
  async (options, cmd) => {
5369
5557
  const globalOpts = cmd.optsWithGlobals();
@@ -5389,6 +5577,21 @@ function createDecisionsCommand() {
5389
5577
  if (goalId !== void 0 && Number.isNaN(goalId)) {
5390
5578
  throw new Error(`--goal must be an integer id, got "${options.goal}".`);
5391
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
+ };
5392
5595
  const defaults = {
5393
5596
  workspaceId,
5394
5597
  status,
@@ -5442,6 +5645,18 @@ function createDecisionsCommand() {
5442
5645
  );
5443
5646
  }
5444
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
+ }
5445
5660
  if (options.feature) {
5446
5661
  try {
5447
5662
  await client.decisions.linkFeature(workspaceId, decision2.id, options.feature);
@@ -5484,6 +5699,12 @@ function createDecisionsCommand() {
5484
5699
  deciders: options.decider.length > 0 ? options.decider : void 0,
5485
5700
  evidence: evidenceRaw === void 0 ? void 0 : parseEvidence(evidenceRaw)
5486
5701
  });
5702
+ let tags;
5703
+ try {
5704
+ tags = await tagNew(decision);
5705
+ } catch (error) {
5706
+ throw new Error(notTaggedMessage(decision, error));
5707
+ }
5487
5708
  let featureLink;
5488
5709
  if (options.feature) {
5489
5710
  try {
@@ -5496,13 +5717,17 @@ function createDecisionsCommand() {
5496
5717
  throw new Error(notLinkedMessage(decision, options.feature, error));
5497
5718
  }
5498
5719
  }
5499
- if (useJson) outputDecisionJson(decision, featureLink ? { featureLink } : {});
5500
- else {
5720
+ if (useJson) {
5721
+ outputDecisionJson(decision, {
5722
+ ...featureLink ? { featureLink } : {},
5723
+ ...tags ? { tags } : {}
5724
+ });
5725
+ } else {
5501
5726
  console.log(
5502
5727
  `
5503
5728
  \u2713 ${decision.status === "OPEN" ? "Open question" : "Decision"} logged`
5504
5729
  );
5505
- outputDecisionPretty(decision);
5730
+ outputDecisionPretty(decision, tags);
5506
5731
  if (featureLink) console.log(chalk7.gray(` Linked to feature ${options.feature}`));
5507
5732
  }
5508
5733
  } catch (error) {
@@ -5512,7 +5737,7 @@ function createDecisionsCommand() {
5512
5737
  );
5513
5738
  decisions.command("update [id]").description(
5514
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".`
5515
- ).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(
5516
5741
  async (idArg, options, cmd) => {
5517
5742
  const globalOpts = cmd.optsWithGlobals();
5518
5743
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -5529,24 +5754,52 @@ function createDecisionsCommand() {
5529
5754
  keyResultId: parseNullableString(options.keyResult),
5530
5755
  adrDocumentId: parseNullableString(options.adr)
5531
5756
  };
5532
- 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) {
5533
5768
  throw new Error(
5534
- "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."
5535
5770
  );
5536
5771
  }
5537
5772
  const client = getClient();
5538
5773
  const workspaceId = await resolveWorkspaceId(client, options.workspace);
5539
- const productId = options.product === void 0 ? void 0 : options.product === "null" ? null : await resolveProductId(client, workspaceId, options.product);
5540
- const decision = await client.decisions.update({
5541
- workspaceId,
5542
- decisionId: await resolveDecisionRef(client, workspaceId, ref),
5543
- ...patch,
5544
- productId
5545
- });
5546
- 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 });
5547
5800
  else {
5548
5801
  console.log("\n\u2713 Decision updated");
5549
- outputDecisionPretty(decision);
5802
+ outputDecisionPretty(decision, tags);
5550
5803
  }
5551
5804
  } catch (error) {
5552
5805
  handleError(error, useJson);
@@ -7100,7 +7353,7 @@ async function resolveLabelIds(client, workspaceId, values) {
7100
7353
  }
7101
7354
  function createLabelsCommand() {
7102
7355
  const labels = new Command16("labels").description(
7103
- "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.'
7104
7357
  );
7105
7358
  labels.command("list").description("List labels visible in a workspace").option("--workspace <slug|id>", "Workspace slug or CUID").option(
7106
7359
  "--category <category>",