@stalfh233/omc-cli 0.0.0-stage → 0.4.10

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 (181) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +293 -3
  3. package/coverage/m1-coverage-manifest-v1.json +1278 -0
  4. package/dist/approval-token.js +102 -0
  5. package/dist/args.js +25 -0
  6. package/dist/artifacts.js +119 -0
  7. package/dist/bench/call-face-eval.js +256 -0
  8. package/dist/bench/context-attribution.js +151 -0
  9. package/dist/bench/discovery-cost-eval.js +230 -0
  10. package/dist/bench/driver.js +81 -0
  11. package/dist/bench/evals.js +236 -0
  12. package/dist/bench/fake-http-server.js +65 -0
  13. package/dist/bench/instrument.js +87 -0
  14. package/dist/bench/intent-face-eval.js +343 -0
  15. package/dist/bench/run.js +166 -0
  16. package/dist/bench/scenario.js +343 -0
  17. package/dist/bench/types.js +76 -0
  18. package/dist/bi-wire.js +41 -0
  19. package/dist/bizservice-config.js +581 -0
  20. package/dist/call.js +153 -0
  21. package/dist/capability-absences.js +23 -0
  22. package/dist/capability-overview.js +492 -0
  23. package/dist/capability-shape.js +154 -0
  24. package/dist/cli-contract.js +70 -0
  25. package/dist/cli-output.js +73 -0
  26. package/dist/cli.js +1418 -0
  27. package/dist/code-rules.js +69 -0
  28. package/dist/command-transport.js +155 -0
  29. package/dist/config-store.js +195 -0
  30. package/dist/context.js +21 -0
  31. package/dist/contract-consistency.js +66 -0
  32. package/dist/contract-resources.js +62 -0
  33. package/dist/coverage-consistency.js +62 -0
  34. package/dist/coverage-registry.js +76 -0
  35. package/dist/coverage.js +130 -0
  36. package/dist/data-list-filter.js +114 -0
  37. package/dist/discovery.js +390 -0
  38. package/dist/endpoints.js +154 -0
  39. package/dist/environment-policy.js +26 -0
  40. package/dist/execution-metadata.js +1092 -0
  41. package/dist/fake/app.js +45 -0
  42. package/dist/fake/b2-registration.js +594 -0
  43. package/dist/fake/businessrule.js +242 -0
  44. package/dist/fake/datarule.js +72 -0
  45. package/dist/fake/dictionary.js +108 -0
  46. package/dist/fake/environment.js +30 -0
  47. package/dist/fake/field.js +167 -0
  48. package/dist/fake/form.js +101 -0
  49. package/dist/fake/index.js +121 -0
  50. package/dist/fake/list-view.js +289 -0
  51. package/dist/fake/model.js +136 -0
  52. package/dist/fake/online-js.js +18 -0
  53. package/dist/fake/report.js +253 -0
  54. package/dist/fake/routes.js +47 -0
  55. package/dist/fake/rule-lifecycle.js +37 -0
  56. package/dist/fake/runtime-data.js +367 -0
  57. package/dist/fake/state.js +67 -0
  58. package/dist/fake/workflow.js +364 -0
  59. package/dist/field-change.js +200 -0
  60. package/dist/field-families.js +896 -0
  61. package/dist/form-layout.js +111 -0
  62. package/dist/form-support.js +821 -0
  63. package/dist/goal-routes.js +468 -0
  64. package/dist/governed-execution.js +87 -0
  65. package/dist/human-summary.js +212 -0
  66. package/dist/identity.js +62 -0
  67. package/dist/intent/baseline.js +57 -0
  68. package/dist/intent/capabilities/bizservice.js +274 -0
  69. package/dist/intent/capabilities/businessrule.js +493 -0
  70. package/dist/intent/capabilities/datarule.js +187 -0
  71. package/dist/intent/capabilities/field.js +545 -0
  72. package/dist/intent/capabilities/form.js +136 -0
  73. package/dist/intent/capabilities/index.js +64 -0
  74. package/dist/intent/capabilities/listview.js +157 -0
  75. package/dist/intent/capabilities/model.js +100 -0
  76. package/dist/intent/capabilities/onlinejs.js +108 -0
  77. package/dist/intent/capabilities/report.js +355 -0
  78. package/dist/intent/capabilities/workflow.js +458 -0
  79. package/dist/intent/capability.js +6 -0
  80. package/dist/intent/cli.js +91 -0
  81. package/dist/intent/compare.js +56 -0
  82. package/dist/intent/compiler.js +79 -0
  83. package/dist/intent/dsl.js +129 -0
  84. package/dist/intent/plan-file.js +63 -0
  85. package/dist/intent/readback.js +65 -0
  86. package/dist/intent/schema.js +158 -0
  87. package/dist/intent/validation.js +30 -0
  88. package/dist/intent/yaml.js +315 -0
  89. package/dist/json-column.js +68 -0
  90. package/dist/lanes/app-contract.js +95 -0
  91. package/dist/lanes/app-coverage.js +16 -0
  92. package/dist/lanes/app.js +174 -0
  93. package/dist/lanes/apply-changes.js +231 -0
  94. package/dist/lanes/b2-registration-contract.js +292 -0
  95. package/dist/lanes/b2-registration-coverage.js +48 -0
  96. package/dist/lanes/b2-registration.js +1187 -0
  97. package/dist/lanes/businessrule-contract.js +232 -0
  98. package/dist/lanes/businessrule-coverage.js +16 -0
  99. package/dist/lanes/businessrule.js +221 -0
  100. package/dist/lanes/contract-support.js +65 -0
  101. package/dist/lanes/coverage-declaration.js +9 -0
  102. package/dist/lanes/datarule-contract.js +155 -0
  103. package/dist/lanes/datarule-coverage.js +19 -0
  104. package/dist/lanes/datarule-protocol.js +308 -0
  105. package/dist/lanes/datarule.js +818 -0
  106. package/dist/lanes/dictionary-contract.js +78 -0
  107. package/dist/lanes/dictionary-coverage.js +24 -0
  108. package/dist/lanes/dictionary.js +235 -0
  109. package/dist/lanes/environment-contract.js +70 -0
  110. package/dist/lanes/environment-coverage.js +14 -0
  111. package/dist/lanes/environment.js +163 -0
  112. package/dist/lanes/field-contract.js +223 -0
  113. package/dist/lanes/field-coverage.js +27 -0
  114. package/dist/lanes/field.js +374 -0
  115. package/dist/lanes/form-contract.js +97 -0
  116. package/dist/lanes/form-coverage.js +16 -0
  117. package/dist/lanes/form.js +185 -0
  118. package/dist/lanes/lane-ids.js +34 -0
  119. package/dist/lanes/list-view-contract.js +175 -0
  120. package/dist/lanes/list-view-coverage.js +20 -0
  121. package/dist/lanes/list-view-shapes.js +1207 -0
  122. package/dist/lanes/list-view.js +578 -0
  123. package/dist/lanes/meta-contract.js +85 -0
  124. package/dist/lanes/meta.js +255 -0
  125. package/dist/lanes/model-contract.js +168 -0
  126. package/dist/lanes/model-coverage.js +20 -0
  127. package/dist/lanes/model.js +986 -0
  128. package/dist/lanes/online-js-contract.js +99 -0
  129. package/dist/lanes/online-js-coverage.js +28 -0
  130. package/dist/lanes/online-js.js +127 -0
  131. package/dist/lanes/report-contract.js +144 -0
  132. package/dist/lanes/report-coverage.js +21 -0
  133. package/dist/lanes/report.js +476 -0
  134. package/dist/lanes/rule-graph.js +1846 -0
  135. package/dist/lanes/rule-lifecycle-contract.js +92 -0
  136. package/dist/lanes/rule-lifecycle-coverage.js +20 -0
  137. package/dist/lanes/rule-lifecycle.js +176 -0
  138. package/dist/lanes/runtime-data-contract.js +264 -0
  139. package/dist/lanes/runtime-data-coverage.js +25 -0
  140. package/dist/lanes/runtime-data.js +1054 -0
  141. package/dist/lanes/workflow-contract.js +223 -0
  142. package/dist/lanes/workflow-coverage.js +40 -0
  143. package/dist/lanes/workflow.js +1813 -0
  144. package/dist/online-js-layout.js +58 -0
  145. package/dist/online-js-source.js +276 -0
  146. package/dist/package-tool.js +51 -0
  147. package/dist/package.js +73 -0
  148. package/dist/plan.js +73 -0
  149. package/dist/read.js +144 -0
  150. package/dist/redact.js +28 -0
  151. package/dist/rule-support.js +587 -0
  152. package/dist/runtime-support.js +134 -0
  153. package/dist/server.js +92 -0
  154. package/dist/session-manager.js +30 -0
  155. package/dist/session.js +149 -0
  156. package/dist/skills.js +112 -0
  157. package/dist/support.js +98 -0
  158. package/dist/tool-types.js +127 -0
  159. package/dist/tools.js +59 -0
  160. package/dist/usage-log.js +197 -0
  161. package/dist/wire.js +287 -0
  162. package/dist/workflow-support.js +99 -0
  163. package/dist/write-lease.js +26 -0
  164. package/dist/write-lock.js +109 -0
  165. package/dist/write.js +176 -0
  166. package/dist/zip.js +156 -0
  167. package/docs/tool-surface-map.md +42 -0
  168. package/package.json +71 -6
  169. package/skills/omc-acceptance-criteria.md +47 -0
  170. package/skills/omc-business-configuration.md +257 -0
  171. package/skills/omc-capabilities.md +197 -0
  172. package/skills/omc-capability-scouting.md +55 -0
  173. package/skills/omc-config-draft-review.md +171 -0
  174. package/skills/omc-five-piece-flow.md +35 -0
  175. package/skills/omc-glossary.md +86 -0
  176. package/skills/omc-refusals.md +110 -0
  177. package/skills/omc-requirement-analysis.md +161 -0
  178. package/skills/omc-requirement-vocabulary.md +51 -0
  179. package/skills/omc-start-here.md +82 -0
  180. package/skills/omc-tool-selection.md +119 -0
  181. package/skills/omc-write-hazards.md +87 -0
@@ -0,0 +1,70 @@
1
+ import { randomUUID } from "node:crypto";
2
+ export const CLI_EXIT_CODES = {
3
+ ok: 0,
4
+ invalidInput: 10,
5
+ authConfig: 11,
6
+ policyRefused: 12,
7
+ uncertain: 14,
8
+ internal: 15,
9
+ };
10
+ export function envelope(status, result, requestId, error = null) {
11
+ return { ok: error === null, status, result, requestId, error };
12
+ }
13
+ /**
14
+ * The single stdout serialization for every envelope.
15
+ *
16
+ * On zh-CN Windows, PowerShell decodes a native process's bytes with the legacy
17
+ * console code page and mangles UTF-8 Chinese ("付文�?"), which forces callers
18
+ * into a "write to file, then re-read" workaround. When `OMC_ASCII_STDOUT`
19
+ * resolves on, non-ASCII is escaped to `\uXXXX`: stdout stays pure ASCII and
20
+ * decodes identically under any code page while still parsing to the original
21
+ * string. It is on by default only on win32, so Linux output keeps its smaller
22
+ * UTF-8 bytes. Override with `OMC_ASCII_STDOUT=1|0`. Artifacts keep raw UTF-8 —
23
+ * they are files, not a console stream. See `CONTEXT.md` → Agent-facing CLI.
24
+ */
25
+ export function asciiStdout() {
26
+ const override = process.env.OMC_ASCII_STDOUT;
27
+ if (override === "1")
28
+ return true;
29
+ if (override === "0")
30
+ return false;
31
+ return process.platform === "win32";
32
+ }
33
+ export function serializeEnvelope(value) {
34
+ const json = JSON.stringify(value);
35
+ const escaped = asciiStdout() ? json.replace(/[\u007f-\uffff]/g, (character) => `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`) : json;
36
+ return escaped + "\n";
37
+ }
38
+ export function requestId() {
39
+ return randomUUID();
40
+ }
41
+ export function classifyResult(result) {
42
+ const status = String(result.status ?? "ok");
43
+ if (status === "ok")
44
+ return { status, error: null, exitCode: CLI_EXIT_CODES.ok };
45
+ if (status === "dry-run")
46
+ return { status, error: null, exitCode: CLI_EXIT_CODES.ok };
47
+ if (status === "unknown-tool") {
48
+ const candidates = Array.isArray(result.candidates) ? result.candidates : [];
49
+ const suffix = candidates.length > 0 ? `;did you mean: ${candidates.join("、")}` : ";用 `omc commands --json --compact --lane <lane>` 或 `omc next` 定位工具";
50
+ return { status: "error", error: { code: "invalid-input", message: `unknown tool ${String(result.tool ?? "")}${suffix}`, retryable: false }, exitCode: CLI_EXIT_CODES.invalidInput };
51
+ }
52
+ if (result.blocker === "tool-input-invalid")
53
+ return { status: "error", error: { code: "invalid-input", message: String(result.message ?? "tool input is invalid"), retryable: false }, exitCode: CLI_EXIT_CODES.invalidInput };
54
+ if (status === "uncertain")
55
+ return { status, error: { code: "uncertain", message: String(result.message ?? result.reason ?? "outcome is uncertain"), retryable: true }, exitCode: CLI_EXIT_CODES.uncertain };
56
+ if (status === "refused") {
57
+ if (result.blocker === "write-lock-held")
58
+ return { status, error: { code: "policy-refused", message: String(result.message ?? "write lock held"), retryable: true }, exitCode: CLI_EXIT_CODES.policyRefused };
59
+ const auth = String(result.blocker ?? "").startsWith("auth") || String(result.blocker ?? "").includes("credential");
60
+ return { status, error: { code: auth ? "auth-config" : "policy-refused", message: String(result.message ?? result.blocker ?? "operation refused"), retryable: false }, exitCode: auth ? CLI_EXIT_CODES.authConfig : CLI_EXIT_CODES.policyRefused };
61
+ }
62
+ const message = String(result.message ?? "internal error");
63
+ const auth = /credential|configuration|environment|login|authentication|auth/i.test(message);
64
+ return { status: "error", error: { code: auth ? "auth-config" : "internal", message, retryable: false }, exitCode: auth ? CLI_EXIT_CODES.authConfig : CLI_EXIT_CODES.internal };
65
+ }
66
+ export function errorEnvelope(error, code, exitCode, request) {
67
+ const message = error instanceof Error ? error.message : String(error);
68
+ return { envelope: envelope("error", {}, request, { code, message, retryable: false }), exitCode };
69
+ }
70
+ //# sourceMappingURL=cli-contract.js.map
@@ -0,0 +1,73 @@
1
+ import { writeFileSync } from "node:fs";
2
+ import { serializeEnvelope } from "./cli-contract.js";
3
+ import { recordUsageOutput } from "./usage-log.js";
4
+ let options = { quiet: false };
5
+ /** Parse `--quiet` and `--out <file>` from the raw argv once, before dispatch. */
6
+ export function configureOutput(argv) {
7
+ const outIndex = argv.indexOf("--out");
8
+ let outFile;
9
+ if (outIndex >= 0) {
10
+ const value = argv[outIndex + 1];
11
+ // Refuse a missing or flag-looking value rather than writing to a file named
12
+ // `--quiet` and silently dropping the flag. A bad `--out` is invalid input.
13
+ if (value === undefined || value.startsWith("--"))
14
+ throw new Error("--out requires a file path");
15
+ outFile = value;
16
+ }
17
+ options = { quiet: argv.includes("--quiet"), ...(outFile ? { outFile } : {}) };
18
+ return options;
19
+ }
20
+ /**
21
+ * Remove the global output flags from argv before commander parses it, so they
22
+ * are consumed once here instead of being declared on every subcommand.
23
+ */
24
+ export function stripOutputFlags(argv) {
25
+ const out = [];
26
+ for (let index = 0; index < argv.length; index += 1) {
27
+ const token = argv[index];
28
+ if (token === "--quiet")
29
+ continue;
30
+ if (token === "--out") {
31
+ index += 1;
32
+ continue;
33
+ }
34
+ out.push(token);
35
+ }
36
+ return out;
37
+ }
38
+ export function outputOptions() {
39
+ return options;
40
+ }
41
+ /**
42
+ * Write the single stdout envelope. When `--out` is set, the identical bytes are
43
+ * written to that file (UTF-8) FIRST, so a bad path fails before any envelope
44
+ * reaches stdout — keeping the "exactly one envelope" contract even on failure.
45
+ * stdout and the file can never diverge.
46
+ */
47
+ export function writeEnvelope(value) {
48
+ const text = serializeEnvelope(value);
49
+ if (!options.outFile) {
50
+ recordUsageOutput(value, Buffer.byteLength(text, "utf8"));
51
+ process.stdout.write(text);
52
+ return;
53
+ }
54
+ const pretty = `${JSON.stringify(value, null, 2)}\n`;
55
+ writeFileSync(options.outFile, pretty, "utf8");
56
+ const envelopeValue = value && typeof value === "object" ? value : {};
57
+ const confirmation = {
58
+ ok: envelopeValue.ok ?? true,
59
+ status: envelopeValue.status ?? "ok",
60
+ result: { out: options.outFile, bytes: Buffer.byteLength(pretty, "utf8") },
61
+ requestId: envelopeValue.requestId ?? null,
62
+ error: envelopeValue.error ?? null,
63
+ };
64
+ const confirmationText = serializeEnvelope(confirmation);
65
+ recordUsageOutput(value, Buffer.byteLength(confirmationText, "utf8"), Buffer.byteLength(pretty, "utf8"));
66
+ process.stdout.write(confirmationText);
67
+ }
68
+ /** Emit a human diagnostic on stderr, unless `--quiet` asked for none. */
69
+ export function humanSummary(line) {
70
+ if (!options.quiet)
71
+ process.stderr.write(`${line}\n`);
72
+ }
73
+ //# sourceMappingURL=cli-output.js.map