Skip to content

Comments

Add file() directive support for modularizing manifest values#11

Merged
jeffreyaven merged 1 commit intomainfrom
claude/modularize-manifest-policy-akY5V
Feb 23, 2026
Merged

Add file() directive support for modularizing manifest values#11
jeffreyaven merged 1 commit intomainfrom
claude/modularize-manifest-policy-akY5V

Conversation

@jeffreyaven
Copy link
Contributor

Summary

This PR adds support for file() directives in manifest property values, enabling users to modularize large manifest values (such as IAM policy statements) into separate JSON or YAML files.

Key Changes

  • New error variant: Added FileIncludeError to ManifestError enum for file resolution failures
  • File directive parsing: Implemented parse_file_directive() to extract file paths from file(path) syntax with flexible whitespace handling
  • Recursive resolution: Added resolve_file_directives() to recursively traverse and resolve file() directives in YAML/JSON value trees (strings, sequences, and mappings)
  • File loading: Implemented load_file_contents() to read and parse referenced files with support for:
    • JSON files (.json extension)
    • YAML files (.yml, .yaml extensions)
    • Automatic format detection for files without recognized extensions (tries JSON first, falls back to YAML)
    • Nested file directive resolution within loaded content
  • Manifest integration: Added resolve_manifest_file_directives() to process all globals and resource properties in a manifest
  • Load-time resolution: Modified Manifest::load_from_file() to automatically resolve file directives relative to <stack_dir>/resources/ directory
  • Comprehensive test suite: Added 13 tests covering:
    • Directive parsing edge cases
    • JSON object and array resolution
    • YAML file resolution
    • Nested directives in sequences and mappings
    • Subdirectory paths
    • Error handling for missing files
    • Non-directive string preservation
    • Template variable preservation
    • End-to-end manifest loading with file directives
    • Nested file directive resolution

Implementation Details

  • File paths in file() directives are resolved relative to the resources/ subdirectory under the manifest's parent directory
  • The resolution process is recursive, allowing included files to themselves contain file() directives
  • Non-directive strings and template variables (e.g., {{ stack_name }}) are left untouched
  • Error messages include both the original file path and the resolved full path for debugging

https://claude.ai/code/session_01FikwxWpZdvhtNbECVWJiqK

Introduces a `file()` directive that can be used in manifest property
values to include contents from external JSON or YAML files. This
allows large, complex values (e.g., IAM policy statements) to be
extracted into separate files for better readability and reuse.

File paths are resolved relative to the `resources/` directory,
consistent with how `file:` on resources resolves query files.
Supports JSON (.json) and YAML (.yml/.yaml) files, with recursive
resolution of nested file() directives.

https://claude.ai/code/session_01FikwxWpZdvhtNbECVWJiqK
@jeffreyaven jeffreyaven merged commit 22322a9 into main Feb 23, 2026
2 of 3 checks passed
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