oda-engine 0.0.0-stage → 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/README.md +151 -2
- package/bin/nowhere.mjs +352 -0
- package/lib/account.mjs +57 -0
- package/lib/agentModules.mjs +57 -0
- package/lib/devServer.mjs +351 -0
- package/lib/headless.mjs +231 -0
- package/lib/headlessPreview.mjs +212 -0
- package/lib/keys.mjs +517 -0
- package/lib/make.mjs +855 -0
- package/lib/mcp.mjs +537 -0
- package/lib/open.mjs +22 -0
- package/lib/preview.mjs +87 -0
- package/lib/previewRpc.mjs +134 -0
- package/lib/project.mjs +359 -0
- package/lib/publishFlow.mjs +90 -0
- package/lib/resources.mjs +50 -0
- package/lib/rules.mjs +60 -0
- package/lib/scaffold.mjs +42 -0
- package/lib/setup.mjs +59 -0
- package/lib/tools.mjs +668 -0
- package/package.json +51 -4
- package/template/game.config.json +9 -0
- package/template/scene.json +4 -0
- package/template/src/main.ts +11 -0
- package/vendor/DOCS.md +447 -0
- package/vendor/agent/appRun.mjs +520 -0
- package/vendor/agent/assets/brief.mjs +242 -0
- package/vendor/agent/assets/collider.mjs +531 -0
- package/vendor/agent/assets/environments/index.mjs +12 -0
- package/vendor/agent/assets/environments/worldlabs.mjs +161 -0
- package/vendor/agent/assets/fetch.mjs +168 -0
- package/vendor/agent/assets/footprint.mjs +13 -0
- package/vendor/agent/assets/gltf.mjs +547 -0
- package/vendor/agent/assets/hdr.mjs +269 -0
- package/vendor/agent/assets/imageOps.mjs +171 -0
- package/vendor/agent/assets/images/codex.mjs +307 -0
- package/vendor/agent/assets/images/fal.mjs +75 -0
- package/vendor/agent/assets/images/gemini.mjs +84 -0
- package/vendor/agent/assets/images/index.mjs +25 -0
- package/vendor/agent/assets/images/openai.mjs +75 -0
- package/vendor/agent/assets/images/stability.mjs +71 -0
- package/vendor/agent/assets/images/views.mjs +31 -0
- package/vendor/agent/assets/import.mjs +1352 -0
- package/vendor/agent/assets/inspect.mjs +465 -0
- package/vendor/agent/assets/jobs.mjs +196 -0
- package/vendor/agent/assets/ktx2.mjs +290 -0
- package/vendor/agent/assets/ledger.mjs +466 -0
- package/vendor/agent/assets/net.mjs +254 -0
- package/vendor/agent/assets/prices.json +39 -0
- package/vendor/agent/assets/providers/fal.mjs +115 -0
- package/vendor/agent/assets/providers/index.mjs +22 -0
- package/vendor/agent/assets/providers/meshy.mjs +119 -0
- package/vendor/agent/assets/providers/tripo.mjs +188 -0
- package/vendor/agent/assets/sources/ambientcg.mjs +129 -0
- package/vendor/agent/assets/sources/index.mjs +23 -0
- package/vendor/agent/assets/sources/polyhaven.mjs +237 -0
- package/vendor/agent/assets/sources/polypizza.mjs +121 -0
- package/vendor/agent/assets/splat.mjs +631 -0
- package/vendor/agent/assets/targets.mjs +122 -0
- package/vendor/agent/assets/tile.mjs +261 -0
- package/vendor/agent/assets/unzip.mjs +180 -0
- package/vendor/agent/blender/cleanup.py +360 -0
- package/vendor/agent/blender/convert.py +167 -0
- package/vendor/agent/blender/find.mjs +192 -0
- package/vendor/agent/blender/nw_export.py +104 -0
- package/vendor/agent/blender/nw_rubric.py +426 -0
- package/vendor/agent/blender/run.mjs +193 -0
- package/vendor/agent/blender/runner.py +252 -0
- package/vendor/agent/blender/sheet.py +743 -0
- package/vendor/agent/depth.mjs +134 -0
- package/vendor/agent/director/board.mjs +451 -0
- package/vendor/agent/director/contracts.mjs +663 -0
- package/vendor/agent/director/director.mjs +2365 -0
- package/vendor/agent/director/estimate.mjs +200 -0
- package/vendor/agent/director/gate.mjs +802 -0
- package/vendor/agent/director/limits.json +16 -0
- package/vendor/agent/director/methods.mjs +457 -0
- package/vendor/agent/director/policy.json +33 -0
- package/vendor/agent/director/prompts.mjs +244 -0
- package/vendor/agent/director/reading.mjs +341 -0
- package/vendor/agent/director/router.mjs +184 -0
- package/vendor/agent/director/seams.mjs +243 -0
- package/vendor/agent/director/session.mjs +643 -0
- package/vendor/agent/director/store.mjs +119 -0
- package/vendor/agent/director/taskGate.mjs +110 -0
- package/vendor/agent/director/teamLedger.mjs +118 -0
- package/vendor/agent/director/triage.mjs +63 -0
- package/vendor/agent/downloads.cjs +363 -0
- package/vendor/agent/flow.mjs +78 -0
- package/vendor/agent/guard.mjs +613 -0
- package/vendor/agent/host.mjs +1736 -0
- package/vendor/agent/language.mjs +58 -0
- package/vendor/agent/ledger.mjs +360 -0
- package/vendor/agent/locale.cjs +186 -0
- package/vendor/agent/loop/capacity.mjs +74 -0
- package/vendor/agent/loop/compose.mjs +127 -0
- package/vendor/agent/loop/gate.mjs +205 -0
- package/vendor/agent/loop/judge.mjs +189 -0
- package/vendor/agent/loop/levels.mjs +273 -0
- package/vendor/agent/loop/state.mjs +358 -0
- package/vendor/agent/notes.cjs +278 -0
- package/vendor/agent/pace.mjs +258 -0
- package/vendor/agent/panels.mjs +431 -0
- package/vendor/agent/prompt.mjs +342 -0
- package/vendor/agent/reference/board.mjs +410 -0
- package/vendor/agent/reference/compose.mjs +364 -0
- package/vendor/agent/reference/decode.mjs +56 -0
- package/vendor/agent/reference/facts.mjs +1874 -0
- package/vendor/agent/reference/png.mjs +107 -0
- package/vendor/agent/reference/records.mjs +63 -0
- package/vendor/agent/reference/web.mjs +252 -0
- package/vendor/agent/roles/artist.mjs +69 -0
- package/vendor/agent/roles/builder.mjs +79 -0
- package/vendor/agent/roles/checks.mjs +223 -0
- package/vendor/agent/roles/common.mjs +188 -0
- package/vendor/agent/roles/critic.mjs +171 -0
- package/vendor/agent/roles/index.mjs +39 -0
- package/vendor/agent/roles/modeller.mjs +142 -0
- package/vendor/agent/roles/qa.mjs +58 -0
- package/vendor/agent/roles/rubrics.mjs +79 -0
- package/vendor/agent/roles/sound.mjs +69 -0
- package/vendor/agent/rounds.cjs +333 -0
- package/vendor/agent/shared.mjs +284 -0
- package/vendor/agent/stopGate.mjs +574 -0
- package/vendor/agent/subagents.mjs +129 -0
- package/vendor/agent/tools/assets.mjs +499 -0
- package/vendor/agent/tools/blender.mjs +754 -0
- package/vendor/agent/tools/cards.mjs +479 -0
- package/vendor/agent/tools/choices.mjs +479 -0
- package/vendor/agent/tools/compose.mjs +74 -0
- package/vendor/agent/tools/environment.mjs +488 -0
- package/vendor/agent/tools/eyes.mjs +733 -0
- package/vendor/agent/tools/generate.mjs +338 -0
- package/vendor/agent/tools/guide.mjs +46 -0
- package/vendor/agent/tools/harness.mjs +193 -0
- package/vendor/agent/tools/image.mjs +643 -0
- package/vendor/agent/tools/index.mjs +162 -0
- package/vendor/agent/tools/look.mjs +578 -0
- package/vendor/agent/tools/loop.mjs +858 -0
- package/vendor/agent/tools/others.mjs +123 -0
- package/vendor/agent/tools/pictures.mjs +535 -0
- package/vendor/agent/tools/reference.mjs +366 -0
- package/vendor/agent/transcripts.mjs +118 -0
- package/vendor/agent-loop.mjs +602 -0
- package/vendor/agent-plugin/.claude-plugin/plugin.json +5 -0
- package/vendor/agent-plugin/skills/art-direction/SKILL.md +82 -0
- package/vendor/agent-plugin/skills/asset-legality/SKILL.md +101 -0
- package/vendor/agent-plugin/skills/asset-sources/SKILL.md +111 -0
- package/vendor/agent-plugin/skills/blender-modeling/SKILL.md +97 -0
- package/vendor/agent-plugin/skills/look-dev/SKILL.md +104 -0
- package/vendor/agent-plugin/skills/playtesting/SKILL.md +74 -0
- package/vendor/agent-plugin/skills/reference-loop/SKILL.md +102 -0
- package/vendor/agent-plugin/skills/sound-design/SKILL.md +60 -0
- package/vendor/agent-plugin/skills/style/SKILL.md +35 -0
- package/vendor/agent-plugin/skills/tsl-r185/SKILL.md +107 -0
- package/vendor/auth.cjs +570 -0
- package/vendor/build.cjs +953 -0
- package/vendor/catalog.json +455 -0
- package/vendor/connectors.cjs +688 -0
- package/vendor/eyes.mjs +733 -0
- package/vendor/gameExports.json +1390 -0
- package/vendor/git.cjs +222 -0
- package/vendor/models.json +57 -0
- package/vendor/publish.cjs +1018 -0
- package/vendor/refBoard.cjs +301 -0
- package/vendor/schema/dist/assets.d.ts +335 -0
- package/vendor/schema/dist/assets.js +439 -0
- package/vendor/schema/dist/brief.d.ts +357 -0
- package/vendor/schema/dist/brief.js +302 -0
- package/vendor/schema/dist/common.d.ts +9 -0
- package/vendor/schema/dist/common.js +13 -0
- package/vendor/schema/dist/config.d.ts +406 -0
- package/vendor/schema/dist/config.js +355 -0
- package/vendor/schema/dist/contract.d.ts +599 -0
- package/vendor/schema/dist/contract.js +1146 -0
- package/vendor/schema/dist/index.d.ts +14 -0
- package/vendor/schema/dist/index.js +21 -0
- package/vendor/schema/dist/look.d.ts +463 -0
- package/vendor/schema/dist/look.js +681 -0
- package/vendor/schema/dist/lookStats.d.ts +230 -0
- package/vendor/schema/dist/lookStats.js +768 -0
- package/vendor/schema/dist/pilot.d.ts +32 -0
- package/vendor/schema/dist/pilot.js +44 -0
- package/vendor/schema/dist/publish.d.ts +214 -0
- package/vendor/schema/dist/publish.js +291 -0
- package/vendor/schema/dist/scene.d.ts +75 -0
- package/vendor/schema/dist/scene.js +120 -0
- package/vendor/schema/dist/skyLight.d.ts +141 -0
- package/vendor/schema/dist/skyLight.js +436 -0
- package/vendor/schema/dist/style.d.ts +131 -0
- package/vendor/schema/dist/style.js +155 -0
- package/vendor/schema/package.json +1 -0
- package/vendor/selectionPrompt.mjs +51 -0
- package/vendor/useTools.mjs +195 -0
- package/vendor/userMessage.mjs +26 -0
- package/web-dist/assets/GaussianSplatUtils-CB77cP9U.js +1 -0
- package/web-dist/assets/KTX2Loader-6OIWUF7s.js +2 -0
- package/web-dist/assets/SPZLoader-zYj0Alfv.js +1 -0
- package/web-dist/assets/gaussianSplat-CJTI1sEh.js +1 -0
- package/web-dist/assets/index-CcjyyQco.css +1 -0
- package/web-dist/assets/index-DMyJcoZJ.js +693 -0
- package/web-dist/assets/meshopt_decoder.module-BvwdjiD3.js +1 -0
- package/web-dist/assets/zstddec.module-CfFeQW7d.js +1 -0
- package/web-dist/index.html +34 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// How hard the agent thinks about a request. A question or a small tweak
|
|
2
|
+
// should not burn the tokens a whole new space needs, and a "make this game,
|
|
3
|
+
// use Blender, detailed" should not run at the depth of a colour change, as
|
|
4
|
+
// every studio request did until phase 1 (all at medium). Read from the
|
|
5
|
+
// creator's own words with a few regular expressions, kept in one table so a
|
|
6
|
+
// missed phrasing is one line to add. English words carry word boundaries
|
|
7
|
+
// ("through" is not "rough", "island" does not start a question); Hangul has
|
|
8
|
+
// none in JavaScript's \b, so those stay bare.
|
|
9
|
+
//
|
|
10
|
+
// "Make" with a game word is a whole build only in a blank project or when
|
|
11
|
+
// the creator asks for a new one: in Korean "~하게 만들어줘" is how any change
|
|
12
|
+
// is asked for ("맵을 더 넓게 만들어줘"), and a tweak in those words must not
|
|
13
|
+
// run at xhigh behind a cost card.
|
|
14
|
+
|
|
15
|
+
export const EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max']
|
|
16
|
+
|
|
17
|
+
/** The signals, case-insensitive, over the creator's message. */
|
|
18
|
+
export const SIGNALS = {
|
|
19
|
+
ULTRA: /ultracode|울트라|최대한\s*(잘|자세|꼼꼼|디테일)|max(imum)?\s+effort|as (good|detailed) as (you can|possible)|최고\s*품질/i,
|
|
20
|
+
BUILD_VERB: /만들어|만들자|만들고|제작|구현해|지어|짓자|\bmake\b|\bbuild\b|\bcreate\b|作って|作成|做一个|制作/i,
|
|
21
|
+
// A space is a build too (2026-10-24, SPACE_FIRST): a room, a courtyard, a
|
|
22
|
+
// library. 방 alone is left out, since it starts 방법 and 방향.
|
|
23
|
+
BUILD_SCOPE: /게임|월드|세계|맵|레벨|섬(?!세)|행성|마을|도시|던전|공간|실내|인테리어|안뜰|중정|정원|서재|도서관|오두막|\bgame\b|\bworld\b|\blevel\b|\bmap\b|\bisland\b|\bplanet\b|\btown\b|\bcity\b|\bdungeon\b|\bspaces?\b|\brooms?\b|\binterior\b|\bcourtyard\b|\blibrary\b|\bcabin\b|\bgarden\b|\bhall\b|ゲーム|世界|空間|部屋|游戏|空间|房间/i,
|
|
24
|
+
NEW: /새로|(^|\s)새\s|처음부터|\bnew\b|\banother\b|from scratch|新しい|新的|另一个/i,
|
|
25
|
+
DETAIL: /디테일|자세하게|자세히|정교|정밀|아름답게|예쁘게|고퀄|퀄리티|\bdetail(ed)?\b|\bbeautiful(ly)?\b|\bpolish(ed)?\b|high[- ]quality|\bstunning\b|\bgorgeous\b|細かく|精细/i,
|
|
26
|
+
MODEL: /블렌더|blender|모델링|model(l)?ing|\bsculpt|3d ?모델|3d model/i,
|
|
27
|
+
FEATURE: /추가|구현|기능|규칙|시스템|메커니즘|고쳐|수정|버그|안 ?돼|\badd\b|implement|feature|\brules?\b|mechanic|system|\bfix\b|\bbug\b|broken|refactor/i,
|
|
28
|
+
TWEAK: /색|크기|조금|살짝|약간|위치|옮겨|키워|줄여|빠르게|느리게|밝게|어둡게|넓게|좁게|크게|작게|높게|낮게|어렵게|쉽게|짙게|진하게|연하게|colou?r|\bsize\b|bigger|smaller|taller|shorter|wider|larger|harder|easier|\bmove\b|rename|tweak|slightly|a (bit|little)|brighter|darker|faster|slower/i,
|
|
29
|
+
QUESTION_END: /[??]\s*$/,
|
|
30
|
+
QUESTION_START: /^\s*((what|why|how|where|which|when|who|can|could|does|do|is|are)\b|뭐|왜|어떻게|어디|언제|무엇|누가|혹시)/i,
|
|
31
|
+
LIGHTER: /빨리|간단히|대충|가볍게|\bquick(ly)?\b|\bsimple\b|\brough(ly)?\b/i,
|
|
32
|
+
DEEPER: /꼼꼼|신중|철저|\bcareful(ly)?\b|\bthorough(ly)?\b/i,
|
|
33
|
+
// The task card's Continue button in every label language, and the usual words for it.
|
|
34
|
+
CONTINUE: /\bcontin[uú]|이어서|계속|続け|继续|\breprend|\bweiter|keep going|carry on|go on\b/i,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @param {{ text: string, images?: number, attachment?: boolean, emptyProject?: boolean }} input
|
|
39
|
+
* @returns {{ effort: 'low' | 'medium' | 'high' | 'xhigh' | 'max', big: boolean, space: boolean, reason: string }}
|
|
40
|
+
* big: a job that asks for its cost first and keeps a build's pace. space:
|
|
41
|
+
* the request builds a space (the order for a space, its brief and the
|
|
42
|
+
* stop gate's hold to it); a big request that models one thing in Blender
|
|
43
|
+
* or matches a reference is big without being a space.
|
|
44
|
+
*/
|
|
45
|
+
export function chooseDepth({ text, images = 0, attachment = false, emptyProject = false }) {
|
|
46
|
+
const t = String(text ?? '')
|
|
47
|
+
const has = (name) => SIGNALS[name].test(t)
|
|
48
|
+
const length = t.trim().length
|
|
49
|
+
// A short message with a tweak word is a tweak, however it is phrased.
|
|
50
|
+
const tweak = has('TWEAK') && length < 120
|
|
51
|
+
const build = has('BUILD_VERB') && has('BUILD_SCOPE') && (has('NEW') || (emptyProject && !tweak))
|
|
52
|
+
const question = has('QUESTION_END') || has('QUESTION_START')
|
|
53
|
+
// A long first message in an empty project is the space, unless it only
|
|
54
|
+
// asks for one model ("model a wooden chair in blender"): that is a chair,
|
|
55
|
+
// and a chair has no brief, no sky and no hero views of its own.
|
|
56
|
+
const newSpace = build || (emptyProject && !question && !tweak && length >= 20 && !(has('MODEL') && !has('BUILD_SCOPE')))
|
|
57
|
+
|
|
58
|
+
let effort
|
|
59
|
+
let reason
|
|
60
|
+
const extras = [has('DETAIL'), has('MODEL'), images > 0].filter(Boolean).length
|
|
61
|
+
if (has('ULTRA')) [effort, reason] = ['max', 'asked for the most effort']
|
|
62
|
+
else if (build && extras >= 2) [effort, reason] = ['max', 'a detailed build']
|
|
63
|
+
else if (newSpace) [effort, reason] = ['xhigh', 'a new space or world']
|
|
64
|
+
else if (has('MODEL') || (has('DETAIL') && images > 0)) [effort, reason] = ['xhigh', 'modelling or matching a reference']
|
|
65
|
+
else if (question && !has('FEATURE') && !has('TWEAK') && length < 240) [effort, reason] = ['low', 'a question']
|
|
66
|
+
else if (has('FEATURE') || length >= 280 || images > 0) [effort, reason] = ['high', 'a feature']
|
|
67
|
+
else if (has('TWEAK') || attachment || length < 80) [effort, reason] = ['medium', 'a tweak']
|
|
68
|
+
else [effort, reason] = ['high', 'a feature']
|
|
69
|
+
|
|
70
|
+
// "Quickly" and "carefully" move it one step, within the scale.
|
|
71
|
+
let i = EFFORTS.indexOf(effort)
|
|
72
|
+
if (has('LIGHTER')) {
|
|
73
|
+
i = Math.max(0, i - 1)
|
|
74
|
+
reason += ', asked to keep it light'
|
|
75
|
+
}
|
|
76
|
+
if (has('DEEPER')) {
|
|
77
|
+
i = Math.min(EFFORTS.length - 1, i + 1)
|
|
78
|
+
reason += ', asked to be thorough'
|
|
79
|
+
}
|
|
80
|
+
effort = EFFORTS[i]
|
|
81
|
+
return { effort, big: effort === 'xhigh' || effort === 'max', space: newSpace, reason }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** A message that only says to go on (the task card's Continue, a bare "ok"):
|
|
85
|
+
* it carries no signals of its own, so the request it continues sets the depth. */
|
|
86
|
+
export function isContinuation(text) {
|
|
87
|
+
const t = String(text ?? '').trim()
|
|
88
|
+
if (!t) return false
|
|
89
|
+
if (SIGNALS.CONTINUE.test(t) && t.length < 60) return true
|
|
90
|
+
return t.length <= 12 && !Object.entries(SIGNALS).some(([name, re]) => name !== 'CONTINUE' && re.test(t))
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The depth for a request in its conversation: its own, or for a
|
|
95
|
+
* continuation the depth of the request it continues when that is deeper
|
|
96
|
+
* (big flag included), so a stopped max build does not go on at medium.
|
|
97
|
+
* The earlier request is read as in a project that has a game already.
|
|
98
|
+
*
|
|
99
|
+
* @param {{ text: string, history?: { role: string, text: string, images?: number }[], images?: number,
|
|
100
|
+
* attachment?: boolean, emptyProject?: boolean }} input
|
|
101
|
+
*/
|
|
102
|
+
export function depthFor({ text, history = [], images = 0, attachment = false, emptyProject = false }) {
|
|
103
|
+
const own = chooseDepth({ text, images, attachment, emptyProject })
|
|
104
|
+
if (!isContinuation(text) || !Array.isArray(history)) return own
|
|
105
|
+
const earlier = [...history].reverse().find((m) => m?.role === 'user' && typeof m.text === 'string' && m.text.trim() && !isContinuation(m.text))
|
|
106
|
+
if (!earlier) return own
|
|
107
|
+
const before = chooseDepth({ text: earlier.text, images: Number(earlier.images) || 0 })
|
|
108
|
+
return EFFORTS.indexOf(before.effort) > EFFORTS.indexOf(own.effort) ? { ...before, reason: `${before.reason}, continued` } : own
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The request's depth on the model that runs it: never deeper than the
|
|
113
|
+
* model's effortCeiling (models.json). Claude Haiku 5.5 at max spent 361k
|
|
114
|
+
* of 395k output tokens thinking, about 21k a call, and in 40 minutes and
|
|
115
|
+
* 17 calls never built the island (2026-10-20); at a lower effort the same
|
|
116
|
+
* model builds. A big job stays big (its cost card and its pace) on any
|
|
117
|
+
* model: it only thinks less per step.
|
|
118
|
+
*
|
|
119
|
+
* @param {{ effort: string, big: boolean, reason: string }} depth
|
|
120
|
+
* @param {{ id?: string, name?: string, effortCeiling?: string } | null | undefined} model
|
|
121
|
+
* @returns {{ effort: string, big: boolean, reason: string, asked?: string }}
|
|
122
|
+
*/
|
|
123
|
+
export function fitDepth(depth, model) {
|
|
124
|
+
const ceiling = EFFORTS.includes(model?.effortCeiling) ? model.effortCeiling : 'max'
|
|
125
|
+
if (EFFORTS.indexOf(depth.effort) <= EFFORTS.indexOf(ceiling)) return depth
|
|
126
|
+
return { ...depth, effort: ceiling, asked: depth.effort, reason: `${depth.reason}, at most ${ceiling} on ${model?.name ?? model?.id ?? 'this model'}` }
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** One effort level down, never below `floor`; null when it is there already. */
|
|
130
|
+
export function lowerEffort(effort, floor = 'medium') {
|
|
131
|
+
const i = EFFORTS.indexOf(effort)
|
|
132
|
+
const f = EFFORTS.indexOf(floor)
|
|
133
|
+
return i > f ? EFFORTS[i - 1] : null
|
|
134
|
+
}
|
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
// The board PLAN writes, held to rules code can check before anything runs
|
|
2
|
+
// (orchestrator spec 2.5). The rules are what lets several roles work in one
|
|
3
|
+
// working tree at once without overwriting each other: two tasks that may
|
|
4
|
+
// run at the same time own disjoint files, the game's composition (main.ts,
|
|
5
|
+
// scene.json, the config) is the builder's alone, the look keys change only
|
|
6
|
+
// through look_apply, every artist and QA task waits for the blockout that
|
|
7
|
+
// makes the cameras, every modelled asset stands at one of the blockout's
|
|
8
|
+
// placements, every request element and signature moment has a task that
|
|
9
|
+
// covers it, and every task whose work is seen gives the critic criteria to
|
|
10
|
+
// judge it by: with a reference, the forms that matter most (the blockout,
|
|
11
|
+
// a hero model, the integration) by a brief subject's crop of it, and never
|
|
12
|
+
// by a reading of the picture too unsure to stand on. validateBoard answers
|
|
13
|
+
// every error at once, so the one repair decision sees them all.
|
|
14
|
+
//
|
|
15
|
+
// What a task makes reaches the others through the director: a seam (the
|
|
16
|
+
// materials, the audio, the placements the models take over) or the look
|
|
17
|
+
// keys, each of which stays in a working state while its maker has not
|
|
18
|
+
// passed. So a dependency on such a maker only orders the work: a kept or
|
|
19
|
+
// failed maker leaves its stand-in in place, and the tasks after it go on.
|
|
20
|
+
//
|
|
21
|
+
// Globs are project-relative, with forward slashes: `**` any depth, `*` and
|
|
22
|
+
// `?` within one folder. A role's mayOwn may carve a part out with a leading
|
|
23
|
+
// `!` (the modeller owns assets/** but not assets/audio/**).
|
|
24
|
+
|
|
25
|
+
import { citesAdvisory } from '../reference/facts.mjs'
|
|
26
|
+
import { SOUND_MODULE } from '../roles/sound.mjs'
|
|
27
|
+
import { playParams } from '../tools/eyes.mjs'
|
|
28
|
+
import { CHECK_KINDS, HEX, PLACEMENT_ID, ROLE_IDS, normalizeCheck } from './contracts.mjs'
|
|
29
|
+
import { methodErrors, usesPictures } from './methods.mjs'
|
|
30
|
+
|
|
31
|
+
/** The files only the director writes: the seams, the brief and .nowhere/.
|
|
32
|
+
* materials and audio are interface kinds; placements is the seam of the
|
|
33
|
+
* blockout's stand-ins, which the made models take over. */
|
|
34
|
+
export const SEAM_PATHS = { materials: 'src/look/index.ts', audio: 'src/audio/index.ts', placements: 'src/placements/index.ts' }
|
|
35
|
+
export const DIRECTOR_FILES = [...Object.values(SEAM_PATHS), 'brief.md', '.nowhere/**']
|
|
36
|
+
/** The game's composition, the builder's alone. */
|
|
37
|
+
export const BUILDER_FILES = ['src/main.ts', 'scene.json', 'game.config.json']
|
|
38
|
+
/** game.config.json's keys that only look_apply changes. */
|
|
39
|
+
export const LOOK_KEYS = ['sky', 'fog', 'lighting', 'bloom', 'look']
|
|
40
|
+
/** The kinds that are verification rather than the always-on hygiene. */
|
|
41
|
+
export const HYGIENE = new Set(['markers', 'ownership'])
|
|
42
|
+
/** The kinds that use the preview, so wait for its lane. */
|
|
43
|
+
export const PREVIEW_KINDS = new Set(['build', 'runtime', 'view', 'compare', 'cameras', 'placements', 'play', 'perf'])
|
|
44
|
+
/** A task that ended with its work in the game: passed, or kept below the
|
|
45
|
+
* critic's bar as the best attempt there was. */
|
|
46
|
+
export const DONE = new Set(['passed', 'kept'])
|
|
47
|
+
/** A task that will not run again in this production. */
|
|
48
|
+
export const ENDED = new Set(['passed', 'kept', 'failed', 'blocked', 'skipped'])
|
|
49
|
+
|
|
50
|
+
const WILD = /[*?[{]/
|
|
51
|
+
|
|
52
|
+
/** A project-relative path as globs read it. */
|
|
53
|
+
export const relPath = (p) =>
|
|
54
|
+
String(p ?? '')
|
|
55
|
+
.replace(/\\/g, '/')
|
|
56
|
+
.replace(/^(\.\/)+/, '')
|
|
57
|
+
.replace(/\/+$/, '')
|
|
58
|
+
|
|
59
|
+
const cache = new Map()
|
|
60
|
+
/** A glob as a regular expression over a whole relative path. */
|
|
61
|
+
export function globRe(glob) {
|
|
62
|
+
const g = relPath(glob)
|
|
63
|
+
if (cache.has(g)) return cache.get(g)
|
|
64
|
+
let re = ''
|
|
65
|
+
for (let i = 0; i < g.length; i++) {
|
|
66
|
+
const c = g[i]
|
|
67
|
+
if (c === '*' && g[i + 1] === '*') {
|
|
68
|
+
// `a/**` is a/ and everything under it; `**/b` is b at any depth.
|
|
69
|
+
if (g[i + 2] === '/') {
|
|
70
|
+
re += '(?:.*/)?'
|
|
71
|
+
i += 2
|
|
72
|
+
} else {
|
|
73
|
+
re += '.*'
|
|
74
|
+
i += 1
|
|
75
|
+
}
|
|
76
|
+
} else if (c === '*') re += '[^/]*'
|
|
77
|
+
else if (c === '?') re += '[^/]'
|
|
78
|
+
else re += c.replace(/[.+^${}()|[\]\\]/g, '\\$&')
|
|
79
|
+
}
|
|
80
|
+
const out = new RegExp(`^${re}$`)
|
|
81
|
+
cache.set(g, out)
|
|
82
|
+
return out
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Whether a relative path matches a glob; `dir/**` also matches dir itself. */
|
|
86
|
+
export function matches(glob, rel) {
|
|
87
|
+
const g = relPath(glob)
|
|
88
|
+
const p = relPath(rel)
|
|
89
|
+
if (globRe(g).test(p)) return true
|
|
90
|
+
return g.endsWith('/**') && p === g.slice(0, -3)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** The part of a glob before its first wildcard. */
|
|
94
|
+
export const literalPrefix = (glob) => relPath(glob).split(WILD)[0]
|
|
95
|
+
const literal = (glob) => !WILD.test(relPath(glob))
|
|
96
|
+
|
|
97
|
+
/** Whether two globs may name a common file: equal literals, or one
|
|
98
|
+
* literal prefix the start of the other's (src/look/** and src/look/sky.ts). */
|
|
99
|
+
export function overlaps(a, b) {
|
|
100
|
+
if (literal(a) && literal(b)) return relPath(a) === relPath(b)
|
|
101
|
+
if (literal(a)) return matches(b, a) || literalPrefix(b).startsWith(relPath(a) + '/')
|
|
102
|
+
if (literal(b)) return matches(a, b) || literalPrefix(a).startsWith(relPath(b) + '/')
|
|
103
|
+
const pa = literalPrefix(a)
|
|
104
|
+
const pb = literalPrefix(b)
|
|
105
|
+
return pa.startsWith(pb) || pb.startsWith(pa)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** A path a glob would match, for testing containment. */
|
|
109
|
+
const sampleOf = (glob) => relPath(glob).replace(/\*\*/g, 'x/y').replace(/\*/g, 'x').replace(/\?/g, 'x')
|
|
110
|
+
|
|
111
|
+
/** Whether every file `glob` names is inside `allowed` (globs, `!` to carve out). */
|
|
112
|
+
export function inside(glob, allowed) {
|
|
113
|
+
const plus = allowed.filter((a) => !a.startsWith('!'))
|
|
114
|
+
const minus = allowed.filter((a) => a.startsWith('!')).map((a) => a.slice(1))
|
|
115
|
+
const sample = sampleOf(glob)
|
|
116
|
+
if (!plus.some((a) => matches(a, sample) || (literal(glob) && matches(a, glob)))) return false
|
|
117
|
+
if (literal(glob)) return !minus.some((m) => matches(m, glob))
|
|
118
|
+
// A glob that reaches into a carved-out part is not inside, unless that
|
|
119
|
+
// part is a seam or another of the director's files: the write guard keeps
|
|
120
|
+
// those the director's whatever a task owns (src/look/** stays the
|
|
121
|
+
// artist's around src/look/index.ts).
|
|
122
|
+
return !minus.some((m) => !isDirectorFile(m) && (matches(m, sample) || literalPrefix(m).startsWith(literalPrefix(glob))))
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Whether a path is one of the director's files. */
|
|
126
|
+
export const isDirectorFile = (rel) => DIRECTOR_FILES.some((g) => matches(g, rel))
|
|
127
|
+
|
|
128
|
+
/** The blockout's placements (the task that makes the cameras declares them). */
|
|
129
|
+
export const placementsOf = (board) => (board?.tasks ?? []).find((t) => t.makesCameras === true)?.placements ?? []
|
|
130
|
+
|
|
131
|
+
/** Whether what a task makes reaches the game only through the director: a
|
|
132
|
+
* seam (an interface's module, a model at a placement) or the look keys
|
|
133
|
+
* (an artist's, put back as one with its module). Waiting on such a task
|
|
134
|
+
* orders the work; its failure leaves its stand-in, and blocks nothing. */
|
|
135
|
+
export function throughSeam(task) {
|
|
136
|
+
if (!task) return false
|
|
137
|
+
return task.role === 'artist' || !!task.interface || (task.role === 'modeller' && !!task.placement)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** The ids of every task `id` depends on, directly or not. */
|
|
141
|
+
export function upstream(board, id, seen = new Set()) {
|
|
142
|
+
const byId = new Map(board.tasks.map((t) => [t.id, t]))
|
|
143
|
+
const walk = (tid) => {
|
|
144
|
+
for (const d of byId.get(tid)?.deps ?? []) {
|
|
145
|
+
if (seen.has(d)) continue
|
|
146
|
+
seen.add(d)
|
|
147
|
+
walk(d)
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
walk(id)
|
|
151
|
+
return seen
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Whether one of two tasks waits for the other. */
|
|
155
|
+
export const ordered = (board, a, b) => upstream(board, a).has(b) || upstream(board, b).has(a)
|
|
156
|
+
|
|
157
|
+
/** A dependency cycle as ids, or null. */
|
|
158
|
+
export function cycleOf(tasks) {
|
|
159
|
+
const byId = new Map(tasks.map((t) => [t.id, t]))
|
|
160
|
+
const state = new Map()
|
|
161
|
+
const stack = []
|
|
162
|
+
const visit = (id) => {
|
|
163
|
+
if (state.get(id) === 'done') return null
|
|
164
|
+
if (state.get(id) === 'open') return [...stack.slice(stack.indexOf(id)), id]
|
|
165
|
+
state.set(id, 'open')
|
|
166
|
+
stack.push(id)
|
|
167
|
+
for (const d of byId.get(id)?.deps ?? []) {
|
|
168
|
+
if (!byId.has(d)) continue
|
|
169
|
+
const c = visit(d)
|
|
170
|
+
if (c) return c
|
|
171
|
+
}
|
|
172
|
+
stack.pop()
|
|
173
|
+
state.set(id, 'done')
|
|
174
|
+
return null
|
|
175
|
+
}
|
|
176
|
+
for (const t of tasks) {
|
|
177
|
+
const c = visit(t.id)
|
|
178
|
+
if (c) return c
|
|
179
|
+
}
|
|
180
|
+
return null
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Which role's file a path is, by the board's tasks first, then the
|
|
184
|
+
* roles' mayOwn; the director's files are the director's. */
|
|
185
|
+
export function ownerOf(rel, { board, roles }) {
|
|
186
|
+
if (isDirectorFile(rel)) return 'director'
|
|
187
|
+
const task = board?.tasks?.find((t) => (t.owns ?? []).some((g) => matches(g, rel)))
|
|
188
|
+
if (task) return task.role
|
|
189
|
+
for (const id of ROLE_IDS) if (roles?.[id]?.mayOwn?.length && inside(rel, roles[id].mayOwn)) return id
|
|
190
|
+
return 'director'
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const ROLE_NOUN = { builder: 'the builder', artist: 'the artist', modeller: 'the modeller', sound: 'the sound designer', qa: 'the playtester', director: 'the director' }
|
|
194
|
+
export const roleNoun = (id) => ROLE_NOUN[id] ?? 'the director'
|
|
195
|
+
|
|
196
|
+
/** The checks a task runs: the board's, then its role's defaults for any
|
|
197
|
+
* kind the board did not give, then markers and ownership. */
|
|
198
|
+
export function withDefaults(task, role, brief, { interfaces = [] } = {}) {
|
|
199
|
+
const given = (task.accept?.checks ?? []).map(normalizeCheck)
|
|
200
|
+
let defaults = []
|
|
201
|
+
try {
|
|
202
|
+
defaults = (role?.defaultChecks?.(task, brief, { interfaces }) ?? []).map(normalizeCheck)
|
|
203
|
+
} catch {
|
|
204
|
+
defaults = []
|
|
205
|
+
}
|
|
206
|
+
const kinds = new Set(given.map((c) => c.kind))
|
|
207
|
+
const ids = new Set(given.map((c) => c.id))
|
|
208
|
+
const out = [...given]
|
|
209
|
+
const push = (c) => {
|
|
210
|
+
let id = c.id ?? `d-${c.kind}`
|
|
211
|
+
while (ids.has(id)) id = `${id}-2`
|
|
212
|
+
ids.add(id)
|
|
213
|
+
kinds.add(c.kind)
|
|
214
|
+
out.push({ ...c, id })
|
|
215
|
+
}
|
|
216
|
+
for (const c of defaults) if (!kinds.has(c.kind)) push(c)
|
|
217
|
+
for (const kind of ['markers', 'ownership']) if (!kinds.has(kind)) push({ id: kind, kind })
|
|
218
|
+
return { ...task, accept: { checks: out, critic: task.accept?.critic ?? [] } }
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Every rule of 2.5 at once. Returns the errors, each one sentence naming
|
|
223
|
+
* the task; an empty list is a board that may run.
|
|
224
|
+
*
|
|
225
|
+
* @param {object} board
|
|
226
|
+
* @param {{ roles: Record<string, object>, brief: object, vision: object, limits: object, facts?: object | null, declinePaid?: boolean, catalogue?: string[], methods?: object | null }} context
|
|
227
|
+
* facts: the reference's (the art's), for the readings no criterion may stand on;
|
|
228
|
+
* methods: the capability list (methods.mjs capabilitiesOf), with which
|
|
229
|
+
* every modeller task must say how its asset is made, a way that can run here.
|
|
230
|
+
*/
|
|
231
|
+
export function validateBoard(board, { roles, brief, vision, limits, facts = null, declinePaid = false, catalogue = CHECK_KINDS, methods = null }) {
|
|
232
|
+
const errors = []
|
|
233
|
+
const tasks = Array.isArray(board?.tasks) ? board.tasks : []
|
|
234
|
+
const max = limits?.maxTasks ?? 12
|
|
235
|
+
if (tasks.length < 1 || tasks.length > max) errors.push(`The board has ${tasks.length} tasks; it needs 1 to ${max}.`)
|
|
236
|
+
const ids = new Set()
|
|
237
|
+
tasks.forEach((t, i) => {
|
|
238
|
+
if (t.id !== `t${i + 1}`) errors.push(`Task ${i + 1} is "${t.id}"; ids go t1, t2, ... in board order.`)
|
|
239
|
+
if (ids.has(t.id)) errors.push(`Two tasks are ${t.id}.`)
|
|
240
|
+
ids.add(t.id)
|
|
241
|
+
if (!roles?.[t.role]) errors.push(`${t.id}: the role "${t.role}" is not one of ${Object.keys(roles ?? {}).join(', ')}.`)
|
|
242
|
+
})
|
|
243
|
+
const byId = new Map(tasks.map((t) => [t.id, t]))
|
|
244
|
+
for (const t of tasks) for (const d of t.deps ?? []) if (!byId.has(d)) errors.push(`${t.id} depends on ${d}, which is not on the board.`)
|
|
245
|
+
const cycle = cycleOf(tasks)
|
|
246
|
+
if (cycle) errors.push(`The dependencies go round in a circle: ${cycle.join(' -> ')}.`)
|
|
247
|
+
const b = { tasks }
|
|
248
|
+
|
|
249
|
+
// Ownership.
|
|
250
|
+
for (const t of tasks) {
|
|
251
|
+
const mayOwn = roles?.[t.role]?.mayOwn ?? []
|
|
252
|
+
if (t.role === 'qa' && (t.owns ?? []).length) errors.push(`${t.id}: a QA task owns nothing; it only reads and plays.`)
|
|
253
|
+
for (const g of t.owns ?? []) {
|
|
254
|
+
// A wide glob may cover a seam (src/look/** has src/look/index.ts in
|
|
255
|
+
// it): the write guard keeps the seam the director's. .nowhere/ never.
|
|
256
|
+
if (literal(g) ? isDirectorFile(g) : overlaps(g, '.nowhere/**')) {
|
|
257
|
+
errors.push(`${t.id} owns ${g}, which is the director's (the seams, brief.md and .nowhere/).`)
|
|
258
|
+
continue
|
|
259
|
+
}
|
|
260
|
+
if (t.role !== 'qa' && !inside(g, mayOwn)) errors.push(`${t.id} owns ${g}, which ${roleNoun(t.role)} may not own (it may own ${mayOwn.join(', ') || 'nothing'}).`)
|
|
261
|
+
if (t.role !== 'builder' && BUILDER_FILES.some((f) => overlaps(f, g))) {
|
|
262
|
+
errors.push(`${t.id} (${t.role}) owns ${g}: src/main.ts, scene.json and game.config.json are only the builder's; the look keys change through look_apply.`)
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
267
|
+
for (let j = i + 1; j < tasks.length; j++) {
|
|
268
|
+
const a = tasks[i]
|
|
269
|
+
const c = tasks[j]
|
|
270
|
+
if (cycle || ordered(b, a.id, c.id)) continue
|
|
271
|
+
const clash = (a.owns ?? []).flatMap((x) => (c.owns ?? []).filter((y) => overlaps(x, y)).map((y) => `${x} and ${y}`))
|
|
272
|
+
if (clash.length) errors.push(`${a.id} and ${c.id} can run at the same time and both own ${clash[0]}; give one the file or make one depend on the other.`)
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// The blockout comes first, with the cameras.
|
|
277
|
+
const blockout = tasks.find((t) => roles?.[t.role]?.lane === 'preview')
|
|
278
|
+
if (blockout && !(blockout.role === 'builder' && blockout.makesCameras === true)) {
|
|
279
|
+
errors.push(`${blockout.id} is the first task in the preview lane; it must be a builder blockout with makesCameras true.`)
|
|
280
|
+
}
|
|
281
|
+
if (!tasks.some((t) => t.role === 'builder' && t.makesCameras === true)) errors.push('No task makes the cameras: the first preview task is a builder blockout with makesCameras true.')
|
|
282
|
+
const camerasTask = tasks.find((t) => t.role === 'builder' && t.makesCameras === true)
|
|
283
|
+
if (camerasTask && !cycle) {
|
|
284
|
+
for (const t of tasks) {
|
|
285
|
+
if ((t.role === 'artist' || t.role === 'qa') && !upstream(b, t.id).has(camerasTask.id)) errors.push(`${t.id} (${t.role}) must depend on the blockout ${camerasTask.id}.`)
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// The placements: the blockout stands a stand-in at each, and every
|
|
290
|
+
// modelled asset takes over one of them, so the director can put it in
|
|
291
|
+
// the game the moment it is made.
|
|
292
|
+
const placed = new Map()
|
|
293
|
+
for (const t of tasks) {
|
|
294
|
+
if ((t.placements ?? []).length && t !== camerasTask) errors.push(`${t.id} declares placements; only the blockout (the task that makes the cameras) does.`)
|
|
295
|
+
}
|
|
296
|
+
for (const p of camerasTask?.placements ?? []) {
|
|
297
|
+
if (!PLACEMENT_ID.test(p.id)) errors.push(`The placement "${p.id}" of ${camerasTask.id} must be an id the code adds a stand-in under (a letter, then letters, digits, - or _).`)
|
|
298
|
+
if (placed.has(p.id)) errors.push(`${camerasTask.id} declares the placement ${p.id} twice.`)
|
|
299
|
+
placed.set(p.id, null)
|
|
300
|
+
}
|
|
301
|
+
for (const t of tasks.filter((x) => x.role === 'modeller')) {
|
|
302
|
+
if (!t.placement) {
|
|
303
|
+
errors.push(`${t.id} (modeller) names no placement: give it the blockout's placement its model takes over${camerasTask ? ` (${camerasTask.id} declares ${(camerasTask.placements ?? []).map((p) => p.id).join(', ') || 'none yet'})` : ''}.`)
|
|
304
|
+
continue
|
|
305
|
+
}
|
|
306
|
+
if (!placed.has(t.placement)) errors.push(`${t.id} stands at the placement "${t.placement}", which the blockout does not declare; add it to ${camerasTask?.id ?? 'the blockout'}'s placements.`)
|
|
307
|
+
else if (placed.get(t.placement)) errors.push(`${placed.get(t.placement)} and ${t.id} both stand at the placement ${t.placement}; one model per placement.`)
|
|
308
|
+
else placed.set(t.placement, t.id)
|
|
309
|
+
}
|
|
310
|
+
for (const t of tasks) if (t.role !== 'modeller' && t.placement) errors.push(`${t.id} (${t.role}) names a placement; only a modeller task's model stands at one.`)
|
|
311
|
+
|
|
312
|
+
// How each modelled asset is made: chosen by the plan, checked here
|
|
313
|
+
// against what can run, never chosen here.
|
|
314
|
+
for (const t of tasks) {
|
|
315
|
+
if (t.role !== 'modeller') {
|
|
316
|
+
if (t.method || t.fallback) errors.push(`${t.id} (${t.role}) has a method; only a modeller task's asset is made by one.`)
|
|
317
|
+
continue
|
|
318
|
+
}
|
|
319
|
+
if (!t.method) {
|
|
320
|
+
if (methods) errors.push(`${t.id} (modeller) does not say how its asset is made: give method (how, why, and the subject and providers it needs), chosen from the capability list.`)
|
|
321
|
+
continue
|
|
322
|
+
}
|
|
323
|
+
errors.push(...methodErrors(t, t.method, { caps: methods, brief }))
|
|
324
|
+
if (t.fallback) errors.push(...methodErrors(t, t.fallback, { caps: methods, brief, fallback: true }))
|
|
325
|
+
for (const m of [t.method, t.fallback].filter(Boolean)) if (declinePaid && usesPictures(m)) errors.push(`${t.id} makes its asset by ${m.how}, which is paid, but the creator declined paid tools.`)
|
|
326
|
+
}
|
|
327
|
+
for (const [id, maker] of placed) if (!maker) errors.push(`No modeller task stands at the placement ${id}; give it one, or leave it out of the placements (a stand-in no model takes over stays a stand-in).`)
|
|
328
|
+
|
|
329
|
+
// Checks.
|
|
330
|
+
const cameraIds = new Set((brief?.cameras ?? []).map((c) => c.id))
|
|
331
|
+
const referenceCameras = new Set((brief?.cameras ?? []).filter((c) => c.purpose === 'reference').map((c) => c.id))
|
|
332
|
+
const subjectIds = new Set((brief?.subjects ?? []).map((x) => x.id))
|
|
333
|
+
const integration = [...tasks].reverse().find((t) => t.role === 'builder')
|
|
334
|
+
for (const t of tasks) {
|
|
335
|
+
const checks = (t.accept?.checks ?? []).map(normalizeCheck)
|
|
336
|
+
if (t.role !== 'qa' && !checks.some((c) => !HYGIENE.has(c.kind))) errors.push(`${t.id} has no tool check; every task but QA needs at least one.`)
|
|
337
|
+
// A preview check on a task outside the preview lane waits for that lane,
|
|
338
|
+
// which a builder or an artist holds for its whole task.
|
|
339
|
+
const lane = roles?.[t.role]?.lane
|
|
340
|
+
if (lane && lane !== 'preview') {
|
|
341
|
+
const looks = [...new Set(checks.filter((c) => PREVIEW_KINDS.has(c.kind)).map((c) => c.kind))]
|
|
342
|
+
if (looks.length) errors.push(`${t.id} (${t.role}, the ${lane} lane) has ${looks.join(', ')} checks, which use the preview; leave those to the tasks in the preview lane (the final gate builds and runs the whole game).`)
|
|
343
|
+
}
|
|
344
|
+
if (t.role === 'modeller' && !checks.some((c) => c.kind === 'asset') && !(t.owns ?? []).some((g) => literal(g) && /^assets\/.+\.(glb|gltf)$/i.test(relPath(g)))) {
|
|
345
|
+
errors.push(`${t.id} (modeller) has no asset check: own the asset's .glb by its path, or give an asset check for it.`)
|
|
346
|
+
}
|
|
347
|
+
// The critic is the judge of how the work looks: every task whose work is
|
|
348
|
+
// seen (an artist's, a modeller's, the blockout's forms and framing, the
|
|
349
|
+
// integration's whole picture) needs criteria for it to judge.
|
|
350
|
+
const seen = t.role === 'artist' || t.role === 'modeller' || (t.role === 'builder' && (t.makesCameras === true || t === integration))
|
|
351
|
+
if (seen && !(t.accept?.critic ?? []).length) errors.push(`${t.id} (${t.makesCameras ? 'the blockout' : t === integration && t.role === 'builder' ? 'the last builder task' : t.role}) has no critic criteria; give one to ${limits?.criteriaPerTask ?? 6}, each checkable from a picture.`)
|
|
352
|
+
for (const c of checks) {
|
|
353
|
+
if (!catalogue.includes(c.kind)) errors.push(`${t.id}: the check kind "${c.kind}" is not in the catalogue (${catalogue.join(', ')}).`)
|
|
354
|
+
for (const cam of [...(c.cameras ?? []), ...(c.camera ? [c.camera] : [])]) if (!cameraIds.has(cam)) errors.push(`${t.id}: the check ${c.id} names the camera "${cam}", which the brief does not have.`)
|
|
355
|
+
// A play check's steps are nw_play's input, read as the gate will read
|
|
356
|
+
// them: a shape nw_play refuses makes a task no role can pass, since
|
|
357
|
+
// the board's checks are not the role's to change.
|
|
358
|
+
if (c.kind === 'play' && Array.isArray(c.steps)) {
|
|
359
|
+
const played = playParams({ steps: c.steps, frames: 0 })
|
|
360
|
+
if (!played.ok) errors.push(`${t.id}: the play check ${c.id} is not an input nw_play takes: ${played.error}`)
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
for (const cr of t.accept?.critic ?? []) {
|
|
364
|
+
if (cr.camera && !cameraIds.has(cr.camera)) errors.push(`${t.id}: the criterion ${cr.id} names the camera "${cr.camera}", which the brief does not have.`)
|
|
365
|
+
if (cr.subject && !subjectIds.has(cr.subject)) errors.push(`${t.id}: the criterion ${cr.id} names the subject "${cr.subject}", which the brief does not have${subjectIds.size ? ` (${[...subjectIds].join(', ')})` : ''}.`)
|
|
366
|
+
// A reading of the picture under the confidence rule never becomes a criterion.
|
|
367
|
+
const leans = citesAdvisory(cr.text, facts, { reference: referenceCameras.has(cr.camera) })
|
|
368
|
+
if (leans.length) errors.push(`${t.id}: the criterion ${cr.id} stands on the reference's ${leans.join(' and ')}, which ${leans.length === 1 ? 'reads' : 'read'} under 0.5 confidence (advisory): judge what the picture clearly shows instead.`)
|
|
369
|
+
}
|
|
370
|
+
// The forms that matter most are judged against what the picture shows of them.
|
|
371
|
+
const hero = t.role === 'modeller' && checks.some((c) => c.kind === 'asset' && c.hero === true)
|
|
372
|
+
if (subjectIds.size && (t.makesCameras === true || hero || (t.role === 'builder' && t === integration)) && !(t.accept?.critic ?? []).some((cr) => subjectIds.has(cr.subject))) {
|
|
373
|
+
errors.push(`${t.id} (${t.makesCameras ? 'the blockout' : hero ? 'a hero model' : 'the last builder task'}) has no criterion tied to a brief subject: give one at least (subject: one of ${[...subjectIds].join(', ')}), judged against that subject's crop of the reference.`)
|
|
374
|
+
}
|
|
375
|
+
const most = limits?.criteriaPerTask ?? 6
|
|
376
|
+
if ((t.accept?.critic ?? []).length > most) errors.push(`${t.id} has ${(t.accept?.critic ?? []).length} critic criteria; at most ${most}.`)
|
|
377
|
+
if (!Number.isInteger(t.roundLimit) || t.roundLimit < 1 || t.roundLimit > (limits?.roundsPerTask ?? 4)) errors.push(`${t.id}: roundLimit ${t.roundLimit} must be 1 to ${limits?.roundsPerTask ?? 4}.`)
|
|
378
|
+
}
|
|
379
|
+
const rounds = tasks.reduce((s, t) => s + (Number(t.roundLimit) || 0), 0)
|
|
380
|
+
if (rounds > (limits?.attempts ?? 30)) errors.push(`The round limits add up to ${rounds}; at most ${limits?.attempts ?? 30} in all.`)
|
|
381
|
+
|
|
382
|
+
// Coverage.
|
|
383
|
+
const covered = new Set(tasks.flatMap((t) => t.covers ?? []))
|
|
384
|
+
for (const e of brief?.requestElements ?? []) if (!covered.has(e.id)) errors.push(`No task covers the request element ${e.id} ("${e.text}").`)
|
|
385
|
+
for (const m of vision?.moments ?? []) if (!covered.has(m.id)) errors.push(`No task covers the signature moment ${m.id} ("${m.label}").`)
|
|
386
|
+
|
|
387
|
+
// Interfaces.
|
|
388
|
+
const kinds = new Map()
|
|
389
|
+
for (const inf of board?.interfaces ?? []) {
|
|
390
|
+
if (kinds.has(inf.kind)) errors.push(`${kinds.get(inf.kind)} and ${inf.id} are both ${inf.kind}; one seam takes one interface of each kind.`)
|
|
391
|
+
kinds.set(inf.kind, inf.id)
|
|
392
|
+
if (inf.kind === 'materials') for (const n of inf.names ?? []) if (!/^[A-Za-z_$][\w$]*$/.test(n)) errors.push(`The material name "${n}" of ${inf.id} must be a code name (letters, digits, _).`)
|
|
393
|
+
const producer = byId.get(inf.producer)
|
|
394
|
+
if (!producer) {
|
|
395
|
+
errors.push(`The interface ${inf.id} names the producer ${inf.producer}, which is not on the board.`)
|
|
396
|
+
continue
|
|
397
|
+
}
|
|
398
|
+
if (producer.interface !== inf.id) errors.push(`${inf.producer} produces ${inf.id}, so its interface field must say "${inf.id}".`)
|
|
399
|
+
if (!(producer.owns ?? []).some((g) => matches(g, inf.module))) errors.push(`${inf.producer} must own ${inf.module}, the module of ${inf.id}.`)
|
|
400
|
+
const seam = SEAM_PATHS[inf.kind]
|
|
401
|
+
if (seam && relPath(inf.module).split('/').slice(0, -1).join('/') !== seam.split('/').slice(0, -1).join('/')) {
|
|
402
|
+
errors.push(`The module of ${inf.id} must sit beside its seam ${seam}.`)
|
|
403
|
+
}
|
|
404
|
+
if (seam && relPath(inf.module) === seam) errors.push(`The module of ${inf.id} is the seam itself; it must be its own file beside ${seam}.`)
|
|
405
|
+
// The sound role writes one module, and its checks bundle that one.
|
|
406
|
+
if (inf.kind === 'audio' && relPath(inf.module) !== SOUND_MODULE) errors.push(`The module of ${inf.id} must be ${SOUND_MODULE}, the module the sound role writes and its checks bundle.`)
|
|
407
|
+
// A consumer imports the seam, which builds from the start: it need not
|
|
408
|
+
// wait for the producer, and a producer that fails never blocks it.
|
|
409
|
+
for (const c of inf.consumers ?? []) if (!byId.has(c)) errors.push(`The interface ${inf.id} names the consumer ${c}, which is not on the board.`)
|
|
410
|
+
}
|
|
411
|
+
for (const t of tasks) if (t.interface && !(board?.interfaces ?? []).some((i) => i.id === t.interface)) errors.push(`${t.id} produces the interface ${t.interface}, which the board does not list.`)
|
|
412
|
+
|
|
413
|
+
// Paid generation.
|
|
414
|
+
for (const p of board?.paid ?? []) {
|
|
415
|
+
if (declinePaid) errors.push(`The board has a paid ${p.provider} generation, but the creator declined paid tools.`)
|
|
416
|
+
if (!['meshy', 'fal'].includes(p.provider)) errors.push(`The paid line names "${p.provider}", which is not a known provider (meshy, fal).`)
|
|
417
|
+
if (!byId.has(p.for) || byId.get(p.for).role !== 'modeller') errors.push(`The paid ${p.provider} line is for ${p.for}, which must be a modeller task.`)
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// QA comes after the game it plays.
|
|
421
|
+
for (const t of tasks.filter((x) => x.role === 'qa')) {
|
|
422
|
+
if (integration && !cycle && !upstream(b, t.id).has(integration.id)) errors.push(`${t.id} (QA) must depend on the last builder task, ${integration.id}.`)
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// The palette's colours are hex.
|
|
426
|
+
for (const c of brief?.palette ?? []) if (!HEX.test(c.hex)) errors.push(`The brief's palette colour ${c.hex} is not #rrggbb.`)
|
|
427
|
+
return errors
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/** Whether a dependency lets its task start: its work is in the game, or it
|
|
431
|
+
* reaches the game through the director and has ended either way. */
|
|
432
|
+
const satisfies = (dep) => !!dep && (DONE.has(dep.status) || (throughSeam(dep) && ENDED.has(dep.status)))
|
|
433
|
+
|
|
434
|
+
/** The tasks that can start now: waiting, with every dependency satisfied. */
|
|
435
|
+
export function readyTasks(board) {
|
|
436
|
+
const byId = new Map(board.tasks.map((t) => [t.id, t]))
|
|
437
|
+
return board.tasks.filter((t) => (t.status === 'waiting' || t.status === 'ready') && (t.deps ?? []).every((d) => satisfies(byId.get(d))))
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/** The dependencies that keep a task from ever starting: one whose work the
|
|
441
|
+
* task needs (not through a seam) that failed, was blocked or skipped. */
|
|
442
|
+
export function blockersOf(board, task) {
|
|
443
|
+
const byId = new Map(board.tasks.map((t) => [t.id, t]))
|
|
444
|
+
const dead = new Set(['failed', 'blocked', 'skipped', 'stopped'])
|
|
445
|
+
return (task.deps ?? []).filter((d) => dead.has(byId.get(d)?.status) && !throughSeam(byId.get(d)))
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/** Tasks that can never start: a dependency they need failed, was blocked or skipped. */
|
|
449
|
+
export function blockedTasks(board) {
|
|
450
|
+
return board.tasks.filter((t) => t.status === 'waiting' && blockersOf(board, t).length > 0)
|
|
451
|
+
}
|