### Install Dependencies with UV Source: https://github.com/coderamp-labs/gitrules/blob/main/CLAUDE.md Installs project dependencies listed in requirements.txt using the 'uv pip' command. ```bash uv pip install -r requirements.txt ``` -------------------------------- ### Run Development Server with Uvicorn Source: https://github.com/coderamp-labs/gitrules/blob/main/CLAUDE.md Starts the development server using 'uvicorn', pointing to the application instance in app.main. ```bash uvicorn app.main:app --reload ``` -------------------------------- ### MinIO Setup Script Example Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md A bash script to configure MinIO, creating a bucket and setting access credentials. This script is executed by the 'minio-setup' service. ```bash #!/bin/sh # Set MinIO environment variables export MINIO_ROOT_USER="${MINIO_ROOT_USER}" export MINIO_ROOT_PASSWORD="${MINIO_ROOT_PASSWORD}" # Wait for MinIO to be ready (optional, but good practice) # In a real scenario, you might want a more robust check # For simplicity, we assume it's ready after the healthcheck passes in docker-compose # Create the bucket if it doesn't exist /usr/bin/mc mb "s3://${S3_BUCKET_NAME}" --ignore-existing # Configure credentials (if needed, mc alias set is often used for this) # For this setup, we rely on the environment variables passed to the container # and assume the application will use them directly or via mc alias if needed. # Example of setting an alias (if your application uses mc): # /usr/bin/mc alias set myminio http://minio:9000 ${S3_ACCESS_KEY} ${S3_SECRET_KEY} # Exit successfully exit 0 ``` -------------------------------- ### Docker Compose MinIO Setup Script Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Defines the 'minio-setup' service which uses the 'minio/mc' image to execute a setup script. This script initializes the MinIO server by creating a bucket and setting up user credentials, ensuring it's ready before the application starts. ```yaml # MinIO setup service to create bucket and user minio-setup: image: minio/mc profiles: - dev depends_on: minio: condition: service_healthy environment: <<: *minio-environment S3_ACCESS_KEY: ${S3_ACCESS_KEY:-gitingest} S3_SECRET_KEY: ${S3_SECRET_KEY:-gitingest123} S3_BUCKET_NAME: ${S3_BUCKET_NAME:-gitingest-bucket} volumes: - ./.docker/minio/setup.sh:/setup.sh:ro entrypoint: sh command: -c /setup.sh ``` -------------------------------- ### Install GitIngest Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Instructions for installing the GitIngest package using pip. Supports virtual environments, requirements.txt, and installation with server or development dependencies. ```bash python -m venv gitingest-env source gitingest-env/bin/activate # On Windows: gitingest-env\Scripts\activate pip install gitingest # Or add to requirements.txt echo "gitingest" >> requirements.txt pip install -r requirements.txt # For self-hosting: Install with server dependencies pip install gitingest[server] # For development: Install with dev dependencies pip install gitingest[dev,server] ``` -------------------------------- ### Set Up Gitingest Development Environment Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Sets up a Python virtual environment, installs project dependencies including development and server extras, and installs pre-commit hooks. ```bash python -m venv .venv source .venv/bin/activate pip install -e ".[dev,server]" pre-commit install ``` -------------------------------- ### Install MCP Source: https://github.com/coderamp-labs/gitrules/blob/main/app/templates/components/workspace_actions.html Installs an MCP by fetching its configuration and updating the workspace state. It reads the current MCP configuration from '.mcp.json', sends it to the API, and then saves the returned configuration and content. ```javascript async function installMCP(mcpName) { try { let currentConfig = {}; if (window.workspaceManager && window.workspaceManager.getState()) { const mcpFile = window.workspaceManager.getState().files['.mcp.json']; if (mcpFile) { try { currentConfig = JSON.parse(mcpFile); } catch (e) { currentConfig = {}; } } } const response = await fetch(`/api/actions/mcp-config/${encodeURIComponent(mcpName)}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(currentConfig) }); if (response.ok) { const result = await response.json(); if (window.workspaceManager && window.workspaceManager.currentState) { window.workspaceManager.currentState.addFile(result.path, result.content); window.workspaceManager.saveState(window.workspaceManager.currentContextId); window.workspaceManager.render(); } } } catch (error) { console.error(`Error installing MCP: ${error.message}`); } } ``` -------------------------------- ### Install Dependencies with uv Source: https://github.com/coderamp-labs/gitrules/blob/main/README.md Installs project dependencies using the 'uv' package manager by reading from the requirements.txt file. ```bash uv pip install -r requirements.txt ``` -------------------------------- ### CoD Example A: Search Source: https://github.com/coderamp-labs/gitrules/blob/main/app/actions/agents/code-searcher.md An in-context example demonstrating the CoD style for a code search query, showing the breakdown of the task into goal, glob, grep, found location, and implementation details. ```English Q: "Find where login is implemented" - CoD: - "Goal→auth login" - "Glob→*auth*:*service*,*controller*" - "Grep→login|authenticate" - "Found→src/services/auth.service.ts:42-89" - "Implements→JWT∧bcrypt" - "#### src/services/auth.service.ts:42-89" ``` -------------------------------- ### Install Pipx Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Provides commands to install pipx, a Python utility for managing isolated Python installations. It shows common installation methods using package managers like Homebrew, apt, and scoop. ```bash brew install pipx ``` ```bash apt install pipx ``` ```bash scoop install pipx ``` -------------------------------- ### Inspect Install Script Source: https://github.com/coderamp-labs/gitrules/blob/main/README.md Fetches the installation script from the Gitrules application for manual inspection before execution, ensuring security. ```shell curl -fsSL http://localhost:8000/api/install/.sh ``` -------------------------------- ### MCP Configuration Installation Source: https://github.com/coderamp-labs/gitrules/blob/main/app/templates/components/quick_actions.html Installs an MCP configuration into the workspace. It fetches the MCP configuration from the API, merges it with existing `.mcp.json` content if available, and updates the virtual workspace. ```javascript async function installMCPInContext(mcpName) { try { // Get current .mcp.json content from workspace let currentConfig = {}; if (window.workspaceManager && window.workspaceManager.getState()) { const mcpFile = window.workspaceManager.getState().files['.mcp.json']; if (mcpFile) { try { currentConfig = JSON.parse(mcpFile); } catch (e) { currentConfig = {}; } } } const response = await fetch(`/api/actions/mcp-config/${encodeURIComponent(mcpName)}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(currentConfig) }); if (response.ok) { const result = await response.json(); // Add to virtual workspace if (window.workspaceManager && window.workspaceManager.currentState) { window.workspaceManager.currentState.addFile(result.path, result.content); window.workspaceManager.saveState(window.workspaceManager.currentContextId); window.workspaceManager.render(); } } else { const error = await response.json(); console.error(`Error: ${error.detail}`); } } catch (error) { console.error(`Error installing MCP: ${error.message}`); } } ``` -------------------------------- ### Docker Compose Usage Examples Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Provides command-line examples for running the GitIngest application using Docker Compose in development and production modes, including options for building the image. ```bash # To run the application in development mode: docker compose --profile dev up # To run the application in production mode: docker compose --profile prod up -d # To build and run the application: docker compose --profile prod build docker compose --profile prod up -d ``` -------------------------------- ### Install GitIngest CLI Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Installs the GitIngest command-line interface using pipx for an isolated environment or pip as an alternative. Includes verification of the installation. ```bash # Best practice: Use pipx for CLI tools (isolated environment) pipx install gitingest # Alternative: Use pip (may conflict with other packages) pip install gitingest # Verify installation gitingest --help ``` -------------------------------- ### One-Click Install Script Source: https://github.com/coderamp-labs/gitrules/blob/main/README.md A shell command to download and execute an installation script from the Gitrules application. This script recreates files and sets up the repository context. It's recommended to inspect the script before execution. ```shell sh -c "$(curl -fsSL http://localhost:8000/api/install/.sh)" ``` -------------------------------- ### Select Search Result and Install Action Source: https://github.com/coderamp-labs/gitrules/blob/main/app/templates/components/workspace_actions.html Handles the selection of a search result, clearing the search input, hiding results, and then installing the selected action (MCP, Rule, or Agent) based on its type. ```JavaScript async function selectSearchResult(name, type) { const resultsContainer = document.getElementById('search-results'); const searchInput = document.querySelector('.search-input'); // Clear search searchInput.value = ''; resultsContainer.style.display = 'none'; // Install the selected action if (type === 'MCP') { await installMCP(name); } else if (type === 'Rule') { await installRule(name); } else if (type === 'Agent') { await installAgent(name); } } ``` -------------------------------- ### Example Repository Buttons Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Renders buttons for example repositories that can be used to quickly test the GitIngest functionality. Clicking a button submits the repository URL. ```Jinja {% if show_examples %}

