git: 18010f19cfe4 - main - devel/codebase-memory-mcp: update to 0.10.4
Olivier Cochard <[email protected]>
| Newsgroups | gmane.os.freebsd.devel.cvs.ports |
|---|---|
| Message-ID | <6a84918d.367c8.4f88851f__8971.0599788063$1787072923$gmane$org@gitrepo.freebsd.org> |
The branch main has been updated by olivier: URL: https://cgit.FreeBSD.org/ports/commit/?id=18010f19cfe415ea55e6035700711749c36992ab commit 18010f19cfe415ea55e6035700711749c36992ab Author: Olivier Cochard <[email protected]> AuthorDate: 2026-08-16 16:45:23 +0000 Commit: Olivier Cochard <[email protected]> CommitDate: 2026-08-18 17:06:05 +0000 devel/codebase-memory-mcp: update to 0.10.4 --- devel/codebase-memory-mcp/Makefile | 4 +- devel/codebase-memory-mcp/distinfo | 6 +- .../codebase-memory-mcp/files/patch-src_cli_cli.c | 125 ++++++++------------- .../files/patch-src_daemon_ipc.c | 32 ++++++ .../files/patch-src_daemon_runtime.c | 105 +++++++++++++++++ .../files/patch-src_foundation_system__info.c | 11 -- devel/codebase-memory-mcp/files/patch-src_main.c | 27 ----- .../codebase-memory-mcp/files/patch-src_mcp_mcp.c | 28 ----- 8 files changed, 189 insertions(+), 149 deletions(-) diff --git a/devel/codebase-memory-mcp/Makefile b/devel/codebase-memory-mcp/Makefile index 394b5d3c0e06..6b08e8fda795 100644 --- a/devel/codebase-memory-mcp/Makefile +++ b/devel/codebase-memory-mcp/Makefile @@ -1,6 +1,6 @@ PORTNAME= codebase-memory-mcp DISTVERSIONPREFIX=v -DISTVERSION= 0.9.0 +DISTVERSION= 0.10.4 CATEGORIES= devel MAINTAINER= [email protected] @@ -33,7 +33,7 @@ do-build: ${SETENV} ${MAKE_ENV} \ ${GMAKE} -f Makefile.cbm cbm \ CC="${CC}" CXX="${CXX}" \ - CFLAGS_EXTRA='-DCBM_VERSION=\"${DISTVERSION}\" -DCBM_PACKAGE_MANAGED' + CFLAGS_EXTRA='-DCBM_VERSION=\"${DISTVERSION}\" -DCBM_PKG_PREFIX=\"${PREFIX}\"' do-install: ${INSTALL_PROGRAM} ${WRKSRC}/build/c/codebase-memory-mcp \ diff --git a/devel/codebase-memory-mcp/distinfo b/devel/codebase-memory-mcp/distinfo index f235792c710b..b89283927027 100644 --- a/devel/codebase-memory-mcp/distinfo +++ b/devel/codebase-memory-mcp/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1785259953 -SHA256 (DeusData-codebase-memory-mcp-v0.9.0_GH0.tar.gz) = 05fd0963b4c7c7ecccfa12f50a4a33130ad90019a62c0fc13808a524a8f86abe -SIZE (DeusData-codebase-memory-mcp-v0.9.0_GH0.tar.gz) = 92924651 +TIMESTAMP = 1786775637 +SHA256 (DeusData-codebase-memory-mcp-v0.10.4_GH0.tar.gz) = 5afecf36ebac04dd1d19cda1721621984e7b950b2a72b5223351acd3995eb568 +SIZE (DeusData-codebase-memory-mcp-v0.10.4_GH0.tar.gz) = 94804727 diff --git a/devel/codebase-memory-mcp/files/patch-src_cli_cli.c b/devel/codebase-memory-mcp/files/patch-src_cli_cli.c index 0cae2b429983..ff2e1ad198b7 100644 --- a/devel/codebase-memory-mcp/files/patch-src_cli_cli.c +++ b/devel/codebase-memory-mcp/files/patch-src_cli_cli.c @@ -1,87 +1,56 @@ ---- src/cli/cli.c.orig 2026-07-29 06:28:47 UTC +--- src/cli/cli.c.orig 2026-08-14 04:11:37 UTC +++ src/cli/cli.c -@@ -74,6 +74,10 @@ enum { - #ifdef __APPLE__ - #include <mach-o/dyld.h> - #endif -+#ifdef __FreeBSD__ -+#include <sys/sysctl.h> // KERN_PROC_PATHNAME — /proc-free self-path detection -+#include <sys/types.h> -+#endif - #include "foundation/compat_fs.h" +@@ -7963,7 +7963,12 @@ static void cbm_agent_installed_binary_path(const char - #ifndef CBM_VERSION -@@ -3651,6 +3655,14 @@ static void cbm_detect_self_path(char *buf, size_t buf - if (_NSGetExecutablePath(buf, &sp_sz) != 0) { - buf[0] = '\0'; - } -+#elif defined(__FreeBSD__) -+ /* FreeBSD has no /proc by default; sysctl KERN_PROC_PATHNAME returns the -+ * running executable's path without it. */ -+ int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; -+ size_t sp_sz = buf_sz; -+ if (sysctl(mib, 4, buf, &sp_sz, NULL, 0) != 0) { -+ buf[0] = '\0'; -+ } + static void cbm_agent_installed_binary_path(const char *home, char *binary_path, + size_t binary_path_size) { +-#ifdef _WIN32 ++#if defined(__FreeBSD__) && defined(CBM_PKG_PREFIX) ++ /* The port/pkg install the binary under ${PREFIX}/bin, not ~/.local/bin, so ++ * agent configs (mcp.json, hooks) must point there. */ ++ (void)home; ++ snprintf(binary_path, binary_path_size, CBM_PKG_PREFIX "/bin/codebase-memory-mcp"); ++#elif defined(_WIN32) + snprintf(binary_path, binary_path_size, "%s/.local/bin/codebase-memory-mcp.exe", home); #else - ssize_t sp_len = readlink("/proc/self/exe", buf, buf_sz - SKIP_ONE); - if (sp_len > 0) { -@@ -3821,6 +3833,18 @@ int cbm_cmd_install(int argc, char **argv) { - snprintf(bin_target, sizeof(bin_target), "%s/.local/bin/codebase-memory-mcp", home); - #endif - -+ /* A package manager (FreeBSD ports, Homebrew, distro pkg) already placed the -+ * binary on PATH under its own prefix and owns that file. Install must not -+ * copy it into ~/.local/bin (a duplicate, unmanaged binary in $HOME), and -+ * agent configs must reference the real binary the manager installed, not -+ * the ~/.local/bin path. Point bin_target at the running executable. */ -+#ifdef CBM_PACKAGE_MANAGED -+ if (self_path[0]) { -+ snprintf(bin_target, sizeof(bin_target), "%s", self_path); + snprintf(binary_path, binary_path_size, "%s/.local/bin/codebase-memory-mcp", home); +@@ -9472,6 +9477,16 @@ static const char *cli_external_manager_name(const cha + if (strstr(self_path, "/.cargo/bin/")) { + return "cargo"; + } ++#if defined(__FreeBSD__) && defined(CBM_PKG_PREFIX) ++ /* FreeBSD ports/pkg install the binary under ${PREFIX}/bin (CBM_PKG_PREFIX ++ * is the port's PREFIX, default /usr/local). pkg owns that file, so install ++ * must not copy it into ~/.local/bin or edit PATH, and update must refuse ++ * and defer to pkg(8). Match only ${PREFIX}/bin/ so a manual --dir install ++ * elsewhere is still treated as ours. */ ++ if (strstr(self_path, CBM_PKG_PREFIX "/bin/") == self_path) { ++ return "FreeBSD pkg"; + } +#endif -+ -+#ifndef CBM_PACKAGE_MANAGED - if (!cbm_same_file(self_path, bin_target)) { - struct stat tgt_st; - bool target_exists = (stat(bin_target, &tgt_st) == 0); -@@ -3849,6 +3873,7 @@ int cbm_cmd_install(int argc, char **argv) { - } - } - } -+#endif /* !CBM_PACKAGE_MANAGED */ - - /* Step 1d: macOS ad-hoc signing of the installed binary. A freshly - * clang-built arm64 binary is linker-signed (flags=0x20002) and gets -@@ -3869,10 +3894,14 @@ int cbm_cmd_install(int argc, char **argv) { - /* Step 3: Install/refresh all agent configs, pointing at the install target. */ - cbm_install_agent_configs(home, bin_target, force, dry_run); + return NULL; + } -- /* Step 4: Ensure PATH */ -+ /* Step 4: Ensure PATH. Skipped under CBM_PACKAGE_MANAGED: the package -+ * manager owns PATH via its prefix, so install must not append -+ * `export PATH=...` to the user's shell rc. */ -+ const char *rc = ""; -+#ifndef CBM_PACKAGE_MANAGED - char bin_dir[CLI_BUF_1K]; - snprintf(bin_dir, sizeof(bin_dir), "%s/.local/bin", home); -- const char *rc = cbm_detect_shell_rc(home); -+ rc = cbm_detect_shell_rc(home); - if (rc[0]) { - int path_rc = cbm_ensure_path(bin_dir, rc, dry_run); - if (path_rc == 0) { -@@ -3881,9 +3910,12 @@ int cbm_cmd_install(int argc, char **argv) { - printf("\nPATH already includes %s\n", bin_dir); +@@ -9890,6 +9905,13 @@ int cbm_cmd_install(int argc, char **argv) { + manager ? " by " : "", manager ? manager : "", self_path, bin_dir); } + skip_binary = true; ++ /* We are not placing a binary, so agent configs must reference the one ++ * that is actually running, not the ~/.local/bin default that no file ++ * lives at (#pkg: FreeBSD ports install under /usr/local/bin). Retarget ++ * to the OS-reported self path when we have it. */ ++ if (self_path_exact && self_path[0]) { ++ snprintf(bin_target, sizeof(bin_target), "%s", self_path); ++ } } -+#endif -- printf("\nInstall complete. Restart your shell or run:\n"); -- printf(" source %s\n", rc); -+ printf("\nInstall complete.\n"); -+ if (rc[0]) { -+ printf("Restart your shell or run:\n source %s\n", rc); -+ } - if (dry_run) { - printf("\n(dry-run — no files were modified)\n"); - } + /* NOT stat(): on Windows it goes through the ANSI code page, so an +@@ -11939,6 +11961,8 @@ int cbm_cmd_update(int argc, char **argv) { + (void)fprintf(stderr, " update it with: mise upgrade codebase-memory-mcp\n"); + } else if (manager && strcmp(manager, "Homebrew") == 0) { + (void)fprintf(stderr, " update it with: brew upgrade codebase-memory-mcp\n"); ++ } else if (manager && strcmp(manager, "FreeBSD pkg") == 0) { ++ (void)fprintf(stderr, " update it with: pkg upgrade codebase-memory-mcp\n"); + } else { + (void)fprintf(stderr, " update it through whichever tool installed it.\n"); + } diff --git a/devel/codebase-memory-mcp/files/patch-src_daemon_ipc.c b/devel/codebase-memory-mcp/files/patch-src_daemon_ipc.c new file mode 100644 index 000000000000..c9e1d32101f4 --- /dev/null +++ b/devel/codebase-memory-mcp/files/patch-src_daemon_ipc.c @@ -0,0 +1,32 @@ +--- src/daemon/ipc.c.orig 2026-08-15 21:31:53 UTC ++++ src/daemon/ipc.c +@@ -313,6 +313,9 @@ int cbm_daemon_ipc_wait_pending(const cbm_ipc_pending_ + #include <sys/stat.h> + #include <sys/types.h> + #include <sys/un.h> ++#if defined(__FreeBSD__) ++#include <sys/ucred.h> // struct xucred (LOCAL_PEERCRED peer pid) ++#endif + #include <time.h> + #include <unistd.h> + +@@ -3060,6 +3063,19 @@ uint64_t cbm_daemon_ipc_connection_peer_pid(const cbm_ + return 0; + } + return (uint64_t)peer_pid; ++#elif defined(__FreeBSD__) && defined(LOCAL_PEERCRED) ++ /* FreeBSD has neither SO_PEERCRED nor LOCAL_PEERPID; LOCAL_PEERCRED returns ++ * a struct xucred whose cr_pid (FreeBSD 13+) is the connecting peer's pid. ++ * cr_pid is only meaningful when the version matches and the socket is a ++ * connected stream, both true for our accepted control connection. */ ++ struct xucred credentials; ++ socklen_t length = sizeof(credentials); ++ if (getsockopt(connection->fd, SOL_LOCAL, LOCAL_PEERCRED, &credentials, &length) != 0 || ++ length != sizeof(credentials) || credentials.cr_version != XUCRED_VERSION || ++ credentials.cr_uid != geteuid() || credentials.cr_pid <= 0) { ++ return 0; ++ } ++ return (uint64_t)credentials.cr_pid; + #else + return 0; + #endif diff --git a/devel/codebase-memory-mcp/files/patch-src_daemon_runtime.c b/devel/codebase-memory-mcp/files/patch-src_daemon_runtime.c new file mode 100644 index 000000000000..052f38074c2d --- /dev/null +++ b/devel/codebase-memory-mcp/files/patch-src_daemon_runtime.c @@ -0,0 +1,105 @@ +--- src/daemon/runtime.c.orig 2026-08-15 16:26:11 UTC ++++ src/daemon/runtime.c +@@ -54,6 +54,12 @@ void cbm_daemon_runtime_force_peer_image_mismatch_for_ + #include <fcntl.h> + #include <sys/stat.h> + #include <unistd.h> ++#elif defined(__FreeBSD__) ++#include <fcntl.h> ++#include <sys/stat.h> ++#include <sys/sysctl.h> ++#include <sys/types.h> ++#include <unistd.h> + #endif + + enum { +@@ -155,7 +161,7 @@ typedef struct { + HANDLE file; + BY_HANDLE_FILE_INFORMATION information; + LARGE_INTEGER size; +-#elif defined(__APPLE__) || defined(__linux__) ++#elif defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) + int fd; + struct stat status; + #endif +@@ -510,7 +516,7 @@ static uint64_t runtime_current_process_id(void) { + static uint64_t runtime_current_process_id(void) { + #ifdef _WIN32 + return (uint64_t)GetCurrentProcessId(); +-#elif defined(__APPLE__) || defined(__linux__) ++#elif defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) + return (uint64_t)getpid(); + #else + return 0; +@@ -524,7 +530,7 @@ static void runtime_process_image_reference_init(runti + memset(reference, 0, sizeof(*reference)); + #ifdef _WIN32 + reference->file = INVALID_HANDLE_VALUE; +-#elif defined(__APPLE__) || defined(__linux__) ++#elif defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) + reference->fd = -1; + #endif + } +@@ -538,7 +544,7 @@ static bool runtime_process_image_reference_release(ru + if (reference->file != INVALID_HANDLE_VALUE && !CloseHandle(reference->file)) { + ok = false; + } +-#elif defined(__APPLE__) || defined(__linux__) ++#elif defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) + if (reference->fd >= 0 && close(reference->fd) != 0) { + ok = false; + } +@@ -678,7 +684,7 @@ static bool runtime_mac_process_maps_file_executable(i + return false; + } + +-#elif defined(__linux__) ++#elif defined(__linux__) || defined(__FreeBSD__) + + static bool runtime_linux_stat_same_image(const struct stat *first, const struct stat *second) { + return first && second && S_ISREG(first->st_mode) && S_ISREG(second->st_mode) && +@@ -814,6 +820,35 @@ static bool runtime_process_image_reference_acquire( + } else if (image_fd >= 0) { + (void)close(image_fd); + } ++#elif defined(__FreeBSD__) ++ /* FreeBSD mounts no /proc by default, so /proc/<pid>/exe is unavailable. ++ * sysctl KERN_PROC_PATHNAME resolves any pid's executable path directly. ++ * Open that path and hold it as the image reference, mirroring the Linux ++ * branch's stat-bracketing to detect a swap under us. */ ++ if (process_id > INT_MAX) { ++ return false; ++ } ++ int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, (int)process_id}; ++ char image_path[PATH_MAX]; ++ size_t image_path_size = sizeof(image_path); ++ bool path_ok = sysctl(mib, 4, image_path, &image_path_size, NULL, 0) == 0 && ++ image_path_size > 1 && image_path_size <= sizeof(image_path); ++ int image_fd = path_ok ? open(image_path, O_RDONLY | O_CLOEXEC | O_NOFOLLOW | O_NONBLOCK) : -1; ++ struct stat image_before; ++ struct stat image_after; ++ bool ok = image_fd >= 0 && fstat(image_fd, &image_before) == 0 && ++ S_ISREG(image_before.st_mode) && ++ (!fingerprint || ++ cbm_daemon_build_fingerprint_native_file((uintptr_t)image_fd, fingerprint)) && ++ fstat(image_fd, &image_after) == 0 && ++ runtime_linux_stat_same_image(&image_before, &image_after); ++ if (ok) { ++ reference->held = true; ++ reference->fd = image_fd; ++ reference->status = image_after; ++ } else if (image_fd >= 0) { ++ (void)close(image_fd); ++ } + #else + (void)process_id; + bool ok = false; +@@ -854,7 +889,7 @@ static bool runtime_process_image_reference_matches_pr + runtime_mac_stat_same(&active->status, &peer.status); + bool released = runtime_process_image_reference_release(&peer); + return same && released; +-#elif defined(__linux__) ++#elif defined(__linux__) || defined(__FreeBSD__) + runtime_process_image_reference_t peer; + runtime_process_image_reference_init(&peer); + bool same = runtime_process_image_reference_acquire(process_id, &peer, NULL); diff --git a/devel/codebase-memory-mcp/files/patch-src_foundation_system__info.c b/devel/codebase-memory-mcp/files/patch-src_foundation_system__info.c deleted file mode 100644 index e402abbc576a..000000000000 --- a/devel/codebase-memory-mcp/files/patch-src_foundation_system__info.c +++ /dev/null @@ -1,11 +0,0 @@ ---- src/foundation/system_info.c.orig 2026-06-17 01:27:28 UTC -+++ src/foundation/system_info.c -@@ -95,7 +95,7 @@ static cbm_system_info_t detect_system_bsd(void) { - info.total_cores = nprocs > 0 ? (int)nprocs : 1; - info.perf_cores = info.total_cores; - --#if defined(__OpenBSD__) -+#if defined(__OpenBSD__) || defined(__FreeBSD__) - int mib[2] = {CTL_HW, HW_PHYSMEM}; - #else - int mib[2] = {CTL_HW, HW_PHYSMEM64}; diff --git a/devel/codebase-memory-mcp/files/patch-src_main.c b/devel/codebase-memory-mcp/files/patch-src_main.c deleted file mode 100644 index 6873624ffc3d..000000000000 --- a/devel/codebase-memory-mcp/files/patch-src_main.c +++ /dev/null @@ -1,27 +0,0 @@ ---- src/main.c.orig 2026-06-17 17:18:37 UTC -+++ src/main.c -@@ -286,7 +286,9 @@ static void print_help(void) { - printf(" codebase-memory-mcp cli <tool> [json] Run a single tool\n"); - printf(" codebase-memory-mcp install [-y|-n] [--force] [--dry-run]\n"); - printf(" codebase-memory-mcp uninstall [-y|-n] [--dry-run]\n"); -+#ifndef CBM_PACKAGE_MANAGED - printf(" codebase-memory-mcp update [-y|-n]\n"); -+#endif - printf(" codebase-memory-mcp config <list|get|set|reset>\n"); - printf(" codebase-memory-mcp --version Print version\n"); - printf(" codebase-memory-mcp --help Print this help\n"); -@@ -338,7 +340,14 @@ static int handle_subcommand(int argc, char **argv) { - return cbm_cmd_uninstall(argc - i - SKIP_ONE, argv + i + SKIP_ONE); - } - if (strcmp(argv[i], "update") == 0) { -+#ifdef CBM_PACKAGE_MANAGED -+ (void)fprintf(stderr, -+ "codebase-memory-mcp: 'update' is disabled in this build; " -+ "use the system package manager (e.g. pkg(8)) to upgrade.\n"); -+ return 1; -+#else - return cbm_cmd_update(argc - i - SKIP_ONE, argv + i + SKIP_ONE); -+#endif - } - if (strcmp(argv[i], "config") == 0) { - return cbm_cmd_config(argc - i - SKIP_ONE, argv + i + SKIP_ONE); diff --git a/devel/codebase-memory-mcp/files/patch-src_mcp_mcp.c b/devel/codebase-memory-mcp/files/patch-src_mcp_mcp.c deleted file mode 100644 index 93052a169d1e..000000000000 --- a/devel/codebase-memory-mcp/files/patch-src_mcp_mcp.c +++ /dev/null @@ -1,28 +0,0 @@ ---- src/mcp/mcp.c.orig 2026-06-12 05:05:55 UTC -+++ src/mcp/mcp.c -@@ -4360,6 +4360,7 @@ static void maybe_auto_index(cbm_mcp_server_t *srv) { - - /* ── Background update check ──────────────────────────────────── */ - -+#ifndef CBM_PACKAGE_MANAGED - #define UPDATE_CHECK_URL "https://api.github.com/repos/DeusData/codebase-memory-mcp/releases/latest" - - static void *update_check_thread(void *arg) { -@@ -4423,6 +4424,7 @@ static void start_update_check(cbm_mcp_server_t *srv) - srv->update_thread_active = true; - } - } -+#endif /* !CBM_PACKAGE_MANAGED */ - - /* Prepend update notice to a tool result, then clear it (one-shot). */ - static char *inject_update_notice(cbm_mcp_server_t *srv, char *result_json) { -@@ -4493,7 +4495,9 @@ char *cbm_mcp_server_handle(cbm_mcp_server_t *srv, con - - if (strcmp(req.method, "initialize") == 0) { - result_json = cbm_mcp_initialize_response(req.params_raw); -+#ifndef CBM_PACKAGE_MANAGED - start_update_check(srv); -+#endif - detect_session(srv); - maybe_auto_index(srv); - } else if (strcmp(req.method, "ping") == 0) {