Metadata-Version: 2.4
Name: ci-doctor
Version: 0.1.0
Summary: CLI to diagnose CI pipeline runs
Author-email: Anders <mail@andersj.io>
License: Apache License
        Version 2.0, January 2004
        http://www.apache.org/licenses/
        
        TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
        1. Definitions.
        "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
        "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
        "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity.
        "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
        "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
        "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
        "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
        "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship.
        "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner.
        "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
        
        2. Grant of Copyright License.
        Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
        
        3. Grant of Patent License.
        Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work.
        
        4. Redistribution.
        You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
           (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
           (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
           (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
           (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear.
        
        5. Submission of Contributions.
        Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions.
        
        6. Trademarks.
        This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work.
        
        7. Disclaimer of Warranty.
        Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        
        8. Limitation of Liability.
        In no event and under no legal theory shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character.
        
        9. Accepting Warranty or Additional Liability.
        While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations.
        
        END OF TERMS AND CONDITIONS
        
        
        
Project-URL: Homepage, https://github.com/andersjio/ci-doctor
Project-URL: Repository, https://github.com/andersjio/ci-doctor
Project-URL: Issues, https://github.com/andersjio/ci-doctor/issues
Keywords: ci,github-actions,diagnostics,cli,devops
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: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: typer==0.12.5
Requires-Dist: httpx==0.27.2
Requires-Dist: pydantic==2.9.2
Requires-Dist: rich==13.9.2
Requires-Dist: python-dotenv==1.0.1
Provides-Extra: ai
Requires-Dist: openai>=1.0.0; extra == "ai"
Dynamic: license-file

# CI Doctor

A CLI that analyzes a GitHub Actions run URL and prints a compact diagnosis.

## Install

Using pipx (recommended for CLI tools):

```bash
pipx install cidoc
```

Or with pip:

```bash
pip install cidoc
```

### Install (editable for dev)

```bash
pip install -e .
```

## Auth

Set up a GitHub Personal Access Token. See [GITHUB_TOKEN_SETUP.md](GITHUB_TOKEN_SETUP.md) for detailed instructions.

Quick start:
```bash
export GITHUB_TOKEN=ghp_...
```

### AI Analysis (Optional)

For AI-powered failure analysis, install the AI extras and set your OpenAI API key:

```bash
pip install -e ".[ai]"
export OPENAI_API_KEY=sk-...
```

**Creating an OpenAI API Key**:
1. Go to [https://platform.openai.com/api-keys](https://platform.openai.com/api-keys)
2. Sign in or create an OpenAI account
3. Click "Create new secret key"
4. Give it a name (e.g., "CI Doctor")
5. Copy the key immediately (you won't be able to see it again)
6. Add it to your environment: `export OPENAI_API_KEY=sk-...`

**Note**: AI analysis uses OpenAI's API, which may incur costs. The tool uses `gpt-4o-mini` for cost efficiency.

## Usage

```bash
# Use 'ci-doctor' or shorter alias 'cidoc'
ci-doctor analyze https://github.com/owner/repo/actions/runs/123456789
cidoc analyze <url>

# With AI-powered analysis
ci-doctor analyze <url> --ai

# JSON output
ci-doctor analyze <url> --format json > report.json

# Save logs to disk
ci-doctor analyze <url> --save-logs
```

**Note**: Logs from failing steps are automatically extracted and displayed. Use `--save-logs` to also save the full log ZIP to `./artifacts`. Use `--ai` for intelligent failure analysis (requires OpenAI API key).

## Security

**🔒 This tool is 100% READ-ONLY**

CI Doctor only performs GET requests to the GitHub API. It **cannot**:
- Modify repositories, workflows, or files
- Create, update, or delete anything
- Trigger workflow runs
- Change repository settings or permissions

The tool only reads:
- Workflow run status and metadata
- Job and step information
- Repository commit comparisons
- Logs (download only, no modification)

Use tokens with **read-only** scopes (`actions:read`, `contents:read`) only.

## Notes
- GitHub provider only in v0; provider abstraction enables Jenkins/Azure later.
- Stateless; uses live API with optional ETag cache.
