stillmade-sdk 0.1.41 → 0.1.43

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 (285) hide show
  1. package/.stillmade/sdk-baseline.json +19 -21
  2. package/AGENTS.md +17 -12
  3. package/FRAME_VIEWS.md +113 -0
  4. package/INTERFACE_DESIGN.md +67 -22
  5. package/MOBILE_UI.md +4 -2
  6. package/MODULES.md +152 -6
  7. package/PASTE_TO_LLM.md +42 -32
  8. package/README.md +3 -2
  9. package/SDK.md +1028 -563
  10. package/UI_AESTHETIC.md +30 -3
  11. package/blocks/generate/package.js +1 -0
  12. package/blocks/generate/versions/1.0.0/package.js +463 -0
  13. package/docs/build/audio-to-editor.md +36 -0
  14. package/docs/build/block-builder-contract.md +150 -0
  15. package/docs/build/comfyui.md +227 -0
  16. package/docs/build/concepts.md +40 -0
  17. package/docs/build/context.md +159 -0
  18. package/docs/build/cookbook.md +57 -0
  19. package/docs/build/custom-interface.md +617 -0
  20. package/docs/build/data-types.md +83 -0
  21. package/docs/build/frame-views.md +259 -0
  22. package/docs/build/generate-media.md +59 -0
  23. package/docs/build/github-applications.md +314 -0
  24. package/docs/build/hosted-images.md +214 -0
  25. package/docs/build/hosted-music.md +39 -0
  26. package/docs/build/hosted-speech.md +157 -0
  27. package/docs/build/hosted-text.md +246 -0
  28. package/docs/build/image-description.md +49 -0
  29. package/docs/build/interface-design.md +343 -0
  30. package/docs/build/javascript.md +63 -0
  31. package/docs/build/local-preview.md +61 -0
  32. package/docs/build/media-analysis.md +27 -0
  33. package/docs/build/media.md +400 -0
  34. package/docs/build/mobile-ui.md +106 -0
  35. package/docs/build/modules.md +487 -0
  36. package/docs/build/original-blocks.md +70 -0
  37. package/docs/build/outside-apis.md +128 -0
  38. package/docs/build/production-context-templates.md +12 -0
  39. package/docs/build/project-storage.md +94 -0
  40. package/docs/build/quickstart.md +48 -0
  41. package/docs/build/recipes.md +103 -0
  42. package/docs/build/script-handoff.md +45 -0
  43. package/docs/build/script-writer.md +34 -0
  44. package/docs/build/state.md +223 -0
  45. package/docs/build/testing.md +112 -0
  46. package/docs/build/timeline-edits.md +116 -0
  47. package/docs/build/timeline-proposals.md +76 -0
  48. package/docs/build/transcription.md +59 -0
  49. package/docs/build/triggers.md +59 -0
  50. package/docs/build/tutorial.md +52 -0
  51. package/docs/build/typescript.md +34 -0
  52. package/docs/build/video-generation.md +61 -0
  53. package/docs/build/web-reading.md +37 -0
  54. package/docs/build/with-your-ai.md +27 -0
  55. package/docs/changelog.md +9 -0
  56. package/docs/creators.md +21 -0
  57. package/docs/distribute/discovery.md +43 -0
  58. package/docs/distribute/imports.md +58 -0
  59. package/docs/distribute/publishing.md +29 -0
  60. package/docs/distribute/sdk-versions.md +36 -0
  61. package/docs/distribute/selling.md +14 -0
  62. package/docs/distribute/teams.md +60 -0
  63. package/docs/distribute/versioning.md +28 -0
  64. package/docs/examples.md +23 -0
  65. package/docs/gallery.md +26 -0
  66. package/docs/index.md +50 -0
  67. package/docs/native-mcp.md +307 -0
  68. package/docs/project-types/automation.md +43 -0
  69. package/docs/project-types/batches.md +50 -0
  70. package/docs/project-types/build.md +42 -0
  71. package/docs/project-types/completion.md +15 -0
  72. package/docs/project-types/conditions.md +21 -0
  73. package/docs/project-types/hosted-review.md +115 -0
  74. package/docs/project-types/onboarding.md +75 -0
  75. package/docs/project-types/running.md +309 -0
  76. package/docs/project-types/testing.md +72 -0
  77. package/docs/reference/application-artifacts.md +87 -0
  78. package/docs/reference/authoring-guide.md +134 -0
  79. package/docs/reference/browser-applications.md +267 -0
  80. package/docs/reference/capabilities.md +45 -0
  81. package/docs/reference/cli.md +71 -0
  82. package/docs/reference/connection-api.md +59 -0
  83. package/docs/reference/cooperative-jobs.md +13 -0
  84. package/docs/reference/desktop-capabilities.md +172 -0
  85. package/docs/reference/desktop-execution.md +77 -0
  86. package/docs/reference/errors.md +233 -0
  87. package/docs/reference/execution.md +800 -0
  88. package/docs/reference/first-party-blocks.md +40 -0
  89. package/docs/reference/generation-models.md +59 -0
  90. package/docs/reference/limits.md +306 -0
  91. package/docs/reference/manifest-kinds-controls.md +36 -0
  92. package/docs/reference/manifest.md +181 -0
  93. package/docs/reference/operations.md +36 -0
  94. package/docs/reference/package-jobs.md +35 -0
  95. package/docs/reference/parity.md +55 -0
  96. package/docs/reference/permissions.md +86 -0
  97. package/docs/reference/ports.md +26 -0
  98. package/docs/reference/types.md +268 -0
  99. package/docs/reference/universal-resolver.md +303 -0
  100. package/docs/reference/view-bridge.md +60 -0
  101. package/docs/reference/view-rules.md +15 -0
  102. package/docs/reference/workspace-sync.md +25 -0
  103. package/docs/sdk.md +34 -0
  104. package/docs/tools/block-remix.md +211 -0
  105. package/docs/tools/llm.md +2213 -0
  106. package/docs/tools/repository-adaptation.md +613 -0
  107. package/examples/check-clip.stillmade.json +8 -1
  108. package/examples/clean-text.stillmade.json +4 -0
  109. package/examples/custom-interface.stillmade.json +4 -0
  110. package/examples/describe-image.stillmade.json +4 -0
  111. package/examples/foley-cue.stillmade.json +4 -0
  112. package/examples/generate-image.stillmade.json +4 -0
  113. package/examples/generate-video.stillmade.json +10 -2
  114. package/examples/module-word-stats/stillmade.block.json +4 -0
  115. package/examples/narrate-script.stillmade.json +4 -0
  116. package/examples/numbered-takes.stillmade.json +4 -0
  117. package/examples/research-topic.stillmade.json +9 -1
  118. package/examples/score-a-scene.stillmade.json +4 -0
  119. package/examples/script-draft.stillmade.json +4 -0
  120. package/examples/summarize-page.stillmade.json +4 -0
  121. package/examples/text-workflow.stillmade.json +7 -32
  122. package/examples/thicken-lines.stillmade.json +4 -0
  123. package/examples/timeline-polish.stillmade.json +15 -3
  124. package/examples/transcribe-audio.stillmade.json +15 -3
  125. package/examples/word-count.stillmade.json +4 -0
  126. package/package.json +1 -1
  127. package/packages/block-cli/cli.js +13 -6
  128. package/packages/block-cli/dev-host/assets/host.js +81 -38
  129. package/packages/block-cli/dev-host/assets/index.css +1 -1
  130. package/packages/block-cli/format.js +1 -1
  131. package/packages/block-cli/ready-gate.js +4 -0
  132. package/packages/block-cli/templates.js +37 -19
  133. package/packages/block-cli/type-packages.js +119 -0
  134. package/packages/block-platform/block-readiness.js +8 -1
  135. package/packages/block-platform/canvas.js +2 -1
  136. package/packages/block-platform/catalog.js +27 -48
  137. package/packages/block-platform/native-host-inventory.js +0 -226
  138. package/packages/block-platform/plain-descriptions.js +1 -25
  139. package/packages/block-platform/project-type-starters.js +13 -53
  140. package/packages/block-platform/script-handoff.js +2 -4
  141. package/packages/block-platform/type-workspace.js +2 -0
  142. package/packages/block-sdk/appearance.js +3 -1
  143. package/packages/block-sdk/audio-generation-example.js +2 -2
  144. package/packages/block-sdk/block-tier.js +1 -1
  145. package/packages/block-sdk/builder-contract.js +13 -11
  146. package/packages/block-sdk/capabilities.js +1 -1
  147. package/packages/block-sdk/capability-example.js +1 -1
  148. package/packages/block-sdk/contracts.js +6 -2
  149. package/packages/block-sdk/examples.js +3 -3
  150. package/packages/block-sdk/first-party-identities.js +1 -84
  151. package/packages/block-sdk/first-party-packages.js +3 -85
  152. package/packages/block-sdk/generation-catalog.js +15 -3
  153. package/packages/block-sdk/image-description-example.js +1 -1
  154. package/packages/block-sdk/image-generation-example.js +1 -1
  155. package/packages/block-sdk/index.d.ts +2 -1
  156. package/packages/block-sdk/media-analysis-example.js +2 -2
  157. package/packages/block-sdk/mock-host.js +7 -1
  158. package/packages/block-sdk/module-example.js +1 -1
  159. package/packages/block-sdk/module-host-calls.js +35 -10
  160. package/packages/block-sdk/module-hosted.js +15 -2
  161. package/packages/block-sdk/module-media-access.js +71 -0
  162. package/packages/block-sdk/module-node.js +1 -1
  163. package/packages/block-sdk/portable-media-actions.js +1 -1
  164. package/packages/block-sdk/runtime.js +1 -1
  165. package/packages/block-sdk/speech-example.js +1 -1
  166. package/packages/block-sdk/state-example.js +1 -1
  167. package/packages/block-sdk/timeline-proposal-example.js +1 -1
  168. package/packages/block-sdk/transcription-example.js +1 -1
  169. package/packages/block-sdk/trigger-examples.js +2 -2
  170. package/packages/block-sdk/video-generation-example.js +1 -1
  171. package/packages/block-sdk/view-bridge.js +4 -1
  172. package/packages/block-sdk/view-design.js +44 -15
  173. package/packages/block-sdk/web-example.js +2 -2
  174. package/packages/design-system/block-kit.css +53 -12
  175. package/packages/design-system/block-kit.html +3 -2
  176. package/blocks/mcp-motion-planner/versions/1.1.0/package.js +0 -97
  177. package/blocks/motion-designer/versions/1.0.1/package.js +0 -173318
  178. package/blocks/motion-designer/versions/1.0.2/package.js +0 -173318
  179. package/blocks/motion-frame-review/versions/1.1.1/package.js +0 -465
  180. package/blocks/motion-frame-review/versions/1.1.2/package.snapshot.js +0 -572
  181. package/blocks/narration/package.js +0 -1
  182. package/blocks/narration/versions/1.0.0/package.js +0 -221
  183. package/blocks/narration/versions/1.0.1/package.js +0 -221
  184. package/blocks/native/sm.animated-scene/versions/2.0.0/package.js +0 -475
  185. package/blocks/native/sm.animated-scene/versions/2.1.0/package.js +0 -498
  186. package/blocks/native/sm.animated-scene/versions/2.2.0/package.js +0 -524
  187. package/blocks/native/sm.animated-scene/versions/2.3.0/package.js +0 -618
  188. package/blocks/native/sm.animated-scene/versions/2.3.1/package.js +0 -618
  189. package/blocks/native/sm.animated-scene/versions/2.3.2/package.js +0 -723
  190. package/blocks/native/sm.animated-scene/versions/2.3.3/package.js +0 -723
  191. package/blocks/native/sm.animated-scene/versions/2.3.4/package.js +0 -676
  192. package/blocks/native/sm.animated-scene/versions/2.3.5/package.js +0 -693
  193. package/blocks/native/sm.animated-scene/versions/2.3.6/package.js +0 -700
  194. package/blocks/native/sm.animated-scene/versions/2.3.7/package.js +0 -747
  195. package/blocks/native/sm.animated-scene/versions/2.3.8/package.js +0 -769
  196. package/blocks/native/sm.animated-scene/versions/2.3.9/package.js +0 -769
  197. package/blocks/native/sm.animated-scene-assistant/versions/1.0.0/package.js +0 -183
  198. package/blocks/native/sm.blueprint/versions/2.0.0/package.js +0 -358
  199. package/blocks/native/sm.blueprint/versions/2.1.0/package.js +0 -358
  200. package/blocks/native/sm.blueprint/versions/2.1.1/package.js +0 -358
  201. package/blocks/native/sm.blueprint/versions/2.1.2/package.js +0 -358
  202. package/blocks/native/sm.blueprint/versions/2.1.3/package.js +0 -381
  203. package/blocks/native/sm.blueprint/versions/2.1.4/package.js +0 -381
  204. package/blocks/native/sm.blueprint/versions/2.1.5/package.js +0 -339
  205. package/blocks/native/sm.blueprint/versions/2.1.6/package.js +0 -356
  206. package/blocks/native/sm.blueprint/versions/2.1.7/package.js +0 -363
  207. package/blocks/native/sm.blueprint/versions/2.1.8/package.js +0 -410
  208. package/blocks/native/sm.blueprint/versions/2.1.9/package.js +0 -422
  209. package/blocks/native/sm.blueprint-assistant/versions/1.0.0/package.js +0 -172
  210. package/blocks/native/sm.chat/versions/2.0.0/package.js +0 -144
  211. package/blocks/native/sm.chat/versions/2.0.1/package.js +0 -97
  212. package/blocks/native/sm.chat/versions/2.0.2/package.js +0 -100
  213. package/blocks/native/sm.chat/versions/2.0.3/package.js +0 -100
  214. package/blocks/native/sm.continue-if/versions/1.0.0/package.js +0 -168
  215. package/blocks/native/sm.describe-media/versions/2.0.0/package.js +0 -153
  216. package/blocks/native/sm.describe-media/versions/2.0.1/package.js +0 -156
  217. package/blocks/native/sm.describe-media/versions/2.1.0/package.js +0 -140
  218. package/blocks/native/sm.image-editor/versions/2.0.0/package.js +0 -183
  219. package/blocks/native/sm.image-editor/versions/2.0.1/package.js +0 -190
  220. package/blocks/native/sm.new-items/versions/1.0.0/package.js +0 -191
  221. package/blocks/native/sm.pick-photos/versions/1.0.0/package.js +0 -334
  222. package/blocks/native/sm.quality-audit/versions/1.0.0/package.js +0 -192
  223. package/blocks/native/sm.quality-audit/versions/1.0.1/package.js +0 -192
  224. package/blocks/native/sm.quality-audit/versions/1.0.2/package.js +0 -195
  225. package/blocks/native/sm.research/versions/2.0.0/package.js +0 -175
  226. package/blocks/native/sm.research/versions/2.0.1/package.js +0 -184
  227. package/blocks/native/sm.research/versions/2.0.2/package.js +0 -187
  228. package/blocks/native/sm.script/versions/2.0.0/package.js +0 -144
  229. package/blocks/native/sm.script/versions/2.1.0/package.js +0 -144
  230. package/blocks/native/sm.script/versions/2.1.1/package.js +0 -144
  231. package/blocks/native/sm.script/versions/2.1.2/package.js +0 -105
  232. package/blocks/native/sm.script/versions/2.1.3/package.js +0 -152
  233. package/blocks/native/sm.script/versions/2.1.4/package.js +0 -156
  234. package/blocks/native/sm.script/versions/2.1.5/package.js +0 -156
  235. package/blocks/native/sm.shot-plan/versions/2.0.0/package.js +0 -301
  236. package/blocks/native/sm.shot-plan/versions/2.1.0/package.js +0 -528
  237. package/blocks/native/sm.shot-plan/versions/2.1.1/package.js +0 -528
  238. package/blocks/native/sm.shot-plan/versions/2.1.2/package.js +0 -528
  239. package/blocks/native/sm.shot-plan/versions/2.1.3/package.js +0 -536
  240. package/blocks/native/sm.shot-plan/versions/2.2.0/package.js +0 -800
  241. package/blocks/native/sm.shot-plan/versions/2.2.1/package.js +0 -920
  242. package/blocks/native/sm.shot-plan-assistant/versions/1.0.0/package.js +0 -173
  243. package/blocks/native/sm.stock-search/versions/2.0.0/package.js +0 -174
  244. package/blocks/native/sm.thumbnail/versions/2.0.0/package.js +0 -137
  245. package/blocks/native/sm.thumbnail/versions/2.0.1/package.js +0 -140
  246. package/blocks/native/sm.transcribe/versions/2.0.0/package.js +0 -163
  247. package/blocks/native/sm.transcribe/versions/2.0.1/package.js +0 -168
  248. package/blocks/native/sm.whiteboard-assistant/versions/1.0.0/package.js +0 -175
  249. package/blocks/native/sm.youtube/versions/2.0.0/package.js +0 -217
  250. package/blocks/occasion-story/package.js +0 -1
  251. package/blocks/occasion-story/versions/1.0.0/package.js +0 -1658
  252. package/blocks/occasion-story/versions/1.0.1/package.js +0 -1699
  253. package/blocks/occasion-story/versions/1.0.2/package.js +0 -1682
  254. package/blocks/photo-reel-composer/versions/1.0.0/package.js +0 -3043
  255. package/blocks/photo-reel-composer/versions/1.0.1/package.js +0 -3026
  256. package/blocks/photo-reel-composer/versions/1.0.2/package.js +0 -4149
  257. package/blocks/product-ad-variants/versions/1.0.0/package.js +0 -2911
  258. package/blocks/product-launch-director/versions/1.0.0/package.js +0 -103
  259. package/blocks/release-visuals/package.js +0 -1
  260. package/blocks/release-visuals/versions/1.0.0/package.js +0 -1492
  261. package/blocks/release-visuals/versions/1.0.1/package.js +0 -1517
  262. package/blocks/release-visuals/versions/1.0.2/package.js +0 -1500
  263. package/blocks/screen-recorder/package.js +0 -1
  264. package/blocks/screen-recorder/versions/1.0.0/package.js +0 -223
  265. package/blocks/screen-recorder/versions/1.0.1/package.js +0 -223
  266. package/blocks/short-form-finish/package.js +0 -1
  267. package/blocks/short-form-finish/versions/1.0.0/package.js +0 -1043
  268. package/blocks/short-form-finish/versions/1.0.1/package.js +0 -1043
  269. package/blocks/short-form-finish/versions/1.0.2/package.js +0 -1043
  270. package/blocks/short-form-finish/versions/1.0.3/package.js +0 -1026
  271. package/examples/saas-product-launch-reviewed-source.stillmade.json +0 -383
  272. package/examples/saas-product-launch.stillmade.json +0 -304
  273. package/packages/block-platform/dealer-inventory-video-project-type.js +0 -38
  274. package/packages/block-platform/first-revenue-project-types.js +0 -46
  275. package/packages/block-platform/fixture-starters.js +0 -13
  276. package/packages/block-platform/launch-project-source.js +0 -10
  277. package/packages/block-platform/launch-project.js +0 -30
  278. package/packages/block-platform/motion-project-types.js +0 -55
  279. package/packages/block-platform/motion-starters.js +0 -14
  280. package/packages/block-platform/product-ad-variants-project-type.js +0 -30
  281. package/packages/block-platform/product-launch-updated.js +0 -90
  282. package/packages/block-platform/revenue-review-project-types.js +0 -36
  283. package/packages/block-platform/revenue-review-starters.js +0 -13
  284. package/packages/block-platform/script-writer.js +0 -29
  285. package/packages/block-platform/website-source-block.js +0 -14
