salesprompter-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex/environments/environment.toml +19 -0
- package/README.md +54 -0
- package/data/deel-icp.json +17 -0
- package/data/deel-leads.json +77 -0
- package/data/enriched.json +106 -0
- package/data/icp.json +24 -0
- package/data/leads.json +62 -0
- package/data/scored.json +142 -0
- package/dist/cli.js +114 -0
- package/dist/domain.js +36 -0
- package/dist/engine.js +147 -0
- package/dist/io.js +17 -0
- package/dist/providers.js +1 -0
- package/dist/sample-data.js +34 -0
- package/dist-tests/src/cli.js +114 -0
- package/dist-tests/src/domain.js +36 -0
- package/dist-tests/src/engine.js +147 -0
- package/dist-tests/src/io.js +17 -0
- package/dist-tests/src/providers.js +1 -0
- package/dist-tests/src/sample-data.js +34 -0
- package/dist-tests/tests/cli.test.js +149 -0
- package/package.json +31 -0
- package/src/cli.ts +136 -0
- package/src/domain.ts +50 -0
- package/src/engine.ts +170 -0
- package/src/io.ts +21 -0
- package/src/providers.ts +22 -0
- package/src/sample-data.ts +37 -0
- package/tests/cli.test.ts +184 -0
- package/tsconfig.json +16 -0
- package/tsconfig.test.json +8 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import test from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { execFile } from "node:child_process";
|
|
7
|
+
import { promisify } from "node:util";
|
|
8
|
+
const execFileAsync = promisify(execFile);
|
|
9
|
+
const projectRoot = path.resolve(import.meta.dirname, "..", "..");
|
|
10
|
+
const cliPath = path.join(projectRoot, "dist", "cli.js");
|
|
11
|
+
async function runCli(args) {
|
|
12
|
+
const { stdout } = await execFileAsync("node", [cliPath, ...args], {
|
|
13
|
+
cwd: projectRoot
|
|
14
|
+
});
|
|
15
|
+
return JSON.parse(stdout);
|
|
16
|
+
}
|
|
17
|
+
test("CLI help renders the expected command surface", async () => {
|
|
18
|
+
const { stdout } = await execFileAsync("node", [cliPath, "--help"], {
|
|
19
|
+
cwd: projectRoot
|
|
20
|
+
});
|
|
21
|
+
assert.match(stdout, /icp:define/);
|
|
22
|
+
assert.match(stdout, /leads:generate/);
|
|
23
|
+
assert.match(stdout, /sync:outreach/);
|
|
24
|
+
});
|
|
25
|
+
test("CLI workflow generates, enriches, scores, and syncs leads", async () => {
|
|
26
|
+
const tempDir = await mkdtemp(path.join(os.tmpdir(), "salesprompter-cli-"));
|
|
27
|
+
try {
|
|
28
|
+
const icpPath = path.join(tempDir, "icp.json");
|
|
29
|
+
const leadsPath = path.join(tempDir, "leads.json");
|
|
30
|
+
const enrichedPath = path.join(tempDir, "enriched.json");
|
|
31
|
+
const scoredPath = path.join(tempDir, "scored.json");
|
|
32
|
+
const icpResult = await runCli([
|
|
33
|
+
"icp:define",
|
|
34
|
+
"--name",
|
|
35
|
+
"EU SaaS RevOps",
|
|
36
|
+
"--industries",
|
|
37
|
+
"Software,Financial Services",
|
|
38
|
+
"--company-sizes",
|
|
39
|
+
"50-199,200-499",
|
|
40
|
+
"--regions",
|
|
41
|
+
"Europe",
|
|
42
|
+
"--titles",
|
|
43
|
+
"Head of Revenue Operations,VP Sales",
|
|
44
|
+
"--required-signals",
|
|
45
|
+
"recent funding,growing outbound team",
|
|
46
|
+
"--out",
|
|
47
|
+
icpPath
|
|
48
|
+
]);
|
|
49
|
+
assert.equal(icpResult.status, "ok");
|
|
50
|
+
const generateResult = await runCli([
|
|
51
|
+
"leads:generate",
|
|
52
|
+
"--icp",
|
|
53
|
+
icpPath,
|
|
54
|
+
"--count",
|
|
55
|
+
"4",
|
|
56
|
+
"--out",
|
|
57
|
+
leadsPath
|
|
58
|
+
]);
|
|
59
|
+
assert.equal(generateResult.generated, 4);
|
|
60
|
+
const enrichResult = await runCli([
|
|
61
|
+
"leads:enrich",
|
|
62
|
+
"--in",
|
|
63
|
+
leadsPath,
|
|
64
|
+
"--out",
|
|
65
|
+
enrichedPath
|
|
66
|
+
]);
|
|
67
|
+
assert.equal(enrichResult.enriched, 4);
|
|
68
|
+
const scoreResult = await runCli([
|
|
69
|
+
"leads:score",
|
|
70
|
+
"--icp",
|
|
71
|
+
icpPath,
|
|
72
|
+
"--in",
|
|
73
|
+
enrichedPath,
|
|
74
|
+
"--out",
|
|
75
|
+
scoredPath
|
|
76
|
+
]);
|
|
77
|
+
assert.equal(scoreResult.scored, 4);
|
|
78
|
+
const crmSyncResult = await runCli([
|
|
79
|
+
"sync:crm",
|
|
80
|
+
"--target",
|
|
81
|
+
"hubspot",
|
|
82
|
+
"--in",
|
|
83
|
+
scoredPath
|
|
84
|
+
]);
|
|
85
|
+
assert.deepEqual(crmSyncResult, {
|
|
86
|
+
status: "ok",
|
|
87
|
+
target: "hubspot",
|
|
88
|
+
synced: 4,
|
|
89
|
+
dryRun: true
|
|
90
|
+
});
|
|
91
|
+
const scoredLeads = JSON.parse(await readFile(scoredPath, "utf8"));
|
|
92
|
+
assert.equal(scoredLeads.length, 4);
|
|
93
|
+
assert.ok(scoredLeads.every((lead) => lead.score >= 0 && lead.score <= 100));
|
|
94
|
+
assert.ok(scoredLeads.every((lead) => ["A", "B", "C", "D"].includes(lead.grade)));
|
|
95
|
+
assert.ok(scoredLeads.some((lead) => lead.rationale.length > 0));
|
|
96
|
+
assert.ok(scoredLeads.some((lead) => lead.crmFit === "high" || lead.outreachFit === "high"));
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
test("CLI can target a specific company domain like deel.com", async () => {
|
|
103
|
+
const tempDir = await mkdtemp(path.join(os.tmpdir(), "salesprompter-cli-target-"));
|
|
104
|
+
try {
|
|
105
|
+
const icpPath = path.join(tempDir, "icp.json");
|
|
106
|
+
const leadsPath = path.join(tempDir, "deel-leads.json");
|
|
107
|
+
await runCli([
|
|
108
|
+
"icp:define",
|
|
109
|
+
"--name",
|
|
110
|
+
"Global HR Tech",
|
|
111
|
+
"--industries",
|
|
112
|
+
"Software",
|
|
113
|
+
"--regions",
|
|
114
|
+
"Global",
|
|
115
|
+
"--titles",
|
|
116
|
+
"VP Sales,Head of Revenue Operations",
|
|
117
|
+
"--out",
|
|
118
|
+
icpPath
|
|
119
|
+
]);
|
|
120
|
+
const generateResult = await runCli([
|
|
121
|
+
"leads:generate",
|
|
122
|
+
"--icp",
|
|
123
|
+
icpPath,
|
|
124
|
+
"--count",
|
|
125
|
+
"3",
|
|
126
|
+
"--company-domain",
|
|
127
|
+
"deel.com",
|
|
128
|
+
"--company-name",
|
|
129
|
+
"Deel",
|
|
130
|
+
"--out",
|
|
131
|
+
leadsPath
|
|
132
|
+
]);
|
|
133
|
+
assert.deepEqual(generateResult, {
|
|
134
|
+
status: "ok",
|
|
135
|
+
generated: 3,
|
|
136
|
+
out: leadsPath,
|
|
137
|
+
target: "deel.com"
|
|
138
|
+
});
|
|
139
|
+
const leads = JSON.parse(await readFile(leadsPath, "utf8"));
|
|
140
|
+
assert.equal(leads.length, 3);
|
|
141
|
+
assert.ok(leads.every((lead) => lead.companyName === "Deel"));
|
|
142
|
+
assert.ok(leads.every((lead) => lead.domain === "deel.com"));
|
|
143
|
+
assert.ok(leads.every((lead) => lead.email.endsWith("@deel.com")));
|
|
144
|
+
assert.ok(leads.every((lead) => lead.source === "heuristic-target-account"));
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
148
|
+
}
|
|
149
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "salesprompter-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI for defining ICPs, generating leads, enriching them, scoring them, and syncing to GTM tools.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"salesprompter": "./dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc -p tsconfig.json",
|
|
11
|
+
"check": "tsc --noEmit -p tsconfig.json",
|
|
12
|
+
"start": "node ./dist/cli.js",
|
|
13
|
+
"test": "npm run build && tsc -p tsconfig.test.json && node --test dist-tests/tests/**/*.test.js"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"sales",
|
|
17
|
+
"cli",
|
|
18
|
+
"lead-generation",
|
|
19
|
+
"crm",
|
|
20
|
+
"outreach"
|
|
21
|
+
],
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"commander": "^14.0.1",
|
|
25
|
+
"zod": "^4.1.5"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^24.3.0",
|
|
29
|
+
"typescript": "^5.9.2"
|
|
30
|
+
}
|
|
31
|
+
}
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import {
|
|
6
|
+
EnrichedLeadSchema,
|
|
7
|
+
IcpSchema,
|
|
8
|
+
LeadSchema,
|
|
9
|
+
ScoredLeadSchema,
|
|
10
|
+
SyncTargetSchema
|
|
11
|
+
} from "./domain.js";
|
|
12
|
+
import { DryRunSyncProvider, HeuristicEnrichmentProvider, HeuristicLeadProvider, HeuristicScoringProvider } from "./engine.js";
|
|
13
|
+
import { readJsonFile, splitCsv, writeJsonFile } from "./io.js";
|
|
14
|
+
import type { LeadGenerationTarget } from "./providers.js";
|
|
15
|
+
|
|
16
|
+
const program = new Command();
|
|
17
|
+
const leadProvider = new HeuristicLeadProvider();
|
|
18
|
+
const enrichmentProvider = new HeuristicEnrichmentProvider();
|
|
19
|
+
const scoringProvider = new HeuristicScoringProvider();
|
|
20
|
+
const syncProvider = new DryRunSyncProvider();
|
|
21
|
+
|
|
22
|
+
function printOutput(value: unknown): void {
|
|
23
|
+
process.stdout.write(`${JSON.stringify(value, null, 2)}\n`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
program
|
|
27
|
+
.name("salesprompter")
|
|
28
|
+
.description("Sales workflow CLI for ICP definition, lead generation, enrichment, scoring, and sync.")
|
|
29
|
+
.version("0.1.0");
|
|
30
|
+
|
|
31
|
+
program
|
|
32
|
+
.command("icp:define")
|
|
33
|
+
.description("Define an ideal customer profile and write it to a JSON file.")
|
|
34
|
+
.requiredOption("--name <name>", "Human-readable ICP name")
|
|
35
|
+
.option("--industries <items>", "Comma-separated industries", "")
|
|
36
|
+
.option("--company-sizes <items>", "Comma-separated buckets like 1-49,50-199,200-499,500+", "")
|
|
37
|
+
.option("--regions <items>", "Comma-separated regions", "")
|
|
38
|
+
.option("--titles <items>", "Comma-separated titles", "")
|
|
39
|
+
.option("--pains <items>", "Comma-separated pain points", "")
|
|
40
|
+
.option("--required-signals <items>", "Comma-separated required signals", "")
|
|
41
|
+
.option("--excluded-signals <items>", "Comma-separated excluded signals", "")
|
|
42
|
+
.requiredOption("--out <path>", "Output file path")
|
|
43
|
+
.action(async (options) => {
|
|
44
|
+
const icp = IcpSchema.parse({
|
|
45
|
+
name: options.name,
|
|
46
|
+
industries: splitCsv(options.industries),
|
|
47
|
+
companySizes: splitCsv(options.companySizes),
|
|
48
|
+
regions: splitCsv(options.regions),
|
|
49
|
+
titles: splitCsv(options.titles),
|
|
50
|
+
pains: splitCsv(options.pains),
|
|
51
|
+
requiredSignals: splitCsv(options.requiredSignals),
|
|
52
|
+
excludedSignals: splitCsv(options.excludedSignals)
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
await writeJsonFile(options.out, icp);
|
|
56
|
+
printOutput({ status: "ok", icp });
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
program
|
|
60
|
+
.command("leads:generate")
|
|
61
|
+
.description("Generate seed leads against an ICP.")
|
|
62
|
+
.requiredOption("--icp <path>", "Path to ICP JSON")
|
|
63
|
+
.option("--count <number>", "Number of leads to generate", "10")
|
|
64
|
+
.option("--company-domain <domain>", "Target a specific company domain like deel.com")
|
|
65
|
+
.option("--company-name <name>", "Optional company name override for a targeted domain")
|
|
66
|
+
.requiredOption("--out <path>", "Output file path")
|
|
67
|
+
.action(async (options) => {
|
|
68
|
+
const icp = await readJsonFile(options.icp, IcpSchema);
|
|
69
|
+
const count = z.coerce.number().int().min(1).max(1000).parse(options.count);
|
|
70
|
+
const target: LeadGenerationTarget = {
|
|
71
|
+
companyDomain: options.companyDomain,
|
|
72
|
+
companyName: options.companyName
|
|
73
|
+
};
|
|
74
|
+
const leads = await leadProvider.generateLeads(icp, count, target);
|
|
75
|
+
|
|
76
|
+
await writeJsonFile(options.out, leads);
|
|
77
|
+
printOutput({ status: "ok", generated: leads.length, out: options.out, target: target.companyDomain ?? null });
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
program
|
|
81
|
+
.command("leads:enrich")
|
|
82
|
+
.description("Enrich leads with fit, buying stage, and tech stack data.")
|
|
83
|
+
.requiredOption("--in <path>", "Path to lead JSON array")
|
|
84
|
+
.requiredOption("--out <path>", "Output file path")
|
|
85
|
+
.action(async (options) => {
|
|
86
|
+
const leads = await readJsonFile(options.in, z.array(LeadSchema));
|
|
87
|
+
const enriched = await enrichmentProvider.enrichLeads(leads);
|
|
88
|
+
|
|
89
|
+
await writeJsonFile(options.out, enriched);
|
|
90
|
+
printOutput({ status: "ok", enriched: enriched.length, out: options.out });
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
program
|
|
94
|
+
.command("leads:score")
|
|
95
|
+
.description("Score enriched leads against an ICP.")
|
|
96
|
+
.requiredOption("--icp <path>", "Path to ICP JSON")
|
|
97
|
+
.requiredOption("--in <path>", "Path to enriched lead JSON array")
|
|
98
|
+
.requiredOption("--out <path>", "Output file path")
|
|
99
|
+
.action(async (options) => {
|
|
100
|
+
const icp = await readJsonFile(options.icp, IcpSchema);
|
|
101
|
+
const leads = await readJsonFile(options.in, z.array(EnrichedLeadSchema));
|
|
102
|
+
const scored = await scoringProvider.scoreLeads(icp, leads);
|
|
103
|
+
|
|
104
|
+
await writeJsonFile(options.out, scored);
|
|
105
|
+
printOutput({ status: "ok", scored: scored.length, out: options.out });
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
program
|
|
109
|
+
.command("sync:crm")
|
|
110
|
+
.description("Dry-run sync scored leads into a CRM target.")
|
|
111
|
+
.requiredOption("--target <target>", "hubspot|salesforce|pipedrive")
|
|
112
|
+
.requiredOption("--in <path>", "Path to scored lead JSON array")
|
|
113
|
+
.action(async (options) => {
|
|
114
|
+
const target = SyncTargetSchema.parse(options.target);
|
|
115
|
+
const leads = await readJsonFile(options.in, z.array(ScoredLeadSchema));
|
|
116
|
+
const result = await syncProvider.sync(target, leads);
|
|
117
|
+
printOutput({ status: "ok", ...result });
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
program
|
|
121
|
+
.command("sync:outreach")
|
|
122
|
+
.description("Dry-run sync scored leads into an outreach platform.")
|
|
123
|
+
.requiredOption("--target <target>", "apollo|instantly|outreach")
|
|
124
|
+
.requiredOption("--in <path>", "Path to scored lead JSON array")
|
|
125
|
+
.action(async (options) => {
|
|
126
|
+
const target = SyncTargetSchema.parse(options.target);
|
|
127
|
+
const leads = await readJsonFile(options.in, z.array(ScoredLeadSchema));
|
|
128
|
+
const result = await syncProvider.sync(target, leads);
|
|
129
|
+
printOutput({ status: "ok", ...result });
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
program.parseAsync(process.argv).catch((error: unknown) => {
|
|
133
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
134
|
+
process.stderr.write(`${message}\n`);
|
|
135
|
+
process.exitCode = 1;
|
|
136
|
+
});
|
package/src/domain.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const IcpSchema = z.object({
|
|
4
|
+
name: z.string().min(1),
|
|
5
|
+
industries: z.array(z.string().min(1)).default([]),
|
|
6
|
+
companySizes: z.array(z.string().min(1)).default([]),
|
|
7
|
+
regions: z.array(z.string().min(1)).default([]),
|
|
8
|
+
titles: z.array(z.string().min(1)).default([]),
|
|
9
|
+
pains: z.array(z.string().min(1)).default([]),
|
|
10
|
+
requiredSignals: z.array(z.string().min(1)).default([]),
|
|
11
|
+
excludedSignals: z.array(z.string().min(1)).default([]),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export type Icp = z.infer<typeof IcpSchema>;
|
|
15
|
+
|
|
16
|
+
export const LeadSchema = z.object({
|
|
17
|
+
companyName: z.string().min(1),
|
|
18
|
+
domain: z.string().min(1),
|
|
19
|
+
industry: z.string().min(1),
|
|
20
|
+
region: z.string().min(1),
|
|
21
|
+
employeeCount: z.number().int().nonnegative(),
|
|
22
|
+
contactName: z.string().min(1),
|
|
23
|
+
title: z.string().min(1),
|
|
24
|
+
email: z.string().email(),
|
|
25
|
+
source: z.string().min(1),
|
|
26
|
+
signals: z.array(z.string().min(1)).default([]),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export type Lead = z.infer<typeof LeadSchema>;
|
|
30
|
+
|
|
31
|
+
export const EnrichedLeadSchema = LeadSchema.extend({
|
|
32
|
+
techStack: z.array(z.string().min(1)).default([]),
|
|
33
|
+
crmFit: z.enum(["high", "medium", "low"]),
|
|
34
|
+
outreachFit: z.enum(["high", "medium", "low"]),
|
|
35
|
+
buyingStage: z.enum(["problem-aware", "solution-aware", "active-evaluation"]),
|
|
36
|
+
notes: z.array(z.string().min(1)).default([]),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export type EnrichedLead = z.infer<typeof EnrichedLeadSchema>;
|
|
40
|
+
|
|
41
|
+
export const ScoredLeadSchema = EnrichedLeadSchema.extend({
|
|
42
|
+
score: z.number().int().min(0).max(100),
|
|
43
|
+
grade: z.enum(["A", "B", "C", "D"]),
|
|
44
|
+
rationale: z.array(z.string().min(1)).default([]),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export type ScoredLead = z.infer<typeof ScoredLeadSchema>;
|
|
48
|
+
|
|
49
|
+
export const SyncTargetSchema = z.enum(["hubspot", "salesforce", "pipedrive", "apollo", "instantly", "outreach"]);
|
|
50
|
+
export type SyncTarget = z.infer<typeof SyncTargetSchema>;
|
package/src/engine.ts
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { EnrichmentProvider, LeadGenerationTarget, LeadProvider, ScoringProvider, SyncProvider } from "./providers.js";
|
|
3
|
+
import type { EnrichedLead, Icp, Lead, ScoredLead, SyncTarget } from "./domain.js";
|
|
4
|
+
import { SAMPLE_COMPANIES, SAMPLE_CONTACTS, SAMPLE_SIGNALS, SAMPLE_TECH } from "./sample-data.js";
|
|
5
|
+
|
|
6
|
+
function pickByIndex<T>(items: T[], index: number): T {
|
|
7
|
+
const item = items[index % items.length];
|
|
8
|
+
if (item === undefined) {
|
|
9
|
+
throw new Error("sample data invariant violated");
|
|
10
|
+
}
|
|
11
|
+
return item;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function normalizeCompanySize(employeeCount: number): string {
|
|
15
|
+
if (employeeCount < 50) {
|
|
16
|
+
return "1-49";
|
|
17
|
+
}
|
|
18
|
+
if (employeeCount < 200) {
|
|
19
|
+
return "50-199";
|
|
20
|
+
}
|
|
21
|
+
if (employeeCount < 500) {
|
|
22
|
+
return "200-499";
|
|
23
|
+
}
|
|
24
|
+
return "500+";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function deriveCompanyNameFromDomain(domain: string): string {
|
|
28
|
+
const normalizedDomain = domain
|
|
29
|
+
.toLowerCase()
|
|
30
|
+
.replace(/^https?:\/\//, "")
|
|
31
|
+
.replace(/^www\./, "")
|
|
32
|
+
.split("/")[0];
|
|
33
|
+
const hostname = normalizedDomain.split(".")[0] ?? normalizedDomain;
|
|
34
|
+
|
|
35
|
+
return hostname
|
|
36
|
+
.split(/[-_]/)
|
|
37
|
+
.filter((part) => part.length > 0)
|
|
38
|
+
.map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`)
|
|
39
|
+
.join(" ");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function buildTargetCompany(target: LeadGenerationTarget, fallback: (typeof SAMPLE_COMPANIES)[number], icp: Icp) {
|
|
43
|
+
const domain = target.companyDomain?.trim().toLowerCase();
|
|
44
|
+
if (domain === undefined) {
|
|
45
|
+
return fallback;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
companyName: target.companyName?.trim() || deriveCompanyNameFromDomain(domain),
|
|
50
|
+
domain,
|
|
51
|
+
industry: icp.industries[0] ?? fallback.industry,
|
|
52
|
+
region: icp.regions[0] ?? fallback.region,
|
|
53
|
+
employeeCount: fallback.employeeCount
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export class HeuristicLeadProvider implements LeadProvider {
|
|
58
|
+
async generateLeads(icp: Icp, count: number, target: LeadGenerationTarget = {}): Promise<Lead[]> {
|
|
59
|
+
return Array.from({ length: count }, (_, index) => {
|
|
60
|
+
const fallbackCompany = pickByIndex(SAMPLE_COMPANIES, index);
|
|
61
|
+
const company = buildTargetCompany(target, fallbackCompany, icp);
|
|
62
|
+
const contact = pickByIndex(SAMPLE_CONTACTS, index + 1);
|
|
63
|
+
const signals = [pickByIndex(SAMPLE_SIGNALS, index), pickByIndex(SAMPLE_SIGNALS, index + 2)];
|
|
64
|
+
const industry = icp.industries[index % Math.max(icp.industries.length, 1)] ?? company.industry;
|
|
65
|
+
const region = icp.regions[index % Math.max(icp.regions.length, 1)] ?? company.region;
|
|
66
|
+
const title = icp.titles[index % Math.max(icp.titles.length, 1)] ?? contact.title;
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
companyName: company.companyName,
|
|
70
|
+
domain: company.domain,
|
|
71
|
+
industry,
|
|
72
|
+
region,
|
|
73
|
+
employeeCount: company.employeeCount,
|
|
74
|
+
contactName: contact.contactName,
|
|
75
|
+
title,
|
|
76
|
+
email: `${contact.contactName.toLowerCase().replaceAll(" ", ".")}@${company.domain}`,
|
|
77
|
+
source: target.companyDomain ? "heuristic-target-account" : "heuristic-seed",
|
|
78
|
+
signals
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export class HeuristicEnrichmentProvider implements EnrichmentProvider {
|
|
85
|
+
async enrichLeads(leads: Lead[]): Promise<EnrichedLead[]> {
|
|
86
|
+
return leads.map((lead, index) => ({
|
|
87
|
+
...lead,
|
|
88
|
+
techStack: [pickByIndex(SAMPLE_TECH, index), pickByIndex(SAMPLE_TECH, index + 3)],
|
|
89
|
+
crmFit: lead.employeeCount > 200 ? "high" : lead.employeeCount > 100 ? "medium" : "low",
|
|
90
|
+
outreachFit: lead.signals.some((signal) => signal.includes("outbound")) ? "high" : "medium",
|
|
91
|
+
buyingStage: lead.signals.some((signal) => signal.includes("funding")) ? "active-evaluation" : "solution-aware",
|
|
92
|
+
notes: [
|
|
93
|
+
`${lead.companyName} matches the ${lead.industry} segment.`,
|
|
94
|
+
`${lead.contactName} is likely close to revenue tooling decisions.`
|
|
95
|
+
]
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export class HeuristicScoringProvider implements ScoringProvider {
|
|
101
|
+
async scoreLeads(icp: Icp, leads: EnrichedLead[]): Promise<ScoredLead[]> {
|
|
102
|
+
return leads.map((lead) => {
|
|
103
|
+
const rationale: string[] = [];
|
|
104
|
+
let score = 40;
|
|
105
|
+
|
|
106
|
+
if (icp.industries.includes(lead.industry)) {
|
|
107
|
+
score += 20;
|
|
108
|
+
rationale.push("Industry matches ICP.");
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (icp.regions.includes(lead.region)) {
|
|
112
|
+
score += 10;
|
|
113
|
+
rationale.push("Region matches ICP.");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const normalizedSize = normalizeCompanySize(lead.employeeCount);
|
|
117
|
+
if (icp.companySizes.includes(normalizedSize)) {
|
|
118
|
+
score += 10;
|
|
119
|
+
rationale.push("Company size matches ICP.");
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (icp.titles.includes(lead.title)) {
|
|
123
|
+
score += 10;
|
|
124
|
+
rationale.push("Contact title matches ICP.");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const requiredMatches = icp.requiredSignals.filter((signal) => lead.signals.includes(signal));
|
|
128
|
+
score += Math.min(requiredMatches.length * 5, 10);
|
|
129
|
+
if (requiredMatches.length > 0) {
|
|
130
|
+
rationale.push(`Matched ${requiredMatches.length} required buying signals.`);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const excludedMatches = icp.excludedSignals.filter((signal) => lead.signals.includes(signal));
|
|
134
|
+
score -= excludedMatches.length * 15;
|
|
135
|
+
if (excludedMatches.length > 0) {
|
|
136
|
+
rationale.push(`Matched ${excludedMatches.length} excluded signals.`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (lead.crmFit === "high") {
|
|
140
|
+
score += 5;
|
|
141
|
+
rationale.push("Strong CRM fit.");
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (lead.outreachFit === "high") {
|
|
145
|
+
score += 5;
|
|
146
|
+
rationale.push("Strong outreach fit.");
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const clampedScore = z.number().int().min(0).max(100).parse(score);
|
|
150
|
+
const grade = clampedScore >= 85 ? "A" : clampedScore >= 70 ? "B" : clampedScore >= 55 ? "C" : "D";
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
...lead,
|
|
154
|
+
score: clampedScore,
|
|
155
|
+
grade,
|
|
156
|
+
rationale
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export class DryRunSyncProvider implements SyncProvider {
|
|
163
|
+
async sync(target: SyncTarget, leads: ScoredLead[]): Promise<{ target: SyncTarget; synced: number; dryRun: boolean }> {
|
|
164
|
+
return {
|
|
165
|
+
target,
|
|
166
|
+
synced: leads.length,
|
|
167
|
+
dryRun: true
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
package/src/io.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
export async function readJsonFile<T>(filePath: string, schema: z.ZodType<T>): Promise<T> {
|
|
6
|
+
const content = await readFile(filePath, "utf8");
|
|
7
|
+
const parsed = JSON.parse(content) as unknown;
|
|
8
|
+
return schema.parse(parsed);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function writeJsonFile(filePath: string, value: unknown): Promise<void> {
|
|
12
|
+
await mkdir(path.dirname(filePath), { recursive: true });
|
|
13
|
+
await writeFile(filePath, `${JSON.stringify(value, null, 2)}\n`, "utf8");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function splitCsv(value: string): string[] {
|
|
17
|
+
return value
|
|
18
|
+
.split(",")
|
|
19
|
+
.map((entry) => entry.trim())
|
|
20
|
+
.filter((entry) => entry.length > 0);
|
|
21
|
+
}
|
package/src/providers.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { EnrichedLead, Icp, Lead, ScoredLead, SyncTarget } from "./domain.js";
|
|
2
|
+
|
|
3
|
+
export interface LeadGenerationTarget {
|
|
4
|
+
companyDomain?: string;
|
|
5
|
+
companyName?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface LeadProvider {
|
|
9
|
+
generateLeads(icp: Icp, count: number, target?: LeadGenerationTarget): Promise<Lead[]>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface EnrichmentProvider {
|
|
13
|
+
enrichLeads(leads: Lead[]): Promise<EnrichedLead[]>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ScoringProvider {
|
|
17
|
+
scoreLeads(icp: Icp, leads: EnrichedLead[]): Promise<ScoredLead[]>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface SyncProvider {
|
|
21
|
+
sync(target: SyncTarget, leads: ScoredLead[]): Promise<{ target: SyncTarget; synced: number; dryRun: boolean }>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const SAMPLE_COMPANIES = [
|
|
2
|
+
{ companyName: "Northstar Freight", domain: "northstarfreight.com", industry: "Logistics", region: "North America", employeeCount: 180 },
|
|
3
|
+
{ companyName: "Brightpath Health", domain: "brightpathhealth.io", industry: "Healthcare", region: "Europe", employeeCount: 320 },
|
|
4
|
+
{ companyName: "ForgeOps Cloud", domain: "forgeopscloud.dev", industry: "Software", region: "North America", employeeCount: 85 },
|
|
5
|
+
{ companyName: "Summit Retail Group", domain: "summitretailgroup.com", industry: "Retail", region: "Europe", employeeCount: 540 },
|
|
6
|
+
{ companyName: "Atlas Industrial", domain: "atlasindustrial.co", industry: "Manufacturing", region: "North America", employeeCount: 260 },
|
|
7
|
+
{ companyName: "Meridian Finance", domain: "meridianfinance.ai", industry: "Financial Services", region: "Europe", employeeCount: 140 }
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
export const SAMPLE_CONTACTS = [
|
|
11
|
+
{ contactName: "Avery Chen", title: "VP Sales" },
|
|
12
|
+
{ contactName: "Jordan Patel", title: "Head of Revenue Operations" },
|
|
13
|
+
{ contactName: "Taylor Morgan", title: "Director of Growth" },
|
|
14
|
+
{ contactName: "Morgan Diaz", title: "Chief Revenue Officer" },
|
|
15
|
+
{ contactName: "Cameron Lee", title: "Sales Operations Manager" },
|
|
16
|
+
{ contactName: "Riley Brooks", title: "Demand Generation Lead" }
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export const SAMPLE_SIGNALS = [
|
|
20
|
+
"hiring sales reps",
|
|
21
|
+
"recent funding",
|
|
22
|
+
"expanding into new regions",
|
|
23
|
+
"using fragmented sales tooling",
|
|
24
|
+
"growing outbound team",
|
|
25
|
+
"launching new product line"
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
export const SAMPLE_TECH = [
|
|
29
|
+
"HubSpot",
|
|
30
|
+
"Salesforce",
|
|
31
|
+
"Apollo",
|
|
32
|
+
"Instantly",
|
|
33
|
+
"Outreach",
|
|
34
|
+
"Clay",
|
|
35
|
+
"Segment",
|
|
36
|
+
"PostHog"
|
|
37
|
+
];
|