@seguelac/aca-cli 0.2.0 → 0.5.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/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  All notable changes to `aca-cli` are documented here. Format loosely follows [Keep a Changelog](https://keepachangelog.com/).
4
4
 
5
+ ## [0.5.0] - 2026-08-07
6
+
7
+ ### Added
8
+ - **`aca sequence duplicate <id>`**: copy an email sequence — steps, settings, mailbox pool, tracking domain and enrollment filter — optionally with its audience. `--with-lists` attaches the same lead lists (and their auto-enroll setup); `--with-leads` re-enrols the leads currently in the source. `--name` overrides the default `"<source> (copy)"`.
9
+ - The copy is always created as a **draft**, so duplicating never starts sending.
10
+ - `--with-leads` runs the full enrollment path, so unsubscribed/bounced leads and leads already active in another sequence are skipped — the command reports each bucket. It pages the source (1000 leads per request) and prints progress; ~15s per page, so a 13k-lead sequence takes a few minutes. Every page is durable, so interrupting it leaves correct data behind.
11
+ - Backed by a new `duplicate-email-sequence` edge function and a `sourceSequenceId` mode on `enroll-leads`, both shared with the app UI and the `duplicate_email_sequence` MCP tool.
12
+
13
+ ### Note
14
+ There is intentionally no `aca sequence ls` — listing goes through PostgREST, which only accepts JWTs, not the `aca_` API tokens this CLI recommends.
15
+
16
+ ## [0.4.0] - 2026-07-18
17
+
18
+ ### Added
19
+ - **`aca contact bulk-create`**: create many CRM contacts from a CSV/JSON file (`--file`) or piped stdin. Splits large inputs into batched requests (`--batch-size`, max 1000), dedups on email by default (`--no-dedupe` to override), supports `--source`, `--no-activity`, and `--dry-run`. CSV tags go in one cell separated by `;`.
20
+ - Backed by a new `bulk-create-contacts` edge function (also usable directly as a REST API) and a matching `bulk_create_contacts` MCP tool — all three share one core so behavior is identical across surfaces.
21
+
22
+ ### Changed
23
+ - Reconciled the version number: the built binary reported `0.3.0` while `package.json` was `0.2.0`. Both are now `0.4.0`.
24
+
5
25
  ## [0.2.0] - 2026-05-26
6
26
 
7
27
  ### Added
package/README.md CHANGED
@@ -83,6 +83,13 @@ aca campaign leads <campaignId> --stuck --json | jq '.[] | .contact_id'
83
83
  | `aca campaign status <id>` | Aggregate progress counts (pending, replied, failed, etc.). |
84
84
  | `aca campaign leads <id> --stuck` | List stuck leads (status: failed or sender_disconnected). |
85
85
 
86
+ ### Email sequences
87
+ | Command | What it does |
88
+ |---|---|
89
+ | `aca sequence duplicate <id>` | Copy a sequence (steps, settings, mailbox pool, tracking domain). Always lands as a **draft**. |
90
+ | `aca sequence duplicate <id> --with-lists` | ...and attach the same lead lists (auto-enroll + enrollment filter travel with them). |
91
+ | `aca sequence duplicate <id> --with-leads` | ...and re-enrol the leads currently in the source. Unsubscribed/bounced leads, and leads already active in another sequence, are skipped and reported. Pages through the source, so a large audience takes a few minutes. |
92
+
86
93
  ### Contacts
87
94
  | Command | What it does |
88
95
  |---|---|
@@ -1,7 +1,93 @@
1
- import { restGet, restPatch } from '../api.js';
1
+ import { readFileSync } from 'node:fs';
2
+ import { extname } from 'node:path';
3
+ import { invokeFn, restGet, restPatch } from '../api.js';
2
4
  import { output, fail } from '../output.js';
3
- import { parseList } from '../util.js';
5
+ import { parseCsv, parseList, readStdinIfPiped } from '../util.js';
4
6
  const ALLOWED_STATUSES = ['active', 'archived', 'bounced', 'unsubscribed', 'do_not_contact'];
7
+ const CONTACT_FIELDS = [
8
+ 'display_name',
9
+ 'first_name',
10
+ 'last_name',
11
+ 'company',
12
+ 'job_title',
13
+ 'primary_email',
14
+ 'primary_phone',
15
+ 'primary_linkedin_url',
16
+ 'company_website',
17
+ 'city',
18
+ 'state',
19
+ 'country',
20
+ 'pipeline_id',
21
+ 'stage_id',
22
+ 'tags',
23
+ 'source',
24
+ 'custom_fields',
25
+ 'owner_user_id',
26
+ ];
27
+ const DEFAULT_BATCH_SIZE = 500;
28
+ const MAX_BATCH_SIZE = 1000;
29
+ function normalizeContact(raw) {
30
+ const out = {};
31
+ for (const field of CONTACT_FIELDS) {
32
+ const val = raw[field];
33
+ if (val === undefined || val === null || val === '')
34
+ continue;
35
+ if (field === 'tags') {
36
+ const tags = Array.isArray(val) ? val.map(String) : parseListSemicolon(String(val));
37
+ if (tags.length > 0)
38
+ out.tags = tags;
39
+ continue;
40
+ }
41
+ if (field === 'custom_fields') {
42
+ if (typeof val === 'object') {
43
+ out.custom_fields = val;
44
+ }
45
+ else if (typeof val === 'string') {
46
+ try {
47
+ out.custom_fields = JSON.parse(val);
48
+ }
49
+ catch {
50
+ fail(`custom_fields is not valid JSON: ${val}`);
51
+ }
52
+ }
53
+ continue;
54
+ }
55
+ out[field] = typeof val === 'string' ? val.trim() : val;
56
+ }
57
+ return out;
58
+ }
59
+ function parseListSemicolon(value) {
60
+ return value
61
+ .split(';')
62
+ .map((s) => s.trim())
63
+ .filter(Boolean);
64
+ }
65
+ function parseContactsInput(text, format) {
66
+ const trimmed = text.trim();
67
+ if (!trimmed)
68
+ return [];
69
+ if (format === 'json') {
70
+ const parsed = JSON.parse(trimmed);
71
+ const arr = Array.isArray(parsed) ? parsed : [parsed];
72
+ return arr;
73
+ }
74
+ return parseCsv(trimmed);
75
+ }
76
+ function inferFormat(explicit, filePath, text) {
77
+ if (explicit === 'csv' || explicit === 'json')
78
+ return explicit;
79
+ if (explicit)
80
+ fail(`--format must be 'csv' or 'json'`);
81
+ if (filePath) {
82
+ const ext = extname(filePath).toLowerCase();
83
+ if (ext === '.json')
84
+ return 'json';
85
+ if (ext === '.csv' || ext === '.tsv')
86
+ return 'csv';
87
+ }
88
+ const t = text.trim();
89
+ return t.startsWith('[') || t.startsWith('{') ? 'json' : 'csv';
90
+ }
5
91
  export function registerContact(program) {
6
92
  const contact = program.command('contact').description('Inspect and mutate a single contact');
7
93
  contact
@@ -55,4 +141,71 @@ export function registerContact(program) {
55
141
  });
56
142
  output(Array.isArray(updated) ? updated[0] : updated, { json: opts.json });
57
143
  });
144
+ contact
145
+ .command('bulk-create')
146
+ .description('Create many contacts from a CSV/JSON file or piped stdin')
147
+ .option('-f, --file <path>', 'Path to a .csv or .json file of contacts')
148
+ .option('--format <fmt>', "Force input format: 'csv' or 'json' (else inferred)")
149
+ .option('--source <source>', 'Default source for contacts that omit one')
150
+ .option('--no-dedupe', 'Insert even if a contact with the same email exists')
151
+ .option('--no-activity', "Skip the per-contact 'contact_created' activity log")
152
+ .option('--batch-size <n>', `Contacts per request (max ${MAX_BATCH_SIZE})`, String(DEFAULT_BATCH_SIZE))
153
+ .option('--dry-run', 'Parse and validate only — do not create anything')
154
+ .option('--json', 'Emit JSON')
155
+ .action(async (opts) => {
156
+ let text = null;
157
+ if (opts.file) {
158
+ try {
159
+ text = readFileSync(opts.file, 'utf8');
160
+ }
161
+ catch (err) {
162
+ fail(`Could not read file ${opts.file}: ${err.message}`);
163
+ }
164
+ }
165
+ else {
166
+ text = await readStdinIfPiped();
167
+ }
168
+ if (!text || !text.trim()) {
169
+ fail('No input. Pass --file <path> or pipe CSV/JSON via stdin.');
170
+ }
171
+ const format = inferFormat(opts.format, opts.file, text);
172
+ let rawRecords;
173
+ try {
174
+ rawRecords = parseContactsInput(text, format);
175
+ }
176
+ catch (err) {
177
+ fail(`Failed to parse ${format.toUpperCase()} input: ${err.message}`);
178
+ }
179
+ const contacts = rawRecords.map(normalizeContact).filter((c) => Object.keys(c).length > 0);
180
+ if (contacts.length === 0) {
181
+ fail('No contacts found in input.');
182
+ }
183
+ const batchSize = Math.min(Math.max(1, parseInt(opts.batchSize ?? String(DEFAULT_BATCH_SIZE), 10) || DEFAULT_BATCH_SIZE), MAX_BATCH_SIZE);
184
+ if (opts.dryRun) {
185
+ output({ parsed: contacts.length, format, batch_size: batchSize, sample: contacts[0] }, { json: opts.json });
186
+ return;
187
+ }
188
+ const totals = { created: 0, skipped: 0, total_submitted: 0 };
189
+ const contactIds = [];
190
+ const batches = Math.ceil(contacts.length / batchSize);
191
+ for (let i = 0; i < contacts.length; i += batchSize) {
192
+ const chunk = contacts.slice(i, i + batchSize);
193
+ const batchNo = Math.floor(i / batchSize) + 1;
194
+ if (!opts.json && batches > 1) {
195
+ process.stderr.write(`Batch ${batchNo}/${batches} (${chunk.length} contacts)...\n`);
196
+ }
197
+ const res = await invokeFn('bulk-create-contacts', {
198
+ contacts: chunk,
199
+ dedupe_on_email: opts.dedupe !== false,
200
+ log_activity: opts.activity !== false,
201
+ source: opts.source,
202
+ });
203
+ totals.created += res.created ?? 0;
204
+ totals.skipped += res.skipped ?? 0;
205
+ totals.total_submitted += res.total_submitted ?? chunk.length;
206
+ if (Array.isArray(res.contact_ids))
207
+ contactIds.push(...res.contact_ids);
208
+ }
209
+ output(opts.json ? { ...totals, contact_ids: contactIds } : totals, { json: opts.json });
210
+ });
58
211
  }
@@ -0,0 +1,65 @@
1
+ import { invokeFn } from '../api.js';
2
+ import { output } from '../output.js';
3
+ export function registerSequence(program) {
4
+ const sequence = program.command('sequence').description('Duplicate email sequences');
5
+ sequence
6
+ .command('duplicate')
7
+ .description('Copy a sequence — steps and settings, optionally its audience')
8
+ .argument('<sequenceId>')
9
+ .option('-n, --name <name>', 'Name for the copy (default: "<source> (copy)")')
10
+ .option('--with-lists', 'Attach the same lead lists (carries auto-enroll + enrollment filter)')
11
+ .option('--with-leads', 'Enroll the leads currently in the source sequence')
12
+ .option('--json', 'Emit JSON')
13
+ .action(async (sequenceId, opts) => {
14
+ const dup = await invokeFn('duplicate-email-sequence', {
15
+ sequenceId,
16
+ name: opts.name,
17
+ copyLeadLists: opts.withLists === true,
18
+ });
19
+ let totals = null;
20
+ if (opts.withLeads) {
21
+ const running = {
22
+ enrolled: 0,
23
+ suppressed: 0,
24
+ alreadyInAnotherSequence: 0,
25
+ noEmail: 0,
26
+ leadsWithoutContact: 0,
27
+ };
28
+ totals = running;
29
+ let offset = 0;
30
+ for (;;) {
31
+ const page = await invokeFn('enroll-leads', {
32
+ sequenceId: dup.sequence.id,
33
+ sourceSequenceId: sequenceId,
34
+ sourceOffset: offset,
35
+ });
36
+ running.enrolled += page.enrolled ?? 0;
37
+ running.suppressed += page.suppressed ?? 0;
38
+ running.alreadyInAnotherSequence += page.alreadyInAnotherSequence ?? 0;
39
+ running.noEmail += page.noEmail ?? 0;
40
+ running.leadsWithoutContact += page.leadsWithoutContact ?? 0;
41
+ if (!page.sourceCursor || page.sourceCursor.done)
42
+ break;
43
+ offset = page.sourceCursor.offset;
44
+ if (!opts.json) {
45
+ process.stderr.write(` …${offset} leads scanned, ${running.enrolled} enrolled\n`);
46
+ }
47
+ }
48
+ }
49
+ const result = {
50
+ id: dup.sequence.id,
51
+ name: dup.sequence.name,
52
+ status: dup.sequence.status,
53
+ ...(totals
54
+ ? {
55
+ enrolled: totals.enrolled,
56
+ skipped_suppressed: totals.suppressed,
57
+ skipped_active_elsewhere: totals.alreadyInAnotherSequence,
58
+ skipped_no_email: totals.noEmail,
59
+ skipped_no_crm_contact: totals.leadsWithoutContact,
60
+ }
61
+ : {}),
62
+ };
63
+ output(result, { json: opts.json });
64
+ });
65
+ }
@@ -0,0 +1,117 @@
1
+ import { invokeFn, restPost } from '../api.js';
2
+ import { output, fail } from '../output.js';
3
+ const SIGNAL_TYPES = [
4
+ 'funding', 'acquisition', 'hiring', 'hiring_demand', 'job_change',
5
+ 'executive_hire', 'customer_win', 'award', 'growth',
6
+ ];
7
+ function parsePerson(raw) {
8
+ const parts = raw.split('|').map((p) => p.trim());
9
+ const [full_name, title, linkedin_url, photo_url] = parts;
10
+ if (!full_name)
11
+ fail(`--person needs a name: "${raw}"`);
12
+ if (!linkedin_url)
13
+ fail(`--person needs a linkedin url (3rd field): "${raw}"`);
14
+ return { full_name, linkedin_url, title: title || undefined, photo_url: photo_url || undefined };
15
+ }
16
+ export function registerSignals(program) {
17
+ const signals = program
18
+ .command('signals')
19
+ .description('Push and curate the public /signals buying-signals feed');
20
+ signals
21
+ .command('push')
22
+ .description('Push a buying signal (with optional people) onto the public feed')
23
+ .requiredOption('--company <name>', 'Company name')
24
+ .requiredOption('--type <type>', `Signal type (${SIGNAL_TYPES.join(', ')})`)
25
+ .requiredOption('--source-url <url>', 'Evidence/source URL')
26
+ .option('--domain <domain>', 'Company domain (used for logo)')
27
+ .option('--country <country>')
28
+ .option('--location <location>', 'Display location, e.g. "Berlin, DE"')
29
+ .option('--title <title>', 'Short headline for the signal')
30
+ .option('--summary <summary>', 'One-to-two sentence summary')
31
+ .option('--why <why>', 'Why it matters for outreach')
32
+ .option('--amount <label>', 'Human amount, e.g. "$12M"')
33
+ .option('--amount-usd <number>', 'Numeric amount in USD', (v) => Number(v))
34
+ .option('--date <YYYY-MM-DD>', 'Signal date (defaults to today, UTC)')
35
+ .option('--source-key <key>', "Machine source key, e.g. 'google_news_rss'")
36
+ .option('--source-label <label>', "Human source label, e.g. 'Google News'")
37
+ .option('--verified', 'Mark the signal verified')
38
+ .option('--quality <number>', '0..1 quality/relevance score', (v) => Number(v))
39
+ .option('--unpublished', 'Stage the row without publishing it')
40
+ .option('--company-linkedin <url>')
41
+ .option('--logo <url>', 'Explicit logo URL')
42
+ .option('--dedup-key <key>', 'Override the idempotency key')
43
+ .option('--person <spec>', 'Decision-maker "Name | Title | linkedin_url | photo_url" (repeatable)', (val, acc) => { acc.push(parsePerson(val)); return acc; }, [])
44
+ .option('--json', 'Emit JSON')
45
+ .action(async (opts) => {
46
+ const type = String(opts.type);
47
+ if (!SIGNAL_TYPES.includes(type)) {
48
+ fail(`--type must be one of: ${SIGNAL_TYPES.join(', ')}`);
49
+ }
50
+ const body = {
51
+ company_name: opts.company,
52
+ signal_type: type,
53
+ source_url: opts.sourceUrl,
54
+ domain: opts.domain,
55
+ country: opts.country,
56
+ location: opts.location,
57
+ title: opts.title,
58
+ summary: opts.summary,
59
+ why_it_matters: opts.why,
60
+ amount_label: opts.amount,
61
+ amount_usd: opts.amountUsd,
62
+ signal_date: opts.date,
63
+ source_key: opts.sourceKey,
64
+ source_label: opts.sourceLabel,
65
+ verified: Boolean(opts.verified),
66
+ quality_score: opts.quality,
67
+ published: opts.unpublished ? false : true,
68
+ company_linkedin_url: opts.companyLinkedin,
69
+ logo_url: opts.logo,
70
+ dedup_key: opts.dedupKey,
71
+ people: opts.person ?? [],
72
+ };
73
+ const res = await invokeFn('push-public-signal', body);
74
+ output(res, { json: Boolean(opts.json) });
75
+ });
76
+ signals
77
+ .command('ls')
78
+ .description('List public signals (includes unpublished)')
79
+ .option('--search <text>', 'Filter by company/domain/summary')
80
+ .option('--limit <n>', 'Max rows (default 50)', (v) => Number(v), 50)
81
+ .option('--offset <n>', 'Offset', (v) => Number(v), 0)
82
+ .option('--published-only', 'Hide staged/unpublished rows')
83
+ .option('--json', 'Emit JSON')
84
+ .action(async (opts) => {
85
+ const res = await restPost('rpc/admin_list_public_signals', {
86
+ p_limit: opts.limit,
87
+ p_offset: opts.offset,
88
+ p_search: opts.search ?? null,
89
+ p_include_unpublished: !opts.publishedOnly,
90
+ });
91
+ if (!res.ok)
92
+ fail(res.error === 'forbidden'
93
+ ? 'Forbidden — your account is not a member of the public-signals org.'
94
+ : `Failed: ${res.error}`);
95
+ output(opts.json ? res : (res.signals ?? []), { json: Boolean(opts.json) });
96
+ });
97
+ const setPublished = (publish) => async (id, opts) => {
98
+ const res = await restPost('rpc/admin_set_public_signal_published', { p_id: id, p_published: publish });
99
+ if (!res.ok)
100
+ fail(res.error === 'not_found' ? 'Signal not found.'
101
+ : res.error === 'forbidden' ? 'Forbidden — not a public-signals org member.'
102
+ : `Failed: ${res.error}`);
103
+ output(res, { json: Boolean(opts.json) });
104
+ };
105
+ signals
106
+ .command('hide')
107
+ .description('Unpublish a signal (hide it from the public feed)')
108
+ .argument('<signalId>')
109
+ .option('--json', 'Emit JSON')
110
+ .action(setPublished(false));
111
+ signals
112
+ .command('publish')
113
+ .description('Publish a previously-hidden signal')
114
+ .argument('<signalId>')
115
+ .option('--json', 'Emit JSON')
116
+ .action(setPublished(true));
117
+ }
package/dist/index.js CHANGED
@@ -8,12 +8,14 @@ import { registerLeads } from './commands/leads.js';
8
8
  import { registerInbox } from './commands/inbox.js';
