.
This commit is contained in:
1 parent
77a5f5248c
commit
f0bba7e7b9
68 files changed
+5149
-142
No files matched your search
@@ -0,0 +1,146 @@
|
||||
---
|
||||
name: ss-studio
|
||||
description: Turn a product brief and optional references into three distinct creative directions, a human-selected StyleSeed interaction plan, generated image/video asset jobs, a working UI prototype, and a verified prototype-first showcase reel. Use for client concepts, app interaction exploration, trendy but coherent UI direction, reference discovery and synthesis, or any request that needs more than one static screen.
|
||||
---
|
||||
|
||||
# Build a directed interactive concept
|
||||
|
||||
Run the full Studio pipeline. Do not reduce it to a moodboard, a static image, or a set of arbitrary
|
||||
motion effects.
|
||||
|
||||
## Start the run
|
||||
|
||||
Read `STUDIO-PIPELINE.md`, `PRODUCT-PRINCIPLES.md`, and the resolved project rules first. If the
|
||||
project has no valid `STYLESEED.md`, run setup and resolve before Studio.
|
||||
|
||||
Initialize a durable run:
|
||||
|
||||
```bash
|
||||
node <skill-dir>/scripts/studio-run.mjs init \
|
||||
--project-root . \
|
||||
--name "<project or concept>" \
|
||||
--brief "<product job and desired interaction>" \
|
||||
--surface mobile-app \
|
||||
--platform web
|
||||
```
|
||||
|
||||
The command prints the run directory under `.styleseed/studio/`. Use the artifact schemas in
|
||||
`references/artifact-contract.md`. Use `references/provider-adapters.md` only when media generation
|
||||
or recording is required.
|
||||
|
||||
## 1. Scout by role
|
||||
|
||||
Classify supplied and discovered references as `structure`, `navigation`, `signature`, `motion`, or
|
||||
`asset-language`. Capture source URL/path, date, visible observation, transferable principle,
|
||||
confidence, and rights note. Never claim visual evidence for a reference that was not actually seen.
|
||||
|
||||
Do not ask the user to collect a generic moodboard. Find only the missing roles. Keep product UI,
|
||||
marketing presentation, and generated media separate unless the brief explicitly connects them.
|
||||
|
||||
## 2. Produce three directions
|
||||
|
||||
Write exactly three entries in `directions.json`: `native`, `signature`, and `experimental`. Keep
|
||||
the product job and content fixed; vary at least two structural axes. Every direction must include:
|
||||
|
||||
- composition and focal logic;
|
||||
- navigation chrome versus content canvas;
|
||||
- one semantic palette recipe, type, and material roles;
|
||||
- generated asset strategy;
|
||||
- motion and continuity logic;
|
||||
- one product-specific signature move;
|
||||
- output grammar, brand recipe, trade-offs, implementation cost, and risk.
|
||||
|
||||
Advance only after the directions validate:
|
||||
|
||||
```bash
|
||||
node <skill-dir>/scripts/studio-run.mjs advance --project-root . --run <id> --stage directed
|
||||
```
|
||||
|
||||
## 3. Require a selection
|
||||
|
||||
Show the three directions together. Record the user's selection and rationale. Do not average them
|
||||
or quietly choose the easiest one.
|
||||
|
||||
```bash
|
||||
node <skill-dir>/scripts/studio-run.mjs select \
|
||||
--project-root . --run <id> --direction <direction-id> \
|
||||
--by "<reviewer>" --rationale "<decision>"
|
||||
```
|
||||
|
||||
## 4. Compile scenes and media jobs
|
||||
|
||||
Write `scenes.json`, `assets.json`, and `video.json` from the selected direction.
|
||||
|
||||
- An interaction scene defines trigger, states, continuity, enter/exit, feedback, interruption,
|
||||
reduced-motion behavior, and renderer targets.
|
||||
- An asset job defines capability, prompt, inputs, output, provenance, rights note, fallback, and
|
||||
consuming scene.
|
||||
- A video plan starts with real prototype recordings. Mark generative shots explicitly; never use
|
||||
them to fake an interaction that does not work.
|
||||
|
||||
Map capability to an available provider only at execution time. If the needed provider is absent,
|
||||
leave the job `blocked` and report the exact missing capability.
|
||||
|
||||
Record provider execution without hand-editing the run:
|
||||
|
||||
```bash
|
||||
node <skill-dir>/scripts/studio-run.mjs media \
|
||||
--project-root . --run <id> --job <job-id> --status complete \
|
||||
--provider <tool/model> --output <project-relative-path> \
|
||||
--provenance "<model · date · source inputs>"
|
||||
```
|
||||
|
||||
## 5. Generate, build, and record
|
||||
|
||||
Generate raster assets only for imagery, texture, illustration, footage, or product material. Keep
|
||||
UI geometry, icons, and final copy code-native and accessible. Copy final generated files into the
|
||||
run directory and preserve prompts and provenance.
|
||||
|
||||
Build the selected direction as a working prototype. Implement its primary navigation, signature
|
||||
scene, cancel/back behavior, and reduced-motion fallback. Record the actual prototype after it
|
||||
passes the code and pixel gates. Optional generated footage may be composited as labeled media.
|
||||
|
||||
Store prototype and recording paths through the CLI, then advance to `built`:
|
||||
|
||||
```bash
|
||||
node <skill-dir>/scripts/studio-run.mjs output \
|
||||
--project-root . --run <id> --prototype <route-or-path>
|
||||
node <skill-dir>/scripts/studio-run.mjs advance \
|
||||
--project-root . --run <id> --stage built
|
||||
node <skill-dir>/scripts/studio-run.mjs output \
|
||||
--project-root . --run <id> --recording <project-relative-path>
|
||||
```
|
||||
|
||||
## 6. Verify and deliver
|
||||
|
||||
Run StyleSeed score and visual verification, then inspect temporal evidence: start/mid/end frames,
|
||||
interrupt/cancel behavior, and reduced motion. Record `code`, `visual`, `temporal`, and `human` gate
|
||||
statuses plus evidence paths in `verification.json`.
|
||||
|
||||
Record each gate explicitly. A human pass requires a named reviewer:
|
||||
|
||||
```bash
|
||||
node <skill-dir>/scripts/studio-run.mjs gate \
|
||||
--project-root . --run <id> --gate temporal --status pass \
|
||||
--evidence <path> --note "start, mid, end, cancel, and reduced motion inspected"
|
||||
node <skill-dir>/scripts/studio-run.mjs gate \
|
||||
--project-root . --run <id> --gate human --status pass \
|
||||
--reviewer "<name>" --evidence <path> --note "selected result accepted"
|
||||
```
|
||||
|
||||
```bash
|
||||
node <skill-dir>/scripts/studio-run.mjs advance --project-root . --run <id> --stage verified
|
||||
node <skill-dir>/scripts/studio-run.mjs status --project-root . --run <id>
|
||||
```
|
||||
|
||||
Deliver the complete run folder, runnable prototype, actual recording, and unresolved risks. A
|
||||
polished reel by itself is not a completed Studio run.
|
||||
|
||||
## Non-negotiables
|
||||
|
||||
- Keep exactly one selected design direction and one coherent product language.
|
||||
- Human selection precedes expensive generation and implementation.
|
||||
- Do not clone protected brand assets, copy, or trademarked arrangements.
|
||||
- Do not fabricate reference observations, provider outputs, file paths, or verification passes.
|
||||
- Do not let generated imagery carry essential UI text or interaction semantics.
|
||||
- Do not mark a run verified without seeing the pixels and the temporal result.
|
||||
@@ -0,0 +1,4 @@
|
||||
interface:
|
||||
display_name: "StyleSeed Studio"
|
||||
short_description: "Turn briefs into directed UI prototypes and motion reels"
|
||||
default_prompt: "Use $ss-studio to turn this product brief into three creative directions with semantic palette recommendations, a human-selected interactive prototype, generated image/video jobs, and a verified prototype-first showcase reel."
|
||||
@@ -0,0 +1,135 @@
|
||||
# Studio artifact contract
|
||||
|
||||
Use these fields exactly. Extra task-specific fields are allowed, but required fields may not be
|
||||
renamed.
|
||||
|
||||
## `references.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"items": [{
|
||||
"id": "R1",
|
||||
"role": "structure | navigation | signature | motion | asset-language",
|
||||
"source": "URL or path",
|
||||
"observedAt": "ISO-8601",
|
||||
"observation": "visible fact",
|
||||
"principle": "transferable decision",
|
||||
"confidence": "high | medium | low",
|
||||
"rights": "usage/provenance note"
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
## `directions.json`
|
||||
|
||||
`directions` contains exactly one `native`, one `signature`, and one `experimental` direction.
|
||||
|
||||
```json
|
||||
{
|
||||
"directions": [{
|
||||
"id": "signature",
|
||||
"lane": "signature",
|
||||
"name": "user-facing name",
|
||||
"promise": "one-sentence product experience",
|
||||
"grammar": "built-in or reference grammar id",
|
||||
"recipe": "brand recipe id",
|
||||
"palette": "palette recipe id",
|
||||
"composition": "focal and spatial logic",
|
||||
"navigationChrome": "chrome/canvas relationship and states",
|
||||
"typeAndMaterial": "type, color, surface, and image material",
|
||||
"assetDirection": "what media is generated and why",
|
||||
"motionDirection": "continuity and feedback logic",
|
||||
"signatureMove": "one product-owned interaction",
|
||||
"tradeoffs": ["..."],
|
||||
"cost": "low | medium | high",
|
||||
"risk": "low | medium | high"
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
## `selection.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"selectedDirectionId": "signature",
|
||||
"decisionBy": "reviewer name",
|
||||
"decidedAt": "ISO-8601",
|
||||
"rationale": "why this direction fits the job"
|
||||
}
|
||||
```
|
||||
|
||||
## `scenes.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"scenes": [{
|
||||
"id": "open-focus",
|
||||
"trigger": "tap focus card",
|
||||
"from": "home-rest",
|
||||
"to": "focus-detail",
|
||||
"continuity": ["selected card", "title"],
|
||||
"enter": ["detail controls"],
|
||||
"exit": ["secondary feed"],
|
||||
"feedback": "selected card lifts into the content plane",
|
||||
"interrupt": "back or reverse gesture restores the source card",
|
||||
"reducedMotion": "instant state swap plus focus movement",
|
||||
"rendererTargets": ["web"]
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
## `assets.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"jobs": [{
|
||||
"id": "A1",
|
||||
"role": "ambient hero texture",
|
||||
"kind": "raster | vector | video | audio",
|
||||
"capability": "raster-generate",
|
||||
"provider": "provider/tool id or unassigned",
|
||||
"prompt": "complete reproducible prompt",
|
||||
"inputs": [],
|
||||
"output": "relative path or null",
|
||||
"status": "planned | running | complete | blocked | rejected",
|
||||
"provenance": "model/tool/date or pending",
|
||||
"rights": "client usage and source note",
|
||||
"fallback": "code-native or alternate media treatment",
|
||||
"consumingScene": "scene id"
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
## `video.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"mode": "prototype-first",
|
||||
"shots": [{
|
||||
"id": "V1",
|
||||
"sourceType": "prototype-recording | generated-media",
|
||||
"scene": "scene id",
|
||||
"durationMs": 2400,
|
||||
"source": "relative path or null",
|
||||
"status": "planned | complete | blocked",
|
||||
"notes": "camera, crop, caption, or compositing instruction"
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
## `verification.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"gates": {
|
||||
"code": "pending | pass | fail | blocked",
|
||||
"visual": "pending | pass | fail | blocked",
|
||||
"temporal": "pending | pass | fail | blocked",
|
||||
"human": "pending | pass | fail | blocked"
|
||||
},
|
||||
"evidence": [{"gate": "visual", "path": "relative path", "note": "what it proves"}],
|
||||
"reviewer": "name or null",
|
||||
"acceptedAt": "ISO-8601 or null",
|
||||
"risks": []
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,48 @@
|
||||
# Media and recording provider adapters
|
||||
|
||||
Select an adapter by capability. Tool names can change; the run contract must remain stable.
|
||||
|
||||
## Raster generation
|
||||
|
||||
Use for photography, illustration, texture, scene material, or image compositing. Do not render
|
||||
final interface typography or accessible controls into the bitmap.
|
||||
|
||||
Required evidence:
|
||||
|
||||
- complete prompt and all reference-image roles;
|
||||
- provider/model identifier and generation date;
|
||||
- input and output paths copied into the run;
|
||||
- review status and usage-rights note;
|
||||
- a code-native fallback when the asset is nonessential.
|
||||
|
||||
## Video generation
|
||||
|
||||
Use for ambient footage, product-world imagery, texture motion, or an explicitly narrative asset.
|
||||
Do not substitute a generated clip for a real clickable UI state transition.
|
||||
|
||||
Required evidence:
|
||||
|
||||
- prompt, input still/video, duration, aspect ratio, and intended consuming shot;
|
||||
- provider/model identifier;
|
||||
- output copied into the run and labeled `generated-media`;
|
||||
- temporal review for warping, unreadable text, accidental UI, and loop seams.
|
||||
|
||||
## Prototype recording
|
||||
|
||||
Record the real app or browser prototype at its locked viewport. Capture each signature scene from
|
||||
a stable start state and include interruption/back behavior. Store the raw recording before any
|
||||
showcase edit.
|
||||
|
||||
Required evidence:
|
||||
|
||||
- route/build identifier and viewport;
|
||||
- interaction script and input method;
|
||||
- raw recording path;
|
||||
- extracted start/mid/end frames;
|
||||
- reduced-motion capture when the scene materially changes.
|
||||
|
||||
## Reel composition
|
||||
|
||||
Compose only after the prototype passes. The shot manifest remains authoritative. A reel can mix
|
||||
prototype recordings and generated media, but every shot must retain its `sourceType`. Do not apply
|
||||
editing that makes the product appear to support an interaction it does not support.
|
||||
@@ -0,0 +1,356 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
const STAGES = ["briefed", "directed", "selected", "planned", "built", "verified"];
|
||||
const ROLES = new Set(["structure", "navigation", "signature", "motion", "asset-language"]);
|
||||
const LANES = new Set(["native", "signature", "experimental"]);
|
||||
const GATES = ["code", "visual", "temporal", "human"];
|
||||
const GATE_STATUSES = new Set(["pending", "pass", "fail", "blocked"]);
|
||||
const MEDIA_STATUSES = new Set(["planned", "running", "complete", "blocked", "rejected"]);
|
||||
|
||||
function fail(message, code = 1) {
|
||||
console.error(`Studio run error: ${message}`);
|
||||
process.exit(code);
|
||||
}
|
||||
|
||||
function parseArgs(argv) {
|
||||
const [command, ...rest] = argv;
|
||||
const options = {};
|
||||
for (let i = 0; i < rest.length; i += 1) {
|
||||
const token = rest[i];
|
||||
if (!token.startsWith("--")) fail(`unexpected argument ${token}`);
|
||||
const key = token.slice(2);
|
||||
const value = rest[i + 1];
|
||||
if (!value || value.startsWith("--")) fail(`missing value for --${key}`);
|
||||
options[key] = value;
|
||||
i += 1;
|
||||
}
|
||||
return { command, options };
|
||||
}
|
||||
|
||||
function slugify(value) {
|
||||
return value
|
||||
.normalize("NFKD")
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9]+/g, "-")
|
||||
.replace(/^-+|-+$/g, "")
|
||||
.slice(0, 48) || "studio-run";
|
||||
}
|
||||
|
||||
function now() {
|
||||
return new Date().toISOString();
|
||||
}
|
||||
|
||||
function readJson(path) {
|
||||
try {
|
||||
return JSON.parse(readFileSync(path, "utf8"));
|
||||
} catch (error) {
|
||||
fail(`cannot read ${path}: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
function writeJson(path, value) {
|
||||
writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`);
|
||||
}
|
||||
|
||||
function projectRoot(options) {
|
||||
return resolve(options["project-root"] || process.cwd());
|
||||
}
|
||||
|
||||
function runDir(options) {
|
||||
const id = options.run;
|
||||
if (!id) fail("--run is required");
|
||||
return resolve(projectRoot(options), ".styleseed", "studio", id);
|
||||
}
|
||||
|
||||
function requireRun(options) {
|
||||
const dir = runDir(options);
|
||||
const path = resolve(dir, "run.json");
|
||||
if (!existsSync(path)) fail(`run not found: ${dir}`);
|
||||
return { dir, path, run: readJson(path) };
|
||||
}
|
||||
|
||||
function requiredString(value, label, failures) {
|
||||
if (typeof value !== "string" || !value.trim()) failures.push(`${label} is required`);
|
||||
}
|
||||
|
||||
function validateDirection(direction, index, failures) {
|
||||
const prefix = `directions[${index}]`;
|
||||
for (const key of [
|
||||
"id", "lane", "name", "promise", "grammar", "recipe", "palette", "composition",
|
||||
"navigationChrome", "typeAndMaterial", "assetDirection", "motionDirection", "signatureMove",
|
||||
"cost", "risk",
|
||||
]) requiredString(direction?.[key], `${prefix}.${key}`, failures);
|
||||
if (!LANES.has(direction?.lane)) failures.push(`${prefix}.lane is invalid`);
|
||||
if (!Array.isArray(direction?.tradeoffs) || direction.tradeoffs.length === 0) {
|
||||
failures.push(`${prefix}.tradeoffs must contain at least one item`);
|
||||
}
|
||||
}
|
||||
|
||||
function validateTarget(dir, run, target) {
|
||||
const failures = [];
|
||||
if (!STAGES.includes(target)) failures.push(`unknown target stage ${target}`);
|
||||
const briefPath = resolve(dir, "brief.md");
|
||||
if (!existsSync(briefPath) || readFileSync(briefPath, "utf8").trim().length < 40) {
|
||||
failures.push("brief.md must contain a concrete product brief");
|
||||
}
|
||||
|
||||
if (STAGES.indexOf(target) >= STAGES.indexOf("directed")) {
|
||||
const references = readJson(resolve(dir, "references.json"));
|
||||
if (!Array.isArray(references.items)) failures.push("references.json items must be an array");
|
||||
else references.items.forEach((item, index) => {
|
||||
requiredString(item.id, `references[${index}].id`, failures);
|
||||
if (!ROLES.has(item.role)) failures.push(`references[${index}].role is invalid`);
|
||||
for (const key of ["source", "observedAt", "observation", "principle", "confidence", "rights"])
|
||||
requiredString(item[key], `references[${index}].${key}`, failures);
|
||||
});
|
||||
|
||||
const directions = readJson(resolve(dir, "directions.json"));
|
||||
if (!Array.isArray(directions.directions) || directions.directions.length !== 3) {
|
||||
failures.push("directions.json must contain exactly three directions");
|
||||
} else {
|
||||
directions.directions.forEach((direction, index) => validateDirection(direction, index, failures));
|
||||
const lanes = new Set(directions.directions.map((direction) => direction.lane));
|
||||
for (const lane of LANES) if (!lanes.has(lane)) failures.push(`missing ${lane} direction`);
|
||||
const ids = new Set(directions.directions.map((direction) => direction.id));
|
||||
if (ids.size !== 3) failures.push("direction ids must be unique");
|
||||
}
|
||||
}
|
||||
|
||||
if (STAGES.indexOf(target) >= STAGES.indexOf("selected")) {
|
||||
const selection = readJson(resolve(dir, "selection.json"));
|
||||
const directions = readJson(resolve(dir, "directions.json")).directions || [];
|
||||
requiredString(selection.selectedDirectionId, "selection.selectedDirectionId", failures);
|
||||
requiredString(selection.decisionBy, "selection.decisionBy", failures);
|
||||
requiredString(selection.decidedAt, "selection.decidedAt", failures);
|
||||
requiredString(selection.rationale, "selection.rationale", failures);
|
||||
if (!directions.some((direction) => direction.id === selection.selectedDirectionId)) {
|
||||
failures.push("selection does not match a direction id");
|
||||
}
|
||||
}
|
||||
|
||||
if (STAGES.indexOf(target) >= STAGES.indexOf("planned")) {
|
||||
const scenes = readJson(resolve(dir, "scenes.json"));
|
||||
if (!Array.isArray(scenes.scenes) || scenes.scenes.length === 0) failures.push("at least one interaction scene is required");
|
||||
else scenes.scenes.forEach((scene, index) => {
|
||||
for (const key of ["id", "trigger", "from", "to", "feedback", "interrupt", "reducedMotion"])
|
||||
requiredString(scene[key], `scenes[${index}].${key}`, failures);
|
||||
for (const key of ["continuity", "enter", "exit", "rendererTargets"])
|
||||
if (!Array.isArray(scene[key])) failures.push(`scenes[${index}].${key} must be an array`);
|
||||
});
|
||||
|
||||
const assets = readJson(resolve(dir, "assets.json"));
|
||||
if (!Array.isArray(assets.jobs)) failures.push("assets.json jobs must be an array");
|
||||
else assets.jobs.forEach((job, index) => {
|
||||
for (const key of ["id", "role", "kind", "capability", "provider", "prompt", "status", "provenance", "rights", "fallback", "consumingScene"])
|
||||
requiredString(job[key], `assets[${index}].${key}`, failures);
|
||||
if (!Array.isArray(job.inputs)) failures.push(`assets[${index}].inputs must be an array`);
|
||||
if (!MEDIA_STATUSES.has(job.status)) failures.push(`assets[${index}].status is invalid`);
|
||||
if (job.status === "complete") requiredString(job.output, `assets[${index}].output`, failures);
|
||||
});
|
||||
|
||||
const video = readJson(resolve(dir, "video.json"));
|
||||
if (video.mode !== "prototype-first") failures.push("video.mode must be prototype-first");
|
||||
if (!Array.isArray(video.shots) || !video.shots.some((shot) => shot.sourceType === "prototype-recording")) {
|
||||
failures.push("video plan must contain at least one prototype-recording shot");
|
||||
}
|
||||
}
|
||||
|
||||
if (STAGES.indexOf(target) >= STAGES.indexOf("built")) {
|
||||
requiredString(run.outputs?.prototype, "run.outputs.prototype", failures);
|
||||
}
|
||||
|
||||
if (STAGES.indexOf(target) >= STAGES.indexOf("verified")) {
|
||||
requiredString(run.outputs?.recording, "run.outputs.recording", failures);
|
||||
const verification = readJson(resolve(dir, "verification.json"));
|
||||
for (const gate of GATES) {
|
||||
if (verification.gates?.[gate] !== "pass") failures.push(`verification gate ${gate} must pass`);
|
||||
}
|
||||
if (!Array.isArray(verification.evidence) || verification.evidence.length < 4) {
|
||||
failures.push("verification needs evidence for all four gates");
|
||||
}
|
||||
requiredString(verification.reviewer, "verification.reviewer", failures);
|
||||
requiredString(verification.acceptedAt, "verification.acceptedAt", failures);
|
||||
}
|
||||
|
||||
return failures;
|
||||
}
|
||||
|
||||
function init(options) {
|
||||
for (const key of ["name", "brief", "surface", "platform"]) if (!options[key]) fail(`--${key} is required`);
|
||||
const root = projectRoot(options);
|
||||
const baseId = slugify(options.name);
|
||||
let id = baseId;
|
||||
let suffix = 2;
|
||||
while (existsSync(resolve(root, ".styleseed", "studio", id))) id = `${baseId}-${suffix++}`;
|
||||
const dir = resolve(root, ".styleseed", "studio", id);
|
||||
mkdirSync(resolve(dir, "assets", "generated"), { recursive: true });
|
||||
mkdirSync(resolve(dir, "evidence", "frames"), { recursive: true });
|
||||
mkdirSync(resolve(dir, "evidence", "recordings"), { recursive: true });
|
||||
const createdAt = now();
|
||||
writeJson(resolve(dir, "run.json"), {
|
||||
schemaVersion: 1,
|
||||
id,
|
||||
title: options.name,
|
||||
createdAt,
|
||||
updatedAt: createdAt,
|
||||
stage: "briefed",
|
||||
surface: options.surface,
|
||||
platform: options.platform,
|
||||
outputs: { prototype: null, recording: null },
|
||||
});
|
||||
writeFileSync(resolve(dir, "brief.md"), `# ${options.name}\n\n${options.brief.trim()}\n`);
|
||||
writeJson(resolve(dir, "references.json"), { items: [] });
|
||||
writeJson(resolve(dir, "directions.json"), { directions: [] });
|
||||
writeJson(resolve(dir, "selection.json"), { selectedDirectionId: null, decisionBy: null, decidedAt: null, rationale: null });
|
||||
writeJson(resolve(dir, "scenes.json"), { scenes: [] });
|
||||
writeJson(resolve(dir, "assets.json"), { jobs: [] });
|
||||
writeJson(resolve(dir, "video.json"), { mode: "prototype-first", shots: [] });
|
||||
writeJson(resolve(dir, "verification.json"), {
|
||||
gates: Object.fromEntries(GATES.map((gate) => [gate, "pending"])),
|
||||
evidence: [], reviewer: null, acceptedAt: null, risks: [],
|
||||
});
|
||||
console.log(dir);
|
||||
}
|
||||
|
||||
function select(options) {
|
||||
const { dir, path, run } = requireRun(options);
|
||||
for (const key of ["direction", "by", "rationale"]) if (!options[key]) fail(`--${key} is required`);
|
||||
const directedFailures = validateTarget(dir, run, "directed");
|
||||
if (directedFailures.length) fail(`cannot select before directions pass:\n- ${directedFailures.join("\n- ")}`);
|
||||
const directions = readJson(resolve(dir, "directions.json")).directions;
|
||||
if (!directions.some((direction) => direction.id === options.direction)) fail(`unknown direction ${options.direction}`);
|
||||
writeJson(resolve(dir, "selection.json"), {
|
||||
selectedDirectionId: options.direction,
|
||||
decisionBy: options.by,
|
||||
decidedAt: now(),
|
||||
rationale: options.rationale,
|
||||
});
|
||||
run.stage = "selected";
|
||||
run.updatedAt = now();
|
||||
writeJson(path, run);
|
||||
console.log(`${run.id}: selected ${options.direction}`);
|
||||
}
|
||||
|
||||
function output(options) {
|
||||
const { path, run } = requireRun(options);
|
||||
if (!options.prototype && !options.recording) fail("pass --prototype and/or --recording");
|
||||
if (options.prototype) run.outputs.prototype = options.prototype;
|
||||
if (options.recording) run.outputs.recording = options.recording;
|
||||
run.updatedAt = now();
|
||||
writeJson(path, run);
|
||||
console.log(`${run.id}: outputs updated`);
|
||||
}
|
||||
|
||||
function media(options) {
|
||||
const { dir, path, run } = requireRun(options);
|
||||
for (const key of ["job", "status"]) if (!options[key]) fail(`--${key} is required`);
|
||||
if (!MEDIA_STATUSES.has(options.status)) {
|
||||
fail(`--status must be one of ${[...MEDIA_STATUSES].join(", ")}`);
|
||||
}
|
||||
const assetsPath = resolve(dir, "assets.json");
|
||||
const assets = readJson(assetsPath);
|
||||
const job = assets.jobs?.find((item) => item.id === options.job);
|
||||
if (!job) fail(`media job not found: ${options.job}`);
|
||||
if (options.status === "complete") {
|
||||
for (const key of ["provider", "output", "provenance"]) {
|
||||
if (!options[key] && !job[key]) fail(`complete media job requires --${key}`);
|
||||
}
|
||||
}
|
||||
job.status = options.status;
|
||||
if (options.provider) job.provider = options.provider;
|
||||
if (options.output) job.output = options.output;
|
||||
if (options.provenance) job.provenance = options.provenance;
|
||||
job.updatedAt = now();
|
||||
writeJson(assetsPath, assets);
|
||||
run.updatedAt = now();
|
||||
writeJson(path, run);
|
||||
console.log(`${run.id}: media ${job.id} -> ${job.status}`);
|
||||
}
|
||||
|
||||
function gate(options) {
|
||||
const { dir, path, run } = requireRun(options);
|
||||
for (const key of ["gate", "status"]) if (!options[key]) fail(`--${key} is required`);
|
||||
if (!GATES.includes(options.gate)) fail(`--gate must be one of ${GATES.join(", ")}`);
|
||||
if (!GATE_STATUSES.has(options.status)) {
|
||||
fail(`--status must be one of ${[...GATE_STATUSES].join(", ")}`);
|
||||
}
|
||||
if (options.gate === "human" && options.status === "pass" && !options.reviewer) {
|
||||
fail("human pass requires --reviewer");
|
||||
}
|
||||
const verificationPath = resolve(dir, "verification.json");
|
||||
const verification = readJson(verificationPath);
|
||||
verification.gates[options.gate] = options.status;
|
||||
if (options.evidence) {
|
||||
verification.evidence.push({
|
||||
gate: options.gate,
|
||||
path: options.evidence,
|
||||
note: options.note || `${options.gate} ${options.status}`,
|
||||
recordedAt: now(),
|
||||
});
|
||||
}
|
||||
if (options.reviewer) verification.reviewer = options.reviewer;
|
||||
if (options.gate === "human" && options.status === "pass") verification.acceptedAt = now();
|
||||
writeJson(verificationPath, verification);
|
||||
run.updatedAt = now();
|
||||
writeJson(path, run);
|
||||
console.log(`${run.id}: gate ${options.gate} -> ${options.status}`);
|
||||
}
|
||||
|
||||
function advance(options) {
|
||||
const { dir, path, run } = requireRun(options);
|
||||
const target = options.stage;
|
||||
if (!STAGES.includes(target)) fail(`--stage must be one of ${STAGES.join(", ")}`);
|
||||
const currentIndex = STAGES.indexOf(run.stage);
|
||||
const targetIndex = STAGES.indexOf(target);
|
||||
if (targetIndex !== currentIndex + 1) fail(`advance must be sequential: ${run.stage} -> ${STAGES[currentIndex + 1] || "complete"}`);
|
||||
if (target === "selected") fail("use the select command for the human selection gate");
|
||||
const failures = validateTarget(dir, run, target);
|
||||
if (failures.length) fail(`cannot advance to ${target}:\n- ${failures.join("\n- ")}`);
|
||||
run.stage = target;
|
||||
run.updatedAt = now();
|
||||
writeJson(path, run);
|
||||
console.log(`${run.id}: ${target}`);
|
||||
}
|
||||
|
||||
function validate(options) {
|
||||
const { dir, run } = requireRun(options);
|
||||
const target = options.target || run.stage;
|
||||
const failures = validateTarget(dir, run, target);
|
||||
if (failures.length) fail(`${target} validation failed:\n- ${failures.join("\n- ")}`, 2);
|
||||
console.log(`${run.id}: ${target} contract valid`);
|
||||
}
|
||||
|
||||
function status(options) {
|
||||
const { dir, run } = requireRun(options);
|
||||
const selection = readJson(resolve(dir, "selection.json"));
|
||||
const assets = readJson(resolve(dir, "assets.json"));
|
||||
const video = readJson(resolve(dir, "video.json"));
|
||||
const verification = readJson(resolve(dir, "verification.json"));
|
||||
console.log(JSON.stringify({
|
||||
id: run.id,
|
||||
stage: run.stage,
|
||||
surface: run.surface,
|
||||
platform: run.platform,
|
||||
selectedDirection: selection.selectedDirectionId,
|
||||
mediaJobs: assets.jobs.length,
|
||||
mediaComplete: assets.jobs.filter((job) => job.status === "complete").length,
|
||||
prototypeShots: video.shots.filter((shot) => shot.sourceType === "prototype-recording").length,
|
||||
gates: verification.gates,
|
||||
outputs: run.outputs,
|
||||
path: dir,
|
||||
}, null, 2));
|
||||
}
|
||||
|
||||
const { command, options } = parseArgs(process.argv.slice(2));
|
||||
if (command === "init") init(options);
|
||||
else if (command === "select") select(options);
|
||||
else if (command === "output") output(options);
|
||||
else if (command === "media") media(options);
|
||||
else if (command === "gate") gate(options);
|
||||
else if (command === "advance") advance(options);
|
||||
else if (command === "validate") validate(options);
|
||||
else if (command === "status") status(options);
|
||||
else fail("command must be init, select, output, media, gate, advance, validate, or status");
|
||||
Reference in new issue
Block a user