refactor: abstract taskfile loading via loader interface #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Testing
go test ./...Prompt
Task 1: Refactor Configuration Loading (Abstract YAML Parsing)
Purpose: Prepare the codebase to handle multiple config file formats (YAML and HCL) by abstracting the parsing logic. Currently, the Taskfile loading is tightly coupled to YAML via built-in UnmarshalYAML methods. We need to introduce a format-agnostic layer so that adding HCL becomes straightforward.
• Implementation:
• Identify where Taskfiles are read and parsed (e.g. functions that search for Taskfile.yml and call YAML unmarshal). Refactor this logic to use a config loader interface or strategy pattern. For example, define an interface TaskfileLoader with a method like LoadTaskfile(path) (*Taskfile, error).
• Provide two implementations: YAMLLoader (uses existing YAML unmarshal logic) and HCLLoader (to be implemented in later tasks). Determine format by file extension or content.
• Decouple YAML-specific code: If Taskfile.UnmarshalYAML and other struct methods exist, consider moving YAML-specific unmarshalling into the YAML loader. The core Taskfile struct should not assume YAML input.
• Ensure that all references to YAML in the loading process (e.g. error messages like “invalid YAML”) are either generalized or moved into the YAML loader. This lays the groundwork for adding HCL seamlessly.
• Validation:
• All existing tests for loading and parsing YAML Taskfiles must continue to pass. For example, running task with a standard Taskfile.yml should behave exactly as before.
• Add a unit test for the loader interface: invoke the YAML loader on a known-good Taskfile YAML content and verify it returns a proper Taskfile struct (same as direct unmarshal). This confirms the refactor didn’t break YAML support.
https://chatgpt.com/codex/tasks/task_e_6891f2a02d888330bc1cd199e30270bb