@automovie/template 0.2.0 → 0.3.1

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 (265) hide show
  1. package/README.md +2 -2
  2. package/generated/pnpm-workspace.json +3 -3
  3. package/generated/skills/3d-modeling/conditioning.md +42 -34
  4. package/generated/skills/3d-modeling/crafting/SKILL.md +6 -6
  5. package/generated/skills/3d-modeling/crafting/construction.md +22 -29
  6. package/generated/skills/3d-modeling/crafting/lofting.md +26 -24
  7. package/generated/skills/3d-modeling/crafting/recovery.md +8 -8
  8. package/generated/skills/3d-modeling/diffusion/image-hints.md +5 -5
  9. package/generated/skills/3d-modeling/diffusion/models.md +32 -16
  10. package/generated/skills/3d-modeling/diffusion/prompts.md +3 -3
  11. package/generated/skills/3d-modeling/diffusion/request.md +7 -5
  12. package/generated/skills/3d-modeling/diffusion/shape-hints.md +19 -17
  13. package/generated/skills/3d-modeling/inspection.md +11 -9
  14. package/generated/skills/3d-modeling/modularization.md +9 -9
  15. package/generated/skills/3d-modeling/rigging.md +44 -35
  16. package/generated/skills/3d-modeling/sources.md +10 -10
  17. package/generated/skills/contracts/development/common.md +4 -4
  18. package/generated/skills/contracts/development/design.md +4 -4
  19. package/generated/skills/contracts/development/implementation.md +7 -7
  20. package/generated/skills/contracts/development/testing.md +4 -4
  21. package/generated/skills/development/repair.md +2 -4
  22. package/generated/skills/documentation/SKILL.md +4 -4
  23. package/generated/skills/documentation/writing.md +56 -34
  24. package/generated/skills/motion/laws/authoring.md +20 -30
  25. package/generated/skills/motion/laws/contacts.md +13 -13
  26. package/generated/skills/motion/laws/declaration.md +8 -6
  27. package/generated/skills/motion/laws/transitions.md +20 -18
  28. package/generated/skills/motion/laws/variation.md +6 -6
  29. package/generated/skills/motion/laws/verification.md +8 -6
  30. package/generated/skills/prompting/SKILL.md +52 -34
  31. package/generated/skills/visual-debugging/capture.md +24 -22
  32. package/generated/skills/visual-debugging/comparison.md +4 -4
  33. package/generated/skills/visual-debugging/correction-rounds.md +6 -15
  34. package/generated/skills/visual-debugging/passes.md +11 -11
  35. package/generated/skills/visual-debugging/rendering-cost.md +2 -2
  36. package/lib/createAutoMovieScaffold.js +2 -20
  37. package/lib/createAutoMovieScaffold.js.map +1 -1
  38. package/lib/index.d.ts +1 -0
  39. package/lib/index.js +1 -0
  40. package/lib/index.js.map +1 -1
  41. package/lib/renderAutoMovieWorkspace.d.ts +22 -0
  42. package/lib/renderAutoMovieWorkspace.js +141 -0
  43. package/lib/renderAutoMovieWorkspace.js.map +1 -0
  44. package/package.json +5 -5
  45. package/scaffold/instructions/.agents/skills/3d-modeling/SKILL.md +22 -21
  46. package/scaffold/instructions/.agents/skills/3d-modeling/coarse-forms.md +7 -7
  47. package/scaffold/instructions/.agents/skills/3d-modeling/diffusion/SKILL.md +14 -10
  48. package/scaffold/instructions/.agents/skills/audio/SKILL.md +10 -10
  49. package/scaffold/instructions/.agents/skills/audio/acquisition.md +16 -18
  50. package/scaffold/instructions/.agents/skills/audio/diffusion/SKILL.md +18 -0
  51. package/scaffold/instructions/.agents/skills/audio/diffusion/cloning.md +25 -0
  52. package/scaffold/instructions/.agents/skills/audio/diffusion/models.md +59 -0
  53. package/scaffold/instructions/.agents/skills/audio/diffusion/prompts.md +45 -0
  54. package/scaffold/instructions/.agents/skills/audio/film-sound.md +7 -5
  55. package/scaffold/instructions/.agents/skills/audio/generated-sound.md +5 -3
  56. package/scaffold/instructions/.agents/skills/audio/listening.md +13 -0
  57. package/scaffold/instructions/.agents/skills/audio/sound-effects.md +6 -6
  58. package/scaffold/instructions/.agents/skills/audio/soundtrack.md +4 -2
  59. package/scaffold/instructions/.agents/skills/automovie/SKILL.md +32 -0
  60. package/scaffold/instructions/.agents/skills/contracts/SKILL.md +6 -29
  61. package/scaffold/instructions/.agents/skills/contracts/development/SKILL.md +13 -13
  62. package/scaffold/instructions/.agents/skills/contracts/development/behaviors.md +18 -7
  63. package/scaffold/instructions/.agents/skills/contracts/development/composition.md +9 -6
  64. package/scaffold/instructions/.agents/skills/contracts/development/entities.md +6 -7
  65. package/scaffold/instructions/.agents/skills/contracts/development/statements/behaviors.md +18 -20
  66. package/scaffold/instructions/.agents/skills/contracts/development/statements/composition.md +4 -6
  67. package/scaffold/instructions/.agents/skills/contracts/development/statements/entities.md +12 -13
  68. package/scaffold/instructions/.agents/skills/contracts/items.md +26 -0
  69. package/scaffold/instructions/.agents/skills/contracts/story/SKILL.md +37 -25
  70. package/scaffold/instructions/.agents/skills/contracts/story/shared/discovery/brief.md +1 -1
  71. package/scaffold/instructions/.agents/skills/contracts/story/shared/discovery/common.md +2 -2
  72. package/scaffold/instructions/.agents/skills/contracts/story/shared/discovery/narratives.md +1 -1
  73. package/scaffold/instructions/.agents/skills/contracts/story/shared/discovery/screenplay.md +1 -1
  74. package/scaffold/instructions/.agents/skills/contracts/story/shared/discovery/scripts.md +1 -1
  75. package/scaffold/instructions/.agents/skills/contracts/story/shared/discovery/treatments.md +1 -1
  76. package/scaffold/instructions/.agents/skills/contracts/story/shared/naturalness/common.md +4 -4
  77. package/scaffold/instructions/.agents/skills/contracts/story/shared/naturalness/obligations/common.md +2 -2
  78. package/scaffold/instructions/.agents/skills/contracts/story/shared/naturalness/obligations/realized.md +1 -1
  79. package/scaffold/instructions/.agents/skills/contracts/story/shared/naturalness/obligations/scripts.md +1 -1
  80. package/scaffold/instructions/.agents/skills/contracts/story/shared/naturalness/realized.md +2 -2
  81. package/scaffold/instructions/.agents/skills/contracts/story/shared/naturalness/scripts.md +2 -2
  82. package/scaffold/instructions/.agents/skills/contracts/story/shared/obligations/brief.md +1 -1
  83. package/scaffold/instructions/.agents/skills/contracts/story/shared/obligations/common.md +1 -1
  84. package/scaffold/instructions/.agents/skills/contracts/story/shared/obligations/index.md +2 -2
  85. package/scaffold/instructions/.agents/skills/contracts/story/shared/obligations/narratives.md +2 -2
  86. package/scaffold/instructions/.agents/skills/contracts/story/shared/obligations/review.md +2 -2
  87. package/scaffold/instructions/.agents/skills/contracts/story/shared/obligations/screenplay.md +1 -1
  88. package/scaffold/instructions/.agents/skills/contracts/story/shared/obligations/scripts.md +2 -2
  89. package/scaffold/instructions/.agents/skills/contracts/story/shared/obligations/settings.md +1 -1
  90. package/scaffold/instructions/.agents/skills/contracts/story/shared/obligations/treatments.md +1 -1
  91. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/brief.md +1 -1
  92. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/common.md +1 -1
  93. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/index.md +1 -1
  94. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/narratives.md +2 -2
  95. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/realized.md +2 -2
  96. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/research.md +3 -3
  97. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/screenplay.md +3 -3
  98. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/scripts.md +2 -2
  99. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/settings.md +1 -1
  100. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/treatments.md +2 -2
  101. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/discovery/brief.md +1 -3
  102. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/discovery/common.md +3 -5
  103. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/discovery/narratives.md +1 -3
  104. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/discovery/screenplay.md +0 -2
  105. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/discovery/scripts.md +1 -3
  106. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/discovery/settings.md +1 -3
  107. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/discovery/treatments.md +1 -3
  108. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/naturalness/common.md +11 -14
  109. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/naturalness/obligations/common.md +1 -3
  110. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/naturalness/obligations/realized.md +1 -3
  111. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/naturalness/obligations/scripts.md +3 -5
  112. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/naturalness/realized.md +2 -4
  113. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/naturalness/scripts.md +1 -4
  114. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/obligations/brief.md +6 -6
  115. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/obligations/common.md +1 -3
  116. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/obligations/index.md +2 -4
  117. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/obligations/narratives.md +3 -5
  118. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/obligations/review.md +5 -7
  119. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/obligations/screenplay.md +5 -7
  120. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/obligations/scripts.md +2 -4
  121. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/obligations/settings.md +6 -8
  122. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/obligations/treatments.md +1 -3
  123. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/brief.md +4 -6
  124. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/common.md +2 -4
  125. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/index.md +2 -4
  126. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/narratives.md +3 -5
  127. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/realized.md +1 -3
  128. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/research.md +6 -8
  129. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/review.md +5 -7
  130. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/screenplay.md +19 -22
  131. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/scripts.md +9 -11
  132. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/settings.md +3 -5
  133. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/treatments.md +1 -3
  134. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/upstream/screenplay.md +1 -3
  135. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/upstream/scripts.md +1 -3
  136. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/upstream/treatments.md +0 -2
  137. package/scaffold/instructions/.agents/skills/contracts/story/shared/upstream/screenplay.md +1 -1
  138. package/scaffold/instructions/.agents/skills/contracts/story/shared/upstream/scripts.md +1 -1
  139. package/scaffold/instructions/.agents/skills/contracts/story/shared/upstream/treatments.md +1 -1
  140. package/scaffold/instructions/.agents/skills/development/SKILL.md +14 -24
  141. package/scaffold/instructions/.agents/skills/development/entities.md +19 -15
  142. package/scaffold/instructions/.agents/skills/development/modules.md +31 -0
  143. package/scaffold/instructions/.agents/skills/development/source-layout.md +66 -50
  144. package/scaffold/instructions/.agents/skills/development/testing.md +10 -11
  145. package/scaffold/instructions/.agents/skills/evidence/SKILL.md +7 -7
  146. package/scaffold/instructions/.agents/skills/evidence/adoption.md +4 -4
  147. package/scaffold/instructions/.agents/skills/evidence/answering.md +3 -3
  148. package/scaffold/instructions/.agents/skills/evidence/configuration.md +4 -4
  149. package/scaffold/instructions/.agents/skills/image/SKILL.md +8 -19
  150. package/scaffold/instructions/.agents/skills/image/canon-references.md +16 -6
  151. package/scaffold/instructions/.agents/skills/image/diffusion/SKILL.md +23 -0
  152. package/scaffold/instructions/.agents/skills/image/diffusion/conditioning.md +29 -0
  153. package/scaffold/instructions/.agents/skills/image/diffusion/consistency.md +25 -0
  154. package/scaffold/instructions/.agents/skills/image/diffusion/editing.md +15 -0
  155. package/scaffold/instructions/.agents/skills/image/diffusion/finishing.md +11 -0
  156. package/scaffold/instructions/.agents/skills/image/diffusion/models.md +35 -0
  157. package/scaffold/instructions/.agents/skills/image/diffusion/prompting.md +27 -0
  158. package/scaffold/instructions/.agents/skills/image/turnaround-views.md +6 -2
  159. package/scaffold/instructions/.agents/skills/motion/SKILL.md +15 -32
  160. package/scaffold/instructions/.agents/skills/motion/catalog-cases.md +15 -15
  161. package/scaffold/instructions/.agents/skills/motion/compose/composition.md +34 -26
  162. package/scaffold/instructions/.agents/skills/motion/compose/refusals.md +5 -5
  163. package/scaffold/instructions/.agents/skills/motion/control-channels.md +14 -10
  164. package/scaffold/instructions/.agents/skills/motion/diffusion/SKILL.md +12 -8
  165. package/scaffold/instructions/.agents/skills/motion/diffusion/clips.md +23 -9
  166. package/scaffold/instructions/.agents/skills/motion/diffusion/hints.md +20 -8
  167. package/scaffold/instructions/.agents/skills/motion/diffusion/models.md +24 -16
  168. package/scaffold/instructions/.agents/skills/motion/diffusion/tracing.md +18 -12
  169. package/scaffold/instructions/.agents/skills/motion/frame-evaluation.md +6 -6
  170. package/scaffold/instructions/.agents/skills/motion/judgment.md +37 -0
  171. package/scaffold/instructions/.agents/skills/motion/laws/SKILL.md +11 -11
  172. package/scaffold/instructions/.agents/skills/motion/laws/extension.md +15 -11
  173. package/scaffold/instructions/.agents/skills/motion/laws/method-references.md +47 -17
  174. package/scaffold/instructions/.agents/skills/motion/performance.md +11 -0
  175. package/scaffold/instructions/.agents/skills/motion/physical-feedback.md +15 -15
  176. package/scaffold/instructions/.agents/skills/motion/retargeting.md +5 -5
  177. package/scaffold/instructions/.agents/skills/motion/segment-review.md +7 -5
  178. package/scaffold/instructions/.agents/skills/motion/staging.md +10 -8
  179. package/scaffold/instructions/.agents/skills/production/SKILL.md +11 -38
  180. package/scaffold/instructions/.agents/skills/production/assembly.md +11 -5
  181. package/scaffold/instructions/.agents/skills/production/captions.md +4 -4
  182. package/scaffold/instructions/.agents/skills/production/director.md +17 -0
  183. package/scaffold/instructions/.agents/skills/production/media-records.md +33 -11
  184. package/scaffold/instructions/.agents/skills/production/project-context.md +64 -22
  185. package/scaffold/instructions/.agents/skills/production/reorganization.md +3 -3
  186. package/scaffold/instructions/.agents/skills/production/stage-caches.md +7 -11
  187. package/scaffold/instructions/.agents/skills/production/sustained-runs.md +7 -7
  188. package/scaffold/instructions/.agents/skills/production/workflow.md +45 -0
  189. package/scaffold/instructions/.agents/skills/review/SKILL.md +10 -15
  190. package/scaffold/instructions/.agents/skills/review/delivery-review.md +51 -30
  191. package/scaffold/instructions/.agents/skills/review/estimation.md +32 -13
  192. package/scaffold/instructions/.agents/skills/review/independent-reading.md +6 -4
  193. package/scaffold/instructions/.agents/skills/review/narrative-rounds.md +7 -7
  194. package/scaffold/instructions/.agents/skills/review/source-review.md +5 -9
  195. package/scaffold/instructions/.agents/skills/story/SKILL.md +10 -13
  196. package/scaffold/instructions/.agents/skills/story/answers.md +10 -10
  197. package/scaffold/instructions/.agents/skills/story/correction/inspection.md +10 -12
  198. package/scaffold/instructions/.agents/skills/story/correction/repair.md +20 -14
  199. package/scaffold/instructions/.agents/skills/story/document-layout.md +32 -17
  200. package/scaffold/instructions/.agents/skills/story/layers/SKILL.md +11 -9
  201. package/scaffold/instructions/.agents/skills/story/layers/brief.md +4 -8
  202. package/scaffold/instructions/.agents/skills/story/layers/notation.md +8 -6
  203. package/scaffold/instructions/.agents/skills/story/layers/screenplay.md +20 -12
  204. package/scaffold/instructions/.agents/skills/story/layers/scripts.md +3 -3
  205. package/scaffold/instructions/.agents/skills/story/layers/settings.md +28 -11
  206. package/scaffold/instructions/.agents/skills/story/layers/shots.md +8 -8
  207. package/scaffold/instructions/.agents/skills/story/layers/treatments.md +3 -3
  208. package/scaffold/instructions/.agents/skills/story/planning/SKILL.md +7 -7
  209. package/scaffold/instructions/.agents/skills/story/planning/direction.md +2 -2
  210. package/scaffold/instructions/.agents/skills/story/planning/discovery.md +9 -7
  211. package/scaffold/instructions/.agents/skills/story/planning/requirements.md +10 -8
  212. package/scaffold/instructions/.agents/skills/story/planning/research.md +15 -18
  213. package/scaffold/instructions/.agents/skills/story/workflow/SKILL.md +8 -7
  214. package/scaffold/instructions/.agents/skills/story/workflow/long.md +18 -14
  215. package/scaffold/instructions/.agents/skills/story/workflow/routes.md +23 -17
  216. package/scaffold/instructions/.agents/skills/story/workflow/short.md +22 -14
  217. package/scaffold/instructions/.agents/skills/video/SKILL.md +9 -14
  218. package/scaffold/instructions/.agents/skills/video/diffusion/SKILL.md +7 -7
  219. package/scaffold/instructions/.agents/skills/video/diffusion/continuity.md +6 -6
  220. package/scaffold/instructions/.agents/skills/video/diffusion/hints.md +29 -12
  221. package/scaffold/instructions/.agents/skills/video/diffusion/models.md +40 -19
  222. package/scaffold/instructions/.agents/skills/video/diffusion/prompts.md +23 -15
  223. package/scaffold/instructions/.agents/skills/video/direct-film.md +53 -0
  224. package/scaffold/instructions/.agents/skills/video/finishing.md +14 -12
  225. package/scaffold/instructions/.agents/skills/video/generated-film.md +24 -0
  226. package/scaffold/instructions/.agents/skills/video/generation.md +25 -17
  227. package/scaffold/instructions/.agents/skills/video/requests.md +8 -8
  228. package/scaffold/instructions/.agents/skills/visual-debugging/SKILL.md +20 -18
  229. package/scaffold/instructions/AGENTS.md +46 -46
  230. package/scaffold/production/README.md +10 -19
  231. package/scaffold/production/package.json +1 -1
  232. package/scaffold/production/src/IFilmProduction.ts +22 -3
  233. package/scaffold/production/src/executable/physics.ts +8 -4
  234. package/scaffold/production/src/executable/recovery/node/artifact/archiveAutoMovieRecoveryModel.ts +4 -4
  235. package/scaffold/production/src/executable/recovery/node/artifact/createAutoMovieRecoveryArtifact.ts +5 -3
  236. package/scaffold/production/src/executable/recovery/node/artifact/writeAutoMovieRecoveryArtifact.ts +7 -7
  237. package/scaffold/production/src/executable/recovery/node/internal/readRecoveryCameraImages.ts +4 -2
  238. package/scaffold/production/src/executable/recovery/node/internal/recovery.ts +3 -3
  239. package/scaffold/production/src/executable/recovery/node/internal/recoveryImages.ts +3 -3
  240. package/scaffold/production/src/executable/recovery/node/internal/recoveryLocal.ts +4 -2
  241. package/scaffold/production/src/executable/recovery/node/internal/recoveryOpen.ts +2 -2
  242. package/scaffold/production/src/executable/recovery/node/mesh/createAutoMovieRecoveryContourFileMesh.ts +17 -18
  243. package/scaffold/production/src/executable/recovery/node/mesh/createAutoMovieRecoveryMeshSpool.ts +17 -18
  244. package/scaffold/production/src/executable/recovery/node/mesh/readAutoMovieRecoveryMeshFrontier.ts +4 -4
  245. package/scaffold/production/src/executable/recovery/node/publishAutoMovieRecoveryArtifact.ts +37 -21
  246. package/scaffold/production/src/executable/recovery/node/reconstruction/reconstructAutoMovieRecoveryLocal.ts +25 -15
  247. package/scaffold/production/src/executable/recovery/node/runAutoMovieRecoveryCommand.ts +1 -1
  248. package/scaffold/production/src/markFilmProduction.ts +1 -1
  249. package/scaffold/production/src/subjects.ts +28 -7
  250. package/scaffold/production/test/features/test_recovery_publication_cancellation.ts +129 -0
  251. package/scaffold/production/tsconfig.json +1 -2
  252. package/scaffold/production/vite.config.ts +12 -0
  253. package/scaffold/workspace/README.md +2 -2
  254. package/scaffold/workspace/package.json +1 -1
  255. package/src/createAutoMovieScaffold.ts +2 -39
  256. package/src/index.ts +1 -0
  257. package/src/renderAutoMovieWorkspace.ts +157 -0
  258. package/scaffold/instructions/.agents/skills/development/reuse.md +0 -48
  259. package/scaffold/instructions/.agents/skills/direct-film/SKILL.md +0 -51
  260. package/scaffold/instructions/.agents/skills/image/conditioning.md +0 -27
  261. package/scaffold/instructions/.agents/skills/image/consistency.md +0 -23
  262. package/scaffold/instructions/.agents/skills/image/editing.md +0 -15
  263. package/scaffold/instructions/.agents/skills/image/finishing.md +0 -11
  264. package/scaffold/instructions/.agents/skills/image/models.md +0 -18
  265. package/scaffold/instructions/.agents/skills/image/prompting.md +0 -25
@@ -1,16 +1,17 @@
1
- import {
2
- type IAutoMovieRecoveryPublication,
3
- type IAutoMovieRecoveryPublicationOptions,
4
- type IAutoMovieRecoveryResult,
5
- } from "@automovie/recovery";
1
+ import type {
2
+ IAutoMovieFilePublicationOptions,
3
+ IAutoMovieFileReceipt,
4
+ IAutoMovieRecoveryResult,
5
+ } from "@automovie/interface";
6
6
 
7
7
  import { writeAutoMovieRecoveryArtifact } from "./artifact/writeAutoMovieRecoveryArtifact";
8
8
 
9
9
  /**
10
10
  * Publish one plain data artifact atomically without replacing an existing file.
11
11
  * Publication identity is the exact emitted UTF-8 byte hash, independent of model
12
- * identity. Cancellation is checked before synchronous serialization begins; this
13
- * operation cannot observe an event-loop abort while blocked in synchronous I/O.
12
+ * identity. The optional cancellation predicate runs before serialization; this
13
+ * operation cannot observe event-loop changes while blocked in synchronous I/O.
14
+ * A thrown predicate or nonboolean result fails without publishing an artifact.
14
15
  * Failed serialization leaves the target unpublished and removes its temporary
15
16
  * file. A process crash can leave an unpublished temporary file, as documented by
16
17
  * the writer. Cancellation does not delete a completed immutable publication.
@@ -26,23 +27,38 @@ import { writeAutoMovieRecoveryArtifact } from "./artifact/writeAutoMovieRecover
26
27
  export function publishAutoMovieRecoveryArtifact(
27
28
  output: string,
28
29
  artifact: object,
29
- options: IAutoMovieRecoveryPublicationOptions = {},
30
- ): IAutoMovieRecoveryResult<IAutoMovieRecoveryPublication> {
30
+ options: IAutoMovieFilePublicationOptions = {},
31
+ ): IAutoMovieRecoveryResult<IAutoMovieFileReceipt> {
31
32
  const operator: IAutoMovieRecoveryResult<never>["operator"] =
32
33
  "json-publication-v1";
33
- if (options.signal?.aborted)
34
- return {
35
- operator,
36
- status: "cancelled",
37
- diagnostics: ["Cancelled before publication"],
38
- };
39
- if (!output || artifact === null || typeof artifact !== "object")
40
- return {
41
- operator,
42
- status: "refused",
43
- diagnostics: ["An output path and plain data artifact are required"],
44
- };
45
34
  try {
35
+ if (
36
+ options === null ||
37
+ typeof options !== "object" ||
38
+ (options.cancelled !== undefined &&
39
+ typeof options.cancelled !== "function")
40
+ )
41
+ return {
42
+ operator,
43
+ status: "refused",
44
+ diagnostics: ["Cancellation must be an optional synchronous predicate"],
45
+ };
46
+ const cancelled: boolean =
47
+ options.cancelled === undefined ? false : options.cancelled();
48
+ if (typeof cancelled !== "boolean")
49
+ throw new Error("Cancellation predicate must return a boolean");
50
+ if (cancelled)
51
+ return {
52
+ operator,
53
+ status: "cancelled",
54
+ diagnostics: ["Cancelled before publication"],
55
+ };
56
+ if (!output || artifact === null || typeof artifact !== "object")
57
+ return {
58
+ operator,
59
+ status: "refused",
60
+ diagnostics: ["An output path and plain data artifact are required"],
61
+ };
46
62
  const publication: ReturnType<typeof writeAutoMovieRecoveryArtifact> =
47
63
  writeAutoMovieRecoveryArtifact(output, artifact);
48
64
  return {
@@ -1,13 +1,14 @@
1
+ import { tessellateAutoMovieLocalHermite64 as T } from "@automovie/engine";
2
+ import type {
3
+ IAutoMovieCubicBezierCurve64,
4
+ IAutoMovieLocalHermiteStream64,
5
+ IAutoMovieRecoveryLocalBinding,
6
+ IAutoMovieRecoveryLocalResult,
7
+ IAutoMovieRecoveryLocalRunReport,
8
+ IAutoMovieRecoveryOpenContinuation,
9
+ IAutoMovieRecoveryTensorFamiliesInput,
10
+ } from "@automovie/interface";
1
11
  import {
2
- type IAutoMovieCurve64 as C,
3
- tessellateAutoMovieLocalHermite64 as T,
4
- } from "@automovie/engine";
5
- import {
6
- type IAutoMovieRecoveryLocalBinding,
7
- type IAutoMovieRecoveryLocalResult,
8
- type IAutoMovieRecoveryOpenContinuation,
9
- type IAutoMovieRecoveryTensorFamiliesInput,
10
- type RecoveryLocalRunReport,
11
12
  describeRecoveryOpenRun,
12
13
  normalizeRecoveryCourse,
13
14
  prepareRecoveryLocalContinuation,
@@ -121,7 +122,7 @@ export function reconstructAutoMovieRecoveryLocal(
121
122
  attachedBone: null,
122
123
  transform: null,
123
124
  });
124
- type RunReport = RecoveryLocalRunReport;
125
+ type RunReport = IAutoMovieRecoveryLocalRunReport;
125
126
  const runs: RunReport[] = [],
126
127
  checkpoints: { path: string; sha256: string; bytes: number }[] = [];
127
128
  let completedPairs: number = 0,
@@ -311,11 +312,17 @@ export function reconstructAutoMovieRecoveryLocal(
311
312
  elapsedMs: performance.now() - started,
312
313
  }),
313
314
  );
314
- let iterator: Generator<T.Chunk, T.Summary, void> | undefined;
315
+ let iterator:
316
+ | Generator<
317
+ IAutoMovieLocalHermiteStream64.Chunk,
318
+ IAutoMovieLocalHermiteStream64.Summary,
319
+ void
320
+ >
321
+ | undefined;
315
322
  let outputOperation: boolean = false;
316
323
  try {
317
- const courses: C.Cubic[] = nodes.map(
318
- (n: Node, i: number): C.Cubic =>
324
+ const courses: IAutoMovieCubicBezierCurve64[] = nodes.map(
325
+ (n: Node, i: number): IAutoMovieCubicBezierCurve64 =>
319
326
  normalizeRecoveryCourse(
320
327
  bundle.reports[n.section]!.open[n.arc]!.curve,
321
328
  reversals[i]!,
@@ -334,9 +341,12 @@ export function reconstructAutoMovieRecoveryLocal(
334
341
  maxVerticesPerChunk: 32_768,
335
342
  vertexOffset: spool.counts.vertices,
336
343
  });
337
- let result: IteratorResult<T.Chunk, T.Summary> = iterator.next();
344
+ let result: IteratorResult<
345
+ IAutoMovieLocalHermiteStream64.Chunk,
346
+ IAutoMovieLocalHermiteStream64.Summary
347
+ > = iterator.next();
338
348
  while (!result.done) {
339
- const chunk: T.Chunk = result.value;
349
+ const chunk: IAutoMovieLocalHermiteStream64.Chunk = result.value;
340
350
  outputOperation = true;
341
351
  spool.append(chunk, {
342
352
  run: id,
@@ -1,4 +1,4 @@
1
- import type { AutoMovieRecoveryCurveFormat } from "@automovie/recovery";
1
+ import type { AutoMovieRecoveryCurveFormat } from "@automovie/interface";
2
2
 
3
3
  import { recovery } from "./internal/recovery";
4
4
  import { recoveryAtlas } from "./internal/recoveryAtlas";
@@ -1,8 +1,8 @@
1
1
  import {
2
- type IAutoMovieMark,
3
2
  markAutoMovieContacts,
4
3
  markAutoMovieSkeleton,
5
4
  } from "@automovie/engine";
5
+ import type { IAutoMovieMark } from "@automovie/interface";
6
6
 
7
7
  import type { IFilmProduction } from "./IFilmProduction";
8
8
 
@@ -1,8 +1,12 @@
1
- import type { IAutoMovieMark } from "@automovie/engine";
2
1
  import type {
3
- AutoMovieDrawSubjects,
4
- IAutoMovieDrawScene,
5
- IAutoMovieDrawSubject,
2
+ IAutoMovieMark,
3
+ IAutoMovieRenderSoftPropFrame,
4
+ } from "@automovie/interface";
5
+ import {
6
+ type AutoMovieDrawSubjects,
7
+ type IAutoMovieDrawScene,
8
+ type IAutoMovieDrawSubject,
9
+ bindAutoMovieDrawSceneSoftProps,
6
10
  } from "@automovie/render";
7
11
 
8
12
  import type { IFilm } from "./IFilm";
@@ -17,12 +21,12 @@ import { markFilmProduction } from "./markFilmProduction";
17
21
  * Each film is created as the Viewer creates it, at its delivery raster (1280 × 720 when it states none), seeked through its own `seek` at a second clamped to its running time, and marked by `markFilmProduction`, so a capture, a delivered frame and the Viewer show the same state.
18
22
  *
19
23
  * @evidence contracts/development/common.md#meaningful-documentation States what each subject is, who draws it, and how its raster, seek and marks are taken.
20
- * @evidence contracts/development/implementation.md#principled-implementation Wiring only: the film registry, the film's own create and seek, and the shared marks, mapped onto the render package's subject contract.
24
+ * @evidence contracts/development/implementation.md#principled-implementation Maps the film registry, placement and shared marks onto the draw contract, and binds optional soft surfaces after placement at the same clamped second.
21
25
  * @evidence contracts/development/implementation.md#clear-and-simple-structure One mapping per film.
22
26
  * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No film is named; the props are not read, since films need none.
23
27
  * @evidence contracts/development/implementation.md#efficient-algorithms Linear in the registered films; a film is created only when its subject is.
24
28
  * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work A mapping made once per page.
25
- * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The created film is released by the subject's `dispose`.
29
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The subject's dispose releases the film, and the render adapter independently releases any soft prop meshes it mounts.
26
30
  */
