@businesskit/agent 1.0.4 → 1.0.5

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 (153) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.cursor-plugin/plugin.json +25 -0
  3. package/.cursorrules +10 -0
  4. package/.superconsole-plugin/plugin.json +32 -0
  5. package/AGENTS.md +94 -63
  6. package/CLAUDE.md +11 -84
  7. package/GEMINI.md +11 -34
  8. package/README.md +106 -153
  9. package/assets/logo.svg +3 -0
  10. package/bin/businesskit.js +11 -17
  11. package/commands/add-contact.md +47 -0
  12. package/commands/add-inventory-from-invoice.md +80 -0
  13. package/commands/adjust-stock.md +46 -0
  14. package/commands/capabilities.md +33 -0
  15. package/commands/check-stock.md +43 -0
  16. package/commands/create-component.md +109 -0
  17. package/commands/create-invoice.md +69 -0
  18. package/commands/create-new-bill.md +65 -0
  19. package/commands/create-page.md +96 -0
  20. package/commands/list-components.md +41 -0
  21. package/commands/list-content.md +46 -0
  22. package/commands/list-pages.md +45 -0
  23. package/commands/publish-page.md +64 -0
  24. package/commands/send-invoice.md +42 -0
  25. package/commands/seo-audit.md +36 -0
  26. package/commands/update-contact.md +46 -0
  27. package/commands/update-content.md +47 -0
  28. package/commands/update-page.md +55 -0
  29. package/commands/update-price.md +47 -0
  30. package/commands/write-blog.md +52 -0
  31. package/commands/write-docs.md +84 -0
  32. package/commands/write-guide.md +46 -0
  33. package/commands/write-newsletter.md +46 -0
  34. package/mcp_config.json +8 -0
  35. package/package.json +34 -23
  36. package/plugin.json +32 -0
  37. package/scripts/setup.sh +134 -0
  38. package/scripts/setup.ts +92 -0
  39. package/server.json +21 -0
  40. package/skills/README.md +19 -27
  41. package/skills/billing/SKILL.md +64 -0
  42. package/skills/brand/SKILL.md +30 -86
  43. package/skills/copywriting/SKILL.md +1 -1
  44. package/skills/crm/SKILL.md +38 -0
  45. package/skills/docs-cms/SKILL.md +53 -0
  46. package/skills/docs-cms/references/how-to.md +383 -0
  47. package/skills/inbox/SKILL.md +49 -0
  48. package/skills/inventory/SKILL.md +69 -0
  49. package/skills/pages/SKILL.md +169 -0
  50. package/skills/pages/references/sections-catalog.json +950 -0
  51. package/skills/social/SKILL.md +1 -1
  52. package/templates/antigravity.json +8 -0
  53. package/templates/claude-code.mcp.json +8 -0
  54. package/templates/cursor.mcp.json +8 -0
  55. package/templates/vscode.mcp.json +9 -0
  56. package/.claude/commands/analytics.md +0 -7
  57. package/.claude/commands/blog-writer.md +0 -9
  58. package/.claude/commands/cbo.md +0 -7
  59. package/.claude/commands/ceo.md +0 -10
  60. package/.claude/commands/cmo.md +0 -7
  61. package/.claude/commands/compress.md +0 -73
  62. package/.claude/commands/coo.md +0 -11
  63. package/.claude/commands/copywriter.md +0 -15
  64. package/.claude/commands/course-creator.md +0 -9
  65. package/.claude/commands/crm.md +0 -591
  66. package/.claude/commands/deep.md +0 -50
  67. package/.claude/commands/docs-writer.md +0 -8
  68. package/.claude/commands/forms-builder.md +0 -10
  69. package/.claude/commands/ingest.md +0 -110
  70. package/.claude/commands/jobs-manager.md +0 -8
  71. package/.claude/commands/kb.md +0 -107
  72. package/.claude/commands/newsletter-writer.md +0 -9
  73. package/.claude/commands/preserve.md +0 -64
  74. package/.claude/commands/resume.md +0 -67
  75. package/.claude/commands/scheduler.md +0 -8
  76. package/.claude/commands/seo.md +0 -60
  77. package/.claude/commands/social.md +0 -51
  78. package/.claude/commands/store-manager.md +0 -11
  79. package/.claude/settings.json +0 -16
  80. package/.claude/settings.local.json +0 -11
  81. package/.env.example +0 -12
  82. package/.mcp.json +0 -3
  83. package/HEARTBEAT.md +0 -105
  84. package/PLAN.md +0 -345
  85. package/PRD-Agent-Composition.md +0 -149
  86. package/PRD-Agent-Harness.md +0 -316
  87. package/REFERENCE.md +0 -160
  88. package/SOUL.md +0 -148
  89. package/SYSTEM.md +0 -71
  90. package/agents/_base.ts +0 -371
  91. package/agents/analytics/SOUL.md +0 -11
  92. package/agents/analytics/analytics.ts +0 -405
  93. package/agents/business/SOUL.md +0 -11
  94. package/agents/business/business.ts +0 -109
  95. package/agents/ceo/SOUL.md +0 -15
  96. package/agents/ceo/ceo.ts +0 -146
  97. package/agents/content/SOUL.md +0 -11
  98. package/agents/content/content.ts +0 -379
  99. package/agents/copywriting/SOUL.md +0 -11
  100. package/agents/copywriting/copywriting.ts +0 -89
  101. package/agents/courses/SOUL.md +0 -11
  102. package/agents/courses/courses.ts +0 -451
  103. package/agents/docs/SOUL.md +0 -11
  104. package/agents/docs/docs.ts +0 -77
  105. package/agents/forms/SOUL.md +0 -11
  106. package/agents/forms/forms.ts +0 -364
  107. package/agents/hiring/SOUL.md +0 -11
  108. package/agents/hiring/hiring.ts +0 -314
  109. package/agents/marketing/SOUL.md +0 -15
  110. package/agents/marketing/marketing.ts +0 -109
  111. package/agents/newsletter/SOUL.md +0 -11
  112. package/agents/newsletter/newsletter.ts +0 -91
  113. package/agents/operations/SOUL.md +0 -11
  114. package/agents/operations/operations.ts +0 -157
  115. package/agents/sales/SOUL.md +0 -44
  116. package/agents/sales/sales.ts +0 -883
  117. package/agents/scheduler/SOUL.md +0 -11
  118. package/agents/scheduler/scheduler.ts +0 -68
  119. package/agents/seo/SOUL.md +0 -11
  120. package/agents/seo/seo.ts +0 -288
  121. package/agents/social/SOUL.md +0 -11
  122. package/agents/social/social.ts +0 -744
  123. package/agents/store/SOUL.md +0 -11
  124. package/agents/store/store.ts +0 -514
  125. package/cli.ts +0 -144
  126. package/context/about-me.md +0 -96
  127. package/context/brand-voice.md +0 -127
  128. package/context/brand.md +0 -80
  129. package/context/business.md +0 -66
  130. package/context/working-style.md +0 -87
  131. package/lib/analytics.ts +0 -81
  132. package/lib/cms.ts +0 -88
  133. package/lib/db.adapter.ts +0 -30
  134. package/lib/db.ts +0 -63
  135. package/lib/enums.ts +0 -25
  136. package/lib/groups.ts +0 -122
  137. package/lib/id.ts +0 -43
  138. package/lib/kb.ts +0 -337
  139. package/lib/memory.ts +0 -219
  140. package/lib/pattern-detector.ts +0 -169
  141. package/lib/profile.ts +0 -155
  142. package/lib/schema.ts +0 -2015
  143. package/lib/slug.ts +0 -30
  144. package/lib/validate.ts +0 -33
  145. package/setup.ts +0 -141
  146. package/skills/agents/SKILL.md +0 -56
  147. package/skills/analytics/SKILL.md +0 -52
  148. package/skills/blog-writer/SKILL.md +0 -452
  149. package/skills/ceo/SKILL.md +0 -25
  150. package/skills/cmo/SKILL.md +0 -8
  151. package/skills/schema/SKILL.md +0 -86
  152. package/skills/store/SKILL.md +0 -62
  153. package/tsconfig.json +0 -14
