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

Function main_hook_cwd

src/main.c:1945–1965  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1943}
1944
1945static char *main_hook_cwd(const char *input_json) {
1946 if (!input_json) {
1947 return NULL;
1948 }
1949 yyjson_doc *document = yyjson_read(input_json, strlen(input_json), 0);
1950 yyjson_val *root = document ? yyjson_doc_get_root(document) : NULL;
1951 yyjson_val *cwd_value = yyjson_is_obj(root) ? yyjson_obj_get(root, "cwd") : NULL;
1952 const char *cwd = yyjson_is_str(cwd_value) ? yyjson_get_str(cwd_value) : NULL;
1953 char *copy = NULL;
1954 if (cwd && cbm_hook_path_is_abs(cwd)) {
1955 size_t length = strlen(cwd);
1956 copy = malloc(length + 1U);
1957 if (copy) {
1958 memcpy(copy, cwd, length + 1U);
1959 }
1960 }
1961 if (document) {
1962 yyjson_doc_free(document);
1963 }
1964 return copy;
1965}
1966
1967/* Hooks never spawn a daemon (a cold spawn livelocks against the fail-open
1968 * 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