@fxri/toolkit 1.14.6 → 1.14.7
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/CHANGELOG.md +12 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/package.json +11 -7
- package/templates/docs-theme/custom.css +13 -8
package/CHANGELOG.md
CHANGED
package/dist/cli.cjs
CHANGED
|
@@ -115,7 +115,7 @@ ${o}`}function Wo(e){let t=ll(E(e.source),e);return((0,Ct.existsSync)(e.target)?
|
|
|
115
115
|
`)}function Vl(){let e=rt();return e?Object.values(e.sources).some(t=>t.targets.some(n=>n.entries.length>0)):!1}function un(e){let t=dt(e),n=Hl(t);if(!n)return null;if(Bl(n))return{...Ul(),updatedAt:typeof n.updatedAt=="string"?n.updatedAt:"",sources:Yl(n.sources)};if(!Array.isArray(n.shells)&&typeof n.source!="string")return null;try{let r=Jf(n);return Kl(t),Wl(t,r),r}catch{return null}}function Wl(e,t){(0,Je.mkdirSync)((0,an.dirname)(e),{recursive:!0}),_(e,`${JSON.stringify(t,null,2)}
|
|
116
116
|
`)}function Ml(e){return JSON.stringify(e.sources)}function rs(e,t){let n=un(e),r={format:Ke,schemaVersion:Ye,updatedAt:new Date().toISOString(),sources:t};return n&&Ml(n)===Ml(r)?!1:(Wl(dt(e),r),!0)}function os(e){(0,Je.rmSync)(dt(e),{force:!0})}var B=require("fs"),Y=require("path");var Pe=require("fs"),ss=require("os"),Jn=require("path"),qf=".toolkit-skills.lock",Xf="skills.lock",Zf=300*1e3;function is(e){return(0,Jn.join)(e,".agents",qf)}function zl(e){return(0,Jn.join)(e,".toolkit",Xf)}function Jl(e){if(!(0,Pe.existsSync)(e))return null;try{let t=JSON.parse((0,Pe.readFileSync)(e,"utf8"));return typeof t.pid!="number"||typeof t.host!="string"||typeof t.startedAt!="string"?null:{pid:t.pid,host:t.host,startedAt:t.startedAt}}catch{return null}}function Qf(e){let t=Date.parse(e.startedAt);if(!Number.isFinite(t)||Date.now()-t>Zf)return!0;if(e.host===(0,ss.hostname)())try{return process.kill(e.pid,0),!1}catch{return!0}return!1}function ed(e,t){let n=Jl(e);n&&n.pid===t.pid&&n.host===t.host&&n.startedAt===t.startedAt&&(0,Pe.rmSync)(e,{force:!0})}function qr(e){(0,Pe.mkdirSync)((0,Jn.dirname)(e),{recursive:!0});let t={pid:process.pid,host:(0,ss.hostname)(),startedAt:new Date().toISOString()};for(let n=0;n<2;n+=1)try{return(0,Pe.writeFileSync)(e,`${JSON.stringify(t,null,2)}
|
|
117
117
|
`,{flag:"wx"}),()=>ed(e,t)}catch(r){if(r.code!=="EEXIST")throw r;let o=Jl(e);if(o&&!Qf(o))throw new Error(`\u6280\u80FD\u64CD\u4F5C\u9501\u88AB\u5360\u7528\uFF1A${o.host} pid ${o.pid}\uFF08\u59CB\u4E8E ${o.startedAt}\uFF09\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5`,{cause:r});(0,Pe.rmSync)(e,{force:!0})}throw new Error(`\u65E0\u6CD5\u83B7\u53D6\u6280\u80FD\u64CD\u4F5C\u9501\uFF1A${e}`)}function Zl(e,t){if(!t)return e;let n=t.filter(i=>!e.some(l=>l.name===i));n.length>0&&console.warn(`\u26A0\uFE0F \u5FFD\u7565\u4E0D\u5B58\u5728\u7684\u6280\u80FD\uFF1A${n.join("\u3001")}`);let r=t.filter(i=>e.some(l=>l.name===i)),o=Yr(e,r);o.missing.length>0&&console.warn(`\u26A0\uFE0F \u5FFD\u7565\u7F3A\u5931\u7684\u4F9D\u8D56\u6280\u80FD\uFF1A${o.missing.join("\u3001")}`);let s=new Set(o.names);return e.filter(i=>s.has(i.name))}function cs(e={}){let t=[Vn()],n=se();for(let[r,o]of Object.entries(n.sources??{})){let s=o.url??o.root;if(s)try{let i=Yn(s,{name:r,temporary:!1}),l=t.find(c=>c.name===i.name);if(l){if(P(l.root)!==P(i.root))throw new Error(`\u6765\u6E90\u540D\u51B2\u7A81\uFF1A${r}\uFF08${l.root} / ${i.root}\uFF09`);continue}t.push(i)}catch(i){console.warn(`\u26A0\uFE0F \u8DF3\u8FC7\u5931\u6548\u7684\u5916\u90E8\u6765\u6E90 ${r}\uFF1A${i.message}`)}}for(let r of e.externalSources??[]){let o=Yn(r.path,{name:r.name,temporary:r.temporary,dryRun:e.dryRun}),s=t.find(i=>i.name===o.name);if(s&&P(s.root)!==P(o.root))throw new Error(`\u6765\u6E90\u540D\u51B2\u7A81\uFF1A${o.name}\uFF08${s.root} / ${o.root}\uFF09`);s||t.push(o)}return t}function Ql(e={}){let t=cs(e).flatMap(Dt);return Kr(t),t}function ql(e){let t=new Map;for(let n of e)for(let r of Dt(n))t.set(r.name,{dir:r.dir,linkTarget:r.linkTarget});return t}function ls(e,t,n,r){if(!e)return[];let o=[];for(let s of e.entries){if(t.has(s.name))continue;let i=r.get(s.name);if(!i)continue;let l=(0,Y.join)(n,s.name),c=Ft(l,i.linkTarget,void 0,i.dir);if(c==="link-ok"||c==="dir"&&(0,B.existsSync)(i.dir)&&Ne(i.dir,l))try{ze(l),o.push(s.name)}catch{}}return o}function ec(e={}){let t=cs({externalSources:e.externalSources,dryRun:e.dryRun}),n=t.flatMap(Dt);Kr(n);let r=Zl(n,e.skills),o=new Set(r.map(u=>u.name)),s=new Map(n.map(u=>[u.name,{dir:u.dir,linkTarget:u.linkTarget}])),i=se().targets,l=e.targets??(i&&i.length>0?i:void 0),c=Il(l,e.dirs??[]),a=We(),f=[];for(let u of c.invalid)console.warn(`\u26A0\uFE0F \u5FFD\u7565\u672A\u77E5\u7684 agent / \u76EE\u6807\u540D\uFF1A${u}`);for(let u of c.unavailable){console.warn(`\u26A0\uFE0F \u5FFD\u7565\u672C\u673A\u672A\u68C0\u6D4B\u5230\u7684 agent\uFF1A${u}\uFF08\u4E0D\u51ED\u7A7A\u521B\u5EFA\u76EE\u5F55\uFF09`);let m=a.find(d=>d.name===u);m&&f.push({dir:m.dir,label:m.label})}if(l===void 0)for(let u of a)u.kind==="agent"&&!u.available&&f.push({dir:u.dir,label:u.label});let p=c.targets,g=e.dryRun?null:qr(is(J()));try{let u=rt(),m=new Map;for(let[$,b]of Object.entries(u?.sources??{})){let T=new Map;for(let h of b.targets)T.set(P(h.dir),h);m.set($,T)}let d=new Map;for(let $ of t)d.set($.name,[]);let k=new Set,y=[];for(let $ of p){let b=P($.dir);k.add(b);let T={dir:$.dir,label:$.label,kind:$.kind,created:[],updated:[],skipped:[],conflicts:[],failed:[],degraded:[],links:[],copies:[],pruned:[]},h=new Map;for(let S of r){let R=(0,Y.join)($.dir,S.name),N=Ft(R,S.linkTarget),I=m.get(S.source)?.get(b)?.entries.some(j=>j.name===S.name&&j.mode==="copy")??!1;if(N==="link-ok"){T.skipped.push(S.name),T.links.push(S.name),h.set(S.source,[...h.get(S.source)??[],{name:S.name,version:S.version,mode:"link"}]);continue}if(N==="dir"&&!e.force){if(!I){T.conflicts.push(S.name);continue}if(Ne(S.dir,R)){T.skipped.push(S.name),T.copies.push(S.name),h.set(S.source,[...h.get(S.source)??[],{name:S.name,version:S.version,mode:"copy"}]);continue}}if(N==="file"&&!e.force){T.conflicts.push(S.name);continue}let v=!!e.copy||S.temporary||N==="dir"&&I;if(e.dryRun){N==="absent"?T.created.push(S.name):T.updated.push(S.name),v?T.copies.push(S.name):T.links.push(S.name);continue}try{N!=="absent"&&ze(R);let j=Dl(S.linkTarget,S.dir,R,v);N==="absent"?T.created.push(S.name):T.updated.push(S.name),j.mode==="link"?T.links.push(S.name):(T.copies.push(S.name),j.reason&&T.degraded.push({name:S.name,reason:j.reason})),h.set(S.source,[...h.get(S.source)??[],{name:S.name,version:S.version,mode:j.mode}])}catch(j){T.failed.push({name:S.name,reason:j.message})}}if(e.prune&&!e.dryRun)for(let S of t)T.pruned.push(...ls(m.get(S.name)?.get(b),o,$.dir,s));if(y.push(T),!e.dryRun){let S=new Set(T.pruned);for(let R of t){let N=m.get(R.name)?.get(b),I=[...h.get(R.name)??[],...N?.entries.filter(v=>!o.has(v.name)&&!S.has(v.name)&&(0,B.existsSync)((0,Y.join)($.dir,v.name)))??[]];I.length>0&&d.get(R.name).push({id:N?.id??Vr($.dir,$.kind),dir:$.dir,label:$.label,kind:$.kind,entries:I})}}}let x=!!e.prune&&l!==void 0;for(let $ of t)for(let b of u?.sources?.[$.name]?.targets??[]){if(k.has(P(b.dir)))continue;let T=b.entries;if(x){let h=ls(b,new Set,b.dir,s);if(h.length>0){y.push({dir:b.dir,label:b.label||Pt(b.dir)||b.dir,kind:b.kind==="primary"||b.kind==="agent"?b.kind:"custom",created:[],updated:[],skipped:[],conflicts:[],failed:[],degraded:[],links:[],copies:[],pruned:h});let S=new Set(h);T=T.filter(R=>!S.has(R.name))}}T.length>0&&d.get($.name).push({...b,entries:T})}if(!e.dryRun){let $={};for(let[b,T]of Object.entries(u?.sources??{}))!t.some(h=>h.name===b)&&T.targets.length>0&&($[b]=T);for(let b of t){let T=d.get(b.name)??[];T.length>0&&($[b.name]={kind:b.kind,version:b.version,temporary:b.temporary,root:b.root,url:b.url,ref:b.ref,targets:T})}if(rd($),e.saveSelection!==!1&&td(t,r),e.saveTargets!==!1){let b=new Set(a.filter(h=>h.name).map(h=>h.name)),T=l?l.filter(h=>b.has(h)):p.filter(h=>h.name).map(h=>h.name);nd([...new Set(T)])}}return{source:ut(),skills:r.map($=>$.name),selection:r.map($=>$.name),mode:e.mode??se().mode??"skills",targetSelection:p.filter($=>$.name).map($=>$.name),targets:y,skippedTargets:f,stateFile:ft()}}finally{g?.()}}function td(e,t){try{let r={...se().selection??{}};for(let o of e){if(o.temporary){delete r[o.name];continue}r[o.name]=t.filter(s=>s.source===o.name).map(s=>s.name)}Ve({selection:Object.keys(r).length>0?r:void 0})}catch(n){console.warn(`\u26A0\uFE0F \u6280\u80FD\u9009\u62E9\u4FDD\u5B58\u5931\u8D25\uFF1A${n.message}`)}}function nd(e){try{Ve({targets:e})}catch(t){console.warn(`\u26A0\uFE0F \u76EE\u6807\u9009\u62E9\u4FDD\u5B58\u5931\u8D25\uFF1A${t.message}`)}}function rd(e){let t=Object.fromEntries(Object.entries(e).filter(([,r])=>r.targets.length>0)),n=ft();if(Object.keys(t).length===0){(0,B.rmSync)(n,{force:!0});return}(0,B.mkdirSync)((0,Y.dirname)(n),{recursive:!0}),_(n,`${JSON.stringify({format:Ke,schemaVersion:Ye,updatedAt:new Date().toISOString(),sources:t},null,2)}
|
|
118
|
-
`)}function od(e,t){let n=se();if(!n.selection)return;let r={...n.selection};if(!e&&!t){Ve({selection:void 0});return}let o=new Set(e??[]);for(let s of Object.keys(r)){if(t&&s!==t)continue;let i=e?(r[s]??[]).filter(l=>!o.has(l)):[];i.length>0?r[s]=i:delete r[s]}Ve({selection:Object.keys(r).length>0?r:void 0})}function sd(e){let t=se(),n={...t.sources??{}};delete n[e];let r={...t.selection??{}};delete r[e],Ve({sources:Object.keys(n).length>0?n:void 0,selection:Object.keys(r).length>0?r:void 0})}function id(e,t){if(e===De||t.kind==="builtin")return ql([Vn()]);if(!t.root||!(0,B.existsSync)(t.root))return new Map;try{return ql([_t(t.root,{name:e,temporary:t.temporary})])}catch{return new Map}}function as(e={}){let t=ft();e.dryRun||(od(e.skills,e.source),e.source&&sd(e.source));let n=e.dryRun?null:qr(is(J()));try{let r=rt();if(!r)return{stateFile:t,stateExists:!1,targets:[],stateRemoved:!1};let o=e.skills?new Set(e.skills):null,s=[],i=!1,l=!1,c={};for(let[p,g]of Object.entries(r.sources)){if(e.source&&e.source!==p){c[p]=g;continue}let u=id(p,g),m=[];for(let d of g.targets){let k={dir:d.dir,label:d.label||Pt(d.dir)||null,removed:[],missing:[],skippedForeign:[],dirReclaimed:!1},y=[];for(let x of d.entries){if(o&&!o.has(x.name)){y.push(x);continue}let $=(0,Y.join)(d.dir,x.name),b=u.get(x.name);if(!b){let h=!1;try{h=(0,B.lstatSync)($).isSymbolicLink()&&!(0,B.existsSync)($)}catch{h=!1}if(h&&!e.dryRun){ze($),k.removed.push(x.name),l=!0;continue}if(h){k.removed.push(x.name);continue}k.skippedForeign.push(x.name),y.push(x);continue}let T=Ft($,b.linkTarget,void 0,b.dir);if(T==="absent"){k.missing.push(x.name),l=!0;continue}if(T==="wrong"||T==="file"||T==="dir"&&!Ne(b.dir,$)){k.skippedForeign.push(x.name),y.push(x);continue}if(e.dryRun){k.removed.push(x.name);continue}try{ze($),k.removed.push(x.name),l=!0}catch{i=!0,k.skippedForeign.push(x.name),y.push(x)}}if(!e.dryRun&&Wn(d.dir))try{(0,B.rmSync)(d.dir,{recursive:!0,force:!0}),k.dirReclaimed=!0}catch{}s.push(k),y.length>0&&m.push({...d,entries:y})}m.length>0&&(c[p]={...g,targets:m})}let a=s.every(p=>p.skippedForeign.length===0),f=!e.dryRun&&!i&&a&&Object.keys(c).length===0;return e.dryRun||(f?(0,B.rmSync)(t,{force:!0}):(l||Object.keys(c).length!==Object.keys(r.sources).length)&&Jr({format:Ke,schemaVersion:Ye,updatedAt:new Date().toISOString(),sources:c})),{stateFile:t,stateExists:!0,targets:s,stateRemoved:f}}finally{n?.()}}function Xl(e,t,n){t==="created"?e.created.push(n):t==="updated"?e.updated.push(n):t==="skipped"?e.skipped.push(n):e.conflicts.push(n)}function ld(e,t,n,r,o){return(0,B.existsSync)(t)?Ne(e,t)?"skipped":!n&&!r?"conflict":(o||(ze(t),Gn(e,t)),"updated"):(o||Gn(e,t),"created")}function cd(e,t,n,r){let o=(0,B.existsSync)(e),s=o?E(e):"",i=o?Ht(s):null,l;return o?i!==null&&i>zr()||s===t?l="skipped":i===null&&!n?l="conflict":l="updated":l="created",!r&&(l==="created"||l==="updated")&&((0,B.mkdirSync)((0,Y.dirname)(e),{recursive:!0}),_(e,t)),l}function tc(e={}){let t=e.cwd??process.cwd(),n=cs({externalSources:e.externalSources,dryRun:e.dryRun}),r=n.flatMap(Dt);Kr(r);let o=Zl(r,e.skills),s=new Set(o.map(x=>x.name)),i=new Map(r.map(x=>[x.name,{dir:x.dir,linkTarget:x.linkTarget}])),l=Nt(t),c=l.root,a=un(c),f=(x,$,b)=>a?.sources?.[x]?.targets.find(T=>T.kind===$&&T.dir===b),p=[],g=[];for(let x of e.dirs??[]){let $=(0,Y.resolve)(t,x);if(!zn($,c)){p.push(x);continue}let b=Mt(c,$);b!==l.sourceDir&&!g.includes(b)&&g.push(b)}let u=Fe(c).targets,m=e.targetDirs??(u&&u.length>0?u:void 0),d;if(m===void 0)d=[...l.shellDirs];else{d=[];for(let x of m){let $=(0,Y.resolve)(c,x);if(!zn($,c)){console.warn(`\u26A0\uFE0F \u5FFD\u7565\u4ED3\u5E93\u4E4B\u5916\u7684\u6280\u80FD\u76EE\u5F55\uFF1A${x}`);continue}let b=Mt(c,$);if(b!==l.sourceDir){if(!(0,B.existsSync)($)){console.warn(`\u26A0\uFE0F \u5FFD\u7565\u4E0D\u5B58\u5728\u7684\u6280\u80FD\u76EE\u5F55\uFF1A${b}\uFF08\u8865\u9F50\u76EE\u5F55\u540E\u91CD\u8DD1\u5373\u53EF\uFF09`);continue}d.includes(b)||d.push(b)}}}let k=[...d.filter(x=>!g.includes(x)),...g],y=e.dryRun?null:qr(zl(c));try{let x={dir:l.sourceDir,created:[],updated:[],skipped:[],conflicts:[],failed:[],pruned:[]},$=(0,Y.join)(c,l.sourceDir),b=new Map;for(let I of o){let v=f(I.source,"source",l.sourceDir)?.entries.some(j=>j.name===I.name)??!1;try{let j=ld(I.dir,(0,Y.join)($,I.name),v,!!e.force,!!e.dryRun);Xl(x,j,I.name),j!=="conflict"&&!e.dryRun&&b.set(I.source,[...b.get(I.source)??[],{name:I.name,version:I.version,mode:"copy"}])}catch(j){x.failed.push({name:I.name,reason:j.message})}}if(e.prune&&!e.dryRun)for(let I of n)x.pruned.push(...ls(f(I.name,"source",l.sourceDir),s,$,i));let T=new Set(x.pruned),h=[],S=new Map;for(let I of n)S.set(I.name,[]);for(let I of n){let v=f(I.name,"source",l.sourceDir),j=[...b.get(I.name)??[],...v?.entries.filter(z=>!s.has(z.name)&&!T.has(z.name)&&(0,B.existsSync)((0,Y.join)($,z.name)))??[]];j.length>0&&S.get(I.name).push({id:"source",dir:l.sourceDir,label:"\u771F\u6E90\u526F\u672C",kind:"source",entries:j})}for(let I of k){let v={dir:I,created:[],updated:[],skipped:[],conflicts:[],failed:[],pruned:[]},j=new Map;for(let C of o){let A=Wr(C.name,l.sourceDir,Gr(C.dir));try{let D=cd((0,Y.join)(c,I,C.name,X),A,!!e.force,!!e.dryRun);Xl(v,D,C.name),D!=="conflict"&&!e.dryRun&&j.set(C.source,[...j.get(C.source)??[],{name:C.name,version:C.version,mode:"shell"}])}catch(D){v.failed.push({name:C.name,reason:D.message})}}if(e.prune&&!e.dryRun)for(let C of n)for(let A of f(C.name,"shell",I)?.entries??[]){if(s.has(A.name))continue;let D=(0,Y.join)(c,I,A.name,X);if(!(0,B.existsSync)(D))continue;let M=E(D);Ht(M)!==null&&(ze((0,Y.join)(c,I,A.name)),v.pruned.push(A.name))}let z=new Set(v.pruned);for(let C of n){let A=f(C.name,"shell",I),D=[...j.get(C.name)??[],...A?.entries.filter(M=>!s.has(M.name)&&!z.has(M.name)&&(0,B.existsSync)((0,Y.join)(c,I,M.name)))??[]];D.length>0&&S.get(C.name).push({id:I,dir:I,label:"\u8584\u58F3",kind:"shell",entries:D})}h.push(v)}let R=new Set(k),N=!!e.prune&&m!==void 0;for(let I of n)for(let v of a?.sources?.[I.name]?.targets.filter(j=>j.kind==="shell")??[]){if(R.has(v.dir))continue;let j=v.entries;if(N){let z={dir:v.dir,created:[],updated:[],skipped:[],conflicts:[],failed:[],pruned:[]},C=[];for(let A of j){let D=(0,Y.join)(c,v.dir,A.name),M=(0,Y.join)(D,X);if(!(0,B.existsSync)(M))continue;let ee;try{ee=E(M)}catch{C.push(A);continue}if(Ht(ee)===null){C.push(A);continue}try{ze(D),z.pruned.push(A.name)}catch{C.push(A)}}j=C,z.pruned.length>0&&h.push(z)}j.length>0&&S.get(I.name).push({...v,entries:j})}if(!e.dryRun){let I={};for(let[v,j]of Object.entries(a?.sources??{}))!n.some(z=>z.name===v)&&j.targets.length>0&&(I[v]=j);for(let v of n){let j=S.get(v.name)??[];j.length>0&&(I[v.name]={kind:v.kind,version:v.version,temporary:v.temporary,root:v.url?"":v.root,url:v.url,ref:v.ref,targets:j})}fd(c,I),e.saveSelection!==!1&&ad(c,o.filter(v=>!v.temporary).map(v=>v.name)),e.saveTargets!==!1&&ud(c,d)}return{root:c,skills:o.map(I=>I.name),selection:o.map(I=>I.name),mode:e.mode??Fe(c).mode??"skills",targetSelection:k,source:x,shells:h,missingDirs:l.missingDirs,ignoredDirs:p,stateFile:Mt(c,dt(c))}}finally{y?.()}}function ad(e,t){try{let n=Fe(e);Ot({targets:n.targets,selection:t},e)}catch(n){console.warn(`\u26A0\uFE0F \u9879\u76EE\u9762\u6280\u80FD\u9009\u62E9\u4FDD\u5B58\u5931\u8D25\uFF1A${n.message}`)}}function ud(e,t){try{Ot({targets:[...new Set(t)]},e)}catch(n){console.warn(`\u26A0\uFE0F \u9879\u76EE\u9762\u76EE\u5F55\u9009\u62E9\u4FDD\u5B58\u5931\u8D25\uFF1A${n.message}`)}}function fd(e,t){let n=Object.fromEntries(Object.entries(t).filter(([,r])=>r.targets.length>0));if(Object.keys(n).length===0){os(e);return}rs(e,n)}function dd(e,t){let n=Fe(e);if(!n.selection)return;if(!t){Ot({selection:void 0},e);return}let r=new Set(t),o=n.selection.filter(s=>!r.has(s));Ot({selection:o.length>0?o:void 0},e)}function nc(e={}){let t=e.cwd??process.cwd(),n=Nt(t),r=n.root,o=dt(r),s=Mt(r,o);e.dryRun||dd(r,e.skills);let i=un(r);if(!i)return{root:r,stateFile:s,stateExists:!1,sourceDir:n.sourceDir,dirs:[],reclaimed:[],stateRemoved:!1};let l=e.skills?new Set(e.skills):null,c=new Map(nt().map(k=>[k.name,k.dir])),a=[],f=[],p={},g=!1,u=!1;for(let[k,y]of Object.entries(i.sources)){let x=[];for(let $ of y.targets){if($.kind!=="source"&&$.kind!=="shell")continue;let b={dir:$.dir,kind:$.kind,removed:[],missing:[],skippedForeign:[]},T=[];for(let h of $.entries){if(l&&!l.has(h.name)){T.push(h);continue}let S=(0,Y.join)(r,$.dir,h.name);if(!($.kind==="source"?(0,B.existsSync)(S):(0,B.existsSync)((0,Y.join)(S,X)))){b.missing.push(h.name),u=!0;continue}if(!($.kind==="source"?gd(S,c.get(h.name)):pd(S))){b.skippedForeign.push(h.name),T.push(h);continue}if(e.dryRun){b.removed.push(h.name);continue}try{ze(S),b.removed.push(h.name),u=!0}catch{g=!0,b.skippedForeign.push(h.name),T.push(h)}}a.push(b),T.length>0&&x.push({...$,entries:T})}x.length>0&&(p[k]={...y,targets:x})}if(!e.dryRun)for(let k of[n.sourceDir,...i.sources[De]?.targets.filter(y=>y.kind==="shell").map(y=>y.dir)??[]]){let y=(0,Y.join)(r,k);if(!(!(0,B.existsSync)(y)||!Wn(y)))try{(0,B.rmSync)(y,{recursive:!0,force:!0}),f.push(k)}catch{}}let m=a.every(k=>k.skippedForeign.length===0),d=!e.dryRun&&!g&&m&&Object.keys(p).length===0;return e.dryRun||(d?os(r):(u||Object.keys(p).length!==Object.keys(i.sources).length)&&rs(r,p)),{root:r,stateFile:s,stateExists:!0,sourceDir:n.sourceDir,dirs:a,reclaimed:f,stateRemoved:d}}function gd(e,t){return!!t&&Ne(t,e)}function pd(e){try{return Ht(E((0,Y.join)(e,X)))!==null}catch{return!1}}function rc(){let e=de("skills");if(e?.autoLink===!1||process.env.CI)return 0;let t=rt();if(!t)return 0;let n=ut(),r;try{r=new Set((0,B.readdirSync)(n).filter(a=>(0,B.existsSync)((0,Y.join)(n,a))))}catch{return 0}let o=es(),s=e?.autoLinkReplaceForeign!==!1,i=process.platform==="win32"?"junction":"dir",l=0,c={};for(let[a,f]of Object.entries(t.sources)){let p=[];for(let g of f.targets){let u;try{u=(0,B.readdirSync)(g.dir,{withFileTypes:!0})}catch{p.push(g);continue}let m=new Map(u.map(k=>[k.name,k])),d=g.entries.filter(k=>{if(k.mode!=="link")return r.has(k.name);if(!r.has(k.name))return!1;let y=(0,Y.join)(o,k.name),x=(0,Y.join)(g.dir,k.name),$=m.get(k.name),b=$?Ft(x,y,$):"absent";if(b==="link-ok"||!s&&(b==="dir"||b==="file"))return!0;try{return b!=="absent"&&ze(x),(0,B.symlinkSync)(y,x,i),l+=1,!0}catch{return!0}});p.push({...g,entries:d})}c[a]={...f,targets:p}}return l>0&&Jr({format:Ke,schemaVersion:Ye,updatedAt:new Date().toISOString(),sources:c}),l}var xe=require("fs"),ke=require("path");function md(e){return new Map((e?.entries??[]).map(t=>[t.name,t]))}function hd(e){let t=new Map;for(let n of Object.values(e?.sources??{}))for(let r of n.targets)for(let o of r.entries)t.set(o.name,o.version);return t}function sc(e){let t=new Map,n=[],r=hd(e),o=(l,c,a,f,p,g)=>{if(!n.some(u=>u.name===l)){n.push({name:l,kind:c,root:a,version:f,temporary:p,skills:g.map(u=>u.name)});for(let u of g)t.has(u.name)||t.set(u.name,{source:l,version:u.version,dir:u.dir,linkTarget:c==="builtin"?(0,ke.join)(a,"skills",u.name):u.dir,tier:u.tier})}},s=Vn();o(s.name,"builtin",s.root,s.version,!1,s.skills);for(let l of Dt(s))t.set(l.name,{source:l.source,version:l.version,dir:l.dir,linkTarget:l.linkTarget,tier:l.tier});let i=se();for(let[l,c]of Object.entries(i.sources??{}))if(!n.some(a=>a.name===l))try{let a=c.url?e?.sources[l]?.root:c.root;if(!a)continue;let f=_t(a,{name:l,temporary:!1});o(f.name,"local",f.root,f.version,!1,f.skills)}catch{}for(let[l,c]of Object.entries(e?.sources??{})){if(n.some(g=>g.name===l))continue;let a=[];if(c.root&&(0,xe.existsSync)(c.root))try{a=_t(c.root,{name:l,temporary:c.temporary}).skills}catch{a=[]}let f=new Set(a.map(g=>g.name));for(let g of c.targets)for(let u of g.entries)f.add(u.name);let p=[...f].map(g=>{let u=a.find(d=>d.name===g);if(u)return u;let m=c.root?(0,ke.join)(c.root,g):g;return{name:g,dir:m,version:r.get(g)??"",tier:"optional",requires:[]}});if(o(l,c.kind==="builtin"?"builtin":"local",c.root,c.version,c.temporary,p),p.length>0&&c.kind!=="builtin")for(let g of p){let u=t.get(g.name);u&&t.set(g.name,{...u,linkTarget:g.dir})}}return{refs:t,sources:n}}function kd(e){let t;try{t=(0,xe.lstatSync)(e)}catch{return"absent"}if(!t.isSymbolicLink())return t.isDirectory()?"dir":"file";try{let n=(0,xe.readlinkSync)(e),r=Bn((0,ke.isAbsolute)(n)?n:(0,ke.join)((0,ke.dirname)(e),n));return(0,xe.existsSync)(r)?"wrong":"dangling"}catch{return"dangling"}}function Xr(e,t,n=[]){return[...new Set([...e,...t?.entries.map(o=>o.name)??[],...n])].sort()}function Zr(e,t){return Pl(e).filter(n=>n.isDirectory()||n.isSymbolicLink()).map(n=>n.name).filter(n=>t.has(n))}function oc(e,t,n,r,o,s=!0){let i=md(o),l=[];for(let c of t){let a=r.get(c),f=n.has(c),p=(0,ke.join)(e,c),g=a?Ft(p,a.linkTarget,void 0,a.dir):kd(p),u;s?g==="link-ok"?u=f?"link":"installed-unselected":g==="dangling"?u="dangling":g==="wrong"?u="wrong":g==="file"?u="conflict":g==="dir"?a&&(0,xe.existsSync)(a.dir)&&Ne(a.dir,p)?u=f?"copy":"installed-unselected":u=i.get(c)?.mode==="copy"?"copy-drift":"conflict":u=f?"missing":"not-selected":g==="absent"?u="not-selected":g==="wrong"||g==="file"?u=g==="wrong"?"wrong":"conflict":u="installed-unselected",u!=="not-selected"&&l.push({name:c,state:u,version:a?.version??"",source:a?.source??""})}return l}function ic(){let e=rt(),t=se(),{refs:n,sources:r}=sc(e),o=[...n.keys()].sort(),s=t.mode??"skills",i=t.selection,l=i!==void 0&&Object.keys(i).length>0,c=l?o.filter(h=>{let S=n.get(h),R=i[S.source];return R===void 0||R.includes(h)}):s==="package"?[]:o.filter(h=>n.get(h).tier==="core"),a=new Set(c),f=t.targets&&t.targets.length>0?t.targets:void 0,p=h=>!f||f.includes(h),g=We([]),u=new Map(g.filter(h=>h.name).map(h=>[P(h.dir),h.name])),m=new Map;for(let h of Object.values(e?.sources??{}))for(let S of h.targets)m.set(P(S.dir),S);let d=new Set(o),k=h=>l?a:new Set([...a,...h?.entries.map(S=>S.name)??[]]),y=[],x=[],$=new Set;for(let h of g){let S=m.get(P(h.dir));if(!h.available&&h.kind==="agent"){x.push({dir:h.dir,label:h.label});continue}if(h.kind!=="primary"&&!S&&(!h.dirExists||Wn(h.dir)))continue;$.add(P(h.dir));let R=k(S),N=h.name?p(h.name):!0,I=oc(h.dir,Xr(R,S,Zr(h.dir,d)),R,n,S,N);!N&&I.length===0||y.push({dir:h.dir,label:h.label,kind:h.kind,available:h.available,dirExists:h.dirExists,recorded:!!S,selected:N,items:I})}let b=[];for(let h of m.values()){if($.has(P(h.dir)))continue;let S=Ol(h.dir);S&&(0,xe.existsSync)(h.dir)&&b.push({dir:h.dir,label:S});let R=k(h),N=u.get(P(h.dir))??"",I=N?p(N):!0,v=oc(h.dir,Xr(R,h,Zr(h.dir,d)),R,n,h,I);!I&&v.length===0||y.push({dir:h.dir,label:S??(h.label||Pt(h.dir)||"\u81EA\u5B9A\u4E49 --dir"),kind:h.kind==="primary"||h.kind==="agent"?h.kind:"custom",available:!0,dirExists:(0,xe.existsSync)(h.dir),recorded:!0,selected:I,items:v})}let T=[...n.entries()].map(([h,S])=>({name:h,dir:S.dir,version:S.version,tier:S.tier,requires:[]}));return{source:ut(),skills:o,mode:s,selection:c,targetSelection:f??[],sources:r,skillVersions:Object.fromEntries([...n.entries()].map(([h,S])=>[h,S.version])),versionMismatches:ts(T),stateFile:ft(),stateExists:!!e,targets:y,pendingAgents:x,canonicalReaders:Ll(),legacyTargets:b}}function Sd(e,t,n){if(!(0,xe.existsSync)(e))return"missing";let r;try{r=E(e)}catch{return"conflict"}let o=Ht(r);return o===null?"conflict":o>zr()||r===Wr(t.name,n,Gr(t.dir))?"ready":"drift"}function lc(e=process.cwd()){let t=Nt(e),n=t.root,r=un(n),o=Fe(n),{refs:s,sources:i}=sc(r),l=[...s.keys()].sort(),c=o.mode??"skills",a=o.selection!==void 0?o.selection:void 0,f=a!==void 0?l.filter(v=>a.includes(v)):c==="package"?[]:l.filter(v=>s.get(v).tier==="core"),p=new Set(f),g=o.targets&&o.targets.length>0?o.targets:void 0,u=v=>!g||g.includes(v),m=Object.values(r?.sources??{}).flatMap(v=>v.targets),d=m.find(v=>v.kind==="source"&&v.dir===t.sourceDir),k=new Map(m.filter(v=>v.kind==="shell").map(v=>[v.dir,v])),y=new Set(d?.entries.map(v=>v.name)??[]),x=new Set(l),$=v=>a===void 0?new Set([...p,...v]):p,b=$(y),T=Xr(b,d,Zr((0,ke.join)(n,t.sourceDir),x)),h=[];for(let v of T){let j=s.get(v),z=(0,ke.join)(n,t.sourceDir,v),C;(0,xe.existsSync)(z)?j&&Ne(j.dir,z)?C=b.has(v)?"ready":"installed-unselected":C=y.has(v)?"drift":"conflict":C=b.has(v)?"missing":"not-selected",C!=="not-selected"&&h.push({name:v,state:C,version:j?.version??"",source:j?.source??""})}let S=[{dir:t.sourceDir,kind:"source",selected:!0,items:h}],R=(v,j)=>{let z=u(v),C=new Set(j?.entries.map(M=>M.name)??[]),A=$(C),D=[];for(let M of Xr(A,j,Zr((0,ke.join)(n,v),x))){let ee=s.get(M),U;if(!ee)U="conflict";else{let ie=(0,ke.join)(n,v,M,X);U=Sd(ie,{name:M,dir:ee.dir},t.sourceDir),U==="conflict"&&C.has(M)&&(U="drift"),z?(U==="ready"&&!A.has(M)&&(U="installed-unselected"),U==="missing"&&!A.has(M)&&(U="not-selected")):U==="missing"?U="not-selected":(U==="ready"||U==="drift")&&(U="installed-unselected")}U!=="not-selected"&&D.push({name:M,state:U,version:ee?.version??"",source:ee?.source??""})}return{dir:v,kind:"shell",selected:z,items:D}};for(let v of t.shellDirs)S.push(R(v,k.get(v)));let N=new Set(t.shellDirs);for(let[v,j]of k){if(N.has(v)||!(0,xe.existsSync)((0,ke.join)(n,v)))continue;let z=R(v,j);z.items.length>0&&S.push(z)}let I=[...s.entries()].map(([v,j])=>({name:v,dir:j.dir,version:j.version,tier:j.tier,requires:[]}));return{root:n,sourceDir:t.sourceDir,skills:l,mode:c,selection:f,targetSelection:g??[],sources:i,skillVersions:Object.fromEntries([...s.entries()].map(([v,j])=>[v,j.version])),versionMismatches:ts(I),stateFile:Mt(n,dt(n)),stateExists:!!r,dirs:S,missingDirs:t.missingDirs}}function us(e){return e.filter(t=>t.tier==="core").map(t=>t.name)}function yd(e){return e.filter(t=>t.tier!=="core").map(t=>t.name)}function bd(e,t,n="skills"){let r=new Set(t??[]);return e.map(o=>({name:o.name,tier:o.tier,selected:n==="skills"&&o.tier==="core"||r.has(o.name)}))}function cc(e,t){let n=new Set(t);return e.filter(r=>n.has(r.name)).map(r=>r.name)}function fs(e,t,n="skills"){let r=new Set(n==="skills"?[...us(e),...t]:t);return e.filter(o=>r.has(o.name)).map(o=>o.name)}function ac(e){let{skills:t,saved:n,explicit:r,all:o,noOptional:s,interactive:i,yes:l}=e,c=e.mode??"skills",a=t.map(d=>d.name);if(r!==void 0){let d=cc(t,r),k=r.filter(y=>!a.includes(y));return d.length===0?{names:[],invalid:k,savedInvalid:[],needsPrompt:!1,error:"\u5168\u90E8\u53D6\u503C\u975E\u6CD5"}:{names:fs(t,d,c),invalid:k,savedInvalid:[],needsPrompt:!1}}if(o)return{names:a,invalid:[],savedInvalid:[],needsPrompt:!1};if(s)return{names:us(t),invalid:[],savedInvalid:[],needsPrompt:!1};let f=n!==void 0,p=cc(t,n??[]),g=(n??[]).filter(d=>!a.includes(d)),u=c==="package"?f?p:[]:p.length>0?fs(t,p,c):us(t),m=i&&!l&&(c==="package"?t.length>0:yd(t).length>0);return{names:u,invalid:[],savedInvalid:g,needsPrompt:m}}function qn(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}function ds(e){return e instanceof Error?e.name==="ExitPromptError"||e.name==="AbortPromptError"||/force closed|cancel/i.test(e.message):!1}function uc(e,t,n=[]){let r=t?new Set(t):void 0,o=[],s=e.find(l=>l.kind==="primary");s&&o.push({value:s.name,label:`\u5171\u8BFB\uFF5C${s.label}`,checked:r?r.has(s.name):!0});for(let l of e.filter(c=>c.kind==="agent"))!l.available&&!r?.has(l.name)||o.push({value:l.name,label:`agent\uFF5C${l.label}${l.available?"":"\uFF08\u672A\u68C0\u6D4B\u5230\uFF09"}`,checked:l.available?r?r.has(l.name):!0:!1,disabled:l.available?!1:"\u672C\u673A\u672A\u68C0\u6D4B\u5230\u8BE5 agent\uFF0C\u4E0D\u51ED\u7A7A\u521B\u5EFA\u76EE\u5F55"});let i=new Set(n);for(let l of e.filter(c=>c.kind==="custom"&&i.has(c.dir)))o.push({value:l.dir,label:`\u81EA\u5B9A\u4E49\uFF5C${l.dir}\uFF08\u4E00\u6B21\u6027 --dir\uFF09`,checked:!0,disabled:"\u4E00\u6B21\u6027 --dir\uFF0C\u672C\u6B21\u56FA\u5B9A\u5199\u5165\u3001\u4E0D\u4FDD\u5B58\u4E3A\u957F\u671F\u9009\u62E9"});return o}function fc(e,t,n=[],r=[]){let o=t?new Set(t):void 0,s=e.map(i=>({value:i,label:`\u9879\u76EE\u76EE\u5F55\uFF5C${i}`,checked:o?o.has(i):!0}));for(let i of r)o?.has(i)&&s.push({value:i,label:`\u9879\u76EE\u76EE\u5F55\uFF5C${i}\uFF08\u4E0D\u5B58\u5728\uFF09`,checked:!1,disabled:"\u76EE\u5F55\u4E0D\u5B58\u5728\uFF0C\u8865\u9F50\u540E\u91CD\u8DD1\u5373\u53EF"});for(let i of n)e.includes(i)||s.push({value:i,label:`\u81EA\u5B9A\u4E49\uFF5C${i}\uFF08\u4E00\u6B21\u6027 --dir\uFF09`,checked:!0,disabled:"\u4E00\u6B21\u6027 --dir\uFF0C\u672C\u6B21\u56FA\u5B9A\u5199\u5165\u3001\u4E0D\u4FDD\u5B58\u4E3A\u957F\u671F\u9009\u62E9"});return s}async function gs(e,t){if(e.length===0)return[];let{checkbox:n}=await import("@inquirer/prompts");try{return await n({message:t,choices:e.map(r=>({value:r.value,name:r.label,checked:r.checked,disabled:r.disabled??!1})),pageSize:15,required:!1})}catch(r){if(ds(r))return null;throw r}}async function dc(e){let{confirm:t}=await import("@inquirer/prompts");try{return await t({message:e,default:!0})}catch(n){if(ds(n))return null;throw n}}async function gc(e,t,n="skills"){let{checkbox:r}=await import("@inquirer/prompts"),o=bd(e,t,n).map(s=>({value:s.name,name:n==="skills"&&s.tier==="core"?`${s.name}\uFF08core\uFF09`:s.name,checked:s.selected,disabled:n==="skills"&&s.tier==="core"?"core\uFF08\u5FC5\u88C5\uFF09":!1}));try{let s=await r({message:n==="package"?"\u9009\u62E9\u8981\u5B89\u88C5\u7684\u6280\u80FD\uFF08\u7A7A\u683C\u5207\u6362\uFF0C\u56DE\u8F66\u786E\u8BA4\uFF1B\u5168\u4E0D\u9009\u5373\u7EAF\u5305\u7BA1\u7406\u5668\u6A21\u5F0F\uFF09":"\u9009\u62E9\u8981\u5B89\u88C5\u7684\u6280\u80FD\uFF08\u7A7A\u683C\u5207\u6362\uFF0C\u56DE\u8F66\u786E\u8BA4\uFF1Bcore \u5FC5\u88C5\uFF09",choices:o,pageSize:12,required:!1});return n==="package"?s:fs(e,s)}catch(s){if(ds(s))return null;throw s}}var vd="2.0",pc=`/* fxri-docs-theme: ${vd} */`,$d=/^\/\* fxri-docs-theme: (?:v\d+|\d+\.\d+) \*\/$/,mc="/* fxri-docs-theme:brand-start */",hc="/* fxri-docs-theme:brand-end */",ps={"--site-accent":"--fx-accent","--site-glow":"--fx-accent-soft","--site-shadow":"--fx-shadow","--site-hero-angle":"--fx-hero-angle"};function kc(e){return new RegExp(`${e.replace(/[-]/g,"\\-")}(?=\\s*:)`,"g")}function xd(e){let t=e;for(let[n,r]of Object.entries(ps))t=t.replace(kc(n),r);return t}function ms(e){return e.replace(/^\uFEFF/,"").replace(/\r\n/g,`
|
|
118
|
+
`)}function od(e,t){let n=se();if(!n.selection)return;let r={...n.selection};if(!e&&!t){Ve({selection:void 0});return}let o=new Set(e??[]);for(let s of Object.keys(r)){if(t&&s!==t)continue;let i=e?(r[s]??[]).filter(l=>!o.has(l)):[];i.length>0?r[s]=i:delete r[s]}Ve({selection:Object.keys(r).length>0?r:void 0})}function sd(e){let t=se(),n={...t.sources??{}};delete n[e];let r={...t.selection??{}};delete r[e],Ve({sources:Object.keys(n).length>0?n:void 0,selection:Object.keys(r).length>0?r:void 0})}function id(e,t){if(e===De||t.kind==="builtin")return ql([Vn()]);if(!t.root||!(0,B.existsSync)(t.root))return new Map;try{return ql([_t(t.root,{name:e,temporary:t.temporary})])}catch{return new Map}}function as(e={}){let t=ft();e.dryRun||(od(e.skills,e.source),e.source&&sd(e.source));let n=e.dryRun?null:qr(is(J()));try{let r=rt();if(!r)return{stateFile:t,stateExists:!1,targets:[],stateRemoved:!1};let o=e.skills?new Set(e.skills):null,s=[],i=!1,l=!1,c={};for(let[p,g]of Object.entries(r.sources)){if(e.source&&e.source!==p){c[p]=g;continue}let u=id(p,g),m=[];for(let d of g.targets){let k={dir:d.dir,label:d.label||Pt(d.dir)||null,removed:[],missing:[],skippedForeign:[],dirReclaimed:!1},y=[];for(let x of d.entries){if(o&&!o.has(x.name)){y.push(x);continue}let $=(0,Y.join)(d.dir,x.name),b=u.get(x.name);if(!b){let h=!1;try{h=(0,B.lstatSync)($).isSymbolicLink()&&!(0,B.existsSync)($)}catch{h=!1}if(h&&!e.dryRun){ze($),k.removed.push(x.name),l=!0;continue}if(h){k.removed.push(x.name);continue}k.skippedForeign.push(x.name),y.push(x);continue}let T=Ft($,b.linkTarget,void 0,b.dir);if(T==="absent"){k.missing.push(x.name),l=!0;continue}if(T==="wrong"||T==="file"||T==="dir"&&!Ne(b.dir,$)){k.skippedForeign.push(x.name),y.push(x);continue}if(e.dryRun){k.removed.push(x.name);continue}try{ze($),k.removed.push(x.name),l=!0}catch{i=!0,k.skippedForeign.push(x.name),y.push(x)}}if(!e.dryRun&&Wn(d.dir))try{(0,B.rmSync)(d.dir,{recursive:!0,force:!0}),k.dirReclaimed=!0}catch{}s.push(k),y.length>0&&m.push({...d,entries:y})}m.length>0&&(c[p]={...g,targets:m})}let a=s.every(p=>p.skippedForeign.length===0),f=!e.dryRun&&!i&&a&&Object.keys(c).length===0;return e.dryRun||(f?(0,B.rmSync)(t,{force:!0}):(l||Object.keys(c).length!==Object.keys(r.sources).length)&&Jr({format:Ke,schemaVersion:Ye,updatedAt:new Date().toISOString(),sources:c})),{stateFile:t,stateExists:!0,targets:s,stateRemoved:f}}finally{n?.()}}function Xl(e,t,n){t==="created"?e.created.push(n):t==="updated"?e.updated.push(n):t==="skipped"?e.skipped.push(n):e.conflicts.push(n)}function ld(e,t,n,r,o){return(0,B.existsSync)(t)?Ne(e,t)?"skipped":!n&&!r?"conflict":(o||(ze(t),Gn(e,t)),"updated"):(o||Gn(e,t),"created")}function cd(e,t,n,r){let o=(0,B.existsSync)(e),s=o?E(e):"",i=o?Ht(s):null,l;return o?i!==null&&i>zr()||s===t?l="skipped":i===null&&!n?l="conflict":l="updated":l="created",!r&&(l==="created"||l==="updated")&&((0,B.mkdirSync)((0,Y.dirname)(e),{recursive:!0}),_(e,t)),l}function tc(e={}){let t=e.cwd??process.cwd(),n=cs({externalSources:e.externalSources,dryRun:e.dryRun}),r=n.flatMap(Dt);Kr(r);let o=Zl(r,e.skills),s=new Set(o.map(x=>x.name)),i=new Map(r.map(x=>[x.name,{dir:x.dir,linkTarget:x.linkTarget}])),l=Nt(t),c=l.root,a=un(c),f=(x,$,b)=>a?.sources?.[x]?.targets.find(T=>T.kind===$&&T.dir===b),p=[],g=[];for(let x of e.dirs??[]){let $=(0,Y.resolve)(t,x);if(!zn($,c)){p.push(x);continue}let b=Mt(c,$);b!==l.sourceDir&&!g.includes(b)&&g.push(b)}let u=Fe(c).targets,m=e.targetDirs??(u&&u.length>0?u:void 0),d;if(m===void 0)d=[...l.shellDirs];else{d=[];for(let x of m){let $=(0,Y.resolve)(c,x);if(!zn($,c)){console.warn(`\u26A0\uFE0F \u5FFD\u7565\u4ED3\u5E93\u4E4B\u5916\u7684\u6280\u80FD\u76EE\u5F55\uFF1A${x}`);continue}let b=Mt(c,$);if(b!==l.sourceDir){if(!(0,B.existsSync)($)){console.warn(`\u26A0\uFE0F \u5FFD\u7565\u4E0D\u5B58\u5728\u7684\u6280\u80FD\u76EE\u5F55\uFF1A${b}\uFF08\u8865\u9F50\u76EE\u5F55\u540E\u91CD\u8DD1\u5373\u53EF\uFF09`);continue}d.includes(b)||d.push(b)}}}let k=[...d.filter(x=>!g.includes(x)),...g],y=e.dryRun?null:qr(zl(c));try{let x={dir:l.sourceDir,created:[],updated:[],skipped:[],conflicts:[],failed:[],pruned:[]},$=(0,Y.join)(c,l.sourceDir),b=new Map;for(let I of o){let v=f(I.source,"source",l.sourceDir)?.entries.some(j=>j.name===I.name)??!1;try{let j=ld(I.dir,(0,Y.join)($,I.name),v,!!e.force,!!e.dryRun);Xl(x,j,I.name),j!=="conflict"&&!e.dryRun&&b.set(I.source,[...b.get(I.source)??[],{name:I.name,version:I.version,mode:"copy"}])}catch(j){x.failed.push({name:I.name,reason:j.message})}}if(e.prune&&!e.dryRun)for(let I of n)x.pruned.push(...ls(f(I.name,"source",l.sourceDir),s,$,i));let T=new Set(x.pruned),h=[],S=new Map;for(let I of n)S.set(I.name,[]);for(let I of n){let v=f(I.name,"source",l.sourceDir),j=[...b.get(I.name)??[],...v?.entries.filter(z=>!s.has(z.name)&&!T.has(z.name)&&(0,B.existsSync)((0,Y.join)($,z.name)))??[]];j.length>0&&S.get(I.name).push({id:"source",dir:l.sourceDir,label:"\u771F\u6E90\u526F\u672C",kind:"source",entries:j})}for(let I of k){let v={dir:I,created:[],updated:[],skipped:[],conflicts:[],failed:[],pruned:[]},j=new Map;for(let C of o){let A=Wr(C.name,l.sourceDir,Gr(C.dir));try{let D=cd((0,Y.join)(c,I,C.name,X),A,!!e.force,!!e.dryRun);Xl(v,D,C.name),D!=="conflict"&&!e.dryRun&&j.set(C.source,[...j.get(C.source)??[],{name:C.name,version:C.version,mode:"shell"}])}catch(D){v.failed.push({name:C.name,reason:D.message})}}if(e.prune&&!e.dryRun)for(let C of n)for(let A of f(C.name,"shell",I)?.entries??[]){if(s.has(A.name))continue;let D=(0,Y.join)(c,I,A.name,X);if(!(0,B.existsSync)(D))continue;let M=E(D);Ht(M)!==null&&(ze((0,Y.join)(c,I,A.name)),v.pruned.push(A.name))}let z=new Set(v.pruned);for(let C of n){let A=f(C.name,"shell",I),D=[...j.get(C.name)??[],...A?.entries.filter(M=>!s.has(M.name)&&!z.has(M.name)&&(0,B.existsSync)((0,Y.join)(c,I,M.name)))??[]];D.length>0&&S.get(C.name).push({id:I,dir:I,label:"\u8584\u58F3",kind:"shell",entries:D})}h.push(v)}let R=new Set(k),N=!!e.prune&&m!==void 0;for(let I of n)for(let v of a?.sources?.[I.name]?.targets.filter(j=>j.kind==="shell")??[]){if(R.has(v.dir))continue;let j=v.entries;if(N){let z={dir:v.dir,created:[],updated:[],skipped:[],conflicts:[],failed:[],pruned:[]},C=[];for(let A of j){let D=(0,Y.join)(c,v.dir,A.name),M=(0,Y.join)(D,X);if(!(0,B.existsSync)(M))continue;let ee;try{ee=E(M)}catch{C.push(A);continue}if(Ht(ee)===null){C.push(A);continue}try{ze(D),z.pruned.push(A.name)}catch{C.push(A)}}j=C,z.pruned.length>0&&h.push(z)}j.length>0&&S.get(I.name).push({...v,entries:j})}if(!e.dryRun){let I={};for(let[v,j]of Object.entries(a?.sources??{}))!n.some(z=>z.name===v)&&j.targets.length>0&&(I[v]=j);for(let v of n){let j=S.get(v.name)??[];j.length>0&&(I[v.name]={kind:v.kind,version:v.version,temporary:v.temporary,root:v.url?"":v.root,url:v.url,ref:v.ref,targets:j})}fd(c,I),e.saveSelection!==!1&&ad(c,o.filter(v=>!v.temporary).map(v=>v.name)),e.saveTargets!==!1&&ud(c,d)}return{root:c,skills:o.map(I=>I.name),selection:o.map(I=>I.name),mode:e.mode??Fe(c).mode??"skills",targetSelection:k,source:x,shells:h,missingDirs:l.missingDirs,ignoredDirs:p,stateFile:Mt(c,dt(c))}}finally{y?.()}}function ad(e,t){try{let n=Fe(e);Ot({targets:n.targets,selection:t},e)}catch(n){console.warn(`\u26A0\uFE0F \u9879\u76EE\u9762\u6280\u80FD\u9009\u62E9\u4FDD\u5B58\u5931\u8D25\uFF1A${n.message}`)}}function ud(e,t){try{Ot({targets:[...new Set(t)]},e)}catch(n){console.warn(`\u26A0\uFE0F \u9879\u76EE\u9762\u76EE\u5F55\u9009\u62E9\u4FDD\u5B58\u5931\u8D25\uFF1A${n.message}`)}}function fd(e,t){let n=Object.fromEntries(Object.entries(t).filter(([,r])=>r.targets.length>0));if(Object.keys(n).length===0){os(e);return}rs(e,n)}function dd(e,t){let n=Fe(e);if(!n.selection)return;if(!t){Ot({selection:void 0},e);return}let r=new Set(t),o=n.selection.filter(s=>!r.has(s));Ot({selection:o.length>0?o:void 0},e)}function nc(e={}){let t=e.cwd??process.cwd(),n=Nt(t),r=n.root,o=dt(r),s=Mt(r,o);e.dryRun||dd(r,e.skills);let i=un(r);if(!i)return{root:r,stateFile:s,stateExists:!1,sourceDir:n.sourceDir,dirs:[],reclaimed:[],stateRemoved:!1};let l=e.skills?new Set(e.skills):null,c=new Map(nt().map(k=>[k.name,k.dir])),a=[],f=[],p={},g=!1,u=!1;for(let[k,y]of Object.entries(i.sources)){let x=[];for(let $ of y.targets){if($.kind!=="source"&&$.kind!=="shell")continue;let b={dir:$.dir,kind:$.kind,removed:[],missing:[],skippedForeign:[]},T=[];for(let h of $.entries){if(l&&!l.has(h.name)){T.push(h);continue}let S=(0,Y.join)(r,$.dir,h.name);if(!($.kind==="source"?(0,B.existsSync)(S):(0,B.existsSync)((0,Y.join)(S,X)))){b.missing.push(h.name),u=!0;continue}if(!($.kind==="source"?gd(S,c.get(h.name)):pd(S))){b.skippedForeign.push(h.name),T.push(h);continue}if(e.dryRun){b.removed.push(h.name);continue}try{ze(S),b.removed.push(h.name),u=!0}catch{g=!0,b.skippedForeign.push(h.name),T.push(h)}}a.push(b),T.length>0&&x.push({...$,entries:T})}x.length>0&&(p[k]={...y,targets:x})}if(!e.dryRun)for(let k of[n.sourceDir,...i.sources[De]?.targets.filter(y=>y.kind==="shell").map(y=>y.dir)??[]]){let y=(0,Y.join)(r,k);if(!(!(0,B.existsSync)(y)||!Wn(y)))try{(0,B.rmSync)(y,{recursive:!0,force:!0}),f.push(k)}catch{}}let m=a.every(k=>k.skippedForeign.length===0),d=!e.dryRun&&!g&&m&&Object.keys(p).length===0;return e.dryRun||(d?os(r):(u||Object.keys(p).length!==Object.keys(i.sources).length)&&rs(r,p)),{root:r,stateFile:s,stateExists:!0,sourceDir:n.sourceDir,dirs:a,reclaimed:f,stateRemoved:d}}function gd(e,t){return!!t&&Ne(t,e)}function pd(e){try{return Ht(E((0,Y.join)(e,X)))!==null}catch{return!1}}function rc(){let e=de("skills");if(e?.autoLink===!1||process.env.CI)return 0;let t=rt();if(!t)return 0;let n=ut(),r;try{r=new Set((0,B.readdirSync)(n).filter(a=>(0,B.existsSync)((0,Y.join)(n,a))))}catch{return 0}let o=es(),s=e?.autoLinkReplaceForeign!==!1,i=process.platform==="win32"?"junction":"dir",l=0,c={};for(let[a,f]of Object.entries(t.sources)){let p=[];for(let g of f.targets){let u;try{u=(0,B.readdirSync)(g.dir,{withFileTypes:!0})}catch{p.push(g);continue}let m=new Map(u.map(k=>[k.name,k])),d=g.entries.filter(k=>{if(k.mode!=="link")return r.has(k.name);if(!r.has(k.name))return!1;let y=(0,Y.join)(o,k.name),x=(0,Y.join)(g.dir,k.name),$=m.get(k.name),b=$?Ft(x,y,$):"absent";if(b==="link-ok"||!s&&(b==="dir"||b==="file"))return!0;try{return b!=="absent"&&ze(x),(0,B.symlinkSync)(y,x,i),l+=1,!0}catch{return!0}});p.push({...g,entries:d})}c[a]={...f,targets:p}}return l>0&&Jr({format:Ke,schemaVersion:Ye,updatedAt:new Date().toISOString(),sources:c}),l}var xe=require("fs"),ke=require("path");function md(e){return new Map((e?.entries??[]).map(t=>[t.name,t]))}function hd(e){let t=new Map;for(let n of Object.values(e?.sources??{}))for(let r of n.targets)for(let o of r.entries)t.set(o.name,o.version);return t}function sc(e){let t=new Map,n=[],r=hd(e),o=(l,c,a,f,p,g)=>{if(!n.some(u=>u.name===l)){n.push({name:l,kind:c,root:a,version:f,temporary:p,skills:g.map(u=>u.name)});for(let u of g)t.has(u.name)||t.set(u.name,{source:l,version:u.version,dir:u.dir,linkTarget:c==="builtin"?(0,ke.join)(a,"skills",u.name):u.dir,tier:u.tier})}},s=Vn();o(s.name,"builtin",s.root,s.version,!1,s.skills);for(let l of Dt(s))t.set(l.name,{source:l.source,version:l.version,dir:l.dir,linkTarget:l.linkTarget,tier:l.tier});let i=se();for(let[l,c]of Object.entries(i.sources??{}))if(!n.some(a=>a.name===l))try{let a=c.url?e?.sources[l]?.root:c.root;if(!a)continue;let f=_t(a,{name:l,temporary:!1});o(f.name,"local",f.root,f.version,!1,f.skills)}catch{}for(let[l,c]of Object.entries(e?.sources??{})){if(n.some(g=>g.name===l))continue;let a=[];if(c.root&&(0,xe.existsSync)(c.root))try{a=_t(c.root,{name:l,temporary:c.temporary}).skills}catch{a=[]}let f=new Set(a.map(g=>g.name));for(let g of c.targets)for(let u of g.entries)f.add(u.name);let p=[...f].map(g=>{let u=a.find(d=>d.name===g);if(u)return u;let m=c.root?(0,ke.join)(c.root,g):g;return{name:g,dir:m,version:r.get(g)??"",tier:"optional",requires:[]}});if(o(l,c.kind==="builtin"?"builtin":"local",c.root,c.version,c.temporary,p),p.length>0&&c.kind!=="builtin")for(let g of p){let u=t.get(g.name);u&&t.set(g.name,{...u,linkTarget:g.dir})}}return{refs:t,sources:n}}function kd(e){let t;try{t=(0,xe.lstatSync)(e)}catch{return"absent"}if(!t.isSymbolicLink())return t.isDirectory()?"dir":"file";try{let n=(0,xe.readlinkSync)(e),r=Bn((0,ke.isAbsolute)(n)?n:(0,ke.join)((0,ke.dirname)(e),n));return(0,xe.existsSync)(r)?"wrong":"dangling"}catch{return"dangling"}}function Xr(e,t,n=[]){return[...new Set([...e,...t?.entries.map(o=>o.name)??[],...n])].sort()}function Zr(e,t){return Pl(e).filter(n=>n.isDirectory()||n.isSymbolicLink()).map(n=>n.name).filter(n=>t.has(n))}function oc(e,t,n,r,o,s=!0){let i=md(o),l=[];for(let c of t){let a=r.get(c),f=n.has(c),p=(0,ke.join)(e,c),g=a?Ft(p,a.linkTarget,void 0,a.dir):kd(p),u;s?g==="link-ok"?u=f?"link":"installed-unselected":g==="dangling"?u="dangling":g==="wrong"?u="wrong":g==="file"?u="conflict":g==="dir"?a&&(0,xe.existsSync)(a.dir)&&Ne(a.dir,p)?u=f?"copy":"installed-unselected":u=i.get(c)?.mode==="copy"?"copy-drift":"conflict":u=f?"missing":"not-selected":g==="absent"?u="not-selected":g==="wrong"||g==="file"?u=g==="wrong"?"wrong":"conflict":u="installed-unselected",u!=="not-selected"&&l.push({name:c,state:u,version:a?.version??"",source:a?.source??""})}return l}function ic(){let e=rt(),t=se(),{refs:n,sources:r}=sc(e),o=[...n.keys()].sort(),s=t.mode??"skills",i=t.selection,l=i!==void 0&&Object.keys(i).length>0,c=l?o.filter(h=>{let S=n.get(h),R=i[S.source];return R===void 0||R.includes(h)}):s==="package"?[]:o.filter(h=>n.get(h).tier==="core"),a=new Set(c),f=t.targets&&t.targets.length>0?t.targets:void 0,p=h=>!f||f.includes(h),g=We([]),u=new Map(g.filter(h=>h.name).map(h=>[P(h.dir),h.name])),m=new Map;for(let h of Object.values(e?.sources??{}))for(let S of h.targets)m.set(P(S.dir),S);let d=new Set(o),k=h=>l?a:new Set([...a,...h?.entries.map(S=>S.name)??[]]),y=[],x=[],$=new Set;for(let h of g){let S=m.get(P(h.dir));if(!h.available&&h.kind==="agent"){x.push({dir:h.dir,label:h.label});continue}if(h.kind!=="primary"&&!S&&(!h.dirExists||Wn(h.dir)))continue;$.add(P(h.dir));let R=k(S),N=h.name?p(h.name):!0,I=oc(h.dir,Xr(R,S,Zr(h.dir,d)),R,n,S,N);!N&&I.length===0||y.push({dir:h.dir,label:h.label,kind:h.kind,available:h.available,dirExists:h.dirExists,recorded:!!S,selected:N,items:I})}let b=[];for(let h of m.values()){if($.has(P(h.dir)))continue;let S=Ol(h.dir);S&&(0,xe.existsSync)(h.dir)&&b.push({dir:h.dir,label:S});let R=k(h),N=u.get(P(h.dir))??"",I=N?p(N):!0,v=oc(h.dir,Xr(R,h,Zr(h.dir,d)),R,n,h,I);!I&&v.length===0||y.push({dir:h.dir,label:S??(h.label||Pt(h.dir)||"\u81EA\u5B9A\u4E49 --dir"),kind:h.kind==="primary"||h.kind==="agent"?h.kind:"custom",available:!0,dirExists:(0,xe.existsSync)(h.dir),recorded:!0,selected:I,items:v})}let T=[...n.entries()].map(([h,S])=>({name:h,dir:S.dir,version:S.version,tier:S.tier,requires:[]}));return{source:ut(),skills:o,mode:s,selection:c,targetSelection:f??[],sources:r,skillVersions:Object.fromEntries([...n.entries()].map(([h,S])=>[h,S.version])),versionMismatches:ts(T),stateFile:ft(),stateExists:!!e,targets:y,pendingAgents:x,canonicalReaders:Ll(),legacyTargets:b}}function Sd(e,t,n){if(!(0,xe.existsSync)(e))return"missing";let r;try{r=E(e)}catch{return"conflict"}let o=Ht(r);return o===null?"conflict":o>zr()||r===Wr(t.name,n,Gr(t.dir))?"ready":"drift"}function lc(e=process.cwd()){let t=Nt(e),n=t.root,r=un(n),o=Fe(n),{refs:s,sources:i}=sc(r),l=[...s.keys()].sort(),c=o.mode??"skills",a=o.selection!==void 0?o.selection:void 0,f=a!==void 0?l.filter(v=>a.includes(v)):c==="package"?[]:l.filter(v=>s.get(v).tier==="core"),p=new Set(f),g=o.targets&&o.targets.length>0?o.targets:void 0,u=v=>!g||g.includes(v),m=Object.values(r?.sources??{}).flatMap(v=>v.targets),d=m.find(v=>v.kind==="source"&&v.dir===t.sourceDir),k=new Map(m.filter(v=>v.kind==="shell").map(v=>[v.dir,v])),y=new Set(d?.entries.map(v=>v.name)??[]),x=new Set(l),$=v=>a===void 0?new Set([...p,...v]):p,b=$(y),T=Xr(b,d,Zr((0,ke.join)(n,t.sourceDir),x)),h=[];for(let v of T){let j=s.get(v),z=(0,ke.join)(n,t.sourceDir,v),C;(0,xe.existsSync)(z)?j&&Ne(j.dir,z)?C=b.has(v)?"ready":"installed-unselected":C=y.has(v)?"drift":"conflict":C=b.has(v)?"missing":"not-selected",C!=="not-selected"&&h.push({name:v,state:C,version:j?.version??"",source:j?.source??""})}let S=[{dir:t.sourceDir,kind:"source",selected:!0,items:h}],R=(v,j)=>{let z=u(v),C=new Set(j?.entries.map(M=>M.name)??[]),A=$(C),D=[];for(let M of Xr(A,j,Zr((0,ke.join)(n,v),x))){let ee=s.get(M),U;if(!ee)U="conflict";else{let ie=(0,ke.join)(n,v,M,X);U=Sd(ie,{name:M,dir:ee.dir},t.sourceDir),U==="conflict"&&C.has(M)&&(U="drift"),z?(U==="ready"&&!A.has(M)&&(U="installed-unselected"),U==="missing"&&!A.has(M)&&(U="not-selected")):U==="missing"?U="not-selected":(U==="ready"||U==="drift")&&(U="installed-unselected")}U!=="not-selected"&&D.push({name:M,state:U,version:ee?.version??"",source:ee?.source??""})}return{dir:v,kind:"shell",selected:z,items:D}};for(let v of t.shellDirs)S.push(R(v,k.get(v)));let N=new Set(t.shellDirs);for(let[v,j]of k){if(N.has(v)||!(0,xe.existsSync)((0,ke.join)(n,v)))continue;let z=R(v,j);z.items.length>0&&S.push(z)}let I=[...s.entries()].map(([v,j])=>({name:v,dir:j.dir,version:j.version,tier:j.tier,requires:[]}));return{root:n,sourceDir:t.sourceDir,skills:l,mode:c,selection:f,targetSelection:g??[],sources:i,skillVersions:Object.fromEntries([...s.entries()].map(([v,j])=>[v,j.version])),versionMismatches:ts(I),stateFile:Mt(n,dt(n)),stateExists:!!r,dirs:S,missingDirs:t.missingDirs}}function us(e){return e.filter(t=>t.tier==="core").map(t=>t.name)}function yd(e){return e.filter(t=>t.tier!=="core").map(t=>t.name)}function bd(e,t,n="skills"){let r=new Set(t??[]);return e.map(o=>({name:o.name,tier:o.tier,selected:n==="skills"&&o.tier==="core"||r.has(o.name)}))}function cc(e,t){let n=new Set(t);return e.filter(r=>n.has(r.name)).map(r=>r.name)}function fs(e,t,n="skills"){let r=new Set(n==="skills"?[...us(e),...t]:t);return e.filter(o=>r.has(o.name)).map(o=>o.name)}function ac(e){let{skills:t,saved:n,explicit:r,all:o,noOptional:s,interactive:i,yes:l}=e,c=e.mode??"skills",a=t.map(d=>d.name);if(r!==void 0){let d=cc(t,r),k=r.filter(y=>!a.includes(y));return d.length===0?{names:[],invalid:k,savedInvalid:[],needsPrompt:!1,error:"\u5168\u90E8\u53D6\u503C\u975E\u6CD5"}:{names:fs(t,d,c),invalid:k,savedInvalid:[],needsPrompt:!1}}if(o)return{names:a,invalid:[],savedInvalid:[],needsPrompt:!1};if(s)return{names:us(t),invalid:[],savedInvalid:[],needsPrompt:!1};let f=n!==void 0,p=cc(t,n??[]),g=(n??[]).filter(d=>!a.includes(d)),u=c==="package"?f?p:[]:p.length>0?fs(t,p,c):us(t),m=i&&!l&&(c==="package"?t.length>0:yd(t).length>0);return{names:u,invalid:[],savedInvalid:g,needsPrompt:m}}function qn(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}function ds(e){return e instanceof Error?e.name==="ExitPromptError"||e.name==="AbortPromptError"||/force closed|cancel/i.test(e.message):!1}function uc(e,t,n=[]){let r=t?new Set(t):void 0,o=[],s=e.find(l=>l.kind==="primary");s&&o.push({value:s.name,label:`\u5171\u8BFB\uFF5C${s.label}`,checked:r?r.has(s.name):!0});for(let l of e.filter(c=>c.kind==="agent"))!l.available&&!r?.has(l.name)||o.push({value:l.name,label:`agent\uFF5C${l.label}${l.available?"":"\uFF08\u672A\u68C0\u6D4B\u5230\uFF09"}`,checked:l.available?r?r.has(l.name):!0:!1,disabled:l.available?!1:"\u672C\u673A\u672A\u68C0\u6D4B\u5230\u8BE5 agent\uFF0C\u4E0D\u51ED\u7A7A\u521B\u5EFA\u76EE\u5F55"});let i=new Set(n);for(let l of e.filter(c=>c.kind==="custom"&&i.has(c.dir)))o.push({value:l.dir,label:`\u81EA\u5B9A\u4E49\uFF5C${l.dir}\uFF08\u4E00\u6B21\u6027 --dir\uFF09`,checked:!0,disabled:"\u4E00\u6B21\u6027 --dir\uFF0C\u672C\u6B21\u56FA\u5B9A\u5199\u5165\u3001\u4E0D\u4FDD\u5B58\u4E3A\u957F\u671F\u9009\u62E9"});return o}function fc(e,t,n=[],r=[]){let o=t?new Set(t):void 0,s=e.map(i=>({value:i,label:`\u9879\u76EE\u76EE\u5F55\uFF5C${i}`,checked:o?o.has(i):!0}));for(let i of r)o?.has(i)&&s.push({value:i,label:`\u9879\u76EE\u76EE\u5F55\uFF5C${i}\uFF08\u4E0D\u5B58\u5728\uFF09`,checked:!1,disabled:"\u76EE\u5F55\u4E0D\u5B58\u5728\uFF0C\u8865\u9F50\u540E\u91CD\u8DD1\u5373\u53EF"});for(let i of n)e.includes(i)||s.push({value:i,label:`\u81EA\u5B9A\u4E49\uFF5C${i}\uFF08\u4E00\u6B21\u6027 --dir\uFF09`,checked:!0,disabled:"\u4E00\u6B21\u6027 --dir\uFF0C\u672C\u6B21\u56FA\u5B9A\u5199\u5165\u3001\u4E0D\u4FDD\u5B58\u4E3A\u957F\u671F\u9009\u62E9"});return s}async function gs(e,t){if(e.length===0)return[];let{checkbox:n}=await import("@inquirer/prompts");try{return await n({message:t,choices:e.map(r=>({value:r.value,name:r.label,checked:r.checked,disabled:r.disabled??!1})),pageSize:15,required:!1})}catch(r){if(ds(r))return null;throw r}}async function dc(e){let{confirm:t}=await import("@inquirer/prompts");try{return await t({message:e,default:!0})}catch(n){if(ds(n))return null;throw n}}async function gc(e,t,n="skills"){let{checkbox:r}=await import("@inquirer/prompts"),o=bd(e,t,n).map(s=>({value:s.name,name:n==="skills"&&s.tier==="core"?`${s.name}\uFF08core\uFF09`:s.name,checked:s.selected,disabled:n==="skills"&&s.tier==="core"?"core\uFF08\u5FC5\u88C5\uFF09":!1}));try{let s=await r({message:n==="package"?"\u9009\u62E9\u8981\u5B89\u88C5\u7684\u6280\u80FD\uFF08\u7A7A\u683C\u5207\u6362\uFF0C\u56DE\u8F66\u786E\u8BA4\uFF1B\u5168\u4E0D\u9009\u5373\u7EAF\u5305\u7BA1\u7406\u5668\u6A21\u5F0F\uFF09":"\u9009\u62E9\u8981\u5B89\u88C5\u7684\u6280\u80FD\uFF08\u7A7A\u683C\u5207\u6362\uFF0C\u56DE\u8F66\u786E\u8BA4\uFF1Bcore \u5FC5\u88C5\uFF09",choices:o,pageSize:12,required:!1});return n==="package"?s:fs(e,s)}catch(s){if(ds(s))return null;throw s}}var vd="2.1",pc=`/* fxri-docs-theme: ${vd} */`,$d=/^\/\* fxri-docs-theme: (?:v\d+|\d+\.\d+) \*\/$/,mc="/* fxri-docs-theme:brand-start */",hc="/* fxri-docs-theme:brand-end */",ps={"--site-accent":"--fx-accent","--site-glow":"--fx-accent-soft","--site-shadow":"--fx-shadow","--site-hero-angle":"--fx-hero-angle"};function kc(e){return new RegExp(`${e.replace(/[-]/g,"\\-")}(?=\\s*:)`,"g")}function xd(e){let t=e;for(let[n,r]of Object.entries(ps))t=t.replace(kc(n),r);return t}function ms(e){return e.replace(/^\uFEFF/,"").replace(/\r\n/g,`
|
|
119
119
|
`)}function Sc(){return(0,Ie.join)(tt(),"templates","docs-theme")}function Qr(e){let t=ms(e).split(`
|
|
120
120
|
`);if(!$d.test(t[0]??""))return null;let n=t.indexOf(mc),r=t.indexOf(hc);return n===-1||r===-1||r<n?null:{header:t[0],brand:t.slice(n+1,r).join(`
|
|
121
121
|
`).trim(),common:t.slice(r+1).join(`
|
package/dist/cli.js
CHANGED
|
@@ -115,7 +115,7 @@ ${o}`}function Io(e){let t=nl(w(e.source),e);return(yr(e.target)?w(e.target).rep
|
|
|
115
115
|
`)}function Vl(){let e=Ye();return e?Object.values(e.sources).some(t=>t.targets.some(n=>n.entries.length>0)):!1}function Wt(e){let t=tt(e),n=Hl(t);if(!n)return null;if(Bl(n))return{...Ul(),updatedAt:typeof n.updatedAt=="string"?n.updatedAt:"",sources:Yl(n.sources)};if(!Array.isArray(n.shells)&&typeof n.source!="string")return null;try{let r=tg(n);return Kl(t),Wl(t,r),r}catch{return null}}function Wl(e,t){Nl(Ml(e),{recursive:!0}),O(e,`${JSON.stringify(t,null,2)}
|
|
116
116
|
`)}function Dl(e){return JSON.stringify(e.sources)}function Go(e,t){let n=Wt(e),r={format:Oe,schemaVersion:_e,updatedAt:new Date().toISOString(),sources:t};return n&&Dl(n)===Dl(r)?!1:(Wl(tt(e),r),!0)}function Ko(e){Qd(tt(e),{force:!0})}import{existsSync as le,lstatSync as dg,mkdirSync as rc,readdirSync as Ql,rmSync as Fr,symlinkSync as gg}from"fs";import{dirname as oc,join as q,resolve as ec}from"path";import{existsSync as ng,mkdirSync as rg,readFileSync as og,rmSync as zl,writeFileSync as sg}from"fs";import{hostname as Jl}from"os";import{dirname as ig,join as ql}from"path";var lg=".toolkit-skills.lock",cg="skills.lock",ag=300*1e3;function Yo(e){return ql(e,".agents",lg)}function Xl(e){return ql(e,".toolkit",cg)}function Zl(e){if(!ng(e))return null;try{let t=JSON.parse(og(e,"utf8"));return typeof t.pid!="number"||typeof t.host!="string"||typeof t.startedAt!="string"?null:{pid:t.pid,host:t.host,startedAt:t.startedAt}}catch{return null}}function ug(e){let t=Date.parse(e.startedAt);if(!Number.isFinite(t)||Date.now()-t>ag)return!0;if(e.host===Jl())try{return process.kill(e.pid,0),!1}catch{return!0}return!1}function fg(e,t){let n=Zl(e);n&&n.pid===t.pid&&n.host===t.host&&n.startedAt===t.startedAt&&zl(e,{force:!0})}function Dr(e){rg(ig(e),{recursive:!0});let t={pid:process.pid,host:Jl(),startedAt:new Date().toISOString()};for(let n=0;n<2;n+=1)try{return sg(e,`${JSON.stringify(t,null,2)}
|
|
117
117
|
`,{flag:"wx"}),()=>fg(e,t)}catch(r){if(r.code!=="EEXIST")throw r;let o=Zl(e);if(o&&!ug(o))throw new Error(`\u6280\u80FD\u64CD\u4F5C\u9501\u88AB\u5360\u7528\uFF1A${o.host} pid ${o.pid}\uFF08\u59CB\u4E8E ${o.startedAt}\uFF09\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5`,{cause:r});zl(e,{force:!0})}throw new Error(`\u65E0\u6CD5\u83B7\u53D6\u6280\u80FD\u64CD\u4F5C\u9501\uFF1A${e}`)}function sc(e,t){if(!t)return e;let n=t.filter(i=>!e.some(l=>l.name===i));n.length>0&&console.warn(`\u26A0\uFE0F \u5FFD\u7565\u4E0D\u5B58\u5728\u7684\u6280\u80FD\uFF1A${n.join("\u3001")}`);let r=t.filter(i=>e.some(l=>l.name===i)),o=Ar(e,r);o.missing.length>0&&console.warn(`\u26A0\uFE0F \u5FFD\u7565\u7F3A\u5931\u7684\u4F9D\u8D56\u6280\u80FD\uFF1A${o.missing.join("\u3001")}`);let s=new Set(o.names);return e.filter(i=>s.has(i.name))}function Wo(e={}){let t=[In()],n=ee();for(let[r,o]of Object.entries(n.sources??{})){let s=o.url??o.root;if(s)try{let i=Cn(s,{name:r,temporary:!1}),l=t.find(c=>c.name===i.name);if(l){if(N(l.root)!==N(i.root))throw new Error(`\u6765\u6E90\u540D\u51B2\u7A81\uFF1A${r}\uFF08${l.root} / ${i.root}\uFF09`);continue}t.push(i)}catch(i){console.warn(`\u26A0\uFE0F \u8DF3\u8FC7\u5931\u6548\u7684\u5916\u90E8\u6765\u6E90 ${r}\uFF1A${i.message}`)}}for(let r of e.externalSources??[]){let o=Cn(r.path,{name:r.name,temporary:r.temporary,dryRun:e.dryRun}),s=t.find(i=>i.name===o.name);if(s&&N(s.root)!==N(o.root))throw new Error(`\u6765\u6E90\u540D\u51B2\u7A81\uFF1A${o.name}\uFF08${s.root} / ${o.root}\uFF09`);s||t.push(o)}return t}function ic(e={}){let t=Wo(e).flatMap(ht);return Ir(t),t}function tc(e){let t=new Map;for(let n of e)for(let r of ht(n))t.set(r.name,{dir:r.dir,linkTarget:r.linkTarget});return t}function Vo(e,t,n,r){if(!e)return[];let o=[];for(let s of e.entries){if(t.has(s.name))continue;let i=r.get(s.name);if(!i)continue;let l=q(n,s.name),c=kt(l,i.linkTarget,void 0,i.dir);if(c==="link-ok"||c==="dir"&&le(i.dir)&&Ce(i.dir,l))try{Me(l),o.push(s.name)}catch{}}return o}function lc(e={}){let t=Wo({externalSources:e.externalSources,dryRun:e.dryRun}),n=t.flatMap(ht);Ir(n);let r=sc(n,e.skills),o=new Set(r.map(u=>u.name)),s=new Map(n.map(u=>[u.name,{dir:u.dir,linkTarget:u.linkTarget}])),i=ee().targets,l=e.targets??(i&&i.length>0?i:void 0),c=wl(l,e.dirs??[]),a=Ne(),f=[];for(let u of c.invalid)console.warn(`\u26A0\uFE0F \u5FFD\u7565\u672A\u77E5\u7684 agent / \u76EE\u6807\u540D\uFF1A${u}`);for(let u of c.unavailable){console.warn(`\u26A0\uFE0F \u5FFD\u7565\u672C\u673A\u672A\u68C0\u6D4B\u5230\u7684 agent\uFF1A${u}\uFF08\u4E0D\u51ED\u7A7A\u521B\u5EFA\u76EE\u5F55\uFF09`);let m=a.find(d=>d.name===u);m&&f.push({dir:m.dir,label:m.label})}if(l===void 0)for(let u of a)u.kind==="agent"&&!u.available&&f.push({dir:u.dir,label:u.label});let p=c.targets,g=e.dryRun?null:Dr(Yo(V()));try{let u=Ye(),m=new Map;for(let[$,b]of Object.entries(u?.sources??{})){let E=new Map;for(let h of b.targets)E.set(N(h.dir),h);m.set($,E)}let d=new Map;for(let $ of t)d.set($.name,[]);let k=new Set,y=[];for(let $ of p){let b=N($.dir);k.add(b);let E={dir:$.dir,label:$.label,kind:$.kind,created:[],updated:[],skipped:[],conflicts:[],failed:[],degraded:[],links:[],copies:[],pruned:[]},h=new Map;for(let S of r){let R=q($.dir,S.name),F=kt(R,S.linkTarget),C=m.get(S.source)?.get(b)?.entries.some(A=>A.name===S.name&&A.mode==="copy")??!1;if(F==="link-ok"){E.skipped.push(S.name),E.links.push(S.name),h.set(S.source,[...h.get(S.source)??[],{name:S.name,version:S.version,mode:"link"}]);continue}if(F==="dir"&&!e.force){if(!C){E.conflicts.push(S.name);continue}if(Ce(S.dir,R)){E.skipped.push(S.name),E.copies.push(S.name),h.set(S.source,[...h.get(S.source)??[],{name:S.name,version:S.version,mode:"copy"}]);continue}}if(F==="file"&&!e.force){E.conflicts.push(S.name);continue}let v=!!e.copy||S.temporary||F==="dir"&&C;if(e.dryRun){F==="absent"?E.created.push(S.name):E.updated.push(S.name),v?E.copies.push(S.name):E.links.push(S.name);continue}try{F!=="absent"&&Me(R);let A=Ll(S.linkTarget,S.dir,R,v);F==="absent"?E.created.push(S.name):E.updated.push(S.name),A.mode==="link"?E.links.push(S.name):(E.copies.push(S.name),A.reason&&E.degraded.push({name:S.name,reason:A.reason})),h.set(S.source,[...h.get(S.source)??[],{name:S.name,version:S.version,mode:A.mode}])}catch(A){E.failed.push({name:S.name,reason:A.message})}}if(e.prune&&!e.dryRun)for(let S of t)E.pruned.push(...Vo(m.get(S.name)?.get(b),o,$.dir,s));if(y.push(E),!e.dryRun){let S=new Set(E.pruned);for(let R of t){let F=m.get(R.name)?.get(b),C=[...h.get(R.name)??[],...F?.entries.filter(v=>!o.has(v.name)&&!S.has(v.name)&&le(q($.dir,v.name)))??[]];C.length>0&&d.get(R.name).push({id:F?.id??Lr($.dir,$.kind),dir:$.dir,label:$.label,kind:$.kind,entries:C})}}}let x=!!e.prune&&l!==void 0;for(let $ of t)for(let b of u?.sources?.[$.name]?.targets??[]){if(k.has(N(b.dir)))continue;let E=b.entries;if(x){let h=Vo(b,new Set,b.dir,s);if(h.length>0){y.push({dir:b.dir,label:b.label||yt(b.dir)||b.dir,kind:b.kind==="primary"||b.kind==="agent"?b.kind:"custom",created:[],updated:[],skipped:[],conflicts:[],failed:[],degraded:[],links:[],copies:[],pruned:h});let S=new Set(h);E=E.filter(R=>!S.has(R.name))}}E.length>0&&d.get($.name).push({...b,entries:E})}if(!e.dryRun){let $={};for(let[b,E]of Object.entries(u?.sources??{}))!t.some(h=>h.name===b)&&E.targets.length>0&&($[b]=E);for(let b of t){let E=d.get(b.name)??[];E.length>0&&($[b.name]={kind:b.kind,version:b.version,temporary:b.temporary,root:b.root,url:b.url,ref:b.ref,targets:E})}if(hg($),e.saveSelection!==!1&&pg(t,r),e.saveTargets!==!1){let b=new Set(a.filter(h=>h.name).map(h=>h.name)),E=l?l.filter(h=>b.has(h)):p.filter(h=>h.name).map(h=>h.name);mg([...new Set(E)])}}return{source:Qe(),skills:r.map($=>$.name),selection:r.map($=>$.name),mode:e.mode??ee().mode??"skills",targetSelection:p.filter($=>$.name).map($=>$.name),targets:y,skippedTargets:f,stateFile:et()}}finally{g?.()}}function pg(e,t){try{let r={...ee().selection??{}};for(let o of e){if(o.temporary){delete r[o.name];continue}r[o.name]=t.filter(s=>s.source===o.name).map(s=>s.name)}De({selection:Object.keys(r).length>0?r:void 0})}catch(n){console.warn(`\u26A0\uFE0F \u6280\u80FD\u9009\u62E9\u4FDD\u5B58\u5931\u8D25\uFF1A${n.message}`)}}function mg(e){try{De({targets:e})}catch(t){console.warn(`\u26A0\uFE0F \u76EE\u6807\u9009\u62E9\u4FDD\u5B58\u5931\u8D25\uFF1A${t.message}`)}}function hg(e){let t=Object.fromEntries(Object.entries(e).filter(([,r])=>r.targets.length>0)),n=et();if(Object.keys(t).length===0){Fr(n,{force:!0});return}rc(oc(n),{recursive:!0}),O(n,`${JSON.stringify({format:Oe,schemaVersion:_e,updatedAt:new Date().toISOString(),sources:t},null,2)}
|
|
118
|
-
`)}function kg(e,t){let n=ee();if(!n.selection)return;let r={...n.selection};if(!e&&!t){De({selection:void 0});return}let o=new Set(e??[]);for(let s of Object.keys(r)){if(t&&s!==t)continue;let i=e?(r[s]??[]).filter(l=>!o.has(l)):[];i.length>0?r[s]=i:delete r[s]}De({selection:Object.keys(r).length>0?r:void 0})}function Sg(e){let t=ee(),n={...t.sources??{}};delete n[e];let r={...t.selection??{}};delete r[e],De({sources:Object.keys(n).length>0?n:void 0,selection:Object.keys(r).length>0?r:void 0})}function yg(e,t){if(e===Ee||t.kind==="builtin")return tc([In()]);if(!t.root||!le(t.root))return new Map;try{return tc([mt(t.root,{name:e,temporary:t.temporary})])}catch{return new Map}}function zo(e={}){let t=et();e.dryRun||(kg(e.skills,e.source),e.source&&Sg(e.source));let n=e.dryRun?null:Dr(Yo(V()));try{let r=Ye();if(!r)return{stateFile:t,stateExists:!1,targets:[],stateRemoved:!1};let o=e.skills?new Set(e.skills):null,s=[],i=!1,l=!1,c={};for(let[p,g]of Object.entries(r.sources)){if(e.source&&e.source!==p){c[p]=g;continue}let u=yg(p,g),m=[];for(let d of g.targets){let k={dir:d.dir,label:d.label||yt(d.dir)||null,removed:[],missing:[],skippedForeign:[],dirReclaimed:!1},y=[];for(let x of d.entries){if(o&&!o.has(x.name)){y.push(x);continue}let $=q(d.dir,x.name),b=u.get(x.name);if(!b){let h=!1;try{h=dg($).isSymbolicLink()&&!le($)}catch{h=!1}if(h&&!e.dryRun){Me($),k.removed.push(x.name),l=!0;continue}if(h){k.removed.push(x.name);continue}k.skippedForeign.push(x.name),y.push(x);continue}let E=kt($,b.linkTarget,void 0,b.dir);if(E==="absent"){k.missing.push(x.name),l=!0;continue}if(E==="wrong"||E==="file"||E==="dir"&&!Ce(b.dir,$)){k.skippedForeign.push(x.name),y.push(x);continue}if(e.dryRun){k.removed.push(x.name);continue}try{Me($),k.removed.push(x.name),l=!0}catch{i=!0,k.skippedForeign.push(x.name),y.push(x)}}if(!e.dryRun&&An(d.dir))try{Fr(d.dir,{recursive:!0,force:!0}),k.dirReclaimed=!0}catch{}s.push(k),y.length>0&&m.push({...d,entries:y})}m.length>0&&(c[p]={...g,targets:m})}let a=s.every(p=>p.skippedForeign.length===0),f=!e.dryRun&&!i&&a&&Object.keys(c).length===0;return e.dryRun||(f?Fr(t,{force:!0}):(l||Object.keys(c).length!==Object.keys(r.sources).length)&&_r({format:Oe,schemaVersion:_e,updatedAt:new Date().toISOString(),sources:c})),{stateFile:t,stateExists:!0,targets:s,stateRemoved:f}}finally{n?.()}}function nc(e,t,n){t==="created"?e.created.push(n):t==="updated"?e.updated.push(n):t==="skipped"?e.skipped.push(n):e.conflicts.push(n)}function bg(e,t,n,r,o){return le(t)?Ce(e,t)?"skipped":!n&&!r?"conflict":(o||(Me(t),En(e,t)),"updated"):(o||En(e,t),"created")}function vg(e,t,n,r){let o=le(e),s=o?w(e):"",i=o?vt(s):null,l;return o?i!==null&&i>Or()||s===t?l="skipped":i===null&&!n?l="conflict":l="updated":l="created",!r&&(l==="created"||l==="updated")&&(rc(oc(e),{recursive:!0}),O(e,t)),l}function cc(e={}){let t=e.cwd??process.cwd(),n=Wo({externalSources:e.externalSources,dryRun:e.dryRun}),r=n.flatMap(ht);Ir(r);let o=sc(r,e.skills),s=new Set(o.map(x=>x.name)),i=new Map(r.map(x=>[x.name,{dir:x.dir,linkTarget:x.linkTarget}])),l=St(t),c=l.root,a=Wt(c),f=(x,$,b)=>a?.sources?.[x]?.targets.find(E=>E.kind===$&&E.dir===b),p=[],g=[];for(let x of e.dirs??[]){let $=ec(t,x);if(!Ln($,c)){p.push(x);continue}let b=bt(c,$);b!==l.sourceDir&&!g.includes(b)&&g.push(b)}let u=Te(c).targets,m=e.targetDirs??(u&&u.length>0?u:void 0),d;if(m===void 0)d=[...l.shellDirs];else{d=[];for(let x of m){let $=ec(c,x);if(!Ln($,c)){console.warn(`\u26A0\uFE0F \u5FFD\u7565\u4ED3\u5E93\u4E4B\u5916\u7684\u6280\u80FD\u76EE\u5F55\uFF1A${x}`);continue}let b=bt(c,$);if(b!==l.sourceDir){if(!le($)){console.warn(`\u26A0\uFE0F \u5FFD\u7565\u4E0D\u5B58\u5728\u7684\u6280\u80FD\u76EE\u5F55\uFF1A${b}\uFF08\u8865\u9F50\u76EE\u5F55\u540E\u91CD\u8DD1\u5373\u53EF\uFF09`);continue}d.includes(b)||d.push(b)}}}let k=[...d.filter(x=>!g.includes(x)),...g],y=e.dryRun?null:Dr(Xl(c));try{let x={dir:l.sourceDir,created:[],updated:[],skipped:[],conflicts:[],failed:[],pruned:[]},$=q(c,l.sourceDir),b=new Map;for(let C of o){let v=f(C.source,"source",l.sourceDir)?.entries.some(A=>A.name===C.name)??!1;try{let A=bg(C.dir,q($,C.name),v,!!e.force,!!e.dryRun);nc(x,A,C.name),A!=="conflict"&&!e.dryRun&&b.set(C.source,[...b.get(C.source)??[],{name:C.name,version:C.version,mode:"copy"}])}catch(A){x.failed.push({name:C.name,reason:A.message})}}if(e.prune&&!e.dryRun)for(let C of n)x.pruned.push(...Vo(f(C.name,"source",l.sourceDir),s,$,i));let E=new Set(x.pruned),h=[],S=new Map;for(let C of n)S.set(C.name,[]);for(let C of n){let v=f(C.name,"source",l.sourceDir),A=[...b.get(C.name)??[],...v?.entries.filter(Y=>!s.has(Y.name)&&!E.has(Y.name)&&le(q($,Y.name)))??[]];A.length>0&&S.get(C.name).push({id:"source",dir:l.sourceDir,label:"\u771F\u6E90\u526F\u672C",kind:"source",entries:A})}for(let C of k){let v={dir:C,created:[],updated:[],skipped:[],conflicts:[],failed:[],pruned:[]},A=new Map;for(let T of o){let I=jr(T.name,l.sourceDir,Cr(T.dir));try{let _=vg(q(c,C,T.name,W),I,!!e.force,!!e.dryRun);nc(v,_,T.name),_!=="conflict"&&!e.dryRun&&A.set(T.source,[...A.get(T.source)??[],{name:T.name,version:T.version,mode:"shell"}])}catch(_){v.failed.push({name:T.name,reason:_.message})}}if(e.prune&&!e.dryRun)for(let T of n)for(let I of f(T.name,"shell",C)?.entries??[]){if(s.has(I.name))continue;let _=q(c,C,I.name,W);if(!le(_))continue;let P=w(_);vt(P)!==null&&(Me(q(c,C,I.name)),v.pruned.push(I.name))}let Y=new Set(v.pruned);for(let T of n){let I=f(T.name,"shell",C),_=[...A.get(T.name)??[],...I?.entries.filter(P=>!s.has(P.name)&&!Y.has(P.name)&&le(q(c,C,P.name)))??[]];_.length>0&&S.get(T.name).push({id:C,dir:C,label:"\u8584\u58F3",kind:"shell",entries:_})}h.push(v)}let R=new Set(k),F=!!e.prune&&m!==void 0;for(let C of n)for(let v of a?.sources?.[C.name]?.targets.filter(A=>A.kind==="shell")??[]){if(R.has(v.dir))continue;let A=v.entries;if(F){let Y={dir:v.dir,created:[],updated:[],skipped:[],conflicts:[],failed:[],pruned:[]},T=[];for(let I of A){let _=q(c,v.dir,I.name),P=q(_,W);if(!le(P))continue;let X;try{X=w(P)}catch{T.push(I);continue}if(vt(X)===null){T.push(I);continue}try{Me(_),Y.pruned.push(I.name)}catch{T.push(I)}}A=T,Y.pruned.length>0&&h.push(Y)}A.length>0&&S.get(C.name).push({...v,entries:A})}if(!e.dryRun){let C={};for(let[v,A]of Object.entries(a?.sources??{}))!n.some(Y=>Y.name===v)&&A.targets.length>0&&(C[v]=A);for(let v of n){let A=S.get(v.name)??[];A.length>0&&(C[v.name]={kind:v.kind,version:v.version,temporary:v.temporary,root:v.url?"":v.root,url:v.url,ref:v.ref,targets:A})}Rg(c,C),e.saveSelection!==!1&&$g(c,o.filter(v=>!v.temporary).map(v=>v.name)),e.saveTargets!==!1&&xg(c,d)}return{root:c,skills:o.map(C=>C.name),selection:o.map(C=>C.name),mode:e.mode??Te(c).mode??"skills",targetSelection:k,source:x,shells:h,missingDirs:l.missingDirs,ignoredDirs:p,stateFile:bt(c,tt(c))}}finally{y?.()}}function $g(e,t){try{let n=Te(e);pt({targets:n.targets,selection:t},e)}catch(n){console.warn(`\u26A0\uFE0F \u9879\u76EE\u9762\u6280\u80FD\u9009\u62E9\u4FDD\u5B58\u5931\u8D25\uFF1A${n.message}`)}}function xg(e,t){try{pt({targets:[...new Set(t)]},e)}catch(n){console.warn(`\u26A0\uFE0F \u9879\u76EE\u9762\u76EE\u5F55\u9009\u62E9\u4FDD\u5B58\u5931\u8D25\uFF1A${n.message}`)}}function Rg(e,t){let n=Object.fromEntries(Object.entries(t).filter(([,r])=>r.targets.length>0));if(Object.keys(n).length===0){Ko(e);return}Go(e,n)}function wg(e,t){let n=Te(e);if(!n.selection)return;if(!t){pt({selection:void 0},e);return}let r=new Set(t),o=n.selection.filter(s=>!r.has(s));pt({selection:o.length>0?o:void 0},e)}function ac(e={}){let t=e.cwd??process.cwd(),n=St(t),r=n.root,o=tt(r),s=bt(r,o);e.dryRun||wg(r,e.skills);let i=Wt(r);if(!i)return{root:r,stateFile:s,stateExists:!1,sourceDir:n.sourceDir,dirs:[],reclaimed:[],stateRemoved:!1};let l=e.skills?new Set(e.skills):null,c=new Map(Ke().map(k=>[k.name,k.dir])),a=[],f=[],p={},g=!1,u=!1;for(let[k,y]of Object.entries(i.sources)){let x=[];for(let $ of y.targets){if($.kind!=="source"&&$.kind!=="shell")continue;let b={dir:$.dir,kind:$.kind,removed:[],missing:[],skippedForeign:[]},E=[];for(let h of $.entries){if(l&&!l.has(h.name)){E.push(h);continue}let S=q(r,$.dir,h.name);if(!($.kind==="source"?le(S):le(q(S,W)))){b.missing.push(h.name),u=!0;continue}if(!($.kind==="source"?Eg(S,c.get(h.name)):Tg(S))){b.skippedForeign.push(h.name),E.push(h);continue}if(e.dryRun){b.removed.push(h.name);continue}try{Me(S),b.removed.push(h.name),u=!0}catch{g=!0,b.skippedForeign.push(h.name),E.push(h)}}a.push(b),E.length>0&&x.push({...$,entries:E})}x.length>0&&(p[k]={...y,targets:x})}if(!e.dryRun)for(let k of[n.sourceDir,...i.sources[Ee]?.targets.filter(y=>y.kind==="shell").map(y=>y.dir)??[]]){let y=q(r,k);if(!(!le(y)||!An(y)))try{Fr(y,{recursive:!0,force:!0}),f.push(k)}catch{}}let m=a.every(k=>k.skippedForeign.length===0),d=!e.dryRun&&!g&&m&&Object.keys(p).length===0;return e.dryRun||(d?Ko(r):(u||Object.keys(p).length!==Object.keys(i.sources).length)&&Go(r,p)),{root:r,stateFile:s,stateExists:!0,sourceDir:n.sourceDir,dirs:a,reclaimed:f,stateRemoved:d}}function Eg(e,t){return!!t&&Ce(t,e)}function Tg(e){try{return vt(w(q(e,W)))!==null}catch{return!1}}function uc(){let e=ae("skills");if(e?.autoLink===!1||process.env.CI)return 0;let t=Ye();if(!t)return 0;let n=Qe(),r;try{r=new Set(Ql(n).filter(a=>le(q(n,a))))}catch{return 0}let o=Ho(),s=e?.autoLinkReplaceForeign!==!1,i=process.platform==="win32"?"junction":"dir",l=0,c={};for(let[a,f]of Object.entries(t.sources)){let p=[];for(let g of f.targets){let u;try{u=Ql(g.dir,{withFileTypes:!0})}catch{p.push(g);continue}let m=new Map(u.map(k=>[k.name,k])),d=g.entries.filter(k=>{if(k.mode!=="link")return r.has(k.name);if(!r.has(k.name))return!1;let y=q(o,k.name),x=q(g.dir,k.name),$=m.get(k.name),b=$?kt(x,y,$):"absent";if(b==="link-ok"||!s&&(b==="dir"||b==="file"))return!0;try{return b!=="absent"&&Me(x),gg(y,x,i),l+=1,!0}catch{return!0}});p.push({...g,entries:d})}c[a]={...f,targets:p}}return l>0&&_r({format:Oe,schemaVersion:_e,updatedAt:new Date().toISOString(),sources:c}),l}import{existsSync as nt,lstatSync as Cg,readlinkSync as Ig}from"fs";import{dirname as Ag,isAbsolute as Lg,join as Ve}from"path";function jg(e){return new Map((e?.entries??[]).map(t=>[t.name,t]))}function Og(e){let t=new Map;for(let n of Object.values(e?.sources??{}))for(let r of n.targets)for(let o of r.entries)t.set(o.name,o.version);return t}function dc(e){let t=new Map,n=[],r=Og(e),o=(l,c,a,f,p,g)=>{if(!n.some(u=>u.name===l)){n.push({name:l,kind:c,root:a,version:f,temporary:p,skills:g.map(u=>u.name)});for(let u of g)t.has(u.name)||t.set(u.name,{source:l,version:u.version,dir:u.dir,linkTarget:c==="builtin"?Ve(a,"skills",u.name):u.dir,tier:u.tier})}},s=In();o(s.name,"builtin",s.root,s.version,!1,s.skills);for(let l of ht(s))t.set(l.name,{source:l.source,version:l.version,dir:l.dir,linkTarget:l.linkTarget,tier:l.tier});let i=ee();for(let[l,c]of Object.entries(i.sources??{}))if(!n.some(a=>a.name===l))try{let a=c.url?e?.sources[l]?.root:c.root;if(!a)continue;let f=mt(a,{name:l,temporary:!1});o(f.name,"local",f.root,f.version,!1,f.skills)}catch{}for(let[l,c]of Object.entries(e?.sources??{})){if(n.some(g=>g.name===l))continue;let a=[];if(c.root&&nt(c.root))try{a=mt(c.root,{name:l,temporary:c.temporary}).skills}catch{a=[]}let f=new Set(a.map(g=>g.name));for(let g of c.targets)for(let u of g.entries)f.add(u.name);let p=[...f].map(g=>{let u=a.find(d=>d.name===g);if(u)return u;let m=c.root?Ve(c.root,g):g;return{name:g,dir:m,version:r.get(g)??"",tier:"optional",requires:[]}});if(o(l,c.kind==="builtin"?"builtin":"local",c.root,c.version,c.temporary,p),p.length>0&&c.kind!=="builtin")for(let g of p){let u=t.get(g.name);u&&t.set(g.name,{...u,linkTarget:g.dir})}}return{refs:t,sources:n}}function _g(e){let t;try{t=Cg(e)}catch{return"absent"}if(!t.isSymbolicLink())return t.isDirectory()?"dir":"file";try{let n=Ig(e),r=Rn(Lg(n)?n:Ve(Ag(e),n));return nt(r)?"wrong":"dangling"}catch{return"dangling"}}function Nr(e,t,n=[]){return[...new Set([...e,...t?.entries.map(o=>o.name)??[],...n])].sort()}function Mr(e,t){return _l(e).filter(n=>n.isDirectory()||n.isSymbolicLink()).map(n=>n.name).filter(n=>t.has(n))}function fc(e,t,n,r,o,s=!0){let i=jg(o),l=[];for(let c of t){let a=r.get(c),f=n.has(c),p=Ve(e,c),g=a?kt(p,a.linkTarget,void 0,a.dir):_g(p),u;s?g==="link-ok"?u=f?"link":"installed-unselected":g==="dangling"?u="dangling":g==="wrong"?u="wrong":g==="file"?u="conflict":g==="dir"?a&&nt(a.dir)&&Ce(a.dir,p)?u=f?"copy":"installed-unselected":u=i.get(c)?.mode==="copy"?"copy-drift":"conflict":u=f?"missing":"not-selected":g==="absent"?u="not-selected":g==="wrong"||g==="file"?u=g==="wrong"?"wrong":"conflict":u="installed-unselected",u!=="not-selected"&&l.push({name:c,state:u,version:a?.version??"",source:a?.source??""})}return l}function gc(){let e=Ye(),t=ee(),{refs:n,sources:r}=dc(e),o=[...n.keys()].sort(),s=t.mode??"skills",i=t.selection,l=i!==void 0&&Object.keys(i).length>0,c=l?o.filter(h=>{let S=n.get(h),R=i[S.source];return R===void 0||R.includes(h)}):s==="package"?[]:o.filter(h=>n.get(h).tier==="core"),a=new Set(c),f=t.targets&&t.targets.length>0?t.targets:void 0,p=h=>!f||f.includes(h),g=Ne([]),u=new Map(g.filter(h=>h.name).map(h=>[N(h.dir),h.name])),m=new Map;for(let h of Object.values(e?.sources??{}))for(let S of h.targets)m.set(N(S.dir),S);let d=new Set(o),k=h=>l?a:new Set([...a,...h?.entries.map(S=>S.name)??[]]),y=[],x=[],$=new Set;for(let h of g){let S=m.get(N(h.dir));if(!h.available&&h.kind==="agent"){x.push({dir:h.dir,label:h.label});continue}if(h.kind!=="primary"&&!S&&(!h.dirExists||An(h.dir)))continue;$.add(N(h.dir));let R=k(S),F=h.name?p(h.name):!0,C=fc(h.dir,Nr(R,S,Mr(h.dir,d)),R,n,S,F);!F&&C.length===0||y.push({dir:h.dir,label:h.label,kind:h.kind,available:h.available,dirExists:h.dirExists,recorded:!!S,selected:F,items:C})}let b=[];for(let h of m.values()){if($.has(N(h.dir)))continue;let S=Il(h.dir);S&&nt(h.dir)&&b.push({dir:h.dir,label:S});let R=k(h),F=u.get(N(h.dir))??"",C=F?p(F):!0,v=fc(h.dir,Nr(R,h,Mr(h.dir,d)),R,n,h,C);!C&&v.length===0||y.push({dir:h.dir,label:S??(h.label||yt(h.dir)||"\u81EA\u5B9A\u4E49 --dir"),kind:h.kind==="primary"||h.kind==="agent"?h.kind:"custom",available:!0,dirExists:nt(h.dir),recorded:!0,selected:C,items:v})}let E=[...n.entries()].map(([h,S])=>({name:h,dir:S.dir,version:S.version,tier:S.tier,requires:[]}));return{source:Qe(),skills:o,mode:s,selection:c,targetSelection:f??[],sources:r,skillVersions:Object.fromEntries([...n.entries()].map(([h,S])=>[h,S.version])),versionMismatches:Bo(E),stateFile:et(),stateExists:!!e,targets:y,pendingAgents:x,canonicalReaders:Tl(),legacyTargets:b}}function Dg(e,t,n){if(!nt(e))return"missing";let r;try{r=w(e)}catch{return"conflict"}let o=vt(r);return o===null?"conflict":o>Or()||r===jr(t.name,n,Cr(t.dir))?"ready":"drift"}function pc(e=process.cwd()){let t=St(e),n=t.root,r=Wt(n),o=Te(n),{refs:s,sources:i}=dc(r),l=[...s.keys()].sort(),c=o.mode??"skills",a=o.selection!==void 0?o.selection:void 0,f=a!==void 0?l.filter(v=>a.includes(v)):c==="package"?[]:l.filter(v=>s.get(v).tier==="core"),p=new Set(f),g=o.targets&&o.targets.length>0?o.targets:void 0,u=v=>!g||g.includes(v),m=Object.values(r?.sources??{}).flatMap(v=>v.targets),d=m.find(v=>v.kind==="source"&&v.dir===t.sourceDir),k=new Map(m.filter(v=>v.kind==="shell").map(v=>[v.dir,v])),y=new Set(d?.entries.map(v=>v.name)??[]),x=new Set(l),$=v=>a===void 0?new Set([...p,...v]):p,b=$(y),E=Nr(b,d,Mr(Ve(n,t.sourceDir),x)),h=[];for(let v of E){let A=s.get(v),Y=Ve(n,t.sourceDir,v),T;nt(Y)?A&&Ce(A.dir,Y)?T=b.has(v)?"ready":"installed-unselected":T=y.has(v)?"drift":"conflict":T=b.has(v)?"missing":"not-selected",T!=="not-selected"&&h.push({name:v,state:T,version:A?.version??"",source:A?.source??""})}let S=[{dir:t.sourceDir,kind:"source",selected:!0,items:h}],R=(v,A)=>{let Y=u(v),T=new Set(A?.entries.map(P=>P.name)??[]),I=$(T),_=[];for(let P of Nr(I,A,Mr(Ve(n,v),x))){let X=s.get(P),B;if(!X)B="conflict";else{let ne=Ve(n,v,P,W);B=Dg(ne,{name:P,dir:X.dir},t.sourceDir),B==="conflict"&&T.has(P)&&(B="drift"),Y?(B==="ready"&&!I.has(P)&&(B="installed-unselected"),B==="missing"&&!I.has(P)&&(B="not-selected")):B==="missing"?B="not-selected":(B==="ready"||B==="drift")&&(B="installed-unselected")}B!=="not-selected"&&_.push({name:P,state:B,version:X?.version??"",source:X?.source??""})}return{dir:v,kind:"shell",selected:Y,items:_}};for(let v of t.shellDirs)S.push(R(v,k.get(v)));let F=new Set(t.shellDirs);for(let[v,A]of k){if(F.has(v)||!nt(Ve(n,v)))continue;let Y=R(v,A);Y.items.length>0&&S.push(Y)}let C=[...s.entries()].map(([v,A])=>({name:v,dir:A.dir,version:A.version,tier:A.tier,requires:[]}));return{root:n,sourceDir:t.sourceDir,skills:l,mode:c,selection:f,targetSelection:g??[],sources:i,skillVersions:Object.fromEntries([...s.entries()].map(([v,A])=>[v,A.version])),versionMismatches:Bo(C),stateFile:bt(n,tt(n)),stateExists:!!r,dirs:S,missingDirs:t.missingDirs}}function Jo(e){return e.filter(t=>t.tier==="core").map(t=>t.name)}function Fg(e){return e.filter(t=>t.tier!=="core").map(t=>t.name)}function Ng(e,t,n="skills"){let r=new Set(t??[]);return e.map(o=>({name:o.name,tier:o.tier,selected:n==="skills"&&o.tier==="core"||r.has(o.name)}))}function mc(e,t){let n=new Set(t);return e.filter(r=>n.has(r.name)).map(r=>r.name)}function qo(e,t,n="skills"){let r=new Set(n==="skills"?[...Jo(e),...t]:t);return e.filter(o=>r.has(o.name)).map(o=>o.name)}function hc(e){let{skills:t,saved:n,explicit:r,all:o,noOptional:s,interactive:i,yes:l}=e,c=e.mode??"skills",a=t.map(d=>d.name);if(r!==void 0){let d=mc(t,r),k=r.filter(y=>!a.includes(y));return d.length===0?{names:[],invalid:k,savedInvalid:[],needsPrompt:!1,error:"\u5168\u90E8\u53D6\u503C\u975E\u6CD5"}:{names:qo(t,d,c),invalid:k,savedInvalid:[],needsPrompt:!1}}if(o)return{names:a,invalid:[],savedInvalid:[],needsPrompt:!1};if(s)return{names:Jo(t),invalid:[],savedInvalid:[],needsPrompt:!1};let f=n!==void 0,p=mc(t,n??[]),g=(n??[]).filter(d=>!a.includes(d)),u=c==="package"?f?p:[]:p.length>0?qo(t,p,c):Jo(t),m=i&&!l&&(c==="package"?t.length>0:Fg(t).length>0);return{names:u,invalid:[],savedInvalid:g,needsPrompt:m}}function jn(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}function Xo(e){return e instanceof Error?e.name==="ExitPromptError"||e.name==="AbortPromptError"||/force closed|cancel/i.test(e.message):!1}function kc(e,t,n=[]){let r=t?new Set(t):void 0,o=[],s=e.find(l=>l.kind==="primary");s&&o.push({value:s.name,label:`\u5171\u8BFB\uFF5C${s.label}`,checked:r?r.has(s.name):!0});for(let l of e.filter(c=>c.kind==="agent"))!l.available&&!r?.has(l.name)||o.push({value:l.name,label:`agent\uFF5C${l.label}${l.available?"":"\uFF08\u672A\u68C0\u6D4B\u5230\uFF09"}`,checked:l.available?r?r.has(l.name):!0:!1,disabled:l.available?!1:"\u672C\u673A\u672A\u68C0\u6D4B\u5230\u8BE5 agent\uFF0C\u4E0D\u51ED\u7A7A\u521B\u5EFA\u76EE\u5F55"});let i=new Set(n);for(let l of e.filter(c=>c.kind==="custom"&&i.has(c.dir)))o.push({value:l.dir,label:`\u81EA\u5B9A\u4E49\uFF5C${l.dir}\uFF08\u4E00\u6B21\u6027 --dir\uFF09`,checked:!0,disabled:"\u4E00\u6B21\u6027 --dir\uFF0C\u672C\u6B21\u56FA\u5B9A\u5199\u5165\u3001\u4E0D\u4FDD\u5B58\u4E3A\u957F\u671F\u9009\u62E9"});return o}function Sc(e,t,n=[],r=[]){let o=t?new Set(t):void 0,s=e.map(i=>({value:i,label:`\u9879\u76EE\u76EE\u5F55\uFF5C${i}`,checked:o?o.has(i):!0}));for(let i of r)o?.has(i)&&s.push({value:i,label:`\u9879\u76EE\u76EE\u5F55\uFF5C${i}\uFF08\u4E0D\u5B58\u5728\uFF09`,checked:!1,disabled:"\u76EE\u5F55\u4E0D\u5B58\u5728\uFF0C\u8865\u9F50\u540E\u91CD\u8DD1\u5373\u53EF"});for(let i of n)e.includes(i)||s.push({value:i,label:`\u81EA\u5B9A\u4E49\uFF5C${i}\uFF08\u4E00\u6B21\u6027 --dir\uFF09`,checked:!0,disabled:"\u4E00\u6B21\u6027 --dir\uFF0C\u672C\u6B21\u56FA\u5B9A\u5199\u5165\u3001\u4E0D\u4FDD\u5B58\u4E3A\u957F\u671F\u9009\u62E9"});return s}async function Zo(e,t){if(e.length===0)return[];let{checkbox:n}=await import("@inquirer/prompts");try{return await n({message:t,choices:e.map(r=>({value:r.value,name:r.label,checked:r.checked,disabled:r.disabled??!1})),pageSize:15,required:!1})}catch(r){if(Xo(r))return null;throw r}}async function yc(e){let{confirm:t}=await import("@inquirer/prompts");try{return await t({message:e,default:!0})}catch(n){if(Xo(n))return null;throw n}}async function bc(e,t,n="skills"){let{checkbox:r}=await import("@inquirer/prompts"),o=Ng(e,t,n).map(s=>({value:s.name,name:n==="skills"&&s.tier==="core"?`${s.name}\uFF08core\uFF09`:s.name,checked:s.selected,disabled:n==="skills"&&s.tier==="core"?"core\uFF08\u5FC5\u88C5\uFF09":!1}));try{let s=await r({message:n==="package"?"\u9009\u62E9\u8981\u5B89\u88C5\u7684\u6280\u80FD\uFF08\u7A7A\u683C\u5207\u6362\uFF0C\u56DE\u8F66\u786E\u8BA4\uFF1B\u5168\u4E0D\u9009\u5373\u7EAF\u5305\u7BA1\u7406\u5668\u6A21\u5F0F\uFF09":"\u9009\u62E9\u8981\u5B89\u88C5\u7684\u6280\u80FD\uFF08\u7A7A\u683C\u5207\u6362\uFF0C\u56DE\u8F66\u786E\u8BA4\uFF1Bcore \u5FC5\u88C5\uFF09",choices:o,pageSize:12,required:!1});return n==="package"?s:qo(e,s)}catch(s){if(Xo(s))return null;throw s}}var Pg="2.0",vc=`/* fxri-docs-theme: ${Pg} */`,Hg=/^\/\* fxri-docs-theme: (?:v\d+|\d+\.\d+) \*\/$/,$c="/* fxri-docs-theme:brand-start */",xc="/* fxri-docs-theme:brand-end */",Qo={"--site-accent":"--fx-accent","--site-glow":"--fx-accent-soft","--site-shadow":"--fx-shadow","--site-hero-angle":"--fx-hero-angle"};function Rc(e){return new RegExp(`${e.replace(/[-]/g,"\\-")}(?=\\s*:)`,"g")}function Bg(e){let t=e;for(let[n,r]of Object.entries(Qo))t=t.replace(Rc(n),r);return t}function es(e){return e.replace(/^\uFEFF/,"").replace(/\r\n/g,`
|
|
118
|
+
`)}function kg(e,t){let n=ee();if(!n.selection)return;let r={...n.selection};if(!e&&!t){De({selection:void 0});return}let o=new Set(e??[]);for(let s of Object.keys(r)){if(t&&s!==t)continue;let i=e?(r[s]??[]).filter(l=>!o.has(l)):[];i.length>0?r[s]=i:delete r[s]}De({selection:Object.keys(r).length>0?r:void 0})}function Sg(e){let t=ee(),n={...t.sources??{}};delete n[e];let r={...t.selection??{}};delete r[e],De({sources:Object.keys(n).length>0?n:void 0,selection:Object.keys(r).length>0?r:void 0})}function yg(e,t){if(e===Ee||t.kind==="builtin")return tc([In()]);if(!t.root||!le(t.root))return new Map;try{return tc([mt(t.root,{name:e,temporary:t.temporary})])}catch{return new Map}}function zo(e={}){let t=et();e.dryRun||(kg(e.skills,e.source),e.source&&Sg(e.source));let n=e.dryRun?null:Dr(Yo(V()));try{let r=Ye();if(!r)return{stateFile:t,stateExists:!1,targets:[],stateRemoved:!1};let o=e.skills?new Set(e.skills):null,s=[],i=!1,l=!1,c={};for(let[p,g]of Object.entries(r.sources)){if(e.source&&e.source!==p){c[p]=g;continue}let u=yg(p,g),m=[];for(let d of g.targets){let k={dir:d.dir,label:d.label||yt(d.dir)||null,removed:[],missing:[],skippedForeign:[],dirReclaimed:!1},y=[];for(let x of d.entries){if(o&&!o.has(x.name)){y.push(x);continue}let $=q(d.dir,x.name),b=u.get(x.name);if(!b){let h=!1;try{h=dg($).isSymbolicLink()&&!le($)}catch{h=!1}if(h&&!e.dryRun){Me($),k.removed.push(x.name),l=!0;continue}if(h){k.removed.push(x.name);continue}k.skippedForeign.push(x.name),y.push(x);continue}let E=kt($,b.linkTarget,void 0,b.dir);if(E==="absent"){k.missing.push(x.name),l=!0;continue}if(E==="wrong"||E==="file"||E==="dir"&&!Ce(b.dir,$)){k.skippedForeign.push(x.name),y.push(x);continue}if(e.dryRun){k.removed.push(x.name);continue}try{Me($),k.removed.push(x.name),l=!0}catch{i=!0,k.skippedForeign.push(x.name),y.push(x)}}if(!e.dryRun&&An(d.dir))try{Fr(d.dir,{recursive:!0,force:!0}),k.dirReclaimed=!0}catch{}s.push(k),y.length>0&&m.push({...d,entries:y})}m.length>0&&(c[p]={...g,targets:m})}let a=s.every(p=>p.skippedForeign.length===0),f=!e.dryRun&&!i&&a&&Object.keys(c).length===0;return e.dryRun||(f?Fr(t,{force:!0}):(l||Object.keys(c).length!==Object.keys(r.sources).length)&&_r({format:Oe,schemaVersion:_e,updatedAt:new Date().toISOString(),sources:c})),{stateFile:t,stateExists:!0,targets:s,stateRemoved:f}}finally{n?.()}}function nc(e,t,n){t==="created"?e.created.push(n):t==="updated"?e.updated.push(n):t==="skipped"?e.skipped.push(n):e.conflicts.push(n)}function bg(e,t,n,r,o){return le(t)?Ce(e,t)?"skipped":!n&&!r?"conflict":(o||(Me(t),En(e,t)),"updated"):(o||En(e,t),"created")}function vg(e,t,n,r){let o=le(e),s=o?w(e):"",i=o?vt(s):null,l;return o?i!==null&&i>Or()||s===t?l="skipped":i===null&&!n?l="conflict":l="updated":l="created",!r&&(l==="created"||l==="updated")&&(rc(oc(e),{recursive:!0}),O(e,t)),l}function cc(e={}){let t=e.cwd??process.cwd(),n=Wo({externalSources:e.externalSources,dryRun:e.dryRun}),r=n.flatMap(ht);Ir(r);let o=sc(r,e.skills),s=new Set(o.map(x=>x.name)),i=new Map(r.map(x=>[x.name,{dir:x.dir,linkTarget:x.linkTarget}])),l=St(t),c=l.root,a=Wt(c),f=(x,$,b)=>a?.sources?.[x]?.targets.find(E=>E.kind===$&&E.dir===b),p=[],g=[];for(let x of e.dirs??[]){let $=ec(t,x);if(!Ln($,c)){p.push(x);continue}let b=bt(c,$);b!==l.sourceDir&&!g.includes(b)&&g.push(b)}let u=Te(c).targets,m=e.targetDirs??(u&&u.length>0?u:void 0),d;if(m===void 0)d=[...l.shellDirs];else{d=[];for(let x of m){let $=ec(c,x);if(!Ln($,c)){console.warn(`\u26A0\uFE0F \u5FFD\u7565\u4ED3\u5E93\u4E4B\u5916\u7684\u6280\u80FD\u76EE\u5F55\uFF1A${x}`);continue}let b=bt(c,$);if(b!==l.sourceDir){if(!le($)){console.warn(`\u26A0\uFE0F \u5FFD\u7565\u4E0D\u5B58\u5728\u7684\u6280\u80FD\u76EE\u5F55\uFF1A${b}\uFF08\u8865\u9F50\u76EE\u5F55\u540E\u91CD\u8DD1\u5373\u53EF\uFF09`);continue}d.includes(b)||d.push(b)}}}let k=[...d.filter(x=>!g.includes(x)),...g],y=e.dryRun?null:Dr(Xl(c));try{let x={dir:l.sourceDir,created:[],updated:[],skipped:[],conflicts:[],failed:[],pruned:[]},$=q(c,l.sourceDir),b=new Map;for(let C of o){let v=f(C.source,"source",l.sourceDir)?.entries.some(A=>A.name===C.name)??!1;try{let A=bg(C.dir,q($,C.name),v,!!e.force,!!e.dryRun);nc(x,A,C.name),A!=="conflict"&&!e.dryRun&&b.set(C.source,[...b.get(C.source)??[],{name:C.name,version:C.version,mode:"copy"}])}catch(A){x.failed.push({name:C.name,reason:A.message})}}if(e.prune&&!e.dryRun)for(let C of n)x.pruned.push(...Vo(f(C.name,"source",l.sourceDir),s,$,i));let E=new Set(x.pruned),h=[],S=new Map;for(let C of n)S.set(C.name,[]);for(let C of n){let v=f(C.name,"source",l.sourceDir),A=[...b.get(C.name)??[],...v?.entries.filter(Y=>!s.has(Y.name)&&!E.has(Y.name)&&le(q($,Y.name)))??[]];A.length>0&&S.get(C.name).push({id:"source",dir:l.sourceDir,label:"\u771F\u6E90\u526F\u672C",kind:"source",entries:A})}for(let C of k){let v={dir:C,created:[],updated:[],skipped:[],conflicts:[],failed:[],pruned:[]},A=new Map;for(let T of o){let I=jr(T.name,l.sourceDir,Cr(T.dir));try{let _=vg(q(c,C,T.name,W),I,!!e.force,!!e.dryRun);nc(v,_,T.name),_!=="conflict"&&!e.dryRun&&A.set(T.source,[...A.get(T.source)??[],{name:T.name,version:T.version,mode:"shell"}])}catch(_){v.failed.push({name:T.name,reason:_.message})}}if(e.prune&&!e.dryRun)for(let T of n)for(let I of f(T.name,"shell",C)?.entries??[]){if(s.has(I.name))continue;let _=q(c,C,I.name,W);if(!le(_))continue;let P=w(_);vt(P)!==null&&(Me(q(c,C,I.name)),v.pruned.push(I.name))}let Y=new Set(v.pruned);for(let T of n){let I=f(T.name,"shell",C),_=[...A.get(T.name)??[],...I?.entries.filter(P=>!s.has(P.name)&&!Y.has(P.name)&&le(q(c,C,P.name)))??[]];_.length>0&&S.get(T.name).push({id:C,dir:C,label:"\u8584\u58F3",kind:"shell",entries:_})}h.push(v)}let R=new Set(k),F=!!e.prune&&m!==void 0;for(let C of n)for(let v of a?.sources?.[C.name]?.targets.filter(A=>A.kind==="shell")??[]){if(R.has(v.dir))continue;let A=v.entries;if(F){let Y={dir:v.dir,created:[],updated:[],skipped:[],conflicts:[],failed:[],pruned:[]},T=[];for(let I of A){let _=q(c,v.dir,I.name),P=q(_,W);if(!le(P))continue;let X;try{X=w(P)}catch{T.push(I);continue}if(vt(X)===null){T.push(I);continue}try{Me(_),Y.pruned.push(I.name)}catch{T.push(I)}}A=T,Y.pruned.length>0&&h.push(Y)}A.length>0&&S.get(C.name).push({...v,entries:A})}if(!e.dryRun){let C={};for(let[v,A]of Object.entries(a?.sources??{}))!n.some(Y=>Y.name===v)&&A.targets.length>0&&(C[v]=A);for(let v of n){let A=S.get(v.name)??[];A.length>0&&(C[v.name]={kind:v.kind,version:v.version,temporary:v.temporary,root:v.url?"":v.root,url:v.url,ref:v.ref,targets:A})}Rg(c,C),e.saveSelection!==!1&&$g(c,o.filter(v=>!v.temporary).map(v=>v.name)),e.saveTargets!==!1&&xg(c,d)}return{root:c,skills:o.map(C=>C.name),selection:o.map(C=>C.name),mode:e.mode??Te(c).mode??"skills",targetSelection:k,source:x,shells:h,missingDirs:l.missingDirs,ignoredDirs:p,stateFile:bt(c,tt(c))}}finally{y?.()}}function $g(e,t){try{let n=Te(e);pt({targets:n.targets,selection:t},e)}catch(n){console.warn(`\u26A0\uFE0F \u9879\u76EE\u9762\u6280\u80FD\u9009\u62E9\u4FDD\u5B58\u5931\u8D25\uFF1A${n.message}`)}}function xg(e,t){try{pt({targets:[...new Set(t)]},e)}catch(n){console.warn(`\u26A0\uFE0F \u9879\u76EE\u9762\u76EE\u5F55\u9009\u62E9\u4FDD\u5B58\u5931\u8D25\uFF1A${n.message}`)}}function Rg(e,t){let n=Object.fromEntries(Object.entries(t).filter(([,r])=>r.targets.length>0));if(Object.keys(n).length===0){Ko(e);return}Go(e,n)}function wg(e,t){let n=Te(e);if(!n.selection)return;if(!t){pt({selection:void 0},e);return}let r=new Set(t),o=n.selection.filter(s=>!r.has(s));pt({selection:o.length>0?o:void 0},e)}function ac(e={}){let t=e.cwd??process.cwd(),n=St(t),r=n.root,o=tt(r),s=bt(r,o);e.dryRun||wg(r,e.skills);let i=Wt(r);if(!i)return{root:r,stateFile:s,stateExists:!1,sourceDir:n.sourceDir,dirs:[],reclaimed:[],stateRemoved:!1};let l=e.skills?new Set(e.skills):null,c=new Map(Ke().map(k=>[k.name,k.dir])),a=[],f=[],p={},g=!1,u=!1;for(let[k,y]of Object.entries(i.sources)){let x=[];for(let $ of y.targets){if($.kind!=="source"&&$.kind!=="shell")continue;let b={dir:$.dir,kind:$.kind,removed:[],missing:[],skippedForeign:[]},E=[];for(let h of $.entries){if(l&&!l.has(h.name)){E.push(h);continue}let S=q(r,$.dir,h.name);if(!($.kind==="source"?le(S):le(q(S,W)))){b.missing.push(h.name),u=!0;continue}if(!($.kind==="source"?Eg(S,c.get(h.name)):Tg(S))){b.skippedForeign.push(h.name),E.push(h);continue}if(e.dryRun){b.removed.push(h.name);continue}try{Me(S),b.removed.push(h.name),u=!0}catch{g=!0,b.skippedForeign.push(h.name),E.push(h)}}a.push(b),E.length>0&&x.push({...$,entries:E})}x.length>0&&(p[k]={...y,targets:x})}if(!e.dryRun)for(let k of[n.sourceDir,...i.sources[Ee]?.targets.filter(y=>y.kind==="shell").map(y=>y.dir)??[]]){let y=q(r,k);if(!(!le(y)||!An(y)))try{Fr(y,{recursive:!0,force:!0}),f.push(k)}catch{}}let m=a.every(k=>k.skippedForeign.length===0),d=!e.dryRun&&!g&&m&&Object.keys(p).length===0;return e.dryRun||(d?Ko(r):(u||Object.keys(p).length!==Object.keys(i.sources).length)&&Go(r,p)),{root:r,stateFile:s,stateExists:!0,sourceDir:n.sourceDir,dirs:a,reclaimed:f,stateRemoved:d}}function Eg(e,t){return!!t&&Ce(t,e)}function Tg(e){try{return vt(w(q(e,W)))!==null}catch{return!1}}function uc(){let e=ae("skills");if(e?.autoLink===!1||process.env.CI)return 0;let t=Ye();if(!t)return 0;let n=Qe(),r;try{r=new Set(Ql(n).filter(a=>le(q(n,a))))}catch{return 0}let o=Ho(),s=e?.autoLinkReplaceForeign!==!1,i=process.platform==="win32"?"junction":"dir",l=0,c={};for(let[a,f]of Object.entries(t.sources)){let p=[];for(let g of f.targets){let u;try{u=Ql(g.dir,{withFileTypes:!0})}catch{p.push(g);continue}let m=new Map(u.map(k=>[k.name,k])),d=g.entries.filter(k=>{if(k.mode!=="link")return r.has(k.name);if(!r.has(k.name))return!1;let y=q(o,k.name),x=q(g.dir,k.name),$=m.get(k.name),b=$?kt(x,y,$):"absent";if(b==="link-ok"||!s&&(b==="dir"||b==="file"))return!0;try{return b!=="absent"&&Me(x),gg(y,x,i),l+=1,!0}catch{return!0}});p.push({...g,entries:d})}c[a]={...f,targets:p}}return l>0&&_r({format:Oe,schemaVersion:_e,updatedAt:new Date().toISOString(),sources:c}),l}import{existsSync as nt,lstatSync as Cg,readlinkSync as Ig}from"fs";import{dirname as Ag,isAbsolute as Lg,join as Ve}from"path";function jg(e){return new Map((e?.entries??[]).map(t=>[t.name,t]))}function Og(e){let t=new Map;for(let n of Object.values(e?.sources??{}))for(let r of n.targets)for(let o of r.entries)t.set(o.name,o.version);return t}function dc(e){let t=new Map,n=[],r=Og(e),o=(l,c,a,f,p,g)=>{if(!n.some(u=>u.name===l)){n.push({name:l,kind:c,root:a,version:f,temporary:p,skills:g.map(u=>u.name)});for(let u of g)t.has(u.name)||t.set(u.name,{source:l,version:u.version,dir:u.dir,linkTarget:c==="builtin"?Ve(a,"skills",u.name):u.dir,tier:u.tier})}},s=In();o(s.name,"builtin",s.root,s.version,!1,s.skills);for(let l of ht(s))t.set(l.name,{source:l.source,version:l.version,dir:l.dir,linkTarget:l.linkTarget,tier:l.tier});let i=ee();for(let[l,c]of Object.entries(i.sources??{}))if(!n.some(a=>a.name===l))try{let a=c.url?e?.sources[l]?.root:c.root;if(!a)continue;let f=mt(a,{name:l,temporary:!1});o(f.name,"local",f.root,f.version,!1,f.skills)}catch{}for(let[l,c]of Object.entries(e?.sources??{})){if(n.some(g=>g.name===l))continue;let a=[];if(c.root&&nt(c.root))try{a=mt(c.root,{name:l,temporary:c.temporary}).skills}catch{a=[]}let f=new Set(a.map(g=>g.name));for(let g of c.targets)for(let u of g.entries)f.add(u.name);let p=[...f].map(g=>{let u=a.find(d=>d.name===g);if(u)return u;let m=c.root?Ve(c.root,g):g;return{name:g,dir:m,version:r.get(g)??"",tier:"optional",requires:[]}});if(o(l,c.kind==="builtin"?"builtin":"local",c.root,c.version,c.temporary,p),p.length>0&&c.kind!=="builtin")for(let g of p){let u=t.get(g.name);u&&t.set(g.name,{...u,linkTarget:g.dir})}}return{refs:t,sources:n}}function _g(e){let t;try{t=Cg(e)}catch{return"absent"}if(!t.isSymbolicLink())return t.isDirectory()?"dir":"file";try{let n=Ig(e),r=Rn(Lg(n)?n:Ve(Ag(e),n));return nt(r)?"wrong":"dangling"}catch{return"dangling"}}function Nr(e,t,n=[]){return[...new Set([...e,...t?.entries.map(o=>o.name)??[],...n])].sort()}function Mr(e,t){return _l(e).filter(n=>n.isDirectory()||n.isSymbolicLink()).map(n=>n.name).filter(n=>t.has(n))}function fc(e,t,n,r,o,s=!0){let i=jg(o),l=[];for(let c of t){let a=r.get(c),f=n.has(c),p=Ve(e,c),g=a?kt(p,a.linkTarget,void 0,a.dir):_g(p),u;s?g==="link-ok"?u=f?"link":"installed-unselected":g==="dangling"?u="dangling":g==="wrong"?u="wrong":g==="file"?u="conflict":g==="dir"?a&&nt(a.dir)&&Ce(a.dir,p)?u=f?"copy":"installed-unselected":u=i.get(c)?.mode==="copy"?"copy-drift":"conflict":u=f?"missing":"not-selected":g==="absent"?u="not-selected":g==="wrong"||g==="file"?u=g==="wrong"?"wrong":"conflict":u="installed-unselected",u!=="not-selected"&&l.push({name:c,state:u,version:a?.version??"",source:a?.source??""})}return l}function gc(){let e=Ye(),t=ee(),{refs:n,sources:r}=dc(e),o=[...n.keys()].sort(),s=t.mode??"skills",i=t.selection,l=i!==void 0&&Object.keys(i).length>0,c=l?o.filter(h=>{let S=n.get(h),R=i[S.source];return R===void 0||R.includes(h)}):s==="package"?[]:o.filter(h=>n.get(h).tier==="core"),a=new Set(c),f=t.targets&&t.targets.length>0?t.targets:void 0,p=h=>!f||f.includes(h),g=Ne([]),u=new Map(g.filter(h=>h.name).map(h=>[N(h.dir),h.name])),m=new Map;for(let h of Object.values(e?.sources??{}))for(let S of h.targets)m.set(N(S.dir),S);let d=new Set(o),k=h=>l?a:new Set([...a,...h?.entries.map(S=>S.name)??[]]),y=[],x=[],$=new Set;for(let h of g){let S=m.get(N(h.dir));if(!h.available&&h.kind==="agent"){x.push({dir:h.dir,label:h.label});continue}if(h.kind!=="primary"&&!S&&(!h.dirExists||An(h.dir)))continue;$.add(N(h.dir));let R=k(S),F=h.name?p(h.name):!0,C=fc(h.dir,Nr(R,S,Mr(h.dir,d)),R,n,S,F);!F&&C.length===0||y.push({dir:h.dir,label:h.label,kind:h.kind,available:h.available,dirExists:h.dirExists,recorded:!!S,selected:F,items:C})}let b=[];for(let h of m.values()){if($.has(N(h.dir)))continue;let S=Il(h.dir);S&&nt(h.dir)&&b.push({dir:h.dir,label:S});let R=k(h),F=u.get(N(h.dir))??"",C=F?p(F):!0,v=fc(h.dir,Nr(R,h,Mr(h.dir,d)),R,n,h,C);!C&&v.length===0||y.push({dir:h.dir,label:S??(h.label||yt(h.dir)||"\u81EA\u5B9A\u4E49 --dir"),kind:h.kind==="primary"||h.kind==="agent"?h.kind:"custom",available:!0,dirExists:nt(h.dir),recorded:!0,selected:C,items:v})}let E=[...n.entries()].map(([h,S])=>({name:h,dir:S.dir,version:S.version,tier:S.tier,requires:[]}));return{source:Qe(),skills:o,mode:s,selection:c,targetSelection:f??[],sources:r,skillVersions:Object.fromEntries([...n.entries()].map(([h,S])=>[h,S.version])),versionMismatches:Bo(E),stateFile:et(),stateExists:!!e,targets:y,pendingAgents:x,canonicalReaders:Tl(),legacyTargets:b}}function Dg(e,t,n){if(!nt(e))return"missing";let r;try{r=w(e)}catch{return"conflict"}let o=vt(r);return o===null?"conflict":o>Or()||r===jr(t.name,n,Cr(t.dir))?"ready":"drift"}function pc(e=process.cwd()){let t=St(e),n=t.root,r=Wt(n),o=Te(n),{refs:s,sources:i}=dc(r),l=[...s.keys()].sort(),c=o.mode??"skills",a=o.selection!==void 0?o.selection:void 0,f=a!==void 0?l.filter(v=>a.includes(v)):c==="package"?[]:l.filter(v=>s.get(v).tier==="core"),p=new Set(f),g=o.targets&&o.targets.length>0?o.targets:void 0,u=v=>!g||g.includes(v),m=Object.values(r?.sources??{}).flatMap(v=>v.targets),d=m.find(v=>v.kind==="source"&&v.dir===t.sourceDir),k=new Map(m.filter(v=>v.kind==="shell").map(v=>[v.dir,v])),y=new Set(d?.entries.map(v=>v.name)??[]),x=new Set(l),$=v=>a===void 0?new Set([...p,...v]):p,b=$(y),E=Nr(b,d,Mr(Ve(n,t.sourceDir),x)),h=[];for(let v of E){let A=s.get(v),Y=Ve(n,t.sourceDir,v),T;nt(Y)?A&&Ce(A.dir,Y)?T=b.has(v)?"ready":"installed-unselected":T=y.has(v)?"drift":"conflict":T=b.has(v)?"missing":"not-selected",T!=="not-selected"&&h.push({name:v,state:T,version:A?.version??"",source:A?.source??""})}let S=[{dir:t.sourceDir,kind:"source",selected:!0,items:h}],R=(v,A)=>{let Y=u(v),T=new Set(A?.entries.map(P=>P.name)??[]),I=$(T),_=[];for(let P of Nr(I,A,Mr(Ve(n,v),x))){let X=s.get(P),B;if(!X)B="conflict";else{let ne=Ve(n,v,P,W);B=Dg(ne,{name:P,dir:X.dir},t.sourceDir),B==="conflict"&&T.has(P)&&(B="drift"),Y?(B==="ready"&&!I.has(P)&&(B="installed-unselected"),B==="missing"&&!I.has(P)&&(B="not-selected")):B==="missing"?B="not-selected":(B==="ready"||B==="drift")&&(B="installed-unselected")}B!=="not-selected"&&_.push({name:P,state:B,version:X?.version??"",source:X?.source??""})}return{dir:v,kind:"shell",selected:Y,items:_}};for(let v of t.shellDirs)S.push(R(v,k.get(v)));let F=new Set(t.shellDirs);for(let[v,A]of k){if(F.has(v)||!nt(Ve(n,v)))continue;let Y=R(v,A);Y.items.length>0&&S.push(Y)}let C=[...s.entries()].map(([v,A])=>({name:v,dir:A.dir,version:A.version,tier:A.tier,requires:[]}));return{root:n,sourceDir:t.sourceDir,skills:l,mode:c,selection:f,targetSelection:g??[],sources:i,skillVersions:Object.fromEntries([...s.entries()].map(([v,A])=>[v,A.version])),versionMismatches:Bo(C),stateFile:bt(n,tt(n)),stateExists:!!r,dirs:S,missingDirs:t.missingDirs}}function Jo(e){return e.filter(t=>t.tier==="core").map(t=>t.name)}function Fg(e){return e.filter(t=>t.tier!=="core").map(t=>t.name)}function Ng(e,t,n="skills"){let r=new Set(t??[]);return e.map(o=>({name:o.name,tier:o.tier,selected:n==="skills"&&o.tier==="core"||r.has(o.name)}))}function mc(e,t){let n=new Set(t);return e.filter(r=>n.has(r.name)).map(r=>r.name)}function qo(e,t,n="skills"){let r=new Set(n==="skills"?[...Jo(e),...t]:t);return e.filter(o=>r.has(o.name)).map(o=>o.name)}function hc(e){let{skills:t,saved:n,explicit:r,all:o,noOptional:s,interactive:i,yes:l}=e,c=e.mode??"skills",a=t.map(d=>d.name);if(r!==void 0){let d=mc(t,r),k=r.filter(y=>!a.includes(y));return d.length===0?{names:[],invalid:k,savedInvalid:[],needsPrompt:!1,error:"\u5168\u90E8\u53D6\u503C\u975E\u6CD5"}:{names:qo(t,d,c),invalid:k,savedInvalid:[],needsPrompt:!1}}if(o)return{names:a,invalid:[],savedInvalid:[],needsPrompt:!1};if(s)return{names:Jo(t),invalid:[],savedInvalid:[],needsPrompt:!1};let f=n!==void 0,p=mc(t,n??[]),g=(n??[]).filter(d=>!a.includes(d)),u=c==="package"?f?p:[]:p.length>0?qo(t,p,c):Jo(t),m=i&&!l&&(c==="package"?t.length>0:Fg(t).length>0);return{names:u,invalid:[],savedInvalid:g,needsPrompt:m}}function jn(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}function Xo(e){return e instanceof Error?e.name==="ExitPromptError"||e.name==="AbortPromptError"||/force closed|cancel/i.test(e.message):!1}function kc(e,t,n=[]){let r=t?new Set(t):void 0,o=[],s=e.find(l=>l.kind==="primary");s&&o.push({value:s.name,label:`\u5171\u8BFB\uFF5C${s.label}`,checked:r?r.has(s.name):!0});for(let l of e.filter(c=>c.kind==="agent"))!l.available&&!r?.has(l.name)||o.push({value:l.name,label:`agent\uFF5C${l.label}${l.available?"":"\uFF08\u672A\u68C0\u6D4B\u5230\uFF09"}`,checked:l.available?r?r.has(l.name):!0:!1,disabled:l.available?!1:"\u672C\u673A\u672A\u68C0\u6D4B\u5230\u8BE5 agent\uFF0C\u4E0D\u51ED\u7A7A\u521B\u5EFA\u76EE\u5F55"});let i=new Set(n);for(let l of e.filter(c=>c.kind==="custom"&&i.has(c.dir)))o.push({value:l.dir,label:`\u81EA\u5B9A\u4E49\uFF5C${l.dir}\uFF08\u4E00\u6B21\u6027 --dir\uFF09`,checked:!0,disabled:"\u4E00\u6B21\u6027 --dir\uFF0C\u672C\u6B21\u56FA\u5B9A\u5199\u5165\u3001\u4E0D\u4FDD\u5B58\u4E3A\u957F\u671F\u9009\u62E9"});return o}function Sc(e,t,n=[],r=[]){let o=t?new Set(t):void 0,s=e.map(i=>({value:i,label:`\u9879\u76EE\u76EE\u5F55\uFF5C${i}`,checked:o?o.has(i):!0}));for(let i of r)o?.has(i)&&s.push({value:i,label:`\u9879\u76EE\u76EE\u5F55\uFF5C${i}\uFF08\u4E0D\u5B58\u5728\uFF09`,checked:!1,disabled:"\u76EE\u5F55\u4E0D\u5B58\u5728\uFF0C\u8865\u9F50\u540E\u91CD\u8DD1\u5373\u53EF"});for(let i of n)e.includes(i)||s.push({value:i,label:`\u81EA\u5B9A\u4E49\uFF5C${i}\uFF08\u4E00\u6B21\u6027 --dir\uFF09`,checked:!0,disabled:"\u4E00\u6B21\u6027 --dir\uFF0C\u672C\u6B21\u56FA\u5B9A\u5199\u5165\u3001\u4E0D\u4FDD\u5B58\u4E3A\u957F\u671F\u9009\u62E9"});return s}async function Zo(e,t){if(e.length===0)return[];let{checkbox:n}=await import("@inquirer/prompts");try{return await n({message:t,choices:e.map(r=>({value:r.value,name:r.label,checked:r.checked,disabled:r.disabled??!1})),pageSize:15,required:!1})}catch(r){if(Xo(r))return null;throw r}}async function yc(e){let{confirm:t}=await import("@inquirer/prompts");try{return await t({message:e,default:!0})}catch(n){if(Xo(n))return null;throw n}}async function bc(e,t,n="skills"){let{checkbox:r}=await import("@inquirer/prompts"),o=Ng(e,t,n).map(s=>({value:s.name,name:n==="skills"&&s.tier==="core"?`${s.name}\uFF08core\uFF09`:s.name,checked:s.selected,disabled:n==="skills"&&s.tier==="core"?"core\uFF08\u5FC5\u88C5\uFF09":!1}));try{let s=await r({message:n==="package"?"\u9009\u62E9\u8981\u5B89\u88C5\u7684\u6280\u80FD\uFF08\u7A7A\u683C\u5207\u6362\uFF0C\u56DE\u8F66\u786E\u8BA4\uFF1B\u5168\u4E0D\u9009\u5373\u7EAF\u5305\u7BA1\u7406\u5668\u6A21\u5F0F\uFF09":"\u9009\u62E9\u8981\u5B89\u88C5\u7684\u6280\u80FD\uFF08\u7A7A\u683C\u5207\u6362\uFF0C\u56DE\u8F66\u786E\u8BA4\uFF1Bcore \u5FC5\u88C5\uFF09",choices:o,pageSize:12,required:!1});return n==="package"?s:qo(e,s)}catch(s){if(Xo(s))return null;throw s}}var Pg="2.1",vc=`/* fxri-docs-theme: ${Pg} */`,Hg=/^\/\* fxri-docs-theme: (?:v\d+|\d+\.\d+) \*\/$/,$c="/* fxri-docs-theme:brand-start */",xc="/* fxri-docs-theme:brand-end */",Qo={"--site-accent":"--fx-accent","--site-glow":"--fx-accent-soft","--site-shadow":"--fx-shadow","--site-hero-angle":"--fx-hero-angle"};function Rc(e){return new RegExp(`${e.replace(/[-]/g,"\\-")}(?=\\s*:)`,"g")}function Bg(e){let t=e;for(let[n,r]of Object.entries(Qo))t=t.replace(Rc(n),r);return t}function es(e){return e.replace(/^\uFEFF/,"").replace(/\r\n/g,`
|
|
119
119
|
`)}function wc(){return Ie(Ge(),"templates","docs-theme")}function Pr(e){let t=es(e).split(`
|
|
120
120
|
`);if(!Hg.test(t[0]??""))return null;let n=t.indexOf($c),r=t.indexOf(xc);return n===-1||r===-1||r<n?null:{header:t[0],brand:t.slice(n+1,r).join(`
|
|
121
121
|
`).trim(),common:t.slice(r+1).join(`
|
package/package.json
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fxri/toolkit",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.7",
|
|
4
4
|
"description": "专为多人 + AI 跨项目协作打造:任务管理 + 多语言 CHANGELOG。",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"author":
|
|
7
|
-
"name": "唐启云",
|
|
8
|
-
"email": "tqy@fxri.net",
|
|
9
|
-
"url": "https://fxri.net:444/"
|
|
10
|
-
},
|
|
6
|
+
"author": "唐启云 <tqy@fxri.net> (https://fxri.net:444/)",
|
|
11
7
|
"repository": {
|
|
12
8
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/fxri-net/toolkit.git"
|
|
9
|
+
"url": "git+https://github.com/fxri-net/toolkit.git"
|
|
14
10
|
},
|
|
15
11
|
"type": "module",
|
|
16
12
|
"main": "./dist/index.js",
|
|
@@ -74,6 +70,14 @@
|
|
|
74
70
|
"registry": "https://registry.npmjs.org/",
|
|
75
71
|
"access": "public"
|
|
76
72
|
},
|
|
73
|
+
"directories": {
|
|
74
|
+
"doc": "docs"
|
|
75
|
+
},
|
|
76
|
+
"types": "./dist/index.d.ts",
|
|
77
|
+
"bugs": {
|
|
78
|
+
"url": "https://github.com/fxri-net/toolkit/issues"
|
|
79
|
+
},
|
|
80
|
+
"homepage": "https://github.com/fxri-net/toolkit#readme",
|
|
77
81
|
"scripts": {
|
|
78
82
|
"dev": "pnpm build:debug && node ./dist/cli.js",
|
|
79
83
|
"build": "cross-env NODE_ENV=production tsup",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* fxri-docs-theme: 2.
|
|
1
|
+
/* fxri-docs-theme: 2.1 */
|
|
2
2
|
/* fxri-docs-theme:brand-start */
|
|
3
3
|
/* 本站品牌与装饰:唯一允许各站不同的区段,--write 会原样保留 */
|
|
4
4
|
:root {
|
|
@@ -39,8 +39,10 @@
|
|
|
39
39
|
--vp-c-text-3: var(--fx-text-3);
|
|
40
40
|
--vp-c-brand-1: var(--fx-accent, #4f5bd5);
|
|
41
41
|
--vp-c-brand-2: var(--fx-accent, #4f5bd5);
|
|
42
|
-
--vp-c-brand-3: var(--fx-accent
|
|
42
|
+
--vp-c-brand-3: var(--fx-accent, #4f5bd5);
|
|
43
43
|
--vp-c-brand-soft: var(--fx-accent-soft, rgba(79, 91, 213, 0.1));
|
|
44
|
+
--vp-code-color: var(--fx-text-1);
|
|
45
|
+
--vp-code-bg: var(--fx-bg-soft);
|
|
44
46
|
--vp-home-hero-name-color: transparent;
|
|
45
47
|
--vp-home-hero-name-background: linear-gradient(
|
|
46
48
|
120deg,
|
|
@@ -57,15 +59,18 @@
|
|
|
57
59
|
--fx-text-1: #e8eaee;
|
|
58
60
|
--fx-text-2: #b6bdc8;
|
|
59
61
|
--fx-text-3: #858e9b;
|
|
62
|
+
|
|
63
|
+
/* 暗色主按钮底为提亮后的强调色,白字对比不足,改近黑字 */
|
|
64
|
+
--vp-button-brand-text: #111;
|
|
65
|
+
--vp-button-brand-hover-text: #111;
|
|
66
|
+
--vp-button-brand-active-text: #111;
|
|
60
67
|
}
|
|
61
68
|
|
|
62
|
-
/* 首页首屏氛围:只铺 hero
|
|
69
|
+
/* 首页首屏氛围:只铺 hero 区域,底部渐隐到画布色,避免出现横向色带 */
|
|
63
70
|
.VPHome .VPHero {
|
|
64
|
-
background-image:
|
|
65
|
-
|
|
66
|
-
var(--fx-accent-soft, rgba(79, 91, 213, 0.1)),
|
|
67
|
-
transparent 70%
|
|
68
|
-
);
|
|
71
|
+
background-image:
|
|
72
|
+
linear-gradient(to bottom, transparent 55%, var(--fx-bg) 100%),
|
|
73
|
+
linear-gradient(var(--fx-hero-angle, 180deg), var(--fx-accent-soft, rgba(79, 91, 213, 0.1)), transparent 85%);
|
|
69
74
|
background-repeat: no-repeat;
|
|
70
75
|
}
|
|
71
76
|
|