### Install and Run PortHub Source: https://context7.com/narumiruna/porthub/llms.txt Instructions for installing and running PortHub using the uv package manager. This includes syncing dependencies and executing the tool via uv or directly as an installed script. ```bash # Install dependencies uv sync # Run via uv uv run porthub --help # Or use the installed script directly porthub --help ``` -------------------------------- ### Install and Run PortHub CLI Source: https://github.com/narumiruna/porthub/blob/main/README.md Instructions for installing the project dependencies using uv and executing the CLI tool. Users can run commands directly via uv or through the installed script. ```bash uv sync uv run porthub --help porthub --help ``` -------------------------------- ### Retrieve Markdown Content with 'porthub get' Source: https://context7.com/narumiruna/porthub/llms.txt Illustrates the usage of the 'porthub get' command to retrieve Markdown content by its exact key. It shows examples of retrieving existing content, nested keys, handling non-existent keys, and using the command in scripts with error handling. ```bash # Retrieve stored documentation porthub get python/typer # Output: # # Typer (Updated) # # Updated documentation with new examples. # Get content for a nested key porthub get rust/clap # Output: # # Clap # # Command Line Argument Parser for Rust. # ... # Attempt to get a missing key porthub get python/nonexistent # Output (stderr): Key 'python/nonexistent' not found. # Exit code: 1 # Use in scripts with error handling if porthub get python/typer > /dev/null 2>&1; then echo "Documentation exists" else echo "Documentation not found" fi ``` -------------------------------- ### Install PortHub Skill Source: https://github.com/narumiruna/porthub/blob/main/README.md Command to install the PortHub skill into a project using npx. This enables package-documentation retrieval workflows. ```bash npx skills add narumiruna/porthub ``` -------------------------------- ### Integrate PortHub with AI Workflows Source: https://context7.com/narumiruna/porthub/llms.txt Shows how to install the PortHub skill for Claude Code and use it to bootstrap documentation. This enables AI agents to search and retrieve snippets directly from the local store. ```bash npx skills add narumiruna/porthub porthub set python/httpx "# HTTPX\n\nA modern HTTP client for Python 3.\n\n## Installation\n\n```bash\npip install httpx\n```\n\n## Basic Usage\n\n```python\nimport httpx\n\n# Synchronous request\nresponse = httpx.get('https://api.example.com/data')\nprint(response.json())\n\n# Async request\nasync with httpx.AsyncClient() as client:\n response = await client.get('https://api.example.com/data')\n```\n\n## Sources\n\n- https://www.python-httpx.org/" ``` -------------------------------- ### GET /porthub get Source: https://context7.com/narumiruna/porthub/llms.txt Retrieves the raw Markdown content associated with a specific key. ```APIDOC ## GET /porthub get ### Description Retrieves stored Markdown content by an exact key match. ### Method GET (CLI command) ### Parameters #### Path Parameters - **key** (string) - Required - The exact key to retrieve. ### Request Example `porthub get python/typer` ### Response #### Success Response (0) - **content** (string) - The raw Markdown content. #### Error Response (1) - **error** (string) - 'Key not found' message if the key does not exist. ``` -------------------------------- ### GET /porthub list Source: https://context7.com/narumiruna/porthub/llms.txt Lists all stored keys currently in the repository. ```APIDOC ## GET /porthub list ### Description Returns an alphabetically sorted list of all stored keys. ### Method GET (CLI command) ### Request Example `porthub list` ### Response #### Success Response (0) - **keys** (list) - All stored keys, one per line. ``` -------------------------------- ### Interact with PortHub via Python API Source: https://context7.com/narumiruna/porthub/llms.txt Provides examples for programmatic interaction with PortHub, including key validation, path resolution, and file system operations. Ideal for scripts requiring automated documentation retrieval or storage. ```python from pathlib import Path from porthub.cli import ( validate_key, key_to_path, storage_root, list_keys_from_root, ) root = storage_root() normalized = validate_key("python/typer") path = key_to_path("python/typer") keys = list_keys_from_root(storage_root()) # Writing content key = "javascript/react" path = key_to_path(validate_key(key)) path.parent.mkdir(parents=True, exist_ok=True) path.write_text("# React\n\nA JavaScript library for building UIs.", encoding="utf-8") ``` -------------------------------- ### List All Stored Keys with 'porthub list' Source: https://context7.com/narumiruna/porthub/llms.txt Details the 'porthub list' command for displaying all stored documentation keys in alphabetical order. It shows how to get an empty list when no documents exist, count the total number of documents, and filter the list using standard shell utilities like grep. ```bash # List all stored documentation keys porthub list # Output: # docs/guide # python/click # python/typer # rust/clap # zeta/alpha # List returns empty when no documents exist porthub list # Output: (empty) # Exit code: 0 # Count total stored documents porthub list | wc -l # Output: 5 # Iterate over all keys for key in $(porthub list); do echo "Processing: $key" done # Filter keys by prefix using grep porthub list | grep "^python/" # Output: # python/click # python/typer ``` -------------------------------- ### GET /porthub search Source: https://context7.com/narumiruna/porthub/llms.txt Searches for keys by matching a substring against key names and file content. ```APIDOC ## GET /porthub search ### Description Performs a case-insensitive search across all stored keys and their content. Returns matching keys sorted alphabetically. ### Method GET (CLI command) ### Parameters #### Query Parameters - **query** (string) - Required - The substring to search for. ### Request Example `porthub search "CLI framework"` ### Response #### Success Response (0) - **keys** (list) - A list of matching keys, one per line. ``` -------------------------------- ### PortHub Key Validation Rules Source: https://context7.com/narumiruna/porthub/llms.txt Outlines the key validation rules enforced by PortHub to ensure consistent storage and prevent security vulnerabilities. It provides examples of valid keys and demonstrates how invalid keys are rejected with non-zero exit codes and error messages. ```bash # Valid key examples porthub set python/typer "content" # Hierarchical key porthub set rust/tokio "content" # Language/package format porthub set docs/api/v2 "content" # Deeply nested key porthub set mypackage "content" # Single-level key # Invalid key examples - all fail with non-zero exit code # Empty key porthub set "" "content" # Error: Key must not be empty. ``` -------------------------------- ### Search Documentation with 'porthub search' Source: https://context7.com/narumiruna/porthub/llms.txt Explains how to use the 'porthub search' command to find documentation keys based on substring matches in keys or content. It covers case-insensitive searching, searching across multiple documents, handling no matches, and using search results in scripts. ```bash # Search by package name (matches key) porthub search typer # Output: # python/typer # Search by content (case-insensitive) porthub search "CLI framework" # Output: # python/typer # Search across multiple documents # Given these stored documents: # - python/typer: "CLI framework for Python" # - python/click: "CLI toolkit for Python" # - docs/guide: "Use typer for CLI apps" porthub search typer # Output: # docs/guide # python/typer porthub search CLI # Output: # python/click # python/typer # Search with no matches returns empty output porthub search nonexistent # Output: (empty) # Exit code: 0 # Use search results in a script for key in $(porthub search python); do echo "Found: $key" porthub get "$key" echo "---" done ``` -------------------------------- ### Store Markdown Content with 'porthub set' Source: https://context7.com/narumiruna/porthub/llms.txt Demonstrates how to use the 'porthub set' command to store Markdown content under hierarchical keys. It covers storing new content, overwriting existing content, and shows the expected exit code for successful operations. ```bash # Store documentation for a Python package porthub set python/typer "# Typer A modern CLI framework for Python based on type hints. ## Installation ```bash pip install typer ``` ## Basic Usage ```python import typer app = typer.Typer() @app.command() def hello(name: str): print(f'Hello {name}') if __name__ == '__main__': app() ``` " # Store documentation for a Rust crate porthub set rust/clap "# Clap Command Line Argument Parser for Rust. ## Add to Cargo.toml ```toml [dependencies] clap = { version = \"4.0\", features = [\"derive\"] } ``` " # Overwrite existing content porthub set python/typer "# Typer (Updated) Updated documentation with new examples. " # Exit code 0 on success echo $? # Output: 0 ``` -------------------------------- ### PortHub CLI Usage Commands Source: https://github.com/narumiruna/porthub/blob/main/README.md Common operations for managing Markdown content, including setting, retrieving, searching, and listing keys. These commands interact with the local filesystem storage. ```bash porthub set python/typer "# Typer\nCLI framework for Python" porthub get python/typer porthub search typer porthub list ``` -------------------------------- ### Validate and Manage PortHub Keys via CLI Source: https://context7.com/narumiruna/porthub/llms.txt Demonstrates the validation rules for PortHub keys, including restrictions on path traversal and specific character patterns. These commands show how the CLI enforces structure before storage. ```bash porthub set "/python/typer" "content" porthub set "python/typer/" "content" porthub set "python//typer" "content" porthub set "python/../typer" "content" porthub set "python/typer.md" "content" ``` -------------------------------- ### POST /porthub set Source: https://context7.com/narumiruna/porthub/llms.txt Stores or overwrites Markdown content under a specific hierarchical key. Automatically handles directory creation and atomic file writes. ```APIDOC ## POST /porthub set ### Description Stores Markdown content under a hierarchical key. If the key already exists, the content is overwritten. ### Method POST (CLI command) ### Parameters #### Path Parameters - **key** (string) - Required - The hierarchical key (e.g., 'python/typer'). #### Request Body - **content** (string) - Required - The Markdown content to store. ### Request Example `porthub set python/typer "# Typer\n\nA modern CLI framework."` ### Response #### Success Response (0) - **status** (integer) - Returns 0 on successful write. #### Response Example `0` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.