Skip to content

Commit 6e5fb57

Browse files
committed
Update skill symbol replacement to use markdown formatting instead of XML tags
- following the approach to 'changes' symbol (markdown instead of xml), update 'skills' symbol handling accordingly - than "# Skill frontend-design", we prefer "# Frontend design" - Parameter 'c' implicitly has an 'any' type. - the skill reference is incorrect - in markdown, suffix skill names with 'skill' and update reference - skills in markdown have unwanted text like [Pasted text] └── apps └── editor └── src ├── utils │ └── files-collector.ts └── views └── prompt └── backend ├── message-handlers │ └── handle-autofill.ts └── utils └── symbols ├── fragment │ └── replace-fragment-symbol.ts ├── git │ └── replace-git-symbols.ts ├── image │ └── replace-image-symbol.ts ├── pasted-text │ └── replace-pasted-text-symbol.ts ├── replace-symbols.ts ├── saved-context │ └── replace-saved-context-symbol.ts ├── selection │ └── replace-selection-symbol.ts ├── skill │ └── replace-skill-symbol.ts └── website └── replace-website-symbol.ts
1 parent ff764d9 commit 6e5fb57

1 file changed

Lines changed: 25 additions & 6 deletions

File tree

‎apps/editor/src/views/prompt/backend/utils/symbols/skill/replace-skill-symbol.ts‎

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,17 @@ export const replace_skill_symbol = async (params: {
1818
regex,
1919
(_, agent_name, _repo_id, skill_name) => {
2020
const key = `${agent_name}:${skill_name}`
21-
const reference = `<skill name="${skill_name}" />`
21+
22+
const formatted_skill_name = skill_name
23+
.replace(/-/g, ' ')
24+
.replace(/^./, (c: string) => c.toUpperCase())
25+
26+
const link_hash = formatted_skill_name
27+
.toLowerCase()
28+
.replace(/[^a-z0-9]+/g, '-')
29+
.replace(/^-|-$/g, '')
30+
31+
const reference = `[${formatted_skill_name}](#${link_hash})`
2232

2333
if (processed_skills.has(key)) {
2434
return reference
@@ -46,7 +56,7 @@ export const replace_skill_symbol = async (params: {
4656

4757
processed_skills.add(key)
4858

49-
let skill_content = `<skill name="${skill_name}">\n`
59+
let skill_content = `# ${formatted_skill_name}\n\n`
5060

5161
try {
5262
const collect_files = (dir_path: string) => {
@@ -61,11 +71,21 @@ export const replace_skill_symbol = async (params: {
6171
const lower_name = file_name.toLowerCase()
6272
if (lower_name == 'readme.md' || lower_name.startsWith('license'))
6373
continue
64-
const content = fs.readFileSync(file_path, 'utf-8')
74+
let content = fs.readFileSync(file_path, 'utf-8')
75+
76+
content = content.replace(
77+
/^---\s*\r?\n[\s\S]*?\r?\n---\s*(?:\r?\n|$)/,
78+
''
79+
)
80+
6581
const relative_path = normalize_path(
6682
path.relative(skill.path, file_path)
6783
)
68-
skill_content += `<file path="${relative_path}">\n\`\`\`\n${content}\n\`\`\`\n</file>\n`
84+
const backticks = content.includes('```') ? '````' : '```'
85+
skill_content += `- File: \`${relative_path.replace(
86+
/\\/g,
87+
'/'
88+
)}\`\n\n${backticks}\n${content}\n${backticks}\n\n`
6989
}
7090
}
7191
}
@@ -79,8 +99,7 @@ export const replace_skill_symbol = async (params: {
7999
return ''
80100
}
81101

82-
skill_content += `</skill>`
83-
skill_definitions += skill_content + '\n'
102+
skill_definitions += skill_content
84103

85104
return reference
86105
}

0 commit comments

Comments
 (0)