@cnbcool/cnb-cli 1.15.6 → 1.15.8
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.
- package/README.en.md +95 -0
- package/README.md +2 -23
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.en.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# CNB Skills
|
|
2
|
+
|
|
3
|
+
A collection of CNB platform skills that support multiple popular Agents, installable with a single `npx skills` command.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Recommended: install all Skills globally, available to all Agents
|
|
9
|
+
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git -g -y
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Once installed, all CNB Skills are ready to use in any Agent.
|
|
13
|
+
|
|
14
|
+
## More Installation Options
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Install to a specific Agent (e.g. CodeBuddy; when --agent is omitted, it auto-detects and prompts for selection)
|
|
18
|
+
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --agent codebuddy -y
|
|
19
|
+
|
|
20
|
+
# Install to multiple Agents at once
|
|
21
|
+
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --agent codebuddy --agent claude-code -y
|
|
22
|
+
|
|
23
|
+
# Install to all supported Agents
|
|
24
|
+
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --agent '*' -y
|
|
25
|
+
|
|
26
|
+
# Install a specific Skill only (run --list first to view installable items)
|
|
27
|
+
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --list
|
|
28
|
+
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --skill cnb-api --agent codebuddy -y
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Prerequisites
|
|
34
|
+
|
|
35
|
+
Using `npx skills` requires cnb-cli:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# macOS / Linux
|
|
39
|
+
curl -fsSL https://cnb.cool/cnb/skills/cnb-skill/-/git/raw/main/install.sh | sh
|
|
40
|
+
|
|
41
|
+
# Windows PowerShell
|
|
42
|
+
irm https://cnb.cool/cnb/skills/cnb-skill/-/git/raw/main/install.ps1 | iex
|
|
43
|
+
|
|
44
|
+
# npm
|
|
45
|
+
npm install @cnbcool/cnb-cli -g
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
> You can also manually download it from [Releases](https://cnb.cool/cnb/skills/cnb-skill/-/releases).
|
|
49
|
+
|
|
50
|
+
## AI Installation Prompt
|
|
51
|
+
|
|
52
|
+
Send the following to your Agent to install automatically; replace the `--agent` argument as needed:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
npm install @cnbcool/cnb-cli -g
|
|
56
|
+
npm install skills -g
|
|
57
|
+
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --agent codebuddy -y --copy
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Environment Variables
|
|
61
|
+
|
|
62
|
+
| Variable | Description | Required |
|
|
63
|
+
| --- | --- | --- |
|
|
64
|
+
| `CNB_TOKEN` | Access credential | Yes |
|
|
65
|
+
| `CNB_API_ENDPOINT` | API endpoint, e.g. `https://api.cnb.cool` | Yes |
|
|
66
|
+
| `CNB_BRANCH` | Default branch | No |
|
|
67
|
+
|
|
68
|
+
## cnb git-credential
|
|
69
|
+
|
|
70
|
+
`cnb git-credential` can act as a Git Credential Helper, automatically providing CNB access credentials for HTTPS operations.
|
|
71
|
+
|
|
72
|
+
### 1. Login
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
cnb login
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 2. Configure Git
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
git config --global credential.https://cnb.cool.helper ""
|
|
82
|
+
git config --global credential.https://cnb.cool.helper "!cnb git-credential"
|
|
83
|
+
git config --global credential.https://cnb.cool.useHttpPath true
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 3. Use HTTPS Operations
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
git clone https://cnb.cool/<org>/<repo>.git
|
|
90
|
+
cd <repo>
|
|
91
|
+
git pull
|
|
92
|
+
git push
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
> Credential source priority: CodeBuddy environment token → `CNB_TOKEN` environment variable → `~/.cnb/token` login credentials.
|
package/README.md
CHANGED
|
@@ -11,25 +11,10 @@ npx skills add https://cnb.cool/cnb/skills/cnb-skill.git -g -y
|
|
|
11
11
|
|
|
12
12
|
安装后所有 CNB Skills 即可在任意 Agent 中使用。
|
|
13
13
|
|
|
14
|
-
## 支持的 Agent
|
|
15
|
-
|
|
16
|
-
| Agent | `--agent` |
|
|
17
|
-
| --- | --- |
|
|
18
|
-
| CodeBuddy | `codebuddy` |
|
|
19
|
-
| Claude Code | `claude-code` |
|
|
20
|
-
| Codex | `codex` |
|
|
21
|
-
| Cursor | `cursor` |
|
|
22
|
-
| Gemini CLI | `gemini-cli` |
|
|
23
|
-
| OpenCode | `opencode` |
|
|
24
|
-
| Qwen Code | `qwen-code` |
|
|
25
|
-
| Windsurf | `windsurf` |
|
|
26
|
-
|
|
27
14
|
## 更多安装方式
|
|
28
15
|
|
|
29
|
-
### 安装到指定 Agent
|
|
30
|
-
|
|
31
16
|
```bash
|
|
32
|
-
#
|
|
17
|
+
# 安装到指定 Agent(如 CodeBuddy;不指定 --agent 时自动检测并提示选择)
|
|
33
18
|
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --agent codebuddy -y
|
|
34
19
|
|
|
35
20
|
# 同时安装到多个 Agent
|
|
@@ -37,15 +22,9 @@ npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --agent codebuddy --age
|
|
|
37
22
|
|
|
38
23
|
# 安装到所有支持的 Agent
|
|
39
24
|
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --agent '*' -y
|
|
40
|
-
```
|
|
41
25
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
# 查看仓库中可安装的 Skill
|
|
26
|
+
# 只安装指定 Skill(先用 --list 查看可安装项)
|
|
46
27
|
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --list
|
|
47
|
-
|
|
48
|
-
# 安装指定 Skill
|
|
49
28
|
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --skill cnb-api --agent codebuddy -y
|
|
50
29
|
```
|
|
51
30
|
|
package/dist/index.js
CHANGED
|
@@ -150,4 +150,4 @@ PR 页面路径: ${s}
|
|
|
150
150
|
登录成功 \uD83C\uDF89`),r.debug){if(console.log(` token_type : ${n.token_type}`),console.log(` expires_in : ${n.expires_in}`),console.log(` scope : ${n.scope||""}`),console.log(` access_token : ${(0,G.maskToken)(n.access_token)}`),n.refresh_token)console.log(` refresh_token : ${(0,G.maskToken)(n.refresh_token)}`);if(n.id_token)console.log(` id_token : ${(0,G.maskToken)(n.id_token)}`)}let a=Math.floor(Date.now()/1000),l=`https://api.${new URL(r.platformURL).hostname}`,u={access_token:n.access_token,expires_at:a+n.expires_in,platform_url:r.platformURL,client_id:r.clientID,login_host:l};if(n.refresh_token)u.refresh_token=n.refresh_token;if((0,G.saveToken)(u),r.debug)console.log(`Token 已保存到 ${(0,G.getTokenPath)()}`)}catch(s){console.error(`
|
|
151
151
|
登录失败: ${s.message}`),process.exit(1)}})}});var og=o((so)=>{Object.defineProperty(so,"__esModule",{value:!0});so.registerLogoutCommand=i1;var xI=r1(require("fs")),e1=re(),t1=oe();function r1(e){return e&&e.__esModule?e:{default:e}}function i1(e){e.command("logout").description("退出登录,删除本地保存的 access_token").option("--debug","打印调试信息",!1).helpOption("-h, --help","显示帮助文档").action(async(t)=>{let r=(0,e1.getTokenPath)(),i=(0,t1.loadToken)();if(!i){console.log("当前未登录,无需退出。");return}if(t.debug)console.log(`Token 文件路径: ${r}`),console.log(`Platform URL : ${i.platform_url}`),console.log(`Client ID : ${i.client_id}`);try{xI.default.unlinkSync(r),console.log("已成功退出登录。")}catch(s){console.error(`退出登录失败: ${s.message}`),process.exit(1)}})}});var ag=o((po)=>{Object.defineProperty(po,"__esModule",{value:!0});po.registerStatusCommand=a1;var s1=_t(),p1=_e(),n1=re(),o1={workbuddy:"WorkBuddy 远程获取",codebuddy_env:"CNB_TOKEN_FOR_CODEBUDDY 环境变量",env:"CNB_TOKEN 环境变量"};function a1(e){e.command("status").description("检查当前登录状态(token 是否存在、是否过期)").option("--debug","打印调试信息",!1).helpOption("-h, --help","显示帮助文档").action(async(t)=>{let r=await(0,s1.resolveTokenSource)();if(r.source==="none"){console.log(r.reason?`⚠️ ${r.reason}`:"⚠️ 未登录,请执行 `cnb login` 进行授权。");return}if(r.source!=="file"){if(console.log("✅ 已登录。"),t.debug)console.log(` Token 来源: ${o1[r.source]}`);return}let i=(0,n1.getTokenPath)(),s=r.store;if(t.debug)console.log(`Token 文件路径 : ${i}`),console.log(`Platform URL : ${s.platform_url||"未知"}`),console.log(`Client ID : ${s.client_id||"未知"}`),console.log(`Expires At : ${new Date(s.expires_at*1000).toLocaleString()}`);if(Math.floor(Date.now()/1000)>=s.expires_at)if(s.refresh_token){if(t.debug)console.log("Token 已过期,尝试使用 refresh_token 刷新...");try{if(await(0,p1.refreshAccessToken)(s),console.log("✅ 已登录。"),t.debug)console.log(" (Token 已自动刷新)")}catch(a){if(t.debug)console.log(`刷新失败: ${a.message}`);console.log("⚠️ 未登录,请执行 `cnb login` 重新授权。")}}else console.log("⚠️ 未登录,请执行 `cnb login` 重新授权。");else console.log("✅ 已登录。")})}});var dg=o((no)=>{Object.defineProperty(no,"__esModule",{value:!0});no.registerGitCredentialCommand=l1;var d1=ve(),c1=ro(),y1=8000;function l1(e){e.command("git-credential <action>").description("作为 git credential helper,向 git 提供 CNB 凭据(仅供 git 内部调用)").allowUnknownOption().allowExcessArguments().helpOption("-h, --help","显示帮助文档").action(async(t,r,i)=>{let s=i.args.slice(0,-1);if(s.length>0)console.error(`[git-credential]: custom args: ${s.join(" ")}`);if(t==="store"||t==="erase")console.error(`[git-credential]: ${t} ignored`),process.exit(0);if(t!=="get")console.error(`[git-credential]: unknown action: ${t}`),process.exit(1);try{let p=await b1(y1),n=h1(p,"=");m1(n),await u1(n),process.exit(0)}catch(p){console.error(p?.message?p.message:String(p)),process.exit(2)}})}async function u1(e){let{host:t}=e;console.error(`[git-credential]: for ${e.protocol}://${e.host}/${e.path??""}`);let r=(0,c1.getGitRemoteHosts)();if(!t||r.length===0||!r.includes(t))throw Error(`unknown host: ${t}`);let i=await g1(e);process.stdout.write(`username=${i.username}
|
|
152
152
|
`),process.stdout.write(`password=${i.password}
|
|
153
|
-
`),console.error("[git-credential]: done")}async function g1(e){return{username:"cnb",password:await(0,d1.resolveToken)()}}function m1(e){if(!e.path)return;if(e.path.endsWith(".git"))e.path=e.path.slice(0,-4);else if(e.path.endsWith(".git/info/lfs"))e.path=e.path.slice(0,-13)}function b1(e){return new Promise((t,r)=>{let i=[],s=!1,p=()=>{if(s)return;s=!0,clearTimeout(n),t(Buffer.concat(i).toString("utf-8"))},n=setTimeout(()=>{if(s)return;s=!0,console.error("[git-credential]: timeout occurred"),r(Error("stdin timeout"))},e);process.stdin.on("data",(a)=>{if(i.push(a),a.length===1&&a[0]===10)p()}),process.stdin.on("end",()=>{p()}),process.stdin.on("error",(a)=>{if(s)return;s=!0,clearTimeout(n),r(a)})})}function h1(e,t){return e.split(/(?:\r\n|\r|\n)/).filter(Boolean).map((r)=>{let i=r.indexOf(t),s=i>=0?r.substring(0,i).trim():r.trim(),p=i>=0?r.substring(i+1).trim():"";return{key:s,value:p}}).reduce((r,{key:i,value:s})=>{if(i)r[i]=s;return r},{})}});Object.defineProperty(exports,"__esModule",{value:!0});Object.defineProperty(exports,"parseArguments",{enumerable:!0,get:function(){return z1.parseUnknownOptions}});var f1=pt(),_1=Ao(),v1=Cu(),P1=Du(),j1=ng(),k1=og(),K1=ag(),A1=dg(),z1=Et(),O=new f1.Command;O.name("cnb").description("CNB OpenAPI 命令行工具").version("1.15.
|
|
153
|
+
`),console.error("[git-credential]: done")}async function g1(e){return{username:"cnb",password:await(0,d1.resolveToken)()}}function m1(e){if(!e.path)return;if(e.path.endsWith(".git"))e.path=e.path.slice(0,-4);else if(e.path.endsWith(".git/info/lfs"))e.path=e.path.slice(0,-13)}function b1(e){return new Promise((t,r)=>{let i=[],s=!1,p=()=>{if(s)return;s=!0,clearTimeout(n),t(Buffer.concat(i).toString("utf-8"))},n=setTimeout(()=>{if(s)return;s=!0,console.error("[git-credential]: timeout occurred"),r(Error("stdin timeout"))},e);process.stdin.on("data",(a)=>{if(i.push(a),a.length===1&&a[0]===10)p()}),process.stdin.on("end",()=>{p()}),process.stdin.on("error",(a)=>{if(s)return;s=!0,clearTimeout(n),r(a)})})}function h1(e,t){return e.split(/(?:\r\n|\r|\n)/).filter(Boolean).map((r)=>{let i=r.indexOf(t),s=i>=0?r.substring(0,i).trim():r.trim(),p=i>=0?r.substring(i+1).trim():"";return{key:s,value:p}}).reduce((r,{key:i,value:s})=>{if(i)r[i]=s;return r},{})}});Object.defineProperty(exports,"__esModule",{value:!0});Object.defineProperty(exports,"parseArguments",{enumerable:!0,get:function(){return z1.parseUnknownOptions}});var f1=pt(),_1=Ao(),v1=Cu(),P1=Du(),j1=ng(),k1=og(),K1=ag(),A1=dg(),z1=Et(),O=new f1.Command;O.name("cnb").description("CNB OpenAPI 命令行工具").version("1.15.8","--version","显示版本号").allowUnknownOption().allowExcessArguments().helpOption("-h, --help","显示帮助文档").option("-s, --short","显示当前仓库的快捷命令").addHelpText("after",(0,_1.getExtraHelpText)());(0,j1.registerLoginCommand)(O);(0,k1.registerLogoutCommand)(O);(0,K1.registerStatusCommand)(O);(0,A1.registerGitCredentialCommand)(O);(0,v1.registerModuleCommands)(O);(0,P1.registerFallbackAction)(O);O.parseAsync(process.argv);
|