@@ -1,96 +0,0 @@
1
- # About Me
2
-
3
- > Personal context agents need to represent you accurately.
4
- > CRM agent uses this for outreach tone. Social agent uses this for positioning.
5
- > SEO agent uses this for E-E-A-T signals. CEO uses this for strategy context.
6
-
7
- ---
8
-
9
- ## The one-paragraph version
10
-
11
- <!--
12
- How you'd introduce yourself to a stranger who matters.
13
- Include: what you do, who you help, what makes your approach different.
14
- -->
15
-
16
- [Write your one-paragraph intro here]
17
-
18
- ---
19
-
20
- ## Background that shapes my work
21
-
22
- <!--
23
- Relevant experience, turning points, things that give you credibility.
24
- Not your full CV — just the 3-5 things that explain why you do what you do.
25
- -->
26
-
27
- - [Experience / turning point 1]
28
- - [Experience / turning point 2]
29
- - [Experience / turning point 3]
30
-
31
- ---
32
-
33
- ## What I've built
34
-
35
- <!--
36
- Products, projects, communities, businesses. Include numbers if you have them.
37
- -->
38
-
39
- | What | Details | Status |
40
- |---|---|---|
41
- | [Product/project] | [1 line] | Live / Building / Paused |
42
-
43
- ---
44
-
45
- ## My typical week
46
-
47
- <!--
48
- How you actually spend your time. Agents use this for realistic scheduling.
49
- -->
50
-
51
- - **Making:** [What you create]
52
- - **Selling:** [How you generate revenue]
53
- - **Learning:** [What you're studying/following]
54
- - **Community:** [Who you talk to regularly]
55
-
56
- ---
57
-
58
- ## Credibility signals
59
-
60
- <!--
61
- Things that establish authority. Used by SEO agent for bio, structured data.
62
- Agents don't invent these — they use what you list here.
63
- -->
64
-
65
- - Featured in: [Publications, podcasts, newsletters]
66
- - Trusted by: [Audience size, community size, notable clients]
67
- - Proven results: [Specific outcomes you've helped people achieve]
68
-
69
- ---
70
-
71
- ## Social presence
72
-
73
- <!--
74
- Your handles. Agents use these for cross-posting and for voice consistency.
75
- -->
76
-
77
- | Platform | Handle | Active? | Primary use |
78
- |---|---|---|---|
79
- | Twitter/X | @ | Yes/No | [What you post] |
80
- | LinkedIn | /in/ | Yes/No | [What you post] |
81
- | Instagram | @ | Yes/No | [What you post] |
82
- | YouTube | | Yes/No | [What you post] |
83
- | Newsletter | | Yes/No | [Topic + frequency] |
84
-
85
- ---
86
-
87
- ## What I'm working on right now
88
-
89
- <!--
90
- Current projects, goals for the next 90 days.
91
- CEO agent uses this for weekly briefings and prioritisation.
92
- -->
93
-
94
- - [Current project 1]
95
- - [Current project 2]
96
- - 90-day goal: [What success looks like by then]
@@ -1,127 +0,0 @@
1
- # Brand Voice
2
-
3
- > This is the agent's writing bible. Fill it in once, update when your voice evolves.
4
- > Agents load this before writing any content — blog, social, email, copy.
5
-
6
- ---
7
-
8
- ## Voice in three words
9
-
10
- <!--
11
- Pick three adjectives. Then prove each one with an example of what it sounds like.
12
- Bad: "Professional, friendly, innovative"
13
- Good: "Direct, generous, human"
14
- -->
15
-
16
- [Word 1]: [What it means in practice]
17
- [Word 2]: [What it means in practice]
18
- [Word 3]: [What it means in practice]
19
-
20
- ## How I actually write
21
-
22
- <!--
23
- Paste 2-3 real examples of your best writing — a tweet, a paragraph, an email.
24
- This is the most important part. Agents learn more from examples than descriptions.
25
- -->
26
-
27
- ### Example 1 — Short form (tweet / LinkedIn post)
28
-
29
- [Paste a real post you wrote that you're proud of]
30
-
31
- ### Example 2 — Medium form (email / newsletter intro)
32
-
33
- [Paste a real paragraph or intro]
34
-
35
- ### Example 3 — Long form (blog post intro or section)
36
-
37
- [Optional — paste if you write long form]
38
-
39
- ---
40
-
41
- ## What I sound like vs what I don't
42
-
43
- | I sound like this | Not like this |
44
- |---|---|
45
- | "Here's what worked for me" | "In today's digital landscape..." |
46
- | Short sentences. Direct. | Long, hedge-y sentences with qualifiers |
47
- | Specific numbers and examples | Vague generalities |
48
- | First person, conversational | Corporate third person |
49
- | [Add your own] | [Add your own] |
50
-
51
- ---
52
-
53
- ## Topics I own
54
-
55
- <!--
56
- What subjects do you have genuine authority on?
57
- Agents use this to stay in your lane and not write outside your expertise.
58
- -->
59
-
60
- - [Topic 1]
61
- - [Topic 2]
62
- - [Topic 3]
63
-
64
- ## Topics I avoid
65
-
66
- <!--
67
- Things you don't cover. Agents won't write about these.
68
- -->
69
-
70
- - [Topic to avoid]
71
-
72
- ---
73
-
74
- ## Audience
75
-
76
- <!--
77
- Who reads your content? Be specific.
78
- Bad: "entrepreneurs and marketers"
79
- Good: "solo creators who make $50-200k/year, mostly from courses and newsletters,
80
- who are tired of doing everything themselves but can't afford a team"
81
- -->
82
-
83
- **Primary reader:** [Describe them specifically]
84
-
85
- **What they're struggling with:** [The main problem]
86
-
87
- **What they want:** [The transformation they're after]
88
-
89
- **What they already know:** [Don't over-explain this]
90
-
91
- ---
92
-
93
- ## Platform-specific rules
94
-
95
- <!--
96
- How your voice shifts per platform. Keep it brief.
97
- -->
98
-
99
- **Twitter/X:** [e.g. punchy, no threads unless the idea earns it]
100
- **LinkedIn:** [e.g. slightly more professional, lead with the lesson]
101
- **Newsletter:** [e.g. personal, like writing to one person]
102
- **Blog:** [e.g. practical, skimmable, always has a TL;DR]
103
- **Instagram:** [e.g. visual-first, caption is secondary]
104
-
105
- ---
106
-
107
- ## Phrases I use
108
-
109
- <!--
110
- Things you actually say. Agents use these to match your voice.
111
- -->
112
-
113
- - [Phrase you use]
114
- - [Phrase you use]
115
-
116
- ## Phrases to avoid
117
-
118
- <!--
119
- Things that sound like AI slop or that you never say.
120
- -->
121
-
122
- - "In today's fast-paced world..."
123
- - "It's important to note that..."
124
- - "Dive deep"
125
- - "Unlock your potential"
126
- - "Leverage" (unless you mean actual leverage)
127
- - [Add your own]
package/context/brand.md DELETED
@@ -1,80 +0,0 @@
1
- # Brand Context
2
-
3
- > Fill this in once. Agents read it on every session.
4
- > The more specific you are, the better the output.
5
-
6
- ---
7
-
8
- ## Business overview
9
- <!-- What does your business do? Who is your customer? What problem do you solve?
10
- Example:
11
- I run an online education business helping freelance designers charge premium rates.
12
- My customers are designers with 1-3 years experience who are stuck charging low rates.
13
- -->
14
-
15
- [Your business overview here]
16
-
17
- ## Brand voice
18
- <!-- How do you sound? Pick 3-5 adjectives and explain what they mean in practice.
19
- Example:
20
- - Direct: I say what I mean. No fluff. Get to the point.
21
- - Warm: I talk like a friend, not a corporation. Contractions are fine.
22
- - Authoritative: I've done this. I cite real numbers and real experience.
23
- - No hype: I don't use words like "amazing", "incredible", "game-changing"
24
- -->
25
-
26
- [Your brand voice here]
27
-
28
- ## What we never say
29
- <!-- Words, phrases, or tones to avoid.
30
- Example:
31
- - Never say "delve" or "dive deep"
32
- - Never use corporate jargon (synergy, leverage, utilize)
33
- - Never start with "Great question!"
34
- - Never use passive voice
35
- - Never sign off with "Cheers" — use "Best,"
36
- -->
37
-
38
- [Your avoid list here]
39
-
40
- ## Target audience
41
- <!-- Who reads your content? Be specific.
42
- Example:
43
- Freelance designers, 25-35, primarily based in US/UK/AU.
44
- They are good at their craft but struggle with pricing, sales, and business.
45
- They follow people like Paul Jarvis, Nathan Barry, and Justin Welsh.
46
- -->
47
-
48
- [Your audience here]
49
-
50
- ## Core topics we write about
51
- <!-- What are your 5-7 main content pillars?
52
- Example:
53
- 1. Pricing strategy for creatives
54
- 2. Client communication
55
- 3. Building a portfolio that converts
56
- 4. Freelance business operations
57
- 5. Personal branding for designers
58
- -->
59
-
60
- [Your content pillars here]
61
-
62
- ## Products and services
63
- <!-- What do you sell? Include prices if relevant.
64
- Example:
65
- - Email Marketing Masterclass — $197 online course
66
- - 1:1 Strategy Call — $250/hour
67
- - Monthly coaching membership — $49/month
68
- -->
69
-
70
- [Your products here]
71
-
72
- ## Social presence
73
- <!-- Where are you active? What performs well?
74
- Example:
75
- - LinkedIn: 8,200 followers, long-form posts perform best
76
- - X/Twitter: 2,100 followers, threads and hot takes
77
- - Newsletter: 1,400 subscribers, weekly, 42% open rate
78
- -->
79
-
80
- [Your social presence here]
@@ -1,66 +0,0 @@
1
- # Business Context
2
-
3
- > Keep this updated quarterly. Agents use it for CEO briefings and strategy.
4
-
5
- ---
6
-
7
- ## Current goals (this quarter)
8
- <!-- What are you trying to achieve in the next 90 days?
9
- Example:
10
- 1. Reach $10k MRR
11
- 2. Grow newsletter to 2,000 subscribers
12
- 3. Launch the new course on pricing strategy
13
- 4. Hire a part-time VA
14
- -->
15
-
16
- [Your goals here]
17
-
18
- ## Current focus
19
- <!-- What is the one thing you're working on right now?
20
- Example:
21
- Launching my email course by April 30. Everything else is secondary.
22
- -->
23
-
24
- [Your current focus here]
25
-
26
- ## Revenue model
27
- <!-- How do you make money? What are your revenue streams?
28
- Example:
29
- - Courses: 60% of revenue
30
- - Coaching: 30% of revenue
31
- - Affiliate: 10% of revenue
32
- Primary metric: monthly revenue. Target: $8k/month
33
- -->
34
-
35
- [Your revenue model here]
36
-
37
- ## Content publishing schedule
38
- <!-- How often do you publish? On what channels?
39
- Example:
40
- - Blog: 2x per week (Monday, Thursday)
41
- - Newsletter: every Tuesday
42
- - LinkedIn: 3x per week
43
- - Twitter: daily
44
- -->
45
-
46
- [Your publishing schedule here]
47
-
48
- ## Tools and integrations
49
- <!-- What tools do you use that agents should know about?
50
- Example:
51
- - n8n: automation webhook at [URL]
52
- - Notion: task board at [URL]
53
- - Resend: email delivery
54
- - Paddle: payments
55
- -->
56
-
57
- [Your tools here]
58
-
59
- ## Competitors and comparisons
60
- <!-- Who are the main alternatives in your space?
61
- Example:
62
- Main competitors: Teachable, Podia, Gumroad
63
- We're different because: we're built for creators who want to own their data
64
- -->
65
-
66
- [Your competitive context here]
@@ -1,87 +0,0 @@
1
- # Working Style
2
-
3
- > Fill this in. Agents adapt to how you actually work.
4
- > Be honest — the more specific, the better the output.
5
-
6
- ---
7
-
8
- ## How I like to work with agents
9
-
10
- <!--
11
- Examples:
12
- - Show me drafts before publishing anything
13
- - Always give me 3 options, I'll pick one
14
- - Just do it, don't ask — I'll review at the end
15
- - Morning is my review time, schedule posts for afternoon
16
- -->
17
-
18
- [How you prefer to work with agents]
19
-
20
- ## Approval preferences
21
-
22
- <!--
23
- What needs my sign-off? What can agents do automatically?
24
- Examples:
25
- - Blog posts: always show me draft first
26
- - Social posts: auto-publish on LinkedIn, show me Twitter first
27
- - Emails/newsletters: never send without approval
28
- - CRM outreach: draft and queue, I'll approve in batches
29
- -->
30
-
31
- | Action | Auto | Draft first | Always ask |
32
- |---|---|---|---|
33
- | Blog post | | ✓ | |
34
- | Social post | | ✓ | |
35
- | Newsletter | | | ✓ |
36
- | CRM outreach | | ✓ | |
37
- | Product update | | | ✓ |
38
-
39
- ## Publishing schedule
40
-
41
- <!--
42
- When do you publish what? Agents use this for scheduling.
43
- Examples:
44
- - Blog: Tuesday and Thursday
45
- - Newsletter: every Friday 9am
46
- - Social: daily 8am, 12pm, 6pm
47
- - YouTube: Sunday
48
- -->
49
-
50
- [Your publishing schedule]
51
-
52
- ## Review windows
53
-
54
- <!--
55
- When do you actually check and approve things?
56
- Example: I review drafts every morning 9-10am. Don't schedule outside that.
57
- -->
58
-
59
- [When you review and approve]
60
-
61
- ## Things agents should never do without asking
62
-
63
- <!--
64
- Hard stops. Examples:
65
- - Never delete content — archive it instead
66
- - Never change prices without asking
67
- - Never publish to LinkedIn on weekends
68
- - Never send emails to more than 100 people without approval
69
- -->
70
-
71
- - Never delete — archive instead
72
- - [Add your own]
73
-
74
- ## Things agents can always do without asking
75
-
76
- <!--
77
- Safe defaults. Examples:
78
- - Can always save drafts
79
- - Can always add to agent_notes for later
80
- - Can always generate options/variants
81
- - Can always push reports to agent_reports
82
- -->
83
-
84
- - Can always save to drafts
85
- - Can always push to agent_reports
86
- - Can always add to agent_notes inbox
87
- - [Add your own]
package/lib/analytics.ts DELETED
@@ -1,81 +0,0 @@
1
- import { db } from './db.ts'
2
-
3
- const parseArr = (v: unknown): number[] => { try { return JSON.parse(v as string) } catch { return [] } }
4
- const parseObj = (v: unknown): Record<string, number> => { try { return JSON.parse(v as string) } catch { return {} } }
5
- const top = (obj: Record<string, number>, n = 5) =>
6
- Object.entries(obj).sort((a, b) => b[1] - a[1]).slice(0, n)
7
-
8
- export async function profileSummary(profileId: string) {
9
- const { rows: [r] } = await db.execute({
10
- sql: 'SELECT * FROM profile_analytics WHERE profile_id=? LIMIT 1',
11
- args: [profileId],
12
- })
13
- if (!r) return null
14
-
15
- const rev30d = parseArr(r.revenue_30d)
16
- const revLife = parseObj(r.revenue_lifetime)
17
- const clicks30d = parseArr(r.analytics_30d)
18
-
19
- const half = Math.floor(rev30d.length / 2)
20
- const recent = rev30d.slice(half).reduce((a, b) => a + b, 0)
21
- const prior = rev30d.slice(0, half).reduce((a, b) => a + b, 0)
22
- const revTrend = prior
23
- ? `${recent >= prior ? '+' : ''}${Math.round(((recent - prior) / prior) * 100)}%`
24
- : 'new'
25
-
26
- return {
27
- total_clicks: (r.total_clicks as number) ?? 0,
28
- total_sales: (r.total_sales as number) ?? 0,
29
- total_revenue: Object.values(revLife).reduce((a, b) => a + b, 0),
30
- revenue_30d: rev30d,
31
- clicks_30d: clicks30d,
32
- revenue_trend: revTrend,
33
- top_countries: top(parseObj(r.country_clicks)),
34
- top_referrers: top(parseObj(r.referrer_clicks)),
35
- }
36
- }
37
-
38
- export async function productSummary(profileId: string) {
39
- const { rows } = await db.execute({
40
- sql: `SELECT pa.*, p.title, p.type
41
- FROM product_analytics pa
42
- JOIN products p ON p.id = pa.product_id
43
- WHERE pa.profile_id=?
44
- ORDER BY pa.total_revenue_cents DESC`,
45
- args: [profileId],
46
- })
47
- return rows.map(r => ({
48
- id: r.product_id as string,
49
- title: r.title as string,
50
- type: r.type as string,
51
- sales: (r.total_sales as number) ?? 0,
52
- revenue: (r.total_revenue_cents as number) ?? 0,
53
- rev30d: parseArr(r.revenue_30d),
54
- }))
55
- }
56
-
57
- export async function linkSummary(profileId: string, limit = 10) {
58
- const { rows } = await db.execute({
59
- sql: `SELECT la.link_id, la.total_clicks, la.analytics_7d, l.title, l.url
60
- FROM link_analytics la JOIN links l ON l.id = la.link_id
61
- WHERE la.profile_id=? ORDER BY la.total_clicks DESC LIMIT ?`,
62
- args: [profileId, limit],
63
- })
64
- return rows.map(r => ({
65
- id: r.link_id as string,
66
- title: r.title as string,
67
- url: r.url as string,
68
- clicks: (r.total_clicks as number) ?? 0,
69
- last7d: parseArr(r.analytics_7d),
70
- }))
71
- }
72
-
73
- export async function formSummary(profileId: string) {
74
- const { rows } = await db.execute({
75
- sql: `SELECT f.id, f.title, fa.views, fa.submissions
76
- FROM forms f LEFT JOIN form_analytics fa ON fa.form_id = f.id
77
- WHERE f.profile_id=? AND f.hidden=0 ORDER BY fa.submissions DESC`,
78
- args: [profileId],
79
- })
80
- return rows
81
- }
package/lib/cms.ts DELETED
@@ -1,88 +0,0 @@
1
- /**
2
- * lib/cms.ts — cms row resolver.
3
- *
4
- * The app-side `cms` table is one row per content section (Blog, Notes, Jobs,
5
- * Forms, Docs, etc.) keyed by (profile_id, category_id). Triggers on
6
- * job_listings, forms, products, doc_articles, content all UPDATE `cms_analytics`
7
- * for the matching cms_id — so the cms row must exist for counters to move.
8
- *
9
- * Use `ensureCmsRow()` before any INSERT into a table whose trigger touches
10
- * cms_analytics. Idempotent — unique index on (profile_id, category_id).
11
- *
12
- * Category IDs (seeded by app; stable):
13
- * cat_1 Links cat_31 Jobs
14
- * cat_18 Courses cat_32 Docs (Knowledge Base)
15
- * cat_19 Downloads cat_34 Forms
16
- * cat_20 Newsletter cat_35 Blog
17
- * cat_22 Meetings cat_36 Guides
18
- * cat_24 Webinars cat_37 Notes
19
- * cat_25 Services cat_38 Skills
20
- * cat_27 Listing cat_39 Prompt
21
- * cat_30 Booking cat_40 Compare
22
- * cat_41 Alternative
23
- * cat_42 Community cat_45 Posts
24
- * cat_47 Pages cat_8 Events
25
- * cat_21 Sponsorship
26
- */
27
-
28
- import { db } from './db.ts'
29
- import { ulid } from './id.ts'
30
-
31
- /** Find or create a cms row for (profile_id, category_id). Returns the cms.id. */
32
- export async function ensureCmsRow(
33
- profileId: string,
34
- categoryId: string,
35
- opts: { slug?: string; title?: string } = {},
36
- ): Promise<string> {
37
- const { rows: [existing] } = await db.execute({
38
- sql: `SELECT id FROM cms WHERE profile_id=? AND category_id=? LIMIT 1`,
39
- args: [profileId, categoryId],
40
- })
41
- if (existing?.id) return existing.id as string
42
-
43
- const id = ulid()
44
- await db.write({
45
- sql: `INSERT OR IGNORE INTO cms (id, profile_id, slug, title, category_id)
46
- VALUES (?, ?, ?, ?, ?)`,
47
- args: [
48
- id, profileId,
49
- opts.slug ?? categoryId,
50
- opts.title ?? categoryId,
51
- categoryId,
52
- ],
53
- })
54
-
55
- const { rows: [row] } = await db.execute({
56
- sql: `SELECT id FROM cms WHERE profile_id=? AND category_id=? LIMIT 1`,
57
- args: [profileId, categoryId],
58
- })
59
- return (row?.id as string) ?? id
60
- }
61
-
62
- /** Category IDs used by app — import by name to avoid magic strings. */
63
- export const CATEGORY = {
64
- LINKS: 'cat_1',
65
- EVENTS: 'cat_8',
66
- COURSES: 'cat_18',
67
- DOWNLOADS: 'cat_19',
68
- NEWSLETTER: 'cat_20',
69
- SPONSORSHIP: 'cat_21',
70
- MEETINGS: 'cat_22',
71
- WEBINARS: 'cat_24',
72
- SERVICES: 'cat_25',
73
- LISTING: 'cat_27',
74
- BOOKING: 'cat_30',
75
- JOBS: 'cat_31',
76
- DOCS: 'cat_32',
77
- FORMS: 'cat_34',
78
- BLOG: 'cat_35',
79
- GUIDES: 'cat_36',
80
- NOTES: 'cat_37',
81
- SKILLS: 'cat_38',
82
- PROMPT: 'cat_39',
83
- COMPARE: 'cat_40',
84
- ALTERNATIVE: 'cat_41',
85
- COMMUNITY: 'cat_42',
86
- POSTS: 'cat_45',
87
- PAGES: 'cat_47',
88
- } as const
package/lib/db.adapter.ts DELETED
@@ -1,30 +0,0 @@
1
- /**
2
- * db.adapter.ts — Universal DB adapter
3
- *
4
- * This is the ONE file that differs between Phase 1 and Phase 2.
5
- * Everything else (agents, lib/) is identical in both environments.
6
- *
7
- * Phase 1 (local / CLI / Claude Code):
8
- * db is created from process.env in lib/db.ts
9
- *
10
- * Phase 2 (Cloudflare Worker / Qwik routeAction$):
11
- * db is injected from event.sharedMap — already decrypted + connected
12
- * by plugin.ts. Import createAgentDB() instead of db directly.
13
- */
14
-
15
- import type { Client } from '@libsql/client'
16
-
17
- /**
18
- * Phase 2: extract the raw libSQL client from Qwik's sharedMap.
19
- * sharedMap["userClient"] is set by plugin.ts on every request.
20
- */
21
- export function createAgentDB(event: { sharedMap: Map<string, unknown> }): Client {
22
- const client = event.sharedMap.get('userClient') as Client | undefined
23
- if (!client) {
24
- throw new Error(
25
- 'No userClient in sharedMap. ' +
26
- 'Ensure plugin.ts has run and the user has a connected Turso DB.'
27
- )
28
- }
29
- return client
30
- }