@stalfh233/omc-cli 0.4.44 → 0.4.45

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.
@@ -1,5 +1,5 @@
1
1
  import { writeFileSync } from "node:fs";
2
- import { serializeEnvelope } from "./cli-contract.js";
2
+ import { asciiStdout, serializeEnvelope } from "./cli-contract.js";
3
3
  import { recordUsageOutput } from "./usage-log.js";
4
4
  let options = { quiet: false, verbose: false };
5
5
  /** Parse `--quiet`, `--verbose` and `--out <file>` from the raw argv once, before dispatch. */
@@ -63,9 +63,20 @@ function compactForOutput(value) {
63
63
  * reaches stdout — keeping the "exactly one envelope" contract even on failure.
64
64
  * stdout and the file can never diverge (both follow the same verbose rule).
65
65
  */
66
+ let asciiBannerEmitted = false;
67
+ function emitAsciiBannerOnce() {
68
+ if (asciiBannerEmitted)
69
+ return;
70
+ asciiBannerEmitted = true;
71
+ // r73 win32 实测:管道 + 非 UTF-8 代码页时输出被 ASCII 转义(\uXXXX),用户视为乱码。
72
+ // 横幅走 stderr(不进管道、不破坏单信封契约),在痛点时刻给出两个解法。
73
+ process.stderr.write("[omc] 当前控制台代码页非 UTF-8,中文已 ASCII 转义防乱码。要原样中文:chcp 65001 后重跑,或设 OMC_ASCII_STDOUT=0。\n");
74
+ }
66
75
  export function writeEnvelope(value) {
67
76
  const outputValue = compactForOutput(value);
68
77
  const text = serializeEnvelope(outputValue);
78
+ if (asciiStdout())
79
+ emitAsciiBannerOnce();
69
80
  if (!options.outFile) {
70
81
  recordUsageOutput(value, Buffer.byteLength(text, "utf8"));
71
82
  process.stdout.write(text);
package/dist/cli.js CHANGED
@@ -122,7 +122,7 @@ async function cmdDoctor(store, environment, serviceCode) {
122
122
  const chcp = spawnSync("chcp.com", [], { encoding: "utf8" });
123
123
  const active = /([0-9]{3,5})\s*$/.exec((chcp.stdout || "").trim().split("\n").pop() ?? "")?.[1];
124
124
  if (active && active !== "65001") {
125
- steps.push(`编码 ⚠ 活动代码页 ${active}(非 65001)——PowerShell 管道会把 CLI 的 UTF-8 中文输出解成乱码;这是终端解码问题不是 OMC 故障。先 \`chcp 65001\` + \`[Console]::OutputEncoding=[Text.Encoding]::UTF8\` 再读 CLI 输出`);
125
+ steps.push(`编码 ⚠ 活动代码页 ${active}(非 65001)——管道输出会把中文转义为 unicode 形式。要原样中文:\`chcp 65001\` + \`[Console]::OutputEncoding=[Text.Encoding]::UTF8\`,或设 \`OMC_ASCII_STDOUT=0\``);
126
126
  }
127
127
  else if (active === "65001") {
128
128
  steps.push("编码 ok 活动代码页 65001(UTF-8,中文输出无乱码风险)");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.4.44",
3
+ "version": "0.4.45",
4
4
  "description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -59,6 +59,10 @@ A single draft may cover **several** designs; group them by **design surface**:
59
59
  - **Attach the code for identity keys** (model schemaCode, field code, choice
60
60
  values, relation target code) — these are written verbatim and can collide.
61
61
  Pure display labels may omit the code.
62
+ - **编码风格参考(参考非门禁)**:产品规范默认——字段编码=小驼峰(`applyTime`),
63
+ 模型/子表编码=小写下划线(`leave_apply`)。**目标模型既有字段已是另一种风格时,
64
+ 新字段跟随客户既有风格保持整模型一致**(混合风格比统一偏航更伤),并在草稿标注
65
+ 一句"编码风格跟随既有模型"。长度上限与平台保留字仍是强制校验(出门前拒)。
62
66
  - Each section is headed with its design surface + the tool it maps to, so the
63
67
  reviewer can point at one section precisely.
64
68