@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
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Content Agent — unified CMS writer (SEObot-quality).
|
|
3
|
-
*
|
|
4
|
-
* DB reality (see businesskit-files/content.ts):
|
|
5
|
-
* There is no `posts` / `notes` / `guides` / `compare` / `newsletter` table.
|
|
6
|
-
* Everything lives in ONE table: `content`. The "type" of content is
|
|
7
|
-
* encoded by `cms_id` (→ one row per section in the `cms` table, which in
|
|
8
|
-
* turn has a `category_id` like `cat_35` for blog, `cat_37` for notes, etc).
|
|
9
|
-
*
|
|
10
|
-
* Analytics are trigger-maintained:
|
|
11
|
-
* - content_analytics (1 row per content item) — scalar counts + JSON
|
|
12
|
-
* breakdowns. JSON is lazy-aggregated on dashboard page visit;
|
|
13
|
-
* `last_aggregated_at` throttles rebuilds. AGENTS MUST NOT REBUILD.
|
|
14
|
-
* - cms_analytics (1 row per cms page) — total_posts / total_draft /
|
|
15
|
-
* total_published maintained by trg_content_insert / update / delete.
|
|
16
|
-
*
|
|
17
|
-
* Supported kinds (pick one; maps to cms_id via category_id):
|
|
18
|
-
* blog, notes, guides, newsletter, compare, alternative, prompt, skills
|
|
19
|
-
*
|
|
20
|
-
* Quality bar (from SEObot research):
|
|
21
|
-
* - Min 1500 words for blog, 2500+ for ultimate-guide
|
|
22
|
-
* - SEO title ≤60 chars, meta description ≤160 chars
|
|
23
|
-
* - Excerpt is a hook sentence, not a summary
|
|
24
|
-
* - internal_links count maintained, sources JSON cited when factual
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
import { BaseAgent, db, ulid, iso } from '../_base.ts'
|
|
28
|
-
import { logMemory } from '../../lib/memory.ts'
|
|
29
|
-
import { ensureCmsRow } from '../../lib/cms.ts'
|
|
30
|
-
|
|
31
|
-
// ── Content "kinds" — the logical content type. Maps to cms_id at write. ────
|
|
32
|
-
// Kept as a stable public API so other agents (seo, operations, ceo, marketing)
|
|
33
|
-
// don't have to know about cms_id internals.
|
|
34
|
-
export type ContentKind =
|
|
35
|
-
| 'blog' | 'notes' | 'guides' | 'newsletter'
|
|
36
|
-
| 'compare' | 'alternative' | 'prompt' | 'skills'
|
|
37
|
-
|
|
38
|
-
// Back-compat alias — old callers said `ContentTable`, same values.
|
|
39
|
-
export type ContentTable = ContentKind
|
|
40
|
-
|
|
41
|
-
export type ContentType =
|
|
42
|
-
| 'blog'
|
|
43
|
-
| 'listicle'
|
|
44
|
-
| 'how-to'
|
|
45
|
-
| 'checklist'
|
|
46
|
-
| 'qa'
|
|
47
|
-
| 'versus'
|
|
48
|
-
| 'roundup'
|
|
49
|
-
| 'news'
|
|
50
|
-
| 'ultimate-guide'
|
|
51
|
-
| 'programmatic'
|
|
52
|
-
|
|
53
|
-
export interface WriteInput {
|
|
54
|
-
title: string
|
|
55
|
-
kind?: ContentKind // default: 'blog'
|
|
56
|
-
table?: ContentTable // back-compat alias for `kind`
|
|
57
|
-
topic?: string
|
|
58
|
-
content_type?: ContentType
|
|
59
|
-
target_keywords?: string[]
|
|
60
|
-
word_count_target?: number
|
|
61
|
-
collection_id?: string
|
|
62
|
-
publish?: boolean
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface WriteResult {
|
|
66
|
-
id: string
|
|
67
|
-
kind: ContentKind
|
|
68
|
-
slug: string
|
|
69
|
-
title: string
|
|
70
|
-
word_count: number
|
|
71
|
-
content_type: ContentType
|
|
72
|
-
seo_title: string
|
|
73
|
-
seo_description: string
|
|
74
|
-
published: boolean
|
|
75
|
-
url: string
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Logical kind → category_id (seeded, stable — see DEFAULT_CMS_PAGES).
|
|
79
|
-
const KIND_CATEGORY: Record<ContentKind, string> = {
|
|
80
|
-
blog: 'cat_35',
|
|
81
|
-
notes: 'cat_37',
|
|
82
|
-
guides: 'cat_36',
|
|
83
|
-
newsletter: 'cat_20',
|
|
84
|
-
compare: 'cat_40',
|
|
85
|
-
alternative: 'cat_41',
|
|
86
|
-
prompt: 'cat_39',
|
|
87
|
-
skills: 'cat_38',
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Public URL path per kind — blog lives under /blog, everything else under /<kind>.
|
|
91
|
-
const KIND_ROUTE: Record<ContentKind, string> = {
|
|
92
|
-
blog: 'blog',
|
|
93
|
-
notes: 'notes',
|
|
94
|
-
guides: 'guides',
|
|
95
|
-
newsletter: 'n',
|
|
96
|
-
compare: 'compare',
|
|
97
|
-
alternative: 'alternative',
|
|
98
|
-
prompt: 'prompt',
|
|
99
|
-
skills: 'skills',
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Word-count target per content_type
|
|
103
|
-
const WORD_TARGETS: Record<ContentType, number> = {
|
|
104
|
-
'blog': 1500,
|
|
105
|
-
'listicle': 2000,
|
|
106
|
-
'how-to': 2000,
|
|
107
|
-
'checklist': 1200,
|
|
108
|
-
'qa': 1500,
|
|
109
|
-
'versus': 2000,
|
|
110
|
-
'roundup': 2000,
|
|
111
|
-
'news': 800,
|
|
112
|
-
'ultimate-guide': 3000,
|
|
113
|
-
'programmatic': 1000,
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// `versus` is the content_type that belongs in the `compare` kind
|
|
117
|
-
const TYPE_KIND: Partial<Record<ContentType, ContentKind>> = {
|
|
118
|
-
'versus': 'compare',
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/** Resolve a cms_id for a logical content kind — creates missing rows on demand. */
|
|
122
|
-
export async function getCmsId(profileId: string, kind: ContentKind): Promise<string> {
|
|
123
|
-
return ensureCmsRow(profileId, KIND_CATEGORY[kind], {
|
|
124
|
-
slug: KIND_ROUTE[kind],
|
|
125
|
-
title: kind.charAt(0).toUpperCase() + kind.slice(1),
|
|
126
|
-
})
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export class BlogWriter extends BaseAgent {
|
|
130
|
-
readonly name = 'Content'
|
|
131
|
-
readonly title = 'Content Agent'
|
|
132
|
-
|
|
133
|
-
// ── Write new content ──────────────────────────────────────────────────────
|
|
134
|
-
|
|
135
|
-
async write(input: WriteInput): Promise<WriteResult> {
|
|
136
|
-
await this.init()
|
|
137
|
-
|
|
138
|
-
const contentType = input.content_type ?? 'blog'
|
|
139
|
-
const kind = input.kind ?? input.table ?? TYPE_KIND[contentType] ?? 'blog'
|
|
140
|
-
const wordTarget = input.word_count_target ?? WORD_TARGETS[contentType]
|
|
141
|
-
const keywords = input.target_keywords ?? []
|
|
142
|
-
|
|
143
|
-
const cms_id = await getCmsId(this.profileId, kind)
|
|
144
|
-
const slug = await this.makeSlug(input.title, cms_id)
|
|
145
|
-
const id = ulid()
|
|
146
|
-
const ts = iso()
|
|
147
|
-
|
|
148
|
-
// Structural hint — Claude writes actual content when invoked via CLI/Code.
|
|
149
|
-
const structureHint = this.structureForType(contentType, wordTarget, keywords)
|
|
150
|
-
const content = await this.generateContent(input.title, input.topic ?? input.title, structureHint, keywords)
|
|
151
|
-
const excerpt = await this.generateExcerpt(content, contentType)
|
|
152
|
-
const seoTitle = await this.generateSEOTitle(input.title, keywords)
|
|
153
|
-
const seoDesc = await this.generateSEODescription(content, keywords)
|
|
154
|
-
const wordCount = this.countWords(content)
|
|
155
|
-
const readingTime = Math.ceil(wordCount / 200)
|
|
156
|
-
const internalLinks = await this.countInternalLinks(input.title, keywords)
|
|
157
|
-
|
|
158
|
-
await db.write({
|
|
159
|
-
sql: `INSERT INTO content
|
|
160
|
-
(id, cms_id, category_id, profile_id, user_id, slug, title,
|
|
161
|
-
content, excerpt, published, hidden, collection_id,
|
|
162
|
-
seo_title, seo_description, seo_keywords,
|
|
163
|
-
word_count, reading_time_mins, internal_links, sources,
|
|
164
|
-
created_at, updated_at)
|
|
165
|
-
VALUES (?,?,?,?,?,?,?,?,?,?,0,?,?,?,?,?,?,?,'[]',?,?)`,
|
|
166
|
-
args: [
|
|
167
|
-
id, cms_id, KIND_CATEGORY[kind], this.profileId, this.userId, slug, input.title,
|
|
168
|
-
content, excerpt, input.publish ? 1 : 0,
|
|
169
|
-
input.collection_id ?? null,
|
|
170
|
-
seoTitle, seoDesc,
|
|
171
|
-
keywords.length ? JSON.stringify(keywords) : null,
|
|
172
|
-
wordCount, readingTime, internalLinks,
|
|
173
|
-
ts, ts,
|
|
174
|
-
],
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
await logMemory(this.agentType,
|
|
178
|
-
`${input.publish ? 'Published' : 'Drafted'} "${input.title}" (${kind}/${contentType}, ${wordCount} words)`,
|
|
179
|
-
{ id, kind, slug, content_type: contentType, word_count: wordCount })
|
|
180
|
-
|
|
181
|
-
return {
|
|
182
|
-
id, kind, slug, title: input.title,
|
|
183
|
-
word_count: wordCount, content_type: contentType,
|
|
184
|
-
seo_title: seoTitle, seo_description: seoDesc,
|
|
185
|
-
published: !!input.publish,
|
|
186
|
-
url: `https://${this.ctx.profile.slug}.businesskit.io/${KIND_ROUTE[kind]}/${slug}`,
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// ── List + manage (unified table, filter by cms_id/kind) ──────────────────
|
|
191
|
-
|
|
192
|
-
async listDrafts(kind: ContentKind = 'blog') {
|
|
193
|
-
await this.init()
|
|
194
|
-
const cms_id = await getCmsId(this.profileId, kind)
|
|
195
|
-
const { rows } = await db.execute({
|
|
196
|
-
sql: `SELECT id, title, slug, word_count, created_at, updated_at
|
|
197
|
-
FROM content
|
|
198
|
-
WHERE profile_id=? AND cms_id=? AND published=0 AND hidden=0
|
|
199
|
-
ORDER BY updated_at DESC LIMIT 20`,
|
|
200
|
-
args: [this.profileId, cms_id],
|
|
201
|
-
})
|
|
202
|
-
return rows
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
async listPublished(kind: ContentKind = 'blog', limit = 20) {
|
|
206
|
-
await this.init()
|
|
207
|
-
const cms_id = await getCmsId(this.profileId, kind)
|
|
208
|
-
const { rows } = await db.execute({
|
|
209
|
-
sql: `SELECT id, title, slug, word_count, created_at, updated_at
|
|
210
|
-
FROM content
|
|
211
|
-
WHERE profile_id=? AND cms_id=? AND published=1 AND hidden=0
|
|
212
|
-
ORDER BY updated_at DESC LIMIT ?`,
|
|
213
|
-
args: [this.profileId, cms_id, limit],
|
|
214
|
-
})
|
|
215
|
-
return rows
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/** Publish (trigger flips cms_analytics draft→published). */
|
|
219
|
-
async publishContent(id: string) {
|
|
220
|
-
await this.init()
|
|
221
|
-
await db.write({
|
|
222
|
-
sql: `UPDATE content SET published=1, updated_at=?
|
|
223
|
-
WHERE id=? AND profile_id=?`,
|
|
224
|
-
args: [iso(), id, this.profileId],
|
|
225
|
-
})
|
|
226
|
-
const { rows: [r] } = await db.execute({
|
|
227
|
-
sql: `SELECT title, slug FROM content WHERE id=? AND profile_id=? LIMIT 1`,
|
|
228
|
-
args: [id, this.profileId],
|
|
229
|
-
})
|
|
230
|
-
if (r) await logMemory(this.agentType, `Published "${r.title}"`, { id, slug: r.slug })
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
async unpublish(id: string) {
|
|
234
|
-
await this.init()
|
|
235
|
-
await db.write({
|
|
236
|
-
sql: `UPDATE content SET published=0, updated_at=?
|
|
237
|
-
WHERE id=? AND profile_id=?`,
|
|
238
|
-
args: [iso(), id, this.profileId],
|
|
239
|
-
})
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/** Soft archive — never hard DELETE (that would fire trg_content_delete and
|
|
243
|
-
* decrement counters). hidden=1 keeps counters intact. */
|
|
244
|
-
async archiveContent(id: string) {
|
|
245
|
-
await this.init()
|
|
246
|
-
await db.write({
|
|
247
|
-
sql: `UPDATE content SET hidden=1, updated_at=?
|
|
248
|
-
WHERE id=? AND profile_id=?`,
|
|
249
|
-
args: [iso(), id, this.profileId],
|
|
250
|
-
})
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// ── Content inventory — free via cms_analytics (trigger-maintained) ───────
|
|
254
|
-
|
|
255
|
-
async inventory() {
|
|
256
|
-
await this.init()
|
|
257
|
-
const { rows } = await db.execute({
|
|
258
|
-
sql: `SELECT c.slug AS kind, c.category_id,
|
|
259
|
-
a.total_posts, a.total_published, a.total_draft
|
|
260
|
-
FROM cms c
|
|
261
|
-
LEFT JOIN cms_analytics a ON a.cms_id = c.id
|
|
262
|
-
WHERE c.profile_id=?`,
|
|
263
|
-
args: [this.profileId],
|
|
264
|
-
})
|
|
265
|
-
|
|
266
|
-
const out: Record<string, { total: number; published: number; drafts: number }> = {}
|
|
267
|
-
for (const r of rows) {
|
|
268
|
-
const k = String(r.kind ?? r.category_id)
|
|
269
|
-
out[k] = {
|
|
270
|
-
total: Number(r.total_posts ?? 0),
|
|
271
|
-
published: Number(r.total_published ?? 0),
|
|
272
|
-
drafts: Number(r.total_draft ?? 0),
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
return out
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// ── SEO quality audit ─────────────────────────────────────────────────────
|
|
279
|
-
|
|
280
|
-
async seoAudit(kind: ContentKind = 'blog') {
|
|
281
|
-
await this.init()
|
|
282
|
-
const cms_id = await getCmsId(this.profileId, kind)
|
|
283
|
-
const { rows } = await db.execute({
|
|
284
|
-
sql: `SELECT id, title, slug, excerpt, seo_title, seo_description, word_count
|
|
285
|
-
FROM content
|
|
286
|
-
WHERE profile_id=? AND cms_id=? AND published=1 AND hidden=0`,
|
|
287
|
-
args: [this.profileId, cms_id],
|
|
288
|
-
})
|
|
289
|
-
|
|
290
|
-
const issues: Array<{ id: string; title: string; problems: string[] }> = []
|
|
291
|
-
for (const r of rows) {
|
|
292
|
-
const problems: string[] = []
|
|
293
|
-
if (!r.excerpt) problems.push('missing excerpt')
|
|
294
|
-
if (!r.seo_title) problems.push('missing seo_title')
|
|
295
|
-
if (!r.seo_description) problems.push('missing seo_description')
|
|
296
|
-
if (r.seo_title && String(r.seo_title).length > 60) problems.push('seo_title too long (>60)')
|
|
297
|
-
if (r.seo_description && String(r.seo_description).length > 160) problems.push('seo_description too long (>160)')
|
|
298
|
-
if (Number(r.word_count ?? 0) < 300) problems.push('too short (<300 words)')
|
|
299
|
-
if (!r.slug || String(r.slug).includes(' ')) problems.push('bad slug')
|
|
300
|
-
if (problems.length) issues.push({ id: r.id as string, title: r.title as string, problems })
|
|
301
|
-
}
|
|
302
|
-
return issues
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// ── Private helpers ───────────────────────────────────────────────────────
|
|
306
|
-
|
|
307
|
-
private structureForType(type: ContentType, wordTarget: number, keywords: string[]): string {
|
|
308
|
-
const kw = keywords.length ? `Target keywords: ${keywords.join(', ')}. ` : ''
|
|
309
|
-
const structures: Record<ContentType, string> = {
|
|
310
|
-
'blog': `${kw}Write a comprehensive blog post. Intro hook → 3-5 main sections with H2s → conclusion with CTA. ~${wordTarget} words.`,
|
|
311
|
-
'listicle': `${kw}Write a numbered listicle. Hook intro → numbered items (H3 each, 2-3 sentences, practical tip) → summary. 7-15 items. ~${wordTarget} words.`,
|
|
312
|
-
'how-to': `${kw}Write a step-by-step how-to. Problem intro → numbered steps (H3 each, clear action, why it matters) → result. ~${wordTarget} words.`,
|
|
313
|
-
'checklist': `${kw}Write a practical checklist. Short intro → grouped checklist items with brief explanations → conclusion. Imperative language. ~${wordTarget} words.`,
|
|
314
|
-
'qa': `${kw}Write a Q&A article. Short intro → 8-12 questions as H2s with 2-4 sentence answers → summary. Address real search queries. ~${wordTarget} words.`,
|
|
315
|
-
'versus': `${kw}Write a versus comparison. TL;DR verdict → feature table → pros/cons each option → who should use what → verdict. ~${wordTarget} words.`,
|
|
316
|
-
'roundup': `${kw}Write a curated roundup. Criteria intro → each option (H3, 2-3 sentences, best for who) → comparison table → top pick. ~${wordTarget} words.`,
|
|
317
|
-
'news': `${kw}Write a news article. Lead paragraph (who/what/when/where/why) → context → implications → sources cited. ~${wordTarget} words. Cite all facts.`,
|
|
318
|
-
'ultimate-guide':`${kw}Write a definitive ultimate guide. Executive summary → TOC → deep-dive sections (H2+H3) → examples → FAQs → conclusion. ~${wordTarget}+ words.`,
|
|
319
|
-
'programmatic': `${kw}Write an SEO-optimized page. Clear H1 → key info table → main content → FAQs → CTA. Concise, factual. ~${wordTarget} words.`,
|
|
320
|
-
}
|
|
321
|
-
return structures[type]
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
private async generateContent(_title: string, _topic: string, structure: string, _keywords: string[]): Promise<string> {
|
|
325
|
-
// Claude, the runtime LLM, fills this in when invoked via CLI / Code.
|
|
326
|
-
return `<!-- Agent: generate ${structure} -->`
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
private async generateExcerpt(_content: string, type: ContentType): Promise<string> {
|
|
330
|
-
return `<!-- Agent: write a 1-sentence hook excerpt for this ${type} -->`
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
private async generateSEOTitle(title: string, keywords: string[]): Promise<string> {
|
|
334
|
-
const kw = keywords[0] ?? ''
|
|
335
|
-
const base = kw && !title.toLowerCase().includes(kw.toLowerCase())
|
|
336
|
-
? `${title} | ${kw}` : title
|
|
337
|
-
return base.slice(0, 60)
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
private async generateSEODescription(_content: string, keywords: string[]): Promise<string> {
|
|
341
|
-
return `<!-- Agent: write 155-char meta description including: ${keywords.join(', ')} -->`
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/** Count of internal-link candidates — stored as an integer on content. */
|
|
345
|
-
private async countInternalLinks(title: string, keywords: string[]): Promise<number> {
|
|
346
|
-
try {
|
|
347
|
-
const search = keywords[0] ?? title.split(' ')[0]
|
|
348
|
-
const { rows: [r] } = await db.execute({
|
|
349
|
-
sql: `SELECT COUNT(*) AS n FROM content
|
|
350
|
-
WHERE profile_id=? AND published=1 AND hidden=0
|
|
351
|
-
AND (title LIKE ? OR slug LIKE ?)`,
|
|
352
|
-
args: [this.profileId, `%${search}%`, `%${search}%`],
|
|
353
|
-
})
|
|
354
|
-
return Math.min(3, Number(r?.n ?? 0))
|
|
355
|
-
} catch { return 0 }
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
private async makeSlug(title: string, cms_id: string): Promise<string> {
|
|
359
|
-
const base = title.toLowerCase()
|
|
360
|
-
.replace(/[^a-z0-9\s-]/g, '')
|
|
361
|
-
.replace(/\s+/g, '-')
|
|
362
|
-
.replace(/-+/g, '-')
|
|
363
|
-
.slice(0, 80)
|
|
364
|
-
|
|
365
|
-
// Unique index is (profile_id, category_id, slug). Dedupe per cms section.
|
|
366
|
-
const { rows: [exists] } = await db.execute({
|
|
367
|
-
sql: `SELECT slug FROM content
|
|
368
|
-
WHERE profile_id=? AND cms_id=? AND slug=? LIMIT 1`,
|
|
369
|
-
args: [this.profileId, cms_id, base],
|
|
370
|
-
})
|
|
371
|
-
return exists ? `${base}-${Date.now().toString(36)}` : base
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
private countWords(content: string): number {
|
|
375
|
-
return content.replace(/<[^>]+>/g, '').split(/\s+/).filter(Boolean).length
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
export const blogWriter = new BlogWriter()
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# copywriting
|
|
2
|
-
|
|
3
|
-
Placeholder SOUL. See CLAUDE.md routing table and skills/copywriting/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
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* COPY — Copywriter
|
|
3
|
-
* "Words that convert. Nothing more, nothing less."
|
|
4
|
-
* Writes to: pages, product descriptions, link descriptions, profile bio/tagline
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { BaseAgent, db, ulid, now, iso } from '../_base.ts'
|
|
8
|
-
import { uniqueSlug } from '../../lib/slug.ts'
|
|
9
|
-
|
|
10
|
-
export interface PageInput {
|
|
11
|
-
title: string; slug?: string; excerpt?: string; text_field?: string
|
|
12
|
-
hero_section?: Record<string, unknown>; cta_section?: Record<string, unknown>
|
|
13
|
-
testimonials?: unknown[]; faq?: unknown[]; pricing?: unknown[]
|
|
14
|
-
intro_section?: Record<string, unknown>; about_section?: Record<string, unknown>
|
|
15
|
-
publish?: boolean
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class Copywriter extends BaseAgent {
|
|
19
|
-
readonly name = 'COPY'
|
|
20
|
-
readonly title = 'Copywriter'
|
|
21
|
-
|
|
22
|
-
async createPage(input: PageInput) {
|
|
23
|
-
await this.init()
|
|
24
|
-
const id = ulid()
|
|
25
|
-
const slug = input.slug ?? await uniqueSlug('pages', input.title, this.profileId)
|
|
26
|
-
const ts = now()
|
|
27
|
-
|
|
28
|
-
await db.execute({
|
|
29
|
-
sql: `INSERT INTO pages (id,profile_id,user_id,title,slug,excerpt,text_field,
|
|
30
|
-
hero_section,cta_section,testimonials,faq,pricing,intro_section,about_section,
|
|
31
|
-
published,hidden,created_at,updated_at)
|
|
32
|
-
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,?,?)`,
|
|
33
|
-
args: [
|
|
34
|
-
id, this.profileId, this.userId, input.title, slug,
|
|
35
|
-
input.excerpt ?? null, input.text_field ?? null,
|
|
36
|
-
input.hero_section ? JSON.stringify(input.hero_section) : null,
|
|
37
|
-
input.cta_section ? JSON.stringify(input.cta_section) : null,
|
|
38
|
-
input.testimonials ? JSON.stringify(input.testimonials) : null,
|
|
39
|
-
input.faq ? JSON.stringify(input.faq) : null,
|
|
40
|
-
input.pricing ? JSON.stringify(input.pricing) : null,
|
|
41
|
-
input.intro_section ? JSON.stringify(input.intro_section) : null,
|
|
42
|
-
input.about_section ? JSON.stringify(input.about_section) : null,
|
|
43
|
-
input.publish ? 1 : 0, ts, ts,
|
|
44
|
-
],
|
|
45
|
-
})
|
|
46
|
-
return this.getPage(id)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async getPage(id: string) {
|
|
50
|
-
const { rows: [r] } = await db.execute({ sql: 'SELECT * FROM pages WHERE id=?', args: [id] })
|
|
51
|
-
if (!r) throw new Error(`Page not found: ${id}`)
|
|
52
|
-
return r
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async listPages() {
|
|
56
|
-
await this.init()
|
|
57
|
-
const { rows } = await db.execute({
|
|
58
|
-
sql: 'SELECT id,title,slug,published,is_active FROM pages WHERE profile_id=? AND hidden=0 ORDER BY order_index',
|
|
59
|
-
args: [this.profileId],
|
|
60
|
-
})
|
|
61
|
-
return rows
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** Update profile bio and tagline */
|
|
65
|
-
async updateProfileCopy(fields: { bio?: string; tagline?: string; title?: string }) {
|
|
66
|
-
await this.init()
|
|
67
|
-
const sets = [`updated_at=${now()}`]
|
|
68
|
-
const args: unknown[] = []
|
|
69
|
-
if (fields.bio !== undefined) { sets.push('bio=?'); args.push(fields.bio) }
|
|
70
|
-
if (fields.tagline !== undefined) { sets.push('tagline=?'); args.push(fields.tagline) }
|
|
71
|
-
if (fields.title !== undefined) { sets.push('title=?'); args.push(fields.title) }
|
|
72
|
-
await db.execute({ sql: `UPDATE profiles SET ${sets.join(',')} WHERE id=?`, args: [...args, this.profileId] })
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** Update a product's description and excerpt */
|
|
76
|
-
async updateProductCopy(productId: string, fields: { description?: string; excerpt?: string; button_text?: string }) {
|
|
77
|
-
const sets = [`updated_at=${now()}`]
|
|
78
|
-
const args: unknown[] = []
|
|
79
|
-
if (fields.description !== undefined) { sets.push('description=?'); args.push(fields.description) }
|
|
80
|
-
if (fields.excerpt !== undefined) { sets.push('excerpt=?'); args.push(fields.excerpt) }
|
|
81
|
-
if (fields.button_text !== undefined) { sets.push('button_text=?'); args.push(fields.button_text) }
|
|
82
|
-
await db.execute({ sql: `UPDATE products SET ${sets.join(',')} WHERE id=?`, args: [...args, productId] })
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
async publishPage(id: string) { await super.publish('pages', id); return this.getPage(id) }
|
|
86
|
-
async archivePage(id: string) { await super.archive('pages', id) }
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export const copywriter = new Copywriter()
|
package/agents/courses/SOUL.md
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# courses
|
|
2
|
-
|
|
3
|
-
Placeholder SOUL. See CLAUDE.md routing table and skills/courses/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
|