@wirecat/cli-core 0.547.0 → 0.549.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 (79) hide show
  1. package/CHANGELOG.md +228 -0
  2. package/dist/calendar/cli/answers.d.ts +7 -2
  3. package/dist/calendar/cli/answers.js +12 -4
  4. package/dist/calendar/cli/index.d.ts +10 -1
  5. package/dist/calendar/cli/index.js +18 -11
  6. package/dist/calendar/cli/search-all.d.ts +17 -0
  7. package/dist/calendar/cli/search-all.js +72 -0
  8. package/dist/calendar/feeds.d.ts +19 -0
  9. package/dist/calendar/feeds.js +52 -9
  10. package/dist/calendar/source.d.ts +10 -2
  11. package/dist/calendar/sync.d.ts +2 -0
  12. package/dist/calendar/sync.js +10 -6
  13. package/dist/calendar/testing/memory.js +39 -0
  14. package/dist/cli/answer-entity.d.ts +4 -0
  15. package/dist/cli/answer-entity.js +5 -0
  16. package/dist/cli/bot/context.d.ts +2 -0
  17. package/dist/cli/compact.d.ts +41 -0
  18. package/dist/cli/compact.js +313 -0
  19. package/dist/cli/context.d.ts +11 -2
  20. package/dist/cli/context.js +15 -6
  21. package/dist/cli/envelope.d.ts +5 -1
  22. package/dist/cli/envelope.js +15 -4
  23. package/dist/cli/index.d.ts +2 -0
  24. package/dist/cli/index.js +2 -0
  25. package/dist/cli/messenger/search-command.d.ts +10 -0
  26. package/dist/cli/messenger/search-command.js +19 -13
  27. package/dist/cli/messenger/store-maintenance-command.d.ts +1 -1
  28. package/dist/cli/program.d.ts +3 -0
  29. package/dist/cli/program.js +7 -1
  30. package/dist/domain/providers.d.ts +3 -0
  31. package/dist/domain/providers.js +20 -4
  32. package/dist/domain/ref-arguments.js +3 -7
  33. package/dist/domain/ref-summaries.d.ts +56 -0
  34. package/dist/domain/ref-summaries.js +63 -0
  35. package/dist/entities/index.d.ts +11 -0
  36. package/dist/entities/relationship.d.ts +2 -0
  37. package/dist/entities/relationship.js +2 -0
  38. package/dist/entities/task-results.d.ts +10 -0
  39. package/dist/entities/task-results.js +1 -0
  40. package/dist/errors/reasons.js +1 -0
  41. package/dist/meetings/event-store.d.ts +10 -0
  42. package/dist/meetings/testing/event-store-contract.js +36 -0
  43. package/dist/output-detail.js +9 -5
  44. package/dist/output.d.ts +5 -1
  45. package/dist/output.js +29 -4
  46. package/dist/services/proposals/kinds/relationship-update.d.ts +4 -0
  47. package/dist/services/proposals/kinds/relationship-update.js +53 -0
  48. package/dist/services/proposals/registry.js +2 -0
  49. package/dist/store/decisions.d.ts +3 -1
  50. package/dist/store/decisions.js +7 -1
  51. package/dist/store/index.d.ts +2 -1
  52. package/dist/store/sqlite/accounts.d.ts +8 -0
  53. package/dist/store/sqlite/accounts.js +2 -2
  54. package/dist/store/sqlite/calendar-forget.d.ts +17 -0
  55. package/dist/store/sqlite/calendar-forget.js +68 -0
  56. package/dist/store/sqlite/calendar.js +8 -0
  57. package/dist/store/sqlite/evidence-sources.d.ts +2 -2
  58. package/dist/store/sqlite/evidence-sources.js +41 -77
  59. package/dist/store/sqlite/knowledge.d.ts +17 -23
  60. package/dist/store/sqlite/knowledge.js +13 -13
  61. package/dist/store/sqlite/manifest.js +2 -0
  62. package/dist/store/sqlite/migrations.generated.js +12 -0
  63. package/dist/store/sqlite/notes.d.ts +5 -0
  64. package/dist/store/sqlite/notes.js +6 -2
  65. package/dist/store/sqlite/open-store.js +2 -0
  66. package/dist/store/sqlite/proposed-actions.d.ts +1 -1
  67. package/dist/store/sqlite/proposed-actions.js +10 -2
  68. package/dist/store/sqlite/ref-summaries.d.ts +17 -0
  69. package/dist/store/sqlite/ref-summaries.js +378 -0
  70. package/dist/store/sqlite/relation-proposals.d.ts +40 -0
  71. package/dist/store/sqlite/relation-proposals.js +88 -1
  72. package/dist/store/sqlite/schema.d.ts +16 -0
  73. package/dist/store/sqlite/schema.js +1 -0
  74. package/dist/store/sqlite/suggested-links.d.ts +10 -0
  75. package/dist/store/sqlite/suggested-links.js +68 -0
  76. package/dist/store/store.d.ts +3 -0
  77. package/dist/store/store.js +5 -0
  78. package/package.json +3 -3
  79. package/parity.json +4 -0
