{"schemaVersion":1,"id":"recommended.sm-rough-cut","version":"1.0.0","name":"Rough Cut workflow","description":"An editable production workflow using Rough Cut v2.0.0.","stages":[{"id":"main","blockId":"sm.rough-cut","version":"2.0.0","label":"Rough Cut"}],"connections":[],"packages":[{"manifest":{"schemaVersion":1,"sdkVersion":"0.1.0","id":"sm.rough-cut","version":"2.0.0","name":"Rough Cut","description":"Arrange selected unlocked clips into a continuous reviewable cut while preserving every original media reference.","kind":"task","runtime":"javascript","entry":"src/run.js","license":"MIT","provenance":{"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, src/view.json\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","portableSources":[{"kind":"original","license":"MIT","paths":["LICENSE","src/run.js","src/view.json"],"evidence":["upstream/0/LICENSE","upstream/0/src/run.js","upstream/0/src/view.json"],"changes":"Original implementation declared by the packager; no reused repository or dependency code."}]},"inputs":{"timeline":{"type":"timeline","context":"timeline","primary":true,"description":"The current editable timeline snapshot."},"clipIds":{"type":"text","default":"","description":"Selected clip IDs in desired order, one per line; blank uses every unlocked clip in timeline order."},"startAt":{"type":"number","default":0,"min":0,"max":86400,"description":"Start time for the assembled sequence, in seconds."},"gap":{"type":"number","default":0,"min":0,"max":10,"description":"Space between clips, in seconds."}},"outputs":{"edit":{"type":"timeline-edit","primary":true,"description":"A bounded move-only proposal that StillMade previews before Apply."}},"permissions":{"project":["context.timeline.read","timeline.propose"],"network":[],"filesystem":[],"secrets":[]},"ui":[]},"code":"const clips = (input.timeline.clips || []).slice().sort((left, right) => left.start - right.start || left.id.localeCompare(right.id));\nif (!clips.length || clips.length > 100) throw new Error('Rough Cut needs between 1 and 100 timeline clips.');\nconst requested = input.clipIds.split(/\\r?\\n/).map(value => value.trim()).filter(Boolean);\nif (requested.length > 100 || new Set(requested).size !== requested.length) throw new Error('Choose up to 100 distinct clip IDs.');\nconst ids = requested.length ? requested : clips.filter(clip => {\n  const track = (input.timeline.tracks || []).find(item => item.id === clip.trackId);\n  return !clip.locked && !track?.locked;\n}).map(clip => clip.id);\nif (!ids.length) throw new Error('Select at least one unlocked clip.');\nlet cursor = input.startAt;\nconst commands = ids.map(id => {\n  const matches = clips.filter(clip => clip.id === id);\n  if (matches.length !== 1) throw new Error('A selected clip is unavailable. Refresh the timeline.');\n  const clip = matches[0], track = (input.timeline.tracks || []).find(item => item.id === clip.trackId);\n  if (clip.locked || track?.locked) throw new Error('Unlock selected clips before arranging the rough cut.');\n  if (!Number.isFinite(clip.start) || !Number.isFinite(clip.duration) || clip.start < 0 || clip.duration < .001) throw new Error('A selected clip has invalid timing.');\n  const command = {collection: 'clips', operation: 'move', before: clip, values: {start: cursor}};\n  cursor += clip.duration + input.gap;\n  return command;\n});\nreturn {edit: {schemaVersion: 1, title: 'Arrange rough cut', timelineId: input.timeline.activeTimelineId, commands}};\n","view":{"html":"<main class=\"rough-cut\">\n  <header><h1>Rough Cut</h1><p>Select clips in timeline order, then preview one reversible arrangement.</p></header>\n  <div class=\"timing\">\n    <label for=\"start\">Start at <input id=\"start\" type=\"number\" min=\"0\" max=\"86400\" step=\"0.1\" value=\"0\"></label>\n    <label for=\"gap\">Gap <input id=\"gap\" type=\"number\" min=\"0\" max=\"10\" step=\"0.1\" value=\"0\"></label>\n    <button id=\"all\" type=\"button\">Select all unlocked</button><button id=\"none\" type=\"button\">Clear</button>\n  </div>\n  <section id=\"clips\" class=\"clips\" aria-label=\"Timeline clips\"><p>No clips are available.</p></section>\n  <div class=\"actions\"><button id=\"arrange\" type=\"button\">Preview rough cut</button><output id=\"status\" role=\"status\" aria-live=\"polite\">Waiting for a timeline.</output></div>\n</main>\n","css":".rough-cut { box-sizing: border-box; max-width: 900px; min-height: 100%; margin: 0 auto; padding: 24px; color: var(--fg); background: var(--bg); font-family: var(--font-body); }\n.rough-cut h1 { margin: 0 0 8px; font-family: var(--font-display); font-size: 36px; font-style: italic; font-weight: 200; }\n.rough-cut header p, .rough-cut output { color: var(--fg-muted); }\n.timing, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin: 20px 0; }\n.timing label { display: flex; align-items: center; gap: 8px; }\n.rough-cut input[type=number] { width: 88px; padding: 8px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg-elev-1); color: var(--fg); }\n.rough-cut button { padding: 10px 16px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--bg-elev-1); color: var(--fg); font: inherit; cursor: pointer; }\n.rough-cut button:disabled { opacity: .5; cursor: default; }\n.rough-cut #arrange { background: var(--fg); color: var(--bg); }\n.clips { display: grid; gap: 8px; }\n.clip { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 12px 14px; border: 1px solid var(--border-tok); border-radius: 10px; background: var(--bg-elev-1); }\n.clip small { color: var(--fg-subtle); }\n.rough-cut button:focus-visible, .rough-cut input:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }\n@media (max-width: 640px) { .rough-cut { padding: 16px; } .timing { align-items: flex-start; flex-direction: column; } }\n","javascript":"const start = document.getElementById('start');\nconst gap = document.getElementById('gap');\nconst all = document.getElementById('all');\nconst none = document.getElementById('none');\nconst arrange = document.getElementById('arrange');\nconst status = document.getElementById('status');\nlet current = {};\nlet clips = [];\nlet selected = [];\nlet busy = false;\nlet revision = 0;\nconst draw = () => {\n  StillMade.render('clips', clips.length ? clips.map((clip, index) => ({tag: 'label', className: 'clip', children: [\n    {tag: 'input', id: 'clip-' + index, type: 'checkbox', action: 'clip:' + index, checked: selected.includes(clip.id), disabled: busy || clip.locked, label: clip.name || clip.id},\n    {tag: 'span', text: clip.name || clip.id},\n    {tag: 'small', text: clip.locked ? 'Locked' : String(clip.duration) + 's'}\n  ]})) : [{tag: 'p', text: 'No clips are available.'}]);\n  const unlocked = clips.filter(clip => !clip.locked);\n  all.disabled = busy || !unlocked.length;\n  none.disabled = busy || !selected.length;\n  arrange.disabled = busy || !selected.length;\n  status.textContent = selected.length ? String(selected.length) + ' selected in timeline order.' : clips.length ? 'Select clips to arrange.' : 'Waiting for a timeline.';\n};\nStillMade.onInput(input => {\n  current = input;\n  revision += 1;\n  start.value = String(input.startAt ?? 0);\n  gap.value = String(input.gap ?? 0);\n  clips = (input.timeline?.clips || []).slice(0, 100).map(clip => ({id: clip.id, name: clip.name, duration: clip.duration, locked: !!clip.locked || (input.timeline?.tracks || []).some(track => track.id === clip.trackId && !!track.locked)}));\n  selected = (input.clipIds || '').split(/\\r?\\n/).map(value => value.trim()).filter(id => clips.some(clip => clip.id === id && !clip.locked));\n  if (!selected.length) selected = clips.filter(clip => !clip.locked).map(clip => clip.id);\n  draw();\n});\nStillMade.onAction(event => {\n  if (busy || !event.action.startsWith('clip:')) return;\n  const clip = clips.find((item, index) => index === Number(event.action.slice(5)));\n  if (!clip || clip.locked) return;\n  selected = event.checked ? [...selected.filter(id => id !== clip.id), clip.id] : selected.filter(id => id !== clip.id);\n  draw();\n});\nall.addEventListener('click', () => { if (!busy) { selected = clips.filter(clip => !clip.locked).map(clip => clip.id); draw(); } });\nnone.addEventListener('click', () => { if (!busy) { selected = []; draw(); } });\narrange.addEventListener('click', async () => {\n  if (busy || !selected.length) return;\n  const startAt = Number(start.value), spacing = Number(gap.value);\n  if (!Number.isFinite(startAt) || startAt < 0 || startAt > 86400 || !Number.isFinite(spacing) || spacing < 0 || spacing > 10) { status.textContent = 'Use a valid start time and a gap from 0 to 10 seconds.'; return; }\n  const started = revision;\n  busy = true;\n  draw();\n  let message;\n  try { await StillMade.run({timeline: current.timeline, clipIds: selected.join('\\n'), startAt, gap: spacing}); message = 'Rough cut ready. Review the proposed clip moves, then Apply.'; }\n  catch (error) { message = error.message || 'The rough cut could not be prepared.'; }\n  finally { busy = false; draw(); if (started === revision) status.textContent = message; }\n});\n"},"tests":[{"name":"Close gaps in timeline order","input":{"timeline":{"schemaVersion":1,"activeTimelineId":"timeline-1","tracks":[{"id":"video"}],"clips":[{"id":"b","name":"Second","trackId":"video","start":8,"duration":2,"kind":"video","url":"https://media.example/b.mp4"},{"id":"a","name":"First","trackId":"video","start":2,"duration":3,"kind":"video","url":"https://media.example/a.mp4"}]},"clipIds":"","startAt":0,"gap":0},"expected":{"edit":{"schemaVersion":1,"title":"Arrange rough cut","timelineId":"timeline-1","commands":[{"collection":"clips","operation":"move","before":{"id":"a","name":"First","trackId":"video","start":2,"duration":3,"kind":"video","url":"https://media.example/a.mp4"},"values":{"start":0}},{"collection":"clips","operation":"move","before":{"id":"b","name":"Second","trackId":"video","start":8,"duration":2,"kind":"video","url":"https://media.example/b.mp4"},"values":{"start":3}}]}}},{"name":"Use an explicit subset with spacing","input":{"timeline":{"schemaVersion":1,"activeTimelineId":"timeline-2","tracks":[{"id":"video"}],"clips":[{"id":"a","trackId":"video","start":0,"duration":4},{"id":"b","trackId":"video","start":4,"duration":2}]},"clipIds":"b","startAt":5,"gap":0.5},"expected":{"edit":{"schemaVersion":1,"title":"Arrange rough cut","timelineId":"timeline-2","commands":[{"collection":"clips","operation":"move","before":{"id":"b","trackId":"video","start":4,"duration":2},"values":{"start":5}}]}}}],"portable":{"format":"stillmade-block/1","dependencies":[],"sources":[{"kind":"original","license":"MIT","paths":["LICENSE","src/run.js","src/view.json"],"evidence":["upstream/0/LICENSE","upstream/0/src/run.js","upstream/0/src/view.json"],"changes":"Original implementation declared by the packager; no reused repository or dependency code."}],"files":{"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","upstream/0/src/run.js":"const clips = (input.timeline.clips || []).slice().sort((left, right) => left.start - right.start || left.id.localeCompare(right.id));\nif (!clips.length || clips.length > 100) throw new Error('Rough Cut needs between 1 and 100 timeline clips.');\nconst requested = input.clipIds.split(/\\r?\\n/).map(value => value.trim()).filter(Boolean);\nif (requested.length > 100 || new Set(requested).size !== requested.length) throw new Error('Choose up to 100 distinct clip IDs.');\nconst ids = requested.length ? requested : clips.filter(clip => {\n  const track = (input.timeline.tracks || []).find(item => item.id === clip.trackId);\n  return !clip.locked && !track?.locked;\n}).map(clip => clip.id);\nif (!ids.length) throw new Error('Select at least one unlocked clip.');\nlet cursor = input.startAt;\nconst commands = ids.map(id => {\n  const matches = clips.filter(clip => clip.id === id);\n  if (matches.length !== 1) throw new Error('A selected clip is unavailable. Refresh the timeline.');\n  const clip = matches[0], track = (input.timeline.tracks || []).find(item => item.id === clip.trackId);\n  if (clip.locked || track?.locked) throw new Error('Unlock selected clips before arranging the rough cut.');\n  if (!Number.isFinite(clip.start) || !Number.isFinite(clip.duration) || clip.start < 0 || clip.duration < .001) throw new Error('A selected clip has invalid timing.');\n  const command = {collection: 'clips', operation: 'move', before: clip, values: {start: cursor}};\n  cursor += clip.duration + input.gap;\n  return command;\n});\nreturn {edit: {schemaVersion: 1, title: 'Arrange rough cut', timelineId: input.timeline.activeTimelineId, commands}};\n","upstream/0/src/view.json":"{\n  \"html\": \"<main class=\\\"rough-cut\\\">\\n  <header><h1>Rough Cut</h1><p>Select clips in timeline order, then preview one reversible arrangement.</p></header>\\n  <div class=\\\"timing\\\">\\n    <label for=\\\"start\\\">Start at <input id=\\\"start\\\" type=\\\"number\\\" min=\\\"0\\\" max=\\\"86400\\\" step=\\\"0.1\\\" value=\\\"0\\\"></label>\\n    <label for=\\\"gap\\\">Gap <input id=\\\"gap\\\" type=\\\"number\\\" min=\\\"0\\\" max=\\\"10\\\" step=\\\"0.1\\\" value=\\\"0\\\"></label>\\n    <button id=\\\"all\\\" type=\\\"button\\\">Select all unlocked</button><button id=\\\"none\\\" type=\\\"button\\\">Clear</button>\\n  </div>\\n  <section id=\\\"clips\\\" class=\\\"clips\\\" aria-label=\\\"Timeline clips\\\"><p>No clips are available.</p></section>\\n  <div class=\\\"actions\\\"><button id=\\\"arrange\\\" type=\\\"button\\\">Preview rough cut</button><output id=\\\"status\\\" role=\\\"status\\\" aria-live=\\\"polite\\\">Waiting for a timeline.</output></div>\\n</main>\\n\",\n  \"css\": \".rough-cut { box-sizing: border-box; max-width: 900px; min-height: 100%; margin: 0 auto; padding: 24px; color: var(--fg); background: var(--bg); font-family: var(--font-body); }\\n.rough-cut h1 { margin: 0 0 8px; font-family: var(--font-display); font-size: 36px; font-style: italic; font-weight: 200; }\\n.rough-cut header p, .rough-cut output { color: var(--fg-muted); }\\n.timing, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin: 20px 0; }\\n.timing label { display: flex; align-items: center; gap: 8px; }\\n.rough-cut input[type=number] { width: 88px; padding: 8px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg-elev-1); color: var(--fg); }\\n.rough-cut button { padding: 10px 16px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--bg-elev-1); color: var(--fg); font: inherit; cursor: pointer; }\\n.rough-cut button:disabled { opacity: .5; cursor: default; }\\n.rough-cut #arrange { background: var(--fg); color: var(--bg); }\\n.clips { display: grid; gap: 8px; }\\n.clip { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 12px 14px; border: 1px solid var(--border-tok); border-radius: 10px; background: var(--bg-elev-1); }\\n.clip small { color: var(--fg-subtle); }\\n.rough-cut button:focus-visible, .rough-cut input:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }\\n@media (max-width: 640px) { .rough-cut { padding: 16px; } .timing { align-items: flex-start; flex-direction: column; } }\\n\",\n  \"javascript\": \"const start = document.getElementById('start');\\nconst gap = document.getElementById('gap');\\nconst all = document.getElementById('all');\\nconst none = document.getElementById('none');\\nconst arrange = document.getElementById('arrange');\\nconst status = document.getElementById('status');\\nlet current = {};\\nlet clips = [];\\nlet selected = [];\\nlet busy = false;\\nlet revision = 0;\\nconst draw = () => {\\n  StillMade.render('clips', clips.length ? clips.map((clip, index) => ({tag: 'label', className: 'clip', children: [\\n    {tag: 'input', id: 'clip-' + index, type: 'checkbox', action: 'clip:' + index, checked: selected.includes(clip.id), disabled: busy || clip.locked, label: clip.name || clip.id},\\n    {tag: 'span', text: clip.name || clip.id},\\n    {tag: 'small', text: clip.locked ? 'Locked' : String(clip.duration) + 's'}\\n  ]})) : [{tag: 'p', text: 'No clips are available.'}]);\\n  const unlocked = clips.filter(clip => !clip.locked);\\n  all.disabled = busy || !unlocked.length;\\n  none.disabled = busy || !selected.length;\\n  arrange.disabled = busy || !selected.length;\\n  status.textContent = selected.length ? String(selected.length) + ' selected in timeline order.' : clips.length ? 'Select clips to arrange.' : 'Waiting for a timeline.';\\n};\\nStillMade.onInput(input => {\\n  current = input;\\n  revision += 1;\\n  start.value = String(input.startAt ?? 0);\\n  gap.value = String(input.gap ?? 0);\\n  clips = (input.timeline?.clips || []).slice(0, 100).map(clip => ({id: clip.id, name: clip.name, duration: clip.duration, locked: !!clip.locked || (input.timeline?.tracks || []).some(track => track.id === clip.trackId && !!track.locked)}));\\n  selected = (input.clipIds || '').split(/\\\\r?\\\\n/).map(value => value.trim()).filter(id => clips.some(clip => clip.id === id && !clip.locked));\\n  if (!selected.length) selected = clips.filter(clip => !clip.locked).map(clip => clip.id);\\n  draw();\\n});\\nStillMade.onAction(event => {\\n  if (busy || !event.action.startsWith('clip:')) return;\\n  const clip = clips.find((item, index) => index === Number(event.action.slice(5)));\\n  if (!clip || clip.locked) return;\\n  selected = event.checked ? [...selected.filter(id => id !== clip.id), clip.id] : selected.filter(id => id !== clip.id);\\n  draw();\\n});\\nall.addEventListener('click', () => { if (!busy) { selected = clips.filter(clip => !clip.locked).map(clip => clip.id); draw(); } });\\nnone.addEventListener('click', () => { if (!busy) { selected = []; draw(); } });\\narrange.addEventListener('click', async () => {\\n  if (busy || !selected.length) return;\\n  const startAt = Number(start.value), spacing = Number(gap.value);\\n  if (!Number.isFinite(startAt) || startAt < 0 || startAt > 86400 || !Number.isFinite(spacing) || spacing < 0 || spacing > 10) { status.textContent = 'Use a valid start time and a gap from 0 to 10 seconds.'; return; }\\n  const started = revision;\\n  busy = true;\\n  draw();\\n  let message;\\n  try { await StillMade.run({timeline: current.timeline, clipIds: selected.join('\\\\n'), startAt, gap: spacing}); message = 'Rough cut ready. Review the proposed clip moves, then Apply.'; }\\n  catch (error) { message = error.message || 'The rough cut could not be prepared.'; }\\n  finally { busy = false; draw(); if (started === revision) status.textContent = message; }\\n});\\n\"\n}"},"lineage":{"parents":[],"changes":"Packaged original Block source for StillMade."}}}],"license":"MIT"}