xc-skills 1.0.4 → 1.0.6

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 +11 -2
  2. package/dist/cli.js +1 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -61,7 +61,15 @@ xc-skills add https://e.coding.net/your-team/skills.git
61
61
  xc-skills add . --dir my-rules
62
62
  ```
63
63
 
64
- ### 4. 参数化运行
64
+ ### 4. 指定输出路径
65
+
66
+ 如果你想把技能安装到一个特定的文件夹(而不是默认的 Agent 路径或 `.agent/skills`),可以使用 `--out` 参数:
67
+
68
+ ```bash
69
+ xc-skills add . --out ./my-debug-folder
70
+ ```
71
+
72
+ ### 5. 参数化运行
65
73
 
66
74
  ```bash
67
75
  # 自动安装所有技能到 Antigravity(跳过交互)
@@ -74,7 +82,8 @@ xc-skills add . --yes --agent Antigravity --skill *
74
82
  | --- | --- |
75
83
  | `-s, --skill <names>` | 指定要安装的技能名称(逗号分隔,或用 `*` 表示全部) |
76
84
  | `-a, --agent <names>` | 指定目标 Agent 名称(逗号分隔,或用 `*` 表示全部) |
77
- | `-d, --dir <dir>` | 指定技能存放的目录名(默认为 `skills`) |
85
+ | `-d, --dir <dir>` | 指定源目录中技能存放的目录名(默认为 `skills`) |
86
+ | `-o, --out <path>` | 指定输出的目标目录路径 |
78
87
  | `-y, --yes` | 跳过所有确认和交互步骤,使用默认值 |
79
88
  | `-v, --version` | 查看版本号 |
80
89
  | `-h, --help` | 查看帮助信息 |
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{cac as P}from"cac";import*as e from"@clack/prompts";import p from"picocolors";import a from"fs-extra";import{join as k,resolve as T,dirname as M,basename as O}from"path";import I from"os";import{execSync as R}from"child_process";import V from"degit";import S from"os";import{join as b}from"path";var w=[{name:"Antigravity",path:b(S.homedir(),".agent/skills"),description:"Custom AI agent for XC development"},{name:"Trae",path:b(S.homedir(),".trae/skills"),description:"Trae AI IDE"},{name:"Codex",path:b(S.homedir(),".codex/skills"),description:"Codex AI assistant"},{name:"Claude Code",path:b(S.homedir(),".claude/skills"),description:"Anthropic Claude Code CLI"}];import y from"fs-extra";import{join as j,dirname as L,basename as F}from"path";import*as D from"@clack/prompts";import G from"picocolors";import N from"os";async function E(c){let{sourceDir:i,targetAgents:u,selectedSkills:l,scope:s,method:v,strategy:g}=c,$=D.spinner();for(let f of u){let r="";if(s==="project"){let o=F(L(f.path));r=j(process.cwd(),o,"skills")}else r=f.path.replace(/^~/,N.homedir());$.start(`\u6B63\u5728\u90E8\u7F72\u5230 ${f.name} (${r})...`);try{g==="overwrite"&&await y.pathExists(r)?await y.emptyDir(r):await y.ensureDir(r);for(let o of l){let h=j(i,o),d=j(r,o);await y.pathExists(d)&&await y.remove(d),v==="symlink"?await y.ensureSymlink(h,d,"dir"):await y.copy(h,d)}$.stop(`\u6210\u529F\u540C\u6B65\u5230: ${f.name} (${s} \u6A21\u5F0F)`)}catch(o){$.stop(`${G.red("\u5931\u8D25")}: ${f.name} - ${o.message}`)}}}var C=P("xc-skills");function W(c){try{let i=k(c,"SKILL.md");if(a.existsSync(i)){let l=a.readFileSync(i,"utf-8").match(/description:\s*['"]?([^'"\n\r]+)['"]?/);return l?l[1].trim():""}}catch{}return""}C.command("add <source>","Add skills from a local directory or GitHub URL").option("-s, --skill <skills>","Specific skills to install").option("-a, --agent <agents>","Specific agents to install to").option("-d, --dir <dir>","The directory name containing skills",{default:"skills"}).option("-y, --yes","Skip confirmation prompts").action(async(c,i)=>{e.intro(`${p.bgCyan(p.black(" xc-skills "))}`);let u="",l=!1,s=k(I.tmpdir(),`xc-skills-${Date.now()}`),v=c.startsWith("http")||c.startsWith("git@")||c.includes("/")&&!a.existsSync(T(process.cwd(),c));if(v){let t=e.spinner();t.start(`\u6B63\u5728\u5C1D\u8BD5\u4E0B\u8F7D\u6280\u80FD\u5E93: ${c}`);let n=!1;try{await V(c,{cache:!1,force:!0,verbose:!1}).clone(s),n=!0,t.stop("\u4E0B\u8F7D\u6210\u529F (degit)")}catch{try{t.message("degit \u4E0D\u652F\u6301\u6B64\u5E73\u53F0\uFF0C\u6B63\u5728\u5C1D\u8BD5\u4F7F\u7528 git clone..."),R(`git clone --depth 1 ${c} ${s}`,{stdio:"ignore"}),a.existsSync(k(s,".git"))&&await a.remove(k(s,".git")),n=!0,t.stop("\u4E0B\u8F7D\u6210\u529F (git clone)")}catch(A){t.stop(p.red(`\u4E0B\u8F7D\u5931\u8D25: ${A.message}`)),process.exit(1)}}n&&(u=s,l=!0)}else u=T(process.cwd(),c);let g=k(u,i.dir);a.existsSync(g)||(e.log.error(`\u627E\u4E0D\u5230\u6280\u80FD\u76EE\u5F55: ${g}`),l&&await a.remove(s),process.exit(1));let f=(await a.readdir(g,{withFileTypes:!0})).filter(t=>t.isDirectory()&&!t.name.startsWith(".")).map(t=>{let n=t.name,m=W(k(g,n));return{name:n,description:m}});f.length===0&&(e.log.error(`\u5728 ${g} \u4E2D\u6CA1\u6709\u627E\u5230\u4EFB\u4F55\u6709\u6548\u7684\u6280\u80FD\u5B50\u76EE\u5F55`),l&&await a.remove(s),process.exit(1));let r=[];i.yes||i.skill==="*"?r=f.map(t=>t.name):i.skill?r=i.skill.split(","):r=await e.multiselect({message:"\u7B2C\u4E00\u6B65\uFF1A\u9009\u62E9\u8981\u5B89\u88C5\u7684\u6280\u80FD (Select skills)",options:f.map(t=>({value:t.name,label:t.name,hint:t.description})),initialValues:[f[0].name]}),e.isCancel(r)&&(l&&await a.remove(s),e.cancel("\u5DF2\u53D6\u6D88"),process.exit(0));let o=[];if(i.yes||i.agent==="*")o=w;else if(i.agent){let t=i.agent.split(",");o=w.filter(n=>t.includes(n.name))}else o=await e.multiselect({message:"\u7B2C\u4E8C\u6B65\uFF1A\u9009\u62E9\u76EE\u6807\u5F00\u53D1\u5DE5\u5177 (Select agents)",options:w.map(t=>({value:t,label:t.name,hint:t.path.replace(I.homedir(),"~")})),initialValues:[w[0]]});e.isCancel(o)&&(l&&await a.remove(s),e.cancel("\u5DF2\u53D6\u6D88"),process.exit(0));let h="project";i.yes||(h=await e.select({message:"\u7B2C\u4E09\u6B65\uFF1A\u9009\u62E9\u5B89\u88C5\u8303\u56F4 (Installation scope)",options:[{value:"project",label:"Project (\u9879\u76EE\u7EA7)",hint:"./.<agent>/skills"},{value:"global",label:"Global (\u5168\u5C40)",hint:"\u5DE5\u5177\u9ED8\u8BA4\u8DEF\u5F84"}]})),e.isCancel(h)&&(l&&await a.remove(s),e.cancel("\u5DF2\u53D6\u6D88"),process.exit(0));let d="symlink";l?d="copy":i.yes||(d=await e.select({message:"\u7B2C\u56DB\u6B65\uFF1A\u9009\u62E9\u5B89\u88C5\u65B9\u5F0F (Installation method)",options:[{value:"symlink",label:"Symlink (\u8F6F\u94FE\u63A5 - \u63A8\u8350)",hint:"\u4E0E\u6E90\u7801\u4FDD\u6301\u5B9E\u65F6\u540C\u6B65"},{value:"copy",label:"Copy (\u7269\u7406\u62F7\u8D1D)",hint:"\u590D\u5236\u6587\u4EF6\u526F\u672C"}]})),e.isCancel(d)&&(l&&await a.remove(s),e.cancel("\u5DF2\u53D6\u6D88"),process.exit(0));let x="merge";if(!i.yes){let t=!1;for(let n of o){let m="";if(h==="project"){let A=O(M(n.path));m=k(process.cwd(),A,"skills")}else m=n.path.replace(/^~/,I.homedir());if(await a.pathExists(m)){t=!0;break}}t&&(x=await e.select({message:"\u68C0\u6D4B\u5230\u76EE\u6807\u76EE\u5F55\u5DF2\u5B58\u5728\uFF0C\u5982\u4F55\u5904\u7406\uFF1F(Handle conflicts)",options:[{value:"merge",label:"Merge (\u5408\u5E76)",hint:"\u53EA\u66F4\u65B0\u9009\u4E2D\u7684\u6280\u80FD\uFF0C\u4FDD\u7559\u5176\u4ED6\u6280\u80FD"},{value:"overwrite",label:"Overwrite (\u8986\u76D6)",hint:"\u6E05\u7A7A\u76EE\u6807\u76EE\u5F55\u540E\u518D\u5B89\u88C5"}]}))}if(e.isCancel(x)&&(l&&await a.remove(s),e.cancel("\u5DF2\u53D6\u6D88"),process.exit(0)),!i.yes){e.log.message(`${p.cyan("\u5B89\u88C5\u7EFC\u8FF0 (Installation Summary)")}`),[`${p.dim("Source:")} ${v?c:"Local"}`,`${p.dim("Skills:")} ${r.join(", ")}`,`${p.dim("Agents:")} ${o.map(m=>m.name).join(", ")}`,`${p.dim("Scope:")} ${h}`,`${p.dim("Method:")} ${d}`,`${p.dim("Strategy:")} ${x}`].forEach(m=>e.log.message(` ${m}`));let n=await e.confirm({message:"\u786E\u8BA4\u5B89\u88C5\uFF1F(Proceed with installation?)",initialValue:!0});(e.isCancel(n)||!n)&&(l&&await a.remove(s),e.cancel("\u5B89\u88C5\u5DF2\u53D6\u6D88"),process.exit(0))}await E({sourceDir:g,targetAgents:o,selectedSkills:r,scope:h,method:d,strategy:x}),l&&await a.remove(s),e.outro(p.green("\u5B89\u88C5\u5B8C\u6210\uFF01(Installation complete)"))});C.help();C.version("1.0.4");C.parse();
2
+ import{cac as F}from"cac";import*as e from"@clack/prompts";import m from"picocolors";import o from"fs-extra";import{join as w,resolve as b}from"path";import E from"os";import{execSync as M}from"child_process";import N from"degit";import S from"os";import{join as x}from"path";var v=[{name:"Antigravity",path:x(S.homedir(),".agent/skills"),description:"Custom AI agent for XC development"},{name:"Trae",path:x(S.homedir(),".trae/skills"),description:"Trae AI IDE"},{name:"Codex",path:x(S.homedir(),".codex/skills"),description:"Codex AI assistant"},{name:"Claude Code",path:x(S.homedir(),".claude/skills"),description:"Anthropic Claude Code CLI"}];import y from"fs-extra";import{join as j,dirname as R,basename as L}from"path";import*as I from"@clack/prompts";import P from"picocolors";import G from"os";async function D(l){let{sourceDir:t,targetAgents:k,selectedSkills:r,scope:s,method:$,strategy:g,customRoot:A}=l,u=I.spinner();for(let c of k){let a="";if(A)a=A;else if(s==="project"){let p=L(R(c.path));a=j(process.cwd(),p,"skills")}else a=c.path.replace(/^~/,G.homedir());u.start(`\u6B63\u5728\u90E8\u7F72\u5230 ${c.name} (${a})...`);try{g==="overwrite"&&await y.pathExists(a)?await y.emptyDir(a):await y.ensureDir(a);for(let p of r){let h=j(t,p),f=j(a,p);await y.pathExists(f)&&await y.remove(f),$==="symlink"?await y.ensureSymlink(h,f,"dir"):await y.copy(h,f)}u.stop(`\u6210\u529F\u540C\u6B65\u5230: ${c.name} (${s==="custom"?"\u81EA\u5B9A\u4E49\u8DEF\u5F84":s+" \u6A21\u5F0F"})`)}catch(p){u.stop(`${P.red("\u5931\u8D25")}: ${c.name} - ${p.message}`)}}}var C=F("xc-skills");function O(l){try{let t=w(l,"SKILL.md");if(o.existsSync(t)){let r=o.readFileSync(t,"utf-8").match(/description:\s*['"]?([^'"\n\r]+)['"]?/);return r?r[1].trim():""}}catch{}return""}C.command("add <source>","Add skills from a local directory or GitHub URL").option("-s, --skill <skills>","Specific skills to install").option("-a, --agent <agents>","Specific agents to install to").option("-d, --dir <dir>","The directory name containing skills",{default:"skills"}).option("-o, --out <path>","Specify a custom output directory").option("-y, --yes","Skip confirmation prompts").action(async(l,t)=>{e.intro(`${m.bgCyan(m.black(" xc-skills "))}`);let k="",r=!1,s=w(E.tmpdir(),`xc-skills-${Date.now()}`),$=l.startsWith("http")||l.startsWith("git@")||l.includes("/")&&!o.existsSync(b(process.cwd(),l));if($){let i=e.spinner();i.start(`\u6B63\u5728\u5C1D\u8BD5\u4E0B\u8F7D\u6280\u80FD\u5E93: ${l}`);let n=!1;try{await N(l,{cache:!1,force:!0,verbose:!1}).clone(s),n=!0,i.stop("\u4E0B\u8F7D\u6210\u529F (degit)")}catch{try{i.message("degit \u4E0D\u652F\u6301\u6B64\u5E73\u53F0\uFF0C\u6B63\u5728\u5C1D\u8BD5\u4F7F\u7528 git clone..."),M(`git clone --depth 1 ${l} ${s}`,{stdio:"ignore"}),o.existsSync(w(s,".git"))&&await o.remove(w(s,".git")),n=!0,i.stop("\u4E0B\u8F7D\u6210\u529F (git clone)")}catch(T){i.stop(m.red(`\u4E0B\u8F7D\u5931\u8D25: ${T.message}`)),process.exit(1)}}n&&(k=s,r=!0)}else k=b(process.cwd(),l);let g=w(k,t.dir);o.existsSync(g)||(e.log.error(`\u627E\u4E0D\u5230\u6280\u80FD\u76EE\u5F55: ${g}`),r&&await o.remove(s),process.exit(1));let u=(await o.readdir(g,{withFileTypes:!0})).filter(i=>i.isDirectory()&&!i.name.startsWith(".")).map(i=>{let n=i.name,d=O(w(g,n));return{name:n,description:d}});u.length===0&&(e.log.error(`\u5728 ${g} \u4E2D\u6CA1\u6709\u627E\u5230\u4EFB\u4F55\u6709\u6548\u7684\u6280\u80FD\u5B50\u76EE\u5F55`),r&&await o.remove(s),process.exit(1));let c=[];t.yes||t.skill==="*"?c=u.map(i=>i.name):t.skill?c=t.skill.split(","):c=await e.multiselect({message:"\u7B2C\u4E00\u6B65\uFF1A\u9009\u62E9\u8981\u5B89\u88C5\u7684\u6280\u80FD (Select skills)",options:u.map(i=>({value:i.name,label:i.name,hint:i.description})),initialValues:[u[0].name]}),e.isCancel(c)&&(r&&await o.remove(s),e.cancel("\u5DF2\u53D6\u6D88"),process.exit(0));let a=[];if(t.out)a=[{name:"Custom Path",path:b(process.cwd(),t.out)}];else if(t.yes||t.agent==="*")a=v;else if(t.agent){let i=t.agent.split(",");a=v.filter(n=>i.includes(n.name))}else a=await e.multiselect({message:"\u7B2C\u4E8C\u6B65\uFF1A\u9009\u62E9\u76EE\u6807\u5F00\u53D1\u5DE5\u5177 (Select agents)",options:v.map(i=>({value:i,label:i.name,hint:i.path.replace(E.homedir(),"~")})),initialValues:[v[0]]});e.isCancel(a)&&(r&&await o.remove(s),e.cancel("\u5DF2\u53D6\u6D88"),process.exit(0));let p=t.out?"custom":"project";!t.out&&!t.yes&&(p=await e.select({message:"\u7B2C\u4E09\u6B65\uFF1A\u9009\u62E9\u5B89\u88C5\u8303\u56F4 (Installation scope)",options:[{value:"project",label:"Project (\u9879\u76EE\u7EA7)",hint:"./.<agent>/skills"},{value:"global",label:"Global (\u5168\u5C40)",hint:"\u5DE5\u5177\u9ED8\u8BA4\u8DEF\u5F84"}]})),e.isCancel(p)&&(r&&await o.remove(s),e.cancel("\u5DF2\u53D6\u6D88"),process.exit(0));let h="symlink";r?h="copy":t.yes||(h=await e.select({message:"\u7B2C\u56DB\u6B65\uFF1A\u9009\u62E9\u5B89\u88C5\u65B9\u5F0F (Installation method)",options:[{value:"symlink",label:"Symlink (\u8F6F\u94FE\u63A5 - \u63A8\u8350)",hint:"\u4E0E\u6E90\u7801\u4FDD\u6301\u5B9E\u65F6\u540C\u6B65"},{value:"copy",label:"Copy (\u7269\u7406\u62F7\u8D1D)",hint:"\u590D\u5236\u6587\u4EF6\u526F\u672C"}]})),e.isCancel(h)&&(r&&await o.remove(s),e.cancel("\u5DF2\u53D6\u6D88"),process.exit(0));let f="merge";if(!t.yes){let i=!1;for(let n of a){let d=n.path;if(await o.pathExists(d)){i=!0;break}}i&&(f=await e.select({message:"\u68C0\u6D4B\u5230\u76EE\u6807\u76EE\u5F55\u5DF2\u5B58\u5728\uFF0C\u5982\u4F55\u5904\u7406\uFF1F(Handle conflicts)",options:[{value:"merge",label:"Merge (\u5408\u5E76)",hint:"\u53EA\u66F4\u65B0\u9009\u4E2D\u7684\u6280\u80FD\uFF0C\u4FDD\u7559\u5176\u4ED6\u6280\u80FD"},{value:"overwrite",label:"Overwrite (\u8986\u76D6)",hint:"\u6E05\u7A7A\u76EE\u6807\u76EE\u5F55\u540E\u518D\u5B89\u88C5"}]}))}if(e.isCancel(f)&&(r&&await o.remove(s),e.cancel("\u5DF2\u53D6\u6D88"),process.exit(0)),!t.yes){e.log.message(`${m.cyan("\u5B89\u88C5\u7EFC\u8FF0 (Installation Summary)")}`),[`${m.dim("Source:")} ${$?l:"Local"}`,`${m.dim("Skills:")} ${c.join(", ")}`,t.out?`${m.dim("Target:")} ${a[0].path}`:`${m.dim("Agents:")} ${a.map(d=>d.name).join(", ")}`,`${m.dim("Scope:")} ${p}`,`${m.dim("Method:")} ${h}`,`${m.dim("Strategy:")} ${f}`].forEach(d=>e.log.message(` ${d}`));let n=await e.confirm({message:"\u786E\u8BA4\u5B89\u88C5\uFF1F(Proceed with installation?)",initialValue:!0});(e.isCancel(n)||!n)&&(r&&await o.remove(s),e.cancel("\u5B89\u88C5\u5DF2\u53D6\u6D88"),process.exit(0))}await D({sourceDir:g,targetAgents:a,selectedSkills:c,scope:p,method:h,strategy:f,customRoot:t.out?b(process.cwd(),t.out):void 0}),r&&await o.remove(s),e.outro(m.green("\u5B89\u88C5\u5B8C\u6210\uFF01(Installation complete)"))});C.help();C.version("1.0.6");C.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xc-skills",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Custom Agent Skills CLI for XC development",
5
5
  "type": "module",
6
6
  "bin": {