Try these example repositories:

{% for example in examples %} {% endfor %}
{% endif %} ``` -------------------------------- ### Environment Variables Example Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Provides example environment variables for configuring the Gitingest application. It covers host configuration, GitHub authentication, metrics, Sentry error tracking, and MinIO/S3 storage settings. ```dotenv # Gitingest Environment Variables # Host Configuration # Comma-separated list of allowed hostnames # Default: "gitingest.com, *.gitingest.com, localhost, 127.0.0.1" ALLOWED_HOSTS=gitingest.com,*.gitingest.com,localhost,127.0.0.1 # GitHub Authentication # Personal Access Token for accessing private repositories # Generate your token here: https://github.com/settings/tokens/new?description=gitingest&scopes=repo # GITHUB_TOKEN=your_github_token_here # Metrics Configuration # Set to any value to enable the Prometheus metrics server # GITINGEST_METRICS_ENABLED=true # Host for the metrics server (default: "127.0.0.1") GITINGEST_METRICS_HOST=127.0.0.1 # Port for the metrics server (default: "9090") GITINGEST_METRICS_PORT=9090 # Sentry Configuration # Set to any value to enable Sentry error tracking # GITINGEST_SENTRY_ENABLED=true # Sentry DSN (required if Sentry is enabled) # GITINGEST_SENTRY_DSN=your_sentry_dsn_here # Sampling rate for performance data (default: "1.0", range: 0.0-1.0) GITINGEST_SENTRY_TRACES_SAMPLE_RATE=1.0 # Sampling rate for profile sessions (default: "1.0", range: 0.0-1.0) GITINGEST_SENTRY_PROFILE_SESSION_SAMPLE_RATE=1.0 # Profile lifecycle mode (default: "trace") GITINGEST_SENTRY_PROFILE_LIFECYCLE=trace # Send default personally identifiable information (default: "true") GITINGEST_SENTRY_SEND_DEFAULT_PII=true # Environment name for Sentry (default: "") GITINGEST_SENTRY_ENVIRONMENT=development # MinIO Configuration (for development) # Root user credentials for MinIO admin access MINIO_ROOT_USER=minioadmin MINIO_ROOT_PASSWORD=minioadmin # S3 Configuration (for application) # Set to "true" to enable S3 storage for digests # S3_ENABLED=true # Endpoint URL for the S3 service (MinIO in development) S3_ENDPOINT=http://minio:9000 # Access key for the S3 bucket (created automatically in development) S3_ACCESS_KEY=gitingest # Secret key for the S3 bucket (created automatically in development) S3_SECRET_KEY=gitingest123 # Name of the S3 bucket (created automatically in development) S3_BUCKET_NAME=gitingest-bucket # Region for the S3 bucket (default for MinIO) S3_REGION=us-east-1 # Public URL/CDN for accessing S3 resources S3_ALIAS_HOST=127.0.0.1:9000/gitingest-bucket # Optional prefix for S3 file paths (if set, prefixes all S3 paths with this value) ``` -------------------------------- ### Gitingest Server Startup Script Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md This script configures and starts the Gitingest FastAPI server. It loads environment variables, initializes logging, sets up Sentry SDK if enabled, configures rate limiting, mounts static files, and optionally starts a metrics server in a separate thread. The server is run using uvicorn. ```Python import os import threading from pathlib import Path import sentry_sdk from dotenv import load_dotenv from fastapi import FastAPI, Request from fastapi.responses import FileResponse, HTMLResponse, JSONResponse from fastapi.staticfiles import StaticFiles from slowapi.errors import RateLimitExceeded from starlette.middleware.trustedhost import TrustedHostMiddleware # Import logging configuration first to intercept all logging from gitingest.utils.logging_config import get_logger from server.metrics_server import start_metrics_server from server.routers import dynamic, index, ingest from server.server_config import get_version_info, templates from server.server_utils import limiter, rate_limit_exception_handler # Load environment variables from .env file load_dotenv() # Initialize logger for this module logger = get_logger(__name__) # Initialize Sentry SDK if enabled if os.getenv("GITINGEST_SENTRY_ENABLED") is not None: sentry_dsn = os.getenv("GITINGEST_SENTRY_DSN") # Only initialize Sentry if DSN is provided if sentry_dsn: # Configure Sentry options from environment variables traces_sample_rate = float(os.getenv("GITINGEST_SENTRY_TRACES_SAMPLE_RATE", "1.0")) profile_session_sample_rate = float(os.getenv("GITINGEST_SENTRY_PROFILE_SESSION_SAMPLE_RATE", "1.0")) profile_lifecycle_raw = os.getenv("GITINGEST_SENTRY_PROFILE_LIFECYCLE", "trace") profile_lifecycle = profile_lifecycle_raw if profile_lifecycle_raw in ("manual", "trace") else "trace" send_default_pii = os.getenv("GITINGEST_SENTRY_SEND_DEFAULT_PII", "true").lower() == "true" sentry_environment = os.getenv("GITINGEST_SENTRY_ENVIRONMENT", "") sentry_sdk.init( dsn=sentry_dsn, # Add data like request headers and IP for users send_default_pii=send_default_pii, # Set traces_sample_rate to capture transactions for tracing traces_sample_rate=traces_sample_rate, # Set profile_session_sample_rate to profile sessions profile_session_sample_rate=profile_session_sample_rate, # Set profile_lifecycle to automatically run the profiler profile_lifecycle=profile_lifecycle, # Set environment name environment=sentry_environment, ) # Initialize the FastAPI application app = FastAPI(docs_url=None, redoc_url=None) app.state.limiter = limiter # Register the custom exception handler for rate limits app.add_exception_handler(RateLimitExceeded, rate_limit_exception_handler) # Start metrics server in a separate thread if enabled if os.getenv("GITINGEST_METRICS_ENABLED") is not None: metrics_host = os.getenv("GITINGEST_METRICS_HOST", "127.0.0.1") metrics_port = int(os.getenv("GITINGEST_METRICS_PORT", "9090")) metrics_thread = threading.Thread( target=start_metrics_server, args=(metrics_host, metrics_port), daemon=True, ) metrics_thread.start() # Mount static files dynamically to serve CSS, JS, and other static assets static_dir = Path(__file__).parent.parent / "static" app.mount("/static", StaticFiles(directory=static_dir), name="static") ``` -------------------------------- ### Install Dependencies with UV Source: https://github.com/coderamp-labs/gitrules/blob/main/app/actions/rules/use-uv.md Shows how to install project dependencies using UV from either a requirements.txt or pyproject.toml file. ```shell uv pip install -r requirements.txt ``` ```shell uv pip install -r pyproject.toml ``` -------------------------------- ### Install Rule Source: https://github.com/coderamp-labs/gitrules/blob/main/app/templates/components/workspace_actions.html Installs a rule by fetching its content and appending it to the CLAUDE.md file. It retrieves the rule content from an API endpoint and updates the CLAUDE.md file in the workspace state. ```javascript async function installRule(ruleName) { try { const response = await fetch(`/api/actions/rule-content/${encodeURIComponent(ruleName)}`); if (response.ok) { const result = await response.json(); let currentContent = ''; if (window.workspaceManager && window.workspaceManager.getState()) { const claudeFile = window.workspaceManager.getState().files['CLAUDE.md']; if (claudeFile) { currentContent = claudeFile; } } const ruleContent = result.content.trim(); const newContent = currentContent + (currentContent ? '\n' : '') + ruleContent; if (window.workspaceManager && window.workspaceManager.currentState) { window.workspaceManager.currentState.addFile('CLAUDE.md', newContent); window.workspaceManager.saveState(window.workspaceManager.currentContextId); window.workspaceManager.render(); } } } catch (error) { console.error(`Error installing rule: ${error.message}`); } } ``` -------------------------------- ### Agent Installation Source: https://github.com/coderamp-labs/gitrules/blob/main/app/templates/components/quick_actions.html Installs an agent into the current workspace context by fetching its content from the API and adding it to the virtual workspace. Handles API errors and network issues. ```javascript async function installAgentInContext(agentName) { try { const response = await fetch(`/api/actions/agent-content/${encodeURIComponent(agentName)}`); if (response.ok) { const result = await response.json(); // Add to virtual workspace if (window.workspaceManager && window.workspaceManager.currentState) { window.workspaceManager.currentState.addFile(result.path, result.content); window.workspaceManager.saveState(window.workspaceManager.currentContextId); window.workspaceManager.render(); } } else { const error = await response.json(); console.error(`Error: ${error.detail}`); } } catch (error) { console.error(`Error installing agent: ${error.message}`); } } ``` -------------------------------- ### CLI Usage Example with Piping Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md An example of using the GitIngest CLI to pipe the processed repository content directly to an AI processor. ```bash # CLI usage - pipe directly to your AI system gitingest https://github.com/octocat/Hello-World -o - | your_llm_processor # Output streams the complete formatted text: # Repository: octocat/hello-world # Files analyzed: 1 # Estimated tokens: 29 # # Directory structure: # └── octocat-hello-world/ # └── README # # ================================================ # FILE: README # ================================================ # Hello World! ``` -------------------------------- ### CoD Example B: Bug Trace Source: https://github.com/coderamp-labs/gitrules/blob/main/app/actions/agents/code-searcher.md An in-context example illustrating the CoD format for tracing a bug, including the goal, glob pattern, grep terms, file location, identified cause, and suggested fix. ```English Q: "Payment processing NPE on checkout" - CoD: - "Goal→payment NPE" - "Glob→payment* process*" - "Grep→processPayment|null" - "Found→src/payments/pay.ts:89" - "Cause→missing-null-check" - "Fix→add:if(tx?.amount)→validate-input" - "#### src/payments/pay.ts:89 Cause:missing-null-check Fix:add-null-check" ``` -------------------------------- ### CoD Symbolic Notation Guide Source: https://github.com/coderamp-labs/gitrules/blob/main/app/actions/agents/code-searcher.md Provides a comprehensive guide to the symbolic notation used in the CoD methodology for representing logic, quantifiers, operations, structure, and common programming shortcuts. ```English Symbolic Notation Guide: - Logic: ∧(AND), ∨(OR), ¬(NOT), →(implies), ↔(iff) - Quantifiers: ∀(all), ∃(exists), ∄(not exists), ∑(sum) - Operations: :=(assign), ==(equals), !=(not equals), ∈(in), ∉(not in) - Structure: {}(object), [](array), ()(function), <>(generic) - Shortcuts: fn(function), cls(class), impl(implements), ext(extends) ``` -------------------------------- ### Run Gitingest Local Server Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Starts the local development server for Gitingest, accessible at http://localhost:8000. ```bash python -m server ``` -------------------------------- ### CoD Example C: Security Analysis Source: https://github.com/coderamp-labs/gitrules/blob/main/app/actions/agents/code-searcher.md An in-context example showcasing the CoD style for security analysis, focusing on identifying vulnerabilities like SQL injection, specifying the pattern, location, risk, and mitigation strategy. ```English Q: "Find SQL injection vulnerabilities in user input" - CoD: - "Goal→SQL-inject vuln" - "Grep→query.*input|req\..*sql" - "Found→src/db/users.ts:45" - "Vuln→direct-string-concat" - "Risk→HIGH:data-breach" - "Fix→prepared-statements+sanitize" - "#### src/db/users.ts:45 Risk:HIGH Fix:prepared-statements" ``` -------------------------------- ### Python Package Usage Example Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md A Python code example demonstrating how to use the `ingest` function from the GitIngest library to process a GitHub repository and combine the output for AI processing. ```python # Python package usage from gitingest import ingest summary, tree, content = ingest("https://github.com/octocat/Hello-World") # Returns exactly: # summary = "Repository: octocat/hello-world\nFiles analyzed: 1\nEstimated tokens: 29" # tree = "Directory structure:\n└── octocat-hello-world/\n └── README" # content = "================================================\nFILE: README\n================================================\nHello World!\n\n\n" # For AI processing, combine all sections: full_context = f"{summary}\n\n{tree}\n\n{content}" ``` -------------------------------- ### Prometheus Metrics Server Setup Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Initializes a FastAPI application for serving Prometheus metrics. It imports necessary components like uvicorn, FastAPI, and Prometheus client utilities. ```python """Prometheus metrics server running on a separate port.""" import uvicorn from fastapi import FastAPI from fastapi.responses import HTMLResponse from prometheus_client import REGISTRY, generate_latest from gitingest.utils.logging_config import get_logger # Create a logger for this module logger = get_logger(__name__) ``` -------------------------------- ### Run Development Server Source: https://github.com/coderamp-labs/gitrules/blob/main/README.md Starts the FastAPI development server using uvicorn, enabling hot-reloading for rapid development. The server is accessible at http://localhost:8000. ```bash uvicorn app.main:app --reload ``` -------------------------------- ### FastAPI Home Page Router Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Serves the home page of the application, rendering the 'index.jinja' template with example repositories and default parameters. ```Python from fastapi import APIRouter, Request from fastapi.responses import HTMLResponse from server.server_config import EXAMPLE_REPOS, get_version_info, templates router = APIRouter() @router.get("/", response_class=HTMLResponse, include_in_schema=False) async def home(request: Request) -> HTMLResponse: """Render the home page with example repositories and default parameters. This endpoint serves the home page of the application, rendering the ``index.jinja`` template and providing it with a list of example repositories and default file size values. Parameters ---------- request : Request The incoming request object, which provides context for rendering the response. Returns ------- HTMLResponse An HTML response containing the rendered home page template, with example repositories and other default parameters such as file size. """ context = { "request": request, "examples": EXAMPLE_REPOS, "default_max_file_size": 243, } context.update(get_version_info()) return templates.TemplateResponse("index.jinja", context) ``` -------------------------------- ### CoD Search Process Phases Source: https://github.com/coderamp-labs/gitrules/blob/main/app/actions/agents/code-searcher.md Details the three phases of the CoD search process: Goal Abstraction, Search Execution, and Synthesis, including token budgets and symbolic notation examples for each phase. ```English Phase 1: Goal Abstraction (≤5 tokens) Goal→Keywords→Scope - Strip context, extract operation - Example: "find user auth in React app" → "auth→react→*.tsx" Phase 2: Search Execution (≤10 tokens/step) Tool[params]→Count→Paths - Glob[pattern]→n files - Grep[regex]→m matches - Read[file:lines]→logic Phase 3: Synthesis (≤15 tokens) Pattern→Location→Implementation - Use symbols: ∧(and), ∨(or), →(leads to), ∃(exists), ∀(all) - Example: "JWT∧bcrypt→auth.service:45-89→middleware+validation" ``` -------------------------------- ### Python GET Ingestion Logic Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Example Python code for handling GET requests to ingest a repository, constructing the input text from path parameters, and updating metrics. ```Python response = await _perform_ingestion( input_text=f"{user}/{repository}", max_file_size=max_file_size, pattern_type=pattern_type, pattern=pattern, token=token or None, ) # limit URL to 255 characters ingest_counter.labels(status=response.status_code, url=f"{user}/{repository}"[:255]).inc() return response ``` -------------------------------- ### MinIO Setup and Policy Application Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md This snippet demonstrates how to set up MinIO by creating a policy and attaching it to a user. It includes commands for policy creation and attachment, along with output messages indicating successful completion and access information. ```shell mc admin policy create myminio gitingest-policy /tmp/policy.json || echo "Policy already exists" mc admin policy attach myminio gitingest-policy --user ${S3_ACCESS_KEY} echo "MinIO setup completed successfully" echo "Bucket: ${BUCKET_NAME}" echo "Access via console: http://localhost:9001" ``` -------------------------------- ### Install Gitingest with Pip Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Installs the Gitingest package using pip, the Python package installer. This command fetches and installs the latest version of Gitingest from the Python Package Index (PyPI). ```bash pip install gitingest ``` -------------------------------- ### GitIngest AI Agent Quick-Start Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Demonstrates quick-start methods for integrating GitIngest with AI agents using CLI, Python, and a URL hack. ```bash # CLI gitingest https://github.com/user/repo -o - | your-llm # Python from gitingest import ingest; s,t,c = ingest('repo-url'); process(c) # URL Hack Replace `github.com` → `gitingest.com` in any GitHub URL ``` -------------------------------- ### Install Gitingest with Pipx Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Installs Gitingest using pipx, a tool for installing and running Python applications in isolated environments. This method is recommended for CLI tools to avoid dependency conflicts. ```bash pipx install gitingest ``` -------------------------------- ### Verify GitIngest Installation Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Commands to verify that GitIngest has been installed correctly, both via the CLI and as a Python package. ```bash # Test CLI installation gitingest --version # Test Python package python -c "from gitingest import ingest; print('GitIngest installed successfully')" # Quick functionality test gitingest https://github.com/octocat/Hello-World -o test_output.txt ``` -------------------------------- ### Install GitIngest Python Package Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Instructions for installing the GitIngest Python package, intended for integration within Python codebases. ```python # For Code Integration pip install gitingest ``` -------------------------------- ### Comprehensive GitPython Mocks Setup Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Provides a fixture that returns a dictionary of comprehensive GitPython mocks. It includes mocks for `git.Git`, `git.Repo`, and `git.Repo.clone_from`, as well as patching these components within the project's utility modules. ```python @pytest.fixture def gitpython_mocks(mocker: MockerFixture) -> dict[str, MagicMock]: """Provide comprehensive GitPython mocks for testing.""" return _setup_gitpython_mocks(mocker) def _setup_gitpython_mocks(mocker: MockerFixture) -> dict[str, MagicMock]: """Set up comprehensive GitPython mocks.""" # Mock git.Git class mock_git_cmd = MagicMock() mock_git_cmd.version.return_value = "git version 2.34.1" mock_git_cmd.config.return_value = "true" mock_git_cmd.execute.return_value = f"{DEMO_COMMIT}\trefs/heads/main\n" mock_git_cmd.ls_remote.return_value = f"{DEMO_COMMIT}\trefs/heads/main\n" mock_git_cmd.clone.return_value = "" # Mock git.Repo class mock_repo = MagicMock() mock_repo.git = MagicMock() mock_repo.git.fetch = MagicMock() mock_repo.git.checkout = MagicMock() mock_repo.git.submodule = MagicMock() mock_repo.git.execute = MagicMock() mock_repo.git.config = MagicMock() mock_repo.git.sparse_checkout = MagicMock() # Mock git.Repo.clone_from mock_clone_from = MagicMock(return_value=mock_repo) git_git_mock = mocker.patch("git.Git", return_value=mock_git_cmd) git_repo_mock = mocker.patch("git.Repo", return_value=mock_repo) mocker.patch("git.Repo.clone_from", mock_clone_from) # Patch imports in our modules mocker.patch("gitingest.utils.git_utils.git.Git", return_value=mock_git_cmd) mocker.patch("gitingest.utils.git_utils.git.Repo", return_value=mock_repo) mocker.patch("gitingest.clone.git.Git", return_value=mock_git_cmd) return { "mock_git_cmd": mock_git_cmd, "mock_repo": mock_repo, "mock_clone_from": mock_clone_from, "git_git_mock": git_git_mock, "git_repo_mock": git_repo_mock, } ``` -------------------------------- ### Initialize Workspace and Load Actions Source: https://github.com/coderamp-labs/gitrules/blob/main/app/templates/components/quick_actions.html Initializes the workspace by hiding the container and setting up transitions. It then fetches actions (agents, MCPs, rules) from a backend API and caches them. The actions are rendered into their respective containers on the page. ```javascript ``` -------------------------------- ### Create Virtual Environment with UV Source: https://github.com/coderamp-labs/gitrules/blob/main/app/actions/rules/use-uv.md Demonstrates the command to create a new virtual environment using the UV package manager. ```shell uv venv ``` -------------------------------- ### GitIngest CLI Usage Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Demonstrates the basic command-line interface for GitIngest, including essential parameters for repository ingestion. ```Shell gitingest https://github.com/user/repo -i "*.py" -s 51200 -o - ``` -------------------------------- ### Gitingest Docker Self-Hosting Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Instructions for building and running the Gitingest application using Docker, including how to configure allowed hostnames. ```bash # Build the image: docker build -t gitingest . # Run the container: docker run -d --name gitingest -p 8000:8000 gitingest # Default: "gitingest.com, *.gitingest.com, localhost, 127.0.0.1". ALLOWED_HOSTS="example.com, localhost, 127.0.0.1" ``` -------------------------------- ### Install Gitingest with Pip (Server Dependencies) Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Installs Gitingest along with server dependencies using pip. This is useful if you plan to use Gitingest in a server environment or for self-hosting purposes. ```bash pip install gitingest[server] ``` -------------------------------- ### CI Workflow Steps Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Details the steps executed within the CI workflow. This includes hardening the runner, checking out the repository, setting up the Python environment, installing dependencies, caching pytest results, running tests (conditionally based on coverage), and executing pre-commit hooks. ```yaml steps: - name: Harden the runner (Audit all outbound calls) uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 with: egress-policy: audit - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Set up Python uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: python-version: ${{ matrix.python-version }} cache: 'pip' - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install ".[dev,server]" - name: Cache pytest results uses: actions/cache@v4 with: path: .pytest_cache key: ${{ runner.os }}-pytest-${{ matrix.python-version }}-${{ hashFiles('**/pytest.ini') }} restore-keys: | ${{ runner.os }}-pytest-${{ matrix.python-version }}- - name: Run tests if: ${{ matrix.coverage != true }} run: pytest - name: Run tests if: ${{ matrix.coverage == true }} run: pytest - name: Run pre-commit hooks uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 if: ${{ matrix.python-version == '3.13' && matrix.os == 'ubuntu-latest' }} ``` -------------------------------- ### Submit Example Repository (JavaScript) Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md A JavaScript function to set the input field's value to a specified repository name and focus it. This is used for submitting example repositories from UI elements. ```javascript function submitExample(repoName) { const input = document.getElementById('input_text'); if (input) { input.value = repoName; input.focus(); } } // Make it visible to inline onclick handlers window.submitExample = submitExample; ``` -------------------------------- ### MinIO Setup Script (Shell) Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md A shell script to configure MinIO for S3 compatibility. It sets up aliases, creates buckets, sets bucket policies for anonymous downloads, and adds users with specified access and secret keys. ```Shell #!/bin/sh # Simple script to set up MinIO bucket and user # Based on example from MinIO issues # Format bucket name to ensure compatibility BUCKET_NAME=$(echo "${S3_BUCKET_NAME}" | tr '[:upper:]' '[:lower:]' | tr '_' '-') # Configure MinIO client mc alias set myminio http://minio:9000 ${MINIO_ROOT_USER} ${MINIO_ROOT_PASSWORD} # Remove bucket if it exists (for clean setup) mc rm -r --force myminio/${BUCKET_NAME} || true # Create bucket mc mb myminio/${BUCKET_NAME} # Set bucket policy to allow downloads mc anonymous set download myminio/${BUCKET_NAME} # Create user with access and secret keys mc admin user add myminio ${S3_ACCESS_KEY} ${S3_SECRET_KEY} || echo "User already exists" # Create policy for the bucket echo '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["s3:*"],"Resource":["arn:aws:s3:::'${BUCKET_NAME}'/*","arn:aws:s3:::'${BUCKET_NAME}'"]}]}' > /tmp/policy.json ``` -------------------------------- ### Gitingest CLI Entrypoint Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Provides the command-line interface (CLI) for the Gitingest package. It utilizes the 'click' library for argument parsing and integrates with asynchronous ingestion functions and logging configuration. ```Python """Command-line interface (CLI) for Gitingest.""" # pylint: disable=no-value-for-parameter from __future__ import annotations import asyncio from typing import TypedDict import click from typing_extensions import Unpack from gitingest.config import MAX_FILE_SIZE, OUTPUT_FILE_NAME from gitingest.entrypoint import ingest_async # Import logging configuration first to intercept all logging from gitingest.utils.logging_config import get_logger ``` -------------------------------- ### Ensure Git Installation Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Verifies that Git is installed and accessible on the system. For Windows users, it also checks if Git is configured to support long file paths. Raises a RuntimeError if Git is not found or accessible. ```Python import sys import git import logging logger = logging.getLogger(__name__) async def ensure_git_installed() -> None: """Ensure Git is installed and accessible on the system. On Windows, this also checks whether Git is configured to support long file paths. Raises ------ RuntimeError If Git is not installed or not accessible. """ try: # Use GitPython to check git availability git_cmd = git.Git() git_cmd.version() except git.GitCommandError as exc: msg = "Git is not installed or not accessible. Please install Git first." raise RuntimeError(msg) from exc except Exception as exc: msg = "Git is not installed or not accessible. Please install Git first." raise RuntimeError(msg) from exc if sys.platform == "win32": try: longpaths_value = git_cmd.config("core.longpaths") if longpaths_value.lower() != "true": logger.warning( "Git clone may fail on Windows due to long file paths. " "Consider enabling long path support with: 'git config --global core.longpaths true'. " "Note: This command may require administrator privileges.", extra={"platform": "windows", "longpaths_enabled": False}, ) except git.GitCommandError: # Ignore if checking 'core.longpaths' fails. pass ``` -------------------------------- ### Gitingest Project Overview Source: https://github.com/coderamp-labs/gitrules/blob/main/gitingest.md Provides an overview of the Gitingest project, highlighting its technical stack and contribution guidelines. ```Markdown ### Technical ways to contribute Gitingest aims to be friendly for first time contributors, with a simple Python and HTML codebase. If you need any help while working with the code, reach out to us on [Discord](https://discord.com/invite/zerRaGK9EC). For detailed instructions on how to make a pull request, see [CONTRIBUTING.md](./CONTRIBUTING.md). ```