create-nisc 0.2.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.
Files changed (121) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +72 -0
  3. package/bin/create-nisc.js +5 -0
  4. package/dist/chunk-A4727PE2.js +174 -0
  5. package/dist/chunk-A4727PE2.js.map +1 -0
  6. package/dist/chunk-TEYNNEJA.js +173 -0
  7. package/dist/chunk-TEYNNEJA.js.map +1 -0
  8. package/dist/cli.js +113 -0
  9. package/dist/cli.js.map +1 -0
  10. package/dist/index.d.ts +23 -0
  11. package/dist/index.js +3 -0
  12. package/dist/index.js.map +1 -0
  13. package/package.json +54 -0
  14. package/templates/moss-dom/.turbo/turbo-build.log +32 -0
  15. package/templates/moss-dom/.turbo/turbo-test.log +15 -0
  16. package/templates/moss-dom/.turbo/turbo-typecheck.log +4 -0
  17. package/templates/moss-dom/README.md +15 -0
  18. package/templates/moss-dom/index.html +12 -0
  19. package/templates/moss-dom/nisc.config.ts +19 -0
  20. package/templates/moss-dom/package.json +39 -0
  21. package/templates/moss-dom/src/app/action-catalog.ts +8 -0
  22. package/templates/moss-dom/src/app/actions/surfaces/welcome.action.ts +13 -0
  23. package/templates/moss-dom/src/app/actions/surfaces/welcome.layout.ts +27 -0
  24. package/templates/moss-dom/src/app/app.ts +10 -0
  25. package/templates/moss-dom/src/app/charter/assignments.ts +3 -0
  26. package/templates/moss-dom/src/app/charter/charter.ts +8 -0
  27. package/templates/moss-dom/src/app/shell/frame.layout.ts +5 -0
  28. package/templates/moss-dom/src/app/shell/shell.ts +10 -0
  29. package/templates/moss-dom/src/dev/all-checks.ts +20 -0
  30. package/templates/moss-dom/src/dev/artifacts-check.ts +56 -0
  31. package/templates/moss-dom/src/dev/strata.ts +28 -0
  32. package/templates/moss-dom/src/dev/welcome-check.ts +43 -0
  33. package/templates/moss-dom/src/main.ts +22 -0
  34. package/templates/moss-dom/src/server/boot.ts +9 -0
  35. package/templates/moss-dom/src/server/document.ts +15 -0
  36. package/templates/moss-dom/src/server/runtime.ts +21 -0
  37. package/templates/moss-dom/src/ui/kit.css +42 -0
  38. package/templates/moss-dom/src/ui/kit.ts +41 -0
  39. package/templates/moss-dom/src/ui/registry.ts +16 -0
  40. package/templates/moss-dom/strata.lock.json +6 -0
  41. package/templates/moss-dom/tsconfig.json +27 -0
  42. package/templates/moss-dom/vite.config.ts +8 -0
  43. package/templates/moss-react/.turbo/turbo-build.log +32 -0
  44. package/templates/moss-react/.turbo/turbo-test.log +15 -0
  45. package/templates/moss-react/.turbo/turbo-typecheck.log +4 -0
  46. package/templates/moss-react/README.md +15 -0
  47. package/templates/moss-react/index.html +12 -0
  48. package/templates/moss-react/nisc.config.ts +19 -0
  49. package/templates/moss-react/package.json +42 -0
  50. package/templates/moss-react/src/app/action-catalog.ts +8 -0
  51. package/templates/moss-react/src/app/actions/surfaces/welcome.action.ts +13 -0
  52. package/templates/moss-react/src/app/actions/surfaces/welcome.layout.ts +27 -0
  53. package/templates/moss-react/src/app/app.ts +10 -0
  54. package/templates/moss-react/src/app/charter/assignments.ts +3 -0
  55. package/templates/moss-react/src/app/charter/charter.ts +8 -0
  56. package/templates/moss-react/src/app/shell/frame.layout.ts +5 -0
  57. package/templates/moss-react/src/app/shell/shell.ts +10 -0
  58. package/templates/moss-react/src/dev/all-checks.ts +20 -0
  59. package/templates/moss-react/src/dev/artifacts-check.ts +56 -0
  60. package/templates/moss-react/src/dev/strata.ts +28 -0
  61. package/templates/moss-react/src/dev/welcome-check.ts +43 -0
  62. package/templates/moss-react/src/main.tsx +20 -0
  63. package/templates/moss-react/src/server/boot.ts +9 -0
  64. package/templates/moss-react/src/server/document.ts +12 -0
  65. package/templates/moss-react/src/server/runtime.ts +21 -0
  66. package/templates/moss-react/src/ui/kit.css +42 -0
  67. package/templates/moss-react/src/ui/kit.tsx +49 -0
  68. package/templates/moss-react/src/ui/registry.ts +14 -0
  69. package/templates/moss-react/strata.lock.json +6 -0
  70. package/templates/moss-react/tsconfig.json +17 -0
  71. package/templates/moss-react/vite.config.ts +11 -0
  72. package/templates/shell-dom/.turbo/turbo-build.log +31 -0
  73. package/templates/shell-dom/.turbo/turbo-test.log +12 -0
  74. package/templates/shell-dom/.turbo/turbo-typecheck.log +4 -0
  75. package/templates/shell-dom/README.md +16 -0
  76. package/templates/shell-dom/index.html +12 -0
  77. package/templates/shell-dom/nisc.config.ts +19 -0
  78. package/templates/shell-dom/package.json +35 -0
  79. package/templates/shell-dom/src/app/action-catalog.ts +8 -0
  80. package/templates/shell-dom/src/app/actions/surfaces/welcome.action.ts +12 -0
  81. package/templates/shell-dom/src/app/actions/surfaces/welcome.layout.ts +27 -0
  82. package/templates/shell-dom/src/app/shell/frame.layout.ts +5 -0
  83. package/templates/shell-dom/src/app/shell/shell.ts +10 -0
  84. package/templates/shell-dom/src/boot.ts +18 -0
  85. package/templates/shell-dom/src/dev/all-checks.ts +20 -0
  86. package/templates/shell-dom/src/dev/artifacts-check.ts +52 -0
  87. package/templates/shell-dom/src/dev/strata.ts +28 -0
  88. package/templates/shell-dom/src/dev/welcome-check.ts +26 -0
  89. package/templates/shell-dom/src/main.ts +14 -0
  90. package/templates/shell-dom/src/ui/kit.css +42 -0
  91. package/templates/shell-dom/src/ui/kit.ts +41 -0
  92. package/templates/shell-dom/src/ui/registry.ts +16 -0
  93. package/templates/shell-dom/src/ui/screen.ts +16 -0
  94. package/templates/shell-dom/strata.lock.json +6 -0
  95. package/templates/shell-dom/tsconfig.json +27 -0
  96. package/templates/shell-dom/vite.config.ts +6 -0
  97. package/templates/shell-react/.turbo/turbo-build.log +31 -0
  98. package/templates/shell-react/.turbo/turbo-test.log +12 -0
  99. package/templates/shell-react/.turbo/turbo-typecheck.log +4 -0
  100. package/templates/shell-react/README.md +16 -0
  101. package/templates/shell-react/index.html +12 -0
  102. package/templates/shell-react/nisc.config.ts +19 -0
  103. package/templates/shell-react/package.json +40 -0
  104. package/templates/shell-react/src/app/action-catalog.ts +8 -0
  105. package/templates/shell-react/src/app/actions/surfaces/welcome.action.ts +12 -0
  106. package/templates/shell-react/src/app/actions/surfaces/welcome.layout.ts +27 -0
  107. package/templates/shell-react/src/app/shell/frame.layout.ts +5 -0
  108. package/templates/shell-react/src/app/shell/shell.ts +10 -0
  109. package/templates/shell-react/src/boot.ts +18 -0
  110. package/templates/shell-react/src/dev/all-checks.ts +20 -0
  111. package/templates/shell-react/src/dev/artifacts-check.ts +52 -0
  112. package/templates/shell-react/src/dev/strata.ts +28 -0
  113. package/templates/shell-react/src/dev/welcome-check.ts +26 -0
  114. package/templates/shell-react/src/main.tsx +25 -0
  115. package/templates/shell-react/src/ui/kit.css +42 -0
  116. package/templates/shell-react/src/ui/kit.tsx +49 -0
  117. package/templates/shell-react/src/ui/registry.ts +14 -0
  118. package/templates/shell-react/src/ui/screen.tsx +15 -0
  119. package/templates/shell-react/strata.lock.json +6 -0
  120. package/templates/shell-react/tsconfig.json +28 -0
  121. package/templates/shell-react/vite.config.ts +9 -0
@@ -0,0 +1,27 @@
1
+ import type { LayoutNode } from '@niscorp/nova';
2
+
3
+ // JSON, bound to the action's data. Every component name is one the kit in
4
+ // src/ui registers; `ref` is what the action's trigger catches.
5
+ export const welcomeLayout: LayoutNode = {
6
+ component: 'Page',
7
+ children: [
8
+ { component: 'Heading', children: '{{$.name}}' },
9
+ {
10
+ component: 'Text',
11
+ props: { tone: 'muted' },
12
+ children: 'A nisc app behind moss, drawn with plain DOM — no framework in the page. This screen is an action on a canvas, served from a shell on the server; the page arrived drawn, and the browser picked it up. Nobody is signed in, so this shell lasts as long as your connection — reload, and the count starts again.',
13
+ },
14
+ {
15
+ component: 'Row',
16
+ children: [
17
+ { component: 'Button', ref: 'press', props: { label: 'Press' } },
18
+ { component: 'Text', children: 'Presses: {{$.presses}}' },
19
+ ],
20
+ },
21
+ {
22
+ component: 'Text',
23
+ props: { tone: 'muted' },
24
+ children: 'Start in PLAN.md. The rules this app is built by are in AGENTS.md.',
25
+ },
26
+ ],
27
+ };
@@ -0,0 +1,10 @@
1
+ import { defineApp } from '@niscorp/moss';
2
+ import { actions } from './action-catalog';
3
+ import { assignments } from './charter/assignments';
4
+ import { charter } from './charter/charter';
5
+ import { shell } from './shell/shell';
6
+
7
+ // The manifest moss serves. One import per field; every field is data
8
+ // (AGENTS.md, "Layout of an app"). What it grows next — entries for the data
9
+ // layer, behaviors, pages — is in PLAN.md.
10
+ export const app = defineApp({ charter, assignments, actions, shell });
@@ -0,0 +1,3 @@
1
+ // Who wears which roles: principal id → role names. Empty until somebody can
2
+ // sign in; the anonymous principal is always `public`.
3
+ export const assignments: Record<string, readonly string[]> = {};
@@ -0,0 +1,8 @@
1
+ import type { Charter } from '@niscorp/charter';
2
+
3
+ // The policy document: role names → the action ids that exist for them (and,
4
+ // once there is data, `data: ['table.verb', …]`). `public` is whoever has not
5
+ // signed in — today, everybody.
6
+ export const charter: Charter = {
7
+ public: ['welcome'],
8
+ };
@@ -0,0 +1,5 @@
1
+ import type { LayoutNode } from '@niscorp/nova';
2
+
3
+ // The frame around the canvases — chrome lives here, as layout, never as a
4
+ // wrapper component. One canvas for now: `main`, drawn where its slot is.
5
+ export const frameLayout: LayoutNode = { component: 'CanvasSlot', props: { canvasId: 'main' } };
@@ -0,0 +1,10 @@
1
+ import type { ShellManifest } from '@niscorp/moss';
2
+ import { frameLayout } from './frame.layout';
3
+
4
+ // The shell: one canvas, the action it opens with, and the frame around it.
5
+ // Shells host canvases, canvases host action instances, actions render JSON
6
+ // layouts.
7
+ export const shell: ShellManifest = {
8
+ canvases: [{ id: 'main', initial: 'welcome' }],
9
+ layout: frameLayout,
10
+ };
@@ -0,0 +1,20 @@
1
+ import { spawnSync } from 'node:child_process';
2
+
3
+ // Every check, each in its own process over its own fresh database: a check ships the app a
4
+ // history, and a shared one would make the order of the suite part of its
5
+ // meaning. `nisc check` runs this. A new feature adds its check here.
6
+ const CHECKS: readonly (readonly [name: string, what: string, args?: readonly string[]])[] = [
7
+ ['artifacts-check', 'src/app is data: pure JSON, and every artifact parses its schema'],
8
+ ['strata', 'the source is written at the installed grammars (strata.lock.json)', ['status', '--check']],
9
+ ['welcome-check', 'the welcome screen: served, drawn, and pressed'],
10
+ ];
11
+
12
+ let failed = 0;
13
+ for (const [name, what, args = []] of CHECKS) {
14
+ console.log(`\n── ${name} — ${what}`);
15
+ const run = spawnSync(process.execPath, ['--import', 'tsx', `src/dev/${name}.ts`, ...args], { stdio: 'inherit' });
16
+ if (run.status !== 0) failed += 1;
17
+ }
18
+
19
+ console.log(failed === 0 ? `\nAll ${CHECKS.length} checks pass.` : `\n${failed} of ${CHECKS.length} checks failed.`);
20
+ process.exit(failed === 0 ? 0 : 1);
@@ -0,0 +1,56 @@
1
+ // The artifacts check — what makes `src/app/` a tree of DATA: everything in it
2
+ // is pure JSON (no function, no Date, no undefined, no class instance) and
3
+ // parses through its own schema, so a code file cannot pass for an artifact
4
+ // (AGENTS.md, review item 6a). It also holds rule 14: an action's `input`
5
+ // declares only keys its `data` has.
6
+ import { ActionDefinitionSchema, LayoutNodeSchema } from '@niscorp/nova';
7
+ import { actions } from '../app/action-catalog';
8
+ import { assignments } from '../app/charter/assignments';
9
+ import { charter } from '../app/charter/charter';
10
+ import { shell } from '../app/shell/shell';
11
+
12
+ let failures = 0;
13
+ const check = (name: string, passed: boolean, detail = ''): void => {
14
+ console.log(`${passed ? '[pass]' : '[fail]'} ${name}${!passed && detail !== '' ? ` — ${detail}` : ''}`);
15
+ if (!passed) failures += 1;
16
+ };
17
+
18
+ // The first thing in a value that is not JSON, as a path — or '' when all of it is.
19
+ const impurity = (value: unknown, path: string): string => {
20
+ if (value === null || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') return '';
21
+ if (Array.isArray(value)) return value.map((item, at) => impurity(item, `${path}[${at}]`)).find((found) => found !== '') ?? '';
22
+ if (typeof value !== 'object') return `${path} is a ${typeof value}`;
23
+ if (Object.getPrototypeOf(value) !== Object.prototype) return `${path} is not a plain object`;
24
+ return Object.entries(value).map(([key, inner]) => impurity(inner, path === '' ? key : `${path}.${key}`)).find((found) => found !== '') ?? '';
25
+ };
26
+ const pure = (name: string, value: unknown): void => {
27
+ const found = impurity(value, '');
28
+ check(`${name} is pure JSON`, found === '', found);
29
+ };
30
+ const parses = (name: string, parse: () => unknown): void => {
31
+ try {
32
+ parse();
33
+ check(`${name} parses its schema`, true);
34
+ } catch (error) {
35
+ check(`${name} parses its schema`, false, error instanceof Error ? error.message.slice(0, 300) : String(error));
36
+ }
37
+ };
38
+ const isRecord = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null && !Array.isArray(value);
39
+
40
+ pure('the action catalog', actions);
41
+ pure('the charter', charter);
42
+ pure('the assignments', assignments);
43
+ pure('the shell', shell);
44
+ if (shell.layout !== undefined) parses('the shell’s frame', () => LayoutNodeSchema.parse(shell.layout));
45
+
46
+ for (const [id, definition] of Object.entries(actions)) {
47
+ check(`action "${id}" is catalogued under its own id`, definition.id === id, `its id is "${definition.id}"`);
48
+ parses(`action "${id}"`, () => ActionDefinitionSchema.parse(definition));
49
+ // rule 14: what an opener may seed is a subset of the action's data
50
+ const properties = isRecord(definition.input) && isRecord(definition.input['properties']) ? Object.keys(definition.input['properties']) : [];
51
+ const unknown = properties.filter((key) => !(key in (definition.data ?? {})));
52
+ check(`action "${id}" declares only inputs its data has`, unknown.length === 0, unknown.join(', '));
53
+ }
54
+
55
+ console.log(failures === 0 ? '[pass] artifacts: all checks passed' : `[fail] artifacts: ${failures} check(s) failed`);
56
+ process.exit(failures === 0 ? 0 : 1);
@@ -0,0 +1,28 @@
1
+ // strata for this app's SOURCE artifacts — which version of each grammar
2
+ // (nova's, Prism's) the actions in src/app are written in, recorded in
3
+ // strata.lock.json, and how they are brought forward when a grammar moves
4
+ // (AGENTS.md rule 20).
5
+ //
6
+ // npm run strata status where the source stands (`-- --check` to fail when behind)
7
+ // npm run strata upgrade the exact expected JSON + a report of what to edit
8
+ // npm run strata verify holds the edit to that JSON, then moves the lock
9
+ import { fileURLToPath } from 'node:url';
10
+ import { NOVA_SCHEMAS, NOVA_SEQUENCE } from '@niscorp/nova/migrations';
11
+ import { PRISM_SCHEMAS, PRISM_SEQUENCE, prismTransform } from '@niscorp/prism/migrations';
12
+ import { runSourceUpgrade } from '@niscorp/strata/node';
13
+ import { actions } from '../app/action-catalog';
14
+
15
+ const root = fileURLToPath(new URL('../..', import.meta.url));
16
+
17
+ process.exit(
18
+ await runSourceUpgrade(
19
+ {
20
+ root,
21
+ grammars: [NOVA_SEQUENCE, PRISM_SEQUENCE],
22
+ transform: prismTransform,
23
+ schemas: { ...NOVA_SCHEMAS, ...PRISM_SCHEMAS },
24
+ documents: async () => Object.values(actions).map((document) => ({ kind: 'nisc.nova/action', id: document.id, document })),
25
+ },
26
+ process.argv.slice(2),
27
+ ),
28
+ );
@@ -0,0 +1,43 @@
1
+ import { renderDocument } from '@niscorp/moss';
2
+ import { boot } from '../server/boot';
3
+ import { drawing } from '../server/document';
4
+
5
+ // The welcome screen, end to end with no browser: the real server boots, the
6
+ // screen is served to nobody in particular, the page is drawn on the server,
7
+ // and a press reaches the shell. One `[pass]`/`[fail]` line per assertion; any
8
+ // failure exits non-zero (AGENTS.md, "Verification").
9
+
10
+ let failures = 0;
11
+ const check = (name: string, passed: boolean, detail = ''): void => {
12
+ console.log(`${passed ? '[pass]' : '[fail]'} ${name}${!passed && detail !== '' ? ` — ${detail}` : ''}`);
13
+ if (!passed) failures += 1;
14
+ };
15
+
16
+ const tick = (ms = 20): Promise<void> => new Promise((done) => setTimeout(done, ms));
17
+
18
+ const { server } = await boot();
19
+ try {
20
+ const shells = server.shells;
21
+ if (shells === undefined) throw new Error('the manifest has no shell');
22
+ const snapshot = await shells.snapshot(null, null);
23
+ const main = JSON.stringify(snapshot.trees['main'] ?? []);
24
+ check('the anonymous principal is served the welcome action', main.includes('"definitionId":"welcome"'), main.slice(0, 200));
25
+ check('its screen has a button to press', main.includes('"ref":"press"'));
26
+
27
+ const template = '<!doctype html><html><head></head><body><div id="root"></div></body></html>';
28
+ const page = await renderDocument({ ...drawing, server, template, request: { path: '/', cookie: null } });
29
+ check('the page arrives drawn', page.drawn && page.html.includes('k-heading'), page.html.slice(0, 200));
30
+ check('a page drawn for nobody may be kept by a cache', page.headers['cache-control'] === 'no-cache');
31
+
32
+ const session = await shells.session(null, null);
33
+ session.dispatch('main', { type: 'ui:click', ref: 'press' });
34
+ await tick();
35
+ const active = session.shell.getState().canvases['main']?.active?.id ?? '';
36
+ const presses = session.shell.getRuntime(active)?.getData()['presses'];
37
+ check('a press reaches the shell on the server', presses === 1, `presses is ${String(presses)}`);
38
+ } finally {
39
+ server.close();
40
+ }
41
+
42
+ console.log(failures === 0 ? '[pass] welcome: all checks passed' : `[fail] welcome: ${failures} check(s) failed`);
43
+ process.exit(failures === 0 ? 0 : 1);
@@ -0,0 +1,22 @@
1
+ import { browserEnv, createWire, readDocumentSnapshot } from '@niscorp/moss/client';
2
+ import { createTerminal } from '@niscorp/moss/terminal';
3
+ import { domTarget } from '@niscorp/moss/terminal/dom';
4
+ import { buildRegistry } from './ui/registry';
5
+ import './ui/kit.css';
6
+
7
+ // The browser: the kit, handed to moss's terminal — plain DOM, no framework. It
8
+ // knows nothing about the app: it draws the trees the socket sends and sends
9
+ // back what was pressed.
10
+ //
11
+ // The page arrives with the first screen already in it (src/server/document.ts)
12
+ // and the snapshot it was drawn from beside it; the wire starts from that
13
+ // snapshot, and the DOM adapter's first render puts the same elements back.
14
+ // `cookie` keeps a copy of the session token where a page request can carry
15
+ // it, which is how the server will know whose screen to draw once people can
16
+ // sign in.
17
+ const root = document.getElementById('root');
18
+ if (root === null) throw new Error('index.html has no #root');
19
+
20
+ const drawn = readDocumentSnapshot();
21
+ const wire = createWire({ env: browserEnv({ cookie: true }), ...(drawn !== undefined ? { initial: drawn } : {}) });
22
+ createTerminal({ target: domTarget({ root, registry: buildRegistry() }), wire });
@@ -0,0 +1,9 @@
1
+ import { createServer } from '@niscorp/moss';
2
+ import type { MossServer } from '@niscorp/moss';
3
+ import { app } from '../app/app';
4
+ import { runtime } from './runtime';
5
+
6
+ // The one composition: the app's artifacts plus an environment → the server.
7
+ // The dev server, `nisc build`, `nisc start` and every check boot through here.
8
+ // moss refuses to boot an incoherent charter — a refusal is a finding.
9
+ export const boot = async (): Promise<{ server: MossServer }> => ({ server: await createServer(app, await runtime()) });
@@ -0,0 +1,15 @@
1
+ import { JSDOM } from 'jsdom';
2
+ import type { ShellSnapshot } from '@niscorp/moss';
3
+ import { renderSnapshot } from '@niscorp/moss/terminal/dom/server';
4
+ import { buildRegistry } from '../ui/registry';
5
+
6
+ // HOW A SCREEN IS DRAWN on the server: the kit the browser draws with, handed
7
+ // to moss. A DOM kit builds real elements, so it is handed a DOM to build them
8
+ // in (jsdom). A page request is answered with the screen the socket would have
9
+ // streamed a moment later.
10
+ const registry = buildRegistry();
11
+ const { window } = new JSDOM('');
12
+
13
+ export const drawing = {
14
+ draw: (snapshot: ShellSnapshot): string => renderSnapshot({ snapshot, registry, window }),
15
+ };
@@ -0,0 +1,21 @@
1
+ import { PGlite } from '@electric-sql/pglite';
2
+ import { createPostgresCache } from '@niscorp/vex';
3
+ import { createPglitePool, RAW_DATE_PARSERS } from '@niscorp/vex/pglite';
4
+ import type { NiscRuntime } from '@niscorp/moss';
5
+
6
+ // The environment (D2): what the app is handed to run on. An in-memory Postgres
7
+ // (PGlite) — every boot starts empty, which is what development and the checks
8
+ // want. A deployment hands moss a real Postgres pool here instead; nothing else
9
+ // in the app changes (see PLAN.md).
10
+ //
11
+ // `sessions`: moss verifies session tokens against its own table. Nobody can
12
+ // sign in yet — signing in is an application of its own, the anonymous
13
+ // principal's (AGENTS.md rule 12) — so every request is `public` for now.
14
+ export const runtime = async (): Promise<NiscRuntime> => {
15
+ const db = new PGlite();
16
+ // App queries get raw date strings (Prism formats them); the cache keeps
17
+ // Dates. One database, two pools.
18
+ const cache = createPostgresCache({ pool: createPglitePool(db) });
19
+ await cache.init();
20
+ return { db, pool: createPglitePool(db, RAW_DATE_PARSERS), cache, session: 'sessions' };
21
+ };
@@ -0,0 +1,42 @@
1
+ /* The look — the only place it lives. A different look is a different
2
+ stylesheet over the same layouts. */
3
+
4
+ :root {
5
+ --k-bg: #f6f4ef;
6
+ --k-ink: #1d1d1f;
7
+ --k-muted: #6b6a66;
8
+ --k-accent: #2f5bea;
9
+ --k-accent-ink: #ffffff;
10
+ --k-radius: 10px;
11
+ font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
12
+ color: var(--k-ink);
13
+ background: var(--k-bg);
14
+ }
15
+
16
+ html, body, #root { margin: 0; min-height: 100%; }
17
+
18
+ .k-page {
19
+ max-width: 640px;
20
+ margin: 0 auto;
21
+ padding: 64px 24px;
22
+ display: flex;
23
+ flex-direction: column;
24
+ gap: 16px;
25
+ }
26
+
27
+ .k-row { display: flex; align-items: center; gap: 16px; }
28
+ .k-heading { margin: 0; font-size: 32px; letter-spacing: -0.01em; }
29
+ .k-text { margin: 0; line-height: 1.55; }
30
+ .k-muted { color: var(--k-muted); }
31
+
32
+ .k-button {
33
+ border: 0;
34
+ border-radius: var(--k-radius);
35
+ padding: 10px 18px;
36
+ font: inherit;
37
+ font-weight: 600;
38
+ background: var(--k-accent);
39
+ color: var(--k-accent-ink);
40
+ cursor: pointer;
41
+ }
42
+ .k-button:active { transform: translateY(1px); }
@@ -0,0 +1,41 @@
1
+ import { z } from 'zod';
2
+ import type { DomComponent } from '@niscorp/nova/adapters/dom';
3
+
4
+ // ═══════════════════════════════════════════════════════════
5
+ // The kit: domain-blind primitives, as plain DOM — no framework in the page.
6
+ // Props in, an element out; nova's DOM adapter wires a `ref`'d element's clicks
7
+ // by convention, so a button is just a button. Each one is CONFIGURED, never
8
+ // styled: it reads what a thing is (a tone) from a closed set of names, and
9
+ // anything it does not know falls back to the default. The look lives in
10
+ // kit.css alone.
11
+ // ═══════════════════════════════════════════════════════════
12
+
13
+ const parsed = <T>(schema: z.ZodType<T>, props: unknown, fallback: T): T => {
14
+ const result = schema.safeParse(props);
15
+ return result.success ? result.data : fallback;
16
+ };
17
+
18
+ const element = (tag: string, className: string, children: Node[]): HTMLElement => {
19
+ const el = document.createElement(tag);
20
+ el.className = className;
21
+ el.append(...children);
22
+ return el;
23
+ };
24
+
25
+ export const Page: DomComponent = ({ children }) => element('main', 'k-page', children);
26
+ export const Row: DomComponent = ({ children }) => element('div', 'k-row', children);
27
+ export const Heading: DomComponent = ({ children }) => element('h1', 'k-heading', children);
28
+
29
+ const TextProps = z.object({ tone: z.enum(['default', 'muted']).optional() });
30
+ export const Text: DomComponent = ({ props, children }) => {
31
+ const { tone } = parsed(TextProps, props, {});
32
+ return element('p', tone === 'muted' ? 'k-text k-muted' : 'k-text', children);
33
+ };
34
+
35
+ const ButtonProps = z.object({ label: z.string().optional() });
36
+ export const Button: DomComponent = ({ props, children }) => {
37
+ const { label } = parsed(ButtonProps, props, {});
38
+ const button = element('button', 'k-button', label !== undefined ? [document.createTextNode(label)] : children);
39
+ button.setAttribute('type', 'button');
40
+ return button;
41
+ };
@@ -0,0 +1,16 @@
1
+ import { createComponentRegistry, ACTION_SLOT_NAME, CANVAS_SLOT_NAME } from '@niscorp/nova';
2
+ import type { ComponentRegistry } from '@niscorp/nova';
3
+ import type { DomComponent } from '@niscorp/nova/adapters/dom';
4
+ import { fallback } from '@niscorp/nova/adapters/dom/components';
5
+ import { Button, Heading, Page, Row, Text } from './kit';
6
+
7
+ // The one registry, assembled once (rule 2): the kit, and nova's two slot
8
+ // markers (the adapter resolves a canvas slot itself; an action slot is a plain
9
+ // wrapper). Every component a layout may name is here, and nothing else is.
10
+ export const buildRegistry = (): ComponentRegistry<DomComponent> => {
11
+ const registry = createComponentRegistry<DomComponent>();
12
+ registry.register(CANVAS_SLOT_NAME, fallback);
13
+ registry.register(ACTION_SLOT_NAME, fallback);
14
+ registry.registerAll({ Page, Row, Heading, Text, Button });
15
+ return registry;
16
+ };
@@ -0,0 +1,6 @@
1
+ {
2
+ "grammar": {
3
+ "nisc.nova": 2,
4
+ "nisc.prism": 1
5
+ }
6
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "lib": [
7
+ "DOM",
8
+ "DOM.Iterable",
9
+ "ES2022"
10
+ ],
11
+ "strict": true,
12
+ "noUncheckedIndexedAccess": true,
13
+ "verbatimModuleSyntax": true,
14
+ "isolatedModules": true,
15
+ "skipLibCheck": true,
16
+ "noEmit": true,
17
+ "types": [
18
+ "node",
19
+ "vite/client"
20
+ ]
21
+ },
22
+ "include": [
23
+ "src",
24
+ "nisc.config.ts",
25
+ "vite.config.ts"
26
+ ]
27
+ }
@@ -0,0 +1,8 @@
1
+ // A default export, which the style guide otherwise bans: vite reads its config
2
+ // from one, so this file has to match vite's shape (AGENTS.md rule 16, a shim).
3
+ import { defineConfig } from 'vite';
4
+
5
+ // The browser's bundle: plain DOM, no framework. The app server runs inside
6
+ // vite's dev process too, but that is `nisc dev`'s doing (moss's dev plugin,
7
+ // fed from nisc.config.ts) — nothing about it belongs here.
8
+ export default defineConfig({});
@@ -0,0 +1,32 @@
1
+
2
+ > nisc-template-moss-react@0.0.0 build /Users/max/Development/niscorp/.claude/worktrees/prerender/packages/create-nisc/templates/moss-react
3
+ > tsc --noEmit && nisc build
4
+
5
+ vite v7.3.2 building client environment for production...
6
+ transforming...
7
+ ../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/util.js (400:0): A comment
8
+
9
+ "// Wrapped in a `@__PURE__` IIFE: esbuild never tree-shakes a top-level initializer that contains a member access on `Number`, so the bare object literal survived into every bundle."
10
+
11
+ in "../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/util.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.
12
+ ../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/regexes.js (74:0): A comment
13
+
14
+ "/** Anchors a pattern source. The interpolation lives here rather than at the call site because
15
+ * esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it
16
+ * will drop `anchor(dateSource)`. Keeping it inline pinned `date` into every bundle. */"
17
+
18
+ in "../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/regexes.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.
19
+ ✓ 163 modules transformed.
20
+ rendering chunks...
21
+ computing gzip size...
22
+ dist/index.html 0.41 kB │ gzip: 0.27 kB
23
+ dist/assets/index-DALMMv7I.css 0.74 kB │ gzip: 0.43 kB
24
+ dist/assets/index-DvixsGlk.js 299.53 kB │ gzip: 92.01 kB
25
+ ✓ built in 6.32s
26
+ [vex] reads are not bounded: this database cannot enforce statement_timeout (10000ms asked). Fine for development; production wants Postgres.
27
+
28
+ Route What Served as Because
29
+ ● / the app server welcome: a person can act on it
30
+
31
+ ○ file drawn once, for nobody in particular; nothing on it can still happen
32
+ ● server something on it can still happen; it wants moss behind it
@@ -0,0 +1,15 @@
1
+
2
+ > nisc-template-moss-react@0.0.0 test /Users/max/Development/niscorp/.claude/worktrees/prerender/packages/create-nisc/templates/moss-react
3
+ > nisc check
4
+
5
+
6
+ ── welcome-check — the welcome screen: served, drawn, and pressed
7
+ [vex] reads are not bounded: this database cannot enforce statement_timeout (10000ms asked). Fine for development; production wants Postgres.
8
+ [pass] the anonymous principal is served the welcome action
9
+ [pass] its screen has a button to press
10
+ [pass] the page arrives drawn
11
+ [pass] a page drawn for nobody may be kept by a cache
12
+ [pass] a press reaches the shell on the server
13
+ [pass] welcome: all checks passed
14
+
15
+ All 1 checks pass.
@@ -0,0 +1,4 @@
1
+
2
+ > nisc-template-moss-react@0.0.0 typecheck /Users/max/Development/niscorp/.claude/worktrees/prerender/packages/create-nisc/templates/moss-react
3
+ > tsc --noEmit
4
+
@@ -0,0 +1,15 @@
1
+ # nisc-template-moss-react
2
+
3
+ A [nisc](https://github.com/moccadroid/niscorp) application behind moss — the shell runs on the server, one per person; the browser is a canvas terminal.
4
+
5
+ | | |
6
+ |---|---|
7
+ | `npm run dev` | the app, in vite — with its server inside |
8
+ | `npm run build` | typecheck, bundle, draw every path and say how it is served |
9
+ | `npm start` | serve the built app, each first screen drawn |
10
+ | `npm run check` | the checks in `src/dev/` |
11
+ | `npm run strata status` | which grammar versions the source is written at |
12
+
13
+ **Before building anything:** [PLAN.md](PLAN.md) — what was decided when this app
14
+ was made and what is still open — and [AGENTS.md](AGENTS.md), which says where
15
+ the rules are.
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>nisc-template-moss-react</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/main.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,19 @@
1
+ import type { NiscMossProject } from '@niscorp/cli';
2
+ import { boot } from './src/server/boot';
3
+ import { drawing } from './src/server/document';
4
+
5
+ // What this app tells the `nisc` command: how it stands up (the same boot the
6
+ // checks run) and how one of its screens is drawn (the same drawing the dev
7
+ // server and `nisc start` use). Everything else is read off the app.
8
+ //
9
+ // npm run dev the app, with its server inside vite
10
+ // npm run build bundle, then say how each path is served
11
+ // npm start serve the built app, each first screen drawn
12
+ // npm run check the checks in src/dev
13
+ export const project: NiscMossProject = {
14
+ boot: async () => {
15
+ const { server } = await boot();
16
+ return { server, close: () => server.close() };
17
+ },
18
+ ...drawing,
19
+ };
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "nisc-template-moss-react",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=22.12"
8
+ },
9
+ "scripts": {
10
+ "dev": "nisc dev",
11
+ "build": "tsc --noEmit && nisc build",
12
+ "start": "nisc start",
13
+ "check": "nisc check",
14
+ "test": "nisc check",
15
+ "typecheck": "tsc --noEmit",
16
+ "strata": "tsx src/dev/strata.ts"
17
+ },
18
+ "dependencies": {
19
+ "@electric-sql/pglite": "^0.5.1",
20
+ "@niscorp/charter": "workspace:^",
21
+ "@niscorp/moss": "workspace:^",
22
+ "@niscorp/nova": "workspace:^",
23
+ "@niscorp/prism": "workspace:^",
24
+ "@niscorp/strata": "workspace:^",
25
+ "@niscorp/tide": "workspace:^",
26
+ "@niscorp/vex": "workspace:^",
27
+ "react": "^19.2.4",
28
+ "react-dom": "^19.2.4",
29
+ "zod": "^4.6.5"
30
+ },
31
+ "devDependencies": {
32
+ "@niscorp/cli": "workspace:^",
33
+ "@niscorp/nisc": "workspace:^",
34
+ "@types/node": "^26.6.4",
35
+ "@types/react": "^19.2.14",
36
+ "@types/react-dom": "^19.2.3",
37
+ "@vitejs/plugin-react": "^5.0.4",
38
+ "tsx": "^4.23.1",
39
+ "typescript": "^6.0.2",
40
+ "vite": "^7.1.12"
41
+ }
42
+ }
@@ -0,0 +1,8 @@
1
+ import type { ActionDefinition } from '@niscorp/nova';
2
+ import { welcomeAction } from './actions/surfaces/welcome.action';
3
+
4
+ // Ring 1: every action the app ships, by id. Which of them exist for a given
5
+ // principal is the charter's answer, not this file's.
6
+ export const actions: Record<string, ActionDefinition> = {
7
+ [welcomeAction.id]: welcomeAction,
8
+ };
@@ -0,0 +1,13 @@
1
+ import type { ActionDefinition } from '@niscorp/nova';
2
+ import { welcomeLayout } from './welcome.layout';
3
+
4
+ // The first action: data with defaults, a JSON layout, and one trigger. The
5
+ // press is counted in the shell on the server — the browser only draws what
6
+ // the socket sends and sends back what was pressed.
7
+ export const welcomeAction: ActionDefinition = {
8
+ id: 'welcome',
9
+ title: 'Welcome',
10
+ data: { name: 'nisc-template-moss-react', presses: 0 },
11
+ layout: welcomeLayout,
12
+ triggers: [{ event: 'ui:click', ref: 'press', do: [{ increment: 'presses' }] }],
13
+ };