exponential-cli 1.24.0 → 1.27.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
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/program.ts
4
- import { Command as Command27 } from "commander";
4
+ import { Command as Command29 } from "commander";
5
5
 
6
6
  // src/commands/auth.ts
7
7
  import { Command } from "commander";
@@ -93,12 +93,14 @@ function handleError(error, json = false) {
93
93
  message = "Access denied";
94
94
  break;
95
95
  }
96
+ const property = error.data?.property;
96
97
  if (json) {
97
98
  console.log(JSON.stringify({
98
99
  error: {
99
100
  code,
100
101
  message,
101
- suggestion
102
+ suggestion,
103
+ ...property ? { property } : {}
102
104
  }
103
105
  }, null, 2));
104
106
  } else {
@@ -2662,6 +2664,421 @@ ${heading} (${resources.length} total)`));
2662
2664
  }
2663
2665
  console.log();
2664
2666
  }
2667
+ function outputDatabaseJson(database) {
2668
+ console.log(JSON.stringify(database, null, 2));
2669
+ }
2670
+ function describeProperty(p) {
2671
+ const options = p.options?.length ? ` [${p.options.map((o) => o.name).join(", ")}]` : "";
2672
+ return ` ${p.name} ${chalk3.gray(`${p.type} ${p.id}`)}${chalk3.gray(options)}`;
2673
+ }
2674
+ function outputDatabasePretty(database) {
2675
+ console.log(chalk3.gray("\u2500".repeat(50)));
2676
+ console.log(`
2677
+ ${chalk3.bold(database.name)}`);
2678
+ console.log(chalk3.gray(` ID: ${database.id}`));
2679
+ console.log(` ${chalk3.gray("Page:")} ${database.page.title} ${chalk3.gray(database.page.id)}`);
2680
+ const facts = [];
2681
+ if (typeof database.rowCount === "number") facts.push(`${database.rowCount} row${database.rowCount === 1 ? "" : "s"}`);
2682
+ if (database.detachedAt) facts.push(`detached ${formatDate(new Date(database.detachedAt))} \u2014 block is out of the page`);
2683
+ if (facts.length) console.log(chalk3.gray(` ${facts.join(" \xB7 ")}`));
2684
+ console.log(`
2685
+ ${chalk3.gray("Properties")}`);
2686
+ for (const p of database.properties) console.log(describeProperty(p));
2687
+ const view = database.view;
2688
+ const viewParts = [];
2689
+ if (view.sort) viewParts.push(`sort ${view.sort.propertyId} ${view.sort.direction}`);
2690
+ if (view.filters.length) viewParts.push(`${view.filters.length} filter${view.filters.length === 1 ? "" : "s"}`);
2691
+ if (view.hiddenPropertyIds.length) viewParts.push(`${view.hiddenPropertyIds.length} hidden`);
2692
+ if (viewParts.length) console.log(chalk3.gray(`
2693
+ View: ${viewParts.join(" \xB7 ")}`));
2694
+ console.log();
2695
+ }
2696
+ function outputDatabasesPretty(databases) {
2697
+ if (databases.length === 0) {
2698
+ console.log(chalk3.gray("No databases on this page."));
2699
+ return;
2700
+ }
2701
+ console.log(chalk3.bold(`
2702
+ Databases (${databases.length})`));
2703
+ console.log(chalk3.gray("\u2500".repeat(50)));
2704
+ for (const d of databases) {
2705
+ const state = d.detachedAt ? chalk3.yellow(" detached") : "";
2706
+ const rows = typeof d.rowCount === "number" ? chalk3.gray(` ${d.rowCount} rows`) : "";
2707
+ console.log(` ${d.name} ${chalk3.gray(d.id)}${rows}${state}`);
2708
+ }
2709
+ console.log();
2710
+ }
2711
+ function formatCell(def, value) {
2712
+ if (value === null || value === void 0 || value === "") return chalk3.gray("\u2014");
2713
+ if (Array.isArray(value)) {
2714
+ if (value.length === 0) return chalk3.gray("\u2014");
2715
+ return value.map((v) => formatCell(def, v)).join(", ");
2716
+ }
2717
+ if (def?.options) {
2718
+ return def.options.find((o) => o.id === value)?.name ?? String(value);
2719
+ }
2720
+ if (typeof value === "boolean") return value ? "Yes" : "No";
2721
+ return String(value);
2722
+ }
2723
+ function outputRowJson(row) {
2724
+ console.log(JSON.stringify(row, null, 2));
2725
+ }
2726
+ function outputRowPretty(row, database) {
2727
+ console.log(`
2728
+ ${chalk3.bold(row.title || "Untitled")} ${chalk3.gray(row.id)}`);
2729
+ const defs = database?.properties.filter((p) => p.type !== "title") ?? [];
2730
+ if (defs.length) {
2731
+ for (const def of defs) {
2732
+ console.log(` ${chalk3.gray(`${def.name}:`)} ${formatCell(def, row.values[def.id])}`);
2733
+ }
2734
+ } else {
2735
+ for (const [key, value] of Object.entries(row.values)) {
2736
+ console.log(` ${chalk3.gray(`${key}:`)} ${formatCell(void 0, value)}`);
2737
+ }
2738
+ }
2739
+ console.log(chalk3.gray(` Read the page: exponential pages get ${row.id}`));
2740
+ console.log();
2741
+ }
2742
+ function outputRowsPretty(page, database) {
2743
+ if (page.rows.length === 0) {
2744
+ console.log(chalk3.gray(`No rows in ${database.name}.`));
2745
+ return;
2746
+ }
2747
+ const byId = new Map(database.properties.map((p) => [p.id, p]));
2748
+ const columns = page.columns.map((id) => byId.get(id)).filter((p) => !!p && p.type !== "title");
2749
+ console.log(chalk3.bold(`
2750
+ ${database.name} (${page.rows.length} row${page.rows.length === 1 ? "" : "s"}${page.nextCursor ? ", more" : ""})`));
2751
+ console.log(chalk3.gray("\u2500".repeat(50)));
2752
+ for (const row of page.rows) {
2753
+ const cells = columns.map((c) => `${chalk3.gray(`${c.name}:`)} ${formatCell(c, row.values[c.id])}`);
2754
+ console.log(` ${chalk3.bold(row.title || "Untitled")} ${chalk3.gray(row.id)}`);
2755
+ if (cells.length) console.log(` ${cells.join(" ")}`);
2756
+ }
2757
+ if (page.nextCursor) console.log(chalk3.gray(`
2758
+ More: --cursor ${page.nextCursor}`));
2759
+ console.log();
2760
+ }
2761
+ function outputCsvSkipped(skipped) {
2762
+ if (skipped.length === 0) return;
2763
+ console.log(chalk3.yellow(`
2764
+ ${skipped.length} row${skipped.length === 1 ? "" : "s"} not imported:`));
2765
+ for (const row of skipped) {
2766
+ const why = row.errors.map((e) => `${e.propertyName} ${e.reason}`).join("; ");
2767
+ console.log(` row ${row.index + 1}: ${why}`);
2768
+ }
2769
+ }
2770
+ function outputCsvPreviewPretty(preview) {
2771
+ console.log(chalk3.bold(`
2772
+ CSV preview: ${preview.importable} of ${preview.total} row${preview.total === 1 ? "" : "s"} would be created`));
2773
+ console.log(chalk3.gray("\u2500".repeat(50)));
2774
+ for (const column of preview.columns) {
2775
+ const to = column.target.kind === "skip" ? chalk3.gray("skipped") : column.target.kind === "new" ? `${chalk3.green("new")} ${column.propertyName} (${column.type})` : `${column.propertyName} (${column.type})`;
2776
+ console.log(` ${chalk3.gray(`${column.header} \u2192`)} ${to}`);
2777
+ }
2778
+ const newOptions = Object.entries(preview.newOptions ?? {});
2779
+ if (newOptions.length) {
2780
+ console.log(chalk3.green("\n Options the import will add:"));
2781
+ for (const [columnId, names] of newOptions) {
2782
+ const column = preview.columns.find((c) => (c.target.kind === "property" ? c.target.propertyId : `new:${c.propertyName ?? ""}`) === columnId);
2783
+ console.log(` ${column?.propertyName ?? columnId}: ${names.join(", ")}`);
2784
+ }
2785
+ }
2786
+ const skipped = preview.rows.filter((r) => r.errors.length > 0).map((r) => ({ index: r.index, errors: r.errors }));
2787
+ outputCsvSkipped(skipped);
2788
+ console.log(chalk3.gray("\n Nothing was created. Run again without --dry-run to import."));
2789
+ }
2790
+ function getOccurrenceStatusColor(status) {
2791
+ switch (status) {
2792
+ case "AGENDA_CIRCULATED":
2793
+ case "IN_PROGRESS":
2794
+ return "blue";
2795
+ case "CAPTURED":
2796
+ case "FOLLOWED_THROUGH":
2797
+ return "green";
2798
+ case "SKIPPED":
2799
+ return "yellow";
2800
+ default:
2801
+ return "gray";
2802
+ }
2803
+ }
2804
+ function formatInZone(value, timezone) {
2805
+ const date = new Date(value);
2806
+ try {
2807
+ return date.toLocaleString(void 0, {
2808
+ timeZone: timezone,
2809
+ weekday: "short",
2810
+ year: "numeric",
2811
+ month: "short",
2812
+ day: "numeric",
2813
+ hour: "2-digit",
2814
+ minute: "2-digit",
2815
+ timeZoneName: "short"
2816
+ });
2817
+ } catch {
2818
+ return date.toLocaleString();
2819
+ }
2820
+ }
2821
+ function outputCeremoniesJson(ceremonies, extra = {}) {
2822
+ console.log(JSON.stringify({ ceremonies, total: ceremonies.length, ...extra }, null, 2));
2823
+ }
2824
+ function outputCeremoniesPretty(ceremonies) {
2825
+ if (ceremonies.length === 0) {
2826
+ console.log(chalk3.gray("No ceremonies found."));
2827
+ return;
2828
+ }
2829
+ console.log(chalk3.bold(`
2830
+ Ceremonies (${ceremonies.length})`));
2831
+ console.log(chalk3.gray("\u2500".repeat(50)));
2832
+ for (const c of ceremonies) {
2833
+ const inactive = c.isActive ? "" : chalk3.red(" [inactive]");
2834
+ console.log(` ${chalk3.bold(c.name)} ${chalk3.gray(`(${c.slug})`)} ${chalk3.cyan(`[${c.kind}]`)}${inactive}`);
2835
+ console.log(chalk3.gray(` ID: ${c.id}`));
2836
+ console.log(
2837
+ chalk3.gray(
2838
+ ` ${c.cadenceRule ?? "one-off"} \xB7 ${c.timezone} \xB7 ${c.durationMinutes} min \xB7 owner ${c.owner?.name ?? c.ownerId} \xB7 ${c._count.participants} participants \xB7 ${c._count.occurrences} occurrences`
2839
+ )
2840
+ );
2841
+ }
2842
+ console.log();
2843
+ }
2844
+ function outputCeremonyJson(ceremony) {
2845
+ console.log(JSON.stringify(ceremony, null, 2));
2846
+ }
2847
+ function outputCeremonyPretty(c) {
2848
+ console.log(chalk3.gray("\u2500".repeat(50)));
2849
+ const inactive = c.isActive ? "" : chalk3.red(" [inactive]");
2850
+ console.log(`
2851
+ ${chalk3.bold(c.name)} ${chalk3.cyan(`[${c.kind}]`)}${inactive}`);
2852
+ console.log(chalk3.gray(` ID: ${c.id} \xB7 slug: ${c.slug}`));
2853
+ console.log(
2854
+ ` ${chalk3.gray("Cadence:")} ${c.isOneOff ? "one-off meeting" : c.cadenceRule ?? "none"} (${c.timezone}), ${c.durationMinutes} min, agenda ${c.leadTimeHours}h ahead`
2855
+ );
2856
+ if (c.meetingUrl) console.log(` ${chalk3.gray("Room:")} ${c.meetingUrl}`);
2857
+ if (c.autoExtractOutputs) console.log(` ${chalk3.gray("Outputs:")} extracted automatically from recordings`);
2858
+ console.log(` ${chalk3.gray("Owner:")} ${c.owner?.name ?? c.owner?.email ?? c.ownerId}`);
2859
+ if (c.participants.length > 0) {
2860
+ console.log(` ${chalk3.gray("Participants:")} ${c.participants.map((p) => p.user.name ?? p.user.email ?? p.userId).join(", ")}`);
2861
+ }
2862
+ if (c.product) console.log(` ${chalk3.gray("Product:")} ${c.product.name}`);
2863
+ if (c.team) console.log(` ${chalk3.gray("Team:")} ${c.team.name}`);
2864
+ if (c.projects.length > 0) {
2865
+ console.log(` ${chalk3.gray("Projects:")} ${c.projects.map((p) => p.project.name).join(", ")}`);
2866
+ }
2867
+ if (c.aliases.length > 0) console.log(` ${chalk3.gray("Aliases:")} ${c.aliases.join(", ")}`);
2868
+ for (const [label, body] of [
2869
+ ["Purpose", c.purpose],
2870
+ ["Not for", c.notFor],
2871
+ ["Inputs", c.inputs],
2872
+ ["Outputs", c.outputs]
2873
+ ]) {
2874
+ if (body) console.log(`
2875
+ ${chalk3.bold(label)}
2876
+ ${body}`);
2877
+ }
2878
+ if (c.agendaTemplate.length > 0) {
2879
+ console.log(`
2880
+ ${chalk3.bold("Agenda template")}`);
2881
+ for (const s of c.agendaTemplate) {
2882
+ console.log(` - ${s.title} ${chalk3.gray(`(${s.type}${s.minutes ? `, ${s.minutes} min` : ""})`)}`);
2883
+ }
2884
+ }
2885
+ if (c.occurrences.length > 0) {
2886
+ console.log(`
2887
+ ${chalk3.bold("Occurrences")} ${chalk3.gray("(newest first)")}`);
2888
+ for (const o of c.occurrences) {
2889
+ const color = getOccurrenceStatusColor(o.status);
2890
+ const moved = o.cadenceStart === null ? chalk3.gray(" \xB7 added off-cadence") : new Date(o.cadenceStart).getTime() !== new Date(o.scheduledStart).getTime() ? chalk3.gray(` \xB7 moved from ${formatInZone(o.cadenceStart, c.timezone)}`) : "";
2891
+ const recs = o.recordedMeetings.length > 0 ? chalk3.gray(` \xB7 ${o.recordedMeetings.length} recording${o.recordedMeetings.length === 1 ? "" : "s"}`) : "";
2892
+ console.log(` ${formatInZone(o.scheduledStart, c.timezone)} ${chalk3[color](`[${o.status}]`)}${moved}${recs}`);
2893
+ console.log(chalk3.gray(` ID: ${o.id}${o.skipReason ? ` \xB7 skipped: ${o.skipReason}` : ""}`));
2894
+ }
2895
+ }
2896
+ console.log();
2897
+ }
2898
+ function outputCeremonyTemplatesPretty(templates) {
2899
+ console.log(chalk3.bold(`
2900
+ Ceremony templates (${templates.length})`));
2901
+ console.log(chalk3.gray("\u2500".repeat(50)));
2902
+ for (const t of templates) {
2903
+ console.log(` ${chalk3.bold(t.name)} ${chalk3.gray(`(${t.slug})`)} ${chalk3.cyan(`[${t.kind}]`)}`);
2904
+ console.log(chalk3.gray(` ${t.cadenceRule} \xB7 ${t.durationMinutes} min \xB7 ${t.agendaTemplate.length} agenda sections`));
2905
+ if (t.purpose) console.log(chalk3.gray(` ${t.purpose}`));
2906
+ }
2907
+ console.log();
2908
+ }
2909
+ function outputCeremonyWritePretty(result, verb) {
2910
+ const c = result.ceremony;
2911
+ console.log(`\u2713 Ceremony ${verb}: ${chalk3.bold(c.name)} ${chalk3.gray(`(${c.slug})`)}`);
2912
+ console.log(chalk3.gray(` ID: ${c.id}`));
2913
+ if (result.occurrencesCreated > 0) {
2914
+ console.log(chalk3.gray(` ${result.occurrencesCreated} occurrence${result.occurrencesCreated === 1 ? "" : "s"} scheduled`));
2915
+ }
2916
+ }
2917
+ function outputOccurrencesJson(occurrences, extra = {}) {
2918
+ console.log(JSON.stringify({ occurrences, total: occurrences.length, ...extra }, null, 2));
2919
+ }
2920
+ function outputOccurrencesPretty(occurrences) {
2921
+ if (occurrences.length === 0) {
2922
+ console.log(chalk3.gray("No occurrences in this window."));
2923
+ return;
2924
+ }
2925
+ console.log(chalk3.bold(`
2926
+ Occurrences (${occurrences.length})`));
2927
+ console.log(chalk3.gray("\u2500".repeat(50)));
2928
+ for (const o of occurrences) {
2929
+ const color = getOccurrenceStatusColor(o.status);
2930
+ console.log(` ${formatInZone(o.scheduledStart)} ${chalk3.bold(o.ceremony.name)} ${chalk3[color](`[${o.status}]`)}`);
2931
+ console.log(chalk3.gray(` ID: ${o.id} \xB7 ceremony ${o.ceremonyId}`));
2932
+ }
2933
+ console.log();
2934
+ }
2935
+ function outputOccurrenceJson(occurrence, extras = {}) {
2936
+ console.log(JSON.stringify({ ...occurrence, ...extras }, null, 2));
2937
+ }
2938
+ function outputAgendaPretty(agenda) {
2939
+ if (!agenda) {
2940
+ console.log(chalk3.gray("\nNo agenda generated yet."));
2941
+ return;
2942
+ }
2943
+ console.log(`
2944
+ ${chalk3.bold("Agenda")} ${chalk3.gray(`(generated ${new Date(agenda.generatedAt).toLocaleString()})`)}`);
2945
+ for (const section of agenda.sections) {
2946
+ const minutes = section.minutes ? chalk3.gray(` \xB7 ${section.minutes} min`) : "";
2947
+ console.log(`
2948
+ ${chalk3.bold(section.title)}${minutes} ${chalk3.gray(`[${section.key}]`)}`);
2949
+ if (section.items.length === 0) {
2950
+ console.log(chalk3.gray(` ${section.emptyReason ?? "Nothing here."}`));
2951
+ }
2952
+ for (const item of section.items) {
2953
+ const box = item.resolvedAt ? chalk3.green("[x]") : "[ ]";
2954
+ const carried = item.carryCount ? chalk3.yellow(` \u21BB${item.carryCount}`) : "";
2955
+ console.log(` ${box} ${item.title}${carried}`);
2956
+ const meta = [item.detail, `${item.refType} \xB7 id ${item.id}`].filter(Boolean).join(" \xB7 ");
2957
+ console.log(chalk3.gray(` ${meta}`));
2958
+ }
2959
+ }
2960
+ if (agenda.narrative) {
2961
+ console.log(`
2962
+ ${chalk3.bold("Summary")}
2963
+ ${agenda.narrative}`);
2964
+ }
2965
+ }
2966
+ function outputOccurrenceUpdatesPretty(summary) {
2967
+ if (summary.questions.length === 0) {
2968
+ console.log(chalk3.gray("This ceremony kind has no async updates."));
2969
+ return;
2970
+ }
2971
+ console.log(
2972
+ chalk3.bold(`
2973
+ Async updates: ${summary.submittedCount} of ${summary.participants.length} submitted`) + (summary.blockedCount > 0 ? chalk3.red(` \xB7 ${summary.blockedCount} blocked`) : "")
2974
+ );
2975
+ for (const p of summary.participants) {
2976
+ const state = p.submittedAt ? chalk3.green("submitted") : chalk3.gray("not yet");
2977
+ const blocked = p.flaggedBlocker ? chalk3.red(" [blocked]") : "";
2978
+ console.log(`
2979
+ ${chalk3.bold(p.name ?? p.email ?? p.userId)} ${state}${blocked}`);
2980
+ for (const q of summary.questions) {
2981
+ const answer = p.answers[q.key];
2982
+ if (answer) console.log(` ${chalk3.gray(q.prompt)}
2983
+ ${answer.replace(/\n/g, "\n ")}`);
2984
+ }
2985
+ }
2986
+ console.log();
2987
+ }
2988
+ function outputMyOccurrenceUpdatePretty(update) {
2989
+ if (update.questions.length === 0) {
2990
+ console.log(chalk3.gray("This ceremony kind has no async updates."));
2991
+ return;
2992
+ }
2993
+ const state = update.submittedAt ? chalk3.green(`submitted ${new Date(update.submittedAt).toLocaleString()}`) : chalk3.gray("not submitted");
2994
+ console.log(`
2995
+ ${chalk3.bold("Your update")} ${state}${update.flaggedBlocker ? chalk3.red(" [blocked]") : ""}`);
2996
+ if (update.isParticipant === false) {
2997
+ console.log(chalk3.yellow(" You aren't a participant of this ceremony."));
2998
+ }
2999
+ for (const q of update.questions) {
3000
+ const answer = update.answers[q.key];
3001
+ const draft = update.draftAnswers[q.key];
3002
+ console.log(`
3003
+ ${chalk3.bold(q.prompt)} ${chalk3.gray(`[${q.key}]`)}`);
3004
+ if (answer) console.log(` ${answer.replace(/\n/g, "\n ")}`);
3005
+ else if (draft) console.log(chalk3.gray(` (draft) ${draft.replace(/\n/g, "\n ")}`));
3006
+ else console.log(chalk3.gray(" \u2014"));
3007
+ }
3008
+ console.log();
3009
+ }
3010
+ function outputOccurrencePretty(o, extras = {}) {
3011
+ const tz = o.ceremony.timezone;
3012
+ const color = getOccurrenceStatusColor(o.status);
3013
+ console.log(chalk3.gray("\u2500".repeat(50)));
3014
+ console.log(`
3015
+ ${chalk3.bold(o.ceremony.name)} \u2014 ${formatInZone(o.scheduledStart, tz)} ${chalk3[color](`[${o.status}]`)}`);
3016
+ console.log(chalk3.gray(` ID: ${o.id} \xB7 ceremony ${o.ceremonyId}`));
3017
+ console.log(` ${chalk3.gray("Owner:")} ${o.ceremony.owner?.name ?? o.ceremony.owner?.email ?? o.ceremony.ownerId}`);
3018
+ if (o.isOneOff) console.log(` ${chalk3.gray("One-off meeting")}${o.purpose ? `: ${o.purpose}` : ""}`);
3019
+ if (o.cadenceStart && new Date(o.cadenceStart).getTime() !== new Date(o.scheduledStart).getTime()) {
3020
+ console.log(` ${chalk3.gray("Moved from:")} ${formatInZone(o.cadenceStart, tz)}`);
3021
+ }
3022
+ if (o.scheduledMeeting) {
3023
+ const names = o.scheduledMeeting.attendees.map((a) => a.name ?? a.userId).filter(Boolean);
3024
+ console.log(
3025
+ ` ${chalk3.gray("Booking:")} ${o.scheduledMeeting.status}${names.length > 0 ? ` \xB7 ${names.join(", ")}` : ""}`
3026
+ );
3027
+ }
3028
+ if (o.skipReason) console.log(` ${chalk3.gray("Skipped:")} ${o.skipReason}`);
3029
+ if (o.agendaCirculatedAt) {
3030
+ console.log(` ${chalk3.gray("Agenda circulated:")} ${formatInZone(o.agendaCirculatedAt, tz)}`);
3031
+ }
3032
+ if (o.skipProposal?.proposed) {
3033
+ console.log(chalk3.yellow(" The agenda is empty \u2014 this occurrence is a candidate to skip."));
3034
+ }
3035
+ if (o.recordedMeetings.length > 0) {
3036
+ console.log(` ${chalk3.gray("Recordings:")}`);
3037
+ for (const m of o.recordedMeetings) {
3038
+ console.log(m.visible ? ` ${m.title ?? "(untitled)"} ${chalk3.gray(m.id)}` : chalk3.gray(` (a recording you cannot view) ${m.id}`));
3039
+ }
3040
+ }
3041
+ if (o.notesPageId && extras.notes === void 0) {
3042
+ console.log(` ${chalk3.gray("Notes page:")} ${o.notesPageId} ${chalk3.gray("(--notes to include)")}`);
3043
+ }
3044
+ outputAgendaPretty(o.agenda);
3045
+ if (extras.notes !== void 0 && !extras.extrasErrors?.notes) {
3046
+ console.log(`
3047
+ ${chalk3.bold("Notes")}`);
3048
+ console.log(extras.notes?.body ? extras.notes.body : chalk3.gray("No notes yet."));
3049
+ }
3050
+ if (extras.decisions) {
3051
+ console.log(`
3052
+ ${chalk3.bold("Decisions and open questions")}`);
3053
+ if (extras.decisions.length === 0) console.log(chalk3.gray("None logged against this occurrence."));
3054
+ for (const d of extras.decisions) {
3055
+ console.log(` ${chalk3.gray(d.label)} ${d.statement} ${chalk3[getDecisionStatusColor(d.status)](`[${d.status}]`)}`);
3056
+ }
3057
+ }
3058
+ if (extras.updates) outputOccurrenceUpdatesPretty(extras.updates);
3059
+ for (const [section, message] of Object.entries(extras.extrasErrors ?? {})) {
3060
+ console.log(chalk3.yellow(`
3061
+ Couldn't load ${section}: ${message}`));
3062
+ }
3063
+ console.log();
3064
+ }
3065
+ function outputProjectOccurrencesPretty(rows) {
3066
+ if (rows.length === 0) {
3067
+ console.log(chalk3.gray("No meetings in this window."));
3068
+ return;
3069
+ }
3070
+ console.log(chalk3.bold(`
3071
+ Project meetings (${rows.length})`));
3072
+ console.log(chalk3.gray("\u2500".repeat(50)));
3073
+ for (const r of rows) {
3074
+ const color = getOccurrenceStatusColor(r.status);
3075
+ const oneOff = r.isOneOff ? chalk3.cyan(" [one-off]") : "";
3076
+ console.log(` ${formatInZone(r.scheduledStart)} ${chalk3.bold(r.ceremonyName)}${oneOff} ${chalk3[color](`[${r.status}]`)}`);
3077
+ const meta = [`ID: ${r.occurrenceId}`, `${r.attendeeCount} attendee${r.attendeeCount === 1 ? "" : "s"}`, r.purpose].filter(Boolean);
3078
+ console.log(chalk3.gray(` ${meta.join(" \xB7 ")}`));
3079
+ }
3080
+ console.log();
3081
+ }
2665
3082
 
2666
3083
  // src/commands/actions.ts
2667
3084
  var VALID_PRIORITIES = [
@@ -3045,194 +3462,1378 @@ function createContactsCommand() {
3045
3462
  } else {
3046
3463
  outputContactsPretty(result.contacts);
3047
3464
  }
3048
- } catch (error) {
3049
- handleError(error, useJson);
3465
+ } catch (error) {
3466
+ handleError(error, useJson);
3467
+ }
3468
+ });
3469
+ contacts.command("get").description("Get a contact by ID").argument("<id>", "Contact ID").option("--interactions", "Include interaction history").action(async (id, options, cmd) => {
3470
+ const globalOpts = cmd.optsWithGlobals();
3471
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3472
+ try {
3473
+ const client = getClient();
3474
+ const contact = await client.contacts.get(id, {
3475
+ includeInteractions: options.interactions
3476
+ });
3477
+ if (useJson) {
3478
+ outputContactJson(contact);
3479
+ } else {
3480
+ outputContactPretty(contact);
3481
+ }
3482
+ } catch (error) {
3483
+ handleError(error, useJson);
3484
+ }
3485
+ });
3486
+ contacts.command("create").description("Create a new contact").requiredOption("--workspace <id>", "Workspace ID").option("--first-name <name>", "First name").option("--last-name <name>", "Last name").option("--email <email>", "Email address").option("--phone <phone>", "Phone number").option("--linkedin <url>", "LinkedIn URL").option("--telegram <handle>", "Telegram handle").option("--twitter <handle>", "Twitter/X handle").option("--github <handle>", "GitHub username").option("--bluesky <handle>", "Bluesky handle").option("--about <text>", "About / bio").option("--profile-type <type>", "Profile type").option("--skills <skills>", "Skills (comma-separated)").option("--tags <tags>", "Tags (comma-separated)").option("--organization <id>", "Organization ID").option("--organization-name <name>", "Organization name (find-or-create; ignored if --organization is set)").action(async (options, cmd) => {
3487
+ const globalOpts = cmd.optsWithGlobals();
3488
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3489
+ try {
3490
+ const client = getClient();
3491
+ const contact = await client.contacts.create({
3492
+ workspaceId: options.workspace,
3493
+ firstName: options.firstName,
3494
+ lastName: options.lastName,
3495
+ email: options.email,
3496
+ phone: options.phone,
3497
+ linkedIn: options.linkedin,
3498
+ telegram: options.telegram,
3499
+ twitter: options.twitter,
3500
+ github: options.github,
3501
+ bluesky: options.bluesky,
3502
+ about: options.about,
3503
+ profileType: options.profileType,
3504
+ skills: options.skills?.split(",").map((s) => s.trim()),
3505
+ tags: options.tags?.split(",").map((t) => t.trim()),
3506
+ organizationId: options.organization,
3507
+ organizationName: options.organizationName
3508
+ });
3509
+ if (useJson) {
3510
+ outputContactJson(contact);
3511
+ } else {
3512
+ console.log("\n\u2713 Contact created successfully");
3513
+ outputContactPretty(contact);
3514
+ }
3515
+ } catch (error) {
3516
+ handleError(error, useJson);
3517
+ }
3518
+ });
3519
+ contacts.command("update").description("Update an existing contact").requiredOption("--id <id>", "Contact ID").option("--first-name <name>", "First name").option("--last-name <name>", "Last name").option("--email <email>", 'Email (use "null" to clear)').option("--phone <phone>", 'Phone (use "null" to clear)').option("--linkedin <url>", 'LinkedIn URL (use "null" to clear)').option("--telegram <handle>", 'Telegram handle (use "null" to clear)').option("--twitter <handle>", 'Twitter/X handle (use "null" to clear)').option("--github <handle>", 'GitHub username (use "null" to clear)').option("--bluesky <handle>", 'Bluesky handle (use "null" to clear)').option("--about <text>", "About / bio").option("--profile-type <type>", "Profile type").option("--skills <skills>", "Skills (comma-separated)").option("--tags <tags>", "Tags (comma-separated)").option("--organization <id>", 'Organization ID (use "null" to clear)').option("--organization-name <name>", "Organization name (find-or-create; ignored if --organization is set)").action(async (options, cmd) => {
3520
+ const globalOpts = cmd.optsWithGlobals();
3521
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3522
+ const nullable = (v) => v === "null" ? null : v;
3523
+ try {
3524
+ const client = getClient();
3525
+ const contact = await client.contacts.update({
3526
+ id: options.id,
3527
+ firstName: options.firstName,
3528
+ lastName: options.lastName,
3529
+ email: nullable(options.email),
3530
+ phone: nullable(options.phone),
3531
+ linkedIn: nullable(options.linkedin),
3532
+ telegram: nullable(options.telegram),
3533
+ twitter: nullable(options.twitter),
3534
+ github: nullable(options.github),
3535
+ bluesky: nullable(options.bluesky),
3536
+ about: options.about,
3537
+ profileType: options.profileType,
3538
+ skills: options.skills?.split(",").map((s) => s.trim()),
3539
+ tags: options.tags?.split(",").map((t) => t.trim()),
3540
+ organizationId: nullable(options.organization),
3541
+ organizationName: options.organizationName
3542
+ });
3543
+ if (useJson) {
3544
+ outputContactJson(contact);
3545
+ } else {
3546
+ console.log("\n\u2713 Contact updated successfully");
3547
+ outputContactPretty(contact);
3548
+ }
3549
+ } catch (error) {
3550
+ handleError(error, useJson);
3551
+ }
3552
+ });
3553
+ contacts.command("delete").description("Delete a contact").argument("<id>", "Contact ID").action(async (id, _options, cmd) => {
3554
+ const globalOpts = cmd.optsWithGlobals();
3555
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3556
+ try {
3557
+ const client = getClient();
3558
+ await client.contacts.delete(id);
3559
+ if (useJson) {
3560
+ console.log(JSON.stringify({ deleted: true, id }, null, 2));
3561
+ } else {
3562
+ console.log(`
3563
+ \u2713 Contact ${id} deleted`);
3564
+ }
3565
+ } catch (error) {
3566
+ handleError(error, useJson);
3567
+ }
3568
+ });
3569
+ contacts.command("add-interaction").description("Add an interaction to a contact").requiredOption("--contact <id>", "Contact ID").requiredOption("--type <type>", `Interaction type (${VALID_INTERACTION_TYPES.join(", ")})`).requiredOption("--direction <dir>", `Direction (${VALID_INTERACTION_DIRECTIONS.join(", ")})`).option("--subject <text>", "Subject line").option("--notes <text>", "Notes").action(async (options, cmd) => {
3570
+ const globalOpts = cmd.optsWithGlobals();
3571
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3572
+ try {
3573
+ if (!VALID_INTERACTION_TYPES.includes(options.type)) {
3574
+ throw new Error(`Invalid interaction type "${options.type}". Valid: ${VALID_INTERACTION_TYPES.join(", ")}`);
3575
+ }
3576
+ if (!VALID_INTERACTION_DIRECTIONS.includes(options.direction)) {
3577
+ throw new Error(`Invalid direction "${options.direction}". Valid: ${VALID_INTERACTION_DIRECTIONS.join(", ")}`);
3578
+ }
3579
+ const client = getClient();
3580
+ const interaction = await client.contacts.addInteraction({
3581
+ contactId: options.contact,
3582
+ type: options.type,
3583
+ direction: options.direction,
3584
+ subject: options.subject,
3585
+ notes: options.notes
3586
+ });
3587
+ if (useJson) {
3588
+ outputInteractionJson(interaction);
3589
+ } else {
3590
+ console.log("\n\u2713 Interaction added");
3591
+ outputInteractionPretty(interaction);
3592
+ }
3593
+ } catch (error) {
3594
+ handleError(error, useJson);
3595
+ }
3596
+ });
3597
+ contacts.command("enrich").description("Queue a web-search enrichment job for an existing contact (runs regardless of the workspace auto-enrich setting)").argument("<id>", "Contact ID").action(async (id, _options, cmd) => {
3598
+ const globalOpts = cmd.optsWithGlobals();
3599
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3600
+ try {
3601
+ const client = getClient();
3602
+ const result = await client.contacts.enrich(id);
3603
+ if (useJson) {
3604
+ console.log(JSON.stringify(result, null, 2));
3605
+ } else if (result.enqueued) {
3606
+ console.log(`
3607
+ \u2713 Enrichment queued for contact ${id} (job ${result.enrichmentId})`);
3608
+ } else if (result.reason === "already-in-flight") {
3609
+ console.log(`
3610
+ \u2022 Enrichment already in progress for contact ${id} (job ${result.enrichmentId})`);
3611
+ } else {
3612
+ console.log(`
3613
+ \u2022 Not queued for contact ${id}${result.reason ? ` (${result.reason})` : ""}`);
3614
+ }
3615
+ } catch (error) {
3616
+ handleError(error, useJson);
3617
+ }
3618
+ });
3619
+ return contacts;
3620
+ }
3621
+
3622
+ // src/commands/ceremonies.ts
3623
+ import { Command as Command4 } from "commander";
3624
+ import chalk4 from "chalk";
3625
+
3626
+ // src/utils/input.ts
3627
+ import { readFileSync } from "fs";
3628
+ var stdinConsumed = false;
3629
+ function readText(inline, file) {
3630
+ if (inline !== void 0) return inline;
3631
+ if (file === void 0) return void 0;
3632
+ if (file === "-") {
3633
+ if (stdinConsumed) {
3634
+ throw new Error('stdin ("-") can only back one option per invocation.');
3635
+ }
3636
+ stdinConsumed = true;
3637
+ return readFileSync(0, "utf-8");
3638
+ }
3639
+ return readFileSync(file, "utf-8");
3640
+ }
3641
+ function parseDate(value) {
3642
+ if (value === void 0 || value === "") return void 0;
3643
+ const date = /^\d{4}-\d{2}-\d{2}$/.test(value) ? /* @__PURE__ */ new Date(`${value}T00:00:00`) : new Date(value);
3644
+ if (Number.isNaN(date.getTime())) {
3645
+ throw new Error(
3646
+ `Invalid date: "${value}". Use ISO format, e.g. 2026-08-25 or 2026-08-25T14:00.`
3647
+ );
3648
+ }
3649
+ return date;
3650
+ }
3651
+
3652
+ // src/commands/ceremonies.ts
3653
+ var KINDS = [
3654
+ "STANDUP",
3655
+ "PLANNING",
3656
+ "REVIEW",
3657
+ "RETROSPECTIVE",
3658
+ "PRIORITISATION",
3659
+ "ALL_HANDS",
3660
+ "ONE_ON_ONE",
3661
+ "CUSTOM"
3662
+ ];
3663
+ var DAY_MS = 24 * 60 * 60 * 1e3;
3664
+ var CUID = /^c[a-z0-9]{24}$/;
3665
+ var OCCURRENCE_LIST_CAP = 200;
3666
+ function parseKind(value) {
3667
+ const upper = value.toUpperCase().replace(/-/g, "_");
3668
+ if (!KINDS.includes(upper)) {
3669
+ throw new Error(`Invalid kind "${value}". Use one of: ${KINDS.join(", ")}`);
3670
+ }
3671
+ return upper;
3672
+ }
3673
+ function parseIntInRange(value, flag, min, max) {
3674
+ if (value === void 0) return void 0;
3675
+ const n = Number(value);
3676
+ if (!Number.isInteger(n) || n < min || n > max) {
3677
+ throw new Error(`${flag} must be an integer from ${min} to ${max} (got "${value}").`);
3678
+ }
3679
+ return n;
3680
+ }
3681
+ var collect = (value, previous) => [...previous, value];
3682
+ var DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
3683
+ function parseCalendarDate(value) {
3684
+ const parsed = parseDate(value);
3685
+ return value !== void 0 && DATE_ONLY.test(value) ? /* @__PURE__ */ new Date(`${value}T00:00:00.000Z`) : parsed;
3686
+ }
3687
+ function parseWindowEnd(value) {
3688
+ const parsed = parseDate(value);
3689
+ return value !== void 0 && DATE_ONLY.test(value) ? /* @__PURE__ */ new Date(`${value}T23:59:59.999`) : parsed;
3690
+ }
3691
+ function parseCeremonyRef(value) {
3692
+ const match = value.match(/\/w\/([^/?#]+)\/ceremonies\/([^/?#]+)(?:\/([^/?#]+))?/);
3693
+ if (!match) return { id: value };
3694
+ const [, workspaceSlug, ceremonyId, occurrenceId] = match;
3695
+ return {
3696
+ workspaceSlug,
3697
+ ceremonyId,
3698
+ occurrenceId,
3699
+ id: occurrenceId ?? ceremonyId
3700
+ };
3701
+ }
3702
+ function parseOccurrenceRef(value) {
3703
+ const ref = parseCeremonyRef(value);
3704
+ if (ref.ceremonyId && !ref.occurrenceId) {
3705
+ throw new Error(
3706
+ "That URL is a ceremony, not one of its occurrences. List them with `ceremonies occurrences list --ceremony <url>`."
3707
+ );
3708
+ }
3709
+ return ref;
3710
+ }
3711
+ async function resolveCeremonyId(client, workspaceId, ref) {
3712
+ if (CUID.test(ref)) return ref;
3713
+ const all = await client.ceremonies.list(workspaceId, { includeInactive: true });
3714
+ const hit = all.find((c) => c.slug === ref || c.id === ref);
3715
+ if (!hit) {
3716
+ throw new Error(
3717
+ `No ceremony "${ref}" in this workspace. Run \`exponential ceremonies list\` to see slugs and ids.`
3718
+ );
3719
+ }
3720
+ return hit.id;
3721
+ }
3722
+ async function workspaceFor(client, ref, flag) {
3723
+ return resolveWorkspaceId(client, ref.workspaceSlug ?? flag);
3724
+ }
3725
+ function readAgendaTemplate(file) {
3726
+ const raw = readText(void 0, file);
3727
+ if (raw === void 0) return void 0;
3728
+ const parsed = JSON.parse(raw);
3729
+ if (!Array.isArray(parsed)) {
3730
+ throw new Error("--agenda-file must hold a JSON array of { key, type, title, minutes?, config? } sections.");
3731
+ }
3732
+ return parsed;
3733
+ }
3734
+ function parseSuppliedAnswers(pairs, file) {
3735
+ const answers = {};
3736
+ const raw = readText(void 0, file);
3737
+ if (raw !== void 0) {
3738
+ const parsed = JSON.parse(raw);
3739
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
3740
+ throw new Error("--answers-file must hold a JSON object of { questionKey: markdown }.");
3741
+ }
3742
+ for (const [key, value] of Object.entries(parsed)) {
3743
+ if (typeof value !== "string") {
3744
+ throw new Error(`--answers-file: the answer for "${key}" must be a string.`);
3745
+ }
3746
+ answers[key] = value;
3747
+ }
3748
+ }
3749
+ for (const pair of pairs) {
3750
+ const eq = pair.indexOf("=");
3751
+ if (eq <= 0) throw new Error(`--answer takes key=markdown (got "${pair}").`);
3752
+ answers[pair.slice(0, eq)] = pair.slice(eq + 1);
3753
+ }
3754
+ return answers;
3755
+ }
3756
+ function addDefinitionOptions(cmd) {
3757
+ 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(
3758
+ "--cadence <rrule>",
3759
+ 'RRULE body, e.g. "FREQ=WEEKLY;BYDAY=MO;BYHOUR=10;BYMINUTE=0"'
3760
+ ).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");
3761
+ }
3762
+ function definitionFields(options, cmd) {
3763
+ const fields = {};
3764
+ if (options.name !== void 0) fields.name = options.name;
3765
+ if (options.slug !== void 0) fields.slug = options.slug;
3766
+ if (options.kind !== void 0) fields.kind = parseKind(options.kind);
3767
+ if (options.cadence !== void 0) fields.cadenceRule = options.cadence;
3768
+ if (options.timezone !== void 0) fields.timezone = options.timezone;
3769
+ if (options.startsOn !== void 0) fields.startsOn = parseCalendarDate(options.startsOn);
3770
+ const duration = parseIntInRange(options.duration, "--duration", 5, 24 * 60);
3771
+ if (duration !== void 0) fields.durationMinutes = duration;
3772
+ const leadTime = parseIntInRange(options.leadTime, "--lead-time", 0, 24 * 14);
3773
+ if (leadTime !== void 0) fields.leadTimeHours = leadTime;
3774
+ if (options.owner !== void 0) fields.ownerId = options.owner;
3775
+ if (options.participant.length > 0) fields.participantUserIds = options.participant;
3776
+ if (options.project.length > 0) fields.projectIds = options.project;
3777
+ if (options.alias.length > 0) fields.aliases = options.alias;
3778
+ if (options.product !== void 0) fields.productId = options.product;
3779
+ const purpose = readText(options.purpose, options.purposeFile);
3780
+ if (purpose !== void 0) fields.purpose = purpose;
3781
+ if (options.notFor !== void 0) fields.notFor = options.notFor;
3782
+ if (options.inputs !== void 0) fields.inputs = options.inputs;
3783
+ if (options.outputs !== void 0) fields.outputs = options.outputs;
3784
+ const agenda = readAgendaTemplate(options.agendaFile);
3785
+ if (agenda !== void 0) fields.agendaTemplate = agenda;
3786
+ if (cmd.getOptionValueSource("includeProjects") === "cli") {
3787
+ fields.includeProjects = options.includeProjects;
3788
+ }
3789
+ if (options.meetingUrl !== void 0) fields.meetingUrl = options.meetingUrl;
3790
+ if (cmd.getOptionValueSource("autoExtractOutputs") === "cli") {
3791
+ fields.autoExtractOutputs = options.autoExtractOutputs;
3792
+ }
3793
+ return fields;
3794
+ }
3795
+ function parseDateTime(value, flag) {
3796
+ if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
3797
+ throw new Error(`${flag} needs a time too, e.g. 2026-11-04T10:00 (local) or 2026-11-04T09:00Z.`);
3798
+ }
3799
+ const date = parseDate(value);
3800
+ if (!date) throw new Error(`${flag} is required.`);
3801
+ return date;
3802
+ }
3803
+ function createOccurrencesCommand() {
3804
+ const occurrences = new Command4("occurrences").alias("occurrence").description(
3805
+ [
3806
+ "Scheduled instances of a ceremony \u2014 the page at /w/<slug>/ceremonies/<ceremonyId>/<occurrenceId>.",
3807
+ "Every <occurrence> argument takes the occurrence CUID or that full URL (the URL brings its own workspace)."
3808
+ ].join("\n")
3809
+ );
3810
+ occurrences.command("list").description(
3811
+ [
3812
+ "Occurrences starting in a window, oldest first (max 200). Default window: 14 days either side of now.",
3813
+ "--project <id> instead shows that project's Meetings timeline: newest first, one-offs included,",
3814
+ "two weeks back to one week ahead by default, at most --per-ceremony rows per recurring ceremony, and leaving",
3815
+ "out occurrences a recording on that project already captured."
3816
+ ].join(" ")
3817
+ ).option("--workspace <slug|id>", "Workspace (defaults to your default workspace)").option("--ceremony <slug|id>", "Only this ceremony").option("--project <id>", "A project's Meetings timeline (no workspace needed)").option("--per-ceremony <n>", "With --project: rows per recurring ceremony (1-20, default 5)").option("--from <date>", "Window start (YYYY-MM-DD or ISO)").option("--to <date>", "Window end (YYYY-MM-DD or ISO)").action(
3818
+ async (options, cmd) => {
3819
+ const globalOpts = cmd.optsWithGlobals();
3820
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3821
+ try {
3822
+ const client = getClient();
3823
+ if (options.project) {
3824
+ if (options.ceremony) throw new Error("Pass --project or --ceremony, not both.");
3825
+ const rows2 = await client.ceremonies.listOccurrencesForProject({
3826
+ projectId: options.project,
3827
+ from: parseDate(options.from),
3828
+ to: parseWindowEnd(options.to),
3829
+ perCeremony: parseIntInRange(options.perCeremony, "--per-ceremony", 1, 20)
3830
+ });
3831
+ if (useJson) {
3832
+ console.log(
3833
+ JSON.stringify(
3834
+ {
3835
+ occurrences: rows2.map((row) => ({ id: row.occurrenceId, ...row })),
3836
+ total: rows2.length,
3837
+ projectId: options.project
3838
+ },
3839
+ null,
3840
+ 2
3841
+ )
3842
+ );
3843
+ } else {
3844
+ outputProjectOccurrencesPretty(rows2);
3845
+ }
3846
+ return;
3847
+ }
3848
+ const ref = options.ceremony ? parseCeremonyRef(options.ceremony) : void 0;
3849
+ const workspaceId = await workspaceFor(client, ref ?? {}, options.workspace);
3850
+ const now = Date.now();
3851
+ const from = parseDate(options.from) ?? new Date(now - 14 * DAY_MS);
3852
+ const to = parseWindowEnd(options.to) ?? new Date(now + 14 * DAY_MS);
3853
+ const ceremonyId = ref ? await resolveCeremonyId(client, workspaceId, ref.ceremonyId ?? ref.id) : void 0;
3854
+ const rows = await client.ceremonies.listOccurrences({ workspaceId, from, to, ceremonyId });
3855
+ if (useJson) {
3856
+ outputOccurrencesJson(rows, {
3857
+ workspaceId,
3858
+ from,
3859
+ to,
3860
+ ceremonyId: ceremonyId ?? null,
3861
+ // The server returns at most 200, oldest first, so a full page has lost the newest rows.
3862
+ truncated: rows.length >= OCCURRENCE_LIST_CAP
3863
+ });
3864
+ } else outputOccurrencesPretty(rows);
3865
+ } catch (error) {
3866
+ handleError(error, useJson);
3867
+ }
3868
+ }
3869
+ );
3870
+ occurrences.command("get <occurrence>").description(
3871
+ "One occurrence: status, agenda, recordings, notes page. --notes and --decisions pull in the rest of the meeting page."
3872
+ ).option("--workspace <slug|id>", "Workspace (not needed when you pass the URL)").option("--notes", "Include the occurrence's notes page body").option("--decisions", "Include decisions and open questions logged against this occurrence").option("--updates", "Include participants' async updates (standups)").action(
3873
+ async (value, options, cmd) => {
3874
+ const globalOpts = cmd.optsWithGlobals();
3875
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3876
+ try {
3877
+ const client = getClient();
3878
+ const ref = parseOccurrenceRef(value);
3879
+ const workspaceId = await workspaceFor(client, ref, options.workspace);
3880
+ const occurrence = await client.ceremonies.getOccurrence(workspaceId, ref.id);
3881
+ const extrasErrors = {};
3882
+ const attempt = async (key, load) => {
3883
+ try {
3884
+ return await load();
3885
+ } catch (error) {
3886
+ extrasErrors[key] = error instanceof Error ? error.message : String(error);
3887
+ return null;
3888
+ }
3889
+ };
3890
+ const [notes, decisions, updates] = await Promise.all([
3891
+ options.notes ? attempt(
3892
+ "notes",
3893
+ async () => occurrence.notesPageId ? client.pages.get(occurrence.notesPageId) : null
3894
+ ) : void 0,
3895
+ // `decision.list` has no occurrence filter server-side, so this reads
3896
+ // the workspace's confirmed log and filters it here.
3897
+ options.decisions ? attempt(
3898
+ "decisions",
3899
+ async () => (await client.decisions.list({ workspaceId })).filter(
3900
+ (d) => d.occurrenceId === occurrence.id
3901
+ )
3902
+ ) : void 0,
3903
+ options.updates ? attempt("updates", () => client.ceremonies.updateSummary(workspaceId, occurrence.id)) : void 0
3904
+ ]);
3905
+ const extras = {
3906
+ ...options.notes ? { notes: notes ?? null } : {},
3907
+ ...options.decisions ? { decisions: decisions ?? null } : {},
3908
+ ...options.updates ? { updates: updates ?? null } : {},
3909
+ ...Object.keys(extrasErrors).length > 0 ? { extrasErrors } : {}
3910
+ };
3911
+ if (useJson) outputOccurrenceJson(occurrence, extras);
3912
+ else outputOccurrencePretty(occurrence, extras);
3913
+ } catch (error) {
3914
+ handleError(error, useJson);
3915
+ }
3916
+ }
3917
+ );
3918
+ occurrences.command("updates <occurrence>").description("Every participant's async update for an occurrence, and who hasn't answered").option("--workspace <slug|id>", "Workspace (not needed when you pass the URL)").action(async (value, options, cmd) => {
3919
+ const globalOpts = cmd.optsWithGlobals();
3920
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3921
+ try {
3922
+ const client = getClient();
3923
+ const ref = parseOccurrenceRef(value);
3924
+ const workspaceId = await workspaceFor(client, ref, options.workspace);
3925
+ const summary = await client.ceremonies.updateSummary(workspaceId, ref.id);
3926
+ if (useJson) console.log(JSON.stringify(summary, null, 2));
3927
+ else outputOccurrenceUpdatesPretty(summary);
3928
+ } catch (error) {
3929
+ handleError(error, useJson);
3930
+ }
3931
+ });
3932
+ occurrences.command("my-update <occurrence>").description(
3933
+ [
3934
+ "Read, draft or write your own async update (standups ask: done, today, blockers).",
3935
+ "No flags: show it. --draft: fill a draft from your activity since the last occurrence.",
3936
+ "--answer key=markdown (repeatable) saves answers; --submit / --reopen changes its state."
3937
+ ].join(" ")
3938
+ ).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(
3939
+ async (value, options, cmd) => {
3940
+ const globalOpts = cmd.optsWithGlobals();
3941
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3942
+ try {
3943
+ if (options.submit && options.reopen) {
3944
+ throw new Error("Pass --submit or --reopen, not both.");
3945
+ }
3946
+ if (options.draft && (options.submit || options.reopen)) {
3947
+ throw new Error("Run --draft on its own, review it, then --submit. To re-draft a submitted update, --reopen first.");
3948
+ }
3949
+ const supplied = parseSuppliedAnswers(options.answer, options.answersFile);
3950
+ const client = getClient();
3951
+ const ref = parseOccurrenceRef(value);
3952
+ const workspaceId = await workspaceFor(client, ref, options.workspace);
3953
+ const blockerSet = cmd.getOptionValueSource("blocker") === "cli";
3954
+ const writing = Object.keys(supplied).length > 0 || blockerSet || options.submit || options.reopen;
3955
+ const current = await client.ceremonies.myUpdate(workspaceId, ref.id);
3956
+ const known = current.questions.map((q) => q.key);
3957
+ const unknown = Object.keys(supplied).filter((key) => !known.includes(key));
3958
+ if (unknown.length > 0) {
3959
+ throw new Error(
3960
+ `Unknown answer key${unknown.length === 1 ? "" : "s"}: ${unknown.join(", ")}. ` + (known.length > 0 ? `This ceremony asks: ${known.join(", ")}.` : "This ceremony kind has no async updates.")
3961
+ );
3962
+ }
3963
+ let update = options.draft ? await client.ceremonies.draftMyUpdate(workspaceId, ref.id) : current;
3964
+ if (writing) {
3965
+ const answers = { ...update.answers, ...supplied };
3966
+ if (options.submit && !options.allowEmpty && !Object.values(answers).some((answer) => answer.trim() !== "")) {
3967
+ throw new Error(
3968
+ `Nothing to submit: every answer is empty. Pass --answer <key=markdown> (${known.join(", ")}), or --allow-empty.`
3969
+ );
3970
+ }
3971
+ update = await client.ceremonies.saveMyUpdate({
3972
+ workspaceId,
3973
+ occurrenceId: ref.id,
3974
+ answers,
3975
+ ...blockerSet ? { flaggedBlocker: options.blocker } : {},
3976
+ ...options.submit ? { submit: true } : options.reopen ? { submit: false } : {}
3977
+ });
3978
+ }
3979
+ if (useJson) console.log(JSON.stringify(update, null, 2));
3980
+ else outputMyOccurrenceUpdatePretty(update);
3981
+ } catch (error) {
3982
+ handleError(error, useJson);
3983
+ }
3984
+ }
3985
+ );
3986
+ occurrences.command("generate-agenda <occurrence>").description("Generate or regenerate the agenda (ceremony owner, or workspace owner/admin)").option("--workspace <slug|id>", "Workspace (not needed when you pass the URL)").option(
3987
+ "--circulate",
3988
+ "Also notify participants and post to the ceremony's Matrix room. Re-sends both if already sent, so don't retry blindly"
3989
+ ).action(
3990
+ async (value, options, cmd) => {
3991
+ const globalOpts = cmd.optsWithGlobals();
3992
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3993
+ try {
3994
+ const client = getClient();
3995
+ const ref = parseOccurrenceRef(value);
3996
+ const workspaceId = await workspaceFor(client, ref, options.workspace);
3997
+ const result = await client.ceremonies.generateAgenda(workspaceId, ref.id, {
3998
+ circulate: options.circulate
3999
+ });
4000
+ if (useJson) {
4001
+ console.log(JSON.stringify(result, null, 2));
4002
+ } else {
4003
+ console.log(
4004
+ `\u2713 Agenda generated: ${result.itemCount} item${result.itemCount === 1 ? "" : "s"}${result.circulated ? ", circulated" : ""}`
4005
+ );
4006
+ if (options.circulate && !result.circulated) {
4007
+ console.log(chalk4.yellow(" Not circulated: this occurrence is skipped."));
4008
+ }
4009
+ outputAgendaPretty(result.agenda);
4010
+ }
4011
+ } catch (error) {
4012
+ handleError(error, useJson);
4013
+ }
4014
+ }
4015
+ );
4016
+ occurrences.command("add").description("Add an occurrence off the cadence \u2014 a meeting that happened, or will, at another time (ceremony owner, or workspace owner/admin)").requiredOption("--ceremony <slug|id|url>", "The ceremony").requiredOption("--at <datetime>", "Start, e.g. 2026-11-04T10:00 (local) or 2026-11-04T09:00Z").option("--workspace <slug|id>", "Workspace (not needed when you pass the URL)").action(
4017
+ async (options, cmd) => {
4018
+ const globalOpts = cmd.optsWithGlobals();
4019
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4020
+ try {
4021
+ const at = parseDateTime(options.at, "--at");
4022
+ const client = getClient();
4023
+ const ref = parseCeremonyRef(options.ceremony);
4024
+ const workspaceId = await workspaceFor(client, ref, options.workspace);
4025
+ const ceremonyId = await resolveCeremonyId(client, workspaceId, ref.ceremonyId ?? ref.id);
4026
+ const result = await client.ceremonies.addOccurrence(workspaceId, ceremonyId, at);
4027
+ if (useJson) console.log(JSON.stringify(result, null, 2));
4028
+ else console.log(`\u2713 Occurrence ${result.id} added for ${new Date(result.scheduledStart).toLocaleString()}`);
4029
+ } catch (error) {
4030
+ handleError(error, useJson);
4031
+ }
4032
+ }
4033
+ );
4034
+ occurrences.command("move <occurrence>").description("Move an occurrence that has not happened to another time; it keeps its agenda, notes and updates (ceremony owner, or workspace owner/admin)").requiredOption("--to <datetime>", "New start, e.g. 2026-11-04T10:00 (local) or 2026-11-04T09:00Z").option("--workspace <slug|id>", "Workspace (not needed when you pass the URL)").action(async (value, options, cmd) => {
4035
+ const globalOpts = cmd.optsWithGlobals();
4036
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4037
+ try {
4038
+ const to = parseDateTime(options.to, "--to");
4039
+ const client = getClient();
4040
+ const ref = parseOccurrenceRef(value);
4041
+ const workspaceId = await workspaceFor(client, ref, options.workspace);
4042
+ const result = await client.ceremonies.rescheduleOccurrence(workspaceId, ref.id, to);
4043
+ if (useJson) console.log(JSON.stringify(result, null, 2));
4044
+ else if (!result.movedFrom) console.log(`Occurrence ${result.id} is already at that time.`);
4045
+ else {
4046
+ console.log(
4047
+ `\u2713 Occurrence ${result.id} moved from ${new Date(result.movedFrom).toLocaleString()} to ${new Date(result.scheduledStart).toLocaleString()}`
4048
+ );
4049
+ }
4050
+ } catch (error) {
4051
+ handleError(error, useJson);
4052
+ }
4053
+ });
4054
+ occurrences.command("skip <occurrence>").description(
4055
+ [
4056
+ "Skip an occurrence with a reason; participants are notified (ceremony owner, or workspace owner/admin).",
4057
+ "On a booked one-off this CANCELS the meeting: every attendee with an address, external ones included,",
4058
+ "gets a calendar cancellation, the ceremony is retired, and it cannot be unskipped."
4059
+ ].join(" ")
4060
+ ).requiredOption("--reason <text>", "Why it is skipped (1-500 chars)").option("--workspace <slug|id>", "Workspace (not needed when you pass the URL)").action(async (value, options, cmd) => {
4061
+ const globalOpts = cmd.optsWithGlobals();
4062
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4063
+ try {
4064
+ const client = getClient();
4065
+ const ref = parseOccurrenceRef(value);
4066
+ const workspaceId = await workspaceFor(client, ref, options.workspace);
4067
+ const result = await client.ceremonies.skipOccurrence(workspaceId, ref.id, options.reason);
4068
+ if (useJson) console.log(JSON.stringify(result, null, 2));
4069
+ else console.log(`\u2713 Occurrence ${result.id} skipped`);
4070
+ } catch (error) {
4071
+ handleError(error, useJson);
4072
+ }
4073
+ });
4074
+ occurrences.command("unskip <occurrence>").description("Undo a skip (ceremony owner, or workspace owner/admin). A cancelled one-off cannot be unskipped.").option("--workspace <slug|id>", "Workspace (not needed when you pass the URL)").action(async (value, options, cmd) => {
4075
+ const globalOpts = cmd.optsWithGlobals();
4076
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4077
+ try {
4078
+ const client = getClient();
4079
+ const ref = parseOccurrenceRef(value);
4080
+ const workspaceId = await workspaceFor(client, ref, options.workspace);
4081
+ const result = await client.ceremonies.unskipOccurrence(workspaceId, ref.id);
4082
+ if (useJson) console.log(JSON.stringify(result, null, 2));
4083
+ else console.log(`\u2713 Occurrence ${result.id} is back to ${result.status}`);
4084
+ } catch (error) {
4085
+ handleError(error, useJson);
4086
+ }
4087
+ });
4088
+ const agenda = new Command4("agenda").description("Edit an occurrence's agenda by hand");
4089
+ agenda.command("add <occurrence>").description("Add an item to an agenda section; kept across regeneration").requiredOption("--section <key>", "The section key (see `occurrences get`)").requiredOption("--title <text>", "Item title (max 300 chars)").option("--detail <text>", "One line of detail (max 500 chars)").option("--workspace <slug|id>", "Workspace (not needed when you pass the URL)").action(
4090
+ async (value, options, cmd) => {
4091
+ const globalOpts = cmd.optsWithGlobals();
4092
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4093
+ try {
4094
+ const client = getClient();
4095
+ const ref = parseOccurrenceRef(value);
4096
+ const workspaceId = await workspaceFor(client, ref, options.workspace);
4097
+ const result = await client.ceremonies.addAgendaItem({
4098
+ workspaceId,
4099
+ occurrenceId: ref.id,
4100
+ sectionKey: options.section,
4101
+ title: options.title,
4102
+ detail: options.detail
4103
+ });
4104
+ if (useJson) console.log(JSON.stringify(result, null, 2));
4105
+ else {
4106
+ console.log("\u2713 Agenda item added");
4107
+ outputAgendaPretty(result.agenda);
4108
+ }
4109
+ } catch (error) {
4110
+ handleError(error, useJson);
4111
+ }
4112
+ }
4113
+ );
4114
+ agenda.command("resolve <occurrence> <itemId>").description("Mark an agenda item resolved (--reopen to undo)").option("--reopen", "Mark it unresolved again").option("--workspace <slug|id>", "Workspace (not needed when you pass the URL)").action(
4115
+ async (value, itemId, options, cmd) => {
4116
+ const globalOpts = cmd.optsWithGlobals();
4117
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4118
+ try {
4119
+ const client = getClient();
4120
+ const ref = parseOccurrenceRef(value);
4121
+ const workspaceId = await workspaceFor(client, ref, options.workspace);
4122
+ const result = await client.ceremonies.resolveAgendaItem(
4123
+ workspaceId,
4124
+ ref.id,
4125
+ itemId,
4126
+ !options.reopen
4127
+ );
4128
+ if (useJson) console.log(JSON.stringify(result, null, 2));
4129
+ else console.log(options.reopen ? "\u2713 Agenda item reopened" : "\u2713 Agenda item resolved");
4130
+ } catch (error) {
4131
+ handleError(error, useJson);
4132
+ }
4133
+ }
4134
+ );
4135
+ occurrences.addCommand(agenda);
4136
+ occurrences.command("attach <occurrence>").description("Link a recorded meeting to the occurrence it captured (same workspace; you must be able to edit the meeting)").requiredOption("--meeting <id>", "Recorded meeting (transcription session) id").action(async (value, options, cmd) => {
4137
+ const globalOpts = cmd.optsWithGlobals();
4138
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4139
+ try {
4140
+ const client = getClient();
4141
+ const ref = parseOccurrenceRef(value);
4142
+ const result = await client.ceremonies.attachMeeting(options.meeting, ref.id);
4143
+ if (useJson) console.log(JSON.stringify(result, null, 2));
4144
+ else console.log(`\u2713 Meeting ${result.meetingId} attached to occurrence ${result.occurrenceId}`);
4145
+ } catch (error) {
4146
+ handleError(error, useJson);
4147
+ }
4148
+ });
4149
+ occurrences.command("detach <meetingId>").description("Unlink a recorded meeting from its occurrence").action(async (meetingId, _options, cmd) => {
4150
+ const globalOpts = cmd.optsWithGlobals();
4151
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4152
+ try {
4153
+ const client = getClient();
4154
+ const result = await client.ceremonies.detachMeeting(meetingId);
4155
+ if (useJson) console.log(JSON.stringify(result, null, 2));
4156
+ else console.log(`\u2713 Meeting ${result.meetingId} detached`);
4157
+ } catch (error) {
4158
+ handleError(error, useJson);
4159
+ }
4160
+ });
4161
+ return occurrences;
4162
+ }
4163
+ function createCeremoniesCommand() {
4164
+ const ceremonies = new Command4("ceremonies").description(
4165
+ [
4166
+ "Recurring meeting definitions (Settings \u2192 Ceremonies) and their scheduled occurrences.",
4167
+ "",
4168
+ "A ceremony has a cadence (RRULE in a time zone), an owner, participants and an agenda template.",
4169
+ "Each scheduled instance is an occurrence \u2014 see `ceremonies occurrences --help`.",
4170
+ "Decisions logged in an occurrence live under `exponential decisions` (--occurrence).",
4171
+ "",
4172
+ "Some writes reach people or delete data. Read `<command> --help` first: update, occurrences skip,",
4173
+ "occurrences generate-agenda --circulate, import and backfill."
4174
+ ].join("\n")
4175
+ );
4176
+ ceremonies.command("list").description("Ceremonies in a workspace, active first").option("--workspace <slug|id>", "Workspace (defaults to your default workspace)").option("--include-inactive", "Also list retired ceremonies").action(async (options, cmd) => {
4177
+ const globalOpts = cmd.optsWithGlobals();
4178
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4179
+ try {
4180
+ const client = getClient();
4181
+ const workspaceId = await resolveWorkspaceId(client, options.workspace);
4182
+ const rows = await client.ceremonies.list(workspaceId, {
4183
+ includeInactive: options.includeInactive
4184
+ });
4185
+ if (useJson) outputCeremoniesJson(rows, { workspaceId });
4186
+ else outputCeremoniesPretty(rows);
4187
+ } catch (error) {
4188
+ handleError(error, useJson);
4189
+ }
4190
+ });
4191
+ ceremonies.command("get <ceremony>").description("One ceremony with participants, projects and its recent + upcoming occurrences. Takes an id, slug or URL.").option("--workspace <slug|id>", "Workspace (not needed when you pass the URL)").action(async (value, options, cmd) => {
4192
+ const globalOpts = cmd.optsWithGlobals();
4193
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4194
+ try {
4195
+ const client = getClient();
4196
+ const ref = parseCeremonyRef(value);
4197
+ const workspaceId = await workspaceFor(client, ref, options.workspace);
4198
+ const id = await resolveCeremonyId(client, workspaceId, ref.ceremonyId ?? ref.id);
4199
+ const ceremony = await client.ceremonies.get(workspaceId, id);
4200
+ if (useJson) outputCeremonyJson(ceremony);
4201
+ else outputCeremonyPretty(ceremony);
4202
+ } catch (error) {
4203
+ handleError(error, useJson);
4204
+ }
4205
+ });
4206
+ ceremonies.command("templates").description('Built-in ceremony templates, one per kind (the "Add from template" list)').action(async (_options, cmd) => {
4207
+ const globalOpts = cmd.optsWithGlobals();
4208
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4209
+ try {
4210
+ const templates = await getClient().ceremonies.templates();
4211
+ if (useJson) console.log(JSON.stringify({ templates, total: templates.length }, null, 2));
4212
+ else outputCeremonyTemplatesPretty(templates);
4213
+ } catch (error) {
4214
+ handleError(error, useJson);
4215
+ }
4216
+ });
4217
+ const create = addDefinitionOptions(
4218
+ ceremonies.command("create").description(
4219
+ "Create a ceremony and schedule its first occurrences. Needs --name, --cadence, --timezone and --starts-on."
4220
+ ).option("--workspace <slug|id>", "Workspace (defaults to your default workspace)").option("--template <slug>", "Start from a built-in template (see `ceremonies templates`); flags override it")
4221
+ );
4222
+ create.action(
4223
+ async (options, cmd) => {
4224
+ const globalOpts = cmd.optsWithGlobals();
4225
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4226
+ try {
4227
+ const client = getClient();
4228
+ const workspaceId = await resolveWorkspaceId(client, options.workspace);
4229
+ let base = {};
4230
+ if (options.template) {
4231
+ const templates = await client.ceremonies.templates();
4232
+ const t = templates.find((x) => x.slug === options.template);
4233
+ if (!t) {
4234
+ throw new Error(
4235
+ `No template "${options.template}". One of: ${templates.map((x) => x.slug).join(", ")}`
4236
+ );
4237
+ }
4238
+ const { slug: _slug, ...fields } = t;
4239
+ base = fields;
4240
+ }
4241
+ const input = { ...base, ...definitionFields(options, cmd), workspaceId };
4242
+ const missing = ["name", "cadenceRule", "timezone", "startsOn"].filter(
4243
+ (k) => input[k] === void 0
4244
+ );
4245
+ if (missing.length > 0) {
4246
+ const flags = {
4247
+ name: "--name",
4248
+ cadenceRule: "--cadence",
4249
+ timezone: "--timezone",
4250
+ startsOn: "--starts-on"
4251
+ };
4252
+ throw new Error(`Missing ${missing.map((k) => flags[k]).join(", ")}.`);
4253
+ }
4254
+ const result = await client.ceremonies.create(input);
4255
+ if (useJson) console.log(JSON.stringify(result, null, 2));
4256
+ else outputCeremonyWritePretty(result, "created");
4257
+ } catch (error) {
4258
+ handleError(error, useJson);
4259
+ }
4260
+ }
4261
+ );
4262
+ const update = addDefinitionOptions(
4263
+ ceremonies.command("update <ceremony>").description(
4264
+ [
4265
+ "Edit a ceremony (id, slug or URL). Only the flags you pass change.",
4266
+ "Changing --cadence, --timezone, --starts-on or --duration DELETES future PLANNED occurrences that have no",
4267
+ "booking or recording, along with any agenda, notes link and async updates on them, and recreates them with",
4268
+ "new ids. Occurrences moved or added by hand stay."
4269
+ ].join(" ")
4270
+ ).option("--workspace <slug|id>", "Workspace (not needed when you pass the URL)").option("--active", "Re-activate a retired ceremony").option("--inactive", "Retire the ceremony (stops scheduling)")
4271
+ );
4272
+ update.action(
4273
+ async (value, options, cmd) => {
4274
+ const globalOpts = cmd.optsWithGlobals();
4275
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4276
+ try {
4277
+ if (options.active && options.inactive) throw new Error("Pass --active or --inactive, not both.");
4278
+ const client = getClient();
4279
+ const ref = parseCeremonyRef(value);
4280
+ const workspaceId = await workspaceFor(client, ref, options.workspace);
4281
+ const id = await resolveCeremonyId(client, workspaceId, ref.ceremonyId ?? ref.id);
4282
+ const input = {
4283
+ ...definitionFields(options, cmd),
4284
+ workspaceId,
4285
+ id,
4286
+ ...options.active ? { isActive: true } : options.inactive ? { isActive: false } : {}
4287
+ };
4288
+ if (Object.keys(input).length === 2) {
4289
+ throw new Error("Nothing to update \u2014 pass at least one field flag.");
4290
+ }
4291
+ const result = await client.ceremonies.update(input);
4292
+ if (useJson) console.log(JSON.stringify(result, null, 2));
4293
+ else outputCeremonyWritePretty(result, "updated");
4294
+ } catch (error) {
4295
+ handleError(error, useJson);
4296
+ }
4297
+ }
4298
+ );
4299
+ ceremonies.command("import <file>").description(
4300
+ [
4301
+ 'Upsert ceremonies from a JSON array keyed by slug ("-" = stdin). Workspace owner/admin only.',
4302
+ "People go by name or email: participantNames REPLACES the whole set, and a name that matches nobody is dropped",
4303
+ "and reported as unresolved. Not atomic: a failure partway leaves the earlier definitions written."
4304
+ ].join(" ")
4305
+ ).option("--workspace <slug|id>", "Workspace (defaults to your default workspace)").option("--timezone <iana>", "Default zone for definitions without one").option("--starts-on <date>", "Default anchor date for definitions without one").action(
4306
+ async (file, options, cmd) => {
4307
+ const globalOpts = cmd.optsWithGlobals();
4308
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4309
+ try {
4310
+ const raw = readText(void 0, file);
4311
+ const parsed = JSON.parse(raw ?? "");
4312
+ if (!Array.isArray(parsed)) throw new Error("The import file must hold a JSON array of definitions.");
4313
+ const client = getClient();
4314
+ const workspaceId = await resolveWorkspaceId(client, options.workspace);
4315
+ const results = await client.ceremonies.importDefinitions({
4316
+ workspaceId,
4317
+ definitions: parsed,
4318
+ timezone: options.timezone,
4319
+ startsOn: parseCalendarDate(options.startsOn)
4320
+ });
4321
+ if (useJson) {
4322
+ console.log(JSON.stringify({ results, total: results.length }, null, 2));
4323
+ } else {
4324
+ for (const r of results) {
4325
+ console.log(
4326
+ `\u2713 ${r.slug} ${r.action} (${r.occurrencesCreated} occurrence${r.occurrencesCreated === 1 ? "" : "s"} scheduled)`
4327
+ );
4328
+ if (r.unresolved.length > 0) {
4329
+ console.log(chalk4.yellow(` Unresolved people: ${r.unresolved.join(", ")}`));
4330
+ }
4331
+ }
4332
+ }
4333
+ } catch (error) {
4334
+ handleError(error, useJson);
4335
+ }
4336
+ }
4337
+ );
4338
+ ceremonies.command("backfill").description(
4339
+ "Attach unattached recorded meetings to occurrences by alias. Dry run unless --apply, but even a dry run schedules any missing occurrences of active ceremonies. Workspace owner/admin only."
4340
+ ).option("--workspace <slug|id>", "Workspace (defaults to your default workspace)").option("--apply", "Write the attachments (default is a dry-run report)").action(async (options, cmd) => {
4341
+ const globalOpts = cmd.optsWithGlobals();
4342
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4343
+ try {
4344
+ const client = getClient();
4345
+ const workspaceId = await resolveWorkspaceId(client, options.workspace);
4346
+ const result = await client.ceremonies.backfillAttachments(workspaceId, {
4347
+ dryRun: !options.apply
4348
+ });
4349
+ if (useJson) {
4350
+ console.log(JSON.stringify(result, null, 2));
4351
+ } else {
4352
+ console.log(
4353
+ chalk4.bold(
4354
+ `
4355
+ ${result.dryRun ? "Dry run" : "Applied"}: ${result.matched} of ${result.scanned} meetings matched`
4356
+ )
4357
+ );
4358
+ if (result.occurrencesCreated > 0) {
4359
+ console.log(chalk4.gray(` Scheduled ${result.occurrencesCreated} missing occurrences (this happens even on a dry run).`));
4360
+ }
4361
+ for (const row of result.rows) {
4362
+ const target = row.occurrenceId ? chalk4.green(`\u2192 ${row.ceremonyName} ${row.scheduledStart ? new Date(row.scheduledStart).toLocaleString() : ""}`) : chalk4.gray(`\u2014 ${row.reason}`);
4363
+ console.log(` ${row.title ?? row.meetingId} ${target}`);
4364
+ }
4365
+ if (result.dryRun && result.matched > 0) {
4366
+ console.log(chalk4.gray("\nRe-run with --apply to write these attachments."));
4367
+ }
4368
+ }
4369
+ } catch (error) {
4370
+ handleError(error, useJson);
4371
+ }
4372
+ });
4373
+ ceremonies.command("match-url <url>").description(
4374
+ "Which ceremony meets in this video room, and the occurrence on now (or --at). Searches all your workspaces unless --workspace."
4375
+ ).option("--at <datetime>", "Match the occurrence on at this time instead of now").option("--workspace <slug|id>", "Only look in this workspace").action(async (url, options, cmd) => {
4376
+ const globalOpts = cmd.optsWithGlobals();
4377
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4378
+ try {
4379
+ const client = getClient();
4380
+ const workspaceId = options.workspace ? await resolveWorkspaceId(client, options.workspace) : void 0;
4381
+ const match = await client.ceremonies.matchMeetingUrl({
4382
+ url,
4383
+ at: options.at ? parseDateTime(options.at, "--at") : void 0,
4384
+ workspaceId
4385
+ });
4386
+ if (useJson) {
4387
+ console.log(JSON.stringify({ match }, null, 2));
4388
+ } else if (!match) {
4389
+ console.log(chalk4.gray("No ceremony meets in this room (or several do and none is on now)."));
4390
+ } else {
4391
+ console.log(`${chalk4.bold(match.ceremony.name)} ${chalk4.gray(`in ${match.workspace.name} \xB7 ${match.ceremony.id}`)}`);
4392
+ if (match.project) console.log(` ${chalk4.gray("Project:")} ${match.project.name}`);
4393
+ console.log(
4394
+ match.occurrence ? ` ${chalk4.gray("Occurrence:")} ${new Date(match.occurrence.scheduledStart).toLocaleString()} ${chalk4.gray(match.occurrence.id)}` : chalk4.gray(" No occurrence on at that time.")
4395
+ );
4396
+ }
4397
+ } catch (error) {
4398
+ handleError(error, useJson);
4399
+ }
4400
+ });
4401
+ ceremonies.addCommand(createOccurrencesCommand());
4402
+ return ceremonies;
4403
+ }
4404
+
4405
+ // src/commands/databases.ts
4406
+ import { Command as Command5 } from "commander";
4407
+ import chalk5 from "chalk";
4408
+ var ADDABLE_TYPES = [
4409
+ "text",
4410
+ "number",
4411
+ "select",
4412
+ "multiSelect",
4413
+ "date",
4414
+ "checkbox",
4415
+ "url",
4416
+ "person",
4417
+ "createdTime",
4418
+ "lastEditedTime",
4419
+ "createdBy"
4420
+ ];
4421
+ function collect2(value, previous) {
4422
+ return [...previous, value];
4423
+ }
4424
+ function parseLimit(value) {
4425
+ if (value === void 0) return void 0;
4426
+ const n = Number(value);
4427
+ if (!Number.isInteger(n) || n < 1) {
4428
+ throw new Error(`--limit must be a positive integer, got "${value}"`);
4429
+ }
4430
+ return n;
4431
+ }
4432
+ function parseSet(pairs, cleared = []) {
4433
+ const values = {};
4434
+ for (const pair of pairs) {
4435
+ const at = pair.indexOf("=");
4436
+ if (at <= 0) {
4437
+ throw new Error(`--set expects Property=value, got "${pair}"`);
4438
+ }
4439
+ const key = pair.slice(0, at).trim();
4440
+ const raw = pair.slice(at + 1);
4441
+ values[key] = raw === "" ? null : raw;
4442
+ }
4443
+ for (const key of cleared) values[key.trim()] = null;
4444
+ return values;
4445
+ }
4446
+ function parseCsvMapping(database, flags) {
4447
+ const mapping = {};
4448
+ const split = (pair, flag) => {
4449
+ const at = pair.indexOf("=");
4450
+ if (at <= 0) throw new Error(`${flag} expects Column=value, got "${pair}"`);
4451
+ return [pair.slice(0, at).trim(), pair.slice(at + 1).trim()];
4452
+ };
4453
+ for (const pair of flags.map) {
4454
+ const [column, property] = split(pair, "--map");
4455
+ mapping[column] = { kind: "property", propertyId: resolveProperty(database, property).id };
4456
+ }
4457
+ for (const pair of flags.new) {
4458
+ const [column, spec] = split(pair, "--new");
4459
+ const colon = spec.indexOf(":");
4460
+ const name = colon > 0 ? spec.slice(0, colon).trim() : column;
4461
+ const type = colon > 0 ? spec.slice(colon + 1).trim() : spec;
4462
+ mapping[column] = { kind: "new", name, type: parsePropertyType(type) };
4463
+ }
4464
+ for (const column of flags.skip) mapping[column.trim()] = { kind: "skip" };
4465
+ return mapping;
4466
+ }
4467
+ function parsePropertyType(value) {
4468
+ if (ADDABLE_TYPES.includes(value)) return value;
4469
+ throw new Error(`--type must be one of: ${ADDABLE_TYPES.join(", ")} (got "${value}")`);
4470
+ }
4471
+ function parseOptions(value) {
4472
+ if (value === void 0) return void 0;
4473
+ return value.split(",").map((part) => part.trim()).filter(Boolean).map((part) => {
4474
+ const at = part.lastIndexOf(":");
4475
+ if (at > 0) {
4476
+ return { name: part.slice(0, at).trim(), color: part.slice(at + 1).trim() };
4477
+ }
4478
+ return { name: part };
4479
+ });
4480
+ }
4481
+ function parseFilter(expression) {
4482
+ const match = /^\s*(.+?)\s*(!=|>=|<=|=|~|>|<| in )\s*(.*)$/.exec(expression);
4483
+ if (!match) throw new Error(`--filter expects Property=value (or !=, ~, >, <, in), got "${expression}"`);
4484
+ const [, property, operator, value] = match;
4485
+ switch (operator.trim()) {
4486
+ case "=":
4487
+ return value === "" ? { property, op: "isEmpty" } : { property, op: "eq", value };
4488
+ case "!=":
4489
+ return value === "" ? { property, op: "isNotEmpty" } : { property, op: "neq", value };
4490
+ case "~":
4491
+ return { property, op: "contains", value };
4492
+ case ">":
4493
+ return { property, op: "gt", value };
4494
+ case "<":
4495
+ return { property, op: "lt", value };
4496
+ case ">=":
4497
+ case "<=":
4498
+ throw new Error(`--filter does not support "${operator.trim()}" (only > and <), got "${expression}"`);
4499
+ case "in":
4500
+ return { property, op: "anyOf", value: value.split(",").map((s) => s.trim()).filter(Boolean) };
4501
+ default:
4502
+ throw new Error(`Unknown filter operator "${operator}"`);
4503
+ }
4504
+ }
4505
+ function parseSort(value) {
4506
+ if (value === void 0) return void 0;
4507
+ const at = value.lastIndexOf(":");
4508
+ const property = at > 0 ? value.slice(0, at).trim() : value.trim();
4509
+ const direction = at > 0 ? value.slice(at + 1).trim().toLowerCase() : "asc";
4510
+ if (direction !== "asc" && direction !== "desc") {
4511
+ throw new Error(`--sort expects Property or Property:asc|desc, got "${value}"`);
4512
+ }
4513
+ return { property, direction };
4514
+ }
4515
+ function resolveProperty(database, key) {
4516
+ const byId = database.properties.find((p) => p.id === key);
4517
+ if (byId) return byId;
4518
+ const wanted = key.trim().toLowerCase();
4519
+ const byName = database.properties.filter((p) => p.name.trim().toLowerCase() === wanted);
4520
+ if (byName.length === 1) return byName[0];
4521
+ throw new Error(
4522
+ `No property "${key}" on ${database.name}. Properties: ${database.properties.map((p) => p.name).join(", ")}`
4523
+ );
4524
+ }
4525
+ function buildListView(database, filters, sort) {
4526
+ if (filters.length === 0 && sort === void 0) return void 0;
4527
+ const parsedSort = parseSort(sort);
4528
+ return {
4529
+ ...database.view,
4530
+ sort: parsedSort ? { propertyId: resolveProperty(database, parsedSort.property).id, direction: parsedSort.direction } : database.view.sort,
4531
+ filters: filters.length === 0 ? database.view.filters : filters.map((expression) => {
4532
+ const { property, op, value } = parseFilter(expression);
4533
+ return { propertyId: resolveProperty(database, property).id, op, ...value !== void 0 ? { value } : {} };
4534
+ })
4535
+ };
4536
+ }
4537
+ function createDatabasesCommand() {
4538
+ const databases = new Command5("databases").description(
4539
+ 'Databases: typed tables inside pages. A database is a block in a page body, owned by that page; each row is a page of its own (read it with "pages get <rowId>"). Writes are typed per property \u2014 a bad value is refused naming the property. Not a work tracker: use tickets, actions and projects for work.'
4540
+ );
4541
+ databases.command("create").description(
4542
+ "Create a database on a page (with a title property) and place its block at the end of the page body. --no-place leaves the body alone and prints the marker to put in yourself."
4543
+ ).requiredOption("--page <id>", "The page that will hold the database (you need edit access)").requiredOption("--name <name>", "Database name, e.g. Metrics").option("--no-place", "Do not append the marker to the page body").option("-n, --note <text>", "Why: recorded on the page revision that places the block").action(
4544
+ async (options, cmd) => {
4545
+ const globalOpts = cmd.optsWithGlobals();
4546
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4547
+ try {
4548
+ const client = getClient();
4549
+ const database = await client.databases.create({ pageId: options.page, name: options.name });
4550
+ let placed = false;
4551
+ if (options.place && database.marker) {
4552
+ const page = await client.pages.get(options.page);
4553
+ const body = page.body?.trimEnd();
4554
+ await client.pages.update({
4555
+ id: options.page,
4556
+ body: body ? `${body}
4557
+
4558
+ ${database.marker}` : database.marker,
4559
+ baseVersion: page.docVersion,
4560
+ note: options.note ?? `Add the ${database.name} database`
4561
+ });
4562
+ placed = true;
4563
+ }
4564
+ if (useJson) outputDatabaseJson({ ...database, placed });
4565
+ else {
4566
+ console.log(`
4567
+ \u2713 Database created${placed ? ` and placed in "${database.page.title}"` : ""}`);
4568
+ outputDatabasePretty(database);
4569
+ if (!placed && database.marker) {
4570
+ console.log(chalk5.gray(` Put this line in the page body to show it: ${database.marker}
4571
+ `));
4572
+ }
4573
+ }
4574
+ } catch (error) {
4575
+ handleError(error, useJson);
4576
+ }
4577
+ }
4578
+ );
4579
+ databases.command("get <id>").description("One database: its properties, saved view, row count and holding page").action(async (id, _options, cmd) => {
4580
+ const globalOpts = cmd.optsWithGlobals();
4581
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4582
+ try {
4583
+ const database = await getClient().databases.get(id);
4584
+ if (useJson) outputDatabaseJson(database);
4585
+ else outputDatabasePretty(database);
4586
+ } catch (error) {
4587
+ handleError(error, useJson);
4588
+ }
4589
+ });
4590
+ databases.command("list").description("The databases a page holds, detached ones included (a detached database's block is out of the body; its rows wait 30 days for the purge)").requiredOption("--page <id>", "Page CUID").action(async (options, cmd) => {
4591
+ const globalOpts = cmd.optsWithGlobals();
4592
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4593
+ try {
4594
+ const list = await getClient().databases.list(options.page);
4595
+ if (useJson) console.log(JSON.stringify(list, null, 2));
4596
+ else outputDatabasesPretty(list);
4597
+ } catch (error) {
4598
+ handleError(error, useJson);
4599
+ }
4600
+ });
4601
+ databases.command("update").description("Rename a database, or replace its saved view whole (JSON: { sort?, filters, hiddenPropertyIds, propertyOrder })").requiredOption("--id <id>", "Database CUID").option("--name <name>", "New name").option("--view <json>", "The whole view as JSON").option("--view-file <path>", 'Read the view JSON from a file ("-" = stdin)').action(
4602
+ async (options, cmd) => {
4603
+ const globalOpts = cmd.optsWithGlobals();
4604
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4605
+ try {
4606
+ const viewText = readText(options.view, options.viewFile);
4607
+ const view = viewText === void 0 ? void 0 : JSON.parse(viewText);
4608
+ const database = await getClient().databases.update({ id: options.id, name: options.name, view });
4609
+ if (useJson) outputDatabaseJson(database);
4610
+ else {
4611
+ console.log("\n\u2713 Database updated");
4612
+ outputDatabasePretty(database);
4613
+ }
4614
+ } catch (error) {
4615
+ handleError(error, useJson);
4616
+ }
4617
+ }
4618
+ );
4619
+ databases.command("delete <id>").description("Delete a database and every row with it. Removing the block from the page only detaches; this is the delete.").requiredOption("--yes", "Confirm: the rows are pages and they go too").action(async (id, _options, cmd) => {
4620
+ const globalOpts = cmd.optsWithGlobals();
4621
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4622
+ try {
4623
+ const result = await getClient().databases.delete(id);
4624
+ if (useJson) console.log(JSON.stringify(result, null, 2));
4625
+ else console.log(`
4626
+ \u2713 Database ${result.id} deleted with ${result.rowCount} row${result.rowCount === 1 ? "" : "s"}
4627
+ `);
4628
+ } catch (error) {
4629
+ handleError(error, useJson);
4630
+ }
4631
+ });
4632
+ databases.addCommand(createPropertiesCommand());
4633
+ databases.addCommand(createRowsCommand());
4634
+ return databases;
4635
+ }
4636
+ function createPropertiesCommand() {
4637
+ const properties = new Command5("properties").description(
4638
+ "The schema: add, rename, retype, re-option, remove or reorder properties. Ids are stable \u2014 renaming never rewrites a row. A property is named by id or by name."
4639
+ );
4640
+ properties.command("add <databaseId>").description(`Add a property. Types: ${ADDABLE_TYPES.join(", ")} (title exists from creation; relation arrives with V3).`).requiredOption("--name <name>", "Property name").requiredOption("--type <type>", "Property type").option("--options <list>", 'select/multiSelect options, comma-separated; "Name:color" picks a palette colour').option("--description <text>", "What the property means").action(
4641
+ async (databaseId, options, cmd) => {
4642
+ const globalOpts = cmd.optsWithGlobals();
4643
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4644
+ try {
4645
+ const result = await getClient().databases.addProperty({
4646
+ id: databaseId,
4647
+ name: options.name,
4648
+ type: parsePropertyType(options.type),
4649
+ description: options.description,
4650
+ options: parseOptions(options.options)
4651
+ });
4652
+ if (useJson) console.log(JSON.stringify(result, null, 2));
4653
+ else {
4654
+ console.log(`
4655
+ \u2713 Property "${result.property.name}" (${result.property.type}) added \u2014 id ${result.property.id}`);
4656
+ outputDatabasePretty(result.database);
4657
+ }
4658
+ } catch (error) {
4659
+ handleError(error, useJson);
4660
+ }
4661
+ }
4662
+ );
4663
+ properties.command("update <databaseId> <property>").description('Rename, retype, re-option or describe a property. --options replaces the whole list; "id=Name" keeps an existing option under a new name.').option("--name <name>", "New name").option("--type <type>", "New type (not for the title property)").option("--options <list>", 'The full option list, comma-separated; prefix "optionId=" to keep an existing option').option("--description <text>", "New description").option("--clear-description", "Remove the description").action(
4664
+ async (databaseId, property, options, cmd) => {
4665
+ const globalOpts = cmd.optsWithGlobals();
4666
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4667
+ try {
4668
+ const parsedOptions = parseOptions(options.options)?.map((option) => {
4669
+ const at = option.name.indexOf("=");
4670
+ return at > 0 ? { ...option, id: option.name.slice(0, at).trim(), name: option.name.slice(at + 1).trim() } : option;
4671
+ });
4672
+ const result = await getClient().databases.updateProperty({
4673
+ id: databaseId,
4674
+ propertyId: property,
4675
+ name: options.name,
4676
+ type: options.type === void 0 ? void 0 : parsePropertyType(options.type),
4677
+ description: options.clearDescription ? null : options.description,
4678
+ options: parsedOptions
4679
+ });
4680
+ if (useJson) console.log(JSON.stringify(result, null, 2));
4681
+ else {
4682
+ console.log(`
4683
+ \u2713 Property "${result.property.name}" updated`);
4684
+ outputDatabasePretty(result.database);
4685
+ }
4686
+ } catch (error) {
4687
+ handleError(error, useJson);
4688
+ }
3050
4689
  }
3051
- });
3052
- contacts.command("get").description("Get a contact by ID").argument("<id>", "Contact ID").option("--interactions", "Include interaction history").action(async (id, options, cmd) => {
4690
+ );
4691
+ properties.command("remove <databaseId> <property>").description("Remove a property from the schema and the view. Row values under it stay until each row is next written. The title property cannot be removed.").action(async (databaseId, property, _options, cmd) => {
3053
4692
  const globalOpts = cmd.optsWithGlobals();
3054
4693
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3055
4694
  try {
3056
- const client = getClient();
3057
- const contact = await client.contacts.get(id, {
3058
- includeInteractions: options.interactions
3059
- });
3060
- if (useJson) {
3061
- outputContactJson(contact);
3062
- } else {
3063
- outputContactPretty(contact);
4695
+ const database = await getClient().databases.removeProperty(databaseId, property);
4696
+ if (useJson) outputDatabaseJson(database);
4697
+ else {
4698
+ console.log("\n\u2713 Property removed");
4699
+ outputDatabasePretty(database);
3064
4700
  }
3065
4701
  } catch (error) {
3066
4702
  handleError(error, useJson);
3067
4703
  }
3068
4704
  });
3069
- contacts.command("create").description("Create a new contact").requiredOption("--workspace <id>", "Workspace ID").option("--first-name <name>", "First name").option("--last-name <name>", "Last name").option("--email <email>", "Email address").option("--phone <phone>", "Phone number").option("--linkedin <url>", "LinkedIn URL").option("--telegram <handle>", "Telegram handle").option("--twitter <handle>", "Twitter/X handle").option("--github <handle>", "GitHub username").option("--bluesky <handle>", "Bluesky handle").option("--about <text>", "About / bio").option("--profile-type <type>", "Profile type").option("--skills <skills>", "Skills (comma-separated)").option("--tags <tags>", "Tags (comma-separated)").option("--organization <id>", "Organization ID").option("--organization-name <name>", "Organization name (find-or-create; ignored if --organization is set)").action(async (options, cmd) => {
4705
+ properties.command("reorder <databaseId> <propertyIds...>").description("Set the column order. List every property id exactly once (space- or comma-separated).").action(async (databaseId, propertyIds, _options, cmd) => {
3070
4706
  const globalOpts = cmd.optsWithGlobals();
3071
4707
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3072
4708
  try {
3073
- const client = getClient();
3074
- const contact = await client.contacts.create({
3075
- workspaceId: options.workspace,
3076
- firstName: options.firstName,
3077
- lastName: options.lastName,
3078
- email: options.email,
3079
- phone: options.phone,
3080
- linkedIn: options.linkedin,
3081
- telegram: options.telegram,
3082
- twitter: options.twitter,
3083
- github: options.github,
3084
- bluesky: options.bluesky,
3085
- about: options.about,
3086
- profileType: options.profileType,
3087
- skills: options.skills?.split(",").map((s) => s.trim()),
3088
- tags: options.tags?.split(",").map((t) => t.trim()),
3089
- organizationId: options.organization,
3090
- organizationName: options.organizationName
3091
- });
3092
- if (useJson) {
3093
- outputContactJson(contact);
3094
- } else {
3095
- console.log("\n\u2713 Contact created successfully");
3096
- outputContactPretty(contact);
4709
+ const ids = propertyIds.flatMap((part) => part.split(",")).map((s) => s.trim()).filter(Boolean);
4710
+ const database = await getClient().databases.reorderProperties(databaseId, ids);
4711
+ if (useJson) outputDatabaseJson(database);
4712
+ else {
4713
+ console.log("\n\u2713 Properties reordered");
4714
+ outputDatabasePretty(database);
3097
4715
  }
3098
4716
  } catch (error) {
3099
4717
  handleError(error, useJson);
3100
4718
  }
3101
4719
  });
3102
- contacts.command("update").description("Update an existing contact").requiredOption("--id <id>", "Contact ID").option("--first-name <name>", "First name").option("--last-name <name>", "Last name").option("--email <email>", 'Email (use "null" to clear)').option("--phone <phone>", 'Phone (use "null" to clear)').option("--linkedin <url>", 'LinkedIn URL (use "null" to clear)').option("--telegram <handle>", 'Telegram handle (use "null" to clear)').option("--twitter <handle>", 'Twitter/X handle (use "null" to clear)').option("--github <handle>", 'GitHub username (use "null" to clear)').option("--bluesky <handle>", 'Bluesky handle (use "null" to clear)').option("--about <text>", "About / bio").option("--profile-type <type>", "Profile type").option("--skills <skills>", "Skills (comma-separated)").option("--tags <tags>", "Tags (comma-separated)").option("--organization <id>", 'Organization ID (use "null" to clear)').option("--organization-name <name>", "Organization name (find-or-create; ignored if --organization is set)").action(async (options, cmd) => {
3103
- const globalOpts = cmd.optsWithGlobals();
3104
- const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3105
- const nullable = (v) => v === "null" ? null : v;
3106
- try {
3107
- const client = getClient();
3108
- const contact = await client.contacts.update({
3109
- id: options.id,
3110
- firstName: options.firstName,
3111
- lastName: options.lastName,
3112
- email: nullable(options.email),
3113
- phone: nullable(options.phone),
3114
- linkedIn: nullable(options.linkedin),
3115
- telegram: nullable(options.telegram),
3116
- twitter: nullable(options.twitter),
3117
- github: nullable(options.github),
3118
- bluesky: nullable(options.bluesky),
3119
- about: options.about,
3120
- profileType: options.profileType,
3121
- skills: options.skills?.split(",").map((s) => s.trim()),
3122
- tags: options.tags?.split(",").map((t) => t.trim()),
3123
- organizationId: nullable(options.organization),
3124
- organizationName: options.organizationName
3125
- });
3126
- if (useJson) {
3127
- outputContactJson(contact);
3128
- } else {
3129
- console.log("\n\u2713 Contact updated successfully");
3130
- outputContactPretty(contact);
4720
+ return properties;
4721
+ }
4722
+ function createRowsCommand() {
4723
+ const rows = new Command5("rows").description(
4724
+ `Rows: each is a page of the database. Write values with repeatable --set Property=value; read a row's body and history with "pages get <rowId>" / "pages history <rowId>".`
4725
+ );
4726
+ rows.command("list <databaseId>").description(
4727
+ 'Rows through the saved view, or with your own --filter/--sort: "Status=Tracked", "Score>5", "Owner!=", "Name~latency", "Status in Tracked,Instrumenting".'
4728
+ ).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(
4729
+ async (databaseId, options, cmd) => {
4730
+ const globalOpts = cmd.optsWithGlobals();
4731
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4732
+ try {
4733
+ const client = getClient();
4734
+ const database = await client.databases.get(databaseId);
4735
+ const page = await client.databases.listRows(databaseId, {
4736
+ view: buildListView(database, options.filter, options.sort),
4737
+ limit: parseLimit(options.limit),
4738
+ cursor: options.cursor
4739
+ });
4740
+ if (useJson) console.log(JSON.stringify(page, null, 2));
4741
+ else outputRowsPretty(page, database);
4742
+ } catch (error) {
4743
+ handleError(error, useJson);
3131
4744
  }
3132
- } catch (error) {
3133
- handleError(error, useJson);
3134
4745
  }
3135
- });
3136
- contacts.command("delete").description("Delete a contact").argument("<id>", "Contact ID").action(async (id, _options, cmd) => {
4746
+ );
4747
+ rows.command("add <databaseId>").description(
4748
+ '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).'
4749
+ ).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) => {
3137
4750
  const globalOpts = cmd.optsWithGlobals();
3138
4751
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3139
4752
  try {
3140
4753
  const client = getClient();
3141
- await client.contacts.delete(id);
3142
- if (useJson) {
3143
- console.log(JSON.stringify({ deleted: true, id }, null, 2));
3144
- } else {
3145
- console.log(`
3146
- \u2713 Contact ${id} deleted`);
4754
+ const row = await client.databases.createRow(databaseId, parseSet(options.set), { note: options.note });
4755
+ if (useJson) outputRowJson(row);
4756
+ else {
4757
+ console.log("\n\u2713 Row added");
4758
+ outputRowPretty(row, await client.databases.get(databaseId));
3147
4759
  }
3148
4760
  } catch (error) {
3149
4761
  handleError(error, useJson);
3150
4762
  }
3151
4763
  });
3152
- contacts.command("add-interaction").description("Add an interaction to a contact").requiredOption("--contact <id>", "Contact ID").requiredOption("--type <type>", `Interaction type (${VALID_INTERACTION_TYPES.join(", ")})`).requiredOption("--direction <dir>", `Direction (${VALID_INTERACTION_DIRECTIONS.join(", ")})`).option("--subject <text>", "Subject line").option("--notes <text>", "Notes").action(async (options, cmd) => {
3153
- const globalOpts = cmd.optsWithGlobals();
3154
- const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3155
- try {
3156
- if (!VALID_INTERACTION_TYPES.includes(options.type)) {
3157
- throw new Error(`Invalid interaction type "${options.type}". Valid: ${VALID_INTERACTION_TYPES.join(", ")}`);
3158
- }
3159
- if (!VALID_INTERACTION_DIRECTIONS.includes(options.direction)) {
3160
- throw new Error(`Invalid direction "${options.direction}". Valid: ${VALID_INTERACTION_DIRECTIONS.join(", ")}`);
4764
+ rows.command("import <databaseId>").description(
4765
+ '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.'
4766
+ ).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(
4767
+ async (databaseId, options, cmd) => {
4768
+ const globalOpts = cmd.optsWithGlobals();
4769
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4770
+ try {
4771
+ const csv = readText(void 0, options.csv);
4772
+ if (!csv?.trim()) throw new Error("The CSV is empty");
4773
+ const client = getClient();
4774
+ const database = await client.databases.get(databaseId);
4775
+ const overrides = parseCsvMapping(database, options);
4776
+ const suggested = await client.databases.previewCsv(databaseId, csv);
4777
+ const mapping = { ...suggested.mapping, ...overrides };
4778
+ const preview = Object.keys(overrides).length > 0 ? await client.databases.previewCsv(databaseId, csv, mapping) : suggested;
4779
+ if (options.dryRun) {
4780
+ if (useJson) console.log(JSON.stringify(preview, null, 2));
4781
+ else outputCsvPreviewPretty(preview);
4782
+ return;
4783
+ }
4784
+ const result = await client.databases.commitCsv(databaseId, csv, mapping, { note: options.note });
4785
+ if (useJson) console.log(JSON.stringify(result, null, 2));
4786
+ else {
4787
+ console.log(`
4788
+ \u2713 Imported ${result.created.length} of ${result.total} row${result.total === 1 ? "" : "s"}`);
4789
+ for (const p of result.properties) console.log(` + property ${p.name} (${p.type})`);
4790
+ outputCsvSkipped(result.skipped);
4791
+ }
4792
+ } catch (error) {
4793
+ handleError(error, useJson);
3161
4794
  }
3162
- const client = getClient();
3163
- const interaction = await client.contacts.addInteraction({
3164
- contactId: options.contact,
3165
- type: options.type,
3166
- direction: options.direction,
3167
- subject: options.subject,
3168
- notes: options.notes
3169
- });
3170
- if (useJson) {
3171
- outputInteractionJson(interaction);
3172
- } else {
3173
- console.log("\n\u2713 Interaction added");
3174
- outputInteractionPretty(interaction);
4795
+ }
4796
+ );
4797
+ 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(
4798
+ async (rowId, options, cmd) => {
4799
+ const globalOpts = cmd.optsWithGlobals();
4800
+ const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
4801
+ try {
4802
+ const values = parseSet(options.set, options.clear);
4803
+ if (Object.keys(values).length === 0) {
4804
+ throw new Error("Nothing to write: pass at least one --set Property=value or --clear Property");
4805
+ }
4806
+ const client = getClient();
4807
+ const row = await client.databases.updateRow(rowId, values, { note: options.note });
4808
+ if (useJson) outputRowJson(row);
4809
+ else {
4810
+ console.log("\n\u2713 Row updated");
4811
+ outputRowPretty(row, row.databaseId ? await client.databases.get(row.databaseId) : void 0);
4812
+ }
4813
+ } catch (error) {
4814
+ handleError(error, useJson);
3175
4815
  }
3176
- } catch (error) {
3177
- handleError(error, useJson);
3178
4816
  }
3179
- });
3180
- contacts.command("enrich").description("Queue a web-search enrichment job for an existing contact (runs regardless of the workspace auto-enrich setting)").argument("<id>", "Contact ID").action(async (id, _options, cmd) => {
4817
+ );
4818
+ rows.command("delete <rowId>").description("Delete a row (the page and its search chunks)").requiredOption("--yes", "Confirm").action(async (rowId, _options, cmd) => {
3181
4819
  const globalOpts = cmd.optsWithGlobals();
3182
4820
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3183
4821
  try {
3184
- const client = getClient();
3185
- const result = await client.contacts.enrich(id);
3186
- if (useJson) {
3187
- console.log(JSON.stringify(result, null, 2));
3188
- } else if (result.enqueued) {
3189
- console.log(`
3190
- \u2713 Enrichment queued for contact ${id} (job ${result.enrichmentId})`);
3191
- } else if (result.reason === "already-in-flight") {
3192
- console.log(`
3193
- \u2022 Enrichment already in progress for contact ${id} (job ${result.enrichmentId})`);
3194
- } else {
3195
- console.log(`
3196
- \u2022 Not queued for contact ${id}${result.reason ? ` (${result.reason})` : ""}`);
3197
- }
4822
+ const result = await getClient().databases.deleteRow(rowId);
4823
+ if (useJson) console.log(JSON.stringify(result, null, 2));
4824
+ else console.log(`
4825
+ \u2713 Row ${result.id} deleted
4826
+ `);
3198
4827
  } catch (error) {
3199
4828
  handleError(error, useJson);
3200
4829
  }
3201
4830
  });
3202
- return contacts;
3203
- }
3204
-
3205
- // src/commands/decisions.ts
3206
- import { Command as Command4 } from "commander";
3207
- import chalk4 from "chalk";
3208
-
3209
- // src/utils/input.ts
3210
- import { readFileSync } from "fs";
3211
- var stdinConsumed = false;
3212
- function readText(inline, file) {
3213
- if (inline !== void 0) return inline;
3214
- if (file === void 0) return void 0;
3215
- if (file === "-") {
3216
- if (stdinConsumed) {
3217
- throw new Error('stdin ("-") can only back one option per invocation.');
3218
- }
3219
- stdinConsumed = true;
3220
- return readFileSync(0, "utf-8");
3221
- }
3222
- return readFileSync(file, "utf-8");
3223
- }
3224
- function parseDate(value) {
3225
- if (value === void 0 || value === "") return void 0;
3226
- const date = /^\d{4}-\d{2}-\d{2}$/.test(value) ? /* @__PURE__ */ new Date(`${value}T00:00:00`) : new Date(value);
3227
- if (Number.isNaN(date.getTime())) {
3228
- throw new Error(
3229
- `Invalid date: "${value}". Use ISO format, e.g. 2026-08-25 or 2026-08-25T14:00.`
3230
- );
3231
- }
3232
- return date;
4831
+ return rows;
3233
4832
  }
3234
4833
 
3235
4834
  // src/commands/decisions.ts
4835
+ import { Command as Command6 } from "commander";
4836
+ import chalk6 from "chalk";
3236
4837
  var STATUSES = [
3237
4838
  "OPEN",
3238
4839
  "PROPOSED",
@@ -3480,7 +5081,7 @@ function addConfirmCommand(parent) {
3480
5081
  );
3481
5082
  }
3482
5083
  function createDecisionsCommand() {
3483
- const decisions = new Command4("decisions").description(
5084
+ const decisions = new Command6("decisions").description(
3484
5085
  [
3485
5086
  "Log and manage decisions and open questions (the workspace Decision Log).",
3486
5087
  "",
@@ -3506,11 +5107,15 @@ function createDecisionsCommand() {
3506
5107
  "Filter by source (repeatable): MEETING, MANUAL, AGENT",
3507
5108
  (value, previous) => [...previous, parseSource(value)],
3508
5109
  []
3509
- ).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").action(
5110
+ ).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(
3510
5111
  async (options, cmd) => {
3511
5112
  const globalOpts = cmd.optsWithGlobals();
3512
5113
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
3513
5114
  try {
5115
+ if (options.meeting && options.occurrence) {
5116
+ throw new Error("Pass --meeting or --occurrence, not both.");
5117
+ }
5118
+ const occurrence = options.occurrence ? parseOccurrenceRef(options.occurrence) : void 0;
3514
5119
  const client = getClient();
3515
5120
  if (options.meeting) {
3516
5121
  const result = await client.decisions.listForMeeting(options.meeting);
@@ -3531,7 +5136,7 @@ function createDecisionsCommand() {
3531
5136
  outputDecisionsPretty(rows2);
3532
5137
  if (!result.canLogDecision) {
3533
5138
  console.log(
3534
- chalk4.yellow(
5139
+ chalk6.yellow(
3535
5140
  "You cannot log decisions on this meeting (no edit access, or it has no workspace)."
3536
5141
  )
3537
5142
  );
@@ -3539,8 +5144,9 @@ function createDecisionsCommand() {
3539
5144
  }
3540
5145
  return;
3541
5146
  }
3542
- const workspaceId = await resolveWorkspaceId(client, options.workspace);
3543
- const rows = options.adr ? await client.decisions.listForAdr(workspaceId, options.adr) : await client.decisions.list({
5147
+ const workspaceId = await resolveWorkspaceId(client, occurrence?.workspaceSlug ?? options.workspace);
5148
+ const limit = parsePositiveInt(options.limit, "--limit");
5149
+ const all = options.adr ? await client.decisions.listForAdr(workspaceId, options.adr) : await client.decisions.list({
3544
5150
  workspaceId,
3545
5151
  statuses: options.status.length > 0 ? options.status : void 0,
3546
5152
  sources: options.source.length > 0 ? options.source : void 0,
@@ -3549,10 +5155,16 @@ function createDecisionsCommand() {
3549
5155
  projectId: options.project,
3550
5156
  search: options.search,
3551
5157
  number: parsePositiveInt(options.number, "--number"),
3552
- limit: parsePositiveInt(options.limit, "--limit")
5158
+ // With --occurrence the cap applies after filtering, below.
5159
+ limit: occurrence ? void 0 : limit
3553
5160
  });
3554
- if (useJson) outputDecisionsJson(rows, { workspaceId });
3555
- else outputDecisionsPretty(rows);
5161
+ const rows = occurrence ? all.filter((d) => d.occurrenceId === occurrence.id).slice(0, limit) : all;
5162
+ if (useJson) {
5163
+ outputDecisionsJson(
5164
+ rows,
5165
+ occurrence ? { workspaceId, occurrenceId: occurrence.id } : { workspaceId }
5166
+ );
5167
+ } else outputDecisionsPretty(rows);
3556
5168
  } catch (error) {
3557
5169
  handleError(error, useJson);
3558
5170
  }
@@ -3731,7 +5343,7 @@ function createDecisionsCommand() {
3731
5343
  \u2713 ${decision.status === "OPEN" ? "Open question" : "Decision"} logged`
3732
5344
  );
3733
5345
  outputDecisionPretty(decision);
3734
- if (featureLink) console.log(chalk4.gray(` Linked to feature ${options.feature}`));
5346
+ if (featureLink) console.log(chalk6.gray(` Linked to feature ${options.feature}`));
3735
5347
  }
3736
5348
  } catch (error) {
3737
5349
  handleError(error, useJson);
@@ -3840,9 +5452,9 @@ function createDecisionsCommand() {
3840
5452
  const link = options.ticket ? await client.decisions.linkTicket(workspaceId, decisionId, options.ticket) : await client.decisions.linkFeature(workspaceId, decisionId, options.feature);
3841
5453
  if (useJson) console.log(JSON.stringify(link, null, 2));
3842
5454
  else {
3843
- console.log(`\u2713 Linked ${chalk4.gray(`(link id ${link.id})`)}`);
5455
+ console.log(`\u2713 Linked ${chalk6.gray(`(link id ${link.id})`)}`);
3844
5456
  console.log(
3845
- chalk4.gray(" Remove it with: exponential decisions unlink --link " + link.id)
5457
+ chalk6.gray(" Remove it with: exponential decisions unlink --link " + link.id)
3846
5458
  );
3847
5459
  }
3848
5460
  } catch (error) {
@@ -3865,7 +5477,7 @@ function createDecisionsCommand() {
3865
5477
  handleError(error, useJson);
3866
5478
  }
3867
5479
  });
3868
- const drafts = new Command4("draft").description(
5480
+ const drafts = new Command6("draft").description(
3869
5481
  "Review decisions an agent proposed but nobody has confirmed yet (visible only on their source meeting)"
3870
5482
  );
3871
5483
  drafts.command("extract").description(
@@ -3880,22 +5492,22 @@ function createDecisionsCommand() {
3880
5492
  else {
3881
5493
  if (result.alreadyPublished) {
3882
5494
  console.log(
3883
- chalk4.gray("This meeting already has confirmed decisions \u2014 nothing was extracted.")
5495
+ chalk6.gray("This meeting already has confirmed decisions \u2014 nothing was extracted.")
3884
5496
  );
3885
5497
  } else if (result.alreadyDrafted) {
3886
- console.log(chalk4.gray("Returning the drafts this meeting already had."));
5498
+ console.log(chalk6.gray("Returning the drafts this meeting already had."));
3887
5499
  }
3888
5500
  console.log(
3889
5501
  `\u2713 ${result.draftCount} draft${result.draftCount === 1 ? "" : "s"} awaiting review (${result.draftsCreated} new)`
3890
5502
  );
3891
5503
  if (result.discardedWithoutEvidence > 0) {
3892
5504
  console.log(
3893
- chalk4.gray(
5505
+ chalk6.gray(
3894
5506
  ` ${result.discardedWithoutEvidence} candidate(s) dropped \u2014 no transcript turn supported them.`
3895
5507
  )
3896
5508
  );
3897
5509
  }
3898
- for (const message of result.errors) console.log(chalk4.yellow(` ${message}`));
5510
+ for (const message of result.errors) console.log(chalk6.yellow(` ${message}`));
3899
5511
  }
3900
5512
  } catch (error) {
3901
5513
  handleError(error, useJson);
@@ -3952,9 +5564,9 @@ function createDecisionsCommand() {
3952
5564
  }
3953
5565
 
3954
5566
  // src/commands/deals.ts
3955
- import { Command as Command5 } from "commander";
5567
+ import { Command as Command7 } from "commander";
3956
5568
  function createDealsCommand() {
3957
- const deals = new Command5("deals").description("Manage pipeline deals");
5569
+ const deals = new Command7("deals").description("Manage pipeline deals");
3958
5570
  deals.command("pipeline").description("Get pipeline overview with stages").requiredOption("--workspace <id>", "Workspace ID").action(async (options, cmd) => {
3959
5571
  const globalOpts = cmd.optsWithGlobals();
3960
5572
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -4139,7 +5751,7 @@ function createDealsCommand() {
4139
5751
  }
4140
5752
 
4141
5753
  // src/commands/epics.ts
4142
- import { Command as Command6 } from "commander";
5754
+ import { Command as Command8 } from "commander";
4143
5755
  var EPIC_STATUSES = ["OPEN", "IN_PROGRESS", "DONE", "CANCELLED"];
4144
5756
  var EPIC_PRIORITIES = ["HIGH", "MEDIUM", "LOW", "NONE"];
4145
5757
  function validateEpicStatus(value) {
@@ -4167,7 +5779,7 @@ function parseDate2(value) {
4167
5779
  return d;
4168
5780
  }
4169
5781
  function createEpicsCommand() {
4170
- const epics = new Command6("epics").description(
5782
+ const epics = new Command8("epics").description(
4171
5783
  "Manage epics. Epics are workspace-scoped and group actions and tickets across products."
4172
5784
  );
4173
5785
  epics.command("list").description("List epics in a workspace").option("--workspace <slug|id>", "Workspace slug or CUID").option("--status <status>", `Filter by status: ${EPIC_STATUSES.join(", ")}`).action(
@@ -4284,10 +5896,10 @@ function createEpicsCommand() {
4284
5896
  }
4285
5897
 
4286
5898
  // src/commands/features.ts
4287
- import { Command as Command12 } from "commander";
5899
+ import { Command as Command14 } from "commander";
4288
5900
 
4289
5901
  // src/commands/stories.ts
4290
- import { Command as Command7 } from "commander";
5902
+ import { Command as Command9 } from "commander";
4291
5903
  async function readStdin() {
4292
5904
  const chunks = [];
4293
5905
  for await (const chunk of process.stdin) {
@@ -4296,7 +5908,7 @@ async function readStdin() {
4296
5908
  return Buffer.concat(chunks).toString("utf-8");
4297
5909
  }
4298
5910
  function createStoriesCommand() {
4299
- const stories = new Command7("stories").description(
5911
+ const stories = new Command9("stories").description(
4300
5912
  "Manage a feature's native, structured user stories (As a / I want / So that)."
4301
5913
  );
4302
5914
  stories.command("add").description(
@@ -4430,7 +6042,7 @@ function createStoriesCommand() {
4430
6042
  }
4431
6043
 
4432
6044
  // src/commands/scopes.ts
4433
- import { Command as Command8 } from "commander";
6045
+ import { Command as Command10 } from "commander";
4434
6046
  var SCOPE_STATUSES = [
4435
6047
  "PLANNED",
4436
6048
  "IN_PROGRESS",
@@ -4447,7 +6059,7 @@ function validateScopeStatus(value) {
4447
6059
  return value;
4448
6060
  }
4449
6061
  function createScopesCommand() {
4450
- const scopes = new Command8("scopes").description(
6062
+ const scopes = new Command10("scopes").description(
4451
6063
  `Manage a feature's scopes: shippable increments ("V1", "V2"), each with its own lifecycle.`
4452
6064
  );
4453
6065
  scopes.command("list").description("List a feature's scopes").requiredOption("--feature <id>", "Feature CUID").action(
@@ -4526,7 +6138,7 @@ function createScopesCommand() {
4526
6138
  }
4527
6139
 
4528
6140
  // src/commands/requirements.ts
4529
- import { Command as Command9 } from "commander";
6141
+ import { Command as Command11 } from "commander";
4530
6142
  var REQUIREMENT_KINDS = [
4531
6143
  "FUNCTIONAL",
4532
6144
  "NON_FUNCTIONAL",
@@ -4549,7 +6161,7 @@ async function readStdin2() {
4549
6161
  return Buffer.concat(chunks).toString("utf-8");
4550
6162
  }
4551
6163
  function createRequirementsCommand() {
4552
- const requirements = new Command9("requirements").description(
6164
+ const requirements = new Command11("requirements").description(
4553
6165
  `Manage a feature's requirements: atomic, testable EARS-style "shall" statements, checkable met/unmet.`
4554
6166
  );
4555
6167
  requirements.command("add").description(
@@ -4680,25 +6292,25 @@ function createRequirementsCommand() {
4680
6292
  }
4681
6293
 
4682
6294
  // src/commands/areas.ts
4683
- import { Command as Command10 } from "commander";
4684
- import chalk5 from "chalk";
6295
+ import { Command as Command12 } from "commander";
6296
+ import chalk7 from "chalk";
4685
6297
  function outputAreasPretty(areas) {
4686
6298
  if (areas.length === 0) {
4687
- console.log(chalk5.gray("No areas found."));
6299
+ console.log(chalk7.gray("No areas found."));
4688
6300
  return;
4689
6301
  }
4690
- console.log(chalk5.bold(`
6302
+ console.log(chalk7.bold(`
4691
6303
  Areas (${areas.length} total)`));
4692
- console.log(chalk5.gray("\u2500".repeat(50)));
6304
+ console.log(chalk7.gray("\u2500".repeat(50)));
4693
6305
  for (const a of areas) {
4694
- const count = a._count?.features != null ? chalk5.gray(` (${a._count.features} features)`) : "";
4695
- console.log(` ${chalk5.bold(a.name)}${count}`);
4696
- console.log(chalk5.gray(` ID: ${a.id}`));
6306
+ const count = a._count?.features != null ? chalk7.gray(` (${a._count.features} features)`) : "";
6307
+ console.log(` ${chalk7.bold(a.name)}${count}`);
6308
+ console.log(chalk7.gray(` ID: ${a.id}`));
4697
6309
  }
4698
6310
  console.log();
4699
6311
  }
4700
6312
  function createAreasCommand() {
4701
- const areas = new Command10("areas").description(
6313
+ const areas = new Command12("areas").description(
4702
6314
  "Manage a product's areas: the buckets features are filed under (a feature has exactly one or none)."
4703
6315
  );
4704
6316
  areas.command("list").description("List a product's areas").requiredOption("--product <slug|id>", "Product slug or CUID").option("--workspace <slug|id>", "Workspace (required when --product is a slug)").action(
@@ -4742,7 +6354,7 @@ function createAreasCommand() {
4742
6354
  }
4743
6355
 
4744
6356
  // src/commands/featureComments.ts
4745
- import { Command as Command11 } from "commander";
6357
+ import { Command as Command13 } from "commander";
4746
6358
 
4747
6359
  // src/utils/mentions.ts
4748
6360
  function candidateLabels(member) {
@@ -4815,7 +6427,7 @@ function collectMention(value, previous) {
4815
6427
 
4816
6428
  // src/commands/featureComments.ts
4817
6429
  function createFeatureCommentsCommand() {
4818
- const comment = new Command11("comment").description(
6430
+ const comment = new Command13("comment").description(
4819
6431
  "Read and post comments on a feature. Mention teammates with --mention."
4820
6432
  );
4821
6433
  comment.command("list").description("List comments on a feature").requiredOption("--feature <id>", "Feature ID").action(async (options, cmd) => {
@@ -5016,7 +6628,7 @@ function validateFeatureStatus(value) {
5016
6628
  return value;
5017
6629
  }
5018
6630
  function createFeaturesCommand() {
5019
- const features = new Command12("features").description(
6631
+ const features = new Command14("features").description(
5020
6632
  "Manage features. A feature lives under a product and groups user stories, scopes, and tickets."
5021
6633
  );
5022
6634
  features.command("list").description("List features in a product").requiredOption("--product <slug|id>", "Product slug or CUID").option("--workspace <slug|id>", "Workspace (required when --product is a slug)").option("--status <status>", `Filter by status: ${FEATURE_STATUSES.join(", ")}`).action(
@@ -5273,8 +6885,8 @@ Aborted: ${reason}. Feature "${feature.name}" was NOT deleted.`);
5273
6885
  }
5274
6886
 
5275
6887
  // src/commands/labels.ts
5276
- import { Command as Command13 } from "commander";
5277
- import chalk6 from "chalk";
6888
+ import { Command as Command15 } from "commander";
6889
+ import chalk8 from "chalk";
5278
6890
  var TRIAGE_LABELS = [
5279
6891
  { slug: "needs-triage", name: "needs-triage", color: "avatar-orange" },
5280
6892
  { slug: "needs-info", name: "needs-info", color: "avatar-yellow" },
@@ -5288,22 +6900,22 @@ function looksLikeCuid(value) {
5288
6900
  }
5289
6901
  function outputTagsPretty(tags) {
5290
6902
  if (tags.length === 0) {
5291
- console.log(chalk6.dim("No labels found."));
6903
+ console.log(chalk8.dim("No labels found."));
5292
6904
  return;
5293
6905
  }
5294
6906
  console.log();
5295
6907
  for (const tag of tags) {
5296
- const scope = tag.workspaceId === null ? chalk6.cyan("global") : chalk6.magenta("workspace");
5297
- const category = tag.category === null ? chalk6.dim("(label)") : chalk6.dim(`(${tag.category})`);
6908
+ const scope = tag.workspaceId === null ? chalk8.cyan("global") : chalk8.magenta("workspace");
6909
+ const category = tag.category === null ? chalk8.dim("(label)") : chalk8.dim(`(${tag.category})`);
5298
6910
  console.log(
5299
- ` ${chalk6.bold(tag.slug)} ${tag.name} ${chalk6.gray(tag.color)} ${scope} ${category}`
6911
+ ` ${chalk8.bold(tag.slug)} ${tag.name} ${chalk8.gray(tag.color)} ${scope} ${category}`
5300
6912
  );
5301
6913
  }
5302
6914
  console.log();
5303
6915
  }
5304
6916
  function outputTagPretty(tag, prefix) {
5305
6917
  if (prefix) console.log(prefix);
5306
- console.log(` ${chalk6.bold(tag.slug)} ${tag.name} ${chalk6.gray(tag.color)}`);
6918
+ console.log(` ${chalk8.bold(tag.slug)} ${tag.name} ${chalk8.gray(tag.color)}`);
5307
6919
  }
5308
6920
  async function resolveLabelIds(client, workspaceId, values) {
5309
6921
  if (values.length === 0) return [];
@@ -5327,7 +6939,7 @@ async function resolveLabelIds(client, workspaceId, values) {
5327
6939
  return [...byId, ...resolvedFromSlugs];
5328
6940
  }
5329
6941
  function createLabelsCommand() {
5330
- const labels = new Command13("labels").description(
6942
+ const labels = new Command15("labels").description(
5331
6943
  "Manage labels (orthogonal tags applied to actions, tickets, features, and epics)."
5332
6944
  );
5333
6945
  labels.command("list").description("List labels visible in a workspace").option("--workspace <slug|id>", "Workspace slug or CUID").option(
@@ -5375,7 +6987,7 @@ function createLabelsCommand() {
5375
6987
  if (useJson) {
5376
6988
  console.log(JSON.stringify(tag, null, 2));
5377
6989
  } else {
5378
- outputTagPretty(tag, chalk6.green("\n\u2713 Label created"));
6990
+ outputTagPretty(tag, chalk8.green("\n\u2713 Label created"));
5379
6991
  }
5380
6992
  } catch (error) {
5381
6993
  handleError(error, useJson);
@@ -5413,10 +7025,10 @@ function createLabelsCommand() {
5413
7025
  console.log(JSON.stringify(results, null, 2));
5414
7026
  } else {
5415
7027
  console.log();
5416
- console.log(chalk6.bold("Triage labels:"));
7028
+ console.log(chalk8.bold("Triage labels:"));
5417
7029
  for (const r of results) {
5418
- const tag = chalk6.bold(r.slug);
5419
- const status = r.status === "created" ? chalk6.green("created") : chalk6.dim("existed");
7030
+ const tag = chalk8.bold(r.slug);
7031
+ const status = r.status === "created" ? chalk8.green("created") : chalk8.dim("existed");
5420
7032
  console.log(` ${tag} ${status}`);
5421
7033
  }
5422
7034
  console.log();
@@ -5430,10 +7042,10 @@ function createLabelsCommand() {
5430
7042
  }
5431
7043
 
5432
7044
  // src/commands/meetings.ts
5433
- import { Command as Command14 } from "commander";
5434
- import chalk7 from "chalk";
7045
+ import { Command as Command16 } from "commander";
7046
+ import chalk9 from "chalk";
5435
7047
  function createMeetingsCommand() {
5436
- const meetings = new Command14("meetings").description(
7048
+ const meetings = new Command16("meetings").description(
5437
7049
  "Manage meetings and their notes (recorded, imported, or manually created)"
5438
7050
  );
5439
7051
  meetings.command("list").description(
@@ -5594,7 +7206,7 @@ function createMeetingsCommand() {
5594
7206
  console.log(`\u2713 Deleted ${count} of ${ids.length} meeting${ids.length === 1 ? "" : "s"}`);
5595
7207
  if (skipped > 0) {
5596
7208
  console.log(
5597
- chalk7.yellow(
7209
+ chalk9.yellow(
5598
7210
  `${skipped} id(s) were skipped \u2014 not found, or not owned by you.`
5599
7211
  )
5600
7212
  );
@@ -5605,7 +7217,7 @@ function createMeetingsCommand() {
5605
7217
  }
5606
7218
  }
5607
7219
  );
5608
- const notes = new Command14("notes").description(
7220
+ const notes = new Command16("notes").description(
5609
7221
  "Read and write a meeting's notes"
5610
7222
  );
5611
7223
  notes.command("get <id>").description(
@@ -5621,7 +7233,7 @@ function createMeetingsCommand() {
5621
7233
  process.stdout.write(body.endsWith("\n") ? body : `${body}
5622
7234
  `);
5623
7235
  } else if (process.stdout.isTTY) {
5624
- console.log(chalk7.gray("No notes yet."));
7236
+ console.log(chalk9.gray("No notes yet."));
5625
7237
  }
5626
7238
  } catch (error) {
5627
7239
  handleError(error, shouldUseJson(globalOpts.json, globalOpts.pretty));
@@ -5670,7 +7282,7 @@ function createMeetingsCommand() {
5670
7282
  }
5671
7283
 
5672
7284
  // src/commands/organizations.ts
5673
- import { Command as Command15 } from "commander";
7285
+ import { Command as Command17 } from "commander";
5674
7286
  var VALID_SIZES = [
5675
7287
  "1-10",
5676
7288
  "11-50",
@@ -5680,7 +7292,7 @@ var VALID_SIZES = [
5680
7292
  "1000+"
5681
7293
  ];
5682
7294
  function createOrganizationsCommand() {
5683
- const organizations = new Command15("organizations").alias("orgs").description("Manage CRM organizations");
7295
+ const organizations = new Command17("organizations").alias("orgs").description("Manage CRM organizations");
5684
7296
  organizations.command("list").description("List organizations").requiredOption("--workspace <id>", "Workspace ID").option("--search <query>", "Search by name or description").option("--industry <industry>", "Filter by industry").option("--limit <n>", "Max results to return", parseInt).option("--cursor <cursor>", "Pagination cursor").action(async (options, cmd) => {
5685
7297
  const globalOpts = cmd.optsWithGlobals();
5686
7298
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -5748,13 +7360,13 @@ function createOrganizationsCommand() {
5748
7360
  }
5749
7361
 
5750
7362
  // src/commands/pages.ts
5751
- import { Command as Command17 } from "commander";
5752
- import chalk8 from "chalk";
7363
+ import { Command as Command19 } from "commander";
7364
+ import chalk10 from "chalk";
5753
7365
 
5754
7366
  // src/commands/pageComments.ts
5755
- import { Command as Command16 } from "commander";
7367
+ import { Command as Command18 } from "commander";
5756
7368
  function createPageCommentsCommand() {
5757
- const comment = new Command16("comment").description(
7369
+ const comment = new Command18("comment").description(
5758
7370
  "Read and post comments on a page. Mention teammates with --mention."
5759
7371
  );
5760
7372
  comment.command("list").description("List comments on a page").requiredOption("--page <id>", "Page ID").action(async (options, cmd) => {
@@ -5848,7 +7460,7 @@ function createPageCommentsCommand() {
5848
7460
  }
5849
7461
 
5850
7462
  // src/commands/pages.ts
5851
- function parseLimit(value) {
7463
+ function parseLimit2(value) {
5852
7464
  if (value === void 0) return void 0;
5853
7465
  const n = Number(value);
5854
7466
  if (!Number.isInteger(n) || n < 1) {
@@ -5857,7 +7469,7 @@ function parseLimit(value) {
5857
7469
  return n;
5858
7470
  }
5859
7471
  function createPagesCommand() {
5860
- const pages = new Command17("pages").description(
7472
+ const pages = new Command19("pages").description(
5861
7473
  `Manage Knowledge pages (PRDs, research, technical specs). Reads are Markdown-only by default; every write is recorded in the page's history. Link one to a feature with "features link-page".`
5862
7474
  );
5863
7475
  pages.command("list").description("List pages in a workspace (metadata only, no bodies)").option("--workspace <slug|id>", "Workspace (defaults to the configured default)").option(
@@ -5894,7 +7506,7 @@ function createPagesCommand() {
5894
7506
  workspaceId,
5895
7507
  query,
5896
7508
  projectId: options.project,
5897
- limit: parseLimit(options.limit)
7509
+ limit: parseLimit2(options.limit)
5898
7510
  });
5899
7511
  if (useJson) console.log(JSON.stringify(result, null, 2));
5900
7512
  else outputPageSearchPretty(result);
@@ -5987,7 +7599,7 @@ function createPagesCommand() {
5987
7599
  try {
5988
7600
  const client = getClient();
5989
7601
  const history = await client.pages.history(id, {
5990
- limit: parseLimit(options.limit),
7602
+ limit: parseLimit2(options.limit),
5991
7603
  cursor: options.cursor
5992
7604
  });
5993
7605
  if (useJson) console.log(JSON.stringify(history, null, 2));
@@ -6006,13 +7618,13 @@ function createPagesCommand() {
6006
7618
  const revision = await client.pages.revision(id, revisionId);
6007
7619
  if (useJson) console.log(JSON.stringify(revision, null, 2));
6008
7620
  else {
6009
- console.log(chalk8.gray("\u2500".repeat(50)));
7621
+ console.log(chalk10.gray("\u2500".repeat(50)));
6010
7622
  console.log(
6011
7623
  `
6012
- ${chalk8.bold(revision.title)} ${chalk8.gray(`v${revision.docVersion} \xB7 ${revision.kind}`)}`
7624
+ ${chalk10.bold(revision.title)} ${chalk10.gray(`v${revision.docVersion} \xB7 ${revision.kind}`)}`
6013
7625
  );
6014
- console.log(chalk8.gray(` Revision: ${revision.id}`));
6015
- if (revision.note) console.log(` ${chalk8.gray("Note:")} ${revision.note}`);
7626
+ console.log(chalk10.gray(` Revision: ${revision.id}`));
7627
+ if (revision.note) console.log(` ${chalk10.gray("Note:")} ${revision.note}`);
6016
7628
  if (revision.body) console.log(`
6017
7629
  ${revision.body}
6018
7630
  `);
@@ -6084,9 +7696,9 @@ ${revision.body}
6084
7696
  }
6085
7697
 
6086
7698
  // src/commands/products.ts
6087
- import { Command as Command18 } from "commander";
7699
+ import { Command as Command20 } from "commander";
6088
7700
  function createProductsCommand() {
6089
- const products = new Command18("products").description(
7701
+ const products = new Command20("products").description(
6090
7702
  "Manage products. A workspace contains products; a product holds features and tickets."
6091
7703
  );
6092
7704
  products.command("list").description("List products in a workspace").option("--workspace <slug|id>", "Workspace slug or CUID (defaults to configured workspace)").action(async (options, cmd) => {
@@ -6227,7 +7839,7 @@ Re-run with --force to delete it anyway.`
6227
7839
  }
6228
7840
 
6229
7841
  // src/commands/projects.ts
6230
- import { Command as Command19 } from "commander";
7842
+ import { Command as Command21 } from "commander";
6231
7843
  var PROJECT_STATUSES = [
6232
7844
  "ACTIVE",
6233
7845
  "ON_HOLD",
@@ -6254,7 +7866,7 @@ function validateProjectPriority(value) {
6254
7866
  return value;
6255
7867
  }
6256
7868
  function createProjectsCommand() {
6257
- const projects = new Command19("projects").description("Manage projects");
7869
+ const projects = new Command21("projects").description("Manage projects");
6258
7870
  projects.command("list").description("List all projects").option("--workspace <slug|id>", "Workspace slug or CUID").option("--include-actions", "Include actions in output").action(async (options, cmd) => {
6259
7871
  const globalOpts = cmd.optsWithGlobals();
6260
7872
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -6373,7 +7985,7 @@ Re-run with --force to delete it anyway.`
6373
7985
  }
6374
7986
 
6375
7987
  // src/commands/resources.ts
6376
- import { Command as Command20 } from "commander";
7988
+ import { Command as Command22 } from "commander";
6377
7989
  var STATUS_FILTERS = ["unread", "to_read", "reading", "read", "all"];
6378
7990
  function validateStatus(value) {
6379
7991
  const v = value ?? "unread";
@@ -6388,7 +8000,7 @@ function collectTags(value, previous) {
6388
8000
  }
6389
8001
  var TAG_OPTION = "--tag <tag>";
6390
8002
  function createResourcesCommand() {
6391
- const resources = new Command20("resources").description(
8003
+ const resources = new Command22("resources").description(
6392
8004
  "Saved links and reference material. `list` defaults to the Reading list (unread); `create --url` saves a link to read later."
6393
8005
  );
6394
8006
  resources.command("list").description("List resources. Defaults to the Reading list (unread); --status read for what you finished, all for everything.").option("--workspace <slug|id>", "Workspace (defaults to the configured default)").option("--status <status>", `One of: ${STATUS_FILTERS.join(", ")} (default: unread)`).option("--search <text>", "Filter by title/description").option(TAG_OPTION, "Only resources with this tag (repeatable or comma-separated; matches any)", collectTags, []).option("--limit <n>", "Max rows (default 50)", "50").action(
@@ -6495,7 +8107,7 @@ function createResourcesCommand() {
6495
8107
  }
6496
8108
 
6497
8109
  // src/commands/runner.ts
6498
- import { Command as Command21 } from "commander";
8110
+ import { Command as Command23 } from "commander";
6499
8111
  import { hostname, homedir as homedir2, tmpdir as tmpdir2 } from "os";
6500
8112
  import { execFileSync } from "child_process";
6501
8113
  import { mkdirSync as mkdirSync3 } from "fs";
@@ -6947,7 +8559,7 @@ function removeServiceFile(plan) {
6947
8559
 
6948
8560
  // src/commands/runner.ts
6949
8561
  function createRunnerCommand() {
6950
- const cmd = new Command21("runner").description(
8562
+ const cmd = new Command23("runner").description(
6951
8563
  "Run your Assistant locally: claim its queued runs and work them with Claude Code on this machine"
6952
8564
  );
6953
8565
  cmd.command("start").description("Poll for queued runs and work them until stopped (Ctrl-C)").option("--runner-id <id>", "Name of this runner, recorded on each run", hostname()).option("--cwd <dir>", "Working directory for the spawned CLI (overrides runner config; never from the server)").option("--interval <seconds>", "Seconds between polls when nothing is queued", "15").option("--once", "Claim at most one run, work it, and exit").option("--no-mcp", "Spawn without the Exponential MCP run tools (progress still streams; the session cannot ask the owner)").action(async (opts) => {
@@ -7058,8 +8670,8 @@ ${plan.contents}
7058
8670
  }
7059
8671
 
7060
8672
  // src/commands/search.ts
7061
- import { Command as Command22 } from "commander";
7062
- import chalk9 from "chalk";
8673
+ import { Command as Command24 } from "commander";
8674
+ import chalk11 from "chalk";
7063
8675
  var KNOWLEDGE_TYPES = ["transcription", "resource", "document", "page"];
7064
8676
  function parseTypes(value) {
7065
8677
  if (!value) return void 0;
@@ -7088,7 +8700,7 @@ var TYPE_LABELS = {
7088
8700
  product: "Products"
7089
8701
  };
7090
8702
  function createSearchCommand() {
7091
- const search = new Command22("search").description(
8703
+ const search = new Command24("search").description(
7092
8704
  "Global search across projects, actions, goals, workspaces and more \u2014 same coverage as the app's Cmd+K palette. Matches titles; add --semantic to search meetings, resources, documents and pages by meaning."
7093
8705
  ).argument("<query>", "Text to search for").option("-w, --workspace <slug>", "Restrict results to one workspace (slug or ID; required with --semantic)").option("-l, --limit <n>", "Max results per entity type (1-25, default 10; 1-20 with --semantic)").option("--semantic", "Search the Knowledge index by meaning instead of matching titles").option("--types <list>", "With --semantic: comma-separated source kinds (transcription,resource,document,page)").action(async (query, options, cmd) => {
7094
8706
  const globalOpts = cmd.optsWithGlobals();
@@ -7102,10 +8714,10 @@ function createSearchCommand() {
7102
8714
  (w) => w.slug === options.workspace || w.id === options.workspace
7103
8715
  );
7104
8716
  if (!match) {
7105
- console.error(chalk9.red(`Workspace "${options.workspace}" not found.`));
7106
- console.log(chalk9.gray("Available workspaces:"));
8717
+ console.error(chalk11.red(`Workspace "${options.workspace}" not found.`));
8718
+ console.log(chalk11.gray("Available workspaces:"));
7107
8719
  workspaces.forEach((w) => {
7108
- console.log(chalk9.gray(` - ${w.slug} (${w.name})`));
8720
+ console.log(chalk11.gray(` - ${w.slug} (${w.name})`));
7109
8721
  });
7110
8722
  process.exit(1);
7111
8723
  }
@@ -7127,16 +8739,16 @@ function createSearchCommand() {
7127
8739
  return;
7128
8740
  }
7129
8741
  if (knowledge.results.length === 0) {
7130
- console.log(chalk9.gray(`Nothing about "${knowledge.query}" in the Knowledge index.`));
8742
+ console.log(chalk11.gray(`Nothing about "${knowledge.query}" in the Knowledge index.`));
7131
8743
  return;
7132
8744
  }
7133
- console.log(chalk9.bold(`
8745
+ console.log(chalk11.bold(`
7134
8746
  About "${knowledge.query}"`));
7135
8747
  for (const row of knowledge.results) {
7136
8748
  console.log(
7137
- ` ${chalk9.white(row.title)} ${chalk9.gray(`\xB7 ${row.sourceType} \xB7 ${Math.round(row.similarity * 100)}%`)}`
8749
+ ` ${chalk11.white(row.title)} ${chalk11.gray(`\xB7 ${row.sourceType} \xB7 ${Math.round(row.similarity * 100)}%`)}`
7138
8750
  );
7139
- console.log(chalk9.gray(` ${row.sourceId} ${row.url}`));
8751
+ console.log(chalk11.gray(` ${row.sourceId} ${row.url}`));
7140
8752
  if (row.snippet) console.log(` ${row.snippet}`);
7141
8753
  }
7142
8754
  console.log();
@@ -7148,7 +8760,7 @@ About "${knowledge.query}"`));
7148
8760
  return;
7149
8761
  }
7150
8762
  if (result.results.length === 0) {
7151
- console.log(chalk9.gray(`No matches for "${result.query}".`));
8763
+ console.log(chalk11.gray(`No matches for "${result.query}".`));
7152
8764
  return;
7153
8765
  }
7154
8766
  const byType = /* @__PURE__ */ new Map();
@@ -7158,14 +8770,14 @@ About "${knowledge.query}"`));
7158
8770
  byType.set(r.type, bucket);
7159
8771
  }
7160
8772
  for (const [type, rows] of byType) {
7161
- console.log(chalk9.bold(`
8773
+ console.log(chalk11.bold(`
7162
8774
  ${TYPE_LABELS[type] ?? type}`));
7163
8775
  for (const row of rows) {
7164
- const parts = [chalk9.white(row.title)];
7165
- if (row.subtitle) parts.push(chalk9.gray(row.subtitle));
7166
- if (row.workspace) parts.push(chalk9.cyan(`@${row.workspace.slug}`));
7167
- console.log(` ${parts.join(chalk9.gray(" \xB7 "))}`);
7168
- console.log(chalk9.gray(` ${row.id}${row.url ? ` ${row.url}` : ""}`));
8776
+ const parts = [chalk11.white(row.title)];
8777
+ if (row.subtitle) parts.push(chalk11.gray(row.subtitle));
8778
+ if (row.workspace) parts.push(chalk11.cyan(`@${row.workspace.slug}`));
8779
+ console.log(` ${parts.join(chalk11.gray(" \xB7 "))}`);
8780
+ console.log(chalk11.gray(` ${row.id}${row.url ? ` ${row.url}` : ""}`));
7169
8781
  }
7170
8782
  }
7171
8783
  console.log();
@@ -7177,7 +8789,7 @@ ${TYPE_LABELS[type] ?? type}`));
7177
8789
  }
7178
8790
 
7179
8791
  // src/commands/tickets.ts
7180
- import { Command as Command23 } from "commander";
8792
+ import { Command as Command25 } from "commander";
7181
8793
  function collectRepeatable(value, previous) {
7182
8794
  return [...previous, value];
7183
8795
  }
@@ -7220,7 +8832,7 @@ function validateTicketType(value) {
7220
8832
  return value;
7221
8833
  }
7222
8834
  function createTicketsCommand() {
7223
- const tickets = new Command23("tickets").description(
8835
+ const tickets = new Command25("tickets").description(
7224
8836
  "Manage product backlog tickets. Tickets live under a product, link to features/epics, depend on each other, and can be implemented via actions."
7225
8837
  );
7226
8838
  tickets.command("list").description(
@@ -7589,7 +9201,7 @@ function createTicketsCommand() {
7589
9201
  handleError(error, useJson);
7590
9202
  }
7591
9203
  });
7592
- const comment = new Command23("comment").description("Manage comments on a ticket");
9204
+ const comment = new Command25("comment").description("Manage comments on a ticket");
7593
9205
  comment.command("list").description("List comments on a ticket").requiredOption("--id <id>", "Ticket CUID").action(async (options, cmd) => {
7594
9206
  const globalOpts = cmd.optsWithGlobals();
7595
9207
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -7681,7 +9293,7 @@ function createTicketsCommand() {
7681
9293
  }
7682
9294
 
7683
9295
  // src/commands/time.ts
7684
- import { Command as Command24 } from "commander";
9296
+ import { Command as Command26 } from "commander";
7685
9297
  import { segmentConversation } from "exponential-sdk";
7686
9298
  var SOURCES2 = ["manual", "claude-desktop", "agent-run"];
7687
9299
  var STATUSES2 = ["PROPOSED", "CONFIRMED"];
@@ -7771,7 +9383,7 @@ function batchItemToInput(item, index, defaults) {
7771
9383
  };
7772
9384
  }
7773
9385
  function createTimeCommand() {
7774
- const time = new Command24("time").description(
9386
+ const time = new Command26("time").description(
7775
9387
  `Time entries \u2014 log the day's work and list it. ${OWNERSHIP_NOTE}`
7776
9388
  );
7777
9389
  time.command("log").description(
@@ -7941,10 +9553,10 @@ function parseMessagesFile(raw) {
7941
9553
  }
7942
9554
 
7943
9555
  // src/commands/workspaces.ts
7944
- import { Command as Command25 } from "commander";
7945
- import chalk10 from "chalk";
9556
+ import { Command as Command27 } from "commander";
9557
+ import chalk12 from "chalk";
7946
9558
  function createWorkspacesCommand() {
7947
- const workspaces = new Command25("workspaces").description("Manage workspaces");
9559
+ const workspaces = new Command27("workspaces").description("Manage workspaces");
7948
9560
  workspaces.command("list").description("List all workspaces").action(async (_options, cmd) => {
7949
9561
  const globalOpts = cmd.optsWithGlobals();
7950
9562
  const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);
@@ -7957,7 +9569,7 @@ function createWorkspacesCommand() {
7957
9569
  const config = getConfig();
7958
9570
  outputWorkspacesPretty(workspaces2);
7959
9571
  if (config.defaultWorkspaceSlug) {
7960
- console.log(chalk10.gray(`Default workspace: ${config.defaultWorkspaceSlug}`));
9572
+ console.log(chalk12.gray(`Default workspace: ${config.defaultWorkspaceSlug}`));
7961
9573
  }
7962
9574
  }
7963
9575
  } catch (error) {
@@ -7970,10 +9582,10 @@ function createWorkspacesCommand() {
7970
9582
  const workspaces2 = await client.workspaces.list();
7971
9583
  const workspace = workspaces2.find((w) => w.slug === slug);
7972
9584
  if (!workspace) {
7973
- console.error(chalk10.red(`Workspace with slug "${slug}" not found.`));
7974
- console.log(chalk10.gray("Available workspaces:"));
9585
+ console.error(chalk12.red(`Workspace with slug "${slug}" not found.`));
9586
+ console.log(chalk12.gray("Available workspaces:"));
7975
9587
  workspaces2.forEach((w) => {
7976
- console.log(chalk10.gray(` - ${w.slug} (${w.name})`));
9588
+ console.log(chalk12.gray(` - ${w.slug} (${w.name})`));
7977
9589
  });
7978
9590
  process.exit(1);
7979
9591
  }
@@ -7981,7 +9593,7 @@ function createWorkspacesCommand() {
7981
9593
  defaultWorkspaceId: workspace.id,
7982
9594
  defaultWorkspaceSlug: workspace.slug
7983
9595
  });
7984
- console.log(chalk10.green(`Default workspace set to: ${workspace.name} (${workspace.slug})`));
9596
+ console.log(chalk12.green(`Default workspace set to: ${workspace.name} (${workspace.slug})`));
7985
9597
  } catch (error) {
7986
9598
  handleError(error);
7987
9599
  }
@@ -8009,20 +9621,20 @@ function createWorkspacesCommand() {
8009
9621
  return;
8010
9622
  }
8011
9623
  if (members.length === 0) {
8012
- console.log(chalk10.gray("No members found."));
9624
+ console.log(chalk12.gray("No members found."));
8013
9625
  return;
8014
9626
  }
8015
- console.log(chalk10.bold(`
9627
+ console.log(chalk12.bold(`
8016
9628
  Members (${members.length})
8017
9629
  `));
8018
9630
  for (const m of members) {
8019
9631
  const label = m.name ?? m.email ?? m.id;
8020
- const via = m.source === "team" ? chalk10.gray(
9632
+ const via = m.source === "team" ? chalk12.gray(
8021
9633
  ` via team${m.teams.length ? `: ${m.teams.map((t) => t.name).join(", ")}` : ""}` + (m.teamRole ? ` [team ${m.teamRole}]` : "")
8022
9634
  ) : "";
8023
- console.log(`${chalk10.bold(label)} ${chalk10.gray(`(${m.role})`)}${via}`);
8024
- if (m.email) console.log(chalk10.gray(` ${m.email}`));
8025
- console.log(chalk10.gray(` mention: ${m.mentionSyntax}`));
9635
+ console.log(`${chalk12.bold(label)} ${chalk12.gray(`(${m.role})`)}${via}`);
9636
+ if (m.email) console.log(chalk12.gray(` ${m.email}`));
9637
+ console.log(chalk12.gray(` mention: ${m.mentionSyntax}`));
8026
9638
  console.log();
8027
9639
  }
8028
9640
  } catch (error) {
@@ -8034,7 +9646,7 @@ Members (${members.length})
8034
9646
  }
8035
9647
 
8036
9648
  // src/commands/goals.ts
8037
- import { Command as Command26 } from "commander";
9649
+ import { Command as Command28 } from "commander";
8038
9650
  var GOAL_STATUSES = [
8039
9651
  "planned",
8040
9652
  "active",
@@ -8146,7 +9758,7 @@ function validateKeyResultUnit(value) {
8146
9758
  return value;
8147
9759
  }
8148
9760
  function createKeyResultsCommand() {
8149
- const kr = new Command26("kr").description(
9761
+ const kr = new Command28("kr").description(
8150
9762
  "Key results on an objective. Ids are CUIDs; --goal takes the objective's integer id."
8151
9763
  );
8152
9764
  kr.command("list").description("List key results").option("--goal <id>", "Objective ID (a number)").option("-w, --workspace <slug|id>", "Workspace (workspace-wide: every member's KRs)").option("--period <period>", "Period, e.g. Q3-2026").option("--status <status>", `Filter by status: ${KEY_RESULT_STATUSES.join(", ")}`).option("--mine", "Narrow a workspace list to key results you own").action(
@@ -8349,7 +9961,7 @@ function createKeyResultsCommand() {
8349
9961
  return kr;
8350
9962
  }
8351
9963
  function createGoalCommentsCommand() {
8352
- const comment = new Command26("comment").description(
9964
+ const comment = new Command28("comment").description(
8353
9965
  "Read and post comments on a goal. Mention teammates with --mention."
8354
9966
  );
8355
9967
  comment.command("list").description("List comments on a goal").requiredOption("--goal <id>", "Goal ID (a number)").action(async (options, cmd) => {
@@ -8444,7 +10056,7 @@ function createGoalCommentsCommand() {
8444
10056
  return comment;
8445
10057
  }
8446
10058
  function createGoalsCommand() {
8447
- const goals = new Command26("goals").description(
10059
+ const goals = new Command28("goals").description(
8448
10060
  "Manage goals (objectives) and their key results. Objectives have integer ids; key results are CUIDs."
8449
10061
  );
8450
10062
  goals.command("list").description(
@@ -8731,7 +10343,7 @@ Re-run with --with-key-results to go ahead, or move them with \`goals kr update
8731
10343
  return goals;
8732
10344
  }
8733
10345
  function createOkrsCommand() {
8734
- const okrs = new Command26("okrs").description(
10346
+ const okrs = new Command28("okrs").description(
8735
10347
  "OKRs \u2014 objectives with their key results nested. Manage the parts with `goals` and `goals kr`."
8736
10348
  );
8737
10349
  okrs.command("list").description(
@@ -8820,7 +10432,7 @@ function isBareVersionRequest(args) {
8820
10432
  return args.includes("--version") && args.every((arg) => arg.startsWith("-"));
8821
10433
  }
8822
10434
  function buildProgram() {
8823
- const program = new Command27();
10435
+ const program = new Command29();
8824
10436
  program.name("exponential").description(
8825
10437
  [
8826
10438
  "CLI to interact with Exponential productivity app.",
@@ -8833,6 +10445,8 @@ function buildProgram() {
8833
10445
  program.addCommand(createAuthCommand());
8834
10446
  program.addCommand(createActionsCommand());
8835
10447
  program.addCommand(createContactsCommand());
10448
+ program.addCommand(createCeremoniesCommand());
10449
+ program.addCommand(createDatabasesCommand());
8836
10450
  program.addCommand(createDecisionsCommand());
8837
10451
  program.addCommand(createDealsCommand());
8838
10452
  program.addCommand(createEpicsCommand());