@stalfh233/omc-cli 0.4.14 → 0.4.15

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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/dist/cli.js +20 -1
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -246,12 +246,12 @@ src/ args/support/plan/read/write/package/context(治理管道)
246
246
 
247
247
  ## npm 分发
248
248
 
249
- 本包(`@stalfh233/omc-cli`,可执行命令仍是 `omc`)通过公共 npm registry 分发。`omc-core` 是 `omc-cli` 的内部依赖,发布时先发 `omc-core`,再发 `omc-cli`;两者版本保持一致。当前版本为 `0.4.14`,尚未宣称 `1.0.0` 稳定契约。
249
+ 本包(`@stalfh233/omc-cli`,可执行命令仍是 `omc`)通过公共 npm registry 分发。`omc-core` 是 `omc-cli` 的内部依赖,发布时先发 `omc-core`,再发 `omc-cli`;两者版本保持一致。当前版本为 `0.4.15`,尚未宣称 `1.0.0` 稳定契约。
250
250
 
251
251
  ### 使用已发布包
252
252
 
253
253
  ```bash
254
- npm install -g @stalfh233/omc-cli@0.4.14
254
+ npm install -g @stalfh233/omc-cli@0.4.15
255
255
  omc setup
256
256
  omc doctor
257
257
  omc help omc-write-hazards
package/dist/cli.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createInterface } from "node:readline/promises";
3
3
  import { stdin, argv } from "node:process";
4
+ import { createRequire } from "node:module";
4
5
  import { Command, CommanderError } from "commander";
5
6
  import { ConfigStore, defaultPaths, removedProfileKeys } from "./config-store.js";
6
7
  import { loadCoverageManifest, versionFamilyNotice } from "./coverage.js";
@@ -1309,6 +1310,15 @@ async function main() {
1309
1310
  let commandExitCode = 0;
1310
1311
  beginUsage(argv);
1311
1312
  const command = new Command();
1313
+ const ownPackageVersion = () => {
1314
+ try {
1315
+ // ESM 下读自身包根的 package.json(安装形态与源码形态都成立)
1316
+ return String(createRequire(import.meta.url)("../package.json").version);
1317
+ }
1318
+ catch {
1319
+ return "unknown";
1320
+ }
1321
+ };
1312
1322
  try {
1313
1323
  configureOutput(argv);
1314
1324
  }
@@ -1320,6 +1330,13 @@ async function main() {
1320
1330
  command.exitOverride();
1321
1331
  command.configureOutput({ writeOut: (text) => process.stderr.write(text), writeErr: (text) => process.stderr.write(text) });
1322
1332
  command.name("omc").showHelpAfterError().showSuggestionAfterError(true);
1333
+ // --version 短路:commander 的 version 走 process.exit,会被 exitOverride 包成
1334
+ // invalid-input 信封(exit 10);cpdocs --omc-global 的探测要干净的 exit 0。
1335
+ const bare = argv.slice(2).filter((a) => a !== "--");
1336
+ if (bare.includes("--version") || bare.includes("-V")) {
1337
+ process.stdout.write(`${ownPackageVersion()}\n`);
1338
+ return 0;
1339
+ }
1323
1340
  command.addHelpText("after", `\n${onboardingHelp()}\n`);
1324
1341
  // No command at all: guide the agent (help text + onboarding), exit 0. This
1325
1342
  // is a benign "show me the surface" invocation, not a failure.
@@ -1388,7 +1405,9 @@ function finish(code) {
1388
1405
  }
1389
1406
  const request = requestId();
1390
1407
  main().then((code) => {
1391
- if (argv[2] === "call" || argv[2] === "artifact" || argv[2] === "commands" || argv[2] === "describe" || argv[2] === "contract" || argv[2] === "capabilities" || argv[2] === "capability" || argv[2] === "next" || argv[2] === "usage" || argv[2] === "intent" || argv[2] === "help") {
1408
+ // Commands that own their stdout never grow a trailing envelope. `--version`/
1409
+ // `-V` are here because their short-circuit already wrote the bare version.
1410
+ if (argv[2] === "call" || argv[2] === "artifact" || argv[2] === "commands" || argv[2] === "describe" || argv[2] === "contract" || argv[2] === "capabilities" || argv[2] === "capability" || argv[2] === "next" || argv[2] === "usage" || argv[2] === "intent" || argv[2] === "help" || argv[2] === "--version" || argv[2] === "-V") {
1392
1411
  completeUsage(code);
1393
1412
  finish(code);
1394
1413
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.4.14",
3
+ "version": "0.4.15",
4
4
  "description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "commander": "14.0.3",
54
- "omc-core": "0.4.14",
54
+ "omc-core": "0.4.15",
55
55
  "proper-lockfile": "4.1.2",
56
56
  "write-file-atomic": "6.0.0",
57
57
  "zod": "^3.23.8",