Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(companions): rebuild missing Claude skill manifests
Chris09b78716da83
diff --git a/apps/desktop/src/main/bot-import/README.md b/apps/desktop/src/main/bot-import/README.mdindex 3bb9f39458..487a7ca3d6 100644--- a/apps/desktop/src/main/bot-import/README.md+++ b/apps/desktop/src/main/bot-import/README.md@@ -132,7 +132,8 @@ omitting it retains normal companion defaults, and a rejected request can be corRepeated runtime hydrations reuse the small per-owner/bot projection and savedcatalog. Typed writes invalidate it synchronously; filesystem observation plusdirectory identity checks cover hand edits, moves and replacement. Watcher- errors fall back to rebuilding, and missing generated catalogs are recreated.+ errors fall back to rebuilding, and missing generated catalogs, discovery+ Skills or Claude plugin manifests are recreated on the next hydration.The cache retains at most 32 runtime/query entries, not a maximum number of stored Skills.In-flight catalog writers are serialized per root independently of cacheeviction, so an evicted snapshot cannot overwrite its newer replacement.diff --git a/apps/desktop/src/main/maker-ipc/__tests__/botSkillRuntimeCache.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/botSkillRuntimeCache.test.tsindex af1bca9551..969caa3950 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/botSkillRuntimeCache.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/botSkillRuntimeCache.test.ts@@ -132,6 +132,8 @@ it.each([false, true])('serializes catalog writers after eviction, including faiit('rejoins the active entry when evicted during a cached artifact check', async () => {const pluginRoot = path.join(root, '.runtime-skills');await fs.mkdir(pluginRoot);+ await fs.mkdir(path.join(pluginRoot, '.claude-plugin'));+ await fs.writeFile(path.join(pluginRoot, '.claude-plugin', 'plugin.json'), '{"name":"fixture"}');const catalog = path.join(pluginRoot, 'catalog.jsonl');const filePath = path.join(pluginRoot, 'SKILL.md');await fs.writeFile(filePath, 'Fixture');diff --git a/apps/desktop/src/main/maker-ipc/__tests__/botSkillRuntimeProjection.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/botSkillRuntimeProjection.test.tsindex 17d127e228..52159a9276 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/botSkillRuntimeProjection.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/botSkillRuntimeProjection.test.ts@@ -49,6 +49,29 @@ async function assertBoundedNativeMounts() {}describe('complete personal Skills with bounded startup projection', () => {+ it.each(['.claude-plugin/plugin.json', '.claude-plugin'])('rebuilds a missing Claude artifact %s on the next hydration', async missing => {+ const source = `---\nname: oversized\ndescription: ${'Long description '.repeat(30)}\n---\nOriginal instructions\n`;+ const original = await writeSkill('oversized', source);+ const mounts = await assertBoundedNativeMounts();+ const manifestPath = path.join(mounts.pluginRoot, '.claude-plugin', 'plugin.json');+ const manifest = await fs.readFile(manifestPath, 'utf8');+ const catalog = await fs.readFile(path.join(mounts.pluginRoot, 'catalog.jsonl'), 'utf8');+ const discovery = await fs.readFile(mounts.skills[0].filePath, 'utf8');+ // Only a generated Claude file/directory disappears; source metadata, the+ // catalog and the Pi/Codex discovery Skill remain unchanged.+ await fs.rm(path.join(mounts.pluginRoot, missing), { recursive: true });+ expect(await fs.readFile(path.join(mounts.pluginRoot, 'catalog.jsonl'), 'utf8')).toBe(catalog);+ expect(await fs.readFile(mounts.skills[0].filePath, 'utf8')).toBe(discovery);+ expect(await collectBotOwnSkillMounts(botId, deps())).toEqual(mounts);+ expect(await fs.readFile(manifestPath, 'utf8')).toBe(manifest);+ expect(await fs.readFile(path.join(mounts.pluginRoot, 'catalog.jsonl'), 'utf8')).toBe(catalog);+ expect(await fs.readFile(mounts.skills[0].filePath, 'utf8')).toBe(discovery);+ expect(await fs.readFile(original, 'utf8')).toBe(source);+ const opens = vi.spyOn(fs, 'open');+ await assertBoundedNativeMounts();+ expect(opens).not.toHaveBeenCalled();+ });+it('preserves a near-16 MiB original header and loads only bounded runtime metadata', async () => {const source = `---\r\nname: ${'n'.repeat(7 * 1024 * 1024)}\r\ndescription: ${'d'.repeat(8 * 1024 * 1024)} tail-query\r\n---\r\nRun scripts/report.py\r\n`;const original = await writeSkill('oversized', source);diff --git a/apps/desktop/src/main/maker-ipc/botSkillRuntimeCache.ts b/apps/desktop/src/main/maker-ipc/botSkillRuntimeCache.tsindex 20c58a23d7..9dd2c2c238 100644--- a/apps/desktop/src/main/maker-ipc/botSkillRuntimeCache.ts+++ b/apps/desktop/src/main/maker-ipc/botSkillRuntimeCache.ts@@ -102,6 +102,7 @@ export async function cachedBotSkillRuntime(root: string, build: () => Promise<P// Generated files are disposable: deleting them must rebuild the catalog.const artifacts = current.value.artifacts ?? (current.value.pluginRoot === root ? [] : [path.join(current.value.pluginRoot, 'catalog.jsonl'), current.value.skills[0].filePath,+ path.join(current.value.pluginRoot, '.claude-plugin', 'plugin.json'),]);const present = await Promise.all(artifacts.map(file => fs.access(file))).then(() => true, () => false);// Eviction may happen while checking generated files. Rejoin the active