Metadata-Version: 2.4
Name: uspto-oa-cli
Version: 0.1.4
Summary: USPTO 특허 심사과정 분석 CLI — 문서 다운로드 · XML 파싱 · MD 생성
Project-URL: Homepage, https://github.com/noaa/odp_oa_cli
License: MIT
Keywords: cli,office-action,patent,prosecution,uspto
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Legal Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
Requires-Python: >=3.13
Requires-Dist: click>=8.0
Requires-Dist: pypdf>=6.11.0
Requires-Dist: requests>=2.34.2
Requires-Dist: rich>=15.0.0
Description-Content-Type: text/markdown

# uspto-oa-cli

A CLI tool that downloads USPTO patent prosecution documents via the ODP (Open Data Portal) API, parses the XML, and converts them into structured Markdown.

Supports a workflow where the generated MD file is passed to AI agents (Claude Code, Gemini CLI, etc.) for prosecution strategy analysis.

## Requirements

- Python 3.13+
- [uv](https://docs.astral.sh/uv/)
- USPTO API key (issued via the [ODP portal](https://developer.uspto.gov/))

## Installation

```bash
# pip
pip install uspto-oa-cli

# uv (global install)
uv tool install uspto-oa-cli

# uv (add as project dependency)
uv add uspto-oa-cli

# local development
uv sync
```

## API Key Setup

```bash
# Interactive setup (recommended) — saved to ~/.oa-cli.toml
uspto-oa configure

# Show current configuration
uspto-oa configure --show
```

Or set via environment variable:

```bash
export USPTO_API_KEY=your_api_key_here
```

## Usage

```bash
# 0. Check document list before downloading
uspto-oa list 16330077

# 1. Download documents (saved to file/{app_num}/)
uspto-oa download 16330077

# 2. Parse XML → generate prosecution.md
uspto-oa extract 16330077
# Output: file/16330077/16330077_prosecution.md

# Extract in JSON format
uspto-oa extract 16330077 --format json

# Download specific document codes only
uspto-oa download 16330077 --doc-codes CTNF,CTFR,NOA

# Force re-download (overwrite existing files)
uspto-oa download 16330077 --force

# Verbose logging
uspto-oa -v download 16330077

# One-time API key override
uspto-oa download 16330077 --api-key YOUR_KEY
```

### Command Options

**`uspto-oa list <application>`**

| Option | Description |
|--------|-------------|
| `--all` | Show all documents without prosecution-related filter |
| `--format [table\|json]` | Output format (default: `table`) |
| `--api-key TEXT` | API key |

**`uspto-oa download <application>`**

| Option | Description |
|--------|-------------|
| `--doc-codes CODES` | Comma-separated document codes (e.g. `CTNF,CTFR,NOA`). All prosecution docs if omitted |
| `--output-dir DIR` | Save path (default: `file/{app_num}/`) |
| `--force` | Re-download even if file already exists |
| `--api-key TEXT` | API key (overrides config file and environment variable) |

**`uspto-oa extract <application>`**

| Option | Description |
|--------|-------------|
| `--format [md\|json]` | Output format (default: `md`) |
| `--output-dir DIR` | File directory (default: `file/{app_num}/`) |

## Workflow

```
uspto-oa list {app_num}           # Check document list before downloading
    └─ Browse prosecution document codes and formats

uspto-oa download {app_num}
    └─ Save XML / PDF to file/{app_num}/

uspto-oa extract {app_num}
    └─ Generate file/{app_num}/{app_num}_prosecution.md
         └─ AI agent (Claude Code / Gemini CLI)
              └─ Prosecution strategy analysis, summaries, Q&A
```

## Collected Document Codes

| Code | Description |
|------|-------------|
| `CTNF` | Non-Final Office Action |
| `CTFR` | Final Office Action |
| `NOA` / `NACT` | Notice of Allowance |
| `REM` | Remarks |
| `ABN` | Abandonment |
| `SRNT` / `SRFW` | Search Report |
| `EXIN` | Examiner Interview |
| `RCE` / `RCEX` | Request for Continued Examination |
| `CTAV` | Advisory Action |
| `892` / `1449` / `IDS` | Prior Art / IDS |
| `A*` | All Amendment variants |

## Generated File Structure

`file/{app_num}/{app_num}_prosecution.md`:

| Section | Content |
|---------|---------|
| Timeline | All documents sorted by date (XML/PDF format shown) |
| Office Action Details | Full rejection grounds from CTNF/CTFR |
| Amendment Details | Amended claims (CLM) + Remarks (REM) |
| Examiner Interview Details | Full EXIN text |
| Notice of Allowance Details | Allowed claims + Examiner's Statement |
| PDF-only Documents | Image PDF list (for direct AI agent delivery) |

## PyPI Release

```bash
uv build
uv run twine upload dist/*
```
