Skip to content

Commit 5985131

Browse files
committed
Merge origin/main into perf/py-cross-registry-index
Signed-off-by: Martin Vogel <[email protected]>
2 parents 2be8ee3 + dca2a44 commit 5985131

60 files changed

Lines changed: 5554 additions & 711 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -694,15 +694,15 @@ overwrite user-modified agents.
694694

695695
| Agent | Activation | MCP config | Durable context / augmentation |
696696
|-------|------------|------------|--------------------------------|
697-
| Claude Code | Detected | `~/.claude.json` | Skill + three exact-tool graph agents; `SessionStart`, `SubagentStart`, non-blocking `PreToolUse` for `Grep`/`Glob`/`Bash`, and post-`Read` coverage |
698-
| Codex CLI | Detected | `$CODEX_HOME/config.toml` | Managed `AGENTS.md` activation pointer, skill, three read-only agents; `SessionStart` + `SubagentStart` |
697+
| Claude Code | Detected | `~/.claude.json` | Skill + three exact-tool graph agents; `SessionStart`, `SubagentStart`, non-blocking `PreToolUse` for `Grep`/`Glob`/`Bash`, post-`Read` coverage, and a drift note after repeated searches without a graph call |
698+
| Codex CLI | Detected | `$CODEX_HOME/config.toml` | Managed `AGENTS.md` activation pointer, skill, three read-only agents; `SessionStart` + `SubagentStart`, `PreToolUse` graph lookup for `Bash` searches |
699699
| Gemini CLI | Detected | `.gemini/settings.json` | `GEMINI.md`, three explicit read/graph-tool subagents; `BeforeTool`, `AfterTool` `read_file` coverage, and `SessionStart` |
700700
| Zed | Detected | platform `settings.json` (JSONC) | `AGENTS.md` + shared skill |
701701
| OpenCode | Detected | `$OPENCODE_CONFIG` or resolved global config | `AGENTS.md`, skill, three deny-by-default read-only agents; plugin adds grep/glob graph lookup, post-`read` coverage, first-tool-result session context, and post-compaction reinjection |
702702
| Antigravity | Detected | `.gemini/config/mcp_config.json` | `.gemini/GEMINI.md` |
703703
| Aider | Detected | none | `CONVENTIONS.md` via `.aider.conf.yml` |
704704
| KiloCode | Detected | `.config/kilo/kilo.jsonc` | Rule + three graph-tool subagents with deny-by-default permissions |
705-
| VS Code | Detected | platform `Code/User/mcp.json` | `~/.copilot/skills`, three read-only agents, `sessionStart` + `subagentStart` |
705+
| VS Code | Detected | platform `Code/User/mcp.json` | `~/.copilot/skills`, three read-only agents, `sessionStart` + `subagentStart`, post-search `PostToolUse` graph lookup |
706706
| Cursor | Detected | `.cursor/mcp.json` | Skill + three read-only parent-handoff agents; context hooks withheld because session injection races and `readonly` blocks MCP |
707707
| Windsurf | Detected | `~/.codeium/windsurf/mcp_config.json` | Always-on `global_rules.md` |
708708
| Augment / Auggie | Detected | `~/.augment/settings.json` | Rule, three read-only handoff subagents, `SessionStart` + post-`view` coverage |
@@ -714,7 +714,7 @@ overwrite user-modified agents.
714714
| Cline | Detected | `~/.cline/mcp.json` + `${CLINE_DATA_DIR:-~/.cline/data}/settings/cline_mcp_settings.json` | Rule + skill; automatic file hooks withheld because they auto-activate and their output is not reliably consumed; child agents cannot use MCP |
715715
| Warp | Detected, skill only | UI, Warp Drive, or per invocation (manual) | Shared `~/.agents/skills/codebase-memory/SKILL.md` |
716716
| Qwen Code | Detected | `.qwen/settings.json` | `QWEN.md`, skill, three explicit read/graph-tool agents; `SessionStart`, `SubagentStart`, and post-`ReadFile` coverage |
717-
| GitHub Copilot CLI | Detected | `$COPILOT_HOME/mcp-config.json` | Instructions, skill, three read-only agents; `sessionStart` + `subagentStart` |
717+
| GitHub Copilot CLI | Detected | `$COPILOT_HOME/mcp-config.json` | Instructions, skill, three read-only agents; `sessionStart` + `subagentStart`, post-search `PostToolUse` graph lookup |
718718
| Factory Droid | Detected | `.factory/mcp.json` | `AGENTS.md`, skill, three droids with exact per-tier graph-tool lists (without additive whole-server exposure); `SessionStart` + post-`Read` coverage on macOS/Linux, withheld on Windows |
719719
| Crush | Detected | `.config/crush/crush.json` | Managed context path with explicit parent-to-child handoff |
720720
| Goose | Detected | `.config/goose/config.yaml` | `.goosehints` |
@@ -751,7 +751,14 @@ Hooks installed by this project are fail-open and context-only. Claude Code's
751751
`PreToolUse` observes `Grep`/`Glob`/`Bash` and injects matching graph symbols as
752752
`additionalContext`; `PostToolUse` on `Read` adds targeted coverage context when
753753
the graph could not fully parse or index that file. It never denies or replaces
754-
the requested tool call.
754+
the requested tool call. Codex CLI's `PreToolUse` on `Bash` gives its shell
755+
searches the same context. GitHub Copilot CLI and VS Code's Copilot runtime get
756+
it after the search: their `preToolUse` can only decide permissions, so a
757+
`PostToolUse` entry for `Bash`, `Grep` and `Glob` appends the graph symbols to
758+
the tool result. In Claude Code, once a session has run three searches with no
759+
codebase-memory-mcp tool call, the next augmentation adds one line saying so;
760+
the next note comes after six searches, then twelve. Claude's `PostToolUse`
761+
entry also matches the graph tools, and a graph tool call resets the count.
755762

