Files
finish/ARCHITECTURE.md
mike f906e6666a
Some checks failed
Docker Build and Push / build-and-push (push) Failing after 10s
Tests / test (bash) (push) Failing after 9s
Tests / test (zsh) (push) Failing after 10s
Tests / lint (push) Successful in 8s
Tests / docker (push) Successful in 6s
-init-
2025-12-11 09:14:52 +01:00

72 lines
4.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
User Input (Tab×2 or CLI)
┌───────────────────────────────────────┐
│ Entry Points │
├───────────────────────────────────────┤
│ • _finishsh() - Tab completion │
│ • command_command() - CLI mode │
└───────────────┬───────────────────────┘
┌───────────────────────────────────────┐
│ Configuration Layer │
├───────────────────────────────────────┤
│ acsh_load_config() │
│ • Read ~/.finish/config │
│ • Set ACSH_PROVIDER, ACSH_ENDPOINT │
│ • Set ACSH_ACTIVE_API_KEY (if needed) │
└───────────────┬───────────────────────┘
┌───────────────────────────────────────┐
│ Cache Layer │
├───────────────────────────────────────┤
│ • Check cache_dir/acsh-{hash}.txt │
│ • Return cached completions if exists │
└───────────────┬───────────────────────┘
↓ (cache miss)
┌───────────────────────────────────────┐
│ Context Builder │
├───────────────────────────────────────┤
│ _build_prompt() │
│ • Command history (sanitized) │
│ • Terminal info (env vars, cwd) │
│ • Recent files (ls -ld) │
│ • Help message (cmd --help) │
└───────────────┬───────────────────────┘
┌───────────────────────────────────────┐
│ Payload Builder │
├───────────────────────────────────────┤
│ _build_payload() │
│ • Format: {model, messages, temp} │
│ • Provider-specific options: │
│ - Ollama: {format:"json"} │
│ - LMStudio: {stream:true} │
│ - OpenAI: {response_format} │
└───────────────┬───────────────────────┘
┌───────────────────────────────────────┐
│ LLM Provider Layer │
├───────────────────────────────────────┤
│ openai_completion() │
│ • curl to endpoint │
│ • Ollama: no auth header │
│ • Others: Authorization header if key │
│ • Parse response (JSON/streaming) │
└───────────────┬───────────────────────┘
┌───────────────────────────────────────┐
│ Response Parser │
├───────────────────────────────────────┤
│ • Extract completions array │
│ • Fallback parsing for non-JSON │
│ • Filter command-like lines │
└───────────────┬───────────────────────┘
┌───────────────────────────────────────┐
│ Output Layer │
├───────────────────────────────────────┤
│ • Write to cache │
│ • Log usage (tokens, cost) │
│ • Return COMPREPLY array (completion) │
│ • or stdout (CLI mode) │
└───────────────────────────────────────┘