Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ” PerCLI โ€” AI-Powered Search Assistant for your Terminal

A command-line AI assistant that combines Google Gemini with Tavily Search to provide intelligent, source-backed answers directly from your terminal.

Node.js License Version Gemini Tavily Genkit


๐ŸŒ Versiรณn en espaรฑol


โœจ Features

  • ๐Ÿค– AI-Powered Answers โ€” Uses Google Gemini 2.5 Flash for natural language understanding and generation
  • ๐Ÿ”Ž Real-Time Web Search โ€” Leverages Tavily API with advanced search depth to ground responses with up-to-date web data
  • ๐Ÿ’ฌ Interactive Chat Mode โ€” Conversational interface with session-based chat history maintained in memory
  • ๐Ÿ› ๏ธ Genkit Tool System โ€” Search is exposed as a Genkit tool, allowing the AI to autonomously decide when to search the web
  • ๐Ÿ“‘ Source Citations โ€” Responses include numbered source citations and a dedicated Sources section with URLs
  • ๐ŸŽจ Beautiful Terminal UI โ€” Colored output, spinners, and formatted responses using Chalk and Ora
  • ๐Ÿ”ง Genkit Dev Tools โ€” Built on Firebase Genkit for observability, tracing, and debugging

๐Ÿ“‹ Prerequisites

๐Ÿš€ Getting Started

1. Clone the repository

git clone https://github.com/juanan09/percli.git
cd percli

2. Install dependencies

npm install

3. Configure environment variables

Copy the example file and add your API keys:

cp .env.example .env

Edit .env with your keys:

# Tavily API Key - Get it from https://tavily.com
TAVILY_API_KEY=your_tavily_api_key_here

# Google AI API Key - Get it from https://aistudio.google.com/app/apikey
GOOGLE_API_KEY=your_google_api_key_here

4. Run the application

# Production mode
npm start

# Development mode (with Genkit Dev UI for tracing and debugging)
npm run dev

๐ŸŽฎ Usage

Once running, you'll see an interactive prompt:

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘   Welcome to Percli CLI - Interactive Mode     โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
Type your questions and get AI-powered answers with sources!
Chat history is maintained during this session.
Commands: exit, quit, or press Ctrl+C to leave

๐Ÿ’ฌ Ask a question (or type "exit" to quit):

Simply type your question and press Enter. The AI will:

  1. Analyze your query
  2. Automatically search the web if current information is needed
  3. Synthesize information from multiple sources
  4. Provide a comprehensive, well-structured answer with source citations

Commands:

Command Description
exit / quit Exit the application
Ctrl+C Force quit

๐Ÿ’ก Tip: Chat history is maintained during your session, so the AI remembers previous questions and can build on prior context.

๐Ÿ—๏ธ Architecture

PerCLI is built on a tool-augmented agent architecture using Firebase Genkit:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    index.js (CLI Loop)                    โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚   readline   โ”‚  โ”‚  chalk   โ”‚  โ”‚        ora          โ”‚ โ”‚
โ”‚  โ”‚  (user I/O)  โ”‚  โ”‚ (colors) โ”‚  โ”‚    (spinners)       โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚         โ”‚                                                 โ”‚
โ”‚         โ–ผ                                                 โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚              agent.js (Chat Agent)                  โ”‚  โ”‚
โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚  โ”‚
โ”‚  โ”‚  โ”‚  Genkit Prompt   โ”‚  โ”‚     searchWeb Tool     โ”‚  โ”‚  โ”‚
โ”‚  โ”‚  โ”‚  (system prompt  โ”‚  โ”‚  (AI decides when to   โ”‚  โ”‚  โ”‚
โ”‚  โ”‚  โ”‚   + model cfg)   โ”‚  โ”‚   invoke search)       โ”‚  โ”‚  โ”‚
โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”คโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                                        โ”‚                  โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚            search.js (Tavily Integration)           โ”‚  โ”‚
โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚  โ”‚
โ”‚  โ”‚  โ”‚  Advanced search ยท Max N results ยท Answer    โ”‚   โ”‚  โ”‚
โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

How It Works

  1. index.js โ€” Entry point. Sets up the Genkit AI instance, Tavily client, and readline-based interactive loop. Validates environment variables and manages the CLI lifecycle.
  2. src/agent.js โ€” Defines the AI chat agent. Creates a Genkit prompt with a system instruction that tells the AI how to respond, and registers a searchWeb tool that the AI can call autonomously. Uses Zod schemas for input/output validation.
  3. src/search.js โ€” Wraps the Tavily API client. Performs advanced web searches with configurable result limits and returns structured results (title, URL, content).

๐Ÿ“ Project Structure

percli/
โ”œโ”€โ”€ index.js              # Entry point โ€” interactive CLI loop & initialization
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ agent.js          # Chat agent config โ€” prompt, model, and tool registration
โ”‚   โ””โ”€โ”€ search.js         # Tavily web search wrapper with advanced search depth
โ”œโ”€โ”€ .env.example          # Environment variables template
โ”œโ”€โ”€ .gitignore            # Git ignore rules
โ”œโ”€โ”€ package.json          # Dependencies, scripts, and project metadata
โ”œโ”€โ”€ README.md             # This file (English)
โ””โ”€โ”€ README_ES.md          # Documentation in Spanish

๐Ÿ“ฆ Dependencies

Production

Package Version Description
genkit ^1.29.0 Firebase Genkit framework for building AI-powered applications
@genkit-ai/google-genai ^1.29.0 Google Gemini plugin for Genkit
@genkit-ai/googleai ^1.28.0 Google AI integration for Genkit
@tavily/core 0.7.2 Tavily search API client for real-time web search
chalk ^5.6.2 Terminal string styling with colors and formatting
ora ^9.3.0 Elegant terminal spinners for loading states
dotenv ^17.3.1 Loads environment variables from .env files

Development

Package Version Description
genkit-cli ^1.29.0 Genkit CLI for dev UI, tracing, and debugging

๐Ÿ“œ Scripts

Script Command Description
start npm start Runs the CLI in production mode (node index.js)
dev npm run dev Runs with Genkit Dev UI for tracing and debugging (npx genkit start -- node index.js)
test npm test Placeholder for tests (not yet implemented)

๐Ÿ”ง Configuration

All configuration is done through environment variables in the .env file:

Variable Required Description
TAVILY_API_KEY โœ… API key for Tavily web search โ€” get it at tavily.com
GOOGLE_API_KEY โœ… API key for Google Gemini โ€” get it at AI Studio

๐Ÿง  AI Model

PerCLI uses Google Gemini 2.5 Flash as its underlying language model, configured through Genkit. The model is instructed to:

  • Provide comprehensive, factual answers based on web search results
  • Synthesize information from multiple sources
  • Use numbered citations [1], [2], etc. to reference sources
  • Include a "Sources" section at the end of each response with reference URLs
  • Use markdown formatting for better readability
  • Autonomously decide when to use the web search tool

๐Ÿ›ก๏ธ Error Handling

PerCLI includes robust error handling:

  • Missing API keys โ€” Clear error messages with actionable tips if TAVILY_API_KEY or GOOGLE_API_KEY are not set
  • Search failures โ€” Tavily search errors are caught and surfaced with descriptive messages
  • Runtime errors โ€” Per-query errors are caught without crashing the session, allowing continued interaction
  • Graceful shutdown โ€” Clean exit with farewell message on exit, quit, or Ctrl+C

๐Ÿค Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the ISC License.


Made with โค๏ธ using Genkit, Google Gemini, and Tavily

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages