@dench.com/cli 3.1.0-staging.292 → 3.2.1-staging.295

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -201,39 +201,68 @@ dench signin --staging
201
201
  dench signin --host https://staging.dench.com
202
202
  ```
203
203
 
204
- ## Prospect review lists
204
+ ## Saved prospect lists
205
205
 
206
206
  People found with `dench leads find` stay in saved lists, not the CRM.
207
- Open the list in Find for a teammate to mark profiles **ICP approved**,
208
- **Rejected**, or **Needs research**; missing decisions are **Unreviewed**.
209
- ICP means ideal customer profile, not sales qualification.
207
+ The lead-finding skill establishes `/workspace/ICP.md` on first use and
208
+ reads it before later searches. There is no mandatory per-profile ICP decision.
209
+ In Find, click **Find** in a Work email, Phone, or Personal email cell to
210
+ request that field. The control discloses credit use; the lookup starts directly.
211
+ Different people run concurrently; wait for a person's current lookup before
212
+ starting another field. The cell shimmers with **Enriching**, then shows the
213
+ returned value or **Not found**. Header play targets selected profiles, or the
214
+ whole saved list when none are selected, with credit confirmation inline.
215
+ Bulk progress floats temporarily and disappears when finished, including misses.
216
+ Contact results persist in the list; other columns remain under View settings.
210
217
 
211
218
  ```bash
212
219
  dench leads find --titles "VP Sales" --save-as "Q3 targets" --json
213
- dench lists reviews <artifactId> --limit 100 --json
214
- dench lists reviews <artifactId> --limit 100 --cursor <continueCursor> --json
215
- dench lists assess <artifactId> --row-json '<exact returned profile row>' --fit likely_fit --reason 'Matches the requested role; company size is still unknown.' --json
220
+ dench lists save --title "10 RevOps leaders" --people-file /tmp/shortlist.json --json
221
+ dench lists --search "Q3 targets" --limit 25 --json
222
+ dench lists rows <artifactId> --enrichment enriched --limit 100 --json
223
+ dench lists rows <artifactId> --enrichment enriched --limit 100 --cursor <continueCursor> --json
216
224
  ```
217
225
 
218
- `reviews` returns `page`, `continueCursor`, and `isDone`; its limit is 1–100
219
- (default 50). `assess` records only an AI suggestion, never human approval.
220
- Its `--fit` accepts `likely_fit`, `unlikely_fit`, or `unknown`. Reuse the
221
- returned profile identity rather than inventing a row. Material profile
222
- changes require human review again; formatting and added contacts do not.
226
+ `lists save` takes a non-empty JSON array of person rows (`name` or
227
+ `fullName` required), consolidating selected discoveries into a new list
228
+ without searching, enriching, or importing CRM rows. It leaves source lists
229
+ unchanged. Optional `--filters-json` stores criteria/source evidence metadata.
230
+ In chat, explicitly present the final list; research batches stay in activity
231
+ details instead of becoming competing result sets.
223
232
 
224
- Approval starts nothing by itself. In Find, a teammate separately chooses
225
- **Enrich selected**, selects contact fields, and confirms the credit spend.
226
- Results stay with the list and appear in `reviews` and **Export review CSV**.
227
- Do not resubmit pending or uncertain lookups through another tool.
233
+ Before presenting a shortlist, the skill saves an ICP relevance score (0–100)
234
+ and short reason for each profile using the confirmed brief. These appear as
235
+ **ICP fit** and **Why this lead** in Find and in CSV exports. Scores are not
236
+ conversion probabilities or CRM statuses. To save assessments for canonical
237
+ rows returned by `lists rows`, create a JSON array of
238
+ `{row, suggestion: {fit, score, reason}}` (1–100 items per file):
228
239
 
229
- Only when the human explicitly asks to import approved profiles:
240
+ ```bash
241
+ dench lists assess <artifactId> --assessments-file /tmp/icp-assessments.json --json
242
+ ```
243
+
244
+ `fit` is `likely_fit`, `unlikely_fit`, or `unknown`; `score` is a whole number
245
+ from 0 to 100. The CLI validates the file before writes and reports partial
246
+ failures; retrying updates existing assessments. Re-read rows to verify every
247
+ saved score and reason. Older unscored profiles remain **Not scored** until assessed.
248
+
249
+ Directory and row reads return `page`, `continueCursor`, and `isDone`.
250
+ Follow cursors even through empty filtered pages. Lists survive new chats;
251
+ read fresh rows and contacts instead of an old transcript or CSV. Each row
252
+ has its original zero-based `index`. Enriched means a contact was returned,
253
+ not merely that a lookup completed. Never resubmit pending/uncertain jobs.
254
+
255
+ Only when the user explicitly asks to import the selected profiles:
230
256
 
231
257
  ```bash
