@cnbcool/cnb-cli 1.9.0 → 1.9.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.
- package/README.md +37 -3
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,20 +1,54 @@
|
|
|
1
1
|
# CNB Skills
|
|
2
2
|
|
|
3
|
-
CNB
|
|
3
|
+
CNB 平台技能集合,基于开放的 Agent Skills 生态,不仅支持 CodeBuddy,也支持 Claude Code、Codex、Cursor、Gemini CLI、OpenCode、Qwen Code、Windsurf 等多种 Agent,通过 `npx skills` 一键安装。
|
|
4
4
|
|
|
5
5
|
## 安装方式
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### 安装到指定 Agent
|
|
8
|
+
|
|
9
|
+
使用 `--agent` 指定目标 Agent;不指定时,`skills` 会自动检测本机已安装的 Agent 并提示选择。
|
|
8
10
|
|
|
9
11
|
```bash
|
|
12
|
+
# 安装到 CodeBuddy
|
|
10
13
|
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --agent codebuddy -y
|
|
14
|
+
|
|
15
|
+
# 安装到 Claude Code
|
|
16
|
+
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --agent claude-code -y
|
|
17
|
+
|
|
18
|
+
# 安装到 Codex
|
|
19
|
+
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --agent codex -y
|
|
20
|
+
|
|
21
|
+
# 同时安装到多个 Agent
|
|
22
|
+
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --agent codebuddy --agent claude-code --agent cursor -y
|
|
23
|
+
|
|
24
|
+
# 安装到所有支持的 Agent
|
|
25
|
+
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --agent '*' -y
|
|
11
26
|
```
|
|
12
27
|
|
|
28
|
+
常用 Agent 参数示例:
|
|
29
|
+
|
|
30
|
+
| Agent | `--agent` |
|
|
31
|
+
| --- | --- |
|
|
32
|
+
| CodeBuddy | `codebuddy` |
|
|
33
|
+
| Claude Code | `claude-code` |
|
|
34
|
+
| Codex | `codex` |
|
|
35
|
+
| Cursor | `cursor` |
|
|
36
|
+
| Gemini CLI | `gemini-cli` |
|
|
37
|
+
| OpenCode | `opencode` |
|
|
38
|
+
| Qwen Code | `qwen-code` |
|
|
39
|
+
| Windsurf | `windsurf` |
|
|
40
|
+
|
|
13
41
|
### 只安装指定的 Skill
|
|
14
42
|
|
|
15
43
|
```bash
|
|
44
|
+
# 查看仓库中可安装的 Skill
|
|
16
45
|
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --list
|
|
46
|
+
|
|
47
|
+
# 安装指定 Skill 到 CodeBuddy
|
|
17
48
|
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --skill cnb-api --agent codebuddy -y
|
|
49
|
+
|
|
50
|
+
# 安装指定 Skill 到 Claude Code
|
|
51
|
+
npx skills add https://cnb.cool/cnb/skills/cnb-skill.git --skill cnb-api --agent claude-code -y
|
|
18
52
|
```
|
|
19
53
|
|
|
20
54
|
### 安装 cnb-cli
|
|
@@ -46,7 +80,7 @@ npm install @cnbcool/cnb-cli -g
|
|
|
46
80
|
|
|
47
81
|
## AI 安装提示词
|
|
48
82
|
|
|
49
|
-
将以下内容发送给 CodeBuddy
|
|
83
|
+
将以下内容发送给 CodeBuddy、Claude Code、Codex、Cursor、Gemini CLI 等智能体即可自动安装;按需把 `--agent codebuddy` 替换为目标 Agent(如 `claude-code`、`codex`、`cursor`、`gemini-cli`、`opencode`、`qwen-code`、`windsurf`),或使用 `--agent '*'` 安装到所有支持的 Agent。
|
|
50
84
|
|
|
51
85
|
```
|
|
52
86
|
npm install @cnbcool/cnb-cli -g
|
package/dist/index.js
CHANGED
|
@@ -120,4 +120,4 @@ PR 页面路径: ${p}
|
|
|
120
120
|
登录成功 \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,X.maskToken)(n.access_token)}`),n.refresh_token)console.log(` refresh_token : ${(0,X.maskToken)(n.refresh_token)}`);if(n.id_token)console.log(` id_token : ${(0,X.maskToken)(n.id_token)}`)}let y=Math.floor(Date.now()/1000),u=`https://api.${new URL(r.platformURL).hostname}`,l={access_token:n.access_token,expires_at:y+n.expires_in,platform_url:r.platformURL,client_id:r.clientID,login_host:u};if(n.refresh_token)l.refresh_token=n.refresh_token;if((0,X.saveToken)(l),r.debug)console.log(`Token 已保存到 ${(0,X.getTokenPath)()}`)}catch(p){console.error(`
|
|
121
121
|
登录失败: ${p.message}`),process.exit(1)}})}});var su=o((zn)=>{Object.defineProperty(zn,"__esModule",{value:!0});zn.registerLogoutCommand=ZI;var JI=$I(require("fs")),FI=L(),YI=x();function $I(e){return e&&e.__esModule?e:{default:e}}function ZI(e){e.command("logout").description("退出登录,删除本地保存的 access_token").option("--debug","打印调试信息",!1).helpOption("-h, --help","显示帮助文档").action(async(t)=>{let r=(0,FI.getTokenPath)(),i=(0,YI.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{JI.default.unlinkSync(r),console.log("已成功退出登录。")}catch(p){console.error(`退出登录失败: ${p.message}`),process.exit(1)}})}});var nu=o((wn)=>{Object.defineProperty(wn,"__esModule",{value:!0});wn.registerStatusCommand=BI;var XI=it(),MI=ce(),QI=L(),HI={workbuddy:"WorkBuddy 远程获取",codebuddy_env:"CNB_TOKEN_FOR_CODEBUDDY 环境变量",env:"CNB_TOKEN 环境变量"};function BI(e){e.command("status").description("检查当前登录状态(token 是否存在、是否过期)").option("--debug","打印调试信息",!1).helpOption("-h, --help","显示帮助文档").action(async(t)=>{let r=await(0,XI.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 来源: ${HI[r.source]}`);return}let i=(0,QI.getTokenPath)(),p=r.store;if(t.debug)console.log(`Token 文件路径 : ${i}`),console.log(`Platform URL : ${p.platform_url||"未知"}`),console.log(`Client ID : ${p.client_id||"未知"}`),console.log(`Expires At : ${new Date(p.expires_at*1000).toLocaleString()}`);if(Math.floor(Date.now()/1000)>=p.expires_at)if(p.refresh_token){if(t.debug)console.log("Token 已过期,尝试使用 refresh_token 刷新...");try{if(await(0,MI.refreshAccessToken)(p),console.log("✅ 已登录。"),t.debug)console.log(" (Token 已自动刷新)")}catch(y){if(t.debug)console.log(`刷新失败: ${y.message}`);console.log("⚠️ 未登录,请执行 `cnb login` 重新授权。")}}else console.log("⚠️ 未登录,请执行 `cnb login` 重新授权。");else console.log("✅ 已登录。")})}});var ou=o((kn)=>{Object.defineProperty(kn,"__esModule",{value:!0});kn.registerGitCredentialCommand=RI;var GI=de(),OI=["cnb.cool","cnb.woa.com"],LI=8000;function RI(e){e.command("git-credential <action>").description("作为 git credential helper,向 git 提供 CNB 凭据(仅供 git 内部调用)").allowUnknownOption().allowExcessArguments().helpOption("-h, --help","显示帮助文档").action(async(t,r,i)=>{let p=i.args.slice(0,-1);if(p.length>0)console.error(`[git-credential]: custom args: ${p.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 s=await e5(LI),n=t5(s,"=");xI(n),await DI(n),process.exit(0)}catch(s){console.error(s?.message?s.message:String(s)),process.exit(2)}})}async function DI(e){let{host:t}=e;if(console.error(`[git-credential]: for ${e.protocol}://${e.host}/${e.path??""}`),!t||!OI.includes(t))throw Error(`unknown host: ${t}`);let r=await CI(e);process.stdout.write(`username=${r.username}
|
|
122
122
|
`),process.stdout.write(`password=${r.password}
|
|
123
|
-
`),console.error("[git-credential]: done")}async function CI(e){return{username:"cnb",password:await(0,GI.resolveToken)()}}function xI(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 e5(e){return new Promise((t,r)=>{let i=[],p=!1,s=()=>{if(p)return;p=!0,clearTimeout(n),t(Buffer.concat(i).toString("utf-8"))},n=setTimeout(()=>{if(p)return;p=!0,console.error("[git-credential]: timeout occurred"),r(Error("stdin timeout"))},e);process.stdin.on("data",(y)=>{if(i.push(y),y.length===1&&y[0]===10)s()}),process.stdin.on("end",()=>{s()}),process.stdin.on("error",(y)=>{if(p)return;p=!0,clearTimeout(n),r(y)})})}function t5(e,t){return e.split(/(?:\r\n|\r|\n)/).filter(Boolean).map((r)=>{let i=r.indexOf(t),p=i>=0?r.substring(0,i).trim():r.trim(),s=i>=0?r.substring(i+1).trim():"";return{key:p,value:s}}).reduce((r,{key:i,value:p})=>{if(i)r[i]=p;return r},{})}});Object.defineProperty(exports,"__esModule",{value:!0});Object.defineProperty(exports,"parseArguments",{enumerable:!0,get:function(){return c5.parseUnknownOptions}});var r5=Me(),i5=Hn(),p5=Rl(),s5=Dl(),n5=pu(),o5=su(),y5=nu(),a5=ou(),c5=_t(),M=new r5.Command;M.name("cnb").description("CNB OpenAPI 命令行工具").version("
|
|
123
|
+
`),console.error("[git-credential]: done")}async function CI(e){return{username:"cnb",password:await(0,GI.resolveToken)()}}function xI(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 e5(e){return new Promise((t,r)=>{let i=[],p=!1,s=()=>{if(p)return;p=!0,clearTimeout(n),t(Buffer.concat(i).toString("utf-8"))},n=setTimeout(()=>{if(p)return;p=!0,console.error("[git-credential]: timeout occurred"),r(Error("stdin timeout"))},e);process.stdin.on("data",(y)=>{if(i.push(y),y.length===1&&y[0]===10)s()}),process.stdin.on("end",()=>{s()}),process.stdin.on("error",(y)=>{if(p)return;p=!0,clearTimeout(n),r(y)})})}function t5(e,t){return e.split(/(?:\r\n|\r|\n)/).filter(Boolean).map((r)=>{let i=r.indexOf(t),p=i>=0?r.substring(0,i).trim():r.trim(),s=i>=0?r.substring(i+1).trim():"";return{key:p,value:s}}).reduce((r,{key:i,value:p})=>{if(i)r[i]=p;return r},{})}});Object.defineProperty(exports,"__esModule",{value:!0});Object.defineProperty(exports,"parseArguments",{enumerable:!0,get:function(){return c5.parseUnknownOptions}});var r5=Me(),i5=Hn(),p5=Rl(),s5=Dl(),n5=pu(),o5=su(),y5=nu(),a5=ou(),c5=_t(),M=new r5.Command;M.name("cnb").description("CNB OpenAPI 命令行工具").version("1.9.1","-v, --version","显示版本号").allowUnknownOption().allowExcessArguments().helpOption("-h, --help","显示帮助文档").option("-s, --short","显示当前仓库的快捷命令").addHelpText("after",(0,i5.getExtraHelpText)());(0,n5.registerLoginCommand)(M);(0,o5.registerLogoutCommand)(M);(0,y5.registerStatusCommand)(M);(0,a5.registerGitCredentialCommand)(M);(0,p5.registerModuleCommands)(M);(0,s5.registerFallbackAction)(M);M.parseAsync(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cnbcool/cnb-cli",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"description": "CNB OpenAPI 命令行工具,基于 CNB 平台 Swagger 自动生成,支持 Issues、PR、Git、组织管理等全部 API 操作",
|
|
5
5
|
"main": "skills/cnb-api/scripts/core/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"url": "https://cnb.cool/cnb/cnb-cli"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
|
-
"build": "bun build cli/core/index.js --outfile dist/index.js --target node --format cjs --minify",
|
|
30
|
+
"build": "bun build cli/core/index.js --outfile dist/index.js --target node --format cjs --minify && sh scripts/replace-cli-version.sh",
|
|
31
31
|
"compile:darwin-arm64": "bun build cli/core/index.js --compile --minify --target=bun-darwin-arm64 --outfile compile/cnb-darwin-arm64",
|
|
32
32
|
"compile:darwin-x64": "bun build cli/core/index.js --compile --minify --target=bun-darwin-x64-baseline --outfile compile/cnb-darwin-x64",
|
|
33
33
|
"compile:linux-arm64": "bun build cli/core/index.js --compile --minify --target=bun-linux-arm64 --outfile compile/cnb-linux-arm64",
|