@kaisers-io/refs 0.8.1 → 0.8.2

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,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.8.2] - 2026-08-10
11
+
12
+ ### Fixed
13
+
14
+ - Documentation that described flows which did not work. The README's quickstart failed in both
15
+ of its branches, the skill's onboarding handed the user a prompt naming a zod version that was
16
+ never tagged, and `docs/commands.md` showed a stored url and a package count the CLI does not
17
+ produce. Every documented command was re-run and corrected against its real output, and the
18
+ `skill` check's Windows note was still describing the gap 0.8.1 closed.
19
+
20
+ - `git_transport` was documented as overridable per ref. It can be written there, since the
21
+ override schema is derived from the settings schema, but nothing reads it: only `refs add`
22
+ consults the setting, and `add` refuses a key that is already configured. Documented as inert.
23
+
24
+ ### Changed
25
+
26
+ - The README and the package page are rewritten around the agent workflow, which is how refs is
27
+ meant to be used, with the manual CLI route kept as the side note it is.
28
+
29
+ - The package description now matches the repository's.
30
+
10
31
  ## [0.8.1] - 2026-08-10
11
32
 
12
33
  ### Fixed
@@ -388,7 +409,8 @@ trusted-publishing pipeline end to end.
388
409
  installed git hooks.
389
410
  - Agent skill (`skills/refs/`) documenting the investigate/add/maintain workflows.
390
411
 
391
- [Unreleased]: https://github.com/kaisers-io/refs/compare/v0.8.1...HEAD
412
+ [Unreleased]: https://github.com/kaisers-io/refs/compare/v0.8.2...HEAD
413
+ [0.8.2]: https://github.com/kaisers-io/refs/compare/v0.8.1...v0.8.2
392
414
  [0.8.1]: https://github.com/kaisers-io/refs/compare/v0.8.0...v0.8.1
393
415
  [0.8.0]: https://github.com/kaisers-io/refs/compare/v0.7.0...v0.8.0
394
416
  [0.7.0]: https://github.com/kaisers-io/refs/compare/v0.6.1...v0.7.0
package/README.md CHANGED
@@ -2,99 +2,105 @@
2
2
 
3
3
  **Real source code for coding agents.**
4
4
 
5
- `refs` manages arbitrary git repositories (GitHub, GitLab, self-hosted) as local, managed
6
- read-only source-code references, so that coding agents answer questions about
7
- dependencies and reference projects against **real source code** never against a
8
- minified `node_modules` bundle, never against stale training knowledge.
5
+ Ask a coding agent how a library works and it answers from training data that is months
6
+ old. Tell it to go look, and the best it finds is a minified bundle in `node_modules`.
7
+ Private repositories are worse still. The model has never seen that code at all.
9
8
 
10
- When your project depends on `zod`, you say "add zod as a ref"; `refs` resolves the npm
11
- package to its git repository, clones it, detects its release-tag convention and monorepo
12
- packages, and from then on any agent can answer "what changed between v4.0.0 and v4.1.0"
13
- or "how does zod implement codecs" by reading the actual checkout.
9
+ `refs` hands it the source. It keeps read-only git checkouts of the repositories you care
10
+ about, so your agent reads the code that actually ships.
14
11
 
15
- npm is only a convenience resolver (`npm:zod`). Arbitrary git URLs work directly.
12
+ You say "add zod as a ref". `refs` resolves the npm package to its git repository, clones
13
+ it, and works out how the project tags its releases. After that the agent answers "how
14
+ does zod implement codecs" by reading zod's own files, and "what changed between v4.0.1
15
+ and v4.1.0" by diffing those two tags in the same clone.
16
16
 
17
- **Read-only is a workflow promise, not a security boundary.** Every checkout under
18
- `sources/` is a managed reference, not a working copy: agents are instructed never to
19
- edit, commit, or push inside one. `refs` installs git hooks that reject commits/pushes in
20
- a checkout as a backstop, and `refs sync` self-heals a dirty checkout if something slips
21
- through anyway — but this is discipline enforced by convention and tooling, not a sandbox.
17
+ `https` and `ssh` URLs both work, including the `git@host:path` form, so a private repo or
18
+ a self-hosted forge is no different from a public one. Private ones use the credentials
19
+ your git already has, since refs refuses to take any in the URL.
22
20
 
23
21
  ## Install
24
22
 
25
- Requirements: Node.js `>=24.2` and git. macOS, Linux, and Windows are fully supported —
26
- every command, locking, sync, and the read-only guards behave the same on all three (on
27
- Windows, use [Git for Windows](https://gitforwindows.org/)).
23
+ You need Node.js 24.2 or newer, and git. On Windows use
24
+ [Git for Windows](https://gitforwindows.org/), because the read-only guards are `sh` scripts
25
+ and need the shell it ships with. The CLI behaves the same on all three platforms, and its
26
+ full test suite runs on each of them.
28
27
 
29
28
  ```bash
30
29
  npm i -g @kaisers-io/refs
30
+ refs init # seeds the refs home directory and the git hooks guard
31
+ refs doctor # confirms git, node and the setup are in order
31
32
  ```
32
33
 
33
- Then verify the setup:
34
+ ## The agent skill
35
+
36
+ This package is the CLI. The skill that drives it lives in the
37
+ [GitHub repository](https://github.com/kaisers-io/refs) and installs separately:
34
38
 
35
39
  ```bash
36
- refs --version
37
- refs doctor
40
+ npx skills add kaisers-io/refs
38
41
  ```
39
42
 
40
- ## Quickstart
43
+ Invoke it with `/refs` in Claude Code or `$refs` in Codex. It never activates on its own.
44
+ In Claude Code its description also stays out of the context window until you ask for it,
45
+ so questions that need no source code cost you nothing.
46
+
47
+ The agent route is the one to reach for first. It can search the source, follow what it
48
+ finds, and talk with you about it. Its answers name the file and line they came from, so
49
+ you can check a claim instead of trusting it, and they are clickable wherever your
50
+ terminal or app opens file links.
51
+
52
+ ## Driving the CLI yourself
53
+
54
+ Useful for scripting, or for checking what the agent did.
41
55
 
42
56
  ```bash
43
- # 1. Seed the refs home directory, config, and git hooks guard.
44
- refs init
57
+ refs add npm:zod --dry-run --json > proposal.json # clones and proposes, no config entry yet
58
+ # open proposal.json and fill in every empty description, including each package's
59
+ refs add --proposal proposal.json --json # finalize
60
+ ```
61
+
62
+ Finalize rejects a proposal that still has an empty description, which is what keeps refs
63
+ from inventing one for you.
45
64
 
46
- # 2. Propose adding a ref resolves npm:zod to its git repo, clones it, and writes
47
- # a reviewable proposal. Nothing is added to config yet.
48
- refs add npm:zod --dry-run
65
+ You can skip the file when every package already carries a description in its own manifest:
49
66
 
50
- # 3. Review the proposal JSON, then finalize it, or use --description for a
51
- # one-shot add:
52
- refs add npm:zod --description "TypeScript-first schema validation" --json
67
+ ```bash
68
+ refs add https://github.com/stevemao/left-pad --description "Left-pad a string." --json
53
69
  ```
54
70
 
55
- Every command accepts `--json` for a stable, machine-readable envelope and `--verbose`
56
- for stack traces on error. Run `refs --help` or `refs <command> --help` the CLI's own
57
- help is the authoritative, always-current reference.
58
-
59
- ## Commands
60
-
61
- | Command | What it does |
62
- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
63
- | `refs init` | Seed or migrate the refs home directory, its config, and the git hooks guard. |
64
- | `refs add` | Add a git reference in two phases: propose (`--dry-run`), then finalize (`--proposal`). |
65
- | `refs list` | List configured refs with their staleness/missing checkout status. |
66
- | `refs show` | Show a configured ref: entry, state, local path, package count (`--packages`/`--tags` add the package map and sample tags to `--json`). |
67
- | `refs sync` | Fetch (or re-clone, if the checkout is missing) configured refs all by default. |
68
- | `refs resolve` | Resolve a git url, npm package name, import path, or ref-key suffix to its ref/package. |
69
- | `refs tag` | Resolve a version to its git tag, via the ref's (or a package's) `tag_format`. |
70
- | `refs edit` | Edit one field of a global setting, a ref, or a package. |
71
- | `refs remove` | Remove a configured ref: its config/state entry AND its checkout directory. |
72
- | `refs doctor` | Run environment/integrity checks (git, node, config, hooks, checkouts, ssh). |
73
- | `refs migrate` | Migrate the refs config to the current schema, seeding it if absent. |
74
-
75
- ## Agent skill
76
-
77
- The CLI pairs with one thin, cross-agent skill (Claude Code and Codex) that routes agent
78
- questions ("how does zod implement codecs") to the right checkout via `refs resolve
79
- --json` and keeps things fresh with `refs sync`/`refs doctor`. It is user-invoked it
80
- does not activate on its own; invoke it with `/refs` in Claude Code or `$refs` in Codex.
81
- `refs init` prints the exact install command for your setup. The skill is distributed
82
- from the GitHub repository rather than from npm, so it is installed with `skills add`
83
- rather than with this package.
84
-
85
- `refs doctor`'s `skill` check looks for the installed skill in `~/.agents`, `~/.claude`,
86
- `~/.codex` and the current project's `./.agents`/`./.claude`; a `warn` there means the
87
- check couldn't see your skill, not that it is missing.
88
-
89
- Source citations in the skill's final answer are markdown links (visible text relative,
90
- target an absolute checkout path): they open in the Zed terminal and the Codex app
91
- (verified 2026-08-03), but as of the same date the Claude app cannot open files outside
92
- its working directory.
71
+ Every command takes `--json` for a stable machine-readable envelope, and `--verbose` for
72
+ stack traces. Both are global flags, so they are listed under `refs --help` rather than
73
+ under each command's own help.
74
+
75
+ | Command | What it does |
76
+ | -------------- | ------------------------------------------------------------------------------------- |
77
+ | `refs init` | Seed or migrate the refs home directory, its config and the git hooks guard. |
78
+ | `refs add` | Add a git reference: propose with `--dry-run`, then finalize with `--proposal`. |
79
+ | `refs list` | List configured refs with their staleness and missing-checkout status. |
80
+ | `refs show` | Show one ref: entry, state, local path, package count. |
81
+ | `refs sync` | Fetch configured refs, or re-clone the ones whose checkout went missing. |
82
+ | `refs resolve` | Resolve a git url, npm package name, import path or key suffix to its ref or package. |
83
+ | `refs tag` | Resolve a version to its git tag through the ref's `tag_format`, or a package's. |
84
+ | `refs edit` | Edit one field of a global setting, a ref or a package. |
85
+ | `refs remove` | Remove a ref: its config and state entry, and its checkout directory. |
86
+ | `refs doctor` | Check the environment and the integrity of what refs manages. |
87
+ | `refs migrate` | Migrate the config to the current schema, seeding it if absent. |
88
+
89
+ Full reference, including exit codes and `--json` shapes:
90
+ [`docs/commands.md`](https://github.com/kaisers-io/refs/blob/main/docs/commands.md).
91
+
92
+ ## Read-only is a promise, not a sandbox
93
+
94
+ Every checkout is a reference, not a working copy. `refs` installs git hooks that reject
95
+ commits and pushes inside one, and `refs sync` restores a checkout that got dirty anyway.
96
+
97
+ Those hooks are a backstop against mistakes. A determined local process can still write
98
+ into a checkout, so treat this as a workflow that holds, not as a security boundary.
93
99
 
94
100
  ## Changelog
95
101
 
96
- `CHANGELOG.md` ships inside this package, so npm's "Code" tab shows it without leaving
97
- the package page.
102
+ `CHANGELOG.md` ships inside this package, so npm's "Code" tab shows it without leaving the
103
+ package page.
98
104
 
99
105
  ## License
100
106
 
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.1`;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.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(`
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,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaisers-io/refs",
3
- "version": "0.8.1",
4
- "description": "Managed read-only git checkouts of reference repositories for coding agents.",
3
+ "version": "0.8.2",
4
+ "description": "Gives coding agents the real source of your dependencies, not a guess.",
5
5
  "keywords": [
6
6
  "ai",
7
7
  "checkout",