@stalfh233/omc-cli 0.6.85 → 0.6.87

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.
@@ -43,7 +43,7 @@ export function intentCapabilityBlock() {
43
43
  declarativeCapabilities: { model: "partial", field: "partial", businessrule: "partial", datarule: "partial", workflow: "partial", onlinejs: "partial", bizservice: "partial", report: "partial" },
44
44
  absence: "models[].absent:true deletes a whole model; fields[]/listview/datarules[] take absent:true too. Only declared-absent resources are deleted; riskClass becomes destructive and plan.cleanup lists them.",
45
45
  workflowBindings: "models[].workflow.bindRules: [{handler: start|cancel|activate|end, ruleCodes:[...]}] ensures the rules are bound (workflow.bindRule MERGES; undeclared bindings are ignored).",
46
- servicesNote: "top-level services[] registers a new service (optional one method) or patches an existing one; adding a method to an existing service has no declarative tool yet.",
46
+ servicesNote: "top-level services[] registers or patches a service. method (single, name==code, rides service.register) and methods[] (multiple, name may differ from code; missing methods planned as method.create, drift as method.update) are mutually exclusive.",
47
47
  reportsNote: "top-level reports[] creates/configures a report page + BI dashboard (global/attributes/charts); charts diff by uuid, removeUnlistedCharts:true deletes undeclared charts. Only declared reports are touched.",
48
48
  applyVerification: {
49
49
  default: "on",
@@ -19,10 +19,12 @@ function absentModel(code) {
19
19
  export function compileIntent(intent, baseline) {
20
20
  const changes = [];
21
21
  const skipped = [];
22
+ const warnings = [];
22
23
  const capabilities = orderedCapabilities();
23
24
  const emit = {
24
25
  change: (tool, args, resource, reason) => changes.push({ tool, args, resource, reason }),
25
26
  skip: (resource, reason) => skipped.push({ resource, reason }),
27
+ warn: (resource, message, code) => warnings.push({ resource, message, ...(code !== undefined ? { code } : {}) }),
26
28
  };
27
29
  const stateOf = (code) => baseline.models.find((entry) => entry.code === code) ?? absentModel(code);
28
30
  // A declared-absent model only ever plans its own deletion, so restrict it to
@@ -49,10 +51,15 @@ export function compileIntent(intent, baseline) {
49
51
  ...(model.onlinejs ? { onlinejs: { published: model.onlinejs.publish } } : {}),
50
52
  };
51
53
  });
52
- const expectedServices = (intent.services ?? []).map((service) => ({
54
+ const expectedServices = (intent.services ?? [])
55
+ // A declared-absent service/method is a deletion target: it must not appear
56
+ // in the readback expectation (otherwise the plan contradicts itself).
57
+ .filter((service) => service.absent !== true)
58
+ .map((service) => ({
53
59
  service: service.code,
54
- adapterCode: service.adapterCode,
55
- ...(service.method ? { methodCode: service.method.code } : {}),
60
+ adapterCode: service.adapterCode ?? "",
61
+ ...(service.method && service.method.absent !== true ? { methodCode: service.method.code } : {}),
62
+ ...(service.methods !== undefined ? { methodCodes: service.methods.filter((method) => method.absent !== true).map((method) => method.code) } : {}),
56
63
  }));
57
64
  const expectedReports = (intent.reports ?? []).map((report) => ({
58
65
  report: report.code,
@@ -74,6 +81,6 @@ export function compileIntent(intent, baseline) {
74
81
  // approval. It only ever names resources the intent explicitly declared
75
82
  // absent — the ensure-present ownership boundary is unchanged.
76
83
  const cleanup = deletes.map((change) => ({ resource: change.resource, action: change.tool }));
77
- return { changes, skipped, riskClass, expectedReadback, expectedServices, expectedReports, cleanup };
84
+ return { changes, skipped, ...(warnings.length > 0 ? { warnings } : {}), riskClass, expectedReadback, expectedServices, expectedReports, cleanup };
78
85
  }
79
86
  //# sourceMappingURL=compiler.js.map
@@ -11,6 +11,7 @@ import { makeToolContext } from "../context.js";
11
11
  import { SessionManager } from "../session-manager.js";
12
12
  import { ConfigStore, defaultPaths } from "../config-store.js";
13
13
  import { buildToolRegistry } from "../tools.js";
14
+ import { executeChangesBatch } from "../lanes/apply-changes.js";
14
15
  import { acquireWriteLock } from "../write-lock.js";
15
16
  import { wireCall, WireError } from "../wire.js";
16
17
  import { ENDPOINTS } from "../endpoints.js";
@@ -213,7 +214,12 @@ export async function planIntent(intent, environment, planOut) {
213
214
  });
214
215
  const planJson = JSON.stringify(plan, null, 2) + "\n";
215
216
  const artifact = createArtifact(artifactRoot(), planJson);
216
- const warnings = intentWarnings(intent);
217
+ // Plan-time warnings authored by the capabilities (e.g. a referenced method
218
+ // delete) join the assembler's own lint warnings on the decision face.
219
+ const warnings = [
220
+ ...(compiled.warnings ?? []).map((warning) => ({ resource: warning.resource, code: warning.code ?? "plan-warning", message: warning.message })),
221
+ ...intentWarnings(intent),
222
+ ];
217
223
  // r39: a destructive plan that deletes a model carrying runtime data got
218
224
  // ZERO warning — the approval object must surface the blast radius. One
219
225
  // cheap total-only query per declared-absent model (never blocks the plan:
@@ -455,6 +461,7 @@ export async function applyIntent(planPath, options, ports) {
455
461
  changes: plan.changes,
456
462
  skippedCount: plan.skipped.length,
457
463
  riskClass: plan.riskClass,
464
+ ...(plan.warnings !== undefined ? { warnings: plan.warnings } : {}),
458
465
  preview: [...toolCounts.entries()].map(([tool, count]) => (count > 1 ? `${tool}×${count}` : tool)).join("、") || "无变更",
459
466
  });
460
467
  }
@@ -516,7 +523,13 @@ export async function applyIntent(planPath, options, ports) {
516
523
  // stages — fields/views drop first, the model shell lags a moment. An
517
524
  // immediate readback then reports a phantom mismatch. Retry the live
518
525
  // verification briefly (bounded) before declaring failure.
519
- const declaresAbsence = plan.intent.models.some((model) => model.absent === true);
526
+ const declaresAbsence = plan.intent.models.some((model) => model.absent === true)
527
+ // T3: service/method deletion propagates the same way (service delete
528
+ // cascades methods, BizServiceServiceImpl.java:259-273).
529
+ || (plan.intent.services ?? []).some((service) => service.absent === true || service.method?.absent === true || (service.methods ?? []).some((method) => method.absent === true));
530
+ const absenceNote = plan.intent.models.some((model) => model.absent === true)
531
+ ? "本变更含 absent:true 删除:平台删除分阶段传播(字段/视图先撤、模型壳后撤),已做 3 次间隔读回仍不等价——先用 model.inspect 的 modelPresent 独立复核再判定;若 modelPresent:false 则删除实际已生效"
532
+ : "本变更含服务/方法 absent:true 删除:删除按平台自身的传播节奏生效(服务删除会级联方法),已做 3 次间隔读回仍不等价——先 service.get(服务面 + 方法列表)独立复核对账;服务已 500001 即删除实际已生效";
520
533
  const attempt = await verifyWithRetry(async () => {
521
534
  try {
522
535
  const report = await verifyIntentLive(session, plan.intent);
@@ -539,7 +552,7 @@ export async function applyIntent(planPath, options, ports) {
539
552
  verification,
540
553
  ...(declaresAbsence
541
554
  ? {
542
- note: "本变更含 absent:true 删除:平台删除分阶段传播(字段/视图先撤、模型壳后撤),已做 3 次间隔读回仍不等价——先用 model.inspect 的 modelPresent 独立复核再判定;若 modelPresent:false 则删除实际已生效",
555
+ note: absenceNote,
543
556
  }
544
557
  : {}),
545
558
  message: "变更已执行,但最终权威读回与意图不等价:交付可能不完整或环境已漂移。按 differences 定位后重新 intent plan(不要盲重试)",
@@ -565,12 +578,16 @@ export async function applyIntent(planPath, options, ports) {
565
578
  // 审计行时读取),不是工具入参、不进 schema。逐步写本身不产生 journal 行
566
579
  // (无 before 快照),所以审计只到「谁用哪份意图、为什么」这一层。
567
580
  const auditContext = options.reason === undefined ? context : { ...context, writeAudit: { reason: options.reason } };
568
- result = (await applyChanges.handler(auditContext, parseToolInput(applyChanges, {
581
+ // B1:执行段直接进入共享批管线(executeChangesBatch → 共享 governed batch
582
+ // executor);intent 自己的门(写锁 / plan 完整性 / baseline drift / 最终
583
+ // 读回 / --no-verify)全部留在本层。回执字段与经 apply_changes.handler
584
+ // 调用时逐字一致(同一个 plan/审批/逐步读回投影)。
585
+ result = (await executeChangesBatch(auditContext, parseToolInput(applyChanges, {
569
586
  changes,
570
587
  environment: plan.environment,
571
588
  summary,
572
589
  ...(options.confirmProduction === true ? { confirmProduction: true } : {}),
573
- }), applyChanges));
590
+ }), registry));
574
591
  }
575
592
  catch (error) {
576
593
  if (error instanceof ToolInputError)
@@ -30,6 +30,7 @@ export function buildPlan(input) {
30
30
  intentHash: intentHashOf(input.intent),
31
31
  changes: input.compiled.changes,
32
32
  skipped: input.compiled.skipped,
33
+ ...(input.compiled.warnings !== undefined && input.compiled.warnings.length > 0 ? { warnings: input.compiled.warnings } : {}),
33
34
  riskClass: input.compiled.riskClass,
34
35
  expectedReadback: input.compiled.expectedReadback,
35
36
  cleanup: input.compiled.cleanup,
@@ -6,6 +6,83 @@ const newFrontend = () => ({ formBoundFieldCodes: [], listviewPresent: false, li
6
6
  function absentLiveModel(code) {
7
7
  return { code, name: null, present: false, fields: [], form: absentForm, frontend: newFrontend() };
8
8
  }
9
+ /**
10
+ * A7 — every difference carries an actionable next step. These defaults are
11
+ * derived from the difference kind alone (which capability/tool owns the
12
+ * repair, and whether re-planning is enough). A capability may override any of
13
+ * them with exact detail (bizservice fills sourcePath + the concrete repair).
14
+ */
15
+ const REPLAN_COMMAND = "omc intent plan <intent.yaml> --env <env>";
16
+ const replan = (tool) => ({ tool, next: { kind: "replan", command: REPLAN_COMMAND }, safeToReplan: true });
17
+ const declareAbsent = (tool) => ({ tool, next: { kind: "edit-intent" }, safeToReplan: true });
18
+ const escape = (tool, command) => ({ tool, next: { kind: "call", ...(command !== undefined ? { command } : {}) }, escapeHatch: true, safeToReplan: false });
19
+ const DIFFERENCE_DEFAULTS = {
20
+ "model-missing": replan("model.create"),
21
+ "model-name-mismatch": replan("model.update"),
22
+ "field-missing": replan("field.create"),
23
+ "field-name-mismatch": replan("field.update"),
24
+ // A field's wire family is immutable: delete+recreate is the only repair.
25
+ "field-type-mismatch": escape("field.delete"),
26
+ "field-options-mismatch": replan("field.update"),
27
+ "field-option-unwritable": escape("field.update"),
28
+ "field-not-published": replan("field.publish"),
29
+ "form-missing": replan("form.draft"),
30
+ "form-not-published": replan("form.publish"),
31
+ "form-not-bound": replan("form.draft"),
32
+ "listview-missing": replan("listview.create"),
33
+ "listview-columns-missing": replan("listview.configure"),
34
+ "listview-system-columns-unexpected": escape("listview.configure"),
35
+ "child-field-missing": replan("field.update"),
36
+ "child-field-type-mismatch": escape("field.update"),
37
+ "child-field-name-mismatch": replan("field.update"),
38
+ "rule-missing": replan("rule.save"),
39
+ "rule-not-enabled": replan("rule.enable"),
40
+ "rule-enabled-unexpected": escape("rule.save"),
41
+ "rule-graph-mismatch": replan("rule.save"),
42
+ "workflow-missing": replan("workflow.create"),
43
+ "workflow-template-mismatch": replan("workflow.update"),
44
+ "workflow-not-published": replan("workflow.publish"),
45
+ "workflow-rule-not-bound": replan("workflow.bindRule"),
46
+ "onlinejs-missing": replan("onlinejs.compose"),
47
+ "onlinejs-source-mismatch": replan("onlinejs.compose"),
48
+ "onlinejs-not-published": replan("onlinejs.compose"),
49
+ "service-missing": replan("service.register"),
50
+ "service-mismatch": replan("service.update"),
51
+ "method-missing": replan("method.create"),
52
+ "method-mismatch": replan("method.update"),
53
+ "report-missing": replan("report.create"),
54
+ "report-mismatch": replan("report.configure"),
55
+ "report-dashboard-missing": replan("report.configure"),
56
+ "report-charts-mismatch": replan("report.configure"),
57
+ "report-charts-unexpected": replan("report.configure"),
58
+ "datarule-missing": replan("datarule.create"),
59
+ "datarule-mismatch": replan("datarule.create"),
60
+ "model-present-unexpected": declareAbsent("model.delete"),
61
+ "field-present-unexpected": declareAbsent("field.delete"),
62
+ "listview-present-unexpected": declareAbsent("listview.delete"),
63
+ "datarule-present-unexpected": escape("datarule.delete"),
64
+ "service-present-unexpected": declareAbsent("service.delete"),
65
+ "method-present-unexpected": declareAbsent("method.delete"),
66
+ };
67
+ /** Merge a capability's explicit detail over the kind defaults (A7). */
68
+ function differenceOf(kind, resource, message, detail) {
69
+ const fallback = DIFFERENCE_DEFAULTS[kind];
70
+ const sourceTool = detail?.sourceTool ?? fallback.tool;
71
+ const sourcePath = detail?.sourcePath;
72
+ const next = detail?.next ?? fallback.next;
73
+ const escapeHatch = detail?.escapeHatch ?? fallback.escapeHatch;
74
+ const safeToReplan = detail?.safeToReplan ?? fallback.safeToReplan;
75
+ return {
76
+ kind,
77
+ resource,
78
+ message,
79
+ ...(sourceTool !== undefined ? { sourceTool } : {}),
80
+ ...(sourcePath !== undefined ? { sourcePath } : {}),
81
+ ...(next !== undefined ? { next } : {}),
82
+ ...(escapeHatch !== undefined ? { escapeHatch } : {}),
83
+ ...(safeToReplan !== undefined ? { safeToReplan } : {}),
84
+ };
85
+ }
9
86
  /**
10
87
  * Decode a baseline into the intent shape (wire ints -> family names). The
11
88
  * optional `intent` lets a declared-absent model run ONLY the model capability,
@@ -41,7 +118,7 @@ export function compareWithLive(intent, live) {
41
118
  const differences = [];
42
119
  const ignored = [];
43
120
  const emit = {
44
- difference: (kind, resource, message) => differences.push({ kind, resource, message }),
121
+ difference: (kind, resource, message, detail) => differences.push(differenceOf(kind, resource, message, detail)),
45
122
  ignored: (resource) => ignored.push(resource),
46
123
  };
47
124
  const capabilities = orderedCapabilities();
@@ -164,7 +164,7 @@ export function intentSchemaBlock() {
164
164
  conditionOperators: INTENT_CONDITION_OPERATORS,
165
165
  workflow: { required: ["code", "name", "publish"], optional: ["template", "bindRules"], note: "bindRules [{handler: start|cancel|activate|end, ruleCodes:[...]}];流程事件只绑自定义规则" },
166
166
  onlinejs: { required: ["source", "publish"], optional: ["sheetCode", "replace"], note: "replace:true 覆盖;merge 时 source 只给生命周期片段,不能是完整 (function(form){...})" },
167
- services: { required: ["code", "name", "adapterCode", "serviceCategoryId", "serviceConfig"], optional: ["method"], note: "自定义/INTERNAL 适配器走二开扩展包导入,不在声明式写面" },
167
+ services: { required: ["code(present 服务还需要 name/adapterCode/serviceCategoryId/serviceConfig;absent:true 的服务只认 code)"], optional: ["name", "adapterCode", "serviceCategoryId", "serviceConfig", "absent", "method", "methods"], absent: "services[].absent:true 删除整个服务(平台级联删方法,riskClass=destructive);服务仍被规则映射引用时 plan 硬拒(intent-service-referenced,平台自己不拦)——先解绑引用规则并 apply,再删服务。服务保留时 methods[].absent:true 删单方法(平台被引用时回 500108)", note: "method 与 methods 互斥:method 是单方法(name==code,随 service.register);methods[] 是多方法/给既有服务加方法(name 可不同于 code,缺失 plan method.create、漂移 plan method.update)。absent:true 只认 code,带 name/config/method(s) 等 shape 键即拒。自定义/INTERNAL 适配器走二开扩展包导入,不在声明式写面" },
168
168
  examples: RUNNABLE_EXAMPLES.map((example) => ({ id: example.id, title: example.title })),
169
169
  exampleHint: "取可运行 YAML:omc describe intent --example <id>",
170
170
  versionNotice: "intent 只覆盖声明式子集(capabilities 的 intent: partial);未覆盖面用 omc call 补齐。",