@businesskit/agent 1.0.3 → 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.
Files changed (68) hide show
  1. package/.claude/settings.json +16 -0
  2. package/.claude/settings.local.json +11 -0
  3. package/.env.example +10 -0
  4. package/CLAUDE.md +32 -13
  5. package/PLAN.md +95 -134
  6. package/REFERENCE.md +60 -24
  7. package/agents/_base.ts +352 -44
  8. package/agents/analytics/SOUL.md +11 -0
  9. package/agents/analytics/analytics.ts +405 -0
  10. package/agents/business/SOUL.md +11 -0
  11. package/agents/{csuite/cbo.ts → business/business.ts} +2 -2
  12. package/agents/ceo/SOUL.md +15 -0
  13. package/agents/{csuite → ceo}/ceo.ts +33 -8
  14. package/agents/content/SOUL.md +11 -0
  15. package/agents/content/content.ts +379 -0
  16. package/agents/copywriting/SOUL.md +11 -0
  17. package/agents/courses/SOUL.md +11 -0
  18. package/agents/courses/courses.ts +451 -0
  19. package/agents/docs/SOUL.md +11 -0
  20. package/agents/forms/SOUL.md +11 -0
  21. package/agents/forms/forms.ts +364 -0
  22. package/agents/hiring/SOUL.md +11 -0
  23. package/agents/hiring/hiring.ts +314 -0
  24. package/agents/marketing/SOUL.md +15 -0
  25. package/agents/{csuite/cmo.ts → marketing/marketing.ts} +3 -3
  26. package/agents/newsletter/SOUL.md +11 -0
  27. package/agents/operations/SOUL.md +11 -0
  28. package/agents/operations/operations.ts +157 -0
  29. package/agents/sales/SOUL.md +44 -0
  30. package/agents/sales/sales.ts +883 -0
  31. package/agents/scheduler/SOUL.md +11 -0
  32. package/agents/{growth → scheduler}/scheduler.ts +2 -2
  33. package/agents/seo/SOUL.md +11 -0
  34. package/agents/{growth/seo-agent.ts → seo/seo.ts} +60 -54
  35. package/agents/social/SOUL.md +11 -0
  36. package/agents/social/social.ts +744 -0
  37. package/agents/store/SOUL.md +11 -0
  38. package/agents/store/store.ts +514 -0
  39. package/cli.ts +44 -25
  40. package/lib/cms.ts +88 -0
  41. package/lib/db.ts +58 -11
  42. package/lib/enums.ts +25 -0
  43. package/lib/groups.ts +122 -0
  44. package/lib/id.ts +38 -10
  45. package/lib/profile.ts +44 -8
  46. package/lib/schema.ts +2015 -0
  47. package/lib/validate.ts +33 -0
  48. package/package.json +1 -1
  49. package/scripts/generate-schema.ts +244 -0
  50. package/setup.ts +16 -2
  51. package/skills/schema/SKILL.md +57 -16
  52. package/tsconfig.json +2 -1
  53. package/agents/creators/blog-writer.ts +0 -347
  54. package/agents/creators/course-creator.ts +0 -106
  55. package/agents/creators/crm-agent.ts +0 -479
  56. package/agents/creators/forms-builder.ts +0 -90
  57. package/agents/creators/jobs-manager.ts +0 -82
  58. package/agents/creators/store-manager.ts +0 -138
  59. package/agents/csuite/coo.ts +0 -115
  60. package/agents/growth/analytics-agent.ts +0 -52
  61. package/agents/growth/social-agent.ts +0 -346
  62. /package/{ingest.md → .claude/commands/ingest.md} +0 -0
  63. /package/agents/{creators/copywriter.ts → copywriting/copywriting.ts} +0 -0
  64. /package/agents/{creators/docs-writer.ts → docs/docs.ts} +0 -0
  65. /package/agents/{creators/newsletter-writer.ts → newsletter/newsletter.ts} +0 -0
  66. /package/{ABOUT-ME.md → context/about-me.md} +0 -0
  67. /package/{brand-voice.md → context/brand-voice.md} +0 -0
  68. /package/{working-style.md → context/working-style.md} +0 -0
