Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions docs/implementation/cli-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,24 @@ The CLI exposes three commands (`search`, `languages`, `feedback`) that mirror t

| Command | Required Args | Options | Description |
|---|---|---|---|
| `init` | — | `-y, --yes` | Set up MCP server for coding agents |
| `search <query>` | `-l, --lang <language>` | `--license <mode>`, `--explain`, `--json` | Search for code examples |
| `languages [query]` | — | `--json` | List or filter supported languages |
| `feedback <solution_id>` | `--accept` or `--reject` | `-m, --message <text>`, `--json` | Submit feedback on a search result |

### `githits init`

```
githits init # Interactive: scan, select agents, confirm each
githits init --yes # Non-interactive: configure all detected agents
```

Scans for installed coding agents and sets up GitHits MCP server for each. Supports Claude Code, Cursor, Windsurf, Claude Desktop, and Codex CLI. Uses CLI commands for agents that support them (Claude Code, Codex) and atomic config file writes for others (Cursor, Windsurf, Claude Desktop).

This command does NOT use `createContainer()` — it creates its own lightweight dependencies since it doesn't need auth or API access. This is intentional: init should work before the user has authenticated.

**File structure:** The init command uses a subdirectory (`src/commands/init/`) because it has distinct submodules (agent definitions, setup handlers, orchestrator). This is an accepted variation for commands with significant internal complexity.

### `githits search`

```
Expand Down Expand Up @@ -75,6 +89,8 @@ Each command follows this pattern:
4. **Register in CLI** — Import and call `registerXxxCommand(program)` in `src/cli.ts`
5. **Update help text** — If the command is a primary workflow, add it to the `addHelpText("after", ...)` block

For complex commands with multiple submodules, a subdirectory (`src/commands/xxx/`) with an `index.ts` barrel is acceptable (see `init` command for example).

## Error Handling

- **Auth errors** — `requireAuth()` prints instructions and calls `process.exit(1)`
Expand Down Expand Up @@ -103,6 +119,11 @@ All commands support two output modes:
| `src/shared/require-auth.ts` | Auth guard shared with MCP server |
| `src/shared/colors.ts` | ANSI color utilities and `shouldUseColors()` |
| `src/container.ts` | Dependency container with `githitsService` |
| `src/commands/init/init.ts` | Init command orchestrator |
| `src/commands/init/agent-definitions.ts` | Agent detection and setup config |
| `src/commands/init/setup-handlers.ts` | CLI exec and config file merge logic |
| `src/services/prompt-service.ts` | Interactive prompt abstraction |
| `src/services/exec-service.ts` | CLI command execution abstraction |

## Related Documentation

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"access": "public"
},
"dependencies": {
"@inquirer/prompts": "^8.3.2",
"@modelcontextprotocol/sdk": "^1.23.0",
"@napi-rs/keyring": "^1.2.0",
"commander": "^14.0.2",
Expand Down
5 changes: 5 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { version } from "../package.json";
import {
registerAuthStatusCommand,
registerFeedbackCommand,
registerInitCommand,
registerLanguagesCommand,
registerLoginCommand,
registerLogoutCommand,
Expand All @@ -27,6 +28,7 @@ program
"after",
`
Getting started:
githits init Set up MCP for your coding agents
githits login Authenticate with your GitHits account
githits mcp Start MCP server for your AI assistant
githits search "query" --lang python Search for code examples
Expand All @@ -36,6 +38,9 @@ Docs: https://app.githits.com/docs/
Support: support@githits.com`,
);

// Setup command
registerInitCommand(program);

// Auth commands
registerLoginCommand(program);
registerLogoutCommand(program);
Expand Down
6 changes: 6 additions & 0 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ export {
feedbackAction,
registerFeedbackCommand,
} from "./feedback.js";
export {
type InitDependencies,
type InitOptions,
initAction,
registerInitCommand,
} from "./init/index.js";
export {
type LanguagesDependencies,
type LanguagesOptions,
Expand Down
Loading
Loading