mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-05 23:42:03 +00:00
fix: replace .claude paths with .qwen in markdown files during extension install
Previously, only shell scripts (.sh) had .claude -> .qwen path replacement. Markdown files (.md) like cancel-ralph.md and help.md were missing this conversion, causing incorrect paths like .claude/ralph-loop.local.md. Now performVariableReplacement also replaces .claude directory references in markdown files using the same regex pattern as shell scripts.
This commit is contained in:
parent
067430eef2
commit
3c484782ec
2 changed files with 38 additions and 2 deletions
|
|
@ -263,6 +263,34 @@ describe('performVariableReplacement', () => {
|
|||
expect(result).not.toContain('```!');
|
||||
});
|
||||
|
||||
it('should replace .claude with .qwen in markdown files', () => {
|
||||
const extDir = path.join(testDir, 'ext');
|
||||
fs.mkdirSync(extDir, { recursive: true });
|
||||
|
||||
const mdContent = [
|
||||
'---',
|
||||
'description: "Cancel active loop"',
|
||||
'---',
|
||||
'',
|
||||
'# Cancel',
|
||||
'',
|
||||
'Check if `.claude/loop.local.md` exists.',
|
||||
'Remove the file: `rm .claude/loop.local.md`',
|
||||
'Path: `$HOME/.claude/cache`',
|
||||
'Local: `./.claude/local`',
|
||||
].join('\n');
|
||||
fs.writeFileSync(path.join(extDir, 'cancel.md'), mdContent, 'utf-8');
|
||||
|
||||
performVariableReplacement(extDir);
|
||||
|
||||
const result = fs.readFileSync(path.join(extDir, 'cancel.md'), 'utf-8');
|
||||
expect(result).toContain('.qwen/loop.local.md');
|
||||
expect(result).toContain('rm .qwen/loop.local.md');
|
||||
expect(result).toContain('$HOME/.qwen/cache');
|
||||
expect(result).toContain('./.qwen/local');
|
||||
expect(result).not.toContain('.claude/');
|
||||
});
|
||||
|
||||
it('should replace "role":"assistant" with "type":"assistant" in shell scripts', () => {
|
||||
const extDir = path.join(testDir, 'ext');
|
||||
fs.mkdirSync(extDir, { recursive: true });
|
||||
|
|
|
|||
|
|
@ -148,16 +148,24 @@ export function performVariableReplacement(extensionPath: string): void {
|
|||
|
||||
// Replace Markdown shell syntax ```! ... ``` with system-recognized !{...} syntax
|
||||
// This regex finds code blocks with ! language identifier and captures their content
|
||||
const updatedMdContent = updatedContent.replace(
|
||||
const syntaxUpdatedContent = updatedContent.replace(
|
||||
/```!(?:\s*\n)?([\s\S]*?)\n*```/g,
|
||||
'!{$1}',
|
||||
);
|
||||
|
||||
// Replace references to ".claude" directory with ".qwen" in markdown files
|
||||
// Only match path references (e.g., ~/.claude/, $HOME/.claude, ./.claude/)
|
||||
// Avoid matching URLs, comments, or string literals containing .claude
|
||||
const updatedMdContent = syntaxUpdatedContent.replace(
|
||||
/(\$\{?HOME\}?\/|~\/)?\.claude(\/|$)/g,
|
||||
'$1.qwen$2',
|
||||
);
|
||||
|
||||
// Only write if content was actually changed
|
||||
if (updatedMdContent !== content) {
|
||||
fs.writeFileSync(filePath, updatedMdContent, 'utf8');
|
||||
debugLogger.debug(
|
||||
`Updated variables and syntax in file: ${filePath}`,
|
||||
`Updated variables, syntax, and .claude paths in file: ${filePath}`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue