@businesskit/agent 1.0.4 → 1.0.7
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-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +25 -0
- package/.cursorrules +10 -0
- package/.superconsole-plugin/plugin.json +62 -0
- package/AGENTS.md +105 -63
- package/CLAUDE.md +11 -84
- package/GEMINI.md +11 -34
- package/README.md +95 -154
- package/assets/logo.svg +3 -0
- package/bin/businesskit.js +45 -18
- package/commands/add-contact.md +47 -0
- package/commands/add-inventory-from-invoice.md +80 -0
- package/commands/adjust-stock.md +46 -0
- package/commands/brief.md +12 -0
- package/commands/capabilities.md +33 -0
- package/commands/chase.md +12 -0
- package/commands/check-stock.md +43 -0
- package/commands/create-component.md +109 -0
- package/commands/create-invoice.md +69 -0
- package/commands/create-new-bill.md +65 -0
- package/commands/create-page.md +124 -0
- package/commands/crm.md +13 -0
- package/commands/followups.md +13 -0
- package/commands/list-components.md +41 -0
- package/commands/list-content.md +46 -0
- package/commands/list-pages.md +45 -0
- package/commands/pipeline.md +13 -0
- package/commands/publish-page.md +64 -0
- package/commands/send-invoice.md +42 -0
- package/commands/seo-audit.md +36 -0
- package/commands/update-agent.md +33 -0
- package/commands/update-contact.md +46 -0
- package/commands/update-content.md +48 -0
- package/commands/update-page.md +56 -0
- package/commands/update-price.md +47 -0
- package/commands/write-blog.md +56 -0
- package/commands/write-docs.md +90 -0
- package/commands/write-guide.md +51 -0
- package/commands/write-newsletter.md +50 -0
- package/dist/server.js +4099 -0
- package/mcp_config.json +12 -0
- package/package.json +54 -25
- package/plugin.json +32 -0
- package/scripts/setup.sh +169 -0
- package/scripts/setup.ts +129 -0
- package/scripts/update.sh +56 -0
- package/server.json +21 -0
- package/skills/README.md +20 -27
- package/skills/billing/SKILL.md +64 -0
- package/skills/brand/SKILL.md +30 -86
- package/skills/cms/SKILL.md +111 -0
- package/skills/cms/references/cms-hubs.md +84 -0
- package/skills/cms/references/html-blocks.md +177 -0
- package/skills/copywriting/SKILL.md +1 -1
- package/skills/crm/SKILL.md +24 -0
- package/skills/docs/SKILL.md +65 -0
- package/skills/docs/references/how-to.md +155 -0
- package/skills/inbox/SKILL.md +49 -0
- package/skills/inventory/SKILL.md +69 -0
- package/skills/pages/SKILL.md +214 -0
- package/skills/pages/references/sections-catalog.json +1183 -0
- package/skills/social/SKILL.md +84 -211
- package/skills/social/evals/evals.json +66 -0
- package/skills/social/evals/rubric.md +26 -0
- package/skills/social/examples/repurposing-blog-to-social.md +93 -0
- package/skills/social/examples/weekly-content-calendar.md +30 -0
- package/skills/social/linkedin/SKILL.md +107 -0
- package/skills/social/linkedin/evals/evals.json +106 -0
- package/skills/social/linkedin/evals/rubric.md +28 -0
- package/skills/social/linkedin/examples/gasp-weekly-sprint.md +24 -0
- package/skills/social/linkedin/examples/growth-posts-by-format.md +140 -0
- package/skills/social/linkedin/references/gasp-funnel-and-calibration.md +90 -0
- package/skills/social/linkedin/references/six-growth-formats.md +114 -0
- package/skills/social/references/platforms.md +76 -0
- package/skills/social/references/post-templates.md +105 -0
- package/skills/social/references/reverse-engineering.md +62 -0
- package/src/data/sections-catalog.json +950 -0
- package/src/db.ts +170 -0
- package/src/server.ts +75 -0
- package/src/tools/content.ts +326 -0
- package/src/tools/crm.ts +1416 -0
- package/src/tools/domains.ts +89 -0
- package/src/tools/inbox.ts +270 -0
- package/src/tools/index.ts +116 -0
- package/src/tools/pages.ts +1217 -0
- package/src/tools/shop.ts +771 -0
- package/src/tools/system.ts +94 -0
- package/src/tools/types.ts +17 -0
- package/templates/antigravity.json +8 -0
- package/templates/claude-code.mcp.json +8 -0
- package/templates/cursor.mcp.json +8 -0
- package/templates/vscode.mcp.json +9 -0
- package/.claude/commands/analytics.md +0 -7
- package/.claude/commands/blog-writer.md +0 -9
- package/.claude/commands/cbo.md +0 -7
- package/.claude/commands/ceo.md +0 -10
- package/.claude/commands/cmo.md +0 -7
- package/.claude/commands/compress.md +0 -73
- package/.claude/commands/coo.md +0 -11
- package/.claude/commands/copywriter.md +0 -15
- package/.claude/commands/course-creator.md +0 -9
- package/.claude/commands/crm.md +0 -591
- package/.claude/commands/deep.md +0 -50
- package/.claude/commands/docs-writer.md +0 -8
- package/.claude/commands/forms-builder.md +0 -10
- package/.claude/commands/ingest.md +0 -110
- package/.claude/commands/jobs-manager.md +0 -8
- package/.claude/commands/kb.md +0 -107
- package/.claude/commands/newsletter-writer.md +0 -9
- package/.claude/commands/preserve.md +0 -64
- package/.claude/commands/resume.md +0 -67
- package/.claude/commands/scheduler.md +0 -8
- package/.claude/commands/seo.md +0 -60
- package/.claude/commands/social.md +0 -51
- package/.claude/commands/store-manager.md +0 -11
- package/.claude/settings.json +0 -16
- package/.claude/settings.local.json +0 -11
- package/.env.example +0 -12
- package/.mcp.json +0 -3
- package/HEARTBEAT.md +0 -105
- package/PLAN.md +0 -345
- package/PRD-Agent-Composition.md +0 -149
- package/PRD-Agent-Harness.md +0 -316
- package/REFERENCE.md +0 -160
- package/SOUL.md +0 -148
- package/SYSTEM.md +0 -71
- package/agents/_base.ts +0 -371
- package/agents/analytics/SOUL.md +0 -11
- package/agents/analytics/analytics.ts +0 -405
- package/agents/business/SOUL.md +0 -11
- package/agents/business/business.ts +0 -109
- package/agents/ceo/SOUL.md +0 -15
- package/agents/ceo/ceo.ts +0 -146
- package/agents/content/SOUL.md +0 -11
- package/agents/content/content.ts +0 -379
- package/agents/copywriting/SOUL.md +0 -11
- package/agents/copywriting/copywriting.ts +0 -89
- package/agents/courses/SOUL.md +0 -11
- package/agents/courses/courses.ts +0 -451
- package/agents/docs/SOUL.md +0 -11
- package/agents/docs/docs.ts +0 -77
- package/agents/forms/SOUL.md +0 -11
- package/agents/forms/forms.ts +0 -364
- package/agents/hiring/SOUL.md +0 -11
- package/agents/hiring/hiring.ts +0 -314
- package/agents/marketing/SOUL.md +0 -15
- package/agents/marketing/marketing.ts +0 -109
- package/agents/newsletter/SOUL.md +0 -11
- package/agents/newsletter/newsletter.ts +0 -91
- package/agents/operations/SOUL.md +0 -11
- package/agents/operations/operations.ts +0 -157
- package/agents/sales/SOUL.md +0 -44
- package/agents/sales/sales.ts +0 -883
- package/agents/scheduler/SOUL.md +0 -11
- package/agents/scheduler/scheduler.ts +0 -68
- package/agents/seo/SOUL.md +0 -11
- package/agents/seo/seo.ts +0 -288
- package/agents/social/SOUL.md +0 -11
- package/agents/social/social.ts +0 -744
- package/agents/store/SOUL.md +0 -11
- package/agents/store/store.ts +0 -514
- package/cli.ts +0 -144
- package/context/about-me.md +0 -96
- package/context/brand-voice.md +0 -127
- package/context/brand.md +0 -80
- package/context/business.md +0 -66
- package/context/working-style.md +0 -87
- package/lib/analytics.ts +0 -81
- package/lib/cms.ts +0 -88
- package/lib/db.adapter.ts +0 -30
- package/lib/db.ts +0 -63
- package/lib/enums.ts +0 -25
- package/lib/groups.ts +0 -122
- package/lib/id.ts +0 -43
- package/lib/kb.ts +0 -337
- package/lib/memory.ts +0 -219
- package/lib/pattern-detector.ts +0 -169
- package/lib/profile.ts +0 -155
- package/lib/schema.ts +0 -2015
- package/lib/slug.ts +0 -30
- package/lib/validate.ts +0 -33
- package/setup.ts +0 -141
- package/skills/agents/SKILL.md +0 -56
- package/skills/analytics/SKILL.md +0 -52
- package/skills/blog-writer/SKILL.md +0 -452
- package/skills/ceo/SKILL.md +0 -25
- package/skills/cmo/SKILL.md +0 -8
- package/skills/schema/SKILL.md +0 -86
- package/skills/store/SKILL.md +0 -62
- package/tsconfig.json +0 -14
package/PLAN.md
DELETED
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
# BusinessKit Agent — Master Build Plan
|
|
2
|
-
|
|
3
|
-
> One-man army. Autonomous. Profile-isolated. Turso-powered.
|
|
4
|
-
> Built to run locally (Phase 1), in-app via MCP (Phase 2), autonomous on CF Workflows (Phase 3).
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## The Mental Model
|
|
9
|
-
|
|
10
|
-
```
|
|
11
|
-
profile_id = one business = one isolated universe
|
|
12
|
-
Every agent operates within exactly one profile.
|
|
13
|
-
All reads/writes are scoped to profile_id. No exceptions.
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
**Store** = all digital commerce:
|
|
17
|
-
digital downloads, courses, 1:1 meetings, webinars, events, listings, sponsorships, services.
|
|
18
|
-
These all live in the `products` table under different `type` values.
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## Agent Roster
|
|
23
|
-
|
|
24
|
-
### C-Suite (Intelligence + Strategy)
|
|
25
|
-
|
|
26
|
-
| Title | Folder / File | Role |
|
|
27
|
-
|---|---|---|
|
|
28
|
-
| CEO | `agents/ceo/ceo.ts` | Weekly briefing, cross-agent orchestration, priority setting |
|
|
29
|
-
| Marketing (CMO) | `agents/marketing/marketing.ts` | Campaign strategy, content calendar, growth recommendations |
|
|
30
|
-
| Operations (COO) | `agents/operations/operations.ts` | Content pipeline, publish queue, scheduling oversight |
|
|
31
|
-
| Business (CBO) | `agents/business/business.ts` | Revenue analysis, product strategy, pricing recommendations |
|
|
32
|
-
|
|
33
|
-
### Content Creators
|
|
34
|
-
|
|
35
|
-
| Title | Folder / File | Writes to |
|
|
36
|
-
|---|---|---|
|
|
37
|
-
| Sales (CRM) | `agents/sales/sales.ts` | `crm_*` — contacts, deals, activities, proposals, invoices |
|
|
38
|
-
| Content (Blog Writer) | `agents/content/content.ts` | `posts`, `compare`, `alternative`, `prompt`, `notes`, `guides` |
|
|
39
|
-
| Newsletter | `agents/newsletter/newsletter.ts` | `subscribers` + email via SES/Resend |
|
|
40
|
-
| Copywriting | `agents/copywriting/copywriting.ts` | `pages`, `products.description`, `links` |
|
|
41
|
-
| Courses | `agents/courses/courses.ts` | `products` (type=course) + lessons JSON |
|
|
42
|
-
| Store | `agents/store/store.ts` | `products` (downloads, services, webinars, events, listings, sponsorships, meetings) |
|
|
43
|
-
| Hiring | `agents/hiring/hiring.ts` | `job_listings` + `job_applications` |
|
|
44
|
-
| Forms | `agents/forms/forms.ts` | `forms` + `questions` |
|
|
45
|
-
| Docs | `agents/docs/docs.ts` | `doc_collections` + `doc_articles` |
|
|
46
|
-
|
|
47
|
-
### Growth & Intelligence
|
|
48
|
-
|
|
49
|
-
| Title | Folder / File | Role |
|
|
50
|
-
|---|---|---|
|
|
51
|
-
| SEO | `agents/seo/seo.ts` | `collections`, slugs, meta, OG tags |
|
|
52
|
-
| Analytics | `agents/analytics/analytics.ts` | All analytics tables — reads only, never writes |
|
|
53
|
-
| Social | `agents/social/social.ts` | `credentials.n8n_webhook_url` → social platforms |
|
|
54
|
-
| Scheduler | `agents/scheduler/scheduler.ts` | `published=0 + date <= now()` → flips published=1 |
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## Current Repository Structure
|
|
59
|
-
|
|
60
|
-
One folder per agent. Each folder has `SOUL.md` (identity + rules) + `<agent>.ts` (implementation).
|
|
61
|
-
|
|
62
|
-
```
|
|
63
|
-
businesskit-agent/ ← repo root
|
|
64
|
-
│
|
|
65
|
-
├── .claude-plugin/
|
|
66
|
-
│ ├── plugin.json
|
|
67
|
-
│ └── marketplace.json
|
|
68
|
-
│
|
|
69
|
-
├── .claude/
|
|
70
|
-
│ ├── commands/ ← slash-command bodies (user-facing names kept stable)
|
|
71
|
-
│ │ ├── analytics.md blog-writer.md cbo.md
|
|
72
|
-
│ │ ├── ceo.md cmo.md compress.md
|
|
73
|
-
│ │ ├── coo.md copywriter.md course-creator.md
|
|
74
|
-
│ │ ├── crm.md deep.md docs-writer.md
|
|
75
|
-
│ │ ├── forms-builder.md ingest.md jobs-manager.md
|
|
76
|
-
│ │ ├── kb.md newsletter-writer.md
|
|
77
|
-
│ │ ├── preserve.md resume.md scheduler.md
|
|
78
|
-
│ │ ├── seo.md social.md store-manager.md
|
|
79
|
-
│ │ └── settings.json
|
|
80
|
-
│ └── skills/ ← auto-loaded skills (see also top-level skills/)
|
|
81
|
-
│
|
|
82
|
-
├── agents/ ← one folder per agent, SOUL.md + <agent>.ts
|
|
83
|
-
│ ├── _base.ts ← BaseAgent — profile iso, idempotency, txn, audit
|
|
84
|
-
│ │
|
|
85
|
-
│ ├── ceo/ SOUL.md + ceo.ts
|
|
86
|
-
│ ├── marketing/ SOUL.md + marketing.ts (CMO role)
|
|
87
|
-
│ ├── operations/ SOUL.md + operations.ts (COO role)
|
|
88
|
-
│ ├── business/ SOUL.md + business.ts (CBO role)
|
|
89
|
-
│ ├── sales/ SOUL.md + sales.ts (CRM pipeline)
|
|
90
|
-
│ │
|
|
91
|
-
│ ├── content/ SOUL.md + content.ts (blog writer)
|
|
92
|
-
│ ├── newsletter/ SOUL.md + newsletter.ts
|
|
93
|
-
│ ├── copywriting/ SOUL.md + copywriting.ts
|
|
94
|
-
│ ├── courses/ SOUL.md + courses.ts
|
|
95
|
-
│ ├── store/ SOUL.md + store.ts
|
|
96
|
-
│ ├── hiring/ SOUL.md + hiring.ts (job listings)
|
|
97
|
-
│ ├── forms/ SOUL.md + forms.ts
|
|
98
|
-
│ ├── docs/ SOUL.md + docs.ts
|
|
99
|
-
│ │
|
|
100
|
-
│ ├── analytics/ SOUL.md + analytics.ts
|
|
101
|
-
│ ├── seo/ SOUL.md + seo.ts
|
|
102
|
-
│ ├── social/ SOUL.md + social.ts
|
|
103
|
-
│ └── scheduler/ SOUL.md + scheduler.ts
|
|
104
|
-
│
|
|
105
|
-
├── bin/
|
|
106
|
-
│ └── businesskit.js
|
|
107
|
-
│
|
|
108
|
-
├── context/ ← Brand Foundation — fill in once
|
|
109
|
-
│ ├── about-me.md
|
|
110
|
-
│ ├── brand-voice.md
|
|
111
|
-
│ ├── brand.md
|
|
112
|
-
│ ├── business.md
|
|
113
|
-
│ └── working-style.md
|
|
114
|
-
│
|
|
115
|
-
├── lib/
|
|
116
|
-
│ ├── analytics.ts ← analytics summaries
|
|
117
|
-
│ ├── db.adapter.ts ← Phase 1↔2 swap point
|
|
118
|
-
│ ├── db.ts ← Turso client, withRetry, txn, reader/writer split (P0-2, P0-3, P1-4)
|
|
119
|
-
│ ├── enums.ts ← single source of truth for status strings (P0-5)
|
|
120
|
-
│ ├── groups.ts ← crm_contact_groups junction helpers (P0-4)
|
|
121
|
-
│ ├── id.ts ← ulid, iso, now, generateIdempotencyKey (P0-1)
|
|
122
|
-
│ ├── kb.ts ← KB query helpers
|
|
123
|
-
│ ├── memory.ts ← dual-write agent_memory + memory.md
|
|
124
|
-
│ ├── pattern-detector.ts ← Hermes skill-detection
|
|
125
|
-
│ ├── profile.ts ← BrandContext loader
|
|
126
|
-
│ ├── slug.ts ← slug utilities
|
|
127
|
-
│ └── validate.ts ← numeric bounds guards (P0-8)
|
|
128
|
-
│
|
|
129
|
-
├── skills/ ← on-demand domain skills
|
|
130
|
-
│ ├── agents/SKILL.md ← load for routing decisions
|
|
131
|
-
│ ├── analytics/SKILL.md ← load when reading analytics
|
|
132
|
-
│ ├── blog-writer/SKILL.md
|
|
133
|
-
│ ├── brand/SKILL.md ← load when writing content
|
|
134
|
-
│ ├── ceo/SKILL.md
|
|
135
|
-
│ ├── cmo/SKILL.md
|
|
136
|
-
│ ├── copywriting/SKILL.md
|
|
137
|
-
│ ├── humanizer/SKILL.md
|
|
138
|
-
│ ├── sales/ ← reserved (empty)
|
|
139
|
-
│ ├── schema/SKILL.md ← load for DB queries
|
|
140
|
-
│ ├── social/{SKILL.md, content-seo.md}
|
|
141
|
-
│ └── store/SKILL.md
|
|
142
|
-
│
|
|
143
|
-
├── memory/ ← per-session state (gitignored)
|
|
144
|
-
├── .cursorrules .env.example .gitignore .mcp.json
|
|
145
|
-
├── AGENTS.md CLAUDE.md GEMINI.md HEARTBEAT.md
|
|
146
|
-
├── PLAN.md PRD-Agent-Composition.md PRD-Agent-Harness.md
|
|
147
|
-
├── README.md REFERENCE.md SOUL.md SYSTEM.md
|
|
148
|
-
├── cli.ts setup.ts memory.md
|
|
149
|
-
├── package.json package-lock.json tsconfig.json
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
---
|
|
153
|
-
|
|
154
|
-
## Skills vs Commands
|
|
155
|
-
|
|
156
|
-
| Location | What | When it runs |
|
|
157
|
-
|---|---|---|
|
|
158
|
-
| `.claude/skills/` | Background knowledge — schema, brand, store types, analytics patterns | Auto-loaded on every conversation |
|
|
159
|
-
| `.claude/commands/` | Step-by-step task instructions per agent | Only when user types `/command-name` |
|
|
160
|
-
|
|
161
|
-
Skills are **passive context**. Commands are **active triggers**.
|
|
162
|
-
|
|
163
|
-
---
|
|
164
|
-
|
|
165
|
-
## Phase 1 — Local Repo ✅ Complete
|
|
166
|
-
|
|
167
|
-
**Goal**: Users clone → drop in `.env` → run any agent via Claude Code, Cowork, or terminal.
|
|
168
|
-
|
|
169
|
-
```bash
|
|
170
|
-
git clone https://github.com/businesskit/businesskit-agent
|
|
171
|
-
cd businesskit-agent
|
|
172
|
-
npm install
|
|
173
|
-
cp .env.example .env # paste TURSO_URL + TURSO_TOKEN from BusinessKit dashboard
|
|
174
|
-
npm run setup # verify connection
|
|
175
|
-
# Open in Claude Code → type /ceo for first briefing
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
**CLI**:
|
|
179
|
-
|
|
180
|
-
```bash
|
|
181
|
-
npx tsx cli.ts ceo # CEO weekly briefing
|
|
182
|
-
npx tsx cli.ts blog-writer # list posts
|
|
183
|
-
npx tsx cli.ts scheduler hourly # run publish queue
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
**Delivered**:
|
|
187
|
-
|
|
188
|
-
- [x] `CLAUDE.md` — full schema, brand rules, agent roster
|
|
189
|
-
- [x] `lib/` — db (withRetry + txn + reader/writer), id (+ idempotency key), enums, groups junction, validate, memory, profile, kb, analytics, slug
|
|
190
|
-
- [x] `agents/_base.ts` — BaseAgent: profile iso, idempotency (P0-1), txn (P0-2), audit (P0-6), APPEND_ONLY guard (P0-7), logMemory retention (P1-2), single-profile factory (P1-7)
|
|
191
|
-
- [x] 17 agents, one folder each, SOUL.md + `<agent>.ts`
|
|
192
|
-
- [x] 22 slash commands in `.claude/commands/` (+ `settings.json`)
|
|
193
|
-
- [x] Skills in `skills/<domain>/SKILL.md` — loaded on demand
|
|
194
|
-
- [x] `cli.ts` — universal terminal entry point with legacy-name aliases
|
|
195
|
-
- [x] `.claude-plugin/plugin.json`
|
|
196
|
-
- [x] `README.md` + `.env.example` (+ optional `TURSO_REPLICA_URL`) + `setup.ts`
|
|
197
|
-
|
|
198
|
-
---
|
|
199
|
-
|
|
200
|
-
## Phase 2 — In-App (Qwik + CF Worker)
|
|
201
|
-
|
|
202
|
-
**Goal**: Same agents, same code, running inside the BusinessKit dashboard via MCP tool calls.
|
|
203
|
-
|
|
204
|
-
**The only change**: swap the DB client source.
|
|
205
|
-
|
|
206
|
-
```ts
|
|
207
|
-
// Phase 1 — local, reads from .env
|
|
208
|
-
const ceo = new CEO()
|
|
209
|
-
|
|
210
|
-
// Phase 2 — CF Worker, reads from sharedMap set by plugin.ts
|
|
211
|
-
import { createAgentDB } from '~/lib/db.adapter'
|
|
212
|
-
const ceo = new CEO(createAgentDB(event))
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
**Deliverables**:
|
|
216
|
-
|
|
217
|
-
- [ ] Copy `agents/` + `lib/` into `src/lib/agents/` in the Qwik app
|
|
218
|
-
- [ ] `/api/mcp` route in `src/routes/api/mcp/index.tsx`
|
|
219
|
-
- [ ] One MCP tool definition per agent action
|
|
220
|
-
- [ ] Session auth → `sharedMap["userClient"]` → `createAgentDB(event)`
|
|
221
|
-
|
|
222
|
-
---
|
|
223
|
-
|
|
224
|
-
## Phase 3 — Autonomous (CF Workflows + Durable Objects)
|
|
225
|
-
|
|
226
|
-
**Goal**: Agents run on cron with no user present.
|
|
227
|
-
|
|
228
|
-
**Deliverables**:
|
|
229
|
-
|
|
230
|
-
- [ ] `scheduler.ts` as CF Durable Object (stub already in file — uncomment to activate)
|
|
231
|
-
- [ ] Weekly CEO briefing → n8n → email/Slack (`0 8 * * 1`)
|
|
232
|
-
- [ ] Hourly publish queue → flips `published=1` + triggers Social Agent (`0 * * * *`)
|
|
233
|
-
- [ ] CMO auto-generates content calendar → creates drafts via Blog Writer / Store Manager
|
|
234
|
-
- [ ] Newsletter Writer sends on schedule via SES/Resend
|
|
235
|
-
|
|
236
|
-
---
|
|
237
|
-
|
|
238
|
-
## Design Rules
|
|
239
|
-
|
|
240
|
-
- **Minimal code** — raw libSQL, no ORM, no boilerplate beyond BaseAgent
|
|
241
|
-
- **profile_id on every write** — enforced in BaseAgent, never per-agent
|
|
242
|
-
- **No hard deletes** — always `hidden=1`
|
|
243
|
-
- **No credentials in logs** — credentials table is read-only, never output values
|
|
244
|
-
- **One file per agent** — file name = command name (kebab-case)
|
|
245
|
-
- **Composable** — C-Suite calls Growth calls Creators. Never reverse.
|
|
246
|
-
- **n8n = external integration layer** — social posting, email delivery
|
|
247
|
-
- **CF Workflows = cron layer** — Scheduler designed for Durable Objects from day one
|
|
248
|
-
- **Same codebase, two transports** — `db.adapter.ts` is the only diff between Phase 1 and 2
|
|
249
|
-
|
|
250
|
-
---
|
|
251
|
-
|
|
252
|
-
## Phase 2 Additions — Agent Infrastructure (from Hermes + Karpathy patterns)
|
|
253
|
-
|
|
254
|
-
### New tables (defined in agents.ts)
|
|
255
|
-
|
|
256
|
-
| Table | Purpose |
|
|
257
|
-
|---|---|
|
|
258
|
-
| `agents` | Registry — one row per agent type, tracks last_run, auto_approve, pending skill suggestions |
|
|
259
|
-
| `agent_skills` | Live instruction skills — editable from dashboard, version-tracked |
|
|
260
|
-
| `agent_memory` | Rolling 20-row session log — dual-write (Turso + memory.md) |
|
|
261
|
-
| `agent_notes` | Persistent knowledge artifacts — Karpathy wiki pattern (research, analysis, briefings) |
|
|
262
|
-
| `agent_files` | Files agent produces — SEO reports, blog exports, CRM data — visible in dashboard |
|
|
263
|
-
| `agent_tasks` | Tasks: manual + scheduled + auto-detected from patterns (Hermes pattern) |
|
|
264
|
-
| `agent_conversations` | Future agentic chat UI — table only, implementation deferred |
|
|
265
|
-
|
|
266
|
-
### Hermes pattern: auto-skill generation
|
|
267
|
-
|
|
268
|
-
When an agent performs the same action 3+ times in 7 days:
|
|
269
|
-
|
|
270
|
-
1. `detectAndSuggestSkill()` in `_base.ts` detects the pattern
|
|
271
|
-
2. Creates a pending `agent_tasks` row (status='detected')
|
|
272
|
-
3. Sets `pending_skill_suggestion` on the `agents` row
|
|
273
|
-
4. Dashboard surfaces it: "CEO detected you want Monday briefings — add as task?"
|
|
274
|
-
5. User approves → status='active', auto_run=1, skill is_active=1
|
|
275
|
-
6. Rejects → status='cancelled'
|
|
276
|
-
|
|
277
|
-
### Karpathy wiki pattern: agent_notes
|
|
278
|
-
|
|
279
|
-
Agents write persistent knowledge to `agent_notes`, not just ephemeral `agent_memory`.
|
|
280
|
-
|
|
281
|
-
- CEO briefing → saved as note (type='briefing')
|
|
282
|
-
- SEO audit findings → saved as note (type='analysis')
|
|
283
|
-
- CRM lead research → saved as note (type='research', source_id=contact_id)
|
|
284
|
-
- Notes link to each other via related_note_ids JSON
|
|
285
|
-
- Dashboard shows all notes, filterable by agent and type
|
|
286
|
-
|
|
287
|
-
### Dashboard routes (main Qwik app)
|
|
288
|
-
|
|
289
|
-
- `/dashboard/agents` — agent roster grid
|
|
290
|
-
- `/dashboard/agents/[agentType]` — agent detail (memory, skills, tasks, files, notes tabs)
|
|
291
|
-
- `/dashboard/agents/files` — all files across all agents
|
|
292
|
-
|
|
293
|
-
### Build order
|
|
294
|
-
|
|
295
|
-
See CURSOR-PLAN.md for step-by-step Cursor prompts.
|
|
296
|
-
Do Phase 0 → 1 → 2 in order. Phase 3–5 are optional enhancements.
|
|
297
|
-
|
|
298
|
-
---
|
|
299
|
-
|
|
300
|
-
## Architecture Principles (learned from production)
|
|
301
|
-
|
|
302
|
-
### Backend-as-context (Nainsi principle)
|
|
303
|
-
|
|
304
|
-
Same app, same model, same prompt: 10.4M tokens vs 3.7M tokens.
|
|
305
|
-
The difference: treating the backend as part of the agent's context window.
|
|
306
|
-
|
|
307
|
-
**Applied to this repo:**
|
|
308
|
-
|
|
309
|
-
- `HEARTBEAT.md` is a structured snapshot — one read, no DB calls, full business state
|
|
310
|
-
- Skills load on demand, never all at once
|
|
311
|
-
- `agent_kb` index (slug+summary) loaded before content — never full content scan
|
|
312
|
-
- Every DB query returns only what's needed — no `SELECT *` on large tables
|
|
313
|
-
|
|
314
|
-
**The counterintuitive part:** better models make poor infrastructure MORE expensive.
|
|
315
|
-
A capable model explores more deeply when context is missing. Design for no exploration.
|
|
316
|
-
|
|
317
|
-
### Skillify every failure (Garry Tan principle)
|
|
318
|
-
|
|
319
|
-
Every agent mistake → permanent structural fix, not a re-prompt.
|
|
320
|
-
Deterministic work (date math, row counts, routing) → `lib/` functions, not LLM reasoning.
|
|
321
|
-
Every skill in `agent_skills` must be registered in `CLAUDE.md` skills table or it's dark.
|
|
322
|
-
|
|
323
|
-
---
|
|
324
|
-
|
|
325
|
-
## Phase 2 — Dependencies to add when ready
|
|
326
|
-
|
|
327
|
-
### Spectrum (photon.codes)
|
|
328
|
-
|
|
329
|
-
`npm install spectrum-ts` — connects agents to iMessage, Telegram, WhatsApp, Slack, Discord, Instagram.
|
|
330
|
-
Edge-first, <1s latency. Use when users want to talk to their agents via messaging instead of terminal.
|
|
331
|
-
Add to `lib/channels/` — wrap Spectrum adapters per platform, route inbound messages to correct agent.
|
|
332
|
-
|
|
333
|
-
**Phase 2 channel architecture:**
|
|
334
|
-
|
|
335
|
-
```
|
|
336
|
-
User sends iMessage/WhatsApp/Telegram
|
|
337
|
-
→ Spectrum adapter receives
|
|
338
|
-
→ routes to correct agent based on message content
|
|
339
|
-
→ agent reads HEARTBEAT.md + relevant skills
|
|
340
|
-
→ writes response back via Spectrum
|
|
341
|
-
→ logs to agent_memory
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
Not needed for Phase 1 (Claude Code / Cowork covers it).
|
|
345
|
-
Add when users ask for "talk to my CEO agent on WhatsApp."
|
package/PRD-Agent-Composition.md
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
# Agent Composition Pattern
|
|
2
|
-
|
|
3
|
-
> "Build your marketing assets template, then use that to build skills
|
|
4
|
-
> to further automate your workflow." — Claude Design tutorial
|
|
5
|
-
>
|
|
6
|
-
> "Once I have this design system skills, I can continue to build all
|
|
7
|
-
> the skills on top." — same
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## The pattern
|
|
12
|
-
|
|
13
|
-
Single agents are useful. Composed agents are a system.
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
User: "Launch the April product campaign"
|
|
17
|
-
↓
|
|
18
|
-
CEO agent (orchestrator)
|
|
19
|
-
├─ delegates to CMO → campaign strategy + brief
|
|
20
|
-
├─ delegates to Blog Writer → campaign blog post
|
|
21
|
-
├─ delegates to Social Agent → 3 platform posts from brief
|
|
22
|
-
├─ delegates to Newsletter Writer → launch email to subscribers
|
|
23
|
-
└─ delegates to Store Manager → product visibility + pricing check
|
|
24
|
-
|
|
25
|
-
Result: full campaign from one instruction
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## How it works technically
|
|
31
|
-
|
|
32
|
-
Each agent in `agents/` has a `runCommand()` method.
|
|
33
|
-
The CEO (orchestrator) calls those methods directly:
|
|
34
|
-
|
|
35
|
-
```ts
|
|
36
|
-
// CEO orchestrating a campaign launch
|
|
37
|
-
async launchCampaign(productId: string) {
|
|
38
|
-
// 1. Get product context
|
|
39
|
-
const product = await this.db.getProduct(productId)
|
|
40
|
-
|
|
41
|
-
// 2. Delegate to CMO for strategy
|
|
42
|
-
const brief = await this.cmo.campaignBrief(product)
|
|
43
|
-
|
|
44
|
-
// 3. Parallel: content + social + email
|
|
45
|
-
const [post, socialPosts, email] = await Promise.all([
|
|
46
|
-
this.blogWriter.writePost(brief),
|
|
47
|
-
this.socialAgent.createCampaignPosts(brief),
|
|
48
|
-
this.newsletterWriter.draftLaunchEmail(brief),
|
|
49
|
-
])
|
|
50
|
-
|
|
51
|
-
// 4. Push everything to agent_reports
|
|
52
|
-
await this.pushReport('campaign-launch', { brief, post, socialPosts, email })
|
|
53
|
-
|
|
54
|
-
// 5. Surface pending approvals
|
|
55
|
-
return { pending: [post.id, ...socialPosts.map(p => p.id), email.id] }
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
---
|
|
60
|
-
|
|
61
|
-
## Skill composition (from Claude Design tutorial)
|
|
62
|
-
|
|
63
|
-
Skills compose the same way:
|
|
64
|
-
|
|
65
|
-
```
|
|
66
|
-
brand.md (foundation)
|
|
67
|
-
└─ campaign-planning skill (calls brand.md + analytics.md)
|
|
68
|
-
└─ carousel skill (calls brand.md + campaign brief)
|
|
69
|
-
└─ campaign manager agent (orchestrates all above)
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
The campaign manager in the tutorial took one brief and produced:
|
|
73
|
-
|
|
74
|
-
- Campaign planning deck (slides)
|
|
75
|
-
- Performance tracker (Excel with formulas)
|
|
76
|
-
- Social carousel posts (3 on-brand variations)
|
|
77
|
-
- Animated video (HTML motion graphics)
|
|
78
|
-
- Landing page (with embedded video)
|
|
79
|
-
|
|
80
|
-
In 25 minutes, unattended.
|
|
81
|
-
|
|
82
|
-
Your equivalent: `/ceo launch-campaign` → brief → blog post + social posts
|
|
83
|
-
- newsletter + product settings checked + pending approvals surfaced.
|
|
84
|
-
|
|
85
|
-
---
|
|
86
|
-
|
|
87
|
-
## Three orchestration modes
|
|
88
|
-
|
|
89
|
-
### 1. Sequential (default)
|
|
90
|
-
|
|
91
|
-
Agent A finishes → result passes to Agent B.
|
|
92
|
-
Use for: workflows where each step depends on the last.
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
CMO brief → Blog Writer uses brief → Social Agent repurposes post
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### 2. Parallel (faster, for independent tasks)
|
|
99
|
-
|
|
100
|
-
Agents run simultaneously. Use for: independent deliverables from same input.
|
|
101
|
-
|
|
102
|
-
```
|
|
103
|
-
Campaign brief → [Blog Writer + Social Agent + Newsletter Writer] in parallel
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### 3. Human-gated (approval required)
|
|
107
|
-
|
|
108
|
-
Agent completes step → surfaces to user → user approves → next step.
|
|
109
|
-
Use for: anything that goes public (posts, emails, price changes).
|
|
110
|
-
|
|
111
|
-
```
|
|
112
|
-
Social Agent drafts → approval_status='pending' → user approves → publishes
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
---
|
|
116
|
-
|
|
117
|
-
## What the Shopify video showed
|
|
118
|
-
|
|
119
|
-
The Shopify AI toolkit installs as a Claude Code plugin with slash commands.
|
|
120
|
-
Same pattern as your `.claude/commands/`:
|
|
121
|
-
|
|
122
|
-
```
|
|
123
|
-
/shopify → SEO audit, conversion analysis, AOV report, bulk updates
|
|
124
|
-
/ceo → business briefing, campaign launch, pending approvals
|
|
125
|
-
/crm → contact management, deal pipeline, outreach
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
The difference: Shopify connects to one external store.
|
|
129
|
-
Your repo connects to the user's entire business database.
|
|
130
|
-
|
|
131
|
-
Shopify's approach also validated: one tool (Claude Code) as the connective
|
|
132
|
-
tissue between all their tools (Klaviyo, Canva, Clarity). That's your model —
|
|
133
|
-
one `bk` command connecting all their business data.
|
|
134
|
-
|
|
135
|
-
---
|
|
136
|
-
|
|
137
|
-
## Skills vs agents — the distinction
|
|
138
|
-
|
|
139
|
-
| | Skills | Agents |
|
|
140
|
-
|---|---|---|
|
|
141
|
-
| What | Instructions + rules | Executable code |
|
|
142
|
-
| Where | `.agents/skills/*.md` + `agent_skills` table | `agents/**/*.ts` |
|
|
143
|
-
| Load time | On demand | On demand |
|
|
144
|
-
| Can call other | Skills only | Agents + skills |
|
|
145
|
-
| Has memory | No | Via `agent_memory` |
|
|
146
|
-
| Persists output | No | Via `agent_reports` |
|
|
147
|
-
|
|
148
|
-
Skills teach agents *how* to approach something.
|
|
149
|
-
Agents *do* the thing and remember it.
|