@@ -0,0 +1,16 @@
1
+ {
2
+ "autocompact_percentage_override": 75,
3
+ "env": {
4
+ "BASH_MAX_OUTPUT_LENGTH": "150000"
5
+ },
6
+ "permissions": {
7
+ "deny": [
8
+ "Read(node_modules/**)",
9
+ "Read(dist/**)",
10
+ "Read(.next/**)",
11
+ "Read(coverage/**)",
12
+ "Read(*.lock)",
13
+ "Read(.git/**)"
14
+ ]
15
+ }
16
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(npx tsc *)",
5
+ "Bash(set -e)",
6
+ "Bash(git add *)",
7
+ "Bash(git commit -m ' *)",
8
+ "Bash(node *)"
9
+ ]
10
+ }
11
+ }
package/.env.example CHANGED
@@ -1,2 +1,12 @@
1
1
  TURSO_URL=libsql://your-db.turso.io
2
2
  TURSO_TOKEN=your-token
3
+
4
+ # Optional: pick one profile when your UserDB has more than one.
5
+ # Agents auto-detect the single profile when this is unset (normal case).
6
+ # Get the id from BusinessKit → Settings → Credentials, or via:
7
+ # SELECT id, slug, title FROM profiles;
8
+ # PROFILE_ID=
9
+
10
+ # Optional: read replica URL for faster agent briefings (Turso embedded replica).
11
+ # When set, db.execute (reads) hits the replica; writes always go to TURSO_URL.
12
+ # TURSO_REPLICA_URL=libsql://your-db-replica.turso.io
package/CLAUDE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # BusinessKit Agent
2
2
 
3
- Run an entire business from your database. 17 agents — CEO, CRM, Social, SEO, Blog Writer and more.
3
+ Run an entire business from your database. 18 agents — CEO, Sales, Marketing, Social, SEO, Content and more.
4
4
 
5
5
  Credentials in `.env`: `TURSO_URL` + `TURSO_TOKEN` (BusinessKit → Settings → Credentials)
6
6
 
@@ -16,18 +16,28 @@ Credentials in `.env`: `TURSO_URL` + `TURSO_TOKEN` (BusinessKit → Settings →
16
16
 
17
17
  ## What to do when asked
18
18
 
19
- | User says | Run |
19
+ | User says | Agent |
20
20
  |---|---|
21
- | "brief me" / "what's happening" | CEO agent — revenue pulse, approvals, priorities |
22
- | "write a post" / "blog" / "guide" | Blog Writer — load brand-voice.md first |
23
- | "newsletter" / "email my subscribers" | Newsletter Writer |
24
- | "post to Twitter/LinkedIn/Instagram" | Social Agent |
25
- | "leads" / "contacts" / "outreach" | CRM Agent |
26
- | "SEO" / "meta" / "LLM visibility" | SEO Agent |
27
- | "analytics" / "revenue" / "traffic" | Analytics Agent |
28
- | "add a product" / "launch" / "store" | Store Manager |
29
- | "process my notes" / "update KB" | run `/ingest` |
30
- | don't know → check | `.agents/skills/agents.md` |
21
+ | "brief me" / "what's happening" / "priorities" | **ceo** — load HEARTBEAT.md first |
22
+ | "marketing" / "content calendar" / "growth strategy" | **marketing** |
23
+ | "revenue" / "pricing" / "business performance" | **business** |
24
+ | "operations" / "publish queue" / "task management" | **operations** |
25
+ | "leads" / "contacts" / "outreach" / "deals" | **sales** — approval gate on all sends |
26
+ | "write a post" / "blog" / "guide" / "listicle" | **content** — load brand-voice.md first |
27
+ | "newsletter" / "email subscribers" | **newsletter** — approval before send |
28
+ | "copy" / "landing page copy" / "bio" | **copywriting** |
29
+ | "post to Twitter/LinkedIn" / "social" | **social** |
30
+ | "SEO" / "meta" / "LLM visibility" | **seo** |
31
+ | "analytics" / "traffic" / "how many clicks" | **analytics** — read-only |
32
+ | "product" / "launch" / "store item" | **store** |
33
+ | "course" / "lessons" / "module" | **courses** |
34
+ | "job listing" / "hiring" / "applications" | **hiring** |
35
+ | "form" / "intake" / "waitlist" | **forms** |
36
+ | "docs" / "knowledge base" / "help article" | **docs** |
37
+ | "schedule" / "cron" / "queue" | **scheduler** |
38
+ | "page" / "design" / "page builder" | **design** |
39
+ | "process my notes" / "update KB" | `/ingest` command |
40
+ | don't know → check | `skills/ceo/SKILL.md` |
31
41
 
32
42
  ---
33
43
 
@@ -65,4 +75,13 @@ User states a preference → add to `memory.md` → apply immediately.
65
75
 
66
76
  ---
67
77
 
68
- Full schema, agent roster, routing rules: `REFERENCE.md`
78
+ ## Deeper context — read on demand
79
+
80
+ | Need | File |
81
+ |---|---|
82
+ | How the repo wires to UserDB, BaseAgent contract, invariants | `ARCHITECTURE.md` |
83
+ | Per-file inventory: agents/, lib/, skills/, commands | `CODEBASE.md` |
84
+ | Which agent writes to which tables + trigger map | `DOMAINS.md` |
85
+ | Code patterns — profile_id, idempotency, enums, soft-delete | `CONVENTIONS.md` |
86
+ | Full schema + agent roster + Phase 2 swap | `REFERENCE.md` |
87
+ | Roadmap, folder map, Phase 1/2/3 | `PLAN.md` |
package/PLAN.md CHANGED
@@ -23,118 +23,89 @@ These all live in the `products` table under different `type` values.
23
23
 
24
24
  ### C-Suite (Intelligence + Strategy)
25
25
 
26
- | Title | File | Role |
26
+ | Title | Folder / File | Role |
27
27
  |---|---|---|
28
- | CEO | `agents/csuite/ceo.ts` | Weekly briefing, cross-agent orchestration, priority setting |
29
- | CMO | `agents/csuite/cmo.ts` | Campaign strategy, content calendar, growth recommendations |
30
- | COO | `agents/csuite/coo.ts` | Content pipeline, publish queue, scheduling oversight |
31
- | CBO | `agents/csuite/cbo.ts` | Revenue analysis, product strategy, pricing recommendations |
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
32
 
33
33
  ### Content Creators
34
34
 
35
- | Title | File | Writes to |
35
+ | Title | Folder / File | Writes to |
36
36
  |---|---|---|
37
- | Blog Writer | `agents/creators/blog-writer.ts` | `posts` |
38
- | Newsletter Writer | `agents/creators/newsletter-writer.ts` | `subscribers` + email via SES/Resend |
39
- | Copywriter | `agents/creators/copywriter.ts` | `pages`, `products.description`, `links` |
40
- | Course Creator | `agents/creators/course-creator.ts` | `products` (type=course) + lessons JSON |
41
- | Store Manager | `agents/creators/store-manager.ts` | `products` (downloads, services, webinars, events, listings, sponsorships, meetings) |
42
- | Jobs Manager | `agents/creators/jobs-manager.ts` | `job_listings` + `job_applications` |
43
- | Forms Builder | `agents/creators/forms-builder.ts` | `forms` + `questions` |
44
- | Docs Writer | `agents/creators/docs-writer.ts` | `doc_collections` + `doc_articles` |
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` |
45
46
 
46
47
  ### Growth & Intelligence
47
48
 
48
- | Title | File | Role |
49
+ | Title | Folder / File | Role |
49
50
  |---|---|---|
50
- | SEO Agent | `agents/growth/seo-agent.ts` | `collections`, slugs, meta, OG tags |
51
- | Analytics Agent | `agents/growth/analytics-agent.ts` | All analytics tables — reads only, never writes |
52
- | Social Agent | `agents/growth/social-agent.ts` | `credentials.n8n_webhook_url` → social platforms |
53
- | Scheduler | `agents/growth/scheduler.ts` | `published=0 + date <= now()` → flips published=1 |
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 |
54
55
 
55
56
  ---
56
57
 
57
58
  ## Current Repository Structure
58
59
 
60
+ One folder per agent. Each folder has `SOUL.md` (identity + rules) + `<agent>.ts` (implementation).
61
+
59
62
  ```
60
63
  businesskit-agent/ ← repo root
61
64
  │
62
- ├── .agents/
63
- │ └── skills/
64
- │ ├── README.md
65
- │ ├── agents.md
66
- │ ├── analytics.md
67
- │ ├── brand.md
68
- │ ├── schema.md
69
- │ └── store.md
70
- │
71
65
  ├── .claude-plugin/
72
66
  │ ├── plugin.json
73
67
  │ └── marketplace.json
74
68
  │
75
69
  ├── .claude/
76
- │ ├── commands/
77
- │ │ ├── analytics.md
78
- │ │ ├── blog-writer.md
79
- │ │ ├── cbo.md
80
- │ │ ├── ceo.md
81
- │ │ ├── cmo.md
82
- │ │ ├── compress.md
83
- │ │ ├── coo.md
84
- │ │ ├── copywriter.md
85
- │ │ ├── course-creator.md
86
- │ │ ├── crm.md
87
- │ │ ├── deep.md
88
- │ │ ├── docs-writer.md
89
- │ │ ├── forms-builder.md
90
- │ │ ├── ingest.md
91
- │ │ ├── jobs-manager.md
92
- │ │ ├── kb.md
93
- │ │ ├── newsletter-writer.md
94
- │ │ ├── preserve.md
95
- │ │ ├── resume.md
96
- │ │ ├── scheduler.md
97
- │ │ ├── seo.md
98
- │ │ ├── social.md
99
- │ │ └── store-manager.md
100
- │ └── skills/
101
- │ ├── README.md
102
- │ ├── agents.md
103
- │ ├── analytics.md
104
- │ ├── brand.md
105
- │ ├── schema.md
106
- │ └── store.md
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/)
107
81
  │
