MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_install_skills

Function cbm_install_skills

src/cli/cli.c:1441–1494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1439/* ── Skill management ─────────────────────────────────────────── */
1440
1441int cbm_install_skills(const char *skills_dir, bool force, bool dry_run) {
1442 if (!skills_dir) {
1443 return 0;
1444 }
1445 int count = 0;
1446
1447 /* Clean up only empty old directories. Historical files may have been
1448 * customized, and their old content is not an ownership proof. */
1449 for (int i = 0; i < OLD_SKILL_COUNT; i++) {
1450 char old_path[CLI_BUF_1K];
1451 snprintf(old_path, sizeof(old_path), "%s/%s", skills_dir, old_skill_names[i]);
1452 (void)cbm_remove_empty_directory(old_path, dry_run);
1453 }
1454
1455 for (int i = 0; i < CBM_SKILL_COUNT; i++) {
1456 char skill_path[CLI_BUF_1K];
1457 snprintf(skill_path, sizeof(skill_path), "%s/%s", skills_dir, skills[i].name);
1458 char file_path[CLI_BUF_1K];
1459 snprintf(file_path, sizeof(file_path), "%s/SKILL.md", skill_path);
1460
1461 struct stat skill_state;
1462#ifndef _WIN32
1463 if (lstat(skill_path, &skill_state) == 0 && !S_ISDIR(skill_state.st_mode)) {
1464 continue;
1465 }
1466#else
1467 if (stat(skill_path, &skill_state) == 0 && !S_ISDIR(skill_state.st_mode)) {
1468 continue;
1469 }
1470#endif
1471
1472 /* Check if already exists */
1473 if (!force) {
1474 struct stat st;
1475 if (stat(file_path, &st) == 0) {
1476 continue;
1477 }
1478 }
1479
1480 if (dry_run) {
1481 count++;
1482 continue;
1483 }
1484
1485 if (mkdirp(skill_path, DIR_PERMS) != 0) {
1486 continue;
1487 }
1488
1489 if (cbm_text_write_owned_document(file_path, skills[i].content) == 0) {
1490 count++;
1491 }
1492 }
1493 return count;
1494}
1495
1496int cbm_remove_skills(const char *skills_dir, bool dry_run) {
1497 if (!skills_dir) {

Callers 3

install_agent_skillFunction · 0.85
test_cli.cFile · 0.85

Calls 3

mkdirpFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected