gooseworks 0.4.1 → 0.4.4

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.
Files changed (84) hide show
  1. package/README.md +43 -11
  2. package/dist/commands/doctor.d.ts +29 -5
  3. package/dist/commands/doctor.d.ts.map +1 -1
  4. package/dist/commands/doctor.js +107 -63
  5. package/dist/commands/doctor.js.map +1 -1
  6. package/dist/commands/fetch.d.ts +1 -0
  7. package/dist/commands/fetch.d.ts.map +1 -1
  8. package/dist/commands/fetch.js +64 -29
  9. package/dist/commands/fetch.js.map +1 -1
  10. package/dist/commands/install.d.ts.map +1 -1
  11. package/dist/commands/install.js +37 -4
  12. package/dist/commands/install.js.map +1 -1
  13. package/dist/commands/login.d.ts.map +1 -1
  14. package/dist/commands/login.js +8 -3
  15. package/dist/commands/login.js.map +1 -1
  16. package/dist/commands/skills.d.ts +34 -0
  17. package/dist/commands/skills.d.ts.map +1 -0
  18. package/dist/commands/skills.js +109 -0
  19. package/dist/commands/skills.js.map +1 -0
  20. package/dist/commands/update.d.ts.map +1 -1
  21. package/dist/commands/update.js +17 -6
  22. package/dist/commands/update.js.map +1 -1
  23. package/dist/commands/video-local.d.ts +9 -0
  24. package/dist/commands/video-local.d.ts.map +1 -0
  25. package/dist/commands/video-local.js +83 -0
  26. package/dist/commands/video-local.js.map +1 -0
  27. package/dist/commands/video-save.d.ts +3 -0
  28. package/dist/commands/video-save.d.ts.map +1 -0
  29. package/dist/commands/video-save.js +83 -0
  30. package/dist/commands/video-save.js.map +1 -0
  31. package/dist/index.js +7 -0
  32. package/dist/index.js.map +1 -1
  33. package/dist/lib/video-local-captions.d.ts +83 -0
  34. package/dist/lib/video-local-captions.d.ts.map +1 -0
  35. package/dist/lib/video-local-captions.js +261 -0
  36. package/dist/lib/video-local-captions.js.map +1 -0
  37. package/dist/lib/video-local-runtime.d.ts +8 -0
  38. package/dist/lib/video-local-runtime.d.ts.map +1 -0
  39. package/dist/lib/video-local-runtime.js +201 -0
  40. package/dist/lib/video-local-runtime.js.map +1 -0
  41. package/dist/lib/video-save-mcp.d.ts +9 -0
  42. package/dist/lib/video-save-mcp.d.ts.map +1 -0
  43. package/dist/lib/video-save-mcp.js +162 -0
  44. package/dist/lib/video-save-mcp.js.map +1 -0
  45. package/dist/lib/video-save.d.ts +77 -0
  46. package/dist/lib/video-save.d.ts.map +1 -0
  47. package/dist/lib/video-save.js +440 -0
  48. package/dist/lib/video-save.js.map +1 -0
  49. package/dist/skills/custom-video-skill.d.ts +3 -0
  50. package/dist/skills/custom-video-skill.d.ts.map +1 -0
  51. package/dist/skills/custom-video-skill.js +6 -0
  52. package/dist/skills/custom-video-skill.js.map +1 -0
  53. package/dist/skills/installer.d.ts +12 -6
  54. package/dist/skills/installer.d.ts.map +1 -1
  55. package/dist/skills/installer.js +41 -15
  56. package/dist/skills/installer.js.map +1 -1
  57. package/dist/skills/master-skill.d.ts +26 -10
  58. package/dist/skills/master-skill.d.ts.map +1 -1
  59. package/dist/skills/master-skill.js +1534 -286
  60. package/dist/skills/master-skill.js.map +1 -1
  61. package/dist/skills/package-freshness.d.ts +16 -0
  62. package/dist/skills/package-freshness.d.ts.map +1 -0
  63. package/dist/skills/package-freshness.js +36 -0
  64. package/dist/skills/package-freshness.js.map +1 -0
  65. package/dist/skills/releases.d.ts +12 -0
  66. package/dist/skills/releases.d.ts.map +1 -0
  67. package/dist/skills/releases.js +152 -0
  68. package/dist/skills/releases.js.map +1 -0
  69. package/dist/skills/routes.d.ts.map +1 -1
  70. package/dist/skills/routes.js +13 -1
  71. package/dist/skills/routes.js.map +1 -1
  72. package/dist/utils/browser-preflight.d.ts +29 -0
  73. package/dist/utils/browser-preflight.d.ts.map +1 -0
  74. package/dist/utils/browser-preflight.js +338 -0
  75. package/dist/utils/browser-preflight.js.map +1 -0
  76. package/package.json +2 -2
  77. package/skills/goose-ads/SKILL.md +124 -16
  78. package/skills/goose-product-photos/SKILL.md +55 -3
  79. package/skills/goose-video/SKILL.md +369 -433
  80. package/skills/goose-video-local/SKILL.md +1405 -0
  81. package/skills/gooseworks/SKILL.md +200 -13
  82. package/skills/make-custom-video/SKILL.md +490 -0
  83. package/skills/manifest.json +12 -0
  84. package/skills/routes.json +15 -1
@@ -1,11 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RENDER_UPDATE_KEY = exports.RENDER_OPEN_ARGS = exports.RENDER_ROW_TOOL = void 0;
3
4
  exports.getEntrySkills = getEntrySkills;
4
5
  exports.getEntrySkillNames = getEntrySkillNames;
5
6
  exports.getMasterSkillContent = getMasterSkillContent;
6
7
  exports.getGooseAdsSkillContent = getGooseAdsSkillContent;
7
8
  exports.getGooseVideoSkillContent = getGooseVideoSkillContent;
9
+ exports.getGooseVideoLocalSkillContent = getGooseVideoLocalSkillContent;
8
10
  exports.getGooseProductPhotosSkillContent = getGooseProductPhotosSkillContent;
11
+ exports.getMakeCustomVideoSkillContent = getMakeCustomVideoSkillContent;
9
12
  /**
10
13
  * The CLI installs two vendored ENTRY skills into ~/.agents/skills/:
11
14
  * - `gooseworks` — the PARENT router (getMasterSkillContent): GTM/data toolkit
@@ -19,15 +22,210 @@ exports.getGooseProductPhotosSkillContent = getGooseProductPhotosSkillContent;
19
22
  * Sibling domain skills NOT vendored here (fetched live from goose-skills):
20
23
  * - `goose-graphics` — charts/slides/infographics/branded visuals. Installed via
21
24
  * `gooseworks install --with goose-graphics` or fetched on demand.
22
- * - `goose-video` — video ad remix: fetches the per-format recipe by slug,
23
- * renders LOCALLY (Playwright + ffmpeg + media proxies), mirrors a script for
24
- * in-app review, saves the MP4 back over MCP (getGooseVideoSkillContent).
25
+ *
26
+ * Video (vendored here, GOOSE-3677):
27
+ * - `goose-video` — the front door for a new video ad: brand → goal →
28
+ * format table → machine check → project → hand off to goose-video-local
29
+ * (getGooseVideoSkillContent). The only full copy of that body.
30
+ * - `goose-video-local` — render an existing app project/batch LOCALLY
31
+ * (Playwright + ffmpeg + media proxies) (getGooseVideoLocalSkillContent).
25
32
  *
26
33
  * Recipe skills (remix-graphic-ad-from-reference, brand-research, meta-ads-analyzer,
27
34
  * …) are NOT vendored here — they live in goose-skills and are fetched live on
28
- * demand via `gooseworks fetch <slug>`, so they're always current.
35
+ * demand from the connected catalog; saved packages retain their recorded hashes.
29
36
  */
30
37
  const routes_1 = require("./routes");
