quick-ai is a command-line based AI assistant. Users can execute commands in the command line to interact with AI.
Traditional AI chat tools with UI interfaces, such as Cherry Studio, Doubao, etc., generally take a long time to start. Even for a small question, you have to wait a long time to get an answer. With quick-ai, you can get short answers directly in the command line, which is much faster. Additionally, it can work with local large model tools like LMStudio for offline use. Disadvantage: Only suitable for short answers, historical conversations need to be opened using code.
- Installation
npm -g i @vtxf/quick-ai- Usage
qa <user input>
qa -c <user input>qa <user input>: Interact directly with AI in the consoleqa -c <user input>: Continue the conversation with AI based on the previous conversation contentqa -e: Open editor to view conversation contentqa -C: Open configuration fileqa -p: Open system prompt configuration fileqa -h: Display help information
This tool supports Windows, Linux, and macOS systems.
The configuration file is located at ~/.quick-ai/config.json, where the ~ symbol resolves to the user's home directory on different operating systems:
- Windows:
%USERPROFILE%\.quick-ai\config.json - Linux/macOS:
~/.quick-ai/config.json
The system prompt configuration file is located at ~/.quick-ai/system_prompt.md, used to configure the system prompt for AI conversations:
- Windows:
%USERPROFILE%\.quick-ai\system_prompt.md - Linux/macOS:
~/.quick-ai/system_prompt.md
This file defines the behavior and role of the AI assistant. If the file does not exist, the system will automatically create a default system prompt.
{
"env": {
"QUICKAI_OPENAI_BASE_URL": "http://localhost:1234/v1",
"QUICKAI_OPENAI_API_KEY": "",
"QUICKAI_OPENAI_MODEL": "qwen/qwen3-4b-2507",
"QUICKAI_EDITOR": "code -r <QUICKAI_HISTORY_DIR> <QUICKNOTE_HISTORY_FILE_PATH>"
}
}{
"env": {
"QUICKAI_OPENAI_BASE_URL": "https://open.bigmodel.cn/api/paas/v4",
"QUICKAI_OPENAI_API_KEY": "your_glm_api_key",
"QUICKAI_OPENAI_MODEL": "glm-4.5-flash",
"QUICKAI_EDITOR": "code -r <QUICKAI_HISTORY_DIR> <QUICKNOTE_HISTORY_FILE_PATH>"
}
}The QUICKAI_EDITOR environment variable supports various editor configurations, here are some common configuration examples:
"QUICKAI_EDITOR": "notepad <QUICKNOTE_HISTORY_FILE_PATH>""QUICKAI_EDITOR": "vim <QUICKNOTE_HISTORY_FILE_PATH>""QUICKAI_EDITOR": "code -r <QUICKAI_HISTORY_DIR> <QUICKNOTE_HISTORY_FILE_PATH>"Users can choose appropriate editor configurations according to their preferences and system environment.
- If the configuration file does not exist, the system will automatically generate a default configuration file
- The system prioritizes reading environment variables from the configuration file
- If a certain environment variable does not exist in the configuration file, it attempts to read from the system environment variables
QUICKAI_OPENAI_API_KEYcan be left unset, as some large models do not require an API key
QUICKAI_OPENAI_BASE_URL: OpenAI API base URLQUICKAI_OPENAI_API_KEY: OpenAI API key (optional)QUICKAI_OPENAI_MODEL: Model name to use
QUICKAI_HISTORY_DIR: History record directory, forcibly specified as~/.quick-ai/historyfolderQUICKNOTE_HISTORY_FILE_PATH: History record file path, format is~/.quick-ai/history/YYYY/YYYYMM/YYYYMMDD.jsonl, dynamically specified as the current date.
Conversation history is stored in the ~/.quick-ai/history folder, adopting the following structure:
~/.quick-ai/history/
├── YYYY/ # Year directory
│ ├── YYYYMM/ # Year-month directory
│ │ ├── YYYYMMDD.jsonl # Date file, one JSON conversation record per line
├── last.json # JSON file of the most recent conversation
Each conversation record is a JSON object, formatted as follows:
{
"id": 1698704000000,
"date": "20251020",
"messages": [
{
"role": "user",
"content": "Hello"
},
{
"role": "assistant",
"content": "Hello! How can I help you?"
}
]
}id: Unique identifier of the conversation, using millisecond-level timestampdate: Date when the conversation occurred, format is YYYYMMDDmessages: Conversation content array, each element containsrole(user/assistant) andcontentfields
last.json: Only stores the complete JSON object of the most recent conversationYYYYMMDD.jsonl: Stores one conversation JSON object per line (without line breaks, ensuring the entire JSON is on one line)
Execution process:
- Check if
last.jsonexists and has content - If it exists, append the content of
last.jsonto the end of theYYYYMMDD.jsonlfile specified by itsdateattribute - After appending, delete the
last.jsonfile (to prepare for a new conversation) - If it does not exist, skip history processing
- Start a new conversation
- Determine if an AI response is obtained
- If an AI response is obtained, create a new
last.jsonand save the conversation content - If no AI response is obtained, print error information to the console, do not create a new
last.jsonfile
flowchart TD
A[Start executing qa command] --> B{Check if last.json exists and has content}
B -->|Yes| C[Append last.json content to the end of the corresponding date's YYYYMMDD.jsonl file]
B -->|No| D[Skip history processing]
C --> E[Delete last.json file]
D --> F[Start a new conversation]
E --> F
F --> G{Is AI response obtained}
G -->|Yes| H[Create new last.json and save conversation content]
G -->|No| I[Print error information to console]
H --> J[End]
I --> J
Execution process:
- Check if
last.jsonexists - If it exists, read
last.jsonto get the recent conversation content - If it does not exist, start as a new conversation
- If recent conversation content exists, continue interacting with AI based on the recent conversation content
- Determine if an AI response is obtained
- If an AI response is obtained, update
last.jsonto save the conversation content (note: this command does not process history files, only updates last.json) - If no AI response is obtained, print error information to the console, do not update the
last.jsonfile
flowchart TD
A[Start executing qa -c command] --> B{Check if last.json exists}
B -->|Yes| C[Read last.json to get recent conversation content]
B -->|No| D[Start as a new conversation]
C --> E[Continue interacting with AI based on recent conversation content]
D --> F{Is AI response obtained}
E --> F
F -->|Yes| G[Create or update last.json to save conversation content]
F -->|No| H[Print error information to console]
G --> I[End]
H --> I
Execution process:
- Open editor to view the day's historical conversation file
YYYYMMDD.jsonl - Set the current directory to
~/.quick-ai/history - Get the
QUICKAI_EDITORenvironment variable - Replace placeholders in the environment variable:
<QUICKAI_HISTORY_DIR>replaced with~/.quick-ai/history<QUICKNOTE_HISTORY_FILE_PATH>replaced with the current day's history file path
- Console should prompt the user: The most recent conversation content is in the last.json file, not in the current day's history file (only previously completed conversations are saved to the history file)
- Execute the editor command
flowchart TD
A[Start executing qa -e command] --> B[Set current directory to ~/.quick-ai/history]
B --> C[Get QUICKAI_EDITOR environment variable]
C --> D[Replace placeholders in environment variable]
D --> E[Prompt user that the most recent conversation is in last.json]
E --> F[Execute editor command to open current day's history file]
F --> G[End]
Execution process:
- Check if the configuration file directory exists
- If it does not exist, create the configuration file directory
- Check if the configuration file exists
- If it does not exist, create a default configuration file
- Get the editor command, prioritizing the system default editor
- Clean placeholders in the editor command
- Execute the editor command to open the configuration file
flowchart TD
A[Start executing qa -C command] --> B[Check if configuration file directory exists]
B -->|No| C[Create configuration file directory]
B -->|Yes| D[Check if configuration file exists]
C --> D
D -->|No| E[Create default configuration file]
D -->|Yes| F[Get editor command]
E --> F
F --> G[Clean placeholders in editor command]
G --> H[Execute editor command to open configuration file]
H --> I[End]
Execution process:
- Check if the system prompt directory exists
- If it does not exist, create the system prompt directory
- Check if the system prompt file exists
- If it does not exist, create a default system prompt file
- Get the editor command, prioritizing the system default editor
- Clean placeholders in the editor command
- Execute the editor command to open the system prompt file
flowchart TD
A[Start executing qa -p command] --> B[Check if system prompt directory exists]
B -->|No| C[Create system prompt directory]
B -->|Yes| D[Check if system prompt file exists]
C --> D
D -->|No| E[Create default system prompt file]
D -->|Yes| F[Get editor command]
E --> F
F --> G[Clean placeholders in editor command]
G --> H[Execute editor command to open system prompt file]
H --> I[End]
Execution process:
- Display help information, including descriptions and usage of all available commands
- Display configuration file location and environment variable descriptions
- Display history record storage structure description
- Display common questions and answers and error handling methods
In addition to the qa -e command, users can also freely view historical conversations through the following methods:
- Directly open any history file in the
~/.quick-ai/historydirectory - Use any text editor to view
YYYYMMDD.jsonlfiles - Use command line tools (such as
cat,grep, etc.) to search and filter history records
- If the configuration file does not exist, automatically generate a default configuration file
- If the configuration file format is incorrect, prompt the user and use default configuration
- If unable to connect to the AI service, prompt the user that the connection was unsuccessful
- Display specific error reasons (such as network issues, API key errors, etc.)
- When connection fails, end the current conversation and save the ongoing interaction to history records
- If the history record directory cannot be created, prompt the user and exit
- If the history record file cannot be written, prompt the user and exit
- Path separators: Windows uses
\, Linux/macOS uses/ - Environment variables: Windows uses
%VAR%or$env:VAR, Linux/macOS uses$VAR - Command execution: Consider command differences on different operating systems
- Use millisecond-level timestamp as conversation ID
- The possibility of multiple conversations occurring within the same millisecond is extremely low, so conflict handling is not considered
- Prioritize reading API keys from the configuration file
- If it does not exist in the configuration file, read from system environment variables
- If neither exists, some models may not need an API key, continue execution
- History record files are split by date to avoid single files being too large
- During each AI conversation, the system automatically reads the content of the
~/.quick-ai/system_prompt.mdfile as the system prompt - The system prompt defines the role and behavior of the AI assistant.
- Users can edit the system prompt through the
qa -pcommand to customize the function and behavior of the AI assistant - If the system prompt file does not exist, the system will automatically create a prompt
- The
last.jsonfile is created or updated after each conversation ends, rather than being deleted! - The system prompt file supports Markdown format and can contain detailed instructions and examples
- After modifying the system prompt, new conversations will immediately use the updated prompt content
- This is a Node.js project, avoid using external libraries unless necessary.