Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x | import { z } from "zod";
// ============================================================================
// manage_wiki - CQRS Command Tool (discriminated union schema)
// Actions: create, update, delete
// Uses z.discriminatedUnion() for type-safe action handling.
// Schema pipeline flattens to flat JSON Schema for AI clients that don't support oneOf.
// ============================================================================
// --- Shared fields ---
const namespaceField = z.string().describe("Namespace path (group or project)");
const slugField = z.string().describe("URL-encoded slug of the wiki page");
const titleField = z.string().describe("Title of the wiki page");
const contentField = z.string().describe("Content of the wiki page");
const formatField = z
.enum(["markdown", "rdoc", "asciidoc", "org"])
.optional()
.describe("Content format (markdown, rdoc, asciidoc, org). Defaults to markdown.");
// --- Action: create ---
const CreateWikiSchema = z.object({
action: z.literal("create").describe("Create a new wiki page"),
namespace: namespaceField,
title: titleField,
content: contentField,
format: formatField,
});
// --- Action: update ---
const UpdateWikiSchema = z.object({
action: z.literal("update").describe("Update an existing wiki page"),
namespace: namespaceField,
slug: slugField,
title: z.string().optional().describe("New title of the wiki page"),
content: z.string().optional().describe("New content of the wiki page"),
format: formatField,
});
// --- Action: delete ---
const DeleteWikiSchema = z.object({
action: z.literal("delete").describe("Delete a wiki page"),
namespace: namespaceField,
slug: slugField,
});
// --- Discriminated union combining all actions ---
export const ManageWikiSchema = z.discriminatedUnion("action", [
CreateWikiSchema,
UpdateWikiSchema,
DeleteWikiSchema,
]);
// ============================================================================
// Type exports
// ============================================================================
export type ManageWikiInput = z.infer<typeof ManageWikiSchema>;
|