# pi-confluence

Confluence integration for [Pi Coding Agent](https://shittycodingagent.ai) — search, fetch, and save Confluence pages as Markdown files.

## Installation

```bash
pi install npm:pi-confluence
```

## Features

### Tools

| Tool | Description |
|------|-------------|
| `confluence_search` | Search pages by text or CQL query |
| `confluence_fetch` | Fetch a page by ID and save as `.md` |
| `confluence_spaces` | List available Confluence spaces |

### TUI Config Editor

Run `/confluence-config` inside Pi to interactively configure your credentials with a full TUI overlay — no need to hand-edit JSON files.

### HTML → Markdown

Built-in converter handles Confluence-specific markup:
- Structured macros (code blocks, info/note/warning panels)
- Tables, lists, headings, links, images
- Frontmatter with page metadata (ID, space, URL, author, timestamp)

## Configuration

Credentials are loaded from (in priority order):

1. `.pi/confluence.json` (project-local)
2. `~/.pi/agent/confluence.json` (global)
3. Environment variables: `CONFLUENCE_BASE_URL`, `CONFLUENCE_EMAIL`, `CONFLUENCE_API_TOKEN`

### Config format

```json
{
  "baseUrl": "https://your-domain.atlassian.net/wiki",
  "email": "you@company.com",
  "apiToken": "your-api-token",
  "outputDir": "./confluence-docs"
}
```

You can reference environment variables with the `ENV:` prefix:

```json
{
  "baseUrl": "https://your-domain.atlassian.net/wiki",
  "email": "ENV:CONFLUENCE_EMAIL",
  "apiToken": "ENV:CONFLUENCE_API_TOKEN",
  "outputDir": "./confluence-docs"
}
```

Get your API token at: https://id.atlassian.com/manage-profile/security/api-tokens

## Usage Examples

Once configured, the AI agent can use these tools naturally:

```
> Search our wiki for deployment guides
  → confluence_search query="deployment guide"

> Fetch the architecture overview page
  → confluence_fetch pageId="12345"

> Download the entire onboarding space
  → confluence_search query="type=page AND space=ONBOARD"
  → confluence_fetch pageId="..." includeChildren=true
```

## License

MIT
