MCPcopy Index your code
hub / github.com/codeaashu/claude-code / writeSkillFiles

Function writeSkillFiles

src/skills/bundledSkills.ts:147–167  ·  view source on GitHub ↗
(
  dir: string,
  files: Record<string, string>,
)

Source from the content-addressed store, hash-verified

145}
146
147async function writeSkillFiles(
148 dir: string,
149 files: Record<string, string>,
150): Promise<void> {
151 // Group by parent dir so we mkdir each subtree once, then write.
152 const byParent = new Map<string, [string, string][]>()
153 for (const [relPath, content] of Object.entries(files)) {
154 const target = resolveSkillFilePath(dir, relPath)
155 const parent = dirname(target)
156 const entry: [string, string] = [target, content]
157 const group = byParent.get(parent)
158 if (group) group.push(entry)
159 else byParent.set(parent, [entry])
160 }
161 await Promise.all(
162 [...byParent].map(async ([parent, entries]) => {
163 await mkdir(parent, { recursive: true, mode: 0o700 })
164 await Promise.all(entries.map(([p, c]) => safeWriteFile(p, c)))
165 }),
166 )
167}
168
169// The per-process nonce in getBundledSkillsRoot() is the primary defense
170// against pre-created symlinks/dirs. Explicit 0o700/0o600 modes keep the

Callers 1

extractBundledSkillFilesFunction · 0.85

Calls 7

resolveSkillFilePathFunction · 0.85
mkdirFunction · 0.85
safeWriteFileFunction · 0.85
entriesMethod · 0.80
getMethod · 0.65
pushMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected