create-nisc 0.9.3 → 0.9.4

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 (48) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +20 -22
  3. package/dist/{chunk-IJ5E5SA2.js → chunk-2W7KLXCO.js} +3 -3
  4. package/dist/{chunk-IJ5E5SA2.js.map → chunk-2W7KLXCO.js.map} +1 -1
  5. package/dist/cli.js +1 -1
  6. package/dist/index.js +1 -1
  7. package/package.json +1 -1
  8. package/templates/base/files/src/ui/kit.css +8 -41
  9. package/templates/dom/files/src/ui/kit.ts +2 -8
  10. package/templates/dom/files/src/ui/registry.ts +2 -2
  11. package/templates/model-first/agents-section.md +31 -25
  12. package/templates/model-first/files/src/app/action-catalog.ts +4 -3
  13. package/templates/model-first/files/src/app/actions/answer/turn.action.ts +23 -0
  14. package/templates/model-first/files/src/app/actions/ask/dock.action.ts +10 -33
  15. package/templates/model-first/files/src/app/actions/ask/dock.layout.ts +7 -39
  16. package/templates/model-first/files/src/app/actions/guide/guide.actions.ts +16 -19
  17. package/templates/model-first/files/src/app/app.ts +4 -3
  18. package/templates/model-first/files/src/app/charter/charter.ts +1 -1
  19. package/templates/model-first/files/src/app/screens.ts +27 -48
  20. package/templates/model-first/files/src/app/shell/frame.layout.ts +5 -1
  21. package/templates/model-first/files/src/app/shell/shell.ts +7 -10
  22. package/templates/model-first/files/src/dev/all-checks.ts +3 -3
  23. package/templates/model-first/files/src/dev/artifacts-check.ts +14 -25
  24. package/templates/model-first/files/src/dev/compose-check.ts +87 -136
  25. package/templates/model-first/files/src/dev/guide-check.ts +41 -58
  26. package/templates/model-first/files/src/dev/live-ask.ts +43 -138
  27. package/templates/model-first/files/src/dev/scripted.ts +24 -102
  28. package/templates/model-first/files/src/dev/shape-check.ts +2 -6
  29. package/templates/model-first/files/src/dev/strata.ts +2 -2
  30. package/templates/model-first/files/src/server/boot.ts +2 -2
  31. package/templates/model-first/files/src/server/compose/catalog.ts +10 -28
  32. package/templates/model-first/files/src/server/compose/composer.agent.ts +13 -11
  33. package/templates/model-first/files/src/server/compose/index.ts +55 -132
  34. package/templates/model-first/files/src/server/compose/knowledge.ts +22 -43
  35. package/templates/model-first/files/src/server/compose/turn.schema.ts +55 -0
  36. package/templates/model-first/files/src/server/models/index.ts +5 -23
  37. package/templates/model-first/item.json +28 -38
  38. package/templates/react/files/src/ui/kit.tsx +14 -25
  39. package/templates/react/files/src/ui/registry.ts +2 -2
  40. package/templates/model-first/files/src/app/arrangements.ts +0 -17
  41. package/templates/model-first/files/src/app/shell/areas.ts +0 -3
  42. package/templates/model-first/files/src/server/compose/answer.ts +0 -145
  43. package/templates/model-first/files/src/server/compose/history.ts +0 -45
  44. package/templates/model-first/files/src/server/compose/layout.ts +0 -70
  45. package/templates/model-first/files/src/server/compose/pick.ts +0 -44
  46. package/templates/model-first/files/src/server/compose/plan.ts +0 -45
  47. package/templates/model-first/files/src/server/compose/reply.schema.ts +0 -70
  48. package/templates/model-first/files/src/server/compose/screen.ts +0 -40
@@ -1,10 +1,11 @@
1
1
  import type { ActionDefinition } from '@niscorp/nova';
2
2
  import { textAction } from './actions/answer/text.action';
3
+ import { turnAction } from './actions/answer/turn.action';
3
4
  import { dockAction } from './actions/ask/dock.action';
4
5
  import { GUIDE } from './actions/guide/guide.actions';
5
6
 
6
- // What the model may put on a screen, each opened with an input its schema takes. Its words are `answer.text`, placed
7
- // by saying them; the dock is never placed.
7
+ // What the model may show under its sentence, each opened with an input its schema takes. Its words are `answer.text`,
8
+ // placed by saying them; the dock and the turn are never placed by the model.
8
9
  export const placeable: readonly ActionDefinition[] = GUIDE;
9
10
 
10
- export const actions: Record<string, ActionDefinition> = Object.fromEntries([dockAction, textAction, ...placeable].map((action) => [action.id, action]));
11
+ export const actions: Record<string, ActionDefinition> = Object.fromEntries([dockAction, textAction, turnAction, ...placeable].map((action) => [action.id, action]));
@@ -0,0 +1,23 @@
1
+ import type { ActionDefinition } from '@niscorp/nova';
2
+ import { z } from 'zod';
3
+
4
+ // One turn of the conversation: what was asked, and the sentence the model answered with, or that it is still
5
+ // answering. Its cards follow it. Put on the conversation by the server (`ask`), never by the model.
6
+ export const turnAction: ActionDefinition = {
7
+ id: 'answer.turn',
8
+ title: 'You asked',
9
+ description: 'One turn of the conversation: what the person asked, and what the model said back.',
10
+ data: { question: '', reply: '', thinking: false },
11
+ input: z.toJSONSchema(
12
+ z.object({
13
+ question: z.string().describe('What the person asked.'),
14
+ reply: z.string().describe('What the model said back.'),
15
+ thinking: z.boolean().describe('Whether the model is still answering.'),
16
+ }),
17
+ ),
18
+ layout: {
19
+ component: 'Card',
20
+ props: { title: '{{$.question}}' },
21
+ children: [{ if: '$.thinking', then: { component: 'Text', props: { tone: 'muted' }, children: 'Thinking…' }, else: { component: 'Text', children: '{{$.reply}}' } }],
22
+ },
23
+ };
@@ -1,58 +1,35 @@
1
1
  import type { ActionDefinition, Step } from '@niscorp/nova';
2
2
  import { SCREENS } from '../../screens';
3
- import { AREAS } from '../../shell/areas';
4
3
  import { dockLayout } from './dock.layout';
5
4
 
6
- const shown: Step[] = [{ set: 'listing', value: false }, ...AREAS.map((area) => ({ reconcile: { canvas: area, to: `$.current.canvases.${area}`, action: 'action', input: 'input', own: 'canvas' as const } }))];
5
+ const send: Step[] = [{ set: 'error', value: '' }, { call: 'ask', onError: [{ set: 'error', value: '{{@error.message}}' }] }];
6
+ // What was typed is what is asked, and the line is empty again at once: the answer shows in the conversation.
7
+ const ask: Step[] = [{ set: 'asked', value: '{{$.text}}' }, { set: 'text', value: '' }, ...send];
7
8
 
8
- const ask: Step[] = [
9
- { set: 'asking', value: true },
10
- { set: 'error', value: '' },
11
- {
12
- call: 'ask',
13
- onSuccess: [{ set: 'asking', value: false }, { set: 'text', value: '' }, ...shown],
14
- onError: [{ set: 'asking', value: false }, { set: 'error', value: '{{@error.message}}' }],
15
- },
16
- ];
17
-
18
- const open: Step[] = [{ set: 'opening', value: '@event.payload' }, { call: 'open', onSuccess: shown }];
19
-
20
- const [first] = SCREENS;
9
+ const open: Step[] = [{ set: 'opening', value: '@event.payload' }, { call: 'open' }];
21
10
 
22
11
  export const dockAction: ActionDefinition = {
23
12
  id: 'ask.dock',
24
13
  title: 'Dock',
25
- description:
26
- 'Everything a person does, at the bottom: the screens; the chip naming the answer shown and where it stands, which opens what was asked, what the model said it did, and every answer to go back to; back and forward; and the line to ask in.',
14
+ description: 'Everything a person does, at the bottom: the conversation, the screens, and the line to ask in.',
27
15
  data: {
28
16
  screens: SCREENS.map(({ id, label }) => ({ id, label })),
29
- current: { question: '', response: '', label: first.label, screen: first.id, arrangement: first.arrangement, position: 1, total: 1, stack: [{ position: 1, label: first.label }], canvases: {} },
30
- listing: false,
17
+ shown: { screen: SCREENS[0].id },
31
18
  opening: '',
32
- going: 0,
33
19
  text: '',
34
- asking: false,
20
+ asked: '',
35
21
  error: '',
36
22
  },
37
23
  layout: dockLayout,
38
24
  endpoints: {
39
- ask: { fn: 'ask', target: 'current' },
40
- open: { fn: 'screens.open', target: 'current' },
41
- back: { fn: 'answers.back', target: 'current' },
42
- forward: { fn: 'answers.forward', target: 'current' },
43
- go: { fn: 'answers.go', target: 'current' },
44
- current: { fn: 'answers.current', target: 'current' },
25
+ ask: { fn: 'ask' },
26
+ open: { fn: 'screens.open', target: 'shown' },
45
27
  },
46
28
  triggers: [
47
- { message: 'answer-moved', do: [{ call: 'current', onSuccess: shown }] },
48
- { message: 'ask', do: [{ set: 'text', value: '@event.payload' }, ...ask] },
29
+ { message: 'ask', do: [{ set: 'asked', value: '@event.payload' }, ...send] },
49
30
  { message: 'open', do: open },
50
31
  { event: 'ui:key', key: 'Enter', ref: 'text', do: ask },
51
32
  { event: 'ui:click', ref: 'send', do: ask },
52
33
  { event: 'ui:click', ref: 'screen', do: open },
53
- { event: 'ui:click', ref: 'back', do: [{ call: 'back', onSuccess: shown }] },
54
- { event: 'ui:click', ref: 'forward', do: [{ call: 'forward', onSuccess: shown }] },
55
- { event: 'ui:click', ref: 'stack', do: [{ toggle: 'listing' }] },
56
- { event: 'ui:click', ref: 'entry', do: [{ set: 'going', value: '@event.payload' }, { call: 'go', onSuccess: shown }] },
57
34
  ],
58
35
  };
@@ -3,55 +3,23 @@ import type { LayoutNode } from '@niscorp/nova';
3
3
  export const dockLayout: LayoutNode = {
4
4
  component: 'Dock',
5
5
  children: [
6
+ { component: 'Talk', children: [{ component: 'CanvasSlot', props: { canvasId: 'talk' } }] },
6
7
  {
7
8
  component: 'Row',
8
9
  children: [
9
10
  {
10
- component: 'Row',
11
- children: [
12
- {
13
- for: '$.screens',
14
- as: 'screen',
15
- key: 'id',
16
- do: { component: 'Button', ref: 'screen', props: { label: '$screen.label', value: '$screen.id', tone: { $if: { $eq: ['$screen.id', '$.current.screen'] }, $then: 'chosen', $else: 'choice' } } },
17
- },
18
- ],
19
- },
20
- {
21
- component: 'Row',
22
- children: [
23
- { component: 'Button', ref: 'back', props: { label: '←', tone: 'step' } },
24
- { component: 'Button', ref: 'stack', props: { label: '{{$.current.label}} · {{$.current.position}}/{{$.current.total}}', tone: 'summary' } },
25
- { component: 'Button', ref: 'forward', props: { label: '→', tone: 'step' } },
26
- ],
11
+ for: '$.screens',
12
+ as: 'screen',
13
+ key: 'id',
14
+ do: { component: 'Button', ref: 'screen', props: { label: '$screen.label', value: '$screen.id', tone: { $if: { $eq: ['$screen.id', '$.shown.screen'] }, $then: 'chosen', $else: 'choice' } } },
27
15
  },
28
16
  ],
29
17
  },
30
- {
31
- if: '$.listing',
32
- then: {
33
- component: 'Menu',
34
- children: [
35
- { if: '$.current.question', then: { component: 'Text', props: { tone: 'strong' }, children: '{{$.current.question}}' } },
36
- { if: '$.current.response', then: { component: 'Text', props: { tone: 'muted' }, children: '{{$.current.response}}' } },
37
- {
38
- for: '$.current.stack',
39
- as: 'entry',
40
- key: 'position',
41
- do: {
42
- component: 'Button',
43
- ref: 'entry',
44
- props: { label: '{{$entry.position}}. {{$entry.label}}', value: '$entry.position', tone: { $if: { $eq: ['$entry.position', '$.current.position'] }, $then: 'chosen', $else: 'choice' } },
45
- },
46
- },
47
- ],
48
- },
49
- },
50
18
  {
51
19
  component: 'Prompt',
52
20
  children: [
53
- { component: 'Input', ref: 'text', model: '$.text', props: { placeholder: 'What would you like to see?', clearOnEnter: true } },
54
- { component: 'Button', ref: 'send', props: { label: { $if: '$.asking', $then: 'Asking…', $else: 'Send' } } },
21
+ { component: 'Input', ref: 'text', model: '$.text', props: { placeholder: 'Ask anything', clearOnEnter: true } },
22
+ { component: 'Button', ref: 'send', props: { label: 'Send' } },
55
23
  { if: '$.error', then: { component: 'Text', props: { tone: 'error' }, children: '{{$.error}}' } },
56
24
  ],
57
25
  },
@@ -23,9 +23,9 @@ const card = (id: string, description: string, layout: LayoutNode, data: { title
23
23
  export const GUIDE: readonly ActionDefinition[] = [
24
24
  card('guide.welcome', 'The welcome: this app is a tour of nisc that a model leads; where the tour starts, and things to ask.', welcomeLayout, {
25
25
  title: 'Welcome to nisc',
26
- lead: 'This app is a short tour of nisc, and a model leads it. Use it like any app: press, tick, follow the links. Or ask for a screen, and the model builds it from these same cards.',
26
+ lead: 'This app is a short tour of nisc, and a model leads it. Use it like any app: press, tick, follow the links. Or ask something, and the model answers with these same cards.',
27
27
  links: [{ label: 'Start the tour →', screen: 'actions' }],
28
- examples: ['A counter that starts at 100', 'A checklist for my first nisc app', 'Quiz me on actions', 'Put the charter beside the counter'],
28
+ examples: ['A counter that starts at 100', 'A checklist for my first nisc app', 'Quiz me on actions', 'What is the charter?'],
29
29
  }, [opens, asks]),
30
30
  card('guide.nisc', 'What nisc is: apps built out of data — screens, reads, writes and rules as JSON, each with a schema — and code only at the edges, so a model can build them with you.', pointsLayout, {
31
31
  title: 'What nisc is',
@@ -33,7 +33,7 @@ export const GUIDE: readonly ActionDefinition[] = [
33
33
  points: [
34
34
  { title: 'Everything is data', text: 'Screens, reads, writes and rules are JSON, each with a schema.' },
35
35
  { title: 'Code at the edges', text: 'The kit draws and the server serves; the rest is data, checked.' },
36
- { title: 'Led by a model', text: 'Ask, and this app answers with a screen of its own cards.' },
36
+ { title: 'Led by a model', text: 'Ask, and this app answers with a sentence and its own cards.' },
37
37
  ],
38
38
  links: [{ label: 'Lesson 1: actions →', screen: 'actions' }],
39
39
  }),
@@ -53,7 +53,7 @@ export const GUIDE: readonly ActionDefinition[] = [
53
53
  '}',
54
54
  ].join('\n'),
55
55
  text: 'That is the counter on this screen. Actions live in src/app/actions/.',
56
- links: [{ label: 'Next: asking for a screen →', screen: 'asking' }],
56
+ links: [{ label: 'Next: asking →', screen: 'asking' }],
57
57
  }),
58
58
  card('guide.layouts', 'Layouts and the kit: a layout is JSON that names components and binds them to the action’s data, and never styles; the kit in src/ui/ draws them, and its stylesheet holds the look.', exampleLayout, {
59
59
  title: 'Layouts and the kit',
@@ -61,26 +61,26 @@ export const GUIDE: readonly ActionDefinition[] = [
61
61
  example: ['{', ' "component": "Card",', ' "props": { "title": "{{$.title}}" },', ' "children": [', ' { "component": "Text", "children": "{{$.count}}" }', ' ]', '}'].join('\n'),
62
62
  text: 'The kit in src/ui/ is the only code that draws, and its stylesheet the only place the look lives.',
63
63
  }),
64
- card('guide.answers', 'How a message becomes a screen here, step by step: Jev, a fast decision model, says which cards likely belong; gpt-oss, as a cortex agent, writes which areas change and with what; the answer is checked against the catalog; the screen streams in.', stepsLayout, {
65
- title: 'How your message becomes a screen',
66
- lead: 'What happens between your question and the screen it gets.',
64
+ card('guide.answers', 'How a message is answered here, step by step: gpt-oss, as a cortex agent, writes a sentence and the cards that show the answer; they are checked against the cards the app has; the turn goes into the conversation.', stepsLayout, {
65
+ title: 'How your message is answered',
66
+ lead: 'What happens between your question and the answer it gets.',
67
67
  steps: [
68
68
  'The dock sends your message to the server.',
69
- 'Jev, a fast decision model, reads it with the screen and says which cards likely belong.',
70
- 'gpt-oss, as a cortex agent, writes which areas change, with which cards, filled in.',
71
- 'The answer is checked against the cards the app has; one that does not hold is corrected.',
72
- 'The screen fills in while the answer is still being written.',
69
+ 'gpt-oss, as a cortex agent, is told the app’s cards and the conversation so far.',
70
+ 'It answers with one sentence and up to three cards, filled in.',
71
+ 'The cards are checked against the ones the app has; an answer that fails is sent back to be corrected.',
72
+ 'The turn goes into the conversation above the line. The screen behind it stays as it is.',
73
73
  ],
74
74
  links: [{ label: 'Next: who may do what →', screen: 'rules' }],
75
75
  }),
76
76
  card(
77
77
  'guide.ask',
78
- 'Things to ask the model, each asked when pressed: a checklist written for you, a quick check, cards moved or left alone.',
78
+ 'Things to ask the model, each asked when pressed: a checklist written for you, a quick check, a lesson card.',
79
79
  askLayout,
80
80
  {
81
- title: 'Ask for a screen',
82
- lead: 'What you ask goes to the model, and it answers with a screen of this app’s cards, filled in for you. Links open their screen without it.',
83
- examples: ['A checklist for adding a table', 'Quiz me on the shell', 'Put the counter beside the steps', 'Only the steps, please'],
81
+ title: 'Ask something',
82
+ lead: 'What you ask goes to the model, and it answers with a sentence and this app’s cards, filled in for you. Links open their screen without it.',
83
+ examples: ['A checklist for adding a table', 'Quiz me on the shell', 'How do reads work?', 'And who may call them?'],
84
84
  },
85
85
  [asks],
86
86
  ),
@@ -119,10 +119,7 @@ export const GUIDE: readonly ActionDefinition[] = [
119
119
  ' "public": {',
120
120
  ' "actions": ["ask.*", "answer.*", "guide.*"],',
121
121
  ' "data": ["packages.read"],',
122
- ' "functions": [',
123
- ' "ask", "screens.open", "answers.current",',
124
- ' "answers.back", "answers.forward", "answers.go"',
125
- ' ]',
122
+ ' "functions": ["ask", "screens.open"]',
126
123
  ' }',
127
124
  '}',
128
125
  ].join('\n'),
@@ -1,11 +1,12 @@
1
1
  import { defineApp } from '@niscorp/moss';
2
- import type { NiscApp, RunSink } from '@niscorp/moss';
2
+ import type { NiscApp, RunSink, ShellManifest } from '@niscorp/moss';
3
3
  import { actions } from './action-catalog';
4
4
  import { assignments } from './charter/assignments';
5
5
  import { charter } from './charter/charter';
6
6
  import { shell } from './shell/shell';
7
7
  import { ENTRIES } from './vex';
8
8
 
9
- export type AppSeams = { functions: NonNullable<NiscApp['functions']>; runs: RunSink };
9
+ export type AppSeams = { functions: NonNullable<NiscApp['functions']>; runs: RunSink; seeds?: ShellManifest['seeds'] };
10
10
 
11
- export const buildApp = (seams: AppSeams): NiscApp => defineApp({ charter, assignments, actions, entries: ENTRIES, shell, functions: seams.functions, runs: seams.runs });
11
+ export const buildApp = (seams: AppSeams): NiscApp =>
12
+ defineApp({ charter, assignments, actions, entries: ENTRIES, shell: { ...shell, ...(seams.seeds === undefined ? {} : { seeds: seams.seeds }) }, functions: seams.functions, runs: seams.runs });
@@ -5,6 +5,6 @@ export const charter: Charter = {
5
5
  public: {
6
6
  actions: ['ask.*', 'answer.*', 'guide.*'],
7
7
  data: ['packages.read'],
8
- functions: ['ask', 'screens.open', 'answers.back', 'answers.forward', 'answers.go', 'answers.current'],
8
+ functions: ['ask', 'screens.open'],
9
9
  },
10
10
  };
@@ -1,88 +1,67 @@
1
- export type Canvas = { action: string; input: Record<string, unknown>; intent: string };
1
+ // A card on a screen: one of the app's actions, opened with an input its schema takes.
2
+ export type Card = { action: string; input: Record<string, unknown> };
2
3
 
3
- export type Screen = { id: string; label: string; description: string; arrangement: string; canvases: Canvas[] };
4
+ // A screen in the dock: its cards, one under another. The first is the one the app opens on.
5
+ export type Screen = { id: string; label: string; cards: Card[] };
4
6
 
5
- const card = (action: string, intent: string): Canvas => ({ action, input: {}, intent });
7
+ const card = (action: string): Card => ({ action, input: {} });
6
8
 
7
- const COUNTER: Canvas = { action: 'guide.counter', input: { title: 'Press me', count: 0 }, intent: 'a counter to press' };
9
+ const COUNTER: Card = { action: 'guide.counter', input: { title: 'Press me', count: 0 } };
8
10
 
9
- const quiz = (question: string, options: string[], answer: number, explanation: string): Canvas => ({
11
+ const quiz = (question: string, options: string[], answer: number, explanation: string): Card => ({
10
12
  action: 'guide.quiz',
11
13
  input: { title: 'Quick check', question, options, answer, explanation },
12
- intent: `a quick check: ${question}`,
13
14
  });
14
15
 
15
16
  export const SCREENS: readonly [Screen, ...Screen[]] = [
16
17
  {
17
18
  id: 'start',
18
19
  label: 'Start',
19
- description: 'The welcome, a counter to press, a quick check, the tour as a checklist, and what nisc is.',
20
- arrangement: 'hero',
21
- canvases: [
22
- card('guide.welcome', 'what this app is, and where to start'),
20
+ cards: [
21
+ card('guide.welcome'),
23
22
  COUNTER,
24
23
  quiz('You press a link on this screen. What changes the view?', ['The model', 'The app, straight away', 'Your browser, on its own'], 1, 'Links act at once. Only what you ask — typed, or a thing to ask pressed — goes to the model.'),
25
- {
26
- action: 'guide.checklist',
27
- input: { title: 'Your tour', todo: ['Press the counter', 'Answer the quick check', 'Follow a link to a lesson', 'Ask for a screen in the line below', 'Ask the model to change a card'] },
28
- intent: 'the tour, as a checklist',
29
- },
30
- card('guide.nisc', 'what nisc is'),
24
+ { action: 'guide.checklist', input: { title: 'Your tour', todo: ['Press the counter', 'Answer the quick check', 'Follow a link to a lesson', 'Ask something in the line below', 'Ask for a counter that starts at 100'] } },
25
+ card('guide.nisc'),
31
26
  ],
32
27
  },
33
28
  {
34
29
  id: 'actions',
35
30
  label: 'Actions',
36
- description: 'Lesson 1: what an action is, the counter that is one, a quick check, how a card is drawn, and things to try.',
37
- arrangement: 'hero',
38
- canvases: [
39
- card('guide.actions', 'what an action is'),
31
+ cards: [
32
+ card('guide.actions'),
40
33
  COUNTER,
41
34
  quiz('Where does the look of a card live?', ['In its layout', 'In the model’s answer', 'In the kit’s stylesheet'], 2, 'A layout only names components; the kit in src/ui/ draws them, and its stylesheet holds the look.'),
42
- card('guide.layouts', 'how a card is drawn'),
43
- {
44
- action: 'guide.checklist',
45
- input: { title: 'Try it', todo: ['Press + until the counter says 5', 'Press Reset', 'Ask for a counter that starts at 100', 'Ask for the layouts card first'] },
46
- intent: 'things to try in this lesson',
47
- },
35
+ card('guide.layouts'),
36
+ { action: 'guide.checklist', input: { title: 'Try it', todo: ['Press + until the counter says 5', 'Press Reset', 'Ask for a counter that starts at 100', 'Ask what a layout is'] } },
48
37
  ],
49
38
  },
50
39
  {
51
40
  id: 'asking',
52
41
  label: 'Asking',
53
- description: 'Lesson 2: how a message becomes a screen, things to ask the model, and a quick check.',
54
- arrangement: 'hero',
55
- canvases: [
56
- card('guide.answers', 'how a message becomes a screen'),
57
- card('guide.ask', 'things to ask the model'),
58
- quiz('What does the model write when you ask for a screen?', ['Which cards go where, filled in', 'React code', 'A chat reply'], 0, 'It answers with actions and their inputs, area by area, and the app checks them before they are shown.'),
42
+ cards: [
43
+ card('guide.answers'),
44
+ card('guide.ask'),
45
+ quiz('What does the model answer with?', ['A sentence, and cards filled in', 'React code', 'A new screen layout'], 0, 'It answers with a sentence and up to three of the app’s cards, each opened with an input, and the app checks them before they are shown.'),
59
46
  ],
60
47
  },
61
48
  {
62
49
  id: 'rules',
63
50
  label: 'Rules',
64
- description: 'Lesson 3: the charter, the shell on the server, reads and writes, a read from a table, and a quick check.',
65
- arrangement: 'grid',
66
- canvases: [
67
- card('guide.charter', 'what the charter decides'),
68
- card('guide.shell', 'what the shell and moss are'),
69
- card('guide.data', 'how reads and writes work'),
70
- card('guide.packages', 'a read from a table: nisc’s packages'),
51
+ cards: [
52
+ card('guide.charter'),
53
+ card('guide.shell'),
54
+ card('guide.data'),
55
+ card('guide.packages'),
71
56
  quiz('Where is it decided what you may do?', ['In the browser', 'On the server, by the charter', 'In each card'], 1, 'Your browser only draws; the charter decides, on the server, what a role may reach.'),
72
57
  ],
73
58
  },
74
59
  {
75
60
  id: 'yours',
76
61
  label: 'Make it yours',
77
- description: 'What to delete to start your own app, and a checklist for its first feature.',
78
- arrangement: 'pair',
79
- canvases: [
80
- card('guide.yours', 'how to make the app yours'),
81
- {
82
- action: 'guide.checklist',
83
- input: { title: 'Your first feature', todo: ['Add a table in src/db/schema.ts', 'Add a read in src/app/vex/', 'Add an action that shows it', 'Grant it in the charter', 'Run npm run check'] },
84
- intent: 'a checklist for the first feature',
85
- },
62
+ cards: [
63
+ card('guide.yours'),
64
+ { action: 'guide.checklist', input: { title: 'Your first feature', todo: ['Add a table in src/db/schema.ts', 'Add a read in src/app/vex/', 'Add an action that shows it', 'Grant it in the charter', 'Run npm run check'] } },
86
65
  ],
87
66
  },
88
67
  ];
@@ -1,6 +1,10 @@
1
1
  import type { LayoutNode } from '@niscorp/nova';
2
2
 
3
+ // The screen shown, and the dock under it, with the conversation in it.
3
4
  export const frameLayout: LayoutNode = {
4
5
  component: 'Frame',
5
- children: [{ ref: 'answers' }, { component: 'CanvasSlot', props: { canvasId: 'dock' } }],
6
+ children: [
7
+ { component: 'CanvasSlot', props: { canvasId: 'screen' } },
8
+ { component: 'CanvasSlot', props: { canvasId: 'dock' } },
9
+ ],
6
10
  };
@@ -1,20 +1,17 @@
1
1
  import type { ShellManifest } from '@niscorp/moss';
2
- import { ARRANGEMENTS } from '../arrangements';
3
- import { SCREENS } from '../screens';
4
- import { AREAS } from './areas';
2
+ import type { LayoutNode } from '@niscorp/nova';
5
3
  import { frameLayout } from './frame.layout';
6
4
 
7
- const [first] = SCREENS;
8
- const arranged = ARRANGEMENTS.find((arrangement) => arrangement.id === first.arrangement) ?? ARRANGEMENTS[0];
5
+ const each: LayoutNode = { for: '$.instances', as: 'one', key: 'id', do: { component: 'ActionSlot', props: { instanceId: '$one.id' } } };
9
6
 
10
7
  export const shell: ShellManifest = {
11
8
  canvases: [
12
- ...AREAS.map((area, at) => {
13
- const canvas = first.canvases[at];
14
- return canvas === undefined ? { id: area } : { id: area, initial: { action: canvas.action, input: canvas.input } };
15
- }),
9
+ // The screen shown: its cards, one under another — the first screen's when a shell is built (`seeds`), then the one
10
+ // opened (`screens.open`, src/server/compose/index.ts).
11
+ { id: 'screen', mode: 'list', actionLayout: { component: 'Grid', props: { columns: 1 }, children: [each] } },
12
+ // The conversation, drawn in the dock: each turn, then its cards (`ask`). Empty until something is asked.
13
+ { id: 'talk', mode: 'list', actionLayout: [each] },
16
14
  { id: 'dock', initial: 'ask.dock' },
17
15
  ],
18
16
  layout: frameLayout,
19
- layoutStore: arranged === undefined ? {} : { answers: arranged.layout },
20
17
  };
@@ -1,11 +1,11 @@
1
1
  import { spawnSync } from 'node:child_process';
2
2
 
3
3
  const CHECKS: readonly (readonly [name: string, what: string, args?: readonly string[]])[] = [
4
- ['artifacts-check', 'src/app is data: pure JSON, every artifact parses its schema, every screen canvas opens an action with an input it takes'],
4
+ ['artifacts-check', 'src/app is data: pure JSON, every artifact parses its schema, every card on a screen opens an action with an input it takes'],
5
5
  ['shape-check', 'the app keeps nisc’s shape: no style-guide breaks, words in Prism, every server function an action calls named with its reason, src/app data, the kit within its own elements'],
6
6
  ['strata', 'the source is written at the installed grammars (strata.lock.json)', ['status', '--check']],
7
- ['compose-check', 'a message is answered with a screen: the open screen read, picked, composed, checked, placed, written, and back again'],
8
- ['guide-check', 'the tour: its cards pressed, ticked and picked, its links, and what the model sees and changes of them'],
7
+ ['compose-check', 'a message is answered with a turn: a sentence and the cards under it, checked, put on the conversation; screens opened'],
8
+ ['guide-check', 'the tour: its cards pressed, ticked and picked, its links, and its cards shown and filled in by the model'],
9
9
  ];
10
10
 
11
11
  let failed = 0;
@@ -3,11 +3,9 @@ import { ActionDefinitionSchema, LayoutNodeSchema } from '@niscorp/nova';
3
3
  import type { LayoutNode } from '@niscorp/nova';
4
4
  import { componentsOf, walkNodes } from '@niscorp/nova/reflect';
5
5
  import { actions } from '../app/action-catalog';
6
- import { ARRANGEMENTS } from '../app/arrangements';
7
6
  import { assignments } from '../app/charter/assignments';
8
7
  import { charter } from '../app/charter/charter';
9
8
  import { SCREENS } from '../app/screens';
10
- import { AREAS } from '../app/shell/areas';
11
9
  import { shell } from '../app/shell/shell';
12
10
  import { inputKeysOf } from '../server/compose/catalog';
13
11
  import { isRecord } from '../server/compose/record';
@@ -52,44 +50,35 @@ for (const [id, definition] of Object.entries(actions)) {
52
50
  const registered = new Set(buildRegistry().list());
53
51
  const layouts: [string, LayoutNode | undefined][] = [
54
52
  ['the frame', shell.layout],
53
+ ...(shell.canvases ?? []).map((canvas): [string, LayoutNode | undefined] => [`canvas "${canvas.id}"`, typeof canvas.actionLayout === 'string' ? undefined : canvas.actionLayout]),
55
54
  ...Object.values(actions).map((definition): [string, LayoutNode | undefined] => [`action "${definition.id}"`, definition.layout]),
56
- ...ARRANGEMENTS.map((arrangement): [string, LayoutNode | undefined] => [`arrangement "${arrangement.id}"`, arrangement.layout]),
57
55
  ];
58
56
  for (const [name, layout] of layouts) {
59
57
  const missing = [...componentsOf(layout)].filter((component) => !registered.has(component));
60
58
  check(`${name} names only components the kit has`, missing.length === 0, missing.join(', '));
61
59
  }
62
60
 
63
- pure('the arrangements', ARRANGEMENTS);
64
- const canvasesIn = (layout: unknown): string[] => {
65
- const held: string[] = [];
61
+ const slotsIn = (layout: unknown): string[] => {
62
+ const slots: string[] = [];
66
63
  walkNodes(layout, (node) => {
67
- if (node['component'] === 'CanvasSlot' && isRecord(node['props']) && typeof node['props']['canvasId'] === 'string') held.push(node['props']['canvasId']);
64
+ if (node['component'] === 'CanvasSlot' && isRecord(node['props']) && typeof node['props']['canvasId'] === 'string') slots.push(node['props']['canvasId']);
68
65
  });
69
- return held;
66
+ return slots;
70
67
  };
71
- for (const arrangement of ARRANGEMENTS) {
72
- parses(`arrangement "${arrangement.id}"`, () => LayoutNodeSchema.parse(arrangement.layout));
73
- const held = canvasesIn(arrangement.layout);
74
- check(`arrangement "${arrangement.id}" holds only areas the shell has, each once`, held.every((name) => AREAS.some((area) => area === name)) && new Set(held).size === held.length, held.join(', '));
75
- check(`arrangement "${arrangement.id}" holds the ${arrangement.areaCount} it says, the first areas in order`, held.join(',') === AREAS.slice(0, arrangement.areaCount).join(','), held.join(', '));
76
- }
77
- check('the frame has the region an arrangement is swapped into, and the first one in it', JSON.stringify(shell.layout).includes('"ref":"answers"') && shell.layoutStore?.['answers'] !== undefined);
68
+ const drawn = [...slotsIn(shell.layout), ...Object.values(actions).flatMap((definition) => slotsIn(definition.layout))];
69
+ for (const canvas of shell.canvases ?? []) check(`canvas "${canvas.id}" is drawn once: in the frame, or in an action`, drawn.filter((id) => id === canvas.id).length === 1, drawn.join(', '));
78
70
 
79
71
  pure('the screens', SCREENS);
80
72
  for (const screen of SCREENS) {
81
- for (const [at, canvas] of screen.canvases.entries()) {
82
- const action = actions[canvas.action];
83
- const named = `screen "${screen.id}" canvas ${at + 1}`;
84
- check(`${named} opens an action the app has`, action !== undefined, canvas.action);
85
- const extra = Object.keys(canvas.input).filter((key) => !inputKeysOf(action?.input).includes(key));
86
- check(`${named} gives only inputs ${canvas.action} takes`, extra.length === 0, extra.join(', '));
87
- const parsed = action?.input === undefined ? undefined : z.fromJSONSchema(action.input).safeParse(canvas.input);
73
+ for (const [at, card] of screen.cards.entries()) {
74
+ const action = actions[card.action];
75
+ const named = `screen "${screen.id}" card ${String(at + 1)}`;
76
+ check(`${named} opens an action the app has`, action !== undefined, card.action);
77
+ const extra = Object.keys(card.input).filter((key) => !inputKeysOf(action?.input).includes(key));
78
+ check(`${named} gives only inputs ${card.action} takes`, extra.length === 0, extra.join(', '));
79
+ const parsed = action?.input === undefined ? undefined : z.fromJSONSchema(action.input).safeParse(card.input);
88
80
  check(`${named} is opened with an input its action’s schema takes`, parsed === undefined || parsed.success, parsed?.error?.message ?? '');
89
- check(`${named} says why it is there`, canvas.intent.trim() !== '');
90
81
  }
91
- const arrangement = ARRANGEMENTS.find((candidate) => candidate.id === screen.arrangement);
92
- check(`screen "${screen.id}" is laid out in an arrangement there is, with room for its canvases`, arrangement !== undefined && arrangement.areaCount >= screen.canvases.length, `${screen.arrangement}: ${screen.canvases.length} canvases`);
93
82
  }
94
83
 
95
84
  finish();