@contractspec/lib.content-gen 1.57.0 → 1.59.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
package/dist/generators/blog.js
CHANGED
|
@@ -1,70 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/generators/blog.ts
|
|
3
|
+
class BlogGenerator {
|
|
4
|
+
llm;
|
|
5
|
+
model;
|
|
6
|
+
temperature;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.llm = options?.llm;
|
|
9
|
+
this.model = options?.model;
|
|
10
|
+
this.temperature = options?.temperature ?? 0.4;
|
|
11
|
+
}
|
|
12
|
+
async generate(brief) {
|
|
13
|
+
if (this.llm) {
|
|
14
|
+
return this.generateWithLlm(brief);
|
|
15
|
+
}
|
|
16
|
+
return this.generateDeterministic(brief);
|
|
17
|
+
}
|
|
18
|
+
async generateWithLlm(brief) {
|
|
19
|
+
if (!this.llm) {
|
|
20
|
+
return this.generateDeterministic(brief);
|
|
21
|
+
}
|
|
22
|
+
const response = await this.llm.chat([
|
|
23
|
+
{
|
|
24
|
+
role: "system",
|
|
25
|
+
content: [
|
|
26
|
+
{
|
|
27
|
+
type: "text",
|
|
28
|
+
text: "You are a product marketing writer. Produce JSON with title, subtitle, intro, sections[].heading/body/bullets, outro."
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
role: "user",
|
|
34
|
+
content: [
|
|
35
|
+
{
|
|
36
|
+
type: "text",
|
|
37
|
+
text: JSON.stringify({ brief })
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
], {
|
|
42
|
+
responseFormat: "json",
|
|
43
|
+
model: this.model,
|
|
44
|
+
temperature: this.temperature
|
|
45
|
+
});
|
|
46
|
+
const jsonPart = response.message.content.find((part) => ("text" in part));
|
|
47
|
+
if (jsonPart && "text" in jsonPart) {
|
|
48
|
+
return JSON.parse(jsonPart.text);
|
|
49
|
+
}
|
|
50
|
+
return this.generateDeterministic(brief);
|
|
51
|
+
}
|
|
52
|
+
generateDeterministic(brief) {
|
|
53
|
+
const intro = `Operators like ${brief.audience.role} teams face ${brief.problems.slice(0, 2).join(" and ")}. ${brief.title} changes that by ${brief.summary}.`;
|
|
54
|
+
const sections = [
|
|
55
|
+
{
|
|
56
|
+
heading: "Why now",
|
|
57
|
+
body: this.renderWhyNow(brief)
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
heading: "What you get",
|
|
61
|
+
body: "A focused stack built for policy-safe automation.",
|
|
62
|
+
bullets: brief.solutions
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
heading: "Proof it works",
|
|
66
|
+
body: "Teams using the blueprint report measurable wins.",
|
|
67
|
+
bullets: brief.metrics ?? [
|
|
68
|
+
"Launch workflows in minutes",
|
|
69
|
+
"Cut review time by 60%"
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
return {
|
|
74
|
+
title: brief.title,
|
|
75
|
+
subtitle: brief.summary,
|
|
76
|
+
intro,
|
|
77
|
+
sections,
|
|
78
|
+
outro: brief.callToAction ?? "Ready to see it live? Spin up a sandbox in under 5 minutes."
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
renderWhyNow(brief) {
|
|
82
|
+
const audience = `${brief.audience.role}${brief.audience.industry ? ` in ${brief.audience.industry}` : ""}`;
|
|
83
|
+
const pains = brief.problems.slice(0, 2).join("; ");
|
|
84
|
+
return `${audience} teams are stuck with ${pains}. ${brief.title} delivers guardrails without slowing shipping.`;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
BlogGenerator
|
|
66
89
|
};
|
|
67
|
-
|
|
68
|
-
//#endregion
|
|
69
|
-
export { BlogGenerator };
|
|
70
|
-
//# sourceMappingURL=blog.js.map
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import { EmailCampaignBrief, EmailDraft, GeneratorOptions } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
private renderBody;
|
|
15
|
-
private variantHook;
|
|
1
|
+
import type { EmailCampaignBrief, EmailDraft, GeneratorOptions } from '../types';
|
|
2
|
+
export declare class EmailCampaignGenerator {
|
|
3
|
+
private readonly llm?;
|
|
4
|
+
private readonly model?;
|
|
5
|
+
private readonly temperature;
|
|
6
|
+
constructor(options?: GeneratorOptions);
|
|
7
|
+
generate(input: EmailCampaignBrief): Promise<EmailDraft>;
|
|
8
|
+
private generateWithLlm;
|
|
9
|
+
private generateFallback;
|
|
10
|
+
private subjects;
|
|
11
|
+
private defaultPreview;
|
|
12
|
+
private renderBody;
|
|
13
|
+
private variantHook;
|
|
16
14
|
}
|
|
17
|
-
//#endregion
|
|
18
|
-
export { EmailCampaignGenerator };
|
|
19
15
|
//# sourceMappingURL=email.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.d.ts","
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/generators/email.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAGlB,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAc;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;gBAEzB,OAAO,CAAC,EAAE,gBAAgB;IAMhC,QAAQ,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC;YAQhD,eAAe;IAuC7B,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,QAAQ;IAehB,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,UAAU;IAmBlB,OAAO,CAAC,WAAW;CAcpB"}
|
package/dist/generators/email.js
CHANGED
|
@@ -1,100 +1,112 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/generators/email.ts
|
|
3
|
+
class EmailCampaignGenerator {
|
|
4
|
+
llm;
|
|
5
|
+
model;
|
|
6
|
+
temperature;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.llm = options?.llm;
|
|
9
|
+
this.model = options?.model;
|
|
10
|
+
this.temperature = options?.temperature ?? 0.6;
|
|
11
|
+
}
|
|
12
|
+
async generate(input) {
|
|
13
|
+
if (this.llm) {
|
|
14
|
+
const draft = await this.generateWithLlm(input);
|
|
15
|
+
if (draft)
|
|
16
|
+
return draft;
|
|
17
|
+
}
|
|
18
|
+
return this.generateFallback(input);
|
|
19
|
+
}
|
|
20
|
+
async generateWithLlm(input) {
|
|
21
|
+
if (!this.llm)
|
|
22
|
+
return null;
|
|
23
|
+
const response = await this.llm.chat([
|
|
24
|
+
{
|
|
25
|
+
role: "system",
|
|
26
|
+
content: [
|
|
27
|
+
{
|
|
28
|
+
type: "text",
|
|
29
|
+
text: "Draft product marketing email as JSON {subject, previewText, body, cta}."
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
role: "user",
|
|
35
|
+
content: [{ type: "text", text: JSON.stringify(input) }]
|
|
36
|
+
}
|
|
37
|
+
], {
|
|
38
|
+
responseFormat: "json",
|
|
39
|
+
model: this.model,
|
|
40
|
+
temperature: this.temperature
|
|
41
|
+
});
|
|
42
|
+
const jsonPart = response.message.content.find((chunk) => ("text" in chunk));
|
|
43
|
+
if (!jsonPart || !("text" in jsonPart))
|
|
44
|
+
return null;
|
|
45
|
+
const parsed = JSON.parse(jsonPart.text);
|
|
46
|
+
if (!parsed.subject || !parsed.body || !parsed.cta)
|
|
47
|
+
return null;
|
|
48
|
+
return {
|
|
49
|
+
subject: parsed.subject,
|
|
50
|
+
previewText: parsed.previewText ?? this.defaultPreview(input),
|
|
51
|
+
body: parsed.body,
|
|
52
|
+
cta: parsed.cta,
|
|
53
|
+
variant: input.variant
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
generateFallback(input) {
|
|
57
|
+
const { brief, variant } = input;
|
|
58
|
+
const subject = this.subjects(brief.title, variant)[0] ?? `${brief.title} update`;
|
|
59
|
+
const previewText = this.defaultPreview(input);
|
|
60
|
+
const body = this.renderBody(input);
|
|
61
|
+
const cta = brief.callToAction ?? "Explore the sandbox";
|
|
62
|
+
return { subject, previewText, body, cta, variant };
|
|
63
|
+
}
|
|
64
|
+
subjects(title, variant) {
|
|
65
|
+
switch (variant) {
|
|
66
|
+
case "announcement":
|
|
67
|
+
return [`Launch: ${title}`, `${title} is live`, `New: ${title}`];
|
|
68
|
+
case "onboarding":
|
|
69
|
+
return [`Get started with ${title}`, `Your ${title} guide`];
|
|
70
|
+
case "nurture":
|
|
71
|
+
default:
|
|
72
|
+
return [`How ${title} speeds ops`, `Proof ${title} works`];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
defaultPreview(input) {
|
|
76
|
+
const win = input.brief.metrics?.[0] ?? "ship faster without policy gaps";
|
|
77
|
+
return `See how teams ${win}.`;
|
|
78
|
+
}
|
|
79
|
+
renderBody(input) {
|
|
80
|
+
const { brief, variant } = input;
|
|
81
|
+
const greeting = "Hi there,";
|
|
82
|
+
const hook = this.variantHook(variant, brief);
|
|
83
|
+
const proof = brief.metrics?.map((metric) => `\u2022 ${metric}`).join(`
|
|
84
|
+
`) ?? "";
|
|
85
|
+
return `${greeting}
|
|
78
86
|
|
|
79
87
|
${hook}
|
|
80
88
|
|
|
81
89
|
Top reasons teams adopt ${brief.title}:
|
|
82
|
-
${brief.solutions.map((solution) =>
|
|
90
|
+
${brief.solutions.map((solution) => `\u2022 ${solution}`).join(`
|
|
91
|
+
`)}
|
|
83
92
|
|
|
84
93
|
${proof}
|
|
85
94
|
|
|
86
|
-
${brief.callToAction ?? "Spin up a sandbox"}
|
|
95
|
+
${brief.callToAction ?? "Spin up a sandbox"} \u2192 ${(input.cadenceDay ?? 0) + 1}
|
|
87
96
|
`;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
}
|
|
98
|
+
variantHook(variant, brief) {
|
|
99
|
+
switch (variant) {
|
|
100
|
+
case "announcement":
|
|
101
|
+
return `${brief.title} is live. ${brief.summary}`;
|
|
102
|
+
case "onboarding":
|
|
103
|
+
return `Here is your next step to unlock ${brief.title}.`;
|
|
104
|
+
case "nurture":
|
|
105
|
+
default:
|
|
106
|
+
return `Operators like ${brief.audience.role} keep asking how to automate policy checks. Here is what works.`;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
EmailCampaignGenerator
|
|
96
112
|
};
|
|
97
|
-
|
|
98
|
-
//#endregion
|
|
99
|
-
export { EmailCampaignGenerator };
|
|
100
|
-
//# sourceMappingURL=email.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export * from './blog';
|
|
2
|
+
export * from './landing-page';
|
|
3
|
+
export * from './email';
|
|
4
|
+
export * from './social';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generators/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|