Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
fix(discover): skip Laravel's compiled Blade view cache by default (#1735)
Martin Vogeld56e046ddd08
diff --git a/docs/cbmignore.md b/docs/cbmignore.mdindex d8ff0bfbc..ceb345852 100644--- a/docs/cbmignore.md+++ b/docs/cbmignore.md@@ -70,7 +70,12 @@ For directories:1. **Built-in skip list** — `.git`, `node_modules`, `dist`, `target`,`vendor`, tool caches, etc. (60+ names; the fast/moderate index modes add- more, e.g. `docs`, `examples`, `testdata`). A `.cbmignore` negation+ more, e.g. `docs`, `examples`, `testdata`). Generated output whose+ folder name alone is too common to skip everywhere is matched by path+ suffix instead: Laravel's compiled Blade view cache+ `storage/framework/views/` (at any depth) is skipped even without+ Laravel's stock `.gitignore` there, while other `views/` folders stay+ indexed. A `.cbmignore` negation(for example `!target/`) can un-skip these directories, except thenon-negatable safety core: `.git`, `node_modules`, `.worktrees`, and`.claude-worktrees`.diff --git a/src/discover/discover.c b/src/discover/discover.cindex fd4cea272..ebf9d3b53 100644--- a/src/discover/discover.c+++ b/src/discover/discover.c@@ -2,7 +2,8 @@* discover.c — Recursive directory walk with filtering.** Walks a repository directory tree, applying:- * 1. Hardcoded directory skip patterns (60+ dirs like .git, node_modules)+ * 1. Hardcoded directory skip patterns (60+ dirs like .git, node_modules,+ * plus path-suffix rules such as Laravel's storage/framework/views)* 2. Hardcoded suffix filters (.pyc, .png, .wasm, etc.)* 3. Fast-mode additional filters (docs, examples, lock files, etc.)* 4. Gitignore-style pattern matching@@ -52,6 +53,17 @@ static const char *ALWAYS_SKIP_DIRS[] = {/* Misc */".codebase-memory", ".qdrant_code_embeddings", ".tmp", "vendor", "vendored", NULL};+/* Always-skip directories matched by relative-PATH suffix, not by basename:+ * generated build output whose last path component alone ("views") is far too+ * common to skip everywhere. A rule matches the whole relative path or a+ * '/'-aligned tail of it, so "storage/framework/views" and+ * "backend/storage/framework/views" match while "app/views",+ * "mystorage/framework/views" and "storage/framework/views_old" do not. */+static const char *ALWAYS_SKIP_DIR_SUFFIXES[] = {+ /* Laravel's compiled Blade view cache (#1735): generated PHP with no source+ * value, skipped even when Laravel's stock .gitignore there is missing. */+ "storage/framework/views", NULL};+static const char *FAST_SKIP_DIRS[] = {"generated", "gen", "auto-generated", "fixtures", "testdata", "test_data","__tests__", "__mocks__", "__snapshots__", "__fixtures__", "__test__", "docs",@@ -336,6 +348,25 @@ static bool resolve_global_excludes_path(char *out, size_t out_sz) {return false;}+/* True when rel_path equals a suffix rule or ends with "/" + the rule. */+static bool rel_path_has_skip_suffix(const char *rel_path) {+ if (!rel_path) {+ return false;+ }+ size_t plen = strlen(rel_path);+ for (int i = 0; ALWAYS_SKIP_DIR_SUFFIXES[i]; i++) {+ const char *suffix = ALWAYS_SKIP_DIR_SUFFIXES[i];+ size_t slen = strlen(suffix);+ if (slen > plen || strcmp(rel_path + plen - slen, suffix) != 0) {+ continue;+ }+ if (slen == plen || rel_path[plen - slen - SKIP_ONE] == '/') {+ return true;+ }+ }+ return false;+}+/* ── Public filter functions ─────────────────────── */bool cbm_should_skip_dir(const char *dirname, cbm_index_mode_t mode) {@@ -702,7 +733,8 @@ static bool should_skip_directory(const char *entry_name, const char *rel_path,const gitignore_link_t *ignore_chain,const cbm_gitignore_t *global_gi,const cbm_gitignore_t *cbmignore) {- if (cbm_should_skip_dir(entry_name, opts ? opts->mode : CBM_MODE_FULL)) {+ if (cbm_should_skip_dir(entry_name, opts ? opts->mode : CBM_MODE_FULL) ||+ rel_path_has_skip_suffix(rel_path)) {/* #500: a .cbmignore negation (e.g. "!obj/") whose rule is the last* match for this dir un-skips a built-in skip-list dir — except the* non-negatable safety core. Fall through so .gitignore/global/localdiff --git a/tests/test_discover.c b/tests/test_discover.cindex 5e9bdd8af..1cc18fe74 100644--- a/tests/test_discover.c+++ b/tests/test_discover.c@@ -1258,6 +1258,82 @@ TEST(discover_cbmignore_negates_always_skip_dir) {PASS();}+/* ── Laravel compiled Blade view cache (issue #1735) ─────────────── */++/* storage/framework/views/ holds Laravel's compiled Blade templates: generated+ * PHP with no source value that the php_only grammar flags as parse damage.+ * It is skipped by default even when Laravel's stock .gitignore in that folder+ * is missing. The match is on the path suffix, component-aligned, so ordinary+ * views/ dirs (resources/views, app/views, app/framework/views) and look-alike+ * prefixes (mystorage/...) stay indexed. */+TEST(discover_skips_laravel_compiled_views_issue1735) {+ char *base = th_mktempdir("cbm_disc_laravel_views");+ ASSERT(base != NULL);++ /* No .gitignore anywhere: the skip must come from the built-in rule. */+ th_write_file(TH_PATH(base, "storage/framework/views/abc123.php"),+ "<?php $__env->startSection('title'); ?>\n"+ "<?php echo e($title); ?>\n"+ "<?php $__env->stopSection(); ?>\n");+ th_write_file(TH_PATH(base, "backend/storage/framework/views/def456.php"),+ "<?php echo e($x); ?>\n");+ th_write_file(TH_PATH(base, "resources/views/welcome.blade.php"), "<h1>{{ $title }}</h1>\n");+ th_write_file(TH_PATH(base, "app/views/x.php"), "<?php function x() { return 1; }\n");+ th_write_file(TH_PATH(base, "app/framework/views/y.php"), "<?php function y() {}\n");+ th_write_file(TH_PATH(base, "mystorage/framework/views/z.php"), "<?php function z() {}\n");+ th_write_file(TH_PATH(base, "storage/framework/views_old/w.php"), "<?php function w() {}\n");++ cbm_discover_opts_t opts = {0};+ cbm_file_info_t *files = NULL;+ int count = 0;+ char **excluded = NULL;+ int excluded_count = 0;++ int rc = cbm_discover_ex(base, &opts, &files, &count, &excluded, &excluded_count);+ ASSERT_EQ(rc, 0);+ ASSERT_FALSE(discover_has_rel_path(files, count, "storage/framework/views/abc123.php"));+ ASSERT_FALSE(discover_has_rel_path(files, count, "backend/storage/framework/views/def456.php"));+ ASSERT_TRUE(discover_has_rel_path(files, count, "resources/views/welcome.blade.php"));+ ASSERT_TRUE(discover_has_rel_path(files, count, "app/views/x.php"));+ ASSERT_TRUE(discover_has_rel_path(files, count, "app/framework/views/y.php"));+ ASSERT_TRUE(discover_has_rel_path(files, count, "mystorage/framework/views/z.php"));+ ASSERT_TRUE(discover_has_rel_path(files, count, "storage/framework/views_old/w.php"));+ ASSERT_EQ(count, 5);+ /* Reported as an excluded subtree (#411), like every built-in skip dir. */+ ASSERT_TRUE(discover_excluded_contains(excluded, excluded_count, "storage/framework/views"));+ ASSERT_TRUE(+ discover_excluded_contains(excluded, excluded_count, "backend/storage/framework/views"));+ ASSERT_FALSE(discover_excluded_contains(excluded, excluded_count, "app/views"));+ ASSERT_FALSE(discover_excluded_contains(excluded, excluded_count, "resources/views"));++ cbm_discover_free_excluded(excluded, excluded_count);+ cbm_discover_free(files, count);+ th_cleanup(base);+ PASS();+}++/* Like the other ordinary built-in skip dirs (#500), a .cbmignore negation+ * un-skips the compiled-view cache for a user who really wants it indexed. */+TEST(discover_cbmignore_negates_laravel_compiled_views_issue1735) {+ char *base = th_mktempdir("cbm_disc_laravel_views_neg");+ ASSERT(base != NULL);++ th_write_file(TH_PATH(base, ".cbmignore"), "!storage/framework/views/\n");+ th_write_file(TH_PATH(base, "storage/framework/views/abc123.php"), "<?php echo 1; ?>\n");++ cbm_discover_opts_t opts = {0};+ cbm_file_info_t *files = NULL;+ int count = 0;++ int rc = cbm_discover(base, &opts, &files, &count);+ ASSERT_EQ(rc, 0);+ ASSERT_TRUE(discover_has_rel_path(files, count, "storage/framework/views/abc123.php"));++ cbm_discover_free(files, count);+ th_cleanup(base);+ PASS();+}+/* An anchored negation ("!src/target/") un-skips only that nested dir; other* dirs with the same basename stay built-in-skipped. */TEST(discover_cbmignore_negates_only_nested_skip_dir) {@@ -2124,6 +2200,10 @@ SUITE(discover) {RUN_TEST(discover_cbmignore_negation_last_match_wins);RUN_TEST(discover_cbmignore_negation_cannot_unskip_safety_core);+ /* Laravel compiled Blade view cache (issue #1735) */+ RUN_TEST(discover_skips_laravel_compiled_views_issue1735);+ RUN_TEST(discover_cbmignore_negates_laravel_compiled_views_issue1735);+/* .git/info/exclude support (issue #489) */RUN_TEST(discover_git_info_exclude);RUN_TEST(discover_git_info_exclude_stacks_with_gitignore);