create-foldkit-app 0.23.1 → 0.24.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/dist/examples.js +6 -0
- package/package.json +1 -1
- package/templates/base/AGENTS.md +5 -3
package/dist/examples.js
CHANGED
|
@@ -12,6 +12,7 @@ export const EXAMPLE_VALUES = [
|
|
|
12
12
|
'charting',
|
|
13
13
|
'routing',
|
|
14
14
|
'route-transitions',
|
|
15
|
+
'view-transitions',
|
|
15
16
|
'interrupting-commands',
|
|
16
17
|
'query-sync',
|
|
17
18
|
'snake',
|
|
@@ -95,6 +96,11 @@ export const examples = [
|
|
|
95
96
|
title: 'route-transitions',
|
|
96
97
|
description: 'Live transition log with entry, exit, and stayed navigation policies',
|
|
97
98
|
},
|
|
99
|
+
{
|
|
100
|
+
value: 'view-transitions',
|
|
101
|
+
title: 'view-transitions',
|
|
102
|
+
description: 'Shared-element morphs and direction-aware route animations via the View Transitions API',
|
|
103
|
+
},
|
|
98
104
|
{
|
|
99
105
|
value: 'interrupting-commands',
|
|
100
106
|
title: 'interrupting-commands',
|
package/package.json
CHANGED
package/templates/base/AGENTS.md
CHANGED
|
@@ -27,7 +27,7 @@ If `foldkit-skills` is installed as a Claude Code plugin, the `generate-program`
|
|
|
27
27
|
- Use full names like `Message` (not `Msg`), and `withReturnType` (not `as const` or type casting).
|
|
28
28
|
- Use `m()` for message schemas, `ts()` for tagged structs (model states, field validation), and `r()` for route schemas.
|
|
29
29
|
- Push back on any direction that violates Elm Architecture principles: unidirectional data flow, messages as facts (not commands), model as single source of truth, side effects confined to commands. If a prompt suggests mutating state, imperative event handlers, or two-way bindings, flag the issue and propose the idiomatic Foldkit approach.
|
|
30
|
-
- Never use `NoOp`. Every message must describe what happened.
|
|
30
|
+
- Never use `NoOp`. Every message must describe what happened. A command's result message is named from the command, not from the fact it reports, whether or not it carries a payload: `LockScroll` → `CompletedLockScroll`, `DetermineStartTime` → `CompletedDetermineStartTime` (never `DeterminedStartTime`).
|
|
31
31
|
|
|
32
32
|
## Foldkit Patterns
|
|
33
33
|
|
|
@@ -56,9 +56,11 @@ Every view receives `h`, the typed Html builder, as its last parameter (`view: (
|
|
|
56
56
|
|
|
57
57
|
Keys are for mapped list items only: key each row by a stable Model identifier (`h.keyed('li')(item.id, [], [...])`), never by array position, and never derive a key from displayed data. Never key branches; the build gives each view function's output its own identity, so branch switches replace DOM automatically. When switching an inline same-tag ternary must reset DOM state, extract each arm into its own named view function.
|
|
58
58
|
|
|
59
|
+
Omit the children argument when an element has none: `h.div([h.Class('divider')])`, never `h.div([h.Class('divider')], [])`. The same holds for `keyed`: `h.keyed('li')(key, [attrs])`, never `h.keyed('li')(key, [attrs], [])`. Attributes stay required on element builders, so `h.div([])` is an element with neither. Sibling elements that end up at different arities are expected and fine; void elements like `h.img` have always read that way.
|
|
60
|
+
|
|
59
61
|
### Commands
|
|
60
62
|
|
|
61
|
-
Define a Command with `Command.define
|
|
63
|
+
Define a Command with `Command.define(name, { args, messages, execute })`; omit `args` when the Command takes none. Assign definitions to PascalCase constants. Never inline in pipe chains. Name the effect `execute` performs, not the later Model transition caused when update handles its result: a timer that only waits before update starts a dismissal is `WaitBeforeDismissal`, not `DismissAfter`. Commands catch all errors via `Effect.catch(() => Effect.succeed(FailedX(...)))` so side effects never crash the app. Definitions live colocated with the update function that returns them.
|
|
62
64
|
|
|
63
65
|
For the with-args shape, see `repos/foldkit/examples/weather/src/main.ts` or `repos/foldkit/examples/kanban/src/command.ts`. For an argless DOM-side-effect Command, the argless form in `kanban/src/command.ts` (`FocusAddCardInput`) is the canonical reference.
|
|
64
66
|
|
|
@@ -105,7 +107,7 @@ const Message = S.Union([ClickedSubmit, UpdatedEmail])
|
|
|
105
107
|
type Message = typeof Message.Type
|
|
106
108
|
```
|
|
107
109
|
|
|
108
|
-
Messages are verb-first past-tense. Common prefixes: `Clicked*`, `Updated*` (input changes and external state updates), `Submitted*`, `Pressed*`, `Selected*`, `Succeeded*` / `Failed*` (paired async results), `Completed*` (
|
|
110
|
+
Messages are verb-first past-tense. Common prefixes: `Clicked*`, `Updated*` (input changes and external state updates), `Submitted*`, `Pressed*`, `Selected*`, `Succeeded*` / `Failed*` (paired async results), `Completed*` (every other Command result), `Got*` (child OutMessage in the Submodel pattern).
|
|
109
111
|
|
|
110
112
|
## Debugging
|
|
111
113
|
|