Initialize Wiki
wiki.initScaffold a wiki layout in your Obsidian vault, generating Sources/, Concepts/, Entities/ folders and seed index, log, schema files. Idempotent; force re-seeds.
Instructions
Scaffold the wiki layout: Sources/, Concepts/, Entities/ folders plus seed index.md, log.md, and wiki-schema.md. Idempotent; use force:true to re-seed index/log/schema files.
Operates on the session-active vault (see vault.current — selectable via vault.select) unless an explicit vaultPath argument is passed, which always wins.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| wikiRoot | No | ||
| force | No | ||
| vaultPath | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| changed | Yes | True if the tool altered vault state on this call; false if it was a no-op. | |
| target | Yes | The path or identifier the tool acted on. | |
| summary | Yes | Short human-readable summary of what happened. |
Implementation Reference
- src/domain/wiki/init.ts:104-149 (handler)The main handler function for wiki.init. Creates the wiki folder structure (Sources/, Concepts/, Entities/) and seeds index.md, log.md, and wiki-schema.md. Supports force re-seeding via the force flag.
export async function initWiki(context: DomainContext, args: WikiInitArgs) { const paths = resolveWikiPaths(context, args); const force = args.force ?? false; const created: string[] = []; const folders: Array<{ absolute: string; relative: string }> = [ { absolute: paths.rootAbsolute, relative: paths.rootRelative }, { absolute: paths.sourcesAbsolute, relative: paths.sourcesRelative }, { absolute: paths.conceptsAbsolute, relative: paths.conceptsRelative }, { absolute: paths.entitiesAbsolute, relative: paths.entitiesRelative }, ]; for (const { absolute, relative } of folders) { if (await fileExists(absolute)) continue; await ensureDir(absolute); created.push(relative); } const seeds: Array<{ absolute: string; relative: string; content: string }> = [ { absolute: paths.indexAbsolute, relative: paths.indexRelative, content: INDEX_SEED }, { absolute: paths.logAbsolute, relative: paths.logRelative, content: LOG_SEED }, { absolute: paths.schemaAbsolute, relative: paths.schemaRelative, content: SCHEMA_SEED }, ]; for (const seed of seeds) { const existed = await fileExists(seed.absolute); if (existed && !force) continue; await writeUtf8(seed.absolute, seed.content); if (!existed) created.push(seed.relative); } const changed = created.length > 0 || force; return { changed, target: paths.rootRelative, summary: created.length > 0 ? `Initialized wiki at ${paths.rootRelative} (${created.length} new)` : force ? `Re-seeded wiki at ${paths.rootRelative}` : `Wiki at ${paths.rootRelative} already initialized`, created, wikiRoot: paths.rootRelative, force, }; } - src/schema/wiki.ts:55-60 (schema)Zod schema (wikiInitArgsSchema) for wiki.init input: optional wikiRoot override, force boolean, and vaultPath.
export const wikiInitArgsSchema = z.object({ wikiRoot: wikiRootOverrideSchema, force: z.boolean().optional(), vaultPath: z.string().optional(), }); export type WikiInitArgs = z.input<typeof wikiInitArgsSchema>; - src/server/tools/wiki.ts:29-38 (registration)Tool registration for wiki.init in the wikiTools array with name, title, description, schemas, annotations, and handler delegating to initWiki.
{ name: "wiki.init", title: "Initialize Wiki", description: "Scaffold the wiki layout: Sources/, Concepts/, Entities/ folders plus seed index.md, log.md, and wiki-schema.md. Idempotent; use force:true to re-seed index/log/schema files.", inputSchema: wikiInitArgsSchema, outputSchema: mutationResultSchema, annotations: IDEMPOTENT, handler: (context, args) => initWiki(context, args as Parameters<typeof initWiki>[1]), }, - src/domain/wiki/paths.ts:49-89 (helper)resolveWikiPaths helper used by initWiki to resolve all wiki folder and file paths based on context and args.
export function resolveWikiPaths( context: DomainContext, args: ResolveWikiPathsArgs = {}, ): WikiPaths { const vaultRoot = requireVaultPath(context, args.vaultPath); const rootRelative = sanitizeWikiRoot(args.wikiRoot ?? context.env.KOBSIDIAN_WIKI_ROOT); const rootAbsolute = resolveVaultPath(vaultRoot, rootRelative); const sourcesDirName = context.env.KOBSIDIAN_WIKI_SOURCES_DIR; const conceptsDirName = context.env.KOBSIDIAN_WIKI_CONCEPTS_DIR; const entitiesDirName = context.env.KOBSIDIAN_WIKI_ENTITIES_DIR; const indexFileName = context.env.KOBSIDIAN_WIKI_INDEX_FILE; const logFileName = context.env.KOBSIDIAN_WIKI_LOG_FILE; const schemaFileName = context.env.KOBSIDIAN_WIKI_SCHEMA_FILE; const join = (...parts: string[]) => parts.join("/"); return { vaultRoot, rootRelative, rootAbsolute, sourcesDirName, conceptsDirName, entitiesDirName, indexFileName, logFileName, schemaFileName, sourcesRelative: join(rootRelative, sourcesDirName), conceptsRelative: join(rootRelative, conceptsDirName), entitiesRelative: join(rootRelative, entitiesDirName), indexRelative: join(rootRelative, indexFileName), logRelative: join(rootRelative, logFileName), schemaRelative: join(rootRelative, schemaFileName), sourcesAbsolute: path.join(rootAbsolute, sourcesDirName), conceptsAbsolute: path.join(rootAbsolute, conceptsDirName), entitiesAbsolute: path.join(rootAbsolute, entitiesDirName), indexAbsolute: path.join(rootAbsolute, indexFileName), logAbsolute: path.join(rootAbsolute, logFileName), schemaAbsolute: path.join(rootAbsolute, schemaFileName), }; } - src/domain/wiki/schema.ts:46-57 (helper)Helper functions providing body skeletons for source/concept/entity pages (not directly called by initWiki, but part of wiki domain schema utilities).
export function sourceBodySkeleton(): string { return SOURCE_SKELETON; } export function conceptBodySkeleton(): string { return CONCEPT_SKELETON; } export function entityBodySkeleton(): string { return ENTITY_SKELETON; }