@jay-framework/jay-stack-cli 0.24.6 → 0.25.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.
- package/agent-kit-template/INSTRUCTIONS.md +24 -1
- package/agent-kit-template/contracts/GUIDE.md +1 -1
- package/agent-kit-template/contracts/component-contracts.md +42 -12
- package/agent-kit-template/designer/INSTRUCTIONS.md +23 -20
- package/agent-kit-template/designer/cli-commands.md +46 -0
- package/agent-kit-template/designer/contracts-and-plugins.md +30 -1
- package/agent-kit-template/designer/design-system-guide.md +547 -0
- package/agent-kit-template/designer/jay-html-components.md +101 -31
- package/agent-kit-template/designer/jay-html-styling.md +70 -0
- package/agent-kit-template/designer/jay-html-syntax.md +22 -13
- package/agent-kit-template/designer/jay-html-template-syntax.md +3 -3
- package/agent-kit-template/designer/project-structure.md +1 -1
- package/agent-kit-template/designer/routing.md +2 -2
- package/agent-kit-template/designer/validation-guide.md +65 -6
- package/agent-kit-template/developer/INSTRUCTIONS.md +24 -19
- package/agent-kit-template/developer/page-components.md +23 -2
- package/agent-kit-template/developer/project-structure.md +1 -1
- package/agent-kit-template/developer/routing.md +1 -1
- package/agent-kit-template/devops/production-build.md +1 -1
- package/agent-kit-template/plugin/INSTRUCTIONS.md +3 -1
- package/agent-kit-template/plugin/component-structure.md +1 -1
- package/agent-kit-template/plugin/contracts-guide.md +18 -0
- package/agent-kit-template/plugin/design-system-guide.md +173 -0
- package/dist/{index-B9vCxAZ1.js → index-l6QVpvnY.js} +19 -14
- package/dist/index.js +2016 -212
- package/package.json +13 -12
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
This agent kit provides role-specific guides for building a Jay Stack application. Each role covers a different aspect of the project.
|
|
4
4
|
|
|
5
|
+
## Component model: Jay Stack is headless-only
|
|
6
|
+
|
|
7
|
+
Jay has two component models, and **Jay Stack uses only one of them — headless.**
|
|
8
|
+
|
|
9
|
+
- **Headless — the Jay Stack model.** Logic + a `.jay-contract`, with **no bound template of its own**. The
|
|
10
|
+
consuming page (or component) provides the UI by flattening the component's template into a `<jay:X>`
|
|
11
|
+
region. Authored with `makeJayStackComponent` (full-stack: slow/fast/interactive) or provided by a plugin.
|
|
12
|
+
Imported with `<script type="application/jay-headless" contract="…" [src="…"] [template="…"]>`. This is the
|
|
13
|
+
only component model a Jay Stack page composes.
|
|
14
|
+
- **Headfull — the lower-level Jay model.** Logic bundled with its **own** template via `makeJayComponent`.
|
|
15
|
+
Imported with `<script type="application/jay-headfull" src="…" names="…">` (**no** `contract=`). It has **no
|
|
16
|
+
server rendering**, so it is **never used directly in a Jay Stack page** — use it only in standalone,
|
|
17
|
+
client-only Jay apps. A `jay-headfull` import carrying a `contract=` is a hard build error (DL#196).
|
|
18
|
+
|
|
19
|
+
Throughout this kit, "component" means a headless component unless it explicitly says otherwise.
|
|
20
|
+
|
|
21
|
+
**Prefer a design system.** When UI is reused — or could be — compose it from headless components that ship
|
|
22
|
+
`.jay-html` templates (a _design system_) and **flatten** those templates into your pages as design-system
|
|
23
|
+
elements (`template=` + `jay-stack sync`), rather than hand-writing each `<jay:X>` region's markup. Flattened
|
|
24
|
+
regions stay consistent across pages and upgrade in one step via `sync`, while `validate` tracks any
|
|
25
|
+
per-page edits you choose to keep. Hand-author a region's body only when no template is shipped for it. See
|
|
26
|
+
[designer/design-system-guide.md](designer/design-system-guide.md).
|
|
27
|
+
|
|
5
28
|
## Roles
|
|
6
29
|
|
|
7
30
|
### Designer (`designer/`)
|
|
@@ -12,7 +35,7 @@ Creates `.jay-html` pages and templates. Binds to contract data using template s
|
|
|
12
35
|
|
|
13
36
|
### Developer (`developer/`)
|
|
14
37
|
|
|
15
|
-
Creates page components (`page.ts`) using `makeJayStackComponent`, defines page contracts (`page.jay-contract`), configures routing, and sets up project services. Also creates
|
|
38
|
+
Creates page components (`page.ts`) using `makeJayStackComponent`, defines page contracts (`page.jay-contract`), configures routing, and sets up project services. Also creates shared full-stack components (headless) for reusable UI sections (headers, footers).
|
|
16
39
|
|
|
17
40
|
**Use when:** adding page logic, defining data shapes, configuring the project, or creating shared components.
|
|
18
41
|
|
|
@@ -13,7 +13,7 @@ A page has its own data that isn't fully provided by plugins.
|
|
|
13
13
|
- Can coexist with plugin headless contracts on the same page
|
|
14
14
|
- See [page-contracts.md](page-contracts.md)
|
|
15
15
|
|
|
16
|
-
###
|
|
16
|
+
### Full-stack component contract
|
|
17
17
|
|
|
18
18
|
A shared UI section (header, footer, sidebar) that appears across multiple pages.
|
|
19
19
|
|
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Full-Stack Component Contracts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Shared full-stack components in Jay Stack are **headless** — logic + a contract, with their template
|
|
4
|
+
provided by the consuming page. The contract defines the data the component provides to that template.
|
|
4
5
|
|
|
5
6
|
## When to Use
|
|
6
7
|
|
|
7
|
-
Use a
|
|
8
|
+
Use a full-stack component contract for shared UI sections that appear across multiple pages: headers,
|
|
9
|
+
footers, sidebars, navigation menus.
|
|
8
10
|
|
|
9
11
|
## File Structure
|
|
10
12
|
|
|
11
|
-
Each
|
|
13
|
+
Each component lives in its own subdirectory under `src/components/`:
|
|
12
14
|
|
|
13
15
|
```
|
|
14
16
|
src/components/site-header/
|
|
15
17
|
site-header.ts # makeJayStackComponent logic
|
|
16
|
-
site-header.jay-html # template
|
|
18
|
+
site-header.jay-html # source template (flattened into the page)
|
|
17
19
|
site-header.jay-contract # contract (required)
|
|
18
20
|
```
|
|
19
21
|
|
|
20
22
|
## Contract with Props
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
Full-stack components use `props` (not `params`) for configuration passed by the parent page:
|
|
23
25
|
|
|
24
26
|
```yaml
|
|
25
27
|
name: site-header
|
|
@@ -55,23 +57,51 @@ tags:
|
|
|
55
57
|
|
|
56
58
|
## Importing in jay-html
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
Import it as a headless component — `src=` for the logic, `contract=` for the data shape, and `template=`
|
|
61
|
+
so `jay-stack sync` can flatten the component's markup into the page:
|
|
59
62
|
|
|
60
63
|
```html
|
|
61
64
|
<script
|
|
62
|
-
type="application/jay-
|
|
65
|
+
type="application/jay-headless"
|
|
63
66
|
src="../components/site-header/site-header"
|
|
64
|
-
names="SiteHeader"
|
|
65
67
|
contract="../components/site-header/site-header.jay-contract"
|
|
68
|
+
template="../components/site-header/site-header.jay-html"
|
|
66
69
|
></script>
|
|
67
70
|
```
|
|
68
71
|
|
|
69
|
-
Usage in the page body:
|
|
72
|
+
Usage in the page body — place the region and run `jay-stack sync` to flatten its body:
|
|
70
73
|
|
|
71
74
|
```html
|
|
72
|
-
<jay:SiteHeader logoUrl="/logo.png" />
|
|
75
|
+
<jay:SiteHeader ref="header" logoUrl="/logo.png" />
|
|
73
76
|
```
|
|
74
77
|
|
|
78
|
+
> `application/jay-headfull` with a `contract=` attribute is a hard build error (DL#196). `jay-headfull` is
|
|
79
|
+
> the lower-level Jay model (`makeJayComponent`, no server rendering) and is never used in a Jay Stack page.
|
|
80
|
+
> See [jay-html-components.md](../designer/jay-html-components.md#headfull-components-are-not-for-jay-stack).
|
|
81
|
+
|
|
82
|
+
## Templates and the sync / validate pair
|
|
83
|
+
|
|
84
|
+
A headless component has **no bound template of its own** — but it can **ship one or more `.jay-html`
|
|
85
|
+
templates** alongside its logic and contract, for pages to flatten. Each is a self-contained template over
|
|
86
|
+
the same contract; a page chooses which one to flatten with `template=`:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
src/components/site-header/
|
|
90
|
+
site-header.ts # logic (makeJayStackComponent)
|
|
91
|
+
site-header.jay-contract # contract (required)
|
|
92
|
+
site-header.jay-html # default template
|
|
93
|
+
site-header-compact.jay-html # an alternative template (optional)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Flattening copies the chosen template's markup into the page, where you own and edit the copy. This is a
|
|
97
|
+
**design-system element** — and the `sync` / `validate` pair keeps the copy honest:
|
|
98
|
+
|
|
99
|
+
- `jay-stack validate` diffs the page's flattened region against its source `template=` and reports drift
|
|
100
|
+
(at facet granularity) as warnings.
|
|
101
|
+
- `jay-stack sync` re-flattens from the current source, preserving the facets you marked `override`.
|
|
102
|
+
|
|
103
|
+
See [design-system-guide.md](../designer/design-system-guide.md) for the full drift / facet / sync model.
|
|
104
|
+
|
|
75
105
|
## Component Contract vs Page Contract
|
|
76
106
|
|
|
77
107
|
| | Page contract | Component contract |
|
|
@@ -79,4 +109,4 @@ Usage in the page body:
|
|
|
79
109
|
| **Location** | `src/pages/.../page.jay-contract` | `src/components/<name>/<name>.jay-contract` |
|
|
80
110
|
| **Params** | Yes (from route segments) | No (components don't own routes) |
|
|
81
111
|
| **Props** | Rarely | Yes (configured by parent) |
|
|
82
|
-
| **Import** | `<script type="application/jay-data">` | `<script type="application/jay-
|
|
112
|
+
| **Import** | `<script type="application/jay-data">` | `<script type="application/jay-headless">` with `contract` attribute |
|
|
@@ -31,31 +31,34 @@ There is no standalone "interactive" phase. Any tag with `type: interactive` (re
|
|
|
31
31
|
4. **Read actions** — read `.jay-action` files (paths from plugins-index) to see action descriptions, input schemas, and output schemas. This tells you what data each action accepts and returns.
|
|
32
32
|
5. **Read references** — check `references/<plugin>/` for pre-generated discovery data (product catalogs, collection schemas, etc.). These are generated by `jay-stack agent-kit` and contain real data from the site.
|
|
33
33
|
6. **Discover data** — run `jay-stack params <plugin>/<contract>` for SSG route params, `jay-stack action <plugin>/<action>` for data discovery. Use reference files (step 5) first when available — they're faster than running CLI commands.
|
|
34
|
-
7. **Create pages** — write `.jay-html` files under `src/pages/` following directory-based routing. For static override routes (a static page that overrides a dynamic route for a specific URL), declare params with `<script type="application/jay-params">`. Jay-html `if` and `{…}` bind to **tag names only** — no `.length`, method calls, or bracket indexing; derive booleans and counts in `page.ts` (see [jay-html-template-syntax.md](jay-html-template-syntax.md#expression-limits-important)).
|
|
34
|
+
7. **Create pages** — write `.jay-html` files under `src/pages/` following directory-based routing. **Prefer a design system:** when a plugin or component ships a `.jay-html` template, flatten it into your page as a design-system element (`template=` + `jay-stack sync`) and tweak the copy, rather than hand-writing the `<jay:X>` body — see [design-system-guide.md](design-system-guide.md). For static override routes (a static page that overrides a dynamic route for a specific URL), declare params with `<script type="application/jay-params">`. Jay-html `if` and `{…}` bind to **tag names only** — no `.length`, method calls, or bracket indexing; derive booleans and counts in `page.ts` (see [jay-html-template-syntax.md](jay-html-template-syntax.md#expression-limits-important)).
|
|
35
35
|
8. **Validate** — run `jay-stack validate` to check for errors.
|
|
36
36
|
9. **Test** — run `jay-stack dev --test-mode` and verify pages render.
|
|
37
37
|
|
|
38
38
|
## Reference Docs
|
|
39
39
|
|
|
40
|
-
| File | Topic
|
|
41
|
-
| ---------------------------------------------------------- |
|
|
42
|
-
| [project-structure.md](project-structure.md) | Project layout, styling patterns (CSS themes, design tokens), configuration files
|
|
43
|
-
| [jay-html-syntax.md](jay-html-syntax.md) | Jay-HTML overview: philosophy, component types, nesting rules, links to sub-files
|
|
44
|
-
| [jay-html-template-syntax.md](jay-html-template-syntax.md) | Template markup: data binding, conditions, expression limits (no `.length`), loops, refs
|
|
45
|
-
| [jay-html-components.md](jay-html-components.md) | Component imports: headless (key/instance),
|
|
46
|
-
| [
|
|
47
|
-
| [
|
|
48
|
-
| [
|
|
49
|
-
| [
|
|
50
|
-
| [
|
|
51
|
-
| [
|
|
52
|
-
| [
|
|
53
|
-
| [
|
|
54
|
-
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
40
|
+
| File | Topic |
|
|
41
|
+
| ---------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
42
|
+
| [project-structure.md](project-structure.md) | Project layout, styling patterns (CSS themes, design tokens), configuration files |
|
|
43
|
+
| [jay-html-syntax.md](jay-html-syntax.md) | Jay-HTML overview: philosophy, component types, nesting rules, links to sub-files |
|
|
44
|
+
| [jay-html-template-syntax.md](jay-html-template-syntax.md) | Template markup: data binding, conditions, expression limits (no `.length`), loops, refs |
|
|
45
|
+
| [jay-html-components.md](jay-html-components.md) | Component imports: headless (key/instance), full-stack components, nesting, per-instance customization |
|
|
46
|
+
| [design-system-guide.md](design-system-guide.md) | Design-system elements — **create** (author template + contract, `jay-content` slots) and **use** (flatten with `template=`, drift, `override` facets, `sync`) |
|
|
47
|
+
| [jay-html-styling.md](jay-html-styling.md) | Styling: inline, external, dynamic style bindings, class bindings |
|
|
48
|
+
| [routing.md](routing.md) | Directory-based routing: page structure, dynamic routes, route priority |
|
|
49
|
+
| [navigation-patterns.md](navigation-patterns.md) | Active menu/sidebar patterns using `jay.url.path`, `===`, and `^=` operators |
|
|
50
|
+
| [contracts-and-plugins.md](contracts-and-plugins.md) | Reading contracts, plugin.yaml, .jay-action files, and the materialized indexes |
|
|
51
|
+
| [Contract Authoring Guide](../contracts/GUIDE.md) | Writing contracts: syntax, page/component/linked contracts, examples |
|
|
52
|
+
| [script-tags.md](script-tags.md) | Script tag policy: use page.ts for behavior, jay-script="allow" for third-party scripts |
|
|
53
|
+
| [cli-commands.md](cli-commands.md) | CLI commands: setup, validate, sync, params, action, dev server |
|
|
54
|
+
| [validation-guide.md](validation-guide.md) | Understanding validation output: static analysis, component warnings, how to act on findings |
|
|
55
|
+
| `../references/<plugin>/` | Pre-generated discovery data: product catalogs, collection schemas (from `jay-stack agent-kit`) |
|
|
56
|
+
|
|
57
|
+
## When to Use Shared Full-Stack Components
|
|
58
|
+
|
|
59
|
+
Use shared full-stack components (headless — `makeJayStackComponent` + contract) for **shared UI sections that should look the same across pages** — headers, navigation menus, footers, sidebars. These are placed in `src/components/` and imported into any page that needs them. This keeps the shared layout in one place: update the component once and every page reflects the change.
|
|
60
|
+
|
|
61
|
+
The component ships its UI as one or more `.jay-html` templates. A page **flattens** a chosen template into a `<jay:X>` region (a **design-system element**) with `template=` + `jay-stack sync`, and may then tweak that copy. `jay-stack validate` reports where the copy has drifted from the source and `jay-stack sync` re-flattens it — so the component stays reusable while a page can still own per-instance edits. See [design-system-guide.md](design-system-guide.md).
|
|
59
62
|
|
|
60
63
|
If a section is **unique to a single page**, write it directly in the page's `.jay-html` — no component needed.
|
|
61
64
|
|
|
@@ -93,6 +93,52 @@ Errors:
|
|
|
93
93
|
|
|
94
94
|
Always run validate after creating or editing jay-html and contract files.
|
|
95
95
|
|
|
96
|
+
`validate` also nudges you to reuse UI through **design-system elements** (warnings, never blocking):
|
|
97
|
+
`REGION-NOT-LINKED` (a hand-authored region that could link a shipped template), `COMPONENT-NO-TEMPLATE` (a
|
|
98
|
+
component shipping no template), `REGION-OVERRIDE-NON-CONTENT` (a linked region restyled into its own
|
|
99
|
+
variant), and `NO-DESIGN-SYSTEM` (the project uses none). Each is suppressible — see
|
|
100
|
+
[design-system-guide.md](design-system-guide.md#suppressing-the-preference-warnings) and
|
|
101
|
+
[validation-guide.md](validation-guide.md).
|
|
102
|
+
|
|
103
|
+
## jay-stack sync
|
|
104
|
+
|
|
105
|
+
Re-flatten **design-system elements** — `<jay:X>` regions whose import carries `template=` — from their
|
|
106
|
+
current source templates. Fills an empty region on first use, and re-flattens after a component upgrade,
|
|
107
|
+
**preserving every facet you marked `override`**. See
|
|
108
|
+
[design-system-guide.md](design-system-guide.md) for the full model.
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Sync every design-system region in the project
|
|
112
|
+
jay-stack sync
|
|
113
|
+
|
|
114
|
+
# Sync a single page
|
|
115
|
+
jay-stack sync src/pages/home.jay-html
|
|
116
|
+
|
|
117
|
+
# Explicitly sync all pages
|
|
118
|
+
jay-stack sync --all
|
|
119
|
+
|
|
120
|
+
# Show pages that were already in sync
|
|
121
|
+
jay-stack sync -v
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Sync is **re-flatten, not merge**: it overwrites everything from source except your `override` facets — no
|
|
125
|
+
merge base, no conflict prompt. It only touches regions with `template=` provenance; keyed and
|
|
126
|
+
hand-authored nested components are left alone. CSS reconciles the same way: an `@scope (.<ref>)` block is
|
|
127
|
+
rewritten to canonical form unless it carries a `/* jay:override */` pragma, which is preserved verbatim.
|
|
128
|
+
|
|
129
|
+
Example output:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
✓ synced 2 region(s) in src/pages/home.jay-html
|
|
133
|
+
Synced 2 region(s) across 1 file(s).
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
When nothing needs re-flattening:
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
Nothing to sync.
|
|
140
|
+
```
|
|
141
|
+
|
|
96
142
|
## jay-stack params
|
|
97
143
|
|
|
98
144
|
Discover load param values for SSG route generation.
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Contracts and Plugins
|
|
2
2
|
|
|
3
|
+
## Discovery: Design-System Index (what you can flatten)
|
|
4
|
+
|
|
5
|
+
Before hand-authoring a `<jay:X>` region, check what design-system elements already exist. After
|
|
6
|
+
`jay-stack agent-kit`, two generated files catalog every component you can flatten:
|
|
7
|
+
|
|
8
|
+
- **`design-system.md`** — a human/agent "add-menu": each component, its template variants, and a
|
|
9
|
+
paste-ready `template=` import + `<jay:X>` snippet. Start here to pick something to add.
|
|
10
|
+
- **`design-system-index.yaml`** — the structured form (linked from `plugins-index.yaml` via
|
|
11
|
+
`designSystemIndex`). Each component lists its `contractPath`, a component-level `description`, and
|
|
12
|
+
its `templates[]` (`{ path, variant, title? }`). An empty `templates: []` means the component ships
|
|
13
|
+
no template yet and must be hand-authored.
|
|
14
|
+
|
|
15
|
+
Prefer flattening a listed template (link it with `template=` and run `jay-stack sync`) over
|
|
16
|
+
hand-writing the region. See `designer/design-system-guide.md`.
|
|
17
|
+
|
|
3
18
|
## Discovery: Plugins Index
|
|
4
19
|
|
|
5
20
|
After running `jay-stack agent-kit`, read `plugins-index.yaml`:
|
|
@@ -100,10 +115,24 @@ props:
|
|
|
100
115
|
- name: productId
|
|
101
116
|
type: string
|
|
102
117
|
required: true
|
|
118
|
+
phase: fast # slow (default), fast, or fast+interactive
|
|
103
119
|
description: The ID of the product to display
|
|
104
120
|
```
|
|
105
121
|
|
|
106
|
-
Use in jay-html: `<jay:contract-name productId="value">`.
|
|
122
|
+
Use in jay-html: `<jay:contract-name productId="value">` (a literal), or bind a page tag: `<jay:contract-name productId="{someTag}">`.
|
|
123
|
+
|
|
124
|
+
**Prop phase must cover the binding source.** A prop has a `phase` (like a tag) that declares when the component reads it. When you bind a prop to a page tag, the **source tag's phase must be ≤ the prop's phase**:
|
|
125
|
+
|
|
126
|
+
- Binding a `slow` prop to a `fast` / `fast+interactive` tag is a **validation error** — the prop is resolved at build, where the source doesn't exist yet, so it would render `''` at SSR. Bind a `fast`-phase source, a route param, or a literal instead.
|
|
127
|
+
- Binding a `fast` (constant) prop to a `fast+interactive` (changing) source is also an error — a constant can't track a value that changes on the client.
|
|
128
|
+
- A higher-phase prop accepts any lower-or-equal source (e.g. a `fast+interactive` prop takes a `slow`, `fast`, or `fast+interactive` binding).
|
|
129
|
+
|
|
130
|
+
`jay-stack validate` (and `dev` / `build`) report these mismatches with the exact prop, source, and phases.
|
|
131
|
+
|
|
132
|
+
**Enum prop values must match the contract.** For a prop typed `enum(a | b | c)`:
|
|
133
|
+
|
|
134
|
+
- A **literal** value must be one of the declared members, case-sensitive — `status="success"` is fine, `status="sucess"` or `status="Success"` is a **validation error** naming the allowed members. (A wrong value silently renders nothing, because no `if="status===..."` branch matches.)
|
|
135
|
+
- A **bound** value (`status="{someTag}"`) must come from a source that is itself an enum with the **same members in the same order**. Binding a `string` tag, or an enum with different or reordered members, to an enum prop is a validation error.
|
|
107
136
|
|
|
108
137
|
### Params
|
|
109
138
|
|