Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.
JavaScript agent-collaborationagent-harnessagent-orchestrationagent-teamagent-workflowai-assistantai-automationai-employeeai-productivityai-teamai-workflowautonomous-agentsclaude-code-guiclaude-coworkdesktop-agentlocal-firstmulti-agentmulti-agent-systemself-evolving-agentstask-automation
Preserve BOM-prefixed Skill metadata and rebuild stale catalogs
BlueSkyID6666f5de6d7903a
diff --git a/src/main/features/skills.ts b/src/main/features/skills.tsindex ba8fc80c..af08c4e0 100644--- a/src/main/features/skills.ts+++ b/src/main/features/skills.ts@@ -331,6 +331,7 @@ export interface SkillOrkasMeta {* - single-quoted with '' escape: `description: 'it''s fine'`*/export function parseSkillFrontmatter(text: string): SkillFrontmatter {+ if (text.charCodeAt(0) === 0xFEFF) text = text.slice(1);const meta: SkillFrontmatter = {};if (!text.startsWith('---')) return meta;const end = text.indexOf('---', 3);@@ -523,7 +524,9 @@ function removeSkillSidecarDescriptionsSync(dir: string): void {}// Module-level cache for `listSkills`.-const SKILL_CATALOG_CACHE_VERSION = 2;+// Older projections may have lost ownership metadata on BOM-prefixed files.+// Rebuild derived rows once; the original Skill files stay untouched.+const SKILL_CATALOG_CACHE_VERSION = 3;const SKILL_PERSISTED_TRUST_MS = 2_000;interface SkillListCache {@@ -1046,6 +1049,7 @@ function platformSkillMdContent(}export function splitSkillMd(text: string): { meta: SkillFrontmatter; body: string } {+ if (text.charCodeAt(0) === 0xFEFF) text = text.slice(1);if (!text.startsWith('---')) return { meta: {}, body: text };const end = text.indexOf('---', 3);if (end === -1) return { meta: {}, body: text };diff --git a/test/main/features/skills.test.ts b/test/main/features/skills.test.tsindex d16b9f03..ac75cbe7 100644--- a/test/main/features/skills.test.ts+++ b/test/main/features/skills.test.ts@@ -98,6 +98,25 @@ function markImportDraft(id: string, source: 'url' | 'dir' = 'dir'): void {}describe('skills › parseSkillFrontmatter', () => {+ it.each(['\n', '\r\n'])('preserves identity and private ownership with a leading UTF-8 BOM (%j)', async (newline) => {+ const s = await loadSkills();+ const text = ['---', 'name: Fixture', 'description: Synthetic fixture', 'ownerAgent: fixture-owner', '---', 'Body'].join(newline);+ expect(s.parseSkillFrontmatter('\uFEFF' + text)).toMatchObject({+ name: 'Fixture', description: 'Synthetic fixture', ownerAgent: 'fixture-owner',+ });+ });++ it('does not expose a BOM-prefixed private Skill in the public listing', async () => {+ writeCustomSkill('private-bom', 'name: Fixture\ndescription: Synthetic fixture\nownerAgent: fixture-owner');+ const file = path.join(customSkillsDir(), 'private-bom', 'SKILL.md');+ const bytes = Buffer.from('\uFEFF' + fs.readFileSync(file, 'utf8'));+ fs.writeFileSync(file, bytes);+ const s = await loadSkills();+ expect(await s.listSkills()).toEqual([]);+ expect(await s.listAgentPrivateSkills()).toMatchObject([{ id: 'private-bom', ownerAgent: 'fixture-owner' }]);+ expect(fs.readFileSync(file)).toEqual(bytes);+ });+it('extracts unquoted scalars', async () => {const s = await loadSkills();const meta = s.parseSkillFrontmatter('---\nname: agent-browser\ndescription: A tool\n---\nbody');@@ -148,6 +167,14 @@ describe('skills › parseSkillFrontmatter', () => {});describe('skills › splitSkillMd', () => {+ it('recognizes a leading encoding marker without moving frontmatter into the body', async () => {+ const s = await loadSkills();+ const body = ' Body with an interior \uFEFF character\n';+ const result = s.splitSkillMd('\uFEFF---\nname: Fixture\n---\n\n' + body);+ expect(result.meta).toMatchObject({ name: 'Fixture' });+ expect(result.body).toBe(body);+ });+it('separates meta + body for well-formed file', async () => {const s = await loadSkills();const r = s.splitSkillMd('---\nname: n\ndescription: d\n---\n\nbody text');@@ -841,6 +868,37 @@ describe('skills › applySkillContainerFromCommander › edit', () => {// `<uid>/local/marketplace/skills/<id>/` per machine — see features/marketplace_*.ts.describe('skills › listSkills', () => {+ it.each(['custom', 'marketplace'])('rebuilds pre-BOM catalog metadata after restart without exposing private %s Skills', async (source) => {+ const id = 'aabbccddeeff';+ const root = source === 'custom' ? customSkillsDir() : builtinSkillsDir();+ const file = path.join(root, id, 'SKILL.md');+ fs.mkdirSync(path.dirname(file), { recursive: true });+ const bytes = Buffer.from('\uFEFF---\nname: Owned fixture\ndescription: Private fixture\nownerAgent: fixture-owner\n---\nBody');+ fs.writeFileSync(file, bytes);+ const first = await loadSkills();+ expect(await first.listSkills()).toEqual([]);+ first.setSkillEnabledForActiveUser(id, false);+ const paths = await import('../../../src/main/paths');+ const cacheFile = paths.userSkillCatalogCacheFile(TEST_UID);+ const snapshot = JSON.parse(fs.readFileSync(cacheFile, 'utf8'));+ // Old readers persisted the directory id and blank metadata for BOM files.+ // Keep real inventory stamps so only rejecting the obsolete projection can+ // restore the original identity/ownership on the first post-upgrade read.+ fs.writeFileSync(cacheFile, JSON.stringify({+ ...snapshot, version: 2,+ data: [{ id, name: id, source, description_zh: '', description_en: '', category: '', enabled: true }],+ }));+ vi.resetModules();+ (await import('../../../src/main/features/users')).activateUser(TEST_UID);+ const restarted = await loadSkills();+ expect(await restarted.listSkills()).toEqual([]);+ expect(await restarted.listAgentPrivateSkills()).toMatchObject([{+ id, source, name: 'Owned fixture', description_en: 'Private fixture', ownerAgent: 'fixture-owner', enabled: false,+ }]);+ expect(JSON.parse(fs.readFileSync(cacheFile, 'utf8')).version).toBe(3);+ expect(fs.readFileSync(file)).toEqual(bytes);+ });+it('reuses the persisted catalog after a module restart and honors force invalidation', async () => {writeCustomSkill('persisted-skill', 'name: "Old Skill"\ndescription: "cached"');const first = await loadSkills();