toolcrib 0.1.0 → 0.1.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/README.md +187 -146
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,198 +6,239 @@ changed, and stages every addition/modification as a reviewable patch — it
|
|
|
6
6
|
never writes to a pre-existing file directly. You (or your AI assistant)
|
|
7
7
|
apply what you want with `toolcrib apply`.
|
|
8
8
|
|
|
9
|
+
This file covers the CLI itself, start to finish. It doesn't cover how to
|
|
10
|
+
use any individual component; for that, point your AI assistant at the
|
|
11
|
+
toolkit's `ai-docs/` folder, which `toolcrib init` vendors into your project
|
|
12
|
+
(see [What this guide doesn't cover](#what-this-guide-doesnt-cover)).
|
|
13
|
+
|
|
9
14
|
## Install
|
|
10
15
|
|
|
16
|
+
No install needed — run it directly:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npx toolcrib <command>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or install it globally if you'll use it often:
|
|
23
|
+
|
|
11
24
|
```bash
|
|
12
25
|
npm install -g toolcrib
|
|
26
|
+
toolcrib <command>
|
|
13
27
|
```
|
|
14
28
|
|
|
15
|
-
|
|
29
|
+
Run every command from your project's root — the same directory as your
|
|
30
|
+
`package.json`.
|
|
16
31
|
|
|
17
|
-
##
|
|
32
|
+
## The lifecycle, at a glance
|
|
18
33
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
```
|
|
35
|
+
toolcrib init → review ./toolcrib-patches/ → toolcrib apply
|
|
36
|
+
│
|
|
37
|
+
(later, to check in on things) │
|
|
38
|
+
▼
|
|
39
|
+
toolcrib doctor
|
|
40
|
+
│
|
|
41
|
+
(when a new version exists)
|
|
42
|
+
▼
|
|
43
|
+
toolcrib merge → review ./toolcrib-patches/ → toolcrib apply
|
|
44
|
+
```
|
|
26
45
|
|
|
27
|
-
|
|
28
|
-
`init`/`merge` only ever produce patches for you to review first.
|
|
46
|
+
Two ideas make everything else make sense:
|
|
29
47
|
|
|
30
|
-
|
|
48
|
+
1. **Nothing is ever written to an existing file except by `toolcrib
|
|
49
|
+
apply`.** `init` and `merge` only ever compute a diff and save it as a
|
|
50
|
+
`.patch` file in `./toolcrib-patches/` — a folder you can open, read,
|
|
51
|
+
and delete without anything in your project changing. `apply` is the
|
|
52
|
+
only command that actually touches your files, and only for patches
|
|
53
|
+
sitting in that folder.
|
|
54
|
+
2. **Every command is safe to run "just to see."** `init`/`merge` never
|
|
55
|
+
modify anything by themselves, and `doctor`/`versions` are read-only.
|
|
56
|
+
If you're ever unsure what a command will do, running it costs nothing
|
|
57
|
+
— the worst case is a `./toolcrib-patches/` folder you don't apply.
|
|
58
|
+
|
|
59
|
+
## Commands
|
|
31
60
|
|
|
32
|
-
|
|
33
|
-
of fidelity to what a real published install behaves like.
|
|
61
|
+
### `toolcrib init`
|
|
34
62
|
|
|
35
|
-
|
|
63
|
+
Stages the toolkit into your project for the first time.
|
|
36
64
|
|
|
37
65
|
```bash
|
|
38
|
-
|
|
39
|
-
|
|
66
|
+
toolcrib init
|
|
67
|
+
toolcrib init --version 1.2.0 # a specific release instead of latest
|
|
68
|
+
toolcrib init --situation new # greenfield project, no existing UI
|
|
69
|
+
toolcrib init --situation refactor # adopting toolcrib into an existing app
|
|
40
70
|
```
|
|
41
71
|
|
|
42
|
-
|
|
43
|
-
|
|
72
|
+
What it does: downloads the requested release (`latest` by default),
|
|
73
|
+
computes what's new or different compared to what's already in `./toolcrib`
|
|
74
|
+
(nothing, the first time you run it), and writes every addition as a
|
|
75
|
+
numbered `.patch` file under `./toolcrib-patches/`. It also proposes
|
|
76
|
+
patches for `package.json` (adding the toolkit's dependencies and the
|
|
77
|
+
`#toolcrib` import alias), `.gitignore`, and an `AGENTS.md`/`CLAUDE.md`
|
|
78
|
+
block your AI assistant should read.
|
|
44
79
|
|
|
45
|
-
|
|
80
|
+
`--situation` controls whether a **New Project** or **Refactor** guide gets
|
|
81
|
+
added to that instruction-file block, on top of the core rules that are
|
|
82
|
+
always included. Skip it and you'll get the core rules only, with a note
|
|
83
|
+
telling you to re-run with `--situation` (or add the missing block by hand)
|
|
84
|
+
when you're ready.
|
|
46
85
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
```
|
|
86
|
+
One thing worth knowing up front: **`init` doesn't take a target folder
|
|
87
|
+
argument.** It always vendors into `./toolcrib` relative to wherever you
|
|
88
|
+
run it — there's no way to point it at, say, `./src/ui` instead. Run it
|
|
89
|
+
from your project root.
|
|
52
90
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
entry and shebang, unlike option 1.
|
|
91
|
+
Nothing is written to your project yet — see [Reviewing and applying
|
|
92
|
+
patches](#reviewing-and-applying-patches) below.
|
|
56
93
|
|
|
57
|
-
|
|
58
|
-
npm unlink -g toolcrib # when done
|
|
59
|
-
```
|
|
94
|
+
### `toolcrib apply`
|
|
60
95
|
|
|
61
|
-
|
|
96
|
+
Applies everything staged in `./toolcrib-patches/`.
|
|
62
97
|
|
|
63
98
|
```bash
|
|
64
|
-
|
|
65
|
-
npm pack # produces toolcrib-<version>.tgz
|
|
66
|
-
npm install -g ./toolcrib-<version>.tgz # a real install: real deps, real files[] whitelist applied
|
|
67
|
-
toolcrib init # exactly what an end user would type
|
|
99
|
+
toolcrib apply
|
|
68
100
|
```
|
|
69
101
|
|
|
70
|
-
This is the
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
102
|
+
This is the command that actually creates/modifies files. It applies each
|
|
103
|
+
patch in order, reports how many succeeded, and **deletes the
|
|
104
|
+
`./toolcrib-patches/` folder afterward regardless of outcome** — a failed
|
|
105
|
+
patch isn't kept around to retry; if something fails, re-run `init` or
|
|
106
|
+
`merge` afterward to regenerate fresh patches against your project's
|
|
107
|
+
current state, which is more likely to apply cleanly than retrying a stale
|
|
108
|
+
one.
|
|
74
109
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
110
|
+
If your project isn't already a git repository, `apply` will offer to run
|
|
111
|
+
`git init` for you first (it uses `git apply` when possible, since that
|
|
112
|
+
gives you normal git tooling — `git diff`, `git checkout -- .` — to inspect
|
|
113
|
+
or undo what just landed). Say no and it falls back to a built-in patcher
|
|
114
|
+
that doesn't need git at all.
|
|
78
115
|
|
|
79
|
-
|
|
116
|
+
### `toolcrib doctor`
|
|
80
117
|
|
|
81
|
-
|
|
118
|
+
Read-only. Never modifies anything.
|
|
82
119
|
|
|
83
120
|
```bash
|
|
84
|
-
|
|
85
|
-
npm test
|
|
121
|
+
toolcrib doctor
|
|
86
122
|
```
|
|
87
123
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
(`integration-test/mock-github-server.js`) that serves a real release zip
|
|
112
|
-
built from this repo's own toolkit source, shaped exactly like GitHub's
|
|
113
|
-
API and release-asset URLs.
|
|
114
|
-
|
|
115
|
-
**1. Build a real release from the toolkit source (repo root, not cli/)**
|
|
124
|
+
Run this any time you want to sanity-check your install without changing
|
|
125
|
+
anything. It reports:
|
|
126
|
+
|
|
127
|
+
- **Local drift** — files under `./toolcrib` that no longer match what the
|
|
128
|
+
installed version actually shipped (usually from hand-editing a vendored
|
|
129
|
+
file directly, which is supported — that's the whole point of vendoring
|
|
130
|
+
— but worth knowing about).
|
|
131
|
+
- **Stale instruction-file blocks** — if the `<!-- toolcrib:managed:... -->`
|
|
132
|
+
block in your `AGENTS.md`/`CLAUDE.md` was hand-edited instead of
|
|
133
|
+
regenerated, or is out of date with your installed version.
|
|
134
|
+
- **Whether a newer release is available.**
|
|
135
|
+
- **A `tsconfig.json` compatibility check** — if `moduleResolution` isn't
|
|
136
|
+
set to `"bundler"`, `"node16"`, or `"nodenext"`, `import { ... } from
|
|
137
|
+
'#toolcrib'` will run fine but your editor/`tsc` may falsely report
|
|
138
|
+
"Cannot find module." `doctor` tells you the exact setting to fix it.
|
|
139
|
+
- **Bundler-specific notes**, when relevant — for example, on a Next.js
|
|
140
|
+
project it'll remind you that any file rendering toolcrib components
|
|
141
|
+
needs a `'use client'` directive, since Next's App Router treats
|
|
142
|
+
components as server-only by default.
|
|
143
|
+
|
|
144
|
+
### `toolcrib merge`
|
|
145
|
+
|
|
146
|
+
Stages an upgrade from your currently installed version to another.
|
|
116
147
|
|
|
117
148
|
```bash
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
node scripts/package-release.js
|
|
149
|
+
toolcrib merge # upgrade to latest
|
|
150
|
+
toolcrib merge --version 2.1.0 # upgrade to a specific version
|
|
121
151
|
```
|
|
122
152
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
153
|
+
Works like `init`, but smarter: for every vendored file, it compares three
|
|
154
|
+
things — what you originally got, what's actually on disk now, and what
|
|
155
|
+
the new version ships — and sorts each file into one of three outcomes:
|
|
126
156
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
157
|
+
- **Safe update** — you never touched the file; the new version's copy is
|
|
158
|
+
staged as a patch.
|
|
159
|
+
- **Kept as-is** — you edited the file yourself and upstream didn't change
|
|
160
|
+
it; left alone, no patch generated.
|
|
161
|
+
- **Conflict** — you edited it *and* upstream changed it too. `merge` won't
|
|
162
|
+
guess which version wins. Instead it writes a `.upstream-diff` note
|
|
163
|
+
explaining what upstream changed, so you (or your AI assistant) can
|
|
164
|
+
reconcile it by hand.
|
|
133
165
|
|
|
134
|
-
|
|
166
|
+
As with `init`, nothing is written until you run `apply` afterward.
|
|
135
167
|
|
|
136
|
-
|
|
168
|
+
### `toolcrib versions`
|
|
137
169
|
|
|
138
|
-
|
|
139
|
-
`npm link` (see above) for the real `toolcrib` command:
|
|
170
|
+
Lists every published release.
|
|
140
171
|
|
|
141
172
|
```bash
|
|
142
|
-
|
|
143
|
-
|
|
173
|
+
toolcrib versions
|
|
174
|
+
```
|
|
144
175
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
toolcrib init
|
|
176
|
+
Useful for picking an exact `--version` for `init` or `merge` instead of
|
|
177
|
+
always taking `latest`.
|
|
148
178
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
toolcrib
|
|
152
|
-
|
|
179
|
+
## Reviewing and applying patches
|
|
180
|
+
|
|
181
|
+
After `init` or `merge`, you'll have a `./toolcrib-patches/` folder full of
|
|
182
|
+
numbered `.patch` files — plain unified diffs. Before running `apply`:
|
|
183
|
+
|
|
184
|
+
- Open a few and skim them. They're ordinary text; any editor or `git
|
|
185
|
+
diff`-style tool can show them.
|
|
186
|
+
- If you're not going to apply them, just delete the folder — nothing else
|
|
187
|
+
has changed yet.
|
|
188
|
+
- If everything looks right, run `toolcrib apply`.
|
|
153
189
|
|
|
154
|
-
|
|
155
|
-
vendored file, `package.json` should have the real peer dependencies
|
|
156
|
-
added, `.gitignore` should have `/toolcrib-patches/`, and
|
|
157
|
-
`toolcrib/.toolcrib-lock.json` should record the installed version.
|
|
158
|
-
|
|
159
|
-
`TOOLCRIB_API_BASE` / `TOOLCRIB_RELEASES_BASE` are the only two overrides
|
|
160
|
-
this CLI recognizes — unset, everything targets real GitHub. They exist
|
|
161
|
-
specifically to make this kind of test possible without a published
|
|
162
|
-
release or real network access.
|
|
163
|
-
|
|
164
|
-
### Bugs this integration test has already found
|
|
165
|
-
|
|
166
|
-
Worth keeping this test around — it already found three real issues that
|
|
167
|
-
unit tests, by construction, couldn't have caught:
|
|
168
|
-
|
|
169
|
-
1. **Hang on error** — a failed fetch left `@clack/prompts`' spinner
|
|
170
|
-
interval alive, so the process never exited even after printing the
|
|
171
|
-
error. Fixed by calling `process.exit(1)` explicitly in the CLI's
|
|
172
|
-
top-level error handler rather than only setting `process.exitCode`.
|
|
173
|
-
2. **Crash in non-interactive environments** — `p.confirm()` throws a raw
|
|
174
|
-
libuv TTY error (not a catchable message) when stdin/stdout aren't a
|
|
175
|
-
real terminal (CI, scripts, sandboxes). Fixed by detecting
|
|
176
|
-
`process.stdin.isTTY` and defaulting to "yes" for the (safe,
|
|
177
|
-
recoverable) `git init` prompt when non-interactive.
|
|
178
|
-
3. **`git apply` rejected the lockfile patch** — its path was built with a
|
|
179
|
-
leading `./`, which `git apply` treats as invalid even though every
|
|
180
|
-
other file's path (built without the leading `./`) applied fine. Fixed
|
|
181
|
-
by dropping the leading `./`; a regression test now locks this in.
|
|
182
|
-
|
|
183
|
-
## Publishing
|
|
190
|
+
## Upgrading — a full example
|
|
184
191
|
|
|
185
192
|
```bash
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
193
|
+
toolcrib versions # see what's available
|
|
194
|
+
toolcrib merge --version 1.4.0 # stage the upgrade
|
|
195
|
+
# review ./toolcrib-patches/
|
|
196
|
+
toolcrib apply # actually upgrade
|
|
197
|
+
toolcrib doctor # confirm nothing's left drifted
|
|
190
198
|
```
|
|
191
199
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
`
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
200
|
+
## Troubleshooting
|
|
201
|
+
|
|
202
|
+
**`toolcrib apply` says "No pending patches."**
|
|
203
|
+
There's nothing staged — run `init` (first install) or `merge` (upgrade)
|
|
204
|
+
first.
|
|
205
|
+
|
|
206
|
+
**`doctor` warns about `moduleResolution`.**
|
|
207
|
+
Set `"moduleResolution": "bundler"` (or `"node16"`/`"nodenext"`) in your
|
|
208
|
+
`tsconfig.json`'s `compilerOptions`. Your code still runs fine either way —
|
|
209
|
+
this only affects whether `tsc`/your editor understands the `#toolcrib`
|
|
210
|
+
import.
|
|
211
|
+
|
|
212
|
+
**`doctor` (or `merge`) flags a hand-edited instruction-file block.**
|
|
213
|
+
The `<!-- toolcrib:managed:... -->` block in `AGENTS.md`/`CLAUDE.md` is
|
|
214
|
+
meant to be regenerated by `toolcrib merge`, not edited by hand. Move any
|
|
215
|
+
notes of your own outside the fence, then run `merge` to restore it
|
|
216
|
+
cleanly.
|
|
217
|
+
|
|
218
|
+
**`merge` reports a conflict.**
|
|
219
|
+
You changed a vendored file yourself, and the new version changed it too.
|
|
220
|
+
Check the matching `.upstream-diff` file in `./toolcrib-patches/` for what
|
|
221
|
+
upstream did, and reconcile manually — or hand it to your AI assistant with
|
|
222
|
+
"reconcile my local changes to `<file>` with the upstream update."
|
|
223
|
+
|
|
224
|
+
**A bundler-specific note from `doctor`.**
|
|
225
|
+
`doctor` detects Next.js, Create React App, Vite, webpack, and Parcel from
|
|
226
|
+
files already in your project and calls out anything that specific
|
|
227
|
+
tool needs — for instance, Create React App's frozen webpack config
|
|
228
|
+
predating `package.json` "imports" support. If nothing's flagged for your
|
|
229
|
+
bundler, there's nothing to do.
|
|
230
|
+
|
|
231
|
+
## What this guide doesn't cover
|
|
232
|
+
|
|
233
|
+
Everything about actually *using* the toolkit — which component to reach
|
|
234
|
+
for, how theming and the event bus work, first-run gotchas with providers
|
|
235
|
+
— lives in `ai-docs/`, vendored into your project the first time you run
|
|
236
|
+
`toolcrib init`. That folder is written for your AI assistant to read, not
|
|
237
|
+
for you to read directly: point your AI assistant at it and let it handle
|
|
238
|
+
the rest.
|
|
239
|
+
|
|
240
|
+
## Contributing to the CLI itself
|
|
241
|
+
|
|
242
|
+
Working on this tool's own source (not just using it)? See
|
|
243
|
+
[CONTRIBUTING.md](CONTRIBUTING.md) for the local-dev workflow, test suite,
|
|
244
|
+
and publishing process.
|