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

Function main_run_hook_frontend

src/main.c:2034–2060  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2032}
2033
2034static int main_run_hook_frontend(cbm_daemon_runtime_client_t *client, const char *hook_event,
2035 const char *hook_dialect) {
2036 char *input = cbm_hook_augment_read_stdin();
2037 if (!input) {
2038 return 0;
2039 }
2040 char *hook_cwd = main_hook_cwd(input);
2041 bool context_set =
2042 main_set_client_context(client, hook_cwd, CBM_MCP_TOOL_PROFILE_ALL, hook_event,
2043 hook_dialect, MAIN_HOOK_CONNECT_TIMEOUT_MS);
2044 free(hook_cwd);
2045 if (!context_set) {
2046 free(input);
2047 return 0;
2048 }
2049 uint8_t *response = NULL;
2050 uint32_t response_length = 0;
2051 cbm_daemon_runtime_application_status_t status = cbm_daemon_application_client_hook_augment(
2052 client, input, &response, &response_length, MAIN_HOOK_REQUEST_TIMEOUT_MS);
2053 free(input);
2054 if (status == CBM_DAEMON_RUNTIME_APPLICATION_OK && response && response_length > 0) {
2055 (void)fwrite(response, 1, response_length, stdout);
2056 (void)fflush(stdout);
2057 }
2058 free(response);
2059 return 0; /* hooks always fail open */
2060}
2061
2062static bool main_hook_options(int argc, char **argv, const char **event_out,
2063 const char **dialect_out) {

Callers 1

mainFunction · 0.85

Calls 5

main_hook_cwdFunction · 0.85
main_set_client_contextFunction · 0.85
fwriteFunction · 0.85

Tested by

no test coverage detected