The in-process updater refuses a tar.gz that inflates past 500 MiB, but no
test reached that refusal, and the limit had no seam. A test-only setter,
in the block that already holds the extractor under
CBM_CLI_ENABLE_TEST_API, lowers the limit, so
cli_update_refuses_an_archive_over_the_decompression_limit sees a 1 MiB
archive refused over a 64 KiB limit and accepted under the real one. With
the check removed the test fails on its refusal assertion.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Conflicts resolved:
- src/daemon/runtime.h: both sides add test seams at the end of the
CBM_ENABLE_TEST_SEAMS block. Kept main's connection-cap and HELLO-order
seams and placed this branch's fingerprint-cache seams after them; the
branch's added lines are unchanged.
- src/cli/hook_augment.c: kept main's re-arm guard, which opens the
timeouts log only once and keeps that descriptor. Dropped main's early
return and breadcrumb formatting after the open: this branch formats
the breadcrumb before the log path is resolved, so stderr gets it even
when the log cannot be opened. That formatting runs on every arm, so
main's re-arm comment now says the text above is refreshed, and the
#858 header comment now says the breadcrumb also goes to stderr.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
install --no-hooks and the persisted install_hooks=false preference
removed the Augment SessionStart and PostToolUse view registrations from
~/.augment/settings.json but left the two scripts they pointed at,
~/.augment/hooks/codebase-memory-session.sh and
codebase-memory-coverage.sh (.ps1 on Windows), on disk.
The opt-out now deletes them the way uninstall does. Both paths share
remove_augment_owned_hook_scripts(): each script is rebuilt from the
binary path the install embedded and removed with
cbm_text_remove_owned_document() only on a byte-for-byte match, so a
script the user edited, or a foreign file with the same name, is kept.
Uninstall keeps its error operation names; the opt-out records
session_script_disable and coverage_script_disable. install --hooks
writes both scripts again.
Test: cli_no_hooks_removes_augment_owned_scripts drives the install
command with fake activation ops in a temporary HOME: default install,
--no-hooks (both scripts gone, MCP entry kept), a bare install with the
stored preference (still gone), --hooks (restored), and a user-edited
session script that --no-hooks keeps while it deletes the untouched
coverage script. The test ends on --hooks because the opt-out is process
state that later tests rely on.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Removing the only Hermes pre_llm_call hook empties the hooks mapping, and
the mapping editor writes an emptied section as hooks: {} - the same
convention it uses for mcp_servers: {}. The hook sequence editor then
refused that file for both upsert and removal, because it required every
parent on the sequence path to be a block mapping header. On a config
where our hook was the only entry under hooks, install -> uninstall ->
install exited 1, and a repeated uninstall did too.
An exact empty flow mapping on a parent of the sequence path is now read
as that empty mapping, mirroring how the mapping-entry editor already
treats section: {}. Removal is a byte-identical no-op, and upsert expands
the header in place, keeping its comment, the line endings and every
other byte, so a reinstall lands back on the first install byte for
byte. The sequence key itself holding a mapping, any other flow value,
and content nested under the inline mapping stay refused. Hooks written
by the user and every foreign key are left untouched.
Found while finishing #1862: its persisted hook opt-out runs this remover
on every later install, so every Hermes user whose only hook was ours
would have hit the refusal on each install after the first.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
#2719 added a PreToolUse Bash hook for Codex after this opt-out was
written. In config.toml it lives inside the managed block, which the
opt-out already removes. In hooks.json it is a separate entry beside the
lifecycle pair, and the opt-out removed only the pair, so after
install --no-hooks, and on every later bare install or update that
respects the stored preference, our PreToolUse hook stayed registered.
The --no-hooks branch now also calls cbm_remove_codex_pretool_hooks_json,
the exact-command remover that uninstall uses since #2719. A PreToolUse
hook the user owns is left alone.
Test: cli_no_hooks_removes_codex_pretool_hook drives the real install
dispatch through both hook representations. A default install writes ours
beside a foreign hook; --no-hooks and a bare install with the stored
preference remove ours and keep the foreign hook and the MCP entry; and
--hooks restores ours. Without the fix it fails: ours is still in
hooks.json after --no-hooks.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Since #1180 a bare ~/.claude directory no longer counts as a Claude Code
install. The fixture of cli_no_hooks_plan_covers_every_hook_installer_family
now also writes .claude/settings.json. Without it claude-code drops out of
agents_detected and the test fails on the tree merged with current main.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Brings the branch up to main a5b248f47. Eight files conflicted, each a
same-spot insertion where main and this branch added lines next to the
same anchor. Each resolves to the main version plus the change of this
branch:
- src/cli/cli.h, src/cli/cli.c: CBM_CONFIG_IGNORE_WORKTREES and its
CONFIG_KEYS row next to the new doc_candidates key.
- src/mcp/mcp.c: the index_worktree schema property next to the new
doc_candidates property.
- README.md, docs/CONFIGURATION.md: the ignore_worktrees line and table
row next to the rewritten auto_watch entries and the new
doc_candidates and watch_non_git rows.
- src/git/git_context.c: the env-isolation comment after the new debug
stage marker, directly above cbm_popen_git.
- src/cli/hook_augment.c: the new SubagentStart cli_hint ahead of the
parent-graph check of this branch.
- tests/test_mcp.c: both RUN_TEST blocks; main already includes
str_util.h.
Per file, the lines changed against main equal the changes of this
branch against the merge-base.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
The lifecycle hook now reads ignore_worktrees first and does nothing
else for it while the key is off; the project lookup is then the one
the hook did before the key existed.
- cbm_mcp_ignore_worktrees_runtime_enabled() replaces
cbm_mcp_server_attach_runtime_config(). It never attaches a store to
the server, which may be the daemon session server. A server with a
store answers from it. Otherwise the runtime store is opened only to
read this key, and only when it already exists, so a hook event never
creates _config.db.
- cwd canonicalization, the linked-worktree probe and the parent-graph
check moved into ha_resolve_project_ignoring_worktrees(), which runs
only when the key is on.
Test cli_hook_ignore_worktrees_default_off_does_no_worktree_work was red
on the previous head (a default-off event created _config.db). It also
pins, through a test-API counter, that neither an absent store nor a
store without the key reaches the worktree gate, and that the key on
reaches it once. mcp_ignore_worktrees_runtime_read_leaves_server_and_store_alone
replaces the test of the removed helper.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Maintainer refresh of #1862 (persistent install-hook opt-out, direction
decided in #753) onto main a5b248f4. The first refresh is 2577a86a and
carries the semantic fixes for shell-free Claude hooks.
Textual conflicts, all resolved by keeping both sides:
- src/cli/cli.h: main added CBM_CONFIG_DOC_CANDIDATES on the line where
the PR added CBM_CONFIG_INSTALL_HOOKS. Both defines are kept, in
alphabetical order.
- src/cli/cli.c CONFIG_KEYS[]: main added the watch_non_git row where the
PR added install_hooks. Main row stays first, followed by the
install_hooks row.
- src/cli/cli.c Codex hook install: main (#2719) declared pretool_written
in front of the hooks.json branch the PR prefixed with its --no-hooks
removal branch. The declaration stays first, then the PR removal
branch, then main hooks.json and config.toml upsert branches unchanged.
Check: for every file the PR touches, the added and removed lines of the
merged tree against main equal those of the PR against its old base.
No compile-level semantic conflict: no function the PR calls changed its
signature, and the PR re-signs no function main calls. The new Codex
PreToolUse hook from #2719 is gated by the opt-out in the next commit.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Follow POSIX symlinks in dir_exists() on top of cbm_path_info_utf8() only when
the invoking user owns both the symlink and the target directory it resolves
to. Leave cbm_agent_registry_path_exists() unchanged, guard the POSIX symlink
tests with #ifndef _WIN32, and isolate XDG_CONFIG_HOME for Linux runs.
Refs #2671
The SubagentStart hook matches every agent type, but agents defined with an
explicit tool list (e.g. tools: Read, Grep, Glob, Bash) have no MCP tools, and
SubagentStart input carries no tool list to detect that. Append one sentence to
the SubagentStart context only (indexed and unindexed variants) pointing such
agents at `codebase-memory-mcp cli <tool> --help`. Longest variant is ~1.1 KB,
well inside the 2 KB context buffer.
Closes#2837
Signed-off-by: Shane McCarron <shane.mccarron@corvexconnect.com>
Agent detection used POSIX lstat in dir_exists and rejected symlinks
in cbm_agent_registry_path_exists, causing dotfiles setups with
symlinked configuration directories (e.g. ~/Library/Application Support/Zed
or ~/.cursor) to be reported as undetected and skipped during install.
Use stat so valid directory symlinks are followed and detected while
preserving dangling symlink rejection.
Signed-off-by: Divakant Pandey <divakant01@gmail.com>
Bring the branch up to date with main (83109dde) so CI checks the
agentty integration against the current tree. No conflicts.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
The search hook gives each Grep, Glob or Bash search the matching graph
symbols, but a session can keep searching text for questions the graph answers
in one call (#509). Once a session has run three searches with no
codebase-memory-mcp tool call, the next augmentation now adds one factual line
saying so. The next note comes after six searches, then twelve, and any graph
tool call resets the count.
- State: a per-session counter in the process that runs hook requests (the
daemon), keyed by the payload's session_id, in a bounded 64-slot table that
evicts the least recently used session, behind a spin lock. Only searches
that reach the graph lookup count. A search without an augmentation still
counts, and the note waits for the next augmentation.
- Reset: Claude's managed PostToolUse entry now matches
"Read|mcp__.*codebase-memory-mcp__.*", covering plain and plugin server
names. The previous Read-only entry, as installs up to v0.12 wrote it, is
recognized as owned, so install replaces it in place and uninstall removes
either.
- Scope: Claude Code only. Codex sends the same event payload with a turn_id
but has no reset hook, so its sessions are not tracked, and payloads without
a session_id are not tracked either.
- Cost: a graph tool call now runs one hook round-trip to the daemon for the
reset, about 130 ms on a local build.
Refs #509
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
The byte check in cli_extension_leaves_user_owned_module_untouched_issue2204
ran only after a dry run and the plan receipt, and neither of them writes,
so it could not catch the #2204 append. The test now also runs a real
install over the user-owned module, then checks that the file is
byte-identical and that the run reports it as left untouched. Each phase's
stdout checks are bounded to that phase's slice of the capture, so no phase
can pass on another's line.
With the early return that ends the user-owned branch of
install_generated_client_extension() dropped, the test now fails; before
this change it still passed.
Refs #2204
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Brings the opt-in index exit contract up to date with main 0433142a.
The merge is clean; no file this branch changes needed a resolution.
The previous base (fceb25d8) predates the shared CI baseline (72c36044),
whose language-count contract repair is why every test leg failed at
Step 0w on the last run. That failure was in the base, not in this
branch.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>