xc-skills 1.0.0

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 (2) hide show
  1. package/dist/cli.js +2 -0
  2. package/package.json +29 -0
package/dist/cli.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{cac as N}from"cac";import*as e from"@clack/prompts";import n from"picocolors";import C from"fs-extra";import{join as S,resolve as F,dirname as G,basename as O}from"path";import A from"os";import k from"os";import{join as u}from"path";var h=[{name:"Antigravity",path:u(k.homedir(),".agent/skills"),description:"Custom AI agent for XC development"},{name:"Trae",path:u(k.homedir(),".trae/skills"),description:"Trae AI IDE"},{name:"Codex",path:u(k.homedir(),".codex/skills"),description:"Codex AI assistant"},{name:"Claude Code",path:u(k.homedir(),".claude/skills"),description:"Anthropic Claude Code CLI"}];import d from"fs-extra";import{join as x,dirname as I,basename as D}from"path";import*as $ from"@clack/prompts";import E from"picocolors";import T from"os";async function b(v){let{sourceDir:s,targetAgents:y,selectedSkills:g,scope:f,method:c,strategy:o}=v,r=$.spinner();for(let l of y){let i="";if(f==="project"){let p=D(I(l.path));i=x(process.cwd(),p,"skills")}else i=l.path.replace(/^~/,T.homedir());r.start(`\u6B63\u5728\u90E8\u7F72\u5230 ${l.name} (${i})...`);try{o==="overwrite"&&await d.pathExists(i)?await d.emptyDir(i):await d.ensureDir(i);for(let p of g){let t=x(s,p),a=x(i,p);await d.pathExists(a)&&await d.remove(a),c==="symlink"?await d.ensureSymlink(t,a,"dir"):await d.copy(t,a)}r.stop(`\u6210\u529F\u540C\u6B65\u5230: ${l.name} (${f} \u6A21\u5F0F)`)}catch(p){r.stop(`${E.red("\u5931\u8D25")}: ${l.name} - ${p.message}`)}}}var w=N("xc-skills");w.command("add <source>","Add skills from a local directory").option("-s, --skill <skills>","Specific skills to install").option("-a, --agent <agents>","Specific agents to install to").option("-y, --yes","Skip confirmation prompts").action(async(v,s)=>{e.intro(`${n.bgCyan(n.black(" xc-skills "))}`);let y=F(process.cwd(),v),g=S(y,"skills");C.existsSync(g)||(e.log.error(`\u627E\u4E0D\u5230\u6280\u80FD\u76EE\u5F55: ${y}/skills`),process.exit(1));let f=(await C.readdir(g,{withFileTypes:!0})).filter(t=>t.isDirectory()&&!t.name.startsWith(".")).map(t=>t.name),c=[];s.yes||s.skill==="*"?c=f:s.skill?c=s.skill.split(","):c=await e.multiselect({message:"\u7B2C\u4E00\u6B65\uFF1A\u9009\u62E9\u8981\u5B89\u88C5\u7684\u6280\u80FD (Select skills)",options:f.map(t=>({value:t,label:t})),initialValues:[f[0]]}),e.isCancel(c)&&(e.cancel("\u5DF2\u53D6\u6D88"),process.exit(0));let o=[];if(s.yes||s.agent==="*")o=h;else if(s.agent){let t=s.agent.split(",");o=h.filter(a=>t.includes(a.name))}else o=await e.multiselect({message:"\u7B2C\u4E8C\u6B65\uFF1A\u9009\u62E9\u76EE\u6807\u5F00\u53D1\u5DE5\u5177 (Select agents)",options:h.map(t=>({value:t,label:t.name,hint:t.path.replace(A.homedir(),"~")})),initialValues:[h[0]]});e.isCancel(o)&&(e.cancel("\u5DF2\u53D6\u6D88"),process.exit(0));let r="project";s.yes||(r=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(r)&&(e.cancel("\u5DF2\u53D6\u6D88"),process.exit(0));let l="symlink";s.yes||(l=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(l)&&(e.cancel("\u5DF2\u53D6\u6D88"),process.exit(0));let i="merge";if(!s.yes){let t=!1;for(let a of o){let m="";if(r==="project"){let j=O(G(a.path));m=S(process.cwd(),j,"skills")}else m=a.path.replace(/^~/,A.homedir());if(await C.pathExists(m)){t=!0;break}}t&&(i=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(i)&&(e.cancel("\u5DF2\u53D6\u6D88"),process.exit(0)),!s.yes){e.log.message(`${n.cyan("\u5B89\u88C5\u7EFC\u8FF0 (Installation Summary)")}`),[`${n.dim("Skills:")} ${c.join(", ")}`,`${n.dim("Agents:")} ${o.map(m=>m.name).join(", ")}`,`${n.dim("Scope:")} ${r}`,`${n.dim("Method:")} ${l}`,`${n.dim("Strategy:")} ${i}`].forEach(m=>e.log.message(` ${m}`));let a=await e.confirm({message:"\u786E\u8BA4\u5B89\u88C5\uFF1F(Proceed with installation?)",initialValue:!0});(e.isCancel(a)||!a)&&(e.cancel("\u5B89\u88C5\u5DF2\u53D6\u6D88"),process.exit(0))}await b({sourceDir:g,targetAgents:o,selectedSkills:c,scope:r,method:l,strategy:i}),e.outro(n.green("\u5B89\u88C5\u5B8C\u6210\uFF01(Installation complete)"))});w.help();w.version("1.0.0");w.parse();
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "xc-skills",
3
+ "version": "1.0.0",
4
+ "description": "Custom Agent Skills CLI for XC development",
5
+ "type": "module",
6
+ "bin": {
7
+ "xc-skills": "./dist/cli.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "dev": "tsup src/cli.ts --watch --format esm",
14
+ "build": "tsup src/cli.ts --format esm --clean --minify",
15
+ "prepublishOnly": "npm run build"
16
+ },
17
+ "dependencies": {
18
+ "@clack/prompts": "^1.1.0",
19
+ "cac": "^6.7.14",
20
+ "fs-extra": "^11.3.0",
21
+ "picocolors": "^1.1.1"
22
+ },
23
+ "devDependencies": {
24
+ "@types/fs-extra": "^11.0.4",
25
+ "@types/node": "^22.13.1",
26
+ "tsup": "^8.3.6",
27
+ "typescript": "^5.7.3"
28
+ }
29
+ }