@@ -0,0 +1,68 @@
1
+ import { botNamed } from "./actors.js";
2
+ import { linkOf } from "./notes.js";
3
+ import { write } from "./transaction.js";
4
+ /** Set by store version 44 and deleted once the move ran. */
5
+ export const SUGGESTED_LINKS_TO_MOVE = "suggested_links_to_move";
6
+ /**
7
+ * An agent's `agent:<bot>` or a rule's `rule:<id>` suggestion. A rule becomes the seeded bot `rule`, since the text
8
+ * does not say which tool ran it; anything else (Drive's editor links) is a record, not a proposal, and stays.
9
+ */
10
+ const proposerOf = (provenance) => {
11
+ if (provenance?.startsWith("rule:"))
12
+ return { name: "rule", kind: "rule" };
13
+ if (!provenance?.startsWith("agent:"))
14
+ return undefined;
15
+ const name = provenance.slice("agent:".length).split(/[\s;]/, 1)[0] ?? "";
16
+ return { name: name && name.length <= 100 ? name : "agent", kind: "agent" };
17
+ };
18
+ /**
19
+ * Moves the unconfirmed agent and rule links into `proposed_actions` as `relationship` and `key_document`
20
+ * proposals, with their bot, reason and time, so `links` holds what the owner confirmed. The moved row keeps the
21
+ * link's provenance under `suggestedLink`, which marks its proposer unverified: only the owner decides it. A
22
+ * suggestion an older build writes later stays a link, and the proposal kinds still list it.
23
+ */
24
+ export const moveSuggestedLinks = (database, now) => {
25
+ if (!database.prepare("SELECT 1 AS found FROM store_settings WHERE key = ?").get(SUGGESTED_LINKS_TO_MOVE))
26
+ return 0;
27
+ return write(database, () => {
28
+ const rows = database
29
+ .prepare("SELECT * FROM links WHERE confirmed = 0 AND to_id IS NOT NULL AND kind IN ('member-of', 'related-to') ORDER BY id")
30
+ .all();
31
+ const at = now();
32
+ let moved = 0;
33
+ for (const row of rows) {
34
+ const link = linkOf(database, row);
35
+ const proposer = proposerOf(link.provenance);
36
+ const key = link.role === "key";
37
+ if (!proposer || !link.from || !link.to || (key && !link.to.startsWith("project:")))
38
+ continue;
39
+ const kind = key ? "key_document" : "relationship";
40
+ const held = database
41
+ .prepare("SELECT id FROM proposed_actions WHERE kind = ? AND status = 'proposed' AND target_type = ? AND target_id = ? " +
42
+ "AND json_extract(payload, ?) = ?")
43
+ .get(kind, row.from_type, row.from_id, key ? "$.project" : "$.to", link.to);
44
+ if (!held) {
45
+ const bot = botNamed(database, proposer.name, at, proposer.kind);
46
+ const suggestedLink = { id: link.id, provenance: link.provenance };
47
+ const payload = key
48
+ ? { ref: link.from, project: link.to, suggestedLink }
49
+ : {
50
+ from: link.from,
51
+ to: link.to,
52
+ kind: link.kind,
53
+ ...(link.role === null ? {} : { role: link.role }),
54
+ evidence: [],
55
+ suggestedLink,
56
+ };
57
+ database
58
+ .prepare("INSERT INTO proposed_actions (kind, target_type, target_id, payload, reason, status, proposed_by_type, " +
59
+ "proposed_by_id, created_at, updated_at) VALUES (?, ?, ?, ?, ?, 'proposed', ?, ?, ?, ?)")
60
+ .run(kind, row.from_type, row.from_id, JSON.stringify(payload), link.evidence, bot.type, bot.id, row.created_at, at);
61
+ }
62
+ database.prepare("DELETE FROM links WHERE id = ?").run(Number(row.id));
63
+ moved += 1;
64
+ }
65
+ database.prepare("DELETE FROM store_settings WHERE key = ?").run(SUGGESTED_LINKS_TO_MOVE);
66
+ return moved;
67
+ });
68
+ };
@@ -1,4 +1,5 @@
1
1
  import type { ContextEvidenceReader, ContextIndex, ContextRecordReader } from "../context/evidence.js";
2
+ import type { RefsStore } from "../domain/ref-summaries.js";
2
3
  import type { EventStore } from "../meetings/index.js";
3
4
  import { type AccountStore } from "./account-store.js";
4
5
  import { type AccountsStore } from "./accounts.js";
@@ -91,6 +92,8 @@ export interface MessageStore {
91
92
  readonly meetingFindings: MeetingFindingsStore;
92
93
  /** Cited facts and follow-ups about one project from stored messages, mail and documents, for review. */
93
94
  readonly evidenceFindings: EvidenceFindingsStore;
95
+ /** What any ref names, a page of them at a time: read once per page, never once per row. */
96
+ readonly refs: RefsStore;
94
97
  readonly facts: FactsStore;
95
98
  /** What agents concluded: summaries, digests, facts, preferences, each with evidence and a scope. */
96
99
  readonly memories: MemoriesStore;
@@ -37,6 +37,7 @@ import { notesStoreOver } from "./sqlite/notes.js";
37
37
  import { openStoreContext } from "./sqlite/open-store.js";
38
38
  import { projectAnnotationStoreOver } from "./sqlite/project-transfer/store.js";
39
39
  import { proposedActionsStoreOver } from "./sqlite/proposed-actions.js";
40
+ import { refSummariesOf } from "./sqlite/ref-summaries.js";
40
41
  import * as stems from "./sqlite/stems.js";
41
42
  import { taskStoreOver } from "./sqlite/tasks.js";
42
43
  import { syncStoreOver } from "./sync.js";
@@ -105,6 +106,9 @@ const storeOver = (context) => {
105
106
  const calendar = once(() => ({ ...eventStoreOver(context), ...eventSearchOver(context) }));
106
107
  const meetingFindings = once(() => meetingFindingsStoreOver(context));
107
108
  const evidenceFindings = once(() => evidenceFindingsStoreOver(context));
109
+ const refs = {
110
+ summaries: async (texts, options) => refSummariesOf(context.database, texts, options),
111
+ };
108
112
  const facts = once(() => factsStoreOver(context));
109
113
  const memories = once(() => memoriesStoreOver(context));
110
114
  const proposedActions = once(() => proposedActionsStoreOver(context));
@@ -199,6 +203,7 @@ const storeOver = (context) => {
199
203
  get meetingFindings() {
200
204
  return meetingFindings();
201
205
  },
206
+ refs,
202
207
  get evidenceFindings() {
203
208
  return evidenceFindings();
204
209
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-core",
3
- "version": "0.547.0",
3
+ "version": "0.549.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",
@@ -251,7 +251,7 @@
251
251
  "@types/node": "^22.20.5",
252
252
  "@types/pngjs": "6.0.5",
253
253
  "@vitest/coverage-v8": "^5.0.5",
254
- "@wirecat/cli-base": "0.73.0",
254
+ "@wirecat/cli-base": "0.74.0",
255
255
  "@wirecat/cli-core-legacy-tags": "npm:@wirecat/cli-core@0.414.0",
256
256
  "commander": "15.0.0",
257
257
  "cspell": "10.4.0",
@@ -271,7 +271,7 @@
271
271
  },
272
272
  "peerDependencies": {
273
273
  "@napi-rs/canvas": ">=0.1.69 <2",
274
- "@wirecat/cli-base": ">=0.73.0 <0.74.0",
274
+ "@wirecat/cli-base": ">=0.74.0 <0.75.0",
275
275
  "commander": ">=15"
276
276
  },
277
277
  "bin": {
package/parity.json CHANGED
@@ -242,6 +242,9 @@
242
242
  "value": "<post>",
243
243
  "meaning": "comment on this channel post; the comment goes to the post's discussion group"
244
244
  },
245
+ "--compact": {
246
+ "meaning": "one line per item, built from the same answer as --json, with its paging and next steps as # lines"
247
+ },
245
248
  "--component": {
246
249
  "value": "<name>",
247
250
  "meaning": "the ranking component whose contributing messages or answer pairs to read"
@@ -1131,6 +1134,7 @@
1131
1134
  },
1132
1135
  "globalOptions": {
1133
1136
  "--brief": "all",
1137
+ "--compact": "all",
1134
1138
  "--debug": "all",
1135
1139
  "--dry-run": "all",
1136
1140
  "--full": "all",