@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,11 @@
1
+ # scheduler
2
+
3
+ Placeholder SOUL. See CLAUDE.md routing table and skills/scheduler/SKILL.md (if present) for scope.
4
+
5
+ ## Rules
6
+
7
+ - Load skills on demand
8
+ - Draft before publish
9
+ - Archive not delete (hidden=1)
10
+ - Log every action to agent_memory
11
+ - Push reports to agent_reports mid-session
@@ -9,8 +9,8 @@
9
9
  * ARIA (weekly briefing), NOVA (content calendar drafts), PEARL (newsletter).
10
10
  */
11
11
 
12
- import { coo } from '../csuite/coo.ts'
13
- import { ceo } from '../csuite/ceo.ts'
12
+ import { coo } from '../operations/operations.ts'
13
+ import { ceo } from '../ceo/ceo.ts'
14
14
 
15
15
  export class Scheduler {
16
16
  readonly name = 'CRON'
@@ -0,0 +1,11 @@
1
+ # seo
2
+
3
+ Placeholder SOUL. See CLAUDE.md routing table and skills/seo/SKILL.md (if present) for scope.
4
+
5
+ ## Rules
6
+
7
+ - Load skills on demand
8
+ - Draft before publish
9
+ - Archive not delete (hidden=1)
10
+ - Log every action to agent_memory
11
+ - Push reports to agent_reports mid-session
@@ -39,39 +39,49 @@ export class SEOAgent extends BaseAgent {
39
39
  async audit(): Promise<{ issues: SEOIssue[]; score: number; summary: string }> {
40
40
  await this.init()
41
41
 
42
- const tables = ['posts', 'compare', 'alternative', 'guides'] as const
42
+ // All content lives in the unified `content` table; filter by the cms
43
+ // kinds we care about. See businesskit-files/content.ts for the schema.
44
+ const kinds = ['blog', 'compare', 'alternative', 'guides'] as const
43
45
  const allIssues: SEOIssue[] = []
44
46
 
45
- for (const table of tables) {
46
- try {
47
- const { rows } = await db.execute({
48
- sql: `SELECT id,title,slug,excerpt,seo_title,seo_description,word_count
49
- FROM ${table} WHERE profile_id=? AND published=1 AND hidden=0`,
50
- args: [this.profileId],
51
- })
52
-
53
- for (const r of rows) {
54
- const problems: string[] = []
55
- if (!r.excerpt) problems.push('missing excerpt')
56
- if (!r.seo_title) problems.push('missing seo_title')
57
- if (!r.seo_description) problems.push('missing seo_description')
58
- if (r.seo_title && String(r.seo_title).length > 60) problems.push('seo_title >60 chars')
59
- if (r.seo_description && String(r.seo_description).length > 160) problems.push('seo_description >160 chars')
60
- if (Number(r.word_count ?? 0) < 300) problems.push('thin content <300 words')
61
- if (!r.slug || String(r.slug).includes(' ')) problems.push('slug has spaces')
62
- if (String(r.slug ?? '').length > 80) problems.push('slug too long >80 chars')
63
-
64
- if (problems.length) {
65
- allIssues.push({ table, id: r.id as string, title: r.title as string, slug: r.slug as string, problems })
66
- }
47
+ try {
48
+ const { rows } = await db.execute({
49
+ sql: `SELECT c.id, c.title, c.slug, c.excerpt, c.seo_title,
50
+ c.seo_description, c.word_count, cms.slug AS kind
51
+ FROM content c
52
+ JOIN cms ON cms.id = c.cms_id
53
+ WHERE c.profile_id=? AND c.published=1 AND c.hidden=0
54
+ AND cms.slug IN ('blog','compare','alternative','guides')`,
55
+ args: [this.profileId],
56
+ })
57
+
58
+ for (const r of rows) {
59
+ const problems: string[] = []
60
+ if (!r.excerpt) problems.push('missing excerpt')
61
+ if (!r.seo_title) problems.push('missing seo_title')
62
+ if (!r.seo_description) problems.push('missing seo_description')
63
+ if (r.seo_title && String(r.seo_title).length > 60) problems.push('seo_title >60 chars')
64
+ if (r.seo_description && String(r.seo_description).length > 160) problems.push('seo_description >160 chars')
65
+ if (Number(r.word_count ?? 0) < 300) problems.push('thin content <300 words')
66
+ if (!r.slug || String(r.slug).includes(' ')) problems.push('slug has spaces')
67
+ if (String(r.slug ?? '').length > 80) problems.push('slug too long >80 chars')
68
+
69
+ if (problems.length) {
70
+ allIssues.push({
71
+ table: String(r.kind ?? 'content'),
72
+ id: r.id as string,
73
+ title: r.title as string,
74
+ slug: r.slug as string,
75
+ problems,
76
+ })
67
77
  }
68
- } catch { /* table may not exist on older DBs */ }
69
- }
78
+ }
79
+ } catch { /* content table may not exist on pre-migration DBs */ }
70
80
 
71
81
  const score = allIssues.length === 0 ? 100 : Math.max(0, 100 - allIssues.length * 5)
72
82
  const summary = allIssues.length === 0
73
83
  ? 'All content passes SEO checks.'
74
- : `${allIssues.length} issues found across ${tables.join(', ')}.`
84
+ : `${allIssues.length} issues found across ${kinds.join(', ')}.`
75
85
 
76
86
  await logMemory('seo', `SEO audit: score ${score}/100, ${allIssues.length} issues`, { issues: allIssues.length, score })
77
87
 
@@ -80,13 +90,15 @@ export class SEOAgent extends BaseAgent {
80
90
 
81
91
  // ── Fix a specific post's SEO fields ─────────────────────────────────────
82
92
 
93
+ /** Fix SEO fields on any content row (blog, guides, compare, …). */
83
94
  async fixPost(id: string, fixes: {
84
95
  seo_title?: string
85
96
  seo_description?: string
86
97
  seo_keywords?: string[]
87
98
  excerpt?: string
88
99
  slug?: string
89
- }, table = 'posts') {
100
+ }) {
101
+ await this.init()
90
102
  const sets: string[] = ['updated_at=?']
91
103
  const args: unknown[] = [iso()]
92
104
 
@@ -96,10 +108,9 @@ export class SEOAgent extends BaseAgent {
96
108
  if (fixes.excerpt) { sets.push('excerpt=?'); args.push(fixes.excerpt) }
97
109
  if (fixes.slug) { sets.push('slug=?'); args.push(this.toSlug(fixes.slug)) }
98
110
 
99
- args.push(id)
100
- await db.execute({
101
- sql: `UPDATE ${table} SET ${sets.join(',')} WHERE id=? AND profile_id=?`,
102
- args: [...args, this.profileId],
111
+ await db.write({
112
+ sql: `UPDATE content SET ${sets.join(',')} WHERE id=? AND profile_id=?`,
113
+ args: [...args, id, this.profileId],
103
114
  })
104
115
  }
105
116
 
@@ -168,7 +179,7 @@ export class SEOAgent extends BaseAgent {
168
179
  sql: `UPDATE profiles SET llm_visibility=? WHERE id=?`,
169
180
  args: [JSON.stringify(updated), this.profileId],
170
181
  })
171
- await logMemory('seo', 'Updated LLM visibility', updated)
182
+ await logMemory('seo', 'Updated LLM visibility', updated as unknown as Record<string, unknown>)
172
183
  return updated
173
184
  }
174
185
 
@@ -200,38 +211,33 @@ export class SEOAgent extends BaseAgent {
200
211
  advice: string[]
201
212
  }> {
202
213
  await this.init()
203
- const [
204
- { rows: typeCounts },
205
- { rows: [compareCount] },
206
- { rows: [altCount] },
207
- ] = await Promise.all([
214
+ // content_type is no longer a column on the new `content` schema —
215
+ // without it we can only detect missing kinds, not missing styles.
216
+ // We infer style presence from titles as a heuristic.
217
+ const [{ rows: kindCounts }, { rows: [thin] }] = await Promise.all([
208
218
  db.execute({
209
- sql: `SELECT content_type, COUNT(*) as cnt FROM posts
210
- WHERE profile_id=? AND published=1 AND hidden=0
211
- GROUP BY content_type`,
219
+ sql: `SELECT cms.slug AS kind, COUNT(*) cnt, MAX(c.title) title_sample
220
+ FROM content c
221
+ JOIN cms ON cms.id = c.cms_id
222
+ WHERE c.profile_id=? AND c.published=1 AND c.hidden=0
223
+ GROUP BY cms.slug`,
212
224
  args: [this.profileId],
213
225
  }),
214
226
  db.execute({
215
- sql: `SELECT COUNT(*) cnt FROM compare WHERE profile_id=? AND published=1`,
216
- args: [this.profileId],
217
- }),
218
- db.execute({
219
- sql: `SELECT COUNT(*) cnt FROM alternative WHERE profile_id=? AND published=1`,
227
+ sql: `SELECT COUNT(*) cnt FROM content
228
+ WHERE profile_id=? AND published=1 AND word_count < 500`,
220
229
  args: [this.profileId],
221
230
  }),
222
231
  ])
223
232
 
224
- const publishedTypes = new Set(typeCounts.map(r => r.content_type as string))
233
+ const byKind = new Map(kindCounts.map(r => [String(r.kind), Number(r.cnt ?? 0)]))
225
234
  const highValueTypes = ['listicle', 'how-to', 'ultimate-guide', 'qa']
226
- const missingTypes = highValueTypes.filter(t => !publishedTypes.has(t))
227
-
228
- const { rows: [thin] } = await db.execute({
229
- sql: `SELECT COUNT(*) cnt FROM posts WHERE profile_id=? AND published=1 AND word_count < 500`,
230
- args: [this.profileId],
231
- })
235
+ // Best-effort: if there's no blog content at all, assume nothing of that
236
+ // style exists yet. Otherwise leave format-specific gaps to the content agent.
237
+ const missingTypes = (byKind.get('blog') ?? 0) === 0 ? highValueTypes : []
232
238
 
233
- const noCompare = Number(compareCount?.cnt ?? 0) === 0
234
- const noAlternative = Number(altCount?.cnt ?? 0) === 0
239
+ const noCompare = (byKind.get('compare') ?? 0) === 0
240
+ const noAlternative = (byKind.get('alternative') ?? 0) === 0
235
241
  const thinPosts = Number(thin?.cnt ?? 0)
236
242
 
237
243
  const advice: string[] = []
@@ -0,0 +1,11 @@
1
+ # social
2
+
3
+ Placeholder SOUL. See CLAUDE.md routing table and skills/social/SKILL.md (if present) for scope.
4
+
5
+ ## Rules
6
+
7
+ - Load skills on demand
8
+ - Draft before publish
9
+ - Archive not delete (hidden=1)
10
+ - Log every action to agent_memory
11
+ - Push reports to agent_reports mid-session