dir2prompt


Namedir2prompt JSON
Version 1.0.13 PyPI version JSON
download
home_pageNone
SummaryGenerate prompts for long-context LLMs using the content in your directory
upload_time2024-04-25 23:49:09
maintainerNone
docs_urlNone
authorNone
requires_python>=3.6
licenseMIT License Copyright (c) 2024 mkieffer1107 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords prompt engineering large language model directory structure prompt generation file tree visualization directory to prompt automation tools developer utilities code documentation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dir2prompt

[![PyPI version](https://img.shields.io/pypi/v/dir2prompt.svg)](https://pypi.org/project/dir2prompt/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

When you feel too lazy to selectively copy code from all the various files in your project, just copy it all! Inspired by [repo2prompt](https://github.com/andrewgcodes/repo2prompt).

## Installation 💻

You can install `dir2prompt` using pip:

```sh
pip install dir2prompt
```

## Usage 🚀

To generate a prompt from a directory, use the `d2p` command followed by the desired options:

```sh
d2p --dir [directory path] --filters [file extensions] --outpath [output path] --outfile [output file name] --ignore-dir [directories to ignore] --ignore-file [files to ignore] --config [path to config file]

```

For ease of use, you can select a directory by passing it in as a positional argument

```sh
d2p [directory path]
```

If both the positional argument and the `--dir` flag are provided, the `--dir` flag takes priority.

## Options ⚙️

`--dir`: The directory to generate the prompt for (default: current directory).

`--filters`: File extensions to include in the prompt (default: all files).

`--outpath`: The output path for the prompt file (default: current directory).

`--outfile`: The name of the output file (default: `<directory_name>_prompt`).

`--ignore-dir`: Additional directories to ignore (e.g., `experiments`, `run*`).

`--ignore-file`: Additional file types to ignore (e.g., `.pt`, `.rs`).

`--config`: Path to a custom config file (default: `config.json` in the package directory).

## Example 🌟

Here's an example of how to use `dir2prompt` to generate a prompt:

```sh
d2p --dir project --filters .py .txt .md .ipynb --ignore-dir experiments __pycache__ --ignore-file old.py
```

This command will generate a prompt for the specified directory, including only files with the extensions `.py`, `.txt`, `.md`, `.ipynb`, ignoring the `experiments` and `__pycache__` directories, and ignoring the `old.py` file. 

Note that ignored directories are not included in the directory tree, but that ignored files are. However, the content of the ignored files will not be written to the final prompt under the `<files>` tag. This might be changed later...

In this example, the generated prompt will be saved as a `.txt` file in the directory that `d2p` is called in with the name `project_prompt.txt`, and will have the following structure:

**<dir_name>_prompt.txt**
```xml
<context>
<directory_tree>
project/
├── README.md
├── requirements.txt
└── src/
    ├── __init__.py
    ├── main.py
    ├── old.py
    ├── production.ipynb
    └── testing.rs
</directory_tree>

<files>

<file>
<path>README.md</path>
<content>
# Project Title

This is an example Python project.
</content>
</file>

<file>
<path>requirements.txt</path>
<content>
numpy==1.21.0
pandas==1.3.0
</content>
</file>

<file>
<path>src/__init__.py</path>
<content>
EMPTY FILE
</content>
</file>

<file>
<path>src/main.py</path>
<content>
import numpy as np
import pandas as pd

def main():
    print("Hello, World!")

if __name__ == "__main__":
    main()
</content>
</file>

<file>
<path>src/production.ipynb</path>
<content>
---------- Cell 1 (markdown) ----------
### Biologically inspired artificial neuron 

$$
y = mx + b
$$

---------- Cell 2 (code) ----------
def neuron(x, m, b):
    return m * x + b


</content>
</file>

</files>
</context>
```

You can then feed this prompt into an LLM to provide it with context about your project 🦾

## Config File 📋

`dir2prompt` uses a config file, `config.json`, to list common directories and files that should be ignored and excluded from the prompt. You can customize the behavior by supplying your own config file using the `--config` option:

**example.json**
```json
{
    "IGNORE_DIRS": [
        "experiments",
        "run*",
        ...
    ],
    "IGNORE_FILES": [
        ".pt",
        ".rs",
        ...
    ]
}
```





## License 📄

`dir2prompt` is released under the MIT License 🤓

## Contributing 🤝

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.



            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dir2prompt",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "prompt engineering, large language model, directory structure, prompt generation, file tree visualization, directory to prompt, automation tools, developer utilities, code documentation",
    "author": null,
    "author_email": "Max Kieffer <wkieffer@ufl.edu>",
    "download_url": "https://files.pythonhosted.org/packages/26/22/57aaf8b9ad4c236b38106df9b51e576dd9487ed3184cea3d1fbbbcbf1e2b/dir2prompt-1.0.13.tar.gz",
    "platform": null,
    "description": "# dir2prompt\n\n[![PyPI version](https://img.shields.io/pypi/v/dir2prompt.svg)](https://pypi.org/project/dir2prompt/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nWhen you feel too lazy to selectively copy code from all the various files in your project, just copy it all! Inspired by [repo2prompt](https://github.com/andrewgcodes/repo2prompt).\n\n## Installation \ud83d\udcbb\n\nYou can install `dir2prompt` using pip:\n\n```sh\npip install dir2prompt\n```\n\n## Usage \ud83d\ude80\n\nTo generate a prompt from a directory, use the `d2p` command followed by the desired options:\n\n```sh\nd2p --dir [directory path] --filters [file extensions] --outpath [output path] --outfile [output file name] --ignore-dir [directories to ignore] --ignore-file [files to ignore] --config [path to config file]\n\n```\n\nFor ease of use, you can select a directory by passing it in as a positional argument\n\n```sh\nd2p [directory path]\n```\n\nIf both the positional argument and the `--dir` flag are provided, the `--dir` flag takes priority.\n\n## Options \u2699\ufe0f\n\n`--dir`: The directory to generate the prompt for (default: current directory).\n\n`--filters`: File extensions to include in the prompt (default: all files).\n\n`--outpath`: The output path for the prompt file (default: current directory).\n\n`--outfile`: The name of the output file (default: `<directory_name>_prompt`).\n\n`--ignore-dir`: Additional directories to ignore (e.g., `experiments`, `run*`).\n\n`--ignore-file`: Additional file types to ignore (e.g., `.pt`, `.rs`).\n\n`--config`: Path to a custom config file (default: `config.json` in the package directory).\n\n## Example \ud83c\udf1f\n\nHere's an example of how to use `dir2prompt` to generate a prompt:\n\n```sh\nd2p --dir project --filters .py .txt .md .ipynb --ignore-dir experiments __pycache__ --ignore-file old.py\n```\n\nThis command will generate a prompt for the specified directory, including only files with the extensions `.py`, `.txt`, `.md`, `.ipynb`, ignoring the `experiments` and `__pycache__` directories, and ignoring the `old.py` file. \n\nNote that ignored directories are not included in the directory tree, but that ignored files are. However, the content of the ignored files will not be written to the final prompt under the `<files>` tag. This might be changed later...\n\nIn this example, the generated prompt will be saved as a `.txt` file in the directory that `d2p` is called in with the name `project_prompt.txt`, and will have the following structure:\n\n**<dir_name>_prompt.txt**\n```xml\n<context>\n<directory_tree>\nproject/\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 requirements.txt\n\u2514\u2500\u2500 src/\n    \u251c\u2500\u2500 __init__.py\n    \u251c\u2500\u2500 main.py\n    \u251c\u2500\u2500 old.py\n    \u251c\u2500\u2500 production.ipynb\n    \u2514\u2500\u2500 testing.rs\n</directory_tree>\n\n<files>\n\n<file>\n<path>README.md</path>\n<content>\n# Project Title\n\nThis is an example Python project.\n</content>\n</file>\n\n<file>\n<path>requirements.txt</path>\n<content>\nnumpy==1.21.0\npandas==1.3.0\n</content>\n</file>\n\n<file>\n<path>src/__init__.py</path>\n<content>\nEMPTY FILE\n</content>\n</file>\n\n<file>\n<path>src/main.py</path>\n<content>\nimport numpy as np\nimport pandas as pd\n\ndef main():\n    print(\"Hello, World!\")\n\nif __name__ == \"__main__\":\n    main()\n</content>\n</file>\n\n<file>\n<path>src/production.ipynb</path>\n<content>\n---------- Cell 1 (markdown) ----------\n### Biologically inspired artificial neuron \n\n$$\ny = mx + b\n$$\n\n---------- Cell 2 (code) ----------\ndef neuron(x, m, b):\n    return m * x + b\n\n\n</content>\n</file>\n\n</files>\n</context>\n```\n\nYou can then feed this prompt into an LLM to provide it with context about your project \ud83e\uddbe\n\n## Config File \ud83d\udccb\n\n`dir2prompt` uses a config file, `config.json`, to list common directories and files that should be ignored and excluded from the prompt. You can customize the behavior by supplying your own config file using the `--config` option:\n\n**example.json**\n```json\n{\n    \"IGNORE_DIRS\": [\n        \"experiments\",\n        \"run*\",\n        ...\n    ],\n    \"IGNORE_FILES\": [\n        \".pt\",\n        \".rs\",\n        ...\n    ]\n}\n```\n\n\n\n\n\n## License \ud83d\udcc4\n\n`dir2prompt` is released under the MIT License \ud83e\udd13\n\n## Contributing \ud83e\udd1d\n\nContributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 mkieffer1107  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Generate prompts for long-context LLMs using the content in your directory",
    "version": "1.0.13",
    "project_urls": {
        "Homepage": "https://github.com/mkieffer1107/dir2prompt",
        "Issues": "https://github.com/mkieffer1107/dir2prompt/issues"
    },
    "split_keywords": [
        "prompt engineering",
        " large language model",
        " directory structure",
        " prompt generation",
        " file tree visualization",
        " directory to prompt",
        " automation tools",
        " developer utilities",
        " code documentation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2efc649041d5039aec06840fc5409aff3074ab2457d25e2ee7ea1856dc8e0413",
                "md5": "ccb19f2f731da5daf7e19e24aea181b3",
                "sha256": "7a2ab9dc76fc32df73f3dbe6caf0139d59d3ab0e7ae61d66b9ba136ef7184c8d"
            },
            "downloads": -1,
            "filename": "dir2prompt-1.0.13-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ccb19f2f731da5daf7e19e24aea181b3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 8433,
            "upload_time": "2024-04-25T23:49:08",
            "upload_time_iso_8601": "2024-04-25T23:49:08.133365Z",
            "url": "https://files.pythonhosted.org/packages/2e/fc/649041d5039aec06840fc5409aff3074ab2457d25e2ee7ea1856dc8e0413/dir2prompt-1.0.13-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "262257aaf8b9ad4c236b38106df9b51e576dd9487ed3184cea3d1fbbbcbf1e2b",
                "md5": "ae2292397946e9cea2b247032a4f52cf",
                "sha256": "b5de79385d0b4c9ca489a3ab21f9391ec54b27a9eff60aad4fe56fd475cb0560"
            },
            "downloads": -1,
            "filename": "dir2prompt-1.0.13.tar.gz",
            "has_sig": false,
            "md5_digest": "ae2292397946e9cea2b247032a4f52cf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 8212,
            "upload_time": "2024-04-25T23:49:09",
            "upload_time_iso_8601": "2024-04-25T23:49:09.833028Z",
            "url": "https://files.pythonhosted.org/packages/26/22/57aaf8b9ad4c236b38106df9b51e576dd9487ed3184cea3d1fbbbcbf1e2b/dir2prompt-1.0.13.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-25 23:49:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mkieffer1107",
    "github_project": "dir2prompt",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "dir2prompt"
}
        
Elapsed time: 3.73635s