feat: 實作 bear CLI PAT 模式 MVP(login/whoami/token/logout/status)

- 新增 Elixir + Mix escript 專案(Req 0.5+、Jason)
- login --token <PAT>:以 PAT 驗證 /userinfo 後寫入憑證檔(0600)
- whoami:GET /userinfo 顯示身分 claims(支援 --json)
- token:印出 access token 供 pipe(--refresh 在 PAT 模式忽略)
- logout:清除本機憑證;status:純本機判定
- 憑證檔採原子寫入(rename)、0600、O_CREAT|O_EXCL 防 symlink
- 全域選項:--issuer/--config/--json/-v/-h/--version
- 29 個單元測試;mix precommit(compile --warnings-as-errors + format + test)
- 更新 README.md 與 docs/commands.md 反映 PAT 模式 MVP

Device Flow 登入待伺服器端 P1(bear 倉庫)完成後再接。issue #2
This commit is contained in:
2026-08-31 11:14:12 +08:00
parent 14edb84a59
commit 870011f8a7
15 changed files with 1118 additions and 8 deletions
+14
View File
@@ -0,0 +1,14 @@
defmodule BearCli do
@moduledoc """
Bear CLI — Bear SSO 的終端機客戶端。
以 Bear 個人存取權杖(Personal Access Token, PAT)在終端機登入,查詢身分
(`whoami`)、取得 Token(`token`),作為 SSO 的終端入口。Device
Authorization Grant(RFC 8628)登入待伺服器端 P1(bear 倉庫)完成後再接上。
"""
@version "0.1.0"
@doc "回傳 CLI 版本字串(與 mix.exs 的 version 同步)。"
def version, do: @version
end