Skip to content

Code blocks

Code blocks are rendered by Expressive Code, which Starlight bundles. Every block gets a copy button (hover or focus the block). The theme is monochrome: token kinds differ by weight and style, because colour is reserved for state.

```ts
const answer = 42;
```
const answer = 42;

A title="..." on the opening fence adds a file tab.

```ts title="knetik.module.ts"
import { defineModule } from '@knetikdotdev/sdk';
```
knetik.module.ts
import { defineModule } from '@knetikdotdev/sdk';
export default defineModule({ id: 'hello', version: '0.1.0', title: 'Hello module' /* ... */ });

Put line numbers or ranges in braces: {2,4-5}.

```ts title="module.test.ts" {2,4-5}
test('picks a greeting', async () => {
const r = await runModule(mod, { agents, input, model, gates: { choose: 'warm' } });
assert.equal(r.status, 'completed');
assert.deepEqual(Object.keys(r.artifacts).sort(),
['hello.html', 'hello.md']);
});
```
module.test.ts
test('picks a greeting', async () => {
const r = await runModule(mod, { agents, input, model, gates: { choose: 'warm' } });
assert.equal(r.status, 'completed');
assert.deepEqual(Object.keys(r.artifacts).sort(),
['hello.html', 'hello.md']);
});

Wrap text in quotes to mark it wherever it appears, or use a regular expression between slashes.

```bash "KNETIK_SECRET_KEY"
node packages/cli/src/bin.ts keygen
# prints KNETIK_SECRET_KEY=...
```
Terminal window
node packages/cli/src/bin.ts keygen
# prints KNETIK_SECRET_KEY=...

Mark lines with ins={...} and del={...}. Inserted lines get a +, deleted lines a -, in neutral tones.

```ts title="knetik.module.ts" del={2} ins={3}
connectors: {
slack: { scopes: ['chat:write'] },
slack: { scopes: ['chat:write'], required: false },
},
```
knetik.module.ts
connectors: {
slack: { scopes: ['chat:write'] },
slack: { scopes: ['chat:write'], required: false },
},

A block with the language diff uses a leading + or - on each line. Add lang="..." to also highlight the code itself.

```diff lang="json" title="package.json"
"scripts": {
- "build": "npm run build -w @knetikdotdev/web",
+ "build": "npm run build -w @knetikdotdev/web && npm run build -w @knetikdotdev/server",
"start": "node apps/server/dist/server.mjs"
}
```
package.json
"scripts": {
"build": "npm run build -w @knetikdotdev/web",
"build": "npm run build -w @knetikdotdev/web && npm run build -w @knetikdotdev/server",
"start": "node apps/server/dist/server.mjs"
}

Shell languages (bash, sh, powershell) use a terminal frame automatically. Force a frame with frame="terminal", frame="code" or frame="none".

```bash
npm run check:env
npm start
```
Terminal window
npm run check:env
npm start
Output
Your .env looks good.
mode local
agents openrouter/anthropic/claude-sonnet-5.5
A block with no frame and no title, for plain output.

Long lines scroll sideways by default. Add wrap to wrap them instead.

Terminal window
KNETIK_MODULE_CONFIG='{"content-creator":{"brandVoice":"Plain, warm and specific. No hype.","bannedTerms":"guaranteed, miracle","imageStyle":"flat, monochrome, geometric"}}'

Common languages work out of the box.

knetik.modules.json
{
"modules": [
{ "id": "hello", "version": "0.2.0", "approvedBy": "someone" }
]
}
docker-compose.yml
services:
knetik:
image: knetik:local
ports:
- "3000:3000"
Example.tsx
export function Example({ name }: { name: string }) {
return <p className="eyebrow">Hello, {name}</p>;
}

Inline code uses the mono face, for things like KNETIK_MODE=local, /api/runs and run_7f3a.