Skip to content

feat(output): support conditional output directory mappings #101

@kriscoleman

Description

@kriscoleman

Problem

The output: section in flux.yaml is static — every directory mapping is always processed during ailloy cast, regardless of flux variable values. There is no way to conditionally include/exclude output directories based on configuration.

This makes multi-agent molds cumbersome. A mold targeting Claude, Copilot, and Cursor needs separate output directories for each agent:

output:
  commands: .claude/commands       # Claude slash commands
  cursor_rules: .cursor/rules     # Cursor .mdc rules
  copilot_prompts: .github/copilot # Copilot instructions

When a user casts with --set agent.targets="[claude]", the cursor_rules and copilot_prompts directories are still processed and written (producing empty files if the template content is conditional, or the full files if it isn't).

Proposed Solution

Add an agents field (or more general when field) to the expanded output mapping syntax:

Option A: agents field (simpler, purpose-built)

output:
  commands:
    dest:
      claude: .claude/command
    agents: [claude]
  rules:
    agents: [cursor, claude]
    dest:
      cursor: .cursor/rules
      claude: .claude/rules
  prompts:
    dest: 
       copilot: .github/copilot
    agents: [copilot]
  agents: .  # No agents field = always included

The agents field is a list of agent names. The directory is only processed if at least one value in agents appears in agent.targets (from flux context). Directories without an agents field are always processed (backward compatible). destinations are tightly coupled to the agents array, destinations is an kvp object of mappings for each agent. So if rules has cursor and claude agents in it's list, then destinations dest must have keys for cursor and claude where the values are the file path destinations.

Use Case

This is needed for the nimble-mold multi-agent output architecture (nimble-giant/nimble-mold#3). The mold needs to produce output for Claude, Copilot, and/or Cursor depending on configuration, with each agent's files going to their expected directories — without producing artifacts for non-targeted agents.

Acceptance Criteria

  • Output directories can be conditionally included based on flux variables
  • Directories without the conditional field are always processed (backward compatible)
  • The ailloy forge dry-run reflects which directories would be included
  • Works with --set overrides (e.g., --set agent.targets="[claude,cursor]")

depends on

#102

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions