Skip to content

Commit 1fb8125

Browse files
committed
Merge origin/main into fix/windows-unicode-agent-detection
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2 parents 5bb4ee2 + 83109dd commit 1fb8125

66 files changed

Lines changed: 3100 additions & 333 deletions

Some content is hidden

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

‎.github/workflows/pr-acknowledgement.yml‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,25 @@ jobs:
5151
run: |
5252
set -euo pipefail
5353
MESSAGE_FILE=.github/pr-acknowledgement.md
54+
BODY_FILE="$RUNNER_TEMP/pr-acknowledgement-body.md"
5455
5556
if [ ! -f "$MESSAGE_FILE" ]; then
5657
echo "No $MESSAGE_FILE in the base tree — acknowledgements are off."
5758
exit 0
5859
fi
5960
60-
# An empty or whitespace-only file is the documented off switch.
61-
if [ -z "$(tr -d '[:space:]' < "$MESSAGE_FILE")" ]; then
62-
echo "$MESSAGE_FILE is blank — acknowledgements are off."
61+
# HTML comments in the template are notes for maintainers. Posted
62+
# verbatim they become text a reader cannot see but a tool can, and
63+
# our own PR screening holds every comment that carries hidden text.
64+
# Strip them (an unterminated one runs to the end, as GitHub renders
65+
# it) so the posted body is exactly what the contributor sees.
66+
perl -0777 -pe 's/<!--.*?(?:-->|\z)[ \t]*\n?//gs' "$MESSAGE_FILE" > "$BODY_FILE"
67+
68+
# A body with no visible text is the documented off switch.
69+
if [ -z "$(tr -d '[:space:]' < "$BODY_FILE")" ]; then
70+
echo "$MESSAGE_FILE has no visible text — acknowledgements are off."
6371
exit 0
6472
fi
6573
66-
gh pr comment "$PR_NUMBER" --repo "$REPO" --body-file "$MESSAGE_FILE"
74+
gh pr comment "$PR_NUMBER" --repo "$REPO" --body-file "$BODY_FILE"
6775
echo "Acknowledged PR #${PR_NUMBER}."

‎Makefile.cbm‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,7 @@ LLVM_BIN := $(shell brew --prefix llvm 2>/dev/null)/bin
13861386
CLANG_TIDY ?= $(shell [ -x "$(LLVM_BIN)/clang-tidy" ] && echo "$(LLVM_BIN)/clang-tidy" || echo clang-tidy)
13871387
CLANG_FORMAT ?= $(shell [ -x "$(LLVM_BIN)/clang-format" ] && echo "$(LLVM_BIN)/clang-format" || echo clang-format)
13881388
CPPCHECK ?= cppcheck
1389+
CPPCHECK_JOBS ?= 2
13891390

13901391
# macOS SDK sysroot (needed for Homebrew LLVM to find system headers)
13911392
SYSROOT = $(shell xcrun --show-sdk-path 2>/dev/null)
@@ -1410,10 +1411,16 @@ lint-tidy:
14101411
lint-tidy-diff:
14111412
@scripts/lint-tidy-diff.sh "$(CLANG_TIDY)" $(LINT_SRCS) -- $(CFLAGS_COMMON) $(SYSROOT_FLAG)
14121413

1413-
# cppcheck: complementary analysis (config in .cppcheck)
1414+
# cppcheck: complementary analysis (config in .cppcheck). A build directory
1415+
# retains whole-program analysis with parallel workers; each run owns its state.
14141416
lint-cppcheck:
14151417
@echo "=== cppcheck ==="
1416-
@$(CPPCHECK) --enable=warning,style,performance,portability \
1418+
@set -e; \
1419+
cppcheck_dir=$$(mktemp -d "$${TMPDIR:-/tmp}/cbm-cppcheck.XXXXXX"); \
1420+
trap 'status=$$?; rm -rf "$$cppcheck_dir" || :; exit "$$status"' EXIT; \
1421+
trap 'exit 129' HUP; trap 'exit 130' INT; trap 'exit 143' TERM; \
1422+
$(CPPCHECK) -j$(CPPCHECK_JOBS) --cppcheck-build-dir="$$cppcheck_dir" \
1423+
--enable=warning,style,performance,portability \
14171424
--std=c11 --language=c \
14181425
--suppressions-list=.cppcheck \
14191426
--error-exitcode=1 \

‎README.md‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,14 +695,14 @@ overwrite user-modified agents.
695695
| Agent | Activation | MCP config | Durable context / augmentation |
696696
|-------|------------|------------|--------------------------------|
697697
| 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` |
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,11 @@ 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.
755759

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

‎install.ps1‎

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,28 @@ try {
277277

278278
# Validate the zip namespace before extraction. Windows paths are
279279
# case-insensitive, so two entries that differ only in case are ambiguous and
280-
# must never be allowed to overwrite each other. The official five entries are
280+
# must never be allowed to overwrite each other. The official four entries are
281281
# required at the archive root with their exact release names.
282+
#
283+
# Two failure classes are reported differently (both still exit 1; nothing is
284+
# relaxed). An unsafe entry path or a duplicate/case-conflicting entry is a
285+
# hostile archive shape. A well-formed archive whose root file SET differs from
286+
# $WindowsArchiveNames already passed checksum verification above, so it is
287+
# the published artifact for $BaseUrl -- the usual cause is this script being
288+
# newer or older than that release (e.g. install.ps1 run from main ahead of
289+
# the latest release, #1218). Calling that "unsafe" sends the user hunting for
290+
# tampering that is not there. Every entry is screened for the hostile class
291+
# BEFORE any layout verdict, so a bad path can never hide behind a layout
292+
# message just because an unexpected entry happened to come first.
293+
$LayoutMismatch = $false
282294
try {
283295
Add-Type -AssemblyName System.IO.Compression.FileSystem
284296
$zip = [System.IO.Compression.ZipFile]::OpenRead("$TmpDir\$Archive")
285297
try {
286298
$seen = New-Object 'System.Collections.Generic.HashSet[string]' ([System.StringComparer]::OrdinalIgnoreCase)
287299
$archiveCounts = @{}
288300
foreach ($archiveName in $WindowsArchiveNames) { $archiveCounts[$archiveName] = 0 }
301+
$layoutProblem = $null
289302
foreach ($entry in $zip.Entries) {
290303
$entryName = $entry.FullName.Replace('\', '/')
291304
$isDirectory = $entryName.EndsWith('/')
@@ -304,10 +317,16 @@ try {
304317
throw "duplicate or case-conflicting zip entry: $($entry.FullName)"
305318
}
306319
if (-not ($WindowsArchiveNames -ccontains $entryName) -or $isDirectory) {
307-
throw "archive contains an unexpected root entry: $($entry.FullName)"
320+
if ($null -eq $layoutProblem) {
321+
$layoutProblem = "archive contains an unexpected root entry: $($entry.FullName)"
322+
}
323+
continue
308324
}
309325
$archiveCounts[$entryName] = $archiveCounts[$entryName] + 1
310326
}
327+
# Every entry passed the hostile-shape checks; only now judge the layout.
328+
$LayoutMismatch = $true
329+
if ($null -ne $layoutProblem) { throw $layoutProblem }
311330
foreach ($archiveName in $WindowsArchiveNames) {
312331
if ($archiveCounts[$archiveName] -ne 1) {
313332
throw "archive must contain exactly one $archiveName"
@@ -316,11 +335,21 @@ try {
316335
if ($seen.Count -ne $WindowsArchiveNames.Count) {
317336
throw "archive does not match the exact Windows release allowlist"
318337
}
338+
$LayoutMismatch = $false
319339
} finally {
320340
$zip.Dispose()
321341
}
322342
} catch {
323-
Write-Host "error: unsafe or incomplete release archive: $_" -ForegroundColor Red
343+
if ($LayoutMismatch) {
344+
Write-Host "error: release archive layout does not match this installer: $_" -ForegroundColor Red
345+
Write-Host " The archive matched the checksum published with it at $BaseUrl, so it is"
346+
Write-Host " the genuine release artifact, built for a different installer version."
347+
Write-Host " This installer expects: $($WindowsArchiveNames -join ', ')"
348+
Write-Host " Fix: run the install.ps1 shipped inside that same release archive, or"
349+
Write-Host " re-run this script after the next release is published."
350+
} else {
351+
Write-Host "error: unsafe release archive: $_" -ForegroundColor Red
352+
}
324353
Remove-Item -Recurse -Force $TmpDir -ErrorAction SilentlyContinue
325354
exit 1
326355
}

‎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--) {

0 commit comments

Comments
 (0)