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

Function cbm_remove_instructions

src/cli/cli.c:1414–1459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1412}
1413
1414int cbm_remove_instructions(const char *path) {
1415 if (!path) {
1416 return CLI_ERR;
1417 }
1418
1419 size_t len = 0;
1420 char *content = read_file_str(path, &len);
1421 if (!content) {
1422 return CLI_TRUE;
1423 }
1424
1425 char *start = strstr(content, CMM_MARKER_START);
1426 char *end = start ? strstr(start, CMM_MARKER_END) : NULL;
1427
1428 if (!start || !end) {
1429 free(content);
1430 return CLI_TRUE; /* not found */
1431 }
1432
1433 end += strlen(CMM_MARKER_END);
1434 if (*end == '\n') {
1435 end++;
1436 }
1437
1438 /* Also remove a leading newline before the start marker if present */
1439 if (start > content && *(start - CLI_SKIP_ONE) == '\n') {
1440 start--;
1441 }
1442
1443 size_t prefix_len = (size_t)(start - content);
1444 size_t suffix_len = strlen(end);
1445 size_t new_len = prefix_len + suffix_len;
1446 char *result = malloc(new_len + CLI_SKIP_ONE);
1447 if (!result) {
1448 free(content);
1449 return CLI_ERR;
1450 }
1451 memcpy(result, content, prefix_len);
1452 memcpy(result + prefix_len, end, suffix_len);
1453 result[new_len] = '\0';
1454
1455 int rc = write_file_str(path, result);
1456 free(content);
1457 free(result);
1458 return rc;
1459}
1460
1461/* ── Codex MCP config (TOML) ─────────────────────────────────── */
1462

Callers 4

uninstall_gemini_configFunction · 0.85
uninstall_cli_agentsFunction · 0.85
test_cli.cFile · 0.85

Calls 2

read_file_strFunction · 0.85
write_file_strFunction · 0.85

Tested by

no test coverage detected