@dench.com/cli 3.3.0-staging.314 → 3.5.0-staging.327

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.
@@ -0,0 +1,261 @@
1
+ /**
2
+ * `dench crm detections …` — what the ingestion jobs created, and the one
3
+ * rollback for all of it (plan §4, §13 #38).
4
+ *
5
+ * Every counterparty that emails the workspace from a domain the CRM does
6
+ * not know gets ONE verdict (`crmAccountDetections`): Jev classifies the
7
+ * conversation against ORGANISATION.md and only potential / existing
8
+ * customers become an account + contacts. The LinkedIn resolver files its
9
+ * rows on the same table (`evidenceKind: linkedin`), and tasks from email
10
+ * leave a decision per candidate (`crmActivityTasks`). This surface is the
11
+ * audit trail ("why is Acme in my CRM?" / "why isn't it?") and the undo.
12
+ *
13
+ * list [--verdict created|skipped|pending|no_org_context|failed|rolled_back]
14
+ * [--kind detections|linkedin|all] [--since 30d|2026-09-01] [--limit N] [--json]
15
+ * undo --since <30d|2026-09-01|ms> [--kind detections|linkedin|email-tasks|all]
16
+ * [--dry-run] [--limit N] [--json] (admin)
17
+ *
18
+ * `undo` deletes what the detector (`detections`: email + the sweep), the
19
+ * LinkedIn resolver (`linkedin`) and tasks-from-email (`email-tasks`)
20
+ * created since `--since` that no human has touched (no user/agent write in
21
+ * the row's history, no comment), and marks the verdicts / decisions
22
+ * `rolled_back` so nothing is re-created. Rows a human edited stay, with
23
+ * their `created` verdict. `--kind` defaults to `all`. Bounded per call;
24
+ * the output says when to run it again.
25
+ */
26
+
27
+ import { makeFunctionReference } from "convex/server";
28
+ import {
29
+ assertNoUnknownFlags,
30
+ type CrmCliContext,
31
+ CrmCliError,
32
+ callMutation,
33
+ callQuery,
34
+ out,
35
+ } from "./crm";
36
+ import { readSince } from "./crm-comments";
37
+ import { getFlag, hasFlag } from "./lib/cli-args";
38
+
39
+ const api = {
40
+ list: makeFunctionReference<"query">("functions/crm/accountDetection:list"),
41
+ undo: makeFunctionReference<"mutation">(
42
+ "functions/crm/accountDetection:undo",
43
+ ),
44
+ };
45
+
46
+ export const DETECTION_VERDICTS = [
47
+ "pending",
48
+ "created",
49
+ "skipped",
50
+ "no_org_context",
51
+ "failed",
52
+ "rolled_back",
53
+ ] as const;
54
+
55
+ export const DETECTION_LIST_KINDS = ["detections", "linkedin", "all"] as const;
56
+ export const DETECTION_UNDO_KINDS = [
57
+ "detections",
58
+ "linkedin",
59
+ "email-tasks",
60
+ "all",
61
+ ] as const;
62
+ type UndoKind = (typeof DETECTION_UNDO_KINDS)[number];
63
+ type UndoRowKind = Exclude<UndoKind, "all">;
64
+ /** Convex object fields must be identifiers: `email-tasks` → `emailTasks`. */
65
+ type UndoKindCountsKey = "detections" | "linkedin" | "emailTasks";
66
+ function undoKindCountsKey(kind: UndoRowKind): UndoKindCountsKey {
67
+ return kind === "email-tasks" ? "emailTasks" : kind;
68
+ }
69
+
70
+ type DetectionRow = {
71
+ key: string;
72
+ personal: boolean;
73
+ verdict: (typeof DETECTION_VERDICTS)[number];
74
+ evidenceKind: string;
75
+ counterpartyType?: string;
76
+ confidence?: number;
77
+ wantsToUseProduct?: number;
78
+ buyingIntent?: number;
79
+ decidedAt: number;
80
+ createdCompanyEntryId?: string;
81
+ createdPersonEntryIds?: string[];
82
+ error?: string;
83
+ };
84
+
85
+ type UndoKindCounts = {
86
+ scanned: number;
87
+ deleted: number;
88
+ kept: number;
89
+ rolledBack: number;
90
+ remaining: boolean;
91
+ };
92
+
93
+ type UndoResult = {
94
+ dryRun: boolean;
95
+ kind: UndoKind;
96
+ scanned: number;
97
+ rolledBack: number;
98
+ deletedEntryIds: string[];
99
+ keptEntryIds: string[];
100
+ remaining: boolean;
101
+ kinds: Record<UndoKindCountsKey, UndoKindCounts>;
102
+ rows: Array<{
103
+ kind: UndoRowKind;
104
+ key: string;
105
+ verdict: string;
106
+ deleted: string[];
107
+ kept: string[];
108
+ }>;
109
+ };
110
+
111
+ function readLimit(args: string[], fallback: number, max: number): number {
112
+ const raw = getFlag(args, "--limit");
113
+ if (raw === undefined) return fallback;
114
+ const limit = Number.parseInt(raw, 10);
115
+ if (!Number.isFinite(limit) || limit < 1 || limit > max) {
116
+ throw new CrmCliError(`--limit must be an integer between 1 and ${max}`);
117
+ }
118
+ return limit;
119
+ }
120
+
121
+ function readKind<const T extends readonly string[]>(
122
+ args: string[],
123
+ allowed: T,
124
+ ): T[number] | undefined {
125
+ const raw = getFlag(args, "--kind");
126
+ if (raw === undefined) return undefined;
127
+ if (!allowed.includes(raw)) {
128
+ throw new CrmCliError(`--kind must be one of ${allowed.join(", ")}`);
129
+ }
130
+ return raw as T[number];
131
+ }
132
+
133
+ function pct(value: number | undefined): string {
134
+ return value === undefined ? "—" : `${Math.round(value * 100)}%`;
135
+ }
136
+
137
+ export function formatDetectionLine(row: DetectionRow): string {
138
+ const when = new Date(row.decidedAt).toISOString().slice(0, 16);
139
+ const type = row.counterpartyType ?? "—";
140
+ const createdParts = [
141
+ row.createdCompanyEntryId ? "account" : null,
142
+ row.createdPersonEntryIds?.length
143
+ ? `${row.createdPersonEntryIds.length} contact${
144
+ row.createdPersonEntryIds.length === 1 ? "" : "s"
145
+ }`
146
+ : null,
147
+ ].filter(Boolean);
148
+ const created =
149
+ row.verdict === "created"
150
+ ? ` → ${createdParts.length > 0 ? createdParts.join(" + ") : "matched existing"}`
151
+ : "";
152
+ const error = row.error ? ` (${row.error})` : "";
153
+ return `${when} ${row.verdict.padEnd(14)} ${row.evidenceKind.padEnd(9)}${
154
+ row.key
155
+ }${row.personal ? " (personal)" : ""} ${type} ${pct(
156
+ row.confidence,
157
+ )} wants ${pct(row.wantsToUseProduct)} intent ${
158
+ row.buyingIntent ?? "—"
159
+ }/10${created}${error}`;
160
+ }
161
+
162
+ const UNDO_KIND_LABEL: Record<UndoRowKind, string> = {
163
+ detections: "detections (email + sweep)",
164
+ linkedin: "linkedin",
165
+ "email-tasks": "email-tasks",
166
+ };
167
+
168
+ export function formatUndoLines(result: UndoResult): string[] {
169
+ const head = result.dryRun
170
+ ? `Dry run: ${result.deletedEntryIds.length} row(s) would be deleted, ${result.keptEntryIds.length} kept (human-touched), ${result.rolledBack} verdict(s) would be rolled back.`
171
+ : `Deleted ${result.deletedEntryIds.length} row(s), kept ${result.keptEntryIds.length} (human-touched), rolled back ${result.rolledBack} verdict(s).`;
172
+ const lines = [head];
173
+ for (const kind of Object.keys(UNDO_KIND_LABEL) as UndoRowKind[]) {
174
+ const counts = result.kinds?.[undoKindCountsKey(kind)];
175
+ if (!counts || (result.kind !== "all" && result.kind !== kind)) continue;
176
+ lines.push(
177
+ ` ${UNDO_KIND_LABEL[kind]}: scanned ${counts.scanned}, ${
178
+ result.dryRun ? "would delete" : "deleted"
179
+ } ${counts.deleted}, kept ${counts.kept}, rolled back ${
180
+ counts.rolledBack
181
+ }${counts.remaining ? ", more remain" : ""}`,
182
+ );
183
+ }
184
+ for (const row of result.rows) {
185
+ lines.push(
186
+ ` [${row.kind}] ${row.key}: ${row.verdict}${
187
+ row.deleted.length > 0 ? ` deleted ${row.deleted.join(", ")}` : ""
188
+ }${row.kept.length > 0 ? ` kept ${row.kept.join(", ")}` : ""}`,
189
+ );
190
+ }
191
+ if (result.remaining) {
192
+ lines.push("More rows match; run the same command again to continue.");
193
+ }
194
+ return lines;
195
+ }
196
+
197
+ export async function runDetectionsCommand(ctx: CrmCliContext): Promise<void> {
198
+ const verb = ctx.args.shift();
199
+ switch (verb) {
200
+ case "list": {
201
+ const verdict = getFlag(ctx.args, "--verdict");
202
+ if (
203
+ verdict !== undefined &&
204
+ !(DETECTION_VERDICTS as readonly string[]).includes(verdict)
205
+ ) {
206
+ throw new CrmCliError(
207
+ `--verdict must be one of ${DETECTION_VERDICTS.join(", ")}`,
208
+ );
209
+ }
210
+ const kind = readKind(ctx.args, DETECTION_LIST_KINDS);
211
+ const since = readSince(ctx.args);
212
+ const limit = readLimit(ctx.args, 50, 200);
213
+ assertNoUnknownFlags(ctx.args, "crm detections list");
214
+ const rows = (await callQuery(ctx, api.list, {
215
+ ...(verdict ? { verdict } : {}),
216
+ ...(kind ? { kind } : {}),
217
+ ...(since !== undefined ? { since } : {}),
218
+ limit,
219
+ })) as DetectionRow[];
220
+ if (ctx.jsonOutput) {
221
+ out(ctx, rows);
222
+ return;
223
+ }
224
+ out(
225
+ ctx,
226
+ rows.length === 0
227
+ ? "No detection verdicts match."
228
+ : rows.map(formatDetectionLine).join("\n"),
229
+ );
230
+ return;
231
+ }
232
+ case "undo": {
233
+ const since = readSince(ctx.args);
234
+ if (since === undefined) {
235
+ throw new CrmCliError(
236
+ "undo needs --since (30d, 12h, 2026-09-01 or a ms timestamp)",
237
+ );
238
+ }
239
+ const kind = readKind(ctx.args, DETECTION_UNDO_KINDS);
240
+ const dryRun = hasFlag(ctx.args, "--dry-run");
241
+ const limit = readLimit(ctx.args, 50, 50);
242
+ assertNoUnknownFlags(ctx.args, "crm detections undo");
243
+ const result = (await callMutation(ctx, api.undo, {
244
+ since,
245
+ ...(kind ? { kind } : {}),
246
+ ...(dryRun ? { dryRun: true } : {}),
247
+ limit,
248
+ })) as UndoResult;
249
+ if (ctx.jsonOutput) {
250
+ out(ctx, result);
251
+ return;
252
+ }
253
+ out(ctx, formatUndoLines(result).join("\n"));
254
+ return;
255
+ }
256
+ default:
257
+ throw new CrmCliError(
258
+ `Usage: dench crm detections list [--verdict V] [--kind detections|linkedin|all] [--since 30d] [--limit N] | undo --since <30d|date|ms> [--kind detections|linkedin|email-tasks|all] [--dry-run] [--limit N]`,
259
+ );
260
+ }
261
+ }
package/crm.ts CHANGED
@@ -18,7 +18,8 @@
18
18
  * crm objects list / get / create / update / delete / rename
19
19
  * crm views list / get / entries / create / update / delete
20
20
  * crm fields list / create / update / delete / reorder
21
- * crm entries list / get / create / create-many / update / update-many / delete / bulk-delete
21
+ * crm entries list / get / dossier / create / create-many / update / update-many / delete / bulk-delete
22
+ * crm detections list / undo (detection verdicts + LinkedIn rows; the one rollback for detections, linkedin, email-tasks)
22
23
  * crm cells get / set / set-many / append
23
24
  * crm query <object> --where … --select … --sort … --limit …
24
25
  * crm aggregate <object> --field …
@@ -31,10 +32,14 @@ import type { ConvexHttpClient } from "convex/browser";
31
32
  import { makeFunctionReference } from "convex/server";
32
33
  import { runAnalyticsCommand } from "./crm-analytics";
33
34
  import {
35
+ runActivityCommand,
36
+ runBriefCommand,
34
37
  runCommentsCommand,
38
+ runNotesCommand,
35
39
  runTasksCommand,
36
40
  runWatchCommand,
37
41
  } from "./crm-comments";
42
+ import { runDetectionsCommand } from "./crm-detections";
38
43
  import {
39
44
  assertNoUnknownFlags as assertNoUnknownFlagsRaw,
40
45
  CliArgError,
@@ -1071,6 +1076,12 @@ export async function runCrmCommand(opts: {
1071
1076
  return await runHistoryCommand(ctx);
1072
1077
  case "comments":
1073
1078
  return await runCommentsCommand(ctx);
1079
+ case "activity":
1080
+ return await runActivityCommand(ctx);
1081
+ case "brief":
1082
+ return await runBriefCommand(ctx);
1083
+ case "notes":
1084
+ return await runNotesCommand(ctx);
1074
1085
  case "watch":
1075
1086
  return await runWatchCommand(ctx);
1076
1087
  case "tasks":
@@ -1105,6 +1116,8 @@ export async function runCrmCommand(opts: {
1105
1116
  return await runReportsCommand(ctx);
1106
1117
  case "analytics":
1107
1118
  return await runAnalyticsCommand(ctx);
1119
+ case "detections":
1120
+ return await runDetectionsCommand(ctx);
1108
1121
  case "docs":
1109
1122
  case "documents":
1110
1123
  return await runDocsCommand(ctx);
@@ -1140,6 +1153,9 @@ const CRM_SUBCOMMANDS = [
1140
1153
  "entries",
1141
1154
  "history",
1142
1155
  "comments",
1156
+ "activity",
1157
+ "brief",
1158
+ "notes",
1143
1159
  "watch",
1144
1160
  "tasks",
1145
1161
  "cells",
@@ -1157,6 +1173,7 @@ const CRM_SUBCOMMANDS = [
1157
1173
  "enrich",
1158
1174
  "reports",
1159
1175
  "analytics",
1176
+ "detections",
1160
1177
  "docs",
1161
1178
  "documents",
1162
1179
  "actions",
@@ -2386,21 +2403,170 @@ async function runEntriesCommand(ctx: CrmCliContext): Promise<void> {
2386
2403
  });
2387
2404
  return;
2388
2405
  }
2389
- case "get": {
2406
+ case "sync-history": {
2407
+ // Queue the record's email addresses for a full, paged history pull
2408
+ // across the org's mailboxes; `--status` only reads the sync ledger.
2390
2409
  const objectName = shift(ctx.args, "object name");
2391
2410
  const entryId = shift(ctx.args, "entry id");
2392
- assertNoUnknownFlags(ctx.args, "crm entries get");
2411
+ const statusOnly = hasFlag(ctx.args, "--status");
2412
+ assertNoUnknownFlags(ctx.args, "crm entries sync-history");
2413
+ if (!statusOnly) {
2414
+ await callMutation(
2415
+ ctx,
2416
+ makeFunctionReference<"mutation">(
2417
+ "functions/emailIdentityHistory:requestForEntry",
2418
+ ),
2419
+ { objectName, entryId },
2420
+ );
2421
+ }
2422
+ const status = (await callQuery(
2423
+ ctx,
2424
+ makeFunctionReference<"query">(
2425
+ "functions/emailIdentityHistory:statusForEntry",
2426
+ ),
2427
+ { objectName, entryId },
2428
+ )) as {
2429
+ syncing: boolean;
2430
+ rows: Array<{
2431
+ emailKey: string;
2432
+ mailboxEmail: string;
2433
+ status: string;
2434
+ messagesFound: number;
2435
+ oldestSeenAt?: number;
2436
+ capped?: boolean;
2437
+ lastError?: string;
2438
+ }>;
2439
+ };
2440
+ if (ctx.jsonOutput) {
2441
+ out(ctx, status);
2442
+ return;
2443
+ }
2444
+ if (status.rows.length === 0) {
2445
+ out(
2446
+ ctx,
2447
+ "No email history sync for this record (no address, or no mailbox connected).",
2448
+ );
2449
+ return;
2450
+ }
2393
2451
  out(
2394
2452
  ctx,
2395
- withCrmEntryDeepLinks(
2453
+ status.rows
2454
+ .map((row) => {
2455
+ const through = row.oldestSeenAt
2456
+ ? ` through ${new Date(row.oldestSeenAt).toISOString().slice(0, 10)}`
2457
+ : "";
2458
+ const capped = row.capped ? " (capped)" : "";
2459
+ const error = row.lastError ? ` — ${row.lastError}` : "";
2460
+ return `${row.emailKey} ← ${row.mailboxEmail}: ${row.status}, ${row.messagesFound} messages${through}${capped}${error}`;
2461
+ })
2462
+ .join("\n"),
2463
+ );
2464
+ return;
2465
+ }
2466
+ case "dossier": {
2467
+ // The account's research dossier lives INSIDE the record's Notes
2468
+ // (the `dench:dossier` section); this verb reads its status and, with
2469
+ // --regenerate, queues a fresh section. Read the text itself with
2470
+ // `dench crm entries get company <id>` (Notes) or `dench crm activity`.
2471
+ const entryId = shift(ctx.args, "entry id");
2472
+ const regenerate = hasFlag(ctx.args, "--regenerate");
2473
+ assertNoUnknownFlags(ctx.args, "crm entries dossier");
2474
+ if (regenerate) {
2475
+ await callMutation(
2476
+ ctx,
2477
+ makeFunctionReference<"mutation">("functions/crm/dossier:regenerate"),
2478
+ { entryId },
2479
+ );
2480
+ }
2481
+ const status = (await callQuery(
2482
+ ctx,
2483
+ makeFunctionReference<"query">("functions/crm/dossier:getForEntry"),
2484
+ { entryId },
2485
+ )) as {
2486
+ status: string;
2487
+ reason: string;
2488
+ generatedAt?: number;
2489
+ updatesAppended: number;
2490
+ removedByHumanAt?: number;
2491
+ error?: string;
2492
+ } | null;
2493
+ if (ctx.jsonOutput) {
2494
+ out(ctx, status);
2495
+ return;
2496
+ }
2497
+ if (!status) {
2498
+ out(
2396
2499
  ctx,
2500
+ "No dossier has been requested for this record. Run with --regenerate to research it now (the record needs a Website or Domain).",
2501
+ );
2502
+ return;
2503
+ }
2504
+ const when = status.generatedAt
2505
+ ? ` · written ${new Date(status.generatedAt).toISOString().slice(0, 10)}`
2506
+ : "";
2507
+ const updates =
2508
+ status.updatesAppended > 0
2509
+ ? ` · ${status.updatesAppended} update${status.updatesAppended === 1 ? "" : "s"} since`
2510
+ : "";
2511
+ const removed = status.removedByHumanAt
2512
+ ? " · removed from Notes by a member (regenerate to bring it back)"
2513
+ : "";
2514
+ const error = status.error ? `\n${status.error}` : "";
2515
+ out(
2516
+ ctx,
2517
+ `Dossier: ${status.status} (${status.reason})${when}${updates}${removed}${error}\nThe dossier is the \`<!-- dench:dossier -->\` section of the record's Notes.`,
2518
+ );
2519
+ return;
2520
+ }
2521
+ case "get": {
2522
+ const objectName = shift(ctx.args, "object name");
2523
+ const entryId = shift(ctx.args, "entry id");
2524
+ // `--with-context` appends the record's ledger head (newest first) so
2525
+ // one call answers "what is going on here" — the agent's default read.
2526
+ const withContext = hasFlag(ctx.args, "--with-context");
2527
+ assertNoUnknownFlags(ctx.args, "crm entries get");
2528
+ const entry = withCrmEntryDeepLinks(
2529
+ ctx,
2530
+ objectName,
2531
+ await callQuery(ctx, api.entries.get, {
2397
2532
  objectName,
2398
- await callQuery(ctx, api.entries.get, {
2399
- objectName,
2400
- entryId: entryId as any,
2401
- }),
2402
- ),
2533
+ entryId: entryId as any,
2534
+ }),
2403
2535
  );
2536
+ if (!withContext) {
2537
+ out(ctx, entry);
2538
+ return;
2539
+ }
2540
+ const [activity, notes, brief] = await Promise.all([
2541
+ callQuery(
2542
+ ctx,
2543
+ makeFunctionReference<"query">("functions/crm/activity:listForEntry"),
2544
+ { objectName, entryId, order: "desc", limit: 12 },
2545
+ ),
2546
+ callQuery(
2547
+ ctx,
2548
+ makeFunctionReference<"query">(
2549
+ "functions/crm/activity:listNotesForEntry",
2550
+ ),
2551
+ { objectName, entryId, limit: 5 },
2552
+ ),
2553
+ callQuery(
2554
+ ctx,
2555
+ makeFunctionReference<"query">(
2556
+ "functions/crm/intelligence:getForEntry",
2557
+ ),
2558
+ { objectName, entryId },
2559
+ ),
2560
+ ]);
2561
+ out(ctx, {
2562
+ ...(entry as Record<string, unknown>),
2563
+ context: {
2564
+ brief,
2565
+ recentActivity: activity,
2566
+ notes,
2567
+ hint: "Full ledger: dench crm activity <object> <entryId> [--kind …] [--since 30d]; Brief: dench crm brief <object> <entryId>",
2568
+ },
2569
+ });
2404
2570
  return;
2405
2571
  }
2406
2572
  case "create": {
@@ -4563,18 +4729,62 @@ Fields (columns):
4563
4729
  Entries (rows):
4564
4730
  dench crm entries list <object> [--limit N] [--with-meta] [--json]
4565
4731
  [--assigned-to me|unassigned|<userId|email> | --mine] [--assignee-field <Field>]
4566
- dench crm entries get <object> <entryId>
4732
+ dench crm entries get <object> <entryId> [--with-context] (--with-context appends the newest activity + notes)
4733
+ dench crm entries sync-history <object> <entryId> [--status]
4734
+ Queue a full, paged pull of the record's email history from every
4735
+ connected mailbox (or read the sync ledger with --status). Opening the
4736
+ record does this too; use it for a record nobody has opened.
4737
+ dench crm entries dossier <entryId> [--regenerate] [--json]
4738
+ Status of the account's research dossier — the <!-- dench:dossier -->
4739
+ section Dench keeps at the top of a company's Notes. --regenerate
4740
+ researches again and appends a fresh section (Website/Domain required).
4741
+ Read it before your own research; add findings below it, never in it.
4567
4742
  dench crm history <object> <entryId> [--include-system] [--limit N] [--cursor CURSOR] [--json]
4568
4743
 
4744
+ Account detection (why a domain that emailed us did / did not become an account) and the ingestion undo:
4745
+ dench crm detections list [--verdict created|skipped|pending|no_org_context|failed|rolled_back] [--kind detections|linkedin|all] [--since 30d] [--limit N] [--json]
4746
+ dench crm detections undo --since <30d|2026-09-01|ms> [--kind detections|linkedin|email-tasks|all] [--dry-run] [--limit N] [--json] (admin)
4747
+ Deletes what the email detector / sweep (detections), the LinkedIn
4748
+ resolver (linkedin) and tasks-from-email (email-tasks) created that no
4749
+ human has touched, and marks the verdicts / decisions rolled_back
4750
+ (never re-created). --kind defaults to all.
4751
+
4752
+ Brief (what the record means right now — the FIRST thing to read):
4753
+ dench crm brief <object> <entryId> [--regenerate] [--json]
4754
+ Generated from the timeline; read-only. Health, who owes the next
4755
+ move, open threads, commitments, risks, next step, with provenance.
4756
+ Empty on a record nobody has opened yet — the call itself starts one;
4757
+ re-run in a minute. To correct it, write the fact in Notes or a
4758
+ comment and --regenerate; human words outrank inferred facts.
4759
+
4760
+ Activity (the record's ledger — read this before answering questions about a record):
4761
+ dench crm activity <object> <entryId> [--kind email,meetings,slack,linkedin,comments,notes,changes]
4762
+ [--since 30d|12h|2w|2026-09-01] [--limit N] [--order desc|asc] [--before MS | --after MS]
4763
+ [--include-system] [--no-notes] [--no-brief] [--json]
4764
+ Starts with the Brief, then newest first: notes, comments, emails,
4765
+ calendar events, meetings, Slack and LinkedIn touches, field changes —
4766
+ one timeline. Ends with the record's Notes document. Only rows you may
4767
+ read appear (a colleague's private inbox never does). Prefer this over
4768
+ live Gmail/Slack tools; reach for those only when the ledger lacks it.
4769
+
4770
+ Notes (titled, document-style entries on the Activity timeline):
4771
+ dench crm notes list <object> <entryId> [--limit N] [--json]
4772
+ dench crm notes get <noteId>
4773
+ dench crm notes create <object> <entryId> --title "Research — Sep 20" --body "markdown" [--body-file f.md] [--mention <userId>]...
4774
+ Research you were asked for goes here as a NEW note; never rewrite
4775
+ the record's Notes document unless asked to.
4776
+ dench crm notes update <noteId> --body "markdown" [--title "…"]
4777
+ dench crm notes delete <noteId>
4778
+
4569
4779
  Comments (the record's Activity feed):
4570
- dench crm comments list <object> <entryId> [--limit N] [--cursor CURSOR] [--replies N] [--json]
4780
+ dench crm comments list <object> <entryId> [--limit N] [--cursor CURSOR] [--replies N] [--kind comment|note] [--order asc|desc] [--json]
4571
4781
  dench crm comments replies <commentId> [--limit N] [--cursor CURSOR]
4572
4782
  dench crm comments get <commentId>
4573
- dench crm comments create <object> <entryId> --body "markdown" [--body-file f.md] [--reply-to <commentId>] [--mention <userId>]... [--dench]
4783
+ dench crm comments create <object> <entryId> --body "markdown" [--body-file f.md] [--reply-to <commentId>] [--mention <userId>]... [--dench] [--kind note --title "…"]
4574
4784
  Mention a member inline as [@Name](/?member=<userId>); --dench appends
4575
4785
  [@Dench](/?member=dench) so the agent replies in the thread. Returns
4576
4786
  { id, denchRunId? } immediately — poll 'comments list' for the reply.
4577
- dench crm comments update <commentId> --body "markdown"
4787
+ dench crm comments update <commentId> --body "markdown" [--title "…"]
4578
4788
  dench crm comments delete <commentId>
4579
4789
  dench crm comments react <commentId> <emoji> (toggles)
4580
4790
  dench crm watch <object> <entryId> [--off] (follow / unfollow activity)