MCPcopy Create free account
hub / github.com/diillson/chatcli / NewManager

Function NewManager

cli/plugins/manager.go:30–59  ·  view source on GitHub ↗
(logger *zap.Logger)

Source from the content-addressed store, hash-verified

28}
29
30func NewManager(logger *zap.Logger) (*Manager, error) {
31 home, err := utils.GetHomeDir()
32 if err != nil {
33 return nil, fmt.Errorf("não foi possível encontrar o diretório home para plugins: %w", err)
34 }
35 pluginsDir := filepath.Join(home, ".chatcli", "plugins")
36
37 // Garante que o diretório de plugins exista
38 if err := os.MkdirAll(pluginsDir, 0o700); err != nil {
39 return nil, fmt.Errorf("não foi possível criar o diretório de plugins: %w", err)
40 }
41
42 watcher, err := fsnotify.NewWatcher()
43 if err != nil {
44 return nil, fmt.Errorf("não foi possível criar o observador de arquivos: %w", err)
45 }
46
47 m := &Manager{
48 plugins: make(map[string]Plugin),
49 builtins: make(map[string]Plugin),
50 shadowed: make(map[string]struct{}),
51 pluginsDir: pluginsDir,
52 logger: logger,
53 watcher: watcher,
54 }
55 m.Reload()
56 go m.watchForChanges()
57
58 return m, nil
59}
60
61// Close encerra o watcher de arquivos de forma segura.
62func (m *Manager) Close() {

Callers 4

newCatalogCLIFunction · 0.92
NewChatCLIFunction · 0.92
RunServerFunction · 0.92

Calls 4

ReloadMethod · 0.95
watchForChangesMethod · 0.95
GetHomeDirFunction · 0.92
ErrorfMethod · 0.80

Tested by 2

newCatalogCLIFunction · 0.74