@businesskit/agent 1.0.2 → 1.0.4
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/.claude/settings.json +16 -0
- package/.claude/settings.local.json +11 -0
- package/.claude-plugin/marketplace.json +36 -0
- package/.claude-plugin/plugin.json +7 -28
- package/.env.example +10 -0
- package/CLAUDE.md +56 -195
- package/HEARTBEAT.md +81 -57
- package/PLAN.md +211 -119
- package/PRD-Agent-Composition.md +149 -0
- package/README.md +25 -11
- package/REFERENCE.md +160 -0
- package/SOUL.md +31 -0
- package/SYSTEM.md +22 -0
- package/agents/_base.ts +352 -44
- package/agents/analytics/SOUL.md +11 -0
- package/agents/analytics/analytics.ts +405 -0
- package/agents/business/SOUL.md +11 -0
- package/agents/{csuite/cbo.ts → business/business.ts} +2 -2
- package/agents/ceo/SOUL.md +15 -0
- package/agents/{csuite → ceo}/ceo.ts +33 -8
- package/agents/content/SOUL.md +11 -0
- package/agents/content/content.ts +379 -0
- package/agents/copywriting/SOUL.md +11 -0
- package/agents/courses/SOUL.md +11 -0
- package/agents/courses/courses.ts +451 -0
- package/agents/docs/SOUL.md +11 -0
- package/agents/forms/SOUL.md +11 -0
- package/agents/forms/forms.ts +364 -0
- package/agents/hiring/SOUL.md +11 -0
- package/agents/hiring/hiring.ts +314 -0
- package/agents/marketing/SOUL.md +15 -0
- package/agents/{csuite/cmo.ts → marketing/marketing.ts} +3 -3
- package/agents/newsletter/SOUL.md +11 -0
- package/agents/operations/SOUL.md +11 -0
- package/agents/operations/operations.ts +157 -0
- package/agents/sales/SOUL.md +44 -0
- package/agents/sales/sales.ts +883 -0
- package/agents/scheduler/SOUL.md +11 -0
- package/agents/{growth → scheduler}/scheduler.ts +2 -2
- package/agents/seo/SOUL.md +11 -0
- package/agents/{growth/seo-agent.ts → seo/seo.ts} +60 -54
- package/agents/social/SOUL.md +11 -0
- package/agents/social/social.ts +744 -0
- package/agents/store/SOUL.md +11 -0
- package/agents/store/store.ts +514 -0
- package/cli.ts +44 -25
- package/lib/cms.ts +88 -0
- package/lib/db.ts +58 -11
- package/lib/enums.ts +25 -0
- package/lib/groups.ts +122 -0
- package/lib/id.ts +38 -10
- package/lib/profile.ts +44 -8
- package/lib/schema.ts +2015 -0
- package/lib/validate.ts +33 -0
- package/package.json +1 -1
- package/scripts/generate-schema.ts +244 -0
- package/setup.ts +16 -2
- package/{.agents/skills/analytics.md → skills/analytics/SKILL.md} +6 -1
- package/{.agents/skills/brand.md → skills/brand/SKILL.md} +14 -1
- package/skills/ceo/SKILL.md +25 -0
- package/skills/cmo/SKILL.md +8 -0
- package/skills/humanizer/SKILL.md +270 -0
- package/skills/schema/SKILL.md +86 -0
- package/tsconfig.json +2 -1
- package/.agents/skills/schema.md +0 -45
- package/.agents/skills/store.md +0 -46
- package/.claude/skills/agents.md +0 -56
- package/.claude/skills/analytics.md +0 -7
- package/.claude/skills/brand.md +0 -44
- package/.claude/skills/humanizer.md +0 -474
- package/.claude/skills/schema.md +0 -45
- package/agents/creators/blog-writer.ts +0 -347
- package/agents/creators/course-creator.ts +0 -106
- package/agents/creators/crm-agent.ts +0 -479
- package/agents/creators/forms-builder.ts +0 -90
- package/agents/creators/jobs-manager.ts +0 -82
- package/agents/creators/store-manager.ts +0 -138
- package/agents/csuite/coo.ts +0 -115
- package/agents/growth/analytics-agent.ts +0 -52
- package/agents/growth/social-agent.ts +0 -346
- /package/{ingest.md → .claude/commands/ingest.md} +0 -0
- /package/agents/{creators/copywriter.ts → copywriting/copywriting.ts} +0 -0
- /package/agents/{creators/docs-writer.ts → docs/docs.ts} +0 -0
- /package/agents/{creators/newsletter-writer.ts → newsletter/newsletter.ts} +0 -0
- /package/{ABOUT-ME.md → context/about-me.md} +0 -0
- /package/{brand-voice.md → context/brand-voice.md} +0 -0
- /package/{working-style.md → context/working-style.md} +0 -0
- /package/{.claude/skills → skills}/README.md +0 -0
- /package/{.agents/skills/agents.md → skills/agents/SKILL.md} +0 -0
- /package/{.claude/skills/blog-writing.md → skills/blog-writer/SKILL.md} +0 -0
- /package/{.claude/skills/store-copywriting.md → skills/copywriting/SKILL.md} +0 -0
- /package/{.claude/skills/social-content.md → skills/social/SKILL.md} +0 -0
- /package/{.claude/skills → skills/social}/content-seo.md +0 -0
- /package/{.claude/skills/store.md → skills/store/SKILL.md} +0 -0
package/lib/validate.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// lib/validate.ts
|
|
2
|
+
// Guard numeric fields before DB writes.
|
|
3
|
+
// DB triggers will reject out-of-bounds — catch early for clearer errors.
|
|
4
|
+
|
|
5
|
+
export function leadScore(n: number): number {
|
|
6
|
+
if (!Number.isFinite(n) || n < 0 || n > 100)
|
|
7
|
+
throw new Error(`lead_score must be 0–100, got ${n}`)
|
|
8
|
+
return Math.round(n)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function probability(n: number): number {
|
|
12
|
+
if (!Number.isFinite(n) || n < 0 || n > 100)
|
|
13
|
+
throw new Error(`probability must be 0–100, got ${n}`)
|
|
14
|
+
return Math.round(n)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function cents(n: number): number {
|
|
18
|
+
if (!Number.isFinite(n) || n < 0 || !Number.isInteger(n))
|
|
19
|
+
throw new Error(`cents must be non-negative integer, got ${n}`)
|
|
20
|
+
return n
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function hotScore(n: number): number {
|
|
24
|
+
if (!Number.isFinite(n) || n < 0)
|
|
25
|
+
throw new Error(`hot_score must be >= 0, got ${n}`)
|
|
26
|
+
return n
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function slug(s: string): string {
|
|
30
|
+
if (!s || s.length > 200)
|
|
31
|
+
throw new Error(`slug must be 1–200 chars, got "${s}"`)
|
|
32
|
+
return s.toLowerCase().replace(/[^a-z0-9-]/g, '-').replace(/-+/g, '-')
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@businesskit/agent",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Autonomous business agent team — CEO, CRM, Social, SEO, Blog Writer and more. Powered by your own Turso database. Works with Claude Code, Claude Cowork, Gemini CLI, and Codex.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* scripts/generate-schema.ts
|
|
4
|
+
*
|
|
5
|
+
* Parses `businesskit-files/*.ts` → emits `lib/schema.ts`.
|
|
6
|
+
*
|
|
7
|
+
* What it does:
|
|
8
|
+
* 1. Finds every `CREATE TABLE IF NOT EXISTS <name> ( ... )` in the schema files
|
|
9
|
+
* 2. Parses columns: name, SQL type, NOT NULL, DEFAULT
|
|
10
|
+
* 3. Detects enum values from the nearest `-- 'a'|'b'|'c'`-style comment
|
|
11
|
+
* on the same line or the next line
|
|
12
|
+
* 4. Emits one `export interface <PascalName>` per table + a `TABLES` const
|
|
13
|
+
*
|
|
14
|
+
* Run:
|
|
15
|
+
* npx tsx scripts/generate-schema.ts
|
|
16
|
+
*
|
|
17
|
+
* The output is intentionally conservative — when in doubt, the column type
|
|
18
|
+
* widens to `string | null`. Never hand-edit lib/schema.ts; regenerate.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { readFileSync, writeFileSync, readdirSync } from 'node:fs'
|
|
22
|
+
import { join, dirname } from 'node:path'
|
|
23
|
+
import { fileURLToPath } from 'node:url'
|
|
24
|
+
|
|
25
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
26
|
+
const REPO = join(__dirname, '..')
|
|
27
|
+
const SRC_DIR = join(REPO, 'businesskit-files')
|
|
28
|
+
const OUT = join(REPO, 'lib', 'schema.ts')
|
|
29
|
+
|
|
30
|
+
// ── Types ────────────────────────────────────────────────────────────────────
|
|
31
|
+
|
|
32
|
+
interface Column {
|
|
33
|
+
name: string
|
|
34
|
+
sqlType: string
|
|
35
|
+
notNull: boolean
|
|
36
|
+
hasDefault: boolean
|
|
37
|
+
enumValues: string[] // parsed from -- 'a'|'b'|'c' comments
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface Table {
|
|
41
|
+
name: string
|
|
42
|
+
columns: Column[]
|
|
43
|
+
sourceFile: string
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ── Parser ───────────────────────────────────────────────────────────────────
|
|
47
|
+
|
|
48
|
+
function extractCreateTables(source: string, sourceFile: string): Table[] {
|
|
49
|
+
const tables: Table[] = []
|
|
50
|
+
// CREATE TABLE IF NOT EXISTS name ( ... ) — match everything up to the closing
|
|
51
|
+
// paren that's followed by `,` or backtick (the template-string end).
|
|
52
|
+
const re = /CREATE TABLE IF NOT EXISTS\s+(\w+)\s*\(([\s\S]*?)\n\s*\)/g
|
|
53
|
+
|
|
54
|
+
let m: RegExpExecArray | null
|
|
55
|
+
while ((m = re.exec(source)) !== null) {
|
|
56
|
+
const name = m[1]
|
|
57
|
+
const body = m[2]
|
|
58
|
+
tables.push({ name, columns: parseColumns(body), sourceFile })
|
|
59
|
+
}
|
|
60
|
+
return tables
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function parseColumns(body: string): Column[] {
|
|
64
|
+
// Split on commas at depth 0 (SQLite col defs don't nest parens much,
|
|
65
|
+
// but constraints like CHECK(...) might; fold them conservatively).
|
|
66
|
+
const lines = splitTopLevelCommas(body)
|
|
67
|
+
const cols: Column[] = []
|
|
68
|
+
let pendingEnum: string[] = []
|
|
69
|
+
|
|
70
|
+
for (let raw of lines) {
|
|
71
|
+
raw = raw.trim()
|
|
72
|
+
if (!raw) continue
|
|
73
|
+
|
|
74
|
+
// Detect comment-only lines — they're enum hints for the PREVIOUS column
|
|
75
|
+
const commentOnly = raw.match(/^--\s*(.+)/)
|
|
76
|
+
if (commentOnly) {
|
|
77
|
+
const hinted = parseEnumComment(commentOnly[1])
|
|
78
|
+
if (hinted.length && cols.length) {
|
|
79
|
+
const last = cols[cols.length - 1]
|
|
80
|
+
if (!last.enumValues.length) last.enumValues = hinted
|
|
81
|
+
}
|
|
82
|
+
continue
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Skip table-level constraints (PRIMARY KEY (...), UNIQUE(...), FOREIGN KEY)
|
|
86
|
+
const upper = raw.toUpperCase()
|
|
87
|
+
if (/^(PRIMARY KEY|UNIQUE|FOREIGN KEY|CHECK|CONSTRAINT)\s*[(\s]/.test(upper)) continue
|
|
88
|
+
|
|
89
|
+
const col = parseColumnLine(raw)
|
|
90
|
+
if (!col) continue
|
|
91
|
+
|
|
92
|
+
// Same-line comment → enum values
|
|
93
|
+
if (pendingEnum.length) {
|
|
94
|
+
col.enumValues = pendingEnum
|
|
95
|
+
pendingEnum = []
|
|
96
|
+
}
|
|
97
|
+
const inline = raw.match(/--\s*(.+)$/)
|
|
98
|
+
if (inline) {
|
|
99
|
+
const vals = parseEnumComment(inline[1])
|
|
100
|
+
if (vals.length) col.enumValues = vals
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
cols.push(col)
|
|
104
|
+
}
|
|
105
|
+
return cols
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function parseColumnLine(line: string): Column | null {
|
|
109
|
+
// strip trailing comma and inline comment for type parsing
|
|
110
|
+
const codeOnly = line.replace(/--.*$/, '').trim().replace(/,$/, '').trim()
|
|
111
|
+
if (!codeOnly) return null
|
|
112
|
+
|
|
113
|
+
// name [type] [constraints]
|
|
114
|
+
const parts = codeOnly.split(/\s+/)
|
|
115
|
+
if (parts.length < 2) return null
|
|
116
|
+
const name = parts[0]
|
|
117
|
+
if (!/^\w+$/.test(name)) return null
|
|
118
|
+
|
|
119
|
+
const rest = parts.slice(1).join(' ')
|
|
120
|
+
const sqlType = (rest.match(/^(TEXT|INTEGER|REAL|BLOB|NUMERIC)/i)?.[1] ?? 'TEXT').toUpperCase()
|
|
121
|
+
const notNull = /\bNOT NULL\b/i.test(rest)
|
|
122
|
+
const hasDefault = /\bDEFAULT\b/i.test(rest)
|
|
123
|
+
|
|
124
|
+
return { name, sqlType, notNull, hasDefault, enumValues: [] }
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function parseEnumComment(text: string): string[] {
|
|
128
|
+
// Matches 'a'|'b'|'c' (with anything around it)
|
|
129
|
+
const matches = [...text.matchAll(/'([a-z0-9_-]+)'(?:\s*\|\s*'([a-z0-9_-]+)')+/gi)]
|
|
130
|
+
for (const m of matches) {
|
|
131
|
+
const raw = m[0]
|
|
132
|
+
const vals = [...raw.matchAll(/'([a-z0-9_-]+)'/gi)].map(x => x[1])
|
|
133
|
+
if (vals.length >= 2) return vals
|
|
134
|
+
}
|
|
135
|
+
return []
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function splitTopLevelCommas(body: string): string[] {
|
|
139
|
+
const out: string[] = []
|
|
140
|
+
let buf = ''
|
|
141
|
+
let depth = 0
|
|
142
|
+
let inString = false
|
|
143
|
+
for (const ch of body) {
|
|
144
|
+
if (ch === "'" ) inString = !inString
|
|
145
|
+
if (!inString) {
|
|
146
|
+
if (ch === '(') depth++
|
|
147
|
+
else if (ch === ')') depth--
|
|
148
|
+
else if (ch === ',' && depth === 0) { out.push(buf); buf = ''; continue }
|
|
149
|
+
}
|
|
150
|
+
buf += ch
|
|
151
|
+
}
|
|
152
|
+
if (buf.trim()) out.push(buf)
|
|
153
|
+
return out
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// ── Emitter ──────────────────────────────────────────────────────────────────
|
|
157
|
+
|
|
158
|
+
function sqlToTs(col: Column): string {
|
|
159
|
+
// Enum literal union takes priority over SQL type
|
|
160
|
+
if (col.enumValues.length) {
|
|
161
|
+
const union = col.enumValues.map(v => `'${v}'`).join(' | ')
|
|
162
|
+
return col.notNull || col.hasDefault ? union : `${union} | null`
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
let base: string
|
|
166
|
+
switch (col.sqlType) {
|
|
167
|
+
case 'INTEGER': base = 'number'; break
|
|
168
|
+
case 'REAL': base = 'number'; break
|
|
169
|
+
case 'TEXT': base = 'string'; break
|
|
170
|
+
case 'BLOB': base = 'Uint8Array'; break
|
|
171
|
+
case 'NUMERIC': base = 'number'; break
|
|
172
|
+
default: base = 'string'
|
|
173
|
+
}
|
|
174
|
+
// NOT NULL or has DEFAULT → reads are always defined
|
|
175
|
+
return col.notNull || col.hasDefault ? base : `${base} | null`
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function pascalCase(snake: string): string {
|
|
179
|
+
return snake.split('_').map(p => p ? p[0].toUpperCase() + p.slice(1) : '').join('')
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function emit(tables: Table[]): string {
|
|
183
|
+
const header = `// lib/schema.ts
|
|
184
|
+
// AUTO-GENERATED by scripts/generate-schema.ts — DO NOT EDIT.
|
|
185
|
+
// Source: businesskit-files/*.ts (copies of app-side schema).
|
|
186
|
+
// Regenerate: npm run schema:gen
|
|
187
|
+
//
|
|
188
|
+
// What this gives you:
|
|
189
|
+
// - One \`interface <PascalTable>\` per UserDB table
|
|
190
|
+
// - Enum literal unions for columns with \`-- 'a'|'b'|'c'\` comment hints
|
|
191
|
+
// - \`TABLES\` const for typo-safe table references
|
|
192
|
+
//
|
|
193
|
+
// Rows returned by libSQL's Client are \`Record<string, Value>\` — cast via
|
|
194
|
+
// \`as unknown as <Interface>\` at the call site after SELECT.
|
|
195
|
+
`
|
|
196
|
+
|
|
197
|
+
const groups = new Map<string, Table[]>()
|
|
198
|
+
for (const t of tables) {
|
|
199
|
+
const key = t.sourceFile
|
|
200
|
+
if (!groups.has(key)) groups.set(key, [])
|
|
201
|
+
groups.get(key)!.push(t)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const body = [...groups.entries()]
|
|
205
|
+
.map(([file, ts]) => {
|
|
206
|
+
const interfaces = ts.map(t => {
|
|
207
|
+
const fields = t.columns
|
|
208
|
+
.map(c => ` ${c.name}: ${sqlToTs(c)}`)
|
|
209
|
+
.join('\n')
|
|
210
|
+
return `export interface ${pascalCase(t.name)} {\n${fields}\n}`
|
|
211
|
+
}).join('\n\n')
|
|
212
|
+
return `// ── ${file} ${'─'.repeat(Math.max(0, 60 - file.length))}\n\n${interfaces}`
|
|
213
|
+
})
|
|
214
|
+
.join('\n\n')
|
|
215
|
+
|
|
216
|
+
const tableNames = tables.map(t => ` ${t.name}: '${t.name}' as const,`).join('\n')
|
|
217
|
+
const constBlock = `\nexport const TABLES = {\n${tableNames}\n}\n\nexport type TableName = keyof typeof TABLES\n`
|
|
218
|
+
|
|
219
|
+
return `${header}\n${body}\n${constBlock}`
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// ── Main ─────────────────────────────────────────────────────────────────────
|
|
223
|
+
|
|
224
|
+
function main() {
|
|
225
|
+
const files = readdirSync(SRC_DIR).filter(f => f.endsWith('.ts') && !f.endsWith('.md')).sort()
|
|
226
|
+
if (!files.length) {
|
|
227
|
+
console.error(`No schema files found in ${SRC_DIR}`)
|
|
228
|
+
process.exit(1)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const all: Table[] = []
|
|
232
|
+
for (const f of files) {
|
|
233
|
+
const src = readFileSync(join(SRC_DIR, f), 'utf8')
|
|
234
|
+
const tables = extractCreateTables(src, f)
|
|
235
|
+
all.push(...tables)
|
|
236
|
+
console.log(` ${f}: ${tables.length} tables`)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const out = emit(all)
|
|
240
|
+
writeFileSync(OUT, out, 'utf8')
|
|
241
|
+
console.log(`\nWrote ${OUT} — ${all.length} tables, ${all.reduce((a, t) => a + t.columns.length, 0)} columns.`)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
main()
|
package/setup.ts
CHANGED
|
@@ -71,15 +71,29 @@ try {
|
|
|
71
71
|
|
|
72
72
|
// ── Step 3: Profile exists ────────────────────────────────────────────────────
|
|
73
73
|
console.log('\n3. Loading your profile...')
|
|
74
|
+
const PROFILE_ID = env.PROFILE_ID || process.env.PROFILE_ID || ''
|
|
74
75
|
try {
|
|
75
|
-
const { rows } = await db.execute('SELECT id, slug, title FROM profiles
|
|
76
|
+
const { rows } = await db.execute('SELECT id, slug, title FROM profiles')
|
|
76
77
|
if (!rows.length) {
|
|
77
78
|
err('No profile found in your database')
|
|
78
79
|
dim('Complete BusinessKit onboarding at businesskit.io first')
|
|
79
80
|
dim('Then come back and run: npm run setup')
|
|
80
81
|
process.exit(1)
|
|
81
82
|
}
|
|
82
|
-
|
|
83
|
+
if (rows.length > 1 && !PROFILE_ID) {
|
|
84
|
+
err(`Found ${rows.length} profiles — set PROFILE_ID in .env to pick one:`)
|
|
85
|
+
for (const r of rows) dim(` ${r.id} (${r.title} @${r.slug})`)
|
|
86
|
+
process.exit(1)
|
|
87
|
+
}
|
|
88
|
+
const p = PROFILE_ID
|
|
89
|
+
? rows.find(r => r.id === PROFILE_ID)
|
|
90
|
+
: rows[0]
|
|
91
|
+
if (!p) {
|
|
92
|
+
err(`PROFILE_ID=${PROFILE_ID} not found in your database`)
|
|
93
|
+
dim('Available:')
|
|
94
|
+
for (const r of rows) dim(` ${r.id} (${r.title} @${r.slug})`)
|
|
95
|
+
process.exit(1)
|
|
96
|
+
}
|
|
83
97
|
ok(`Profile: ${p.title} (@${p.slug})`)
|
|
84
98
|
dim(`Profile ID: ${p.id}`)
|
|
85
99
|
} catch (e: any) {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
All analytics are stored as JSON in TEXT columns. Parse with JSON.parse().
|
|
6
6
|
|
|
7
7
|
### Time series arrays
|
|
8
|
+
|
|
8
9
|
```
|
|
9
10
|
analytics_7d = [n, n, n, n, n, n, n] → last 7 days, oldest first
|
|
10
11
|
analytics_30d = [n, n, ..., n] → last 30 days
|
|
@@ -13,6 +14,7 @@ analytics_24h = [n, n, ..., n] → last 24 hours (hourly)
|
|
|
13
14
|
```
|
|
14
15
|
|
|
15
16
|
### Lifetime object
|
|
17
|
+
|
|
16
18
|
```
|
|
17
19
|
analytics_lifetime = { "2026-03": 142, "2026-04": 89, ... }
|
|
18
20
|
revenue_lifetime = { "2026-03": 42000, "2026-04": 15000, ... }
|
|
@@ -20,6 +22,7 @@ revenue_lifetime = { "2026-03": 42000, "2026-04": 15000, ... }
|
|
|
20
22
|
```
|
|
21
23
|
|
|
22
24
|
### Breakdown objects (country, device, referrer)
|
|
25
|
+
|
|
23
26
|
```
|
|
24
27
|
country_clicks = { "US": 420, "GB": 88, "IN": 45, ... }
|
|
25
28
|
device_clicks = { "mobile": 312, "desktop": 201 }
|
|
@@ -34,6 +37,7 @@ referrer_clicks = { "twitter.com": 88, "direct": 204, ... }
|
|
|
34
37
|
**Social**: posts published, scheduled, accounts connected
|
|
35
38
|
|
|
36
39
|
## Revenue trend calculation
|
|
40
|
+
|
|
37
41
|
```ts
|
|
38
42
|
const months = Object.entries(revenue_lifetime).sort()
|
|
39
43
|
const last = months.slice(-1)[0]?.[1] ?? 0
|
|
@@ -42,6 +46,7 @@ const trend = prior > 0 ? ((last - prior) / prior * 100).toFixed(1) + '%' : 'N/
|
|
|
42
46
|
```
|
|
43
47
|
|
|
44
48
|
## Never write to analytics tables
|
|
49
|
+
|
|
45
50
|
Analytics are updated by the app on user actions (clicks, purchases).
|
|
46
51
|
Agents read analytics. The app writes analytics. Never reverse this.
|
|
47
|
-
Exception: seed a product_analytics or link_analytics row when creating a new product/link.
|
|
52
|
+
Exception: seed a product_analytics or link_analytics row when creating a new product/link.
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brand
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
type: brand
|
|
5
|
+
load_when: see table in CLAUDE.md
|
|
6
|
+
---
|
|
7
|
+
|
|
1
8
|
# Brand Context + Voice
|
|
2
9
|
|
|
3
10
|
## Load brand context before writing ANY content
|
|
@@ -18,7 +25,9 @@ const { profile, settings } = await getBrandContext()
|
|
|
18
25
|
| `settings.site_title` | Override brand name if set |
|
|
19
26
|
|
|
20
27
|
### Tone consistency check
|
|
28
|
+
|
|
21
29
|
Before writing a blog post, check the last 3 published posts and match the reading level and style:
|
|
30
|
+
|
|
22
31
|
```ts
|
|
23
32
|
const recent = await blogWriter.listPublished('posts', 3)
|
|
24
33
|
// Read titles + excerpts — match that voice
|
|
@@ -35,6 +44,7 @@ const recent = await blogWriter.listPublished('posts', 3)
|
|
|
35
44
|
**Never** write content that contradicts `profile.bio`. Don't switch voice between pieces.
|
|
36
45
|
|
|
37
46
|
**Always**:
|
|
47
|
+
|
|
38
48
|
- Include a clear CTA
|
|
39
49
|
- Write excerpt/meta description separately from the body — it's for search engines + previews
|
|
40
50
|
- Keep titles under 60 characters for SEO
|
|
@@ -61,6 +71,7 @@ const recent = await blogWriter.listPublished('posts', 3)
|
|
|
61
71
|
---
|
|
62
72
|
|
|
63
73
|
## What good writing looks like
|
|
74
|
+
|
|
64
75
|
- First sentence: lead with the outcome or the surprise — never wind up to it
|
|
65
76
|
- Short sentences. Vary the rhythm.
|
|
66
77
|
- One idea per paragraph
|
|
@@ -70,6 +81,7 @@ const recent = await blogWriter.listPublished('posts', 3)
|
|
|
70
81
|
- Scannable: bullet points, bold key phrases, clear H2s
|
|
71
82
|
|
|
72
83
|
## What bad writing looks like — delete on sight
|
|
84
|
+
|
|
73
85
|
- "Delve into" / "dive deep" — never
|
|
74
86
|
- "In today's fast-paced world" — delete the whole sentence
|
|
75
87
|
- "It's important to note that" — delete it
|
|
@@ -80,8 +92,9 @@ const recent = await blogWriter.listPublished('posts', 3)
|
|
|
80
92
|
- Generic opener: "In this article, we will..." — start with the point
|
|
81
93
|
|
|
82
94
|
## Channel-specific tone
|
|
95
|
+
|
|
83
96
|
- Blog → authoritative but approachable
|
|
84
97
|
- Newsletter → warmest voice, most personal
|
|
85
98
|
- Social → punchy, direct, no filler
|
|
86
99
|
- Product copy → outcome-first, specific, no hype
|
|
87
|
-
- Job listings → honest about culture, specific about role
|
|
100
|
+
- Job listings → honest about culture, specific about role
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ceo
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
type: specialty
|
|
5
|
+
load_when: weekly briefing, business overview, pending approvals, revenue pulse, priorities
|
|
6
|
+
description: Run the CEO agent — weekly business briefing, pending approvals, revenue pulse, priorities.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Run the CEO agent for this BusinessKit business.
|
|
10
|
+
|
|
11
|
+
Load HEARTBEAT.md for current business state (one read, no extra DB calls).
|
|
12
|
+
Check agent_memory for last session context.
|
|
13
|
+
Load context/business.md only if doing strategic planning.
|
|
14
|
+
|
|
15
|
+
Deliver:
|
|
16
|
+
|
|
17
|
+
1. Revenue and subscriber pulse (from HEARTBEAT snapshot)
|
|
18
|
+
2. Pending approvals that need owner decision
|
|
19
|
+
3. Top 3 priorities for this week
|
|
20
|
+
4. Any flags or issues
|
|
21
|
+
|
|
22
|
+
Push a briefing to agent_reports when done.
|
|
23
|
+
Log to agent_memory.
|
|
24
|
+
|
|
25
|
+
See: agents/csuite/ceo.ts for full implementation.
|