Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
141 changes: 141 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# Contributing to free-code

Terima kasih atas ketertarikan Anda untuk berkontribusi pada free-code! Berikut panduan untuk memulai.

## Quick Start

### Prerequisites

- **Bun** >= 1.3.11 ([install bun](https://bun.sh))
- **Git**
- API key dari provider yang didukung (Anthropic, OpenAI, atau lainnya)

### 1. Fork & Clone

```bash
# Fork via GitHub web
git clone https://github.com/USERNAME/free-code.git
cd free-code
```

### 2. Install & Build

```bash
bun install
bun run build:dev:full
./cli-dev.exe
```

### 3. Development Loop

```bash
bun run build:dev:full
./cli-dev.exe -p "test your changes"
```

---

## Cara Berkontribusi

### 1. Fix Broken Flags (Paling Mudah)

Lihat `FEATURES.md`. Ada 34 feature flags yang gagal bundle karena file hilang. Yang paling mudah diperbaiki:

- Flag dengan "Easy Reconstruction Path" di `FEATURES.md`
- Biasanya hanya perlu buat file wrapper atau asset

Cara cek:
```bash
bun run ./scripts/build.ts --feature=ULTRAPLAN
```

### 2. Tambah Provider API Baru

Fork `src/services/api/` dan buat adapter baru. Contoh yang sudah ada:
- `codex-fetch-adapter.ts` (OpenAI Codex)
- `vertex-fetch-adapter.ts` (Google Vertex)

### 3. Fix Bugs

Cek issue terbuka di GitHub, terutama:
- **#40** - Windows support
- **#38** - Resubmit tool result
- **#37** - Repeating shell results

### 4. Enhancements

- Tambah CLI flags baru
- Tingkatkan UI/UX
- Optimasi performance

---

## Build Commands

| Command | Output | Features |
|---|---|---|
| `bun run build` | `./cli` | Default (VOICE_MODE only) |
| `bun run build:dev` | `./cli-dev` | Dev build |
| `bun run build:dev:full` | `./cli-dev` | All 54 experimental flags |
| `bun run compile` | `./dist/cli` | Compiled binary |

### Custom Feature Flags

```bash
bun run ./scripts/build.ts --feature=ULTRAPLAN --feature=ULTRATHINK
bun run ./scripts/build.ts --dev --feature=BRIDGE_MODE
```

---

## Code Style

- **TypeScript** untuk semua kode
- Gunakan `const` jika memungkinkan
- Jangan tambah dependency baru tanpa diskusi
- Ikuti pola kode yang sudah ada di `src/`
- Gunakan `bun` sebagai runtime

## Commit Message

Format:
```
<type>: <description>

[optional body]

Fixes #<issue_number>
```

Contoh:
```
feat: add DeepSeek v4 provider support
fix: resolve issue #40 Windows installer path
docs: add PowerShell install instructions
```

---

## Submitting Changes

1. Buat branch baru dari `main`
2. Commit dengan message yang jelas
3. Push ke fork Anda
4. Buka Pull Request (PR) ke `freecodexyz/free-code`
5. Tambah deskripsi yang jelas untuk PR

---

## Topik yang Dibutuhkan

- **Windows Support** - Installer PowerShell, path handling
- **Provider Support** - DeepSeek, Mistral, Kimi, Ollama
- **Feature Flags** - Rekonstruksi 34 flag yang rusak
- **Performance** - Optimasi build time dan runtime
- **Bug Fixes** - Tool result handling, bash classifier

---

## Questions?

Buka issue di GitHub atau hubungi maintainer.
7 changes: 7 additions & 0 deletions free-code.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@echo off
:: Set your API key and preferred model here, or use environment variables.
:: Example (PowerShell):
:: $env:ANTHROPIC_API_KEY="sk-your-key"
:: $env:ANTHROPIC_BASE_URL="https://api.anthropic.com"
:: Or use --login to authenticate interactively.
"%~dp0cli.exe" --model claude %*
Comment on lines +1 to +7
222 changes: 222 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
# free-code installer for Windows (no WSL required)
# Usage: powershell -ExecutionPolicy Bypass -File install.ps1

$ErrorActionPreference = "Stop"

# -------------------------------------------------------------------
# Banner
# -------------------------------------------------------------------

Write-Host ""
Write-Host " ___ _ " -ForegroundColor Cyan
Write-Host " / _|_ __ ___ ___ ___ __| | ___ " -ForegroundColor Cyan
Write-Host "| |_| '__/ _ \/ _ \_____ / __/ _` |/ _ \ " -ForegroundColor Cyan
Write-Host "| _| | | __/ __/_____| (_| (_| | __/ " -ForegroundColor Cyan
Write-Host "|_| |_| \___|\___| \___\__,_|\___| " -ForegroundColor Cyan
Write-Host " The free build of Claude Code" -ForegroundColor DarkGray
Write-Host ""

function Info {
Param([string]$Msg)
Write-Host "[*] $Msg" -ForegroundColor Cyan
}
function Ok {
Param([string]$Msg)
Write-Host "[+] $Msg" -ForegroundColor Green
}
function Warn {
Param([string]$Msg)
Write-Host "[!] $Msg" -ForegroundColor Yellow
}
function Fail {
Param([string]$Msg)
Write-Host "[x] $Msg" -ForegroundColor Red
exit 1
}

# -------------------------------------------------------------------
# System checks
# -------------------------------------------------------------------

$OS = if ($PSVersionTable.PSEdition -eq "Desktop") {
if ([Environment]::Is64BitOperatingSystem) { "win64" } else { "win32" }
} else {
"win64"
}
Ok "OS: Windows $OS"

function Test-CommandExists {
Param([string]$Cmd)
$null -ne (Get-Command $Cmd -ErrorAction SilentlyContinue)
}

if (-not (Test-CommandExists "git")) {
Fail "git is not installed. Get it from https://git-scm.com/download/win"
}
$gitVer = git --version | Select-Object -First 1
Ok "git: $gitVer"

$BUN_MIN_VERSION = "1.3.11"

# Check or install Bun
$bunPath = $null
if (Test-CommandExists "bun") {
$bunPath = (Get-Command bun).Source
$bunVer = bun --version 2>$null
$bunVerParts = $bunVer.Split('.')
$minParts = $BUN_MIN_VERSION.Split('.')
$needsUpgrade = $false
for ($i = 0; $i -lt $minParts.Length; $i++) {
$a = [int]$bunVerParts[$i]
$b = [int]$minParts[$i]
if ($a -gt $b) { break }
if ($a -lt $b) { $needsUpgrade = $true; break }
}
Comment on lines +68 to +74
if ($needsUpgrade) {
Warn "Bun v$bunVer found but v${BUN_MIN_VERSION}+ required. Upgrading..."
$bunPath = $null
} else {
Ok "bun: v$bunVer"
}
}

if (-not $bunPath) {
Info "Installing Bun..."
try {
powershell -c "irm https://bun.sh/install.ps1 | iex"
} catch {
# Try iwr fallback
Invoke-RestMethod -Uri "https://bun.sh/install.ps1" | Invoke-Expression
}
Comment on lines +84 to +90

$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
if (Test-CommandExists "bun") {
$bunPath = (Get-Command bun).Source
$bunVer = bun --version
Ok "bun: v$bunVer (just installed)"
} else {
$bunDir = Join-Path $env:LOCALAPPDATA "Programs\bun"
if (Test-Path (Join-Path $bunDir "bun.exe")) {
$bunPath = Join-Path $bunDir "bun.exe"
Ok "bun: found at $bunPath"
# Add to PATH for this session
$env:Path = "$bunDir;$env:Path"
} else {
Fail "Bun installed but not found on PATH. Restart your terminal and retry."
}
}
}

if (-not $bunPath) {
Fail "Bun installation failed. Please install manually from https://bun.sh"
}

# -------------------------------------------------------------------
# Clone repo
# -------------------------------------------------------------------

$REPO = "https://github.com/freecodexyz/free-code.git"
$INSTALL_DIR = Join-Path $env:USERPROFILE "free-code"
$LINK_DIR = Join-Path $env:LOCALAPPDATA "Programs\free-code"
$LINK_PATH = Join-Path $LINK_DIR "free-code.ps1"

Info "Target directory: $INSTALL_DIR"

if (-not (Test-Path $INSTALL_DIR)) {
Info "Cloning repository..."
git clone --depth 1 "$REPO" "$INSTALL_DIR"
Ok "Source: $INSTALL_DIR"
} else {
Info "Directory already exists, pulling latest..."
Push-Location $INSTALL_DIR
try {
git pull --ff-only
Ok "Updated: $INSTALL_DIR"
} catch {
Warn "Pull failed, using existing copy"
}
Pop-Location
}

# -------------------------------------------------------------------
# Build
# -------------------------------------------------------------------

Info "Installing dependencies..."
Push-Location $INSTALL_DIR
& $bunPath install --frozen-lockfile 2>$null
if ($LASTEXITCODE -ne 0) {
Info "Retrying without frozen lockfile..."
& $bunPath install
}
Ok "Dependencies installed"

Info "Building free-code (all experimental features enabled)..."
& $bunPath run build:dev:full
Ok "Build complete"

Pop-Location

# -------------------------------------------------------------------
# Symlink
# -------------------------------------------------------------------

if (-not (Test-Path $LINK_DIR)) {
New-Item -ItemType Directory -Path $LINK_DIR -Force | Out-Null
}

# Create a PowerShell wrapper script
$escapedPath = $INSTALL_DIR.Replace('"', '`"')
$wrapper = @"
`$ErrorActionPreference = 'Stop'
`$ROOT = '$escapedPath'
`$CLI = Join-Path `$ROOT 'cli-dev.exe'
if (Test-Path (Join-Path `$ROOT 'cli.exe')) {
`$CLI = Join-Path `$ROOT 'cli.exe'
}
Set-Location `$ROOT
Comment on lines +174 to +178
& `$CLI @args
"@

$wrapper | Out-File -FilePath $LINK_PATH -Encoding UTF8
Ok "Installed: $LINK_PATH"

# Add to PATH if not already there
$machinePath = [System.Environment]::GetEnvironmentVariable("Path", "Machine")
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")

if ($machinePath -notlike "*$LINK_DIR*" -and $userPath -notlike "*$LINK_DIR*") {
Info "Adding $LINK_DIR to user PATH..."
[System.Environment]::SetEnvironmentVariable("Path", "$userPath;$LINK_DIR", "User")
$env:Path = "$env:Path;$LINK_DIR"
Warn "Please restart your terminal for PATH to take effect."
}

# Register .ps1 execution policy for the link
$execPolicy = Get-ExecutionPolicy -Scope CurrentUser
if ($execPolicy -eq "Restricted") {
Info "Setting execution policy to RemoteSigned for current user..."
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned -Force
}
Comment on lines +196 to +201

# -------------------------------------------------------------------
# Done
# -------------------------------------------------------------------

Write-Host ""
Write-Host " Installation complete!" -ForegroundColor Green
Write-Host ""
Write-Host " Run it:" -ForegroundColor Cyan
Write-Host " free-code.ps1 # interactive REPL" -ForegroundColor Green
Write-Host " free-code.ps1 -p `"your prompt`" # one-shot mode" -ForegroundColor Green
Write-Host " free-code.ps1 /login # authenticate" -ForegroundColor Green
Write-Host ""
Write-Host " Set your API key (optional):" -ForegroundColor Cyan
Write-Host " `$env:ANTHROPIC_API_KEY = `"sk-ant-...`"" -ForegroundColor Green
Write-Host " `$env:CLAUDE_CODE_USE_OPENAI = 1 # use OpenAI Codex" -ForegroundColor DarkGray
Write-Host ""
Write-Host " Source: $INSTALL_DIR" -ForegroundColor DarkGray
Write-Host " Binary: $INSTALL_DIR\cli-dev.exe" -ForegroundColor DarkGray
Write-Host " Launch: $LINK_PATH" -ForegroundColor DarkGray
Write-Host ""
6 changes: 6 additions & 0 deletions run-free-code.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Set your API key via environment variable before running this script.
# Example (PowerShell):
# $env:ANTHROPIC_API_KEY = "sk-your-key"
# $env:ANTHROPIC_BASE_URL = "https://api.anthropic.com"
# Or use --login to authenticate interactively.
& "$PSScriptRoot\cli.exe" @args