mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-12 14:16:28 +03:00
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:
@@ -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;
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user