108
- ├── agents/
109
- │ ├── _base.ts
110
- │ ├── creators/
111
- │ │ ├── blog-writer.ts
112
- │ │ ├── copywriter.ts
113
- │ │ ├── course-creator.ts
114
- │ │ ├── crm-agent.ts
115
- │ │ ├── docs-writer.ts
116
- │ │ ├── forms-builder.ts
117
- │ │ ├── jobs-manager.ts
118
- │ │ ├── newsletter-writer.ts
119
- │ │ └── store-manager.ts
120
- │ ├── csuite/
121
- │ │ ├── cbo.ts
122
- │ │ ├── ceo.ts
123
- │ │ ├── cmo.ts
124
- │ │ └── coo.ts
125
- │ └── growth/
126
- │ ├── analytics-agent.ts
127
- │ ├── scheduler.ts
128
- │ ├── seo-agent.ts
129
- │ └── social-agent.ts
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
130
104
  │
131
105
  ├── bin/
132
106
  │ └── businesskit.js
133
107
  │
134
- ├── CC-Session-Logs/
135
- │ └── .gitkeep
136
- │
137
- ├── context/
108
+ ├── context/ ← Brand Foundation — fill in once
138
109
  │ ├── about-me.md
139
110
  │ ├── brand-voice.md
140
111
  │ ├── brand.md
@@ -142,50 +113,40 @@ businesskit-agent/ ← repo root
142
113
  │ └── working-style.md
143
114
  │
144
115
  ├── lib/
145
- │ ├── analytics.ts
146
- │ ├── db.adapter.ts
147
- │ ├── db.ts
148
- │ ├── id.ts
149
- │ ├── kb.ts
150
- │ ├── memory.ts
151
- │ ├── pattern-detector.ts
152
- │ ├── profile.ts
153
- │ ├── progress.ts
154
- │ └── slug.ts
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)
155
128
  │
156
- ├── skills/
157
- │ ├── brand/SKILL.md ← load when writing content
158
- │ ├── analytics/SKILL.md ← load when reading analytics
159
- │ ├── store/SKILL.md ← load for products/pricing
160
- │ ├── schema/SKILL.md ← load for DB queries
161
- │ ├── agents/SKILL.md ← load for routing decisions
162
- │ ├── ceo/SKILL.md ← plugin skill
163
- │ ├── crm/SKILL.md ← plugin skill
164
- │ ├── blog-writer/SKILL.md ← plugin skill
165
- │ └── ingest/SKILL.md ← plugin skill
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
166
142
  │
