@ouro.bot/cli 0.1.0-alpha.1156 → 0.1.0-alpha.1157

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/changelog.json CHANGED
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
3
3
  "versions": [
4
+ {
5
+ "version": "0.1.0-alpha.1157",
6
+ "changes": [
7
+ "The ouro CLI refuses an unknown flag and names the nearest real one, at its front door. Commands other people see need --why, which is kept out of their words, and --dry-run says who will see them without doing it. Its help reads the same under -h and --help."
8
+ ]
9
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.1156",
6
12
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1156",
2
+ "runtimeVersion": "0.1.0-alpha.1157",
3
3
  "bundleSchemaVersion": 3,
4
4
  "lastUpdated": "2026-09-03T00:00:00.000Z"
5
5
  }
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0"?>
2
2
  <Container version="2">
3
3
  <Name>ouro-butler</Name>
4
- <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1156</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1157</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PARSER_FLAGS = void 0;
4
+ exports.gateCommandArgs = gateCommandArgs;
5
+ const runtime_1 = require("../../nerves/runtime");
6
+ const cli_parse_1 = require("./cli-parse");
7
+ const cli_manifest_1 = require("./cli-manifest");
8
+ // The flag and argument gate in front of the legacy dispatcher, in the Ouro AX kit's terms: an unknown flag is
9
+ // refused with the nearest real one, a command that reaches other people needs --why, and --dry-run says who
10
+ // will see it without doing it. The commands still do their own work.
11
+ const GLOBAL_FLAGS = ["--json", "--help", "--why", "--why-file", "--agent"];
12
+ const GLOBAL_VALUE_FLAGS = ["--why", "--why-file", "--agent"];
13
+ // Every flag the CLI's parser and dispatcher read: the literals in cli-parse.ts, cli-exec.ts, cli-help.ts and
14
+ // cli-defaults.ts. cli-gate-flags.test.ts fails when a literal is added or removed, so the gate never refuses a flag
15
+ // the CLI reads.
16
+ exports.PARSER_FLAGS = [
17
+ "--account", "--action", "--admission", "--agent", "--alert-file", "--allow-send", "--answers", "--api-key",
18
+ "--api-key-file", "--apply", "--args", "--await", "--backup", "--base-url", "--binding", "--cadence", "--card-url",
19
+ "--category", "--channel", "--clone", "--clone-path", "--component", "--context", "--cooldown-minutes",
20
+ "--credential-item", "--delegated", "--deployment", "--did", "--discover", "--dry-run", "--email", "--endpoint",
21
+ "--event", "--event-type", "--evidence", "--exit-code", "--expires", "--external-id", "--facing", "--file",
22
+ "--fixture", "--follow", "--force", "--foreground", "--format", "--friend", "--friend-id", "--from", "--full",
23
+ "--generate-unlock-secret", "--github-token", "--habit", "--help", "--home", "--host", "--host-stall-observed",
24
+ "--human", "--id", "--identity-file", "--idle-silence-ms", "--ids", "--init", "--initiative", "--input-file", "--into",
25
+ "--item", "--json", "--keep-versions", "--key", "--keys-dir", "--lane", "--last", "--latest", "--legacy",
26
+ "--legacy-root", "--level", "--limit", "--manifest", "--max-duration-ms", "--max-old-space-size", "--message-guid",
27
+ "--migration-path", "--min-mem-available-mb", "--mode", "--model", "--name", "--native", "--no-chat",
28
+ "--no-delegated-source", "--no-repair", "--no-send", "--no-wake", "--note", "--notify-session", "--oauth-token",
29
+ "--observe-only", "--occasion", "--oom-score-adj", "--operation-id", "--output", "--output-file", "--owner-alone",
30
+ "--owner-email", "--owner-name", "--participants", "--path", "--payload", "--persist", "--port", "--prefix", "--print",
31
+ "--priority", "--process", "--profile", "--provider", "--public-field", "--public-url", "--question", "--reason",
32
+ "--replay-output", "--repo-path", "--report", "--report-title", "--request-id", "--require-sense", "--reserve-mb",
33
+ "--role", "--root", "--rotate-missing-mail-keys", "--run-id", "--scope", "--secret-field", "--secret-file", "--server",
34
+ "--session", "--setup-token", "--silent-consent", "--since", "--socket", "--source", "--state", "--store", "--strict",
35
+ "--summary", "--surface", "--switch", "--task", "--template", "--text", "--title", "--to", "--tool", "--trigger",
36
+ "--trust", "--ttl-minutes", "--type", "--uid", "--unattended", "--upstream", "--username", "--value", "--value-file",
37
+ "--verify", "--version", "--web", "--which", "--workbench-mcp", "--yes",
38
+ ];
39
+ function usageLinesFor(name) {
40
+ const words = name.split(" ");
41
+ const last = words[words.length - 1];
42
+ const head = words.slice(0, -1).map((word) => `${word} `).join("");
43
+ return (0, cli_parse_1.usage)()
44
+ .split("\n")
45
+ .filter((line) => {
46
+ if (!line.startsWith(` ouro ${head}`))
47
+ return false;
48
+ const word = line.slice(` ouro ${head}`.length).split(/[\s[<(]/)[0];
49
+ return word.split("|").includes(last);
50
+ });
51
+ }
52
+ function shapeOf(declaration) {
53
+ const flags = new Map();
54
+ let positionals = 0;
55
+ for (const line of usageLinesFor(declaration.name)) {
56
+ for (const match of line.matchAll(/(?<![\w-])(--[a-z][\w-]*)( <[^>]+>)?/g))
57
+ flags.set(match[1], Boolean(match[2]));
58
+ const bare = line.replace(/\[[^\]]*\]/g, " ").replace(/(?<![\w-])--[a-z][\w-]*( <[^>]+>)?/g, " ");
59
+ const after = bare.split(/\s+/).filter((token) => token.startsWith("<") && !token.includes("|"));
60
+ positionals = Math.max(positionals, after.length);
61
+ }
62
+ return { declaration, words: declaration.name.split(" "), flags, positionals };
63
+ }
64
+ const SHAPES = cli_manifest_1.CLI_COMMANDS.map(shapeOf);
65
+ function nearestFlag(flag, known) {
66
+ const ranked = known
67
+ .map((name) => ({ name, distance: editDistance(flag, name) }))
68
+ .filter((candidate) => candidate.distance <= 2)
69
+ .sort((a, b) => a.distance - b.distance);
70
+ return ranked.length > 0 ? ranked[0].name : null;
71
+ }
72
+ function editDistance(a, b) {
73
+ let row = Array.from({ length: b.length + 1 }, (_, index) => index);
74
+ for (let i = 1; i <= a.length; i++) {
75
+ const next = [i];
76
+ for (let j = 1; j <= b.length; j++) {
77
+ next[j] = Math.min(row[j] + 1, next[j - 1] + 1, row[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
78
+ }
79
+ row = next;
80
+ }
81
+ return row[b.length];
82
+ }
83
+ function matchCommand(args) {
84
+ const found = SHAPES.filter((shape) => shape.words.every((word, index) => args[index] === word)).sort((a, b) => b.words.length - a.words.length);
85
+ return found.length > 0 ? found[0] : null;
86
+ }
87
+ function refuse(name, message) {
88
+ (0, runtime_1.emitNervesEvent)({
89
+ level: "warn",
90
+ component: "daemon",
91
+ event: "daemon.cli_flag_gate_refused",
92
+ message: "the flag gate refused a command",
93
+ meta: { command: name },
94
+ });
95
+ return { kind: "refuse", message };
96
+ }
97
+ /** Checks a command line against its declaration; a pass returns the words the legacy dispatcher should read. */
98
+ function gateCommandArgs(args) {
99
+ const shape = matchCommand(args);
100
+ if (!shape)
101
+ return { kind: "pass", args };
102
+ const { declaration, words, flags } = shape;
103
+ const name = declaration.name;
104
+ const others = declaration.effect === "others";
105
+ const known = [...new Set([...exports.PARSER_FLAGS, ...GLOBAL_FLAGS, ...flags.keys()])];
106
+ const rest = args.slice(words.length);
107
+ for (let index = 0; index < rest.length; index++) {
108
+ const token = rest[index];
109
+ if (!token.startsWith("--"))
110
+ continue;
111
+ if (known.includes(token))
112
+ continue;
113
+ const suggestion = nearestFlag(token, known);
114
+ const fix = suggestion
115
+ ? `use ${suggestion}`
116
+ : `drop ${token}; \`ouro ${name} --help\` lists its flags`;
117
+ return refuse(name, `Unknown flag ${token} for "ouro ${name}". Fix: ${fix}.`);
118
+ }
119
+ if (others) {
120
+ const valued = new Set([...GLOBAL_VALUE_FLAGS, ...[...flags].filter(([, takes]) => takes).map(([flag]) => flag)]);
121
+ let extra = 0;
122
+ for (let index = 0; index < rest.length; index++) {
123
+ const token = rest[index];
124
+ if (token.startsWith("-")) {
125
+ if (valued.has(token))
126
+ index++;
127
+ continue;
128
+ }
129
+ extra++;
130
+ }
131
+ if (shape.positionals === 0 && extra > 0) {
132
+ return refuse(name, `"ouro ${name}" takes no words after its command. Fix: run \`ouro ${name} --help\` and drop the extra words.`);
133
+ }
134
+ if (!rest.includes("--why") && !rest.includes("--why-file")) {
135
+ return refuse(name, `ouro ${name} needs --why: other people will see this, so say who asked you and what they said. Fix: add --why "<who asked you, and what they said>" to the command.`);
136
+ }
137
+ if (rest.includes("--dry-run")) {
138
+ const json = rest.includes("--json");
139
+ const text = json
140
+ ? JSON.stringify({ state: "preview", command: name, effect: declaration.effect, dryRun: true, summary: declaration.summary })
141
+ : `Would ${declaration.summary.replace(/\.$/, "").toLowerCase()}. Other people will see this when it runs; nothing was sent or changed. Run it again without --dry-run to do it.`;
142
+ return { kind: "preview", text };
143
+ }
144
+ }
145
+ return { kind: "pass", args: withoutWhy(args) };
146
+ }
147
+ function withoutWhy(args) {
148
+ const out = [];
149
+ for (let index = 0; index < args.length; index++) {
150
+ if (args[index] === "--why" || args[index] === "--why-file") {
151
+ index++;
152
+ continue;
153
+ }
154
+ out.push(args[index]);
155
+ }
156
+ return out;
157
+ }
@@ -6,6 +6,7 @@ const compile_cache_1 = require("./compile-cache");
6
6
  const runtime_1 = require("../../nerves/runtime");
7
7
  const cli_arg_redaction_1 = require("./cli-arg-redaction");
8
8
  const daemon_cli_1 = require("./daemon-cli");
9
+ const cli_gate_1 = require("./cli-gate");
9
10
  const runtime_logging_1 = require("./runtime-logging");
10
11
  const portable_git_1 = require("./portable-git");
11
12
  if (process.argv[2] === "shepherd" && process.argv[3] !== "chat")
@@ -19,15 +20,25 @@ else
19
20
  message: "starting ouro CLI entrypoint",
20
21
  meta: { args: (0, cli_arg_redaction_1.redactCliArgs)(process.argv.slice(2)), compileCache: compile_cache_1.ouroCompileCacheDirectory },
21
22
  });
22
- void (0, daemon_cli_1.runOuroCli)(process.argv.slice(2)).catch((error) => {
23
- const message = error instanceof Error ? error.message : String(error);
24
- process.stderr.write(`${message}\n`);
25
- (0, runtime_1.emitNervesEvent)({
26
- level: "error",
27
- component: "daemon",
28
- event: "daemon.cli_entry_error",
29
- message: "ouro CLI entrypoint failed",
30
- meta: { error: message },
23
+ const gate = (0, cli_gate_1.gateCommandArgs)(process.argv.slice(2));
24
+ if (gate.kind === "refuse") {
25
+ process.stderr.write(`${gate.message}\n`);
26
+ process.exitCode = 1;
27
+ }
28
+ else if (gate.kind === "preview") {
29
+ process.stdout.write(`${gate.text}\n`);
30
+ }
31
+ else {
32
+ void (0, daemon_cli_1.runOuroCli)(gate.args).catch((error) => {
33
+ const message = error instanceof Error ? error.message : String(error);
34
+ process.stderr.write(`${message}\n`);
35
+ (0, runtime_1.emitNervesEvent)({
36
+ level: "error",
37
+ component: "daemon",
38
+ event: "daemon.cli_entry_error",
39
+ message: "ouro CLI entrypoint failed",
40
+ meta: { error: message },
41
+ });
42
+ process.exit(1);
31
43
  });
32
- process.exit(1);
33
- });
44
+ }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1156",
3
+ "version": "0.1.0-alpha.1157",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@ouro.bot/cli",
9
- "version": "0.1.0-alpha.1156",
9
+ "version": "0.1.0-alpha.1157",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.78.0",
12
12
  "@ouro.bot/friends": "0.1.0-alpha.18",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1156",
3
+ "version": "0.1.0-alpha.1157",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },