@seguelac/aca-cli 0.9.0 → 0.10.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,12 @@
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.10.0] - 2026-12-01
6
+
7
+ ### Added
8
+ - **`aca creative`: the creative strategist from the terminal.** `board`, `voc ls|add|sources`, `angles ls|upsert|status`, `hooks add`, `briefs ls|show|new|approve|kill|to-idea|link`, `tests ls|new|decide`, `perf --by angle|hook|format|platform|icp`, `trending`, `teardown` and `pulse`, backed by `/v1/creative` (the `api-creative` edge function, the same operations as the ACA MCP tools). Bulk input is JSON via `--file` or stdin. New angles need evidence; briefs get codes (B-0012) and paid briefs an ad name that maps results back.
9
+ - Requests to edge functions send `X-ACA-Runner` ("Claude Code · host", or `$ACA_RUNNER`), URI-encoded, so the app shows who did the work.
10
+
5
11
  ## [0.9.0] - 2026-11-23
6
12
 
7
13
  ### Added
package/dist/api.js CHANGED
@@ -1,5 +1,13 @@
1
1
  import { SUPABASE_URL, SUPABASE_ANON_KEY } from './constants.js';
2
+ import { hostname } from 'node:os';
2
3
  import { getAccessToken } from './session.js';
4
+ export function runnerLabel() {
5
+ if (process.env.ACA_RUNNER?.trim())
6
+ return process.env.ACA_RUNNER.trim().slice(0, 120);
7
+ const who = process.env.CLAUDECODE ? 'Claude Code' : 'aca CLI';
8
+ const host = hostname().replace(/\.local$/, '');
9
+ return `${who}${host ? ` · ${host}` : ''}`.slice(0, 120);
10
+ }
3
11
  async function authHeaders() {
4
12
  const token = await getAccessToken();
5
13
  return {
@@ -95,7 +103,7 @@ export async function fnRequest(method, name, params = {}, body) {
95
103
  const qs = query.toString();
96
104
  const res = await fetch(`${SUPABASE_URL}/functions/v1/${name}${qs ? `?${qs}` : ''}`, {
97
105
  method,
98
- headers: { ...headers, 'Content-Type': 'application/json' },
106
+ headers: { ...headers, 'Content-Type': 'application/json', 'x-aca-client': 'aca-cli', 'x-aca-runner': encodeURIComponent(runnerLabel()) },
99
107
  body: body === undefined ? undefined : JSON.stringify(body),
100
108
  });
101
109
  const text = await res.text();
@@ -0,0 +1,264 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { fnRequest } from '../api.js';
3
+ import { output, fail } from '../output.js';
4
+ import { readStdinIfPiped } from '../util.js';
5
+ const FN = 'api-creative';
6
+ const one = (s, n = 80) => String(s ?? '').replace(/\s+/g, ' ').slice(0, n);
7
+ async function readItems(key, file) {
8
+ const raw = file ? readFileSync(file, 'utf8') : await readStdinIfPiped();
9
+ if (!raw)
10
+ fail(`Give the ${key} as JSON: --file <path>, or pipe it in`);
11
+ let parsed;
12
+ try {
13
+ parsed = JSON.parse(raw);
14
+ }
15
+ catch {
16
+ fail(`${file ?? 'stdin'} is not valid JSON`);
17
+ }
18
+ const items = Array.isArray(parsed) ? parsed : parsed?.[key];
19
+ if (!Array.isArray(items))
20
+ fail(`Expected a JSON array or { "${key}": [...] }`);
21
+ return items;
22
+ }
23
+ export function registerCreative(program) {
24
+ const cr = program.command('creative').description('Creative strategist: customer words → angles → hooks → briefs → tests → learnings');
25
+ cr.command('board')
26
+ .description('The strategy at a glance (what a strategist session reads first)')
27
+ .option('--json', 'Emit JSON')
28
+ .action(async (opts) => {
29
+ const b = await fnRequest('GET', FN, { resource: 'board' });
30
+ if (opts.json)
31
+ return output(b, { json: true });
32
+ const voc = Object.entries(b.voice_of_customer.counts).map(([k, n]) => `${n} ${k}`).join(', ');
33
+ console.log(`Customer quotes: ${voc || 'none yet'}`);
34
+ console.log(`Briefs: ${Object.entries(b.counts.briefs_by_status).map(([k, n]) => `${n} ${k}`).join(', ') || 'none'} · open tests: ${b.counts.open_tests}\n`);
35
+ if (b.angles.length) {
36
+ output(b.angles.map((a) => ({
37
+ code: a.code, status: a.status, kind: a.kind, name: one(a.name, 40),
38
+ hooks: a.hooks.length, briefs: a.live_briefs.length,
39
+ lift: a.organic ? `${a.organic.avg_lift ?? '-'}${a.organic.confident ? '' : ' (low n)'}` : '',
40
+ })));
41
+ }
42
+ if (b.recent_learnings.length) {
43
+ console.log('\nRecent learnings:');
44
+ for (const l of b.recent_learnings.slice(0, 5))
45
+ console.log(`- ${one(l.summary, 140)}`);
46
+ }
47
+ if (b.next_steps.length) {
48
+ console.log('\nNext:');
49
+ for (const s of b.next_steps)
50
+ console.log(`- ${s}`);
51
+ }
52
+ console.log(`\n${b.app_url}`);
53
+ });
54
+ const voc = cr.command('voc').description('Voice of customer: verbatim quotes');
55
+ voc.command('ls')
56
+ .option('--kind <kind>', 'pain, desire, objection, trigger, phrase, proof, alternative')
57
+ .option('--source <source>')
58
+ .option('--query <words>')
59
+ .option('--limit <n>', 'Max rows', '50')
60
+ .option('--json', 'Emit JSON')
61
+ .action(async (o) => {
62
+ const d = await fnRequest('GET', FN, { resource: 'voc', kind: o.kind, source: o.source, query: o.query, limit: o.limit });
63
+ if (o.json)
64
+ return output(d, { json: true });
65
+ output(d.snippets.map((s) => ({ kind: s.kind, source: s.source, quote: one(s.quote, 100), id: s.id })));
66
+ });
67
+ voc.command('add')
68
+ .description('One quote with --quote/--kind, or many as JSON (--file or stdin)')
69
+ .option('--quote <text>')
70
+ .option('--kind <kind>')
71
+ .option('--source <source>', 'inbox, comment, review, call, survey, reddit, ad_comment, social, manual', 'manual')
72
+ .option('--file <path>', 'JSON array of { quote, kind, source?, source_ref?, icp_id? }')
73
+ .option('--json', 'Emit JSON')
74
+ .action(async (o) => {
75
+ const snippets = o.quote ? [{ quote: o.quote, kind: o.kind, source: o.source }] : await readItems('snippets', o.file);
76
+ output(await fnRequest('POST', FN, { resource: 'voc' }, { snippets }), { json: o.json });
77
+ });
78
+ voc.command('sources')
79
+ .description('Replies not mined yet (read them, then `aca creative voc add`)')
80
+ .option('--since <date>')
81
+ .option('--limit <n>', 'Max messages', '60')
82
+ .option('--json', 'Emit JSON')
83
+ .action(async (o) => {
84
+ const d = await fnRequest('GET', FN, { resource: 'voc-sources', since: o.since, limit: o.limit });
85
+ if (o.json)
86
+ return output(d, { json: true });
87
+ console.log(`Since ${d.since} · ${d.messages.length} message(s) · mined_until ${d.mined_until}`);
88
+ output(d.messages.map((m) => ({ at: m.at.slice(0, 16).replace('T', ' '), channel: m.channel, text: one(m.text, 110), id: m.message_id })));
89
+ });
90
+ const angles = cr.command('angles').description('Angles (A-001…) and their hooks');
91
+ angles.command('ls')
92
+ .option('--status <list>', 'hypothesis,testing,winner,loser,retired')
93
+ .option('--json', 'Emit JSON')
94
+ .action(async (o) => {
95
+ const d = await fnRequest('GET', FN, { resource: 'angles', status: o.status });
96
+ if (o.json)
97
+ return output(d, { json: true });
98
+ for (const a of d.angles) {
99
+ console.log(`${a.code} [${a.status}] ${a.kind}/${a.awareness} ${a.name}\n ${one(a.thesis, 140)}`);
100
+ for (const h of a.hooks)
101
+ console.log(` ${h.code} (${h.hook_type}${h.status !== 'hypothesis' ? `, ${h.status}` : ''}): ${one(h.text, 110)}`);
102
+ }
103
+ });
104
+ angles.command('upsert')
105
+ .description('Create or update angles from JSON (--file or stdin). New angles need name, thesis, kind, evidence.')
106
+ .option('--file <path>')
107
+ .option('--json', 'Emit JSON')
108
+ .action(async (o) => output(await fnRequest('POST', FN, { resource: 'angles' }, { angles: await readItems('angles', o.file) }), { json: o.json }));
109
+ angles.command('status')
110
+ .description('Set an angle\'s status')
111
+ .argument('<code>')
112
+ .argument('<status>', 'hypothesis, testing, winner, loser, retired')
113
+ .action(async (code, status) => output(await fnRequest('POST', FN, { resource: 'angles' }, { angles: [{ code, status }] })));
114
+ const hooks = cr.command('hooks').description('Hooks (A-001-H1…)');
115
+ hooks.command('add')
116
+ .description('One hook with --angle/--text/--type, or many as JSON (--file or stdin)')
117
+ .option('--angle <code>')
118
+ .option('--text <text>')
119
+ .option('--type <type>', 'question, stat, callout, contrarian, story, pattern_interrupt, demo, before_after, promise, curiosity')
120
+ .option('--modality <m>', 'spoken, on_screen, caption, headline, visual')
121
+ .option('--file <path>')
122
+ .option('--json', 'Emit JSON')
123
+ .action(async (o) => {
124
+ const items = o.text ? [{ angle: o.angle, text: o.text, hook_type: o.type, modality: o.modality }] : await readItems('hooks', o.file);
125
+ output(await fnRequest('POST', FN, { resource: 'hooks' }, { hooks: items }), { json: o.json });
126
+ });
127
+ const briefs = cr.command('briefs').description('Briefs (B-0001…): one angle + one hook, organic or paid');
128
+ briefs.command('ls')
129
+ .option('--status <list>', 'draft,approved,in_production,live,done,killed')
130
+ .option('--channel <channel>', 'organic or paid')
131
+ .option('--angle <code>')
132
+ .option('--json', 'Emit JSON')
133
+ .action(async (o) => {
134
+ const d = await fnRequest('GET', FN, { resource: 'briefs', status: o.status, channel: o.channel, angle: o.angle });
135
+ if (o.json)
136
+ return output(d, { json: true });
137
+ output(d.briefs.map((b) => ({
138
+ code: b.code, status: b.status, channel: b.channel, platform: b.platform, format: b.format,
139
+ angle: b.angle?.code, hook: b.hook?.code ?? '', posts: b.assets.length, ad_name: b.ad_name ?? '',
140
+ })));
141
+ });
142
+ briefs.command('show')
143
+ .argument('<code>')
144
+ .option('--json', 'Emit JSON')
145
+ .action(async (code, o) => {
146
+ const { brief: b, app_url } = await fnRequest('GET', FN, { resource: 'briefs', id: code });
147
+ if (o.json)
148
+ return output(b, { json: true });
149
+ console.log(`${b.code} [${b.status}] ${b.channel} · ${b.platform} · ${b.format} · ${b.objective}`);
150
+ console.log(`Angle ${b.angle.code}: ${b.angle.name}\n ${b.angle.thesis}`);
151
+ if (b.hook)
152
+ console.log(`Hook ${b.hook.code}: ${b.hook.text}`);
153
+ for (const beat of b.beats)
154
+ console.log(` ${beat.t ? `[${beat.t}] ` : ''}${beat.says ?? ''}${beat.shows ? ` (shows: ${beat.shows})` : ''}`);
155
+ if (b.proof)
156
+ console.log(`Proof: ${b.proof}`);
157
+ if (b.cta)
158
+ console.log(`CTA: ${b.cta}${b.destination_url ? ` → ${b.destination_url}` : ''}`);
159
+ if (b.ad_name)
160
+ console.log(`Ad name: ${b.ad_name}`);
161
+ console.log(app_url);
162
+ });
163
+ briefs.command('new')
164
+ .description('Create briefs from JSON (--file or stdin)')
165
+ .option('--file <path>')
166
+ .option('--json', 'Emit JSON')
167
+ .action(async (o) => {
168
+ const d = await fnRequest('POST', FN, { resource: 'briefs' }, { briefs: await readItems('briefs', o.file) });
169
+ if (o.json)
170
+ return output(d, { json: true });
171
+ output(d.briefs.map((b) => ({ code: b.code, channel: b.channel, platform: b.platform, format: b.format, angle: b.angle?.code, hook: b.hook?.code ?? '', ad_name: b.ad_name ?? '' })));
172
+ });
173
+ for (const [verb, status] of [['approve', 'approved'], ['kill', 'killed']]) {
174
+ briefs.command(verb).argument('<code>').action(async (code) => output(await fnRequest('PATCH', FN, { resource: 'briefs', id: code }, { status })));
175
+ }
176
+ briefs.command('to-idea')
177
+ .description('Turn an organic brief into a content idea (optionally into an autopilot pool)')
178
+ .argument('<code>')
179
+ .option('--autopilot <id>')
180
+ .action(async (code, o) => output(await fnRequest('POST', FN, { resource: 'briefs', id: code, action: 'to-idea' }, { autopilot_id: o.autopilot })));
181
+ briefs.command('link')
182
+ .description('Link a Scheduler post or an ad to a brief')
183
+ .argument('<code>')
184
+ .option('--post <id>', 'Scheduler post id')
185
+ .option('--ad <id>', 'Ad id on the ad platform')
186
+ .option('--ad-name <name>')
187
+ .action(async (code, o) => {
188
+ if (!o.post && !o.ad)
189
+ fail('Give --post <id> or --ad <id>');
190
+ output(await fnRequest('POST', FN, { resource: 'briefs', id: code, action: 'link' }, { post_id: o.post, external_ad_id: o.ad, ad_name: o.adName }));
191
+ });
192
+ const tests = cr.command('tests').description('Creative tests (T-001…)');
193
+ tests.command('ls')
194
+ .option('--status <list>', 'planned,running,decided,inconclusive')
195
+ .option('--json', 'Emit JSON')
196
+ .action(async (o) => {
197
+ const d = await fnRequest('GET', FN, { resource: 'tests', status: o.status });
198
+ if (o.json)
199
+ return output(d, { json: true });
200
+ for (const t of d.tests) {
201
+ console.log(`${t.code} [${t.status}] ${t.variable} · ${t.channel} · ${t.primary_metric}: ${one(t.hypothesis, 100)}`);
202
+ for (const v of t.variants)
203
+ console.log(` ${v.code}${t.winner_brief_id === v.brief_id ? ' ★' : ''} ${v.organic ? `${v.organic.posts} posts, lift ${v.organic.avg_lift ?? '-'}${v.organic.confident ? '' : ' (low n)'}` : 'no results yet'}`);
204
+ if (t.decision)
205
+ console.log(` → ${t.decision}`);
206
+ }
207
+ });
208
+ tests.command('new')
209
+ .requiredOption('--hypothesis <text>')
210
+ .requiredOption('--variable <v>', 'hook, angle, format, persona, offer, cta, visual')
211
+ .option('--channel <channel>', 'organic or paid', 'organic')
212
+ .option('--metric <metric>', 'engagement_lift, saves, comments, clicks, leads, hook_rate, hold_rate, ctr, cpa, roas')
213
+ .option('--briefs <codes>', 'Comma list of brief codes (the variants)')
214
+ .option('--json', 'Emit JSON')
215
+ .action(async (o) => output(await fnRequest('POST', FN, { resource: 'tests' }, {
216
+ hypothesis: o.hypothesis, variable: o.variable, channel: o.channel, primary_metric: o.metric,
217
+ briefs: o.briefs ? String(o.briefs).split(',').map((s) => s.trim()) : undefined,
218
+ }), { json: o.json }));
219
+ tests.command('decide')
220
+ .argument('<code>')
221
+ .requiredOption('--decision <text>', 'What we now believe, with the numbers')
222
+ .option('--winner <brief>')
223
+ .option('--inconclusive')
224
+ .action(async (code, o) => {
225
+ if (!o.winner && !o.inconclusive)
226
+ fail('Give --winner <brief code> or --inconclusive');
227
+ output(await fnRequest('POST', FN, { resource: 'tests', id: code, action: 'decide' }, { winner: o.winner, inconclusive: !!o.inconclusive, decision: o.decision }));
228
+ });
229
+ cr.command('perf')
230
+ .description('Organic results rolled up (lift = engagement rate / the account\'s usual)')
231
+ .option('--by <group>', 'angle, hook, hook_type, angle_kind, awareness, format, platform, icp, brief', 'angle')
232
+ .option('--days <n>', 'Window', '90')
233
+ .option('--json', 'Emit JSON')
234
+ .action(async (o) => {
235
+ const d = await fnRequest('GET', FN, { resource: 'performance', group_by: o.by, days: o.days });
236
+ if (o.json)
237
+ return output(d, { json: true });
238
+ output(d.rows.map((r) => ({ [o.by]: r.group_key, label: one(r.label, 40), posts: r.posts, impressions: r.impressions, lift: r.avg_lift, best: r.best_lift, confident: r.confident ? 'yes' : 'no' })));
239
+ });
240
+ cr.command('trending')
241
+ .description('Outlier posts in the niche (ratio = times their usual)')
242
+ .option('--platform <p>')
243
+ .option('--days <n>', 'Window', '30')
244
+ .option('--limit <n>', 'Max rows', '25')
245
+ .option('--json', 'Emit JSON')
246
+ .action(async (o) => {
247
+ const d = await fnRequest('GET', FN, { resource: 'trending', platform: o.platform, days: o.days, limit: o.limit });
248
+ if (o.json)
249
+ return output(d, { json: true });
250
+ output(d.posts.map((p) => ({ ratio: `${p.ratio.toFixed(1)}x`, platform: p.platform, author: p.author ?? '', title: one(p.title, 60), formula: one(p.formula, 40), id: p.id })));
251
+ });
252
+ cr.command('teardown').argument('<id>').option('--json', 'Emit JSON')
253
+ .action(async (id, o) => output(await fnRequest('GET', FN, { resource: 'trending', id }), { json: o.json ?? true }));
254
+ cr.command('pulse')
255
+ .description('What the niche is talking about now')
256
+ .option('--days <n>', 'Window', '7')
257
+ .option('--json', 'Emit JSON')
258
+ .action(async (o) => {
259
+ const d = await fnRequest('GET', FN, { resource: 'pulse', days: o.days });
260
+ if (o.json)
261
+ return output(d, { json: true });
262
+ output(d.stories.map((s) => ({ fit: s.fit_score ?? '', headline: one(s.headline, 60), angle: one(s.angle, 70), id: s.id })));
263
+ });
264
+ }
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ import { registerSignals } from './commands/signals.js';
18
18
  import { registerAutopilot } from './commands/autopilot.js';
19
19
  import { registerMessaging } from './commands/messaging.js';
20
20
  import { registerScheduler } from './commands/scheduler.js';
21
+ import { registerCreative } from './commands/creative.js';
21
22
  import { registerConfig } from './commands/config.js';
22
23
  import { registerCompletion } from './commands/completion.js';
23
24
  import { maybeCheckForUpdate } from './update-check.js';
@@ -44,6 +45,7 @@ registerSignals(program);
44
45
  registerAutopilot(program);
45
46
  registerMessaging(program);
46
47
  registerScheduler(program);
48
+ registerCreative(program);
47
49
  registerConfig(program);
48
50
  registerCompletion(program);
49
51
  async function main() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seguelac/aca-cli",
3
- "version": "0.9.0",
3
+ "version": "0.10.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": {