27
31
  export const subjects: AutoMovieDrawSubjects = (): Readonly<
28
32
  Record<string, IAutoMovieDrawSubject>
@@ -34,13 +38,19 @@ export const subjects: AutoMovieDrawSubjects = (): Readonly<
34
38
  {
35
39
  create: async (): Promise<IAutoMovieDrawScene> => {
36
40
  const production: IFilmProduction = await film.create();
37
- return {
41
+ const subject: IAutoMovieDrawScene = {
38
42
  scene: production.scene,
39
43
  camera: production.camera,
40
44
  durationSeconds: film.durationSeconds,
41
45
  fps: film.fps,
42
46
  width: film.width ?? 1280,
43
47
  height: film.height ?? 720,
48
+ markKinds: [
49
+ ...(production.markKinds ?? []),
50
+ ...(production.performance === undefined
51
+ ? []
52
+ : ["joint", "bone", "contact"]),
53
+ ],
44
54
  ...(production.views === undefined
45
55
  ? {}
46
56
  : { views: production.views }),
@@ -52,6 +62,17 @@ export const subjects: AutoMovieDrawSubjects = (): Readonly<
52
62
  ),
53
63
  dispose: (): void => production.dispose(),
54
64
  };
65
+ const softPropsAt: IFilmProduction["softPropsAt"] =
66
+ production.softPropsAt?.bind(production);
67
+ return softPropsAt === undefined
68
+ ? subject
69
+ : bindAutoMovieDrawSceneSoftProps(
70
+ subject,
71
+ (seconds: number): readonly IAutoMovieRenderSoftPropFrame[] =>
72
+ softPropsAt(
73
+ clampProductionSeconds(seconds, film.durationSeconds),
74
+ ),
75
+ );
55
76
  },
56
77
  },
57
78
  ],
@@ -0,0 +1,129 @@
1
+ import type {
2
+ IAutoMovieFilePublicationOptions,
3
+ IAutoMovieFileReceipt,
4
+ IAutoMovieRecoveryResult,
5
+ } from "@automovie/interface";
6
+ import { TestValidator } from "@nestia/e2e";
7
+ import fs from "node:fs";
8
+ import os from "node:os";
9
+ import path from "node:path";
10
+
11
+ import { publishAutoMovieRecoveryArtifact } from "../../src/executable/recovery/node/publishAutoMovieRecoveryArtifact";
12
+
13
+ /**
14
+ * A publication's cancellation predicate is observed before any output is created.
15
+ *
16
+ * Scenarios:
17
+ * 1. True cancels and a thrown predicate fails; both run exactly once and create no output.
18
+ * 2. Nonboolean predicate results fail, while a nonfunction predicate refuses, without output.
19
+ * 3. False permits exact JSON publication and a later cancellation preserves the existing bytes.
20
+ *
21
+ * @evidence contracts/development/testing.md#behavioral-verification Calls the shipped Node publication host and observes terminal tags, predicate invocation count, filesystem absence and exact surviving JSON bytes.
22
+ * @evidence contracts/development/testing.md#independent-expectations Literal predicates and callback errors determine the terminal outcomes; an owned empty directory independently exposes any premature publication.
23
+ * @evidence contracts/development/testing.md#distinguishing-cases Separates true/false, thrown callback, undefined/null/string/number result, malformed callback and cancellation after an immutable output already exists.
24
+ * @evidence contracts/development/testing.md#execution-ownership The entry owns one unique temporary directory and removes it in finally; it replaces no foreign method and starts no subprocess, compiler, renderer or timer.
25
+ * @evidence contracts/development/common.md#meaningful-documentation States pre-work cancellation and failure behavior alongside exact output/lifetime checks.
26
+ */
27
+ export function test_recovery_publication_cancellation(): void {
28
+ const directory: string = fs.mkdtempSync(
29
+ path.join(os.tmpdir(), "automovie-interface-publication-"),
30
+ );
31
+ const output: string = path.join(directory, "artifact.json");
32
+ const artifact: { value: number } = { value: 42 };
33
+ try {
34
+ for (const throws of [false, true]) {
35
+ let calls: number = 0;
36
+ const result: IAutoMovieRecoveryResult<IAutoMovieFileReceipt> =
37
+ publishAutoMovieRecoveryArtifact(output, artifact, {
38
+ cancelled: (): boolean => {
39
+ calls++;
40
+ if (throws) throw new Error("publication predicate failed");
41
+ return true;
42
+ },
43
+ });
44
+ TestValidator.equals(
45
+ "cancellation and exception remain distinct",
46
+ result.status,
47
+ throws ? "failed" : "cancelled",
48
+ );
49
+ TestValidator.equals("one pre-work predicate call", calls, 1);
50
+ TestValidator.predicate(
51
+ "pre-work exit returns no receipt",
52
+ !("value" in result),
53
+ );
54
+ TestValidator.equals(
55
+ "pre-work exit creates no files",
56
+ fs.readdirSync(directory),
57
+ [],
58
+ );
59
+ }
60
+ for (const invalidResult of [undefined, null, "yes", 1]) {
61
+ const options: IAutoMovieFilePublicationOptions = Object.defineProperty(
62
+ {},
63
+ "cancelled",
64
+ { value: (): unknown => invalidResult },
65
+ );
66
+ const result: IAutoMovieRecoveryResult<IAutoMovieFileReceipt> =
67
+ publishAutoMovieRecoveryArtifact(output, artifact, options);
68
+ TestValidator.equals(
69
+ "nonboolean predicate fails",
70
+ result.status,
71
+ "failed",
72
+ );
73
+ TestValidator.equals(
74
+ "invalid result creates no files",
75
+ fs.readdirSync(directory),
76
+ [],
77
+ );
78
+ }
79
+ const invalid: IAutoMovieRecoveryResult<IAutoMovieFileReceipt> =
80
+ publishAutoMovieRecoveryArtifact(
81
+ output,
82
+ artifact,
83
+ JSON.parse('{"cancelled":null}'),
84
+ );
85
+ TestValidator.equals(
86
+ "nonfunction predicate refuses",
87
+ invalid.status,
88
+ "refused",
89
+ );
90
+ TestValidator.equals(
91
+ "refused predicate creates no files",
92
+ fs.readdirSync(directory),
93
+ [],
94
+ );
95
+ const completed: IAutoMovieRecoveryResult<IAutoMovieFileReceipt> =
96
+ publishAutoMovieRecoveryArtifact(output, artifact, {
97
+ cancelled: (): boolean => false,
98
+ });
99
+ TestValidator.equals(
100
+ "false permits publication",
101
+ completed.status,
102
+ "complete",
103
+ );
104
+ const bytes: string = fs.readFileSync(output, "utf8");
105
+ TestValidator.equals(
106
+ "published data preserves the artifact",
107
+ JSON.parse(bytes),
108
+ artifact,
109
+ );
110
+ const cancelled: IAutoMovieRecoveryResult<IAutoMovieFileReceipt> =
111
+ publishAutoMovieRecoveryArtifact(
112
+ output,
113
+ { value: 99 },
114
+ { cancelled: (): boolean => true },
115
+ );
116
+ TestValidator.equals(
117
+ "later cancellation returns no publication",
118
+ cancelled.status,
119
+ "cancelled",
120
+ );
121
+ TestValidator.equals(
122
+ "cancellation preserves published bytes",
123
+ fs.readFileSync(output, "utf8"),
124
+ bytes,
125
+ );
126
+ } finally {
127
+ fs.rmSync(directory, { recursive: true });
128
+ }
129
+ }
@@ -19,8 +19,7 @@
19
19
  "inlineSources": true,
20
20
  "plugins": [
21
21
  {
22
- "transform": "@ttsc/lint",
23
- "configFile": "lint.config.ts"
22
+ "transform": "@ttsc/lint"
24
23
  }
25
24
  ]
26
25
  },
@@ -7,8 +7,20 @@ const productionRoot: string = fileURLToPath(new URL(".", import.meta.url));
7
7
 
8
8
  /** The production's inspector page; generated evidence and capture scratch never reload it. `automovie capture`, `render` and `inspect` build their own pages with this configuration. */
9
9
  export default defineConfig({
10
+ resolve: {
11
+ // Published SDK CommonJS imports must share the browser's ESM Three.js;
12
+ // Three.js's require entry emits a Node-only process warning.
13
+ alias: [
14
+ {
15
+ find: /^three$/,
16
+ replacement: fileURLToPath(import.meta.resolve("three")),
17
+ },
18
+ ],
19
+ },
10
20
  build: {
11
21
  target: "es2022",
22
+ // Preserve lazy initialization across the published SDK's require cycles.
23
+ commonjsOptions: { strictRequires: true },
12
24
  },
13
25
  server: {
14
26
  host: "127.0.0.1",
@@ -1,6 +1,6 @@
1
1
  # {{name}}
2
2
 
3
- An AutoMovie workspace: several productions share one set of skills and contracts, one AutoMovie release and the workspace's own packages. Each production turns an LLM-authored screenplay into a reproducible motion hint, as its own README describes.
3
+ An AutoMovie workspace lets productions share skills, contracts, an AutoMovie release and workspace packages. Follow each production's README for its workflow.
4
4
 
5
5
  ## Layout
6
6
 
@@ -24,7 +24,7 @@ pnpm automovie add shorts/<name>
24
24
  pnpm install
25
25
  ```
26
26
 
27
- `pnpm automovie add shorts/<name>` or `pnpm automovie add series/<name>` creates the production from the installed AutoMovie scaffold, naming its package after `<name>`, lowercased and npm-safe, unless `--name <package>` is given. The second `pnpm install` links it. Then follow that production's README.
27
+ `pnpm automovie add shorts/<name>` or `pnpm automovie add series/<name>` creates the production from the installed scaffold and fills any missing dependency catalog entries. Existing pins and overrides keep their values. The package name is the lowercased, npm-safe form of `<name>`, unless you supply `--name <package>`. Run `pnpm install` again to link the production, then follow its README.
28
28
 
29
29
  ## Packages
30
30
 
@@ -2,7 +2,7 @@
2
2
  "name": "{{name}}",
3
3
  "private": true,
4
4
  "type": "module",
5
- "version": "0.2.0",
5
+ "version": "0.3.1",
6
6
  "license": "MIT",
7
7
  "description": "An AutoMovie workspace of productions and their shared packages.",
8
8
  "engines": {
@@ -1,27 +1,15 @@
1
1
  import * as fs from "node:fs";
2
2
  import * as path from "node:path";
3
- import { stringify } from "yaml";
4
3
 
5
4
  import type { IAutoMovieScaffoldProps } from "./IAutoMovieScaffoldProps";
6
5
  import { assertScaffoldProjectName } from "./assertScaffoldProjectName";
7
6
  import { listAutoMovieScaffoldFiles } from "./listAutoMovieScaffoldFiles";
7
+ import { renderAutoMovieWorkspace } from "./renderAutoMovieWorkspace";
8
8
  import { scaffoldSharedSkillPath } from "./scaffoldSharedSkillPath";
9
9
 
10
10
  /** The package root: `src` under ttsx and `lib` when published both sit one level below it. */
11
11
  const PACKAGE: string = path.resolve(__dirname, "..");
12
12
 
13
- /** The pnpm settings `build/prepare.ts` reads from the repository's own `pnpm-workspace.yaml`. */
14
- interface IScaffoldPnpmSettings {
15
- /** Names of the packages in the `automovie` catalog, whose range is this package's own version. */
16
- automovie: string[];
17
-
18
- /** Every other catalog the scaffold's `package.json` files reference, with the repository's ranges. */
19
- catalogs: Record<string, Record<string, string>>;
20
-
21
- /** The repository's dependency build policy. */
22
- allowBuilds: Record<string, boolean>;
23
- }
24
-
25
13
  /**
26
14
  * Create the files of a new AutoMovie installation as a `{ posixPath: content }` map.
27
15
  *
@@ -73,7 +61,7 @@ export const createAutoMovieScaffold: (
73
61
  if (props.kind !== "workspace-production") readLayer("instructions", add);
74
62
  readLayer(props.kind === "workspace" ? "workspace" : "production", add);
75
63
  if (props.kind !== "workspace-production")
76
- add("pnpm-workspace.yaml", renderPnpmWorkspace(props.kind === "workspace"));
64
+ add("pnpm-workspace.yaml", renderAutoMovieWorkspace(props.kind));
77
65
  if (props.kind !== "workspace")
78
66
  add(
79
67
  "evidence.config.ts",
@@ -106,31 +94,6 @@ const readLayer = (
106
94
  }
107
95
  };
108
96
 
109
- /** The `pnpm-workspace.yaml` of a single production, or with `packages` of a workspace root. */
110
- const renderPnpmWorkspace = (packages: boolean): string => {
111
- const settings: IScaffoldPnpmSettings = JSON.parse(
112
- read(path.join(PACKAGE, "generated", "pnpm-workspace.json")),
113
- ) as IScaffoldPnpmSettings;
114
- const manifest: { version: string } = JSON.parse(
115
- read(path.join(PACKAGE, "package.json")),
116
- ) as { version: string };
117
- return stringify({
118
- ...(packages
119
- ? { packages: ["movies/shorts/*", "movies/series/*", "packages/*"] }
120
- : {}),
121
- catalogs: {
122
- automovie: Object.fromEntries(
123
- settings.automovie.map((key: string): [string, string] => [
124
- key,
125
- `^${manifest.version}`,
126
- ]),
127
- ),
128
- ...settings.catalogs,
129
- },
130
- allowBuilds: settings.allowBuilds,
131
- });
132
- };
133
-
134
97
  /** The `evidence.config.ts` of a production, reading its own skills or, inside a workspace, the root's. */
135
98
  const renderEvidenceConfig = (workspace: boolean): string =>
136
99
  [
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./IAutoMovieScaffoldProps";
2
2
  export * from "./assertScaffoldProjectName";
3
3
  export * from "./createAutoMovieScaffold";
4
+ export * from "./renderAutoMovieWorkspace";
@@ -0,0 +1,157 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { type Document, isMap, parseDocument, stringify, visit } from "yaml";
4
+
5
+ /** Catalog dependencies and build policy collected from the shipped manifests at build time. */
6
+ interface IScaffoldSettings {
7
+ automovie: string[];
8
+ catalogs: Record<string, Record<string, string>>;
9
+ allowBuilds: Record<string, boolean>;
10
+ }
11
+
12
+ /**
13
+ * Render pnpm settings for a new production or workspace. Given an existing
14
+ * workspace's directory and YAML, fill missing scaffold catalog entries.
15
+ * Existing pins, overrides, workspace members and build policy keep their values.
16
+ * A linked SDK supplies missing scoped packages when their sibling manifests
17
+ * identify them. Other new entries use the installed scaffold's ranges.
18
+ *
19
+ * @param workspace The new layout or the existing workspace whose catalogs the CLI needs.
20
+ * @returns Workspace YAML, byte-for-byte unchanged when every required entry exists.
21
+ * @throws If the shipped settings or workspace YAML cannot be read as required.
22
+ * @evidence contracts/development/implementation.md#principled-implementation Both paths resolve the shipped manifests' catalog references from the same build settings and template version. Local SDK lookup requires an existing link and the requested package identity.
23
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure The layout selects creation or completion. The YAML document owns edits and the caller owns the write.
24
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The build discovers the dependencies. Package names and workspace layouts follow their published conventions.
25
+ * @evidence contracts/development/implementation.md#efficient-algorithms The existing document is parsed once and each required entry is visited once. Only missing SDK entries probe sibling manifests in distinct linked directories.
26
+ * @evidence contracts/development/implementation.md#reuse-equivalent-work Both layouts share the resolved defaults. SDK directories are deduplicated per document.
27
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources File reads close synchronously. Parsed settings, document and link directories live for one call.
28
+ * @evidence contracts/development/common.md#meaningful-documentation The comment describes each mode, precedence, return value and failure.
29
+ */
30
+ export function renderAutoMovieWorkspace(
31
+ workspace: "production" | "workspace" | { directory: string; source: string },
32
+ ): string {
33
+ const settings: IScaffoldSettings = JSON.parse(
34
+ fs.readFileSync(
35
+ path.join(__dirname, "../generated/pnpm-workspace.json"),
36
+ "utf8",
37
+ ),
38
+ );
39
+ const manifest: { version: string } = JSON.parse(
40
+ fs.readFileSync(path.join(__dirname, "../package.json"), "utf8"),
41
+ );
42
+ const catalogs: Record<string, Record<string, string>> = {
43
+ automovie: Object.fromEntries(
44
+ settings.automovie.map((name: string) => [name, `^${manifest.version}`]),
45
+ ),
46
+ ...settings.catalogs,
47
+ };
48
+ if (typeof workspace === "string")
49
+ return stringify({
50
+ ...(workspace === "workspace"
51
+ ? { packages: ["movies/shorts/*", "movies/series/*", "packages/*"] }
52
+ : {}),
53
+ catalogs,
54
+ allowBuilds: settings.allowBuilds,
55
+ });
56
+
57
+ const document: Document = parseDocument(workspace.source, { merge: true });
58
+ if (document.errors.length) throw document.errors[0];
59
+ const root: Map<string, unknown> = mapping(
60
+ document.toJS({ mapAsMap: true }),
61
+ "pnpm-workspace.yaml",
62
+ );
63
+ const current: Map<string, unknown> = mapping(
64
+ root.get("catalogs"),
65
+ "catalogs",
66
+ );
67
+ const sdk: Map<string, unknown> = mapping(
68
+ current.get("automovie"),
69
+ "catalogs.automovie",
70
+ );
71
+ const overrides: Map<string, unknown> = mapping(
72
+ root.get("overrides"),
73
+ "overrides",
74
+ );
75
+ const directories: Set<string> = new Set();
76
+ for (const [name, spec] of new Map([...sdk, ...overrides]))
77
+ if (
78
+ name.startsWith("@automovie/") &&
79
+ typeof spec === "string" &&
80
+ spec.startsWith("link:")
81
+ )
82
+ directories.add(
83
+ path.dirname(path.resolve(workspace.directory, spec.slice(5))),
84
+ );
85
+
86
+ let changed: boolean = false;
87
+ for (const [catalog, dependencies] of Object.entries(catalogs)) {
88
+ const entries: Map<string, unknown> = mapping(
89
+ current.get(catalog),
90
+ `catalogs.${catalog}`,
91
+ );
92
+ const missing: [string, string][] = Object.entries(dependencies).filter(
93
+ ([name]) => !entries.has(name),
94
+ );
95
+ if (missing.length === 0) continue;
96
+ if (!changed) isolateMapping(document, ["catalogs"], current);
97
+ isolateMapping(document, ["catalogs", catalog], entries);
98
+ for (const [name, range] of missing) {
99
+ const link: string | undefined =
100
+ catalog === "automovie" && !overrides.has(name)
101
+ ? linkedSibling(workspace.directory, directories, name)
102
+ : undefined;
103
+ document.setIn(["catalogs", catalog, name], link ?? range);
104
+ }
105
+ changed = true;
106
+ }
107
+ return changed ? document.toString() : workspace.source;
108
+ }
109
+
110
+ /** Give this path its own entries, preserving the old values at other uses of its anchor. */
111
+ function isolateMapping(
112
+ document: Document,
113
+ keys: string[],
114
+ values: Map<string, unknown>,
115
+ ): void {
116
+ const node = document.getIn(keys, true);
117
+ if (!isMap(node)) {
118
+ document.setIn(keys, document.createNode(values));
119
+ return;
120
+ }
121
+ if (node.anchor)
122
+ visit(document, {
123
+ Alias: (_key, alias) => {
124
+ if (alias.resolve(document) === node)
125
+ return document.createNode(values, { aliasDuplicateObjects: false });
126
+ },
127
+ });
128
+ }
129
+
130
+ /** Read an optional YAML mapping, refusing malformed pnpm settings before edits. */
131
+ function mapping(value: unknown, key: string): Map<string, unknown> {
132
+ if (value === undefined || value === null) return new Map();
133
+ if (value instanceof Map) return value;
134
+ throw new Error(`${key} must be a mapping in pnpm-workspace.yaml`);
135
+ }
136
+
137
+ /** Resolve a missing scoped SDK package beside the workspace's linked SDK packages. */
138
+ function linkedSibling(
139
+ root: string,
140
+ directories: Set<string>,
141
+ name: string,
142
+ ): string | undefined {
143
+ if (!name.startsWith("@automovie/")) return undefined;
144
+ for (const directory of directories) {
145
+ const candidate: string = path.join(
146
+ directory,
147
+ name.slice("@automovie/".length),
148
+ );
149
+ const file: string = path.join(candidate, "package.json");
150
+ if (
151
+ fs.existsSync(file) &&
152
+ JSON.parse(fs.readFileSync(file, "utf8")).name === name
153
+ )
154
+ return `link:${path.relative(root, candidate).split(path.sep).join("/")}`;
155
+ }
156
+ return undefined;
157
+ }