@kaisers-io/refs 0.8.2 → 0.8.3

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 CHANGED
@@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.8.3] - 2026-08-12
11
+
12
+ ### Added
13
+
14
+ - The skill states a trust boundary. Everything inside a managed checkout is untrusted third-party
15
+ content — README, comments, commit messages, and any `AGENTS.md` or `CLAUDE.md` a tracked repo
16
+ ships — so it is evidence to read and never instruction to follow. Documentation stays evidence,
17
+ including a repo's own contributor and agent docs; what goes to the user as a finding is content
18
+ targeting the agent that reads it. Both worker flows carry the rule into their prompts. This
19
+ narrows the blast radius of indirect prompt injection; it is not a sandbox, and SECURITY.md says
20
+ so.
21
+
22
+ ### Changed
23
+
24
+ - The skill installs nothing. Its capability gate used to ask permission and then run
25
+ `npm i -g @kaisers-io/refs` itself; it now prints the command — pinned to the version the skill
26
+ was written against, not `@latest` — and stops until the user has run it. A skill that installs
27
+ the executable giving it its capabilities is a bootstrap trust boundary worth keeping explicit,
28
+ and Anthropic's skill documentation discourages global installs from a skill.
29
+
30
+ - The `--json` examples in the skill's command reference use placeholder repositories
31
+ (`example-org/…`) instead of real third-party ones, and say up front that they are illustrative
32
+ output rather than repositories the skill fetches.
33
+
10
34
  ## [0.8.2] - 2026-08-10
11
35
 
12
36
  ### Fixed
@@ -409,7 +433,8 @@ trusted-publishing pipeline end to end.
409
433
  installed git hooks.
410
434
  - Agent skill (`skills/refs/`) documenting the investigate/add/maintain workflows.
411
435
 
412
- [Unreleased]: https://github.com/kaisers-io/refs/compare/v0.8.2...HEAD
436
+ [Unreleased]: https://github.com/kaisers-io/refs/compare/v0.8.3...HEAD
437
+ [0.8.3]: https://github.com/kaisers-io/refs/compare/v0.8.2...v0.8.3
413
438
  [0.8.2]: https://github.com/kaisers-io/refs/compare/v0.8.1...v0.8.2
414
439
  [0.8.1]: https://github.com/kaisers-io/refs/compare/v0.8.0...v0.8.1
415
440
  [0.8.0]: https://github.com/kaisers-io/refs/compare/v0.7.0...v0.8.0
package/dist/refs.mjs CHANGED
@@ -347,7 +347,7 @@ sync_ttl = "1h"
347
347
  `).map(e=>e.trim()).filter(e=>e!==``).slice(0,n),Ac=async(e,t,n)=>(await e.run(`git`,[`show-ref`,`--verify`,`--`,`refs/tags/${n}`],{cwd:t})).exitCode===0,jc=[`#!/bin/sh`,`echo "refs: this checkout is a managed read-only reference — commits are blocked" >&2`,`exit 1`,``].join(`
348
348
  `),Mc=async e=>{await Promise.all([`pre-commit`,`pre-push`].map(async n=>{let r=h(e.hooksDir,n);await Bs(r,jc),await t(r,493)}))},Nc=/\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?/u,Pc=/\d+\.\d+\.\d+/gu,Fc=e=>ts.safeParse(e).success,Ic=e=>{let t=e.match(Pc);return t!==null&&t.length>1},Lc=e=>{let t=Nc.exec(e);if(!t||Ic(e))return;let[n]=t,r=e.replace(n,`{version}`);if(Fc(r))return r},Rc=(e,t,n)=>{let r=e.get(t);r===void 0?e.set(t,{count:1,index:n}):r.count+=1},zc=e=>{let t=new Map;for(let[n,r]of e.entries()){let e=Lc(r);e&&Rc(t,e,n)}return t},Bc=(e,t)=>e.count>t.count||e.count===t.count&&e.index<t.index,Vc=e=>{let t=[...e.entries()],[n]=t;if(n===void 0)return null;let[r,i]=n;return t.slice(1).reduce(({format:e,data:t},[n,r])=>Bc(r,t)?{data:r,format:n}:{data:t,format:e},{data:i,format:r}).format},Hc=e=>{let t=zc(e);return Vc(t)},Uc=(e,t)=>e.replaceAll(`{version}`,()=>t),Wc=async(e,t,n,r)=>{let i=Uc(n,r);if(!await Ac(e,t,i))throw y(`tag '${i}' not found in ${t} — check the version or tag_format`);return i},Gc=/^(?<scheme>[a-z][a-z0-9+.-]*:\/\/)?[\s\S]*@/iu,q=e=>{let t=e.replace(Gc,`$<scheme><redacted>@`);return t.length<=200?t:`${t.slice(0,200)}…`},Kc=/\.git$/u,qc=e=>e.replace(Kc,``),Jc=e=>{let t=0,n=e.length;for(;t<n&&e.charAt(t)===`/`;)t+=1;for(;n>t&&e.charAt(n-1)===`/`;)--n;return e.slice(t,n)},Yc=/^git@(?<host>[^:/\s]+):(?<path>[^\s]+)$/u,Xc=/^git\+/u,Zc={"https:":`443`,"ssh:":`22`},Qc=e=>e.split(`/`).some(e=>e===`.`||e===`..`),$c=e=>e.includes(`\\`),el=e=>e.includes(`%`),tl=e=>{let t=z.safeParse(e);if(!t.success)throw x(`not a supported git url: derived key '${q(e)}' is invalid`);return t.data},nl=({host:e,port:t,protocol:n})=>{let r=Zc[n];return t===``||t===r?e.toLowerCase():`${e.toLowerCase()}_${t}`},rl=e=>{let t=qc(Jc(e.path));return tl(`${nl(e)}/${t}`)},il=e=>{let t=decodeURIComponent(e).split(`/`).filter(e=>e!==``);if(t.length<2)throw x(`not a supported git url: file url path must have at least 2 segments`);let n=t.at(-2)??``,r=t.at(-1)??``;return tl(`local/${n}/${r}`)},al=(e,t)=>{try{return new URL(e)}catch{throw x(`not a supported git url: ${q(t)}`)}},ol=e=>{if(e.password!==``)throw x(`not a supported git url: credentials embedded in url`);if(e.protocol===`https:`&&e.username!==``)throw x(`not a supported git url: credentials embedded in https url`)},sl=(e,t)=>{if(e.protocol===`file:`){if(!t)throw x(`not a supported git url: unsupported protocol ${e.protocol}`);return il(e.pathname)}if(e.protocol!==`https:`&&e.protocol!==`ssh:`)throw x(`not a supported git url: unsupported protocol ${e.protocol}`);return ol(e),rl({host:e.hostname,path:e.pathname,port:e.port,protocol:e.protocol})},cl=(e,t)=>{if(el(e))throw x(`not a supported git url: percent-encoding not supported in ${q(t)}`);if(e.includes(`:`))throw x(`not a supported git url: ambiguous ':' in scp-style path ${q(t)}; use the ssh:// url form instead`);if(e.startsWith(`/`)||e.startsWith(`~`))throw x(`not a supported git url: ambiguous absolute/home-relative scp path in ${q(t)}; use the ssh:// url form instead`)},ll=(e,t)=>{let n=e.groups?.path??``;return cl(n,t),rl({host:e.groups?.host??``,path:n,port:``,protocol:`ssh:`})},ul=(e,t)=>{if($c(e))throw x(`not a supported git url: backslash not allowed in ${q(t)}`)},dl=(e,t)=>{if(Qc(e))throw x(`not a supported git url: path traversal segment in ${q(t)}`)},fl=(e,t,n)=>{if(e.protocol!==`file:`&&el(t))throw x(`not a supported git url: percent-encoding not supported in ${q(n)}`)},pl=(e,t)=>{let n=t?.allowFileUrls??!1,r=e.replace(Xc,``);ul(r,e),dl(r,e);let i=Yc.exec(r);if(i?.groups!==void 0)return{cloneUrl:r,key:ll(i,e)};let a=al(r,e);return fl(a,r,e),{cloneUrl:r,key:sl(a,n)}},ml=`.git`,hl=e=>e.endsWith(ml)?e:`${e}${ml}`,gl=(e,t)=>`https://${e.toLowerCase()}/${Jc(t)}`,_l=(e,t)=>`git@${e.toLowerCase()}:${hl(Jc(t))}`,vl=e=>{if(e===`https:`)return`https`;if(e===`ssh:`)return`ssh`;throw x(`not a supported git url: unsupported protocol ${e}`)},yl=(e,t,n)=>{let r=Zc[e.protocol];if(e.port!==``&&e.port!==r)throw x(`cannot apply git_transport=${t} to ${q(n)}: its non-default port ${e.port} cannot be expressed in the ${t} url form — add the repo with an explicit url instead`)},bl=(e,t)=>t===`https`?gl(e.hostname,e.pathname):_l(e.hostname,e.pathname),xl=(e,t,n)=>{let r=pl(t).key;if(r!==n)throw x(`git_transport transform changed repo identity: '${q(e)}' → '${t}' (key '${n}' → '${r}')`);return t},Sl=(e,t)=>{if(t.transport===`ssh`)return t.cloneUrl;let n=e.groups?.host??``,r=e.groups?.path??``;return xl(t.cloneUrl,gl(n,r),t.originalKey)},Cl=e=>{let t=al(e.cloneUrl,e.cloneUrl);return vl(t.protocol)===e.transport?e.cloneUrl:(yl(t,e.transport,e.cloneUrl),xl(e.cloneUrl,bl(t,e.transport),e.originalKey))},wl=(e,t)=>{if(e.startsWith(`file:`))return e;let n={cloneUrl:e,originalKey:pl(e).key,transport:t},r=Yc.exec(e);return r?.groups===void 0?Cl(n):Sl(r,n)},Tl=`meta.json`,El=e=>{if(typeof e==`object`&&e&&`code`in e){let{code:t}=e;if(typeof t==`string`)return t}},Dl=e=>{try{return process.kill(e,0),!0}catch(e){return El(e)!==`ESRCH`}},Ol=e=>{try{return JSON.parse(e)}catch{return}},kl=async e=>{try{return await o(e,`utf8`)}catch{return}},Al=e=>{if(typeof e!=`string`)return;let t=Date.parse(e);if(!Number.isNaN(t))return t},jl=e=>{if(typeof e!=`object`||!e)return;let t=e,{pid:n}=t,r=Al(t.acquired_at);if(typeof n==`number`&&r!==void 0)return{acquiredAtMs:r,pid:n}},Ml=async e=>{let t=await kl(h(e,Tl));if(t!==void 0)return jl(Ol(t))},Nl=e=>{if(typeof e!=`object`||!e)return;let{token:t}=e;if(typeof t==`string`)return t},Pl=async e=>{let t=await kl(h(e,Tl));if(t!==void 0)return Nl(Ol(t))},Fl=async e=>{try{return(await f(e)).mtimeMs}catch{return}},Il=async(e,t)=>{let n=h(e,Tl),r=`${n}.tmp-${se()}`;await p(r,t,`utf8`),await l(r,n)},Ll=async(e,t)=>{await Il(e,JSON.stringify({acquired_at:new Date().toISOString(),pid:process.pid,token:t}))},Rl=new Set([`EEXIST`,`EPERM`,`EACCES`,`EBUSY`]),zl=new Set([`ENOENT`,`EPERM`,`EACCES`,`EBUSY`]),Bl=async e=>{try{return await a(e,{recursive:!1}),!0}catch(e){let t=El(e);if(t!==void 0&&Rl.has(t))return!1;throw e}},Vl=async(e,t)=>{try{return await l(e,t),!0}catch(e){let t=El(e);if(t!==void 0&&zl.has(t))return!1;throw e}},Hl=/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/u,Ul=async e=>{let t=await Ml(e);if(t===void 0){let t=await Fl(e);return t!==void 0&&Date.now()-t>5e3}return Date.now()-t.acquiredAtMs>6e5||!Dl(t.pid)},Wl=async(e,t)=>{try{await Ll(e,t)}catch(e){if(El(e)===`ENOENT`)return`retry`;throw e}return t},Gl=async(e,t)=>{if(!await Bl(e))return;let n=await Wl(e,se());return n===`retry`?Date.now()>=t?void 0:Gl(e,t):n},Kl=e=>h(e.locksDir,`${e.name}.steal-claim`),ql=e=>h(e.locksDir,`${e.name}.steal.${se()}`),Jl=async e=>{let t=await Fl(e);return t!==void 0&&Date.now()-t>2e3},Yl=async e=>await Bl(e)?!0:await Jl(e)?(await u(e,{force:!0,recursive:!0}),Bl(e)):!1,Xl=async e=>{let t=ql(e);return await Vl(e.lockPath,t)?t:void 0},Zl=async e=>{if(!await Ul(e.lockPath))return!1;let t=await Xl(e);return t!==void 0&&(await u(t,{force:!0,recursive:!0}),!0)},Ql=async e=>{let t=Kl(e);if(!await Yl(t))return!1;try{return await Zl(e)}finally{await u(t,{force:!0,recursive:!0})}},$l=async(e,t)=>{if(!(await Ul(e.lockPath)&&await Ql(e))){if(Date.now()>=t)throw ve(`lock ${e.name} is held — another refs process is running`);await fe(100)}},eu=async(e,t)=>{let n=await Gl(e.lockPath,t);return n===void 0?(await $l(e,t),eu(e,t)):n},tu=async(e,t)=>{await Pl(e)===t&&await u(e,{force:!0,recursive:!0})},nu=e=>{if(e===`.`||e===`..`||!Hl.test(e))throw x(`lock name must not contain "/" or other unsafe characters — only letters, digits, and "_.-" are allowed, and it may not be "." or "..": ${e}`)},J=async(e,t,n,r)=>{nu(t);let i={lockPath:h(e.locksDir,t),locksDir:e.locksDir,name:t};await a(e.locksDir,{recursive:!0});let o=Date.now()+(r?.timeoutMs??1e4),s=await eu(i,o);try{return await n()}finally{await tu(i.lockPath,s)}},ru=ro({directory:I().optional(),url:I().optional()}),iu=ro({repository:ao([I(),ru]).optional()}),au=/^(?:@[a-z0-9-~][a-z0-9._~-]*\/)?[a-z0-9-~][a-z0-9._~-]*$/u,ou=new Set([`node_modules`,`favicon.ico`]),su=e=>y(`package '${e}' has no usable repository field — find the repository and run: refs add <git-url>`),cu=e=>{let[t,n]=e.split(`/`);return n??t??e},lu=e=>{if(e.length>214)throw b(`invalid package name: '${e}' exceeds maximum length of 214 characters`);if(!au.test(e))throw b(`invalid package name: '${e}' does not match npm naming rules`);let t=cu(e);if(ou.has(t))throw b(`invalid package name: '${e}' uses a reserved name`)},uu=e=>e.replaceAll(`/`,`%2F`),du=e=>typeof e==`string`?e:e?.url,fu=e=>{if(typeof e==`object`&&e?.directory){let t=ns.safeParse(e.directory);if(t.success)return t.data}},pu=async(e,t)=>{try{return await e.json()}catch{throw x(`invalid npm registry response for '${t}': not parseable JSON`)}},mu=async(e,t)=>{let n=await e(`https://registry.npmjs.org/${uu(t)}`);if(n.status===404)throw y(`npm package '${t}' not found`);if(n.status!==200)throw x(`failed to fetch npm package '${t}': status ${n.status}`);let r=await pu(n,t),i=iu.safeParse(r);if(!i.success)throw x(`invalid npm package response for '${t}'`);return i.data},hu=(e,t)=>{try{return pl(e)}catch{throw su(t)}},gu=async(e,t)=>{lu(t);let n=await mu(e,t),r=du(n.repository);if(r===void 0||r===``)throw su(t);let{cloneUrl:i,key:a}=hu(r,t),o=fu(n.repository);return o===void 0?{cloneUrl:i,key:a}:{cloneUrl:i,directory:o,key:a}},_u=new Set;let vu=!1;const yu=()=>{for(let e of _u)try{e.kill(`SIGKILL`)}catch{}},bu=[`SIGINT`,`SIGTERM`,`SIGHUP`,`SIGBREAK`],xu=e=>{let t=()=>{yu(),process.removeListener(e,t),process.kill(process.pid,e)};process.on(e,t)},Su=()=>{vu||(vu=!0,bu.forEach(e=>{xu(e)}),process.on(`exit`,yu))},Cu=()=>{let e=[],t=0,n=!1;return{finish:()=>({text:Buffer.concat(e).toString(`utf8`),truncated:n}),push:r=>{if(n)return;let i=67108864-t;if(r.length<=i){e.push(r),t+=r.length;return}i>0&&e.push(r.subarray(0,i)),n=!0}}},wu=(e,t)=>[e.replace(/\r?\n$/u,``),t].filter(e=>e!==``).join(`
349
349
  `),Tu=(e,t,n)=>{let r=e;return t.truncated&&(r=wu(r,`refs: stdout exceeded 67108864 bytes, truncated`)),n.truncated&&(r=wu(r,`refs: stderr exceeded 67108864 bytes, truncated`)),r},Eu={clear:()=>{},markedTimedOut:()=>!1},Du=(e,t)=>{if(t===void 0)return Eu;let n=!1,r,i=setTimeout(()=>{n=!0,e.kill(`SIGTERM`),r=setTimeout(()=>{e.kill(`SIGKILL`)},2e3)},t);return{clear:()=>{clearTimeout(i),r!==void 0&&clearTimeout(r)},markedTimedOut:()=>n}},Ou=e=>e===void 0?{}:{cwd:e},ku=(e,t)=>wu(e,`refs: command timed out after ${String(t)}ms`),Au=(e,t)=>({exitCode:124,stderr:ku(e,t),stdout:``,timedOut:!0}),ju=(e,t,n)=>{let r=ge(e,t,{...Ou(n?.cwd),stdio:[`ignore`,`pipe`,`pipe`]});_u.add(r);let i=Cu(),a=Cu();return r.stdout.on(`data`,e=>{i.push(e)}),r.stderr.on(`data`,e=>{a.push(e)}),{child:r,stderrCollector:a,stdoutCollector:i,timeout:Du(r,n?.timeoutMs)}},Mu=(e,t,n)=>{try{return ju(e,t,n)}catch(e){return{exitCode:127,stderr:Pu(e),stdout:``}}},Nu=e=>!(`child`in e),Pu=e=>e instanceof Error?e.message:String(e),Fu=async e=>{try{let[t]=await me(e,`close`);return{code:t}}catch(e){return{code:null,errorMessage:Pu(e)}}},Iu=e=>e===null?1:e,Lu=(e,t)=>t.truncated?{...e,stdoutTruncated:!0}:e,Ru=e=>e.timedOut?Au(e.stderr.text,e.timeoutMs):e.errorMessage===void 0?Lu({exitCode:Iu(e.code),stderr:Tu(e.stderr.text,e.stdout,e.stderr),stdout:e.stdout.text},e.stdout):Lu({exitCode:127,stderr:wu(e.stderr.text,e.errorMessage),stdout:e.stdout.text},e.stdout);var zu=class{async run(e,t,n){Su();let r=Mu(e,t,n);if(Nu(r))return r;let i=await Fu(r.child);return _u.delete(r.child),r.timeout.clear(),Ru({code:i.code,errorMessage:i.errorMessage,stderr:r.stderrCollector.finish(),stdout:r.stdoutCollector.finish(),timedOut:r.timeout.markedTimedOut(),timeoutMs:n?.timeoutMs})}};const Bu=os.partial({description:!0}),Vu=R({default_branch:I().min(1),key:z,tag_format_candidate:ts.nullable(),url:I().min(1)});Vu.extend({description:I().default(``),packages:Vo(Bu)});const Hu=Vu.extend({description:I().min(1),packages:Vo(os)}),Uu=R({effective_clone_mode:$o.optional(),head_sha:I().regex(/^[0-9a-f]{40}$/u,`head_sha must be a 40-character lowercase hex string`).optional(),last_error:I().optional(),last_fetched_at:ia().optional(),pending_proposal_at:ia().optional()}),Wu=R({refs:zo(e=>e.length>0&&!Ro.has(e),()=>`state ref key must be non-empty and not "__proto__", "constructor", or "prototype"`,lo(I(),Uu)).default({})}),Y=(e,t,n)=>t?.[e]??n[e],Gu=async e=>{try{return await o(e.statePath,`utf8`)}catch(e){if(V(e))return;throw e}},Ku=e=>{try{return JSON.parse(e)}catch{return}},X=async e=>{let t=await Gu(e);if(t===void 0)return Wu.parse({});let n=Ku(t);if(n===void 0)return Wu.parse({});let r=Wu.safeParse(n);return r.success?r.data:Wu.parse({})},qu=async(e,t)=>{let n=Wu.safeParse(t);if(!n.success)throw x(O(n.error));await Bs(e.statePath,`${JSON.stringify(n.data,void 0,2)}\n`)},Ju=/[/\\]/u,Yu={kind:`ignore`},Xu=e=>!ne(e)&&e.split(Ju).every(e=>e!==`.`&&e!==`..`),Zu=e=>Xu(e)&&!e.startsWith(`!`)&&!e.includes(`**`)&&(e.match(/\*/gu)??[]).length<=1,Qu=e=>Zu(e)?e.endsWith(`/*`)?{baseDir:e.slice(0,-2),kind:`expand-children`}:e===`*`?{baseDir:`.`,kind:`expand-children`}:e.includes(`*`)?Yu:{dir:e,kind:`probe-dir`}:Yu,$u=(e,t)=>{if(t&&e===``)return!0;let n=e===`..`||e.startsWith(`..`+oe);return e!==``&&!n&&!ne(e)},ed=(e,t,n)=>t.filter((e,t)=>n[t]===!0).map(t=>re.join(e,t)),td=(e,t)=>t?.name?{description:t.description,name:t.name,path:e}:void 0,nd=e=>{let t=e.map(e=>[e.path,e]),n=[...new Map(t).values()];return n.sort((e,t)=>e.path.localeCompare(t.path)),n},rd=/^\s*-\s+["']?(?<pattern>[^"'#]+)["']?/u,id=/^packages:\s*(?:#.*)?$/u,ad=e=>typeof e==`object`&&!!e&&!Array.isArray(e),od=e=>{if(Array.isArray(e))return e.filter(e=>typeof e==`string`);if(!ad(e))return[];let{packages:t}=e;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]},sd=Symbol(`end-of-section`),cd=e=>{let t=e.trim();if(t&&!t.startsWith(`-`)&&t.includes(`:`)&&!id.test(e))return sd;if(!t.startsWith(`-`))return;let n=rd.exec(e)?.groups?.pattern?.trim();if(n)return n},ld=e=>{let t=[];for(let n of e){let e=cd(n);if(e===sd)break;e!==void 0&&t.push(e)}return t},ud=e=>{let t=e.findIndex(e=>id.test(e));return t===-1?[]:ld(e.slice(t+1))},dd=e=>{let{name:t}=e;if(typeof t==`string`)return t},fd=e=>{let{description:t}=e;if(typeof t==`string`)return t},pd=async(e,t,n=!1)=>{try{let r=await c(e),i=await c(t);return $u(ie(r,i),n)}catch{return!1}},md=async(e,t)=>{try{let n=h(t,`package.json`);return await pd(e,n)?(await o(n,`utf8`),!0):!1}catch{return!1}},hd=async(e,t)=>{try{let n=h(e,t);if(!await pd(e,n,t===`.`))return[];let r=(await s(n,{withFileTypes:!0})).filter(e=>e.isDirectory()),i=await Promise.all(r.map(t=>md(e,h(n,t.name))));return ed(t,r.map(e=>e.name),i)}catch{return[]}},gd=async(e,t)=>{let n=Qu(t);if(n.kind===`expand-children`)return hd(e,n.baseDir);if(n.kind===`probe-dir`){let t=h(e,n.dir);if(await pd(e,t)&&await md(e,t))return[n.dir]}return[]},_d=async(e,t)=>{try{let n=h(t,`package.json`);if(!await pd(e,n))return;let r=await o(n,`utf8`),i=JSON.parse(r);return{description:fd(i),name:dd(i)}}catch{return}},vd=async(e,t)=>{let n=new Set;try{if(!await pd(e,t))return n;let r=await o(t,`utf8`),i=JSON.parse(r);od(i.workspaces).forEach(e=>n.add(e))}catch{}return n},yd=async(e,t)=>{let n=new Set;try{if(!await pd(e,t))return n;let r=await o(t,`utf8`);ud(r.split(`
350
- `)).forEach(e=>n.add(e))}catch{}return n},bd=async(e,t)=>{let n=new Set,r=[...t].map(t=>gd(e,t));return(await Promise.all(r)).forEach(e=>{e.forEach(e=>n.add(e))}),n},xd=async(e,t)=>{let n=h(e,t);if(await pd(e,n))return td(t,await _d(e,n))},Sd=async(e,t)=>{let n=[...t].map(t=>xd(e,t));return(await Promise.all(n)).filter(e=>e!==void 0)},Cd=async e=>{let t=h(e,`package.json`),n=h(e,`pnpm-workspace.yaml`),r=await vd(e,t),i=await yd(e,n),a=new Set([...r,...i]);if(a.size===0)return[];let o=await bd(e,a),s=await Sd(e,o);return nd(s)};var wd=`0.8.2`;const Td=async()=>{let e=[];for await(let t of process.stdin)e.push(Buffer.from(t));return Buffer.concat(e).toString(`utf8`)},Ed=()=>{try{return de()}catch{return``}},Dd=()=>({cliVersion:wd,cwd:process.cwd(),env:process.env,errLine:e=>{process.stderr.write(`${e}\n`)},fetcher:e=>fetch(e),homedir:Ed(),nodeVersion:process.version,out:e=>{process.stdout.write(`${e}\n`)},readStdin:Td,runner:new zu});var Od=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},kd=class extends Od{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}},Ad=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,t)=>{if(!this.argChoices.includes(e))throw new kd(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,t):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function jd(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}var Md=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(e=>jd(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(t?` `+t:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
350
+ `)).forEach(e=>n.add(e))}catch{}return n},bd=async(e,t)=>{let n=new Set,r=[...t].map(t=>gd(e,t));return(await Promise.all(r)).forEach(e=>{e.forEach(e=>n.add(e))}),n},xd=async(e,t)=>{let n=h(e,t);if(await pd(e,n))return td(t,await _d(e,n))},Sd=async(e,t)=>{let n=[...t].map(t=>xd(e,t));return(await Promise.all(n)).filter(e=>e!==void 0)},Cd=async e=>{let t=h(e,`package.json`),n=h(e,`pnpm-workspace.yaml`),r=await vd(e,t),i=await yd(e,n),a=new Set([...r,...i]);if(a.size===0)return[];let o=await bd(e,a),s=await Sd(e,o);return nd(s)};var wd=`0.8.3`;const Td=async()=>{let e=[];for await(let t of process.stdin)e.push(Buffer.from(t));return Buffer.concat(e).toString(`utf8`)},Ed=()=>{try{return de()}catch{return``}},Dd=()=>({cliVersion:wd,cwd:process.cwd(),env:process.env,errLine:e=>{process.stderr.write(`${e}\n`)},fetcher:e=>fetch(e),homedir:Ed(),nodeVersion:process.version,out:e=>{process.stdout.write(`${e}\n`)},readStdin:Td,runner:new zu});var Od=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},kd=class extends Od{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}},Ad=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,t)=>{if(!this.argChoices.includes(e))throw new kd(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,t):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function jd(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}var Md=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(e=>jd(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(t?` `+t:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
351
351
  `)}displayWidth(e){return _e(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
352
352
  `+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
353
353
  `)}},Nd=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=Id(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,t)=>{if(!this.argChoices.includes(e))throw new kd(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,t):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?Fd(this.name().replace(/^no-/,``)):Fd(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Pd=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r!==void 0&&r;return t.negate===(i===e)}};function Fd(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Id(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaisers-io/refs",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "Gives coding agents the real source of your dependencies, not a guess.",
5
5
  "keywords": [
6
6
  "ai",