@lingjingai/scriptctl 0.61.1 → 0.61.2

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.
@@ -1014,7 +1014,6 @@ function commit(doc, path4 = doc.path) {
1014
1014
  const tmp = `${path4}.tmp-${process.pid}`;
1015
1015
  fs.writeFileSync(tmp, JSON.stringify(doc.raw, null, 2) + "\n");
1016
1016
  fs.renameSync(tmp, path4);
1017
- doc.path = path4;
1018
1017
  step("commit", `${fs.statSync(path4).size} bytes -> ${path4} (tmp + atomic rename)`);
1019
1018
  }
1020
1019
 
@@ -2903,17 +2902,17 @@ async function reviewScript(opts) {
2903
2902
  opts.onEvent?.(event);
2904
2903
  };
2905
2904
  const units = [];
2906
- await pool(selected, opts.concurrency ?? 5, async (episode) => {
2907
- const unit = await reviewUnit(doc, episode, videos[episode - 1], config);
2905
+ const checkpoint = (unit, type) => {
2908
2906
  units.push(unit);
2909
- emit({ type: "episode", ...unit });
2907
+ commit(doc, opts.scriptPath);
2908
+ emit({ type, ...unit });
2909
+ };
2910
+ await pool(selected, opts.concurrency ?? 5, async (episode) => {
2911
+ checkpoint(await reviewUnit(doc, episode, videos[episode - 1], config), "episode");
2910
2912
  });
2911
2913
  if (opts.converge !== false) {
2912
- const unit = await reviewUnit(doc, 0, void 0, config);
2913
- units.push(unit);
2914
- emit({ type: "global", ...unit });
2914
+ checkpoint(await reviewUnit(doc, 0, void 0, config), "global");
2915
2915
  }
2916
- commit(doc, opts.scriptPath);
2917
2916
  const usage_total = units.flatMap((unit) => unit.usage);
2918
2917
  emit({
2919
2918
  type: "done",