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

Function main_hook_cwd

src/main.c:1588–1608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1586}
1587
1588static char *main_hook_cwd(const char *input_json) {
1589 if (!input_json) {
1590 return NULL;
1591 }
1592 yyjson_doc *document = yyjson_read(input_json, strlen(input_json), 0);
1593 yyjson_val *root = document ? yyjson_doc_get_root(document) : NULL;
1594 yyjson_val *cwd_value = yyjson_is_obj(root) ? yyjson_obj_get(root, "cwd") : NULL;
1595 const char *cwd = yyjson_is_str(cwd_value) ? yyjson_get_str(cwd_value) : NULL;
1596 char *copy = NULL;
1597 if (cwd && cbm_hook_path_is_abs(cwd)) {
1598 size_t length = strlen(cwd);
1599 copy = malloc(length + 1U);
1600 if (copy) {
1601 memcpy(copy, cwd, length + 1U);
1602 }
1603 }
1604 if (document) {
1605 yyjson_doc_free(document);
1606 }
1607 return copy;
1608}
1609
1610/* Hooks never spawn a daemon (a cold spawn livelocks against the fail-open
1611 * budget), so augmentation is absent until an MCP session or `daemon start`

Callers 1

main_run_hook_frontendFunction · 0.85

Calls 1

cbm_hook_path_is_absFunction · 0.85

Tested by

no test coverage detected