@dypt/cli 0.1.16 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -34,6 +34,21 @@ dypt task list
34
34
  dypt task list --limit 10
35
35
  ```
36
36
 
37
+ Result filters such as `--priority`, `--status`, and `--tag` describe the task
38
+ returned by the list. Branch filters describe one ancestor-or-self anchor and
39
+ include that anchor's descendants. All supplied `--branch-*` predicates must
40
+ match the same anchor:
41
+
42
+ ```bash
43
+ dypt task list --priority high --branch-tag project
44
+ dypt task list --branch-priority high --branch-tag project --branch-tag client --branch-tag-mode all
45
+ dypt task list --scope Work --branch-deadline-to 2026-08-31 --show-path
46
+ ```
47
+
48
+ Branch filtering is query-time ancestry matching. It does not copy tags,
49
+ priority, status, deadlines, or time estimates onto descendants. Run
50
+ `dypt task list --help` for the branch priority, deadline, and tag flags.
51
+
37
52
  ### Create a task
38
53
 
39
54
  Create a new task:
@@ -158,6 +173,51 @@ dypt task list --limit 10 --json
158
173
  dypt task get 123 --json
159
174
  ```
160
175
 
176
+ ### Maintenance responses
177
+
178
+ If dypt is in maintenance mode, API-backed commands stop after the first `503`
179
+ response and exit with code `75` (`EX_TEMPFAIL`). Mutations are never retried
180
+ automatically. Human output explains that no change was applied and includes
181
+ the server's `Retry-After` guidance when available.
182
+
183
+ The canonical server response combines HTTP `503`,
184
+ `X-Dypt-Maintenance: true`, `Retry-After`, and the stable
185
+ `DYPT_MAINTENANCE` response code. The CLI also normalizes an accidental HTML
186
+ `503` from a break-glass rewrite instead of reporting a JSON parse failure.
187
+
188
+ Commands invoked with `--json` write this stable retryable classification to
189
+ standard error and also exit `75`:
190
+
191
+ ```json
192
+ {
193
+ "error": {
194
+ "code": "DYPT_MAINTENANCE",
195
+ "message": "dypt is temporarily under maintenance.",
196
+ "retryable": true,
197
+ "retryAfter": "120",
198
+ "retryAfterSeconds": 120,
199
+ "noChangeApplied": true
200
+ }
201
+ }
202
+ ```
203
+
204
+ Agents may retry after the indicated delay. They should not revoke credentials,
205
+ start a new login flow, or assume that an interrupted mutation was applied.
206
+
207
+ ### Read-query throttling
208
+
209
+ Authenticated reads use an account-level weighted budget that is shared across
210
+ all CLI tokens. Normal pagination and agent inspection workflows fit within the
211
+ budget, while sustained task list, tree, search, summary, and planning traffic
212
+ consumes it faster than bounded point reads.
213
+
214
+ When the server returns `CLI_READ_RATE_LIMITED`, wait at least the reported
215
+ `retryAfterSeconds`, add backoff or jitter, and continue from the last cursor.
216
+ Rotating credentials does not increase capacity. The CLI exits with temporary
217
+ failure code `75`; `--json` emits a stable retryable error object. Read
218
+ throttling is independent of mutation throttling and per-request filter/input
219
+ bounds.
220
+
161
221
  ## Agent guidance
162
222
 
163
223
  Install or inspect dypt agent guidance for supported AI coding tools:
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { Argument, Command, Option } from "commander";
9
9
  // package.json
10
10
  var package_default = {
11
11
  name: "@dypt/cli",
12
- version: "0.1.16",
12
+ version: "0.1.18",
13
13
  description: "Command-line interface for dypt task management",
14
14
  license: "SEE LICENSE IN LICENSE",
15
15
  homepage: "https://dypt.app",
@@ -242,6 +242,156 @@ async function clearCliToken(baseUrl = getBaseUrl(), filePath = getScopedTokenFi
242
242
  // src/lib/trpc.ts
243
243
  import { createTRPCProxyClient, httpBatchLink } from "@trpc/client";
244
244
  import superjson from "superjson";
245
+
246
+ // src/lib/maintenance.ts
247
+ var DYPT_MAINTENANCE_CODE = "DYPT_MAINTENANCE";
248
+ var DYPT_MAINTENANCE_EXIT_CODE = 75;
249
+ var MAINTENANCE_HEADER = "x-dypt-maintenance";
250
+ var DyptMaintenanceError = class extends Error {
251
+ constructor(retryAfter, retryAfterSeconds) {
252
+ super("dypt is temporarily under maintenance.");
253
+ this.retryAfter = retryAfter;
254
+ this.retryAfterSeconds = retryAfterSeconds;
255
+ this.code = DYPT_MAINTENANCE_CODE;
256
+ this.retryable = true;
257
+ this.noChangeApplied = true;
258
+ this.name = "DyptMaintenanceError";
259
+ }
260
+ };
261
+ function parseRetryAfterSeconds(value) {
262
+ if (value === null) return null;
263
+ const seconds = Number(value);
264
+ if (Number.isInteger(seconds) && seconds >= 0) return seconds;
265
+ const timestamp = Date.parse(value);
266
+ if (Number.isNaN(timestamp)) return null;
267
+ return Math.max(0, Math.ceil((timestamp - Date.now()) / 1e3));
268
+ }
269
+ async function hasMaintenanceCode(response) {
270
+ const contentType = response.headers.get("content-type") ?? "";
271
+ if (!contentType.toLowerCase().includes("json")) return false;
272
+ try {
273
+ const body = await response.clone().json();
274
+ return body.code === DYPT_MAINTENANCE_CODE || typeof body.error === "object" && body.error?.code === DYPT_MAINTENANCE_CODE;
275
+ } catch {
276
+ return false;
277
+ }
278
+ }
279
+ async function getMaintenanceError(response) {
280
+ if (response.status !== 503) return null;
281
+ const hasHeader = response.headers.get(MAINTENANCE_HEADER)?.toLowerCase() === "true";
282
+ const hasCode = await hasMaintenanceCode(response);
283
+ const isHtml = (response.headers.get("content-type") ?? "").toLowerCase().includes("text/html");
284
+ if (!hasHeader && !hasCode && !isHtml) return null;
285
+ const retryAfter = response.headers.get("retry-after");
286
+ return new DyptMaintenanceError(
287
+ retryAfter,
288
+ parseRetryAfterSeconds(retryAfter)
289
+ );
290
+ }
291
+ async function fetchWithMaintenanceCheck(input, init) {
292
+ const response = await globalThis.fetch(input, init);
293
+ const maintenanceError = await getMaintenanceError(response);
294
+ if (maintenanceError) throw maintenanceError;
295
+ return response;
296
+ }
297
+ function findCliReadRateLimitError(error) {
298
+ const seen = /* @__PURE__ */ new Set();
299
+ const pending = [error];
300
+ while (pending.length > 0) {
301
+ const current = pending.shift();
302
+ if (!current || seen.has(current) || typeof current !== "object") continue;
303
+ seen.add(current);
304
+ const candidate = current;
305
+ if (candidate.code === "CLI_READ_RATE_LIMITED" && candidate.retryable === true && typeof candidate.retryAfterSeconds === "number") {
306
+ return candidate;
307
+ }
308
+ pending.push(
309
+ candidate.cause,
310
+ candidate.data,
311
+ candidate.shape,
312
+ candidate.cliError
313
+ );
314
+ }
315
+ return null;
316
+ }
317
+ function findMaintenanceError(error) {
318
+ const seen = /* @__PURE__ */ new Set();
319
+ let current = error;
320
+ while (current && !seen.has(current)) {
321
+ seen.add(current);
322
+ if (current instanceof DyptMaintenanceError) return current;
323
+ if (typeof current !== "object") return null;
324
+ const candidate = current;
325
+ if (candidate.code === DYPT_MAINTENANCE_CODE && candidate.retryable === true) {
326
+ return new DyptMaintenanceError(
327
+ typeof candidate.retryAfter === "string" ? candidate.retryAfter : null,
328
+ typeof candidate.retryAfterSeconds === "number" ? candidate.retryAfterSeconds : null
329
+ );
330
+ }
331
+ current = candidate.cause;
332
+ }
333
+ return null;
334
+ }
335
+ function formatRetryGuidance(error) {
336
+ if (error.retryAfterSeconds !== null) {
337
+ const unit = error.retryAfterSeconds === 1 ? "second" : "seconds";
338
+ return ` Retry after ${error.retryAfterSeconds} ${unit}.`;
339
+ }
340
+ if (error.retryAfter) return ` Retry after ${error.retryAfter}.`;
341
+ return " Retry later.";
342
+ }
343
+ function formatCliFailure(error, json) {
344
+ const maintenanceError = findMaintenanceError(error);
345
+ const readRateLimitError = findCliReadRateLimitError(error);
346
+ if (readRateLimitError) {
347
+ const message = "CLI read budget exhausted.";
348
+ if (json) {
349
+ return {
350
+ exitCode: DYPT_MAINTENANCE_EXIT_CODE,
351
+ output: JSON.stringify({
352
+ error: {
353
+ code: readRateLimitError.code,
354
+ message,
355
+ retryable: true,
356
+ retryAfterSeconds: readRateLimitError.retryAfterSeconds
357
+ }
358
+ })
359
+ };
360
+ }
361
+ const unit = readRateLimitError.retryAfterSeconds === 1 ? "second" : "seconds";
362
+ return {
363
+ exitCode: DYPT_MAINTENANCE_EXIT_CODE,
364
+ output: `${message} Retry after ${readRateLimitError.retryAfterSeconds} ${unit} with backoff.`
365
+ };
366
+ }
367
+ if (!maintenanceError) {
368
+ return {
369
+ exitCode: 1,
370
+ output: error instanceof Error ? error.message : String(error)
371
+ };
372
+ }
373
+ if (json) {
374
+ return {
375
+ exitCode: DYPT_MAINTENANCE_EXIT_CODE,
376
+ output: JSON.stringify({
377
+ error: {
378
+ code: maintenanceError.code,
379
+ message: maintenanceError.message,
380
+ retryable: maintenanceError.retryable,
381
+ retryAfter: maintenanceError.retryAfter,
382
+ retryAfterSeconds: maintenanceError.retryAfterSeconds,
383
+ noChangeApplied: maintenanceError.noChangeApplied
384
+ }
385
+ })
386
+ };
387
+ }
388
+ return {
389
+ exitCode: DYPT_MAINTENANCE_EXIT_CODE,
390
+ output: `${maintenanceError.message} No change was applied.${formatRetryGuidance(maintenanceError)}`
391
+ };
392
+ }
393
+
394
+ // src/lib/trpc.ts
245
395
  function resolveBaseUrl(baseUrl) {
246
396
  return (baseUrl ?? getBaseUrl()).replace(/\/$/, "");
247
397
  }
@@ -260,6 +410,7 @@ async function createCliTrpcClient(options = {}) {
260
410
  httpBatchLink({
261
411
  url: `${baseUrl}/api/trpc`,
262
412
  transformer: superjson,
413
+ fetch: fetchWithMaintenanceCheck,
263
414
  headers() {
264
415
  return accessToken ? {
265
416
  Authorization: `Bearer ${accessToken}`
@@ -270,13 +421,16 @@ async function createCliTrpcClient(options = {}) {
270
421
  });
271
422
  }
272
423
  async function postJson(path4, body, options = {}) {
273
- const response = await fetch(new URL(path4, resolveBaseUrl(options.baseUrl)), {
274
- method: "POST",
275
- headers: {
276
- "content-type": "application/json"
277
- },
278
- body: JSON.stringify(body)
279
- });
424
+ const response = await fetchWithMaintenanceCheck(
425
+ new URL(path4, resolveBaseUrl(options.baseUrl)),
426
+ {
427
+ method: "POST",
428
+ headers: {
429
+ "content-type": "application/json"
430
+ },
431
+ body: JSON.stringify(body)
432
+ }
433
+ );
280
434
  return {
281
435
  status: response.status,
282
436
  json: await response.json()
@@ -431,6 +585,7 @@ import {
431
585
  mkdtemp,
432
586
  readFile as readFile2,
433
587
  readdir,
588
+ realpath,
434
589
  rm as rm2,
435
590
  stat,
436
591
  writeFile as writeFile2
@@ -676,6 +831,11 @@ async function installAgentSkill(input) {
676
831
  const source = await resolveSource(input.source, fetchFn);
677
832
  try {
678
833
  const exists = await pathExists(targetPath);
834
+ if (exists && input.source.type === "local" && await realpath(source.skillPath) === await realpath(targetPath)) {
835
+ throw new Error(
836
+ "Local toolkit source must differ from the install path."
837
+ );
838
+ }
679
839
  const action = exists ? "update" : "install";
680
840
  const metadata = exists ? await readMetadata(targetPath) : null;
681
841
  if (exists && !input.force && !input.backup) {
@@ -780,13 +940,20 @@ async function getAgentStatus(input) {
780
940
 
781
941
  // src/commands/agent/install.ts
782
942
  function resolveSource2(input) {
783
- if (input.source === "local") {
943
+ const source = input.source ?? "github-release";
944
+ if (input.path && source !== "local") {
945
+ throw new Error("Use --path only with --source local.");
946
+ }
947
+ if (input.version && source !== "github-release") {
948
+ throw new Error("Use --version only with --source github-release.");
949
+ }
950
+ if (source === "local") {
784
951
  if (!input.path) {
785
952
  throw new Error("Use --path <local-toolkit-path> with --source local.");
786
953
  }
787
954
  return { type: "local", path: input.path };
788
955
  }
789
- if (input.source === "github-main") {
956
+ if (source === "github-main") {
790
957
  return { type: "github-main" };
791
958
  }
792
959
  return {
@@ -1115,6 +1282,20 @@ async function runTaskGet(input, deps) {
1115
1282
  }
1116
1283
 
1117
1284
  // src/commands/task/list.ts
1285
+ function getArchivedTagFilterWarnings(result) {
1286
+ if (typeof result !== "object" || result === null) return [];
1287
+ const warnings = result.warnings;
1288
+ if (!Array.isArray(warnings)) return [];
1289
+ return warnings.filter(
1290
+ (warning) => typeof warning === "object" && warning !== null && warning.code === "archived-tag-filter" && Array.isArray(warning.tagNames) && warning.tagNames.every(
1291
+ (tagName) => typeof tagName === "string"
1292
+ )
1293
+ );
1294
+ }
1295
+ function formatArchivedTagFilterWarning(tagNames) {
1296
+ const formattedNames = tagNames.map((name) => `"${name}"`).join(", ");
1297
+ return tagNames.length === 1 ? `Archived tag ${formattedNames} was ignored. Restore it before filtering.` : `Archived tags ${formattedNames} were ignored. Restore them before filtering.`;
1298
+ }
1118
1299
  async function runTaskList(input, deps) {
1119
1300
  const result = await deps.listTasks({
1120
1301
  parent: input.parent,
@@ -1138,12 +1319,20 @@ async function runTaskList(input, deps) {
1138
1319
  limit: input.limit ?? "50",
1139
1320
  cursor: input.cursor,
1140
1321
  tag: input.tag,
1141
- tagMode: input.tagMode
1322
+ tagMode: input.tagMode,
1323
+ branchPriority: input.branchPriority,
1324
+ branchDeadlineFrom: input.branchDeadlineFrom,
1325
+ branchDeadlineTo: input.branchDeadlineTo,
1326
+ branchTag: input.branchTag,
1327
+ branchTagMode: input.branchTagMode
1142
1328
  });
1143
1329
  if (input.json) {
1144
1330
  deps.printJson(result);
1145
1331
  return;
1146
1332
  }
1333
+ for (const warning of getArchivedTagFilterWarnings(result)) {
1334
+ deps.printWarning(formatArchivedTagFilterWarning(warning.tagNames));
1335
+ }
1147
1336
  deps.printTable({
1148
1337
  ...typeof result === "object" && result !== null ? result : {},
1149
1338
  meta: {
@@ -2555,6 +2744,10 @@ function printTable(value) {
2555
2744
  process.stdout.write(`${formatHumanOutput(value)}
2556
2745
  `);
2557
2746
  }
2747
+ function printWarning(message) {
2748
+ process.stderr.write(`Warning: ${message}
2749
+ `);
2750
+ }
2558
2751
  async function confirmAction(message, deps = {}) {
2559
2752
  if (deps.isTty === false) {
2560
2753
  return false;
@@ -2570,6 +2763,7 @@ async function confirmAction(message, deps = {}) {
2570
2763
  var cliVersion = package_default.version;
2571
2764
  var taskStatusChoices = ["not started", "in progress", "completed"];
2572
2765
  var taskPriorityChoices = ["low", "mid", "medium", "high"];
2766
+ var nullableTaskPriorityChoices = ["none", ...taskPriorityChoices];
2573
2767
  var agentTargetChoices = ["codex", "claude"];
2574
2768
  var agentSourceChoices = ["github-release", "github-main", "local"];
2575
2769
  var tagColourChoices = [
@@ -2608,6 +2802,9 @@ function normalizePriority(priority) {
2608
2802
  }
2609
2803
  throw new Error(`Unsupported priority: ${priority}`);
2610
2804
  }
2805
+ function normalizeNullablePriority(priority) {
2806
+ return priority === "none" ? null : normalizePriority(priority);
2807
+ }
2611
2808
  function normalizeStatus(status) {
2612
2809
  if (!status) return void 0;
2613
2810
  if (status === "not started" || status === "in progress" || status === "completed") {
@@ -2778,7 +2975,7 @@ async function promptLine(prompt) {
2778
2975
  }
2779
2976
  function buildCli() {
2780
2977
  const program = new Command();
2781
- program.name("dypt").version(cliVersion, "-V, --version");
2978
+ program.name("dypt").version(cliVersion, "-V, --version").enablePositionalOptions();
2782
2979
  const addGroupHelpAction = (command) => {
2783
2980
  command.action(() => {
2784
2981
  command.outputHelp();
@@ -3083,6 +3280,20 @@ function buildCli() {
3083
3280
  (value, values = []) => [...values, value]
3084
3281
  ).addOption(
3085
3282
  new Option("--tag-mode <mode>", "match any or all selected tags").choices(["any", "all"]).default("any")
3283
+ ).addOption(
3284
+ new Option(
3285
+ "--branch-priority <priority>",
3286
+ "require the same ancestor-or-self anchor to have this priority"
3287
+ ).choices([...nullableTaskPriorityChoices])
3288
+ ).option("--branch-deadline-from <iso>", "inclusive anchor deadline start").option("--branch-deadline-to <iso>", "inclusive anchor deadline end").option(
3289
+ "--branch-tag <name>",
3290
+ "require a tag on the same ancestor-or-self anchor; repeatable",
3291
+ (value, values = []) => [...values, value]
3292
+ ).addOption(
3293
+ new Option(
3294
+ "--branch-tag-mode <mode>",
3295
+ "match any or all branch tags on that anchor"
3296
+ ).choices(["any", "all"]).default("any")
3086
3297
  ).option("--limit <n>", "page size (1-100, default: 50)").option("--cursor <id>", "cursor task id for pagination").option("--json", "print JSON output").addHelpText(
3087
3298
  "after",
3088
3299
  [
@@ -3121,6 +3332,11 @@ function buildCli() {
3121
3332
  cursor: options.cursor,
3122
3333
  tag: options.tag,
3123
3334
  tagMode: options.tagMode,
3335
+ branchPriority: options.branchPriority,
3336
+ branchDeadlineFrom: options.branchDeadlineFrom,
3337
+ branchDeadlineTo: options.branchDeadlineTo,
3338
+ branchTag: options.branchTag,
3339
+ branchTagMode: options.branchTagMode,
3124
3340
  json: Boolean(options.json)
3125
3341
  },
3126
3342
  {
@@ -3164,6 +3380,19 @@ function buildCli() {
3164
3380
  showPath: input.showPath,
3165
3381
  tagNames: input.tag,
3166
3382
  tagMode: input.tagMode === "all" ? "all" : "any",
3383
+ branchPriority: normalizeNullablePriority(
3384
+ input.branchPriority
3385
+ ),
3386
+ branchDeadlineFrom: parseDateOption(
3387
+ input.branchDeadlineFrom,
3388
+ "start"
3389
+ ),
3390
+ branchDeadlineTo: parseDateOption(
3391
+ input.branchDeadlineTo,
3392
+ "end"
3393
+ ),
3394
+ branchTagNames: input.branchTag,
3395
+ branchTagMode: input.branchTagMode === "all" ? "all" : "any",
3167
3396
  limit: parseIntegerOption(input.limit, "limit", 1, 100),
3168
3397
  cursor: input.cursor ? {
3169
3398
  id: parseIntegerOption(input.cursor, "cursor", 1)
@@ -3171,7 +3400,8 @@ function buildCli() {
3171
3400
  });
3172
3401
  }),
3173
3402
  printJson,
3174
- printTable
3403
+ printTable,
3404
+ printWarning
3175
3405
  }
3176
3406
  );
3177
3407
  }
@@ -3417,7 +3647,8 @@ function buildCli() {
3417
3647
  deadline: options.deadline ? parseDateOption(options.deadline, "start") : void 0,
3418
3648
  expectedTimeTaken: parseIntegerOption(
3419
3649
  options.expectedTime,
3420
- "expected-time"
3650
+ "expected-time",
3651
+ 1
3421
3652
  ),
3422
3653
  note: options.note,
3423
3654
  timeBeforeDeadline: options.reminder ? parseReminderTimings(options.reminder) : void 0,
@@ -3537,11 +3768,13 @@ function buildCli() {
3537
3768
  deadline: input.deadline ? new Date(String(input.deadline)) : void 0,
3538
3769
  expectedTimeTaken: parseIntegerOption(
3539
3770
  input.expectedTimeTaken,
3540
- "expected-time"
3771
+ "expected-time",
3772
+ 1
3541
3773
  ),
3542
3774
  actualTimeTaken: parseIntegerOption(
3543
3775
  input.actualTimeTaken,
3544
- "actual-time"
3776
+ "actual-time",
3777
+ 1
3545
3778
  ),
3546
3779
  archivedAt: input.archivedAt,
3547
3780
  parentId: await resolveParentId(
@@ -3559,11 +3792,13 @@ function buildCli() {
3559
3792
  deadline: input.deadline ? new Date(String(input.deadline)) : void 0,
3560
3793
  expectedTimeTaken: parseIntegerOption(
3561
3794
  input.expectedTimeTaken,
3562
- "expected-time"
3795
+ "expected-time",
3796
+ 1
3563
3797
  ),
3564
3798
  actualTimeTaken: parseIntegerOption(
3565
3799
  input.actualTimeTaken,
3566
- "actual-time"
3800
+ "actual-time",
3801
+ 1
3567
3802
  ),
3568
3803
  archivedAt: input.archivedAt,
3569
3804
  parentId: await resolveParentId(
@@ -3639,11 +3874,13 @@ function buildCli() {
3639
3874
  deadline: input.deadline ? new Date(String(input.deadline)) : void 0,
3640
3875
  expectedTimeTaken: parseIntegerOption(
3641
3876
  input.expectedTimeTaken,
3642
- "expected-time"
3877
+ "expected-time",
3878
+ 1
3643
3879
  ),
3644
3880
  actualTimeTaken: parseIntegerOption(
3645
3881
  input.actualTimeTaken,
3646
- "actual-time"
3882
+ "actual-time",
3883
+ 1
3647
3884
  ),
3648
3885
  archivedAt: input.archivedAt,
3649
3886
  parentId: await resolveParentId(
@@ -3663,11 +3900,13 @@ function buildCli() {
3663
3900
  deadline: input.deadline ? new Date(String(input.deadline)) : void 0,
3664
3901
  expectedTimeTaken: parseIntegerOption(
3665
3902
  input.expectedTimeTaken,
3666
- "expected-time"
3903
+ "expected-time",
3904
+ 1
3667
3905
  ),
3668
3906
  actualTimeTaken: parseIntegerOption(
3669
3907
  input.actualTimeTaken,
3670
- "actual-time"
3908
+ "actual-time",
3909
+ 1
3671
3910
  ),
3672
3911
  archivedAt: input.archivedAt,
3673
3912
  parentId: await resolveParentId(
@@ -4004,12 +4243,6 @@ async function runCli(argv) {
4004
4243
  await cli.parseAsync(argv);
4005
4244
  return 0;
4006
4245
  }
4007
- function formatCliError(error) {
4008
- if (error instanceof Error) {
4009
- return error.message;
4010
- }
4011
- return String(error);
4012
- }
4013
4246
  function isCliEntrypoint(invokedPath, moduleUrl) {
4014
4247
  if (!invokedPath) {
4015
4248
  return false;
@@ -4024,13 +4257,21 @@ function isCliEntrypoint(invokedPath, moduleUrl) {
4024
4257
  return pathToFileURL(invokedPath).href === moduleUrl;
4025
4258
  }
4026
4259
  }
4260
+ async function runCliEntrypoint(argv, deps = {}) {
4261
+ try {
4262
+ return await (deps.run ?? runCli)(argv);
4263
+ } catch (error) {
4264
+ const failure = formatCliFailure(error, argv.includes("--json"));
4265
+ (deps.writeError ?? ((output) => process.stderr.write(`${output}
4266
+ `)))(
4267
+ failure.output
4268
+ );
4269
+ return failure.exitCode;
4270
+ }
4271
+ }
4027
4272
  if (isCliEntrypoint(process.argv[1], import.meta.url)) {
4028
- void runCli(process.argv).then((exitCode) => {
4273
+ void runCliEntrypoint(process.argv).then((exitCode) => {
4029
4274
  process.exitCode = exitCode;
4030
- }).catch((error) => {
4031
- process.stderr.write(`${formatCliError(error)}
4032
- `);
4033
- process.exitCode = 1;
4034
4275
  });
4035
4276
  }
4036
4277
  export {
@@ -4038,6 +4279,7 @@ export {
4038
4279
  isCliEntrypoint,
4039
4280
  resolveParentId,
4040
4281
  resolveTaskRefFromSearchMatches,
4041
- runCli
4282
+ runCli,
4283
+ runCliEntrypoint
4042
4284
  };
4043
4285
  //# sourceMappingURL=index.js.map