Locaith CLI
Trợ lý lập trình Locaith ngay trong terminal — đọc và sửa mã, chạy lệnh, nối công cụ MCP, hooks, quay lại (rewind), nhớ việc qua nhiều phiên. Cùng lõi với extension Locaith AI Agent cho VS Code (cùng engine, công cụ, kỹ năng, quyền, nén ngữ cảnh), nên làm trong terminal hay trong editor đều như nhau. Locaith CLI is the Locaith coding agent for your terminal — same engine as the VS Code extension. Quick start below; English notes at the end.
pip install locaith-cli # đã kèm Node.js — không cần cài gì thêm
locaith # mở phiên tương tác (lần đầu: đăng nhập, chọn ngôn ngữ, tin cậy thư mục)
Lần đầu chạy
locaithhỏi ngôn ngữ (Tiếng Việt / English), rồi đăng nhập: trình duyệt mở trang locaith.ai, bấm «Cho phép» — terminal tự nhận. Máy không có trình duyệt (SSH, server):locaith login --no-browser, mở liên kết trên máy khác rồi dán mã.- Đồng ý thông báo dữ liệu (một lần cho tài khoản, dùng chung với extension).
- Chọn tin cậy thư mục làm việc. Thư mục chưa tin cậy: Locaith không chạy hooks, MCP và lệnh tuỳ chỉnh của dự án.
- Gõ việc cần làm, ví dụ:
đọc repo này và cho tôi biết cách chạy test.
Máy chủ / CI không tương tác: đặt LOCAITH_API_KEY thay cho login và dùng locaith -p "…" (xem «Chế độ in một lần»).
Dùng trong phiên tương tác
| Gõ | Việc |
|---|---|
/ |
menu lệnh (lọc khi gõ, ↑↓ chọn, Enter) |
@đường-dẫn |
nhắc một tệp / ảnh / tài liệu (có gợi ý Tab) |
!lệnh |
chạy shell ngay, kết quả đi vào ngữ cảnh |
? |
bảng phím tắt |
Phím: Enter gửi · Ctrl+J / Alt+Enter / \+Enter xuống dòng · ↑↓ lịch sử · Ctrl+R tìm lịch sử · Esc dừng lượt đang chạy (bấm 2 lần: menu rewind) · Ctrl+C xoá/dừng/thoát · Ctrl+D thoát · Shift+Tab đổi chế độ quyền · Ctrl+O mở/gập kết quả công cụ · Ctrl+T bảng việc · Ctrl+L vẽ lại.
Gõ tiếp khi trợ lý đang chạy: tin được xếp hàng và gửi ở ranh giới vòng công cụ kế tiếp.
Lệnh gạch chéo (đầy đủ: /help trong phiên hoặc locaith help commands):
/clear /compact /context /cost /model /mode /thinking /resume /sessions /rewind /fork /tasks /hooks /permissions /agents /mcp /memory /init /skills
/review /simplify /security-review /verify /output-style /config /theme /login /logout /whoami /provider /doctor /update /export /copy /exit.
Tự thêm lệnh: tạo .locaith/commands/ten.md (dự án) hoặc ~/.locaith/commands/ten.md (cá nhân), dùng $ARGUMENTS, @tệp, !`lệnh` .
Dùng khoá hoặc API của hãng khác
Ngoài mô hình Locaith, dùng được khoá của Anthropic · OpenAI · Gemini · DeepSeek · xAI, các API tương thích OpenAI (OpenRouter · Ollama · LM Studio · Groq · Together · Mistral · Fireworks) hoặc máy chủ riêng của bạn:
locaith provider add # trình hướng dẫn: chọn hãng/mẫu → dán khoá (ô ẩn) → thử kết nối
locaith provider add ollama --models qwen3-coder # chạy trên máy bạn, không cần khoá
locaith provider add my-llm --url https://llm.example.com/v1 --key-env MY_LLM_KEY # API riêng
locaith provider key anthropic # lưu / đổi khoá một hãng (--key-stdin · --key-env TÊN · --remove)
locaith provider list | test | remove <id>
locaith --model ollama:qwen3-coder # hoặc /model trong phiên
Trong phiên gõ /provider: nhà cung cấp vừa thêm dùng được ngay. Khoá lưu ở ~/.locaith/provider-keys.json (quyền 600) và gắn với địa chỉ lúc lưu — đổi địa chỉ thì khoá không được gửi đi.
Không nhập khoá ở dòng lệnh (lộ trong lịch sử shell). Cài đặt trong kho mã không thêm được nhà cung cấp hay đổi địa chỉ — chỉ ~/.locaith/settings.json của bạn. Chi tiết: locaith help providers.
Quyền — bạn luôn nắm quyền
Chế độ (đổi bằng Shift+Tab hoặc --permission-mode): default (hỏi trước khi sửa tệp/chạy lệnh) · acceptEdits (tự nhận chỉnh sửa tệp) · plan (chỉ đọc, lập kế hoạch) · bypassPermissions (không hỏi — thận trọng).
Luật chi tiết trong cài đặt permissions.allow / ask / deny, cú pháp Bash(npm test:*), Edit(src/**), Read(.env*), WebFetch(domain:github.com), mcp__máy-chủ__*; thứ tự deny > ask > allow.
Mọi thao tác ngoài thư mục làm việc, tệp bí mật và lệnh nguy hiểm luôn hỏi. Mọi sửa đổi tệp được chụp lại (checkpoints) để quay lại bằng /rewind.
Chế độ in một lần (script, CI)
locaith -p "tóm tắt repo này trong 5 gạch đầu dòng"
cat build.log | locaith -p "vì sao build lỗi?"
locaith -p --output-format json "…" # một đối tượng JSON (result, usage, session_id, num_turns…)
locaith -p --output-format stream-json "…" # NDJSON từng sự kiện
locaith -p --permission-mode acceptEdits "sửa lỗi type trong src/api.ts rồi chạy test"
locaith -p --allowedTools "Bash(npm test:*)" "chạy test và sửa"
Không có terminal để hỏi: thao tác chưa được cấp quyền bị từ chối (không treo). Tiến trình đi stderr, kết quả đi stdout.
| Mã thoát | Nghĩa |
|---|---|
| 0 | Xong |
| 1 | Lỗi (mạng, 401, vượt hạn mức, chưa xong) |
| 2 | Dùng sai lệnh/tuỳ chọn |
| 127 | Không tìm thấy Node.js ≥ 20 |
| 130 | Bị ngắt (Ctrl+C) |
Phiên, ký ức, cài đặt
- Mỗi cuộc trò chuyện tự lưu ở
~/.locaith/sessions.locaith -ctiếp tục phiên gần nhất của thư mục;locaith -r [id]mở lại;locaith sessionsliệt kê. - Ngữ cảnh tự nén ở 80% cửa sổ (kết quả công cụ cũ được lược trước, bản tóm tắt có cấu trúc giữ nguyên yêu cầu của bạn);
/compact <giữ gì>để nén tay. - Chỉ dẫn dự án:
LOCAITH.md(hoặcAGENTS.md,CLAUDE.md) ở gốc dự án và~/.locaith/LOCAITH.md;/inittạo giúp. Ký ức bền ở.locaith/memory/MEMORY.mdvà~/.locaith/memory/MEMORY.md. - Cài đặt (JSON, khoá giống extension bỏ tiền tố
locaithAgent.):~/.locaith/settings.json(cá nhân) <<dự-án>/.locaith/settings.json<<dự-án>/.locaith/settings.local.json.locaith configin đường dẫn các tệp;locaith help settingscó ví dụ. - Hooks (cùng lược đồ Claude Code), MCP (
.mcp.json,~/.locaith/mcp.json,--mcp-config), kỹ năng (.locaith/skills), agent con (.locaith/agents):locaith help hooks,locaith help mcp.
Biến môi trường: LOCAITH_API_KEY, LOCAITH_LANG=vi|en, NO_COLOR=1, LOCAITH_ASCII=1 (khung/biểu tượng ASCII), LOCAITH_HOME (đổi thư mục ~/.locaith), LOCAITH_NODE (đường dẫn Node riêng).
Lệnh con
locaith doctor (kiểm máy + cách sửa) · login / logout / whoami · consent --yes · provider (nhà cung cấp mô hình) · update · sessions · config · help [chủ đề] · --version.
Cập nhật, gỡ cài đặt, thu hồi quyền
locaith update # hoặc: pip install -U locaith-cli
pip uninstall locaith-cli
locaith logout # xoá khoá đã lưu (~/.locaith/cli.json)
Thu hồi phía máy chủ: locaith.ai → «VS Code từ xa» → thu hồi thiết bị có nhãn chứa Locaith CLI. Token sống 90 ngày không dùng; mỗi lần chạy gia hạn thêm. Không ai đưa token cho bạn qua chat/email — đừng dán token cho người lạ.
Kỹ thuật
pip install locaith-cli kéo theo nodejs-wheel-binaries (Node.js đi kèm). Nếu máy đã có Node ≥ 20 thì dùng Node của hệ thống; đặt LOCAITH_NODE để chỉ định. Gói chứa đúng một tệp lõi locaith.cjs (cùng mã nguồn với extension).
Khoá không bao giờ được ghi ra log; locaith doctor --json đã tự ẩn khoá. Mã nguồn công khai ở https://github.com/locaith/locaith-agent (giấy phép FSL-1.1-ALv2).
English notes
- Install:
pip install locaith-cli(Node.js is bundled vianodejs-wheel-binaries; a system Node ≥ 20 is used when present). Run:locaith(first run: language, sign-in, folder trust). - Interactive:
/commands,@filementions,!shell,Shift+Tabpermission modes,Escto interrupt, messages typed while it works are queued./helplists everything. - Non-interactive:
locaith -p "task"(reads stdin,--output-format json|stream-json,--permission-mode,--allowedTools); unprompted actions are denied, never hang. Exit codes: 0 ok · 1 error · 2 usage · 127 Node missing · 130 interrupted. - Same engine as the VS Code extension: permission rules, hooks, checkpoints/rewind, background tasks, MCP, skills, sub-agents, context compaction, independent verification.
- Config:
~/.locaith/settings.json< project.locaith/settings.json<.locaith/settings.local.json; envLOCAITH_API_KEY,LOCAITH_LANG,NO_COLOR,LOCAITH_ASCII,LOCAITH_HOME,LOCAITH_NODE. Project settings need a trusted folder. - Other vendors / your own API (0.4.1):
locaith provider add|key|list|test|removeand/provider— Anthropic, OpenAI, Gemini, DeepSeek, xAI, OpenAI-compatible presets (OpenRouter, Ollama, LM Studio, Groq, Together, Mistral, Fireworks) or any address. Keys go through a hidden prompt,--key-stdinor--key-env(never the command line) and are saved to~/.locaith/provider-keys.json(mode 600), bound to the address they were saved for. A repository cannot add providers or change addresses.locaith help providers. - Diagnose:
locaith doctor· Update:locaith update· Help topics:locaith help commands|shortcuts|print|settings|permissions|providers|hooks|mcp|sessions|memory|troubleshooting.
Metadata
Release files for locaith-cli 0.4.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| locaith_cli-0.4.8.tar.gz | 1.2 MB | Without provenance | Details for locaith_cli-0.4.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| locaith_cli-0.4.8-py3-none-any.whl | Python 3 | none | any | Details for locaith_cli-0.4.8-py3-none-any.whl |
Total release size: 2.3 MB
Release files / locaith_cli-0.4.8.tar.gz
| Download URL | locaith_cli-0.4.8.tar.gz |
|---|---|
| Size | 1.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b944f035896ae08e8271184270cd86b1c9ac12f52651f695ab205456f8351123
|
|
BLAKE2b-256 checksum How to use checksums |
5cb5437f0e1c72db6376fcdd2921e4c5eea4d70225f356d0296da43fc574aaa9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / locaith_cli-0.4.8-py3-none-any.whl
| Download URL | locaith_cli-0.4.8-py3-none-any.whl |
|---|---|
| Size | 1.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
572e8282e79b3118738ebb285e96e70608b31c26a133e6a802a3a86cedb36e0b
|
|
BLAKE2b-256 checksum How to use checksums |
1d0fa4fcbb100394919e9736a78ffa679306812f5ec92339d958d3cdef8868d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for locaith-cli 0.4.8
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.