756763
Claude Code, Codex CLI, Qwen Code, GitHub Copilot CLI, and VS Code's Copilot
757764
runtime receive paired session/subagent context where the vendor exposes a

‎internal/cbm/extract_channels.c‎

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,42 @@ static void elixir_emit_second_arg(CBMExtractCtx *ctx, TSNode call, TSNode args,
901901
}
902902
}
903903

904-
static void elixir_process_call(CBMExtractCtx *ctx, TSNode call) {
904+
/* tree-sitter-elixir gives a call's arguments node NO field name — its whole
905+
* field set is key, left, operand, operator, quoted_start, quoted_end, right,
906+
* target and value — so the generic field lookup is always null here and every
907+
* channel below was silently skipped. extract_defs.c has carried the same
908+
* positional fallback for the definition side since Elixir was added. */
909+
static TSNode elixir_channel_call_args(TSNode call) {
910+
TSNode args = ts_node_child_by_field_name(call, TS_FIELD("arguments"));
911+
if (ts_node_is_null(args) && ts_node_child_count(call) > 1) {
912+
args = ts_node_child(call, 1);
913+
}
914+
return args;
915+
}
916+
917+
/* The callee of an Elixir `call`. The grammar labels it `target`; child(0) is
918+
* the same node and is what extract_defs.c reads, so accept either. */
919+
static TSNode elixir_channel_call_target(TSNode call) {
905920
TSNode target = ts_node_child_by_field_name(call, TS_FIELD("target"));
921+
if (ts_node_is_null(target) && ts_node_child_count(call) > 0) {
922+
target = ts_node_child(call, 0);
923+
}
924+
return target;
925+
}
926+
927+
/* Elixir def* macros. `def`/`defp` cover Phoenix channel callbacks; the macro
928+
* forms are included because `handle_in` is generated by macros in some
929+
* libraries. */
930+
static bool elixir_channel_is_def_macro(const char *macro) {
931+
if (!macro) {
932+
return false;
933+
}
934+
return strcmp(macro, "def") == 0 || strcmp(macro, "defp") == 0 ||
935+
strcmp(macro, "defmacro") == 0 || strcmp(macro, "defmacrop") == 0;
936+
}
937+
938+
static void elixir_process_call(CBMExtractCtx *ctx, TSNode call) {
939+
TSNode target = elixir_channel_call_target(call);
906940
if (ts_node_is_null(target)) {
907941
return;
908942
}
@@ -911,7 +945,7 @@ static void elixir_process_call(CBMExtractCtx *ctx, TSNode call) {
911945
return;
912946
}
913947

914-
TSNode args = ts_node_child_by_field_name(call, TS_FIELD("arguments"));
948+
TSNode args = elixir_channel_call_args(call);
915949

916950
if (strstr(target_text, "PubSub.broadcast") || strstr(target_text, "PubSub.local_broadcast")) {
917951
elixir_emit_second_arg(ctx, call, args, "phoenix_pubsub", CBM_CHANNEL_EMIT);
@@ -927,18 +961,39 @@ static void elixir_process_call(CBMExtractCtx *ctx, TSNode call) {
927961
}
928962
}
929963

930-
/* Detect handle_in("event", payload, socket) — Phoenix Channel listener */
931-
static void elixir_process_function_def(CBMExtractCtx *ctx, TSNode func_def) {
932-
TSNode name_node = ts_node_child_by_field_name(func_def, TS_FIELD("name"));
933-
if (ts_node_is_null(name_node)) {
964+
/* Detect handle_in("event", payload, socket) — Phoenix Channel listener.
965+
* `def_call` is the `call` node of a def* macro. Elixir has no `def` node type
966+
* and no `name`/`parameters` fields: a definition is a call whose first
967+
* argument is the head, itself a call of name(params) — wrapped in a `when`
968+
* binary_operator when the clause carries a guard. */
969+
static void elixir_process_function_def(CBMExtractCtx *ctx, TSNode def_call) {
970+
TSNode args = elixir_channel_call_args(def_call);
971+
if (ts_node_is_null(args) || ts_node_named_child_count(args) == 0) {
972+
return;
973+
}
974+
TSNode head = ts_node_named_child(args, 0);
975+
if (strcmp(ts_node_type(head), "binary_operator") == 0) {
976+
TSNode op = ts_node_child_by_field_name(head, TS_FIELD("operator"));
977+
TSNode left = ts_node_child_by_field_name(head, TS_FIELD("left"));
978+
if (!ts_node_is_null(op) && !ts_node_is_null(left) &&
979+
ts_node_end_byte(op) - ts_node_start_byte(op) == 4 &&
980+
strncmp(ctx->source + ts_node_start_byte(op), "when", 4) == 0) {
981+
head = left;
982+
}
983+
}
984+
if (strcmp(ts_node_type(head), "call") != 0 || ts_node_child_count(head) == 0) {
985+
return;
986+
}
987+
TSNode name_node = ts_node_child(head, 0);
988+
if (ts_node_is_null(name_node) || strcmp(ts_node_type(name_node), "identifier") != 0) {
934989
return;
935990
}
936991
char *name = cbm_node_text(ctx->arena, name_node, ctx->source);
937992
if (!name || strcmp(name, "handle_in") != 0) {
938993
return;
939994
}
940995
/* First parameter is the event name pattern */
941-
TSNode params = ts_node_child_by_field_name(func_def, TS_FIELD("parameters"));
996+
TSNode params = elixir_channel_call_args(head);
942997
if (ts_node_is_null(params)) {
943998
return;
944999
}
@@ -952,7 +1007,7 @@ static void elixir_process_function_def(CBMExtractCtx *ctx, TSNode func_def) {
9521007
val = literal_from_first_child(ctx, first_param);
9531008
}
9541009
if (val) {
955-
push_channel(ctx, val, "phoenix_channel", CBM_CHANNEL_LISTEN, func_def);
1010+
push_channel(ctx, val, "phoenix_channel", CBM_CHANNEL_LISTEN, def_call);
9561011
}
9571012
}
9581013

@@ -964,10 +1019,18 @@ static void extract_channels_elixir(CBMExtractCtx *ctx) {
9641019
while (stack.count > 0) {
9651020
TSNode node = ts_nstack_pop(&stack);
9661021
const char *kind = ts_node_type(node);
1022+
/* Everything in Elixir is a `call`, including `def`. The old dispatch
1023+
* tested for a "def" node type the grammar does not have, so the
1024+
* handle_in listener branch was unreachable. */
9671025
if (strcmp(kind, "call") == 0) {
968-
elixir_process_call(ctx, node);
969-
} else if (strcmp(kind, "def") == 0) {
970-
elixir_process_function_def(ctx, node);
1026+
TSNode target = elixir_channel_call_target(node);
1027+
char *macro =
1028+
ts_node_is_null(target) ? NULL : cbm_node_text(ctx->arena, target, ctx->source);
1029+
if (elixir_channel_is_def_macro(macro)) {
1030+
elixir_process_function_def(ctx, node);
1031+
} else {
1032+
elixir_process_call(ctx, node);
1033+
}
9711034
}
9721035
uint32_t count = ts_node_child_count(node);
9731036
for (int i = (int)count - SKIP_ONE; i >= 0; i--) {

‎internal/cbm/extract_unified.c‎

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,27 +1663,39 @@ typedef struct {
16631663
TSNode node;
16641664
const char *prefix;
16651665
} yaml_walk_frame_t;
1666-
#define YAML_WALK_STACK_CAP CBM_SZ_256
1667-
1668-
/* Push block_mapping children of a block_node/block_mapping value onto the walk stack. */
1669-
static void push_yaml_block_children(TSNode val, const char *path, yaml_walk_frame_t *stack,
1670-
int *top) {
1666+
/* On-stack first chunk of the key-path walk; wider mappings spill to the heap
1667+
* through cbm_walk_stack_reserve instead of dropping frames (#2388). */
1668+
#define YAML_WALK_STACK_INLINE CBM_SZ_256
1669+
1670+
/* Push block_mapping children of a block_node/block_mapping value onto the walk
1671+
* stack, growing it as needed. False when the stack could not grow (logged by
1672+
* cbm_walk_stack_reserve as extract.walk_stack_alloc_failed). */
1673+
static bool push_yaml_block_children(TSNode val, const char *path, yaml_walk_frame_t **stack,
1674+
int *cap, int *top, const yaml_walk_frame_t *inline_buf) {
16711675
uint32_t vnc = ts_node_named_child_count(val);
1672-
for (int vi = (int)vnc - SKIP_ONE; vi >= 0 && *top < YAML_WALK_STACK_CAP; vi--) {
1676+
if (!cbm_walk_stack_reserve((void **)stack, cap, *top + (int)vnc, sizeof(yaml_walk_frame_t),
1677+
inline_buf, "yaml_key_paths")) {
1678+
return false;
1679+
}
1680+
for (int vi = (int)vnc - SKIP_ONE; vi >= 0; vi--) {
16731681
TSNode vc = ts_node_named_child(val, (uint32_t)vi);
16741682
const char *vctype = ts_node_type(vc);
16751683
if (strcmp(vctype, "block_mapping") == 0 || strcmp(vctype, "block_mapping_pair") == 0) {
1676-
stack[(*top)++] = (yaml_walk_frame_t){vc, path};
1684+
(*stack)[(*top)++] = (yaml_walk_frame_t){vc, path};
16771685
}
16781686
}
1687+
return true;
16791688
}
16801689

16811690
static void walk_yaml_mapping(CBMExtractCtx *ctx, TSNode root, const char *root_prefix) {
1682-
yaml_walk_frame_t stack[YAML_WALK_STACK_CAP];
1691+
yaml_walk_frame_t inline_stack[YAML_WALK_STACK_INLINE];
1692+
yaml_walk_frame_t *stack = inline_stack;
1693+
int cap = YAML_WALK_STACK_INLINE;
16831694
int top = 0;
16841695
stack[top++] = (yaml_walk_frame_t){root, root_prefix};
1696+
bool grown = true;
16851697

1686-
while (top > 0) {
1698+
while (grown && top > 0) {
16871699
yaml_walk_frame_t frame = stack[--top];
16881700
TSNode node = frame.node;
16891701
const char *prefix = frame.prefix;
@@ -1709,12 +1721,16 @@ static void walk_yaml_mapping(CBMExtractCtx *ctx, TSNode root, const char *root_
17091721
}
17101722
const char *vk = ts_node_type(val);
17111723
if (strcmp(vk, "block_node") == 0 || strcmp(vk, "block_mapping") == 0) {
1712-
push_yaml_block_children(val, path, stack, &top);
1724+
grown = push_yaml_block_children(val, path, &stack, &cap, &top, inline_stack);
1725+
if (!grown) {
1726+
break;
1727+
}
17131728
continue;
17141729
}
17151730
emit_yaml_leaf_value(ctx, val, path);
17161731
}
17171732
}
1733+
cbm_walk_stack_release(stack, inline_stack);
17181734
}
17191735

17201736
/* ── Infrastructure binding extraction ─────────────────────────────
@@ -1873,9 +1889,13 @@ static void scan_mapping_for_bindings(CBMExtractCtx *ctx, TSNode mapping) {
18731889
emit_infra_bindings(ctx, sources, source_keys, n_sources, targets, n_targets);
18741890
}
18751891

1876-
#define INFRA_SCAN_STACK_CAP CBM_SZ_512
1892+
/* On-stack first chunk of the binding scan; wider subtrees spill to the heap
1893+
* through cbm_walk_stack_reserve instead of dropping nodes (#2388). */
1894+
#define INFRA_SCAN_STACK_INLINE CBM_SZ_512
18771895
static void scan_yaml_for_infra_bindings(CBMExtractCtx *ctx, TSNode root) {
1878-
TSNode stack[INFRA_SCAN_STACK_CAP];
1896+
TSNode inline_stack[INFRA_SCAN_STACK_INLINE];
1897+
TSNode *stack = inline_stack;
1898+
int cap = INFRA_SCAN_STACK_INLINE;
18791899
int top = 0;
18801900
stack[top++] = root;
18811901
while (top > 0) {
@@ -1884,10 +1904,15 @@ static void scan_yaml_for_infra_bindings(CBMExtractCtx *ctx, TSNode root) {
18841904
scan_mapping_for_bindings(ctx, node);
18851905
}
18861906
uint32_t nc = ts_node_named_child_count(node);
1887-
for (int i = (int)nc - SKIP_ONE; i >= 0 && top < INFRA_SCAN_STACK_CAP; i--) {
1907+
if (!cbm_walk_stack_reserve((void **)&stack, &cap, top + (int)nc, sizeof(TSNode),
1908+
inline_stack, "yaml_infra_bindings")) {
1909+
break;
1910+
}
1911+
for (int i = (int)nc - SKIP_ONE; i >= 0; i--) {
18881912
stack[top++] = ts_node_named_child(node, (uint32_t)i);
18891913
}
18901914
}
1915+
cbm_walk_stack_release(stack, inline_stack);
18911916
}
18921917

18931918
/* ── HCL infrastructure binding extraction ───────────────────────────

‎internal/cbm/extract_url_fold.c‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,22 @@ static bool is_interpolated_string(TSNode node) {
401401
return false;
402402
}
403403

404+
/* A Python string whose opening token is more than one quote -- a prefix
405+
* (r"", b"", u"", an f"" with no field) or a triple quote -- cannot go down
406+
* the literal path: that strips exactly one quote from each end, so the
407+
* prefix and the extra quotes stayed in the URL and it never matched a route
408+
* (#523). Folding reads the content pieces instead. JS/TS strings have no
409+
* string_start, so this is Python only. */
410+
static bool is_wrapped_string(TSNode node) {
411+
TSNode start = ts_node_child(node, 0);
412+
return !ts_node_is_null(start) && strcmp(ts_node_type(start), "string_start") == 0 &&
413+
ts_node_end_byte(start) - ts_node_start_byte(start) > SKIP_ONE;
414+
}
415+
404416
static bool is_foldable_arg(TSNode arg) {
405417
const char *k = ts_node_type(arg);
406418
if (strcmp(k, "string") == 0) {
407-
return is_interpolated_string(arg);
419+
return is_interpolated_string(arg) || is_wrapped_string(arg);
408420
}
409421
return strcmp(k, "template_string") == 0 || strcmp(k, "binary_expression") == 0 ||
410422
strcmp(k, "binary_operator") == 0 || strcmp(k, "identifier") == 0 ||

0 commit comments

Comments
 (0)