@contractspec/lib.content-gen 1.57.0 → 1.58.0
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/dist/browser/generators/blog.js +88 -0
- package/dist/browser/generators/email.js +111 -0
- package/dist/browser/generators/index.js +367 -0
- package/dist/browser/generators/landing-page.js +93 -0
- package/dist/browser/generators/social.js +78 -0
- package/dist/browser/index.js +407 -0
- package/dist/browser/seo/index.js +42 -0
- package/dist/browser/seo/optimizer.js +42 -0
- package/dist/browser/types.js +0 -0
- package/dist/generators/blog.d.ts +10 -14
- package/dist/generators/blog.d.ts.map +1 -1
- package/dist/generators/blog.js +88 -69
- package/dist/generators/email.d.ts +13 -17
- package/dist/generators/email.d.ts.map +1 -1
- package/dist/generators/email.js +103 -91
- package/dist/generators/index.d.ts +5 -5
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +367 -5
- package/dist/generators/landing-page.d.ts +21 -25
- package/dist/generators/landing-page.d.ts.map +1 -1
- package/dist/generators/landing-page.js +93 -77
- package/dist/generators/social.d.ts +9 -13
- package/dist/generators/social.d.ts.map +1 -1
- package/dist/generators/social.js +77 -73
- package/dist/index.d.ts +4 -7
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +407 -6
- package/dist/node/generators/blog.js +88 -0
- package/dist/node/generators/email.js +111 -0
- package/dist/node/generators/index.js +367 -0
- package/dist/node/generators/landing-page.js +93 -0
- package/dist/node/generators/social.js +78 -0
- package/dist/node/index.js +407 -0
- package/dist/node/seo/index.js +42 -0
- package/dist/node/seo/optimizer.js +42 -0
- package/dist/node/types.js +0 -0
- package/dist/seo/index.d.ts +2 -2
- package/dist/seo/index.d.ts.map +1 -0
- package/dist/seo/index.js +43 -3
- package/dist/seo/optimizer.d.ts +6 -10
- package/dist/seo/optimizer.d.ts.map +1 -1
- package/dist/seo/optimizer.js +42 -48
- package/dist/types.d.ts +58 -62
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/package.json +100 -31
- package/dist/generators/blog.js.map +0 -1
- package/dist/generators/email.js.map +0 -1
- package/dist/generators/landing-page.js.map +0 -1
- package/dist/generators/social.js.map +0 -1
- package/dist/seo/optimizer.js.map +0 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// src/generators/blog.ts
|
|
2
|
+
class BlogGenerator {
|
|
3
|
+
llm;
|
|
4
|
+
model;
|
|
5
|
+
temperature;
|
|
6
|
+
constructor(options) {
|
|
7
|
+
this.llm = options?.llm;
|
|
8
|
+
this.model = options?.model;
|
|
9
|
+
this.temperature = options?.temperature ?? 0.4;
|
|
10
|
+
}
|
|
11
|
+
async generate(brief) {
|
|
12
|
+
if (this.llm) {
|
|
13
|
+
return this.generateWithLlm(brief);
|
|
14
|
+
}
|
|
15
|
+
return this.generateDeterministic(brief);
|
|
16
|
+
}
|
|
17
|
+
async generateWithLlm(brief) {
|
|
18
|
+
if (!this.llm) {
|
|
19
|
+
return this.generateDeterministic(brief);
|
|
20
|
+
}
|
|
21
|
+
const response = await this.llm.chat([
|
|
22
|
+
{
|
|
23
|
+
role: "system",
|
|
24
|
+
content: [
|
|
25
|
+
{
|
|
26
|
+
type: "text",
|
|
27
|
+
text: "You are a product marketing writer. Produce JSON with title, subtitle, intro, sections[].heading/body/bullets, outro."
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
role: "user",
|
|
33
|
+
content: [
|
|
34
|
+
{
|
|
35
|
+
type: "text",
|
|
36
|
+
text: JSON.stringify({ brief })
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
], {
|
|
41
|
+
responseFormat: "json",
|
|
42
|
+
model: this.model,
|
|
43
|
+
temperature: this.temperature
|
|
44
|
+
});
|
|
45
|
+
const jsonPart = response.message.content.find((part) => ("text" in part));
|
|
46
|
+
if (jsonPart && "text" in jsonPart) {
|
|
47
|
+
return JSON.parse(jsonPart.text);
|
|
48
|
+
}
|
|
49
|
+
return this.generateDeterministic(brief);
|
|
50
|
+
}
|
|
51
|
+
generateDeterministic(brief) {
|
|
52
|
+
const intro = `Operators like ${brief.audience.role} teams face ${brief.problems.slice(0, 2).join(" and ")}. ${brief.title} changes that by ${brief.summary}.`;
|
|
53
|
+
const sections = [
|
|
54
|
+
{
|
|
55
|
+
heading: "Why now",
|
|
56
|
+
body: this.renderWhyNow(brief)
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
heading: "What you get",
|
|
60
|
+
body: "A focused stack built for policy-safe automation.",
|
|
61
|
+
bullets: brief.solutions
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
heading: "Proof it works",
|
|
65
|
+
body: "Teams using the blueprint report measurable wins.",
|
|
66
|
+
bullets: brief.metrics ?? [
|
|
67
|
+
"Launch workflows in minutes",
|
|
68
|
+
"Cut review time by 60%"
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
return {
|
|
73
|
+
title: brief.title,
|
|
74
|
+
subtitle: brief.summary,
|
|
75
|
+
intro,
|
|
76
|
+
sections,
|
|
77
|
+
outro: brief.callToAction ?? "Ready to see it live? Spin up a sandbox in under 5 minutes."
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
renderWhyNow(brief) {
|
|
81
|
+
const audience = `${brief.audience.role}${brief.audience.industry ? ` in ${brief.audience.industry}` : ""}`;
|
|
82
|
+
const pains = brief.problems.slice(0, 2).join("; ");
|
|
83
|
+
return `${audience} teams are stuck with ${pains}. ${brief.title} delivers guardrails without slowing shipping.`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export {
|
|
87
|
+
BlogGenerator
|
|
88
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// src/generators/email.ts
|
|
2
|
+
class EmailCampaignGenerator {
|
|
3
|
+
llm;
|
|
4
|
+
model;
|
|
5
|
+
temperature;
|
|
6
|
+
constructor(options) {
|
|
7
|
+
this.llm = options?.llm;
|
|
8
|
+
this.model = options?.model;
|
|
9
|
+
this.temperature = options?.temperature ?? 0.6;
|
|
10
|
+
}
|
|
11
|
+
async generate(input) {
|
|
12
|
+
if (this.llm) {
|
|
13
|
+
const draft = await this.generateWithLlm(input);
|
|
14
|
+
if (draft)
|
|
15
|
+
return draft;
|
|
16
|
+
}
|
|
17
|
+
return this.generateFallback(input);
|
|
18
|
+
}
|
|
19
|
+
async generateWithLlm(input) {
|
|
20
|
+
if (!this.llm)
|
|
21
|
+
return null;
|
|
22
|
+
const response = await this.llm.chat([
|
|
23
|
+
{
|
|
24
|
+
role: "system",
|
|
25
|
+
content: [
|
|
26
|
+
{
|
|
27
|
+
type: "text",
|
|
28
|
+
text: "Draft product marketing email as JSON {subject, previewText, body, cta}."
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
role: "user",
|
|
34
|
+
content: [{ type: "text", text: JSON.stringify(input) }]
|
|
35
|
+
}
|
|
36
|
+
], {
|
|
37
|
+
responseFormat: "json",
|
|
38
|
+
model: this.model,
|
|
39
|
+
temperature: this.temperature
|
|
40
|
+
});
|
|
41
|
+
const jsonPart = response.message.content.find((chunk) => ("text" in chunk));
|
|
42
|
+
if (!jsonPart || !("text" in jsonPart))
|
|
43
|
+
return null;
|
|
44
|
+
const parsed = JSON.parse(jsonPart.text);
|
|
45
|
+
if (!parsed.subject || !parsed.body || !parsed.cta)
|
|
46
|
+
return null;
|
|
47
|
+
return {
|
|
48
|
+
subject: parsed.subject,
|
|
49
|
+
previewText: parsed.previewText ?? this.defaultPreview(input),
|
|
50
|
+
body: parsed.body,
|
|
51
|
+
cta: parsed.cta,
|
|
52
|
+
variant: input.variant
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
generateFallback(input) {
|
|
56
|
+
const { brief, variant } = input;
|
|
57
|
+
const subject = this.subjects(brief.title, variant)[0] ?? `${brief.title} update`;
|
|
58
|
+
const previewText = this.defaultPreview(input);
|
|
59
|
+
const body = this.renderBody(input);
|
|
60
|
+
const cta = brief.callToAction ?? "Explore the sandbox";
|
|
61
|
+
return { subject, previewText, body, cta, variant };
|
|
62
|
+
}
|
|
63
|
+
subjects(title, variant) {
|
|
64
|
+
switch (variant) {
|
|
65
|
+
case "announcement":
|
|
66
|
+
return [`Launch: ${title}`, `${title} is live`, `New: ${title}`];
|
|
67
|
+
case "onboarding":
|
|
68
|
+
return [`Get started with ${title}`, `Your ${title} guide`];
|
|
69
|
+
case "nurture":
|
|
70
|
+
default:
|
|
71
|
+
return [`How ${title} speeds ops`, `Proof ${title} works`];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
defaultPreview(input) {
|
|
75
|
+
const win = input.brief.metrics?.[0] ?? "ship faster without policy gaps";
|
|
76
|
+
return `See how teams ${win}.`;
|
|
77
|
+
}
|
|
78
|
+
renderBody(input) {
|
|
79
|
+
const { brief, variant } = input;
|
|
80
|
+
const greeting = "Hi there,";
|
|
81
|
+
const hook = this.variantHook(variant, brief);
|
|
82
|
+
const proof = brief.metrics?.map((metric) => `• ${metric}`).join(`
|
|
83
|
+
`) ?? "";
|
|
84
|
+
return `${greeting}
|
|
85
|
+
|
|
86
|
+
${hook}
|
|
87
|
+
|
|
88
|
+
Top reasons teams adopt ${brief.title}:
|
|
89
|
+
${brief.solutions.map((solution) => `• ${solution}`).join(`
|
|
90
|
+
`)}
|
|
91
|
+
|
|
92
|
+
${proof}
|
|
93
|
+
|
|
94
|
+
${brief.callToAction ?? "Spin up a sandbox"} → ${(input.cadenceDay ?? 0) + 1}
|
|
95
|
+
`;
|
|
96
|
+
}
|
|
97
|
+
variantHook(variant, brief) {
|
|
98
|
+
switch (variant) {
|
|
99
|
+
case "announcement":
|
|
100
|
+
return `${brief.title} is live. ${brief.summary}`;
|
|
101
|
+
case "onboarding":
|
|
102
|
+
return `Here is your next step to unlock ${brief.title}.`;
|
|
103
|
+
case "nurture":
|
|
104
|
+
default:
|
|
105
|
+
return `Operators like ${brief.audience.role} keep asking how to automate policy checks. Here is what works.`;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
EmailCampaignGenerator
|
|
111
|
+
};
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
// src/generators/blog.ts
|
|
2
|
+
class BlogGenerator {
|
|
3
|
+
llm;
|
|
4
|
+
model;
|
|
5
|
+
temperature;
|
|
6
|
+
constructor(options) {
|
|
7
|
+
this.llm = options?.llm;
|
|
8
|
+
this.model = options?.model;
|
|
9
|
+
this.temperature = options?.temperature ?? 0.4;
|
|
10
|
+
}
|
|
11
|
+
async generate(brief) {
|
|
12
|
+
if (this.llm) {
|
|
13
|
+
return this.generateWithLlm(brief);
|
|
14
|
+
}
|
|
15
|
+
return this.generateDeterministic(brief);
|
|
16
|
+
}
|
|
17
|
+
async generateWithLlm(brief) {
|
|
18
|
+
if (!this.llm) {
|
|
19
|
+
return this.generateDeterministic(brief);
|
|
20
|
+
}
|
|
21
|
+
const response = await this.llm.chat([
|
|
22
|
+
{
|
|
23
|
+
role: "system",
|
|
24
|
+
content: [
|
|
25
|
+
{
|
|
26
|
+
type: "text",
|
|
27
|
+
text: "You are a product marketing writer. Produce JSON with title, subtitle, intro, sections[].heading/body/bullets, outro."
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
role: "user",
|
|
33
|
+
content: [
|
|
34
|
+
{
|
|
35
|
+
type: "text",
|
|
36
|
+
text: JSON.stringify({ brief })
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
], {
|
|
41
|
+
responseFormat: "json",
|
|
42
|
+
model: this.model,
|
|
43
|
+
temperature: this.temperature
|
|
44
|
+
});
|
|
45
|
+
const jsonPart = response.message.content.find((part) => ("text" in part));
|
|
46
|
+
if (jsonPart && "text" in jsonPart) {
|
|
47
|
+
return JSON.parse(jsonPart.text);
|
|
48
|
+
}
|
|
49
|
+
return this.generateDeterministic(brief);
|
|
50
|
+
}
|
|
51
|
+
generateDeterministic(brief) {
|
|
52
|
+
const intro = `Operators like ${brief.audience.role} teams face ${brief.problems.slice(0, 2).join(" and ")}. ${brief.title} changes that by ${brief.summary}.`;
|
|
53
|
+
const sections = [
|
|
54
|
+
{
|
|
55
|
+
heading: "Why now",
|
|
56
|
+
body: this.renderWhyNow(brief)
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
heading: "What you get",
|
|
60
|
+
body: "A focused stack built for policy-safe automation.",
|
|
61
|
+
bullets: brief.solutions
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
heading: "Proof it works",
|
|
65
|
+
body: "Teams using the blueprint report measurable wins.",
|
|
66
|
+
bullets: brief.metrics ?? [
|
|
67
|
+
"Launch workflows in minutes",
|
|
68
|
+
"Cut review time by 60%"
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
return {
|
|
73
|
+
title: brief.title,
|
|
74
|
+
subtitle: brief.summary,
|
|
75
|
+
intro,
|
|
76
|
+
sections,
|
|
77
|
+
outro: brief.callToAction ?? "Ready to see it live? Spin up a sandbox in under 5 minutes."
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
renderWhyNow(brief) {
|
|
81
|
+
const audience = `${brief.audience.role}${brief.audience.industry ? ` in ${brief.audience.industry}` : ""}`;
|
|
82
|
+
const pains = brief.problems.slice(0, 2).join("; ");
|
|
83
|
+
return `${audience} teams are stuck with ${pains}. ${brief.title} delivers guardrails without slowing shipping.`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/generators/email.ts
|
|
88
|
+
class EmailCampaignGenerator {
|
|
89
|
+
llm;
|
|
90
|
+
model;
|
|
91
|
+
temperature;
|
|
92
|
+
constructor(options) {
|
|
93
|
+
this.llm = options?.llm;
|
|
94
|
+
this.model = options?.model;
|
|
95
|
+
this.temperature = options?.temperature ?? 0.6;
|
|
96
|
+
}
|
|
97
|
+
async generate(input) {
|
|
98
|
+
if (this.llm) {
|
|
99
|
+
const draft = await this.generateWithLlm(input);
|
|
100
|
+
if (draft)
|
|
101
|
+
return draft;
|
|
102
|
+
}
|
|
103
|
+
return this.generateFallback(input);
|
|
104
|
+
}
|
|
105
|
+
async generateWithLlm(input) {
|
|
106
|
+
if (!this.llm)
|
|
107
|
+
return null;
|
|
108
|
+
const response = await this.llm.chat([
|
|
109
|
+
{
|
|
110
|
+
role: "system",
|
|
111
|
+
content: [
|
|
112
|
+
{
|
|
113
|
+
type: "text",
|
|
114
|
+
text: "Draft product marketing email as JSON {subject, previewText, body, cta}."
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
role: "user",
|
|
120
|
+
content: [{ type: "text", text: JSON.stringify(input) }]
|
|
121
|
+
}
|
|
122
|
+
], {
|
|
123
|
+
responseFormat: "json",
|
|
124
|
+
model: this.model,
|
|
125
|
+
temperature: this.temperature
|
|
126
|
+
});
|
|
127
|
+
const jsonPart = response.message.content.find((chunk) => ("text" in chunk));
|
|
128
|
+
if (!jsonPart || !("text" in jsonPart))
|
|
129
|
+
return null;
|
|
130
|
+
const parsed = JSON.parse(jsonPart.text);
|
|
131
|
+
if (!parsed.subject || !parsed.body || !parsed.cta)
|
|
132
|
+
return null;
|
|
133
|
+
return {
|
|
134
|
+
subject: parsed.subject,
|
|
135
|
+
previewText: parsed.previewText ?? this.defaultPreview(input),
|
|
136
|
+
body: parsed.body,
|
|
137
|
+
cta: parsed.cta,
|
|
138
|
+
variant: input.variant
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
generateFallback(input) {
|
|
142
|
+
const { brief, variant } = input;
|
|
143
|
+
const subject = this.subjects(brief.title, variant)[0] ?? `${brief.title} update`;
|
|
144
|
+
const previewText = this.defaultPreview(input);
|
|
145
|
+
const body = this.renderBody(input);
|
|
146
|
+
const cta = brief.callToAction ?? "Explore the sandbox";
|
|
147
|
+
return { subject, previewText, body, cta, variant };
|
|
148
|
+
}
|
|
149
|
+
subjects(title, variant) {
|
|
150
|
+
switch (variant) {
|
|
151
|
+
case "announcement":
|
|
152
|
+
return [`Launch: ${title}`, `${title} is live`, `New: ${title}`];
|
|
153
|
+
case "onboarding":
|
|
154
|
+
return [`Get started with ${title}`, `Your ${title} guide`];
|
|
155
|
+
case "nurture":
|
|
156
|
+
default:
|
|
157
|
+
return [`How ${title} speeds ops`, `Proof ${title} works`];
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
defaultPreview(input) {
|
|
161
|
+
const win = input.brief.metrics?.[0] ?? "ship faster without policy gaps";
|
|
162
|
+
return `See how teams ${win}.`;
|
|
163
|
+
}
|
|
164
|
+
renderBody(input) {
|
|
165
|
+
const { brief, variant } = input;
|
|
166
|
+
const greeting = "Hi there,";
|
|
167
|
+
const hook = this.variantHook(variant, brief);
|
|
168
|
+
const proof = brief.metrics?.map((metric) => `• ${metric}`).join(`
|
|
169
|
+
`) ?? "";
|
|
170
|
+
return `${greeting}
|
|
171
|
+
|
|
172
|
+
${hook}
|
|
173
|
+
|
|
174
|
+
Top reasons teams adopt ${brief.title}:
|
|
175
|
+
${brief.solutions.map((solution) => `• ${solution}`).join(`
|
|
176
|
+
`)}
|
|
177
|
+
|
|
178
|
+
${proof}
|
|
179
|
+
|
|
180
|
+
${brief.callToAction ?? "Spin up a sandbox"} → ${(input.cadenceDay ?? 0) + 1}
|
|
181
|
+
`;
|
|
182
|
+
}
|
|
183
|
+
variantHook(variant, brief) {
|
|
184
|
+
switch (variant) {
|
|
185
|
+
case "announcement":
|
|
186
|
+
return `${brief.title} is live. ${brief.summary}`;
|
|
187
|
+
case "onboarding":
|
|
188
|
+
return `Here is your next step to unlock ${brief.title}.`;
|
|
189
|
+
case "nurture":
|
|
190
|
+
default:
|
|
191
|
+
return `Operators like ${brief.audience.role} keep asking how to automate policy checks. Here is what works.`;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// src/generators/landing-page.ts
|
|
197
|
+
class LandingPageGenerator {
|
|
198
|
+
options;
|
|
199
|
+
llm;
|
|
200
|
+
model;
|
|
201
|
+
constructor(options) {
|
|
202
|
+
this.options = options;
|
|
203
|
+
this.llm = options?.llm;
|
|
204
|
+
this.model = options?.model;
|
|
205
|
+
}
|
|
206
|
+
async generate(brief) {
|
|
207
|
+
if (this.llm) {
|
|
208
|
+
return this.generateWithLlm(brief);
|
|
209
|
+
}
|
|
210
|
+
return this.generateFallback(brief);
|
|
211
|
+
}
|
|
212
|
+
async generateWithLlm(brief) {
|
|
213
|
+
if (!this.llm) {
|
|
214
|
+
return this.generateFallback(brief);
|
|
215
|
+
}
|
|
216
|
+
const response = await this.llm.chat([
|
|
217
|
+
{
|
|
218
|
+
role: "system",
|
|
219
|
+
content: [
|
|
220
|
+
{
|
|
221
|
+
type: "text",
|
|
222
|
+
text: "Write JSON landing page copy with hero/highlights/socialProof/faq arrays."
|
|
223
|
+
}
|
|
224
|
+
]
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
role: "user",
|
|
228
|
+
content: [{ type: "text", text: JSON.stringify({ brief }) }]
|
|
229
|
+
}
|
|
230
|
+
], {
|
|
231
|
+
responseFormat: "json",
|
|
232
|
+
model: this.model,
|
|
233
|
+
temperature: this.options?.temperature ?? 0.5
|
|
234
|
+
});
|
|
235
|
+
const part = response.message.content.find((chunk) => ("text" in chunk));
|
|
236
|
+
if (part && "text" in part) {
|
|
237
|
+
return JSON.parse(part.text);
|
|
238
|
+
}
|
|
239
|
+
return this.generateFallback(brief);
|
|
240
|
+
}
|
|
241
|
+
generateFallback(brief) {
|
|
242
|
+
return {
|
|
243
|
+
hero: {
|
|
244
|
+
eyebrow: `${brief.audience.industry ?? "Operations"} teams`,
|
|
245
|
+
title: brief.title,
|
|
246
|
+
subtitle: brief.summary,
|
|
247
|
+
primaryCta: brief.callToAction ?? "Launch a sandbox",
|
|
248
|
+
secondaryCta: "View docs"
|
|
249
|
+
},
|
|
250
|
+
highlights: brief.solutions.slice(0, 3).map((solution, index) => ({
|
|
251
|
+
heading: [
|
|
252
|
+
"Policy-safe by default",
|
|
253
|
+
"Auto-adapts per tenant",
|
|
254
|
+
"Launch-ready in days"
|
|
255
|
+
][index] ?? "Key capability",
|
|
256
|
+
body: solution
|
|
257
|
+
})),
|
|
258
|
+
socialProof: {
|
|
259
|
+
heading: "Teams using ContractSpec",
|
|
260
|
+
body: brief.proofPoints?.join(`
|
|
261
|
+
`) ?? "“We ship compliant workflows 5x faster while cutting ops toil in half.”"
|
|
262
|
+
},
|
|
263
|
+
faq: this.buildFaq(brief)
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
buildFaq(brief) {
|
|
267
|
+
const faqs = [
|
|
268
|
+
{
|
|
269
|
+
heading: "How does this keep policies enforced?",
|
|
270
|
+
body: "All workflows compile from TypeScript specs and pass through PDP checks before execution, so no shadow logic slips through."
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
heading: "Will it fit our existing stack?",
|
|
274
|
+
body: "Runtime adapters plug into REST, GraphQL, or MCP. Integrations stay vendor agnostic."
|
|
275
|
+
}
|
|
276
|
+
];
|
|
277
|
+
if (brief.complianceNotes?.length) {
|
|
278
|
+
faqs.push({
|
|
279
|
+
heading: "What about compliance requirements?",
|
|
280
|
+
body: brief.complianceNotes.join(" ")
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
return faqs;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// src/generators/social.ts
|
|
288
|
+
class SocialPostGenerator {
|
|
289
|
+
llm;
|
|
290
|
+
model;
|
|
291
|
+
constructor(options) {
|
|
292
|
+
this.llm = options?.llm;
|
|
293
|
+
this.model = options?.model;
|
|
294
|
+
}
|
|
295
|
+
async generate(brief) {
|
|
296
|
+
if (this.llm) {
|
|
297
|
+
const posts = await this.generateWithLlm(brief);
|
|
298
|
+
if (posts.length)
|
|
299
|
+
return posts;
|
|
300
|
+
}
|
|
301
|
+
return this.generateFallback(brief);
|
|
302
|
+
}
|
|
303
|
+
async generateWithLlm(brief) {
|
|
304
|
+
if (!this.llm)
|
|
305
|
+
return [];
|
|
306
|
+
const response = await this.llm.chat([
|
|
307
|
+
{
|
|
308
|
+
role: "system",
|
|
309
|
+
content: [
|
|
310
|
+
{
|
|
311
|
+
type: "text",
|
|
312
|
+
text: "Create JSON array of social posts for twitter/linkedin/threads with body, hashtags, cta."
|
|
313
|
+
}
|
|
314
|
+
]
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
role: "user",
|
|
318
|
+
content: [{ type: "text", text: JSON.stringify(brief) }]
|
|
319
|
+
}
|
|
320
|
+
], { responseFormat: "json", model: this.model });
|
|
321
|
+
const part = response.message.content.find((chunk) => ("text" in chunk));
|
|
322
|
+
if (!part || !("text" in part))
|
|
323
|
+
return [];
|
|
324
|
+
return JSON.parse(part.text);
|
|
325
|
+
}
|
|
326
|
+
generateFallback(brief) {
|
|
327
|
+
const hashtags = this.buildHashtags(brief);
|
|
328
|
+
return [
|
|
329
|
+
{
|
|
330
|
+
channel: "linkedin",
|
|
331
|
+
body: `${brief.title}: ${brief.summary}
|
|
332
|
+
${brief.problems[0]} → ${brief.solutions[0]}`,
|
|
333
|
+
hashtags,
|
|
334
|
+
cta: brief.callToAction ?? "Book a 15-min run-through"
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
channel: "twitter",
|
|
338
|
+
body: `${brief.solutions[0]} in <60s. ${brief.solutions[1] ?? ""}`.trim(),
|
|
339
|
+
hashtags: hashtags.slice(0, 3),
|
|
340
|
+
cta: "→ contractspec.io/sandbox"
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
channel: "threads",
|
|
344
|
+
body: `Ops + policy can move fast. ${brief.title} automates guardrails so teams ship daily.`,
|
|
345
|
+
hashtags: hashtags.slice(1, 4)
|
|
346
|
+
}
|
|
347
|
+
];
|
|
348
|
+
}
|
|
349
|
+
buildHashtags(brief) {
|
|
350
|
+
const base = [
|
|
351
|
+
brief.audience.industry ? `#${camel(brief.audience.industry)}` : "#operations",
|
|
352
|
+
"#automation",
|
|
353
|
+
"#aiops",
|
|
354
|
+
"#compliance"
|
|
355
|
+
];
|
|
356
|
+
return [...new Set(base.map((tag) => tag.replace(/\s+/g, "")))].slice(0, 5);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
function camel(text) {
|
|
360
|
+
return text.split(/\s|-/).filter(Boolean).map((word) => word[0]?.toUpperCase() + word.slice(1)).join("");
|
|
361
|
+
}
|
|
362
|
+
export {
|
|
363
|
+
SocialPostGenerator,
|
|
364
|
+
LandingPageGenerator,
|
|
365
|
+
EmailCampaignGenerator,
|
|
366
|
+
BlogGenerator
|
|
367
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// src/generators/landing-page.ts
|
|
2
|
+
class LandingPageGenerator {
|
|
3
|
+
options;
|
|
4
|
+
llm;
|
|
5
|
+
model;
|
|
6
|
+
constructor(options) {
|
|
7
|
+
this.options = options;
|
|
8
|
+
this.llm = options?.llm;
|
|
9
|
+
this.model = options?.model;
|
|
10
|
+
}
|
|
11
|
+
async generate(brief) {
|
|
12
|
+
if (this.llm) {
|
|
13
|
+
return this.generateWithLlm(brief);
|
|
14
|
+
}
|
|
15
|
+
return this.generateFallback(brief);
|
|
16
|
+
}
|
|
17
|
+
async generateWithLlm(brief) {
|
|
18
|
+
if (!this.llm) {
|
|
19
|
+
return this.generateFallback(brief);
|
|
20
|
+
}
|
|
21
|
+
const response = await this.llm.chat([
|
|
22
|
+
{
|
|
23
|
+
role: "system",
|
|
24
|
+
content: [
|
|
25
|
+
{
|
|
26
|
+
type: "text",
|
|
27
|
+
text: "Write JSON landing page copy with hero/highlights/socialProof/faq arrays."
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
role: "user",
|
|
33
|
+
content: [{ type: "text", text: JSON.stringify({ brief }) }]
|
|
34
|
+
}
|
|
35
|
+
], {
|
|
36
|
+
responseFormat: "json",
|
|
37
|
+
model: this.model,
|
|
38
|
+
temperature: this.options?.temperature ?? 0.5
|
|
39
|
+
});
|
|
40
|
+
const part = response.message.content.find((chunk) => ("text" in chunk));
|
|
41
|
+
if (part && "text" in part) {
|
|
42
|
+
return JSON.parse(part.text);
|
|
43
|
+
}
|
|
44
|
+
return this.generateFallback(brief);
|
|
45
|
+
}
|
|
46
|
+
generateFallback(brief) {
|
|
47
|
+
return {
|
|
48
|
+
hero: {
|
|
49
|
+
eyebrow: `${brief.audience.industry ?? "Operations"} teams`,
|
|
50
|
+
title: brief.title,
|
|
51
|
+
subtitle: brief.summary,
|
|
52
|
+
primaryCta: brief.callToAction ?? "Launch a sandbox",
|
|
53
|
+
secondaryCta: "View docs"
|
|
54
|
+
},
|
|
55
|
+
highlights: brief.solutions.slice(0, 3).map((solution, index) => ({
|
|
56
|
+
heading: [
|
|
57
|
+
"Policy-safe by default",
|
|
58
|
+
"Auto-adapts per tenant",
|
|
59
|
+
"Launch-ready in days"
|
|
60
|
+
][index] ?? "Key capability",
|
|
61
|
+
body: solution
|
|
62
|
+
})),
|
|
63
|
+
socialProof: {
|
|
64
|
+
heading: "Teams using ContractSpec",
|
|
65
|
+
body: brief.proofPoints?.join(`
|
|
66
|
+
`) ?? "“We ship compliant workflows 5x faster while cutting ops toil in half.”"
|
|
67
|
+
},
|
|
68
|
+
faq: this.buildFaq(brief)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
buildFaq(brief) {
|
|
72
|
+
const faqs = [
|
|
73
|
+
{
|
|
74
|
+
heading: "How does this keep policies enforced?",
|
|
75
|
+
body: "All workflows compile from TypeScript specs and pass through PDP checks before execution, so no shadow logic slips through."
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
heading: "Will it fit our existing stack?",
|
|
79
|
+
body: "Runtime adapters plug into REST, GraphQL, or MCP. Integrations stay vendor agnostic."
|
|
80
|
+
}
|
|
81
|
+
];
|
|
82
|
+
if (brief.complianceNotes?.length) {
|
|
83
|
+
faqs.push({
|
|
84
|
+
heading: "What about compliance requirements?",
|
|
85
|
+
body: brief.complianceNotes.join(" ")
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return faqs;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
LandingPageGenerator
|
|
93
|
+
};
|