mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-28 05:04:23 +01:00
resolve nested commands (#2537)
This commit is contained in:
@@ -118,16 +118,27 @@ export namespace Config {
|
||||
// Load command markdown files
|
||||
result.command = result.command || {}
|
||||
const markdownCommands = [
|
||||
...(await Filesystem.globUp("command/*.md", Global.Path.config, Global.Path.config)),
|
||||
...(await Filesystem.globUp(".opencode/command/*.md", Instance.directory, Instance.worktree)),
|
||||
...(await Filesystem.globUp("command/**/*.md", Global.Path.config, Global.Path.config)),
|
||||
...(await Filesystem.globUp(".opencode/command/**/*.md", Instance.directory, Instance.worktree)),
|
||||
]
|
||||
for (const item of markdownCommands) {
|
||||
const content = await Bun.file(item).text()
|
||||
const md = matter(content)
|
||||
if (!md.data) continue
|
||||
|
||||
const name = (() => {
|
||||
const patterns = ["/.opencode/command/", "/command/"]
|
||||
const pattern = patterns.find((p) => item.includes(p))
|
||||
|
||||
if (pattern) {
|
||||
const index = item.indexOf(pattern)
|
||||
return item.slice(index + pattern.length, -3)
|
||||
}
|
||||
return path.basename(item, ".md")
|
||||
})()
|
||||
|
||||
const config = {
|
||||
name: path.basename(item, ".md"),
|
||||
name,
|
||||
...md.data,
|
||||
template: md.content.trim(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user