mirror of
https://github.com/sst/opencode.git
synced 2025-08-22 14:04:07 +00:00
tweak(config): make markdown agent files in subfolder discoverable .opencode/agent/some-folder/*.md
(#1999)
This commit is contained in:
parent
daea79c0d4
commit
1e204c23b9
1 changed files with 18 additions and 3 deletions
|
@ -44,16 +44,31 @@ export namespace Config {
|
|||
|
||||
result.agent = result.agent || {}
|
||||
const markdownAgents = [
|
||||
...(await Filesystem.globUp("agent/*.md", Global.Path.config, Global.Path.config)),
|
||||
...(await Filesystem.globUp(".opencode/agent/*.md", app.path.cwd, app.path.root)),
|
||||
...(await Filesystem.globUp("agent/**/*.md", Global.Path.config, Global.Path.config)),
|
||||
...(await Filesystem.globUp(".opencode/agent/**/*.md", app.path.cwd, app.path.root)),
|
||||
]
|
||||
for (const item of markdownAgents) {
|
||||
const content = await Bun.file(item).text()
|
||||
const md = matter(content)
|
||||
if (!md.data) continue
|
||||
|
||||
// Extract relative path from agent folder for nested agents
|
||||
let agentName = path.basename(item, ".md")
|
||||
const agentFolderPath = item.includes("/.opencode/agent/")
|
||||
? item.split("/.opencode/agent/")[1]
|
||||
: item.includes("/agent/")
|
||||
? item.split("/agent/")[1]
|
||||
: agentName + ".md"
|
||||
|
||||
// If agent is in a subfolder, include folder path in name
|
||||
if (agentFolderPath.includes("/")) {
|
||||
const relativePath = agentFolderPath.replace(".md", "")
|
||||
const pathParts = relativePath.split("/")
|
||||
agentName = pathParts.slice(0, -1).join("/").toUpperCase() + "/" + pathParts[pathParts.length - 1].toUpperCase()
|
||||
}
|
||||
|
||||
const config = {
|
||||
name: path.basename(item, ".md"),
|
||||
name: agentName,
|
||||
...md.data,
|
||||
prompt: md.content.trim(),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue