shtukbasehub

The kit components

The components package of the Shtukbase kit: the classes and blocks every page and lens uses (page base, header, chips, links, card, markdown, board, gallery, page column) and page.js for the light or dark theme. Uses only CSS variables; the values come from the space's style package.

Packagecomponents-kitv0.1.07 files

The design kit: style packages and components packages

The look of every Shtukbase page (the layouts, the lenses, the reports, the landing, the site gallery) comes from two packages, and nothing else names a colour:

KindDeclared in package.mdHoldsExamples
stylecontributes: [{style: style.css}]CSS variables only — colours, fonts, radii, shadows, hues, color-scheme — on :root (light) and :root[data-theme="dark"] (dark)style-desktop (default), style-calm
componentscontributes: [{components: components.css, script: page.js}] (script optional)classes and blocks that use only variables; page.js sets the light or dark themecomponents-kit

A space has one active style and one active components package: the keys style: and components: in the front matter of the space head (base/project.md, else index.md). Defaults: style-desktop, components-kit.

---
type: Space
title: "Моя студия"
style: style-calm          # optional; default style-desktop
components: components-kit # optional; default components-kit
---

To replace the theme, install another style package and change style:. To replace the components, install another components package (same class names, same variable contract) and change components:. Pages do not change.

The contract between the two is the variable list in style-desktop/package.md; test/kit.test.ts checks that every style defines every variable the components use, that a style holds only variables, and that the components hold no colour.

Stable addresses

Every page links exactly these (the order: components, then style, then the page's own CSS):

<link rel="stylesheet" href="/_kit/components.css">
<link rel="stylesheet" href="/_kit/style.css">
<script src="/_kit/page.js"></script>   <!-- pages that are not lenses; a lens takes the theme from its layout (lens.js) -->

The host maps them: /_kit/style.css → the active style's style file, /_kit/components.css and /_kit/page.js → the active components package's components and script files (both under .shtukbase/packages/<id>/). Any other /_kit/<path> is still design/kit-style/<path> (the compatibility package), so old pages keep working. shtuk serve reads the setting on every request (change it, reload: the space restyles); the cloud deploy reads it when it builds (change it, deploy again).

Outside a host

A page opened from disk or from a plain static server cannot reach /_kit/. It links the package files by a relative path instead, and so fixes the style in the link:

<!-- in this repository, from apps/standard/packages/<pkg>/<dir>/page.html -->
<link rel="stylesheet" href="../../components-kit/components.css">
<link rel="stylesheet" href="../../style-desktop/style.css">
<!-- in an installed space, from <space>/<dir>/page.html -->
<link rel="stylesheet" href="../.shtukbase/packages/components-kit/components.css">
<link rel="stylesheet" href="../.shtukbase/packages/style-desktop/style.css">

A page that is both served and opened from disk (the chat lens) links the stable addresses with data-kit and, when not hosted, rewrites them: components.css → <rel>/components-kit/components.css, style.css → <rel>/style-desktop/style.css (see chat/lens/chat.html). pages-kit-check accepts all three forms as wearing the kit.

The landing and the site gallery

The landing (shtuks/projects/shtukbase/assets/logo/landing-*.html) is a set of files in the repository opened from disk or a static server. Replace its palette.css link with the kit and keep its layout file:

<link rel="stylesheet" href="../../../../../apps/standard/packages/components-kit/components.css">
<link rel="stylesheet" href="../../../../../apps/standard/packages/style-desktop/style.css">
<link rel="stylesheet" href="landing-base.css">   <!-- its layout; colours only through var(--…) -->
<script src="../../../../../apps/standard/packages/components-kit/page.js"></script>

When the landing is published by the site build, it is served like the site (below) and links /_kit/… instead.

The site gallery (apps/site) builds static pages. Its build copies the active packages to the stable addresses of its output and its pages link them:

// apps/site/build.ts — in place of the kit-style copy
const STYLE = process.env.SITE_STYLE ?? 'style-desktop';
copyText(join(PACKAGES, 'components-kit/components.css'), '_kit/components.css');
copyText(join(PACKAGES, 'components-kit/page.js'), '_kit/page.js');
copyText(join(PACKAGES, STYLE, 'style.css'), '_kit/style.css');
<!-- apps/site/src/html.ts -->
<link rel="stylesheet" href="/_kit/components.css">
<link rel="stylesheet" href="/_kit/style.css">
<script src="/_kit/page.js"></script>

The site now wears the keer skin; that becomes a style package style-keer (from kit-style/skins/keer.css, made the same way as style-desktop), and SITE_STYLE=style-keer keeps its look.

The host patch

The hosts (apps/shtuk, apps/cloud) need this change to know the two new kinds and map the stable addresses (against main at 4e68a15bdd; the contributes parser lives twice, in manifest.ts and core/packages.ts). Until it lands, installing a style or components package fails with "a contribution needs …", and the registry skips them.

--- a/apps/shtuk/src/manifest.ts	2026-11-29 07:48:54
+++ b/apps/shtuk/src/manifest.ts	2026-11-29 07:51:55
@@ -17,7 +17,8 @@
 /** When an action runs by itself: after the files of a new install or of a new version are laid (only for a trusted package). */
 export type Event = 'install' | 'update';
 export type Slot = 'main' | 'panel';
-export type Contribution = { layout: string } | { lens: string; file: string; title: string; for: string; slot: Slot };
+export type Contribution = { layout: string } | { lens: string; file: string; title: string; for: string; slot: Slot }
+  | { style: string } | { components: string; script?: string };
 export type Pkg = {
   id: string;
   version: string;
@@ -166,7 +167,9 @@
       if (slot !== 'main' && slot !== 'panel') throw new Fail(`${at}: slot must be main or panel`);
       return { lens: c.lens, file: pagePath(c.file), title: c.title, for: c.for, slot };
     }
-    throw new Fail(`${at}: a contribution needs "layout" or "lens", "file", "title" and "for"`);
+    if (typeof c?.style === 'string') return { style: pagePath(c.style) };
+    if (typeof c?.components === 'string') return { components: pagePath(c.components), ...(typeof c.script === 'string' ? { script: pagePath(c.script) } : {}) };
+    throw new Fail(`${at}: a contribution needs "layout", "style", "components" or "lens", "file", "title" and "for"`);
   });
 }
 
@@ -187,7 +190,7 @@
     if (!statSync(manifest, { throwIfNoEntry: false })?.isFile()) continue;
     for (const c of parseContributes(parseHead(readFileSync(manifest, 'utf8'), manifest).contributes, manifest)) {
       if ('layout' in c) layouts.push({ package: id, file: c.layout });
-      else { const { lens, ...rest } = c; lenses.push({ id: lens, package: id, ...rest }); }
+      else if ('lens' in c) { const { lens, ...rest } = c; lenses.push({ id: lens, package: id, ...rest }); }
     }
   }
   const names = layouts.map((l) => l.package).join(', ');
@@ -248,3 +251,19 @@
   }
   return ids.sort();
 }
+
+/** The kit's stable addresses /_kit/style.css, /_kit/components.css and /_kit/page.js: the path (package id, then the
+ * file) of the space's active style or components package: keys `style` and `components` of the space head, defaults
+ * style-desktop and components-kit. Undefined for another name or a package that is not installed. */
+export function kitFile(packagesDir: string, space: Record<string, unknown>, name: string): string[] | undefined {
+  const kind = name === 'style.css' ? 'style' : name === 'components.css' || name === 'page.js' ? 'components' : undefined;
+  if (!kind) return undefined;
+  const id = String(space[kind] ?? (kind === 'style' ? 'style-desktop' : 'components-kit'));
+  const manifest = join(packagesDir, id, 'package.md');
+  if (!isId(id) || !statSync(manifest, { throwIfNoEntry: false })?.isFile()) return undefined;
+  for (const c of parseContributes(parseHead(readFileSync(manifest, 'utf8'), manifest).contributes, manifest) as Record<string, string>[]) {
+    const file = name === 'page.js' ? c.script : c[kind];
+    if (file) return [id, ...file.split('/')];
+  }
+  return undefined;
+}
--- a/apps/shtuk/src/core/packages.ts	2026-11-29 07:48:54
+++ b/apps/shtuk/src/core/packages.ts	2026-11-29 07:58:35
@@ -109,7 +109,7 @@
     const lenses = [...info.lenses];
     for (const pkg of await installed()) {
       for (const contribution of pkg.contributes) {
-        if ('layout' in contribution) continue;
+        if (!('lens' in contribution)) continue;
         const { lens: id, ...rest } = contribution;
         if (!lenses.some((item) => item.package === pkg.id && item.id === id && item.file === rest.file)) {
           lenses.push({ id, package: pkg.id, ...rest });
@@ -374,7 +374,9 @@
       if (slot !== 'main' && slot !== 'panel') throw new Fail(`${at}: slot must be main or panel`);
       return { lens: c.lens, file: pagePath(c.file), title: c.title, for: c.for, slot };
     }
-    throw new Fail(`${at}: a contribution needs "layout" or "lens", "file", "title" and "for"`);
+    if (typeof c?.style === 'string') return { style: pagePath(c.style) };
+    if (typeof c?.components === 'string') return { components: pagePath(c.components), ...(typeof c.script === 'string' ? { script: pagePath(c.script) } : {}) };
+    throw new Fail(`${at}: a contribution needs "layout", "style", "components" or "lens", "file", "title" and "for"`);
   });
 }
 
