@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.
Files changed (51) hide show
  1. package/dist/browser/generators/blog.js +88 -0
  2. package/dist/browser/generators/email.js +111 -0
  3. package/dist/browser/generators/index.js +367 -0
  4. package/dist/browser/generators/landing-page.js +93 -0
  5. package/dist/browser/generators/social.js +78 -0
  6. package/dist/browser/index.js +407 -0
  7. package/dist/browser/seo/index.js +42 -0
  8. package/dist/browser/seo/optimizer.js +42 -0
  9. package/dist/browser/types.js +0 -0
  10. package/dist/generators/blog.d.ts +10 -14
  11. package/dist/generators/blog.d.ts.map +1 -1
  12. package/dist/generators/blog.js +88 -69
  13. package/dist/generators/email.d.ts +13 -17
  14. package/dist/generators/email.d.ts.map +1 -1
  15. package/dist/generators/email.js +103 -91
  16. package/dist/generators/index.d.ts +5 -5
  17. package/dist/generators/index.d.ts.map +1 -0
  18. package/dist/generators/index.js +367 -5
  19. package/dist/generators/landing-page.d.ts +21 -25
  20. package/dist/generators/landing-page.d.ts.map +1 -1
  21. package/dist/generators/landing-page.js +93 -77
  22. package/dist/generators/social.d.ts +9 -13
  23. package/dist/generators/social.d.ts.map +1 -1
  24. package/dist/generators/social.js +77 -73
  25. package/dist/index.d.ts +4 -7
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +407 -6
  28. package/dist/node/generators/blog.js +88 -0
  29. package/dist/node/generators/email.js +111 -0
  30. package/dist/node/generators/index.js +367 -0
  31. package/dist/node/generators/landing-page.js +93 -0
  32. package/dist/node/generators/social.js +78 -0
  33. package/dist/node/index.js +407 -0
  34. package/dist/node/seo/index.js +42 -0
  35. package/dist/node/seo/optimizer.js +42 -0
  36. package/dist/node/types.js +0 -0
  37. package/dist/seo/index.d.ts +2 -2
  38. package/dist/seo/index.d.ts.map +1 -0
  39. package/dist/seo/index.js +43 -3
  40. package/dist/seo/optimizer.d.ts +6 -10
  41. package/dist/seo/optimizer.d.ts.map +1 -1
  42. package/dist/seo/optimizer.js +42 -48
  43. package/dist/types.d.ts +58 -62
  44. package/dist/types.d.ts.map +1 -1
  45. package/dist/types.js +1 -0
  46. package/package.json +100 -31
  47. package/dist/generators/blog.js.map +0 -1
  48. package/dist/generators/email.js.map +0 -1
  49. package/dist/generators/landing-page.js.map +0 -1
  50. package/dist/generators/social.js.map +0 -1
  51. package/dist/seo/optimizer.js.map +0 -1
@@ -1,70 +1,89 @@
1
- //#region src/generators/blog.ts
2
- var BlogGenerator = class {
3
- llm;
4
- model;
5
- temperature;
6
- constructor(options) {
7
- this.llm = options?.llm;
8
- this.model = options?.model;
9
- this.temperature = options?.temperature ?? .4;
10
- }
11
- async generate(brief) {
12
- if (this.llm) return this.generateWithLlm(brief);
13
- return this.generateDeterministic(brief);
14
- }
15
- async generateWithLlm(brief) {
16
- if (!this.llm) return this.generateDeterministic(brief);
17
- const jsonPart = (await this.llm.chat([{
18
- role: "system",
19
- content: [{
20
- type: "text",
21
- text: "You are a product marketing writer. Produce JSON with title, subtitle, intro, sections[].heading/body/bullets, outro."
22
- }]
23
- }, {
24
- role: "user",
25
- content: [{
26
- type: "text",
27
- text: JSON.stringify({ brief })
28
- }]
29
- }], {
30
- responseFormat: "json",
31
- model: this.model,
32
- temperature: this.temperature
33
- })).message.content.find((part) => "text" in part);
34
- if (jsonPart && "text" in jsonPart) return JSON.parse(jsonPart.text);
35
- return this.generateDeterministic(brief);
36
- }
37
- generateDeterministic(brief) {
38
- const intro = `Operators like ${brief.audience.role} teams face ${brief.problems.slice(0, 2).join(" and ")}. ${brief.title} changes that by ${brief.summary}.`;
39
- const sections = [
40
- {
41
- heading: "Why now",
42
- body: this.renderWhyNow(brief)
43
- },
44
- {
45
- heading: "What you get",
46
- body: "A focused stack built for policy-safe automation.",
47
- bullets: brief.solutions
48
- },
49
- {
50
- heading: "Proof it works",
51
- body: "Teams using the blueprint report measurable wins.",
52
- bullets: brief.metrics ?? ["Launch workflows in minutes", "Cut review time by 60%"]
53
- }
54
- ];
55
- return {
56
- title: brief.title,
57
- subtitle: brief.summary,
58
- intro,
59
- sections,
60
- outro: brief.callToAction ?? "Ready to see it live? Spin up a sandbox in under 5 minutes."
61
- };
62
- }
63
- renderWhyNow(brief) {
64
- return `${`${brief.audience.role}${brief.audience.industry ? ` in ${brief.audience.industry}` : ""}`} teams are stuck with ${brief.problems.slice(0, 2).join("; ")}. ${brief.title} delivers guardrails without slowing shipping.`;
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 "../types.js";
2
-
3
- //#region src/generators/email.d.ts
4
- declare class EmailCampaignGenerator {
5
- private readonly llm?;
6
- private readonly model?;
7
- private readonly temperature;
8
- constructor(options?: GeneratorOptions);
9
- generate(input: EmailCampaignBrief): Promise<EmailDraft>;
10
- private generateWithLlm;
11
- private generateFallback;
12
- private subjects;
13
- private defaultPreview;
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","names":[],"sources":["../../src/generators/email.ts"],"mappings":";;;cAOa,sBAAA;EAAA,iBACM,GAAA;EAAA,iBACA,KAAA;EAAA,iBACA,WAAA;cAEL,OAAA,GAAU,gBAAA;EAMhB,QAAA,CAAS,KAAA,EAAO,kBAAA,GAAqB,OAAA,CAAQ,UAAA;EAAA,QAQrC,eAAA;EAAA,QAuCN,gBAAA;EAAA,QAUA,QAAA;EAAA,QAeA,cAAA;EAAA,QAKA,UAAA;EAAA,QAmBA,WAAA;AAAA"}
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"}
@@ -1,100 +1,112 @@
1
- //#region src/generators/email.ts
2
- var EmailCampaignGenerator = class {
3
- llm;
4
- model;
5
- temperature;
6
- constructor(options) {
7
- this.llm = options?.llm;
8
- this.model = options?.model;
9
- this.temperature = options?.temperature ?? .6;
10
- }
11
- async generate(input) {
12
- if (this.llm) {
13
- const draft = await this.generateWithLlm(input);
14
- if (draft) return draft;
15
- }
16
- return this.generateFallback(input);
17
- }
18
- async generateWithLlm(input) {
19
- if (!this.llm) return null;
20
- const jsonPart = (await this.llm.chat([{
21
- role: "system",
22
- content: [{
23
- type: "text",
24
- text: "Draft product marketing email as JSON {subject, previewText, body, cta}."
25
- }]
26
- }, {
27
- role: "user",
28
- content: [{
29
- type: "text",
30
- text: JSON.stringify(input)
31
- }]
32
- }], {
33
- responseFormat: "json",
34
- model: this.model,
35
- temperature: this.temperature
36
- })).message.content.find((chunk) => "text" in chunk);
37
- if (!jsonPart || !("text" in jsonPart)) return null;
38
- const parsed = JSON.parse(jsonPart.text);
39
- if (!parsed.subject || !parsed.body || !parsed.cta) return null;
40
- return {
41
- subject: parsed.subject,
42
- previewText: parsed.previewText ?? this.defaultPreview(input),
43
- body: parsed.body,
44
- cta: parsed.cta,
45
- variant: input.variant
46
- };
47
- }
48
- generateFallback(input) {
49
- const { brief, variant } = input;
50
- return {
51
- subject: this.subjects(brief.title, variant)[0] ?? `${brief.title} update`,
52
- previewText: this.defaultPreview(input),
53
- body: this.renderBody(input),
54
- cta: brief.callToAction ?? "Explore the sandbox",
55
- variant
56
- };
57
- }
58
- subjects(title, variant) {
59
- switch (variant) {
60
- case "announcement": return [
61
- `Launch: ${title}`,
62
- `${title} is live`,
63
- `New: ${title}`
64
- ];
65
- case "onboarding": return [`Get started with ${title}`, `Your ${title} guide`];
66
- default: return [`How ${title} speeds ops`, `Proof ${title} works`];
67
- }
68
- }
69
- defaultPreview(input) {
70
- return `See how teams ${input.brief.metrics?.[0] ?? "ship faster without policy gaps"}.`;
71
- }
72
- renderBody(input) {
73
- const { brief, variant } = input;
74
- const greeting = "Hi there,";
75
- const hook = this.variantHook(variant, brief);
76
- const proof = brief.metrics?.map((metric) => `• ${metric}`).join("\n") ?? "";
77
- return `${greeting}
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) => `• ${solution}`).join("\n")}
90
+ ${brief.solutions.map((solution) => `\u2022 ${solution}`).join(`
91
+ `)}
83
92
 
84
93
  ${proof}
85
94
 
86
- ${brief.callToAction ?? "Spin up a sandbox"} ${(input.cadenceDay ?? 0) + 1}
95
+ ${brief.callToAction ?? "Spin up a sandbox"} \u2192 ${(input.cadenceDay ?? 0) + 1}
87
96
  `;
88
- }
89
- variantHook(variant, brief) {
90
- switch (variant) {
91
- case "announcement": return `${brief.title} is live. ${brief.summary}`;
92
- case "onboarding": return `Here is your next step to unlock ${brief.title}.`;
93
- default: return `Operators like ${brief.audience.role} keep asking how to automate policy checks. Here is what works.`;
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
- import { BlogGenerator } from "./blog.js";
2
- import { EmailCampaignGenerator } from "./email.js";
3
- import { LandingPageCopy, LandingPageGenerator } from "./landing-page.js";
4
- import { SocialPostGenerator } from "./social.js";
5
- export { BlogGenerator, EmailCampaignGenerator, LandingPageCopy, LandingPageGenerator, SocialPostGenerator };
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"}