@wirecat/cli-core 0.729.0 → 0.731.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/dist/background/daily-archive-timer.d.ts +1 -1
  3. package/dist/cli/documents/catalog.js +6 -3
  4. package/dist/cli/documents/documents.js +3 -2
  5. package/dist/cli/documents/file-conflicts.js +15 -2
  6. package/dist/cli/documents/file-edit.js +7 -2
  7. package/dist/cli/documents/folders.js +2 -1
  8. package/dist/cli/documents/history.js +3 -2
  9. package/dist/cli/documents/index.d.ts +1 -0
  10. package/dist/cli/documents/index.js +1 -0
  11. package/dist/cli/documents/knowledge.js +6 -2
  12. package/dist/cli/documents/library.js +9 -2
  13. package/dist/cli/documents/search.js +4 -1
  14. package/dist/cli/untrusted-marks.d.ts +10 -0
  15. package/dist/cli/untrusted-marks.js +19 -0
  16. package/dist/documents/model.d.ts +2 -0
  17. package/dist/domain/tracker.d.ts +2 -0
  18. package/dist/domain/tracker.js +2 -0
  19. package/dist/services/documents/plan.js +36 -10
  20. package/dist/services/index.d.ts +1 -0
  21. package/dist/services/index.js +1 -0
  22. package/dist/services/notes-search.d.ts +13 -2
  23. package/dist/services/notes-search.js +2 -2
  24. package/dist/services/search-all.d.ts +5 -0
  25. package/dist/services/search-all.js +76 -6
  26. package/dist/services/tracker-meaning.d.ts +17 -0
  27. package/dist/services/tracker-meaning.js +27 -0
  28. package/dist/store/exports.d.ts +1 -1
  29. package/dist/store/sqlite/tracker-chunks.d.ts +52 -0
  30. package/dist/store/sqlite/tracker-chunks.js +190 -0
  31. package/dist/store/sqlite/tracker.d.ts +37 -0
  32. package/dist/store/sqlite/tracker.js +50 -4
  33. package/dist/tracker/cli/index.d.ts +6 -3
  34. package/dist/tracker/cli/index.js +82 -12
  35. package/dist/tracker/cli/writes.d.ts +2 -2
  36. package/dist/tracker/cli/writes.js +18 -12
  37. package/dist/tracker/writer.d.ts +1 -1
  38. package/dist/tracker/writer.js +3 -4
  39. package/dist/tracker/writes.d.ts +1 -1
  40. package/dist/tracker/writes.js +14 -13
  41. package/package.json +2 -2
@@ -9,12 +9,16 @@ import { FETCH, LOCAL_READ, LOCAL_WRITE, NO_EFFECTS } from "../../cli/effects.js
9
9
  import { itemOf, listOf, renderAnswer } from "../../cli/envelope.js";
10
10
  import { listQuery, nativeTermLists, queryTerms, termField, typedQuery, withQuery } from "../../cli/list-query.js";
11
11
  import { aheadOf } from "../../domain/moment.js";
12
- import { STATE_TYPES, TRACKER_KINDS, } from "../../domain/tracker.js";
12
+ import { STATE_TYPES, TRACKER_KINDS, TRACKER_PRIORITY_LABELS, } from "../../domain/tracker.js";
13
13
  import { count, text } from "../../entities/fields.js";
14
+ import { embedTracker } from "../../services/tracker-meaning.js";
14
15
  import { syncTracker } from "../sync.js";
15
16
  import { trackerIssueTask } from "../tasks.js";
16
17
  import { addTrackerWriteCommands } from "./writes.js";
17
18
  const MOST = 500;
19
+ // The documents' own answer has a `skipped` list of files; a part that did not run says why in a string.
20
+ const isSkipped = (item) => typeof item.skipped === "string";
21
+ const EMBED_MAX = 600;
18
22
  const integer = (most) => (value) => {
19
23
  const number = Number(value);
20
24
  if (!Number.isSafeInteger(number) || number < 1 || number > most)
@@ -90,6 +94,14 @@ const trackerSync = v.strictObject({
90
94
  v.strictObject({ opened: count, closed: count, reopened: count, renamed: count }),
91
95
  v.strictObject({ skipped: text }),
92
96
  ])),
