CLI output và automation
Bestie CLI có hai kiểu output: output thân thiện cho terminal và output máy đọc được cho scripts. Dùng các tùy chọn trong trang này khi chạy Bestie trong CI, shell scripts, cron jobs hoặc automation khác.
Tắt banner
Phần tiêu đề “Tắt banner”Các lệnh human-facing in Bestie ASCII banner trước nội dung lệnh. Trong terminal interactive, banner có thể animate ngắn. Trong output non-interactive, Bestie in banner tĩnh.
Tắt banner cho một command:
BESTIE_NO_BANNER=1 bestie statusGiữ banner nhưng tắt animation:
BESTIE_BANNER=static bestie statusÉp animation khi stdout là TTY:
BESTIE_BANNER=animate bestie statusCác command máy đọc được tự suppress banner khi CLI entrypoint nhận diện được.
Tắt màu
Phần tiêu đề “Tắt màu”Bestie dùng badge, table và progress indicator có màu cho human output khi stdout là TTY.
Tắt ANSI color:
NO_COLOR=1 bestie doctorDùng cách này khi capture command output vào script hoặc log không nên chứa terminal escape sequences.
Dùng command máy đọc được
Phần tiêu đề “Dùng command máy đọc được”Ưu tiên command có JSON hoặc raw output khi automation cần parse kết quả.
Doctor JSON:
bestie doctor --jsonChannel Doctor JSON:
bestie channels doctor --channel all --jsonbestie channels doctor --channel telegram --connect --jsonbestie channels doctor --channel zalo --connect --jsonMCP tool call JSON:
bestie mcp call dry-run read_file --read --json '{"path":"README.md"}'Memory JSON và export commands:
bestie memory exportbestie memory analyze --jsonbestie memory cleanup --dry-run --jsonbestie memory cleanup --apply --yes --jsonNhững command này được thiết kế để tránh decorative output. Với command chưa có JSON mode, set BESTIE_NO_BANNER=1 và NO_COLOR=1 trước khi parse human output.
Xử lý update notice
Phần tiêu đề “Xử lý update notice”Bestie có thể in update notice nhẹ khi npm có bản mới hơn. Notice cho biết version hiện tại, version mới nhất và command để update:
Có bản Bestie mới: <current> -> <latest>Chạy `bestie update --apply` để cài bản npm mới nhất.Update notice dùng cache 24 giờ trong runtime data directory. Chat và daemon start hoặc restart path có thể kích hoạt notice này.
Chủ động kiểm tra update
Phần tiêu đề “Chủ động kiểm tra update”Chạy npm version check rõ ràng:
bestie updateBestie đọc package name và version hiện tại từ package.json đã cài, hỏi npm registry version mới nhất, ghi update-check.json trong runtime data directory, rồi in current/latest version.
Nếu không kết nối được npm, Bestie vẫn in local version, báo npm check failed, gợi ý command cài thủ công và exit non-zero.
Apply update nếu có:
bestie update --apply--apply chạy:
npm install -g bestie-agent@latestNếu install command thành công, mở terminal mới nếu shell của bạn vẫn cache binary bestie cũ. Nếu npm exit non-zero, Bestie báo exit code đó.
Chỉ dùng --apply khi môi trường cho phép sửa global npm installation. Trong CI hoặc host bị khóa, ưu tiên bestie update rồi để deployment process quyết định cách cài version mới.
Kiểm tra exit codes
Phần tiêu đề “Kiểm tra exit codes”Doctor exit non-zero khi phát hiện lỗi:
bestie doctor --json > doctor-report.jsonDùng exit code để fail CI hoặc setup scripts, và dùng JSON report để hiển thị các check bị fail.
Command arguments không hợp lệ cũng set hoặc trả về exit status non-zero. Với command destructive hoặc thay đổi state, chỉ dùng confirmation flag như --yes, --apply hoặc --confirm sau khi dry run đã ổn.
Checklist cho script
Phần tiêu đề “Checklist cho script”- Ưu tiên
--jsonhoặc raw export command khi có. - Set
BESTIE_NO_BANNER=1cho human-facing command được dùng trong scripts. - Set
NO_COLOR=1khi logs không nên chứa ANSI escape sequences. - Xem update notice là human output, không phải dữ liệu máy đọc được.
- Giữ secrets trong
.bestie/.envhoặc environment variables, không để trong command arguments hoặc logs. - Tránh parse decorative human table khi đã có JSON command.
