Skip to main content

Code5 - NVIDIA AI Coding Agent

一個類似 OpenCode 的開源 AI Coding Agent,使用 NVIDIA NIM 服務作為 LLM 後端。

功能特色

  • AI 對話式編碼輔助 - 使用自然語言與 AI 互動
  • Shell 命令執行 - 自動執行 shell 命令
  • 安全審查 - 防止執行危險命令
  • 對話記憶 - 滾動歷史 + 關鍵資訊提取
  • 多 Session 支援 - 支援多個獨立對話
  • Mock 模式 - 測試無需呼叫真實 LLM

安裝

pip install code5

或開發模式:

pip install -e ".[dev]"

快速開始

使用 Mock 模式(測試用)

from code5 import Code5Agent, MockClient

agent = Code5Agent(client=MockClient())
result = await agent.run("Hello!")

使用 NVIDIA NIM

from code5 import Code5Agent, Config
from code5.client import NVIDIAClient

config = Config(api_key="nvapi-xxx")
agent = Code5Agent(client=NVIDIAClient(config))
result = await agent.run("Help me write a function")

CLI 使用

# 互動模式
code5

# 單次執行
code5 "幫我寫一個 hello.py"

# 使用 mock
code5 --use-mock "Hello"

設定

透過環境變數:

  • NVIDIA_API_KEY - NVIDIA NIM API key
  • NVIDIA_MODEL - 模型名稱(預設:minimaxai/minimax-m2.7)
  • NVIDIA_BASE_URL - API 端點
  • CODE5_USE_MOCK - 設為 true 使用 mock 模式

測試

./test.sh

專案結構

code5/
├── src/code5/
│   ├── __init__.py      # 套件導出
│   ├── agent.py         # 主要 Agent 類別
│   ├── client.py        # LLM 客戶端
│   ├── config.py        # 設定管理
│   ├── memory.py        # 記憶體管理
│   ├── prompts.py       # System prompts
│   ├── reviewer.py      # 安全審查
│   ├── session.py       # Session 管理
│   ├── tools.py         # 工具執行
│   └── __main__.py      # CLI 入口
└── tests/              # 測試檔案

授權

MIT License

Metadata

Release files for code5 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for code5 0.7.0
File Size Uploaded Provenance
code5-0.7.0.tar.gz 35.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for code5 0.7.0
File Interpreter ABI Platform
code5-0.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 63.9 kB

Release files / code5-0.7.0.tar.gz

Download URL code5-0.7.0.tar.gz
Size 35.6 kB
Tags Source
SHA-256 checksum
How to use checksums
818ab6e6810eb78e23c3ac164ce298d3ffc44ce086791f99e5d147070e20caa3
BLAKE2b-256 checksum
How to use checksums
468b7fbdc9afa89544da48e1459a46b7a8384381c3dbfe65c261a1e51c5da1c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / code5-0.7.0-py3-none-any.whl

Download URL code5-0.7.0-py3-none-any.whl
Size 28.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2bedfc2e652495e7e90b6724c009145ca8a2d829fe7b41d38eb66b44637f6c11
BLAKE2b-256 checksum
How to use checksums
ee3497ddd94b4aab1c8df19cceabde60c8390c2d8be823d164467cc9217d6694
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Security for code5 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page