Skip to content

roelbondoc/askcii

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Askcii

Bring the power of Large Language Models to your command line—the Unix way.

Askcii is a terminal-native CLI tool that connects you to multiple LLM providers (OpenAI, Anthropic, Gemini, DeepSeek, OpenRouter, and Ollama) through a simple, composable interface. It's designed to integrate seamlessly into your existing Unix workflows, treating LLMs as just another filter in your pipeline.

Philosophy: Why CLI, Not TUI?

In the Unix tradition, the most powerful tools are those that compose. They read from standard input, write to standard output, and can be chained together with pipes to create sophisticated workflows. Askcii embraces this philosophy completely.

Unlike interactive TUI (Text User Interface) applications that take over your terminal with full-screen interfaces, Askcii is a single-purpose filter: it takes text in, sends it to an LLM, and streams the response back out. This simple design makes it infinitely more versatile.

What this means in practice:

  • Pipeable: Chain it with grep, awk, sed, jq, and any other Unix tool
  • Scriptable: Use it in shell scripts, cron jobs, and automation workflows
  • Composable: Combine it with your existing toolchain without context switching
  • Redirectable: Save outputs to files, pipe to other commands, integrate into larger systems
  • Session-aware: Maintain conversation context across invocations when needed
  • Privacy-first: Run in private mode or use local models via Ollama for sensitive data

Askcii doesn't try to be a chat application. It's a Unix power tool that puts LLM capabilities directly into your pipeline, where they belong.

Installation

gem install askcii

Or add to your Gemfile:

gem 'askcii'

Quick Start

# Simple prompt
askcii 'Explain recursive functions in one sentence'

# Pipe input from other commands
git diff | askcii 'Review this code change'

# Chain with other tools
curl -s https://api.github.com/repos/ruby/ruby | askcii 'Summarize this repo' | tee summary.txt

# Private session (no history)
askcii -p 'What is my IP address showing?'

Usage

Basic Patterns

# Direct prompt
askcii 'Your prompt here'

# Standard input from pipe
echo 'Context text' | askcii 'Analyze this'

# Read from file
askcii 'Summarize this document' < document.txt

# Redirect output to file
askcii 'Write a bash script to backup /home' > backup.sh

# Chain multiple commands
cat error.log | grep ERROR | askcii 'What are the common patterns?' | less

Command-Line Options

Usage: askcii [options] 'Your prompt here'

Options:
  -p, --private         Private session (no conversation history saved)
  -r, --last-response   Retrieve and output the last assistant response
  -c, --configure       Launch configuration management interface
  -m, --model ID        Use specific configuration by ID number
  -h, --help            Show this help message

Real-World Examples

Code Analysis & Development

# Code review with detailed feedback
git diff main..feature-branch | askcii 'Review these changes. Focus on security and performance.'

# Explain unfamiliar code
cat legacy_module.rb | askcii 'Explain what this code does and identify potential issues'

# Generate unit tests
askcii 'Write RSpec tests for a User model with email validation' > spec/user_spec.rb

# Debug assistance
tail -50 production.log | grep ERROR | askcii 'What are the root causes of these errors?'

# Refactoring suggestions
cat messy_controller.rb | askcii 'Suggest refactoring to improve this code'

# Documentation generation
ls -R lib/ | askcii 'Create a project structure overview' > STRUCTURE.md

Data Processing & Analysis

# CSV to JSON conversion
cat users.csv | askcii 'Convert this CSV to JSON array format' > users.json

# Log analysis and summarization
tail -1000 /var/log/nginx/access.log | askcii 'Summarize traffic patterns and anomalies'

# Data extraction from unstructured text
curl -s https://example.com/article | askcii 'Extract all email addresses and URLs as a list'

# SQL query generation
askcii 'Write a PostgreSQL query to find duplicate users by email' >> queries.sql

# API response analysis
curl -s https://api.service.com/status | jq . | askcii 'Is this API healthy? Explain the metrics.'

System Administration

# Server health check summary
df -h && free -h && uptime | askcii 'Assess system health and recommend actions'

# Parse and explain complex configs
cat /etc/nginx/nginx.conf | askcii 'Explain this configuration and suggest optimizations'

