@cnbcool/cnb-cli 1.7.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +45 -1
  2. package/dist/index.js +39 -37
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -58,4 +58,48 @@ npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --agent codebuddy -y --
58
58
 
59
59
  - `CNB_TOKEN`:访问凭证(必须)
60
60
  - `CNB_API_ENDPOINT`:API 端点,如 `https://api.cnb.cool`(必须)
61
- - `CNB_BRANCH`:默认分支(选填)
61
+ - `CNB_BRANCH`:默认分支(选填)
62
+
63
+ ## cnb git-credential 使用说明
64
+
65
+ `cnb git-credential` 可作为 Git Credential Helper,为 `git clone`、`git pull`、`git push`、Git LFS 等 HTTPS 操作自动提供 CNB 访问凭据。
66
+
67
+ ### 1. 登录 CNB
68
+
69
+ ```bash
70
+ cnb login
71
+ ```
72
+
73
+ 登录成功后,凭据会保存到 `~/.cnb/token`。后续 Git 操作会自动读取该凭据;若 token 过期且存在 `refresh_token`,会自动刷新。
74
+
75
+ ### 2. 配置 Git Credential Helper
76
+
77
+ 推荐只为 CNB 域名配置 helper,避免影响其他 Git 站点:
78
+
79
+ ```bash
80
+ git config --global credential.https://cnb.cool.helper "!cnb git-credential"
81
+ git config --global credential.https://cnb.cool.useHttpPath true
82
+ ```
83
+
84
+ 也可以直接在 `~/.gitconfig` 中加入:
85
+
86
+ ```ini
87
+ [credential "https://cnb.cool"]
88
+ helper = "cnb git-credential"
89
+ useHttpPath = true
90
+ ```
91
+
92
+ ### 3. 使用 HTTPS 地址操作仓库
93
+
94
+ ```bash
95
+ git clone https://cnb.cool/<org>/<repo>.git
96
+ cd <repo>
97
+ git pull
98
+ git push
99
+ ```
100
+
101
+ 说明:
102
+
103
+ - `cnb git-credential` 仅供 Git 内部调用;通常无需手动执行。
104
+ - 凭据来源优先级:CodeBuddy 环境 token、`CNB_TOKEN` 环境变量、`~/.cnb/token` 登录凭据。
105
+ - 如需取消配置,可执行:`git config --global --unset credential.https://cnb.cool.helper`。