167
- ├── .cursorrules
168
- ├── .env.example
169
- ├── .gitignore
170
- ├── .mcp.json
171
- ├── AGENTS.md
172
- ├── CLAUDE.md
173
- ├── CURSOR-PLAN.md
174
- ├── GEMINI.md
175
- ├── HEARTBEAT.md
176
- ├── PLAN.md
177
- ├── PRD-Agent-Composition.md
178
- ├── PRD-Agent-Harness.md
179
- ├── README.md
180
- ├── SOUL.md
181
- ├── SYSTEM.md
182
- ├── agents.ts
183
- ├── cli.ts
184
- ├── memory.md
185
- ├── package.json
186
- ├── provision-migrations.ts
187
- ├── setup.ts
188
- └── tsconfig.json
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
189
150
  ```
190
151
 
191
152
  ---
@@ -225,14 +186,14 @@ npx tsx cli.ts scheduler hourly # run publish queue
225
186
  **Delivered**:
226
187
 
227
188
  - [x] `CLAUDE.md` — full schema, brand rules, agent roster
228
- - [x] `lib/` — 6 files: db, db.adapter, id, slug, profile, analytics
229
- - [x] `agents/_base.ts` — BaseAgent with profile isolation
230
- - [x] 16 agents: 4 C-Suite + 8 Creators + 4 Growth
231
- - [x] 16 slash commands in `.claude/commands/`
232
- - [x] 5 skill files in `.claude/skills/`
233
- - [x] `cli.ts` — universal terminal entry point
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
234
195
  - [x] `.claude-plugin/plugin.json`
235
- - [x] `README.md` + `.env.example` + `setup.ts`
196
+ - [x] `README.md` + `.env.example` (+ optional `TURSO_REPLICA_URL`) + `setup.ts`
236
197
 
237
198
  ---
238
199
 
package/REFERENCE.md CHANGED
@@ -33,18 +33,17 @@
33
33
 
34
34
  ## Schema Quick Reference
35
35
 
36
- ### Content tables
36
+ ### Content — unified `content` table
37
37
 
38
- All have: `profile_id, slug, title, content, excerpt, published, hidden, collection_id`
38
+ All blog/notes/guides/newsletter/compare/alternative/prompt/skills content lives in the single `content` table, keyed by `cms_id` (one row per section in `cms`, which has a `category_id`). There is no `posts`/`newsletter`/`notes`/... table.
39
39
 
40
- | Table | Extra columns |
41
- |---|---|
42
- | `posts` | seo_title, seo_description, content_type, word_count |
43
- | `newsletter` | word_count, sent_count |
44
- | `notes`, `guides` | word_count |
45
- | `compare`, `alternative`, `prompt` | sources |
46
- | `doc_collections` | INT AUTOINCREMENT id |
47
- | `doc_articles` | INT AUTOINCREMENT id, collection_id |
40
+ Shared columns: `id, cms_id, category_id, profile_id, user_id, slug, title, content, excerpt, published, hidden, collection_id, seo_title (≤60), seo_description (≤160), seo_keywords, word_count, reading_time_mins, internal_links (int), sources JSON, created_at, updated_at`.
41
+
42
+ Resolve cms_id for a kind via `getCmsId(profileId, kind)` in `agents/content/content.ts`. The unique index is `(profile_id, category_id, slug)`.
43
+
44
+ Kind → category_id: blog=cat_35, notes=cat_37, guides=cat_36, newsletter=cat_20, compare=cat_40, alternative=cat_41, prompt=cat_39, skills=cat_38.
45
+
46
+ Docs are separate (INT AUTOINCREMENT ids): `doc_collections`, `doc_articles`.
48
47
 
49
48
  ### Products
50
49
 
@@ -53,13 +52,44 @@ type: download|course|meeting|webinar|event|listing|sponsorship|service
53
52
  price_cents INT | slug UNIQUE | published | hidden=1 to archive
54
53
  ```
55
54
 
56
- ### CRM
55
+ ### Sales (CRM)
57
56
 
58
57
  ```
59
- crm_contacts: lead_score, icp_match, outreach_status, agent_status, auto_approve
60
- crm_activities: approval_status (pending→approved|auto_sent|rejected) — append-only
61
- crm_deals: stage (new|contacted|proposal|negotiation|won|lost)
62
- crm_analytics: DB triggers manage this — NEVER write manually
58
+ -- Contacts (dashboard route: /dashboard/contacts/[id]/)
59
+ crm_contacts: lead_score(0-100), icp_match, outreach_status, agent_status,
60
+ auto_approve, suggested_dm, conversation_thread JSON,
61
+ agent_context JSON, is_duplicate, duplicate_of
62
+
63
+ -- Pipeline
64
+ crm_deals: stage (new|contacted|proposal|negotiation|won|lost)
65
+ value_cents, probability, expected_close_at, line_items JSON
66
+
67
+ -- Activity timeline — APPEND-ONLY, never UPDATE
68
+ crm_activities: approval_status (pending_approval→approved|auto_sent|rejected)
69
+ direction (outbound|inbound), sender (agent|you|contact)
70
+ type (dm|email|call|meeting|note|task_done|purchase|agent_action)
71
+
72
+ -- Supporting tables
73
+ crm_tasks: status (open|done), due_at, priority
74
+ crm_notes: pinned, body (rich text) — editable unlike activities
75
+ crm_groups: name, icon — membership via crm_contact_groups junction table
76
+ NEVER use LIKE '%grp_x%' — use lib/groups.ts helpers
77
+ crm_templates: type (dm|email|follow_up|proposal), reply_rate_pct
78
+ crm_proposals: public_slug, status (draft|sent|viewed|signed|paid|expired|declined)
79
+ email_opened_at, email_open_count, email_clicked_at
80
+ crm_invoices: invoice_number, public_slug, line_items JSON, total_cents
81
+ email_opened_at, email_open_count, email_clicked_at
82
+ crm_imports: source (csv|linkedin|twitter|apollo|agent), status
83
+ crm_analytics: DB TRIGGERS manage ALL counters — NEVER write manually
84
+ total_pending_approvals, reply_rate_pct, forecast_*_cents
85
+
86
+ -- Key rules for sales agent
87
+ 1. approval_status='pending_approval' on ALL outbound activities — never auto_send
88
+ unless contact.auto_approve=1
89
+ 2. crm_activities is append-only — insert correcting row, never UPDATE
90
+ 3. crm_analytics is trigger-managed — never INSERT or UPDATE
91
+ 4. Groups: use lib/groups.ts not JSON LIKE queries
92
+ 5. Proposals/invoices: email tracking columns written by email_events triggers
63
93
  ```
64
94
 
65
95
  ### Social
@@ -93,25 +123,31 @@ iso() = new Date().toISOString().slice(0,19)+'Z' — TEXT timestamp columns
93
123
 
94
124
  ```
95
125
  cat_1=links cat_15=startups cat_18=courses cat_19=downloads
96
- Cat_31=jobs Cat_32=docs Cat_34=forms Cat_35=blog
126
+ cat_31=jobs cat_32=docs cat_34=forms cat_35=blog
97
127
  ```
98
128
 
99
129
  ---
100
130
 
101
- ## Agent Roster
131
+ ## Agent Roster (18 agents)
132
+
133
+ ### C-Suite
134
+
135
+ ceo (orchestrator, can_create=1, can_assign=1)
136
+ operations (can_assign=1), business
137
+
138
+ ### Marketing
102
139
 
103
- ### C-Suite (`agents/csuite/`)
140
+ marketing, content, newsletter, copywriting, social, seo
104
141
 
105
- CEO → CMO, COO, CBO (all report to CEO)
142
+ ### Operations
106
143
 
107
- ### Creators (`agents/creators/`)
144
+ store, courses, hiring, forms, docs, scheduler, design
108
145
 
109
- blog-writer, newsletter-writer, copywriter, course-creator,
110
- store-manager, jobs-manager, forms-builder, docs-writer, crm-agent
146
+ ### Business
111
147
 
112
- ### Growth (`agents/growth/`)
148
+ sales, analytics
113
149
 
114
- analytics-agent, seo-agent, social-agent, scheduler
150
+ **Reporting:** operations/business/marketing → ceo. All others → their group lead.
115
151
 
116
152
  ---
117
153