MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / installFromLocal

Function installFromLocal

internal/cli/management.go:1526–1590  ·  view source on GitHub ↗

--- install from local directory ------------------------------------------

(kind entities.Kind, dirPath, skillName string, all, force bool, out io.Writer, resolveApps func() ([]string, error), stdin io.Reader)

Source from the content-addressed store, hash-verified

1524// --- install from local directory ------------------------------------------
1525
1526func installFromLocal(kind entities.Kind, dirPath, skillName string, all, force bool, out io.Writer, resolveApps func() ([]string, error), stdin io.Reader) error {
1527 // Resolve ~ and relative paths.
1528 if strings.HasPrefix(dirPath, "~/") {
1529 dirPath = filepath.Join(pathutil.Home(), dirPath[2:])
1530 }
1531 absPath, err := filepath.Abs(dirPath)
1532 if err != nil {
1533 return fmt.Errorf("could not resolve path: %w", err)
1534 }
1535 info, err := os.Stat(absPath)
1536 if err != nil {
1537 return fmt.Errorf("could not access directory: %w", err)
1538 }
1539 if !info.IsDir() {
1540 return fmt.Errorf("%s is not a directory", absPath)
1541 }
1542
1543 // Discover entities in the directory.
1544 items := discoverEntities(kind, absPath)
1545 if len(items) == 0 {
1546 fmt.Fprintf(out, "No %ss found in %s\n", kind, absPath)
1547 return nil
1548 }
1549
1550 // Let user pick skills first.
1551 items, err = selectItems(items, skillName, all, kind, absPath, stdin)
1552 if err != nil {
1553 return err
1554 }
1555
1556 // Now resolve the target agent(s) (prompt if needed).
1557 apps, err := resolveApps()
1558 if err != nil {
1559 return err
1560 }
1561
1562 for _, app := range apps {
1563 fmt.Fprintf(out, "\n%s:\n", app)
1564 installed := 0
1565 for _, item := range items {
1566 if !force && isAlreadyInstalled(item.name, kind, app) {
1567 if isInteractive(stdin) && confirmOverwrite(item.name, kind, app) {
1568 // user said yes — fall through to install
1569 } else {
1570 fmt.Fprintf(out, " Skipping %s (already installed)\n", item.name)
1571 continue
1572 }
1573 }
1574 e := entities.Entity{
1575 Name: item.name,
1576 Content: item.content,
1577 Path: item.path,
1578 }
1579 dest, err := entities.InstallToApp(e, kind, app)
1580 if err != nil {
1581 fmt.Fprintf(out, " Error installing %s: %v\n", item.name, err)
1582 continue
1583 }

Callers 1

entityInstallCommandFunction · 0.85

Calls 7

HomeFunction · 0.92
InstallToAppFunction · 0.92
discoverEntitiesFunction · 0.85
selectItemsFunction · 0.85
isAlreadyInstalledFunction · 0.85
isInteractiveFunction · 0.85
confirmOverwriteFunction · 0.85

Tested by

no test coverage detected