slimcontext


Nameslimcontext JSON
Version 0.9.0 PyPI version JSON
download
home_pagehttps://gitlab.com/notorious-community/slimcontext
SummaryA tool to turn a git repository into context for LLMs.
upload_time2025-07-15 04:06:25
maintainerNone
docs_urlNone
authorNeil Schneider
requires_python>=3.10
licenseMIT
keywords llm git context tool chatbot
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SlimContext

SlimContext is a powerful tool designed to extract project structure and generate context for LLM models, offering seamless integration with Git repositories and directories.

## Features

- **Git Repository Integration**: Extract context directly from Git repositories.
- **Directory Traversal**: Supports context generation from a directory of files.
- **File with Imports**: Supports context generation from a file with locally imported modules.
- **Customizable Context Levels**: Generate either `full` or `slim` context based on your needs.
- **Token Counting**: Calculate token usage for popular LLM models like `gpt-4` and `gpt-3.5-turbo`.
- **Flexible Output Options**: Save context to a file or output it to stdout.

## Installation

To install SlimContext, use the following command:

```bash
pip install slimcontext
```

Or install directly from GitLab:

```bash
pip install git+https://gitlab.com/notorious-community/slimcontext.git
```

## Usage

SlimContext can be run via the command line:

```bash
slimcontext --repo-path /path/to/your/git/repo
```

### Options

- `--repo-path, -p`: Path to the Git repository. Defaults to the current directory if not provided.
- `--directory, -d`: Path to a directory to gather files from. **Takes priority over `--repo-path`**.
- `--file, -f`: Path to a file to generate context for. **Takes priority over `--repo-path` and `-directory`**.
- `--context-level, -c`: Level of context to generate (`full` or `slim`). Default is `full`.
- `--output, -o`: Path to save the output file. Defaults to stdout if not provided.
- `--token-model, -t`: Model name for token counting (`gpt-4`, `gpt-3.5-turbo`, or `none`). Default is `gpt-4`.
- `--include-ext, -x`: Additional file extensions (e.g., `.txt`, `.cfg`) to include alongside default recognized code files.
- `--only-ext, -X`: Restrict context generation to only the specified extensions. This overrides the default extension behavior.
- `--verbose, -v`: Increase verbosity (use `-v` for INFO and `-vv` for DEBUG).

### Example

```bash
slimcontext -d /path/to/directory -c slim -o output.txt -t gpt-4 -v
```

This command generates a slim context from the specified directory, counts tokens using `gpt-4`, and saves the result to `output.txt`.

### Directory Support

SlimContext supports extracting context directly from directories:

- Use `--directory` to specify the directory.
- All files within the directory (and subdirectories) will be processed.

Example:

```bash
slimcontext --directory /path/to/files -c full -o context.txt
```

### File Support

SlimContext supports extracting context directly from file and modules imported in that file:

- Use `--file` to specify the direcfiletory.
- All local modules loaded in the file will also be included in the output.

Example:

```bash
slimcontext --file /path/to/file.py -c full -o context.txt
```

### Extension Filtering

SlimContext allows fine-grained control over which file types to include:

- Use `--include-ext` to **add additional file extensions** to the default list (e.g., `.txt`, `.cfg`).
- Use `--only-ext` to **limit output strictly to certain extensions**, overriding all default behavior.

#### Example: Include additional file types

```bash
slimcontext --directory ./my_project -x .cfg -x .txt
```

This will include `.cfg` and `.txt` files in addition to the default recognized file types.

#### Example: Restrict to specific file types

```bash
slimcontext --directory ./my_project -X .py -X .ts
```

This will only include .py and .ts files in the output, skipping all others.

## Logging

Use the `-v` or `-vv` flags to control verbosity:

- `-v`: INFO level logs.
- `-vv`: DEBUG level logs.

## Development

### Setting Up the Development Environment

1. **Clone the Repository:**

    ```bash
    git clone https://gitlab.com/notorious-community/slimcontext.git
    cd slimcontext
    ```

2. **Install Dependencies:**

    Ensure you have `poetry` installed. Then run:

    ```bash
    poetry install
    ```

### Running Tests

The package includes a comprehensive test suite using `pytest`.

```bash
poetry run pytest
```

### Linting and Formatting

Ensure code quality and consistency with `ruff`.

```bash
poetry run ruff check .
```

### Running Nox Sessions

Automate development tasks across multiple Python environments using `nox`.

```bash
nox -s tests
```

## Project Structure

```
slimcontext/
├── slimcontext/
│   ├── main.py
│   ├── managers/  # Houses various managers for languages.
│   ├── parsers/  # Houses the code to parse and extract key context by language.
│   └── utils/  # Various utilities used across code base.
├── tests/ 
├── gitlab-ci.yml
├── CHANGELOG
├── LICENSE
├── noxfile.py
├── pyproject.toml
└── README.md
```

## Contributions

Contributions are welcome! Whether it's reporting bugs, suggesting features, or submitting pull requests, your help is appreciated. Please follow these steps to contribute:

1. **Fork the Repository:**

    Click the "Fork" button at the top right of the repository page.

2. **Clone Your Fork:**

    ```bash
    git clone https://gitlab.com/your-username/slimcontext.git
    cd slimcontext
    ```

3. **Create a New Branch:**

    ```bash
    git checkout -b feature/your-feature-name
    ```

4. **Make Your Changes:**

    Implement your feature or bug fix.

5. **Commit Your Changes:**

    ```bash
    git commit -m "Title of your changes" -m "Describe **Why** you made this change."
    ```

6. **Push to Your Fork:**

    ```bash
    git push origin feature/your-feature-name
    ```

7. **Create a Merge Request:**

    Go to the original repository and create a merge request from your fork.

Please ensure all tests pass and adhere to the project's coding standards before submitting your merge request.

## License

This project is licensed under the [MIT License](LICENSE). See the [LICENSE](LICENSE) file for details.

---

**Copyright (c) 2024 Neil Schneider**

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/notorious-community/slimcontext",
    "name": "slimcontext",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "LLM, Git, Context, Tool, ChatBot",
    "author": "Neil Schneider",
    "author_email": "schneider.neil@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/54/a9/a6f0960b8894c46827ef3e47c5276b294b94b739b2e9115ffa397a4ba1b4/slimcontext-0.9.0.tar.gz",
    "platform": null,
    "description": "# SlimContext\n\nSlimContext is a powerful tool designed to extract project structure and generate context for LLM models, offering seamless integration with Git repositories and directories.\n\n## Features\n\n- **Git Repository Integration**: Extract context directly from Git repositories.\n- **Directory Traversal**: Supports context generation from a directory of files.\n- **File with Imports**: Supports context generation from a file with locally imported modules.\n- **Customizable Context Levels**: Generate either `full` or `slim` context based on your needs.\n- **Token Counting**: Calculate token usage for popular LLM models like `gpt-4` and `gpt-3.5-turbo`.\n- **Flexible Output Options**: Save context to a file or output it to stdout.\n\n## Installation\n\nTo install SlimContext, use the following command:\n\n```bash\npip install slimcontext\n```\n\nOr install directly from GitLab:\n\n```bash\npip install git+https://gitlab.com/notorious-community/slimcontext.git\n```\n\n## Usage\n\nSlimContext can be run via the command line:\n\n```bash\nslimcontext --repo-path /path/to/your/git/repo\n```\n\n### Options\n\n- `--repo-path, -p`: Path to the Git repository. Defaults to the current directory if not provided.\n- `--directory, -d`: Path to a directory to gather files from. **Takes priority over `--repo-path`**.\n- `--file, -f`: Path to a file to generate context for. **Takes priority over `--repo-path` and `-directory`**.\n- `--context-level, -c`: Level of context to generate (`full` or `slim`). Default is `full`.\n- `--output, -o`: Path to save the output file. Defaults to stdout if not provided.\n- `--token-model, -t`: Model name for token counting (`gpt-4`, `gpt-3.5-turbo`, or `none`). Default is `gpt-4`.\n- `--include-ext, -x`: Additional file extensions (e.g., `.txt`, `.cfg`) to include alongside default recognized code files.\n- `--only-ext, -X`: Restrict context generation to only the specified extensions. This overrides the default extension behavior.\n- `--verbose, -v`: Increase verbosity (use `-v` for INFO and `-vv` for DEBUG).\n\n### Example\n\n```bash\nslimcontext -d /path/to/directory -c slim -o output.txt -t gpt-4 -v\n```\n\nThis command generates a slim context from the specified directory, counts tokens using `gpt-4`, and saves the result to `output.txt`.\n\n### Directory Support\n\nSlimContext supports extracting context directly from directories:\n\n- Use `--directory` to specify the directory.\n- All files within the directory (and subdirectories) will be processed.\n\nExample:\n\n```bash\nslimcontext --directory /path/to/files -c full -o context.txt\n```\n\n### File Support\n\nSlimContext supports extracting context directly from file and modules imported in that file:\n\n- Use `--file` to specify the direcfiletory.\n- All local modules loaded in the file will also be included in the output.\n\nExample:\n\n```bash\nslimcontext --file /path/to/file.py -c full -o context.txt\n```\n\n### Extension Filtering\n\nSlimContext allows fine-grained control over which file types to include:\n\n- Use `--include-ext` to **add additional file extensions** to the default list (e.g., `.txt`, `.cfg`).\n- Use `--only-ext` to **limit output strictly to certain extensions**, overriding all default behavior.\n\n#### Example: Include additional file types\n\n```bash\nslimcontext --directory ./my_project -x .cfg -x .txt\n```\n\nThis will include `.cfg` and `.txt` files in addition to the default recognized file types.\n\n#### Example: Restrict to specific file types\n\n```bash\nslimcontext --directory ./my_project -X .py -X .ts\n```\n\nThis will only include .py and .ts files in the output, skipping all others.\n\n## Logging\n\nUse the `-v` or `-vv` flags to control verbosity:\n\n- `-v`: INFO level logs.\n- `-vv`: DEBUG level logs.\n\n## Development\n\n### Setting Up the Development Environment\n\n1. **Clone the Repository:**\n\n    ```bash\n    git clone https://gitlab.com/notorious-community/slimcontext.git\n    cd slimcontext\n    ```\n\n2. **Install Dependencies:**\n\n    Ensure you have `poetry` installed. Then run:\n\n    ```bash\n    poetry install\n    ```\n\n### Running Tests\n\nThe package includes a comprehensive test suite using `pytest`.\n\n```bash\npoetry run pytest\n```\n\n### Linting and Formatting\n\nEnsure code quality and consistency with `ruff`.\n\n```bash\npoetry run ruff check .\n```\n\n### Running Nox Sessions\n\nAutomate development tasks across multiple Python environments using `nox`.\n\n```bash\nnox -s tests\n```\n\n## Project Structure\n\n```\nslimcontext/\n\u251c\u2500\u2500 slimcontext/\n\u2502   \u251c\u2500\u2500 main.py\n\u2502   \u251c\u2500\u2500 managers/  # Houses various managers for languages.\n\u2502   \u251c\u2500\u2500 parsers/  # Houses the code to parse and extract key context by language.\n\u2502   \u2514\u2500\u2500 utils/  # Various utilities used across code base.\n\u251c\u2500\u2500 tests/ \n\u251c\u2500\u2500 gitlab-ci.yml\n\u251c\u2500\u2500 CHANGELOG\n\u251c\u2500\u2500 LICENSE\n\u251c\u2500\u2500 noxfile.py\n\u251c\u2500\u2500 pyproject.toml\n\u2514\u2500\u2500 README.md\n```\n\n## Contributions\n\nContributions are welcome! Whether it's reporting bugs, suggesting features, or submitting pull requests, your help is appreciated. Please follow these steps to contribute:\n\n1. **Fork the Repository:**\n\n    Click the \"Fork\" button at the top right of the repository page.\n\n2. **Clone Your Fork:**\n\n    ```bash\n    git clone https://gitlab.com/your-username/slimcontext.git\n    cd slimcontext\n    ```\n\n3. **Create a New Branch:**\n\n    ```bash\n    git checkout -b feature/your-feature-name\n    ```\n\n4. **Make Your Changes:**\n\n    Implement your feature or bug fix.\n\n5. **Commit Your Changes:**\n\n    ```bash\n    git commit -m \"Title of your changes\" -m \"Describe **Why** you made this change.\"\n    ```\n\n6. **Push to Your Fork:**\n\n    ```bash\n    git push origin feature/your-feature-name\n    ```\n\n7. **Create a Merge Request:**\n\n    Go to the original repository and create a merge request from your fork.\n\nPlease ensure all tests pass and adhere to the project's coding standards before submitting your merge request.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE). See the [LICENSE](LICENSE) file for details.\n\n---\n\n**Copyright (c) 2024 Neil Schneider**\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A tool to turn a git repository into context for LLMs.",
    "version": "0.9.0",
    "project_urls": {
        "Homepage": "https://gitlab.com/notorious-community/slimcontext"
    },
    "split_keywords": [
        "llm",
        " git",
        " context",
        " tool",
        " chatbot"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9f36b993dce676fd8f3422ae86c43d72db1047bbc690c6b274fac2a776d9acca",
                "md5": "93216d908977d1782f78a534c9bfebcb",
                "sha256": "762657f5499582807cd628688b4864f9cd6d8d4e13639ec22157623be3b349c0"
            },
            "downloads": -1,
            "filename": "slimcontext-0.9.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "93216d908977d1782f78a534c9bfebcb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 33831,
            "upload_time": "2025-07-15T04:06:24",
            "upload_time_iso_8601": "2025-07-15T04:06:24.659552Z",
            "url": "https://files.pythonhosted.org/packages/9f/36/b993dce676fd8f3422ae86c43d72db1047bbc690c6b274fac2a776d9acca/slimcontext-0.9.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "54a9a6f0960b8894c46827ef3e47c5276b294b94b739b2e9115ffa397a4ba1b4",
                "md5": "4d294e8af0eec394e8b62be2521a065c",
                "sha256": "50c1ded482ba1fab2247e6b9111ad95258e5354cf5b694d70cb963acff6cfd7a"
            },
            "downloads": -1,
            "filename": "slimcontext-0.9.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4d294e8af0eec394e8b62be2521a065c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 24565,
            "upload_time": "2025-07-15T04:06:25",
            "upload_time_iso_8601": "2025-07-15T04:06:25.455237Z",
            "url": "https://files.pythonhosted.org/packages/54/a9/a6f0960b8894c46827ef3e47c5276b294b94b739b2e9115ffa397a4ba1b4/slimcontext-0.9.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-15 04:06:25",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "notorious-community",
    "gitlab_project": "slimcontext",
    "lcname": "slimcontext"
}
        
Elapsed time: 0.63754s