feat: add Open WebUI PostgreSQL code export script

Added artifact_postgres_export.sh to automate exporting code artifacts
from Open WebUI chat conversations stored in PostgreSQL.

Features:
- Direct PostgreSQL database access via Docker exec
- Remote server support via SSH (--remote flag)
- Automatic filename detection from markdown headers
- Directory structure preservation (src/main.rs, src/parser/mod.rs, etc.)
- Safety checks: UUID validation, empty directory check (--force override)
- Colored terminal output with verbose mode
- Smart code block extraction with language detection
- Support for 20+ file extensions (Rust, Python, JS, YAML, etc.)
- No metadata file pollution in output directory

Usage:
  artifact_postgres_export.sh [OPTIONS] <chat_id> <output_dir>

Example:
  artifact_postgres_export.sh --remote vps e135d74e-5b43-4b24-a651-e999f103942b ~/Projects/rust/piglet

Updated README.md with comprehensive documentation including:
- Full option reference
- Usage examples
- Feature list

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-09 01:33:19 +01:00
parent e93c7d917e
commit 54c4bef7f2
2 changed files with 368 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ This documentation was auto-generated using [`doc_bash_generate.sh`](https://git
## Table of Contents
- [`artifact_github_download.sh`](#artifact-github-download-sh)
- [`artifact_postgres_export.sh`](#artifact-postgres-export-sh)
- [`css_color_filter.sh`](#css-color-filter-sh)
- [`css_color_palette.sh`](#css-color-palette-sh)
- [`css_json_convert.sh`](#css-json-convert-sh)
@@ -84,6 +85,79 @@ artifact_github_download.sh valknarness/awesome -n awesome-database-latest -o ~/
---
## `artifact_postgres_export.sh`
Export code artifacts from Open WebUI PostgreSQL database
### Usage
```bash
artifact_postgres_export.sh [OPTIONS] <chat_id> <output_dir>
```
### Arguments
- `chat_id` - Chat ID from Open WebUI URL (UUID format)
- `output_dir` - Directory to save extracted code files (optional, defaults to current directory)
### Options
<details>
<summary>Click to expand full help output</summary>
```
artifact_postgres_export.sh - Export code artifacts from Open WebUI PostgreSQL database
Usage: artifact_postgres_export.sh [OPTIONS] <chat_id> <output_dir>
Arguments:
chat_id Chat ID from Open WebUI URL (e.g., e135d74e-5b43-4b24-a651-e999f103942b)
output_dir Directory to save extracted code files
Options:
-h, --help Show this help message
-H, --host HOST PostgreSQL host (default: ai_postgres via Docker)
-u, --user USER PostgreSQL user (default: ai)
-d, --db DATABASE PostgreSQL database (default: openwebui)
-v, --verbose Verbose output
--remote HOST SSH remote host for Docker access (default: vps)
-f, --force Force export even if output directory is not empty
Examples:
artifact_postgres_export.sh e135d74e-5b43-4b24-a651-e999f103942b ~/Projects/rust/piglet
artifact_postgres_export.sh --remote vps abc123def456 ./output
```
</details>
### Examples
```bash
# Export chat to local directory
artifact_postgres_export.sh e135d74e-5b43-4b24-a651-e999f103942b ~/Projects/rust/piglet
# Export from remote server
artifact_postgres_export.sh --remote vps abc123def456 ./output
# Force export to non-empty directory
artifact_postgres_export.sh -f e135d74e-5b43-4b24-a651-e999f103942b ./output
# Verbose output with custom database
artifact_postgres_export.sh -v -d custom_db abc123def456 ./output
```
### Features
- **Direct PostgreSQL access** via Docker exec (SSH-enabled for remote servers)
- **Automatic filename detection** from markdown headers (e.g., `### src/main.rs`)
- **Directory structure preservation** - maintains original paths like `src/parser/duration.rs`
- **Safety checks** - validates chat ID format and checks for empty output directory
- **Colored output** - uses ANSI colors for better readability
- **Smart code extraction** - parses markdown code blocks with language detection
- **File extension mapping** - supports 20+ file types (Rust, Python, JavaScript, etc.)
---
## `css_color_filter.sh`
CSS Color Filter Generator