chore: generate
This commit is contained in:
@@ -70,7 +70,9 @@ export namespace Auth {
|
|||||||
const data = yield* all()
|
const data = yield* all()
|
||||||
if (norm !== key) delete data[key]
|
if (norm !== key) delete data[key]
|
||||||
delete data[norm + "/"]
|
delete data[norm + "/"]
|
||||||
yield* fsys.writeJson(file, { ...data, [norm]: info }, 0o600).pipe(Effect.mapError(fail("Failed to write auth data")))
|
yield* fsys
|
||||||
|
.writeJson(file, { ...data, [norm]: info }, 0o600)
|
||||||
|
.pipe(Effect.mapError(fail("Failed to write auth data")))
|
||||||
})
|
})
|
||||||
|
|
||||||
const remove = Effect.fn("Auth.remove")(function* (key: string) {
|
const remove = Effect.fn("Auth.remove")(function* (key: string) {
|
||||||
|
|||||||
@@ -190,45 +190,45 @@ export namespace Skill {
|
|||||||
export class Service extends ServiceMap.Service<Service, Interface>()("@opencode/Skill") {}
|
export class Service extends ServiceMap.Service<Service, Interface>()("@opencode/Skill") {}
|
||||||
|
|
||||||
export const layer = Layer.effect(
|
export const layer = Layer.effect(
|
||||||
Service,
|
Service,
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
const discovery = yield* Discovery.Service
|
const discovery = yield* Discovery.Service
|
||||||
const config = yield* Config.Service
|
const config = yield* Config.Service
|
||||||
const bus = yield* Bus.Service
|
const bus = yield* Bus.Service
|
||||||
const fsys = yield* AppFileSystem.Service
|
const fsys = yield* AppFileSystem.Service
|
||||||
const state = yield* InstanceState.make(
|
const state = yield* InstanceState.make(
|
||||||
Effect.fn("Skill.state")(function* (ctx) {
|
Effect.fn("Skill.state")(function* (ctx) {
|
||||||
const s: State = { skills: {}, dirs: new Set() }
|
const s: State = { skills: {}, dirs: new Set() }
|
||||||
yield* loadSkills(s, config, discovery, bus, fsys, ctx.directory, ctx.worktree)
|
yield* loadSkills(s, config, discovery, bus, fsys, ctx.directory, ctx.worktree)
|
||||||
return s
|
return s
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
const get = Effect.fn("Skill.get")(function* (name: string) {
|
const get = Effect.fn("Skill.get")(function* (name: string) {
|
||||||
const s = yield* InstanceState.get(state)
|
const s = yield* InstanceState.get(state)
|
||||||
return s.skills[name]
|
return s.skills[name]
|
||||||
})
|
})
|
||||||
|
|
||||||
const all = Effect.fn("Skill.all")(function* () {
|
const all = Effect.fn("Skill.all")(function* () {
|
||||||
const s = yield* InstanceState.get(state)
|
const s = yield* InstanceState.get(state)
|
||||||
return Object.values(s.skills)
|
return Object.values(s.skills)
|
||||||
})
|
})
|
||||||
|
|
||||||
const dirs = Effect.fn("Skill.dirs")(function* () {
|
const dirs = Effect.fn("Skill.dirs")(function* () {
|
||||||
const s = yield* InstanceState.get(state)
|
const s = yield* InstanceState.get(state)
|
||||||
return Array.from(s.dirs)
|
return Array.from(s.dirs)
|
||||||
})
|
})
|
||||||
|
|
||||||
const available = Effect.fn("Skill.available")(function* (agent?: Agent.Info) {
|
const available = Effect.fn("Skill.available")(function* (agent?: Agent.Info) {
|
||||||
const s = yield* InstanceState.get(state)
|
const s = yield* InstanceState.get(state)
|
||||||
const list = Object.values(s.skills).toSorted((a, b) => a.name.localeCompare(b.name))
|
const list = Object.values(s.skills).toSorted((a, b) => a.name.localeCompare(b.name))
|
||||||
if (!agent) return list
|
if (!agent) return list
|
||||||
return list.filter((skill) => Permission.evaluate("skill", skill.name, agent.permission).action !== "deny")
|
return list.filter((skill) => Permission.evaluate("skill", skill.name, agent.permission).action !== "deny")
|
||||||
})
|
})
|
||||||
|
|
||||||
return Service.of({ get, all, dirs, available })
|
return Service.of({ get, all, dirs, available })
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
export const defaultLayer = layer.pipe(
|
export const defaultLayer = layer.pipe(
|
||||||
Layer.provide(Discovery.defaultLayer),
|
Layer.provide(Discovery.defaultLayer),
|
||||||
|
|||||||
Reference in New Issue
Block a user