@@ -1,191 +0,0 @@
1
- // Generated by scripts/build-owned-blocks.mjs. Edit the owned source files.
2
- export default {
3
- "manifest": {
4
- "schemaVersion": 1,
5
- "sdkVersion": "0.1.0",
6
- "id": "sm.new-items",
7
- "version": "1.0.0",
8
- "name": "Only new items",
9
- "description": "Pass on one item an app returned that this automation has not handled yet, such as a new lead, order or message. It remembers what it has already passed on, so the same item is never handled twice; when nothing is new, the run stops here.",
10
- "kind": "task",
11
- "runtime": "javascript",
12
- "license": "MIT",
13
- "provenance": {
14
- "notice": "Original source (authorship declared by the packager)\nLicense: MIT\nChanges: Original implementation declared by the packager; no reused repository or dependency code.\nFiles: LICENSE, src/run.js\n\nMIT License\n\nCopyright (c) 2026 StillMade contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
15
- "portableSources": [
16
- {
17
- "kind": "original",
18
- "license": "MIT",
19
- "paths": [
20
- "LICENSE",
21
- "src/run.js"
22
- ],
23
- "evidence": [
24
- "upstream/0/LICENSE",
25
- "upstream/0/src/run.js"
26
- ],
27
- "changes": "Original implementation declared by the packager; no reused repository or dependency code."
28
- }
29
- ]
30
- },
31
- "inputs": {
32
- "items": {
33
- "type": "object",
34
- "primary": true,
35
- "semantic": "external_data",
36
- "required": true,
37
- "description": "An app's result that contains a list, for example Meta Ads leads or Shopify orders.",
38
- "schema": "object"
39
- },
40
- "id_field": {
41
- "type": "text",
42
- "default": "id",
43
- "required": false,
44
- "description": "The field that identifies each item. Most apps use id.",
45
- "semantic": "item_id_field"
46
- }
47
- },
48
- "outputs": {
49
- "item": {
50
- "type": "object",
51
- "primary": true,
52
- "semantic": "external_data",
53
- "required": false,
54
- "description": "The oldest item not handled yet. Missing when there is nothing new.",
55
- "schema": "object"
56
- },
57
- "waiting": {
58
- "type": "integer",
59
- "required": false,
60
- "description": "How many more new items are waiting for the next runs.",
61
- "semantic": "pending_item_count"
62
- }
63
- },
64
- "permissions": {
65
- "project": [
66
- "state.step"
67
- ]
68
- },
69
- "state": {
70
- "scope": "step",
71
- "version": 1,
72
- "initial": {
73
- "seen": []
74
- }
75
- },
76
- "ui": [
77
- {
78
- "port": "items",
79
- "control": "text"
80
- },
81
- {
82
- "port": "id_field",
83
- "control": "text"
84
- }
85
- ]
86
- },
87
- "code": "const findList = (value, depth) => {\n if (Array.isArray(value)) return value;\n if (!value || typeof value !== 'object' || depth > 3) return null;\n for (const key of ['data', 'items', 'results', 'records', 'leads', 'orders', 'messages', 'rows', 'value']) {\n const found = findList(value[key], depth + 1);\n if (found) return found;\n }\n for (const key of Object.keys(value)) {\n if (Array.isArray(value[key])) return value[key];\n }\n for (const key of Object.keys(value)) {\n const found = findList(value[key], depth + 1);\n if (found) return found;\n }\n return null;\n};\nconst field = (input.id_field || 'id').trim() || 'id';\nconst list = (findList(input.items, 0) || []).filter(item => item && typeof item === 'object' && !Array.isArray(item));\nconst keyOf = item => item[field] === undefined || item[field] === null ? JSON.stringify(item) : String(item[field]);\nconst seen = new Set(state.seen);\n// Apps usually list newest first; handle the oldest new item first.\nconst fresh = list.filter(item => !seen.has(keyOf(item))).reverse();\nif (!fresh.length) return {};\nstate.seen = [...state.seen, keyOf(fresh[0])].slice(-2000);\nreturn { item: fresh[0], waiting: fresh.length - 1 };\n",
88
- "tests": [
89
- {
90
- "name": "Passes the oldest new lead",
91
- "input": {
92
- "items": {
93
- "data": [
94
- {
95
- "id": "3",
96
- "name": "Cara"
97
- },
98
- {
99
- "id": "2",
100
- "name": "Ben"
101
- },
102
- {
103
- "id": "1",
104
- "name": "Ana"
105
- }
106
- ]
107
- }
108
- },
109
- "state": {
110
- "version": 1,
111
- "value": {
112
- "seen": [
113
- "1"
114
- ]
115
- }
116
- },
117
- "expected": {
118
- "item": {
119
- "id": "2",
120
- "name": "Ben"
121
- },
122
- "waiting": 1
123
- },
124
- "expectedState": {
125
- "version": 1,
126
- "value": {
127
- "seen": [
128
- "1",
129
- "2"
130
- ]
131
- }
132
- }
133
- },
134
- {
135
- "name": "Stops when nothing is new",
136
- "input": {
137
- "items": {
138
- "data": [
139
- {
140
- "id": "1"
141
- }
142
- ]
143
- }
144
- },
145
- "state": {
146
- "version": 1,
147
- "value": {
148
- "seen": [
149
- "1"
150
- ]
151
- }
152
- },
153
- "expected": {},
154
- "expectedState": {
155
- "version": 1,
156
- "value": {
157
- "seen": [
158
- "1"
159
- ]
160
- }
161
- }
162
- }
163
- ],
164
- "portable": {
165
- "format": "stillmade-block/1",
166
- "dependencies": [],
167
- "sources": [
168
- {
169
- "kind": "original",
170
- "license": "MIT",
171
- "paths": [
172
- "LICENSE",
173
- "src/run.js"
174
- ],
175
- "evidence": [
176
- "upstream/0/LICENSE",
177
- "upstream/0/src/run.js"
178
- ],
179
- "changes": "Original implementation declared by the packager; no reused repository or dependency code."
180
- }
181
- ],
182
- "files": {
183
- "upstream/0/LICENSE": "MIT License\n\nCopyright (c) 2026 StillMade contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
184
- "upstream/0/src/run.js": "const findList = (value, depth) => {\n if (Array.isArray(value)) return value;\n if (!value || typeof value !== 'object' || depth > 3) return null;\n for (const key of ['data', 'items', 'results', 'records', 'leads', 'orders', 'messages', 'rows', 'value']) {\n const found = findList(value[key], depth + 1);\n if (found) return found;\n }\n for (const key of Object.keys(value)) {\n if (Array.isArray(value[key])) return value[key];\n }\n for (const key of Object.keys(value)) {\n const found = findList(value[key], depth + 1);\n if (found) return found;\n }\n return null;\n};\nconst field = (input.id_field || 'id').trim() || 'id';\nconst list = (findList(input.items, 0) || []).filter(item => item && typeof item === 'object' && !Array.isArray(item));\nconst keyOf = item => item[field] === undefined || item[field] === null ? JSON.stringify(item) : String(item[field]);\nconst seen = new Set(state.seen);\n// Apps usually list newest first; handle the oldest new item first.\nconst fresh = list.filter(item => !seen.has(keyOf(item))).reverse();\nif (!fresh.length) return {};\nstate.seen = [...state.seen, keyOf(fresh[0])].slice(-2000);\nreturn { item: fresh[0], waiting: fresh.length - 1 };\n"
185
- },
186
- "lineage": {
187
- "parents": [],
188
- "changes": "Packaged original Block source for StillMade."
189
- }
190
- }
191
- };
@@ -1,334 +0,0 @@
1
- // Generated by scripts/build-owned-blocks.mjs. Edit the owned source files.
2
- export default {
3
- "manifest": {
4
- "schemaVersion": 1,
5
- "sdkVersion": "0.1.0",
6
- "id": "sm.pick-photos",
7
- "version": "1.0.0",
8
- "name": "Pick best photos",
9
- "description": "Check every photo with StillMade's vision capability and keep only the best ones: sharp, well lit, clear faces, varied, and true to your note.",
10
- "kind": "task",
11
- "runtime": "javascript",
12
- "entry": "src/run.js",
13
- "license": "MIT",
14
- "provenance": {
15
- "notice": "Original source (authorship declared by the packager)\nLicense: MIT\nChanges: Original implementation declared by the packager; no reused repository or dependency code.\nFiles: LICENSE, src/run.js\n\nMIT License\n\nCopyright (c) 2026 StillMade contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
16
- "portableSources": [
17
- {
18
- "kind": "original",
19
- "license": "MIT",
20
- "paths": [
21
- "LICENSE",
22
- "src/run.js"
23
- ],
24
- "evidence": [
25
- "upstream/0/LICENSE",
26
- "upstream/0/src/run.js"
27
- ],
28
- "changes": "Original implementation declared by the packager; no reused repository or dependency code."
29
- }
30
- ]
31
- },
32
- "inputs": {
33
- "photos": {
34
- "type": "image[]",
35
- "primary": true,
36
- "required": true,
37
- "imageMode": "reference",
38
- "description": "The photos to choose from, up to 100.",
39
- "semantic": "image",
40
- "accepts": [
41
- "source_image"
42
- ]
43
- },
44
- "keep": {
45
- "type": "integer",
46
- "default": 12,
47
- "min": 1,
48
- "max": 50,
49
- "required": false,
50
- "description": "How many photos to keep.",
51
- "semantic": "photo_keep_count"
52
- },
53
- "instruction": {
54
- "type": "text",
55
- "default": "",
56
- "required": false,
57
- "description": "What the photos are for, such as: a memorial tribute for Grandma; prefer clear faces and happy moments.",
58
- "semantic": "photo_selection_instruction"
59
- },
60
- "notes": {
61
- "type": "json",
62
- "required": false,
63
- "description": "One note per photo from the photo check. StillMade fills this in when the Step runs; leave it empty.",
64
- "semantic": "photo_notes",
65
- "schema": [
66
- {
67
- "ok": "boolean?",
68
- "sharp": "number?",
69
- "light": "number?",
70
- "people": "integer?",
71
- "facesClear": "boolean?",
72
- "smiling": "boolean?",
73
- "eyesClosed": "boolean?",
74
- "tags": "string[]?",
75
- "text": "string?"
76
- }
77
- ]
78
- }
79
- },
80
- "outputs": {
81
- "photos": {
82
- "type": "image[]",
83
- "primary": true,
84
- "description": "Only the chosen photos, unchanged, in the order they were taken when dates are known, otherwise best first.",
85
- "semantic": "image"
86
- },
87
- "reasons": {
88
- "type": "text",
89
- "description": "Why each photo was kept.",
90
- "semantic": "plain_text"
91
- }
92
- },
93
- "permissions": {
94
- "project": [],
95
- "network": [],
96
- "filesystem": [],
97
- "secrets": []
98
- },
99
- "ui": [
100
- {
101
- "port": "photos",
102
- "control": "asset"
103
- },
104
- {
105
- "port": "keep",
106
- "control": "number",
107
- "label": "How many to keep"
108
- },
109
- {
110
- "port": "instruction",
111
- "control": "text",
112
- "label": "What they are for"
113
- },
114
- {
115
- "port": "photos",
116
- "control": "gallery"
117
- }
118
- ],
119
- "platforms": {
120
- "phone": {
121
- "supported": true
122
- },
123
- "browser": {
124
- "supported": true
125
- },
126
- "desktop": {
127
- "supported": true
128
- }
129
- }
130
- },
131
- "code": "// Pick best photos: rank the photos from their notes (one per photo, made by\n// Photo notes when the Step runs) and return only the chosen ones, unchanged.\nconst MAX_PHOTOS=100;\nconst photos=Array.isArray(input.photos)?input.photos:[];\nif(!photos.length)throw new Error('Add photos to choose from.');\nif(photos.length>MAX_PHOTOS)throw new Error('Pick best photos checks up to 100 photos at a time. You added '+String(photos.length)+'. Remove some, or split them into groups of 100 or fewer.');\nconst notes=Array.isArray(input.notes)?input.notes:null;\nif(!notes||notes.length!==photos.length)throw new Error('Pick best photos needs its photo check. Run this Step in your project to check the photos.');\nconst keep=Math.max(1,Math.min(50,Math.round(Number(input.keep)||12)));\nconst instruction=typeof input.instruction==='string'?input.instruction.toLowerCase():'';\n\nconst STOP=new Set(['the','and','for','with','that','this','from','into','our','her','his','their','them','who','are','was','were','has','have','had','want','like','prefer','some','more','most','very','only','photos','photo','pictures','picture','images','image','video','please','make','show','use','good','best','nice','tribute','about']);\nconst words=text=>String(text||'').toLowerCase().split(/[^a-z0-9]+/).filter(word=>word.length>=3&&!STOP.has(word));\nconst stem=word=>word.slice(0,5);\nconst wanted=[...new Set(words(instruction).map(stem))];\nconst wantsFaces=/face|people|person|portrait|family|everyone|group/.test(instruction);\nconst wantsHappy=/happy|smil|joy|laugh|fun|cheer/.test(instruction);\nconst wantsSharp=/clear|sharp|focus|quality/.test(instruction);\nconst level=value=>{const number=Number(value);return Number.isFinite(number)?Math.max(0,Math.min(10,number)):5;};\n\nconst notesFor=(note)=>{\n const ok=!!note&&typeof note==='object'&&note.ok!==false;\n const tags=Array.isArray(note&&note.tags)?note.tags.map(tag=>String(tag).toLowerCase()).slice(0,12):[];\n const text=String(note&&note.text||'');\n return {ok,sharp:level(note&&note.sharp),light:level(note&&note.light),people:Math.max(0,Math.min(50,Math.round(Number(note&&note.people)||0))),facesClear:note&&note.facesClear===true,smiling:note&&note.smiling===true,eyesClosed:note&&note.eyesClosed===true,tags,text,signature:new Set([...tags.flatMap(words),...words(text)].map(stem))};\n};\nconst fitOf=note=>{\n if(!wanted.length)return 0;\n let hits=0;for(const word of wanted)if(note.signature.has(word))hits++;\n return hits/wanted.length;\n};\nconst scoreOf=note=>{\n if(!note.ok)return -100;\n const quality=(note.sharp*.6+note.light*.4)/10;\n let score=3*quality+(note.people>0?1:0)+(note.facesClear?1.5:0)+(note.smiling?1:0)-(note.eyesClosed?1.5:0)+3*fitOf(note);\n if(wantsFaces)score+=(note.facesClear?1.5:0)+(note.people>0?1:0);\n if(wantsHappy)score+=note.smiling?2:0;\n if(wantsSharp)score+=2*quality;\n if(note.sharp<=2)score-=2;\n return Math.round(score*1000)/1000;\n};\nconst similarity=(a,b)=>{\n if(!a.signature.size||!b.signature.size)return 0;\n let shared=0;for(const word of a.signature)if(b.signature.has(word))shared++;\n return shared/(a.signature.size+b.signature.size-shared);\n};\nconst dateOf=photo=>{\n for(const key of ['takenAt','capturedAt','createdAt','date']){\n const value=photo&&photo[key];\n const time=typeof value==='number'?value:typeof value==='string'?Date.parse(value):NaN;\n if(Number.isFinite(time))return time;\n }\n return null;\n};\n\n// Exact repeats of one saved version count once.\nconst seen=new Set();\nconst rows=[];\nphotos.forEach((photo,index)=>{\n const key=photo&&photo.assetId&&photo.versionId?photo.assetId+':'+photo.versionId:String(photo&&photo.url||index);\n if(seen.has(key))return;\n seen.add(key);\n const note=notesFor(notes[index]);\n rows.push({photo,index,note,score:scoreOf(note),fit:fitOf(note)});\n});\nconst ranked=rows.filter(row=>row.note.ok).sort((a,b)=>b.score-a.score||a.index-b.index);\nif(!ranked.length)throw new Error('None of these photos could be checked. Try clearer photos, or run the Step again.');\n\n// Near-duplicates (the same scene and people) give way to the best of them,\n// unless there are not enough different photos to fill the count.\nconst NEAR=.7;\nconst chosen=[],skipped=[];\nfor(const row of ranked){\n if(chosen.length>=keep)break;\n const twin=chosen.find(other=>Math.abs(other.note.people-row.note.people)<=1&&similarity(other.note,row.note)>=NEAR);\n if(twin){row.twin=twin;skipped.push(row);}else chosen.push(row);\n}\nfor(const row of skipped){if(chosen.length>=keep)break;chosen.push(row);}\n\nconst dated=chosen.every(row=>dateOf(row.photo)!==null);\nconst ordered=dated?chosen.slice().sort((a,b)=>dateOf(a.photo)-dateOf(b.photo)||a.index-b.index):chosen;\nconst nameOf=row=>row.photo&&typeof row.photo.name==='string'&&row.photo.name.trim()?row.photo.name.trim():'Photo '+String(row.index+1);\nconst why=row=>{\n const parts=[];\n const quality=(row.note.sharp*.6+row.note.light*.4);\n parts.push(quality>=7.5?'sharp and well lit':quality>=5?'clear enough':'the best of a weak set');\n if(row.note.people)parts.push(String(row.note.people)+(row.note.people===1?' person':' people'));\n if(row.note.facesClear)parts.push('clear faces');\n if(row.note.smiling)parts.push('smiling');\n if(row.fit>0)parts.push('fits your note');\n if(row.twin)parts.push('similar to another pick, kept to fill the count');\n return parts.join(', ');\n};\nconst lines=ordered.map((row,at)=>String(at+1)+'. '+nameOf(row)+': '+why(row)+'.');\nconst left=rows.length-chosen.length;\nconst header='Kept '+String(chosen.length)+' of '+String(photos.length)+' photos'+(dated?', in the order they were taken':', best first')+'.'+(left>0?' '+String(left)+' left out'+(skipped.length>chosen.filter(row=>row.twin).length?', some as near-duplicates':'')+'.':'');\nreturn {photos:ordered.map(row=>row.photo),reasons:[header,...lines].join('\\n')};\n",
132
- "tests": [
133
- {
134
- "name": "keeps the sharpest varied photos and drops a near-duplicate",
135
- "input": {
136
- "photos": [
137
- {
138
- "kind": "image",
139
- "assetId": "photo-1",
140
- "versionId": "v1",
141
- "url": "/api/media/photo-1"
142
- },
143
- {
144
- "kind": "image",
145
- "assetId": "photo-2",
146
- "versionId": "v1",
147
- "url": "/api/media/photo-2"
148
- },
149
- {
150
- "kind": "image",
151
- "assetId": "photo-3",
152
- "versionId": "v1",
153
- "url": "/api/media/photo-3"
154
- },
155
- {
156
- "kind": "image",
157
- "assetId": "photo-4",
158
- "versionId": "v1",
159
- "url": "/api/media/photo-4"
160
- }
161
- ],
162
- "keep": 2,
163
- "instruction": "Memorial tribute for Grandma; prefer clear faces",
164
- "notes": [
165
- {
166
- "sharp": 9,
167
- "light": 8,
168
- "people": 2,
169
- "facesClear": true,
170
- "smiling": true,
171
- "eyesClosed": false,
172
- "tags": [
173
- "grandma",
174
- "garden",
175
- "family"
176
- ],
177
- "text": "Two people smiling in a garden."
178
- },
179
- {
180
- "sharp": 2,
181
- "light": 3,
182
- "people": 0,
183
- "facesClear": false,
184
- "smiling": false,
185
- "eyesClosed": false,
186
- "tags": [
187
- "blur"
188
- ],
189
- "text": "A blurred hallway."
190
- },
191
- {
192
- "sharp": 9,
193
- "light": 8,
194
- "people": 2,
195
- "facesClear": true,
196
- "smiling": true,
197
- "eyesClosed": false,
198
- "tags": [
199
- "grandma",
200
- "garden",
201
- "family"
202
- ],
203
- "text": "Two people smiling in a garden."
204
- },
205
- {
206
- "sharp": 8,
207
- "light": 8,
208
- "people": 1,
209
- "facesClear": true,
210
- "smiling": false,
211
- "eyesClosed": false,
212
- "tags": [
213
- "kitchen",
214
- "baking",
215
- "grandma"
216
- ],
217
- "text": "A woman baking in a kitchen."
218
- }
219
- ]
220
- },
221
- "expected": {
222
- "photos": [
223
- {
224
- "kind": "image",
225
- "assetId": "photo-1",
226
- "versionId": "v1",
227
- "url": "/api/media/photo-1"
228
- },
229
- {
230
- "kind": "image",
231
- "assetId": "photo-4",
232
- "versionId": "v1",
233
- "url": "/api/media/photo-4"
234
- }
235
- ],
236
- "reasons": "Kept 2 of 4 photos, best first. 2 left out, some as near-duplicates.\n1. Photo 1: sharp and well lit, 2 people, clear faces, smiling, fits your note.\n2. Photo 4: sharp and well lit, 1 person, clear faces, fits your note."
237
- }
238
- },
239
- {
240
- "name": "orders dated picks by when they were taken",
241
- "input": {
242
- "photos": [
243
- {
244
- "kind": "image",
245
- "assetId": "photo-1",
246
- "versionId": "v1",
247
- "url": "/api/media/photo-1",
248
- "takenAt": "2020-05-01T10:00:00Z"
249
- },
250
- {
251
- "kind": "image",
252
- "assetId": "photo-2",
253
- "versionId": "v1",
254
- "url": "/api/media/photo-2",
255
- "takenAt": "2019-01-01T10:00:00Z"
256
- }
257
- ],
258
- "keep": 2,
259
- "notes": [
260
- {
261
- "sharp": 9,
262
- "light": 9,
263
- "people": 1,
264
- "facesClear": true,
265
- "smiling": true,
266
- "eyesClosed": false,
267
- "tags": [
268
- "park"
269
- ],
270
- "text": "A child in a park."
271
- },
272
- {
273
- "sharp": 6,
274
- "light": 6,
275
- "people": 0,
276
- "facesClear": false,
277
- "smiling": false,
278
- "eyesClosed": false,
279
- "tags": [
280
- "lake"
281
- ],
282
- "text": "A quiet lake."
283
- }
284
- ]
285
- },
286
- "expected": {
287
- "photos": [
288
- {
289
- "kind": "image",
290
- "assetId": "photo-2",
291
- "versionId": "v1",
292
- "url": "/api/media/photo-2",
293
- "takenAt": "2019-01-01T10:00:00Z"
294
- },
295
- {
296
- "kind": "image",
297
- "assetId": "photo-1",
298
- "versionId": "v1",
299
- "url": "/api/media/photo-1",
300
- "takenAt": "2020-05-01T10:00:00Z"
301
- }
302
- ],
303
- "reasons": "Kept 2 of 2 photos, in the order they were taken.\n1. Photo 2: clear enough.\n2. Photo 1: sharp and well lit, 1 person, clear faces, smiling."
304
- }
305
- }
306
- ],
307
- "portable": {
308
- "format": "stillmade-block/1",
309
- "dependencies": [],
310
- "sources": [
311
- {
312
- "kind": "original",
313
- "license": "MIT",
314
- "paths": [
315
- "LICENSE",
316
- "src/run.js"
317
- ],
318
- "evidence": [
319
- "upstream/0/LICENSE",
320
- "upstream/0/src/run.js"
321
- ],
322
- "changes": "Original implementation declared by the packager; no reused repository or dependency code."
323
- }
324
- ],
325
- "files": {
326
- "upstream/0/LICENSE": "MIT License\n\nCopyright (c) 2026 StillMade contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
327
- "upstream/0/src/run.js": "// Pick best photos: rank the photos from their notes (one per photo, made by\n// Photo notes when the Step runs) and return only the chosen ones, unchanged.\nconst MAX_PHOTOS=100;\nconst photos=Array.isArray(input.photos)?input.photos:[];\nif(!photos.length)throw new Error('Add photos to choose from.');\nif(photos.length>MAX_PHOTOS)throw new Error('Pick best photos checks up to 100 photos at a time. You added '+String(photos.length)+'. Remove some, or split them into groups of 100 or fewer.');\nconst notes=Array.isArray(input.notes)?input.notes:null;\nif(!notes||notes.length!==photos.length)throw new Error('Pick best photos needs its photo check. Run this Step in your project to check the photos.');\nconst keep=Math.max(1,Math.min(50,Math.round(Number(input.keep)||12)));\nconst instruction=typeof input.instruction==='string'?input.instruction.toLowerCase():'';\n\nconst STOP=new Set(['the','and','for','with','that','this','from','into','our','her','his','their','them','who','are','was','were','has','have','had','want','like','prefer','some','more','most','very','only','photos','photo','pictures','picture','images','image','video','please','make','show','use','good','best','nice','tribute','about']);\nconst words=text=>String(text||'').toLowerCase().split(/[^a-z0-9]+/).filter(word=>word.length>=3&&!STOP.has(word));\nconst stem=word=>word.slice(0,5);\nconst wanted=[...new Set(words(instruction).map(stem))];\nconst wantsFaces=/face|people|person|portrait|family|everyone|group/.test(instruction);\nconst wantsHappy=/happy|smil|joy|laugh|fun|cheer/.test(instruction);\nconst wantsSharp=/clear|sharp|focus|quality/.test(instruction);\nconst level=value=>{const number=Number(value);return Number.isFinite(number)?Math.max(0,Math.min(10,number)):5;};\n\nconst notesFor=(note)=>{\n const ok=!!note&&typeof note==='object'&&note.ok!==false;\n const tags=Array.isArray(note&&note.tags)?note.tags.map(tag=>String(tag).toLowerCase()).slice(0,12):[];\n const text=String(note&&note.text||'');\n return {ok,sharp:level(note&&note.sharp),light:level(note&&note.light),people:Math.max(0,Math.min(50,Math.round(Number(note&&note.people)||0))),facesClear:note&&note.facesClear===true,smiling:note&&note.smiling===true,eyesClosed:note&&note.eyesClosed===true,tags,text,signature:new Set([...tags.flatMap(words),...words(text)].map(stem))};\n};\nconst fitOf=note=>{\n if(!wanted.length)return 0;\n let hits=0;for(const word of wanted)if(note.signature.has(word))hits++;\n return hits/wanted.length;\n};\nconst scoreOf=note=>{\n if(!note.ok)return -100;\n const quality=(note.sharp*.6+note.light*.4)/10;\n let score=3*quality+(note.people>0?1:0)+(note.facesClear?1.5:0)+(note.smiling?1:0)-(note.eyesClosed?1.5:0)+3*fitOf(note);\n if(wantsFaces)score+=(note.facesClear?1.5:0)+(note.people>0?1:0);\n if(wantsHappy)score+=note.smiling?2:0;\n if(wantsSharp)score+=2*quality;\n if(note.sharp<=2)score-=2;\n return Math.round(score*1000)/1000;\n};\nconst similarity=(a,b)=>{\n if(!a.signature.size||!b.signature.size)return 0;\n let shared=0;for(const word of a.signature)if(b.signature.has(word))shared++;\n return shared/(a.signature.size+b.signature.size-shared);\n};\nconst dateOf=photo=>{\n for(const key of ['takenAt','capturedAt','createdAt','date']){\n const value=photo&&photo[key];\n const time=typeof value==='number'?value:typeof value==='string'?Date.parse(value):NaN;\n if(Number.isFinite(time))return time;\n }\n return null;\n};\n\n// Exact repeats of one saved version count once.\nconst seen=new Set();\nconst rows=[];\nphotos.forEach((photo,index)=>{\n const key=photo&&photo.assetId&&photo.versionId?photo.assetId+':'+photo.versionId:String(photo&&photo.url||index);\n if(seen.has(key))return;\n seen.add(key);\n const note=notesFor(notes[index]);\n rows.push({photo,index,note,score:scoreOf(note),fit:fitOf(note)});\n});\nconst ranked=rows.filter(row=>row.note.ok).sort((a,b)=>b.score-a.score||a.index-b.index);\nif(!ranked.length)throw new Error('None of these photos could be checked. Try clearer photos, or run the Step again.');\n\n// Near-duplicates (the same scene and people) give way to the best of them,\n// unless there are not enough different photos to fill the count.\nconst NEAR=.7;\nconst chosen=[],skipped=[];\nfor(const row of ranked){\n if(chosen.length>=keep)break;\n const twin=chosen.find(other=>Math.abs(other.note.people-row.note.people)<=1&&similarity(other.note,row.note)>=NEAR);\n if(twin){row.twin=twin;skipped.push(row);}else chosen.push(row);\n}\nfor(const row of skipped){if(chosen.length>=keep)break;chosen.push(row);}\n\nconst dated=chosen.every(row=>dateOf(row.photo)!==null);\nconst ordered=dated?chosen.slice().sort((a,b)=>dateOf(a.photo)-dateOf(b.photo)||a.index-b.index):chosen;\nconst nameOf=row=>row.photo&&typeof row.photo.name==='string'&&row.photo.name.trim()?row.photo.name.trim():'Photo '+String(row.index+1);\nconst why=row=>{\n const parts=[];\n const quality=(row.note.sharp*.6+row.note.light*.4);\n parts.push(quality>=7.5?'sharp and well lit':quality>=5?'clear enough':'the best of a weak set');\n if(row.note.people)parts.push(String(row.note.people)+(row.note.people===1?' person':' people'));\n if(row.note.facesClear)parts.push('clear faces');\n if(row.note.smiling)parts.push('smiling');\n if(row.fit>0)parts.push('fits your note');\n if(row.twin)parts.push('similar to another pick, kept to fill the count');\n return parts.join(', ');\n};\nconst lines=ordered.map((row,at)=>String(at+1)+'. '+nameOf(row)+': '+why(row)+'.');\nconst left=rows.length-chosen.length;\nconst header='Kept '+String(chosen.length)+' of '+String(photos.length)+' photos'+(dated?', in the order they were taken':', best first')+'.'+(left>0?' '+String(left)+' left out'+(skipped.length>chosen.filter(row=>row.twin).length?', some as near-duplicates':'')+'.':'');\nreturn {photos:ordered.map(row=>row.photo),reasons:[header,...lines].join('\\n')};\n"
328
- },
329
- "lineage": {
330
- "parents": [],
331
- "changes": "Packaged original Block source for StillMade."
332
- }
333
- }
334
- };