MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / stampSource

Function stampSource

src/skills/installer.ts:237–246  ·  view source on GitHub ↗
(skillFile: string, source: string)

Source from the content-addressed store, hash-verified

235}
236
237async function stampSource(skillFile: string, source: string): Promise<void> {
238 const raw = await fs.readFile(skillFile, 'utf-8');
239 if (/^source\s*:/m.test(raw)) return;
240 // Inject `source:` inside the existing frontmatter block, just before `---`.
241 const m = raw.match(/^---\s*\n([\s\S]*?)\n---\s*\r?\n?([\s\S]*)$/);
242 if (!m) return;
243 const newFm = (m[1] ?? '').trimEnd() + `\nsource: ${source}\n`;
244 const next = `---\n${newFm}---\n${m[2] ?? ''}`;
245 await fs.writeFile(skillFile, next);
246}
247
248export async function removeSkill(name: string): Promise<void> {
249 if (!NAME_RE.test(name)) throw new Error(`Invalid skill name "${name}".`);

Callers 1

copyIntoFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected