@stalfh233/omc-cli 0.8.10 → 0.8.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/cli.js +1 -1
- package/dist/form-default.js +9 -5
- package/dist/form-support.js +348 -3
- package/dist/goal-routes.js +59 -3
- package/dist/intent/capabilities/field.js +77 -3
- package/dist/intent/plan-apply.js +13 -1
- package/dist/lanes/field.js +85 -9
- package/dist/lanes/form.js +23 -2
- package/dist/lanes/list-view-contract.js +2 -2
- package/dist/lanes/list-view-shapes.js +46 -0
- package/dist/lanes/list-view.js +128 -101
- package/dist/lanes/runtime-data-contract.js +1 -1
- package/dist/lanes/runtime-data.js +86 -11
- package/dist/model-purge.js +31 -12
- package/dist/path-projection.js +150 -11
- package/dist/recipes/datarule.js +1 -1
- package/dist/recipes/field.js +11 -4
- package/dist/recipes/form.js +10 -1
- package/dist/recipes/runtime-data.js +35 -2
- package/dist/write.js +7 -2
- package/package.json +3 -3
- package/skills/omc-refusals.md +3 -0
- package/skills/omc-requirement-vocabulary.md +2 -1
- package/skills/omc-start-here.md +1 -1
package/dist/cli.js
CHANGED
|
@@ -3619,7 +3619,7 @@ async function main() {
|
|
|
3619
3619
|
.option("--env <environment>")
|
|
3620
3620
|
.option("--environment <environment>")
|
|
3621
3621
|
.option("--apply")
|
|
3622
|
-
.addHelpText("after", "\n一条命令按依赖倒序清掉一个模型:列表视图 → 业务规则 → 计算规则 → 流程实例 → 流程 → 模型(字段/表单随模型级联,并级联删除流程模板 <code>_wf 及其发起权限绑定)。默认 dry-run。\n
|
|
3622
|
+
.addHelpText("after", "\n一条命令按依赖倒序清掉一个模型:列表视图 → 业务规则 → 计算规则 → 流程实例 → 流程 → 模型(字段/表单随模型级联,并级联删除流程模板 <code>_wf 及其发起权限绑定)。默认 dry-run。\n入站引用(被其它模型关联字段引用,或子表关联列指向自身):dry-run 回 status:\"dry-run\" + blocker:\"model-referenced-by\" 并预置 unbindSteps/wouldRequireFlags(一条完整计划,零写入);--apply 未带 --unbind-references 时回 blocked/partial 并给 deletionSteps;加 --unbind-references --apply 让本命令先拆引用(破坏性:会删除引用列/子表关联列,列数据不可恢复),任一步失败即停且不删模型。\n业务数据:--purge-instances 删流程实例;普通业务行(无流程)不会自动带走——先 data.delete 清(sweep-all-readback 配方),再 purge,否则留孤儿数据。\n")
|
|
3623
3623
|
.action(async (options) => {
|
|
3624
3624
|
const rest = ["model-purge",
|
|
3625
3625
|
...(options.code ? ["--code", options.code] : []),
|
package/dist/form-default.js
CHANGED
|
@@ -41,9 +41,11 @@ function extractControls(formGet) {
|
|
|
41
41
|
return undefined;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* `form.get`
|
|
45
|
-
*
|
|
46
|
-
*
|
|
44
|
+
* `form.get` 的**默认(非 full)面**把大字段降载(长字符串 → `{length, sha256,
|
|
45
|
+
* omitted:true}`、控件清单 → `{keys, sha256, omitted:true}`),raw 面在
|
|
46
|
+
* detailArtifactId。`full:true` 在 2.1.5 实测全文内联(约 19KB),只有超过内联
|
|
47
|
+
* 上限才走 `*Omitted` + artifact——但 `controls:true` 仍可能只回定义摘要。
|
|
48
|
+
* 把摘要当数组会读成「2 个控件」。
|
|
47
49
|
*
|
|
48
50
|
* r10 (2026-10-22) F1: `form-default --apply` cloned that摘要 as the draft, wrote
|
|
49
51
|
* a 2-control form, and `form.publish`'s degrade guard then refused its own
|
|
@@ -137,8 +139,10 @@ export async function cmdFormDefault(args) {
|
|
|
137
139
|
return 0;
|
|
138
140
|
}
|
|
139
141
|
// 2) form.draft:需要完整 draftAttributesJson——单控件投影不够,取发布面的全量控件
|
|
140
|
-
// 图。`controls:true`
|
|
141
|
-
//
|
|
142
|
+
// 图。`controls:true` 的定义映射可能是摘要({keys,sha256}),默认面的大字符串也
|
|
143
|
+
// 可能被通用降载折成 {length,sha256};`full:true` 在 2.1.5 是全文内联,但超过
|
|
144
|
+
// 内联上限(当前 32KB)会外置成 `*Omitted` + artifact——两条路都以 detail
|
|
145
|
+
// artifact 为安全取值面。
|
|
142
146
|
const getAll = await runToolCall("form.get", { args: { schemaCode: schema, full: true, ...(environment ? { environment } : {}) }, requestId: request, environment, print: silent });
|
|
143
147
|
if (getAll.exitCode !== 0) {
|
|
144
148
|
const classified = classifyResult(getAll.result);
|
package/dist/form-support.js
CHANGED
|
@@ -4,7 +4,7 @@ import { decodeJsonObjectColumn } from "./json-column.js";
|
|
|
4
4
|
import { ToolRefusalError } from "./tool-types.js";
|
|
5
5
|
import { FIELD_CONTROL_TYPES, childColumnsOf, SYSTEM_FIELD_CODES, fieldControlOptions, relationDisplayField, relationMappings, } from "./field-families.js";
|
|
6
6
|
import { deriveControlOptions } from "./capability-shape.js";
|
|
7
|
-
import { hardLayoutViolations, validateFormLayoutShape, controlTypeMismatches, FORM_CONTROL_TYPE_HINT } from "./form-layout.js";
|
|
7
|
+
import { ALLOWED_SPANS, FULL_SPAN, hardLayoutViolations, validateFormLayout, validateFormLayoutShape, controlTypeMismatches, FORM_CONTROL_TYPE_HINT } from "./form-layout.js";
|
|
8
8
|
/**
|
|
9
9
|
* Propagate each relation field's `options.mappings` into its form control so
|
|
10
10
|
* the form-fill carry is configured where the form renderer reads it. The
|
|
@@ -845,6 +845,327 @@ export function assertCallerFormLayout(args) {
|
|
|
845
845
|
});
|
|
846
846
|
}
|
|
847
847
|
}
|
|
848
|
+
const LAYOUT_SYSTEM_CONTROL_TYPES = new Set([100, 101, 102, 103, 104, 105, 106, 200, 203, 249]);
|
|
849
|
+
/** 系统/布局控件:系统字段码、设计器脚手架的 Title…/Group… 键,或系统控件类型。 */
|
|
850
|
+
export function isLayoutSystemControl(code, control) {
|
|
851
|
+
if (SYSTEM_FIELD_CODES.has(code))
|
|
852
|
+
return true;
|
|
853
|
+
if (/^(Title|Group)\d*$/.test(code))
|
|
854
|
+
return true;
|
|
855
|
+
const rawType = control && typeof control === "object" ? control.type : undefined;
|
|
856
|
+
const type = Number(rawType);
|
|
857
|
+
return Number.isInteger(type) && LAYOUT_SYSTEM_CONTROL_TYPES.has(type);
|
|
858
|
+
}
|
|
859
|
+
function layoutRowsOf(face) {
|
|
860
|
+
if (typeof face !== "string")
|
|
861
|
+
return undefined;
|
|
862
|
+
try {
|
|
863
|
+
const parsed = JSON.parse(face);
|
|
864
|
+
if (!Array.isArray(parsed))
|
|
865
|
+
return undefined;
|
|
866
|
+
if (!parsed.every((row) => Array.isArray(row) && row.every((cell) => typeof cell === "string")))
|
|
867
|
+
return undefined;
|
|
868
|
+
return parsed;
|
|
869
|
+
}
|
|
870
|
+
catch {
|
|
871
|
+
return undefined;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
/** 行内自动均分:24/n 必须在 span 白名单内(n=1→24,2→12,3→8,4→6;>4 无整数解)。 */
|
|
875
|
+
function evenLayoutSpan(count) {
|
|
876
|
+
if (count <= 0)
|
|
877
|
+
return undefined;
|
|
878
|
+
const span = FULL_SPAN / count;
|
|
879
|
+
return Number.isInteger(span) && ALLOWED_SPANS.has(span) ? span : undefined;
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* `layout` 是增量面,与「整包布局/重建」参数互斥。纯参数门:在写权限门与任何
|
|
883
|
+
* wire 之前拒绝(preflight 调用,execute 也调一次防内部调用方绕过)。
|
|
884
|
+
*/
|
|
885
|
+
export function assertLayoutRequestConflicts(args) {
|
|
886
|
+
if (args.layout === undefined)
|
|
887
|
+
return;
|
|
888
|
+
const conflictKeys = ["draftViewJson", "draftAttributesJson", "rebuild", "refreshFromFields", "fromReadback", "fieldCodes", "childColumns"].filter((key) => args[key] !== undefined);
|
|
889
|
+
if (conflictKeys.length === 0)
|
|
890
|
+
return;
|
|
891
|
+
throw new ToolRefusalError({
|
|
892
|
+
status: "refused",
|
|
893
|
+
blocker: "form-layout-param-conflict",
|
|
894
|
+
schemaCode: String(args.schemaCode ?? ""),
|
|
895
|
+
sheetCode: String(args.sheetCode ?? args.schemaCode ?? ""),
|
|
896
|
+
conflictKeys,
|
|
897
|
+
message: `layout 与 ${conflictKeys.join("、")} 互斥:layout 是增量面(以已发布表单为基线,只改这些控件的行分组与 span),不要同时回传整包 attrs/view、不要重建;二选一。`,
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* 用 `layout` 生成 form.draft 的 viewJson/attributesJson:基线控件面逐键保留,只改
|
|
902
|
+
* rows 分组 + 被点名控件的 options.span。dry-run(writeLint)与真写共用本函数,
|
|
903
|
+
* 因此两边答案逐字相同。
|
|
904
|
+
*/
|
|
905
|
+
export async function composeFormLayoutDraft(session, args) {
|
|
906
|
+
const { layout } = args;
|
|
907
|
+
const sheet = await readFormOrNull(session, args.schemaCode, args.sheetCode);
|
|
908
|
+
const decode = (value) => decodeJsonObjectColumn(value, { invalid: "undefined", array: "reject", object: "accept" });
|
|
909
|
+
const publishedAttrs = sheet === null ? undefined : decode(sheet.publishedAttributesJson);
|
|
910
|
+
const draftAttrs = sheet === null ? undefined : decode(sheet.draftAttributesJson);
|
|
911
|
+
const baseline = publishedAttrs !== undefined && Object.keys(publishedAttrs).length > 0
|
|
912
|
+
? "published"
|
|
913
|
+
: draftAttrs !== undefined && Object.keys(draftAttrs).length > 0
|
|
914
|
+
? "draft"
|
|
915
|
+
: undefined;
|
|
916
|
+
if (sheet === null || baseline === undefined) {
|
|
917
|
+
throw new ToolRefusalError({
|
|
918
|
+
status: "refused",
|
|
919
|
+
blocker: "form-layout-baseline-absent",
|
|
920
|
+
schemaCode: args.schemaCode,
|
|
921
|
+
sheetCode: args.sheetCode,
|
|
922
|
+
message: `表单 ${args.sheetCode} 没有可作基线的控件面(published/draft 的 attributes 都为空或不存在):layout 是增量面,必须先有表单控件。新建表单用 form.draft {rebuild:true} 或 draftAttributesJson 先建布局,不要用 layout 从零搭表。`,
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
const attrs = (baseline === "published" ? publishedAttrs : draftAttrs);
|
|
926
|
+
const attrCodes = Object.keys(attrs);
|
|
927
|
+
const attrSet = new Set(attrCodes);
|
|
928
|
+
const rowsInput = layout.rows;
|
|
929
|
+
if (!Array.isArray(rowsInput) || rowsInput.length === 0) {
|
|
930
|
+
throw new ToolRefusalError({
|
|
931
|
+
status: "refused",
|
|
932
|
+
blocker: "form-layout-rows-invalid",
|
|
933
|
+
schemaCode: args.schemaCode,
|
|
934
|
+
sheetCode: args.sheetCode,
|
|
935
|
+
message: "layout.rows 必须是非空二维数组:一行几个 code 就是几列(如 [[\"a\",\"b\"],[\"c\"]])。",
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
const named = [];
|
|
939
|
+
const namedSet = new Set();
|
|
940
|
+
for (const [rowIndex, row] of rowsInput.entries()) {
|
|
941
|
+
if (!Array.isArray(row) || row.length === 0) {
|
|
942
|
+
throw new ToolRefusalError({
|
|
943
|
+
status: "refused",
|
|
944
|
+
blocker: "form-layout-rows-invalid",
|
|
945
|
+
schemaCode: args.schemaCode,
|
|
946
|
+
sheetCode: args.sheetCode,
|
|
947
|
+
row: rowIndex + 1,
|
|
948
|
+
message: `layout.rows 第 ${rowIndex + 1} 行是空行或不是数组:每行至少要有一个控件 code。`,
|
|
949
|
+
});
|
|
950
|
+
}
|
|
951
|
+
for (const code of row) {
|
|
952
|
+
if (typeof code !== "string" || code === "") {
|
|
953
|
+
throw new ToolRefusalError({
|
|
954
|
+
status: "refused",
|
|
955
|
+
blocker: "form-layout-rows-invalid",
|
|
956
|
+
schemaCode: args.schemaCode,
|
|
957
|
+
sheetCode: args.sheetCode,
|
|
958
|
+
row: rowIndex + 1,
|
|
959
|
+
message: `layout.rows 第 ${rowIndex + 1} 行含非字符串/空 code;每个单元格必须是控件 code 字符串。`,
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
if (namedSet.has(code)) {
|
|
963
|
+
throw new ToolRefusalError({
|
|
964
|
+
status: "refused",
|
|
965
|
+
blocker: "form-layout-rows-duplicate",
|
|
966
|
+
schemaCode: args.schemaCode,
|
|
967
|
+
sheetCode: args.sheetCode,
|
|
968
|
+
field: code,
|
|
969
|
+
message: `layout.rows 里 ${code} 出现多次:一个控件只能占一个位置(否则换行/覆盖语义不唯一)。`,
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
namedSet.add(code);
|
|
973
|
+
named.push(code);
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
const unknownControls = named.filter((code) => !attrSet.has(code));
|
|
977
|
+
if (unknownControls.length > 0) {
|
|
978
|
+
throw new ToolRefusalError({
|
|
979
|
+
status: "refused",
|
|
980
|
+
blocker: "form-layout-unknown-controls",
|
|
981
|
+
schemaCode: args.schemaCode,
|
|
982
|
+
sheetCode: args.sheetCode,
|
|
983
|
+
unknownControls,
|
|
984
|
+
availableControls: attrCodes,
|
|
985
|
+
message: `layout.rows 引用了基线 ${baseline} 控件面里不存在的控件:${unknownControls.join("、")}。布局只能重排**已有控件**;新字段先 field.publish 并用 form.draft {rebuild:true} 等把控件加进表单,再用 layout 调布局。`,
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
const systemNamed = named.filter((code) => isLayoutSystemControl(code, attrs[code]));
|
|
989
|
+
if (systemNamed.length > 0 && layout.includeSystem !== true) {
|
|
990
|
+
throw new ToolRefusalError({
|
|
991
|
+
status: "refused",
|
|
992
|
+
blocker: "layout-system-control-locked",
|
|
993
|
+
schemaCode: args.schemaCode,
|
|
994
|
+
sheetCode: args.sheetCode,
|
|
995
|
+
systemControls: systemNamed,
|
|
996
|
+
message: `layout.rows 点名了系统控件 ${systemNamed.join("、")}:系统控件默认保留原行,不参与业务布局重排。确要移动它们请显式传 includeSystem:true;否则从 rows 里去掉(它们会自动保留在基线位置)。`,
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
const spanInput = layout.spans ?? {};
|
|
1000
|
+
const straySpans = Object.keys(spanInput).filter((code) => !namedSet.has(code));
|
|
1001
|
+
if (straySpans.length > 0) {
|
|
1002
|
+
throw new ToolRefusalError({
|
|
1003
|
+
status: "refused",
|
|
1004
|
+
blocker: "form-layout-spans-unknown",
|
|
1005
|
+
schemaCode: args.schemaCode,
|
|
1006
|
+
sheetCode: args.sheetCode,
|
|
1007
|
+
unknownSpans: straySpans,
|
|
1008
|
+
message: `layout.spans 只给 layout.rows 里的控件:${straySpans.join("、")} 不在任何一行。未列入 rows 的控件保留基线 span,不需要也不必给它传 span。`,
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
const spans = {};
|
|
1012
|
+
for (const [rowIndex, row] of rowsInput.entries()) {
|
|
1013
|
+
const explicit = row.map((code) => spanInput[code]);
|
|
1014
|
+
let used = 0;
|
|
1015
|
+
for (const [cellIndex, span] of explicit.entries()) {
|
|
1016
|
+
if (span === undefined)
|
|
1017
|
+
continue;
|
|
1018
|
+
if (!Number.isInteger(span) || !ALLOWED_SPANS.has(span)) {
|
|
1019
|
+
throw new ToolRefusalError({
|
|
1020
|
+
status: "refused",
|
|
1021
|
+
blocker: "form-layout-invalid",
|
|
1022
|
+
schemaCode: args.schemaCode,
|
|
1023
|
+
sheetCode: args.sheetCode,
|
|
1024
|
+
validation: [{ classification: "layout_invalid_span", row: rowIndex + 1, field: row[cellIndex], span }],
|
|
1025
|
+
message: `layout.spans.${row[cellIndex]} = ${String(span)} 不在允许宽度 ${[...ALLOWED_SPANS].join("/")}。`,
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
used += span;
|
|
1029
|
+
}
|
|
1030
|
+
const autoCount = explicit.filter((span) => span === undefined).length;
|
|
1031
|
+
if (autoCount > 0) {
|
|
1032
|
+
const remaining = FULL_SPAN - used;
|
|
1033
|
+
const autoSpan = remaining > 0 && remaining % autoCount === 0 ? remaining / autoCount : Number.NaN;
|
|
1034
|
+
if (!Number.isInteger(autoSpan) || !ALLOWED_SPANS.has(autoSpan)) {
|
|
1035
|
+
throw new ToolRefusalError({
|
|
1036
|
+
status: "refused",
|
|
1037
|
+
blocker: "form-layout-span-unsatisfiable",
|
|
1038
|
+
schemaCode: args.schemaCode,
|
|
1039
|
+
sheetCode: args.sheetCode,
|
|
1040
|
+
row: rowIndex + 1,
|
|
1041
|
+
codes: [...row],
|
|
1042
|
+
usedWidth: used,
|
|
1043
|
+
autoColumns: autoCount,
|
|
1044
|
+
allowedSpans: [...ALLOWED_SPANS],
|
|
1045
|
+
message: `layout.rows 第 ${rowIndex + 1} 行(${row.join(" + ")})无法自动均分:已用 ${used} 格,剩 ${remaining} 格给 ${autoCount} 个未指定 span 的控件。给这些控件显式传 layout.spans,或调整行内控件数。`,
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
explicit.forEach((span, cellIndex) => {
|
|
1049
|
+
if (span === undefined)
|
|
1050
|
+
spans[row[cellIndex]] = autoSpan;
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
else if (used > FULL_SPAN) {
|
|
1054
|
+
throw new ToolRefusalError({
|
|
1055
|
+
status: "refused",
|
|
1056
|
+
blocker: "form-layout-invalid",
|
|
1057
|
+
schemaCode: args.schemaCode,
|
|
1058
|
+
sheetCode: args.sheetCode,
|
|
1059
|
+
validation: [{ classification: "layout_row_overflow", row: rowIndex + 1, message: `第 ${rowIndex + 1} 行 span 合计 ${used},超过 ${FULL_SPAN}` }],
|
|
1060
|
+
message: `layout.rows 第 ${rowIndex + 1} 行(${row.join(" + ")})显式 span 合计 ${used},超过 ${FULL_SPAN}。`,
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
explicit.forEach((span, cellIndex) => {
|
|
1064
|
+
if (span !== undefined)
|
|
1065
|
+
spans[row[cellIndex]] = span;
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1068
|
+
// 基线行分组(保留未点名控件):去非法 cell/重复 cell,空行丢弃。
|
|
1069
|
+
const parsedBaseline = layoutRowsOf(baseline === "published" ? sheet.publishedViewJson : sheet.draftViewJson) ?? [];
|
|
1070
|
+
const seenCell = new Set();
|
|
1071
|
+
const baselineRows = [];
|
|
1072
|
+
const droppedCells = [];
|
|
1073
|
+
for (const row of parsedBaseline) {
|
|
1074
|
+
const kept = [];
|
|
1075
|
+
for (const cell of row) {
|
|
1076
|
+
if (!attrSet.has(cell)) {
|
|
1077
|
+
droppedCells.push(cell);
|
|
1078
|
+
continue;
|
|
1079
|
+
}
|
|
1080
|
+
if (seenCell.has(cell))
|
|
1081
|
+
continue;
|
|
1082
|
+
seenCell.add(cell);
|
|
1083
|
+
kept.push(cell);
|
|
1084
|
+
}
|
|
1085
|
+
if (kept.length > 0)
|
|
1086
|
+
baselineRows.push(kept);
|
|
1087
|
+
}
|
|
1088
|
+
const firstNamed = baselineRows.findIndex((row) => row.some((code) => namedSet.has(code)));
|
|
1089
|
+
const lastNamed = firstNamed < 0 ? -1 : baselineRows.reduce((last, row, index) => (row.some((code) => namedSet.has(code)) ? index : last), firstNamed);
|
|
1090
|
+
const prefix = firstNamed < 0 ? baselineRows : baselineRows.slice(0, firstNamed);
|
|
1091
|
+
const suffix = firstNamed < 0 ? [] : baselineRows.slice(lastNamed + 1);
|
|
1092
|
+
const orphanRows = [];
|
|
1093
|
+
if (firstNamed >= 0) {
|
|
1094
|
+
for (let index = firstNamed; index <= lastNamed; index += 1) {
|
|
1095
|
+
const rest = baselineRows[index].filter((code) => !namedSet.has(code));
|
|
1096
|
+
if (rest.length > 0)
|
|
1097
|
+
orphanRows.push(rest);
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
const layoutRows = rowsInput.map((row) => [...row]);
|
|
1101
|
+
const finalRows = firstNamed < 0 ? [...baselineRows, ...layoutRows] : [...prefix, ...layoutRows, ...orphanRows, ...suffix];
|
|
1102
|
+
// 基线 viewJson 里没有的控件(平台草稿可能不完整):按 attrs 顺序追加为末行,保证
|
|
1103
|
+
// 覆盖率门(attributes ↔ rows 一一对应)成立,一个控件都不丢。
|
|
1104
|
+
const placed = new Set(finalRows.flat());
|
|
1105
|
+
const appended = attrCodes.filter((code) => !placed.has(code));
|
|
1106
|
+
for (const code of appended)
|
|
1107
|
+
finalRows.push([code]);
|
|
1108
|
+
// 只改被点名控件的 options.span;其它控件/属性逐键保留(深拷贝后原样序列化)。
|
|
1109
|
+
const composed = JSON.parse(JSON.stringify(attrs));
|
|
1110
|
+
for (const code of named) {
|
|
1111
|
+
const control = composed[code];
|
|
1112
|
+
const options = control.options;
|
|
1113
|
+
if (options === undefined) {
|
|
1114
|
+
control.options = { span: spans[code] };
|
|
1115
|
+
continue;
|
|
1116
|
+
}
|
|
1117
|
+
if (options === null || typeof options !== "object" || Array.isArray(options)) {
|
|
1118
|
+
throw new ToolRefusalError({
|
|
1119
|
+
status: "refused",
|
|
1120
|
+
blocker: "form-layout-invalid",
|
|
1121
|
+
schemaCode: args.schemaCode,
|
|
1122
|
+
sheetCode: args.sheetCode,
|
|
1123
|
+
validation: [{ classification: "control_options_not_object", field: code, message: `控件 ${code} 的 options 不是对象` }],
|
|
1124
|
+
message: `控件 ${code} 的 options 不是对象(基线里是 ${typeof options}):无法安全改 span。先按 form.get 原文修复该控件,再用 layout。`,
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1127
|
+
options.span = spans[code];
|
|
1128
|
+
}
|
|
1129
|
+
const layoutRowStart = firstNamed < 0 ? baselineRows.length : prefix.length;
|
|
1130
|
+
const layoutRowEnd = layoutRowStart + layoutRows.length;
|
|
1131
|
+
const violations = validateFormLayout(finalRows, composed);
|
|
1132
|
+
// 调用方 authored 的行/span 违规 → 拒;平台基线保留下来的行形状(如设计器自带的
|
|
1133
|
+
// 系统行/子表列行)→ 只告警,与本文件 form.draft 的 roundtrip 容忍同口径。
|
|
1134
|
+
const touchesCaller = (violation) => {
|
|
1135
|
+
if (violation.classification === "layout_coverage_mismatch")
|
|
1136
|
+
return true;
|
|
1137
|
+
if (typeof violation.row === "number")
|
|
1138
|
+
return violation.row - 1 >= layoutRowStart && violation.row - 1 < layoutRowEnd;
|
|
1139
|
+
if (typeof violation.field === "string")
|
|
1140
|
+
return namedSet.has(violation.field);
|
|
1141
|
+
return true;
|
|
1142
|
+
};
|
|
1143
|
+
const blocking = violations.filter(touchesCaller);
|
|
1144
|
+
if (blocking.length > 0) {
|
|
1145
|
+
throw new ToolRefusalError({
|
|
1146
|
+
status: "refused",
|
|
1147
|
+
blocker: "form-layout-invalid",
|
|
1148
|
+
schemaCode: args.schemaCode,
|
|
1149
|
+
sheetCode: args.sheetCode,
|
|
1150
|
+
validation: blocking,
|
|
1151
|
+
message: "layout 生成的布局未过布局门;按 validation 修正 rows/spans(span 白名单/行宽≤24/整行独占)。",
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
const warnings = violations.filter((violation) => !touchesCaller(violation));
|
|
1155
|
+
const preserved = attrCodes.filter((code) => !namedSet.has(code));
|
|
1156
|
+
const receipt = {
|
|
1157
|
+
baseline,
|
|
1158
|
+
rows: finalRows.length,
|
|
1159
|
+
named,
|
|
1160
|
+
preserved,
|
|
1161
|
+
...(appended.length > 0 ? { appended } : {}),
|
|
1162
|
+
...(droppedCells.length > 0 ? { droppedCells: [...new Set(droppedCells)] } : {}),
|
|
1163
|
+
spans,
|
|
1164
|
+
includeSystem: layout.includeSystem === true,
|
|
1165
|
+
note: "只改 rows 分组与这些控件的 span;其它控件属性/HTML 逐键保留,未列入 rows 的控件保留基线行(锚定在被点名控件周围)",
|
|
1166
|
+
};
|
|
1167
|
+
return { viewJson: JSON.stringify(finalRows), attributesJson: JSON.stringify(composed), receipt, warnings };
|
|
1168
|
+
}
|
|
848
1169
|
export async function lintFormControlTypes(session, args) {
|
|
849
1170
|
if (typeof args.draftAttributesJson !== "string")
|
|
850
1171
|
return undefined;
|
|
@@ -989,6 +1310,10 @@ function hasExplicitDraftIntent(args) {
|
|
|
989
1310
|
export function refuseEmptyCallerLayout(args) {
|
|
990
1311
|
if (args.allowEmptyLayout === true)
|
|
991
1312
|
return;
|
|
1313
|
+
// layout 是增量面:完整 view/attrs 由 composeFormLayoutDraft 从基线组合出来,
|
|
1314
|
+
// 调用方本来就不传整包面——这不是「没有布局意图」。
|
|
1315
|
+
if (args.layout !== undefined)
|
|
1316
|
+
return;
|
|
992
1317
|
const emptyFaces = [];
|
|
993
1318
|
if (typeof args.draftViewJson === "string" && isEmptyLayoutJson(args.draftViewJson))
|
|
994
1319
|
emptyFaces.push("draftViewJson");
|
|
@@ -1463,6 +1788,10 @@ export function readFormButtons(options) {
|
|
|
1463
1788
|
* so the high-level orchestrator never bypasses the scaffold.
|
|
1464
1789
|
*/
|
|
1465
1790
|
export async function executeFormDraftWrite(session, args) {
|
|
1791
|
+
// 增量布局面(探针 G F3):与整包布局/重建参数互斥,必须在组合之前判。
|
|
1792
|
+
const layoutRequest = args.layout;
|
|
1793
|
+
if (layoutRequest !== undefined)
|
|
1794
|
+
assertLayoutRequestConflicts({ ...args });
|
|
1466
1795
|
// 兼容别名:`fieldCodes:["items.category"]` 等价于
|
|
1467
1796
|
// `childColumns:[{parent:"items",fieldCodes:["category"]}]`(issue #24)。
|
|
1468
1797
|
// 点号形式是使用者最自然的写法——子表列在父模型里本来就该这样指代。
|
|
@@ -1490,6 +1819,17 @@ export async function executeFormDraftWrite(session, args) {
|
|
|
1490
1819
|
if (args.draftHtmlJson !== undefined) {
|
|
1491
1820
|
assertHtmlRender(args.draftHtmlJson, { schemaCode: args.schemaCode, sheetCode: args.sheetCode, face: "draftHtmlJson" });
|
|
1492
1821
|
}
|
|
1822
|
+
// 增量布局面:以已发布(无则草稿)控件面为基线组合出完整 viewJson/attributesJson。
|
|
1823
|
+
// 组合失败(无基线/未知控件/系统控件/span 不自洽)就在任何 wire 之前拒;dry-run 走
|
|
1824
|
+
// 同一个 composeFormLayoutDraft(见 form.draft 的 writeLint),两边答案逐字相同。
|
|
1825
|
+
let layoutReceipt;
|
|
1826
|
+
let composedLayoutWarnings = [];
|
|
1827
|
+
if (layoutRequest !== undefined) {
|
|
1828
|
+
const composed = await composeFormLayoutDraft(session, { schemaCode: args.schemaCode, sheetCode: args.sheetCode, layout: layoutRequest });
|
|
1829
|
+
layoutReceipt = composed.receipt;
|
|
1830
|
+
composedLayoutWarnings = composed.warnings;
|
|
1831
|
+
args = { ...args, draftViewJson: composed.viewJson, draftAttributesJson: composed.attributesJson };
|
|
1832
|
+
}
|
|
1493
1833
|
// Caller-provided layouts get the distribution-grade shape gate (options
|
|
1494
1834
|
// objects, string viewJson cells, no child keys as rows) before any wire.
|
|
1495
1835
|
// Ticket 74 — refuse CALLER-PROVIDED empty layouts before any wire call.
|
|
@@ -1567,7 +1907,8 @@ export async function executeFormDraftWrite(session, args) {
|
|
|
1567
1907
|
// 是工具从已存平台布局追加子表列——两者都不是手写布局,跳过;调用方显式
|
|
1568
1908
|
// allowTypeMismatch:true 时降级为回执 warning(不偷偷改用户输入)。
|
|
1569
1909
|
let controlTypeWarnings;
|
|
1570
|
-
|
|
1910
|
+
// layout 面只改 rows/span,不 author 控件 type:基线里的 type 原样保留,不做枚举交叉校验。
|
|
1911
|
+
if (layoutRequest === undefined && args.draftAttributesJson !== undefined && args.fromReadback !== true && args.amendChildColumns !== true) {
|
|
1571
1912
|
const typeLint = await lintFormControlTypes(session, {
|
|
1572
1913
|
schemaCode: args.schemaCode,
|
|
1573
1914
|
sheetCode: args.sheetCode,
|
|
@@ -1637,7 +1978,9 @@ export async function executeFormDraftWrite(session, args) {
|
|
|
1637
1978
|
// the violations reported as warnings. Caller-authored layouts stay strict.
|
|
1638
1979
|
const roundTripFaces = new Set();
|
|
1639
1980
|
let layoutWarnings = [];
|
|
1640
|
-
|
|
1981
|
+
// layout 组合面已由 composeFormLayoutDraft 做「调用方 rows/spans 严判 + 平台保序行容忍」
|
|
1982
|
+
// 校验,不再按调用方手写整包布局二次严判(基线是平台自己的形状)。
|
|
1983
|
+
if (layoutRequest === undefined && (args.draftViewJson !== undefined || args.draftAttributesJson !== undefined)) {
|
|
1641
1984
|
const pre2 = pre;
|
|
1642
1985
|
const same = (provided, stored) => typeof provided === "string" && typeof stored === "string" && provided.trim() === stored.trim();
|
|
1643
1986
|
const viewRoundTrip = same(args.draftViewJson, pre2?.publishedViewJson) || same(args.draftViewJson, pre2?.draftViewJson);
|
|
@@ -1871,6 +2214,8 @@ export async function executeFormDraftWrite(session, args) {
|
|
|
1871
2214
|
// stored column is the stringified form the form page refuses to render.
|
|
1872
2215
|
...(customButtonJsonStoredShape(sheet.options) === "string" ? { formButtonsShapeWarning: CUSTOM_BUTTON_JSON_STRING_SHAPE_WARNING } : {}),
|
|
1873
2216
|
...(mergedOptions !== undefined ? { customButtonJsonWritten: true } : {}),
|
|
2217
|
+
...(layoutReceipt !== undefined ? { layout: layoutReceipt } : {}),
|
|
2218
|
+
...(composedLayoutWarnings.length > 0 ? { layoutWarnings: composedLayoutWarnings } : {}),
|
|
1874
2219
|
...(controlTypeWarnings !== undefined
|
|
1875
2220
|
? {
|
|
1876
2221
|
controlTypeMismatchAllowed: true,
|
package/dist/goal-routes.js
CHANGED
|
@@ -552,6 +552,58 @@ function orderedCapabilities(ids, index) {
|
|
|
552
552
|
* runtime/exact patches), not a second main path.
|
|
553
553
|
*/
|
|
554
554
|
const WHOLE_PACKAGE_CAPABILITIES = ["model", "field", "form", "listview", "datarule", "businessrule", "workflow", "onlinejs"];
|
|
555
|
+
/**
|
|
556
|
+
* F5(0.8.11,探针 F):整包路线推荐 intent 时,必须同时说清**intent 能/不能
|
|
557
|
+
* 覆盖什么**。
|
|
558
|
+
*
|
|
559
|
+
* 真机现象(0.8.10):`next "整包…"` 只给 `route.primary:"intent"` + 7 步
|
|
560
|
+
* `atomicSupplement.ladder`,没有一句解释覆盖面。agent 按推荐写完 YAML、apply
|
|
561
|
+
* 之后才发现:表单只有 publish/fieldCodes(两列布局要 `form.draft`)、listview
|
|
562
|
+
* 只声明列(排序/筛选要 `listview.configure`)、workflow 只到模板+发布(提交/
|
|
563
|
+
* 审批是 runtime 操作)、子表取主表字段的映射回填与精确 patch 以 `child-map-fill`
|
|
564
|
+
* 原子配方为事实源——一半需求要回落 `omc call`,而这些本可以在第一答里说清。
|
|
565
|
+
*
|
|
566
|
+
* 覆盖面文案与 `omc intent schema` 同源(schema.ts 的 form/listview/fields/
|
|
567
|
+
* workflow 节),改 schema 时同步本块。只挂在**整包且 primary=intent** 的
|
|
568
|
+
* route 上:单面 recipe/read/composer 路线不加(那是噪音,且它们本来就不是
|
|
569
|
+
* 声明式路径)。
|
|
570
|
+
*/
|
|
571
|
+
const INTENT_COVERAGE = Object.freeze({
|
|
572
|
+
note: "intent 覆盖面(与 `omc intent schema` 同源):covered 由 validate/plan/apply 声明式生成;needsCall 是 intent 不声明(或运行语义/精确 patch 不在声明面)的部分,apply 后用 command 走原子面补齐。",
|
|
573
|
+
covered: [
|
|
574
|
+
"模型 model(含 absent 删除)",
|
|
575
|
+
"标量字段与子表标量列(CHILD_TABLE subFields)",
|
|
576
|
+
"字段发布 field.publish",
|
|
577
|
+
"表单发布 form.publish + 绑定字段 form.fieldCodes",
|
|
578
|
+
"列表视图列 listview.fieldCodes",
|
|
579
|
+
"业务规则 rules(actions 紧凑 / nodeGraph 透传)",
|
|
580
|
+
"字段级数据规则 datarules",
|
|
581
|
+
"流程模板 + 发布 + 规则绑定 workflow(template/publish/bindRules)",
|
|
582
|
+
"在线 JS onlinejs、业务服务/方法 services",
|
|
583
|
+
],
|
|
584
|
+
needsCall: [
|
|
585
|
+
{
|
|
586
|
+
id: "child-map-fill",
|
|
587
|
+
what: "子表取主表字段:WORK_SHEET 关联列 + options.mappings(intent 子列可声明 relativeCode/options;映射回填只在门户表单执行、REST 不回填,精确改映射与读回以 child-map-fill 配方为准)",
|
|
588
|
+
command: "omc describe field.create --example child-map-fill",
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
id: "form-two-column-layout",
|
|
592
|
+
what: "表单两列布局(intent 的 form 只有 publish/fieldCodes,不含行分组/控件 span)",
|
|
593
|
+
command: "omc describe form.draft --example two-column-layout",
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
id: "listview-sorts-conditions",
|
|
597
|
+
what: "列表视图业务排序/筛选条件(intent 的 listview 只声明列,排序/条件/按钮 apply 后用 listview.configure 补)",
|
|
598
|
+
command: "omc describe listview.configure --param sorts",
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
id: "workflow-runtime",
|
|
602
|
+
what: "审批运行操作:提交/审批/待办/流转(intent 的 workflow 只到模板+发布+绑规则,运行实例走 data.save/data.submit/workitem.list)",
|
|
603
|
+
command: "omc describe data.submit --example workflow-backed-data-submit",
|
|
604
|
+
},
|
|
605
|
+
],
|
|
606
|
+
});
|
|
555
607
|
const COMPOSER_ROUTES = Object.freeze([
|
|
556
608
|
{
|
|
557
609
|
id: "model-purge",
|
|
@@ -773,9 +825,13 @@ function wholePackageRoute(registry, goal, index, hitCapabilities) {
|
|
|
773
825
|
ladder: atomicLadder,
|
|
774
826
|
}),
|
|
775
827
|
faceCount: faces.length,
|
|
828
|
+
// F5(0.8.11):主推 intent 时先交代「能/不能覆盖什么」,别让 agent 写完
|
|
829
|
+
// YAML 才发现半边需求要回落 omc call。atomic 主路径(intent.level=none)
|
|
830
|
+
// 不加——它没有推荐 intent,说明覆盖面只会误导。
|
|
831
|
+
...(intentCovered ? { intentCoverage: INTENT_COVERAGE } : {}),
|
|
776
832
|
atomicSupplement: {
|
|
777
833
|
note: intentCovered
|
|
778
|
-
? "intent 已覆盖下列能力的创建;原子工具只用于 intent 未覆盖面(删除/生命周期/运行数据/精确 patch
|
|
834
|
+
? "intent 已覆盖下列能力的创建;原子工具只用于 intent 未覆盖面(删除/生命周期/运行数据/精确 patch)——逐项见 intentCoverage.needsCall"
|
|
779
835
|
: "intent 仅覆盖下列能力中的部分面;未覆盖能力必须走原子工具",
|
|
780
836
|
capabilities: ordered,
|
|
781
837
|
// round16b: 这是**指针**(capability + why),不是第二套执行阶梯——
|
|
@@ -1517,7 +1573,7 @@ function goalRouteInner(registry, goal) {
|
|
|
1517
1573
|
match: { kind: readish ? "read-ladder" : "ladder", ref: `${routeOrder.join("→")}${routeOrder.includes("businessrule") && /累加|联动|审计|规则触发|自动累加|自动回写/.test(goal) ? "(规则面不在本阶梯)" : ""}`, capabilities: routeOrder },
|
|
1518
1574
|
route: {
|
|
1519
1575
|
...(whole ? (intentCoveredOf(ordered)
|
|
1520
|
-
? { primary: "intent", atomicSupplement }
|
|
1576
|
+
? { primary: "intent", intentCoverage: INTENT_COVERAGE, atomicSupplement }
|
|
1521
1577
|
: { primary: "atomic", note: "命中能力中有 intent.level=none 的面,声明式 intent 不覆盖全部需求,走原子工具阶梯", ladder }) : { ladder }),
|
|
1522
1578
|
// r28e F2(真机复现 2026-11-05):`next "建表单布局、在线JS、表单按钮"`
|
|
1523
1579
|
// 命中的是 model→form→listview→businessrule→onlinejs 的整包 ladder,
|
|
@@ -1615,7 +1671,7 @@ function goalRouteInner(registry, goal) {
|
|
|
1615
1671
|
capability: capabilityId,
|
|
1616
1672
|
lane: route.lane,
|
|
1617
1673
|
...(whole ? (intentCoveredOf([capabilityId])
|
|
1618
|
-
? { primary: "intent" }
|
|
1674
|
+
? { primary: "intent", intentCoverage: INTENT_COVERAGE }
|
|
1619
1675
|
: { primary: "atomic", note: "该能力无声明式面(intent.level=none),走原子工具" }) : {}),
|
|
1620
1676
|
...(readish ? { readTools: readToolsInLane(registry, route.lane) } : { tools: route.tools }),
|
|
1621
1677
|
// r66 ②(c-F4):有依赖顺序的能力(report)显式给 order,修掉 tools 键序
|
|
@@ -45,6 +45,50 @@ function relationCodeOf(field) {
|
|
|
45
45
|
const raw = field.options?.relativeCode ?? field.options?.schemaCode;
|
|
46
46
|
return typeof raw === "string" && raw.trim() ? raw.trim() : undefined;
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* 0.8.11 P0(探针 F):同一意图里既新建模型 A、又在模型 B 的关联字段(或子表关联列)
|
|
50
|
+
* 指向 A 时,plan 曾通过而 apply 在写前门被 `relation-target-not-found` 全量拒绝——
|
|
51
|
+
* 门的候选集只来自**基线**模型清单,不含本 plan 声明并即将创建的模型。
|
|
52
|
+
*
|
|
53
|
+
* `relationTargetsFromPlan` 列出「本包会提供的关联目标」:意图声明为存在、基线里还
|
|
54
|
+
* 不存在(本次 apply 会先 model.create)。plan 回执用它让调用方在 plan 阶段就能确认
|
|
55
|
+
* 同包引用可解析;apply 的写前门另按 changes 里**实际先于该字段**的 `model.create`
|
|
56
|
+
* 判,顺序被改坏时不会误放行。
|
|
57
|
+
*/
|
|
58
|
+
export function relationTargetsFromPlan(intent, baseline) {
|
|
59
|
+
const present = new Set(baseline.models.filter((model) => model.present).map((model) => model.code));
|
|
60
|
+
const declared = new Set(intent.models.filter((model) => model.absent !== true).map((model) => model.code));
|
|
61
|
+
const targets = new Set();
|
|
62
|
+
const collect = (target) => {
|
|
63
|
+
if (target && declared.has(target) && !present.has(target))
|
|
64
|
+
targets.add(target);
|
|
65
|
+
};
|
|
66
|
+
for (const model of intent.models) {
|
|
67
|
+
if (model.absent === true)
|
|
68
|
+
continue;
|
|
69
|
+
for (const field of model.fields) {
|
|
70
|
+
if (field.absent === true)
|
|
71
|
+
continue;
|
|
72
|
+
collect(relationCodeOf(field));
|
|
73
|
+
for (const sub of field.subFields ?? [])
|
|
74
|
+
collect(sub.relativeCode?.trim());
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return [...targets].sort();
|
|
78
|
+
}
|
|
79
|
+
/** The relation target a `field.create` payload names (top-level relativeCode wins, then options). */
|
|
80
|
+
function relationTargetOfPayload(args) {
|
|
81
|
+
const relative = typeof args.relativeCode === "string" ? args.relativeCode.trim() : "";
|
|
82
|
+
if (relative)
|
|
83
|
+
return relative;
|
|
84
|
+
const options = args.options;
|
|
85
|
+
if (options !== null && typeof options === "object" && !Array.isArray(options)) {
|
|
86
|
+
const schemaCode = options.schemaCode;
|
|
87
|
+
if (typeof schemaCode === "string")
|
|
88
|
+
return schemaCode.trim();
|
|
89
|
+
}
|
|
90
|
+
return "";
|
|
91
|
+
}
|
|
48
92
|
const familyOf = (wireType) => Object.entries(FIELD_PROPERTY_TYPES).find(([, value]) => value === wireType)?.[0];
|
|
49
93
|
/** Explicit option keys the intent declares (relations lift `relativeCode` to the row). */
|
|
50
94
|
function declaredOptionKeys(field) {
|
|
@@ -236,17 +280,33 @@ export async function lintIntentFieldCreateChanges(session, intent, changes) {
|
|
|
236
280
|
const overlays = intentOwnFieldOverlays(intent);
|
|
237
281
|
if (overlays.size === 0)
|
|
238
282
|
return undefined;
|
|
239
|
-
const relevant = changes
|
|
283
|
+
const relevant = changes
|
|
284
|
+
.map((change, index) => ({ change, index }))
|
|
285
|
+
.filter(({ change }) => change.tool === "field.create" && overlays.has(String(change.args.schemaCode ?? "")));
|
|
240
286
|
if (relevant.length === 0)
|
|
241
287
|
return undefined;
|
|
288
|
+
// 0.8.11 P0(探针 F):候选集必须含**本 plan 里在该字段之前 model.create 的模型**。
|
|
289
|
+
// 能力分级排序把 model 全部排在 field 之前,所以同包目标在写入时确实已存在;
|
|
290
|
+
// 只认「先于该字段」的创建(不按意图声明整包放行),顺序若被改坏仍会拒绝。
|
|
291
|
+
const createIndex = new Map();
|
|
292
|
+
changes.forEach((change, index) => {
|
|
293
|
+
if (change.tool !== "model.create")
|
|
294
|
+
return;
|
|
295
|
+
const code = String(change.args.code ?? "").trim();
|
|
296
|
+
if (code && !createIndex.has(code))
|
|
297
|
+
createIndex.set(code, index);
|
|
298
|
+
});
|
|
299
|
+
const declaredPresent = new Set(intent.models.filter((model) => model.absent !== true).map((model) => model.code));
|
|
242
300
|
// One model-list read for the whole plan (field.create would read it per field).
|
|
243
301
|
const relationCandidates = await modelSchemaCodes(session);
|
|
244
302
|
const targetVersion = session.detectedVersion();
|
|
245
|
-
for (const change of relevant) {
|
|
303
|
+
for (const { change, index } of relevant) {
|
|
246
304
|
const schemaCode = String(change.args.schemaCode ?? "");
|
|
305
|
+
const createdBefore = [...createIndex.entries()].filter(([, at]) => at < index).map(([code]) => code);
|
|
306
|
+
const candidates = createdBefore.length > 0 ? [...new Set([...relationCandidates, ...createdBefore])] : relationCandidates;
|
|
247
307
|
try {
|
|
248
308
|
await lintFieldCreateWrite(session, gateInputOf(schemaCode, change.args, targetVersion), {
|
|
249
|
-
relationCandidates,
|
|
309
|
+
relationCandidates: candidates,
|
|
250
310
|
pendingOwnFields: overlays.get(schemaCode),
|
|
251
311
|
});
|
|
252
312
|
}
|
|
@@ -254,14 +314,28 @@ export async function lintIntentFieldCreateChanges(session, intent, changes) {
|
|
|
254
314
|
if (!(error instanceof ToolRefusalError))
|
|
255
315
|
throw error;
|
|
256
316
|
const { status: _status, ...detail } = error.payload;
|
|
317
|
+
const target = relationTargetOfPayload(change.args);
|
|
318
|
+
const declaredButCreatedLater = target.length > 0
|
|
319
|
+
&& declaredPresent.has(target)
|
|
320
|
+
&& !createdBefore.includes(target)
|
|
321
|
+
&& !relationCandidates.includes(target);
|
|
257
322
|
return {
|
|
258
323
|
status: "refused",
|
|
259
324
|
...detail,
|
|
325
|
+
...(createdBefore.length > 0 ? { relationTargetsFromPlan: createdBefore } : {}),
|
|
260
326
|
intentField: {
|
|
261
327
|
schemaCode,
|
|
262
328
|
code: String(change.args.code ?? ""),
|
|
263
329
|
...(change.resource !== undefined ? { resource: change.resource } : {}),
|
|
264
330
|
},
|
|
331
|
+
...(declaredButCreatedLater
|
|
332
|
+
? {
|
|
333
|
+
relationTargetOrdering: {
|
|
334
|
+
target,
|
|
335
|
+
message: `关联目标 ${target} 是本意图声明的模型,但 plan 里没有在该字段之前创建它——重新 intent plan(模型创建由能力排序排在全部字段创建之前),不要手工调整 plan 顺序`,
|
|
336
|
+
},
|
|
337
|
+
}
|
|
338
|
+
: {}),
|
|
265
339
|
message: `${String(detail.message ?? "字段写前语义门拒绝")};intent apply 在任何写 wire 之前按整包字段面判定,本次零写入——修正意图后重新 intent plan`,
|
|
266
340
|
nextAction: "fix the declared fields/mappings in the intent, then re-run intent plan + apply",
|
|
267
341
|
};
|