Skip to main content

Generate a project map from a directory.

Project description

🧩 projext: Project-to-Text Mapper

A versatile CLI tool that scans your project directories and generates a comprehensive "map" of your codebase.


English README (Click to expand)

projext is a versatile CLI tool that scans your project directories and generates a comprehensive "map" of your codebase in various formats. It's designed to help you quickly understand project structures, analyze code components, and create context for Large Language Models (LLMs).

Features

  • Dual Output Modes: Generate a map with the full content of files (full mode) or a structured summary of Python files using AST (ast mode).
  • Directory Tree Generation: Output a classic directory tree structure, similar to the tree command.
  • Flexible Configuration: Fine-tune what to include/exclude with options for file extensions, size limits, exclusion patterns, and per-file mode overrides.
  • Multiple Formats: Output the project map as Markdown for human readability or JSON for machine processing (e.g., RAG pipelines).
  • AST Analysis: In ast mode, projext extracts key information from Python files, including classes, functions (with type hints and docstrings), and imports.

Installation

pip install projext

Usage

projext has two main commands: map and tree.

projext map <path> [options]

Scans a directory and generates a detailed map of file contents.

Arguments

  • <path> (Required): The root directory of the project you want to scan.

Options

Option Description Default
--ext A comma-separated list of file extensions to include in the scan. .py,.json,.md
--out The name of the output file. project_tree.md
--format The output format. Can be md (Markdown) or json. md
--max-file-size The maximum size for a single file to be included. (e.g., 1MB, 500K). 1MB
--mode The default processing mode: full (file content) or ast (Python code summary). full
--full A file or directory path to force full mode on, overriding the default. Can be used multiple times. N/A
--ast A file or directory path to force ast mode on for Python files, overriding the default. Can be used multiple times. N/A
--exclude A glob pattern to exclude files or directories. Can be used multiple times. N/A

projext tree <path> [options]

Generates a classic directory tree structure.

Arguments

  • <path> (Required): The root directory to create a tree from.

Options

Option Description Default
--out The name of the output file. project_tree.txt
--exclude A glob pattern to exclude files or directories. Can be used multiple times. N/A

Use Cases & Examples

1. Basic Project Overview (AST Mode)

Generate a structural summary of a Python project. This is useful for quickly understanding the architecture.

projext map ./my-python-app --mode ast --out ast_summary.md

2. Full Content Map

Create a complete map of a project with the full content of all specified files.

projext map ./my-project --ext .py,.md --out overview.md

3. Directory Tree

Generate a simple, clean directory tree, excluding node_modules and .git by default.

projext tree . --out tree.txt

4. Hybrid Mode for Mixed Analysis

Use full mode as the default, but specifically request an AST summary for a complex part of the application.

projext map ./my-project --mode full --ast ./my-project/core/

5. Excluding Files and Directories

Generate a map while excluding test files and temporary directories.

projext map . --exclude "tests/*" --exclude "temp/"

License

This project is licensed under the MIT License.


日本語 README (クリックして展開)

projext は、プロジェクトディレクトリをスキャンし、コードベースの包括的な「マップ」を様々な形式で生成する、多機能なCLIツールです。プロジェクト構造の迅速な理解、コードコンポーネントの分析、そして大規模言語モデル(LLM)向けのコンテキスト作成を支援します。

✨ 主な機能

  • デュアル出力モード: ファイルの全コンテンツを含むマップ(fullモード)または、Pythonファイルの構造化サマリ(astモード)を生成します。
  • ディレクトリツリー生成: treeコマンドに似た、クラシックなディレクトリツリー構造を出力します。
  • 柔軟な設定: ファイル拡張子、サイズ上限、除外パターン、ファイルごとのモード上書きなど、スキャン対象を細かく調整できます。
  • 複数フォーマット対応: 人間が読みやすいMarkdown形式、または機械処理(RAGパイプラインなど)に適したJSON形式でマップを出力します。
  • AST解析: astモードでは、クラス、関数(型ヒントやdocstringを含む)、インポート文など、Pythonファイルの重要な情報を抽出します。

📦 インストール

pip install projext

使い方

projext には maptree の2つの主要なコマンドがあります。

projext map <path> [options]

ディレクトリをスキャンし、ファイルコンテンツの詳細なマップを生成します。

引数

  • <path> (必須): スキャンしたいプロジェクトのルートディレクトリ。

オプション

オプション 説明 デフォルト
--ext スキャンに含めるファイル拡張子をカンマ区切りで指定します。 .py,.json,.md
--out 出力ファイル名。 project_tree.md
--format 出力フォーマット。md (Markdown) または json を指定できます。 md
--max-file-size スキャンに含める単一ファイルの最大サイズ(例: 1MB, 500K)。 1MB
--mode デフォルトの処理モード: full (ファイル全体) または ast (Pythonコードの要約)。 full
--full デフォルトモードを上書きし、fullモードを強制するファイル/ディレクトリ。複数回指定可能。 N/A
--ast デフォルトモードを上書きし、Pythonファイルにastモードを強制するファイル/ディレクトリ。複数回指定可能。 N/A
--exclude 除外するファイルやディレクトリのglobパターン。複数回指定可能。 N/A

projext tree <path> [options]

クラシックなディレクトリツリー構造を生成します。

引数

  • <path> (必須): ツリーを生成するルートディレクトリ。

オプション

オプション 説明 デフォルト
--out 出力ファイル名。 project_tree.txt
--exclude 除外するファイルやディレクトリのglobパターン。複数回指定可能。 N/A

ユースケースと実行例

1. 基本的なプロジェクト概要(ASTモード)

Pythonプロジェクトの構造的なサマリを生成します。アーキテクチャを素早く理解するのに役立ちます。

projext map ./my-python-app --mode ast --out ast_summary.md

2. フルコンテンツ・マップ

指定されたすべてのファイルの全コンテンツを含む完全なマップを作成します。

projext map ./my-project --ext .py,.md --out overview.md

3. ディレクトリツリー

node_modules.git などをデフォルトで除外した、シンプルでクリーンなディレクトリツリーを生成します。

projext tree . --out tree.txt

4. ハイブリッドモードでの複合分析

デフォルトは full モードを使いつつ、アプリケーションの複雑な部分だけASTサマリをリクエストします。

projext map ./my-project --mode full --ast ./my-project/core/

5. ファイルとディレクトリの除外

テストファイルや一時ディレクトリを除外してマップを生成します。

projext map . --exclude "tests/*" --exclude "temp/"

ライセンス

このプロジェクトはMITライセンスの下で公開されています。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

projext-0.1.0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

projext-0.1.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file projext-0.1.0.tar.gz.

File metadata

  • Download URL: projext-0.1.0.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.10.19 Linux/6.8.0-87-generic

File hashes

Hashes for projext-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b91b59d95a47959ae3e332bd619180b410b03fdcc9162a65bebadd4731b6c38f
MD5 c55f2c1de720d5f113fe5493c2e051a6
BLAKE2b-256 703ba8482acf9957b8047ad42f1a22d900a36282be94a798140eb229697472f9

See more details on using hashes here.

File details

Details for the file projext-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: projext-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.10.19 Linux/6.8.0-87-generic

File hashes

Hashes for projext-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ff8270b958e672bc888a3ec8324834f7ee4a893f41fd24fca8b5aa673d8a386
MD5 6cbef619eed75d16488b32aabd2a05b3
BLAKE2b-256 1f9ff4b7c575daf0c784cafa530f6cabc87bdc6cbb4a0a4b629c937cdfa182f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page