@moda-ai/cli 1.55.41 → 1.55.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/{agent-ck6y31n2.js → agent-x1gwrrvd.js} +6 -5
  2. package/dist/{cli-xddtv3yn.js → cli-5fhqfx04.js} +1 -39
  3. package/dist/{cli-gt3yq1y5.js → cli-5y9tj6cb.js} +183 -1
  4. package/dist/{cli-f1jfrqgf.js → cli-9a0a3v13.js} +234 -17
  5. package/dist/cli-e0kbye4s.js +39 -0
  6. package/dist/{cli-ypqwcf9n.js → cli-fpd1pfvt.js} +2 -2
  7. package/dist/{cli-a8nxbtpk.js → cli-h62j4jn7.js} +2 -2
  8. package/dist/{cli-4tg0hkbz.js → cli-k5drmy8r.js} +7 -7
  9. package/dist/{cli-azage7s0.js → cli-s1w5phms.js} +3 -3
  10. package/dist/{cli-7bn406mt.js → cli-stfpr2ct.js} +2 -2
  11. package/dist/cli.js +224 -52
  12. package/dist/{doctor-p8sp6cbk.js → doctor-wrgajgev.js} +5 -4
  13. package/dist/{fix-0r974yge.js → fix-7aajsdbf.js} +1 -1
  14. package/dist/{harness-72ejenza.js → harness-1rn1hqzz.js} +4 -3
  15. package/dist/{harness-github-actions-2qc4gg2w.js → harness-github-actions-m95qvgbs.js} +4 -3
  16. package/dist/{index-w7v472w4.js → index-svfzq5rb.js} +7 -6
  17. package/dist/{production-intelligence-e5vsc6cw.js → production-intelligence-7jvfdz6b.js} +22 -5
  18. package/dist/{prompt-attribution-3987hhqz.js → prompt-attribution-hc6mcvee.js} +4 -3
  19. package/dist/prompt-source-mcp.js +4 -3
  20. package/dist/{prompts-ab-gmd10n5d.js → prompts-ab-ws66335h.js} +5 -4
  21. package/dist/{prompts-propose-q626zmm4.js → prompts-propose-a9m0p9nr.js} +5 -4
  22. package/dist/{prompts-ysm9ra72.js → prompts-xe5bgbx8.js} +4 -3
  23. package/dist/{provision-cya5rpxa.js → provision-a9kkfvp7.js} +2 -1
  24. package/dist/{registry-7xz09ry0.js → registry-j2dsfh6v.js} +1 -1
  25. package/dist/{skills-x6yszxxn.js → skills-vveagdwe.js} +4 -3
  26. package/dist/{sync-trjzvam9.js → sync-yy3fgnxe.js} +6 -5
  27. package/package.json +1 -1
  28. package/skills/integration/index.json +2 -2
  29. package/skills/moda-cli/SKILL.md +4 -1
  30. package/skills/moda-cli/references/commands.md +8 -3
  31. package/skills/moda-cli/references/dashboard-parity.md +7 -2
  32. package/skills/moda-cli/references/detections.md +20 -0
  33. package/skills/moda-cli/references/production-intelligence.md +48 -0
