@ouro.bot/cli 0.1.0-alpha.1421 → 0.1.0-alpha.1422

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": "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.1422",
6
+ "changes": [
7
+ "`find_tools` now searches the agent's skills as well as its held-back tools. When a skill documents the job (for example a bundle command run through `shell`), the reply includes that skill's section, where its commands run from and how to open the whole skill, instead of only the closest tools or \"no matching tools\". A section matches only on its own words, with at least one in its heading or its skill's description. One section per skill and at most two skills, with about 900 characters of section text in all (plus each skill's header and command line). Only turns that offer `load_skill` or `read_file` get skill text, so a friend's or guest's turn gets none. On Anthropic the section is sent as text after the tool results instead of being dropped."
8
+ ]
9
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.1421",
6
12
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1421",
2
+ "runtimeVersion": "0.1.0-alpha.1422",
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.1421</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1422</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -30,6 +30,7 @@ const source_grounding_1 = require("./source-grounding");
30
30
  const shelf_claims_1 = require("./shelf-claims");
31
31
  const reply_style_1 = require("./reply-style");
32
32
  const tool_catalog_1 = require("../repertoire/tool-catalog");
33
+ const skill_search_1 = require("../repertoire/skill-search");
33
34
  const skill_summaries_1 = require("../repertoire/skill-summaries");
34
35
  const tools_1 = require("../repertoire/tools");
35
36
  const tools_base_1 = require("../repertoire/tools-base");
@@ -2673,13 +2674,16 @@ async function runAgent(messages, callbacks, channel, signal, options) {
2673
2674
  for (const name of matchedNames)
2674
2675
  if (!loadedDeferredTools.includes(name))
2675
2676
  loadedDeferredTools.push(name);
2676
- const found = (0, tool_catalog_1.formatLoadedDoors)(matched);
2677
+ // A job a bundle does with a command its skill documents has no door to find; the skill's section answers.
2678
+ const skills = (0, skill_search_1.findToolsSkillNote)(query, activeToolNames);
2679
+ const found = (0, tool_catalog_1.formatFindToolsReply)(matched, skills.note);
2677
2680
  pushGenerated({ role: "tool", tool_call_id: tc.id, content: found });
2678
2681
  providerRuntime.appendToolOutput(tc.id, found);
2679
- if (matched.length > 0)
2682
+ if (matched.length > 0 || skills.hits > 0)
2680
2683
  lastIterationMadeProgress = true;
2684
+ // onToolEnd's success means a door was loaded; a skill-only reply loaded none, but is still progress.
2681
2685
  callbacks.onToolEnd(tool_catalog_1.FIND_TOOLS_NAME, query, matched.length > 0);
2682
- (0, tool_catalog_1.recordFindTools)({ query, matched: matched.length, deferred: deferralPool.length });
2686
+ (0, tool_catalog_1.recordFindTools)({ query, matched: matched.length, deferred: deferralPool.length, skills: skills.hits });
2683
2687
  continue;
2684
2688
  }
2685
2689
  if (tc.name === "speak") {
@@ -136,7 +136,19 @@ function toAnthropicMessages(messages, options = {}) {
136
136
  const systemParts = [];
137
137
  const converted = [];
138
138
  const findToolsCallIds = new Set();
139
+ // Skill notes from find_tools results whose doors went as references. Text may follow tool_result blocks but not
140
+ // sit between them, so the notes wait until the run of tool results ends and then follow the last one.
141
+ let pendingNotes = [];
142
+ const flushNotes = () => {
143
+ if (pendingNotes.length === 0)
144
+ return;
145
+ converted[converted.length - 1].content.push({ type: "text", text: pendingNotes.join("\n\n") });
146
+ pendingNotes = [];
147
+ };
139
148
  for (const msg of messages) {
149
+ // System messages go to the system prompt, not between messages, so they don't end a run of tool results.
150
+ if (msg.role !== "tool" && msg.role !== "system")
151
+ flushNotes();
140
152
  if (msg.role === "system") {
141
153
  const text = toAnthropicTextContent(msg.content).trim();
142
154
  if (text)
@@ -207,8 +219,12 @@ function toAnthropicMessages(messages, options = {}) {
207
219
  },
208
220
  ],
209
221
  });
222
+ // A skill note after the doors is text the model needs; the references would otherwise replace it.
223
+ if (references.length > 0 && (0, tool_catalog_1.findToolsNote)(text))
224
+ pendingNotes.push((0, tool_catalog_1.findToolsNote)(text));
210
225
  }
211
226
  }
227
+ flushNotes();
212
228
  return { system: systemParts.length > 0 ? systemParts.join("\n\n") : undefined, messages: converted };
213
229
  }
214
230
  // The Anthropic API rejects the whole request when any tool's input_schema has
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.skillSections = skillSections;
37
+ exports.searchSkills = searchSkills;
38
+ exports.findToolsSkillNote = findToolsSkillNote;
39
+ exports.formatSkillHits = formatSkillHits;
40
+ const fs = __importStar(require("fs"));
41
+ const runtime_1 = require("../nerves/runtime");
42
+ const skills_1 = require("./skills");
43
+ const skill_summaries_1 = require("./skill-summaries");
44
+ const tool_catalog_1 = require("./tool-catalog");
45
+ const MAX_SKILLS = 2;
46
+ /** The skill text one reply may carry, shared across its hits, so two hits cost no more than one. */
47
+ const MAX_NOTE_CHARS = 900;
48
+ const MAX_RUNS_CHARS = 200;
49
+ /** Stems that name the same job, so "delete the book" finds a section that says "removing". */
50
+ const SAME_AS = { delet: "remov", eras: "remov", ebook: "book" };
51
+ /**
52
+ * The catalog's words with a final "e" dropped too, so "remove", "removed" and "removing" are one word, as are
53
+ * "replace" and "replacing"; then the synonyms.
54
+ */
55
+ const searchWords = (text) => (0, tool_catalog_1.words)(text)
56
+ .map((word) => (word.length > 4 && word.endsWith("e") ? word.slice(0, -1) : word))
57
+ .map((word) => SAME_AS[word] ?? word);
58
+ function firstCommandBlock(text) {
59
+ const block = /```[^\n]*\n([\s\S]*?)```/.exec(text)?.[1]?.trim();
60
+ return block ? block : undefined;
61
+ }
62
+ function withoutFrontmatter(markdown) {
63
+ const lines = markdown.split(/\r?\n/);
64
+ if (lines[0]?.trim() !== "---")
65
+ return lines.join("\n");
66
+ const end = lines.findIndex((line, index) => index > 0 && line.trim() === "---");
67
+ return end > 0 ? lines.slice(end + 1).join("\n") : lines.join("\n");
68
+ }
69
+ /** A skill's sections: the intro under its title, then one per `##` heading, each with its own lines only. */
70
+ function skillSections(skill, file, markdown) {
71
+ const sections = [];
72
+ let current = { heading: skill, lines: [] };
73
+ sections.push(current);
74
+ for (const line of withoutFrontmatter(markdown).split(/\r?\n/)) {
75
+ const title = /^#\s+(.+)$/.exec(line);
76
+ const heading = /^##\s+(.+)$/.exec(line);
77
+ if (title && sections.length === 1 && current.lines.every((entry) => entry.trim() === "")) {
78
+ current.heading = title[1].trim();
79
+ }
80
+ else if (heading) {
81
+ current = { heading: heading[1].trim(), lines: [] };
82
+ sections.push(current);
83
+ }
84
+ else {
85
+ current.lines.push(line);
86
+ }
87
+ }
88
+ const runs = firstCommandBlock(sections[0].lines.join("\n"));
89
+ return sections
90
+ .map((section) => ({ skill, path: file, heading: section.heading, text: section.lines.join("\n").trim(), ...(runs ? { runs } : {}) }))
91
+ .filter((section, index) => index === 0 || section.text.length > 0);
92
+ }
93
+ function scoreSection(terms, section, about) {
94
+ const heading = new Set(searchWords(section.heading));
95
+ const body = new Set(searchWords(section.text));
96
+ let own = 0;
97
+ let anchored = false;
98
+ let score = 0;
99
+ for (const term of terms) {
100
+ const inSection = (heading.has(term) ? 3 : 0) + (body.has(term) ? 1 : 0);
101
+ if (inSection > 0)
102
+ own += 1;
103
+ if (heading.has(term) || about.has(term))
104
+ anchored = true;
105
+ score += inSection + (about.has(term) ? 2 : 0);
106
+ }
107
+ // Only the section's own words count toward a match, so a skill's name or description alone can't make one. And
108
+ // the match needs an anchor in the section's heading or the skill's description: common words that a body happens
109
+ // to use ("check", "server") are not what the section is about.
110
+ return { section, covered: anchored ? own : 0, score };
111
+ }
112
+ /** The skill sections that cover a query, best first. `select:` queries name doors, so they find no skill. */
113
+ function searchSkills(query) {
114
+ const trimmed = query.trim();
115
+ const terms = trimmed.toLowerCase().startsWith("select:") ? [] : [...new Set(searchWords(trimmed))];
116
+ const names = terms.length > 0 ? (0, skills_1.listSkills)() ?? [] : [];
117
+ const needed = terms.length >= 2 ? 2 : 1;
118
+ let sectionCount = 0;
119
+ const best = [];
120
+ for (const name of names) {
121
+ const file = (0, skill_summaries_1.skillPath)(name);
122
+ if (!file)
123
+ continue;
124
+ let markdown;
125
+ try {
126
+ markdown = fs.readFileSync(file, "utf-8");
127
+ }
128
+ catch {
129
+ continue; // an unreadable skill can't answer a search
130
+ }
131
+ const sections = skillSections(name, file, markdown);
132
+ sectionCount += sections.length;
133
+ const about = new Set(searchWords(`${name} ${sections[0].heading} ${(0, skill_summaries_1.whenLine)(markdown) ?? ""}`));
134
+ const scored = sections.map((section) => scoreSection(terms, section, about)).filter((entry) => entry.covered >= needed);
135
+ // Within a skill, the section that answers most of the query, then the heading's weight: "remove" in a heading
136
+ // beats it in a passing rule.
137
+ const top = scored.sort((a, b) => b.covered - a.covered || b.score - a.score)[0];
138
+ // Across skills, the skill that answers more of the query wins.
139
+ if (top)
140
+ best.push(top);
141
+ }
142
+ best.sort((a, b) => b.covered - a.covered || b.score - a.score);
143
+ // A second skill comes back only when it answers as much of the query and nearly as strongly (80%).
144
+ const hits = best.filter((entry) => entry.covered === best[0].covered && entry.score * 5 >= best[0].score * 4)
145
+ .slice(0, MAX_SKILLS).map((entry) => entry.section);
146
+ (0, runtime_1.emitNervesEvent)({
147
+ component: "repertoire", event: "repertoire.skill_search", message: "find_tools searched the skills",
148
+ meta: { skills: names.length, sections: sectionCount, hits: hits.length },
149
+ });
150
+ return hits;
151
+ }
152
+ /**
153
+ * The skill note for a `find_tools` reply on a turn that offers `tools`. Skill text goes only to a turn that could
154
+ * read the skill anyway (through `load_skill` or `read_file`), so a friend's or guest's turn gets none.
155
+ */
156
+ function findToolsSkillNote(query, tools) {
157
+ if (!tools.has("load_skill") && !tools.has("read_file"))
158
+ return { hits: 0, note: "" };
159
+ const hits = searchSkills(query);
160
+ return { hits: hits.length, note: formatSkillHits(hits, { loadSkill: tools.has("load_skill") }) };
161
+ }
162
+ /** A clipped section that cut a code block open gets it closed again. */
163
+ function closeFence(text) {
164
+ return (text.match(/```/g)?.length ?? 0) % 2 === 1 ? `${text}\n\`\`\`` : text;
165
+ }
166
+ function clip(text, max) {
167
+ return text.length > max ? `${text.slice(0, max - 1)}…` : text;
168
+ }
169
+ /** The hits as `find_tools` shows them: the section's own words and how to open the whole skill. */
170
+ function formatSkillHits(hits, offered) {
171
+ const each = Math.floor(MAX_NOTE_CHARS / Math.max(hits.length, 1));
172
+ return hits.map((hit) => {
173
+ const open = offered.loadSkill ? `load_skill ${hit.skill}` : `read_file ${hit.path}`;
174
+ const runs = hit.runs ? `\nits commands run as: ${clip(hit.runs, MAX_RUNS_CHARS)}` : "";
175
+ return `skill ${hit.skill} documents this, in "${hit.heading}" (${open} for the whole skill):\n${closeFence(clip(hit.text, each))}${runs}`;
176
+ }).join("\n\n");
177
+ }
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.whenLine = whenLine;
37
37
  exports.declaredTools = declaredTools;
38
+ exports.skillPath = skillPath;
38
39
  exports.skillWhenLines = skillWhenLines;
39
40
  const fs = __importStar(require("fs"));
40
41
  const path = __importStar(require("path"));
@@ -83,6 +84,7 @@ function clip(text) {
83
84
  const sentence = text.trim().match(/^.*?[.!?](?=\s|$)/)?.[0] ?? text.trim();
84
85
  return sentence.length > MAX_WHEN_LENGTH ? `${sentence.slice(0, MAX_WHEN_LENGTH - 1)}…` : sentence;
85
86
  }
87
+ /** Where a skill's markdown is: the agent's skills, its protocol mirrors, then the harness's own. */
86
88
  function skillPath(name) {
87
89
  const roots = [
88
90
  () => path.join((0, identity_1.getAgentRoot)(), "skills"),
@@ -3,8 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findToolsDefinition = exports.TURN_TOOL_NAMES = exports.FIND_TOOLS_NAME = void 0;
4
4
  exports.catalogDoor = catalogDoor;
5
5
  exports.buildToolCatalog = buildToolCatalog;
6
+ exports.words = words;
6
7
  exports.searchCatalog = searchCatalog;
7
8
  exports.formatLoadedDoors = formatLoadedDoors;
9
+ exports.formatFindToolsReply = formatFindToolsReply;
10
+ exports.findToolsNote = findToolsNote;
8
11
  exports.loadedDoorNames = loadedDoorNames;
9
12
  exports.partitionCatalog = partitionCatalog;
10
13
  exports.buildFindToolsSchema = buildFindToolsSchema;
@@ -111,11 +114,30 @@ function formatLoadedDoors(loaded) {
111
114
  return (0, tool_error_code_1.withCode)("no matching tools. try different words, or select:name1,name2 using a name from the list in find_tools.", "no-matching-tools");
112
115
  return `${LOADED_HEADER}\n${loaded.map((tool) => `- ${tool.function.name}(${signature(tool)}): ${tool.function.description ?? ""}`).join("\n")}`;
113
116
  }
117
+ const SKILL_NOTE_HEADER = "skills that document this job:";
118
+ /**
119
+ * `find_tools`'s whole reply: the doors it loaded, then any skill sections that document the job under their own
120
+ * header. The loaded-doors header stays first, so `loadedDoorNames` reads the reply back unchanged.
121
+ */
122
+ function formatFindToolsReply(loaded, skillNote) {
123
+ if (!skillNote)
124
+ return formatLoadedDoors(loaded);
125
+ const note = `${SKILL_NOTE_HEADER}\n${skillNote}`;
126
+ return loaded.length === 0 ? `no held-back tool matched (try other words, or select:name1,name2 with a name from the find_tools list).\n\n${note}` : `${formatLoadedDoors(loaded)}\n\n${note}`;
127
+ }
128
+ /** The skill note a `find_tools` reply carries after its loaded doors, header included, or "" when it has none. */
129
+ function findToolsNote(reply) {
130
+ if (!reply.startsWith(LOADED_HEADER))
131
+ return "";
132
+ const at = reply.indexOf(`\n\n${SKILL_NOTE_HEADER}\n`);
133
+ return at >= 0 ? reply.slice(at + 2) : "";
134
+ }
114
135
  /** The door names a `find_tools` reply loaded, read back from its text so the reply itself stays the record. */
115
136
  function loadedDoorNames(reply) {
116
137
  if (!reply.startsWith(LOADED_HEADER))
117
138
  return [];
118
- return reply.split("\n").slice(1).flatMap((line) => /^- ([A-Za-z0-9_-]+)\(/.exec(line)?.[1] ?? []);
139
+ // The skill note is quoted skill text; a list line in it is never a loaded door.
140
+ return reply.split(`\n\n${SKILL_NOTE_HEADER}\n`)[0].split("\n").slice(1).flatMap((line) => /^- ([A-Za-z0-9_-]+)\(/.exec(line)?.[1] ?? []);
119
141
  }
120
142
  /**
121
143
  * Splits a turn's doors. Eager doors, names in `keep` and doors the catalog doesn't know stay in canonical order;
@@ -190,7 +212,7 @@ function scanHistory(messages, withCalls) {
190
212
  function recordFindTools(search) {
191
213
  (0, runtime_1.emitNervesEvent)({
192
214
  component: "repertoire", event: "repertoire.find_tools_searched", message: "find_tools searched the held-back doors",
193
- meta: { select: search.query.trim().toLowerCase().startsWith("select:"), matched: search.matched, deferred: search.deferred },
215
+ meta: { select: search.query.trim().toLowerCase().startsWith("select:"), matched: search.matched, deferred: search.deferred, skills: search.skills ?? 0 },
194
216
  });
195
217
  }
196
218
  /**
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1421",
3
+ "version": "0.1.0-alpha.1422",
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.1421",
9
+ "version": "0.1.0-alpha.1422",
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.1421",
3
+ "version": "0.1.0-alpha.1422",
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": {