every brief the platform writes, where both harnesses will find it
opencode discovers AGENTS.md and nothing else — its only target is
H.up({targets:["AGENTS.md"]}), verified in the binary. claude code discovers
CLAUDE.md. no overlap.
every brief the platform wrote was CLAUDE.md, so under opencode a commander got
none of its standing brief, a bot none of its arming instructions, and a plugin
chat none of its plugin's guidance. nothing failed and nothing was logged: the
agent simply knew nothing, which is indistinguishable from the feature not
existing, and is why it lasted this long. commanders can already run under
opencode, so this was live.
writeAgentBrief puts the content in AGENTS.md and a POINTER in CLAUDE.md. a
pointer rather than two copies because these are rewritten every turn, two
copies of that will eventually disagree, and the stale one is the one somebody
reads.
three writers, and the third needed a flag the others must not have:
bots rewritten every turn ON PURPOSE, so a template change reaches them
plugin chats same
commanders onlyIfAbsent — a commander EXTENDS this file over its life, and
rewriting it when the template changed would delete the job it
had agreed with the owner
two things that would have quietly defeated it. the file listing handed to a
commander said "CLAUDE.md — this file", which would have had it editing the
pointer. and backfill-commander-credentials appended to CLAUDE.md, which on a
new commander means burying a credential section inside six lines nobody reads —
it targets AGENTS.md where one exists, CLAUDE.md where it does not, so old
commanders still work.
plugins ship these too: email and proxy-manager's chat/CLAUDE.md are now
chat/AGENTS.md. the platform accepts BOTH source names, because a plugin is its
own repository on its own release cadence and dropping the old name would
un-brief any installed copy that had not updated — silently, again.
tested: both files written, pointer is not a second copy, idempotent, rewrites
on change, and onlyIfAbsent leaves an extended brief alone. verified on disk
after a restart.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Officer-Session: 656f5c85-e49a-4f1f-b9f3-042a04b4d043
This commit is contained in:
@@ -42,6 +42,7 @@ import { claudeLoginState } from '@@/os-user-claude';
|
||||
import { mkdirSync, existsSync } from 'node:fs';
|
||||
import { snapshotPlugins } from '@@/plugins/mount';
|
||||
import { writeAtomic } from '@@/write-atomic';
|
||||
import { writeAgentBrief } from '@@/agent-brief';
|
||||
import { ensureBotsBrief } from '../bots/brief';
|
||||
import { logger } from './logger';
|
||||
import { isSuperAdmin } from '@@/super-admin';
|
||||
@@ -246,14 +247,18 @@ async function installPluginChatBrief(appName: string, dir: string): Promise<voi
|
||||
const state = states.find((s) => s.plugin.appName === appName && s.install?.enabled);
|
||||
if (!state) return;
|
||||
|
||||
const source = join(state.plugin.dir, 'chat', 'CLAUDE.md');
|
||||
if (!existsSync(source)) return;
|
||||
// `chat/AGENTS.md`, with the old name still accepted: a plugin is its own repository on its own
|
||||
// release cadence, so the platform cannot rename a file inside one and assume every installed copy
|
||||
// followed. Dropping the fallback would silently un-brief a plugin that had not been updated —
|
||||
// silently, because a missing brief is indistinguishable from a plugin that ships none.
|
||||
const source = ['AGENTS.md', 'CLAUDE.md']
|
||||
.map((name) => join(state.plugin.dir, 'chat', name))
|
||||
.find((path) => existsSync(path));
|
||||
if (!source) return;
|
||||
|
||||
const target = join(dir, 'CLAUDE.md');
|
||||
const next = await Bun.file(source).text();
|
||||
// Skip the write when nothing changed, so a directory's mtimes do not churn on every chat start.
|
||||
if (existsSync(target) && (await Bun.file(target).text()) === next) return;
|
||||
await writeAtomic(target, next);
|
||||
// Both names, so opencode finds it too — see `writeAgentBrief`. Content-diffed inside, so a
|
||||
// directory's mtimes do not churn on every chat start.
|
||||
await writeAgentBrief(dir, await Bun.file(source).text());
|
||||
} catch (err) {
|
||||
console.error(`[chat] could not install ${appName}'s chat brief:`, err instanceof Error ? err.message : err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user