@wirecat/wirecat 0.0.0-stage → 1.1.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 (230) hide show
  1. package/LICENSE +204 -0
  2. package/README.md +399 -2
  3. package/THIRD_PARTY_NOTICES +2 -0
  4. package/contracts/wirecat.json +4612 -0
  5. package/dist/actions/actions.js +269 -0
  6. package/dist/actions/command.js +102 -0
  7. package/dist/agents/command.js +17 -0
  8. package/dist/agents/log.js +23 -0
  9. package/dist/answer.js +100 -0
  10. package/dist/answers/command.js +128 -0
  11. package/dist/app.js +15 -0
  12. package/dist/author.js +109 -0
  13. package/dist/bin/wcat-wirecat.js +40 -0
  14. package/dist/bots/command.js +175 -0
  15. package/dist/bundle/auto-O24ISPOI.js +43 -0
  16. package/dist/bundle/chunk-2A3YPENI.js +31 -0
  17. package/dist/bundle/chunk-6BDIFKF5.js +222 -0
  18. package/dist/bundle/chunk-7O7XM37N.js +2 -0
  19. package/dist/bundle/chunk-AYHZY24E.js +120 -0
  20. package/dist/bundle/chunk-CKBTMZUX.js +72 -0
  21. package/dist/bundle/chunk-FGXUH3XL.js +416 -0
  22. package/dist/bundle/chunk-I5JQBRRC.js +807 -0
  23. package/dist/bundle/chunk-RKVAWMZT.js +38 -0
  24. package/dist/bundle/chunk-SCDNOUUR.js +395 -0
  25. package/dist/bundle/chunk-T7TG4JKR.js +312 -0
  26. package/dist/bundle/chunk-XBUCXQKT.js +51 -0
  27. package/dist/bundle/entry-EW5A7FYV.js +64 -0
  28. package/dist/bundle/failure-HMELJ3K5.js +19 -0
  29. package/dist/bundle/from-memo-F7NTUXAR.js +314 -0
  30. package/dist/bundle/program-7XWGFN4H.js +14994 -0
  31. package/dist/bundle/server-T7RVBNRW.js +303 -0
  32. package/dist/bundle/update-JZDS7B6L.js +22 -0
  33. package/dist/bundle/wcat-wirecat.js +83 -0
  34. package/dist/config-command.js +39 -0
  35. package/dist/config-issues.js +15 -0
  36. package/dist/config.js +187 -0
  37. package/dist/context/command.js +162 -0
  38. package/dist/context/context.js +197 -0
  39. package/dist/contract-overrides/commands.js +81 -0
  40. package/dist/contract-overrides/mcp.js +241 -0
  41. package/dist/contract-overrides/meetings.js +344 -0
  42. package/dist/contract-overrides/search.js +508 -0
  43. package/dist/contract-overrides/skill.js +85 -0
  44. package/dist/contract-overrides.js +7 -0
  45. package/dist/digest/backfill.js +175 -0
  46. package/dist/digest/brief.js +189 -0
  47. package/dist/digest/catch-up-record.js +30 -0
  48. package/dist/digest/catch-up.js +86 -0
  49. package/dist/digest/command.js +110 -0
  50. package/dist/digest/digest-commands.js +327 -0
  51. package/dist/digest/digest.js +560 -0
  52. package/dist/digest/digests.js +213 -0
  53. package/dist/digest/history.js +202 -0
  54. package/dist/digest/input.js +30 -0
  55. package/dist/digest/known.js +28 -0
  56. package/dist/digest/sources.js +155 -0
  57. package/dist/digest/sync-health.js +158 -0
  58. package/dist/digest/task-proposals.js +67 -0
  59. package/dist/digest/tasks.js +145 -0
  60. package/dist/digest/text.js +49 -0
  61. package/dist/discovery/command.js +107 -0
  62. package/dist/doctor/command.js +167 -0
  63. package/dist/documents/command.js +107 -0
  64. package/dist/domain-lists/command.js +13 -0
  65. package/dist/events/command.js +35 -0
  66. package/dist/events/events.js +196 -0
  67. package/dist/examples.js +609 -0
  68. package/dist/facts/command.js +100 -0
  69. package/dist/facts/fact.js +54 -0
  70. package/dist/facts/facts.js +15 -0
  71. package/dist/failure.js +58 -0
  72. package/dist/finance/command.js +121 -0
  73. package/dist/finance/contracts-command.js +109 -0
  74. package/dist/finance/deal-text.js +34 -0
  75. package/dist/finance/deals-command.js +346 -0
  76. package/dist/finance/finance.js +129 -0
  77. package/dist/finance/lines-command.js +70 -0
  78. package/dist/finance/orders-command.js +94 -0
  79. package/dist/finance/products-command.js +98 -0
  80. package/dist/finance/subscriptions-command.js +152 -0
  81. package/dist/finance/transactions-command.js +136 -0
  82. package/dist/finance/wallets-command.js +105 -0
  83. package/dist/finance/written.js +36 -0
  84. package/dist/findings/command.js +102 -0
  85. package/dist/findings-input.js +23 -0
  86. package/dist/identity.js +20 -0
  87. package/dist/install/postinstall.js +47 -0
  88. package/dist/json-fields.js +48 -0
  89. package/dist/knowledge/business-text.js +19 -0
  90. package/dist/knowledge/command.js +435 -0
  91. package/dist/knowledge/document-context.js +33 -0
  92. package/dist/knowledge/key-documents.js +120 -0
  93. package/dist/knowledge/list-queries.js +20 -0
  94. package/dist/knowledge/meeting-projects-command.js +61 -0
  95. package/dist/knowledge/messenger-sync.js +253 -0
  96. package/dist/knowledge/money-text.js +16 -0
  97. package/dist/knowledge/notes-about.js +81 -0
  98. package/dist/knowledge/organization-delete-command.js +44 -0
  99. package/dist/knowledge/organization-text.js +27 -0
  100. package/dist/knowledge/project-actions-command.js +130 -0
  101. package/dist/knowledge/project-actions.js +104 -0
  102. package/dist/knowledge/project-activity-command.js +70 -0
  103. package/dist/knowledge/project-context.js +101 -0
  104. package/dist/knowledge/project-findings.js +41 -0
  105. package/dist/knowledge/project-gather-command.js +100 -0
  106. package/dist/knowledge/project-status-command.js +129 -0
  107. package/dist/knowledge/project-transfer-command.js +58 -0
  108. package/dist/knowledge/project-transfer.js +107 -0
  109. package/dist/knowledge/relationships-scan.js +116 -0
  110. package/dist/knowledge/relationships.js +115 -0
  111. package/dist/knowledge/roles-command.js +67 -0
  112. package/dist/mail/command.js +20 -0
  113. package/dist/mail/findings-command.js +143 -0
  114. package/dist/mail/findings-duplicates.js +159 -0
  115. package/dist/mail/messages-command.js +77 -0
  116. package/dist/mail/review-command.js +59 -0
  117. package/dist/mail/subscriptions-command.js +84 -0
  118. package/dist/mcp/catalogue.js +159 -0
  119. package/dist/mcp/command.js +125 -0
  120. package/dist/mcp/granted.js +18 -0
  121. package/dist/mcp/permissions.js +61 -0
  122. package/dist/mcp/server.js +128 -0
  123. package/dist/meetings/command.js +31 -0
  124. package/dist/meetings/list-command.js +59 -0
  125. package/dist/meetings/preparation-command.js +42 -0
  126. package/dist/meetings/preparation-text.js +44 -0
  127. package/dist/meetings/preparation.js +50 -0
  128. package/dist/meetings/read.js +32 -0
  129. package/dist/memories/command.js +105 -0
  130. package/dist/memories/memories.js +17 -0
  131. package/dist/memories/memory.js +89 -0
  132. package/dist/memories/sources.js +111 -0
  133. package/dist/mentions/command.js +91 -0
  134. package/dist/migrate/check.js +48 -0
  135. package/dist/migrate/from-memo.js +345 -0
  136. package/dist/migrate/skill.js +35 -0
  137. package/dist/models/command.js +19 -0
  138. package/dist/options.js +35 -0
  139. package/dist/output.js +17 -0
  140. package/dist/page.js +14 -0
  141. package/dist/people/command.js +144 -0
  142. package/dist/people/delete-command.js +53 -0
  143. package/dist/people/doubts-command.js +81 -0
  144. package/dist/people/identities-command.js +188 -0
  145. package/dist/people/identity.js +42 -0
  146. package/dist/people/owner.js +14 -0
  147. package/dist/people/proposal-rows.js +70 -0
  148. package/dist/people/proposals-command.js +248 -0
  149. package/dist/people/review-context.js +108 -0
  150. package/dist/people/subject.js +19 -0
  151. package/dist/program.js +875 -0
  152. package/dist/read-only.js +51 -0
  153. package/dist/reasons.js +368 -0
  154. package/dist/records/import.js +135 -0
  155. package/dist/records/input.js +210 -0
  156. package/dist/records/mapping.js +80 -0
  157. package/dist/records/record-commands.js +125 -0
  158. package/dist/records/sources.js +73 -0
  159. package/dist/refs.js +28 -0
  160. package/dist/review/command.js +171 -0
  161. package/dist/review/kinds.js +44 -0
  162. package/dist/review/review.js +299 -0
  163. package/dist/review/status.js +93 -0
  164. package/dist/rows.js +219 -0
  165. package/dist/run/auto.js +237 -0
  166. package/dist/run/entry.js +62 -0
  167. package/dist/run/files.js +51 -0
  168. package/dist/run/import.js +253 -0
  169. package/dist/run/lock.js +20 -0
  170. package/dist/save-help.js +3 -0
  171. package/dist/schedule/command.js +58 -0
  172. package/dist/schedule/mail-triage-input.js +152 -0
  173. package/dist/schedule/task-triage-input.js +152 -0
  174. package/dist/search/answers.js +176 -0
  175. package/dist/search/command.js +257 -0
  176. package/dist/search/denied.js +9 -0
  177. package/dist/search/embed.js +126 -0
  178. package/dist/search/hits.js +4 -0
  179. package/dist/search/lane-gates.js +76 -0
  180. package/dist/search/notes-text.js +18 -0
  181. package/dist/search/people.js +88 -0
  182. package/dist/search/search.js +306 -0
  183. package/dist/show/command.js +179 -0
  184. package/dist/store/crm-viewer.js +102 -0
  185. package/dist/store/group.js +112 -0
  186. package/dist/store/groups-command.js +136 -0
  187. package/dist/store/guard.js +94 -0
  188. package/dist/store/held.js +21 -0
  189. package/dist/store/info-command.js +37 -0
  190. package/dist/store/scope.js +53 -0
  191. package/dist/store/source-list.js +222 -0
  192. package/dist/store/source-target.js +28 -0
  193. package/dist/tags/command.js +176 -0
  194. package/dist/tasks/command.js +174 -0
  195. package/dist/tasks/context.js +74 -0
  196. package/dist/tasks/list.js +199 -0
  197. package/dist/tasks/proposal-duplicates.js +70 -0
  198. package/dist/tasks/relations-command.js +28 -0
  199. package/dist/tasks/shared.js +105 -0
  200. package/dist/tasks/tasks.js +197 -0
  201. package/dist/templates/command.js +18 -0
  202. package/dist/terminal.js +23 -0
  203. package/dist/update.js +35 -0
  204. package/dist/version.js +2 -0
  205. package/dist/vocabulary/command.js +103 -0
  206. package/dist/vocabulary/inspect.js +23 -0
  207. package/dist/vocabulary/inspection.js +18 -0
  208. package/dist/vocabulary/list.js +18 -0
  209. package/dist/vocabulary/project.js +19 -0
  210. package/dist/wcat.js +3 -0
  211. package/install/postinstall.mjs +9 -0
  212. package/package.json +89 -4
  213. package/scenarios/decision-trail.md +21 -0
  214. package/scenarios/person-brief.md +35 -0
  215. package/scenarios/prepare-meeting.md +17 -0
  216. package/scenarios/project-state.md +26 -0
  217. package/scenarios/set-up.md +18 -0
  218. package/scenarios/start-the-day.md +19 -0
  219. package/skills/mail-triage/SKILL.md +208 -0
  220. package/skills/morning-digest/SKILL.md +147 -0
  221. package/skills/task-triage/SKILL.md +79 -0
  222. package/skills/wcat/SKILL.md +65 -0
  223. package/skills/wcat/topics/mail.md +32 -0
  224. package/skills/wcat/topics/mcp.md +22 -0
  225. package/skills/wcat/topics/meetings.md +37 -0
  226. package/skills/wcat/topics/money.md +52 -0
  227. package/skills/wcat/topics/projects.md +54 -0
  228. package/skills/wcat/topics/proposals.md +113 -0
  229. package/skills/wcat/topics/search.md +85 -0
  230. package/skills/wcat/topics/vocabulary.md +8 -0
@@ -0,0 +1,130 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { annotate } from "@wirecat/cli-base/commands";
3
+ import { answerEntity, environmentOf, LOCAL_READ, LOCAL_WRITE, parseEvidenceFindingsJson, proposesOnly, queryTerms, termField, withQuery, } from "@wirecat/cli-core";
4
+ import * as v from "valibot";
5
+ import { answers, itemAnswer, listAnswer } from "../answer.js";
6
+ import { byOption, deciderOf, whoRuns } from "../author.js";
7
+ import { FINDINGS_INPUT_HELP, readFindingsInput } from "../findings-input.js";
8
+ import { positive, whole } from "../options.js";
9
+ import { withoutTaskDuplicates } from "../tasks/proposal-duplicates.js";
10
+ import { projectOf } from "./key-documents.js";
11
+ import { decideAction, projectActions } from "./project-actions.js";
12
+ const ACTIONS_QUERY = {
13
+ entity: "project_action",
14
+ backend: "native",
15
+ fields: [termField("status", "enum", "status:proposed", { values: ["proposed", "reviewed"] })],
16
+ defaults: ["status:proposed"],
17
+ };
18
+ const json = (command) => command.option("--json", "print JSON; --json=id,status keeps only those fields");
19
+ export const projectActionsCommand = (projects, streams, env) => {
20
+ const group = projects
21
+ .command("actions")
22
+ .description("cited key documents and findings an agent proposed for a project, with the evidence to decide them")
23
+ .summary("an agent's proposals for a project, and deciding them");
24
+ const { run } = answers(projects, streams, env);
25
+ json(proposesOnly(annotate(group.command("add"), { effects: LOCAL_WRITE })))
26
+ .description("stage an agent's cited facts and follow-ups about one project for review")
27
+ .argument("<file>", FINDINGS_INPUT_HELP)
28
+ .addHelpText("after", "\nInput: schema_version 1, key, extractor, findings. Every finding names id, kind and evidence: 1–8 msg:, " +
29
+ "document: or note: references with the fingerprint projects evidence or notes show gives. A fact may name a " +
30
+ "project and a subject (person:, organization:, task: or project:), or neither; a task names its project. " +
31
+ "Facts name type and statement; tasks name type, title, reason and commitment (explicit or inferred). A due_at " +
32
+ "or assignee needs due_evidence or assignee_evidence citing this finding's references. A payment names payment " +
33
+ "{amount, currency, direction to_us|from_us, state paid|expected|cancelled, counterparty, paid_at}: an expected " +
34
+ "one becomes an invoice and needs a person: or organization: counterparty; a paid or cancelled one names in " +
35
+ "supersedes the invoice: it settles or voids. At most one project per " +
36
+ "batch. The same key and input returns the same batch; actions confirm and reject decide it by its id.\n")
37
+ .action(async (file, given, command) => {
38
+ const input = parseEvidenceFindingsJson(await readFindingsInput(file, environmentOf(projects).stdin ?? process.stdin));
39
+ const author = await whoRuns(command, env, { question: "" });
40
+ if (author === "owner")
41
+ throw new CliError("validation_error", "findings are an agent's proposals; record your own with wcat facts add");
42
+ await run(given.json, async (store) => {
43
+ const { input: kept, duplicates } = await withoutTaskDuplicates(store, env, input);
44
+ const noted = duplicates.length ? { duplicates } : {};
45
+ if (kept.findings.length === 0)
46
+ return itemAnswer({ staged: false, findings: 0, ...noted });
47
+ return itemAnswer({ ...(await store.evidenceFindings.stage(kept, author)), ...noted });
48
+ });
49
+ });
50
+ withQuery(json(answerEntity(annotate(group.command("list"), { effects: LOCAL_READ }), "project_action", v.union([
51
+ v.strictObject({
52
+ kind: v.literal("key_document"),
53
+ id: v.string(),
54
+ status: v.literal("proposed"),
55
+ reason: v.nullable(v.string()),
56
+ provenance: v.unknown(),
57
+ evidence: v.array(v.unknown()),
58
+ }),
59
+ v.strictObject({
60
+ kind: v.literal("findings"),
61
+ id: v.string(),
62
+ status: v.string(),
63
+ fingerprint: v.string(),
64
+ author: v.unknown(),
65
+ key: v.string(),
66
+ extractor: v.string(),
67
+ decided_by: v.unknown(),
68
+ decision: v.unknown(),
69
+ findings: v.array(v.unknown()),
70
+ }),
71
+ ]))).argument("<project>", "the project's id, project:<id>, key, exact name or alias"), ACTIONS_QUERY)
72
+ .summary("a project's proposals with the evidence to decide them")
73
+ .description("a project's proposed key documents and findings, newest first, with source state, cited text and nearby " +
74
+ "messages or document paragraphs; key-document text is untracked because no fingerprint was saved")
75
+ .option("--limit <n>", "findings batches per page, at most 50", positive, 10)
76
+ .option("--page <n>", "which page, from 1; key documents come on the first", positive, 1)
77
+ .option("--brief", "only references and source state, without excerpts or nearby text")
78
+ .option("--before-n <n>", "messages or document paragraphs before the citation, at most 5", whole, 2)
79
+ .option("--after-n <n>", "messages or document paragraphs after the citation, at most 5", whole, 2)
80
+ .action((reference, words, given) => run(given.json, async (store) => {
81
+ const status = queryTerms(words, ACTIONS_QUERY, "projects actions list").get("status");
82
+ const project = await projectOf(store, reference);
83
+ const found = await projectActions(store, project, {
84
+ status,
85
+ limit: given.limit,
86
+ page: given.page,
87
+ brief: given.brief === true,
88
+ before: Math.min(given.beforeN, 5),
89
+ after: Math.min(given.afterN, 5),
90
+ });
91
+ return listAnswer("projects actions list", {
92
+ items: found.items,
93
+ limit: given.limit,
94
+ page: given.page,
95
+ has_more: found.hasMore,
96
+ args: { project: reference, query: words.join(" ") },
97
+ });
98
+ }));
99
+ for (const name of ["confirm", "reject"]) {
100
+ const command = byOption(json(annotate(group.command(name), { effects: LOCAL_WRITE }))
101
+ .description(name === "confirm"
102
+ ? "confirm a suggested key document, or create the named findings of a batch and reject its other new " +
103
+ "ones; an agent decides for you only when agent_decisions is true, and with --reason"
104
+ : "reject a suggested key document, or every new finding of a batch")
105
+ .summary(name === "confirm" ? "confirm a proposal, yours or an agent's with --reason" : "reject a proposal")
106
+ .argument("<project>", "the project's id, project:<id>, key, exact name or alias")
107
+ .argument("<id>", "key:<id> for a key document, or a findings batch number, as projects actions list gives them"));
108
+ if (name === "confirm")
109
+ command.argument("[findings...]", "the finding IDs of a batch to create");
110
+ command
111
+ .option("--fingerprint <hash>", "a findings batch's fingerprint, as projects actions list gives it")
112
+ .option("--reason <text>", "why, in a few words; required when an agent decides for you")
113
+ .action(async (reference, id, ...rest) => {
114
+ const accept = name === "confirm" ? rest[0] : [];
115
+ const given = (name === "confirm" ? rest[1] : rest[0]);
116
+ const by = await deciderOf(command, env, { ...given, question: `${name} ${id} as you, the owner?` });
117
+ await run(given.json, async (store) => {
118
+ const project = await projectOf(store, reference);
119
+ return itemAnswer(await decideAction(store, env, project, id, {
120
+ confirm: name === "confirm",
121
+ ...(given.fingerprint === undefined ? {} : { fingerprint: given.fingerprint }),
122
+ ...(given.reason === undefined ? {} : { reason: given.reason }),
123
+ accept,
124
+ by,
125
+ }));
126
+ });
127
+ });
128
+ }
129
+ };
130
+ //# sourceMappingURL=project-actions-command.js.map
@@ -0,0 +1,104 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { contextEvidenceFingerprint, documentPassage, excerpt, paymentTitle, proposalRegistry, storedNeighbours, } from "@wirecat/cli-core";
3
+ import { decideBatch } from "../actions/actions.js";
4
+ import { decideOne, decisionOf } from "../review/review.js";
5
+ /** What a reviewer reads to decide one cited reference: the text now, whether it changed, and its neighbours. */
6
+ export const evidenceContext = async (store, ref, fingerprint, words, window) => {
7
+ const record = await store.contextRecords?.read(ref);
8
+ const state = record === null || record === undefined
9
+ ? "missing"
10
+ : fingerprint === null
11
+ ? "untracked"
12
+ : contextEvidenceFingerprint(record) === fingerprint
13
+ ? "unchanged"
14
+ : "changed";
15
+ if (window.brief || !record)
16
+ return { reference: ref, state };
17
+ const around = window.before + window.after === 0
18
+ ? []
19
+ : ref.startsWith("document:")
20
+ ? documentPassage(record.text, words, window).map((one) => ({ ref, ...one }))
21
+ : (await storedNeighbours(store)
22
+ .around(ref, window)
23
+ .catch(() => [])).map((one) => ({ ...one, text: excerpt(one.text, words, 200) }));
24
+ return {
25
+ reference: ref,
26
+ state,
27
+ title: record.title,
28
+ text: excerpt(record.text, words, 400),
29
+ around,
30
+ };
31
+ };
32
+ const findingWords = (finding) => finding.kind === "task"
33
+ ? `${finding.title} ${finding.reason}`
34
+ : finding.kind === "payment"
35
+ ? (finding.statement ?? paymentTitle(finding))
36
+ : finding.statement;
37
+ const findingsItem = async (store, batch, window) => ({
38
+ kind: "findings",
39
+ id: batch.id,
40
+ status: batch.status,
41
+ fingerprint: batch.fingerprint,
42
+ author: batch.author,
43
+ key: batch.input.key,
44
+ extractor: batch.input.extractor,
45
+ decided_by: batch.decidedBy,
46
+ decision: batch.receipt?.decision ?? null,
47
+ findings: await Promise.all(batch.input.findings.map(async (finding) => ({
48
+ ...finding,
49
+ earlier: batch.previous.find((one) => one.id === finding.id) ?? null,
50
+ outcome: batch.receipt?.items.find((one) => one.id === finding.id) ?? null,
51
+ evidence: await Promise.all(finding.evidence.map((one) => evidenceContext(store, one.reference, one.fingerprint, findingWords(finding), window))),
52
+ }))),
53
+ });
54
+ /**
55
+ * One project's proposals: the key documents an agent suggested and the findings batches it staged, each with the
56
+ * evidence it cites and, unless brief, the text around it, so a reviewer decides without opening every source.
57
+ */
58
+ export const projectActions = async (store, project, options) => {
59
+ const keys = options.page === 1 && options.status !== "reviewed"
60
+ ? await Promise.all((await proposalRegistry(store).list({
61
+ project: project.ref,
62
+ kinds: ["key_document"],
63
+ status: "proposed",
64
+ limit: 50,
65
+ offset: 0,
66
+ })).items.map(async (row) => ({
67
+ kind: "key_document",
68
+ id: row.id,
69
+ status: "proposed",
70
+ reason: row.reason,
71
+ provenance: row.proposedBy.type === "agent" ? `${row.proposedBy.kind}:${row.proposedBy.name}` : null,
72
+ evidence: [await evidenceContext(store, row.subject, null, row.reason ?? "", options)],
73
+ })))
74
+ : [];
75
+ const found = await store.evidenceFindings.list({
76
+ project: project.ref,
77
+ limit: options.limit,
78
+ offset: (options.page - 1) * options.limit,
79
+ ...(options.status === undefined ? {} : { status: options.status }),
80
+ });
81
+ return {
82
+ items: [...keys, ...(await Promise.all(found.items.map((batch) => findingsItem(store, batch, options))))],
83
+ hasMore: found.hasMore,
84
+ };
85
+ };
86
+ /** A suggested key document (`key:<id>` or its proposal number) or a findings batch, through the review registry. */
87
+ export const decideAction = async (store, env, project, id, decision) => {
88
+ if (!/^(key:)?[1-9]\d*$/.test(id))
89
+ throw new CliError("validation_error", "an action ID is a batch number or key:<id>");
90
+ const row = await proposalRegistry(store).get(id);
91
+ if (row.project !== project.ref || (row.kind !== "key_document" && row.kind !== "findings"))
92
+ throw new CliError("not_found", `no proposal ${id} in ${project.ref}; wcat projects actions list shows them`);
93
+ if (row.kind === "key_document") {
94
+ await decideOne(store, env, id, decisionOf(decision.confirm, decision.by, decision.reason));
95
+ return { id, kind: "key_document", ref: row.subject, confirmed: decision.confirm, decided_by: decision.by };
96
+ }
97
+ if (decision.fingerprint === undefined)
98
+ throw new CliError("validation_error", "a findings batch needs the --fingerprint shown in projects actions list", {
99
+ param: "fingerprint",
100
+ });
101
+ await decideBatch(store, id, { ...decision, fingerprint: decision.fingerprint });
102
+ return store.evidenceFindings.get(id);
103
+ };
104
+ //# sourceMappingURL=project-actions.js.map
@@ -0,0 +1,70 @@
1
+ import { annotate } from "@wirecat/cli-base/commands";
2
+ import { LOCAL_READ, projectActivity, projectWindowOf } from "@wirecat/cli-core";
3
+ import { Command } from "commander";
4
+ import { answers, listAnswer, withStore } from "../answer.js";
5
+ import { positive } from "../options.js";
6
+ import { groupScopeOf } from "../store/group.js";
7
+ const DAY = 86_400_000;
8
+ /** `all`, or days back (30d) or a start date as `projects status` takes them. */
9
+ const sinceOf = (value, now) => {
10
+ if (value.trim().toLowerCase() === "all")
11
+ return 0;
12
+ const window = projectWindowOf(value);
13
+ return "days" in window ? now - window.days * DAY : window.after;
14
+ };
15
+ const textOf = (one) => [
16
+ `${one.key ?? one.ref} ${one.name} · ${one.chats} chats${one.muted ? ` (${one.muted} muted, not counted)` : ""} · ` +
17
+ `${one.messages} messages (${one.sent} yours)${one.lastAt ? ` · last ${one.lastAt.slice(0, 10)}` : ""}` +
18
+ (one.partial ? " · some sub-projects not counted" : ""),
19
+ ...one.top.map((chat) => ` ${chat.messages} ${chat.title ?? chat.ref}`),
20
+ ].join("\n");
21
+ /** How busy each project's linked chats were: one light read for a dashboard, where `projects status` is per project. */
22
+ export const projectActivityCommand = (program, streams, env) => {
23
+ const { print } = answers(program, streams, env);
24
+ const stats = program.commands.find((command) => command.name() === "stats") ??
25
+ program.command("stats").description("statistics about what the store holds");
26
+ const projects = new Command("projects").description("project statistics");
27
+ stats.addCommand(projects);
28
+ annotate(projects.command("show"), { effects: LOCAL_READ })
29
+ .summary("each project's linked chats: messages in a period, last activity, busiest chats")
30
+ .description("for each of your projects, the chats linked to it or its child projects (every confirmed link, any purpose, " +
31
+ "no chat limit, unlike projects status): how many, how many are muted, messages and yours in the period by when they " +
32
+ "were sent, the newest message and the three busiest chats; a muted chat's messages are not counted. Busiest " +
33
+ "first. One read for all projects; projects status <project> says where one stands")
34
+ .option("--since-time <time>", "how far back: days (30d, at most 730d), a start date (2026-09-01) or all", "30d")
35
+ .option("--limit <n>", "most projects on a page, up to 200", positive, 20)
36
+ .option("--page <n>", "which page, from 1", positive, 1)
37
+ .option("--json", "print JSON; --json=id,title keeps only those fields")
38
+ .action(async (options) => {
39
+ const now = Date.now();
40
+ const since = sinceOf(options.sinceTime, now);
41
+ const limit = Math.min(options.limit, 200);
42
+ const found = await withStore(env, async (store) => {
43
+ const scope = await groupScopeOf(store, env);
44
+ return projectActivity(store, {
45
+ since,
46
+ until: now,
47
+ limit,
48
+ offset: (options.page - 1) * limit,
49
+ ...(scope === undefined ? {} : { accounts: scope.accounts }),
50
+ });
51
+ });
52
+ print(options.json, listAnswer("stats projects show", {
53
+ items: found.items,
54
+ limit,
55
+ page: options.page,
56
+ has_more: found.hasMore,
57
+ total: { value: found.total, relation: "eq" },
58
+ args: { since_time: options.sinceTime, limit },
59
+ }), [
60
+ since === 0 ? "all time" : `since ${new Date(since).toISOString().slice(0, 10)}`,
61
+ ...(found.items.length
62
+ ? found.items.map(textOf)
63
+ : [options.page > 1 ? "no projects on this page" : "no projects"]),
64
+ ...(found.hasMore
65
+ ? [`more: --since-time ${options.sinceTime} --limit ${limit} --page ${options.page + 1}`]
66
+ : []),
67
+ ].join("\n\n"));
68
+ });
69
+ };
70
+ //# sourceMappingURL=project-activity-command.js.map
@@ -0,0 +1,101 @@
1
+ import { byEngagement, paymentTitle, standingOf } from "@wirecat/cli-core";
2
+ import { itemAnswer, plainText } from "../answer.js";
3
+ import { factItem } from "../facts/fact.js";
4
+ import { labelsFor, proposerName, reviewItem } from "../review/review.js";
5
+ import { atLeast, kindsText, waitingAbout } from "../review/status.js";
6
+ import { groupScopeOf, keepInGroup } from "../store/group.js";
7
+ import { proposalsOf } from "../store/guard.js";
8
+ import { keyDocuments, projectOf } from "./key-documents.js";
9
+ import { notesAbout } from "./notes-about.js";
10
+ import { projectFindings } from "./project-findings.js";
11
+ export const projectContext = async (store, env, reference) => {
12
+ const project = await projectOf(store, reference);
13
+ const linked = byEngagement((await store.notes.links({ to: project.ref }))
14
+ .concat(await store.notes.links({ from: project.ref }))
15
+ .filter((link) => link.kind !== "about" && link.kind !== "links-to" && link.role !== "key")).map((link) => ({ ...link, standing: standingOf(link, Date.now()) }));
16
+ // A chat or meeting of an account outside the run's group stays out, with what it would bring in.
17
+ const relationships = await keepInGroup(store, env, linked, (link) => link.from === project.ref ? String(link.to) : link.from);
18
+ const documents = await keyDocuments(store, project);
19
+ const proposals = await proposalsOf(store, env);
20
+ const pending = (kind) => proposals.list({ project: project.ref, kinds: [kind], status: "proposed", limit: 50, offset: 0 });
21
+ const [facts, tasks, findings, keys, links, waiting] = await Promise.all([
22
+ store.facts.list({ project: project.ref, status: "proposed", limit: 20 }),
23
+ store.tasks.find({ project: project.ref, status: "open", limit: 20 }),
24
+ projectFindings(store, project.ref, relationships),
25
+ pending("key_document"),
26
+ pending("relationship"),
27
+ waitingAbout(store, env, [project.ref]),
28
+ ]);
29
+ const label = await labelsFor(store, [...keys.items, ...links.items].flatMap((row) => [row.subject, row.object]));
30
+ return {
31
+ keyDocuments: documents,
32
+ project,
33
+ relationships,
34
+ notes: await notesAbout(store, { ref: project.ref }, 20, (await groupScopeOf(store, env))?.accounts),
35
+ tags: await store.knowledge.tags(null, { type: "project", id: project.id }),
36
+ review: {
37
+ waiting: {
38
+ ...waiting,
39
+ next: { command: "review list", args: { query: `project:${project.key ?? project.id}` } },
40
+ },
41
+ keyDocuments: keys.items.map((row) => ({
42
+ id: row.id,
43
+ ref: row.subject,
44
+ title: label(row.subject),
45
+ reason: row.reason,
46
+ confirmed: false,
47
+ proposer: proposerName(row.proposedBy),
48
+ })),
49
+ relationships: links.items.map((row) => ({
50
+ id: row.id,
51
+ from: row.subject,
52
+ to: row.object,
53
+ title: reviewItem(row, label).title,
54
+ role: row.summary,
55
+ reason: row.reason,
56
+ confirmed: false,
57
+ proposer: proposerName(row.proposedBy),
58
+ })),
59
+ facts: {
60
+ items: facts.items.map(factItem),
61
+ hasMore: facts.hasMore,
62
+ next: facts.hasMore
63
+ ? { command: "facts list", args: { query: `project:"${project.ref}" status:proposed`, limit: 100 } }
64
+ : null,
65
+ },
66
+ meetingActions: findings,
67
+ },
68
+ openTasks: {
69
+ items: tasks.items,
70
+ hasMore: tasks.hasMore,
71
+ next: tasks.hasMore ? { command: "tasks list", args: { query: `project:"${project.ref}"`, limit: 100 } } : null,
72
+ },
73
+ };
74
+ };
75
+ export const projectContextText = (context) => {
76
+ const line = (text) => text.replace(/\s+/g, " ").slice(0, 240);
77
+ const { review } = context;
78
+ return [
79
+ plainText(itemAnswer(context)),
80
+ `Pending review: ${atLeast(review.waiting.count, review.waiting.complete)} proposal${review.waiting.count === 1 ? "" : "s"} waiting${review.waiting.count ? ` (${kindsText(review.waiting.kinds)})` : ""} — wcat review list project:${context.project.key ?? context.project.id} (nothing confirmed):`,
81
+ ...review.keyDocuments.map((document) => ` key document ${document.ref}: ${line(document.reason ?? "")}`),
82
+ ...review.relationships.map((link) => ` relationship ${link.id}: ${link.title}`),
83
+ ...review.facts.items.map((fact) => ` ${fact.ref} [${fact.kind}]: ${line(fact.text)}`),
84
+ ...review.meetingActions.items.flatMap((batch) => batch.findings.map((finding) => ` batch ${batch.id}/${finding.id} [${finding.kind}]: ${line(finding.kind === "task"
85
+ ? finding.title
86
+ : finding.kind === "payment"
87
+ ? (finding.statement ?? paymentTitle(finding))
88
+ : finding.statement)}`)),
89
+ "Open numbered tasks:",
90
+ ...context.openTasks.items.map((task) => ` open task ${task.key}: ${line(task.title)}`),
91
+ ...(review.facts.hasMore ||
92
+ context.openTasks.hasMore ||
93
+ review.meetingActions.coverage.accounts.some((account) => account.has_more) ||
94
+ review.meetingActions.coverage.omitted_accounts.length ||
95
+ review.meetingActions.coverage.missing_account_ids.length
96
+ ? ["More or missing records: --json shows coverage and continuation commands."]
97
+ : []),
98
+ "Meeting proposals cover linked meeting accounts only; read a full batch before owner review.",
99
+ ].join("\n");
100
+ };
101
+ //# sourceMappingURL=project-context.js.map
@@ -0,0 +1,41 @@
1
+ import { parseMeetingReference } from "@wirecat/cli-core";
2
+ export const projectFindings = async (store, project, links) => {
3
+ const ids = new Set();
4
+ for (const link of links) {
5
+ const ref = link.from.startsWith("meeting:") ? link.from : link.to;
6
+ if (ref?.startsWith("meeting:"))
7
+ ids.add(parseMeetingReference(ref).accountId);
8
+ }
9
+ const accounts = (await store.accounts.storedAccounts()).filter((account) => ids.has(account.id));
10
+ const pages = await Promise.all(accounts.slice(0, 8).map(async ({ provider, account }) => {
11
+ const key = { provider, account };
12
+ const page = await store.meetingFindings.list(key, { status: "proposed", limit: 5 });
13
+ return {
14
+ source: `${provider}:${account}`,
15
+ has_more: page.hasMore,
16
+ next: page.hasMore
17
+ ? {
18
+ command: "meetings actions list",
19
+ args: { source: `${provider}:${account}`, query: "status:proposed", limit: 5, page: 2 },
20
+ }
21
+ : null,
22
+ items: page.items.flatMap((batch) => {
23
+ const decided = new Set(batch.previous.map((item) => item.id));
24
+ const findings = batch.input.findings.filter((finding) => finding.project === project && !decided.has(finding.id));
25
+ return findings.length ? [{ id: batch.id, account: key, fingerprint: batch.fingerprint, findings }] : [];
26
+ }),
27
+ };
28
+ }));
29
+ return {
30
+ items: pages.flatMap((page) => page.items),
31
+ coverage: {
32
+ scope: "linked_meeting_accounts",
33
+ limit_per_account: 5,
34
+ accounts: pages.map(({ items: _items, ...page }) => page),
35
+ omitted_accounts: accounts.slice(8).map(({ provider, account }) => `${provider}:${account}`),
36
+ missing_account_ids: [...ids].filter((id) => !accounts.some((account) => account.id === id)),
37
+ },
38
+ review_instruction: "Read each full batch with meetings actions show before owner review; other projects may share it.",
39
+ };
40
+ };
41
+ //# sourceMappingURL=project-findings.js.map
@@ -0,0 +1,100 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { annotate, annotateOption } from "@wirecat/cli-base/commands";
3
+ import { MAX_NEXT_STEPS } from "@wirecat/cli-base/standards";
4
+ import { FETCH, gatherStoredProject, parseDuration, projectAnswerParts, projectCutoffTime, projectEvidenceText, projectWindowOf, purposeList, } from "@wirecat/cli-core";
5
+ import { Option } from "commander";
6
+ import { itemAnswer, withStore } from "../answer.js";
7
+ import { collect, positive, whole } from "../options.js";
8
+ import { ACCOUNTS_HELP, contextSourcesOf } from "../store/source-list.js";
9
+ import { projectOf } from "./key-documents.js";
10
+ import { chatSync, messengerFetcher, syncHint, syncProfileOf } from "./messenger-sync.js";
11
+ import { scanStep } from "./relationships-scan.js";
12
+ export const PURPOSES_HELP = "the linked chats' purposes to read, comma-separated: work, sales, support, other, or all; default work";
13
+ /** `--purposes`, and the hidden `--purpose` it replaced, kept for one version as in cli-core. */
14
+ export const oldPurposeOption = () => new Option("--purpose <purposes>", "replaced by --purposes; kept for one version").argParser(purposeList).hideHelp();
15
+ export const purposesAsked = ({ purposes = [], purpose = [] }) => {
16
+ const asked = [...purposes, ...purpose];
17
+ return asked.length === 0 ? {} : { purposes: asked };
18
+ };
19
+ /** Off MCP: a tool call ends at about a minute, too soon for a sync, which would fail the whole answer. */
20
+ const cliOnly = (option) => annotateOption(option, { mcp: false });
21
+ export const projectGatherCommand = (projects, print, env, warn) =>
22
+ // Declared as a fetch for --sync-first; cli-base fixes effects per command, and without it nothing leaves this machine.
23
+ annotate(projects.command("evidence"), { effects: FETCH, partial: true })
24
+ .description("cited references about a project in stored messages, mail, meeting transcripts and imported notes folders. The project's name, " +
25
+ "its key, each of its aliases and each --alias, each --context-query and each --contact name is its own search: every word of " +
26
+ "it must appear in one text, in any order, as whole words; their hits are joined. Every message of a chat confirmed as the " +
27
+ "project's (wcat relationships add chat:<provider>/<account>/<chat> project:<id>) is read too, when --source holds its " +
28
+ "account, and so is everything a confirmed person member of the project wrote (as --contact person:<id>, " +
29
+ "without aliases). New mail and documents are indexed for search first, unless --no-catch-up. Reads " +
30
+ "what the store holds; with --sync-first it first syncs the linked chats the store lacks for the window by running " +
31
+ "their messenger CLI (tg, max, wa) with the profile signed in to each chat's account, or the one --sync-profile " +
32
+ "names when several are; proposes and confirms nothing. A partial answer exits 0 with meta.complete false")
33
+ .summary("find what the store holds about a project: names, words, people, linked chats")
34
+ .argument("<project>", "an existing project's id, key, exact name or alias, or a new project's name")
35
+ .requiredOption("--source <accounts>", `where to look, or all: ${ACCOUNTS_HELP}`)
36
+ .option("--alias <name>", "another name of the project, searched on its own; repeat for more", collect, [])
37
+ .option("--context-query <words>", "more words that all appear in one text; repeat for another search", collect, [])
38
+ .option("--contact <person>", "a name to search, or person:<id> to read what that person's stored identities wrote and search the aliases " +
39
+ "you gave them; what only names them or comes from them is context, not the project", collect, [])
40
+ .option("--since-time <time>", "how far back: days (90d, at most 730d) or a start date (2026-09-01)", "60d")
41
+ .option("--before-time <time>", "fixed exclusive end: ISO 8601 timestamp with UTC offset; days back count from it")
42
+ .option("--limit <n>", "new references at most, up to 500", positive, 100)
43
+ .option("--max-pages <pages>", "store pages read at most this run, up to 512", positive)
44
+ .option("--cursor <cursor>", "continue a stopped search from its checkpoint, with the same options")
45
+ .option("--before-n <n>", "messages before each message hit, shown as its context, at most 5", whole, 2)
46
+ .option("--after-n <n>", "messages after each message hit, shown as its context, at most 5", whole, 2)
47
+ .option("--no-catch-up", "read the search index as it is, without indexing new mail and documents first")
48
+ .addOption(cliOnly(new Option("--sync-first", "first sync the linked chats the store does not hold back to --since-time, through their messenger CLI; " +
49
+ "off by default")))
50
+ .addOption(cliOnly(new Option("--sync-time <duration>", "time for all of --sync-first's syncs together").default("3m")))
51
+ .addOption(cliOnly(new Option("--sync-profile <tool=profile>", "the messenger profile to sync as when several are signed in to a chat's account, such as max=default; " +
52
+ "repeat for another tool. It must be signed in to that account").argParser(syncProfileOf)))
53
+ .option("--purposes <purposes>", PURPOSES_HELP, purposeList)
54
+ .addOption(oldPurposeOption())
55
+ .option("--include-proposed", "also read chats and members proposed for the project, after the confirmed ones")
56
+ .option("--json", "print JSON; --json=id,title keeps only those fields")
57
+ .action(async (project, options) => {
58
+ const maxFetchMs = parseDuration(options.syncTime, "--sync-time");
59
+ const chosen = options.syncProfile ?? {};
60
+ const { found, scan } = await withStore(env, async (store) => {
61
+ const found = await gatherStoredProject(store, {
62
+ project,
63
+ sources: await contextSourcesOf(store, env, options.source),
64
+ ...projectWindowOf(options.sinceTime),
65
+ ...(options.beforeTime === undefined ? {} : { asOf: projectCutoffTime(options.beforeTime) }),
66
+ limit: options.limit,
67
+ catchUp: options.catchUp,
68
+ beforeN: options.beforeN,
69
+ afterN: options.afterN,
70
+ ...(options.alias ? { aliases: options.alias } : {}),
71
+ ...(options.contextQuery ? { keywords: options.contextQuery } : {}),
72
+ ...(options.contact ? { people: options.contact } : {}),
73
+ ...(options.maxPages === undefined ? {} : { maxReads: options.maxPages }),
74
+ ...(options.cursor === undefined ? {} : { checkpoint: options.cursor }),
75
+ ...purposesAsked(options),
76
+ ...(options.includeProposed ? { includeProposed: true } : {}),
77
+ ...(options.syncFirst ? { fetcher: messengerFetcher({ env, note: warn, chosen }), maxFetchMs } : {}),
78
+ });
79
+ const known = await projectOf(store, project).catch((error) => {
80
+ if (error instanceof CliError && error.code === "not_found")
81
+ return undefined;
82
+ throw error;
83
+ });
84
+ return { found, scan: known ? await scanStep(store, known, options.source) : [] };
85
+ });
86
+ const since = new Date(found.window.after).toISOString().slice(0, 10);
87
+ const syncs = found.linkedChats.map((one) => one.completeness === null || one.completeness.state === "complete" ? null : chatSync(one, since, env, chosen));
88
+ const parts = projectAnswerParts(options.sinceTime, found);
89
+ const blocked = [...new Set(syncs.flatMap((one) => (one && one.command === null ? [one.why] : [])))];
90
+ const missing = [...(parts.missing ?? []), ...blocked.map((why) => ({ field: "sync_command", why }))];
91
+ const next = [...(parts.next ?? []), ...scan].slice(0, MAX_NEXT_STEPS);
92
+ print(options.json, itemAnswer({
93
+ ...found,
94
+ linkedChats: found.linkedChats.map((one, i) => ({ ...one, syncCommand: syncs[i]?.command ?? null })),
95
+ }, { ...parts, ...(missing.length ? { missing } : {}), ...(next.length ? { next } : {}) }), projectEvidenceText(found, {
96
+ sync: (chat, at) => syncHint(chat, at, env, chosen),
97
+ showDocument: "wcat notes show",
98
+ }));
99
+ });
100
+ //# sourceMappingURL=project-gather-command.js.map