Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: starter tool list back under budget; disclosure header names a release range past 4 releases

garrytan006260a4aea4
diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.ts
index f7e00e91ec..0d7858e27c 100644
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@ -448,6 +448,21 @@ export const BEHAVIOR_NOTICE_ID = `${BEHAVIOR_NOTICE_CODE}@${BEHAVIOR_NOTICE_SIN
* all of them), grouped by release; null when none apply. `remote` (HTTP)
* names only that a chain is configured; entries and providers stay on the host.
*/
+/**
+ * The releases a disclosure covers: listed when there are a few, a range past
+ * that, so the header does not crowd the changes out of the rendered 2,000
+ * characters as releases accumulate.
+ */
+export function releaseSpan(versions: string[]): string {
+ if (versions.length > RELEASE_LIST_MAX) {
+ const sorted = [...versions].sort(compareReleases);
+ return `v${sorted[0]} through v${sorted.at(-1)} (${versions.length} releases)`;
+ }
+ const releases = versions.map(v => `v${v}`);
+ return releases.length > 1 ? `${releases.slice(0, -1).join(', ')} and ${releases.at(-1)}` : releases[0]!;
+}
+const RELEASE_LIST_MAX = 4;
+
export function behaviorChangesNotice(chain: ChainDisclosure | null, opts: { remote?: boolean; after?: string } = {}): Notice | null {
const byRelease = new Map<string, string[]>();
let namesChain = false;
@@ -459,10 +474,9 @@ export function behaviorChangesNotice(chain: ChainDisclosure | null, opts: { rem
byRelease.set(change.since, [...(byRelease.get(change.since) ?? []), text]);
}
if (byRelease.size === 0) return null;
- const releases = [...byRelease.keys()].map(v => `v${v}`);
const count = [...byRelease.values()].reduce((n, texts) => n + texts.length, 0);
let n = 0;
- const why = `gbrain ${releases.length > 1 ? `${releases.slice(0, -1).join(', ')} and ${releases.at(-1)}` : releases[0]} changed ${count} behavior${count === 1 ? '' : 's'} on this brain. All stay on; this is a one-time disclosure, not a request for consent. ` +
+ const why = `gbrain ${releaseSpan([...byRelease.keys()])} changed ${count} behavior${count === 1 ? '' : 's'} on this brain. All stay on; this is a one-time disclosure, not a request for consent. ` +
[...byRelease].map(([since, texts]) => (byRelease.size > 1 ? `v${since}: ` : '') + texts.map(t => `(${++n}) ${t}`).join(' ')).join(' ') +
' gbrain doctor --only behavior_changes shows this again.';
const fix: Action = chain && namesChain && !opts.remote
diff --git a/src/core/operation-manifest.generated.ts b/src/core/operation-manifest.generated.ts
index 8aff7c89e8..2f2a1e7671 100644
--- a/src/core/operation-manifest.generated.ts
+++ b/src/core/operation-manifest.generated.ts
@@ -844,7 +844,7 @@ export const OPERATION_MANIFEST: OperationMeta[] = [
"name": "search",
"idempotent": true,
"outputRedaction": "retrieval",
- "description": "Cheap hybrid search, no LLM expansion, top 20: exact tokens, names, field values. NOT proof of coverage; match: \"keyword\" pages every keyword match and takes OR across quoted names or codes (\"A\" OR \"B\" OR …): one call lists every page matching any. Name lists: entity names. Concepts or landscape: `query`; lists: list_pages; personal: get_recent_salience. return_unit: sections or conversations. fields: \"full\" adds diagnostics.",
+ "description": "Cheap hybrid search, no LLM expansion, top 20: exact tokens, names, field values. NOT proof of coverage; match: \"keyword\" pages every keyword match and takes OR across quoted names or codes (\"A\" OR \"B\" OR …): one call lists every match. Name lists: entity names. Concepts or landscape: `query`; lists: list_pages; personal: get_recent_salience. return_unit: sections or conversations. fields: \"full\" adds diagnostics.",
"params": {
"query": {
"type": "string",
diff --git a/src/core/operations-descriptions.ts b/src/core/operations-descriptions.ts
index 26fb790a26..e7bec0527f 100644
--- a/src/core/operations-descriptions.ts
+++ b/src/core/operations-descriptions.ts
@@ -52,7 +52,7 @@ export const QUERY_DESCRIPTION =
"Hybrid search plus multi-query expansion for concept/landscape questions (expansion recovers synonyms). Still top-K; return_unit: sections or conversations. Lists: list_pages. Exact tokens: `search` is cheaper (no LLM call). Personal: get_recent_salience, find_anomalies; transcripts: `gbrain transcripts recent`. Do NOT assume 'crazy' means impressive (often difficult or emotionally charged). Needs an embedding key (else keyword-only); expansion needs a chat key. Fact rows: use follow_up. fields: \"full\" adds diagnostics.";
export const SEARCH_DESCRIPTION =
- "Cheap hybrid search, no LLM expansion, top 20: exact tokens, names, field values. NOT proof of coverage; match: \"keyword\" pages every keyword match and takes OR across quoted names or codes (\"A\" OR \"B\" OR …): one call lists every page matching any. Name lists: entity names. Concepts or landscape: `query`; lists: list_pages; personal: get_recent_salience. return_unit: sections or conversations. fields: \"full\" adds diagnostics.";
+ "Cheap hybrid search, no LLM expansion, top 20: exact tokens, names, field values. NOT proof of coverage; match: \"keyword\" pages every keyword match and takes OR across quoted names or codes (\"A\" OR \"B\" OR …): one call lists every match. Name lists: entity names. Concepts or landscape: `query`; lists: list_pages; personal: get_recent_salience. return_unit: sections or conversations. fields: \"full\" adds diagnostics.";
/** `search`'s `match` param (Cat 40 Hard F2). */
export const SEARCH_MATCH_DESCRIPTION = 'keyword: every keyword match, paged.';
diff --git a/test/behavior-change-notice.test.ts b/test/behavior-change-notice.test.ts
index 529fe2cdfa..e13f582638 100644
--- a/test/behavior-change-notice.test.ts
+++ b/test/behavior-change-notice.test.ts
@@ -51,8 +51,10 @@ const NEXT_PATCH = NEWEST.replace(/^(\d+\.\d+\.)(\d+)(.*)$/, (_m, a: string, b:
const NEWEST_TEXT = (BEHAVIOR_CHANGES.find(c => c.since === NEWEST && typeof c.text === 'string')!.text as string).slice(0, 48);
function noticeHeader(after: string, withChain = false): string {
const rows = BEHAVIOR_CHANGES.filter(c => compareReleases(c.since, after) > 0 && (withChain || typeof c.text === 'string'));
- const releases = [...new Set(rows.map(c => `v${c.since}`))];
- const list = releases.length > 1 ? `${releases.slice(0, -1).join(', ')} and ${releases.at(-1)}` : releases[0];
+ const releases = [...new Set(rows.map(c => c.since))];
+ const list = releases.length > 4
+ ? `v${[...releases].sort(compareReleases)[0]} through v${[...releases].sort(compareReleases).at(-1)} (${releases.length} releases)`
+ : releases.length > 1 ? `${releases.slice(0, -1).map(v => `v${v}`).join(', ')} and v${releases.at(-1)}` : `v${releases[0]}`;
return `gbrain ${list} changed ${rows.length} behavior${rows.length === 1 ? '' : 's'}`;
}
import { NoticeLedger, __resetProcessNoticeLedgerForTests } from '../src/core/notice-ledger.ts';
diff --git a/test/fixtures/goldens/cli/tools-json.json b/test/fixtures/goldens/cli/tools-json.json
index 8214537d95..38c093284c 100644
--- a/test/fixtures/goldens/cli/tools-json.json
+++ b/test/fixtures/goldens/cli/tools-json.json
@@ -2,8 +2,8 @@
"golden": {
"exitCode": 0,
"stderr": "",
- "stdoutBytes": 230690,
- "stdoutSha256": "3eebc1ab64c848e89077be85f11d14631c9401a8c47ecf34b40dabb1b9ef4cc7",
+ "stdoutBytes": 230678,
+ "stdoutSha256": "db7234af3b149673d60b8a8e1759aa419dd1bbca92a10d07dfeb494d8a298510",
"toolNames": [
"remember",
"entity",
@@ -1097,7 +1097,7 @@
"scope": "write"
},
{
- "description": "Cheap hybrid search, no LLM expansion, top 20: exact tokens, names, field values. NOT proof of coverage; match: \"keyword\" pages every keyword match and takes OR across quoted names or codes (\"A\" OR \"B\" OR …): one call lists every page matching any. Name lists: entity names. Concepts or landscape: `query`; lists: list_pages; personal: get_recent_salience. return_unit: sections or conversations. fields: \"full\" adds diagnostics.",
+ "description": "Cheap hybrid search, no LLM expansion, top 20: exact tokens, names, field values. NOT proof of coverage; match: \"keyword\" pages every keyword match and takes OR across quoted names or codes (\"A\" OR \"B\" OR …): one call lists every match. Name lists: entity names. Concepts or landscape: `query`; lists: list_pages; personal: get_recent_salience. return_unit: sections or conversations. fields: \"full\" adds diagnostics.",
"idempotent": true,
"local_only": false,
"mutating": false,