@wirecat/cli-core 0.724.0 → 0.726.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,56 @@ Notable changes to `@wirecat/cli-core` (`@wirecat/cli-messaging` up to 0.261.0,
5
5
  minor version may break callers, and says how under "Changed — may break callers". `pnpm docs:check` checks the
6
6
  shape of this file.
7
7
 
8
+ ## 0.726.0 — 23.11.2026
9
+
10
+ ### Added
11
+
12
+ - `CrmWrites.ownedByDefault`: a new item of these kinds is the sign-in's user's when no `--owner` is given, as Attio
13
+ needs for a deal. With no user known, the create is refused before anything is sent.
14
+ - `CrmWrites.self` may be a function, asked only when a write needs the sign-in's user, so a CLI whose sign-in does
15
+ not name that user still checks `--owner` against it.
16
+
17
+ ### Fixed
18
+
19
+ - A manifest write that merges a name from its parts sends a cleared part as an empty string beside the given ones,
20
+ as Attio's name needs all three parts: `--name Madonna` and a lone `--first-name` are no longer refused.
21
+
22
+ ## 0.725.0 — 23.11.2026
23
+
24
+ ### Added
25
+
26
+ - **`search all` finds a tracker's issues, projects and comments.** A new lane, `tracker`, reads every tracker
27
+ account's copy by the words of titles and text, as `issues search` does, beside messages, mail, notes and the rest.
28
+ Hits are `issue` (titled with the key, `ENG-12 Fix login`), `project` and `issue_comment`, with ref
29
+ `tracker:<provider>/<account>/<kind>/<id>`, their title and excerpt untrusted. A provider kind `tracker` joins the
30
+ registry, and `linear` is seeded as one. A CLI that gates `search all` lanes by list keys gates issues and comments
31
+ by `issues.list` and projects by `projects.list`: memo needs that gate in the bump that brings this lane
32
+ ([TRACKER.md](docs/dev/TRACKER.md#search-all)).
33
+
34
+ ### Changed — may break callers
35
+
36
+ - **`mirrors conflicts resolve` runs inside the app's run.** `FileConflictCommands.connect(command, mirror, body)` now
37
+ takes the body and runs it inside the app's run, so a resolve is bounded by `--timeout`, kept by `--record` under its
38
+ own name, and its requests land in that run. Before, `connect` answered the connection and the resolve ran outside
39
+ any run. A CLI that mounts `fileConflictsCommand` wraps `body(connection)` in its own run, as its `mirrors sync`
40
+ does; `FileConflictConnection` is the type it hands over (#3230).
41
+ - **The Office edit refusals keep their own reason, spelled like every other reason.** `office.formula_cell` and the
42
+ other `office.*` reasons were not registered, so the CLI and MCP showed `input.invalid` in their place, and the
43
+ registry refuses an underscore. They are registered now and use hyphens: `office.formula-cell`,
44
+ `office.wrong-format`, `office.invalid-cell`, `office.no-sheet` and the rest
45
+ ([Editing Office files](docs/office.md)). Code that compared `details.reason` with the old spelling compares
46
+ with the new one.
47
+
48
+ ### Fixed
49
+
50
+ - **The shared `changes` command passes the command lint.** With cli-base 0.129.0 or later, whose vocabulary has the
51
+ view `changes` and the flags `--since <time>` and `--event <events>`, and the `--until <time>` cli-core 0.724.0
52
+ takes, a documents CLI needs no lint override or audit difference for it. cli-core's own command lint now mounts
53
+ `documents history` and `changes`, so a new finding fails here first (#3229).
54
+ - **`crmManifestFake` keeps a written value at a place whose schema lists the values it takes.** It dropped every
55
+ value there and kept its sample, the list's first: a deal written in EUR read back in ARS from Attio's real
56
+ `currency_code`, so `crmManifestWriteContract` failed on Attio's own API description.
57
+
8
58
  ## 0.724.0 — 23.11.2026
9
59
 
10
60
  ### Added
@@ -15,9 +15,14 @@ export interface FileConflictCommands {
15
15
  pathOf(mirror: Mirror, input: string): string;
16
16
  stateOf(command: Command, mirror: Mirror): FileMirrorStatePort;
17
17
  versionsOf(command: Command, mirror: Mirror): FileVersions;
18
- /** The remote signed in for the mirror's account, the write guard and the mirrors' sync lock. */
19
- connect(command: Command, mirror: Mirror): Promise<Pick<FileConflictResolveOptions, "target" | "principal" | "guard" | "operationId" | "lock" | "signal">>;
18
+ /**
19
+ * Runs `body` inside the app's run (its `--timeout`, run record and request log) with the remote signed in for the
20
+ * mirror's account, the write guard and the mirrors' sync lock; answers what `body` answered.
21
+ */
22
+ connect<T>(command: Command, mirror: Mirror, body: (connection: FileConflictConnection) => Promise<T>): Promise<T>;
20
23
  }
24
+ /** What `connect` hands `mirrors conflicts resolve`. */
25
+ export type FileConflictConnection = Pick<FileConflictResolveOptions, "target" | "principal" | "guard" | "operationId" | "lock" | "signal">;
21
26
  /**
22
27
  * `mirrors conflicts list|show|resolve` for a file mirror: the conflicts the last sync left, each with its three
23
28
  * versions and the line merge that failed, and a resolution that writes one final content to both sides.
@@ -86,16 +86,17 @@ export const fileConflictsCommand = (helpers) => {
86
86
  });
87
87
  const mirror = one(this, id);
88
88
  const keep = (args.keep === remote ? "remote" : args.keep);
89
- const resolved = await resolveFileConflict({
90
- ...(await helpers.connect(this, mirror)),
89
+ const path = helpers.pathOf(mirror, input);
90
+ const resolved = await helpers.connect(this, mirror, (connection) => resolveFileConflict({
91
+ ...connection,
91
92
  root: mirror.path,
92
93
  folder: mirror.folder,
93
- path: helpers.pathOf(mirror, input),
94
+ path,
94
95
  state: helpers.stateOf(this, mirror),
95
96
  versions: helpers.versionsOf(this, mirror),
96
97
  remote,
97
98
  choice: keep ? { keep } : { file: file },
98
- });
99
+ }));
99
100
  const resolution = resolved.resolution === "remote" ? remote : resolved.resolution;
100
101
  helpers.output(this, itemOf(snakeKeys({ id, ...resolved, resolution })));
101
102
  }));
@@ -59,7 +59,7 @@ const columnName = (column) => {
59
59
  const cornerOf = (address) => {
60
60
  const match = ADDRESS.exec(address.toUpperCase());
61
61
  if (!match)
62
- throw new CliError("validation_error", `${address} is not a cell like B7`, { reason: "office.invalid_cell" });
62
+ throw new CliError("validation_error", `${address} is not a cell like B7`, { reason: "office.invalid-cell" });
63
63
  const letters = match[1];
64
64
  return {
65
65
  column: [...letters].reduce((sum, letter) => sum * 26 + letter.charCodeAt(0) - 64, 0),
@@ -201,7 +201,7 @@ const addFileEditCommandsDefinition = (files, helpers) => {
201
201
  const wanted = sheetRangeOf(range);
202
202
  if (wanted.range === undefined)
203
203
  throw new CliError("validation_error", `${range} names no cell; give one like Sheet1!B2`, {
204
- reason: "office.invalid_cell",
204
+ reason: "office.invalid-cell",
205
205
  });
206
206
  cellEditsOf("", wanted.range, values);
207
207
  await editInPlace(this, "sheets", input, args.expectedFingerprint, async (bytes) => {
@@ -209,7 +209,7 @@ const addFileEditCommandsDefinition = (files, helpers) => {
209
209
  if (sheet === undefined) {
210
210
  const names = (await readXlsxCells(bytes, { range: "A1" })).map((one) => one.name);
211
211
  if (names.length !== 1)
212
- throw new CliError("validation_error", `the workbook has ${names.length} sheets (${names.map((name) => `"${name}"`).join(", ")}); name one, like ${names[0] ?? "Sheet1"}!${wanted.range}`, { reason: "office.no_sheet" });
212
+ throw new CliError("validation_error", `the workbook has ${names.length} sheets (${names.map((name) => `"${name}"`).join(", ")}); name one, like ${names[0] ?? "Sheet1"}!${wanted.range}`, { reason: "office.no-sheet" });
213
213
  sheet = names[0];
214
214
  }
215
215
  try {
@@ -228,7 +228,7 @@ const addFileEditCommandsDefinition = (files, helpers) => {
228
228
  };
229
229
  }
230
230
  catch (error) {
231
- if (isCliError(error) && error.details?.reason === "office.formula_cell")
231
+ if (isCliError(error) && error.details?.reason === "office.formula-cell")
232
232
  throw new CliError("validation_error", error.message.replace("pass overwriteFormulas", "pass --replace"), error.details);
233
233
  throw error;
234
234
  }
@@ -10,7 +10,7 @@ import { type DocumentSyncCommands } from "./sync.js";
10
10
  import type { DocumentWords } from "./words.js";
11
11
  export { addDocumentCatalogCommands, CATALOG_FIELDS, type CatalogTree, type CatalogTreeSource, catalogId, catalogOutput, catalogSource, catalogTree, type DocumentCatalog, type DocumentCatalogCommands, type DocumentCatalogStores, } from "./catalog.js";
12
12
  export { addLocalDocumentCommands, type ImportedDocument, type LocalDocumentCommands } from "./documents.js";
13
- export { type FileConflictCommands, fileConflictsCommand } from "./file-conflicts.js";
13
+ export { type FileConflictCommands, type FileConflictConnection, fileConflictsCommand } from "./file-conflicts.js";
14
14
  export { addFileEditCommands, type FileEditCommands } from "./file-edit.js";
15
15
  export { addFileUpdateCommand, type FileUpdateCommands, type FileUpdatePort } from "./file-update.js";
16
16
  export { addDocumentFolderCommands, type DocumentFolderCommands } from "./folders.js";
@@ -297,6 +297,10 @@ const ALL_HIT_UNTRUSTED = {
297
297
  lead: ["title", "excerpt"],
298
298
  // A client's file: its name and every word of it are someone else's.
299
299
  crm_file: ["title", "excerpt"],
300
+ // Written by the tracker's users, the owner's colleagues or anyone a public issue lets in.
301
+ issue: ["title", "excerpt"],
302
+ project: ["title", "excerpt"],
303
+ issue_comment: ["title", "excerpt"],
300
304
  ...BUSINESS_UNTRUSTED,
301
305
  };
302
306
  export const allHitItem = (item) => item.kind === "meeting"
@@ -12,6 +12,7 @@ declare const LIST_KEYS: {
12
12
  readonly events: "events.list";
13
13
  readonly meetings: "meetings.list";
14
14
  readonly crm_file: "files.list";
15
+ readonly tracker: "issues.list";
15
16
  };
16
17
  export type SearchedKind = keyof typeof LIST_KEYS;
17
18
  export interface LeftOut<K extends SearchedKind> {
@@ -13,6 +13,7 @@ const LIST_KEYS = {
13
13
  events: "events.list",
14
14
  meetings: "meetings.list",
15
15
  crm_file: "files.list",
16
+ tracker: "issues.list",
16
17
  };
17
18
  /**
18
19
  * The kinds whose list `permissions` deny, for a CLI with levels of its own, such as memo's: `by` names who denies in
@@ -51,7 +51,6 @@ export const crmManifestWriteKeys = (input, api, bodyPermissions) => {
51
51
  };
52
52
  };
53
53
  const refused = (message, param) => new CliError("validation_error", message, { reason: "crm.record-field", sent: false, ...(param ? { param } : {}) });
54
- /** A merge of the entries rules that share a key give: each object's keys beside the others'. */
55
54
  /** Our fields that write one key of the service together, by that key: Attio's name and its parts. */
56
55
  const sharedOf = (one) => {
57
56
  const by = new Map();
@@ -60,10 +59,14 @@ const sharedOf = (one) => {
60
59
  by.set(rule.to, [...(by.get(rule.to) ?? []), field]);
61
60
  return [...by.values()].filter((fields) => fields.length > 1);
62
61
  };
62
+ /**
63
+ * A merge of the entries rules that share a key give: each object's keys beside the others'. A part cleared beside a
64
+ * part given is sent empty, not left out: Attio refuses a name without all three of its parts.
65
+ */
63
66
  const merged = (entries, list) => {
64
- const given = entries.filter((one) => one !== CLEAR);
65
- if (given.length === 0)
67
+ if (entries.every(({ value }) => value === CLEAR))
66
68
  return CLEAR;
69
+ const given = entries.map(({ value, blank }) => (value === CLEAR ? blank : value));
67
70
  if (given.length === 1)
68
71
  return given[0];
69
72
  const first = (one) => (list && Array.isArray(one) ? one[0] : one);
@@ -175,7 +178,7 @@ export const crmWriterFromManifest = (input, options) => {
175
178
  const fields = written;
176
179
  const given = kind === "person" ? namesOf(one, fields) : fields;
177
180
  const parts = new Map();
178
- const add = (to, list, entry) => parts.set(to, { list, entries: [...(parts.get(to)?.entries ?? []), entry] });
181
+ const add = (to, list, value, blank = value) => parts.set(to, { list, entries: [...(parts.get(to)?.entries ?? []), { value, blank }] });
179
182
  for (const [field, value] of Object.entries(given)) {
180
183
  if (value === undefined || field === "custom")
181
184
  continue;
@@ -194,7 +197,7 @@ export const crmWriterFromManifest = (input, options) => {
194
197
  throw refused(`${service} keeps a ${kind}'s amount in ${currency}; give that ${field} or none`, field);
195
198
  continue;
196
199
  }
197
- add(rule.to, rule.list === true, encode(kind, field, rule, value));
200
+ add(rule.to, rule.list === true, encode(kind, field, rule, value), value === null ? encode(kind, field, rule, "") : undefined);
198
201
  }
199
202
  const custom = Object.entries(given.custom ?? {});
200
203
  if (custom.length && !one.custom)
@@ -285,13 +288,14 @@ export const crmWriterFromManifest = (input, options) => {
285
288
  * `api` keys of each operation it sends as `alsoChecks`. The writes' guard asks before each one and journals it.
286
289
  */
287
290
  export const crmManifestWrites = (input, options) => {
288
- const { manifest: api, service, source, app, settings, self, env, warn } = options;
291
+ const { manifest: api, service, source, app, settings, self, ownedByDefault, env, warn } = options;
289
292
  return {
290
293
  writer: crmWriterFromManifest(input, { api, service, send: serviceApiSend(options), source }),
291
294
  alsoChecks: crmManifestWriteKeys(input, api, options.bodyPermissions),
292
295
  app,
293
296
  settings,
294
297
  ...(self === undefined ? {} : { self }),
298
+ ...(ownedByDefault === undefined ? {} : { ownedByDefault }),
295
299
  ...(env === undefined ? {} : { env }),
296
300
  ...(warn === undefined ? {} : { warn }),
297
301
  };
@@ -79,7 +79,7 @@ const givenOf = (spec, values) => {
79
79
  .map(String);
80
80
  if (list)
81
81
  given[name] = field === "people" ? found.map((one) => ({ externalId: one, role: "contact" })) : found;
82
- // A key several rules write together is replaced whole: a part it leaves out is gone.
82
+ // One value replaces the field whole, so a part of a key several rules share that the write leaves out is gone.
83
83
  else
84
84
  given[name] = found[0] ?? null;
85
85
  }
@@ -162,7 +162,7 @@ export const crmManifestFake = (input, options) => {
162
162
  if (type === "integer" || type === "number")
163
163
  return Number.isFinite(Number(value)) ? Number(value) : undefined;
164
164
  if (type === "string" && found?.type === "string" && found.enum)
165
- return undefined;
165
+ return found.enum.includes(String(value)) ? String(value) : undefined;
166
166
  return ["string", "unknown"].includes(type) ? String(value) : undefined;
167
167
  };
168
168
  /**
@@ -12,8 +12,13 @@ import { type CrmVerb, type CrmWriter } from "./writer.js";
12
12
  /** What a CLI hands the CRM writes for one profile. */
13
13
  export interface CrmWrites extends ProfileWrites {
14
14
  writer: CrmWriter;
15
- /** The CRM user the sign-in acts as. An owner other than it checks `crm.assign-others`; left out, every owner does. */
16
- self?: string;
15
+ /**
16
+ * The CRM user the sign-in acts as, or how to ask the CRM for it when a write needs it. An owner other than it
17
+ * checks `crm.assign-others`; left out, or answered empty, every owner does.
18
+ */
19
+ self?: string | (() => Promise<string | undefined>);
20
+ /** The kinds a new item of which is the sign-in's user's when no --owner is given: Attio refuses a deal with none. */
21
+ ownedByDefault?: readonly CrmKind[];
17
22
  /**
18
23
  * The CLI's own keys a write also checks, such as Bitrix24's `api.crm.deal.update`; pass the same function to
19
24
  * `crmAlsoChecks` so `--dry-run` names them.
@@ -238,13 +238,14 @@ export const crmCustomValues = (fields, pairs) => {
238
238
  /** `--field` pairs by the field definitions the last sync stored. */
239
239
  const customOf = async (context, kind, pairs) => pairs?.length ? crmCustomValues(await context.store.crm.fields(context.account, kind), pairs) : undefined;
240
240
  /** Every key the write checks: its own, and each action its fields also take (WC-PERM-22). */
241
- const keysOf = (context, kind, verb, { stage, owner }) => {
241
+ const selfOf = async ({ writes: { self } }) => (typeof self === "function" ? await self() : self) || undefined;
242
+ const keysOf = async (context, kind, verb, { stage, owner }) => {
242
243
  const extra = [];
243
244
  if (stage && verb !== "move")
244
245
  extra.push(keyOf(kind, "move"));
245
246
  if (stage && stage.outcome !== "open")
246
247
  extra.push(keyOf(kind, "close"));
247
- if (owner != null && owner !== context.writes.self)
248
+ if (owner != null && owner !== (await selfOf(context)))
248
249
  extra.push(CRM_ASSIGN_OTHERS_KEY);
249
250
  return { key: keyOf(kind, verb), extra: [...extra, ...(context.writes.alsoChecks?.(kind, verb) ?? [])] };
250
251
  };
@@ -314,8 +315,14 @@ export const createCrmItem = async (context, kind, input, options = {}) => {
314
315
  const custom = await customOf(context, kind, input.custom);
315
316
  if (custom)
316
317
  fields.custom = custom;
318
+ if (fields.owner === undefined && context.writes.ownedByDefault?.includes(kind)) {
319
+ const self = await selfOf(context);
320
+ if (self === undefined)
321
+ throw invalid(`a new ${kind} needs --owner: the sign-in names no CRM user`, "--owner");
322
+ fields.owner = self;
323
+ }
317
324
  const operationId = operationOf(context, options.operationId);
318
- const item = await written(context, keysOf(context, kind, "create", { stage, owner: fields.owner }), operationId, () => writer.create(kind, fields, { operationId }));
325
+ const item = await written(context, await keysOf(context, kind, "create", { stage, owner: fields.owner }), operationId, () => writer.create(kind, fields, { operationId }));
319
326
  return { operationId, item: await kept(context, kind, item, operationId) };
320
327
  };
321
328
  export const updateCrmItem = async (context, kind, reference, input, options = {}) => {
@@ -334,7 +341,7 @@ export const updateCrmItem = async (context, kind, reference, input, options = {
334
341
  if (Object.keys(fields).length === 0)
335
342
  throw invalid("nothing to change: name a field");
336
343
  const operationId = operationOf(context, options.operationId);
337
- const item = await written(context, keysOf(context, kind, "update", { stage, owner: fields.owner }), operationId, () => writer.update(kind, copy.externalId, fields, { operationId }));
344
+ const item = await written(context, await keysOf(context, kind, "update", { stage, owner: fields.owner }), operationId, () => writer.update(kind, copy.externalId, fields, { operationId }));
338
345
  return { operationId, item: await kept(context, kind, item, operationId) };
339
346
  };
340
347
  export const moveCrmItem = async (context, kind, reference, stageName, options = {}) => {
@@ -343,7 +350,7 @@ export const moveCrmItem = async (context, kind, reference, stageName, options =
343
350
  const copy = await copyOf(context, kind, reference);
344
351
  const stage = stageOf(await pipelineOf(context, kind, copy.pipeline), stageName);
345
352
  const operationId = operationOf(context, options.operationId);
346
- const item = await written(context, keysOf(context, kind, "move", { stage }), operationId, () => writer.move(kind, copy.externalId, stage.externalId, { operationId }));
353
+ const item = await written(context, await keysOf(context, kind, "move", { stage }), operationId, () => writer.move(kind, copy.externalId, stage.externalId, { operationId }));
347
354
  return { operationId, item: await kept(context, kind, item, operationId) };
348
355
  };
349
356
  export const closeCrmItem = async (context, kind, reference, outcome, options = {}) => {
@@ -356,7 +363,7 @@ export const closeCrmItem = async (context, kind, reference, outcome, options =
356
363
  if (reason !== undefined && (reason === "" || reason.length > 2000))
357
364
  throw invalid("--reason is 1 to 2000 characters", "--reason");
358
365
  const operationId = operationOf(context, options.operationId);
359
- const item = await written(context, keysOf(context, kind, "close", {}), operationId, () => writer.close(kind, copy.externalId, outcome, { operationId, ...(reason ? { reason } : {}) }));
366
+ const item = await written(context, await keysOf(context, kind, "close", {}), operationId, () => writer.close(kind, copy.externalId, outcome, { operationId, ...(reason ? { reason } : {}) }));
360
367
  return { operationId, item: await kept(context, kind, item, operationId) };
361
368
  };
362
369
  export const removeCrmItem = async (context, kind, reference, options = {}) => {
@@ -364,7 +371,7 @@ export const removeCrmItem = async (context, kind, reference, options = {}) => {
364
371
  supported(writer, kind, "remove");
365
372
  const copy = await copyOf(context, kind, reference);
366
373
  const operationId = operationOf(context, options.operationId);
367
- await written(context, keysOf(context, kind, "remove", {}), operationId, () => writer.remove(kind, copy.externalId, { operationId }));
374
+ await written(context, await keysOf(context, kind, "remove", {}), operationId, () => writer.remove(kind, copy.externalId, { operationId }));
368
375
  const removed = await context.store.crm.remove(context.account, kind, [copy.externalId]);
369
376
  return { operationId, ref: copy.ref, removed };
370
377
  };
@@ -450,7 +457,7 @@ const writeRecord = async (context, kind, verb, fields, operationId, act) => {
450
457
  if (!context.source)
451
458
  throw new CliError("configuration_error", "a contact or company write needs the CRM source to tell your clients");
452
459
  const rule = foreignContacts(context.source(), undefined);
453
- const record = await written(context, keysOf(context, kind, verb, { owner: fields.owner }), operationId, act);
460
+ const record = await written(context, await keysOf(context, kind, verb, { owner: fields.owner }), operationId, act);
454
461
  const stored = await rule.own(kind, record);
455
462
  let removed;
456
463
  try {
@@ -1,7 +1,7 @@
1
1
  import type { Provider } from "./models.js";
2
2
  import { type RefKindName } from "./references.js";
3
3
  /** What a search reads; the same names `--only`, `searched` and `skipped` use. */
4
- export declare const KINDS: readonly ["messages", "mail", "notes", "documents", "meetings", "events", "crm"];
4
+ export declare const KINDS: readonly ["messages", "mail", "notes", "documents", "meetings", "events", "crm", "tracker"];
5
5
  export type Kind = (typeof KINDS)[number];
6
6
  export interface ProviderEntry {
7
7
  name: Provider;
@@ -1,7 +1,7 @@
1
1
  import { CliError } from "@wirecat/cli-base";
2
2
  import { REF_KINDS } from "./references.js";
3
3
  /** What a search reads; the same names `--only`, `searched` and `skipped` use. */
4
- export const KINDS = ["messages", "mail", "notes", "documents", "meetings", "events", "crm"];
4
+ export const KINDS = ["messages", "mail", "notes", "documents", "meetings", "events", "crm", "tracker"];
5
5
  const MESSENGER_OPENS = { chat: "messages list", message: "messages show", contact: "contacts show" };
6
6
  /** What a CRM CLI's entry gives as `opens`: the read commands `addCrmCommands` mounts. */
7
7
  export const CRM_OPENS = { deal: "deals show", lead: "leads show", pipeline: "pipelines show" };
@@ -22,6 +22,8 @@ export const PROVIDERS = [
22
22
  // Google Meet has no tool of its own: its meetings are gcal's, since every meeting is on the calendar.
23
23
  { name: "google-meet", kind: "meetings", aliases: [], command: "gcal" },
24
24
  { name: "google-drive", kind: "documents", aliases: [] },
25
+ // Seeded: linear-cli registers no entry, and without one its accounts would count as a messenger's.
26
+ { name: "linear", kind: "tracker", aliases: [], command: "linear" },
25
27
  // Its meetings come from the notes Telemost mails (`keeper@telemost.yandex.ru`), read by a mail rule.
26
28
  { name: "telemost", kind: "meetings", aliases: [] },
27
29
  // A phone export's records: its SMS and its calls in the one account the import names.
@@ -41,6 +43,7 @@ const LABELS = {
41
43
  added: "added by hand",
42
44
  email: "mail",
43
45
  telemost: "Telemost",
46
+ linear: "Linear",
44
47
  };
45
48
  /** How a text names a provider to a person: `MAX`, not `max`. */
46
49
  export const providerLabel = (provider) => LABELS[provider] ?? provider;
@@ -1,10 +1,11 @@
1
1
  import * as v from "valibot";
2
2
  /**
3
3
  * One result of `search all`: a message, a mail, a note, a calendar event, a meeting passage, a deal, a lead, the text
4
- * of a downloaded CRM file, or an invoice, payment, order, contract, subscription, product or wallet.
4
+ * of a downloaded CRM file, a tracker's issue, project or issue comment, or an invoice, payment, order, contract,
5
+ * subscription, product or wallet.
5
6
  */
6
7
  export declare const hit: v.StrictObjectSchema<{
7
- readonly kind: v.PicklistSchema<["message", "mail", "note", "document", "event", "meeting", "deal", "lead", "crm_file", "invoice", "payment", "order", "contract", "subscription", "product", "wallet"], undefined>;
8
+ readonly kind: v.PicklistSchema<["message", "mail", "note", "document", "event", "meeting", "deal", "lead", "crm_file", "issue", "project", "issue_comment", "invoice", "payment", "order", "contract", "subscription", "product", "wallet"], undefined>;
8
9
  readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
9
10
  readonly provider: v.StringSchema<undefined>;
10
11
  readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -4,7 +4,8 @@ import { hitFile } from "./attachment.js";
4
4
  import { count, reference, text, time, untrusted } from "./fields.js";
5
5
  /**
6
6
  * One result of `search all`: a message, a mail, a note, a calendar event, a meeting passage, a deal, a lead, the text
7
- * of a downloaded CRM file, or an invoice, payment, order, contract, subscription, product or wallet.
7
+ * of a downloaded CRM file, a tracker's issue, project or issue comment, or an invoice, payment, order, contract,
8
+ * subscription, product or wallet.
8
9
  */
9
10
  export const hit = v.strictObject({
10
11
  kind: v.picklist([
@@ -17,6 +18,9 @@ export const hit = v.strictObject({
17
18
  "deal",
18
19
  "lead",
19
20
  "crm_file",
21
+ "issue",
22
+ "project",
23
+ "issue_comment",
20
24
  ...BUSINESS_KINDS,
21
25
  ]),
22
26
  ref: reference,
@@ -4326,7 +4326,7 @@ export declare const ENTITIES: {
4326
4326
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
4327
4327
  }, undefined>;
4328
4328
  readonly hit: v.StrictObjectSchema<{
4329
- readonly kind: v.PicklistSchema<["message", "mail", "note", "document", "event", "meeting", "deal", "lead", "crm_file", "invoice", "payment", "order", "contract", "subscription", "product", "wallet"], undefined>;
4329
+ readonly kind: v.PicklistSchema<["message", "mail", "note", "document", "event", "meeting", "deal", "lead", "crm_file", "issue", "project", "issue_comment", "invoice", "payment", "order", "contract", "subscription", "product", "wallet"], undefined>;
4330
4330
  readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
4331
4331
  readonly provider: v.StringSchema<undefined>;
4332
4332
  readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -123,6 +123,27 @@ const SQL = [
123
123
  ["db.timeout", "timeout", "the database server did not answer in time"],
124
124
  ["db.failed", "provider_error", "the database server failed the query"],
125
125
  ];
126
+ /** In-place Office edits (`./office`, `files sheets|documents update`); the names are documented in office.md. */
127
+ const OFFICE = [
128
+ ["office.wrong-format", "the file is not the Office format the command edits, or its parts cannot be read"],
129
+ ["office.invalid-cell", "a cell is not an address like B7"],
130
+ ["office.invalid-value", "a cell value cannot be written: a number must be finite"],
131
+ ["office.no-sheet", "the workbook has no such sheet, or several when none is named"],
132
+ ["office.duplicate-edit", "the same cell or paragraph is changed twice in one call"],
133
+ ["office.formula-cell", "the cell holds a formula; --replace writes the value over it"],
134
+ ["office.shared-formula", "the cell holds a formula other cells share; replacing it would break theirs"],
135
+ ["office.array-formula", "the cell is part of an array formula; change it in Excel"],
136
+ ["office.rich-value", "the cell holds a picture or a linked data type, which the editor does not replace"],
137
+ ["office.table-header", "the cell is a table's header or total, whose part repeats the text; change it in Excel"],
138
+ ["office.implicit-rows", "the sheet has rows without numbers, so a row cannot be added"],
139
+ ["office.implicit-cells", "the row has cells without addresses, so a cell cannot be added"],
140
+ ["office.no-paragraph", "the document has no paragraph at that index"],
141
+ ["office.unsafe-paragraph", "the paragraph cannot be edited safely; documents show gives the reason"],
142
+ ["office.tracked-change", "the paragraph holds a tracked change"],
143
+ ["office.section-break", "the paragraph ends a section; deleting it would merge two sections"],
144
+ ["office.bookmark", "the paragraph holds a bookmark a cross-reference may point at"],
145
+ ["office.last-paragraph", "the delete would leave the document or a table cell without a paragraph"],
146
+ ].map(([reason, message]) => validation(reason, message));
126
147
  const OTHERS = [
127
148
  validation("doctor.report-exists", "the report's file exists; a problem report never overwrites a file"),
128
149
  validation("usage.unknown-command", "no command by this name; the CLI's help lists them"),
@@ -769,7 +790,7 @@ const DETAILED = {
769
790
  export const REASONS = defineReasons([
770
791
  ...QUERY_REASONS,
771
792
  ...INPUT_FIELD_REASONS,
772
- ...[...QUERY, ...SIGN_IN, ...PROVIDER_API, ...SFTP, ...SQL, ...OTHERS].map(([reason, code, message]) => ({
793
+ ...[...QUERY, ...SIGN_IN, ...PROVIDER_API, ...SFTP, ...SQL, ...OFFICE, ...OTHERS].map(([reason, code, message]) => ({
773
794
  reason,
774
795
  code,
775
796
  message,
@@ -66,10 +66,10 @@ class Document {
66
66
  const root = this.part.root;
67
67
  this.ns = root.ns;
68
68
  if (root.local !== "document" || !WORD_NAMESPACES.includes(this.ns))
69
- throw refuse("the file is not a Word document", "office.wrong_format");
69
+ throw refuse("the file is not a Word document", "office.wrong-format");
70
70
  const body = childrenOf(root, this.ns, "body")[0];
71
71
  if (!body)
72
- throw refuse("the document has no body", "office.wrong_format");
72
+ throw refuse("the document has no body", "office.wrong-format");
73
73
  this.walk(body, "body", false);
74
74
  const styles = pack.related(this.part.path, "styles");
75
75
  if (styles && pack.has(styles[1].path)) {
@@ -208,7 +208,7 @@ class Document {
208
208
  if (!properties)
209
209
  return "";
210
210
  if (hasTracked(properties))
211
- throw refuse("the paragraph to copy the style from holds a tracked change", "office.tracked_change");
211
+ throw refuse("the paragraph to copy the style from holds a tracked change", "office.tracked-change");
212
212
  let raw = this.raw(properties);
213
213
  for (const section of childrenOf(properties, this.ns, "sectPr").reverse())
214
214
  raw = raw.slice(0, section.start - properties.start) + raw.slice(section.end - properties.start);
@@ -253,18 +253,18 @@ export const editDocxParagraphs = async (bytes, edits) => {
253
253
  const infos = document.paragraphs();
254
254
  const check = (index, what) => {
255
255
  if (!Number.isInteger(index) || index < 0 || index >= found.length)
256
- throw refuse(`${what} ${index} does not exist; the document has ${found.length} paragraphs`, "office.no_paragraph");
256
+ throw refuse(`${what} ${index} does not exist; the document has ${found.length} paragraphs`, "office.no-paragraph");
257
257
  return found[index];
258
258
  };
259
259
  const editable = (index, action) => {
260
260
  const info = infos[index];
261
261
  if (!info.editable)
262
- throw refuse(`paragraph ${index} cannot be ${action}: ${info.reason}`, "office.unsafe_paragraph");
262
+ throw refuse(`paragraph ${index} cannot be ${action}: ${info.reason}`, "office.unsafe-paragraph");
263
263
  };
264
264
  const touched = new Set();
265
265
  const once = (index) => {
266
266
  if (touched.has(index))
267
- throw refuse(`paragraph ${index} is changed twice in one call`, "office.duplicate_edit");
267
+ throw refuse(`paragraph ${index} is changed twice in one call`, "office.duplicate-edit");
268
268
  touched.add(index);
269
269
  };
270
270
  const splices = [];
@@ -281,7 +281,7 @@ export const editDocxParagraphs = async (bytes, edits) => {
281
281
  editable(edit.delete, "deleted");
282
282
  const properties = childrenOf(target.element, document.ns, "pPr")[0];
283
283
  if (properties && childrenOf(properties, document.ns, "sectPr").length)
284
- throw refuse(`paragraph ${edit.delete} ends a section; deleting it would merge two sections`, "office.section_break");
284
+ throw refuse(`paragraph ${edit.delete} ends a section; deleting it would merge two sections`, "office.section-break");
285
285
  if (target.element.children.some((child) => MARKERS.has(child.local)))
286
286
  throw refuse(`paragraph ${edit.delete} holds a bookmark that a cross-reference may point at`, "office.bookmark");
287
287
  splices.push({ start: target.element.start, end: target.element.end, text: "" });
@@ -307,10 +307,10 @@ export const editDocxParagraphs = async (bytes, edits) => {
307
307
  if (edit.insertAfter !== -1)
308
308
  check(edit.insertAfter, "paragraph");
309
309
  if (!found.length)
310
- throw refuse("the document has no paragraph to insert next to", "office.no_paragraph");
310
+ throw refuse("the document has no paragraph to insert next to", "office.no-paragraph");
311
311
  const neighbour = found[Math.max(0, edit.insertAfter)];
312
312
  if (neighbour.lockedControl)
313
- throw refuse(`paragraph ${edit.insertAfter} sits in a locked content control`, "office.unsafe_paragraph");
313
+ throw refuse(`paragraph ${edit.insertAfter} sits in a locked content control`, "office.unsafe-paragraph");
314
314
  const source = check(edit.styleFrom ?? Math.max(0, edit.insertAfter), "styleFrom paragraph").element;
315
315
  const element = neighbour.element;
316
316
  const text = normalized(edit.text);
@@ -332,7 +332,7 @@ export const editDocxParagraphs = async (bytes, edits) => {
332
332
  const remaining = blocks.filter((block) => !deleted.includes(found.findIndex((entry) => entry.element === block)));
333
333
  const addsAtEnd = found.some((entry, index) => insertedAfter.has(index) && entry.element === blocks.at(-1));
334
334
  if (!addsAtEnd && remaining.at(-1)?.local !== "p")
335
- throw refuse(`${container.local === "tc" ? "a table cell" : "the document"} must end with a paragraph; this delete would leave it without one`, "office.last_paragraph");
335
+ throw refuse(`${container.local === "tc" ? "a table cell" : "the document"} must end with a paragraph; this delete would leave it without one`, "office.last-paragraph");
336
336
  }
337
337
  if (!edits.length)
338
338
  return { bytes: bytes.slice(), replaced, inserted, deleted, collapsed };
@@ -30,7 +30,7 @@ const parseAddress = (address) => {
30
30
  const column = match ? [...match[1]].reduce((sum, letter) => sum * 26 + letter.charCodeAt(0) - 64, 0) : 0;
31
31
  const row = Number(match?.[2]);
32
32
  if (!match || column > MAX_COLUMN || row > MAX_ROW)
33
- throw refuse(`${address} is not a cell address like B7`, "office.invalid_cell");
33
+ throw refuse(`${address} is not a cell address like B7`, "office.invalid-cell");
34
34
  return { row, column };
35
35
  };
36
36
  const parseRange = (range) => {
@@ -61,14 +61,14 @@ class Workbook {
61
61
  this.workbook = pack.part(path);
62
62
  this.ns = this.workbook.root.ns;
63
63
  if (this.workbook.root.local !== "workbook" || !SHEET_NAMESPACES.includes(this.ns))
64
- throw refuse("the file is not an Excel workbook", "office.wrong_format");
64
+ throw refuse("the file is not an Excel workbook", "office.wrong-format");
65
65
  const rels = pack.relationships(path);
66
66
  const sheetsElement = childrenOf(this.workbook.root, this.ns, "sheets")[0];
67
67
  this.sheets = (sheetsElement ? childrenOf(sheetsElement, this.ns, "sheet") : []).map((sheet) => {
68
68
  const id = attributeOf(sheet, REL, "id") ?? attributeOf(sheet, STRICT_REL, "id") ?? "";
69
69
  const target = rels.get(id);
70
70
  if (!target?.type.endsWith("/worksheet"))
71
- throw refuse("a sheet of the workbook is not a worksheet (a chart sheet or a missing part)", "office.wrong_format");
71
+ throw refuse("a sheet of the workbook is not a worksheet (a chart sheet or a missing part)", "office.wrong-format");
72
72
  return { name: attributeOf(sheet, "", "name") ?? "", path: target.path };
73
73
  });
74
74
  const shared = pack.related(path, "sharedStrings");
@@ -88,7 +88,7 @@ class Workbook {
88
88
  sheet(name) {
89
89
  const found = this.sheets.find((sheet) => sheet.name === name);
90
90
  if (!found)
91
- throw refuse(`the workbook has no sheet "${name}"; it has ${this.sheets.map((sheet) => `"${sheet.name}"`).join(", ")}`, "office.no_sheet");
91
+ throw refuse(`the workbook has no sheet "${name}"; it has ${this.sheets.map((sheet) => `"${sheet.name}"`).join(", ")}`, "office.no-sheet");
92
92
  return found;
93
93
  }
94
94
  }
@@ -119,7 +119,7 @@ const rowsOf = (sheetData, ns) => {
119
119
  if (reference) {
120
120
  const address = parseAddress(reference);
121
121
  if (address.row !== number)
122
- throw refuse(`cell ${reference} sits in row ${number}`, "office.wrong_format");
122
+ throw refuse(`cell ${reference} sits in row ${number}`, "office.wrong-format");
123
123
  column = address.column;
124
124
  }
125
125
  else
@@ -158,7 +158,7 @@ const cellOf = (workbook, text, node) => {
158
158
  if (type === "s") {
159
159
  const string = workbook.strings[Number(saved)];
160
160
  if (!/^\d+$/.test(saved) || string === undefined)
161
- throw refuse(`cell ${columnName(node.column)}${node.row} points at a missing shared string`, "office.wrong_format");
161
+ throw refuse(`cell ${columnName(node.column)}${node.row} points at a missing shared string`, "office.wrong-format");
162
162
  value = string;
163
163
  kind = "string";
164
164
  }
@@ -195,10 +195,10 @@ const cellOf = (workbook, text, node) => {
195
195
  };
196
196
  const sheetDataOf = (part, ns) => {
197
197
  if (part.root.local !== "worksheet" || part.root.ns !== ns)
198
- throw refuse(`${part.path} is not a worksheet`, "office.wrong_format");
198
+ throw refuse(`${part.path} is not a worksheet`, "office.wrong-format");
199
199
  const sheetData = childrenOf(part.root, ns, "sheetData")[0];
200
200
  if (!sheetData)
201
- throw refuse(`${part.path} has no cell data`, "office.wrong_format");
201
+ throw refuse(`${part.path} has no cell data`, "office.wrong-format");
202
202
  return sheetData;
203
203
  };
204
204
  /** The workbook's sheets and their stored cells, with each cell's type, formula and format index. */
@@ -278,7 +278,7 @@ const valueXml = (cell, value, strings) => {
278
278
  return { type: "b", content: `<${v}>${value ? 1 : 0}</${v}>` };
279
279
  if (typeof value === "number") {
280
280
  if (!Number.isFinite(value))
281
- throw refuse("a cell number must be finite", "office.invalid_value");
281
+ throw refuse("a cell number must be finite", "office.invalid-value");
282
282
  return { type: undefined, content: `<${v}>${String(value)}</${v}>` };
283
283
  }
284
284
  if (strings)
@@ -336,7 +336,7 @@ const editSheet = (workbook, sheet, planned, options, strings) => {
336
336
  for (const label of tableLabels(workbook, sheet))
337
337
  for (const item of planned)
338
338
  if (item.row >= label.top && item.row <= label.bottom && item.column >= label.left && item.column <= label.right)
339
- throw refuse(`${sheet.name}!${item.address} is a ${label.kind} of the table "${label.table}", whose part repeats the text; change it in Excel`, "office.table_header");
339
+ throw refuse(`${sheet.name}!${item.address} is a ${label.kind} of the table "${label.table}", whose part repeats the text; change it in Excel`, "office.table-header");
340
340
  const splices = [];
341
341
  const changed = [];
342
342
  let formulaRemoved = false;
@@ -354,7 +354,7 @@ const editSheet = (workbook, sheet, planned, options, strings) => {
354
354
  const row = rows.find((candidate) => candidate.row === rowNumber);
355
355
  if (!row) {
356
356
  if (rows.some((candidate) => !candidate.explicit))
357
- throw refuse(`${sheet.name} has rows without numbers, so row ${rowNumber} cannot be added`, "office.implicit_rows");
357
+ throw refuse(`${sheet.name} has rows without numbers, so row ${rowNumber} cannot be added`, "office.implicit-rows");
358
358
  const next = rows.find((candidate) => candidate.row > rowNumber);
359
359
  const r = qualified(sheetData, "row");
360
360
  const xml = `<${r} r="${rowNumber}">${items.map((item) => newCell(item)).join("")}</${r}>`;
@@ -378,7 +378,7 @@ const editSheet = (workbook, sheet, planned, options, strings) => {
378
378
  const existing = row.cells.find((cell) => cell.column === item.column);
379
379
  if (!existing) {
380
380
  if (row.cells.some((cell) => attributeOf(cell.element, "", "r") === undefined))
381
- throw refuse(`row ${rowNumber} of ${sheet.name} has cells without addresses, so ${item.address} cannot be added`, "office.implicit_cells");
381
+ throw refuse(`row ${rowNumber} of ${sheet.name} has cells without addresses, so ${item.address} cannot be added`, "office.implicit-cells");
382
382
  const next = row.cells.find((cell) => cell.column > item.column);
383
383
  inserts.push({ at: next ? next.element.start : -1, xml: newCell(item, rowStyle) });
384
384
  changed.push({ sheet: sheet.name, cell: item.address, before: null, after: item.edit.value, created: true });
@@ -387,7 +387,7 @@ const editSheet = (workbook, sheet, planned, options, strings) => {
387
387
  const before = cellOf(workbook, text, existing);
388
388
  const element = existing.element;
389
389
  if (attributeOf(element, "", "vm") !== undefined)
390
- throw refuse(`${sheet.name}!${item.address} holds a picture or a linked data type, which this editor does not replace`, "office.rich_value");
390
+ throw refuse(`${sheet.name}!${item.address} holds a picture or a linked data type, which this editor does not replace`, "office.rich-value");
391
391
  const formula = childrenOf(element, ns, "f")[0];
392
392
  const array = arrays.find((entry) => item.row >= entry.range.top &&
393
393
  item.row <= entry.range.bottom &&
@@ -395,12 +395,12 @@ const editSheet = (workbook, sheet, planned, options, strings) => {
395
395
  item.column <= entry.range.right &&
396
396
  (entry.range.top !== entry.range.bottom || entry.range.left !== entry.range.right));
397
397
  if (array)
398
- throw refuse(`${sheet.name}!${item.address} is part of an array formula; change it in Excel`, "office.array_formula");
398
+ throw refuse(`${sheet.name}!${item.address} is part of an array formula; change it in Excel`, "office.array-formula");
399
399
  if (formula) {
400
400
  if (!options.overwriteFormulas)
401
- throw refuse(`${sheet.name}!${item.address} holds the formula =${before.formula}; pass overwriteFormulas to replace it with a value`, "office.formula_cell");
401
+ throw refuse(`${sheet.name}!${item.address} holds the formula =${before.formula}; pass overwriteFormulas to replace it with a value`, "office.formula-cell");
402
402
  if (attributeOf(formula, "", "t") === "shared" && attributeOf(formula, "", "ref") !== undefined)
403
- throw refuse(`${sheet.name}!${item.address} holds a formula that other cells share; replacing it would break theirs`, "office.shared_formula");
403
+ throw refuse(`${sheet.name}!${item.address} holds a formula that other cells share; replacing it would break theirs`, "office.shared-formula");
404
404
  formulaRemoved = true;
405
405
  }
406
406
  if (attributeOf(element, "", "t") === "s" && strings)
@@ -516,7 +516,7 @@ export const editXlsxCells = async (bytes, edits, options = {}) => {
516
516
  const address = `${columnName(column)}${row}`;
517
517
  const key = `${sheet.name}!${address}`;
518
518
  if (seen.has(key))
519
- throw refuse(`${key} is edited twice in one call`, "office.duplicate_edit");
519
+ throw refuse(`${key} is edited twice in one call`, "office.duplicate-edit");
520
520
  seen.add(key);
521
521
  bySheet.set(sheet, [...(bySheet.get(sheet) ?? []), { edit, row, column, address }]);
522
522
  }
@@ -246,6 +246,7 @@ const READS = {
246
246
  meetings: "meetings — search all reads them",
247
247
  events: "calendar events — no search reads them yet",
248
248
  crm: "CRM deals and leads — search all reads them",
249
+ tracker: "a tracker's issues, projects and comments — search all reads them",
249
250
  };
250
251
  /**
251
252
  * The accounts of `kinds` the entries name, and each entry that names none of them with the reason. A search
@@ -10,15 +10,15 @@ import type { SearchCoverage } from "./messages-search.js";
10
10
  import { type MeetingAccountCoverage, type MeetingSearchItem } from "./search-all-meetings.js";
11
11
  import { type HarderOptions, type HarderResult } from "./search-harder.js";
12
12
  import type { Backend, ServerOptions, ServerSearched } from "./server-search.js";
13
- export declare const RESOURCES_SEARCHED: readonly ["messages", "mail", "notes", "events", "crm", "business", "meetings"];
13
+ export declare const RESOURCES_SEARCHED: readonly ["messages", "mail", "notes", "events", "crm", "business", "meetings", "tracker"];
14
14
  export type SearchedResource = (typeof RESOURCES_SEARCHED)[number];
15
15
  /** One hit of `search all`: a stored record, or a passage of a meeting. */
16
16
  export type SearchAllItem = SearchAllRecordItem | MeetingSearchItem;
17
17
  export interface SearchAllRecordItem {
18
- kind: "message" | "mail" | "note" | "document" | "event" | "deal" | "lead" | "crm_file" | BusinessKind;
18
+ kind: "message" | "mail" | "note" | "document" | "event" | "deal" | "lead" | "crm_file" | TrackerHitKind | BusinessKind;
19
19
  /**
20
20
  * `msg:…` for a message or a mail, `note:…`, `event:…`, `deal:…`, `lead:…`, `crmfile:<file id>` for a downloaded CRM
21
- * file, or a business ref: `invoice:…`.
21
+ * file, `tracker:<provider>/<account>/<kind>/<id>` for an issue, a project or a comment, or a business ref: `invoice:…`.
22
22
  */
23
23
  ref: string;
24
24
  provider: string;
@@ -178,6 +178,10 @@ export declare const titleWords: (text: string, refused?: string) => {
178
178
  words: string[];
179
179
  anyWord: boolean;
180
180
  };
181
+ /** A tracker hit's kind: a comment is named for the issue it is on, beside a CRM's and a message's kinds. */
182
+ export type TrackerHitKind = "issue" | "project" | "issue_comment";
183
+ /** The accounts of every tracker the store holds copies of. */
184
+ export declare const trackerAccounts: (store: MessageStore) => Promise<AccountKey[]>;
181
185
  /** The accounts of every CRM the store holds copies of. */
182
186
  export declare const crmAccounts: (store: MessageStore) => Promise<AccountKey[]>;
183
187
  /**
@@ -5,6 +5,7 @@ import { hitFiles } from "../domain/attachments.js";
5
5
  import { parseLocator } from "../domain/locator.js";
6
6
  import { senderIsMe } from "../domain/models.js";
7
7
  import { holdsKind, INTERNAL_NOTES } from "../domain/providers.js";
8
+ import { trackerTitleOf } from "../domain/tracker.js";
8
9
  import { runEmbedders } from "../embeddings/embed.js";
9
10
  import { chosenTextModel } from "../embeddings/models.js";
10
11
  import { formatMeetingReference } from "../meetings/index.js";
@@ -23,7 +24,16 @@ import { BUSINESS_WORDS_ONLY, searchBusiness } from "./search-all-business.js";
23
24
  import { meetingLane } from "./search-all-meetings.js";
24
25
  import { HARDER_CANDIDATES, reorderHarder } from "./search-harder.js";
25
26
  import { listContextOf } from "./search-kind.js";
26
- export const RESOURCES_SEARCHED = ["messages", "mail", "notes", "events", "crm", "business", "meetings"];
27
+ export const RESOURCES_SEARCHED = [
28
+ "messages",
29
+ "mail",
30
+ "notes",
31
+ "events",
32
+ "crm",
33
+ "business",
34
+ "meetings",
35
+ "tracker",
36
+ ];
27
37
  const refusal = (error, text) => {
28
38
  const { reason, span } = (error.details ?? {});
29
39
  const why = typeof reason === "string" ? reason : undefined;
@@ -117,6 +127,15 @@ const copyViewers = async (store) => {
117
127
  }
118
128
  return viewers;
119
129
  };
130
+ const TRACKER_HIT_KINDS = { issue: "issue", project: "project", comment: "issue_comment" };
131
+ /** The accounts of every tracker the store holds copies of. */
132
+ export const trackerAccounts = async (store) => (await store.accounts.accounts()).filter(({ provider }) => holdsKind(provider, "tracker"));
133
+ /** An issue is titled as people say it, `ENG-12 Fix login`; anything else by its name or its first line. */
134
+ const trackerTitle = ({ kind, record }) => {
135
+ const title = trackerTitleOf(kind, record);
136
+ const key = kind === "issue" ? record.key : undefined;
137
+ return key ? `${key} ${title}` : title;
138
+ };
120
139
  /** The accounts of every CRM the store holds copies of. */
121
140
  export const crmAccounts = async (store) => (await store.accounts.accounts()).filter(({ provider }) => holdsKind(provider, "crm"));
122
141
  /**
@@ -388,6 +407,37 @@ export const searchAll = async (store, account, asked, messenger = {}, searchMes
388
407
  for (const { provider, account } of read)
389
408
  accounts.push({ resource, provider, account });
390
409
  }
410
+ else if (resource === "tracker") {
411
+ // The registry says which providers are trackers; reading every account's rows would show hits the listed
412
+ // accounts do not account for.
413
+ const read = scope?.tracker ?? (await trackerAccounts(store));
414
+ if (!read.length)
415
+ continue;
416
+ const { words, anyWord } = titleWords(request.text, "issues, projects and comments are found by the words of their title and text only");
417
+ const found = await store.tracker.find({
418
+ words,
419
+ anyWord: anyWord || discover,
420
+ ...(request.exact ? { exact: true } : {}),
421
+ kinds: ["issue", "project", "comment"],
422
+ limit: Math.min(depth, 500),
423
+ accounts: read,
424
+ });
425
+ hasMore ||= found.hasMore;
426
+ lists.push(found.items.map(({ account: at, item, excerpt: text }) => ({
427
+ kind: TRACKER_HIT_KINDS[item.kind],
428
+ // Two sign-ins see the same issue under the same id, so the account keeps their hits apart.
429
+ ref: `tracker:${at.provider}/${at.account}/${item.kind}/${item.record.externalId}`,
430
+ provider: at.provider,
431
+ account: at.account,
432
+ ...(item.record.url ? { url: item.record.url } : {}),
433
+ title: trackerTitle(item),
434
+ timestamp: new Date(item.record.updatedAt ?? item.syncedAt).toISOString(),
435
+ text,
436
+ foundBy: ["words"],
437
+ })));
438
+ for (const { provider, account } of read)
439
+ accounts.push({ resource, provider, account });
440
+ }
391
441
  else if (resource === "business") {
392
442
  const { words, anyWord } = titleWords(request.text, BUSINESS_WORDS_ONLY);
393
443
  const found = await searchBusiness(store, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-core",
3
- "version": "0.724.0",
3
+ "version": "0.726.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.127.0",
337
+ "@wirecat/cli-base": "0.130.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",