@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
package/CHANGELOG.md CHANGED
@@ -5,6 +5,68 @@ 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.731.0 — 23.11.2026
9
+
10
+ ### Added
11
+
12
+ - **`DOCUMENT_UNTRUSTED`, `DOCUMENT_CONTEXT_UNTRUSTED` and `marksUntrusted` from `@wirecat/cli-core/documents/cli`**,
13
+ for a CLI with its own `documents`, `catalog` or knowledge commands to mark the same text as the shared ones
14
+ ([DOCUMENTS.md](docs/dev/DOCUMENTS.md#shared-commands)).
15
+ - **`SourceWalk.deleted`**: the ids a stopped walk found deleted, so the call that resumes it removes them as
16
+ deleted. A CLI that validates its walk file with a strict schema must accept the key; one that strips it removes
17
+ them as `unavailable` ([DOCUMENTS.md](docs/dev/DOCUMENTS.md#walks-over-several-syncs)).
18
+
19
+ ### Changed — may break callers
20
+
21
+ - **The tracker writes use the family's words.** `issues comment <issue> --body <text>` is now
22
+ `issues comments create <issue> --text <text>`, and its permission key `issues.comment` is now
23
+ `issues.comments.create` (`TRACKER_WRITE_KEYS`): a saved `issues.comment` is refused and names the new key, and
24
+ `trackerAlsoChecks` finds the write by its path. On `issues create|update`, `--state <state>` is now
25
+ `--status <state>`, the family's flag for the state to put a thing in, and `--parent <issue>` is now `--parent <id>`,
26
+ with the same values. `--priority <n>` takes the family's priority, as `tasks` do: low, medium, high, critical
27
+ (or the tracker's urgent) and none, a score from 0.0 to 1.0, or the old 0 urgent … 4 low, written on the tracker's
28
+ scale (critical 1, high 2, medium 3, low 4, none 0). A bare `2` was the tracker's high and is now the family's
29
+ medium. An issue's answer has `priority_label` beside the tracker's `priority`. No tracker CLI with these commands
30
+ is published yet; linear-cli moves its tests and README with its next bump
31
+ ([TRACKER.md](docs/dev/TRACKER.md#writes), #3237).
32
+
33
+ ### Fixed
34
+
35
+ - **A documents CLI marks other people's text for a scheduled agent.** The shared reads declare the names, titles,
36
+ paths, text, excerpts and link text of a provider's files as untrusted (`DOCUMENT_UNTRUSTED`): `documents
37
+ list|show|history`, `changes`, `search`, `folders list`, `folders browse`, `catalog show|list|search|tree`, the link
38
+ text in `relationships list`, and in `documents context` the document and its links but not the owner's notes,
39
+ memories and facts. `files sheets show` and `files documents show` mark the cells and paragraphs, `mirrors
40
+ conflicts show` the path, the three versions, the merge and its hunks. In a run locked read-only with a mark, that
41
+ text now comes between the run's markers, so an agent's answers there quote it marked; elsewhere no answer changes.
42
+ A CLI with its own copies of these commands declares the same list, exported with `marksUntrusted` from
43
+ `@wirecat/cli-core/documents/cli` ([DOCUMENTS.md](docs/dev/DOCUMENTS.md#shared-commands)).
44
+ - **A full walk removes a row its listing puts in the trash as deleted.** A listed row with `trashed: true` (Linear's
45
+ trash, listed through `includeArchived`; a manifest's `trashed` path) used to stay `unavailable` with its text kept
46
+ for good when a `--rescan` saw it first; it now leaves as `deleted`, as the change feed's trashed row does, and
47
+ `changes` shows it so. A row a finished walk does not list is still `unavailable`. A stopped walk, a round of
48
+ changes' included, keeps the reason in its walk file's new `deleted` list ([DOCUMENTS.md](docs/dev/DOCUMENTS.md#a-trashed-row-in-a-listing)).
49
+
50
+ ## 0.730.0 — 23.11.2026
51
+
52
+ ### Added
53
+
54
+ - **`search all` finds issues, projects and comments by meaning.** A tracker's issues, projects and comments get
55
+ chunks as notes do (`tracker_item`), kept in step by `save` and `removeUnlisted`, and `embedTracker` embeds them
56
+ with the shared text model. The tracker lane fuses words and meaning by reciprocal rank, says how it searched under
57
+ `tracker: { by, meaningSkipped? }`, and marks each hit's `foundBy`. A tracker CLI's `sync --embed` embeds new items,
58
+ the combined sync with documents too, within the deadline; a model not downloaded keeps the sync's answer and is
59
+ named in `meta.issues`. Items synced before are embedded at the next `sync --embed`
60
+ ([TRACKER.md](docs/dev/TRACKER.md#search-all)).
61
+
62
+ ### Fixed
63
+
64
+ - **A documents `sync --embed` stops embedding before the run's deadline.** `embedNotes` now gets the deadline the
65
+ sync had, so `--timeout` bounds the embedding too and the answer says when it stopped
66
+ ([DOCUMENTS.md](docs/dev/DOCUMENTS.md#walks-over-several-syncs)).
67
+ - A tracker's combined `sync` that cannot reach the tracker and has no documents folder chosen fails as a tracker-only
68
+ `sync` does (for example `authentication_error` before sign-in) instead of a partial answer that exits 0.
69
+
8
70
  ## 0.729.0 — 23.11.2026
9
71
 
10
72
  ### Added
@@ -24,12 +24,12 @@ export interface DailyArchiveTimerInput {
24
24
  }
25
25
  export declare const dailyArchiveTimer: (input: DailyArchiveTimerInput) => DailyArchiveTimer;
26
26
  export declare const manageDailyArchiveTimer: (plan: DailyArchiveTimer, action: "install" | "start" | "stop" | "status" | "uninstall", system: Pick<ServerSystem, "platform" | "run">, env: NodeJS.ProcessEnv, signal?: AbortSignal) => Promise<{
27
+ action?: undefined;
27
28
  name: string;
28
29
  installed: boolean;
29
30
  active: boolean;
30
31
  servicePath: string;
31
32
  timerPath: string;
32
- action?: undefined;
33
33
  } | {
34
34
  active?: undefined;
35
35
  name: string;
@@ -5,6 +5,7 @@ import { CATALOG_QUERY } from "../../store/index.js";
5
5
  import { honoursDryRun } from "../dry-run-guard.js";
6
6
  import { LOCAL_READ, LOCAL_WRITE } from "../effects.js";
7
7
  import { itemOf, listOf } from "../envelope.js";
8
+ import { DOCUMENT_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
8
9
  import { bindQuery, documentQueries, tagRow, termsOf } from "./queries.js";
9
10
  import { allOf, examples, nonnegative, positive, wordsOf } from "./words.js";
10
11
  /** How many entries one `catalog tree` answer holds before it asks for a smaller folder or depth. */
@@ -147,6 +148,8 @@ export const CATALOG_FIELDS = Object.keys({
147
148
  content: true,
148
149
  });
149
150
  const local = (command, mutates = false) => annotate(command, { effects: mutates ? LOCAL_WRITE : LOCAL_READ });
151
+ // Names, descriptions and the people seen on a file are the provider's; the owner's own tags are not in these answers.
152
+ const read = (command) => marksUntrusted(local(command), DOCUMENT_UNTRUSTED);
150
153
  const addDocumentCatalogCommandsDefinition = (program, helpers) => {
151
154
  const { output } = helpers;
152
155
  const wording = wordsOf(helpers.words);
@@ -170,7 +173,7 @@ const addDocumentCatalogCommandsDefinition = (program, helpers) => {
170
173
  return found;
171
174
  };
172
175
  examples(local(catalog.command("import").description("put cached file and folder metadata into the shared database"), true), [`${prefix} catalog import --offline`]).action(async () => output(itemOf(await run((index, principal) => index.catalog.import(principal), true))));
173
- examples(annotate(local(catalog.command("show").description("show stored metadata and the stable file or folder reference")), {
176
+ examples(annotate(read(catalog.command("show").description("show stored metadata and the stable file or folder reference")), {
174
177
  output: { entity: "document", view },
175
178
  }), [`${prefix} catalog show FILE_ID --offline`])
176
179
  .argument("<file>", text.catalogArgument)
@@ -189,7 +192,7 @@ const addDocumentCatalogCommandsDefinition = (program, helpers) => {
189
192
  }));
190
193
  };
191
194
  for (const action of ["list", "search"]) {
192
- const command = examples(local(catalog
195
+ const command = examples(read(catalog
193
196
  .command(action)
194
197
  .description(action === "list"
195
198
  ? "list cached files and folders using metadata queries"
@@ -204,7 +207,7 @@ const addDocumentCatalogCommandsDefinition = (program, helpers) => {
204
207
  .action(async (terms, args) => list(terms, args, action === "search"));
205
208
  annotate(command, { query: CATALOG_QUERY, output: { entity: "document", view } });
206
209
  }
207
- examples(local(catalog.command("tree").description("show the cached hierarchy below a folder or all selected roots")), [`${prefix} catalog tree --offline`, `${prefix} catalog tree FOLDER_ID --depth 3 --offline`])
210
+ examples(read(catalog.command("tree").description("show the cached hierarchy below a folder or all selected roots")), [`${prefix} catalog tree --offline`, `${prefix} catalog tree FOLDER_ID --depth 3 --offline`])
208
211
  .argument("[folder]", text.treeArgument)
209
212
  .option("--depth <n>", "maximum descendant depth, from 0 to 50", nonnegative, 5)
210
213
  .action(async (id, args) => output(await run(async (index, principal) => {
@@ -6,13 +6,14 @@ import { honoursDryRun } from "../dry-run-guard.js";
6
6
  import { LOCAL_READ, LOCAL_WRITE } from "../effects.js";
7
7
  import { itemOf, listOf } from "../envelope.js";
8
8
  import { listQuery, typedQuery, withQuery } from "../list-query.js";
9
+ import { DOCUMENT_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
9
10
  import { ageOf, documentsGroup, examples, positive, staleCopy, wordsOf } from "./words.js";
10
11
  const addLocalDocumentCommandsDefinition = (program, helpers) => {
11
12
  const { output, lastSync } = helpers;
12
13
  const wording = wordsOf(helpers.words);
13
14
  const { prefix, provider, text } = wording;
14
15
  const documents = documentsGroup(program, wording);
15
- annotate(withQuery(examples(annotate(documents.command("list"), { effects: LOCAL_READ }).description(text.documentsList), [
16
+ annotate(withQuery(examples(marksUntrusted(annotate(documents.command("list"), { effects: LOCAL_READ }).description(text.documentsList), DOCUMENT_UNTRUSTED), [
16
17
  `${prefix} documents list`,
17
18
  `${prefix} documents list tag:budget`,
18
19
  `${prefix} documents list person:PERSON_UID --limit 10`,
@@ -34,7 +35,7 @@ const addLocalDocumentCommandsDefinition = (program, helpers) => {
34
35
  args: { query: query || undefined },
35
36
  }));
36
37
  });
37
- examples(annotate(documents.command("show"), { effects: LOCAL_READ, partial: true })
38
+ examples(marksUntrusted(annotate(documents.command("show"), { effects: LOCAL_READ, partial: true }), DOCUMENT_UNTRUSTED)
38
39
  .argument("<document>", text.documentArgument)
39
40
  .description("show an imported document's text, tabs and metadata"), [`${prefix} documents show DOC_ID`, `${prefix} documents show document:42 --offline`]).action((input) => {
40
41
  const { metadata, snapshot } = helpers.document(input);
@@ -7,8 +7,19 @@ import { refusedPlace } from "../../sends/upload.js";
7
7
  import { environmentOf } from "../context.js";
8
8
  import { LOCAL_READ, ownerOnlyOption, REMOTE_WRITE } from "../effects.js";
9
9
  import { itemOf, listOf, snakeKeys } from "../envelope.js";
10
+ import { marksUntrusted } from "../untrusted-marks.js";
10
11
  const ID = "mirror id from mirrors list";
11
12
  const PATH = "the file's path inside the mirror, like notes/plan.md";
13
+ const CONFLICT_UNTRUSTED = [
14
+ "path",
15
+ "base.text",
16
+ "local.text",
17
+ "remote.text",
18
+ "merged",
19
+ "hunks.base",
20
+ "hunks.local",
21
+ "hunks.remote",
22
+ ];
12
23
  /**
13
24
  * `mirrors conflicts list|show|resolve` for a file mirror: the conflicts the last sync left, each with its three
14
25
  * versions and the line merge that failed, and a resolution that writes one final content to both sides.
@@ -36,10 +47,12 @@ export const fileConflictsCommand = (helpers) => {
36
47
  has_more: false,
37
48
  }));
38
49
  }))
39
- .addCommand(annotate(new Command("show"), {
50
+ .addCommand(
51
+ // The remote side is someone else's, and the base and the merge hold it too.
52
+ marksUntrusted(annotate(new Command("show"), {
40
53
  effects: LOCAL_READ,
41
54
  examples: [`${app} personal mirrors conflicts show 1a2b3c4d notes/plan.md --json`],
42
- })
55
+ }), CONFLICT_UNTRUSTED)
43
56
  .summary("show a conflict's three versions and the lines that conflict")
44
57
  .description("show a conflict's three versions (the last sync's, the local and the remote) and each changed stretch " +
45
58
  "of the line merge; merged is the whole file with conflict markers, a start for resolve --file")
@@ -10,6 +10,7 @@ import { guardedFileWrite, remoteChanged } from "../../services/files/guarded-wr
10
10
  import { honoursDryRun } from "../dry-run-guard.js";
11
11
  import { REMOTE_READ, REMOTE_WRITE } from "../effects.js";
12
12
  import { itemOf } from "../envelope.js";
13
+ import { marksUntrusted } from "../untrusted-marks.js";
13
14
  import { addFileUpdateCommand, replacedOf, sha256Of, } from "./file-update.js";
14
15
  import { examples, wordsOf } from "./words.js";
15
16
  /** The whole file is held in memory to edit it. */
@@ -158,7 +159,11 @@ const addFileEditCommandsDefinition = (files, helpers) => {
158
159
  helpers.output(itemOf(item), command);
159
160
  };
160
161
  const sheets = annotate(files.command("sheets"), { effects: REMOTE_READ }).description(`the cells of an Excel workbook (.xlsx) on ${place}, read and changed in place`);
161
- examples(annotate(sheets.command("show"), { effects: REMOTE_READ, offline: false })
162
+ examples(marksUntrusted(annotate(sheets.command("show"), { effects: REMOTE_READ, offline: false }), [
163
+ "sheets.name",
164
+ "sheets.cells.value",
165
+ "sheets.cells.formula",
166
+ ])
162
167
  .summary("show a workbook's cells and the sha256 to edit them at")
163
168
  .description("show a workbook's stored cells, each with its value, type, formula and format, and the file's sha256 to pass " +
164
169
  "as --expected-fingerprint to sheets update. Formulas show the value Excel saved last")
@@ -235,7 +240,7 @@ const addFileEditCommandsDefinition = (files, helpers) => {
235
240
  });
236
241
  });
237
242
  const documents = annotate(files.command("documents"), { effects: REMOTE_READ }).description(`the paragraphs of a Word document (.docx) on ${place}, read and changed in place`);
238
- examples(annotate(documents.command("show"), { effects: REMOTE_READ, offline: false })
243
+ examples(marksUntrusted(annotate(documents.command("show"), { effects: REMOTE_READ, offline: false }), ["paragraphs.text"])
239
244
  .summary("show a document's paragraphs and the sha256 to edit them at")
240
245
  .description("show a Word document's paragraphs by index, with their style, whether each can be edited and why not, and " +
241
246
  "the file's sha256 to pass as --expected-fingerprint to documents update")
@@ -2,6 +2,7 @@ import { annotate, sharedCommand } from "@wirecat/cli-base/commands";
2
2
  import { honoursDryRun } from "../dry-run-guard.js";
3
3
  import { FETCH, LOCAL_READ, LOCAL_WRITE } from "../effects.js";
4
4
  import { itemOf } from "../envelope.js";
5
+ import { DOCUMENT_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
5
6
  import { bindQuery, documentQueries, folderRow, termsOf } from "./queries.js";
6
7
  import { allOf, examples, wordsOf } from "./words.js";
7
8
  const addDocumentFolderCommandsDefinition = (program, helpers) => {
@@ -16,7 +17,7 @@ const addDocumentFolderCommandsDefinition = (program, helpers) => {
16
17
  const { id, name } = await helpers.add(input);
17
18
  output(itemOf({ id, name, added: true }));
18
19
  });
19
- bindQuery(examples(annotate(folders.command("list"), { effects: LOCAL_READ }).description("list the folder ids sync imports"), [`${prefix} folders list`]), queries.folders, folderRow).action((words) => {
20
+ bindQuery(examples(marksUntrusted(annotate(folders.command("list"), { effects: LOCAL_READ }), DOCUMENT_UNTRUSTED).description("list the folder ids sync imports"), [`${prefix} folders list`]), queries.folders, folderRow).action((words) => {
20
21
  const filter = termsOf(words, queries.folders, "folders list");
21
22
  output(allOf(helpers.list(filter)));
22
23
  });
@@ -9,6 +9,7 @@ import { honoursDryRun } from "../dry-run-guard.js";
9
9
  import { LOCAL_READ } from "../effects.js";
10
10
  import { itemOf, listOf } from "../envelope.js";
11
11
  import { count, fromFile } from "../settings.js";
12
+ import { DOCUMENT_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
12
13
  import { documentsGroup, examples, positive, wordsOf } from "./words.js";
13
14
  /** `keep_versions_for_days`: a documents CLI adds it to `settingsFor` and passes `keepVersionsForDays` to its sync. */
14
15
  export const DOCUMENT_HISTORY_SETTINGS = {
@@ -42,7 +43,7 @@ const addDocumentHistoryCommandsDefinition = (program, helpers) => {
42
43
  });
43
44
  return found;
44
45
  };
45
- examples(annotate(documents.command("history"), { effects: LOCAL_READ })
46
+ examples(marksUntrusted(annotate(documents.command("history"), { effects: LOCAL_READ }), DOCUMENT_UNTRUSTED)
46
47
  .argument("<document>", text.documentArgument)
47
48
  .description("list the versions of a document kept in the local copy, or show one with --revision"), [`${prefix} documents history DOC_ID`, `${prefix} documents history DOC_ID --revision 3`])
48
49
  .option("--revision <n>", "show the text of this version", positive)
@@ -54,7 +55,7 @@ const addDocumentHistoryCommandsDefinition = (program, helpers) => {
54
55
  }
55
56
  helpers.output(itemOf(await history.versions(ref)));
56
57
  }));
57
- return examples(annotate(program.command("changes"), { effects: LOCAL_READ }).description("list the documents the sync added, changed, removed or brought back, newest first"), [`${prefix} changes`, `${prefix} changes --since 7d --event deleted,unavailable`])
58
+ return examples(marksUntrusted(annotate(program.command("changes"), { effects: LOCAL_READ }), DOCUMENT_UNTRUSTED).description("list the documents the sync added, changed, removed or brought back, newest first"), [`${prefix} changes`, `${prefix} changes --since 7d --event deleted,unavailable`])
58
59
  .option("--since <time>", "from this time: an ISO 8601 time, today, yesterday, or 30m, 2h, 1d ago", "1d")
59
60
  .option("--until <time>", "up to this time, in the same forms")
60
61
  .option(`--event <events>`, `only these, comma separated: ${DOCUMENT_EVENTS.join(", ")}`, eventList)
@@ -8,6 +8,7 @@ import { type DocumentMirrorCommands } from "./mirrors.js";
8
8
  import { type DocumentSearchCommands } from "./search.js";
9
9
  import { type DocumentSyncCommands } from "./sync.js";
10
10
  import type { DocumentWords } from "./words.js";
11
+ export { DOCUMENT_CONTEXT_UNTRUSTED, DOCUMENT_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
11
12
  export { addDocumentCatalogCommands, CATALOG_FIELDS, type CatalogTree, type CatalogTreeSource, catalogId, catalogOutput, catalogSource, catalogTree, type DocumentCatalog, type DocumentCatalogCommands, type DocumentCatalogStores, } from "./catalog.js";
12
13
  export { addLocalDocumentCommands, type ImportedDocument, type LocalDocumentCommands } from "./documents.js";
13
14
  export { type FileConflictCommands, type FileConflictConnection, fileConflictsCommand } from "./file-conflicts.js";
@@ -6,6 +6,7 @@ import { addDocumentKnowledgeCommands } from "./knowledge.js";
6
6
  import { addDocumentMirrorCommands } from "./mirrors.js";
7
7
  import { addDocumentSearchCommand } from "./search.js";
8
8
  import { addDocumentSyncCommands } from "./sync.js";
9
+ export { DOCUMENT_CONTEXT_UNTRUSTED, DOCUMENT_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
9
10
  export { addDocumentCatalogCommands, CATALOG_FIELDS, catalogId, catalogOutput, catalogSource, catalogTree, } from "./catalog.js";
10
11
  export { addLocalDocumentCommands } from "./documents.js";
11
12
  export { fileConflictsCommand } from "./file-conflicts.js";
@@ -7,6 +7,7 @@ import { honoursDryRun } from "../dry-run-guard.js";
7
7
  import { LOCAL_READ, LOCAL_WRITE, REMOTE_WRITE } from "../effects.js";
8
8
  import { itemOf, listOf } from "../envelope.js";
9
9
  import { queryHelp, queryTerms, withQuery } from "../list-query.js";
10
+ import { DOCUMENT_CONTEXT_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
10
11
  import { bindQuery, documentQueries, FACT_QUERY, factItem, identityRow, linkRow, MEMORY_QUERY, MEMORY_SEARCH_QUERY, memoryItem, memorySearch, tagRow, termsOf, } from "./queries.js";
11
12
  import { allOf, documentsGroup, examples, positive, wordsOf } from "./words.js";
12
13
  const addDocumentKnowledgeCommandsDefinition = (program, helpers) => {
@@ -17,7 +18,7 @@ const addDocumentKnowledgeCommandsDefinition = (program, helpers) => {
17
18
  const documentArgument = text.knowledgeArgument;
18
19
  const scopes = ["personal", "work"];
19
20
  const documents = documentsGroup(program, wording);
20
- examples(annotate(documents.command("context"), { effects: LOCAL_READ })
21
+ examples(marksUntrusted(annotate(documents.command("context"), { effects: LOCAL_READ }), DOCUMENT_CONTEXT_UNTRUSTED)
21
22
  .argument("<document>", documentArgument)
22
23
  .description("show a document with its tags, relationships, notes, memories and editors"), [`${prefix} documents context DOC_ID`]).action(async (doc) => output(itemOf(await run(doc, (k, p, ref) => k.context(p, ref)))));
23
24
  const tags = annotate(program.command("tags"), { effects: LOCAL_READ }).description("label imported documents; labels survive a sync");
@@ -37,7 +38,10 @@ const addDocumentKnowledgeCommandsDefinition = (program, helpers) => {
37
38
  .action(async (doc, values) => output(itemOf({ tags: await run(doc, (k, p, ref) => k.tags(p, ref, action, values)) })));
38
39
  }
39
40
  const relationships = annotate(program.command("relationships"), { effects: LOCAL_READ }).description("connect a document to people, projects, notes and other references");
40
- bindQuery(examples(annotate(relationships.command("list"), { effects: LOCAL_READ }).description("list a document's relationships"), [`${prefix} relationships list DOC_ID`]).argument("<document>", documentArgument), queries.links, linkRow).action(async (doc, words) => {
41
+ bindQuery(examples(marksUntrusted(annotate(relationships.command("list"), { effects: LOCAL_READ }), [
42
+ "targetText",
43
+ "target_text",
44
+ ]).description("list a document's relationships"), [`${prefix} relationships list DOC_ID`]).argument("<document>", documentArgument), queries.links, linkRow).action(async (doc, words) => {
41
45
  const { confirmed, ...filter } = termsOf(words, queries.links, "relationships list");
42
46
  output(allOf(await run(doc, (k, p, ref) => k.links(p, ref, { ...filter, ...(confirmed === undefined ? {} : { confirmed: confirmed === "true" }) }))));
43
47
  });
@@ -19,6 +19,7 @@ import { writesOwnerFiles } from "../effects.js";
19
19
  import { renderAnswer } from "../envelope.js";
20
20
  import { accountFileFor, profilesHere, rememberAccount } from "../messenger/accounts.js";
21
21
  import { ProfileTokenStore } from "../profile-token.js";
22
+ import { DOCUMENT_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
22
23
  import { addDocumentCatalogCommands } from "./catalog.js";
23
24
  import { addLocalDocumentCommands } from "./documents.js";
24
25
  import { addDocumentFolderCommands } from "./folders.js";
@@ -374,7 +375,12 @@ const libraryOf = (options, withSync) => {
374
375
  const { embedNotes } = await import("../../services/notes-search.js");
375
376
  return {
376
377
  ...result,
377
- embeddings: await embedNotes(store, { maxChunks: 600, env: env(), command: app.command }),
378
+ embeddings: await embedNotes(store, {
379
+ maxChunks: 600,
380
+ env: env(),
381
+ command: app.command,
382
+ ...(deadline ? { deadline } : {}),
383
+ }),
378
384
  };
379
385
  }));
380
386
  }, deadline);
@@ -537,8 +543,9 @@ const libraryOf = (options, withSync) => {
537
543
  const folders = find(holder, "folders");
538
544
  // Choosing a folder changes what the next sync keeps and removes, so an agent asks for it through the write tool.
539
545
  writesOwnerFiles(find(folders, "add"));
546
+ // The CLI's own listing of the provider's folders: names others chose.
540
547
  if (options.browse)
541
- annotate(find(folders, "browse"), { partial: true });
548
+ marksUntrusted(annotate(find(folders, "browse"), { partial: true }), DOCUMENT_UNTRUSTED);
542
549
  const start = (action, side, account) => {
543
550
  running = action;
544
551
  warnings = [];
@@ -2,6 +2,7 @@ import { annotate, sharedCommand } from "@wirecat/cli-base/commands";
2
2
  import { honoursDryRun } from "../dry-run-guard.js";
3
3
  import { LOCAL_READ } from "../effects.js";
4
4
  import { itemOf } from "../envelope.js";
5
+ import { DOCUMENT_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
5
6
  import { examples, positive, wordsOf } from "./words.js";
6
7
  const notImported = (app, folder, { profile, chosen, documents }) => {
7
8
  if (documents > 0)
@@ -14,7 +15,9 @@ const notImported = (app, folder, { profile, chosen, documents }) => {
14
15
  const addDocumentSearchCommandDefinition = (program, helpers) => {
15
16
  const wording = wordsOf(helpers.words);
16
17
  const { prefix } = wording;
17
- return examples(annotate(program.command("search"), { effects: LOCAL_READ })
18
+ return examples(
19
+ // Every hit is a document the profile copied from the provider, never a note of the owner's.
20
+ marksUntrusted(annotate(program.command("search"), { effects: LOCAL_READ }), DOCUMENT_UNTRUSTED)
18
21
  .argument("<query>", "words to look for, and fields such as tag: and date: that every hit must match")
19
22
  .description("search imported documents by words, and by meaning when indexed"), [`${prefix} search budget`, `${prefix} search "quarterly plan" --exact --limit 5`])
20
23
  .option("--limit <n>", "how many results to return", positive, 20)
@@ -24,6 +24,16 @@ export declare const MESSAGE_UNTRUSTED: readonly ["text", "transcript", "excerpt
24
24
  export declare const CHAT_UNTRUSTED: readonly ["title", "description"];
25
25
  /** Other people's text in a contact: what the person says about themselves and the titles of the chats shared. */
26
26
  export declare const CONTACT_UNTRUSTED: readonly ["description", "chats.title"];
27
+ /**
28
+ * Other people's text in a documents CLI's copy of a provider's files: names, titles and paths others chose, a
29
+ * document's text and tabs, a hit's excerpt and the link text written in it. Anyone who shares a file writes these.
30
+ */
31
+ export declare const DOCUMENT_UNTRUSTED: readonly ["name", "title", "path", "text", "description", "excerpt", "target_text", "targetText"];
32
+ /**
33
+ * `documents context`: the document and the links written in it. The notes, memories, facts and tags beside it are
34
+ * the owner's own, as a note is in `search notes`, so a bare `text` or `title` would mark them too.
35
+ */
36
+ export declare const DOCUMENT_CONTEXT_UNTRUSTED: string[];
27
37
  /** Declares the fields of a read's answer that hold other people's text, at any depth, for a scheduled agent's run. */
28
38
  export declare const marksUntrusted: <T extends Command>(command: T, fields?: readonly string[]) => T;
29
39
  export declare const untrustedFieldsOf: (command: Command) => readonly string[] | undefined;
@@ -90,6 +90,25 @@ export const MESSAGE_UNTRUSTED = [
90
90
  export const CHAT_UNTRUSTED = ["title", "description"];
91
91
  /** Other people's text in a contact: what the person says about themselves and the titles of the chats shared. */
92
92
  export const CONTACT_UNTRUSTED = ["description", "chats.title"];
93
+ /**
94
+ * Other people's text in a documents CLI's copy of a provider's files: names, titles and paths others chose, a
95
+ * document's text and tabs, a hit's excerpt and the link text written in it. Anyone who shares a file writes these.
96
+ */
97
+ export const DOCUMENT_UNTRUSTED = [
98
+ "name",
99
+ "title",
100
+ "path",
101
+ "text",
102
+ "description",
103
+ "excerpt",
104
+ "target_text",
105
+ "targetText",
106
+ ];
107
+ /**
108
+ * `documents context`: the document and the links written in it. The notes, memories, facts and tags beside it are
109
+ * the owner's own, as a note is in `search notes`, so a bare `text` or `title` would mark them too.
110
+ */
111
+ export const DOCUMENT_CONTEXT_UNTRUSTED = ["document.title", "document.text", "document.path", "links.targetText"];
93
112
  const DECLARED = new WeakMap();
94
113
  /** Declares the fields of a read's answer that hold other people's text, at any depth, for a scheduled agent's run. */
95
114
  export const marksUntrusted = (command, fields = MESSAGE_UNTRUSTED) => {
@@ -144,6 +144,8 @@ export interface SourceWalk<M extends SourceFile = SourceFile> {
144
144
  folders: Record<string, M>;
145
145
  files: M[];
146
146
  discovered: number;
147
+ /** Ids of `files` the source itself marked deleted, so a walk resumed in a later call still removes them so. */
148
+ deleted?: string[];
147
149
  }
148
150
  export interface SourceIndex<M extends SourceFile = SourceFile> {
149
151
  catalog?: {
@@ -8,6 +8,8 @@ export type TrackerKind = (typeof TRACKER_KINDS)[number];
8
8
  /** Where an issue in a state stands in its work, whatever the team named the state. */
9
9
  export declare const STATE_TYPES: readonly ["triage", "backlog", "unstarted", "started", "completed", "canceled"];
10
10
  export type StateType = (typeof STATE_TYPES)[number];
11
+ /** A tracker's 0–4 priority as the family's label: 0 is none, the tracker's 1 urgent is critical. */
12
+ export declare const TRACKER_PRIORITY_LABELS: readonly [null, "critical", "high", "medium", "low"];
11
13
  /**
12
14
  * Every record has the tracker's id. A field left out means the tracker did not say, and the store keeps what it
13
15
  * held; `null` means the tracker said there is none. Times are epoch milliseconds.
@@ -6,6 +6,8 @@
6
6
  export const TRACKER_KINDS = ["team", "user", "state", "label", "project", "issue", "comment"];
7
7
  /** Where an issue in a state stands in its work, whatever the team named the state. */
8
8
  export const STATE_TYPES = ["triage", "backlog", "unstarted", "started", "completed", "canceled"];
9
+ /** A tracker's 0–4 priority as the family's label: 0 is none, the tracker's 1 urgent is critical. */
10
+ export const TRACKER_PRIORITY_LABELS = [null, "critical", "high", "medium", "low"];
9
11
  /** The record's title in lists and search: an issue's title, a comment's start, anything else's name. */
10
12
  export const trackerTitleOf = (kind, record) => kind === "issue"
11
13
  ? record.title
@@ -86,8 +86,19 @@ export const planDocuments = async (options, source, state, roots, limit, pictur
86
86
  files.delete(id);
87
87
  removals.set(id, reason);
88
88
  };
89
+ // A listing's own trash is the same signal as the feed's: the row leaves the copy as deleted. A full walk has
90
+ // cleared `files`, so the row goes into the saved walk from here.
91
+ const trash = (file) => {
92
+ files.delete(file.id);
93
+ delta.set(file.id, file);
94
+ removals.set(file.id, "deleted");
95
+ };
89
96
  const container = (file) => {
90
- if (options.isDocument?.(file))
97
+ if (!options.isDocument?.(file))
98
+ return;
99
+ if (file.trashed)
100
+ trash(file);
101
+ else
91
102
  keep(file);
92
103
  };
93
104
  // A folder the last finished pass walked keeps its subtree: a round lists only its direct children, and the
@@ -188,10 +199,13 @@ export const planDocuments = async (options, source, state, roots, limit, pictur
188
199
  let found = [];
189
200
  if (walk) {
190
201
  const visited = new Set(walk.visited);
202
+ const deleted = new Set(walk.deleted);
191
203
  Object.assign(folders, walk.folders);
192
204
  for (const file of walk.files) {
193
- // A walk saved part way keeps no reason; one it cannot prove is a deletion keeps the text.
194
- if (file.trashed)
205
+ // One the saved walk cannot prove is a deletion keeps the text.
206
+ if (file.trashed && deleted.has(file.id))
207
+ trash(file);
208
+ else if (file.trashed)
195
209
  drop(file.id, "unavailable");
196
210
  else
197
211
  keep(file);
@@ -201,7 +215,14 @@ export const planDocuments = async (options, source, state, roots, limit, pictur
201
215
  let savedAt = now();
202
216
  const current = walk;
203
217
  const record = () => {
204
- walks?.save({ ...current, visited: [...visited], folders, files: [...delta.values()] });
218
+ const deleted = [...removals].flatMap(([id, reason]) => (reason === "deleted" && delta.has(id) ? [id] : []));
219
+ walks?.save({
220
+ ...current,
221
+ visited: [...visited],
222
+ folders,
223
+ files: [...delta.values()],
224
+ ...(deleted.length ? { deleted } : {}),
225
+ });
205
226
  savedAt = now();
206
227
  };
207
228
  let spent = 0;
@@ -303,6 +324,8 @@ export const planDocuments = async (options, source, state, roots, limit, pictur
303
324
  else
304
325
  nested.push({ id: file.id, ancestry: [...step.ancestry, folder.id], folder: file });
305
326
  }
327
+ else if (file.trashed)
328
+ trash(file);
306
329
  else
307
330
  keep(file);
308
331
  walk.stack.pop();
@@ -335,11 +358,13 @@ export const planDocuments = async (options, source, state, roots, limit, pictur
335
358
  found = await query.list();
336
359
  const matched = new Set();
337
360
  for (const file of found) {
338
- if ((isFolder(file) && !options.isDocument?.(file)) ||
339
- file.trashed ||
340
- !query?.matches(file) ||
341
- matched.has(file.id))
361
+ if ((isFolder(file) && !options.isDocument?.(file)) || !query?.matches(file) || matched.has(file.id))
342
362
  continue;
363
+ if (file.trashed) {
364
+ files.delete(file.id);
365
+ removals.set(file.id, "deleted");
366
+ continue;
367
+ }
343
368
  // Listed again on every sync, so only a new or changed file is work; a skipped one keeps its skip.
344
369
  const prior = state.documents[file.id]?.metadata ?? state.skipped.find((item) => item.id === file.id)?.file;
345
370
  if (initial || !prior || changedSince(prior, file))
@@ -389,8 +414,9 @@ export const planDocuments = async (options, source, state, roots, limit, pictur
389
414
  // After every real edit, so a run that stops on its deadline spends it on those first.
390
415
  for (const job of again)
391
416
  jobs.push(job);
392
- // Absent from the listing is not a deletion: only the source's own signal is (`drop`). Out of scope is `unsynced`
393
- // only when the owner changed the scope; a folder above that was unshared or vanished leaves its files unavailable.
417
+ // Absent from the listing is not a deletion: only the source's own signal is (`drop`, `trash`). Out of scope is
418
+ // `unsynced` only when the owner changed the scope; a folder above that was unshared or vanished leaves its files
419
+ // unavailable.
394
420
  const narrowed = state.scope !== scope;
395
421
  for (const id of Object.keys(state.documents)) {
396
422
  const file = files.get(id);
@@ -231,3 +231,4 @@ export { createStoredMeetingProjectCandidateReader } from "./stored-meeting-proj
231
231
  export { applyTaskRulesSinceLastPass, applyTaskRulesToStored, type RuleResult } from "./task-rules.js";
232
232
  export type { ThreadContext, ThreadOptions } from "./thread-context.js";
233
233
  export { readThreadContext, THREAD_BOUNDS } from "./thread-context.js";
234
+ export { embedTracker, nearestTracker } from "./tracker-meaning.js";
@@ -179,3 +179,4 @@ export { SERVER_BOUNDS, SERVER_SEARCH_KEY, } from "./server-search.js";
179
179
  export { createStoredMeetingProjectCandidateReader } from "./stored-meeting-project-candidates.js";
180
180
  export { applyTaskRulesSinceLastPass, applyTaskRulesToStored } from "./task-rules.js";
181
181
  export { readThreadContext, THREAD_BOUNDS } from "./thread-context.js";
182
+ export { embedTracker, nearestTracker } from "./tracker-meaning.js";
@@ -84,6 +84,18 @@ export declare const localModel: (choice: string | undefined, env: NodeJS.Proces
84
84
  key: string;
85
85
  };
86
86
  export declare const withLocal: <T>(model: TextModel, directory: string, threads: number | undefined, work: (embedder: Embedder) => Promise<T>, shared?: Pick<WarmEmbedders, "get">) => Promise<T>;
87
+ /**
88
+ * Embeds the notes' chunks that have no vector of the model yet, with the same model, prefixes and key
89
+ * as conversations, so a chunk whose text a conversation shares is embedded once. A missing model is
90
+ * an error naming the download command; nothing is downloaded.
91
+ */
92
+ /** When a run with this deadline stops: its margin before the end, as the word index after a sync does. */
93
+ export declare const stopsAt: (deadline: Deadline | undefined) => number;
94
+ export declare const embedChunks: (store: MessageStore, source: Pick<MessageStore["notes"] | MessageStore["calendar"] | MessageStore["tracker"], "chunksToEmbed"> & {
95
+ chunksLeft?(model: string): Promise<number>;
96
+ }, { model: choice, maxChunks, env, threads, command, deadline, signal, }?: NotesEmbedOptions & {
97
+ command?: string;
98
+ }) => Promise<NotesEmbedded>;
87
99
  export declare const embedNotes: (store: MessageStore, options?: NotesEmbedOptions & {
88
100
  command?: string;
89
101
  }) => Promise<NotesEmbedded>;
@@ -97,7 +109,7 @@ export declare const embedMail: (store: MessageStore, options?: NotesEmbedOption
97
109
  }) => Promise<NotesEmbedded>;
98
110
  /** Notes nearest in meaning to the query, best first; only notes already embedded can be found. */
99
111
  export declare const nearestNotes: (store: MessageStore, query: string, options: NearestOptions) => Promise<NearestNote[]>;
100
- type NearestOptions = Omit<NotesEmbedOptions, "maxChunks"> & {
112
+ export type NearestOptions = Omit<NotesEmbedOptions, "maxChunks"> & {
101
113
  limit: number;
102
114
  folderIds?: string[];
103
115
  withInternal?: boolean;
@@ -235,4 +247,3 @@ export declare const searchNotesOf: (store: MessageStore, account: AccountKey, t
235
247
  app?: AppIdentity;
236
248
  env?: NodeJS.ProcessEnv;
237
249
  }) => Promise<NotesFoundOf>;
238
- export {};
@@ -103,8 +103,8 @@ export const withLocal = async (model, directory, threads, work, shared) => {
103
103
  * an error naming the download command; nothing is downloaded.
104
104
  */
105
105
  /** When a run with this deadline stops: its margin before the end, as the word index after a sync does. */
106
- const stopsAt = (deadline) => deadline ? deadline.endsAt - deadlineMargin(deadline) : Number.POSITIVE_INFINITY;
107
- const embedChunks = async (store, source, { model: choice, maxChunks = Number.POSITIVE_INFINITY, env, threads, command, deadline, signal, } = {}) => {
106
+ export const stopsAt = (deadline) => deadline ? deadline.endsAt - deadlineMargin(deadline) : Number.POSITIVE_INFINITY;
107
+ export const embedChunks = async (store, source, { model: choice, maxChunks = Number.POSITIVE_INFINITY, env, threads, command, deadline, signal, } = {}) => {
108
108
  const { model, directory, key } = localModel(choice, env, command);
109
109
  if ((await source.chunksToEmbed(key, { limit: 1 })).length === 0)
110
110
  return { model: model.id, embedded: 0, left: false };
@@ -101,6 +101,11 @@ export interface SearchAllFound {
101
101
  by: "words" | "words and meaning";
102
102
  meaningSkipped?: string;
103
103
  };
104
+ /** How issues, projects and comments were searched, when they were; never by meaning with `exact`. */
105
+ tracker?: {
106
+ by: "words" | "words and meaning";
107
+ meaningSkipped?: string;
108
+ };
104
109
  /** How the messages were searched, when they were; never by meaning with `exact` or the server alone. */
105
110
  messages?: {
106
111
  by: "words" | "words and meaning";