@mgamadeus/ddd-web 0.16.2 → 0.17.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.
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  name: ddd-web-specialist
3
- description: "Use and maintain @mgamadeus/ddd-web, the TS client of mgamadeus/ddd: openapi-config.ts defineConfig (schemaFile, sideEffects, responseHandlers, invalidation), the RTK Query SDK from ddd-web-sdk (cache tags by entity identity, mergeDddTagTypes, blob downloads, multipartFiles uploads, progress via baseQuery.upload), QueryOptions builders, createDddBaseQuery (Bearer, shared refresh + retry, relogin, session-bound requests, normalizeDddError), token storage, JWT helpers, foreign global Request (MooTools: dddFetchApiRequestPlugin), the client-errors reporter /issues (browser, Node, React Native), link-skills, release. Use when wiring a frontend to a DDD backend, regenerating the SDK, building filters, uploading files, FormData, upload or download progress, fixing token refresh, guest login, a request sent under the wrong account after a switch, stale cache tags, downloading an export, requests failing in a legacy page, reporting web, server or mobile errors to the issues log, or releasing ddd-web."
3
+ description: "Use and maintain @mgamadeus/ddd-web, the TS client of mgamadeus/ddd: openapi-config.ts defineConfig (schemaFile, sideEffects, responseHandlers, invalidation), the RTK Query SDK from ddd-web-sdk (cache tags by entity identity, mergeDddTagTypes, blob downloads, multipartFiles uploads, progress via baseQuery.upload), QueryOptions builders, createDddBaseQuery (Bearer, shared refresh + retry, relogin, session-bound requests, normalizeDddError), token storage, JWT helpers, foreign global Request (MooTools: dddFetchApiRequestPlugin), the client-errors reporter /issues (browser, Node, React Native), link-skills (all DDD skills, --check), release. Use when wiring a frontend to a DDD API, regenerating the SDK, building filters, uploading files, FormData, upload or download progress, fixing token refresh, guest login, a request sent under the wrong account after a switch, stale cache tags, downloading an export, requests failing in a legacy page, reporting errors to the issues log, linking skills, or releasing ddd-web."
4
4
  metadata:
5
5
  author: mgamadeus
6
- version: "1.5.0"
6
+ version: "1.6.0"
7
7
  package: "@mgamadeus/ddd-web"
8
8
  ---
9
9
 
@@ -70,7 +70,7 @@ export default defineConfig({
70
70
 
71
71
  ```sh
72
72
  pnpm exec ddd-web-sdk # writes adminApi.ts, adminApiEnhanced.ts, adminApiTags.ts and ../models
73
- pnpm exec ddd-web link-skills # links this skill into .claude/skills/
73
+ pnpm exec ddd-web link-skills # links the skills of all DDD packages into the repo's .claude/skills/ (postinstall)
74
74
  ```
75
75
 
76
76
  Import `adminApiEnhanced` once (e.g. in the store setup) and use the hooks from `adminApi`:
@@ -83,7 +83,7 @@ ddd-web-sdk [options] (same as: ddd-web sdk [options])
83
83
  --workspace <value> value for config.workspace.envVar (alias --subdomain)
84
84
  --skip-prettier do not format the generated files
85
85
  --skip-tsc do not type-check after generation
86
- ddd-web link-skills link the package's agent skills into .claude/skills/
86
+ ddd-web link-skills link the agent skills of all DDD packages into .claude/skills/ (--check, --dry-run, --quiet, --root)
87
87
  ```
88
88
 
89
89
  Pipeline: load every spec once → validate the DDD contract parts → namespace registry from the `SchemaDefinition`
@@ -546,9 +546,29 @@ Behaviour:
546
546
 
547
547
  ## 8. Agent skills (`link-skills`)
548
548
 
549
- `pnpm exec ddd-web link-skills` symlinks every skill directory of the installed package into `.claude/skills/`.
550
- Idempotent; an existing symlink is repointed, a real file or directory is never touched. Run it after install (e.g. in
551
- `postinstall`) and commit the symlinks if the app versions its `.claude/skills`.
549
+ `ddd-web link-skills` generates the links to the agent skills of every DDD package — `node_modules/@mgamadeus/*` and
550
+ `vendor/mgamadeus/*` up to three levels below the repository root — in the repository's `.claude/skills`. Its twin
551
+ `ddd-link-skills` of mgamadeus/ddd behaves identically and shares the manifest, so either hook alone links
552
+ everything.
553
+
554
+ Wiring: `"postinstall": "ddd-web link-skills"` in the frontend's `package.json`; with a Composer backend also
555
+ `"@php vendor/bin/ddd-link-skills"` in `post-install-cmd` / `post-update-cmd`. Once: untrack the hand-made links the
556
+ tool lists (`git rm --cached -- …`) and commit with the generated `.gitignore` blocks. CI / session start:
557
+ `ddd-web link-skills --check`.
558
+
559
+ Rules worth knowing:
560
+ - Root = nearest ancestor with `.git`, else `.claude` (never the home folder); `--root` / `DDD_SKILLS_ROOT`.
561
+ - Relative targets, written into the real location when `.claude` or `.claude/skills` is a symlink; existing real
562
+ `.agents/skills` / `.codex/skills` get `../../.claude/skills/<name>`; missing mirrors are never created.
563
+ - An app skill (real folder or foreign symlink) of the same name wins and is reported as a clash; broken links into
564
+ DDD vendor areas are removed.
565
+ - `<primary>/.ddd-skills.json` records package, version, sha256 of SKILL.md and mirrors per link; a `# ddd-skills:start`
566
+ … `# ddd-skills:end` block in the `.gitignore` files lists the generated names.
567
+ - `--check` exits 1 on missing, stale or broken links, outdated manifest or gitignore block, clashes, tracked generated
568
+ links and edited vendor skills; a normal run only warns and exits 0.
569
+ - Programmatic: `runSkillLinks({ cwd, root, check, dryRun, quiet, logger })` → `{ exitCode, skills, lines, problems }`.
570
+
571
+ Full spec: the package README, "Agent skills (`link-skills`)".
552
572
 
553
573
  ## 9. Troubleshooting
554
574
 
@@ -31,6 +31,8 @@ test/ vitest suites per subpath; fixtures/specs/sample-admin.json (neutr
31
31
  consumer/ (installed-package check); fixtures/private/ is ignored — never commit app specs
32
32
  scripts/ clean.mjs (dist cleaned once before tsup), check-package.mjs (exports / bin targets, --require-skills)
33
33
  .claude/skills/ddd-web-specialist/ this skill — shipped in the tarball, linked into apps by `ddd-web link-skills`
34
+ (link-skills.ts mirrors `ddd-link-skills` of mgamadeus/ddd: a behaviour change lands in both
35
+ implementations and both test suites, same fixture layouts)
34
36
  ```
35
37
 
36
38
  Each subpath is its own tsup entry with its own `.d.ts`; `codegen` is Node-only and must never be imported from the
package/CHANGELOG.md CHANGED
@@ -1,5 +1,52 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.17.1
4
+
5
+ ### Fixed
6
+ - A CommonJS script that loads code importing `@mgamadeus/ddd-web/contract` no longer fails with
7
+ `ERR_PACKAGE_PATH_NOT_EXPORTED`: the entries without runtime dependencies (`/contract`, `/query`, `/auth`,
8
+ `/fetch-api-request`, `/issues`, `/issues/browser`, `/issues/node`, `/issues/wire`) have a `default` condition on
9
+ their ES module build, so `require()` loads them on Node ≥ 20.19 / ≥ 22.12 (require of an ES module; no entry uses
10
+ top-level await). On an older Node 20 the error is now `ERR_REQUIRE_ESM`.
11
+ - No CommonJS build: one module instance per entry, no dual-package state. `/api` (RTK Query peer dependency),
12
+ `/vite` and `/codegen` stay import-only.
13
+
14
+ ### Tests
15
+ - The consumer check requires every entry with a `default` condition from a CommonJS script against the packed
16
+ tarball (`test/consumer/smoke-require.cjs`); a manifest test pins which entries are requirable.
17
+
18
+ ## 0.17.0
19
+
20
+ ### Changed
21
+ - `ddd-web link-skills` is now the vendor skill links tool shared with `ddd-link-skills` of mgamadeus/ddd 3.36.0
22
+ (same behaviour, output and manifest; spec in the README, "Agent skills"):
23
+ - finds the repository root (nearest ancestor with `.git`, else `.claude`; `--root`, `DDD_SKILLS_ROOT`), so the
24
+ postinstall of a frontend in a subfolder links into the repository's `.claude/skills`, not `web/.claude/skills`;
25
+ - links the skills of every `node_modules/@mgamadeus/*` AND `vendor/mgamadeus/*` package up to three levels below
26
+ the root, not only this package's; a name shipped by two packages is reported as a clash;
27
+ - writes into the real location when `.claude` or `.claude/skills` is a symlink, mirrors into existing real
28
+ `.agents/skills` / `.codex/skills` folders (`../../.claude/skills/<name>`), never creates or changes a mirror
29
+ layout;
30
+ - removes broken links into DDD vendor areas (skill or package removed); app skills, real folders and foreign
31
+ symlinks are never touched;
32
+ - records each link in `<primary>/.ddd-skills.json` and keeps a `# ddd-skills:start` … `# ddd-skills:end` block in
33
+ the `.gitignore` files; reports generated links git still tracks with the `git rm --cached` command;
34
+ - output prefixed `[ddd-skills]`, one line per change; a normal run exits 0 (warnings), 1 only on a write error.
35
+ - `linkSkills()` keeps its signature and result (`linked` / `relinked` / `unchanged` / `skipped`, now with
36
+ `package`); `cwd` is where the root search starts; `sourceDir` is deprecated.
37
+
38
+ ### Added
39
+ - `ddd-web link-skills --check` (CI, session start: exit 1 on missing, stale or broken links, outdated manifest or
40
+ gitignore block, clashes, tracked generated links, edited vendor skills), `--dry-run`, `--quiet`, `--root <dir>`.
41
+ - `runSkillLinks()`, `findSkillsRepositoryRoot()` and the types `SkillLinksOptions`, `SkillLinksReport`,
42
+ `SkillsManifest`, `SkillsManifestEntry` from `/codegen`.
43
+
44
+ ### App side
45
+ - `web/package.json`: `"postinstall": "ddd-web link-skills"`; with a Composer backend also
46
+ `"@php vendor/bin/ddd-link-skills"` in `post-install-cmd` / `post-update-cmd` (either hook alone links everything).
47
+ - Once: untrack the formerly hand-made links the tool lists (`git rm --cached -- …`) and commit them with the new
48
+ `.gitignore` blocks; add `ddd-web link-skills --check` to CI.
49
+
3
50
  ## 0.16.2
4
51
 
5
52
  ### Fixed
package/README.md CHANGED
@@ -47,13 +47,18 @@ export default defineConfig({
47
47
 
48
48
  ```sh
49
49
  pnpm exec ddd-web-sdk # generate the SDK
50
- pnpm exec ddd-web link-skills # link the package's agent skills into .claude/skills
50
+ pnpm exec ddd-web link-skills # link the agent skills of all DDD packages into .claude/skills
51
51
  ```
52
52
 
53
53
  Subpaths: `@mgamadeus/ddd-web/codegen`, `/query`, `/api`, `/auth`, `/contract`, `/fetch-api-request`, `/vite`
54
54
  (pages whose global `Request` is not the Fetch API's, e.g. MooTools or Prototype: `dddFetchApiRequestPlugin()`) and
55
55
  `/issues`, `/issues/browser`, `/issues/node`, `/issues/wire` (client errors, below).
56
56
 
57
+ The package is an ES module. A CommonJS script may `require()` the entries without runtime dependencies — `/contract`,
58
+ `/query`, `/auth`, `/fetch-api-request`, `/issues`, `/issues/browser`, `/issues/node`, `/issues/wire` — on Node
59
+ ≥ 20.19 or ≥ 22.12 (Node's require of an ES module; none of them uses top-level await). `/api` (RTK Query), `/vite`
60
+ and `/codegen` are import-only.
61
+
57
62
  ### File downloads
58
63
 
59
64
  Endpoints whose 2xx responses are files (`application/octet-stream`, `application/zip`, `application/pdf`,
@@ -198,10 +203,112 @@ Everything is redacted on the device (tokens in paths and queries, e-mails, bear
198
203
  known noise is dropped, repeats are folded into `count`, and caps, batching, retry and backoff keep a broken page from
199
204
  flooding the endpoint. Details: the agent skill, `references/consumer.md` › Client errors.
200
205
 
201
- ## Agent skill
206
+ ## Agent skills (`link-skills`)
207
+
208
+ The package ships the agent skill `ddd-web-specialist` (consumer guide + maintaining guide). `ddd-web link-skills`
209
+ links it — and the skills of every other DDD package installed through npm or Composer — into the repository's
210
+ `.claude/skills`:
211
+
212
+ ```sh
213
+ ddd-web link-skills [--check] [--dry-run] [--quiet] [--root <dir>]
214
+ ```
215
+
216
+ ```json
217
+ { "scripts": { "postinstall": "ddd-web link-skills" } }
218
+ ```
219
+
220
+ Programmatic: `runSkillLinks({ cwd, root, check, dryRun, quiet, logger })` from `/codegen` returns a report with
221
+ `exitCode`, `skills`, `lines` and `problems`; `linkSkills()` (one result per skill) stays for existing callers.
222
+
223
+ ### Vendor skill links — behaviour (shared by `ddd-link-skills` and `ddd-web link-skills`)
224
+
225
+ DDD packages ship agent skills at `<package>/.claude/skills/<name>/SKILL.md`. `ddd-link-skills` (Composer package
226
+ `mgamadeus/ddd`) and `ddd-web link-skills` (npm package `@mgamadeus/ddd-web`) generate and maintain the links to them.
227
+ Both behave identically, print the same lines and read and write the same manifest, so a Composer hook and an npm
228
+ postinstall never fight; either one alone links everything.
229
+
230
+ 1. **Root**: the nearest ancestor of the working directory (itself included) that contains `.git` (folder or file),
231
+ else the nearest that contains `.claude` (never the home folder), else the working directory. `--root <dir>` or the
232
+ env variable `DDD_SKILLS_ROOT` override it. The install may run in a subfolder (Composer in `app/`, npm in `web/`).
233
+ 2. **Discovery**: every `vendor/mgamadeus/*` and `node_modules/@mgamadeus/*` whose `vendor/` / `node_modules/` folder
234
+ lies at most three levels below the root (`vendor/`, `app/vendor/`, `apps/admin/node_modules/`); other `vendor/`,
235
+ `node_modules/` and dot folders are not searched, symlinked folders are not followed. A skill is a folder with a
236
+ `SKILL.md`. Order: skill path, byte order. The same name from two packages is a clash: the first is kept and the
237
+ clash reported. The same package installed twice (two Composer roots) is not a clash.
238
+ 3. **Primary folder** `<root>/.claude/skills`, created when missing. When `.claude` or `.claude/skills` is a symlink
239
+ (for example to `.codex`), the links go into its real location, once.
240
+ 4. **Mirrors** `<root>/.agents/skills` and `<root>/.codex/skills` (Codex): the layout is detected, never changed. A
241
+ missing mirror is not created; a mirror (or its parent) that resolves to the primary folder gets nothing; a mirror
242
+ that is a real folder gets one link per skill, `../../.claude/skills/<name>`, pointing to the primary entry.
243
+ 5. **Links**: relative targets from the link's real folder to the skill folder, for example
244
+ `../../app/vendor/mgamadeus/ddd/.claude/skills/ddd-entity-specialist`. Idempotent; a link into a DDD vendor area
245
+ with another target is repointed. A real file or folder, or a symlink that points elsewhere, is never touched: it
246
+ is reported as a clash with the app's own skill.
247
+ 6. **Cleanup**: broken symlinks in the primary folder and the mirrors whose target lies in a `vendor/mgamadeus/` or
248
+ `node_modules/@mgamadeus/` path are deleted (skill no longer shipped, package removed), and so are mirror links to
249
+ primary entries that were removed. Only symlinks; app skills and real folders stay.
250
+ 7. **Manifest** `<primary>/.ddd-skills.json` (format below), rewritten only when its content changes. An entry whose
251
+ link still resolves but whose package was not found by this run (another install tree) is kept.
252
+ 8. **Git**: a managed block in `<primary>/.gitignore` and in each real mirror folder's `.gitignore` lists the generated
253
+ link names (and, in the primary, the manifest); everything outside the block stays. Nothing is removed from git:
254
+ generated links that git still tracks are reported with the exact `git rm --cached -- …` command.
255
+ 9. **`--check`**: changes nothing and exits 1, with a list, on missing links, stale targets, broken DDD links, an
256
+ outdated manifest or gitignore block, clashes, generated paths still tracked, and edited vendor skills (same package
257
+ version as in the manifest, different SKILL.md hash; a normal run warns and keeps the recorded hash, so the check
258
+ keeps failing until the package is reinstalled). `--dry-run` prints what would change; `--quiet` prints only
259
+ warnings and problems.
260
+ 10. **Output and exit code**: one line per change, prefixed `[ddd-skills]`. A normal run always exits 0 (clashes and
261
+ tracked links are warnings), except on an unexpected error writing the folder (exit 1).
262
+
263
+ Manifest:
264
+
265
+ ```json
266
+ {
267
+ "format": 1,
268
+ "skills": {
269
+ "ddd-entity-specialist": {
270
+ "package": "mgamadeus/ddd",
271
+ "version": "3.36.0",
272
+ "source": "app/vendor/mgamadeus/ddd/.claude/skills/ddd-entity-specialist",
273
+ "target": "../../app/vendor/mgamadeus/ddd/.claude/skills/ddd-entity-specialist",
274
+ "sha256": "<sha256 of SKILL.md>",
275
+ "mirrors": [".agents/skills"]
276
+ }
277
+ }
278
+ }
279
+ ```
280
+
281
+ `version` comes from `vendor/composer/installed.json` (else the package's `composer.json`) or the package's
282
+ `package.json`; `source` is relative to the root. Both tools write it byte-identically (4-space JSON, names sorted,
283
+ trailing newline).
284
+
285
+ Gitignore block:
286
+
287
+ ```gitignore
288
+ # ddd-skills:start
289
+ # Generated by ddd-link-skills / ddd-web link-skills; rewritten on every install.
290
+ /.ddd-skills.json
291
+ /ddd-entity-specialist
292
+ # ddd-skills:end
293
+ ```
202
294
 
203
- The package ships the agent skill `ddd-web-specialist` (consumer guide + maintaining guide). Link it into an app's
204
- `.claude/skills` with `pnpm exec ddd-web link-skills`.
295
+ ### App-side setup
296
+
297
+ For an app whose Composer root is `app/` and whose frontend is `web/`:
298
+
299
+ 1. `app/composer.json`, alongside the existing scripts:
300
+ ```json
301
+ "scripts": {
302
+ "post-install-cmd": ["@php vendor/bin/ddd-link-skills", "..."],
303
+ "post-update-cmd": ["@php vendor/bin/ddd-link-skills", "..."]
304
+ }
305
+ ```
306
+ 2. `web/package.json`: `"postinstall": "ddd-web link-skills"` (an app that installs with `ignore-scripts` relies on
307
+ the Composer hook, which links the npm skills too).
308
+ 3. Run the install once, then untrack the formerly hand-made links the tool reports
309
+ (`git rm --cached -- .claude/skills/ddd-entity-specialist …`) and commit together with the new `.gitignore` blocks.
310
+ 4. CI or session start: `php app/vendor/bin/ddd-link-skills --check` (or `pnpm --dir web exec ddd-web link-skills
311
+ --check`).
205
312
 
206
313
  ## Development
207
314