Skip to content

[Feature]: Add gitbun init setup wizard that detects the project's framework, sets up .gitbunrc, and configures the optimal AI provider and model for the repository #77

Description

@divyanshim27

Summary

First-time Gitbun users must manually create a .gitbunrc or .smartcommitrc configuration file. The README provides examples but does not walk through what settings to choose for different project types. A gitbun init setup wizard would auto-detect the project type (Node.js, Python, Rust, etc.) and Ollama availability, then write a sensible default config — dramatically reducing onboarding friction for new GSSoC contributors and general users.

Problem

  • New users running npx gitbun for the first time get the rule-based fallback if Ollama is not installed and no API key is configured — with no guidance on how to enable AI.
  • The config format (.smartcommitrc vs .gitbunrc) is inconsistently named — README.md shows both, creating confusion about which one takes precedence.
  • There is no way to discover available Ollama models from within Gitbun — users must separately run ollama list and then manually type the model name into their config.
  • The VS Code extension (gitbun-vscode/) and the frontend playground (frontend/) are separate sub-projects — a user working in the VS Code extension context might need different configuration than a CLI user.

Proposed Solution

A gitbun init command that runs a guided setup:

// src/commands/init.ts
import inquirer from 'inquirer';
import { execSync } from 'child_process';
import { writeFileSync, existsSync } from 'fs';
import chalk from 'chalk';

async function detectOllamaModels(): Promise<string[]> {
  try {
    const output = execSync('ollama list --format json', { stdio: ['pipe', 'pipe', 'ignore'] }).toString();
    const models = JSON.parse(output);
    return models.map((m: { name: string }) => m.name);
  } catch {
    return [];
  }
}

function detectProjectType(): string {
  if (existsSync('Cargo.toml')) return 'rust';
  if (existsSync('pyproject.toml') || existsSync('requirements.txt')) return 'python';
  if (existsSync('go.mod')) return 'go';
  if (existsSync('package.json')) {
    const pkg = JSON.parse(readFileSync('package.json', 'utf-8'));
    if (pkg.dependencies?.next || pkg.devDependencies?.next) return 'nextjs';
    if (pkg.dependencies?.react || pkg.devDependencies?.react) return 'react';
    return 'nodejs';
  }
  return 'generic';
}

export async function runInitWizard() {
  console.log(chalk.cyan('\n🐇 Welcome to Gitbun! Let\'s set up your config.\n'));

  const projectType = detectProjectType();
  const ollamaModels = await detectOllamaModels();
  const hasOllama = ollamaModels.length > 0;

  console.log(chalk.gray(`Detected project type: ${projectType}`));
  console.log(chalk.gray(`Ollama: ${hasOllama ? `✓ (${ollamaModels.length} models available)` : '✗ not detected'}\n`));

  const answers = await inquirer.prompt([
    {
      type: 'list',
      name: 'provider',
      message: 'Which AI provider would you like to use?',
      choices: [
        ...(hasOllama ? [{ name: `Ollama (local, private)`, value: 'ollama' }] : []),
        { name: 'OpenAI (cloud, requires OPENAI_API_KEY)', value: 'openai' },
        { name: 'Anthropic Claude (cloud, requires ANTHROPIC_API_KEY)', value: 'anthropic' },
        { name: 'Rule-based only (no AI)', value: 'none' },
      ],
    },
    {
      type: 'list',
      name: 'model',
      message: 'Which Ollama model?',
      choices: ollamaModels,
      when: (a) => a.provider === 'ollama' && hasOllama,
    },
    {
      type: 'confirm',
      name: 'interactive',
      message: 'Always show preview before committing?',
      default: true,
    },
    {
      type: 'confirm',
      name: 'conventionalCommits',
      message: 'Enforce Conventional Commits format?',
      default: true,
    },
  ]);

  const config = {
    provider: answers.provider === 'none' ? undefined : answers.provider,
    model: answers.model,
    ai: answers.provider !== 'none',
    interactive: answers.interactive,
  };

  const configPath = '.gitbunrc';
  writeFileSync(configPath, JSON.stringify(config, null, 2));

  console.log(chalk.green(`\n✓ Config written to ${configPath}`));
  console.log(chalk.cyan('Run `gitbun` in any repo to generate your first commit message.\n'));
}

Additional Notes

  • If .gitbunrc already exists, gitbun init will ask before overwriting it.
  • The wizard auto-detects available Ollama models by calling ollama list — if Ollama is not installed, the Ollama option is hidden.
  • The final config is always shown to the user for review before writing.
  • gitbun init --yes (non-interactive mode) accepts all defaults for CI/scripted setups.
  • I will add this to the README.md Quick Start section and update the CONTRIBUTING.md setup steps to recommend running gitbun init first.

Could you assign this issue to me?

Labels: enhancement, feature, dx, good first issue, GSSoC 2026

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions