Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/utils/skill-metadata.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { existsSync, readFileSync, writeFileSync } from 'fs';
import { join } from 'path';

function normalizePathSeparators(path: string): string {
return path.replace(/\\/g, '/');
}

export const SKILL_METADATA_FILE = '.openskills.json';

export type SkillSourceType = 'git' | 'github' | 'local';
Expand Down Expand Up @@ -30,6 +34,8 @@ export function writeSkillMetadata(skillDir: string, metadata: SkillSourceMetada
const metadataPath = join(skillDir, SKILL_METADATA_FILE);
const payload = {
...metadata,
subpath: metadata.subpath ? normalizePathSeparators(metadata.subpath) : undefined,
localPath: metadata.localPath ? normalizePathSeparators(metadata.localPath) : undefined,
installedAt: metadata.installedAt || new Date().toISOString(),
};
writeFileSync(metadataPath, JSON.stringify(payload, null, 2));
Expand Down
29 changes: 29 additions & 0 deletions tests/utils/skill-metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,33 @@ describe('skill-metadata', () => {
writeFileSync(join(tempDir, SKILL_METADATA_FILE), '{not-json');
expect(readSkillMetadata(tempDir)).toBeNull();
});

it('normalizes Windows backslashes to forward slashes in subpath', () => {
const payload = {
source: 'owner/repo',
sourceType: 'git' as const,
repoUrl: 'https://github.com/owner/repo',
subpath: 'skills\\nested\\skill',
installedAt: '2026-01-01T00:00:00.000Z',
};

writeSkillMetadata(tempDir, payload);
const read = readSkillMetadata(tempDir);

expect(read?.subpath).toBe('skills/nested/skill');
});

it('normalizes Windows backslashes to forward slashes in localPath', () => {
const payload = {
source: '/path/to/skill',
sourceType: 'local' as const,
localPath: 'C:\\Users\\test\\skills\\my-skill',
installedAt: '2026-01-01T00:00:00.000Z',
};

writeSkillMetadata(tempDir, payload);
const read = readSkillMetadata(tempDir);

expect(read?.localPath).toBe('C:/Users/test/skills/my-skill');
});
});