@businesskit/agent 1.0.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/.agents/skills/agents.md +56 -0
- package/.agents/skills/analytics.md +47 -0
- package/.agents/skills/brand.md +87 -0
- package/.agents/skills/schema.md +45 -0
- package/.agents/skills/store.md +46 -0
- package/.claude/commands/analytics.md +7 -0
- package/.claude/commands/blog-writer.md +9 -0
- package/.claude/commands/cbo.md +7 -0
- package/.claude/commands/ceo.md +10 -0
- package/.claude/commands/cmo.md +7 -0
- package/.claude/commands/compress.md +73 -0
- package/.claude/commands/coo.md +11 -0
- package/.claude/commands/copywriter.md +15 -0
- package/.claude/commands/course-creator.md +9 -0
- package/.claude/commands/crm.md +82 -0
- package/.claude/commands/deep.md +50 -0
- package/.claude/commands/docs-writer.md +8 -0
- package/.claude/commands/forms-builder.md +10 -0
- package/.claude/commands/jobs-manager.md +8 -0
- package/.claude/commands/kb.md +107 -0
- package/.claude/commands/newsletter-writer.md +9 -0
- package/.claude/commands/preserve.md +64 -0
- package/.claude/commands/resume.md +67 -0
- package/.claude/commands/scheduler.md +8 -0
- package/.claude/commands/seo.md +60 -0
- package/.claude/commands/social.md +51 -0
- package/.claude/commands/store-manager.md +11 -0
- package/.claude/skills/README.md +33 -0
- package/.claude/skills/agents.md +56 -0
- package/.claude/skills/analytics.md +7 -0
- package/.claude/skills/blog-writing.md +452 -0
- package/.claude/skills/brand.md +44 -0
- package/.claude/skills/content-seo.md +0 -0
- package/.claude/skills/humanizer.md +474 -0
- package/.claude/skills/schema.md +45 -0
- package/.claude/skills/social-content.md +278 -0
- package/.claude/skills/store-copywriting.md +519 -0
- package/.claude/skills/store.md +62 -0
- package/.claude-plugin/plugin.json +33 -0
- package/.cursorrules +0 -0
- package/.env.example +2 -0
- package/.mcp.json +3 -0
- package/AGENTS.md +63 -0
- package/CLAUDE.md +221 -0
- package/GEMINI.md +37 -0
- package/LICENSE +21 -0
- package/PLAN.md +253 -0
- package/PRD-Agent-Harness.md +316 -0
- package/README.md +237 -0
- package/SYSTEM.md +49 -0
- package/agents/_base.ts +63 -0
- package/agents/creators/blog-writer.ts +347 -0
- package/agents/creators/copywriter.ts +89 -0
- package/agents/creators/course-creator.ts +106 -0
- package/agents/creators/crm-agent.ts +479 -0
- package/agents/creators/docs-writer.ts +77 -0
- package/agents/creators/forms-builder.ts +90 -0
- package/agents/creators/jobs-manager.ts +82 -0
- package/agents/creators/newsletter-writer.ts +91 -0
- package/agents/creators/store-manager.ts +138 -0
- package/agents/csuite/cbo.ts +109 -0
- package/agents/csuite/ceo.ts +121 -0
- package/agents/csuite/cmo.ts +109 -0
- package/agents/csuite/coo.ts +115 -0
- package/agents/growth/analytics-agent.ts +52 -0
- package/agents/growth/scheduler.ts +68 -0
- package/agents/growth/seo-agent.ts +282 -0
- package/agents/growth/social-agent.ts +346 -0
- package/bin/businesskit.js +17 -0
- package/cli.ts +125 -0
- package/context/brand.md +80 -0
- package/context/business.md +66 -0
- package/lib/analytics.ts +81 -0
- package/lib/db.adapter.ts +30 -0
- package/lib/db.ts +16 -0
- package/lib/id.ts +15 -0
- package/lib/kb.ts +337 -0
- package/lib/memory.ts +219 -0
- package/lib/pattern-detector.ts +169 -0
- package/lib/profile.ts +119 -0
- package/lib/slug.ts +30 -0
- package/package.json +50 -0
- package/setup.ts +127 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Social Agent — Agent-First SMM
|
|
3
|
+
*
|
|
4
|
+
* All posting goes through Zernio API (https://zernio.com/api/v1).
|
|
5
|
+
* Reads from social_accounts, social_posts, social_post_platforms in Turso.
|
|
6
|
+
* Writes social_posts rows, then calls Zernio to schedule/publish.
|
|
7
|
+
*
|
|
8
|
+
* Three modes (from social.ts):
|
|
9
|
+
* zernio_byok → user's own Zernio key from connections table
|
|
10
|
+
* zernio_platform → BusinessKit platform key via POST /api/social/schedule
|
|
11
|
+
* direct → n8n webhook fallback
|
|
12
|
+
*
|
|
13
|
+
* Agent reads mode from social_accounts.connection_mode and routes accordingly.
|
|
14
|
+
* Platform key (ZERNIO_API_KEY) is NEVER used here — that's the Worker's job.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { BaseAgent, db, ulid, now, iso } from '../_base.ts'
|
|
18
|
+
|
|
19
|
+
const ZERNIO_BASE = 'https://zernio.com/api/v1'
|
|
20
|
+
|
|
21
|
+
export type SocialPlatform =
|
|
22
|
+
| 'twitter' | 'instagram' | 'facebook' | 'linkedin' | 'tiktok'
|
|
23
|
+
| 'youtube' | 'pinterest' | 'reddit' | 'bluesky' | 'threads'
|
|
24
|
+
| 'googlebusiness' | 'telegram' | 'snapchat'
|
|
25
|
+
|
|
26
|
+
export interface PostInput {
|
|
27
|
+
content: string
|
|
28
|
+
platforms?: SocialPlatform[] // omit = all connected accounts
|
|
29
|
+
scheduledFor?: string // ISO: '2026-04-01T09:00:00'
|
|
30
|
+
timezone?: string // default: 'UTC'
|
|
31
|
+
publishNow?: boolean
|
|
32
|
+
useQueue?: boolean // use Zernio's recurring queue
|
|
33
|
+
mediaItems?: Array<{ url: string; type: 'image' | 'video' | 'document' }>
|
|
34
|
+
sourceId?: string // FK to posts.id / products.id for cross-post
|
|
35
|
+
sourceType?: 'blog_crosspost' | 'product_launch' | 'manual'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface PostResult {
|
|
39
|
+
ok: boolean
|
|
40
|
+
post_id?: string // local social_posts.id
|
|
41
|
+
zernio_post_id?: string // Zernio's post ID
|
|
42
|
+
platforms: string[]
|
|
43
|
+
status: string
|
|
44
|
+
error?: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class SocialAgent extends BaseAgent {
|
|
48
|
+
readonly name = 'Social Agent'
|
|
49
|
+
readonly title = 'Social Agent'
|
|
50
|
+
|
|
51
|
+
// ── Read state from DB ──────────────────────────────────────────────────────
|
|
52
|
+
|
|
53
|
+
async listAccounts(activeOnly = true) {
|
|
54
|
+
await this.init()
|
|
55
|
+
let sql = 'SELECT * FROM social_accounts WHERE profile_id=?'
|
|
56
|
+
const args: unknown[] = [this.profileId]
|
|
57
|
+
if (activeOnly) { sql += ' AND is_active=1 AND is_connected=1' }
|
|
58
|
+
const { rows } = await db.execute({ sql, args })
|
|
59
|
+
return rows
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async listPosts(opts: { status?: string; limit?: number } = {}) {
|
|
63
|
+
await this.init()
|
|
64
|
+
let sql = 'SELECT * FROM social_posts WHERE profile_id=? AND hidden=0'
|
|
65
|
+
const args: unknown[] = [this.profileId]
|
|
66
|
+
if (opts.status) { sql += ' AND status=?'; args.push(opts.status) }
|
|
67
|
+
sql += ` ORDER BY created_at DESC LIMIT ${opts.limit ?? 20}`
|
|
68
|
+
const { rows } = await db.execute({ sql, args })
|
|
69
|
+
return rows
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async getDrafts() { return this.listPosts({ status: 'draft' }) }
|
|
73
|
+
async getScheduled() { return this.listPosts({ status: 'scheduled' }) }
|
|
74
|
+
|
|
75
|
+
async getAnalytics(accountId: string) {
|
|
76
|
+
const { rows: [r] } = await db.execute({
|
|
77
|
+
sql: 'SELECT * FROM social_analytics WHERE account_id=? LIMIT 1',
|
|
78
|
+
args: [accountId],
|
|
79
|
+
})
|
|
80
|
+
return r ?? null
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async getInbox(opts: { status?: string; type?: string; limit?: number } = {}) {
|
|
84
|
+
await this.init()
|
|
85
|
+
let sql = 'SELECT * FROM social_inbox WHERE profile_id=?'
|
|
86
|
+
const args: unknown[] = [this.profileId]
|
|
87
|
+
if (opts.status) { sql += ' AND status=?'; args.push(opts.status) }
|
|
88
|
+
if (opts.type) { sql += ' AND type=?'; args.push(opts.type) }
|
|
89
|
+
sql += ` ORDER BY received_at DESC LIMIT ${opts.limit ?? 50}`
|
|
90
|
+
const { rows } = await db.execute({ sql, args })
|
|
91
|
+
return rows
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ── Core: create + schedule a post ─────────────────────────────────────────
|
|
95
|
+
|
|
96
|
+
async post(input: PostInput): Promise<PostResult> {
|
|
97
|
+
await this.init()
|
|
98
|
+
|
|
99
|
+
// 1. Determine which accounts to post to
|
|
100
|
+
const accounts = await this.listAccounts()
|
|
101
|
+
if (!accounts.length) {
|
|
102
|
+
return { ok: false, platforms: [], status: 'no_accounts',
|
|
103
|
+
error: 'No connected social accounts. Connect platforms in BusinessKit → Settings → Social.' }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const targets = input.platforms
|
|
107
|
+
? accounts.filter(a => input.platforms!.includes(a.platform as SocialPlatform))
|
|
108
|
+
: accounts
|
|
109
|
+
|
|
110
|
+
if (!targets.length) {
|
|
111
|
+
return { ok: false, platforms: [], status: 'no_matching_accounts',
|
|
112
|
+
error: `No accounts connected for: ${input.platforms?.join(', ')}` }
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// 2. Resolve Zernio key (BYOK only — platform key goes via /api/social/schedule)
|
|
116
|
+
const zernioKey = await this.resolveZernioKey()
|
|
117
|
+
|
|
118
|
+
// 3. Determine connection mode
|
|
119
|
+
const mode = targets[0].connection_mode as string
|
|
120
|
+
|
|
121
|
+
if (mode === 'zernio_byok' && zernioKey) {
|
|
122
|
+
return this.postViaZernio(input, targets, zernioKey, 'byok')
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (mode === 'zernio_platform') {
|
|
126
|
+
// Needs session token — only works in-app (Phase 2)
|
|
127
|
+
return {
|
|
128
|
+
ok: false, platforms: [], status: 'requires_session',
|
|
129
|
+
error: 'Platform key posting requires authentication. Use /api/social/schedule from the dashboard.',
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (mode === 'n8n' || this.ctx.credentials.n8n_webhook_url) {
|
|
134
|
+
return this.postViaN8n(input, targets)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return { ok: false, platforms: [], status: 'no_method',
|
|
138
|
+
error: 'No Zernio key or n8n webhook configured.' }
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// ── Zernio posting (BYOK) ───────────────────────────────────────────────────
|
|
142
|
+
|
|
143
|
+
private async postViaZernio(
|
|
144
|
+
input: PostInput,
|
|
145
|
+
accounts: typeof Object[],
|
|
146
|
+
apiKey: string,
|
|
147
|
+
scheduledVia: 'byok' | 'platform'
|
|
148
|
+
): Promise<PostResult> {
|
|
149
|
+
const platforms = accounts.map((a: any) => ({
|
|
150
|
+
platform: a.platform,
|
|
151
|
+
accountId: a.zernio_account_id,
|
|
152
|
+
}))
|
|
153
|
+
|
|
154
|
+
const payload: Record<string, unknown> = {
|
|
155
|
+
content: input.content,
|
|
156
|
+
platforms,
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (input.publishNow) payload.publishNow = true
|
|
160
|
+
if (input.useQueue) payload.useQueue = true
|
|
161
|
+
if (input.scheduledFor) payload.scheduledFor = input.scheduledFor
|
|
162
|
+
if (input.timezone) payload.timezone = input.timezone ?? 'UTC'
|
|
163
|
+
if (input.mediaItems?.length) payload.mediaItems = input.mediaItems
|
|
164
|
+
|
|
165
|
+
let zernioRes: { id?: string; status?: string } = {}
|
|
166
|
+
let ok = false
|
|
167
|
+
let error: string | undefined
|
|
168
|
+
|
|
169
|
+
try {
|
|
170
|
+
const res = await fetch(`${ZERNIO_BASE}/posts`, {
|
|
171
|
+
method: 'POST',
|
|
172
|
+
headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
|
|
173
|
+
body: JSON.stringify(payload),
|
|
174
|
+
})
|
|
175
|
+
if (res.ok) {
|
|
176
|
+
zernioRes = await res.json() as typeof zernioRes
|
|
177
|
+
ok = true
|
|
178
|
+
} else {
|
|
179
|
+
const errBody = await res.text()
|
|
180
|
+
error = `Zernio ${res.status}: ${errBody}`
|
|
181
|
+
}
|
|
182
|
+
} catch (e) {
|
|
183
|
+
error = String(e)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Write to social_posts regardless — draft if failed
|
|
187
|
+
const postId = ulid()
|
|
188
|
+
const ts = now()
|
|
189
|
+
const month = new Date().toISOString().slice(0, 7)
|
|
190
|
+
const status = ok
|
|
191
|
+
? (input.publishNow ? 'published' : input.scheduledFor ? 'scheduled' : 'queued')
|
|
192
|
+
: 'failed'
|
|
193
|
+
|
|
194
|
+
await db.execute({
|
|
195
|
+
sql: `INSERT INTO social_posts
|
|
196
|
+
(id,profile_id,content,status,scheduled_for,timezone,publish_now,use_queue,
|
|
197
|
+
source,source_id,zernio_post_id,scheduled_via,platform_schedule_month,
|
|
198
|
+
ai_generated,error,created_at,updated_at)
|
|
199
|
+
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,0,?,?,?)`,
|
|
200
|
+
args: [
|
|
201
|
+
postId, this.profileId, input.content, status,
|
|
202
|
+
input.scheduledFor ?? null, input.timezone ?? 'UTC',
|
|
203
|
+
input.publishNow ? 1 : 0, input.useQueue ? 1 : 0,
|
|
204
|
+
input.sourceType ?? 'manual', input.sourceId ?? null,
|
|
205
|
+
zernioRes.id ?? null, scheduledVia, month,
|
|
206
|
+
error ?? null, ts, ts,
|
|
207
|
+
],
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
// Write per-platform rows
|
|
211
|
+
if (ok && zernioRes.id) {
|
|
212
|
+
const stmts = (accounts as any[]).map(a => ({
|
|
213
|
+
sql: `INSERT INTO social_post_platforms
|
|
214
|
+
(id,post_id,profile_id,account_id,platform,zernio_account_id,zernio_post_id,
|
|
215
|
+
status,created_at,updated_at)
|
|
216
|
+
VALUES (?,?,?,?,?,?,?,?,?,?)`,
|
|
217
|
+
args: [
|
|
218
|
+
ulid(), postId, this.profileId, a.id, a.platform,
|
|
219
|
+
a.zernio_account_id, zernioRes.id, status, ts, ts,
|
|
220
|
+
],
|
|
221
|
+
}))
|
|
222
|
+
await db.batch(stmts)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
await this.logProgress(ok, input.content.slice(0, 60), (accounts as any[]).map(a => a.platform))
|
|
226
|
+
|
|
227
|
+
return {
|
|
228
|
+
ok,
|
|
229
|
+
post_id: postId,
|
|
230
|
+
zernio_post_id: zernioRes.id,
|
|
231
|
+
platforms: (accounts as any[]).map(a => a.platform),
|
|
232
|
+
status,
|
|
233
|
+
error,
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// ── n8n fallback ────────────────────────────────────────────────────────────
|
|
238
|
+
|
|
239
|
+
private async postViaN8n(input: PostInput, accounts: typeof Object[]): Promise<PostResult> {
|
|
240
|
+
const { n8n_webhook_url } = this.ctx.credentials
|
|
241
|
+
if (!n8n_webhook_url) {
|
|
242
|
+
return { ok: false, platforms: [], status: 'no_n8n', error: 'No n8n webhook URL in credentials.' }
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
try {
|
|
246
|
+
const res = await fetch(n8n_webhook_url, {
|
|
247
|
+
method: 'POST',
|
|
248
|
+
headers: { 'Content-Type': 'application/json' },
|
|
249
|
+
body: JSON.stringify({
|
|
250
|
+
event: 'social_post',
|
|
251
|
+
profile_id: this.profileId,
|
|
252
|
+
business: this.ctx.profile.title,
|
|
253
|
+
content: input.content,
|
|
254
|
+
platforms: (accounts as any[]).map(a => a.platform),
|
|
255
|
+
scheduled_for: input.scheduledFor ?? null,
|
|
256
|
+
publish_now: input.publishNow ?? false,
|
|
257
|
+
source_id: input.sourceId ?? null,
|
|
258
|
+
timestamp: iso(),
|
|
259
|
+
}),
|
|
260
|
+
})
|
|
261
|
+
return {
|
|
262
|
+
ok: res.ok,
|
|
263
|
+
platforms: (accounts as any[]).map(a => a.platform),
|
|
264
|
+
status: res.ok ? 'sent_to_n8n' : 'n8n_error',
|
|
265
|
+
error: res.ok ? undefined : `n8n returned ${res.status}`,
|
|
266
|
+
}
|
|
267
|
+
} catch (e) {
|
|
268
|
+
return { ok: false, platforms: [], status: 'n8n_error', error: String(e) }
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// ── Convenience: cross-post from content ────────────────────────────────────
|
|
273
|
+
|
|
274
|
+
async crossPostBlog(postId: string, title: string, slug: string, excerpt?: string) {
|
|
275
|
+
const url = `https://${this.ctx.profile.slug}.businesskit.io/blog/${slug}`
|
|
276
|
+
const content = excerpt ? `${title}\n\n${excerpt}\n\n${url}` : `${title}\n\n${url}`
|
|
277
|
+
return this.post({ content, sourceId: postId, sourceType: 'blog_crosspost' })
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
async announceProduct(productId: string, title: string, slug: string, priceCents: number) {
|
|
281
|
+
const url = `https://${this.ctx.profile.slug}.businesskit.io/store/${slug}`
|
|
282
|
+
const price = `$${(priceCents / 100).toFixed(2)}`
|
|
283
|
+
const content = `New: ${title} — ${price}\n\n${url}`
|
|
284
|
+
return this.post({ content, sourceId: productId, sourceType: 'product_launch' })
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// ── Queue management ────────────────────────────────────────────────────────
|
|
288
|
+
|
|
289
|
+
async listQueueSlots(accountId?: string) {
|
|
290
|
+
await this.init()
|
|
291
|
+
let sql = 'SELECT * FROM social_queue WHERE profile_id=?'
|
|
292
|
+
const args: unknown[] = [this.profileId]
|
|
293
|
+
if (accountId) { sql += ' AND account_id=?'; args.push(accountId) }
|
|
294
|
+
sql += ' ORDER BY day_of_week ASC, time_of_day ASC'
|
|
295
|
+
const { rows } = await db.execute({ sql, args })
|
|
296
|
+
return rows
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// ── Analytics summary ───────────────────────────────────────────────────────
|
|
300
|
+
|
|
301
|
+
async socialSummary() {
|
|
302
|
+
await this.init()
|
|
303
|
+
const accounts = await this.listAccounts()
|
|
304
|
+
const { rows: [counts] } = await db.execute({
|
|
305
|
+
sql: `SELECT
|
|
306
|
+
COUNT(*) total,
|
|
307
|
+
SUM(CASE WHEN status='published' THEN 1 ELSE 0 END) published,
|
|
308
|
+
SUM(CASE WHEN status='scheduled' THEN 1 ELSE 0 END) scheduled,
|
|
309
|
+
SUM(CASE WHEN status='draft' THEN 1 ELSE 0 END) drafts
|
|
310
|
+
FROM social_posts WHERE profile_id=? AND hidden=0`,
|
|
311
|
+
args: [this.profileId],
|
|
312
|
+
})
|
|
313
|
+
return { accounts: accounts.length, posts: counts }
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// ── Helpers ─────────────────────────────────────────────────────────────────
|
|
317
|
+
|
|
318
|
+
private async resolveZernioKey(): Promise<string | null> {
|
|
319
|
+
try {
|
|
320
|
+
const { rows: [r] } = await db.execute({
|
|
321
|
+
sql: `SELECT client_id FROM connections
|
|
322
|
+
WHERE profile_id=? AND service='zernio' AND is_active=1 AND client_id IS NOT NULL
|
|
323
|
+
LIMIT 1`,
|
|
324
|
+
args: [this.profileId],
|
|
325
|
+
})
|
|
326
|
+
return (r?.client_id as string) ?? null
|
|
327
|
+
} catch {
|
|
328
|
+
return null
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
private async logProgress(ok: boolean, preview: string, platforms: string[]) {
|
|
333
|
+
try {
|
|
334
|
+
const { logMemory } = await import('../../lib/memory.ts')
|
|
335
|
+
await logMemory(
|
|
336
|
+
'social',
|
|
337
|
+
ok
|
|
338
|
+
? `Posted "${preview.slice(0, 80)}..." to ${platforms.join(', ')}`
|
|
339
|
+
: `Failed to post "${preview.slice(0, 80)}..."`,
|
|
340
|
+
{ platforms, ok }
|
|
341
|
+
)
|
|
342
|
+
} catch { /* memory_log optional until provisioned */ }
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export const socialAgent = new SocialAgent()
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from 'child_process';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { dirname, resolve } from 'path';
|
|
6
|
+
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const rootDir = resolve(__dirname, '..');
|
|
9
|
+
const cliTs = resolve(rootDir, 'cli.ts');
|
|
10
|
+
|
|
11
|
+
// Run the cli.ts file using tsx
|
|
12
|
+
const result = spawnSync('npx', ['tsx', cliTs, ...process.argv.slice(2)], {
|
|
13
|
+
stdio: 'inherit',
|
|
14
|
+
cwd: process.cwd()
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
process.exit(result.status ?? 0);
|
package/cli.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* cli.ts — BusinessKit Agent CLI
|
|
4
|
+
*
|
|
5
|
+
* Usage: npx businesskit-agent <agent> [command] [...args]
|
|
6
|
+
*
|
|
7
|
+
* Examples:
|
|
8
|
+
* npx businesskit-agent ceo
|
|
9
|
+
* npx businesskit-agent blog-writer create "My Post Title"
|
|
10
|
+
* npx businesskit-agent scheduler hourly
|
|
11
|
+
* npx businesskit-agent analytics-agent snapshot
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import 'dotenv/config'
|
|
15
|
+
|
|
16
|
+
const [, , agentName, command, ...args] = process.argv
|
|
17
|
+
|
|
18
|
+
const AGENTS: Record<string, string> = {
|
|
19
|
+
'ceo': 'csuite/ceo',
|
|
20
|
+
'cmo': 'csuite/cmo',
|
|
21
|
+
'coo': 'csuite/coo',
|
|
22
|
+
'cbo': 'csuite/cbo',
|
|
23
|
+
'blog-writer': 'creators/blog-writer',
|
|
24
|
+
'newsletter-writer': 'creators/newsletter-writer',
|
|
25
|
+
'copywriter': 'creators/copywriter',
|
|
26
|
+
'course-creator': 'creators/course-creator',
|
|
27
|
+
'store-manager': 'creators/store-manager',
|
|
28
|
+
'jobs-manager': 'creators/jobs-manager',
|
|
29
|
+
'forms-builder': 'creators/forms-builder',
|
|
30
|
+
'docs-writer': 'creators/docs-writer',
|
|
31
|
+
'crm': 'creators/crm-agent',
|
|
32
|
+
'crm-agent': 'creators/crm-agent',
|
|
33
|
+
'analytics-agent': 'growth/analytics-agent',
|
|
34
|
+
'seo-agent': 'growth/seo-agent',
|
|
35
|
+
'social-agent': 'growth/social-agent',
|
|
36
|
+
'scheduler': 'growth/scheduler',
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!agentName || agentName === 'help') {
|
|
40
|
+
printHelp()
|
|
41
|
+
process.exit(0)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const path = AGENTS[agentName.toLowerCase()]
|
|
45
|
+
if (!path) {
|
|
46
|
+
console.error(`\nUnknown agent: "${agentName}"`)
|
|
47
|
+
console.error('Run: npx businesskit-agent help\n')
|
|
48
|
+
process.exit(1)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const mod = await import(`./agents/${path}.ts`)
|
|
52
|
+
const exportKey = Object.keys(mod).find(k => typeof mod[k] === 'object' && mod[k] !== null)
|
|
53
|
+
const agent = exportKey ? mod[exportKey] : null
|
|
54
|
+
|
|
55
|
+
if (!agent) {
|
|
56
|
+
console.error(`Could not load agent: ${agentName}`)
|
|
57
|
+
process.exit(1)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const cmd = command ?? defaultCommand(agentName)
|
|
61
|
+
|
|
62
|
+
if (typeof agent[cmd] !== 'function') {
|
|
63
|
+
console.error(`\nAgent "${agentName}" has no command "${cmd}"`)
|
|
64
|
+
const methods = Object.getOwnPropertyNames(Object.getPrototypeOf(agent))
|
|
65
|
+
.filter(m => m !== 'constructor' && !m.startsWith('_') && typeof agent[m] === 'function')
|
|
66
|
+
console.error(`Available: ${methods.join(', ')}\n`)
|
|
67
|
+
process.exit(1)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
const result = await agent[cmd](...args)
|
|
72
|
+
if (result !== undefined) console.log(JSON.stringify(result, null, 2))
|
|
73
|
+
} catch (e) {
|
|
74
|
+
console.error('\nError:', e instanceof Error ? e.message : e)
|
|
75
|
+
process.exit(1)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function defaultCommand(name: string): string {
|
|
79
|
+
const defaults: Record<string, string> = {
|
|
80
|
+
'ceo': 'weeklyBriefing',
|
|
81
|
+
'cmo': 'contentCalendar',
|
|
82
|
+
'coo': 'draftPipeline',
|
|
83
|
+
'cbo': 'revenueReport',
|
|
84
|
+
'analytics-agent': 'snapshot',
|
|
85
|
+
'seo-agent': 'audit',
|
|
86
|
+
'scheduler': 'daily',
|
|
87
|
+
}
|
|
88
|
+
return defaults[name] ?? 'list'
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function printHelp() {
|
|
92
|
+
console.log(`
|
|
93
|
+
BusinessKit Agent CLI
|
|
94
|
+
|
|
95
|
+
Usage: npx businesskit-agent <agent> [command] [args]
|
|
96
|
+
|
|
97
|
+
C-Suite:
|
|
98
|
+
ceo Weekly briefing (revenue, traffic, priorities)
|
|
99
|
+
cmo Content calendar + growth strategy
|
|
100
|
+
coo Draft pipeline + publish queue
|
|
101
|
+
cbo Revenue report + pricing audit
|
|
102
|
+
|
|
103
|
+
Creators:
|
|
104
|
+
blog-writer List posts or create new (create "Title")
|
|
105
|
+
newsletter-writer Subscriber stats or send newsletter
|
|
106
|
+
copywriter List pages or create new
|
|
107
|
+
course-creator List courses
|
|
108
|
+
store-manager List products by type
|
|
109
|
+
jobs-manager List job listings
|
|
110
|
+
forms-builder List forms
|
|
111
|
+
docs-writer List articles
|
|
112
|
+
crm CRM contacts and pipeline
|
|
113
|
+
|
|
114
|
+
Growth:
|
|
115
|
+
analytics-agent Full analytics snapshot
|
|
116
|
+
seo-agent SEO audit across all content
|
|
117
|
+
social-agent Post content to social via n8n
|
|
118
|
+
scheduler Run publish queue (hourly|daily|weekly)
|
|
119
|
+
|
|
120
|
+
Setup:
|
|
121
|
+
npx tsx setup.ts Verify Turso connection
|
|
122
|
+
|
|
123
|
+
Requires TURSO_URL + TURSO_TOKEN in .env
|
|
124
|
+
`)
|
|
125
|
+
}
|
package/context/brand.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Brand Context
|
|
2
|
+
|
|
3
|
+
> Fill this in once. Agents read it on every session.
|
|
4
|
+
> The more specific you are, the better the output.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Business overview
|
|
9
|
+
<!-- What does your business do? Who is your customer? What problem do you solve?
|
|
10
|
+
Example:
|
|
11
|
+
I run an online education business helping freelance designers charge premium rates.
|
|
12
|
+
My customers are designers with 1-3 years experience who are stuck charging low rates.
|
|
13
|
+
-->
|
|
14
|
+
|
|
15
|
+
[Your business overview here]
|
|
16
|
+
|
|
17
|
+
## Brand voice
|
|
18
|
+
<!-- How do you sound? Pick 3-5 adjectives and explain what they mean in practice.
|
|
19
|
+
Example:
|
|
20
|
+
- Direct: I say what I mean. No fluff. Get to the point.
|
|
21
|
+
- Warm: I talk like a friend, not a corporation. Contractions are fine.
|
|
22
|
+
- Authoritative: I've done this. I cite real numbers and real experience.
|
|
23
|
+
- No hype: I don't use words like "amazing", "incredible", "game-changing"
|
|
24
|
+
-->
|
|
25
|
+
|
|
26
|
+
[Your brand voice here]
|
|
27
|
+
|
|
28
|
+
## What we never say
|
|
29
|
+
<!-- Words, phrases, or tones to avoid.
|
|
30
|
+
Example:
|
|
31
|
+
- Never say "delve" or "dive deep"
|
|
32
|
+
- Never use corporate jargon (synergy, leverage, utilize)
|
|
33
|
+
- Never start with "Great question!"
|
|
34
|
+
- Never use passive voice
|
|
35
|
+
- Never sign off with "Cheers" — use "Best,"
|
|
36
|
+
-->
|
|
37
|
+
|
|
38
|
+
[Your avoid list here]
|
|
39
|
+
|
|
40
|
+
## Target audience
|
|
41
|
+
<!-- Who reads your content? Be specific.
|
|
42
|
+
Example:
|
|
43
|
+
Freelance designers, 25-35, primarily based in US/UK/AU.
|
|
44
|
+
They are good at their craft but struggle with pricing, sales, and business.
|
|
45
|
+
They follow people like Paul Jarvis, Nathan Barry, and Justin Welsh.
|
|
46
|
+
-->
|
|
47
|
+
|
|
48
|
+
[Your audience here]
|
|
49
|
+
|
|
50
|
+
## Core topics we write about
|
|
51
|
+
<!-- What are your 5-7 main content pillars?
|
|
52
|
+
Example:
|
|
53
|
+
1. Pricing strategy for creatives
|
|
54
|
+
2. Client communication
|
|
55
|
+
3. Building a portfolio that converts
|
|
56
|
+
4. Freelance business operations
|
|
57
|
+
5. Personal branding for designers
|
|
58
|
+
-->
|
|
59
|
+
|
|
60
|
+
[Your content pillars here]
|
|
61
|
+
|
|
62
|
+
## Products and services
|
|
63
|
+
<!-- What do you sell? Include prices if relevant.
|
|
64
|
+
Example:
|
|
65
|
+
- Email Marketing Masterclass — $197 online course
|
|
66
|
+
- 1:1 Strategy Call — $250/hour
|
|
67
|
+
- Monthly coaching membership — $49/month
|
|
68
|
+
-->
|
|
69
|
+
|
|
70
|
+
[Your products here]
|
|
71
|
+
|
|
72
|
+
## Social presence
|
|
73
|
+
<!-- Where are you active? What performs well?
|
|
74
|
+
Example:
|
|
75
|
+
- LinkedIn: 8,200 followers, long-form posts perform best
|
|
76
|
+
- X/Twitter: 2,100 followers, threads and hot takes
|
|
77
|
+
- Newsletter: 1,400 subscribers, weekly, 42% open rate
|
|
78
|
+
-->
|
|
79
|
+
|
|
80
|
+
[Your social presence here]
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Business Context
|
|
2
|
+
|
|
3
|
+
> Keep this updated quarterly. Agents use it for CEO briefings and strategy.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Current goals (this quarter)
|
|
8
|
+
<!-- What are you trying to achieve in the next 90 days?
|
|
9
|
+
Example:
|
|
10
|
+
1. Reach $10k MRR
|
|
11
|
+
2. Grow newsletter to 2,000 subscribers
|
|
12
|
+
3. Launch the new course on pricing strategy
|
|
13
|
+
4. Hire a part-time VA
|
|
14
|
+
-->
|
|
15
|
+
|
|
16
|
+
[Your goals here]
|
|
17
|
+
|
|
18
|
+
## Current focus
|
|
19
|
+
<!-- What is the one thing you're working on right now?
|
|
20
|
+
Example:
|
|
21
|
+
Launching my email course by April 30. Everything else is secondary.
|
|
22
|
+
-->
|
|
23
|
+
|
|
24
|
+
[Your current focus here]
|
|
25
|
+
|
|
26
|
+
## Revenue model
|
|
27
|
+
<!-- How do you make money? What are your revenue streams?
|
|
28
|
+
Example:
|
|
29
|
+
- Courses: 60% of revenue
|
|
30
|
+
- Coaching: 30% of revenue
|
|
31
|
+
- Affiliate: 10% of revenue
|
|
32
|
+
Primary metric: monthly revenue. Target: $8k/month
|
|
33
|
+
-->
|
|
34
|
+
|
|
35
|
+
[Your revenue model here]
|
|
36
|
+
|
|
37
|
+
## Content publishing schedule
|
|
38
|
+
<!-- How often do you publish? On what channels?
|
|
39
|
+
Example:
|
|
40
|
+
- Blog: 2x per week (Monday, Thursday)
|
|
41
|
+
- Newsletter: every Tuesday
|
|
42
|
+
- LinkedIn: 3x per week
|
|
43
|
+
- Twitter: daily
|
|
44
|
+
-->
|
|
45
|
+
|
|
46
|
+
[Your publishing schedule here]
|
|
47
|
+
|
|
48
|
+
## Tools and integrations
|
|
49
|
+
<!-- What tools do you use that agents should know about?
|
|
50
|
+
Example:
|
|
51
|
+
- n8n: automation webhook at [URL]
|
|
52
|
+
- Notion: task board at [URL]
|
|
53
|
+
- Resend: email delivery
|
|
54
|
+
- Paddle: payments
|
|
55
|
+
-->
|
|
56
|
+
|
|
57
|
+
[Your tools here]
|
|
58
|
+
|
|
59
|
+
## Competitors and comparisons
|
|
60
|
+
<!-- Who are the main alternatives in your space?
|
|
61
|
+
Example:
|
|
62
|
+
Main competitors: Teachable, Podia, Gumroad
|
|
63
|
+
We're different because: we're built for creators who want to own their data
|
|
64
|
+
-->
|
|
65
|
+
|
|
66
|
+
[Your competitive context here]
|