232
- dench artifacts import <artifactId> --to lead --view "Q3 outbound" --pin
258
+ dench artifacts import <artifactId> --to lead --rows 0,4,9 --status "Contacted" --view "Q3 outbound" --pin
233
259
  ```
234
260
 
235
- This imports currently approved profiles and known contacts, reusing existing
236
- CRM records. It does not buy contacts, mark Leads `Qualified`, or start outreach.
261
+ This imports exactly those original indices and known contacts, reusing existing
262
+ CRM records. Inspect the actual Lead status options first. Omit `--status`
263
+ to keep the default New; use `--enrichment enriched` for contact-bearing rows.
264
+ Enrichment is optional for explicit imports. Import sets status only, even
265
+ Qualified: it never purchases contacts, sends outreach, or converts records.
237
266
  See the [lead-finding workflow](../convex/lib/seedSkills/lead-finding.md)
238
267
  and [sales pipeline playbook](../public/references/SALES.md).
239
268
 
package/app-sdk.d.ts CHANGED
@@ -79,10 +79,31 @@ export interface ApiRequests {
79
79
  limit?: number;
80
80
  };
81
81
  /** List saved searches (find-result lists) in the workspace, newest first. — `dench lists` — GET /api/v1/lists */
82
- "lists.list": Record<string, unknown>;
82
+ "lists.list": {
83
+ search?: string;
84
+ cursor?: string;
85
+ limit?: number;
86
+ };
87
+ /** Read saved rows with current enrichment results and original indices; cursor-paged, without repeating a search. — `dench lists rows` — GET /api/v1/lists/{artifactId}/rows */
88
+ "lists.rows": {
89
+ artifactId: string;
90
+ cursor?: string;
91
+ limit?: number;
92
+ enrichment?: "all" | "enriched" | "in_progress" | "no_contacts" | "failed" | "not_enriched";
93
+ };
94
+ /** Explicitly import selected saved profiles, optionally filtered by enrichment, with a configured Lead status. Reuses CRM records; never sends outreach or triggers conversion. — `dench artifacts import` — POST /api/v1/lists/{artifactId}/import */
95
+ "lists.import": {
96
+ artifactId: string;
97
+ to: "lead" | "company" | "job_posting";
98
+ rowIndexes?: number[];
99
+ status?: string;
100
+ enrichment?: "all" | "enriched" | "in_progress" | "no_contacts" | "failed" | "not_enriched";
101
+ viewName?: string;
102
+ pin?: boolean;
103
+ };
83
104
  /** Get one saved search / list by artifact id. — `dench lists show` — GET /api/v1/lists/{artifactId} */
84
105
  "lists.get": Record<string, unknown>;
85
- /** Save find results as a named list (rows + filters become a workspace artifact). — `dench leads find --save-as "Name"` — POST /api/v1/lists */
106
+ /** Save find results as a named list (rows + filters become a workspace artifact). — `dench lists save` — POST /api/v1/lists */
86
107
  "lists.save": Record<string, unknown>;
87
108
  /** Update a saved list in place (title, filters, and/or replacement rows). — `dench lists update` — PATCH /api/v1/lists/{artifactId} */
88
109
  "lists.update": Record<string, unknown>;
@@ -90,7 +111,7 @@ export interface ApiRequests {
90
111
  "lists.rename": Record<string, unknown>;
91
112
  /** Delete a saved search / list, its exported CSV/JSONL files, and any linked watch. — `dench lists delete` — DELETE /api/v1/lists/{artifactId} */
92
113
  "lists.delete": Record<string, unknown>;
93
- /** Read saved prospect review decisions and enrichment outcomes. Human approval is separate from AI suggestions. — `dench lists reviews` — GET /api/v1/lists/{artifactId}/reviews */
114
+ /** Read durable enrichment activity (legacy review metadata remains readable). Use lists rows for current saved profiles and contacts. — `dench lists reviews` — GET /api/v1/lists/{artifactId}/reviews */
94
115
  "lists.prospects.reviews": {
95
116
  artifactId: string;
96
117
  limit?: number;
@@ -102,6 +123,8 @@ export interface ApiRequests {
102
123
  row: Record<string, unknown>;
103
124
  suggestion: {
104
125
  fit: "likely_fit" | "unlikely_fit" | "unknown";
126
+ /** AI relevance to the saved ICP, not conversion probability. */
127
+ score?: number;
105
128
  reason: string;
106
129
  };
107
130
  };
@@ -2793,6 +2816,8 @@ export interface ApiResponses {
2793
2816
  updatedAt: number;
2794
2817
  }>;
2795
2818
  "lists.list": unknown;
2819
+ "lists.rows": unknown;
2820
+ "lists.import": unknown;
2796
2821
  "lists.get": unknown;
2797
2822
  "lists.save": unknown;
2798
2823
  "lists.update": unknown;
@@ -6490,17 +6515,21 @@ export type DenchApiTree = {
6490
6515
  delete(args: Req<"lists.delete">): Promise<Res<"lists.delete">>;
6491
6516
  /** Get one saved search / list by artifact id. (`dench lists show`) */
6492
6517
  get(args: Req<"lists.get">): Promise<Res<"lists.get">>;
6518
+ /** Explicitly import selected saved profiles, optionally filtered by enrichment, with a configured Lead status. Reuses CRM records; never sends outreach or triggers conversion. (`dench artifacts import`) */
6519
+ import(args: Req<"lists.import">): Promise<Res<"lists.import">>;
6493
6520
  /** List saved searches (find-result lists) in the workspace, newest first. (`dench lists`) */
6494
6521
  list(args?: Req<"lists.list">): Promise<Res<"lists.list">>;
6495
6522
  prospects: {
6496
6523
  /** Suggest ICP fit for one profile. Never changes a human review decision. (`dench lists assess`) */
6497
6524
  assess(args: Req<"lists.prospects.assess">): Promise<Res<"lists.prospects.assess">>;
6498
- /** Read saved prospect review decisions and enrichment outcomes. Human approval is separate from AI suggestions. (`dench lists reviews`) */
6525
+ /** Read durable enrichment activity (legacy review metadata remains readable). Use lists rows for current saved profiles and contacts. (`dench lists reviews`) */
6499
6526
  reviews(args: Req<"lists.prospects.reviews">): Promise<Res<"lists.prospects.reviews">>;
6500
6527
  };
6501
6528
  /** Rename a saved search / list. (`dench lists rename`) */
6502
6529
  rename(args: Req<"lists.rename">): Promise<Res<"lists.rename">>;
6503
- /** Save find results as a named list (rows + filters become a workspace artifact). (`dench leads find --save-as "Name"`) */
6530
+ /** Read saved rows with current enrichment results and original indices; cursor-paged, without repeating a search. (`dench lists rows`) */
6531
+ rows(args: Req<"lists.rows">): Promise<Res<"lists.rows">>;
6532
+ /** Save find results as a named list (rows + filters become a workspace artifact). (`dench lists save`) */
6504
6533
  save(args: Req<"lists.save">): Promise<Res<"lists.save">>;
6505
6534
  /** Update a saved list in place (title, filters, and/or replacement rows). (`dench lists update`) */
6506
6535
  update(args: Req<"lists.update">): Promise<Res<"lists.update">>;
package/dench.ts CHANGED
@@ -501,6 +501,7 @@ Usage:
501
501
  dench artifacts import <id> --to lead|company|job_posting [--view "Q3 outbound"] [--pin] [--json]
502
502
  dench lists [--limit 25] [--json]
503
503
  dench lists show <id> [--json]
504
+ dench lists save --title "Shortlist" --people-file <people.json> [--json]
504
505
  dench lists rename <id> "New name" [--json]
505
506
  dench lists update <id> [--title "New name"] [--filters-json '{...}'] [--json]
506
507
  dench lists delete <id> [--json]
@@ -827,6 +828,7 @@ function listsCliHelp() {
827
828
  Usage:
828
829
  dench lists [--limit 25] [--json]
829
830
  dench lists show <id> [--json]
831
+ dench lists save --title "Shortlist" --people-file <people.json> [--json]
830
832
  dench lists rename <id> "New name" [--json]
831
833
  dench lists update <id> [--title "New name"] [--filters-json '{"titles":["CTO"]}'] [--json]
832
834
  dench lists delete <id> [--json]
package/leads.ts CHANGED
@@ -3,6 +3,8 @@
3
3
  * list/show/import. Find writes a durable table artifact; import is the
4
4
  * same path as the chat card.
5
5
  */
6
+
7
+ import { readFile } from "node:fs/promises";
6
8
  import type { ConvexHttpClient } from "convex/browser";
7
9
  import { makeFunctionReference } from "convex/server";
8
10
  import {
@@ -20,6 +22,7 @@ import {
20
22
  searchPeople,
21
23
  } from "./lib/enrichment-gateway";
22
24
  import { FIND_FILTER_OPTION_CATALOG } from "./lib/find-filter-options.generated";
25
+ import { parseProspectAssessments } from "./lib/prospect-assessment";
23
26
 
24
27
  class FindCliError extends Error {
25
28
  constructor(message: string) {
@@ -50,6 +53,12 @@ const api = {
50
53
  "functions/workspaceArtifacts:remove",
51
54
  ),
52
55
  list: makeFunctionReference<"query">("functions/workspaceArtifacts:list"),
56
+ listSaved: makeFunctionReference<"query">(
57
+ "functions/workspaceArtifacts:listSaved",
58
+ ),
59
+ listRows: makeFunctionReference<"action">(
60
+ "functions/workspaceArtifacts:listRows",
61
+ ),
53
62
  get: makeFunctionReference<"query">("functions/workspaceArtifacts:get"),
54
63
  reviews: makeFunctionReference<"query">("functions/prospectReviews:list"),
55
64
  assess: makeFunctionReference<"mutation">("functions/prospectReviews:assess"),
@@ -61,14 +70,22 @@ const api = {
61
70
  ),
62
71
  };
63
72
 
64
- /** createdFrom values that mark an artifact as a saved search / list. */
65
- const LIST_CREATED_FROM = new Set([
66
- "find_people",
67
- "find_companies",
68
- "find_jobs",
69
- "mixed",
70
- "watch_fire",
71
- ]);
73
+ const ENRICHMENT_FILTERS = [
74
+ "all",
75
+ "enriched",
76
+ "in_progress",
77
+ "no_contacts",
78
+ "failed",
79
+ "not_enriched",
80
+ ];
81
+ function enrichmentFlag(args: string[]): string | undefined {
82
+ const value = getFlag(args, "--enrichment");
83
+ if (value !== undefined && !ENRICHMENT_FILTERS.includes(value))
84
+ throw new FindCliError(
85
+ "--enrichment must be " + ENRICHMENT_FILTERS.join("|"),
86
+ );
87
+ return value;
88
+ }
72
89
 
73
90
  function shift(args: string[], expected: string): string {
74
91
  try {
@@ -494,7 +511,7 @@ Usage:
494
511
  dench artifacts [--limit 25] [--json]
495
512
  dench artifacts list [--limit 25] [--json]
496
513
  dench artifacts show <id> [--json]
497
- dench artifacts import <id> --to lead|company|job_posting [--view "Q3 outbound"] [--pin] [--json]
514
+ dench artifacts import <id> --to lead|company|job_posting [--rows 0,4,9] [--enrichment enriched] [--status "Contacted"] [--view "Q3 outbound"] [--pin] [--json]
498
515
 
499
516
  \`list\` / \`show\` / \`import\` operate on find results (lead lists and job
500
517
  searches). Bare \`dench artifacts\` still lists agent suggested-work artifacts.
@@ -506,18 +523,28 @@ export function listsHelp(): void {
506
523
  console.log(`Dench lists
507
524
 
508
525
  Usage:
509
- dench lists [--limit 25] [--json]
526
+ dench lists [--search "September"] [--limit 25] [--cursor <cursor>] [--json]
510
527
  dench lists show <id> [--json]
528
+ dench lists save --title "Shortlist" --people-file <people.json> [--filters-json '{...}'] [--json]
529
+ dench lists rows <id> [--enrichment all|enriched|in_progress|no_contacts|failed|not_enriched] [--limit 100] [--cursor <cursor>] [--json]
511
530
  dench lists rename <id> "New name" [--json]
512
531
  dench lists update <id> [--title "New name"] [--filters-json '{"titles":["CTO"]}'] [--json]
513
532
  dench lists delete <id> [--json]
514
533
 
515
534
  Lists are saved searches from Find (people / companies / job postings).
516
- People lists are review queues, not Leads. In Find, mark profiles ICP approved,
517
- then explicitly confirm enrichment or import. Agents can suggest fit, not approve.
535
+ People lists are not Leads. Select profiles in Find and confirm enrichment;
536
+ there is no mandatory per-profile ICP decision. Import only on explicit request, with the
537
+ requested configured CRM status. Follow pagination until isDone, even across
538
+ empty filtered pages. --rows uses original zero-based indices from lists rows.
518
539
  dench lists reviews <id> [--limit 100] [--cursor <cursor>] [--json]
519
- dench lists assess <id> --row-json '<profile>' --fit likely_fit|unlikely_fit|unknown --reason '<evidence and unknowns>' [--json]
540
+ dench lists assess <id> --row-json '<profile>' --fit likely_fit|unlikely_fit|unknown --score 0-100 --reason '<short ICP reason>' [--json]
541
+ dench lists assess <id> --assessments-file <assessments.json> [--json]
542
+ Assessments files contain 1–100 {row, suggestion: {fit, score, reason}} items.
543
+ Scores are AI relevance to the saved ICP, not conversion probabilities or CRM qualification.
520
544
  Create one with \`dench leads|companies|jobs find --save-as "Name"\`.
545
+ Consolidate selected search profiles with \`dench lists save\`: --people-file
546
+ is a JSON array of person rows, not a CSV or a whole tool response. It saves
547
+ a new list without searching, enriching, changing source lists, or importing CRM rows.
521
548
  Delete removes the list, its exported CSV/JSONL files, and any linked watch.
522
549
  CRM lists (saved views on Leads/Companies/Job Postings) are managed with
523
550
  \`dench crm views list|get|create|rename|delete\`.
@@ -545,30 +572,98 @@ export async function runListsCommand(opts: {
545
572
  if (verb === "help" || verb === "--help") return false;
546
573
  if (verb === undefined || verb === "list" || verb?.startsWith("--")) {
547
574
  if (verb === "list") args.shift();
548
- const limitRaw = getFlag(args, "--limit");
549
- const limit = limitRaw ? Number(limitRaw) : 25;
575
+ const limit = Number(getFlag(args, "--limit") ?? 25);
576
+ const cursor = getFlag(args, "--cursor") ?? null;
577
+ const search = getFlag(args, "--search");
578
+ if (!Number.isInteger(limit) || limit < 1 || limit > 100)
579
+ throw new FindCliError("--limit must be between 1 and 100");
550
580
  assertNoUnknownFlags(args, "lists");
551
- const rows = (await callQuery(ctx, api.list, {
552
- kind: "table",
553
- // Over-fetch: the query filters by kind only; saved searches are
554
- // the table artifacts whose createdFrom is a find/watch source.
555
- limit: Math.min(Math.max(limit * 2, limit), 200),
556
- })) as Array<Record<string, unknown>>;
557
- const lists = rows
558
- .filter((row) => LIST_CREATED_FROM.has(String(row.createdFrom)))
559
- .slice(0, limit)
560
- .map((row) => ({
561
- _id: row._id,
562
- title: row.title,
563
- createdFrom: row.createdFrom,
564
- rowCount: row.rowCount,
565
- createdAt: row.createdAt,
566
- watchId: row.watchId,
567
- }));
568
- out(ctx, lists);
581
+ out(
582
+ ctx,
583
+ await callQuery(ctx, api.listSaved, {
584
+ paginationOpts: { numItems: limit, cursor },
585
+ search,
586
+ }),
587
+ );
569
588
  return true;
570
589
  }
571
590
  args.shift();
591
+ if (verb === "save") {
592
+ const title = getFlag(args, "--title")?.trim();
593
+ const peopleFile = getFlag(args, "--people-file");
594
+ const filtersJson = getFlag(args, "--filters-json");
595
+ assertNoUnknownFlags(args, "lists save");
596
+ if (!title || !peopleFile) {
597
+ throw new FindCliError(
598
+ "dench lists save requires --title and --people-file",
599
+ );
600
+ }
601
+ let people: unknown;
602
+ let filters: unknown;
603
+ try {
604
+ people = JSON.parse(await readFile(peopleFile, "utf-8"));
605
+ } catch {
606
+ throw new FindCliError(
607
+ "--people-file must be a readable JSON file containing an array of person rows",
608
+ );
609
+ }
610
+ if (
611
+ !Array.isArray(people) ||
612
+ people.length === 0 ||
613
+ people.some(
614
+ (person) =>
615
+ !person ||
616
+ typeof person !== "object" ||
617
+ Array.isArray(person) ||
618
+ ![person.fullName, person.name].some(
619
+ (name) => typeof name === "string" && name.trim(),
620
+ ),
621
+ )
622
+ ) {
623
+ throw new FindCliError(
624
+ "--people-file must contain a non-empty array of person rows, each with name or fullName",
625
+ );
626
+ }
627
+ if (filtersJson !== undefined) {
628
+ try {
629
+ filters = JSON.parse(filtersJson);
630
+ } catch {
631
+ throw new FindCliError("--filters-json must be a JSON object");
632
+ }
633
+ if (!filters || typeof filters !== "object" || Array.isArray(filters)) {
634
+ throw new FindCliError("--filters-json must be a JSON object");
635
+ }
636
+ }
637
+ out(
638
+ ctx,
639
+ await callAction(ctx, api.saveFind, {
640
+ createdFrom: "find_people",
641
+ title,
642
+ people,
643
+ ...(filters !== undefined ? { filters } : {}),
644
+ }),
645
+ );
646
+ return true;
647
+ }
648
+ if (verb === "rows") {
649
+ const artifactId = shift(args, "list id");
650
+ const limit = Number(getFlag(args, "--limit") ?? 100);
651
+ const cursor = getFlag(args, "--cursor");
652
+ const enrichment = enrichmentFlag(args);
653
+ if (!Number.isInteger(limit) || limit < 1 || limit > 100)
654
+ throw new FindCliError("--limit must be between 1 and 100");
655
+ assertNoUnknownFlags(args, "lists rows");
656
+ out(
657
+ ctx,
658
+ await callAction(ctx, api.listRows, {
659
+ artifactId,
660
+ limit,
661
+ cursor,
662
+ enrichment,
663
+ }),
664
+ );
665
+ return true;
666
+ }
572
667
  if (verb === "reviews") {
573
668
  const artifactId = shift(args, "list id");
574
669
  const limit = Number(getFlag(args, "--limit") ?? 50);
@@ -588,9 +683,48 @@ export async function runListsCommand(opts: {
588
683
  if (verb === "assess") {
589
684
  const artifactId = shift(args, "list id");
590
685
  const rowJson = getFlag(args, "--row-json");
686
+ const assessmentsFile = getFlag(args, "--assessments-file");
591
687
  const fit = getFlag(args, "--fit");
688
+ const scoreRaw = getFlag(args, "--score");
592
689
  const reason = getFlag(args, "--reason");
593
690
  assertNoUnknownFlags(args, "lists assess");
691
+ if (assessmentsFile) {
692
+ if (
693
+ rowJson !== undefined ||
694
+ fit !== undefined ||
695
+ scoreRaw !== undefined ||
696
+ reason !== undefined
697
+ )
698
+ throw new FindCliError(
699
+ "Use --assessments-file alone, or --row-json with --fit, --score, and --reason.",
700
+ );
701
+ let input: unknown;
702
+ try {
703
+ input = JSON.parse(await readFile(assessmentsFile, "utf-8"));
704
+ } catch {
705
+ throw new FindCliError(
706
+ "--assessments-file must be a readable JSON array of assessments.",
707
+ );
708
+ }
709
+ const assessments = parseProspectAssessments(input);
710
+ let saved = 0;
711
+ try {
712
+ for (const assessment of assessments) {
713
+ await ctx.convex.mutation(api.assess, {
714
+ artifactId,
715
+ ...assessment,
716
+ ...(ctx.sessionToken ? { sessionToken: ctx.sessionToken } : {}),
717
+ } as never);
718
+ saved++;
719
+ }
720
+ } catch (error) {
721
+ throw new FindCliError(
722
+ `Saved ${saved} of ${assessments.length} assessments. Retry the file to continue; assessments are replaced, not duplicated. ${error instanceof Error ? error.message : "Assessment failed."}`,
723
+ );
724
+ }
725
+ out(ctx, { assessed: saved });
726
+ return true;
727
+ }
594
728
  if (
595
729
  !rowJson ||
596
730
  !reason ||
@@ -610,8 +744,18 @@ export async function runListsCommand(opts: {
610
744
  ctx,
611
745
  await ctx.convex.mutation(api.assess, {
612
746
  artifactId,
613
- row,
614
- suggestion: { fit, reason },
747
+ ...parseProspectAssessments([
748
+ {
749
+ row,
750
+ suggestion: {
751
+ fit,
752
+ reason,
753
+ ...(scoreRaw !== undefined
754
+ ? { score: scoreRaw.trim() ? Number(scoreRaw) : NaN }
755
+ : {}),
756
+ },
757
+ },
758
+ ])[0],
615
759
  ...(ctx.sessionToken ? { sessionToken: ctx.sessionToken } : {}),
616
760
  } as never),
617
761
  );
@@ -1075,6 +1219,22 @@ export async function runWorkspaceArtifactsCommand(opts: {
1075
1219
  }
1076
1220
  const viewName = getFlag(args, "--view");
1077
1221
  const pin = hasFlag(args, "--pin");
1222
+ const status = getFlag(args, "--status");
1223
+ const enrichment = enrichmentFlag(args);
1224
+ const rowsFlag = getFlag(args, "--rows");
1225
+ const rowIndexes =
1226
+ rowsFlag === undefined
1227
+ ? undefined
1228
+ : rowsFlag.split(",").map((value) => {
1229
+ if (!/^\d+$/.test(value.trim()))
1230
+ throw new FindCliError(
1231
+ "--rows must be comma-separated original zero-based row indices",
1232
+ );
1233
+ const index = Number(value);
1234
+ if (!Number.isSafeInteger(index))
1235
+ throw new FindCliError("Invalid row index");
1236
+ return index;
1237
+ });
1078
1238
  assertNoUnknownFlags(args, "artifacts import");
1079
1239
  out(
1080
1240
  ctx,
@@ -1083,6 +1243,9 @@ export async function runWorkspaceArtifactsCommand(opts: {
1083
1243
  to,
1084
1244
  viewName,
1085
1245
  pin,
1246
+ status,
1247
+ enrichment,
1248
+ rowIndexes,
1086
1249
  }),
1087
1250
  );
1088
1251
  return true;
@@ -95,12 +95,14 @@ export const APP_SDK_OPERATIONS: readonly AppSdkOperationInfo[] = [
95
95
  {"id":"workspace.artifacts.list","group":"workspace","summary":"List artifacts for the authenticated workspace.","cli":"dench artifacts","method":"GET","path":"/artifacts","permission":"workspace:read","pathParams":[]},
96
96
  {"id":"workspace.suggestedWork.list","group":"workspace","summary":"List draft suggested-work artifacts.","cli":"dench suggested-work","method":"GET","path":"/suggested-work","permission":"workspace:read","pathParams":[]},
97
97
  {"id":"lists.list","group":"lists","summary":"List saved searches (find-result lists) in the workspace, newest first.","cli":"dench lists","method":"GET","path":"/lists","permission":"lists:read","pathParams":[]},
98
+ {"id":"lists.rows","group":"lists","summary":"Read saved rows with current enrichment results and original indices; cursor-paged, without repeating a search.","cli":"dench lists rows","method":"GET","path":"/lists/{artifactId}/rows","permission":"lists:read","pathParams":["artifactId"]},
99
+ {"id":"lists.import","group":"lists","summary":"Explicitly import selected saved profiles, optionally filtered by enrichment, with a configured Lead status. Reuses CRM records; never sends outreach or triggers conversion.","cli":"dench artifacts import","method":"POST","path":"/lists/{artifactId}/import","permission":"lists:write","pathParams":["artifactId"]},
98
100
  {"id":"lists.get","group":"lists","summary":"Get one saved search / list by artifact id.","cli":"dench lists show","method":"GET","path":"/lists/{artifactId}","permission":"lists:read","pathParams":["artifactId"]},
99
- {"id":"lists.save","group":"lists","summary":"Save find results as a named list (rows + filters become a workspace artifact).","cli":"dench leads find --save-as \"Name\"","method":"POST","path":"/lists","permission":"lists:write","pathParams":[]},
101
+ {"id":"lists.save","group":"lists","summary":"Save find results as a named list (rows + filters become a workspace artifact).","cli":"dench lists save","method":"POST","path":"/lists","permission":"lists:write","pathParams":[]},
100
102
  {"id":"lists.update","group":"lists","summary":"Update a saved list in place (title, filters, and/or replacement rows).","cli":"dench lists update","method":"PATCH","path":"/lists/{artifactId}","permission":"lists:write","pathParams":["artifactId"]},
101
103
  {"id":"lists.rename","group":"lists","summary":"Rename a saved search / list.","cli":"dench lists rename","method":"POST","path":"/lists/{artifactId}/rename","permission":"lists:write","pathParams":["artifactId"]},
102
104
  {"id":"lists.delete","group":"lists","summary":"Delete a saved search / list, its exported CSV/JSONL files, and any linked watch.","cli":"dench lists delete","method":"DELETE","path":"/lists/{artifactId}","permission":"lists:write","pathParams":["artifactId"]},
103
- {"id":"lists.prospects.reviews","group":"lists","summary":"Read saved prospect review decisions and enrichment outcomes. Human approval is separate from AI suggestions.","cli":"dench lists reviews","method":"GET","path":"/lists/{artifactId}/reviews","permission":"lists:read","pathParams":["artifactId"]},
105
+ {"id":"lists.prospects.reviews","group":"lists","summary":"Read durable enrichment activity (legacy review metadata remains readable). Use lists rows for current saved profiles and contacts.","cli":"dench lists reviews","method":"GET","path":"/lists/{artifactId}/reviews","permission":"lists:read","pathParams":["artifactId"]},
104
106
  {"id":"lists.prospects.assess","group":"lists","summary":"Suggest ICP fit for one profile. Never changes a human review decision.","cli":"dench lists assess","method":"POST","path":"/lists/{artifactId}/assess","permission":"lists:write","pathParams":["artifactId"]},
105
107
  {"id":"memory.search","group":"memory","summary":"Search durable workspace memory.","cli":"dench memory search","method":"GET","path":"/memory/search","permission":"memory:read","pathParams":[]},
106
108
  {"id":"memory.save","group":"memory","summary":"Save a durable workspace memory fact.","cli":"dench memory save","method":"POST","path":"/memory","permission":"memory:write","pathParams":[]},
@@ -346,9 +346,74 @@ const rawApiOperations = [
346
346
  aliases: ["dench lists list"],
347
347
  method: "GET",
348
348
  path: "/lists",
349
- requestSchema: noBody,
349
+ requestSchema: z.object({
350
+ search: z.string().optional(),
351
+ cursor: z.string().optional(),
352
+ limit: z.coerce.number().int().min(1).max(100).optional(),
353
+ }),
354
+ responseSchema: anyResponse,
355
+ backend: {
356
+ ...convex("query", "functions/workspaceArtifacts:listSaved"),
357
+ transformArgs: (input) => ({
358
+ search: input.search,
359
+ paginationOpts: paginationOptsFrom(input, 25),
360
+ }),
361
+ },
362
+ }),
363
+ op({
364
+ id: "lists.rows",
365
+ group: "lists",
366
+ summary:
367
+ "Read saved rows with current enrichment results and original indices; cursor-paged, without repeating a search.",
368
+ cli: "dench lists rows",
369
+ method: "GET",
370
+ path: "/lists/{artifactId}/rows",
371
+ requestSchema: z.object({
372
+ artifactId: z.string().min(1),
373
+ cursor: z.string().optional(),
374
+ limit: z.coerce.number().int().min(1).max(100).optional(),
375
+ enrichment: z
376
+ .enum([
377
+ "all",
378
+ "enriched",
379
+ "in_progress",
380
+ "no_contacts",
381
+ "failed",
382
+ "not_enriched",
383
+ ])
384
+ .optional(),
385
+ }),
386
+ responseSchema: anyResponse,
387
+ backend: convex("action", "functions/workspaceArtifacts:listRows"),
388
+ }),
389
+ op({
390
+ id: "lists.import",
391
+ group: "lists",
392
+ summary:
393
+ "Explicitly import selected saved profiles, optionally filtered by enrichment, with a configured Lead status. Reuses CRM records; never sends outreach or triggers conversion.",
394
+ cli: "dench artifacts import",
395
+ method: "POST",
396
+ path: "/lists/{artifactId}/import",
397
+ requestSchema: z.object({
398
+ artifactId: z.string().min(1),
399
+ to: z.enum(["lead", "company", "job_posting"]),
400
+ rowIndexes: z.array(z.number().int().min(0)).optional(),
401
+ status: z.string().min(1).optional(),
402
+ enrichment: z
403
+ .enum([
404
+ "all",
405
+ "enriched",
406
+ "in_progress",
407
+ "no_contacts",
408
+ "failed",
409
+ "not_enriched",
410
+ ])
411
+ .optional(),
412
+ viewName: z.string().optional(),
413
+ pin: z.boolean().optional(),
414
+ }),
350
415
  responseSchema: anyResponse,
351
- backend: convex("query", "functions/workspaceArtifacts:list"),
416
+ backend: convex("action", "functions/workspaceArtifacts:importArtifact"),
352
417
  }),
353
418
  op({
354
419
  id: "lists.get",
@@ -366,7 +431,8 @@ const rawApiOperations = [
366
431
  group: "lists",
367
432
  summary:
368
433
  "Save find results as a named list (rows + filters become a workspace artifact).",
369
- cli: 'dench leads find --save-as "Name"',
434
+ cli: "dench lists save",
435
+ aliases: ['dench leads find --save-as "Name"'],
370
436
  method: "POST",
371
437
  path: "/lists",
372
438
  requestSchema: anyObject,
@@ -413,7 +479,7 @@ const rawApiOperations = [
413
479
  id: "lists.prospects.reviews",
414
480
  group: "lists",
415
481
  summary:
416
- "Read saved prospect review decisions and enrichment outcomes. Human approval is separate from AI suggestions.",
482
+ "Read durable enrichment activity (legacy review metadata remains readable). Use lists rows for current saved profiles and contacts.",
417
483
  cli: "dench lists reviews",
418
484
  method: "GET",
419
485
  path: "/lists/{artifactId}/reviews",
@@ -444,6 +510,15 @@ const rawApiOperations = [
444
510
  row: z.record(z.string(), z.unknown()),
445
511
  suggestion: z.object({
446
512
  fit: z.enum(["likely_fit", "unlikely_fit", "unknown"]),
513
+ score: z
514
+ .number()
515
+ .int()
516
+ .min(0)
517
+ .max(100)
518
+ .optional()
519
+ .describe(
520
+ "AI relevance to the saved ICP, not conversion probability.",
521
+ ),
447
522
  reason: z.string().min(1).max(2000),
448
523
  }),
449
524
  }),
@@ -0,0 +1,50 @@
1
+ export type ProspectAssessment = {
2
+ row: Record<string, unknown>;
3
+ suggestion: {
4
+ fit: "likely_fit" | "unlikely_fit" | "unknown";
5
+ score?: number;
6
+ reason: string;
7
+ };
8
+ };
9
+
10
+ /** Validate the entire file before the first write, including optional legacy scores. */
11
+ export function parseProspectAssessments(input: unknown): ProspectAssessment[] {
12
+ if (!Array.isArray(input) || !input.length || input.length > 100)
13
+ throw new Error("Provide 1–100 assessments containing row and suggestion.");
14
+ return input.map((entry) => {
15
+ const row = entry?.row;
16
+ const suggestion = entry?.suggestion;
17
+ if (
18
+ !row ||
19
+ typeof row !== "object" ||
20
+ Array.isArray(row) ||
21
+ !suggestion ||
22
+ !["likely_fit", "unlikely_fit", "unknown"].includes(suggestion.fit) ||
23
+ typeof suggestion.reason !== "string" ||
24
+ !suggestion.reason.trim() ||
25
+ suggestion.reason.length > 2000
26
+ )
27
+ throw new Error(
28
+ "Each assessment needs a profile row, fit (likely_fit|unlikely_fit|unknown), and a reason of 1–2000 characters.",
29
+ );
30
+ const score = suggestion.score;
31
+ if (
32
+ score !== undefined &&
33
+ (typeof score !== "number" ||
34
+ !Number.isInteger(score) ||
35
+ score < 0 ||
36
+ score > 100)
37
+ )
38
+ throw new Error(
39
+ "ICP relevance score must be a whole number from 0 to 100.",
40
+ );
41
+ return {
42
+ row,
43
+ suggestion: {
44
+ fit: suggestion.fit,
45
+ reason: suggestion.reason.trim(),
46
+ ...(score !== undefined ? { score } : {}),
47
+ },
48
+ };
49
+ });
50
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dench.com/cli",
3
- "version": "3.1.0-staging.292",
3
+ "version": "3.2.1-staging.295",
4
4
  "description": "Dench agent workspace CLI.",
5
5
  "type": "module",
6
6
  "bin": {