chore: generate
This commit is contained in:
@@ -171,7 +171,11 @@ export const layer = Layer.effect(
|
|||||||
const discovered = locationIsGlobal
|
const discovered = locationIsGlobal
|
||||||
? []
|
? []
|
||||||
: yield* fs
|
: yield* fs
|
||||||
.up({ targets: [".opencode", ...names.toReversed()], start: location.directory, stop: location.project.directory })
|
.up({
|
||||||
|
targets: [".opencode", ...names.toReversed()],
|
||||||
|
start: location.directory,
|
||||||
|
stop: location.project.directory,
|
||||||
|
})
|
||||||
.pipe(Effect.orDie)
|
.pipe(Effect.orDie)
|
||||||
const directories = [
|
const directories = [
|
||||||
globalDirectory,
|
globalDirectory,
|
||||||
|
|||||||
@@ -19,7 +19,19 @@ const legacySources = [
|
|||||||
const decodeAgent = Schema.decodeUnknownOption(ConfigAgent.Info)
|
const decodeAgent = Schema.decodeUnknownOption(ConfigAgent.Info)
|
||||||
const decodeLegacyAgent = Schema.decodeUnknownOption(ConfigAgentV1.Info)
|
const decodeLegacyAgent = Schema.decodeUnknownOption(ConfigAgentV1.Info)
|
||||||
const decodeConfig = Schema.decodeUnknownOption(Config.Info)
|
const decodeConfig = Schema.decodeUnknownOption(Config.Info)
|
||||||
const agentKeys = new Set(["model", "variant", "request", "system", "description", "mode", "hidden", "color", "steps", "disabled", "permissions"])
|
const agentKeys = new Set([
|
||||||
|
"model",
|
||||||
|
"variant",
|
||||||
|
"request",
|
||||||
|
"system",
|
||||||
|
"description",
|
||||||
|
"mode",
|
||||||
|
"hidden",
|
||||||
|
"color",
|
||||||
|
"steps",
|
||||||
|
"disabled",
|
||||||
|
"permissions",
|
||||||
|
])
|
||||||
|
|
||||||
export const Plugin = PluginV2.define({
|
export const Plugin = PluginV2.define({
|
||||||
id: PluginV2.ID.make("config-agent"),
|
id: PluginV2.ID.make("config-agent"),
|
||||||
@@ -37,7 +49,9 @@ export const Plugin = PluginV2.define({
|
|||||||
Effect.catch(() => Effect.succeed(undefined)),
|
Effect.catch(() => Effect.succeed(undefined)),
|
||||||
),
|
),
|
||||||
).pipe(
|
).pipe(
|
||||||
Effect.map((documents) => documents.filter((document): document is Config.Document => document !== undefined)),
|
Effect.map((documents) =>
|
||||||
|
documents.filter((document): document is Config.Document => document !== undefined),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}).pipe(Effect.map((documents) => documents.flat()))
|
}).pipe(Effect.map((documents) => documents.flat()))
|
||||||
@@ -88,7 +102,9 @@ function discover(fs: FSUtil.Interface, directory: string) {
|
|||||||
return Effect.forEach(legacySources, (source) =>
|
return Effect.forEach(legacySources, (source) =>
|
||||||
fs
|
fs
|
||||||
.glob(source.pattern, { cwd: directory, absolute: true, dot: true, symlink: true })
|
.glob(source.pattern, { cwd: directory, absolute: true, dot: true, symlink: true })
|
||||||
.pipe(Effect.map((files) => files.toSorted().map((filepath) => ({ directory, filepath, primary: source.primary })))),
|
.pipe(
|
||||||
|
Effect.map((files) => files.toSorted().map((filepath) => ({ directory, filepath, primary: source.primary }))),
|
||||||
|
),
|
||||||
).pipe(
|
).pipe(
|
||||||
Effect.map((files) => files.flat()),
|
Effect.map((files) => files.flat()),
|
||||||
Effect.catch(() => Effect.succeed([])),
|
Effect.catch(() => Effect.succeed([])),
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const Plugin = PluginV2.define({
|
|||||||
const skill = yield* SkillV2.Service
|
const skill = yield* SkillV2.Service
|
||||||
const transform = yield* skill.transform()
|
const transform = yield* skill.transform()
|
||||||
const entries = yield* config.entries()
|
const entries = yield* config.entries()
|
||||||
const items = entries.flatMap((entry) => (entry.type === "document" ? entry.info.skills ?? [] : []))
|
const items = entries.flatMap((entry) => (entry.type === "document" ? (entry.info.skills ?? []) : []))
|
||||||
|
|
||||||
yield* transform((editor) => {
|
yield* transform((editor) => {
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
|
|||||||
@@ -108,13 +108,15 @@ export const layer = Layer.effect(
|
|||||||
? path.basename(filepath, ".md")
|
? path.basename(filepath, ".md")
|
||||||
: undefined
|
: undefined
|
||||||
if (!name) continue
|
if (!name) continue
|
||||||
skills.push(new Info({
|
skills.push(
|
||||||
name,
|
new Info({
|
||||||
description: frontmatter.description,
|
name,
|
||||||
slash: frontmatter.slash,
|
description: frontmatter.description,
|
||||||
location: AbsolutePath.make(filepath),
|
slash: frontmatter.slash,
|
||||||
content: markdown.content,
|
location: AbsolutePath.make(filepath),
|
||||||
}))
|
content: markdown.content,
|
||||||
|
}),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return skills
|
return skills
|
||||||
|
|||||||
@@ -110,7 +110,9 @@ describe("Config", () => {
|
|||||||
const config = yield* Config.Service
|
const config = yield* Config.Service
|
||||||
const entries = yield* config.entries()
|
const entries = yield* config.entries()
|
||||||
|
|
||||||
expect(entries).toEqual([new Config.Directory({ type: "directory", path: AbsolutePath.make(path.join(tmp.path, "global")) })])
|
expect(entries).toEqual([
|
||||||
|
new Config.Directory({ type: "directory", path: AbsolutePath.make(path.join(tmp.path, "global")) }),
|
||||||
|
])
|
||||||
}).pipe(Effect.provide(testLayer(tmp.path))),
|
}).pipe(Effect.provide(testLayer(tmp.path))),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -157,11 +159,11 @@ describe("Config", () => {
|
|||||||
yield* Effect.promise(() =>
|
yield* Effect.promise(() =>
|
||||||
fs.writeFile(path.join(tmp.path, "opencode.jsonc"), JSON.stringify({ $schema: "changed" })),
|
fs.writeFile(path.join(tmp.path, "opencode.jsonc"), JSON.stringify({ $schema: "changed" })),
|
||||||
)
|
)
|
||||||
expect((yield* config.entries()).filter((entry) => entry.type === "document").map((document) => document.info.$schema)).toEqual([
|
expect(
|
||||||
"base",
|
(yield* config.entries())
|
||||||
"middle",
|
.filter((entry) => entry.type === "document")
|
||||||
"last",
|
.map((document) => document.info.$schema),
|
||||||
])
|
).toEqual(["base", "middle", "last"])
|
||||||
}).pipe(Effect.provide(testLayer(tmp.path)))
|
}).pipe(Effect.provide(testLayer(tmp.path)))
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -57,11 +57,13 @@ describe("ConfigSkillPlugin.Plugin", () => {
|
|||||||
|
|
||||||
expect(sources).toEqual([
|
expect(sources).toEqual([
|
||||||
new SkillV2.DirectorySource({ type: "directory", path: AbsolutePath.make(path.join(directory, "skills")) }),
|
new SkillV2.DirectorySource({ type: "directory", path: AbsolutePath.make(path.join(directory, "skills")) }),
|
||||||
new SkillV2.DirectorySource({ type: "directory", path: AbsolutePath.make(path.join("/home/test", "shared-skills")) }),
|
new SkillV2.DirectorySource({
|
||||||
|
type: "directory",
|
||||||
|
path: AbsolutePath.make(path.join("/home/test", "shared-skills")),
|
||||||
|
}),
|
||||||
new SkillV2.DirectorySource({ type: "directory", path: AbsolutePath.make("/opt/skills") }),
|
new SkillV2.DirectorySource({ type: "directory", path: AbsolutePath.make("/opt/skills") }),
|
||||||
new SkillV2.UrlSource({ type: "url", url: "https://example.test/skills/" }),
|
new SkillV2.UrlSource({ type: "url", url: "https://example.test/skills/" }),
|
||||||
])
|
])
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -254,10 +254,7 @@ function testLayer(input: {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Layer.succeed(
|
Layer.succeed(Config.Service, Config.Service.of({ entries: () => Effect.succeed(input.documents) })),
|
||||||
Config.Service,
|
|
||||||
Config.Service.of({ entries: () => Effect.succeed(input.documents) }),
|
|
||||||
),
|
|
||||||
Layer.succeed(RepositoryCache.Service, RepositoryCache.Service.of({ ensure: input.ensure })),
|
Layer.succeed(RepositoryCache.Service, RepositoryCache.Service.of({ ensure: input.ensure })),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user