This project transforms your command line into an intelligent assistant for managing a personal knowledge base. Using Google's Gemini CLI, it allows you to conversationally query, update, summarize, and organize your local notes and documents (e.g., Markdown, PDFs).
It works directly with your files in a local directory, requiring no complex setup or database migration. Just point it to your notes, and start asking questions.
The system leverages the power of Gemini AI models through the Gemini CLI. Here's the core mechanism:
- System Instructions (
GEMINI.md): When you launch the tool in your knowledge base directory, it readsGEMINI.md. This file acts as a system prompt, telling the AI its role, capabilities, and how to behave. - Local Context: The AI treats all the files in the directory as its knowledge source. It can read and analyze text files, and thanks to its multimodal capabilities, it can also process content within PDFs, including text, tables, and images.
- Custom Commands (
commands.toml): Thecommands.tomlfile defines simple, reusable slash commands (like/queryor/research) that act as shortcuts for common tasks. - Conversational Interface: The tool runs in a chat-like REPL (Read-Eval-Print Loop), allowing for natural, back-and-forth conversations about your knowledge base.
- Conversational Interface: Chat with your documents as if you were talking to a helpful assistant.
- Multi-File Querying: Ask questions that require synthesizing information from multiple files.
- On-the-Fly Summarization: Get quick summaries of long notes or documents.
- File Management: Create new notes or get suggestions on how to organize your existing ones.
- Multimodal Support: Natively analyzes text and images within PDF files.
- External Research: Integrates Google Search to answer questions that require up-to-date, external information.
- Cross-Platform: Works on macOS, Windows (with a small adjustment), and Linux.
- Customizable: Easily modify the AI's instructions or add your own custom commands.
Follow these steps to set up the Personal Knowledge Base Enhancer on your system.
- Node.js: You'll need Node.js version 20 or higher. You can download it from nodejs.org.
- Git: You'll need Git to clone the repository.
First, clone this repository to your local machine and navigate into the directory.
git clone https://github.com/your-username/personal-knowledge-base-enhancer.git
cd personal-knowledge-base-enhancerThe core of this project is the Gemini CLI. Install it globally using npm (which comes with Node.js):
npm install -g gemini-cliTo verify the installation, run gemini --version.
The first time you run the tool, you'll need to authenticate with your Google account.
- Run the
geminicommand in your terminal. - It will prompt you to sign in with your Google account. The free tier is generous, offering up to 60 requests per minute.
Alternatively (for advanced users):
You can set your API key as an environment variable.
-
macOS/Linux:
export GEMINI_API_KEY="your-api-key-here"
(Add this to your
~/.zshrcor~/.bash_profileto make it permanent). -
Windows (Command Prompt):
set GEMINI_API_KEY="your-api-key-here"
-
Windows (PowerShell):
$env:GEMINI_API_KEY="your-api-key-here"
Place your notes and documents (e.g., .md, .pdf, .txt files) into the directory you just cloned. This will be your knowledge base.
-
On macOS and Linux: The project includes a simple shell script to launch the tool. First, make it executable:
chmod +x kb-enhancer.sh
Then, run it:
./kb-enhancer.sh
-
On Windows: The
kb-enhancer.shscript is for Unix-based systems. For Windows, you can run Gemini CLI directly in the project directory:gemini
For a similar launcher experience, you can create a batch file named
kb-enhancer.batwith the following content:@echo off echo Starting Knowledge Base Enhancer... gemini
Save this file in the project directory, and you can run it by simply typing
kb-enhancer.bat.
Once launched, you will be greeted with a welcome message. You can now interact with the assistant.
1. Ask Natural Language Questions Simply type your question and press Enter.
What do my notes say about sustainable farming?
2. Use Custom Slash Commands
These commands are shortcuts defined in commands.toml.
/query [topic]: Search and summarize notes on a topic./query AI ethics/update [file] [changes]: Propose edits to a file./update meeting-notes.md Add a summary point about the Q4 budget/organize [category]: Get suggestions for organizing files./organize recipes/research [query]: Perform a Google search and summarize the results./research latest advancements in battery technology/faq [question]: Ask a question in a conversational, wiki-like manner./faq How do I set up a Zettelkasten system?
3. Exiting the Tool
Press Ctrl+C or type /quit to exit the session.
You can easily tailor this project to your needs.
- AI Behavior: Edit the
GEMINI.mdfile to change the AI's instructions, role, or personality. - Custom Commands: Open
commands.tomlto add new slash commands or modify existing ones.