@kaisers-io/refs 0.4.0 → 0.5.1

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 ADDED
@@ -0,0 +1,228 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.5.1] - 2026-07-30
11
+
12
+ ### Added
13
+
14
+ - The npm tarball now ships a package README (the npm page was empty) and this
15
+ `CHANGELOG.md` — the latter matters because the GitHub repository is private during the
16
+ current development phase, so the packaged copy is the only changelog users can see.
17
+ The release pipeline's tarball-content allowlist covers both, and a new guard fails the
18
+ release if the packaged changelog drifts from the repository one.
19
+ - Registry metadata in `package.json`: `keywords`, `homepage`, and `bugs`.
20
+
21
+ ## [0.5.0] - 2026-07-30
22
+
23
+ ### Added
24
+
25
+ - Full Windows support: every command, the lock/steal machinery, sync/clone/remove with their
26
+ containment guards, and the read-only hook guards now behave on Windows exactly as on
27
+ macOS/Linux (Git for Windows required). CI runs the full test suite plus a PowerShell smoke
28
+ test — which exercises the npm-generated `.cmd` shims — on `windows-latest`.
29
+
30
+ ### Fixed
31
+
32
+ - Lock directory names no longer contain `:` (illegal in Windows file names; every locked
33
+ command failed with `EINVAL` there). Per-ref locks are now named `ref.<key>`; a stale
34
+ `ref:<key>` directory left by an older version is inert and can be deleted.
35
+ - The lock-steal pipeline treats Windows sharing-violation errors (`EPERM`/`EACCES`/`EBUSY` on
36
+ the tombstone rename or on re-creating a directory that is still delete-pending) as a lost
37
+ race and retries, instead of crashing.
38
+ - Workspace package paths are `/`-separated identifiers on every platform (they previously used
39
+ `\` on Windows, breaking sorting, deduplication, and stored config paths).
40
+ - Child-process cleanup also listens for `SIGBREAK`, so Ctrl-Break on Windows kills spawned
41
+ git/ssh children like Ctrl-C does.
42
+
43
+ ## [0.4.0] - 2026-07-28
44
+
45
+ ### Changed
46
+
47
+ - Internal: whole-codebase clarity refactor — comments now explain behavior instead of project
48
+ history, inline lint exceptions cut from 75 to 20, `type` aliases replace interfaces
49
+ throughout, dead exports removed, and the workspace-detection logic is split into a pure,
50
+ directly-tested module. No CLI behavior change.
51
+
52
+ ### Removed
53
+
54
+ - `refs search` and `refs range` (both added in 0.3.0). A dedicated efficiency benchmark
55
+ (18-task corpus built around the two commands, taught inline with worked `--json` examples and
56
+ provably on `PATH`) measured **0 / 324 adoption** — neither Opus 4.8 nor GPT-5.6 invoked either
57
+ command on a single task, including tasks constructed to favor them — while the condition
58
+ carrying the teaching cost _more_ (cost-weighted spend +19% over discipline, +41% over naive for
59
+ Claude). With the dependency source checked out, both commands compete head-to-head with the
60
+ agent's native `git grep` / `git log` / `git diff` and lose: they are redundant with skills the
61
+ agent already has on the very source refs provides. refs' core value — real, local source the
62
+ agent then reads and greps — is unchanged. The agent skill now routes source-search and version
63
+ questions to `resolve`/`sync`/`tag` plus read-only git on the checkout. The now-dead core helpers
64
+ (`git/grep`, `git/range`, `git/changelog`) were removed with them.
65
+
66
+ ## [0.3.0] - 2026-07-23
67
+
68
+ ### Added
69
+
70
+ - `refs range <ref> <old-version> <new-version>` — a bounded version-diff digest for
71
+ agent-driven "what changed between these versions" questions. Resolves both versions to git
72
+ tags (same `tag_format` inheritance as `refs tag`) and returns, in one call, the commit count,
73
+ the newest `--limit` (default 50) non-merge commit subjects, diff stats, changed paths (capped
74
+ at 200), and a changelog excerpt extracted at the new tag. `--package <name>` scopes the
75
+ diff/paths/changelog to that package's path while the commit log stays repo-wide. Every bounded
76
+ list carries an honest flag in `truncated`; the digest is a starting point, and the full history
77
+ stays available via plain git in the checkout.
78
+ - `refs search <ref> <pattern>` — bounded structured code search over a ref's checkout. Wraps
79
+ `git grep -z -n -I --extended-regexp` and returns `{path, line, snippet}` matches (trimmed,
80
+ capped at 200 chars), at most `--limit` (default 50), with `truncated: true` whenever more
81
+ exist. Vendored/generated paths (`dist`, `build`, `node_modules`, lockfiles, …) are excluded by
82
+ default and echoed in `excludes_applied`; `--no-default-excludes` turns them off. `--glob` takes
83
+ plain glob patterns (never raw git pathspec magic — leading `:` or root-escaping `..` are
84
+ rejected), and `--package` is a hard boundary that intersects with any `--glob` and refuses a
85
+ package directory resolving outside the checkout. No matches is a success, not an error.
86
+
87
+ ### Changed
88
+
89
+ - Rewrote the agent skill's investigation playbook (`skills/refs/references/investigate.md`) as an
90
+ advisory guide built on the "hint, not gate" principle: four hard rules (read real source before
91
+ citing, treat digests as starting points, honour truncation flags, unmask decoy version tags)
92
+ plus recommended investigation funnels with explicit escape hatches, tuned by two real-world
93
+ field tests.
94
+
95
+ ## [0.2.0] - 2026-07-07
96
+
97
+ ### Added
98
+
99
+ - Onboarding flow for the agent skill (`skills/refs/references/onboarding.md`, triggered by
100
+ "onboard me" / "set up refs" / "what is refs"): health check via `refs doctor --json`, a
101
+ consented `refs init` where needed, the three core jobs explained with copyable example
102
+ prompts, and a first-ref suggestion drawn from the project's own dependency manifests.
103
+ - Install flow in the skill's capability gate: when the `refs` CLI is missing, the agent now
104
+ checks the Node version, asks the user for consent, installs `@kaisers-io/refs` from npm,
105
+ verifies with `refs --version`, and runs `refs doctor --json` automatically. A new
106
+ `compatibility` frontmatter field declares the CLI dependency.
107
+
108
+ ### Changed
109
+
110
+ - All example content (docs, skill references, README, CLI help text) switched from next.js to
111
+ zod (`github.com/colinhacks/zod`) — every example validated against a real zod checkout via
112
+ refs itself.
113
+ - Development now requires pnpm 11 or newer (`engines.pnpm` at the workspace root); the
114
+ published CLI has no pnpm requirement.
115
+ - The user-facing supported Node range relaxed from `>=24.12 <25` to `>=24.12` (open-ended),
116
+ verified working on Node 25.9 and 26.4 (build, tests, stub, and source fallback). Development
117
+ stays pinned to Node 24.12 via `.node-version`; CI and the root `packageManager` field are
118
+ unchanged.
119
+ - `packages/cli/bin/refs.mjs` is now a committed, zero-dependency stub (not build output): it
120
+ checks the Node.js version, then loads and runs the tsdown bundle from `dist/refs.mjs`. If the
121
+ bundle is missing but sources and dependencies are present, it falls back to running the CLI
122
+ directly from TypeScript source via Node's native type stripping. It fails loudly with an
123
+ actionable message (exit 1) only if neither the bundle nor the source fallback can load. The
124
+ tsdown bundle itself moved from `bin/refs.mjs` to `dist/refs.mjs`, and remains gitignored build
125
+ output produced by `pnpm build`.
126
+
127
+ ## [0.1.3] - 2026-07-05
128
+
129
+ ### Added
130
+
131
+ - Plugin manifests for the Codex app/CLI (`.codex-plugin/plugin.json`) and Claude Code's
132
+ plugin marketplace (`.claude-plugin/plugin.json` + `marketplace.json`), plus a
133
+ `.agents/plugins/marketplace.json` mirror for Codex's own marketplace. A
134
+ `.agents/skills/refs` symlink to `skills/refs/` gives Codex repo-local
135
+ auto-discovery of the skill when run inside this checkout.
136
+
137
+ ### Changed
138
+
139
+ - `packages/cli/bin/refs.mjs` (the built CLI bundle) is no longer committed to the repo — it's
140
+ build output, regenerated by `pnpm build` and gitignored. CI now proves the build is
141
+ deterministic (two consecutive builds byte-for-byte identical) instead of diffing a committed
142
+ copy, and the release pipeline passes the bundle built and guarded by the unprivileged `verify`
143
+ job to the minimal `publish` job as a workflow artifact, so `publish` still never installs
144
+ dependencies or runs a build while it holds the npm OIDC token.
145
+ - Updated the bundled `smol-toml` TOML parser/serializer from 1.6.1 to 1.7.0 (faster
146
+ single-pass string decoding; integers beyond the safe range now serialize as floats;
147
+ no breaking changes).
148
+ - `refs add <source> --description <text>` no longer reuses `<text>` as a fallback
149
+ description for detected packages that lack one. `<text>` is now only ever the
150
+ top-level ref description; if one or more detected packages have no manifest
151
+ description (including a single-package repo whose lone package has none, and a
152
+ package whose manifest carries an empty `"description": ""` — the `npm init -y`
153
+ scaffold), the one-shot fails (exit 3) naming every affected package and pointing at
154
+ the two-phase `--dry-run`/`--proposal` flow instead. Consequently, an `npm:<pkg>`
155
+ source without detected workspace packages can effectively never use the one-shot —
156
+ its single seeded package entry never carries a description — and always needs the
157
+ two-phase flow.
158
+
159
+ - Replaced the `execa` dependency with a small hand-rolled `node:child_process`-based
160
+ process runner. `git`/`ssh` invocations, timeouts, and error handling work as
161
+ before, with two minor observable differences: a command that fails to spawn at
162
+ all (e.g. `git` missing from `PATH`) now reports exit code 127 instead of 1, and
163
+ its OS error message (e.g. `spawn git ENOENT`) now lands on stderr — improving
164
+ `refs doctor`'s failure detail for a missing `git` binary. The published CLI
165
+ bundle is smaller as a result (`bin/refs.mjs`: 305,188 → 196,249 bytes raw,
166
+ 89,740 → 55,864 bytes gzipped).
167
+
168
+ ### Fixed
169
+
170
+ - `refs add --proposal` validation errors now name the offending key(s) for a
171
+ stray/unrecognized field in the proposal — top-level (e.g.
172
+ `unrecognized key(s) in proposal: "okay"`) and nested inside a package entry (e.g.
173
+ `unrecognized key(s) in proposal at packages.<name>: "bogus"`) — instead of a bare,
174
+ contextless `Invalid input`. Named-field validation errors (missing or wrong-typed
175
+ fields, including nested package fields like `packages.<name>.description`) are
176
+ unchanged.
177
+
178
+ ## [0.1.2] - 2026-07-05
179
+
180
+ ### Added
181
+
182
+ - `refs add` now emits progress lines on stderr while it works (`refs: resolving npm
183
+ package '…'…`, `refs: cloning …`, `refs: detecting workspace packages…`) in both
184
+ human and `--json` mode, so long clones no longer look like a hang. stdout is
185
+ unaffected and stays exactly the parseable envelope in `--json` mode.
186
+
187
+ ### Fixed
188
+
189
+ - `refs add --proposal` now accepts the full `--json` envelope that
190
+ `refs add … --dry-run --json` prints, so the documented pipe workflow
191
+ (`refs add npm:x --dry-run --json > f.json` → edit → `refs add --proposal f.json`)
192
+ works without hand-stripping the `data` wrapper. Bare proposal documents keep
193
+ working unchanged.
194
+ - A proposal file containing a failed (`ok: false`) or malformed (no usable `data`
195
+ object) envelope now fails with a clear message instead of a field-by-field
196
+ validation dump.
197
+
198
+ ## [0.1.1] - 2026-07-05
199
+
200
+ No user-facing changes. First tag-driven release, validating the OIDC
201
+ trusted-publishing pipeline end to end.
202
+
203
+ ## [0.1.0] - 2026-07-05
204
+
205
+ ### Added
206
+
207
+ - Initial release of the `refs` CLI: manage local, read-only checkouts of reference
208
+ repositories ("refs") for agents and humans — `init`, `add` (two-phase
209
+ proposal/finalize or one-shot `--description`), `list`, `show`, `resolve`, `sync`,
210
+ `edit`, `remove`, `migrate`, and `doctor`.
211
+ - npm-source resolution (`refs add npm:<package>`), workspace package detection
212
+ (npm/yarn/pnpm monorepos), tag-format detection, blobless clones with full-clone
213
+ fallback, and a configurable git transport (`https`/`ssh`).
214
+ - Machine-readable `--json` output with a stable `{ok, data, warnings}` /
215
+ `{ok, error}` envelope on every command, plus stable exit codes.
216
+ - Containment-guarded destructive operations, credential redaction in every
217
+ URL-carrying message, and read-only enforcement of managed checkouts via
218
+ installed git hooks.
219
+ - Agent skill (`skills/refs/`) documenting the investigate/add/maintain workflows.
220
+
221
+ [Unreleased]: https://github.com/kaisers-io/refs/compare/v0.4.0...HEAD
222
+ [0.4.0]: https://github.com/kaisers-io/refs/compare/v0.3.0...v0.4.0
223
+ [0.3.0]: https://github.com/kaisers-io/refs/compare/v0.2.0...v0.3.0
224
+ [0.2.0]: https://github.com/kaisers-io/refs/compare/v0.1.3...v0.2.0
225
+ [0.1.3]: https://github.com/kaisers-io/refs/compare/v0.1.2...v0.1.3
226
+ [0.1.2]: https://github.com/kaisers-io/refs/compare/v0.1.1...v0.1.2
227
+ [0.1.1]: https://github.com/kaisers-io/refs/compare/v0.1.0...v0.1.1
228
+ [0.1.0]: https://github.com/kaisers-io/refs/releases/tag/v0.1.0
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # @kaisers-io/refs
2
+
3
+ **Real source code for coding agents.**
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.
9
+
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.
14
+
15
+ npm is only a convenience resolver (`npm:zod`). Arbitrary git URLs work directly.
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.
22
+
23
+ ## Install
24
+
25
+ Requirements: Node.js `>=24.12` 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/)).
28
+
29
+ ```bash
30
+ npm i -g @kaisers-io/refs
31
+ ```
32
+
33
+ Then verify the setup:
34
+
35
+ ```bash
36
+ refs --version
37
+ refs doctor
38
+ ```
39
+
40
+ ## Quickstart
41
+
42
+ ```bash
43
+ # 1. Seed the refs home directory, config, and git hooks guard.
44
+ refs init
45
+
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
49
+
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
53
+ ```
54
+
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: full entry, state, local path, and sample tags. |
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`. `refs init` prints the
80
+ exact install command for your setup. The skill is distributed from the GitHub
81
+ repository, which is private during the current development phase — it opens up when
82
+ `refs` goes public.
83
+
84
+ ## Changelog
85
+
86
+ `CHANGELOG.md` ships inside this package (npm's "Code" tab shows it) — the GitHub
87
+ repository is private during the current development phase.
88
+
89
+ ## License
90
+
91
+ MIT