fix: preserve article casing in prefixed skill references

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
Gujiassh
2026-03-19 11:52:26 +09:00
co-authored by Sisyphus
parent d6b1a56bc5
commit b1becfc341
2 changed files with 6 additions and 4 deletions
+4 -1
View File
@@ -331,7 +331,10 @@ export function prefixSkillReferences(content, prefix, skillNames) {
result = result.replace(new RegExp(`\\/(?=${escapeRegex(name)}(?:[^a-zA-Z0-9_-]|$))`, 'g'), `/${prefix}`);
// Replace `the skillname skill` references
result = result.replace(new RegExp(`the ${escapeRegex(name)} skill`, 'gi'), `the ${prefixed} skill`);
result = result.replace(
new RegExp(`(the) ${escapeRegex(name)} skill`, 'gi'),
(_, article) => `${article} ${prefixed} skill`
);
}
return result;
+2 -3
View File
@@ -677,7 +677,7 @@ describe('prefixSkillReferences', () => {
const result = prefixSkillReferences('Run /audit then /polish. The audit skill is great.', 'i-', ['audit', 'polish']);
expect(result).toContain('/i-audit');
expect(result).toContain('/i-polish');
expect(result).toContain('the i-audit skill');
expect(result).toContain('The i-audit skill');
});
test('should not partially match longer skill names', () => {
@@ -687,8 +687,7 @@ describe('prefixSkillReferences', () => {
test('should handle case-insensitive "the X skill" matching', () => {
const result = prefixSkillReferences('The audit skill is useful.', 'i-', ['audit']);
// The regex replaces case-insensitively, so "The" becomes "the" in the replacement
expect(result).toBe('the i-audit skill is useful.');
expect(result).toBe('The i-audit skill is useful.');
});
test('should return content unchanged with empty prefix', () => {