@jskit-ai/agent-docs 0.1.373 → 0.1.375

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.
Files changed (62) hide show
  1. package/guide/agent/app-setup/authentication.md +34 -18
  2. package/guide/agent/app-setup/database-layer.md +42 -18
  3. package/guide/agent/app-setup/existing-application-migration.md +3 -2
  4. package/guide/agent/app-setup/initial-scaffolding.md +3 -2
  5. package/guide/agent/app-setup/package-with-nix.md +4 -2
  6. package/guide/agent/framework/data-access.md +4 -2
  7. package/guide/agent/framework/material-3.md +4 -2
  8. package/guide/agent/framework/security-pass.md +2 -1
  9. package/guide/agent/framework/test-pass.md +55 -4
  10. package/guide/agent/framework/typed-features.md +45 -3
  11. package/package.json +1 -1
  12. package/patterns/feature-package/example/booking-engine/package.json +1 -1
  13. package/patterns/minimal-foundation/example/AGENTS.md +4 -2
  14. package/patterns/minimal-foundation/example/package.json +3 -3
  15. package/patterns/minimal-foundation/example/server.js +2 -2
  16. package/patterns/shell-foundation/example/AGENTS.md +4 -2
  17. package/patterns/shell-foundation/example/package.json +4 -4
  18. package/patterns/shell-foundation/example/packages/main/package.json +1 -1
  19. package/patterns/shell-foundation/example/server.js +2 -2
  20. package/patterns/shell-foundation/example/src/components/ShellLayout.vue +13 -10
  21. package/reference/autogen/KERNEL_MAP.md +2 -0
  22. package/reference/autogen/PATTERN_INDEX.md +39 -39
  23. package/reference/autogen/packages/agent-docs.md +1 -1
  24. package/reference/autogen/packages/assistant-core.md +11 -8
  25. package/reference/autogen/packages/database-runtime.md +26 -4
  26. package/reference/autogen/packages/kernel.md +7 -2
  27. package/reference/autogen/packages/oidc-issuer-core.md +2 -2
  28. package/reference/autogen/packages/resource-runtime.md +1 -1
  29. package/reference/autogen/packages/shell-web.md +9 -1
  30. package/reference/autogen/tooling/jskit-catalog.md +31 -16
  31. package/reference/autogen/tooling/jskit-release.md +2 -1
  32. package/reference/autogen/tooling/testUtils.md +7 -0
  33. package/skills/jskit/references/data-access.md +4 -2
  34. package/skills/jskit/references/database-layer.md +42 -18
  35. package/skills/jskit/references/existing-application-migration.md +3 -2
  36. package/skills/jskit/references/material-3.md +4 -2
  37. package/skills/jskit/references/package-with-nix.md +4 -2
  38. package/skills/jskit/references/pattern-index.md +39 -39
  39. package/skills/jskit/references/patterns/app/minimal-foundation/example/AGENTS.md +4 -2
  40. package/skills/jskit/references/patterns/app/minimal-foundation/example/package.json +3 -3
  41. package/skills/jskit/references/patterns/app/minimal-foundation/example/server.js +2 -2
  42. package/skills/jskit/references/patterns/app/shell-foundation/example/AGENTS.md +4 -2
  43. package/skills/jskit/references/patterns/app/shell-foundation/example/package.json +4 -4
  44. package/skills/jskit/references/patterns/app/shell-foundation/example/packages/main/package.json +1 -1
  45. package/skills/jskit/references/patterns/app/shell-foundation/example/server.js +2 -2
  46. package/skills/jskit/references/patterns/app/shell-foundation/example/src/components/ShellLayout.vue +13 -10
  47. package/skills/jskit/references/patterns/auth/accounts-hub/example/package.json +3 -3
  48. package/skills/jskit/references/patterns/auth/oidc-sign-in/example/package.json +2 -2
  49. package/skills/jskit/references/patterns/auth/supabase-auth/example/package.json +1 -1
  50. package/skills/jskit/references/patterns/connectors/calendar-cli/example/package.json +5 -5
  51. package/skills/jskit/references/patterns/crud/crud-feature-package/example/packages/books/package.json +3 -3
  52. package/skills/jskit/references/patterns/crud/crud-screen-set/PATTERN.md +3 -1
  53. package/skills/jskit/references/patterns/database/mysql-application/example/package.json +2 -2
  54. package/skills/jskit/references/patterns/database/postgres-application/example/package.json +2 -2
  55. package/skills/jskit/references/patterns/realtime/realtime-application/example/package.json +2 -2
  56. package/skills/jskit/references/patterns/server/feature-package/example/booking-engine/package.json +1 -1
  57. package/skills/jskit/references/patterns/shell/application-shell/example/src/components/ShellLayout.vue +13 -10
  58. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users/package.json +3 -3
  59. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users-workspace/package.json +6 -6
  60. package/skills/jskit/references/security-pass.md +2 -1
  61. package/skills/jskit/references/test-pass.md +55 -4
  62. package/skills/jskit/references/typed-features.md +45 -3
@@ -430,7 +430,7 @@ Local functions
430
430
  - `findImports(root, packageIds)`
431
431
  - `approveInstallScripts(manifest, declared)`
432
432
 
433
- ### `scripts/test-budget.mjs`
433
+ ### `scripts/testing/budget.mjs`
434
434
  Exports
435
435
  - `BUDGET_VARIABLE`
436
436
  - `availableCpus({ parallelism = os.availableParallelism(), readFile = readFileSync } = {})`
@@ -438,15 +438,17 @@ Exports
438
438
  Local functions
439
439
  - `quotaCpus(text)`
440
440
 
441
- ### `scripts/test-command.mjs`
441
+ ### `scripts/testing/command.mjs`
442
442
  Exports
443
- - `DEFAULT_PATTERN`
443
+ - `defaultTestFiles(cwd)`
444
444
  - `findTestFiles(patterns, cwd)`
445
+ - `missedTestFiles(defaultFiles, cwd)`
446
+ - `planTestPool(groups, { concurrency = testConcurrency() } = {})`
445
447
  - `planTestRuns(args, { cwd = process.cwd(), concurrency = testConcurrency() } = {})`
448
+ - `runTestPool(groups)`
446
449
  - `runTests(args)`
447
450
  - `withTimeReporter(run, destination)`
448
451
  Local functions
449
- - `missedTestFiles(defaultFiles, cwd)`
450
452
  - `readMarkedFiles(files, cwd)`
451
453
  - `markedDestination(destination, kind)`
452
454
  - `markedRunOptions(options, kind)`
@@ -454,33 +456,43 @@ Local functions
454
456
  - `databaseShortfall(databases, asked)`
455
457
  - `runNode(args, env)`
456
458
  - `listTestFiles(args)`
459
+ - `pooledName({ group, file })`
460
+ - `longestFirst(first, second)`
461
+ - `reportPoolTimes(groups, wallMs)`
462
+ - `textOf(stream)`
457
463
 
458
- ### `scripts/test-databases.mjs`
464
+ ### `scripts/testing/databases.mjs`
459
465
  Exports
460
466
  - `DATABASES_OPTION`
461
467
  - `foreignKeyCheckFor(cwd)`
462
468
  - `runMigrationHistory(cwd = process.cwd())`
463
- - `testDatabaseRunFor(count, cwd = process.cwd())`
469
+ - `testDatabaseRunFor(count, { spares = 0, cwd = process.cwd() } = {})`
464
470
  Local functions
465
471
  - `withOwnEnvironment(load)`
466
472
  - `exportedTableResources(namespace, isTableResource)`
467
473
  - `keyText({ tableName, columns, referencedTableName, referencedColumns })`
468
474
  - `applicationTestDatabases(cwd, command)`
