MCPcopy Create free account
hub / github.com/astercloud/aster / List

Method List

pkg/commands/loader.go:103–122  ·  view source on GitHub ↗

List 列出所有可用命令

(ctx context.Context)

Source from the content-addressed store, hash-verified

101
102// List 列出所有可用命令
103func (cl *CommandLoader) List(ctx context.Context) ([]string, error) {
104 // 使用 Glob 匹配所有 .md 文件
105 pattern := "*.md"
106 files, err := cl.fs.Glob(ctx, pattern, &sandbox.GlobOptions{
107 CWD: cl.baseDir,
108 Absolute: false,
109 })
110 if err != nil {
111 return nil, fmt.Errorf("glob commands: %w", err)
112 }
113
114 commands := make([]string, 0, len(files))
115 for _, file := range files {
116 // 去掉 .md 后缀
117 name := strings.TrimSuffix(filepath.Base(file), ".md")
118 commands = append(commands, name)
119 }
120
121 return commands, nil
122}
123
124// LoadLocal 从本地文件系统加载(用于开发)
125func LoadLocal(baseDir, commandName string) (*CommandDefinition, error) {

Callers

nothing calls this directly

Calls 1

GlobMethod · 0.65

Tested by

no test coverage detected