@lingjingai/scriptctl 0.13.0 → 0.15.0
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.
- package/dist/cli.js +26 -49
- package/dist/cli.js.map +1 -1
- package/dist/common.d.ts +1 -1
- package/dist/common.js +1 -1
- package/dist/domain/script-core.d.ts +15 -0
- package/dist/domain/script-core.js +207 -63
- package/dist/domain/script-core.js.map +1 -1
- package/dist/help-text.js +31 -315
- package/dist/help-text.js.map +1 -1
- package/dist/infra/providers.d.ts +0 -36
- package/dist/infra/providers.js +6 -211
- package/dist/infra/providers.js.map +1 -1
- package/dist/usecases/direct.js +3 -4
- package/dist/usecases/direct.js.map +1 -1
- package/dist/usecases/doctor.js +2 -5
- package/dist/usecases/doctor.js.map +1 -1
- package/dist/usecases/script.d.ts +5 -0
- package/dist/usecases/script.js +172 -5
- package/dist/usecases/script.js.map +1 -1
- package/package.json +2 -3
- package/dist/domain/asset-registry.d.ts +0 -141
- package/dist/domain/asset-registry.js +0 -318
- package/dist/domain/asset-registry.js.map +0 -1
- package/dist/domain/collision-detector.d.ts +0 -83
- package/dist/domain/collision-detector.js +0 -248
- package/dist/domain/collision-detector.js.map +0 -1
- package/dist/infra/default-writing-prompt.d.ts +0 -31
- package/dist/infra/default-writing-prompt.js +0 -50
- package/dist/infra/default-writing-prompt.js.map +0 -1
- package/dist/infra/default-writing-prompt.md +0 -115
- package/dist/infra/gemini-writer.d.ts +0 -107
- package/dist/infra/gemini-writer.js +0 -207
- package/dist/infra/gemini-writer.js.map +0 -1
- package/dist/usecases/episode.d.ts +0 -48
- package/dist/usecases/episode.js +0 -1242
- package/dist/usecases/episode.js.map +0 -1
package/dist/usecases/doctor.js
CHANGED
|
@@ -63,7 +63,6 @@ export function commandDoctor(_opts) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
const anthropicKeyConfigured = Boolean(process.env.PROJECT_LITELLM_GATEWAY_API_KEY);
|
|
66
|
-
const geminiKeyConfigured = Boolean(process.env.SCRIPTCTL_GEMINI_API_KEY || process.env.GEMINI_API_KEY);
|
|
67
66
|
const modeInfo = resolveOutputMode();
|
|
68
67
|
const mode = modeInfo.mode;
|
|
69
68
|
const localDirRaw = (process.env.SCRIPTCTL_OUTPUT_DIR ?? "").trim() || defaultLocalOutputDir();
|
|
@@ -95,7 +94,6 @@ export function commandDoctor(_opts) {
|
|
|
95
94
|
storageLine,
|
|
96
95
|
envFileLine,
|
|
97
96
|
`provider anthropic: ${fmtCheck(anthropicKeyConfigured)}`,
|
|
98
|
-
`provider gemini: ${fmtCheck(geminiKeyConfigured)}`,
|
|
99
97
|
];
|
|
100
98
|
// Doctor result lines vary by where the published script lands, but the
|
|
101
99
|
// word "mode" / "local" / "remote" is deliberately absent: upper layers
|
|
@@ -117,7 +115,7 @@ export function commandDoctor(_opts) {
|
|
|
117
115
|
if (missingDeps.length > 0) {
|
|
118
116
|
nextSteps.push("Install missing CLI dependencies (see above).");
|
|
119
117
|
}
|
|
120
|
-
if (!anthropicKeyConfigured
|
|
118
|
+
if (!anthropicKeyConfigured) {
|
|
121
119
|
nextSteps.push("Configure provider credentials before running delivery commands.");
|
|
122
120
|
}
|
|
123
121
|
// SCRIPTCTL_OUTPUT_MODE typos used to be surfaced here as a warning, but
|
|
@@ -131,7 +129,7 @@ export function commandDoctor(_opts) {
|
|
|
131
129
|
}
|
|
132
130
|
}
|
|
133
131
|
else if (!gatewayUrlConfigured || !gatewayAccessConfigured || !projectGroupConfigured) {
|
|
134
|
-
nextSteps.push("Configure gateway credentials before running `
|
|
132
|
+
nextSteps.push("Configure gateway credentials before running `direct export` / script CRUD against the remote project.");
|
|
135
133
|
}
|
|
136
134
|
if (nextSteps.length === 0) {
|
|
137
135
|
nextSteps.push("Environment looks ready.");
|
|
@@ -163,7 +161,6 @@ export function commandDoctor(_opts) {
|
|
|
163
161
|
},
|
|
164
162
|
provider: {
|
|
165
163
|
anthropic: { ok: anthropicKeyConfigured },
|
|
166
|
-
gemini: { ok: geminiKeyConfigured },
|
|
167
164
|
},
|
|
168
165
|
output: outputChecks,
|
|
169
166
|
dependencies,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/usecases/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAe,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,SAAS,eAAe,CAAC,IAAY;IACnC,IAAI,CAAC;QACH,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,yEAAyE;AACzE,qEAAqE;AACrE,SAAS,mBAAmB,CAAC,GAAW;IAItC,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACvB,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YACtC,QAAQ,GAAG,IAAI,CAAC;QAClB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,QAAQ,GAAG,KAAK,CAAC;IACnB,CAAC;IACD,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,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KAAK,OAAO;QACd,CAAC,CAAC;YACE,GAAG,EAAE;gBACH,EAAE,EAAE,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC;gBACjC,QAAQ,EAAE,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC;gBACvC,SAAS,EAAE,OAAO,CAAC,UAAU,EAAE,SAAS,CAAC;aAC1C;SACF;QACH,CAAC,CAAC;YACE,QAAQ,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE;YACtC,MAAM,EAAE,EAAE,EAAE,EAAE,uBAAuB,EAAE;YACvC,OAAO,EAAE,EAAE,EAAE,EAAE,sBAAsB,EAAE;SACxC,CAAC;IAER,MAAM,MAAM,GAA4B;QACtC,IAAI,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE;QAC1C,OAAO,EAAE,EAAE,OAAO,EAAE,kBAAkB,EAAE,EAAE,EAAE,IAAI,EAAE;QAClD,GAAG,EAAE;YACH,EAAE,EAAE,gBAAgB,CAAC,MAAM,GAAG,CAAC;YAC/B,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,gBAAgB,CAAC,MAAM,EAAE,CAAC;SAC9E;QACD,QAAQ,EAAE;YACR,SAAS,EAAE,EAAE,EAAE,EAAE,sBAAsB,EAAE;SAC1C;QACD,MAAM,EAAE,YAAY;QACpB,YAAY;KACb,CAAC;IAEF,MAAM,MAAM,GAAW;QACrB,KAAK,EAAE,+BAA+B;QACtC,MAAM;QACN,MAAM;QACN,IAAI,EAAE,SAAS;KAChB,CAAC;IACF,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -59,4 +59,9 @@ export declare function commandTransition(opts: Dict): Promise<[Report, number]>
|
|
|
59
59
|
export declare function commandDialogue(opts: Dict): Promise<[Report, number]>;
|
|
60
60
|
export declare function commandOverlap(opts: Dict): Promise<[Report, number]>;
|
|
61
61
|
export declare function commandAddSpeaker(opts: Dict): Promise<[Report, number]>;
|
|
62
|
+
export declare function commandCreate(opts: Dict): Promise<[Report, number]>;
|
|
63
|
+
export declare function commandAddActor(opts: Dict): Promise<[Report, number]>;
|
|
64
|
+
export declare function commandAddLocation(opts: Dict): Promise<[Report, number]>;
|
|
65
|
+
export declare function commandAddProp(opts: Dict): Promise<[Report, number]>;
|
|
66
|
+
export declare function commandAddEpisode(opts: Dict): Promise<[Report, number]>;
|
|
62
67
|
export {};
|
package/dist/usecases/script.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as os from "node:os";
|
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { CliError, EXIT_INPUT, EXIT_NEEDS_AGENT, EXIT_OK, EXIT_RUNTIME, EXIT_USAGE, directDir, exists, readJson, readText, scriptJsonPath, sha256Text, writeJson, } from "../common.js";
|
|
6
|
-
import { applyPatchOperations, collectAssetRefs, collectStateRefs, parseAnyAddress, parseStateTarget, validateScript, PATCH_OP_SCHEMA, } from "../domain/script-core.js";
|
|
6
|
+
import { applyPatchOperations, blankScript, collectAssetRefs, collectStateRefs, parseAnyAddress, parseStateTarget, validateScript, PATCH_OP_SCHEMA, } from "../domain/script-core.js";
|
|
7
7
|
import { RemoteScriptOutputStore } from "../infra/script-output-api.js";
|
|
8
8
|
import { LocalScriptOutputStore } from "../infra/local-script-output-store.js";
|
|
9
9
|
import { ScriptOutputApiError, resolveOutputMode, } from "../infra/script-output-store.js";
|
|
@@ -283,6 +283,7 @@ async function loadScriptForEdit(opts) {
|
|
|
283
283
|
// agent. It is mutually exclusive with the raw --script-path and the DB-mode
|
|
284
284
|
// --project-group-no (both name a different target).
|
|
285
285
|
const draft = Boolean(opts["draft"]);
|
|
286
|
+
let draftPath = null;
|
|
286
287
|
if (draft) {
|
|
287
288
|
if (opts["script_path"]) {
|
|
288
289
|
throw new CliError("SCRIPT BLOCKED: --draft conflicts with --script-path", "--draft conflicts with --script-path.", {
|
|
@@ -302,7 +303,7 @@ async function loadScriptForEdit(opts) {
|
|
|
302
303
|
errorCode: "DRAFT_FLAG_CONFLICT",
|
|
303
304
|
});
|
|
304
305
|
}
|
|
305
|
-
|
|
306
|
+
draftPath = path.join(directDir(workspace), "script.initial.json");
|
|
306
307
|
if (!exists(draftPath)) {
|
|
307
308
|
throw new CliError("SCRIPT BLOCKED: Draft script not found", "Direct draft script not found.", {
|
|
308
309
|
exitCode: EXIT_INPUT,
|
|
@@ -312,12 +313,14 @@ async function loadScriptForEdit(opts) {
|
|
|
312
313
|
errorCode: "SCRIPT_NOT_FOUND",
|
|
313
314
|
});
|
|
314
315
|
}
|
|
315
|
-
opts["script_path"] = draftPath;
|
|
316
316
|
}
|
|
317
|
-
|
|
317
|
+
// Resolve the local file from --draft or --script-path WITHOUT mutating opts:
|
|
318
|
+
// commandAlias loads twice with the same opts, and writing script_path back
|
|
319
|
+
// would make the second load see a phantom --script-path and reject --draft.
|
|
320
|
+
if (!draftPath && !opts["script_path"]) {
|
|
318
321
|
return loadRemoteScript(opts, workspace);
|
|
319
322
|
}
|
|
320
|
-
const p = scriptJsonPath(opts);
|
|
323
|
+
const p = draftPath ?? scriptJsonPath(opts);
|
|
321
324
|
if (!exists(p)) {
|
|
322
325
|
throw new CliError("SCRIPT BLOCKED: Local script file not found", "Local script file not found.", {
|
|
323
326
|
exitCode: EXIT_INPUT,
|
|
@@ -744,6 +747,14 @@ async function applySingleScriptOp(opts, op) {
|
|
|
744
747
|
}
|
|
745
748
|
function summarizeScriptOp(_script, op) {
|
|
746
749
|
const kind = strOf(op["op"]);
|
|
750
|
+
if (kind === "actor.add")
|
|
751
|
+
return `已新增人物 ${op["name"] || op["actor_name"]}${op["role_type"] ? `(${op["role_type"]})` : ""}`;
|
|
752
|
+
if (kind === "location.add")
|
|
753
|
+
return `已新增场景地点 ${op["name"] || op["location_name"]}`;
|
|
754
|
+
if (kind === "prop.add")
|
|
755
|
+
return `已新增道具 ${op["name"] || op["prop_name"]}`;
|
|
756
|
+
if (kind === "episode.add")
|
|
757
|
+
return `已新增分集${op["episode_id"] ? ` ${op["episode_id"]}` : "(自动编号)"}${op["title"] ? `:${op["title"]}` : ""}`;
|
|
747
758
|
if (kind === "state.add")
|
|
748
759
|
return `已为 ${op["target"]} 新增状态 ${op["state_id"]}: ${op["name"] || op["state_name"]}`;
|
|
749
760
|
if (kind === "action.state.change")
|
|
@@ -2174,4 +2185,160 @@ export async function commandAddSpeaker(opts) {
|
|
|
2174
2185
|
speaker_id: opts["speaker_id"],
|
|
2175
2186
|
});
|
|
2176
2187
|
}
|
|
2188
|
+
// ----- create (blank scaffold) ----------------------------------------------
|
|
2189
|
+
// Create an empty schema-v2 script as the starting point for building a script
|
|
2190
|
+
// bottom-up with the atomic add/insert verbs (instead of direct/parse/write
|
|
2191
|
+
// assembly). Targets the same three destinations as the edit verbs:
|
|
2192
|
+
// --script-path <file> local JSON file
|
|
2193
|
+
// --draft the direct intermediate (script.initial.json)
|
|
2194
|
+
// --project-group-no DB-backed script-output (first write at revision 0)
|
|
2195
|
+
// Refuses to clobber an existing target (local: pass --force to overwrite; DB:
|
|
2196
|
+
// edit the existing script instead). Validates in incomplete-tolerant mode, so
|
|
2197
|
+
// the blank scaffold reports passed.
|
|
2198
|
+
export async function commandCreate(opts) {
|
|
2199
|
+
const workspace = strOf(opts["workspace_path"] || "workspace");
|
|
2200
|
+
const force = Boolean(opts["force"]);
|
|
2201
|
+
const title = strOf(opts["title"]).trim();
|
|
2202
|
+
const script = blankScript(title);
|
|
2203
|
+
const draft = Boolean(opts["draft"]);
|
|
2204
|
+
const scriptPathOpt = strOf(opts["script_path"]).trim();
|
|
2205
|
+
if (draft && scriptPathOpt) {
|
|
2206
|
+
throw new CliError("CREATE BLOCKED: --draft conflicts with --script-path", "--draft conflicts with --script-path.", {
|
|
2207
|
+
exitCode: EXIT_USAGE,
|
|
2208
|
+
required: ["either --draft or --script-path, not both"],
|
|
2209
|
+
received: ["--draft and --script-path"],
|
|
2210
|
+
nextSteps: ["Drop one of the two flags and retry."],
|
|
2211
|
+
errorCode: "DRAFT_FLAG_CONFLICT",
|
|
2212
|
+
});
|
|
2213
|
+
}
|
|
2214
|
+
if (draft && strOf(opts["project_group_no"]).trim()) {
|
|
2215
|
+
throw new CliError("CREATE BLOCKED: --draft conflicts with --project-group-no", "--draft conflicts with --project-group-no.", {
|
|
2216
|
+
exitCode: EXIT_USAGE,
|
|
2217
|
+
required: ["either --draft (local draft) or --project-group-no (DB), not both"],
|
|
2218
|
+
received: ["--draft and --project-group-no"],
|
|
2219
|
+
nextSteps: ["Drop one of the two flags and retry."],
|
|
2220
|
+
errorCode: "DRAFT_FLAG_CONFLICT",
|
|
2221
|
+
});
|
|
2222
|
+
}
|
|
2223
|
+
const localPath = draft ? path.join(directDir(workspace), "script.initial.json") : (scriptPathOpt || null);
|
|
2224
|
+
if (localPath) {
|
|
2225
|
+
if (exists(localPath) && !force) {
|
|
2226
|
+
throw new CliError("CREATE BLOCKED: target already exists", "A script already exists at the target.", {
|
|
2227
|
+
exitCode: EXIT_INPUT,
|
|
2228
|
+
required: ["a non-existent target, or --force to overwrite"],
|
|
2229
|
+
received: [localPath],
|
|
2230
|
+
nextSteps: ["Edit the existing script with the atomic verbs, or pass --force to overwrite with a blank scaffold."],
|
|
2231
|
+
errorCode: "SCRIPT_EXISTS",
|
|
2232
|
+
});
|
|
2233
|
+
}
|
|
2234
|
+
writeJson(localPath, script);
|
|
2235
|
+
const session = new ScriptEditSession({ workspace, scriptPath: localPath, script });
|
|
2236
|
+
const validation = validateSession(session);
|
|
2237
|
+
const passed = Boolean(validation["passed"]);
|
|
2238
|
+
return [blankCreateReport(session, validation, null), passed ? EXIT_OK : EXIT_NEEDS_AGENT];
|
|
2239
|
+
}
|
|
2240
|
+
// DB mode: first write must be at revision 0. We never silently overwrite a
|
|
2241
|
+
// populated DB script with a blank one — that would destroy work.
|
|
2242
|
+
const client = scriptOutputClient(opts);
|
|
2243
|
+
const baseRevision = await currentRevisionOrZero(client);
|
|
2244
|
+
if (baseRevision > 0) {
|
|
2245
|
+
throw new CliError("CREATE BLOCKED: DB script already exists", "A script already exists for this project.", {
|
|
2246
|
+
exitCode: EXIT_INPUT,
|
|
2247
|
+
required: ["an empty project (no published script)"],
|
|
2248
|
+
received: [`revision=${baseRevision}`],
|
|
2249
|
+
nextSteps: ["Edit the existing script with the atomic verbs instead of creating a blank one."],
|
|
2250
|
+
errorCode: "SCRIPT_EXISTS",
|
|
2251
|
+
});
|
|
2252
|
+
}
|
|
2253
|
+
const requestId = requestIdForScriptWrite(opts, "script.create", { script });
|
|
2254
|
+
let res;
|
|
2255
|
+
try {
|
|
2256
|
+
res = await client.replaceScript({ requestId, baseRevision, script, source: "ctl" });
|
|
2257
|
+
}
|
|
2258
|
+
catch (exc) {
|
|
2259
|
+
if (exc instanceof ScriptOutputApiError) {
|
|
2260
|
+
throw apiErrorToCli("SCRIPT API BLOCKED: Create write failed", exc);
|
|
2261
|
+
}
|
|
2262
|
+
throw exc;
|
|
2263
|
+
}
|
|
2264
|
+
const revision = Number(res["revision"] ?? 0);
|
|
2265
|
+
const session = new ScriptEditSession({ workspace, script, client, projectGroupNo: client.projectGroupNo, revision });
|
|
2266
|
+
const validation = validateSession(session);
|
|
2267
|
+
await syncValidationResult(session, validation, revision);
|
|
2268
|
+
const passed = Boolean(validation["passed"]);
|
|
2269
|
+
return [blankCreateReport(session, validation, Boolean(res["idempotent"])), passed ? EXIT_OK : EXIT_NEEDS_AGENT];
|
|
2270
|
+
}
|
|
2271
|
+
function blankCreateReport(session, validation, idempotent) {
|
|
2272
|
+
const passed = Boolean(validation["passed"]);
|
|
2273
|
+
const resultLines = ["created: blank script (schema v2)", `validation: ${passed ? "passed" : "needs repair"}`];
|
|
2274
|
+
if (session.remote) {
|
|
2275
|
+
resultLines.push(`revision: ${session.revision}`);
|
|
2276
|
+
if (idempotent !== null)
|
|
2277
|
+
resultLines.push(`idempotent: ${String(idempotent).toLowerCase()}`);
|
|
2278
|
+
}
|
|
2279
|
+
return {
|
|
2280
|
+
title: passed ? "SCRIPT CREATED: Blank scaffold" : "SCRIPT CREATED: Validation needs repair",
|
|
2281
|
+
op: "script.create",
|
|
2282
|
+
changed: true,
|
|
2283
|
+
summary: "已创建空白剧本(schema v2,待填充人物/地点/道具/分集)",
|
|
2284
|
+
result: resultLines,
|
|
2285
|
+
warnings: summarizeIssues(asList(validation["issues"])),
|
|
2286
|
+
artifacts: [session.artifactLabel],
|
|
2287
|
+
next: [
|
|
2288
|
+
"用 worldview 设定世界观,用 add-actor / add-location / add-prop 注册资产,用 add-episode + insert 搭出分集与场景。",
|
|
2289
|
+
],
|
|
2290
|
+
};
|
|
2291
|
+
}
|
|
2292
|
+
// ----- add-* (register new entities) ----------------------------------------
|
|
2293
|
+
// Read the single positional <name> arg shared by add-actor/location/prop, or
|
|
2294
|
+
// throw the common ARGS_MISSING usage error with a verb-specific example.
|
|
2295
|
+
function requireNameArg(opts, verb, example) {
|
|
2296
|
+
const args = asList(opts["_args"]);
|
|
2297
|
+
if (args.length < 1) {
|
|
2298
|
+
throw new CliError(`VERB BLOCKED: ${verb} name missing`, "Name missing.", {
|
|
2299
|
+
exitCode: EXIT_USAGE,
|
|
2300
|
+
required: ["<name>"],
|
|
2301
|
+
received: ["<empty>"],
|
|
2302
|
+
nextSteps: [example],
|
|
2303
|
+
errorCode: "ARGS_MISSING",
|
|
2304
|
+
});
|
|
2305
|
+
}
|
|
2306
|
+
return args[0];
|
|
2307
|
+
}
|
|
2308
|
+
export async function commandAddActor(opts) {
|
|
2309
|
+
const name = requireNameArg(opts, "add-actor", "Example: scriptctl add-actor \"林夏\" --role 主角");
|
|
2310
|
+
return applySingleScriptOp(opts, {
|
|
2311
|
+
op: "actor.add",
|
|
2312
|
+
name,
|
|
2313
|
+
actor_id: opts["id"],
|
|
2314
|
+
role_type: opts["role"],
|
|
2315
|
+
description: opts["description"],
|
|
2316
|
+
aliases: opts["alias"],
|
|
2317
|
+
});
|
|
2318
|
+
}
|
|
2319
|
+
export async function commandAddLocation(opts) {
|
|
2320
|
+
const name = requireNameArg(opts, "add-location", "Example: scriptctl add-location \"教室\"");
|
|
2321
|
+
return applySingleScriptOp(opts, {
|
|
2322
|
+
op: "location.add",
|
|
2323
|
+
name,
|
|
2324
|
+
location_id: opts["id"],
|
|
2325
|
+
description: opts["description"],
|
|
2326
|
+
});
|
|
2327
|
+
}
|
|
2328
|
+
export async function commandAddProp(opts) {
|
|
2329
|
+
const name = requireNameArg(opts, "add-prop", "Example: scriptctl add-prop \"怀表\"");
|
|
2330
|
+
return applySingleScriptOp(opts, {
|
|
2331
|
+
op: "prop.add",
|
|
2332
|
+
name,
|
|
2333
|
+
prop_id: opts["id"],
|
|
2334
|
+
description: opts["description"],
|
|
2335
|
+
});
|
|
2336
|
+
}
|
|
2337
|
+
export async function commandAddEpisode(opts) {
|
|
2338
|
+
return applySingleScriptOp(opts, {
|
|
2339
|
+
op: "episode.add",
|
|
2340
|
+
episode_id: opts["id"],
|
|
2341
|
+
title: opts["title"],
|
|
2342
|
+
});
|
|
2343
|
+
}
|
|
2177
2344
|
//# sourceMappingURL=script.js.map
|