Themes and plugins
Three commands help you write a theme or a plugin. They are not for a server. They run in a TomeCMS source checkout, with npm run tome --, need no sudo, and say Run this in a TomeCMS source checkout. and exit 1 anywhere else. Only the checkout’s own src/cli/main.ts runs them, so the tome installed on a server always refuses, even in its release clone at /opt/tome-cms-src. The server commands keep their sudo, and the two groups do not mix.
npm run tome -- theme new <id> [--from plain|paper|almanac] [--dry-run]npm run tome -- plugin new <id> --hook publicPage|signIn|editorSuggestions [--client] [--dry-run]npm run tome -- checktheme newcopies an existing theme under a new id and registers it. Writing a theme says what it renames.plugin newwrites a plugin that fills its hook and does nothing yet, switched off. Writing a plugin shows what it writes.checkchecks every theme and plugin, and prints each problem aspath:line: what is wrong. It changes nothing. It exits 0 when it found none and 1 when it found any.npm run checkruns it, so CI stops a mistake before it is merged.
check looks for these:
- a theme or plugin whose directory name is not its manifest’s id;
- one that is not listed in both its
manifests.tsand itsregistry.ts, or a list entry with no directory; - a missing file: a theme needs
index.ts,theme.ts,Shell.astro,Home.astro,Post.astro,Page.astroandtheme.css; a plugin needsplugin.tsandindex.ts, andclient.tswhen it has apublicClient; - a setting that is not well formed: a repeated key, a kind the contract does not allow, a label or hint missing in English or Thai, a choice without options or whose fallback is not one of them, a theme’s text setting without a maximum length (a plugin’s text has none in its contract), a switch whose fallback is not
onoroff; - a plugin whose
index.tsdoes not export the sign-in pair every plugin answers, or a method of each hook it declares; - a theme that imports from
src/server/orsrc/pages/; - a raw colour in a theme’s CSS outside a token block. A raw colour is a hex such as
#c00, orrgb(),hsl(),hwb(),oklch(),oklab(),lab(),lch()orcolor(). A token block is a rule whose own declarations are all custom properties, such as--color-ink: oklch(24% 0.012 70);; a rule nested inside it is checked on its own. Everywhere else the stylesheet usesvar(--color-ink). Comments are not read, and neither is a colour name such asred. - a font a theme’s manifest preloads, in
preloadFonts, that is not a.woff2file inpublic/fonts/.
It does not run a plugin. It imports each manifest and each plugin’s index.ts, as the core does, and calls nothing in them. Any way of exporting a method counts, including export * from './hooks'. A method that is only on the default export object does not count, because the core uses the module’s named exports.
A checkout with nothing wrong:
$ npm run tome -- checkChecked 3 themes and 6 plugins: no problems.A plugin made with plugin new nimbus --hook publicPage, with export then taken off the siteNotice line of its index.ts, and settings: [], in its plugin.ts replaced by a setting with no Thai label:
settings: [ { key: 'message', kind: 'text', label: { en: 'Message', th: '' }, required: false }, ],$ npm run tome -- checksrc/plugins/nimbus/plugin.ts:11: setting "message" has no Thai labelsrc/plugins/nimbus/index.ts:1: declares publicPage, but exports none of siteNotice, sitePopup, publicClient2 problems.npm run tome -- --help lists them, and every command takes --help.