38
+ const custom_video_skill_1 = require("./custom-video-skill");
39
+ const STORED_FOOTAGE_GUIDANCE = "\n## Use uploaded footage\n\nWhen the customer asks to use existing footage, check the actual advertised schemas. Use `media_search` with purpose `production`, kind `video`, the brand and current project when needed. Omit query spend for free retrieval. Read facts/scenes with `media_analyze`, then use `media_excerpt` action `inspect` to review actual bounded frames and timed transcript before selecting. A description or thumbnail URL alone is not visual review.\n\nFreeze `source_excerpt:{asset_id,analysis_revision,scene_id,start_ms,end_ms,audio_mode}`. Revision is the original-byte SHA, scene may be null for a known user trim, bounds use integer milliseconds, and audio is original or muted. Call `media_excerpt` action `attach` with that exact selection and a stable idempotency key. The returned project remains unfinished and unapproved. Open its existing Studio review; preserve user locks and requested format, and keep footage separate from image packshot indexes. An incompatible format requires an explicit choice before changing it.\n\nFor custom production, fetch the current shared `video-production-harness` and follow script/ingredient gates. Download the verified original and trim its exact selected window at normal speed with the approved audio. Recheck current revision and production permission before consumption and final upload/completion. Save excerpt lineage in plan and ingredient readback. Missing optional semantics does not require another upload; known user-selected stored footage remains usable. Research and competitor references never become production footage. Selected originals require no paid generation; only newly generated/replaced ingredients consume the approved budget.\n";
40
+ /**
41
+ * How every entry skill talks to the customer. Shared so the five skills can't
42
+ * drift. The customer is a marketer or founder, not an engineer: everything the
43
+ * skills say about tools, fields, polling and pipeline steps is for the agent,
44
+ * and a run that narrated it ("checking the media-proxy helpers for voiceover
45
+ * timestamps and lipsync", "generated with gpt-image-2") read as noise.
46
+ */
47
+ const SKILL_FRESHNESS = `## Use current instructions for new work
48
+
49
+ Before a new task in a terminal host, run \`gooseworks skills status\` once. It compares the
50
+ installed entry files, running CLI and published npm release. An older CLI needs a package
51
+ upgrade before \`gooseworks update\`; update alone only uses that CLI's bundled instructions.
52
+ Preserve local edits or unknown install provenance. Review/back up before explicitly replacing
53
+ modified files; never quietly reinstall over them. If the release check is unavailable, report
54
+ that freshness is unknown rather than claiming the local copy is latest.
55
+
56
+ For a new recipe run, fetch its package from the connected catalog. Retain the returned
57
+ \`version\` / \`contentHash\` and every dependency's hash with the saved package. When reusing a
58
+ saved fetch JSON, \`gooseworks fetch <slug> --saved-package <file>\` returns the current package
59
+ and a hash comparison without changing that file. With MCP, if the advertised \`catalog_fetch\`
60
+ schema accepts them, send \`saved_content_hash\` and \`saved_dependency_hashes\`; otherwise fetch
61
+ normally and compare the returned hashes yourself. Missing hashes mean unknown, not current.
62
+ The server cannot inspect a client's saved files; hash metadata does not certify later edits.
63
+ Fetch current packages into a new run directory and report stale saved instructions. Preserve
64
+ an existing approved run's recorded package; changing that harness requires a reviewed change
65
+ and approval before spending. Hosted installed snapshots use the existing Skills Update action.
66
+ Skill content and a host's cached MCP tool schemas are separate: refreshing one does not refresh
67
+ the other. Check the actual advertised tools before using new fields.`;
68
+ const CUSTOMER_TALK = `## How to talk to the customer (applies to every message you send them)
69
+
70
+ The customer is a marketer or founder, not an engineer. Everything in this skill about tools,
71
+ fields, files, polling, models and pipeline steps is for YOU. Never pass it on to them.
72
+
73
+ - **Say what they get and what they need to decide, never how it's made.**
74
+ Bad: "Checking the media-proxy helpers for voiceover timestamps and lipsync." / "Generated with
75
+ gpt-image-2 at high quality, mouth closed, passes QC."
76
+ Good: "Recording the voices now." / "Here are your two hosts."
77
+ - **Never mention** tool, file or field names, ids, JSON, commands, scripts, installed software,
78
+ uploads, model or vendor names, timings in seconds or frames, retries, polling, internal statuses
79
+ or your own quality checks. Fix what you can quietly. If they ask how something works, explain it
80
+ simply.
81
+ - **Update them only at milestones they care about**: choices confirmed, script and voices done,
82
+ visuals done, ready to review, finished. One short line each, then stay quiet until the next
83
+ milestone. No update for setup, downloads, uploads or saving.
84
+ - **Money is in credits, with a number**: "the full video uses about N credits". Never "the cheap
85
+ pieces" or "the expensive render".
86
+ - **Problems:** say what it means for them and what they can do, in one or two sentences. No error
87
+ codes or stack traces. Only raise a problem that changes something for them.
88
+ - **Use their words**: script, voice, hook, scene, host, ending, logo, the product shot.
89
+ - **No filler**: no "Great question!", "Certainly!", "I hope this helps!", no restating what they
90
+ just said at length.
91
+
92
+ Example. Instead of a dozen lines about render tools, scripts, uploads and portraits, send:
93
+ "Got it: warm tone, home podcast studio, Brielle as the skeptic and Mark as the believer." then
94
+ "Script and voices are done (about 34 seconds)." then "Ready for you to review: the script, voices,
95
+ both hosts and the ending. You can also review your recipe ingredients in the app: <link>. Say go
96
+ here and I'll make the full video (about N credits)."
97
+
98
+ ${SKILL_FRESHNESS}`;
99
+ const ENVIRONMENT_IDENTITY = `## Keep the selected connection for the whole run
100
+
101
+ Call \`account_whoami\` on the connection that owns the brand/project before the first write.
102
+ Keep \`environment.name\` and the public \`environment.api_origin\` with this run. Respect the
103
+ user's selected production or staging connection. If multiple connections are available and
104
+ none was selected, resolve that once. Missing or unknown identity is uncertainty, not
105
+ permission to switch. Never infer the environment from credits, billing links or Node mode.
106
+
107
+ Reads, project creation, uploads, generation, polling and final updates all use that same
108
+ connection. If a production request fails, resume or report the failure on production;
109
+ never retry it on staging or recreate the project there. Before retrying a timed-out write,
110
+ read back the existing project or paid request on the selected connection.
111
+
112
+ Local/CLI proxy origin must match \`environment.api_origin\`. If it differs, use the MCP
113
+ relay on the selected connection (\`GW_MEDIA_VIA=mcp\`) before paid calls. Do not change
114
+ credentials or API origins to recover a failed write. An explicit user-requested move is
115
+ a separate operation, with the existing project and paid requests reconciled first.`;
116
+ const ASSET_READINESS = `## Check assets for the selected format before spending
117
+
118
+ For a template, read its structured \`asset_readiness\` from
119
+ \`video_catalog_list { kind: "formats", brand_id }\`. \`missing\` names gaps;
120
+ \`needs_review\` means suitability is unverified, including older recipes without
121
+ structured requirements. \`ready\` describes assets only, not script or budget approval.
122
+ For a custom video, derive requirements from its actual approved scenes.
123
+
124
+ Inspect candidate files for the chosen product and format. A catalog photo can contain
125
+ multiple objects, other products or a person; its existence or approved status does not
126
+ make it a standalone image of the selected product. Check object count, framing, readable
127
+ print and real image bytes. A service conversation has no automatic packshot requirement.
128
+
129
+ Reuse a suitable approved image first. A free crop or cutout is a new file: keep the
130
+ original, inspect the result and include it in the normal ingredient review. When no
131
+ usable input exists, explain the gap before generation. Estimate any paid preparation
132
+ separately before spending. Record the selected asset and inspection in the project
133
+ review set; do not add a separate approval round.`;
134
+ /** Same canonical capture policy for the router and both video entrypoints. */
135
+ const DURABLE_BRAND_CAPTURE = `## Save durable brand answers, then verify them
136
+
137
+ Read the selected brand with \`brand_read { brand_id, sections: ["summary", "kit", "products", "learnings", "onboarding"] }\`
138
+ (fallback: \`brand_get_context\` with the same sections). Keep founder answers, user corrections,
139
+ research and your own hypotheses distinct. Reuse matching saved answers; ask only about gaps.
140
+
141
+ When the user asks to remember a rule, answers a brand interview, or explicitly corrects a
142
+ standing fact, save that answer in the same turn. The capture request authorizes those answers;
143
+ do not ask for approval again. A direction for this one video stays in its brief. If the scope
144
+ is genuinely ambiguous, ask whether it applies to future videos before saving a standing rule.
145
+
146
+ Use the **live registered schema**. Where supported, call \`brand_update\` with
147
+ \`knowledge_intent: "user_correction"\` and \`user_statement\` containing the user's exact,
148
+ verbatim answer, not your paraphrase or researched text.
149
+ For an inference or suggested improvement, use \`knowledge_intent: "agent_proposal"\`. Show the
150
+ before/after change from your prior read and proposed value; retain the returned proposal IDs
151
+ and say the user must accept it in the app. Link only a review surface actually returned by a
152
+ tool; the compact \`knowledge_updates\` response does not itself contain a diff or URL.
153
+ A pending proposal is not a saved fact. Never call an unavailable
154
+ tool or silently relabel research or your inference as something the user said.
155
+
156
+ The safe structured shape is \`patch: { knowledge: { positioning?, audience?, voice?,
157
+ instructions?, brandType?, tagline?, valueProps? } }\`, using only fields present in the live
158
+ schema. Inferred rules/taste go in an \`instructions\` proposal with a rationale, never in
159
+ \`patch.facts\`. Prefix every video-only preference in that proposed text with "Video preference:"
160
+ so it remains production direction after acceptance. Preserve unrelated instructions when
161
+ proposing a merged replacement.
162
+
163
+ | User answer | Canonical write |
164
+ | --- | --- |
165
+ | Primary audience, positioning or voice correction | \`patch.knowledge: { audience/positioning/voice: <answer> }\` (one actual key). During onboarding, \`brand_onboarding { action: "review_research", review: { action: "correct", field, value } }\` writes these existing corrections with provenance. |
166
+ | Founder story, customer pains, objections, buying trigger or useful audience detail without a structured field | \`patch.facts: [{ kind: "insight", text }]\`; retain attribution such as "Founder reports: …" rather than turn a belief into a verified result. |
167
+ | Required wording or pronunciation | \`patch.facts: [{ kind: "must", text }]\`; pronunciation is exactly \`Pronounce "<term>" as "<say_as>"\`. |
168
+ | Forbidden claim, word or visual | \`patch.facts: [{ kind: "dont", text }]\`. |
169
+ | Durable visual, voice or pacing preference | \`patch.facts: [{ kind: "do", text }]\` for a preference; \`dont\` for an avoidance; \`template_hint\` for a preferred format. Prefix video-only preferences with "Video preference:". |
170
+
171
+ Facts are existing \`ad_brand_learning\` rows with user provenance; they are not a second profile.
172
+ Update a matching rule by its returned \`id\` instead of adding duplicates. Preserve unrelated
173
+ rules and the user's exact meaning. Only use the legacy facts shape for explicitly user-authored
174
+ answers when the live schema lacks intent fields; agent suggestions still need a proposal path.
175
+
176
+ **Claims and plans have separate gates.** A founder assertion or proof point is not an approved,
177
+ evidence-backed claim or consent to quote a customer. Use the existing evidence/claims and
178
+ operating-plan tools only if registered, following their proposal, evidence and confirmation
179
+ requirements. Never encode a spend cap, approver or emergency stop as a learning. If that write
180
+ path is missing, report the specific unsaved item and keep it pending for the supported review
181
+ surface; do not claim it was saved or create a parallel local profile.
182
+
183
+ After every write, **read back before saying saved**: use \`brand_read\` with \`kit\`, \`learnings\`
184
+ or \`onboarding\` as appropriate, or \`brand_onboarding { action: "status", brand_id }\` after an
185
+ onboarding answer. Verify the intended field/rule, its source and the absence of a conflicting
186
+ duplicate. A generic success response, pending proposal, ignored key or truncated result is not
187
+ proof. Report partial saves honestly. Carry the verified rules into the current task and the
188
+ routed skill; claims still pass their own safety gate.`;
189
+ /** The existing media library and learnings are sufficient for a minimal taste brief. */
190
+ const VIDEO_TASTE_CAPTURE = `## Video taste — reuse examples and preferences
191
+
192
+ When asked to capture video taste, or when the user volunteers a durable video preference,
193
+ first read the saved learnings and \`media_list { brand_id, scope: "brand", scope_id: brand_id,
194
+ tags: ["video-taste"], limit: 100 }\`. Follow \`next_cursor\` before deciding an example is absent.
195
+ Do not force a taste interview before an unrelated task or ask again for an existing preference.
196
+
197
+ Save what the user has already supplied first. Then ask only the missing useful question, for
198
+ example: "What do you like about this video—its pace, voice, captions, or look?" An inaccessible
199
+ link can still be saved as a link with the user's explanation; do not pretend you watched it.
200
+
201
+ - **Direct clip or video file:** register with \`media_upload { brand_id, scope: "brand",
202
+ scope_id: brand_id, kind: "video", source: { type: "url", url }, tags: ["video-taste", "reference-only"],
203
+ metadata: { purpose: "video_taste", source_url: url, provenance: "user", captured_at: <ISO timestamp>,
204
+ preference: <the user's explanation> } }\`. For a file use the live file/bytes upload flow and
205
+ \`media_confirm\` after a presigned upload. Registration of a URL does not copy or inspect it.
206
+ - **Instagram/post/page link:** the same registration with \`kind: "document"\`; it is a link
207
+ bookmark, not downloadable footage or an indexed transcript. Do not fabricate a direct clip URL.
208
+ - **Preferences:** save the user's reasons, likes and dislikes through the facts mapping above.
209
+ Read and preserve existing facts before updating one. Do not invent \`video_preferences\` or
210
+ new \`video_lab\` keys; the live kit patch accepts only its documented asset fields.
211
+ - **Deduplicate:** reuse a matching returned media row, then \`media_update\` its title/tags/metadata
212
+ if needed; preserve existing metadata and tags. Do not create another row for the same example.
213
+ Read back with \`media_list\` and \`brand_read\` learnings before claiming it was saved.
214
+ Check the returned row belongs to this brand: URL deduplication may return another brand's
215
+ existing row. Do not relabel that row or claim success unless the current brand's scoped read
216
+ actually returns it. Report an unsaved association if no supported attach path is available.
217
+
218
+ Never put third-party taste examples into kit reference images: \`kind: "reference"\` at brand
219
+ scope writes there. The tags and metadata above record purpose and provenance; **they do not
220
+ grant or enforce usage rights**. Study the structure, pacing and look only. Never use the example's
221
+ footage, face, product, testimonial or claims in a new ad without independently verified permission.
222
+
223
+ Read video-only entries prefixed \`Video preference:\` from both saved learnings and
224
+ \`kit.instructions\`, including accepted proposals. Keep them out of required or forbidden
225
+ dialogue. Build a brief from the verified readback: preferred pace, voice, caption treatment, visual style,
226
+ formats to favour/avoid, reference links and the user's reasons. Say what is still unknown.
227
+ Pass it with the brand rules into the existing video workflow. A one-video request overrides a
228
+ default for that project; it does not silently rewrite the brand's standing preference.`;
31
229
  /**
32
230
  * THE registry of entry skills (GOOSE-3190) — one list, four consumers:
33
231
  * - `gooseworks install` / `update` / login-refresh write exactly these dirs,
@@ -44,6 +242,8 @@ function getEntrySkills() {
44
242
  { name: 'gooseworks', content: getMasterSkillContent() },
45
243
  { name: 'goose-ads', content: getGooseAdsSkillContent() },
46
244
  { name: 'goose-video', content: getGooseVideoSkillContent() },
245
+ { name: 'goose-video-local', content: getGooseVideoLocalSkillContent() },
246
+ { name: 'make-custom-video', content: getMakeCustomVideoSkillContent() },
47
247
  { name: 'goose-product-photos', content: getGooseProductPhotosSkillContent() },
48
248
  ];
49
249
  }
@@ -68,6 +268,7 @@ description: >
68
268
  GooseWorks growth coworker and specialist-skill router. Research brands, customers, competitors,
69
269
  creators, markets, and prospects; analyze ads and performance; create ads, product photos,
70
270
  graphics, and video; search and scrape public web and social data; find and enrich leads.
271
+ Capture founder answers, brand rules, audience depth, and video taste in the existing brand.
71
272
  Use it as the single GooseWorks entry point for brand growth, B2B, sales, research, and GTM work.
72
273
  category: general
73
274
  version: 1.0.0
@@ -81,10 +282,16 @@ You have access to GooseWorks — an AI coworker with specialist skills for rese
81
282
 
82
283
  This skill is also the **parent router** for the GooseWorks family. Data/GTM work you handle here (see "How to Use"); specialized work you hand off to a dedicated \`goose-*\` skill.
83
284
 
285
+ ${CUSTOMER_TALK}
286
+
84
287
  ## Route to the right skill FIRST
85
288
 
86
289
  First apply the **Common company onboarding** gate below. Preserve the user's original request while onboarding, then continue with it as soon as onboarding is complete. Then load the brand context (**"Load the brand context FIRST"**, immediately below). After that, check whether the request belongs to a specialized domain. If so, **switch to that skill** instead of the data flow below:
87
290
 
291
+ For "interview me about the brand", "save our brand rules", "refine our audience", or "remember
292
+ our video taste", stay here and follow **Guided brand capture** below. This extends the current
293
+ brand and onboarding flow; it does not create another onboarding checklist.
294
+
88
295
  | If the user wants… | Route to | How |
89
296
  | --- | --- | --- |
90
297
  ${(0, routes_1.renderDomainRouteTable)()}
@@ -94,7 +301,7 @@ Examples — all of these route to \`goose-ads\`, not the data flow: "remix this
94
301
 
95
302
  ## Load the brand context FIRST (mandatory — before you route, and before you ask anything)
96
303
 
97
- **Call \`brand_get_context\` before the first substantive step of ANY task**, and before you route to a specialist skill. It is a cheap, read-only call that returns the brand's canonical facts:
304
+ **Call \`brand_read { brand_id, sections: ["summary", "kit", "products", "learnings", "onboarding"] }\` before the first substantive step of ANY task**, and before you route to a specialist skill. Older clients can use \`brand_get_context\` with the same sections only when that tool is advertised. It is a read-only call that returns the brand's canonical facts and saved rules:
98
305
 
99
306
  | It returns | Use it for |
100
307
  | --- | --- |
@@ -109,8 +316,8 @@ Then:
109
316
  1. **Pass what it returned INTO the routed skill.** When you hand off to \`goose-ads\`, \`goose-video\`, \`goose-product-photos\`, \`goose-graphics\`, or a fetched Brand Growth recipe, carry the voice / products / audience / positioning with you. Do **not** make the routed skill re-derive them, and do **not** re-run brand research when the context is already there.
110
317
  2. **Never re-ask the user for something the brand context already answers.** If a routed skill's own prose asks a question the context answers, the context wins — answer it yourself and move on. Ask only for what is genuinely missing or ambiguous.
111
318
  3. **If research status is not complete**, say so in one line, use what you have, and continue. Only run brand research when the context comes back empty or the user asks for it.
112
- 4. **If \`brand_get_context\` is unavailable** (no MCP connection), fall back to \`get_brand_kit\` for the selected brand and treat its fields the same way. If neither is available, tell the user the GooseWorks MCP connection is needed rather than guessing brand facts.
113
- 5. **Treat it as read-only.** Writing brand facts back is the reconciliation flow in \`goose-ads\` (ask first, then \`update_brand_kit\`) — not something this router does.
319
+ 4. **If \`brand_read\` is unavailable**, refresh the GooseWorks connection or tool list. An older connection may expose \`brand_get_context\` / \`get_brand_kit\`; use those only when actually advertised. Never require a legacy tool name or guess brand facts.
320
+ 5. **A read grants no write permission.** Save explicit durable answers/corrections with the capture policy below. Propose agent-derived changes for review; never overwrite confirmed knowledge with research or a guess.
114
321
 
115
322
  Never invent a brand fact. If it isn't in the brand context and the user hasn't said it, ask.
116
323
 
@@ -167,16 +374,53 @@ When onboarding returns a review link, show that single link and ask the user to
167
374
  Use the host's native question controls. Ask one short group at a time and rely on the live tool schema for accepted values.
168
375
 
169
376
  1. **Start** — If status returns \`start\`, ask for the company website or Apple App Store URL. Also offer the optional hero product URL and “Where do you do your work?” choices: Slack, WhatsApp, iMessage, Claude Code, Claude, Codex, and ChatGPT. Call \`action: "start"\`; server-side research begins immediately. If status returns \`select_brand\`, ask which company/client to use. Otherwise reuse the only brand automatically.
170
- 2. **Your coworker** — Ask what they want to name their Growth Coworker. A text-only client may keep the default avatar; do not block on an image. Save with \`action: "save_coworker"\`.
171
- 3. **Your company** — Use the returned \`company_draft\` as the starting point and ask the user to verify or edit: what they sell (\`marketCategory\`), where people buy (\`appPlatforms\`), primary customer, customer problem, promised outcome, and optional differentiator. Save with \`action: "save_company"\`.
172
- 4. **Your taste** — In a terminal or CLI host, use the returned \`taste_url\`: open it when the host supports opening links and always show one clickable **Choose your taste in GooseWorks** link. Ask the user to heart or skip ads on that page, click **Continue** or **Skip this**, return to the agent, and reply \`done\`. Do not print, enumerate, or summarize \`taste_deck\` in the terminal. After \`done\`, call \`brand_onboarding { action: "status" }\` again and follow the refreshed \`next_step\`. In a chat host that renders images, show only the one image attached by the tool and save each Love/Skip decision with \`action: "save_taste"\`; send \`complete: true\` after three hearts or an explicit skip.
173
- 5. **First campaign** — Ask **“What’s happening right now?”**: launch \`launch\`, promotion \`promo\`, seasonal moment \`seasonal\`, or nothing special \`nothing\`, plus an optional note. Call \`action: "propose_campaign"\`, show the returned editable card (name, objective, offer, audience, 2–3 angles, CTA, and product URL), and save edits with \`action: "save_campaign"\`. Send \`accept: true\` only after approval; acceptance can start the complimentary first creatives.
174
- 6. **Where you are** — Ask monthly ad spend (\`none\`, \`under_1k\`, \`1k_5k\`, \`5k_25k\`, \`25k_plus\`), annual revenue (\`under_1m\`, \`1m_10m\`, \`10m_100m\`, \`100m_plus\`), the 90-day goal, current channels (an empty list is a valid “nothing yet”), and at least one channel they are willing to use. Channel values: \`paid_social\`, \`search_ads\`, \`content\`, \`creators\`, \`seo\`, \`communities\`, \`referrals\`, \`partnerships\`, \`outbound\`, \`app_stores\`, \`other\`. Save with \`action: "save_progress"\`.
175
- 7. **Review** — Show the returned founder, researched, and inferred facts with their provenance. The user may correct positioning, audience, voice, value propositions, proof points, or competitors through \`action: "review_research"\`. Complete the review even when research is still running, failed, or sparse; never trap the user waiting for it.
176
- 8. **Channels** — If \`channel_connected\` is already true, this is complete automatically. Otherwise ask whether they want to connect Slack, WhatsApp, or iMessage later, or skip for now. An explicit skip is valid; call \`action: "complete_channels"\`.
377
+ 2. **Your coworker** — The current flow accepts the default coworker automatically. If an older session returns \`coworker\`, refresh \`status\`; do not introduce a naming/avatar question. Rename only when the user asks and the live tool supports it.
378
+ 3. **Your company** — Use the returned \`company_draft\` plus the user's existing answers. Ask only to verify missing or ambiguous details: what they sell (\`marketCategory\`), where people buy (\`appPlatforms\`), primary customer, customer problem, promised outcome, and optional differentiator. Monthly Meta ad spend belongs here when absent: \`none\`, \`under_10k\`, \`10k_50k\`, \`50k_150k\`, \`150k_plus\`, or \`not_sure\`. Save the merged required company object with \`action: "save_company", company: { … }\`; read \`status\` back.
379
+ 4. **Your taste** — In a terminal or CLI host, use the returned \`taste_url\`: open it when the host supports opening links and always show one clickable **Choose your taste in GooseWorks** link. Ask the user to heart or skip ads on that page, click **Continue** or **Skip this**, return to the agent, and reply \`done\`. Do not print, enumerate, or summarize \`taste_deck\` in the terminal. After \`done\`, call \`brand_onboarding { action: "status" }\` again and follow the refreshed \`next_step\`. In a chat host that renders images, show only the one image attached by the tool and save each Love/Skip decision with \`action: "save_taste", taste: { hearted_ids, skipped_ids, complete }\`; set \`taste.complete: true\` after three hearts or an explicit skip.
380
+ 5. **First campaign** — Ask **“What’s happening right now?”**: launch \`launch\`, promotion \`promo\`, seasonal moment \`seasonal\`, or nothing special \`nothing\`, plus an optional note. Call \`action: "propose_campaign"\`, show the returned editable card (name, objective, offer, audience, 2–3 angles, CTA, and product URL), and save edits with \`action: "save_campaign"\`. Send \`campaign.accept: true\` only after approval; acceptance can start the complimentary first creatives.
381
+ 6. **Review** — Show the returned founder, researched, and inferred facts with their provenance. The user may correct positioning, audience, voice, value propositions, proof points, or competitors through \`action: "review_research", review: { action: "correct", field, value }\`. A proof-point edit does not approve a claim. Complete with \`review: { action: "complete" }\` even when research is still running, failed, or sparse; never trap the user waiting for it.
382
+ 7. **Channels** — If \`channel_connected\` is already true, this is complete automatically. Otherwise ask whether they want to connect Slack, WhatsApp, or iMessage later, or skip for now. An explicit skip is valid; call \`action: "complete_channels"\`.
383
+
384
+ The former revenue / 90-day-goal / \`save_progress\` screen is retired. Do not insert it into
385
+ onboarding. Ask those human-only questions later only when the user's task needs them.
177
386
 
178
387
  Do not ask for role, discovery source, who makes creatives, who manages ads, or a separate “what do you want to do first?” menu. Those belonged to the retired CLI questionnaire. The task the user already asked for is their first task.
179
388
 
389
+ ## Guided brand capture
390
+
391
+ Use this when the user requests a founder interview, audience/rules capture, or video taste.
392
+ Keep their original task pending. Load the current brand first, compare it with information
393
+ already volunteered in this chat, and **save known information first** using the canonical
394
+ mapping below. Do not run a long questionnaire as a prerequisite for making an ad.
395
+
396
+ For facts needed by the task but absent from the read, call \`knowledge_search\` first if it is
397
+ registered. Use returned citations and states honestly: an empty, building or failed index is
398
+ not proof that the brand has no answer. Do not re-scrape or ask the founder for a fact already
399
+ answered by trustworthy saved knowledge.
400
+
401
+ Ask one short group of missing human-only facts at a time, in plain language, with the relevant
402
+ known answer in that same question. "Skip" or "not sure" is valid. Examples, **only for gaps**:
403
+
404
+ | Gap | Useful question |
405
+ | --- | --- |
406
+ | Founder origin or conviction | "What made you start this, and what do you believe that alternatives get wrong?" |
407
+ | Audience depth | "Who buys first, what problem pushes them to act, and what nearly stops them?" |
408
+ | Buying trigger or alternatives | "What happens just before they look for you, and what do they use instead?" |
409
+ | Rules | "What must we always say or show, and what must we never say or imply?" |
410
+ | Proof | "What evidence supports that result, and do we have permission to quote the customer?" Keep unsupported claims pending. |
411
+ | Video taste | "Share a video you like and what you would keep or avoid: pace, voice, captions, or look." |
412
+
413
+ Keep skipped or uncertain answers as gaps in the brief; do not save them as confirmed facts.
414
+ Save each answered group and read it back before the next group. Stop when the requested capture
415
+ is covered or the user skips; resume from canonical saved answers after interruption. Present a
416
+ short brief containing verified answers, attribution, pending proposals and remaining gaps, then
417
+ continue the original task. Review happens in this chat plus any proposal review link returned
418
+ by the tools. Do not promise an unavailable evidence, claims or plan write.
419
+
420
+ ${DURABLE_BRAND_CAPTURE}
421
+
422
+ ${VIDEO_TASTE_CAPTURE}
423
+
180
424
  ## Brand Growth discovery
181
425
 
182
426
  Brand Growth is a collection inside the normal skill catalog, not a command or installable pack. Use these known routes when relevant, while preserving all existing B2B, sales, research, lead-generation, and data behavior:
@@ -185,7 +429,7 @@ Brand Growth is a collection inside the normal skill catalog, not a command or i
185
429
  | --- | --- |
186
430
  ${(0, routes_1.renderBrandGrowthTable)()}
187
431
 
188
- Fetch the named public skill before following it. You already called \`brand_get_context\` — hand the brand's voice, products, audience, and positioning to the fetched skill instead of letting it re-derive or re-ask them. Provider helpers such as \`scrapecreators-api\` and \`transcript-intelligence\` are dependencies, not user-facing results.
432
+ Fetch the named public skill before following it. You already called \`brand_read\` — hand the brand's voice, products, audience, and positioning to the fetched skill instead of letting it re-derive or re-ask them. Provider helpers such as \`scrapecreators-api\` and \`transcript-intelligence\` are dependencies, not user-facing results.
189
433
 
190
434
  For a multi-part request, repeat this routing check before each new job. Fetch and follow the
191
435
  closest outcome skill first (for example, \`comment-mining\`, \`creator-profile-teardown\`, or
@@ -315,7 +559,7 @@ The \`gooseworks\` CLI sends authenticated requests (Bearer \`GOOSEWORKS_API_KEY
315
559
 
316
560
  ## Rules
317
561
 
318
- 0. **Call \`brand_get_context\` before anything else**, pass what it returns into whatever skill you route to, and never re-ask the user for a fact it already answers (see "Load the brand context FIRST").
562
+ 0. **Read the canonical brand context before substantive work**, pass what it returns into whatever skill you route to, and never re-ask the user for a fact it already answers (see "Load the brand context FIRST").
319
563
  1. **Consider a GooseWorks skill when it fits the task** — scraping, research, lead gen, enrichment, especially at scale, behind auth, or from a specific source. For a quick lookup your built-in tools are fine; use your judgement and pick the best tool for the user.
320
564
  2. **Before paid operations**, tell the user the estimated credit cost
321
565
  3. **If a \`gooseworks\` command exits with "Not logged in"**: tell the user to run \`npx gooseworks login\`
@@ -373,6 +617,8 @@ The GooseWorks ads skill. Two jobs:
373
617
  2. **Analyze ad performance** — fetch ad-analytics recipes from goose-skills on demand
374
618
  (these are unrelated to generation; see "Analyze / intelligence" below).
375
619
 
620
+ ${CUSTOMER_TALK}
621
+
376
622
  ## Prerequisite — the GooseWorks MCP server is REQUIRED
377
623
 
378
624
  Everything goes through the \`mcp__gooseworks__*\` tools. If they are not available, **stop and
@@ -382,7 +628,7 @@ no HTTP/file fallback — the REST ad endpoints are session-cookie-only and reje
382
628
  ## Start from the brand context — don't re-ask what it already answers
383
629
 
384
630
  If the \`gooseworks\` router handed you brand context, USE IT. If you were invoked directly, call
385
- \`brand_get_context\` first (falling back to \`get_brand_kit\` for the selected brand). It already
631
+ \`brand_read { brand_id, sections: ["summary","kit","products","learnings"] }\` first. It already
386
632
  answers most of what the flows below would otherwise ask the user:
387
633
 
388
634
  - **Which product to feature** → \`products[]\`. Offer the real catalog entries; never guess a
@@ -490,7 +736,7 @@ immediately.
490
736
  competitor ad or an image found online.
491
737
  - \`get_ad_project\` / \`append_project_message\` — inspect a creative / leave a note on its thread.
492
738
 
493
- ## Keep the brand kit in sync — reconcile, then update (ASK first)
739
+ ## Keep the brand kit in sync — reconcile, then save or propose
494
740
 
495
741
  The brand kit is the source of truth every generation reads. During ANY task, when the user
496
742
  **tells you something about the brand or asks to change something brand-level** — a different
@@ -498,24 +744,26 @@ tagline, audience, voice, a product's name/price/description, "our logo is X", "
498
744
  anymore", a new product photo — treat it as a possible kit update, don't just use it for this one
499
745
  ad and forget it:
500
746
 
501
- 1. **Check it against the kit.** Call \`get_brand_kit\` for the active brand and see whether what the user said
747
+ 1. **Check it against the kit.** Call \`brand_read\` with \`kit\` and \`learnings\` for the active brand and see whether what the user said
502
748
  matches, is missing from, or contradicts the kit.
503
749
  2. **If it's already in the kit and matches** — nothing to do; proceed.
504
- 3. **If it's new or different — ASK before writing.** Confirm in one line: *"Want me to update
505
- the brand kit so this sticks for future ads?"* Only persist on a yes (or when the user clearly
506
- asked you to change the brand). Don't silently mutate the kit, and don't nag on trivia.
507
- 4. **Persist with the write tools** (partial — only the fields you pass are touched; each edit is
508
- recorded as a user override that later re-research won't clobber):
509
- - \`update_brand_kit\` — structured brand fields.
510
- - \`upsert_brand_product\` / \`delete_brand_product\` — products.
511
- - \`add_brand_product_image\` / \`remove_brand_reference_image\` — product and reference photos.
750
+ 3. **If it's new or different**, persist an explicit request to correct or remember the brand
751
+ through the policy below; that request is already authorization. For an ambiguous one-ad
752
+ direction, ask once whether it should stick. Agent-derived suggestions become proposals.
753
+ 4. **Persist with the canonical write tools** (send only changed fields):
754
+ - \`brand_update\` with explicit user-correction intent — structured brand fields or products;
755
+ an inferred structured field uses agent-proposal intent instead. Follow the live schema.
756
+ - \`media_upload\` / \`media_update\` — the user's own product and reference photos.
512
757
  Inspect each live schema and send only the fields needed for the confirmed change.
513
- 5. **Confirm what changed** and continue the task. (Logo, colors, and fonts are owned by the
514
- backend research pass — prefer \`update_ad_brand\` / the research flow for those, not free text.)
758
+ 5. **Read back what changed** before saying saved, then continue the task. (Use the research
759
+ workflow for researched logo/colors/fonts; explicit user edits use only fields supported by
760
+ the canonical tool schema and the correction policy below.)
515
761
 
516
762
  This is the parity gap the app closes in-product: a brand fact the user gives mid-task should be
517
763
  able to flow back into the kit — with their ok — instead of being lost.
518
764
 
765
+ ${DURABLE_BRAND_CAPTURE}
766
+
519
767
  ## Picking source ads — use approved sources, not the retired catalog
520
768
 
521
769
  When the user wants to make ads but has NOT named a specific template (id/slug/Community
@@ -675,9 +923,10 @@ run through the \`gooseworks\` CLI (\`gooseworks fetch\` / \`gooseworks call\`),
675
923
  - **Treat competitor ads as inspiration** — never attest rights, imply ownership, or promise to
676
924
  copy a competitor's distinctive expression.
677
925
  - **Reconcile brand facts into the kit** — when the user states or changes something brand-level
678
- mid-task, check it against \`get_brand_kit\` and, with their ok, persist it via \`update_brand_kit\`
679
- / \`upsert_brand_product\` / \`add_brand_product_image\` so it sticks for future ads. Ask first;
680
- never silently mutate the kit.
926
+ mid-task, compare it with \`brand_read\`. Save explicitly authorized corrections through
927
+ \`brand_update\` with correction intent and the user's exact statement, or the user's own
928
+ images through \`media_upload\`; read back before saying saved. Proposed improvements stay
929
+ pending. Ask only when it is unclear whether a one-ad direction should apply to future ads.
681
930
  - **Record feedback** — when the user reacts to a generated image, inspect and call
682
931
  \`set_creative_feedback\` so the quality loop learns.
683
932
  - **Plan mode is opt-in** — only use the live approval option, then \`list_ad_approvals\` and
@@ -691,44 +940,293 @@ run through the \`gooseworks\` CLI (\`gooseworks fetch\` / \`gooseworks call\`),
691
940
  with the real error + step in \`details\`) so the team gets visibility. Still tell the user too.
692
941
  `;
693
942
  }
694
- /**
695
- * Returns the goose-video entry SKILL.md content (the `goose-video` entry skill).
696
- *
697
- * Unlike `goose-ads` (static images, generated 100% server-side via the remix
698
- * batch tools), VIDEO ads render LOCALLY in the user's own Claude Code: the app
699
- * pre-creates the project and hands the user a paste prompt; this skill fetches
700
- * the per-format recipe by slug from goose-skills, renders on the user's machine
701
- * (Playwright + ffmpeg + the GooseWorks media proxies), mirrors the script for a
702
- * free in-app review, then saves the finished MP4 back over MCP. The app is the
703
- * viewer + review surface. The `gooseworks` parent router hands video here; Claude
704
- * also loads it by description.
705
- */
943
+ /** Card-aware video entry. Shell execution and widget display are independent. */
706
944
  function getGooseVideoSkillContent() {
707
945
  return `---
708
946
  name: goose-video
709
947
  slug: goose-video
710
948
  description: >
711
- GooseWorks video ads — remix a video ad template (iMessage chat-reveal, more coming) into a
712
- branded video ad for the user's product. Renders LOCALLY on the user's machine (Playwright +
713
- ffmpeg + GooseWorks media proxies) and saves the finished MP4 back to the project over MCP.
714
- Use when the user says "make the video for project <id>", "for video batch <id>", references a
715
- video ad project/batch or template, or asks to remix a video ad. Unlike goose-ads (static images,
716
- generated server-side), video renders locally and reports progress + the result back through the
717
- gooseworks MCP tools.
949
+ Start a video ad in the same chat. Resolve the brand and suggest supported formats with a
950
+ picker or the returned text choices. An agent with a verified shell makes the video with
951
+ goose-video-local; a chat host hands the same project to the GooseWorks coworker. Review
952
+ one complete template plan and total credits before production. Custom videos retain two authenticated review gates in this chat.
718
953
  category: ads
719
- version: 0.3.0
954
+ version: 3.0.0
720
955
  author: GooseWorks
721
- tags: [gooseworks, ads, video, remix, imessage, local-render, byoa]
956
+ tags: [gooseworks, ads, video, local-render, coworker, chat]
722
957
  ---
723
958
 
724
- # GooseWorks Video Ads — local remix runtime
959
+ # GooseWorks Video Ads — choose, review, make
960
+
961
+ ${CUSTOMER_TALK}
962
+
963
+ ## Purpose
964
+
965
+ Resolve the brand, show supported formats and create one saved project. An agent with a verified
966
+ shell follows **\`goose-video-local\`**. A chat host delegates that same project to the GooseWorks
967
+ coworker, which renders in its sandbox. This is agent execution, not a recipe server-order API.
968
+
969
+ **Cards and execution are separate capabilities.** A terminal may render without drawing a
970
+ picker; a chat host may draw a picker while the coworker renders. Follow \`card.display_hint\`
971
+ and \`available_here\`, never a guess from the host's name. Template-remix review stays in this
972
+ chat. Custom videos use separate authenticated script and ingredient approvals in this same chat.
973
+ Studio is an optional review surface.
974
+
975
+ ## Custom videos: route before formats
976
+
977
+ For an original brief without a reference template, an Instagram reel/post URL or a direct video URL to study, fetch \`catalog_fetch { type: "skill", slug: "make-custom-video" }\` and follow it in this same session. It creates format:"custom", custom_mode:"generate" with the brief and optional reference_url. Growth executes in its managed sandbox; connected agents use their shell. Script and actual ingredients are reviewed and separately approved in the same chat before paid production; Studio is optional. Do not force a template choice or import the reference as a finished video.
978
+
979
+ ## Route first: is this a new video?
980
+
981
+ Hand off to **\`goose-video-local\`** now, and stop following this skill, for:
982
+
983
+ - an existing **project** id or a **video batch** id;
984
+ - the app's copy-for-Claude command (it names \`goose-video-local\`);
985
+ - "remix this video ad template" for a specific app template.
986
+
987
+ Use \`goose-video-local\` if it is installed; otherwise load it with
988
+ \`catalog_fetch { type: "skill", slug: "goose-video-local" }\` on the GooseWorks MCP (older clients:
989
+ \`fetch_skill("goose-video-local")\`). It reads the project first and says what to do with it.
990
+
991
+ When they ask **what** to make ("give me video ad ideas", "what angles should I use?", "what's
992
+ working for my competitors?"), fetch **\`ad-angle-miner\`** (\`catalog_fetch { type: "skill", slug: "ad-angle-miner" }\`,
993
+ using its advertised tools) and run it with the **video** output. It returns ranked
994
+ video ideas mapped to formats and hands the picked ones to \`goose-video-local\`.
995
+
996
+ Everything else, including "make me a video ad for <brand>", starts at step 1 below.
997
+
998
+ ${ENVIRONMENT_IDENTITY}
999
+
1000
+ ${ASSET_READINESS}
1001
+
1002
+ ## Inputs
1003
+
1004
+ - A brand, usually named in the request. Resolve it from the accessible brands; one brand needs no question.
1005
+ - The customer's goal, occasion, audience, selected angle and constraints when supplied; otherwise propose defaults from the verified kit.
1006
+ - The selected format's required assets. Presence does not prove suitability; uncertain assets remain “needs review.”
1007
+
1008
+ ${DURABLE_BRAND_CAPTURE}
1009
+
1010
+ ${VIDEO_TASTE_CAPTURE}
1011
+
1012
+ ## Composed Atoms
1013
+
1014
+ Use the live canonical schemas: brand_read, brand_create, video_catalog_list,
1015
+ video_project_upsert, video_project_read, catalog_fetch, goose_run_task and job_cancel.
1016
+ An old tool name in a recipe is not grounds for terminal-update advice in a chat host.
1017
+
1018
+ ## Paid media: images, clips, voice
1019
+
1020
+ **No FAL_KEY, ElevenLabs key or \`fal_client\` is ever needed.** Use
1021
+ \`data_post_provider { provider: "fal", path: <model id, e.g. "fal-ai/nano-banana/edit">, body: <model input>, project_id }\`
1022
+ then \`job_get { job_id }\`; voice/music use provider:"elevenlabs". Upload local inputs through
1023
+ media_upload first. **A missing key is never a blocker.** \`photos_generate\` is **not** a general
1024
+ image tool: it photographs physical catalog products only. Use goose-video-local for the
1025
+ runtime, paid approval, asset saving and quality checks.
1026
+
1027
+ ## Workflow
1028
+
1029
+ ### 1. Resolve the brand, quietly when you can
1030
+
1031
+ Call brand_read without brand_id to list accessible brands. Resolve the customer's name from
1032
+ actual returned names. One brand, or exactly one match: state it and continue. Several possible
1033
+ brands: show names and websites and ask once. No match: show accessible brands and offer to add
1034
+ one only when the customer asks and supplies its website; never guess the URL.
1035
+
1036
+ Read \`brand_read { brand_id, sections: ["summary","kit","products","learnings"] }\` before
1037
+ choosing a format. Reconcile explicit brand corrections through the durable capture rules.
1038
+ A direct video request does not require first-campaign acceptance. Follow any returned
1039
+ request-specific setup requirement; never mark research complete or accept a campaign to
1040
+ bypass setup. Keep the original request.
1041
+
1042
+ ### 2. Keep the goal and propose defaults
1043
+
1044
+ Never ask what the ad is for before showing formats. Keep the customer's exact direction.
1045
+ Otherwise propose defaults from the verified kit's products, audience, offer and voice. Show
1046
+ those defaults in the saved plan so any can be changed. Never invent proof or product facts.
1047
+ Idea requests still follow ad-angle-miner with the video output.
725
1048
 
726
- You produce **video** ad creative on the user's OWN machine and sync the result back to the
727
- GooseWorks app over MCP. This document is the **runtime contract** (auth, credits, the media
728
- proxies, data I/O, the review gate). A separate **recipe skill** — fetched per format — tells you
729
- *what to make* (the pieces, prompts, models, order of assembly).
1049
+ ### 3. Show the picker or its text fallback
730
1050
 
731
- **Division of authority — read both, but when they disagree THIS doc wins on the environment AND the
1051
+ Call \`video_catalog_list { kind: "formats", brand_id }\`. On the customer's computer, when you
1052
+ can actually execute shell commands, include \`client: { shell: true }\`; in a chat host omit
1053
+ that claim. Inside a coworker sandbox follow its reported capabilities, never claim to be the
1054
+ customer's computer. Respect requested limit and next_cursor for more item pages; the card may
1055
+ contain a full picker independently of the item page.
1056
+
1057
+ - **card.display_hint:"widget"**: the picker replaces a format table. Write at most one short
1058
+ acknowledgement, print no table or list of the formats, and wait for the selection.
1059
+ - **Otherwise**: print card.text_summary as returned. Without a card, show returned rows with
1060
+ names, faithful descriptions, needs and demo links, respecting the requested page size.
1061
+ Write "no demo yet" when absent. Never put links only in a question control.
1062
+ - A format whose card contradicts what they asked for is never Suggested. Never offer
1063
+ available_here:false as an executable choice. Relay not_available_here in one short line.
1064
+ - Missing required assets are missing; unknown suitability is “needs review.” Inspect the
1065
+ selected format's candidates before spending. Never promise an unverified asset is ready.
1066
+ - Template formats use **one plan, one approval with the total in credits**, not approval for
1067
+ each paid step. Custom videos retain separate authenticated script/ingredient/budget gates in this chat.
1068
+
1069
+ ### 4. Check this machine can render it
1070
+
1071
+ - **Chat host without a shell:** skip local checks and delegate an available format in Step 5.
1072
+ Never tell a chat host it needs Claude Code to start. Browser-only formats remain unavailable
1073
+ here; give computer setup guidance only if asked how to make one.
1074
+ - **Local shell:** run \`gooseworks doctor --no-browser\` for common setup (auth/MCP, Node 18+,
1075
+ ffmpeg with libx264 + libass, ffprobe). Then fetch the selected template and its capabilities,
1076
+ and install documented dependencies in its fetched folder. Do not guess a renderer from a
1077
+ format name. For each Node renderer using default Playwright Chromium, run
1078
+ \`gooseworks doctor --renderer-script "/absolute/path/to/the/fetched/scripts/record.js"\` with
1079
+ the exact environment used to render, including NODE_PATH and PLAYWRIGHT_BROWSERS_PATH.
1080
+ Use the actual script path. Custom browser launch settings need their equivalent exact-runtime
1081
+ check. Non-browser capabilities need only their documented runtime checks.
1082
+ Never create paid ingredients before the selected renderer passes. Repair and recheck under
1083
+ existing setup permissions. If it cannot be fixed, re-list with client:{shell:false} and
1084
+ delegate only a format available to the coworker; never silently change the selected format.
1085
+ - **Coworker sandbox:** you are the renderer. Follow goose-video-local's sandbox checks; never
1086
+ hand off recursively or claim browser capability that the sandbox lacks.
1087
+
1088
+ ### 5. Create the project and hand it off, in this session
1089
+
1090
+ 1. \`video_project_upsert { brand_id, name, format: <template_id> }\` with no brief (a brief creates
1091
+ a concept batch). Include client:{shell:true} only for real local execution. Default
1092
+ creation_intent:"format" keeps the style with this brand's content; source_remix requires an
1093
+ explicit choice to use source content.
1094
+ If they already chose a campaign/concept, include its verified campaign_id and optional
1095
+ campaign_concept_id. Read the IDs from that brand's saved campaign; the concept must belong
1096
+ to it. Omit unknown IDs and never infer a link or create a campaign solely to file a video.
1097
+ 2. **Verified local shell or coworker sandbox:** load
1098
+ \`catalog_fetch { type: "skill", slug: "goose-video-local" }\` and follow it on the same project_id.
1099
+ Carry the customer's words, verified defaults, campaign and selected angle into its brief.
1100
+ 3. **Chat host:** \`goose_run_task { brand_id, project_id, message }\` with the request, selected
1101
+ format and defaults. Keep task_id. Continue questions/edits with the same task and project.
1102
+ A saved free draft is not a started worker or a complete plan. Follow actual saved state.
1103
+ 4. When follow.card_follows is true, the card follows progress: do not re-read it in a loop.
1104
+ Read again on a customer reply, card action or requested update. A failure or missing saved
1105
+ plan needs the returned recovery action; never claim completion or approve an empty plan.
1106
+ Approval requires the current complete plan and total. Insufficient balance: offer a shorter
1107
+ video or top-up. “Not now” keeps the saved plan.
1108
+
1109
+ Do not hand the customer a command to paste somewhere else.
1110
+
1111
+ ## Decision Rules
1112
+
1113
+ - One sentence is a complete request. Resolve the brand and show formats without a goal interview.
1114
+ - One brand in the org: never ask which brand. Cards decide presentation; checks decide execution.
1115
+ - Use canonical tools. Preserve campaign context, selected script angles and custom authenticated review gates.
1116
+ - Never fabricate readiness, completion, approval or a second project.
1117
+
1118
+ ## Output
1119
+
1120
+ One project, one current saved plan in this chat, then the finished video. With a widget write one
1121
+ line and do not add app_url, brand_url or duplicate video links. A text host gets text_summary
1122
+ and its usable delivery link.
1123
+
1124
+ ## Quality Checks
1125
+
1126
+ - No forced goal question, duplicate table or unsupported shell claim.
1127
+ - The exact renderer passed before local paid ingredients; uncertain assets stay uncertain.
1128
+ - Selected campaign and angle survive; a single template project has no brief.
1129
+ - Current complete plan and total precede approval. Custom script and ingredient gates remain independent; Studio is optional.
1130
+
1131
+ ## Failure Modes
1132
+
1133
+ | Symptom | Cause | Fix |
1134
+ | --- | --- | --- |
1135
+ | Picker plus table | Ignored display_hint | Widget: one line; otherwise text_summary |
1136
+ | Terminal loses formats | Confused cards with execution | Declare real shell capability and check renderer |
1137
+ | Chat told it cannot start | Only local execution considered | Create once and delegate to coworker |
1138
+ | Worker ends without a plan | Assumed completion means ready | Follow actual failure/recovery state |
1139
+ | Two projects for one video | Recreated instead of resuming | Continue same project and task |
1140
+ ${STORED_FOOTAGE_GUIDANCE}`;
1141
+ }
1142
+ /**
1143
+ * The canonical render-row actions for a client/agent-rendered video
1144
+ * (GOOSE-3725): `video_render_run kind:"full"` (no dry_run) on a sample-remix
1145
+ * project OPENS a queued ad_render row and returns `render_id`;
1146
+ * `video_render_run { render: { render_id, status, ... } }` UPDATES it
1147
+ * (← update_render_status). If those names change, edit ONLY these constants:
1148
+ * every mention in the goose-video-local skill text is built from them.
1149
+ */
1150
+ exports.RENDER_ROW_TOOL = 'video_render_run';
1151
+ exports.RENDER_OPEN_ARGS = 'kind: "full"';
1152
+ exports.RENDER_UPDATE_KEY = 'render';
1153
+ /**
1154
+ * Returns the goose-video-local entry SKILL.md content (GOOSE-3677, GOOSE-3726).
1155
+ *
1156
+ * The local-render runtime. VIDEO projects made in the app (template remixes,
1157
+ * concept batches, anything that is not a recipe order) render wherever the
1158
+ * agent runs: the user's own Claude Code (with or without the gooseworks CLI)
1159
+ * OR an agent inside the GooseWorks E2B workspace sandbox (canonical MCP tools
1160
+ * + Bash, no CLI, no credentials.json; media proxies via GW_MEDIA_PROXY_TOKEN).
1161
+ * It fetches the per-format recipe, renders (ffmpeg, PIL, Playwright where
1162
+ * available), mirrors the review set for a free in-app review, then saves the
1163
+ * finished MP4 back over MCP using the canonical tools (video_project_*,
1164
+ * catalog_fetch, media_upload, the video_render_run render-row actions).
1165
+ */
1166
+ function getGooseVideoLocalSkillContent() {
1167
+ return `---
1168
+ name: goose-video-local
1169
+ slug: goose-video-local
1170
+ description: >
1171
+ Render an EXISTING GooseWorks video ad project or video batch with ffmpeg (plus Playwright for
1172
+ phone-mockup formats) and the GooseWorks media proxies, then save the finished MP4 back to the
1173
+ project over MCP. Runs on the user's own machine (Claude Code / desktop app, with or without the
1174
+ gooseworks CLI) OR inside a GooseWorks workspace sandbox (canonical MCP tools + Bash, no CLI).
1175
+ Use for a client-side format project (created by goose-video), a template-remix project or a
1176
+ video batch. A copy-for-Claude command or project id must first be checked with
1177
+ video_project_read. A hosted connector with no shell hands this same project to the GooseWorks coworker. To start a NEW video ad in chat,
1178
+ use goose-video first.
1179
+ category: ads
1180
+ version: 0.6.1
1181
+ author: GooseWorks
1182
+ tags: [gooseworks, ads, video, remix, imessage, podcast, ugc, local-render, sandbox, byoa]
1183
+ ---
1184
+
1185
+ # GooseWorks Video Ads — local remix runtime
1186
+
1187
+ ${CUSTOMER_TALK}
1188
+
1189
+ ## Chat hosts and cards
1190
+
1191
+ First perform the mandatory route check below. Then, without a shell, hand a verified template
1192
+ project to \`goose_run_task { brand_id, project_id, message }\`, or a verified template batch to
1193
+ \`goose_run_task { brand_id, batch_id, message }\` (never send both ids). Keep task_id and the
1194
+ same project or batch. Generated custom children keep their separate make-custom-video flow.
1195
+ Inside a coworker sandbox you are the renderer: never delegate recursively.
1196
+ With card.display_hint:"widget", say at most one line and never duplicate its plan, total or
1197
+ links. Otherwise print card.text_summary. Read again on customer input, not in a polling loop.
1198
+ A free saved draft is not proof that planning started or a complete plan exists.
1199
+
1200
+ ## Mandatory route check before any local work or spend
1201
+
1202
+ For every existing \`project_id\` (including one supplied by the app's copy-for-Claude command),
1203
+ call \`video_project_read { brand_id, project_id }\` **before** template lookup, toolchain setup,
1204
+ media-proxy calls, or a review-set upload. For a batch, inspect each child project.
1205
+
1206
+ - **A server-rendered order** — the response has \`creative_plan\`,
1207
+ \`project.creative_spec_revision_id\`, \`order.creative_spec_revision_id\`, a planning
1208
+ \`lifecycle\`, or an \`order\` / \`script_drafts.recipe\` on a server format → **stop.**
1209
+ Server video orders are paused, and there is **no vetted local node-execution API** for them:
1210
+ do not rebuild one locally. Tell the customer this project was made for the server flow, which
1211
+ is paused; offer to start the same ad on a client-side format (\`goose-video\`, fetched with
1212
+ \`catalog_fetch { type: "skill", slug: "goose-video" }\`, older clients:
1213
+ \`fetch_skill("goose-video")\`). An order already holding credits can be released with
1214
+ \`job_cancel\`.
1215
+ - **A client-side format or template remix** (a \`source_sample_id\` / \`template_id\` and none of
1216
+ the above) → continue below.
1217
+ - **Generated custom video** (\`project.custom_video_state.mode === "generate"\`) → fetch \`catalog_fetch { type: "skill", slug: "make-custom-video" }\`, follow it on this same project and stop following the template flow. Record independent authenticated script/ingredient approvals in this chat with the current custom_review.approval_quote phase, review_token and cumulative total; Studio is optional. A handed-off coworker cannot self-approve; do not report approval_not_required.
1218
+ - **Unclear** → read again or ask; never guess and generate. A copy prompt that names this skill
1219
+ is not proof of which kind the project is.
1220
+
1221
+ Continue below only for a verified client-side format or template remix.
1222
+
1223
+ For client-side formats and template remixes, you produce **video** ad creative wherever THIS agent runs and sync
1224
+ the result back to the GooseWorks app over MCP. This document is the **runtime contract** (auth,
1225
+ credits, the media proxies, data I/O, the review gate). A separate **recipe** — the template's
1226
+ \`recipe\`, plus the capability skills it names — tells you *what to make* (the pieces, prompts,
1227
+ models, order of assembly).
1228
+
1229
+ **Division of authority: read both, but when they disagree THIS doc wins on the environment AND the
732
1230
  review/approval flow.** The recipe governs WHAT to make; this doc governs WHEN you pause, generate,
733
1231
  and spend. In particular: a recipe may spell out a **multi-phase, multi-gate** flow — "generate the
734
1232
  still [GATE] → approve → author the prompt [GATE] → approve → render [GATE] → approve", several
@@ -737,19 +1235,142 @@ separate pauses. **Do NOT run it that way.** Collapse every one of those gates i
737
1235
  and models; ignore its intermediate pauses. This is the exact contradiction that confused past runs
738
1236
  (GOOSE-2542) — there is no ambiguity: review-once wins.
739
1237
 
740
- You run inside the user's own Claude Code session (they pasted an instruction with a project
741
- id). The app NEVER runs you — it is the viewer + review surface; you are the renderer.
1238
+ The app NEVER runs this skill by itself — it is the viewer + review surface; you are the renderer.
742
1239
 
743
- ## CLI-free environments (cowork / headless)
1240
+ ${ENVIRONMENT_IDENTITY}
744
1241
 
745
- You may be running WITHOUT the \`gooseworks\` CLI binary (e.g. Anthropic cowork). The
746
- \`mcp__gooseworks__*\` tools work over the MCP connection regardless, so wherever this skill
747
- says to shell out, use the MCP equivalent:
1242
+ ${ASSET_READINESS}
748
1243
 
749
- - \`gooseworks fetch <slug>\` → the **\`fetch_skill\`** MCP tool (returns the same content/scripts/
750
- files/dependencySkills). \`gooseworks search <q>\` → **\`search_skills\`**.
751
- - \`gooseworks credits\` → the **\`get_ad_credits\`** MCP tool.
752
- - \`gooseworks doctor\` → do the manual toolchain check in the preflight below.
1244
+ ## Where am I running? (decide once, first)
1245
+
1246
+ Check in Bash, without printing any secret value:
1247
+
1248
+ \`\`\`bash
1249
+ [ -n "$GW_MEDIA_PROXY_TOKEN" ] && echo sandbox || echo local
1250
+ command -v gooseworks >/dev/null && echo cli || echo no-cli
1251
+ \`\`\`
1252
+
1253
+ | Mode | How you know | Skills / atoms | Media-proxy auth |
1254
+ |---|---|---|---|
1255
+ | **GooseWorks sandbox** | \`GW_MEDIA_PROXY_TOKEN\` is set | \`catalog_fetch { type: "skill" }\` | env: \`GW_MEDIA_PROXY_TOKEN\` + \`GW_*_PROXY_URL\` |
1256
+ | **Local, CLI installed** | \`gooseworks\` on PATH | \`gooseworks fetch <slug>\` or \`catalog_fetch\` | \`~/.gooseworks/credentials.json\` |
1257
+ | **Local, no CLI** (Claude desktop app / Codex without login) | neither | \`catalog_fetch { type: "skill" }\` | \`~/.gooseworks/credentials.json\` if present, else **paid media over the MCP** (below) |
1258
+
1259
+ The \`gooseworks\` CLI and \`~/.gooseworks/credentials.json\` are **optional**. Everything this skill
1260
+ needs from the app goes through the GooseWorks MCP tools below; the atoms' \`media_proxy.py\` reads
1261
+ credentials.json when it exists and falls back to the \`GW_MEDIA_PROXY_TOKEN\` env otherwise.
1262
+
1263
+ ### Paid media over the MCP: no key, no CLI needed
1264
+
1265
+ Every paid generation goes through the GooseWorks media proxy and is billed to the project. **You
1266
+ never need FAL_KEY, an ElevenLabs key or \`fal_client\`.** An atom, a recipe or an open-source
1267
+ skill that lists \`FAL_KEY\` in its environment is describing a standalone setup; here the proxy
1268
+ satisfies it. Never stop, and never ask anyone to set a key, because one is missing.
1269
+
1270
+ **A one-off image or clip — call the MCP directly.** A frame placed in a laptop, a product cutout,
1271
+ a creator still, a restyle, an animated shot, with any fal model (Nano Banana, GPT-image, Seedream,
1272
+ Seedance, Kling). No atom script is needed:
1273
+
1274
+ 1. A local input (a frame pulled from a screen recording, a screenshot) must be a public URL first:
1275
+ \`media_upload { brand_id, scope: "video_project", scope_id: project_id, source: { type: "file" | "bytes", … } }\`
1276
+ (no \`path\`). For a file, PUT its bytes to \`upload.url\` with \`upload.required_headers\`,
1277
+ then call \`media_confirm { brand_id, media_id: media.id }\`. Use the returned \`media.url\`.
1278
+ 2. \`data_post_provider { provider: "fal", path: <model id, e.g. "fal-ai/nano-banana/edit">, body: <model input>, project_id }\`
1279
+ returns \`{ job_id: "fal:<request_id>" }\`. Pass an \`idempotency_key\` so a retry isn't billed twice.
1280
+ 3. Poll \`job_get { job_id }\` every few seconds until \`complete\`; the \`*.fal.media\` URLs are in
1281
+ \`result\`. Download each and QC it (open the image) before using it.
1282
+
1283
+ For a set that must match (every laptop shot, every creator still), use ONE prompt and the same
1284
+ model for all of them and change only the input image. Voice and music:
1285
+ \`data_post_provider { provider: "elevenlabs", path: "/v1/text-to-speech/{voice_id}" | "/v1/music", body, project_id }\`
1286
+ (synchronous; the audio lands in the project folder).
1287
+
1288
+ \`photos_generate\` is **not** a general image tool: it only photographs a physical catalog
1289
+ product (apparel, beauty, CPG) and needs a \`product_id\`. A software screenshot or app mockup is a
1290
+ fal image edit, above.
1291
+
1292
+ **Atom scripts — the MCP relay.** With neither \`GW_MEDIA_PROXY_TOKEN\` nor
1293
+ \`~/.gooseworks/credentials.json\`, the atoms' \`media_proxy.py\` RELAYS each paid call through you
1294
+ instead of calling the proxies over HTTP. Before running any atom,
1295
+ \`export GW_PROJECT_ID=<project_id> GW_BRAND_ID=<brand_id>\` (every call is billed to that
1296
+ project). When a script **exits with code 3** it wrote a request file under
1297
+ \`working/mcp-requests/\`: make exactly that MCP call — fal:
1298
+ \`data_post_provider { provider: "fal", path, body, project_id }\` then \`job_get { job_id }\` until
1299
+ \`complete\`, saving \`result.output\`; ElevenLabs: \`data_post_provider { provider: "elevenlabs", … }\`,
1300
+ saving the reply; a local file: \`media_upload\` with its bytes, saving \`{"url": …}\`. Write that JSON
1301
+ to the request's \`save_result_to\` and **re-run the same command**; repeat until the script
1302
+ finishes. Same server proxy and price as the CLI path. If the CLI is logged in to a DIFFERENT
1303
+ environment than this MCP connector (prod vs staging), set \`GW_MEDIA_VIA=mcp\` so the spend lands
1304
+ where the project lives.
1305
+
1306
+ ## MCP tools — canonical names (use these)
1307
+
1308
+ Use the canonical GooseWorks MCP tools. Legacy names are listed only as a fallback for an older
1309
+ client that does not expose the canonical tool; never mix both for one step.
1310
+
1311
+ | Step | Canonical tool (use this) | Legacy fallback |
1312
+ |---|---|---|
1313
+ | Read a project / batch | \`video_project_read { brand_id, project_id }\` / \`video_project_read { brand_id, batch_id }\` | \`get_ad_project\` / \`get_ad_video_batch\` |
1314
+ | Template recipe | \`catalog_fetch { type: "template", slug: <source_sample_id> }\` | \`get_ad_template\` |
1315
+ | Capability skill (atom) + its scripts | \`catalog_fetch { type: "skill", slug }\` | \`gooseworks fetch <slug>\` / \`fetch_skill\` |
1316
+ | Brand kit, products, rules | \`brand_read { brand_id, sections: ["summary","kit","products","learnings"] }\` | \`brand_get_context\` / \`get_brand_kit\` |
1317
+ | Save a brand rule (a correction) | \`brand_update { brand_id, knowledge_intent: "user_correction", user_statement: <the user's exact words>, patch: { facts: [{ id?, kind, text }] } }\` | none |
1318
+ | Mirror the review set | \`video_project_upsert { brand_id, project_id, patch: { script: { script_drafts, script } } }\` | \`update_ad_project_script\` |
1319
+ | Project assets | \`video_project_upsert { …, patch: { assets: [...] } }\` | \`update_ad_project_asset\` |
1320
+ | Progress note | \`video_project_upsert { …, patch: { message: { role: "agent", content } } }\` | \`append_project_message\` |
1321
+ | Batch status | \`video_project_upsert { brand_id, batch_id, patch: { batch: { status } } }\` | \`update_ad_video_batch\` |
1322
+ | Upload a file to the project | \`media_upload { brand_id, scope: "video_project", scope_id: project_id, kind, path, source: { type: "file", filename, content_type } }\` → PUT → \`media_confirm { brand_id, media_id: media.id }\` | \`get_upload_url\` / \`get_ad_upload_url\` |
1323
+ | Save / find a finished piece (resume) | \`media_upload { …, path, ingredient_key, input_digest }\` / \`media_list { brand_id, scope: "video_project", scope_id: project_id, ingredient_key_prefix: "" }\` (see "Save as you go") | none |
1324
+ | Open the render row | \`${exports.RENDER_ROW_TOOL} { brand_id, project_id, ${exports.RENDER_OPEN_ARGS} }\` (no \`dry_run\`; returns \`render_id\`) | \`submit_render { project_id, kind: "full" }\` |
1325
+ | Update the render row | \`${exports.RENDER_ROW_TOOL} { brand_id, project_id, ${exports.RENDER_UPDATE_KEY}: { render_id, status, output_url?, thumbnail_url?, error_message?, quality_status?, quality_report? } }\` | \`update_render_status\` |
1326
+ | Pin the final render | \`video_project_upsert { brand_id, project_id, patch: { final_render_id: render_id } }\` | \`set_final_render\` |
1327
+ | Credits / identity | \`account_whoami\` | \`get_ad_credits\` |
1328
+
1329
+ \`list_accessible_scopes\` and the \`target: { type: "agent", agent_id }\` dance are **not needed**:
1330
+ \`media_upload\` with \`scope: "video_project"\` derives the right storage key (org-default Ads agent
1331
+ + brand slug + project folder) on the server.
1332
+
1333
+ ## Running in a GooseWorks sandbox
1334
+
1335
+ You are an agent inside the user's GooseWorks workspace sandbox (Claude Code harness, Bash, the
1336
+ GooseWorks MCP with canonical tools only). There is **no \`gooseworks\` CLI** and **no
1337
+ \`~/.gooseworks/credentials.json\`**. The environment carries \`GW_MEDIA_PROXY_TOKEN\`, \`GW_API_BASE\`,
1338
+ \`GW_FAL_PROXY_URL\`, \`GW_FAL_STORAGE_PROXY_URL\`, \`GW_ELEVENLABS_PROXY_URL\`, \`GW_WHISPER_PROXY_URL\`
1339
+ and usually \`GW_PROJECT_ID\`.
1340
+
1341
+ - **Formats:** only formats that need **no Chromium** run here — podcast skits and UGC /
1342
+ talking-head formats (ffmpeg + PIL assembly). If the template's recipe or an atom needs
1343
+ Playwright/Chromium with no PIL fallback (iMessage / ChatGPT / Notes phone mockups,
1344
+ hyperframes, HTML recorders), **stop before any spend** and say so plainly: "This format needs
1345
+ a browser renderer that this workspace doesn't have. Run it in your own Claude Code with the
1346
+ GooseWorks CLI (\`goose-video-local\`), or pick a podcast/UGC format." Do not half-render.
1347
+ - **Toolchain:** check \`ffmpeg -version\` and \`ffprobe -version\`. Install Python deps only when an
1348
+ atom needs them: \`pip install --quiet pillow\` when a render atom uses PIL (captions, end card),
1349
+ \`pip install --quiet requests\` if \`import requests\` fails. Never \`npx playwright install\` here.
1350
+ - **Atoms:** \`catalog_fetch { type: "skill", slug }\` returns \`content\`, \`scripts\`, \`files\` and
1351
+ \`dependencySkills\`. Write \`content\` to \`/tmp/gooseworks-scripts/<slug>/SKILL.md\`, each
1352
+ \`scripts\` entry to \`/tmp/gooseworks-scripts/<slug>/scripts/<name>\` and each \`files\` entry to
1353
+ \`/tmp/gooseworks-scripts/<slug>/<name>\` (keep the key as the relative path; do the same for
1354
+ each dependency skill). Run scripts from their \`scripts/\` folder so \`import media_proxy\` resolves.
1355
+ - **Project attribution:** \`export GW_PROJECT_ID=<project_id>\` in the shell **before running any
1356
+ atom** for that project (re-export per concept in a batch). The proxies bill the workspace
1357
+ agent and attribute spend to that project.
1358
+ - **Never call a provider with a raw key.** All FAL / ElevenLabs / Whisper traffic goes through
1359
+ the \`GW_*_PROXY_URL\` bases with \`GW_MEDIA_PROXY_TOKEN\`. \`FAL_KEY\` / \`ELEVENLABS_API_KEY\` in
1360
+ this environment are proxy tokens, not provider keys — never send them to \`fal.run\`,
1361
+ \`queue.fal.run\` or \`api.elevenlabs.io\` directly. Never print any token.
1362
+ - **Whisper for QC:** \`export OPENAI_BASE_URL="$GW_WHISPER_PROXY_URL/v1"\` before running
1363
+ \`review-ugc-render\` / \`watch\` transcripts.
1364
+ - **The operator may be absent.** Keep every quality gate and checkpoint below, but decide
1365
+ defaults yourself from the project brief and the recipe, and record them in the review set.
1366
+ Ask in the chat **only for a true taste call** (a creative choice the brief and recipe leave
1367
+ open and that changes the ad), never for a mechanical or recoverable decision. The Step 3
1368
+ approval still applies: ask for it in this chat and record the yes with
1369
+ \`video_project_upsert patch.approve\`.
1370
+ - **Outputs:** keep working files under \`/tmp/gooseworks-video/<project_id>/\` (local disk — never
1371
+ the s3fs workspace mount, which is slow and can drop writes); anything the user must see goes to
1372
+ the project via \`media_upload\` (never leave the result only in the sandbox). Every paid piece is
1373
+ also SAVED to the project as soon as it passes QC — see "Save as you go — and resume".
753
1374
 
754
1375
  ## Report problems so we can fix them (telemetry — do this, don't skip it)
755
1376
 
@@ -762,97 +1383,285 @@ the skill. It's fire-and-forget, never counts against you, and never blocks your
762
1383
  \`export GW_RUN_ID="vid-<project_or_batch_id>"\` (and \`export GW_SKILL="<recipe-slug>"\`) in the
763
1384
  shell you render from. The media proxies read \`GW_RUN_ID\` automatically.
764
1385
  - **CLI present →** \`gooseworks log "<what happened>" --event-type <type> --level error --details '{"error":"...","step":"...","model":"..."}'\`
765
- - **No CLI (cowork / headless) →** the **\`log_cli_event\`** MCP tool with the same fields (pass \`run_id\`).
766
- - \`--event-type\`: \`api_failure\` (a proxy/model call failed) · \`missing_input\` · \`blocker\` ·
1386
+ - **No CLI (sandbox / cowork) →** from any atom's \`scripts/\` folder:
1387
+ \`python3 -c 'from media_proxy import gw_log; gw_log("<what happened>", event_type="blocker", level="error", details={"step": "..."})'\`
1388
+ (or the \`log_cli_event\` MCP tool if your client has it).
1389
+ - Event types: \`api_failure\` (a proxy/model call failed) · \`missing_input\` · \`blocker\` ·
767
1390
  \`confusion\` (unclear/contradictory instruction) · \`error\` (a bug) · \`step\`/\`info\` (progress notes).
768
- - Put the **real error text + the step you were on** in \`--details\`. Paid FAL/ElevenLabs calls
1391
+ - Put the **real error text + the step you were on** in the details. Paid FAL/ElevenLabs calls
769
1392
  ALREADY auto-log their own failures, so focus your manual logs on what the proxy can't see:
770
1393
  missing inputs, confusing/contradictory recipe instructions, toolchain/setup failures, and bugs.
771
1394
  - Logging is FOR US — it does not replace telling the user. When a problem blocks the run, still
772
- explain it to the user (and ask if you need a decision); just also \`log\` it so we can fix the skill.
1395
+ explain it to the user (and ask if you need a decision); just also log it so we can fix the skill.
773
1396
 
774
1397
  ## Prerequisite — MCP + a render toolchain (Phase 0 preflight)
775
1398
 
776
- - The \`mcp__gooseworks__*\` tools are REQUIRED. If they're unavailable, stop and tell the user
1399
+ - The GooseWorks MCP tools are REQUIRED. If they're unavailable, stop and tell the user
777
1400
  to connect the GooseWorks MCP server (or run \`gooseworks install --claude --mcp\` on the CLI)
778
1401
  and restart. There is no REST fallback.
779
- - **The render runs wherever THIS agent runs, and it needs a real toolchain: \`ffmpeg\` +
780
- \`ffprobe\` + a Playwright **Chromium**.** Establish it in this priority order, and do NOT start
1402
+ - **The render runs wherever THIS agent runs, and it needs a real toolchain:** \`ffmpeg\` +
1403
+ \`ffprobe\` always, plus a Playwright **Chromium** for browser-rendered formats (phone mockups,
1404
+ HTML end cards without a PIL fallback). Establish it in this priority order, and do NOT start
781
1405
  rendering until one is confirmed:
782
- 1. **CLI present →** run \`gooseworks doctor\` (checks login, MCP, ffmpeg/ffprobe, Playwright
783
- Chromium in one shot). Fix any ✗ with the command it prints, then continue.
784
- 2. **No CLI →** check the toolchain yourself: \`ffmpeg -version\`, \`ffprobe -version\`, and a
785
- Playwright Chromium probe (\`npx playwright --version\` and, if needed, \`npx playwright install
786
- chromium\`). If all resolve, continue.
787
- 3. **Docker available →** this is the most reliable way to get the toolchain in a sandbox that
788
- lacks it: run the render steps inside the prebuilt image
1406
+ 1. **Sandbox →** see "Running in a GooseWorks sandbox": ffmpeg + ffprobe (+ PIL on demand); no
1407
+ Chromium, so browser formats stop there.
1408
+ 2. **CLI present →** run \`gooseworks doctor --no-browser\` for login, MCP, Node 18+, ffmpeg
1409
+ with libx264 + libass, and ffprobe. This is common setup only. After fetching the selected
1410
+ capabilities in Step 2, check each browser renderer's actual launch before ANY paid
1411
+ ingredient. An unscoped \`gooseworks doctor\` checks only the calling folder's browser;
1412
+ it cannot certify a different fetched renderer.
1413
+ 3. **No CLI →** check the toolchain yourself: \`node --version\` (18+), \`ffmpeg -version\`,
1414
+ \`ffprobe -version\`, plus \`ffmpeg -hide_banner -encoders\` (libx264) and
1415
+ \`ffmpeg -hide_banner -filters\` (ass). After fetching, use the exact-package free launch
1416
+ check in Step 2; resolving a package or finding a cache folder does not prove its browser
1417
+ can launch. The \`watch\` QC step later needs the same ffmpeg and,
1418
+ for transcripts, a Whisper backend — without one it degrades to frames only.
1419
+ 4. **Docker available →** the most reliable way to get the toolchain on a host that lacks it:
1420
+ run the render steps inside the prebuilt image
789
1421
  **\`ghcr.io/gooseworks-ai/goose-video-render\`** (ffmpeg + ffprobe + Playwright Chromium baked
790
- in), mounting the project working directory. Use Docker whenever the host is missing ffmpeg or
791
- Chromium and \`docker\` is on PATH. (Note: nested Docker is usually disabled inside managed
792
- sandboxes like cowork — treat this as an option, not a guarantee.)
793
- 4. **None of the above works →** STOP and tell the user plainly, e.g.: *"Video rendering needs
794
- ffmpeg + a Playwright Chromium (or Docker) on the machine running this agent. This environment
795
- doesn't have them and I can't install them here. Options: (a) enable/allow Docker so I can use
796
- the goose-video-render image, (b) install ffmpeg + \`npx playwright install chromium\`, or
797
- (c) run this skill locally in your own Claude Code where the toolchain is available."* Do not
1422
+ in), mounting the project working directory. (Nested Docker is usually disabled inside
1423
+ managed sandboxes — treat this as an option, not a guarantee.)
1424
+ 5. **None of the above works →** STOP and tell the user plainly, e.g.: *"Video rendering needs
1425
+ ffmpeg (and, for this format, a Playwright Chromium) on the machine running this agent. This
1426
+ environment doesn't have them and I can't install them here. Options: (a) enable Docker so I
1427
+ can use the goose-video-render image, (b) install ffmpeg + \`npx playwright install chromium\`,
1428
+ or (c) run this skill in your own Claude Code where the toolchain is available."* Do not
798
1429
  half-render or fake a result. Static image ads (the \`goose-ads\` skill) do NOT need any of this
799
1430
  and work anywhere — offer that as the fallback if they just want an ad now.
800
1431
 
801
1432
  ## Identity, token, credits
802
1433
 
803
- - Read \`~/.gooseworks/credentials.json\` → \`api_key\` (your agent token), \`api_base\`, \`agent_id\`.
804
- Never print the token.
805
- - **CRITICAL — target the org-default Ads agent on EVERY file op.** The app serves project files
806
- (the render-file route) from the org's DEFAULT agent, but MCP file writes default to your
807
- token's pinned agent — which can be a DIFFERENT agent, so a render written with the default
808
- scope is **invisible in the app**. First resolve the Ads agent: \`list_accessible_scopes\` → the
809
- scope with \`is_org_default: true\` (the ORG default — NOT the \`is_default\` / \`default_agent_id\`
810
- fields, which are the *user's* default agent and are often a DIFFERENT agent). Its \`agent_id\` is
811
- \`ADS_AGENT\` (name "Ads agent", slug \`org-default\`; usually also the \`agent_id\` in
812
- credentials.json). Then pass \`target: { type: "agent", agent_id: ADS_AGENT }\` on EVERY
813
- \`get_upload_url\` / \`get_download_url\` / \`write_file\` / \`list_directory\` / \`read_file\` — NEVER
814
- omit \`target\`.
815
- - **CRITICAL — publish under the PROJECT FOLDER, not the workspace root (the #1 "video renders but
816
- is invisible" bug).** \`get_upload_url\` stores at \`<ADS_AGENT>/files/<path>\` verbatim, but the
817
- render-file route reads from
818
- \`<ADS_AGENT>/files/agent-config/brands/<brand_slug>/projects/<project_id>/<path>\`
819
- (see backend \`resolveProjectFileKey\`). So EVERY publish/preview \`path\` MUST be prefixed with
820
- \`agent-config/brands/<brand_slug>/projects/<project_id>/\` — e.g. upload to
821
- \`agent-config/brands/<brand_slug>/projects/<project_id>/working/final.mp4\`, NEVER bare
822
- \`working/final.mp4\`. A bare path 404s in the app even though the render row AND a bare-path
823
- \`get_download_url\` both "succeed" (they resolve the wrong key). The render \`output_url\` still
824
- stays the project-relative \`...render-file?path=working/final.mp4\` — the route re-prepends the
825
- prefix itself. Always verify with \`get_download_url\` on the FULL \`agent-config/...\` path (must
826
- be non-empty; curl it for HTTP 200) BEFORE marking the render complete.
1434
+ - **Sandbox:** the token is \`GW_MEDIA_PROXY_TOKEN\` (already scoped to this workspace's agent and
1435
+ org); the API base is \`GW_API_BASE\`. Never print either.
1436
+ - **Local:** read \`~/.gooseworks/credentials.json\` → \`api_key\` (your agent token), \`api_base\`,
1437
+ \`agent_id\`. Never print the token.
1438
+ - **Uploads go through \`media_upload\` with \`scope: "video_project"\`** — pass \`path\` = the
1439
+ project-relative path (\`working/final.mp4\`, \`working/review/end-card.png\`). The server stores it
1440
+ in the project folder of the org-default Ads agent (where the app's render-file route reads) and
1441
+ returns \`upload.url\` (presigned PUT), \`upload.required_headers\` and
1442
+ \`upload.render_file_url\`. PUT the bytes with exactly those headers, check the PUT returned
1443
+ 2xx, then call \`media_confirm { brand_id, media_id: media.id }\` and require success before
1444
+ using the file in ingredients or completing a render. This applies to project-path and
1445
+ path-less file uploads. Confirmation verifies the stored file; Goose performs this tool step
1446
+ without asking the user for another approval. On failure, report or repair the upload before
1447
+ continuing. Never hand-build storage paths or agent prefixes; a bare workspace upload is
1448
+ invisible in the app.
827
1449
  - Media generation (FAL / ElevenLabs) through the GooseWorks proxies is the **REAL spend** — billed
828
- to the agent per call as you generate (Step 4). \`submit_render { kind: "full" }\` additionally
829
- debits **1 nominal ad credit when the render ROW is opened** (a bookkeeping fee, NOT the render's
830
- true cost) — so open it only once you actually have a rendered master (Step 4.1/4.2), and never
831
- re-submit on a guess (that double-bills). The final-video QC gate (Step 4.3) then sits between
832
- that master and PINNING it. Call \`get_ad_credits\` first; the user can check \`gooseworks credits\`.
1450
+ per call as you generate (Step 4). The render row (\`${exports.RENDER_ROW_TOOL} ${exports.RENDER_OPEN_ARGS}\`) charges the flat
1451
+ **video base fee once, when a full render is reported \`complete\`**. Open one row immediately
1452
+ after recorded approval, BEFORE paid production (Step 4.1), and reuse that render_id for progress
1453
+ and completion. Never open a second row on a guess (a second completed row bills again). The final-video QC gate (Step 4.3) then sits between
1454
+ that master and PINNING it. Call \`account_whoami\` first to see the credit balance.
1455
+
1456
+ ## Save as you go — and resume (never pay twice for a piece)
1457
+
1458
+ A sandbox can die mid-run (timeout, restart, a new session picks the project up). Anything that
1459
+ lives only in \`/tmp\` is then gone, and regenerating it pays again. So: **save every piece to the
1460
+ project the moment it passes its QC, and start every run by loading what is already saved.**
1461
+ Working files stay in \`/tmp/gooseworks-video/<project_id>/\` (never the s3fs workspace mount);
1462
+ the project is the durable copy.
1463
+
1464
+ **Ingredient keys.** Give every planned piece a stable key before you generate it, the same on
1465
+ every run: \`vo/scene-03\`, \`vo/sample-her\`, \`still/her-base\`, \`still/scene-05\`,
1466
+ \`clip/scene-05\` (a lipsync / video clip), \`music/bed\`, \`endcard\`, \`captions\`, \`final\`,
1467
+ \`final-thumb\`. Upload path = \`working/<role>/<file>\` (\`working/vo/scene-03.mp3\`,
1468
+ \`working/clip/scene-05.mp4\`); the review set keeps its \`working/review/<name>\` paths.
1469
+
1470
+ **Input digest.** Name the exact inputs of each generation with \`input_digest\` from
1471
+ \`media_proxy\` (in every media capability's \`scripts/\` folder):
1472
+
1473
+ \`\`\`python
1474
+ from media_proxy import input_digest
1475
+ digest = input_digest(model_path, args) # the model + the EXACT payload you send
1476
+ \`\`\`
1477
+
1478
+ Hash only what decides the output (prompt, voice_id, model_id, seed, duration, aspect…). An input
1479
+ that is a presigned or proxy URL changes every run, so swap it for that input's own identity
1480
+ before hashing, e.g. \`{**args, "image_url": {"ingredient": "still/her-base", "digest": her_digest}}\`
1481
+ — then a changed still correctly invalidates every clip made from it. For a piece you build
1482
+ locally (ffmpeg stitch, PIL end card, captions) use \`input_digest("local/<step>", {params,
1483
+ inputs: {key: digest, …}})\`.
1484
+
1485
+ **1. At the START of every run (first run, resume, new sandbox), load what exists — one call:**
1486
+ \`media_list { brand_id, scope: "video_project", scope_id: project_id, ingredient_key_prefix: "",
1487
+ limit: 100 }\`. It returns ONE compact row per \`ingredient_key\` (the newest):
1488
+ \`{ id, ingredient_key, input_digest, kind, status, mime, bytes, url, path, created_at }\`. Every
1489
+ status except archived is included. Project-path uploads remain \`pending\` until
1490
+ \`media_confirm\` succeeds. Confirm a pending project-path upload before reusing it; if
1491
+ confirmation fails, repair the upload before treating it as a verified save.
1492
+ Page with \`cursor\` if \`next_cursor\` is set (keep the first row you see per key — it is the newest). Also read \`script_drafts.ingredients\` from
1493
+ \`video_project_read\`: it records which pieces were already approved in the review.
1494
+
1495
+ **2. For each planned piece:** compute its digest from the args you WOULD send now. If a saved row
1496
+ has the same \`ingredient_key\` AND the same \`input_digest\`, **download it instead of
1497
+ generating**:
1498
+
1499
+ \`\`\`bash
1500
+ curl -fsSL "$URL" -o /tmp/gooseworks-video/<project_id>/<path> # URL = that row's \`url\`
1501
+ \`\`\`
1502
+
1503
+ That \`url\` is a short-lived (~15 min) presigned S3 GET the server signs for you, so it needs no
1504
+ auth header — download right after listing (list again if it expired). **Never fetch the
1505
+ \`/api/ads/projects/<id>/render-file?path=…\` route from the sandbox:** it needs the app's
1506
+ browser session and answers 401 to a token. Check the file is non-empty and plays (ffprobe for
1507
+ audio/video, open the image); if the download fails or the file is broken, regenerate the piece.
1508
+ Only generate what is missing or whose digest changed — a changed digest means the inputs changed,
1509
+ so the old file is stale.
1510
+
1511
+ **Pass the digest to the proxy too:** \`fal_generate(..., input_digest=digest)\` (and
1512
+ \`fal_generate_video\` / \`fal_whisper\`). A piece that was generated but never saved (the sandbox
1513
+ died between the fal result and the upload) is then handed back by the proxy instead of paid for
1514
+ again, even though its input URLs changed. Only pass \`new_take=True\` when the user wants a
1515
+ different take of the same inputs.
1516
+
1517
+ **3. After EACH piece is generated AND passes its own QC, upload it right away** — don't batch
1518
+ the uploads to the end:
1519
+ \`media_upload { brand_id, scope: "video_project", scope_id: project_id, kind, path:
1520
+ "working/<role>/<file>", ingredient_key, input_digest, source: { type: "file", filename,
1521
+ content_type } }\` → PUT the bytes to \`upload.url\` with \`upload.required_headers\` →
1522
+ \`media_confirm { brand_id, media_id: media.id }\`. Require a successful confirmation.
1523
+ Kind: \`audio\` (VO), \`music\`, \`image\` (a still),
1524
+ \`video\` (a clip), \`endcard\`, \`document\` (captions / a JSON sidecar), \`render\` (the master),
1525
+ \`thumbnail\`. Re-uploading the same key is fine — the newest wins. A piece that FAILED QC is never
1526
+ uploaded under its key. **Save a piece's sidecars with it** under \`<key>.<name>\` — e.g. the VO's
1527
+ char-level timestamps as \`vo/scene-03.timestamps\` (\`kind: "document"\`, same digest). Captions are
1528
+ built from them; without them a resumed run has to fall back to Whisper timings, which mis-case
1529
+ brand names.
1530
+
1531
+ **4. Keep the approved review unchanged during production.** Record each confirmed piece's
1532
+ \`media_id\`, \`path\`, \`ingredient_key\` and \`input_digest\` locally; the confirmed media rows
1533
+ and render progress are the durable resume record. Before approval, mirror the draft ingredients
1534
+ as part of Step 3. After approval, do NOT write \`patch.script\` or \`script_drafts\` during any
1535
+ paid production, QC or repair step, or while provider work is pending. A review-set write clears
1536
+ approval and can stop the next paid step, including a batch concept. Save the final descriptive
1537
+ review once all paid work is finished and settled, as Step 4.5 requires.
1538
+
1539
+ Any material creative change or ANY change the user asked for in this chat must stop production:
1540
+ save the changed complete plan and full credit total, then obtain fresh approval before continuing.
1541
+ Never reuse the earlier yes for a changed plan. A repair that restores the approved choices can
1542
+ continue within the existing allowance and Stop guards without rewriting the approved review.
1543
+
1544
+ The \`final\` master and \`final-thumb\` poster (Step 4.4) carry \`ingredient_key\` too, so a
1545
+ resumed run that finds a passing \`final\` with the same digest only needs to publish.
1546
+
1547
+ ## Finished video, interrupted saving — resume the same version
1548
+
1549
+ If the final already passed QC and the customer says **"finish saving this video"**, start here.
1550
+ Do not restart the recipe, choose another format, open another render, generate a take, or run a
1551
+ paid transcript check again. Saving uses the **same render_id**. The ordinary first-completion
1552
+ video fee can still apply; its existing same-render idempotency prevents a duplicate fee. Never
1553
+ promise that all saving is free.
1554
+
1555
+ **Before the first final upload**, save the final review set and production manifest from Step
1556
+ 4.5/4.6 (including any QC repairs) only after all paid work is finished and settled. Preserve the
1557
+ approved creative choices; a material change requires the changed-plan approval flow first.
1558
+ After that final save, start no new provider or render work: prepare the checkpoint and finish
1559
+ the same opened render using its existing finishing allowance and guards. A released allowance
1560
+ or stopped/capped render requires normal recovery; never reopen or bypass approval.
1561
+ Write a durable local checkpoint outside the fetched-scripts cache. Keep the actual
1562
+ final, JPEG poster, structured passing quality report, and review evidence files alongside it in
1563
+ a retained local working folder. Record their SHA-256 **at the time those exact bytes pass QC**;
1564
+ never attach an old verdict to a newly hashed replacement. A sandbox's local disk can disappear:
1565
+ this checkpoint recovers connection interruptions, not lost storage. Save ingredients remotely
1566
+ as above and tell the customer if the checked local output is no longer available.
1567
+
1568
+ With the current CLI and its normal login to the selected environment, write a manifest like:
1569
+
1570
+ \`\`\`json
1571
+ {
1572
+ "brand_id": "<owning brand>", "project_id": "<same project>", "render_id": "<already opened render>",
1573
+ "input_digest": "<assembly input digest>",
1574
+ "final_path": "/absolute/retained/working/final.mp4",
1575
+ "poster_path": "/absolute/retained/working/final-thumb.jpg",
1576
+ "qc": {
1577
+ "final_sha256": "<64 lowercase hex characters recorded during final QC>",
1578
+ "poster_sha256": "<64 lowercase hex characters recorded during poster review>",
1579
+ "report_path": "/absolute/retained/working/quality-report.json",
1580
+ "evidence_paths": ["/absolute/retained/working/review/finished-ad.json"]
1581
+ }
1582
+ }
1583
+ \`\`\`
1584
+
1585
+ Run \`gooseworks video-save prepare --manifest <manifest.json> --checkpoint <retained/save-<render_id>.json>\`
1586
+ before any upload, then \`gooseworks video-save resume --checkpoint <same checkpoint>\` for both
1587
+ normal saving and recovery. The helper uses the saved login and canonical MCP connection; it does
1588
+ not copy credentials or use a raw Ads REST fallback. Its atomic private checkpoint binds the
1589
+ environment, account, project owner, project/render, final/poster bytes, assembly digest, passing
1590
+ quality report, review set, evidence files and stage receipts. Preserve it until delivery. Never
1591
+ edit the checkpoint to clear a failed check. Keep checkpoint and manifest files out of commits.
1592
+
1593
+ The helper reads remote state before writes. It keeps \`final\` / \`final-thumb\` ingredient keys
1594
+ and writes per-render paths \`working/final-<render_id>.mp4\` / \`working/final-<render_id>-thumb.jpg\`
1595
+ so saving this version cannot overwrite an older one. It confirms pending uploads, checks remote
1596
+ bytes against the QC hashes, and reuses confirmed media. A request with missing stored bytes can
1597
+ get a fresh upload URL at that same path. A lost completion reply is unknown until project read
1598
+ confirms the same render's output and passing report; then only final selection remains.
1599
+
1600
+ **No CLI / a host-selected MCP connection:** keep the same protocol with the host's canonical
1601
+ tools. Atomically write versioned JSON locally (write a private same-directory temporary file,
1602
+ flush/fsync, rename, then fsync the directory) before any upload and between each upload request,
1603
+ PUT, confirmation, completion and final selection. Persist only public environment identity,
1604
+ account/owner/project/render IDs, file paths/sizes/hashes, input digest, exact quality report and
1605
+ evidence fingerprints, saved-review digest, media IDs and stage states; **no tokens, session IDs,
1606
+ signed URLs or auth headers**. On reconnect call \`account_whoami\`,
1607
+ \`video_project_read { brand_id, project_id, include: ["renders"] }\` and
1608
+ \`media_list { brand_id, scope: "video_project", scope_id: project_id, ingredient_key, input_digest }\`
1609
+ on the original connection. Compare identities, local/evidence hashes and saved review; verify
1610
+ confirmed remote bytes too. Treat a lost reply as unknown and read back before retrying. Use only
1611
+ the missing \`media_upload\` → PUT → \`media_confirm\`, same-render \`video_render_run { render: … }\`
1612
+ callback and \`video_project_upsert\` with only \`patch.final_render_id\` and
1613
+ \`patch.final_selection_guard: { expected_final_render_id, expected_review_digest }\`; never a
1614
+ render-open call. The expected final is the last read's pin, including explicit \`null\`; the
1615
+ review digest is SHA-256 of recursively sorted-key JSON
1616
+ \`{script: project.script ?? null, script_drafts: project.script_drafts ?? null}\` saved at checkpoint
1617
+ creation. First confirm the selected server advertises this guard in \`tools/list\`. If absent,
1618
+ stop and request the normal server update/reconnect; an unguarded pin is unsafe. A
1619
+ \`final_selection_conflict\` means the choice or review changed: keep the checkpoint and explain
1620
+ that saving stopped without overwriting it. Retain the
1621
+ strict Step 4.3/4.4 report and Step 4.5 review-set requirements.
1622
+
1623
+ If authorization expired, reconnect/sign in through the normal host/CLI flow on the original
1624
+ connection, then resume. Missing tools are a reconnect requirement, not permission to switch
1625
+ environments. Missing/changed files, stale/missing QC, changed account/owner/review, another final
1626
+ selection, or a stopped/capped/failed/blocked render require diagnosis; do not reopen it or
1627
+ regenerate automatically. If saving stops, say: **"Your video is finished locally, but saving to
1628
+ Goose was interrupted."** Link the actual local file and preserve its checkpoint. Claim saved
1629
+ delivery only after a fresh project read verifies completion and selection of that exact render.
833
1630
 
834
1631
  ## Step 0 — project id, or video BATCH id? (fan out before anything else)
835
1632
 
836
- The handoff you were pasted is EITHER a single \`project <id>\` OR a \`video batch <id>\`. A batch is
1633
+ The handoff is EITHER a single \`project <id>\` OR a \`video batch <id>\`. A batch is
837
1634
  the app's "N concepts" flow: one composer submission fans out into **N independent concept projects**
838
1635
  (the user picked a concept count, default 3), and the app expects EACH to be rendered. **Handle both:**
839
1636
 
840
1637
  - **\`project <id>\`** → you have one project. Treat it as a batch of one and continue to Step 1.
841
- - **\`video batch <id>\`** → call \`get_ad_video_batch { video_batch_id }\`. It returns every child
1638
+ - **\`video batch <id>\`** → call \`video_project_read { brand_id, batch_id }\`. It returns every child
842
1639
  concept under \`projects[]\` — each is a normal project with its own \`id\`, \`variant_index\`
843
1640
  (Concept 1..N), and its own \`creative_brief\` (the per-concept angle/hook/offer/message). **You
844
1641
  MUST process every concept, not just the first** — dropping concepts 2..N is the #1 batch bug.
845
1642
 
846
- **Loop shape (one agent, sequential, ONE approval for the whole batch):**
847
- 1. Run **Step 1 + Step 1.5 + Step 2 + Step 3-assemble** for EACH concept project (each has its own
848
- \`project_id\`, brief, and \`working/\` folder — never cross-write between concepts).
849
- 2. Mirror EVERY concept's review set (Step 3's \`update_ad_project_script\` per project), then stop
850
- for **ONE** approval that covers all concepts — show the per-concept credit estimate and the
851
- batch total. Set the batch to \`review\` (\`update_ad_video_batch { status: "review" }\`).
852
- 3. On approval, set the batch to \`rendering\` and run **Step 4 (the expensive render)** for each
853
- concept **sequentially** (finish Concept 1's master before starting Concept 2 — one machine can't
854
- render them in parallel). Deliver each (Step 5). When all concepts are pinned, set the batch to
855
- \`complete\`.
1643
+ **Loop shape (ONE approval for the batch, isolated work per concept):**
1644
+ 1. Run **Step 1 + Step 1.5 + Step 2 + Step 2.5 + Step 3-assemble** for EACH concept project (each
1645
+ has its own \`project_id\`, brief, \`GW_PROJECT_ID\` and \`working/\` folder — never cross-write
1646
+ between concepts). The brand read (Step 1 item 3) and \`brand-rules.json\` (Step 1.7) are per
1647
+ BRAND: do them once for the batch and copy the file into each concept's \`working/\`. The read is
1648
+ ~90K characters. Step 2.5's angle bank is shared per brand AND product: load or build it once, and
1649
+ give every concept whose angle is \`auto\` a DIFFERENT angle from that list, so the batch is N
1650
+ different ads, not one ad N times.
1651
+ 2. Mirror EVERY concept's review set (Step 3's \`video_project_upsert patch.script\` per project),
1652
+ then stop for **ONE** approval in this chat that covers all concepts. Save each render_estimate.total_credits
1653
+ (previews + render + the 200 base fee) and the batch total. Widget: one line; text: card.text_summary. Set the batch to \`review\` (\`video_project_upsert
1654
+ { brand_id, batch_id, patch: { batch: { status: "review" } } }\`).
1655
+ 3. On an explicit yes, record it ONCE for the whole batch: \`video_project_upsert { brand_id, batch_id,
1656
+ patch: { approve: { user_quote: "<their exact words>", total_credits: <the saved total> } } }\`. Check its \`not_ready\` list is
1657
+ empty (a concept listed there has no saved review set: save it, show it, ask again). If they
1658
+ approve only some concepts ("1 and 3 are good, redo 2"), record each approved one with its
1659
+ \`project_id\` instead, and redo the rest. Then set the batch to \`rendering\` and run **Step 4 (the expensive render)** for each
1660
+ concept with up to 8 isolated workers when the machine can sustain them. Retry
1661
+ concurrency_limit after retry_after_seconds; reduce concurrency on a limited machine. Deliver each (Step 5). When every concept is pinned, set the batch to
1662
+ \`complete\`. A concept the Step 4.3 gate leaves \`blocked\` cannot be pinned (a batch concept
1663
+ needs \`passed\`): finish the others, set the batch to \`blocked\`, and tell the user which
1664
+ concepts passed and which are blocked, with each one's failing checks.
856
1665
 
857
1666
  If a single concept fails, keep going with the rest, mark that concept blocked, and report which
858
1667
  ones shipped — never abort the whole batch on one bad concept. Everything below (Steps 1–5) is
@@ -860,11 +1669,18 @@ written per-project; a batch just runs it N times with the shared approval gate
860
1669
 
861
1670
  ## Step 1 — resolve the project, source, brand
862
1671
 
863
- 1. \`get_ad_project { project_id }\` → keep \`brand_id\`, \`source_sample_id\`, \`name\`, \`status\`, the
864
- **top-level** \`app_url\` + \`brand_url\` (returned alongside \`project\`, NOT inside it — the links
865
- you hand the user for the in-app review in Step 3 and delivery in Step 5), AND the user's
866
- **\`creative_brief\`**, project **\`assets\`**, \`character_id\`, \`default_voice_id\` — these are the
867
- authoritative inputs the user chose in the composer (see Step 1.5). Do NOT discard them.
1672
+ 1. \`video_project_read { brand_id, project_id }\` → keep \`brand_id\`, \`source_sample_id\`, \`name\`,
1673
+ \`status\`, the **top-level** \`app_url\` + \`brand_url\` (the links you hand the user for the in-app
1674
+ review in Step 3 and delivery in Step 5), AND the user's **\`creative_brief\`**, project
1675
+ **\`assets\`**, \`character_id\`, \`default_voice_id\` — these are the authoritative inputs the user
1676
+ chose in the composer (see Step 1.5). Do NOT discard them. Then \`export GW_PROJECT_ID=<project_id>\`.
1677
+ Keep its saved \`campaign_id\` and \`campaign_concept_id\` too. If the customer explicitly
1678
+ wants to attach this existing video to a known campaign/concept, verify the IDs with the
1679
+ campaign read and use \`video_project_upsert { brand_id, project_id, patch: {
1680
+ campaign_association: { campaign_id, campaign_concept_id? } } }\` as a separate, sole-field
1681
+ patch. Read back the same project and confirm the saved IDs. Linking never needs a new
1682
+ project, render, generation call or approval. A conflicting saved link stays intact; explain
1683
+ it instead of silently moving the video. Leave unlinked legacy videos alone unless asked.
868
1684
 
869
1685
  ### Step 1.5 — the project brief is AUTHORITATIVE (honor it; don't re-ask)
870
1686
 
@@ -883,49 +1699,277 @@ for a field the brief leaves empty. Map the fields you WILL honor:
883
1699
  assets.
884
1700
  - \`character_id\` → the avatar/creator to use. \`default_voice_id\` → the voice for any VO (put its
885
1701
  NAME in the review \`subtitle\`). Use these instead of picking your own.
886
- - \`creative_brief.ratio\` / \`.durationSeconds\` → target aspect ratio + length. Honor when the
887
- format's render pipeline supports it; if the format physically can't (e.g. a fixed phone-mockup
888
- aspect), keep the format's native value and note the constraint in the review rather than silently
889
- ignoring the request.
1702
+ - \`creative_brief.durationSeconds\` → target length; honor it when the format allows.
1703
+ \`creative_brief.ratio\` → video ads are ALWAYS 9:16 (1080×1920). If the brief asks for another
1704
+ ratio, make 9:16 anyway and say so in the review; never export another size (a recipe's
1705
+ "also 1:1" option included).
890
1706
  - \`polish_policy\` (\`standard\` | \`extra\`) → \`extra\` means spend the extra pass on QC/polish.
891
- 2. \`get_ad_template { template_id: source_sample_id }\` → the source video: \`media_url\`,
892
- \`recipe\`, \`format\` (e.g. "imessage"), \`extracted_script\`, \`how_to\`, \`remix_spec\`.
893
- 3. Brand gate: \`get_brand_kit { brand_id }\`. If \`researchStatus\` is \`complete\`, REUSE it —
894
- never re-research. If not, run brand research first (\`gooseworks fetch brand-research\`,
895
- follow it, then \`finalize_brand_research { brand_id }\`) before continuing.
1707
+
1708
+ 2. \`catalog_fetch { type: "template", slug: <source_sample_id> }\` → the source video: \`media_url\`,
1709
+ \`recipe\`, \`format\` (e.g. "podcast-skit", "imessage"), \`extracted_script\`, \`how_to\`, \`remix_spec\`.
1710
+ 3. Brand gate: \`brand_read { brand_id, sections: ["summary", "kit", "products", "learnings"] }\`
1711
+ (older clients: \`brand_get_context\` with the same sections). Ask for all four: the default
1712
+ leaves out the kit and the brand's saved rules, and a video made without them is off-brand.
1713
+ If the kit's \`researchStatus\` (or the brand's \`research_status\`) is \`complete\`, REUSE it —
1714
+ never re-research. If not, run brand research first (\`catalog_fetch { type: "skill", slug:
1715
+ "brand-research" }\`) and follow its stored-pack workflow. Only when that verified pack is
1716
+ saved in the supported research workspace, finalize with
1717
+ \`brand_update { brand_id, patch: { finalize_research: true } }\`, then read the brand back.
1718
+ Never send raw research JSON through \`kit_patch\`: the public tool accepts only the existing
1719
+ \`video_lab\` asset slot there. If there is no verified stored pack, submit researched facts
1720
+ through typed \`patch.knowledge\` / \`patch.kit\` as pending agent proposals; do not pretend
1721
+ research is finalized or its proposals are approved. Then do Step 1.7 with verified facts.
1722
+
1723
+ ### Step 1.6 — a remix of a FINISHED video (the project read has a \`remix\` block)
1724
+
1725
+ A project made from **Community videos** remakes another customer's finished video for THIS brand.
1726
+ Its \`video_project_read\` returns a top-level \`remix\` block
1727
+ (\`{ remix_of_project_id, instruction, direction }\`), and \`reference_video_url\` is that finished video.
1728
+
1729
+ - **Watch the reference video first** (download \`reference_video_url\`, pull frames + the transcript).
1730
+ It is the target: match its structure, beat order, pacing, framing, look, voice and tone.
1731
+ - **\`remix.direction\` is its approved review set** (scenes and lines, set/look notes, take prompts,
1732
+ captions, music, voice). Start your review set from it instead of the template's defaults; it
1733
+ already carries every change that customer made to the template.
1734
+ - **\`remix.direction.implementation\`, when present, is HOW it was made**: the pipeline and the model
1735
+ each step used, the style and negative prompts, the character and per-scene still/motion prompts
1736
+ with their guards, voice and music settings, the mix, and \`fixes\` (what went wrong and how it was
1737
+ fixed). Reuse the same models, style/negative prompts and guards, rewrite the prompts' subjects for
1738
+ this brand, and apply every \`fix\` up front so you don't repeat the same mistake.
1739
+ - **Rewrite everything for THIS brand.** "[source brand]", "[source product]", "[link]", "[email]"
1740
+ and "[code]" mark the other customer's details: never write them, and never reuse their claims,
1741
+ numbers, URLs, offers or CTA. Every product, claim, name, image and CTA comes from this brand's
1742
+ kit, products and media. Their footage (screen recordings, product shots) and their creator face
1743
+ are NOT carried over: use this brand's own assets and make a new creator from the description.
1744
+ - Precedence: this project's own \`creative_brief\` and assets (Step 1.5) > \`remix.direction\` >
1745
+ the template recipe's defaults.
1746
+ - In the Step 3 review, say it is a remix of that video and list what you kept vs. changed.
1747
+
1748
+ ### Step 1.7 — the brand rules file and the brand assets (every run, before any writing)
1749
+
1750
+ Write \`working/brand-rules.json\` from the Step 1 brand read. Every later step reads THIS file,
1751
+ not your memory of the chat:
1752
+
1753
+ \`\`\`json
1754
+ {
1755
+ "name": "Acme",
1756
+ "pronunciations": [{ "term": "Acme", "say_as": "ak-mee", "learning_id": "…" }],
1757
+ "must_say": [{ "text": "…", "learning_id": "…" }],
1758
+ "never_say": [{ "text": "Never claim it cures insomnia", "learning_id": "…" }],
1759
+ "products": [{ "id": "…", "name": "…", "facts": ["size, flavour, price, ingredients as stored"], "images": ["…"] }],
1760
+ "logo": { "url": "…", "confidence": "<kit.logoConfidence>" },
1761
+ "fonts": ["…"],
1762
+ "palette": ["#…"]
1763
+ }
1764
+ \`\`\`
1765
+
1766
+ - **Video taste is direction, not dialogue.** Before mapping brand rules, extract entries
1767
+ prefixed \`Video preference:\` from both \`learnings\` and \`kit.instructions\` into the verified
1768
+ taste brief, including accepted proposals. They govern pacing, voices, captions, visuals and
1769
+ format choice; do not copy them into \`must_say\` / \`never_say\` or read them aloud. Carry the
1770
+ brief into the choices, scene planning and review.
1771
+ - **Sources.** \`learnings\` are the brand's saved rules (the user's past corrections among them):
1772
+ \`must\` / \`do\` → \`must_say\`, \`dont\` → \`never_say\`, and a \`must\` whose text reads
1773
+ \`Pronounce "<term>" as "<say_as>"\` (straight or curly quotes) → \`pronunciations\`. Add \`kit.instructions\` (free-text
1774
+ standing rules) only when they require actual spoken wording or prohibit a claim. Production
1775
+ directions stay in the brief. A required spoken line or prohibited claim remains its own
1776
+ ordinary \`must\` / \`dont\` rule.
1777
+ - **Which product.** The one the brief names (\`creative_brief.productName\`); with none, the row
1778
+ whose name matches the product the user asked for, or the brand itself for a one-product
1779
+ brand. Product lists often hold other brands' items or old ads saved as products: if more than
1780
+ one row could be it, ask in the choices round. Never mix facts across rows.
1781
+ - **Product facts** come from that row (name, description, variant, price) and, when the row is
1782
+ empty, from the kit (\`valueProps\`, \`description\`, \`tagline\`): nothing else. Write them to
1783
+ \`products[].facts\`; the script may only state what is there.
1784
+ - **Logo.** Download the kit's logo FILE (\`kit.logoUrl\`, else \`kit.logos[0]\`) to \`working/brand/\`,
1785
+ keeping its real extension (an SVG stays \`.svg\`; rasterise it to a 1024px-wide PNG with
1786
+ \`rsvg-convert\` or \`cairosvg\` when a renderer needs pixels). It is used as-is on every scene and
1787
+ end card that shows a logo: **never generate, redraw, re-letter or restyle a logo with an image
1788
+ model.** If the kit's \`logoConfidence\` says favicon-grade, or the file's long side is under
1789
+ 256 px (or it is under 40,000 px²), it is a site favicon, not a logo: do not upscale it. Ask the user for a real logo (or offer the brand name
1790
+ set as text in the brand font) in the SAME question round as the recipe's \`choices\`.
1791
+ - **Font.** \`kit.typography.heading\` when its \`source\` is \`user\` (the user chose it), else
1792
+ \`kit.fonts.heading\`. Download the font file (the kit's own, or the same family from Google
1793
+ Fonts) to \`working/brand/\` and use it for every on-screen line. With no match, use the closest
1794
+ free font and say so in the review.
1795
+ - **No wordmark file.** When a recipe wants a wordmark SVG and the kit has only a logo image, set
1796
+ the brand name as text in the brand font beside the logo file. Never generate one.
1797
+ - Record in \`brand-rules.json\` which logo the video will actually composite (\`logo.file\`), or
1798
+ \`"logo": { "mode": "text" }\` when it will show only the brand name set in the brand font.
1799
+ - **Product images.** Download this product's own images to \`working/brand/\`. Use only images of
1800
+ THIS product: never a catalogue image of another product, a mascot, a lifestyle photo of a
1801
+ person, or a stand-in. If the product has no usable image, ask in the choices round.
1802
+
1803
+ ### Brand corrections stick — save them to the brand the moment they are made
1804
+
1805
+ When the user corrects something about the BRAND in chat — how a name is said, a claim that may
1806
+ not be made, a product fact, a visual rule ("never use red", "the logo goes top-left") — save it
1807
+ in the SAME turn, before anything else:
1808
+
1809
+ \`brand_update { brand_id, knowledge_intent: "user_correction", user_statement: <the user's exact correction>, patch: { facts: [{ kind, text }] } }\`
1810
+
1811
+ | Correction | \`kind\` | \`text\` |
1812
+ |---|---|---|
1813
+ | Pronunciation | \`must\` | \`Pronounce "Acme" as "ak-mee"\` (exactly this form) |
1814
+ | A claim or word to avoid | \`dont\` | \`Never say or imply: <the claim>\` |
1815
+ | Something that must be said | \`must\` | \`<the rule>\` |
1816
+ | A product fact | \`must\` | \`<product name>: <the fact>\` |
1817
+ | A visual rule | \`do\` / \`dont\` | \`<the rule>\` |
1818
+
1819
+ - If it changes an EXISTING rule (a new pronunciation for the same term), update that rule by id
1820
+ (\`facts: [{ id: <learning_id>, text }]\`) instead of adding a second one.
1821
+ - Use the correction intent and user's statement when supported, as described below. Read
1822
+ \`brand_read\` learnings back and verify the rule and source before claiming it was saved.
1823
+ - Then tell the user in one line: "Saved to your brand for future videos." Update
1824
+ \`working/brand-rules.json\` and apply the rule to THIS video too.
1825
+ - A one-off note about this video ("make it shorter", "use the blue background here") is NOT a
1826
+ brand rule: don't save it.
1827
+
1828
+ ${DURABLE_BRAND_CAPTURE}
1829
+
1830
+ ${VIDEO_TASTE_CAPTURE}
896
1831
 
897
1832
  ## Step 2 — read the template's recipe (it carries everything; NO hardcoded format map)
898
1833
 
899
1834
  The ad format is a **template (data) in the ad_sample DB**, not a per-format skill.
900
- \`get_ad_template(source_sample_id)\` returns the template's \`recipe\` — a self-contained brief you
1835
+ \`catalog_fetch { type: "template" }\` returns the template's \`recipe\` — a self-contained brief you
901
1836
  read and execute. **Do NOT map \`format\` to a hardcoded recipe slug** (there is no such table):
902
1837
 
903
1838
  - \`recipe.format\` — the format label (e.g. \`vignette\`), for display only.
904
- - \`recipe.atoms\` — the **capabilities** this template composes (e.g. \`create-video-seedance-2-fal\`,
905
- \`create-image-gpt-image-fal\`, \`review-ugc-render\`, \`watch\`). \`gooseworks fetch <name>\` each — they
906
- live in \`skills/ads/capabilities/\` and are reused across templates (so they cache).
1839
+ - \`recipe.atoms\` — the **capabilities** this template composes (e.g. \`create-vo-elevenlabs\`,
1840
+ \`create-image-gpt-image-fal\`, \`render-podcast-skit\`, \`review-ugc-render\`, \`watch\`). Fetch each
1841
+ with \`catalog_fetch { type: "skill", slug }\` (or \`gooseworks fetch <name>\` when the CLI is
1842
+ installed) — they are reused across templates.
907
1843
  - \`recipe.instructions\` — the **playbook** to follow: \`instructions.inline\` prose, or
908
1844
  \`instructions.doc_url\` (an S3 markdown doc — fetch it).
909
1845
  - \`recipe.config\` — every param (prompts, layout, timings, palette, model choices).
910
1846
  - \`recipe.inputs\` — the brand-asset contract (which product / logo / offer this template needs).
1847
+ - \`recipe.choices\` — the creative calls the USER makes (who is on screen, narrator, tone, setting,
1848
+ art style, music). Ask every unanswered one in ONE round before any paid step, with its options plus
1849
+ "you pick". Its \`reference\` is what the demo used: an example, never the default.
911
1850
  - \`recipe.assets\` — reference material as S3 links (reference render, style guide, example frames) —
912
1851
  fetch as needed.
913
1852
 
914
- Runtime: **read the recipe → \`gooseworks fetch\` each capability in \`recipe.atoms\` → follow
1853
+ Runtime: **read the recipe → fetch each capability in \`recipe.atoms\` → follow
915
1854
  \`recipe.instructions\` with \`recipe.config\` + the brand's bound \`inputs\`.** The template IS the recipe;
916
1855
  there is no \`format → recipe-slug\` table and no per-format skill to fetch.
917
1856
 
918
- Save each fetched capability's scripts + files under \`/tmp/gooseworks-scripts/<name>/\`. If a capability
919
- is a Node package (a phone-mockup renderer), \`npm install\` in its folder so its \`generate.js\` +
920
- Playwright resolve, and point the recorder's \`NODE_PATH\` at it.
1857
+ Save each fetched capability's content, scripts + files under \`/tmp/gooseworks-scripts/<name>/\`
1858
+ (layout in "Running in a GooseWorks sandbox"). If a capability is a Node package (a phone-mockup
1859
+ renderer), install its documented dependencies in the folder containing its \`package.json\`,
1860
+ and preserve the recorder's documented \`NODE_PATH\` — local machines only; in a sandbox that
1861
+ format stops (no Chromium).
1862
+
1863
+ **Selected browser readiness — before ANY paid ingredient:** identify the actual browser script
1864
+ from the fetched capability's instructions (including an HTML end-card renderer if used).
1865
+ For Node scripts using \`require('playwright')\` with default \`chromium.launch()\`, run
1866
+ \`gooseworks doctor --renderer-script "/absolute/path/to/the/fetched/scripts/record.js"\`.
1867
+ Substitute the actual script, and keep the same cwd and environment as the render, including
1868
+ \`NODE_PATH\` and \`PLAYWRIGHT_BROWSERS_PATH\`. It resolves Playwright relative to that script,
1869
+ launches and closes Chromium with the default settings and bounded waits, and downloads nothing.
1870
+ On failure, stop before spending, show its folder-specific repair and recheck after setup.
1871
+ For non-browser formats use \`doctor --no-browser\` plus their documented runtime checks;
1872
+ never combine \`--no-browser\` with \`--renderer-script\` or use it to bypass a browser renderer.
1873
+
1874
+ **No CLI or CLI without these flags:** run an equivalent free probe in a separate Node process: use
1875
+ \`require('node:module').createRequire(require('node:path').resolve(actualRendererScript))\`
1876
+ to load \`playwright\`; keep the render's cwd, environment and default launch settings. Await
1877
+ \`chromium.launch({ timeout: 15000 })\`, then await \`browser.close()\` (bound close to 3 seconds).
1878
+ Bound the whole process to 20 seconds and stop its own process tree on failure or timeout.
1879
+ Report the resolved module path/version and error without credentials. Missing module, executable,
1880
+ headless runtime or failed launch is a failed check; a cache folder, executablePath alone or
1881
+ another project's browser is not a pass. Other browser packages, Python renderers or custom
1882
+ launch settings need the same free launch/close check through their documented runtime and
1883
+ actual settings. Do not replace their browser/channel/flags to get a pass. Setup is a separate
1884
+ action under existing permissions; this check never silently installs or downloads anything.
921
1885
 
922
1886
  > **Migration note:** older phone-mockup formats (\`imessage\` / \`chatgpt\` / \`apple-notes\`) whose DB
923
1887
  > recipe does not yet carry \`atoms\` / \`instructions\` still hold the legacy \`recipe.thread\` payload;
924
1888
  > migrate them to this shape (capabilities + instructions in the DB) — do not reintroduce a CLI map.
925
1889
 
926
- ## Step 3 — assemble the review set, then get ONE approval in the app (before the expensive render)
927
-
928
- This is a **review-once** flow: put the whole review set in the app, get ONE approval, then run the
1890
+ ## Step 2.5 — plan words and visuals with \`write-video-ad-script\`
1891
+
1892
+ Every video concept gets creative strategy, including silent formats. Fetch
1893
+ **\`write-video-ad-script\`** through the skill catalogue and follow it before assembling
1894
+ review ingredients. It reuses or fetches **\`ad-angle-miner\`**, binds the researched promise
1895
+ to this template's full recipe, writes words and visuals together, and checks product
1896
+ claims and production fit. Its independent critic is a quality screen, not a forecast
1897
+ of ad performance. The existing Step 3 review and approval remain unchanged.
1898
+
1899
+ - **Carry the research into the writer.** Pass the brand and exact product, audience,
1900
+ objective, offer, CTA, selected template recipe, available assets and the full miner
1901
+ bank or its readable workspace pointer. A selected miner idea includes its angle id,
1902
+ evidence and proof plan, not only its hook. Reuse the shared video-angle-bank.v1 from
1903
+ the brand's video-scripts workspace or this run. Prepare angle-context.json with the
1904
+ writer's preparation script with \`--brief working/script/creative-brief.json\` and use
1905
+ its strict rule check before review. Save the sourced brief in the writer's documented
1906
+ shape: exact product/variant, buyer situation, supported mechanism, offer/CTA, constraints,
1907
+ delivery intent, source references, locked copy, applicable prior decisions and unknowns.
1908
+ New custom/template shapes set \`requires_creative_brief: true\`; both writer and critic
1909
+ receive the same angle-context. Carry that brief revision into the scene/tool plan and
1910
+ production manifest; missing evidence stays explicit rather than becoming a claim.
1911
+ - **Already decided stays decided.** The user's angle, hook, batch concept, recipe choice
1912
+ or remix direction is binding. Preserve the selected angle id. Compare executions or
1913
+ hooks inside it; do not reopen the angle choice. An incompatible promise needs a
1914
+ supported execution or an explicit format change before production.
1915
+ - **The recipe owns the production contract.** Its story mechanism, speakers, timing,
1916
+ text limits and visual capabilities win. Inspect the actual recipe and available assets;
1917
+ a catalogue card alone cannot establish fit. An impossible essential visual blocks
1918
+ the proposal until repaired. Do not force a testimonial into every format.
1919
+ - **Research only what is missing.** Fetching the miner does not spend or rerun research.
1920
+ Reuse current facts and prior evidence. If paid collection is needed, its permission
1921
+ rides in the existing choices round. A new product with no reviews can use verified
1922
+ facts and a feasible demo; do not require paid research merely to fill a quote quota.
1923
+ - **Choose eligible concepts only.** Take the strongest supported concept and validated
1924
+ hook into review, with up to two viable alternatives when the direction is open.
1925
+ Do not pad three concepts or select the highest-ranked rejected one. If all fail,
1926
+ repair within the brief and recipe before Step 3.
1927
+ - **Unavailable writer or research.** Complete an explicit agent check of claim support,
1928
+ recipe limits, visual feasibility and hook payoff. Record missing provenance and say
1929
+ in the review when research is provisional. Never report a failed check as a pass.
1930
+ - **The user's exact lines** remain verbatim; use report-only checks and raise material
1931
+ timing, claim or format conflicts without silently rewriting them.
1932
+ - **No spoken words.** Still fit the visual promise, reveal, cards and CTA to the silent
1933
+ recipe. Skip speech writing and spoken checks, not the strategy step.
1934
+ - **Keep private provenance separate.** Store source quotes and links in the research
1935
+ workspace; put only a concise strategy explanation in remixable review data.
1936
+
1937
+ ## Shared editorial craft inside this template flow
1938
+
1939
+ Fetch \`video-production-harness\` and read its \`references/editorial-review.md\`,
1940
+ \`references/specialist-handoff.md\` and \`references/hook-compatibility.md\`, plus the
1941
+ review/edit/polish/promote/wrap steps when used. Save the fetched version/content hash with
1942
+ this run's capability records. These supply craft and evidence rules inside the template
1943
+ flow; this entry's existing review, paid approval, storage and two-repair limit still apply.
1944
+ Do not turn a template into a custom project or import the custom host's extra gates.
1945
+
1946
+ Before executing a fetched recipe atom, pass the exact brief/script revision, scene/beat IDs,
1947
+ timing, selected product/assets/source windows, performance choice and expected output roles.
1948
+ Check actual scripts/dependencies and free runtime readiness, then validate returned media
1949
+ against that handoff. An interrupted run reuses valid approved media with matching digest;
1950
+ a file merely existing does not prove validity. A missing package/required renderer blocks
1951
+ that route before paid generation, with a concrete supported alternative for review.
1952
+
1953
+ Rough review asks what the cut communicates and whether the proof/payoff serves the hook;
1954
+ fine review diagnoses performance, sequence and local execution; final review checks each
1955
+ actual export. Save the received message from the cut before comparing with the brief where
1956
+ possible. A technically clean incoherent cut returns to script/sequence work; a local caption
1957
+ defect gets a local repair. These internal questions share existing review surfaces.
1958
+
1959
+ Before a hook change, classify same-promise compatible opening versus new-promise/body recut.
1960
+ For example, an automatic report supports “stop copying campaign results”; it does not alone
1961
+ prove “know where to spend the next dollar.” Propose required script/body/coverage changes for
1962
+ the latter. Every restyled opening gets fresh image/action/audio/text review even when words
1963
+ are unchanged. Fetch the existing \`render-hook-replacement\` before selecting that route;
1964
+ a not-found/empty result stops it before generation. Use its actual preflight and preservation
1965
+ checks when available; never build a duplicate renderer or infer publication from source.
1966
+ Compare complete labeled candidates, retain source/body/ending and record the hypothesis.
1967
+ No quality score or recommendation is an observed performance winner.
1968
+
1969
+ ## Step 3 — assemble the review set, then get ONE approval (before the expensive render)
1970
+
1971
+ This is a **review-once** flow: save the whole review set to the project, get ONE approval in this
1972
+ chat, then run the
929
1973
  expensive render + any remaining paid work end-to-end. Never spend on the expensive render before
930
1974
  approval, and don't drip pieces out one at a time and re-pause.
931
1975
 
@@ -938,9 +1982,10 @@ every piece three ways by cost, NOT just "free vs paid":
938
1982
  mirror the real asset. The few credits buy a real review: the user SEES the actual creator face
939
1983
  and end card and HEARS the VO, instead of judging a prompt. **This OVERRIDES any recipe rule that
940
1984
  says to gate ALL paid calls** — only the expensive render below is gated.
941
- - **EXPENSIVE paid** — the video take / final AI render (hundreds of credits) → do NOT generate.
942
- Put its **exact prompt/spec** (+ ref image URLs) in the tile. This is the ONE thing approved as a
943
- prompt (you can't preview a hundreds-of-credits video for free); it's generated only in Step 4.
1985
+ - **EXPENSIVE paid** — the video take / final AI render / per-line lipsync clips (hundreds of
1986
+ credits) → do NOT generate. Put its **exact prompt/spec** (+ ref image URLs) in the tile. This is
1987
+ the ONE thing approved as a prompt (you can't preview a hundreds-of-credits video for free); it's
1988
+ generated only in Step 4.
944
1989
 
945
1990
  **The expensive render's exact prompt must be in the panel BEFORE you ask for approval** — so a
946
1991
  single "go" runs it (plus any remaining paid work) without re-pausing mid-run.
@@ -957,27 +2002,38 @@ render (GOOSE-2542). The full video is assembled ONLY in Step 4, after approval.
957
2002
  ingredient here is only a genuinely separate SOURCE clip the format needs (e.g. supplied b-roll).
958
2003
 
959
2004
  1. **Assemble every piece the format needs — not just the script.** Read the recipe for the exact
960
- list. For an iMessage video that's the **script** (bubble thread), the **conversation image(s)**,
961
- and the **end card**; richer templates add a hook frame, background, product shots, music bed, a
962
- creator/avatar, a voiceover… For each piece, decide FREE / CHEAP-paid / EXPENSIVE-paid (above):
963
- - **FREE or CHEAP paid** (≤ ~100 credits — HTML mockups, a still, the creator frame, the end
964
- card, a short VO/music bed) → generate it now and \`get_upload_url\` the asset to the project
965
- folder \`agent-config/brands/<brand_slug>/projects/<project_id>/working/review/<name>\` (same
966
- path-prefix rule as final publish — a bare \`working/review/<name>\` won't render in the panel);
967
- set that piece's \`path\` in \`script_drafts\` to the project-relative \`working/review/<name>\`.
968
- - **EXPENSIVE paid** (the video take / final render, hundreds of credits) → do NOT generate. Put
969
- the **exact prompt/spec** (and any ref image URLs) in the tile's \`text\` / \`subtitle\` so the
970
- user reviews what will be spent on. No \`path\` yet — it's generated in Step 4.
971
- Include the **estimated cost in CREDITS** (never dollars) of the cheap pieces already generated +
972
- the pending render, so the user approves knowing the total spend. **Answer clarifying questions
2005
+ list. For a podcast skit that's the **script** (both hosts' lines), the two **host stills**,
2006
+ one **voice sample per host**, and the **end card**; an iMessage video has the bubble thread,
2007
+ the conversation image(s) and the end card. For each piece, decide FREE / CHEAP-paid /
2008
+ EXPENSIVE-paid (above):
2009
+ - **FREE or CHEAP paid** (≤ ~100 credits) → generate it now and upload it with
2010
+ \`media_upload { brand_id, scope: "video_project", scope_id: project_id, kind, path:
2011
+ "working/review/<name>", ingredient_key, input_digest, source: { type: "file", filename:
2012
+ "<name>", content_type } }\` → PUT → \`media_confirm { brand_id, media_id: media.id }\`;
2013
+ after confirmation succeeds, set that
2014
+ piece's \`path\` (+ \`media_id\`, \`ingredient_key\`) in \`script_drafts\` to the project-relative
2015
+ \`working/review/<name>\`. First check "Save as you go" — a piece already saved with the same
2016
+ digest is downloaded, not regenerated.
2017
+ - **EXPENSIVE paid** → do NOT generate. Put the **exact prompt/spec** (and any ref image URLs)
2018
+ in the tile's \`text\` / \`subtitle\` so the user reviews what will be spent on. No \`path\` yet —
2019
+ it's generated in Step 4.
2020
+ Save **render_estimate.total_credits**: previews already spent + pending render + the 200 base fee.
2021
+ Use current server pricing, never a catalog range in place of the full total.
2022
+ **Brand check of the script, before it goes in the panel:** every line, caption and on-screen
2023
+ text is checked against \`working/brand-rules.json\`. Nothing in \`never_say\` appears, in words or
2024
+ in meaning (a paraphrase of a banned claim is still banned). Every product detail (name,
2025
+ flavour, size, price, ingredient, result) comes from \`products[]\` or the kit: anything else is
2026
+ cut, not invented. Add a \`note\` ingredient labelled "Brand rules applied" that lists the
2027
+ pronunciations used and the rules the script respects, so the user sees them.
2028
+ **Answer clarifying questions
973
2029
  from the project brief FIRST (Step 1.5)** — only ask the user for a field (angle, which product,
974
2030
  offer/code) the \`creative_brief\` leaves empty AND the recipe can't default. Do not re-ask for
975
2031
  anything the composer already captured.
976
- 2. **Mirror the whole ingredient set for review** — \`update_ad_project_script { project_id,
977
- script_drafts, script }\`. \`script_drafts\` is a structured payload of **container-tagged
978
- ingredients** so the app renders each piece the right way:
979
- \`{ format, scenes?, ingredients: [{ container, label, subtitle?, path?, text? }] }\`. Each
980
- ingredient's \`container\` tells the app HOW to show it:
2032
+ 2. **Mirror the whole ingredient set for review** — \`video_project_upsert { brand_id, project_id,
2033
+ patch: { script: { script_drafts, script } } }\`. \`script_drafts\` is a structured payload of
2034
+ **container-tagged ingredients** so the app renders each piece the right way:
2035
+ \`{ format, scenes?, ingredients: [{ container, label, subtitle?, path?, url?, text? }], render_estimate? }\`.
2036
+ Each ingredient's \`container\` tells the app HOW to show it:
981
2037
  - \`image\` (a frame shown in the video), \`endcard\` (the end card), \`avatar\` (a character
982
2038
  headshot), \`background\` → rendered as an image tile.
983
2039
  - \`voice\` (a voiceover clip — put the voice NAME in \`subtitle\`), \`music\` (the bed),
@@ -985,147 +2041,325 @@ ingredient here is only a genuinely separate SOURCE clip the format needs (e.g.
985
2041
  - \`video\` (a clip) → a video player. \`text\` (a copy line like the CTA) → a text tile.
986
2042
  - \`script\` / \`thread\` / \`note\` / \`conversation\` → the written script (or set \`scenes[]\`
987
2043
  for the podcast shape, or pass the readable \`script\` string).
988
- \`path\` = \`working/review/<name>\` (upload the preview asset first via \`get_upload_url\`); \`url\`
989
- works too. **Label every ingredient** ("Hook image", "End card", "Voiceover", "Background
990
- music", "HER"). The \`update_ad_project_script\` call itself writes no render and costs no credits
991
- (the cheap pieces you already generated above have their own small cost) — it just populates the
992
- review panel.
993
- 3. **STOP — the review happens in the APP's review panel, NOT in this chat.** You've mirrored the
994
- ingredients (3.2); now hand the user the project's \`app_url\` (from \`get_ad_project\`) and tell
995
- them to review the pieces there and hit **"Approve & render"**. That button gives them a short
996
- message to paste back into this session — THAT is your go-ahead. Do NOT paste the
997
- script/ingredients into the chat for a thumbs-up, and do NOT render until that approval comes
998
- back from the app. If they want changes (via the app's comments or here), regenerate the
999
- affected ingredient, call \`update_ad_project_script\` again, tell them it's refreshed in the
1000
- app, and wait for a fresh approval. Only AFTER the app approval do Step 4. A single approval
1001
- authorises the WHOLE remaining chain — generate every paid piece, render, self-QC, publish —
1002
- with NO further pauses (that is exactly why every paid prompt must already be in the panel).
1003
-
1004
- ## Step 4 — render locally, report stages, publish
1005
-
1006
- 1. Now generate every PAID piece you showed as a prompt in Step 3 — the AI stills/video, voice,
1007
- music, the end-card render — through the media proxies (below), each from its approved prompt.
1008
- Then assemble per the recipe (Playwright record where needed → ffmpeg stitch → \`mix-master\`
1009
- audio).
1010
- 2. Open the row LAST: \`submit_render { project_id, kind: "full" }\` → keep \`render_id\`, then
1011
- \`update_render_status { render_id, status: "running" }\`. The render row tracks status only
1012
- (queued / running / complete / failed) — narrate fine-grained progress with
1013
- \`append_project_message\` instead.
1014
- 3. **MANDATORY final-video QC gate — YOU review EVERY finished master before \`set_final_render\`,
1015
- whatever the format (UGC or not).** This is your own automated quality check, separate from the
1016
- user's Step-3 approval — it does not go back to the user. The render row is already open (its
1017
- nominal credit spent, \`submit_render\` in 4.2);
1018
- this gate stands between a rendered master and PINNING/publishing it, so a bad render never gets
1019
- set as final. A master that looks fine on a still can still have a mis-voiced word, a caption
1020
- drifting off its line, a beat out of order, or a deformation — review the actual VIDEO, not
1021
- stills. Run the passes that APPLY to this format:
2044
+ **Label every ingredient** ("Hook image", "End card", "Voiceover", "Host A", "HER"). The upsert
2045
+ writes no render and costs no credits — it just populates the review panel.
2046
+ 3. **STOP for ONE approval, in this chat.** Only a complete current saved review set with
2047
+ render_estimate.total_credits can be approved. Widget: one line, no duplicate plan or app
2048
+ link; otherwise print card.text_summary. The choices are Approve, Change and Not now.
2049
+ “Not now” keeps the plan. In a coworker sandbox end the turn after saving the review set;
2050
+ the customer's approval arrives as the next message.
2051
+ Record the explicit yes with \`video_project_upsert { brand_id, project_id, patch: { approve:
2052
+ { user_quote: "<their exact words>", total_credits: <the saved total> } } }\` before rendering.
2053
+ A single project requires recorded approval too; never treat an absent approval as permission.
2054
+ Changes require an updated saved review, clearing prior approval, and approval of the new
2055
+ total. One yes authorizes the remaining approved chain. On insufficient_balance start
2056
+ nothing; offer a shorter video or top-up. Remove batch concepts with patch.concepts remove:true,
2057
+ then show the changed total before approval.
2058
+
2059
+ ## Step 4 — render, report stages, publish
2060
+
2061
+ 1. **Open the render row FIRST** — right after recording the Step 3 approval, before any paid
2062
+ generation (if this returns \`approval_required\`, the approval is missing or was cleared: go
2063
+ back to Step 3 and ask in this chat, don't retry):
2064
+ \`${exports.RENDER_ROW_TOOL} { brand_id, project_id, ${exports.RENDER_OPEN_ARGS} }\` (no \`dry_run\`; returns
2065
+ \`render_id\`) → keep \`render_id\`, then mark it running:
2066
+ \`${exports.RENDER_ROW_TOOL} { brand_id, project_id, ${exports.RENDER_UPDATE_KEY}: { render_id, status: "running",
2067
+ workflow_stage: "preparing", progress_note: "starting", progress_percent: 5 } }\`. The user sees this
2068
+ live in the app and gets a WhatsApp "started" message automatically — don't message them yourself
2069
+ about start / blocked / complete.
2070
+ After EVERY progress callback inspect stop. If true, start no new paid step; record
2071
+ status:"stopped" with a plain note and report what is kept and credits used. SPEND_CAP_REACHED
2072
+ stops the same way; raising the cap requires patch.approve scope:"raise_cap" and the customer's
2073
+ words. Send render.steps with the same neutral names each time and a live count only in the
2074
+ current detail; use render.choices when blocked.
2075
+ 2. Now generate every PAID piece you showed as a prompt in Step 3 — the AI stills/video, lipsync
2076
+ clips, voice, music — through the media proxies (below), each from its approved prompt, with
2077
+ \`GW_PROJECT_ID\` exported. **Save as you go** (section above): skip any piece already saved
2078
+ with the same \`input_digest\` (download it), and upload each new piece with its
2079
+ \`ingredient_key\` + \`input_digest\` the moment it passes QC.
2080
+ Keep the approved script and review unchanged throughout production and QC; confirmed media
2081
+ and progress preserve resume state. Stop and replan/reapprove any material creative change.
2082
+ A voiceover made with \`data_post_provider\` (ElevenLabs \`…/with-timestamps\`) returns its
2083
+ \`alignment\` only in the reply: write it to \`working/vo/<scene>.timestamps.json\` at once
2084
+ (captions are timed from it) and record the returned \`media_id\` on the ingredient.
2085
+ **Brand pronunciations in every voiceover:** the text sent to the voice has each
2086
+ \`pronunciations[].term\` replaced by its \`say_as\` (\`create-vo-elevenlabs\`:
2087
+ \`gen_vo.py … --rules working/brand-rules.json\`; when a render atom calls the voice itself,
2088
+ swap the terms in the text you hand it). Captions, on-screen text and the review keep the
2089
+ written name. Write \`working/approved-script.txt\` (the Step 4.3 audio check) with the SPOKEN
2090
+ form. **Logo, font, product:** every logo is the file from Step 1.7 composited as-is; every
2091
+ product shot uses the Step 1.7 product images as its reference.
2092
+ Then assemble per the recipe (ffmpeg stitch; PIL captions / end card;
2093
+ Playwright record only where the format needs it and the host has Chromium → \`mix-master\` audio).
2094
+ **Report progress at each milestone** — about one update per milestone, never per poll:
2095
+ \`${exports.RENDER_ROW_TOOL} { brand_id, project_id, ${exports.RENDER_UPDATE_KEY}: { render_id, status: "running", workflow_stage, progress_note, progress_percent } }\`
2096
+ (\`progress_note\` = plain words the customer reads in the app, ≤200 chars; no model, tool or
2097
+ step names):
2098
+ - voiceovers done → \`"preparing"\`, \`"voices recorded"\`, 20
2099
+ - stills done → \`"preparing"\`, \`"scenes designed"\`, 35
2100
+ - each lipsync / video clip → \`"rendering"\`, e.g. \`"filming scene 5 of 8"\`, 35–75
2101
+ - assembly → \`"rendering"\`, \`"putting the video together"\`, 85
2102
+ - QC (4.3) → \`"final check"\`, 95
2103
+ **Hard stop that needs the user** → \`{ render_id, status: "running", workflow_stage: "blocked",
2104
+ error_message: "<what's wrong + what you need>" }\`; an unrecoverable failure → \`status: "failed"\`
2105
+ + \`error_message\`. Completing (4.4) sets the bar to 100.
2106
+ 3. **MANDATORY final-video QC gate — YOU review EVERY finished master before pinning it
2107
+ (\`patch.final_render_id\`), whatever the format (UGC or not).** This is your own automated quality
2108
+ check, separate from the user's Step-3 approval — it does not go back to the user. The render row
2109
+ is already open (4.1); this gate stands between a rendered master and PINNING/publishing it, so a
2110
+ bad render never gets set as final. A master that looks fine on a still can still have a
2111
+ mis-voiced word, a caption drifting off its line, a beat out of order, or a deformation — review
2112
+ the actual VIDEO, not stills. Run the passes that APPLY to this format:
1022
2113
  - **Audio ↔ script** — any master with SPEECH (VO or native/Seedance voice); **skip for
1023
2114
  music-only / no-speech formats.** \`review-ugc-render\` is format-agnostic despite the name —
1024
- a deterministic Whisper transcript-vs-script diff, not UGC-specific: persist the approved
1025
- spoken lines to \`working/approved-script.txt\`, then \`gooseworks fetch review-ugc-render\` and
1026
- run \`review_render.py --video <master>.mp4 --script-file working/approved-script.txt --json
1027
- working/review-verdict.json\` (exit 0 PASS / 2 FAIL / 3 ERROR). It blocks a mis-voiced word
2115
+ a deterministic Whisper transcript-vs-script diff: persist the approved spoken lines to
2116
+ \`working/approved-script.txt\`, fetch \`review-ugc-render\` (\`catalog_fetch\`) and run
2117
+ \`review_render.py --video <master>.mp4 --script-file working/approved-script.txt --json
2118
+ working/review-verdict.json\` (exit 0 PASS / 2 FAIL / 3 ERROR). For each brand pronunciation add
2119
+ \`--brand-term "<term>"\`, plus \`--brand-term\` for each word of \`say_as\` that is not an
2120
+ everyday word (the flag strips those tokens from the WHOLE diff, so never pass "a", "one",
2121
+ "works" alone): Whisper spells a respelled name back as the brand word ("Goose Works" heard
2122
+ as "Gooseworks"), so the diff must accept it. The proof of
2123
+ intended delivery is the text/settings you sent (keep them in the review); actual
2124
+ pronunciation/performance requires isolated and mixed-audio listening at normal speed.
2125
+ Preserve pauses/emphasis and final consonants; never mandate faster or louder delivery.
2126
+ Verify a transcript mismatch against the actual audio before calling it a defect. It flags a mis-voiced word
1028
2127
  (approved "human-vetted" → "human witted"), a dropped phrase, or silence. It routes Whisper
1029
- through the gooseworks proxy when \`OPENAI_BASE_URL\` is set; with no backend at all, run
1030
- \`fal-ai/whisper\` via \`fal-proxy\` (upload the audio, pass its \`get_download_url\` as \`audio_url\`)
2128
+ through the gooseworks proxy when \`OPENAI_BASE_URL\` is set (sandbox:
2129
+ \`$GW_WHISPER_PROXY_URL/v1\`); with no backend at all, run \`fal-ai/whisper\` via the FAL proxy
1031
2130
  and diff the transcript yourself.
1032
2131
  - **Captions / subtitles** — ANY captioned format (the most common non-UGC defect); **skip for
1033
- UGC/Seedance masters, which carry no subtitle track.** Concrete check: diff the caption file
1034
- you burned (SRT/ASS) against the SAME Whisper transcript + word timings from the audio pass —
1035
- every caption line must match the heard/scripted words and sit within ~0.3s of when they're
1036
- spoken; then in the visual pass below, OCR-read the burned caption off 4–5 sampled frames to
1037
- confirm it's actually on screen at that time and not colliding with a hyperframe or the end
1038
- card. Mismatched text or >0.3s drift fails the gate.
2132
+ UGC/Seedance masters, which carry no subtitle track.** Diff the caption file you burned
2133
+ (SRT/ASS/PNG cue list) against the SAME Whisper transcript + word timings — every caption line
2134
+ must match the heard/scripted words and sit within ~0.3s of when they're spoken; then in the
2135
+ visual pass below, inspect each cue and its start/end boundaries in actual frames, plus
2136
+ full-speed playback at destination size, to confirm reading time, product visibility,
2137
+ hierarchy and no duplicate overlay or end-card collision. Silent/text-led formats use
2138
+ approved visible wording and reading windows, not nonexistent speech timings. Mismatched text or >0.3s drift fails the gate.
1039
2139
  - **Visual + structure** — always: run the \`watch\` skill on the master — beat/scene order + SFX,
1040
- the brand's product (not the source's) is shown, the end card has the real wordmark + code, no
2140
+ the brand's product (not the source's) is shown, the end card has the brand's logo file (or its name set in the brand font) + code, no
1041
2141
  deformation/artifact, duration within ~20% of the source.
1042
- If ANY applicable pass fails, FIX it (regenerate/stitch the offending window, rebuild captions)
1043
- and re-review — only a clean pass proceeds to \`set_final_render\`. **This gate is universal: it
1044
- runs from the master skill for every format, so a recipe never has to opt in.**
1045
- 4. Publish: \`get_upload_url { target: { type: "agent", agent_id: ADS_AGENT } }\` → PUT the master
1046
- and poster **under the project folder** (see Identity's path-prefix rule) — to
1047
- \`agent-config/brands/<brand_slug>/projects/<project_id>/working/final.mp4\` and
1048
- \`.../working/final-thumb.jpg\`. **Always target ADS_AGENT AND use the full project-folder path**
1049
- — a bare \`working/final.mp4\`, even on the right agent, 404s in the app. Verify servable:
1050
- \`get_download_url { target: ADS_AGENT, path: "agent-config/brands/<brand_slug>/projects/<project_id>/working/final.mp4" }\`
1051
- must return a non-empty URL (curl it for HTTP 200).
1052
- Then \`update_render_status { render_id, status: "complete", output_url, thumbnail_url }\` where
2142
+ - **Finished ad + brand fidelity** — always: fetch \`review-finished-ad\` (\`catalog_fetch\`,
2143
+ \`pip install --quiet numpy pillow\` if needed) and run
2144
+ \`review_finished_ad.py --video <master>.mp4 --json working/review/finished-ad.json
2145
+ --sheet working/review/finished-ad-sheet.png --logo <the logo file the video composites>
2146
+ --palette "<kit palette, comma-separated>" --product-images <the Step 1.7 images>
2147
+ --font <brand font file> --brand-name "<name>" --endcard-s <end card length>\`. Pass the
2148
+ file that is ACTUALLY on screen (the kit logo, or the recipe's wordmark file). When the video
2149
+ shows only the brand name as text (\`"logo": {"mode": "text"}\`), omit \`--logo\` and judge the
2150
+ text on the sheet. Add \`--no-speech\` for a format with no VO or dialogue, \`--logo-at <s>\` for
2151
+ each mid-video logo, and any gate flags the recipe's instructions name (a chat format's
2152
+ reading holds need a longer \`--max-freeze-s\`). Exit 0 PASS / 2 FAIL / 3 ERROR. It
2153
+ checks size, hook, pacing, dead air, black frames, the kit logo on the end card
2154
+ (a wrong, redrawn or favicon logo fails) and the palette. **Then open the sheet it writes
2155
+ and judge every line of its \`judge_on_sheet\`:** captions/CTA/logo outside the red safe
2156
+ zones, the brand font, every product shot matching the product images, the product the same
2157
+ in every scene, the logo unaltered. A failed eye check is a FAIL like any other.
2158
+ - **Output size** — always **1080×1920 (9:16)**. Video ads are only ever 9:16. Lipsync / video
2159
+ models often return 720p or odd sizes — scale (and pad if the aspect differs) every clip to
2160
+ 1080×1920 BEFORE the concat, never ship the model's native size.
2161
+ Save exact output checksum/version, first-to-last normal-speed playback and full-audio
2162
+ coverage. Frame sheets, transcripts and process success do not substitute for listening or
2163
+ continuous motion. Missing required capability leaves review incomplete/blocked. Each
2164
+ supported crop, duration, language or caption derivative needs its own actual-file review;
2165
+ unsupported destination requirements need a reviewed route, never a silent export change.
2166
+ Honor intended silence, loops and endings rather than forcing music or fades on every ad.
2167
+ If ANY applicable pass fails, FIX it (regenerate/stitch the offending window, re-composite the
2168
+ end card from the real logo file, rebuild captions) and re-run the passes — only a clean pass
2169
+ proceeds to pinning. **At most 2 repair rounds.** If a pass still fails after them, do NOT pin
2170
+ and do NOT present the video as finished: upload it (4.4) and close the row with exactly
2171
+ \`video_render_run { brand_id, project_id, render: { render_id, status: "complete",
2172
+ workflow_stage: "blocked", quality_status: "blocked", repair_pass_count: 2, output_url,
2173
+ thumbnail_url, quality_report } }\` (the failing checks as \`fail\` in the report), and tell the user plainly in
2174
+ chat which checks failed, what you tried, and the choices (fix a specific thing, re-roll, or
2175
+ use it anyway). Pin it only if they say to use it anyway. The app shows a blocked render as
2176
+ "Needs attention". **This gate is universal: it runs from this skill for every format, so a
2177
+ recipe never has to opt in.**
2178
+ 4. **For a passing final, create the finished-video checkpoint first**, following "Finished video, interrupted saving"
2179
+ above. With the CLI, use its prepare/resume flow instead of duplicating the writes below; it
2180
+ saves the same already-opened render and pins only the checked output. Save the final review set
2181
+ and production manifest (Step 4.5/4.6) before preparing that checkpoint. Without it, follow the
2182
+ same durable protocol. A blocked version follows Step 4.3's existing upload/report-only path;
2183
+ never route it through the passing-final helper or pin it automatically.
2184
+ Publish: \`media_upload { brand_id, scope: "video_project", scope_id: project_id, kind: "render",
2185
+ path: "working/final.mp4", ingredient_key: "final", input_digest, source: { type: "file", filename: "final.mp4", content_type:
2186
+ "video/mp4" } }\` → PUT the master to \`upload.url\` with \`upload.required_headers\` →
2187
+ \`media_confirm { brand_id, media_id: media.id }\`. Same for the poster (\`kind: "thumbnail"\`, \`path: "working/final-thumb.jpg"\`, \`ingredient_key: "final-thumb"\`).
2188
+ Keep each \`upload.render_file_url\`. Verify the PUT returned 2xx and the file you uploaded is a
2189
+ real, non-empty MP4 (ffprobe it), and require both confirmations to succeed BEFORE marking
2190
+ the render complete.
2191
+ Then \`${exports.RENDER_ROW_TOOL} { brand_id, project_id, ${exports.RENDER_UPDATE_KEY}: { render_id, status: "complete", output_url, thumbnail_url } }\` (attach the Step 4.3 verdict as \`quality_status: "passed"\` (or
2192
+ \`"blocked"\` when the gate still fails after 2 repair rounds) + \`quality_report\` — ALWAYS
2193
+ attach it; a batch concept cannot complete without a passing one; exact shape, strict (no extra keys):
2194
+ \`{ version: 1, summary: string, checks: { source, brand, product, hook_and_scene_order,
2195
+ voice_and_script, captions, endcard_and_cta, duration_and_ratio, visual_artifacts }, detected_issues?:
2196
+ string[], repair_actions?: string[] }\` where EVERY check is \`{ status: "pass"|"fail"|"not_applicable",
2197
+ note?: string }\`). Fill each check from the Step 4.3 passes: \`brand\` ← logo_asset + logo +
2198
+ palette + font + logo unaltered; \`product\` ← product likeness + product consistency;
2199
+ \`hook_and_scene_order\` ← hook + pacing + the \`watch\` beat order; \`voice_and_script\` ← the
2200
+ Whisper diff (pronunciations included) + no \`never_say\` line; \`captions\` ← the caption diff +
2201
+ safe zones; \`duration_and_ratio\` ← ratio + duration; \`visual_artifacts\` ← black frames +
2202
+ frozen stretches + the \`watch\` pass; \`endcard_and_cta\` ← the end card holds the real logo +
2203
+ CTA. Put each failing check's note in \`detected_issues\` and each fix in \`repair_actions\`.
1053
2204
  **output_url MUST be the durable render-file URL**
1054
- \`/api/ads/projects/<project_id>/render-file?path=working/final.mp4\` (the app re-presigns it on
1055
- every view) — NEVER a raw proxy/CDN URL (those expire). Same for \`thumbnail_url\`.
1056
- 5. \`set_final_render { project_id, render_id }\` to pin it, then return the \`app_url\` +
1057
- \`brand_url\` (from the project/links) verbatim. Never end on just "done" or a file path.
1058
-
1059
- Narrate each long step in one line via \`append_project_message { project_id, role: "agent",
1060
- content }\` — never sit silent on a queue > 90s.
2205
+ (\`upload.render_file_url\`, i.e. \`/api/ads/projects/<project_id>/render-file?path=working/final.mp4\`
2206
+ — the app re-presigns it on every view) — NEVER a raw proxy/CDN/presigned URL (those expire).
2207
+ Same for \`thumbnail_url\`.
2208
+ 5. **Save the final review set BEFORE pinning** — it must describe the video you actually rendered.
2209
+ Only after all paid production, QC, repairs and pending provider work are finished and settled,
2210
+ save one final descriptive/provenance update: confirmed pieces, exact settings and repairs that
2211
+ preserve the approved creative choices. Material creative changes, including changed lines,
2212
+ look, timing, captions or music, require a changed complete plan, total and fresh approval BEFORE
2213
+ the changed production. Never relabel a changed plan as provenance or silently reuse approval.
2214
+ In the checkpoint flow, save the final review before Step 4.4; do not rewrite it afterward merely
2215
+ to follow the numbered order. Resume checks that this reviewed set stayed unchanged.
2216
+ When final provenance needs updating, upsert the review set once:
2217
+ \`video_project_upsert { brand_id, project_id, patch: { script: {
2218
+ script_drafts, script } } }\` with the final lines, final pieces (mark generated takes as done, not
2219
+ "not generated yet") and the settings you used. The project keeps this, not your chat: it is
2220
+ what the app shows, and what a Community remix of this video copies. Instructions that live only
2221
+ in this conversation are lost when it ends. **Keep the approved detail**: never shorten a piece to a
2222
+ summary (e.g. per-scene prompts or their "no shake / no letterbox" guards). Only update what changed.
2223
+ After this write, do not start new paid work. Save the production manifest, prepare the final
2224
+ checkpoint and complete the same render with its existing finishing allowance and guards.
2225
+ 6. **Save the production manifest** — HOW you made it, so the next run (or a remix) starts from what
2226
+ worked instead of rediscovering it: \`video_project_upsert { brand_id, project_id, patch: { production:
2227
+ { version: 1, pipeline: [{ step, model, purpose?, settings? }], style: { prompt, negative, notes? },
2228
+ characters: [{ name, prompt }], scenes: [{ id, line, still_prompt, motion_prompt, duration_s }],
2229
+ voice: { voice_id, name, model, settings }, music: { prompt, model, length_s }, assembly: { … },
2230
+ fixes: [{ problem, fix }], notes? } } }\`. Use the exact models and prompts you sent (full text, guards
2231
+ included), and list every fix you had to make (e.g. "VO ran 47s → tightened four lines, voice 1.08x";
2232
+ "hair drifted → restated the hair colour"). No URLs, keys or raw logs; it must stay under 48 KB.
2233
+ In the checkpoint flow, save this before Step 4.4 too and skip the duplicate write afterward.
2234
+ 7. Pin it — only a \`passed\` render (or a \`blocked\` one the user said to use anyway):
2235
+ If checkpoint recovery already verified selection of this render, skip this duplicate write.
2236
+ An unfinished checkpoint must use the guarded selection protocol above; never replace it
2237
+ with an unguarded pin.
2238
+ \`video_project_upsert { brand_id, project_id, patch: { final_render_id: render_id } }\`,
2239
+ then use the returned card: widget hosts get one line and no duplicate links; text hosts get
2240
+ card.text_summary and the returned delivery links verbatim. Never end with a local file path.
2241
+
2242
+ Narrate each long step in one line via \`video_project_upsert { brand_id, project_id, patch:
2243
+ { message: { role: "agent", content } } }\` — never sit silent on a queue > 90s. Write it for the
2244
+ customer ("Filming the scenes, about 5 more minutes"), per "How to talk to the customer" above.
1061
2245
 
1062
2246
  ## Media generation — the GooseWorks proxies (queue loop)
1063
2247
 
1064
- Media APIs go through GooseWorks proxies with your agent token; do NOT use an SDK's default host
1065
- (your token isn't a FAL/ElevenLabs token → 401). Base = \`<api_base>/api/internal/<proxy>\`; pass
1066
- \`?token=<api_key>&agent_id=<agent_id>&project_id=<project_id>\` (agent_id bills the Ads agent;
1067
- \`project_id\` = the id of the project you're rendering — it attributes this generation's credits to
1068
- that ad project so the user sees per-project spend in the app. ALWAYS pass it). FAL = \`fal-proxy\`
1069
- (+ \`fal-storage-proxy\` to host a local image and get a CDN URL); ElevenLabs = \`elevenlabs-proxy\`
1070
- (VO / music bed).
2248
+ Media APIs go through GooseWorks proxies; do NOT use an SDK's default host (your token isn't a
2249
+ FAL/ElevenLabs token → 401, and in a sandbox a raw provider call is never allowed). Prefer the
2250
+ atoms' own \`media_proxy.py\` (\`fal_generate\`, \`fal_generate_video\`, \`eleven_music\`, …) — it already
2251
+ handles auth, the queue host-swap, project attribution (\`GW_PROJECT_ID\`) and failure logging.
2252
+
2253
+ - **Sandbox:** FAL base = \`$GW_FAL_PROXY_URL\`, ElevenLabs = \`$GW_ELEVENLABS_PROXY_URL\`, FAL
2254
+ storage = \`$GW_FAL_STORAGE_PROXY_URL\`; auth = \`?token=$GW_MEDIA_PROXY_TOKEN\` (or
2255
+ \`Authorization: Bearer\`), plus \`&project_id=$GW_PROJECT_ID\`. The token already names the agent.
2256
+ - **Local:** base = \`<api_base>/api/internal/<proxy>\` (\`fal-proxy\`, \`fal-storage-proxy\`,
2257
+ \`elevenlabs-proxy\`); pass \`?token=<api_key>&agent_id=<agent_id>&project_id=<project_id>\`
2258
+ (agent_id bills the Ads agent; project_id attributes the spend to this ad project so the user
2259
+ sees per-project spend in the app. ALWAYS pass it).
1071
2260
 
1072
2261
  **FAL queue gotcha** (#1 waste of generations): submit returns \`status_url\`/\`response_url\` on
1073
2262
  \`queue.fal.run\` (the real host, not the proxy). Polling those 401s forever — rewrite their host
1074
- to the proxy base (keep the path), re-add \`?token=&agent_id=\`. Only the final \`*.fal.media\`
1075
- image is a real public URL. Helper:
2263
+ to the proxy base (keep the path), re-add the auth params. Only the final \`*.fal.media\`
2264
+ file is a real public URL. Helper (works in both modes):
1076
2265
 
1077
2266
  \`\`\`python
1078
2267
  import json, os, pathlib, time, requests
1079
2268
  from urllib.parse import urlparse
1080
2269
 
1081
2270
  def _cfg():
2271
+ """(fal_base, token, agent_id). Sandbox env first, then ~/.gooseworks/credentials.json."""
2272
+ tok = os.environ.get("GW_MEDIA_PROXY_TOKEN")
2273
+ if tok:
2274
+ base = os.environ.get("GW_FAL_PROXY_URL") or os.environ["GW_API_BASE"].rstrip("/") + "/api/internal/fal-proxy"
2275
+ return base.rstrip("/"), tok, None
1082
2276
  c = json.loads(pathlib.Path(os.path.expanduser("~/.gooseworks/credentials.json")).read_text())
1083
- return c["api_base"].rstrip("/"), c["api_key"], c.get("agent_id")
2277
+ return c["api_base"].rstrip("/") + "/api/internal/fal-proxy", c["api_key"], c.get("agent_id")
1084
2278
 
1085
- def _params(tok, agent, project_id=None):
2279
+ def _params(tok, agent):
1086
2280
  p = {"token": tok}
1087
2281
  if agent: p["agent_id"] = agent
1088
- if project_id: p["project_id"] = project_id # attributes the spend to this ad project
2282
+ pid = os.environ.get("GW_PROJECT_ID")
2283
+ if pid: p["project_id"] = pid # attributes the spend to this ad project
1089
2284
  return p
1090
2285
 
1091
- def fal_generate(model_path, payload, project_id=None, timeout_s=180, poll_s=3):
2286
+ def fal_generate(model_path, payload, timeout_s=180, poll_s=3):
1092
2287
  """model_path e.g. 'fal-ai/nano-banana-2/edit' (the recipe names the model).
1093
- Pass project_id = the ad project you're rendering so credits attribute to it.
1094
- Returns the result image URL (a public *.fal.media CDN URL)."""
1095
- api_base, tok, agent = _cfg()
1096
- base = api_base + "/api/internal/fal-proxy"
1097
- sub = requests.post(f"{base}/{model_path}", params=_params(tok, agent, project_id), json=payload).json()
2288
+ Export GW_PROJECT_ID first. Returns the result image URL (a public *.fal.media URL)."""
2289
+ base, tok, agent = _cfg()
2290
+ sub = requests.post(f"{base}/{model_path}", params=_params(tok, agent), json=payload).json()
1098
2291
  to_proxy = lambda u: base + urlparse(u).path
1099
2292
  status_url, response_url = to_proxy(sub["status_url"]), to_proxy(sub["response_url"])
1100
2293
  deadline = time.time() + timeout_s
1101
2294
  while time.time() < deadline:
1102
- st = requests.get(status_url, params=_params(tok, agent, project_id)).json()
2295
+ st = requests.get(status_url, params=_params(tok, agent)).json()
1103
2296
  if st.get("status") == "COMPLETED":
1104
- return requests.get(response_url, params=_params(tok, agent, project_id)).json()["images"][0]["url"]
2297
+ return requests.get(response_url, params=_params(tok, agent)).json()["images"][0]["url"]
1105
2298
  if st.get("status") in ("FAILED", "ERROR"):
1106
2299
  raise RuntimeError(f"FAL failed: {st}")
1107
2300
  time.sleep(poll_s)
1108
2301
  raise TimeoutError("FAL polling exceeded timeout")
1109
2302
  \`\`\`
1110
2303
 
1111
- ElevenLabs (VO / music) is the same shape against \`<api_base>/api/internal/elevenlabs-proxy\`
1112
- with \`?token=&agent_id=&project_id=\`. Feed FAL a local image by storing it (\`get_upload_url\`) and passing its
1113
- \`get_download_url\` presigned URL as an \`image_urls\` / \`audio_url\` entry — this is the reliable
1114
- path. (\`fal-storage-proxy\` may 404 depending on the install; don't block on it — prefer the
1115
- \`get_download_url\` presigned URL.)
2304
+ ElevenLabs (VO / music) is the same shape against the ElevenLabs proxy base. To feed FAL a local
2305
+ file (a product image, a VO track), it must be a PUBLIC URL: upload it with \`media_upload\`
2306
+ (\`scope: "video_project"\`, source \`file\`, no \`path\`) → PUT → \`media_confirm\` and use the returned
2307
+ \`media.url\` if it is a public https URL (curl it: HTTP 200 without auth), or host it through the
2308
+ FAL storage proxy. Never pass a \`render-file\` URL to a provider — it needs app auth.
2309
+
2310
+ ## Follow-up actions use the watched version
2311
+
2312
+ Keep original note text, exact source render/time and intended viewer effect. Record an
2313
+ acceptance condition and disposition in existing feedback/project artifacts; applying a
2314
+ command means changed, not verified. Consolidate duplicates without deleting their source
2315
+ IDs. Conflicting “calmer” and “more urgent” instructions need the authorized decision owner's
2316
+ recorded choice, even if they touch different files. Offer concrete cheap alternatives for
2317
+ “more premium” inside the approved scope before escalating taste.
2318
+
2319
+ Map changed copy/performance/shot/pause to affected picture, timings, captions, music/SFX,
2320
+ approvals and derivatives; preserve unrelated approved work. Rewatch the full candidate and
2321
+ verify the original effect before resolving a note. Accepted final, candidate and original
2322
+ note source remain distinct across selection and rollback. Keep editable script/timeline,
2323
+ source assets/takes, stems, captions, package versions and prior decisions in the existing
2324
+ production manifest/history; retrieve applicable rejections/pronunciation/delivery rules
2325
+ before a related brief. Project taste is not a standing brand rule. Record audience results
2326
+ only with actual variant/audience/placement/objective/window; otherwise unavailable.
2327
+
2328
+ - “Fix this”: use the render/project context attached to the message (or named version, else
2329
+ the final one). Save patch.fix { of_render_id, changes, total_credits }. Never replace a supplied
2330
+ watched render with the final. After explicit approval save patch.approve { user_quote,
2331
+ total_credits, scope:"fix" }, then video_render_run { kind:"partial", fix_of_render_id }.
2332
+ Re-make only changed scenes, keep earlier versions and charge no second base fee.
2333
+ - “Make 3 more like this”: video_project_upsert { brand_id, name, remix_of_project_id,
2334
+ remix_of_render_id, vary, concepts:3 }. Preserve a provided watched render; omit only when none is named.
2335
+ - “Test 1 of each”: approve only:"test"; “Make the other N”: only:"rest". “Stop the rest”:
2336
+ job_cancel { job_id:<batch_id> }. Finished videos stay saved.
2337
+ - Share for review uses patch.share_for_review { subject }; return the real link.
1116
2338
 
1117
2339
  ## Rules
1118
2340
 
1119
- - **MCP + ffmpeg + Playwright required** — run \`gooseworks doctor\` in Phase 0; stop with the
1120
- exact fix it prints if anything is ✗.
1121
- - **Assemble the whole review set first**, mirror it with \`update_ad_project_script\`, and get the
1122
- user's approval **in the app's review panel** (the "Approve & render" button) BEFORE the expensive
1123
- render — never ask for a thumbs-up in this chat (review-once, in-app).
2341
+ - **Canonical MCP tools first** (\`video_project_read\`, \`video_project_upsert\`, \`catalog_fetch\`,
2342
+ \`media_upload\` + \`media_confirm\`, the \`video_render_run\` render-row actions, \`account_whoami\`);
2343
+ legacy names only when the client lacks the canonical tool.
2344
+ - **A missing key is never a blocker.** Paid media goes through the proxy: a one-off image or clip
2345
+ is \`data_post_provider { provider: "fal", … }\` + \`job_get\` (see "Paid media over the MCP");
2346
+ never ask for FAL_KEY, never use \`photos_generate\` for anything but a physical product.
2347
+ - **The CLI and credentials.json are optional.** In a GooseWorks sandbox (\`GW_MEDIA_PROXY_TOKEN\`
2348
+ set) use the env proxies and \`catalog_fetch\`; never call a provider with a raw key.
2349
+ - **No Chromium in a sandbox** — a browser-rendered format stops there, before any spend, and says so.
2350
+ - **Toolchain before spend** — common checks use \`gooseworks doctor --no-browser\`; every selected
2351
+ browser renderer must also pass \`--renderer-script\` or its equivalent exact-runtime launch
2352
+ check in Step 2. Stop with the folder-specific fix if anything is missing.
2353
+ - **Assemble the whole review set first**, mirror it with \`video_project_upsert patch.script\`, and
2354
+ get ONE approval in this chat, recorded with \`patch.approve\`, BEFORE the expensive render
2355
+ (review-once). Never send the user to the app to approve; the app is only for reviewing.
1124
2356
  - **Show the REAL cheap pieces; PROMPT only the expensive render.** Generate the FREE + CHEAP-paid
1125
2357
  pieces (≤ ~100 credits — stills, creator frame, end card, short VO/music) and mirror the real
1126
2358
  assets; put ONLY the expensive video take/render in the panel as its exact prompt. That prompt
1127
2359
  must be in the panel before you ask to approve, so a single "go" runs the render + any remaining
1128
2360
  paid work (→ QC → publish) with no re-pausing.
2361
+ - **Operator may be absent (sandbox):** decide mechanical choices yourself; ask in chat only for a
2362
+ true taste call.
1129
2363
  - **Costs in CREDITS, never dollars.** credits ≈ round-up(provider-$ × 120) per generation + a flat
1130
2364
  200-credit base per video; never show a "$…" figure to the user.
1131
2365
  - **Never assemble the full video before approval.** The review shows the
@@ -1133,19 +2367,27 @@ path. (\`fal-storage-proxy\` may 404 depending on the install; don't block on it
1133
2367
  stitched/composited cut; do not add a "full cascade" / finished-video clip
1134
2368
  as a review ingredient (GOOSE-2542). The assembled video is produced only in
1135
2369
  Step 4.
1136
- - **submit_render only after the master is rendered** (Step 4.2), never on a guess; \`output_url\` =
1137
- the durable render-file URL, never a CDN URL.
1138
- - **Always pass \`project_id\` on media-proxy calls** (fal / ElevenLabs) so the credits attribute
1139
- to this ad project — that's what lets the user see per-project spend in the app.
2370
+ - **Open the render row at the start of Step 4** (4.1, after the approval) and keep its stage /
2371
+ progress current; mark it \`complete\` only after the master passes QC. \`output_url\` = the
2372
+ durable render-file URL, never a CDN URL.
2373
+ - **Always export \`GW_PROJECT_ID\`** (and pass \`project_id\` on hand-rolled proxy calls) so the
2374
+ credits attribute to this ad project.
1140
2375
  - **Verify a real, non-empty MP4** (watch it) before marking the render complete.
1141
2376
  - **Reuse the brand** when its research is complete; never re-research.
2377
+ - **Brand rules first:** load kit + products + learnings (Step 1), write \`working/brand-rules.json\`
2378
+ (Step 1.7), and follow it: pronunciations in every voiceover, nothing from \`never_say\`, product
2379
+ facts only from the product rows, the kit's logo FILE (never a generated or favicon logo), the
2380
+ brand font, this product's own images.
2381
+ - **Save brand corrections** from chat with \`brand_update patch.facts\` in the same turn, and say so.
2382
+ - **Finished-ad gate on every master** (\`review-finished-ad\` + the sheet); at most 2 repair
2383
+ rounds, then publish as \`blocked\` with the report and warn the user — never pass off a failing
2384
+ video as finished.
1142
2385
  - On a hard error (auth/quota/model/timeout) set the render \`failed\` with a short
1143
- \`error_message\` and stop — don't ship the source unchanged. **Also \`log\` it** (\`gooseworks log\`
1144
- / \`log_cli_event\`, \`--event-type api_failure|error\`) so we can see + fix it (see "Report problems").
1145
- - **Report blockers/bugs/confusing instructions via telemetry** (\`gooseworks log\` or the
1146
- \`log_cli_event\` MCP tool) — not just to the user. Set \`GW_RUN_ID\` once so events group.
1147
- - Always end a successful run with \`app_url\` + \`brand_url\`, verbatim.
1148
- `;
2386
+ \`error_message\` (\`${exports.RENDER_ROW_TOOL} { …, ${exports.RENDER_UPDATE_KEY}: { render_id, status: "failed", error_message } }\`) and stop — don't ship the source unchanged. **Also log
2387
+ it** (see "Report problems") so we can see + fix it.
2388
+ - Finish according to card.display_hint: widget hosts get one short line without duplicate links;
2389
+ text hosts get card.text_summary and the returned delivery links verbatim.
2390
+ ${STORED_FOOTAGE_GUIDANCE}`;
1149
2391
  }
1150
2392
  /**
1151
2393
  * Returns the goose-product-photos entry SKILL.md content.
@@ -1186,6 +2428,8 @@ Photos studio uses, so the skill and the app can never drift. The point is to **
1186
2428
  usable product imagery** — approved photos join the brand kit and can then feed the ad workflow
1187
2429
  (\`goose-ads\`).
1188
2430
 
2431
+ ${CUSTOMER_TALK}
2432
+
1189
2433
  ## Prerequisite — the GooseWorks MCP server is REQUIRED
1190
2434
 
1191
2435
  Everything goes through the \`mcp__gooseworks__*\` tools. If they are not available, **stop and
@@ -1195,7 +2439,7 @@ HTTP/file fallback.
1195
2439
  ## Start from the brand context — don't re-ask what it already answers
1196
2440
 
1197
2441
  If the \`gooseworks\` router handed you brand context, USE IT. If you were invoked directly, call
1198
- \`brand_get_context\` yourself first. It answers most of the setup questions below, so **do not ask
2442
+ \`brand_read\` yourself first. It answers most of the setup questions below, so **do not ask
1199
2443
  the user for them**:
1200
2444
 
1201
2445
  - **Which product?** — the context's \`products[]\` are the real catalog entries. Offer them; never
@@ -1259,7 +2503,7 @@ whether a human model is wanted (which needs explicit consent — see the rules)
1259
2503
 
1260
2504
  ## Workflow — shoot a product
1261
2505
 
1262
- 1. **Load the brand context** (\`brand_get_context\`, or reuse what the router passed you) and
2506
+ 1. **Load the brand context** (\`brand_read\`, or reuse what the router passed you) and
1263
2507
  **resolve the brand + product.** \`list_ad_brands\` → \`brand_id\`. \`list_brand_products\` → pick a
1264
2508
  \`product_id\` from the catalog you already know about. If the product genuinely isn't there,
1265
2509
  \`import_product\` (poll \`get_product_import\`).
@@ -1277,7 +2521,7 @@ whether a human model is wanted (which needs explicit consent — see the rules)
1277
2521
  - **Never invent product facts.** The backend grounds the shot on the product's real images; don't
1278
2522
  describe a product you can't see.
1279
2523
  - **Use the brand context instead of interviewing the user.** Product, audience, voice, positioning,
1280
- logo/colors/fonts all come from \`brand_get_context\` / the brand kit. Ask only for the shot
2524
+ logo/colors/fonts all come from \`brand_read\` / the brand kit. Ask only for the shot
1281
2525
  category, count, quality, and model consent.
1282
2526
  - **Ask before spending.** Quote the estimate and confirm \`count\` / \`quality\` before
1283
2527
  \`generate_product_photos\` — it reserves credits.
@@ -1289,4 +2533,8 @@ whether a human model is wanted (which needs explicit consent — see the rules)
1289
2533
  kit / ad workflow; archived ones never do.
1290
2534
  `;
1291
2535
  }
2536
+ /** Thin GooseWorks connection to the catalog-published production harness. */
2537
+ function getMakeCustomVideoSkillContent() {
2538
+ return custom_video_skill_1.CUSTOM_VIDEO_ADAPTER_CONTENT.replace("\n# Agent version\n", `\n# Agent version\n\n${CUSTOMER_TALK}\n\n${ENVIRONMENT_IDENTITY}\n\n${ASSET_READINESS}\n`) + STORED_FOOTAGE_GUIDANCE;
2539
+ }
1292
2540
  //# sourceMappingURL=master-skill.js.map