init
Initialize OSS Autopilot with your GitHub username. This creates the state file and sets up initial configuration for managing open source contributions.
Instructions
Initialize OSS Autopilot with a GitHub username. Creates the state file and sets up initial configuration.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes | Your GitHub username |
Implementation Reference
- packages/core/src/commands/init.ts:22-33 (handler)The core handler function `runInit` that executes the 'init' tool logic. It validates the GitHub username and updates the config with it via `stateManager.updateConfig`.
export async function runInit(options: { username: string }): Promise<InitOutput> { validateGitHubUsername(options.username); const stateManager = getStateManager(); // Set username in config stateManager.updateConfig({ githubUsername: options.username }); return { username: options.username, message: 'Username saved. Run `daily` to fetch your open PRs from GitHub.', }; } - The `InitOutput` type interface defining the return shape (username and message strings).
export interface InitOutput { username: string; message: string; } - packages/mcp-server/src/tools.ts:397-409 (registration)The MCP tool registration for 'init'. Registers the tool with the server using name 'init', a description, a Zod inputSchema for `username`, and wraps `runInit` via `wrapTool`.
// 12. init — Initialize with GitHub username server.registerTool( 'init', { description: 'Initialize OSS Autopilot with a GitHub username. Creates the state file and sets up initial configuration.', inputSchema: { username: z.string().describe('Your GitHub username'), }, annotations: { readOnlyHint: false, destructiveHint: false }, }, wrapTool(runInit), ); - The input schema for the 'init' tool, requiring a single `username` string parameter described as 'Your GitHub username'.
// 12. init — Initialize with GitHub username server.registerTool( 'init', { description: 'Initialize OSS Autopilot with a GitHub username. Creates the state file and sets up initial configuration.', inputSchema: { username: z.string().describe('Your GitHub username'), }, annotations: { readOnlyHint: false, destructiveHint: false }, }, wrapTool(runInit), ); - The `validateGitHubUsername` helper called by `runInit` to validate the username against GitHub's rules (length, characters, no leading/trailing hyphens, no placeholders).
export function validateGitHubUsername(username: string): string { if (!username || username.trim().length === 0) { throw new ValidationError('GitHub username cannot be empty.'); } const trimmed = username.trim(); if (trimmed.length > MAX_USERNAME_LENGTH) { throw new ValidationError( `GitHub username must be at most ${MAX_USERNAME_LENGTH} characters (got ${trimmed.length}).`, ); } if (!USERNAME_CHARS_PATTERN.test(trimmed)) { throw new ValidationError('GitHub username can only contain alphanumeric characters and hyphens.'); } if (trimmed.startsWith('-')) { throw new ValidationError('GitHub username cannot start with a hyphen.'); } if (trimmed.endsWith('-')) { throw new ValidationError('GitHub username cannot end with a hyphen.'); } if (CONSECUTIVE_HYPHENS_PATTERN.test(trimmed)) { throw new ValidationError('GitHub username cannot contain consecutive hyphens.'); } // Reject the same placeholder strings that pr-monitor's runtime auto-repair // catches. Without this guard `init`, `setup --set username=`, and the MCP // `config` tool happily persist values like "example-user" copied from // documentation, leaving auto-repair to clean up after the next fetch and // surfacing a "showing partial data" banner on the dashboard in the meantime. if (isPlaceholderUsername(trimmed)) { throw new ValidationError( `"${trimmed}" looks like a placeholder from documentation, not a real GitHub username. Use your actual GitHub login.`, ); } return trimmed; }