useakit 0.2.0-dev.111 → 0.2.0-dev.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +2 -2
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -71,7 +71,7 @@ ${r(`gray`,P)}`:``}`}default:{let a=i?`${r(`cyan`,P)} `:``,o=c.split(`
71
71
  `),u=s.length+1;return`${c}${a}${Rt({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:a.length,rowPadding:o+u,style:(e,n)=>t(e,e.disabled?`disabled`:n?`active`:`inactive`)}).join(`
72
72
  ${a}`)}
73
73
  ${l}
74
- `}}}}).prompt()};`${r(`gray`,P)}`;const Zt=[`stable`,`beta`],Qt=[`latest`,...Zt],$t=e=>Zt.includes(e),en=e=>Qt.includes(e);function tn(e,t,n){if(n===`latest`)return{version:t,fellBack:!1};let r=e[n];return r===null?{version:t,fellBack:!0}:{version:r,fellBack:!1}}var nn=`0.2.0-dev.111`;const rn=[{id:`claude-code`,name:`Claude Code`,projectDir:`.claude/skills`,globalDir:`.claude/skills`,marker:`.claude`},{id:`codex`,name:`Codex`,projectDir:`.agents/skills`,globalDir:`.agents/skills`,marker:`.codex`},{id:`cursor`,name:`Cursor`,projectDir:`.agents/skills`,globalDir:`.cursor/skills`,marker:`.cursor`},{id:`gemini-cli`,name:`Gemini CLI`,projectDir:`.agents/skills`,globalDir:`.gemini/skills`,marker:`.gemini`}],an=e=>e===`global`?C():process.cwd();function on(e=C()){return rn.filter(t=>f(_(e,t.marker)))}function sn(e){return rn.find(t=>t.id===e)}function cn(e,t,n=an(t)){let r=e.map(e=>b(n,t===`global`?e.globalDir:e.projectDir));return[...new Set(r)]}const ln={maxNameLength:100,maxPromptBytes:20480,maxChecks:20,maxHiddenFiles:20,maxHiddenBytes:1048576,maxSetupLength:4096,maxCheckTextLength:10240,minTrials:1,maxTrials:5,maxAttemptsPerRun:50,maxModelsPerRun:4,maxFinalTextBytes:20480,maxJudgedDiffBytes:102400,maxCheckOutputBytes:8192,maxSandboxesPerOrganization:5};function un(e){return e===null||e===0?`—`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(e<1?3:2)}`}ln.maxPromptBytes;function dn(e){return e<1e3?String(e):e<1e6?`${pn(e/1e3)}k`:`${pn(e/1e6)}M`}const fn=e=>`${dn(e.inputTokens+e.outputTokens)} tok · ${un(e.costUsd)}`,pn=e=>e>=100?Math.round(e):Number(e.toFixed(1));function mn(e){switch(e){case`refusal`:return`Claude declined to answer this.`;case`max_tokens`:return`The answer was cut off at the token limit.`;case`tool_use`:return`Stopped after too many skill loads in one turn.`;default:return null}}function hn(e){let t=e.split(`
74
+ `}}}}).prompt()};`${r(`gray`,P)}`;const Zt=[`stable`,`beta`],Qt=[`latest`,...Zt],$t=e=>Zt.includes(e),en=e=>Qt.includes(e);function tn(e,t,n){if(n===`latest`)return{version:t,fellBack:!1};let r=e[n];return r===null?{version:t,fellBack:!0}:{version:r,fellBack:!1}}var nn=`0.2.0-dev.112`;const rn=[{id:`claude-code`,name:`Claude Code`,projectDir:`.claude/skills`,globalDir:`.claude/skills`,marker:`.claude`},{id:`codex`,name:`Codex`,projectDir:`.agents/skills`,globalDir:`.agents/skills`,marker:`.codex`},{id:`cursor`,name:`Cursor`,projectDir:`.agents/skills`,globalDir:`.cursor/skills`,marker:`.cursor`},{id:`gemini-cli`,name:`Gemini CLI`,projectDir:`.agents/skills`,globalDir:`.gemini/skills`,marker:`.gemini`}],an=e=>e===`global`?C():process.cwd();function on(e=C()){return rn.filter(t=>f(_(e,t.marker)))}function sn(e){return rn.find(t=>t.id===e)}function cn(e,t,n=an(t)){let r=e.map(e=>b(n,t===`global`?e.globalDir:e.projectDir));return[...new Set(r)]}const ln={maxNameLength:100,maxPromptBytes:20480,maxChecks:20,maxHiddenFiles:20,maxHiddenBytes:1048576,maxSetupLength:4096,maxCheckTextLength:10240,minTrials:1,maxTrials:5,maxAttemptsPerRun:50,maxModelsPerRun:4,maxFinalTextBytes:20480,maxJudgedDiffBytes:102400,maxCheckOutputBytes:8192,maxSandboxesPerOrganization:5};function un(e){return e===null||e===0?`—`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(e<1?3:2)}`}ln.maxPromptBytes;function dn(e){return e<1e3?String(e):e<1e6?`${pn(e/1e3)}k`:`${pn(e/1e6)}M`}const fn=e=>`${dn(e.inputTokens+e.outputTokens)} tok · ${un(e.costUsd)}`,pn=e=>e>=100?Math.round(e):Number(e.toFixed(1));function mn(e){switch(e){case`refusal`:return`Claude declined to answer this.`;case`max_tokens`:return`The answer was cut off at the token limit.`;case`tool_use`:return`Stopped after too many skill loads in one turn.`;default:return null}}function hn(e){let t=e.split(`
75
75
  `),n=t.pop()??``,r=[];for(let e of t)if(e.trim()!==``)try{r.push(JSON.parse(e))}catch{r.push({type:`error`,message:`The answer came back garbled.`})}return{events:r,rest:n}}function gn(){return process.env.npm_command===`exec`||/[\\/]_npx[\\/]/.test(process.argv[1]??``)?nn.includes(`-dev`)?`npx useakit@next`:`npx useakit`:`a-kit`}const L=e=>`\`${gn()} ${e}\``;var R=class extends Error{status;code;constructor(e,t,n){super(n),this.status=e,this.code=t}};function z(e,t,n=fetch){async function r(r,i={}){let a;try{a=await n(`${e}${r}`,{...i,headers:{"User-Agent":`a-kit/${nn}`,...i.body?{"Content-Type":`application/json`}:{},...t?{Authorization:`Bearer ${t}`}:{},...i.headers}})}catch{throw new R(0,`NETWORK`,`Couldn't reach ${e}.`)}if(!a.ok){let e=await a.json().catch(()=>null);throw a.status===401?new R(401,`UNAUTHORIZED`,`You're not logged in. Run ${L(`login`)}.`):new R(a.status,e?.code??`HTTP_ERROR`,e?.message??`${i.method??`GET`} ${r} failed (${a.status})`)}return a}let i=async(e,t)=>await(await r(e,t)).json();return{me:()=>i(`/me`),logout:()=>r(`/auth/logout`,{method:`POST`}),startLogin:()=>i(`/auth/cli`,{method:`POST`}),pollLogin:e=>i(`/auth/cli/token`,{method:`POST`,body:JSON.stringify({deviceCode:e})}),listSkills:async()=>{let[e,t]=await Promise.all([i(`/skills`),i(`/orgs`)]),n=new Map(t.map(e=>[e.id,e]));return e.map(e=>({...e,organizationName:n.get(e.organizationId)?.name??``,organizationSlug:n.get(e.organizationId)?.slug??null,showOrganization:t.length>1}))},listKits:async()=>{let[e,t]=await Promise.all([i(`/kits`),i(`/orgs`)]),n=new Map(t.map(e=>[e.id,e.name]));return e.map(e=>({...e,organizationName:n.get(e.organizationId)??``,showOrganization:t.length>1}))},getKit:e=>i(`/kits/${e}`),listOrganizations:e=>i(`/orgs`,{signal:e}),listSkillSummaries:e=>i(`/skills`,{signal:e}),listProjects:(e,t)=>i(`/orgs/${e}/projects`,{signal:t}),listRoles:(e,t)=>i(`/orgs/${e}/roles`,{signal:t}),getRepository:(e,t)=>i(`/orgs/${e}/repository`,{signal:t}),reportActivations:(e,t)=>i(`/activations`,{method:`POST`,body:JSON.stringify({activations:e}),signal:t}),reportSessionEvents:(e,t)=>i(`/agent-sessions/events`,{method:`POST`,body:JSON.stringify({events:e}),signal:t}),reportSessionUsage:(e,t)=>i(`/agent-sessions/usage`,{method:`POST`,body:JSON.stringify({sessions:e}),signal:t}),fingerprint:(e,t)=>i(`/fingerprint`,{method:`POST`,body:JSON.stringify(e),signal:t}),sendHeartbeat:(e,t)=>i(`/machines/heartbeat`,{method:`POST`,body:JSON.stringify(e),signal:t}),machineName:e=>i(`/machines/${encodeURIComponent(e)}/name`),nameMachine:(e,t)=>i(`/machines/${encodeURIComponent(e)}/name`,{method:`PUT`,body:JSON.stringify({name:t})}),search:e=>i(`/search?q=${encodeURIComponent(e)}`),getSkill:(e,t=`latest`)=>i(`/skills/${e}${t===`latest`?``:`?channel=${t}`}`),getVersion:(e,t)=>i(`/skills/${e}/versions/${t}`),getSkillHealth:e=>i(`/skills/${e}/health`),createReport:(e,t)=>i(`/orgs/${e}/reports`,{method:`POST`,body:JSON.stringify(t)}),playground:async(e,t,n)=>{let i=await r(`/skills/${e}/playground`,{method:`POST`,body:JSON.stringify(t)}),a=``,o=new TextDecoder;for await(let e of i.body??[]){let t=hn(a+o.decode(e,{stream:!0}));a=t.rest,t.events.forEach(n)}hn(`${a}${o.decode()}\n`).events.forEach(n)},getBlob:async(e,t)=>new Uint8Array(await(await r(`/skills/${e}/blobs/${t}`)).arrayBuffer()),getPublicSkill:e=>i(`/public/skills/${_n(e)}`),getPublicBlob:async(e,t)=>new Uint8Array(await(await r(`/public/skills/${_n(e)}/blobs/${t}`)).arrayBuffer()),countInstall:e=>r(`/public/skills/${_n(e)}/installs`,{method:`POST`})}}const _n=e=>e.split(`/`).map(encodeURIComponent).join(`/`),vn=()=>!!(process.stdin.isTTY&&process.stdout.isTTY)&&!process.env.CI;function yn(e){return rt(e)&&(Ut(`Cancelled.`),process.exit(130)),e}async function bn(e,t){if(e.length>0)return e.map(e=>{let t=sn(e);if(!t)throw Error(`Unknown agent "${e}". Use one of: ${rn.map(e=>e.id).join(`, `)}.`);return t});let n=on(),r=n.length>0?n:[sn(`claude-code`)];return!t||!vn()?r:yn(await Ht({message:`Which agents should get the skills?`,options:rn.map(e=>({value:e.id,label:e.name,hint:n.includes(e)?`detected`:void 0})),initialValues:r.map(e=>e.id),required:!0})).map(e=>sn(e))}async function xn(e,t){return e?`global`:!t||!vn()?`project`:yn(await Xt({message:`Where should they go?`,options:[{value:`project`,label:`This project`,hint:process.cwd()},{value:`global`,label:`Everywhere`,hint:`your home folder`}],initialValue:`project`}))}const Sn=`kit/`;function Cn(e){let t=[],n=[];for(let r of e)r.startsWith(`kit/`)?n.push(r.slice(4)):t.push(r);return{skills:t,kits:n}}async function wn(e,t,n){if(t.length>0)return En(e,t,n,`skill`);if(!n||!vn())throw Error(`Name the skills to add, like ${L(`add my-skill`)}.`);let r=yn(await Ht({message:`Which skills?`,options:e.map(e=>({value:e.id,label:Nn(e),hint:e.description.length>60?`${e.description.slice(0,57)}…`:e.description})),required:!0}));return e.filter(e=>r.includes(e.id))}const Tn=(e,t,n)=>En(e,t,n,`kit`);async function En(e,t,n,r){let i=[];for(let a of t){let t=An(e,a,r),o=t.length===1?t[0]:await jn(t,n,r);i.includes(o)||i.push(o)}return i}const Dn=(e,t)=>An(e,t,`skill`);function On(e,t){let n=t.lastIndexOf(`/`),r=t.slice(n+1),i=n===-1?null:t.slice(0,n).trim().toLowerCase();return e.filter(e=>e.name===r&&(i===null||e.organizationName.toLowerCase()===i||e.organizationSlug!=null&&e.organizationSlug===i))}const kn=(e,t)=>On(e,t);function An(e,t,n){let r=t.lastIndexOf(`/`),i=t.slice(r+1),a=On(e,t);if(a.length===0)throw Error(r===-1?`There's no ${n} named "${i}" in your agent kit. See them with ${L(`list`)}.`:`There's no ${n} named "${i}" in an organization called "${t.slice(0,r)}". See them with ${L(`list`)}.`);return a}async function jn(e,t,n){let r=e[0].name,i=n===`kit`?Sn:``;if(!t||!vn()){let t=e.map(e=>{let t=i+Mn(e);return L(`add ${/\s/.test(t)?`"${t}"`:t}`)});throw Error(`More than one of your organizations has a ${n} named "${r}". Say which one: ${t.join(` or `)}.`)}let a=yn(await Xt({message:`More than one of your organizations has ${n===`kit`?`kit/${r}`:`"${r}"`}. Which one?`,options:e.map(e=>({value:e.id,label:Mn(e)}))}));return e.find(e=>e.id===a)}const Mn=e=>`${e.organizationName}/${e.name}`,Nn=e=>e.showOrganization?`${e.name} (${e.organizationName})`:e.name;function B(){return(process.env.AGENT_KIT_API_URL??`https://api-dev.useagentkit.dev`??`http://localhost:8787`).replace(/\/+$/,``)}function Pn(e){let t=new URL(e);return t.hostname===`localhost`&&t.port===`8787`?`http://localhost:5173`:(t.hostname=t.hostname.replace(/^api(?:-([^.]+))?\./,(e,t)=>t?`${t}.`:``),t.origin)}function V(){return process.env.AGENT_KIT_CONFIG_DIR?process.env.AGENT_KIT_CONFIG_DIR:process.platform===`win32`&&process.env.APPDATA?_(process.env.APPDATA,`agent-kit`):_(process.env.XDG_CONFIG_HOME??_(C(),`.config`),`agent-kit`)}const Fn=()=>_(V(),`credentials.json`);async function In(){try{return JSON.parse(await O(Fn(),`utf8`))}catch{return{}}}async function H(){return(await In())[B()]??null}async function Ln(e){let t=await In();e?t[B()]=e:delete t[B()];let n=Fn();await D(g(n),{recursive:!0,mode:448}),await k(n,JSON.stringify(t,null,2)+`
76
76
  `,{mode:384}),await re(n,384)}const Rn=()=>_(V(),`settings.json`);async function U(){try{return JSON.parse(await O(Rn(),`utf8`))}catch{return{}}}async function zn(e){let t={...await U(),...e};await D(V(),{recursive:!0,mode:448}),await k(Rn(),JSON.stringify(t,null,2)+`
77
77
  `)}function Bn(e=process.env){let t=e=>e!==void 0&&[`0`,`false`,`off`,`no`].includes(e.toLowerCase());return(e=>e!==void 0&&e!==``&&!t(e))(e.DO_NOT_TRACK)||t(e.AGENT_KIT_TELEMETRY)}function W(e){let t=y(process.cwd(),e);return t&&!t.startsWith(`..`)?t:e}const Vn=/* @__PURE__ */ new Set([`.DS_Store`,`Thumbs.db`,`desktop.ini`,`.git`,`.idea`,`.vscode`,`node_modules`,`__pycache__`,`4913`]);function Hn(e){return e.split(`/`).some(e=>Vn.has(e)||/^\..*\.sw[a-p]$/.test(e)||e.endsWith(`~`)||/^#.*#$/.test(e)||e.startsWith(`.#`)||e.endsWith(`.tmp`))}const Un=e=>he(`sha256`).update(e).digest(`hex`);async function Wn(e){let t=await ce(e,{recursive:!0,withFileTypes:!0}),n=[];for(let r of t){if(!r.isFile())continue;let t=y(e,_(r.parentPath,r.name)).split(x).join(`/`);if(Hn(t))continue;let i=new Uint8Array(await O(_(e,t)));n.push({path:t,size:i.byteLength,sha256:Un(i),bytes:i})}return n.sort((e,t)=>e.path<t.path?-1:+(e.path>t.path))}function Gn(e,t){let n=new Map(t.filter(e=>!Hn(e.path)).map(e=>[e.path,e.sha256])),r=new Set(e.map(e=>e.path)),i=e.filter(e=>n.get(e.path)!==e.sha256),a=[...n.keys()].filter(e=>!r.has(e));return{upserts:i,deletes:a,paths:[...i.map(e=>e.path),...a].sort()}}function Kn(e){return e.length===0?`nothing`:e.length>3?`${e.length} files`:e.length===1?e[0]:`${e.slice(0,-1).join(`, `)} and ${e.at(-1)}`}async function qn(e,t){for(let n of e){if(!f(n))continue;let{paths:e}=Gn(await Wn(n),t);if(e.length>0)return{folder:n,paths:e}}return null}async function Jn(e,t,n,r){let i=await e.getVersion(n.id,n.version).catch(()=>null);return i?qn(r.map(e=>_(e,t)),i.files):null}async function Yn(e){try{if(!(await oe(e)).isSymbolicLink())return null}catch{return null}return b(g(e),await le(e))}async function Xn(e,t){for(let n of e){let e=await Yn(_(n,t));if(e)return e}return null}async function Zn(e,t){await de(e,{recursive:!0,force:!0}),await D(g(e),{recursive:!0}),await pe(t,e,process.platform===`win32`?`junction`:`dir`)}const G=`SKILL.md`,Qn={maxFiles:200,maxFileBytes:1048576,maxSkillBytes:10485760,maxPathLength:255},$n=/[\u0000-\u001f\u007f\\:]/;function er(e){if(e.trim()===``)return`The path is empty.`;if(e.length>Qn.maxPathLength)return`Paths can be at most ${Qn.maxPathLength} characters.`;if(e.startsWith(`/`))return`Use a relative path, without a leading /.`;if($n.test(e))return`Paths can't contain \\, : or control characters.`;for(let t of e.split(`/`)){if(t===``)return`The path has an empty folder name (//).`;if(t===`.`||t===`..`)return`The path can't contain . or .. folders.`;if(t!==t.trim())return`Names can't start or end with a space.`}return null}function tr(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function nr(e){return e.slice(e.lastIndexOf(`/`)+1)}function rr(e,t){let n=tr(e)?tr(e).split(`/`):[];for(let e of t.split(`/`))if(e!==``&&e!==`.`){if(e===`..`){if(n.length===0)return null;n.pop()}else n.push(e)}return n.join(`/`)}var K=/* @__PURE__ */ A((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),c=e=>!!e&&typeof e==`object`&&e[s]===t,l=e=>!!e&&typeof e==`object`&&e[s]===n,u=e=>!!e&&typeof e==`object`&&e[s]===r,d=e=>!!e&&typeof e==`object`&&e[s]===i,f=e=>!!e&&typeof e==`object`&&e[s]===a,p=e=>!!e&&typeof e==`object`&&e[s]===o;function m(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function h(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=e=>(f(e)||m(e))&&!!e.anchor,e.isAlias=c,e.isCollection=m,e.isDocument=l,e.isMap=u,e.isNode=h,e.isPair=d,e.isScalar=f,e.isSeq=p})),ir=/* @__PURE__ */ A((e=>{var t=K();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function a(e,n){let r=l(n);t.isDocument(e)?o(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):o(null,e,r,Object.freeze([]))}a.BREAK=n,a.SKIP=r,a.REMOVE=i;function o(e,r,a,s){let c=u(e,r,a,s);if(t.isNode(c)||t.isPair(c))return d(e,s,c),o(e,c,a,s);if(typeof c!=`symbol`){if(t.isCollection(r)){s=Object.freeze(s.concat(r));for(let e=0;e<r.items.length;++e){let t=o(e,r.items[e],a,s);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){s=Object.freeze(s.concat(r));let e=o(`key`,r.key,a,s);if(e===n)return n;e===i&&(r.key=null);let t=o(`value`,r.value,a,s);if(t===n)return n;t===i&&(r.value=null)}}return c}async function s(e,n){let r=l(n);t.isDocument(e)?await c(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await c(null,e,r,Object.freeze([]))}s.BREAK=n,s.SKIP=r,s.REMOVE=i;async function c(e,r,a,o){let s=await u(e,r,a,o);if(t.isNode(s)||t.isPair(s))return d(e,o,s),c(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await c(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await c(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await c(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function l(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function u(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function d(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=a,e.visitAsync=s})),ar=/* @__PURE__ */ A((e=>{var t=K(),n=ir();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},i=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var a=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+i(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)t===`!!`&&n===`tag:yaml.org,2002:`||e&&!a.some(e=>e.startsWith(n))||r.push(`%TAG ${t} ${n}`);return r.join(`
@@ -271,7 +271,7 @@ Only the conversation up to the developer's request to report it is sent; this p
271
271
  `)}const $o=e=>Object.keys(e.skills).length===0&&Object.keys(e.kits).length===0&&Object.keys(e.public??{}).length===0;async function es(e,t=qo,n=Date.now()){return(await U()).autoUpdate===!1||$o(await X(Y(`global`)))||!await H()||!await Yo(n)?!1:(t(e,[`auto-update`,`run`]),!0)}const ts=e=>({skills:Object.values(e.skills).map(e=>{let t=Yi(e);return t===`latest`?{id:e.id}:{id:e.id,channel:t}}),kits:Object.values(e.kits).map(e=>e.id),public:Object.values(e.public??{}).map(e=>e.ref)});async function ns(e,t,n=Jo()){try{let r=await X(Y(`global`));if($o(r))return`unchanged`;let{fingerprint:i}=await e.fingerprint(ts(r),AbortSignal.timeout(5e3));return(await Zo(n)).fingerprint===i?`unchanged`:(await t(),await Qo(n,{...await Zo(n),fingerprint:i}),`updated`)}catch{return`failed`}}const rs=6e3,is=e=>`github.com/${e.toLowerCase()}`,as=()=>_(V(),`project-repositories.json`);async function os(){try{let e=JSON.parse(await O(as(),`utf8`));return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}catch{return{}}}async function ss(e){let t=await os();t[B()]=e,await D(V(),{recursive:!0,mode:448});let n=`${as()}.${process.pid}`;await k(n,JSON.stringify(t)+`
272
272
  `),await ue(n,as())}const cs=e=>typeof e==`object`&&!!e&&!Array.isArray(e);async function ls(e){let t=(await os())[B()];return!t||t.userId!==e||typeof t.checkedAt!=`string`||typeof t.triedAt!=`string`||!cs(t.repositories)||!cs(t.skills)?null:t}async function us(e,t,n,r){let[i,a]=await Promise.all([e.listOrganizations(r),e.listSkillSummaries(r)]),o=await Promise.all(i.map(async t=>({organizationId:t.id,projects:await e.listProjects(t.id,r)}))),s={userId:t,checkedAt:n.toISOString(),triedAt:n.toISOString(),repositories:{},skills:{}};for(let{organizationId:e,projects:t}of o)for(let n of t)for(let t of n.repositories)s.repositories[is(t.fullName)]=e;for(let e of a)s.skills[e.id]=e.organizationId;return await ss(s),s}function ds(e,t,n){if(!e)return!0;let r=e=>t.getTime()-(Date.parse(e)||0);return r(e.triedAt)<36e5?!1:r(e.checkedAt)>=864e5||!!n&&!(n in e.skills)}async function fs(e,t,n,r){try{return await ss({userId:t,checkedAt:n?.checkedAt??(/* @__PURE__ */ new Date(0)).toISOString(),repositories:n?.repositories??{},skills:n?.skills??{},triedAt:r.toISOString()}),await us(e,t,r,AbortSignal.timeout(rs))}catch{return null}}async function ps(){try{if(Bn()||(await U()).telemetry===!1)return;let e=await H();if(!e)return;await us(z(B(),e.token),e.user.id,/* @__PURE__ */ new Date,AbortSignal.timeout(rs))}catch{}}async function ms(e){Wt(`agent kit`),await ps();let t=e.global?`global`:`project`,n=Y(t),r=await X(n),i=Object.entries(r.public??{});if(Object.keys(r.skills).length===0&&Object.keys(r.kits).length===0&&i.length===0){I(e.global?"No skills installed everywhere yet. Add some with `a-kit add -g`.":"No skills installed in this project yet. Add some with `a-kit add`.");return}let a=Object.keys(r.skills).length===0&&Object.keys(r.kits).length===0?z(B(),(await H())?.token):(await to()).api,o=Uo(t),s=[...Object.values(r.skills).flatMap(e=>o(e.agents)),...Object.values(r.kits).flatMap(e=>o(e.agents)),...i.flatMap(([,e])=>o(e.agents))];await Ho([...new Set(s)]);let c=0,l=0,u=0;for(let[e,t]of Object.entries(r.kits)){let i;try{i=await a.getKit(t.id)}catch(t){if(t instanceof R&&t.status===404){F.warn(`kit/${e} isn't in your agent kit anymore; left its skills as they are.`);continue}throw t}$i(r,e,i.name);try{let e=await ea(a,r,i,{agents:t.agents,dirsOf:o,reinstall:!1});for(let t of e.installed)F.success(`${t}: added to kit/${i.name}, installed`);for(let t of e.removed)F.success(`${t}: taken out of kit/${i.name}, removed`);c+=e.installed.length,l+=e.removed.length,u+=e.kept.length}finally{await Xi(n,r)}}let d=0;for(let[e,t]of Object.entries(r.skills)){let i=Yi(t),s;try{s=await a.getSkill(t.id,i)}catch(t){if(t instanceof R&&t.status===404){F.warn(`${e} isn't in your agent kit anymore; left it as it is.`);continue}throw t}if(s.version===t.version)continue;let c=o(t.agents),l=await Xn(c,e);if(l){F.warn(`${e} uses ${W(l)} (\`a-kit link\`); left it. \`a-kit add ${e}\` goes back to v${s.version}.`),u++;continue}let f=await Jn(a,e,t,c);if(f)F.warn(`${e} has edits here that aren't in agent kit (${Kn(f.paths)}); left it at v${t.version}. To keep them, make them in your organization's repository (\`a-kit link\` tries a skill from it); \`a-kit add ${e}\` throws them away.`),u++;else{if(await qi(a,t.id,c,i),s.name!==e){for(let t of c)await de(_(t,e),{recursive:!0,force:!0});delete r.skills[e]}r.skills[s.name]={...t,version:s.version},await Xi(n,r),F.success(`${s.name}: v${t.version} → v${s.version}`+(i===`latest`?``:` (${i})`)+(s.name===e?``:` (was ${e})`)),d++}}for(let[e,t]of i){let i;try{i=await a.getPublicSkill(t.ref)}catch(e){if(e instanceof R&&e.status===404){F.warn(`${t.ref} isn't public anymore; left it as it is.`);continue}throw e}if(i.version===t.version&&i.name===e)continue;if(i.name!==e&&r.skills[i.name]){F.warn(`${t.ref} is now named ${i.name}, like one of your skills; left it at v${t.version}.`);continue}let s=o(t.agents);if(await qi(Ki(a,i),t.ref,s),i.name!==e){for(let t of s)await de(_(t,e),{recursive:!0,force:!0});delete r.public[e]}r.public[i.name]={...t,version:i.version},await Xi(n,r),F.success(`${i.name}: v${t.version} → v${i.version} (${t.ref})`+(i.name===e?``:` (was ${e})`)),d++}await Ro([...new Set([...Object.values(r.skills),...Object.values(r.kits),...i.map(([,e])=>e)].flatMap(e=>e.agents))]),I(gs(d,c,l,u))}const hs=e=>`${e} skill${e===1?``:`s`}`;function gs(e,t,n,r){let i=[e&&`updated ${hs(e)}`,t&&`installed ${hs(t)}`,n&&`removed ${hs(n)}`].filter(Boolean),a=r?`Left ${hs(r)} with local edits or links as they are.`:``;if(i.length===0)return a||`Everything is up to date.`;let o=i.join(`, `);return`${o[0].toUpperCase()}${o.slice(1)}.${a&&` ${a}`}`}async function _s(e){switch(e){case`run`:{let e=await H();if(!e)return;await ns(z(B(),e.token),()=>ms({global:!0,agent:[],yes:!0,channel:`latest`}));return}case`on`:{await zn({autoUpdate:!0});let e=await No();e.status===`skipped`?F.warn(`Couldn't add the Claude Code hook: ${e.reason}.`):F.success(`Auto-update is on: when a Claude Code session starts, your global skills update if they changed.`);return}case`off`:await zn({autoUpdate:!1}),await No(),F.success("Auto-update is off. Update with `a-kit update -g`, or turn it back on with `a-kit auto-update on`.");return;case void 0:case`status`:{let e=(await U()).autoUpdate!==!1,t=(await Io()).includes(`autoUpdate`);console.log(`Auto-update is ${e?`on`:`off`}.`),console.log(`Claude Code: ${t?`checks the global skills for changes when a session starts`:`no hook installed`}.`),console.log("\nWhen a Claude Code session starts, agent kit checks in the background whether the skills and kits you installed everywhere (-g) changed, and updates them when they did. A project's skills stay as they are until you run `a-kit update` there.");return}default:throw Error(`Unknown auto-update action "${e}". Use on, off or status.`)}}function vs(e,t){let n=1;for(let r=0;r<Math.min(t,e.length);r++)e.charCodeAt(r)===10&&n++;return n}const ys=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function bs(e,t=!!process.stdout.isTTY&&!process.env.NO_COLOR){let n=(e,n)=>t?r(e,n):n;return e.map(e=>{let t=e.severity===`error`?n(`red`,`✗`):n(`yellow`,`▲`),r=e.path===null?`repository`:e.path+(e.line?`:${e.line}`:``);return`${t} ${e.message} ${n(`dim`,r)}`})}function xs(e){let t=typeof e==`string`?e.trim():``;return t?t.length>64?{ok:!1,message:`Keep the name under 64 characters.`}:/^[a-z0-9-]+$/.test(t)?t.startsWith(`-`)||t.endsWith(`-`)||t.includes(`--`)?{ok:!1,message:`The name can't start or end with a hyphen, or have two in a row.`}:{ok:!0,name:t}:{ok:!1,message:`Use only lowercase letters, numbers and hyphens in the name.`}:{ok:!1,message:`Give the kit a name.`}}const Ss=e=>`kits/${e}.yaml`;function Cs(e){let t=/^kits\/([^/]+)\.yaml$/.exec(e);return t?t[1]:null}function ws(e){let t;try{t=(0,J.parse)(e)}catch(e){let t=e instanceof Error?e.message.split(`
273
273
  `)[0]:``;return{error:`It isn't valid YAML${t?`: ${t}`:`.`}`}}if(t==null)return{skills:[]};let n="It has to list the kit's skills by name: `skills: [tdd, notes]`.";if(!Ts(t))return{error:n};let{skills:r}=t;return r==null?{skills:[]}:!Array.isArray(r)||!r.every(e=>typeof e==`string`)?{error:n}:{skills:[...new Set(r.map(e=>e.trim()))]}}const Ts=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function Es(e){let t;try{t=(0,J.parse)(e)}catch(e){let t=e instanceof Error?e.message.split(`
274
- `)[0]:``;return{error:`It isn't valid YAML${t?`: ${t}`:`.`}`}}if(t==null)return{pins:/* @__PURE__ */ new Map,problems:[]};if(!Ts(t))return{error:"It has to be a list of skills, each with its channels: `tdd: { stable: 7, beta: 9 }`."};let n={pins:/* @__PURE__ */ new Map,problems:[]};for(let[e,r]of Object.entries(t)){let t={};if(n.pins.set(e,t),r!==null){if(Ts(r))for(let[i,a]of Object.entries(r))Zt.includes(i)?Number.isInteger(a)&&Number(a)>0?t[i]=a:(t[i]=null,n.problems.push(`The ${i} channel of “${e}” has to be a version number, like 7.`)):n.problems.push(`“${e}” has a channel called “${i}”. Only stable and beta can be set.`);else{for(let e of Zt)t[e]=null;n.problems.push(`“${e}” has to have its channels, like \`{ stable: 7 }\`.`)}}}return n}const Ds=(...e)=>({words:e}),Os={text:`one`},ks={issue:{about:`an issue's state changed`,value:Ds(`opened`,`closed`,`reopened`),fields:{}},label:{about:`a label was put on an issue or a pull request, or taken off`,value:Os,fields:{on:Ds(`added`,`removed`)}},path:{about:`a pull request that changes a path was merged`,value:Os,fields:{on:Ds(`merged`)}},"pull-request":{about:`a pull request was opened, marked ready, merged or closed`,value:Ds(`opened`,`ready`,`merged`,`closed`),fields:{base:Os,head:Os}},review:{about:`a pull request got a review`,value:Ds(`approved`,`changes-requested`,`commented`),fields:{by:{text:`many`}},roles:[`by`]},checks:{about:`a pull request's checks finished`,value:Ds(`passed`,`failed`),fields:{}},release:{about:`a release was published`,value:Ds(`published`),fields:{}},skill:{about:`an agent loaded a skill`,value:Os,fields:{}},branch:{about:`a branch got its first commit`,value:Ds(`first-commit`),fields:{}}},As=Object.keys(ks),js=e=>Object.hasOwn(ks,e),Ms=(e,t=`and`)=>e.length<=1?e[0]??``:`${e.slice(0,-1).join(`, `)} ${t} ${e.at(-1)}`,Ns=`flows`,Ps=[`epic`,`ticket`,`pull-request`],Fs=[`paths`,`labels`];function Is(e){let t=/^flows\/([^/]+)\.yaml$/.exec(e);return t?t[1]:null}function Ls(e){return e.length===0?`It's empty.`:e.length>64?`It's longer than 64 characters.`:/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e)?null:`Use only lowercase letters, numbers and single hyphens, not at the start or the end.`}function Rs(e){let t=Ls(e);return t===null?null:`“${e}” can't be a flow's name, so this file isn't read. ${t}`}const zs=[`name`,`description`,`stations`],Bs=[`id`,`unit`,`signal`,`owner`,`before`,`when`];function Vs(e){let t=[],n=[],r=(0,J.parseDocument)(e,{prettyErrors:!1}),i=t=>t&&typeof t==`object`&&`range`in t&&t.range?vs(e,t.range[0]):null,a=(e,n)=>{t.push({line:i(e),message:n})},o=(e,t)=>{n.push({name:e,line:i(t)})};if(r.errors.length>0){for(let n of r.errors)t.push({line:vs(e,n.pos[0]),message:`It isn't valid YAML: ${n.message.split(`
274
+ `)[0]:``;return{error:`It isn't valid YAML${t?`: ${t}`:`.`}`}}if(t==null)return{pins:/* @__PURE__ */ new Map,problems:[]};if(!Ts(t))return{error:"It has to be a list of skills, each with its channels: `tdd: { stable: 7, beta: 9 }`."};let n={pins:/* @__PURE__ */ new Map,problems:[]};for(let[e,r]of Object.entries(t)){let t={};if(n.pins.set(e,t),r!==null){if(Ts(r))for(let[i,a]of Object.entries(r))Zt.includes(i)?Number.isInteger(a)&&Number(a)>0?t[i]=a:(t[i]=null,n.problems.push(`The ${i} channel of “${e}” has to be a version number, like 7.`)):n.problems.push(`“${e}” has a channel called “${i}”. Only stable and beta can be set.`);else{for(let e of Zt)t[e]=null;n.problems.push(`“${e}” has to have its channels, like \`{ stable: 7 }\`.`)}}}return n}const Ds=(...e)=>({words:e}),Os={text:`one`},ks={issue:{about:`an issue's state changed: it was opened, closed or reopened, or it moved to a status the flow names`,value:Os,fields:{}},label:{about:`a label was put on an issue or a pull request, or taken off`,value:Os,fields:{on:Ds(`added`,`removed`)}},path:{about:`a pull request that changes a path was merged`,value:Os,fields:{on:Ds(`merged`)}},"pull-request":{about:`a pull request was opened, marked ready, merged or closed`,value:Ds(`opened`,`ready`,`merged`,`closed`),fields:{base:Os,head:Os}},review:{about:`a pull request got a review`,value:Ds(`approved`,`changes-requested`,`commented`),fields:{by:{text:`many`}},roles:[`by`]},checks:{about:`a pull request's checks finished`,value:Ds(`passed`,`failed`),fields:{}},release:{about:`a release was published`,value:Ds(`published`),fields:{}},skill:{about:`an agent loaded a skill`,value:Os,fields:{}},branch:{about:`a branch got its first commit`,value:Ds(`first-commit`),fields:{}}},As=Object.keys(ks),js=e=>Object.hasOwn(ks,e),Ms=(e,t=`and`)=>e.length<=1?e[0]??``:`${e.slice(0,-1).join(`, `)} ${t} ${e.at(-1)}`,Ns=`flows`,Ps=[`epic`,`ticket`,`pull-request`],Fs=[`paths`,`labels`];function Is(e){let t=/^flows\/([^/]+)\.yaml$/.exec(e);return t?t[1]:null}function Ls(e){return e.length===0?`It's empty.`:e.length>64?`It's longer than 64 characters.`:/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e)?null:`Use only lowercase letters, numbers and single hyphens, not at the start or the end.`}function Rs(e){let t=Ls(e);return t===null?null:`“${e}” can't be a flow's name, so this file isn't read. ${t}`}const zs=[`name`,`description`,`stations`],Bs=[`id`,`unit`,`signal`,`owner`,`before`,`when`];function Vs(e){let t=[],n=[],r=(0,J.parseDocument)(e,{prettyErrors:!1}),i=t=>t&&typeof t==`object`&&`range`in t&&t.range?vs(e,t.range[0]):null,a=(e,n)=>{t.push({line:i(e),message:n})},o=(e,t)=>{n.push({name:e,line:i(t)})};if(r.errors.length>0){for(let n of r.errors)t.push({line:vs(e,n.pos[0]),message:`It isn't valid YAML: ${n.message.split(`
275
275
  `)[0]}`});return{flow:null,problems:t,roles:n}}let s=Hs(r,r.contents);if(s===null||(0,J.isScalar)(s)&&s.value===null)return t.push({line:null,message:"It's empty. A flow lists its stations: `stations: [{ id: review, unit: pull-request, signal: { review: approved } }]`."}),{flow:null,problems:t,roles:n};if(!(0,J.isMap)(s))return a(s,"A flow has to be a mapping, with its `stations`."),{flow:null,problems:t,roles:n};let c=Us(r,s,zs,`A flow`,a),l=c.has(`name`)?Ws(c.get(`name`),"Its `name`",a):null,u=c.has(`description`)?Ws(c.get(`description`),"Its `description`",a):null,d=c.get(`stations`),f=[],p=[];if(!d)a(s,"It has no `stations`: a flow lists them in order.");else if(!(0,J.isSeq)(d.value)||d.value.items.length===0)a(d.value??d.key,"Its `stations` have to be a list, with one station at least.");else if(d.value.items.length>100)a(d.key,`A flow has at most 100 stations, and this one has ${d.value.items.length}.`);else{let e=/* @__PURE__ */ new Map;d.value.items.forEach((t,n)=>{let s=Hs(r,t),c=`Station ${n+1}`;if(!(0,J.isMap)(s)){a(s??d.value,`${c} has to be a mapping, with its \`id\`, \`unit\` and \`signal\`.`);return}let l=Us(r,s,Bs,c,a),u=l.get(`id`),m=null;if(!u)a(s,`${c} has no \`id\`. Give it one that stays the same, like \`review\`.`);else{m=Ws(u,`The \`id\` of ${c.toLowerCase()}`,a);let t=m===null?null:Ls(m);if(m!==null&&t)a(u.value,`“${m}” can't be a station's id. ${t}`),m=null;else if(m!==null&&e.has(m)){let t=e.get(m);a(u.value,`There's another station with the id “${m}”${t?` (line ${t})`:``}. Each station's id has to be its own.`),m=null}else m!==null&&e.set(m,i(u.value))}let h=m?`Station “${m}”`:c,g=l.get(`unit`),_=null;if(!g)a(s,`${h} has no \`unit\`: say whether it's counted for an \`epic\`, a \`ticket\` or a \`pull-request\`.`);else{let e=Ws(g,`The \`unit\` of ${h.toLowerCase()}`,a);e!==null&&(Ps.includes(e)?_=e:a(g.value,`“${e}” isn't a unit. A station is counted for an epic, a ticket or a pull-request.`))}let v=l.get(`signal`),y=null;v?y=Ks(r,v.value,h,a,o):a(s,`${h} has no \`signal\`: say how agent kit knows it happened, like \`{ review: approved }\`.`);let b=l.has(`owner`)?Gs(r,l.get(`owner`),`The \`owner\` of ${h.toLowerCase()}`,`a role`,a,o):[],x=[],S=l.get(`before`);if(S){let e=Hs(r,S.value),t=(0,J.isSeq)(e)?e.items.map(e=>Hs(r,e)):[e];for(let e of t){let t=(0,J.isScalar)(e)&&(typeof e.value==`string`||typeof e.value==`number`)?String(e.value).trim():``;t?(x.push(t),p.push({station:m??``,node:e,id:t})):a(e??S.key,`The \`before\` of ${h.toLowerCase()} has to be a station's id, or a list of them.`)}}let C=l.has(`when`)?Xs(r,l.get(`when`),h,a):null;m!==null&&_!==null&&y!==null&&b!==null&&C!==void 0&&f.push({id:m,unit:_,signals:y,owner:b,before:x,when:C})});for(let{station:t,node:n,id:r}of p)r===t?a(n,`Station “${t}” can't come before itself.`):e.has(r)||a(n,`There's no station “${r}” in this flow, so nothing can come before it.`)}return t.sort((e,t)=>(e.line??0)-(t.line??0)),n.sort((e,t)=>(e.line??0)-(t.line??0)),{flow:t.length===0?{name:l,description:u,stations:f}:null,problems:t,roles:n}}const Hs=(e,t)=>t==null?null:(0,J.isAlias)(t)?t.resolve(e)??null:t;function Us(e,t,n,r,i){let a=/* @__PURE__ */ new Map;if(!(0,J.isMap)(t))return a;for(let o of t.items){let s=Hs(e,o.key),c=(0,J.isScalar)(s)?String(s.value):null;c===null||!n.includes(c)?i(s??t,`${r} doesn't take \`${c??`?`}\`. It takes ${Ms(n.map(e=>`\`${e}\``))}.`):a.set(c,{key:s,value:Hs(e,o.value)})}return a}function Ws(e,t,n){let{value:r}=e;return(0,J.isScalar)(r)&&(typeof r.value==`string`||typeof r.value==`number`)&&String(r.value).trim()!==``?String(r.value).trim():(n(r??e.key,`${t} has to be some text.`),null)}function Gs(e,t,n,r,i,a){let o=Hs(e,t.value),s=(0,J.isSeq)(o)?o.items.map(t=>Hs(e,t)):[o],c=[];for(let e of s){if(!(0,J.isScalar)(e)||typeof e.value!=`string`&&typeof e.value!=`number`||String(e.value).trim()===``)return i(e??t.key,`${n} has to be ${r}, or a list of them.`),null;c.push(String(e.value).trim())}return c.forEach((e,t)=>a?.(e,s[t])),c.length===0?(i(o??t.key,`${n} has to be ${r}, or a list of them.`),null):c}function Ks(e,t,n,r,i){let a=(0,J.isSeq)(t)?t.items.map(t=>Hs(e,t)):[t];if(a.length===0)return r(t,`The \`signal\` of ${n.toLowerCase()} is an empty list: give it one at least.`),null;let o=[],s=!0;for(let t of a){let a=Js(e,t,n,r,i);a?o.push(a):s=!1}return s?o:null}const qs=Ms(As.map(e=>`\`${e}\``));function Js(e,t,n,r,i){if(!(0,J.isMap)(t))return r(t,`A signal of ${n.toLowerCase()} has to be a mapping that starts with its kind, like \`{ review: approved }\`. The kinds are ${qs}.`),null;let a=t.items.map(t=>{let n=Hs(e,t.key);return{key:n,name:(0,J.isScalar)(n)?String(n.value):`?`,value:Hs(e,t.value)}}),o=a.filter(e=>js(e.name));if(o.length===0){let[e]=a;return r(e?.key??t,e?`“${e.name}” isn't a kind of signal. The kinds are ${qs}.`:`A signal of ${n.toLowerCase()} is empty. Start it with its kind: ${qs}.`),null}if(o.length>1)return r(o[1].key,`A signal is of one kind, and this one has ${Ms(o.map(e=>`\`${e.name}\``))}. To take any of them, make \`signal\` a list.`),null;let s=o[0].name,c=ks[s],l=!0,u=Ys(o[0].value,c.value,`\`${s}\``,o[0].key,r);(u===null||Array.isArray(u))&&(l=!1);let d={},f=Object.keys(c.fields);for(let e of a){if(e.name===s)continue;let t=c.fields[e.name];if(!t){r(e.key,f.length===0?`A \`${s}\` signal takes no other field, and this one has \`${e.name}\`.`:`A \`${s}\` signal doesn't take \`${e.name}\`. It takes ${Ms(f.map(e=>`\`${e}\``))}.`),l=!1;continue}let n=Ys(e.value,t,`\`${e.name}\``,e.key,r);if(n===null)l=!1;else if(d[e.name]=n,c.roles?.includes(e.name)){let t=(0,J.isSeq)(e.value)?e.value.items:[e.value];(Array.isArray(n)?n:[n]).forEach((n,r)=>i(n,t[r]??e.key))}}return l?{kind:s,value:u,fields:d}:null}function Ys(e,t,n,r,i){let a=e=>(0,J.isScalar)(e)&&(typeof e.value==`string`||typeof e.value==`number`)&&String(e.value).trim()!==``?String(e.value).trim():null;if(`words`in t){let o=a(e);return o!==null&&t.words.includes(o)?o:(i(e??r,`${n} has to be ${Ms(t.words.map(e=>`\`${e}\``),`or`)}${o===null?``:`, not “${o}”`}.`),null)}if(t.text===`many`&&(0,J.isSeq)(e)){let t=e.items.map(e=>a(e));return t.length>0&&t.every(e=>e!==null)?t:(i(e,`${n} has to be a name, or a list of them.`),null)}let o=a(e);return o===null?(i(e??r,`${n} has to be ${t.text===`many`?`a name, or a list of them`:`some text`}.`),null):o}function Xs(e,t,n,r){let i=t.value;if(!(0,J.isMap)(i)){r(i??t.key,`The \`when\` of ${n.toLowerCase()} has to be a mapping, like \`{ paths: [docs] }\`.`);return}let a=Us(e,i,Fs,`The \`when\` of ${n.toLowerCase()}`,r);if(a.size!==i.items.length)return;let o={};for(let[t,n]of a){let i=Gs(e,n,`\`${t}\``,`a name`,r);if(i===null)return;o[t]=i}return o}const Zs=new Map([{key:`name`,scope:`standard`,kind:`string`,required:!0,summary:`The skill's id and its /command. 1–64 lowercase letters, numbers and single hyphens.`},{key:`description`,scope:`standard`,kind:`string`,required:!0,summary:`What the skill does and when to use it. The agent reads it to decide when to load the skill. Up to 1024 characters.`},{key:`license`,scope:`standard`,kind:`string`,summary:`A license name, or the path of a license file in the skill.`},{key:`compatibility`,scope:`standard`,kind:`string`,summary:`Environment the skill needs (tools, network, OS). Up to 500 characters; only add it when it matters.`},{key:`metadata`,scope:`standard`,kind:`map`,summary:`Extra key: value pairs, both strings (author, version…).`,snippet:`
276
276
  author: `},{key:`allowed-tools`,scope:`standard`,kind:`tools`,summary:"Space-separated tools the skill may use without asking, like `Bash(git:*) Read`. Experimental."},{key:`when_to_use`,scope:`claude-code`,kind:`string`,summary:`More on when to use the skill, appended to the description in Claude Code's listing.`},{key:`argument-hint`,scope:`claude-code`,kind:`string`,summary:"Hint shown when typing the /command, like `[issue-number]`."},{key:`arguments`,scope:`claude-code`,kind:`tools`,summary:`Names for the /command's arguments, in order; use them as $name in the body.`},{key:`disable-model-invocation`,scope:`claude-code`,kind:`boolean`,summary:`true: only you can run it with its /command; Claude won't load it.`,snippet:`true`},{key:`user-invocable`,scope:`claude-code`,kind:`boolean`,summary:`false: hide it from the / menu, so only Claude loads it.`,snippet:`false`},{key:`disallowed-tools`,scope:`claude-code`,kind:`tools`,summary:`Tools taken away while the skill runs.`},{key:`model`,scope:`claude-code`,kind:`string`,summary:"Model to use while the skill runs, or `inherit`."},{key:`effort`,scope:`claude-code`,kind:{oneOf:[`low`,`medium`,`high`,`xhigh`,`max`]},summary:`Reasoning effort while the skill runs.`},{key:`context`,scope:`claude-code`,kind:{oneOf:[`fork`]},summary:"`fork` runs the skill in a subagent with its own context.",snippet:`fork`},{key:`agent`,scope:`claude-code`,kind:`string`,summary:"Subagent type to run in, with `context: fork`."},{key:`background`,scope:`claude-code`,kind:`boolean`,summary:"With `context: fork`, whether the subagent runs in the background."},{key:`hooks`,scope:`claude-code`,kind:`any`,summary:`Hooks registered while the skill is in use.`},{key:`paths`,scope:`claude-code`,kind:`tools`,summary:`Globs; Claude offers the skill when working on matching files.`},{key:`shell`,scope:`claude-code`,kind:{oneOf:[`bash`,`powershell`]},summary:"Shell for !`command` blocks in the body."}].map(e=>[e.key,e])),Qs=1024,$s=1536,ec=[`anthropic`,`claude`],tc=/<\/?[A-Za-z][^>]*>/;function nc(e){let t=[];e.files.length>Qn.maxFiles&&t.push(dc(`A skill can have at most ${Qn.maxFiles} files.`));let n=0,r=/* @__PURE__ */ new Set;for(let i of e.files){n+=i.size;let e=er(i.path);e&&t.push({severity:`error`,path:i.path,message:e}),r.has(i.path)&&t.push({severity:`error`,path:i.path,message:`Duplicate path.`}),r.add(i.path),i.size>Qn.maxFileBytes&&t.push({severity:`error`,path:i.path,message:`Files can be at most ${mc(Qn.maxFileBytes)}.`})}for(let e of r){let n=e.split(`/`);for(let i=1;i<n.length;i++){let a=n.slice(0,i).join(`/`);r.has(a)&&t.push({severity:`error`,path:a,message:`${a} is a file, so it can't also be the folder of ${e}.`})}}return n>Qn.maxSkillBytes&&t.push(dc(`The whole skill can be at most ${mc(Qn.maxSkillBytes)}.`)),e.skillMd===null?(t.push(dc(`Every skill needs a ${G} at its root.`)),t):(t.push(...rc(e.skillMd,r,e.skills)),t)}function rc(e,t,n){let r=[],i=(e,t,n,i,a)=>r.push({severity:e,path:G,message:t,from:n,to:i,fix:a}),a=xi(e);if(!a.ok)return a.reason===`unclosed`?i(`error`,`The frontmatter has no closing --- line.`,0,3):i(`error`,`${G} must start with frontmatter: a --- line, name and description, and another --- line.`,0,Math.min(e.indexOf(`
277
277
  `)===-1?e.length:e.indexOf(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "useakit",
3
- "version": "0.2.0-dev.111",
3
+ "version": "0.2.0-dev.112",
4
4
  "description": "Install your agent kit skills into Claude Code, Codex, Cursor and Gemini CLI.",
5
5
  "keywords": [
6
6
  "agent-kit",