@stalfh233/omc-cli 0.6.35 → 0.6.36
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 +12 -5
- package/dist/recipes/businessrule.js +37 -0
- package/dist/skills.js +16 -12
- package/package.json +3 -3
- package/skills/omc-backend-online-coding.md +8 -0
package/dist/cli.js
CHANGED
|
@@ -1858,7 +1858,7 @@ function cmdHelpSearch(topic, query, transport, searchMode, limit) {
|
|
|
1858
1858
|
sectionOrdinal: match.sectionOrdinal,
|
|
1859
1859
|
matchLines: match.matchLines,
|
|
1860
1860
|
sectionBytes: match.sectionBytes,
|
|
1861
|
-
sectionCommand: `omc help ${match.topic} --section
|
|
1861
|
+
sectionCommand: `omc help ${match.topic} --section ${shellQuote(match.heading)}`,
|
|
1862
1862
|
sectionComplete: complete,
|
|
1863
1863
|
...(complete ? { sectionContent: match.section } : { inlineOmitted: `${match.sectionBytes}B 超过单节内联上限 ${SEARCH_INLINE_SECTION_CEILING}B;用 sectionCommand 精确取这一节` }),
|
|
1864
1864
|
};
|
|
@@ -1895,6 +1895,10 @@ function cmdHelpSearch(topic, query, transport, searchMode, limit) {
|
|
|
1895
1895
|
console.error(`omc help --search "${query.trim()}":${result.total} 节命中,返回 ${matches.length} 节${truncating || anyOmitted ? "(含未内联正文,见 sectionCommand)" : ""}`);
|
|
1896
1896
|
return emitTransportResult(envelopeFor(matches, truncating), transport);
|
|
1897
1897
|
}
|
|
1898
|
+
/** Quote a heading so `sectionCommand` can be pasted into a POSIX shell. */
|
|
1899
|
+
function shellQuote(value) {
|
|
1900
|
+
return /[`'"$\s]/.test(value) ? `'${value.replace(/'/g, "'\\''")}'` : value;
|
|
1901
|
+
}
|
|
1898
1902
|
/**
|
|
1899
1903
|
* Ticket 122 — `omc help [topic]`: the methodology layer, reachable exactly
|
|
1900
1904
|
* like `git help <concept>`. The command list is the "what"; these topics are
|
|
@@ -1956,7 +1960,7 @@ function cmdHelpSearch(topic, query, transport, searchMode, limit) {
|
|
|
1956
1960
|
for (const requested of requestedSections) {
|
|
1957
1961
|
const sliced = readSkillSection(topic, requested);
|
|
1958
1962
|
if (sliced?.section)
|
|
1959
|
-
found.push({ section: requested, content: sliced.section, chars: sliced.section.length, bytes: Buffer.byteLength(sliced.section, "utf8") });
|
|
1963
|
+
found.push({ section: sliced.heading ?? requested, ...(sliced.heading !== requested ? { requested } : {}), ...(sliced.matchType === "partial" ? { matchType: "partial" } : {}), content: sliced.section, chars: sliced.section.length, bytes: Buffer.byteLength(sliced.section, "utf8") });
|
|
1960
1964
|
else
|
|
1961
1965
|
missing.push(requested);
|
|
1962
1966
|
}
|
|
@@ -1990,7 +1994,9 @@ function cmdHelpSearch(topic, query, transport, searchMode, limit) {
|
|
|
1990
1994
|
return emitTransportResult({
|
|
1991
1995
|
status: "ok",
|
|
1992
1996
|
topic: sliced.document.name,
|
|
1993
|
-
section: singleSection,
|
|
1997
|
+
section: sliced.heading ?? singleSection,
|
|
1998
|
+
...(sliced.heading !== singleSection || sliced.matchType === "partial" ? { requested: singleSection } : {}),
|
|
1999
|
+
...(sliced.matchType === "partial" ? { matchType: "partial" } : {}),
|
|
1994
2000
|
chars: sliced.section.length,
|
|
1995
2001
|
bytes: Buffer.byteLength(sliced.section, "utf8"),
|
|
1996
2002
|
complete: true,
|
|
@@ -2164,7 +2170,8 @@ async function main() {
|
|
|
2164
2170
|
return CLI_EXIT_CODES.ok;
|
|
2165
2171
|
}
|
|
2166
2172
|
// r30f F15:topic 既是位置参数也接受 `--topic <name>` 别名(肌肉记忆对齐 capability/contract)。
|
|
2167
|
-
|
|
2173
|
+
const collectSection = (value, previous = []) => [...previous, value];
|
|
2174
|
+
command.command("help [topic]").option("--topic <name>", "topic 别名(与位置参数等价:`omc help omc-refusals` = `omc help --topic omc-refusals`)").option("--section [heading]", "按标题取该节内容;可重复或用逗号一次取多节:--section a --section b / --section a,b(不带值则列出该 topic 的节标题)", collectSection, []).option("--sections").option("--all", "回整篇正文(默认只回节索引:标题 + 各节字节)").option("--search <query>", "跨 topic 全文检索(错误码/字段名/命令名);命中节正文随结果返回,不需要再取一次").option("--search-mode <mode>", "all(默认,同一节包含全部词)或 any(包含任一)").option("--limit <n>", "检索最多返回几节(默认 5,1–50)").option("--max-output-bytes <bytes>").action(async (topic, options) => {
|
|
2168
2175
|
const resolvedTopic = typeof options.topic === "string" && options.topic.trim() !== "" ? options.topic.trim() : topic;
|
|
2169
2176
|
commandExitCode = await withTransport(options, request, (transport) => cmdHelp(resolvedTopic, command.commands.map((entry) => entry.name()), transport, options.section, options.sections === true, options.all === true, typeof options.search === "string" ? options.search : undefined, typeof options.searchMode === "string" ? options.searchMode : undefined, typeof options.limit === "string" ? options.limit : undefined));
|
|
2170
2177
|
});
|
|
@@ -2356,7 +2363,7 @@ async function main() {
|
|
|
2356
2363
|
.option("--schema <schemaCode>", "模型 code")
|
|
2357
2364
|
.option("--schema-code <schemaCode>")
|
|
2358
2365
|
.option("--rule-code <ruleCode>")
|
|
2359
|
-
.option("--name <name>", "规则显示名(rule.save 的 name
|
|
2366
|
+
.option("--name <name>", "规则显示名(rule.save 的 name 位;与既有规则同 code 则覆盖更新)。**平台约束:仅中文/字母/数字,长度 1–50**——下划线等符号能落库但设计器无法再编辑(rule-name-invalid 会拦)")
|
|
2360
2367
|
.option("--node-graph <json>", "规则图 {nodes,routes} JSON")
|
|
2361
2368
|
.option("--publish", "保存后同时发布规则版本")
|
|
2362
2369
|
.option("--env <environment>")
|
|
@@ -1,4 +1,41 @@
|
|
|
1
1
|
import { environment, model, commonRecovery } from "./shared.js";
|
|
2
|
+
const ruleCustomMinimal = Object.freeze({
|
|
3
|
+
id: "custom-rule-minimal",
|
|
4
|
+
title: "自定义触发规则最小图形状(ruleCode 非平台触发码 → 业务规则面板按钮/API 调用)",
|
|
5
|
+
status: "requires-prior-readback",
|
|
6
|
+
tool: "rule.save",
|
|
7
|
+
args: {
|
|
8
|
+
environment,
|
|
9
|
+
schemaCode: model,
|
|
10
|
+
ruleCode: "<自定义规则 code,如 riskFlagRule>",
|
|
11
|
+
name: "风控标记",
|
|
12
|
+
nodeGraph: {
|
|
13
|
+
nodes: [
|
|
14
|
+
{ nodeCode: "Start", nodeType: "START" },
|
|
15
|
+
// 自定义规则的动作节点按需要选;下面是「写死一个字段」的最小可跑形状
|
|
16
|
+
{ nodeCode: "UPDATE_1", nodeType: "UPDATE", targetObjectCode: model, inputParam: "_input", filterCondition: { mainConditions: [[{ targetSchemaDataItem: "id", ruleConditionType: "EQ", ruleValueType: "DYNAMIC", currentSchemaDataItem: "id" }]], sheetConditions: [] }, dataActions: [{ targetDataItem: "risk_flag", ruleValueType: "FIXED", value: "HIGH", ruleActionType: "EQUALS" }] },
|
|
17
|
+
{ nodeCode: "End", nodeType: "END" },
|
|
18
|
+
],
|
|
19
|
+
routes: [
|
|
20
|
+
{ preNode: "Start", postNode: "UPDATE_1" },
|
|
21
|
+
{ preNode: "UPDATE_1", postNode: "End" },
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
preconditions: [
|
|
26
|
+
"ruleCode **不是** Create/Update/Delete/Load/GetList/Cancel/Available 之一,平台就按自定义规则处理(工具自动补 CUSTOM_NODE)。",
|
|
27
|
+
"自定义规则**不会被数据事件自动触发**:要么设计器/按钮调用,要么 `omc call rule.run`,要么 v2/v3 invoke 端点(见 help omc-backend-online-coding §5.1)。",
|
|
28
|
+
],
|
|
29
|
+
conditionalRequirements: [
|
|
30
|
+
"想跑 Java 源码:先用本配方建规则,再 `programming.get` 取模板 → 写 handler → compile → save → publish。",
|
|
31
|
+
"**name 有字符集约束**:仅中文/字母/数字,1–50 字符;下划线会被 rule-name-invalid 拒(能落库但设计器不可编辑)。",
|
|
32
|
+
],
|
|
33
|
+
priorToolReferences: [{ tool: "rule.list", args: { environment, schemaCode: model }, purpose: "确认 ruleCode 未被占用(自定义规则不会自动出现在数据事件列表里,但同名会覆盖)" }],
|
|
34
|
+
dryRun: { supported: true, command: `omc call rule.save --env ${environment} --dry-run --args '<recipe.args>'`, notes: "dry-run 校验 nodeGraph 形状与 ruleCode/name 约束,零 wire" },
|
|
35
|
+
expectedReadback: { performed: { errcode: 0 }, readback: { rulePresent: true }, next: ["rule.enable", "programming.get 取模板", "programming.publish"] },
|
|
36
|
+
refusalRecovery: [{ code: "rule-name-invalid", action: "改 name 为纯中文/字母/数字(去掉下划线等符号);或省略 name 让工具按 ruleCode 生成" }, ...commonRecovery],
|
|
37
|
+
requiresEnvironmentDerivedIds: false,
|
|
38
|
+
});
|
|
2
39
|
const ruleGraph = Object.freeze({
|
|
3
40
|
id: "standard-business-rule-graph",
|
|
4
41
|
title: "保存并启用最小数据事件规则图",
|
package/dist/skills.js
CHANGED
|
@@ -248,13 +248,12 @@ function scanHeadings(lines) {
|
|
|
248
248
|
*/
|
|
249
249
|
function sliceSectionText(lines, start, level) {
|
|
250
250
|
let end = lines.length;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
251
|
+
// Reuse the same fence-aware scan as the section index. A Markdown comment
|
|
252
|
+
// inside a fenced shell/YAML example is not a heading and must not truncate
|
|
253
|
+
// the section body.
|
|
254
|
+
const next = scanHeadings(lines).find((entry) => entry.index > start && entry.level <= level);
|
|
255
|
+
if (next !== undefined)
|
|
256
|
+
end = next.index;
|
|
258
257
|
return lines.slice(start, end).join("\n").trim() + "\n";
|
|
259
258
|
}
|
|
260
259
|
/** Return one Markdown heading and its nested content without loading the full topic into the envelope. */
|
|
@@ -272,7 +271,7 @@ export function readSkillSection(name, requested) {
|
|
|
272
271
|
// full heading ("8. Canonical configuration order(规范配置顺序)") — the
|
|
273
272
|
// route lists headings, but agents also number-jump. Match on the leading
|
|
274
273
|
// ordinal too, so a numeric request does not waste a retry.
|
|
275
|
-
const requestedOrdinal = /^(\d+)(?:[.\)、]|\s|$)/.exec(normalized)?.[1];
|
|
274
|
+
const requestedOrdinal = /^(\d+(?:\.\d+)*)(?:[.\)、]|\s|$)/.exec(normalized)?.[1];
|
|
276
275
|
const matches = (heading) => {
|
|
277
276
|
if (heading === normalized)
|
|
278
277
|
return true;
|
|
@@ -281,25 +280,30 @@ export function readSkillSection(name, requested) {
|
|
|
281
280
|
if (heading.replace(/[^\p{L}\p{N}]+/gu, "-").toLowerCase() === normalized)
|
|
282
281
|
return true;
|
|
283
282
|
if (requestedOrdinal !== undefined) {
|
|
284
|
-
const headingOrdinal = /^(\d+)(?:[.\)、]|\s|$)/.exec(heading)?.[1];
|
|
283
|
+
const headingOrdinal = /^(\d+(?:\.\d+)*)(?:[.\)、]|\s|$)/.exec(heading)?.[1];
|
|
285
284
|
if (headingOrdinal === requestedOrdinal)
|
|
286
285
|
return true;
|
|
287
286
|
}
|
|
288
287
|
return false;
|
|
289
288
|
};
|
|
290
|
-
|
|
289
|
+
const exact = scanned.find((entry) => matches(entry.heading.trim().toLowerCase()));
|
|
290
|
+
let start = exact?.index ?? -1;
|
|
291
|
+
// 精确命中(含序号/归一化形态)即 exact;仅唯一子串回退才降级为 partial。
|
|
292
|
+
let matchType = "exact";
|
|
291
293
|
// Forgiving fallback: a unique prefix/substring match ("流程" for "流程字段权限").
|
|
292
294
|
// A non-unique partial matches nothing (precision over recall) and the
|
|
293
295
|
// not-found error lists the real headings, so the caller can retry once.
|
|
294
296
|
if (start < 0 && normalized.length >= 2) {
|
|
295
297
|
const partial = scanned.filter((entry) => entry.heading.trim().toLowerCase().includes(normalized));
|
|
296
|
-
if (partial.length === 1)
|
|
298
|
+
if (partial.length === 1) {
|
|
297
299
|
start = partial[0].index;
|
|
300
|
+
matchType = "partial";
|
|
301
|
+
}
|
|
298
302
|
}
|
|
299
303
|
if (start < 0)
|
|
300
304
|
return { document, section: "", headings };
|
|
301
305
|
const startEntry = scanned.find((entry) => entry.index === start);
|
|
302
|
-
return { document, section: sliceSectionText(lines, startEntry.index, startEntry.level), headings };
|
|
306
|
+
return { document, section: sliceSectionText(lines, startEntry.index, startEntry.level), headings, heading: startEntry.heading, matchType };
|
|
303
307
|
}
|
|
304
308
|
/**
|
|
305
309
|
* The "shape" of a topic: every heading with the bytes it would cost to read.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stalfh233/omc-cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.36",
|
|
4
4
|
"description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"commander": "14.0.3",
|
|
58
|
-
"omc-core": "0.6.
|
|
58
|
+
"omc-core": "0.6.36",
|
|
59
59
|
"proper-lockfile": "4.1.2",
|
|
60
60
|
"write-file-atomic": "6.0.0",
|
|
61
61
|
"zod": "^3.23.8",
|
|
@@ -73,6 +73,6 @@
|
|
|
73
73
|
"directory": "packages/omc-cli"
|
|
74
74
|
},
|
|
75
75
|
"optionalDependencies": {
|
|
76
|
-
"@stalfh233/omc-fake-platform": "0.6.
|
|
76
|
+
"@stalfh233/omc-fake-platform": "0.6.36"
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -132,6 +132,10 @@ webapi = Spring Boot `PropertiesLauncher`,真机启动参数
|
|
|
132
132
|
import;但 launcher 自身的嵌套 BOOT-INF lib 对直接 import 仍不可见(`jakarta.*` 编不过的
|
|
133
133
|
边界不变)。
|
|
134
134
|
|
|
135
|
+
**你没法列举已部署的类**:CLI 没有「列出 extensions 内容」的读面(`extensions/` 在远端容器里,
|
|
136
|
+
agent 侧看不到)。判断某个类能不能用只有一条路——写进 handler,`programming.compile` 试一次
|
|
137
|
+
(只读、不落库):成功即可用,`errors[]` 里报 `package ... does not exist` 即不可用。
|
|
138
|
+
|
|
135
139
|
## 1. 两种用法:单条 vs 工作区
|
|
136
140
|
|
|
137
141
|
### 单条(快速改一条规则)
|
|
@@ -332,6 +336,10 @@ owner/creater/modifier/部门/时间字段才从请求上下文回填(显式
|
|
|
332
336
|
| 前端 / 站内 | `POST /api/v2/businessRule/invoke`,body `{appCode,schemaCode,businessRuleCode,data}` | RequestContext(无 userId 参数) | **handle 返回值直接 = `ResponseResult.data`** |
|
|
333
337
|
| 第三方 | `POST /api/openapi/v3/bo/invokeBizRule`,body 带 `userId` | OAuth2 client_credentials(`POST /oauth/token` → bearer) | handle 返回值**包在 `returnObject` 里**(不是直接 data) |
|
|
334
338
|
|
|
339
|
+
**两个易混点**:
|
|
340
|
+
- `omc call rule.run` 走的是**第一个面(平台按钮)**,它**不回 handle 的返回 Map**——回执里只有执行结果信封(`effectHint` 明说返回的是执行前快照)。要拿 handle 返回值必须走 v2/v3 的 invoke 端点。
|
|
341
|
+
- 想验规则副作用:写业务字段 → `data.load` 读回。
|
|
342
|
+
|
|
335
343
|
- **硬闸**:两个 invoke 端点都**只接受自定义规则**——Create/Update/Delete/Load/GetList 五个
|
|
336
344
|
默认规则名直接抛 `BUSINESS_RULE_ONLY_SUPPORT_CUSTOM_RUN`(Cancel/Available 由 invokeCustom
|
|
337
345
|
特判逐条执行)。
|