bpmax-cli 0.1.44-beta.10 → 0.1.44-beta.12
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/bin.js +165 -4
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/skills/bpmax-e2e-flow-test-operator/SKILL.md +10 -0
- package/skills/bpmax-flow-template-editor/SKILL.md +26 -1
- package/skills/bpmax-flow-template-editor/references/project-create-runtime-gotchas.md +54 -2
- package/skills/bpmax-flow-template-editor/references/script-review-hard-rules.md +2 -0
- package/skills/bpmax-list-template-editor/SKILL.md +6 -0
- package/skills/bpmax-project-detail-template-editor/SKILL.md +6 -0
package/dist/bin.js
CHANGED
|
@@ -444,7 +444,7 @@ function normalizePath2(path9) {
|
|
|
444
444
|
// package.json
|
|
445
445
|
var package_default = {
|
|
446
446
|
name: "bpmax-cli",
|
|
447
|
-
version: "0.1.44-beta.
|
|
447
|
+
version: "0.1.44-beta.12",
|
|
448
448
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
449
449
|
type: "module",
|
|
450
450
|
bin: {
|
|
@@ -804,14 +804,24 @@ function createApiClient(profile) {
|
|
|
804
804
|
$workspace: normalizeWorkspaceForApi(String(workspaceParam)),
|
|
805
805
|
$language: config.params?.$language ?? profile.config.language
|
|
806
806
|
};
|
|
807
|
-
|
|
807
|
+
const executionToken = process.env.BPMAX_EXECUTION_TOKEN;
|
|
808
|
+
if (executionToken || profile.config.api_key) {
|
|
808
809
|
const headers = AxiosHeaders.from(config.headers || {});
|
|
809
|
-
headers.set("Authorization", `Bearer ${profile.config.api_key}`);
|
|
810
|
+
headers.set("Authorization", `Bearer ${executionToken || profile.config.api_key}`);
|
|
810
811
|
if (profile.config.terminal_id) {
|
|
811
812
|
headers.set("X-BPMAX-CLI-Terminal-Id", profile.config.terminal_id);
|
|
812
813
|
}
|
|
813
814
|
headers.set("X-BPMAX-CLI-Version", VERSION);
|
|
814
815
|
headers.set("X-BPMAX-CLI-Command", commandHeaderSummary());
|
|
816
|
+
if (process.env.BPMAX_AI_ACTION_KEY) {
|
|
817
|
+
headers.set("X-BPMAX-AI-Action-Key", process.env.BPMAX_AI_ACTION_KEY);
|
|
818
|
+
}
|
|
819
|
+
if (process.env.BPMAX_AI_SESSION_KEY) {
|
|
820
|
+
headers.set("X-BPMAX-AI-Session-Key", process.env.BPMAX_AI_SESSION_KEY);
|
|
821
|
+
}
|
|
822
|
+
if (process.env.BPMAX_AI_TRACE_ID) {
|
|
823
|
+
headers.set("X-BPMAX-AI-Trace-Id", process.env.BPMAX_AI_TRACE_ID);
|
|
824
|
+
}
|
|
815
825
|
config.headers = headers;
|
|
816
826
|
}
|
|
817
827
|
return config;
|
|
@@ -3096,6 +3106,133 @@ function validateFlowTemplateFormDrivenCreateBaseline(value, errors, options = {
|
|
|
3096
3106
|
}
|
|
3097
3107
|
throw new Error(message);
|
|
3098
3108
|
}
|
|
3109
|
+
function validateFlowTemplateProjectAfterCreatePath(value, errors) {
|
|
3110
|
+
const data = isRecord3(value.data) ? value.data : {};
|
|
3111
|
+
const meta = isRecord3(data.meta) ? data.meta : {};
|
|
3112
|
+
const script = meta.project_after_create_path;
|
|
3113
|
+
if (script === void 0 || script === null || script === "") {
|
|
3114
|
+
return;
|
|
3115
|
+
}
|
|
3116
|
+
const message = "data.meta.project_after_create_path must be a script string starting with `return` so the project create page receives a route path.";
|
|
3117
|
+
if (typeof script !== "string" || !script.trim().startsWith("return")) {
|
|
3118
|
+
if (errors) {
|
|
3119
|
+
errors.push(message);
|
|
3120
|
+
return;
|
|
3121
|
+
}
|
|
3122
|
+
throw new Error(message);
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
function validateFlowTemplateStandardPageCreateFormTemplate(value, errors) {
|
|
3126
|
+
const data = isRecord3(value.data) ? value.data : {};
|
|
3127
|
+
const meta = isRecord3(data.meta) ? data.meta : {};
|
|
3128
|
+
if (meta.project_create_mode !== "standard" || meta.project_create_standard_mode !== "page") {
|
|
3129
|
+
return;
|
|
3130
|
+
}
|
|
3131
|
+
if (!isEmptyTemplateReference(meta.form_template)) {
|
|
3132
|
+
return;
|
|
3133
|
+
}
|
|
3134
|
+
const nodes = Array.isArray(data.nodes) ? data.nodes : [];
|
|
3135
|
+
const nodeNames = nodes.filter(isRecord3).filter((node) => !isEmptyTemplateReference(node.form_template)).map((node, index) => {
|
|
3136
|
+
const name = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${index}]`;
|
|
3137
|
+
return name;
|
|
3138
|
+
});
|
|
3139
|
+
if (nodeNames.length === 0) {
|
|
3140
|
+
return;
|
|
3141
|
+
}
|
|
3142
|
+
const message = `data.meta.form_template is required for standard page project create when node.form_template is configured; project create pages load the create form from meta.form_template, not from node.form_template (${nodeNames.join(", ")}).`;
|
|
3143
|
+
if (errors) {
|
|
3144
|
+
errors.push(message);
|
|
3145
|
+
return;
|
|
3146
|
+
}
|
|
3147
|
+
throw new Error(message);
|
|
3148
|
+
}
|
|
3149
|
+
function looksLikeParseEvalFunctionBody(script) {
|
|
3150
|
+
const text5 = script.trim();
|
|
3151
|
+
if (!text5) {
|
|
3152
|
+
return false;
|
|
3153
|
+
}
|
|
3154
|
+
const firstToken = text5.split(/\s+/, 1)[0] || "";
|
|
3155
|
+
if (/^(return|if|const|let|var|try|for|while|switch|async|await|function|\{)/.test(firstToken)) {
|
|
3156
|
+
return true;
|
|
3157
|
+
}
|
|
3158
|
+
return text5.startsWith("(") && (text5.includes("=>") || text5.includes("function"));
|
|
3159
|
+
}
|
|
3160
|
+
function addCodeModeMessageScriptError(errors, pathName) {
|
|
3161
|
+
errors.push(
|
|
3162
|
+
`${pathName} is code-mode message content but is not a parseEvalFunction body; wrap literal text as a JS return script, for example: return "\u8BF7\u5904\u7406...";`
|
|
3163
|
+
);
|
|
3164
|
+
}
|
|
3165
|
+
function validateCodeModeMessageScript(errors, pathName, value) {
|
|
3166
|
+
if (value === void 0 || value === null || value === "") {
|
|
3167
|
+
return;
|
|
3168
|
+
}
|
|
3169
|
+
if (typeof value !== "string" || !looksLikeParseEvalFunctionBody(value)) {
|
|
3170
|
+
addCodeModeMessageScriptError(errors, pathName);
|
|
3171
|
+
}
|
|
3172
|
+
}
|
|
3173
|
+
function validateCodeModeMessageActionUrl(errors, pathName, value) {
|
|
3174
|
+
if (value === void 0 || value === null || value === "") {
|
|
3175
|
+
return;
|
|
3176
|
+
}
|
|
3177
|
+
if (typeof value !== "string") {
|
|
3178
|
+
errors.push(`${pathName} is code-mode message action URL but is not a string script.`);
|
|
3179
|
+
return;
|
|
3180
|
+
}
|
|
3181
|
+
if (value.includes("${") && !looksLikeParseEvalFunctionBody(value)) {
|
|
3182
|
+
errors.push(
|
|
3183
|
+
`${pathName} contains template interpolation but is not a parseEvalFunction body; use a JS return script such as: return '/projectContinue?id=' + step.project_id + '&step_id=' + step.id;`
|
|
3184
|
+
);
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3187
|
+
function validateFlowTemplateCodeModeMessages(value, errors) {
|
|
3188
|
+
const nextErrors = [];
|
|
3189
|
+
const data = isRecord3(value.data) ? value.data : {};
|
|
3190
|
+
const meta = isRecord3(data.meta) ? data.meta : {};
|
|
3191
|
+
if (meta.message_config_mode === "code") {
|
|
3192
|
+
validateCodeModeMessageScript(nextErrors, "data.meta.message_template", meta.message_template);
|
|
3193
|
+
}
|
|
3194
|
+
if (meta.cc_message_config_mode === "code" || meta.project_cc_message_config_mode === "code") {
|
|
3195
|
+
validateCodeModeMessageScript(nextErrors, "data.meta.cc_message_template", meta.cc_message_template);
|
|
3196
|
+
}
|
|
3197
|
+
const nodes = Array.isArray(data.nodes) ? data.nodes : [];
|
|
3198
|
+
nodes.forEach((node, index) => {
|
|
3199
|
+
if (!isRecord3(node)) {
|
|
3200
|
+
return;
|
|
3201
|
+
}
|
|
3202
|
+
const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${index}]`;
|
|
3203
|
+
if (node.message_config_mode === "code") {
|
|
3204
|
+
validateCodeModeMessageScript(nextErrors, `${nodeName}.message_template`, node.message_template);
|
|
3205
|
+
const simpleTemplate = isRecord3(node.message_template_simple) ? node.message_template_simple : {};
|
|
3206
|
+
const actions = Array.isArray(simpleTemplate.actions) ? simpleTemplate.actions : [];
|
|
3207
|
+
actions.forEach((action, actionIndex) => {
|
|
3208
|
+
if (!isRecord3(action)) {
|
|
3209
|
+
return;
|
|
3210
|
+
}
|
|
3211
|
+
validateCodeModeMessageActionUrl(
|
|
3212
|
+
nextErrors,
|
|
3213
|
+
`${nodeName}.message_template_simple.actions[${actionIndex}].url`,
|
|
3214
|
+
action.url
|
|
3215
|
+
);
|
|
3216
|
+
validateCodeModeMessageActionUrl(
|
|
3217
|
+
nextErrors,
|
|
3218
|
+
`${nodeName}.message_template_simple.actions[${actionIndex}].m_url`,
|
|
3219
|
+
action.m_url
|
|
3220
|
+
);
|
|
3221
|
+
});
|
|
3222
|
+
}
|
|
3223
|
+
if (node.cc_message_config_mode === "code" || node.step_cc_message_config_mode === "code") {
|
|
3224
|
+
validateCodeModeMessageScript(nextErrors, `${nodeName}.cc_message_template`, node.cc_message_template);
|
|
3225
|
+
}
|
|
3226
|
+
});
|
|
3227
|
+
if (!nextErrors.length) {
|
|
3228
|
+
return;
|
|
3229
|
+
}
|
|
3230
|
+
if (errors) {
|
|
3231
|
+
errors.push(...nextErrors);
|
|
3232
|
+
return;
|
|
3233
|
+
}
|
|
3234
|
+
throw new Error(`flow-template code-mode message gate failed: ${nextErrors.join("; ")}`);
|
|
3235
|
+
}
|
|
3099
3236
|
function isEmptyTemplateReference(value) {
|
|
3100
3237
|
return value === void 0 || value === null || value === "" || value === 0 || value === "0";
|
|
3101
3238
|
}
|
|
@@ -3531,6 +3668,9 @@ function normalizeFlowTemplatePayload(work) {
|
|
|
3531
3668
|
}
|
|
3532
3669
|
data.meta = meta;
|
|
3533
3670
|
validateFlowTemplateRemoteTemplateRefs({ ...work, data });
|
|
3671
|
+
validateFlowTemplateProjectAfterCreatePath({ ...work, data });
|
|
3672
|
+
validateFlowTemplateStandardPageCreateFormTemplate({ ...work, data });
|
|
3673
|
+
validateFlowTemplateCodeModeMessages({ ...work, data });
|
|
3534
3674
|
const payload = pickDefined(work, [
|
|
3535
3675
|
"name",
|
|
3536
3676
|
"flow_type",
|
|
@@ -4746,6 +4886,9 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
|
|
|
4746
4886
|
throw new Error("flow-template create requires a work JSON object.");
|
|
4747
4887
|
}
|
|
4748
4888
|
validateFlowTemplateRemoteTemplateRefs(work);
|
|
4889
|
+
validateFlowTemplateProjectAfterCreatePath(work);
|
|
4890
|
+
validateFlowTemplateStandardPageCreateFormTemplate(work);
|
|
4891
|
+
validateFlowTemplateCodeModeMessages(work);
|
|
4749
4892
|
validateFlowTemplateFormDrivenCreateBaseline(work, void 0, { context: "flow-template create" });
|
|
4750
4893
|
const createShell = {
|
|
4751
4894
|
name: String(work.name || ""),
|
|
@@ -5181,6 +5324,9 @@ async function lintConfigWorkFile(file) {
|
|
|
5181
5324
|
if (isFlowTemplateWork(value)) {
|
|
5182
5325
|
const flowWork = value;
|
|
5183
5326
|
validateFlowTemplateRemoteTemplateRefs(flowWork, errors);
|
|
5327
|
+
validateFlowTemplateProjectAfterCreatePath(flowWork, errors);
|
|
5328
|
+
validateFlowTemplateStandardPageCreateFormTemplate(flowWork, errors);
|
|
5329
|
+
validateFlowTemplateCodeModeMessages(flowWork, errors);
|
|
5184
5330
|
if (flowWork.mode === "create") {
|
|
5185
5331
|
validateFlowTemplateFormDrivenCreateBaseline(flowWork, errors, { context: "flow-template create" });
|
|
5186
5332
|
} else {
|
|
@@ -5411,6 +5557,9 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
5411
5557
|
await ensureConfigCapability(profile, `${definition.capability}.export`);
|
|
5412
5558
|
if (domain === "flow-template") {
|
|
5413
5559
|
validateFlowTemplateRemoteTemplateRefs(submit.payload);
|
|
5560
|
+
validateFlowTemplateProjectAfterCreatePath(submit.payload);
|
|
5561
|
+
validateFlowTemplateStandardPageCreateFormTemplate(submit.payload);
|
|
5562
|
+
validateFlowTemplateCodeModeMessages(submit.payload);
|
|
5414
5563
|
validateFlowTemplateStandardFlowType(submit.payload);
|
|
5415
5564
|
validateFlowTemplateIdentityStandard(id, submit.payload);
|
|
5416
5565
|
}
|
|
@@ -10128,10 +10277,22 @@ function configDirFromArgv(argv) {
|
|
|
10128
10277
|
}
|
|
10129
10278
|
return void 0;
|
|
10130
10279
|
}
|
|
10131
|
-
program.name(CLI_NAME).description("BPMAX multi-environment CLI").version(VERSION).option("--config-dir <dir>", "Root directory for bpmax-cli local state");
|
|
10280
|
+
program.name(CLI_NAME).description("BPMAX multi-environment CLI").version(VERSION).option("--config-dir <dir>", "Root directory for bpmax-cli local state").option("--execution-token <token>", "Short-lived BPMAX AI execution token").option("--action-key <actionKey>", "AI action key for execution audit").option("--session-key <sessionKey>", "AI conversation session key").option("--trace-id <traceId>", "AI execution trace id");
|
|
10132
10281
|
program.hook("preAction", (thisCommand) => {
|
|
10133
10282
|
const options = thisCommand.optsWithGlobals();
|
|
10134
10283
|
setConfigDir(options.configDir);
|
|
10284
|
+
if (options.executionToken) {
|
|
10285
|
+
process.env.BPMAX_EXECUTION_TOKEN = options.executionToken;
|
|
10286
|
+
}
|
|
10287
|
+
if (options.actionKey) {
|
|
10288
|
+
process.env.BPMAX_AI_ACTION_KEY = options.actionKey;
|
|
10289
|
+
}
|
|
10290
|
+
if (options.sessionKey) {
|
|
10291
|
+
process.env.BPMAX_AI_SESSION_KEY = options.sessionKey;
|
|
10292
|
+
}
|
|
10293
|
+
if (options.traceId) {
|
|
10294
|
+
process.env.BPMAX_AI_TRACE_ID = options.traceId;
|
|
10295
|
+
}
|
|
10135
10296
|
beginCommandAuditScope();
|
|
10136
10297
|
});
|
|
10137
10298
|
program.hook("postAction", async () => {
|