9
9
  import { registerReply } from './commands/reply.js';
10
10
  import { registerCampaign } from './commands/campaign.js';
11
+ import { registerSequence } from './commands/sequence.js';
11
12
  import { registerContact } from './commands/contact.js';
13
+ import { registerSignals } from './commands/signals.js';
12
14
  import { registerAutopilot } from './commands/autopilot.js';
13
15
  import { registerConfig } from './commands/config.js';
14
16
  import { registerCompletion } from './commands/completion.js';
15
17
  import { maybeCheckForUpdate } from './update-check.js';
16
- const VERSION = '0.2.0';
18
+ const VERSION = '0.5.0';
17
19
  const program = new Command();
18
20
  program
19
21
  .name('aca')
@@ -27,7 +29,9 @@ registerLeads(program);
27
29
  registerInbox(program);
28
30
  registerReply(program);
29
31
  registerCampaign(program);
32
+ registerSequence(program);
30
33
  registerContact(program);
34
+ registerSignals(program);
31
35
  registerAutopilot(program);
32
36
  registerConfig(program);
33
37
  registerCompletion(program);
package/dist/util.js CHANGED
@@ -15,3 +15,73 @@ export async function readStdinIfPiped() {
15
15
  }
16
16
  return data.trim() || null;
17
17
  }
18
+ function parseCsvRows(text) {
19
+ const rows = [];
20
+ let field = '';
21
+ let row = [];
22
+ let inQuotes = false;
23
+ let started = false;
24
+ for (let i = 0; i < text.length; i++) {
25
+ const ch = text[i];
26
+ if (inQuotes) {
27
+ if (ch === '"') {
28
+ if (text[i + 1] === '"') {
29
+ field += '"';
30
+ i++;
31
+ }
32
+ else {
33
+ inQuotes = false;
34
+ }
35
+ }
36
+ else {
37
+ field += ch;
38
+ }
39
+ started = true;
40
+ }
41
+ else if (ch === '"') {
42
+ inQuotes = true;
43
+ started = true;
44
+ }
45
+ else if (ch === ',') {
46
+ row.push(field);
47
+ field = '';
48
+ started = true;
49
+ }
50
+ else if (ch === '\n') {
51
+ row.push(field);
52
+ rows.push(row);
53
+ row = [];
54
+ field = '';
55
+ started = false;
56
+ }
57
+ else if (ch === '\r') {
58
+ }
59
+ else {
60
+ field += ch;
61
+ started = true;
62
+ }
63
+ }
64
+ if (started || field !== '' || row.length > 0) {
65
+ row.push(field);
66
+ rows.push(row);
67
+ }
68
+ return rows;
69
+ }
70
+ export function parseCsv(text) {
71
+ const rows = parseCsvRows(text);
72
+ if (rows.length === 0)
73
+ return [];
74
+ const header = rows[0].map((h) => h.trim());
75
+ const out = [];
76
+ for (let i = 1; i < rows.length; i++) {
77
+ const cells = rows[i];
78
+ if (cells.length === 1 && cells[0].trim() === '')
79
+ continue;
80
+ const rec = {};
81
+ header.forEach((h, j) => {
82
+ rec[h] = (cells[j] ?? '').trim();
83
+ });
84
+ out.push(rec);
85
+ }
86
+ return out;
87
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seguelac/aca-cli",
3
- "version": "0.2.0",
3
+ "version": "0.5.0",
4
4
  "description": "Command-line interface for ACA (Automated Client Acquisition) — push leads to campaigns, triage replies, manage contacts, all from your terminal.",
5
5
  "type": "module",
6
6
  "bin": {