@mgamadeus/ddd-web 0.16.2 → 0.17.0

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,37 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.17.0
4
+
5
+ ### Changed
6
+ - `ddd-web link-skills` is now the vendor skill links tool shared with `ddd-link-skills` of mgamadeus/ddd 3.36.0
7
+ (same behaviour, output and manifest; spec in the README, "Agent skills"):
8
+ - finds the repository root (nearest ancestor with `.git`, else `.claude`; `--root`, `DDD_SKILLS_ROOT`), so the
9
+ postinstall of a frontend in a subfolder links into the repository's `.claude/skills`, not `web/.claude/skills`;
10
+ - links the skills of every `node_modules/@mgamadeus/*` AND `vendor/mgamadeus/*` package up to three levels below
11
+ the root, not only this package's; a name shipped by two packages is reported as a clash;
12
+ - writes into the real location when `.claude` or `.claude/skills` is a symlink, mirrors into existing real
13
+ `.agents/skills` / `.codex/skills` folders (`../../.claude/skills/<name>`), never creates or changes a mirror
14
+ layout;
15
+ - removes broken links into DDD vendor areas (skill or package removed); app skills, real folders and foreign
16
+ symlinks are never touched;
17
+ - records each link in `<primary>/.ddd-skills.json` and keeps a `# ddd-skills:start` … `# ddd-skills:end` block in
18
+ the `.gitignore` files; reports generated links git still tracks with the `git rm --cached` command;
19
+ - output prefixed `[ddd-skills]`, one line per change; a normal run exits 0 (warnings), 1 only on a write error.
20
+ - `linkSkills()` keeps its signature and result (`linked` / `relinked` / `unchanged` / `skipped`, now with
21
+ `package`); `cwd` is where the root search starts; `sourceDir` is deprecated.
22
+
23
+ ### Added
24
+ - `ddd-web link-skills --check` (CI, session start: exit 1 on missing, stale or broken links, outdated manifest or
25
+ gitignore block, clashes, tracked generated links, edited vendor skills), `--dry-run`, `--quiet`, `--root <dir>`.
26
+ - `runSkillLinks()`, `findSkillsRepositoryRoot()` and the types `SkillLinksOptions`, `SkillLinksReport`,
27
+ `SkillsManifest`, `SkillsManifestEntry` from `/codegen`.
28
+
29
+ ### App side
30
+ - `web/package.json`: `"postinstall": "ddd-web link-skills"`; with a Composer backend also
31
+ `"@php vendor/bin/ddd-link-skills"` in `post-install-cmd` / `post-update-cmd` (either hook alone links everything).
32
+ - Once: untrack the formerly hand-made links the tool lists (`git rm --cached -- …`) and commit them with the new
33
+ `.gitignore` blocks; add `ddd-web link-skills --check` to CI.
34
+
3
35
  ## 0.16.2
4
36
 
5
37
  ### Fixed
package/README.md CHANGED
@@ -47,7 +47,7 @@ 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`
@@ -198,10 +198,112 @@ Everything is redacted on the device (tokens in paths and queries, e-mails, bear
198
198
  known noise is dropped, repeats are folded into `count`, and caps, batching, retry and backoff keep a broken page from
199
199
  flooding the endpoint. Details: the agent skill, `references/consumer.md` › Client errors.
200
200
 
201
- ## Agent skill
201
+ ## Agent skills (`link-skills`)
202
202
 
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`.
203
+ The package ships the agent skill `ddd-web-specialist` (consumer guide + maintaining guide). `ddd-web link-skills`
204
+ links it — and the skills of every other DDD package installed through npm or Composer — into the repository's
205
+ `.claude/skills`:
206
+
207
+ ```sh
208
+ ddd-web link-skills [--check] [--dry-run] [--quiet] [--root <dir>]
209
+ ```
210
+
211
+ ```json
212
+ { "scripts": { "postinstall": "ddd-web link-skills" } }
213
+ ```
214
+
215
+ Programmatic: `runSkillLinks({ cwd, root, check, dryRun, quiet, logger })` from `/codegen` returns a report with
216
+ `exitCode`, `skills`, `lines` and `problems`; `linkSkills()` (one result per skill) stays for existing callers.
217
+
218
+ ### Vendor skill links — behaviour (shared by `ddd-link-skills` and `ddd-web link-skills`)
219
+
220
+ DDD packages ship agent skills at `<package>/.claude/skills/<name>/SKILL.md`. `ddd-link-skills` (Composer package
221
+ `mgamadeus/ddd`) and `ddd-web link-skills` (npm package `@mgamadeus/ddd-web`) generate and maintain the links to them.
222
+ Both behave identically, print the same lines and read and write the same manifest, so a Composer hook and an npm
223
+ postinstall never fight; either one alone links everything.
224
+
225
+ 1. **Root**: the nearest ancestor of the working directory (itself included) that contains `.git` (folder or file),
226
+ else the nearest that contains `.claude` (never the home folder), else the working directory. `--root <dir>` or the
227
+ env variable `DDD_SKILLS_ROOT` override it. The install may run in a subfolder (Composer in `app/`, npm in `web/`).
228
+ 2. **Discovery**: every `vendor/mgamadeus/*` and `node_modules/@mgamadeus/*` whose `vendor/` / `node_modules/` folder
229
+ lies at most three levels below the root (`vendor/`, `app/vendor/`, `apps/admin/node_modules/`); other `vendor/`,
230
+ `node_modules/` and dot folders are not searched, symlinked folders are not followed. A skill is a folder with a
231
+ `SKILL.md`. Order: skill path, byte order. The same name from two packages is a clash: the first is kept and the
232
+ clash reported. The same package installed twice (two Composer roots) is not a clash.
233
+ 3. **Primary folder** `<root>/.claude/skills`, created when missing. When `.claude` or `.claude/skills` is a symlink
234
+ (for example to `.codex`), the links go into its real location, once.
235
+ 4. **Mirrors** `<root>/.agents/skills` and `<root>/.codex/skills` (Codex): the layout is detected, never changed. A
236
+ missing mirror is not created; a mirror (or its parent) that resolves to the primary folder gets nothing; a mirror
237
+ that is a real folder gets one link per skill, `../../.claude/skills/<name>`, pointing to the primary entry.
238
+ 5. **Links**: relative targets from the link's real folder to the skill folder, for example
239
+ `../../app/vendor/mgamadeus/ddd/.claude/skills/ddd-entity-specialist`. Idempotent; a link into a DDD vendor area
240
+ with another target is repointed. A real file or folder, or a symlink that points elsewhere, is never touched: it
241
+ is reported as a clash with the app's own skill.
242
+ 6. **Cleanup**: broken symlinks in the primary folder and the mirrors whose target lies in a `vendor/mgamadeus/` or
243
+ `node_modules/@mgamadeus/` path are deleted (skill no longer shipped, package removed), and so are mirror links to
244
+ primary entries that were removed. Only symlinks; app skills and real folders stay.
245
+ 7. **Manifest** `<primary>/.ddd-skills.json` (format below), rewritten only when its content changes. An entry whose
246
+ link still resolves but whose package was not found by this run (another install tree) is kept.
247
+ 8. **Git**: a managed block in `<primary>/.gitignore` and in each real mirror folder's `.gitignore` lists the generated
248
+ link names (and, in the primary, the manifest); everything outside the block stays. Nothing is removed from git:
249
+ generated links that git still tracks are reported with the exact `git rm --cached -- …` command.
250
+ 9. **`--check`**: changes nothing and exits 1, with a list, on missing links, stale targets, broken DDD links, an
251
+ outdated manifest or gitignore block, clashes, generated paths still tracked, and edited vendor skills (same package
252
+ version as in the manifest, different SKILL.md hash; a normal run warns and keeps the recorded hash, so the check
253
+ keeps failing until the package is reinstalled). `--dry-run` prints what would change; `--quiet` prints only
254
+ warnings and problems.
255
+ 10. **Output and exit code**: one line per change, prefixed `[ddd-skills]`. A normal run always exits 0 (clashes and
256
+ tracked links are warnings), except on an unexpected error writing the folder (exit 1).
257
+
258
+ Manifest:
259
+
260
+ ```json
261
+ {
262
+ "format": 1,
263
+ "skills": {
264
+ "ddd-entity-specialist": {
265
+ "package": "mgamadeus/ddd",
266
+ "version": "3.36.0",
267
+ "source": "app/vendor/mgamadeus/ddd/.claude/skills/ddd-entity-specialist",
268
+ "target": "../../app/vendor/mgamadeus/ddd/.claude/skills/ddd-entity-specialist",
269
+ "sha256": "<sha256 of SKILL.md>",
270
+ "mirrors": [".agents/skills"]
271
+ }
272
+ }
273
+ }
274
+ ```
275
+
276
+ `version` comes from `vendor/composer/installed.json` (else the package's `composer.json`) or the package's
277
+ `package.json`; `source` is relative to the root. Both tools write it byte-identically (4-space JSON, names sorted,
278
+ trailing newline).
279
+
280
+ Gitignore block:
281
+
282
+ ```gitignore
283
+ # ddd-skills:start
284
+ # Generated by ddd-link-skills / ddd-web link-skills; rewritten on every install.
285
+ /.ddd-skills.json
286
+ /ddd-entity-specialist
287
+ # ddd-skills:end
288
+ ```
289
+
290
+ ### App-side setup
291
+
292
+ For an app whose Composer root is `app/` and whose frontend is `web/`:
293
+
294
+ 1. `app/composer.json`, alongside the existing scripts:
295
+ ```json
296
+ "scripts": {
297
+ "post-install-cmd": ["@php vendor/bin/ddd-link-skills", "..."],
298
+ "post-update-cmd": ["@php vendor/bin/ddd-link-skills", "..."]
299
+ }
300
+ ```
301
+ 2. `web/package.json`: `"postinstall": "ddd-web link-skills"` (an app that installs with `ignore-scripts` relies on
302
+ the Composer hook, which links the npm skills too).
303
+ 3. Run the install once, then untrack the formerly hand-made links the tool reports
304
+ (`git rm --cached -- .claude/skills/ddd-entity-specialist …`) and commit together with the new `.gitignore` blocks.
305
+ 4. CI or session start: `php app/vendor/bin/ddd-link-skills --check` (or `pnpm --dir web exec ddd-web link-skills
306
+ --check`).
205
307
 
206
308
  ## Development
207
309