97
+ /** What `sync --embed` embedded of the issues, projects and comments: `embedTracker`'s answer. */
98
+ embeddings: v.optional(v.strictObject({
99
+ model: text,
100
+ embedded: count,
101
+ left: v.boolean(),
102
+ stopped: v.optional(v.picklist(["deadline", "cancelled"])),
103
+ remaining: v.optional(count),
104
+ })),
93
105
  });
94
106
  const partError = v.strictObject({ code: text, reason: v.optional(text), message: text });
95
107
  /** The tracker's answer as `tracker_sync` has it, or the error it failed with, and the documents' answer or error. */
@@ -109,7 +121,11 @@ const resumeStep = (opts, why, extra = {}) => ({
109
121
  kind: "command",
110
122
  step: "tracker.sync",
111
123
  command: "sync",
112
- args: { ...(opts.maxPages === undefined ? {} : { max_pages: opts.maxPages }), ...extra },
124
+ args: {
125
+ ...(opts.maxPages === undefined ? {} : { max_pages: opts.maxPages }),
126
+ ...(opts.embed ? { embed: true } : {}),
127
+ ...extra,
128
+ },
113
129
  why,
114
130
  safe_to_auto_execute: true,
115
131
  });
@@ -132,8 +148,13 @@ const trackerNext = (report, opts) => report.state === "partial" && report.progr
132
148
  : "the sync stopped before its end; running it again goes on from there"),
133
149
  ]
134
150
  : [];
