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

Function cbm_install_skills

src/cli/cli.c:1413–1466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1411/* ── Skill management ─────────────────────────────────────────── */
1412
1413int cbm_install_skills(const char *skills_dir, bool force, bool dry_run) {
1414 if (!skills_dir) {
1415 return 0;
1416 }
1417 int count = 0;
1418
1419 /* Clean up only empty old directories. Historical files may have been
1420 * customized, and their old content is not an ownership proof. */
1421 for (int i = 0; i < OLD_SKILL_COUNT; i++) {
1422 char old_path[CLI_BUF_1K];
1423 snprintf(old_path, sizeof(old_path), "%s/%s", skills_dir, old_skill_names[i]);
1424 (void)cbm_remove_empty_directory(old_path, dry_run);
1425 }
1426
1427 for (int i = 0; i < CBM_SKILL_COUNT; i++) {
1428 char skill_path[CLI_BUF_1K];
1429 snprintf(skill_path, sizeof(skill_path), "%s/%s", skills_dir, skills[i].name);
1430 char file_path[CLI_BUF_1K];
1431 snprintf(file_path, sizeof(file_path), "%s/SKILL.md", skill_path);
1432
1433 struct stat skill_state;
1434#ifndef _WIN32
1435 if (lstat(skill_path, &skill_state) == 0 && !S_ISDIR(skill_state.st_mode)) {
1436 continue;
1437 }
1438#else
1439 if (stat(skill_path, &skill_state) == 0 && !S_ISDIR(skill_state.st_mode)) {
1440 continue;
1441 }
1442#endif
1443
1444 /* Check if already exists */
1445 if (!force) {
1446 struct stat st;
1447 if (stat(file_path, &st) == 0) {
1448 continue;
1449 }
1450 }
1451
1452 if (dry_run) {
1453 count++;
1454 continue;
1455 }
1456
1457 if (mkdirp(skill_path, DIR_PERMS) != 0) {
1458 continue;
1459 }
1460
1461 if (cbm_text_write_owned_document(file_path, skills[i].content) == 0) {
1462 count++;
1463 }
1464 }
1465 return count;
1466}
1467
1468int cbm_remove_skills(const char *skills_dir, bool dry_run) {
1469 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