@jskit-ai/agent-docs 0.1.279 → 0.1.280
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/guide/agent/app-extras/assistant.md +123 -0
- package/guide/agent/app-setup/authentication.md +34 -3
- package/guide/agent/app-setup/database-layer.md +35 -6
- package/guide/agent/app-setup/material-3-migration.md +38 -9
- package/guide/agent/app-setup/multi-homing.md +8 -2
- package/guide/agent/app-setup/upgrading-jskit.md +30 -0
- package/guide/agent/app-setup/users.md +9 -1
- package/guide/agent/framework/material-3.md +111 -71
- package/guide/agent/framework/sanity-checks.md +180 -0
- package/guide/agent/framework/translation.md +4 -0
- package/guide/agent/framework/typed-features.md +158 -105
- package/guide/agent/framework/ui-operations.md +3 -1
- package/guide/agent/index.md +3 -0
- package/package.json +2 -2
- package/patterns/feature-package/example/booking-engine/package.json +1 -1
- package/patterns/minimal-foundation/PATTERN.md +6 -2
- package/patterns/minimal-foundation/example/AGENTS.md +10 -0
- package/patterns/minimal-foundation/example/package.json +6 -6
- package/patterns/minimal-foundation/example/playwright.config.mjs +3 -0
- package/patterns/minimal-foundation/example/src/main.js +3 -2
- package/patterns/minimal-foundation/example/vite.config.mjs +3 -1
- package/patterns/shell-foundation/PATTERN.md +4 -1
- package/patterns/shell-foundation/example/AGENTS.md +10 -0
- package/patterns/shell-foundation/example/package.json +7 -7
- package/patterns/shell-foundation/example/packages/main/package.json +1 -1
- package/patterns/shell-foundation/example/packages/main/src/client/providers/MainClientProvider.js +3 -0
- package/patterns/shell-foundation/example/playwright.config.mjs +3 -0
- package/patterns/shell-foundation/example/src/components/menus/SectionTabLinkItem.vue +42 -0
- package/patterns/shell-foundation/example/src/main.js +3 -2
- package/patterns/shell-foundation/example/src/pages/home.vue +1 -1
- package/patterns/shell-foundation/example/src/views/NotFound.vue +1 -1
- package/patterns/shell-foundation/example/vite.config.mjs +3 -1
- package/reference/autogen/PATTERN_INDEX.md +37 -37
- package/reference/autogen/packages/agent-docs.md +4 -0
- package/reference/autogen/packages/assistant-runtime.md +27 -2
- package/reference/autogen/packages/auth-web.md +10 -0
- package/reference/autogen/packages/crud-core.md +3 -0
- package/reference/autogen/packages/http-web.md +0 -4
- package/reference/autogen/packages/json-rest-api-core.md +17 -4
- package/reference/autogen/packages/kernel.md +10 -1
- package/reference/autogen/packages/material-web.md +2 -1
- package/reference/autogen/packages/shell-web.md +84 -0
- package/reference/autogen/packages/users-web.md +5 -2
- package/reference/autogen/packages/workspaces-core.md +2 -0
- package/reference/autogen/tooling/jskit-catalog.md +52 -5
- package/reference/autogen/tooling/testUtils.md +15 -1
- package/skills/jskit/SKILL.md +15 -5
- package/skills/jskit/references/heuristics/INDEX.md +3 -1
- package/skills/jskit/references/heuristics/row-policies.md +3 -3
- package/skills/jskit/references/heuristics/typed-features.md +7 -7
- package/skills/jskit/references/heuristics/ui-testing.md +8 -7
- package/skills/jskit/references/material-3.md +111 -71
- package/skills/jskit/references/multi-homing.md +8 -2
- package/skills/jskit/references/pattern-index.md +37 -37
- package/skills/jskit/references/patterns/app/minimal-foundation/PATTERN.md +6 -2
- package/skills/jskit/references/patterns/app/minimal-foundation/example/AGENTS.md +10 -0
- package/skills/jskit/references/patterns/app/minimal-foundation/example/package.json +6 -6
- package/skills/jskit/references/patterns/app/minimal-foundation/example/playwright.config.mjs +3 -0
- package/skills/jskit/references/patterns/app/minimal-foundation/example/src/main.js +3 -2
- package/skills/jskit/references/patterns/app/minimal-foundation/example/vite.config.mjs +3 -1
- package/skills/jskit/references/patterns/app/shell-foundation/PATTERN.md +4 -1
- package/skills/jskit/references/patterns/app/shell-foundation/example/AGENTS.md +10 -0
- package/skills/jskit/references/patterns/app/shell-foundation/example/package.json +7 -7
- package/skills/jskit/references/patterns/app/shell-foundation/example/packages/main/package.json +1 -1
- package/skills/jskit/references/patterns/app/shell-foundation/example/packages/main/src/client/providers/MainClientProvider.js +3 -0
- package/skills/jskit/references/patterns/app/shell-foundation/example/playwright.config.mjs +3 -0
- package/skills/jskit/references/patterns/app/shell-foundation/example/src/components/menus/SectionTabLinkItem.vue +42 -0
- package/skills/jskit/references/patterns/app/shell-foundation/example/src/main.js +3 -2
- package/skills/jskit/references/patterns/app/shell-foundation/example/src/pages/home.vue +1 -1
- package/skills/jskit/references/patterns/app/shell-foundation/example/src/views/NotFound.vue +1 -1
- package/skills/jskit/references/patterns/app/shell-foundation/example/vite.config.mjs +3 -1
- package/skills/jskit/references/patterns/auth/accounts-hub/example/package.json +2 -2
- package/skills/jskit/references/patterns/auth/auth-surface/PATTERN.md +18 -5
- package/skills/jskit/references/patterns/auth/auth-surface/example/src/components/AppBrand.vue +17 -0
- package/skills/jskit/references/patterns/auth/auth-surface/example/src/pages/auth/login.vue +2 -2
- package/skills/jskit/references/patterns/auth/auth-surface/example/src/pages/auth/reset-password.vue +2 -2
- package/skills/jskit/references/patterns/auth/auth-surface/example/src/pages/auth/signout.vue +2 -2
- package/skills/jskit/references/patterns/auth/auth-surface/example/src/views/auth/LoginView.vue +6 -1
- package/skills/jskit/references/patterns/auth/auth-surface/example/src/views/auth/ResetPasswordView.vue +6 -1
- package/skills/jskit/references/patterns/auth/auth-surface/example/src/views/auth/SignOutView.vue +6 -1
- package/skills/jskit/references/patterns/auth/oidc-sign-in/example/package.json +2 -2
- package/skills/jskit/references/patterns/auth/supabase-auth/example/package.json +1 -1
- package/skills/jskit/references/patterns/connectors/aws-storage-queries/example/formats/package.json +1 -1
- package/skills/jskit/references/patterns/connectors/calendar-cli/example/package.json +4 -4
- package/skills/jskit/references/patterns/console/console-surface/example/src/pages/console.vue +1 -1
- package/skills/jskit/references/patterns/crud/json-api-resource-package/example/packages/books/package.json +2 -2
- package/skills/jskit/references/patterns/database/mysql-application/example/package.json +1 -1
- package/skills/jskit/references/patterns/database/postgres-application/example/package.json +1 -1
- package/skills/jskit/references/patterns/realtime/realtime-application/example/package.json +2 -2
- package/skills/jskit/references/patterns/rewards/google-rewarded/example/googlePublisherTag.js +5 -2
- package/skills/jskit/references/patterns/server/feature-package/example/booking-engine/package.json +1 -1
- package/skills/jskit/references/patterns/shell/application-shell/PATTERN.md +11 -6
- package/skills/jskit/references/patterns/shell/application-shell/example/src/components/menus/SectionTabLinkItem.vue +42 -0
- package/skills/jskit/references/patterns/shell/application-shell/example/src/pages/home.vue +1 -1
- package/skills/jskit/references/patterns/shell/application-shell/example/src/views/NotFound.vue +1 -1
- package/skills/jskit/references/patterns/ui/page-and-placement/PATTERN.md +6 -0
- package/skills/jskit/references/patterns/ui/page-and-placement/example/src/pages/home/reports.vue +9 -4
- package/skills/jskit/references/patterns/ui/page-and-placement/example/src/placementTopology.js +5 -3
- package/skills/jskit/references/patterns/users/account-settings/PATTERN.md +24 -3
- package/skills/jskit/references/patterns/users/account-settings/example/src/components/account/settings/AccountSettingsNotificationsSection.vue +1 -1
- package/skills/jskit/references/patterns/users/account-settings/example/src/components/account/settings/AccountSettingsPreferencesSection.vue +2 -1
- package/skills/jskit/references/patterns/users/account-settings/example/src/components/account/settings/AccountSettingsProfileSection.vue +3 -2
- package/skills/jskit/references/patterns/users/account-settings/example/src/pages/account/[section].vue +23 -0
- package/skills/jskit/references/patterns/users/account-settings/example/src/pages/account.vue +4 -3
- package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users/package.json +2 -2
- package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users-workspace/package.json +3 -3
- package/skills/jskit/references/patterns/workspaces/workspace-surfaces/example/packages/main/src/client/components/AccountPendingInvitesCue.vue +3 -3
- package/skills/jskit/references/patterns/workspaces/workspace-surfaces/example/src/surfaces/admin/root.vue +1 -1
- package/skills/jskit/references/patterns/workspaces/workspace-surfaces/example/src/surfaces/app/root.vue +1 -1
- package/skills/jskit/references/sanity-checks.md +180 -0
- package/skills/jskit/references/translation.md +4 -0
- package/skills/jskit/references/typed-features.md +158 -105
- package/skills/jskit/references/ui-operations.md +3 -1
|
@@ -443,6 +443,9 @@ record declares `mode: "patch"`; a command never does.**
|
|
|
443
443
|
|
|
444
444
|
- Patch mode skips `required`, so a service keeps its guard for a field a
|
|
445
445
|
patch input lists as required.
|
|
446
|
+
- An input field lists its allowed values with `enum`; the kernel refuses
|
|
447
|
+
`oneOf` on an input field at startup, because json-rest-schema checks no
|
|
448
|
+
`oneOf` and the field would accept any value.
|
|
446
449
|
|
|
447
450
|
Why: a command whose required field is never enforced reaches the service
|
|
448
451
|
without it.
|
|
@@ -644,7 +647,7 @@ way (is this user an operator) is a member of its owner's capability.**
|
|
|
644
647
|
- A helper two packages of an application use lives in its shared package,
|
|
645
648
|
never inside one of them.
|
|
646
649
|
|
|
647
|
-
Why:
|
|
650
|
+
Why: the kernel's helpers fix one meaning of empty, and a copy brings its own.
|
|
648
651
|
|
|
649
652
|
```js
|
|
650
653
|
// good
|
|
@@ -673,7 +676,8 @@ helper, never by hand.**
|
|
|
673
676
|
| the workspace a request asks for, before any action context | `requestedWorkspaceScope(request)` (`@jskit-ai/workspaces-core/server/support/workspaceRouteInput`) |
|
|
674
677
|
| a context's workspace id | `resolveWorkspaceScopeValue(context)` (`@jskit-ai/json-rest-api-core/server/jsonRestApiHost`) |
|
|
675
678
|
|
|
676
|
-
Why: each
|
|
679
|
+
Why: each reader knows every place JSKIT keeps its fact (`trx` or
|
|
680
|
+
`transaction`, a tagged result's wrapper), and a hand read misses one.
|
|
677
681
|
|
|
678
682
|
```js
|
|
679
683
|
// good
|
|
@@ -693,11 +697,17 @@ page means "the first 20 rows".**
|
|
|
693
697
|
- json-rest-api answers a query that names no page with the resource's
|
|
694
698
|
default page, 20 rows, and says nothing about the rest. The CRUD
|
|
695
699
|
repository's `queryDocuments(query)` without a `limit` is the same first
|
|
696
|
-
page
|
|
697
|
-
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
700
|
+
page, and one with a `limit` above its `queryMaxLimit()` (100) throws,
|
|
701
|
+
because json-rest-api would answer only 100. A CRUD read of every record
|
|
702
|
+
uses the repository's `queryEveryDocument(query, options)`, which answers
|
|
703
|
+
one JSON:API document `{ data, included }` with no `limit`, `cursor` or
|
|
704
|
+
`sort`.
|
|
705
|
+
- The helper reads cursor pages of 1,000 rows (json-rest-api's server-only
|
|
706
|
+
`pageSizeLimit`; a resource whose `queryMaxLimit` is larger uses that) in id
|
|
707
|
+
order until none follows, keeping the call's transaction and context, so no
|
|
708
|
+
row is skipped or repeated. Each page pays the row policy and linkage
|
|
709
|
+
queries once, so 480 rows cost 3 statements, not 15. It sets the page and
|
|
710
|
+
sort itself; sort the rows it returns.
|
|
701
711
|
- A lookup by a unique key (an id, a slug, a token hash, a unique pair such
|
|
702
712
|
as workspace and user) matches at most one row and may read `rows[0]` of a
|
|
703
713
|
plain query. A read of the newest or first few rows names its own `sort`
|
|
@@ -724,33 +734,35 @@ const rows = extractJsonRestCollectionRows(await api.resources.workspaceMembersh
|
|
|
724
734
|
}, createJsonRestContext(options.context)));
|
|
725
735
|
```
|
|
726
736
|
|
|
727
|
-
###
|
|
737
|
+
### Lists read related rows in batches
|
|
728
738
|
|
|
729
|
-
**A read that builds a list
|
|
730
|
-
query per table
|
|
731
|
-
|
|
739
|
+
**A read that builds a list fetches its related rows in batches, an id-list
|
|
740
|
+
query per related table, and groups them in memory, so its query count follows
|
|
741
|
+
the tables and pages it reads, not the rows.**
|
|
732
742
|
|
|
733
|
-
- Collect the ids from the first read, then read each related table
|
|
734
|
-
|
|
743
|
+
- Collect the ids from the first read, then read each related table with an
|
|
744
|
+
id-list filter: a `searchSchema` entry
|
|
735
745
|
`{ type: "array", actualField: "<column>", filterOperator: "in" }`, read
|
|
736
746
|
through `queryAllJsonRestCollectionRows()`, or the resource's `include`.
|
|
737
747
|
Group the rows by id with `Map.groupBy()`.
|
|
738
|
-
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
748
|
+
- A count that grows with the rows means something runs per row:
|
|
749
|
+
`getDocumentById()`, `queryDocuments()`, a service `get` or another owner's
|
|
750
|
+
single-record read inside a loop over the list, however the loop is spelled
|
|
751
|
+
(`for`, `map` with `Promise.all`, a helper called per item), or a
|
|
752
|
+
single-record helper reused for a list.
|
|
742
753
|
- Work derived from a row (hashing, preparing a form, assembling a snapshot)
|
|
743
754
|
runs once per distinct input in the call, not once per row it appears in.
|
|
744
|
-
-
|
|
745
|
-
the resource
|
|
746
|
-
|
|
747
|
-
|
|
755
|
+
- A JSON:API read also costs a few lookup and visibility queries per page and
|
|
756
|
+
relationship field, and pages hold the resource's `queryMaxLimit` (100 rows
|
|
757
|
+
unless it sets one). That cost follows pages, so three hundred invoices take
|
|
758
|
+
a few more queries than ten, not three hundred more ([Query counts at
|
|
759
|
+
realistic sizes](#query-counts-at-realistic-sizes)).
|
|
748
760
|
|
|
749
|
-
Why:
|
|
750
|
-
|
|
761
|
+
Why: each JSKIT single-record read runs its lookups and row policy too, so a
|
|
762
|
+
read per row repeats all of them.
|
|
751
763
|
|
|
752
764
|
```js
|
|
753
|
-
// good:
|
|
765
|
+
// good: a read per related table, however many invoices there are
|
|
754
766
|
const invoiceRows = await queryAllJsonRestCollectionRows(api.resources.invoices, {
|
|
755
767
|
queryParams: { filters: { workspace: workspaceId } },
|
|
756
768
|
transaction: resolveTransaction(options),
|
|
@@ -784,21 +796,25 @@ paying a read policy for every row it writes.**
|
|
|
784
796
|
[row policies heuristic](https://github.com/mobily-enterprises/jskit-ai/blob/main/packages/agent-docs/heuristics/row-policies.md)
|
|
785
797
|
has the policy contract and its package composition.
|
|
786
798
|
- The policy runs on every single-record read, and a CRUD write includes one:
|
|
787
|
-
`createDocument()` and `patchDocumentById()`
|
|
788
|
-
|
|
789
|
-
look the record up through it.
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
delivery, an import, a fan-out)
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
799
|
+
`createDocument()` and `patchDocumentById()` default to `returning: "full"`,
|
|
800
|
+
which reads the record back through the policy, and `patch` and `delete`
|
|
801
|
+
first look the record up through it.
|
|
802
|
+
- A write path decides access once, inside its transaction. A write that does
|
|
803
|
+
not use its result passes `returning: "minimal"` or `"none"`, and a batch of
|
|
804
|
+
creates (a delivery, an import, a fan-out) goes through
|
|
805
|
+
`createDocuments(payloads, { trx, context })`, which reads nothing back
|
|
806
|
+
unless asked
|
|
807
|
+
([writes that return less](https://mobily-enterprises.github.io/jskit-ai/guide/app-setup/database-layer#writes-that-return-less)).
|
|
808
|
+
Any other batch whose per-row lookup would pay an expensive policy writes
|
|
809
|
+
through a repository method added with `decorateRepository`, on
|
|
810
|
+
`resolveRepoClient(database.knex, options)`, setting the same columns the
|
|
811
|
+
resource would, its ownership columns included.
|
|
812
|
+
- Its test counts the queries of one read and one write for a subject with a
|
|
813
|
+
short history and for one with a long one ([Query counts at realistic
|
|
814
|
+
sizes](#query-counts-at-realistic-sizes)).
|
|
815
|
+
|
|
816
|
+
Why: the row policy runs on every read, write read-back and lookup, so every
|
|
817
|
+
request pays what it costs.
|
|
802
818
|
|
|
803
819
|
```js
|
|
804
820
|
// good: one predicate on the row being read
|
|
@@ -935,7 +951,8 @@ carries on.**
|
|
|
935
951
|
(`response.body.cancel()`), for queue tails whose error reaches the queued
|
|
936
952
|
caller, and for client best effort, each with a short comment saying so.
|
|
937
953
|
|
|
938
|
-
Why:
|
|
954
|
+
Why: a collaborator call's failure can be a wiring `TypeError`, and
|
|
955
|
+
`() => {}` hides it with the rest.
|
|
939
956
|
|
|
940
957
|
```js
|
|
941
958
|
// good
|
|
@@ -957,8 +974,8 @@ frame.**
|
|
|
957
974
|
- Complete a double with the method the code calls, returning its neutral
|
|
958
975
|
value; never shape production code around a double.
|
|
959
976
|
|
|
960
|
-
Why:
|
|
961
|
-
|
|
977
|
+
Why: an owner's seams are its contract; its id formats and stream frames
|
|
978
|
+
change with its package.
|
|
962
979
|
|
|
963
980
|
```js
|
|
964
981
|
// good
|
|
@@ -977,8 +994,8 @@ double.**
|
|
|
977
994
|
- One named clock per factory (`now = Date.now`) is a platform default, not a
|
|
978
995
|
test seam.
|
|
979
996
|
|
|
980
|
-
Why: a
|
|
981
|
-
|
|
997
|
+
Why: a factory's parameters are its contract with the features that call it,
|
|
998
|
+
and a test is not one of them.
|
|
982
999
|
|
|
983
1000
|
```js
|
|
984
1001
|
// good
|
|
@@ -997,8 +1014,8 @@ through the feature, and pure helpers through `__testables`.**
|
|
|
997
1014
|
- `__testables` holds pure helpers only, never one that touches a
|
|
998
1015
|
collaborator or reads request facts.
|
|
999
1016
|
|
|
1000
|
-
Why: a test
|
|
1001
|
-
|
|
1017
|
+
Why: `__testables` is the one way a test reaches inside a module, so every
|
|
1018
|
+
other export is production API.
|
|
1002
1019
|
|
|
1003
1020
|
```js
|
|
1004
1021
|
// good
|
|
@@ -1011,87 +1028,105 @@ export function resetInvoiceCacheForTests() {
|
|
|
1011
1028
|
}
|
|
1012
1029
|
```
|
|
1013
1030
|
|
|
1014
|
-
###
|
|
1031
|
+
### Query counts at realistic sizes
|
|
1015
1032
|
|
|
1016
|
-
**A list, batch or write path
|
|
1017
|
-
|
|
1018
|
-
|
|
1033
|
+
**A list, batch or write path's database test counts its queries with the
|
|
1034
|
+
test Knex instance's `query` event at a few rows and at a realistic number,
|
|
1035
|
+
and fails when the count grows with the rows instead of the pages.**
|
|
1019
1036
|
|
|
1020
|
-
-
|
|
1021
|
-
|
|
1022
|
-
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
one write) asserts the same count at a short and a long history. A query
|
|
1026
|
-
count is stable in CI; also report the time the call took.
|
|
1027
|
-
- Meet the budget by fixing the reads ([One read per
|
|
1028
|
-
table](#one-read-per-table), [Bounded access checks](#bounded-access-checks)),
|
|
1029
|
-
never by shrinking the data or raising the budget.
|
|
1037
|
+
- Pages add a few queries; rows should add none. A path that pages nothing
|
|
1038
|
+
(one read, one write) compares a short and a long history.
|
|
1039
|
+
- When it fails, fix the reads ([Lists read related rows in
|
|
1040
|
+
batches](#lists-read-related-rows-in-batches), [Bounded access
|
|
1041
|
+
checks](#bounded-access-checks)).
|
|
1030
1042
|
|
|
1031
|
-
Why:
|
|
1032
|
-
|
|
1043
|
+
Why: JSON:API reads add queries per page and relationship field, so comparing
|
|
1044
|
+
two sizes separates that cost from a read per row, where one fixed number
|
|
1045
|
+
cannot.
|
|
1033
1046
|
|
|
1034
1047
|
```js
|
|
1035
1048
|
// good
|
|
1036
|
-
|
|
1037
|
-
await seedInvoices(knex, { workspace, count: 300, linesEach: 5 });
|
|
1049
|
+
async function countQueries(knex, work) {
|
|
1038
1050
|
let queries = 0;
|
|
1039
1051
|
const count = () => { queries += 1; };
|
|
1040
1052
|
knex.on("query", count);
|
|
1041
1053
|
try {
|
|
1042
|
-
await
|
|
1054
|
+
await work();
|
|
1043
1055
|
} finally {
|
|
1044
1056
|
knex.off("query", count);
|
|
1045
1057
|
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1058
|
+
return queries;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
test("the invoice list's queries follow its pages, not its invoices", async () => {
|
|
1062
|
+
const listAt = async (count) => {
|
|
1063
|
+
const workspace = await createWorkspace(knex);
|
|
1064
|
+
await seedInvoices(knex, { workspace, count, linesEach: 5 });
|
|
1065
|
+
return countQueries(knex, () => invoices.listWithLines(workspace, { context }));
|
|
1066
|
+
};
|
|
1067
|
+
const few = await listAt(10);
|
|
1068
|
+
const many = await listAt(300);
|
|
1069
|
+
// Thirty times the invoices may add pages; a read per invoice would add about 290 queries.
|
|
1070
|
+
assert.ok(many <= few * 2, `${few} queries for 10 invoices, ${many} for 300`);
|
|
1048
1071
|
});
|
|
1049
1072
|
|
|
1050
|
-
// bad: three invoices
|
|
1073
|
+
// bad: three invoices, nothing counted, so a read per invoice passes
|
|
1051
1074
|
test("the invoice list has its lines", async () => {
|
|
1052
1075
|
await seedInvoices(knex, { workspace, count: 3, linesEach: 1 });
|
|
1053
1076
|
assert.equal((await invoices.listWithLines(workspace, { context })).length, 3);
|
|
1054
1077
|
});
|
|
1055
1078
|
```
|
|
1056
1079
|
|
|
1057
|
-
###
|
|
1058
|
-
|
|
1059
|
-
**A
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1080
|
+
### Test files run in parallel
|
|
1081
|
+
|
|
1082
|
+
**A test suite runs its files in parallel, as many at a time as the machine's
|
|
1083
|
+
test budget allows: never one file at a time, and never more than the machine
|
|
1084
|
+
can take. Node's test runner runs through `jskit test`; Playwright's `workers`
|
|
1085
|
+
and Vitest's `maxWorkers` come from `testConcurrency()`.**
|
|
1086
|
+
|
|
1087
|
+
- The budget is `V64_TEST_CONCURRENCY` when it is a positive whole number (a
|
|
1088
|
+
test runner that hands out slots exports it for each run), otherwise half of
|
|
1089
|
+
the machine's CPUs, rounded down and at least 1: a 2-vCPU VPS runs one file
|
|
1090
|
+
at a time, an 8-thread machine four.
|
|
1091
|
+
- `jskit test` (from `@jskit-ai/jskit-catalog`) passes its arguments to
|
|
1092
|
+
`node --test` and sets `--test-concurrency` to the budget.
|
|
1093
|
+
`testConcurrency()` from `@jskit-ai/jskit-catalog/test-budget` returns the
|
|
1094
|
+
same number for a config.
|
|
1095
|
+
- No script passes a fixed concurrency or worker count. `jskit check` fails a
|
|
1096
|
+
package script that runs `node --test` directly or passes one, and a
|
|
1097
|
+
Playwright or Vitest config those scripts use whose workers do not come from
|
|
1098
|
+
`testConcurrency()` ([test-run rules](#test-run-rules)).
|
|
1099
|
+
- Each file isolates what it shares: a port the system picks (`listen(0)`), a
|
|
1100
|
+
directory from `mkdtemp`, its own database or schema with a name no other
|
|
1101
|
+
file uses, its own Vite `cacheDir` for each dev server it starts (Vite
|
|
1102
|
+
replaces a shared dependency cache under servers still reading it), and no
|
|
1103
|
+
writes into the source tree. Files that collide are isolated, never
|
|
1104
|
+
serialised. A Playwright spec works on its own records, so
|
|
1105
|
+
specs can share one server.
|
|
1106
|
+
- A file that truly cannot run beside others, because it holds a resource of
|
|
1107
|
+
the whole machine, says why on its first line,
|
|
1108
|
+
`// jskit-test: alone - <reason>`. `jskit test` runs it after the others,
|
|
1109
|
+
one such file at a time, and fails on a marker without a reason or below the
|
|
1110
|
+
first line.
|
|
1111
|
+
|
|
1112
|
+
Why: `jskit test` and `testConcurrency()` read one budget, so every runner
|
|
1113
|
+
uses the machine without starving the other runs on it.
|
|
1077
1114
|
|
|
1078
1115
|
```js
|
|
1079
|
-
// good:
|
|
1080
|
-
|
|
1081
|
-
await deliveries.processBatch(workspace, { context });
|
|
1082
|
-
});
|
|
1116
|
+
// good: package.json "test": "jskit test", and playwright.config.mjs
|
|
1117
|
+
import { testConcurrency } from "@jskit-ai/jskit-catalog/test-budget";
|
|
1083
1118
|
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
});
|
|
1119
|
+
export default defineConfig({ workers: testConcurrency() });
|
|
1120
|
+
|
|
1121
|
+
// bad: "test": "node --test --test-concurrency=1", and
|
|
1122
|
+
export default defineConfig({ workers: 1 });
|
|
1088
1123
|
```
|
|
1089
1124
|
|
|
1090
1125
|
### Test databases are prepared once
|
|
1091
1126
|
|
|
1092
|
-
**A test run prepares each database once
|
|
1093
|
-
schema, migration ledger and seed rows checked by a digest of
|
|
1094
|
-
|
|
1127
|
+
**A test run prepares each database once and restores it from a stored
|
|
1128
|
+
snapshot of the schema, migration ledger and seed rows, checked by a digest of
|
|
1129
|
+
their sources.**
|
|
1095
1130
|
|
|
1096
1131
|
- The snapshot is rebuilt only when the digest of the migration and seed
|
|
1097
1132
|
sources changes, once and outside the timed tests; every disposable
|
|
@@ -1099,15 +1134,15 @@ and never replays the whole migration history inside the run.**
|
|
|
1099
1134
|
it.
|
|
1100
1135
|
- The full migration history runs once, in its own fresh-schema check
|
|
1101
1136
|
([database verification](https://mobily-enterprises.github.io/jskit-ai/guide/app-setup/database-layer#verification)).
|
|
1102
|
-
- The harness reports each preparation phase and its duration, and
|
|
1103
|
-
|
|
1137
|
+
- The harness reports each preparation phase and its duration, and those
|
|
1138
|
+
durations are read, so slow preparation shows instead of hiding inside the
|
|
1104
1139
|
next test that waits for it.
|
|
1105
1140
|
- The database layer guide's [integration test
|
|
1106
1141
|
databases](https://mobily-enterprises.github.io/jskit-ai/guide/app-setup/database-layer#integration-test-databases)
|
|
1107
1142
|
gives the snapshot's contents per engine.
|
|
1108
1143
|
|
|
1109
|
-
Why:
|
|
1110
|
-
|
|
1144
|
+
Why: an application's migrations include those of every installed package, so
|
|
1145
|
+
replaying them costs more with each package as well as each migration.
|
|
1111
1146
|
|
|
1112
1147
|
```js
|
|
1113
1148
|
// good: the application's test support restores the snapshot its digest names
|
|
@@ -1125,6 +1160,10 @@ before(() => knex.migrate.latest());
|
|
|
1125
1160
|
code: server, shared, client (`.vue` and `.js`) and scripts. One concern per
|
|
1126
1161
|
factory.**
|
|
1127
1162
|
|
|
1163
|
+
- The limit is an outer bound, not a size to aim for: a file near it usually
|
|
1164
|
+
holds more than one concern. Split it by concern; never trim lines or join
|
|
1165
|
+
statements to fit.
|
|
1166
|
+
|
|
1128
1167
|
Why: a reader holds one concern at a time; a 2,000-line closure holds ten.
|
|
1129
1168
|
|
|
1130
1169
|
```text
|
|
@@ -1224,8 +1263,9 @@ Why: a comment that narrates history is wrong the day after it is written.
|
|
|
1224
1263
|
### Running the checks
|
|
1225
1264
|
|
|
1226
1265
|
`npm run lint` runs ESLint with `@jskit-ai/config-eslint`, and `npm run
|
|
1227
|
-
verify` runs `jskit check` (the package graph
|
|
1228
|
-
build. The foundations'
|
|
1266
|
+
verify` runs `jskit check` (the package graph, navigation and [test
|
|
1267
|
+
runs](#test-run-rules)), lint, the tests and the build. The foundations'
|
|
1268
|
+
`eslint.config.mjs` already holds a new
|
|
1229
1269
|
application's code to every check:
|
|
1230
1270
|
|
|
1231
1271
|
```js
|
|
@@ -1297,6 +1337,19 @@ Every finding ends with a link to the section of this page that explains it.
|
|
|
1297
1337
|
| `jskit/allow-comment-form` | a `readable-check: allow` reason without a prefix from the table below, or one that cites tests or the state of a project | [Exceptions](#exceptions) |
|
|
1298
1338
|
| `max-lines`, `max-lines-per-function` | files over 750 lines, functions over 600 | [Size limits](#size-limits) |
|
|
1299
1339
|
|
|
1340
|
+
### Test-run rules
|
|
1341
|
+
|
|
1342
|
+
`jskit check` reports these in every package script, and in the Playwright
|
|
1343
|
+
and Vitest configs those scripts use. No comment excuses them; a test file
|
|
1344
|
+
that must run alone says so on its own first line instead.
|
|
1345
|
+
|
|
1346
|
+
| Rule | Reports | Section |
|
|
1347
|
+
| --- | --- | --- |
|
|
1348
|
+
| `test/node-test` | a script that runs `node --test` directly instead of `jskit test` | [Test files run in parallel](#test-files-run-in-parallel) |
|
|
1349
|
+
| `test/fixed-concurrency` | `--test-concurrency` in a script | [Test files run in parallel](#test-files-run-in-parallel) |
|
|
1350
|
+
| `test/playwright-workers` | `--workers` or `-j` passed to `playwright test`, or its config without `workers: testConcurrency()` | [Test files run in parallel](#test-files-run-in-parallel) |
|
|
1351
|
+
| `test/vitest-workers` | `--maxWorkers`, `--minWorkers` or `--no-file-parallelism` passed to Vitest, or its config without `maxWorkers: testConcurrency()` or with `fileParallelism: false` | [Test files run in parallel](#test-files-run-in-parallel) |
|
|
1352
|
+
|
|
1300
1353
|
The rules see shapes, not intent. Feature files, owned state beyond
|
|
1301
1354
|
registries, shutdown, loggers, shared action fields, strict inputs, the action
|
|
1302
1355
|
policy, request context, validated input, one reader per fact, routes,
|
|
@@ -36,7 +36,9 @@ Cancel, Close, and a wizard's Previous step; keep existing unsaved-change
|
|
|
36
36
|
guards.
|
|
37
37
|
|
|
38
38
|
`createShellRouter()` owns scroll position (`shell/application-shell`
|
|
39
|
-
pattern); never reset scroll in page components.
|
|
39
|
+
pattern); never reset scroll in page components. An app's own scroll behaviour
|
|
40
|
+
is its `scrollBehavior` option, never a `createRouter` wrapper's (that throws);
|
|
41
|
+
a hash target opens below its `scroll-margin-top`.
|
|
40
42
|
|
|
41
43
|
## Application-owned files
|
|
42
44
|
|
package/guide/agent/index.md
CHANGED
|
@@ -35,6 +35,9 @@ apply or adapt. It does not prescribe an agent host or project orchestrator.
|
|
|
35
35
|
- [Material 3](/guide/framework/material-3)
|
|
36
36
|
- [UI pass](/guide/framework/ui-pass): make a task's changes, a section or the
|
|
37
37
|
whole app exact Material 3
|
|
38
|
+
- [Sanity checks](/guide/framework/sanity-checks): JSKIT's own pitfalls, and
|
|
39
|
+
the JSKIT calls that check data access, tests, a refactor, a screen or a
|
|
40
|
+
deployment before calling it done
|
|
38
41
|
- [Translating a JSKIT app](/guide/framework/translation)
|
|
39
42
|
- [Complete source pattern library](/patterns/)
|
|
40
43
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/agent-docs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.280",
|
|
4
4
|
"description": "Distributed JSKIT agent references, prompts, guides, and generated reference maps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"skills"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
-
"test": "
|
|
13
|
+
"test": "jskit test test/*.test.js"
|
|
14
14
|
},
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": "^22.13.0 || ^24.0.0 || ^26.0.0"
|
|
@@ -18,8 +18,12 @@ tests, browser tests, and the normal build entrypoints.
|
|
|
18
18
|
|
|
19
19
|
The example is a concrete application named `reading-room`. Copy the useful
|
|
20
20
|
files into the project root, rename the application in normal source and
|
|
21
|
-
package metadata, and then edit the product-facing page. The
|
|
22
|
-
|
|
21
|
+
package metadata, and then edit the product-facing page. The name is spelt in
|
|
22
|
+
`package.json`, `app.json` and `index.html`'s `<title>` (the app's name, which
|
|
23
|
+
the shell's messages use), and, once the app adds sign-in, in the
|
|
24
|
+
`auth/auth-surface` pattern's `src/components/AppBrand.vue` (the brand on the
|
|
25
|
+
sign-in screens); rename them together. The files become ordinary application
|
|
26
|
+
source immediately.
|
|
23
27
|
|
|
24
28
|
## Do not use when
|
|
25
29
|
|
|
@@ -35,6 +35,16 @@ and prove that disposable cleanup preserves browser migrations. Require
|
|
|
35
35
|
repeat-start regression proof; do not rebuild the database or production
|
|
36
36
|
frontend for each focused browser check.
|
|
37
37
|
|
|
38
|
+
Tests run in parallel within the machine's test budget: run node's test
|
|
39
|
+
runner through `jskit test` (`npm test`), and take Playwright's `workers` and
|
|
40
|
+
Vitest's `maxWorkers` from `testConcurrency()` of
|
|
41
|
+
`@jskit-ai/jskit-catalog/test-budget`; never one file at a time or a fixed
|
|
42
|
+
count. Isolate files that collide (their own port, temporary directory and
|
|
43
|
+
database) instead of serialising them; a file that truly must run alone says
|
|
44
|
+
why on its first line, `// jskit-test: alone - <reason>`. Plain `jskit check`
|
|
45
|
+
fails anything else
|
|
46
|
+
(`https://mobily-enterprises.github.io/jskit-ai/guide/framework/typed-features#test-files-run-in-parallel`).
|
|
47
|
+
|
|
38
48
|
Keep verification output small. Run the relevant cases together, save complete
|
|
39
49
|
stdout/stderr to local artifacts, and preserve the exit status. Report counts,
|
|
40
50
|
duration, failed case names and artifact paths; read only actionable failure
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"build:home": "VITE_SURFACE=home vite build",
|
|
25
25
|
"preview": "vite preview",
|
|
26
26
|
"lint": "eslint .",
|
|
27
|
-
"test": "
|
|
27
|
+
"test": "jskit test",
|
|
28
28
|
"test:client": "vitest run tests/client",
|
|
29
29
|
"test:e2e": "playwright test tests/e2e",
|
|
30
30
|
"jskit:update": "npx --yes @jskit-ai/jskit-catalog@latest update",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@local/main": "0.1.0",
|
|
36
36
|
"@fastify/static": "^10.1.3",
|
|
37
|
-
"@jskit-ai/kernel": "0.2.
|
|
38
|
-
"@jskit-ai/material-web": "0.1.
|
|
37
|
+
"@jskit-ai/kernel": "0.2.11",
|
|
38
|
+
"@jskit-ai/material-web": "0.1.3",
|
|
39
39
|
"@tanstack/vue-query": "^5.101.0",
|
|
40
40
|
"fastify": "^5.12.7",
|
|
41
41
|
"pino": "^10.3.1",
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
"vue": "^3.5.44",
|
|
45
45
|
"vue-router": "^5.3.1",
|
|
46
46
|
"vuetify": "^4.3.0",
|
|
47
|
-
"@jskit-ai/http-runtime": "0.2.
|
|
47
|
+
"@jskit-ai/http-runtime": "0.2.11",
|
|
48
48
|
"@fastify/fast-json-stringify-compiler": "^5.1.0",
|
|
49
49
|
"@vue/devtools-api": "^8.2.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@jskit-ai/config-eslint": "0.1.
|
|
53
|
-
"@jskit-ai/jskit-catalog": "0.2.
|
|
52
|
+
"@jskit-ai/config-eslint": "0.1.246",
|
|
53
|
+
"@jskit-ai/jskit-catalog": "0.2.32",
|
|
54
54
|
"@playwright/test": "1.61.1",
|
|
55
55
|
"@vitejs/plugin-vue": "^6.0.7",
|
|
56
56
|
"eslint": "^10.8.0",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineConfig } from "@playwright/test";
|
|
2
|
+
import { testConcurrency } from "@jskit-ai/jskit-catalog/test-budget";
|
|
2
3
|
|
|
3
4
|
const managedBaseUrl = String(process.env.PLAYWRIGHT_BASE_URL || "")
|
|
4
5
|
.trim()
|
|
@@ -9,6 +10,8 @@ const storageState = String(process.env.PLAYWRIGHT_STORAGE_STATE || "").trim();
|
|
|
9
10
|
|
|
10
11
|
export default defineConfig({
|
|
11
12
|
testDir: "./tests/e2e",
|
|
13
|
+
// Spec files run in parallel within the machine's test budget, so each one works on its own data.
|
|
14
|
+
workers: testConcurrency(),
|
|
12
15
|
timeout: 60_000,
|
|
13
16
|
expect: {
|
|
14
17
|
timeout: 10_000
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
// Vuetify's styles first, so its stylesheet comes before any component chunk's.
|
|
2
|
+
import "vuetify/styles";
|
|
3
|
+
import "@jskit-ai/material-web/client/material.css";
|
|
1
4
|
import { createApp } from "vue";
|
|
2
5
|
import { createPinia } from "pinia";
|
|
3
6
|
import { QueryClient, VueQueryPlugin } from "@tanstack/vue-query";
|
|
4
7
|
import { createRouter, createWebHistory } from "vue-router/auto";
|
|
5
8
|
import { routes } from "vue-router/auto-routes";
|
|
6
|
-
import "vuetify/styles";
|
|
7
|
-
import "@jskit-ai/material-web/client/material.css";
|
|
8
9
|
import { createVuetify } from "vuetify";
|
|
9
10
|
import { createMaterialVuetifyOptions } from "@jskit-ai/material-web/client";
|
|
10
11
|
import App from "./App.vue";
|
|
@@ -4,6 +4,7 @@ import vue from "@vitejs/plugin-vue";
|
|
|
4
4
|
import vuetify from "vite-plugin-vuetify";
|
|
5
5
|
import VueRouter from "vue-router/vite";
|
|
6
6
|
import { createJskitClientBootstrapPlugin } from "@jskit-ai/kernel/client/vite";
|
|
7
|
+
import { testConcurrency } from "@jskit-ai/jskit-catalog/test-budget";
|
|
7
8
|
|
|
8
9
|
const configuredDevPort = Number.parseInt(String(process.env.VITE_DEV_PORT || "").trim(), 10);
|
|
9
10
|
const devPort = Number.isInteger(configuredDevPort) && configuredDevPort > 0 ? configuredDevPort : 5173;
|
|
@@ -52,7 +53,8 @@ export default defineConfig({
|
|
|
52
53
|
}
|
|
53
54
|
],
|
|
54
55
|
test: {
|
|
55
|
-
include: ["tests/client/**/*.vitest.js"]
|
|
56
|
+
include: ["tests/client/**/*.vitest.js"],
|
|
57
|
+
maxWorkers: testConcurrency()
|
|
56
58
|
},
|
|
57
59
|
optimizeDeps: {
|
|
58
60
|
include: ["vuetify/components/**", "vuetify/directives/**"],
|
|
@@ -118,7 +118,10 @@ Read these together before adapting the shell:
|
|
|
118
118
|
|
|
119
119
|
## Variation points
|
|
120
120
|
|
|
121
|
-
Rename the example
|
|
121
|
+
Rename the example (its name is spelt in `package.json`, `app.json` and
|
|
122
|
+
`index.html`'s `<title>`, and, once the app adds sign-in, in the
|
|
123
|
+
`auth/auth-surface` pattern's `src/components/AppBrand.vue`; rename them
|
|
124
|
+
together), replace the home content, add or remove settings routes,
|
|
122
125
|
and change placements through their public contracts. Use package-owned
|
|
123
126
|
patterns for auth, users, databases, CRUD, realtime, and other capabilities.
|
|
124
127
|
Do not preinstall capabilities solely because they appear in another app.
|
|
@@ -35,6 +35,16 @@ and prove that disposable cleanup preserves browser migrations. Require
|
|
|
35
35
|
repeat-start regression proof; do not rebuild the database or production
|
|
36
36
|
frontend for each focused browser check.
|
|
37
37
|
|
|
38
|
+
Tests run in parallel within the machine's test budget: run node's test
|
|
39
|
+
runner through `jskit test` (`npm test`), and take Playwright's `workers` and
|
|
40
|
+
Vitest's `maxWorkers` from `testConcurrency()` of
|
|
41
|
+
`@jskit-ai/jskit-catalog/test-budget`; never one file at a time or a fixed
|
|
42
|
+
count. Isolate files that collide (their own port, temporary directory and
|
|
43
|
+
database) instead of serialising them; a file that truly must run alone says
|
|
44
|
+
why on its first line, `// jskit-test: alone - <reason>`. Plain `jskit check`
|
|
45
|
+
fails anything else
|
|
46
|
+
(`https://mobily-enterprises.github.io/jskit-ai/guide/framework/typed-features#test-files-run-in-parallel`).
|
|
47
|
+
|
|
38
48
|
Keep verification output small. Run the relevant cases together, save complete
|
|
39
49
|
stdout/stderr to local artifacts, and preserve the exit status. Report counts,
|
|
40
50
|
duration, failed case names and artifact paths; read only actionable failure
|