Skip to content

feat(tasks): add extend mode for task includes#9038

Closed
risu729 wants to merge 6 commits intojdx:mainfrom
risu729:task-includes-mode-extend
Closed

feat(tasks): add extend mode for task includes#9038
risu729 wants to merge 6 commits intojdx:mainfrom
risu729:task-includes-mode-extend

Conversation

@risu729
Copy link
Copy Markdown
Contributor

@risu729 risu729 commented Apr 10, 2026

Summary

Follow-up to #8740 and #8905.

Rebased on main after #9039. This branch builds on #9039's fixed MISE_ENV task-config precedence when resolving stacked task_config.includes_mode = "extend" inheritance.

This adds an explicit opt-in mode for users who want the additive task include behavior from #8740 without changing the existing default replacement semantics that were discussed in review.

  • add task_config.includes_mode = "extend"
  • keep current task_config.includes replacement behavior when includes_mode is unset
  • merge default task include directories and inherited config-scope task_config.includes entries recursively when extend mode is enabled
  • apply the same include collection path to git includes so git URLs are additive in extend mode too
  • add task_config.includes_mode to the JSON schema
  • document the new option and keep the file-task default directory order aligned with default_task_includes()

Verification

  • mise run render:schema
  • cargo fmt --check
  • git diff --check
  • mise run test:e2e e2e/tasks/test_task_includes_env_precedence e2e/tasks/test_task_includes_mode_extend
  • previously: e2e/run_test tasks/test_task_remote_git_includes

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new configuration option, task_config.includes_mode, which allows users to choose between replacing or extending the default task include directories. The implementation includes updates to the configuration structures, logic for merging include paths, and corresponding documentation and E2E tests. Review feedback identifies a logic flaw in how the extension mode is applied across the configuration stack, which could prevent high-priority local configurations from overriding parent settings. There is also a suggestion to address logic duplication and potential inconsistencies between the different task loading mechanisms.

Comment thread src/config/mod.rs Outdated
Comment thread src/config/mod.rs
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 10, 2026

Greptile Summary

This PR adds an opt-in task_config.includes_mode = \"extend\" setting that makes a config file's task_config.includes additive rather than replacing the inherited includes. The implementation uses a recursive replacement_task_include_specs_for_dir function to walk the config precedence chain and accumulate includes from all configs that opt into extend mode, falling back to default_task_includes() when no more parents exist. The refactor also extracts configs_for_filename_at_root (now reversing glob results so that lexicographically later conf.d files have higher precedence) and adds a new task_git_includes_for_dir helper so git-URL entries follow the same stacking semantics as local paths.

Confidence Score: 5/5

Safe to merge — the recursive extend logic is correct and terminates, all prior review concerns are addressed, and the implementation is well-tested.

No P0 or P1 findings. The recursion in replacement_task_include_specs_for_dir terminates because each call adds exactly one config to exclude_paths against a finite set. The serde representation matches the JSON schema. The glob-reversal change for conf.d precedence is validated by the new unit test. Both code paths (project configs via task_include_specs_for_dir and global configs via load_file_tasks) handle extend mode consistently. The previously flagged issues (all-or-nothing merging, undocumented additive alias) are resolved.

No files require special attention.

Important Files Changed

Filename Overview
src/config/mod.rs Core logic for extend-mode task includes: introduces recursive replacement_task_include_specs_for_dir, task_git_includes_for_dir, and configs_for_filename_at_root (with glob reversal for conf.d precedence); terminates correctly since each recursion adds one config to exclude_paths against a finite list.
src/config/config_file/mod.rs Adds TaskIncludesMode enum (Replace default, Extend) with #[serde(rename_all = "lowercase")] and adds includes_mode field to TaskConfig; serde aliases removed from prior draft.
src/config/config_file/mise_toml.rs Debug output now also shows task_config when includes_mode is non-default or dir is set, not only when includes is Some.
e2e/tasks/test_task_includes_mode_extend New e2e test covering extend mode scenarios including cascading extends and MISE_ENV interaction; the last block's assertions depend on precedence behavior from #9039.
e2e/tasks/test_task_remote_git_includes Adds a test block verifying that git-URL includes are additive in extend mode alongside local-path includes.
schema/mise.json Adds includes_mode with enum ["replace", "extend"] to the JSON schema, matching the serde representation.
docs/tasks/task-configuration.md Documents includes_mode = "extend" with a correct example and accurate description of inheritance and fallback-to-defaults behaviour.
docs/tasks/file-tasks.md Reorders default task directory list to match default_task_includes() function order (.mise/tasks before mise/tasks).

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[task_includes_for_dir] --> B[task_include_specs_for_dir]
    B --> C[configs_at_root]
    B --> D[replacement_task_include_specs_for_dir]
    D --> E{selected_task_include_config}
    E -- "None (no config with includes)" --> F[default_task_include_specs_for_dir]
    E -- "cf with includes_mode=Replace" --> G[task_include_specs_for_config cf]
    E -- "cf with includes_mode=Extend" --> H[exclude cf, recurse]
    H --> D
    H --> I[prepend inherited specs]
    I --> J[append task_include_specs_for_config cf]
    K[load_tasks_in_dir] --> A
    K --> L[task_git_includes_for_dir]
    L --> B
    M[load_file_tasks - global only] --> N{includes + mode?}
    N -- "Some + Extend" --> O[default_task_includes + config includes]
    N -- "Some + Replace" --> P[config includes only]
    N -- "None" --> Q[default_task_includes]
Loading

Reviews (11): Last reviewed commit: "Merge branch 'main' into task-includes-m..." | Re-trigger Greptile

Comment thread src/config/mod.rs Outdated
Comment thread src/config/config_file/mod.rs
Comment thread e2e/tasks/test_task_includes_mode_extend
@risu729 risu729 marked this pull request as draft April 10, 2026 21:47
@risu729 risu729 force-pushed the task-includes-mode-extend branch from 75d27f5 to 4aeca61 Compare April 10, 2026 21:50

This comment was marked as outdated.

@risu729 risu729 force-pushed the task-includes-mode-extend branch from 4aeca61 to 2807066 Compare April 10, 2026 22:14

This comment was marked as outdated.

@risu729 risu729 force-pushed the task-includes-mode-extend branch 3 times, most recently from 320d4fb to 696c521 Compare April 11, 2026 12:35
@risu729 risu729 force-pushed the task-includes-mode-extend branch from 37eb492 to 52ce982 Compare April 11, 2026 17:34
@risu729 risu729 marked this pull request as ready for review April 12, 2026 04:02
@risu729 risu729 marked this pull request as draft April 12, 2026 04:30
@risu729 risu729 marked this pull request as ready for review April 12, 2026 20:47
@jdx
Copy link
Copy Markdown
Owner

jdx commented Apr 23, 2026

I don't really see much value in this, sorry. If you're using this why wouldn't you just list the directories you know you have?

@risu729
Copy link
Copy Markdown
Contributor Author

risu729 commented Apr 24, 2026

My idea was to provide a way to avoid repeating the same entries in mise.local.toml, so I don't need to always update mise.local.toml.
I made this PR because I saw similar requests, but I agree that it doesn't worth for adding some complexity.

@risu729 risu729 closed this Apr 24, 2026
@risu729 risu729 deleted the task-includes-mode-extend branch April 24, 2026 18:32
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.

2 participants