@xylabs/ts-scripts-yarn3 7.5.9 → 7.5.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/ts-scripts-yarn3",
3
- "version": "7.5.9",
3
+ "version": "7.5.11",
4
4
  "description": "TypeScript project scripts",
5
5
  "keywords": [
6
6
  "xylabs",
@@ -50,15 +50,15 @@
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/yargs": "~17.0.35",
53
- "@xylabs/ts-scripts-common": "~7.5.9",
54
- "@xylabs/tsconfig": "~7.5.9",
53
+ "@xylabs/ts-scripts-common": "~7.5.11",
54
+ "@xylabs/tsconfig": "~7.5.11",
55
55
  "publint": "~0.3.18",
56
56
  "tsup": "~8.5.1",
57
57
  "typescript": "^5.9.3",
58
58
  "vitest": "^4.1.1"
59
59
  },
60
60
  "peerDependencies": {
61
- "@xylabs/ts-scripts-common": "~7.5.9",
61
+ "@xylabs/ts-scripts-common": "~7.5.11",
62
62
  "typescript": "~5"
63
63
  },
64
64
  "engines": {
@@ -0,0 +1,254 @@
1
+ ---
2
+ name: xylabs-xy-deplint-fix
3
+ description: >
4
+ Fix dependency declaration errors in one or more packages using `xy deplint`.
5
+ Use this skill whenever the user asks to fix deplint errors, clean up package.json
6
+ dependencies, or resolve "dependency should be devDependency" / "missing dependency"
7
+ warnings in an XY Labs monorepo. If a package name is supplied as an argument, fix
8
+ only that package. If no argument is given, fix all packages in the repo.
9
+ ---
10
+
11
+ # xylabs-xy-deplint-fix
12
+
13
+ Diagnoses and fixes `package.json` dependency declaration errors reported by `xy deplint`
14
+ in an XY Labs Yarn-workspaces monorepo.
15
+
16
+ ---
17
+
18
+ ## Bundled Scripts
19
+
20
+ Three shell scripts live alongside this skill in `scripts/`. They collapse multiple
21
+ bash operations into single approved calls, minimising permission prompts:
22
+
23
+ | Script | Purpose | Prompts saved |
24
+ |--------|---------|---------------|
25
+ | `scripts/deplint-scan.sh [pkg]` | Run deplint; emit structured `PACKAGE/ERROR/PATH/STATUS` lines | Replaces 1 raw deplint call with parseable output |
26
+ | `scripts/deplint-install.sh` | Run full `yarn install` (or `pnpm install`) from repo root | Always safe to approve once; never uses `workspaces focus` |
27
+ | `scripts/deplint-verify.sh pkg1 [pkg2 …]` | Check N packages in one call; prints `PASS/FAIL` per package | Replaces N individual verify calls with one |
28
+
29
+ **How to use them in the workflow:**
30
+
31
+ ```
32
+ Step 1 → bash scripts/deplint-scan.sh [pkg] # 1 approval
33
+ Step 3 → (LLM reads/writes package.json files) # no prompts
34
+ Step 4 → bash scripts/deplint-install.sh # 1 approval
35
+ Step 5 → bash scripts/deplint-verify.sh <pkgs…> # 1 approval
36
+ ```
37
+
38
+ All three scripts auto-detect the repo root (walking up until they find `yarn.lock`
39
+ or `pnpm-lock.yaml`), so they work correctly regardless of the current working directory.
40
+
41
+ ---
42
+
43
+ ## Package Manager Detection
44
+
45
+ Check the repo root before running any command:
46
+
47
+ * `yarn.lock` present → prefix commands with **yarn** (e.g. `yarn xy deplint`)
48
+ * `pnpm-lock.yaml` present → prefix commands with **pnpm**
49
+
50
+ All commands below are shown without a prefix. Prepend accordingly.
51
+
52
+ ---
53
+
54
+ ## Determine scope from arguments
55
+
56
+ * **Argument provided** (e.g. `@xyo-network/advertising-payload-plugins`) → single-package
57
+ mode: run Steps 1–5 for that package only, then stop.
58
+ * **No argument** → whole-repo mode: run `xy deplint` without a package name to get all
59
+ problems, extract the unique set of affected package names from the output, then run
60
+ Steps 1–5 for each affected package in turn.
61
+
62
+ ---
63
+
64
+ ## Step 1 — Run deplint
65
+
66
+ Use the bundled scan script (preferred — one approval, structured output):
67
+
68
+ ```bash
69
+ # Single-package
70
+ bash .claude/skills/xylabs-xy-deplint-fix/scripts/deplint-scan.sh @scope/package-name
71
+
72
+ # Whole-repo
73
+ bash .claude/skills/xylabs-xy-deplint-fix/scripts/deplint-scan.sh
74
+ ```
75
+
76
+ Output lines have the form:
77
+
78
+ ```
79
+ PACKAGE:@scope/package-name
80
+ ERROR:<problem description>:<dep>
81
+ PATH:packages/path/to/package.json
82
+ STATUS:errors # or STATUS:clean
83
+ ```
84
+
85
+ In whole-repo mode, collect every unique `PACKAGE:` line to build the list of packages
86
+ to fix. Work through them one at a time.
87
+
88
+ Alternatively, run deplint directly:
89
+
90
+ ```bash
91
+ xy deplint [package-name]
92
+ ```
93
+
94
+ Each problem line has the form:
95
+
96
+ ```
97
+ [@scope/package-name] <problem description>: <dependency-name>
98
+ <path/to/package.json>
99
+ ```
100
+
101
+ ---
102
+
103
+ ## Step 2 — Classify each error
104
+
105
+ | Error message | Meaning | Fix |
106
+ |---|---|---|
107
+ | `dependency should be devDependency` | Listed in `dependencies` but not needed by npm consumers at runtime — it's a build/type/test dep, or it's a peer that consumers already provide | Move from `dependencies` → `devDependencies` |
108
+ | `Unused devDependency` | Listed in `devDependencies` but no import of it was found anywhere in the package's source | Remove from `devDependencies` |
109
+ | `Missing dependency` | Imported in source but absent from `dependencies` | Add to `dependencies` |
110
+ | `Missing devDependency` | Imported in source but absent from `devDependencies` | Add to `devDependencies` |
111
+
112
+ > **Aggregator packages** (packages with no `src/` that only re-export workspace children)
113
+ > typically need all of their workspace children as `devDependencies`, not `dependencies`.
114
+ > See Edge Cases below.
115
+
116
+ ---
117
+
118
+ ## Step 3 — Edit the package.json
119
+
120
+ Open the `package.json` file identified in the deplint output and apply the fix for each
121
+ classified error:
122
+
123
+ * **Move dep**: cut the entry from `dependencies`, paste into `devDependencies`.
124
+ * **Remove dep**: delete the entry entirely from `devDependencies`.
125
+ * **Add dep**: insert the entry with the correct version into the appropriate section.
126
+ Resolve the version using this priority order:
127
+
128
+ 1. **Lock file** (preferred) — search `yarn.lock` or `pnpm-lock.yaml` for the
129
+ package name. Use the resolved version already present in the repo.
130
+ * In `yarn.lock`, look for a block starting with `"<pkg>@`:
131
+ ```
132
+ "@xyo-network/payload-model@npm:~5.3.5":
133
+ version: 5.3.7
134
+ ```
135
+ Use the declared range (e.g. `~5.3.5`), not the resolved exact version.
136
+ * In `pnpm-lock.yaml`, find the entry under `packages:` and use its
137
+ specifier (e.g. `~5.3.5`).
138
+
139
+ 2. **Another package.json in the repo** — if the lock file entry is unclear,
140
+ grep other `package.json` files in the monorepo for the dep name and
141
+ copy the version string used there.
142
+
143
+ 3. **Latest from the registry** — if the dep does not exist anywhere in the
144
+ repo yet, it is safe to use `~latest` by running:
145
+ ```bash
146
+ npm view <package-name> version
147
+ ```
148
+ Then prefix the result with `~` (e.g. `~5.4.0`).
149
+
150
+ **Version format rule:** prefer `~` ranges throughout. If the sourced version
151
+ already carries a range prefix (`~` or `^`), keep it as-is. If it is a bare
152
+ semver (e.g. `5.3.1`), add a `~` prefix (e.g. `~5.3.1`).
153
+ * If `dependencies` becomes empty after edits, remove the `"dependencies"` key entirely
154
+ to keep the file clean.
155
+
156
+ ---
157
+
158
+ ## Step 4 — Reinstall dependencies
159
+
160
+ After editing `package.json`, run a **full install from the repo root**. Do not use
161
+ `yarn workspaces focus` — it strips the `xy` scripts needed for verification.
162
+
163
+ Use the bundled install script (preferred — one approval, always runs from root):
164
+
165
+ ```bash
166
+ bash .claude/skills/xylabs-xy-deplint-fix/scripts/deplint-install.sh
167
+ ```
168
+
169
+ Or directly:
170
+
171
+ ```bash
172
+ yarn install # or: pnpm install
173
+ ```
174
+
175
+ ---
176
+
177
+ ## Step 5 — Verify
178
+
179
+ Use the bundled verify script (preferred — verifies multiple packages in one approval):
180
+
181
+ ```bash
182
+ bash .claude/skills/xylabs-xy-deplint-fix/scripts/deplint-verify.sh <pkg1> [pkg2 …]
183
+ ```
184
+
185
+ Or directly:
186
+
187
+ ```bash
188
+ xy deplint <package-name>
189
+ ```
190
+
191
+ **Definition of done for a single package:** output contains `PASS: <name>` or:
192
+
193
+ ```
194
+ Deplint: Found no dependency problems. ✔
195
+ ```
196
+
197
+ If problems remain, return to Step 2 and repeat the loop for the same package.
198
+
199
+ ---
200
+
201
+ ## Step 6 — Advance to the next package (whole-repo mode only)
202
+
203
+ In whole-repo mode, once a package passes Step 5, move to the next package in the list
204
+ collected in Step 1 and repeat Steps 2–5 for it.
205
+
206
+ **Definition of done for whole-repo mode:** every package that appeared in the original
207
+ `xy deplint` output now passes `xy deplint <package-name>` individually. Confirm by
208
+ running a final `xy deplint` (no arguments) and verifying:
209
+
210
+ ```
211
+ Deplint: Found no dependency problems. ✔
212
+ ```
213
+
214
+ ---
215
+
216
+ ## Edge Cases
217
+
218
+ ### `yarn workspaces focus` breaks the `xy` command
219
+
220
+ `yarn workspaces focus <package>` installs only the deps for that one package and removes
221
+ the root-level `xy` script bindings. Always use `yarn install` (full) after editing any
222
+ `package.json`.
223
+
224
+ ### Empty `dependencies` block after migration
225
+
226
+ If all entries are moved out of `dependencies`, remove the key entirely. An empty
227
+ `"dependencies": {}` is harmless but creates noise and may confuse other tools.
228
+
229
+ ### Formatter auto-sorts keys
230
+
231
+ The repo formatter (run as part of `yarn install` hooks) may re-sort `devDependencies`
232
+ alphabetically. This is expected — do not revert it.
233
+
234
+ ### Aggregator packages
235
+
236
+ Aggregator packages (e.g. `packages/payload/package.json`, `packages/sdk/package.json`)
237
+ have no `src/` and exist solely to re-export leaf packages. In these packages:
238
+
239
+ * Workspace child packages belong in `devDependencies`, not `dependencies`
240
+ * Their transitive deps (e.g. `@xyo-network/payload-model`) will also surface as
241
+ `Missing devDependency` because deplint walks the leaf source files from the
242
+ aggregator's root
243
+
244
+ Fix: move all workspace children to `devDependencies`, then add any missing transitive
245
+ deps (also as `devDependencies`).
246
+
247
+ ### `dependency should be devDependency` for a runtime import
248
+
249
+ deplint may flag a dep as "should be devDependency" even when it is imported for a
250
+ runtime value (not just a type). This happens when the dep is a **foundational library**
251
+ that consumers of the package are expected to already have installed (i.e. it behaves
252
+ like a peer). In these cases the correct fix is still to move it to `devDependencies`.
253
+ If the dep must be guaranteed for external npm consumers, also add it to
254
+ `peerDependencies`.