@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.
- package/LICENSE +21 -0
- package/README.md +293 -3
- package/coverage/m1-coverage-manifest-v1.json +1278 -0
- package/dist/approval-token.js +102 -0
- package/dist/args.js +25 -0
- package/dist/artifacts.js +119 -0
- package/dist/bench/call-face-eval.js +256 -0
- package/dist/bench/context-attribution.js +151 -0
- package/dist/bench/discovery-cost-eval.js +230 -0
- package/dist/bench/driver.js +81 -0
- package/dist/bench/evals.js +236 -0
- package/dist/bench/fake-http-server.js +65 -0
- package/dist/bench/instrument.js +87 -0
- package/dist/bench/intent-face-eval.js +343 -0
- package/dist/bench/run.js +166 -0
- package/dist/bench/scenario.js +343 -0
- package/dist/bench/types.js +76 -0
- package/dist/bi-wire.js +41 -0
- package/dist/bizservice-config.js +581 -0
- package/dist/call.js +153 -0
- package/dist/capability-absences.js +23 -0
- package/dist/capability-overview.js +492 -0
- package/dist/capability-shape.js +154 -0
- package/dist/cli-contract.js +70 -0
- package/dist/cli-output.js +73 -0
- package/dist/cli.js +1418 -0
- package/dist/code-rules.js +69 -0
- package/dist/command-transport.js +155 -0
- package/dist/config-store.js +195 -0
- package/dist/context.js +21 -0
- package/dist/contract-consistency.js +66 -0
- package/dist/contract-resources.js +62 -0
- package/dist/coverage-consistency.js +62 -0
- package/dist/coverage-registry.js +76 -0
- package/dist/coverage.js +130 -0
- package/dist/data-list-filter.js +114 -0
- package/dist/discovery.js +390 -0
- package/dist/endpoints.js +154 -0
- package/dist/environment-policy.js +26 -0
- package/dist/execution-metadata.js +1092 -0
- package/dist/fake/app.js +45 -0
- package/dist/fake/b2-registration.js +594 -0
- package/dist/fake/businessrule.js +242 -0
- package/dist/fake/datarule.js +72 -0
- package/dist/fake/dictionary.js +108 -0
- package/dist/fake/environment.js +30 -0
- package/dist/fake/field.js +167 -0
- package/dist/fake/form.js +101 -0
- package/dist/fake/index.js +121 -0
- package/dist/fake/list-view.js +289 -0
- package/dist/fake/model.js +136 -0
- package/dist/fake/online-js.js +18 -0
- package/dist/fake/report.js +253 -0
- package/dist/fake/routes.js +47 -0
- package/dist/fake/rule-lifecycle.js +37 -0
- package/dist/fake/runtime-data.js +367 -0
- package/dist/fake/state.js +67 -0
- package/dist/fake/workflow.js +364 -0
- package/dist/field-change.js +200 -0
- package/dist/field-families.js +896 -0
- package/dist/form-layout.js +111 -0
- package/dist/form-support.js +821 -0
- package/dist/goal-routes.js +468 -0
- package/dist/governed-execution.js +87 -0
- package/dist/human-summary.js +212 -0
- package/dist/identity.js +62 -0
- package/dist/intent/baseline.js +57 -0
- package/dist/intent/capabilities/bizservice.js +274 -0
- package/dist/intent/capabilities/businessrule.js +493 -0
- package/dist/intent/capabilities/datarule.js +187 -0
- package/dist/intent/capabilities/field.js +545 -0
- package/dist/intent/capabilities/form.js +136 -0
- package/dist/intent/capabilities/index.js +64 -0
- package/dist/intent/capabilities/listview.js +157 -0
- package/dist/intent/capabilities/model.js +100 -0
- package/dist/intent/capabilities/onlinejs.js +108 -0
- package/dist/intent/capabilities/report.js +355 -0
- package/dist/intent/capabilities/workflow.js +458 -0
- package/dist/intent/capability.js +6 -0
- package/dist/intent/cli.js +91 -0
- package/dist/intent/compare.js +56 -0
- package/dist/intent/compiler.js +79 -0
- package/dist/intent/dsl.js +129 -0
- package/dist/intent/plan-file.js +63 -0
- package/dist/intent/readback.js +65 -0
- package/dist/intent/schema.js +158 -0
- package/dist/intent/validation.js +30 -0
- package/dist/intent/yaml.js +315 -0
- package/dist/json-column.js +68 -0
- package/dist/lanes/app-contract.js +95 -0
- package/dist/lanes/app-coverage.js +16 -0
- package/dist/lanes/app.js +174 -0
- package/dist/lanes/apply-changes.js +231 -0
- package/dist/lanes/b2-registration-contract.js +292 -0
- package/dist/lanes/b2-registration-coverage.js +48 -0
- package/dist/lanes/b2-registration.js +1187 -0
- package/dist/lanes/businessrule-contract.js +232 -0
- package/dist/lanes/businessrule-coverage.js +16 -0
- package/dist/lanes/businessrule.js +221 -0
- package/dist/lanes/contract-support.js +65 -0
- package/dist/lanes/coverage-declaration.js +9 -0
- package/dist/lanes/datarule-contract.js +155 -0
- package/dist/lanes/datarule-coverage.js +19 -0
- package/dist/lanes/datarule-protocol.js +308 -0
- package/dist/lanes/datarule.js +818 -0
- package/dist/lanes/dictionary-contract.js +78 -0
- package/dist/lanes/dictionary-coverage.js +24 -0
- package/dist/lanes/dictionary.js +235 -0
- package/dist/lanes/environment-contract.js +70 -0
- package/dist/lanes/environment-coverage.js +14 -0
- package/dist/lanes/environment.js +163 -0
- package/dist/lanes/field-contract.js +223 -0
- package/dist/lanes/field-coverage.js +27 -0
- package/dist/lanes/field.js +374 -0
- package/dist/lanes/form-contract.js +97 -0
- package/dist/lanes/form-coverage.js +16 -0
- package/dist/lanes/form.js +185 -0
- package/dist/lanes/lane-ids.js +34 -0
- package/dist/lanes/list-view-contract.js +175 -0
- package/dist/lanes/list-view-coverage.js +20 -0
- package/dist/lanes/list-view-shapes.js +1207 -0
- package/dist/lanes/list-view.js +578 -0
- package/dist/lanes/meta-contract.js +85 -0
- package/dist/lanes/meta.js +255 -0
- package/dist/lanes/model-contract.js +168 -0
- package/dist/lanes/model-coverage.js +20 -0
- package/dist/lanes/model.js +986 -0
- package/dist/lanes/online-js-contract.js +99 -0
- package/dist/lanes/online-js-coverage.js +28 -0
- package/dist/lanes/online-js.js +127 -0
- package/dist/lanes/report-contract.js +144 -0
- package/dist/lanes/report-coverage.js +21 -0
- package/dist/lanes/report.js +476 -0
- package/dist/lanes/rule-graph.js +1846 -0
- package/dist/lanes/rule-lifecycle-contract.js +92 -0
- package/dist/lanes/rule-lifecycle-coverage.js +20 -0
- package/dist/lanes/rule-lifecycle.js +176 -0
- package/dist/lanes/runtime-data-contract.js +264 -0
- package/dist/lanes/runtime-data-coverage.js +25 -0
- package/dist/lanes/runtime-data.js +1054 -0
- package/dist/lanes/workflow-contract.js +223 -0
- package/dist/lanes/workflow-coverage.js +40 -0
- package/dist/lanes/workflow.js +1813 -0
- package/dist/online-js-layout.js +58 -0
- package/dist/online-js-source.js +276 -0
- package/dist/package-tool.js +51 -0
- package/dist/package.js +73 -0
- package/dist/plan.js +73 -0
- package/dist/read.js +144 -0
- package/dist/redact.js +28 -0
- package/dist/rule-support.js +587 -0
- package/dist/runtime-support.js +134 -0
- package/dist/server.js +92 -0
- package/dist/session-manager.js +30 -0
- package/dist/session.js +149 -0
- package/dist/skills.js +112 -0
- package/dist/support.js +98 -0
- package/dist/tool-types.js +127 -0
- package/dist/tools.js +59 -0
- package/dist/usage-log.js +197 -0
- package/dist/wire.js +287 -0
- package/dist/workflow-support.js +99 -0
- package/dist/write-lease.js +26 -0
- package/dist/write-lock.js +109 -0
- package/dist/write.js +176 -0
- package/dist/zip.js +156 -0
- package/docs/tool-surface-map.md +42 -0
- package/package.json +71 -6
- package/skills/omc-acceptance-criteria.md +47 -0
- package/skills/omc-business-configuration.md +257 -0
- package/skills/omc-capabilities.md +197 -0
- package/skills/omc-capability-scouting.md +55 -0
- package/skills/omc-config-draft-review.md +171 -0
- package/skills/omc-five-piece-flow.md +35 -0
- package/skills/omc-glossary.md +86 -0
- package/skills/omc-refusals.md +110 -0
- package/skills/omc-requirement-analysis.md +161 -0
- package/skills/omc-requirement-vocabulary.md +51 -0
- package/skills/omc-start-here.md +82 -0
- package/skills/omc-tool-selection.md +119 -0
- 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
|