General Introduction
Open Codex is an open source command line AI tool designed for developers to convert natural language instructions into precise shell commands. It uses a native language model (e.g., phi-4-mini) and requires no networking or API keys; all operations run locally. Users can generate shell commands or code with a simple description, suitable for quick programming tasks. The project is hosted on GitHub, easy to install, and supports macOS, Linux, and Windows. Open Codex emphasizes security and requires user confirmation before command execution to protect the system.
Function List
- Natural Language to Shell Commands: Converts natural language input from the user into executable shell commands.
- Local model runs: Supports local models such as phi-4-mini without the need for an Internet connection, protecting privacy.
- code generation: Generate code snippets in multiple programming languages based on descriptions.
- Order Confirmation Mechanism: User confirmation is required after generating commands to prevent misuse.
- Operation History: Save command history, support view and partial undo functions.
- Plug-in extensions: Support for developers to customize plug-ins to extend the functionality of the tool.
- Cross-platform supportCompatible with macOS, Linux and Windows, and suitable for multiple terminals.
Using Help
Installation process
Open Codex supports multiple installation methods for different operating systems and user habits. Below are the detailed steps to ensure a quick start.
Installation via Homebrew (macOS/Linux)
- Add the Homebrew source for Open Codex:
brew tap codingmoh/open-codex
- Installation Tools:
brew install open-codex
- Verify the installation and check the version:
open-codex --version
Installation via pipx (cross-platform)
- Make sure Python (3.8 or above) and pipx are installed.
- Install Open Codex globally:
pipx install open-codex
- Verify the installation:
open-codex --version
Installation via source code
- Clone a GitHub repository:
git clone https://github.com/codingmoh/open-codex.git
- Go to the project catalog:
cd open-codex
- Install the dependencies:
pip install .
- Verify the installation:
open-codex --version
Basic use
After installation, Open Codex can be invoked from the command line. The following are instructions for operating the core functions.
Natural Language to Shell Commands
The core function of Open Codex is to convert natural language into shell commands. The procedure is as follows:
- Enter natural language commands at the terminal, for example:
open-codex "列出当前目录下所有Python文件"
- tool to generate the corresponding shell commands, for example:
ls *.py
- The system prompts the user to choose:
y
: Execute the command.c
: Copy command to the clipboard.n
: Cancel the operation.
- option
y
The command executes locally and displays the results, e.g., lists all.py
Documentation.
Generating Complex Shell Commands
For complex tasks, Open Codex can also generate multi-step commands. For example:
- Input:
open-codex "查找所有txt文件并统计行数"
- tools may be generated:
find . -name "*.txt" -exec wc -l {} \;
- After the user confirms, the command executes, displaying the number of lines and the total number of each txt file.
Generate Code
In addition to shell commands, Open Codex supports code generation:
- Input:
open-codex "用 Bash 写一个备份文件夹的脚本"
- The tool returns the code, for example:
#!/bin/bash tar -czf backup_$(date +%F).tar.gz /path/to/folder
- User selectable:
- Save to file: Enter
open-codex --save backup.sh
The - Copy to Clipboard: Select
c
The - Direct execution: select
y
(Need to make sure the script is executable).
- Save to file: Enter
View History
- View the history of generated and executed commands:
open-codex --history
- The history is sorted by time, showing commands and execution status.
- Undo operation (if supported):
open-codex --undo
Custom Models
Open Codex uses the phi-4-mini model by default. Switching models step by step:
- Edit the configuration file (located in the
~/.open-codex/config.yaml
):model: phi-4-mini
- modifications
model
fields are other supported local models. - Save and restart the terminal for the switch to take effect.
Featured Function Operation
Security confirmation mechanism
To prevent misuse, all commands require user confirmation before execution:
- After entering natural language commands, the tool displays suggested commands.
- Users are provided with
y
(Implementation),c
(Reproduction) orn
(Cancel) Selection. - option
y
When the command is run in a sandboxed environment, it ensures system security.
Local operation guarantees privacy
Open Codex operates locally and does not require an Internet connection. User data and generated content are not uploaded to the cloud, which is suitable for scenarios with high privacy requirements. For example:
- Generate commands or code in an offline environment.
- Avoid data leakage when handling sensitive projects.
Plug-in extensions
Developers can create plug-in enhancements:
- In the project root directory, create the
plugins
Folder. - Write the plugin according to the documentation (refer to the GitHub repository for the
CONTRIBUTING.md
). - Restart Open Codex and the plugin loads automatically.
caveat
- Make sure Python 3.8 or above is installed.
- Homebrew or pipx installation requires a stable network.
- The source code installation needs to be updated manually, and it is recommended to run it on a regular basis.
git pull
The - The tool is in the development stage and may have unfinished features, so we recommend following the GitHub Issues.
- Complex command generation may be limited by model capabilities, requiring the user to check the accuracy of the commands.
application scenario
- Quick Command Generation
The developer forgets the specific shell command (e.g. unzip tar.gz) and typesopen-codex "解压 tar.gz 文件"
Gettar -xzf file.tar.gz
and implementation. - Offline Development
Developers use Open Codex to generate shell scripts or Python code in network-less environments, protecting project privacy. - system management
Administrator inputopen-codex "查找占用磁盘空间最大的文件"
Getdu -ah | sort -rh | head
, quickly locate the problem. - Learning Shell Scripting
Beginner inputopen-codex "用 Bash 写一个监控CPU的脚本"
, get sample code and learn scripting. - Community Development
Developers contribute new features via GitHub, such as adding new model support or optimizing command generation logic.
QA
- How accurate is natural language to shell commands?
Accuracy depends on modeling capabilities. phi-4-mini can handle common tasks. complex commands suggest that the user check the generated results. - Are other terminal commands supported?
The main support is for shell commands (bash/zsh), with possible future extensions to PowerShell, etc. See the GitHub roadmap for details. - How do I handle the Generate Error command?
After checking the command selectn
Cancellation of execution, or adoption ofopen-codex --history
Check history and revoke if necessary. - Does it support multi-language input?
Currently optimized for Chinese and English input, other languages may require more precise descriptions. - How do I give feedback on a problem?
Visit the GitHub repository (https://github.com/codingmoh/open-codex) to submit Issues or Pull Requests.