Skip to content

feat(mold): auto-discover well-known ai-agent directories during cast #142

@kriscoleman

Description

@kriscoleman

When a mold's only content lives under a dot-prefixed top-level directory (e.g. .claude/, .cursor/, .codex/), ailloy cast silently installs nothing because discoverTopLevelDirs in pkg/mold/output.go:168 excludes any entry whose name starts with .. Authors must add an explicit output: mapping in flux.yaml like:

output:
  .claude: .claude

This is a sharp edge — the canonical Ailloy use case is shipping commands and rules to AI coding agents, all of which conventionally live in dot-prefixed directories. A new mold author who scaffolds .claude/commands/foo.md, runs cast, and sees an empty target directory has no signal that anything went wrong.

This was found during end-to-end testing of the foundry index system in PR #81 against a private kriscoleman/foundry-test repo: a minimal mold with only .claude/commands/hello.md produced an "✅ Project casting complete!" message but installed no files.

Proposed Change

Add an allowlist of well-known AI-agent directories to pkg/mold/output.go that are auto-discovered despite their dot-prefix. Initial entries:

  • .claude (Claude Code)
  • .cursor (Cursor)
  • .codex (Codex)
  • .opencode (OpenCode)
  • .windsurf (Windsurf)
  • .continue (Continue)
  • .aider (Aider)
  • .github (GitHub Copilot lives at .github/copilot-instructions.md, plus shared workflow blanks)
  • .gemini (Gemini CLI)

Behavior:

  • A mold whose only top-level content is one of these dirs will install correctly with no flux.yaml output mapping.
  • An explicit output: mapping in flux.yaml continues to override auto-discovery (no behavior change for existing molds).
  • Other dot-prefixed dirs (e.g. .git, .idea, .vscode-test) remain excluded.
  • The same allowlist should be applied to discoverRootFiles for analogous root-level dotfiles where it makes sense (e.g. .cursorrules, .aider.conf.yml) — confirm during implementation whether that's symmetric.

Acceptance Criteria

  • pkg/mold/output.go exports a named allowlist (e.g. wellKnownAgentDirs) alongside reservedDirs with the directories listed above.
  • discoverTopLevelDirs includes a dot-prefixed dir if and only if its name is in the allowlist.
  • A mold containing only .claude/commands/hello.md (no flux.yaml) installs .claude/commands/hello.md to the project root via ailloy cast.
  • Same passes for .cursor/, .codex/, .opencode/, .windsurf/, .continue/, .aider/, .github/, .gemini/.
  • A mold containing .git/ or .idea/ is still excluded from auto-discovery.
  • Existing molds that use explicit output: mappings continue to behave unchanged.
  • Unit tests in pkg/mold/output_test.go (or equivalent) cover both allowlisted and non-allowlisted dot-prefixed dirs.
  • If discoverRootFiles gets symmetric treatment, well-known root dotfiles (.cursorrules, etc.) are covered by tests too.
  • assay lint output mentions when a mold relies on the allowlist, so authors aren't surprised (optional — confirm during implementation).

Notes

  • Source pointer: the exclusion lives at pkg/mold/output.go:168 (strings.HasPrefix(name, ".")) and at :190 for root files.
  • Keep the allowlist as a single source of truth — both auto-discovery paths (identity mode and the string output: parent form) use discoverTopLevelDirs, so a single change covers both.
  • Consider whether the allowlist should be configurable via mold.yaml (autoDiscover: [".myagent"]) for forward-compat with new tools — likely overkill for v1, but worth a sentence in the PR description.
  • Discovered while testing PR feat: foundry index system for SCM-agnostic mold discovery #81: feat: foundry index system for SCM-agnostic mold discovery #81

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions