oneshot-gtm-server 0.3.0 → 0.4.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 (71) hide show
  1. package/dist/bin.mjs +788 -242
  2. package/dist/bin.mjs.map +1 -1
  3. package/dist/web/assets/Badge-B2tW85qr.js +1 -0
  4. package/dist/web/assets/Button-C-XcKplu.js +1 -0
  5. package/dist/web/assets/EmptyNote-zvLnRLPo.js +1 -0
  6. package/dist/web/assets/Field-BxSk5tbg.js +1 -0
  7. package/dist/web/assets/Modal-CU0ZPvE2.js +1 -0
  8. package/dist/web/assets/Skeleton-DNAfO8PV.js +1 -0
  9. package/dist/web/assets/StrategistPanel-DMjQbPlQ.js +6 -0
  10. package/dist/web/assets/cadences-CvBPoULf.js +1 -0
  11. package/dist/web/assets/chevron-down-CDjJN-YY.js +1 -0
  12. package/dist/web/assets/chevron-right-BTFaTdbr.js +1 -0
  13. package/dist/web/assets/{Button-D1rFtlez.js → cn-CS0Arupu.js} +1 -2
  14. package/dist/web/assets/inbox-CzzgtWQf.js +1 -0
  15. package/dist/web/assets/index-B_nrqLlS.js +54 -0
  16. package/dist/web/assets/loader-circle-CKkt6cSn.js +1 -0
  17. package/dist/web/assets/measure-CEgySDdR.js +1 -0
  18. package/dist/web/assets/plays-CuudkOHb.js +1 -0
  19. package/dist/web/assets/queue-C7vGtsQ5.js +1 -0
  20. package/dist/web/assets/receipts-B5u3oLpw.js +1 -0
  21. package/dist/web/assets/refresh-cw-Bz4Kdt55.js +1 -0
  22. package/dist/web/assets/routes-DHC_we4Z.js +1 -0
  23. package/dist/web/assets/run._playName-B9sG9Msq.js +4 -0
  24. package/dist/web/assets/send-Bv2Dd-HU.js +1 -0
  25. package/dist/web/assets/setup-BRVBiCEX.js +1 -0
  26. package/dist/web/assets/{summarizeRun-D5Pd2arb.js → summarizeRun-CVWcweeA.js} +1 -2
  27. package/dist/web/assets/x-CPdidoxn.js +1 -0
  28. package/dist/web/index.html +2 -2
  29. package/package.json +1 -1
  30. package/dist/web/assets/Badge-Bl9eBoUa.js +0 -2
  31. package/dist/web/assets/Badge-Bl9eBoUa.js.map +0 -1
  32. package/dist/web/assets/Button-D1rFtlez.js.map +0 -1
  33. package/dist/web/assets/EmptyNote-CZaRRtmD.js +0 -2
  34. package/dist/web/assets/EmptyNote-CZaRRtmD.js.map +0 -1
  35. package/dist/web/assets/Field-DJ9InfU_.js +0 -2
  36. package/dist/web/assets/Field-DJ9InfU_.js.map +0 -1
  37. package/dist/web/assets/Modal-CturxR2v.js +0 -2
  38. package/dist/web/assets/Modal-CturxR2v.js.map +0 -1
  39. package/dist/web/assets/Skeleton-CHzR-B21.js +0 -2
  40. package/dist/web/assets/Skeleton-CHzR-B21.js.map +0 -1
  41. package/dist/web/assets/cadences-D9cvMlfq.js +0 -2
  42. package/dist/web/assets/cadences-D9cvMlfq.js.map +0 -1
  43. package/dist/web/assets/chevron-down-J-vUa4uQ.js +0 -2
  44. package/dist/web/assets/chevron-down-J-vUa4uQ.js.map +0 -1
  45. package/dist/web/assets/chevron-right-DAxZefV9.js +0 -2
  46. package/dist/web/assets/chevron-right-DAxZefV9.js.map +0 -1
  47. package/dist/web/assets/inbox-Dsg3_bXr.js +0 -2
  48. package/dist/web/assets/inbox-Dsg3_bXr.js.map +0 -1
  49. package/dist/web/assets/index-BVno9lTD.js +0 -60
  50. package/dist/web/assets/index-BVno9lTD.js.map +0 -1
  51. package/dist/web/assets/loader-circle-B_w_dqVu.js +0 -2
  52. package/dist/web/assets/loader-circle-B_w_dqVu.js.map +0 -1
  53. package/dist/web/assets/measure-CV7Towgf.js +0 -2
  54. package/dist/web/assets/measure-CV7Towgf.js.map +0 -1
  55. package/dist/web/assets/plays-BSlXDDDK.js +0 -2
  56. package/dist/web/assets/plays-BSlXDDDK.js.map +0 -1
  57. package/dist/web/assets/queue-BHKT-qjx.js +0 -2
  58. package/dist/web/assets/queue-BHKT-qjx.js.map +0 -1
  59. package/dist/web/assets/receipts-opTtY1t7.js +0 -2
  60. package/dist/web/assets/receipts-opTtY1t7.js.map +0 -1
  61. package/dist/web/assets/refresh-cw-BO0blIzU.js +0 -2
  62. package/dist/web/assets/refresh-cw-BO0blIzU.js.map +0 -1
  63. package/dist/web/assets/routes-BgDvPuJP.js +0 -2
  64. package/dist/web/assets/routes-BgDvPuJP.js.map +0 -1
  65. package/dist/web/assets/run._playName-CQU-5e18.js +0 -5
  66. package/dist/web/assets/run._playName-CQU-5e18.js.map +0 -1
  67. package/dist/web/assets/send-9D8YeqmY.js +0 -2
  68. package/dist/web/assets/send-9D8YeqmY.js.map +0 -1
  69. package/dist/web/assets/setup-CqCzlBdR.js +0 -2
  70. package/dist/web/assets/setup-CqCzlBdR.js.map +0 -1
  71. package/dist/web/assets/summarizeRun-D5Pd2arb.js.map +0 -1
package/dist/bin.mjs CHANGED
@@ -181,6 +181,9 @@ var Ledger = class {
181
181
  );
182
182
  CREATE INDEX IF NOT EXISTS idx_receipts_play ON receipts(play_name);
183
183
  CREATE INDEX IF NOT EXISTS idx_receipts_created ON receipts(created_at);
184
+ -- listReceipts / spend rollups filter (play_name, created_at) together and
185
+ -- sort by created_at; the composite serves both without a separate sort scan.
186
+ CREATE INDEX IF NOT EXISTS idx_receipts_play_created ON receipts(play_name, created_at);
184
187
 
185
188
  CREATE TABLE IF NOT EXISTS prospects (
186
189
  id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -210,6 +213,11 @@ var Ledger = class {
210
213
  -- prospect), per-play send counts, and cadence scans — all by
211
214
  -- prospect_id and/or created_at. Without this it's a full table scan.
212
215
  CREATE INDEX IF NOT EXISTS idx_sequence_events_prospect_created ON sequence_events(prospect_id, created_at);
216
+ -- listSequenceEventsForProspectPlay (per-row in /api/cadences toView)
217
+ -- and listSequenceEventsForCadences (bulk variant) both filter on
218
+ -- (prospect_id, play_name) and ORDER BY step_index — composite index
219
+ -- serves both the seek and the sort, no temp B-tree.
220
+ CREATE INDEX IF NOT EXISTS idx_sequence_events_prospect_play ON sequence_events(prospect_id, play_name, step_index);
213
221
 
214
222
  CREATE TABLE IF NOT EXISTS interviews (
215
223
  id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -336,6 +344,29 @@ var Ledger = class {
336
344
  JOIN prospects p ON p.id = c.prospect_id
337
345
  ORDER BY c.status ASC, c.next_due_at ASC NULLS LAST
338
346
  `).all();
347
+ }
348
+ /**
349
+ * Single cadence (joined with its prospect) by (prospect_id, play_name) — an
350
+ * index seek on the `cadence_state` PRIMARY KEY. Replaces the O(n)
351
+ * `listAllCadences().find(...)` scan callers used to do per row.
352
+ */
353
+ getCadence(prospectId, playName) {
354
+ return this.db.query(`
355
+ SELECT c.*, p.email AS prospect_email, p.name AS prospect_name, p.company AS prospect_company
356
+ FROM cadence_state c
357
+ JOIN prospects p ON p.id = c.prospect_id
358
+ WHERE c.prospect_id = ? AND c.play_name = ?
359
+ `).get(prospectId, playName) ?? null;
360
+ }
361
+ /** All cadences for one prospect — index seek on cadence_state.prospect_id (PK prefix). */
362
+ listCadencesForProspect(prospectId) {
363
+ return this.db.query(`
364
+ SELECT c.*, p.email AS prospect_email, p.name AS prospect_name, p.company AS prospect_company
365
+ FROM cadence_state c
366
+ JOIN prospects p ON p.id = c.prospect_id
367
+ WHERE c.prospect_id = ?
368
+ ORDER BY c.status ASC, c.next_due_at ASC NULLS LAST
369
+ `).all(prospectId);
339
370
  }
340
371
  advanceCadence(input) {
341
372
  this.db.prepare(`UPDATE cadence_state
@@ -382,6 +413,10 @@ var Ledger = class {
382
413
  getProspectByEmail(email) {
383
414
  return this.db.query("SELECT * FROM prospects WHERE email = ?").get(canonEmail(email)) ?? null;
384
415
  }
416
+ /** Full prospect record by id (PK seek). Avoids loading every prospect to find one. */
417
+ getProspectById(id) {
418
+ return this.db.query("SELECT * FROM prospects WHERE id = ?").get(id) ?? null;
419
+ }
385
420
  /** Cached enrichProfile result for an email (profiles are stable; reused with a TTL). */
386
421
  getCachedEnrichment(email) {
387
422
  return this.db.query("SELECT result_json, fetched_at FROM enrichment_cache WHERE email = ?").get(email) ?? null;
@@ -501,6 +536,37 @@ var Ledger = class {
501
536
  AND status IN ('sent','delivered','replied')
502
537
  ORDER BY step_index ASC, id ASC`).all(prospectId, playName);
503
538
  }
539
+ /**
540
+ * Bulk variant of listSequenceEventsForProspectPlay: one SQL round-trip for
541
+ * many (prospect_id, play_name) pairs. Returns a Map keyed by
542
+ * `${prospect_id}|${play_name}` so callers can index in O(1). The
543
+ * per-key arrays preserve the same (step_index ASC, id ASC) ordering the
544
+ * single-row method returns. Empty input → empty map (no query).
545
+ *
546
+ * Index-served by idx_sequence_events_prospect_play; the OR-chain is
547
+ * expanded into per-pair index seeks by the query planner.
548
+ */
549
+ listSequenceEventsForCadences(pairs) {
550
+ const map = /* @__PURE__ */ new Map();
551
+ if (pairs.length === 0) return map;
552
+ const conditions = pairs.map(() => "(prospect_id = ? AND play_name = ?)").join(" OR ");
553
+ const args = [];
554
+ for (const p of pairs) args.push(p.prospectId, p.playName);
555
+ const rows = this.db.query(`SELECT * FROM sequence_events
556
+ WHERE (${conditions})
557
+ AND status IN ('sent','delivered','replied')
558
+ ORDER BY prospect_id ASC, play_name ASC, step_index ASC, id ASC`).all(...args);
559
+ for (const r of rows) {
560
+ const key = `${r.prospect_id}|${r.play_name}`;
561
+ let list = map.get(key);
562
+ if (!list) {
563
+ list = [];
564
+ map.set(key, list);
565
+ }
566
+ list.push(r);
567
+ }
568
+ return map;
569
+ }
504
570
  recordInterview(input) {
505
571
  const result = this.db.prepare(`
506
572
  INSERT INTO interviews(person, transcript_path, jtbd, pain_quotes_json)
@@ -1150,6 +1216,35 @@ function resolveClientId() {
1150
1216
  return cachedClientId;
1151
1217
  }
1152
1218
  //#endregion
1219
+ //#region ../../packages/core/src/parallel.ts
1220
+ /**
1221
+ * Run `fn` over `items` with at most `concurrency` Promises in flight at once.
1222
+ * Preserves input order in the result array. Errors propagate via Promise.all
1223
+ * — caller is expected to catch per-item internally if partial success matters.
1224
+ *
1225
+ * Worker-pool implementation: spawn `concurrency` workers that pull from a
1226
+ * shared cursor. Cheaper than a chunked Promise.all (which stalls on the
1227
+ * slowest item per chunk) and avoids the dependency surface of p-limit.
1228
+ *
1229
+ * Lives in core so both `find` (candidate pipelines) and `plays` (batch send
1230
+ * loops) can share it without a cross-package dependency.
1231
+ */
1232
+ async function parallelMap(items, concurrency, fn) {
1233
+ const out = Array.from({ length: items.length });
1234
+ if (items.length === 0) return out;
1235
+ const workers = Math.max(1, Math.min(concurrency, items.length));
1236
+ let cursor = 0;
1237
+ async function worker() {
1238
+ while (true) {
1239
+ const i = cursor++;
1240
+ if (i >= items.length) return;
1241
+ out[i] = await fn(items[i], i);
1242
+ }
1243
+ }
1244
+ await Promise.all(Array.from({ length: workers }, () => worker()));
1245
+ return out;
1246
+ }
1247
+ //#endregion
1153
1248
  //#region src/api/home.ts
1154
1249
  function homeMetrics(req) {
1155
1250
  const ledger = getLedger();
@@ -1838,7 +1933,7 @@ function enrollInCadence(input) {
1838
1933
  async function runCadenceStepForProspect(opts) {
1839
1934
  const ledger = getLedger();
1840
1935
  const cfg = loadConfig();
1841
- const cadence = ledger.listAllCadences().find((c) => c.prospect_id === opts.prospectId && c.play_name === opts.playName);
1936
+ const cadence = ledger.getCadence(opts.prospectId, opts.playName);
1842
1937
  if (!cadence) return {
1843
1938
  action: "skipped",
1844
1939
  payload: null,
@@ -1977,7 +2072,7 @@ async function runCadenceStepForProspect(opts) {
1977
2072
  async function previewCadenceStep(input) {
1978
2073
  const ledger = getLedger();
1979
2074
  const cfg = loadConfig();
1980
- const cadence = ledger.listAllCadences().find((c) => c.prospect_id === input.prospectId && c.play_name === input.playName);
2075
+ const cadence = ledger.getCadence(input.prospectId, input.playName);
1981
2076
  if (!cadence) throw new Error("no cadence for that prospect+play");
1982
2077
  if (cadence.status !== "active") throw new Error(`cadence is ${cadence.status}, can only preview an active cadence`);
1983
2078
  const seq = effectiveSequence(input.playName);
@@ -2037,30 +2132,32 @@ async function sendCadenceStep(input) {
2037
2132
  });
2038
2133
  }
2039
2134
  /**
2040
- * Serial preview of a list of cadence rows. Each per-prospect failure is
2041
- * captured in the result array — the batch never throws. Sequential
2042
- * iteration is deliberate: parallel LLM calls would risk burst rate-limits
2043
- * and the founder is waiting on us anyway (~10s/row).
2135
+ * Parallel preview of a list of cadence rows (concurrency 3). Each
2136
+ * per-prospect failure is captured in the result array — the batch never
2137
+ * throws. `parallelMap` preserves input order so the returned array matches
2138
+ * `items` 1:1. Concurrency mirrors `runEmailPlay` + `advanceCadence`; the
2139
+ * founder is waiting at the UI, so 3× speedup on a 10-row preview drops
2140
+ * wall-clock from ~100s to ~35s.
2044
2141
  */
2045
2142
  async function previewCadenceStepBatch(items) {
2046
- const out = [];
2047
- for (const item of items) try {
2048
- const preview = await previewCadenceStep(item);
2049
- out.push({
2050
- prospectId: item.prospectId,
2051
- playName: item.playName,
2052
- ok: true,
2053
- preview
2054
- });
2055
- } catch (err) {
2056
- out.push({
2057
- prospectId: item.prospectId,
2058
- playName: item.playName,
2059
- ok: false,
2060
- error: (err?.message ?? "preview failed").slice(0, 120)
2061
- });
2062
- }
2063
- return out;
2143
+ return parallelMap(items, 3, async (item) => {
2144
+ try {
2145
+ const preview = await previewCadenceStep(item);
2146
+ return {
2147
+ prospectId: item.prospectId,
2148
+ playName: item.playName,
2149
+ ok: true,
2150
+ preview
2151
+ };
2152
+ } catch (err) {
2153
+ return {
2154
+ prospectId: item.prospectId,
2155
+ playName: item.playName,
2156
+ ok: false,
2157
+ error: (err?.message ?? "preview failed").slice(0, 120)
2158
+ };
2159
+ }
2160
+ });
2064
2161
  }
2065
2162
  /**
2066
2163
  * Serial send of a list of previewed cadence rows. Each per-prospect failure
@@ -2068,6 +2165,11 @@ async function previewCadenceStepBatch(items) {
2068
2165
  * as a background promise — caller returns 202 immediately and the UI sees
2069
2166
  * progress via subsequent `/api/cadences` refetches (the existing
2070
2167
  * `advanceCadence` clears `next_step_draft_json` as each row completes).
2168
+ *
2169
+ * Sends stay serial (unlike previewCadenceStepBatch) for two reasons: the
2170
+ * `onItemSettled` callback drives the in-flight UI badge per row (parallel
2171
+ * would batch-flash all rows at once), and parallel SMTP to the same
2172
+ * domain risks soft-bounces.
2071
2173
  */
2072
2174
  async function sendCadenceStepBatch(items, onItemSettled) {
2073
2175
  const out = [];
@@ -2174,7 +2276,7 @@ async function dispatchStep(input) {
2174
2276
  };
2175
2277
  }
2176
2278
  function loadProspect(id) {
2177
- return getLedger().db.query("SELECT * FROM prospects WHERE id = ?").get(id) ?? null;
2279
+ return getLedger().getProspectById(id);
2178
2280
  }
2179
2281
  function buildFollowUpEmail(opts) {
2180
2282
  return async (ctx) => {
@@ -2228,17 +2330,37 @@ function getPriorStepsForProspect(prospectId, playName) {
2228
2330
  } catch {
2229
2331
  return [];
2230
2332
  }
2231
- return rows.map((r) => {
2232
- const meta = tryParseJsonObject(r.metadata_json ?? "", {});
2233
- return {
2234
- stepIndex: r.step_index,
2235
- label: meta.label ?? (r.step_index === 0 ? "initial send" : "follow-up"),
2236
- subject: meta.subject ?? "(no subject)",
2237
- body: meta.body ?? null,
2238
- sentAt: r.created_at,
2239
- status: r.status ?? "sent"
2240
- };
2241
- });
2333
+ return rows.map(rowToPriorStep);
2334
+ }
2335
+ function rowToPriorStep(r) {
2336
+ const meta = tryParseJsonObject(r.metadata_json ?? "", {});
2337
+ return {
2338
+ stepIndex: r.step_index,
2339
+ label: meta.label ?? (r.step_index === 0 ? "initial send" : "follow-up"),
2340
+ subject: meta.subject ?? "(no subject)",
2341
+ body: meta.body ?? null,
2342
+ sentAt: r.created_at,
2343
+ status: r.status ?? "sent"
2344
+ };
2345
+ }
2346
+ /**
2347
+ * Bulk variant of getPriorStepsForProspect: one SQL round-trip for many
2348
+ * (prospect_id, play_name) pairs. Returns a Map keyed by
2349
+ * `${prospectId}|${playName}` so /api/cadences's toView can index in O(1)
2350
+ * instead of issuing one query per row. Pairs the founder hasn't sent for
2351
+ * are absent from the map (callers should default to []).
2352
+ */
2353
+ function getPriorStepsBulk(pairs) {
2354
+ if (pairs.length === 0) return /* @__PURE__ */ new Map();
2355
+ let bulk;
2356
+ try {
2357
+ bulk = getLedger().listSequenceEventsForCadences(pairs);
2358
+ } catch {
2359
+ return /* @__PURE__ */ new Map();
2360
+ }
2361
+ const out = /* @__PURE__ */ new Map();
2362
+ for (const [key, rows] of bulk) out.set(key, rows.map(rowToPriorStep));
2363
+ return out;
2242
2364
  }
2243
2365
  function buildPriorEmailsBlock(prospectId, playName) {
2244
2366
  const prior = getPriorStepsForProspect(prospectId, playName).filter((r) => r.body !== null && r.body.length > 0);
@@ -2262,49 +2384,51 @@ function buildPriorEmailsBlock(prospectId, playName) {
2262
2384
  async function runEmailPlay(def, opts) {
2263
2385
  const cfg = loadConfig();
2264
2386
  if (!cfg.founderName || !cfg.productOneLiner) throw new Error("founder profile incomplete. Run: oneshot-gtm config founder");
2265
- const drafted = [];
2266
- for (const target of opts.targets) try {
2267
- const prep = await def.prepare(target, opts.dryRun);
2268
- const proof = socialProofBlock();
2269
- const inputBlock = proof ? `${def.buildInputBlock(target, prep, cfg)}\n\n${proof}` : def.buildInputBlock(target, prep, cfg);
2270
- const draft = await draftEmailFromPrompt({
2271
- promptName: def.promptName,
2272
- inputBlock
2273
- });
2274
- const flags = lintEmail(draft.subject, draft.body, def.maxBodyWords);
2275
- const send = await sendDraftedEmail({
2276
- playName: def.playName,
2277
- to: def.toEmail(target),
2278
- draft,
2279
- flags,
2280
- prospectMeta: def.prospectMeta(target),
2281
- ...def.metadata ? { metadata: def.metadata(target) } : {},
2282
- dryRun: opts.dryRun
2283
- });
2284
- if (send.sent && def.enrollCadence) {
2285
- const prospect = getLedger().findProspectByEmail(def.toEmail(target));
2286
- if (prospect) enrollInCadence({
2287
- prospectId: prospect.id,
2288
- playName: def.playName
2387
+ const emails = opts.targets.map((t) => def.toEmail(t).trim().toLowerCase());
2388
+ const concurrency = new Set(emails).size !== emails.length ? 1 : 3;
2389
+ return { drafted: await parallelMap(opts.targets, concurrency, async (target) => {
2390
+ try {
2391
+ const prep = await def.prepare(target, opts.dryRun);
2392
+ const proof = socialProofBlock();
2393
+ const inputBlock = proof ? `${def.buildInputBlock(target, prep, cfg)}\n\n${proof}` : def.buildInputBlock(target, prep, cfg);
2394
+ const draft = await draftEmailFromPrompt({
2395
+ promptName: def.promptName,
2396
+ inputBlock
2289
2397
  });
2398
+ const flags = lintEmail(draft.subject, draft.body, def.maxBodyWords);
2399
+ const send = await sendDraftedEmail({
2400
+ playName: def.playName,
2401
+ to: def.toEmail(target),
2402
+ draft,
2403
+ flags,
2404
+ prospectMeta: def.prospectMeta(target),
2405
+ ...def.metadata ? { metadata: def.metadata(target) } : {},
2406
+ dryRun: opts.dryRun
2407
+ });
2408
+ if (send.sent && def.enrollCadence) {
2409
+ const prospect = getLedger().findProspectByEmail(def.toEmail(target));
2410
+ if (prospect) enrollInCadence({
2411
+ prospectId: prospect.id,
2412
+ playName: def.playName
2413
+ });
2414
+ }
2415
+ return {
2416
+ target,
2417
+ subject: draft.subject,
2418
+ body: draft.body,
2419
+ receiptIds: [...prep.receiptIds, ...send.receiptIds],
2420
+ sent: send.sent,
2421
+ flags,
2422
+ ...prep.extra ?? {}
2423
+ };
2424
+ } catch (err) {
2425
+ return {
2426
+ target,
2427
+ ...errorDraft(err?.message),
2428
+ ...def.errorExtra ?? {}
2429
+ };
2290
2430
  }
2291
- drafted.push({
2292
- target,
2293
- subject: draft.subject,
2294
- body: draft.body,
2295
- receiptIds: [...prep.receiptIds, ...send.receiptIds],
2296
- sent: send.sent,
2297
- flags,
2298
- ...prep.extra ?? {}
2299
- });
2300
- } catch (err) {
2301
- drafted.push({
2302
- target,
2303
- ...errorDraft(err?.message),
2304
- ...def.errorExtra ?? {}
2305
- });
2306
- }
2307
- return { drafted };
2431
+ }) };
2308
2432
  }
2309
2433
  /**
2310
2434
  * The common `prepare` body for plays that personalize via `safeEnrich` (cached
@@ -2332,18 +2456,18 @@ async function standardEnrich(opts) {
2332
2456
  }
2333
2457
  //#endregion
2334
2458
  //#region ../../packages/plays/src/accelerator-batch.ts
2335
- const PLAY_NAME$20 = "accelerator-batch";
2459
+ const PLAY_NAME$22 = "accelerator-batch";
2336
2460
  function runAcceleratorBatch(opts) {
2337
2461
  const senderCohortFor = (t) => (t.senderCohort?.trim() || opts.senderCohort || "").trim();
2338
2462
  const offerFor = (t) => t.freeForCohortOffer ?? opts.freeForCohortOffer;
2339
2463
  return runEmailPlay({
2340
- playName: PLAY_NAME$20,
2464
+ playName: PLAY_NAME$22,
2341
2465
  promptName: "accelerator-batch-email",
2342
2466
  maxBodyWords: 100,
2343
2467
  enrollCadence: true,
2344
2468
  toEmail: (t) => t.email,
2345
2469
  prepare: (t, dryRun) => standardEnrich({
2346
- playName: PLAY_NAME$20,
2470
+ playName: PLAY_NAME$22,
2347
2471
  enrichInput: {
2348
2472
  ...t.email ? { email: t.email } : {},
2349
2473
  ...t.linkedinUrl ? { linkedinUrl: t.linkedinUrl } : {},
@@ -2378,14 +2502,14 @@ function runAcceleratorBatch(opts) {
2378
2502
  }, opts);
2379
2503
  }
2380
2504
  registerSequence({
2381
- playName: PLAY_NAME$20,
2505
+ playName: PLAY_NAME$22,
2382
2506
  steps: [{
2383
2507
  dayOffset: 5,
2384
2508
  channel: "email",
2385
2509
  breakOnReply: true,
2386
2510
  label: "single follow-up + breakup",
2387
2511
  builder: buildFollowUpEmail({
2388
- playName: PLAY_NAME$20,
2512
+ playName: PLAY_NAME$22,
2389
2513
  promptName: "breakup-email",
2390
2514
  contextLines: [`PLAY: accelerator-batch. The accelerator-batch motion is one-touch + one breakup; this is the final note. Lean very short.`]
2391
2515
  })
@@ -2393,7 +2517,7 @@ registerSequence({
2393
2517
  });
2394
2518
  //#endregion
2395
2519
  //#region ../../packages/plays/src/breakup-revive.ts
2396
- const PLAY_NAME$19 = "breakup-revive";
2520
+ const PLAY_NAME$21 = "breakup-revive";
2397
2521
  async function runBreakupRevive(opts) {
2398
2522
  const cfg = loadConfig();
2399
2523
  if (!cfg.founderName || !cfg.productOneLiner) throw new Error("founder profile incomplete. Run: oneshot-gtm config founder");
@@ -2414,7 +2538,7 @@ async function runBreakupRevive(opts) {
2414
2538
  });
2415
2539
  const flags = lintEmail(draft.subject, draft.body, 80);
2416
2540
  const send = await sendDraftedEmail({
2417
- playName: PLAY_NAME$19,
2541
+ playName: PLAY_NAME$21,
2418
2542
  to: t.email,
2419
2543
  draft,
2420
2544
  flags,
@@ -2475,10 +2599,10 @@ function ledgerScanTargets(opts) {
2475
2599
  }
2476
2600
  //#endregion
2477
2601
  //#region ../../packages/plays/src/competitor-switch.ts
2478
- const PLAY_NAME$18 = "competitor-switch";
2602
+ const PLAY_NAME$20 = "competitor-switch";
2479
2603
  function runCompetitorSwitch(opts) {
2480
2604
  return runEmailPlay({
2481
- playName: PLAY_NAME$18,
2605
+ playName: PLAY_NAME$20,
2482
2606
  promptName: "competitor-switch-email",
2483
2607
  maxBodyWords: 100,
2484
2608
  enrollCadence: true,
@@ -2490,7 +2614,7 @@ function runCompetitorSwitch(opts) {
2490
2614
  ...t.email ? { email: t.email } : {},
2491
2615
  name: t.name,
2492
2616
  companyDomain: emailDomain(t.email)
2493
- }, { playName: PLAY_NAME$18 });
2617
+ }, { playName: PLAY_NAME$20 });
2494
2618
  if (enr.receiptId) receiptIds.push(enr.receiptId);
2495
2619
  const dossier = JSON.stringify(enr.result, null, 2).slice(0, 3500);
2496
2620
  if (!dryRun) {
@@ -2514,7 +2638,7 @@ function runCompetitorSwitch(opts) {
2514
2638
  }
2515
2639
  },
2516
2640
  maxSteps: 12
2517
- }, { playName: PLAY_NAME$18 });
2641
+ }, { playName: PLAY_NAME$20 });
2518
2642
  receiptIds.push(browse.receiptId);
2519
2643
  scrapedEvidence = typeof browse.result.output === "string" ? browse.result.output : JSON.stringify(browse.result.output ?? {});
2520
2644
  }
@@ -2552,14 +2676,14 @@ function runCompetitorSwitch(opts) {
2552
2676
  }, opts);
2553
2677
  }
2554
2678
  registerSequence({
2555
- playName: PLAY_NAME$18,
2679
+ playName: PLAY_NAME$20,
2556
2680
  steps: [{
2557
2681
  dayOffset: 3,
2558
2682
  channel: "email",
2559
2683
  breakOnReply: true,
2560
2684
  label: "value follow-up",
2561
2685
  builder: buildFollowUpEmail({
2562
- playName: PLAY_NAME$18,
2686
+ playName: PLAY_NAME$20,
2563
2687
  promptName: "competitor-switch-followup",
2564
2688
  contextLines: [`PLAY: competitor-switch. Day-3 value follow-up after the migration-honesty pitch.`]
2565
2689
  })
@@ -2569,7 +2693,7 @@ registerSequence({
2569
2693
  breakOnReply: true,
2570
2694
  label: "breakup",
2571
2695
  builder: buildFollowUpEmail({
2572
- playName: PLAY_NAME$18,
2696
+ playName: PLAY_NAME$20,
2573
2697
  promptName: "breakup-email",
2574
2698
  contextLines: [`PLAY: competitor-switch. Final breakup after the migration-honesty pitch.`]
2575
2699
  })
@@ -2577,11 +2701,11 @@ registerSequence({
2577
2701
  });
2578
2702
  //#endregion
2579
2703
  //#region ../../packages/plays/src/hiring-signal.ts
2580
- const PLAY_NAME$17 = "hiring-signal";
2704
+ const PLAY_NAME$19 = "hiring-signal";
2581
2705
  const NO_HOOK = "(no specific job post phrase scraped)";
2582
2706
  function runHiringSignal(opts) {
2583
2707
  return runEmailPlay({
2584
- playName: PLAY_NAME$17,
2708
+ playName: PLAY_NAME$19,
2585
2709
  promptName: "hiring-signal-email",
2586
2710
  maxBodyWords: 100,
2587
2711
  enrollCadence: true,
@@ -2596,12 +2720,12 @@ function runHiringSignal(opts) {
2596
2720
  const search = await webSearch({
2597
2721
  query: `${t.company} careers ${t.jobTitle} site:lever.co OR site:greenhouse.io OR site:workable.com OR site:ashbyhq.com`,
2598
2722
  maxResults: 5
2599
- }, { playName: PLAY_NAME$17 });
2723
+ }, { playName: PLAY_NAME$19 });
2600
2724
  receiptIds.push(search.receiptId);
2601
2725
  jobUrl = search.result.results[0]?.url;
2602
2726
  }
2603
2727
  if (jobUrl) {
2604
- const read = await webRead({ url: jobUrl }, { playName: PLAY_NAME$17 });
2728
+ const read = await webRead({ url: jobUrl }, { playName: PLAY_NAME$19 });
2605
2729
  receiptIds.push(read.receiptId);
2606
2730
  const md = read.result.markdown ?? "";
2607
2731
  jobPostHook = (md.match(/(?:About the role|Responsibilities|Requirements|What you[' ]?ll do)[^\n]*\n+([\s\S]{40,300})/i)?.[1] ?? md.slice(0, 400)).replace(/\s+/g, " ").trim();
@@ -2636,14 +2760,14 @@ function runHiringSignal(opts) {
2636
2760
  }, opts);
2637
2761
  }
2638
2762
  registerSequence({
2639
- playName: PLAY_NAME$17,
2763
+ playName: PLAY_NAME$19,
2640
2764
  steps: [{
2641
2765
  dayOffset: 3,
2642
2766
  channel: "email",
2643
2767
  breakOnReply: true,
2644
2768
  label: "value follow-up",
2645
2769
  builder: buildFollowUpEmail({
2646
- playName: PLAY_NAME$17,
2770
+ playName: PLAY_NAME$19,
2647
2771
  promptName: "hiring-signal-followup",
2648
2772
  contextLines: [`PLAY: hiring-signal. Day-3 value follow-up about the open role.`]
2649
2773
  })
@@ -2653,7 +2777,7 @@ registerSequence({
2653
2777
  breakOnReply: true,
2654
2778
  label: "breakup",
2655
2779
  builder: buildFollowUpEmail({
2656
- playName: PLAY_NAME$17,
2780
+ playName: PLAY_NAME$19,
2657
2781
  promptName: "breakup-email",
2658
2782
  contextLines: [`PLAY: hiring-signal. Final breakup.`]
2659
2783
  })
@@ -2661,15 +2785,15 @@ registerSequence({
2661
2785
  });
2662
2786
  //#endregion
2663
2787
  //#region ../../packages/plays/src/job-change.ts
2664
- const PLAY_NAME$16 = "job-change";
2788
+ const PLAY_NAME$18 = "job-change";
2665
2789
  const jobChangeDef = {
2666
- playName: PLAY_NAME$16,
2790
+ playName: PLAY_NAME$18,
2667
2791
  promptName: "job-change-email",
2668
2792
  maxBodyWords: 100,
2669
2793
  enrollCadence: true,
2670
2794
  toEmail: (t) => t.email,
2671
2795
  prepare: (t, dryRun) => standardEnrich({
2672
- playName: PLAY_NAME$16,
2796
+ playName: PLAY_NAME$18,
2673
2797
  enrichInput: {
2674
2798
  ...t.email ? { email: t.email } : {},
2675
2799
  ...t.linkedinUrl ? { linkedinUrl: t.linkedinUrl } : {},
@@ -2703,14 +2827,14 @@ function runJobChange(opts) {
2703
2827
  return runEmailPlay(jobChangeDef, opts);
2704
2828
  }
2705
2829
  registerSequence({
2706
- playName: PLAY_NAME$16,
2830
+ playName: PLAY_NAME$18,
2707
2831
  steps: [{
2708
2832
  dayOffset: 5,
2709
2833
  channel: "email",
2710
2834
  breakOnReply: true,
2711
2835
  label: "value follow-up",
2712
2836
  builder: buildFollowUpEmail({
2713
- playName: PLAY_NAME$16,
2837
+ playName: PLAY_NAME$18,
2714
2838
  promptName: "job-change-followup",
2715
2839
  contextLines: [`CONTEXT: prospect recently joined a new role; first email went unanswered ~5 days ago.`]
2716
2840
  })
@@ -2720,7 +2844,7 @@ registerSequence({
2720
2844
  breakOnReply: true,
2721
2845
  label: "breakup",
2722
2846
  builder: buildFollowUpEmail({
2723
- playName: PLAY_NAME$16,
2847
+ playName: PLAY_NAME$18,
2724
2848
  promptName: "breakup-email",
2725
2849
  contextLines: [`PLAY: job-change. Sender is closing the file.`]
2726
2850
  })
@@ -2728,10 +2852,10 @@ registerSequence({
2728
2852
  });
2729
2853
  //#endregion
2730
2854
  //#region ../../packages/plays/src/podcast-guest.ts
2731
- const PLAY_NAME$15 = "podcast-guest";
2855
+ const PLAY_NAME$17 = "podcast-guest";
2732
2856
  function runPodcastGuest(opts) {
2733
2857
  return runEmailPlay({
2734
- playName: PLAY_NAME$15,
2858
+ playName: PLAY_NAME$17,
2735
2859
  promptName: "podcast-guest-email",
2736
2860
  maxBodyWords: 90,
2737
2861
  enrollCadence: true,
@@ -2743,7 +2867,7 @@ function runPodcastGuest(opts) {
2743
2867
  const s = await webSearch({
2744
2868
  query: `${t.name} ${t.podcast} "${t.episodeTitle}" notes OR transcript`,
2745
2869
  maxResults: 3
2746
- }, { playName: PLAY_NAME$15 });
2870
+ }, { playName: PLAY_NAME$17 });
2747
2871
  receiptIds.push(s.receiptId);
2748
2872
  dossier = s.result.results.slice(0, 2).map((r) => `- ${r.title}: ${r.description}`).join("\n");
2749
2873
  }
@@ -2777,20 +2901,20 @@ function runPodcastGuest(opts) {
2777
2901
  }, opts);
2778
2902
  }
2779
2903
  registerSequence({
2780
- playName: PLAY_NAME$15,
2904
+ playName: PLAY_NAME$17,
2781
2905
  steps: []
2782
2906
  });
2783
2907
  //#endregion
2784
2908
  //#region ../../packages/plays/src/post-funding.ts
2785
- const PLAY_NAME$14 = "post-funding";
2909
+ const PLAY_NAME$16 = "post-funding";
2786
2910
  const postFundingDef = {
2787
- playName: PLAY_NAME$14,
2911
+ playName: PLAY_NAME$16,
2788
2912
  promptName: "post-funding-email",
2789
2913
  maxBodyWords: 100,
2790
2914
  enrollCadence: true,
2791
2915
  toEmail: (t) => t.email,
2792
2916
  prepare: (t, dryRun) => standardEnrich({
2793
- playName: PLAY_NAME$14,
2917
+ playName: PLAY_NAME$16,
2794
2918
  enrichInput: {
2795
2919
  ...t.email ? { email: t.email } : {},
2796
2920
  ...t.linkedinUrl ? { linkedinUrl: t.linkedinUrl } : {},
@@ -2826,14 +2950,14 @@ function runPostFunding(opts) {
2826
2950
  return runEmailPlay(postFundingDef, opts);
2827
2951
  }
2828
2952
  registerSequence({
2829
- playName: PLAY_NAME$14,
2953
+ playName: PLAY_NAME$16,
2830
2954
  steps: [{
2831
2955
  dayOffset: 9,
2832
2956
  channel: "email",
2833
2957
  breakOnReply: true,
2834
2958
  label: "case-study follow-up",
2835
2959
  builder: buildFollowUpEmail({
2836
- playName: PLAY_NAME$14,
2960
+ playName: PLAY_NAME$16,
2837
2961
  promptName: "post-funding-followup",
2838
2962
  contextLines: [`CONTEXT: prospect's company recently raised; first email sent ~9 days ago, no reply.`]
2839
2963
  })
@@ -2843,22 +2967,60 @@ registerSequence({
2843
2967
  breakOnReply: true,
2844
2968
  label: "breakup",
2845
2969
  builder: buildFollowUpEmail({
2846
- playName: PLAY_NAME$14,
2970
+ playName: PLAY_NAME$16,
2847
2971
  promptName: "breakup-email",
2848
2972
  contextLines: [`PLAY: post-funding.`]
2849
2973
  })
2850
2974
  }]
2851
2975
  });
2852
2976
  //#endregion
2977
+ //#region ../../packages/plays/src/repo-interest.ts
2978
+ const PLAY_NAME$15 = "repo-interest";
2979
+ const repoInterestDef = {
2980
+ playName: PLAY_NAME$15,
2981
+ promptName: "repo-interest-email",
2982
+ maxBodyWords: 90,
2983
+ toEmail: (t) => t.email,
2984
+ prepare: (t) => standardEnrich({
2985
+ playName: PLAY_NAME$15,
2986
+ enrichInput: {
2987
+ ...t.email ? { email: t.email } : {},
2988
+ name: t.name,
2989
+ companyDomain: emailDomain(t.email)
2990
+ },
2991
+ enrichSlice: 3500
2992
+ }),
2993
+ buildInputBlock: (t, prep, cfg) => [
2994
+ `FOUNDER: ${cfg.founderName}`,
2995
+ `PRODUCT: ${cfg.productOneLiner}`,
2996
+ `PROSPECT: ${t.name} at ${t.company}`,
2997
+ `STARRED REPO: ${t.repoLabel ?? t.repo}`,
2998
+ `YOUR EDGE: ${t.yourEdge}`,
2999
+ `DOSSIER:\n${prep.dossier || "(dry-run)"}`
3000
+ ].join("\n"),
3001
+ prospectMeta: (t) => ({
3002
+ name: t.name,
3003
+ email: t.email,
3004
+ company: t.company,
3005
+ linkedin_url: t.linkedinUrl ?? null,
3006
+ phone: t.phone ?? null,
3007
+ source: "repo-interest"
3008
+ }),
3009
+ metadata: (t) => ({ repo: t.repo })
3010
+ };
3011
+ function runRepoInterest(opts) {
3012
+ return runEmailPlay(repoInterestDef, opts);
3013
+ }
3014
+ //#endregion
2853
3015
  //#region ../../packages/plays/src/show-hn.ts
2854
- const PLAY_NAME$13 = "show-hn";
3016
+ const PLAY_NAME$14 = "show-hn";
2855
3017
  const showHnDef = {
2856
- playName: PLAY_NAME$13,
3018
+ playName: PLAY_NAME$14,
2857
3019
  promptName: "show-hn-email",
2858
3020
  maxBodyWords: 90,
2859
3021
  toEmail: (t) => t.founderEmail,
2860
3022
  prepare: (t, dryRun) => standardEnrich({
2861
- playName: PLAY_NAME$13,
3023
+ playName: PLAY_NAME$14,
2862
3024
  enrichInput: {
2863
3025
  email: t.founderEmail,
2864
3026
  name: t.founderName
@@ -2896,15 +3058,15 @@ function extractCompany(title) {
2896
3058
  }
2897
3059
  //#endregion
2898
3060
  //#region ../../packages/plays/src/stack-consolidation.ts
2899
- const PLAY_NAME$12 = "stack-consolidation";
3061
+ const PLAY_NAME$13 = "stack-consolidation";
2900
3062
  const stackConsolidationDef = {
2901
- playName: PLAY_NAME$12,
3063
+ playName: PLAY_NAME$13,
2902
3064
  promptName: "stack-consolidation-email",
2903
3065
  maxBodyWords: 100,
2904
3066
  enrollCadence: true,
2905
3067
  toEmail: (t) => t.email,
2906
3068
  prepare: (t) => standardEnrich({
2907
- playName: PLAY_NAME$12,
3069
+ playName: PLAY_NAME$13,
2908
3070
  enrichInput: {
2909
3071
  ...t.email ? { email: t.email } : {},
2910
3072
  name: t.name,
@@ -2937,14 +3099,14 @@ function runStackConsolidation(opts) {
2937
3099
  return runEmailPlay(stackConsolidationDef, opts);
2938
3100
  }
2939
3101
  registerSequence({
2940
- playName: PLAY_NAME$12,
3102
+ playName: PLAY_NAME$13,
2941
3103
  steps: [{
2942
3104
  dayOffset: 3,
2943
3105
  channel: "email",
2944
3106
  breakOnReply: true,
2945
3107
  label: "value follow-up",
2946
3108
  builder: buildFollowUpEmail({
2947
- playName: PLAY_NAME$12,
3109
+ playName: PLAY_NAME$13,
2948
3110
  promptName: "stack-consolidation-followup",
2949
3111
  contextLines: [`PLAY: stack-consolidation. Day-3 value follow-up after the consolidation-honesty pitch.`]
2950
3112
  })
@@ -2954,7 +3116,7 @@ registerSequence({
2954
3116
  breakOnReply: true,
2955
3117
  label: "breakup",
2956
3118
  builder: buildFollowUpEmail({
2957
- playName: PLAY_NAME$12,
3119
+ playName: PLAY_NAME$13,
2958
3120
  promptName: "breakup-email",
2959
3121
  contextLines: [`PLAY: stack-consolidation. Final breakup after the consolidation-honesty pitch.`]
2960
3122
  })
@@ -3003,6 +3165,10 @@ const PLAYS = {
3003
3165
  dryRun: o.dryRun,
3004
3166
  targets: o.targets
3005
3167
  }) },
3168
+ "repo-interest": { run: (o) => runRepoInterest({
3169
+ dryRun: o.dryRun,
3170
+ targets: o.targets
3171
+ }) },
3006
3172
  "breakup-revive": { run: (o) => runBreakupRevive({
3007
3173
  dryRun: o.dryRun,
3008
3174
  targets: o.targets
@@ -3013,16 +3179,16 @@ function isSupportedPlay(name) {
3013
3179
  }
3014
3180
  //#endregion
3015
3181
  //#region ../../packages/plays/src/demo-no-show.ts
3016
- const PLAY_NAME$11 = "demo-no-show";
3182
+ const PLAY_NAME$12 = "demo-no-show";
3017
3183
  registerSequence({
3018
- playName: PLAY_NAME$11,
3184
+ playName: PLAY_NAME$12,
3019
3185
  steps: [{
3020
3186
  dayOffset: 3,
3021
3187
  channel: "email",
3022
3188
  breakOnReply: true,
3023
3189
  label: "day-3 follow-up",
3024
3190
  builder: buildFollowUpEmail({
3025
- playName: PLAY_NAME$11,
3191
+ playName: PLAY_NAME$12,
3026
3192
  promptName: "demo-no-show-followup",
3027
3193
  contextLines: [`PLAY: demo-no-show day-3 follow-up. After this, drop the lead.`]
3028
3194
  })
@@ -3041,7 +3207,28 @@ registerSequence({
3041
3207
  */
3042
3208
  const inFlightSends = /* @__PURE__ */ new Set();
3043
3209
  const inFlightKey = (prospectId, playName) => `${prospectId}|${playName}`;
3044
- function toView$3(row) {
3210
+ function buildPlayInfoMap(rows) {
3211
+ const map = /* @__PURE__ */ new Map();
3212
+ for (const row of rows) {
3213
+ let info = map.get(row.play_name);
3214
+ if (!info) {
3215
+ info = {
3216
+ nextLabelByStep: /* @__PURE__ */ new Map(),
3217
+ followupCount: playFollowupCount(row.play_name)
3218
+ };
3219
+ map.set(row.play_name, info);
3220
+ }
3221
+ if (!info.nextLabelByStep.has(row.current_step)) {
3222
+ const next = nextStepInfo(row.play_name, row.current_step);
3223
+ info.nextLabelByStep.set(row.current_step, {
3224
+ label: next?.label ?? null,
3225
+ isBreakup: next?.isBreakup ?? false
3226
+ });
3227
+ }
3228
+ }
3229
+ return map;
3230
+ }
3231
+ function toView$3(row, priorByKey, playInfo) {
3045
3232
  let nextStepDraft = null;
3046
3233
  if (row.next_step_draft_json) try {
3047
3234
  const parsed = JSON.parse(row.next_step_draft_json);
@@ -3054,8 +3241,10 @@ function toView$3(row) {
3054
3241
  } catch {
3055
3242
  nextStepDraft = null;
3056
3243
  }
3057
- const next = nextStepInfo(row.play_name, row.current_step);
3058
- const priorSteps = getPriorStepsForProspect(row.prospect_id, row.play_name).map((s) => ({
3244
+ const info = playInfo.get(row.play_name);
3245
+ const next = info?.nextLabelByStep.get(row.current_step) ?? null;
3246
+ const followupCount = info?.followupCount ?? 0;
3247
+ const priorSteps = (priorByKey.get(`${row.prospect_id}|${row.play_name}`) ?? []).map((s) => ({
3059
3248
  stepIndex: s.stepIndex,
3060
3249
  label: s.label,
3061
3250
  subject: s.subject,
@@ -3076,30 +3265,37 @@ function toView$3(row) {
3076
3265
  nextStepDraft,
3077
3266
  nextStepLabel: next?.label ?? null,
3078
3267
  nextStepIsBreakup: next?.isBreakup ?? false,
3079
- followupCount: playFollowupCount(row.play_name),
3268
+ followupCount,
3080
3269
  priorSteps,
3081
3270
  isSending: inFlightSends.has(inFlightKey(row.prospect_id, row.play_name))
3082
3271
  };
3083
3272
  }
3273
+ function viewsForRows(rows) {
3274
+ const priorByKey = getPriorStepsBulk(rows.map((r) => ({
3275
+ prospectId: r.prospect_id,
3276
+ playName: r.play_name
3277
+ })));
3278
+ const playInfo = buildPlayInfoMap(rows);
3279
+ return rows.map((r) => toView$3(r, priorByKey, playInfo));
3280
+ }
3084
3281
  function listCadences(req) {
3085
3282
  const all = new URL(req.url).searchParams.get("all") === "1";
3086
3283
  const ledger = getLedger();
3087
- return jsonResponse({ cadences: (all ? ledger.listAllCadences() : ledger.listActiveCadences()).map(toView$3) }, 200, req);
3284
+ return jsonResponse({ cadences: viewsForRows(all ? ledger.listAllCadences() : ledger.listActiveCadences()) }, 200, req);
3088
3285
  }
3089
3286
  function getCadence(req, params) {
3090
3287
  const id = Number.parseInt(params["id"] ?? "", 10);
3091
3288
  if (!Number.isFinite(id)) return jsonResponse({ error: "bad id" }, 400, req);
3092
- const all = getLedger().listAllCadences().filter((c) => c.prospect_id === id);
3289
+ const all = getLedger().listCadencesForProspect(id);
3093
3290
  if (all.length === 0) return jsonResponse({ error: "no cadences for prospect" }, 404, req);
3094
- return jsonResponse({ cadences: all.map(toView$3) }, 200, req);
3291
+ return jsonResponse({ cadences: viewsForRows(all) }, 200, req);
3095
3292
  }
3096
3293
  function stopCadence(req, params) {
3097
3294
  const id = Number.parseInt(params["id"] ?? "", 10);
3098
3295
  if (!Number.isFinite(id)) return jsonResponse({ error: "bad id" }, 400, req);
3099
3296
  const playName = new URL(req.url).searchParams.get("play");
3100
3297
  const ledger = getLedger();
3101
- const cadences = ledger.listAllCadences().filter((c) => {
3102
- if (c.prospect_id !== id) return false;
3298
+ const cadences = ledger.listCadencesForProspect(id).filter((c) => {
3103
3299
  if (playName && c.play_name !== playName) return false;
3104
3300
  return c.status === "active";
3105
3301
  });
@@ -3358,6 +3554,10 @@ const PLAY_CATALOG = [
3358
3554
  name: "stack-consolidation",
3359
3555
  cli: "oneshot-gtm find watch # fed by the github-topics finder, drained from /queue"
3360
3556
  },
3557
+ {
3558
+ name: "repo-interest",
3559
+ cli: "oneshot-gtm find watch # fed by the github-stars finder (adjacent repos), drained from /queue"
3560
+ },
3361
3561
  {
3362
3562
  name: "hiring-signal",
3363
3563
  cli: "oneshot-gtm motion hiring-signal --target ./examples/hiring-signal.json"
@@ -3581,7 +3781,7 @@ function mergeString(incoming, current) {
3581
3781
  }
3582
3782
  //#endregion
3583
3783
  //#region src/api/derive-icp.ts
3584
- const PLAY_NAME$10 = "config:icp";
3784
+ const PLAY_NAME$11 = "config:icp";
3585
3785
  async function deriveIcpRoute(req) {
3586
3786
  startRun();
3587
3787
  let body = {};
@@ -3600,7 +3800,7 @@ async function deriveIcpRoute(req) {
3600
3800
  const readStartedAt = Date.now();
3601
3801
  logEvent("derive_icp.read.start", { host });
3602
3802
  try {
3603
- const read = await webRead({ url }, { playName: PLAY_NAME$10 });
3803
+ const read = await webRead({ url }, { playName: PLAY_NAME$11 });
3604
3804
  markdown = (read.result.markdown ?? "").trim();
3605
3805
  const c = read.result.cost;
3606
3806
  if (typeof c === "number") costUsd += c;
@@ -3948,7 +4148,7 @@ function shouldSkipFindEmail(input) {
3948
4148
  * the founder sees these signals in /queue review and the prospect row carries
3949
4149
  * them after drain.
3950
4150
  */
3951
- const PLAY_NAME$9 = "linkedin-lookup";
4151
+ const PLAY_NAME$10 = "linkedin-lookup";
3952
4152
  /** Match `linkedin.com/in/<slug>` profile URLs. The slug class is permissive
3953
4153
  * enough to cover URL-encoded unicode slugs (e.g. `%E7%8E%8B`) which LinkedIn
3954
4154
  * does serve for non-Latin display names. */
@@ -3995,7 +4195,7 @@ async function findLinkedInUrl(args) {
3995
4195
  const search = await webSearch({
3996
4196
  query,
3997
4197
  maxResults: 5
3998
- }, { playName: PLAY_NAME$9 });
4198
+ }, { playName: PLAY_NAME$10 });
3999
4199
  args.accumCost(search.result.cost ?? 0);
4000
4200
  for (const r of search.result.results ?? []) {
4001
4201
  const url = typeof r.url === "string" ? r.url : "";
@@ -4093,35 +4293,9 @@ async function enrichVerifiedContact(email, opts) {
4093
4293
  }
4094
4294
  }
4095
4295
  //#endregion
4096
- //#region ../../packages/find/src/_parallel.ts
4097
- /**
4098
- * Run `fn` over `items` with at most `concurrency` Promises in flight at once.
4099
- * Preserves input order in the result array. Errors propagate via Promise.all
4100
- * — caller is expected to catch per-item internally if partial success matters.
4101
- *
4102
- * Worker-pool implementation: spawn `concurrency` workers that pull from a
4103
- * shared cursor. Cheaper than a chunked Promise.all (which stalls on the
4104
- * slowest item per chunk) and avoids the dependency surface of p-limit.
4105
- */
4106
- async function parallelMap(items, concurrency, fn) {
4107
- const out = Array.from({ length: items.length });
4108
- if (items.length === 0) return out;
4109
- const workers = Math.max(1, Math.min(concurrency, items.length));
4110
- let cursor = 0;
4111
- async function worker() {
4112
- while (true) {
4113
- const i = cursor++;
4114
- if (i >= items.length) return;
4115
- out[i] = await fn(items[i], i);
4116
- }
4117
- }
4118
- await Promise.all(Array.from({ length: workers }, () => worker()));
4119
- return out;
4120
- }
4121
- //#endregion
4122
4296
  //#region ../../packages/find/src/show-hn.ts
4123
4297
  const HN_ALGOLIA = "https://hn.algolia.com/api/v1/search_by_date";
4124
- const PLAY_NAME$8 = "show-hn";
4298
+ const PLAY_NAME$9 = "show-hn";
4125
4299
  const SOURCE$6 = "find:show-hn";
4126
4300
  /**
4127
4301
  * Pulls Show HN posts from HN Algolia, ICP-filters them, enriches founder
@@ -4144,7 +4318,7 @@ async function runShowHnFinder(opts) {
4144
4318
  costUsd: 0
4145
4319
  };
4146
4320
  logEvent("finder.start", {
4147
- name: PLAY_NAME$8,
4321
+ name: PLAY_NAME$9,
4148
4322
  since_days: sinceDays,
4149
4323
  limit
4150
4324
  });
@@ -4154,7 +4328,7 @@ async function runShowHnFinder(opts) {
4154
4328
  const data = await res.json();
4155
4329
  result.candidates = data.hits.length;
4156
4330
  logEvent("finder.fetched", {
4157
- name: PLAY_NAME$8,
4331
+ name: PLAY_NAME$9,
4158
4332
  candidates: result.candidates
4159
4333
  });
4160
4334
  const concurrency = opts.concurrency ?? 3;
@@ -4174,7 +4348,7 @@ async function runShowHnFinder(opts) {
4174
4348
  result.droppedLowSignal = (result.droppedLowSignal ?? 0) + 1;
4175
4349
  return;
4176
4350
  }
4177
- if (ledger.isQueueDuplicate(PLAY_NAME$8, hit.objectID)) {
4351
+ if (ledger.isQueueDuplicate(PLAY_NAME$9, hit.objectID)) {
4178
4352
  result.droppedDuplicate++;
4179
4353
  return;
4180
4354
  }
@@ -4190,7 +4364,7 @@ async function runShowHnFinder(opts) {
4190
4364
  if (!filter.match) {
4191
4365
  result.droppedIcp++;
4192
4366
  if (!opts.dryRun) ledger.enqueueTarget({
4193
- playName: PLAY_NAME$8,
4367
+ playName: PLAY_NAME$9,
4194
4368
  payload: {
4195
4369
  postTitle: hit.title,
4196
4370
  postUrl: hit.url,
@@ -4220,28 +4394,28 @@ async function runShowHnFinder(opts) {
4220
4394
  if (!skip.ok) {
4221
4395
  result.droppedEnrichment++;
4222
4396
  logEvent("finder.skipped_findemail", {
4223
- name: PLAY_NAME$8,
4397
+ name: PLAY_NAME$9,
4224
4398
  reason: skip.reason
4225
4399
  }, "info");
4226
4400
  return;
4227
4401
  }
4228
4402
  const findInput = { companyDomain: domain };
4229
4403
  if (fullName) findInput.fullName = fullName;
4230
- const found = await findEmail(findInput, { playName: PLAY_NAME$8 });
4404
+ const found = await findEmail(findInput, { playName: PLAY_NAME$9 });
4231
4405
  result.costUsd += found.result.cost ?? 0;
4232
4406
  if (!found.result.found || !found.result.email) {
4233
4407
  result.droppedEnrichment++;
4234
4408
  return;
4235
4409
  }
4236
4410
  const email = found.result.email;
4237
- const verified = await verifyEmail({ email }, { playName: PLAY_NAME$8 });
4411
+ const verified = await verifyEmail({ email }, { playName: PLAY_NAME$9 });
4238
4412
  result.costUsd += verified.result.cost ?? 0;
4239
4413
  if (!verified.result.deliverable) {
4240
4414
  result.droppedEnrichment++;
4241
4415
  return;
4242
4416
  }
4243
4417
  if (isDuplicate({
4244
- playName: PLAY_NAME$8,
4418
+ playName: PLAY_NAME$9,
4245
4419
  dedupeKey: hit.objectID,
4246
4420
  prospectEmail: email
4247
4421
  })) {
@@ -4250,7 +4424,7 @@ async function runShowHnFinder(opts) {
4250
4424
  }
4251
4425
  let hookSummary = (hit.story_text ?? "").trim().slice(0, 280);
4252
4426
  if (hookSummary.length < 40 && hit.url) try {
4253
- const read = await webRead({ url: hit.url }, { playName: PLAY_NAME$8 });
4427
+ const read = await webRead({ url: hit.url }, { playName: PLAY_NAME$9 });
4254
4428
  result.costUsd += read.result.cost ?? 0;
4255
4429
  hookSummary = (read.result.markdown ?? "").trim().slice(0, 280);
4256
4430
  } catch (err) {
@@ -4262,7 +4436,7 @@ async function runShowHnFinder(opts) {
4262
4436
  if (!hookSummary || hookSummary.length < 20) hookSummary = `Show HN post: ${hit.title}. ${hit.points} points.`;
4263
4437
  const founderName = found.result.full_name ?? hit.author;
4264
4438
  const enr = await enrichVerifiedContact(email, {
4265
- playName: PLAY_NAME$8,
4439
+ playName: PLAY_NAME$9,
4266
4440
  errKindPrefix: "show-hn"
4267
4441
  });
4268
4442
  result.costUsd += enr.costUsd;
@@ -4286,7 +4460,7 @@ async function runShowHnFinder(opts) {
4286
4460
  ...phone ? { phone } : {}
4287
4461
  };
4288
4462
  if (ledger.enqueueTarget({
4289
- playName: PLAY_NAME$8,
4463
+ playName: PLAY_NAME$9,
4290
4464
  payload: target,
4291
4465
  dedupeKey: hit.objectID,
4292
4466
  source: SOURCE$6,
@@ -4295,7 +4469,7 @@ async function runShowHnFinder(opts) {
4295
4469
  else result.droppedDuplicate++;
4296
4470
  });
4297
4471
  logEvent("finder.done", {
4298
- name: PLAY_NAME$8,
4472
+ name: PLAY_NAME$9,
4299
4473
  candidates: result.candidates,
4300
4474
  enqueued: result.enqueued,
4301
4475
  dropped_icp: result.droppedIcp,
@@ -4309,7 +4483,7 @@ async function runShowHnFinder(opts) {
4309
4483
  }
4310
4484
  //#endregion
4311
4485
  //#region ../../packages/find/src/post-funding.ts
4312
- const PLAY_NAME$7 = "post-funding";
4486
+ const PLAY_NAME$8 = "post-funding";
4313
4487
  const SOURCE$5 = "find:post-funding";
4314
4488
  const ROUND_MAP = {
4315
4489
  "Pre-Seed": "Pre-Seed",
@@ -4350,7 +4524,7 @@ async function runPostFundingFinder(opts) {
4350
4524
  result.halted = `max-cost cap (${opts.maxCostUsd})`;
4351
4525
  break;
4352
4526
  }
4353
- if (ledger.isQueueDuplicate(PLAY_NAME$7, url)) {
4527
+ if (ledger.isQueueDuplicate(PLAY_NAME$8, url)) {
4354
4528
  result.droppedDuplicate++;
4355
4529
  continue;
4356
4530
  }
@@ -4360,7 +4534,7 @@ async function runPostFundingFinder(opts) {
4360
4534
  }
4361
4535
  let extract;
4362
4536
  try {
4363
- const read = await webRead({ url }, { playName: PLAY_NAME$7 });
4537
+ const read = await webRead({ url }, { playName: PLAY_NAME$8 });
4364
4538
  result.costUsd += read.result.cost ?? 0;
4365
4539
  extract = parsePostFundingExtract((await complete({
4366
4540
  messages: [{
@@ -4396,7 +4570,7 @@ async function runPostFundingFinder(opts) {
4396
4570
  if (!filter.match) {
4397
4571
  result.droppedIcp++;
4398
4572
  ledger.enqueueTarget({
4399
- playName: PLAY_NAME$7,
4573
+ playName: PLAY_NAME$8,
4400
4574
  payload: {
4401
4575
  company: extract.company,
4402
4576
  round: extract.round,
@@ -4418,7 +4592,7 @@ async function runPostFundingFinder(opts) {
4418
4592
  if (!skip.ok) {
4419
4593
  result.droppedEnrichment++;
4420
4594
  logEvent("finder.skipped_findemail", {
4421
- name: PLAY_NAME$7,
4595
+ name: PLAY_NAME$8,
4422
4596
  reason: skip.reason
4423
4597
  }, "info");
4424
4598
  continue;
@@ -4426,7 +4600,7 @@ async function runPostFundingFinder(opts) {
4426
4600
  const found = await findEmail({
4427
4601
  fullName: extract.founderName,
4428
4602
  companyDomain: extract.companyDomain
4429
- }, { playName: PLAY_NAME$7 });
4603
+ }, { playName: PLAY_NAME$8 });
4430
4604
  result.costUsd += found.result.cost ?? 0;
4431
4605
  if (!found.result.found || !found.result.email) {
4432
4606
  result.droppedEnrichment++;
@@ -4434,21 +4608,21 @@ async function runPostFundingFinder(opts) {
4434
4608
  }
4435
4609
  const email = found.result.email;
4436
4610
  if (isDuplicate({
4437
- playName: PLAY_NAME$7,
4611
+ playName: PLAY_NAME$8,
4438
4612
  dedupeKey: url,
4439
4613
  prospectEmail: email
4440
4614
  })) {
4441
4615
  result.droppedDuplicate++;
4442
4616
  continue;
4443
4617
  }
4444
- const verified = await verifyEmail({ email }, { playName: PLAY_NAME$7 });
4618
+ const verified = await verifyEmail({ email }, { playName: PLAY_NAME$8 });
4445
4619
  result.costUsd += verified.result.cost ?? 0;
4446
4620
  if (!verified.result.deliverable) {
4447
4621
  result.droppedEnrichment++;
4448
4622
  continue;
4449
4623
  }
4450
4624
  const enr = await enrichVerifiedContact(email, {
4451
- playName: PLAY_NAME$7,
4625
+ playName: PLAY_NAME$8,
4452
4626
  errKindPrefix: "post-funding"
4453
4627
  });
4454
4628
  result.costUsd += enr.costUsd;
@@ -4475,7 +4649,7 @@ async function runPostFundingFinder(opts) {
4475
4649
  ...phone ? { phone } : {}
4476
4650
  };
4477
4651
  if (ledger.enqueueTarget({
4478
- playName: PLAY_NAME$7,
4652
+ playName: PLAY_NAME$8,
4479
4653
  payload: target,
4480
4654
  dedupeKey: url,
4481
4655
  source: SOURCE$5,
@@ -4551,7 +4725,7 @@ async function harvestAutoUrls(args) {
4551
4725
  const search = await webSearch({
4552
4726
  query,
4553
4727
  maxResults: Math.min(20, Math.max(5, args.limit - urls.length))
4554
- }, { playName: PLAY_NAME$7 });
4728
+ }, { playName: PLAY_NAME$8 });
4555
4729
  costUsd += search.result.cost ?? 0;
4556
4730
  for (const hit of search.result.results ?? []) {
4557
4731
  if (urls.length >= args.limit) break;
@@ -4664,7 +4838,7 @@ function deriveIndustryHint(icp) {
4664
4838
  * Less reliable than the yc-oss adapter (search recall depends on the
4665
4839
  * accelerator's web presence) but works without per-accelerator scrapers.
4666
4840
  */
4667
- const PLAY_NAME$6 = "accelerator-batch";
4841
+ const PLAY_NAME$7 = "accelerator-batch";
4668
4842
  /**
4669
4843
  * Build the three search queries from a human-readable cohort label.
4670
4844
  * Founders supply `cohortLabel: "YC W26"` or `"Techstars Toronto Spring 2025"`
@@ -4733,7 +4907,7 @@ async function fetchAcceleratorSearch(_cohort, cohortLabel, limit) {
4733
4907
  const search = await webSearch({
4734
4908
  query,
4735
4909
  maxResults: Math.min(15, limit)
4736
- }, { playName: PLAY_NAME$6 });
4910
+ }, { playName: PLAY_NAME$7 });
4737
4911
  costUsd += search.result.cost ?? 0;
4738
4912
  for (const raw of search.result.results ?? []) {
4739
4913
  if (!raw.url || seen.has(raw.url)) continue;
@@ -4762,7 +4936,7 @@ async function fetchAcceleratorSearch(_cohort, cohortLabel, limit) {
4762
4936
  for (const hit of hits.slice(0, limit)) {
4763
4937
  let extract = null;
4764
4938
  try {
4765
- const read = await webRead({ url: hit.url }, { playName: PLAY_NAME$6 });
4939
+ const read = await webRead({ url: hit.url }, { playName: PLAY_NAME$7 });
4766
4940
  costUsd += read.result.cost ?? 0;
4767
4941
  extract = parseAcceleratorLaunchExtract((await complete({
4768
4942
  messages: [{
@@ -5034,7 +5208,7 @@ function mapYcOssCompany(c) {
5034
5208
  * verifyEmail → enqueue, all under `parallelMap` (concurrency 3, mirrors
5035
5209
  * github-topics).
5036
5210
  */
5037
- const PLAY_NAME$5 = "accelerator-batch";
5211
+ const PLAY_NAME$6 = "accelerator-batch";
5038
5212
  /**
5039
5213
  * Normalize the legacy single-cohort opts shape into the new multi-cohort
5040
5214
  * list. Old trigger rows with `{cohort, cohortLabel}` keep working — they
@@ -5216,7 +5390,7 @@ async function runAcceleratorBatchFinder(opts) {
5216
5390
  return;
5217
5391
  }
5218
5392
  const dedupeKey = makeDedupeKey(record, record.cohort);
5219
- if (ledger.isQueueDuplicate(PLAY_NAME$5, dedupeKey)) {
5393
+ if (ledger.isQueueDuplicate(PLAY_NAME$6, dedupeKey)) {
5220
5394
  result.droppedDuplicate++;
5221
5395
  return;
5222
5396
  }
@@ -5235,7 +5409,7 @@ async function runAcceleratorBatchFinder(opts) {
5235
5409
  if (!filter.match) {
5236
5410
  result.droppedIcp++;
5237
5411
  ledger.enqueueTarget({
5238
- playName: PLAY_NAME$5,
5412
+ playName: PLAY_NAME$6,
5239
5413
  payload: rejectionPayload(record, record.cohort),
5240
5414
  dedupeKey,
5241
5415
  source,
@@ -5270,7 +5444,7 @@ async function runAcceleratorBatchFinder(opts) {
5270
5444
  if (!skip.ok) {
5271
5445
  result.droppedEnrichment++;
5272
5446
  logEvent("finder.skipped_findemail", {
5273
- name: PLAY_NAME$5,
5447
+ name: PLAY_NAME$6,
5274
5448
  reason: skip.reason
5275
5449
  }, "info");
5276
5450
  return;
@@ -5278,7 +5452,7 @@ async function runAcceleratorBatchFinder(opts) {
5278
5452
  const found = await findEmail({
5279
5453
  fullName: founderName,
5280
5454
  companyDomain: domain
5281
- }, { playName: PLAY_NAME$5 });
5455
+ }, { playName: PLAY_NAME$6 });
5282
5456
  result.costUsd += found.result.cost ?? 0;
5283
5457
  if (!found.result.found || !found.result.email) {
5284
5458
  result.droppedEnrichment++;
@@ -5287,21 +5461,21 @@ async function runAcceleratorBatchFinder(opts) {
5287
5461
  const email = found.result.email;
5288
5462
  const fullName = found.result.full_name?.trim() || founderName;
5289
5463
  if (isDuplicate({
5290
- playName: PLAY_NAME$5,
5464
+ playName: PLAY_NAME$6,
5291
5465
  dedupeKey,
5292
5466
  prospectEmail: email
5293
5467
  })) {
5294
5468
  result.droppedDuplicate++;
5295
5469
  return;
5296
5470
  }
5297
- const verified = await verifyEmail({ email }, { playName: PLAY_NAME$5 });
5471
+ const verified = await verifyEmail({ email }, { playName: PLAY_NAME$6 });
5298
5472
  result.costUsd += verified.result.cost ?? 0;
5299
5473
  if (!verified.result.deliverable) {
5300
5474
  result.droppedEnrichment++;
5301
5475
  return;
5302
5476
  }
5303
5477
  const enr = await enrichVerifiedContact(email, {
5304
- playName: PLAY_NAME$5,
5478
+ playName: PLAY_NAME$6,
5305
5479
  errKindPrefix: "accelerator-batch"
5306
5480
  });
5307
5481
  result.costUsd += enr.costUsd;
@@ -5328,7 +5502,7 @@ async function runAcceleratorBatchFinder(opts) {
5328
5502
  ...opts.freeForCohortOffer ? { freeForCohortOffer: opts.freeForCohortOffer } : {}
5329
5503
  };
5330
5504
  if (ledger.enqueueTarget({
5331
- playName: PLAY_NAME$5,
5505
+ playName: PLAY_NAME$6,
5332
5506
  payload: target,
5333
5507
  dedupeKey,
5334
5508
  source,
@@ -5386,7 +5560,7 @@ async function resolveFounderName(record) {
5386
5560
  };
5387
5561
  let costUsd = 0;
5388
5562
  try {
5389
- const read = await webRead({ url }, { playName: PLAY_NAME$5 });
5563
+ const read = await webRead({ url }, { playName: PLAY_NAME$6 });
5390
5564
  costUsd += read.result.cost ?? 0;
5391
5565
  const extract = parseAcceleratorLaunchExtract((await complete({
5392
5566
  messages: [{
@@ -5426,7 +5600,7 @@ async function resolveFounderName(record) {
5426
5600
  }
5427
5601
  //#endregion
5428
5602
  //#region ../../packages/find/src/job-change.ts
5429
- const PLAY_NAME$4 = "job-change";
5603
+ const PLAY_NAME$5 = "job-change";
5430
5604
  const SOURCE$4 = "find:job-change";
5431
5605
  const DEFAULT_PERSONAS = [
5432
5606
  "VP Engineering",
@@ -5460,7 +5634,7 @@ async function runJobChangeFinder(opts) {
5460
5634
  const search = await webSearch({
5461
5635
  query,
5462
5636
  maxResults: Math.min(15, limit)
5463
- }, { playName: PLAY_NAME$4 });
5637
+ }, { playName: PLAY_NAME$5 });
5464
5638
  result.costUsd += search.result.cost ?? 0;
5465
5639
  for (const hit of search.result.results ?? []) {
5466
5640
  if (!hit.url || seenUrls.has(hit.url)) continue;
@@ -5486,7 +5660,7 @@ async function runJobChangeFinder(opts) {
5486
5660
  result.halted = `max-cost cap (${opts.maxCostUsd})`;
5487
5661
  break;
5488
5662
  }
5489
- if (ledger.isQueueDuplicate(PLAY_NAME$4, hit.url)) {
5663
+ if (ledger.isQueueDuplicate(PLAY_NAME$5, hit.url)) {
5490
5664
  result.droppedDuplicate++;
5491
5665
  continue;
5492
5666
  }
@@ -5505,7 +5679,7 @@ async function runJobChangeFinder(opts) {
5505
5679
  if (!filter.match) {
5506
5680
  result.droppedIcp++;
5507
5681
  ledger.enqueueTarget({
5508
- playName: PLAY_NAME$4,
5682
+ playName: PLAY_NAME$5,
5509
5683
  payload: {
5510
5684
  title: hit.title,
5511
5685
  url: hit.url,
@@ -5559,7 +5733,7 @@ async function runJobChangeFinder(opts) {
5559
5733
  if (!skip.ok) {
5560
5734
  result.droppedEnrichment++;
5561
5735
  logEvent("finder.skipped_findemail", {
5562
- name: PLAY_NAME$4,
5736
+ name: PLAY_NAME$5,
5563
5737
  reason: skip.reason
5564
5738
  }, "info");
5565
5739
  continue;
@@ -5567,7 +5741,7 @@ async function runJobChangeFinder(opts) {
5567
5741
  const found = await findEmail({
5568
5742
  fullName: extract.fullName,
5569
5743
  companyDomain: domain
5570
- }, { playName: PLAY_NAME$4 });
5744
+ }, { playName: PLAY_NAME$5 });
5571
5745
  result.costUsd += found.result.cost ?? 0;
5572
5746
  if (!found.result.found || !found.result.email) {
5573
5747
  result.droppedEnrichment++;
@@ -5575,21 +5749,21 @@ async function runJobChangeFinder(opts) {
5575
5749
  }
5576
5750
  const email = found.result.email;
5577
5751
  if (isDuplicate({
5578
- playName: PLAY_NAME$4,
5752
+ playName: PLAY_NAME$5,
5579
5753
  dedupeKey: hit.url,
5580
5754
  prospectEmail: email
5581
5755
  })) {
5582
5756
  result.droppedDuplicate++;
5583
5757
  continue;
5584
5758
  }
5585
- const verified = await verifyEmail({ email }, { playName: PLAY_NAME$4 });
5759
+ const verified = await verifyEmail({ email }, { playName: PLAY_NAME$5 });
5586
5760
  result.costUsd += verified.result.cost ?? 0;
5587
5761
  if (!verified.result.deliverable) {
5588
5762
  result.droppedEnrichment++;
5589
5763
  continue;
5590
5764
  }
5591
5765
  const enr = await enrichVerifiedContact(email, {
5592
- playName: PLAY_NAME$4,
5766
+ playName: PLAY_NAME$5,
5593
5767
  errKindPrefix: "job-change"
5594
5768
  });
5595
5769
  result.costUsd += enr.costUsd;
@@ -5615,7 +5789,7 @@ async function runJobChangeFinder(opts) {
5615
5789
  ...phone ? { phone } : {}
5616
5790
  };
5617
5791
  if (ledger.enqueueTarget({
5618
- playName: PLAY_NAME$4,
5792
+ playName: PLAY_NAME$5,
5619
5793
  payload: target,
5620
5794
  dedupeKey: hit.url,
5621
5795
  source: SOURCE$4,
@@ -5640,7 +5814,7 @@ function parseJobChangeExtract(raw) {
5640
5814
  }
5641
5815
  //#endregion
5642
5816
  //#region ../../packages/find/src/hiring-signal.ts
5643
- const PLAY_NAME$3 = "hiring-signal";
5817
+ const PLAY_NAME$4 = "hiring-signal";
5644
5818
  const SOURCE$3 = "find:hiring-signal";
5645
5819
  const ATS_DOMAIN_HINTS = [
5646
5820
  "boards.greenhouse.io",
@@ -5686,7 +5860,7 @@ async function runHiringSignalFinder(opts) {
5686
5860
  const search = await webSearch({
5687
5861
  query,
5688
5862
  maxResults: Math.min(15, limit)
5689
- }, { playName: PLAY_NAME$3 });
5863
+ }, { playName: PLAY_NAME$4 });
5690
5864
  result.costUsd += search.result.cost ?? 0;
5691
5865
  for (const hit of search.result.results ?? []) {
5692
5866
  if (!hit.url || seen.has(hit.url) || !isAtsUrl(hit.url)) continue;
@@ -5712,7 +5886,7 @@ async function runHiringSignalFinder(opts) {
5712
5886
  result.halted = `max-cost cap (${opts.maxCostUsd})`;
5713
5887
  break;
5714
5888
  }
5715
- if (ledger.isQueueDuplicate(PLAY_NAME$3, hit.url)) {
5889
+ if (ledger.isQueueDuplicate(PLAY_NAME$4, hit.url)) {
5716
5890
  result.droppedDuplicate++;
5717
5891
  continue;
5718
5892
  }
@@ -5731,7 +5905,7 @@ async function runHiringSignalFinder(opts) {
5731
5905
  if (!filter.match) {
5732
5906
  result.droppedIcp++;
5733
5907
  ledger.enqueueTarget({
5734
- playName: PLAY_NAME$3,
5908
+ playName: PLAY_NAME$4,
5735
5909
  payload: {
5736
5910
  title: hit.title,
5737
5911
  url: hit.url,
@@ -5746,7 +5920,7 @@ async function runHiringSignalFinder(opts) {
5746
5920
  }
5747
5921
  let extract;
5748
5922
  try {
5749
- const read = await webRead({ url: hit.url }, { playName: PLAY_NAME$3 });
5923
+ const read = await webRead({ url: hit.url }, { playName: PLAY_NAME$4 });
5750
5924
  result.costUsd += read.result.cost ?? 0;
5751
5925
  extract = parseHiringSignalExtract((await complete({
5752
5926
  messages: [{
@@ -5792,7 +5966,7 @@ async function runHiringSignalFinder(opts) {
5792
5966
  if (!skip.ok) {
5793
5967
  result.droppedEnrichment++;
5794
5968
  logEvent("finder.skipped_findemail", {
5795
- name: PLAY_NAME$3,
5969
+ name: PLAY_NAME$4,
5796
5970
  reason: skip.reason
5797
5971
  }, "info");
5798
5972
  continue;
@@ -5800,7 +5974,7 @@ async function runHiringSignalFinder(opts) {
5800
5974
  const found = await findEmail(managerName ? {
5801
5975
  fullName: managerName,
5802
5976
  companyDomain: domain
5803
- } : { companyDomain: domain }, { playName: PLAY_NAME$3 });
5977
+ } : { companyDomain: domain }, { playName: PLAY_NAME$4 });
5804
5978
  result.costUsd += found.result.cost ?? 0;
5805
5979
  if (!found.result.found || !found.result.email) {
5806
5980
  result.droppedEnrichment++;
@@ -5808,14 +5982,14 @@ async function runHiringSignalFinder(opts) {
5808
5982
  }
5809
5983
  const email = found.result.email;
5810
5984
  if (isDuplicate({
5811
- playName: PLAY_NAME$3,
5985
+ playName: PLAY_NAME$4,
5812
5986
  dedupeKey: hit.url,
5813
5987
  prospectEmail: email
5814
5988
  })) {
5815
5989
  result.droppedDuplicate++;
5816
5990
  continue;
5817
5991
  }
5818
- const verified = await verifyEmail({ email }, { playName: PLAY_NAME$3 });
5992
+ const verified = await verifyEmail({ email }, { playName: PLAY_NAME$4 });
5819
5993
  result.costUsd += verified.result.cost ?? 0;
5820
5994
  if (!verified.result.deliverable) {
5821
5995
  result.droppedEnrichment++;
@@ -5823,7 +5997,7 @@ async function runHiringSignalFinder(opts) {
5823
5997
  }
5824
5998
  const recipientName = extract.hiringManagerName ?? found.result.full_name ?? null;
5825
5999
  const enr = await enrichVerifiedContact(email, {
5826
- playName: PLAY_NAME$3,
6000
+ playName: PLAY_NAME$4,
5827
6001
  errKindPrefix: "hiring-signal"
5828
6002
  });
5829
6003
  result.costUsd += enr.costUsd;
@@ -5849,7 +6023,7 @@ async function runHiringSignalFinder(opts) {
5849
6023
  ...phone ? { phone } : {}
5850
6024
  };
5851
6025
  if (ledger.enqueueTarget({
5852
- playName: PLAY_NAME$3,
6026
+ playName: PLAY_NAME$4,
5853
6027
  payload: target,
5854
6028
  dedupeKey: hit.url,
5855
6029
  source: SOURCE$3,
@@ -5902,7 +6076,7 @@ async function resolveCorporateDomain(company, jobUrl, cache) {
5902
6076
  const search = await webSearch({
5903
6077
  query: `"${company}" official site`,
5904
6078
  maxResults: 5
5905
- }, { playName: PLAY_NAME$3 });
6079
+ }, { playName: PLAY_NAME$4 });
5906
6080
  costUsd += search.result.cost ?? 0;
5907
6081
  for (const hit of search.result.results ?? []) {
5908
6082
  const host = pickCorporateHost(hit.url);
@@ -5954,7 +6128,7 @@ function parseHiringSignalExtract(raw) {
5954
6128
  }
5955
6129
  //#endregion
5956
6130
  //#region ../../packages/find/src/podcast-guest.ts
5957
- const PLAY_NAME$2 = "podcast-guest";
6131
+ const PLAY_NAME$3 = "podcast-guest";
5958
6132
  const SOURCE$2 = "find:podcast-guest";
5959
6133
  const DEFAULT_PODCASTS = [
5960
6134
  "Latent Space",
@@ -5989,7 +6163,7 @@ async function runPodcastGuestFinder(opts) {
5989
6163
  const search = await webSearch({
5990
6164
  query,
5991
6165
  maxResults: Math.min(15, limit)
5992
- }, { playName: PLAY_NAME$2 });
6166
+ }, { playName: PLAY_NAME$3 });
5993
6167
  result.costUsd += search.result.cost ?? 0;
5994
6168
  for (const hit of search.result.results ?? []) {
5995
6169
  if (!hit.url || seen.has(hit.url)) continue;
@@ -6015,7 +6189,7 @@ async function runPodcastGuestFinder(opts) {
6015
6189
  result.halted = `max-cost cap (${opts.maxCostUsd})`;
6016
6190
  break;
6017
6191
  }
6018
- if (ledger.isQueueDuplicate(PLAY_NAME$2, hit.url)) {
6192
+ if (ledger.isQueueDuplicate(PLAY_NAME$3, hit.url)) {
6019
6193
  result.droppedDuplicate++;
6020
6194
  continue;
6021
6195
  }
@@ -6034,7 +6208,7 @@ async function runPodcastGuestFinder(opts) {
6034
6208
  if (!filter.match) {
6035
6209
  result.droppedIcp++;
6036
6210
  ledger.enqueueTarget({
6037
- playName: PLAY_NAME$2,
6211
+ playName: PLAY_NAME$3,
6038
6212
  payload: {
6039
6213
  title: hit.title,
6040
6214
  url: hit.url,
@@ -6055,7 +6229,7 @@ async function runPodcastGuestFinder(opts) {
6055
6229
  description: hit.description
6056
6230
  };
6057
6231
  if (!opts.skipRead) {
6058
- const read = await webRead({ url: hit.url }, { playName: PLAY_NAME$2 });
6232
+ const read = await webRead({ url: hit.url }, { playName: PLAY_NAME$3 });
6059
6233
  result.costUsd += read.result.cost ?? 0;
6060
6234
  payload = {
6061
6235
  ...payload,
@@ -6092,7 +6266,7 @@ async function runPodcastGuestFinder(opts) {
6092
6266
  if (!skip.ok) {
6093
6267
  result.droppedEnrichment++;
6094
6268
  logEvent("finder.skipped_findemail", {
6095
- name: PLAY_NAME$2,
6269
+ name: PLAY_NAME$3,
6096
6270
  reason: skip.reason
6097
6271
  }, "info");
6098
6272
  continue;
@@ -6100,7 +6274,7 @@ async function runPodcastGuestFinder(opts) {
6100
6274
  const found = await findEmail({
6101
6275
  fullName: extract.guestName,
6102
6276
  companyDomain: extract.guestCompanyDomain
6103
- }, { playName: PLAY_NAME$2 });
6277
+ }, { playName: PLAY_NAME$3 });
6104
6278
  result.costUsd += found.result.cost ?? 0;
6105
6279
  if (!found.result.found || !found.result.email) {
6106
6280
  result.droppedEnrichment++;
@@ -6108,21 +6282,21 @@ async function runPodcastGuestFinder(opts) {
6108
6282
  }
6109
6283
  const email = found.result.email;
6110
6284
  if (isDuplicate({
6111
- playName: PLAY_NAME$2,
6285
+ playName: PLAY_NAME$3,
6112
6286
  dedupeKey: hit.url,
6113
6287
  prospectEmail: email
6114
6288
  })) {
6115
6289
  result.droppedDuplicate++;
6116
6290
  continue;
6117
6291
  }
6118
- const verified = await verifyEmail({ email }, { playName: PLAY_NAME$2 });
6292
+ const verified = await verifyEmail({ email }, { playName: PLAY_NAME$3 });
6119
6293
  result.costUsd += verified.result.cost ?? 0;
6120
6294
  if (!verified.result.deliverable) {
6121
6295
  result.droppedEnrichment++;
6122
6296
  continue;
6123
6297
  }
6124
6298
  const enr = await enrichVerifiedContact(email, {
6125
- playName: PLAY_NAME$2,
6299
+ playName: PLAY_NAME$3,
6126
6300
  errKindPrefix: "podcast-guest"
6127
6301
  });
6128
6302
  result.costUsd += enr.costUsd;
@@ -6148,7 +6322,7 @@ async function runPodcastGuestFinder(opts) {
6148
6322
  ...phone ? { phone } : {}
6149
6323
  };
6150
6324
  if (ledger.enqueueTarget({
6151
- playName: PLAY_NAME$2,
6325
+ playName: PLAY_NAME$3,
6152
6326
  payload: target,
6153
6327
  dedupeKey: hit.url,
6154
6328
  source: SOURCE$2,
@@ -6175,7 +6349,7 @@ function parsePodcastGuestExtract(raw) {
6175
6349
  }
6176
6350
  //#endregion
6177
6351
  //#region ../../packages/find/src/breakup-revive.ts
6178
- const PLAY_NAME$1 = "breakup-revive";
6352
+ const PLAY_NAME$2 = "breakup-revive";
6179
6353
  const SOURCE$1 = "find:breakup-revive";
6180
6354
  /**
6181
6355
  * Scan the local ledger for cold prospects (no activity in the last
@@ -6211,7 +6385,7 @@ function runBreakupReviveFinder(opts) {
6211
6385
  }
6212
6386
  const dedupeKey = `prospect:${p.id}`;
6213
6387
  if (isDuplicate({
6214
- playName: PLAY_NAME$1,
6388
+ playName: PLAY_NAME$2,
6215
6389
  dedupeKey,
6216
6390
  prospectEmail: void 0
6217
6391
  })) {
@@ -6233,7 +6407,7 @@ function runBreakupReviveFinder(opts) {
6233
6407
  continue;
6234
6408
  }
6235
6409
  const id = ledger.enqueueTarget({
6236
- playName: PLAY_NAME$1,
6410
+ playName: PLAY_NAME$2,
6237
6411
  payload: target,
6238
6412
  dedupeKey,
6239
6413
  source: SOURCE$1,
@@ -6669,7 +6843,7 @@ function parseEnvKeys(content) {
6669
6843
  * directly from package.json / pyproject.toml / requirements.txt /
6670
6844
  * .env.example via the GitHub Contents API. Free, fast, deterministic.
6671
6845
  */
6672
- const PLAY_NAME = "stack-consolidation";
6846
+ const PLAY_NAME$1 = "stack-consolidation";
6673
6847
  /**
6674
6848
  * Process a single candidate through the full pipeline. Mutates ctx.result.
6675
6849
  * Never throws — internal exceptions become droppedEnrichment increments via
@@ -6711,7 +6885,7 @@ async function processRepoCandidate(hit, ctx) {
6711
6885
  if (!snippetFilter.match) {
6712
6886
  result.droppedIcp++;
6713
6887
  ledger.enqueueTarget({
6714
- playName: PLAY_NAME,
6888
+ playName: PLAY_NAME$1,
6715
6889
  payload: {
6716
6890
  repoUrl: hit.url,
6717
6891
  title: hit.title,
@@ -6859,7 +7033,7 @@ async function processRepoCandidate(hit, ctx) {
6859
7033
  async function resolveContact(args) {
6860
7034
  const { extract, repoUrl, ghUser, accumCost, useDeepResearch } = args;
6861
7035
  const errKindPrefix = args.errKindPrefix ?? "repo-pipeline";
6862
- const playName = args.playName ?? PLAY_NAME;
7036
+ const playName = args.playName ?? PLAY_NAME$1;
6863
7037
  const extractDomain = extract.companyDomain ?? extract.personalDomain ?? null;
6864
7038
  let discoveredLinkedinUrl = null;
6865
7039
  if (extractDomain) {
@@ -7191,6 +7365,323 @@ async function runGitHubTopicsFinder(opts) {
7191
7365
  return result;
7192
7366
  }
7193
7367
  //#endregion
7368
+ //#region ../../packages/find/src/_stargazers.ts
7369
+ /** Parse one `application/vnd.github.star+json` stargazer row. */
7370
+ function parseStarRow(raw) {
7371
+ if (!raw || typeof raw !== "object") return null;
7372
+ const r = raw;
7373
+ const starredAt = typeof r["starred_at"] === "string" ? r["starred_at"] : null;
7374
+ const user = r["user"];
7375
+ if (!starredAt || !user || typeof user !== "object") return null;
7376
+ const u = user;
7377
+ const login = typeof u["login"] === "string" ? u["login"] : null;
7378
+ if (!login) return null;
7379
+ return {
7380
+ login,
7381
+ userUrl: (typeof u["html_url"] === "string" ? u["html_url"] : null) ?? `https://github.com/${login}`,
7382
+ starredAt
7383
+ };
7384
+ }
7385
+ /** Read the `page=N>; rel="last"` page number from a GitHub `Link` header. */
7386
+ function parseLastPage(link) {
7387
+ if (!link) return 1;
7388
+ const m = link.match(/[?&]page=(\d+)>;\s*rel="last"/);
7389
+ return m ? Math.max(1, Number.parseInt(m[1] ?? "1", 10)) : 1;
7390
+ }
7391
+ /**
7392
+ * Recent stargazers of a public repo. GitHub returns stargazers oldest-first,
7393
+ * so the newest stars live on the LAST page — we read the `Link: rel="last"`
7394
+ * page number, then page backward (newest → older), collecting stars with
7395
+ * `starredAt >= sinceIso` and stopping as soon as a page has none fresh (every
7396
+ * earlier page is older still) or `maxPages` is hit. Fault-tolerant like
7397
+ * `searchTopicRepos`: returns `{ stargazers: [], error }` on any non-2xx /
7398
+ * network / parse failure so the caller logs + continues to the next repo.
7399
+ *
7400
+ * Requires `GITHUB_TOKEN` for any real volume (5,000 req/hr core); without it
7401
+ * GitHub rate-limits hard at 60/hr.
7402
+ */
7403
+ async function recentStargazers(repo, opts) {
7404
+ const maxPages = Math.max(1, opts.maxPages ?? 20);
7405
+ const headers = {
7406
+ ...githubHeaders(),
7407
+ Accept: "application/vnd.github.star+json"
7408
+ };
7409
+ const base = `https://api.github.com/repos/${repo}/stargazers?per_page=100`;
7410
+ try {
7411
+ const firstRes = await fetch(`${base}&page=1`, { headers });
7412
+ if (!firstRes.ok) {
7413
+ logEvent("github.stargazers", {
7414
+ repo,
7415
+ ok: false,
7416
+ status: firstRes.status
7417
+ }, "warn");
7418
+ return {
7419
+ stargazers: [],
7420
+ error: `status ${firstRes.status}`
7421
+ };
7422
+ }
7423
+ const lastPage = parseLastPage(firstRes.headers.get("link"));
7424
+ const page1Rows = await firstRes.json() ?? [];
7425
+ const out = [];
7426
+ let pagesFetched = 1;
7427
+ for (let page = lastPage; page >= 1 && pagesFetched <= maxPages; page--) {
7428
+ let rows;
7429
+ if (page === 1) rows = page1Rows;
7430
+ else {
7431
+ const res = await fetch(`${base}&page=${page}`, { headers });
7432
+ pagesFetched++;
7433
+ if (!res.ok) break;
7434
+ rows = await res.json() ?? [];
7435
+ }
7436
+ const parsed = rows.map(parseStarRow).filter((s) => s !== null && s.starredAt >= opts.sinceIso);
7437
+ out.push(...parsed);
7438
+ if (parsed.length === 0) break;
7439
+ }
7440
+ const seen = /* @__PURE__ */ new Set();
7441
+ const stargazers = out.filter((s) => {
7442
+ const key = s.login.toLowerCase();
7443
+ if (seen.has(key)) return false;
7444
+ seen.add(key);
7445
+ return true;
7446
+ });
7447
+ logEvent("github.stargazers", {
7448
+ repo,
7449
+ ok: true,
7450
+ fresh: stargazers.length,
7451
+ last_page: lastPage,
7452
+ pages_fetched: pagesFetched
7453
+ });
7454
+ return { stargazers };
7455
+ } catch (err) {
7456
+ const message = (err.message ?? "").slice(0, 120);
7457
+ logEvent("github.stargazers", {
7458
+ repo,
7459
+ ok: false,
7460
+ message_120: message
7461
+ }, "warn");
7462
+ return {
7463
+ stargazers: [],
7464
+ error: message
7465
+ };
7466
+ }
7467
+ }
7468
+ //#endregion
7469
+ //#region ../../packages/find/src/github-stars.ts
7470
+ const PLAY_NAME = "github-stars";
7471
+ function deriveLabel(repo) {
7472
+ return repo.split("/")[1]?.trim() || repo;
7473
+ }
7474
+ function sourceFor(repo) {
7475
+ return `find:${PLAY_NAME}:${repo}`;
7476
+ }
7477
+ /**
7478
+ * github-stars finder: recent stargazers of watched repos → prospects, routed
7479
+ * by each repo's founder-tagged `rel`. A `competitor` repo's stargazers become
7480
+ * `competitor-switch` rows ("why teams switch from X"); an `adjacent` repo's
7481
+ * become `repo-interest` rows ("you're into X — my product helps"). Reuses the
7482
+ * shared finder stack (ICP filter, findEmail/verify/enrich, dedupe, prescreen)
7483
+ * and the soft-cap loop pattern from show-hn / accelerator-batch.
7484
+ */
7485
+ async function runGitHubStarsFinder(opts) {
7486
+ const limit = opts.limit ?? 25;
7487
+ const concurrency = Math.max(1, opts.concurrency ?? 3);
7488
+ const sinceDays = opts.sinceDays ?? 30;
7489
+ const sinceIso = (/* @__PURE__ */ new Date(Date.now() - sinceDays * 24 * 3600 * 1e3)).toISOString();
7490
+ const icp = resolveIcp(opts.icpOverride);
7491
+ const ledger = getLedger();
7492
+ const result = {
7493
+ source: `find:${PLAY_NAME}`,
7494
+ candidates: 0,
7495
+ droppedIcp: 0,
7496
+ droppedDuplicate: 0,
7497
+ droppedEnrichment: 0,
7498
+ enqueued: 0,
7499
+ costUsd: 0
7500
+ };
7501
+ logEvent("finder.start", {
7502
+ name: PLAY_NAME,
7503
+ repos: opts.repos.length,
7504
+ since_days: sinceDays,
7505
+ limit
7506
+ });
7507
+ const tagged = [];
7508
+ let anyRepoOk = false;
7509
+ for (const w of opts.repos) {
7510
+ const { stargazers, error } = await recentStargazers(w.repo, { sinceIso });
7511
+ if (!error) anyRepoOk = true;
7512
+ const label = w.label?.trim() || deriveLabel(w.repo);
7513
+ for (const s of stargazers) tagged.push({
7514
+ ...s,
7515
+ repo: w.repo,
7516
+ rel: w.rel,
7517
+ label
7518
+ });
7519
+ }
7520
+ const seen = /* @__PURE__ */ new Set();
7521
+ const candidates = tagged.filter((c) => {
7522
+ const k = c.login.toLowerCase();
7523
+ if (seen.has(k)) return false;
7524
+ seen.add(k);
7525
+ return true;
7526
+ });
7527
+ result.candidates = candidates.length;
7528
+ if (candidates.length === 0) {
7529
+ result.halted = anyRepoOk ? "no recent stargazers in the window" : "all repos failed (check GITHUB_TOKEN / repo names)";
7530
+ logEvent("finder.done", {
7531
+ name: PLAY_NAME,
7532
+ candidates: 0,
7533
+ halted: result.halted
7534
+ });
7535
+ return result;
7536
+ }
7537
+ let halted = false;
7538
+ await parallelMap(candidates, concurrency, async (c) => {
7539
+ if (halted) return;
7540
+ if (result.enqueued >= limit) {
7541
+ halted = true;
7542
+ return;
7543
+ }
7544
+ if (opts.maxCostUsd != null && result.costUsd >= opts.maxCostUsd) {
7545
+ result.halted = `max-cost cap (${opts.maxCostUsd})`;
7546
+ halted = true;
7547
+ return;
7548
+ }
7549
+ const playName = c.rel === "competitor" ? "competitor-switch" : "repo-interest";
7550
+ const dedupeKey = `${PLAY_NAME}:${c.repo}:${c.login}`;
7551
+ if (ledger.isQueueDuplicate(playName, dedupeKey)) {
7552
+ result.droppedDuplicate++;
7553
+ return;
7554
+ }
7555
+ const user = await fetchGitHubUser(c.login);
7556
+ if (!user) {
7557
+ result.droppedEnrichment++;
7558
+ return;
7559
+ }
7560
+ const fullName = user.name ?? c.login;
7561
+ const filter = await icpFilter({
7562
+ icp,
7563
+ candidate: {
7564
+ title: fullName,
7565
+ url: c.userUrl,
7566
+ summary: [user.company, `starred ${c.repo}`].filter(Boolean).join(" · ")
7567
+ }
7568
+ });
7569
+ if (!filter.match) {
7570
+ result.droppedIcp++;
7571
+ if (!opts.dryRun) ledger.enqueueTarget({
7572
+ playName,
7573
+ payload: {
7574
+ name: fullName,
7575
+ company: user.company ?? "",
7576
+ repo: c.repo
7577
+ },
7578
+ dedupeKey,
7579
+ source: sourceFor(c.repo),
7580
+ initialStatus: "rejected",
7581
+ notes: `auto: ICP — ${filter.reason}`
7582
+ });
7583
+ return;
7584
+ }
7585
+ if (opts.dryRun) {
7586
+ result.enqueued++;
7587
+ return;
7588
+ }
7589
+ let email = user.email;
7590
+ if (!email) {
7591
+ const domain = user.blogDomain;
7592
+ if (!domain) {
7593
+ result.droppedEnrichment++;
7594
+ return;
7595
+ }
7596
+ const skip = shouldSkipFindEmail({
7597
+ fullName,
7598
+ companyDomain: domain
7599
+ });
7600
+ if (!skip.ok) {
7601
+ result.droppedEnrichment++;
7602
+ logEvent("finder.skipped_findemail", {
7603
+ name: PLAY_NAME,
7604
+ reason: skip.reason
7605
+ }, "info");
7606
+ return;
7607
+ }
7608
+ const found = await findEmail({
7609
+ companyDomain: domain,
7610
+ fullName
7611
+ }, { playName: PLAY_NAME });
7612
+ result.costUsd += found.result.cost ?? 0;
7613
+ if (!found.result.found || !found.result.email) {
7614
+ result.droppedEnrichment++;
7615
+ return;
7616
+ }
7617
+ email = found.result.email;
7618
+ }
7619
+ const verified = await verifyEmail({ email }, { playName: PLAY_NAME });
7620
+ result.costUsd += verified.result.cost ?? 0;
7621
+ if (!verified.result.deliverable) {
7622
+ result.droppedEnrichment++;
7623
+ return;
7624
+ }
7625
+ if (isDuplicate({
7626
+ playName,
7627
+ dedupeKey,
7628
+ prospectEmail: email
7629
+ })) {
7630
+ result.droppedDuplicate++;
7631
+ return;
7632
+ }
7633
+ const enr = await enrichVerifiedContact(email, {
7634
+ playName: PLAY_NAME,
7635
+ errKindPrefix: PLAY_NAME
7636
+ });
7637
+ result.costUsd += enr.costUsd;
7638
+ const company = user.company?.trim() || "(unknown)";
7639
+ const repoUrl = `https://github.com/${c.repo}`;
7640
+ const contactExtras = {
7641
+ ...enr.linkedinUrl ? { linkedinUrl: enr.linkedinUrl } : {},
7642
+ ...enr.phone ? { phone: enr.phone } : {}
7643
+ };
7644
+ const target = c.rel === "competitor" ? {
7645
+ name: fullName,
7646
+ email,
7647
+ company,
7648
+ competitor: c.label,
7649
+ evidenceUrl: repoUrl,
7650
+ evidenceText: `Starred ${c.label}'s repo (${c.repo}) on ${c.starredAt.slice(0, 10)} — actively evaluating tools in this space.`,
7651
+ yourEdge: opts.yourEdge,
7652
+ ...contactExtras
7653
+ } : {
7654
+ name: fullName,
7655
+ email,
7656
+ company,
7657
+ repo: c.repo,
7658
+ repoLabel: c.label,
7659
+ yourEdge: opts.yourEdge,
7660
+ evidenceUrl: repoUrl,
7661
+ ...contactExtras
7662
+ };
7663
+ if (ledger.enqueueTarget({
7664
+ playName,
7665
+ payload: target,
7666
+ dedupeKey,
7667
+ source: sourceFor(c.repo),
7668
+ notes: filter.reason
7669
+ }) != null) result.enqueued++;
7670
+ else result.droppedDuplicate++;
7671
+ });
7672
+ logEvent("finder.done", {
7673
+ name: PLAY_NAME,
7674
+ candidates: result.candidates,
7675
+ enqueued: result.enqueued,
7676
+ dropped_icp: result.droppedIcp,
7677
+ dropped_dup: result.droppedDuplicate,
7678
+ dropped_enrich: result.droppedEnrichment,
7679
+ cost_usd: result.costUsd,
7680
+ halted: result.halted ?? null
7681
+ });
7682
+ return result;
7683
+ }
7684
+ //#endregion
7194
7685
  //#region ../../packages/find/src/registry.ts
7195
7686
  /** Evaluate a spec's readiness fn (defaulting to ready when absent). */
7196
7687
  function checkReadiness(spec, config) {
@@ -7487,6 +7978,60 @@ const TRIGGERS = [
7487
7978
  });
7488
7979
  }
7489
7980
  },
7981
+ {
7982
+ name: "github-stars",
7983
+ defaultIntervalMs: 12 * ONE_HOUR,
7984
+ enabledByDefault: false,
7985
+ defaultConfig: {
7986
+ repos: [],
7987
+ yourEdge: "",
7988
+ sinceDays: 30,
7989
+ concurrency: 3,
7990
+ limit: 25,
7991
+ maxCostUsd: 5
7992
+ },
7993
+ configBrief: "Finds recent stargazers of repos you watch and turns them into prospects. Config: `repos` (array of `{repo:\"owner/name\", rel:\"competitor\"|\"adjacent\", label?}` — tag a repo `competitor` to pitch a switch (→ competitor-switch) or `adjacent` for a complementary intro (→ repo-interest); `label` is the human name, else derived from the repo), `yourEdge` (one-line pitch fed to whichever play, REQUIRED), `sinceDays` (recency window, default 30), `limit`, `maxCostUsd`. Needs `GITHUB_TOKEN` for any volume. STRATEGIST DUTY: pick repos your buyers' current tools live in; tag the ones you replace as `competitor`, the rest `adjacent`.",
7994
+ readiness: (cfg) => {
7995
+ if ((Array.isArray(cfg["repos"]) ? cfg["repos"] : []).filter((r) => {
7996
+ if (!r || typeof r !== "object") return false;
7997
+ const e = r;
7998
+ return typeof e["repo"] === "string" && e["repo"].trim().length > 0 && (e["rel"] === "competitor" || e["rel"] === "adjacent");
7999
+ }).length === 0) return {
8000
+ ready: false,
8001
+ reason: "set `repos` (each `{repo, rel:'competitor'|'adjacent'}`)"
8002
+ };
8003
+ const edge = cfg["yourEdge"];
8004
+ if (typeof edge !== "string" || edge.trim().length === 0) return {
8005
+ ready: false,
8006
+ reason: "set `yourEdge` — your one-line pitch"
8007
+ };
8008
+ return { ready: true };
8009
+ },
8010
+ run: (cfg) => {
8011
+ return runGitHubStarsFinder({
8012
+ dryRun: false,
8013
+ repos: (Array.isArray(cfg["repos"]) ? cfg["repos"] : []).map((r) => {
8014
+ if (!r || typeof r !== "object") return null;
8015
+ const e = r;
8016
+ const repo = typeof e["repo"] === "string" ? e["repo"].trim() : "";
8017
+ const rel = e["rel"];
8018
+ if (repo.length === 0 || rel !== "competitor" && rel !== "adjacent") return null;
8019
+ const label = typeof e["label"] === "string" ? e["label"].trim() : "";
8020
+ const watch = {
8021
+ repo,
8022
+ rel
8023
+ };
8024
+ if (label) watch.label = label;
8025
+ return watch;
8026
+ }).filter((r) => r !== null),
8027
+ yourEdge: typeof cfg["yourEdge"] === "string" ? cfg["yourEdge"] : "",
8028
+ sinceDays: cfg["sinceDays"] ?? 30,
8029
+ concurrency: cfg["concurrency"] ?? 3,
8030
+ limit: cfg["limit"] ?? 25,
8031
+ maxCostUsd: cfg["maxCostUsd"] ?? 5
8032
+ });
8033
+ }
8034
+ },
7490
8035
  {
7491
8036
  name: "breakup-revive",
7492
8037
  defaultIntervalMs: 168 * ONE_HOUR,
@@ -8302,7 +8847,8 @@ const SUPPORTED = new Set([
8302
8847
  "hiring-signal",
8303
8848
  "podcast-guest",
8304
8849
  "competitor-switch",
8305
- "stack-consolidation"
8850
+ "stack-consolidation",
8851
+ "repo-interest"
8306
8852
  ]);
8307
8853
  async function runPlay(req, params) {
8308
8854
  const playName = params["playName"] ?? "";