| 1943 | } |
| 1944 | |
| 1945 | static 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` |
no test coverage detected