create-nisc 0.8.0 → 0.8.2
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/CHANGELOG.md +20 -0
- package/README.md +89 -13
- package/dist/chunk-B3L4UJDN.js +316 -0
- package/dist/chunk-B3L4UJDN.js.map +1 -0
- package/dist/cli.js +86 -42
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +61 -6
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/base/files/src/ui/kit.css +232 -0
- package/templates/base/item.json +31 -0
- package/templates/{moss-dom → classic/files}/src/app/actions/surfaces/welcome.action.ts +1 -1
- package/templates/classic/item.json +32 -0
- package/templates/{moss-dom → dom/files}/index.html +1 -1
- package/templates/dom/files/src/ui/kit.ts +109 -0
- package/templates/{shell-dom → dom/files}/src/ui/registry.ts +2 -2
- package/templates/{shell-dom → dom/files}/tsconfig.json +3 -14
- package/templates/dom/item.json +24 -0
- package/templates/model-first/agents-section.md +42 -0
- package/templates/model-first/files/src/app/action-catalog.ts +10 -0
- package/templates/model-first/files/src/app/actions/answer/text.action.ts +17 -0
- package/templates/model-first/files/src/app/actions/answer/text.layout.ts +3 -0
- package/templates/model-first/files/src/app/actions/ask/dock.action.ts +58 -0
- package/templates/model-first/files/src/app/actions/ask/dock.layout.ts +59 -0
- package/templates/model-first/files/src/app/actions/guide/checklist.action.ts +24 -0
- package/templates/model-first/files/src/app/actions/guide/checklist.layout.ts +17 -0
- package/templates/model-first/files/src/app/actions/guide/counter.action.ts +22 -0
- package/templates/model-first/files/src/app/actions/guide/counter.layout.ts +19 -0
- package/templates/model-first/files/src/app/actions/guide/guide.actions.ts +144 -0
- package/templates/model-first/files/src/app/actions/guide/guide.layouts.ts +31 -0
- package/templates/model-first/files/src/app/actions/guide/quiz.action.ts +25 -0
- package/templates/model-first/files/src/app/actions/guide/quiz.layout.ts +33 -0
- package/templates/model-first/files/src/app/app.ts +11 -0
- package/templates/model-first/files/src/app/arrangements.ts +17 -0
- package/templates/model-first/files/src/app/charter/assignments.ts +1 -0
- package/templates/model-first/files/src/app/charter/charter.ts +10 -0
- package/templates/model-first/files/src/app/screens.ts +87 -0
- package/templates/model-first/files/src/app/shell/areas.ts +3 -0
- package/templates/model-first/files/src/app/shell/frame.layout.ts +6 -0
- package/templates/model-first/files/src/app/shell/shell.ts +20 -0
- package/templates/model-first/files/src/app/vex/index.ts +3 -0
- package/templates/model-first/files/src/db/schema.ts +3 -0
- package/templates/{moss-react → model-first/files}/src/dev/all-checks.ts +3 -2
- package/templates/model-first/files/src/dev/artifacts-check.ts +95 -0
- package/templates/model-first/files/src/dev/checks.ts +13 -0
- package/templates/model-first/files/src/dev/compose-check.ts +191 -0
- package/templates/model-first/files/src/dev/guide-check.ts +90 -0
- package/templates/model-first/files/src/dev/live-ask.ts +185 -0
- package/templates/model-first/files/src/dev/scripted.ts +208 -0
- package/templates/{shell-dom → model-first/files}/src/dev/strata.ts +7 -1
- package/templates/model-first/files/src/server/boot.ts +24 -0
- package/templates/model-first/files/src/server/compose/answer.ts +145 -0
- package/templates/model-first/files/src/server/compose/catalog.ts +46 -0
- package/templates/model-first/files/src/server/compose/composer.agent.ts +18 -0
- package/templates/model-first/files/src/server/compose/history.ts +45 -0
- package/templates/model-first/files/src/server/compose/index.ts +170 -0
- package/templates/model-first/files/src/server/compose/knowledge.ts +57 -0
- package/templates/model-first/files/src/server/compose/layout.ts +70 -0
- package/templates/model-first/files/src/server/compose/pick.ts +44 -0
- package/templates/model-first/files/src/server/compose/plan.ts +45 -0
- package/templates/model-first/files/src/server/compose/record.ts +3 -0
- package/templates/model-first/files/src/server/compose/reply.schema.ts +70 -0
- package/templates/model-first/files/src/server/compose/screen.ts +40 -0
- package/templates/model-first/files/src/server/models/index.ts +35 -0
- package/templates/model-first/files/src/server/runs/index.ts +20 -0
- package/templates/model-first/item.json +84 -0
- package/templates/{moss-dom → moss/files}/README.md +1 -1
- package/templates/moss/item.json +40 -0
- package/templates/{shell-dom → page/files}/README.md +1 -1
- package/templates/page/item.json +37 -0
- package/templates/questions.json +5 -0
- package/templates/{moss-react → react/files}/index.html +1 -1
- package/templates/react/files/src/ui/kit.tsx +221 -0
- package/templates/{moss-react → react/files}/src/ui/registry.ts +2 -2
- package/templates/react/item.json +31 -0
- package/dist/chunk-RU5ATATK.js +0 -174
- package/dist/chunk-RU5ATATK.js.map +0 -1
- package/templates/moss-dom/package.json +0 -39
- package/templates/moss-dom/src/app/actions/surfaces/welcome.layout.ts +0 -25
- package/templates/moss-dom/src/ui/kit.css +0 -42
- package/templates/moss-dom/src/ui/kit.ts +0 -35
- package/templates/moss-dom/src/ui/registry.ts +0 -15
- package/templates/moss-dom/tsconfig.json +0 -27
- package/templates/moss-react/README.md +0 -15
- package/templates/moss-react/nisc.config.ts +0 -11
- package/templates/moss-react/package.json +0 -42
- package/templates/moss-react/src/app/action-catalog.ts +0 -6
- package/templates/moss-react/src/app/actions/surfaces/welcome.action.ts +0 -10
- package/templates/moss-react/src/app/app.ts +0 -7
- package/templates/moss-react/src/app/charter/assignments.ts +0 -2
- package/templates/moss-react/src/app/charter/charter.ts +0 -5
- package/templates/moss-react/src/app/shell/frame.layout.ts +0 -3
- package/templates/moss-react/src/app/shell/shell.ts +0 -7
- package/templates/moss-react/src/dev/artifacts-check.ts +0 -49
- package/templates/moss-react/src/dev/strata.ts +0 -21
- package/templates/moss-react/src/dev/welcome-check.ts +0 -38
- package/templates/moss-react/src/server/boot.ts +0 -6
- package/templates/moss-react/src/server/runtime.ts +0 -13
- package/templates/moss-react/src/ui/kit.css +0 -42
- package/templates/moss-react/src/ui/kit.tsx +0 -39
- package/templates/moss-react/strata.lock.json +0 -6
- package/templates/shell-dom/index.html +0 -12
- package/templates/shell-dom/package.json +0 -35
- package/templates/shell-dom/src/app/action-catalog.ts +0 -6
- package/templates/shell-dom/src/app/actions/surfaces/welcome.action.ts +0 -10
- package/templates/shell-dom/src/app/actions/surfaces/welcome.layout.ts +0 -32
- package/templates/shell-dom/src/app/shell/frame.layout.ts +0 -3
- package/templates/shell-dom/src/ui/kit.css +0 -42
- package/templates/shell-dom/src/ui/kit.ts +0 -35
- package/templates/shell-dom/strata.lock.json +0 -6
- package/templates/shell-dom/vite.config.ts +0 -5
- package/templates/shell-react/README.md +0 -16
- package/templates/shell-react/index.html +0 -12
- package/templates/shell-react/package.json +0 -40
- package/templates/shell-react/src/app/action-catalog.ts +0 -6
- package/templates/shell-react/src/app/actions/surfaces/welcome.action.ts +0 -10
- package/templates/shell-react/src/app/shell/frame.layout.ts +0 -3
- package/templates/shell-react/src/app/shell/shell.ts +0 -7
- package/templates/shell-react/src/boot.ts +0 -13
- package/templates/shell-react/src/dev/all-checks.ts +0 -17
- package/templates/shell-react/src/dev/artifacts-check.ts +0 -45
- package/templates/shell-react/src/dev/strata.ts +0 -21
- package/templates/shell-react/src/dev/welcome-check.ts +0 -21
- package/templates/shell-react/src/ui/kit.css +0 -42
- package/templates/shell-react/src/ui/kit.tsx +0 -39
- package/templates/shell-react/src/ui/registry.ts +0 -12
- package/templates/shell-react/strata.lock.json +0 -6
- package/templates/shell-react/tsconfig.json +0 -28
- package/templates/shell-react/vite.config.ts +0 -8
- /package/templates/{moss-dom → base/files}/strata.lock.json +0 -0
- /package/templates/{moss-dom → classic/files}/src/app/action-catalog.ts +0 -0
- /package/templates/{moss-dom → classic/files}/src/app/shell/frame.layout.ts +0 -0
- /package/templates/{moss-dom → classic/files}/src/dev/strata.ts +0 -0
- /package/templates/{moss-react → classic/with/moss}/src/app/actions/surfaces/welcome.layout.ts +0 -0
- /package/templates/{moss-dom → classic/with/moss}/src/app/app.ts +0 -0
- /package/templates/{moss-dom → classic/with/moss}/src/app/charter/assignments.ts +0 -0
- /package/templates/{moss-dom → classic/with/moss}/src/app/charter/charter.ts +0 -0
- /package/templates/{moss-dom → classic/with/moss}/src/app/shell/shell.ts +0 -0
- /package/templates/{moss-dom → classic/with/moss}/src/dev/all-checks.ts +0 -0
- /package/templates/{moss-dom → classic/with/moss}/src/dev/artifacts-check.ts +0 -0
- /package/templates/{moss-dom → classic/with/moss}/src/dev/welcome-check.ts +0 -0
- /package/templates/{moss-dom → classic/with/moss}/src/server/boot.ts +0 -0
- /package/templates/{shell-react → classic/with/page}/src/app/actions/surfaces/welcome.layout.ts +0 -0
- /package/templates/{shell-dom → classic/with/page}/src/app/shell/shell.ts +0 -0
- /package/templates/{shell-dom → classic/with/page}/src/boot.ts +0 -0
- /package/templates/{shell-dom → classic/with/page}/src/dev/all-checks.ts +0 -0
- /package/templates/{shell-dom → classic/with/page}/src/dev/artifacts-check.ts +0 -0
- /package/templates/{shell-dom → classic/with/page}/src/dev/welcome-check.ts +0 -0
- /package/templates/{moss-dom → dom/files}/vite.config.ts +0 -0
- /package/templates/{moss-dom → dom/with/moss}/src/main.ts +0 -0
- /package/templates/{moss-dom → dom/with/moss}/src/server/document.ts +0 -0
- /package/templates/{shell-dom → dom/with/page}/nisc.config.ts +0 -0
- /package/templates/{shell-dom → dom/with/page}/src/main.ts +0 -0
- /package/templates/{shell-dom → dom/with/page}/src/ui/screen.ts +0 -0
- /package/templates/{moss-dom → moss/files}/nisc.config.ts +0 -0
- /package/templates/{moss-dom → moss/files}/src/server/runtime.ts +0 -0
- /package/templates/{moss-react → react/files}/tsconfig.json +0 -0
- /package/templates/{moss-react → react/files}/vite.config.ts +0 -0
- /package/templates/{moss-react → react/with/moss}/src/main.tsx +0 -0
- /package/templates/{moss-react → react/with/moss}/src/server/document.ts +0 -0
- /package/templates/{shell-react → react/with/page}/nisc.config.ts +0 -0
- /package/templates/{shell-react → react/with/page}/src/main.tsx +0 -0
- /package/templates/{shell-react → react/with/page}/src/ui/screen.tsx +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { DomComponent } from '@niscorp/nova/adapters/dom';
|
|
3
|
+
|
|
4
|
+
// nova's DOM adapter wires the clicks of an element with a `ref` (its `value` the payload), and the input and keys of
|
|
5
|
+
// one with a `model`, itself.
|
|
6
|
+
|
|
7
|
+
// A value a component does not take falls back to its default on its own; the others still hold.
|
|
8
|
+
const parsed = <S extends z.ZodRawShape>(schema: z.ZodObject<S>, props: Record<string, unknown>, fallback: z.output<z.ZodObject<S>>): z.output<z.ZodObject<S>> => {
|
|
9
|
+
const taken = Object.fromEntries(
|
|
10
|
+
Object.entries(props).filter(([key, value]) => {
|
|
11
|
+
const field = schema.shape[key];
|
|
12
|
+
return field !== undefined && z.safeParse(field, value).success;
|
|
13
|
+
}),
|
|
14
|
+
);
|
|
15
|
+
const result = schema.safeParse({ ...fallback, ...taken });
|
|
16
|
+
return result.success ? result.data : fallback;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const cell = (value: unknown): string => (value === null || value === undefined ? '' : typeof value === 'object' ? JSON.stringify(value) : String(value));
|
|
20
|
+
|
|
21
|
+
const element = (tag: string, className: string, children: Node[]): HTMLElement => {
|
|
22
|
+
const el = document.createElement(tag);
|
|
23
|
+
if (className !== '') el.className = className;
|
|
24
|
+
el.append(...children);
|
|
25
|
+
return el;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const text = (value: unknown): Text => document.createTextNode(cell(value));
|
|
29
|
+
|
|
30
|
+
const toned = (base: string, tone: string | undefined, plain: string): string => (tone === undefined || tone === plain ? base : `${base} k-${tone}`);
|
|
31
|
+
|
|
32
|
+
export const Page: DomComponent = ({ children }) => element('main', 'k-page', children);
|
|
33
|
+
export const Row: DomComponent = ({ children }) => element('div', 'k-row', children);
|
|
34
|
+
export const Heading: DomComponent = ({ children }) => element('h1', 'k-heading', children);
|
|
35
|
+
|
|
36
|
+
const TextProps = z.object({ tone: z.enum(['default', 'lead', 'muted', 'strong', 'display', 'right', 'wrong', 'error']).optional() });
|
|
37
|
+
export const Text: DomComponent = ({ props, children }) => element('p', toned('k-text', parsed(TextProps, props, {}).tone, 'default'), children);
|
|
38
|
+
|
|
39
|
+
const ButtonProps = z.object({ label: z.string().optional(), tone: z.enum(['primary', 'suggestion', 'link', 'choice', 'chosen', 'right', 'wrong', 'summary', 'step']).optional() });
|
|
40
|
+
export const Button: DomComponent = ({ props, children }) => {
|
|
41
|
+
const { label, tone } = parsed(ButtonProps, props, {});
|
|
42
|
+
const button = element('button', toned('k-button', tone, 'primary'), label !== undefined ? [text(label)] : children);
|
|
43
|
+
button.setAttribute('type', 'button');
|
|
44
|
+
return button;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const Frame: DomComponent = ({ children }) => element('div', 'k-frame', children);
|
|
48
|
+
export const Dock: DomComponent = ({ children }) => element('footer', 'k-dock', children);
|
|
49
|
+
export const Menu: DomComponent = ({ children }) => element('nav', 'k-menu', children);
|
|
50
|
+
|
|
51
|
+
const GridProps = z.object({ columns: z.number().int().min(1).max(3).optional() });
|
|
52
|
+
export const Grid: DomComponent = ({ props, children }) => element('main', `k-grid k-columns-${parsed(GridProps, props, {}).columns ?? 2}`, children);
|
|
53
|
+
|
|
54
|
+
const AreaProps = z.object({ name: z.string(), span: z.number().int().min(1).max(3).optional(), changed: z.boolean().optional() });
|
|
55
|
+
export const Area: DomComponent = ({ props, children }) => {
|
|
56
|
+
const { span, changed } = parsed(AreaProps, props, { name: '' });
|
|
57
|
+
return element('section', `k-area k-span-${span ?? 1}${changed === true ? ' k-area-changed' : ''}`, children);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const CardProps = z.object({ title: z.string().optional(), tone: z.enum(['default', 'hero']).optional() });
|
|
61
|
+
export const Card: DomComponent = ({ props, children }) => {
|
|
62
|
+
const { title, tone } = parsed(CardProps, props, {});
|
|
63
|
+
return element('article', toned('k-card', tone, 'default'), [...(title !== undefined && title !== '' ? [element('h2', 'k-card-title', [text(title)])] : []), ...children]);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const CodeProps = z.object({ text: z.string() });
|
|
67
|
+
export const Code: DomComponent = ({ props }) => element('pre', 'k-code', [element('code', '', [text(parsed(CodeProps, props, { text: '' }).text)])]);
|
|
68
|
+
|
|
69
|
+
const PointsProps = z.object({ items: z.array(z.object({ title: z.string(), text: z.string() })) });
|
|
70
|
+
export const Points: DomComponent = ({ props }) =>
|
|
71
|
+
element(
|
|
72
|
+
'dl',
|
|
73
|
+
'k-points',
|
|
74
|
+
parsed(PointsProps, props, { items: [] }).items.map((item) => element('div', 'k-point', [element('dt', '', [text(item.title)]), element('dd', '', [text(item.text)])])),
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const StepsProps = z.object({ items: z.array(z.string()) });
|
|
78
|
+
export const Steps: DomComponent = ({ props }) => element('ol', 'k-steps', parsed(StepsProps, props, { items: [] }).items.map((item) => element('li', '', [text(item)])));
|
|
79
|
+
|
|
80
|
+
const CheckProps = z.object({ label: z.string(), checked: z.boolean().optional() });
|
|
81
|
+
export const Check: DomComponent = ({ props }) => {
|
|
82
|
+
const { label, checked } = parsed(CheckProps, props, { label: '' });
|
|
83
|
+
const box = element('span', 'k-box', []);
|
|
84
|
+
box.setAttribute('aria-hidden', 'true');
|
|
85
|
+
const check = element('button', checked === true ? 'k-check k-checked' : 'k-check', [box, element('span', 'k-check-label', [text(label)])]);
|
|
86
|
+
check.setAttribute('type', 'button');
|
|
87
|
+
check.setAttribute('role', 'checkbox');
|
|
88
|
+
check.setAttribute('aria-checked', String(checked === true));
|
|
89
|
+
return check;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const InputProps = z.object({ placeholder: z.string().optional(), value: z.unknown().optional(), clearOnEnter: z.boolean().optional() });
|
|
93
|
+
// The one listener a component here adds: a line something is sent from empties itself on Enter. What was typed has
|
|
94
|
+
// already reached the shell, one `ui:model` a keystroke.
|
|
95
|
+
export const Input: DomComponent = ({ props }) => {
|
|
96
|
+
const { placeholder, value, clearOnEnter } = parsed(InputProps, props, {});
|
|
97
|
+
const input = document.createElement('input');
|
|
98
|
+
input.className = 'k-input';
|
|
99
|
+
if (placeholder !== undefined) input.placeholder = placeholder;
|
|
100
|
+
input.value = cell(value);
|
|
101
|
+
if (clearOnEnter === true) {
|
|
102
|
+
input.addEventListener('keydown', (event) => {
|
|
103
|
+
if (event.key === 'Enter') input.value = '';
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return input;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const Prompt: DomComponent = ({ children }) => element('div', 'k-prompt', children);
|
|
@@ -2,7 +2,7 @@ import { createComponentRegistry, ACTION_SLOT_NAME, CANVAS_SLOT_NAME } from '@ni
|
|
|
2
2
|
import type { ComponentRegistry } from '@niscorp/nova';
|
|
3
3
|
import type { DomComponent } from '@niscorp/nova/adapters/dom';
|
|
4
4
|
import { fallback } from '@niscorp/nova/adapters/dom/components';
|
|
5
|
-
import { Button, Heading, Page, Row, Text } from './kit';
|
|
5
|
+
import { Area, Button, Card, Check, Code, Dock, Frame, Grid, Heading, Input, Menu, Page, Points, Prompt, Row, Steps, Text } from './kit';
|
|
6
6
|
|
|
7
7
|
// The adapter resolves a canvas slot itself, and an action slot is a plain
|
|
8
8
|
// wrapper: `fallback` does for both.
|
|
@@ -10,6 +10,6 @@ export const buildRegistry = (): ComponentRegistry<DomComponent> => {
|
|
|
10
10
|
const registry = createComponentRegistry<DomComponent>();
|
|
11
11
|
registry.register(CANVAS_SLOT_NAME, fallback);
|
|
12
12
|
registry.register(ACTION_SLOT_NAME, fallback);
|
|
13
|
-
registry.registerAll({ Page, Row, Heading, Text, Button });
|
|
13
|
+
registry.registerAll({ Page, Row, Heading, Text, Button, Frame, Dock, Menu, Grid, Area, Card, Code, Points, Steps, Check, Input, Prompt });
|
|
14
14
|
return registry;
|
|
15
15
|
};
|
|
@@ -3,25 +3,14 @@
|
|
|
3
3
|
"target": "ES2022",
|
|
4
4
|
"module": "ESNext",
|
|
5
5
|
"moduleResolution": "Bundler",
|
|
6
|
-
"lib": [
|
|
7
|
-
"DOM",
|
|
8
|
-
"DOM.Iterable",
|
|
9
|
-
"ES2022"
|
|
10
|
-
],
|
|
6
|
+
"lib": ["DOM", "DOM.Iterable", "ES2022"],
|
|
11
7
|
"strict": true,
|
|
12
8
|
"noUncheckedIndexedAccess": true,
|
|
13
9
|
"verbatimModuleSyntax": true,
|
|
14
10
|
"isolatedModules": true,
|
|
15
11
|
"skipLibCheck": true,
|
|
16
12
|
"noEmit": true,
|
|
17
|
-
"types": [
|
|
18
|
-
"node",
|
|
19
|
-
"vite/client"
|
|
20
|
-
]
|
|
13
|
+
"types": ["node", "vite/client"]
|
|
21
14
|
},
|
|
22
|
-
"include": [
|
|
23
|
-
"src",
|
|
24
|
-
"nisc.config.ts",
|
|
25
|
-
"vite.config.ts"
|
|
26
|
-
]
|
|
15
|
+
"include": ["src", "nisc.config.ts", "vite.config.ts"]
|
|
27
16
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "dom",
|
|
3
|
+
"answers": "kit",
|
|
4
|
+
"label": "Plain DOM",
|
|
5
|
+
"hint": "no framework in the page",
|
|
6
|
+
"usage": "plain DOM draws the screen, no framework in the page",
|
|
7
|
+
"summary": "plain DOM",
|
|
8
|
+
"docs": {
|
|
9
|
+
"is": "drawn with plain DOM (nova’s DOM adapter — no framework in the page)",
|
|
10
|
+
"answered": ["**What draws the screen:** plain DOM (nova’s DOM adapter — no framework in the page). The kit in `src/ui/` is where the look lives; a layout names components, never styles."]
|
|
11
|
+
},
|
|
12
|
+
"with": {
|
|
13
|
+
"moss": {
|
|
14
|
+
"package": {
|
|
15
|
+
"dependencies": { "jsdom": "^25.0.1" },
|
|
16
|
+
"devDependencies": { "@types/jsdom": "^30.0.0" }
|
|
17
|
+
},
|
|
18
|
+
"docs": { "where": ["src/ui/ the kit — the only renderer code, with src/main.ts, the terminal entry"] }
|
|
19
|
+
},
|
|
20
|
+
"page": {
|
|
21
|
+
"docs": { "where": ["src/ui/ the kit and the screen — the only renderer code, with src/main.ts, the entry"] }
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
## How the model leads
|
|
2
|
+
|
|
3
|
+
There is no chat history: the screen open when a message arrives is the conversation. The answer fills the page and scrolls; one dock stays at the bottom (`src/app/actions/ask/dock.action.ts`). Read from the screen down to the hands, it holds the **screens** (`src/app/screens.ts`: canvases shown together, opened without asking, as a card's link opens one); a chip naming the answer shown by its title and where it stands ("The charter · 2/5"), with back and forward beside it, which opens upward to what was asked, what the model said it did, and every answer to go back to, each by its title; and the line to ask in. A person types there, and the answer is a screen: up to six canvases — an action opened with an input, and why it is there — on the areas `a`–`f`. The canvas an answer changed is outlined until the next one. The first screen is what the app opens on, and the first in the stack. A screen already in the stack is gone back to, not stacked again.
|
|
4
|
+
|
|
5
|
+
- **The message loop is `src/server/compose/`**, the function `ask`:
|
|
6
|
+
1. **The open screen is read** (`screen.ts`), area by area, the words too: each canvas's action and intent; its input as it stands, with what the person pressed, ticked or picked in what the input carries; and what else its live data holds beyond what it was opened with — a list as its count and its first three rows, ids left out; a line being typed. Before anything else is shown — an answer, a screen, back or forward — the screen as it stands is kept with the answer it is on, as a browser keeps a page's form: going back shows it as the person left it.
|
|
7
|
+
2. **Jev's pass** (`pick.ts`): over the message and the open screen, how likely each action, read, write and screen of the catalog belongs in the answer, in about 200 ms (what it was measured to be worth is PLAN.md D6). Only a hint: the model decides, and only what the pass finds likely (0.5 or more) is shown to it. Whether a canvas is still wanted is the model's to say (PLAN.md D11).
|
|
8
|
+
3. **gpt-oss-120b composes, as a cortex agent** (`composer.agent.ts`, `knowledge.ts`, `reply.schema.ts`, `answer.ts`). Its producers give it the catalog — each action the person holds that the model may place, with its input's JSON Schema, each read with the rows it answers and the values it is asked with, each write, the screens, the arrangements with where each puts its areas — and cortex's OUTPUT SCHEMA, the envelope with the reply's own JSON Schema in it, in the part of the prompt that never changes; the run's input is the open screen, Jev's picks as a hint, and the message. What each field of the reply means is said on the schema (`.describe()`), never in prose beside it (nisc rule 15). It answers with cortex's envelope: its `reasoning` first, then its `response` — one sentence for the person, at most 120 characters, saying what it changes and why, or why nothing changes, shown when the dock's chip is opened — then its `data`, the reply: its `title` — what the answer is, in at most four words, the name the chip and the stack give it — then **the areas that change** (PLAN.md D10): each a canvas moved there from another area (`keep`), a canvas, words (`say`, only where no action shows what was asked), or nothing (`drop`); an area it leaves out stays as it is, unless the arrangement it gives has no such area — and then the room, when the one on screen will not do: an arrangement, or a grid of its own. Or it replies with one of the app's screens as it is (`screen`). The reply is checked whole — every action in the catalog, every input against its action's schema, every read and write one the app ships, every value a read is asked with present and none it does not take, every field a write saves present, every area in the arrangement, nothing kept from an empty area, nothing shown twice — by the agent's `output.validate`, and one that does not hold, or does not fit the schema, is corrected inside the same run with what is wrong with it: three answers at most (cortex's `outputRetries`). About 1 s.
|
|
9
|
+
4. **The answer is laid out,** in the arrangement on screen unless the model gives another (`src/app/arrangements.ts`), or a grid it writes (`grid`: how many columns, and the areas in the order they are drawn, each with its span), which the server turns into the layout. The server swaps it into the region — around moss, through `@niscorp/moss/unverified`, until the app has sign-in; then through `session.draft`.
|
|
10
|
+
5. **The plan is placed by the dock,** with nova's `reconcile`: each area holds exactly what the plan lists for it. A canvas that stays keeps its instance and what the person did to it; a card the model writes again is written where it stands. A canvas written onto a screen holds its whole input — what it leaves out is its action's default (`opened`, in `catalog.ts`) — so a card written where another was keeps nothing of it (PLAN.md D12). An answer that changes nothing adds nothing to the stack; the chip still names what was asked and opens to what the model said. A screen opened, or back or forward pressed, while an answer streams in is what is shown: that answer is no longer placed.
|
|
11
|
+
6. **The answer streams in.** Cortex hands the composer the reply as solid parses it, while the model writes it. Once an area's entry is followed by the next, or by the room, it is finished, and it is placed in the room on screen if its own checks pass; another room, or a screen, comes with the whole reply; the dock re-reads the answer so far (`answers.current`) whenever the message `answer-moved` says it moved. Whether the whole reply holds is checked when it ends. A correction, or a run that ends without an answer, puts the screen back as it was.
|
|
12
|
+
- **A message that gets no screen leaves the screen as it is,** and the line says why: the model's reply did not fit, it could not be reached, or there is no key.
|
|
13
|
+
- **Jev may take 2 s and the model 8 s.** A Jev pass given up leaves the model to answer alone.
|
|
14
|
+
- **Every message is recorded as a run for each model it went to,** through moss (`session.recordRun`): `nisc-template-app.jev` and `nisc-template-app.compose`, each with its provider and model, the tokens it spent (`reported: false` where signal estimated them), its steps and how long it took — for the composer, cortex's run meta — and whether it ended in an answer. The server logs a line for each (`src/server/runs/`).
|
|
15
|
+
- **The app starts as a tour of nisc** (`src/app/actions/guide/`): five screens in the dock — a start, three lessons, and how to make it yours. Cards to read — points, an example in code, or steps, the text in the action's own data, no input — and cards to use: a counter, a checklist and a quick check, each with an input the model can fill. A card's link opens another screen at once, as the dock's buttons do; only what is typed, or a thing to ask pressed, goes to the model. What a person presses, ticks and picks stays on the screen; the model sees it, and can change it: "tick off the first step", "a counter that starts at 100", "quiz me on the charter". Its check is `src/dev/guide-check.ts`.
|
|
16
|
+
- **An action you add is small, with one purpose:** it says what it shows (`description`), and declares what the model may open it with as a JSON Schema written with zod, every field described; the model's answers are checked against that same schema (`z.fromJSONSchema`). A read or a write it names must be one the app ships, asked with the values it takes. The ones the model may place are `placeable`, in `src/app/action-catalog.ts`.
|
|
17
|
+
- **The model never presses anything.** It opens cards with an input — a checklist with a step ticked, a form filled in — and only the person saves.
|
|
18
|
+
- **The keys are in `.env`:** `GROQ_API_KEY` (gpt-oss-120b; without it, a message is answered with a notice saying so), and `TYPESAFE_API_KEY` (Jev; without it there is no Jev pass).
|
|
19
|
+
- **`src/dev/compose-check.ts` runs the loop offline**, with a scripted Jev and a scripted model (`src/dev/scripted.ts`), on words, screens and actions the app does not have — so it holds whatever actions the app ships. **`src/dev/live-ask.ts` asks the real models** its cases (`RUN`), each from the screen it was asked on, and counts the screens that are what the case wants, with nothing shown twice (`--runs=<n>`, `--why`, `--prompts` for everything the models were sent, `--no-jev`, or messages of your own, each after `--screen=<id>` to ask it from that screen). It costs a Jev pass and a chat call a message, and is not part of `npm run check`.
|
|
20
|
+
|
|
21
|
+
## How to proceed from here
|
|
22
|
+
|
|
23
|
+
The tour is a starting point, there to be deleted. First the interview: PLAN.md's open items, each answered or delegated by name (the rulebook's "Before any code").
|
|
24
|
+
|
|
25
|
+
**Remove the tour.** It lives in two places and is named in five:
|
|
26
|
+
|
|
27
|
+
1. Delete `src/app/actions/guide/` and `src/dev/guide-check.ts`.
|
|
28
|
+
2. `src/app/action-catalog.ts`: drop the `GUIDE` import; `placeable` is `[]` until your own actions are in it.
|
|
29
|
+
3. `src/app/charter/charter.ts`: drop `'guide.*'`.
|
|
30
|
+
4. `src/dev/all-checks.ts`: drop the `guide-check` line.
|
|
31
|
+
5. `src/app/screens.ts`: everything below its two types — your screens instead of the tour's. Until there are actions, one screen of words will do:
|
|
32
|
+
```ts
|
|
33
|
+
export const SCREENS: readonly [Screen, ...Screen[]] = [
|
|
34
|
+
{ id: 'start', label: 'Start', description: 'What this app is.', arrangement: 'single', canvases: [{ action: 'answer.text', input: { title: 'The app', text: 'What it is, in a sentence.' }, intent: 'what this app is' }] },
|
|
35
|
+
];
|
|
36
|
+
```
|
|
37
|
+
6. `src/dev/live-ask.ts`: your cases in `RUN` instead of the tour's, and its `tour` helper.
|
|
38
|
+
7. This file: the tour's rows under "Where things go", its paragraph above, and this list; PLAN.md: the tour in D3 and in the order of work. `npm run check` passes again.
|
|
39
|
+
|
|
40
|
+
What stays is the app: the message loop, the dock, the arrangements, the kit, and `compose-check`, which needs nothing of the tour.
|
|
41
|
+
|
|
42
|
+
**Then build in PLAN.md's order of work,** each step checked before the next: your tables, reads and writes; your actions, each placeable one in `placeable` and every one granted in the charter's `actions`; your screens; a check for each feature in `src/dev/`; and `live-ask` cases for what people will ask.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ActionDefinition } from '@niscorp/nova';
|
|
2
|
+
import { textAction } from './actions/answer/text.action';
|
|
3
|
+
import { dockAction } from './actions/ask/dock.action';
|
|
4
|
+
import { GUIDE } from './actions/guide/guide.actions';
|
|
5
|
+
|
|
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.
|
|
8
|
+
export const placeable: readonly ActionDefinition[] = GUIDE;
|
|
9
|
+
|
|
10
|
+
export const actions: Record<string, ActionDefinition> = Object.fromEntries([dockAction, textAction, ...placeable].map((action) => [action.id, action]));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ActionDefinition } from '@niscorp/nova';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { textLayout } from './text.layout';
|
|
4
|
+
|
|
5
|
+
export const textAction: ActionDefinition = {
|
|
6
|
+
id: 'answer.text',
|
|
7
|
+
title: 'Text',
|
|
8
|
+
description: 'A few words: a title, and at most two short sentences.',
|
|
9
|
+
data: { title: '', text: '' },
|
|
10
|
+
input: z.toJSONSchema(
|
|
11
|
+
z.object({
|
|
12
|
+
title: z.string().describe('A few words.'),
|
|
13
|
+
text: z.string().describe('At most two short sentences.'),
|
|
14
|
+
}),
|
|
15
|
+
),
|
|
16
|
+
layout: textLayout,
|
|
17
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ActionDefinition, Step } from '@niscorp/nova';
|
|
2
|
+
import { SCREENS } from '../../screens';
|
|
3
|
+
import { AREAS } from '../../shell/areas';
|
|
4
|
+
import { dockLayout } from './dock.layout';
|
|
5
|
+
|
|
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 } }))];
|
|
7
|
+
|
|
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;
|
|
21
|
+
|
|
22
|
+
export const dockAction: ActionDefinition = {
|
|
23
|
+
id: 'ask.dock',
|
|
24
|
+
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.',
|
|
27
|
+
data: {
|
|
28
|
+
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,
|
|
31
|
+
opening: '',
|
|
32
|
+
going: 0,
|
|
33
|
+
text: '',
|
|
34
|
+
asking: false,
|
|
35
|
+
error: '',
|
|
36
|
+
},
|
|
37
|
+
layout: dockLayout,
|
|
38
|
+
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' },
|
|
45
|
+
},
|
|
46
|
+
triggers: [
|
|
47
|
+
{ message: 'answer-moved', do: [{ call: 'current', onSuccess: shown }] },
|
|
48
|
+
{ message: 'ask', do: [{ set: 'text', value: '@event.payload' }, ...ask] },
|
|
49
|
+
{ message: 'open', do: open },
|
|
50
|
+
{ event: 'ui:key', key: 'Enter', ref: 'text', do: ask },
|
|
51
|
+
{ event: 'ui:click', ref: 'send', do: ask },
|
|
52
|
+
{ 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
|
+
],
|
|
58
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { LayoutNode } from '@niscorp/nova';
|
|
2
|
+
|
|
3
|
+
export const dockLayout: LayoutNode = {
|
|
4
|
+
component: 'Dock',
|
|
5
|
+
children: [
|
|
6
|
+
{
|
|
7
|
+
component: 'Row',
|
|
8
|
+
children: [
|
|
9
|
+
{
|
|
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
|
+
],
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
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
|
+
{
|
|
51
|
+
component: 'Prompt',
|
|
52
|
+
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' } } },
|
|
55
|
+
{ if: '$.error', then: { component: 'Text', props: { tone: 'error' }, children: '{{$.error}}' } },
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ActionDefinition } from '@niscorp/nova';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { checklistLayout } from './checklist.layout';
|
|
4
|
+
|
|
5
|
+
// A tick moves a step from one list to the other, so each press is a push and a removal, and no step needs an id.
|
|
6
|
+
export const checklistAction: ActionDefinition = {
|
|
7
|
+
id: 'guide.checklist',
|
|
8
|
+
title: 'Checklist',
|
|
9
|
+
description: 'A checklist a person ticks off and adds steps to: the steps to do, in order, and the ones done.',
|
|
10
|
+
data: { title: '', todo: [], done: [], adding: '' },
|
|
11
|
+
input: z.toJSONSchema(
|
|
12
|
+
z.object({
|
|
13
|
+
title: z.string().describe('What the steps are for, in a few words.'),
|
|
14
|
+
todo: z.array(z.string()).min(1).describe('The steps still to do, in order, each a few words.'),
|
|
15
|
+
done: z.array(z.string()).nullish().describe('The steps already done.'),
|
|
16
|
+
}),
|
|
17
|
+
),
|
|
18
|
+
layout: checklistLayout,
|
|
19
|
+
triggers: [
|
|
20
|
+
{ event: 'ui:click', ref: 'tick', do: [{ push: 'done', value: { $at: ['$.todo', '@event.payload'] } }, { removeAt: 'todo', index: '{{@event.payload}}' }] },
|
|
21
|
+
{ event: 'ui:click', ref: 'untick', do: [{ push: 'todo', value: { $at: ['$.done', '@event.payload'] } }, { removeAt: 'done', index: '{{@event.payload}}' }] },
|
|
22
|
+
{ event: 'ui:click', ref: 'add', do: [{ push: 'todo', value: '$.adding' }, { set: 'adding', value: '' }] },
|
|
23
|
+
],
|
|
24
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { LayoutNode } from '@niscorp/nova';
|
|
2
|
+
|
|
3
|
+
export const checklistLayout: LayoutNode = {
|
|
4
|
+
component: 'Card',
|
|
5
|
+
props: { title: '{{$.title}}' },
|
|
6
|
+
children: [
|
|
7
|
+
{ for: '$.todo', as: 'item', do: { component: 'Check', ref: 'tick', props: { label: '$item', checked: false, value: '$index' } } },
|
|
8
|
+
{ for: '$.done', as: 'item', do: { component: 'Check', ref: 'untick', props: { label: '$item', checked: true, value: '$index' } } },
|
|
9
|
+
{
|
|
10
|
+
component: 'Row',
|
|
11
|
+
children: [
|
|
12
|
+
{ component: 'Input', ref: 'adding', model: '$.adding', props: { placeholder: 'Add a step' } },
|
|
13
|
+
{ if: '$.adding', then: { component: 'Button', ref: 'add', props: { label: 'Add' } } },
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ActionDefinition } from '@niscorp/nova';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { counterLayout } from './counter.layout';
|
|
4
|
+
|
|
5
|
+
export const counterAction: ActionDefinition = {
|
|
6
|
+
id: 'guide.counter',
|
|
7
|
+
title: 'Counter',
|
|
8
|
+
description: 'A counter a person presses: a number, buttons that count it up and down, and one that sets it back to zero. Shows that a card is data, and a press a change to it.',
|
|
9
|
+
data: { title: 'Press me', count: 0 },
|
|
10
|
+
input: z.toJSONSchema(
|
|
11
|
+
z.object({
|
|
12
|
+
title: z.string().nullish().describe('What it counts, in a few words.'),
|
|
13
|
+
count: z.number().int().nullish().describe('The number it shows.'),
|
|
14
|
+
}),
|
|
15
|
+
),
|
|
16
|
+
layout: counterLayout,
|
|
17
|
+
triggers: [
|
|
18
|
+
{ event: 'ui:click', ref: 'up', do: [{ increment: 'count' }] },
|
|
19
|
+
{ event: 'ui:click', ref: 'down', do: [{ decrement: 'count' }] },
|
|
20
|
+
{ event: 'ui:click', ref: 'reset', do: [{ set: 'count', value: 0 }] },
|
|
21
|
+
],
|
|
22
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { LayoutNode } from '@niscorp/nova';
|
|
2
|
+
|
|
3
|
+
export const counterLayout: LayoutNode = {
|
|
4
|
+
component: 'Card',
|
|
5
|
+
props: { title: '{{$.title}}' },
|
|
6
|
+
children: [
|
|
7
|
+
{ component: 'Text', props: { tone: 'display' }, children: '{{$.count}}' },
|
|
8
|
+
{
|
|
9
|
+
component: 'Row',
|
|
10
|
+
children: [
|
|
11
|
+
{ component: 'Button', ref: 'down', props: { label: '−' } },
|
|
12
|
+
{ component: 'Button', ref: 'up', props: { label: '+' } },
|
|
13
|
+
{ component: 'Button', ref: 'reset', props: { label: 'Reset', tone: 'step' } },
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
{ component: 'Code', props: { text: '{ "count": {{$.count}} }' } },
|
|
17
|
+
{ component: 'Text', props: { tone: 'muted' }, children: 'The number is this card’s data; each press changes it.' },
|
|
18
|
+
],
|
|
19
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { ActionDefinition, LayoutNode, TriggerConfig } from '@niscorp/nova';
|
|
2
|
+
import { checklistAction } from './checklist.action';
|
|
3
|
+
import { counterAction } from './counter.action';
|
|
4
|
+
import { askLayout, exampleLayout, pointsLayout, stepsLayout, welcomeLayout } from './guide.layouts';
|
|
5
|
+
import { quizAction } from './quiz.action';
|
|
6
|
+
|
|
7
|
+
type Link = { label: string; screen: string };
|
|
8
|
+
|
|
9
|
+
// A link opens one of the app's screens, as the dock's own buttons do; nothing is asked of the model.
|
|
10
|
+
const opens: TriggerConfig = { event: 'ui:click', ref: 'link', do: [{ emit: { channel: 'open', payload: '@event.payload' } }] };
|
|
11
|
+
const asks: TriggerConfig = { event: 'ui:click', ref: 'example', do: [{ emit: { channel: 'ask', payload: '@event.payload' } }] };
|
|
12
|
+
|
|
13
|
+
const card = (id: string, description: string, layout: LayoutNode, data: { title: string; lead: string; links?: Link[] } & Record<string, unknown>, triggers = [opens]): ActionDefinition => ({
|
|
14
|
+
id,
|
|
15
|
+
title: data.title,
|
|
16
|
+
description,
|
|
17
|
+
data: { links: [], ...data },
|
|
18
|
+
layout,
|
|
19
|
+
triggers,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const GUIDE: readonly ActionDefinition[] = [
|
|
23
|
+
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, {
|
|
24
|
+
title: 'Welcome to nisc',
|
|
25
|
+
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
|
+
links: [{ label: 'Start the tour →', screen: 'actions' }],
|
|
27
|
+
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
|
+
}, [opens, asks]),
|
|
29
|
+
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, {
|
|
30
|
+
title: 'What nisc is',
|
|
31
|
+
lead: 'nisc builds apps out of data, so a model can build them with you.',
|
|
32
|
+
points: [
|
|
33
|
+
{ title: 'Everything is data', text: 'Screens, reads, writes and rules are JSON, each with a schema.' },
|
|
34
|
+
{ title: 'Code at the edges', text: 'The kit draws and the server serves; the rest is data, checked.' },
|
|
35
|
+
{ title: 'Led by a model', text: 'Ask, and this app answers with a screen of its own cards.' },
|
|
36
|
+
],
|
|
37
|
+
links: [{ label: 'Lesson 1: actions →', screen: 'actions' }],
|
|
38
|
+
}),
|
|
39
|
+
card('guide.actions', 'Actions: everything on screen is an action — JSON with its data, its layout, and its triggers, what a press does to the data; the counter’s as the example.', exampleLayout, {
|
|
40
|
+
title: 'Actions',
|
|
41
|
+
lead: 'Everything you see is an action: JSON with its data, its layout, and what a press does.',
|
|
42
|
+
example: [
|
|
43
|
+
'{',
|
|
44
|
+
' "id": "guide.counter",',
|
|
45
|
+
' "data": { "title": "Press me", "count": 0 },',
|
|
46
|
+
' "triggers": [',
|
|
47
|
+
' { "event": "ui:click", "ref": "up", "do": [{ "increment": "count" }] },',
|
|
48
|
+
' { "event": "ui:click", "ref": "down", "do": [{ "decrement": "count" }] },',
|
|
49
|
+
' { "event": "ui:click", "ref": "reset", "do": [{ "set": "count", "value": 0 }] }',
|
|
50
|
+
' ],',
|
|
51
|
+
' "layout": { "component": "Card", "children": [ … ] }',
|
|
52
|
+
'}',
|
|
53
|
+
].join('\n'),
|
|
54
|
+
text: 'That is the counter on this screen. Actions live in src/app/actions/.',
|
|
55
|
+
links: [{ label: 'Next: asking for a screen →', screen: 'asking' }],
|
|
56
|
+
}),
|
|
57
|
+
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, {
|
|
58
|
+
title: 'Layouts and the kit',
|
|
59
|
+
lead: 'A layout is JSON that names components and binds them to the action’s data. It never styles anything.',
|
|
60
|
+
example: ['{', ' "component": "Card",', ' "props": { "title": "{{$.title}}" },', ' "children": [', ' { "component": "Text", "children": "{{$.count}}" }', ' ]', '}'].join('\n'),
|
|
61
|
+
text: 'The kit in src/ui/ is the only code that draws, and its stylesheet the only place the look lives.',
|
|
62
|
+
}),
|
|
63
|
+
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, {
|
|
64
|
+
title: 'How your message becomes a screen',
|
|
65
|
+
lead: 'What happens between your question and the screen it gets.',
|
|
66
|
+
steps: [
|
|
67
|
+
'The dock sends your message to the server.',
|
|
68
|
+
'Jev, a fast decision model, reads it with the screen and says which cards likely belong.',
|
|
69
|
+
'gpt-oss, as a cortex agent, writes which areas change, with which cards, filled in.',
|
|
70
|
+
'The answer is checked against the cards the app has; one that does not hold is corrected.',
|
|
71
|
+
'The screen fills in while the answer is still being written.',
|
|
72
|
+
],
|
|
73
|
+
links: [{ label: 'Next: who may do what →', screen: 'rules' }],
|
|
74
|
+
}),
|
|
75
|
+
card(
|
|
76
|
+
'guide.ask',
|
|
77
|
+
'Things to ask the model, each asked when pressed: a checklist written for you, a quick check, cards moved or left alone.',
|
|
78
|
+
askLayout,
|
|
79
|
+
{
|
|
80
|
+
title: 'Ask for a screen',
|
|
81
|
+
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.',
|
|
82
|
+
examples: ['A checklist for adding a table', 'Quiz me on the shell', 'Put the counter beside the steps', 'Only the steps, please'],
|
|
83
|
+
},
|
|
84
|
+
[asks],
|
|
85
|
+
),
|
|
86
|
+
card('guide.shell', 'The shell and moss: moss keeps one shell per person, on the server, which holds the cards and runs what they do; the browser only draws the frames moss sends over a socket.', pointsLayout, {
|
|
87
|
+
title: 'The shell and moss',
|
|
88
|
+
lead: 'The shell holds the cards and runs what they do.',
|
|
89
|
+
points: [
|
|
90
|
+
{ title: 'One per person', text: 'moss keeps a shell for each person who signs in; until then, one a connection.' },
|
|
91
|
+
{ title: 'Drawn where you are', text: 'Your browser draws the frames moss sends over a socket.' },
|
|
92
|
+
{ title: 'Rules on the server', text: 'What you may do is decided there, never in the browser.' },
|
|
93
|
+
],
|
|
94
|
+
}),
|
|
95
|
+
card('guide.data', 'Reads and writes: vex queries and mutations written as JSON, replayed by their fingerprint and run under the person’s policy; an example read.', exampleLayout, {
|
|
96
|
+
title: 'Reads and writes',
|
|
97
|
+
lead: 'Data comes through vex: a read is a query written as JSON, replayed by its fingerprint.',
|
|
98
|
+
example: [
|
|
99
|
+
'{',
|
|
100
|
+
' "fingerprint": "notes/list",',
|
|
101
|
+
' "intent": "Every note, newest first",',
|
|
102
|
+
' "dsl": {',
|
|
103
|
+
' "from": ["notes"],',
|
|
104
|
+
' "sort": [{ "field": "notes.created_at", "dir": "desc" }],',
|
|
105
|
+
' "limit": 100',
|
|
106
|
+
' }',
|
|
107
|
+
'}',
|
|
108
|
+
].join('\n'),
|
|
109
|
+
text: 'A write is the same, as a mutation. Both run under the person’s policy; yours go in src/app/vex/.',
|
|
110
|
+
}),
|
|
111
|
+
card('guide.charter', 'The charter: which actions, data and server functions each role may reach, decided on the server; this app’s own charter as the example.', exampleLayout, {
|
|
112
|
+
title: 'The charter',
|
|
113
|
+
lead: 'The charter says what each role may do: which actions exist for them, which data they reach, which server functions they call.',
|
|
114
|
+
example: [
|
|
115
|
+
'{',
|
|
116
|
+
' "public": {',
|
|
117
|
+
' "actions": ["ask.*", "answer.*", "guide.*"],',
|
|
118
|
+
' "data": [],',
|
|
119
|
+
' "functions": [',
|
|
120
|
+
' "ask", "screens.open", "answers.current",',
|
|
121
|
+
' "answers.back", "answers.forward", "answers.go"',
|
|
122
|
+
' ]',
|
|
123
|
+
' }',
|
|
124
|
+
'}',
|
|
125
|
+
].join('\n'),
|
|
126
|
+
text: 'This is this app’s. moss will not start an app whose charter does not add up.',
|
|
127
|
+
links: [{ label: 'Next: make it yours →', screen: 'yours' }],
|
|
128
|
+
}),
|
|
129
|
+
card('guide.yours', 'Making it yours, step by step: delete the guide, then tables go in src/db/schema.ts, reads and writes in src/app/vex/, actions in src/app/actions/.', stepsLayout, {
|
|
130
|
+
title: 'Making it yours',
|
|
131
|
+
lead: 'Start your own app from this one.',
|
|
132
|
+
steps: [
|
|
133
|
+
'Delete src/app/actions/guide/ and src/dev/guide-check.ts, and the lines that name them: AGENTS.md lists them.',
|
|
134
|
+
'Put your tables in src/db/schema.ts.',
|
|
135
|
+
'Put your reads and writes in src/app/vex/.',
|
|
136
|
+
'Add your actions in src/app/actions/, each with a description the model chooses by, and the ones it may place in placeable.',
|
|
137
|
+
'Run npm run check after each step.',
|
|
138
|
+
],
|
|
139
|
+
links: [{ label: 'Back to the start →', screen: 'start' }],
|
|
140
|
+
}),
|
|
141
|
+
counterAction,
|
|
142
|
+
checklistAction,
|
|
143
|
+
quizAction,
|
|
144
|
+
];
|