469
475
 
470
- ### `scripts/test-environment.mjs`
476
+ ### `scripts/testing/environment.mjs`
471
477
  Exports
472
478
  - `useTestAppEnvironment(env, command)`
473
479
 
474
- ### `scripts/test-file-stop.mjs`
480
+ ### `scripts/testing/file-stop.mjs`
475
481
  Exports
482
+ - `EXITED_PREFIX`
483
+ - `LINGERED_PREFIX`
476
484
  - `STOPPED_PREFIX`
477
485
  - `STOPS_VARIABLE`
486
+ - `describeHold(resources)`
487
+ Local functions
488
+ - `stdioHandle(fd)`
489
+ - `heldOpen()`
478
490
 
479
- ### `scripts/test-network-guard-preload.mjs`
491
+ ### `scripts/testing/network-guard-preload.mjs`
480
492
  Exports
481
493
  - None
482
494
 
483
- ### `scripts/test-network-guard.mjs`
495
+ ### `scripts/testing/network-guard.mjs`
484
496
  Exports
485
497
  - `NETWORK_GUARD_PRELOAD`
486
498
  - `NETWORK_GUARD_VARIABLE`
@@ -495,7 +507,7 @@ Local functions
495
507
  - `refusal(command, host, port)`
496
508
  - `connectTarget(args)`
497
509
 
498
- ### `scripts/test-runs.mjs`
510
+ ### `scripts/testing/runs.mjs`
499
511
  Exports
500
512
  - `checkTestRuns({ projectRoot, manifests })`
501
513
  - `formatTestRunsReport(result)`
@@ -513,7 +525,7 @@ Local functions
513
525
  - `checkLoggerLevel({ root, report })`
514
526
  - `checkRunnerConfig({ root, configPath, directory, runner, report })`
515
527
 
516
- ### `scripts/test-sources-scan.mjs`
528
+ ### `scripts/testing/sources-scan.mjs`
517
529
  Exports
518
530
  - `excusedWait(text, offset, tokens = scanSource(text))`
519
531
  - `scanSource(text)`
@@ -527,7 +539,7 @@ Local functions
527
539
  - `rereads(tokens, keyword, body)`
528
540
  - `leaves(tokens, index, body, isBreak)`
529
541
 
530
- ### `scripts/test-sources.mjs`
542
+ ### `scripts/testing/sources.mjs`
531
543
  Exports
532
544
  - `checkTestSources({ projectRoot })`
533
545
  - `formatTestSourcesReport(result)`
@@ -549,17 +561,20 @@ Local functions
549
561
  - `checkViteConfig(file, contents, report)`
550
562
  - `kindOf(file)`
551
563
 
552
- ### `scripts/test-time-report.mjs`
564
+ ### `scripts/testing/time-report.mjs`
553
565
  Exports
554
566
  - `BOUNDS_FILE`
555
567
  - `FILE_TIMES`
556
- - `checkTestTimes({ bounds, files, tests, wallMs, stopped = [] })`
568
+ - `checkTestTimes({ bounds, files, tests, wallMs, stopped = [], lingered = [], exited = [], empty = [] })`
557
569
  - `fileStop({ bound, recorded })`
570
+ - `readRecordedTimes(cwd)`
571
+ - `readTestTimeBounds(cwd)`
572
+ - `recordTestTimes({ cwd, collected, directory, filtered = false })`
558
573
  - `reportTestTimes({ cwd, collected, directory, wallMs, filtered = false })`
574
+ - `testTimesOf`
559
575
  - `writeFileStops({ cwd, files, directory })`
560
576
  Local functions
561
577
  - `seconds(ms)`
562
- - `readTestTimeBounds(cwd)`
563
578
 
564
579
  ### `scripts/ui-components.mjs`
565
580
  Exports
@@ -46,6 +46,7 @@ Exports
46
46
  - `createPublicationInspection({ directory, registry, configPath = "", env = process.env })`
47
47
  - `fileState(file)`
48
48
  - `inParallel(items, work, limit = REGISTRY_CONCURRENCY)`
49
+ - `npmEnvironment(env = process.env)`
49
50
  - `planPublication(records, options)`
50
51
  - `snapshotFiles(root)`
51
52
  Local functions
@@ -76,7 +77,7 @@ Exports
76
77
  - `validateReleaseState`
77
78
  Local functions
78
79
  - `normalizeRegistryUrl(value)`
79
- - `runCommand(command, args, { cwd, env = process.env } = {})`
80
+ - `runNpm(args, { cwd } = {})`
80
81
  - `compareVersions(left, right)`
81
82
  - `assertNoNewerVersions(records, inspection)`
82
83
  - `lockfileNeedsUpdate(records, repoRoot)`
@@ -38,6 +38,13 @@ Exports
38
38
  Local functions
39
39
  - `passCsrfProtection(_request, _reply, done)`
40
40
 
41
+ ### `ports.mjs`
42
+ Exports
43
+ - `freeConsecutivePorts(count, host = "127.0.0.1")`
44
+ - `freePort(host = "127.0.0.1")`
45
+ Local functions
46
+ - `listenOn(port, host)`
47
+
41
48
  ### `visualBaseline.mjs`
42
49
  Exports
43
50
  - `expectMaterialBaseline(page, { directory, name, probes })`
@@ -857,8 +857,10 @@ other than its id, takes `limit: 1`, one statement as `lock(id)` is
857
857
  (`workspaces.memberships.lockByWorkspaceIdAndUserId` locks its membership so).
858
858
  Without either, `lockWhere` locks every match in id order (on MySQL and MariaDB
859
859
  in the order of the index it reads, below), at most 1,000 (more throw), and
860
- PostgreSQL reads them once more under its locks, for a row that started to
861
- match while it waited; with a `limit` it stops once it holds that many. A
860
+ on PostgreSQL it is two statements by design: it reads them once more under
861
+ its locks, for a row that started to match while it waited; with a `limit` it
862
+ stops once it holds that many. Lock rows whose ids you know with
863
+ `lockMany(ids, txOptions)`, one statement on PostgreSQL, MySQL and MariaDB. A
862
864
  `limit` outside 1 to 1,000, or a `sort` on no stored field, is refused before
863
865
  any statement.
864
866
 
@@ -395,23 +395,39 @@ the application's `knexfile.js`:
395
395
  those two replaced, is set.
396
396
  Every file starts from the snapshot, rows included: a copy an earlier file of
397
397
  the run used is restored before the next file takes it, so no file sees what
398
- another wrote. On MySQL and MariaDB the restore replaces only the tables
398
+ another wrote. The run restores it in the background as soon as that file
399
+ ends, and when more files follow than run at once it keeps spare copies
400
+ ready, the next numbered ones, one for every four files at once, which it
401
+ makes in the background as the first files start: the file that follows
402
+ starts at once on a ready copy instead of waiting for a restore, and only
403
+ when none is ready does a file restore one itself. The run's last line says
404
+ how its files started (`jskit test: 41 of 42 test file(s) started on a ready
405
+ test database, 1 restored theirs first (390ms); 46 restore(s) in the
406
+ background (17204ms).`). A copy the run could not restore, such as one a
407
+ test left a view in, fails the run that left it, naming the copy and why.
408
+ On MySQL and MariaDB the restore replaces only the tables
399
409
  that differ from the snapshot, found exactly: a table's definition and its
400
410
  `AUTO_INCREMENT` counter (`SHOW CREATE TABLE`, so a row written and deleted,
401
411
  or a write rolled back, counts), a trigger on it, rows whose `CHECKSUM
402
- TABLE` is not the snapshot's, and tables missing or added; each replaced
403
- table is made on the server, its definition and then its rows copied from
404
- the snapshot database (`INSERT ... SELECT`), so no row passes through Node;
412
+ TABLE` is not the snapshot's, and tables missing or added. A table whose
413
+ primary key is one auto-increment id, and that differs only by the rows a
414
+ file added and the counter they moved, keeps its table: the rows from the
415
+ snapshot's counter on are deleted, reading only those, and the counter is
416
+ set back. Each other table is replaced, made on the server, its definition
417
+ and then its rows copied from the snapshot database (`INSERT ... SELECT`,
418
+ without foreign key or unique checks, since the snapshot's rows hold every
419
+ key), so no row passes through Node;
405
420
  a preparation fills up to eight tables at once, each on a connection of its
406
- own, shared between the databases it restores at once, and a test file's
407
- restore fills on its share of the eight by the run's files at once, so a
408
- run never fills on more than eight connections, plus one for each database
409
- being restored. No table waits in a connection pool's queue, where Knex gives
421
+ own, shared between the databases it restores at once, and a restore during
422
+ the run, a file's or the run's own, fills on its share of the eight by the
423
+ run's copies, spares included, so a run never fills on more than eight
424
+ connections, plus one for each database being restored. No table waits in a connection pool's queue, where Knex gives
410
425
  up after its `acquireConnectionTimeout`.
411
426
  The tables it fills are then sampled for the planner in one `ANALYZE TABLE`:
412
427
  InnoDB keeps the statistics it took of the empty table until it samples it
413
428
  again, and the planner would read a filled table as empty.
414
- A file that wrote three tables costs three tables, not the whole schema. On
429
+ A file that wrote three tables costs three tables, not the whole schema,
430
+ and one that only added rows to them costs those rows. On
415
431
  PostgreSQL the copy is made again from the snapshot database, which costs
416
432
  less than finding the tables; the snapshot database is analyzed once when
417
433
  it is built (`ANALYZE`), so each copy has its statistics.
@@ -419,15 +435,23 @@ the application's `knexfile.js`:
419
435
  whether its test files passed, failed or were stopped (Ctrl-C, `SIGTERM`),
420
436
  or its foreign key check failed before the first file, and so do the copies
421
437
  a run of fewer files does not take: the next run restores each one it takes
422
- instead of making it again. On MySQL and MariaDB a run after one whose files
423
- wrote three tables copies those three, not the schema; its summary says how
424
- many tables its restores copied (`restore 412ms of 3 table(s)`). A run that
425
- never reached its end (killed with `SIGKILL`, stopped at a command's time
426
- limit, or on a machine that went down) leaves nothing the next run does not
427
- restore, a table it was copying included. Each copy takes the disk space of
428
- the snapshot's rows, and there are as many as the most files a run took at
429
- once; they last until the project's test databases are dropped. Two runs at
430
- once on one database name still are not supported.
438
+ instead of making it again. A run that reaches its end, stopped or not,
439
+ first restores the copies its last files used, so the next finds them
440
+ ready. On MySQL and MariaDB a run after one that did not reach its end, and
441
+ whose files wrote three tables, copies those three, not the schema; its
442
+ summary says how many tables its restores copied (`restore 412ms of 3
443
+ table(s)`). A run that never reached its end (killed with `SIGKILL`, stopped
444
+ at a command's time limit, or on a machine that went down) leaves nothing
445
+ the next run does not restore, a table it was copying included. Each copy
446
+ takes the disk space of the snapshot's rows, and there are as many as the
447
+ most files a run took at once and its spares; they last until the project's
448
+ test databases are dropped. A run holds its test databases, on the
449
+ database server, from before it prepares them until it ends, and so does
450
+ `jskit migration-history`: another run on the same `TEST_DB_NAME`, from
451
+ another checkout or another session of the project on that server, waits
452
+ for it up to a minute, then refuses, naming the first run's database
453
+ session (`GET_LOCK` on MySQL and MariaDB, an advisory lock on PostgreSQL).
454
+ A run that ends without its cleanup gives them up with its process.
431
455
  - The snapshot holds the schema as the engine reports it and the rows the
432
456
  migrations wrote, including the migration ledger, in a database of its own
433
457
  on the database server, where `npm ci`, which empties `node_modules`, cannot
@@ -150,7 +150,7 @@ import SerializerSelector from "@fastify/fast-json-stringify-compiler";
150
150
  import { createCachedResponseSerializerFactory, resolveTrustedProxies } from "@jskit-ai/kernel/server/http";
151
151
 
152
152
  const app = Fastify({
153
- // TRUSTED_PROXIES: the proxies whose X-Forwarded-For is believed (loopback without it).
153
+ // TRUSTED_PROXIES: the proxies whose X-Forwarded-For is believed (without it, loopback and MOBILYNET_EDGE_ADDRESSES).
154
154
  trustProxy: resolveTrustedProxies(runtimeEnv),
155
155
  schemaController: {
156
156
  compilersFactory: {
@@ -164,7 +164,8 @@ Keep the application's other Fastify options, including serializer options and
164
164
  validator configuration, but replace an application's own `trustProxy` setting
165
165
  with `resolveTrustedProxies(runtimeEnv)` (`runtimeEnv` is the environment the
166
166
  server starts with, `process.env` if it has no other), and its environment
167
- variable with `TRUSTED_PROXIES`; see
167
+ variable with `TRUSTED_PROXIES` (on mobilynet none is needed: the server reads
168
+ the `MOBILYNET_EDGE_ADDRESSES` mobilynet sets); see
168
169
  [sign-in protection](https://mobily-enterprises.github.io/jskit-ai/guide/app-setup/authentication#sign-in-protection)
169
170
  for the setting. This setup wraps the native default serializer builder;
170
171
  retain any deliberately chosen custom compiler instead of replacing or wrapping
@@ -489,8 +489,10 @@ Run this behavior-preserving audit over every affected screen:
489
489
  4. Correct issues at the narrowest established owner. Consolidate only truly
490
490
  repeated policy; avoid pass-through wrappers and speculative abstractions.
491
491
  5. Run `jskit check` and `jskit check m3` on the affected files, then focused
492
- tests and Playwright at compact, medium, and expanded widths in light and
493
- dark (`shellBackButton(page)` and `pressShellBack(page)` from
492
+ tests, and Playwright: the journeys at desktop, at phone where their steps
493
+ differ, and layout checks at compact, medium and expanded widths in light and
494
+ dark, reloading a page that decides its layout at first load
495
+ (`shellBackButton(page)` and `pressShellBack(page)` from
494
496
  `@jskit-ai/shell-web/test/shellNavigation` drive Up).
495
497
 
496
498
  Do not declare Material 3 compliance from visual resemblance alone. Report any
@@ -114,8 +114,10 @@ environment's. The option is not called `--env-file` because Node reads an
114
114
  package never guesses it, and a server without one refuses to start. The
115
115
  programs default `NODE_ENV` to `production`, the build the package holds.
116
116
  - Behind a load balancer or proxy, `TRUSTED_PROXIES` names its addresses, as
117
- the [authentication](/guide/app-setup/authentication) guide says, and
118
- `APP_PUBLIC_URL` is the address people use. `APP_REDIRECT_HOSTS` lists the
117
+ the [authentication](/guide/app-setup/authentication#sign-in-protection)
118
+ guide says (on mobilynet nothing needs setting: mobilynet sets
119
+ `MOBILYNET_EDGE_ADDRESSES`, its edge's addresses, which the server reads),
120
+ and `APP_PUBLIC_URL` is the address people use. `APP_REDIRECT_HOSTS` lists the
119
121
  app's other names, such as `www.example.com`, which the server sends on to
120
122
  `APP_PUBLIC_URL` with a 301
121
123
  ([Other names](/guide/app-setup/initial-scaffolding#other-names)).