@@ -36,8 +36,20 @@ var daysBackFlag = (fallback) => {
36
36
  var ISO_BOUND_MESSAGE = "must be an ISO 8601 date (2026-10-07) or datetime (2026-10-07T14:30:00Z)";
37
37
  var ISO_BOUND = /^\d{4}-\d{2}-\d{2}(?:[Tt ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:[Zz]|[+-]\d{2}:?\d{2})?)?$/;
38
38
  var isoBoundFlag = () => z.string().trim().regex(ISO_BOUND, ISO_BOUND_MESSAGE).optional();
39
+ var COHORT_REF = /^(all|builtin:[a-z_]{1,64}|[a-z_]{1,64}|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
40
+ var COHORT_REF_MESSAGE = "must be builtin:<key> or a saved cohort id (see moda cohorts list)";
41
+ var cohortFlag = (description) => z.string().regex(COHORT_REF, COHORT_REF_MESSAGE).optional().describe(description);
42
+ var CLUSTER_COHORT_TIME_RANGES = ["all", "3d", "7d", "30d"];
43
+ var TREND_UNITS = ["conversation", "segment", "turn"];
44
+ var compareFlag = () => boolFlag().describe("Add summary.compare: the dashboard KPI tiles and rate for this window against the previous window of equal length");
39
45
  var OverviewSchema = z.object({
40
- days_back: daysBackFlag(7)
46
+ days_back: daysBackFlag(7),
47
+ compare: boolFlag().describe("Add trends: overview KPIs, per-unit rates and each detector family, against the previous window of equal length"),
48
+ series: boolFlag().describe("Add trends.series: [bucket, value] per hour (windows up to 2 days) or per day"),
49
+ since: isoBoundFlag().describe("Trends window start (ISO date or datetime, UTC unless an offset is given); the previous window is the same span before it"),
50
+ until: isoBoundFlag().describe("Trends window end, inclusive (default now); needs --since"),
51
+ agent_name: z.string().trim().min(1).max(200).optional().describe("Scope the trends overview KPIs to one sub-agent (the Analytics agent selector; names are in trends.agent.options)"),
52
+ unit: z.enum(TREND_UNITS).optional().describe("Denominator of trends.rates (default conversation)")
41
53
  });
42
54
  var ClustersSchema = z.object({
43
55
  parent_id: z.string().optional().describe("List the children of this cluster node"),
@@ -45,7 +57,8 @@ var ClustersSchema = z.object({
45
57
  search: z.string().min(2).max(200).optional().describe("Find clusters by name or meaning"),
46
58
  node_id: z.string().min(1).max(512).optional().describe("Resolve one cluster node by id (deep link)"),
47
59
  mode: z.enum(["fuzzy", "semantic", "hybrid"]).optional().describe("Cluster search mode (server default hybrid)"),
48
- limit: z.number().int().min(1).max(50).optional().describe("Maximum clusters to return (with --search/--node-id)")
60
+ limit: z.number().int().min(1).max(50).optional().describe("Maximum clusters to return (with --search/--node-id)"),
61
+ cohort: cohortFlag("Only the clusters this cohort's users reach, with its segment counts (builtin:<key> or a saved cohort id); --time-range all|3d|7d|30d")
49
62
  });
50
63
  var ClusterConversationsSchema = z.object({
51
64
  node_id: z.string().describe("Cluster node id (from moda clusters)"),
@@ -64,6 +77,7 @@ var ConversationsSchema = z.object({
64
77
  outcome: z.enum(["any", "positive", "negative"]).default("any").optional().describe("Filter by trace outcome (trajectory + frustration)"),
65
78
  include_world_state: boolFlag().describe("Attach each result's world-state summary"),
66
79
  sort: z.enum(["recent", "longest", "slowest"]).optional().describe("recent = newest activity, longest = most messages, slowest = longest span"),
80
+ cohort: cohortFlag("Only traces of this cohort's current members (builtin:<key> or a saved cohort id)"),
67
81
  limit: z.number().int().min(1).max(100).default(20).optional().describe("Maximum traces to return"),
68
82
  offset: z.number().int().min(0).default(0).optional().describe("Number of traces to skip")
69
83
  });
@@ -124,18 +138,20 @@ var emotionTraceFilters = {
124
138
  trajectory: z.enum(EMOTION_TRAJECTORIES).optional().describe("How the emotion moved over the trace; needs --group-by=trace"),
125
139
  signal: emotionSignalsFlag(),
126
140
  sort: z.enum(EMOTION_TRACE_SORTS).optional().describe("Trace order (default score); needs --group-by=trace"),
127
- order: z.enum(SORT_ORDERS).optional().describe("Sort direction (default desc); needs --group-by=trace")
141
+ order: z.enum(SORT_ORDERS).optional().describe("Sort direction (default desc); needs --group-by=trace"),
142
+ cohort: cohortFlag("Only traces of this cohort's members, summary included (builtin:<key> or a saved cohort id); implies --group-by=trace")
128
143
  };
129
144
  var TRACE_GRAIN_FLAGS = {
130
- emotions: ["search", "status", "elicitor", "trajectory", "signal", "sort", "order"],
131
- frustrations: ["search", "status", "elicitor", "trajectory", "signal", "sort", "order"],
132
- hallucinations: ["search", "status", "rule", "source", "sort", "order"]
145
+ emotions: ["search", "status", "elicitor", "trajectory", "signal", "sort", "order", "cohort"],
146
+ frustrations: ["search", "status", "elicitor", "trajectory", "signal", "sort", "order", "cohort"],
147
+ hallucinations: ["search", "status", "rule", "source", "sort", "order", "cohort"]
133
148
  };
134
149
  var MAX_CONVERSATION_IDS_FILTER = 50;
135
150
  var conversationIdsFlag = () => z.string().min(1).max(MAX_CONVERSATION_IDS_FILTER * 257).optional().describe(`Scope everything to several trace IDs, comma-separated (up to ${MAX_CONVERSATION_IDS_FILTER}; or --ids-from)`);
136
151
  var idsFromFilterFlag = () => z.string().min(1).optional().describe(`Read the trace IDs to scope to from a file, or - for stdin, one per line (up to ${MAX_CONVERSATION_IDS_FILTER})`);
137
152
  var FrustrationsSchema = z.object({
138
153
  days_back: daysBackFlag(7),
154
+ compare: compareFlag(),
139
155
  limit: z.number().int().min(1).max(20).default(10).optional().describe("Maximum detections to return"),
140
156
  offset: z.number().int().min(0).default(0).optional().describe("Number of detections to skip"),
141
157
  include_window: boolFlag().describe("Attach the surrounding messages to each detection (agent output omits them by default)"),
@@ -147,14 +163,15 @@ var FrustrationsSchema = z.object({
147
163
  ids_from: idsFromFilterFlag()
148
164
  });
149
165
  var ToolFailuresSchema = z.object({
150
- days_back: daysBackFlag(7)
166
+ days_back: daysBackFlag(7),
167
+ cohort: cohortFlag("The dashboard Tool Failures leaderboard for this cohort's traces (builtin:<key> or a saved cohort id)"),
168
+ compare: compareFlag()
151
169
  });
152
170
  var PROBLEM_LIST_VIEWS = ["auto", "book", "dream"];
153
171
  var BOOK_PROBLEM_SORTS = ["rank", "users", "signals", "problems"];
154
172
  var DREAM_PROBLEM_SORTS = ["severity", "users", "silent"];
155
173
  var PROBLEMS_MAX_LIMIT = 200;
156
174
  var PROBLEMS_DEFAULT_LIMIT = 10;
157
- var COHORT_REF = /^(all|builtin:[a-z_]{1,64}|[a-z_]{1,64}|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
158
175
  var ProblemsSchema = z.object({
159
176
  view: z.enum(PROBLEM_LIST_VIEWS).default("auto").optional().describe("auto: what the dashboard shows (the dream grouping when published, else the Book); book or dream to force one"),
160
177
  days_back: daysBackFlag().describe("Whole days to look back (Book default 30; the dream view defaults to its run window)"),
@@ -163,7 +180,7 @@ var ProblemsSchema = z.object({
163
180
  list_version: z.string().regex(/^[0-9a-f]{1,64}$/, "must be the list_version of a previous page").optional().describe("list_version of the first page, passed with every later --offset"),
164
181
  sort: z.string().regex(/^(rank|severity|users|signals|problems|silent|signal:[a-z_]{1,64})$/, "must be rank, severity, users, silent (dream), signals, problems or signal:<family> (Book)").optional().describe("Order: rank (default), users; dream: severity, silent; Book: signals, problems, signal:<family>"),
165
182
  dir: z.enum(["desc", "asc"]).optional().describe("Sort direction (default desc)"),
166
- cohort: z.string().regex(COHORT_REF, "must be builtin:<key> or a saved cohort id").optional().describe("Only the Problems this cohort hit (builtin:<key> or a saved cohort id), with its counts")
183
+ cohort: cohortFlag("Only the Problems this cohort hit (builtin:<key> or a saved cohort id), with its counts")
167
184
  });
168
185
  var REMAINDER_FAMILIES = [
169
186
  "tool_failure",
@@ -220,7 +237,8 @@ var ProblemSchema = z.object({
220
237
  door: z.enum(PROBLEM_DOORS).optional().describe("With --traces: only this attribution door"),
221
238
  view: z.enum(["book", "dream"]).optional().describe("dream: the dream view of the problem (definition, severity, incidents with verdicts); default the dossier"),
222
239
  offset: z.number().int().min(0).max(1e4).optional().describe("With --view=dream: first incident to return"),
223
- days_back: daysBackFlag().describe("With --view=dream: whole days to count (default the dream run window)")
240
+ days_back: daysBackFlag().describe("With --view=dream: whole days to count (default the dream run window). With --trend: days of history (default 30)"),
241
+ trend: boolFlag().describe("Incidents and users per day, and the window against the previous window of equal length")
224
242
  });
225
243
  var PROBLEM_FEEDBACK_ACTIONS = [
226
244
  "mark_fixed",
@@ -248,7 +266,8 @@ var SignalSchema = z.object({
248
266
  detections: boolFlag().describe("List recent hits instead of the summary"),
249
267
  days_back: daysBackFlag(),
250
268
  limit: z.number().int().min(1).max(20).optional().describe("Hits page size (server default 10)"),
251
- offset: z.number().int().min(0).max(1e4).optional().describe("Number of hits to skip")
269
+ offset: z.number().int().min(0).max(1e4).optional().describe("Number of hits to skip"),
270
+ cohort: cohortFlag("Only hits on traces of this cohort's members (builtin:<key> or a saved cohort id); with --detections")
252
271
  });
253
272
  var SIGNAL_LABELS = ["fits", "does_not_fit"];
254
273
  var SignalLabelSchema = z.object({
@@ -318,6 +337,7 @@ var EMOTION_FAMILIES = [
318
337
  ];
319
338
  var EmotionsSchema = z.object({
320
339
  days_back: daysBackFlag(7),
340
+ compare: compareFlag(),
321
341
  limit: z.number().int().min(1).max(20).default(10).optional().describe("Maximum detections to return"),
322
342
  offset: z.number().int().min(0).max(1e4).optional().describe("Number of detections to skip"),
323
343
  family: z.enum(EMOTION_FAMILIES).optional().describe("Only this family in the detections list (summary covers all)"),
@@ -330,6 +350,7 @@ var EmotionsSchema = z.object({
330
350
  });
331
351
  var HallucinationsSchema = z.object({
332
352
  days_back: daysBackFlag(7),
353
+ compare: compareFlag(),
333
354
  limit: z.number().int().min(1).max(20).default(10).optional().describe("Maximum detections to return"),
334
355
  offset: z.number().int().min(0).max(1e4).optional().describe("Number of detections to skip"),
335
356
  conversation_id: z.string().max(200).optional().describe("Scope summary and list to one trace ID"),
@@ -342,7 +363,8 @@ var HallucinationsSchema = z.object({
342
363
  rule: z.string().trim().min(1).max(200).optional().describe("One rule_id from summary.rule_breakdown; scopes the summary too; needs --group-by=trace"),
343
364
  source: z.enum(HALLUCINATION_SOURCES).optional().describe("Only detections from this source; needs --group-by=trace"),
344
365
  sort: z.enum(HALLUCINATION_TRACE_SORTS).optional().describe("Trace order (default contradicted_count); needs --group-by=trace"),
345
- order: z.enum(SORT_ORDERS).optional().describe("Sort direction (default desc); needs --group-by=trace")
366
+ order: z.enum(SORT_ORDERS).optional().describe("Sort direction (default desc); needs --group-by=trace"),
367
+ cohort: cohortFlag("Only traces of this cohort's members, summary included (builtin:<key> or a saved cohort id); implies --group-by=trace")
346
368
  });
347
369
  var LAZINESS_FAMILIES = [
348
370
  "omission_comment",
@@ -367,6 +389,7 @@ var LAZINESS_FAMILIES = [
367
389
  ];
368
390
  var LazinessSchema = z.object({
369
391
  days_back: daysBackFlag(7),
392
+ compare: compareFlag(),
370
393
  limit: z.number().int().min(1).max(50).default(10).optional().describe("Maximum detections to return"),
371
394
  offset: z.number().int().min(0).max(1e4).optional().describe("Number of detections to skip"),
372
395
  conversation_id: z.string().max(200).optional().describe("One trace's detections"),
@@ -377,7 +400,8 @@ var LazinessSchema = z.object({
377
400
  search: z.string().trim().min(1).max(200).optional().describe("Trace ID substring"),
378
401
  status: z.enum(["all", "strong"]).optional().describe("all (default), or strong: traces with a high-confidence detection"),
379
402
  sort: z.enum(LAZINESS_TRACE_SORTS).optional().describe("Trace order (default detections_count)"),
380
- order: z.enum(SORT_ORDERS).optional().describe("Sort direction (default desc)")
403
+ order: z.enum(SORT_ORDERS).optional().describe("Sort direction (default desc)"),
404
+ cohort: cohortFlag("Only traces of this cohort's members (builtin:<key> or a saved cohort id); not with --conversation-id")
381
405
  });
382
406
  var StepScoresSchema = z.object({
383
407
  conversation_id: z.string().min(1).describe("Trace ID")
@@ -489,7 +513,7 @@ var UsersSchema = z.object({
489
513
  page_size: z.number().int().min(1).optional().describe("Users per page"),
490
514
  limit: z.number().int().min(1).optional().describe("Alias of --page-size"),
491
515
  search: z.string().optional().describe("Match user id or name"),
492
- cohort: z.enum(USER_COHORTS).optional().describe("Only users in this cohort"),
516
+ cohort: cohortFlag(`Only users in this cohort: builtin:<key>, a saved cohort id, or a built-in key (${USER_COHORTS.filter((key) => key !== "all").join(", ")})`),
493
517
  sort: z.enum(USER_SORTS).optional().describe("Sort field"),
494
518
  order: z.enum(["asc", "desc"]).optional().describe("Sort order"),
495
519
  health_status: z.string().optional().describe(`Comma-separated health states (${USER_HEALTH.join(", ")})`),
@@ -510,6 +534,52 @@ var ProblemReopenSchema = z.object({
510
534
  reason: z.string().max(500).optional().describe("Why it is being reopened"),
511
535
  dry_run: boolFlag().describe("Print the request and send nothing")
512
536
  });
537
+ var COHORT_COLORS = ["neutral", "blue", "green", "amber", "red", "violet"];
538
+ var COHORT_COMPARE_DAYS = ["7", "30", "90"];
539
+ var cohortTenant = () => z.string().optional().describe("Tenant to read; must match the API key's tenant");
540
+ var cohortRef = (description) => z.string().regex(COHORT_REF, COHORT_REF_MESSAGE).describe(description);
541
+ var cohortDefinitionFlags = {
542
+ definition: z.string().optional().describe("Cohort definition (DSL v1) as inline JSON; see moda cohorts fields"),
543
+ file: z.string().optional().describe("JSON file with the definition, or a body with a definition key")
544
+ };
545
+ var CohortsListSchema = z.object({
546
+ include_archived: boolFlag().describe("Also list archived saved cohorts"),
547
+ tenant_id: cohortTenant()
548
+ });
549
+ var CohortGetSchema = z.object({
550
+ ref: cohortRef("builtin:<key> or a saved cohort id"),
551
+ tenant_id: cohortTenant()
552
+ });
553
+ var CohortFieldsSchema = z.object({
554
+ tenant_id: cohortTenant()
555
+ });
556
+ var CohortPreviewSchema = z.object({
557
+ ...cohortDefinitionFlags,
558
+ tenant_id: cohortTenant()
559
+ });
560
+ var CohortCompareSchema = z.object({
561
+ a: cohortRef("First cohort: builtin:<key> or a saved cohort id"),
562
+ b: cohortRef("Second cohort: builtin:<key> or a saved cohort id"),
563
+ days: z.enum(COHORT_COMPARE_DAYS).optional().describe("Window for top topics and failure mix (server default 30)"),
564
+ tenant_id: cohortTenant()
565
+ });
566
+ var cohortFieldFlags = {
567
+ name: z.string().max(120).optional().describe("Cohort name"),
568
+ description: z.string().max(2000).optional().describe("Cohort description"),
569
+ ...cohortDefinitionFlags,
570
+ pinned: boolFlag().describe("Pin the cohort on the Users page"),
571
+ color: z.enum(COHORT_COLORS).optional().describe("Pill color")
572
+ };
573
+ var CohortCreateSchema = z.object({
574
+ ...cohortFieldFlags,
575
+ tenant_id: cohortTenant()
576
+ });
577
+ var CohortUpdateSchema = z.object({
578
+ id: z.string().regex(UUID_RE, "must be a saved cohort id (UUID); built-in cohorts cannot be edited").describe("Saved cohort id"),
579
+ ...cohortFieldFlags,
580
+ note: z.string().max(500).optional().describe("Why it changed (kept with the revision)"),
581
+ tenant_id: cohortTenant()
582
+ });
513
583
 
514
584
  // ../../packages/database/src/agent-feedback.ts
515
585
  var FEEDBACK_CATEGORIES = [
@@ -716,7 +786,18 @@ var COMMAND_FLAG_SPECS = {
716
786
  positionals: [{ name: "note", key: "note", required: true, variadic: true, alsoFlag: true }]
717
787
  },
718
788
  users: { schema: UsersSchema, handParsed: true },
719
- user: { schema: UserSchema, handParsed: true, positionals: [{ name: "user_id", key: "user_id", required: true }] }
789
+ user: { schema: UserSchema, handParsed: true, positionals: [{ name: "user_id", key: "user_id", required: true }] },
790
+ "cohort-list": { schema: CohortsListSchema, handParsed: true },
791
+ "cohort-get": { schema: CohortGetSchema, handParsed: true, positionals: [{ name: "ref", key: "ref", required: true }] },
792
+ "cohort-fields": { schema: CohortFieldsSchema, handParsed: true },
793
+ "cohort-preview": { schema: CohortPreviewSchema, handParsed: true },
794
+ "cohort-compare": {
795
+ schema: CohortCompareSchema,
796
+ handParsed: true,
797
+ positionals: [{ name: "cohort_a", key: "a", required: true }, { name: "cohort_b", key: "b", required: true }]
798
+ },
799
+ "cohort-create": { schema: CohortCreateSchema, extra: DRY_RUN, handParsed: true },
800
+ "cohort-update": { schema: CohortUpdateSchema, extra: DRY_RUN, handParsed: true, positionals: [{ name: "cohort_id", key: "id", required: true }] }
720
801
  };
721
802
  function flagSpecFor(command) {
722
803
  return Object.hasOwn(COMMAND_FLAG_SPECS, command) ? COMMAND_FLAG_SPECS[command] : undefined;
@@ -1063,6 +1144,14 @@ function oneOf(name, value, allowed) {
1063
1144
  }
1064
1145
  return value;
1065
1146
  }
1147
+ function cohortRefFlag(value) {
1148
+ if (value === undefined)
1149
+ return;
1150
+ if (!COHORT_REF.test(value)) {
1151
+ throw new CliInputError(`--cohort must be builtin:<key> or a saved cohort id (got '${value}').`, "List the refs with `moda cohorts list`.");
1152
+ }
1153
+ return value;
1154
+ }
1066
1155
  function csv(value) {
1067
1156
  if (value === undefined)
1068
1157
  return;
@@ -1116,7 +1205,7 @@ async function runUsersCommand(context) {
1116
1205
  page: flags.page,
1117
1206
  pageSize: flags["page-size"] ?? flags.limit,
1118
1207
  search: flags.search,
1119
- cohort: oneOf("cohort", flags.cohort, USER_COHORTS),
1208
+ cohort: cohortRefFlag(flags.cohort),
1120
1209
  sortBy: oneOf("sort", flags.sort, USER_SORTS),
1121
1210
  sortOrder: oneOf("order", flags.order, ["asc", "desc"]),
1122
1211
  healthStatus: csv(flags["health-status"])?.map((value) => oneOf("health-status", value, HEALTH)).join(","),
@@ -1146,6 +1235,134 @@ async function runUserCommand(context) {
1146
1235
  await send(context, "control", "GET", `/tenants/${encodeURIComponent(tenantId)}/users/${encodeURIComponent(userId)}${suffix}`);
1147
1236
  return { exitCode: 0 };
1148
1237
  }
1238
+ var COHORT_DEFINITION_HINT = 'A definition is {"version":1,"window":"24h|7d|30d|90d","where":{...}}; `moda cohorts fields` lists the fields and operators.';
1239
+ function cohortsBase(context) {
1240
+ return `/tenants/${encodeURIComponent(requireTenant(context))}/cohorts`;
1241
+ }
1242
+ function cohortRefArg(value, what, usage) {
1243
+ if (!value)
1244
+ throw new CliInputError(`${what} is required.`, `Usage: ${usage}`);
1245
+ if (!COHORT_REF.test(value)) {
1246
+ throw new CliInputError(`${what} must be builtin:<key> or a saved cohort id (got '${value}').`, "List the refs with `moda cohorts list`.");
1247
+ }
1248
+ return value;
1249
+ }
1250
+ function cohortBodyInput(flags, cwd) {
1251
+ const fromFile = readBodyFile(flags, cwd);
1252
+ const body = Object.keys(fromFile).length === 0 ? {} : ("definition" in fromFile) ? fromFile : { definition: fromFile };
1253
+ if (flags.definition !== undefined) {
1254
+ let parsed;
1255
+ try {
1256
+ parsed = JSON.parse(flags.definition);
1257
+ } catch (error) {
1258
+ throw new CliInputError(`--definition is not valid JSON: ${error instanceof Error ? error.message : String(error)}`, COHORT_DEFINITION_HINT);
1259
+ }
1260
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
1261
+ throw new CliInputError("--definition must be a JSON object.", COHORT_DEFINITION_HINT);
1262
+ body.definition = parsed;
1263
+ }
1264
+ if (body.definition !== undefined && (!body.definition || typeof body.definition !== "object" || Array.isArray(body.definition))) {
1265
+ throw new CliInputError("The cohort definition must be a JSON object.", COHORT_DEFINITION_HINT);
1266
+ }
1267
+ return body;
1268
+ }
1269
+ function cohortFieldBody(flags, cwd) {
1270
+ const pinned = flags.pinned === undefined ? undefined : oneOf("pinned", flags.pinned, ["true", "false", "1", "0", "yes", "no"]);
1271
+ return {
1272
+ ...cohortBodyInput(flags, cwd),
1273
+ ...compact({
1274
+ name: flags.name,
1275
+ description: flags.description,
1276
+ pinned: pinned === undefined ? undefined : ["true", "1", "yes"].includes(pinned),
1277
+ color: oneOf("color", flags.color, COHORT_COLORS)
1278
+ })
1279
+ };
1280
+ }
1281
+ var COHORT_COMMANDS = {
1282
+ "cohort-list": { path: "cohorts list", usage: "moda cohorts list [--include-archived]" },
1283
+ "cohort-get": { path: "cohorts get", usage: "moda cohorts get <ref>" },
1284
+ "cohort-fields": { path: "cohorts fields", usage: "moda cohorts fields" },
1285
+ "cohort-preview": { path: "cohorts preview", usage: "moda cohorts preview --file=<path> | --definition=<json>" },
1286
+ "cohort-compare": { path: "cohorts compare", usage: "moda cohorts compare <cohort_a> <cohort_b> [--days=7|30|90]" },
1287
+ "cohort-create": { path: "cohorts create", usage: "moda cohorts create --name=NAME --file=<path>|--definition=<json> [--description --pinned --color] [--dry-run]" },
1288
+ "cohort-update": { path: "cohorts update", usage: "moda cohorts update <cohort_id> [--name --description --file|--definition --pinned --color --note] [--dry-run]" }
1289
+ };
1290
+ async function runCohortCommand(context) {
1291
+ const flags = context.flags;
1292
+ const command = COHORT_COMMANDS[context.command];
1293
+ if (!command)
1294
+ throw new CliInputError(`Unknown cohorts command '${context.command}'.`, "Run 'moda cohorts --help'.");
1295
+ const spec = flagSpecFor(context.command);
1296
+ assertFlags(command.path, flags, spec ? specFlagNames(spec) : []);
1297
+ assertPositionals(command.path, context.positionals, spec?.positionals?.length ?? 0, command.usage);
1298
+ const [first, second] = context.positionals;
1299
+ switch (context.command) {
1300
+ case "cohort-list": {
1301
+ requireKey(context);
1302
+ const archived = flags["include-archived"];
1303
+ const query = archived !== undefined && archived !== "false" && archived !== "0" ? "?includeArchived=1" : "";
1304
+ await send(context, "control", "GET", `${cohortsBase(context)}${query}`);
1305
+ return { exitCode: 0 };
1306
+ }
1307
+ case "cohort-get": {
1308
+ const ref = cohortRefArg(first, "<ref>", "moda cohorts get <ref>");
1309
+ requireKey(context);
1310
+ await send(context, "control", "GET", `${cohortsBase(context)}/${encodeURIComponent(ref)}`);
1311
+ return { exitCode: 0 };
1312
+ }
1313
+ case "cohort-fields": {
1314
+ requireKey(context);
1315
+ await send(context, "control", "GET", `${cohortsBase(context)}/fields`);
1316
+ return { exitCode: 0 };
1317
+ }
1318
+ case "cohort-preview": {
1319
+ const { definition } = cohortBodyInput(flags, context.cwd);
1320
+ if (definition === undefined)
1321
+ throw new CliInputError("Pass the definition with --file=<path> or --definition=<json>.", COHORT_DEFINITION_HINT);
1322
+ requireKey(context);
1323
+ const data = await callControlAPI(`${cohortsBase(context)}/preview`, { method: "POST", body: JSON.stringify({ definition }) }, profileOptions(context));
1324
+ context.output.writeData(data ?? {});
1325
+ return { exitCode: 0 };
1326
+ }
1327
+ case "cohort-compare": {
1328
+ const usage = "moda cohorts compare <cohort_a> <cohort_b> [--days=7|30|90]";
1329
+ const a = cohortRefArg(first, "<cohort_a>", usage);
1330
+ const b = cohortRefArg(second, "<cohort_b>", usage);
1331
+ const days = oneOf("days", flags.days, COHORT_COMPARE_DAYS);
1332
+ requireKey(context);
1333
+ const query = new URLSearchParams(compact({ a, b, days }));
1334
+ await send(context, "control", "GET", `${cohortsBase(context)}/compare?${query.toString()}`);
1335
+ return { exitCode: 0 };
1336
+ }
1337
+ case "cohort-create": {
1338
+ const body = cohortFieldBody(flags, context.cwd);
1339
+ const missing = ["name", "definition"].filter((field) => body[field] === undefined);
1340
+ if (missing.length > 0) {
1341
+ throw new CliInputError(`Missing ${missing.join(" and ")} for cohorts create, so nothing was sent.`, `Pass --name and --file=<definition.json> (or --definition=<json>). ${COHORT_DEFINITION_HINT} Check the members first with \`moda cohorts preview\`.`);
1342
+ }
1343
+ requireKey(context);
1344
+ await send(context, "control", "POST", cohortsBase(context), body);
1345
+ return { exitCode: 0 };
1346
+ }
1347
+ case "cohort-update": {
1348
+ const usage = "moda cohorts update <cohort_id> [--name --description --file|--definition --pinned --color --note] [--dry-run]";
1349
+ if (!first)
1350
+ throw new CliInputError("<cohort_id> is required.", `Usage: ${usage}`);
1351
+ if (!UUID_RE2.test(first)) {
1352
+ throw new CliInputError(`<cohort_id> must be a saved cohort id (UUID), got '${first}'. Built-in cohorts cannot be edited.`, "List saved cohorts with `moda cohorts list`.");
1353
+ }
1354
+ const body = { ...cohortFieldBody(flags, context.cwd), ...compact({ note: flags.note }) };
1355
+ if (Object.keys(body).filter((key) => key !== "note").length === 0) {
1356
+ throw new CliInputError("Nothing to update, so nothing was sent: pass at least one of --name, --description, --file/--definition, --pinned or --color.", `Usage: ${usage}`);
1357
+ }
1358
+ requireKey(context);
1359
+ await send(context, "control", "PATCH", `${cohortsBase(context)}/${encodeURIComponent(first)}`, body);
1360
+ return { exitCode: 0 };
1361
+ }
1362
+ default:
1363
+ throw new CliInputError(`Unknown cohorts command '${context.command}'.`, "Run 'moda cohorts --help'.");
1364
+ }
1365
+ }
1149
1366
  async function runProblemReopenCommand(context) {
1150
1367
  assertFlags("problem-reopen", context.flags, specFlagNames(COMMAND_FLAG_SPECS["problem-reopen"]));
1151
1368
  assertPositionals("problem-reopen", context.positionals, 1, "moda problems reopen <problem_id> [--reason=TEXT]");
@@ -1447,4 +1664,4 @@ function unknownSignalsSubcommandError(sub, args = []) {
1447
1664
  ${SIGNAL_USAGE}`);
1448
1665
  }
1449
1666
 
1450
- export { TRACE_GRAIN_FLAGS, MAX_CONVERSATION_IDS_FILTER, BOOK_PROBLEM_SORTS, DREAM_PROBLEM_SORTS, PROBLEMS_MAX_LIMIT, PROBLEMS_DEFAULT_LIMIT, ProblemsRemainderSchema, UUID_RE, ProblemImpactSchema, PROBLEM_FEEDBACK_ACTIONS, ProblemFeedbackSchema, ProblemLinearFileSchema, SignalLabelSchema, DETECTION_VERDICTS, DetectionReviewSchema, FALSE_POSITIVE_KINDS, FalsePositiveSchema, EMOTION_FAMILIES, LAZINESS_FAMILIES, StepScoresSchema, AuditSchema, TraceFindingsSchema, FEEDBACK_USAGE, isFeedbackRefFlag, buildFeedbackRequest, writeDryRun, COMMAND_FLAG_SPECS, flagSpecFor, kebabFlag, schemaShape, describeField, specFlagKeys, specFlagNames, describeSpecFlags, closestMatches, usageLine, renderFlagHelp, subcommandHelpFlags, manifestFlagFields, requireTenant, assertFlags, assertPositionals, runUsersCommand, runUserCommand, runProblemReopenCommand, runSignalsManagementCommand, SIGNALS_MANAGEMENT_SUBCOMMANDS, unknownSignalsSubcommandError };
1667
+ export { CLUSTER_COHORT_TIME_RANGES, TRACE_GRAIN_FLAGS, MAX_CONVERSATION_IDS_FILTER, BOOK_PROBLEM_SORTS, DREAM_PROBLEM_SORTS, PROBLEMS_MAX_LIMIT, PROBLEMS_DEFAULT_LIMIT, ProblemsRemainderSchema, UUID_RE, ProblemImpactSchema, PROBLEM_FEEDBACK_ACTIONS, ProblemFeedbackSchema, ProblemLinearFileSchema, SignalLabelSchema, DETECTION_VERDICTS, DetectionReviewSchema, FALSE_POSITIVE_KINDS, FalsePositiveSchema, EMOTION_FAMILIES, LAZINESS_FAMILIES, StepScoresSchema, AuditSchema, TraceFindingsSchema, FEEDBACK_USAGE, isFeedbackRefFlag, buildFeedbackRequest, writeDryRun, COMMAND_FLAG_SPECS, flagSpecFor, kebabFlag, schemaShape, describeField, specFlagKeys, specFlagNames, describeSpecFlags, closestMatches, usageLine, renderFlagHelp, subcommandHelpFlags, manifestFlagFields, requireTenant, assertFlags, assertPositionals, runUsersCommand, runUserCommand, runCohortCommand, runProblemReopenCommand, runSignalsManagementCommand, SIGNALS_MANAGEMENT_SUBCOMMANDS, unknownSignalsSubcommandError };
@@ -0,0 +1,39 @@
1
+ // src/boolean-words.ts
2
+ var BOOLEAN_TRUE_WORDS = new Set(["true", "yes", "1", "on"]);
3
+ var BOOLEAN_FALSE_WORDS = new Set(["false", "no", "0", "off"]);
4
+ function parseBooleanFlagValue(value) {
5
+ if (typeof value === "boolean")
6
+ return value;
7
+ if (typeof value === "number")
8
+ return value === 1 ? true : value === 0 ? false : undefined;
9
+ if (typeof value !== "string")
10
+ return;
11
+ const text = value.trim().toLowerCase();
12
+ if (BOOLEAN_TRUE_WORDS.has(text))
13
+ return true;
14
+ if (BOOLEAN_FALSE_WORDS.has(text))
15
+ return false;
16
+ return;
17
+ }
18
+ function flagValue(flags, name) {
19
+ return flags[name] ?? flags[name.replace(/-/g, "_")];
20
+ }
21
+ function withoutFlag(flags, name) {
22
+ const snake = name.replace(/-/g, "_");
23
+ return Object.fromEntries(Object.entries(flags).filter(([key]) => key !== name && key !== snake));
24
+ }
25
+ function optOutFlagSet(flags, name, strict = true) {
26
+ const raw = flagValue(flags, name);
27
+ if (raw === undefined)
28
+ return false;
29
+ const value = parseBooleanFlagValue(raw);
30
+ return strict ? value === true : value !== false;
31
+ }
32
+ function envSwitchedOff(value) {
33
+ return parseBooleanFlagValue(value) === false;
34
+ }
35
+ function envOptOutSet(value) {
36
+ return value !== undefined && value.trim() !== "" && parseBooleanFlagValue(value) !== false;
37
+ }
38
+
39
+ export { parseBooleanFlagValue, withoutFlag, optOutFlagSet, envSwitchedOff, envOptOutSet };
@@ -4,7 +4,7 @@ import {
4
4
  parsePromptFileForAb,
5
5
  readPromptLock,
6
6
  runPromptSync
7
- } from "./cli-4tg0hkbz.js";
7
+ } from "./cli-k5drmy8r.js";
8
8
  import {
9
9
  DEFAULT_POLL_INTERVAL_MS,
10
10
  DEFAULT_WAIT_TIMEOUT_MS,
@@ -12,7 +12,7 @@ import {
12
12
  } from "./cli-daqkdnm1.js";
13
13
  import {
14
14
  UUID_RE
15
- } from "./cli-f1jfrqgf.js";
15
+ } from "./cli-9a0a3v13.js";
16
16
  import {
17
17
  callControlAPI,
18
18
  callDataAPI
@@ -4,7 +4,7 @@ import {
4
4
  } from "./cli-pmzh2qjy.js";
5
5
  import {
6
6
  inspectPromptManifest
7
- } from "./cli-4tg0hkbz.js";
7
+ } from "./cli-k5drmy8r.js";
8
8
  import {
9
9
  readHarnessSyncState,
10
10
  renderDoctorHuman,
@@ -376,7 +376,7 @@ async function harnessCurrentCheck(cwd, manifestPath, manifestExists, tenantId)
376
376
  };
377
377
  }
378
378
  try {
379
- const { scanHarness } = await import("./harness-72ejenza.js");
379
+ const { scanHarness } = await import("./harness-1rn1hqzz.js");
380
380
  const current = scanHarness({
381
381
  rootDir: cwd,
382
382
  scannerVersion: "doctor",
@@ -4,11 +4,11 @@ import {
4
4
  } from "./cli-mm48br00.js";
5
5
  import {
6
6
  createCommandContext
7
- } from "./cli-xddtv3yn.js";
7
+ } from "./cli-5fhqfx04.js";
8
8
  import {
9
9
  assertFlags,
10
10
  assertPositionals
11
- } from "./cli-f1jfrqgf.js";
11
+ } from "./cli-9a0a3v13.js";
12
12
  import {
13
13
  callControlAPI
14
14
  } from "./cli-0xc5htv7.js";
@@ -5725,9 +5725,9 @@ async function runPromptsCommand(input, legacyFlags, legacyProfileOptions) {
5725
5725
  await promotePrompt(positionals, flags, profileOptions, context);
5726
5726
  break;
5727
5727
  case "ab":
5728
- return (await import("./prompts-ab-gmd10n5d.js")).runPromptAb(flags, profileOptions, context);
5728
+ return (await import("./prompts-ab-ws66335h.js")).runPromptAb(flags, profileOptions, context);
5729
5729
  case "propose":
5730
- await (await import("./prompts-propose-q626zmm4.js")).runPromptPropose(positionals, flags, profileOptions, context);
5730
+ await (await import("./prompts-propose-a9m0p9nr.js")).runPromptPropose(positionals, flags, profileOptions, context);
5731
5731
  break;
5732
5732
  case "list":
5733
5733
  case "show":
@@ -5830,7 +5830,7 @@ async function runPromptSyncExclusive(flags, profileOptions, options) {
5830
5830
  const analyzedDefinitions = new Map;
5831
5831
  if (flags["no-analyze"] !== "true") {
5832
5832
  options.onProgress?.("Analyzing prompt sources before sync.");
5833
- const { analyzeHarnessPrompts } = await import("./harness-72ejenza.js");
5833
+ const { analyzeHarnessPrompts } = await import("./harness-1rn1hqzz.js");
5834
5834
  const result = await analyzeHarnessPrompts({
5835
5835
  rootDir: process.cwd(),
5836
5836
  existing: established.flatMap((prompt) => prompt.sourceDefinition ? [prompt.sourceDefinition.source] : []),
@@ -5858,7 +5858,7 @@ async function runPromptSyncExclusive(flags, profileOptions, options) {
5858
5858
  const mergedSources = mergePromptSources(manifest.sources, extraSources);
5859
5859
  const manifestUpdate = stableJson(mergedSources) === stableJson(mergePromptSources(manifest.sources, [])) ? undefined : $stringify({ version: 2, prompt_paths: manifest.promptPaths, sources: mergedSources });
5860
5860
  const prompts = await discoverPrompts(extraSources);
5861
- const { checkPromptAttribution } = await import("./prompt-attribution-3987hhqz.js");
5861
+ const { checkPromptAttribution } = await import("./prompt-attribution-hc6mcvee.js");
5862
5862
  const attribution = checkPromptAttribution(process.cwd(), prompts.map((prompt) => prompt.key));
5863
5863
  const brokenAttribution = attribution.references.filter((reference) => reference.status === "missing");
5864
5864
  if (brokenAttribution.length) {
@@ -6164,7 +6164,7 @@ async function migratePromptManifest(options = {}) {
6164
6164
  let addedSources = [];
6165
6165
  let pendingSources = [];
6166
6166
  if (options.discover) {
6167
- const { analyzeHarnessPrompts } = await import("./harness-72ejenza.js");
6167
+ const { analyzeHarnessPrompts } = await import("./harness-1rn1hqzz.js");
6168
6168
  const result = await analyzeHarnessPrompts({
6169
6169
  rootDir: root,
6170
6170
  existing: manifest.sources,
@@ -44,12 +44,12 @@ import {
44
44
  import {
45
45
  createCommandContext,
46
46
  stringOption
47
- } from "./cli-xddtv3yn.js";
47
+ } from "./cli-5fhqfx04.js";
48
48
  import {
49
49
  assertFlags,
50
50
  assertPositionals,
51
51
  requireTenant
52
- } from "./cli-f1jfrqgf.js";
52
+ } from "./cli-9a0a3v13.js";
53
53
  import {
54
54
  ApiError,
55
55
  callControlAPI
@@ -14048,7 +14048,7 @@ async function runHarnessCommand(context) {
14048
14048
  throw new CliInputError("Focused remote prompt analysis is not supported yet.", "Use local --analyst=claude|codex|cursor|local-scan, or drop --concern for a full remote report.");
14049
14049
  }
14050
14050
  if (context.flags["github-actions"] === "true") {
14051
- const { runGithubActionsAnalyze } = await import("./harness-github-actions-2qc4gg2w.js");
14051
+ const { runGithubActionsAnalyze } = await import("./harness-github-actions-m95qvgbs.js");
14052
14052
  const result = await runGithubActionsAnalyze(rootDir, {
14053
14053
  writeReport: (report2) => {
14054
14054
  const normalized = normalizeHarnessReport(report2);
@@ -13,12 +13,12 @@ import {
13
13
  } from "./cli-hcwdz9sd.js";
14
14
  import {
15
15
  createCommandContext
16
- } from "./cli-xddtv3yn.js";
16
+ } from "./cli-5fhqfx04.js";
17
17
  import {
18
18
  assertFlags,
19
19
  assertPositionals,
20
20
  writeDryRun
21
- } from "./cli-f1jfrqgf.js";
21
+ } from "./cli-9a0a3v13.js";
22
22
  import {
23
23
  callControlAPI
24
24
  } from "./cli-0xc5htv7.js";