init
Initialize PolyPlan in your project by creating the required .plans and .polyplan directories for structured multi-model AI planning sessions.
Instructions
Initialize PolyPlan in this project — creates .plans/ and .polyplan/ directories
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:35-53 (registration)Registration of the 'init' MCP tool on the server via server.tool() with name 'init', description, and an inline async handler.
// ─── init ───────────────────────────────────────────────────────── server.tool( "init", "Initialize PolyPlan in this project — creates .plans/ and .polyplan/ directories", {}, async () => { const alreadyInit = await isInitialized(projectRoot); if (alreadyInit) { return { content: [{ type: "text", text: "PolyPlan is already initialized in this project." }] }; } const config = await initProject(projectRoot); return { content: [{ type: "text", text: `✅ PolyPlan initialized!\n📁 Project: ${config.projectName}\n📂 Created .plans/ and .polyplan/\n🕐 Session started: ${config.createdAt}`, }], }; } ); - src/core/session.ts:74-91 (handler)Core implementation of initProject(): creates .plans/ and .polyplan/ directories, writes config.json, and updates .gitignore.
export async function initProject(projectRoot: string): Promise<PolyPlanConfig> { // Create directories const plansPath = path.join(projectRoot, PLANS_DIR); await fs.mkdir(plansPath, { recursive: true }); await ensurePolyPlanDir(projectRoot); // Create config const projectName = path.basename(projectRoot); const config: PolyPlanConfig = { projectName, createdAt: new Date().toISOString(), }; await writeConfig(projectRoot, config); // Update .gitignore await updateGitignore(projectRoot); return config; - src/core/session.ts:97-100 (handler)Helper isInitialized() checks whether .polyplan/config.json already exists.
export async function isInitialized(projectRoot: string): Promise<boolean> { const config = await readConfig(projectRoot); return config !== null; } - src/types.ts:44-51 (schema)PolyPlanConfig interface: defines the shape of the config object created by init.
export interface PolyPlanConfig { /** Human-readable project name */ projectName: string; /** When the session was first created */ createdAt: string; /** Current active problem description (set in Round 1) */ problemDescription?: string; } - src/core/session.ts:15-19 (helper)ensurePolyPlanDir() creates the .polyplan/ directory if it doesn't exist.
export async function ensurePolyPlanDir(projectRoot: string): Promise<string> { const polyplanPath = path.join(projectRoot, POLYPLAN_DIR); await fs.mkdir(polyplanPath, { recursive: true }); return polyplanPath; }