135
- const trackerAnswer = (report, opts) => {
136
- const issues = trackerIssues(report);
151
+ /** Why `--embed` failed after the sync saved its report: a model not downloaded. */
152
+ const embeddingIssue = (error) => {
153
+ const { code, reason } = errorOf(error);
154
+ return { code, reason: reason ?? "sync.failed", source: "tracker:embeddings" };
155
+ };
156
+ const trackerAnswer = (report, opts, embedError) => {
157
+ const issues = [...trackerIssues(report), ...(embedError === undefined ? [] : [embeddingIssue(embedError)])];
137
158
  const next = trackerNext(report, opts);
138
159
  return itemOf(report, {
139
160
  ...(report.state === "partial" || issues.length
@@ -156,7 +177,7 @@ const errorOf = (error) => {
156
177
  * Both parts in one answer: the tracker's report as `tracker_sync` has it, the documents' under `documents`. A part
157
178
  * that fails is named in its place and in `meta.issues`, so the other's answer still shows; `complete` is both parts'.
158
179
  */
159
- const combinedAnswer = (tracker, documents, opts) => {
180
+ const combinedAnswer = (tracker, documents, opts, embedError) => {
160
181
  const failed = (part, error) => ({
161
182
  code: error.code,
162
183
  reason: error.reason ?? "sync.failed",
@@ -169,6 +190,7 @@ const combinedAnswer = (tracker, documents, opts) => {
169
190
  const issues = [
170
191
  ...(report ? trackerIssues(report) : []),
171
192
  ...(trackerError ? [failed("tracker", trackerError)] : []),
193
+ ...(embedError === undefined ? [] : [embeddingIssue(embedError)]),
172
194
  ...(outcome?.meta.issues ?? []),
173
195
  ...(documentsError ? [failed("documents", documentsError)] : []),
174
196
  ];
@@ -180,7 +202,6 @@ const combinedAnswer = (tracker, documents, opts) => {
180
202
  ? [
181
203
  resumeStep(opts, trackerStep?.why ?? "the sync stopped before its end; running it again goes on from there", {
182
204
  ...(opts.timeout === undefined ? {} : { timeout: opts.timeout }),
183
- ...(opts.embed ? { embed: true } : {}),
184
205
  }),
185
206
  ]
186
207
  : []),
@@ -213,8 +234,11 @@ const withNames = async (run, items) => {
213
234
  const assignee = item.record.assignee
214
235
  ? users.get(item.record.assignee)
215
236
  : undefined;
237
+ const { priority } = item.record;
216
238
  return viewOf(item, {
217
239
  ...(state ? { state_name: state.name, state_type: state.type } : {}),
240
+ // Beside the tracker's number, the family's word, which --priority takes back.
241
+ ...(typeof priority === "number" ? { priority_label: TRACKER_PRIORITY_LABELS[priority] ?? null } : {}),
218
242
  ...(assignee ? { assignee_name: assignee.name } : {}),
219
243
  ...(item.record.assignee && people.has(item.record.assignee)
220
244
  ? { assignee_person: people.get(item.record.assignee) }
@@ -255,6 +279,21 @@ const addTrackerCommandsDefinition = (program, options) => {
255
279
  ...(opts.rescan ? { rescan: true } : {}),
256
280
  });
257
281
  };
282
+ // A run its budget stopped has no time left for the model; the run that finishes the round embeds.
283
+ const embedOf = async (command, run, report) => {
284
+ if (report.stopped)
285
+ return report;
286
+ const { signal, env } = environmentOf(command);
287
+ const deadline = environmentOf(command).deadline?.();
288
+ const embeddings = await embedTracker(run.store, {
289
+ maxChunks: EMBED_MAX,
290
+ ...(deadline ? { deadline } : {}),
291
+ ...(signal ? { signal } : {}),
292
+ ...(env ? { env } : {}),
293
+ command: options.app.command,
294
+ });
295
+ return { ...report, embeddings };
296
+ };
258
297
  const trackerPart = (command, opts, opened = () => { }) => inCommandRun(command, async () => {
259
298
  const run = await options.open(command, { readOnly: false });
260
299
  opened(run.account);
@@ -283,12 +322,28 @@ const addTrackerCommandsDefinition = (program, options) => {
283
322
  ? "at most this many requests for the issues in this run, and as many for the documents"
284
323
  : "at most this many requests to the tracker in this run", integer(100_000));
285
324
  if (!documents)
286
- sync.action(async (opts, command) => {
287
- await within(command, false, async (run) => trackerAnswer(await syncOf(command, opts)(run), opts));
325
+ sync
326
+ .option("--embed", "also index new issues, projects and comments for meaning search, with a model already downloaded")
327
+ .action(async (opts, command) => {
328
+ await within(command, false, async (run) => {
329
+ const report = await syncOf(command, opts)(run);
330
+ if (!opts.embed)
331
+ return trackerAnswer(report, opts);
332
+ try {
333
+ return trackerAnswer(await embedOf(command, run, report), opts);
334
+ }
335
+ catch (error) {
336
+ // What the sync saved is answered; a cancel still ends the command.
337
+ if (environmentOf(command).signal?.aborted)
338
+ throw error;
339
+ return trackerAnswer(report, opts, error);
340
+ }
341
+ });
288
342
  });
289
343
  else
290
344
  sync
291
- .option("--embed", "also index the documents' pending text for meaning search, with a model already downloaded")
345
+ .option("--embed", "also index new issues, projects and comments and the documents' pending text for meaning search, with a " +
346
+ "model already downloaded")
292
347
  .addOption(new Option("--limit <n>", "refused: it would count documents only").hideHelp().argParser(() => {
293
348
  throw new InvalidArgumentError("--limit counts documents only, and this sync brings the issues too; --max-pages bounds both parts");
294
349
  }))
@@ -314,6 +369,21 @@ const addTrackerCommandsDefinition = (program, options) => {
314
369
  ...(opts.embed ? { embed: true } : {}),
315
370
  ...(deadline ? { deadline } : {}),
316
371
  }));
372
+ // A skipped documents part did not run, so a failed tracker part is the whole answer, as without documents.
373
+ if ("error" in tracker && "value" in docs && isSkipped(docs.value.item))
374
+ throw tracker.error;
375
+ // After both parts, so the documents get their sync's time first; outside the tracker's run, which has ended.
376
+ const embedded = opts.embed && "value" in tracker
377
+ ? await settled(async () => {
378
+ const run = await options.open(command, { readOnly: false });
379
+ try {
380
+ return await embedOf(command, run, tracker.value);
381
+ }
382
+ finally {
383
+ await run.close?.();
384
+ }
385
+ })
386
+ : undefined;
317
387
  if ("error" in tracker && "error" in docs) {
318
388
  const failed = errorOf(docs.error);
319
389
  // An error envelope has no meta and keeps only the details its reason registers, so the documents'
@@ -324,7 +394,7 @@ const addTrackerCommandsDefinition = (program, options) => {
324
394
  : tracker.error;
325
395
  }
326
396
  const timeout = command.optsWithGlobals().timeout;
327
- const answer = combinedAnswer(tracker, docs, { ...opts, ...(timeout === undefined ? {} : { timeout }) });
397
+ const answer = combinedAnswer(embedded && "value" in embedded ? embedded : tracker, docs, { ...opts, ...(timeout === undefined ? {} : { timeout }) }, embedded && "error" in embedded ? embedded.error : undefined);
328
398
  renderAnswer(command, outputFor(command), answer);
329
399
  if ("value" in docs)
330
400
  for (const line of docs.value.diagnostics)
@@ -447,7 +517,7 @@ const addTrackerCommandsDefinition = (program, options) => {
447
517
  }
448
518
  };
449
519
  /**
450
- * The tracker's commands: `sync`, `issues list|show|search|assign`, `issues create|update|comment` for the writes in
451
- * `writes`, and a `list` of each other kind.
520
+ * The tracker's commands: `sync`, `issues list|show|search|assign`, `issues create|update` and
521
+ * `issues comments create` for the writes in `writes`, and a `list` of each other kind.
452
522
  */
453
523
  export const addTrackerCommands = honoursDryRun(sharedCommand(addTrackerCommandsDefinition));
@@ -2,7 +2,7 @@ import type { Command } from "commander";
2
2
  import type * as v from "valibot";
3
3
  import { type Body } from "../../cli/envelope.js";
4
4
  import type { TrackerItem } from "../../store/sqlite/tracker.js";
5
- import type { TrackerWrite } from "../writer.js";
5
+ import { type TrackerWrite } from "../writer.js";
6
6
  import { type TrackerWriteContext, type TrackerWrites } from "../writes.js";
7
7
  /** What the writes need of the open profile: the shared `TrackerRun` and its writes, built for the command run. */
8
8
  interface WriteRun {
@@ -22,6 +22,6 @@ export interface TrackerWriteCommandOptions<R extends WriteRun> {
22
22
  answer: v.GenericSchema;
23
23
  now: () => number;
24
24
  }
25
- /** `issues create|update|comment` for each write the tracker takes, under the `issues` group. */
25
+ /** `issues create|update` and `issues comments create`, for each write the tracker takes, under the `issues` group. */
26
26
  export declare const addTrackerWriteCommands: <R extends WriteRun>(issues: Command, options: TrackerWriteCommandOptions<R>) => void;
27
27
  export {};
@@ -1,17 +1,20 @@
1
1
  import { CliError } from "@wirecat/cli-base";
2
2
  import { annotate } from "@wirecat/cli-base/commands";
3
3
  import { answerEntity } from "../../cli/answer-entity.js";
4
- import { REMOTE_WRITE } from "../../cli/effects.js";
4
+ import { NO_EFFECTS, REMOTE_WRITE } from "../../cli/effects.js";
5
5
  import { itemOf } from "../../cli/envelope.js";
6
6
  import { terminalAsker } from "../../cli/messenger/ask.js";
7
+ import { markRenamedPermissionKeys } from "../../cli/permission-keys.js";
8
+ import { TRACKER_WRITE_KEYS } from "../writer.js";
7
9
  import { commentTrackerIssue, createTrackerIssue, updateTrackerIssue, } from "../writes.js";
8
10
  const collect = (value, previous = []) => [...previous, value];
9
- const inputOf = ({ label, ...rest }) => ({
11
+ const inputOf = ({ label, status, ...rest }) => ({
10
12
  ...Object.fromEntries(Object.entries(rest).filter(([, value]) => value !== undefined)),
13
+ ...(status === undefined ? {} : { state: status }),
11
14
  // The empty default marks the flag as repeatable; left empty, the labels are not changed.
12
15
  ...(label?.length ? { labels: label } : {}),
13
16
  });
14
- /** `issues create|update|comment` for each write the tracker takes, under the `issues` group. */
17
+ /** `issues create|update` and `issues comments create`, for each write the tracker takes, under the `issues` group. */
15
18
  export const addTrackerWriteCommands = (issues, options) => {
16
19
  const contextOf = (run, command) => {
17
20
  if (!run.writes)
@@ -33,20 +36,20 @@ export const addTrackerWriteCommands = (issues, options) => {
33
36
  untrusted: shown.untrusted.map((field) => `${kind}.${field}`),
34
37
  });
35
38
  };
36
- const write = (name, description) => answerEntity(annotate(issues.command(name), { effects: REMOTE_WRITE, offline: false }), "tracker_write", options.answer).description(description);
39
+ const write = (group, name, description) => answerEntity(annotate(group.command(name), { effects: REMOTE_WRITE, offline: false }), "tracker_write", options.answer).description(description);
37
40
  const fields = (command) => command
38
41
  .option("--description <text>", "the issue's text; an empty value clears it")
39
42
  .option("--team <team>", "the team, by its id, key or name; left out, the copy's only team")
40
- .option("--state <state>", "the workflow state, by its id or a name only one of the team's states has")
41
43
  .option("--assignee <user>", "the user, by id, name or e-mail; empty for none; anyone but you checks issues.assign-others")
42
- .option("--priority <priority>", "0 to 4, or none, urgent, high, medium, low; empty for none")
44
+ .option("--priority <n>", "critical or urgent (1), high (2), medium (3), low (4), none or empty (0), a 0.0–1.0 score or the old 0–4")
45
+ .option("--status <state>", "the workflow state, by its id or a name only one of the team's states has")
43
46
  .option("--label <label>", "a label by its id or name; repeat it for each; replaces the issue's labels, and one empty value clears them", collect, [])
44
47
  .option("--project <project>", "the project, by its id or name; empty for none")
45
- .option("--parent <issue>", "the issue this one is part of, by its key or id; empty for none");
48
+ .option("--parent <id>", "the issue this one is part of, by its key or id; empty for none");
46
49
  const reference = (command) => command.argument("<issue>", "the issue's key (ENG-12) or id");
47
50
  if (options.writes.includes("create"))
48
51
  options
49
- .example(fields(write("create", "make an issue in the tracker, then store the tracker's copy of it").requiredOption("--title <title>", "the issue's title")), 'issues create --title "Example: invoices fail for EUR" --team ENG --label Bug', 'issues create --title "Example: write the guide" --assignee ada@example.com --priority high')
52
+ .example(fields(write(issues, "create", "make an issue in the tracker, then store the tracker's copy of it").requiredOption("--title <title>", "the issue's title")), 'issues create --title "Example: invoices fail for EUR" --team ENG --label Bug', 'issues create --title "Example: write the guide" --assignee ada@example.com --priority high')
50
53
  .action(async (typed, command) => {
51
54
  await options.within(command, false, async (run) => {
52
55
  const done = await createTrackerIssue(contextOf(run, command), inputOf(typed));
@@ -55,20 +58,23 @@ export const addTrackerWriteCommands = (issues, options) => {
55
58
  });
56
59
  if (options.writes.includes("update"))
57
60
  options
58
- .example(fields(reference(write("update", "change an issue in the tracker; what is left out keeps its value; the tracker's copy is stored again")).option("--title <title>", "the issue's title")), 'issues update ENG-12 --state "In Progress"', 'issues update ENG-12 --assignee ""')
61
+ .example(fields(reference(write(issues, "update", "change an issue in the tracker; what is left out keeps its value; the tracker's copy is stored again")).option("--title <title>", "the issue's title")), 'issues update ENG-12 --status "In Progress"', 'issues update ENG-12 --assignee ""')
59
62
  .action(async (issue, typed, command) => {
60
63
  await options.within(command, false, async (run) => {
61
64
  const done = await updateTrackerIssue(contextOf(run, command), issue, inputOf(typed));
62
65
  return answered(run, done.operationId, "issue", done.issue);
63
66
  });
64
67
  });
65
- if (options.writes.includes("comment"))
68
+ if (options.writes.includes("comment")) {
69
+ const comments = annotate(issues.command("comments"), { effects: NO_EFFECTS }).description("comments on the tracker's issues; issues show lists an issue's");
70
+ markRenamedPermissionKeys(comments, new Map([["issues.comment", TRACKER_WRITE_KEYS.comment]]));
66
71
  options
67
- .example(reference(write("comment", "add a comment to an issue in the tracker, then store it")).requiredOption("--body <text>", "the comment, as it is to read"), 'issues comment ENG-12 --body "Example: fixed in the next release"')
72
+ .example(reference(write(comments, "create", "add a comment to an issue in the tracker, then store it")).requiredOption("--text <text>", "the comment, as it is to read"), 'issues comments create ENG-12 --text "Example: fixed in the next release"')
68
73
  .action(async (issue, typed, command) => {
69
74
  await options.within(command, false, async (run) => {
70
- const done = await commentTrackerIssue(contextOf(run, command), issue, typed.body);
75
+ const done = await commentTrackerIssue(contextOf(run, command), issue, typed.text);
71
76
  return answered(run, done.operationId, "comment", done.comment);
72
77
  });
73
78
  });
79
+ }
74
80
  };
@@ -35,7 +35,7 @@ export interface TrackerWriteOptions {
35
35
  */
36
36
  export interface TrackerWriter {
37
37
  readonly provider: string;
38
- /** What this tracker takes: `issues create`, `issues update` and `issues comment` are mounted for these. */
38
+ /** What this tracker takes: `issues create`, `issues update` and `issues comments create` are mounted for these. */
39
39
  readonly writes: readonly TrackerWrite[];
40
40
  createIssue(draft: TrackerIssueDraft, options: TrackerWriteOptions): Promise<TrackerIssue>;
41
41
  updateIssue(externalId: string, patch: TrackerIssueFields, options: TrackerWriteOptions): Promise<TrackerIssue>;
@@ -3,7 +3,7 @@ export const TRACKER_WRITES = ["create", "update", "comment"];
3
3
  export const TRACKER_WRITE_KEYS = {
4
4
  create: "issues.create",
5
5
  update: "issues.update",
6
- comment: "issues.comment",
6
+ comment: "issues.comments.create",
7
7
  };
8
8
  /** Giving an issue to a tracker user other than the one the sign-in acts as, as `crm.assign-others` for a CRM. */
9
9
  export const TRACKER_ASSIGN_OTHERS_KEY = "issues.assign-others";
@@ -16,9 +16,8 @@ export const TRACKER_WRITE_DEFAULTS = { [TRACKER_ASSIGN_OTHERS_KEY]: "deny" };
16
16
  * `--dry-run` names each: `also` adds the CLI's own, such as the `api.*` key of the mutation it sends.
17
17
  */
18
18
  export const trackerAlsoChecks = (also) => (path) => {
19
- const [noun, command] = path;
20
- const write = TRACKER_WRITES.find((one) => one === command);
21
- if (path.length !== 2 || noun !== "issues" || write === undefined)
19
+ const write = TRACKER_WRITES.find((one) => TRACKER_WRITE_KEYS[one] === path.join("."));
20
+ if (write === undefined)
22
21
  return [];
23
22
  const assign = { key: TRACKER_ASSIGN_OTHERS_KEY, when: "--assignee other than the sign-in's user" };
24
23
  return [...(write === "comment" ? [] : [assign]), ...(also?.(write) ?? [])];
@@ -29,7 +29,7 @@ export interface TrackerIssueInput {
29
29
  team?: string;
30
30
  state?: string;
31
31
  assignee?: string;
32
- /** 0 to 4, or none, urgent, high, medium, low. */
32
+ /** The family's priority: a label, none, a 0.0–1.0 score or the old 0–4; urgent is critical. */
33
33
  priority?: string;
34
34
  labels?: readonly string[];
35
35
  project?: string;
@@ -1,12 +1,13 @@
1
1
  import { CliError, isCliError } from "@wirecat/cli-base";
2
+ import { TRACKER_PRIORITY_LABELS } from "../domain/tracker.js";
2
3
  import { foldName } from "../resolve.js";
3
4
  import { guardedWrite } from "../sends/guarded.js";
4
5
  import { askedKeys, profileWriteGuard } from "../sends/profile-writes.js";
5
6
  import { newOperationId } from "../sends/send-id.js";
7
+ import { priorityLabel, priorityOf } from "../tasks/index.js";
6
8
  import { trackerSelfOf } from "./sync.js";
7
9
  import { TRACKER_ASSIGN_OTHERS_KEY, TRACKER_WRITE_DEFAULTS, TRACKER_WRITE_KEYS, } from "./writer.js";
8
10
  const PAGE = 500;
9
- const PRIORITIES = { none: 0, urgent: 1, high: 2, medium: 3, low: 4 };
10
11
  const PLURALS = { team: "teams", user: "users", state: "states", label: "labels", project: "projects" };
11
12
  const invalid = (message, param, details = {}) => new CliError("validation_error", message, { reason: "tracker.field", ...(param ? { param } : {}), ...details });
12
13
  const supported = (writer, write) => {
@@ -88,15 +89,15 @@ export const trackerIssueOf = async (context, reference, param = "<issue>") => {
88
89
  throw new CliError("not_found", `no issue ${reference} in the copy; run sync, then try again`, { param });
89
90
  return found;
90
91
  };
91
- /** An empty value clears it, as for every other field: 0 is the tracker's "no priority". */
92
- const priorityOf = (typed) => {
93
- if (typed.trim() === "")
94
- return 0;
95
- const word = PRIORITIES[typed.trim().toLowerCase()];
96
- const number = word ?? Number(typed);
97
- if (!Number.isInteger(number) || number < 0 || number > 4)
98
- throw invalid("--priority is 0 to 4, or none, urgent, high, medium, low", "--priority");
99
- return number;
92
+ /** The family's priority (`priorityOf`, and the tracker's own `urgent`) on the tracker's 0 none, 1 urgent … 4 low. */
93
+ const trackerPriorityOf = (typed) => {
94
+ const word = typed.trim().toLowerCase() || "none";
95
+ try {
96
+ return TRACKER_PRIORITY_LABELS.indexOf(priorityLabel(priorityOf(word === "urgent" ? "critical" : word)));
97
+ }
98
+ catch (error) {
99
+ throw isCliError(error) ? invalid(error.message, "--priority") : error;
100
+ }
100
101
  };
101
102
  /** Typed fields into the port's, each reference resolved in the copy; `team` is the issue's, for its states. */
102
103
  const fieldsOf = async (context, input, team, self) => {
@@ -113,13 +114,13 @@ const fieldsOf = async (context, input, team, self) => {
113
114
  fields.team = team;
114
115
  if (input.state !== undefined) {
115
116
  if (cleared(input.state))
116
- throw invalid("every issue is in a state; name one", "--state");
117
- fields.state = await referenceOf(context, "state", input.state, "--state", team);
117
+ throw invalid("every issue is in a state; name one", "--status");
118
+ fields.state = await referenceOf(context, "state", input.state, "--status", team);
118
119
  }
119
120
  if (input.assignee !== undefined)
120
121
  fields.assignee = cleared(input.assignee) ? null : await referenceOf(context, "user", input.assignee, "--assignee");
121
122
  if (input.priority !== undefined)
122
- fields.priority = priorityOf(input.priority);
123
+ fields.priority = trackerPriorityOf(input.priority);
123
124
  if (input.labels !== undefined)
124
125
  fields.labels =
125
126
  input.labels.length === 1 && cleared(input.labels[0])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-core",
3
- "version": "0.729.0",
3
+ "version": "0.731.0",
4
4
  "description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Viacheslav Ptsarev",
@@ -334,7 +334,7 @@
334
334
  "@types/pngjs": "6.0.5",
335
335
  "@types/ssh2": "1.15.5",
336
336
  "@vitest/coverage-v8": "^5.0.5",
337
- "@wirecat/cli-base": "0.131.0",
337
+ "@wirecat/cli-base": "0.132.0",
338
338
  "@wirecat/cli-core-legacy-tags": "npm:@wirecat/cli-core@0.414.0",
339
339
  "ajv": "8.17.1",
340
340
  "commander": "15.0.0",