@contractspec/example.content-generation 0.0.0-canary-20260113162409
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/.turbo/turbo-build$colon$bundle.log +25 -0
- package/.turbo/turbo-build.log +26 -0
- package/CHANGELOG.md +350 -0
- package/LICENSE +21 -0
- package/README.md +14 -0
- package/dist/docs/content-generation.docblock.d.ts +1 -0
- package/dist/docs/content-generation.docblock.js +29 -0
- package/dist/docs/content-generation.docblock.js.map +1 -0
- package/dist/docs/index.d.ts +1 -0
- package/dist/docs/index.js +1 -0
- package/dist/example.d.ts +7 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +46 -0
- package/dist/example.js.map +1 -0
- package/dist/generate.d.ts +5 -0
- package/dist/generate.d.ts.map +1 -0
- package/dist/generate.js +48 -0
- package/dist/generate.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/package.json +58 -0
- package/src/docs/content-generation.docblock.ts +28 -0
- package/src/docs/index.ts +1 -0
- package/src/example.ts +32 -0
- package/src/generate.ts +54 -0
- package/src/index.ts +3 -0
- package/tsconfig.json +11 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsdown.config.js +6 -0
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@contractspec/example.content-generation",
|
|
3
|
+
"version": "0.0.0-canary-20260113162409",
|
|
4
|
+
"description": "Content generation example using @contractspec/lib.content-gen.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.js",
|
|
9
|
+
"./docs": "./dist/docs/index.js",
|
|
10
|
+
"./docs/content-generation.docblock": "./dist/docs/content-generation.docblock.js",
|
|
11
|
+
"./example": "./dist/example.js",
|
|
12
|
+
"./generate": "./dist/generate.js",
|
|
13
|
+
"./*": "./*"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
|
|
17
|
+
"publish:pkg:canary": "bun publish:pkg --tag canary",
|
|
18
|
+
"build": "bun build:types && bun build:bundle",
|
|
19
|
+
"build:bundle": "tsdown",
|
|
20
|
+
"build:types": "tsc --noEmit",
|
|
21
|
+
"dev": "bun build:bundle --watch",
|
|
22
|
+
"clean": "rimraf dist .turbo",
|
|
23
|
+
"lint": "bun lint:fix",
|
|
24
|
+
"lint:fix": "eslint src --fix",
|
|
25
|
+
"lint:check": "eslint src",
|
|
26
|
+
"test": "bun test"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@contractspec/lib.contracts": "0.0.0-canary-20260113162409",
|
|
30
|
+
"@contractspec/lib.content-gen": "0.0.0-canary-20260113162409",
|
|
31
|
+
"@contractspec/lib.logger": "0.0.0-canary-20260113162409"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@contractspec/tool.tsdown": "0.0.0-canary-20260113162409",
|
|
35
|
+
"@contractspec/tool.typescript": "0.0.0-canary-20260113162409",
|
|
36
|
+
"tsdown": "^0.19.0",
|
|
37
|
+
"typescript": "^5.9.3"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public",
|
|
41
|
+
"exports": {
|
|
42
|
+
".": "./dist/index.js",
|
|
43
|
+
"./docs": "./dist/docs/index.js",
|
|
44
|
+
"./docs/content-generation.docblock": "./dist/docs/content-generation.docblock.js",
|
|
45
|
+
"./example": "./dist/example.js",
|
|
46
|
+
"./generate": "./dist/generate.js",
|
|
47
|
+
"./*": "./*"
|
|
48
|
+
},
|
|
49
|
+
"registry": "https://registry.npmjs.org/"
|
|
50
|
+
},
|
|
51
|
+
"license": "MIT",
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "https://github.com/lssm-tech/contractspec.git",
|
|
55
|
+
"directory": "packages/examples/content-generation"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://contractspec.io"
|
|
58
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { DocBlock } from '@contractspec/lib.contracts/docs';
|
|
2
|
+
import { registerDocBlocks } from '@contractspec/lib.contracts/docs';
|
|
3
|
+
|
|
4
|
+
const blocks: DocBlock[] = [
|
|
5
|
+
{
|
|
6
|
+
id: 'docs.examples.content-generation',
|
|
7
|
+
title: 'Content Generation (example)',
|
|
8
|
+
summary:
|
|
9
|
+
'Generate a consistent set of marketing assets from a typed ContentBrief (blog, landing hero, email, social, SEO).',
|
|
10
|
+
kind: 'reference',
|
|
11
|
+
visibility: 'public',
|
|
12
|
+
route: '/docs/examples/content-generation',
|
|
13
|
+
tags: ['content', 'marketing', 'example'],
|
|
14
|
+
body: `## What this example shows\n- A spec-first-ish interface for content brief inputs (typed, validated).\n- Deterministic orchestration of generators (same input → same structure).\n\n## Outputs\n- Blog intro\n- Landing hero\n- Email subject/body\n- Social post bodies\n- SEO metadata`,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: 'docs.examples.content-generation.usage',
|
|
18
|
+
title: 'Content Generation — Usage',
|
|
19
|
+
summary: 'How to run the example and extend the brief.',
|
|
20
|
+
kind: 'usage',
|
|
21
|
+
visibility: 'public',
|
|
22
|
+
route: '/docs/examples/content-generation/usage',
|
|
23
|
+
tags: ['content', 'usage'],
|
|
24
|
+
body: `## Usage\n- Call \`runContentGenerationExample()\`.\n- Modify the \`ContentBrief\` fields to drive different outputs.\n\n## Guardrails\n- Avoid PII in briefs.\n- Keep output logging structured; no raw \`console.log\` in library code.`,
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
registerDocBlocks(blocks);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './content-generation.docblock';
|
package/src/example.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineExample } from '@contractspec/lib.contracts';
|
|
2
|
+
|
|
3
|
+
const example = defineExample({
|
|
4
|
+
meta: {
|
|
5
|
+
key: 'content-generation',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
title: 'Content Generation',
|
|
8
|
+
description:
|
|
9
|
+
'Generate blog/landing/email/social/SEO assets from a typed ContentBrief using @contractspec/lib.content-gen.',
|
|
10
|
+
kind: 'script',
|
|
11
|
+
visibility: 'public',
|
|
12
|
+
stability: 'experimental',
|
|
13
|
+
owners: ['@platform.core'],
|
|
14
|
+
tags: ['content', 'marketing', 'generation', 'ai'],
|
|
15
|
+
},
|
|
16
|
+
docs: {
|
|
17
|
+
rootDocId: 'docs.examples.content-generation',
|
|
18
|
+
usageDocId: 'docs.examples.content-generation.usage',
|
|
19
|
+
},
|
|
20
|
+
entrypoints: {
|
|
21
|
+
packageName: '@contractspec/example.content-generation',
|
|
22
|
+
docs: './docs',
|
|
23
|
+
},
|
|
24
|
+
surfaces: {
|
|
25
|
+
templates: true,
|
|
26
|
+
sandbox: { enabled: true, modes: ['markdown'] },
|
|
27
|
+
studio: { enabled: true, installable: true },
|
|
28
|
+
mcp: { enabled: true },
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export default example;
|
package/src/generate.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BlogGenerator,
|
|
3
|
+
EmailCampaignGenerator,
|
|
4
|
+
LandingPageGenerator,
|
|
5
|
+
SocialPostGenerator,
|
|
6
|
+
} from '@contractspec/lib.content-gen/generators';
|
|
7
|
+
import { SeoOptimizer } from '@contractspec/lib.content-gen/seo';
|
|
8
|
+
import type { ContentBrief } from '@contractspec/lib.content-gen';
|
|
9
|
+
import { Logger, LogLevel } from '@contractspec/lib.logger';
|
|
10
|
+
import type { LoggerConfig } from '@contractspec/lib.logger/types';
|
|
11
|
+
|
|
12
|
+
const logger = new Logger({
|
|
13
|
+
level: process.env.NODE_ENV === 'production' ? LogLevel.INFO : LogLevel.DEBUG,
|
|
14
|
+
environment:
|
|
15
|
+
(process.env.NODE_ENV as LoggerConfig['environment']) || 'development',
|
|
16
|
+
enableColors: process.env.NODE_ENV !== 'production',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export async function runContentGenerationExample(): Promise<void> {
|
|
20
|
+
const brief: ContentBrief = {
|
|
21
|
+
title: 'AI-Native Operations Copilot',
|
|
22
|
+
summary:
|
|
23
|
+
'Automates support resolutions, growth playbooks, and DevOps rituals.',
|
|
24
|
+
problems: [
|
|
25
|
+
'Support queues pile up after hours',
|
|
26
|
+
'Growth teams lack fresh experiments',
|
|
27
|
+
],
|
|
28
|
+
solutions: [
|
|
29
|
+
'Stateful AI agents grounded in your knowledge spaces',
|
|
30
|
+
'CI-safe approval workflows for human review',
|
|
31
|
+
'Analytics + experimentation stack built into ContractSpec',
|
|
32
|
+
],
|
|
33
|
+
metrics: ['80% auto-resolution rate', '10+ experiments shipped weekly'],
|
|
34
|
+
audience: { role: 'COO', industry: 'Fintech', maturity: 'scaleup' },
|
|
35
|
+
callToAction: 'Book a 15‑minute pilot run',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const blog = await new BlogGenerator().generate(brief);
|
|
39
|
+
const landing = await new LandingPageGenerator().generate(brief);
|
|
40
|
+
const email = await new EmailCampaignGenerator().generate({
|
|
41
|
+
brief,
|
|
42
|
+
variant: 'announcement',
|
|
43
|
+
});
|
|
44
|
+
const social = await new SocialPostGenerator().generate(brief);
|
|
45
|
+
const seo = new SeoOptimizer().optimize(brief);
|
|
46
|
+
|
|
47
|
+
logger.info('Generated content assets', {
|
|
48
|
+
blogIntro: blog.intro,
|
|
49
|
+
landingHero: landing.hero,
|
|
50
|
+
emailSubject: email.subject,
|
|
51
|
+
socialPosts: social.map((post) => post.body),
|
|
52
|
+
seo,
|
|
53
|
+
});
|
|
54
|
+
}
|
package/src/index.ts
ADDED