Metadata-Version: 2.4
Name: prompt-grapher
Version: 1.4.2
Summary: Generate repository-specific Cursor rules and AGENTS.md files from Graphify dependency graphs.
Author: geekprateek
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: click>=8.1.7
Requires-Dist: graphifyy>=0.8.14
Requires-Dist: networkx>=3.2
Requires-Dist: openai>=1.30.0
Requires-Dist: python-dotenv>=1.0.1
Provides-Extra: dev
Requires-Dist: pytest>=8.2.0; extra == "dev"
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# PromptGrapher

PromptGrapher turns a Graphify dependency graph into repository-specific Cursor rules. It is designed to work against arbitrary projects, not just a single language or framework.

## What It Does

1. Reads `graphify-out/graph.json` or `graphify-out/manifest.json`.
2. Infers the project's primary languages, framework hints, architecture style, naming patterns, hotspots, entrypoints, and test presence.
3. Sends that summary to an OpenAI-compatible model.
4. Writes `.cursor/rules/project-rules.mdc` for Cursor and `AGENTS.md` as a root-level backup/source-of-truth.

## Requirements

- Python 3.10+
- No separate Graphify install step. `graphifyy` is installed as a dependency.
- An OpenAI-compatible API key and model name

## Installation

Install from PyPI:

```bash
python -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install prompt-grapher
```

On Windows PowerShell, activate the environment with:

```powershell
.venv\Scripts\Activate.ps1
```

## Configuration

From the root of the project you want to analyze, create a `.env` file:

```bash
prompt-grapher init
```

Then set:

- `AI_API_KEY`
- `AI_MODEL_NAME`
- `AI_BASE_URL` if you are using a non-default OpenAI-compatible endpoint such as Groq, OpenRouter, or Ollama

PromptGrapher also falls back to `OPENAI_API_KEY`, `GROQ_API_KEY`, and `OPENROUTER_API_KEY`.

Important: `prompt-grapher init` writes the `.env` file into your current working directory, so run it inside the repository you want to analyze.

## Usage

From the project root, analyze the current repository and auto-run Graphify when needed:

```bash
prompt-grapher analyze .
```

Re-running `prompt-grapher analyze` refreshes the Graphify artifact by default before regenerating rules, so architecture and module changes are picked up automatically.

If you intentionally want to reuse the current `graphify-out` contents without refreshing them, use:

```bash
prompt-grapher analyze /path/to/project --reuse-graph
```

By default, PromptGrapher bootstraps Graphify with a code-only graph build that does not require a second LLM provider:

```bash
python -m graphify update /path/to/project --no-cluster
```

This mode is enough for PromptGrapher's architecture heuristics and works well for PyPI installs.

If you explicitly want Graphify's semantic extraction path, switch strategies:

```bash
prompt-grapher analyze /path/to/project --graphify-strategy semantic --graphify-backend openai --graphify-model gpt-4.1-mini
```

Semantic extraction requires a Graphify-supported backend and its API key.

Reuse an existing Graphify artifact:

```bash
prompt-grapher analyze /path/to/project --graph-input /path/to/project/graphify-out/graph.json
```

Override the model or output filename:

```bash
prompt-grapher analyze /path/to/project --model gpt-4.1-mini --output-file .cursor/rules/project-rules.mdc --agents-file AGENTS.md
```

## Quick Start

```bash
pip install prompt-grapher
cd /path/to/project
prompt-grapher init
# fill AI_API_KEY and AI_MODEL_NAME in .env
prompt-grapher analyze .
```

## Local Smoke Tests

```bash
pip install -e .[dev]
pytest
```
