Skip to content

A tool that creates a summary of files in a repository to help ChatGPT understand the contents of the repository.

License

Notifications You must be signed in to change notification settings

takurot/RepoSumm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Repository Code Summarizer

This script analyzes code and related files within a repository (.py, .js, .ts, .c, .cpp, .md, .yaml, .json) and automatically generates summaries using the OpenAI API. Summaries of each file are written to a Markdown file named repo_summary.md.

Features

  • Recursively scans all files within the specified directory (only selected extensions)
  • Summarizes each file’s content using AI
  • Organizes summaries by file in Markdown format and outputs them to repo_summary.md

Requirements

Configuration

An OpenAI API key is required. Set your API key in the environment variable OPENAI_API_KEY.

Usage

  1. Clone or download the repository.

  2. Specify the path of the repository root directory you want to analyze when running the script.

  3. Run the following command to generate the summary file in Markdown format:

    python summarize_repo.py [repo_path]
    • Summarizes code within the directory specified by repo_path.
    • The generated summary file, repo_summary.md, is saved in the same directory.

Function Descriptions

  • summarize_code(code_snippet): Summarizes a code snippet using the OpenAI API.
  • process_file(file_path): Reads the specified file, splits it into manageable parts, and summarizes each part.
  • process_directory(start_path): Recursively scans the specified directory and collects summaries for matching files.
  • write_markdown(summaries, output_path="repo_summary.md"): Writes the summaries to a Markdown file.

Notes

  • Using the OpenAI API incurs costs, so summarizing a large number of files may result in charges.
  • Summaries are generated by AI, so the content may vary slightly from the original code’s exact nuances. Review is recommended.

License

This script is freely available for use, but please check the LICENSE file within the repository for details on licensing.

Repository Code Summarizer

このスクリプトは、リポジトリ内のコードおよび関連ファイル(.py, .js, .ts, .c, .cpp, .md, .yaml, .json)を解析し、OpenAI APIを利用して自動的に要約します。各ファイルの要約はMarkdownファイル repo_summary.md に書き出されます。

機能

  • 指定されたディレクトリ以下のすべてのファイル(指定拡張子のみ)を再帰的に探索
  • 各ファイルの内容をAIを用いて要約
  • Markdown形式でファイルごとに要約を整理し、repo_summary.md に出力

必要な環境

設定

OpenAI APIキーが必要です。APIキーの設定は OPENAI_API_KEY の環境変数に設定してください。

スクリプトの使い方

  1. リポジトリのクローンまたはダウンロードを行います。

  2. スクリプトの実行には、解析対象のリポジトリのルートディレクトリパスを指定する必要があります。

  3. 以下のコマンドでスクリプトを実行し、Markdown形式の要約ファイルを生成します。

    python summarize_repo.py [repo_path]
    • repo_path で指定されたパスのディレクトリ以下のコードを要約します。
    • 生成された要約ファイル repo_summary.md は同じディレクトリに保存されます。

関数説明

  • summarize_code(code_snippet): OpenAI APIを使い、コードスニペットを要約。
  • process_file(file_path): 指定したファイルを読み込み、適切な長さに分割して各部分を要約。
  • process_directory(start_path): 指定されたディレクトリを再帰的に探索し、対応するファイルの要約を収集。
  • write_markdown(summaries, output_path="repo_summary.md"): 要約をMarkdownファイルに書き出します。

注意

  • OpenAI APIの利用には料金がかかるため、大量のファイルを要約する際にはコストが発生する可能性があります。
  • AIによる要約のため、生成される内容は元のコードのニュアンスと若干異なる場合があります。内容の確認を推奨します。

ライセンス

このスクリプトは自由に使用可能ですが、利用にあたってのライセンスについてはリポジトリ内の LICENSE ファイルをご確認ください。

About

A tool that creates a summary of files in a repository to help ChatGPT understand the contents of the repository.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages