Detect the running binary's path at runtime. Falls back to ~/.local/bin/. */
| 3642 | |
| 3643 | /* Detect the running binary's path at runtime. Falls back to ~/.local/bin/. */ |
| 3644 | static void cbm_detect_self_path(char *buf, size_t buf_sz, const char *home) { |
| 3645 | buf[0] = '\0'; |
| 3646 | #ifdef _WIN32 |
| 3647 | GetModuleFileNameA(NULL, buf, (DWORD)buf_sz); |
| 3648 | cbm_normalize_path_sep(buf); |
| 3649 | #elif defined(__APPLE__) |
| 3650 | uint32_t sp_sz = (uint32_t)buf_sz; |
| 3651 | if (_NSGetExecutablePath(buf, &sp_sz) != 0) { |
| 3652 | buf[0] = '\0'; |
| 3653 | } |
| 3654 | #else |
| 3655 | ssize_t sp_len = readlink("/proc/self/exe", buf, buf_sz - SKIP_ONE); |
| 3656 | if (sp_len > 0) { |
| 3657 | buf[sp_len] = '\0'; |
| 3658 | } |
| 3659 | #endif |
| 3660 | if (!buf[0]) { |
| 3661 | #ifdef _WIN32 |
| 3662 | snprintf(buf, buf_sz, "%s/.local/bin/codebase-memory-mcp.exe", home); |
| 3663 | #else |
| 3664 | snprintf(buf, buf_sz, "%s/.local/bin/codebase-memory-mcp", home); |
| 3665 | #endif |
| 3666 | } |
| 3667 | } |
| 3668 | |
| 3669 | /* Build the agent.install.plan.v1 receipt (#388): a machine-readable list of |
| 3670 | * the config / instruction / hook files `install` WOULD write, produced by |
no test coverage detected