@lingjingai/scriptctl 0.61.1 → 0.61.3

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