# Security audit
find . -name "*.sh" -exec cat {} \; | askcii 'Review these shell scripts for security issues'

# Quick command help
askcii 'Show me tar command examples for incremental backups'

# Incident analysis
journalctl --since "1 hour ago" | askcii 'Identify any critical system events'

Documentation & Writing

# Generate README sections
askcii 'Write installation instructions for a Ruby gem' >> README.md

# Meeting notes to action items
cat meeting_transcript.txt | askcii 'Extract action items with owners as markdown checklist'

# Explain technical concepts
askcii 'Explain OAuth2 flow in simple terms' > oauth_explainer.md

# Create Git commit messages
git diff --staged | askcii 'Write a conventional commit message' | pbcopy

Session-Based Conversations

# Named session for ongoing work
export ASKCII_SESSION="database-migration"
askcii 'I need to migrate from MySQL to PostgreSQL'
askcii 'What about handling JSON columns?' # Remembers context
askcii 'Show migration script for users table' > migrate_users.sql

# Project-specific session
ASKCII_SESSION="feature-auth" askcii 'How should I implement 2FA?'
ASKCII_SESSION="feature-auth" askcii 'Show me the code for TOTP generation'

# Retrieve last response (useful when output scrolled away)
askcii -r | less

Multi-Provider Workflows

# Use Claude for creative content
askcii -m 1 'Write a technical blog post intro about WebAssembly' > blog_draft.md

# Use GPT-4 for code generation
askcii -m 2 'Create a Python class for rate limiting' > rate_limiter.py

# Use local Ollama for private/sensitive data
cat proprietary_data.txt | askcii -m 3 -p 'Analyze this confidential report'

# Use DeepSeek for cost-effective tasks
find . -name "*.rb" | xargs wc -l | askcii -m 4 'Summarize codebase statistics'

Advanced Compositions

# Multi-stage pipeline
cat research_papers.txt | \
  askcii 'Extract key findings' | \
  askcii 'Group by topic' | \
  askcii 'Create a bibliography' > bibliography.md

# Watch and analyze in real-time
tail -f app.log | grep --line-buffered ERROR | while read line; do
  echo "$line" | askcii -p 'Explain this error briefly'
done

# Batch processing with parallel
find . -name "*.java" | parallel -j4 "cat {} | askcii 'Rate code quality 1-10' | echo {}: "

# Interactive script integration
#!/bin/bash
context=$(cat context.txt)
while true; do
  read -p "Question: " question
  echo "$context" | askcii "$question"
done

Configuration Management

Askcii supports multiple provider configurations, allowing you to switch between different LLMs based on your needs—cost, privacy, capability, or speed.

Interactive Configuration Setup

Launch the configuration manager:

askcii -c

You'll see an interface like:

Configuration Management
=======================
Current configurations:
  1. GPT-4 Turbo [openai] (default)
  2. Claude 3.5 Sonnet [anthropic]
  3. Gemini 2.0 Flash [gemini]
  4. DeepSeek V3 [deepseek]
  5. Mixtral [openrouter]
  6. Llama 3.2 [ollama]

Options:
  1. Add new configuration
  2. Set default configuration
  3. Delete configuration
  4. Exit

Supported Providers

Provider Use Case API Key Required
OpenAI GPT models (GPT-4, GPT-4 Turbo, GPT-3.5) Yes
Anthropic Claude models (Opus, Sonnet, Haiku) Yes
Gemini Google's Gemini models Yes
DeepSeek Cost-effective DeepSeek models Yes
OpenRouter Access 100+ models through one API Yes
Ollama Local models (Llama, Mistral, etc.) No

Adding Configurations

When you add a new configuration, you provide:

  1. Name: Friendly identifier (e.g., "GPT-4 for Code")
  2. Provider: Choose from the supported list
  3. API Key: Your provider API key (except Ollama)
  4. Endpoint: API endpoint (defaults provided)
  5. Model ID: Specific model identifier

Example: Adding OpenAI

Name: GPT-4 Turbo
Provider: 1 (OpenAI)
API Key: sk-proj-xxxxxxxxxxxxx
Endpoint: [leave blank for default]
Model ID: gpt-4-turbo-preview

