@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,316 @@
|
|
|
1
|
+
# BusinessKit Agent — PRD: Agent Harness & Domain Workflows
|
|
2
|
+
|
|
3
|
+
> Inspired by ep6-agent-harness from theaiautomators/claude-code-agentic-rag-series.
|
|
4
|
+
> Adapted for BusinessKit: profile-isolated, Turso-powered, Cloudflare Workers compatible.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## The Core Insight
|
|
9
|
+
|
|
10
|
+
> "The model is commoditized. Structured enforcement of process is where value lives."
|
|
11
|
+
|
|
12
|
+
A domain harness **guarantees** every step completes and validates before advancing.
|
|
13
|
+
The LLM executes within each phase but **cannot skip, reorder, or bypass phases**.
|
|
14
|
+
|
|
15
|
+
For BusinessKit this means:
|
|
16
|
+
|
|
17
|
+
- A blog post always gets SEO-checked before publishing
|
|
18
|
+
- A product always gets copy-reviewed before going live
|
|
19
|
+
- A newsletter always confirms subscriber count before sending
|
|
20
|
+
- A job listing always gets a description quality check before posting
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Two Layers
|
|
25
|
+
|
|
26
|
+
### Layer 1 — Deep Mode (LLM controls flow)
|
|
27
|
+
|
|
28
|
+
User activates Deep Mode → CEO/CMO/COO agents plan via todo list, execute multi-step tasks, delegate to sub-agents, ask user for clarification mid-task. The LLM decides the order.
|
|
29
|
+
|
|
30
|
+
### Layer 2 — Domain Harness (system controls flow)
|
|
31
|
+
|
|
32
|
+
A backend state machine drives deterministic phase transitions with validation gates.
|
|
33
|
+
LLM executes within each phase. The **system** advances phases — not the LLM.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Part 1: Deep Mode
|
|
38
|
+
|
|
39
|
+
### Feature 1.1: Deep Mode Activation
|
|
40
|
+
|
|
41
|
+
Per-session flag. When active:
|
|
42
|
+
|
|
43
|
+
- Agents gain planning tools (todo list)
|
|
44
|
+
- Session workspace becomes available (`progress.md` + per-run files)
|
|
45
|
+
- CEO can delegate to sub-agents (Blog Writer, Store Manager, etc.)
|
|
46
|
+
- Agents can pause and ask the user for clarification
|
|
47
|
+
|
|
48
|
+
When OFF: current behavior unchanged. No overhead.
|
|
49
|
+
|
|
50
|
+
### Feature 1.2: Planning (Todos)
|
|
51
|
+
|
|
52
|
+
CEO/CMO/COO write a structured todo list at the start of complex tasks.
|
|
53
|
+
Updated in real-time as steps complete. User sees plan progressing.
|
|
54
|
+
|
|
55
|
+
**Pattern:**
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
1. [CEO] Read analytics snapshot via Analytics Agent
|
|
59
|
+
2. [CEO] Identify top 3 priorities from briefing
|
|
60
|
+
3. [CMO] Generate 4-week content calendar
|
|
61
|
+
4. [Blog Writer] Draft post #1 from calendar
|
|
62
|
+
5. [SEO Agent] Audit post #1
|
|
63
|
+
6. [COO] Schedule post #1 for Monday 9am
|
|
64
|
+
7. [Social Agent] Queue social distribution
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Feature 1.3: Session Workspace (`progress.md`)
|
|
68
|
+
|
|
69
|
+
Per-session file that agents write to after significant actions.
|
|
70
|
+
Next session reads it first — solving the "start from zero every time" problem.
|
|
71
|
+
|
|
72
|
+
```markdown
|
|
73
|
+
## 2026-03-22 — CEO Session
|
|
74
|
+
- Revenue: $4,200 last 30d (+18% trend)
|
|
75
|
+
- Published: "How to Build a Newsletter" (blake, post_id: 01JXXX)
|
|
76
|
+
- Scheduled: "Course Launch" for 2026-03-25 (product_id: 01JYYY)
|
|
77
|
+
- SEO issues found: 3 posts missing excerpts → SCOUT to fix next session
|
|
78
|
+
- Priority next: launch webinar product, PEARL newsletter on Thursday
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Stored locally as `progress.md` in the repo root.
|
|
82
|
+
**Not in Turso** — this is agent working memory, not business data.
|
|
83
|
+
|
|
84
|
+
### Feature 1.4: Sub-Agent Delegation
|
|
85
|
+
|
|
86
|
+
CEO can delegate to any other agent with isolated context:
|
|
87
|
+
|
|
88
|
+
- Clean context per sub-agent (no full history passed)
|
|
89
|
+
- Shared `progress.md` workspace
|
|
90
|
+
- Results returned as tool result to CEO
|
|
91
|
+
- Failure isolated — parent continues
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
CEO delegates to Blog Writer:
|
|
95
|
+
task("Write a blog post about email marketing tips", {
|
|
96
|
+
brand_context: profile.bio,
|
|
97
|
+
existing_posts: last 3 titles for tone matching
|
|
98
|
+
})
|
|
99
|
+
→ Blog Writer drafts, saves to progress.md
|
|
100
|
+
→ Result returned to CEO
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Feature 1.5: Ask User (Mid-Task Clarification)
|
|
104
|
+
|
|
105
|
+
Agent pauses and asks a specific question before continuing.
|
|
106
|
+
Used when: ambiguous brief, missing required field, approval needed before publishing.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Part 2: Domain Harness Engine
|
|
111
|
+
|
|
112
|
+
### Phase Types
|
|
113
|
+
|
|
114
|
+
| Type | Description | Used for |
|
|
115
|
+
|---|---|---|
|
|
116
|
+
| `programmatic` | Pure TS, no LLM. Data fetching, validation. | Load analytics, check word count |
|
|
117
|
+
| `llm_single` | Single LLM call, structured JSON output | Brand voice check, SEO scoring |
|
|
118
|
+
| `llm_agent` | Multi-round agent loop with tools | Write full blog post, generate course outline |
|
|
119
|
+
| `llm_batch` | Parallel sub-agents per item | Audit multiple products, check multiple links |
|
|
120
|
+
| `llm_human_input` | Pause for user clarification | Confirm publish, approve price |
|
|
121
|
+
|
|
122
|
+
### Harness State Machine
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
PENDING → RUNNING (phase 1)
|
|
126
|
+
→ phase complete + validation pass → RUNNING (phase 2)
|
|
127
|
+
→ phase complete + validation pass → RUNNING (phase 3)
|
|
128
|
+
→ ...
|
|
129
|
+
→ all phases complete → COMPLETED
|
|
130
|
+
→ any validation fail → FAILED (with reason)
|
|
131
|
+
→ user paused → PAUSED → resume → RUNNING
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The system drives phase transitions. LLM cannot jump ahead.
|
|
135
|
+
|
|
136
|
+
### Workspace-Based Context Passing
|
|
137
|
+
|
|
138
|
+
Phases read from and write to named workspace files — not inline dumps:
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
phase 1 writes: analytics-snapshot.md
|
|
142
|
+
phase 2 reads: analytics-snapshot.md → writes: content-priorities.md
|
|
143
|
+
phase 3 reads: content-priorities.md → writes: blog-draft.md
|
|
144
|
+
phase 4 reads: blog-draft.md → writes: seo-report.md
|
|
145
|
+
phase 5 reads: blog-draft.md + seo-report.md → publishes post
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Part 3: BusinessKit Domain Harnesses
|
|
151
|
+
|
|
152
|
+
### Harness 1: Publish Blog Post
|
|
153
|
+
|
|
154
|
+
**Trigger:** `/blog-writer publish` or "publish my draft post"
|
|
155
|
+
|
|
156
|
+
**Phases:**
|
|
157
|
+
|
|
158
|
+
| # | Name | Type | Reads | Writes | Validation |
|
|
159
|
+
|---|---|---|---|---|---|
|
|
160
|
+
| 1 | Load Draft | `programmatic` | posts table (published=0) | `draft.md` | Must have title + content |
|
|
161
|
+
| 2 | Brand Check | `llm_single` | `draft.md` + profile.bio | `brand-check.md` | Score ≥ 7/10 or flag for review |
|
|
162
|
+
| 3 | SEO Check | `llm_single` | `draft.md` | `seo-report.md` | Title ≤60 chars, excerpt exists |
|
|
163
|
+
| 4 | Auto-Fix SEO | `llm_agent` | `draft.md` + `seo-report.md` | `draft-v2.md` | Runs only if SEO issues found |
|
|
164
|
+
| 5 | Confirm | `llm_human_input` | `draft-v2.md` + `seo-report.md` | `publish-intent.md` | User confirms or requests changes |
|
|
165
|
+
| 6 | Publish | `programmatic` | `publish-intent.md` | posts table (published=1) | Row updated successfully |
|
|
166
|
+
| 7 | Social Queue | `llm_agent` | `draft-v2.md` + profile.social_links | n8n / direct API | Social Agent fires for each platform |
|
|
167
|
+
|
|
168
|
+
**Guarantee:** No post goes live without brand check + SEO check + user confirm.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
### Harness 2: Launch Product to Store
|
|
173
|
+
|
|
174
|
+
**Trigger:** `/store-manager launch` or "launch my product"
|
|
175
|
+
|
|
176
|
+
**Phases:**
|
|
177
|
+
|
|
178
|
+
| # | Name | Type | Reads | Writes | Validation |
|
|
179
|
+
|---|---|---|---|---|---|
|
|
180
|
+
| 1 | Load Draft | `programmatic` | products table (published=0) | `product.md` | title, price_cents, type required |
|
|
181
|
+
| 2 | Copy Review | `llm_single` | `product.md` + profile.bio | `copy-report.md` | description ≥150 words, excerpt ≤160 chars |
|
|
182
|
+
| 3 | Improve Copy | `llm_agent` | `product.md` + `copy-report.md` | `product-v2.md` | Only if copy issues found |
|
|
183
|
+
| 4 | Price Check | `llm_single` | `product-v2.md` + product_analytics | `pricing-report.md` | Flags if price = $0 or unusually high |
|
|
184
|
+
| 5 | Confirm | `llm_human_input` | `product-v2.md` + `pricing-report.md` | `launch-intent.md` | User confirms price + description |
|
|
185
|
+
| 6 | Launch | `programmatic` | `launch-intent.md` | products table (published=1) | Row + analytics seed updated |
|
|
186
|
+
| 7 | Announce | `llm_agent` | `product-v2.md` | Social Agent | Posts launch announcement |
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
### Harness 3: Send Newsletter
|
|
191
|
+
|
|
192
|
+
**Trigger:** `/newsletter-writer send` or "send this week's newsletter"
|
|
193
|
+
|
|
194
|
+
**Phases:**
|
|
195
|
+
|
|
196
|
+
| # | Name | Type | Reads | Writes | Validation |
|
|
197
|
+
|---|---|---|---|---|---|
|
|
198
|
+
| 1 | Audience Check | `programmatic` | subscribers table | `audience.md` | Must have ≥1 subscriber |
|
|
199
|
+
| 2 | Draft Review | `llm_single` | user input + profile.bio | `newsletter-draft.md` | Subject ≤60 chars, body ≥200 words |
|
|
200
|
+
| 3 | Personalization | `llm_agent` | `newsletter-draft.md` + `audience.md` | `newsletter-final.md` | Add first-name token, preview text |
|
|
201
|
+
| 4 | Confirm Send | `llm_human_input` | `newsletter-final.md` + `audience.md` | `send-intent.md` | Show: subject, subscriber count, confirm |
|
|
202
|
+
| 5 | Send | `programmatic` | `send-intent.md` + credentials (SES/Resend) | delivery report | API call succeeds |
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
### Harness 4: Weekly CEO Briefing (Autonomous)
|
|
207
|
+
|
|
208
|
+
**Trigger:** Cron (`0 8 * * 1`) via Scheduler, or `/ceo brief`
|
|
209
|
+
|
|
210
|
+
**Phases:**
|
|
211
|
+
|
|
212
|
+
| # | Name | Type | Reads | Writes |
|
|
213
|
+
|---|---|---|---|---|
|
|
214
|
+
| 1 | Analytics Pull | `programmatic` | All analytics tables | `analytics.md` |
|
|
215
|
+
| 2 | Content Inventory | `programmatic` | posts, products, jobs, forms tables | `inventory.md` |
|
|
216
|
+
| 3 | Revenue Analysis | `llm_single` | `analytics.md` | `revenue-report.md` |
|
|
217
|
+
| 4 | Priority Setting | `llm_single` | `analytics.md` + `inventory.md` + `revenue-report.md` | `priorities.md` |
|
|
218
|
+
| 5 | Briefing Write | `llm_agent` | all above | `briefing.md` |
|
|
219
|
+
| 6 | Deliver | `programmatic` | `briefing.md` + credentials.n8n_webhook_url | n8n → email/Slack |
|
|
220
|
+
| 7 | Update Progress | `programmatic` | `briefing.md` | `progress.md` |
|
|
221
|
+
|
|
222
|
+
**Phase 3 runs autonomously with no user present (Phase 3: CF Workflows)**
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
### Harness 5: Post Job Listing
|
|
227
|
+
|
|
228
|
+
**Trigger:** `/jobs-manager post`
|
|
229
|
+
|
|
230
|
+
| # | Name | Type | Validates |
|
|
231
|
+
|---|---|---|---|
|
|
232
|
+
| 1 | Load Draft | `programmatic` | title, company, description required |
|
|
233
|
+
| 2 | Description Check | `llm_single` | ≥200 words, requirements section present |
|
|
234
|
+
| 3 | Improve Description | `llm_agent` | Only if quality score <7 |
|
|
235
|
+
| 4 | Confirm | `llm_human_input` | Show preview, user approves |
|
|
236
|
+
| 5 | Publish | `programmatic` | published=1 in job_listings |
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Part 4: Session Memory (`progress.md`)
|
|
241
|
+
|
|
242
|
+
Persistent working memory across sessions. Not business data — agent scratch pad.
|
|
243
|
+
|
|
244
|
+
### Format
|
|
245
|
+
|
|
246
|
+
```markdown
|
|
247
|
+
# BusinessKit Agent Progress
|
|
248
|
+
|
|
249
|
+
## Last updated: {ISO timestamp}
|
|
250
|
+
## Business: {profile.title}
|
|
251
|
+
|
|
252
|
+
## Recent actions
|
|
253
|
+
- {timestamp}: Published "{title}" (blog post, id: {id})
|
|
254
|
+
- {timestamp}: Launched "{title}" (product, $XX, id: {id})
|
|
255
|
+
- {timestamp}: Sent newsletter "{subject}" to {N} subscribers
|
|
256
|
+
|
|
257
|
+
## Open items
|
|
258
|
+
- 3 posts missing SEO excerpts → run /seo to fix
|
|
259
|
+
- Course "Advanced Email Marketing" has 0 sales → price review needed
|
|
260
|
+
- Job listing "Senior Designer" expires {date}
|
|
261
|
+
|
|
262
|
+
## Last briefing summary (CEO)
|
|
263
|
+
- Revenue last 30d: $X (+Y% trend)
|
|
264
|
+
- Top product: "{title}" — $Z revenue
|
|
265
|
+
- Traffic: N clicks, top country: US
|
|
266
|
+
|
|
267
|
+
## Scheduled content
|
|
268
|
+
- {title} → publishes {date} (post)
|
|
269
|
+
- {title} → publishes {date} (product)
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Rules
|
|
273
|
+
|
|
274
|
+
- Agents append to it — never overwrite the full file
|
|
275
|
+
- CEO reads it at the start of every briefing
|
|
276
|
+
- Stored in repo root as `progress.md`
|
|
277
|
+
- Added to `.gitignore` (personal working memory, not for GitHub)
|
|
278
|
+
- Re-created fresh if deleted
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Part 5: Implementation Roadmap
|
|
283
|
+
|
|
284
|
+
### Phase 1 (Now — this repo)
|
|
285
|
+
|
|
286
|
+
- [x] 16 agents with direct Turso access
|
|
287
|
+
- [x] `cli.ts` universal entry point
|
|
288
|
+
- [x] `progress.md` pattern documented in CLAUDE.md
|
|
289
|
+
- [ ] Deep Mode slash command (`/deep`) in `.claude/commands/`
|
|
290
|
+
- [ ] `progress.md` write helper in `lib/`
|
|
291
|
+
|
|
292
|
+
### Phase 2 (In-app, Qwik + CF Worker)
|
|
293
|
+
|
|
294
|
+
- [ ] Harness engine as a Qwik `routeAction$`
|
|
295
|
+
- [ ] Phase state machine in `src/lib/harness/`
|
|
296
|
+
- [ ] Real-time phase progress via CF Queue or SSE
|
|
297
|
+
- [ ] Plan Panel in dashboard UI (shows harness phases)
|
|
298
|
+
|
|
299
|
+
### Phase 3 (Autonomous, CF Workflows + Durable Objects)
|
|
300
|
+
|
|
301
|
+
- [ ] Weekly CEO briefing harness on cron
|
|
302
|
+
- [ ] Scheduler as Durable Object
|
|
303
|
+
- [ ] Harness run state stored in Turso (not DO RAM)
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## Design Rules
|
|
308
|
+
|
|
309
|
+
- **Harness controls phases, LLM executes within them** — never reverse
|
|
310
|
+
- **Workspace files for context passing** — no inline dumps between phases
|
|
311
|
+
- **Validation before advancing** — no phase skipping on failure, surface the error
|
|
312
|
+
- **progress.md for cross-session memory** — not Turso, not disk cache, just a file
|
|
313
|
+
- **profile_id on every DB write** — same rule as all agents
|
|
314
|
+
- **No hard deletes** — harness sets hidden=1 on cleanup, never DELETE
|
|
315
|
+
- **Idempotent phases** — safe to re-run a phase if interrupted
|
|
316
|
+
- **User confirm before any irreversible action** — publish, send, post to social
|
package/README.md
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# BusinessKit Agent
|
|
2
|
+
|
|
3
|
+
Your autonomous business team — CEO, CMO, COO, CBO, Blog Writer, Course Creator, Store Manager, Newsletter Writer, CRM Agent, Social Agent, SEO Agent, Analytics Agent, and more.
|
|
4
|
+
|
|
5
|
+
Reads and writes directly to your Turso database. Works with Claude Code, Claude Cowork, Gemini CLI, Codex, and any terminal.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Setup
|
|
10
|
+
|
|
11
|
+
**Step 1 — Clone and install**
|
|
12
|
+
```bash
|
|
13
|
+
git clone https://github.com/businesskit-io/businesskit-agent
|
|
14
|
+
cd businesskit-agent
|
|
15
|
+
npm install
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
**Step 2 — Add credentials**
|
|
19
|
+
```bash
|
|
20
|
+
cp .env.example .env
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Open `.env`. Paste your Turso credentials from **BusinessKit → Settings → Credentials**:
|
|
24
|
+
```
|
|
25
|
+
TURSO_URL=libsql://your-db.turso.io
|
|
26
|
+
TURSO_TOKEN=your-auth-token
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Step 3 — Verify**
|
|
30
|
+
```bash
|
|
31
|
+
npm run setup
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
You'll see your business name confirmed. If not, check your `.env`.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## How to use
|
|
39
|
+
|
|
40
|
+
### Claude Code
|
|
41
|
+
Open this folder. Type any slash command:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
/ceo /cmo /coo /cbo
|
|
45
|
+
/blog-writer /newsletter-writer /copywriter
|
|
46
|
+
/course-creator /store-manager /jobs-manager
|
|
47
|
+
/forms-builder /docs-writer
|
|
48
|
+
/crm /social /analytics /seo
|
|
49
|
+
/scheduler /deep
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Claude Cowork
|
|
53
|
+
Install the BusinessKit plugin. Same commands, runs in your browser.
|
|
54
|
+
|
|
55
|
+
### Terminal
|
|
56
|
+
```bash
|
|
57
|
+
npx tsx cli.ts ceo
|
|
58
|
+
npx tsx cli.ts blog-writer
|
|
59
|
+
npx tsx cli.ts crm
|
|
60
|
+
npx tsx cli.ts social
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Agents
|
|
66
|
+
|
|
67
|
+
### C-Suite
|
|
68
|
+
| Command | Does |
|
|
69
|
+
|---|---|
|
|
70
|
+
| `/ceo` | Weekly briefing — revenue, traffic, priorities, cross-agent orchestration |
|
|
71
|
+
| `/cmo` | 4-week content calendar, content gap analysis, growth recommendations |
|
|
72
|
+
| `/coo` | Publish queue, draft pipeline, scheduling oversight |
|
|
73
|
+
| `/cbo` | Revenue report, pricing audit, upsell strategy |
|
|
74
|
+
|
|
75
|
+
### Content
|
|
76
|
+
| Command | Does | Writes to |
|
|
77
|
+
|---|---|---|
|
|
78
|
+
| `/blog-writer` | 8 content formats: listicle, how-to, checklist, QA, versus, roundup, news, ultimate guide | `posts`, `compare`, `alternative`, `prompt`, `notes`, `guides` |
|
|
79
|
+
| `/newsletter-writer` | Write and send newsletters | `newsletter` + SES/Resend |
|
|
80
|
+
| `/copywriter` | Landing pages, product descriptions, profile bio | `pages`, `products` |
|
|
81
|
+
| `/course-creator` | Courses with lessons | `products` (type=course) |
|
|
82
|
+
| `/store-manager` | Downloads, meetings, webinars, events, listings, sponsorships, services | `products` |
|
|
83
|
+
| `/jobs-manager` | Job listings and applications | `job_listings` |
|
|
84
|
+
| `/forms-builder` | Forms with questions and analytics | `forms`, `questions` |
|
|
85
|
+
| `/docs-writer` | Knowledge base articles | `doc_collections`, `doc_articles` |
|
|
86
|
+
|
|
87
|
+
### CRM (agent-first)
|
|
88
|
+
```
|
|
89
|
+
/crm
|
|
90
|
+
```
|
|
91
|
+
> "Add a lead: Sarah Chen, LinkedIn @sarahchen, founder at TechCo"
|
|
92
|
+
> "Show my top 10 leads by score"
|
|
93
|
+
> "Draft a DM for my hottest lead"
|
|
94
|
+
> "Show who replied to my outreach"
|
|
95
|
+
> "Create a $5,000 deal for John"
|
|
96
|
+
> "What tasks are due today?"
|
|
97
|
+
> "Show pending approvals"
|
|
98
|
+
|
|
99
|
+
Agent drives the full pipeline: research → enrich → score → draft DM → approve → send → follow-up.
|
|
100
|
+
Every DM/email draft waits for your approval before sending (unless you set `auto_approve=1`).
|
|
101
|
+
|
|
102
|
+
### Social (agent-first, powered by Zernio)
|
|
103
|
+
```
|
|
104
|
+
/social
|
|
105
|
+
```
|
|
106
|
+
> "Post my latest blog post to LinkedIn and X"
|
|
107
|
+
> "Announce my new course on all platforms"
|
|
108
|
+
> "Schedule a post for Monday 9am"
|
|
109
|
+
> "Show my unread DMs and comments"
|
|
110
|
+
> "How are my accounts performing?"
|
|
111
|
+
|
|
112
|
+
Posts to 13 platforms via [Zernio API](https://zernio.com). Reads your connected accounts from Turso. Writes `social_posts` + `social_post_platforms` on every action.
|
|
113
|
+
|
|
114
|
+
**Requires:** Zernio API key saved in BusinessKit → Settings → Credentials (BYOK).
|
|
115
|
+
Free-tier users: use the dashboard → posting is capped at 20/month via the platform key.
|
|
116
|
+
|
|
117
|
+
### Growth
|
|
118
|
+
| Command | Does |
|
|
119
|
+
|---|---|
|
|
120
|
+
| `/analytics` | Full snapshot: revenue, traffic, top products, link clicks |
|
|
121
|
+
| `/seo` | Audit all content for SEO issues, fix titles/descriptions, content gap analysis, LLM visibility tracking |
|
|
122
|
+
| `/scheduler` | Run publish queue, manage scheduled content |
|
|
123
|
+
|
|
124
|
+
### Deep Mode
|
|
125
|
+
```
|
|
126
|
+
/deep
|
|
127
|
+
```
|
|
128
|
+
CEO reads memory, checks analytics, writes a plan, delegates to the full team. Hand off your weekly business work entirely.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Memory — synced across machines
|
|
133
|
+
|
|
134
|
+
Agent memory is stored in your Turso database (`memory_log` table, max 20 rows). Not a local file — synced everywhere.
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
import { sessionContext } from './lib/memory.ts'
|
|
138
|
+
const { memory, skills } = await sessionContext()
|
|
139
|
+
// memory: last 20 agent actions
|
|
140
|
+
// skills: your brand voice, SEO rules, store guidelines
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Skills — live in Turso, editable from dashboard
|
|
146
|
+
|
|
147
|
+
Agent skills (brand voice, SEO rules, store pricing) live in `agent_skills` table. Edit them in **BusinessKit → Dashboard → Agent Skills** and agents pick them up immediately — no file changes needed.
|
|
148
|
+
|
|
149
|
+
Default skills seeded on first run:
|
|
150
|
+
- `brand-voice` — your tone, style, what to avoid
|
|
151
|
+
- `seo` — target keywords, internal linking rules
|
|
152
|
+
- `store` — pricing guidelines, product naming
|
|
153
|
+
- `analytics` — how to interpret your data
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Content formats (Blog Writer)
|
|
158
|
+
|
|
159
|
+
Inspired by SEObot's approach — each format has a specific structure and word count target:
|
|
160
|
+
|
|
161
|
+
| Format | Min words | Best for |
|
|
162
|
+
|---|---|---|
|
|
163
|
+
| `listicle` | 2000 | "Top 10 X" — high traffic |
|
|
164
|
+
| `how-to` | 2000 | "How to X" — high search intent |
|
|
165
|
+
| `ultimate-guide` | 3000 | Definitive resource — best for LLM citations |
|
|
166
|
+
| `checklist` | 1200 | Practical checklists |
|
|
167
|
+
| `qa` | 1500 | FAQ articles — long-tail keywords |
|
|
168
|
+
| `versus` | 2000 | "X vs Y" — high buying intent → `compare` table |
|
|
169
|
+
| `roundup` | 2000 | "Best X" — affiliate/referral traffic |
|
|
170
|
+
| `news` | 800 | Timely coverage with cited sources |
|
|
171
|
+
| `programmatic` | 1000 | Template-based SEO at scale |
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## LLM Visibility (SEO Agent)
|
|
176
|
+
|
|
177
|
+
The SEO agent tracks whether ChatGPT, Claude, Gemini, and Perplexity mention your brand. Strategy: publish comprehensive, well-cited content that LLMs reference.
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
/seo → "Check my LLM visibility"
|
|
181
|
+
/seo → "What content gaps do I have?"
|
|
182
|
+
/seo → "Audit my SEO"
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Social credentials
|
|
188
|
+
|
|
189
|
+
Go to **BusinessKit → Settings → Credentials** and add your Zernio API key:
|
|
190
|
+
|
|
191
|
+
| Credential | What |
|
|
192
|
+
|---|---|
|
|
193
|
+
| Zernio API key | Enables posting to all 13 platforms |
|
|
194
|
+
|
|
195
|
+
Alternatively connect platforms in **BusinessKit → Settings → Social** using the Zernio OAuth flow.
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Requirements
|
|
200
|
+
|
|
201
|
+
- Node.js 18+
|
|
202
|
+
- BusinessKit account with Turso connected
|
|
203
|
+
- Zernio API key (optional, for social posting)
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Works with
|
|
208
|
+
|
|
209
|
+
| Tool | How |
|
|
210
|
+
|---|---|
|
|
211
|
+
| Claude Code | `/` slash commands in `.claude/commands/` |
|
|
212
|
+
| Claude Cowork | Plugin at claude.com/plugins |
|
|
213
|
+
| Gemini CLI | Reads `GEMINI.md` automatically |
|
|
214
|
+
| Codex | Reads `AGENTS.md` automatically |
|
|
215
|
+
| Cursor | Reads `.cursorrules` automatically |
|
|
216
|
+
| Any terminal | `npx tsx cli.ts <agent>` |
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Architecture
|
|
221
|
+
|
|
222
|
+
```
|
|
223
|
+
Your Turso DB (you own it)
|
|
224
|
+
↑
|
|
225
|
+
lib/db.ts, lib/memory.ts, lib/profile.ts
|
|
226
|
+
↑
|
|
227
|
+
agents/_base.ts (profile isolation enforced on every query)
|
|
228
|
+
↑
|
|
229
|
+
agents/csuite/ agents/creators/ agents/growth/
|
|
230
|
+
↑
|
|
231
|
+
.claude/commands/ (slash commands — Claude Code + Cowork)
|
|
232
|
+
.agents/skills/ (universal skills — all tools)
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Phase 1 (now): local repo — Claude Code + Cowork + terminal
|
|
236
|
+
Phase 2 (next): in-app MCP server on Cloudflare Worker
|
|
237
|
+
Phase 3 (later): autonomous cron via Cloudflare Durable Objects
|
package/SYSTEM.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# BusinessKit Agent System
|
|
2
|
+
|
|
3
|
+
You are an autonomous business agent for a creator running their business on BusinessKit.
|
|
4
|
+
|
|
5
|
+
Your job is to get real business work done efficiently. Not to demonstrate capability. Not to be thorough for its own sake. To actually help someone run their business with minimal friction.
|
|
6
|
+
|
|
7
|
+
## Core constraint
|
|
8
|
+
|
|
9
|
+
Every token costs money. Every unnecessary step wastes the user's time. Be direct. Be efficient. Do the work. Ask only when genuinely blocked.
|
|
10
|
+
|
|
11
|
+
## You have access to
|
|
12
|
+
|
|
13
|
+
- The user's Turso database (all their business data)
|
|
14
|
+
- 17 specialized agents you can delegate to
|
|
15
|
+
- Skills loaded on demand — only load what the current task needs
|
|
16
|
+
- agent_memory, agent_notes, agent_kb, agent_reports — all persistent
|
|
17
|
+
|
|
18
|
+
## How to work
|
|
19
|
+
|
|
20
|
+
**Do first, report after.** Don't narrate what you're about to do. Do it, then say what you did.
|
|
21
|
+
|
|
22
|
+
**Load skills on demand.** Don't load all skills at start. Load only what the task requires:
|
|
23
|
+
|
|
24
|
+
- Writing content → load brand-voice skill
|
|
25
|
+
- SEO work → load seo skill
|
|
26
|
+
- Store/pricing → load store skill
|
|
27
|
+
- Reading analytics → load analytics skill
|
|
28
|
+
|
|
29
|
+
**Push reports to Turso.** Any significant output (briefing, audit, research, analysis) goes to `agent_reports` table immediately. Never lose work to session end.
|
|
30
|
+
|
|
31
|
+
**Use agent_memory.** Log actions after completion. Session start: read memory to know what happened last time.
|
|
32
|
+
|
|
33
|
+
**Use agent_notes inbox.** If user drops something without a clear instruction, add it to agent_notes with status='inbox'. Don't ask what to do with it — the agent processes it periodically.
|
|
34
|
+
|
|
35
|
+
## When to ask
|
|
36
|
+
|
|
37
|
+
Only ask when you genuinely cannot proceed without the answer. Examples of when NOT to ask:
|
|
38
|
+
|
|
39
|
+
- "Should I publish this?" → Draft it, show it, let them say go
|
|
40
|
+
- "What tone should I use?" → Read profile.bio and match it
|
|
41
|
+
- "Which platforms?" → Check social_accounts table, post to all connected ones
|
|
42
|
+
|
|
43
|
+
One question at a time if you must ask. Never a list of clarifying questions.
|
|
44
|
+
|
|
45
|
+
## Cost awareness
|
|
46
|
+
|
|
47
|
+
Prefer reading the index before loading full content.
|
|
48
|
+
Prefer summary columns before loading content columns.
|
|
49
|
+
Prefer one DB query that returns what you need over multiple queries.
|
package/agents/_base.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { db } from '../lib/db.ts'
|
|
2
|
+
import { getBrandContext, type BrandContext } from '../lib/profile.ts'
|
|
3
|
+
import { ulid, now, iso } from '../lib/id.ts'
|
|
4
|
+
import type { Client } from '@libsql/client'
|
|
5
|
+
|
|
6
|
+
/** Singleton Turso client — agents may import `db` for raw queries */
|
|
7
|
+
export { db, ulid, now, iso }
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* BaseAgent — extend this for every agent.
|
|
11
|
+
*
|
|
12
|
+
* Provides:
|
|
13
|
+
* - this.ctx → BrandContext (profile, settings, credentials)
|
|
14
|
+
* - this.profileId → enforced on every write
|
|
15
|
+
* - this.userId → from profile
|
|
16
|
+
* - this.archive() → soft delete (hidden=1) for any table
|
|
17
|
+
* - this.publish() → flip published=1 for any table
|
|
18
|
+
* - this.count() → content inventory for any table
|
|
19
|
+
*/
|
|
20
|
+
export abstract class BaseAgent {
|
|
21
|
+
protected ctx!: BrandContext
|
|
22
|
+
protected db: Client
|
|
23
|
+
|
|
24
|
+
constructor(injectedDB?: Client) {
|
|
25
|
+
this.db = injectedDB ?? db
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Call at the start of any agent method that needs the DB */
|
|
29
|
+
protected async init() {
|
|
30
|
+
if (!this.ctx) this.ctx = await getBrandContext(this.db)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
protected get profileId() { return this.ctx.profile.id }
|
|
34
|
+
protected get userId() { return this.ctx.profile.user_id }
|
|
35
|
+
|
|
36
|
+
/** Soft delete — never hard delete */
|
|
37
|
+
protected async archive(table: string, id: string | number) {
|
|
38
|
+
const ts = typeof id === 'number'
|
|
39
|
+
? `updated_at='${iso()}'`
|
|
40
|
+
: `updated_at=${now()}`
|
|
41
|
+
await this.db.execute({ sql: `UPDATE ${table} SET hidden=1,${ts} WHERE id=?`, args: [id] })
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Publish any content row */
|
|
45
|
+
protected async publish(table: string, id: string | number) {
|
|
46
|
+
const ts = typeof id === 'number'
|
|
47
|
+
? `updated_at='${iso()}'`
|
|
48
|
+
: `updated_at=${now()}`
|
|
49
|
+
await this.db.execute({ sql: `UPDATE ${table} SET published=1,${ts} WHERE id=?`, args: [id] })
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Quick inventory: { total, live, drafts } */
|
|
53
|
+
protected async count(table: string) {
|
|
54
|
+
const { rows: [r] } = await this.db.execute({
|
|
55
|
+
sql: `SELECT COUNT(*) total,
|
|
56
|
+
SUM(CASE WHEN published=1 AND hidden=0 THEN 1 ELSE 0 END) live,
|
|
57
|
+
SUM(CASE WHEN published=0 AND hidden=0 THEN 1 ELSE 0 END) drafts
|
|
58
|
+
FROM ${table} WHERE profile_id=?`,
|
|
59
|
+
args: [this.profileId],
|
|
60
|
+
})
|
|
61
|
+
return { total: Number(r?.total ?? 0), live: Number(r?.live ?? 0), drafts: Number(r?.drafts ?? 0) }
|
|
62
|
+
}
|
|
63
|
+
}
|