@moda-ai/cli 1.55.44 → 1.55.46

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 (42) hide show
  1. package/README.md +7 -8
  2. package/dist/{agent-5ax7fqhe.js → agent-aewgndk0.js} +16 -16
  3. package/dist/{cli-tztzrh6b.js → cli-4kf462jq.js} +3 -3
  4. package/dist/{cli-xcpwp0gb.js → cli-d6gfxx8t.js} +1 -1
  5. package/dist/{cli-t4xfvrry.js → cli-dxbd1xxs.js} +5 -5
  6. package/dist/{cli-wwbr5caw.js → cli-fqc02t6h.js} +12 -91
  7. package/dist/{cli-sejqvvhv.js → cli-h1z9yyqk.js} +1 -1
  8. package/dist/{cli-dmm9jm9m.js → cli-j08a1mam.js} +1 -1
  9. package/dist/{cli-8pcq2et6.js → cli-m4474bnj.js} +1 -1
  10. package/dist/{cli-xx0pjzkh.js → cli-s7d069g0.js} +5 -19
  11. package/dist/{cli-k2ka2kjb.js → cli-sqnw96gj.js} +7 -2
  12. package/dist/{cli-d4cdczhe.js → cli-x7rc3twr.js} +42 -42
  13. package/dist/{cli-5aa48ry5.js → cli-xctqdn42.js} +3 -3
  14. package/dist/cli.js +227 -630
  15. package/dist/{doctor-k4tdgvgv.js → doctor-fz5kq44d.js} +8 -8
  16. package/dist/{harness-avynbq4f.js → harness-cy0gpyhj.js} +10 -10
  17. package/dist/{harness-github-actions-gd6vyxb0.js → harness-github-actions-aac3tn96.js} +9 -9
  18. package/dist/{index-63k2a6gb.js → index-5eyq3ykt.js} +26 -26
  19. package/dist/{production-intelligence-sv3qx7f4.js → production-intelligence-8j8008d2.js} +6 -4
  20. package/dist/{profile-commands-mh3kfqkn.js → profile-commands-zbyn9xg2.js} +5 -5
  21. package/dist/{prompt-attribution-wvvnzw4m.js → prompt-attribution-g9gtv191.js} +9 -9
  22. package/dist/prompt-source-mcp.js +9 -9
  23. package/dist/{prompts-snnbyxmz.js → prompts-b6awryvv.js} +9 -13
  24. package/dist/{provision-t1dpzcjp.js → provision-xkhwz86g.js} +6 -6
  25. package/dist/{registry-8zkxefjs.js → registry-d7xdm4dw.js} +4 -4
  26. package/dist/{skills-d4215fa9.js → skills-zfenne8w.js} +6 -6
  27. package/dist/{sync-17f9yxb1.js → sync-5vd8gwte.js} +12 -12
  28. package/package.json +1 -1
  29. package/skills/integration/index.json +2 -2
  30. package/skills/moda-cli/SKILL.md +7 -10
  31. package/skills/moda-cli/references/commands.md +1 -2
  32. package/skills/moda-cli/references/dashboard-parity.md +2 -3
  33. package/skills/moda-cli/references/output-protocol.md +1 -1
  34. package/skills/moda-cli/references/production-intelligence.md +0 -4
  35. package/skills/moda-cli/references/prompts.md +1 -27
  36. package/skills/moda-cli/references/{replays-and-registry.md → registry.md} +15 -59
  37. package/dist/cli-4pc0a18x.js +0 -12
  38. package/dist/cli-8pksf2x7.js +0 -754
  39. package/dist/fix-nk5xffz8.js +0 -1440
  40. package/dist/prompts-ab-y7egdzg4.js +0 -64
  41. package/dist/prompts-propose-5nw25v9a.js +0 -256
  42. package/dist/{cli-e24fjyrb.js → cli-da3h2p6w.js} +28 -28
