# zendy

Pi extension for Dify Enterprise support ticket analysis. Analyze Zendesk tickets with natural language — from ticket metadata to Helm chart values to source code.

Powered by [pi](https://pi.dev).

[中文](docs/README.zh.md) | [日本語](docs/README.ja.md)

## What it does

zendy is a single pi extension that provides:

- **LLM Tools** — Direct API access to Zendesk, Helm Watchdog, and Knowledge Graph. No external CLI dependencies.
- **Slash Commands** — `/zendy-config` to set up credentials, `/zendy-status` to check connectivity.
- **Skill** — a `zendy` skill (also `/skill:zendy`) that teaches the agent the ticket-analysis workflow, so "analyze ticket #1959" reliably uses the right tools in the right order.
- **Session Safety** — Automatic workspace isolation and cleanup for source code analysis.
- **Source Registry** — Bundled Dify source repository defaults. Enterprise repos use SSH URLs, so GitHub SSH permissions remain the access gate.

Typical workflow:

```
pi → "Analyze ticket #1959" → agent calls zendy_ticket_get →
identifies version → agent calls zendy_helm_get →
synthesizes findings → drafts reply
```

## Prerequisites

- [pi](https://pi.dev) installed globally: `npm install -g @earendil-works/pi-coding-agent`

## Install

```bash
pi install npm:@tplog/pi-zendy
```

## Configure

Start pi and run:

```
/zendy-config
```

This interactively collects Zendesk credentials (subdomain, email, API token) and Knowledge Graph API key.

Alternatively, set environment variables:

```bash
export ZENDY_ZENDESK_SUBDOMAIN=dify
export ZENDY_ZENDESK_EMAIL=you@example.com
export ZENDY_ZENDESK_API_TOKEN=your_token
export ZENDY_KG_API_KEY=your_kg_key
```

Credentials are stored in `~/.zendy/config.json` (mode 0600). On first run, zendy auto-imports
from legacy `zcli` and `zendesk-kg` config files if they exist.

## Commands

| Command | Purpose |
|---------|---------|
| `/zendy-config` | Configure Zendesk and KG credentials |
| `/zendy-status` | Check connectivity to all services |

## Tools

The agent can call these tools directly:

| Tool | Description |
|------|-------------|
| `zendy_ticket_get` | Fetch ticket metadata, comments, and user info |
| `zendy_ticket_search` | Search live Zendesk tickets |
| `zendy_whoami` | Check the currently authenticated Zendesk identity |
| `zendy_helm_get` | Query Helm chart values, images, validation by version |
| `zendy_kg_search` | Semantic search over historical tickets |
| `zendy_source_status` | Check source analysis workspace and bundled Dify source repository registry |

## How it works

zendy registers as a pi extension package. The extension provides tools (callable by the LLM),
slash commands (for human engineers), and session lifecycle hooks (workspace creation, cleanup).
All data access goes through direct REST APIs — no `zcli`, `zendesk-kg`, or other CLI tools
are required at runtime.

For source analysis, zendy ships default repository entries for Dify Enterprise backend/frontend and related public Dify repositories. The Enterprise entries are SSH URLs; users without GitHub SSH access can install zendy, but source clone attempts will fail at Git authentication.
