qlogicagent 2.11.1 → 2.11.3
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/cli.js +290 -289
- package/dist/index.js +292 -291
- package/dist/pet-contracts.js +1 -1
- package/dist/protocol.js +1 -1
- package/dist/types/cli/handlers/session-handler.d.ts +3 -3
- package/dist/types/cli/media-runtime-facade.d.ts +8 -0
- package/dist/types/cli/pet-runtime.d.ts +1 -3
- package/dist/types/cli/session-query-service.d.ts +1 -0
- package/dist/types/protocol/wire/acp-protocol.d.ts +6 -0
- package/dist/types/protocol/wire/gateway-rpc.d.ts +2 -0
- package/dist/types/protocol/wire/pet-contracts.d.ts +3 -2
- package/dist/types/runtime/infra/acp-detector.d.ts +21 -0
- package/dist/types/runtime/infra/project-store.d.ts +1 -0
- package/dist/types/runtime/pet/hatch-pet-runner.d.ts +18 -0
- package/dist/types/runtime/pet/index.d.ts +12 -5
- package/dist/types/runtime/pet/pet-file-loader.d.ts +1 -1
- package/dist/types/runtime/pet/pet-growth-engine.d.ts +2 -58
- package/dist/types/runtime/pet/pet-profile-service.d.ts +5 -7
- package/dist/types/runtime/pet/pet-reaction-engine.d.ts +11 -0
- package/dist/types/runtime/pet/pet-soul-service.d.ts +2 -2
- package/dist/types/runtime/pet/pet-types.d.ts +1 -32
- package/dist/types/runtime/pet/petdex-asset.d.ts +3 -109
- package/dist/types/runtime/pet/petdex-forge-service.d.ts +3 -94
- package/dist/types/runtime/prompt/fresh-workspace-evidence.d.ts +1 -0
- package/dist/types/runtime/session/session-locator.d.ts +2 -0
- package/dist/types/runtime/session/session-persistence.d.ts +17 -3
- package/dist/types/skills/tools/petdex-create-tool.d.ts +2 -16
- package/dist/vendor/hatch-pet/LICENSE.txt +201 -0
- package/dist/vendor/hatch-pet/NOTICE.md +25 -0
- package/dist/vendor/hatch-pet/references/animation-rows.md +29 -0
- package/dist/vendor/hatch-pet/references/codex-pet-contract.md +35 -0
- package/dist/vendor/hatch-pet/references/qa-rubric.md +66 -0
- package/dist/vendor/hatch-pet/scripts/compose_atlas.py +169 -0
- package/dist/vendor/hatch-pet/scripts/derive_running_left_from_running_right.py +150 -0
- package/dist/vendor/hatch-pet/scripts/extract_strip_frames.py +408 -0
- package/dist/vendor/hatch-pet/scripts/inspect_frames.py +256 -0
- package/dist/vendor/hatch-pet/scripts/make_contact_sheet.py +96 -0
- package/dist/vendor/hatch-pet/scripts/prepare_pet_run.py +830 -0
- package/dist/vendor/hatch-pet/scripts/render_animation_previews.py +78 -0
- package/dist/vendor/hatch-pet/scripts/validate_atlas.py +157 -0
- package/package.json +5 -3
- package/dist/types/runtime/pet/pet-reaction-service.d.ts +0 -33
|
@@ -0,0 +1,830 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Create a Codex pet run folder, prompts, and imagegen job manifest."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import json
|
|
8
|
+
import math
|
|
9
|
+
import re
|
|
10
|
+
import shutil
|
|
11
|
+
from datetime import datetime, timezone
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
from PIL import Image
|
|
15
|
+
from PIL import ImageDraw
|
|
16
|
+
|
|
17
|
+
ATLAS = {"columns": 8, "rows": 9, "cell_width": 192, "cell_height": 208}
|
|
18
|
+
ATLAS["width"] = ATLAS["columns"] * ATLAS["cell_width"]
|
|
19
|
+
ATLAS["height"] = ATLAS["rows"] * ATLAS["cell_height"]
|
|
20
|
+
|
|
21
|
+
ROWS = [
|
|
22
|
+
("idle", 0, 6, "calm resting, breathing, and blinking loop"),
|
|
23
|
+
("running-right", 1, 8, "rightward drag movement loop"),
|
|
24
|
+
("running-left", 2, 8, "leftward drag movement loop"),
|
|
25
|
+
("waving", 3, 4, "greeting or attention gesture"),
|
|
26
|
+
("jumping", 4, 5, "hover or playful jump"),
|
|
27
|
+
("failed", 5, 8, "blocked, failed, or cancelled reaction"),
|
|
28
|
+
("waiting", 6, 6, "waiting for approval, help, or user input"),
|
|
29
|
+
("running", 7, 6, "active task work or processing"),
|
|
30
|
+
("review", 8, 6, "ready or completed output review"),
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
STATE_PROMPTS = {
|
|
34
|
+
"idle": "Calm low-distraction resting loop: subtle breathing, tiny blink, slight head/body bob, and only quiet persona-preserving motion.",
|
|
35
|
+
"running-right": "Dragging-right loop: show directional movement to the right through body and limb poses only.",
|
|
36
|
+
"running-left": "Dragging-left loop: show directional movement to the left through body and limb poses only.",
|
|
37
|
+
"waving": "Greeting loop: paw or limb down, raised, tilted, and returning in a friendly attention gesture.",
|
|
38
|
+
"jumping": "Hover jump loop: anticipation, lift, airborne peak, descent, and settle through body height.",
|
|
39
|
+
"failed": "Blocked/failed loop: slumped or deflated reaction with sad or closed eyes.",
|
|
40
|
+
"waiting": "Needs-input loop: expectant asking pose for approval, help, or user input.",
|
|
41
|
+
"running": "Working loop: focused active-task processing, thinking, typing, scanning, or effortful concentration; not literal foot-running, jogging, sprinting, treadmill motion, raised knees, long steps, pumping arms, or directional travel.",
|
|
42
|
+
"review": "Ready-review loop: focused inspection of completed output with lean, blink, narrowed eyes, head tilt, or paw pose.",
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
STATE_REQUIREMENTS = {
|
|
46
|
+
"idle": [
|
|
47
|
+
"CRITICAL: idle is the low-distraction baseline state and the first frame is also used as the reduced-motion static pet.",
|
|
48
|
+
"Use only subtle idle motion: gentle breathing, a tiny blink, a slight head or body bob, a very small material sway, or another quiet motion that fits the pet persona.",
|
|
49
|
+
"Keep the pet essentially in the same pose, facing direction, silhouette, markings, palette, and prop state across all 6 frames.",
|
|
50
|
+
"Idle variation must stay calm but still read as animation; do not repeat effectively identical copies across the loop.",
|
|
51
|
+
"Do not show waving, walking, running, jumping, talking, working, reviewing, emotional reactions, large gestures, item interactions, or new props.",
|
|
52
|
+
"Feet, base, body, or object anchor should remain planted or nearly planted.",
|
|
53
|
+
"The first and last frames should be very close visually so the loop feels calm and does not pop.",
|
|
54
|
+
],
|
|
55
|
+
"waving": [
|
|
56
|
+
"Show the greeting through paw, hand, wing, or limb pose only.",
|
|
57
|
+
"Do not draw wave marks, motion arcs, lines, sparkles, symbols, or floating effects around the gesture.",
|
|
58
|
+
],
|
|
59
|
+
"jumping": [
|
|
60
|
+
"Show the jump through pose and vertical body position only: anticipation, lift, airborne peak, descent, settle.",
|
|
61
|
+
"Do not draw ground shadows, contact shadows, drop shadows, oval shadows, landing marks, dust, smears, bounce pads, or motion marks under the pet.",
|
|
62
|
+
"Keep the background outside the pet perfectly flat chroma key with no darker key-colored patches.",
|
|
63
|
+
],
|
|
64
|
+
"failed": [
|
|
65
|
+
"Show failure through slumped pose, drooping ears/limbs, closed or sad eyes, and lower body position.",
|
|
66
|
+
"Tears, small smoke puffs, or tiny stars are allowed only if attached to or overlapping the pet silhouette and kept inside the same frame slot.",
|
|
67
|
+
"Do not draw red X marks, floating symbols, detached stars, separated smoke clouds, falling tear drops, dust, or other loose effects.",
|
|
68
|
+
],
|
|
69
|
+
"waiting": [
|
|
70
|
+
"Show that Codex needs approval, help, or user input through an expectant asking pose.",
|
|
71
|
+
"Keep the motion patient and readable, without turning it into ordinary idle or review.",
|
|
72
|
+
],
|
|
73
|
+
"running": [
|
|
74
|
+
"Show the pet actively working or processing, as if running a task: focused posture, busy hands or paws, purposeful bobbing, thinking motion, tool or prop motion only if already part of the pet identity, or other non-locomotion activity.",
|
|
75
|
+
"Do not show literal foot-running, jogging, sprinting, treadmill motion, raised knees, long steps, pumping arms, directional travel, speed lines, dust clouds, floor shadows, motion trails, or detached motion effects.",
|
|
76
|
+
],
|
|
77
|
+
"review": [
|
|
78
|
+
"Show review through lean, blink, narrowed eyes, head tilt, or paw/hand position.",
|
|
79
|
+
"Do not add magnifying glasses, papers, code, UI, punctuation, symbols, or other new props unless they already exist in the base pet identity.",
|
|
80
|
+
],
|
|
81
|
+
"running-right": [
|
|
82
|
+
"Show directional drag movement to the right through body, limb, and prop movement only.",
|
|
83
|
+
"The row must unmistakably face and travel right.",
|
|
84
|
+
"The movement cadence must alternate visibly across the 8 frames instead of repeating one nearly static stride.",
|
|
85
|
+
"Do not draw speed lines, dust clouds, floor shadows, motion trails, or detached motion effects.",
|
|
86
|
+
],
|
|
87
|
+
"running-left": [
|
|
88
|
+
"Show directional drag movement to the left through body, limb, and prop movement only.",
|
|
89
|
+
"The row must unmistakably face and travel left.",
|
|
90
|
+
"The movement cadence must alternate visibly across the 8 frames instead of repeating one nearly static stride.",
|
|
91
|
+
"Do not draw speed lines, dust clouds, floor shadows, motion trails, or detached motion effects.",
|
|
92
|
+
],
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
NON_DERIVABLE_STATES = {
|
|
96
|
+
"waving",
|
|
97
|
+
"jumping",
|
|
98
|
+
"failed",
|
|
99
|
+
"waiting",
|
|
100
|
+
"running",
|
|
101
|
+
"review",
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
PET_SAFE_STYLE = (
|
|
105
|
+
"Pet-safe sprite: compact full-body mascot, readable in a 192x208 cell, "
|
|
106
|
+
"clear silhouette, simple face, stable palette/materials, and crisp edges "
|
|
107
|
+
"for chroma-key extraction."
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
STYLE_PRESETS = {
|
|
111
|
+
"auto": (
|
|
112
|
+
"Infer the most appropriate pet-safe style from the user request and "
|
|
113
|
+
"reference images, then keep that exact style consistent across every row."
|
|
114
|
+
),
|
|
115
|
+
"pixel": (
|
|
116
|
+
"Pixel-art-adjacent digital mascot with a chunky silhouette, simple dark "
|
|
117
|
+
"outline, limited palette, flat cel shading, and visible stepped edges."
|
|
118
|
+
),
|
|
119
|
+
"plush": (
|
|
120
|
+
"Soft plush toy mascot with rounded stitched forms, fuzzy fabric feel, "
|
|
121
|
+
"simple sewn details, and readable toy-like proportions."
|
|
122
|
+
),
|
|
123
|
+
"clay": (
|
|
124
|
+
"Handmade clay or polymer-clay mascot with rounded sculpted forms, soft "
|
|
125
|
+
"material texture, simple features, and clean readable edges."
|
|
126
|
+
),
|
|
127
|
+
"sticker": (
|
|
128
|
+
"Polished sticker mascot with bold clean shapes, crisp outline, flat "
|
|
129
|
+
"colors, and minimal highlight detail."
|
|
130
|
+
),
|
|
131
|
+
"flat-vector": (
|
|
132
|
+
"Flat vector-style mascot with simple geometric forms, crisp color areas, "
|
|
133
|
+
"clean outline, and minimal shading."
|
|
134
|
+
),
|
|
135
|
+
"3d-toy": (
|
|
136
|
+
"Stylized 3D toy mascot with smooth rounded forms, simple materials, "
|
|
137
|
+
"clear silhouette, and no photoreal complexity."
|
|
138
|
+
),
|
|
139
|
+
"painterly": (
|
|
140
|
+
"Painterly mascot with simplified brush texture, readable forms, stable "
|
|
141
|
+
"palette, and enough edge clarity for clean extraction."
|
|
142
|
+
),
|
|
143
|
+
"brand-inspired": (
|
|
144
|
+
"Brand-inspired mascot using approved public or user-provided brand cues "
|
|
145
|
+
"such as colors, mascot themes, and vibe while avoiding readable text or "
|
|
146
|
+
"logo copying unless explicitly approved."
|
|
147
|
+
),
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
CHROMA_KEY_CANDIDATES = [
|
|
151
|
+
("magenta", "#FF00FF"),
|
|
152
|
+
("cyan", "#00FFFF"),
|
|
153
|
+
("yellow", "#FFFF00"),
|
|
154
|
+
("blue", "#0000FF"),
|
|
155
|
+
("orange", "#FF7F00"),
|
|
156
|
+
("green", "#00FF00"),
|
|
157
|
+
]
|
|
158
|
+
|
|
159
|
+
DEFAULT_PET_NAME = "Sprout"
|
|
160
|
+
CANONICAL_BASE_PATH = "references/canonical-base.png"
|
|
161
|
+
BRAND_DISCOVERY_PATH = "references/brand-discovery.md"
|
|
162
|
+
LAYOUT_GUIDE_DIR = "references/layout-guides"
|
|
163
|
+
LAYOUT_GUIDE_SAFE_MARGIN_X = 18
|
|
164
|
+
LAYOUT_GUIDE_SAFE_MARGIN_Y = 16
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def slugify(value: str) -> str:
|
|
168
|
+
value = value.strip().lower()
|
|
169
|
+
value = re.sub(r"[^a-z0-9]+", "-", value)
|
|
170
|
+
value = re.sub(r"-{2,}", "-", value)
|
|
171
|
+
return value.strip("-")
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def display_from_slug(value: str) -> str:
|
|
175
|
+
words = [word for word in re.split(r"[^a-zA-Z0-9]+", value.strip()) if word]
|
|
176
|
+
return " ".join(word.capitalize() for word in words)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def concept_words(value: str) -> list[str]:
|
|
180
|
+
stop_words = {
|
|
181
|
+
"a",
|
|
182
|
+
"an",
|
|
183
|
+
"and",
|
|
184
|
+
"app",
|
|
185
|
+
"based",
|
|
186
|
+
"codex",
|
|
187
|
+
"compact",
|
|
188
|
+
"digital",
|
|
189
|
+
"for",
|
|
190
|
+
"from",
|
|
191
|
+
"in",
|
|
192
|
+
"of",
|
|
193
|
+
"on",
|
|
194
|
+
"pet",
|
|
195
|
+
"ready",
|
|
196
|
+
"small",
|
|
197
|
+
"the",
|
|
198
|
+
"to",
|
|
199
|
+
"with",
|
|
200
|
+
}
|
|
201
|
+
words = [
|
|
202
|
+
word.lower()
|
|
203
|
+
for word in re.findall(r"[a-zA-Z0-9]+", value)
|
|
204
|
+
if word.lower() not in stop_words
|
|
205
|
+
]
|
|
206
|
+
return words
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def infer_name(args: argparse.Namespace, reference_paths: list[Path]) -> str:
|
|
210
|
+
for raw_value in [args.display_name, args.pet_name]:
|
|
211
|
+
value = raw_value.strip()
|
|
212
|
+
if value:
|
|
213
|
+
return value
|
|
214
|
+
|
|
215
|
+
if args.pet_id.strip():
|
|
216
|
+
display = display_from_slug(args.pet_id)
|
|
217
|
+
if display:
|
|
218
|
+
return display
|
|
219
|
+
|
|
220
|
+
for raw_value in [args.pet_notes, args.description, args.brand_name]:
|
|
221
|
+
words = concept_words(raw_value)
|
|
222
|
+
if words:
|
|
223
|
+
return words[0].capitalize()
|
|
224
|
+
|
|
225
|
+
for path in reference_paths:
|
|
226
|
+
display = display_from_slug(path.stem)
|
|
227
|
+
if display:
|
|
228
|
+
return display
|
|
229
|
+
|
|
230
|
+
return DEFAULT_PET_NAME
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def sentence(value: str) -> str:
|
|
234
|
+
value = " ".join(value.strip().split())
|
|
235
|
+
if not value:
|
|
236
|
+
return value
|
|
237
|
+
if value[-1] not in ".!?":
|
|
238
|
+
value += "."
|
|
239
|
+
return value
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def infer_description(args: argparse.Namespace, reference_paths: list[Path]) -> str:
|
|
243
|
+
if args.description.strip():
|
|
244
|
+
return sentence(args.description)
|
|
245
|
+
if args.pet_notes.strip():
|
|
246
|
+
return sentence(f"A compact Codex pet: {args.pet_notes}")
|
|
247
|
+
if args.brand_name.strip():
|
|
248
|
+
return sentence(f"A compact Codex pet inspired by {args.brand_name}")
|
|
249
|
+
if reference_paths:
|
|
250
|
+
return "A compact Codex pet based on the provided reference image."
|
|
251
|
+
return "A compact original Codex pet ready for animation."
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def infer_pet_notes(args: argparse.Namespace, reference_paths: list[Path]) -> str:
|
|
255
|
+
if args.pet_notes.strip():
|
|
256
|
+
return args.pet_notes.strip()
|
|
257
|
+
if args.description.strip():
|
|
258
|
+
return args.description.strip().rstrip(".")
|
|
259
|
+
if args.brand_name.strip():
|
|
260
|
+
return f"a compact mascot inspired by {args.brand_name.strip()}"
|
|
261
|
+
if reference_paths:
|
|
262
|
+
return "the pet shown in the reference image(s)"
|
|
263
|
+
return "a compact original Codex pet"
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def default_output_dir(pet_id: str) -> Path:
|
|
267
|
+
timestamp = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
|
|
268
|
+
return Path.cwd() / "output" / "hatch-pet" / f"{pet_id}-{timestamp}"
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def rel(path: Path, root: Path) -> str:
|
|
272
|
+
return str(path.resolve().relative_to(root.resolve()))
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def image_metadata(path: Path) -> dict[str, object]:
|
|
276
|
+
with Image.open(path) as image:
|
|
277
|
+
return {
|
|
278
|
+
"path": str(path),
|
|
279
|
+
"width": image.width,
|
|
280
|
+
"height": image.height,
|
|
281
|
+
"mode": image.mode,
|
|
282
|
+
"format": image.format,
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def draw_dashed_line(
|
|
287
|
+
draw: ImageDraw.ImageDraw,
|
|
288
|
+
start: tuple[int, int],
|
|
289
|
+
end: tuple[int, int],
|
|
290
|
+
*,
|
|
291
|
+
fill: str,
|
|
292
|
+
dash: int = 8,
|
|
293
|
+
gap: int = 6,
|
|
294
|
+
) -> None:
|
|
295
|
+
x1, y1 = start
|
|
296
|
+
x2, y2 = end
|
|
297
|
+
if x1 == x2:
|
|
298
|
+
step = dash + gap
|
|
299
|
+
for y in range(min(y1, y2), max(y1, y2), step):
|
|
300
|
+
draw.line((x1, y, x2, min(y + dash, max(y1, y2))), fill=fill)
|
|
301
|
+
return
|
|
302
|
+
if y1 == y2:
|
|
303
|
+
step = dash + gap
|
|
304
|
+
for x in range(min(x1, x2), max(x1, x2), step):
|
|
305
|
+
draw.line((x, y1, min(x + dash, max(x1, x2)), y2), fill=fill)
|
|
306
|
+
return
|
|
307
|
+
raise ValueError("draw_dashed_line only supports horizontal or vertical lines")
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
def create_layout_guide(path: Path, state: str, frames: int) -> dict[str, object]:
|
|
311
|
+
width = frames * ATLAS["cell_width"]
|
|
312
|
+
height = ATLAS["cell_height"]
|
|
313
|
+
cell_width = ATLAS["cell_width"]
|
|
314
|
+
image = Image.new("RGB", (width, height), "#f7f7f7")
|
|
315
|
+
draw = ImageDraw.Draw(image)
|
|
316
|
+
|
|
317
|
+
for index in range(frames):
|
|
318
|
+
left = index * cell_width
|
|
319
|
+
right = left + cell_width - 1
|
|
320
|
+
draw.rectangle((left, 0, right, height - 1), outline="#111111", width=2)
|
|
321
|
+
|
|
322
|
+
safe_left = left + LAYOUT_GUIDE_SAFE_MARGIN_X
|
|
323
|
+
safe_top = LAYOUT_GUIDE_SAFE_MARGIN_Y
|
|
324
|
+
safe_right = right - LAYOUT_GUIDE_SAFE_MARGIN_X
|
|
325
|
+
safe_bottom = height - 1 - LAYOUT_GUIDE_SAFE_MARGIN_Y
|
|
326
|
+
draw.rectangle(
|
|
327
|
+
(safe_left, safe_top, safe_right, safe_bottom),
|
|
328
|
+
outline="#2f80ed",
|
|
329
|
+
width=2,
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
center_x = left + cell_width // 2
|
|
333
|
+
center_y = height // 2
|
|
334
|
+
draw_dashed_line(
|
|
335
|
+
draw,
|
|
336
|
+
(center_x, safe_top),
|
|
337
|
+
(center_x, safe_bottom),
|
|
338
|
+
fill="#b8b8b8",
|
|
339
|
+
)
|
|
340
|
+
draw_dashed_line(
|
|
341
|
+
draw,
|
|
342
|
+
(safe_left, center_y),
|
|
343
|
+
(safe_right, center_y),
|
|
344
|
+
fill="#b8b8b8",
|
|
345
|
+
)
|
|
346
|
+
|
|
347
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
348
|
+
image.save(path)
|
|
349
|
+
return {
|
|
350
|
+
"state": state,
|
|
351
|
+
"path": str(path),
|
|
352
|
+
"width": width,
|
|
353
|
+
"height": height,
|
|
354
|
+
"frames": frames,
|
|
355
|
+
"cell_width": ATLAS["cell_width"],
|
|
356
|
+
"cell_height": ATLAS["cell_height"],
|
|
357
|
+
"safe_margin_x": LAYOUT_GUIDE_SAFE_MARGIN_X,
|
|
358
|
+
"safe_margin_y": LAYOUT_GUIDE_SAFE_MARGIN_Y,
|
|
359
|
+
"usage": "layout guide input only; do not copy visible guide lines into generated sprite strips",
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
def create_layout_guides(run_dir: Path) -> list[dict[str, object]]:
|
|
364
|
+
guide_dir = run_dir / LAYOUT_GUIDE_DIR
|
|
365
|
+
return [
|
|
366
|
+
create_layout_guide(guide_dir / f"{state}.png", state, frames)
|
|
367
|
+
for state, _row, frames, _purpose in ROWS
|
|
368
|
+
]
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
def parse_hex_color(value: str) -> tuple[int, int, int]:
|
|
372
|
+
if not re.fullmatch(r"#[0-9a-fA-F]{6}", value):
|
|
373
|
+
raise SystemExit(f"invalid chroma key color: {value}; expected #RRGGBB")
|
|
374
|
+
return tuple(int(value[index : index + 2], 16) for index in (1, 3, 5))
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
def rgb_to_hex(rgb: tuple[int, int, int]) -> str:
|
|
378
|
+
return f"#{rgb[0]:02X}{rgb[1]:02X}{rgb[2]:02X}"
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
def color_distance(left: tuple[int, int, int], right: tuple[int, int, int]) -> float:
|
|
382
|
+
return math.sqrt(sum((left[index] - right[index]) ** 2 for index in range(3)))
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
def sampled_reference_pixels(paths: list[Path]) -> list[tuple[int, int, int]]:
|
|
386
|
+
pixels: list[tuple[int, int, int]] = []
|
|
387
|
+
for path in paths:
|
|
388
|
+
with Image.open(path) as opened:
|
|
389
|
+
image = opened.convert("RGBA")
|
|
390
|
+
image.thumbnail((128, 128), Image.Resampling.LANCZOS)
|
|
391
|
+
data = image.tobytes()
|
|
392
|
+
for index in range(0, len(data), 4):
|
|
393
|
+
red, green, blue, alpha = data[index : index + 4]
|
|
394
|
+
if alpha <= 16:
|
|
395
|
+
continue
|
|
396
|
+
pixels.append((red, green, blue))
|
|
397
|
+
|
|
398
|
+
non_background = [
|
|
399
|
+
pixel
|
|
400
|
+
for pixel in pixels
|
|
401
|
+
if not (pixel[0] > 244 and pixel[1] > 244 and pixel[2] > 244)
|
|
402
|
+
]
|
|
403
|
+
return non_background or pixels
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
def choose_chroma_key(reference_paths: list[Path], requested: str) -> dict[str, object]:
|
|
407
|
+
if requested.lower() != "auto":
|
|
408
|
+
rgb = parse_hex_color(requested)
|
|
409
|
+
return {
|
|
410
|
+
"hex": rgb_to_hex(rgb),
|
|
411
|
+
"rgb": list(rgb),
|
|
412
|
+
"name": "user-selected",
|
|
413
|
+
"selection": "manual",
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
pixels = sampled_reference_pixels(reference_paths)
|
|
417
|
+
if not pixels:
|
|
418
|
+
rgb = parse_hex_color("#FF00FF")
|
|
419
|
+
return {
|
|
420
|
+
"hex": "#FF00FF",
|
|
421
|
+
"rgb": list(rgb),
|
|
422
|
+
"name": "magenta",
|
|
423
|
+
"selection": "fallback",
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
scored: list[tuple[float, int, str, tuple[int, int, int]]] = []
|
|
427
|
+
for preference_index, (name, hex_color) in enumerate(CHROMA_KEY_CANDIDATES):
|
|
428
|
+
rgb = parse_hex_color(hex_color)
|
|
429
|
+
distances = sorted(color_distance(rgb, pixel) for pixel in pixels)
|
|
430
|
+
percentile_index = max(0, min(len(distances) - 1, int(len(distances) * 0.01)))
|
|
431
|
+
scored.append((distances[percentile_index], -preference_index, name, rgb))
|
|
432
|
+
|
|
433
|
+
score, _preference, name, rgb = max(scored)
|
|
434
|
+
return {
|
|
435
|
+
"hex": rgb_to_hex(rgb),
|
|
436
|
+
"rgb": list(rgb),
|
|
437
|
+
"name": name,
|
|
438
|
+
"selection": "auto",
|
|
439
|
+
"score": round(score, 2),
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
def write_text(path: Path, text: str) -> None:
|
|
444
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
445
|
+
path.write_text(text.rstrip() + "\n", encoding="utf-8")
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
def resolved_style_contract(style_preset: str, raw_style_notes: str) -> str:
|
|
449
|
+
style_preset = style_preset.strip().lower()
|
|
450
|
+
if style_preset not in STYLE_PRESETS:
|
|
451
|
+
allowed = ", ".join(sorted(STYLE_PRESETS))
|
|
452
|
+
raise SystemExit(
|
|
453
|
+
f"invalid style preset: {style_preset}; expected one of: {allowed}"
|
|
454
|
+
)
|
|
455
|
+
raw_style_notes = raw_style_notes.strip()
|
|
456
|
+
preset_contract = STYLE_PRESETS[style_preset]
|
|
457
|
+
if not raw_style_notes:
|
|
458
|
+
return f"{PET_SAFE_STYLE} Style `{style_preset}`: {preset_contract}"
|
|
459
|
+
return (
|
|
460
|
+
f"{PET_SAFE_STYLE} Style `{style_preset}`: {preset_contract} "
|
|
461
|
+
f"User style notes: {raw_style_notes}."
|
|
462
|
+
)
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
def compact(value: str) -> str:
|
|
466
|
+
return " ".join(value.strip().split())
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
def brand_inspiration_line(args: argparse.Namespace) -> str:
|
|
470
|
+
brand_name = compact(args.brand_name)
|
|
471
|
+
brand_brief = compact(args.brand_brief)
|
|
472
|
+
if not brand_name and not brand_brief:
|
|
473
|
+
return ""
|
|
474
|
+
|
|
475
|
+
prefix = f"{brand_name}: " if brand_name else ""
|
|
476
|
+
if brand_brief:
|
|
477
|
+
return (
|
|
478
|
+
f"{prefix}{brand_brief} Use only broad mascot-safe cues; do not copy "
|
|
479
|
+
"readable logos, marks, UI screenshots, or text."
|
|
480
|
+
)
|
|
481
|
+
return (
|
|
482
|
+
f"{prefix}Use only broad mascot-safe brand cues. Do not copy readable "
|
|
483
|
+
"logos, marks, UI screenshots, or text."
|
|
484
|
+
)
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
def base_pet_prompt(args: argparse.Namespace) -> str:
|
|
488
|
+
pet_notes = args.pet_notes or "the pet shown in the reference image(s)"
|
|
489
|
+
style_contract = resolved_style_contract(args.style_preset, args.style_notes)
|
|
490
|
+
brand_line = brand_inspiration_line(args)
|
|
491
|
+
brand_block = f"\nBrand inspiration: {brand_line}\n" if brand_line else "\n"
|
|
492
|
+
chroma_key = args.chroma_key["hex"]
|
|
493
|
+
chroma_name = args.chroma_key["name"]
|
|
494
|
+
return f"""Create one clean full-body reference sprite for Codex pet {args.display_name}.
|
|
495
|
+
|
|
496
|
+
Pet identity: {pet_notes}.
|
|
497
|
+
Style: {style_contract}
|
|
498
|
+
{brand_block}
|
|
499
|
+
Place a single centered pose on a perfectly flat pure {chroma_name} {chroma_key} chroma-key background. Keep the full pet visible, compact, readable at 192x208, and easy to animate. Preserve approved reference identity cues. No scenery, text, borders, checkerboard transparency, shadows, glows, detached effects, or extra props. Keep {chroma_key} and close colors out of the pet, props, highlights, and effects."""
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
def row_prompt(
|
|
503
|
+
args: argparse.Namespace, state: str, row: int, frames: int, purpose: str
|
|
504
|
+
) -> str:
|
|
505
|
+
pet_notes = args.pet_notes or "the same pet from the approved base reference"
|
|
506
|
+
style_contract = resolved_style_contract(args.style_preset, args.style_notes)
|
|
507
|
+
chroma_key = args.chroma_key["hex"]
|
|
508
|
+
chroma_name = args.chroma_key["name"]
|
|
509
|
+
state_prompt = STATE_PROMPTS[state]
|
|
510
|
+
state_requirements = "\n".join(f"- {line}" for line in STATE_REQUIREMENTS[state])
|
|
511
|
+
return f"""Create one horizontal animation strip for Codex pet `{args.pet_id}`, state `{state}`.
|
|
512
|
+
|
|
513
|
+
Use the attached canonical base for identity. Use the attached layout guide only for slot count, spacing, centering, and padding; do not draw the guide.
|
|
514
|
+
|
|
515
|
+
Output exactly {frames} full-body frames in one left-to-right row on flat pure {chroma_name} {chroma_key}. Treat the row as {frames} invisible equal-width slots: one centered complete pose per slot, evenly spaced, with no overlap, clipping, empty slots, labels, or borders.
|
|
516
|
+
|
|
517
|
+
Identity: same pet in every frame: {pet_notes}. Preserve silhouette, face, proportions, markings, palette, material, style, and props.
|
|
518
|
+
Style: {style_contract}
|
|
519
|
+
Animation continuity: keep apparent pet scale and baseline stable within the row unless the state itself intentionally changes vertical position, such as `jumping`. Move the pose within the slot instead of redrawing the pet larger or smaller frame to frame.
|
|
520
|
+
|
|
521
|
+
State action: {state_prompt}
|
|
522
|
+
|
|
523
|
+
State requirements:
|
|
524
|
+
{state_requirements}
|
|
525
|
+
|
|
526
|
+
Clean extraction: crisp opaque edges, safe padding, no scenery, text, guide marks, checkerboard, shadows, glows, motion blur, speed lines, dust, detached effects, stray pixels, or chroma-key colors inside the pet."""
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
def retry_row_prompt(
|
|
530
|
+
args: argparse.Namespace, state: str, row: int, frames: int, purpose: str
|
|
531
|
+
) -> str:
|
|
532
|
+
pet_notes = args.pet_notes or "the canonical base pet"
|
|
533
|
+
chroma_key = args.chroma_key["hex"]
|
|
534
|
+
chroma_name = args.chroma_key["name"]
|
|
535
|
+
state_prompt = STATE_PROMPTS[state]
|
|
536
|
+
state_requirements = "\n".join(f"- {line}" for line in STATE_REQUIREMENTS[state])
|
|
537
|
+
return f"""Create Codex pet row `{state}` for `{args.pet_id}`: exactly {frames} full-body frames in one horizontal strip on flat pure {chroma_name} {chroma_key}.
|
|
538
|
+
|
|
539
|
+
Use the attached canonical base for identity and the layout guide only for spacing. Same pet in every frame: {pet_notes}. Preserve silhouette, face, palette, material, proportions, markings, and props.
|
|
540
|
+
|
|
541
|
+
Keep apparent pet scale and baseline stable within the row unless the state itself intentionally changes vertical position, such as `jumping`.
|
|
542
|
+
|
|
543
|
+
Action: {state_prompt}
|
|
544
|
+
|
|
545
|
+
State requirements:
|
|
546
|
+
{state_requirements}
|
|
547
|
+
|
|
548
|
+
One centered complete pose per invisible slot. No text, boxes, guide marks, scenery, shadows, glows, motion blur, speed lines, dust, detached effects, stray pixels, or {chroma_key} colors in the pet."""
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
def make_jobs(
|
|
552
|
+
run_dir: Path, copied_refs: list[dict[str, object]]
|
|
553
|
+
) -> list[dict[str, object]]:
|
|
554
|
+
reference_inputs = [
|
|
555
|
+
{"path": rel(Path(str(ref["copied_path"])), run_dir), "role": "pet reference"}
|
|
556
|
+
for ref in copied_refs
|
|
557
|
+
]
|
|
558
|
+
identity_reference_paths = [CANONICAL_BASE_PATH]
|
|
559
|
+
jobs: list[dict[str, object]] = [
|
|
560
|
+
{
|
|
561
|
+
"id": "base",
|
|
562
|
+
"kind": "base-pet",
|
|
563
|
+
"status": "pending",
|
|
564
|
+
"prompt_file": "prompts/base-pet.md",
|
|
565
|
+
"input_images": reference_inputs,
|
|
566
|
+
"output_path": "decoded/base.png",
|
|
567
|
+
"depends_on": [],
|
|
568
|
+
"generation_skill": "$imagegen",
|
|
569
|
+
"requires_grounded_generation": bool(reference_inputs),
|
|
570
|
+
"allow_prompt_only_generation": not reference_inputs,
|
|
571
|
+
}
|
|
572
|
+
]
|
|
573
|
+
for state, _row, frames, _purpose in ROWS:
|
|
574
|
+
depends_on = ["base"]
|
|
575
|
+
extra_inputs: list[dict[str, str]] = []
|
|
576
|
+
derivation_policy: dict[str, object] = {
|
|
577
|
+
"may_derive": False,
|
|
578
|
+
"reason": "state requires its own generated animation semantics",
|
|
579
|
+
}
|
|
580
|
+
if state == "running-left":
|
|
581
|
+
depends_on.append("running-right")
|
|
582
|
+
extra_inputs.append(
|
|
583
|
+
{
|
|
584
|
+
"path": "decoded/running-right.png",
|
|
585
|
+
"role": "rightward gait reference for leftward row decision",
|
|
586
|
+
}
|
|
587
|
+
)
|
|
588
|
+
derivation_policy = {
|
|
589
|
+
"may_derive": True,
|
|
590
|
+
"may_derive_from": "running-right",
|
|
591
|
+
"derivation": "framewise-horizontal-mirror-preserving-order",
|
|
592
|
+
"requires_explicit_approval": True,
|
|
593
|
+
"fallback_generation_skill": "$imagegen",
|
|
594
|
+
}
|
|
595
|
+
elif state not in NON_DERIVABLE_STATES:
|
|
596
|
+
derivation_policy["reason"] = "no deterministic derivation is configured for this state"
|
|
597
|
+
jobs.append(
|
|
598
|
+
{
|
|
599
|
+
"id": state,
|
|
600
|
+
"kind": "row-strip",
|
|
601
|
+
"status": "pending",
|
|
602
|
+
"prompt_file": f"prompts/rows/{state}.md",
|
|
603
|
+
"retry_prompt_file": f"prompts/row-retries/{state}.md",
|
|
604
|
+
"input_images": [
|
|
605
|
+
*reference_inputs,
|
|
606
|
+
{
|
|
607
|
+
"path": f"{LAYOUT_GUIDE_DIR}/{state}.png",
|
|
608
|
+
"role": f"layout guide for {frames} frame slots; use for spacing only, do not copy guide lines",
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
"path": CANONICAL_BASE_PATH,
|
|
612
|
+
"role": "canonical identity reference",
|
|
613
|
+
},
|
|
614
|
+
*extra_inputs,
|
|
615
|
+
],
|
|
616
|
+
"output_path": f"decoded/{state}.png",
|
|
617
|
+
"depends_on": depends_on,
|
|
618
|
+
"generation_skill": "$imagegen",
|
|
619
|
+
"requires_grounded_generation": True,
|
|
620
|
+
"allow_prompt_only_generation": False,
|
|
621
|
+
"identity_reference_paths": identity_reference_paths,
|
|
622
|
+
"parallelizable_after": depends_on,
|
|
623
|
+
"derivation_policy": derivation_policy,
|
|
624
|
+
"mirror_policy": derivation_policy if state == "running-left" else {},
|
|
625
|
+
}
|
|
626
|
+
)
|
|
627
|
+
return jobs
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
def main() -> None:
|
|
631
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
632
|
+
parser.add_argument(
|
|
633
|
+
"--pet-name",
|
|
634
|
+
default="",
|
|
635
|
+
help="User-facing pet name. Ask the user for this when practical; otherwise choose a short appropriate name.",
|
|
636
|
+
)
|
|
637
|
+
parser.add_argument(
|
|
638
|
+
"--pet-id",
|
|
639
|
+
default="",
|
|
640
|
+
help="Stable pet folder/id slug. Defaults to the slugified pet name.",
|
|
641
|
+
)
|
|
642
|
+
parser.add_argument(
|
|
643
|
+
"--display-name",
|
|
644
|
+
default="",
|
|
645
|
+
help="Display label. Defaults to the pet name.",
|
|
646
|
+
)
|
|
647
|
+
parser.add_argument("--description", default="")
|
|
648
|
+
parser.add_argument("--reference", action="append", default=[])
|
|
649
|
+
parser.add_argument("--output-dir", default="")
|
|
650
|
+
parser.add_argument("--pet-notes", default="")
|
|
651
|
+
parser.add_argument(
|
|
652
|
+
"--brand-name",
|
|
653
|
+
default="",
|
|
654
|
+
help="Brand, company, or product name used for broad mascot inspiration.",
|
|
655
|
+
)
|
|
656
|
+
parser.add_argument(
|
|
657
|
+
"--brand-brief",
|
|
658
|
+
default="",
|
|
659
|
+
help="Compact researched brand cue sentence for the base pet only.",
|
|
660
|
+
)
|
|
661
|
+
parser.add_argument(
|
|
662
|
+
"--brand-source",
|
|
663
|
+
action="append",
|
|
664
|
+
default=[],
|
|
665
|
+
help="Source URL used to produce the brand brief. May be passed multiple times.",
|
|
666
|
+
)
|
|
667
|
+
parser.add_argument(
|
|
668
|
+
"--brand-discovery-file",
|
|
669
|
+
default="",
|
|
670
|
+
help="Optional markdown discovery brief to copy into the run for review.",
|
|
671
|
+
)
|
|
672
|
+
parser.add_argument(
|
|
673
|
+
"--style-preset",
|
|
674
|
+
default="auto",
|
|
675
|
+
choices=sorted(STYLE_PRESETS),
|
|
676
|
+
help="Pet-safe style preset to use across the base and all animation rows.",
|
|
677
|
+
)
|
|
678
|
+
parser.add_argument("--style-notes", default="")
|
|
679
|
+
parser.add_argument(
|
|
680
|
+
"--chroma-key",
|
|
681
|
+
default="auto",
|
|
682
|
+
help="Chroma key as #RRGGBB, or auto to choose a safe key from reference colors.",
|
|
683
|
+
)
|
|
684
|
+
parser.add_argument("--force", action="store_true")
|
|
685
|
+
args = parser.parse_args()
|
|
686
|
+
|
|
687
|
+
raw_reference_paths = [
|
|
688
|
+
Path(raw_path).expanduser().resolve() for raw_path in args.reference
|
|
689
|
+
]
|
|
690
|
+
raw_brand_discovery_path = (
|
|
691
|
+
Path(args.brand_discovery_file).expanduser().resolve()
|
|
692
|
+
if args.brand_discovery_file.strip()
|
|
693
|
+
else None
|
|
694
|
+
)
|
|
695
|
+
|
|
696
|
+
args.display_name = infer_name(args, raw_reference_paths)
|
|
697
|
+
args.pet_name = (args.pet_name or args.display_name).strip()
|
|
698
|
+
args.description = infer_description(args, raw_reference_paths)
|
|
699
|
+
args.pet_notes = infer_pet_notes(args, raw_reference_paths)
|
|
700
|
+
args.pet_id = slugify(args.pet_id or args.pet_name or args.display_name)
|
|
701
|
+
args.style_preset = args.style_preset.strip().lower()
|
|
702
|
+
args.style_contract = resolved_style_contract(args.style_preset, args.style_notes)
|
|
703
|
+
args.brand_name = compact(args.brand_name)
|
|
704
|
+
args.brand_brief = compact(args.brand_brief)
|
|
705
|
+
args.brand_source = [
|
|
706
|
+
compact(source) for source in args.brand_source if compact(source)
|
|
707
|
+
]
|
|
708
|
+
if not args.pet_id:
|
|
709
|
+
raise SystemExit("pet id must contain at least one letter or digit")
|
|
710
|
+
|
|
711
|
+
run_dir = (
|
|
712
|
+
Path(args.output_dir).expanduser().resolve()
|
|
713
|
+
if args.output_dir
|
|
714
|
+
else default_output_dir(args.pet_id).resolve()
|
|
715
|
+
)
|
|
716
|
+
if run_dir.exists() and any(run_dir.iterdir()) and not args.force:
|
|
717
|
+
raise SystemExit(
|
|
718
|
+
f"{run_dir} already exists and is not empty; pass --force to reuse it"
|
|
719
|
+
)
|
|
720
|
+
run_dir.mkdir(parents=True, exist_ok=True)
|
|
721
|
+
|
|
722
|
+
ref_dir = run_dir / "references"
|
|
723
|
+
prompt_dir = run_dir / "prompts"
|
|
724
|
+
row_prompt_dir = prompt_dir / "rows"
|
|
725
|
+
row_retry_prompt_dir = prompt_dir / "row-retries"
|
|
726
|
+
for directory in [
|
|
727
|
+
ref_dir,
|
|
728
|
+
prompt_dir,
|
|
729
|
+
row_prompt_dir,
|
|
730
|
+
row_retry_prompt_dir,
|
|
731
|
+
run_dir / "decoded",
|
|
732
|
+
run_dir / "qa",
|
|
733
|
+
]:
|
|
734
|
+
directory.mkdir(parents=True, exist_ok=True)
|
|
735
|
+
|
|
736
|
+
copied_refs: list[dict[str, object]] = []
|
|
737
|
+
copied_ref_paths: list[Path] = []
|
|
738
|
+
for index, source in enumerate(raw_reference_paths, start=1):
|
|
739
|
+
if not source.is_file():
|
|
740
|
+
raise SystemExit(f"reference not found: {source}")
|
|
741
|
+
suffix = source.suffix.lower() or ".png"
|
|
742
|
+
copied = ref_dir / f"reference-{index:02d}{suffix}"
|
|
743
|
+
shutil.copy2(source, copied)
|
|
744
|
+
meta = image_metadata(copied)
|
|
745
|
+
meta["source_path"] = str(source)
|
|
746
|
+
meta["copied_path"] = str(copied)
|
|
747
|
+
copied_refs.append(meta)
|
|
748
|
+
copied_ref_paths.append(copied)
|
|
749
|
+
|
|
750
|
+
brand_discovery_path = ""
|
|
751
|
+
if raw_brand_discovery_path is not None:
|
|
752
|
+
if not raw_brand_discovery_path.is_file():
|
|
753
|
+
raise SystemExit(f"brand discovery file not found: {raw_brand_discovery_path}")
|
|
754
|
+
copied_discovery = run_dir / BRAND_DISCOVERY_PATH
|
|
755
|
+
shutil.copy2(raw_brand_discovery_path, copied_discovery)
|
|
756
|
+
brand_discovery_path = rel(copied_discovery, run_dir)
|
|
757
|
+
|
|
758
|
+
args.chroma_key = choose_chroma_key(copied_ref_paths, args.chroma_key)
|
|
759
|
+
layout_guides = create_layout_guides(run_dir)
|
|
760
|
+
|
|
761
|
+
request = {
|
|
762
|
+
"pet_id": args.pet_id,
|
|
763
|
+
"display_name": args.display_name,
|
|
764
|
+
"description": args.description,
|
|
765
|
+
"created_at": datetime.now(timezone.utc).isoformat(),
|
|
766
|
+
"atlas": ATLAS,
|
|
767
|
+
"rows": [
|
|
768
|
+
{"state": state, "row": row, "frames": frames, "purpose": purpose}
|
|
769
|
+
for state, row, frames, purpose in ROWS
|
|
770
|
+
],
|
|
771
|
+
"layout_guides": [
|
|
772
|
+
{**guide, "path": rel(Path(str(guide["path"])), run_dir)}
|
|
773
|
+
for guide in layout_guides
|
|
774
|
+
],
|
|
775
|
+
"references": copied_refs,
|
|
776
|
+
"chroma_key": args.chroma_key,
|
|
777
|
+
"pet_notes": args.pet_notes,
|
|
778
|
+
"style_preset": args.style_preset,
|
|
779
|
+
"style_notes": args.style_notes,
|
|
780
|
+
"style_contract": args.style_contract,
|
|
781
|
+
"brand_name": args.brand_name,
|
|
782
|
+
"brand_brief": args.brand_brief,
|
|
783
|
+
"brand_sources": args.brand_source,
|
|
784
|
+
"pet_safe_style": PET_SAFE_STYLE,
|
|
785
|
+
"primary_generation_skill": "$imagegen",
|
|
786
|
+
}
|
|
787
|
+
if brand_discovery_path:
|
|
788
|
+
request["brand_discovery_path"] = brand_discovery_path
|
|
789
|
+
(run_dir / "pet_request.json").write_text(
|
|
790
|
+
json.dumps(request, indent=2) + "\n", encoding="utf-8"
|
|
791
|
+
)
|
|
792
|
+
|
|
793
|
+
write_text(prompt_dir / "base-pet.md", base_pet_prompt(args))
|
|
794
|
+
for state, row, frames, purpose in ROWS:
|
|
795
|
+
write_text(
|
|
796
|
+
row_prompt_dir / f"{state}.md",
|
|
797
|
+
row_prompt(args, state, row, frames, purpose),
|
|
798
|
+
)
|
|
799
|
+
write_text(
|
|
800
|
+
row_retry_prompt_dir / f"{state}.md",
|
|
801
|
+
retry_row_prompt(args, state, row, frames, purpose),
|
|
802
|
+
)
|
|
803
|
+
|
|
804
|
+
jobs = {
|
|
805
|
+
"schema_version": 1,
|
|
806
|
+
"created_at": datetime.now(timezone.utc).isoformat(),
|
|
807
|
+
"run_dir": str(run_dir),
|
|
808
|
+
"primary_generation_skill": "$imagegen",
|
|
809
|
+
"jobs": make_jobs(run_dir, copied_refs),
|
|
810
|
+
}
|
|
811
|
+
(run_dir / "imagegen-jobs.json").write_text(
|
|
812
|
+
json.dumps(jobs, indent=2) + "\n", encoding="utf-8"
|
|
813
|
+
)
|
|
814
|
+
|
|
815
|
+
print(
|
|
816
|
+
json.dumps(
|
|
817
|
+
{
|
|
818
|
+
"ok": True,
|
|
819
|
+
"run_dir": str(run_dir),
|
|
820
|
+
"request": str(run_dir / "pet_request.json"),
|
|
821
|
+
"jobs": str(run_dir / "imagegen-jobs.json"),
|
|
822
|
+
"ready_jobs": ["base"],
|
|
823
|
+
},
|
|
824
|
+
indent=2,
|
|
825
|
+
)
|
|
826
|
+
)
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
if __name__ == "__main__":
|
|
830
|
+
main()
|