# GitLink Code

AI-powered coding agent CLI for DevOps. Interactive TUI, non-interactive mode, slash commands, multi-agent workflows.

## Installation

```bash
npm install -g gitlink-code
```

Requires Node.js >= 18.

## Getting Started

### 1. Configure your API key

**Option A — Environment variable (quickest):**
```bash
export DEEPSEEK_API_KEY="sk-your-key-here"
```

**Option B — User config file (recommended):**
```bash
mkdir -p ~/.gc
cat > ~/.gc/settings.json << 'EOF'
{
  "providers": {
    "deepseek": {
      "apiKey": "sk-your-key-here",
      "model": "deepseek-v4-pro"
    }
  }
}
EOF
```

**Option C — Project config (team-shared):**

Place `.gc/settings.json` in your project root. Same format as above.

### 2. Start coding

```bash
gc                          # Interactive TUI mode
gc --print "explain this code"  # Non-interactive mode
```

## CLI Entry Points

| Command | Behavior |
|---------|----------|
| `gc` | Interactive AI coding agent |
| `gitlink code` | Same as `gc` (subcommand form) |
| `gitlinkcode` | Same as `gc` (alias) |
| `gitlink --help` | Show all available commands |

## Configuration

### Config file locations

| File | Scope | Priority |
|------|-------|----------|
| `~/.gc/settings.json` | User-level (all projects) | Lower |
| `.gc/settings.json` | Project-level (single project) | Higher |
| `DEEPSEEK_API_KEY` env var | Session-level | Highest |
| CLI flags (`--model`, `--permission-mode`) | One-off | Highest |

### Full config format

```json
{
  "model": "deepseek-v4-pro",
  "permissionMode": "default",
  "providers": {
    "deepseek": {
      "apiKey": "",
      "baseUrl": "https://api.deepseek.com",
      "model": "deepseek-v4-pro",
      "maxTokens": 8192
    }
  }
}
```

### Permission modes

| Mode | Behavior |
|------|----------|
| `default` | Ask before tools that modify files or run commands |
| `acceptEdits` | Auto-approve Read/Write/Edit, ask for Bash |
| `bypassPermissions` | Auto-approve all tools |

## CLI Options

```
gc [options]

Options:
  -m, --model <model>         Model to use
  -p, --print <query>         Non-interactive mode
  --permission-mode <mode>    default | acceptEdits | bypassPermissions
  --project <path>            Project directory
  --max-turns <n>             Max conversation turns (default: 25)
```

## Slash Commands

| Command | Description |
|---------|-------------|
| `/help` | Show available commands |
| `/specify` | Generate SPEC.md from feature description |
| `/plan` | Generate PLAN.md + TASKS.md |
| `/implement` | Execute tasks from TASKS.md |
| `/validate` | Validate implementation against SPEC |
| `/pr-list` | List pull requests |
| `/pr-review` | Review a PR |
| `/ci-status` | List CI builds |
| `/ci-debug` | Diagnose CI failure |
| `/release-notes` | Generate release notes |
| `/sprint-status` | Generate sprint status report |

## Project Configuration

Place a `CLAUDE.md` or `.gc/config.md` in your project root. Its content is injected into the AI's system prompt as project-specific context.

## Uninstall

```bash
npm uninstall -g gitlink-code
rm -rf ~/.gc
```