@@ -1,64 +0,0 @@
1
- import {
2
- DEFAULT_PROBLEM_MAX_CASES,
3
- MAX_AUTO_GENERATE_CASES,
4
- MAX_REPLAY_TRACES,
5
- PLAYOUT_CONFIRM_THRESHOLD,
6
- REPLAY_MODEL_ALLOWLIST,
7
- TERMINAL_RUN_STATUSES,
8
- assertAllowedModel,
9
- assertArmSourceShape,
10
- assertPlayoutBudget,
11
- candidateOutcome,
12
- describePlayouts,
13
- describeProblemCases,
14
- enqueueAndPollComparison,
15
- fetchProblemCases,
16
- fetchReplaySetCases,
17
- formatVerdict,
18
- parseTraceRef,
19
- planReplaySet,
20
- replayCasePin,
21
- rerunWithYes,
22
- resolvePromptArmSpec,
23
- runPromptAb,
24
- selectProblemCases,
25
- waitLabel
26
- } from "./cli-8pksf2x7.js";
27
- import"./cli-wwbr5caw.js";
28
- import"./cli-4pc0a18x.js";
29
- import"./cli-mm48br00.js";
30
- import"./cli-8pcq2et6.js";
31
- import"./cli-e0kbye4s.js";
32
- import"./cli-tztzrh6b.js";
33
- import"./cli-dmm9jm9m.js";
34
- import"./cli-e24fjyrb.js";
35
- import"./cli-k4tqwah4.js";
36
- import"./cli-9kfxkxmk.js";
37
- import"./cli-ns5fcnkz.js";
38
- import"./cli-0v6na3yp.js";
39
- export {
40
- waitLabel,
41
- selectProblemCases,
42
- runPromptAb,
43
- resolvePromptArmSpec,
44
- rerunWithYes,
45
- replayCasePin,
46
- planReplaySet,
47
- parseTraceRef,
48
- formatVerdict,
49
- fetchReplaySetCases,
50
- fetchProblemCases,
51
- enqueueAndPollComparison,
52
- describeProblemCases,
53
- describePlayouts,
54
- candidateOutcome,
55
- assertPlayoutBudget,
56
- assertArmSourceShape,
57
- assertAllowedModel,
58
- TERMINAL_RUN_STATUSES,
59
- REPLAY_MODEL_ALLOWLIST,
60
- PLAYOUT_CONFIRM_THRESHOLD,
61
- MAX_REPLAY_TRACES,
62
- MAX_AUTO_GENERATE_CASES,
63
- DEFAULT_PROBLEM_MAX_CASES
64
- };
@@ -1,256 +0,0 @@
1
- import {
2
- assertAllowedModel,
3
- assertPlayoutBudget,
4
- candidateOutcome,
5
- describePlayouts,
6
- enqueueAndPollComparison,
7
- formatVerdict,
8
- rerunWithYes,
9
- resolvePromptArmSpec
10
- } from "./cli-8pksf2x7.js";
11
- import"./cli-wwbr5caw.js";
12
- import"./cli-4pc0a18x.js";
13
- import"./cli-mm48br00.js";
14
- import"./cli-8pcq2et6.js";
15
- import"./cli-e0kbye4s.js";
16
- import"./cli-tztzrh6b.js";
17
- import {
18
- callControlAPI
19
- } from "./cli-dmm9jm9m.js";
20
- import {
21
- resolveApiTenantId,
22
- shellArg,
23
- validateConfig
24
- } from "./cli-e24fjyrb.js";
25
- import {
26
- CliInputError
27
- } from "./cli-k4tqwah4.js";
28
- import"./cli-9kfxkxmk.js";
29
- import"./cli-ns5fcnkz.js";
30
- import"./cli-0v6na3yp.js";
31
-
32
- // src/prompts-propose.ts
33
- import { writeFileSync } from "node:fs";
34
- import { isAbsolute, resolve } from "node:path";
35
- var PROPOSE_TIMEOUT_MS = 300000;
36
- async function runPromptPropose(positionals, flags, profileOptions, context) {
37
- validateConfig();
38
- const promptKey = flags["prompt-key"] || positionals[1];
39
- const fromRunId = flags["from-run"] || flags["from-run-id"] || flags["run-id"];
40
- const replaySetId = flags["set-id"] || flags["replay-set-id"];
41
- if (!promptKey || !fromRunId || !replaySetId) {
42
- throw new Error("Usage: moda prompts propose --prompt-key=<key> --from-run=<run_id> --set-id=<replay_set_id> [--max-dossiers=8] [--model=<slug>] [--out=path.prompt.md] [--gate [--seeds=1-10] [--assistant-model=<slug>] [--yes]] [--promote-on-win] [--allow-any-model]");
43
- }
44
- const maxDossiers = parsePositiveInt(flags["max-dossiers"], 8, 16, "--max-dossiers");
45
- parsePositiveInt(flags["gate-timeout"] ?? flags.timeout, 2 * 60 * 60 * 1000, 24 * 60 * 60 * 1000, flags["gate-timeout"] !== undefined ? "--gate-timeout" : "--timeout");
46
- parsePositiveInt(flags["poll-interval"], 15000, 120000, "--poll-interval");
47
- const model = assertAllowedModel(flags.model ?? flags["revise-model"], flags, "--model");
48
- const wantGate = flags.gate === "true";
49
- let gatePlan;
50
- if (wantGate) {
51
- const tenantId = flags["tenant-id"] || resolveApiTenantId(profileOptions);
52
- if (!tenantId) {
53
- throw new Error("Missing tenant id for --gate. Run `moda init` or pass --tenant-id=<id>.");
54
- }
55
- const seedsPerCase = parsePositiveInt(flags.seeds ?? flags["seeds-per-case"], 3, 10, flags.seeds !== undefined ? "--seeds" : "--seeds-per-case");
56
- const assistantModel = assertAllowedModel(flags["assistant-model"], flags, "--assistant-model");
57
- const snapshot = await fetchGateSetCases(tenantId, replaySetId, profileOptions);
58
- const cases = snapshot?.ids.length ?? null;
59
- const plannedPlayouts = cases === null ? null : cases * seedsPerCase * 2;
60
- assertPlayoutBudget(plannedPlayouts, { seedsPerCase, cases }, context.yes, rerunWithYes("prompts propose", positionals.slice(1), flags));
61
- if (context.outputMode === "human") {
62
- process.stderr.write(`Gate: ${describePlayouts(plannedPlayouts, cases, seedsPerCase)}
63
- `);
64
- }
65
- gatePlan = { tenantId, seedsPerCase, assistantModel, plannedPlayouts, cases, caseIds: snapshot?.ids };
66
- }
67
- const result = await callControlAPI(`/prompts/${encodeURIComponent(promptKey)}/propose`, {
68
- method: "POST",
69
- body: JSON.stringify({ fromRunId, replaySetId, maxDossiers, model: model || undefined })
70
- }, profileOptions, { timeoutMs: PROPOSE_TIMEOUT_MS, retries: 0 });
71
- let outPath;
72
- if (result.status === "proposed" && result.content && flags.out) {
73
- outPath = isAbsolute(flags.out) ? flags.out : resolve(process.cwd(), flags.out);
74
- writeFileSync(outPath, result.content, "utf8");
75
- }
76
- const promoteOnWin = flags["promote-on-win"] === "true";
77
- let gate;
78
- if (gatePlan) {
79
- if (result.status !== "proposed" || !result.content) {
80
- gate = {
81
- ran: false,
82
- scope: "full-set",
83
- scopeNote: `no candidate to gate (${result.status})`,
84
- verdict: "skipped",
85
- outcome: "no-run",
86
- runId: null,
87
- promoted: false,
88
- plannedPlayouts: gatePlan.plannedPlayouts
89
- };
90
- } else {
91
- gate = await runGate({
92
- result,
93
- promptKey,
94
- replaySetId,
95
- flags,
96
- plan: gatePlan,
97
- promoteOnWin,
98
- profileOptions,
99
- context
100
- });
101
- }
102
- }
103
- if (context.outputMode === "human") {
104
- printHuman(result, outPath, gate);
105
- }
106
- context.output.writeData({
107
- ...result,
108
- ...outPath ? { outPath } : {},
109
- ...gate ? { gate } : {}
110
- });
111
- }
112
- async function fetchGateSetCases(tenantId, replaySetId, profileOptions) {
113
- let set;
114
- try {
115
- set = await callControlAPI(`/tenants/${encodeURIComponent(tenantId)}/replay-sets/${encodeURIComponent(replaySetId)}`, { method: "GET" }, profileOptions);
116
- } catch (error) {
117
- if (error?.statusCode === 404) {
118
- throw new CliInputError(`Replay set '${replaySetId}' not found for tenant ${tenantId}, so nothing was sent.`, "Check --set-id: use the replay set the --from-run run was scored on (see `moda prompts replay-runs <key>`).");
119
- }
120
- return null;
121
- }
122
- if (!Array.isArray(set?.cases))
123
- return null;
124
- return {
125
- ids: set.cases.filter((c) => String(c?.scenario ?? "").trim()).map((c, index) => String(c?.id ?? `case_${index}`))
126
- };
127
- }
128
- async function runGate(args) {
129
- const { result, promptKey, replaySetId, flags, plan, promoteOnWin, profileOptions, context } = args;
130
- const { tenantId, seedsPerCase, assistantModel } = plan;
131
- const prodArm = await resolvePromptArmSpec(promptKey, "baseline", { preferKey: true });
132
- const proposedArm = {
133
- content: result.content ?? "",
134
- prompt_version_id: result.versionId ?? "",
135
- prompt_id: "",
136
- prompt_label: "candidate"
137
- };
138
- const timeoutMs = parsePositiveInt(flags["gate-timeout"] ?? flags.timeout, 2 * 60 * 60 * 1000, 24 * 60 * 60 * 1000, flags["gate-timeout"] !== undefined ? "--gate-timeout" : "--timeout");
139
- const pollIntervalMs = parsePositiveInt(flags["poll-interval"], 15000, 120000, "--poll-interval");
140
- const scopeNote = result.holdoutCaseIds.length ? `gated over the FULL replay set (${result.holdoutCaseIds.length} holdout case(s) could not be isolated — the run endpoint scores every case)` : "gated over the FULL replay set";
141
- if (context.outputMode === "human") {
142
- process.stderr.write(`
143
- Gating candidate for '${promptKey}' — ${scopeNote}...
144
- `);
145
- }
146
- const payload = await enqueueAndPollComparison({
147
- tenantId,
148
- replaySetId,
149
- promptArms: { prod: prodArm, proposed: proposedArm },
150
- seedsPerCase,
151
- assistantModel: assistantModel || undefined,
152
- promotePrimary: false,
153
- caseIds: plan.caseIds,
154
- timeoutMs,
155
- pollIntervalMs,
156
- onWaiting: context.outputMode === "human" ? (status) => process.stderr.write(`Waiting for gate run (${status})...
157
- `) : undefined
158
- }, profileOptions);
159
- const outcome = candidateOutcome(payload);
160
- const gate = {
161
- ran: true,
162
- scope: "full-set",
163
- scopeNote,
164
- verdict: formatVerdict(payload),
165
- outcome,
166
- runId: payload.run?.runId ?? null,
167
- promoted: false,
168
- plannedPlayouts: plan.plannedPlayouts
169
- };
170
- if (promoteOnWin) {
171
- if (outcome === "candidate" && result.versionId) {
172
- await callControlAPI(`/prompts/${encodeURIComponent(promptKey)}/labels`, { method: "POST", body: JSON.stringify({ label: "prod", versionId: result.versionId }) }, profileOptions);
173
- gate.promoted = true;
174
- } else {
175
- gate.promoteSkippedReason = outcome === "candidate" ? "no candidate versionId to promote" : `candidate did not strictly win (${outcome})`;
176
- }
177
- }
178
- return gate;
179
- }
180
- function printHuman(result, outPath, gate) {
181
- const w = (s) => process.stderr.write(s + `
182
- `);
183
- if (result.status !== "proposed") {
184
- w(`No candidate produced (${result.status}): ${result.note}`);
185
- return;
186
- }
187
- w(`Proposed candidate for '${result.promptKey}'`);
188
- w(` new version: ${result.versionId} (unlabeled — not promoted)`);
189
- w(` base version: ${result.baseVersionId ?? "(none)"}`);
190
- w(` from run: built from ${result.dossierCount} failure dossier(s)`);
191
- if (result.changelog)
192
- w(` changelog: ${result.changelog}`);
193
- if (result.risks.length)
194
- w(` risks: ${result.risks.map((r) => `- ${r}`).join(`
195
- `)}`);
196
- if (outPath)
197
- w(` written to: ${outPath}`);
198
- if (result.lowN) {
199
- w("");
200
- w(` ⚠ low sample: ${result.lowN}`);
201
- }
202
- w("");
203
- if (gate?.ran) {
204
- w("Gate (automatic A/B of candidate vs baseline):");
205
- w(` scope: ${gate.scopeNote}`);
206
- w(` verdict: ${gate.verdict}`);
207
- if (gate.plannedPlayouts !== undefined)
208
- w(` playouts: ${gate.plannedPlayouts ?? "unknown"} planned`);
209
- if (gate.runId)
210
- w(` run id: ${gate.runId}`);
211
- if (gate.promoted) {
212
- w(` promoted: candidate won — promoted version ${result.versionId} to label 'prod'`);
213
- } else if (gate.promoteSkippedReason) {
214
- w(` promote: skipped (${gate.promoteSkippedReason})`);
215
- }
216
- w("");
217
- if (!gate.promoted) {
218
- w(` moda prompts promote ${shellArg(result.promptKey)} --label=prod --version=${result.versionId ? shellArg(result.versionId) : "<version_id>"}`);
219
- }
220
- return;
221
- }
222
- if (gate && !gate.ran) {
223
- w(`Gate not run: ${gate.scopeNote}`);
224
- w("");
225
- }
226
- w("Next — gate on holdout cases the revision never saw, then promote if it wins:");
227
- if (result.holdoutCaseIds.length) {
228
- w(` holdout cases (${result.holdoutCaseIds.length}): ${result.holdoutCaseIds.join(", ")}`);
229
- } else {
230
- w(" (too few failures to reserve a holdout — gate on a fresh --auto-generate set)");
231
- }
232
- if (outPath) {
233
- w(` moda prompts ab --baseline-key=${shellArg(result.promptKey)} --candidate=${shellArg(outPath)} --auto-generate`);
234
- } else {
235
- w(` # re-run with --out=<path.prompt.md> to materialize the candidate, then:`);
236
- w(` moda prompts ab --baseline-key=${shellArg(result.promptKey)} --candidate=<path.prompt.md> --auto-generate`);
237
- }
238
- w(` # or: moda prompts propose ... --gate --promote-on-win (auto-A/B, promote on a strict win)`);
239
- w(` moda prompts promote ${shellArg(result.promptKey)} --label=prod --version=${result.versionId ? shellArg(result.versionId) : "<version_id>"}`);
240
- }
241
- function parsePositiveInt(raw, fallback, max, flagName) {
242
- if (raw === undefined)
243
- return fallback;
244
- const text = String(raw).trim();
245
- const parsed = Number(text);
246
- if (!/^\d+$/.test(text) || !Number.isSafeInteger(parsed) || parsed < 1) {
247
- throw new CliInputError(`${flagName}=${raw} must be a whole number of at least 1, so nothing was sent.`, `Use ${flagName}=N with 1 <= N <= ${max}.`);
248
- }
249
- if (parsed > max) {
250
- throw new CliInputError(`${flagName}=${parsed} is above the maximum of ${max}, so nothing was sent.`, `Use ${flagName}=${max} or less.`);
251
- }
252
- return parsed;
253
- }
254
- export {
255
- runPromptPropose
256
- };
@@ -1,3 +1,6 @@
1
+ import {
2
+ redactDeep
3
+ } from "./cli-ns5fcnkz.js";
1
4
  import {
2
5
  CliAccessError,
3
6
  CliAuthError,
@@ -10,9 +13,6 @@ import {
10
13
  isApiLikeError,
11
14
  isNetworkLikeError
12
15
  } from "./cli-k4tqwah4.js";
13
- import {
14
- redactDeep
15
- } from "./cli-ns5fcnkz.js";
16
16
 
17
17
  // src/profiles.ts
18
18
  import {
@@ -660,31 +660,6 @@ function validateConfig() {
660
660
  }
661
661
  }
662
662
 
663
- // src/api-key-headers.ts
664
- var PLATFORM_API_KEY_PREFIX = "moda_pk_";
665
- var TENANT_HEADER = "x-moda-tenant-id";
666
- function isPlatformApiKey(key) {
667
- return Boolean(key?.startsWith(PLATFORM_API_KEY_PREFIX));
668
- }
669
- var platformTenantOverride;
670
- function setPlatformTenantOverride(tenantId) {
671
- platformTenantOverride = tenantId;
672
- }
673
- var TENANT_PATH = /\/tenants\/([^/?#]+)/;
674
- function tenantFromUrl(url) {
675
- const match = url ? TENANT_PATH.exec(url) : null;
676
- return match ? decodeURIComponent(match[1]) : undefined;
677
- }
678
- function apiKeyHeaders(key, options = {}, url) {
679
- const headers = { "x-api-key": key };
680
- if (isPlatformApiKey(key)) {
681
- const tenantId = tenantFromUrl(url) || platformTenantOverride || resolveTenantId(options);
682
- if (tenantId)
683
- headers[TENANT_HEADER] = tenantId;
684
- }
685
- return headers;
686
- }
687
-
688
663
  // src/api-request-count.ts
689
664
  var apiRequestCount = 0;
690
665
  function recordApiRequest() {
@@ -2295,4 +2270,29 @@ function extractSuggestedCommands(text) {
2295
2270
  return commands.length > 0 ? commands : undefined;
2296
2271
  }
2297
2272
 
2273
+ // src/api-key-headers.ts
2274
+ var PLATFORM_API_KEY_PREFIX = "moda_pk_";
2275
+ var TENANT_HEADER = "x-moda-tenant-id";
2276
+ function isPlatformApiKey(key) {
2277
+ return Boolean(key?.startsWith(PLATFORM_API_KEY_PREFIX));
2278
+ }
2279
+ var platformTenantOverride;
2280
+ function setPlatformTenantOverride(tenantId) {
2281
+ platformTenantOverride = tenantId;
2282
+ }
2283
+ var TENANT_PATH = /\/tenants\/([^/?#]+)/;
2284
+ function tenantFromUrl(url) {
2285
+ const match = url ? TENANT_PATH.exec(url) : null;
2286
+ return match ? decodeURIComponent(match[1]) : undefined;
2287
+ }
2288
+ function apiKeyHeaders(key, options = {}, url) {
2289
+ const headers = { "x-api-key": key };
2290
+ if (isPlatformApiKey(key)) {
2291
+ const tenantId = tenantFromUrl(url) || platformTenantOverride || resolveTenantId(options);
2292
+ if (tenantId)
2293
+ headers[TENANT_HEADER] = tenantId;
2294
+ }
2295
+ return headers;
2296
+ }
2297
+
2298
2298
  export { PROD_BASE_URL, DEFAULT_INGEST_URL, getModaPaths, getModaDir, isLoopbackBaseUrl, describeBaseUrlSource, loadProfileConfig, saveProfileConfig, getActiveProfile, setActiveProfile, upsertProfile, clearStoredApiKeyCredentials, secretFilePathFromRef, resolveSecretReference, resolveApiKeyFromActiveProfile, resolveTenantIdFromActiveProfile, ensureSecretFilePermissions, writeSecretJsonFile, VERSION, MODA_BASE_URL, loadCliConfig, saveCliConfig, resolveApiKey, embeddedTenantIdFromApiKey, resolveIngestUrl2 as resolveIngestUrl, resolveTenantId, resolveApiTenantId, resolveModaBaseUrl, describeModaBaseUrl, refusedBaseUrlMessage, resolveModaBaseUrlStrict, validateConfig, isPlatformApiKey, setPlatformTenantOverride, apiKeyHeaders, recordApiRequest, getApiRequestCount, resetApiRequestCount, shellArg, apiForbiddenReason, errorBodyFields, apiForbiddenError, LEGACY_NAMES, canonicalCommandText, setAgentUpdateNotice, EXIT_OK, EXIT_ERROR, EXIT_DEGRADED, EXIT_AUTH_REQUIRED, EXIT_INPUT_REQUIRED, EXIT_CANCELLED, AGENT_ERROR_CODES, wasOutputCancelled, safeWriteStdout, safeWriteStderr, explicitOutputMode, outputModeFromFlags, resolveOutputMode, createCliOutput, agentEnvelopeFits, errorToAgentError, agentMaxOutputBytes, continuationCommand };