bau/agentsetup

Writes project-local coding-agent setup files for Bau MCP and skills.

Types

AgentSetupFile = object
  agent*: string             ## Agent host name.
  kind*: string              ## File role, such as `mcp` or `skill`.
  path*: string              ## Absolute path to the setup file.
  action*: string            ## create, update, unchanged, skipped, etc.
  changed*: bool             ## True when the action would change the file.
  reason*: string            ## Explanation for skipped or failed actions.
One setup file that was planned or written.
AgentSetupOptions = object
  targets*: seq[AgentTarget] ## Agent hosts to configure.
  force*: bool               ## Replace existing divergent generated entries.
  dryRun*: bool              ## Report planned changes without writing files.
Options for project-local agent setup.
AgentSetupResult = object
  projectDir*: string        ## Bau project directory.
  files*: seq[AgentSetupFile] ## File-level results.
Project-local agent setup summary.
AgentTarget = enum
  atCodex = "codex", atClaude = "claude", atCopilot = "copilot"
Coding-agent host to configure.

Consts

BauAgentSkillContent = """---
name: bau
description: Use Bau for this Nim project. Use when building, testing, running, managing dependencies, working with tasks/cache/docs, inspecting metadata, or connecting coding agents through MCP.
---

# Bau

Use Bau as the orchestration layer for this Nim project.

## First Moves

1. Read `bau.toml` before changing build behavior.
2. Prefer Bau commands over raw `nim`, `nimble`, or `atlas` commands.
3. Use `bau metadata --json` when you need project structure.
4. Preserve `bau.lock`; use `bau deps sync --locked` for normal setup.
5. Use `bau deps sync` only when intentionally refreshing dependency state.

## Common Commands

```sh
bau check
bau test
bau ci
bau run -- --help
bau deps sync --locked
bau deps verify
bau doc
bau affected list --since origin/main
bau affected test --since origin/main
```

## Agent Integration

Bau exposes the same operations through CLI and MCP. Start the MCP server with:

```sh
bau mcp
```

Use MCP tools for build, run, test, check, lint, CI, docs, dependency, task,
cache, metadata, graph, query, affected-work, package, publish dry-run, and
setup operations when they are available.
"""

Procs

proc agentSetupResultJson(setup: AgentSetupResult): JsonNode {....raises: [],
    tags: [], forbids: [].}
Convert an agent setup result to stable machine-readable JSON.
proc defaultAgentTargets(): seq[AgentTarget] {....raises: [], tags: [], forbids: [].}
Return every supported project-local agent setup target.
proc normalizeAgentTargets(values: openArray[string]): seq[AgentTarget] {.
    ...raises: [ValueError], tags: [], forbids: [].}
Parse and de-duplicate agent target names.
proc parseAgentTarget(value: string): AgentTarget {....raises: [ValueError],
    tags: [], forbids: [].}
Parse a command-line or JSON target name.
proc setupAgents(projectDir: string; opts: AgentSetupOptions): AgentSetupResult {.
    ...raises: [IOError, OSError, JsonParsingError, ValueError, KeyError], tags: [
    ReadDirEffect, ReadIOEffect, WriteDirEffect, WriteIOEffect, RootEffect],
    forbids: [].}
Write MCP registration and project-local skill files for agent hosts.