Problem
When a new release adds include/exclude patterns to DEFAULT_CONFIG (e.g. new file extensions or framework-specific paths), existing projects are not affected. The .codegraph/config.json was written at init time and is never updated — so new patterns are silently ignored until the user manually reinitialises.
This was discovered while working on Drupal support (#268). The new release added:
- Include patterns:
**/*.module, **/*.install, **/*.theme, **/*.inc, **/*.routing.yml, **/*.twig
- Exclude patterns:
**/web/core/**, **/web/modules/contrib/**, **/web/themes/contrib/**
After upgrading and reindexing, the file/node/edge counts were identical to before — because the existing config.json had none of the new patterns. The only workaround today is to delete config.json and run codegraph init -i again, which is non-obvious and undocumented.
Note: the database schema already has a proper migration system (migrations.ts) that auto-applies changes on next run. The config file has no equivalent.
Proposed Solution
Add a config migration mechanism similar to the existing DB migrations:
- Bump
config.version when DEFAULT_CONFIG patterns change.
- On
init / serve startup, compare the stored version against the current DEFAULT_CONFIG version.
- When the stored version is older, merge in any new include/exclude patterns from the default (without overriding user customisations).
- Persist the updated config and bump the version.
Alternatively, a simpler short-term fix would be a codegraph config reset command that regenerates config.json from defaults while preserving user-added custom patterns.
Related
Problem
When a new release adds include/exclude patterns to
DEFAULT_CONFIG(e.g. new file extensions or framework-specific paths), existing projects are not affected. The.codegraph/config.jsonwas written atinittime and is never updated — so new patterns are silently ignored until the user manually reinitialises.This was discovered while working on Drupal support (#268). The new release added:
**/*.module,**/*.install,**/*.theme,**/*.inc,**/*.routing.yml,**/*.twig**/web/core/**,**/web/modules/contrib/**,**/web/themes/contrib/**After upgrading and reindexing, the file/node/edge counts were identical to before — because the existing
config.jsonhad none of the new patterns. The only workaround today is to deleteconfig.jsonand runcodegraph init -iagain, which is non-obvious and undocumented.Note: the database schema already has a proper migration system (
migrations.ts) that auto-applies changes on next run. The config file has no equivalent.Proposed Solution
Add a config migration mechanism similar to the existing DB migrations:
config.versionwhenDEFAULT_CONFIGpatterns change.init/servestartup, compare the storedversionagainst the currentDEFAULT_CONFIGversion.Alternatively, a simpler short-term fix would be a
codegraph config resetcommand that regeneratesconfig.jsonfrom defaults while preserving user-added custom patterns.Related