Skip to content

Refactor cache configuration from cacheScripts to flexible cache option#191

Merged
branchseer merged 3 commits intomainfrom
claude/refactor-cache-config-WadB1
Mar 4, 2026
Merged

Refactor cache configuration from cacheScripts to flexible cache option#191
branchseer merged 3 commits intomainfrom
claude/refactor-cache-config-WadB1

Conversation

@branchseer
Copy link
Copy Markdown
Member

Summary

This PR replaces the simple boolean cacheScripts configuration option with a more flexible cache configuration that supports both boolean and detailed object formats, enabling independent control over caching for package.json scripts and task entries.

Key Changes

  • New UserGlobalCacheConfig enum: Replaces cache_scripts: bool with a flexible configuration that accepts:

    • true / false (boolean shorthand)
    • { scripts?: bool, tasks?: bool } (detailed configuration)
  • New ResolvedGlobalCacheConfig struct: Provides a resolution mechanism with sensible defaults:

    • scripts: defaults to false
    • tasks: defaults to true
  • Configuration field rename: UserRunConfig.cache_scriptsUserRunConfig.cache

  • Error message update: TaskGraphLoadError::CacheScriptsInNonRootPackageTaskGraphLoadError::CacheInNonRootPackage

  • TypeScript types: Generated UserGlobalCacheConfig type in run-config.ts with comprehensive documentation

  • Test fixtures: Added two new test fixtures demonstrating the new configuration:

    • cache-true-no-force-enable: Shows how cache: true with individual task cache: false overrides work
    • cache-tasks-disabled: Shows how cache: { tasks: false } disables all task caching while respecting individual task settings
  • Test coverage: Added comprehensive unit tests for all configuration variants (boolean true/false, detailed with various field combinations, defaults, and error cases)

  • Migration: Updated all existing test fixtures from cacheScripts to cache format

Implementation Details

The resolution logic ensures backward compatibility while providing more granular control:

  • When cache is omitted, defaults to { scripts: false, tasks: true }
  • Boolean true expands to { scripts: true, tasks: true }
  • Boolean false expands to { scripts: false, tasks: false }
  • Detailed objects use provided values with appropriate defaults for missing fields

https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah

claude added 3 commits March 4, 2026 09:13
…ks}` in root config

Replace the root-level `cacheScripts: boolean` field with a richer `cache`
field that supports both boolean shorthand and detailed object form:

- `cache: true` = `{ scripts: true, tasks: true }`
- `cache: false` = `{ scripts: false, tasks: false }`
- Default (omitted) = `{ scripts: false, tasks: true }`
- `cache.scripts` controls caching for package.json scripts (same as old `cacheScripts`)
- `cache.tasks` is a global kill switch: when false, disables cache on ALL tasks
  even those with explicit `cache: true`; when true (default), respects each
  task's own `cache` setting without force-enabling tasks with `cache: false`

https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah
@branchseer branchseer merged commit 9ce14cf into main Mar 4, 2026
10 of 12 checks passed
@branchseer branchseer deleted the claude/refactor-cache-config-WadB1 branch March 4, 2026 15:09
branchseer pushed a commit that referenced this pull request Mar 4, 2026
The cache configuration refactor in #191 added UserGlobalCacheConfig
but didn't regenerate run-config.ts, causing the typescript_generation
test to fail in CI.

https://claude.ai/code/session_014eMPQ1Mw6EQpPkjkk1onsQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants