bpmax-cli 0.1.36 → 0.1.38
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/README.md +26 -0
- package/dist/bin.js +578 -47
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/skills/bpmax-cli/SKILL.md +1 -0
- package/skills/bpmax-project/SKILL.md +30 -0
package/dist/bin.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
// src/bin.ts
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
|
|
6
|
+
// src/commands/api.ts
|
|
7
|
+
import { readFile as readFile3 } from "fs/promises";
|
|
8
|
+
|
|
6
9
|
// src/core/config.ts
|
|
7
10
|
import { homedir } from "os";
|
|
8
11
|
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
@@ -210,6 +213,27 @@ async function apiRequest(client, method, path6, options = {}) {
|
|
|
210
213
|
return body.data ?? body;
|
|
211
214
|
}
|
|
212
215
|
|
|
216
|
+
// src/core/json-input.ts
|
|
217
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
218
|
+
async function parseJsonInput(input, label = "JSON input") {
|
|
219
|
+
const source = input.startsWith("@") ? input.slice(1) : void 0;
|
|
220
|
+
if (source === "") {
|
|
221
|
+
throw new Error(`${label} file path is empty.`);
|
|
222
|
+
}
|
|
223
|
+
const raw = source ? await readFile2(source, "utf8") : input;
|
|
224
|
+
let parsed;
|
|
225
|
+
try {
|
|
226
|
+
parsed = JSON.parse(raw);
|
|
227
|
+
} catch (error) {
|
|
228
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
229
|
+
throw new Error(`${label} is not valid JSON: ${detail}`);
|
|
230
|
+
}
|
|
231
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
232
|
+
throw new Error(`${label} must be a JSON object.`);
|
|
233
|
+
}
|
|
234
|
+
return parsed;
|
|
235
|
+
}
|
|
236
|
+
|
|
213
237
|
// src/core/output.ts
|
|
214
238
|
var noticeProvider = null;
|
|
215
239
|
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -275,19 +299,43 @@ function printResult(format, value) {
|
|
|
275
299
|
}
|
|
276
300
|
|
|
277
301
|
// src/commands/api.ts
|
|
278
|
-
function
|
|
302
|
+
async function parseJsonAny(input, label = "JSON input") {
|
|
279
303
|
if (!input) {
|
|
280
304
|
return void 0;
|
|
281
305
|
}
|
|
282
|
-
|
|
306
|
+
const source = input.startsWith("@") ? input.slice(1) : void 0;
|
|
307
|
+
if (source === "") {
|
|
308
|
+
throw new Error(`${label} file path is empty.`);
|
|
309
|
+
}
|
|
310
|
+
const raw = source ? await readFile3(source, "utf8") : input;
|
|
311
|
+
try {
|
|
312
|
+
return JSON.parse(raw);
|
|
313
|
+
} catch (error) {
|
|
314
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
315
|
+
throw new Error(`${label} is not valid JSON: ${detail}`);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function isMutatingMethod(method) {
|
|
319
|
+
return ["POST", "PUT", "PATCH", "DELETE"].includes(method.toUpperCase());
|
|
283
320
|
}
|
|
284
321
|
function registerApiCommands(program2) {
|
|
285
|
-
program2.command("api <method> <path>").description("Call an arbitrary BPMAX /api endpoint").option("--profile <profile>", "Profile name").option("--params <json>", "Query params JSON").option("--data <json>", "Request body JSON").option("--format <format>", "Output format", "json").action(async (method, path6, options) => {
|
|
322
|
+
program2.command("api <method> <path>").description("Call an arbitrary BPMAX /api endpoint").option("--profile <profile>", "Profile name").option("--params <json>", "Query params JSON or @file").option("--data <json>", "Request body JSON or @file").option("--confirm-mutating", "Allow mutating API calls").option("--format <format>", "Output format", "json").action(async (method, path6, options) => {
|
|
323
|
+
const normalizedMethod = method.toUpperCase();
|
|
324
|
+
if (isMutatingMethod(normalizedMethod) && options.confirmMutating !== true) {
|
|
325
|
+
printResult(options.format, {
|
|
326
|
+
ok: false,
|
|
327
|
+
dry_run: true,
|
|
328
|
+
method: normalizedMethod,
|
|
329
|
+
path: path6,
|
|
330
|
+
warning: "Mutating raw API calls require --confirm-mutating. Prefer typed bpmax-cli commands such as step submit."
|
|
331
|
+
});
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
286
334
|
const config = await loadConfig();
|
|
287
335
|
const profile = resolveProfile(config, options.profile);
|
|
288
|
-
const result = await apiRequest(createApiClient(profile),
|
|
289
|
-
params:
|
|
290
|
-
data:
|
|
336
|
+
const result = await apiRequest(createApiClient(profile), normalizedMethod, path6, {
|
|
337
|
+
params: options.params ? await parseJsonInput(options.params, "--params") : void 0,
|
|
338
|
+
data: await parseJsonAny(options.data, "--data")
|
|
291
339
|
});
|
|
292
340
|
printResult(options.format, result);
|
|
293
341
|
});
|
|
@@ -680,33 +728,12 @@ function registerAuthCommands(program2, deps = {}) {
|
|
|
680
728
|
|
|
681
729
|
// src/commands/bbs.ts
|
|
682
730
|
import { basename } from "path";
|
|
683
|
-
import { readFile as
|
|
684
|
-
|
|
685
|
-
// src/core/json-input.ts
|
|
686
|
-
import { readFile as readFile2 } from "fs/promises";
|
|
687
|
-
async function parseJsonInput(input, label = "JSON input") {
|
|
688
|
-
const source = input.startsWith("@") ? input.slice(1) : void 0;
|
|
689
|
-
if (source === "") {
|
|
690
|
-
throw new Error(`${label} file path is empty.`);
|
|
691
|
-
}
|
|
692
|
-
const raw = source ? await readFile2(source, "utf8") : input;
|
|
693
|
-
let parsed;
|
|
694
|
-
try {
|
|
695
|
-
parsed = JSON.parse(raw);
|
|
696
|
-
} catch (error) {
|
|
697
|
-
const detail = error instanceof Error ? error.message : String(error);
|
|
698
|
-
throw new Error(`${label} is not valid JSON: ${detail}`);
|
|
699
|
-
}
|
|
700
|
-
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
701
|
-
throw new Error(`${label} must be a JSON object.`);
|
|
702
|
-
}
|
|
703
|
-
return parsed;
|
|
704
|
-
}
|
|
731
|
+
import { readFile as readFile5 } from "fs/promises";
|
|
705
732
|
|
|
706
733
|
// package.json
|
|
707
734
|
var package_default = {
|
|
708
735
|
name: "bpmax-cli",
|
|
709
|
-
version: "0.1.
|
|
736
|
+
version: "0.1.38",
|
|
710
737
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
711
738
|
type: "module",
|
|
712
739
|
bin: {
|
|
@@ -867,7 +894,7 @@ function attachProjectDetailUrl(profile, value) {
|
|
|
867
894
|
}
|
|
868
895
|
|
|
869
896
|
// src/core/business-skills.ts
|
|
870
|
-
import { cp, mkdir as mkdir2, readFile as
|
|
897
|
+
import { cp, mkdir as mkdir2, readFile as readFile4, rm, stat, writeFile as writeFile2 } from "fs/promises";
|
|
871
898
|
import { createHash as createHash2 } from "crypto";
|
|
872
899
|
import { homedir as homedir2, tmpdir } from "os";
|
|
873
900
|
import path2 from "path";
|
|
@@ -983,7 +1010,7 @@ function parseBbsJson(raw) {
|
|
|
983
1010
|
}
|
|
984
1011
|
async function readBbsJson(skillDir) {
|
|
985
1012
|
try {
|
|
986
|
-
return parseBbsJson(await
|
|
1013
|
+
return parseBbsJson(await readFile4(path2.join(skillDir, "bbs.json"), "utf8"));
|
|
987
1014
|
} catch (error) {
|
|
988
1015
|
if (error.code === "ENOENT") {
|
|
989
1016
|
return void 0;
|
|
@@ -1068,7 +1095,7 @@ function businessSkillStatePath(profileName, agent) {
|
|
|
1068
1095
|
}
|
|
1069
1096
|
async function readBusinessSkillState(profileName, agent) {
|
|
1070
1097
|
try {
|
|
1071
|
-
return JSON.parse(await
|
|
1098
|
+
return JSON.parse(await readFile4(businessSkillStatePath(profileName, agent), "utf8"));
|
|
1072
1099
|
} catch {
|
|
1073
1100
|
return { skills: {} };
|
|
1074
1101
|
}
|
|
@@ -1139,7 +1166,7 @@ async function lintBusinessSkillDirectory(skillDir, options = {}) {
|
|
|
1139
1166
|
let manifest = {};
|
|
1140
1167
|
let config;
|
|
1141
1168
|
try {
|
|
1142
|
-
skillMarkdown = await
|
|
1169
|
+
skillMarkdown = await readFile4(path2.join(skillDir, "SKILL.md"), "utf8");
|
|
1143
1170
|
manifest = parseFrontmatter(skillMarkdown);
|
|
1144
1171
|
} catch {
|
|
1145
1172
|
issues.push(issue("error", "missing_skill_md", "BBS package must contain top-level SKILL.md."));
|
|
@@ -1226,7 +1253,7 @@ async function lintBusinessSkillDirectory(skillDir, options = {}) {
|
|
|
1226
1253
|
}
|
|
1227
1254
|
async function lintBusinessSkillZip(zipPath, options = {}) {
|
|
1228
1255
|
try {
|
|
1229
|
-
const buffer = await
|
|
1256
|
+
const buffer = await readFile4(zipPath);
|
|
1230
1257
|
const dir = await zipDirectoryToTemp(buffer, "bbs-lint");
|
|
1231
1258
|
return lintBusinessSkillDirectory(dir, options);
|
|
1232
1259
|
} catch (error) {
|
|
@@ -1247,7 +1274,7 @@ async function runBusinessSkillGate(options) {
|
|
|
1247
1274
|
let skillMarkdown = "";
|
|
1248
1275
|
let config;
|
|
1249
1276
|
try {
|
|
1250
|
-
skillMarkdown = await
|
|
1277
|
+
skillMarkdown = await readFile4(path2.join(options.skillDir, "SKILL.md"), "utf8");
|
|
1251
1278
|
} catch {
|
|
1252
1279
|
errors.push(issue("error", "missing_skill_md", "Installed BBS is missing SKILL.md."));
|
|
1253
1280
|
}
|
|
@@ -1410,7 +1437,7 @@ async function buildCatalogSkill(skills) {
|
|
|
1410
1437
|
|
|
1411
1438
|
// src/commands/bbs.ts
|
|
1412
1439
|
async function zipPayload(zipPath) {
|
|
1413
|
-
const buffer = await
|
|
1440
|
+
const buffer = await readFile5(zipPath);
|
|
1414
1441
|
return {
|
|
1415
1442
|
zip_base64: buffer.toString("base64"),
|
|
1416
1443
|
file_name: basename(zipPath)
|
|
@@ -1911,7 +1938,7 @@ function setupSummary(input) {
|
|
|
1911
1938
|
}
|
|
1912
1939
|
|
|
1913
1940
|
// src/core/skills.ts
|
|
1914
|
-
import { mkdir as mkdir3, readFile as
|
|
1941
|
+
import { mkdir as mkdir3, readFile as readFile6, writeFile as writeFile3 } from "fs/promises";
|
|
1915
1942
|
import path3 from "path";
|
|
1916
1943
|
import { fileURLToPath } from "url";
|
|
1917
1944
|
var SKILLS_STAMP_FILE = "skills.stamp";
|
|
@@ -1924,7 +1951,7 @@ function stampPath(configDir = getConfigDir()) {
|
|
|
1924
1951
|
}
|
|
1925
1952
|
async function readSkillsStamp(configDir = getConfigDir()) {
|
|
1926
1953
|
try {
|
|
1927
|
-
return (await
|
|
1954
|
+
return (await readFile6(stampPath(configDir), "utf8")).trim();
|
|
1928
1955
|
} catch {
|
|
1929
1956
|
return "";
|
|
1930
1957
|
}
|
|
@@ -2670,7 +2697,7 @@ async function buildProjectFormPayload(client, flowDetail, form, knownTemplate)
|
|
|
2670
2697
|
}
|
|
2671
2698
|
|
|
2672
2699
|
// src/commands/project.ts
|
|
2673
|
-
function
|
|
2700
|
+
function parseJson(input) {
|
|
2674
2701
|
if (!input) {
|
|
2675
2702
|
return {};
|
|
2676
2703
|
}
|
|
@@ -3063,7 +3090,7 @@ function registerProjectCommands(program2) {
|
|
|
3063
3090
|
page: Number(options.page),
|
|
3064
3091
|
page_size: Number(options.pageSize)
|
|
3065
3092
|
},
|
|
3066
|
-
data:
|
|
3093
|
+
data: parseJson(options.body)
|
|
3067
3094
|
}
|
|
3068
3095
|
);
|
|
3069
3096
|
printResult(options.format, result);
|
|
@@ -3128,11 +3155,11 @@ function registerProjectCommands(program2) {
|
|
|
3128
3155
|
const profile = resolveProfile(config, options.profile);
|
|
3129
3156
|
const client = createApiClient(profile);
|
|
3130
3157
|
const useInteractive = !options.body && options.interactive !== false;
|
|
3131
|
-
let payload =
|
|
3158
|
+
let payload = parseJson(options.body);
|
|
3132
3159
|
if (!options.body) {
|
|
3133
3160
|
const flow = await resolveFlowIdentifiers(client, options, { loadDetail: useInteractive });
|
|
3134
3161
|
const { flowDetail, ...flowIdentifiers } = flow;
|
|
3135
|
-
const extra =
|
|
3162
|
+
const extra = parseJson(options.json);
|
|
3136
3163
|
const form = typeof extra.form === "object" && extra.form !== null && !Array.isArray(extra.form) ? extra.form : {};
|
|
3137
3164
|
let name = options.name;
|
|
3138
3165
|
let projectFormTemplate;
|
|
@@ -3247,7 +3274,7 @@ import { spawn as spawn2 } from "child_process";
|
|
|
3247
3274
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
3248
3275
|
|
|
3249
3276
|
// src/core/recipes.ts
|
|
3250
|
-
import { access, mkdir as mkdir4, readdir, readFile as
|
|
3277
|
+
import { access, mkdir as mkdir4, readdir, readFile as readFile7, writeFile as writeFile4 } from "fs/promises";
|
|
3251
3278
|
import path4 from "path";
|
|
3252
3279
|
var RECIPE_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
3253
3280
|
var TEMPLATE_PATTERN = /{{\s*([a-zA-Z0-9_.-]+)\s*}}/g;
|
|
@@ -3329,7 +3356,7 @@ function parseRecipeDefinition(input) {
|
|
|
3329
3356
|
};
|
|
3330
3357
|
}
|
|
3331
3358
|
async function loadRecipe(recipeDir) {
|
|
3332
|
-
const raw = await
|
|
3359
|
+
const raw = await readFile7(path4.join(recipeDir, "recipe.json"), "utf8");
|
|
3333
3360
|
return parseRecipeDefinition(JSON.parse(raw));
|
|
3334
3361
|
}
|
|
3335
3362
|
async function listRecipes(recipesDir) {
|
|
@@ -3428,7 +3455,7 @@ async function renderArgv(options) {
|
|
|
3428
3455
|
const rendered = [];
|
|
3429
3456
|
for (const token of options.recipe.command.argv) {
|
|
3430
3457
|
if (token.startsWith("@")) {
|
|
3431
|
-
const raw = await
|
|
3458
|
+
const raw = await readFile7(resolveRecipeFile(options.recipeDir, token), "utf8");
|
|
3432
3459
|
rendered.push(renderTemplate(raw, options.variables));
|
|
3433
3460
|
} else {
|
|
3434
3461
|
rendered.push(renderTemplate(token, options.variables));
|
|
@@ -3618,6 +3645,10 @@ var schemaEntries = [
|
|
|
3618
3645
|
{ name: "project.approval-context", description: "Get project form values and ended approval step form values.", method: "GET", path: "/api/project/:id + /api/step/:id" },
|
|
3619
3646
|
{ name: "project.create", description: "Create a project with local form schema validation when form payload is provided.", method: "POST", path: "/api/project" },
|
|
3620
3647
|
{ name: "step.get", description: "Get step detail.", method: "GET", path: "/api/step/:id" },
|
|
3648
|
+
{ name: "step.context", description: "Get safe step processing context before mutation.", method: "GET", path: "/api/project/:id + /api/step/:id + /api/user/current" },
|
|
3649
|
+
{ name: "step.actions", description: "List safe step actions parsed from the flow node.", method: "GET", path: "/api/project/:id + /api/step/:id" },
|
|
3650
|
+
{ name: "step.requirements", description: "List required step inputs before submitting.", method: "GET", path: "/api/project/:id + /api/step/:id" },
|
|
3651
|
+
{ name: "step.submit", description: "Dry-run or submit a step action with safety checks.", method: "PUT", path: "/api/step/:id?action=:action" },
|
|
3621
3652
|
{ name: "bbs.list", description: "List BPMAX Business Skills.", method: "GET", path: "/api/business_skill" },
|
|
3622
3653
|
{ name: "bbs.create", description: "Create a BPMAX Business Skill from a standard skill zip.", method: "POST", path: "/api/business_skill" },
|
|
3623
3654
|
{ name: "bbs.lint", description: "Lint a BPMAX Business Skill package before publish." },
|
|
@@ -3723,6 +3754,403 @@ function registerSetupCommand(program2, deps = {}) {
|
|
|
3723
3754
|
}
|
|
3724
3755
|
|
|
3725
3756
|
// src/commands/step.ts
|
|
3757
|
+
function isRecord7(value) {
|
|
3758
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3759
|
+
}
|
|
3760
|
+
function stringValue(value) {
|
|
3761
|
+
if (value === void 0 || value === null) {
|
|
3762
|
+
return void 0;
|
|
3763
|
+
}
|
|
3764
|
+
const next = String(value).trim();
|
|
3765
|
+
return next ? next : void 0;
|
|
3766
|
+
}
|
|
3767
|
+
function idValue(value) {
|
|
3768
|
+
const next = stringValue(value);
|
|
3769
|
+
return next && /^\d+$/.test(next) ? next : void 0;
|
|
3770
|
+
}
|
|
3771
|
+
function hasMeaningfulValue(value) {
|
|
3772
|
+
if (value === void 0 || value === null) {
|
|
3773
|
+
return false;
|
|
3774
|
+
}
|
|
3775
|
+
if (typeof value === "string") {
|
|
3776
|
+
return value.trim().length > 0;
|
|
3777
|
+
}
|
|
3778
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
3779
|
+
return true;
|
|
3780
|
+
}
|
|
3781
|
+
if (Array.isArray(value)) {
|
|
3782
|
+
return value.some(hasMeaningfulValue);
|
|
3783
|
+
}
|
|
3784
|
+
if (isRecord7(value)) {
|
|
3785
|
+
return Object.values(value).some(hasMeaningfulValue);
|
|
3786
|
+
}
|
|
3787
|
+
return false;
|
|
3788
|
+
}
|
|
3789
|
+
function isEmptyValue2(value) {
|
|
3790
|
+
return value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0;
|
|
3791
|
+
}
|
|
3792
|
+
function projectIdOfStep(step) {
|
|
3793
|
+
const nestedProjectId = isRecord7(step.project) ? step.project.id : void 0;
|
|
3794
|
+
return idValue(step.project_id ?? step.projectId ?? nestedProjectId);
|
|
3795
|
+
}
|
|
3796
|
+
function stepFlowNodeId(step) {
|
|
3797
|
+
return stringValue(step.flow_step_id ?? step.flowStepId ?? step.flow_node_id ?? step.flowNodeId);
|
|
3798
|
+
}
|
|
3799
|
+
function isStepFinished(step) {
|
|
3800
|
+
if (step.real_end_time || step.end_time) {
|
|
3801
|
+
return true;
|
|
3802
|
+
}
|
|
3803
|
+
const status = step.status;
|
|
3804
|
+
if (typeof status === "string") {
|
|
3805
|
+
return ["finished", "done", "completed", "end", "ended"].includes(status.toLowerCase());
|
|
3806
|
+
}
|
|
3807
|
+
if (typeof status === "number") {
|
|
3808
|
+
return [3, 4, 5].includes(status);
|
|
3809
|
+
}
|
|
3810
|
+
return false;
|
|
3811
|
+
}
|
|
3812
|
+
function collectRecords(value, output = [], seen = /* @__PURE__ */ new Set()) {
|
|
3813
|
+
if (!value || seen.has(value)) {
|
|
3814
|
+
return output;
|
|
3815
|
+
}
|
|
3816
|
+
seen.add(value);
|
|
3817
|
+
if (Array.isArray(value)) {
|
|
3818
|
+
value.forEach((item) => collectRecords(item, output, seen));
|
|
3819
|
+
return output;
|
|
3820
|
+
}
|
|
3821
|
+
if (!isRecord7(value)) {
|
|
3822
|
+
return output;
|
|
3823
|
+
}
|
|
3824
|
+
output.push(value);
|
|
3825
|
+
for (const child of Object.values(value)) {
|
|
3826
|
+
if (Array.isArray(child) || isRecord7(child)) {
|
|
3827
|
+
collectRecords(child, output, seen);
|
|
3828
|
+
}
|
|
3829
|
+
}
|
|
3830
|
+
return output;
|
|
3831
|
+
}
|
|
3832
|
+
function findFlowNode(project, step) {
|
|
3833
|
+
const flowStepId = stepFlowNodeId(step);
|
|
3834
|
+
if (!flowStepId) {
|
|
3835
|
+
return null;
|
|
3836
|
+
}
|
|
3837
|
+
const candidates = [
|
|
3838
|
+
project.flow,
|
|
3839
|
+
project.flow_data,
|
|
3840
|
+
project.flowData,
|
|
3841
|
+
project.flow_detail,
|
|
3842
|
+
project.flowDetail,
|
|
3843
|
+
project.current_flow,
|
|
3844
|
+
project.currentFlow,
|
|
3845
|
+
project.config
|
|
3846
|
+
];
|
|
3847
|
+
for (const candidate of candidates) {
|
|
3848
|
+
const match = collectRecords(candidate).find((item) => stringValue(item.id) === flowStepId);
|
|
3849
|
+
if (match) {
|
|
3850
|
+
return match;
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
return null;
|
|
3854
|
+
}
|
|
3855
|
+
function parseConfiguredActions(value, action, type) {
|
|
3856
|
+
if (!Array.isArray(value)) {
|
|
3857
|
+
return [];
|
|
3858
|
+
}
|
|
3859
|
+
return value.map((item) => {
|
|
3860
|
+
const raw = String(item ?? "");
|
|
3861
|
+
const [label, targetStep] = raw.split("|");
|
|
3862
|
+
return {
|
|
3863
|
+
action,
|
|
3864
|
+
type,
|
|
3865
|
+
label: label?.trim() || (action === "approve" ? "\u901A\u8FC7" : "\u62D2\u7EDD"),
|
|
3866
|
+
...targetStep?.trim() ? { target_step: targetStep.trim() } : {},
|
|
3867
|
+
requires_comment: action === "refuse",
|
|
3868
|
+
requires_attachment: false,
|
|
3869
|
+
requires_next_owner: false
|
|
3870
|
+
};
|
|
3871
|
+
});
|
|
3872
|
+
}
|
|
3873
|
+
function buildStepActions(flowNode) {
|
|
3874
|
+
const approveActions = parseConfiguredActions(flowNode?.approve_actions, "approve", "pass");
|
|
3875
|
+
const refuseActions = parseConfiguredActions(flowNode?.approve_fail_actions, "refuse", "refuse");
|
|
3876
|
+
const actions = [...approveActions, ...refuseActions];
|
|
3877
|
+
const hasApprove = actions.some((item) => item.action === "approve");
|
|
3878
|
+
const hasRefuse = actions.some((item) => item.action === "refuse");
|
|
3879
|
+
if (!hasApprove) {
|
|
3880
|
+
actions.unshift({
|
|
3881
|
+
action: "approve",
|
|
3882
|
+
type: "pass",
|
|
3883
|
+
label: "\u901A\u8FC7",
|
|
3884
|
+
requires_comment: false,
|
|
3885
|
+
requires_attachment: false,
|
|
3886
|
+
requires_next_owner: false
|
|
3887
|
+
});
|
|
3888
|
+
}
|
|
3889
|
+
if (!hasRefuse) {
|
|
3890
|
+
actions.push({
|
|
3891
|
+
action: "refuse",
|
|
3892
|
+
type: "refuse",
|
|
3893
|
+
label: "\u62D2\u7EDD",
|
|
3894
|
+
requires_comment: true,
|
|
3895
|
+
requires_attachment: false,
|
|
3896
|
+
requires_next_owner: false
|
|
3897
|
+
});
|
|
3898
|
+
}
|
|
3899
|
+
return actions.map((item) => ({
|
|
3900
|
+
...item,
|
|
3901
|
+
requires_attachment: Array.isArray(flowNode?.attachment_required) && flowNode.attachment_required.length > 0,
|
|
3902
|
+
requires_next_owner: Array.isArray(flowNode?.arrange_owner_steps) && flowNode.arrange_owner_steps.length > 0
|
|
3903
|
+
}));
|
|
3904
|
+
}
|
|
3905
|
+
function formListOfStep(step) {
|
|
3906
|
+
const values = [step.formList, step.forms, step.metaForm];
|
|
3907
|
+
return values.filter(hasMeaningfulValue);
|
|
3908
|
+
}
|
|
3909
|
+
function unwrapFormValue(value) {
|
|
3910
|
+
if (!isRecord7(value)) {
|
|
3911
|
+
return value;
|
|
3912
|
+
}
|
|
3913
|
+
if ("value" in value && Object.keys(value).length <= 3) {
|
|
3914
|
+
return unwrapFormValue(value.value);
|
|
3915
|
+
}
|
|
3916
|
+
return value;
|
|
3917
|
+
}
|
|
3918
|
+
function collectFormValues(value, output = {}, seen = /* @__PURE__ */ new Set()) {
|
|
3919
|
+
if (!value || seen.has(value)) {
|
|
3920
|
+
return output;
|
|
3921
|
+
}
|
|
3922
|
+
seen.add(value);
|
|
3923
|
+
if (Array.isArray(value)) {
|
|
3924
|
+
value.forEach((item) => collectFormValues(item, output, seen));
|
|
3925
|
+
return output;
|
|
3926
|
+
}
|
|
3927
|
+
if (!isRecord7(value)) {
|
|
3928
|
+
return output;
|
|
3929
|
+
}
|
|
3930
|
+
const key = stringValue(value.key ?? value.field_key ?? value.fieldKey ?? value.name);
|
|
3931
|
+
if (key && "value" in value) {
|
|
3932
|
+
const nextValue = unwrapFormValue(value.value);
|
|
3933
|
+
if (hasMeaningfulValue(nextValue)) {
|
|
3934
|
+
output[key] = nextValue;
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3937
|
+
for (const child of Object.values(value)) {
|
|
3938
|
+
if (Array.isArray(child) || isRecord7(child)) {
|
|
3939
|
+
collectFormValues(child, output, seen);
|
|
3940
|
+
}
|
|
3941
|
+
}
|
|
3942
|
+
return output;
|
|
3943
|
+
}
|
|
3944
|
+
function stepRequirementSource(step, flowNode) {
|
|
3945
|
+
return {
|
|
3946
|
+
step_form_template: step.form_template ?? step.formTemplate ?? step.form_template_data ?? step.formTemplateData,
|
|
3947
|
+
step_form_schema: step.form_schema ?? step.formSchema,
|
|
3948
|
+
step_forms: step.forms ?? step.formList ?? step.metaForm,
|
|
3949
|
+
flow_node_step_form_template: flowNode?.form_template ?? flowNode?.formTemplate ?? flowNode?.step_form_template ?? flowNode?.stepFormTemplate,
|
|
3950
|
+
flow_node_form_schema: flowNode?.form_schema ?? flowNode?.formSchema
|
|
3951
|
+
};
|
|
3952
|
+
}
|
|
3953
|
+
function buildSubmitPayloadTemplate(fields) {
|
|
3954
|
+
const template = {};
|
|
3955
|
+
for (const field of fields) {
|
|
3956
|
+
if (field.hidden) {
|
|
3957
|
+
continue;
|
|
3958
|
+
}
|
|
3959
|
+
template[field.key] = isSubFormField(field) ? [
|
|
3960
|
+
Object.fromEntries((field.children ?? []).filter((child) => !child.hidden).map((child) => [child.key, null]))
|
|
3961
|
+
] : null;
|
|
3962
|
+
}
|
|
3963
|
+
return template;
|
|
3964
|
+
}
|
|
3965
|
+
function fieldWithValue(field, value) {
|
|
3966
|
+
const missing = Boolean(field.required && !field.hidden && isEmptyValue2(value));
|
|
3967
|
+
return {
|
|
3968
|
+
...field,
|
|
3969
|
+
...value !== void 0 ? { value } : {},
|
|
3970
|
+
missing
|
|
3971
|
+
};
|
|
3972
|
+
}
|
|
3973
|
+
function collectMissingRequiredInputs(fields, values) {
|
|
3974
|
+
const missing = [];
|
|
3975
|
+
for (const field of fields) {
|
|
3976
|
+
const value = values[field.key];
|
|
3977
|
+
if (field.required && !field.hidden && isEmptyValue2(value)) {
|
|
3978
|
+
missing.push(fieldWithValue(field, value));
|
|
3979
|
+
continue;
|
|
3980
|
+
}
|
|
3981
|
+
if (!isSubFormField(field) || !Array.isArray(value) || !field.children?.length) {
|
|
3982
|
+
continue;
|
|
3983
|
+
}
|
|
3984
|
+
value.forEach((row, index) => {
|
|
3985
|
+
if (!isRecord7(row)) {
|
|
3986
|
+
return;
|
|
3987
|
+
}
|
|
3988
|
+
for (const child of field.children ?? []) {
|
|
3989
|
+
const childValue = row[child.key];
|
|
3990
|
+
if (child.required && !child.hidden && isEmptyValue2(childValue)) {
|
|
3991
|
+
missing.push(fieldWithValue({ ...child, key: `${field.key}[${index}].${child.key}` }, childValue));
|
|
3992
|
+
}
|
|
3993
|
+
}
|
|
3994
|
+
});
|
|
3995
|
+
}
|
|
3996
|
+
return missing;
|
|
3997
|
+
}
|
|
3998
|
+
function buildStepRequirements(step, flowNode, submitData = {}) {
|
|
3999
|
+
const fields = extractFormFields(stepRequirementSource(step, flowNode));
|
|
4000
|
+
const providedValues = {
|
|
4001
|
+
...collectFormValues(step.formList),
|
|
4002
|
+
...collectFormValues(step.forms),
|
|
4003
|
+
...collectFormValues(step.metaForm),
|
|
4004
|
+
...extractSubmitInputValues(submitData)
|
|
4005
|
+
};
|
|
4006
|
+
const requirementFields = fields.map((field) => fieldWithValue(field, providedValues[field.key]));
|
|
4007
|
+
const missingRequiredInputs = collectMissingRequiredInputs(fields, providedValues);
|
|
4008
|
+
return {
|
|
4009
|
+
fields: requirementFields,
|
|
4010
|
+
required_inputs: requirementFields.filter((field) => field.required && !field.hidden),
|
|
4011
|
+
optional_inputs: requirementFields.filter((field) => !field.required && !field.hidden),
|
|
4012
|
+
missing_required_inputs: missingRequiredInputs,
|
|
4013
|
+
provided_values: providedValues,
|
|
4014
|
+
submit_payload_template: buildSubmitPayloadTemplate(fields),
|
|
4015
|
+
can_submit: missingRequiredInputs.length === 0,
|
|
4016
|
+
blocking_reasons: missingRequiredInputs.length > 0 ? ["missing_required_step_inputs"] : []
|
|
4017
|
+
};
|
|
4018
|
+
}
|
|
4019
|
+
function buildFormSummary(project, step) {
|
|
4020
|
+
const projectFormEmpty = !hasMeaningfulValue(project.metaForm ?? project.project_form ?? project.projectForm);
|
|
4021
|
+
const stepFormsEmpty = formListOfStep(step).length === 0;
|
|
4022
|
+
return {
|
|
4023
|
+
project_form_empty: projectFormEmpty,
|
|
4024
|
+
step_forms_empty: stepFormsEmpty,
|
|
4025
|
+
has_identity_evidence: !projectFormEmpty || !stepFormsEmpty
|
|
4026
|
+
};
|
|
4027
|
+
}
|
|
4028
|
+
function ownerIdsFromStep(step) {
|
|
4029
|
+
const owners = [
|
|
4030
|
+
step.owner_id,
|
|
4031
|
+
step.ownerId,
|
|
4032
|
+
step.user_id,
|
|
4033
|
+
step.userId,
|
|
4034
|
+
...Array.isArray(step.owners) ? step.owners : [],
|
|
4035
|
+
...Array.isArray(step.owner_list) ? step.owner_list : [],
|
|
4036
|
+
...Array.isArray(step.step_owners) ? step.step_owners : []
|
|
4037
|
+
];
|
|
4038
|
+
const ids = /* @__PURE__ */ new Set();
|
|
4039
|
+
for (const owner of owners) {
|
|
4040
|
+
if (isRecord7(owner)) {
|
|
4041
|
+
const id = idValue(owner.owner_id ?? owner.user_id ?? owner.id);
|
|
4042
|
+
if (id) {
|
|
4043
|
+
ids.add(id);
|
|
4044
|
+
}
|
|
4045
|
+
} else {
|
|
4046
|
+
const id = idValue(owner);
|
|
4047
|
+
if (id) {
|
|
4048
|
+
ids.add(id);
|
|
4049
|
+
}
|
|
4050
|
+
}
|
|
4051
|
+
}
|
|
4052
|
+
return [...ids];
|
|
4053
|
+
}
|
|
4054
|
+
function checkCurrentUserCanProcess(step, currentUser) {
|
|
4055
|
+
const ownerIds = ownerIdsFromStep(step);
|
|
4056
|
+
if (ownerIds.length === 0) {
|
|
4057
|
+
return {
|
|
4058
|
+
current_user_can_process: null,
|
|
4059
|
+
current_user_reason: "Step owner data is unavailable in step detail; verify my-step before mutating."
|
|
4060
|
+
};
|
|
4061
|
+
}
|
|
4062
|
+
const currentUserId = currentUser ? idValue(currentUser.id ?? currentUser.user_id ?? currentUser.owner_id) : void 0;
|
|
4063
|
+
if (!currentUserId) {
|
|
4064
|
+
return {
|
|
4065
|
+
current_user_can_process: false,
|
|
4066
|
+
current_user_reason: "Current user id is unavailable."
|
|
4067
|
+
};
|
|
4068
|
+
}
|
|
4069
|
+
return {
|
|
4070
|
+
current_user_can_process: ownerIds.includes(currentUserId),
|
|
4071
|
+
current_user_reason: ownerIds.includes(currentUserId) ? "Current user is listed as a step owner." : "Current user is not listed as a step owner."
|
|
4072
|
+
};
|
|
4073
|
+
}
|
|
4074
|
+
async function buildStepContext(profile, client, stepId, projectId) {
|
|
4075
|
+
const [project, step, currentUser] = await Promise.all([
|
|
4076
|
+
apiRequest(client, "GET", `/project/${projectId}`),
|
|
4077
|
+
apiRequest(client, "GET", `/step/${stepId}`),
|
|
4078
|
+
apiRequest(client, "GET", "/user/current").catch(() => null)
|
|
4079
|
+
]);
|
|
4080
|
+
const actualProjectId = projectIdOfStep(step);
|
|
4081
|
+
if (actualProjectId && actualProjectId !== projectId) {
|
|
4082
|
+
throw new Error(`Step ${stepId} belongs to project ${actualProjectId}, not project ${projectId}.`);
|
|
4083
|
+
}
|
|
4084
|
+
const flowNode = findFlowNode(project, step);
|
|
4085
|
+
const formSummary = buildFormSummary(project, step);
|
|
4086
|
+
const requirements = buildStepRequirements(step, flowNode);
|
|
4087
|
+
const identityUnverified = !formSummary.has_identity_evidence;
|
|
4088
|
+
const userCheck = checkCurrentUserCanProcess(step, currentUser);
|
|
4089
|
+
const stepFinished = isStepFinished(step);
|
|
4090
|
+
const riskWarnings = [];
|
|
4091
|
+
if (identityUnverified) {
|
|
4092
|
+
riskWarnings.push("No project or step form evidence was returned; do not advance solely from ES or attachment text matches.");
|
|
4093
|
+
}
|
|
4094
|
+
if (stepFinished) {
|
|
4095
|
+
riskWarnings.push("Step appears to be finished.");
|
|
4096
|
+
}
|
|
4097
|
+
if (userCheck.current_user_can_process === false) {
|
|
4098
|
+
riskWarnings.push(userCheck.current_user_reason);
|
|
4099
|
+
}
|
|
4100
|
+
if (!requirements.can_submit) {
|
|
4101
|
+
riskWarnings.push(`Missing required step input(s): ${requirements.missing_required_inputs.map((field) => field.key).join(", ")}`);
|
|
4102
|
+
}
|
|
4103
|
+
return {
|
|
4104
|
+
project_id: projectId,
|
|
4105
|
+
step_id: stepId,
|
|
4106
|
+
project,
|
|
4107
|
+
step,
|
|
4108
|
+
current_flow_node: flowNode,
|
|
4109
|
+
actions: buildStepActions(flowNode),
|
|
4110
|
+
url: buildBpmaxUrl(profile, "project-step", { projectId, stepId }).url,
|
|
4111
|
+
current_user: currentUser,
|
|
4112
|
+
...userCheck,
|
|
4113
|
+
step_finished: stepFinished,
|
|
4114
|
+
form_summary: formSummary,
|
|
4115
|
+
requirements,
|
|
4116
|
+
identity_unverified: identityUnverified,
|
|
4117
|
+
risk_warnings: riskWarnings
|
|
4118
|
+
};
|
|
4119
|
+
}
|
|
4120
|
+
async function loadSubmitData(data) {
|
|
4121
|
+
if (!data) {
|
|
4122
|
+
return {};
|
|
4123
|
+
}
|
|
4124
|
+
return parseJsonInput(data, "--data");
|
|
4125
|
+
}
|
|
4126
|
+
var SUBMIT_NON_FORM_KEYS = /* @__PURE__ */ new Set([
|
|
4127
|
+
"project_id",
|
|
4128
|
+
"projectId",
|
|
4129
|
+
"target_step",
|
|
4130
|
+
"targetStep",
|
|
4131
|
+
"action",
|
|
4132
|
+
"action_label",
|
|
4133
|
+
"actionLabel",
|
|
4134
|
+
"step_comments",
|
|
4135
|
+
"stepComments",
|
|
4136
|
+
"comments",
|
|
4137
|
+
"urgency"
|
|
4138
|
+
]);
|
|
4139
|
+
function extractSubmitInputValues(data) {
|
|
4140
|
+
const candidates = [data.form, data.form_data, data.formData, data.fields, data.values];
|
|
4141
|
+
const values = {};
|
|
4142
|
+
for (const candidate of candidates) {
|
|
4143
|
+
if (isRecord7(candidate)) {
|
|
4144
|
+
Object.assign(values, candidate);
|
|
4145
|
+
}
|
|
4146
|
+
}
|
|
4147
|
+
for (const [key, value] of Object.entries(data)) {
|
|
4148
|
+
if (!SUBMIT_NON_FORM_KEYS.has(key) && !isRecord7(value) && !Array.isArray(value)) {
|
|
4149
|
+
values[key] = value;
|
|
4150
|
+
}
|
|
4151
|
+
}
|
|
4152
|
+
return values;
|
|
4153
|
+
}
|
|
3726
4154
|
function registerStepCommands(program2) {
|
|
3727
4155
|
const step = program2.command("step").description("Step commands");
|
|
3728
4156
|
step.command("get <id>").description("Get step detail").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (id, options) => {
|
|
@@ -3735,10 +4163,113 @@ function registerStepCommands(program2) {
|
|
|
3735
4163
|
);
|
|
3736
4164
|
printResult(options.format, result);
|
|
3737
4165
|
});
|
|
4166
|
+
step.command("context <id>").description("Get safe step processing context").requiredOption("--project-id <projectId>", "Project id").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (id, options) => {
|
|
4167
|
+
const config = await loadConfig();
|
|
4168
|
+
const profile = resolveProfile(config, options.profile);
|
|
4169
|
+
const client = createApiClient(profile);
|
|
4170
|
+
const result = await buildStepContext(profile, client, id, options.projectId);
|
|
4171
|
+
printResult(options.format, result);
|
|
4172
|
+
});
|
|
4173
|
+
step.command("actions <id>").description("List safe step actions").requiredOption("--project-id <projectId>", "Project id").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (id, options) => {
|
|
4174
|
+
const config = await loadConfig();
|
|
4175
|
+
const profile = resolveProfile(config, options.profile);
|
|
4176
|
+
const client = createApiClient(profile);
|
|
4177
|
+
const context = await buildStepContext(profile, client, id, options.projectId);
|
|
4178
|
+
printResult(options.format, {
|
|
4179
|
+
project_id: context.project_id,
|
|
4180
|
+
step_id: context.step_id,
|
|
4181
|
+
current_flow_node: context.current_flow_node,
|
|
4182
|
+
actions: context.actions,
|
|
4183
|
+
identity_unverified: context.identity_unverified,
|
|
4184
|
+
risk_warnings: context.risk_warnings
|
|
4185
|
+
});
|
|
4186
|
+
});
|
|
4187
|
+
step.command("requirements <id>").description("List required step inputs before submitting").requiredOption("--project-id <projectId>", "Project id").option("--data <json>", "Additional submit payload JSON or @file").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (id, options) => {
|
|
4188
|
+
const config = await loadConfig();
|
|
4189
|
+
const profile = resolveProfile(config, options.profile);
|
|
4190
|
+
const client = createApiClient(profile);
|
|
4191
|
+
const context = await buildStepContext(profile, client, id, options.projectId);
|
|
4192
|
+
const data = await loadSubmitData(options.data);
|
|
4193
|
+
const requirements = buildStepRequirements(context.step, context.current_flow_node, data);
|
|
4194
|
+
printResult(options.format, {
|
|
4195
|
+
project_id: context.project_id,
|
|
4196
|
+
step_id: context.step_id,
|
|
4197
|
+
url: context.url,
|
|
4198
|
+
requirements
|
|
4199
|
+
});
|
|
4200
|
+
});
|
|
4201
|
+
step.command("submit <id>").description("Safely submit a step action").requiredOption("--project-id <projectId>", "Project id").requiredOption("--action <action>", "Step action, e.g. approve/refuse").option("--label <label>", "Action label").option("--target-step <targetStep>", "Target flow step id").option("--data <json>", "Additional submit payload JSON or @file").option("--comments <comments>", "Step comments").option("--urgency <urgency>", "Urgency value", "1").option("--confirm <confirmation>", "Actually submit the step action").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (id, options) => {
|
|
4202
|
+
const config = await loadConfig();
|
|
4203
|
+
const profile = resolveProfile(config, options.profile);
|
|
4204
|
+
const client = createApiClient(profile);
|
|
4205
|
+
const context = await buildStepContext(profile, client, id, options.projectId);
|
|
4206
|
+
const data = await loadSubmitData(options.data);
|
|
4207
|
+
const requirements = buildStepRequirements(context.step, context.current_flow_node, data);
|
|
4208
|
+
const payload = {
|
|
4209
|
+
...data,
|
|
4210
|
+
project_id: Number(options.projectId),
|
|
4211
|
+
...options.targetStep ? { target_step: options.targetStep } : {},
|
|
4212
|
+
action: options.action,
|
|
4213
|
+
...options.label ? { action_label: options.label } : {},
|
|
4214
|
+
...options.comments ? { step_comments: options.comments } : {},
|
|
4215
|
+
urgency: Number(options.urgency)
|
|
4216
|
+
};
|
|
4217
|
+
const dryRun = !options.confirm;
|
|
4218
|
+
const request = {
|
|
4219
|
+
method: "PUT",
|
|
4220
|
+
path: `/step/${id}`,
|
|
4221
|
+
params: { action: options.action },
|
|
4222
|
+
data: payload
|
|
4223
|
+
};
|
|
4224
|
+
if (dryRun) {
|
|
4225
|
+
printResult(options.format, {
|
|
4226
|
+
ok: true,
|
|
4227
|
+
dry_run: true,
|
|
4228
|
+
request,
|
|
4229
|
+
context: {
|
|
4230
|
+
project_id: context.project_id,
|
|
4231
|
+
step_id: context.step_id,
|
|
4232
|
+
url: context.url,
|
|
4233
|
+
identity_unverified: context.identity_unverified,
|
|
4234
|
+
current_user_can_process: context.current_user_can_process,
|
|
4235
|
+
step_finished: context.step_finished,
|
|
4236
|
+
requirements,
|
|
4237
|
+
risk_warnings: context.risk_warnings
|
|
4238
|
+
},
|
|
4239
|
+
next_command_hint: requirements.can_submit ? "Re-run with --confirm after verifying project identity, target action, and payload." : "Fill missing required step input(s) in --data before confirming."
|
|
4240
|
+
});
|
|
4241
|
+
return;
|
|
4242
|
+
}
|
|
4243
|
+
if (context.identity_unverified) {
|
|
4244
|
+
throw new Error("Refusing to submit: project identity is unverified because project and step form evidence is empty.");
|
|
4245
|
+
}
|
|
4246
|
+
if (context.step_finished) {
|
|
4247
|
+
throw new Error("Refusing to submit: step appears to be finished.");
|
|
4248
|
+
}
|
|
4249
|
+
if (context.current_user_can_process === false) {
|
|
4250
|
+
throw new Error(`Refusing to submit: ${context.current_user_reason}`);
|
|
4251
|
+
}
|
|
4252
|
+
if (!requirements.can_submit) {
|
|
4253
|
+
throw new Error(`Refusing to submit: missing required step input(s): ${requirements.missing_required_inputs.map((field) => field.key).join(", ")}`);
|
|
4254
|
+
}
|
|
4255
|
+
const result = await apiRequest(client, "PUT", `/step/${id}`, {
|
|
4256
|
+
params: { action: options.action },
|
|
4257
|
+
data: payload
|
|
4258
|
+
});
|
|
4259
|
+
printResult(options.format, {
|
|
4260
|
+
ok: true,
|
|
4261
|
+
submitted: true,
|
|
4262
|
+
request,
|
|
4263
|
+
result,
|
|
4264
|
+
project_id: options.projectId,
|
|
4265
|
+
step_id: id,
|
|
4266
|
+
url: context.url
|
|
4267
|
+
});
|
|
4268
|
+
});
|
|
3738
4269
|
}
|
|
3739
4270
|
|
|
3740
4271
|
// src/core/update.ts
|
|
3741
|
-
import { access as access2, mkdir as mkdir5, readFile as
|
|
4272
|
+
import { access as access2, mkdir as mkdir5, readFile as readFile8, realpath, writeFile as writeFile5 } from "fs/promises";
|
|
3742
4273
|
import path5 from "path";
|
|
3743
4274
|
var DEFAULT_REGISTRY_URL = "https://registry.npmjs.org/";
|
|
3744
4275
|
var UPDATE_STATE_FILE = "update-state.json";
|
|
@@ -3855,7 +4386,7 @@ function updateStatePath(configDir = getConfigDir()) {
|
|
|
3855
4386
|
}
|
|
3856
4387
|
async function readUpdateState(configDir) {
|
|
3857
4388
|
try {
|
|
3858
|
-
const raw = await
|
|
4389
|
+
const raw = await readFile8(updateStatePath(configDir), "utf8");
|
|
3859
4390
|
const parsed = JSON.parse(raw);
|
|
3860
4391
|
if (typeof parsed.latest_version !== "string" || typeof parsed.checked_at !== "number") {
|
|
3861
4392
|
return null;
|