Example: Adding Ollama (Local)

Name: Local Llama
Provider: 6 (Ollama)
Endpoint: http://localhost:11434/v1
Model ID: llama3.2:latest

Using Configurations

# Use default configuration
askcii 'Hello world'

# Use specific configuration by ID
askcii -m 2 'Use Claude for this'

# Switch default in config manager
askcii -c  # Then select "Set default configuration"

Environment Variable Fallback

For quick one-offs or CI/CD environments, use environment variables:

# Quick override
ASKCII_API_KEY="sk-xxx" ASKCII_MODEL_ID="gpt-4" askcii 'Quick question'

# In scripts
export ASKCII_API_KEY="your_key"
export ASKCII_API_ENDPOINT="https://api.openai.com/v1"
export ASKCII_MODEL_ID="gpt-3.5-turbo"
askcii 'Automated query'

Session Management

Askcii maintains conversation context across invocations, but you control when and how.

Session Contexts

Sessions are identified by the ASKCII_SESSION environment variable:

# Random session per terminal session (recommended)
export ASKCII_SESSION=$(openssl rand -hex 16)

# Named session for a specific project
export ASKCII_SESSION="refactoring-auth-module"
askcii 'What patterns should I use for the auth module?'
askcii 'Show code for the JWT validator'  # Remembers previous context

# One-off session (no context retention)
askcii 'Standalone question'  # Creates random session ID

# Private mode (no database storage at all)
askcii -p 'What is 2+2?'  # No session, no history

Retrieving Responses

# Get last response from current session
askcii -r

# Useful in scripts
last_response=$(askcii -r)
echo "$last_response" | process_further.sh

# Copy to clipboard
askcii -r | pbcopy  # macOS
askcii -r | xclip -selection clipboard  # Linux

Privacy Considerations

# Private mode: no storage, no history
askcii -p 'Analyze this sensitive data' < confidential.txt

# Use local Ollama for complete privacy
askcii -m 6 'Process private information' < private.txt

# Session isolation
ASKCII_SESSION="temp-$(date +%s)" askcii 'Temporary context'

Data Storage

  • Database: ~/.local/share/askcii/askcii.db (SQLite)
  • Stored: Conversations, messages, configurations
  • Not stored: Private mode sessions (-p flag)

Integration Examples

Git Hooks

# .git/hooks/pre-commit
#!/bin/bash
git diff --cached | askcii -p 'Any obvious issues with this commit?' | tee /dev/tty
read -p "Proceed with commit? [y/N] " -n 1 -r
echo
[[ $REPLY =~ ^[Yy]$ ]] || exit 1

Vim Integration

" In ~/.vimrc - send selection to askcii
vnoremap <leader>a :w !askcii 'Improve this code'<CR>

Shell Aliases

# ~/.bashrc or ~/.zshrc
alias explain='askcii "Explain this command:"'
alias review='git diff | askcii "Review this code:"'
alias commit-msg='git diff --staged | askcii -p "Write a commit message:" | head -1'
alias tldr='askcii "Summarize in 3 bullets:"'

Makefiles

.PHONY: analyze
analyze:
	@find src/ -name "*.rb" -exec cat {} \; | askcii 'Code quality report' > analysis.txt
	@echo "Analysis saved to analysis.txt"

Development

# Setup
git clone https://github.com/yourusername/askcii.git
cd askcii
bin/setup

# Run locally
bin/askcii 'Test prompt'

# Run tests
rake test

# Interactive console
bin/console

# Build and install locally
bundle exec rake build
bundle exec rake install

Why Askcii?

Unix Philosophy: Do one thing well. Askcii is a filter, not an application.

Provider Agnostic: Switch between OpenAI, Anthropic, local models—same interface.

Session Awareness: Maintain context when needed, forget when you don't.

Privacy First: Private mode and local model support for sensitive workflows.

Scriptable: Integrates into automation, cron jobs, CI/CD pipelines.

Composable: Works with every other Unix tool you already know.

Terminal Native: No context switching, no browser tabs, no GUI overhead.

License

MIT License - See LICENSE


Askcii: Because the best interface is the one you're already using.

About

A command-line application for interacting with LLM models in a terminal-friendly way.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors