kamilstanuch / codebase-digest

🗜️ Codebase-digest is your AI-friendly codebase packer and analyzer. Features 60+ coding prompts and generates structured overviews with metrics. Ideal for feeding projects to LLMs like GPT-4, Claude, PaLM, and Gemini for code analysis and understanding.
76 stars 6 forks source link

Add --no-input argument #4

Open frogermcs opened 1 week ago

frogermcs commented 1 week ago

Short summary

Add the --no-input argument so the app can be run with all input prompts surpassed, e.g., to prevent Github actions from crashing.

Screenshot 2024-10-28 at 12 54 32

More context

I want to use codebase-digest as part of my Github Actions pipelines. I want it export digest as txt file, and it almost works. :)

The problematic part are your input() prompts, which currently cannot be disabled via arguments, so I added one.

I also added a basic unit testing framework to make it easier to modularize and test code in the future.

Example Github Action

Once this PR is merged and released to production, I plan to create another one with example Github Action.

If you want to try it on your own, here's the example code:

name: Consolidate Repository to Single Prompt

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  consolidate:
    runs-on: ubuntu-latest

    steps:
      - name: Check out the code
        uses: actions/checkout@v3

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.x'

      - name: Install Codebase Digest
        run: pip install codebase-digest

      - name: Generate Single Prompt File
        run: cdigest . -f consolidated_project_prompt.txt --copy-to-clipboard=false 

      - name: Upload Prompt File as Artifact
        uses: actions/upload-artifact@v3
        with:
          name: consolidated_project_prompt
          path: consolidated_project_prompt.txt

Chores

This PR also creates very (very!) basic setup for unit testing. I assume this project will grow, so it would be nice to bring at least baseline for maintainability.

To run unit tests 1) Go to /codebase-digest directory 2) Run python -m unittest discover -s tests

This required adding one more dependency in requirements-dev.txt: unittest