ossclip 0.1.10 → 0.1.12

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.
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>ossclip editor</title>
7
- <script type="module" crossorigin src="/assets/index-Bo0WME7k.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-BBVLCP-N.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-C8IPo60X.css">
9
9
  </head>
10
10
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ossclip",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Local-first CLI video producer: cuts silence and fillers, word-timed captions, face-aware framing, and LLM-planned code-rendered graphics — transcription and rendering never leave your machine",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -36,9 +36,9 @@
36
36
  "commander": "^12.1.0",
37
37
  "tsx": "^4.19.0",
38
38
  "zod": "^3.25.76",
39
- "@ossclip/core": "0.1.10",
40
- "@ossclip/renderer": "0.1.10",
41
- "@ossclip/scenes": "0.1.10"
39
+ "@ossclip/core": "0.1.12",
40
+ "@ossclip/renderer": "0.1.12",
41
+ "@ossclip/scenes": "0.1.12"
42
42
  },
43
43
  "homepage": "https://github.com/AhsanAyaz/ossclip#readme",
44
44
  "bugs": {
package/src/edit.ts CHANGED
@@ -390,11 +390,22 @@ export async function startEditServer(
390
390
  );
391
391
  if (!parsed.success) return send(500, { error: `command.json is not valid: ${parsed.error.message}` });
392
392
  const cmd = parsed.data;
393
+ // §129: heal legacy records at replay. Before the fix, wizard and
394
+ // bare-path runs recorded process.argv — the ORIGINAL invocation,
395
+ // missing the `produce` literal the re-entered parse actually ran —
396
+ // so replaying them verbatim dies at commander's front door with
397
+ // "error: unknown option '--llm'". produce is the ONLY command that
398
+ // ever writes command.json, so an args array not starting with
399
+ // "produce" can only be that bug: prepend the literal to
400
+ // reconstruct the command that ran. A modern record — and a legacy
401
+ // directly-typed `ossclip produce …` — already starts with it and
402
+ // is untouched.
403
+ const args = cmd.args[0] === "produce" ? cmd.args : ["produce", ...cmd.args];
393
404
  renderLines = [];
394
405
  renderExit = null;
395
406
  renderStartedAt = Date.now();
396
407
  renderCancelled = false;
397
- const child = spawn(cmd.execPath, [...cmd.execArgv, cmd.script, ...cmd.args], {
408
+ const child = spawn(cmd.execPath, [...cmd.execArgv, cmd.script, ...args], {
398
409
  cwd: cmd.cwd,
399
410
  stdio: ["ignore", "pipe", "pipe"],
400
411
  });
@@ -11,9 +11,14 @@ export interface ProduceExtras {
11
11
  sourceFit?: "cover" | "contain";
12
12
  speaker?: string;
13
13
  whisperModel?: string;
14
+ whisperLanguage?: string;
14
15
  blooperMarker?: string;
15
16
  collapseRetakes?: boolean;
16
17
  sourceIsEdited?: boolean;
18
+ /** Opt-in "made with ossclip" credit. The wizard only ever turns it ON —
19
+ * off is the default, and a config-on user who wants it off for one run
20
+ * types `--no-watermark`, a flags-only surface like --sort. */
21
+ watermark?: boolean;
17
22
  llm?: "claude" | "claude-cli" | "gemini" | "mock";
18
23
  }
19
24
 
@@ -50,9 +55,13 @@ export function produceArgv(a: ProduceAnswers): string[] {
50
55
  if (e.sourceFit === "contain") argv.push("--source-fit", "contain");
51
56
  if (e.speaker) argv.push("--speaker", e.speaker);
52
57
  if (e.whisperModel) argv.push("--whisper-model", e.whisperModel);
58
+ // Empty answer means "whisper's default (en)" — the elision rule above:
59
+ // no flag whose value equals the default.
60
+ if (e.whisperLanguage) argv.push("--whisper-language", e.whisperLanguage);
53
61
  if (e.blooperMarker) argv.push("--blooper-marker", e.blooperMarker);
54
62
  if (e.collapseRetakes === true) argv.push("--collapse-retakes");
55
63
  if (e.sourceIsEdited === true) argv.push("--source-is-edited");
64
+ if (e.watermark === true) argv.push("--watermark");
56
65
  if (e.llm) argv.push("--llm", e.llm);
57
66
 
58
67
  return argv;
@@ -1,15 +1,16 @@
1
1
  import { basename } from "node:path";
2
- import { existsSync, statSync } from "node:fs";
2
+ import { existsSync, readdirSync, statSync } from "node:fs";
3
3
  import { produceArgv, type ProduceAnswers, type ProduceExtras } from "./produce-argv";
4
4
  import { assertInteractive, confirm, intro, multiselect, select, text, unwrap } from "./prompts";
5
5
 
6
6
  /**
7
- * The produce wizard. Thirty flags (plus the positional input path) sorted
8
- * into three tiers: six prompts asked directly — the input path, plus five
9
- * flags (--out, --cleanup, --aspect, --produce, --intent) — eight behind one
10
- * "anything else?" multiselect, and the remaining seventeen stay flags-only:
11
- * debug/internal surfaces, replay-only fields, or (final-review fix wave,
12
- * Finding 1) --sort. A folder's clip order only means anything once the
7
+ * The produce wizard. Thirty-two flags (plus the positional input path)
8
+ * sorted into three tiers: six prompts asked directly — the input path, plus
9
+ * five flags (--out, --cleanup, --aspect, --produce, --intent) — nine behind
10
+ * one "anything else?" multiselect, and the remaining stay flags-only:
11
+ * debug/internal surfaces, replay-only fields, --no-watermark (the
12
+ * multiselect only turns the credit ON; off is already the default), or
13
+ * (final-review fix wave, Finding 1) --sort. A folder's clip order only means anything once the
13
14
  * folder has been enumerated, and that enumeration happens inside
14
15
  * `produce()` — after the wizard has already returned argv — so there is
15
16
  * nothing for a prompt to offer a choice about beforehand. --sort stays
@@ -34,6 +35,7 @@ const EXTRAS = [
34
35
  hint: "--collapse-retakes",
35
36
  },
36
37
  { value: "sourceIsEdited", label: "Source already has burned-in text", hint: "--source-is-edited" },
38
+ { value: "watermark", label: 'Credit the tool with a small "made with ossclip"', hint: "--watermark" },
37
39
  { value: "llm", label: "Choose the LLM provider", hint: "--llm" },
38
40
  ] as const;
39
41
 
@@ -45,12 +47,92 @@ const EXTRAS = [
45
47
  * error nine prompts later — so the clip extra is only ever listed once
46
48
  * graphics is already on. Exported and kept pure so this can be asserted
47
49
  * without a TTY.
50
+ *
51
+ * `watermarkFromConfig` (review, minor a): on a config-on machine the
52
+ * watermark entry sits UNCHECKED while the credit will render anyway —
53
+ * unchecked is "don't emit the flag", not "off", and the multiselect has no
54
+ * way to say the second thing. The honest cheap fix is to say so in the
55
+ * entry's own hint rather than pre-checking it (a pre-check would emit a
56
+ * redundant --watermark and teach a command line longer than the run needs,
57
+ * against produceArgv's default-elision rule).
58
+ */
59
+ export function extrasFor(
60
+ graphics: boolean,
61
+ opts: { watermarkFromConfig?: boolean } = {},
62
+ ): { value: (typeof EXTRAS)[number]["value"]; label: string; hint: string }[] {
63
+ const list = graphics ? [...EXTRAS] : EXTRAS.filter((e) => e.value !== "graphicsClip");
64
+ if (opts.watermarkFromConfig !== true) return [...list];
65
+ return list.map((e) =>
66
+ e.value === "watermark"
67
+ ? { ...e, hint: "already on via your config — unticking does not disable it; --no-watermark does" }
68
+ : e,
69
+ );
70
+ }
71
+
72
+ /** Select value that routes to the free-text model prompt instead of a name. */
73
+ export const CUSTOM_MODEL = "__custom__";
74
+
75
+ /**
76
+ * A model pick reduced to its bare name: basename, minus the optional ggml-
77
+ * prefix and .bin suffix. Exists because the language prefill classifies on
78
+ * `.endsWith(".en")`, and an absolute path like /x/ggml-small.en.bin ends in
79
+ * ".bin" — an English model would have been prefilled `auto` (review fix,
80
+ * Urdu field test 2026-08-05).
81
+ */
82
+ export function bareWhisperModelName(nameOrPath: string): string {
83
+ const base = basename(nameOrPath);
84
+ const m = /^(?:ggml-)?(.+?)(?:\.bin)?$/.exec(base);
85
+ return m?.[1] ?? base;
86
+ }
87
+
88
+ /** The three names `ossclip setup` knows how to download, with their hints. */
89
+ const CANONICAL_MODELS = [
90
+ { value: "base.en", hint: "fastest, least accurate" },
91
+ { value: "small.en", hint: "default" },
92
+ { value: "medium.en", hint: "slowest, most accurate" },
93
+ ] as const;
94
+
95
+ /**
96
+ * modelDir listing → select choices. Pure so the enumeration rules —
97
+ * `ggml-*.bin` stripped to bare names, everything else ignored — are testable
98
+ * without a TTY or a real ~/.ossclip. Exists because the fixed .en-only list
99
+ * made a downloaded fine-tune unpickable from the wizard (Urdu field test
100
+ * 2026-08-05: ggml-medium-urdu.bin was installed and working via
101
+ * `--whisper-model medium-urdu`, and the wizard could not name it).
48
102
  */
49
- export function extrasFor(graphics: boolean): (typeof EXTRAS)[number][] {
50
- return graphics ? [...EXTRAS] : EXTRAS.filter((e) => e.value !== "graphicsClip");
103
+ export function whisperModelChoices(
104
+ modelDirFiles: string[],
105
+ ): { value: string; label: string; hint: string }[] {
106
+ const installed = new Set<string>();
107
+ for (const f of modelDirFiles) {
108
+ // Bare name is what --whisper-model takes: produce.ts joins it back into
109
+ // `ggml-<name>.bin`, so the round trip is exact by construction.
110
+ const m = /^ggml-(.+)\.bin$/.exec(f);
111
+ if (m?.[1] !== undefined) installed.add(m[1]);
112
+ }
113
+ // Canonicals stay listed whether or not downloaded: produce.ts already
114
+ // errors helpfully (naming the setup/curl fix) on a missing model, so the
115
+ // pick works — but the download should not be a surprise, hence the marker.
116
+ const choices: { value: string; label: string; hint: string }[] = CANONICAL_MODELS.map((c) => ({
117
+ value: c.value,
118
+ label: c.value,
119
+ hint: installed.has(c.value) ? c.hint : `${c.hint} · will need download`,
120
+ }));
121
+ const canonical = new Set<string>(CANONICAL_MODELS.map((c) => c.value));
122
+ for (const name of [...installed].filter((n) => !canonical.has(n)).sort()) {
123
+ choices.push({ value: name, label: name, hint: "installed" });
124
+ }
125
+ choices.push({
126
+ value: CUSTOM_MODEL,
127
+ label: "type a name or absolute path",
128
+ hint: "anything whisper.cpp can load",
129
+ });
130
+ return choices;
51
131
  }
52
132
 
53
- export async function produceWizard(cfg: { speaker?: string; input?: string } = {}): Promise<string[]> {
133
+ export async function produceWizard(
134
+ cfg: { speaker?: string; modelDir?: string; input?: string; watermark?: boolean } = {},
135
+ ): Promise<string[]> {
54
136
  assertInteractive("produce wizard");
55
137
  intro("ossclip produce");
56
138
 
@@ -128,7 +210,7 @@ export async function produceWizard(cfg: { speaker?: string; input?: string } =
128
210
  const chosen = unwrap(
129
211
  await multiselect({
130
212
  message: "Anything else? (space to toggle, enter to accept)",
131
- options: extrasFor(graphics),
213
+ options: extrasFor(graphics, { watermarkFromConfig: cfg.watermark === true }),
132
214
  required: false,
133
215
  }),
134
216
  ) as string[];
@@ -153,6 +235,7 @@ export async function produceWizard(cfg: { speaker?: string; input?: string } =
153
235
  if (chosen.includes("sourceFit")) extras.sourceFit = "contain";
154
236
  if (chosen.includes("collapseRetakes")) extras.collapseRetakes = true;
155
237
  if (chosen.includes("sourceIsEdited")) extras.sourceIsEdited = true;
238
+ if (chosen.includes("watermark")) extras.watermark = true;
156
239
  if (chosen.includes("speaker")) {
157
240
  extras.speaker = unwrap(
158
241
  await text({
@@ -165,17 +248,50 @@ export async function produceWizard(cfg: { speaker?: string; input?: string } =
165
248
  ) as string;
166
249
  }
167
250
  if (chosen.includes("whisperModel")) {
168
- extras.whisperModel = unwrap(
251
+ // Enumerated from disk, not hardcoded (Urdu field test 2026-08-05): a
252
+ // fine-tune the user already installed must be pickable here, not
253
+ // flags-only. A missing/unset modelDir just means nothing extra to list.
254
+ const modelFiles =
255
+ cfg.modelDir !== undefined && existsSync(cfg.modelDir) ? readdirSync(cfg.modelDir) : [];
256
+ let model = unwrap(
169
257
  await select({
170
258
  message: "Transcription model",
171
259
  initialValue: "small.en",
172
- options: [
173
- { value: "base.en", label: "base.en", hint: "fastest, least accurate" },
174
- { value: "small.en", label: "small.en", hint: "default" },
175
- { value: "medium.en", label: "medium.en", hint: "slowest, most accurate" },
176
- ],
260
+ options: whisperModelChoices(modelFiles),
177
261
  }),
178
262
  ) as string;
263
+ if (model === CUSTOM_MODEL) {
264
+ // Trimmed before the guard: " " passing as truthy would emit a
265
+ // whitespace --whisper-model that produce.ts then fails to resolve.
266
+ model = (
267
+ unwrap(
268
+ await text({
269
+ message: "Model name or absolute path to a ggml .bin",
270
+ placeholder: "medium-urdu",
271
+ validate: (v) => (v?.trim() ? undefined : "a model name or path is required"),
272
+ }),
273
+ ) as string
274
+ ).trim();
275
+ }
276
+ extras.whisperModel = model;
277
+ // Follow-up under the same extra, like --clip's seconds prompt: a language
278
+ // only means anything once a model is being picked, and a multilingual
279
+ // fine-tune silently decodes English without it (Urdu field test
280
+ // 2026-08-05). A non-.en pick is multilingual by construction, so the
281
+ // prefill makes plain Enter the safe answer — `auto` lets whisper detect.
282
+ // Empty keeps whisper's en default, and produceArgv's default-elision
283
+ // rule then emits no flag at all.
284
+ const lang = (
285
+ unwrap(
286
+ await text({
287
+ message: "Transcription language code (empty = default en)",
288
+ placeholder: "ur",
289
+ initialValue: bareWhisperModelName(model).endsWith(".en") ? "" : "auto",
290
+ defaultValue: "",
291
+ }),
292
+ ) as string
293
+ ).trim(); // a whitespace answer means "default", not a bogus -l " "
294
+ if (lang) extras.whisperLanguage = lang;
179
295
  }
180
296
  if (chosen.includes("blooperMarker")) {
181
297
  extras.blooperMarker = unwrap(
package/src/produce.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { createReadStream } from "node:fs";
3
- import { mkdir, readFile, writeFile, rename } from "node:fs/promises";
4
- import { copyFileSync, existsSync, mkdirSync, readFileSync, statSync } from "node:fs";
3
+ import { mkdir, readFile, writeFile, rename, rm } from "node:fs/promises";
4
+ import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync } from "node:fs";
5
5
  import { basename, dirname, isAbsolute, join, resolve } from "node:path";
6
6
  import { z } from "zod/v4";
7
7
  import {
@@ -97,7 +97,13 @@ import {
97
97
  type Transcript,
98
98
  } from "@ossclip/core";
99
99
  import { recordRecentProject } from "./edit";
100
+ import {
101
+ strandedOverrideSiblings,
102
+ strandedPointerLine,
103
+ workdirBaseName,
104
+ } from "./stranded-overrides";
100
105
  import { editHint } from "./interactive/edit-hint";
106
+ import { recordedProduceArgs } from "./replay-argv";
101
107
  import { renderCover, renderProduction } from "@ossclip/renderer";
102
108
  import {
103
109
  coverTextRect,
@@ -117,6 +123,43 @@ export interface ProduceResult {
117
123
  rendered: boolean;
118
124
  }
119
125
 
126
+ /**
127
+ * What produced the workdir's transcript.json — written beside it as
128
+ * transcript-key.json (review fix, Urdu field test 2026-08-05). Parsed with
129
+ * zod like the transcript itself: a hand-edited or truncated key must error,
130
+ * not silently decide whether a cache is reused.
131
+ */
132
+ export const TranscriptKeySchema = z.object({
133
+ model: z.string(),
134
+ language: z.string().optional(),
135
+ });
136
+ export type TranscriptKey = z.infer<typeof TranscriptKeySchema>;
137
+
138
+ /**
139
+ * Whether the cached transcript answers the current request. Pure so all
140
+ * four corners (matching key, differing key, keyless + default, keyless +
141
+ * non-default) are testable without a workdir. A missing key means a workdir
142
+ * from before the key existed; every one of those was transcribed with the
143
+ * config-default model and no -l, so it is treated as exactly that — old
144
+ * workdirs must not all re-transcribe spuriously, but a non-default request
145
+ * against a keyless cache must.
146
+ */
147
+ export function transcriptCacheReusable(
148
+ recorded: TranscriptKey | null,
149
+ requested: TranscriptKey,
150
+ defaultModel: string,
151
+ ): { reuse: boolean; recorded: TranscriptKey } {
152
+ const effective = recorded ?? { model: defaultModel };
153
+ return {
154
+ reuse:
155
+ effective.model === requested.model &&
156
+ // "" and absent both mean whisper's en default — program.ts rejects an
157
+ // empty code, but a key file predating that guard must not wedge.
158
+ (effective.language ?? "") === (requested.language ?? ""),
159
+ recorded: effective,
160
+ };
161
+ }
162
+
120
163
  export interface ProduceOptions {
121
164
  out?: string;
122
165
  cleanup: CleanupLevel;
@@ -142,6 +185,12 @@ export interface ProduceOptions {
142
185
  repair?: boolean;
143
186
  /** Override the whisper model for this run (A/B base.en vs small.en). */
144
187
  whisperModel?: string;
188
+ /**
189
+ * `-l` language code for whisper (e.g. "ur", "auto"). Unset keeps whisper's
190
+ * English default — required for a non-English fine-tune, which otherwise
191
+ * decodes garbage (Urdu field test 2026-08-05).
192
+ */
193
+ whisperLanguage?: string;
145
194
  /** Debug: force every graphic moment to this component. */
146
195
  forceComponent?: SceneComponentId;
147
196
  /** Write a cover image beside the video (default on). */
@@ -189,6 +238,14 @@ export interface ProduceOptions {
189
238
  * window with zero LLM calls. Written by clip runs; not for hand use.
190
239
  */
191
240
  clipWindow?: string;
241
+ /**
242
+ * `--watermark` / `--no-watermark` tri-state: true/false when TYPED,
243
+ * undefined when not — undefined lets the config's `watermark` key supply
244
+ * the default (`resolveWatermark`). Opt-in by design: the default is off
245
+ * for everyone, because a forced watermark on an open-source tool reads as
246
+ * a free-tier limitation; this is voluntary attribution.
247
+ */
248
+ watermark?: boolean;
192
249
  /**
193
250
  * `<input>` a DIRECTORY: order its clips before concatenating them into the
194
251
  * source produce runs on (folder-input-brief.md). `name` (default) is a
@@ -206,6 +263,23 @@ export interface ProduceOptions {
206
263
  sortExplicit?: boolean;
207
264
  }
208
265
 
266
+ /**
267
+ * The effective watermark switch: a TYPED flag always wins (so
268
+ * `--no-watermark` beats a config-on), and only then does the config supply
269
+ * the default. The config side is `=== true`, never truthiness — the value
270
+ * comes from a hand-editable JSON file loadConfig doesn't zod-parse, and a
271
+ * typo'd `"watermark": "no"` coercing a credit ON is exactly the
272
+ * parse-don't-coerce failure CLAUDE.md forbids; for an opt-in credit, off is
273
+ * the only safe reading of anything malformed. Pure so the whole
274
+ * flag × config matrix is testable without a config file on disk.
275
+ */
276
+ export function resolveWatermark(
277
+ flag: boolean | undefined,
278
+ configValue: boolean | undefined,
279
+ ): boolean {
280
+ return flag ?? configValue === true;
281
+ }
282
+
209
283
  function sha1File(path: string): Promise<string> {
210
284
  return new Promise((res, rej) => {
211
285
  const h = createHash("sha1");
@@ -245,10 +319,9 @@ function deriveWorkdir(
245
319
  landscape: boolean,
246
320
  ): string {
247
321
  const workRoot = workdirOpt ? resolve(workdirOpt) : join(dirname(identity), ".ossclip");
248
- return join(
249
- workRoot,
250
- `${basename(identity).replace(/\.[^.]+$/, "")}-${hash}${landscape ? "-16x9" : ""}`,
251
- );
322
+ // The basename half is shared with the §131 stranded-edits scan so the
323
+ // scan's matching can never drift from the naming it scans for.
324
+ return join(workRoot, `${workdirBaseName(identity)}-${hash}${landscape ? "-16x9" : ""}`);
252
325
  }
253
326
 
254
327
  /**
@@ -494,6 +567,36 @@ export async function produce(inputArg: string, opts: ProduceOptions): Promise<P
494
567
  await mkdir(work, { recursive: true });
495
568
  console.log(`▸ workdir ${work}`);
496
569
 
570
+ // §131 residue: a folder re-key (clips renamed/added/removed → new content
571
+ // hash) correctly lands in a fresh workdir, but any editor edits saved in
572
+ // the PREVIOUS workdir's overrides.json don't carry over — and without this
573
+ // pointer the user sees a clean produce and never learns where those edits
574
+ // went. Gated on the current workdir lacking overrides.json: a warm re-run
575
+ // that already has edits needs no pointer. Print-only by design — no
576
+ // migration, no prompt — and best-effort: a courtesy line must never be the
577
+ // reason a produce fails.
578
+ if (isFolder && !existsSync(join(work, "overrides.json"))) {
579
+ try {
580
+ const workRoot = dirname(work);
581
+ const entries = readdirSync(workRoot, { withFileTypes: true })
582
+ .filter((d) => d.isDirectory())
583
+ .map((d) => {
584
+ const overrides = join(workRoot, d.name, "overrides.json");
585
+ const st = existsSync(overrides) ? statSync(overrides) : null;
586
+ return { name: d.name, hasOverrides: st !== null, mtimeMs: st?.mtimeMs ?? 0 };
587
+ });
588
+ const stranded = strandedOverrideSiblings({
589
+ base: workdirBaseName(input),
590
+ currentHash: hash,
591
+ entries,
592
+ });
593
+ for (const name of stranded) console.log(strandedPointerLine(join(workRoot, name)));
594
+ } catch {
595
+ // Racing deletes/permissions while scanning siblings: drop the hint,
596
+ // keep the run (§131 — the pointer is a courtesy, not a dependency).
597
+ }
598
+ }
599
+
497
600
  if (isFolder && folderListing) {
498
601
  const sort = opts.sort ?? "name";
499
602
  const result = await concatFolder(tools, input, folderListing, work, sort, {
@@ -562,18 +665,48 @@ export async function produce(inputArg: string, opts: ProduceOptions): Promise<P
562
665
 
563
666
  let transcript: Transcript;
564
667
  const transcriptCache = join(work, "transcript.json");
668
+ // Which model/language WROTE transcript.json, recorded beside it (review
669
+ // fix, Urdu field test 2026-08-05): the cache used to be reused on
670
+ // existence alone, so a warm workdir silently served the stale English
671
+ // transcript on the first `--whisper-language ur` retry — the exact run
672
+ // the flag exists for — and equally defeated the model A/B the
673
+ // --whisper-model help text advertises.
674
+ const transcriptKeyPath = join(work, "transcript-key.json");
675
+ const requestedKey: TranscriptKey = {
676
+ model: opts.whisperModel ?? cfg.model,
677
+ ...(opts.whisperLanguage !== undefined ? { language: opts.whisperLanguage } : {}),
678
+ };
679
+ let cacheVerdict: ReturnType<typeof transcriptCacheReusable> | null = null;
680
+ if (!opts.transcript && existsSync(transcriptCache)) {
681
+ const recorded = existsSync(transcriptKeyPath)
682
+ ? TranscriptKeySchema.parse(JSON.parse(await readFile(transcriptKeyPath, "utf8")))
683
+ : null;
684
+ cacheVerdict = transcriptCacheReusable(recorded, requestedKey, cfg.model);
685
+ }
565
686
  if (opts.transcript) {
566
687
  transcript = TranscriptSchema.parse(JSON.parse(await readFile(resolve(opts.transcript), "utf8")));
567
688
  console.log(`▸ transcript injected from ${opts.transcript} (${transcript.words.length} words)`);
568
- } else if (existsSync(transcriptCache)) {
689
+ // An injected transcript came from no whisper run at all, so any key left
690
+ // by an earlier one would mislabel the cache this branch overwrites below.
691
+ // Keyless-as-default keeps today's behavior: later default runs reuse it,
692
+ // and only an explicit model/language request re-transcribes over it.
693
+ await rm(transcriptKeyPath, { force: true });
694
+ } else if (cacheVerdict?.reuse) {
569
695
  transcript = TranscriptSchema.parse(JSON.parse(await readFile(transcriptCache, "utf8")));
570
696
  console.log(`▸ transcript cached (${transcript.words.length} words)`);
571
697
  } else {
698
+ if (cacheVerdict !== null) {
699
+ const fmt = (k: TranscriptKey) => `${k.model}/lang ${k.language ?? "default"}`;
700
+ console.log(
701
+ `▸ transcript cache is for model ${fmt(cacheVerdict.recorded)} — ` +
702
+ `re-transcribing with ${fmt(requestedKey)}`,
703
+ );
704
+ }
572
705
  await preflight(
573
706
  cfg.whisperPath,
574
707
  "Run `ossclip setup`, install whisper.cpp yourself (https://github.com/ggml-org/whisper.cpp), or set OSSCLIP_WHISPER.",
575
708
  );
576
- const model = opts.whisperModel ?? cfg.model;
709
+ const model = requestedKey.model;
577
710
  const modelPath = isAbsolute(model) ? model : join(cfg.modelDir, `ggml-${model}.bin`);
578
711
  if (!existsSync(modelPath)) {
579
712
  throw new Error(
@@ -584,10 +717,16 @@ export async function produce(inputArg: string, opts: ProduceOptions): Promise<P
584
717
  }
585
718
  console.log(`▸ transcribing (${basename(modelPath)})…`);
586
719
  transcript = await runWhisper(
587
- { whisperPath: cfg.whisperPath, modelPath, outBase: join(work, "whisper") },
720
+ {
721
+ whisperPath: cfg.whisperPath,
722
+ modelPath,
723
+ outBase: join(work, "whisper"),
724
+ language: opts.whisperLanguage,
725
+ },
588
726
  audioPath,
589
727
  );
590
728
  console.log(`▸ transcribed ${transcript.words.length} words`);
729
+ await writeFile(transcriptKeyPath, JSON.stringify(requestedKey, null, 2));
591
730
  }
592
731
  await writeFile(transcriptCache, JSON.stringify(transcript, null, 2));
593
732
 
@@ -1881,6 +2020,17 @@ export async function produce(inputArg: string, opts: ProduceOptions): Promise<P
1881
2020
  );
1882
2021
  }
1883
2022
 
2023
+ // Resolved HERE, next to the props it feeds, and announced when on — the
2024
+ // one ▸ line is how a config-sourced credit stays visible per run instead
2025
+ // of surprising the author on upload.
2026
+ const watermark = resolveWatermark(opts.watermark, cfg.watermark);
2027
+ if (watermark) {
2028
+ console.log(
2029
+ `▸ watermark: "made with ossclip" in the top-left safe area` +
2030
+ `${opts.watermark === undefined ? " (from config; --no-watermark overrides)" : ""}`,
2031
+ );
2032
+ }
2033
+
1884
2034
  const props = {
1885
2035
  videoFileName: basename(renderVideo),
1886
2036
  spans: [...map.spans],
@@ -1937,6 +2087,10 @@ export async function produce(inputArg: string, opts: ProduceOptions): Promise<P
1937
2087
  ...(opts.sourceFit === "contain"
1938
2088
  ? { sourceFit: "contain" as const, sourceSize: content }
1939
2089
  : {}),
2090
+ // Written only when ON, matching the field's absent-means-off contract:
2091
+ // an off run's render-props.json stays byte-identical to a pre-watermark
2092
+ // one, so nothing downstream can tell the feature ever shipped.
2093
+ ...(watermark ? { watermark: true } : {}),
1940
2094
  };
1941
2095
  await writeFile(join(work, "render-props.json"), JSON.stringify(props, null, 2));
1942
2096
 
@@ -2092,18 +2246,32 @@ export async function produce(inputArg: string, opts: ProduceOptions): Promise<P
2092
2246
  // provider (R16 §75). Pin the RESOLVED choice into the recorded args —
2093
2247
  // never the key itself; secrets stay out of the workdir — so a replay
2094
2248
  // uses the same configuration or fails loudly asking for it.
2095
- const recordedArgs = process.argv.slice(2);
2096
- if (provider && !recordedArgs.includes("--llm")) {
2097
- recordedArgs.push("--llm", providerName);
2098
- }
2099
2249
  // §93g: pin the RESOLVED window, exactly as §75 pinned the provider. The
2100
2250
  // editor's Render replays this argv; if replay re-asked the model and got a
2101
2251
  // slightly different window, every saved override — anchored to scene ids
2102
2252
  // and word indices — would land on the wrong words. The word range, not
2103
2253
  // just `--clip 60`, is what makes replay deterministic with zero LLM calls.
2104
- if (clipWindow && !recordedArgs.includes("--clip-window")) {
2105
- recordedArgs.push("--clip-window", `${clipWindow.startWord}:${clipWindow.endWord}`);
2106
- }
2254
+ //
2255
+ // §129: NOT process.argv. A wizard or bare-path run re-enters commander
2256
+ // with a BUILT argv while process.argv still holds the original invocation
2257
+ // (`ossclip <path>`, no `produce` literal, none of the wizard's answers) —
2258
+ // recording process.argv shipped a command that replays as
2259
+ // `ossclip <path> --llm …` and dies on "unknown option '--llm'".
2260
+ // recordedProduceArgs prefers the argv the re-entry stashed and falls back
2261
+ // to process.argv for a directly typed `ossclip produce …`, which stays
2262
+ // byte-identical to what was always recorded.
2263
+ // Watermark pin, same §75 shape, and in BOTH directions (review,
2264
+ // Important): the effective default comes from THIS machine's
2265
+ // ~/.ossclip/config.json, so an unpinned record replays differently
2266
+ // wherever that config differs — an off-run would silently gain a credit
2267
+ // under a later/foreign config-on, an on-run would silently lose it. The
2268
+ // RESOLVED state is always pinned; a typed flag is already in the argv and
2269
+ // the includes-guard leaves it alone.
2270
+ const recordedArgs = recordedProduceArgs({
2271
+ llm: provider ? providerName : undefined,
2272
+ clipWindow: clipWindow ? `${clipWindow.startWord}:${clipWindow.endWord}` : undefined,
2273
+ watermark,
2274
+ });
2107
2275
  await writeFile(
2108
2276
  join(work, "command.json"),
2109
2277
  JSON.stringify(