@aicopycoders/exodus 2026.11.1200-beta.13 → 2026.11.1200-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1654,8 +1654,9 @@ under it:
1654
1654
  made again with `retry-clip`, or kept as it is with `exodus video keep
1655
1655
  <runId> --scene <n>` or on the video's page (the link it prints). Keeping
1656
1656
  the last one starts the cut.
1657
- A One-take take held for its words, or for a product label that came out
1658
- backwards and could not be fixed, is named under `Held:` with its own
1657
+ A One-take take held for its words, for a picture that came out turned on
1658
+ its side or upside down, or for a product label that came out backwards and
1659
+ could not be fixed, is named under `Held:` with its own
1659
1660
  sentence, every reason it was held for (`stop.heldTakes` in `--json`). It
1660
1661
  cannot be made again on its own, so no `retry-clip` is offered. Show the user the sentence
1661
1662
  and ask them to watch the take. With their yes, `exodus video keep <runId>
@@ -630,12 +630,21 @@ function spokenWords(word) {
630
630
  return spokenForms(word).flatMap((t) => SPOKEN_FORMS.get(t) ?? [t]).map((t) => SAME_WORD_SPELLINGS.get(t) ?? t);
631
631
  }
632
632
 
633
+ /**
634
+ * COP-311: a scribe writes two words it heard as one with a slash ("probiotic/an" for "probiotic and"): the
635
+ * aligners read them as the words they are, as scout scribe.ts slashParts. A number ("1/2", "24/7") stays whole.
636
+ */
637
+ function slashParts(word) {
638
+ const parts = String(word ?? "").split("/").filter(Boolean);
639
+ return parts.length > 1 && parts.every((p) => /\p{L}/u.test(p)) ? parts : [word];
640
+ }
641
+
633
642
  /** { tokens, sourceIndex }: tokens[i] came from written word sourceIndex[i]. */
634
- function spokenTokens(words) {
643
+ function spokenTokens(words, partsOf = (word) => [word]) {
635
644
  const tokens = [];
636
645
  const sourceIndex = [];
637
646
  words.forEach((word, i) => {
638
- for (const token of spokenWords(word)) {
647
+ for (const token of partsOf(word).flatMap(spokenWords)) {
639
648
  tokens.push(token);
640
649
  sourceIndex.push(i);
641
650
  }
@@ -726,6 +735,24 @@ const soundKey = (token) =>
726
735
  .replace(/(?<=\w{3})oe$/, "o")
727
736
  .replace(/(?<=[aeiou])z$/, "s");
728
737
 
738
+ /**
739
+ * The script's and the heard words' tokens as the aligner compares them, and
740
+ * its word match: matches(e, h) when script token e is said by heard token h.
741
+ * `slash`: both sides read a word written with a slash as its words (COP-311).
742
+ */
743
+ function scriptTokens(words, written, slash = true) {
744
+ const partsOf = slash ? slashParts : undefined;
745
+ const scripted = spokenTokens(written, partsOf);
746
+ const heardWords = spokenTokens(words.map((w) => w.w), partsOf);
747
+ const nameLike = nameLikeWords(written);
748
+ const names = scripted.tokens.filter((_, t) => nameLike[scripted.sourceIndex[t]]);
749
+ const heard = joinSplitWords(heardWords, scripted.tokens, names);
750
+ const expected = joinSplitWords(scripted, heard.tokens);
751
+ const matches = (e, h) =>
752
+ h < heard.tokens.length && sameWord(expected.tokens[e], heard.tokens[h], nameLike[expected.sourceIndex[e]]);
753
+ return { heardWords, heard, expected, matches };
754
+ }
755
+
729
756
  /**
730
757
  * Where the script's first complete, in-order delivery sits in the heard
731
758
  * words, or null. heardTokenOf/heardWordOf give the heard token and word that
@@ -735,15 +762,13 @@ const soundKey = (token) =>
735
762
  * exact delivery wins. Mirrors scout scribe.ts alignScript.
736
763
  */
737
764
  function alignScript(words, written) {
738
- const scripted = spokenTokens(written);
739
- const heardWords = spokenTokens(words.map((w) => w.w));
740
- const nameLike = nameLikeWords(written);
741
- const names = scripted.tokens.filter((_, t) => nameLike[scripted.sourceIndex[t]]);
742
- const heard = joinSplitWords(heardWords, scripted.tokens, names);
743
- const expected = joinSplitWords(scripted, heard.tokens);
765
+ // COP-311: read with the slash words split, else as written, so a take found before ("salt and/or pepper"
766
+ // said "salt and pepper") is still found. Mirrors scout scribe.ts alignScript.
767
+ return alignTokens(scriptTokens(words, written, true)) ?? alignTokens(scriptTokens(words, written, false));
768
+ }
769
+
770
+ function alignTokens({ heardWords, heard, expected, matches }) {
744
771
  if (expected.tokens.length === 0 || heard.tokens.length === 0) return null;
745
- const matches = (e, h) =>
746
- h < heard.tokens.length && sameWord(expected.tokens[e], heard.tokens[h], nameLike[expected.sourceIndex[e]]);
747
772
  const pair = (allowMisheard) => {
748
773
  const tokenOf = [];
749
774
  let j = 0;
@@ -766,6 +791,90 @@ function alignScript(words, written) {
766
791
  };
767
792
  }
768
793
 
794
+ /** scriptTimes: sounds a speaker makes between words; one never stands in the place of a script word. */
795
+ const FILLER_TOKENS = new Set(["um", "umm", "uhm", "uh", "uhh", "er", "erm", "ah", "hmm", "mm", "mhm"]);
796
+ /** scriptTimes: a take with fewer of its script's tokens heard as written than this share is not the script misheard. */
797
+ const MIN_HEARD_SHARE = 0.5;
798
+
799
+ /**
800
+ * COP-311, Mario's "Fix the text, never the times", for a take where
801
+ * alignScript finds no delivery of the whole script in order: the script's
802
+ * tokens and the heard ones are paired by their longest common run, with the
803
+ * aligner's word match. The script tokens left between two pairs take the
804
+ * time of the heard words left in their place, a filler ("um") never one of
805
+ * them: one heard token each when the counts are the same, else, with one
806
+ * heard token more (a word heard as two), the span of them shared evenly by
807
+ * the script words there. Before the first pair or after the last, only one
808
+ * heard token each: a lead-in ("Okay so") or a sign-off ("Thanks guys") is
809
+ * not told apart from a misheard first or last word, so neither is shown.
810
+ * Every other place times nothing: a script word dropped, or said over words
811
+ * the script does not have, is not shown, and a heard word with no script
812
+ * word in its place times nothing. A take with fewer than MIN_HEARD_SHARE of
813
+ * its script tokens heard as written says something else: only those are
814
+ * timed. A script word with a digit ("$23.08", "30%") is timed only where
815
+ * its number words are heard as written ("dollars" may be heard as "oh"),
816
+ * so a number said otherwise is never shown. `times[e]` is script token e's [start, end] on the heard words'
817
+ * clock, or null.
818
+ */
819
+ function scriptTimes(words, written) {
820
+ const { heard, expected, matches } = scriptTokens(words, written);
821
+ const n = expected.tokens.length;
822
+ const m = heard.tokens.length;
823
+ // run[e * (m + 1) + h]: the longest common run of script tokens e.. and heard tokens h..
824
+ const run = new Int32Array((n + 1) * (m + 1));
825
+ const at = (e, h) => run[e * (m + 1) + h];
826
+ for (let e = n - 1; e >= 0; e--) {
827
+ for (let h = m - 1; h >= 0; h--) {
828
+ run[e * (m + 1) + h] = matches(e, h) ? at(e + 1, h + 1) + 1 : Math.max(at(e + 1, h), at(e, h + 1));
829
+ }
830
+ }
831
+ // Each script token on its earliest heard token that keeps the run longest.
832
+ const pairs = [[-1, -1]];
833
+ for (let e = 0, h = 0; e < n && h < m; ) {
834
+ if (matches(e, h)) pairs.push([e++, h++]);
835
+ else if (at(e, h + 1) >= at(e + 1, h)) h++;
836
+ else e++;
837
+ }
838
+ pairs.push([n, m]);
839
+ const span = (from, to) => [words[heard.sourceIndex[from]].s, words[heard.lastSourceIndex[to]].e];
840
+ const times = new Array(n).fill(null);
841
+ const scriptHeard = pairs.length - 2 >= n * MIN_HEARD_SHARE;
842
+ for (let k = 0; k + 1 < pairs.length; k++) {
843
+ const [e0, h0] = pairs[k];
844
+ const [e1, h1] = pairs[k + 1];
845
+ if (e0 >= 0) times[e0] = span(h0, h0);
846
+ const left = e1 - e0 - 1;
847
+ if (!scriptHeard || left === 0) continue;
848
+ const places = [];
849
+ for (let h = h0 + 1; h < h1; h++) if (!FILLER_TOKENS.has(heard.tokens[h])) places.push(h);
850
+ // At an end, a heard word more is a lead-in or a sign-off as likely as a word heard as two.
851
+ if ((e0 < 0 || e1 === n) && places.length !== left) continue;
852
+ if (places.length === left) {
853
+ for (let i = 0; i < left; i++) times[e0 + 1 + i] = span(places[i], places[i]);
854
+ } else if (places.length === left + 1) {
855
+ const [gapStart, gapEnd] = span(places[0], places.at(-1));
856
+ const owners = [...new Set(expected.sourceIndex.slice(e0 + 1, e1))];
857
+ const share = (gapEnd - gapStart) / owners.length;
858
+ for (let t = e0 + 1; t < e1; t++) {
859
+ const u = owners.indexOf(expected.sourceIndex[t]);
860
+ times[t] = [gapStart + u * share, gapStart + (u + 1) * share];
861
+ }
862
+ }
863
+ }
864
+ // A number token of a script word with a digit not heard as written: that word is not shown.
865
+ const paired = new Set(pairs.slice(1, -1).map(([e]) => e));
866
+ const numberToken = (token) => NUMBER_WORDS.has(token) || /\p{N}/u.test(token);
867
+ const unheardNumbers = new Set();
868
+ for (let e = 0; e < n; e++) {
869
+ if (paired.has(e) || !numberToken(expected.tokens[e])) continue;
870
+ for (let i = expected.sourceIndex[e]; i <= expected.lastSourceIndex[e]; i++) if (/\p{N}/u.test(written[i])) unheardNumbers.add(i);
871
+ }
872
+ for (let e = 0; e < n; e++) {
873
+ for (let i = expected.sourceIndex[e]; i <= expected.lastSourceIndex[e]; i++) if (unheardNumbers.has(i)) times[e] = null;
874
+ }
875
+ return { expected, times };
876
+ }
877
+
769
878
  /**
770
879
  * #2541: the indexes of the heard words that deliver the first and last
771
880
  * scripted word, matching the script in order at its earliest delivery, or null
@@ -4611,14 +4720,14 @@ export function lineCaptionScreens(words, cap = null) {
4611
4720
 
4612
4721
  /**
4613
4722
  * captionsByLine: the cut's words in its own time, each with the script line
4614
- * it belongs to. Where a segment's script is heard in order (alignScript),
4615
- * they are the script's words as written, each timed by the heard words that
4616
- * say it; elsewhere they are the heard words, each on the line its place among
4617
- * the script's words gives it, the way a cue line is found (lineInSegment).
4723
+ * it belongs to. They are the script's words as written, never a heard word
4724
+ * the script does not have (COP-311). Where a segment's script is heard in
4725
+ * order (alignScript), each is timed by the heard words that say it;
4726
+ * elsewhere by the heard words in its place (scriptTimes), and a script word
4727
+ * with nothing heard in its place is left out.
4618
4728
  */
4619
4729
  export function lineWords(timeline, storyboard) {
4620
4730
  const texts = new Map((storyboard?.script ?? []).map((line) => [line?.lineId, line?.text]));
4621
- const counts = lineWordCounts(storyboard);
4622
4731
  const rows = [];
4623
4732
  for (const seg of timeline.spine) {
4624
4733
  const heard = seg.words ?? [];
@@ -4638,19 +4747,48 @@ export function lineWords(timeline, storyboard) {
4638
4747
  });
4639
4748
  continue;
4640
4749
  }
4641
- const ends = [];
4642
- let n = 0;
4643
- for (const id of seg.lineIds) ends.push((n += counts.get(id) ?? 0));
4644
- heard.forEach((w, i) => {
4645
- const text = (w.w ?? "").trim();
4646
- const start = at(w.s);
4647
- const end = at(w.e);
4648
- if (!text || end <= start) return;
4649
- const j = ends.findIndex((last) => Math.min(i, n - 1) < last);
4650
- rows.push({ text, start, end, line: seg.lineIds[j] ?? seg.lineIds.at(-1) ?? `scene ${seg.sceneIndex}` });
4750
+ // COP-311: the script's words still, each on the time of what was heard in its place (scriptTimes).
4751
+ const lineOf = lines.flatMap((ws, j) => ws.map(() => seg.lineIds[j]));
4752
+ const { expected, times } = scriptTimes(heard, lines.flat());
4753
+ lines.flat().forEach((text, i) => {
4754
+ const said = times.filter((time, e) => time && expected.sourceIndex[e] <= i && i <= expected.lastSourceIndex[e]);
4755
+ if (said.length === 0) return;
4756
+ const start = at(said[0][0]);
4757
+ const end = at(said.at(-1)[1]);
4758
+ if (end > start) rows.push({ text, start, end, line: lineOf[i] });
4651
4759
  });
4652
4760
  }
4653
- return rows;
4761
+ return sharedHeardWords(rows);
4762
+ }
4763
+
4764
+ /**
4765
+ * lineWords: script words that start on one heard word but are not timed
4766
+ * alike ("probiotics/and" ending one line and starting the next) take that
4767
+ * word's time (to the earliest of their ends) in turn, so no caption screen
4768
+ * is cleared before its word is said. A word that runs on past it keeps its
4769
+ * own end. Words timed alike on one line stay on one screen
4770
+ * (lineCaptionScreens).
4771
+ */
4772
+ function sharedHeardWords(rows) {
4773
+ const out = [];
4774
+ for (let i = 0; i < rows.length; ) {
4775
+ let j = i + 1;
4776
+ while (j < rows.length && rows[j].start === rows[i].start) j++;
4777
+ const run = rows.slice(i, j);
4778
+ const keys = [...new Set(run.map((r) => `${r.line}|${r.end}`))];
4779
+ if (keys.length === 1) out.push(...run);
4780
+ else {
4781
+ const start = run[0].start;
4782
+ const shared = Math.min(...run.map((r) => r.end));
4783
+ const slot = (shared - start) / keys.length;
4784
+ for (const r of run) {
4785
+ const u = keys.indexOf(`${r.line}|${r.end}`);
4786
+ out.push({ ...r, start: roundMs(start + u * slot), end: r.end > shared ? r.end : roundMs(start + (u + 1) * slot) });
4787
+ }
4788
+ }
4789
+ i = j;
4790
+ }
4791
+ return out;
4654
4792
  }
4655
4793
 
4656
4794
  /**
@@ -5,4 +5,5 @@ export const ONE_TAKE_HOLD_CODES = [
5
5
  "one-take-words-unchecked",
6
6
  "one-take-label-held",
7
7
  "one-take-said-wrong",
8
+ "one-take-sideways",
8
9
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aicopycoders/exodus",
3
- "version": "2026.11.1200-beta.13",
3
+ "version": "2026.11.1200-beta.14",
4
4
  "description": "CLI + Claude Code skills for the Copycoders Exodus ad pipeline",
5
5
  "repository": {
6
6
  "type": "git",