--- a/apps/shtuk/src/serve.ts	2026-11-29 07:48:54
+++ b/apps/shtuk/src/serve.ts	2026-11-29 07:51:55
@@ -8,7 +8,7 @@
 import { diskPath, makeFsStore } from './core/store-fs.ts';
 import { Fail } from './fail.ts';
 import { lockDir } from './lock.ts';
-import { isId, parseHead, spaceParts } from './manifest.ts';
+import { isId, kitFile, parseHead, spaceParts } from './manifest.ts';
 
 const packageRoot = [lockDir, 'packages'];
 const notFound = () => new Response('Not found', { status: 404 });
@@ -91,7 +91,11 @@
             if (segments.some((part) => part.includes('/')) || !isSpacePath('/' + segments.join('/'))) return notFound();
             const [mount, ...rest] = segments;
             if (mount === '_pkg' && rest.length >= 2 && isId(rest[0])) parts = [...packageRoot, ...rest];
-            else if (mount === '_kit' && rest.length) parts = ['design', 'kit-style', ...rest];
+            else if (mount === '_kit' && rest.length) {
+              const project = (await store.get('/base/project.md')) ?? (await store.get('/index.md'));
+              const kit = rest.length === 1 ? kitFile(diskPath(root, packageRoot).path, project === null ? {} : parseHead(project, 'base/project.md'), rest[0]) : undefined;
+              parts = kit ? [...packageRoot, ...kit] : ['design', 'kit-style', ...rest];
+            }
             else return notFound();
           }
           const located = diskPath(root, parts);
--- a/apps/cloud/deploy.ts	2026-11-29 07:48:54
+++ b/apps/cloud/deploy.ts	2026-11-29 07:52:10
@@ -5,7 +5,7 @@
 import { basename, dirname, extname, join } from 'node:path';
 import { parseArgs } from 'node:util';
 import { installedLightChecks } from '../shtuk/src/check.ts';
-import { isId, spaceParts } from '../shtuk/src/manifest.ts';
+import { isId, kitFile, parseHead, spaceParts } from '../shtuk/src/manifest.ts';
 import { openProject } from '../shtuk/src/project.ts';
 import type { Host } from '../shtuk/src/core/api.ts';
 import { isSpacePath } from '../shtuk/src/core/store.ts';
@@ -46,6 +46,11 @@
   copyFileSync(join(assets, '_pkg', layout.package, layout.file), join(assets, 'index.html'));
   const kit = join(dir, 'design/kit-style');
   if (existsSync(kit)) copy(kit, join(assets, '_kit'));
+  const head = ['base/project.md', 'index.md'].map((f) => join(dir, f)).find((f) => existsSync(f));
+  for (const name of ['style.css', 'components.css', 'page.js']) {
+    const file = kitFile(packages, head ? parseHead(readFileSync(head, 'utf8'), head) : {}, name);
+    if (file) { mkdirSync(join(assets, '_kit'), { recursive: true }); copyFileSync(join(packages, ...file), join(assets, '_kit', name)); }
+  }
   const info: Info = { name: spaceName, layout, lenses };
   const checks = installedLightChecks(dir);
   if (checks.length) {

Old design packages

PackageFate
kit-stylecompatibility: requires components-kit, style-desktop, style-calm; its files (kit.css, skins/*.css, page.js) stay at /_kit/<path> for pages not yet moved; frozen, retired when no page links them
keer-stylebecomes a style: style-keer (its tokens already make kit-style/skins/keer.css)
shtukbase-stylebecomes a style: style-shtukbase (from kit-style/skins/shtukbase.css and its tokens)
design-scalesfolded into the styles (spacing, type, radii are variables); retired
explore-kitits panel becomes a block of components-kit; retired as a separate style
shtukbase-ui-htmla components package on a different contract (shadcn names); retired, its blocks move into components-kit when needed
design-tokenskept as a tool (DTCG tokens → a style package's variables, the contract check); not itself a style
design-a11ykept as a check; it should run on every style package (contrast of --ink/--bg and the chips)
design-base, design-components, design-lensesretired from page styling: they describe the React/shadcn design system and lens design docs; kept as documentation
shtukbase-ui-react, keer-ui, shadcnReact component libraries, not the HTML kit; out of this model
icons, shtukbase-iconskept: icons are not style
lenseskept; its lib/kit.css build reads kit-style today and should read components-kit + the active style next

Nothing is deleted.