studio-lumiere-cli 0.1.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/.agents/skills/annotate-image/SKILL.md +99 -0
- package/.agents/skills/config-troubleshooting/SKILL.md +97 -0
- package/.agents/skills/generate-images/SKILL.md +667 -0
- package/.agents/skills/generate-video/SKILL.md +328 -0
- package/.agents/skills/image-grid/SKILL.md +96 -0
- package/.agents/skills/image-overlay/SKILL.md +66 -0
- package/.agents/skills/image-overlay/agents/openai.yaml +4 -0
- package/.agents/skills/image-overlay/scripts/overlay-image.js +218 -0
- package/.agents/skills/muse-management/SKILL.md +232 -0
- package/.agents/skills/refine-images/SKILL.md +192 -0
- package/.agents/skills/tired-girl/SKILL.md +131 -0
- package/.env.example +2 -0
- package/AGENTS.md +66 -0
- package/README.md +96 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +214 -0
- package/dist/cli.js.map +1 -0
- package/dist/clients/geminiClient.d.ts +37 -0
- package/dist/clients/geminiClient.js +129 -0
- package/dist/clients/geminiClient.js.map +1 -0
- package/dist/config/constants.d.ts +63 -0
- package/dist/config/constants.js +1005 -0
- package/dist/config/constants.js.map +1 -0
- package/dist/config/options.d.ts +1 -0
- package/dist/config/options.js +2 -0
- package/dist/config/options.js.map +1 -0
- package/dist/config/templates.d.ts +3 -0
- package/dist/config/templates.js +4 -0
- package/dist/config/templates.js.map +1 -0
- package/dist/config/tiredGirl.d.ts +3 -0
- package/dist/config/tiredGirl.js +9 -0
- package/dist/config/tiredGirl.js.map +1 -0
- package/dist/image/annotate.d.ts +2 -0
- package/dist/image/annotate.js +119 -0
- package/dist/image/annotate.js.map +1 -0
- package/dist/image/grid.d.ts +2 -0
- package/dist/image/grid.js +44 -0
- package/dist/image/grid.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/pipelines/createMuse.d.ts +3 -0
- package/dist/pipelines/createMuse.js +49 -0
- package/dist/pipelines/createMuse.js.map +1 -0
- package/dist/pipelines/generateImages.d.ts +2 -0
- package/dist/pipelines/generateImages.js +140 -0
- package/dist/pipelines/generateImages.js.map +1 -0
- package/dist/pipelines/generateTiredGirl.d.ts +2 -0
- package/dist/pipelines/generateTiredGirl.js +73 -0
- package/dist/pipelines/generateTiredGirl.js.map +1 -0
- package/dist/pipelines/generateVideo.d.ts +2 -0
- package/dist/pipelines/generateVideo.js +27 -0
- package/dist/pipelines/generateVideo.js.map +1 -0
- package/dist/pipelines/refineImage.d.ts +2 -0
- package/dist/pipelines/refineImage.js +28 -0
- package/dist/pipelines/refineImage.js.map +1 -0
- package/dist/pipelines/resolve.d.ts +11 -0
- package/dist/pipelines/resolve.js +74 -0
- package/dist/pipelines/resolve.js.map +1 -0
- package/dist/pipelines/upscaleImage.d.ts +2 -0
- package/dist/pipelines/upscaleImage.js +23 -0
- package/dist/pipelines/upscaleImage.js.map +1 -0
- package/dist/prompt/buildPrompt.d.ts +4 -0
- package/dist/prompt/buildPrompt.js +322 -0
- package/dist/prompt/buildPrompt.js.map +1 -0
- package/dist/prompt/tiredGirlPrompt.d.ts +3 -0
- package/dist/prompt/tiredGirlPrompt.js +33 -0
- package/dist/prompt/tiredGirlPrompt.js.map +1 -0
- package/dist/storage/files.d.ts +15 -0
- package/dist/storage/files.js +34 -0
- package/dist/storage/files.js.map +1 -0
- package/dist/storage/museStore.d.ts +5 -0
- package/dist/storage/museStore.js +26 -0
- package/dist/storage/museStore.js.map +1 -0
- package/dist/types.d.ts +169 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/examples/generate.d.ts +1 -0
- package/examples/generate.js +28 -0
- package/examples/generate.js.map +1 -0
- package/examples/generate.ts +30 -0
- package/examples/muse.d.ts +1 -0
- package/examples/muse.js +18 -0
- package/examples/muse.js.map +1 -0
- package/examples/muse.ts +20 -0
- package/examples/video.d.ts +1 -0
- package/examples/video.js +18 -0
- package/examples/video.js.map +1 -0
- package/examples/video.ts +20 -0
- package/logo-round.png +0 -0
- package/logo.jpeg +0 -0
- package/package.json +27 -0
- package/src/cli.ts +259 -0
- package/src/clients/geminiClient.ts +168 -0
- package/src/config/constants.ts +1105 -0
- package/src/config/options.ts +15 -0
- package/src/config/templates.ts +4 -0
- package/src/config/tiredGirl.ts +11 -0
- package/src/image/annotate.ts +139 -0
- package/src/image/grid.ts +58 -0
- package/src/index.ts +27 -0
- package/src/pipelines/createMuse.ts +76 -0
- package/src/pipelines/generateImages.ts +203 -0
- package/src/pipelines/generateTiredGirl.ts +86 -0
- package/src/pipelines/generateVideo.ts +36 -0
- package/src/pipelines/refineImage.ts +36 -0
- package/src/pipelines/resolve.ts +88 -0
- package/src/pipelines/upscaleImage.ts +30 -0
- package/src/prompt/buildPrompt.ts +380 -0
- package/src/prompt/tiredGirlPrompt.ts +35 -0
- package/src/storage/files.ts +41 -0
- package/src/storage/museStore.ts +31 -0
- package/src/types.ts +198 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { GeminiClient } from "../clients/geminiClient.js";
|
|
3
|
+
import { LumiereConfig, RefineRequest } from "../types.js";
|
|
4
|
+
import { readImageAsPart, resolveOutputDir, saveBase64Image, writeJson } from "../storage/files.js";
|
|
5
|
+
|
|
6
|
+
export const refineImage = async (config: LumiereConfig, request: RefineRequest): Promise<string> => {
|
|
7
|
+
const client = new GeminiClient(config);
|
|
8
|
+
const outputDir = resolveOutputDir(request.outputDir ?? config.outputDir, "refinements");
|
|
9
|
+
|
|
10
|
+
const sizeAdjustment = request.sizeAdjustment;
|
|
11
|
+
let prompt = `You are an expert high-end jewelry photo retoucher. Refine this image according to: "${request.instruction}". Preserve jewelry design and materials. Maintain photorealism.`;
|
|
12
|
+
|
|
13
|
+
if (sizeAdjustment !== undefined && sizeAdjustment !== 100) {
|
|
14
|
+
const direction = sizeAdjustment < 100 ? "smaller" : "larger";
|
|
15
|
+
prompt = `Adjust the size of all jewelry pieces to ${sizeAdjustment}% of current size (${direction}). Preserve all details, lighting, and composition. ${request.instruction}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const imagePart = await readImageAsPart(request.inputImage);
|
|
19
|
+
const images = await client.generateImage({
|
|
20
|
+
parts: [{ text: prompt }, imagePart],
|
|
21
|
+
imageSize: "2K"
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const outputPath = path.join(outputDir, "refined.png");
|
|
25
|
+
await saveBase64Image(images[0], outputPath);
|
|
26
|
+
|
|
27
|
+
await writeJson(path.join(outputDir, "refine.json"), {
|
|
28
|
+
inputImage: request.inputImage,
|
|
29
|
+
instruction: request.instruction,
|
|
30
|
+
sizeAdjustment,
|
|
31
|
+
outputPath
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return outputPath;
|
|
35
|
+
};
|
|
36
|
+
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Option, OccasionTheme, Resolution, Template } from "../types.js";
|
|
2
|
+
import { TEMPLATE_MAP } from "../config/templates.js";
|
|
3
|
+
import {
|
|
4
|
+
BACKGROUNDS,
|
|
5
|
+
BACKGROUND_TYPES,
|
|
6
|
+
ETHNICITIES,
|
|
7
|
+
HAIR_COLORS,
|
|
8
|
+
OCCASIONS,
|
|
9
|
+
RESOLUTIONS,
|
|
10
|
+
SKIN_TONES,
|
|
11
|
+
VIBES
|
|
12
|
+
} from "../config/options.js";
|
|
13
|
+
|
|
14
|
+
const optionMap = (options: Option[]): Map<string, Option> => {
|
|
15
|
+
return new Map(options.map((opt) => [opt.id, opt]));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const ETHNICITY_MAP = optionMap(ETHNICITIES);
|
|
19
|
+
const SKIN_TONE_MAP = optionMap(SKIN_TONES);
|
|
20
|
+
const HAIR_COLOR_MAP = optionMap(HAIR_COLORS);
|
|
21
|
+
const BACKGROUND_MAP = optionMap(BACKGROUNDS);
|
|
22
|
+
const BACKGROUND_TYPE_MAP = optionMap(BACKGROUND_TYPES);
|
|
23
|
+
const VIBE_MAP = optionMap(VIBES);
|
|
24
|
+
const OCCASION_MAP = new Map(OCCASIONS.map((o) => [o.id, o]));
|
|
25
|
+
const RESOLUTION_MAP = new Map(RESOLUTIONS.map((r) => [r.id, r]));
|
|
26
|
+
|
|
27
|
+
export const getTemplate = (id: string): Template => {
|
|
28
|
+
const template = TEMPLATE_MAP.get(id);
|
|
29
|
+
if (!template) {
|
|
30
|
+
throw new Error(`Unknown template: ${id}`);
|
|
31
|
+
}
|
|
32
|
+
return template;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const resolveTemplateOption = (template: Template, id?: string, which?: "primary" | "secondary" | "tertiary"): Option | undefined => {
|
|
36
|
+
if (!id) return undefined;
|
|
37
|
+
const options =
|
|
38
|
+
which === "secondary"
|
|
39
|
+
? template.secondaryCustomizationOptions
|
|
40
|
+
: which === "tertiary"
|
|
41
|
+
? template.tertiaryCustomizationOptions
|
|
42
|
+
: template.customizationOptions;
|
|
43
|
+
|
|
44
|
+
return options?.find((opt: Option) => opt.id === id) ?? { id, name: id, value: id };
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const resolveEthnicity = (id?: string): Option | undefined => {
|
|
48
|
+
if (!id) return undefined;
|
|
49
|
+
return ETHNICITY_MAP.get(id) ?? { id, name: id, value: id };
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const resolveSkinTone = (id?: string): Option | undefined => {
|
|
53
|
+
if (!id) return undefined;
|
|
54
|
+
return SKIN_TONE_MAP.get(id) ?? { id, name: id, value: id };
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const resolveHairColor = (id?: string): Option | undefined => {
|
|
58
|
+
if (!id) return undefined;
|
|
59
|
+
return HAIR_COLOR_MAP.get(id) ?? { id, name: id, value: id };
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const resolveBackground = (id?: string): Option | undefined => {
|
|
63
|
+
if (!id) return undefined;
|
|
64
|
+
return BACKGROUND_MAP.get(id) ?? { id, name: id, value: id };
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const resolveBackgroundType = (id?: string): Option | undefined => {
|
|
68
|
+
if (!id) return undefined;
|
|
69
|
+
return BACKGROUND_TYPE_MAP.get(id) ?? { id, name: id, value: id };
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const resolveVibe = (id?: string): Option | undefined => {
|
|
73
|
+
if (!id) return undefined;
|
|
74
|
+
return VIBE_MAP.get(id) ?? { id, name: id, value: id };
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const resolveOccasion = (id?: string): OccasionTheme | undefined => {
|
|
78
|
+
if (!id) return undefined;
|
|
79
|
+
return OCCASION_MAP.get(id);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const resolveResolution = (id?: string): Resolution => {
|
|
83
|
+
const fallback = RESOLUTION_MAP.get("portrait") ?? Array.from(RESOLUTION_MAP.values())[0];
|
|
84
|
+
if (!fallback) throw new Error("No resolutions configured.");
|
|
85
|
+
if (!id) return fallback;
|
|
86
|
+
return RESOLUTION_MAP.get(id) ?? fallback;
|
|
87
|
+
};
|
|
88
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { GeminiClient } from "../clients/geminiClient.js";
|
|
3
|
+
import { LumiereConfig, UpscaleRequest } from "../types.js";
|
|
4
|
+
import { readImageAsPart, resolveOutputDir, saveBase64Image, writeJson } from "../storage/files.js";
|
|
5
|
+
|
|
6
|
+
export const upscaleImage = async (config: LumiereConfig, request: UpscaleRequest): Promise<string> => {
|
|
7
|
+
const client = new GeminiClient(config);
|
|
8
|
+
const outputDir = resolveOutputDir(request.outputDir ?? config.outputDir, "upscales");
|
|
9
|
+
|
|
10
|
+
const scale = request.scale ?? 2;
|
|
11
|
+
const prompt = `Upscale this image to ${scale}x resolution. Preserve all details, composition, and color. Do not change jewelry design, lighting, or background.`;
|
|
12
|
+
|
|
13
|
+
const imagePart = await readImageAsPart(request.inputImage);
|
|
14
|
+
const images = await client.generateImage({
|
|
15
|
+
parts: [{ text: prompt }, imagePart],
|
|
16
|
+
imageSize: scale >= 4 ? "4K" : "2K"
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const outputPath = path.join(outputDir, "upscaled.png");
|
|
20
|
+
await saveBase64Image(images[0], outputPath);
|
|
21
|
+
|
|
22
|
+
await writeJson(path.join(outputDir, "upscale.json"), {
|
|
23
|
+
inputImage: request.inputImage,
|
|
24
|
+
scale,
|
|
25
|
+
outputPath
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return outputPath;
|
|
29
|
+
};
|
|
30
|
+
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { Template, Option } from "../types.js";
|
|
2
|
+
import { OccasionTheme, ETHNICITY_REGIONS, getRandomLuxuryInterior } from "../config/constants.js";
|
|
3
|
+
export const buildLLMPrompt = (
|
|
4
|
+
template: Template,
|
|
5
|
+
detail: Option | undefined,
|
|
6
|
+
secondaryDetail: Option | undefined,
|
|
7
|
+
tertiaryDetail: Option | undefined,
|
|
8
|
+
ethnicity: Option | undefined,
|
|
9
|
+
skinTone: Option | undefined,
|
|
10
|
+
hairColor: Option | undefined,
|
|
11
|
+
background: Option | undefined,
|
|
12
|
+
backgroundType: Option | undefined,
|
|
13
|
+
vibe: Option | undefined,
|
|
14
|
+
imageCount: number,
|
|
15
|
+
occasion: OccasionTheme | undefined,
|
|
16
|
+
isVariation: boolean = false,
|
|
17
|
+
styleHint?: string
|
|
18
|
+
) => {
|
|
19
|
+
const needsBothHands = template.id === 'hand_model' && imageCount >= 3;
|
|
20
|
+
const quantityConstraint = imageCount > 1
|
|
21
|
+
? `The model is wearing ALL the provided pieces together. Do NOT add any other jewelry.${needsBothHands ? ' IMPORTANT: Show BOTH hands with the pieces distributed naturally and elegantly across both hands — do NOT cram all pieces onto a single hand.' : ''}`
|
|
22
|
+
: 'The model is wearing ONLY the single piece of jewelry shown in the reference. Do NOT add matching earrings, necklaces, or other rings.';
|
|
23
|
+
|
|
24
|
+
// Dynamic Base Concept
|
|
25
|
+
let ethnicityLabel = (ethnicity && ethnicity.id !== 'none') ? ethnicity.name : "professional female";
|
|
26
|
+
|
|
27
|
+
// Diversity Injection: Pick a specific region if available
|
|
28
|
+
if (ethnicity && ethnicity.id && ETHNICITY_REGIONS[ethnicity.id]) {
|
|
29
|
+
const regions = ETHNICITY_REGIONS[ethnicity.id];
|
|
30
|
+
const randomRegion = regions[Math.floor(Math.random() * regions.length)];
|
|
31
|
+
ethnicityLabel = `${randomRegion} (${ethnicity.name})`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let basePrompt = template.basePrompt;
|
|
35
|
+
basePrompt = basePrompt.replace(/\[ETHNICITY\]/g, ethnicityLabel);
|
|
36
|
+
|
|
37
|
+
const hairColorLabel = (hairColor && hairColor.id !== 'none') ? hairColor.name.toLowerCase() : "natural colored";
|
|
38
|
+
basePrompt = basePrompt.replace(/\[HAIR_COLOR\]/g, hairColorLabel);
|
|
39
|
+
|
|
40
|
+
let instruction = `Write a highly detailed, structured photorealistic prompt for the specific jewelry shown in the attached images.
|
|
41
|
+
|
|
42
|
+
══════════════════════════════════
|
|
43
|
+
📸 PHOTOGRAPHY SPECIFICATION
|
|
44
|
+
══════════════════════════════════
|
|
45
|
+
Base Concept: ${basePrompt}
|
|
46
|
+
Camera: Hasselblad X2D 100C, 120mm Macro lens, f/2.8
|
|
47
|
+
Target: Authentic, high-end editorial photography. Cinematic, naturalistic, slightly imperfect.
|
|
48
|
+
|
|
49
|
+
══════════════════════════════════
|
|
50
|
+
💎 SUBJECT & JEWELRY (HIGHEST PRIORITY)
|
|
51
|
+
══════════════════════════════════
|
|
52
|
+
${quantityConstraint}
|
|
53
|
+
CRITICAL: Describe the jewelry EXACTLY as seen in the reference images. Preserve all details: metal type, stone cuts, chain style, settings, etc.
|
|
54
|
+
Do NOT invent additional jewelry pieces or embellishments.
|
|
55
|
+
Do NOT add sparkles, glitter, or magical glow effects.
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
// OCCASION CONTEXT - Give this prominence if selected
|
|
59
|
+
if (occasion?.promptDetails) {
|
|
60
|
+
instruction += `
|
|
61
|
+
══════════════════════════════════
|
|
62
|
+
🎭 OCCASION CONTEXT: ${occasion.name.toUpperCase()}
|
|
63
|
+
══════════════════════════════════
|
|
64
|
+
${occasion.description}
|
|
65
|
+
|
|
66
|
+
🏛️ SETTING & ENVIRONMENT:
|
|
67
|
+
${occasion.promptDetails.setting}
|
|
68
|
+
|
|
69
|
+
✨ ATMOSPHERE & MOOD:
|
|
70
|
+
${occasion.promptDetails.atmosphere}
|
|
71
|
+
|
|
72
|
+
🎨 COLOR PALETTE:
|
|
73
|
+
${occasion.promptDetails.colorPalette}
|
|
74
|
+
|
|
75
|
+
🌟 CULTURAL & THEMATIC ELEMENTS:
|
|
76
|
+
${occasion.promptDetails.culturalElements}
|
|
77
|
+
|
|
78
|
+
💄 MODEL STYLING & AESTHETIC:
|
|
79
|
+
${occasion.promptDetails.styling}
|
|
80
|
+
`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// MODEL CUSTOMIZATIONS
|
|
84
|
+
let modelDetails = [];
|
|
85
|
+
|
|
86
|
+
if (ethnicity && ethnicity.id !== 'none') {
|
|
87
|
+
modelDetails.push(`Model Ethnicity: ${ethnicityLabel}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (detail) {
|
|
91
|
+
// Replace [HAIR_COLOR] in the detail value (e.g. Hairstyle Context)
|
|
92
|
+
const detailValue = detail.value.replace(/\[HAIR_COLOR\]/g, hairColorLabel);
|
|
93
|
+
modelDetails.push(`${template.customizationLabel}: ${detailValue}`);
|
|
94
|
+
} else if (template.customizationLabel?.toLowerCase().includes('makeup')) {
|
|
95
|
+
modelDetails.push(`${template.customizationLabel}: completely bare faced, no makeup, fresh natural skin`);
|
|
96
|
+
} else if (template.customizationLabel?.toLowerCase().includes('nail')) {
|
|
97
|
+
modelDetails.push(`${template.customizationLabel}: natural unpainted nails with a clear healthy coat`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (secondaryDetail) {
|
|
101
|
+
modelDetails.push(`${template.secondaryCustomizationLabel}: ${secondaryDetail.value}`);
|
|
102
|
+
} else if (template.secondaryCustomizationLabel?.toLowerCase().includes('makeup')) {
|
|
103
|
+
modelDetails.push(`${template.secondaryCustomizationLabel}: completely bare faced, no makeup, fresh natural skin`);
|
|
104
|
+
} else if (template.secondaryCustomizationLabel?.toLowerCase().includes('nail')) {
|
|
105
|
+
modelDetails.push(`${template.secondaryCustomizationLabel}: natural unpainted nails with a clear healthy coat`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (tertiaryDetail) {
|
|
109
|
+
modelDetails.push(`${template.tertiaryCustomizationLabel}: ${tertiaryDetail.value}`);
|
|
110
|
+
} else if (template.tertiaryCustomizationLabel?.toLowerCase().includes('makeup')) {
|
|
111
|
+
modelDetails.push(`${template.tertiaryCustomizationLabel}: completely bare faced, no makeup, fresh natural skin`);
|
|
112
|
+
} else if (template.tertiaryCustomizationLabel?.toLowerCase().includes('nail')) {
|
|
113
|
+
modelDetails.push(`${template.tertiaryCustomizationLabel}: natural unpainted nails with a clear healthy coat`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (skinTone && skinTone.id !== 'none' && !template.id.includes('flatlay')) {
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
modelDetails.push(`Model Skin Tone: ${skinTone.value}`);
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
if (hairColor && hairColor.id !== 'none' && !['hand_model', 'flatlay_creative', 'floating_minimal'].includes(template.id)) {
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
modelDetails.push(`Model Hair Color: ${hairColor.value}`);
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
if (modelDetails.length > 0) {
|
|
153
|
+
instruction += `
|
|
154
|
+
══════════════════════════════════
|
|
155
|
+
👤 MODEL SPECIFICATIONS
|
|
156
|
+
══════════════════════════════════
|
|
157
|
+
${modelDetails.join('\n')}
|
|
158
|
+
The model should look like a natural, real human.
|
|
159
|
+
`;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// SETTING & BACKGROUND (if not overridden by occasion)
|
|
163
|
+
if (!occasion && (background || backgroundType || vibe)) {
|
|
164
|
+
instruction += `
|
|
165
|
+
══════════════════════════════════
|
|
166
|
+
🎬 SETTING & ENVIRONMENT
|
|
167
|
+
══════════════════════════════════
|
|
168
|
+
`;
|
|
169
|
+
|
|
170
|
+
if (backgroundType) {
|
|
171
|
+
const bgValue = backgroundType.id === 'interior' ? getRandomLuxuryInterior() : backgroundType.value;
|
|
172
|
+
instruction += `Setting Type: ${bgValue}\n`;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (background) {
|
|
176
|
+
if (template.id === 'flatlay_creative') {
|
|
177
|
+
instruction += `Secondary accent color/texture element to complement the main surface: ${background.value}\n`;
|
|
178
|
+
} else {
|
|
179
|
+
instruction += `Color Palette & Texture: ${background.value}\n`;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (vibe) {
|
|
184
|
+
instruction += `Photography Style & Mood: ${vibe.value}\n`;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
instruction += `\nBackground Treatment: HEAVILY BLURRED (deep cinematic bokeh) to keep focus strictly on the jewelry.
|
|
188
|
+
`;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// TECHNICAL REQUIREMENTS
|
|
192
|
+
instruction += `
|
|
193
|
+
══════════════════════════════════
|
|
194
|
+
⚙️ TECHNICAL REQUIREMENTS
|
|
195
|
+
══════════════════════════════════
|
|
196
|
+
- Natural light reflections on jewelry (NO artificial sparkles or glow)
|
|
197
|
+
- Sharp focus on jewelry with shallow depth of field
|
|
198
|
+
- Authentic photographic quality (film grain acceptable)
|
|
199
|
+
- Professional color grading
|
|
200
|
+
- 2K resolution output quality
|
|
201
|
+
`;
|
|
202
|
+
|
|
203
|
+
// STYLE & POSE DIRECTION (for diversity in batch generation)
|
|
204
|
+
if (styleHint) {
|
|
205
|
+
instruction += `
|
|
206
|
+
══════════════════════════════════
|
|
207
|
+
🎭 STYLE & POSE DIRECTION
|
|
208
|
+
══════════════════════════════════
|
|
209
|
+
${styleHint}
|
|
210
|
+
IMPORTANT: Follow this specific direction to ensure variety across generated images.
|
|
211
|
+
`;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (isVariation) {
|
|
215
|
+
instruction += `
|
|
216
|
+
══════════════════════════════════
|
|
217
|
+
🔄 VARIATION INSTRUCTION
|
|
218
|
+
══════════════════════════════════
|
|
219
|
+
Keep the SAME jewelry pieces and overall aesthetic, but RADICALLY CHANGE THE POSE.
|
|
220
|
+
- If previous shot was static, make this dynamic
|
|
221
|
+
- If previous was profile, try 3/4 view or different angle
|
|
222
|
+
- Change hand placement, head tilt, or body position
|
|
223
|
+
- Goal: Fresh perspective with different composition
|
|
224
|
+
`;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
instruction += `
|
|
228
|
+
══════════════════════════════════
|
|
229
|
+
🚫 STRICT PROHIBITIONS
|
|
230
|
+
══════════════════════════════════
|
|
231
|
+
DO NOT add: fake sparkles, glitter particles, magical glows, lens flares, additional jewelry not in reference
|
|
232
|
+
DO NOT change: the jewelry design, metal type, stone cuts, or any jewelry characteristics
|
|
233
|
+
DO NOT use: artificial effects, over-processing, unrealistic elements
|
|
234
|
+
DO NOT describe: skin details like pores, skin texture, or hyper-realistic skin features - just let the model look naturally human
|
|
235
|
+
|
|
236
|
+
OUTPUT: A structured JSON-like prompt with distinct sections. Do not use a single block of text. Use the following format:
|
|
237
|
+
|
|
238
|
+
{
|
|
239
|
+
"Subject": "Detailed description of the jewelry and model...",
|
|
240
|
+
"Environment": "Setting, background, and atmosphere...",
|
|
241
|
+
"Lighting": "Lighting details...",
|
|
242
|
+
"Photography": "Camera and technical specs..."
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
Ensure the content of each section is rich, dense, and highly descriptive.
|
|
246
|
+
`;
|
|
247
|
+
|
|
248
|
+
return instruction;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export const buildSystemInstruction = (
|
|
252
|
+
template: Template,
|
|
253
|
+
ethnicity: Option | undefined
|
|
254
|
+
): string => {
|
|
255
|
+
const isFloating = template.id === 'floating_minimal';
|
|
256
|
+
const isFlatlay = template.id === 'flatlay_creative';
|
|
257
|
+
const isHandModel = template.id === 'hand_model';
|
|
258
|
+
const isMuseumExhibit = template.id === 'museum_exhibit';
|
|
259
|
+
const isRomance = template.id === 'romance_proposal';
|
|
260
|
+
const isRomanticMood = template.id === 'romantic_mood';
|
|
261
|
+
let llmSystemInstruction = '';
|
|
262
|
+
if (isRomanticMood) {
|
|
263
|
+
llmSystemInstruction = `You are a world-renowned still-life photographer and prop stylist for luxury jewelry and lifestyle brands.
|
|
264
|
+
Your task is to write a prompt for an AI image generator to create a DREAMY, INTIMATE STILL-LIFE PHOTOGRAPH of jewelry in a romantic setting.
|
|
265
|
+
|
|
266
|
+
CRITICAL GUIDELINES:
|
|
267
|
+
1. **JEWELRY FIDELITY (TOP PRIORITY)**: The final image must contain ONLY the jewelry pieces visible in the reference images.
|
|
268
|
+
- Do NOT invent new pieces.
|
|
269
|
+
- Do NOT modify the design of the existing jewelry.
|
|
270
|
+
2. **PROP DISCIPLINE (CRITICAL)**: Use ONLY the specific prop/scene described in the user's customization choice. Do NOT add other props.
|
|
271
|
+
- If the user chose "candles", the scene is ONLY candles and the jewelry. Do NOT add roses, letters, or other objects.
|
|
272
|
+
- If the user chose "rose petals", the scene is ONLY rose petals and the jewelry. Do NOT add candles, letters, or other objects.
|
|
273
|
+
- Keep the scene focused and minimal — one prop theme, not a cluttered collection of romantic clichés.
|
|
274
|
+
3. **Subject**: NO human model, NO body parts, NO mannequins, NO hands.
|
|
275
|
+
4. **NO FAKE EFFECTS**: Strictly FORBID "sparkles", "glitter particles", "magical glow". Use natural light and genuine material textures.
|
|
276
|
+
5. **Realism**: Use product photography keywords (Hasselblad X2D 100C, 120mm Macro, f/2.8, shallow depth of field). Props must look real and tactile.
|
|
277
|
+
6. **Vibe**: Romantic, intimate, dreamy, feminine.
|
|
278
|
+
|
|
279
|
+
Output: A single, dense, highly descriptive English prompt. No introductions.`;
|
|
280
|
+
} else if (isRomance) {
|
|
281
|
+
const ethnicityPrompt = (ethnicity && ethnicity.id !== 'none') ? ethnicity.value : "Professional couple";
|
|
282
|
+
llmSystemInstruction = `You are a world-renowned wedding and engagement photographer, known for capturing raw, authentic emotional moments.
|
|
283
|
+
Your task is to write a prompt for an AI image generator to create an INTIMATE, EMOTIONALLY POWERFUL photograph based on reference jewelry images.
|
|
284
|
+
|
|
285
|
+
CRITICAL GUIDELINES:
|
|
286
|
+
1. **JEWELRY FIDELITY (TOP PRIORITY)**: The final image must contain ONLY the jewelry pieces visible in the reference images.
|
|
287
|
+
- Do NOT invent new pieces (e.g. do not add a necklace if only a ring is provided).
|
|
288
|
+
- Do NOT modify the design of the existing jewelry.
|
|
289
|
+
2. **Subject**: Focus on the emotional authenticity of the moment. The jewelry (especially rings) should be prominently visible but feel naturally integrated.
|
|
290
|
+
- Hands, fingers, and body language are critical storytelling elements.
|
|
291
|
+
- Ethnicity context: ${ethnicityPrompt}
|
|
292
|
+
3. **NO FAKE EFFECTS**: Strictly FORBID "sparkles", "glitter particles", "magical glow". Natural light reflection only.
|
|
293
|
+
4. **Realism**: Use photography keywords (Contax 645, Zeiss Planar 80mm f/2, Kodak Portra 400).
|
|
294
|
+
5. **Vibe**: Tender, authentic, emotionally powerful, intimate. Real love story energy.
|
|
295
|
+
|
|
296
|
+
Output: A single, dense, highly descriptive English prompt. No introductions.`;
|
|
297
|
+
} else if (isMuseumExhibit) {
|
|
298
|
+
llmSystemInstruction = `You are a world-renowned museum photographer and exhibition designer.
|
|
299
|
+
Your task is to write a prompt for an AI image generator to create a MUSEUM-QUALITY photograph of jewelry displayed as a priceless exhibit.
|
|
300
|
+
|
|
301
|
+
CRITICAL GUIDELINES:
|
|
302
|
+
1. **JEWELRY FIDELITY (TOP PRIORITY)**: The final image must contain ONLY the jewelry pieces visible in the reference images.
|
|
303
|
+
- Do NOT invent new pieces.
|
|
304
|
+
- Do NOT modify the design of the existing jewelry.
|
|
305
|
+
2. **Subject**: The jewelry should be displayed as a priceless artifact worthy of the world's greatest museums.
|
|
306
|
+
- NO human model, NO body parts, NO mannequins.
|
|
307
|
+
3. **NO FAKE EFFECTS**: Strictly FORBID "sparkles", "glitter particles", "magical glow". Professional museum lighting only.
|
|
308
|
+
4. **Realism**: Use professional museum photography equipment and lighting terminology.
|
|
309
|
+
5. **Vibe**: Reverent, prestigious, archival quality, awe-inspiring.
|
|
310
|
+
|
|
311
|
+
Output: A single, dense, highly descriptive English prompt. No introductions.`;
|
|
312
|
+
} else if (isFloating) {
|
|
313
|
+
llmSystemInstruction = `You are a world-renowned product photographer and creative director for luxury jewelry campaigns.
|
|
314
|
+
Your task is to write a prompt for an AI image generator to create a HYPER-REALISTIC product photograph based on reference images.
|
|
315
|
+
|
|
316
|
+
CRITICAL GUIDELINES:
|
|
317
|
+
1. **JEWELRY FIDELITY (TOP PRIORITY)**: The final image must contain ONLY the jewelry pieces visible in the reference images.
|
|
318
|
+
- Do NOT invent new pieces (e.g. do not add earrings if only a necklace is provided).
|
|
319
|
+
- Do NOT modify the design of the existing jewelry.
|
|
320
|
+
2. **Subject**: The jewelry should appear to be SUSPENDED in mid-air, floating, with NO human model, NO body parts, and NO mannequins. Focus on dramatic lighting, shadows, and a clean, minimalist composition.
|
|
321
|
+
3. **NO FAKE EFFECTS**: Strictly FORBID "sparkles", "glitter particles", "magical glow". Natural light reflection only.
|
|
322
|
+
4. **Realism**: Use photography keywords (Hasselblad X2D 100C, Macro Lens 120mm, f/2.8).
|
|
323
|
+
5. **Vibe**: Old money, elegant, classy, expensive, minimalist.
|
|
324
|
+
|
|
325
|
+
Output: A single, dense, highly descriptive English prompt. No introductions.`;
|
|
326
|
+
} else if (isFlatlay) {
|
|
327
|
+
llmSystemInstruction = `You are a world-renowned product photographer and creative director for luxury jewelry campaigns.
|
|
328
|
+
Your task is to write a prompt for an AI image generator to create a HYPER-REALISTIC product photograph based on reference images.
|
|
329
|
+
|
|
330
|
+
CRITICAL GUIDELINES:
|
|
331
|
+
1. **JEWELRY FIDELITY (TOP PRIORITY)**: The final image must contain ONLY the jewelry pieces visible in the reference images.
|
|
332
|
+
- Do NOT invent new pieces (e.g. do not add earrings if only a necklace is provided).
|
|
333
|
+
- Do NOT modify the design of the existing jewelry.
|
|
334
|
+
2. **Subject**: The jewelry should be displayed as a creative still-life composition, with NO human model, NO body parts, and NO mannequins.
|
|
335
|
+
- The jewelry may be laid flat on a surface, OR elevated on geometric pedestals, cubes, stone risers, plinths, or sculptural props.
|
|
336
|
+
- Lighting should always look natural and photographic � soft studio light, window light, or gentle directional light. Shadows should feel organic, not artificial.
|
|
337
|
+
3. **NO FAKE EFFECTS**: Strictly FORBID "sparkles", "glitter particles", "magical glow", neon lighting, overly stylized color gels. Natural light reflection only.
|
|
338
|
+
4. **Realism**: Use photography keywords (Hasselblad X2D 100C, Macro Lens 120mm, f/2.8).
|
|
339
|
+
5. **Vibe**: Old money, elegant, classy, expensive, artistic.
|
|
340
|
+
|
|
341
|
+
Output: A single, dense, highly descriptive English prompt. No introductions.`;
|
|
342
|
+
} else if (isHandModel) {
|
|
343
|
+
llmSystemInstruction = `You are a world-renowned product photographer and creative director for luxury jewelry campaigns.
|
|
344
|
+
Your task is to write a prompt for an AI image generator to create a HYPER-REALISTIC hand model photograph based on reference images.
|
|
345
|
+
|
|
346
|
+
CRITICAL GUIDELINES:
|
|
347
|
+
1. **JEWELRY FIDELITY (TOP PRIORITY)**: The final image must contain ONLY the jewelry pieces visible in the reference images.
|
|
348
|
+
- Do NOT invent new pieces (e.g. do not add earrings if only a ring is provided).
|
|
349
|
+
- Do NOT modify the design of the existing jewelry.
|
|
350
|
+
2. **FRAMING (CRITICAL)**: The image focuses on the hand, wrist, and forearm area.
|
|
351
|
+
- NO face, head, or shoulders visible.
|
|
352
|
+
- The forearm may be bare OR elegantly sleeved (luxurious fabrics like silk, cashmere, lace, velvet).
|
|
353
|
+
- When clothing is present, it should be high-end and sophisticated.
|
|
354
|
+
3. **Subject**: A model's hand(s) (age 20-30) with elegant, relaxed pose wearing the jewelry. Focus on authentic skin texture and natural nail appearance.
|
|
355
|
+
- If 3 or more jewelry pieces are provided, show BOTH hands to distribute the pieces naturally and elegantly across both hands. Avoid cramming all pieces onto a single hand.
|
|
356
|
+
- If 1-2 pieces, a single hand is fine.
|
|
357
|
+
4. **NO FAKE EFFECTS**: Strictly FORBID "sparkles", "glitter particles", "magical glow". Natural light reflection only.
|
|
358
|
+
5. **Realism**: Use photography keywords (Hasselblad X2D 100C, Macro Lens 120mm, f/2.8).
|
|
359
|
+
6. **Vibe**: Old money, elegant, classy, expensive, feminine.
|
|
360
|
+
|
|
361
|
+
Output: A single, dense, highly descriptive English prompt. No introductions.`;
|
|
362
|
+
} else {
|
|
363
|
+
const ethnicityPrompt = (ethnicity && ethnicity.id !== 'none') ? ethnicity.value : "Professional female model";
|
|
364
|
+
llmSystemInstruction = `You are a world-renowned fashion photographer and creative director for Vogue Arabia and High Jewelry campaigns.
|
|
365
|
+
Your task is to write a prompt for an AI image generator to create an AUTHENTIC, CINEMATIC photograph based on reference images. Skin texture should look natural and smooth.
|
|
366
|
+
|
|
367
|
+
CRITICAL GUIDELINES:
|
|
368
|
+
1. **JEWELRY FIDELITY (TOP PRIORITY)**: The final image must contain ONLY the jewelry pieces visible in the reference images.
|
|
369
|
+
- Do NOT invent new pieces (e.g. do not add earrings if only a necklace is provided).
|
|
370
|
+
- Do NOT modify the design of the existing jewelry.
|
|
371
|
+
- If one ring is provided, the model wears ONE ring.
|
|
372
|
+
2. **Subject**: ALWAYS a ${ethnicityPrompt} (age 20-30).
|
|
373
|
+
3. **NO FAKE EFFECTS**: Strictly FORBID "sparkles", "glitter particles", "magical glow". Natural light reflection only.
|
|
374
|
+
4. **Realism**: Use photography keywords (Hasselblad X2D 100C, Macro Lens 120mm, f/2.8).
|
|
375
|
+
5. **Vibe**: Old money, elegant, classy, expensive, feminine.
|
|
376
|
+
|
|
377
|
+
Output: A single, dense, highly descriptive English prompt. No introductions.`;
|
|
378
|
+
}
|
|
379
|
+
return llmSystemInstruction;
|
|
380
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Option } from "../types.js";
|
|
2
|
+
import { TIRED_GIRL_STYLE_MAP, TIRED_GIRL_STYLES } from "../config/tiredGirl.js";
|
|
3
|
+
|
|
4
|
+
export const resolveTiredGirlStyles = (styleIds?: string[], quantity: number = 1): Option[] => {
|
|
5
|
+
if (styleIds && styleIds.length > 0) {
|
|
6
|
+
const resolved = styleIds
|
|
7
|
+
.map((id) => TIRED_GIRL_STYLE_MAP.get(id))
|
|
8
|
+
.filter((style): style is Option => !!style);
|
|
9
|
+
if (resolved.length > 0) return resolved;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Default cycling through predefined styles
|
|
13
|
+
const styles: Option[] = [];
|
|
14
|
+
for (let i = 0; i < quantity; i += 1) {
|
|
15
|
+
styles.push(TIRED_GIRL_STYLES[i % TIRED_GIRL_STYLES.length]);
|
|
16
|
+
}
|
|
17
|
+
return styles;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const buildTiredGirlPrompt = (style: Option, hasMuse: boolean): string => {
|
|
21
|
+
return `You are a world-renowned fashion photographer.
|
|
22
|
+
Your task is to write a prompt for an AI image generator to create a photorealistic portrait of a model in a "before" look.
|
|
23
|
+
|
|
24
|
+
CRITICAL GUIDELINES:
|
|
25
|
+
1. JEWELRY REMOVAL: The final image must contain NO jewelry whatsoever (no rings, earrings, necklaces, bracelets, watches).
|
|
26
|
+
- If jewelry appears in reference images, REMOVE it.
|
|
27
|
+
2. IDENTITY CONSISTENCY: The model must match the reference images exactly (same face, features, skin tone).
|
|
28
|
+
${hasMuse ? "3. The reference images are of the same model (Muse). Use them to preserve identity." : "3. Use the reference image to preserve identity."}
|
|
29
|
+
4. STYLE: ${style.value}
|
|
30
|
+
5. WARDROBE: casual, at-home, or relaxed styling (if not explicitly specified in style).
|
|
31
|
+
6. LIGHTING: naturalistic, soft, real-world light.
|
|
32
|
+
7. REALISM: no stylized effects, no glamour retouching.
|
|
33
|
+
|
|
34
|
+
OUTPUT: A single, dense prompt describing the scene. Do not include any jewelry.`;
|
|
35
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
export const ensureDir = async (dir: string): Promise<void> => {
|
|
5
|
+
await fs.mkdir(dir, { recursive: true });
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const readFileAsBase64 = async (filePath: string): Promise<{ data: string; mimeType: string }> => {
|
|
9
|
+
const buffer = await fs.readFile(filePath);
|
|
10
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
11
|
+
const mimeType = ext === ".png" ? "image/png" : ext === ".webp" ? "image/webp" : "image/jpeg";
|
|
12
|
+
return { data: buffer.toString("base64"), mimeType };
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const readImageAsPart = async (filePath: string): Promise<{ inlineData: { mimeType: string; data: string } }> => {
|
|
16
|
+
const { data, mimeType } = await readFileAsBase64(filePath);
|
|
17
|
+
return { inlineData: { data, mimeType } };
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const saveBase64Image = async (base64DataUrl: string, outputPath: string): Promise<void> => {
|
|
21
|
+
const base64 = base64DataUrl.includes(",") ? base64DataUrl.split(",")[1] : base64DataUrl;
|
|
22
|
+
const buffer = Buffer.from(base64, "base64");
|
|
23
|
+
await ensureDir(path.dirname(outputPath));
|
|
24
|
+
await fs.writeFile(outputPath, buffer);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const saveBinary = async (bytes: Uint8Array, outputPath: string): Promise<void> => {
|
|
28
|
+
await ensureDir(path.dirname(outputPath));
|
|
29
|
+
await fs.writeFile(outputPath, Buffer.from(bytes));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const writeJson = async (outputPath: string, payload: unknown): Promise<void> => {
|
|
33
|
+
await ensureDir(path.dirname(outputPath));
|
|
34
|
+
await fs.writeFile(outputPath, JSON.stringify(payload, null, 2));
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const resolveOutputDir = (baseDir: string, subdir: string): string => {
|
|
38
|
+
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
39
|
+
return path.join(baseDir, subdir, stamp);
|
|
40
|
+
};
|
|
41
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { MuseRecord } from "../types.js";
|
|
4
|
+
|
|
5
|
+
const museIndexPath = (baseDir: string) => path.join(baseDir, "muses.json");
|
|
6
|
+
|
|
7
|
+
export const loadMuses = async (baseDir: string): Promise<MuseRecord[]> => {
|
|
8
|
+
try {
|
|
9
|
+
const raw = await fs.readFile(museIndexPath(baseDir), "utf-8");
|
|
10
|
+
return JSON.parse(raw) as MuseRecord[];
|
|
11
|
+
} catch {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const saveMuses = async (baseDir: string, muses: MuseRecord[]): Promise<void> => {
|
|
17
|
+
await fs.mkdir(baseDir, { recursive: true });
|
|
18
|
+
await fs.writeFile(museIndexPath(baseDir), JSON.stringify(muses, null, 2));
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const addMuse = async (baseDir: string, muse: MuseRecord): Promise<void> => {
|
|
22
|
+
const muses = await loadMuses(baseDir);
|
|
23
|
+
muses.push(muse);
|
|
24
|
+
await saveMuses(baseDir, muses);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const getMuseById = async (baseDir: string, id: string): Promise<MuseRecord | undefined> => {
|
|
28
|
+
const muses = await loadMuses(baseDir);
|
|
29
|
+
return muses.find((m) => m.id === id);
|
|
30
|
+
};
|
|
31
|
+
|