From 4e3189da8fc89f68de9fb98b6c6a2e4da8c362fe Mon Sep 17 00:00:00 2001 From: ingyukoh Date: Wed, 25 Mar 2026 16:17:26 +0900 Subject: [PATCH 1/2] fix: create CLAUDE.md from template when registering groups via IPC The registerGroup() function in index.ts creates the group folder and logs subdirectory but never copies the global CLAUDE.md template. Agents in newly registered groups start without identity or instructions until the container is manually fixed. Copy groups/global/CLAUDE.md into the new group folder on registration, substituting the assistant name if it differs from the default. Closes #1391 --- src/index.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/index.ts b/src/index.ts index 3f5e710..1465d56 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,6 +5,7 @@ import { OneCLI } from '@onecli-sh/sdk'; import { ASSISTANT_NAME, + GROUPS_DIR, IDLE_TIMEOUT, ONECLI_URL, POLL_INTERVAL, @@ -133,6 +134,25 @@ function registerGroup(jid: string, group: RegisteredGroup): void { // Create group folder fs.mkdirSync(path.join(groupDir, 'logs'), { recursive: true }); + // Copy CLAUDE.md template into the new group folder so agents have + // identity and instructions from the first run. (Fixes #1391) + const groupMdFile = path.join(groupDir, 'CLAUDE.md'); + if (!fs.existsSync(groupMdFile)) { + const templateFile = path.join(GROUPS_DIR, 'global', 'CLAUDE.md'); + if (fs.existsSync(templateFile)) { + let content = fs.readFileSync(templateFile, 'utf-8'); + if (ASSISTANT_NAME !== 'Andy') { + content = content.replace(/^# Andy$/m, `# ${ASSISTANT_NAME}`); + content = content.replace( + /You are Andy/g, + `You are ${ASSISTANT_NAME}`, + ); + } + fs.writeFileSync(groupMdFile, content); + logger.info({ folder: group.folder }, 'Created CLAUDE.md from template'); + } + } + // Ensure a corresponding OneCLI agent exists (best-effort, non-blocking) ensureOneCLIAgent(jid, group); From 80f6fb2b9abd57a844243b4d58a6d0e573dcdf16 Mon Sep 17 00:00:00 2001 From: NanoClaw User Date: Wed, 25 Mar 2026 13:37:01 +0000 Subject: [PATCH 2/2] style: fix prettier formatting in registerGroup template copy Co-Authored-By: Claude Opus 4.6 (1M context) --- src/index.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 1465d56..f78d8e9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -143,10 +143,7 @@ function registerGroup(jid: string, group: RegisteredGroup): void { let content = fs.readFileSync(templateFile, 'utf-8'); if (ASSISTANT_NAME !== 'Andy') { content = content.replace(/^# Andy$/m, `# ${ASSISTANT_NAME}`); - content = content.replace( - /You are Andy/g, - `You are ${ASSISTANT_NAME}`, - ); + content = content.replace(/You are Andy/g, `You are ${ASSISTANT_NAME}`); } fs.writeFileSync(groupMdFile, content); logger.info({ folder: group.folder }, 'Created CLAUDE.md from template');