Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

739 B
Raw Blame
import type { SkillSource } from './source'
import { mkdir, rm, writeFile } from 'node:fs/promises'
import { dirname, join } from 'node:path'
import { SKILL_NAME } from './source'

export async function installSkill(root: string, source: SkillSource): Promise<string[]> {
  const files = await Promise.all(
    source.paths.map(async (path) => ({ path, file: await source.read(path) })),
  )
  const target = join(root, SKILL_NAME)
  await rm(target, { recursive: true, force: true })
  const wrote: string[] = []
  for (const { path, file } of files) {
    const abs = join(target, path)
    await mkdir(dirname(abs), { recursive: true })
    await writeFile(abs, file.bytes, { mode: file.mode })
    wrote.push(abs)
  }
  return wrote
}