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,52 @@
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 { shell } from '../app/shell/shell';
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
+ // The first thing in a value that is not JSON, as a path — or '' when all of it is.
17
+ const impurity = (value: unknown, path: string): string => {
18
+ if (value === null || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') return '';
19
+ if (Array.isArray(value)) return value.map((item, at) => impurity(item, `${path}[${at}]`)).find((found) => found !== '') ?? '';
20
+ if (typeof value !== 'object') return `${path} is a ${typeof value}`;
21
+ if (Object.getPrototypeOf(value) !== Object.prototype) return `${path} is not a plain object`;
22
+ return Object.entries(value).map(([key, inner]) => impurity(inner, path === '' ? key : `${path}.${key}`)).find((found) => found !== '') ?? '';
23
+ };
24
+ const pure = (name: string, value: unknown): void => {
25
+ const found = impurity(value, '');
26
+ check(`${name} is pure JSON`, found === '', found);
27
+ };
28
+ const parses = (name: string, parse: () => unknown): void => {
29
+ try {
30
+ parse();
31
+ check(`${name} parses its schema`, true);
32
+ } catch (error) {
33
+ check(`${name} parses its schema`, false, error instanceof Error ? error.message.slice(0, 300) : String(error));
34
+ }
35
+ };
36
+ const isRecord = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null && !Array.isArray(value);
37
+
38
+ pure('the action catalog', actions);
39
+ pure('the shell', shell);
40
+ parses('the shell’s frame', () => LayoutNodeSchema.parse(shell.canvasLayout));
41
+
42
+ for (const [id, definition] of Object.entries(actions)) {
43
+ check(`action "${id}" is catalogued under its own id`, definition.id === id, `its id is "${definition.id}"`);
44
+ parses(`action "${id}"`, () => ActionDefinitionSchema.parse(definition));
45
+ // rule 14: what an opener may seed is a subset of the action's data
46
+ const properties = isRecord(definition.input) && isRecord(definition.input['properties']) ? Object.keys(definition.input['properties']) : [];
47
+ const unknown = properties.filter((key) => !(key in (definition.data ?? {})));
48
+ check(`action "${id}" declares only inputs its data has`, unknown.length === 0, unknown.join(', '));
49
+ }
50
+
51
+ console.log(failures === 0 ? '[pass] artifacts: all checks passed' : `[fail] artifacts: ${failures} check(s) failed`);
52
+ 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,26 @@
1
+ import { shellSettled } from '@niscorp/nova';
2
+ import { boot } from '../boot';
3
+
4
+ // The welcome screen, with no browser: the app's own boot, its first screen
5
+ // whole, and a press reaching the shell. One `[pass]`/`[fail]` line per
6
+ // assertion; any failure exits non-zero (AGENTS.md, "Verification"). Whether
7
+ // the screen draws and is picked up in a page is `nisc build`'s to check.
8
+
9
+ let failures = 0;
10
+ const check = (name: string, passed: boolean, detail = ''): void => {
11
+ console.log(`${passed ? '[pass]' : '[fail]'} ${name}${!passed && detail !== '' ? ` — ${detail}` : ''}`);
12
+ if (!passed) failures += 1;
13
+ };
14
+
15
+ const shell = boot();
16
+ check('the first screen is whole', await shellSettled(shell));
17
+ const active = shell.getState().canvases['main']?.active;
18
+ check('the welcome action opens on the main canvas', active?.definitionId === 'welcome', String(active?.definitionId));
19
+
20
+ shell.dispatch({ type: 'ui:click', ref: 'press', ...(active !== undefined ? { origin: active.id } : {}) });
21
+ await new Promise((done) => setTimeout(done, 20));
22
+ const presses = shell.getRuntime(active?.id ?? '')?.getData()['presses'];
23
+ check('a press reaches the shell', presses === 1, `presses is ${String(presses)}`);
24
+
25
+ console.log(failures === 0 ? '[pass] welcome: all checks passed' : `[fail] welcome: ${failures} check(s) failed`);
26
+ process.exit(failures === 0 ? 0 : 1);
@@ -0,0 +1,25 @@
1
+ import { createRoot } from 'react-dom/client';
2
+ import { shellSettled } from '@niscorp/nova';
3
+ import { boot } from './boot';
4
+ import { Screen, adopt } from './ui/screen';
5
+ import './ui/kit.css';
6
+
7
+ // The entry: boot the shell, then one of two things —
8
+ //
9
+ // the screen ARRIVED DRAWN (`nisc export` or `nisc start` wrote it into the
10
+ // root): the shell reaches that same screen, and picks the elements up as
11
+ // they are;
12
+ //
13
+ // the root is empty (dev): the screen is rendered from nothing.
14
+ //
15
+ // Either way the shell is this page's own from here on.
16
+ const root = document.getElementById('root');
17
+ if (root === null) throw new Error('index.html has no #root');
18
+
19
+ const shell = boot();
20
+ if (root.hasChildNodes()) {
21
+ await shellSettled(shell, { waitMs: 10_000 });
22
+ adopt(root, shell);
23
+ } else {
24
+ createRoot(root).render(<Screen shell={shell} />);
25
+ }
@@ -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,49 @@
1
+ import { z } from 'zod';
2
+ import { useNovaDispatch } from '@niscorp/nova/adapters/react';
3
+ import type { NovaComponent } from '@niscorp/nova/adapters/react';
4
+
5
+ // ═══════════════════════════════════════════════════════════
6
+ // The kit: domain-blind primitives. Props in, events out. Each one is
7
+ // CONFIGURED, never styled — it reads what a thing is (a tone, a level) from a
8
+ // closed set of names, and anything it does not know falls back to the default.
9
+ // The look lives in kit.css alone.
10
+ //
11
+ // Every prop a layout passes is parsed here, at the boundary (rule 13); a
12
+ // layout that names an unknown value gets the default, never a crash.
13
+ // ═══════════════════════════════════════════════════════════
14
+
15
+ const parsed = <T,>(schema: z.ZodType<T>, props: unknown, fallback: T): T => {
16
+ const result = schema.safeParse(props);
17
+ return result.success ? result.data : fallback;
18
+ };
19
+
20
+ const PageProps = z.object({}).describe('The page: a centred column with the app’s background.');
21
+ export const Page: NovaComponent = ({ children }) => <main className="k-page">{children}</main>;
22
+ Page.meta = { description: 'The page: a centred column.', propsSchema: PageProps };
23
+
24
+ const RowProps = z.object({}).describe('Children side by side, centred.');
25
+ export const Row: NovaComponent = ({ children }) => <div className="k-row">{children}</div>;
26
+ Row.meta = { description: 'Children side by side.', propsSchema: RowProps };
27
+
28
+ const HeadingProps = z.object({}).describe('The page’s title.');
29
+ export const Heading: NovaComponent = ({ children }) => <h1 className="k-heading">{children}</h1>;
30
+ Heading.meta = { description: 'The page’s title.', propsSchema: HeadingProps };
31
+
32
+ const TextProps = z.object({ tone: z.enum(['default', 'muted']).optional().describe('default | muted') });
33
+ export const Text: NovaComponent = ({ children, novaRef: _ref, novaModel: _model, ...props }) => {
34
+ const { tone } = parsed(TextProps, props, {});
35
+ return <p className={tone === 'muted' ? 'k-text k-muted' : 'k-text'}>{children}</p>;
36
+ };
37
+ Text.meta = { description: 'A paragraph.', propsSchema: TextProps };
38
+
39
+ const ButtonProps = z.object({ label: z.string().optional().describe('What the button says; falls back to its children.') });
40
+ export const Button: NovaComponent = ({ children, novaRef, novaModel: _model, ...props }) => {
41
+ const dispatch = useNovaDispatch();
42
+ const { label } = parsed(ButtonProps, props, {});
43
+ return (
44
+ <button type="button" className="k-button" data-ref={novaRef} onClick={() => dispatch({ type: 'ui:click', ...(novaRef !== undefined ? { ref: novaRef } : {}) })}>
45
+ {label ?? children}
46
+ </button>
47
+ );
48
+ };
49
+ Button.meta = { description: 'A button; dispatches ui:click with its ref.', propsSchema: ButtonProps };
@@ -0,0 +1,14 @@
1
+ import { createComponentRegistry } from '@niscorp/nova';
2
+ import type { ComponentRegistry } from '@niscorp/nova';
3
+ import { ActionSlot, CanvasSlot } from '@niscorp/nova/adapters/react/components';
4
+ import type { NovaComponent } from '@niscorp/nova/adapters/react';
5
+ import { Button, Heading, Page, Row, Text } from './kit';
6
+
7
+ // The one registry, assembled once (rule 2): nova's two slot markers, then the
8
+ // kit. Every component a layout may name is here, and nothing else is.
9
+ export const buildRegistry = (): ComponentRegistry<NovaComponent> => {
10
+ const registry = createComponentRegistry<NovaComponent>();
11
+ registry.registerAll({ CanvasSlot, ActionSlot });
12
+ registry.registerAll({ Page, Row, Heading, Text, Button });
13
+ return registry;
14
+ };
@@ -0,0 +1,15 @@
1
+ import { hydrateRoot } from 'react-dom/client';
2
+ import { NovaShell } from '@niscorp/nova/adapters/react';
3
+ import type { Shell } from '@niscorp/nova';
4
+
5
+ // The screen: the shell's frame and canvases, drawn with the shell's own kit.
6
+ // Drawn three ways from this one description — to markup at build
7
+ // (nisc.config.ts), over that markup in the page (`adopt`), and from nothing
8
+ // in dev (src/main.tsx).
9
+ export const Screen = ({ shell }: { shell: Shell }): React.JSX.Element => <NovaShell shell={shell} />;
10
+
11
+ // Pick up a screen that arrived drawn — the one call both the page and the
12
+ // build's adoption check make.
13
+ export const adopt = (root: HTMLElement, shell: Shell): void => {
14
+ hydrateRoot(root, <Screen shell={shell} />);
15
+ };
@@ -0,0 +1,6 @@
1
+ {
2
+ "grammar": {
3
+ "nisc.nova": 2,
4
+ "nisc.prism": 1
5
+ }
6
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "lib": [
7
+ "DOM",
8
+ "DOM.Iterable",
9
+ "ES2022"
10
+ ],
11
+ "jsx": "react-jsx",
12
+ "strict": true,
13
+ "noUncheckedIndexedAccess": true,
14
+ "verbatimModuleSyntax": true,
15
+ "isolatedModules": true,
16
+ "skipLibCheck": true,
17
+ "noEmit": true,
18
+ "types": [
19
+ "node",
20
+ "vite/client"
21
+ ]
22
+ },
23
+ "include": [
24
+ "src",
25
+ "nisc.config.ts",
26
+ "vite.config.ts"
27
+ ]
28
+ }
@@ -0,0 +1,9 @@
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
+ import react from '@vitejs/plugin-react';
5
+
6
+ // The bundle IS the app: the shell, its actions and its kit all run in the page.
7
+ export default defineConfig({
8
+ plugins: [react()],
9
+ });