@mevdragon/vidfarm-devcli 0.2.12 → 0.2.14

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 (205) hide show
  1. package/.env.example +37 -1
  2. package/README.md +27 -183
  3. package/SKILL.director.md +293 -0
  4. package/SKILL.platform.md +312 -0
  5. package/auto-create-hyperframe-templates/AUTO_CREATE_HYPERFRAME_TEMPLATES.md +275 -0
  6. package/auto-create-hyperframe-templates/extractor-system-prompt.md +128 -0
  7. package/auto-create-hyperframe-templates/input-manifest.schema.json +56 -0
  8. package/auto-create-hyperframe-templates/lambda-memory-estimator.md +118 -0
  9. package/auto-create-hyperframe-templates/production-graph.schema.json +314 -0
  10. package/auto-create-hyperframe-templates/runbook.md +198 -0
  11. package/auto-create-hyperframe-templates/scripts/create-hyperframe-template.mjs +368 -0
  12. package/auto-create-hyperframe-templates/template-plan.schema.json +311 -0
  13. package/auto-create-hyperframe-templates/template-planner-prompt.md +144 -0
  14. package/auto-create-templates/AUTO_CREATE_TEMPLATES.md +116 -0
  15. package/auto-create-templates/extractor-system-prompt.md +6 -1
  16. package/auto-create-templates/template-plan.schema.json +73 -2
  17. package/auto-create-templates/template-planner-prompt.md +62 -1
  18. package/dist/src/account-pages-legacy.js +363 -89
  19. package/dist/src/account-pages-legacy.js.map +1 -0
  20. package/dist/src/account-pages.js +3 -2
  21. package/dist/src/account-pages.js.map +1 -0
  22. package/dist/src/app.js +7096 -1294
  23. package/dist/src/app.js.map +1 -0
  24. package/dist/src/cli.js +115 -29
  25. package/dist/src/cli.js.map +1 -0
  26. package/dist/src/composition-runtime.js +581 -0
  27. package/dist/src/composition-runtime.js.map +1 -0
  28. package/dist/src/config.js +69 -11
  29. package/dist/src/config.js.map +1 -0
  30. package/dist/src/context.js +280 -21
  31. package/dist/src/context.js.map +1 -0
  32. package/dist/src/dev-app-legacy.js +18 -17
  33. package/dist/src/dev-app-legacy.js.map +1 -0
  34. package/dist/src/dev-app.js +1 -0
  35. package/dist/src/dev-app.js.map +1 -0
  36. package/dist/src/dev-serve.js +169 -0
  37. package/dist/src/dev-serve.js.map +1 -0
  38. package/dist/src/domain.js +2 -1
  39. package/dist/src/domain.js.map +1 -0
  40. package/dist/src/editor-chat-history.js +10 -0
  41. package/dist/src/editor-chat-history.js.map +1 -0
  42. package/dist/src/editor-chat.js +135 -25
  43. package/dist/src/editor-chat.js.map +1 -0
  44. package/dist/src/editor-dark-theme.js +1128 -0
  45. package/dist/src/editor-dark-theme.js.map +1 -0
  46. package/dist/src/frontend/flockposter-cache-store.js +10 -2
  47. package/dist/src/frontend/flockposter-cache-store.js.map +1 -0
  48. package/dist/src/frontend/homepage-client.js +6 -3
  49. package/dist/src/frontend/homepage-client.js.map +1 -0
  50. package/dist/src/frontend/homepage-shared.js +1 -0
  51. package/dist/src/frontend/homepage-shared.js.map +1 -0
  52. package/dist/src/frontend/homepage-store.js +1 -0
  53. package/dist/src/frontend/homepage-store.js.map +1 -0
  54. package/dist/src/frontend/homepage-view.js +131 -18
  55. package/dist/src/frontend/homepage-view.js.map +1 -0
  56. package/dist/src/frontend/page-runtime-client.js +27 -3
  57. package/dist/src/frontend/page-runtime-client.js.map +1 -0
  58. package/dist/src/frontend/page-runtime-store.js +1 -0
  59. package/dist/src/frontend/page-runtime-store.js.map +1 -0
  60. package/dist/src/frontend/sentry.js +42 -0
  61. package/dist/src/frontend/sentry.js.map +1 -0
  62. package/dist/src/frontend/template-editor-chat.js +1711 -212
  63. package/dist/src/frontend/template-editor-chat.js.map +1 -0
  64. package/dist/src/help-page.js +333 -0
  65. package/dist/src/help-page.js.map +1 -0
  66. package/dist/src/homepage.js +169 -47
  67. package/dist/src/homepage.js.map +1 -0
  68. package/dist/src/hyperframes/composition.js +180 -0
  69. package/dist/src/hyperframes/composition.js.map +1 -0
  70. package/dist/src/index.js +1 -0
  71. package/dist/src/index.js.map +1 -0
  72. package/dist/src/instrument.js +30 -0
  73. package/dist/src/instrument.js.map +1 -0
  74. package/dist/src/lib/crypto.js +1 -0
  75. package/dist/src/lib/crypto.js.map +1 -0
  76. package/dist/src/lib/dev-log.js +54 -0
  77. package/dist/src/lib/dev-log.js.map +1 -0
  78. package/dist/src/lib/display-name.js +11 -0
  79. package/dist/src/lib/display-name.js.map +1 -0
  80. package/dist/src/lib/ids.js +21 -1
  81. package/dist/src/lib/ids.js.map +1 -0
  82. package/dist/src/lib/images.js +1 -0
  83. package/dist/src/lib/images.js.map +1 -0
  84. package/dist/src/lib/json.js +1 -0
  85. package/dist/src/lib/json.js.map +1 -0
  86. package/dist/src/lib/template-dna.js +1 -0
  87. package/dist/src/lib/template-dna.js.map +1 -0
  88. package/dist/src/lib/template-paths.js +1 -0
  89. package/dist/src/lib/template-paths.js.map +1 -0
  90. package/dist/src/lib/template-style-options.js +29 -3
  91. package/dist/src/lib/template-style-options.js.map +1 -0
  92. package/dist/src/lib/time.js +1 -0
  93. package/dist/src/lib/time.js.map +1 -0
  94. package/dist/src/lib/video-quality-harness.js +60 -0
  95. package/dist/src/lib/video-quality-harness.js.map +1 -0
  96. package/dist/src/page-runtime.js +1 -0
  97. package/dist/src/page-runtime.js.map +1 -0
  98. package/dist/src/page-shell.js +403 -29
  99. package/dist/src/page-shell.js.map +1 -0
  100. package/dist/src/primitive-context.js +144 -8
  101. package/dist/src/primitive-context.js.map +1 -0
  102. package/dist/src/primitive-registry.js +1919 -78
  103. package/dist/src/primitive-registry.js.map +1 -0
  104. package/dist/src/primitive-sdk.js +1 -0
  105. package/dist/src/primitive-sdk.js.map +1 -0
  106. package/dist/src/primitives/remotion/html-image.js +3 -1
  107. package/dist/src/primitives/remotion/html-image.js.map +1 -0
  108. package/dist/src/primitives/remotion/media-slideshow.js +60 -0
  109. package/dist/src/primitives/remotion/media-slideshow.js.map +1 -0
  110. package/dist/src/react-page-shell.js +1 -0
  111. package/dist/src/react-page-shell.js.map +1 -0
  112. package/dist/src/ready-post-schedule-component.js +1 -0
  113. package/dist/src/ready-post-schedule-component.js.map +1 -0
  114. package/dist/src/registry.js +237 -24
  115. package/dist/src/registry.js.map +1 -0
  116. package/dist/src/runtime.js +3 -0
  117. package/dist/src/runtime.js.map +1 -0
  118. package/dist/src/services/api-call-history.js +4 -0
  119. package/dist/src/services/api-call-history.js.map +1 -0
  120. package/dist/src/services/auth.js +40 -50
  121. package/dist/src/services/auth.js.map +1 -0
  122. package/dist/src/services/billing.js +20 -44
  123. package/dist/src/services/billing.js.map +1 -0
  124. package/dist/src/services/chat-threads.js +10 -6
  125. package/dist/src/services/chat-threads.js.map +1 -0
  126. package/dist/src/services/fork-access.js +93 -0
  127. package/dist/src/services/fork-access.js.map +1 -0
  128. package/dist/src/services/fork-manifest.js +43 -0
  129. package/dist/src/services/fork-manifest.js.map +1 -0
  130. package/dist/src/services/ghostcut.js +132 -0
  131. package/dist/src/services/ghostcut.js.map +1 -0
  132. package/dist/src/services/hyperframes.js +1014 -0
  133. package/dist/src/services/hyperframes.js.map +1 -0
  134. package/dist/src/services/job-capacity.js +14 -0
  135. package/dist/src/services/job-capacity.js.map +1 -0
  136. package/dist/src/services/job-logs.js +4 -0
  137. package/dist/src/services/job-logs.js.map +1 -0
  138. package/dist/src/services/jobs.js +99 -91
  139. package/dist/src/services/jobs.js.map +1 -0
  140. package/dist/src/services/media-processing.js +743 -0
  141. package/dist/src/services/media-processing.js.map +1 -0
  142. package/dist/src/services/primitive-media-lambda.js +280 -0
  143. package/dist/src/services/primitive-media-lambda.js.map +1 -0
  144. package/dist/src/services/providers.js +1560 -178
  145. package/dist/src/services/providers.js.map +1 -0
  146. package/dist/src/services/rate-limits.js +3 -2
  147. package/dist/src/services/rate-limits.js.map +1 -0
  148. package/dist/src/services/remotion.js +495 -92
  149. package/dist/src/services/remotion.js.map +1 -0
  150. package/dist/src/services/serverless-auth.js +374 -0
  151. package/dist/src/services/serverless-auth.js.map +1 -0
  152. package/dist/src/services/serverless-jobs.js +1074 -0
  153. package/dist/src/services/serverless-jobs.js.map +1 -0
  154. package/dist/src/services/serverless-provider-keys.js +401 -0
  155. package/dist/src/services/serverless-provider-keys.js.map +1 -0
  156. package/dist/src/services/serverless-records.js +1088 -0
  157. package/dist/src/services/serverless-records.js.map +1 -0
  158. package/dist/src/services/serverless-template-configs.js +67 -0
  159. package/dist/src/services/serverless-template-configs.js.map +1 -0
  160. package/dist/src/services/storage.js +171 -35
  161. package/dist/src/services/storage.js.map +1 -0
  162. package/dist/src/services/template-certification.js +295 -3
  163. package/dist/src/services/template-certification.js.map +1 -0
  164. package/dist/src/services/template-loader.js +45 -1
  165. package/dist/src/services/template-loader.js.map +1 -0
  166. package/dist/src/services/template-runtime-bundles.js +217 -0
  167. package/dist/src/services/template-runtime-bundles.js.map +1 -0
  168. package/dist/src/services/template-sources.js +452 -87
  169. package/dist/src/services/template-sources.js.map +1 -0
  170. package/dist/src/services/video-normalization.js +2 -0
  171. package/dist/src/services/video-normalization.js.map +1 -0
  172. package/dist/src/services/webhooks.js +7 -6
  173. package/dist/src/services/webhooks.js.map +1 -0
  174. package/dist/src/template-editor-pages.js +2051 -1869
  175. package/dist/src/template-editor-pages.js.map +1 -0
  176. package/dist/src/template-editor-shell.js +1376 -181
  177. package/dist/src/template-editor-shell.js.map +1 -0
  178. package/dist/src/template-sdk.js +1 -0
  179. package/dist/src/template-sdk.js.map +1 -0
  180. package/dist/src/worker.js +11 -226
  181. package/dist/src/worker.js.map +1 -0
  182. package/package.json +47 -12
  183. package/public/assets/homepage-client-app.js +34 -8
  184. package/public/assets/page-runtime-client-app.js +44 -18
  185. package/readme.secret.md +89 -0
  186. package/templates/vidfarm_template_0000/README.md +106 -0
  187. package/templates/vidfarm_template_0000/SKILL.md +266 -0
  188. package/templates/vidfarm_template_0000/assets/Abel-Regular.ttf +0 -0
  189. package/templates/vidfarm_template_0000/assets/DMSerifDisplay-Regular.ttf +0 -0
  190. package/templates/vidfarm_template_0000/assets/Montserrat[wght].ttf +0 -0
  191. package/templates/vidfarm_template_0000/assets/SourceCodePro[wght].ttf +0 -0
  192. package/templates/vidfarm_template_0000/assets/TikTokSans-SemiBold.ttf +0 -0
  193. package/templates/vidfarm_template_0000/assets/Yesteryear-Regular.ttf +0 -0
  194. package/templates/vidfarm_template_0000/composition.json +11 -0
  195. package/templates/vidfarm_template_0000/src/lib/images.js +221 -0
  196. package/templates/vidfarm_template_0000/src/remotion/Root.js +33 -0
  197. package/templates/vidfarm_template_0000/src/remotion/index.js +3 -0
  198. package/templates/vidfarm_template_0000/src/sdk.js +3 -0
  199. package/templates/vidfarm_template_0000/src/style-options.js +200 -0
  200. package/templates/vidfarm_template_0000/src/template-dna.js +9 -0
  201. package/templates/vidfarm_template_0000/src/template.js +1566 -0
  202. package/templates/vidfarm_template_0000/template.config.json +21 -0
  203. package/GETTING_STARTED.developers.md +0 -87
  204. package/SKILL.developer.md +0 -1186
  205. package/dist/src/db.js +0 -2007
package/.env.example CHANGED
@@ -1,24 +1,60 @@
1
1
  NODE_ENV="development"
2
2
  PORT="3000"
3
+ MOCK_PROVIDER_RESPONSES="false"
4
+ MAX_ACTIVE_JOBS_PER_CUSTOMER="30"
5
+ PROVIDER_LEASE_INLINE_WAIT_SECONDS="5"
6
+ PROVIDER_LEASE_STEP_WAIT_SECONDS="60"
7
+ PROVIDER_LEASE_MAX_STEP_WAIT_SECONDS="43200"
8
+ MAX_JOB_WALL_CLOCK_SECONDS="86400"
3
9
 
4
10
  OPENAI_API_KEY=""
5
11
  OPENROUTER_API_KEY=""
6
12
  GEMINI_API_KEY=""
7
13
  PERPLEXITY_API_KEY=""
14
+ GHOSTCUT_KEY=""
15
+ GHOSTCUT_SECRET=""
8
16
 
9
- # Optional. Production CDK wires these automatically for the EC2 app and ZIP Lambda.
17
+ # Optional. Production CDK wires these automatically. Browser-facing Lambda calls still callback to PUBLIC_BASE_URL for auth.
10
18
  VIDFARM_ZIP_LAMBDA_URL=""
11
19
  VIDFARM_ZIP_LAMBDA_SECRET=""
