| 1586 | } |
| 1587 | |
| 1588 | static 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` |
no test coverage detected