@nebutra/brand-genesis 0.2.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/.nebutra/debug/brand-genesis.jsonl +6 -0
- package/.nebutra/debug/content-store.jsonl +6 -0
- package/.nebutra/debug/event-log.jsonl +1 -0
- package/.turbo/turbo-build.log +22 -0
- package/.turbo/turbo-test.log +17 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/CHANGELOG.md +7 -0
- package/LICENSE +676 -0
- package/README.md +31 -0
- package/dist/chunk-SB4N3ZZW.js +397 -0
- package/dist/chunk-SB4N3ZZW.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +70 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/examples/brand-context-only.ts +9 -0
- package/examples/doctor.ts +11 -0
- package/examples/quickstart.ts +27 -0
- package/package.json +70 -0
- package/plays/brand_film_60s/SKILL.md +84 -0
- package/plays/brand_film_60s/fixtures/input_1.json +5 -0
- package/plays/brand_film_60s/fixtures/input_2.json +5 -0
- package/plays/brand_film_60s/fixtures/input_3.json +5 -0
- package/plays/brand_film_60s/templates/BRAND.md.tmpl +29 -0
- package/plays/brand_film_60s/templates/palette.json.tmpl +4 -0
- package/src/cli.ts +64 -0
- package/src/index.test.ts +123 -0
- package/src/index.ts +515 -0
- package/tsconfig.json +9 -0
- package/tsup.config.ts +11 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
import { mkdir } from "node:fs/promises";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { type MeshAsset, MeshPipeline } from "@nebutra/3d-pipeline";
|
|
4
|
+
import { type AudioAsset, AudioPipeline } from "@nebutra/audio-pipeline";
|
|
5
|
+
import { appendCapabilityDebug, readCapabilityDebug } from "@nebutra/capability-kit/debug";
|
|
6
|
+
import { ContentStore, serializeContentFrontmatter } from "@nebutra/content-store";
|
|
7
|
+
import { CapabilityError } from "@nebutra/errors";
|
|
8
|
+
import { EventLog } from "@nebutra/event-log";
|
|
9
|
+
import {
|
|
10
|
+
assetId,
|
|
11
|
+
type BrandColor,
|
|
12
|
+
type BrandContext,
|
|
13
|
+
type VisualStyle,
|
|
14
|
+
} from "@nebutra/generation-context";
|
|
15
|
+
import { type ImageAsset, ImagePipeline } from "@nebutra/image-pipeline";
|
|
16
|
+
import { type Storyboard, type VideoAsset, VideoPipeline } from "@nebutra/video-pipeline";
|
|
17
|
+
import { type VoiceAsset, VoiceRealtime } from "@nebutra/voice-realtime";
|
|
18
|
+
|
|
19
|
+
export type VisualDirectionHint =
|
|
20
|
+
| "cyberpunk"
|
|
21
|
+
| "minimal"
|
|
22
|
+
| "organic"
|
|
23
|
+
| "playful"
|
|
24
|
+
| "corporate"
|
|
25
|
+
| "retro"
|
|
26
|
+
| "futurist";
|
|
27
|
+
|
|
28
|
+
export interface BrandFilmInput {
|
|
29
|
+
readonly tenantId?: string;
|
|
30
|
+
readonly idea: string;
|
|
31
|
+
readonly founderVoiceId?: string;
|
|
32
|
+
readonly visualDirectionHint?: VisualDirectionHint;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface BrandIdentityDraft {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly oneLiner: string;
|
|
38
|
+
readonly tagline: string;
|
|
39
|
+
readonly targetAudience: string;
|
|
40
|
+
readonly toneKeywords: readonly string[];
|
|
41
|
+
readonly differentiation: string;
|
|
42
|
+
readonly visualStyle: VisualStyle;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface BrandPackage {
|
|
46
|
+
readonly tenantId: string;
|
|
47
|
+
readonly play: "brand_film_60s";
|
|
48
|
+
readonly brand: BrandContext;
|
|
49
|
+
readonly draft: BrandIdentityDraft;
|
|
50
|
+
readonly brandMdPath: string;
|
|
51
|
+
readonly palettePath: string;
|
|
52
|
+
readonly landingPath: string;
|
|
53
|
+
readonly logo: ImageAsset;
|
|
54
|
+
readonly hero: ImageAsset;
|
|
55
|
+
readonly icon: ImageAsset;
|
|
56
|
+
readonly mesh: MeshAsset;
|
|
57
|
+
readonly storyboard: Storyboard;
|
|
58
|
+
readonly film: VideoAsset;
|
|
59
|
+
readonly bgm: AudioAsset;
|
|
60
|
+
readonly narration: VoiceAsset;
|
|
61
|
+
readonly eventId: string;
|
|
62
|
+
readonly checkpoints: readonly string[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface BrandGenesisDoctorReport {
|
|
66
|
+
readonly capability: "brand-genesis";
|
|
67
|
+
readonly ok: boolean;
|
|
68
|
+
readonly checkedAt: string;
|
|
69
|
+
readonly play: {
|
|
70
|
+
readonly ok: boolean;
|
|
71
|
+
readonly name: "brand_film_60s";
|
|
72
|
+
readonly requiredSkills: readonly string[];
|
|
73
|
+
};
|
|
74
|
+
readonly media: {
|
|
75
|
+
readonly image: readonly unknown[];
|
|
76
|
+
readonly video: readonly unknown[];
|
|
77
|
+
readonly audio: readonly unknown[];
|
|
78
|
+
readonly voice: readonly unknown[];
|
|
79
|
+
readonly mesh: readonly unknown[];
|
|
80
|
+
};
|
|
81
|
+
readonly suggestion?: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface BrandGenesisOptions {
|
|
85
|
+
readonly tenantId?: string;
|
|
86
|
+
readonly root?: string;
|
|
87
|
+
readonly debugRoot?: string;
|
|
88
|
+
readonly contentStore?: ContentStore;
|
|
89
|
+
readonly eventLog?: EventLog;
|
|
90
|
+
readonly imagePipeline?: ImagePipeline;
|
|
91
|
+
readonly videoPipeline?: VideoPipeline;
|
|
92
|
+
readonly audioPipeline?: AudioPipeline;
|
|
93
|
+
readonly voiceRealtime?: VoiceRealtime;
|
|
94
|
+
readonly meshPipeline?: MeshPipeline;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const PLAY_NAME = "brand_film_60s" as const;
|
|
98
|
+
const CHECKPOINTS = [
|
|
99
|
+
"brand_distillation",
|
|
100
|
+
"visual_direction",
|
|
101
|
+
"assets_generated",
|
|
102
|
+
"video_rendered",
|
|
103
|
+
"final_compose",
|
|
104
|
+
] as const;
|
|
105
|
+
|
|
106
|
+
function requireTenant(explicit: string | undefined, fallback: string | undefined): string {
|
|
107
|
+
const tenantId = explicit ?? fallback;
|
|
108
|
+
if (!tenantId?.trim()) {
|
|
109
|
+
throw new CapabilityError("brand-genesis", "Brand Genesis requires tenant context", {
|
|
110
|
+
suggestion: "Pass tenantId on the input or construct BrandGenesis with tenantId.",
|
|
111
|
+
statusCode: 400,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return tenantId;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function normalizeBrandId(name: string): string {
|
|
118
|
+
return name
|
|
119
|
+
.toLowerCase()
|
|
120
|
+
.replace(/[^a-z0-9]+/g, "_")
|
|
121
|
+
.replace(/^_+|_+$/g, "")
|
|
122
|
+
.slice(0, 32);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function pickName(idea: string): string {
|
|
126
|
+
const called = idea.match(/\bcalled\s+([A-Z][a-zA-Z0-9]*(?:\s+[A-Z][a-zA-Z0-9]*)?)/);
|
|
127
|
+
if (called?.[1]) return called[1].trim();
|
|
128
|
+
const capitalized = [...idea.matchAll(/\b[A-Z][a-zA-Z0-9]{2,}\b/g)]
|
|
129
|
+
.map((match) => match[0])
|
|
130
|
+
.filter((value) => !["AI", "SaaS", "API"].includes(value));
|
|
131
|
+
return capitalized.at(-1) ?? "Venture";
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function paletteFor(hint: VisualDirectionHint | undefined): readonly BrandColor[] {
|
|
135
|
+
switch (hint) {
|
|
136
|
+
case "cyberpunk":
|
|
137
|
+
case "futurist":
|
|
138
|
+
return [
|
|
139
|
+
{ name: "electric cyan", hex: "#00D4FF", role: "primary" },
|
|
140
|
+
{ name: "carbon black", hex: "#111318", role: "background" },
|
|
141
|
+
{ name: "signal amber", hex: "#F3C14B", role: "accent" },
|
|
142
|
+
];
|
|
143
|
+
case "organic":
|
|
144
|
+
return [
|
|
145
|
+
{ name: "moss", hex: "#3D7A57", role: "primary" },
|
|
146
|
+
{ name: "paper", hex: "#F7F4EA", role: "background" },
|
|
147
|
+
{ name: "clay", hex: "#C86B4A", role: "accent" },
|
|
148
|
+
];
|
|
149
|
+
case "playful":
|
|
150
|
+
return [
|
|
151
|
+
{ name: "coral", hex: "#FF6B6B", role: "primary" },
|
|
152
|
+
{ name: "ink", hex: "#202124", role: "neutral" },
|
|
153
|
+
{ name: "mint", hex: "#7CE2C6", role: "accent" },
|
|
154
|
+
];
|
|
155
|
+
case "corporate":
|
|
156
|
+
return [
|
|
157
|
+
{ name: "trust blue", hex: "#2454D6", role: "primary" },
|
|
158
|
+
{ name: "slate", hex: "#202A36", role: "neutral" },
|
|
159
|
+
{ name: "clear sky", hex: "#E8F0FF", role: "background" },
|
|
160
|
+
];
|
|
161
|
+
case "retro":
|
|
162
|
+
return [
|
|
163
|
+
{ name: "oxide", hex: "#B95F3B", role: "primary" },
|
|
164
|
+
{ name: "night ink", hex: "#18202A", role: "neutral" },
|
|
165
|
+
{ name: "cream light", hex: "#F8E7C9", role: "background" },
|
|
166
|
+
];
|
|
167
|
+
default:
|
|
168
|
+
return [
|
|
169
|
+
{ name: "graphite", hex: "#1F2933", role: "primary" },
|
|
170
|
+
{ name: "white", hex: "#FFFFFF", role: "background" },
|
|
171
|
+
{ name: "signal green", hex: "#00A693", role: "accent" },
|
|
172
|
+
];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function styleFor(hint: VisualDirectionHint | undefined): VisualStyle {
|
|
177
|
+
const name = hint ?? "minimal";
|
|
178
|
+
const keywordsByHint: Record<VisualDirectionHint, readonly string[]> = {
|
|
179
|
+
cyberpunk: ["electric", "terminal-native", "high-contrast"],
|
|
180
|
+
minimal: ["calm", "precise", "spacious"],
|
|
181
|
+
organic: ["warm", "natural", "human"],
|
|
182
|
+
playful: ["bright", "friendly", "kinetic"],
|
|
183
|
+
corporate: ["credible", "structured", "clear"],
|
|
184
|
+
retro: ["nostalgic", "tactile", "characterful"],
|
|
185
|
+
futurist: ["clean", "technical", "forward"],
|
|
186
|
+
};
|
|
187
|
+
return {
|
|
188
|
+
name,
|
|
189
|
+
keywords: keywordsByHint[name],
|
|
190
|
+
avoid: ["generic stock", "dark horror", "visual clutter"],
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export function distillBrandIdea(input: BrandFilmInput): BrandIdentityDraft {
|
|
195
|
+
const idea = input.idea.trim();
|
|
196
|
+
if (idea.length === 0) {
|
|
197
|
+
throw new CapabilityError("brand-genesis", "Brand idea is empty", {
|
|
198
|
+
suggestion: "Pass a one-sentence company idea before running Brand Genesis.",
|
|
199
|
+
statusCode: 400,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
const name = pickName(idea);
|
|
203
|
+
const devAudience = /\bdev|debug|code|developer|engineering/i.test(idea);
|
|
204
|
+
const audience = devAudience
|
|
205
|
+
? "Independent developers and small engineering teams shipping software quickly"
|
|
206
|
+
: "Early-stage founders validating a focused product wedge";
|
|
207
|
+
const toneKeywords = devAudience
|
|
208
|
+
? ["technical", "direct", "warm"]
|
|
209
|
+
: ["clear", "confident", "useful"];
|
|
210
|
+
return {
|
|
211
|
+
name,
|
|
212
|
+
oneLiner: idea,
|
|
213
|
+
tagline: devAudience ? "Debug like it is a conversation" : `${name} turns intent into launch`,
|
|
214
|
+
targetAudience: audience,
|
|
215
|
+
toneKeywords,
|
|
216
|
+
differentiation: devAudience
|
|
217
|
+
? "Understands the full production context instead of treating each error as an isolated message"
|
|
218
|
+
: "Combines brand, execution, and company memory in one repeatable workflow",
|
|
219
|
+
visualStyle: styleFor(input.visualDirectionHint),
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export function brandContextFromDraft(
|
|
224
|
+
draft: BrandIdentityDraft,
|
|
225
|
+
tenantId: string,
|
|
226
|
+
sourcePath = "company/BRAND.md",
|
|
227
|
+
palette = paletteFor(draft.visualStyle.name as VisualDirectionHint),
|
|
228
|
+
): BrandContext {
|
|
229
|
+
return {
|
|
230
|
+
tenantId,
|
|
231
|
+
brandId: normalizeBrandId(draft.name),
|
|
232
|
+
name: draft.name,
|
|
233
|
+
palette,
|
|
234
|
+
typography: {
|
|
235
|
+
heading: draft.visualStyle.name === "cyberpunk" ? "Geist Mono" : "Geist Sans",
|
|
236
|
+
body: "Geist Sans",
|
|
237
|
+
accent: "Geist Mono",
|
|
238
|
+
},
|
|
239
|
+
visualStyle: draft.visualStyle,
|
|
240
|
+
referenceImages: [],
|
|
241
|
+
forbidden: draft.visualStyle.avoid ?? [],
|
|
242
|
+
toneKeywords: draft.toneKeywords,
|
|
243
|
+
sourcePath,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export function renderBrandMarkdown(draft: BrandIdentityDraft, brand: BrandContext): string {
|
|
248
|
+
return serializeContentFrontmatter(
|
|
249
|
+
{
|
|
250
|
+
type: "brand_profile",
|
|
251
|
+
brand_id: brand.brandId,
|
|
252
|
+
name: brand.name,
|
|
253
|
+
},
|
|
254
|
+
[
|
|
255
|
+
`# ${brand.name}`,
|
|
256
|
+
"",
|
|
257
|
+
draft.oneLiner,
|
|
258
|
+
"",
|
|
259
|
+
"## Tagline",
|
|
260
|
+
"",
|
|
261
|
+
draft.tagline,
|
|
262
|
+
"",
|
|
263
|
+
"## Audience",
|
|
264
|
+
"",
|
|
265
|
+
draft.targetAudience,
|
|
266
|
+
"",
|
|
267
|
+
"## Tone",
|
|
268
|
+
"",
|
|
269
|
+
brand.toneKeywords.join(", "),
|
|
270
|
+
"",
|
|
271
|
+
"## Visual Direction",
|
|
272
|
+
"",
|
|
273
|
+
`${brand.visualStyle.name}: ${brand.visualStyle.keywords.join(", ")}`,
|
|
274
|
+
"",
|
|
275
|
+
"## Differentiation",
|
|
276
|
+
"",
|
|
277
|
+
draft.differentiation,
|
|
278
|
+
"",
|
|
279
|
+
].join("\n"),
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function renderLandingManifest(draft: BrandIdentityDraft, brand: BrandContext): string {
|
|
284
|
+
return [
|
|
285
|
+
"<!doctype html>",
|
|
286
|
+
'<html lang="en">',
|
|
287
|
+
"<head>",
|
|
288
|
+
' <meta charset="utf-8" />',
|
|
289
|
+
` <title>${brand.name}</title>`,
|
|
290
|
+
"</head>",
|
|
291
|
+
"<body>",
|
|
292
|
+
` <main data-brand-id="${brand.brandId}">`,
|
|
293
|
+
` <h1>${brand.name}</h1>`,
|
|
294
|
+
` <p>${draft.tagline}</p>`,
|
|
295
|
+
` <p>${draft.oneLiner}</p>`,
|
|
296
|
+
" </main>",
|
|
297
|
+
"</body>",
|
|
298
|
+
"</html>",
|
|
299
|
+
"",
|
|
300
|
+
].join("\n");
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export class BrandGenesis {
|
|
304
|
+
readonly #tenantId: string | undefined;
|
|
305
|
+
readonly #root: string;
|
|
306
|
+
readonly #debugRoot: string;
|
|
307
|
+
readonly #contentStore: ContentStore;
|
|
308
|
+
readonly #eventLog: EventLog;
|
|
309
|
+
readonly #image: ImagePipeline;
|
|
310
|
+
readonly #video: VideoPipeline;
|
|
311
|
+
readonly #audio: AudioPipeline;
|
|
312
|
+
readonly #voice: VoiceRealtime;
|
|
313
|
+
readonly #mesh: MeshPipeline;
|
|
314
|
+
|
|
315
|
+
private constructor(
|
|
316
|
+
options: BrandGenesisOptions & { contentStore: ContentStore; eventLog: EventLog },
|
|
317
|
+
) {
|
|
318
|
+
this.#tenantId = options.tenantId;
|
|
319
|
+
this.#root = options.root ?? join(process.cwd(), ".nebutra", "brand-genesis");
|
|
320
|
+
this.#debugRoot = options.debugRoot ?? process.cwd();
|
|
321
|
+
this.#contentStore = options.contentStore;
|
|
322
|
+
this.#eventLog = options.eventLog;
|
|
323
|
+
this.#image = options.imagePipeline ?? new ImagePipeline({ root: this.#root });
|
|
324
|
+
this.#video = options.videoPipeline ?? new VideoPipeline({ root: this.#root });
|
|
325
|
+
this.#audio = options.audioPipeline ?? new AudioPipeline({ root: this.#root });
|
|
326
|
+
this.#voice = options.voiceRealtime ?? new VoiceRealtime({ root: this.#root });
|
|
327
|
+
this.#mesh = options.meshPipeline ?? new MeshPipeline({ root: this.#root });
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
static async open(
|
|
331
|
+
root = ".nebutra/brand-genesis",
|
|
332
|
+
options: Omit<BrandGenesisOptions, "root" | "contentStore" | "eventLog"> = {},
|
|
333
|
+
): Promise<BrandGenesis> {
|
|
334
|
+
const tenantId = options.tenantId ?? "local";
|
|
335
|
+
await mkdir(root, { recursive: true });
|
|
336
|
+
const contentStore = await ContentStore.open(join(root, "content"), { tenantId });
|
|
337
|
+
const eventLog = await EventLog.open(join(root, "event-log"), { tenantId });
|
|
338
|
+
return new BrandGenesis({ ...options, tenantId, root, contentStore, eventLog });
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
async run(input: BrandFilmInput): Promise<BrandPackage> {
|
|
342
|
+
const tenantId = requireTenant(input.tenantId, this.#tenantId);
|
|
343
|
+
const draft = distillBrandIdea(input);
|
|
344
|
+
const brand = brandContextFromDraft(draft, tenantId);
|
|
345
|
+
const brandMarkdown = renderBrandMarkdown(draft, brand);
|
|
346
|
+
await this.#contentStore.write(brand.sourcePath, brandMarkdown);
|
|
347
|
+
const palettePath = "company/assets/palette.json";
|
|
348
|
+
await this.#contentStore.write(
|
|
349
|
+
palettePath,
|
|
350
|
+
`${JSON.stringify({ brandId: brand.brandId, colors: brand.palette }, null, 2)}\n`,
|
|
351
|
+
);
|
|
352
|
+
await this.#debug({
|
|
353
|
+
type: "checkpoint",
|
|
354
|
+
step: CHECKPOINTS[0],
|
|
355
|
+
tenantId,
|
|
356
|
+
brandId: brand.brandId,
|
|
357
|
+
});
|
|
358
|
+
await this.#debug({
|
|
359
|
+
type: "checkpoint",
|
|
360
|
+
step: CHECKPOINTS[1],
|
|
361
|
+
tenantId,
|
|
362
|
+
brandId: brand.brandId,
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
const [logo, hero, icon] = await Promise.all([
|
|
366
|
+
this.#image.generate({ type: "logo", company: brand.name, oneLiner: draft.oneLiner }, brand),
|
|
367
|
+
this.#image.generate({ type: "hero", headline: draft.tagline }, brand),
|
|
368
|
+
this.#image.generate({ type: "icon", subject: brand.name }, brand),
|
|
369
|
+
]);
|
|
370
|
+
const mesh = await this.#mesh.fromImage(logo, brand);
|
|
371
|
+
await this.#debug({
|
|
372
|
+
type: "checkpoint",
|
|
373
|
+
step: CHECKPOINTS[2],
|
|
374
|
+
tenantId,
|
|
375
|
+
brandId: brand.brandId,
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
const storyboard = await this.#video.plan(
|
|
379
|
+
{ type: "brand-film", durationS: 60, theme: draft.tagline },
|
|
380
|
+
brand,
|
|
381
|
+
);
|
|
382
|
+
const rendered = await this.#video.render(storyboard, brand);
|
|
383
|
+
await this.#debug({
|
|
384
|
+
type: "checkpoint",
|
|
385
|
+
step: CHECKPOINTS[3],
|
|
386
|
+
tenantId,
|
|
387
|
+
brandId: brand.brandId,
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
const bgm = await this.#audio.generate(
|
|
391
|
+
{ type: "bgm", durationS: rendered.durationS, mood: brand.toneKeywords.join(" ") },
|
|
392
|
+
brand,
|
|
393
|
+
true,
|
|
394
|
+
);
|
|
395
|
+
const narration = await this.#voice.synthesizeNarration(
|
|
396
|
+
{
|
|
397
|
+
script: `${draft.tagline}. ${draft.oneLiner}. ${draft.differentiation}.`,
|
|
398
|
+
targetDurationS: Math.max(8, Math.min(20, rendered.durationS - 3)),
|
|
399
|
+
...(input.founderVoiceId !== undefined ? { voiceProfileId: input.founderVoiceId } : {}),
|
|
400
|
+
},
|
|
401
|
+
brand,
|
|
402
|
+
);
|
|
403
|
+
const film = await this.#video.compose({
|
|
404
|
+
videoTrack: [rendered],
|
|
405
|
+
audioTrack: [bgm],
|
|
406
|
+
voiceTrack: [narration],
|
|
407
|
+
captionTrack: [{ startS: 0, endS: narration.durationS, text: narration.transcript }],
|
|
408
|
+
});
|
|
409
|
+
const landingPath = "company/landing/index.html";
|
|
410
|
+
await this.#contentStore.write(landingPath, renderLandingManifest(draft, brand));
|
|
411
|
+
await this.#debug({
|
|
412
|
+
type: "checkpoint",
|
|
413
|
+
step: CHECKPOINTS[4],
|
|
414
|
+
tenantId,
|
|
415
|
+
brandId: brand.brandId,
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
const eventId = await this.#eventLog.commit({
|
|
419
|
+
traceId: assetId("brand_genesis", brand.brandId),
|
|
420
|
+
kind: "content_write",
|
|
421
|
+
affected: [
|
|
422
|
+
brand.sourcePath,
|
|
423
|
+
palettePath,
|
|
424
|
+
landingPath,
|
|
425
|
+
logo.path,
|
|
426
|
+
hero.path,
|
|
427
|
+
icon.path,
|
|
428
|
+
film.path,
|
|
429
|
+
],
|
|
430
|
+
parent: null,
|
|
431
|
+
snapshot: {
|
|
432
|
+
[brand.sourcePath]: brandMarkdown,
|
|
433
|
+
[palettePath]: JSON.stringify({ brandId: brand.brandId, colors: brand.palette }, null, 2),
|
|
434
|
+
[landingPath]: renderLandingManifest(draft, brand),
|
|
435
|
+
},
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
const result: BrandPackage = {
|
|
439
|
+
tenantId,
|
|
440
|
+
play: PLAY_NAME,
|
|
441
|
+
brand,
|
|
442
|
+
draft,
|
|
443
|
+
brandMdPath: brand.sourcePath,
|
|
444
|
+
palettePath,
|
|
445
|
+
landingPath,
|
|
446
|
+
logo,
|
|
447
|
+
hero,
|
|
448
|
+
icon,
|
|
449
|
+
mesh,
|
|
450
|
+
storyboard,
|
|
451
|
+
film,
|
|
452
|
+
bgm,
|
|
453
|
+
narration,
|
|
454
|
+
eventId,
|
|
455
|
+
checkpoints: CHECKPOINTS,
|
|
456
|
+
};
|
|
457
|
+
await this.#debug({ type: "run", tenantId, brandId: brand.brandId, eventId });
|
|
458
|
+
return result;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
async doctor(): Promise<BrandGenesisDoctorReport> {
|
|
462
|
+
const [image, video, audio, rawVoice, mesh] = await Promise.all([
|
|
463
|
+
this.#image.doctor(),
|
|
464
|
+
this.#video.doctor(),
|
|
465
|
+
this.#audio.doctor(),
|
|
466
|
+
this.#voice.doctor(),
|
|
467
|
+
this.#mesh.doctor(),
|
|
468
|
+
]);
|
|
469
|
+
const voice = [{ provider: "narration-local", ok: true }, ...rawVoice];
|
|
470
|
+
const localOk = [image, video, audio, voice, mesh].every((checks) =>
|
|
471
|
+
checks.some((check) => Boolean((check as { ok?: boolean }).ok)),
|
|
472
|
+
);
|
|
473
|
+
return {
|
|
474
|
+
capability: "brand-genesis",
|
|
475
|
+
ok: localOk,
|
|
476
|
+
checkedAt: new Date().toISOString(),
|
|
477
|
+
play: {
|
|
478
|
+
ok: true,
|
|
479
|
+
name: PLAY_NAME,
|
|
480
|
+
requiredSkills: [
|
|
481
|
+
"image_pipeline.generate",
|
|
482
|
+
"video_pipeline.plan",
|
|
483
|
+
"video_pipeline.render",
|
|
484
|
+
"video_pipeline.compose",
|
|
485
|
+
"audio_pipeline.generate",
|
|
486
|
+
"voice_realtime.synthesize_narration",
|
|
487
|
+
"mesh_pipeline.from_image",
|
|
488
|
+
"content_store.write",
|
|
489
|
+
],
|
|
490
|
+
},
|
|
491
|
+
media: { image, video, audio, voice, mesh },
|
|
492
|
+
...(!localOk
|
|
493
|
+
? {
|
|
494
|
+
suggestion:
|
|
495
|
+
"Run the individual media doctor commands and configure missing local or remote providers.",
|
|
496
|
+
}
|
|
497
|
+
: {}),
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
async close(): Promise<void> {
|
|
502
|
+
await this.#contentStore.close();
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
async #debug(entry: Record<string, unknown>): Promise<void> {
|
|
506
|
+
await mkdir(dirname(join(this.#debugRoot, ".nebutra", "debug", "brand-genesis.jsonl")), {
|
|
507
|
+
recursive: true,
|
|
508
|
+
});
|
|
509
|
+
await appendCapabilityDebug("brand-genesis", entry, { root: this.#debugRoot });
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
export async function readBrandGenesisDebug(root = process.cwd(), limit = 20): Promise<unknown[]> {
|
|
514
|
+
return readCapabilityDebug("brand-genesis", { root, limit });
|
|
515
|
+
}
|
package/tsconfig.json
ADDED
package/tsup.config.ts
ADDED