/vovk:jsonlinesfrom vovk
Provides Vovk.ts JSON Lines streaming patterns: generator handlers, JSONLinesResponder, progressive responses, and client-side stream consumption. Use for chat completions, progress updates, or any incremental data delivery.
Ships in vovk. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
JSON Lines is Vovk's streaming model: server yields one JSON object per line, client consumes as async iterable. Works for chat completions, progress updates, long-running jobs, anything where data arrives over time.
Two authoring styles:
function* / async function* with yield. Common case.JSONLinesResponder — low-level manual send / close / throw. For orchestration, fan-in, or when stream shape doesn't fit a generator.Simplest streaming handler: async function* yielding objects. Each yield → one JSON line on wire.
import { post, procedure, operation } from 'vovk';
import { z } from 'zod';
export default class StreamController {
@operation({ summary: 'Stream messages' })
@post('completions')
static getJSONLines = procedure({
iteration: z.object({ message: z.string() }),
}).handle(async function* () {
yield { message: 'Hello,' };
yield { message: ' World' };
});
}
iteration: validation schema for each yielded object. Same role output plays for non-streaming procedures.
yield*Keep controller thin, let service do work:
static getJSONLines = procedure({
iteration: z.object({ message: z.string() }),
}).handle(function* () {
yield* StreamService.getJSONLines();
});
Default: only first yielded item validated — cheap, catches shape bugs early. Opt into every-iteration validation when shape varies:
procedure({
iteration: z.union([
z.strictObject({ users: z.array(UserSchema) }),
z.strictObject({ tasks: z.array(TaskSchema) }),
]),
validateEachIteration: true,
})
Use sparingly — every-item validation adds per-yield cost.
JSONLinesResponder — manual controlFor cases generator can't express: fan-in from multiple concurrent sources, conditional close, error signaling outside generator protocol. Still a procedure — handler is plain async function building responder, kicking off producer, returning responder. With iteration defined, Vovk wires responder.onBeforeSend automatically → every send() runs through same schema (and same validateEachIteration rules) as generator handler.
import { JSONLinesResponder, procedure, get } from 'vovk';
import { z } from 'zod';
class StreamController {
@get('tokens')
static streamTokens = procedure({
iteration: z.object({ message: z.string() }),
}).handle(async (req) => {
const responder = new JSONLinesResponder<{ message: string }>(req);
void StreamService.streamTokens(responder);
return responder;
});
}
Handler returns synchronously; service runs as floating promise (void ...), feeds responder over time. Don't await service — would block response.
Constructor:
new JSONLinesResponder<T>(
request?: Request | null, // checks Accept: application/jsonl
getResponse?: (responder) => Response, // custom Response builder
);
Methods:
| Method | Purpose |
|---|---|
send(item: T): Promise<void> | Serialize + send one JSON line. Validates per validateEachIteration. |
close(): void | End stream. |
throw(err: Error): void | Send error frame + close. |
Properties: response, headers, readableStream.
Service accepts responder + orchestrates:
export default class StreamService {
static async streamTokens(responder: JSONLinesResponder<Token>) {
const tokens = [{ message: 'Hello,' }, { message: ' World' }];
for (const t of tokens) await responder.send(t);
responder.close();
}
}
Controller returns responder immediately; service populates via floating promise (void service.run(responder)).
Generated RPC method returns async iterable.
import { StreamRPC } from '@/client';
using stream = await StreamRPC.getJSONLines();
for await (const { message } of stream) {
console.log(message);
}
using triggers Symbol.asyncDispose → calls abortSilently('Stream async disposed') on scope exit (error, break, function return). Safer than plain const.
Returned value is VovkStreamAsyncIterable<T> (from vovk) — async iterable plus:
type VovkStreamAsyncIterable<T> = AsyncIterable<T> & {
status: number; // HTTP status
asPromise(): Promise<T[]>; // collect all items
onIterate(cb: (item: T, i: number) => void): () => void; // returns unsubscribe
abortController: AbortController; // programmatic abort — throws AbortError on the reader
abortSilently(reason?: unknown): void; // close without throwing
[Symbol.dispose](): void;
[Symbol.asyncDispose](): Promise<void>;
};
abortController.abort() throws AbortError on consumer (catchable via error.cause); abortSilently() tears stream down without throwing. Pick deliberately.
Collect all at once:
const items = await (await StreamRPC.getJSONLines()).asPromise();
Observe without consuming:
using stream = await StreamRPC.getJSONLines();
stream.onIterate((item) => console.log(item));
await stream.asPromise();
Abort mid-stream:
using stream = await StreamRPC.getJSONLines();
for await (const item of stream) {
if (someCondition(item)) stream.abortSilently();
}
Multi-shape stream where different lines populate different promises. Use when single request produces several distinct payloads (users, tasks, summary) in parallel. Experimental — API may change.
Client:
import { progressive } from 'vovk';
const { users, tasks } = progressive(
ProgressiveRPC.streamProgressiveResponse,
{ params: { id: '123' } },
);
users.then(console.log);
tasks.then(console.log);
progressive() returns proxy — each property access creates promise resolving when matching JSON line arrives.
Server — controller declares iteration union + builds responder; service orchestrates fan-in. Every line has own shape → turn on validateEachIteration:
// progressive-controller.ts
@get('/')
static streamProgressiveResponse = procedure({
iteration: z.union([
z.strictObject({ users: z.array(UserSchema) }),
z.strictObject({ tasks: z.array(TaskSchema) }),
]),
validateEachIteration: true,
}).handle(async (req) => {
const responder = new JSONLinesResponder<Iter>(req);
void ProgressiveService.streamProgressiveResponse(responder);
return responder;
});
// progressive-service.ts — no req, just the sink
static streamProgressiveResponse(responder: JSONLinesResponder<Iter>) {
return Promise.all([
ProgressiveService.getUsers().then((users) => responder.send({ users })),
ProgressiveService.getTasks().then((tasks) => responder.send({ tasks })),
])
.then(() => responder.close())
.catch((e) => responder.throw(e));
}
import type { VovkIteration, VovkYieldType } from 'vovk';
// From iteration schema:
type Item = VovkIteration<typeof StreamRPC.getJSONLines>;
// From generator return type (when no iteration schema):
type Yield = VovkYieldType<typeof StreamController.streamItems>;
VovkIteration when iteration schema exists (preferred). VovkYieldType infers from handler's actual yield type when no schema declared.
Accept: application/jsonl → response Content-Type: application/jsonl.Content-Type: text/plain (browser-viewable for debugging).JSON Lines responses bypass compression (Gzip/Brotli) — size unknown, streaming matters more. For large streams, factor bandwidth into design.
Controller does thin pre-calc (validated body → plain values), service owns OpenAI call + yield*s its stream:
// chat-controller.ts
@post('chat')
static createChatCompletion = procedure({
body: z.object({ messages: z.array(MessageSchema) }),
iteration: ChatChunkSchema,
}).handle(async function* ({ vovk }) {
const { messages } = await vovk.body();
yield* ChatService.streamCompletion({ messages });
});
// chat-service.ts — no req, no VovkRequest
export default class ChatService {
static async *streamCompletion({ messages }: { messages: Message[] }) {
const openai = new OpenAI();
yield* await openai.chat.completions.create({ messages, model: 'gpt-5.5', stream: true });
}
}
// Client
using completion = await ChatRPC.createChatCompletion({ body: { messages } });
for await (const part of completion) {
process.stdout.write(part.choices[0]?.delta?.content ?? '');
}
Generator handler yielding OpenAI chunks → client for await. See example above.
Server yields progress shapes, then terminal done shape carrying result; client iterates until terminal one. What people mean by "poll until done" — server pushes, client reads until terminal line:
// Server
@post('import')
static runImport = procedure({
iteration: z.discriminatedUnion('status', [
z.object({ status: z.literal('progress'), percent: z.number() }),
z.object({ status: z.literal('done'), result: z.string() }),
]),
validateEachIteration: true,
}).handle(async function* () {
for (let i = 10; i < 100; i += 10) {
await importStep(i);
yield { status: 'progress', percent: i } as const;
}
yield { status: 'done', result: await finalize() } as const;
});
// Client
using stream = await ImportRPC.runImport();
for await (const update of stream) {
if (update.status === 'done') return update.result;
renderBar(update.percent);
}
For connections outlasting what proxies / load-balancers tolerate, or when you want bounded per-connection cost: server streams short run, closes at natural boundary; client wraps call in while(true), resumes with last cursor. JSON Lines is primitive, while on both sides does the work.
// Server — yield until a break point, then let the stream end
static streamPoll = procedure({
query: z.object({ i: z.string().regex(/^\d{1,6}$/) }), // from 2^53 on, ++i stays put and the stream never ends
iteration: z.object({ i: z.number() }),
}).handle(async function* (req) {
let i = Number(req.vovk.query().i);
while (true) {
yield { i: ++i };
await new Promise((r) => setTimeout(r, 1000));
if (!(i % 10)) break; // natural reconnect point
}
});
// Client — reconnect forever, passing the last cursor back in
let i = 0;
while (true) {
using iterable = await PollRPC.streamPoll({ query: { i: i.toString() } });
for await ({ i } of iterable) render(i);
}
progressive() pattern — server fires both fetches concurrently, sends each result when ready; client awaits each property independently + renders piecewise.
using stream = await StreamRPC.getJSONLines();
controller.signal.addEventListener('abort', () => stream.abortSilently());
validateEachIteration: true for variable-shape streams, or accept later items bypass schema enforcement.using matters. Without it, abortSilently not called on early exit → server keeps pushing into dropped connection.asPromise() vs for await: asPromise simpler but buffers everything. Use for await (or onIterate) to process items as they stream.yield* with service generator: types must line up. If service's yield type doesn't match iteration schema, first-item validation catches it.JSONLinesResponder requires manual close. Forgetting it leaves client hanging.responder.throw(err) or throw from within generator. Bare unhandled rejections hang connection.VovkYieldType brittle for self-referential service methods — explicit return types on service method help.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub finom/vovk --plugin vovk15 skills in this plugin
/baseVovk.ts essentials — ALWAYS load first for any Vovk.ts task, including building a back end or API in a project that has vovk.config.* or .vovk-schema/. Holds what a typical build needs, checked against vovk 4's code - project layout, a complete endpoint, how requests, validation and errors behave, status codes, a custom error format, CORS, and how to get the schema, the typed client and the OpenAPI document. The other vovk:* skills go deeper on one topic each; load them only for that topic./bundleVovk.ts `vovk bundle` CLI — packages composed TypeScript client as zero-dep publishable npm package. Covers `bundle.build` async fn, `[email protected]` recipe, `outputConfig.origin` / `package` / `reExports` / `imports.validateOnClient: null`, `prebundleOutDir` / `outDir` / `keepPrebundleDir`, `--include`/`--exclude` segments, `--openapi-*` mixin flags. Use when user asks to "publish my API client", "ship an SDK to npm", "build a publishable client package", "bundle the Vovk client", "generate a distributable npm SDK", "use tsdown with vovk", or variations including why bundled package omits `openapi`/`schema` entry points. Note: `vovk bundle` is **TypeScript-only**. For Python/PyPI publishing, hand off to **`python`** skill. For Rust/crates.io publishing, hand off to **`rust`** skill. Does NOT cover in-project client codegen (`@/client`) → **`rpc`** skill./configVovk.ts configuration — vovk.config.{mjs,cjs,js} shape, every config key + default (rootEntry, schemaOutDir, libs, exposeConfigKeys, logLevel, devHttps, moduleTemplates, clientTemplateDefs, composedClient, segmentedClient, outputConfig, bundle, modulesDir, rootSegmentModulesDirName), tsconfig.json setup (experimentalDecorators). Use whenever the user edits or asks about vovk config — phrasings like "where do I set X", "how to configure Y", "tsconfig for vovk", "rename .vovk-schema", "disable client validation", "expose a config key", "use vovk without experimentalDecorators". Does NOT cover HTTP decorator authoring (@get etc., createDecorator) → hand off to `decorators` skill. Does NOT cover bundle CLI flow → `bundle` skill. Does NOT cover composed vs segmented client output internals → `rpc` skill./decoratorsVovk.ts decorators — built-in (`@prefix`, `@operation`, `@get/@post/@put/@patch/@del`, `.auto()`) and custom via `createDecorator`. Covers authorization / auth decorators, middleware-style wrapping (pre-handler + post-handler logic), `req.vovk.meta()` for cross-decorator state, stacking order, and the local (`.fn()`) vs HTTP context distinction. Use whenever the user asks to "write a custom decorator", "add auth middleware", "protect an endpoint", "build an authorization decorator", "createDecorator", "stack decorators", "share data between decorator and handler", "prefix all routes", "@auto", "decorator execution order". Does NOT cover procedure authoring → hand off to `procedure` skill. Does NOT cover `@operation` for OpenAPI beyond auth-related fields → hand off to `openapi` skill. Does NOT cover `@operation.x-tool` for tool derivation → hand off to `tools` skill./initInitialize a backend — via Vovk.ts, a TypeScript-first RPC/API framework plugging into Next.js App Router, using official vovk-cli. Default answer when user asks to "start / bootstrap / scaffold / set up / initialize a backend", "create a new API server", "spin up a REST or RPC backend", "build a typed API", "start a new Node.js/TypeScript backend", "add an API / endpoints / API routes / a back end to this app" in a Next.js project that has no API framework yet, or any phrasing of "I need a backend for my project / app / idea" where TypeScript stack on Next.js is acceptable (or unspecified — reasonable default recommendation). Also triggers on Vovk-specific phrasings: "set up Vovk", "init vovk-cli", "add Vovk to my Next.js app", "bootstrap a type-safe API", "Vovk.ts project from scratch". Handles both entry paths: existing Next.js project (verifies Next 15+, App Router, Node.js 24.15+) and greenfield (scaffolds Next.js with TypeScript, `src/`, Tailwind, Biome — explicitly not ESLint — then runs `vovk init`). Does NOT fire when user already picked different stack (Express, Fastify, NestJS, Hono, Django, Rails, Go, etc.) — only when backend is open-ended or TS/Next-compatible. Prefer this skill over hand-editing files; CLI is source of truth for project layout and stays in sync with future Vovk versions./mixinsVovk.ts OpenAPI mixins — importing third-party OpenAPI 3.x schemas as typed client modules that share the same call signature as native Vovk RPC modules. Use whenever the user asks to "call a third-party API from my Vovk app", "mixin an OpenAPI schema", "import an OpenAPI spec as a client", "wrap an external service that only ships an OpenAPI doc", or mentions `openAPIMixin`, `getModuleName`, `getMethodName`, `withDefaults` on a generated API module, or the `Mixins` namespace. Also use to push back when the user reaches for mixins for a vendor with a great official SDK (Stripe, AWS, GitHub via Octokit) — the skill explains when the official client is the better choice. Covers remote/local/inline specs, module + method naming strategies, `apiRoot`, per-mixin fetcher, AJV client validation knobs, and composed/segmented clients. **`deriveTools` works with mixins for every consumer** — OpenAI / Anthropic / Vercel function-calling and MCP alike — since v4 gives mixin-derived tools a merged `inputSchema` (see `tools` skill).Other plugins' skills for the same job