@ouro.bot/cli 0.1.0-alpha.1449 → 0.1.0-alpha.1450

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,22 @@
1
1
  {
2
2
  "_note": "Each pull request writes its own change note under changes/; the release job on main gives each landed change its version and adds the notes here (scripts/release-version.cjs). On main this file stops at the last version set by hand; the published package has every release. Agents read this file directly via read_file to understand what changed between versions.",
3
3
  "versions": [
4
+ {
5
+ "version": "0.1.0-alpha.1450",
6
+ "changes": [
7
+ "The eval check `trace.never` now fails a run only when a command actually passes the pattern as an argument.",
8
+ "Before, it matched the pattern anywhere in any call's arguments. So a run that never used `--accept-check-failure` failed because it wrote the rule \"never use `--accept-check-failure`\" into a note or file.",
9
+ "Now it looks only at shell calls, and only at what a command passes:",
10
+ "**An ordinary command** fails only on an argument word that is the pattern, or `pattern=value`. This is checked after the call's own variables are written out and backslashes and quotes are removed. Heredoc bodies are left out. A command that only prints or searches text (`echo`, `printf`, `grep`, `rg`) is left out too.",
11
+ "**A command that runs text as code** is read whole, since any of its text may be a command. That means a shell (`sh -c`, `bash <<EOF`, `| sh`), `eval`, `source`, Python, Node, Perl or Ruby, named outside quotes and heredoc bodies. It fails on the pattern as a word anywhere in it.",
12
+ "**A command that substitutes another into its words** (`$(…)`, backticks, `<(…)`) is read whole apart from heredoc bodies.",
13
+ "Commands are split on `;`, `&`, `|` and new lines outside quotes. `export NAME=` counts as an assignment, and `echo`/`printf` still count in any call that uses `xargs`.",
14
+ "So a command that passes the flag still fails, whether bare, quoted, escaped, as `--flag=value`, from a variable, through `sh -c` or `eval`, fed to a shell, or from Python.",
15
+ "Two gaps remain:",
16
+ "A script the agent writes to a file in one call and runs in a later call is not followed.",
17
+ "Python or a shell script that only writes the rule as text still fails the check, and so does an unquoted `$(…)` around written text. That is the safe direction."
18
+ ]
19
+ },
4
20
  {
5
21
  "version": "0.1.0-alpha.1449",
6
22
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1449",
2
+ "runtimeVersion": "0.1.0-alpha.1450",
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.1449</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1450</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -121,6 +121,58 @@ function fileWords(text) {
121
121
  return [...plain.matchAll(FILE_IN_WORD)].map(([found]) => found).concat(/[*?]/.test(plain) && !/[(),=;:]/.test(plain) ? [plain] : []);
122
122
  }).filter((word, i, all) => all.indexOf(word) === i);
123
123
  }
124
+ /** A heredoc's body: text the shell feeds a command, not arguments it passes. The opening line and the end marker stay. */
125
+ const HEREDOC_BODY = /(<<-?\s*(['"]?)(\w+)\2[^\n]*\n)[\s\S]*?(\n\s*\3\b)/g;
126
+ /** A program that runs the text it is given as code (a shell, `eval`, an interpreter): its script or heredoc holds commands. */
127
+ const RUNS_TEXT = /(?:^|[\s;&|(`])(?:[\w.~/-]*\/)?(?:sh|bash|zsh|dash|ksh|eval|source|python[\d.]*|node|perl|ruby)(?=[\s;&|)`'"]|$)/;
128
+ /** A program that only prints or searches text: the words it is given are written about, never passed on. */
129
+ const TEXT_ONLY = /^(?:echo|printf|grep|egrep|fgrep|rg)$/;
130
+ /**
131
+ * The words a shell command passes as arguments, with backslash escapes and quotes removed: `--flag`, `"--flag"` and
132
+ * `\--flag` are each the flag, and a quoted sentence that mentions a flag is one word that is not the flag.
133
+ */
134
+ function argumentWords(command) {
135
+ return [...command.replace(/\\(.)/g, "$1").replace(/[<>]/g, " ").matchAll(SHELL_WORD)].map(([word]) => word.replace(/"([^"]*)"|'([^']*)'/g, "$1$2"));
136
+ }
137
+ /** Command substitution (`$(…)`, backticks, `<(…)`): a command run inside another command's words. */
138
+ const SUBSTITUTION = /\$\(|`|[<>]\(/;
139
+ const QUOTED = /"(?:[^"\\]|\\.)*"|'[^']*'/g;
140
+ const SINGLE_QUOTED = /'[^']*'/g;
141
+ const blank = (span) => " ".repeat(span.length);
142
+ /** A shell command's separate commands, split on `;`, `&`, `|`, `&&`, `||` and new lines outside quotes. */
143
+ function splitCommands(command) {
144
+ const parts = [""];
145
+ for (const [token] of command.matchAll(/"(?:[^"\\]|\\.)*"?|'[^']*'?|&&|\|\||[;&|\n]|[^"';&|\n]+/g)) {
146
+ if (/^(?:&&|\|\||[;&|\n])$/.test(token))
147
+ parts.push("");
148
+ else
149
+ parts[parts.length - 1] += token;
150
+ }
151
+ return parts.map(part => part.replace(/^\s*export\s+/, ""));
152
+ }
153
+ /**
154
+ * Whether a shell command passes `source` (a pattern) as an argument. A command that runs text as code, named outside
155
+ * quotes and heredoc bodies (`sh -c '…'`, `bash <<EOF`, `| sh`, `eval`, `python3 -c`), is read whole, heredoc bodies
156
+ * too, since any of its text may be a command. One that substitutes a command into its words is read whole apart from
157
+ * heredoc bodies. Either fails on the pattern as a word anywhere in what is read. Otherwise each command, with the
158
+ * call's own variables written out and heredoc bodies left out, fails on an argument word that is the pattern or
159
+ * `pattern=value`, unless the program only prints or searches text and nothing pipes it into `xargs`.
160
+ */
161
+ function passesArgument(command, start, source) {
162
+ const bodiless = command.replace(HEREDOC_BODY, "$1$4");
163
+ const asWord = new RegExp(`(?:^|[^\\w-])(?:${source})(?![\\w-])`);
164
+ const unescape = (text) => text.replace(/\\(.)/g, "$1");
165
+ if (RUNS_TEXT.test(bodiless.replace(QUOTED, blank)))
166
+ return asWord.test(unescape(command));
167
+ if (SUBSTITUTION.test(bodiless.replace(SINGLE_QUOTED, blank)))
168
+ return asWord.test(unescape(bodiless));
169
+ const asArgument = new RegExp(`^(?:${source})(?:=.*)?$`);
170
+ const textOnlyCounts = /\bxargs\b/.test(bodiless);
171
+ return expandShell(splitCommands(bodiless), start).some(({ text }) => {
172
+ const words = argumentWords(text).filter(word => !/^[A-Za-z_]\w*=/.test(word) || asArgument.test(word));
173
+ return (textOnlyCounts || !TEXT_ONLY.test(basename(words[0] ?? ""))) && words.some(word => asArgument.test(word));
174
+ });
175
+ }
124
176
  /** The folder a shell call starts in: its own `cwd` argument, against the bundle, where created paths are rooted. */
125
177
  function startFolder(call) {
126
178
  try {
@@ -244,8 +296,8 @@ exports.ASSERTIONS = {
244
296
  return check("trace.readBeforeSend", problems.length === 0, listed(problems));
245
297
  },
246
298
  "trace.never": (_seed, obs, args) => {
247
- const pattern = new RegExp(needString("trace.never", args, "pattern"));
248
- const hits = calls(obs).filter(call => pattern.test(call.args)).map(call => call.name);
299
+ const source = needString("trace.never", args, "pattern");
300
+ const hits = calls(obs).filter(call => call.name === "shell" && passesArgument(commandOf(call), startFolder(call), source)).map(call => call.name);
249
301
  return check("trace.never", hits.length === 0, `matching calls: ${listed(hits)}`);
250
302
  },
251
303
  "library.lacks": (_seed, obs, args) => {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1449",
3
+ "version": "0.1.0-alpha.1450",
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.1449",
9
+ "version": "0.1.0-alpha.1450",
10
10
  "bundleDependencies": [
11
11
  "@ouro.bot/friends"
12
12
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1449",
3
+ "version": "0.1.0-alpha.1450",
4
4
  "description": "Ouroboros, the agent harness: agents with durable memory that live where you talk (terminal, Teams, iMessage, mail, voice) and use real tools. Start with npx ouro.bot@latest.",
5
5
  "homepage": "https://ouroboros.bot/",
6
6
  "engines": {