@lingjingai/scriptctl 0.49.10 → 0.49.13

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.
Files changed (93) hide show
  1. package/README.md +8 -5
  2. package/changes/0.49.11.md +13 -0
  3. package/changes/0.49.12.md +13 -0
  4. package/changes/unreleased.md +12 -3
  5. package/dist/cli.js +34 -1
  6. package/dist/cli.js.map +1 -1
  7. package/dist/common.d.ts +1 -4
  8. package/dist/common.js +1 -12
  9. package/dist/common.js.map +1 -1
  10. package/dist/domain/authoring/apply.d.ts +33 -0
  11. package/dist/domain/authoring/apply.js +717 -0
  12. package/dist/domain/authoring/apply.js.map +1 -0
  13. package/dist/domain/authoring/export.d.ts +7 -0
  14. package/dist/domain/authoring/export.js +85 -0
  15. package/dist/domain/authoring/export.js.map +1 -0
  16. package/dist/domain/authoring/parser.d.ts +3 -0
  17. package/dist/domain/authoring/parser.js +915 -0
  18. package/dist/domain/authoring/parser.js.map +1 -0
  19. package/dist/domain/authoring/serializer.d.ts +2 -0
  20. package/dist/domain/authoring/serializer.js +244 -0
  21. package/dist/domain/authoring/serializer.js.map +1 -0
  22. package/dist/domain/authoring/types.d.ts +87 -0
  23. package/dist/domain/authoring/types.js +2 -0
  24. package/dist/domain/authoring/types.js.map +1 -0
  25. package/dist/domain/ingest/apply-plan.d.ts +1 -1
  26. package/dist/domain/ingest/records.d.ts +3 -2
  27. package/dist/domain/ingest/records.js +2 -1
  28. package/dist/domain/ingest/records.js.map +1 -1
  29. package/dist/domain/ingest/serial-context.d.ts +1 -1
  30. package/dist/domain/ingest/validation.js +20 -2
  31. package/dist/domain/ingest/validation.js.map +1 -1
  32. package/dist/domain/ingest/video-apply.js +7 -9
  33. package/dist/domain/ingest/video-apply.js.map +1 -1
  34. package/dist/domain/script/address.js.map +1 -1
  35. package/dist/domain/script/lookups.d.ts +0 -1
  36. package/dist/domain/script/lookups.js +0 -9
  37. package/dist/domain/script/lookups.js.map +1 -1
  38. package/dist/domain/script/parse.d.ts +3 -0
  39. package/dist/domain/script/parse.js +165 -0
  40. package/dist/domain/script/parse.js.map +1 -0
  41. package/dist/domain/script/patch/apply.d.ts +1 -3
  42. package/dist/domain/script/patch/apply.js +5 -12
  43. package/dist/domain/script/patch/apply.js.map +1 -1
  44. package/dist/domain/script/patch/inline-speaker.js +2 -2
  45. package/dist/domain/script/patch/inline-speaker.js.map +1 -1
  46. package/dist/domain/script/patch/ops-action.js +3 -3
  47. package/dist/domain/script/patch/ops-action.js.map +1 -1
  48. package/dist/domain/script/patch/ops-asset.js +4 -5
  49. package/dist/domain/script/patch/ops-asset.js.map +1 -1
  50. package/dist/domain/script/patch/ops-meta.js.map +1 -1
  51. package/dist/domain/script/selector.js +1 -3
  52. package/dist/domain/script/selector.js.map +1 -1
  53. package/dist/domain/script/types.d.ts +123 -0
  54. package/dist/domain/script/types.js +9 -0
  55. package/dist/domain/script/types.js.map +1 -0
  56. package/dist/help-text.js +105 -0
  57. package/dist/help-text.js.map +1 -1
  58. package/dist/infra/converters.d.ts +0 -1
  59. package/dist/infra/converters.js +0 -29
  60. package/dist/infra/converters.js.map +1 -1
  61. package/dist/infra/script-working-copy.d.ts +1 -0
  62. package/dist/infra/script-working-copy.js +4 -1
  63. package/dist/infra/script-working-copy.js.map +1 -1
  64. package/dist/llm/tasks/ingest/asset-curate.d.ts +1 -1
  65. package/dist/llm/tasks/ingest/text-normalize.js +0 -21
  66. package/dist/llm/tasks/ingest/text-normalize.js.map +1 -1
  67. package/dist/llm/tasks/ingest/video-serial.js +2 -2
  68. package/dist/llm/tasks/ingest/video-serial.js.map +1 -1
  69. package/dist/llm/tasks/schemas.js +2 -2
  70. package/dist/llm/tasks/schemas.js.map +1 -1
  71. package/dist/usecases/doctor.js +0 -1
  72. package/dist/usecases/doctor.js.map +1 -1
  73. package/dist/usecases/ingest/pipeline.js +1 -1
  74. package/dist/usecases/script/do.js +2 -2
  75. package/dist/usecases/script/do.js.map +1 -1
  76. package/dist/usecases/script/export-authoring.d.ts +4 -0
  77. package/dist/usecases/script/export-authoring.js +305 -0
  78. package/dist/usecases/script/export-authoring.js.map +1 -0
  79. package/dist/usecases/script/ids.d.ts +3 -0
  80. package/dist/usecases/script/ids.js +101 -0
  81. package/dist/usecases/script/ids.js.map +1 -0
  82. package/dist/usecases/script/lib.js +1 -6
  83. package/dist/usecases/script/lib.js.map +1 -1
  84. package/dist/usecases/script/write-authoring.d.ts +3 -0
  85. package/dist/usecases/script/write-authoring.js +186 -0
  86. package/dist/usecases/script/write-authoring.js.map +1 -0
  87. package/package.json +2 -3
  88. package/skills/scriptctl/SKILL.md +41 -7
  89. package/skills/scriptctl/references/bulk-authoring.md +165 -0
  90. package/skills/scriptctl/references/state-reference-repair.md +2 -2
  91. package/dist/domain/ingest/script-v3.d.ts +0 -94
  92. package/dist/domain/ingest/script-v3.js +0 -7
  93. package/dist/domain/ingest/script-v3.js.map +0 -1
@@ -0,0 +1,305 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { CliError, EXIT_INPUT, EXIT_OK, EXIT_USAGE, scriptJsonPath, } from "../../common.js";
4
+ import { GENERATED_SOURCE, scriptExportDocument, targetExportDocument, } from "../../domain/authoring/export.js";
5
+ import { serializeAuthoring } from "../../domain/authoring/serializer.js";
6
+ import { requireScriptV3 } from "../../domain/script/parse.js";
7
+ import { strOf } from "../../domain/script/shared.js";
8
+ import { atomicWriteText } from "../../infra/script-working-copy.js";
9
+ function blocked(code, message, received, next, exitCode = EXIT_INPUT) {
10
+ throw new CliError("AUTHORING EXPORT BLOCKED", message, {
11
+ exitCode,
12
+ errorCode: code,
13
+ received,
14
+ nextSteps: [next],
15
+ });
16
+ }
17
+ function readScript(opts) {
18
+ const scriptPath = scriptJsonPath(opts);
19
+ let value;
20
+ try {
21
+ value = JSON.parse(fs.readFileSync(scriptPath, "utf-8"));
22
+ }
23
+ catch (error) {
24
+ blocked("SCRIPT_JSON_UNAVAILABLE", "The local script cannot be read as JSON.", [
25
+ scriptPath,
26
+ error instanceof Error ? error.message : String(error),
27
+ ], "Provide a readable local Script v3 file.");
28
+ }
29
+ return requireScriptV3(value);
30
+ }
31
+ function regions(raw) {
32
+ if (!raw)
33
+ blocked("AUTHORING_SELECTOR_REQUIRED", "This export kind requires --in.", ["<missing>"], "Pass one or more comma-separated point or from..through regions.", EXIT_USAGE);
34
+ return raw.split(",").map((part) => {
35
+ const value = part.trim();
36
+ if (!value)
37
+ blocked("AUTHORING_SELECTOR_INVALID", "Selector contains an empty region.", [raw], "Remove empty comma-separated regions.", EXIT_USAGE);
38
+ const delimiter = value.indexOf("..");
39
+ if (delimiter < 0)
40
+ return { from: value, through: value };
41
+ if (value.indexOf("..", delimiter + 2) >= 0)
42
+ blocked("AUTHORING_SELECTOR_INVALID", "Selector region has more than one range delimiter.", [value], "Use point or from..through.", EXIT_USAGE);
43
+ const from = value.slice(0, delimiter);
44
+ const through = value.slice(delimiter + 2);
45
+ if (!from || !through)
46
+ blocked("AUTHORING_SELECTOR_INVALID", "Selector range endpoint is empty.", [value], "Provide both endpoints.", EXIT_USAGE);
47
+ return { from, through };
48
+ });
49
+ }
50
+ function rangeIndices(ids, region, label) {
51
+ if (region.from === "*" && region.through === "*") {
52
+ if (ids.length === 0)
53
+ blocked("AUTHORING_SELECTOR_EMPTY", `The script contains no ${label}.`, ["*"], "Choose a non-empty target kind.");
54
+ return [0, ids.length - 1];
55
+ }
56
+ if (ids.filter((id) => id === region.from).length > 1
57
+ || ids.filter((id) => id === region.through).length > 1) {
58
+ blocked("AUTHORING_SELECTOR_AMBIGUOUS", `${label} selector endpoint is not unique.`, [region.from, region.through], "Repair duplicate stable IDs before exporting this target.");
59
+ }
60
+ const from = ids.indexOf(region.from);
61
+ const through = ids.indexOf(region.through);
62
+ if (from < 0 || through < 0)
63
+ blocked("AUTHORING_SELECTOR_NOT_FOUND", `${label} selector endpoint was not found.`, [region.from, region.through], "Use IDs from the current local script.");
64
+ if (from > through)
65
+ blocked("AUTHORING_SELECTOR_REVERSED", `${label} selector is reversed in current document order.`, [region.from, region.through], "Put the earlier document endpoint first.");
66
+ return [from, through];
67
+ }
68
+ function uniqueTargets(values, key) {
69
+ const seen = new Set();
70
+ for (const value of values) {
71
+ const id = key(value);
72
+ if (seen.has(id))
73
+ blocked("AUTHORING_SELECTOR_OVERLAP", "Selector regions overlap or repeat a target.", [id], "Use non-overlapping regions.");
74
+ seen.add(id);
75
+ }
76
+ return values;
77
+ }
78
+ function assertIncreasing(coordinates, label) {
79
+ for (let index = 1; index < coordinates.length; index += 1) {
80
+ const previous = coordinates[index - 1];
81
+ const current = coordinates[index];
82
+ const length = Math.max(previous.length, current.length);
83
+ let comparison = 0;
84
+ for (let part = 0; part < length; part += 1) {
85
+ comparison = (current[part] ?? 0) - (previous[part] ?? 0);
86
+ if (comparison !== 0)
87
+ break;
88
+ }
89
+ if (comparison <= 0) {
90
+ blocked("AUTHORING_SELECTOR_ORDER", `${label} selector regions are not in current document order.`, [
91
+ `region=${index + 1}`,
92
+ ], "List disjoint selector regions from earlier to later document positions.");
93
+ }
94
+ }
95
+ }
96
+ function episodeDocument(script, raw) {
97
+ const selected = [];
98
+ const ids = script.episodes.map((episode) => episode.episode_id);
99
+ for (const region of regions(raw)) {
100
+ const [from, through] = rangeIndices(ids, region, "episode");
101
+ selected.push(...script.episodes.slice(from, through + 1));
102
+ }
103
+ uniqueTargets(selected, (episode) => episode.episode_id);
104
+ assertIncreasing(selected.map((episode) => [ids.indexOf(episode.episode_id)]), "Episode");
105
+ const targets = selected.map((episode) => ({
106
+ kind: "episode",
107
+ value: structuredClone(episode),
108
+ source: GENERATED_SOURCE,
109
+ }));
110
+ return targetExportDocument("episode", targets);
111
+ }
112
+ function episodeSpanDocument(script, raw) {
113
+ const ids = script.episodes.map((episode) => episode.episode_id);
114
+ const targets = [];
115
+ const occupied = new Set();
116
+ const coordinates = [];
117
+ for (const region of regions(raw)) {
118
+ const [from, through] = rangeIndices(ids, region, "episode");
119
+ for (let index = from; index <= through; index += 1) {
120
+ if (occupied.has(index))
121
+ blocked("AUTHORING_SELECTOR_OVERLAP", "Episode span regions overlap.", [`${region.from}..${region.through}`], "Use non-overlapping regions.");
122
+ occupied.add(index);
123
+ }
124
+ targets.push({
125
+ kind: "episode-span",
126
+ from: ids[from],
127
+ through: ids[through],
128
+ episodes: structuredClone(script.episodes.slice(from, through + 1)),
129
+ source: GENERATED_SOURCE,
130
+ });
131
+ coordinates.push([from]);
132
+ }
133
+ assertIncreasing(coordinates, "Episode span");
134
+ return targetExportDocument("episode-span", targets);
135
+ }
136
+ function sceneEntries(script) {
137
+ return script.episodes.flatMap((episode) => episode.scenes.map((scene) => ({
138
+ episodeId: episode.episode_id,
139
+ scene,
140
+ })));
141
+ }
142
+ function sceneAddress(entry) {
143
+ return `${entry.episodeId}/${entry.scene.scene_id}`;
144
+ }
145
+ function sceneDocument(script, raw) {
146
+ const entries = sceneEntries(script);
147
+ const ids = entries.map(sceneAddress);
148
+ const selected = [];
149
+ for (const region of regions(raw)) {
150
+ const [from, through] = rangeIndices(ids, region, "scene");
151
+ selected.push(...entries.slice(from, through + 1));
152
+ }
153
+ uniqueTargets(selected, sceneAddress);
154
+ assertIncreasing(selected.map((entry) => [ids.indexOf(sceneAddress(entry))]), "Scene");
155
+ const targets = selected.map((entry) => ({
156
+ kind: "scene",
157
+ parent: entry.episodeId,
158
+ value: structuredClone(entry.scene),
159
+ source: GENERATED_SOURCE,
160
+ }));
161
+ return targetExportDocument("scene", targets);
162
+ }
163
+ function parseSceneAddress(raw) {
164
+ const match = /^([^/#]+)\/([^/#]+)$/.exec(raw);
165
+ if (!match)
166
+ blocked("AUTHORING_SELECTOR_INVALID", "Scene selector endpoint must be ep/scn.", [raw], "Use ep_ID/scn_ID.");
167
+ return { episodeId: match[1], sceneId: match[2] };
168
+ }
169
+ function sceneSpanDocument(script, raw) {
170
+ const targets = [];
171
+ const occupied = new Set();
172
+ const coordinates = [];
173
+ for (const region of regions(raw)) {
174
+ if (region.from === "*" || region.through === "*")
175
+ blocked("AUTHORING_SELECTOR_INVALID", "A scene span wildcard has no single parent.", ["*"], "Use one explicit region per episode.");
176
+ const fromAddress = parseSceneAddress(region.from);
177
+ const throughAddress = parseSceneAddress(region.through);
178
+ if (fromAddress.episodeId !== throughAddress.episodeId)
179
+ blocked("AUTHORING_SELECTOR_CROSS_PARENT", "A scene span must remain inside one episode.", [region.from, region.through], "Split it into one region per episode.");
180
+ const matchingEpisodes = script.episodes.filter((candidate) => candidate.episode_id === fromAddress.episodeId);
181
+ if (matchingEpisodes.length === 0)
182
+ blocked("AUTHORING_SELECTOR_NOT_FOUND", "Scene span parent episode was not found.", [fromAddress.episodeId], "Use an existing episode ID.");
183
+ if (matchingEpisodes.length > 1)
184
+ blocked("AUTHORING_SELECTOR_AMBIGUOUS", "Scene span parent episode is not unique.", [fromAddress.episodeId], "Repair duplicate stable IDs before exporting.");
185
+ const episode = matchingEpisodes[0];
186
+ const ids = episode.scenes.map((scene) => scene.scene_id);
187
+ const [from, through] = rangeIndices(ids, { from: fromAddress.sceneId, through: throughAddress.sceneId }, "scene");
188
+ for (let index = from; index <= through; index += 1) {
189
+ const address = `${episode.episode_id}/${ids[index]}`;
190
+ if (occupied.has(address))
191
+ blocked("AUTHORING_SELECTOR_OVERLAP", "Scene span regions overlap.", [address], "Use non-overlapping regions.");
192
+ occupied.add(address);
193
+ }
194
+ targets.push({
195
+ kind: "scene-span",
196
+ parent: episode.episode_id,
197
+ from: ids[from],
198
+ through: ids[through],
199
+ scenes: structuredClone(episode.scenes.slice(from, through + 1)),
200
+ source: GENERATED_SOURCE,
201
+ });
202
+ coordinates.push([script.episodes.indexOf(episode), from]);
203
+ }
204
+ assertIncreasing(coordinates, "Scene span");
205
+ return targetExportDocument("scene-span", targets);
206
+ }
207
+ function parseActionAddress(raw) {
208
+ const match = /^([^/#]+\/[^/#]+)#(\d+)$/.exec(raw);
209
+ if (!match)
210
+ blocked("AUTHORING_SELECTOR_INVALID", "Action selector endpoint must be ep/scn#index.", [raw], "Use a zero-based ep_ID/scn_ID#index address.");
211
+ const index = Number(match[2]);
212
+ if (!Number.isSafeInteger(index))
213
+ blocked("AUTHORING_SELECTOR_INVALID", "Action index is outside the safe integer range.", [raw], "Use a zero-based safe integer index.");
214
+ return { parent: match[1], index };
215
+ }
216
+ function actionSpanDocument(script, raw) {
217
+ const targets = [];
218
+ const occupied = new Set();
219
+ const coordinates = [];
220
+ for (const region of regions(raw)) {
221
+ if (region.from === "*" || region.through === "*")
222
+ blocked("AUTHORING_SELECTOR_INVALID", "An action span wildcard has no single parent.", ["*"], "Use one explicit region per scene.");
223
+ const fromAddress = parseActionAddress(region.from);
224
+ const throughAddress = parseActionAddress(region.through);
225
+ if (fromAddress.parent !== throughAddress.parent)
226
+ blocked("AUTHORING_SELECTOR_CROSS_PARENT", "An action span must remain inside one scene.", [region.from, region.through], "Split it into one region per scene.");
227
+ const sceneAddressValue = parseSceneAddress(fromAddress.parent);
228
+ const matchingEpisodes = script.episodes.filter((candidate) => candidate.episode_id === sceneAddressValue.episodeId);
229
+ if (matchingEpisodes.length === 0)
230
+ blocked("AUTHORING_SELECTOR_NOT_FOUND", "Action span parent episode was not found.", [sceneAddressValue.episodeId], "Use an existing episode ID.");
231
+ if (matchingEpisodes.length > 1)
232
+ blocked("AUTHORING_SELECTOR_AMBIGUOUS", "Action span parent episode is not unique.", [sceneAddressValue.episodeId], "Repair duplicate stable IDs before exporting.");
233
+ const episode = matchingEpisodes[0];
234
+ const matchingScenes = episode.scenes.filter((candidate) => candidate.scene_id === sceneAddressValue.sceneId);
235
+ if (matchingScenes.length === 0)
236
+ blocked("AUTHORING_SELECTOR_NOT_FOUND", "Action span parent scene was not found.", [fromAddress.parent], "Use an existing scene address.");
237
+ if (matchingScenes.length > 1)
238
+ blocked("AUTHORING_SELECTOR_AMBIGUOUS", "Action span parent scene is not unique.", [fromAddress.parent], "Repair duplicate stable IDs before exporting.");
239
+ const scene = matchingScenes[0];
240
+ if (fromAddress.index > throughAddress.index)
241
+ blocked("AUTHORING_SELECTOR_REVERSED", "Action span is reversed.", [region.from, region.through], "Put the lower current action index first.");
242
+ if (throughAddress.index >= scene.actions.length)
243
+ blocked("AUTHORING_SELECTOR_NOT_FOUND", "Action span endpoint is outside the current body.", [region.through, `actions=${scene.actions.length}`], "Use current zero-based action indices.");
244
+ for (let index = fromAddress.index; index <= throughAddress.index; index += 1) {
245
+ const address = `${fromAddress.parent}#${index}`;
246
+ if (occupied.has(address))
247
+ blocked("AUTHORING_SELECTOR_OVERLAP", "Action span regions overlap.", [address], "Use non-overlapping regions.");
248
+ occupied.add(address);
249
+ }
250
+ targets.push({
251
+ kind: "action-span",
252
+ parent: fromAddress.parent,
253
+ from: fromAddress.index,
254
+ through: throughAddress.index,
255
+ actions: structuredClone(scene.actions.slice(fromAddress.index, throughAddress.index + 1)),
256
+ source: GENERATED_SOURCE,
257
+ });
258
+ coordinates.push([
259
+ script.episodes.indexOf(episode),
260
+ episode.scenes.indexOf(scene),
261
+ fromAddress.index,
262
+ ]);
263
+ }
264
+ assertIncreasing(coordinates, "Action span");
265
+ return targetExportDocument("action-span", targets);
266
+ }
267
+ export function commandExportAuthoring(kind, opts) {
268
+ const outputRaw = strOf(opts["output"]).trim();
269
+ if (!outputRaw)
270
+ blocked("AUTHORING_OUTPUT_REQUIRED", "Export requires --output.", ["<missing>"], "Pass a destination .scriptctl file.", EXIT_USAGE);
271
+ const script = readScript(opts);
272
+ const selector = strOf(opts["in"]).trim();
273
+ let document;
274
+ if (kind === "script")
275
+ document = scriptExportDocument(script);
276
+ else if (kind === "episodes")
277
+ document = episodeDocument(script, selector);
278
+ else if (kind === "episode-spans")
279
+ document = episodeSpanDocument(script, selector);
280
+ else if (kind === "scenes")
281
+ document = sceneDocument(script, selector);
282
+ else if (kind === "scene-spans")
283
+ document = sceneSpanDocument(script, selector);
284
+ else
285
+ document = actionSpanDocument(script, selector);
286
+ const outputPath = path.resolve(outputRaw);
287
+ const content = serializeAuthoring(document);
288
+ atomicWriteText(outputPath, content);
289
+ const report = {
290
+ title: "AUTHORING EXPORTED",
291
+ op: `export.${kind}`,
292
+ result: [
293
+ `kind=${kind}`,
294
+ `targets=${document.targets.length}`,
295
+ `output=${outputPath}`,
296
+ ],
297
+ artifacts: [outputPath],
298
+ output_path: outputPath,
299
+ target_kind: document.targetKind,
300
+ target_count: document.targets.length,
301
+ bytes: Buffer.byteLength(content),
302
+ };
303
+ return [report, EXIT_OK];
304
+ }
305
+ //# sourceMappingURL=export-authoring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-authoring.js","sourceRoot":"","sources":["../../../src/usecases/script/export-authoring.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EACL,QAAQ,EACR,UAAU,EACV,OAAO,EACP,UAAU,EACV,cAAc,GAEf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,KAAK,EAAa,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAarE,SAAS,OAAO,CAAC,IAAY,EAAE,OAAe,EAAE,QAAkB,EAAE,IAAY,EAAE,QAAQ,GAAG,UAAU;IACrG,MAAM,IAAI,QAAQ,CAAC,0BAA0B,EAAE,OAAO,EAAE;QACtD,QAAQ;QACR,SAAS,EAAE,IAAI;QACf,QAAQ;QACR,SAAS,EAAE,CAAC,IAAI,CAAC;KAClB,CAAC,CAAC;AACL,CAAC;AAED,SAAS,UAAU,CAAC,IAAU;IAC5B,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,C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AE;YACpC,UAAU,UAAU,EAAE;SACvB;QACD,SAAS,EAAE,CAAC,UAAU,CAAC;QACvB,WAAW,EAAE,UAAU;QACvB,WAAW,EAAE,QAAQ,CAAC,UAAU;QAChC,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM;QACrC,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC;KAClC,CAAC;IACF,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type Report } from "../../common.js";
2
+ import { type Dict } from "../../domain/script/shared.js";
3
+ export declare function commandIds(opts: Dict): [Report, number];
@@ -0,0 +1,101 @@
1
+ import * as fs from "node:fs";
2
+ import { CliError, EXIT_INPUT, EXIT_OK, EXIT_USAGE, scriptJsonPath, } from "../../common.js";
3
+ import { requireScriptV3 } from "../../domain/script/parse.js";
4
+ import { strOf } from "../../domain/script/shared.js";
5
+ const PREFIX = {
6
+ actor: "act",
7
+ location: "loc",
8
+ prop: "prp",
9
+ state: "st",
10
+ episode: "ep",
11
+ scene: "scn",
12
+ };
13
+ function isIdKind(value) {
14
+ return value === "actor"
15
+ || value === "location"
16
+ || value === "prop"
17
+ || value === "state"
18
+ || value === "episode"
19
+ || value === "scene";
20
+ }
21
+ function usage(message, received) {
22
+ throw new CliError("IDS BLOCKED: invalid invocation", message, {
23
+ exitCode: EXIT_USAGE,
24
+ errorCode: "IDS_USAGE_INVALID",
25
+ required: ["--kind actor|location|prop|state|episode|scene", "--count <positive integer>"],
26
+ received,
27
+ nextSteps: ["Pass one canonical ID kind and the number of candidate IDs needed."],
28
+ });
29
+ }
30
+ function readScript(opts) {
31
+ const scriptPath = scriptJsonPath(opts);
32
+ let parsed;
33
+ try {
34
+ parsed = JSON.parse(fs.readFileSync(scriptPath, "utf-8"));
35
+ }
36
+ catch (error) {
37
+ throw new CliError("IDS BLOCKED: local script unavailable", "The local Script v3 file cannot be read.", {
38
+ exitCode: EXIT_INPUT,
39
+ errorCode: "SCRIPT_JSON_UNAVAILABLE",
40
+ received: [scriptPath, error instanceof Error ? error.message : String(error)],
41
+ nextSteps: ["Use an existing local script; for a brand-new script, assign canonical IDs directly."],
42
+ });
43
+ }
44
+ return requireScriptV3(parsed);
45
+ }
46
+ function existingIds(script, kind) {
47
+ if (kind === "actor")
48
+ return script.actors.map((asset) => asset.actor_id);
49
+ if (kind === "location")
50
+ return script.locations.map((asset) => asset.location_id);
51
+ if (kind === "prop")
52
+ return script.props.map((asset) => asset.prop_id);
53
+ if (kind === "episode")
54
+ return script.episodes.map((episode) => episode.episode_id);
55
+ if (kind === "scene")
56
+ return script.episodes.flatMap((episode) => episode.scenes.map((scene) => scene.scene_id));
57
+ return [
58
+ ...script.actors.flatMap((asset) => asset.states.map((state) => state.state_id)),
59
+ ...script.locations.flatMap((asset) => asset.states.map((state) => state.state_id)),
60
+ ...script.props.flatMap((asset) => asset.states.map((state) => state.state_id)),
61
+ ].filter((id) => id !== "default");
62
+ }
63
+ function allocate(ids, prefix, count) {
64
+ const pattern = new RegExp(`^${prefix}_(\\d+)$`);
65
+ let maximum = 0;
66
+ for (const id of ids) {
67
+ const match = pattern.exec(id);
68
+ if (match !== null)
69
+ maximum = Math.max(maximum, Number(match[1]));
70
+ }
71
+ return Array.from({ length: count }, (_, offset) => {
72
+ const value = maximum + offset + 1;
73
+ return `${prefix}_${String(value).padStart(3, "0")}`;
74
+ });
75
+ }
76
+ export function commandIds(opts) {
77
+ const rawKind = strOf(opts["kind"]).trim();
78
+ if (!isIdKind(rawKind))
79
+ usage("ID kind is invalid.", [rawKind || "<missing>"]);
80
+ const kind = rawKind;
81
+ const rawCount = strOf(opts["count"]).trim();
82
+ if (!/^[1-9]\d*$/.test(rawCount))
83
+ usage("ID count must be a positive integer.", [rawCount || "<missing>"]);
84
+ const count = Number(rawCount);
85
+ if (!Number.isSafeInteger(count))
86
+ usage("ID count is outside the safe integer range.", [rawCount]);
87
+ const script = readScript(opts);
88
+ const candidates = allocate(existingIds(script, kind), PREFIX[kind], count);
89
+ const rows = candidates.map((id) => ({ addr: id, kind, id }));
90
+ const report = {
91
+ title: "IDS",
92
+ op: "ids",
93
+ row_columns: ["addr", "kind", "id"],
94
+ rows,
95
+ kind,
96
+ count,
97
+ reserved: false,
98
+ };
99
+ return [report, EXIT_OK];
100
+ }
101
+ //# sourceMappingURL=ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.js","sourceRoot":"","sources":["../../../src/usecases/script/ids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,EACL,QAAQ,EACR,UAAU,EACV,OAAO,EACP,UAAU,EACV,cAAc,GAEf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,KAAK,EAAa,MAAM,+BAA+B,CAAC;AAEjE,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,KAAK;IACf,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,KAAK;CACJ,CAAC;AAIX,SAAS,QAAQ,CAAC,KAAa;IAC7B,OAAO,KAAK,KAAK,OAAO;WACnB,KAAK,KAAK,UAAU;WACpB,KAAK,KAAK,MAAM;WAChB,KAAK,KAAK,OAAO;WACjB,KAAK,KAAK,SAAS;WACnB,KAAK,KAAK,OAAO,CAAC;AACzB,CAAC;AAED,SAAS,KAAK,CAAC,OAAe,EAAE,QAAkB;IAChD,MAAM,IAAI,QAAQ,CAAC,iCAAiC,EAAE,OAAO,EAAE;QAC7D,QAAQ,EAAE,UAAU;QACpB,SAAS,EAAE,mBAAmB;QAC9B,QAAQ,EAAE,CAAC,gDAAgD,EAAE,4BAA4B,CAAC;QAC1F,QAAQ;QACR,SAAS,EAAE,CAAC,oEAAoE,CAAC;KAClF,CAAC,CAAC;AAC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AAC;IAC5E,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAW;QACrB,KAAK,EAAE,KAAK;QACZ,EAAE,EAAE,KAAK;QACT,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC;QACnC,IAAI;QACJ,IAAI;QACJ,KAAK;QACL,QAAQ,EAAE,KAAK;KAChB,CAAC;IACF,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3B,CAAC"}
@@ -1,6 +1,5 @@
1
1
  import { CliError, EXIT_NEEDS_AGENT, EXIT_OK, EXIT_USAGE, } from "../../common.js";
2
2
  import { applyPatchOperations } from "../../domain/script/patch/apply.js";
3
- import { renumberSceneIds } from "../../domain/script/lookups.js";
4
3
  import { sceneRefs } from "../../domain/script/scene-refs.js";
5
4
  import { isDangerousRegex, MAX_GREP_PATTERN_LEN, parseInSelector, selectorSingleActionPoint, WHOLE_SCRIPT, } from "../../domain/script/selector.js";
6
5
  import { parseAnyAddress, } from "../../domain/script/address.js";
@@ -607,9 +606,7 @@ export async function applySelectorEdits(opts, template, verbLabel) {
607
606
  let skipped = 0;
608
607
  for (const ref of refs) {
609
608
  try {
610
- // Skip the per-op scene renumber; selector verbs are all non-structural,
611
- // so we renumber once after the whole sweep instead of N times.
612
- applyPatchOperations(script, source, [{ ...template, at: ref }], { renumber: false });
609
+ applyPatchOperations(script, source, [{ ...template, at: ref }]);
613
610
  applied += 1;
614
611
  }
615
612
  catch (err) {
@@ -620,8 +617,6 @@ export async function applySelectorEdits(opts, template, verbLabel) {
620
617
  throw err;
621
618
  }
622
619
  }
623
- if (applied > 0)
624
- renumberSceneIds(script);
625
620
  const sample = refs.slice(0, 12);
626
621
  const blast = [
627
622
  `verb: ${verbLabel} (${opName})`,