12
20
  VIDFARM_BILLING_URL=""
13
21
  VIDFARM_BILLING_SECRET=""
14
22
  VIDFARM_RATE_LIMITS_TABLE_NAME=""
23
+ # Optional production CDK overrides. Leave empty to use deterministic per-account/per-region names.
24
+ VIDFARM_STORAGE_S3_BUCKET_NAME=""
15
25
 
16
26
  # Optional when calling a hosted Vidfarm API directly.
17
27
  VIDFARM_USER_ID=""
18
28
  VIDFARM_API_KEY=""
29
+ # Optional director override for production debugging. Send as x-superagency-key.
30
+ SUPERAGENCY_KEY=""
19
31
 
20
32
  # Optional local overrides. The CLI will choose sensible local defaults.
21
33
  PUBLIC_BASE_URL="http://localhost:3310"
22
34
  # Optional public browser-facing chat endpoint. Leave empty locally unless you want the UI to hit a separate chat host directly.
23
35
  PUBLIC_EDITOR_CHAT_URL=""
36
+
37
+ # Optional Sentry setup. SENTRY_DSN powers the Hono Node backend.
38
+ # SENTRY_LAMBDA_DSN powers the CDK-managed AWS Lambdas.
39
+ # PUBLIC_SENTRY_DSN powers the browser React bundles and may be the same DSN or a separate browser project DSN.
40
+ SENTRY_DSN=""
41
+ SENTRY_ENVIRONMENT="development"
42
+ SENTRY_RELEASE=""
43
+ SENTRY_TRACES_SAMPLE_RATE=""
44
+ SENTRY_ENABLE_LOGS="true"
45
+ SENTRY_SEND_DEFAULT_PII="false"
46
+ SENTRY_DEBUG_ROUTE="false"
47
+ SENTRY_LAMBDA_DSN=""
48
+ SENTRY_LAMBDA_TRACES_SAMPLE_RATE="1.0"
49
+ PUBLIC_SENTRY_DSN=""
50
+ PUBLIC_SENTRY_TRACES_SAMPLE_RATE=""
51
+ PUBLIC_SENTRY_REPLAYS_SESSION_SAMPLE_RATE=""
52
+ PUBLIC_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE=""
53
+ PUBLIC_SENTRY_ENABLE_LOGS="true"
54
+ PUBLIC_SENTRY_SEND_DEFAULT_PII="true"
55
+ PUBLIC_SENTRY_TRACE_PROPAGATION_TARGETS=""
24
56
  REMOTION_MODE="local"
57
+
58
+
59
+ GHOSTCUT_KEY="_________"
60
+ GHOSTCUT_SECRET="_________"
package/README.md CHANGED
@@ -1,200 +1,44 @@
1
- # Vidfarm Dev CLI
1
+ # Vidfarm
2
2
 
3
- `@mevdragon/vidfarm-devcli` is the local development toolkit for third-party Vidfarm template authors.
3
+ Vidfarm is a serverless composition studio for short-form video. Directors fork templates, edit compositions on a timeline in the **Trackpad Editor**, publish MP4s via a shared Remotion Lambda, and share results.
4
4
 
5
- This package is intentionally scoped to:
5
+ Everything runs on AWS Lambda + DynamoDB + S3. There is no long-lived worker. It scales to zero at idle.
6
6
 
7
- - building templates under `templates/*`
8
- - running the local Vidfarm API and worker
9
- - testing template operations as async jobs
10
- - validating template metadata, skills, and smoke test payloads
11
- - rendering Remotion locally when a template uses Remotion
7
+ ## Where to start
12
8
 
13
- It is intentionally not documentation for platform internals, production deployment, admin release flow, or shared cloud infrastructure.
9
+ - **Using Vidfarm as a director** [`SKILL.director.md`](./SKILL.director.md)
10
+ Login, forking templates, editing in the Trackpad Editor, auto-decompose, publishing, sharing, billing.
14
11
 
15
- ## Quick Start
12
+ - **Understanding how Vidfarm works internally** → [`SKILL.platform.md`](./SKILL.platform.md)
13
+ Architecture, data model, composition runtime, publish pipeline, deployment, migrations.
16
14
 
17
- 1. Create a local `.env` from the example file.
18
- 2. Add at least one AI provider key.
19
- 3. Start the local CLI runtime.
15
+ ## Repository layout
20
16
 
21
- ```bash
22
- cp .env.example .env
23
- npx @mevdragon/vidfarm-devcli dev --port 3310 --reset
24
- ```
17
+ - `src/` — API server (Hono, deployed as container Lambda)
18
+ - `demo/` — Trackpad Editor React app (deployed to CloudFront under `/editor/`)
19
+ - `infra/cdk/` CDK stacks for staging and production
20
+ - `infra/lambda/` — Lambda entry points (api, editor-chat, primitive-media, job-runner, billing, ready-post-zip, job-sweeper)
21
+ - `templates/` — Draft composition templates checked into the repo
22
+ - `scripts/` — One-shot ops and migration scripts
23
+ - `auto-create-hyperframe-templates/` — Extractor prompts / schemas for generating new templates from source footage
25
24
 
26
- Useful commands:
25
+ ## Deploy
27
26
 
28
27
  ```bash
29
- npx @mevdragon/vidfarm-devcli dev --port 3310 --reset
30
- npx @mevdragon/vidfarm-devcli session
31
- npx @mevdragon/vidfarm-devcli validate-template --template-id template_0000
32
- npx @mevdragon/vidfarm-devcli copy-reference-template --template-dir ./src/vidfarm_template_0000
33
- npx @mevdragon/vidfarm-devcli autocreate-template ./drafts/my_format ./templates/vidfarm_template_my_format
34
- npx @mevdragon/vidfarm-devcli generate-template --slug-id template_0001 --template-dir ./templates/vidfarm_template_0001
35
- npx @mevdragon/vidfarm-devcli analyze-viral-dna --template-dir ./templates/vidfarm_template_0001
36
- npx @mevdragon/vidfarm-devcli analyze-visual-dna --template-dir ./templates/vidfarm_template_0001
37
- npx @mevdragon/vidfarm-devcli presign-preview-media --file ./drafts/preview/example.png --directory drafts/preview
38
- ```
39
-
40
- After install, the package exposes both `vidfarm` and `vidfarm-devcli` as local binaries.
41
-
42
- `autocreate-template` prepares the auto-create harness run folder, stages media from the input path, snapshots the current harness files, scaffolds the output template, and writes an agent handoff prompt at `auto-create-templates/runs/<run_id>/agent_prompt.md`. Keep improving `auto-create-templates/AUTO_CREATE_TEMPLATES.md`; each new run uses the current harness and stores a per-run snapshot for traceability.
43
-
44
- ## What The Local CLI Does
45
-
46
- The local CLI runs the same template contract used by the hosted platform, but with local-first defaults:
47
-
48
- - local SQLite state under `.vidfarm/local`
49
- - local filesystem storage instead of cloud object storage
50
- - local Remotion rendering
51
- - a seeded developer session for local testing
52
- - provider keys sourced from your local `.env`
53
- - mocked provider responses only when no real provider keys are present
54
-
55
- Use `vidfarm session` to print reusable auth headers and a sample `curl` request for the local REST API.
56
-
57
- For hosted preview-media uploads, use `vidfarm-devcli presign-preview-media`. It calls the authenticated Vidfarm API with `VIDFARM_API_KEY`, mints a presigned PUT URL under `developer/<user_id>/*`, stores each uploaded file under a UUID path segment while preserving the original filename, uploads the file automatically when `--file` is provided, and returns a public-read media URL for the uploaded object. Public readability is granted by bucket policy for `developer/*`, not by public write or list access.
58
-
59
- ## What The Hosted Platform Expects From Templates
60
-
61
- Vidfarm treats templates as async job producers, not as ad hoc endpoints.
62
-
63
- Each template should provide:
64
-
65
- - stable template metadata
66
- - a `SKILL.md` file for users and agents
67
- - a TypeScript entrypoint at `src/template.ts`
68
- - one or more named operations
69
- - workflow functions behind those operations
70
- - a `smokeTestPayload` for each operation
71
- - `about.viral_dna` and `about.visual_dna`
72
-
73
- At runtime, the platform uses the template wrapper to expose a consistent API shape:
74
-
75
- - `GET /api/v1/templates/:templateId`
76
- - `GET /api/v1/templates/:templateId/skill`
77
- - `POST /api/v1/templates/:templateId/config`
78
- - `POST /api/v1/templates/:templateId/operations/:operationName`
79
- - `GET /api/v1/templates/:templateId/jobs/:jobId`
80
- - `GET /api/v1/templates/:templateId/jobs/:jobId/logs`
81
-
82
- Operations should return work through the job system rather than inventing one-off synchronous routes.
83
-
84
- ## Approval Flow
85
-
86
- Third-party developers build and validate templates locally first.
87
-
88
- After handoff, a Vidfarm admin reviews the template before it is made available on the hosted platform. Template authors should assume there is an approval step between local development and production availability.
89
-
90
- The developer handoff ends at:
91
-
92
- - `git push` of the template code
93
- - template source registration or registration update
94
- - for an already-registered template, publishing the exact GitHub commit SHA that should enter review
95
-
96
- The developer handoff does not include:
97
-
98
- - importing the source into the live platform
99
- - activating a release
100
- - making the template public/live
101
-
102
- If a developer receives `403 Admin access required` while trying to import or activate a registered source, that is expected. Those routes are for platform admins. Developers should use the publish-update flow to submit an exact commit SHA for review instead.
103
-
104
- ## Template Deploy Cycle
28
+ # staging first, always
29
+ npm run cdk:synth:staging-serverless
30
+ npm run cdk:deploy:staging-serverless
105
31
 
106
- When someone says "template deploy cycle" in this repo, they mean this exact sequence:
107
-
108
- 1. commit and `git push` the repo that contains the template folder, such as `templates/vidfarm_template_<slug>/` inside a monorepo or a standalone template repo
109
- 2. as the platform admin, pull/import that template commit into Vidfarm
110
- 3. approve and activate the imported template release in the hosted platform
111
- 4. run the prod deploy script if platform-runtime code changed, or reuse the current prod image if the change was template-only and you just need a formal deploy-cycle restart
112
-
113
- For `template_0000`, that usually means:
114
-
115
- ```bash
116
- git -C templates/vidfarm_template_0000 push origin production
117
- # third-party developer registration step
118
- node dist/src/cli.js register-source-hosted \
119
- --env-file .env.production \
120
- --template-id 4c7a7e1a-7f35-4f30-9f86-9c8a63c7f2db \
121
- --slug-id template_0000 \
122
- --repo-url https://github.com/your-org/your-template-repo \
123
- --branch production \
124
- --template-module-path templates/vidfarm_template_0000/src/template.ts
125
-
126
- # then run the platform operator command
127
- node dist/src/cli.js deploy-template-cycle \
128
- --env-file .env.production \
129
- --stack-name VidfarmProdStack \
130
- --template-id 4c7a7e1a-7f35-4f30-9f86-9c8a63c7f2db \
131
- --slug-id template_0000 \
132
- --repo-url https://github.com/your-org/your-template-repo \
133
- --branch production \
134
- --template-module-path templates/vidfarm_template_0000/src/template.ts
32
+ # then production
33
+ npm run cdk:deploy:prod-serverless
135
34
  ```
136
35
 
137
- The important distinction is:
138
-
139
- - third-party developers ship template repo changes plus registration metadata, and can publish an exact commit SHA for an existing registered template
140
- - platform admins import and activate those template repo changes
141
- - new source registrations land in the hosted review queue before approval
142
- - developer-published commit SHAs become reviewable releases while an older active release stays live
143
- - platform code changes ship through the root prod deploy script
144
- - multiple templates can live in one git repo as long as each template has its own folder and its `template_module_path` points at that folder's `src/template.ts`
145
-
146
- ## Authentication Context
147
-
148
- When calling a hosted Vidfarm API directly, authenticated requests use:
149
-
150
- - `vidfarm-user-id`
151
- - `vidfarm-api-key`
152
-
153
- The API key comes from Vidfarm login and settings, not from platform infrastructure secrets.
154
- If you need to discover the authenticated customer ID first, resolve it from `GET /api/v1/user/me` and then send both headers on subsequent requests.
155
-
156
- For hosted template source registration, treat `template_module_path` as repo-relative and point it at the template's TypeScript entrypoint, for example `templates/vidfarm_template_hooks/src/template.ts`. Each template folder must start with `vidfarm_template_`. The import flow builds the repo and loads the compiled `src/template.js` sibling at activation time.
157
-
158
- For hosted registration, use `register-source-hosted`. It talks to the Vidfarm REST API directly, so the source record lands in the production database that backs the hosted review queue. `register-source-prod` remains as a compatibility alias for internal/operator workflows.
159
-
160
- For updates to an already-registered template, use `publish-update-hosted` with the exact reviewed commit SHA. The CLI packages that commit locally into a signed artifact, uploads it to platform-controlled S3 through the Vidfarm API, and then creates or refreshes the pending release for admin review without granting developers approval or activation rights.
161
-
162
- ```bash
163
- node dist/src/cli.js publish-update-hosted \
164
- --env-file .env \
165
- --template-id c7af2cd8-f032-45fa-9d4d-7af0e85cf4ef \
166
- --slug-id vidfarm_template_reddit_brainrot \
167
- --repo-url https://github.com/mevdragon/vidfarm_templates.git \
168
- --branch main \
169
- --template-module-path src/vidfarm_template_reddit_brainrot/src/template.ts \
170
- --commit-sha 5e05a90a05a40105cc6e3b6a06774fdfb60c1893
171
- ```
172
-
173
- The hosted publish path no longer depends on server-side GitHub access for template updates. Prod imports the uploaded artifact from S3 during review/import.
174
-
175
- For local CLI usage, the `session` command gives you a local seeded session so you can test without manually wiring auth state.
176
-
177
- ## Provider Keys
178
-
179
- Templates should work with the developer's own upstream AI keys.
180
-
181
- Typical local `.env`:
182
-
183
- ```env
184
- GEMINI_API_KEY=""
185
- OPENAI_API_KEY=""
186
- OPENROUTER_API_KEY=""
187
- PERPLEXITY_API_KEY=""
188
- ```
189
-
190
- You usually only need one provider key to develop and test a template locally.
191
-
192
- ## Remotion
36
+ Never call bare `cdk deploy` — the npm scripts load the correct `.env.<stage>` and select the right stack.
193
37
 
194
- For third-party template authors, Remotion is local.
38
+ ## Deprecated: `@mevdragon/vidfarm-devcli`
195
39
 
196
- If your template uses `ctx.remotion`, develop and validate it locally through the CLI. This package does not document or require shared cloud Remotion infrastructure.
40
+ The `vidfarm-devcli` CLI (`src/cli.ts`) is **deprecated and no longer maintained**. It was built around the old REST-API template model — templates with `src/template.ts`, workflows, operations, viral DNA extraction, and the hosted publish/approve/activate flow. That entire paradigm has been superseded by the browser-based **Trackpad Editor** at `https://vidfarm.cc/editor/`.
197
41
 
198
- ## Next Read
42
+ The CLI still exists in the repo and may partially work, but it will print a deprecation banner on every invocation. No fixes will land. Do not build new tooling on it.
199
43
 
200
- For the external template-author workflow, continue with [GETTING_STARTED.developers.md](./GETTING_STARTED.developers.md) and the example template in [`templates/vidfarm_template_0000`](./templates/vidfarm_template_0000).
44
+ See `SKILL.platform.md` for the current architecture.
@@ -0,0 +1,293 @@
1
+ ---
2
+ name: vidfarm-director
3
+ description: Use Vidfarm as a director. Fork a template into a composition, edit it in the Trackpad Editor (timeline-based like Premiere/DaVinci), auto-decompose source video into scenes, publish to MP4, and share. Includes login, provider keys, discovery, publishing, versioning, and billing.
4
+ ---
5
+
6
+ # Vidfarm Director
7
+
8
+ Vidfarm is a **video composition studio**. Directors fork a published template, edit it on a timeline in the **Trackpad Editor**, publish to MP4, and share.
9
+
10
+ Use this skill when the user wants to:
11
+
12
+ - log in with OTP and save their AI provider keys
13
+ - discover published composition templates
14
+ - fork a template into an editable composition
15
+ - edit the timeline (add/remove/reorder layers, retime clips, swap media)
16
+ - auto-decompose a raw source video into scenes with AI
17
+ - publish a fork to MP4 and share the result
18
+ - browse version history and revert
19
+ - manage sharing/visibility
20
+
21
+ Do **not** use this skill to author new templates from scratch, deploy platform infrastructure, or discuss internal architecture — those belong to `SKILL.platform.md` (if it exists) or a separate developer workflow.
22
+
23
+ ## Mental model
24
+
25
+ A Vidfarm composition is an **HTML document + JSON metadata**. Each layer (video clip, audio, image, text, caption) is a timed DOM element with `data-start`, `data-duration`, `data-track-index` attributes. The Trackpad Editor is a timeline UI over this document, similar to Premiere or DaVinci.
26
+
27
+ Every director workflow goes through three concepts:
28
+
29
+ 1. **Template** — a published composition anyone can fork. Templates live at `/hyperframes/:slug` and have a source video, a decomposed timeline, and metadata (viral DNA, captions, scenes).
30
+ 2. **Composition fork** — a private editable copy of a template. Every fork has a `forkId`, an owner, a working state, and a version history. The Trackpad Editor operates on a fork.
31
+ 3. **Publish** — render the current fork state to MP4 via a Lambda render job. Each publish snapshots the current working state as an immutable version.
32
+
33
+ The Trackpad Editor is the primary surface. Most director actions happen there. This skill's REST endpoints exist for automation, CI, and headless flows.
34
+
35
+ ## Base URL and auth
36
+
37
+ The current API base URLs are:
38
+
39
+ - staging: `https://staging.vidfarm.cc`
40
+ - production: `https://vidfarm.cc`
41
+
42
+ Every browser action is authenticated by the session cookie set at `/login`. Every headless action needs the `vidfarm-api-key` header set to the caller's API key (from Settings → API Keys).
43
+
44
+ ```
45
+ vidfarm-api-key: vf_key_<32 hex>
46
+ ```
47
+
48
+ ## Login flow
49
+
50
+ Directors log in with OTP:
51
+
52
+ 1. `POST /api/v1/auth/otp/request { email }` — sends a code to email
53
+ 2. `POST /api/v1/auth/otp/verify { email, code }` — sets session cookie, returns `{ user, apiKey }`
54
+
55
+ Save the `apiKey` in the client and use it for automation.
56
+
57
+ ## Provider keys
58
+
59
+ Vidfarm executes many features (smart auto-decompose, editor chat) with the **caller's own AI provider keys**. Directors save keys once via:
60
+
61
+ - UI: Settings → Provider Keys
62
+ - API: `PUT /api/v1/user/me/provider-keys { openai, gemini, openrouter, perplexity }`
63
+
64
+ Priority: Gemini → OpenAI → OpenRouter. If a director has no keys, smart decompose falls back to a deterministic time-based split.
65
+
66
+ ## Discover templates
67
+
68
+ Templates are listed on the Vidfarm homepage under `/hyperframes/`. Each has a slug, a preview MP4, source video metadata, and viral DNA.
69
+
70
+ - Browser: browse the homepage
71
+ - API: `GET /api/v1/hyperframes` — returns template summaries
72
+
73
+ Each template exposes a public preview:
74
+
75
+ - `GET /hyperframes/:slug` — HTML preview
76
+ - `GET /hyperframes/:slug/composition` — composition HTML
77
+ - `GET /hyperframes/:slug/composition.json` — composition metadata (scenes, captions, viral DNA)
78
+
79
+ Directors don't edit templates directly. They fork.
80
+
81
+ ## Fork a template
82
+
83
+ ```
84
+ POST /api/v1/compositions
85
+ Content-Type: application/json
86
+
87
+ { "source_slug_id": "<template slug>", "title": "Optional title" }
88
+ ```
89
+
90
+ Returns the new fork's metadata:
91
+
92
+ ```
93
+ { "id": "<forkId>", "sourceSlugId": "...", "title": "...", "visibility": "private", "latestVersion": 0, ... }
94
+ ```
95
+
96
+ Take the returned `forkId` and open the Trackpad Editor at:
97
+
98
+ ```
99
+ /editor/?fork=<forkId>
100
+ ```
101
+
102
+ The editor loads `composition.html` and `composition.json` from the fork's working state.
103
+
104
+ ## Edit in the Trackpad Editor
105
+
106
+ The editor is a full timeline surface:
107
+
108
+ - **Timeline** — multi-track, drag/trim/split clips, group/ungroup layers
109
+ - **Inspector panel** — per-layer property editor (text, color, font, position, size, media source, playback start, volume)
110
+ - **Canvas frame overlay** — 8-handle resize + WYSIWYG positioning
111
+ - **Chat panel** — AI assistant that can programmatically edit the composition (13 action types: `add_layer`, `remove_layer`, `set_layer_start`, `set_layer_duration`, `group_layers`, `replace_composition_html`, ...). The assistant uses the caller's saved provider keys.
112
+ - **Auto-save** — every commit writes composition.html + composition.json to the working state. No explicit save button.
113
+
114
+ The editor persists to:
115
+
116
+ - `PUT /api/v1/compositions/:forkId/composition.html` — replace HTML
117
+ - `PATCH /api/v1/compositions/:forkId/composition.json` — patch metadata
118
+
119
+ Automation that needs to bypass the UI can call these endpoints directly.
120
+
121
+ ## Auto-decompose
122
+
123
+ If the fork's source is a raw video (not a pre-decomposed template), call auto-decompose to split it into scenes:
124
+
125
+ ```
126
+ POST /api/v1/compositions/:forkId/auto-decompose
127
+ Content-Type: application/json
128
+
129
+ { "mode": "smart" | "time-slice", "html": "<optional current html>", "requested_scenes": null, "target_scene_seconds": null, "user_prompt": "optional guidance" }
130
+ ```
131
+
132
+ Two modes:
133
+
134
+ - **`smart`** — uses the caller's Gemini/OpenAI/OpenRouter key. Samples frames, extracts scenes with labels and viral notes, extracts on-screen captions with positions, and detects viral DNA (hook, retention, payoff). Takes 30-60 seconds. Auto-fires GhostCut for subtitle removal in the background.
135
+ - **`time-slice`** — deterministic equal-duration split. Instant. No AI provider needed.
136
+
137
+ Response:
138
+
139
+ ```
140
+ { "ok": true, "mode": "smart", "scene_count": 6, "caption_count": 4, "duration_seconds": 12.4, "ghostcut_pending": true, "ghostcut_task_id": "..." }
141
+ ```
142
+
143
+ If `ghostcut_pending: true`, poll `POST /api/v1/compositions/:forkId/ghostcut-poll` until status transitions to `done` or `failed`.
144
+
145
+ ## Publish
146
+
147
+ Publishing renders the fork's current working state to an MP4 using shared Remotion Lambda.
148
+
149
+ ```
150
+ POST /api/v1/compositions/:forkId/publish
151
+ Content-Type: application/json
152
+
153
+ { "title": "optional", "version": null, "tracer": "optional-idempotency-key" }
154
+ ```
155
+
156
+ Returns `{ render_id, job_id, snapshot_version }`. Poll:
157
+
158
+ ```
159
+ GET /api/v1/compositions/:forkId/renders/:renderId
160
+ ```
161
+
162
+ Response includes `{ phase: "RUNNING" | "SUCCEEDED" | "FAILED", progress, output_url, cost_usd }`. On success, `output_url` is the durable MP4 URL.
163
+
164
+ Every publish creates an immutable version snapshot at `versions/<N>/composition.html` and `versions/<N>/composition.json`.
165
+
166
+ ## Version history
167
+
168
+ ```
169
+ GET /api/v1/compositions/:forkId/versions?limit=100
170
+ ```
171
+
172
+ Returns the version list with `{ version, reason, message, created_at }`. Reason is `publish`, `clone`, `manual`, or `migration`.
173
+
174
+ To view a past cut without reverting:
175
+
176
+ ```
177
+ GET /api/v1/compositions/:forkId/versions/:version/composition.html
178
+ ```
179
+
180
+ To revert the working state to a version, `PUT` the historical HTML/JSON back to the working keys.
181
+
182
+ ## Sharing and visibility
183
+
184
+ Every fork has a visibility: `private` (default), `unlisted` (legacy), or `public` (view-only).
185
+
186
+ ```
187
+ PATCH /api/v1/compositions/:forkId/visibility { "visibility": "public" }
188
+ ```
189
+
190
+ Public forks are accessible at `/editor/?fork=<forkId>` (view-only for non-owners). Public visibility is the simplest sharing surface.
191
+
192
+ Fine-grained sharing uses per-user permissions and share links:
193
+
194
+ - `POST /api/v1/compositions/:forkId/permissions { granteeType, granteeId, role, expiresAt? }` — grant a specific user access. Roles: `viewer`, `editor`, `publisher`.
195
+ - `POST /api/v1/compositions/:forkId/share-links { role, expiresAt? }` — create a token URL. Anyone with the token gets the role.
196
+ - `GET /api/v1/compositions/shared/:token` — access via share link
197
+ - `DELETE /api/v1/compositions/:forkId/permissions/:permissionId` — revoke a grant
198
+ - `DELETE /api/v1/compositions/:forkId/share-links/:token` — revoke a link
199
+
200
+ ## Cloning a fork
201
+
202
+ Directors can clone another fork (their own or a shared one) as a new starting point:
203
+
204
+ ```
205
+ POST /api/v1/compositions { "parent_fork_id": "<forkId>", "parent_version": <N or omit for latest> }
206
+ ```
207
+
208
+ The new fork inherits the parent's HTML/JSON at the specified version and creates a version-1 snapshot with `reason: "clone"`.
209
+
210
+ ## Delete a fork
211
+
212
+ ```
213
+ DELETE /api/v1/compositions/:forkId
214
+ ```
215
+
216
+ Soft-delete only. The fork's `deletedAt` is set. Versions and share links are preserved for audit.
217
+
218
+ ## Billing
219
+
220
+ Vidfarm charges directly in USD from the caller's wallet. There are no credits.
221
+
222
+ - **Wallet top-up** — Stripe checkout via `POST /api/v1/user/me/wallet/checkout`
223
+ - **Balance** — `GET /api/v1/user/me/wallet`
224
+ - **Cost anchors**:
225
+ - Publish (Remotion Lambda render): typically $0.01 – $0.10 per MP4 depending on length/resolution
226
+ - Auto-decompose smart mode: pass-through of caller's AI provider spend
227
+ - Auto-decompose time-slice: free
228
+ - GhostCut subtitle removal: ~$0.10 per 30 seconds of source video
229
+
230
+ Framing:
231
+
232
+ - Vidfarm is optimized for cost efficiency, not markup
233
+ - Total director cost per video is typically far below alternatives
234
+ - Platform retains a small safety buffer for operational correctness
235
+
236
+ ## Automation patterns
237
+
238
+ For agents that operate Vidfarm headlessly, the typical loop is:
239
+
240
+ 1. `POST /api/v1/compositions { source_slug_id }` → fork
241
+ 2. `PUT /api/v1/compositions/:forkId/composition.html` → apply edits
242
+ 3. `PATCH /api/v1/compositions/:forkId/composition.json` → update metadata
243
+ 4. `POST /api/v1/compositions/:forkId/publish { tracer }` → render
244
+ 5. Poll `GET /api/v1/compositions/:forkId/renders/:renderId` until `SUCCEEDED`
245
+ 6. Use `output_url` in the next stage
246
+
247
+ Always send a stable `tracer` on publish to make retries idempotent.
248
+
249
+ ## What NOT to do
250
+
251
+ - Do **not** manipulate composition HTML by string concatenation. Always parse, edit, and re-serialize the DOM. The editor and runtime rely on `data-start`, `data-duration`, `data-track-index`, `data-hf-id`, `data-composition-id` attributes being well-formed.
252
+ - Do **not** save AI provider keys in the composition HTML or JSON. They belong in the caller's provider-keys record.
253
+ - Do **not** call Remotion directly. Publishing goes through `/publish` so billing, retries, cost caps, and Lambda quotas are enforced.
254
+ - Do **not** re-invent scene manipulation as REST commands (`AddScene`, `RemoveScene`, `UpdateSceneField`). The Trackpad Editor is the surface for that. The pattern is: mutate the composition HTML DOM, PUT it back.
255
+
256
+ ## Alpha posture
257
+
258
+ Vidfarm is in active development. Endpoints, response shapes, and the editor UI can change. When something behaves unexpectedly:
259
+
260
+ - prefer `GET /api/v1/compositions/:forkId` over cached state
261
+ - treat `latestVersion` as the source of truth for what the editor loaded
262
+ - if a publish fails, check `renders/:renderId` for the error phase and stderr before retrying
263
+
264
+ ## Default assistance pattern
265
+
266
+ When a director asks "make me a video", the default sequence is:
267
+
268
+ 1. Ask what source material and what template style they want
269
+ 2. Discover a matching template with `GET /api/v1/hyperframes`
270
+ 3. Fork it
271
+ 4. If they want an entirely new source video, guide them to `auto-decompose` first
272
+ 5. Open the Trackpad Editor and let them make edits
273
+ 6. Publish and share
274
+
275
+ Prefer specific templates over primitives when a template exists that already captures the desired production pattern.
276
+
277
+ ## Primitive: image_remove_background
278
+
279
+ Remove the background from any image URL. Result is a transparent PNG/WebP stored at a durable Vidfarm URL you can reuse in compositions or downstream primitives.
280
+
281
+ - `POST /api/v1/primitives/images/remove-background`
282
+ - Body: `{ "source_image_url": "https://...", "output_format": "webp" | "png" | "jpeg" }` (`output_format` defaults to `webp`)
283
+ - Response: standard primitive job; poll for completion, then read `image.file_url` / `primary_file_url`
284
+ - Billing: flat pass-through fee via RapidAPI (`rapidapi_remove_background` cost center)
285
+
286
+ Example:
287
+
288
+ ```bash
289
+ curl -X POST "$VIDFARM_BASE/api/v1/primitives/images/remove-background" \
290
+ -H "authorization: Bearer $VIDFARM_API_KEY" \
291
+ -H "content-type: application/json" \
292
+ -d '{"source_image_url": "https://cdn.example.com/photo.jpg"}'
293
+ ```